@tidepool/viz
Version:
Tidepool data visualization for diabetes device data.
2 lines • 703 kB
JavaScript
!function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}var a=n(1),i=r(a),o=new i["default"];onmessage=function(e){o.handleMessage(e,postMessage)},function(){"undefined"!=typeof __REACT_HOT_LOADER__&&__REACT_HOT_LOADER__.register(o,"worker","/Users/clintbeacock/Sites/tidepool/viz/src/worker/index.js")}()},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function a(e){return e&&e.__esModule?e:{"default":e}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(2),u=a(s),d=n(5),l=r(d),M=n(6),_=r(M),f=n(7),p=a(f),h=function(){function e(t,n){o(this,e),this.log=(0,u["default"])("PDFWorker"),this.log("PDFWorker constructed!"),this.importer=t,this.renderer=n}return c(e,[{key:"handleMessage",value:function(e,t){var n=e.data;switch(n.type){case _.GENERATE_PDF_REQUEST:var r=n.payload,a=r.type,o=r.mostRecent,c=r.groupedData,s=r.opts,u=n.meta.origin,d="undefined"!=typeof this.importer?this.importer:importScripts,M="undefined"!=typeof this.renderer?this.renderer:p["default"];d(u+"/pdfkit.js",u+"/blob-stream.js"),M(o,c,s).then(function(e){return t(l.generatePDFSuccess(i({},a,e)))})["catch"](function(e){return t(l.generatePDFFailure(e))});break;default:throw new Error("Unhandled action type ["+n.type+"] passed to Web Worker!")}}}]),e}(),m=h;t["default"]=m,function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(h,"PDFWorker","/Users/clintbeacock/Sites/tidepool/viz/src/worker/PDFWorker.js"),__REACT_HOT_LOADER__.register(m,"default","/Users/clintbeacock/Sites/tidepool/viz/src/worker/PDFWorker.js"))}()},function(e,t,n){(function(t){(function(){function r(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;var e,n=!!window.chrome,r=/firefox/i.test(navigator.userAgent),a=t&&t.versions&&t.versions.electron;if(r){var i=navigator.userAgent.match(/Firefox\/(\d+\.\d+)/);i&&i[1]&&Number(i[1])&&(e=Number(i[1]))}return n||e>=31||a}var a=function(){var e=.618033988749895;return l+=e,l%=1,360*l},i="undefined"==typeof window,o=!i&&window.localStorage,c=o.andlogKey||"debug",s=o[c],u=n(4),d=Function.prototype.bind,l=0,M=15,_=function(){},f=o.debugColors?"false"!==o.debugColors:r(),p=null,h=null,m=!1,b={};s&&"!"===s[0]&&"/"===s[1]&&(m=!0,s=s.slice(1)),h=s&&"/"===s[0]&&new RegExp(s.substring(1,s.length-1));for(var L=["log","debug","warn","error","info"],A=0,y=L.length;A<y;A++)_[L[A]]=_;p=function(e){var t,n,r;if(t=e.slice(0,M),t+=Array(M+3-t.length).join(" ")+"|",h){var i=e.match(h);if(!m&&!i||m&&i)return _}if(!d)return _;var o=[u];if(f){b[e]||(b[e]=a());var c=b[e];t="%c"+t,n="color: hsl("+c+",99%,40%); font-weight: bold",o.push(t,n)}else o.push(t);if(arguments.length>1){var s=Array.prototype.slice.call(arguments,1);o=o.concat(s)}return r=d.apply(u.log,o),L.forEach(function(e){r[e]=d.apply(u[e]||r,o)}),r},p.config=function(e){e.padLength&&(M=e.padLength)},e.exports=p}).call()}).call(t,n(3))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function a(e){if(d===setTimeout)return setTimeout(e,0);if((d===n||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function o(){p&&_&&(p=!1,_.length?f=_.concat(f):h=-1,f.length&&c())}function c(){if(!p){var e=a(o);p=!0;for(var t=f.length;t;){for(_=f,f=[];++h<t;)_&&_[h].run();h=-1,t=f.length}_=null,p=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function u(){}var d,l,M=e.exports={};!function(){try{d="function"==typeof setTimeout?setTimeout:n}catch(e){d=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var _,f=[],p=!1,h=-1;M.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new s(e,t)),1!==f.length||p||a(c)},s.prototype.run=function(){this.fun.apply(null,this.array)},M.title="browser",M.browser=!0,M.env={},M.argv=[],M.version="",M.versions={},M.on=u,M.addListener=u,M.once=u,M.off=u,M.removeListener=u,M.removeAllListeners=u,M.emit=u,M.prependListener=u,M.prependOnceListener=u,M.listeners=function(e){return[]},M.binding=function(e){throw new Error("process.binding is not supported")},M.cwd=function(){return"/"},M.chdir=function(e){throw new Error("process.chdir is not supported")},M.umask=function(){return 0}},function(e,t,n){!function(){var t="undefined"==typeof window,n=!t&&window.localStorage,r={};if(t)return void(e.exports=console);var a=n.andlogKey||"debug";if(n&&n[a]&&window.console)r=window.console;else for(var i="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),o=i.length,c=function(){};o--;)r[i[o]]=c;e.exports=r}()},function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}function a(e,t,n,r){return{type:u.GENERATE_PDF_REQUEST,meta:{WebWorker:!0,origin:document.location.origin},payload:{type:e,mostRecent:t,groupedData:n,opts:r}}}function i(e){return{type:u.GENERATE_PDF_SUCCESS,payload:{pdf:e}}}function o(e){return{type:u.GENERATE_PDF_FAILURE,error:e}}function c(){return{type:u.REMOVE_GENERATED_PDFS}}Object.defineProperty(t,"__esModule",{value:!0}),t.generatePDFRequest=a,t.generatePDFSuccess=i,t.generatePDFFailure=o,t.removeGeneratedPDFS=c;var s=n(6),u=r(s);!function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(a,"generatePDFRequest","/Users/clintbeacock/Sites/tidepool/viz/src/redux/actions/worker.js"),__REACT_HOT_LOADER__.register(i,"generatePDFSuccess","/Users/clintbeacock/Sites/tidepool/viz/src/redux/actions/worker.js"),__REACT_HOT_LOADER__.register(o,"generatePDFFailure","/Users/clintbeacock/Sites/tidepool/viz/src/redux/actions/worker.js"),__REACT_HOT_LOADER__.register(c,"removeGeneratedPDFS","/Users/clintbeacock/Sites/tidepool/viz/src/redux/actions/worker.js"))}()},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=t.FOCUS_TRENDS_CBG_DATE_TRACE="FOCUS_TRENDS_CBG_DATE_TRACE",r=t.FOCUS_TRENDS_CBG_SLICE="FOCUS_TRENDS_CBG_SLICE",a=t.FOCUS_TRENDS_SMBG="FOCUS_TRENDS_SMBG",i=t.FOCUS_TRENDS_SMBG_RANGE_AVG="FOCUS_TRENDS_SMBG_RANGE_AVG",o=t.MARK_SETTINGS_VIEWED="MARK_SETTINGS_VIEWED",c=t.MARK_TRENDS_VIEWED="MARK_TRENDS_VIEWED",s=t.SHOW_CBG_DATE_TRACES="SHOW_CBG_DATE_TRACES",u=t.TOGGLE_SETTINGS_SECTION="TOGGLE_SETTINGS_SECTION",d=t.TURN_OFF_CBG_RANGE="TURN_OFF_CBG_RANGE",l=t.TURN_ON_CBG_RANGE="TURN_ON_CBG_RANGE",M=t.UNFOCUS_TRENDS_CBG_DATE_TRACE="UNFOCUS_TRENDS_CBG_DATE_TRACE",_=t.UNFOCUS_TRENDS_CBG_SLICE="UNFOCUS_TRENDS_CBG_SLICE",f=t.UNFOCUS_TRENDS_SMBG="UNFOCUS_TRENDS_SMBG",p=t.UNFOCUS_TRENDS_SMBG_RANGE_AVG="UNFOCUS_TRENDS_SMBG_RANGE_AVG",h=t.FETCH_PATIENT_DATA_SUCCESS="FETCH_PATIENT_DATA_SUCCESS",m=t.LOGOUT_REQUEST="LOGOUT_REQUEST",b=t.GENERATE_PDF_REQUEST="GENERATE_PDF_REQUEST",L=t.GENERATE_PDF_SUCCESS="GENERATE_PDF_SUCCESS",A=t.GENERATE_PDF_FAILURE="GENERATE_PDF_FAILURE",y=t.REMOVE_GENERATED_PDFS="REMOVE_GENERATED_PDFS";!function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(n,"FOCUS_TRENDS_CBG_DATE_TRACE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(r,"FOCUS_TRENDS_CBG_SLICE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(a,"FOCUS_TRENDS_SMBG","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(i,"FOCUS_TRENDS_SMBG_RANGE_AVG","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(o,"MARK_SETTINGS_VIEWED","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(c,"MARK_TRENDS_VIEWED","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(s,"SHOW_CBG_DATE_TRACES","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(u,"TOGGLE_SETTINGS_SECTION","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(d,"TURN_OFF_CBG_RANGE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(l,"TURN_ON_CBG_RANGE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(M,"UNFOCUS_TRENDS_CBG_DATE_TRACE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(_,"UNFOCUS_TRENDS_CBG_SLICE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(f,"UNFOCUS_TRENDS_SMBG","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(p,"UNFOCUS_TRENDS_SMBG_RANGE_AVG","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(h,"FETCH_PATIENT_DATA_SUCCESS","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(m,"LOGOUT_REQUEST","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(b,"GENERATE_PDF_REQUEST","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(L,"GENERATE_PDF_SUCCESS","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(A,"GENERATE_PDF_FAILURE","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"),__REACT_HOT_LOADER__.register(y,"REMOVE_GENERATED_PDFS","/Users/clintbeacock/Sites/tidepool/viz/src/redux/constants/actionTypes.js"))}()},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n,r,a,i){var o=3;return new _.DailyPrintView(e,t,{bgPrefs:n,chartsPerPage:o,debug:!1,defaultFontSize:8,dpi:f,footerFontSize:8,headerFontSize:14,height:11*f-2*p,margins:{left:p,top:p,right:p,bottom:p},numDays:a,patient:i,summaryHeaderFontSize:10,summaryWidthAsPercentage:.18,timePrefs:r,width:8.5*f-2*p})}function o(e,t,n){var r=n.bgPrefs,a=n.numDays,o=n.patient,c=n.timePrefs;return new s["default"](function(n,s){var u=_.reshapeBgClassesToBgBounds(r),d=_.selectDailyViewData(e,t,a,c),l="undefined"!=typeof PDFDocument?PDFDocument:_.PDFDocument,M="undefined"!=typeof blobStream?blobStream:_.blobStream,f=new l({autoFirstPage:!1,bufferPages:!0,margin:p}),h=f.pipe(M()),m=i(f,d,{bgBounds:u,bgUnits:r.bgUnits},c,a,o);m.render(),f.end(),h.on("finish",function(){var e={blob:h.toBlob(),url:h.toBlobURL("application/pdf")};return n(e)}),h.on("error",function(e){return h.end(),s(e)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.utils=void 0,t.createDailyPrintView=i,t.createPrintPDFPackage=o;var c=n(8),s=r(c),u=n(45),d=r(u),l=n(180),M=n(186),_=t.utils={reshapeBgClassesToBgBounds:l.reshapeBgClassesToBgBounds,selectDailyViewData:M.selectDailyViewData,PDFDocument:function m(){a(this,m)},blobStream:function(){},DailyPrintView:d["default"]},f=72,p=f/2,h=o;t["default"]=h,function(){"undefined"!=typeof __REACT_HOT_LOADER__&&(__REACT_HOT_LOADER__.register(_,"utils","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"),__REACT_HOT_LOADER__.register(f,"DPI","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"),__REACT_HOT_LOADER__.register(p,"MARGIN","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"),__REACT_HOT_LOADER__.register(i,"createDailyPrintView","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"),__REACT_HOT_LOADER__.register(o,"createPrintPDFPackage","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"),__REACT_HOT_LOADER__.register(h,"default","/Users/clintbeacock/Sites/tidepool/viz/src/modules/print/index.js"))}()},function(e,t,n){"use strict";function r(){try{Promise===i&&(Promise=a)}catch(e){}return i}var a;"undefined"!=typeof Promise&&(a=Promise);var i=n(9)();i.noConflict=r,e.exports=i},function(e,t,n){(function(t){"use strict";e.exports=function(){function r(){}function a(e,t){if(null==e||e.constructor!==i)throw new L("the promise constructor cannot be invoked directly\n\n See http://goo.gl/MqrFmX\n");if("function"!=typeof t)throw new L("expecting a function but got "+f.classString(t))}function i(e){e!==y&&a(this,e),this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._resolveFromExecutor(e),this._promiseCreated(),this._fireEvent("promiseCreated",this)}function o(e){this.promise._resolveCallback(e)}function c(e){this.promise._rejectCallback(e,!1)}function s(e){var t=new i(y);t._fulfillmentHandler0=e,t._rejectionHandler0=e,t._promise0=e,t._receiver0=e}var u,d=function(){return new L("circular promise resolution chain\n\n See http://goo.gl/MqrFmX\n")},l=function(){return new i.PromiseInspection(this._target())},M=function(e){return i.reject(new L(e))},_={},f=n(10);u=f.isNode?function(){var e=t.domain;return void 0===e&&(e=null),e}:function(){return null},f.notEnumerableProp(i,"_getDomain",u);var p=n(11),h=n(12),m=new h;p.defineProperty(i,"_async",{value:m});var b=n(16),L=i.TypeError=b.TypeError;i.RangeError=b.RangeError;var A=i.CancellationError=b.CancellationError;i.TimeoutError=b.TimeoutError,i.OperationalError=b.OperationalError,i.RejectionError=b.OperationalError,i.AggregateError=b.AggregateError;var y=function(){},z={},T={},g=n(17)(i,y),v=n(18)(i,y,g,M,r),O=n(19)(i),D=O.create,k=n(20)(i,O),Y=(k.CapturedTrace,n(21)(i,g,T)),S=n(22)(T),N=n(23),w=f.errorObj,W=f.tryCatch;return i.prototype.toString=function(){return"[object Promise]"},i.prototype.caught=i.prototype["catch"]=function(e){var t=arguments.length;if(t>1){var n,r=new Array(t-1),a=0;for(n=0;n<t-1;++n){var i=arguments[n];if(!f.isObject(i))return M("Catch statement predicate: expecting an object but got "+f.classString(i));r[a++]=i}return r.length=a,e=arguments[n],this.then(void 0,S(r,e,this))}return this.then(void 0,e)},i.prototype.reflect=function(){return this._then(l,l,void 0,this,void 0)},i.prototype.then=function(e,t){if(k.warnings()&&arguments.length>0&&"function"!=typeof e&&"function"!=typeof t){var n=".then() only accepts functions but was passed: "+f.classString(e);arguments.length>1&&(n+=", "+f.classString(t)),this._warn(n)}return this._then(e,t,void 0,void 0,void 0)},i.prototype.done=function(e,t){var n=this._then(e,t,void 0,void 0,void 0);n._setIsFinal()},i.prototype.spread=function(e){return"function"!=typeof e?M("expecting a function but got "+f.classString(e)):this.all()._then(e,void 0,void 0,z,void 0)},i.prototype.toJSON=function(){var e={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(e.fulfillmentValue=this.value(),e.isFulfilled=!0):this.isRejected()&&(e.rejectionReason=this.reason(),e.isRejected=!0),e},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new v(this).promise()},i.prototype.error=function(e){return this.caught(f.originatesFromRejection,e)},i.getNewLibraryCopy=e.exports,i.is=function(e){return e instanceof i},i.fromNode=i.fromCallback=function(e){var t=new i(y);t._captureStackTrace();var n=arguments.length>1&&!!Object(arguments[1]).multiArgs,r=W(e)(N(t,n));return r===w&&t._rejectCallback(r.e,!0),t._isFateSealed()||t._setAsyncGuaranteed(),t},i.all=function(e){return new v(e).promise()},i.cast=function(e){var t=g(e);return t instanceof i||(t=new i(y),t._captureStackTrace(),t._setFulfilled(),t._rejectionHandler0=e),t},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(e){var t=new i(y);return t._captureStackTrace(),t._rejectCallback(e,!0),t},i.setScheduler=function(e){if("function"!=typeof e)throw new L("expecting a function but got "+f.classString(e));return m.setScheduler(e)},i.prototype._then=function(e,t,n,r,a){var o=void 0!==a,c=o?a:new i(y),s=this._target(),d=s._bitField;o||(c._propagateFrom(this,3),c._captureStackTrace(),void 0===r&&0!==(2097152&this._bitField)&&(r=0!==(50397184&d)?this._boundValue():s===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,c));var l=u();if(0!==(50397184&d)){var M,_,p=s._settlePromiseCtx;0!==(33554432&d)?(_=s._rejectionHandler0,M=e):0!==(16777216&d)?(_=s._fulfillmentHandler0,M=t,s._unsetRejectionIsUnhandled()):(p=s._settlePromiseLateCancellationObserver,_=new A("late cancellation observer"),s._attachExtraTrace(_),M=t),m.invoke(p,s,{handler:null===l?M:"function"==typeof M&&f.domainBind(l,M),promise:c,receiver:r,value:_})}else s._addCallbacks(e,t,c,r,l);return c},i.prototype._length=function(){return 65535&this._bitField},i.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},i.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},i.prototype._setLength=function(e){this._bitField=this._bitField&-65536|65535&e},i.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},i.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},i.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},i.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},i.prototype._isFinal=function(){return(4194304&this._bitField)>0},i.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},i.prototype._setAsyncGuaranteed=function(){m.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(e){var t=0===e?this._receiver0:this[4*e-4+3];if(t!==_)return void 0===t&&this._isBound()?this._boundValue():t},i.prototype._promiseAt=function(e){return this[4*e-4+2]},i.prototype._fulfillmentHandlerAt=function(e){return this[4*e-4+0]},i.prototype._rejectionHandlerAt=function(e){return this[4*e-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(e){var t=(e._bitField,e._fulfillmentHandler0),n=e._rejectionHandler0,r=e._promise0,a=e._receiverAt(0);void 0===a&&(a=_),this._addCallbacks(t,n,r,a,null)},i.prototype._migrateCallbackAt=function(e,t){var n=e._fulfillmentHandlerAt(t),r=e._rejectionHandlerAt(t),a=e._promiseAt(t),i=e._receiverAt(t);void 0===i&&(i=_),this._addCallbacks(n,r,a,i,null)},i.prototype._addCallbacks=function(e,t,n,r,a){var i=this._length();if(i>=65531&&(i=0,this._setLength(0)),0===i)this._promise0=n,this._receiver0=r,"function"==typeof e&&(this._fulfillmentHandler0=null===a?e:f.domainBind(a,e)),"function"==typeof t&&(this._rejectionHandler0=null===a?t:f.domainBind(a,t));else{var o=4*i-4;this[o+2]=n,this[o+3]=r,"function"==typeof e&&(this[o+0]=null===a?e:f.domainBind(a,e)),"function"==typeof t&&(this[o+1]=null===a?t:f.domainBind(a,t))}return this._setLength(i+1),i},i.prototype._proxy=function(e,t){this._addCallbacks(void 0,void 0,t,e,null)},i.prototype._resolveCallback=function(e,t){if(0===(117506048&this._bitField)){if(e===this)return this._rejectCallback(d(),!1);var n=g(e,this);if(!(n instanceof i))return this._fulfill(e);t&&this._propagateFrom(n,2);var r=n._target();if(r===this)return void this._reject(d());var a=r._bitField;if(0===(50397184&a)){var o=this._length();o>0&&r._migrateCallback0(this);for(var c=1;c<o;++c)r._migrateCallbackAt(this,c);this._setFollowing(),this._setLength(0),this._setFollowee(r)}else if(0!==(33554432&a))this._fulfill(r._value());else if(0!==(16777216&a))this._reject(r._reason());else{var s=new A("late cancellation observer");r._attachExtraTrace(s),this._reject(s)}}},i.prototype._rejectCallback=function(e,t,n){var r=f.ensureErrorObject(e),a=r===e;if(!a&&!n&&k.warnings()){var i="a promise was rejected with a non-error: "+f.classString(e);this._warn(i,!0)}this._attachExtraTrace(r,!!t&&a),this._reject(e)},i.prototype._resolveFromExecutor=function(e){if(e!==y){var t=this;this._captureStackTrace(),this._pushContext();var n=!0,r=this._execute(e,function(e){t._resolveCallback(e)},function(e){t._rejectCallback(e,n)});n=!1,this._popContext(),void 0!==r&&t._rejectCallback(r,!0)}},i.prototype._settlePromiseFromHandler=function(e,t,n,r){var a=r._bitField;if(0===(65536&a)){r._pushContext();var i;t===z?n&&"number"==typeof n.length?i=W(e).apply(this._boundValue(),n):(i=w,i.e=new L("cannot .spread() a non-array: "+f.classString(n))):i=W(e).call(t,n);var o=r._popContext();a=r._bitField,0===(65536&a)&&(i===T?r._reject(n):i===w?r._rejectCallback(i.e,!1):(k.checkForgottenReturns(i,o,"",r,this),r._resolveCallback(i)))}},i.prototype._target=function(){for(var e=this;e._isFollowing();)e=e._followee();return e},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(e){this._rejectionHandler0=e},i.prototype._settlePromise=function(e,t,n,a){var o=e instanceof i,c=this._bitField,s=0!==(134217728&c);0!==(65536&c)?(o&&e._invokeInternalOnCancel(),n instanceof Y&&n.isFinallyHandler()?(n.cancelPromise=e,W(t).call(n,a)===w&&e._reject(w.e)):t===l?e._fulfill(l.call(n)):n instanceof r?n._promiseCancelled(e):o||e instanceof v?e._cancel():n.cancel()):"function"==typeof t?o?(s&&e._setAsyncGuaranteed(),this._settlePromiseFromHandler(t,n,a,e)):t.call(n,a,e):n instanceof r?n._isResolved()||(0!==(33554432&c)?n._promiseFulfilled(a,e):n._promiseRejected(a,e)):o&&(s&&e._setAsyncGuaranteed(),0!==(33554432&c)?e._fulfill(a):e._reject(a))},i.prototype._settlePromiseLateCancellationObserver=function(e){var t=e.handler,n=e.promise,r=e.receiver,a=e.value;"function"==typeof t?n instanceof i?this._settlePromiseFromHandler(t,r,a,n):t.call(r,a,n):n instanceof i&&n._reject(a)},i.prototype._settlePromiseCtx=function(e){this._settlePromise(e.promise,e.handler,e.receiver,e.value)},i.prototype._settlePromise0=function(e,t,n){var r=this._promise0,a=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(r,e,a,t)},i.prototype._clearCallbackDataAtIndex=function(e){var t=4*e-4;this[t+2]=this[t+3]=this[t+0]=this[t+1]=void 0},i.prototype._fulfill=function(e){var t=this._bitField;if(!((117506048&t)>>>16)){if(e===this){var n=d();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=e,(65535&t)>0&&(0!==(134217728&t)?this._settlePromises():m.settlePromises(this))}},i.prototype._reject=function(e){var t=this._bitField;if(!((117506048&t)>>>16))return this._setRejected(),this._fulfillmentHandler0=e,this._isFinal()?m.fatalError(e,f.isNode):void((65535&t)>0?m.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(e,t){for(var n=1;n<e;n++){var r=this._fulfillmentHandlerAt(n),a=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(a,r,i,t)}},i.prototype._rejectPromises=function(e,t){for(var n=1;n<e;n++){var r=this._rejectionHandlerAt(n),a=this._promiseAt(n),i=this._receiverAt(n);this._clearCallbackDataAtIndex(n),this._settlePromise(a,r,i,t)}},i.prototype._settlePromises=function(){var e=this._bitField,t=65535&e;if(t>0){if(0!==(16842752&e)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,e),this._rejectPromises(t,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,e),this._fulfillPromises(t,r)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var e=this._bitField;return 0!==(33554432&e)?this._rejectionHandler0:0!==(16777216&e)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){k.deprecated("Promise.defer","new Promise");var e=new i(y);return{promise:e,resolve:o,reject:c}},f.notEnumerableProp(i,"_makeSelfResolutionError",d),n(24)(i,y,g,M,k),n(25)(i,y,g,k),n(26)(i,v,M,k),n(27)(i),n(28)(i),n(29)(i,v,g,y,m,u),i.Promise=i,i.version="3.5.0",n(30)(i,v,M,g,y,k),n(31)(i),n(32)(i,M,g,D,y,k),n(33)(i,y,k),n(34)(i,M,y,g,r,k),n(35)(i),n(36)(i,y),n(37)(i,v,g,M),n(38)(i,y,g,M),n(39)(i,v,M,g,y,k),n(40)(i,v,k),n(41)(i,v,M),n(42)(i,y),n(43)(i,y),n(44)(i),f.toFastProperties(i),f.toFastProperties(i.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new i(y)),k.setBounds(h.firstLineError,f.lastLineError),i}}).call(t,n(3))},function(e,t,n){(function(t,r){"use strict";function a(){try{var e=S;return S=null,e.apply(this,arguments)}catch(t){return Y.e=t,Y}}function i(e){return S=e,a}function o(e){return null==e||e===!0||e===!1||"string"==typeof e||"number"==typeof e}function c(e){return"function"==typeof e||"object"==typeof e&&null!==e}function s(e){return o(e)?new Error(m(e)):e}function u(e,t){var n,r=e.length,a=new Array(r+1);for(n=0;n<r;++n)a[n]=e[n];return a[n]=t,a}function d(e,t,n){if(!D.isES5)return{}.hasOwnProperty.call(e,t)?e[t]:void 0;var r=Object.getOwnPropertyDescriptor(e,t);return null!=r?null==r.get&&null==r.set?r.value:n:void 0}function l(e,t,n){if(o(e))return e;var r={value:n,configurable:!0,enumerable:!1,writable:!0};return D.defineProperty(e,t,r),e}function M(e){throw e}function _(e){try{if("function"==typeof e){var t=D.names(e.prototype),n=D.isES5&&t.length>1,r=t.length>0&&!(1===t.length&&"constructor"===t[0]),a=q.test(e+"")&&D.names(e).length>0;if(n||r||a)return!0}return!1}catch(i){return!1}}function f(e){function t(){}t.prototype=e;for(var n=8;n--;)new t;return e}function p(e){return E.test(e)}function h(e,t,n){for(var r=new Array(e),a=0;a<e;++a)r[a]=t+a+n;return r}function m(e){try{return e+""}catch(t){return"[no string representation]"}}function b(e){return null!==e&&"object"==typeof e&&"string"==typeof e.message&&"string"==typeof e.name}function L(e){try{l(e,"isOperational",!0)}catch(t){}}function A(e){return null!=e&&(e instanceof Error.__BluebirdErrorTypes__.OperationalError||e.isOperational===!0)}function y(e){return b(e)&&D.propertyIsWritable(e,"stack")}function z(e){return{}.toString.call(e)}function T(e,t,n){for(var r=D.names(e),a=0;a<r.length;++a){var i=r[a];if(n(i))try{D.defineProperty(t,i,D.getDescriptor(e,i))}catch(o){}}}function g(e){return H?r.env[e]:void 0}function v(){if("function"==typeof Promise)try{var e=new Promise(function(){});if("[object Promise]"==={}.toString.call(e))return Promise}catch(t){}}function O(e,t){return e.bind(t)}var D=n(11),k="undefined"==typeof navigator,Y={e:{}},S,N="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0!==this?this:null,w=function(e,t){function n(){this.constructor=e,this.constructor$=t;for(var n in t.prototype)r.call(t.prototype,n)&&"$"!==n.charAt(n.length-1)&&(this[n+"$"]=t.prototype[n])}var r={}.hasOwnProperty;return n.prototype=t.prototype,e.prototype=new n,e.prototype},W=function(){var e=[Array.prototype,Object.prototype,Function.prototype],t=function(t){for(var n=0;n<e.length;++n)if(e[n]===t)return!0;return!1};if(D.isES5){var n=Object.getOwnPropertyNames;return function(e){for(var r=[],a=Object.create(null);null!=e&&!t(e);){var i;try{i=n(e)}catch(o){return r}for(var c=0;c<i.length;++c){var s=i[c];if(!a[s]){a[s]=!0;var u=Object.getOwnPropertyDescriptor(e,s);null!=u&&null==u.get&&null==u.set&&r.push(s)}}e=D.getPrototypeOf(e)}return r}}var r={}.hasOwnProperty;return function(n){if(t(n))return[];var a=[];e:for(var i in n)if(r.call(n,i))a.push(i);else{for(var o=0;o<e.length;++o)if(r.call(e[o],i))continue e;a.push(i)}return a}}(),q=/this\s*\.\s*\S+\s*=/,E=/^[a-z$_][a-z$_0-9]*$/i,B=function(){return"stack"in new Error?function(e){return y(e)?e:new Error(m(e))}:function(e){if(y(e))return e;try{throw new Error(m(e))}catch(t){return t}}}(),C=function(e){return D.isArray(e)?e:null};if("undefined"!=typeof Symbol&&Symbol.iterator){var X="function"==typeof Array.from?function(e){return Array.from(e)}:function(e){for(var t,n=[],r=e[Symbol.iterator]();!(t=r.next()).done;)n.push(t.value);return n};C=function(e){return D.isArray(e)?e:null!=e&&"function"==typeof e[Symbol.iterator]?X(e):null}}var R="undefined"!=typeof r&&"[object process]"===z(r).toLowerCase(),H="undefined"!=typeof r&&"undefined"!=typeof r.env,x={isClass:_,isIdentifier:p,inheritedDataKeys:W,getDataPropertyOrDefault:d,thrower:M,isArray:D.isArray,asArray:C,notEnumerableProp:l,isPrimitive:o,isObject:c,isError:b,canEvaluate:k,errorObj:Y,tryCatch:i,inherits:w,withAppended:u,maybeWrapAsError:s,toFastProperties:f,filledRange:h,toString:m,canAttachTrace:y,ensureErrorObject:B,originatesFromRejection:A,markAsOriginatingFromRejection:L,classString:z,copyDescriptors:T,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:R,hasEnvVariables:H,env:g,global:N,getNativePromise:v,domainBind:O};x.isRecentNode=x.isNode&&function(){var e=r.versions.node.split(".").map(Number);return 0===e[0]&&e[1]>10||e[0]>0}(),x.isNode&&x.toFastProperties(r);try{throw new Error}catch(j){x.lastLineError=j}e.exports=x}).call(t,function(){return this}(),n(3))},function(e,t){var n=function(){"use strict";return void 0===this}();if(n)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:n,propertyIsWritable:function(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return!(n&&!n.writable&&!n.set)}};else{var r={}.hasOwnProperty,a={}.toString,i={}.constructor.prototype,o=function(e){var t=[];for(var n in e)r.call(e,n)&&t.push(n);return t},c=function(e,t){return{value:e[t]}},s=function(e,t,n){return e[t]=n.value,e},u=function(e){return e},d=function(e){try{return Object(e).constructor.prototype}catch(t){return i}},l=function(e){try{return"[object Array]"===a.call(e)}catch(t){return!1}};e.exports={isArray:l,keys:o,names:o,defineProperty:s,getDescriptor:c,freeze:u,getPrototypeOf:d,isES5:n,propertyIsWritable:function(){return!0}}}},function(e,t,n){(function(t){"use strict";function r(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new d(16),this._normalQueue=new d(16),this._haveDrainedQueues=!1,this._trampolineEnabled=!0;var e=this;this.drainQueues=function(){e._drainQueues()},this._schedule=u}function a(e,t,n){this._lateQueue.push(e,t,n),this._queueTick()}function i(e,t,n){this._normalQueue.push(e,t,n),this._queueTick()}function o(e){this._normalQueue._pushOne(e),this._queueTick()}var c;try{throw new Error}catch(s){c=s}var u=n(13),d=n(15),l=n(10);r.prototype.setScheduler=function(e){var t=this._schedule;return this._schedule=e,this._customScheduler=!0,t},r.prototype.hasCustomScheduler=function(){return this._customScheduler},r.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},r.prototype.disableTrampolineIfNecessary=function(){l.hasDevTools&&(this._trampolineEnabled=!1);
},r.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},r.prototype.fatalError=function(e,n){n?(t.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),t.exit(2)):this.throwLater(e)},r.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(n){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},l.hasDevTools?(r.prototype.invokeLater=function(e,t,n){this._trampolineEnabled?a.call(this,e,t,n):this._schedule(function(){setTimeout(function(){e.call(t,n)},100)})},r.prototype.invoke=function(e,t,n){this._trampolineEnabled?i.call(this,e,t,n):this._schedule(function(){e.call(t,n)})},r.prototype.settlePromises=function(e){this._trampolineEnabled?o.call(this,e):this._schedule(function(){e._settlePromises()})}):(r.prototype.invokeLater=a,r.prototype.invoke=i,r.prototype.settlePromises=o),r.prototype._drainQueue=function(e){for(;e.length()>0;){var t=e.shift();if("function"==typeof t){var n=e.shift(),r=e.shift();t.call(n,r)}else t._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=r,e.exports.firstLineError=c}).call(t,n(3))},function(e,t,n){(function(t,r,a){"use strict";var i,o=n(10),c=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},s=o.getNativePromise();if(o.isNode&&"undefined"==typeof MutationObserver){var u=t.setImmediate,d=r.nextTick;i=o.isRecentNode?function(e){u.call(t,e)}:function(e){d.call(r,e)}}else if("function"==typeof s&&"function"==typeof s.resolve){var l=s.resolve();i=function(e){l.then(e)}}else i="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&(window.navigator.standalone||window.cordova)?"undefined"!=typeof a?function(e){a(e)}:"undefined"!=typeof setTimeout?function(e){setTimeout(e,0)}:c:function(){var e=document.createElement("div"),t={attributes:!0},n=!1,r=document.createElement("div"),a=new MutationObserver(function(){e.classList.toggle("foo"),n=!1});a.observe(r,t);var i=function(){n||(n=!0,r.classList.toggle("foo"))};return function(n){var r=new MutationObserver(function(){r.disconnect(),n()});r.observe(e,t),i()}}();e.exports=i}).call(t,function(){return this}(),n(3),n(14).setImmediate)},function(e,t,n){(function(e,r){function a(e,t){this._id=e,this._clearFn=t}var i=n(3).nextTick,o=Function.prototype.apply,c=Array.prototype.slice,s={},u=0;t.setTimeout=function(){return new a(o.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new a(o.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},t.setImmediate="function"==typeof e?e:function(e){var n=u++,r=!(arguments.length<2)&&c.call(arguments,1);return s[n]=!0,i(function(){s[n]&&(r?e.apply(null,r):e.call(null),t.clearImmediate(n))}),n},t.clearImmediate="function"==typeof r?r:function(e){delete s[e]}}).call(t,n(14).setImmediate,n(14).clearImmediate)},function(e,t){"use strict";function n(e,t,n,r,a){for(var i=0;i<a;++i)n[i+r]=e[i+t],e[i+t]=void 0}function r(e){this._capacity=e,this._length=0,this._front=0}r.prototype._willBeOverCapacity=function(e){return this._capacity<e},r.prototype._pushOne=function(e){var t=this.length();this._checkCapacity(t+1);var n=this._front+t&this._capacity-1;this[n]=e,this._length=t+1},r.prototype.push=function(e,t,n){var r=this.length()+3;if(this._willBeOverCapacity(r))return this._pushOne(e),this._pushOne(t),void this._pushOne(n);var a=this._front+r-3;this._checkCapacity(r);var i=this._capacity-1;this[a+0&i]=e,this[a+1&i]=t,this[a+2&i]=n,this._length=r},r.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},r.prototype.length=function(){return this._length},r.prototype._checkCapacity=function(e){this._capacity<e&&this._resizeTo(this._capacity<<1)},r.prototype._resizeTo=function(e){var t=this._capacity;this._capacity=e;var r=this._front,a=this._length,i=r+a&t-1;n(this,0,this,t,i)},e.exports=r},function(e,t,n){"use strict";function r(e,t){function n(r){return this instanceof n?(l(this,"message","string"==typeof r?r:t),l(this,"name",e),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return d(n,Error),n}function a(e){return this instanceof a?(l(this,"name","OperationalError"),l(this,"message",e),this.cause=e,this.isOperational=!0,void(e instanceof Error?(l(this,"message",e.message),l(this,"stack",e.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new a(e)}var i,o,c=n(11),s=c.freeze,u=n(10),d=u.inherits,l=u.notEnumerableProp,M=r("Warning","warning"),_=r("CancellationError","cancellation error"),f=r("TimeoutError","timeout error"),p=r("AggregateError","aggregate error");try{i=TypeError,o=RangeError}catch(h){i=r("TypeError","type error"),o=r("RangeError","range error")}for(var m="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),b=0;b<m.length;++b)"function"==typeof Array.prototype[m[b]]&&(p.prototype[m[b]]=Array.prototype[m[b]]);c.defineProperty(p.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),p.prototype.isOperational=!0;var L=0;p.prototype.toString=function(){var e=Array(4*L+1).join(" "),t="\n"+e+"AggregateError of:\n";L++,e=Array(4*L+1).join(" ");for(var n=0;n<this.length;++n){for(var r=this[n]===this?"[Circular AggregateError]":this[n]+"",a=r.split("\n"),i=0;i<a.length;++i)a[i]=e+a[i];r=a.join("\n"),t+=r+"\n"}return L--,t},d(a,Error);var A=Error.__BluebirdErrorTypes__;A||(A=s({CancellationError:_,TimeoutError:f,OperationalError:a,RejectionError:a,AggregateError:p}),c.defineProperty(Error,"__BluebirdErrorTypes__",{value:A,writable:!1,enumerable:!1,configurable:!1})),e.exports={Error:Error,TypeError:i,RangeError:o,CancellationError:A.CancellationError,OperationalError:A.OperationalError,TimeoutError:A.TimeoutError,AggregateError:A.AggregateError,Warning:M}},function(e,t,n){"use strict";e.exports=function(e,t){function r(n,r){if(d(n)){if(n instanceof e)return n;var a=i(n);if(a===u){r&&r._pushContext();var s=e.reject(a.e);return r&&r._popContext(),s}if("function"==typeof a){if(o(n)){var s=new e(t);return n._then(s._fulfill,s._reject,void 0,s,null),s}return c(n,a,r)}}return n}function a(e){return e.then}function i(e){try{return a(e)}catch(t){return u.e=t,u}}function o(e){try{return l.call(e,"_promise0")}catch(t){return!1}}function c(n,r,a){function i(e){c&&(c._resolveCallback(e),c=null)}function o(e){c&&(c._rejectCallback(e,l,!0),c=null)}var c=new e(t),d=c;a&&a._pushContext(),c._captureStackTrace(),a&&a._popContext();var l=!0,M=s.tryCatch(r).call(n,i,o);return l=!1,c&&M===u&&(c._rejectCallback(M.e,!0,!0),c=null),d}var s=n(10),u=s.errorObj,d=s.isObject,l={}.hasOwnProperty;return r}},function(e,t,n){"use strict";e.exports=function(e,t,r,a,i){function o(e){switch(e){case-2:return[];case-3:return{};case-6:return new Map}}function c(n){var r=this._promise=new e(t);n instanceof e&&r._propagateFrom(n,3),r._setOnCancel(this),this._values=n,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var s=n(10);s.isArray;return s.inherits(c,i),c.prototype.length=function(){return this._length},c.prototype.promise=function(){return this._promise},c.prototype._init=function u(t,n){var i=r(this._values,this._promise);if(i instanceof e){i=i._target();var c=i._bitField;if(this._values=i,0===(50397184&c))return this._promise._setAsyncGuaranteed(),i._then(u,this._reject,void 0,this,n);if(0===(33554432&c))return 0!==(16777216&c)?this._reject(i._reason()):this._cancel();i=i._value()}if(i=s.asArray(i),null===i){var d=a("expecting an array or an iterable object but got "+s.classString(i)).reason();return void this._promise._rejectCallback(d,!1)}return 0===i.length?void(n===-5?this._resolveEmptyArray():this._resolve(o(n))):void this._iterate(i)},c.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var a=this._promise,i=!1,o=null,c=0;c<n;++c){var s=r(t[c],a);s instanceof e?(s=s._target(),o=s._bitField):o=null,i?null!==o&&s.suppressUnhandledRejections():null!==o?0===(50397184&o)?(s._proxy(this,c),this._values[c]=s):i=0!==(33554432&o)?this._promiseFulfilled(s._value(),c):0!==(16777216&o)?this._promiseRejected(s._reason(),c):this._promiseCancelled(c):i=this._promiseFulfilled(s,c)}i||a._setAsyncGuaranteed()},c.prototype._isResolved=function(){return null===this._values},c.prototype._resolve=function(e){this._values=null,this._promise._fulfill(e)},c.prototype._cancel=function(){!this._isResolved()&&this._promise._isCancellable()&&(this._values=null,this._promise._cancel())},c.prototype._reject=function(e){this._values=null,this._promise._rejectCallback(e,!1)},c.prototype._promiseFulfilled=function(e,t){this._values[t]=e;var n=++this._totalResolved;return n>=this._length&&(this._resolve(this._values),!0)},c.prototype._promiseCancelled=function(){return this._cancel(),!0},c.prototype._promiseRejected=function(e){return this._totalResolved++,this._reject(e),!0},c.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n<t.length;++n)t[n]instanceof e&&t[n].cancel()}},c.prototype.shouldCopyValues=function(){return!0},c.prototype.getActualLength=function(e){return e},c}},function(e,t){"use strict";e.exports=function(e){function t(){this._trace=new t.CapturedTrace(r())}function n(){if(a)return new t}function r(){var e=i.length-1;if(e>=0)return i[e]}var a=!1,i=[];return e.prototype._promiseCreated=function(){},e.prototype._pushContext=function(){},e.prototype._popContext=function(){return null},e._peekContext=e.prototype._peekContext=function(){},t.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,i.push(this._trace))},t.prototype._popContext=function(){if(void 0!==this._trace){var e=i.pop(),t=e._promiseCreated;return e._promiseCreated=null,t}return null},t.CapturedTrace=null,t.create=n,t.deactivateLongStackTraces=function(){},t.activateLongStackTraces=function(){var n=e.prototype._pushContext,i=e.prototype._popContext,o=e._peekContext,c=e.prototype._peekContext,s=e.prototype._promiseCreated;t.deactivateLongStackTraces=function(){e.prototype._pushContext=n,e.prototype._popContext=i,e._peekContext=o,e.prototype._peekContext=c,e.prototype._promiseCreated=s,a=!1},a=!0,e.prototype._pushContext=t.prototype._pushContext,e.prototype._popContext=t.prototype._popContext,e._peekContext=e.prototype._peekContext=r,e.prototype._promiseCreated=function(){var e=this._peekContext();e&&null==e._promiseCreated&&(e._promiseCreated=this)}},t}},function(e,t,n){(function(t){"use strict";e.exports=function(e,r){function a(e,t){return{promise:t}}function i(){return!1}function o(e,t,n){var r=this;try{e(t,n,function(e){if("function"!=typeof e)throw new TypeError("onCancel must be a function, got: "+R.toString(e));r._attachCancellationCallback(e)})}catch(a){return a}}function c(e){if(!this._isCancellable())return this;var t=this._onCancel();void 0!==t?R.isArray(t)?t.push(e):this._setOnCancel([t,e]):this._setOnCancel(e)}function s(){return this._onCancelField}function u(e){this._onCancelField=e}function d(){this._cancellationParent=void 0,this._onCancelField=void 0}function l(e,t){if(0!==(1&t)){this._cancellationParent=e;var n=e._branchesRemainingToCancel;void 0===n&&(n=0),e._branchesRemainingToCancel=n+1}0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function M(e,t){0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function _(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t}function f(){this._trace=new w(this._peekContext())}function p(e,t){if(H(e)){var n=this._trace;if(void 0!==n&&t&&(n=n._parent),void 0!==n)n.attachExtraTrace(e);else if(!e.__stackCleaned__){var r=g(e);R.notEnumerableProp(e,"stack",r.message+"\n"+r.stack.join("\n")),R.notEnumerableProp(e,"__stackCleaned__",!0)}}}function h(e,t,n,r,a){if(void 0===e&&null!==t&&K){if(void 0!==a&&a._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var i="",o="";if(t._trace){for(var c=t._trace.stack.split("\n"),s=z(c),u=s.length-1;u>=0;--u){var d=s[u];if(!j.test(d)){var l=d.match(P);l&&(i="at "+l[1]+":"+l[2]+":"+l[3]+" ");break}}if(s.length>0)for(var M=s[0],u=0;u<c.length;++u)if(c[u]===M){u>0&&(o="\n"+c[u-1]);break}}var _="a promise was created in a "+n+"handler "+i+"but was not returned from it, see http://goo.gl/rRqMUw"+o;r._warn(_,!0,t)}}function m(e,t){var n=e+" is deprecated and will be removed in a future version.";return t&&(n+=" Use "+t+" instead."),b(n)}function b(t,n,r){if(oe.warnings){var a,i=new X(t);if(n)r._attachExtraTrace(i);else if(oe.longStackTraces&&(a=e._peekContext()))a.attachExtraTrace(i);else{var o=g(i);i.stack=o.message+"\n"+o.stack.join("\n")}te("warning",i)||v(i,"",!0)}}function L(e,t){for(var n=0;n<t.length-1;++n)t[n].push("From previous event:"),t[n]=t[n].join("\n");return n<t.length&&(t[n]=t[n].join("\n")),e+"\n"+t.join("\n")}function A(e){for(var t=0;t<e.length;++t)(0===e[t].length||t+1<e.length&&e[t][0]===e[t+1][0])&&(e.splice(t,1),t--)}function y(e){for(var t=e[0],n=1;n<e.length;++n){for(var r=e[n],a=t.length-1,i=t[a],o=-1,c=r.length-1;c>=0;--c)if(r[c]===i){o=c;break}for(var c=o;c>=0;--c){var s=r[c];if(t[a]!==s)break;t.pop(),a--}t=r}}function z(e){for(var t=[],n=0;n<e.length;++n){var r=e[n],a=" (No stack trace)"===r||F.test(r),i=a&&re(r);a&&!i&&(I&&" "!==r.charAt(0)&&(r=" "+r),t.push(r))}return t}function T(e){for(var t=e.stack.replace(/\s+$/g,"").split("\n"),n=0;n<t.length;++n){var r=t[n];if(" (No stack trace)"===r||F.test(r))break}return n>0&&"SyntaxError"!=e.name&&(t=t.slice(n)),t}function g(e){var t=e.stack,n=e.toString();return t="string"==typeof t&&t.length>0?T(e):[" (No stack trace)"],{message:n,stack:"SyntaxError"==e.name?t:z(t)}}function v(e,t,n){if("undefined"!=typeof console){var r;if(R.isObject(e)){var a=e.stack;r=t+U(a,e)}else r=t+String(e);"function"==typeof E?E(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function O(e,t,n,r){var a=!1;try{"function"==typeof t&&(a=!0,"rejectionHandled"===e?t(r):t(n,r))}catch(i){C.throwLater(i)}"unhandledRejection"===e?te(e,n,r)||a||v(n,"Unhandled rejection "):te(e,r)}function D(e){var t;if("function"==typeof e)t="[function "+(e.name||"anonymous")+"]";else{t=e&&"function"==typeof e.toString?e.toString():R.toString(e);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(t))try{var r=JSON.stringify(e);t=r}catch(a){}0===t.length&&(t="(empty array)")}return"(<"+k(t)+">, no stack trace)"}function k(e){var t=41;return e.length<t?e:e.substr(0,t-3)+"..."}function Y(){return"function"==typeof ie}function S(e){var t=e.match(ae);if(t)return{fileName:t[1],line:parseInt(t[2],10)}}function N(e,t){if(Y()){for(var n,r,a=e.stack.split("\n"),i=t.stack.split("\n"),o=-1,c=-1,s=0;s<a.length;++s){var u=S(a[s]);if(u){n=u.fileName,o=u.line;break}}for(var s=0;s<i.length;++s){var u=S(i[s]);if(u){r=u.fileName,c=u.line;break}}o<0||c<0||!n||!r||n!==r||o>=c||(re=function(e){if(x.test(e))return!0;var t=S(e);return!!(t&&t.fileName===n&&o<=t.line&&t.line<=c)})}}function w(e){this._parent=e,this._promisesCreated=0;var t=this._length=1+(void 0===e?0:e._length);ie(this,w),t>32&&this.uncycle()}var W,q,E,B=e._getDomain,C=e._async,X=n(16).Warning,R=n(10),H=R.canAttachTrace,x=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,j=/\((?:timers\.js):\d+:\d+\)/,P=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,F=null,U=null,I=!1,G=!(0==R.env("BLUEBIRD_DEBUG")||!R.env("BLUEBIRD_DEBUG")&&"development"!==R.env("NODE_ENV")),J=!(0==R.env("BLUEBIRD_WARNINGS")||!G&&!R.env("BLUEBIRD_WARNINGS")),V=!(0==R.env("BLUEBIRD_LONG_STACK_TRACES")||!G&&!R.env("BLUEBIRD_LONG_STACK_TRACES")),K=0!=R.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!R.env("BLUEBIRD_W_FORGOTTEN_RETURN"));e.prototype.suppressUnhandledRejections=function(){var e=this._target();e._bitField=e._bitField&-1048577|524288},e.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),C.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){O("rejectionHandled",W,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(),O("unhandledRejection",q,e,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-262145},e.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-1048577,this._isUnhandledRejectionNotifi