From 05048777027a7a36fe85da4a578a457386079cc7 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Mon, 14 Nov 2016 10:53:16 -0800 Subject: [PATCH 1/2] Add global variable export for use in non CommonJS environments. Summary: This is needed for us to set up in Bower and have the SDK pulled in as a snippet. Test Plan: Unit and manual Reviewers: #oasis_team_review Differential Revision: https://phabricator.optimizely.com/D13788 --- CHANGELOG | 7 +++++++ dist/optimizely.min.js | 8 ++++---- index.js | 2 +- package.json | 3 ++- webpack.config.js | 10 ++-------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 130edd43b..0a02621b8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +------------------------------------------------------------------------------- +1.1.0 +------------------------------------------------------------------------------- +* Add global variable name export for use in non CommonJS environments +* Remove redundant lodash core dependency to reduce bundle bloat +------------------------------------------------------------------------------- + ------------------------------------------------------------------------------- 1.0.0 ------------------------------------------------------------------------------- diff --git a/dist/optimizely.min.js b/dist/optimizely.min.js index 2b675781b..90fb6ae6e 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 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(12),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 b(t,e){return t&&Ke(t,e,rr)}function O(t,e){return _(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?_e:u),s||(c=Le.call(e),c=c==le?_e:c);var f=u==_e&&!p(t),l=c==_e&&!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 m=f&&Pe.call(t,"__wrapped__"),y=l&&Pe.call(e,"__wrapped__");if(m||y){var g=m?t.value():t,E=y?e.value():e,v=r(g,E,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 Et(t){if("function"!=typeof t)throw new TypeError(oe);return function(){return!t.apply(this,arguments)}}function _t(t){return gt(2,t)}function It(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 Dt(t)&&t!=+t}function Mt(t){return null===t}function Dt(t){return"number"==typeof t||Ct(t)&&Le.call(t)==Ee}function Ft(t){return Lt(t)&&Le.call(t)==Ie}function Ut(t){return"string"==typeof t||!Je(t)&&Ct(t)&&Le.call(t)==be}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=m(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?E(t,Jt,x):ne}function re(t){return t&&t.length?E(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]",me="[object Error]",ye="[object Function]",ge="[object GeneratorFunction]",Ee="[object Number]",_e="[object Object]",Ie="[object RegExp]",be="[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,Me=Te.propertyIsEnumerable,De=Se.isFinite,Fe=Object.keys,Ue=Math.max;h.prototype=m(l.prototype),h.prototype.constructor=h;var Ge=K(b),Ke=B(),Be=L("length"),qe=String,$e=$(Q),ze=It(function(t,e,r){return z(t,ae|se,e,r)}),He=It(function(t,e){return y(t,1,e)}),Ze=It(function(t,e,r){return y(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=It(function(t){return t.push(ne,d),tr.apply(ne,t)}),rr=w,nr=S,ir=It(function(t,e){return null==t?{}:V(t,T(I(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=Et,l.once=_t,l.pick=ir,l.slice=ot,l.sortBy=yt,l.tap=st,l.thru=ut,l.toArray=Kt,l.values=Ht,l.extend=Qe,Yt(l,l),l.clone=bt,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=Mt,l.isNumber=Dt,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=mt,l.uniqueId=te,l.each=lt,l.first=rt,Yt(l,function(){var t={};return b(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){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="",m=[];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):"",m.push(c[5]?a+f:f+a)}return m.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){function n(t){var e=t.clientEngine;if(e!==u.NODE_CLIENT_ENGINE&&e!==u.JAVASCRIPT_CLIENT_ENGINE&&(t.logger.log(m.INFO,h(y.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(m.INFO,h(y.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(m.INFO,h(y.VALID_DATAFILE,g)))}catch(n){this.isValidInstance=!1,this.logger.log(m.ERROR,n.message),this.errorHandler.handleError(n)}else this.logger.log(m.ERROR,h(v.NO_DATAFILE_SPECIFIED,g)),this.errorHandler.handleError(new Error(h(v.NO_DATAFILE_SPECIFIED,g))),this.isValidInstance=!1}var i=r(1),o=r(13),a=r(14),s=r(16),u=r(5),c=r(18),f=r(161),p=r(20),l=r(171),h=r(4),d=r(172),v=u.ERROR_MESSAGES,m=u.LOG_LEVEL,y=u.LOG_MESSAGES,g="OPTIMIZELY";n.prototype.activate=function(t,e,r){if(!this.isValidInstance)return this.logger.log(m.ERROR,h(y.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(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.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(y.DISPATCH_IMPRESSION_EVENT,g,u.url,JSON.stringify(u.params));this.logger.log(m.DEBUG,f),this.eventDispatcher.dispatchEvent(u).then(function(){var r=h(y.ACTIVATE_USER,g,e,t);this.logger.log(m.INFO,r)}.bind(this));var l=p.getVariationKeyFromId(this.configObj,t,n);return l}catch(d){this.logger.log(m.ERROR,d.message);var o=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.INFO,o),this.errorHandler.handleError(d),null}},n.prototype.track=function(t,e,r,n){if(!this.isValidInstance)return void this.logger.log(m.ERROR,h(y.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(m.WARNING,h(y.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,g,t));var o=this.__getValidExperimentInformationForEvent(t,e,r),a=o.validExperimentKeysForEvent;if(!a.length){var s=h(y.NO_VALID_EXPERIMENTS_FOR_EVENT_TO_TRACK,g,t);return void this.logger.log(m.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(y.DISPATCH_CONVERSION_EVENT,g,l.url,JSON.stringify(l.params));this.logger.log(m.DEBUG,d),this.eventDispatcher.dispatchEvent(l).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);var E=h(y.NOT_TRACKING_USER,g,e);this.logger.log(m.INFO,E),this.errorHandler.handleError(v)}},n.prototype.getVariation=function(t,e,r){if(!this.isValidInstance)return this.logger.log(m.ERROR,h(y.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(m.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(y.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);return void this.logger.log(m.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(y.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);this.logger.log(m.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(m.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(m.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__checkIfExperimentIsRunning=function(t,e){if(!p.isExperimentRunning(this.configObj,t)){var r=h(y.EXPERIMENT_NOT_RUNNING,g,t);return this.logger.log(m.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(y.USER_NOT_IN_EXPERIMENT,g,e,t);return this.logger.log(m.INFO,i),!1}return!0},n.prototype.__notActivatingExperiment=function(t,e){var r=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.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(15);t.exports={evaluate:function(t,e){if(!t||0===t.length)return!0;if(!e)return!1;for(var r=!1,i=0;i=4;)r=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^r,n-=4,++o;switch(n){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i^=255&t.charCodeAt(o),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)}return i^=i>>>13,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>15,i>>>0}function r(t,e){var r,n,i,o,a,s,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(1),a=r(5),s=r(4),u=r(19),c=r(160),f=r(20);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(1),i=r(20),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(1),i=r(21),o=r(130),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(22),i=n(function(t,e,r){t[r]=e});t.exports=i},function(t,e,r){function n(t,e){return function(r,n){var u=s(r)?i:o,c=e?e():{};return u(r,t,a(n),c)}}var i=r(23),o=r(24),a=r(49),s=r(44);t.exports=n},function(t,e){function r(t,e,r,n){for(var i=-1,o=t?t.length:0;++i-1&&t%1==0&&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(44),o=r(43),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(56);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(56);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(53);t.exports=n},function(t,e){function r(t){return this.__data__["delete"](t)}t.exports=r},function(t,e){function r(t){return this.__data__.get(t)}t.exports=r},function(t,e){function r(t){return this.__data__.has(t)}t.exports=r},function(t,e,r){function n(t,e){var r=this.__data__;return r instanceof i&&r.__data__.length==a&&(r=this.__data__=new o(r.__data__)),r.set(t,e),this}var i=r(53),o=r(66),a=200;t.exports=n},function(t,e,r){function n(t){var e=-1,r=t?t.length:0;for(this.clear();++ep))return!1;var h=c.get(t);if(h)return h==e;var d=-1,v=!0,m=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(165);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"],m=["{","}","|","\\","^","`"].concat(v),y=["'"].concat(m),g=["%","/","?",";","#"].concat(y),E=["/","?","#"],_=255,I=/^[a-z0-9A-Z_-]{0,63}$/,b=/^([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(166);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;c127?"x":w[R];if(!S.match(I)){var P=m.slice(0,c),V=m.slice(c+1),L=w.match(b);L&&(P.push(L[1]),V.unshift(L[2])),V.length&&(n="/"+V.join(".")+n),this.hostname=P.join(".");break}}}if(this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),!v){for(var C=this.hostname.split("."),k=[],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(!d.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var y=d.slice(-1)[0],g=(r.host||t.host)&&("."===y||".."===y)||""===y,E=0,_=d.length;_>=0;_--)y=d[_],"."==y?d.splice(_,1):".."===y?(d.splice(_,1),E++):E&&(d.splice(_,1),E--);if(!l&&!h)for(;E--;E)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),g&&"/"!==d.join("/").substr(-1)&&d.push("");var I=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(v){r.hostname=r.host=I?"":d.length?d.shift():"";var m=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");m&&(r.auth=m.shift(),r.host=r.hostname=m.shift())}return l=l||r.host&&d.length,l&&!I&&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:I}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+=I)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=[],m=t.length,y=0,g=N,E=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=m&&a("invalid-input"),c=p(t.charCodeAt(i++)),(c>=I||c>L((_-y)/s))&&a("overflow"),y+=c*s,l=u<=E?b:u>=E+O?O:u-E,!(cL(_/d)&&a("overflow"),s*=d;e=v.length+1,E=h(y-o,e,0==o),L(y/e)>_-g&&a("overflow"),g+=L(y/e),y%=e,v.splice(y++,0,g)}return f(v)}function v(t){var e,r,n,i,o,s,u,f,p,d,v,m,y,g,E,x=[];for(t=c(t),m=t.length,e=N,r=0,o=j,s=0;s=e&&vL((_-r)/y)&&a("overflow"),r+=(u-e)*y,e=u,s=0;s_&&a("overflow"),v==e){for(f=r,p=I;d=p<=o?b:p>=o+O?O:p-o,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=I-b,L=Math.floor,C=String.fromCharCode;E={version:"1.3.2",ucs2:{decode:c,encode:f},decode:d,encode:v,toASCII:y,toUnicode:m},n=function(){return E}.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(167),e.encode=e.stringify=r(168)},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(164),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 +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.optimizelyClient=e():t.optimizelyClient=e()}(this,function(){return 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(12),f="1.1.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 b(t,e){return t&&Ke(t,e,rr)}function O(t,e){return _(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?_e:u),s||(c=Le.call(e),c=c==le?_e:c);var f=u==_e&&!p(t),l=c==_e&&!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 m=f&&Pe.call(t,"__wrapped__"),y=l&&Pe.call(e,"__wrapped__");if(m||y){var g=m?t.value():t,E=y?e.value():e,v=r(g,E,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 Et(t){if("function"!=typeof t)throw new TypeError(oe);return function(){return!t.apply(this,arguments)}}function _t(t){return gt(2,t)}function It(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 Dt(t)&&t!=+t}function Mt(t){return null===t}function Dt(t){return"number"==typeof t||Ct(t)&&Le.call(t)==Ee}function Ft(t){return Lt(t)&&Le.call(t)==Ie}function Ut(t){return"string"==typeof t||!Je(t)&&Ct(t)&&Le.call(t)==be}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=m(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?E(t,Jt,x):ne}function re(t){return t&&t.length?E(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]",me="[object Error]",ye="[object Function]",ge="[object GeneratorFunction]",Ee="[object Number]",_e="[object Object]",Ie="[object RegExp]",be="[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,Me=Te.propertyIsEnumerable,De=Se.isFinite,Fe=Object.keys,Ue=Math.max;h.prototype=m(l.prototype),h.prototype.constructor=h;var Ge=K(b),Ke=B(),Be=L("length"),qe=String,$e=$(Q),ze=It(function(t,e,r){return z(t,ae|se,e,r)}),He=It(function(t,e){return y(t,1,e)}),Ze=It(function(t,e,r){return y(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=It(function(t){return t.push(ne,d),tr.apply(ne,t)}),rr=w,nr=S,ir=It(function(t,e){return null==t?{}:V(t,T(I(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=Et,l.once=_t,l.pick=ir,l.slice=ot,l.sortBy=yt,l.tap=st,l.thru=ut,l.toArray=Kt,l.values=Ht,l.extend=Qe,Yt(l,l),l.clone=bt,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=Mt,l.isNumber=Dt,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=mt,l.uniqueId=te,l.each=lt,l.first=rt,Yt(l,function(){var t={};return b(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){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="",m=[];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):"",m.push(c[5]?a+f:f+a)}return m.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){function n(t){var e=t.clientEngine;if(e!==u.NODE_CLIENT_ENGINE&&e!==u.JAVASCRIPT_CLIENT_ENGINE&&(t.logger.log(m.INFO,h(y.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(m.INFO,h(y.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(m.INFO,h(y.VALID_DATAFILE,g)))}catch(n){this.isValidInstance=!1,this.logger.log(m.ERROR,n.message),this.errorHandler.handleError(n)}else this.logger.log(m.ERROR,h(v.NO_DATAFILE_SPECIFIED,g)),this.errorHandler.handleError(new Error(h(v.NO_DATAFILE_SPECIFIED,g))),this.isValidInstance=!1}var i=r(1),o=r(13),a=r(14),s=r(16),u=r(5),c=r(18),f=r(161),p=r(20),l=r(171),h=r(4),d=r(172),v=u.ERROR_MESSAGES,m=u.LOG_LEVEL,y=u.LOG_MESSAGES,g="OPTIMIZELY";n.prototype.activate=function(t,e,r){if(!this.isValidInstance)return this.logger.log(m.ERROR,h(y.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(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.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(y.DISPATCH_IMPRESSION_EVENT,g,u.url,JSON.stringify(u.params));this.logger.log(m.DEBUG,f),this.eventDispatcher.dispatchEvent(u).then(function(){var r=h(y.ACTIVATE_USER,g,e,t);this.logger.log(m.INFO,r)}.bind(this));var l=p.getVariationKeyFromId(this.configObj,t,n);return l}catch(d){this.logger.log(m.ERROR,d.message);var o=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.INFO,o),this.errorHandler.handleError(d),null}},n.prototype.track=function(t,e,r,n){if(!this.isValidInstance)return void this.logger.log(m.ERROR,h(y.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(m.WARNING,h(y.EVENT_NOT_ASSOCIATED_WITH_EXPERIMENTS,g,t));var o=this.__getValidExperimentInformationForEvent(t,e,r),a=o.validExperimentKeysForEvent; +if(!a.length){var s=h(y.NO_VALID_EXPERIMENTS_FOR_EVENT_TO_TRACK,g,t);return void this.logger.log(m.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(y.DISPATCH_CONVERSION_EVENT,g,l.url,JSON.stringify(l.params));this.logger.log(m.DEBUG,d),this.eventDispatcher.dispatchEvent(l).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);var E=h(y.NOT_TRACKING_USER,g,e);this.logger.log(m.INFO,E),this.errorHandler.handleError(v)}},n.prototype.getVariation=function(t,e,r){if(!this.isValidInstance)return this.logger.log(m.ERROR,h(y.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(m.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(y.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);return void this.logger.log(m.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(y.NOT_TRACKING_USER_FOR_EXPERIMENT,g,e,a);this.logger.log(m.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(m.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(m.ERROR,r.message),this.errorHandler.handleError(r),!1}},n.prototype.__checkIfExperimentIsRunning=function(t,e){if(!p.isExperimentRunning(this.configObj,t)){var r=h(y.EXPERIMENT_NOT_RUNNING,g,t);return this.logger.log(m.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(y.USER_NOT_IN_EXPERIMENT,g,e,t);return this.logger.log(m.INFO,i),!1}return!0},n.prototype.__notActivatingExperiment=function(t,e){var r=h(y.NOT_ACTIVATING_USER,g,e,t);return this.logger.log(m.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(15);t.exports={evaluate:function(t,e){if(!t||0===t.length)return!0;if(!e)return!1;for(var r=!1,i=0;i=4;)r=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),r^=r>>>24,r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^r,n-=4,++o;switch(n){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i^=255&t.charCodeAt(o),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)}return i^=i>>>13,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>15,i>>>0}function r(t,e){var r,n,i,o,a,s,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(1),a=r(5),s=r(4),u=r(19),c=r(160),f=r(20);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(1),i=r(20),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(1),i=r(21),o=r(130),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(22),i=n(function(t,e,r){t[r]=e});t.exports=i},function(t,e,r){function n(t,e){return function(r,n){var u=s(r)?i:o,c=e?e():{};return u(r,t,a(n),c)}}var i=r(23),o=r(24),a=r(49),s=r(44);t.exports=n},function(t,e){function r(t,e,r,n){for(var i=-1,o=t?t.length:0;++i-1&&t%1==0&&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(44),o=r(43),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(56);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(56);t.exports=n},function(t,e,r){function n(){this.__data__=new i}var i=r(53);t.exports=n},function(t,e){function r(t){return this.__data__["delete"](t)}t.exports=r},function(t,e){function r(t){return this.__data__.get(t)}t.exports=r},function(t,e){function r(t){return this.__data__.has(t)}t.exports=r},function(t,e,r){function n(t,e){var r=this.__data__;return r instanceof i&&r.__data__.length==a&&(r=this.__data__=new o(r.__data__)),r.set(t,e),this}var i=r(53),o=r(66),a=200;t.exports=n},function(t,e,r){function n(t){var e=-1,r=t?t.length:0;for(this.clear();++ep))return!1;var h=c.get(t);if(h)return h==e;var d=-1,v=!0,m=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(165);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"],m=["{","}","|","\\","^","`"].concat(v),y=["'"].concat(m),g=["%","/","?",";","#"].concat(y),E=["/","?","#"],_=255,I=/^[a-z0-9A-Z_-]{0,63}$/,b=/^([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(166);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;c127?"x":w[R];if(!S.match(I)){var P=m.slice(0,c),V=m.slice(c+1),L=w.match(b);L&&(P.push(L[1]),V.unshift(L[2])),V.length&&(n="/"+V.join(".")+n),this.hostname=P.join(".");break}}}if(this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),!v){for(var C=this.hostname.split("."),k=[],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(!d.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var y=d.slice(-1)[0],g=(r.host||t.host)&&("."===y||".."===y)||""===y,E=0,_=d.length;_>=0;_--)y=d[_],"."==y?d.splice(_,1):".."===y?(d.splice(_,1),E++):E&&(d.splice(_,1),E--);if(!l&&!h)for(;E--;E)d.unshift("..");!l||""===d[0]||d[0]&&"/"===d[0].charAt(0)||d.unshift(""),g&&"/"!==d.join("/").substr(-1)&&d.push("");var I=""===d[0]||d[0]&&"/"===d[0].charAt(0);if(v){r.hostname=r.host=I?"":d.length?d.shift():"";var m=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");m&&(r.auth=m.shift(),r.host=r.hostname=m.shift())}return l=l||r.host&&d.length,l&&!I&&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:I}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+=I)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=[],m=t.length,y=0,g=N,E=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=m&&a("invalid-input"),c=p(t.charCodeAt(i++)),(c>=I||c>L((_-y)/s))&&a("overflow"),y+=c*s,l=u<=E?b:u>=E+O?O:u-E,!(cL(_/d)&&a("overflow"),s*=d;e=v.length+1,E=h(y-o,e,0==o),L(y/e)>_-g&&a("overflow"),g+=L(y/e),y%=e,v.splice(y++,0,g)}return f(v)}function v(t){var e,r,n,i,o,s,u,f,p,d,v,m,y,g,E,x=[];for(t=c(t),m=t.length,e=N,r=0,o=j,s=0;s=e&&vL((_-r)/y)&&a("overflow"),r+=(u-e)*y,e=u,s=0;s_&&a("overflow"),v==e){for(f=r,p=I;d=p<=o?b:p>=o+O?O:p-o,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=I-b,L=Math.floor,C=String.fromCharCode;E={version:"1.3.2",ucs2:{decode:c,encode:f},decode:d,encode:v,toASCII:y,toUnicode:m},n=function(){return E}.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(167),e.encode=e.stringify=r(168)},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(164),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 3a76b5d3c..0f8528c11 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ 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 JAVASCRIPT_CLIENT_VERSION = '1.1.0'; var MODULE_NAME = 'INDEX'; /** diff --git a/package.json b/package.json index 11fe97461..d5e58d7a0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "optimizely-client-sdk", - "version": "1.0.0", + "version": "1.1.0", "description": "JavaScript SDK for Optimizely X Full Stack", "main": "index.js", "scripts": { "test": "./node_modules/.bin/mocha ./tests.js", + "build": "webpack index.js dist/optimizely.min.js", "lint": "eslint lib/**" }, "repository": { diff --git a/webpack.config.js b/webpack.config.js index 676841cfb..a5170790f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,6 @@ var webpack = require('webpack'); module.exports = { - module: { - loaders: [ - { test: /\.json/, loader: 'json-loader' }, - ], - }, plugins: [ new webpack.optimize.UglifyJsPlugin({ compress: { @@ -17,9 +12,8 @@ module.exports = { }), new webpack.optimize.DedupePlugin(), ], - entry: './index.js', output: { - filename: 'optimizely.min.js', - path: './dist' + library: 'optimizelyClient', + libraryTarget: 'umd' }, }; From e1428203591101670865a59251efdcb447302592 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Mon, 14 Nov 2016 11:00:50 -0800 Subject: [PATCH 2/2] Add new instructions to readme. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b92f188a0..9b12ef8e8 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ The SDK is available through [npm](https://npmjs.com/package/optimizely-client-s npm install optimizely-client-sdk --save ``` +Or to use in a non CommonJS fashion: + +1. Pull in `dist/optimizely.min.js` as a `