diff --git a/CHANGELOG b/CHANGELOG index b162aab9f..00ed315da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +------------------------------------------------------------------------------- +0.1.1 +------------------------------------------------------------------------------- +* Remove percentageIncluded field from JSON schema, which is not needed. +------------------------------------------------------------------------------- + ------------------------------------------------------------------------------- 0.1.0 ------------------------------------------------------------------------------- diff --git a/dist/optimizely.min.js b/dist/optimizely.min.js index d1a036c3c..be6b86c83 100644 --- a/dist/optimizely.min.js +++ b/dist/optimizely.min.js @@ -1,6 +1,6 @@ -!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var n=r(1),i=r(3),o=r(6),a=r(7),s=r(5),c=r(11),u=r(12);t.exports={createInstance:function(t){var e=c.createLogger({logLevel:s.LOG_LEVEL.INFO});if(t)try{i.validate(t)}catch(r){e.log(s.LOG_LEVEL.ERROR,r.message)}return t=n.assignIn({errorHandler:o,eventDispatcher:a,logger:c.createLogger({logLevel:s.LOG_LEVEL.INFO})},t),new u(t)}}},function(t,e,r){var n;(function(t,i){(function(){function o(t,e){return t.push.apply(t,e),t}function a(t,e,r,n){for(var i=t.length,o=r+(n?1:-1);n?o--:++o0&&r(c)?e>1?E(c,e-1,r,n,i):o(i,c):n||(i[i.length]=c)}return i}function x(t,e){return t&&Be(t,e,rr)}function j(t,e){return b(e,function(e){return Tt(t[e])})}function w(t,e){return t>e}function O(t,e,r,n,i){return t===e?!0:null==t||null==e||!Pt(t)&&!Nt(e)?t!==t&&e!==e:I(t,e,O,r,n,i)}function I(t,e,r,n,i,o){var a=Ze(t),s=Ze(e),c=he,u=he;a||(c=Pe.call(t),c=c==pe?be:c),s||(u=Pe.call(e),u=u==pe?be:u);var l=c==be&&!f(t),p=u==be&&!f(e),h=c==u;o||(o=[]);var d=Ke(o,function(e){return e[0]===t});if(d&&d[1])return d[1]==e;if(o.push([t,e]),h&&!l){var v=a?$(t,e,r,n,i,o):X(t,e,c,r,n,i,o);return o.pop(),v}if(!(i&ue)){var _=l&&Te.call(t,"__wrapped__"),y=p&&Te.call(e,"__wrapped__");if(_||y){var m=_?t.value():t,g=y?e.value():e,v=r(m,g,n,i,o);return o.pop(),v}}if(!h)return!1;var v=Z(t,e,r,n,i,o);return o.pop(),v}function A(t){return"function"==typeof t?t:null==t?Zt:("object"==typeof t?T:P)(t)}function S(t){return Ue(Object(t))}function C(t){t=null==t?t:Object(t);var e=[];for(var r in t)e.push(r);return e}function R(t,e){return e>t}function k(t,e){var r=-1,n=Ot(t)?Array(t.length):[];return Ge(t,function(t,i,o){n[++r]=e(t,i,o)}),n}function T(t){var e=rr(t);return function(r){var n=e.length;if(null==r)return!n;for(r=Object(r);n--;){var i=e[n];if(!(i in r&&O(t[i],r[i],ne,ce|ue)))return!1}return!0}}function F(t,e){return t=Object(t),dt(e,function(e,r){return r in t&&(e[r]=t[r]),e},{})}function P(t){return function(e){return null==e?ne:e[t]}}function N(t,e,r){var n=-1,i=t.length;0>e&&(e=-e>i?0:i+e),r=r>i?i:r,0>r&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&c&&!s&&!u||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!u&&e>t||u&&r&&i&&!n&&!o||s&&r&&i||!a&&i||!c)return-1}return 0}function M(t,e,r,n){r||(r={});for(var i=-1,o=e.length;++i1?r[i-1]:ne;for(o=t.length>3&&"function"==typeof o?(i--,o):ne,e=Object(e);++n-1?e[o?o[a]:a]:ne}}function q(t,e,r,n){function i(){for(var e=-1,s=arguments.length,c=-1,u=n.length,l=Array(u+s),f=this&&this!==Ce&&this instanceof i?a:t;++cs))return!1;for(var u=-1,l=!0,f=i&ce?[]:ne;++ui&&(i=Me(n+i,0)),a(t,A(e,3),i)}function tt(t){var e=t?t.length:0;return e?E(t,1):[]}function et(t){var e=t?t.length:0;return e?E(t,le):[]}function rt(t){return t&&t.length?t[0]:ne}function nt(t,e,r){var n=t?t.length:0;r="number"==typeof r?0>r?Me(n+r,0):r:0;for(var i=(r||0)-1,o=e===e;++i0&&(r=e.apply(this,arguments)),1>=t&&(e=ne),r}}function gt(t){if("function"!=typeof t)throw new TypeError(oe);return function(){return!t.apply(this,arguments)}}function bt(t){return mt(2,t)}function Et(t,e){if("function"!=typeof t)throw new TypeError(oe);return e=Me(e===ne?t.length-1:Je(e),0),function(){for(var r=arguments,n=-1,i=Me(r.length-e,0),o=Array(i);++n-1&&t%1==0&&fe>=t}function Pt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return!!t&&"object"==typeof t}function Lt(t){return Vt(t)&&t!=+t}function Dt(t){return null===t}function Vt(t){return"number"==typeof t||Nt(t)&&Pe.call(t)==ge}function Ut(t){return Pt(t)&&Pe.call(t)==Ee}function Mt(t){return"string"==typeof t||!Ze(t)&&Nt(t)&&Pe.call(t)==xe}function Gt(t){return t===ne}function Bt(t){return Ot(t)?t.length?L(t):[]:$t(t)}function zt(t){return"string"==typeof t?t:null==t?"":t+""}function Ht(t,e){var r=_(t);return e?We(r,e):r}function Kt(t,e){return null!=t&&Te.call(t,e)}function qt(t,e,r){var n=null==t?ne:t[e];return n===ne&&(n=r),Tt(n)?n.call(t):n}function $t(t){return t?c(t,rr(t)):[]}function Xt(t){return t=zt(t),t&&we.test(t)?t.replace(je,l):t}function Zt(t){return t}function Jt(t){return T(We({},t))}function Qt(t,e,r){var n=rr(e),i=j(e,n);null!=r||Pt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=j(e,rr(e)));var a=!(Pt(r)&&"chain"in r&&!r.chain),s=Tt(t);return Ge(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__),i=r.__actions__=L(this.__actions__);return i.push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,o([this.value()],arguments))})}),t}function Wt(){return Ce._===this&&(Ce._=Ne),this}function Yt(){}function te(t){var e=++Fe;return zt(t)+e}function ee(t){return t&&t.length?g(t,Zt,w):ne}function re(t){return t&&t.length?g(t,Zt,R):ne}var ne,ie="4.13.1",oe="Expected a function",ae=1,se=32,ce=1,ue=2,le=1/0,fe=9007199254740991,pe="[object Arguments]",he="[object Array]",de="[object Boolean]",ve="[object Date]",_e="[object Error]",ye="[object Function]",me="[object GeneratorFunction]",ge="[object Number]",be="[object Object]",Ee="[object RegExp]",xe="[object String]",je=/[&<>"'`]/g,we=RegExp(je.source),Oe={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ie=u("object"==typeof i&&i),Ae=u("object"==typeof self&&self),Se=u("object"==typeof this&&this),Ce=Ie||Ae||Se||Function("return this")(),Re=Array.prototype,ke=Object.prototype,Te=ke.hasOwnProperty,Fe=0,Pe=ke.toString,Ne=Ce._,Le=Object.create,De=ke.propertyIsEnumerable,Ve=Ce.isFinite,Ue=Object.keys,Me=Math.max;h.prototype=_(p.prototype),h.prototype.constructor=h;var Ge=B(x),Be=z(),ze=P("length"),He=String,Ke=K(Y),qe=Et(function(t,e,r){return q(t,ae|se,e,r)}),$e=Et(function(t,e){return y(t,1,e)}),Xe=Et(function(t,e,r){return y(t,Qe(e)||0,r)}),Ze=Array.isArray,Je=Number,Qe=Number,We=G(function(t,e){M(e,rr(e),t)}),Ye=G(function(t,e){M(e,nr(e),t)}),tr=G(function(t,e,r,n){M(e,nr(e),t,n)}),er=Et(function(t){return t.push(ne,d),tr.apply(ne,t)}),rr=S,nr=C,ir=Et(function(t,e){return null==t?{}:F(t,k(E(e,1),He))}),or=A;p.assignIn=Ye,p.before=mt,p.bind=qe,p.chain=at,p.compact=Q,p.concat=W,p.create=Ht,p.defaults=er,p.defer=$e,p.delay=Xe,p.filter=ft,p.flatten=tt,p.flattenDeep=et,p.iteratee=or,p.keys=rr,p.map=ht,p.matches=Jt,p.mixin=Qt,p.negate=gt,p.once=bt,p.pick=ir,p.slice=ot,p.sortBy=yt,p.tap=st,p.thru=ct,p.toArray=Bt,p.values=$t,p.extend=Ye,Qt(p,p),p.clone=xt,p.escape=Xt,p.every=lt,p.find=Ke,p.forEach=pt,p.has=Kt,p.head=rt,p.identity=Zt,p.indexOf=nt,p.isArguments=wt,p.isArray=Ze,p.isBoolean=At,p.isDate=St,p.isEmpty=Ct,p.isEqual=Rt,p.isFinite=kt,p.isFunction=Tt,p.isNaN=Lt,p.isNull=Dt,p.isNumber=Vt,p.isObject=Pt,p.isRegExp=Ut,p.isString=Mt,p.isUndefined=Gt,p.last=it,p.max=ee,p.min=re,p.noConflict=Wt,p.noop=Yt,p.reduce=dt,p.result=qt,p.size=vt,p.some=_t,p.uniqueId=te,p.each=pt,p.first=rt,Qt(p,function(){var t={};return x(p,function(e,r){Te.call(p.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),p.VERSION=ie,Ge(["pop","join","replace","reverse","split","push","shift","sort","splice","unshift"],function(t){var e=(/^(?:replace|split)$/.test(t)?String.prototype:Re)[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|join|replace|shift)$/.test(t);p.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Ze(i)?i:[],t)}return this[r](function(r){return e.apply(Ze(r)?r:[],t)})}}),p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ut,(Ae||{})._=p,n=function(){return p}.call(e,r,e,t),!(n!==ne&&(t.exports=n))}).call(this)}).call(e,r(2)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,r){var n=r(4),i=r(5).ERROR_MESSAGES,o="CONFIG_VALIDATOR";t.exports={validate:function(t){if(t.errorHandler&&"function"!=typeof t.errorHandler.handleError)throw new Error(n(i.INVALID_ERROR_HANDLER,o));if(t.eventDispatcher&&"function"!=typeof t.eventDispatcher.dispatchEvent)throw new Error(n(i.INVALID_EVENT_DISPATCHER,o));if(t.logger&&"function"!=typeof t.logger.log)throw new Error(n(i.INVALID_LOGGER,o));return!0}}},function(t,e){var r=function(){function t(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function e(t,e){for(var r=[];e>0;r[--e]=t);return r.join("")}var n=function(){return n.cache.hasOwnProperty(arguments[0])||(n.cache[arguments[0]]=n.parse(arguments[0])),n.format.call(null,n.cache[arguments[0]],arguments)};return n.object_stringify=function(t,e,r,i){var o="";if(null!=t)switch(typeof t){case"function":return"[Function"+(t.name?": "+t.name:"")+"]";case"object":if(t instanceof Error)return"["+t.toString()+"]";if(e>=r)return"[Object]";if(i&&(i=i.slice(0),i.push(t)),null!=t.length){o+="[";var a=[];for(var s in t)i&&i.indexOf(t[s])>=0?a.push("[Circular]"):a.push(n.object_stringify(t[s],e+1,r,i));o+=a.join(", ")+"]"}else{if("getMonth"in t)return"Date("+t+")";o+="{";var a=[];for(var c in t)t.hasOwnProperty(c)&&(i&&i.indexOf(t[c])>=0?a.push(c+": [Circular]"):a.push(c+": "+n.object_stringify(t[c],e+1,r,i)));o+=a.join(", ")+"}"}return o;case"string":return'"'+t+'"'}return""+t},n.format=function(i,o){var a,s,c,u,l,f,p,h=1,d=i.length,v="",_=[];for(s=0;d>s;s++)if(v=t(i[s]),"string"===v)_.push(i[s]);else if("array"===v){if(u=i[s],u[2])for(a=o[h],c=0;c=0?"+"+a:a,f=u[4]?"0"==u[4]?"0":u[4].charAt(1):" ",p=u[6]-String(a).length,l=u[6]?e(f,p):"",_.push(u[5]?a+l:l+a)}return _.join("")},n.cache={},n.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=/^[^\x25]+/.exec(e)))n.push(r[0]);else if(null!==(r=/^\x25{2}/.exec(e)))n.push("%");else{if(null===(r=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(e)))throw new Error("[sprintf] "+e);if(r[2]){i|=1;var o=[],a=r[2],s=[];if(null===(s=/^([a-z_][a-z_\d]*)/i.exec(a)))throw new Error("[sprintf] "+a);for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=/^\.([a-z_][a-z_\d]*)/i.exec(a)))o.push(s[1]);else{if(null===(s=/^\[(\d+)\]/.exec(a)))throw new Error("[sprintf] "+a);o.push(s[1])}r[2]=o}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push(r)}e=e.substring(r[0].length)}return n},n}(),n=function(t,e){var n=e.slice();return n.unshift(t),r.apply(null,n)};t.exports=r,r.sprintf=r,r.vsprintf=n},function(t,e){e.LOG_LEVEL={NOTSET:0,DEBUG:1,INFO:2,WARNING:3,ERROR:4},e.ERROR_MESSAGES={INVALID_ATTRIBUTES:"%s: Provided attributes are in an invalid format.",INVALID_BUCKETING_ID:"%s: Unable to generate hash for bucketing ID %s: %s",INVALID_DATAFILE:"%s: Datafile is invalid: %s",INVALID_JSON:"%s: JSON object is not valid.",INVALID_ERROR_HANDLER:'%s: Provided "errorHandler" is in an invalid format.',INVALID_EVENT_DISPATCHER:'%s: Provided "eventDispatcher" is in an invalid format.',INVALID_EVENT_KEY:"%s: Event key %s is not in datafile.",INVALID_EXPERIMENT_KEY:"%s: Experiment key %s is not in datafile.",INVALID_GROUP_ID:"%s: Group ID %s is not in datafile.",INVALID_LOGGER:'%s: Provided "logger" is in an invalid format.',INVALID_USER_ID:"%s: Provided user ID is in an invalid format.",JSON_SCHEMA_EXPECTED:"%s: JSON schema expected.",NO_DATAFILE_SPECIFIED:"%s: No datafile specified. Cannot start optimizely.",NO_JSON_PROVIDED:"%s: No JSON object to validate against schema."},e.LOG_MESSAGES={ACTIVATE_USER:"%s: Activating user %s in experiment %s.",DISPATCH_CONVERSION_EVENT:"%s: Dispatching conversion event to URL %s with params %s.",DISPATCH_IMPRESSION_EVENT:"%s: Dispatching impression event to URL %s with params %s.",EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS:"%s: Event %s is not associated with any running experiments.",EXPERIMENT_NOT_RUNNING:"%s: Experiment %s is not running.",FORCED_BUCKETING_FAILED:"%s: Variation key %s is not in datafile. Not activating user %s.",NO_VALID_EXPERIMENTS_FOR_GOAL_TO_TRACK:"%s: There are no valid experiments for event %s to track.",NOT_ACTIVATING_USER:"%s: Not activating user %s for experiment %s.",NOT_TRACKING_USER_FOR_EXPERIMENT:"%s: Not tracking user %s for experiment %s.",TRACK_EVENT:"%s: Tracking event %s for user %s.",USER_ASSIGNED_TO_VARIATION_BUCKET:"%s: Assigned variation bucket %s to user %s.",USER_ASSIGNED_TO_EXPERIMENT_BUCKET:"%s: Assigned experiment bucket %s to user %s.",USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is in experiment %s of group %s.",USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is not in experiment %s of group %s.",USER_NOT_IN_EXPERIMENT:"%s: User %s is in no experiment.",USER_FORCED_IN_VARIATION:"%s: User %s is forced in variation %s.",USER_HAS_VARIATION:"%s: User %s is in variation %s of experiment %s.",USER_HAS_NO_VARIATION:"%s: User %s is in no variation of experiment %s.",USER_NOT_IN_ANY_EXPERIMENT:"%s: User %s is not in any experiment of group %s.",USER_NOT_IN_EXPERIMENT:"%s: User %s does not meet conditions to be in experiment %s.",VALID_DATAFILE:"%s: Datafile is valid."}},function(t,e){t.exports={handleError:function(t){}}},function(t,e,r){var n=r(1),i=r(8);t.exports={dispatchEvent:function(t,e){return new i(function(r,n){e&&(t+="?"+o(e));var i=new XMLHttpRequest;i.open("GET",t,!0),i.addEventListener("load",function(t){var e=JSON.parse(t.target.responseText);r(e)}),i.send()})}};var o=function(t){return n.map(t,function(t,e){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&")}},function(t,e,r){(function(e,r,n){!function(e){t.exports=e()}(function(){var t,i,o;return function a(t,e,r){function n(o,s){if(!e[o]){if(!t[o]){var c="function"==typeof _dereq_&&_dereq_;if(!s&&c)return c(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=e[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return n(r?r:e)},l,l.exports,a,t,e,r)}return e[o].exports}for(var i="function"==typeof _dereq_&&_dereq_,o=0;o0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},i.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},i.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},i.prototype._reset=function(){this._isTickUsed=!1},r.exports=i,r.exports.firstLineError=c},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=n.propagateFromFunction(),t.prototype._boundValue=n.boundValueFunction());var u=r(o),l=new t(e);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(u),u instanceof t){var p={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:u};f._then(e,a,void 0,l,p),u._then(s,c,void 0,l,p),l._setOnCancel(u)}else l._resolveCallback(f);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,r){return t.resolve(r).bind(e)}}},{}],4:[function(t,e,r){"use strict";function n(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=n,e.exports=o},{"./promise":22}],5:[function(t,e,r){"use strict";var n=Object.create;if(n){var i=n(null),o=n(null);i[" size"]=o[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+s.classString(t)+" has no method '"+s.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var a,s=t("./util"),c=s.canEvaluate;s.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(n,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(c){var n=a(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t.isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var r=t._cancellationParent;if(null==r||!r.isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),e=t,t=r}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var r=0;r=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=r,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var r=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=r,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=n,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,r,n){"use strict";r.exports=function(r,n){function i(t,e){return{promise:e}}function o(){return!1}function a(t,e,r){var n=this;try{t(e,r,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+U.toString(t));n._attachCancellationCallback(t)})}catch(i){return i}}function s(t){if(!this.isCancellable())return this;var e=this._onCancel();void 0!==e?U.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function c(){return this._onCancelField}function u(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(t,e){if(0!==(1&e)){this._cancellationParent=t;var r=t._branchesRemainingToCancel;void 0===r&&(r=0),t._branchesRemainingToCancel=r+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(){var t=this._boundTo;return void 0!==t&&t instanceof r?t.isFulfilled()?t.value():void 0:t}function d(){this._trace=new T(this._peekContext())}function v(t,e){if(M(t)){var r=this._trace;if(void 0!==r&&e&&(r=r._parent),void 0!==r)r.attachExtraTrace(t);else if(!t.__stackCleaned__){var n=w(t);U.notEnumerableProp(t,"stack",n.message+"\n"+n.stack.join("\n")),U.notEnumerableProp(t,"__stackCleaned__",!0)}}}function _(t,e,r,n,i){if(void 0===t&&null!==e&&X){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&n._bitField))return;r&&(r+=" ");var o="a promise was created in a "+r+"handler but was not returned from it";n._warn(o,!0,e)}}function y(t,e){var r=t+" is deprecated and will be removed in a future version.";return e&&(r+=" Use "+e+" instead."),m(r)}function m(t,e,n){if(it.warnings){var i,o=new V(t);if(e)n._attachExtraTrace(o);else if(it.longStackTraces&&(i=r._peekContext()))i.attachExtraTrace(o);else{var a=w(o);o.stack=a.message+"\n"+a.stack.join("\n")}Y("warning",o)||O(o,"",!0)}}function g(t,e){for(var r=0;r=0;--s)if(n[s]===o){a=s;break}for(var s=a;s>=0;--s){var c=n[s];if(e[i]!==c)break;e.pop(),i--}e=n}}function x(t){for(var e=[],r=0;r0&&(e=e.slice(r)),e}function w(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?j(t):[" (No stack trace)"],{message:r,stack:x(e)}}function O(t,e,r){if("undefined"!=typeof console){var n;if(U.isObject(t)){var i=t.stack;n=e+z(i,t)}else n=e+String(t);"function"==typeof N?N(n,r):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(n)}}function I(t,e,r,n){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(n):e(r,n))}catch(o){D.throwLater(o)}"unhandledRejection"===t?Y(t,r,n)||i||O(r,"Unhandled rejection "):Y(t,n)}function A(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{ -e=t&&"function"==typeof t.toString?t.toString():U.toString(t);var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+S(e)+">, no stack trace)"}function S(t){var e=41;return t.lengtha||0>s||!r||!n||r!==n||a>=s||(et=function(t){if(G.test(t))return!0;var e=R(t);return!!(e&&e.fileName===r&&a<=e.line&&e.line<=s)})}}function T(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);nt(this,T),e>32&&this.uncycle()}var F,P,N,L=r._getDomain,D=r._async,V=t("./errors").Warning,U=t("./util"),M=U.canAttachTrace,G=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,B=null,z=null,H=!1,K=!(0==U.env("BLUEBIRD_DEBUG")),q=!(0==U.env("BLUEBIRD_WARNINGS")||!K&&!U.env("BLUEBIRD_WARNINGS")),$=!(0==U.env("BLUEBIRD_LONG_STACK_TRACES")||!K&&!U.env("BLUEBIRD_LONG_STACK_TRACES")),X=0!=U.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(q||!!U.env("BLUEBIRD_W_FORGOTTEN_RETURN"));r.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},r.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),D.invokeLater(this._notifyUnhandledRejection,this,void 0))},r.prototype._notifyUnhandledRejectionIsHandled=function(){I("rejectionHandled",F,void 0,this)},r.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},r.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},r.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),I("unhandledRejection",P,t,this)}},r.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},r.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},r.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},r.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},r.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},r.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},r.prototype._warn=function(t,e,r){return m(t,e,r||this)},r.onPossiblyUnhandledRejection=function(t){var e=L();P="function"==typeof t?null===e?t:e.bind(t):void 0},r.onUnhandledRejectionHandled=function(t){var e=L();F="function"==typeof t?null===e?t:e.bind(t):void 0};var Z=function(){};r.longStackTraces=function(){if(D.haveItemsQueued()&&!it.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!it.longStackTraces&&C()){var t=r.prototype._captureStackTrace,e=r.prototype._attachExtraTrace;it.longStackTraces=!0,Z=function(){if(D.haveItemsQueued()&&!it.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");r.prototype._captureStackTrace=t,r.prototype._attachExtraTrace=e,n.deactivateLongStackTraces(),D.enableTrampoline(),it.longStackTraces=!1},r.prototype._captureStackTrace=d,r.prototype._attachExtraTrace=v,n.activateLongStackTraces(),D.disableTrampolineIfNecessary()}},r.hasLongStackTraces=function(){return it.longStackTraces&&C()};var J=function(){try{var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),U.global.dispatchEvent(t),function(t,e){var r=document.createEvent("CustomEvent");return r.initCustomEvent(t.toLowerCase(),!1,!0,e),!U.global.dispatchEvent(r)}}catch(e){}return function(){return!1}}(),Q=function(){return U.isNode?function(){return e.emit.apply(e,arguments)}:U.global?function(t){var e="on"+t.toLowerCase(),r=U.global[e];return r?(r.apply(U.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),W={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(t,e,r){return{promise:e,child:r}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,r){return{reason:e,promise:r}},rejectionHandled:i},Y=function(t){var e=!1;try{e=Q.apply(null,arguments)}catch(r){D.throwLater(r),e=!0}var n=!1;try{n=J(t,W[t].apply(null,arguments))}catch(r){D.throwLater(r),n=!0}return n||e};r.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?r.longStackTraces():!t.longStackTraces&&r.hasLongStackTraces()&&Z()),"warnings"in t){var e=t.warnings;it.warnings=!!e,X=it.warnings,U.isObject(e)&&"wForgottenReturn"in e&&(X=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!it.cancellation){if(D.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");r.prototype._clearCancellationData=l,r.prototype._propagateFrom=f,r.prototype._onCancel=c,r.prototype._setOnCancel=u,r.prototype._attachCancellationCallback=s,r.prototype._execute=a,tt=f,it.cancellation=!0}"monitoring"in t&&(t.monitoring&&!it.monitoring?(it.monitoring=!0,r.prototype._fireEvent=Y):!t.monitoring&&it.monitoring&&(it.monitoring=!1,r.prototype._fireEvent=o))},r.prototype._fireEvent=o,r.prototype._execute=function(t,e,r){try{t(e,r)}catch(n){return n}},r.prototype._onCancel=function(){},r.prototype._setOnCancel=function(t){},r.prototype._attachCancellationCallback=function(t){},r.prototype._captureStackTrace=function(){},r.prototype._attachExtraTrace=function(){},r.prototype._clearCancellationData=function(){},r.prototype._propagateFrom=function(t,e){};var tt=p,et=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;U.inherits(T,Error),n.CapturedTrace=T,T.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var a=e[n].stack,s=r[a];if(void 0!==s&&s!==n){s>0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var c=n>0?e[n-1]:this;t-1>s?(c._parent=e[s+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var u=c._length+1,l=n-2;l>=0;--l)e[l]._length=u,u++;return}}}},T.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=w(t),r=e.message,n=[e.stack],i=this;void 0!==i;)n.push(x(i.stack.split("\n"))),i=i._parent;E(n),b(n),U.notEnumerableProp(t,"stack",g(r,n)),U.notEnumerableProp(t,"__stackCleaned__",!0)}};var nt=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():A(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,B=t,z=e;var r=Error.captureStackTrace;return et=function(t){return G.test(t)},function(t,e){Error.stackTraceLimit+=6,r(t,e),Error.stackTraceLimit-=6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return B=/@/,z=e,H=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in n||!i||"number"!=typeof Error.stackTraceLimit?(z=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?A(e):e.toString()},null):(B=t,z=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(N=function(t){console.warn(t)},U.isNode&&e.stderr.isTTY?N=function(t,e){var r=e?"":"";console.warn(r+t+"\n")}:U.isNode||"string"!=typeof(new Error).stack||(N=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var it={warnings:q,longStackTraces:!1,cancellation:!1,monitoring:!1};return $&&r.longStackTraces(),{longStackTraces:function(){return it.longStackTraces},warnings:function(){return it.warnings},cancellation:function(){return it.cancellation},monitoring:function(){return it.monitoring},propagateFromFunction:function(){return tt},boundValueFunction:function(){return h},checkForgottenReturns:_,setBounds:k,warn:m,deprecated:y,CapturedTrace:T,fireDomEvent:J,fireGlobalEvent:Q}}},{"./errors":12,"./util":36}],10:[function(t,e,r){"use strict";e.exports=function(t){function e(){return this.value}function r(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(r){return r instanceof t&&r.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:r},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(r,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,r,void 0,{reason:t},void 0);var e=arguments[1],n=function(){throw e};return this.caught(t,n)},t.prototype.catchReturn=function(r){if(arguments.length<=1)return r instanceof t&&r.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:r},void 0);var n=arguments[1];n instanceof t&&n.suppressUnhandledRejections();var i=function(){return n};return this.caught(r,i)}}},{}],11:[function(t,e,r){"use strict";e.exports=function(t,e){function r(){return o(this)}function n(t,r){return i(t,r,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return this.mapSeries(t)._then(r,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,e){return n(t,e)._then(r,void 0,void 0,t,void 0)},t.mapSeries=n}},{}],12:[function(t,e,r){"use strict";function n(t,e){function r(n){return this instanceof r?(f(this,"message","string"==typeof n?n:e),f(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return l(r,Error),r}function i(t){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(f(this,"message",t.message),f(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),c=s.freeze,u=t("./util"),l=u.inherits,f=u.notEnumerableProp,p=n("Warning","warning"),h=n("CancellationError","cancellation error"),d=n("TimeoutError","timeout error"),v=n("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(_){o=n("TypeError","type error"),a=n("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),m=0;m1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return c.call(this,this.promise._target()._settledValue())}function s(t){return o(this,t)?void 0:(f.e=t,f)}function c(t){var n=this.promise,c=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?c.call(n._boundValue()):c.call(n._boundValue(),t);if(void 0!==u){n._setReturnedNonUndefined();var p=r(u,n);if(p instanceof e){if(null!=this.cancelPromise){if(p.isCancelled()){var h=new l("late cancellation observer");return n._attachExtraTrace(h),f.e=h,f}p.isPending()&&p._attachCancellationCallback(new i(this))}return p._then(a,s,void 0,this,void 0)}}}return n.isRejected()?(o(this),f.e=t,f):(o(this),t)}var u=t("./util"),l=e.CancellationError,f=u.errorObj;return n.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,r,i){return"function"!=typeof t?this.then():this._then(r,i,void 0,new n(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},n}},{"./util":36}],16:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,r,n){for(var o=0;o0&&"function"==typeof arguments[e]){t=arguments[e];var n}var i=[].slice.call(arguments);t&&i.pop();var n=new r(i).promise();return void 0!==t?n.spread(t):n}}},{"./util":36}],18:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace();var i=u();this._callback=null===i?e:i.bind(e),this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:h,this._init$(void 0,-2)}function c(t,r,i,o){if("function"!=typeof r)return n("expecting a function but got "+l.classString(r));var a=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+l.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+l.classString(i.concurrency)));a=i.concurrency}return a="number"==typeof a&&isFinite(a)&&a>=1?a:0,new s(t,r,a,o).promise()}var u=e._getDomain,l=t("./util"),f=l.tryCatch,p=l.errorObj,h=[];l.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,c=this._limit;if(0>r){if(r=-1*r-1,n[r]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return n[r]=t,this._queue.push(r),!1;null!==s&&(s[r]=t);var u=this._promise,l=this._callback,h=u._boundValue();u._pushContext();var d=f(l).call(h,t,r,o),v=u._popContext();if(a.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",u),d===p)return this._reject(d.e),!0;var _=i(d,this._promise);if(_ instanceof e){_=_._target();var y=_._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,n[r]=_,_._proxy(this,-1*(r+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(_._reason()),!0):(this._cancel(),!0);d=_._value()}n[r]=d}var m=++this._totalResolved;return m>=o?(null!==s?this._filter(n,s):this._resolve(n),!0):!1},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,r,n){return c(t,e,r,n)}}},{"./util":36}],19:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){var a=t("./util"),s=a.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+a.classString(t));return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments),a=n._popContext();return o.checkForgottenReturns(i,a,"Promise.method",n),n._resolveFromSyncValue(i),n}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+a.classString(t));var n=new e(r);n._captureStackTrace(),n._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var u=arguments[1],l=arguments[2];c=a.isArray(u)?s(t).apply(l,u):s(t).call(l,u)}else c=s(t)();var f=n._popContext();return o.checkForgottenReturns(c,f,"Promise.try",n),n._resolveFromSyncValue(c),n},e.prototype._resolveFromSyncValue=function(t){t===a.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,r){"use strict";function n(t){return t instanceof Error&&l.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(n(t)){e=new u(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var r=l.keys(t),i=0;i1){var r,n=new Array(e-1),i=0;for(r=0;e-1>r;++r){var o=arguments[r];if(!h.isObject(o))return f("expecting an object but got "+h.classString(o));n[i++]=o}return n.length=i,t=arguments[r],this.then(void 0,C(n,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(l,l,void 0,this,void 0)},i.prototype.then=function(t,e){if(A.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var r=".then() only accepts functions but was passed: "+h.classString(t);arguments.length>1&&(r+=", "+h.classString(e)),this._warn(r)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var r=this._then(t,e,void 0,void 0,void 0);r._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?f("expecting a function but got "+h.classString(t)):this.all()._then(t,void 0,void 0,E,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new w(this).promise()},i.prototype.error=function(t){return this.caught(h.originatesFromRejection,t)},i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(b);e._captureStackTrace();var r=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,n=T(t)(R(e,r));return n===k&&e._rejectCallback(n.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new w(t).promise()},i.cast=function(t){var e=j(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new m("expecting a function but got "+h.classString(t));return _.setScheduler(t)},i.prototype._then=function(t,e,r,n,o){var a=void 0!==o,s=a?o:new i(b),u=this._target(),l=u._bitField;a||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===n&&0!==(2097152&this._bitField)&&(n=0!==(50397184&l)?this._boundValue():u===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var f=c();if(0!==(50397184&l)){var p,h,d=u._settlePromiseCtx;0!==(33554432&l)?(h=u._rejectionHandler0,p=t):0!==(16777216&l)?(h=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(d=u._settlePromiseLateCancellationObserver,h=new g("late cancellation observer"),u._attachExtraTrace(h),p=e),_.invoke(d,u,{handler:null===f?p:"function"==typeof p&&f.bind(p),promise:s,receiver:n,value:h})}else u._addCallbacks(t,e,s,n,f);return s},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(t){this._bitField=-65536&this._bitField|65535&t},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=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setAsyncGuaranteed=function(){_.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==p)return void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),r=t._rejectionHandler0,n=t._promise0,i=t._receiverAt(0);void 0===i&&(i=p),this._addCallbacks(e,r,n,i,null)},i.prototype._migrateCallbackAt=function(t,e){var r=t._fulfillmentHandlerAt(e),n=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=p),this._addCallbacks(r,n,i,o,null)},i.prototype._addCallbacks=function(t,e,r,n,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=r,this._receiver0=n,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var a=4*o-4;this[a+2]=r,this[a+3]=n,"function"==typeof t&&(this[a+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[a+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(u(),!1);var r=j(t,this);if(!(r instanceof i))return this._fulfill(t);e&&this._propagateFrom(r,2);var n=r._target();if(n===this)return void this._reject(u());var o=n._bitField;if(0===(50397184&o)){var a=this._length();a>0&&n._migrateCallback0(this);for(var s=1;a>s;++s)n._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(n)}else if(0!==(33554432&o))this._fulfill(n._value());else if(0!==(16777216&o))this._reject(n._reason());else{var c=new g("late cancellation observer");n._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,r){var n=h.ensureErrorObject(t),i=n===t;if(!i&&!r&&A.warnings()){var o="a promise was rejected with a non-error: "+h.classString(t);this._warn(o,!0)}this._attachExtraTrace(n,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,r)});r=!1,this._popContext(),void 0!==n&&e._rejectCallback(n,!0)},i.prototype._settlePromiseFromHandler=function(t,e,r,n){var i=n._bitField;if(0===(65536&i)){n._pushContext();var o;e===E?r&&"number"==typeof r.length?o=T(t).apply(this._boundValue(),r):(o=k,o.e=new m("cannot .spread() a non-array: "+h.classString(r))):o=T(t).call(e,r); -var a=n._popContext();i=n._bitField,0===(65536&i)&&(o===x?n._reject(r):o===k?n._rejectCallback(o.e,!1):(A.checkForgottenReturns(o,a,"",n,this),n._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,n,o){var a=t instanceof i,s=this._bitField,c=0!==(134217728&s);0!==(65536&s)?(a&&t._invokeInternalOnCancel(),n instanceof S&&n.isFinallyHandler()?(n.cancelPromise=t,T(e).call(n,o)===k&&t._reject(k.e)):e===l?t._fulfill(l.call(n)):n instanceof r?n._promiseCancelled(t):a||t instanceof w?t._cancel():n.cancel()):"function"==typeof e?a?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,n,o,t)):e.call(n,o,t):n instanceof r?n._isResolved()||(0!==(33554432&s)?n._promiseFulfilled(o,t):n._promiseRejected(o,t)):a&&(c&&t._setAsyncGuaranteed(),0!==(33554432&s)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,r=t.promise,n=t.receiver,o=t.value;"function"==typeof e?r instanceof i?this._settlePromiseFromHandler(e,n,o,r):e.call(n,o,r):r instanceof i&&r._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,r){var n=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(n,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var r=u();return this._attachExtraTrace(r),this._reject(r)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():_.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?_.fatalError(t,h.isNode):void((65535&e)>0?_.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var r=1;t>r;r++){var n=this._fulfillmentHandlerAt(r),i=this._promiseAt(r),o=this._receiverAt(r);this._clearCallbackDataAtIndex(r),this._settlePromise(i,n,o,e)}},i.prototype._rejectPromises=function(t,e){for(var r=1;t>r;r++){var n=this._rejectionHandlerAt(r),i=this._promiseAt(r),o=this._receiverAt(r);this._clearCallbackDataAtIndex(r),this._settlePromise(i,n,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var r=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,r,t),this._rejectPromises(e,r)}else{var n=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,n,t),this._fulfillPromises(e,n)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){A.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:a}},h.notEnumerableProp(i,"_makeSelfResolutionError",u),t("./method")(i,b,j,f,A),t("./bind")(i,b,j,A),t("./cancel")(i,w,f,A),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,w,j,b,A),i.Promise=i,i.version="3.4.0",t("./map.js")(i,w,f,j,b,A),t("./call_get.js")(i),t("./using.js")(i,f,j,I,b,A),t("./timers.js")(i,b,A),t("./generators.js")(i,f,b,j,r,A),t("./nodeify.js")(i),t("./promisify.js")(i,b),t("./props.js")(i,w,j,f),t("./race.js")(i,b,j,f),t("./reduce.js")(i,w,f,j,b,A),t("./settle.js")(i,w,A),t("./some.js")(i,w,f),t("./filter.js")(i,b),t("./each.js")(i,b),t("./any.js")(i),h.toFastProperties(i),h.toFastProperties(i.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new i(b)),A.setBounds(v.firstLineError,h.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function a(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n=this._promise=new e(r);t instanceof e&&n._propagateFrom(t,3),n._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(s,o),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function u(t,r){var o=n(this._values,this._promise);if(o instanceof e){o=o._target();var s=o._bitField;if(this._values=o,0===(50397184&s))return this._promise._setAsyncGuaranteed(),o._then(u,this._reject,void 0,this,r);if(0===(33554432&s))return 0!==(16777216&s)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(-5===r?this._resolveEmptyArray():this._resolve(a(r))):void this._iterate(o)},s.prototype._iterate=function(t){var r=this.getActualLength(t.length);this._length=r,this._values=this.shouldCopyValues()?new Array(r):this._values;for(var i=this._promise,o=!1,a=null,s=0;r>s;++s){var c=n(t[s],i);c instanceof e?(c=c._target(),a=c._bitField):a=null,o?null!==a&&c.suppressUnhandledRejections():null!==a?0===(50397184&a)?(c._proxy(this,s),this._values[s]=c):o=0!==(33554432&a)?this._promiseFulfilled(c._value(),s):0!==(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):o=this._promiseFulfilled(c,s)}o||i._setAsyncGuaranteed()},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype._cancel=function(){!this._isResolved()&&this._promise.isCancellable()&&(this._values=null,this._promise._cancel())},s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;return r>=this._length?(this._resolve(this._values),!0):!1},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var r=0;rc;c+=2){var l=a[c],f=a[c+1],d=l+e;if(n===O)t[d]=O(l,p,l,f,e,i);else{var v=n(f,function(){return O(l,p,l,f,e,i)});h.notEnumerableProp(v,"__isPromisified__",!0),t[d]=v}}return h.toFastProperties(t),t}function l(t,e,r){return O(t,e,void 0,t,null,r)}var f,p={},h=t("./util"),d=t("./nodeback"),v=h.withAppended,_=h.maybeWrapAsError,y=h.canEvaluate,m=t("./errors").TypeError,g="Async",b={__isPromisified__:!0},E=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],x=new RegExp("^(?:"+E.join("|")+")$"),j=function(t){return h.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},w=function(t){return t.replace(/([$])/,"\\$")},O=y?f:c;e.promisify=function(t,e){if("function"!=typeof t)throw new m("expecting a function but got "+h.classString(t));if(i(t))return t;e=Object(e);var r=void 0===e.context?p:e.context,o=!!e.multiArgs,a=l(t,r,o);return h.copyDescriptors(t,a,n),a},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new m("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var r=!!e.multiArgs,n=e.suffix;"string"!=typeof n&&(n=g);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=O),!h.isIdentifier(n))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var a=h.inheritedDataKeys(t),s=0;so;++o){var a=n[o];e[o]=t[a],e[o+i]=a}}this.constructor$(e),this._isMap=r,this._init$(void 0,-3)}function a(t){var r,a=n(t);return u(a)?(r=a instanceof e?a._then(e.props,void 0,void 0,void 0,void 0):new o(a).promise(),a instanceof e&&r._propagateFrom(a,2),r):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var s,c=t("./util"),u=c.isObject,l=t("./es5");"function"==typeof Map&&(s=Map);var f=function(){function t(t,n){this[e]=t,this[e+r]=n,e++}var e=0,r=0;return function(n){r=n.size,e=0;var i=new Array(2*n.size);return n.forEach(t,i),i}}(),p=function(t){for(var e=new s,r=t.length/2|0,n=0;r>n;++n){var i=t[r+n],o=t[n];e.set(i,o)}return e};c.inherits(o,r),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){var n;if(this._isMap)n=p(this._values);else{n={};for(var i=this.length(),o=0,a=this.length();a>o;++o)n[this._values[o+i]]=this._values[o]}return this._resolve(n),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return a(this)},e.props=function(t){return a(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,r){"use strict";function n(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityp;++p){var d=t[p];(void 0!==d||p in t)&&e.cast(d)._then(l,f,void 0,u,null)}return u}var a=t("./util"),s=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,r,n,i){this.constructor$(t);var a=p();this._fn=null===a?r:a.bind(r),void 0!==n&&(n=e.resolve(n),n._attachCancellationCallback(this)),this._initialValue=n,this._currentCancellable=null,this._eachValues=i===o?[]:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function u(t,e,r,i){if("function"!=typeof e)return n("expecting a function but got "+h.classString(e));var o=new s(t,e,r,i);return o.promise()}function l(t){this.accum=t,this.array._gotAccum(t);var r=i(this.value,this.array._promise);return r instanceof e?(this.array._currentCancellable=r,r._then(f,void 0,void 0,this,void 0)):f.call(this,r)}function f(t){var r=this.array,n=r._promise,i=d(r._fn);n._pushContext();var o;o=void 0!==r._eachValues?i.call(n._boundValue(),t,this.index,this.length):i.call(n._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(r._currentCancellable=o);var s=n._popContext();return a.checkForgottenReturns(o,s,void 0!==r._eachValues?"Promise.each":"Promise.reduce",n),o}var p=e._getDomain,h=t("./util"),d=h.tryCatch;h.inherits(s,r),s.prototype._gotAccum=function(t){void 0!==this._eachValues&&t!==o&&this._eachValues.push(t)},s.prototype._eachComplete=function(t){return this._eachValues.push(t),this._eachValues},s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},s.prototype.shouldCopyValues=function(){return!1},s.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},s.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},s.prototype._iterate=function(t){this._values=t;var r,n,i=t.length;if(void 0!==this._initialValue?(r=this._initialValue,n=0):(r=e.resolve(t[0]),n=1),this._currentCancellable=r,!r.isRejected())for(;i>n;++n){var o={accum:null,value:t[n],index:n,length:i,array:this};r=r._then(l,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(r=r._then(this._eachComplete,void 0,void 0,this,void 0)),r._then(c,c,void 0,r,this)},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./util":36}],29:[function(t,i,o){"use strict";var a,s=t("./util"),c=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},u=s.getNativePromise();if(s.isNode&&"undefined"==typeof MutationObserver){var l=r.setImmediate,f=e.nextTick;a=s.isRecentNode?function(t){l.call(r,t)}:function(t){f.call(e,t)}}else if("function"==typeof u){var p=u.resolve();a=function(t){p.then(t)}}else a="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?"undefined"!=typeof n?function(t){n(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:c:function(){var t=document.createElement("div"),e={attributes:!0},r=!1,n=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),r=!1});i.observe(n,e);var o=function(){r||(r=!0,n.classList.toggle("foo"))};return function(r){var n=new MutationObserver(function(){n.disconnect(),r()});n.observe(t,e),o()}}();i.exports=a},{"./util":36}],30:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t)}var o=e.PromiseInspection,a=t("./util");a.inherits(i,r),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;return r>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var r=new o;return r._bitField=33554432,r._settledValueField=t,this._promiseResolved(e,r)},i.prototype._promiseRejected=function(t,e){var r=new o;return r._bitField=16777216,r._settledValueField=t,this._promiseResolved(e,r)},e.settle=function(t){return n.deprecated(".settle()",".reflect()"),new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var a=t("./util"),s=t("./errors").RangeError,c=t("./errors").AggregateError,u=a.isArray,l={};a.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=u(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new s(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,r){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var r=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},n=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},a=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=t.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype.isCancelled=function(){return this._target()._isCancelled()},t.prototype.isPending=function(){return a.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return r.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),n.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t,n){if(l(t)){if(t instanceof e)return t;var i=o(t);if(i===u){n&&n._pushContext();var c=e.reject(i.e);return n&&n._popContext(),c}if("function"==typeof i){if(a(t)){var c=new e(r);return t._then(c._fulfill,c._reject,void 0,c,null),c}return s(t,i,n)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return u.e=e,u}}function a(t){try{return f.call(t,"_promise0")}catch(e){return!1}}function s(t,n,i){function o(t){s&&(s._resolveCallback(t),s=null)}function a(t){s&&(s._rejectCallback(t,f,!0),s=null)}var s=new e(r),l=s;i&&i._pushContext(),s._captureStackTrace(),i&&i._popContext();var f=!0,p=c.tryCatch(n).call(t,o,a);return f=!1,s&&p===u&&(s._rejectCallback(p.e,!0,!0),s=null),l}var c=t("./util"),u=c.errorObj,l=c.isObject,f={}.hasOwnProperty;return n}},{"./util":36}],34:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function a(t){throw clearTimeout(this.handle),t}var s=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var u=function(t){return l(+this).thenReturn(t)},l=e.delay=function(t,o){var a,s;return void 0!==o?(a=e.resolve(o)._then(u,null,null,t,void 0),n.cancellation()&&o instanceof e&&a._setOnCancel(o)):(a=new e(r),s=setTimeout(function(){a._fulfill()},+t),n.cancellation()&&a._setOnCancel(new i(s))),a._setAsyncGuaranteed(),a};e.prototype.delay=function(t){return l(t,this)};var f=function(t,e,r){var n;n="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),s.markAsOriginatingFromRejection(n),t._attachExtraTrace(n),t._reject(n),null!=r&&r.cancel()};e.prototype.timeout=function(t,e){t=+t;var r,s,c=new i(setTimeout(function(){r.isPending()&&f(r,e,s)},t));return n.cancellation()?(s=this.then(),r=s._then(o,a,void 0,c,void 0),r._setOnCancel(c)):r=this._then(o,a,void 0,c,void 0),r}}},{"./util":36}],35:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t){setTimeout(function(){throw t},0)}function c(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(a>=u)return l._fulfill();var o=c(t[a++]);if(o instanceof e&&o._isDisposable()){try{o=n(o._getDisposer().tryDispose(r),t.promise)}catch(f){return s(f)}if(o instanceof e)return o._then(i,s,null,null,null)}i()}var a=0,u=t.length,l=new e(o);return i(),l}function l(t,e,r){this._data=t,this._promise=e,this._context=r}function f(t,e,r){this.constructor$(t,e,r)}function p(t){return l.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function h(t){this.length=t,this.promise=null,this[t-1]=null}var d=t("./util"),v=t("./errors").TypeError,_=t("./util").inherits,y=d.errorObj,m=d.tryCatch,g={};l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():g},l.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=e!==g?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},_(f,l),f.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},h.prototype._resultCancelled=function(){for(var t=this.length,r=0;t>r;++r){var n=this[r];n instanceof e&&n.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("expecting a function but got "+d.classString(i));var o,s=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,s=!1):(o=arguments,t--);for(var c=new h(t),f=0;t>f;++f){var v=o[f];if(l.isDisposer(v)){var _=v;v=v.promise(),v._setDisposable(_)}else{var g=n(v);g instanceof e&&(v=g._then(p,null,null,{resources:c,index:f},void 0))}c[f]=v}for(var b=new Array(c.length),f=0;f0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new f(t,this,i());throw new v}}},{"./errors":12,"./util":36}],36:[function(t,n,i){"use strict";function o(){try{var t=R;return R=null,t.apply(this,arguments)}catch(e){return C.e=e,C}}function a(t){return R=t,o}function s(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function c(t){return"function"==typeof t||"object"==typeof t&&null!==t}function u(t){return s(t)?new Error(m(t)):t}function l(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function f(t,e,r){if(!A.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function p(t,e,r){if(s(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return A.defineProperty(t,e,n),t}function h(t){throw t}function d(t){try{if("function"==typeof t){var e=A.names(t.prototype),r=A.isES5&&e.length>1,n=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=P.test(t+"")&&A.names(t).length>0;if(r||n||i)return!0}return!1}catch(o){return!1}}function v(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return N.test(t)}function y(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function m(t){try{return t+""}catch(e){return"[no string representation]"}}function g(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function b(t){try{p(t,"isOperational",!0)}catch(e){}}function E(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function x(t){return g(t)&&A.propertyIsWritable(t,"stack")}function j(t){return{}.toString.call(t)}function w(t,e,r){for(var n=A.names(t),i=0;i10||t[0]>0}(),M.isNode&&M.toFastProperties(e);try{throw new Error}catch(G){M.lastLineError=G}n.exports=M},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(e,r(9),function(){return this}(),r(10).setImmediate)},function(t,e){function r(){u&&a&&(u=!1,a.length?c=a.concat(c):l=-1,c.length&&n())}function n(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(a=c,c=[];++l1)for(var r=1;r=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var r=u++,n=arguments.length<2?!1:s.call(arguments,1);return c[r]=!0,o(function(){c[r]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(r))}),r},e.clearImmediate="function"==typeof n?n:function(t){delete c[t]}}).call(e,r(10).setImmediate,r(10).clearImmediate)},function(t,e,r){function n(){}function i(t){t=s.assignIn({logLevel:c.LOG_LEVEL.ERROR,logToConsole:!0,prefix:"[OPTIMIZELY]"},t),this.setLogLevel(t.logLevel),this.logLevelName=o(t.logLevel),this.logToConsole=t.logToConsole,this.prefix=t.prefix}function o(t){switch(t){case c.LOG_LEVEL.DEBUG:return"DEBUG";case c.LOG_LEVEL.INFO:return"INFO";case c.LOG_LEVEL.WARNING:return"WARNING";case c.LOG_LEVEL.ERROR:return"ERROR";default:return"NOTSET"}}function a(){return new Date}var s=r(1),c=r(5);n.prototype.log=function(){},i.prototype.log=function(t,e){this.__shouldLog(t)&&(this.prefix&&(e=this.prefix+" - "+this.logLevelName+" "+a()+" "+e),this.logToConsole&&this.__consoleLog(t,[e]))},i.prototype.setLogLevel=function(t){this.logLevel=t,this.log("Setting log level to "+t)},i.prototype.__shouldLog=function(t){return t>=this.logLevel},i.prototype.__consoleLog=function(t,e){switch(t){case c.LOG_LEVEL.DEBUG:console.debug.apply(console,e);break;case c.LOG_LEVEL.INFO:console.log.apply(console,e);break;case c.LOG_LEVEL.WARNING:console.warn.apply(console,e);break;case c.LOG_LEVEL.ERROR:console.error.apply(console,e);break;default:console.log.apply(console,e)}},t.exports={createLogger:function(t){return new i(t)},createNoOpLogger:function(){return new n}}},function(t,e,r){function n(t){if(this.logger=t.logger,this.eventDispatcher=t.eventDispatcher,this.errorHandler=t.errorHandler,t.datafile)if(t.skipJSONValidation===!0)this.configObj=f.createProjectConfig(t.datafile),this.logger.log(_.INFO,h(y.VALID_DATAFILE,m));else try{l.validate(p,t.datafile)&&(this.configObj=f.createProjectConfig(t.datafile),this.logger.log(_.INFO,h(y.VALID_DATAFILE,m)))}catch(e){this.logger.log(_.ERROR,e.message),this.errorHandler.handleError(e)}else this.logger.log(_.ERROR,h(v.NO_DATAFILE_SPECIFIED,m)),this.errorHandler.handleError(new Error(h(v.NO_DATAFILE_SPECIFIED,m)))}var i=r(1),o=r(13),a=r(14),s=(r(8),r(16)),c=r(5),u=r(18),l=r(160),f=r(20),p=r(170),h=r(4),d=r(171),v=c.ERROR_MESSAGES,_=c.LOG_LEVEL,y=c.LOG_MESSAGES,m="OPTIMIZELY";n.prototype.activate=function(t,e,r){try{if(!this.__validateInputs(e,r)||!this.__validatePreconditions(t,e,r)){var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),null}var i=this.__buildBucketerParams(t,e),o=s.bucket(i);if(null===o){var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),null}var a=u.createImpressionEventParams(this.configObj,t,o,e,r),c=u.getUrl(this.configObj),l=h(y.DISPATCH_IMPRESSION_EVENT,m,c,a);this.logger.log(_.DEBUG,l),this.eventDispatcher.dispatchEvent(c,a).then(function(){var r=h(y.ACTIVATE_USER,m,e,t);this.logger.log(_.INFO,r)}.bind(this));var p=f.getVariationKeyFromId(this.configObj,t,o);return p}catch(d){this.logger.log(_.ERROR,d.message);var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),this.errorHandler.handleError(d),null}},n.prototype.track=function(t,e,r,n){try{if(!this.__validateInputs(e,r))return;var i=f.getExperimentIdsForGoal(this.configObj,t);if(!i)return void this.logger.log(_.WARNING,h(y.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,m,t));var o=this.__getValidExperimentIdsForGoal(t,e,r);if(!o.length){var a=h(y.NO_VALID_EXPERIMENTS_FOR_GOAL_TO_TRACK,m,t);return void this.logger.log(_.INFO,a)}var s=this.__getBucketedVariationIdsForUser(o,e),c=u.createConversionEventParams(this.configObj,t,e,r,n,s,o),l=u.getUrl(this.configObj),p=h(y.DISPATCH_CONVERSION_EVENT,m,l,c);this.logger.log(_.DEBUG,p),this.eventDispatcher.dispatchEvent(l,c).then(function(){var r=h(y.TRACK_EVENT,m,t,e);this.logger.log(_.INFO,r)}.bind(this))}catch(d){this.logger.log(_.ERROR,d.message),this.errorHandler.handleError(d)}},n.prototype.getVariation=function(t,e,r){try{if(!this.__validateInputs(e,r)||!this.__validatePreconditions(t,e,r))return null;var n=this.__buildBucketerParams(t,e),i=s.bucket(n);return f.getVariationKeyFromId(this.configObj,t,i)}catch(o){return this.logger.log(_.ERROR,o.message),this.errorHandler.handleError(o),null}},n.prototype.__getValidExperimentIdsForGoal=function(t,e,r){var n=[];if(this.configObj.eventKeyMap[t]){var o,a;i.forEach(this.configObj.eventKeyMap[t].experimentIds,function(t){if(o=this.configObj.experimentIdMap[t].key,a=f.getAudiencesForExperiment(this.configObj,o),this.__validatePreconditions(o,e,r))n.push(t);else{var i=h(y.NOT_TRACKING_USER_FOR_EXPERIMENT,m,e,o);this.logger.log(_.INFO,i)}}.bind(this))}return n},n.prototype.__getBucketedVariationIdsForUser=function(t,e){try{var r=i.filter(Object.keys(this.configObj.experimentKeyMap),function(e){var r=f.getExperimentId(this.configObj,e);return r&&-1!==t.indexOf(r)}.bind(this)),n=i.map(r,function(t){var r=this.__buildBucketerParams(t,e);return s.bucket(r)}.bind(this));return n}catch(o){return this.logger.log(_.ERROR,o.message),this.errorHandler.handleError(o),null}},n.prototype.__validateInputs=function(t,e){try{return d.validate(t),e&&o.validate(e),!0}catch(r){return this.logger.log(_.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__validatePreconditions=function(t,e,r){if(!f.isExperimentRunning(this.configObj,t)){var n=h(y.EXPERIMENT_NOT_RUNNING,m,t);return this.logger.log(_.INFO,n),!1}var i=f.getAudiencesForExperiment(this.configObj,t);if(!a.evaluate(i,r)){var o=h(y.USER_NOT_IN_EXPERIMENT,m,e,t);return this.logger.log(_.INFO,o),!1}return!0},n.prototype.__buildBucketerParams=function(t,e){var r={};return r.experimentKey=t,r.experimentId=f.getExperimentId(this.configObj,t),r.userId=e,r.forcedVariations=this.configObj.experimentKeyMap[t].forcedVariations,r.trafficAllocationConfig=f.getTrafficAllocation(this.configObj,t),r.experimentKeyMap=this.configObj.experimentKeyMap,r.groupIdMap=this.configObj.groupIdMap,r.experimentVariationKeyMap=this.configObj.experimentVariationKeyMap,r.variationIdMap=this.configObj.variationIdMap,r.logger=this.logger,r},t.exports=n},function(t,e,r){var n=r(4),i=r(5).ERROR_MESSAGES,o="ATTRIBUTES_VALIDATOR";t.exports={validate:function(t){if("object"!=typeof t||Array.isArray(t)||null===t)throw new Error(n(i.INVALID_ATTRIBUTES,o));return!0}}},function(t,e,r){var n=r(15);t.exports={evaluate:function(t,e){if(!t||0===t.length)return!0;if(!e)return!1;for(var r=!1,i=0;i=4;)r=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^r,n-=4,++o;switch(n){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i^=255&t.charCodeAt(o),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)}return i^=i>>>13,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>15,i>>>0}function r(t,e){var r,n,i,o,a,s,c,u;for(r=3&t.length,n=t.length-r,i=e,a=3432918353,s=461845907,u=0;n>u;)c=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c,i=i<<13|i>>>19,o=5*(65535&i)+((5*(i>>>16)&65535)<<16)&4294967295,i=(65535&o)+27492+(((o>>>16)+58964&65535)<<16);switch(c=0,r){case 3:c^=(255&t.charCodeAt(u+2))<<16;case 2:c^=(255&t.charCodeAt(u+1))<<8;case 1:c^=255&t.charCodeAt(u),c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c}return i^=t.length,i^=i>>>16,i=2246822507*(65535&i)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(65535&i)+((3266489909*(i>>>16)&65535)<<16)&4294967295,i^=i>>>16,i>>>0}var n=r;n.v2=e,n.v3=r;t.exports=n}()},function(t,e,r){function n(t,e){var r={};return u.forEach(e,function(e,n){if(e||e===!1||0===e){var i=t.attributeKeyMap[n].segmentId,o=f("%s%s",h.segmentPrefix,i);r[o]=e}}),r}function i(t,e,r){var i={};if(i[h.projectId]=t.projectId,i[h.accountId]=t.accountId,i[h.endUserId]=e,r){var o=n(t,r);u.assignIn(i,o)}return i[h.source]=f("node-sdk-%s",l.version),i[h.time]=Math.round((new Date).getTime()/1e3),i}function o(t,e){var r={},n=p.getExperimentId(t,e);return r[h.goalId]=n,r[h.goalName]="visitor-event",r}function a(t,e,r){var n={},i=t.eventKeyMap[e].id,o=i;return r&&(o=f("%s,%s",i,p.getRevenueGoalId(t)),n[h.eventValue]=r),n[h.goalId]=o,n[h.goalName]=e,n}function s(t,e,r){var n={},i=p.getExperimentId(t,e),o=f("%s%s",h.experimentPrefix,i);return n[o]=r,n}function c(t,e,r,n){var i={},o=u.filter(Object.keys(t.experimentKeyMap),function(e){var r=t.experimentKeyMap[e].id;return r&&-1!==n.indexOf(r)?e:void 0});return u.forEach(o,function(e){var n=p.getExperimentId(t,e),o=f("%s%s",h.experimentPrefix,n),a=p.getEventVariationIdFromExperimentKey(t,e,r);i[o]=a}),i}var u=r(1),l=r(19),f=r(4),p=r(20),h={accountId:"d",projectId:"a",experimentPrefix:"x",goalId:"g",goalName:"n",segmentPrefix:"s",endUserId:"u",eventValue:"v",source:"src",time:"time"};t.exports={getUrl:function(t){return f("https://%s.log.optimizely.com/event",t.projectId)},createImpressionEventParams:function(t,e,r,n,a){var c=i(t,n,a),l=o(t,e),f=s(t,e,r);return u.assignIn(c,l,f)},createConversionEventParams:function(t,e,r,n,o,s,l){var f=i(t,r,n),p=a(t,e,o),h=c(t,r,s,l);return u.assignIn(f,p,h)}}},function(t,e){t.exports={name:"optimizely-server-sdk",description:"Node SDK for consumption for server-side testing",version:"0.1.0",repository:{type:"git",url:"https://github.com/optimizely/optimizely-testing-sdk-node.git"},keywords:["optimizely"],homepage:"https://github.com/optimizely/optimizely-testing-sdk-node",main:"index.js",scripts:{test:"mocha ./tests.js ./tests/*tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js","profile-test":"mocha ./tests/profiling_tests.js",cover:"istanbul cover _mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js",coveralls:"npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"},dependencies:{bluebird:"^3.3.5",jsonschema:"^1.1.0",lodash:"4.13.1",murmurhash:"0.0.2","request-promise":"^2.0.1",sprintf:"^0.1.5"},devDependencies:{chai:"^3.5.0",coveralls:"^2.11.9",eslint:"^2.9.0",istanbul:"^0.4.3",mocha:"^2.4.5","mocha-lcov-reporter":"^1.2.0",nock:"^7.7.2",sinon:"^1.17.4"},readme:'#Optimizely Node SDK\n[![Build Status](https://travis-ci.com/optimizely/optimizely-testing-sdk-node.svg?token=f1nmwFnopXzkdMKTUReK&branch=master)](https://travis-ci.com/optimizely/optimizely-testing-sdk-node)\n[![Coverage Status](https://coveralls.io/repos/github/optimizely/optimizely-testing-sdk-node/badge.svg?branch=master&t=pegN7y)](https://coveralls.io/github/optimizely/optimizely-testing-sdk-node?branch=master)\n\nThis Node SDK allows you to use the Optimizely testing framework to set up and manage your Custom experiments.\n\n##Usage\n\n###Create an instance\n\nAn Optimizely instance requires the datafile as an argument:\n\n```\noptimizely = optimizely.createInstance({\n datafile: datafile\n});\n```\n\nOptional error handler, event dispatcher, and logger arguments can also be passed in:\n\n```\nvar defaultErrorHandler = require(optimizely-testing-sdk-node/lib/plugins/error_handler);\nvar defaultEventDispatcher = require(optimizely-testing-sdk-node/lib/plugins/event_dispatcher);\nvar defaultLogger = require(optimizely-testing-sdk-node/lib/plugins/logger);\n\noptimizely = optimizely.createInstance({\n datafile: datafile,\n errorHandler: defaultErrorHandler,\n eventDispatcher: defaultEventDispatcher,\n logger: defaultLogger.createLogger(),\n});\n```\n\n###APIs\n```\noptimizelyInstance.activate(experimentKey, userId, attributes);\n\noptimizelyInstance.track(eventKey, userId, attributes, eventValue);\n\noptimizelyInstance.getVariation(experimentKey, userId, attributes);\n```\n\n###Directory structure\n\nMain file is `index.js` at the root of the directory\n\nAll other source code should be put into `lib/`.\n\nEach "class" should follow the module pattern:\n```js\nlib/optimizely/\n├── index.js // MAIN ENTRY POINT - facade that exposes a public api for the module\n└── tests.js // API tests for the module\'s facade (index.js)\n```\n\n###Installing the SDK\n```\nnpm install path/to/optimizely-testing-sdk-node --save\n```\n\n###Using the SDK\n\nInstructions on using the SDK can be found [here](http://developers.optimizely.com/server/reference/index).\n\n###Unit tests\n\n#####Run all tests\nYou can trigger all unit tests by typing the following command:\n```\nnpm test\n```\n',readmeFilename:"README.md",bugs:{url:"https://github.com/optimizely/optimizely-testing-sdk-node/issues"},_id:"optimizely-server-sdk@0.1.0",_shasum:"8c011045887681c5c4e4ac979cae394f042d1857",_resolved:"git+ssh://git@github.com:optimizely/optimizely-testing-sdk-node.git#022648a73eb1aa555f19f4b1f43adb57d186a1f6",_from:"optimizely-server-sdk@git+ssh://git@github.com:optimizely/optimizely-testing-sdk-node.git#v0.1.0"}},function(t,e,r){var n=r(1),i=r(21),o=r(130),a=r(5),s=r(4),c="Running",u="PROJECT_CONFIG",l="Total Revenue",f=a.ERROR_MESSAGES;t.exports={createProjectConfig:function(e){var r=o(e);n.forEach(r.audiences,function(t){t.conditions=JSON.parse(t.conditions)}),r.attributeKeyMap=i(r.dimensions,"key"),r.eventKeyMap=i(r.events,"key"),r.groupIdMap=i(r.groups,"id");var a;return n.forEach(r.groupIdMap,function(t,e){a=o(t.experiments),n.forEach(a,function(t){r.experiments.push(n.assignIn(t,{groupId:e}))})}),r.experimentKeyMap=i(r.experiments,"key"),r.experimentIdMap=i(r.experiments,"id"),r.experimentVariationKeyMap={},r.variationIdMap={},n.forEach(r.experiments,function(e){n.assignIn(r.experimentVariationKeyMap,t.exports._generateExperimentVariationKeyMap(e.variations,e.key,"key")),n.assignIn(r.variationIdMap,i(e.variations,"id"))}),r},_generateExperimentVariationKeyMap:function(t,e,r){for(var n,i={},o=0;o0?r.experimentIds:null;throw new Error(s(f.INVALID_EVENT_KEY,u,e))},getTrafficAllocation:function(t,e){var r=t.experimentKeyMap[e];if(n.isEmpty(r))throw new Error(s(f.INVALID_EXPERIMENT_KEY,u,e));return r.trafficAllocation}}},function(t,e,r){var n=r(22),i=n(function(t,e,r){t[r]=e});t.exports=i},function(t,e,r){function n(t,e){return function(r,n){var c=s(r)?i:o,u=e?e():{};return c(r,t,a(n),u)}}var i=r(23),o=r(24),a=r(49),s=r(44);t.exports=n},function(t,e){function r(t,e,r,n){for(var i=-1,o=t?t.length:0;++i-1&&t%1==0&&n>=t}var n=9007199254740991;t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}t.exports=r},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){function n(t){return"string"==typeof t||!i(t)&&o(t)&&c.call(t)==a}var i=r(44),o=r(43),a="[object String]",s=Object.prototype,c=s.toString;t.exports=n},function(t,e){function r(t,e){return e=null==e?n:e,!!e&&("number"==typeof t||i.test(t))&&t>-1&&t%1==0&&e>t}var n=9007199254740991,i=/^(?:0|[1-9]\d*)$/;t.exports=r},function(t,e){function r(t){var e=t&&t.constructor,r="function"==typeof e&&e.prototype||n;return t===r}var n=Object.prototype;t.exports=r},function(t,e,r){function n(t,e){return function(r,n){if(null==r)return r;if(!i(r))return t(r,n);for(var o=r.length,a=e?o:-1,s=Object(r);(e?a--:++ar)return!1;var n=e.length-1;return r==n?e.pop():a.call(e,r,1),!0}var i=r(56),o=Array.prototype,a=o.splice;t.exports=n},function(t,e,r){function n(t,e){for(var r=t.length;r--;)if(i(t[r][0],e))return r;return-1}var i=r(57);t.exports=n},function(t,e){function r(t,e){return t===e||t!==t&&e!==e}t.exports=r},function(t,e,r){function n(t){var e=this.__data__,r=i(e,t);return 0>r?void 0:e[r][1]}var i=r(56);t.exports=n},function(t,e,r){function n(t){return i(this.__data__,t)>-1}var i=r(56);t.exports=n},function(t,e,r){function n(t,e){var r=this.__data__,n=i(r,t);return 0>n?r.push([t,e]):r[n][1]=e,this}var i=r(56);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(53);t.exports=n},function(t,e){function r(t){return this.__data__["delete"](t)}t.exports=r},function(t,e){function r(t){return this.__data__.get(t)}t.exports=r},function(t,e){function r(t){return this.__data__.has(t)}t.exports=r},function(t,e,r){function n(t,e){var r=this.__data__;return r instanceof i&&r.__data__.length==a&&(r=this.__data__=new o(r.__data__)),r.set(t,e),this}var i=r(53),o=r(66),a=200;t.exports=n},function(t,e,r){function n(t){var e=-1,r=t?t.length:0;for(this.clear();++ef))return!1;var h=u.get(t);if(h)return h==e;var d=-1,v=!0,_=c&a?new i:void 0;for(u.set(t,e);++dr;)t=t[a(e[r++])];return r&&r==n?t:void 0}var i=r(116),o=r(122),a=r(123);t.exports=n},function(t,e,r){function n(t){return i(t)?t:o(t)}var i=r(44),o=r(117);t.exports=n},function(t,e,r){var n=r(118),i=r(119),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g,a=/\\(\\)?/g,s=n(function(t){var e=[];return i(t).replace(o,function(t,r,n,i){e.push(n?i.replace(a,"$1"):r||t)}),e});t.exports=s},function(t,e,r){function n(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(o);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a),a};return r.cache=new(n.Cache||i),r}var i=r(66),o="Expected a function";n.Cache=i,t.exports=n},function(t,e,r){function n(t){return null==t?"":i(t)}var i=r(120);t.exports=n},function(t,e,r){function n(t){if("string"==typeof t)return t;if(o(t))return c?c.call(t):"";var e=t+"";return"0"==e&&1/t==-a?"-0":e}var i=r(99),o=r(121),a=1/0,s=i?i.prototype:void 0,c=s?s.toString:void 0;t.exports=n},function(t,e,r){function n(t){return"symbol"==typeof t||i(t)&&s.call(t)==o}var i=r(43),o="[object Symbol]",a=Object.prototype,s=a.toString;t.exports=n},function(t,e,r){function n(t,e){if(i(t))return!1;var r=typeof t;return"number"==r||"symbol"==r||"boolean"==r||null==t||o(t)?!0:s.test(t)||!a.test(t)||null!=e&&t in Object(e)}var i=r(44),o=r(121),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;t.exports=n},function(t,e,r){function n(t){if("string"==typeof t||i(t))return t;var e=t+"";return"0"==e&&1/t==-o?"-0":e}var i=r(121),o=1/0;t.exports=n},function(t,e,r){function n(t,e){return null!=t&&o(t,e,i)}var i=r(125),o=r(126);t.exports=n},function(t,e){function r(t,e){return null!=t&&e in Object(t)}t.exports=r},function(t,e,r){function n(t,e,r){e=c(e,t)?[e]:i(e);for(var n,p=-1,h=e.length;++p already exists with different definition");return this.schemas[i]}this.schemas[i]=e;var s=i.replace(/^([^#]*)#$/,"$1");this.schemas[s]=e}return this.addSubSchemaArray(a,e.items instanceof Array?e.items:[e.items]),this.addSubSchemaArray(a,e["extends"]instanceof Array?e["extends"]:[e["extends"]]),this.addSubSchema(a,e.additionalItems),this.addSubSchemaObject(a,e.properties),this.addSubSchema(a,e.additionalProperties),this.addSubSchemaObject(a,e.definitions),this.addSubSchemaObject(a,e.patternProperties),this.addSubSchemaObject(a,e.dependencies),this.addSubSchemaArray(a,e.disallow),this.addSubSchemaArray(a,e.allOf),this.addSubSchemaArray(a,e.anyOf),this.addSubSchemaArray(a,e.oneOf),this.addSubSchema(a,e.not),this.schemas[i]}},u.prototype.addSubSchemaArray=function(t,e){if(e instanceof Array)for(var r=0;r",t);var u=o.objectGetPath(r.schemas[c],a.substr(1));if(void 0===u)throw new s("no such schema "+a+" located in <"+c+">",t);return{subschema:u,switchSchema:e}},u.prototype.testType=function(t,e,r,n,i){if("function"==typeof this.types[i])return this.types[i].call(this,t);if(i&&"object"==typeof i){var o=this.validateSchema(t,i,r,n);return void 0===o||!(o&&o.errors.length)}return!0};var l=u.prototype.types={};l.string=function(t){return"string"==typeof t},l.number=function(t){return"number"==typeof t&&isFinite(t)},l.integer=function(t){return"number"==typeof t&&t%1===0},l["boolean"]=function(t){return"boolean"==typeof t},l.array=function(t){return t instanceof Array},l["null"]=function(t){return null===t},l.date=function(t){return t instanceof Date},l.any=function(t){return!0},l.object=function(t){return t&&"object"==typeof t&&!(t instanceof Array)&&!(t instanceof Date)},t.exports=u},function(t,e,r){function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&u(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return c(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function a(t,e){return i(t,!1,!0).resolve(e)}function s(t,e){return t?i(t,!1,!0).resolveObject(e):e}function c(t){return"string"==typeof t}function u(t){return"object"==typeof t&&null!==t}function l(t){return null===t}function f(t){return null==t}var p=r(164);e.parse=i,e.resolve=a,e.resolveObject=s,e.format=o,e.Url=n;var h=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,v=["<",">",'"',"`"," ","\r","\n"," "],_=["{","}","|","\\","^","`"].concat(v),y=["'"].concat(_),m=["%","/","?",";","#"].concat(y),g=["/","?","#"],b=255,E=/^[a-z0-9A-Z_-]{0,63}$/,x=/^([a-z0-9A-Z_-]{0,63})(.*)$/,j={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},O={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},I=r(165);n.prototype.parse=function(t,e,r){if(!c(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=h.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===n.substr(0,2);!a||i&&w[i]||(n=n.substr(2),this.slashes=!0)}if(!w[i]&&(a||i&&!O[i])){for(var s=-1,u=0;ul)&&(s=l)}var f,d;d=-1===s?n.lastIndexOf("@"):n.lastIndexOf("@",s),-1!==d&&(f=n.slice(0,d),n=n.slice(d+1),this.auth=decodeURIComponent(f)),s=-1;for(var u=0;ul)&&(s=l)}-1===s&&(s=n.length),this.host=n.slice(0,s),n=n.slice(s),this.parseHost(),this.hostname=this.hostname||"";var v="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!v)for(var _=this.hostname.split(/\./),u=0,A=_.length;A>u;u++){var S=_[u];if(S&&!S.match(E)){for(var C="",R=0,k=S.length;k>R;R++)C+=S.charCodeAt(R)>127?"x":S[R];if(!C.match(E)){var T=_.slice(0,u),F=_.slice(u+1),P=S.match(x);P&&(T.push(P[1]),F.unshift(P[2])),F.length&&(n="/"+F.join(".")+n),this.hostname=T.join(".");break}}}if(this.hostname.length>b?this.hostname="":this.hostname=this.hostname.toLowerCase(),!v){for(var N=this.hostname.split("."),L=[],u=0;uu;u++){var M=y[u],G=encodeURIComponent(M);G===M&&(G=escape(M)),n=n.split(M).join(G)}var B=n.indexOf("#");-1!==B&&(this.hash=n.substr(B),n=n.slice(0,B));var z=n.indexOf("?");if(-1!==z?(this.search=n.substr(z),this.query=n.substr(z+1),e&&(this.query=I.parse(this.query)),n=n.slice(0,z)):e&&(this.search="",this.query={}),n&&(this.pathname=n),O[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var V=this.pathname||"",D=this.search||"";this.path=V+D}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&u(this.query)&&Object.keys(this.query).length&&(o=I.stringify(this.query));var a=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||O[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),a=a.replace("#","%23"),e+i+r+a+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(c(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),O[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!O[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||w[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var o=r.pathname||"",a=r.search||"";r.path=o+a}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var s=r.pathname&&"/"===r.pathname.charAt(0),u=t.host||t.pathname&&"/"===t.pathname.charAt(0),p=u||s||r.host&&t.pathname,h=p,d=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],v=r.protocol&&!O[r.protocol];if(v&&(r.hostname="",r.port=null,r.host&&(""===d[0]?d[0]=r.host:d.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),p=p&&(""===i[0]||""===d[0])),u)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,d=i;else if(i.length)d||(d=[]),d.pop(),d=d.concat(i),r.search=t.search,r.query=t.query;else if(!f(t.search)){if(v){r.hostname=r.host=d.shift();var _=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;_&&(r.auth=_.shift(),r.host=r.hostname=_.shift())}return r.search=t.search,r.query=t.query,l(r.pathname)&&l(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!d.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var y=d.slice(-1)[0],m=(r.host||t.host)&&("."===y||".."===y)||""===y,g=0,b=d.length;b>=0;b--)y=d[b],"."==y?d.splice(b,1):".."===y?(d.splice(b,1),g++):g&&(d.splice(b,1),g--);if(!p&&!h)for(;g--;g)d.unshift("..");!p||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),m&&"/"!==d.join("/").substr(-1)&&d.push("");var E=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(v){r.hostname=r.host=E?"":d.length?d.shift():"";var _=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;_&&(r.auth=_.shift(),r.host=r.hostname=_.shift())}return p=p||r.host&&d.length,p&&!E&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),l(r.pathname)&&l(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=d.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){var n;(function(t,i){!function(o){function a(t){throw RangeError(T[t])}function s(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function c(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]),t=t.replace(k,".");var i=t.split("."),o=s(i,e).join(".");return n+o}function u(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&o>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function l(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function f(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:E}function p(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?P(t/O):t>>1,t+=P(t/e);t>F*j>>1;n+=E)t=P(t/F);return P(n+(F+1)*t/(t+w))}function d(t){var e,r,n,i,o,s,c,u,p,d,v=[],_=t.length,y=0,m=A,g=I;for(r=t.lastIndexOf(S),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&a("not-basic"),v.push(t.charCodeAt(n));for(i=r>0?r+1:0;_>i;){for(o=y,s=1,c=E;i>=_&&a("invalid-input"),u=f(t.charCodeAt(i++)),(u>=E||u>P((b-y)/s))&&a("overflow"),y+=u*s,p=g>=c?x:c>=g+j?j:c-g,!(p>u);c+=E)d=E-p,s>P(b/d)&&a("overflow"),s*=d;e=v.length+1,g=h(y-o,e,0==o),P(y/e)>b-m&&a("overflow"),m+=P(y/e),y%=e,v.splice(y++,0,m)}return l(v)}function v(t){var e,r,n,i,o,s,c,l,f,d,v,_,y,m,g,w=[];for(t=u(t),_=t.length,e=A,r=0,o=I,s=0;_>s;++s)v=t[s],128>v&&w.push(N(v));for(n=i=w.length,i&&w.push(S);_>n;){for(c=b,s=0;_>s;++s)v=t[s],v>=e&&c>v&&(c=v);for(y=n+1,c-e>P((b-r)/y)&&a("overflow"),r+=(c-e)*y,e=c,s=0;_>s;++s)if(v=t[s],e>v&&++r>b&&a("overflow"),v==e){for(l=r,f=E;d=o>=f?x:f>=o+j?j:f-o,!(d>l);f+=E)g=l-d,m=E-d,w.push(N(p(d+g%m,0))),l=P(g/m);w.push(N(p(l,0))),o=h(r,y,n==i),r=0,++n}++r,++e}return w.join("")}function _(t){return c(t,function(t){return C.test(t)?d(t.slice(4).toLowerCase()):t})}function y(t){return c(t,function(t){return R.test(t)?"xn--"+v(t):t})}var m=("object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof i&&i);m.global!==m&&m.window!==m&&m.self!==m||(o=m);var g,b=2147483647,E=36,x=1,j=26,w=38,O=700,I=72,A=128,S="-",C=/^xn--/,R=/[^\x20-\x7E]/,k=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=E-x,P=Math.floor,N=String.fromCharCode;g={version:"1.3.2",ucs2:{decode:u,encode:l},decode:d,encode:v,toASCII:y,toUnicode:_},n=function(){return g}.call(e,r,e,t),!(void 0!==n&&(t.exports=n))}(this)}).call(e,r(2)(t),function(){return this}())},function(t,e,r){"use strict";e.decode=e.parse=r(166),e.encode=e.stringify=r(167)},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,i){e=e||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var a=/\+/g;t=t.split(e);var s=1e3;i&&"number"==typeof i.maxKeys&&(s=i.maxKeys);var c=t.length;s>0&&c>s&&(c=s);for(var u=0;c>u;++u){var l,f,p,h,d=t[u].replace(a,"%20"),v=d.indexOf(n);v>=0?(l=d.substr(0,v),f=d.substr(v+1)):(l=d,f=""),p=decodeURIComponent(l),h=decodeURIComponent(f),r(o,p)?Array.isArray(o[p])?o[p].push(h):o[p]=[o[p],h]:o[p]=h}return o}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,i){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(i){var o=encodeURIComponent(r(i))+n;return Array.isArray(t[i])?t[i].map(function(t){return o+encodeURIComponent(r(t))}).join(e):o+encodeURIComponent(r(t[i]))}).join(e):i?encodeURIComponent(r(i))+n+encodeURIComponent(r(t)):""}},function(t,e,r){"use strict";function n(t,e,r,n){return this.validateSchema(t,n,e,r).valid}function i(t,e,r,n,i,o){if(!e.properties||void 0===e.properties[i])if(e.additionalProperties===!1)o.addError({name:"additionalProperties",argument:i,message:"additionalProperty "+JSON.stringify(i)+" exists in instance when not allowed"});else{var a=e.additionalProperties||{},s=this.validateSchema(t[i],a,r,n.makeChild(a,i));s.instance!==o.instance[i]&&(o.instance[i]=s.instance),o.importErrors(s)}}function o(t,e,r){var n,i=r.length;for(n=e+1,i;i>n;n++)if(a.deepCompareStrict(t,r[n]))return!1;return!0}var a=r(169),s=a.ValidatorResult,c=a.SchemaError,u={};u.ignoreProperties={id:!0,"default":!0,description:!0,title:!0,exclusiveMinimum:!0,exclusiveMaximum:!0,additionalItems:!0,$schema:!0,$ref:!0,"extends":!0};var l=u.validators={};l.type=function(t,e,r,n){if(void 0===t)return null;var i=new s(t,e,r,n),o=e.type instanceof Array?e.type:[e.type];if(!o.some(this.testType.bind(this,t,e,r,n))){var a=o.map(function(t){return t.id&&"<"+t.id+">"||t+""});i.addError({name:"type",argument:a,message:"is not of a type(s) "+a})}return i},l.anyOf=function(t,e,r,i){if(void 0===t)return null;var o=new s(t,e,r,i);if(!(e.anyOf instanceof Array))throw new c("anyOf must be an array");if(!e.anyOf.some(n.bind(this,t,r,i))){var a=e.anyOf.map(function(t,e){return t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+e+"]"});o.addError({name:"anyOf",argument:a,message:"is not any of "+a.join(",")})}return o},l.allOf=function(t,e,r,n){if(void 0===t)return null;if(!(e.allOf instanceof Array))throw new c("allOf must be an array");var i=new s(t,e,r,n),o=this;return e.allOf.forEach(function(e,a){var s=o.validateSchema(t,e,r,n);if(!s.valid){var c=e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+a+"]";i.addError({name:"allOf",argument:{id:c,length:s.errors.length,valid:s},message:"does not match allOf schema "+c+" with "+s.errors.length+" error[s]:"}),i.importErrors(s)}}),i},l.oneOf=function(t,e,r,i){if(void 0===t)return null;if(!(e.oneOf instanceof Array))throw new c("oneOf must be an array");var o=new s(t,e,r,i),a=e.oneOf.filter(n.bind(this,t,r,i)).length,u=e.oneOf.map(function(t,e){return t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+e+"]"});return 1!==a&&o.addError({name:"oneOf",argument:u,message:"is not exactly one from "+u.join(",")}),o},l.properties=function(t,e,r,n){if(void 0!==t&&t instanceof Object){var i=new s(t,e,r,n),o=e.properties||{};for(var a in o){var c=(t||void 0)&&t[a],u=this.validateSchema(c,o[a],r,n.makeChild(o[a],a));u.instance!==i.instance[a]&&(i.instance[a]=u.instance),i.importErrors(u)}return i}},l.patternProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){var o=new s(t,e,r,n),a=e.patternProperties||{};for(var c in t){var u=!0;for(var l in a){var f=new RegExp(l);if(f.test(c)){u=!1;var p=this.validateSchema(t[c],a[l],r,n.makeChild(a[l],c));p.instance!==o.instance[c]&&(o.instance[c]=p.instance),o.importErrors(p)}}u&&i.call(this,t,e,r,n,c,o)}return o}},l.additionalProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){if(e.patternProperties)return null;var o=new s(t,e,r,n);for(var a in t)i.call(this,t,e,r,n,a,o);return o}},l.minProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var i=new s(t,e,r,n),o=Object.keys(t);return o.length>=e.minProperties||i.addError({name:"minProperties",argument:e.minProperties,message:"does not meet minimum property length of "+e.minProperties}),i},l.maxProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var i=new s(t,e,r,n),o=Object.keys(t);return o.length<=e.maxProperties||i.addError({name:"maxProperties",argument:e.maxProperties,message:"does not meet maximum property length of "+e.maxProperties}),i},l.items=function(t,e,r,n){if(!(t instanceof Array))return null;var i=this,o=new s(t,e,r,n);return void 0!==t&&e.items?(t.every(function(t,a){var s=e.items instanceof Array?e.items[a]||e.additionalItems:e.items;if(void 0===s)return!0;if(s===!1)return o.addError({name:"items",message:"additionalItems not permitted"}),!1;var c=i.validateSchema(t,s,r,n.makeChild(s,a));return c.instance!==o.instance[a]&&(o.instance[a]=c.instance),o.importErrors(c),!0}),o):o},l.minimum=function(t,e,r,n){if("number"!=typeof t)return null;var i=new s(t,e,r,n),o=!0;return o=e.exclusiveMinimum&&e.exclusiveMinimum===!0?t>e.minimum:t>=e.minimum,o||i.addError({name:"minimum",argument:e.minimum,message:"must have a minimum value of "+e.minimum}),i},l.maximum=function(t,e,r,n){if("number"!=typeof t)return null;var i,o=new s(t,e,r,n);return i=e.exclusiveMaximum&&e.exclusiveMaximum===!0?t=e.minLength||i.addError({name:"minLength",argument:e.minLength,message:"does not meet minimum length of "+e.minLength}),i},l.maxLength=function(t,e,r,n){if("string"!=typeof t)return null;var i=new s(t,e,r,n);return t.length<=e.maxLength||i.addError({name:"maxLength",argument:e.maxLength,message:"does not meet maximum length of "+e.maxLength}),i},l.minItems=function(t,e,r,n){if(!(t instanceof Array))return null;var i=new s(t,e,r,n);return t.length>=e.minItems||i.addError({name:"minItems",argument:e.minItems,message:"does not meet minimum length of "+e.minItems}),i},l.maxItems=function(t,e,r,n){if(!(t instanceof Array))return null;var i=new s(t,e,r,n);return t.length<=e.maxItems||i.addError({name:"maxItems",argument:e.maxItems,message:"does not meet maximum length of "+e.maxItems}),i},l.uniqueItems=function(t,e,r,n){function i(t,e,r){for(var n=e+1;n"||a;o.addError({name:"not",argument:s,message:"is of prohibited type "+s})}}),o):null},t.exports=u},function(t,e,r){"use strict";var n=r(163),i=e.ValidationError=function(t,e,r,n,i,o){n&&(this.property=n),t&&(this.message=t),r&&(r.id?this.schema=r.id:this.schema=r),e&&(this.instance=e),this.name=i,this.argument=o,this.stack=this.toString()};i.prototype.toString=function(){return this.property+" "+this.message};var o=e.ValidatorResult=function(t,e,r,n){this.instance=t,this.schema=e,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=r&&r.throwError,this.disableFormat=r&&r.disableFormat===!0};o.prototype.addError=function(t){var e;if("string"==typeof t)e=new i(t,this.instance,this.schema,this.propertyPath);else{if(!t)throw new Error("Missing error detail");if(!t.message)throw new Error("Missing error message");if(!t.name)throw new Error("Missing validator type");e=new i(t.message,this.instance,this.schema,this.propertyPath,t.name,t.argument)}if(this.throwError)throw e;return this.errors.push(e),e},o.prototype.importErrors=function(t){if("string"==typeof t||t&&t.validatorType)this.addError(t);else if(t&&t.errors){var e=this.errors;t.errors.forEach(function(t){e.push(t)})}},o.prototype.toString=function(t){return this.errors.map(function(t,e){return e+": "+t.toString()+"\n"}).join("")},Object.defineProperty(o.prototype,"valid",{get:function(){return!this.errors.length}});var a=e.SchemaError=function l(t,e){this.message=t,this.schema=e,Error.call(this,t),Error.captureStackTrace(this,l)};a.prototype=Object.create(Error.prototype,{constructor:{value:a,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var s=e.SchemaContext=function(t,e,r,n,i){this.schema=t,this.options=e,this.propertyPath=r,this.base=n,this.schemas=i};s.prototype.resolve=function(t){return n.resolve(this.base,t)},s.prototype.makeChild=function(t,e){var r=void 0===e?this.propertyPath:this.propertyPath+u(e),i=n.resolve(this.base,t.id||""),o=new s(t,this.options,r,i,Object.create(this.schemas));return t.id&&!o.schemas[i]&&(o.schemas[i]=t),o};var c=e.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"ip-address":/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,ipv6:/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,uri:/^[a-zA-Z][a-zA-Z0-9+-.]*:[^\s]*$/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"utc-millisec":function(t){return"string"==typeof t&&parseFloat(t)===parseInt(t,10)&&!isNaN(t)},regex:function(t){var e=!0;try{new RegExp(t)}catch(r){e=!1}return e},style:/\s*(.+?):\s*([^;]+);?/g,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/};c.regexp=c.regex,c.pattern=c.regex,c.ipv4=c["ip-address"],e.isFormat=function(t,e,r){if("string"==typeof t&&void 0!==c[e]){if(c[e]instanceof RegExp)return c[e].test(t);if("function"==typeof c[e])return c[e](t)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[e])return r.customFormats[e](t);return!0};var u=e.makeSuffix=function(t){return t=t.toString(),t.match(/[.\s\[\]]/)||t.match(/^[\d]/)?t.match(/^\d+$/)?"["+t+"]":"["+JSON.stringify(t)+"]":"."+t};e.deepCompareStrict=function f(t,e){if(typeof t!=typeof e)return!1;if(t instanceof Array)return e instanceof Array?t.length!==e.length?!1:t.every(function(r,n){return f(t[n],e[n])}):!1;if("object"==typeof t){if(!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(function(r){return f(t[r],e[r])})}return t===e},t.exports.deepMerge=function p(t,e){var r=Array.isArray(e),n=r&&[]||{};return r?(t=t||[],n=n.concat(t),e.forEach(function(e,r){"object"==typeof e?n[r]=p(t[r],e):-1===t.indexOf(e)&&n.push(e)})):(t&&"object"==typeof t&&Object.keys(t).forEach(function(e){n[e]=t[e]}),Object.keys(e).forEach(function(r){"object"==typeof e[r]&&e[r]&&t[r]?n[r]=p(t[r],e[r]):n[r]=e[r]})),n},e.objectGetPath=function(t,e){for(var r,n=e.split("/").slice(1);"string"==typeof(r=n.shift());){var i=decodeURIComponent(r.replace(/~0/,"~").replace(/~1/g,"/"));if(!(i in t))return;t=t[i]}return t},e.encodePath=function(t){return t.map(function(t){return"/"+encodeURIComponent(t).replace(/~/g,"%7E")}).join("")}},function(t,e){t.exports={$schema:"http://json-schema.org/draft-04/schema#",type:"object",properties:{projectId:{type:"string"},accountId:{type:"string"},groups:{type:"array",items:{type:"object",properties:{id:{type:"string"},policy:{type:"string"},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},experiments:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},status:{type:"string"},variations:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"}},required:["id","key"]}},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},percentageIncluded:{type:"integer"},audienceIds:{type:"array",items:{type:"string"}},forcedVariations:{type:"object"}},required:["id","key","status","variations","trafficAllocation","percentageIncluded","audienceIds","forcedVariations"]}}},required:["id","policy","trafficAllocation","experiments"]}},experiments:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},status:{type:"string"},variations:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"}},required:["id","key"]}},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},percentageIncluded:{type:"integer"},audienceIds:{type:"array",items:{type:"string"}},forcedVariations:{type:"object"}},required:["id","key","status","variations","trafficAllocation","percentageIncluded","audienceIds","forcedVariations"]}},events:{type:"array",items:{type:"object",properties:{key:{type:"string"},experimentIds:{type:"array",items:{type:"string"}},id:{type:"string"}},required:["key","experimentIds","id"]}},audiences:{type:"array",items:{type:"object",properties:{id:{type:"string"},name:{type:"string"},conditions:{type:"string"}},required:["id","name","conditions"]}},dimensions:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},segmentId:{type:"string"}},required:["id","key","segmentId"]}},version:{type:"string"},revision:{type:"string"}},required:["projectId","accountId","groups","experiments","events","audiences","dimensions","version","revision"]}},function(t,e,r){var n=r(5),i=r(4),o=n.ERROR_MESSAGES,a="USER_ID_VALIDATOR";t.exports={validate:function(t){if("string"!=typeof t||""===t)throw new Error(i(o.INVALID_USER_ID,a));return!0}}}]); \ No newline at end of file +!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var n=r(1),i=r(3),o=r(6),a=r(7),s=r(5),c=r(11),u=r(12);t.exports={createInstance:function(t){var e=c.createLogger({logLevel:s.LOG_LEVEL.INFO});if(t)try{i.validate(t)}catch(r){e.log(s.LOG_LEVEL.ERROR,r.message)}return t=n.assignIn({errorHandler:o,eventDispatcher:a,logger:c.createLogger({logLevel:s.LOG_LEVEL.INFO})},t),new u(t)}}},function(t,e,r){var n;(function(t,i){(function(){function o(t,e){return t.push.apply(t,e),t}function a(t,e,r,n){for(var i=t.length,o=r+(n?1:-1);n?o--:++o0&&r(c)?e>1?E(c,e-1,r,n,i):o(i,c):n||(i[i.length]=c)}return i}function x(t,e){return t&&Be(t,e,rr)}function j(t,e){return b(e,function(e){return kt(t[e])})}function w(t,e){return t>e}function O(t,e,r,n,i){return t===e?!0:null==t||null==e||!Pt(t)&&!Nt(e)?t!==t&&e!==e:I(t,e,O,r,n,i)}function I(t,e,r,n,i,o){var a=Ze(t),s=Ze(e),c=he,u=he;a||(c=Pe.call(t),c=c==pe?be:c),s||(u=Pe.call(e),u=u==pe?be:u);var l=c==be&&!f(t),p=u==be&&!f(e),h=c==u;o||(o=[]);var d=qe(o,function(e){return e[0]===t});if(d&&d[1])return d[1]==e;if(o.push([t,e]),h&&!l){var v=a?z(t,e,r,n,i,o):X(t,e,c,r,n,i,o);return o.pop(),v}if(!(i&ue)){var _=l&&ke.call(t,"__wrapped__"),y=p&&ke.call(e,"__wrapped__");if(_||y){var m=_?t.value():t,g=y?e.value():e,v=r(m,g,n,i,o);return o.pop(),v}}if(!h)return!1;var v=Z(t,e,r,n,i,o);return o.pop(),v}function A(t){return"function"==typeof t?t:null==t?Zt:("object"==typeof t?k:P)(t)}function S(t){return Ue(Object(t))}function C(t){t=null==t?t:Object(t);var e=[];for(var r in t)e.push(r);return e}function R(t,e){return e>t}function T(t,e){var r=-1,n=Ot(t)?Array(t.length):[];return Ge(t,function(t,i,o){n[++r]=e(t,i,o)}),n}function k(t){var e=rr(t);return function(r){var n=e.length;if(null==r)return!n;for(r=Object(r);n--;){var i=e[n];if(!(i in r&&O(t[i],r[i],ne,ce|ue)))return!1}return!0}}function F(t,e){return t=Object(t),dt(e,function(e,r){return r in t&&(e[r]=t[r]),e},{})}function P(t){return function(e){return null==e?ne:e[t]}}function N(t,e,r){var n=-1,i=t.length;0>e&&(e=-e>i?0:i+e),r=r>i?i:r,0>r&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&c&&!s&&!u||n&&a&&c||!r&&c||!i)return 1;if(!n&&!o&&!u&&e>t||u&&r&&i&&!n&&!o||s&&r&&i||!a&&i||!c)return-1}return 0}function M(t,e,r,n){r||(r={});for(var i=-1,o=e.length;++i1?r[i-1]:ne;for(o=t.length>3&&"function"==typeof o?(i--,o):ne,e=Object(e);++n-1?e[o?o[a]:a]:ne}}function $(t,e,r,n){function i(){for(var e=-1,s=arguments.length,c=-1,u=n.length,l=Array(u+s),f=this&&this!==Ce&&this instanceof i?a:t;++cs))return!1;for(var u=-1,l=!0,f=i&ce?[]:ne;++ui&&(i=Me(n+i,0)),a(t,A(e,3),i)}function tt(t){var e=t?t.length:0;return e?E(t,1):[]}function et(t){var e=t?t.length:0;return e?E(t,le):[]}function rt(t){return t&&t.length?t[0]:ne}function nt(t,e,r){var n=t?t.length:0;r="number"==typeof r?0>r?Me(n+r,0):r:0;for(var i=(r||0)-1,o=e===e;++i0&&(r=e.apply(this,arguments)),1>=t&&(e=ne),r}}function gt(t){if("function"!=typeof t)throw new TypeError(oe);return function(){return!t.apply(this,arguments)}}function bt(t){return mt(2,t)}function Et(t,e){if("function"!=typeof t)throw new TypeError(oe);return e=Me(e===ne?t.length-1:Je(e),0),function(){for(var r=arguments,n=-1,i=Me(r.length-e,0),o=Array(i);++n-1&&t%1==0&&fe>=t}function Pt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return!!t&&"object"==typeof t}function Lt(t){return Vt(t)&&t!=+t}function Dt(t){return null===t}function Vt(t){return"number"==typeof t||Nt(t)&&Pe.call(t)==ge}function Ut(t){return Pt(t)&&Pe.call(t)==Ee}function Mt(t){return"string"==typeof t||!Ze(t)&&Nt(t)&&Pe.call(t)==xe}function Gt(t){return t===ne}function Bt(t){return Ot(t)?t.length?L(t):[]:zt(t)}function Ht(t){return"string"==typeof t?t:null==t?"":t+""}function Kt(t,e){var r=_(t);return e?We(r,e):r}function qt(t,e){return null!=t&&ke.call(t,e)}function $t(t,e,r){var n=null==t?ne:t[e];return n===ne&&(n=r),kt(n)?n.call(t):n}function zt(t){return t?c(t,rr(t)):[]}function Xt(t){return t=Ht(t),t&&we.test(t)?t.replace(je,l):t}function Zt(t){return t}function Jt(t){return k(We({},t))}function Qt(t,e,r){var n=rr(e),i=j(e,n);null!=r||Pt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=j(e,rr(e)));var a=!(Pt(r)&&"chain"in r&&!r.chain),s=kt(t);return Ge(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__),i=r.__actions__=L(this.__actions__);return i.push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,o([this.value()],arguments))})}),t}function Wt(){return Ce._===this&&(Ce._=Ne),this}function Yt(){}function te(t){var e=++Fe;return Ht(t)+e}function ee(t){return t&&t.length?g(t,Zt,w):ne}function re(t){return t&&t.length?g(t,Zt,R):ne}var ne,ie="4.13.1",oe="Expected a function",ae=1,se=32,ce=1,ue=2,le=1/0,fe=9007199254740991,pe="[object Arguments]",he="[object Array]",de="[object Boolean]",ve="[object Date]",_e="[object Error]",ye="[object Function]",me="[object GeneratorFunction]",ge="[object Number]",be="[object Object]",Ee="[object RegExp]",xe="[object String]",je=/[&<>"'`]/g,we=RegExp(je.source),Oe={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ie=u("object"==typeof i&&i),Ae=u("object"==typeof self&&self),Se=u("object"==typeof this&&this),Ce=Ie||Ae||Se||Function("return this")(),Re=Array.prototype,Te=Object.prototype,ke=Te.hasOwnProperty,Fe=0,Pe=Te.toString,Ne=Ce._,Le=Object.create,De=Te.propertyIsEnumerable,Ve=Ce.isFinite,Ue=Object.keys,Me=Math.max;h.prototype=_(p.prototype),h.prototype.constructor=h;var Ge=B(x),Be=H(),He=P("length"),Ke=String,qe=q(Y),$e=Et(function(t,e,r){return $(t,ae|se,e,r)}),ze=Et(function(t,e){return y(t,1,e)}),Xe=Et(function(t,e,r){return y(t,Qe(e)||0,r)}),Ze=Array.isArray,Je=Number,Qe=Number,We=G(function(t,e){M(e,rr(e),t)}),Ye=G(function(t,e){M(e,nr(e),t)}),tr=G(function(t,e,r,n){M(e,nr(e),t,n)}),er=Et(function(t){return t.push(ne,d),tr.apply(ne,t)}),rr=S,nr=C,ir=Et(function(t,e){return null==t?{}:F(t,T(E(e,1),Ke))}),or=A;p.assignIn=Ye,p.before=mt,p.bind=$e,p.chain=at,p.compact=Q,p.concat=W,p.create=Kt,p.defaults=er,p.defer=ze,p.delay=Xe,p.filter=ft,p.flatten=tt,p.flattenDeep=et,p.iteratee=or,p.keys=rr,p.map=ht,p.matches=Jt,p.mixin=Qt,p.negate=gt,p.once=bt,p.pick=ir,p.slice=ot,p.sortBy=yt,p.tap=st,p.thru=ct,p.toArray=Bt,p.values=zt,p.extend=Ye,Qt(p,p),p.clone=xt,p.escape=Xt,p.every=lt,p.find=qe,p.forEach=pt,p.has=qt,p.head=rt,p.identity=Zt,p.indexOf=nt,p.isArguments=wt,p.isArray=Ze,p.isBoolean=At,p.isDate=St,p.isEmpty=Ct,p.isEqual=Rt,p.isFinite=Tt,p.isFunction=kt,p.isNaN=Lt,p.isNull=Dt,p.isNumber=Vt,p.isObject=Pt,p.isRegExp=Ut,p.isString=Mt,p.isUndefined=Gt,p.last=it,p.max=ee,p.min=re,p.noConflict=Wt,p.noop=Yt,p.reduce=dt,p.result=$t,p.size=vt,p.some=_t,p.uniqueId=te,p.each=pt,p.first=rt,Qt(p,function(){var t={};return x(p,function(e,r){ke.call(p.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),p.VERSION=ie,Ge(["pop","join","replace","reverse","split","push","shift","sort","splice","unshift"],function(t){var e=(/^(?:replace|split)$/.test(t)?String.prototype:Re)[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|join|replace|shift)$/.test(t);p.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Ze(i)?i:[],t)}return this[r](function(r){return e.apply(Ze(r)?r:[],t)})}}),p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ut,(Ae||{})._=p,n=function(){return p}.call(e,r,e,t),!(n!==ne&&(t.exports=n))}).call(this)}).call(e,r(2)(t),function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,r){var n=r(4),i=r(5).ERROR_MESSAGES,o="CONFIG_VALIDATOR";t.exports={validate:function(t){if(t.errorHandler&&"function"!=typeof t.errorHandler.handleError)throw new Error(n(i.INVALID_ERROR_HANDLER,o));if(t.eventDispatcher&&"function"!=typeof t.eventDispatcher.dispatchEvent)throw new Error(n(i.INVALID_EVENT_DISPATCHER,o));if(t.logger&&"function"!=typeof t.logger.log)throw new Error(n(i.INVALID_LOGGER,o));return!0}}},function(t,e){var r=function(){function t(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function e(t,e){for(var r=[];e>0;r[--e]=t);return r.join("")}var n=function(){return n.cache.hasOwnProperty(arguments[0])||(n.cache[arguments[0]]=n.parse(arguments[0])),n.format.call(null,n.cache[arguments[0]],arguments)};return n.object_stringify=function(t,e,r,i){var o="";if(null!=t)switch(typeof t){case"function":return"[Function"+(t.name?": "+t.name:"")+"]";case"object":if(t instanceof Error)return"["+t.toString()+"]";if(e>=r)return"[Object]";if(i&&(i=i.slice(0),i.push(t)),null!=t.length){o+="[";var a=[];for(var s in t)i&&i.indexOf(t[s])>=0?a.push("[Circular]"):a.push(n.object_stringify(t[s],e+1,r,i));o+=a.join(", ")+"]"}else{if("getMonth"in t)return"Date("+t+")";o+="{";var a=[];for(var c in t)t.hasOwnProperty(c)&&(i&&i.indexOf(t[c])>=0?a.push(c+": [Circular]"):a.push(c+": "+n.object_stringify(t[c],e+1,r,i)));o+=a.join(", ")+"}"}return o;case"string":return'"'+t+'"'}return""+t},n.format=function(i,o){var a,s,c,u,l,f,p,h=1,d=i.length,v="",_=[];for(s=0;d>s;s++)if(v=t(i[s]),"string"===v)_.push(i[s]);else if("array"===v){if(u=i[s],u[2])for(a=o[h],c=0;c=0?"+"+a:a,f=u[4]?"0"==u[4]?"0":u[4].charAt(1):" ",p=u[6]-String(a).length,l=u[6]?e(f,p):"",_.push(u[5]?a+l:l+a)}return _.join("")},n.cache={},n.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=/^[^\x25]+/.exec(e)))n.push(r[0]);else if(null!==(r=/^\x25{2}/.exec(e)))n.push("%");else{if(null===(r=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(e)))throw new Error("[sprintf] "+e);if(r[2]){i|=1;var o=[],a=r[2],s=[];if(null===(s=/^([a-z_][a-z_\d]*)/i.exec(a)))throw new Error("[sprintf] "+a);for(o.push(s[1]);""!==(a=a.substring(s[0].length));)if(null!==(s=/^\.([a-z_][a-z_\d]*)/i.exec(a)))o.push(s[1]);else{if(null===(s=/^\[(\d+)\]/.exec(a)))throw new Error("[sprintf] "+a);o.push(s[1])}r[2]=o}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push(r)}e=e.substring(r[0].length)}return n},n}(),n=function(t,e){var n=e.slice();return n.unshift(t),r.apply(null,n)};t.exports=r,r.sprintf=r,r.vsprintf=n},function(t,e){e.LOG_LEVEL={NOTSET:0,DEBUG:1,INFO:2,WARNING:3,ERROR:4},e.ERROR_MESSAGES={INVALID_ATTRIBUTES:"%s: Provided attributes are in an invalid format.",INVALID_BUCKETING_ID:"%s: Unable to generate hash for bucketing ID %s: %s",INVALID_DATAFILE:"%s: Datafile is invalid: %s",INVALID_JSON:"%s: JSON object is not valid.",INVALID_ERROR_HANDLER:'%s: Provided "errorHandler" is in an invalid format.',INVALID_EVENT_DISPATCHER:'%s: Provided "eventDispatcher" is in an invalid format.',INVALID_EVENT_KEY:"%s: Event key %s is not in datafile.",INVALID_EXPERIMENT_KEY:"%s: Experiment key %s is not in datafile.",INVALID_GROUP_ID:"%s: Group ID %s is not in datafile.",INVALID_LOGGER:'%s: Provided "logger" is in an invalid format.',INVALID_USER_ID:"%s: Provided user ID is in an invalid format.",JSON_SCHEMA_EXPECTED:"%s: JSON schema expected.",NO_DATAFILE_SPECIFIED:"%s: No datafile specified. Cannot start optimizely.",NO_JSON_PROVIDED:"%s: No JSON object to validate against schema."},e.LOG_MESSAGES={ACTIVATE_USER:"%s: Activating user %s in experiment %s.",DISPATCH_CONVERSION_EVENT:"%s: Dispatching conversion event to URL %s with params %s.",DISPATCH_IMPRESSION_EVENT:"%s: Dispatching impression event to URL %s with params %s.",EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS:"%s: Event %s is not associated with any running experiments.",EXPERIMENT_NOT_RUNNING:"%s: Experiment %s is not running.",FORCED_BUCKETING_FAILED:"%s: Variation key %s is not in datafile. Not activating user %s.",NO_VALID_EXPERIMENTS_FOR_GOAL_TO_TRACK:"%s: There are no valid experiments for event %s to track.",NOT_ACTIVATING_USER:"%s: Not activating user %s for experiment %s.",NOT_TRACKING_USER_FOR_EXPERIMENT:"%s: Not tracking user %s for experiment %s.",TRACK_EVENT:"%s: Tracking event %s for user %s.",USER_ASSIGNED_TO_VARIATION_BUCKET:"%s: Assigned variation bucket %s to user %s.",USER_ASSIGNED_TO_EXPERIMENT_BUCKET:"%s: Assigned experiment bucket %s to user %s.",USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is in experiment %s of group %s.",USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP:"%s: User %s is not in experiment %s of group %s.",USER_NOT_IN_EXPERIMENT:"%s: User %s is in no experiment.",USER_FORCED_IN_VARIATION:"%s: User %s is forced in variation %s.",USER_HAS_VARIATION:"%s: User %s is in variation %s of experiment %s.",USER_HAS_NO_VARIATION:"%s: User %s is in no variation of experiment %s.",USER_NOT_IN_ANY_EXPERIMENT:"%s: User %s is not in any experiment of group %s.",USER_NOT_IN_EXPERIMENT:"%s: User %s does not meet conditions to be in experiment %s.",VALID_DATAFILE:"%s: Datafile is valid."}},function(t,e){t.exports={handleError:function(t){}}},function(t,e,r){var n=r(1),i=r(8);t.exports={dispatchEvent:function(t,e){return new i(function(r,n){e&&(t+="?"+o(e));var i=new XMLHttpRequest;i.open("GET",t,!0),i.addEventListener("load",function(t){var e=JSON.parse(t.target.responseText);r(e)}),i.send()})}};var o=function(t){return n.map(t,function(t,e){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&")}},function(t,e,r){(function(e,r,n){!function(e){t.exports=e()}(function(){var t,i,o;return function a(t,e,r){function n(o,s){if(!e[o]){if(!t[o]){var c="function"==typeof _dereq_&&_dereq_;if(!s&&c)return c(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=e[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return n(r?r:e)},l,l.exports,a,t,e,r)}return e[o].exports}for(var i="function"==typeof _dereq_&&_dereq_,o=0;o0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},i.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},i.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},i.prototype._reset=function(){this._isTickUsed=!1},r.exports=i,r.exports.firstLineError=c},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,r){"use strict";e.exports=function(t,e,r,n){var i=!1,o=function(t,e){this._reject(e)},a=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(o,o,null,this,t)},s=function(t,e){0===(50397184&this._bitField)&&this._resolveCallback(e.target)},c=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(o){i||(i=!0,t.prototype._propagateFrom=n.propagateFromFunction(),t.prototype._boundValue=n.boundValueFunction());var u=r(o),l=new t(e);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(u),u instanceof t){var p={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:u};f._then(e,a,void 0,l,p),u._then(s,c,void 0,l,p),l._setOnCancel(u)}else l._resolveCallback(f);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},t.bind=function(e,r){return t.resolve(r).bind(e)}}},{}],4:[function(t,e,r){"use strict";function n(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise")();o.noConflict=n,e.exports=o},{"./promise":22}],5:[function(t,e,r){"use strict";var n=Object.create;if(n){var i=n(null),o=n(null);i[" size"]=o[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+s.classString(t)+" has no method '"+s.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var a,s=t("./util"),c=s.canEvaluate;s.isIdentifier;e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(n,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(c){var n=a(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util"),a=o.tryCatch,s=o.errorObj,c=e._async;e.prototype["break"]=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t.isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var r=t._cancellationParent;if(null==r||!r.isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),e=t,t=r}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),this._enoughBranchesHaveCancelled()?(this._invokeOnCancel(),!0):!1)},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this.isCancellable()&&(this._setCancelled(),c.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var r=0;r=0?o[t]:void 0}var i=!1,o=[];return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},e.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,o.push(this._trace))},e.prototype._popContext=function(){if(void 0!==this._trace){var t=o.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},e.CapturedTrace=null,e.create=r,e.deactivateLongStackTraces=function(){},e.activateLongStackTraces=function(){var r=t.prototype._pushContext,o=t.prototype._popContext,a=t._peekContext,s=t.prototype._peekContext,c=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=r,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=c,i=!1},i=!0,t.prototype._pushContext=e.prototype._pushContext,t.prototype._popContext=e.prototype._popContext,t._peekContext=t.prototype._peekContext=n,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},e}},{}],9:[function(t,r,n){"use strict";r.exports=function(r,n){function i(t,e){return{promise:e}}function o(){return!1}function a(t,e,r){var n=this;try{t(e,r,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+U.toString(t));n._attachCancellationCallback(t)})}catch(i){return i}}function s(t){if(!this.isCancellable())return this;var e=this._onCancel();void 0!==e?U.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function c(){return this._onCancelField}function u(t){this._onCancelField=t}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(t,e){if(0!==(1&e)){this._cancellationParent=t;var r=t._branchesRemainingToCancel;void 0===r&&(r=0),t._branchesRemainingToCancel=r+1}0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function p(t,e){0!==(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}function h(){var t=this._boundTo;return void 0!==t&&t instanceof r?t.isFulfilled()?t.value():void 0:t}function d(){this._trace=new k(this._peekContext())}function v(t,e){if(M(t)){var r=this._trace;if(void 0!==r&&e&&(r=r._parent),void 0!==r)r.attachExtraTrace(t);else if(!t.__stackCleaned__){var n=w(t);U.notEnumerableProp(t,"stack",n.message+"\n"+n.stack.join("\n")),U.notEnumerableProp(t,"__stackCleaned__",!0)}}}function _(t,e,r,n,i){if(void 0===t&&null!==e&&X){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&n._bitField))return;r&&(r+=" ");var o="a promise was created in a "+r+"handler but was not returned from it";n._warn(o,!0,e)}}function y(t,e){var r=t+" is deprecated and will be removed in a future version.";return e&&(r+=" Use "+e+" instead."),m(r)}function m(t,e,n){if(it.warnings){var i,o=new V(t);if(e)n._attachExtraTrace(o);else if(it.longStackTraces&&(i=r._peekContext()))i.attachExtraTrace(o);else{var a=w(o);o.stack=a.message+"\n"+a.stack.join("\n")}Y("warning",o)||O(o,"",!0)}}function g(t,e){for(var r=0;r=0;--s)if(n[s]===o){a=s;break}for(var s=a;s>=0;--s){var c=n[s];if(e[i]!==c)break;e.pop(),i--}e=n}}function x(t){for(var e=[],r=0;r0&&(e=e.slice(r)),e}function w(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?j(t):[" (No stack trace)"],{message:r,stack:x(e)}}function O(t,e,r){if("undefined"!=typeof console){var n;if(U.isObject(t)){var i=t.stack;n=e+H(i,t)}else n=e+String(t);"function"==typeof N?N(n,r):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(n)}}function I(t,e,r,n){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(n):e(r,n))}catch(o){D.throwLater(o)}"unhandledRejection"===t?Y(t,r,n)||i||O(r,"Unhandled rejection "):Y(t,n)}function A(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{ +e=t&&"function"==typeof t.toString?t.toString():U.toString(t);var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+S(e)+">, no stack trace)"}function S(t){var e=41;return t.lengtha||0>s||!r||!n||r!==n||a>=s||(et=function(t){if(G.test(t))return!0;var e=R(t);return!!(e&&e.fileName===r&&a<=e.line&&e.line<=s)})}}function k(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);nt(this,k),e>32&&this.uncycle()}var F,P,N,L=r._getDomain,D=r._async,V=t("./errors").Warning,U=t("./util"),M=U.canAttachTrace,G=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,B=null,H=null,K=!1,q=!(0==U.env("BLUEBIRD_DEBUG")),$=!(0==U.env("BLUEBIRD_WARNINGS")||!q&&!U.env("BLUEBIRD_WARNINGS")),z=!(0==U.env("BLUEBIRD_LONG_STACK_TRACES")||!q&&!U.env("BLUEBIRD_LONG_STACK_TRACES")),X=0!=U.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&($||!!U.env("BLUEBIRD_W_FORGOTTEN_RETURN"));r.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},r.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),D.invokeLater(this._notifyUnhandledRejection,this,void 0))},r.prototype._notifyUnhandledRejectionIsHandled=function(){I("rejectionHandled",F,void 0,this)},r.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},r.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},r.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),I("unhandledRejection",P,t,this)}},r.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},r.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},r.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},r.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},r.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},r.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},r.prototype._warn=function(t,e,r){return m(t,e,r||this)},r.onPossiblyUnhandledRejection=function(t){var e=L();P="function"==typeof t?null===e?t:e.bind(t):void 0},r.onUnhandledRejectionHandled=function(t){var e=L();F="function"==typeof t?null===e?t:e.bind(t):void 0};var Z=function(){};r.longStackTraces=function(){if(D.haveItemsQueued()&&!it.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!it.longStackTraces&&C()){var t=r.prototype._captureStackTrace,e=r.prototype._attachExtraTrace;it.longStackTraces=!0,Z=function(){if(D.haveItemsQueued()&&!it.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");r.prototype._captureStackTrace=t,r.prototype._attachExtraTrace=e,n.deactivateLongStackTraces(),D.enableTrampoline(),it.longStackTraces=!1},r.prototype._captureStackTrace=d,r.prototype._attachExtraTrace=v,n.activateLongStackTraces(),D.disableTrampolineIfNecessary()}},r.hasLongStackTraces=function(){return it.longStackTraces&&C()};var J=function(){try{var t=document.createEvent("CustomEvent");return t.initCustomEvent("testingtheevent",!1,!0,{}),U.global.dispatchEvent(t),function(t,e){var r=document.createEvent("CustomEvent");return r.initCustomEvent(t.toLowerCase(),!1,!0,e),!U.global.dispatchEvent(r)}}catch(e){}return function(){return!1}}(),Q=function(){return U.isNode?function(){return e.emit.apply(e,arguments)}:U.global?function(t){var e="on"+t.toLowerCase(),r=U.global[e];return r?(r.apply(U.global,[].slice.call(arguments,1)),!0):!1}:function(){return!1}}(),W={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(t,e,r){return{promise:e,child:r}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,r){return{reason:e,promise:r}},rejectionHandled:i},Y=function(t){var e=!1;try{e=Q.apply(null,arguments)}catch(r){D.throwLater(r),e=!0}var n=!1;try{n=J(t,W[t].apply(null,arguments))}catch(r){D.throwLater(r),n=!0}return n||e};r.config=function(t){if(t=Object(t),"longStackTraces"in t&&(t.longStackTraces?r.longStackTraces():!t.longStackTraces&&r.hasLongStackTraces()&&Z()),"warnings"in t){var e=t.warnings;it.warnings=!!e,X=it.warnings,U.isObject(e)&&"wForgottenReturn"in e&&(X=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!it.cancellation){if(D.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");r.prototype._clearCancellationData=l,r.prototype._propagateFrom=f,r.prototype._onCancel=c,r.prototype._setOnCancel=u,r.prototype._attachCancellationCallback=s,r.prototype._execute=a,tt=f,it.cancellation=!0}"monitoring"in t&&(t.monitoring&&!it.monitoring?(it.monitoring=!0,r.prototype._fireEvent=Y):!t.monitoring&&it.monitoring&&(it.monitoring=!1,r.prototype._fireEvent=o))},r.prototype._fireEvent=o,r.prototype._execute=function(t,e,r){try{t(e,r)}catch(n){return n}},r.prototype._onCancel=function(){},r.prototype._setOnCancel=function(t){},r.prototype._attachCancellationCallback=function(t){},r.prototype._captureStackTrace=function(){},r.prototype._attachExtraTrace=function(){},r.prototype._clearCancellationData=function(){},r.prototype._propagateFrom=function(t,e){};var tt=p,et=function(){return!1},rt=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;U.inherits(k,Error),n.CapturedTrace=k,k.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var a=e[n].stack,s=r[a];if(void 0!==s&&s!==n){s>0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var c=n>0?e[n-1]:this;t-1>s?(c._parent=e[s+1],c._parent.uncycle(),c._length=c._parent._length+1):(c._parent=void 0,c._length=1);for(var u=c._length+1,l=n-2;l>=0;--l)e[l]._length=u,u++;return}}}},k.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=w(t),r=e.message,n=[e.stack],i=this;void 0!==i;)n.push(x(i.stack.split("\n"))),i=i._parent;E(n),b(n),U.notEnumerableProp(t,"stack",g(r,n)),U.notEnumerableProp(t,"__stackCleaned__",!0)}};var nt=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():A(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,B=t,H=e;var r=Error.captureStackTrace;return et=function(t){return G.test(t)},function(t,e){Error.stackTraceLimit+=6,r(t,e),Error.stackTraceLimit-=6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return B=/@/,H=e,K=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in n||!i||"number"!=typeof Error.stackTraceLimit?(H=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?A(e):e.toString()},null):(B=t,H=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(N=function(t){console.warn(t)},U.isNode&&e.stderr.isTTY?N=function(t,e){var r=e?"":"";console.warn(r+t+"\n")}:U.isNode||"string"!=typeof(new Error).stack||(N=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var it={warnings:$,longStackTraces:!1,cancellation:!1,monitoring:!1};return z&&r.longStackTraces(),{longStackTraces:function(){return it.longStackTraces},warnings:function(){return it.warnings},cancellation:function(){return it.cancellation},monitoring:function(){return it.monitoring},propagateFromFunction:function(){return tt},boundValueFunction:function(){return h},checkForgottenReturns:_,setBounds:T,warn:m,deprecated:y,CapturedTrace:k,fireDomEvent:J,fireGlobalEvent:Q}}},{"./errors":12,"./util":36}],10:[function(t,e,r){"use strict";e.exports=function(t){function e(){return this.value}function r(){throw this.reason}t.prototype["return"]=t.prototype.thenReturn=function(r){return r instanceof t&&r.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:r},void 0)},t.prototype["throw"]=t.prototype.thenThrow=function(t){return this._then(r,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,r,void 0,{reason:t},void 0);var e=arguments[1],n=function(){throw e};return this.caught(t,n)},t.prototype.catchReturn=function(r){if(arguments.length<=1)return r instanceof t&&r.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:r},void 0);var n=arguments[1];n instanceof t&&n.suppressUnhandledRejections();var i=function(){return n};return this.caught(r,i)}}},{}],11:[function(t,e,r){"use strict";e.exports=function(t,e){function r(){return o(this)}function n(t,r){return i(t,r,e,e)}var i=t.reduce,o=t.all;t.prototype.each=function(t){return this.mapSeries(t)._then(r,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,e){return n(t,e)._then(r,void 0,void 0,t,void 0)},t.mapSeries=n}},{}],12:[function(t,e,r){"use strict";function n(t,e){function r(n){return this instanceof r?(f(this,"message","string"==typeof n?n:e),f(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return l(r,Error),r}function i(t){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(f(this,"message",t.message),f(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,a,s=t("./es5"),c=s.freeze,u=t("./util"),l=u.inherits,f=u.notEnumerableProp,p=n("Warning","warning"),h=n("CancellationError","cancellation error"),d=n("TimeoutError","timeout error"),v=n("AggregateError","aggregate error");try{o=TypeError,a=RangeError}catch(_){o=n("TypeError","type error"),a=n("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),m=0;m1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0):!1}function a(){return c.call(this,this.promise._target()._settledValue())}function s(t){return o(this,t)?void 0:(f.e=t,f)}function c(t){var n=this.promise,c=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?c.call(n._boundValue()):c.call(n._boundValue(),t);if(void 0!==u){n._setReturnedNonUndefined();var p=r(u,n);if(p instanceof e){if(null!=this.cancelPromise){if(p.isCancelled()){var h=new l("late cancellation observer");return n._attachExtraTrace(h),f.e=h,f}p.isPending()&&p._attachCancellationCallback(new i(this))}return p._then(a,s,void 0,this,void 0)}}}return n.isRejected()?(o(this),f.e=t,f):(o(this),t)}var u=t("./util"),l=e.CancellationError,f=u.errorObj;return n.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){o(this.finallyHandler)},e.prototype._passThrough=function(t,e,r,i){return"function"!=typeof t?this.then():this._then(r,i,void 0,new n(this,e,t),void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThrough(t,0,c,c)},e.prototype.tap=function(t){return this._passThrough(t,1,c)},n}},{"./util":36}],16:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,r,n){for(var o=0;o0&&"function"==typeof arguments[e]){t=arguments[e];var n}var i=[].slice.call(arguments);t&&i.pop();var n=new r(i).promise();return void 0!==t?n.spread(t):n}}},{"./util":36}],18:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace();var i=u();this._callback=null===i?e:i.bind(e),this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:h,this._init$(void 0,-2)}function c(t,r,i,o){if("function"!=typeof r)return n("expecting a function but got "+l.classString(r));var a=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+l.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+l.classString(i.concurrency)));a=i.concurrency}return a="number"==typeof a&&isFinite(a)&&a>=1?a:0,new s(t,r,a,o).promise()}var u=e._getDomain,l=t("./util"),f=l.tryCatch,p=l.errorObj,h=[];l.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,c=this._limit;if(0>r){if(r=-1*r-1,n[r]=t,c>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(c>=1&&this._inFlight>=c)return n[r]=t,this._queue.push(r),!1;null!==s&&(s[r]=t);var u=this._promise,l=this._callback,h=u._boundValue();u._pushContext();var d=f(l).call(h,t,r,o),v=u._popContext();if(a.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",u),d===p)return this._reject(d.e),!0;var _=i(d,this._promise);if(_ instanceof e){_=_._target();var y=_._bitField;if(0===(50397184&y))return c>=1&&this._inFlight++,n[r]=_,_._proxy(this,-1*(r+1)),!1;if(0===(33554432&y))return 0!==(16777216&y)?(this._reject(_._reason()),!0):(this._cancel(),!0);d=_._value()}n[r]=d}var m=++this._totalResolved;return m>=o?(null!==s?this._filter(n,s):this._resolve(n),!0):!1},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlighto;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return c(this,t,e,null)},e.map=function(t,e,r,n){return c(t,e,r,n)}}},{"./util":36}],19:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){var a=t("./util"),s=a.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("expecting a function but got "+a.classString(t));return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments),a=n._popContext();return o.checkForgottenReturns(i,a,"Promise.method",n),n._resolveFromSyncValue(i),n}},e.attempt=e["try"]=function(t){if("function"!=typeof t)return i("expecting a function but got "+a.classString(t));var n=new e(r);n._captureStackTrace(),n._pushContext();var c;if(arguments.length>1){o.deprecated("calling Promise.try with more than 1 argument");var u=arguments[1],l=arguments[2];c=a.isArray(u)?s(t).apply(l,u):s(t).call(l,u)}else c=s(t)();var f=n._popContext();return o.checkForgottenReturns(c,f,"Promise.try",n),n._resolveFromSyncValue(c),n},e.prototype._resolveFromSyncValue=function(t){t===a.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,r){"use strict";function n(t){return t instanceof Error&&l.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(n(t)){e=new u(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var r=l.keys(t),i=0;i1){var r,n=new Array(e-1),i=0;for(r=0;e-1>r;++r){var o=arguments[r];if(!h.isObject(o))return f("expecting an object but got "+h.classString(o));n[i++]=o}return n.length=i,t=arguments[r],this.then(void 0,C(n,t,this))}return this.then(void 0,t)},i.prototype.reflect=function(){return this._then(l,l,void 0,this,void 0)},i.prototype.then=function(t,e){if(A.warnings()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var r=".then() only accepts functions but was passed: "+h.classString(t);arguments.length>1&&(r+=", "+h.classString(e)),this._warn(r)}return this._then(t,e,void 0,void 0,void 0)},i.prototype.done=function(t,e){var r=this._then(t,e,void 0,void 0,void 0);r._setIsFinal()},i.prototype.spread=function(t){return"function"!=typeof t?f("expecting a function but got "+h.classString(t)):this.all()._then(t,void 0,void 0,E,void 0)},i.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},i.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new w(this).promise()},i.prototype.error=function(t){return this.caught(h.originatesFromRejection,t)},i.is=function(t){return t instanceof i},i.fromNode=i.fromCallback=function(t){var e=new i(b);e._captureStackTrace();var r=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,n=k(t)(R(e,r));return n===T&&e._rejectCallback(n.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},i.all=function(t){return new w(t).promise()},i.cast=function(t){var e=j(t);return e instanceof i||(e=new i(b),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},i.resolve=i.fulfilled=i.cast,i.reject=i.rejected=function(t){var e=new i(b);return e._captureStackTrace(),e._rejectCallback(t,!0),e},i.setScheduler=function(t){if("function"!=typeof t)throw new m("expecting a function but got "+h.classString(t));return _.setScheduler(t)},i.prototype._then=function(t,e,r,n,o){var a=void 0!==o,s=a?o:new i(b),u=this._target(),l=u._bitField;a||(s._propagateFrom(this,3),s._captureStackTrace(),void 0===n&&0!==(2097152&this._bitField)&&(n=0!==(50397184&l)?this._boundValue():u===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,s));var f=c();if(0!==(50397184&l)){var p,h,d=u._settlePromiseCtx;0!==(33554432&l)?(h=u._rejectionHandler0,p=t):0!==(16777216&l)?(h=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(d=u._settlePromiseLateCancellationObserver,h=new g("late cancellation observer"),u._attachExtraTrace(h),p=e),_.invoke(d,u,{handler:null===f?p:"function"==typeof p&&f.bind(p),promise:s,receiver:n,value:h})}else u._addCallbacks(t,e,s,n,f);return s},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(t){this._bitField=-65536&this._bitField|65535&t},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=-65537&this._bitField},i.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},i.prototype._setAsyncGuaranteed=function(){_.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},i.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==p)return void 0===e&&this._isBound()?this._boundValue():e},i.prototype._promiseAt=function(t){return this[4*t-4+2]},i.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},i.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},i.prototype._boundValue=function(){},i.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),r=t._rejectionHandler0,n=t._promise0,i=t._receiverAt(0);void 0===i&&(i=p),this._addCallbacks(e,r,n,i,null)},i.prototype._migrateCallbackAt=function(t,e){var r=t._fulfillmentHandlerAt(e),n=t._rejectionHandlerAt(e),i=t._promiseAt(e),o=t._receiverAt(e);void 0===o&&(o=p),this._addCallbacks(r,n,i,o,null)},i.prototype._addCallbacks=function(t,e,r,n,i){var o=this._length();if(o>=65531&&(o=0,this._setLength(0)),0===o)this._promise0=r,this._receiver0=n,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:i.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:i.bind(e));else{var a=4*o-4;this[a+2]=r,this[a+3]=n,"function"==typeof t&&(this[a+0]=null===i?t:i.bind(t)),"function"==typeof e&&(this[a+1]=null===i?e:i.bind(e))}return this._setLength(o+1),o},i.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},i.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(u(),!1);var r=j(t,this);if(!(r instanceof i))return this._fulfill(t);e&&this._propagateFrom(r,2);var n=r._target();if(n===this)return void this._reject(u());var o=n._bitField;if(0===(50397184&o)){var a=this._length();a>0&&n._migrateCallback0(this);for(var s=1;a>s;++s)n._migrateCallbackAt(this,s);this._setFollowing(),this._setLength(0),this._setFollowee(n)}else if(0!==(33554432&o))this._fulfill(n._value());else if(0!==(16777216&o))this._reject(n._reason());else{var c=new g("late cancellation observer");n._attachExtraTrace(c),this._reject(c)}}},i.prototype._rejectCallback=function(t,e,r){var n=h.ensureErrorObject(t),i=n===t;if(!i&&!r&&A.warnings()){var o="a promise was rejected with a non-error: "+h.classString(t);this._warn(o,!0)}this._attachExtraTrace(n,e?i:!1),this._reject(t)},i.prototype._resolveFromExecutor=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=this._execute(t,function(t){e._resolveCallback(t)},function(t){e._rejectCallback(t,r)});r=!1,this._popContext(),void 0!==n&&e._rejectCallback(n,!0)},i.prototype._settlePromiseFromHandler=function(t,e,r,n){var i=n._bitField;if(0===(65536&i)){n._pushContext();var o;e===E?r&&"number"==typeof r.length?o=k(t).apply(this._boundValue(),r):(o=T,o.e=new m("cannot .spread() a non-array: "+h.classString(r))):o=k(t).call(e,r); +var a=n._popContext();i=n._bitField,0===(65536&i)&&(o===x?n._reject(r):o===T?n._rejectCallback(o.e,!1):(A.checkForgottenReturns(o,a,"",n,this),n._resolveCallback(o)))}},i.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},i.prototype._followee=function(){return this._rejectionHandler0},i.prototype._setFollowee=function(t){this._rejectionHandler0=t},i.prototype._settlePromise=function(t,e,n,o){var a=t instanceof i,s=this._bitField,c=0!==(134217728&s);0!==(65536&s)?(a&&t._invokeInternalOnCancel(),n instanceof S&&n.isFinallyHandler()?(n.cancelPromise=t,k(e).call(n,o)===T&&t._reject(T.e)):e===l?t._fulfill(l.call(n)):n instanceof r?n._promiseCancelled(t):a||t instanceof w?t._cancel():n.cancel()):"function"==typeof e?a?(c&&t._setAsyncGuaranteed(),this._settlePromiseFromHandler(e,n,o,t)):e.call(n,o,t):n instanceof r?n._isResolved()||(0!==(33554432&s)?n._promiseFulfilled(o,t):n._promiseRejected(o,t)):a&&(c&&t._setAsyncGuaranteed(),0!==(33554432&s)?t._fulfill(o):t._reject(o))},i.prototype._settlePromiseLateCancellationObserver=function(t){var e=t.handler,r=t.promise,n=t.receiver,o=t.value;"function"==typeof e?r instanceof i?this._settlePromiseFromHandler(e,n,o,r):e.call(n,o,r):r instanceof i&&r._reject(o)},i.prototype._settlePromiseCtx=function(t){this._settlePromise(t.promise,t.handler,t.receiver,t.value)},i.prototype._settlePromise0=function(t,e,r){var n=this._promise0,i=this._receiverAt(0);this._promise0=void 0,this._receiver0=void 0,this._settlePromise(n,t,i,e)},i.prototype._clearCallbackDataAtIndex=function(t){var e=4*t-4;this[e+2]=this[e+3]=this[e+0]=this[e+1]=void 0},i.prototype._fulfill=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(t===this){var r=u();return this._attachExtraTrace(r),this._reject(r)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():_.settlePromises(this))}},i.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?_.fatalError(t,h.isNode):void((65535&e)>0?_.settlePromises(this):this._ensurePossibleRejectionHandled())},i.prototype._fulfillPromises=function(t,e){for(var r=1;t>r;r++){var n=this._fulfillmentHandlerAt(r),i=this._promiseAt(r),o=this._receiverAt(r);this._clearCallbackDataAtIndex(r),this._settlePromise(i,n,o,e)}},i.prototype._rejectPromises=function(t,e){for(var r=1;t>r;r++){var n=this._rejectionHandlerAt(r),i=this._promiseAt(r),o=this._receiverAt(r);this._clearCallbackDataAtIndex(r),this._settlePromise(i,n,o,e)}},i.prototype._settlePromises=function(){var t=this._bitField,e=65535&t;if(e>0){if(0!==(16842752&t)){var r=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,r,t),this._rejectPromises(e,r)}else{var n=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,n,t),this._fulfillPromises(e,n)}this._setLength(0)}this._clearCancellationData()},i.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},i.defer=i.pending=function(){A.deprecated("Promise.defer","new Promise");var t=new i(b);return{promise:t,resolve:o,reject:a}},h.notEnumerableProp(i,"_makeSelfResolutionError",u),t("./method")(i,b,j,f,A),t("./bind")(i,b,j,A),t("./cancel")(i,w,f,A),t("./direct_resolve")(i),t("./synchronous_inspection")(i),t("./join")(i,w,j,b,A),i.Promise=i,i.version="3.4.0",t("./map.js")(i,w,f,j,b,A),t("./call_get.js")(i),t("./using.js")(i,f,j,I,b,A),t("./timers.js")(i,b,A),t("./generators.js")(i,f,b,j,r,A),t("./nodeify.js")(i),t("./promisify.js")(i,b),t("./props.js")(i,w,j,f),t("./race.js")(i,b,j,f),t("./reduce.js")(i,w,f,j,b,A),t("./settle.js")(i,w,A),t("./some.js")(i,w,f),t("./filter.js")(i,b),t("./each.js")(i,b),t("./any.js")(i),h.toFastProperties(i),h.toFastProperties(i.prototype),s({a:1}),s({b:2}),s({c:3}),s(1),s(function(){}),s(void 0),s(!1),s(new i(b)),A.setBounds(v.firstLineError,h.lastLineError),i}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function a(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n=this._promise=new e(r);t instanceof e&&n._propagateFrom(t,3),n._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var c=t("./util");c.isArray;return c.inherits(s,o),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function u(t,r){var o=n(this._values,this._promise);if(o instanceof e){o=o._target();var s=o._bitField;if(this._values=o,0===(50397184&s))return this._promise._setAsyncGuaranteed(),o._then(u,this._reject,void 0,this,r);if(0===(33554432&s))return 0!==(16777216&s)?this._reject(o._reason()):this._cancel();o=o._value()}if(o=c.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+c.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(-5===r?this._resolveEmptyArray():this._resolve(a(r))):void this._iterate(o)},s.prototype._iterate=function(t){var r=this.getActualLength(t.length);this._length=r,this._values=this.shouldCopyValues()?new Array(r):this._values;for(var i=this._promise,o=!1,a=null,s=0;r>s;++s){var c=n(t[s],i);c instanceof e?(c=c._target(),a=c._bitField):a=null,o?null!==a&&c.suppressUnhandledRejections():null!==a?0===(50397184&a)?(c._proxy(this,s),this._values[s]=c):o=0!==(33554432&a)?this._promiseFulfilled(c._value(),s):0!==(16777216&a)?this._promiseRejected(c._reason(),s):this._promiseCancelled(s):o=this._promiseFulfilled(c,s)}o||i._setAsyncGuaranteed()},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype._cancel=function(){!this._isResolved()&&this._promise.isCancellable()&&(this._values=null,this._promise._cancel())},s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1)},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;return r>=this._length?(this._resolve(this._values),!0):!1},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var r=0;rc;c+=2){var l=a[c],f=a[c+1],d=l+e;if(n===O)t[d]=O(l,p,l,f,e,i);else{var v=n(f,function(){return O(l,p,l,f,e,i)});h.notEnumerableProp(v,"__isPromisified__",!0),t[d]=v}}return h.toFastProperties(t),t}function l(t,e,r){return O(t,e,void 0,t,null,r)}var f,p={},h=t("./util"),d=t("./nodeback"),v=h.withAppended,_=h.maybeWrapAsError,y=h.canEvaluate,m=t("./errors").TypeError,g="Async",b={__isPromisified__:!0},E=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],x=new RegExp("^(?:"+E.join("|")+")$"),j=function(t){return h.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},w=function(t){return t.replace(/([$])/,"\\$")},O=y?f:c;e.promisify=function(t,e){if("function"!=typeof t)throw new m("expecting a function but got "+h.classString(t));if(i(t))return t;e=Object(e);var r=void 0===e.context?p:e.context,o=!!e.multiArgs,a=l(t,r,o);return h.copyDescriptors(t,a,n),a},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new m("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/MqrFmX\n");e=Object(e);var r=!!e.multiArgs,n=e.suffix;"string"!=typeof n&&(n=g);var i=e.filter;"function"!=typeof i&&(i=j);var o=e.promisifier;if("function"!=typeof o&&(o=O),!h.isIdentifier(n))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n");for(var a=h.inheritedDataKeys(t),s=0;so;++o){var a=n[o];e[o]=t[a],e[o+i]=a}}this.constructor$(e),this._isMap=r,this._init$(void 0,-3)}function a(t){var r,a=n(t);return u(a)?(r=a instanceof e?a._then(e.props,void 0,void 0,void 0,void 0):new o(a).promise(),a instanceof e&&r._propagateFrom(a,2),r):i("cannot await properties of a non-object\n\n See http://goo.gl/MqrFmX\n")}var s,c=t("./util"),u=c.isObject,l=t("./es5");"function"==typeof Map&&(s=Map);var f=function(){function t(t,n){this[e]=t,this[e+r]=n,e++}var e=0,r=0;return function(n){r=n.size,e=0;var i=new Array(2*n.size);return n.forEach(t,i),i}}(),p=function(t){for(var e=new s,r=t.length/2|0,n=0;r>n;++n){var i=t[r+n],o=t[n];e.set(i,o)}return e};c.inherits(o,r),o.prototype._init=function(){},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){var n;if(this._isMap)n=p(this._values);else{n={};for(var i=this.length(),o=0,a=this.length();a>o;++o)n[this._values[o+i]]=this._values[o]}return this._resolve(n),!0}return!1},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return a(this)},e.props=function(t){return a(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,r){"use strict";function n(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacityp;++p){var d=t[p];(void 0!==d||p in t)&&e.cast(d)._then(l,f,void 0,u,null)}return u}var a=t("./util"),s=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util":36}],28:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t,r,n,i){this.constructor$(t);var a=p();this._fn=null===a?r:a.bind(r),void 0!==n&&(n=e.resolve(n),n._attachCancellationCallback(this)),this._initialValue=n,this._currentCancellable=null,this._eachValues=i===o?[]:void 0,this._promise._captureStackTrace(),this._init$(void 0,-5)}function c(t,e){this.isFulfilled()?e._resolve(t):e._reject(t)}function u(t,e,r,i){if("function"!=typeof e)return n("expecting a function but got "+h.classString(e));var o=new s(t,e,r,i);return o.promise()}function l(t){this.accum=t,this.array._gotAccum(t);var r=i(this.value,this.array._promise);return r instanceof e?(this.array._currentCancellable=r,r._then(f,void 0,void 0,this,void 0)):f.call(this,r)}function f(t){var r=this.array,n=r._promise,i=d(r._fn);n._pushContext();var o;o=void 0!==r._eachValues?i.call(n._boundValue(),t,this.index,this.length):i.call(n._boundValue(),this.accum,t,this.index,this.length),o instanceof e&&(r._currentCancellable=o);var s=n._popContext();return a.checkForgottenReturns(o,s,void 0!==r._eachValues?"Promise.each":"Promise.reduce",n),o}var p=e._getDomain,h=t("./util"),d=h.tryCatch;h.inherits(s,r),s.prototype._gotAccum=function(t){void 0!==this._eachValues&&t!==o&&this._eachValues.push(t)},s.prototype._eachComplete=function(t){return this._eachValues.push(t),this._eachValues},s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){this._resolve(void 0!==this._eachValues?this._eachValues:this._initialValue)},s.prototype.shouldCopyValues=function(){return!1},s.prototype._resolve=function(t){this._promise._resolveCallback(t),this._values=null},s.prototype._resultCancelled=function(t){return t===this._initialValue?this._cancel():void(this._isResolved()||(this._resultCancelled$(),this._currentCancellable instanceof e&&this._currentCancellable.cancel(),this._initialValue instanceof e&&this._initialValue.cancel()))},s.prototype._iterate=function(t){this._values=t;var r,n,i=t.length;if(void 0!==this._initialValue?(r=this._initialValue,n=0):(r=e.resolve(t[0]),n=1),this._currentCancellable=r,!r.isRejected())for(;i>n;++n){var o={accum:null,value:t[n],index:n,length:i,array:this};r=r._then(l,void 0,void 0,o,void 0)}void 0!==this._eachValues&&(r=r._then(this._eachComplete,void 0,void 0,this,void 0)),r._then(c,c,void 0,r,this)},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./util":36}],29:[function(t,i,o){"use strict";var a,s=t("./util"),c=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")},u=s.getNativePromise();if(s.isNode&&"undefined"==typeof MutationObserver){var l=r.setImmediate,f=e.nextTick;a=s.isRecentNode?function(t){l.call(r,t)}:function(t){f.call(e,t)}}else if("function"==typeof u){var p=u.resolve();a=function(t){p.then(t)}}else a="undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?"undefined"!=typeof n?function(t){n(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:c:function(){var t=document.createElement("div"),e={attributes:!0},r=!1,n=document.createElement("div"),i=new MutationObserver(function(){t.classList.toggle("foo"),r=!1});i.observe(n,e);var o=function(){r||(r=!0,n.classList.toggle("foo"))};return function(r){var n=new MutationObserver(function(){n.disconnect(),r()});n.observe(t,e),o()}}();i.exports=a},{"./util":36}],30:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t)}var o=e.PromiseInspection,a=t("./util");a.inherits(i,r),i.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;return r>=this._length?(this._resolve(this._values),!0):!1},i.prototype._promiseFulfilled=function(t,e){var r=new o;return r._bitField=33554432,r._settledValueField=t,this._promiseResolved(e,r)},i.prototype._promiseRejected=function(t,e){var r=new o;return r._bitField=16777216,r._settledValueField=t,this._promiseResolved(e,r)},e.settle=function(t){return n.deprecated(".settle()",".reflect()"),new i(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var a=t("./util"),s=t("./errors").RangeError,c=t("./errors").AggregateError,u=a.isArray,l={};a.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=u(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()?(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0):!1},i.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},i.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(l),this._checkOutcome())},i.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new c,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new s(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors":12,"./util":36}],32:[function(t,e,r){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var r=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},n=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!==(33554432&this._bitField)},o=e.prototype.isRejected=function(){return 0!==(16777216&this._bitField)},a=e.prototype.isPending=function(){return 0===(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!==(50331648&this._bitField)};e.prototype.isCancelled=t.prototype._isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype.isCancelled=function(){return this._target()._isCancelled()},t.prototype.isPending=function(){return a.call(this._target())},t.prototype.isRejected=function(){return o.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return r.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),n.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t,n){if(l(t)){if(t instanceof e)return t;var i=o(t);if(i===u){n&&n._pushContext();var c=e.reject(i.e);return n&&n._popContext(),c}if("function"==typeof i){if(a(t)){var c=new e(r);return t._then(c._fulfill,c._reject,void 0,c,null),c}return s(t,i,n)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return u.e=e,u}}function a(t){try{return f.call(t,"_promise0")}catch(e){return!1}}function s(t,n,i){function o(t){s&&(s._resolveCallback(t),s=null)}function a(t){s&&(s._rejectCallback(t,f,!0),s=null)}var s=new e(r),l=s;i&&i._pushContext(),s._captureStackTrace(),i&&i._popContext();var f=!0,p=c.tryCatch(n).call(t,o,a);return f=!1,s&&p===u&&(s._rejectCallback(p.e,!0,!0),s=null),l}var c=t("./util"),u=c.errorObj,l=c.isObject,f={}.hasOwnProperty;return n}},{"./util":36}],34:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.handle=t}function o(t){return clearTimeout(this.handle),t}function a(t){throw clearTimeout(this.handle),t}var s=t("./util"),c=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var u=function(t){return l(+this).thenReturn(t)},l=e.delay=function(t,o){var a,s;return void 0!==o?(a=e.resolve(o)._then(u,null,null,t,void 0),n.cancellation()&&o instanceof e&&a._setOnCancel(o)):(a=new e(r),s=setTimeout(function(){a._fulfill()},+t),n.cancellation()&&a._setOnCancel(new i(s))),a._setAsyncGuaranteed(),a};e.prototype.delay=function(t){return l(t,this)};var f=function(t,e,r){var n;n="string"!=typeof e?e instanceof Error?e:new c("operation timed out"):new c(e),s.markAsOriginatingFromRejection(n),t._attachExtraTrace(n),t._reject(n),null!=r&&r.cancel()};e.prototype.timeout=function(t,e){t=+t;var r,s,c=new i(setTimeout(function(){r.isPending()&&f(r,e,s)},t));return n.cancellation()?(s=this.then(),r=s._then(o,a,void 0,c,void 0),r._setOnCancel(c)):r=this._then(o,a,void 0,c,void 0),r}}},{"./util":36}],35:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o,a){function s(t){setTimeout(function(){throw t},0)}function c(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(a>=u)return l._fulfill();var o=c(t[a++]);if(o instanceof e&&o._isDisposable()){try{o=n(o._getDisposer().tryDispose(r),t.promise)}catch(f){return s(f)}if(o instanceof e)return o._then(i,s,null,null,null)}i()}var a=0,u=t.length,l=new e(o);return i(),l}function l(t,e,r){this._data=t,this._promise=e,this._context=r}function f(t,e,r){this.constructor$(t,e,r)}function p(t){return l.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function h(t){this.length=t,this.promise=null,this[t-1]=null}var d=t("./util"),v=t("./errors").TypeError,_=t("./util").inherits,y=d.errorObj,m=d.tryCatch,g={};l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():g},l.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=e!==g?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},_(f,l),f.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},h.prototype._resultCancelled=function(){for(var t=this.length,r=0;t>r;++r){var n=this[r];n instanceof e&&n.cancel()}},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("expecting a function but got "+d.classString(i));var o,s=!0;2===t&&Array.isArray(arguments[0])?(o=arguments[0],t=o.length,s=!1):(o=arguments,t--);for(var c=new h(t),f=0;t>f;++f){var v=o[f];if(l.isDisposer(v)){var _=v;v=v.promise(),v._setDisposable(_)}else{var g=n(v);g instanceof e&&(v=g._then(p,null,null,{resources:c,index:f},void 0))}c[f]=v}for(var b=new Array(c.length),f=0;f0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new f(t,this,i());throw new v}}},{"./errors":12,"./util":36}],36:[function(t,n,i){"use strict";function o(){try{var t=R;return R=null,t.apply(this,arguments)}catch(e){return C.e=e,C}}function a(t){return R=t,o}function s(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function c(t){return"function"==typeof t||"object"==typeof t&&null!==t}function u(t){return s(t)?new Error(m(t)):t}function l(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function f(t,e,r){if(!A.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function p(t,e,r){if(s(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return A.defineProperty(t,e,n),t}function h(t){throw t}function d(t){try{if("function"==typeof t){var e=A.names(t.prototype),r=A.isES5&&e.length>1,n=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=P.test(t+"")&&A.names(t).length>0;if(r||n||i)return!0}return!1}catch(o){return!1}}function v(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return N.test(t)}function y(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function m(t){try{return t+""}catch(e){return"[no string representation]"}}function g(t){return null!==t&&"object"==typeof t&&"string"==typeof t.message&&"string"==typeof t.name}function b(t){try{p(t,"isOperational",!0)}catch(e){}}function E(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function x(t){return g(t)&&A.propertyIsWritable(t,"stack")}function j(t){return{}.toString.call(t)}function w(t,e,r){for(var n=A.names(t),i=0;i10||t[0]>0}(),M.isNode&&M.toFastProperties(e);try{throw new Error}catch(G){M.lastLineError=G}n.exports=M},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(e,r(9),function(){return this}(),r(10).setImmediate)},function(t,e){function r(){u&&a&&(u=!1,a.length?c=a.concat(c):l=-1,c.length&&n())}function n(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(a=c,c=[];++l1)for(var r=1;r=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var r=u++,n=arguments.length<2?!1:s.call(arguments,1);return c[r]=!0,o(function(){c[r]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(r))}),r},e.clearImmediate="function"==typeof n?n:function(t){delete c[t]}}).call(e,r(10).setImmediate,r(10).clearImmediate)},function(t,e,r){function n(){}function i(t){t=s.assignIn({logLevel:c.LOG_LEVEL.ERROR,logToConsole:!0,prefix:"[OPTIMIZELY]"},t),this.setLogLevel(t.logLevel),this.logLevelName=o(t.logLevel),this.logToConsole=t.logToConsole,this.prefix=t.prefix}function o(t){switch(t){case c.LOG_LEVEL.DEBUG:return"DEBUG";case c.LOG_LEVEL.INFO:return"INFO";case c.LOG_LEVEL.WARNING:return"WARNING";case c.LOG_LEVEL.ERROR:return"ERROR";default:return"NOTSET"}}function a(){return new Date}var s=r(1),c=r(5);n.prototype.log=function(){},i.prototype.log=function(t,e){this.__shouldLog(t)&&(this.prefix&&(e=this.prefix+" - "+this.logLevelName+" "+a()+" "+e),this.logToConsole&&this.__consoleLog(t,[e]))},i.prototype.setLogLevel=function(t){this.logLevel=t,this.log("Setting log level to "+t)},i.prototype.__shouldLog=function(t){return t>=this.logLevel},i.prototype.__consoleLog=function(t,e){switch(t){case c.LOG_LEVEL.DEBUG:console.debug.apply(console,e);break;case c.LOG_LEVEL.INFO:console.log.apply(console,e);break;case c.LOG_LEVEL.WARNING:console.warn.apply(console,e);break;case c.LOG_LEVEL.ERROR:console.error.apply(console,e);break;default:console.log.apply(console,e)}},t.exports={createLogger:function(t){return new i(t)},createNoOpLogger:function(){return new n}}},function(t,e,r){function n(t){if(this.logger=t.logger,this.eventDispatcher=t.eventDispatcher,this.errorHandler=t.errorHandler,t.datafile)if(t.skipJSONValidation===!0)this.configObj=f.createProjectConfig(t.datafile),this.logger.log(_.INFO,h(y.VALID_DATAFILE,m));else try{l.validate(p,t.datafile)&&(this.configObj=f.createProjectConfig(t.datafile),this.logger.log(_.INFO,h(y.VALID_DATAFILE,m)))}catch(e){this.logger.log(_.ERROR,e.message),this.errorHandler.handleError(e)}else this.logger.log(_.ERROR,h(v.NO_DATAFILE_SPECIFIED,m)),this.errorHandler.handleError(new Error(h(v.NO_DATAFILE_SPECIFIED,m)))}var i=r(1),o=r(13),a=r(14),s=r(16),c=r(5),u=r(18),l=r(160),f=r(20),p=r(170),h=r(4),d=r(171),v=c.ERROR_MESSAGES,_=c.LOG_LEVEL,y=c.LOG_MESSAGES,m="OPTIMIZELY";n.prototype.activate=function(t,e,r){try{if(!this.__validateInputs(e,r)||!this.__validatePreconditions(t,e,r)){var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),null}var i=this.__buildBucketerParams(t,e),o=s.bucket(i);if(null===o){var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),null}var a=u.createImpressionEventParams(this.configObj,t,o,e,r),c=u.getUrl(this.configObj),l=h(y.DISPATCH_IMPRESSION_EVENT,m,c,a);this.logger.log(_.DEBUG,l),this.eventDispatcher.dispatchEvent(c,a).then(function(){var r=h(y.ACTIVATE_USER,m,e,t);this.logger.log(_.INFO,r)}.bind(this));var p=f.getVariationKeyFromId(this.configObj,t,o);return p}catch(d){this.logger.log(_.ERROR,d.message);var n=h(y.NOT_ACTIVATING_USER,m,e,t);return this.logger.log(_.INFO,n),this.errorHandler.handleError(d),null}},n.prototype.track=function(t,e,r,n){try{if(!this.__validateInputs(e,r))return;var i=f.getExperimentIdsForGoal(this.configObj,t);if(!i)return void this.logger.log(_.WARNING,h(y.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,m,t));var o=this.__getValidExperimentIdsForGoal(t,e,r);if(!o.length){var a=h(y.NO_VALID_EXPERIMENTS_FOR_GOAL_TO_TRACK,m,t);return void this.logger.log(_.INFO,a)}var s=this.__getBucketedVariationIdsForUser(o,e),c=u.createConversionEventParams(this.configObj,t,e,r,n,s,o),l=u.getUrl(this.configObj),p=h(y.DISPATCH_CONVERSION_EVENT,m,l,c);this.logger.log(_.DEBUG,p),this.eventDispatcher.dispatchEvent(l,c).then(function(){var r=h(y.TRACK_EVENT,m,t,e);this.logger.log(_.INFO,r)}.bind(this))}catch(d){this.logger.log(_.ERROR,d.message),this.errorHandler.handleError(d)}},n.prototype.getVariation=function(t,e,r){try{if(!this.__validateInputs(e,r)||!this.__validatePreconditions(t,e,r))return null;var n=this.__buildBucketerParams(t,e),i=s.bucket(n);return f.getVariationKeyFromId(this.configObj,t,i)}catch(o){return this.logger.log(_.ERROR,o.message),this.errorHandler.handleError(o),null}},n.prototype.__getValidExperimentIdsForGoal=function(t,e,r){var n=[];if(this.configObj.eventKeyMap[t]){var o;i.forEach(this.configObj.eventKeyMap[t].experimentIds,function(t){if(o=this.configObj.experimentIdMap[t].key,this.__validatePreconditions(o,e,r))n.push(t);else{var i=h(y.NOT_TRACKING_USER_FOR_EXPERIMENT,m,e,o);this.logger.log(_.INFO,i)}}.bind(this))}return n},n.prototype.__getBucketedVariationIdsForUser=function(t,e){try{var r=i.filter(Object.keys(this.configObj.experimentKeyMap),function(e){var r=f.getExperimentId(this.configObj,e);return r&&-1!==t.indexOf(r)}.bind(this)),n=i.map(r,function(t){var r=this.__buildBucketerParams(t,e);return s.bucket(r)}.bind(this));return n}catch(o){return this.logger.log(_.ERROR,o.message),this.errorHandler.handleError(o),null}},n.prototype.__validateInputs=function(t,e){try{return d.validate(t),e&&o.validate(e),!0}catch(r){return this.logger.log(_.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__validatePreconditions=function(t,e,r){if(!f.isExperimentRunning(this.configObj,t)){var n=h(y.EXPERIMENT_NOT_RUNNING,m,t);return this.logger.log(_.INFO,n),!1}var i=f.getAudiencesForExperiment(this.configObj,t);if(!a.evaluate(i,r)){var o=h(y.USER_NOT_IN_EXPERIMENT,m,e,t);return this.logger.log(_.INFO,o),!1}return!0},n.prototype.__buildBucketerParams=function(t,e){var r={};return r.experimentKey=t,r.experimentId=f.getExperimentId(this.configObj,t),r.userId=e,r.forcedVariations=this.configObj.experimentKeyMap[t].forcedVariations,r.trafficAllocationConfig=f.getTrafficAllocation(this.configObj,t),r.experimentKeyMap=this.configObj.experimentKeyMap,r.groupIdMap=this.configObj.groupIdMap,r.experimentVariationKeyMap=this.configObj.experimentVariationKeyMap,r.variationIdMap=this.configObj.variationIdMap,r.logger=this.logger,r},t.exports=n},function(t,e,r){var n=r(4),i=r(5).ERROR_MESSAGES,o="ATTRIBUTES_VALIDATOR";t.exports={validate:function(t){if("object"!=typeof t||Array.isArray(t)||null===t)throw new Error(n(i.INVALID_ATTRIBUTES,o));return!0}}},function(t,e,r){var n=r(15);t.exports={evaluate:function(t,e){if(!t||0===t.length)return!0;if(!e)return!1;for(var r=!1,i=0;i=4;)r=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^r,n-=4,++o;switch(n){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i^=255&t.charCodeAt(o),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)}return i^=i>>>13,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>15,i>>>0}function r(t,e){var r,n,i,o,a,s,c,u;for(r=3&t.length,n=t.length-r,i=e,a=3432918353,s=461845907,u=0;n>u;)c=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c,i=i<<13|i>>>19,o=5*(65535&i)+((5*(i>>>16)&65535)<<16)&4294967295,i=(65535&o)+27492+(((o>>>16)+58964&65535)<<16);switch(c=0,r){case 3:c^=(255&t.charCodeAt(u+2))<<16;case 2:c^=(255&t.charCodeAt(u+1))<<8;case 1:c^=255&t.charCodeAt(u),c=(65535&c)*a+(((c>>>16)*a&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(65535&c)*s+(((c>>>16)*s&65535)<<16)&4294967295,i^=c}return i^=t.length,i^=i>>>16,i=2246822507*(65535&i)+((2246822507*(i>>>16)&65535)<<16)&4294967295,i^=i>>>13,i=3266489909*(65535&i)+((3266489909*(i>>>16)&65535)<<16)&4294967295,i^=i>>>16,i>>>0}var n=r;n.v2=e,n.v3=r;t.exports=n}()},function(t,e,r){function n(t,e){var r={};return u.forEach(e,function(e,n){if(e||e===!1||0===e){var i=t.attributeKeyMap[n].segmentId,o=f("%s%s",h.segmentPrefix,i);r[o]=e}}),r}function i(t,e,r){var i={};if(i[h.projectId]=t.projectId,i[h.accountId]=t.accountId,i[h.endUserId]=e,r){var o=n(t,r);u.assignIn(i,o)}return i[h.source]=f("node-sdk-%s",l.version),i[h.time]=Math.round((new Date).getTime()/1e3),i}function o(t,e){var r={},n=p.getExperimentId(t,e);return r[h.goalId]=n,r[h.goalName]="visitor-event",r}function a(t,e,r){var n={},i=t.eventKeyMap[e].id,o=i;return r&&(o=f("%s,%s",i,p.getRevenueGoalId(t)),n[h.eventValue]=r),n[h.goalId]=o,n[h.goalName]=e,n}function s(t,e,r){var n={},i=p.getExperimentId(t,e),o=f("%s%s",h.experimentPrefix,i);return n[o]=r,n}function c(t,e,r,n){var i={},o=u.filter(Object.keys(t.experimentKeyMap),function(e){var r=t.experimentKeyMap[e].id;return r&&-1!==n.indexOf(r)?e:void 0});return u.forEach(o,function(e){var n=p.getExperimentId(t,e),o=f("%s%s",h.experimentPrefix,n),a=p.getEventVariationIdFromExperimentKey(t,e,r);i[o]=a}),i}var u=r(1),l=r(19),f=r(4),p=r(20),h={accountId:"d",projectId:"a",experimentPrefix:"x",goalId:"g",goalName:"n",segmentPrefix:"s",endUserId:"u",eventValue:"v",source:"src",time:"time"};t.exports={getUrl:function(t){return f("https://%s.log.optimizely.com/event",t.projectId)},createImpressionEventParams:function(t,e,r,n,a){var c=i(t,n,a),l=o(t,e),f=s(t,e,r);return u.assignIn(c,l,f)},createConversionEventParams:function(t,e,r,n,o,s,l){var f=i(t,r,n),p=a(t,e,o),h=c(t,r,s,l);return u.assignIn(f,p,h)}}},function(t,e){t.exports={name:"optimizely-server-sdk",description:"Node SDK for consumption for server-side testing",version:"0.1.1",repository:{type:"git",url:"https://github.com/optimizely/node-sdk.git"},keywords:["optimizely"],homepage:"https://github.com/optimizely/node-sdk",main:"index.js",scripts:{test:"mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js","profile-test":"mocha ./tests/profiling_tests.js",lint:"eslint lib/** index.js tests.js",cover:"istanbul cover _mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js",coveralls:"npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"},dependencies:{bluebird:"^3.3.5",jsonschema:"^1.1.0",lodash:"4.13.1",murmurhash:"0.0.2","request-promise":"^2.0.1",sprintf:"^0.1.5"},devDependencies:{chai:"^3.5.0",coveralls:"^2.11.9",eslint:"^2.9.0",istanbul:"^0.4.3",mathjs:"^3.3.0",mocha:"^2.4.5","mocha-lcov-reporter":"^1.2.0",nock:"^7.7.2",sinon:"^1.17.4"},readme:"#Optimizely Node SDK\n[![Build Status](https://travis-ci.com/optimizely/node-sdk.svg?token=f1nmwFnopXzkdMKTUReK&branch=master)](https://travis-ci.com/optimizely/node-sdk)\n[![Coverage Status](https://coveralls.io/repos/github/optimizely/node-sdk/badge.svg?branch=master&t=pegN7y)](https://coveralls.io/github/optimizely/node-sdk?branch=master)\n\nThis repository houses the Node SDK for Optimizely's server-side testing product, which is currently in private beta.\n\n##Getting Started\n\n###Installing the SDK\n\nThe SDK is available through [npm](https://npmjs.com/package/optimizely-server-sdk). To install:\n\n```\nnpm install optimizely-server-sdk --save\n```\n\n###Using the SDK\nSee the Optimizely server-side testing [developer documentation](http://developers.optimizely.com/server/reference/index) to learn how to set up your first custom project and use the SDK. **Please note that you must be a member of the private server-side testing beta to create custom projects and use this SDK.**\n\n##Development\n\n###Installing dependencies\n\n```npm install```\n\n###Unit tests\n\nYou can run all unit tests with:\n```\nnpm test\n```\n\n###Benchmarking tests\n\nYou can run benchmarking tests with:\n```\nnpm run profile-test\n```\n\n###Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md).\n",readmeFilename:"README.md",gitHead:"e85bc818f3a76ac290a45aac0ae62e72dad2eb24",bugs:{url:"https://github.com/optimizely/node-sdk/issues"},_id:"optimizely-server-sdk@0.1.1",_shasum:"8438ff9a485d199dcb5c1e7ae26d08a8bfa3d73c",_from:"optimizely-server-sdk@^0.1.1"}},function(t,e,r){var n=r(1),i=r(21),o=r(130),a=r(5),s=r(4),c="Running",u="PROJECT_CONFIG",l="Total Revenue",f=a.ERROR_MESSAGES;t.exports={createProjectConfig:function(e){var r=o(e);n.forEach(r.audiences,function(t){t.conditions=JSON.parse(t.conditions)}),r.attributeKeyMap=i(r.dimensions,"key"),r.eventKeyMap=i(r.events,"key"),r.groupIdMap=i(r.groups,"id");var a;return n.forEach(r.groupIdMap,function(t,e){a=o(t.experiments),n.forEach(a,function(t){r.experiments.push(n.assignIn(t,{groupId:e}))})}),r.experimentKeyMap=i(r.experiments,"key"),r.experimentIdMap=i(r.experiments,"id"),r.experimentVariationKeyMap={},r.variationIdMap={},n.forEach(r.experiments,function(e){n.assignIn(r.experimentVariationKeyMap,t.exports._generateExperimentVariationKeyMap(e.variations,e.key,"key")),n.assignIn(r.variationIdMap,i(e.variations,"id"))}),r},_generateExperimentVariationKeyMap:function(t,e,r){for(var n,i={},o=0;o0?r.experimentIds:null;throw new Error(s(f.INVALID_EVENT_KEY,u,e))},getTrafficAllocation:function(t,e){var r=t.experimentKeyMap[e];if(n.isEmpty(r))throw new Error(s(f.INVALID_EXPERIMENT_KEY,u,e));return r.trafficAllocation}}},function(t,e,r){var n=r(22),i=n(function(t,e,r){t[r]=e});t.exports=i},function(t,e,r){function n(t,e){return function(r,n){var c=s(r)?i:o,u=e?e():{};return c(r,t,a(n),u)}}var i=r(23),o=r(24),a=r(49),s=r(44);t.exports=n},function(t,e){function r(t,e,r,n){for(var i=-1,o=t?t.length:0;++i-1&&t%1==0&&n>=t}var n=9007199254740991;t.exports=r},function(t,e){function r(t){return!!t&&"object"==typeof t}t.exports=r},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){function n(t){return"string"==typeof t||!i(t)&&o(t)&&c.call(t)==a}var i=r(44),o=r(43),a="[object String]",s=Object.prototype,c=s.toString;t.exports=n},function(t,e){function r(t,e){return e=null==e?n:e,!!e&&("number"==typeof t||i.test(t))&&t>-1&&t%1==0&&e>t}var n=9007199254740991,i=/^(?:0|[1-9]\d*)$/;t.exports=r},function(t,e){function r(t){var e=t&&t.constructor,r="function"==typeof e&&e.prototype||n;return t===r}var n=Object.prototype;t.exports=r},function(t,e,r){function n(t,e){return function(r,n){if(null==r)return r;if(!i(r))return t(r,n);for(var o=r.length,a=e?o:-1,s=Object(r);(e?a--:++ar)return!1;var n=e.length-1;return r==n?e.pop():a.call(e,r,1),!0}var i=r(56),o=Array.prototype,a=o.splice;t.exports=n},function(t,e,r){function n(t,e){for(var r=t.length;r--;)if(i(t[r][0],e))return r;return-1}var i=r(57);t.exports=n},function(t,e){function r(t,e){return t===e||t!==t&&e!==e}t.exports=r},function(t,e,r){function n(t){var e=this.__data__,r=i(e,t);return 0>r?void 0:e[r][1]}var i=r(56);t.exports=n},function(t,e,r){function n(t){return i(this.__data__,t)>-1}var i=r(56);t.exports=n},function(t,e,r){function n(t,e){var r=this.__data__,n=i(r,t);return 0>n?r.push([t,e]):r[n][1]=e,this}var i=r(56);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(53);t.exports=n},function(t,e){function r(t){return this.__data__["delete"](t)}t.exports=r},function(t,e){function r(t){return this.__data__.get(t)}t.exports=r},function(t,e){function r(t){return this.__data__.has(t)}t.exports=r},function(t,e,r){function n(t,e){var r=this.__data__;return r instanceof i&&r.__data__.length==a&&(r=this.__data__=new o(r.__data__)),r.set(t,e),this}var i=r(53),o=r(66),a=200;t.exports=n},function(t,e,r){function n(t){var e=-1,r=t?t.length:0;for(this.clear();++ef))return!1;var h=u.get(t);if(h)return h==e;var d=-1,v=!0,_=c&a?new i:void 0;for(u.set(t,e);++dr;)t=t[a(e[r++])];return r&&r==n?t:void 0}var i=r(116),o=r(122),a=r(123);t.exports=n},function(t,e,r){function n(t){return i(t)?t:o(t)}var i=r(44),o=r(117);t.exports=n},function(t,e,r){var n=r(118),i=r(119),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g,a=/\\(\\)?/g,s=n(function(t){var e=[];return i(t).replace(o,function(t,r,n,i){e.push(n?i.replace(a,"$1"):r||t)}),e});t.exports=s},function(t,e,r){function n(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(o);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a),a};return r.cache=new(n.Cache||i),r}var i=r(66),o="Expected a function";n.Cache=i,t.exports=n},function(t,e,r){function n(t){return null==t?"":i(t)}var i=r(120);t.exports=n},function(t,e,r){function n(t){if("string"==typeof t)return t;if(o(t))return c?c.call(t):"";var e=t+"";return"0"==e&&1/t==-a?"-0":e}var i=r(99),o=r(121),a=1/0,s=i?i.prototype:void 0,c=s?s.toString:void 0;t.exports=n},function(t,e,r){function n(t){return"symbol"==typeof t||i(t)&&s.call(t)==o}var i=r(43),o="[object Symbol]",a=Object.prototype,s=a.toString;t.exports=n},function(t,e,r){function n(t,e){if(i(t))return!1;var r=typeof t;return"number"==r||"symbol"==r||"boolean"==r||null==t||o(t)?!0:s.test(t)||!a.test(t)||null!=e&&t in Object(e)}var i=r(44),o=r(121),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;t.exports=n},function(t,e,r){function n(t){if("string"==typeof t||i(t))return t;var e=t+"";return"0"==e&&1/t==-o?"-0":e}var i=r(121),o=1/0;t.exports=n},function(t,e,r){function n(t,e){return null!=t&&o(t,e,i)}var i=r(125),o=r(126);t.exports=n},function(t,e){function r(t,e){return null!=t&&e in Object(t)}t.exports=r},function(t,e,r){function n(t,e,r){e=c(e,t)?[e]:i(e);for(var n,p=-1,h=e.length;++p already exists with different definition");return this.schemas[i]}this.schemas[i]=e;var s=i.replace(/^([^#]*)#$/,"$1");this.schemas[s]=e}return this.addSubSchemaArray(a,e.items instanceof Array?e.items:[e.items]),this.addSubSchemaArray(a,e["extends"]instanceof Array?e["extends"]:[e["extends"]]),this.addSubSchema(a,e.additionalItems),this.addSubSchemaObject(a,e.properties),this.addSubSchema(a,e.additionalProperties),this.addSubSchemaObject(a,e.definitions),this.addSubSchemaObject(a,e.patternProperties),this.addSubSchemaObject(a,e.dependencies),this.addSubSchemaArray(a,e.disallow),this.addSubSchemaArray(a,e.allOf),this.addSubSchemaArray(a,e.anyOf),this.addSubSchemaArray(a,e.oneOf),this.addSubSchema(a,e.not),this.schemas[i]}},u.prototype.addSubSchemaArray=function(t,e){if(e instanceof Array)for(var r=0;r",t);var u=o.objectGetPath(r.schemas[c],a.substr(1));if(void 0===u)throw new s("no such schema "+a+" located in <"+c+">",t);return{subschema:u,switchSchema:e}},u.prototype.testType=function(t,e,r,n,i){if("function"==typeof this.types[i])return this.types[i].call(this,t);if(i&&"object"==typeof i){var o=this.validateSchema(t,i,r,n);return void 0===o||!(o&&o.errors.length)}return!0};var l=u.prototype.types={};l.string=function(t){return"string"==typeof t},l.number=function(t){return"number"==typeof t&&isFinite(t)},l.integer=function(t){return"number"==typeof t&&t%1===0},l["boolean"]=function(t){return"boolean"==typeof t},l.array=function(t){return t instanceof Array},l["null"]=function(t){return null===t},l.date=function(t){return t instanceof Date},l.any=function(t){return!0},l.object=function(t){return t&&"object"==typeof t&&!(t instanceof Array)&&!(t instanceof Date)},t.exports=u},function(t,e,r){function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function i(t,e,r){if(t&&u(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return c(t)&&(t=i(t)),t instanceof n?t.format():n.prototype.format.call(t)}function a(t,e){return i(t,!1,!0).resolve(e)}function s(t,e){return t?i(t,!1,!0).resolveObject(e):e}function c(t){return"string"==typeof t}function u(t){return"object"==typeof t&&null!==t}function l(t){return null===t}function f(t){return null==t}var p=r(164);e.parse=i,e.resolve=a,e.resolveObject=s,e.format=o,e.Url=n;var h=/^([a-z0-9.+-]+:)/i,d=/:[0-9]*$/,v=["<",">",'"',"`"," ","\r","\n"," "],_=["{","}","|","\\","^","`"].concat(v),y=["'"].concat(_),m=["%","/","?",";","#"].concat(y),g=["/","?","#"],b=255,E=/^[a-z0-9A-Z_-]{0,63}$/,x=/^([a-z0-9A-Z_-]{0,63})(.*)$/,j={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},O={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},I=r(165);n.prototype.parse=function(t,e,r){if(!c(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var i=h.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===n.substr(0,2);!a||i&&w[i]||(n=n.substr(2),this.slashes=!0)}if(!w[i]&&(a||i&&!O[i])){for(var s=-1,u=0;ul)&&(s=l)}var f,d;d=-1===s?n.lastIndexOf("@"):n.lastIndexOf("@",s),-1!==d&&(f=n.slice(0,d),n=n.slice(d+1),this.auth=decodeURIComponent(f)),s=-1;for(var u=0;ul)&&(s=l)}-1===s&&(s=n.length),this.host=n.slice(0,s),n=n.slice(s),this.parseHost(),this.hostname=this.hostname||"";var v="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!v)for(var _=this.hostname.split(/\./),u=0,A=_.length;A>u;u++){var S=_[u];if(S&&!S.match(E)){for(var C="",R=0,T=S.length;T>R;R++)C+=S.charCodeAt(R)>127?"x":S[R];if(!C.match(E)){var k=_.slice(0,u),F=_.slice(u+1),P=S.match(x);P&&(k.push(P[1]),F.unshift(P[2])),F.length&&(n="/"+F.join(".")+n),this.hostname=k.join(".");break}}}if(this.hostname.length>b?this.hostname="":this.hostname=this.hostname.toLowerCase(),!v){for(var N=this.hostname.split("."),L=[],u=0;uu;u++){var M=y[u],G=encodeURIComponent(M);G===M&&(G=escape(M)),n=n.split(M).join(G)}var B=n.indexOf("#");-1!==B&&(this.hash=n.substr(B),n=n.slice(0,B));var H=n.indexOf("?");if(-1!==H?(this.search=n.substr(H),this.query=n.substr(H+1),e&&(this.query=I.parse(this.query)),n=n.slice(0,H)):e&&(this.search="",this.query={}),n&&(this.pathname=n),O[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var V=this.pathname||"",D=this.search||"";this.path=V+D}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&u(this.query)&&Object.keys(this.query).length&&(o=I.stringify(this.query));var a=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||O[e])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),a=a.replace("#","%23"),e+i+r+a+n},n.prototype.resolve=function(t){return this.resolveObject(i(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(c(t)){var e=new n;e.parse(t,!1,!0),t=e}var r=new n;if(Object.keys(this).forEach(function(t){r[t]=this[t]},this),r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol)return Object.keys(t).forEach(function(e){"protocol"!==e&&(r[e]=t[e])}),O[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(t.protocol&&t.protocol!==r.protocol){if(!O[t.protocol])return Object.keys(t).forEach(function(e){r[e]=t[e]}),r.href=r.format(),r;if(r.protocol=t.protocol,t.host||w[t.protocol])r.pathname=t.pathname;else{for(var i=(t.pathname||"").split("/");i.length&&!(t.host=i.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var o=r.pathname||"",a=r.search||"";r.path=o+a}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var s=r.pathname&&"/"===r.pathname.charAt(0),u=t.host||t.pathname&&"/"===t.pathname.charAt(0),p=u||s||r.host&&t.pathname,h=p,d=r.pathname&&r.pathname.split("/")||[],i=t.pathname&&t.pathname.split("/")||[],v=r.protocol&&!O[r.protocol];if(v&&(r.hostname="",r.port=null,r.host&&(""===d[0]?d[0]=r.host:d.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===i[0]?i[0]=t.host:i.unshift(t.host)),t.host=null),p=p&&(""===i[0]||""===d[0])),u)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,d=i;else if(i.length)d||(d=[]),d.pop(),d=d.concat(i),r.search=t.search,r.query=t.query;else if(!f(t.search)){if(v){r.hostname=r.host=d.shift();var _=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;_&&(r.auth=_.shift(),r.host=r.hostname=_.shift())}return r.search=t.search,r.query=t.query,l(r.pathname)&&l(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!d.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var y=d.slice(-1)[0],m=(r.host||t.host)&&("."===y||".."===y)||""===y,g=0,b=d.length;b>=0;b--)y=d[b],"."==y?d.splice(b,1):".."===y?(d.splice(b,1),g++):g&&(d.splice(b,1),g--);if(!p&&!h)for(;g--;g)d.unshift("..");!p||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),m&&"/"!==d.join("/").substr(-1)&&d.push("");var E=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(v){r.hostname=r.host=E?"":d.length?d.shift():"";var _=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;_&&(r.auth=_.shift(),r.host=r.hostname=_.shift())}return p=p||r.host&&d.length,p&&!E&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),l(r.pathname)&&l(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=d.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){var n;(function(t,i){!function(o){function a(t){throw RangeError(k[t])}function s(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function c(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]),t=t.replace(T,".");var i=t.split("."),o=s(i,e).join(".");return n+o}function u(t){for(var e,r,n=[],i=0,o=t.length;o>i;)e=t.charCodeAt(i++),e>=55296&&56319>=e&&o>i?(r=t.charCodeAt(i++),56320==(64512&r)?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--)):n.push(e);return n}function l(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function f(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:E}function p(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?P(t/O):t>>1,t+=P(t/e);t>F*j>>1;n+=E)t=P(t/F);return P(n+(F+1)*t/(t+w))}function d(t){var e,r,n,i,o,s,c,u,p,d,v=[],_=t.length,y=0,m=A,g=I;for(r=t.lastIndexOf(S),0>r&&(r=0),n=0;r>n;++n)t.charCodeAt(n)>=128&&a("not-basic"),v.push(t.charCodeAt(n));for(i=r>0?r+1:0;_>i;){for(o=y,s=1,c=E;i>=_&&a("invalid-input"),u=f(t.charCodeAt(i++)),(u>=E||u>P((b-y)/s))&&a("overflow"),y+=u*s,p=g>=c?x:c>=g+j?j:c-g,!(p>u);c+=E)d=E-p,s>P(b/d)&&a("overflow"),s*=d;e=v.length+1,g=h(y-o,e,0==o),P(y/e)>b-m&&a("overflow"),m+=P(y/e),y%=e,v.splice(y++,0,m)}return l(v)}function v(t){var e,r,n,i,o,s,c,l,f,d,v,_,y,m,g,w=[];for(t=u(t),_=t.length,e=A,r=0,o=I,s=0;_>s;++s)v=t[s],128>v&&w.push(N(v));for(n=i=w.length,i&&w.push(S);_>n;){for(c=b,s=0;_>s;++s)v=t[s],v>=e&&c>v&&(c=v);for(y=n+1,c-e>P((b-r)/y)&&a("overflow"),r+=(c-e)*y,e=c,s=0;_>s;++s)if(v=t[s],e>v&&++r>b&&a("overflow"),v==e){for(l=r,f=E;d=o>=f?x:f>=o+j?j:f-o,!(d>l);f+=E)g=l-d,m=E-d,w.push(N(p(d+g%m,0))),l=P(g/m);w.push(N(p(l,0))),o=h(r,y,n==i),r=0,++n}++r,++e}return w.join("")}function _(t){return c(t,function(t){return C.test(t)?d(t.slice(4).toLowerCase()):t})}function y(t){return c(t,function(t){return R.test(t)?"xn--"+v(t):t})}var m=("object"==typeof e&&e&&!e.nodeType&&e,"object"==typeof t&&t&&!t.nodeType&&t,"object"==typeof i&&i);m.global!==m&&m.window!==m&&m.self!==m||(o=m);var g,b=2147483647,E=36,x=1,j=26,w=38,O=700,I=72,A=128,S="-",C=/^xn--/,R=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,k={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=E-x,P=Math.floor,N=String.fromCharCode;g={version:"1.3.2",ucs2:{decode:u,encode:l},decode:d,encode:v,toASCII:y,toUnicode:_},n=function(){return g}.call(e,r,e,t),!(void 0!==n&&(t.exports=n))}(this)}).call(e,r(2)(t),function(){return this}())},function(t,e,r){"use strict";e.decode=e.parse=r(166),e.encode=e.stringify=r(167)},function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,i){e=e||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var a=/\+/g;t=t.split(e);var s=1e3;i&&"number"==typeof i.maxKeys&&(s=i.maxKeys);var c=t.length;s>0&&c>s&&(c=s);for(var u=0;c>u;++u){var l,f,p,h,d=t[u].replace(a,"%20"),v=d.indexOf(n);v>=0?(l=d.substr(0,v),f=d.substr(v+1)):(l=d,f=""),p=decodeURIComponent(l),h=decodeURIComponent(f),r(o,p)?Array.isArray(o[p])?o[p].push(h):o[p]=[o[p],h]:o[p]=h}return o}},function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,i){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(i){var o=encodeURIComponent(r(i))+n;return Array.isArray(t[i])?t[i].map(function(t){return o+encodeURIComponent(r(t))}).join(e):o+encodeURIComponent(r(t[i]))}).join(e):i?encodeURIComponent(r(i))+n+encodeURIComponent(r(t)):""}},function(t,e,r){"use strict";function n(t,e,r,n){return this.validateSchema(t,n,e,r).valid}function i(t,e,r,n,i,o){if(!e.properties||void 0===e.properties[i])if(e.additionalProperties===!1)o.addError({name:"additionalProperties",argument:i,message:"additionalProperty "+JSON.stringify(i)+" exists in instance when not allowed"});else{var a=e.additionalProperties||{},s=this.validateSchema(t[i],a,r,n.makeChild(a,i));s.instance!==o.instance[i]&&(o.instance[i]=s.instance),o.importErrors(s)}}function o(t,e,r){var n,i=r.length;for(n=e+1,i;i>n;n++)if(a.deepCompareStrict(t,r[n]))return!1;return!0}var a=r(169),s=a.ValidatorResult,c=a.SchemaError,u={};u.ignoreProperties={id:!0,"default":!0,description:!0,title:!0,exclusiveMinimum:!0,exclusiveMaximum:!0,additionalItems:!0,$schema:!0,$ref:!0,"extends":!0};var l=u.validators={};l.type=function(t,e,r,n){if(void 0===t)return null;var i=new s(t,e,r,n),o=e.type instanceof Array?e.type:[e.type];if(!o.some(this.testType.bind(this,t,e,r,n))){var a=o.map(function(t){return t.id&&"<"+t.id+">"||t+""});i.addError({name:"type",argument:a,message:"is not of a type(s) "+a})}return i},l.anyOf=function(t,e,r,i){if(void 0===t)return null;var o=new s(t,e,r,i);if(!(e.anyOf instanceof Array))throw new c("anyOf must be an array");if(!e.anyOf.some(n.bind(this,t,r,i))){var a=e.anyOf.map(function(t,e){return t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+e+"]"});o.addError({name:"anyOf",argument:a,message:"is not any of "+a.join(",")})}return o},l.allOf=function(t,e,r,n){if(void 0===t)return null;if(!(e.allOf instanceof Array))throw new c("allOf must be an array");var i=new s(t,e,r,n),o=this;return e.allOf.forEach(function(e,a){var s=o.validateSchema(t,e,r,n);if(!s.valid){var c=e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+a+"]";i.addError({name:"allOf",argument:{id:c,length:s.errors.length,valid:s},message:"does not match allOf schema "+c+" with "+s.errors.length+" error[s]:"}),i.importErrors(s)}}),i},l.oneOf=function(t,e,r,i){if(void 0===t)return null;if(!(e.oneOf instanceof Array))throw new c("oneOf must be an array");var o=new s(t,e,r,i),a=e.oneOf.filter(n.bind(this,t,r,i)).length,u=e.oneOf.map(function(t,e){return t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+e+"]"});return 1!==a&&o.addError({name:"oneOf",argument:u,message:"is not exactly one from "+u.join(",")}),o},l.properties=function(t,e,r,n){if(void 0!==t&&t instanceof Object){var i=new s(t,e,r,n),o=e.properties||{};for(var a in o){var c=(t||void 0)&&t[a],u=this.validateSchema(c,o[a],r,n.makeChild(o[a],a));u.instance!==i.instance[a]&&(i.instance[a]=u.instance),i.importErrors(u)}return i}},l.patternProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){var o=new s(t,e,r,n),a=e.patternProperties||{};for(var c in t){var u=!0;for(var l in a){var f=new RegExp(l);if(f.test(c)){u=!1;var p=this.validateSchema(t[c],a[l],r,n.makeChild(a[l],c));p.instance!==o.instance[c]&&(o.instance[c]=p.instance),o.importErrors(p)}}u&&i.call(this,t,e,r,n,c,o)}return o}},l.additionalProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){if(e.patternProperties)return null;var o=new s(t,e,r,n);for(var a in t)i.call(this,t,e,r,n,a,o);return o}},l.minProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var i=new s(t,e,r,n),o=Object.keys(t);return o.length>=e.minProperties||i.addError({name:"minProperties",argument:e.minProperties,message:"does not meet minimum property length of "+e.minProperties}),i},l.maxProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var i=new s(t,e,r,n),o=Object.keys(t);return o.length<=e.maxProperties||i.addError({name:"maxProperties",argument:e.maxProperties,message:"does not meet maximum property length of "+e.maxProperties}),i},l.items=function(t,e,r,n){if(!(t instanceof Array))return null;var i=this,o=new s(t,e,r,n);return void 0!==t&&e.items?(t.every(function(t,a){var s=e.items instanceof Array?e.items[a]||e.additionalItems:e.items;if(void 0===s)return!0;if(s===!1)return o.addError({name:"items",message:"additionalItems not permitted"}),!1;var c=i.validateSchema(t,s,r,n.makeChild(s,a));return c.instance!==o.instance[a]&&(o.instance[a]=c.instance),o.importErrors(c),!0}),o):o},l.minimum=function(t,e,r,n){if("number"!=typeof t)return null;var i=new s(t,e,r,n),o=!0;return o=e.exclusiveMinimum&&e.exclusiveMinimum===!0?t>e.minimum:t>=e.minimum,o||i.addError({name:"minimum",argument:e.minimum,message:"must have a minimum value of "+e.minimum}),i},l.maximum=function(t,e,r,n){if("number"!=typeof t)return null;var i,o=new s(t,e,r,n);return i=e.exclusiveMaximum&&e.exclusiveMaximum===!0?t=e.minLength||i.addError({name:"minLength",argument:e.minLength,message:"does not meet minimum length of "+e.minLength}),i},l.maxLength=function(t,e,r,n){if("string"!=typeof t)return null;var i=new s(t,e,r,n);return t.length<=e.maxLength||i.addError({name:"maxLength",argument:e.maxLength,message:"does not meet maximum length of "+e.maxLength}),i},l.minItems=function(t,e,r,n){if(!(t instanceof Array))return null;var i=new s(t,e,r,n);return t.length>=e.minItems||i.addError({name:"minItems",argument:e.minItems,message:"does not meet minimum length of "+e.minItems}),i},l.maxItems=function(t,e,r,n){if(!(t instanceof Array))return null;var i=new s(t,e,r,n);return t.length<=e.maxItems||i.addError({name:"maxItems",argument:e.maxItems,message:"does not meet maximum length of "+e.maxItems}),i},l.uniqueItems=function(t,e,r,n){function i(t,e,r){for(var n=e+1;n"||a;o.addError({name:"not",argument:s,message:"is of prohibited type "+s})}}),o):null},t.exports=u},function(t,e,r){"use strict";var n=r(163),i=e.ValidationError=function(t,e,r,n,i,o){n&&(this.property=n),t&&(this.message=t),r&&(r.id?this.schema=r.id:this.schema=r),e&&(this.instance=e),this.name=i,this.argument=o,this.stack=this.toString()};i.prototype.toString=function(){return this.property+" "+this.message};var o=e.ValidatorResult=function(t,e,r,n){this.instance=t,this.schema=e,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=r&&r.throwError,this.disableFormat=r&&r.disableFormat===!0};o.prototype.addError=function(t){var e;if("string"==typeof t)e=new i(t,this.instance,this.schema,this.propertyPath);else{if(!t)throw new Error("Missing error detail");if(!t.message)throw new Error("Missing error message");if(!t.name)throw new Error("Missing validator type");e=new i(t.message,this.instance,this.schema,this.propertyPath,t.name,t.argument)}if(this.throwError)throw e;return this.errors.push(e),e},o.prototype.importErrors=function(t){if("string"==typeof t||t&&t.validatorType)this.addError(t);else if(t&&t.errors){var e=this.errors;t.errors.forEach(function(t){e.push(t)})}},o.prototype.toString=function(t){return this.errors.map(function(t,e){return e+": "+t.toString()+"\n"}).join("")},Object.defineProperty(o.prototype,"valid",{get:function(){return!this.errors.length}});var a=e.SchemaError=function l(t,e){this.message=t,this.schema=e,Error.call(this,t),Error.captureStackTrace(this,l)};a.prototype=Object.create(Error.prototype,{constructor:{value:a,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var s=e.SchemaContext=function(t,e,r,n,i){this.schema=t,this.options=e,this.propertyPath=r,this.base=n,this.schemas=i};s.prototype.resolve=function(t){return n.resolve(this.base,t)},s.prototype.makeChild=function(t,e){var r=void 0===e?this.propertyPath:this.propertyPath+u(e),i=n.resolve(this.base,t.id||""),o=new s(t,this.options,r,i,Object.create(this.schemas));return t.id&&!o.schemas[i]&&(o.schemas[i]=t),o};var c=e.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"ip-address":/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,ipv6:/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,uri:/^[a-zA-Z][a-zA-Z0-9+-.]*:[^\s]*$/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"utc-millisec":function(t){return"string"==typeof t&&parseFloat(t)===parseInt(t,10)&&!isNaN(t)},regex:function(t){var e=!0;try{new RegExp(t)}catch(r){e=!1}return e},style:/\s*(.+?):\s*([^;]+);?/g,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/};c.regexp=c.regex,c.pattern=c.regex,c.ipv4=c["ip-address"],e.isFormat=function(t,e,r){if("string"==typeof t&&void 0!==c[e]){if(c[e]instanceof RegExp)return c[e].test(t);if("function"==typeof c[e])return c[e](t)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[e])return r.customFormats[e](t);return!0};var u=e.makeSuffix=function(t){return t=t.toString(),t.match(/[.\s\[\]]/)||t.match(/^[\d]/)?t.match(/^\d+$/)?"["+t+"]":"["+JSON.stringify(t)+"]":"."+t};e.deepCompareStrict=function f(t,e){if(typeof t!=typeof e)return!1;if(t instanceof Array)return e instanceof Array?t.length!==e.length?!1:t.every(function(r,n){return f(t[n],e[n])}):!1;if("object"==typeof t){if(!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length!==n.length?!1:r.every(function(r){return f(t[r],e[r])})}return t===e},t.exports.deepMerge=function p(t,e){var r=Array.isArray(e),n=r&&[]||{};return r?(t=t||[],n=n.concat(t),e.forEach(function(e,r){"object"==typeof e?n[r]=p(t[r],e):-1===t.indexOf(e)&&n.push(e)})):(t&&"object"==typeof t&&Object.keys(t).forEach(function(e){n[e]=t[e]}),Object.keys(e).forEach(function(r){"object"==typeof e[r]&&e[r]&&t[r]?n[r]=p(t[r],e[r]):n[r]=e[r]})),n},e.objectGetPath=function(t,e){for(var r,n=e.split("/").slice(1);"string"==typeof(r=n.shift());){var i=decodeURIComponent(r.replace(/~0/,"~").replace(/~1/g,"/"));if(!(i in t))return;t=t[i]}return t},e.encodePath=function(t){return t.map(function(t){return"/"+encodeURIComponent(t).replace(/~/g,"%7E")}).join("")}},function(t,e){t.exports={$schema:"http://json-schema.org/draft-04/schema#",type:"object",properties:{projectId:{type:"string"},accountId:{type:"string"},groups:{type:"array",items:{type:"object",properties:{id:{type:"string"},policy:{type:"string"},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},experiments:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},status:{type:"string"},variations:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"}},required:["id","key"]}},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},audienceIds:{type:"array",items:{type:"string"}},forcedVariations:{type:"object"}},required:["id","key","status","variations","trafficAllocation","audienceIds","forcedVariations"]}}},required:["id","policy","trafficAllocation","experiments"]}},experiments:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},status:{type:"string"},variations:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"}},required:["id","key"]}},trafficAllocation:{type:"array",items:{type:"object",properties:{entityId:{type:"string"},endOfRange:{type:"integer"}},required:["entityId","endOfRange"]}},audienceIds:{type:"array",items:{type:"string"}},forcedVariations:{type:"object"}},required:["id","key","status","variations","trafficAllocation","audienceIds","forcedVariations"]}},events:{type:"array",items:{type:"object",properties:{key:{type:"string"},experimentIds:{type:"array",items:{type:"string"}},id:{type:"string"}},required:["key","experimentIds","id"]}},audiences:{type:"array",items:{type:"object",properties:{id:{type:"string"},name:{type:"string"},conditions:{type:"string"}},required:["id","name","conditions"]}},dimensions:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"},segmentId:{type:"string"}},required:["id","key","segmentId"]}},version:{type:"string"},revision:{type:"string"}},required:["projectId","accountId","groups","experiments","events","audiences","dimensions","version","revision"]}},function(t,e,r){var n=r(5),i=r(4),o=n.ERROR_MESSAGES,a="USER_ID_VALIDATOR";t.exports={validate:function(t){if("string"!=typeof t||""===t)throw new Error(i(o.INVALID_USER_ID,a));return!0}}}]); \ No newline at end of file diff --git a/package.json b/package.json index fd98fd30f..5a4c371f7 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": { "bluebird": "^3.4.0", "lodash": "^4.13.1", - "optimizely-server-sdk": "^0.1.0" + "optimizely-server-sdk": "^0.1.1" }, "devDependencies": { "chai": "^3.5.0",