diff --git a/.travis.yml b/.travis.yml index 8436b7bcd..393ea9e4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ node_js: branches: only: - master + - devel install: "npm install" script: - "npm test" diff --git a/CHANGELOG b/CHANGELOG index 663ab36e7..130edd43b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +------------------------------------------------------------------------------- +1.0.0 +------------------------------------------------------------------------------- +* Introduce support for Full Stack projects in Optimizely X with no breaking changes from previous version. +* Introduce more graceful exception handling in instantiation and core methods. +* Update whitelisting to take precedence over audience condition evaluation. +* Fix bug activating/tracking with attributes not in the datafile. +------------------------------------------------------------------------------- + ------------------------------------------------------------------------------- 0.1.4 ------------------------------------------------------------------------------- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a218a851..77fee57bb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,16 +1,16 @@ #Contributing to the Optimizely JavaScript SDK -We welcome contributions and feedback! Please read the [README](README.md) to set up your development environment, then read the guidelines below for information on submitting your code. +We welcome contributions and feedback! All contributors must sign our [Contributor License Agreement (CLA)](https://docs.google.com/a/optimizely.com/forms/d/e/1FAIpQLSf9cbouWptIpMgukAKZZOIAhafvjFCV8hS00XJLWQnWDFtwtA/viewform) to be eligible to contribute. Please read the [README](README.md) to set up your development environment, then read the guidelines below for information on submitting your code. ## Development process -1. Create a branch off of `master`: `git checkout -b YOUR_NAME/branch_name`. +1. Create a branch off of `devel`: `git checkout -b YOUR_NAME/branch_name`. 2. Commit your changes. Make sure to add tests! 3. Run `npm run lint` to ensure there are no lint errors. 4. Run `webpack` to generate the built and minified file for those not installing via `npm` 5. `git push` your changes to GitHub. -6. Make sure that all unit tests are passing and that there are no merge conflicts between your branch and `master`. -7. Open a pull request from `YOUR_NAME/branch_name` to `master`. +6. Make sure that all unit tests are passing and that there are no merge conflicts between your branch and `devel`. +7. Open a pull request from `YOUR_NAME/branch_name` to `devel`. 8. A repository maintainer will review your pull request and, if all goes well, merge it! ##Pull request acceptance criteria diff --git a/README.md b/README.md index 94f5b7fa4..b92f188a0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #Optimizely JavaScript SDK -This repository houses the JavaScript SDK for Optimizely's server-side testing product, which is currently in private beta. +This repository houses the JavaScript SDK for Optimizely X Full Stack. ##Getting Started @@ -13,7 +13,7 @@ npm install optimizely-client-sdk --save ``` ###Using the SDK -See the Optimizely server-side testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) 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.** +See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK. ##Development diff --git a/dist/optimizely.min.js b/dist/optimizely.min.js index f14d2a87a..0212da89b 100644 --- a/dist/optimizely.min.js +++ b/dist/optimizely.min.js @@ -1,6 +1,4 @@ -!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),u=r(11),c=r(13);t.exports={createInstance:function(t){var e=u.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:u.createLogger({logLevel:s.LOG_LEVEL.INFO})},t),new c(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(u)?e>1?j(u,e-1,r,n,i):o(i,u):n||(i[i.length]=u)}return i}function x(t,e){return t&&Ge(t,e,nr)}function w(t,e){return E(e,function(e){return Tt(t[e])})}function O(t,e){return t>e}function A(t){return Pt(t)&&Ne.call(t)==de}function I(t,e,r,n,i){return t===e||(null==t||null==e||!Nt(t)&&!Pt(e)?t!==t&&e!==e:C(t,e,I,r,n,i))}function C(t,e,r,n,i,o){var a=Xe(t),s=Xe(e),u=pe,c=pe;a||(u=Ne.call(t),u=u==fe?ge:u),s||(c=Ne.call(e),c=c==fe?ge:c);var l=u==ge&&!f(t),p=c==ge&&!f(e),h=u==c;o||(o=[]);var d=qe(o,function(e){return e[0]==t}),v=qe(o,function(t){return t[0]==e});if(d&&v)return d[1]==e;if(o.push([t,e]),o.push([e,t]),h&&!l){var _=a?X(t,e,r,n,i,o):J(t,e,u,r,n,i,o);return o.pop(),_}if(!(i&ue)){var y=l&&Te.call(t,"__wrapped__"),m=p&&Te.call(e,"__wrapped__");if(y||m){var g=y?t.value():t,b=m?e.value():e,_=r(g,b,n,i,o);return o.pop(),_}}if(!h)return!1;var _=Z(t,e,r,n,i,o);return o.pop(),_}function S(t){return Nt(t)&&Ne.call(t)==be}function R(t){return"function"==typeof t?t:null==t?Xt:("object"==typeof t?F:s)(t)}function k(t,e){return ti?0:i+e),r=r>i?i:r,r<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&u&&!s&&!c||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&t1?r[i-1]:re;for(o=t.length>3&&"function"==typeof o?(i--,o):re,e=Object(e);++n-1?i[o?e[a]:a]:re}}function K(t,e,r,n){function i(){for(var e=-1,s=arguments.length,u=-1,c=n.length,l=Array(c+s),f=this&&this!==Ie&&this instanceof i?a:t;++us))return!1;for(var c=-1,l=!0,f=i&se?[]:re;++c0&&(r=e.apply(this,arguments)),t<=1&&(e=re),r}}function Et(t){if("function"!=typeof t)throw new TypeError(ie);return function(){var e=arguments;return!t.apply(this,e)}}function jt(t){return bt(2,t)}function xt(t){return Nt(t)?Xe(t)?D(t):B(t,Ue(t)):t}function wt(t,e){return t===e||t!==t&&e!==e}function Ot(t){return It(t)&&Te.call(t,"callee")&&(!De.call(t,"callee")||Ne.call(t)==fe)}function At(t){return null!=t&&Ft(t.length)&&!Tt(t)}function It(t){return Pt(t)&&At(t)}function Ct(t){return t===!0||t===!1||Pt(t)&&Ne.call(t)==he}function St(t){return At(t)&&(Xe(t)||Ut(t)||Tt(t.splice)||Ot(t))?!t.length:!Ue(t).length}function Rt(t,e){return I(t,e)}function kt(t){return"number"==typeof t&&Ve(t)}function Tt(t){var e=Nt(t)?Ne.call(t):"";return e==_e||e==ye}function Ft(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=le}function Nt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Pt(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||Pt(t)&&Ne.call(t)==me}function Ut(t){return"string"==typeof t||!Xe(t)&&Pt(t)&&Ne.call(t)==Ee}function Mt(t){return t===re}function Bt(t){return At(t)?t.length?D(t):[]:$t(t)}function Gt(t){return"string"==typeof t?t:null==t?"":t+""}function Ht(t,e){var r=y(t);return e?Ye(r,e):r}function qt(t,e){return null!=t&&Te.call(t,e)}function zt(t,e,r){var n=null==t?re:t[e];return n===re&&(n=r),Tt(n)?n.call(t):n}function $t(t){return t?l(t,nr(t)):[]}function Kt(t){return t=Gt(t),t&&xe.test(t)?t.replace(je,Se):t}function Xt(t){return t}function Jt(t){return F(Ye({},t))}function Zt(t,e,r){var n=nr(e),i=w(e,n);null!=r||Nt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=w(e,nr(e)));var a=!(Nt(r)&&"chain"in r&&!r.chain),s=Tt(t);return Be(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__=D(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 Qt(){return Ie._===this&&(Ie._=Pe),this}function Wt(){}function Yt(t){var e=++Fe;return Gt(t)+e}function te(t){return t&&t.length?b(t,Xt,O):re}function ee(t){return t&&t.length?b(t,Xt,k):re}var re,ne="4.15.0",ie="Expected a function",oe=1,ae=32,se=1,ue=2,ce=1/0,le=9007199254740991,fe="[object Arguments]",pe="[object Array]",he="[object Boolean]",de="[object Date]",ve="[object Error]",_e="[object Function]",ye="[object GeneratorFunction]",me="[object Number]",ge="[object Object]",be="[object RegExp]",Ee="[object String]",je=/[&<>"'`]/g,xe=RegExp(je.source),we={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Oe="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,Ie=Oe||Ae||Function("return this")(),Ce="object"==typeof e&&e&&!e.nodeType&&e,Se=(Ce&&"object"==typeof i&&i&&!i.nodeType&&i,u(we)),Re=Array.prototype,ke=Object.prototype,Te=ke.hasOwnProperty,Fe=0,Ne=ke.toString,Pe=Ie._,Le=Object.create,De=ke.propertyIsEnumerable,Ve=Ie.isFinite,Ue=p(Object.keys,Object),Me=Math.max;d.prototype=y(h.prototype),d.prototype.constructor=d;var Be=H(x),Ge=q(),He=String,qe=$(et),ze=P(function(t,e,r){return K(t,oe|ae,e,r)}),$e=P(function(t,e){return m(t,1,e)}),Ke=P(function(t,e,r){return m(t,We(e)||0,r)}),Xe=Array.isArray,Je=A,Ze=S,Qe=Number,We=Number,Ye=G(function(t,e){B(e,Ue(e),t)}),tr=G(function(t,e){B(e,W(e),t)}),er=G(function(t,e,r,n){B(e,ir(e),t,n)}),rr=P(function(t){return t.push(re,v),er.apply(re,t)}),nr=Ue,ir=W,or=P(function(t,e){return null==t?{}:N(t,T(j(e,1),He))}),ar=R;h.assignIn=tr,h.before=bt,h.bind=ze,h.chain=ut,h.compact=Y,h.concat=tt,h.create=Ht,h.defaults=rr,h.defer=$e,h.delay=Ke,h.filter=ht,h.flatten=rt,h.flattenDeep=nt,h.iteratee=ar,h.keys=nr,h.map=vt,h.matches=Jt,h.mixin=Zt,h.negate=Et,h.once=jt,h.pick=or,h.slice=st,h.sortBy=gt,h.tap=ct,h.thru=lt,h.toArray=Bt,h.values=$t,h.extend=tr,Zt(h,h),h.clone=xt,h.escape=Kt,h.every=pt,h.find=qe,h.forEach=dt,h.has=qt,h.head=it,h.identity=Xt,h.indexOf=ot,h.isArguments=Ot,h.isArray=Xe,h.isBoolean=Ct,h.isDate=Je,h.isEmpty=St,h.isEqual=Rt,h.isFinite=kt,h.isFunction=Tt,h.isNaN=Lt,h.isNull=Dt,h.isNumber=Vt,h.isObject=Nt,h.isRegExp=Ze,h.isString=Ut,h.isUndefined=Mt,h.last=at,h.max=te,h.min=ee,h.noConflict=Qt,h.noop=Wt,h.reduce=_t,h.result=zt,h.size=yt,h.some=mt,h.uniqueId=Yt,h.each=dt,h.first=it,Zt(h,function(){var t={};return x(h,function(e,r){Te.call(h.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),h.VERSION=ne,Be(["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);h.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Xe(i)?i:[],t)}return this[r](function(r){return e.apply(Xe(r)?r:[],t)})}}),h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=ft,Ie._=h,n=function(){return h}.call(e,r,e,i),!(n!==re&&(i.exports=n))}).call(this)}).call(e,function(){return this}(),r(2)(t))},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 u in t)t.hasOwnProperty(u)&&(i&&i.indexOf(t[u])>=0?a.push(u+": [Circular]"):a.push(u+": "+n.object_stringify(t[u],e+1,r,i)));o+=a.join(", ")+"}"}return o;case"string":return'"'+t+'"'}return""+t},n.format=function(i,o){var a,s,u,c,l,f,p,h=1,d=i.length,v="",_=[];for(s=0;s=0?"+"+a:a,f=c[4]?"0"==c[4]?"0":c[4].charAt(1):" ",p=c[6]-String(a).length,l=c[6]?e(f,p):"",_.push(c[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),o="POST",a="GET";t.exports={dispatchEvent:function(t){var e=t.url,r=t.params;return new i(t.httpVerb===o?function(t,n){var i=new XMLHttpRequest;i.open(o,e,!0),i.setRequestHeader("Content-Type","application/json"),i.addEventListener("load",function(e){var r=e.target.responseText;t(r)}),i.send(JSON.stringify(r))}:function(t,n){e+="?wxhr=true",r&&(e+="&"+s(r));var i=new XMLHttpRequest;i.open(a,e,!0),i.addEventListener("load",function(e){var r=JSON.parse(e.target.responseText);t(r)}),i.send()})}};var s=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 u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}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=u},{"./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)},u=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 c=r(o),l=new t(e);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof t){var p={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(e,a,void 0,l,p),c._then(s,u,void 0,l,p),l._setOnCancel(c)}else l._resolveCallback(f);return l},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=this._bitField&-2097153},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 e<0&&(e=Math.max(0,e+t.length)),t[e]}var a,s=t("./util"),u=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(u){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,u=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(),t._setWillBeCancelled(),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))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.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.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(o.isArray(t))for(var r=0;r=0)return o[t]}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,u=t.prototype._promiseCreated;e.deactivateLongStackTraces=function(){t.prototype._pushContext=r,t.prototype._popContext=o,t._peekContext=a,t.prototype._peekContext=s,t.prototype._promiseCreated=u,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 u(){return this._onCancelField}function c(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&&Z){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&n._bitField))return;r&&(r+=" ");var o="",a="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=j(s),c=u.length-1;c>=0;--c){var l=u[c];if(!G.test(l)){var f=l.match(H);f&&(o="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0)for(var p=u[0],c=0;c0&&(a="\n"+s[c-1]);break}}var h="a promise was created in a "+r+"handler "+o+"but was not returned from it, see http://goo.gl/rRqMUw"+a;n._warn(h,!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(at.warnings){var i,o=new V(t);if(e)n._attachExtraTrace(o);else if(at.longStackTraces&&(i=r._peekContext()))i.attachExtraTrace(o);else{var a=w(o);o.stack=a.message+"\n"+a.stack.join("\n")}et("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 u=n[s];if(e[i]!==u)break;e.pop(),i--}e=n}}function j(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?x(t):[" (No stack trace)"],{message:r,stack:j(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 P?P(n,r):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(n)}}function A(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?et(t,r,n)||i||O(r,"Unhandled rejection "):et(t,n)}function I(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"(<"+C(e)+">, no stack trace)"}function C(t){var e=41;return t.length=s||(nt=function(t){if(B.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);ot(this,T),e>32&&this.uncycle()}var F,N,P,L=r._getDomain,D=r._async,V=t("./errors").Warning,U=t("./util"),M=U.canAttachTrace,B=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,G=/\((?:timers\.js):\d+:\d+\)/,H=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,q=null,z=null,$=!1,K=!(0==U.env("BLUEBIRD_DEBUG")),X=!(0==U.env("BLUEBIRD_WARNINGS")||!K&&!U.env("BLUEBIRD_WARNINGS")),J=!(0==U.env("BLUEBIRD_LONG_STACK_TRACES")||!K&&!U.env("BLUEBIRD_LONG_STACK_TRACES")),Z=0!=U.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(X||!!U.env("BLUEBIRD_W_FORGOTTEN_RETURN"));r.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=t._bitField&-1048577|524288},r.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),D.invokeLater(this._notifyUnhandledRejection,this,void 0))},r.prototype._notifyUnhandledRejectionIsHandled=function(){A("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(),A("unhandledRejection",N,t,this)}},r.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},r.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-262145},r.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},r.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},r.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-1048577,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();N="function"==typeof t?null===e?t:U.domainBind(e,t):void 0},r.onUnhandledRejectionHandled=function(t){var e=L();F="function"==typeof t?null===e?t:U.domainBind(e,t):void 0};var Q=function(){};r.longStackTraces=function(){if(D.haveItemsQueued()&&!at.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!at.longStackTraces&&S()){var t=r.prototype._captureStackTrace,e=r.prototype._attachExtraTrace;at.longStackTraces=!0,Q=function(){if(D.haveItemsQueued()&&!at.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(),at.longStackTraces=!1},r.prototype._captureStackTrace=d,r.prototype._attachExtraTrace=v,n.activateLongStackTraces(),D.disableTrampolineIfNecessary()}},r.hasLongStackTraces=function(){return at.longStackTraces&&S()};var W=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return U.global.dispatchEvent(t),function(t,e){var r=new CustomEvent(t.toLowerCase(),{detail:e,cancelable:!0});return!U.global.dispatchEvent(r)}}if("function"==typeof Event){var t=new Event("CustomEvent");return U.global.dispatchEvent(t),function(t,e){var r=new Event(t.toLowerCase(),{cancelable:!0});return r.detail=e,!U.global.dispatchEvent(r)}}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}}(),Y=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)}:function(){return!1}}(),tt={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},et=function(t){var e=!1;try{e=Y.apply(null,arguments)}catch(r){D.throwLater(r),e=!0}var n=!1;try{n=W(t,tt[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()&&Q()),"warnings"in t){var e=t.warnings;at.warnings=!!e,Z=at.warnings,U.isObject(e)&&"wForgottenReturn"in e&&(Z=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!at.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=u,r.prototype._setOnCancel=c,r.prototype._attachCancellationCallback=s,r.prototype._execute=a,rt=f,at.cancellation=!0}"monitoring"in t&&(t.monitoring&&!at.monitoring?(at.monitoring=!0,r.prototype._fireEvent=et):!t.monitoring&&at.monitoring&&(at.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 rt=p,nt=function(){return!1},it=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;U.inherits(T,Error),n.CapturedTrace=T,T.prototype.uncycle=function(){var t=this._length;if(!(t<2)){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;n0&&(e[s-1]._parent=void 0,e[s-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;s=0;--l)e[l]._length=c,c++;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(j(i.stack.split("\n"))),i=i._parent;E(n),b(n),U.notEnumerableProp(t,"stack",g(r,n)),U.notEnumerableProp(t,"__stackCleaned__",!0)}};var ot=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():I(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,q=t,z=e;var r=Error.captureStackTrace;return nt=function(t){return B.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 q=/@/,z=e,$=!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?I(e):e.toString()},null):(q=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&&(P=function(t){console.warn(t)},U.isNode&&e.stderr.isTTY?P=function(t,e){var r=e?"":"";console.warn(r+t+"\n")}:U.isNode||"string"!=typeof(new Error).stack||(P=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var at={warnings:X,longStackTraces:!1,cancellation:!1,monitoring:!1};return J&&r.longStackTraces(),{longStackTraces:function(){return at.longStackTraces},warnings:function(){return at.warnings},cancellation:function(){return at.cancellation},monitoring:function(){return at.monitoring},propagateFromFunction:function(){return rt},boundValueFunction:function(){return h},checkForgottenReturns:_,setBounds:k,warn:m,deprecated:y,CapturedTrace:T,fireDomEvent:W,fireGlobalEvent:Y}}},{"./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 i(this,t,e,0)._then(r,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return i(this,t,e,e)},t.each=function(t,n){return i(t,n,e,0)._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"),u=s.freeze,c=t("./util"),l=c.inherits,f=c.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)}function a(){return u.call(this,this.promise._target()._settledValue())}function s(t){if(!o(this,t))return f.e=t,f}function u(t){var n=this.promise,u=this.handler;if(!this.called){this.called=!0;var c=this.isFinallyHandler()?u.call(n._boundValue()):u.call(n._boundValue(),t);if(void 0!==c){n._setReturnedNonUndefined();var p=r(c,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 c=t("./util"),l=e.CancellationError,f=c.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,u,u)},e.prototype.tap=function(t){return this._passThrough(t,1,u)},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=c();this._callback=null===i?e:l.domainBind(i,e),this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=[],h.invoke(this._asyncInit,this,void 0)}function u(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 c=e._getDomain,l=t("./util"),f=l.tryCatch,p=l.errorObj,h=e._async;l.inherits(s,r),s.prototype._asyncInit=function(){this._init$(void 0,-2)},s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,u=this._limit;if(r<0){if(r=r*-1-1,n[r]=t,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return n[r]=t,this._queue.push(r),!1;null!==s&&(s[r]=t);var c=this._promise,l=this._callback,h=c._boundValue();c._pushContext();var d=f(l).call(h,t,r,o),v=c._popContext();if(a.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",c),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 u>=1&&this._inFlight++,n[r]=_,_._proxy(this,(r+1)*-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)},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlight1){o.deprecated("calling Promise.try with more than 1 argument");var c=arguments[1],l=arguments[2];u=a.isArray(c)?s(t).apply(l,c):s(t).call(l,c)}else u=s(t)();var f=n._popContext();return o.checkForgottenReturns(u,f,"Promise.try",n),n._resolveFromSyncValue(u),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 c(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;r0&&"function"!=typeof t&&"function"!=typeof e){var r=".then() only accepts functions but was passed: "+d.classString(t);arguments.length>1&&(r+=", "+d.classString(e)),this._warn(r)}return this._then(t,e,void 0,void 0,void 0)},o.prototype.done=function(t,e){var r=this._then(t,e,void 0,void 0,void 0);r._setIsFinal()},o.prototype.spread=function(t){return"function"!=typeof t?p("expecting a function but got "+d.classString(t)):this.all()._then(t,void 0,void 0,j,void 0)},o.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},o.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new O(this).promise()},o.prototype.error=function(t){return this.caught(d.originatesFromRejection,t)},o.getNewLibraryCopy=r.exports,o.is=function(t){return t instanceof o},o.fromNode=o.fromCallback=function(t){var e=new o(E);e._captureStackTrace();var r=arguments.length>1&&!!Object(arguments[1]).multiArgs,n=F(t)(k(e,r));return n===T&&e._rejectCallback(n.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},o.all=function(t){return new O(t).promise()},o.cast=function(t){var e=w(t);return e instanceof o||(e=new o(E),e._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},o.resolve=o.fulfilled=o.cast,o.reject=o.rejected=function(t){var e=new o(E);return e._captureStackTrace(),e._rejectCallback(t,!0),e},o.setScheduler=function(t){if("function"!=typeof t)throw new g("expecting a function but got "+d.classString(t));return y.setScheduler(t)},o.prototype._then=function(t,e,r,n,i){var a=void 0!==i,s=a?i:new o(E),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,v=u._settlePromiseCtx;0!==(33554432&l)?(h=u._rejectionHandler0,p=t):0!==(16777216&l)?(h=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(v=u._settlePromiseLateCancellationObserver,h=new b("late cancellation observer"),u._attachExtraTrace(h),p=e),y.invoke(v,u,{handler:null===f?p:"function"==typeof p&&d.domainBind(f,p),promise:s,receiver:n,value:h})}else u._addCallbacks(t,e,s,n,f);return s},o.prototype._length=function(){return 65535&this._bitField},o.prototype._isFateSealed=function(){return 0!==(117506048&this._bitField)},o.prototype._isFollowing=function(){return 67108864===(67108864&this._bitField)},o.prototype._setLength=function(t){this._bitField=this._bitField&-65536|65535&t},o.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},o.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},o.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},o.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},o.prototype._isFinal=function(){return(4194304&this._bitField)>0},o.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},o.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},o.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},o.prototype._setAsyncGuaranteed=function(){y.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},o.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==h)return void 0===e&&this._isBound()?this._boundValue():e},o.prototype._promiseAt=function(t){return this[4*t-4+2]},o.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},o.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},o.prototype._boundValue=function(){},o.prototype._migrateCallback0=function(t){var e=(t._bitField,t._fulfillmentHandler0),r=t._rejectionHandler0,n=t._promise0,i=t._receiverAt(0);void 0===i&&(i=h),this._addCallbacks(e,r,n,i,null)},o.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=h),this._addCallbacks(r,n,i,o,null)},o.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:d.domainBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:d.domainBind(i,e));else{var a=4*o-4;this[a+2]=r,this[a+3]=n, -"function"==typeof t&&(this[a+0]=null===i?t:d.domainBind(i,t)),"function"==typeof e&&(this[a+1]=null===i?e:d.domainBind(i,e))}return this._setLength(o+1),o},o.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},o.prototype._resolveCallback=function(t,e){if(0===(117506048&this._bitField)){if(t===this)return this._rejectCallback(l(),!1);var r=w(t,this);if(!(r instanceof o))return this._fulfill(t);e&&this._propagateFrom(r,2);var n=r._target();if(n===this)return void this._reject(l());var i=n._bitField;if(0===(50397184&i)){var a=this._length();a>0&&n._migrateCallback0(this);for(var s=1;s>>16)){if(t===this){var r=l();return this._attachExtraTrace(r),this._reject(r)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!==(134217728&e)?this._settlePromises():y.settlePromises(this))}},o.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16))return this._setRejected(),this._fulfillmentHandler0=t,this._isFinal()?y.fatalError(t,d.isNode):void((65535&e)>0?y.settlePromises(this):this._ensurePossibleRejectionHandled())},o.prototype._fulfillPromises=function(t,e){for(var r=1;r0){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()},o.prototype._settledValue=function(){var t=this._bitField;return 0!==(33554432&t)?this._rejectionHandler0:0!==(16777216&t)?this._fulfillmentHandler0:void 0},o.defer=o.pending=function(){C.deprecated("Promise.defer","new Promise");var t=new o(E);return{promise:t,resolve:a,reject:s}},d.notEnumerableProp(o,"_makeSelfResolutionError",l),t("./method")(o,E,w,p,C),t("./bind")(o,E,w,C),t("./cancel")(o,O,p,C),t("./direct_resolve")(o),t("./synchronous_inspection")(o),t("./join")(o,O,w,E,y,c),o.Promise=o,o.version="3.4.6",t("./map.js")(o,O,p,w,E,C),t("./call_get.js")(o),t("./using.js")(o,p,w,I,E,C),t("./timers.js")(o,E,C),t("./generators.js")(o,p,E,w,n,C),t("./nodeify.js")(o),t("./promisify.js")(o,E),t("./props.js")(o,O,w,p),t("./race.js")(o,E,w,p),t("./reduce.js")(o,O,p,w,E,C),t("./settle.js")(o,O,C),t("./some.js")(o,O,p),t("./filter.js")(o,E),t("./each.js")(o,E),t("./any.js")(o),d.toFastProperties(o),d.toFastProperties(o.prototype),u({a:1}),u({b:2}),u({c:3}),u(1),u(function(){}),u(void 0),u(!1),u(new o(E)),C.setBounds(_.firstLineError,d.lastLineError),o}},{"./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 u=t("./util");u.isArray;return u.inherits(s,o),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function c(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(c,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=u.asArray(o),null===o){var l=i("expecting an array or an iterable object but got "+u.classString(o)).reason();return void this._promise._rejectCallback(l,!1)}return 0===o.length?void(r===-5?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;s=this._length&&(this._resolve(this._values),!0)},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;r=this._length){var n;if(this._isMap)n=p(this._values);else{n={};for(var i=this.length(),o=0,a=this.length();o>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;o=this._length&&(this._resolve(this._values),!0)},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||e<0)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,u=t("./errors").AggregateError,c=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=c(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)},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 u,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=function(){return 0!==(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536===(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!==(8454144&this._target()._bitField)},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===c){n&&n._pushContext();var u=e.reject(i.e);return n&&n._popContext(),u}if("function"==typeof i){if(a(t)){var u=new e(r);return t._then(u._fulfill,u._reject,void 0,u,null),u}return s(t,i,n)}}return t}function i(t){return t.then}function o(t){try{return i(t)}catch(e){return c.e=e,c}}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=u.tryCatch(n).call(t,o,a);return f=!1,s&&p===c&&(s._rejectCallback(p.e,!0,!0),s=null),l}var u=t("./util"),c=u.errorObj,l=u.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"),u=e.TimeoutError;i.prototype._resultCancelled=function(){clearTimeout(this.handle)};var c=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(c,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._captureStackTrace()),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 u("operation timed out"):new u(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,u=new i(setTimeout(function(){r.isPending()&&f(r,e,s)},t));return n.cancellation()?(s=this.then(),r=s._then(o,a,void 0,u,void 0),r._setOnCancel(u)):r=this._then(o,a,void 0,u,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 u(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function c(t,r){function i(){if(a>=c)return l._fulfill();var o=u(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,c=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;r0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=this._bitField&-131073,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=k;return k=null,t.apply(this,arguments)}catch(e){return R.e=e,R}}function a(t){return k=t,o}function s(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function u(t){return"function"==typeof t||"object"==typeof t&&null!==t}function c(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;r1,n=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=P.test(t+"")&&C.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 L.test(t)}function y(t,e,r){for(var n=new Array(t),i=0;i10||t[0]>0}(),B.isNode&&B.toFastProperties(e);try{throw new Error}catch(G){B.lastLineError=G}n.exports=B},{"./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(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function o(t){if(f===clearTimeout)return clearTimeout(t);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function a(){v&&h&&(v=!1,h.length?d=h.concat(d):_=-1,d.length&&s())}function s(){if(!v){var t=i(a);v=!0;for(var e=d.length;e;){for(h=d,d=[];++_1)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=c++,n=!(arguments.length<2)&&s.call(arguments,1);return u[r]=!0,o(function(){u[r]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(r))}),r},e.clearImmediate="function"==typeof n?n:function(t){delete u[t]}}).call(e,r(10).setImmediate,r(10).clearImmediate)},function(t,e,r){function n(){}function i(t){t=s.assignIn({logLevel:u.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 u.LOG_LEVEL.DEBUG:return"DEBUG";case u.LOG_LEVEL.INFO:return"INFO";case u.LOG_LEVEL.WARNING:return"WARNING";case u.LOG_LEVEL.ERROR:return"ERROR";default:return"NOTSET"}}function a(){return new Date}var s=r(12),u=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 u.LOG_LEVEL.DEBUG:console.debug.apply(console,e);break;case u.LOG_LEVEL.INFO:console.log.apply(console,e);break;case u.LOG_LEVEL.WARNING:console.warn.apply(console,e);break;case u.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){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(u)?e>1?E(u,e-1,r,n,i):o(i,u):n||(i[i.length]=u)}return i}function j(t,e){return t&&Ge(t,e,rr)}function x(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||(null==t||null==e||!Nt(t)&&!Pt(e)?t!==t&&e!==e:A(t,e,O,r,n,i))}function A(t,e,r,n,i,o){var a=Je(t),s=Je(e),u=he,c=he;a||(u=Ne.call(t),u=u==pe?be:u),s||(c=Ne.call(e),c=c==pe?be:c);var l=u==be&&!f(t),p=c==be&&!f(e),h=u==c;o||(o=[]);var d=ze(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?K(t,e,r,n,i,o):X(t,e,u,r,n,i,o);return o.pop(),v}if(!(i&ce)){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=J(t,e,r,n,i,o);return o.pop(),v}function I(t){return"function"==typeof t?t:null==t?Jt:("object"==typeof t?T:N)(t)}function C(t){return Ue(Object(t))}function S(t){t=null==t?t:Object(t);var e=[];for(var r in t)e.push(r);return e}function R(t,e){return ti?0:i+e),r=r>i?i:r,r<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&u&&!s&&!c||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&t1?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,u=-1,c=n.length,l=Array(c+s),f=this&&this!==Se&&this instanceof i?a:t;++us))return!1;for(var c=-1,l=!0,f=i&ue?[]:ne;++c0&&(r=e.apply(this,arguments)),t<=1&&(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:Ze(e),0),function(){for(var r=arguments,n=-1,i=Me(r.length-e,0),o=Array(i);++n-1&&t%1==0&&t<=fe}function Nt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Pt(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||Pt(t)&&Ne.call(t)==ge}function Ut(t){return Nt(t)&&Ne.call(t)==Ee}function Mt(t){return"string"==typeof t||!Je(t)&&Pt(t)&&Ne.call(t)==je}function Bt(t){return t===ne}function Gt(t){return Ot(t)?t.length?L(t):[]:Kt(t)}function Ht(t){return"string"==typeof t?t:null==t?"":t+""}function qt(t,e){var r=_(t);return e?We(r,e):r}function zt(t,e){return null!=t&&Te.call(t,e)}function $t(t,e,r){var n=null==t?ne:t[e];return n===ne&&(n=r),Tt(n)?n.call(t):n}function Kt(t){return t?u(t,rr(t)):[]}function Xt(t){return t=Ht(t),t&&we.test(t)?t.replace(xe,l):t}function Jt(t){return t}function Zt(t){return T(We({},t))}function Qt(t,e,r){var n=rr(e),i=x(e,n);null!=r||Nt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=x(e,rr(e)));var a=!(Nt(r)&&"chain"in r&&!r.chain),s=Tt(t);return Be(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 Se._===this&&(Se._=Pe),this}function Yt(){}function te(t){var e=++Fe;return Ht(t)+e}function ee(t){return t&&t.length?g(t,Jt,w):ne}function re(t){return t&&t.length?g(t,Jt,R):ne}var ne,ie="4.13.1",oe="Expected a function",ae=1,se=32,ue=1,ce=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]",je="[object String]",xe=/[&<>"'`]/g,we=RegExp(xe.source),Oe={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ae=c("object"==typeof i&&i),Ie=c("object"==typeof self&&self),Ce=c("object"==typeof this&&this),Se=Ae||Ie||Ce||Function("return this")(),Re=Array.prototype,ke=Object.prototype,Te=ke.hasOwnProperty,Fe=0,Ne=ke.toString,Pe=Se._,Le=Object.create,De=ke.propertyIsEnumerable,Ve=Se.isFinite,Ue=Object.keys,Me=Math.max;h.prototype=_(p.prototype),h.prototype.constructor=h;var Be=G(j),Ge=H(),He=N("length"),qe=String,ze=z(Y),$e=Et(function(t,e,r){return $(t,ae|se,e,r)}),Ke=Et(function(t,e){return y(t,1,e)}),Xe=Et(function(t,e,r){return y(t,Qe(e)||0,r)}),Je=Array.isArray,Ze=Number,Qe=Number,We=B(function(t,e){M(e,rr(e),t)}),Ye=B(function(t,e){M(e,nr(e),t)}),tr=B(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=C,nr=S,ir=Et(function(t,e){return null==t?{}:F(t,k(E(e,1),qe))}),or=I;p.assignIn=Ye,p.before=mt,p.bind=$e,p.chain=at,p.compact=Q,p.concat=W,p.create=qt,p.defaults=er,p.defer=Ke,p.delay=Xe,p.filter=ft,p.flatten=tt,p.flattenDeep=et,p.iteratee=or,p.keys=rr,p.map=ht,p.matches=Zt,p.mixin=Qt,p.negate=gt,p.once=bt,p.pick=ir,p.slice=ot,p.sortBy=yt,p.tap=st,p.thru=ut,p.toArray=Gt,p.values=Kt,p.extend=Ye,Qt(p,p),p.clone=jt,p.escape=Xt,p.every=lt,p.find=ze,p.forEach=pt,p.has=zt,p.head=rt,p.identity=Jt,p.indexOf=nt,p.isArguments=wt,p.isArray=Je,p.isBoolean=It,p.isDate=Ct,p.isEmpty=St,p.isEqual=Rt,p.isFinite=kt,p.isFunction=Tt,p.isNaN=Lt,p.isNull=Dt,p.isNumber=Vt,p.isObject=Nt,p.isRegExp=Ut,p.isString=Mt,p.isUndefined=Bt,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 j(p,function(e,r){Te.call(p.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),p.VERSION=ie,Be(["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(Je(i)?i:[],t)}return this[r](function(r){return e.apply(Je(r)?r:[],t)})}}),p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ct,(Ie||{})._=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,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(12),o=r(14),a=r(15),s=r(17),u=r(5),c=r(19),l=r(162),f=r(22),p=r(172),h=r(4),d=r(173),v=u.ERROR_MESSAGES,_=u.LOG_LEVEL,y=u.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=c.createImpressionEventParams(this.configObj,t,o,e,r),u=c.getUrl(this.configObj),l=h(y.DISPATCH_IMPRESSION_EVENT,m,u,a);this.logger.log(_.DEBUG,l),this.eventDispatcher.dispatchEvent(u,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),u=c.createConversionEventParams(this.configObj,t,e,r,n,s,o),l=c.getUrl(this.configObj),p=h(y.DISPATCH_CONVERSION_EVENT,m,l,u);this.logger.log(_.DEBUG,p),this.eventDispatcher.dispatchEvent(l,u).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&&t.indexOf(r)!==-1}.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(16);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,u,c;for(r=3&t.length,n=t.length-r,i=e,a=3432918353,s=461845907,c=0;c>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,i^=u,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(u=0,r){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,i^=u}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 c.forEach(e,function(e,n){if(e||e===!1||0===e){var i=t.attributeKeyMap[n].segmentId,o=p("%s%s",d.segmentPrefix,i);r[o]=e}}),r}function i(t,e,r){var i={};if(i[d.projectId]=t.projectId,i[d.accountId]=t.accountId,i[d.endUserId]=e,r){var o=n(t,r);c.assignIn(i,o)}var a=l.isNode()?"node-sdk":"javascript-sdk";return i[d.source]=p("%s-%s",a,f.version),i[d.time]=Math.round((new Date).getTime()/1e3),i}function o(t,e){var r={},n=h.getExperimentId(t,e);return r[d.goalId]=n,r[d.goalName]="visitor-event",r}function a(t,e,r){var n={},i=t.eventKeyMap[e].id,o=i;return r&&(o=p("%s,%s",i,h.getRevenueGoalId(t)),n[d.eventValue]=r),n[d.goalId]=o,n[d.goalName]=e,n}function s(t,e,r){var n={},i=h.getExperimentId(t,e),o=p("%s%s",d.experimentPrefix,i);return n[o]=r,n}function u(t,e,r,n){var i={},o=c.filter(Object.keys(t.experimentKeyMap),function(e){var r=t.experimentKeyMap[e].id;if(r&&n.indexOf(r)!==-1)return e});return c.forEach(o,function(e){var n=h.getExperimentId(t,e),o=p("%s%s",d.experimentPrefix,n),a=h.getEventVariationIdFromExperimentKey(t,e,r);i[o]=a}),i}var c=r(12),l=r(20),f=r(21),p=r(4),h=r(22),d={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 p("https://%s.log.optimizely.com/event",t.projectId)},createImpressionEventParams:function(t,e,r,n,a){var u=i(t,n,a),l=o(t,e),f=s(t,e,r);return c.assignIn(u,l,f)},createConversionEventParams:function(t,e,r,n,o,s,l){var f=i(t,r,n),p=a(t,e,o),h=u(t,r,s,l);return c.assignIn(f,p,h)}}},function(t,e,r){(function(e){t.exports={isNode:function(){return"undefined"==typeof window&&"object"==typeof e}}}).call(e,r(9))},function(t,e){t.exports={_args:[[{name:"optimizely-server-sdk",raw:"optimizely-server-sdk@^0.1.3",rawSpec:"^0.1.3",scope:null,spec:">=0.1.3 <0.2.0",type:"range"},"/Users/hbash/javascript-sdk"]],_from:"optimizely-server-sdk@>=0.1.3 <0.2.0",_id:"optimizely-server-sdk@0.1.3",_inCache:!0,_installable:!0,_location:"/optimizely-server-sdk",_npmOperationalInternal:{host:"packages-12-west.internal.npmjs.com",tmp:"tmp/optimizely-server-sdk-0.1.3.tgz_1472058039652_0.5944091617129743"},_npmUser:{email:"mikebuybuy@gmail.com",name:"mikeng13"},_npmVersion:"1.4.28",_phantomChildren:{},_requested:{name:"optimizely-server-sdk",raw:"optimizely-server-sdk@^0.1.3",rawSpec:"^0.1.3",scope:null,spec:">=0.1.3 <0.2.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/optimizely-server-sdk/-/optimizely-server-sdk-0.1.3.tgz",_shasum:"dac7364231affbb62bebb351fa365be94b910a41",_shrinkwrap:null,_spec:"optimizely-server-sdk@^0.1.3",_where:"/Users/hbash/javascript-sdk",bugs:{url:"https://github.com/optimizely/node-sdk/issues"},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"},description:"Node SDK for consumption for server-side testing",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"},directories:{},dist:{shasum:"dac7364231affbb62bebb351fa365be94b910a41",tarball:"https://registry.npmjs.org/optimizely-server-sdk/-/optimizely-server-sdk-0.1.3.tgz"},gitHead:"ea123218984da886a6dc4e46832dd5f31de3307c",homepage:"https://github.com/optimizely/node-sdk",keywords:["optimizely"],main:"index.js",maintainers:[{email:"ali@optimizely.com",name:"aliabbasrizvi"},{email:"haley.bash@optimizely.com",name:"haleybash_optimizely"},{email:"mikeng13@gmail.com",name:"mikeng13"}],name:"optimizely-server-sdk",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/optimizely/node-sdk.git"},scripts:{cover:"istanbul cover _mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js",coveralls:"npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",lint:"eslint lib/** index.js tests.js","profile-test":"mocha ./tests/profiling_tests.js",test:"mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js"},version:"0.1.3"}},function(t,e,r){var n=r(12),i=r(23),o=r(132),a=r(5),s=r(4),u="Running",c="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,c,e))},getTrafficAllocation:function(t,e){var r=t.experimentKeyMap[e];if(n.isEmpty(r))throw new Error(s(f.INVALID_EXPERIMENT_KEY,c,e));return r.trafficAllocation}}},function(t,e,r){var n=r(24),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 u=s(r)?i:o,c=e?e():{};return u(r,t,a(n),c)}}var i=r(25),o=r(26),a=r(51),s=r(46);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&&t<=n}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)&&u.call(t)==a}var i=r(46),o=r(45),a="[object String]",s=Object.prototype,u=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&&t-1}var i=r(58);t.exports=n},function(t,e,r){function n(t,e){var r=this.__data__,n=i(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}var i=r(58);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(55);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(55),o=r(68),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=c.get(t);if(h)return h==e;var d=-1,v=!0,_=u&a?new i:void 0;for(c.set(t,e);++d 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]}},c.prototype.addSubSchemaArray=function(t,e){if(e instanceof Array)for(var r=0;r",t);var c=o.objectGetPath(r.schemas[u],a.substr(1));if(void 0===c)throw new s("no such schema "+a+" located in <"+u+">",t);return{subschema:c,switchSchema:e}},c.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=c.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=c},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&&c(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return u(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 u(t){return"string"==typeof t}function c(t){return"object"==typeof t&&null!==t}function l(t){return null===t}function f(t){return null==t}var p=r(166);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","\t"],_=["{","}","|","\\","^","`"].concat(v),y=["'"].concat(_),m=["%","/","?",";","#"].concat(y),g=["/","?","#"],b=255,E=/^[a-z0-9A-Z_-]{0,63}$/,j=/^([a-z0-9A-Z_-]{0,63})(.*)$/,x={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},A=r(167);n.prototype.parse=function(t,e,r){if(!u(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,c=0;c127?"x":C[R];if(!S.match(E)){var T=_.slice(0,c),F=_.slice(c+1),N=C.match(j);N&&(T.push(N[1]),F.unshift(N[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 P=this.hostname.split("."),L=[],c=0;c0)&&r.host.split("@");_&&(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("@");_&&(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 u(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 c(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=P(t>>>10&1023|55296),t=56320|1023&t),e+=P(t)}).join("")}function f(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:E}function p(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?N(t/O):t>>1,t+=N(t/e);t>F*x>>1;n+=E)t=N(t/F);return N(n+(F+1)*t/(t+w))}function d(t){var e,r,n,i,o,s,u,c,p,d,v=[],_=t.length,y=0,m=I,g=A;for(r=t.lastIndexOf(C),r<0&&(r=0),n=0;n=128&&a("not-basic"),v.push(t.charCodeAt(n));for(i=r>0?r+1:0;i<_;){for(o=y,s=1,u=E;i>=_&&a("invalid-input"),c=f(t.charCodeAt(i++)),(c>=E||c>N((b-y)/s))&&a("overflow"),y+=c*s,p=u<=g?j:u>=g+x?x:u-g,!(cN(b/d)&&a("overflow"),s*=d;e=v.length+1,g=h(y-o,e,0==o),N(y/e)>b-m&&a("overflow"),m+=N(y/e),y%=e,v.splice(y++,0,m)}return l(v)}function v(t){var e,r,n,i,o,s,u,l,f,d,v,_,y,m,g,w=[];for(t=c(t),_=t.length,e=I,r=0,o=A,s=0;s<_;++s)v=t[s],v<128&&w.push(P(v));for(n=i=w.length,i&&w.push(C);n<_;){for(u=b,s=0;s<_;++s)v=t[s],v>=e&&vN((b-r)/y)&&a("overflow"),r+=(u-e)*y,e=u,s=0;s<_;++s)if(v=t[s],vb&&a("overflow"),v==e){for(l=r,f=E;d=f<=o?j:f>=o+x?x:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=E-j,N=Math.floor,P=String.fromCharCode;g={version:"1.3.2",ucs2:{decode:c,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(168),e.encode=e.stringify=r(169)},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 u=t.length;s>0&&u>s&&(u=s);for(var c=0;c=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;n"||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 u("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 u("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 u=e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+a+"]";i.addError({name:"allOf",argument:{id:u,length:s.errors.length,valid:s},message:"does not match allOf schema "+u+" 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 u("oneOf must be an array");var o=new s(t,e,r,i),a=e.oneOf.filter(n.bind(this,t,r,i)).length,c=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:c,message:"is not exactly one from "+c.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 u=(t||void 0)&&t[a],c=this.validateSchema(u,o[a],r,n.makeChild(o[a],a));c.instance!==i.instance[a]&&(i.instance[a]=c.instance),i.importErrors(c)}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 u in t){var c=!0;for(var l in a){var f=new RegExp(l);if(f.test(u)){c=!1;var p=this.validateSchema(t[u],a[l],r,n.makeChild(a[l],u));p.instance!==o.instance[u]&&(o.instance[u]=p.instance),o.importErrors(p)}}c&&i.call(this,t,e,r,n,u,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 u=i.validateSchema(t,s,r,n.makeChild(s,a));return u.instance!==o.instance[a]&&(o.instance[a]=u.instance),o.importErrors(u),!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=c},function(t,e,r){"use strict";var n=r(165),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+c(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 u=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]$/};u.regexp=u.regex,u.pattern=u.regex,u.ipv4=u["ip-address"],e.isFormat=function(t,e,r){if("string"==typeof t&&void 0!==u[e]){if(u[e]instanceof RegExp)return u[e].test(t);if("function"==typeof u[e])return u[e](t)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[e])return r.customFormats[e](t);return!0};var c=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&&t.every(function(r,n){return f(t[n],e[n])}));if("object"==typeof t){if(!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&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):t.indexOf(e)===-1&&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 +!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),u=r(11),c=r(13),f="1.0.0",p="INDEX";t.exports={createInstance:function(t){var e=u.createLogger({logLevel:s.LOG_LEVEL.INFO});if(t)try{i.validate(t),t.isValidInstance=!0}catch(r){var l=p+":"+r.message;t.logger?t.logger.log(s.LOG_LEVEL.ERROR,l):e.log(s.LOG_LEVEL.ERROR,l),t.isValidInstance=!1}return t=n.assignIn({clientEngine:s.JAVASCRIPT_CLIENT_ENGINE,clientVersion:f,errorHandler:o,eventDispatcher:a,logger:u.createLogger({logLevel:s.LOG_LEVEL.INFO})},t),new c(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(u)?e>1?I(u,e-1,r,n,i):o(i,u):n||(i[i.length]=u)}return i}function O(t,e){return t&&Ke(t,e,nr)}function x(t,e){return b(e,function(e){return Pt(t[e])})}function A(t,e){return t>e}function j(t){return Ct(t)&&Le.call(t)==de}function N(t,e,r,n,i){return t===e||(null==t||null==e||!Lt(t)&&!Ct(e)?t!==t&&e!==e:w(t,e,N,r,n,i))}function w(t,e,r,n,i,o){var a=Ze(t),s=Ze(e),u=le,c=le;a||(u=Le.call(t),u=u==pe?_e:u),s||(c=Le.call(e),c=c==pe?_e:c);var f=u==_e&&!p(t),l=c==_e&&!p(e),h=u==c;o||(o=[]);var d=qe(o,function(e){return e[0]==t}),v=qe(o,function(t){return t[0]==e});if(d&&v)return d[1]==e;if(o.push([t,e]),o.push([e,t]),h&&!f){var y=a?Z(t,e,r,n,i,o):J(t,e,u,r,n,i,o);return o.pop(),y}if(!(i&ue)){var m=f&&Pe.call(t,"__wrapped__"),g=l&&Pe.call(e,"__wrapped__");if(m||g){var _=m?t.value():t,E=g?e.value():e,y=r(_,E,n,i,o);return o.pop(),y}}if(!h)return!1;var y=X(t,e,r,n,i,o);return o.pop(),y}function S(t){return Lt(t)&&Le.call(t)==Ee}function R(t){return"function"==typeof t?t:null==t?Zt:("object"==typeof t?V:s)(t)}function T(t,e){return ti?0:i+e),r=r>i?i:r,r<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&u&&!s&&!c||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&t1?r[i-1]:re;for(o=t.length>3&&"function"==typeof o?(i--,o):re,e=Object(e);++n-1?i[o?e[a]:a]:re}}function H(t,e,r,n){function i(){for(var e=-1,s=arguments.length,u=-1,c=n.length,f=Array(c+s),p=this&&this!==Ne&&this instanceof i?a:t;++us))return!1;for(var c=-1,f=!0,p=i&se?[]:re;++c0&&(r=e.apply(this,arguments)),t<=1&&(e=re),r}}function bt(t){if("function"!=typeof t)throw new TypeError(ie);return function(){var e=arguments;return!t.apply(this,e)}}function It(t){return Et(2,t)}function Ot(t){return Lt(t)?Ze(t)?D(t):G(t,Fe(t)):t}function xt(t,e){return t===e||t!==t&&e!==e}function At(t){return Nt(t)&&Pe.call(t,"callee")&&(!De.call(t,"callee")||Le.call(t)==pe)}function jt(t){return null!=t&&Vt(t.length)&&!Pt(t)}function Nt(t){return Ct(t)&&jt(t)}function wt(t){return t===!0||t===!1||Ct(t)&&Le.call(t)==he}function St(t){return jt(t)&&(Ze(t)||Ft(t)||Pt(t.splice)||At(t))?!t.length:!Fe(t).length}function Rt(t,e){return N(t,e)}function Tt(t){return"number"==typeof t&&Me(t)}function Pt(t){var e=Lt(t)?Le.call(t):"";return e==ye||e==me}function Vt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=fe}function Lt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ct(t){return!!t&&"object"==typeof t}function kt(t){return Mt(t)&&t!=+t}function Dt(t){return null===t}function Mt(t){return"number"==typeof t||Ct(t)&&Le.call(t)==ge}function Ft(t){return"string"==typeof t||!Ze(t)&&Ct(t)&&Le.call(t)==be}function Ut(t){return t===re}function Gt(t){return jt(t)?t.length?D(t):[]:zt(t)}function Kt(t){return"string"==typeof t?t:null==t?"":t+""}function Bt(t,e){var r=m(t);return e?Qe(r,e):r}function qt(t,e){return null!=t&&Pe.call(t,e)}function $t(t,e,r){var n=null==t?re:t[e];return n===re&&(n=r),Pt(n)?n.call(t):n}function zt(t){return t?f(t,nr(t)):[]}function Ht(t){return t=Kt(t),t&&Oe.test(t)?t.replace(Ie,Se):t}function Zt(t){return t}function Jt(t){return V(Qe({},t))}function Xt(t,e,r){var n=nr(e),i=x(e,n);null!=r||Lt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=x(e,nr(e)));var a=!(Lt(r)&&"chain"in r&&!r.chain),s=Pt(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__=D(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 Yt(){return Ne._===this&&(Ne._=Ce),this}function Wt(){}function Qt(t){var e=++Ve;return Kt(t)+e}function te(t){return t&&t.length?E(t,Zt,A):re}function ee(t){return t&&t.length?E(t,Zt,T):re}var re,ne="4.15.0",ie="Expected a function",oe=1,ae=32,se=1,ue=2,ce=1/0,fe=9007199254740991,pe="[object Arguments]",le="[object Array]",he="[object Boolean]",de="[object Date]",ve="[object Error]",ye="[object Function]",me="[object GeneratorFunction]",ge="[object Number]",_e="[object Object]",Ee="[object RegExp]",be="[object String]",Ie=/[&<>"'`]/g,Oe=RegExp(Ie.source),xe={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ae="object"==typeof t&&t&&t.Object===Object&&t,je="object"==typeof self&&self&&self.Object===Object&&self,Ne=Ae||je||Function("return this")(),we="object"==typeof e&&e&&!e.nodeType&&e,Se=(we&&"object"==typeof i&&i&&!i.nodeType&&i,u(xe)),Re=Array.prototype,Te=Object.prototype,Pe=Te.hasOwnProperty,Ve=0,Le=Te.toString,Ce=Ne._,ke=Object.create,De=Te.propertyIsEnumerable,Me=Ne.isFinite,Fe=l(Object.keys,Object),Ue=Math.max;d.prototype=m(h.prototype),d.prototype.constructor=d;var Ge=B(O),Ke=q(),Be=String,qe=z(et),$e=C(function(t,e,r){return H(t,oe|ae,e,r)}),ze=C(function(t,e){return g(t,1,e)}),He=C(function(t,e,r){return g(t,We(e)||0,r)}),Ze=Array.isArray,Je=j,Xe=S,Ye=Number,We=Number,Qe=K(function(t,e){G(e,Fe(e),t)}),tr=K(function(t,e){G(e,W(e),t)}),er=K(function(t,e,r,n){G(e,ir(e),t,n)}),rr=C(function(t){return t.push(re,v),er.apply(re,t)}),nr=Fe,ir=W,or=C(function(t,e){return null==t?{}:L(t,P(I(e,1),Be))}),ar=R;h.assignIn=tr,h.before=Et,h.bind=$e,h.chain=ut,h.compact=Q,h.concat=tt,h.create=Bt,h.defaults=rr,h.defer=ze,h.delay=He,h.filter=ht,h.flatten=rt,h.flattenDeep=nt,h.iteratee=ar,h.keys=nr,h.map=vt,h.matches=Jt,h.mixin=Xt,h.negate=bt,h.once=It,h.pick=or,h.slice=st,h.sortBy=_t,h.tap=ct,h.thru=ft,h.toArray=Gt,h.values=zt,h.extend=tr,Xt(h,h),h.clone=Ot,h.escape=Ht,h.every=lt,h.find=qe,h.forEach=dt,h.has=qt,h.head=it,h.identity=Zt,h.indexOf=ot,h.isArguments=At,h.isArray=Ze,h.isBoolean=wt,h.isDate=Je,h.isEmpty=St,h.isEqual=Rt,h.isFinite=Tt,h.isFunction=Pt,h.isNaN=kt,h.isNull=Dt,h.isNumber=Mt,h.isObject=Lt,h.isRegExp=Xe,h.isString=Ft,h.isUndefined=Ut,h.last=at,h.max=te,h.min=ee,h.noConflict=Yt,h.noop=Wt,h.reduce=yt,h.result=$t,h.size=mt,h.some=gt,h.uniqueId=Qt,h.each=dt,h.first=it,Xt(h,function(){var t={};return O(h,function(e,r){Pe.call(h.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),h.VERSION=ne,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);h.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)})}}),h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=pt,Ne._=h,n=function(){return h}.call(e,r,e,i),!(n!==re&&(i.exports=n))}).call(this)}).call(e,function(){return this}(),r(2)(t))},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 u in t)t.hasOwnProperty(u)&&(i&&i.indexOf(t[u])>=0?a.push(u+": [Circular]"):a.push(u+": "+n.object_stringify(t[u],e+1,r,i)));o+=a.join(", ")+"}"}return o;case"string":return'"'+t+'"'}return""+t},n.format=function(i,o){var a,s,u,c,f,p,l,h=1,d=i.length,v="",y=[];for(s=0;s=0?"+"+a:a,p=c[4]?"0"==c[4]?"0":c[4].charAt(1):" ",l=c[6]-String(a).length,f=c[6]?e(p,l):"",y.push(c[5]?a+f:f+a)}return y.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.",INVALID_OBJECT:"%s: Optimizely object is not valid. Failing %s.",INVALID_CLIENT_ENGINE:"%s: Invalid client engine passed: %s. Defaulting to node-sdk.",NO_VALID_EXPERIMENTS_FOR_EVENT_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:"%s: Not tracking user %s.",NOT_TRACKING_USER_FOR_EXPERIMENT:"%s: Not tracking user %s for experiment %s.",SKIPPING_JSON_VALIDATION:"%s: Skipping JSON schema validation.",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."},e.JAVASCRIPT_CLIENT_ENGINE="javascript-sdk",e.NEW_OPTIMIZELY_VERSION="2",e.NODE_CLIENT_ENGINE="node-sdk",e.NODE_CLIENT_VERSION="1.0.0"},function(t,e){t.exports={handleError:function(t){}}},function(t,e,r){var n=r(1),i=r(8).Promise,o="POST",a="GET";t.exports={dispatchEvent:function(t){var e=t.url,r=t.params;return new i(t.httpVerb===o?function(t,n){var i=new XMLHttpRequest;i.open(o,e,!0),i.setRequestHeader("Content-Type","application/json"),i.addEventListener("load",function(e){var r=e.target.responseText;t(r)}),i.send(JSON.stringify(r))}:function(t,n){e+="?wxhr=true",r&&(e+="&"+s(r));var i=new XMLHttpRequest;i.open(a,e,!0),i.addEventListener("load",function(e){var r=JSON.parse(e.target.responseText);t(r)}),i.send()})}};var s=function(t){return n.map(t,function(t,e){return encodeURIComponent(e)+"="+encodeURIComponent(t)}).join("&")}},function(t,e,r){(function(e,n){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function o(t){J=t}function a(t){X=t}function s(){return function(){return e.nextTick(l)}}function u(){return function(){Z(l)}}function c(){var t=0,e=new Q(l),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function f(){var t=new MessageChannel;return t.port1.onmessage=l,function(){return t.port2.postMessage(0)}}function p(){var t=setTimeout;return function(){return t(l,1)}}function l(){for(var t=0;t1)for(var n=1;n=this.logLevel},i.prototype.__consoleLog=function(t,e){switch(t){case u.LOG_LEVEL.DEBUG:console.log.apply(console,e);break;case u.LOG_LEVEL.INFO:console.log.apply(console,e);break;case u.LOG_LEVEL.WARNING:console.warn.apply(console,e);break;case u.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){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(u)?e>1?b(u,e-1,r,n,i):o(i,u):n||(i[i.length]=u)}return i}function I(t,e){return t&&Ke(t,e,rr)}function O(t,e){return E(e,function(e){return Pt(t[e])})}function x(t,e){return t>e}function A(t,e,r,n,i){return t===e||(null==t||null==e||!Lt(t)&&!Ct(e)?t!==t&&e!==e:j(t,e,A,r,n,i))}function j(t,e,r,n,i,o){var a=Je(t),s=Je(e),u=he,c=he;a||(u=Le.call(t),u=u==le?Ee:u),s||(c=Le.call(e),c=c==le?Ee:c);var f=u==Ee&&!p(t),l=c==Ee&&!p(e),h=u==c;o||(o=[]);var d=$e(o,function(e){return e[0]===t});if(d&&d[1])return d[1]==e;if(o.push([t,e]),h&&!f){var v=a?H(t,e,r,n,i,o):Z(t,e,u,r,n,i,o);return o.pop(),v}if(!(i&ce)){var y=f&&Pe.call(t,"__wrapped__"),m=l&&Pe.call(e,"__wrapped__");if(y||m){var g=y?t.value():t,_=m?e.value():e,v=r(g,_,n,i,o);return o.pop(),v}}if(!h)return!1;var v=J(t,e,r,n,i,o);return o.pop(),v}function N(t){return"function"==typeof t?t:null==t?Jt:("object"==typeof t?P:L)(t)}function w(t){return Fe(Object(t))}function S(t){t=null==t?t:Object(t);var e=[];for(var r in t)e.push(r);return e}function R(t,e){return ti?0:i+e),r=r>i?i:r,r<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++ne||o&&a&&u&&!s&&!c||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&t1?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 z(t,e,r,n){function i(){for(var e=-1,s=arguments.length,u=-1,c=n.length,f=Array(c+s),p=this&&this!==Se&&this instanceof i?a:t;++us))return!1;for(var c=-1,f=!0,p=i&ue?[]:ne;++c0&&(r=e.apply(this,arguments)),t<=1&&(e=ne),r}}function _t(t){if("function"!=typeof t)throw new TypeError(oe);return function(){return!t.apply(this,arguments)}}function Et(t){return gt(2,t)}function bt(t,e){if("function"!=typeof t)throw new TypeError(oe);return e=Ue(e===ne?t.length-1:Xe(e),0),function(){for(var r=arguments,n=-1,i=Ue(r.length-e,0),o=Array(i);++n-1&&t%1==0&&t<=pe}function Lt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ct(t){return!!t&&"object"==typeof t}function kt(t){return Mt(t)&&t!=+t}function Dt(t){return null===t}function Mt(t){return"number"==typeof t||Ct(t)&&Le.call(t)==_e}function Ft(t){return Lt(t)&&Le.call(t)==be}function Ut(t){return"string"==typeof t||!Je(t)&&Ct(t)&&Le.call(t)==Ie}function Gt(t){return t===ne}function Kt(t){return At(t)?t.length?k(t):[]:Ht(t)}function Bt(t){return"string"==typeof t?t:null==t?"":t+""}function qt(t,e){var r=y(t);return e?We(r,e):r}function $t(t,e){return null!=t&&Pe.call(t,e)}function zt(t,e,r){var n=null==t?ne:t[e];return n===ne&&(n=r),Pt(n)?n.call(t):n}function Ht(t){return t?u(t,rr(t)):[]}function Zt(t){return t=Bt(t),t&&xe.test(t)?t.replace(Oe,f):t}function Jt(t){return t}function Xt(t){return P(We({},t))}function Yt(t,e,r){var n=rr(e),i=O(e,n);null!=r||Lt(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=O(e,rr(e)));var a=!(Lt(r)&&"chain"in r&&!r.chain),s=Pt(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__=k(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 Se._===this&&(Se._=Ce),this}function Qt(){}function te(t){var e=++Ve;return Bt(t)+e}function ee(t){return t&&t.length?_(t,Jt,x):ne}function re(t){return t&&t.length?_(t,Jt,R):ne}var ne,ie="4.13.1",oe="Expected a function",ae=1,se=32,ue=1,ce=2,fe=1/0,pe=9007199254740991,le="[object Arguments]",he="[object Array]",de="[object Boolean]",ve="[object Date]",ye="[object Error]",me="[object Function]",ge="[object GeneratorFunction]",_e="[object Number]",Ee="[object Object]",be="[object RegExp]",Ie="[object String]",Oe=/[&<>"'`]/g,xe=RegExp(Oe.source),Ae={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},je=c("object"==typeof i&&i),Ne=c("object"==typeof self&&self),we=c("object"==typeof this&&this),Se=je||Ne||we||Function("return this")(),Re=Array.prototype,Te=Object.prototype,Pe=Te.hasOwnProperty,Ve=0,Le=Te.toString,Ce=Se._,ke=Object.create,De=Te.propertyIsEnumerable,Me=Se.isFinite,Fe=Object.keys,Ue=Math.max;h.prototype=y(l.prototype),h.prototype.constructor=h;var Ge=K(I),Ke=B(),Be=L("length"),qe=String,$e=$(Q),ze=bt(function(t,e,r){return z(t,ae|se,e,r)}),He=bt(function(t,e){return m(t,1,e)}),Ze=bt(function(t,e,r){return m(t,Ye(e)||0,r)}),Je=Array.isArray,Xe=Number,Ye=Number,We=G(function(t,e){U(e,rr(e),t)}),Qe=G(function(t,e){U(e,nr(e),t)}),tr=G(function(t,e,r,n){U(e,nr(e),t,n)}),er=bt(function(t){return t.push(ne,d),tr.apply(ne,t)}),rr=w,nr=S,ir=bt(function(t,e){return null==t?{}:V(t,T(b(e,1),qe))}),or=N;l.assignIn=Qe,l.before=gt,l.bind=ze,l.chain=at,l.compact=Y,l.concat=W,l.create=qt,l.defaults=er,l.defer=He,l.delay=Ze,l.filter=pt,l.flatten=tt,l.flattenDeep=et,l.iteratee=or,l.keys=rr,l.map=ht,l.matches=Xt,l.mixin=Yt,l.negate=_t,l.once=Et,l.pick=ir,l.slice=ot,l.sortBy=mt,l.tap=st,l.thru=ut,l.toArray=Kt,l.values=Ht,l.extend=Qe,Yt(l,l),l.clone=It,l.escape=Zt,l.every=ft,l.find=$e,l.forEach=lt,l.has=$t,l.head=rt,l.identity=Jt,l.indexOf=nt,l.isArguments=xt,l.isArray=Je,l.isBoolean=Nt,l.isDate=wt,l.isEmpty=St,l.isEqual=Rt,l.isFinite=Tt,l.isFunction=Pt,l.isNaN=kt,l.isNull=Dt,l.isNumber=Mt,l.isObject=Lt,l.isRegExp=Ft,l.isString=Ut,l.isUndefined=Gt,l.last=it,l.max=ee,l.min=re,l.noConflict=Wt,l.noop=Qt,l.reduce=dt,l.result=zt,l.size=vt,l.some=yt,l.uniqueId=te,l.each=lt,l.first=rt,Yt(l,function(){var t={};return I(l,function(e,r){Pe.call(l.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),l.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);l.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Je(i)?i:[],t)}return this[r](function(r){return e.apply(Je(r)?r:[],t)})}}),l.prototype.toJSON=l.prototype.valueOf=l.prototype.value=ct,(Ne||{})._=l,n=function(){return l}.call(e,r,e,t),!(n!==ne&&(t.exports=n))}).call(this)}).call(e,r(2)(t),function(){return this}())},function(t,e,r){function n(t){var e=t.clientEngine;if(e!==u.NODE_CLIENT_ENGINE&&e!==u.JAVASCRIPT_CLIENT_ENGINE&&(t.logger.log(y.INFO,h(m.INVALID_CLIENT_ENGINE,g,e)),e=u.NODE_CLIENT_ENGINE),this.clientEngine=e,this.clientVersion=t.clientVersion||u.NODE_CLIENT_VERSION,this.errorHandler=t.errorHandler,this.eventDispatcher=t.eventDispatcher,this.isValidInstance=t.isValidInstance,this.logger=t.logger,t.datafile)if(t.skipJSONValidation===!0)this.configObj=p.createProjectConfig(t.datafile),this.logger.log(y.INFO,h(m.SKIPPING_JSON_VALIDATION,g));else try{var r=t.datafile.version===u.NEW_OPTIMIZELY_VERSION?l.V2:l.V1;f.validate(r,t.datafile)&&(this.configObj=p.createProjectConfig(t.datafile),this.logger.log(y.INFO,h(m.VALID_DATAFILE,g)))}catch(n){this.isValidInstance=!1,this.logger.log(y.ERROR,n.message),this.errorHandler.handleError(n)}else this.logger.log(y.ERROR,h(v.NO_DATAFILE_SPECIFIED,g)),this.errorHandler.handleError(new Error(h(v.NO_DATAFILE_SPECIFIED,g))),this.isValidInstance=!1}var i=r(12),o=r(14),a=r(15),s=r(17),u=r(5),c=r(19),f=r(162),p=r(21),l=r(172),h=r(4),d=r(173),v=u.ERROR_MESSAGES,y=u.LOG_LEVEL,m=u.LOG_MESSAGES,g="OPTIMIZELY";n.prototype.activate=function(t,e,r){if(!this.isValidInstance)return this.logger.log(y.ERROR,h(m.INVALID_OBJECT,g,"activate")),null;try{if(!this.__validateInputs(e,r)||!this.__checkIfExperimentIsRunning(t,e))return this.__notActivatingExperiment(t,e);var n=this.__returnForcedVariationIdIfProvided(t,e);if(!n){if(!this.__checkIfUserIsInAudience(t,e,r))return this.__notActivatingExperiment(t,e);var i=this.__buildBucketerParams(t,e);n=s.bucket(i)}if(null===n){var o=h(m.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(y.INFO,o),null}var a={attributes:r,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:this.configObj,experimentKey:t,userId:e,variationId:n},u=c.getImpressionEvent(a),f=h(m.DISPATCH_IMPRESSION_EVENT,g,u.url,JSON.stringify(u.params));this.logger.log(y.DEBUG,f),this.eventDispatcher.dispatchEvent(u).then(function(){var r=h(m.ACTIVATE_USER,g,e,t);this.logger.log(y.INFO,r)}.bind(this));var l=p.getVariationKeyFromId(this.configObj,t,n);return l}catch(d){this.logger.log(y.ERROR,d.message);var o=h(m.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(y.INFO,o),this.errorHandler.handleError(d),null}},n.prototype.track=function(t,e,r,n){if(!this.isValidInstance)return void this.logger.log(y.ERROR,h(m.INVALID_OBJECT,g,"track"));try{if(!this.__validateInputs(e,r))return;var i=p.getExperimentIdsForEvent(this.configObj,t);if(!i)return void this.logger.log(y.WARNING,h(m.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,g,t));var o=this.__getValidExperimentInformationForEvent(t,e,r),a=o.validExperimentKeysForEvent;if(!a.length){var s=h(m.NO_VALID_EXPERIMENTS_FOR_EVENT_TO_TRACK,g,t);return void this.logger.log(y.INFO,s)}var u=this.__getBucketedVariationIdsForUser(o,e),f={attributes:r,clientEngine:this.clientEngine,clientVersion:this.clientVersion,configObj:this.configObj,eventKey:t,eventValue:n,userId:e,validExperimentKeysForEvent:a,variationIds:u},l=c.getConversionEvent(f),d=h(m.DISPATCH_CONVERSION_EVENT,g,l.url,JSON.stringify(l.params));this.logger.log(y.DEBUG,d),this.eventDispatcher.dispatchEvent(l).then(function(){var r=h(m.TRACK_EVENT,g,t,e);this.logger.log(y.INFO,r)}.bind(this))}catch(v){this.logger.log(y.ERROR,v.message);var _=h(m.NOT_TRACKING_USER,g,e);this.logger.log(y.INFO,_),this.errorHandler.handleError(v)}},n.prototype.getVariation=function(t,e,r){if(!this.isValidInstance)return this.logger.log(y.ERROR,h(m.INVALID_OBJECT,g,"getVariation")),null;try{if(!this.__validateInputs(e,r)||!this.__checkIfExperimentIsRunning(t,e))return null;var n=this.__returnForcedVariationIdIfProvided(t,e);if(!n){if(!this.__checkIfUserIsInAudience(t,e,r))return null;var i=this.__buildBucketerParams(t,e);n=s.bucket(i)}return p.getVariationKeyFromId(this.configObj,t,n)}catch(o){return this.logger.log(y.ERROR,o.message),this.errorHandler.handleError(o),null}},n.prototype.__getValidExperimentInformationForEvent=function(t,e,r){var n=[],o={};if(this.configObj.eventKeyMap[t]){var a;i.forEach(this.configObj.eventKeyMap[t].experimentIds,function(t){if(a=this.configObj.experimentIdMap[t].key,!this.__checkIfExperimentIsRunning(a,e)){var i=h(m.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);return void this.logger.log(y.INFO,i)}var s=this.__returnForcedVariationIdIfProvided(a,e);if(s)n.push(a),o[a]=s;else if(this.__checkIfUserIsInAudience(a,e,r))n.push(a);else{var i=h(m.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);this.logger.log(y.INFO,i)}}.bind(this))}return{validExperimentKeysForEvent:n,experimentKeyToForcedVariationIdMap:o}},n.prototype.__getBucketedVariationIdsForUser=function(t,e){try{var r=t.validExperimentKeysForEvent,n=t.experimentKeyToForcedVariationIdMap,o=i.map(r,function(t){var r=n[t];if(r)return r;var i=this.__buildBucketerParams(t,e);return s.bucket(i)}.bind(this));return o}catch(a){return this.logger.log(y.ERROR,a.message),this.errorHandler.handleError(a),null}},n.prototype.__validateInputs=function(t,e){try{return d.validate(t),e&&o.validate(e),!0}catch(r){return this.logger.log(y.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__checkIfExperimentIsRunning=function(t,e){if(!p.isExperimentRunning(this.configObj,t)){var r=h(m.EXPERIMENT_NOT_RUNNING,g,t);return this.logger.log(y.INFO,r),!1}return!0},n.prototype.__returnForcedVariationIdIfProvided=function(t,e){var r=this.configObj.experimentKeyMap[t];if(i.isEmpty(r))throw new Error(h(v.INVALID_EXPERIMENT_KEY,g,t));return!i.isEmpty(r.forcedVariations)&&r.forcedVariations.hasOwnProperty(e)?s.forcedBucket(e,r.forcedVariations,t,this.configObj.experimentVariationKeyMap,this.logger):null},n.prototype.__checkIfUserIsInAudience=function(t,e,r){var n=p.getAudiencesForExperiment(this.configObj,t);if(!a.evaluate(n,r)){var i=h(m.USER_NOT_IN_EXPERIMENT,g,e,t);return this.logger.log(y.INFO,i),!1}return!0},n.prototype.__notActivatingExperiment=function(t,e){var r=h(m.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(y.INFO,r),null},n.prototype.__buildBucketerParams=function(t,e){var r={};return r.experimentKey=t,r.experimentId=p.getExperimentId(this.configObj,t),r.userId=e,r.trafficAllocationConfig=p.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(16);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,u,c;for(r=3&t.length,n=t.length-r,i=e,a=3432918353,s=461845907,c=0;c>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,i^=u,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(u=0,r){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,i^=u}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){return t.version===a.NEW_OPTIMIZELY_VERSION?c.POST_METHOD:u.GET_METHOD}function i(t){var e=t.attributes,r=t.configObj,n=t.userId;if(r.version===a.NEW_OPTIMIZELY_VERSION){var i={accountId:r.accountId,projectId:r.projectId,visitorId:n,timestamp:Math.round((new Date).getTime()),isGlobalHoldback:!1,userFeatures:[],clientEngine:t.clientEngine,clientVersion:t.clientVersion};for(var p in e){var l=f.getAttributeId(t.configObj,p);if(l){var h={id:l,name:p,type:c.CUSTOM_ATTRIBUTE_FEATURE_TYPE,value:e[p],shouldIndex:!0};i.userFeatures.push(h)}}return i}var d={};if(d[u.urlParams.projectId]=r.projectId,d[u.urlParams.accountId]=r.accountId,d[u.urlParams.endUserId]=n,e){var v=u.getAttributeParams(r,e);o.assignIn(d,v)}return d[u.urlParams.source]=s("%s-%s",t.clientEngine,t.clientVersion),d[u.urlParams.time]=Math.round((new Date).getTime()/1e3),d}var o=r(12),a=r(5),s=r(4),u=r(20),c=r(161),f=r(21);t.exports={getImpressionEvent:function(t){var e={httpVerb:n(t.configObj)},r=i(t);if(t.configObj.version===a.NEW_OPTIMIZELY_VERSION){e.url=c.NEW_OPTIMIZELY_IMPRESSION_ENDPOINT;var f=c.getImpressionEventParams(t.configObj,t.experimentKey,t.variationId);e.params=o.assignIn(r,f)}else{e.url=s(u.CLASSIC_OPTIMIZELY_ENDPOINT,t.configObj.projectId);var f=u.getImpressionGoalParams(t.configObj,t.experimentKey),p=u.getExperimentParams(t.configObj,t.experimentKey,t.variationId);e.params=o.assignIn(r,f,p)}return e},getConversionEvent:function(t){var e={httpVerb:n(t.configObj)},r=i(t);if(t.configObj.version===a.NEW_OPTIMIZELY_VERSION){e.url=c.NEW_OPTIMIZELY_CONVERSION_ENDPOINT;var f=c.getConversionEventParams(t.configObj,t.eventKey,t.eventValue,t.variationIds,t.validExperimentKeysForEvent);e.params=o.assignIn(r,f)}else{e.url=s(u.CLASSIC_OPTIMIZELY_ENDPOINT,t.configObj.projectId);var f=u.getConversionGoalParams(t.configObj,t.eventKey,t.eventValue),p=u.getExperimentVariationParams(t.configObj,t.variationIds,t.validExperimentKeysForEvent);e.params=o.assignIn(r,f,p)}return e}}},function(t,e,r){var n=r(12),i=r(21),o=r(4);t.exports={CLASSIC_OPTIMIZELY_ENDPOINT:"https://%s.log.optimizely.com/event",GET_METHOD:"GET",urlParams:{accountId:"d",projectId:"a",experimentPrefix:"x",goalId:"g",goalName:"n",segmentPrefix:"s",endUserId:"u",eventValue:"v",source:"src",time:"time"},getAttributeParams:function(e,r){var i={};return n.forEach(r,function(r,n){if(n in e.attributeKeyMap&&(r||r===!1||0===r)){var a=e.attributeKeyMap[n].segmentId,s=o("%s%s",t.exports.urlParams.segmentPrefix,a);i[s]=r}}),i},getImpressionGoalParams:function(e,r){var n={},o=i.getExperimentId(e,r);return n[t.exports.urlParams.goalId]=o,n[t.exports.urlParams.goalName]="visitor-event",n},getConversionGoalParams:function(e,r,n){var a={},s=e.eventKeyMap[r].id,u=s;return n&&(u=o("%s,%s",s,i.getRevenueGoalId(e)),a[t.exports.urlParams.eventValue]=n),a[t.exports.urlParams.goalId]=u,a[t.exports.urlParams.goalName]=r,a},getExperimentParams:function(e,r,n){var a={},s=i.getExperimentId(e,r),u=o("%s%s",t.exports.urlParams.experimentPrefix,s);return a[u]=n,a},getExperimentVariationParams:function(e,r,a){var s={};return n.forEach(a,function(n){var a=i.getExperimentId(e,n),u=o("%s%s",t.exports.urlParams.experimentPrefix,a),c=i.getEventVariationIdFromExperimentKey(e,n,r);s[u]=c}),s}}},function(t,e,r){var n=r(12),i=r(22),o=r(131),a=r(5),s=r(4),u="Running",c="PROJECT_CONFIG",f="Total Revenue",p=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.version===a.NEW_OPTIMIZELY_VERSION?r.attributeKeyMap=i(r.attributes,"key"):r.attributeKeyMap=i(r.dimensions,"key"),r.eventKeyMap=i(r.events,"key"),r.groupIdMap=i(r.groups,"id");var s;return n.forEach(r.groupIdMap,function(t,e){s=o(t.experiments),n.forEach(s,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(p.INVALID_EVENT_KEY,c,e))},getTrafficAllocation:function(t,e){var r=t.experimentKeyMap[e];if(n.isEmpty(r))throw new Error(s(p.INVALID_EXPERIMENT_KEY,c,e));return r.trafficAllocation}}},function(t,e,r){var n=r(23),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 u=s(r)?i:o,c=e?e():{};return u(r,t,a(n),c)}}var i=r(24),o=r(25),a=r(50),s=r(45);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&&t<=n}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)&&u.call(t)==a}var i=r(45),o=r(44),a="[object String]",s=Object.prototype,u=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&&t-1}var i=r(57);t.exports=n},function(t,e,r){function n(t,e){var r=this.__data__,n=i(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}var i=r(57);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(54);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(54),o=r(67),a=200;t.exports=n},function(t,e,r){function n(t){var e=-1,r=t?t.length:0;for(this.clear();++ep))return!1;var h=c.get(t);if(h)return h==e;var d=-1,v=!0,y=u&a?new i:void 0;for(c.set(t,e);++d 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]}},c.prototype.addSubSchemaArray=function(t,e){if(e instanceof Array)for(var r=0;r",t);var c=o.objectGetPath(r.schemas[u],a.substr(1));if(void 0===c)throw new s("no such schema "+a+" located in <"+u+">",t);return{subschema:c,switchSchema:e}},c.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 f=c.prototype.types={};f.string=function(t){return"string"==typeof t},f.number=function(t){return"number"==typeof t&&isFinite(t)},f.integer=function(t){return"number"==typeof t&&t%1===0},f["boolean"]=function(t){return"boolean"==typeof t},f.array=function(t){return t instanceof Array},f["null"]=function(t){return null===t},f.date=function(t){return t instanceof Date},f.any=function(t){return!0},f.object=function(t){return t&&"object"==typeof t&&!(t instanceof Array)&&!(t instanceof Date)},t.exports=c},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&&c(t)&&t instanceof n)return t;var i=new n;return i.parse(t,e,r),i}function o(t){return u(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 u(t){return"string"==typeof t}function c(t){return"object"==typeof t&&null!==t}function f(t){return null===t}function p(t){return null==t}var l=r(166);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","\t"],y=["{","}","|","\\","^","`"].concat(v),m=["'"].concat(y),g=["%","/","?",";","#"].concat(m),_=["/","?","#"],E=255,b=/^[a-z0-9A-Z_-]{0,63}$/,I=/^([a-z0-9A-Z_-]{0,63})(.*)$/,O={javascript:!0,"javascript:":!0},x={javascript:!0,"javascript:":!0},A={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},j=r(167);n.prototype.parse=function(t,e,r){if(!u(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&&x[i]||(n=n.substr(2),this.slashes=!0)}if(!x[i]&&(a||i&&!A[i])){for(var s=-1,c=0;c<_.length;c++){var f=n.indexOf(_[c]);f!==-1&&(s===-1||f127?"x":w[R];if(!S.match(b)){var P=y.slice(0,c),V=y.slice(c+1),L=w.match(I);L&&(P.push(L[1]),V.unshift(L[2])),V.length&&(n="/"+V.join(".")+n),this.hostname=P.join(".");break}}}if(this.hostname.length>E?this.hostname="":this.hostname=this.hostname.toLowerCase(),!v){for(var C=this.hostname.split("."),k=[],c=0;c0)&&r.host.split("@");y&&(r.auth=y.shift(),r.host=r.hostname=y.shift())}return r.search=t.search,r.query=t.query,f(r.pathname)&&f(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 m=d.slice(-1)[0],g=(r.host||t.host)&&("."===m||".."===m)||""===m,_=0,E=d.length;E>=0;E--)m=d[E],"."==m?d.splice(E,1):".."===m?(d.splice(E,1),_++):_&&(d.splice(E,1),_--);if(!l&&!h)for(;_--;_)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),g&&"/"!==d.join("/").substr(-1)&&d.push("");var b=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(v){r.hostname=r.host=b?"":d.length?d.shift():"";var y=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");y&&(r.auth=y.shift(),r.host=r.hostname=y.shift())}return l=l||r.host&&d.length,l&&!b&&d.unshift(""),d.length?r.pathname=d.join("/"):(r.pathname=null,r.path=null),f(r.pathname)&&f(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(P[t])}function s(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function u(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 c(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=C(t>>>10&1023|55296),t=56320|1023&t),e+=C(t)}).join("")}function p(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:b}function l(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function h(t,e,r){var n=0;for(t=r?L(t/A):t>>1,t+=L(t/e);t>V*O>>1;n+=b)t=L(t/V);return L(n+(V+1)*t/(t+x))}function d(t){var e,r,n,i,o,s,u,c,l,d,v=[],y=t.length,m=0,g=N,_=j;for(r=t.lastIndexOf(w),r<0&&(r=0),n=0;n=128&&a("not-basic"),v.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=y&&a("invalid-input"),c=p(t.charCodeAt(i++)),(c>=b||c>L((E-m)/s))&&a("overflow"),m+=c*s,l=u<=_?I:u>=_+O?O:u-_,!(cL(E/d)&&a("overflow"),s*=d;e=v.length+1,_=h(m-o,e,0==o),L(m/e)>E-g&&a("overflow"),g+=L(m/e),m%=e,v.splice(m++,0,g)}return f(v)}function v(t){var e,r,n,i,o,s,u,f,p,d,v,y,m,g,_,x=[];for(t=c(t),y=t.length,e=N,r=0,o=j,s=0;s=e&&vL((E-r)/m)&&a("overflow"),r+=(u-e)*m,e=u,s=0;sE&&a("overflow"), +v==e){for(f=r,p=b;d=p<=o?I:p>=o+O?O:p-o,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=b-I,L=Math.floor,C=String.fromCharCode;_={version:"1.3.2",ucs2:{decode:c,encode:f},decode:d,encode:v,toASCII:m,toUnicode:y},n=function(){return _}.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(168),e.encode=e.stringify=r(169)},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 u=t.length;s>0&&u>s&&(u=s);for(var c=0;c=0?(f=d.substr(0,v),p=d.substr(v+1)):(f=d,p=""),l=decodeURIComponent(f),h=decodeURIComponent(p),r(o,l)?Array.isArray(o[l])?o[l].push(h):o[l]=[o[l],h]:o[l]=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;n"||t+""});i.addError({name:"type",argument:a,message:"is not of a type(s) "+a})}return i},f.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 u("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},f.allOf=function(t,e,r,n){if(void 0===t)return null;if(!(e.allOf instanceof Array))throw new u("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 u=e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+a+"]";i.addError({name:"allOf",argument:{id:u,length:s.errors.length,valid:s},message:"does not match allOf schema "+u+" with "+s.errors.length+" error[s]:"}),i.importErrors(s)}}),i},f.oneOf=function(t,e,r,i){if(void 0===t)return null;if(!(e.oneOf instanceof Array))throw new u("oneOf must be an array");var o=new s(t,e,r,i),a=e.oneOf.filter(n.bind(this,t,r,i)).length,c=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:c,message:"is not exactly one from "+c.join(",")}),o},f.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 u=(t||void 0)&&t[a],c=this.validateSchema(u,o[a],r,n.makeChild(o[a],a));c.instance!==i.instance[a]&&(i.instance[a]=c.instance),i.importErrors(c)}return i}},f.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 u in t){var c=!0;for(var f in a){var p=new RegExp(f);if(p.test(u)){c=!1;var l=this.validateSchema(t[u],a[f],r,n.makeChild(a[f],u));l.instance!==o.instance[u]&&(o.instance[u]=l.instance),o.importErrors(l)}}c&&i.call(this,t,e,r,n,u,o)}return o}},f.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}},f.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},f.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},f.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 u=i.validateSchema(t,s,r,n.makeChild(s,a));return u.instance!==o.instance[a]&&(o.instance[a]=u.instance),o.importErrors(u),!0}),o):o},f.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},f.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},f.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},f.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},f.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},f.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=c},function(t,e,r){"use strict";var n=r(165),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 f(t,e){this.message=t,this.schema=e,Error.call(this,t),Error.captureStackTrace(this,f)};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+c(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 u=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]$/};u.regexp=u.regex,u.pattern=u.regex,u.ipv4=u["ip-address"],e.isFormat=function(t,e,r){if("string"==typeof t&&void 0!==u[e]){if(u[e]instanceof RegExp)return u[e].test(t);if("function"==typeof u[e])return u[e](t)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[e])return r.customFormats[e](t);return!0};var c=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 p(t,e){if(typeof t!=typeof e)return!1;if(t instanceof Array)return e instanceof Array&&(t.length===e.length&&t.every(function(r,n){return p(t[n],e[n])}));if("object"==typeof t){if(!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(r){return p(t[r],e[r])})}return t===e},t.exports.deepMerge=function l(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]=l(t[r],e):t.indexOf(e)===-1&&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]=l(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={V2:{$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"},layerId:{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","layerId","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"},layerId:{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","layerId","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"]}},attributes:{type:"array",items:{type:"object",properties:{id:{type:"string"},key:{type:"string"}},required:["id","key"]}},version:{type:"string"},revision:{type:"string"}},required:["projectId","accountId","groups","experiments","events","audiences","attributes","version","revision"]},V1:{$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/index.js b/index.js index 5e50331fb..94c855a62 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,9 @@ var logger = require('optimizely-server-sdk/lib/plugins/logger'); var Optimizely = require('optimizely-server-sdk/lib/optimizely'); +var JAVASCRIPT_CLIENT_VERSION = '1.0.0'; +var MODULE_NAME = 'INDEX'; + /** * Entry point into the Optimizely Node testing SDK */ @@ -26,12 +29,21 @@ module.exports = { if (config) { try { configValidator.validate(config); + config.isValidInstance = true; } catch (ex) { - defaultLogger.log(enums.LOG_LEVEL.ERROR, ex.message); + var errorMessage = MODULE_NAME + ':' + ex.message; + if (config.logger) { + config.logger.log(enums.LOG_LEVEL.ERROR, errorMessage); + } else { + defaultLogger.log(enums.LOG_LEVEL.ERROR, errorMessage); + } + config.isValidInstance = false; } } config = _.assignIn({ + clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE, + clientVersion: JAVASCRIPT_CLIENT_VERSION, errorHandler: defaultErrorHandler, eventDispatcher: defaultEventDispatcher, logger: logger.createLogger({ logLevel: enums.LOG_LEVEL.INFO }), diff --git a/lib/plugins/event_dispatcher/index.js b/lib/plugins/event_dispatcher/index.js index 8aa6a6626..534c938f2 100644 --- a/lib/plugins/event_dispatcher/index.js +++ b/lib/plugins/event_dispatcher/index.js @@ -1,5 +1,5 @@ var _ = require('lodash/core'); -var bluebird = require('bluebird'); +var es6Promise = require('es6-promise').Promise; var POST_METHOD = 'POST'; var GET_METHOD = 'GET'; @@ -16,7 +16,7 @@ module.exports = { var params = eventObj.params; if (eventObj.httpVerb === POST_METHOD) { - return new bluebird(function(resolve, reject) { + return new es6Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.open(POST_METHOD, url, true); @@ -26,9 +26,9 @@ module.exports = { resolve(responseObj); }); req.send(JSON.stringify(params)); - }) + }); } else { - return new bluebird(function (resolve, reject) { + return new es6Promise(function (resolve, reject) { // add param for cors headers to be sent by the log endpoint url += '?wxhr=true'; if (params) { diff --git a/package.json b/package.json index 183f7ee82..80a786d15 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "optimizely-client-sdk", - "version": "0.1.4", - "description": "Javascript SDK for client testing", + "version": "1.0.0", + "description": "JavaScript SDK for client testing", "main": "index.js", "scripts": { "test": "./node_modules/.bin/mocha ./tests.js", @@ -19,9 +19,9 @@ }, "homepage": "https://github.com/optimizely/javascript-sdk#readme", "dependencies": { - "bluebird": "^3.4.0", + "es6-promise": "^3.3.1", "lodash": "^4.13.1", - "optimizely-server-sdk": "^0.1.4" + "optimizely-server-sdk": "^1.0.0" }, "devDependencies": { "chai": "^3.5.0", diff --git a/tests.js b/tests.js index 29e501bff..6e990ecb9 100644 --- a/tests.js +++ b/tests.js @@ -1,6 +1,7 @@ var configValidator = require('optimizely-server-sdk/lib/utils/config_validator'); var Optimizely = require('optimizely-server-sdk/lib/optimizely'); var optimizelyFactory = require('./'); +var packageJSON = require('./package.json'); var chai = require('chai'); var assert = chai.assert; @@ -42,6 +43,18 @@ describe('javascript-sdk', function() { assert.instanceOf(optlyInstance, Optimizely); }); + + it('should set the Javascript client engine and version', function() { + var optlyInstance = optimizelyFactory.createInstance({ + datafile: {}, + errorHandler: fakeErrorHandler, + eventDispatcher: fakeEventDispatcher, + logger: fakeLogger, + }); + + assert.equal('javascript-sdk', optlyInstance.clientEngine); + assert.equal(packageJSON.version, optlyInstance.clientVersion); + }); }); }); });