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/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 4a956825f..0212da89b 100644 --- a/dist/optimizely.min.js +++ b/dist/optimizely.min.js @@ -1,4 +1,4 @@ -!function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var n=r(1),o=r(3),i=r(6),a=r(7),u=r(5),s=r(11),c=r(13);t.exports={createInstance:function(t){var e=s.createLogger({logLevel:u.LOG_LEVEL.INFO});if(t)try{o.validate(t)}catch(r){e.log(u.LOG_LEVEL.ERROR,r.message)}return t=n.assignIn({errorHandler:i,eventDispatcher:a,logger:s.createLogger({logLevel:u.LOG_LEVEL.INFO})},t),new c(t)}}},function(t,e,r){var n;(function(t,o){(function(){function i(t,e){return t.push.apply(t,e),t}function a(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i0&&r(s)?e>1?x(s,e-1,r,n,o):i(o,s):n||(o[o.length]=s)}return o}function O(t,e){return t&&Ke(t,e,nr)}function I(t,e){return E(e,function(e){return kt(t[e])})}function j(t,e){return t>e}function A(t){return Ct(t)&&Pe.call(t)==ve}function w(t,e,r,n,o){return t===e||(null==t||null==e||!Pt(t)&&!Ct(e)?t!==t&&e!==e:S(t,e,w,r,n,o))}function S(t,e,r,n,o,i){var a=Xe(t),u=Xe(e),s=pe,c=pe;a||(s=Pe.call(t),s=s==le?be:s),u||(c=Pe.call(e),c=c==le?be:c);var f=s==be&&!l(t),p=c==be&&!l(e),h=s==c;i||(i=[]);var v=ze(i,function(e){return e[0]==t}),d=ze(i,function(t){return t[0]==e});if(v&&d)return v[1]==e;if(i.push([t,e]),i.push([e,t]),h&&!f){var m=a?X(t,e,r,n,o,i):Z(t,e,s,r,n,o,i);return i.pop(),m}if(!(o&se)){var y=f&&ke.call(t,"__wrapped__"),g=p&&ke.call(e,"__wrapped__");if(y||g){var b=y?t.value():t,_=g?e.value():e,m=r(b,_,n,o,i);return i.pop(),m}}if(!h)return!1;var m=J(t,e,r,n,o,i);return i.pop(),m}function N(t){return Pt(t)&&Pe.call(t)==_e}function R(t){return"function"==typeof t?t:null==t?Xt:("object"==typeof t?L:u)(t)}function T(t,e){return to?0:o+e),r=r>o?o:r,r<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++ne||i&&a&&s&&!u&&!c||n&&a&&s||!r&&s||!o)return 1;if(!n&&!i&&!c&&t1?r[o-1]:re;for(i=t.length>3&&"function"==typeof i?(o--,i):re,e=Object(e);++n-1?o[i?e[a]:a]:re}}function H(t,e,r,n){function o(){for(var e=-1,u=arguments.length,s=-1,c=n.length,f=Array(c+u),l=this&&this!==we&&this instanceof o?a:t;++su))return!1;for(var c=-1,f=!0,l=o&ue?[]:re;++c0&&(r=e.apply(this,arguments)),t<=1&&(e=re),r}}function Et(t){if("function"!=typeof t)throw new TypeError(oe);return function(){var e=arguments;return!t.apply(this,e)}}function xt(t){return _t(2,t)}function Ot(t){return Pt(t)?Xe(t)?F(t):G(t,Me(t)):t}function It(t,e){return t===e||t!==t&&e!==e}function jt(t){return wt(t)&&ke.call(t,"callee")&&(!Fe.call(t,"callee")||Pe.call(t)==le)}function At(t){return null!=t&&Lt(t.length)&&!kt(t)}function wt(t){return Ct(t)&&At(t)}function St(t){return t===!0||t===!1||Ct(t)&&Pe.call(t)==he}function Nt(t){return At(t)&&(Xe(t)||Mt(t)||kt(t.splice)||jt(t))?!t.length:!Me(t).length}function Rt(t,e){return w(t,e)}function Tt(t){return"number"==typeof t&&Ve(t)}function kt(t){var e=Pt(t)?Pe.call(t):"";return e==me||e==ye}function Lt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=fe}function Pt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ct(t){return!!t&&"object"==typeof t}function Dt(t){return Vt(t)&&t!=+t}function Ft(t){return null===t}function Vt(t){return"number"==typeof t||Ct(t)&&Pe.call(t)==ge}function Mt(t){return"string"==typeof t||!Xe(t)&&Ct(t)&&Pe.call(t)==Ee}function Ut(t){return t===re}function Gt(t){return At(t)?t.length?F(t):[]:qt(t)}function Kt(t){return"string"==typeof t?t:null==t?"":t+""}function Bt(t,e){var r=y(t);return e?Qe(r,e):r}function zt(t,e){return null!=t&&ke.call(t,e)}function $t(t,e,r){var n=null==t?re:t[e];return n===re&&(n=r),kt(n)?n.call(t):n}function qt(t){return t?f(t,nr(t)):[]}function Ht(t){return t=Kt(t),t&&Oe.test(t)?t.replace(xe,Ne):t}function Xt(t){return t}function Zt(t){return L(Qe({},t))}function Jt(t,e,r){var n=nr(e),o=I(e,n);null!=r||Pt(e)&&(o.length||!n.length)||(r=e,e=t,t=this,o=I(e,nr(e)));var a=!(Pt(r)&&"chain"in r&&!r.chain),u=kt(t);return Ge(o,function(r){var n=e[r];t[r]=n,u&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__),o=r.__actions__=F(this.__actions__);return o.push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,i([this.value()],arguments))})}),t}function Yt(){return we._===this&&(we._=Ce),this}function Wt(){}function Qt(t){var e=++Le;return Kt(t)+e}function te(t){return t&&t.length?_(t,Xt,j):re}function ee(t){return t&&t.length?_(t,Xt,T):re}var re,ne="4.15.0",oe="Expected a function",ie=1,ae=32,ue=1,se=2,ce=1/0,fe=9007199254740991,le="[object Arguments]",pe="[object Array]",he="[object Boolean]",ve="[object Date]",de="[object Error]",me="[object Function]",ye="[object GeneratorFunction]",ge="[object Number]",be="[object Object]",_e="[object RegExp]",Ee="[object String]",xe=/[&<>"'`]/g,Oe=RegExp(xe.source),Ie={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},je="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,we=je||Ae||Function("return this")(),Se="object"==typeof e&&e&&!e.nodeType&&e,Ne=(Se&&"object"==typeof o&&o&&!o.nodeType&&o,s(Ie)),Re=Array.prototype,Te=Object.prototype,ke=Te.hasOwnProperty,Le=0,Pe=Te.toString,Ce=we._,De=Object.create,Fe=Te.propertyIsEnumerable,Ve=we.isFinite,Me=p(Object.keys,Object),Ue=Math.max;v.prototype=y(h.prototype),v.prototype.constructor=v;var Ge=B(O),Ke=z(),Be=String,ze=q(et),$e=C(function(t,e,r){return H(t,ie|ae,e,r)}),qe=C(function(t,e){return g(t,1,e)}),He=C(function(t,e,r){return g(t,We(e)||0,r)}),Xe=Array.isArray,Ze=A,Je=N,Ye=Number,We=Number,Qe=K(function(t,e){G(e,Me(e),t)}),tr=K(function(t,e){G(e,W(e),t)}),er=K(function(t,e,r,n){G(e,or(e),t,n)}),rr=C(function(t){return t.push(re,d),er.apply(re,t)}),nr=Me,or=W,ir=C(function(t,e){return null==t?{}:P(t,k(x(e,1),Be))}),ar=R;h.assignIn=tr,h.before=_t,h.bind=$e,h.chain=st,h.compact=Q,h.concat=tt,h.create=Bt,h.defaults=rr,h.defer=qe,h.delay=He,h.filter=ht,h.flatten=rt,h.flattenDeep=nt,h.iteratee=ar,h.keys=nr,h.map=dt,h.matches=Zt,h.mixin=Jt,h.negate=Et,h.once=xt,h.pick=ir,h.slice=ut,h.sortBy=bt,h.tap=ct,h.thru=ft,h.toArray=Gt,h.values=qt,h.extend=tr,Jt(h,h),h.clone=Ot,h.escape=Ht,h.every=pt,h.find=ze,h.forEach=vt,h.has=zt,h.head=ot,h.identity=Xt,h.indexOf=it,h.isArguments=jt,h.isArray=Xe,h.isBoolean=St,h.isDate=Ze,h.isEmpty=Nt,h.isEqual=Rt,h.isFinite=Tt,h.isFunction=kt,h.isNaN=Dt,h.isNull=Ft,h.isNumber=Vt,h.isObject=Pt,h.isRegExp=Je,h.isString=Mt,h.isUndefined=Ut,h.last=at,h.max=te,h.min=ee,h.noConflict=Yt,h.noop=Wt,h.reduce=mt,h.result=$t,h.size=yt,h.some=gt,h.uniqueId=Qt,h.each=vt,h.first=ot,Jt(h,function(){var t={};return O(h,function(e,r){ke.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 o=this.value();return e.apply(Xe(o)?o:[],t)}return this[r](function(r){return e.apply(Xe(r)?r:[],t)})}}),h.prototype.toJSON=h.prototype.valueOf=h.prototype.value=lt,we._=h,n=function(){return h}.call(e,r,e,o),!(n!==re&&(o.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),o=r(5).ERROR_MESSAGES,i="CONFIG_VALIDATOR";t.exports={validate:function(t){if(t.errorHandler&&"function"!=typeof t.errorHandler.handleError)throw new Error(n(o.INVALID_ERROR_HANDLER,i));if(t.eventDispatcher&&"function"!=typeof t.eventDispatcher.dispatchEvent)throw new Error(n(o.INVALID_EVENT_DISPATCHER,i));if(t.logger&&"function"!=typeof t.logger.log)throw new Error(n(o.INVALID_LOGGER,i));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,o){var i="";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(o&&(o=o.slice(0),o.push(t)),null!=t.length){i+="[";var a=[];for(var u in t)o&&o.indexOf(t[u])>=0?a.push("[Circular]"):a.push(n.object_stringify(t[u],e+1,r,o));i+=a.join(", ")+"]"}else{if("getMonth"in t)return"Date("+t+")";i+="{";var a=[];for(var s in t)t.hasOwnProperty(s)&&(o&&o.indexOf(t[s])>=0?a.push(s+": [Circular]"):a.push(s+": "+n.object_stringify(t[s],e+1,r,o)));i+=a.join(", ")+"}"}return i;case"string":return'"'+t+'"'}return""+t},n.format=function(o,i){var a,u,s,c,f,l,p,h=1,v=o.length,d="",m=[];for(u=0;u=0?"+"+a:a,l=c[4]?"0"==c[4]?"0":c[4].charAt(1):" ",p=c[6]-String(a).length,f=c[6]?e(l,p):"",m.push(c[5]?a+f:f+a)}return m.join("")},n.cache={},n.parse=function(t){for(var e=t,r=[],n=[],o=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]){o|=1;var i=[],a=r[2],u=[];if(null===(u=/^([a-z_][a-z_\d]*)/i.exec(a)))throw new Error("[sprintf] "+a);for(i.push(u[1]);""!==(a=a.substring(u[0].length));)if(null!==(u=/^\.([a-z_][a-z_\d]*)/i.exec(a)))i.push(u[1]);else{if(null===(u=/^\[(\d+)\]/.exec(a)))throw new Error("[sprintf] "+a);i.push(u[1])}r[2]=i}else o|=2;if(3===o)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),o=r(8).Promise,i="POST",a="GET";t.exports={dispatchEvent:function(t){var e=t.url,r=t.params;return new o(t.httpVerb===i?function(t,n){var o=new XMLHttpRequest;o.open(i,e,!0),o.setRequestHeader("Content-Type","application/json"),o.addEventListener("load",function(e){var r=e.target.responseText;t(r)}),o.send(JSON.stringify(r))}:function(t,n){e+="?wxhr=true",r&&(e+="&"+u(r));var o=new XMLHttpRequest;o.open(a,e,!0),o.addEventListener("load",function(e){var r=JSON.parse(e.target.responseText);t(r)}),o.send()})}};var u=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 o(t){return"function"==typeof t}function i(t){Z=t}function a(t){J=t}function u(){return function(){return e.nextTick(p)}}function s(){return function(){X(p)}}function c(){var t=0,e=new Q(p),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=p,function(){return t.port2.postMessage(0)}}function l(){var t=setTimeout;return function(){return t(p,1)}}function p(){for(var t=0;t1)for(var n=1;n=this.logLevel},o.prototype.__consoleLog=function(t,e){switch(t){case s.LOG_LEVEL.DEBUG:console.debug.apply(console,e);break;case s.LOG_LEVEL.INFO:console.log.apply(console,e);break;case s.LOG_LEVEL.WARNING:console.warn.apply(console,e);break;case s.LOG_LEVEL.ERROR:console.error.apply(console,e);break;default:console.log.apply(console,e)}},t.exports={createLogger:function(t){return new o(t)},createNoOpLogger:function(){return new n}}},function(t,e,r){var n;(function(t,o){(function(){function i(t,e){return t.push.apply(t,e),t}function a(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i0&&r(s)?e>1?E(s,e-1,r,n,o):i(o,s):n||(o[o.length]=s)}return o}function x(t,e){return t&&Ke(t,e,rr)}function O(t,e){return _(e,function(e){return kt(t[e])})}function I(t,e){return t>e}function j(t,e,r,n,o){return t===e||(null==t||null==e||!Pt(t)&&!Ct(e)?t!==t&&e!==e:A(t,e,j,r,n,o))}function A(t,e,r,n,o,i){var a=Ze(t),u=Ze(e),s=he,c=he;a||(s=Pe.call(t),s=s==pe?_e:s),u||(c=Pe.call(e),c=c==pe?_e:c);var f=s==_e&&!l(t),p=c==_e&&!l(e),h=s==c;i||(i=[]);var v=$e(i,function(e){return e[0]===t});if(v&&v[1])return v[1]==e;if(i.push([t,e]),h&&!f){var d=a?H(t,e,r,n,o,i):X(t,e,s,r,n,o,i);return i.pop(),d}if(!(o&ce)){var m=f&&ke.call(t,"__wrapped__"),y=p&&ke.call(e,"__wrapped__");if(m||y){var g=m?t.value():t,b=y?e.value():e,d=r(g,b,n,o,i);return i.pop(),d}}if(!h)return!1;var d=Z(t,e,r,n,o,i);return i.pop(),d}function w(t){return"function"==typeof t?t:null==t?Zt:("object"==typeof t?k:P)(t)}function S(t){return Me(Object(t))}function N(t){t=null==t?t:Object(t);var e=[];for(var r in t)e.push(r);return e}function R(t,e){return to?0:o+e),r=r>o?o:r,r<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++ne||i&&a&&s&&!u&&!c||n&&a&&s||!r&&s||!o)return 1;if(!n&&!i&&!c&&t1?r[o-1]:ne;for(i=t.length>3&&"function"==typeof i?(o--,i):ne,e=Object(e);++n-1?e[i?i[a]:a]:ne}}function q(t,e,r,n){function o(){for(var e=-1,u=arguments.length,s=-1,c=n.length,f=Array(c+u),l=this&&this!==Ne&&this instanceof o?a:t;++su))return!1;for(var c=-1,f=!0,l=o&se?[]:ne;++c0&&(r=e.apply(this,arguments)),t<=1&&(e=ne),r}}function bt(t){if("function"!=typeof t)throw new TypeError(ie);return function(){return!t.apply(this,arguments)}}function _t(t){return gt(2,t)}function Et(t,e){if("function"!=typeof t)throw new TypeError(ie);return e=Ue(e===ne?t.length-1:Je(e),0),function(){for(var r=arguments,n=-1,o=Ue(r.length-e,0),i=Array(o);++n-1&&t%1==0&&t<=le}function Pt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ct(t){return!!t&&"object"==typeof t}function Dt(t){return Vt(t)&&t!=+t}function Ft(t){return null===t}function Vt(t){return"number"==typeof t||Ct(t)&&Pe.call(t)==be}function Mt(t){return Pt(t)&&Pe.call(t)==Ee}function Ut(t){return"string"==typeof t||!Ze(t)&&Ct(t)&&Pe.call(t)==xe}function Gt(t){return t===ne}function Kt(t){return jt(t)?t.length?D(t):[]:Ht(t)}function Bt(t){return"string"==typeof t?t:null==t?"":t+""}function zt(t,e){var r=m(t);return e?We(r,e):r}function $t(t,e){return null!=t&&ke.call(t,e)}function qt(t,e,r){var n=null==t?ne:t[e];return n===ne&&(n=r),kt(n)?n.call(t):n}function Ht(t){return t?s(t,rr(t)):[]}function Xt(t){return t=Bt(t),t&&Ie.test(t)?t.replace(Oe,f):t}function Zt(t){return t}function Jt(t){return k(We({},t))}function Yt(t,e,r){var n=rr(e),o=O(e,n);null!=r||Pt(e)&&(o.length||!n.length)||(r=e,e=t,t=this,o=O(e,rr(e)));var a=!(Pt(r)&&"chain"in r&&!r.chain),u=kt(t);return Ge(o,function(r){var n=e[r];t[r]=n,u&&(t.prototype[r]=function(){var e=this.__chain__;if(a||e){var r=t(this.__wrapped__),o=r.__actions__=D(this.__actions__);return o.push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,i([this.value()],arguments))})}),t}function Wt(){return Ne._===this&&(Ne._=Ce),this}function Qt(){}function te(t){var e=++Le;return Bt(t)+e}function ee(t){return t&&t.length?b(t,Zt,I):ne}function re(t){return t&&t.length?b(t,Zt,R):ne}var ne,oe="4.13.1",ie="Expected a function",ae=1,ue=32,se=1,ce=2,fe=1/0,le=9007199254740991,pe="[object Arguments]",he="[object Array]",ve="[object Boolean]",de="[object Date]",me="[object Error]",ye="[object Function]",ge="[object GeneratorFunction]",be="[object Number]",_e="[object Object]",Ee="[object RegExp]",xe="[object String]",Oe=/[&<>"'`]/g,Ie=RegExp(Oe.source),je={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ae=c("object"==typeof o&&o),we=c("object"==typeof self&&self),Se=c("object"==typeof this&&this),Ne=Ae||we||Se||Function("return this")(),Re=Array.prototype,Te=Object.prototype,ke=Te.hasOwnProperty,Le=0,Pe=Te.toString,Ce=Ne._,De=Object.create,Fe=Te.propertyIsEnumerable,Ve=Ne.isFinite,Me=Object.keys,Ue=Math.max;h.prototype=m(p.prototype),h.prototype.constructor=h;var Ge=K(x),Ke=B(),Be=P("length"),ze=String,$e=$(Q),qe=Et(function(t,e,r){return q(t,ae|ue,e,r)}),He=Et(function(t,e){return y(t,1,e)}),Xe=Et(function(t,e,r){return y(t,Ye(e)||0,r)}),Ze=Array.isArray,Je=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=Et(function(t){return t.push(ne,v),tr.apply(ne,t)}),rr=S,nr=N,or=Et(function(t,e){return null==t?{}:L(t,T(E(e,1),ze))}),ir=w;p.assignIn=Qe,p.before=gt,p.bind=qe,p.chain=at,p.compact=Y,p.concat=W,p.create=zt,p.defaults=er,p.defer=He,p.delay=Xe,p.filter=lt,p.flatten=tt,p.flattenDeep=et,p.iteratee=ir,p.keys=rr,p.map=ht,p.matches=Jt,p.mixin=Yt,p.negate=bt,p.once=_t,p.pick=or,p.slice=it,p.sortBy=yt,p.tap=ut,p.thru=st,p.toArray=Kt,p.values=Ht,p.extend=Qe,Yt(p,p),p.clone=xt,p.escape=Xt,p.every=ft,p.find=$e,p.forEach=pt,p.has=$t,p.head=rt,p.identity=Zt,p.indexOf=nt,p.isArguments=It,p.isArray=Ze,p.isBoolean=wt,p.isDate=St,p.isEmpty=Nt,p.isEqual=Rt,p.isFinite=Tt,p.isFunction=kt,p.isNaN=Dt,p.isNull=Ft,p.isNumber=Vt,p.isObject=Pt,p.isRegExp=Mt,p.isString=Ut,p.isUndefined=Gt,p.last=ot,p.max=ee,p.min=re,p.noConflict=Wt,p.noop=Qt,p.reduce=vt,p.result=qt,p.size=dt,p.some=mt,p.uniqueId=te,p.each=pt,p.first=rt,Yt(p,function(){var t={};return x(p,function(e,r){ke.call(p.prototype,r)||(t[r]=e)}),t}(),{chain:!1}),p.VERSION=oe,Ge(["pop","join","replace","reverse","split","push","shift","sort","splice","unshift"],function(t){var e=(/^(?:replace|split)$/.test(t)?String.prototype:Re)[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|join|replace|shift)$/.test(t);p.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var o=this.value();return e.apply(Ze(o)?o:[],t)}return this[r](function(r){return e.apply(Ze(r)?r:[],t)})}}),p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ct,(we||{})._=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=l.createProjectConfig(t.datafile),this.logger.log(m.INFO,h(y.VALID_DATAFILE,g));else try{f.validate(p,t.datafile)&&(this.configObj=l.createProjectConfig(t.datafile),this.logger.log(m.INFO,h(y.VALID_DATAFILE,g)))}catch(e){this.logger.log(m.ERROR,e.message),this.errorHandler.handleError(e)}else this.logger.log(m.ERROR,h(d.NO_DATAFILE_SPECIFIED,g)),this.errorHandler.handleError(new Error(h(d.NO_DATAFILE_SPECIFIED,g)))}var o=r(12),i=r(14),a=r(15),u=r(17),s=r(5),c=r(19),f=r(162),l=r(22),p=r(172),h=r(4),v=r(173),d=s.ERROR_MESSAGES,m=s.LOG_LEVEL,y=s.LOG_MESSAGES,g="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,g,e,t);return this.logger.log(m.INFO,n),null}var o=this.__buildBucketerParams(t,e),i=u.bucket(o);if(null===i){var n=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.INFO,n),null}var a=c.createImpressionEventParams(this.configObj,t,i,e,r),s=c.getUrl(this.configObj),f=h(y.DISPATCH_IMPRESSION_EVENT,g,s,a);this.logger.log(m.DEBUG,f),this.eventDispatcher.dispatchEvent(s,a).then(function(){var r=h(y.ACTIVATE_USER,g,e,t);this.logger.log(m.INFO,r)}.bind(this));var p=l.getVariationKeyFromId(this.configObj,t,i);return p}catch(v){this.logger.log(m.ERROR,v.message);var n=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.INFO,n),this.errorHandler.handleError(v),null}},n.prototype.track=function(t,e,r,n){try{if(!this.__validateInputs(e,r))return;var o=l.getExperimentIdsForGoal(this.configObj,t);if(!o)return void this.logger.log(m.WARNING,h(y.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,g,t));var i=this.__getValidExperimentIdsForGoal(t,e,r);if(!i.length){var a=h(y.NO_VALID_EXPERIMENTS_FOR_GOAL_TO_TRACK,g,t);return void this.logger.log(m.INFO,a)}var u=this.__getBucketedVariationIdsForUser(i,e),s=c.createConversionEventParams(this.configObj,t,e,r,n,u,i),f=c.getUrl(this.configObj),p=h(y.DISPATCH_CONVERSION_EVENT,g,f,s);this.logger.log(m.DEBUG,p),this.eventDispatcher.dispatchEvent(f,s).then(function(){var r=h(y.TRACK_EVENT,g,t,e);this.logger.log(m.INFO,r)}.bind(this))}catch(v){this.logger.log(m.ERROR,v.message),this.errorHandler.handleError(v)}},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),o=u.bucket(n);return l.getVariationKeyFromId(this.configObj,t,o)}catch(i){return this.logger.log(m.ERROR,i.message),this.errorHandler.handleError(i),null}},n.prototype.__getValidExperimentIdsForGoal=function(t,e,r){var n=[];if(this.configObj.eventKeyMap[t]){var i;o.forEach(this.configObj.eventKeyMap[t].experimentIds,function(t){if(i=this.configObj.experimentIdMap[t].key,this.__validatePreconditions(i,e,r))n.push(t);else{var o=h(y.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,i);this.logger.log(m.INFO,o)}}.bind(this))}return n},n.prototype.__getBucketedVariationIdsForUser=function(t,e){try{var r=o.filter(Object.keys(this.configObj.experimentKeyMap),function(e){var r=l.getExperimentId(this.configObj,e);return r&&t.indexOf(r)!==-1}.bind(this)),n=o.map(r,function(t){var r=this.__buildBucketerParams(t,e);return u.bucket(r)}.bind(this));return n}catch(i){return this.logger.log(m.ERROR,i.message),this.errorHandler.handleError(i),null}},n.prototype.__validateInputs=function(t,e){try{return v.validate(t),e&&i.validate(e),!0}catch(r){return this.logger.log(m.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__validatePreconditions=function(t,e,r){if(!l.isExperimentRunning(this.configObj,t)){var n=h(y.EXPERIMENT_NOT_RUNNING,g,t);return this.logger.log(m.INFO,n),!1}var o=l.getAudiencesForExperiment(this.configObj,t);if(!a.evaluate(o,r)){var i=h(y.USER_NOT_IN_EXPERIMENT,g,e,t);return this.logger.log(m.INFO,i),!1}return!0},n.prototype.__buildBucketerParams=function(t,e){var r={};return r.experimentKey=t,r.experimentId=l.getExperimentId(this.configObj,t),r.userId=e,r.forcedVariations=this.configObj.experimentKeyMap[t].forcedVariations,r.trafficAllocationConfig=l.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),o=r(5).ERROR_MESSAGES,i="ATTRIBUTES_VALIDATOR";t.exports={validate:function(t){if("object"!=typeof t||Array.isArray(t)||null===t)throw new Error(n(o.INVALID_ATTRIBUTES,i));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,o=0;o=4;)r=255&t.charCodeAt(i)|(255&t.charCodeAt(++i))<<8|(255&t.charCodeAt(++i))<<16|(255&t.charCodeAt(++i))<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^r,n-=4,++i;switch(n){case 3:o^=(255&t.charCodeAt(i+2))<<16;case 2:o^=(255&t.charCodeAt(i+1))<<8;case 1:o^=255&t.charCodeAt(i),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)}return o^=o>>>13,o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16),o^=o>>>15,o>>>0}function r(t,e){var r,n,o,i,a,u,s,c;for(r=3&t.length,n=t.length-r,o=e,a=3432918353,u=461845907,c=0;c>>16)*a&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*u+(((s>>>16)*u&65535)<<16)&4294967295,o^=s,o=o<<13|o>>>19,i=5*(65535&o)+((5*(o>>>16)&65535)<<16)&4294967295,o=(65535&i)+27492+(((i>>>16)+58964&65535)<<16);switch(s=0,r){case 3:s^=(255&t.charCodeAt(c+2))<<16;case 2:s^=(255&t.charCodeAt(c+1))<<8;case 1:s^=255&t.charCodeAt(c),s=(65535&s)*a+(((s>>>16)*a&65535)<<16)&4294967295,s=s<<15|s>>>17,s=(65535&s)*u+(((s>>>16)*u&65535)<<16)&4294967295,o^=s}return o^=t.length,o^=o>>>16,o=2246822507*(65535&o)+((2246822507*(o>>>16)&65535)<<16)&4294967295,o^=o>>>13,o=3266489909*(65535&o)+((3266489909*(o>>>16)&65535)<<16)&4294967295,o^=o>>>16,o>>>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 o=t.attributeKeyMap[n].segmentId,i=p("%s%s",v.segmentPrefix,o);r[i]=e}}),r}function o(t,e,r){var o={};if(o[v.projectId]=t.projectId,o[v.accountId]=t.accountId,o[v.endUserId]=e,r){var i=n(t,r);c.assignIn(o,i)}var a=f.isNode()?"node-sdk":"javascript-sdk";return o[v.source]=p("%s-%s",a,l.version),o[v.time]=Math.round((new Date).getTime()/1e3),o}function i(t,e){var r={},n=h.getExperimentId(t,e);return r[v.goalId]=n,r[v.goalName]="visitor-event",r}function a(t,e,r){var n={},o=t.eventKeyMap[e].id,i=o;return r&&(i=p("%s,%s",o,h.getRevenueGoalId(t)),n[v.eventValue]=r),n[v.goalId]=i,n[v.goalName]=e,n}function u(t,e,r){var n={},o=h.getExperimentId(t,e),i=p("%s%s",v.experimentPrefix,o);return n[i]=r,n}function s(t,e,r,n){var o={},i=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(i,function(e){var n=h.getExperimentId(t,e),i=p("%s%s",v.experimentPrefix,n),a=h.getEventVariationIdFromExperimentKey(t,e,r);o[i]=a}),o}var c=r(12),f=r(20),l=r(21),p=r(4),h=r(22),v={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 s=o(t,n,a),f=i(t,e),l=u(t,e,r);return c.assignIn(s,f,l)},createConversionEventParams:function(t,e,r,n,i,u,f){var l=o(t,r,n),p=a(t,e,i),h=s(t,r,u,f);return c.assignIn(l,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={name:"optimizely-server-sdk",description:"Node SDK for consumption for server-side testing",version:"0.1.3",repository:{type:"git",url:"https://github.com/optimizely/node-sdk.git"},keywords:["optimizely"],homepage:"https://github.com/optimizely/node-sdk",main:"index.js",scripts:{test:"mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js","profile-test":"mocha ./tests/profiling_tests.js",lint:"eslint lib/** index.js tests.js",cover:"istanbul cover _mocha ./tests.js ./lib/**/*tests.js ./lib/**/**/*tests.js",coveralls:"npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"},dependencies:{bluebird:"^3.3.5",jsonschema:"^1.1.0",lodash:"4.13.1",murmurhash:"0.0.2","request-promise":"^2.0.1",sprintf:"^0.1.5"},devDependencies:{chai:"^3.5.0",coveralls:"^2.11.9",eslint:"^2.9.0",istanbul:"^0.4.3",mathjs:"^3.3.0",mocha:"^2.4.5","mocha-lcov-reporter":"^1.2.0",nock:"^7.7.2",sinon:"^1.17.4"},readme:"#Optimizely Node SDK\n[![Build Status](https://travis-ci.org/optimizely/node-sdk.svg?branch=master)](https://travis-ci.org/optimizely/node-sdk)\n[![Coverage Status](https://coveralls.io/repos/github/optimizely/node-sdk/badge.svg?branch=master&t=pegN7y)](https://coveralls.io/github/optimizely/node-sdk?branch=master)\n\nThis repository houses the Node SDK for Optimizely's server-side testing product, which is currently in private beta.\n\n##Getting Started\n\n###Installing the SDK\n\nThe SDK is available through [npm](https://npmjs.com/package/optimizely-server-sdk). To install:\n\n```\nnpm install optimizely-server-sdk --save\n```\n\n###Using the SDK\nSee the Optimizely server-side testing [developer documentation](http://developers.optimizely.com/server/reference/index) to learn how to set up your first custom project and use the SDK. **Please note that you must be a member of the private server-side testing beta to create custom projects and use this SDK.**\n\n##Development\n\n###Installing dependencies\n\n```npm install```\n\n###Unit tests\n\nYou can run all unit tests with:\n```\nnpm test\n```\n\n###Benchmarking tests\n\nYou can run benchmarking tests with:\n```\nnpm run profile-test\n```\n\n###Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md).\n",readmeFilename:"README.md",gitHead:"ea123218984da886a6dc4e46832dd5f31de3307c",bugs:{url:"https://github.com/optimizely/node-sdk/issues"},_id:"optimizely-server-sdk@0.1.3",_shasum:"dac7364231affbb62bebb351fa365be94b910a41",_from:"optimizely-server-sdk@^0.1.3"}},function(t,e,r){var n=r(12),o=r(23),i=r(132),a=r(5),u=r(4),s="Running",c="PROJECT_CONFIG",f="Total Revenue",l=a.ERROR_MESSAGES;t.exports={createProjectConfig:function(e){var r=i(e);n.forEach(r.audiences,function(t){t.conditions=JSON.parse(t.conditions)}),r.attributeKeyMap=o(r.dimensions,"key"),r.eventKeyMap=o(r.events,"key"),r.groupIdMap=o(r.groups,"id");var a;return n.forEach(r.groupIdMap,function(t,e){a=i(t.experiments),n.forEach(a,function(t){r.experiments.push(n.assignIn(t,{groupId:e}))})}),r.experimentKeyMap=o(r.experiments,"key"),r.experimentIdMap=o(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,o(e.variations,"id"))}),r},_generateExperimentVariationKeyMap:function(t,e,r){for(var n,o={},i=0;i0?r.experimentIds:null;throw new Error(u(l.INVALID_EVENT_KEY,c,e))},getTrafficAllocation:function(t,e){var r=t.experimentKeyMap[e];if(n.isEmpty(r))throw new Error(u(l.INVALID_EXPERIMENT_KEY,c,e));return r.trafficAllocation}}},function(t,e,r){var n=r(24),o=n(function(t,e,r){t[r]=e});t.exports=o},function(t,e,r){function n(t,e){return function(r,n){var s=u(r)?o:i,c=e?e():{};return s(r,t,a(n),c)}}var o=r(25),i=r(26),a=r(51),u=r(46);t.exports=n},function(t,e){function r(t,e,r,n){for(var o=-1,i=t?t.length:0;++o-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||!o(t)&&i(t)&&s.call(t)==a}var o=r(46),i=r(45),a="[object String]",u=Object.prototype,s=u.toString;t.exports=n},function(t,e){function r(t,e){return e=null==e?n:e,!!e&&("number"==typeof t||o.test(t))&&t>-1&&t%1==0&&t-1}var o=r(58);t.exports=n},function(t,e,r){function n(t,e){var r=this.__data__,n=o(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}var o=r(58);t.exports=n},function(t,e,r){function n(){this.__data__=new o}var o=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 o&&r.__data__.length==a&&(r=this.__data__=new i(r.__data__)),r.set(t,e),this}var o=r(55),i=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();++el))return!1;var h=c.get(t);if(h)return h==e;var v=-1,d=!0,m=s&a?new o:void 0;for(c.set(t,e);++v already exists with different definition");return this.schemas[o]}this.schemas[o]=e;var u=o.replace(/^([^#]*)#$/,"$1");this.schemas[u]=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[o]}},c.prototype.addSubSchemaArray=function(t,e){if(e instanceof Array)for(var r=0;r",t);var c=i.objectGetPath(r.schemas[s],a.substr(1));if(void 0===c)throw new u("no such schema "+a+" located in <"+s+">",t);return{subschema:c,switchSchema:e}},c.prototype.testType=function(t,e,r,n,o){if("function"==typeof this.types[o])return this.types[o].call(this,t);if(o&&"object"==typeof o){var i=this.validateSchema(t,o,r,n);return void 0===i||!(i&&i.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 o(t,e,r){if(t&&c(t)&&t instanceof n)return t;var o=new n;return o.parse(t,e,r),o}function i(t){return s(t)&&(t=o(t)),t instanceof n?t.format():n.prototype.format.call(t)}function a(t,e){return o(t,!1,!0).resolve(e)}function u(t,e){return t?o(t,!1,!0).resolveObject(e):e}function s(t){return"string"==typeof t}function c(t){return"object"==typeof t&&null!==t}function f(t){return null===t}function l(t){return null==t}var p=r(166);e.parse=o,e.resolve=a,e.resolveObject=u,e.format=i,e.Url=n;var h=/^([a-z0-9.+-]+:)/i,v=/:[0-9]*$/,d=["<",">",'"',"`"," ","\r","\n","\t"],m=["{","}","|","\\","^","`"].concat(d),y=["'"].concat(m),g=["%","/","?",";","#"].concat(y),b=["/","?","#"],_=255,E=/^[a-z0-9A-Z_-]{0,63}$/,x=/^([a-z0-9A-Z_-]{0,63})(.*)$/,O={javascript:!0,"javascript:":!0},I={javascript:!0,"javascript:":!0},j={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(!s(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t;n=n.trim();var o=h.exec(n);if(o){o=o[0];var i=o.toLowerCase();this.protocol=i,n=n.substr(o.length)}if(r||o||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===n.substr(0,2);!a||o&&I[o]||(n=n.substr(2),this.slashes=!0)}if(!I[o]&&(a||o&&!j[o])){for(var u=-1,c=0;c127?"x":S[R];if(!N.match(E)){var k=m.slice(0,c),L=m.slice(c+1),P=S.match(x);P&&(k.push(P[1]),L.unshift(P[2])),L.length&&(n="/"+L.join(".")+n),this.hostname=k.join(".");break}}}if(this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),!d){for(var C=this.hostname.split("."),D=[],c=0;c0)&&r.host.split("@");m&&(r.auth=m.shift(),r.host=r.hostname=m.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(!v.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var y=v.slice(-1)[0],g=(r.host||t.host)&&("."===y||".."===y)||""===y,b=0,_=v.length;_>=0;_--)y=v[_],"."==y?v.splice(_,1):".."===y?(v.splice(_,1),b++):b&&(v.splice(_,1),b--);if(!p&&!h)for(;b--;b)v.unshift("..");!p||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),g&&"/"!==v.join("/").substr(-1)&&v.push("");var E=""===v[0]||v[0]&&"/"===v[0].charAt(0);if(d){r.hostname=r.host=E?"":v.length?v.shift():"";var m=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");m&&(r.auth=m.shift(),r.host=r.hostname=m.shift())}return p=p||r.host&&v.length,p&&!E&&v.unshift(""),v.length?r.pathname=v.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=v.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,o){!function(i){function a(t){throw RangeError(k[t])}function u(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function s(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]),t=t.replace(T,".");var o=t.split("."),i=u(o,e).join(".");return n+i}function c(t){for(var e,r,n=[],o=0,i=t.length;o=55296&&e<=56319&&o65535&&(t-=65536,e+=C(t>>>10&1023|55296),t=56320|1023&t),e+=C(t)}).join("")}function l(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?P(t/j):t>>1,t+=P(t/e);t>L*O>>1;n+=E)t=P(t/L);return P(n+(L+1)*t/(t+I))}function v(t){var e,r,n,o,i,u,s,c,p,v,d=[],m=t.length,y=0,g=w,b=A;for(r=t.lastIndexOf(S),r<0&&(r=0),n=0;n=128&&a("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;o=m&&a("invalid-input"),c=l(t.charCodeAt(o++)),(c>=E||c>P((_-y)/u))&&a("overflow"),y+=c*u,p=s<=b?x:s>=b+O?O:s-b,!(cP(_/v)&&a("overflow"),u*=v;e=d.length+1,b=h(y-i,e,0==i),P(y/e)>_-g&&a("overflow"),g+=P(y/e),y%=e,d.splice(y++,0,g)}return f(d)}function d(t){var e,r,n,o,i,u,s,f,l,v,d,m,y,g,b,I=[];for(t=c(t),m=t.length,e=w,r=0,i=A,u=0;u=e&&dP((_-r)/y)&&a("overflow"),r+=(s-e)*y,e=s,u=0;u_&&a("overflow"),d==e){for(f=r,l=E;v=l<=i?x:l>=i+O?O:l-i,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=E-x,P=Math.floor,C=String.fromCharCode;b={version:"1.3.2",ucs2:{decode:c,encode:f},decode:v,encode:d,toASCII:y,toUnicode:m},n=function(){return b}.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,o){e=e||"&",n=n||"=";var i={};if("string"!=typeof t||0===t.length)return i;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var s=t.length;u>0&&s>u&&(s=u);for(var c=0;c=0?(f=v.substr(0,d),l=v.substr(d+1)):(f=v,l=""),p=decodeURIComponent(f),h=decodeURIComponent(l),r(i,p)?Array.isArray(i[p])?i[p].push(h):i[p]=[i[p],h]:i[p]=h}return i}},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,o){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map(function(o){var i=encodeURIComponent(r(o))+n;return Array.isArray(t[o])?t[o].map(function(t){return i+encodeURIComponent(r(t))}).join(e):i+encodeURIComponent(r(t[o]))}).join(e):o?encodeURIComponent(r(o))+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 o(t,e,r,n,o,i){if(!e.properties||void 0===e.properties[o])if(e.additionalProperties===!1)i.addError({name:"additionalProperties",argument:o,message:"additionalProperty "+JSON.stringify(o)+" exists in instance when not allowed"});else{var a=e.additionalProperties||{},u=this.validateSchema(t[o],a,r,n.makeChild(a,o)); -u.instance!==i.instance[o]&&(i.instance[o]=u.instance),i.importErrors(u)}}function i(t,e,r){var n,o=r.length;for(n=e+1,o;n"||t+""});o.addError({name:"type",argument:a,message:"is not of a type(s) "+a})}return o},f.anyOf=function(t,e,r,o){if(void 0===t)return null;var i=new u(t,e,r,o);if(!(e.anyOf instanceof Array))throw new s("anyOf must be an array");if(!e.anyOf.some(n.bind(this,t,r,o))){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+"]"});i.addError({name:"anyOf",argument:a,message:"is not any of "+a.join(",")})}return i},f.allOf=function(t,e,r,n){if(void 0===t)return null;if(!(e.allOf instanceof Array))throw new s("allOf must be an array");var o=new u(t,e,r,n),i=this;return e.allOf.forEach(function(e,a){var u=i.validateSchema(t,e,r,n);if(!u.valid){var s=e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+a+"]";o.addError({name:"allOf",argument:{id:s,length:u.errors.length,valid:u},message:"does not match allOf schema "+s+" with "+u.errors.length+" error[s]:"}),o.importErrors(u)}}),o},f.oneOf=function(t,e,r,o){if(void 0===t)return null;if(!(e.oneOf instanceof Array))throw new s("oneOf must be an array");var i=new u(t,e,r,o),a=e.oneOf.filter(n.bind(this,t,r,o)).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&&i.addError({name:"oneOf",argument:c,message:"is not exactly one from "+c.join(",")}),i},f.properties=function(t,e,r,n){if(void 0!==t&&t instanceof Object){var o=new u(t,e,r,n),i=e.properties||{};for(var a in i){var s=(t||void 0)&&t[a],c=this.validateSchema(s,i[a],r,n.makeChild(i[a],a));c.instance!==o.instance[a]&&(o.instance[a]=c.instance),o.importErrors(c)}return o}},f.patternProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){var i=new u(t,e,r,n),a=e.patternProperties||{};for(var s in t){var c=!0;for(var f in a){var l=new RegExp(f);if(l.test(s)){c=!1;var p=this.validateSchema(t[s],a[f],r,n.makeChild(a[f],s));p.instance!==i.instance[s]&&(i.instance[s]=p.instance),i.importErrors(p)}}c&&o.call(this,t,e,r,n,s,i)}return i}},f.additionalProperties=function(t,e,r,n){if(void 0!==t&&this.types.object(t)){if(e.patternProperties)return null;var i=new u(t,e,r,n);for(var a in t)o.call(this,t,e,r,n,a,i);return i}},f.minProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var o=new u(t,e,r,n),i=Object.keys(t);return i.length>=e.minProperties||o.addError({name:"minProperties",argument:e.minProperties,message:"does not meet minimum property length of "+e.minProperties}),o},f.maxProperties=function(t,e,r,n){if(!t||"object"!=typeof t)return null;var o=new u(t,e,r,n),i=Object.keys(t);return i.length<=e.maxProperties||o.addError({name:"maxProperties",argument:e.maxProperties,message:"does not meet maximum property length of "+e.maxProperties}),o},f.items=function(t,e,r,n){if(!(t instanceof Array))return null;var o=this,i=new u(t,e,r,n);return void 0!==t&&e.items?(t.every(function(t,a){var u=e.items instanceof Array?e.items[a]||e.additionalItems:e.items;if(void 0===u)return!0;if(u===!1)return i.addError({name:"items",message:"additionalItems not permitted"}),!1;var s=o.validateSchema(t,u,r,n.makeChild(u,a));return s.instance!==i.instance[a]&&(i.instance[a]=s.instance),i.importErrors(s),!0}),i):i},f.minimum=function(t,e,r,n){if("number"!=typeof t)return null;var o=new u(t,e,r,n),i=!0;return i=e.exclusiveMinimum&&e.exclusiveMinimum===!0?t>e.minimum:t>=e.minimum,i||o.addError({name:"minimum",argument:e.minimum,message:"must have a minimum value of "+e.minimum}),o},f.maximum=function(t,e,r,n){if("number"!=typeof t)return null;var o,i=new u(t,e,r,n);return o=e.exclusiveMaximum&&e.exclusiveMaximum===!0?t=e.minLength||o.addError({name:"minLength",argument:e.minLength,message:"does not meet minimum length of "+e.minLength}),o},f.maxLength=function(t,e,r,n){if("string"!=typeof t)return null;var o=new u(t,e,r,n);return t.length<=e.maxLength||o.addError({name:"maxLength",argument:e.maxLength,message:"does not meet maximum length of "+e.maxLength}),o},f.minItems=function(t,e,r,n){if(!(t instanceof Array))return null;var o=new u(t,e,r,n);return t.length>=e.minItems||o.addError({name:"minItems",argument:e.minItems,message:"does not meet minimum length of "+e.minItems}),o},f.maxItems=function(t,e,r,n){if(!(t instanceof Array))return null;var o=new u(t,e,r,n);return t.length<=e.maxItems||o.addError({name:"maxItems",argument:e.maxItems,message:"does not meet maximum length of "+e.maxItems}),o},f.uniqueItems=function(t,e,r,n){function o(t,e,r){for(var n=e+1;n"||a;i.addError({name:"not",argument:u,message:"is of prohibited type "+u})}}),i):null},t.exports=c},function(t,e,r){"use strict";var n=r(165),o=e.ValidationError=function(t,e,r,n,o,i){n&&(this.property=n),t&&(this.message=t),r&&(r.id?this.schema=r.id:this.schema=r),e&&(this.instance=e),this.name=o,this.argument=i,this.stack=this.toString()};o.prototype.toString=function(){return this.property+" "+this.message};var i=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};i.prototype.addError=function(t){var e;if("string"==typeof t)e=new o(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 o(t.message,this.instance,this.schema,this.propertyPath,t.name,t.argument)}if(this.throwError)throw e;return this.errors.push(e),e},i.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)})}},i.prototype.toString=function(t){return this.errors.map(function(t,e){return e+": "+t.toString()+"\n"}).join("")},Object.defineProperty(i.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 u=e.SchemaContext=function(t,e,r,n,o){this.schema=t,this.options=e,this.propertyPath=r,this.base=n,this.schemas=o};u.prototype.resolve=function(t){return n.resolve(this.base,t)},u.prototype.makeChild=function(t,e){var r=void 0===e?this.propertyPath:this.propertyPath+c(e),o=n.resolve(this.base,t.id||""),i=new u(t,this.options,r,o,Object.create(this.schemas));return t.id&&!i.schemas[o]&&(i.schemas[o]=t),i};var s=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]$/};s.regexp=s.regex,s.pattern=s.regex,s.ipv4=s["ip-address"],e.isFormat=function(t,e,r){if("string"==typeof t&&void 0!==s[e]){if(s[e]instanceof RegExp)return s[e].test(t);if("function"==typeof s[e])return s[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 l(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 l(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 l(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 o=decodeURIComponent(r.replace(/~0/,"~").replace(/~1/g,"/"));if(!(o in t))return;t=t[o]}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),o=r(4),i=n.ERROR_MESSAGES,a="USER_ID_VALIDATOR";t.exports={validate:function(t){if("string"!=typeof t||""===t)throw new Error(o(i.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/package.json b/package.json index cab70bd06..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", @@ -21,7 +21,7 @@ "dependencies": { "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); + }); }); }); });