!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).TestTrack=e()}(this,function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var r=e(function(t,e){var r;r=function(){function t(){for(var t=0,e={};t1){if("number"==typeof(o=t({path:"/"},n.defaults,o)).expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*o.expires),o.expires=a}o.expires=o.expires?o.expires.toUTCString():"";try{s=JSON.stringify(i),/^[\{\[]/.test(s)&&(i=s)}catch(t){}i=r.write?r.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=(e=(e=encodeURIComponent(String(e))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var u="";for(var c in o)o[c]&&(u+="; "+c,!0!==o[c]&&(u+="="+o[c]));return document.cookie=e+"="+i+u}e||(s={});for(var f=document.cookie?document.cookie.split("; "):[],p=/(%[0-9A-Z]{2})+/g,l=0;l1;){var e=t.pop(),r=e.obj[e.prop];if(o(r)){for(var n=[],i=0;i=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?i+=n.charAt(o):a<128?i+=s[a]:a<2048?i+=s[192|a>>6]+s[128|63&a]:a<55296||a>=57344?i+=s[224|a>>12]+s[128|a>>6&63]+s[128|63&a]:(o+=1,a=65536+((1023&a)<<10|1023&n.charCodeAt(o)),i+=s[240|a>>18]+s[128|a>>12&63]+s[128|a>>6&63]+s[128|63&a])}return i},isBuffer:function(t){return!(!t||"object"!=typeof t||!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t)))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},merge:function t(e,r,n){if(!r)return e;if("object"!=typeof r){if(o(e))e.push(r);else{if(!e||"object"!=typeof e)return[e,r];(n&&(n.plainObjects||n.allowPrototypes)||!i.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(r);var s=e;return o(e)&&!o(r)&&(s=a(e,n)),o(e)&&o(r)?(r.forEach(function(r,o){if(i.call(e,o)){var s=e[o];s&&"object"==typeof s&&r&&"object"==typeof r?e[o]=t(s,r,n):e.push(r)}else e[o]=r}),e):Object.keys(r).reduce(function(e,o){var s=r[o];return i.call(e,o)?e[o]=t(e[o],s,n):e[o]=s,e},s)}},c=String.prototype.replace,f=/%20/g,p={RFC1738:"RFC1738",RFC3986:"RFC3986"},l=u.assign({default:p.RFC3986,formatters:{RFC1738:function(t){return c.call(t,f,"+")},RFC3986:function(t){return String(t)}}},p),d=Object.prototype.hasOwnProperty,h={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},g=Array.isArray,m=Array.prototype.push,y=function(t,e){m.apply(t,g(e)?e:[e])},v=Date.prototype.toISOString,w=l.default,_={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:u.encode,encodeValuesOnly:!1,format:w,formatter:l.formatters[w],indices:!1,serializeDate:function(t){return v.call(t)},skipNulls:!1,strictNullHandling:!1},b=function t(e,r,n,i,o,s,a,c,f,p,l,d,h){var m,v=e;if("function"==typeof a?v=a(r,v):v instanceof Date?v=p(v):"comma"===n&&g(v)&&(v=v.join(",")),null===v){if(i)return s&&!d?s(r,_.encoder,h,"key"):r;v=""}if("string"==typeof(m=v)||"number"==typeof m||"boolean"==typeof m||"symbol"==typeof m||"bigint"==typeof m||u.isBuffer(v))return s?[l(d?r:s(r,_.encoder,h,"key"))+"="+l(s(v,_.encoder,h,"value"))]:[l(r)+"="+l(String(v))];var w,b=[];if(void 0===v)return b;if(g(a))w=a;else{var C=Object.keys(v);w=c?C.sort(c):C}for(var A=0;A0?p+f:""}),A=function(t,e){return function(){for(var r=new Array(arguments.length),n=0;n=0)return;u[i]="set-cookie"===i?(u[i]?u[i]:[]).concat([s]):u[i]?u[i]+", "+s:s}}),u):u):null,f={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:c,config:t,request:o};!function(t,e,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?e(B("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,f),o=null}},o.onabort=function(){o&&(r(B("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(B("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(B(e,t,"ECONNABORTED",o)),o=null},V.isStandardBrowserEnv()){var p=(t.withCredentials||q(f))&&t.xsrfCookieName?F.read(t.xsrfCookieName):void 0;p&&(i[t.xsrfHeaderName]=p)}if("setRequestHeader"in o&&V.forEach(i,function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete i[e]:o.setRequestHeader(e,t)}),V.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(t){o&&(o.abort(),r(t),o=null)}),n||(n=null),o.send(n)})},M={"Content-Type":"application/x-www-form-urlencoded"};function J(t,e){!V.isUndefined(t)&&V.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var $,W={adapter:("undefined"!=typeof XMLHttpRequest?$=z:"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)&&($=z),$),transformRequest:[function(t,e){return I(e,"Accept"),I(e,"Content-Type"),V.isFormData(t)||V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)?t:V.isArrayBufferView(t)?t.buffer:V.isURLSearchParams(t)?(J(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):V.isObject(t)?(J(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};W.headers={common:{Accept:"application/json, text/plain, */*"}},V.forEach(["delete","get","head"],function(t){W.headers[t]={}}),V.forEach(["post","put","patch"],function(t){W.headers[t]=V.merge(M)});var Q=W;function X(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var G=function(t){return X(t),t.headers=t.headers||{},t.data=L(t.data,t.headers,t.transformRequest),t.headers=V.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),V.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||Q.adapter)(t).then(function(e){return X(t),e.data=L(e.data,e.headers,t.transformResponse),e},function(e){return D(e)||(X(t),e&&e.response&&(e.response.data=L(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})},Z=function(t,e){e=e||{};var r={},n=["url","method","data"],i=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(t,e){return V.isPlainObject(t)&&V.isPlainObject(e)?V.merge(t,e):V.isPlainObject(e)?V.merge({},e):V.isArray(e)?e.slice():e}function u(n){V.isUndefined(e[n])?V.isUndefined(t[n])||(r[n]=a(void 0,t[n])):r[n]=a(t[n],e[n])}V.forEach(n,function(t){V.isUndefined(e[t])||(r[t]=a(void 0,e[t]))}),V.forEach(i,u),V.forEach(o,function(n){V.isUndefined(e[n])?V.isUndefined(t[n])||(r[n]=a(void 0,t[n])):r[n]=a(void 0,e[n])}),V.forEach(s,function(n){n in e?r[n]=a(t[n],e[n]):n in t&&(r[n]=a(void 0,t[n]))});var c=n.concat(i).concat(o).concat(s),f=Object.keys(t).concat(Object.keys(e)).filter(function(t){return-1===c.indexOf(t)});return V.forEach(f,u),r};function K(t){this.defaults=t,this.interceptors={request:new P,response:new P}}K.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Z(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[G,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)r=r.then(e.shift(),e.shift());return r},K.prototype.getUri=function(t){return t=Z(this.defaults,t),U(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},V.forEach(["delete","get","head","options"],function(t){K.prototype[t]=function(e,r){return this.request(Z(r||{},{method:t,url:e,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){K.prototype[t]=function(e,r,n){return this.request(Z(n||{},{method:t,url:e,data:r}))}});var Y=K;function tt(t){this.message=t}tt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},tt.prototype.__CANCEL__=!0;var et=tt;function rt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var r=this;t(function(t){r.reason||(r.reason=new et(t),e(r.reason))})}rt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},rt.source=function(){var t;return{token:new rt(function(e){t=e}),cancel:t}};var nt=rt;function it(t){var e=new Y(t),r=A(Y.prototype.request,e);return V.extend(r,Y.prototype,e),V.extend(r,e),r}var ot=it(Q);ot.Axios=Y,ot.create=function(t){return it(Z(ot.defaults,t))},ot.Cancel=et,ot.CancelToken=nt,ot.isCancel=D,ot.all=function(t){return Promise.all(t)},ot.spread=function(t){return function(e){return t.apply(null,e)}},ot.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var st=ot,at=ot;st.default=at;var ut=st;for(var ct={atob:function(t){if((t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(t=t.replace(/==?$/,"")),t.length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let e="",r=0,n=0;for(let o=0;o>16),e+=String.fromCharCode((65280&r)>>8),e+=String.fromCharCode(255&r),r=n=0);var i;return 12===n?(r>>=4,e+=String.fromCharCode(r)):18===n&&(r>>=2,e+=String.fromCharCode((65280&r)>>8),e+=String.fromCharCode(255&r)),e},btoa:function(t){let e;for(t=`${t}`,e=0;e255)return null;let r="";for(e=0;e>2,i[1]=(3&t.charCodeAt(e))<<4,t.length>e+1&&(i[1]|=t.charCodeAt(e+1)>>4,i[2]=(15&t.charCodeAt(e+1))<<2),t.length>e+2&&(i[2]|=t.charCodeAt(e+2)>>6,i[3]=63&t.charCodeAt(e+2));for(let t=0;t2&&this._visitor.logError("A/B for "+this._splitName+" configures split with more than 2 variants"),{true:this._getTrueVariant(),false:this._getFalseVariant()}},t.prototype._getTrueVariant=function(){return this._trueVariant||"true"},t.prototype._getFalseVariant=function(){var t=this._getNonTrueVariants();return Array.isArray(t)&&0!==t.length?t.sort()[0]:"false"},t.prototype._getNonTrueVariants=function(){var t=this._getSplitVariants();if(t){var e=this._getTrueVariant(),r=t.indexOf(e.toString());return-1!==r&&t.splice(r,1),t}return null},t.prototype._getSplit=function(){return this._splitRegistry.getSplit(this._splitName)},t.prototype._getSplitVariants=function(){return this._getSplit()&&this._getSplit().getVariants()},t}(),Ct=function(){function t(t){var e=t.visitor,r=t.assignment;if(this._visitor=e,this._assignment=r,!this._visitor)throw new Error("must provide visitor");if(!this._assignment)throw new Error("must provide assignment")}return t.prototype.send=function(){var t=this,e=this._persistAssignment(),r=new Promise(function(e){t._visitor.analytics.trackAssignment(t._visitor.getId(),t._assignment,function(r){return t._persistAssignment(r?"success":"failure").then(e)})});return Promise.all([e,r])},t.prototype._persistAssignment=function(t){var e=this;return wt.post("/v1/assignment_event",C({visitor_id:this._visitor.getId(),split_name:this._assignment.getSplitName(),context:this._assignment.getContext(),mixpanel_result:t})).catch(function(t){if(t.response){var r=t.response,n=r.status,i=r.statusText,o=r.data;e._visitor.logError("test_track persistAssignment response error: "+n+", "+i+", "+o)}else e._visitor.logError("test_track persistAssignment other error: "+t)})},t}(),At=function(){function t(t){if(this.visitorId=t.visitorId,this.identifierType=t.identifierType,this.value=t.value,!this.visitorId)throw new Error("must provide visitorId");if(!this.identifierType)throw new Error("must provide identifierType");if(!this.value)throw new Error("must provide value")}return t.prototype.save=function(){return wt.post("/v1/identifier",C({identifier_type:this.identifierType,value:this.value,visitor_id:this.visitorId})).then(function(t){var e=t.data;return new Ut({id:e.visitor.id,assignments:n.fromJsonArray(e.visitor.assignments)})})},t}(),St=function(){function t(){}return t.prototype.trackAssignment=function(t,e,r){var n={TTVisitorID:t,SplitName:e.getSplitName(),SplitVariant:e.getVariant(),SplitContext:e.getContext()};window.mixpanel&&window.mixpanel.track("SplitAssigned",n,r)},t.prototype.identify=function(t){window.mixpanel&&window.mixpanel.identify(t)},t.prototype.alias=function(t){window.mixpanel&&window.mixpanel.alias(t)},t}(),Et=e(function(t){var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var r=new Uint8Array(16);t.exports=function(){return e(r),r}}else{var n=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),n[e]=t>>>((3&e)<<3)&255;return n}}}),xt=[],Nt=0;Nt<256;++Nt)xt[Nt]=(Nt+256).toString(16).substr(1);var Ot=function(t,e){var r=e||0,n=xt;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")};var jt=function(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Et)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var o=0;o<16;++o)e[n+o]=i[o];return e||Ot(i)},Rt=e(function(e){!function(t){function r(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function n(t,e,n,i,o,s){return r((a=r(r(e,t),r(i,s)))<<(u=o)|a>>>32-u,n);var a,u}function i(t,e,r,i,o,s,a){return n(e&r|~e&i,t,e,o,s,a)}function o(t,e,r,i,o,s,a){return n(e&i|r&~i,t,e,o,s,a)}function s(t,e,r,i,o,s,a){return n(e^r^i,t,e,o,s,a)}function a(t,e,r,i,o,s,a){return n(r^(e|~i),t,e,o,s,a)}function u(t,e){var n,u,c,f,p;t[e>>5]|=128<>>9<<4)]=e;var l=1732584193,d=-271733879,h=-1732584194,g=271733878;for(n=0;n>5]>>>e%32&255);return r}function f(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e>5]|=(255&t.charCodeAt(e/8))<>>4&15)+"0123456789abcdef".charAt(15&e);return n}function l(t){return unescape(encodeURIComponent(t))}function d(t){return function(t){return c(u(f(t),8*t.length))}(l(t))}function h(t,e){return function(t,e){var r,n,i=f(t),o=[],s=[];for(o[15]=s[15]=void 0,i.length>16&&(i=u(i,8*t.length)),r=0;r<16;r+=1)o[r]=909522486^i[r],s[r]=1549556828^i[r];return n=u(o.concat(f(e)),512+8*e.length),c(u(s.concat(n),640))}(l(t),l(e))}function g(t,e,r){return e?r?h(e,t):p(h(e,t)):r?d(t):p(d(t))}e.exports?e.exports=g:t.md5=g}(t)}),Vt=function(){function t(t){if(this.visitor=t.visitor,this.splitName=t.splitName,!this.visitor)throw new Error("must provide visitor");if(!this.splitName)throw new Error("must provide splitName")}return t.prototype.getVariant=function(){if(!vt.getSplitRegistry().isLoaded())return null;for(var t=0,e=this.getAssignmentBucket(),r=this.getWeighting(),n=this.getSortedVariants(),i=0;ie)return o}throw new Error("Assignment bucket out of range. "+e+" unmatched in "+this.splitName+": "+JSON.stringify(r))},t.prototype.getSplitVisitorHash=function(){return Rt(this.splitName+this.visitor.getId())},t.prototype.getHashFixnum=function(){return parseInt(this.getSplitVisitorHash().substr(0,8),16)},t.prototype.getAssignmentBucket=function(){return this.getHashFixnum()%100},t.prototype.getSortedVariants=function(){return this.getVariants().sort()},t.prototype.getVariants=function(){return Object.getOwnPropertyNames(this.getWeighting())},t.prototype.getWeighting=function(){var t=vt.getSplitRegistry().getSplit(this.splitName);if(!t){var e='Unknown split: "'+this.splitName+'"';throw this.visitor.logError(e),new Error(e)}return t.getWeighting()},t}(),kt=function(){function t(t){if(!t.assignment)throw new Error("must provide assignment");if(!t.visitor)throw new Error("must provide visitor");this._assignment=t.assignment,this._visitor=t.visitor,this._splitRegistry=vt.getSplitRegistry(),this._variantHandlers={}}return t.prototype.when=function(){for(var t=this,e=[],r=0;r0){var e=t.join(", ").replace(/, (.+)$/," and $1");this._visitor.logError("does not configure variants "+e)}}},t.prototype._getSplit=function(){return this._splitRegistry.getSplit(this._assignment.getSplitName())},t.prototype._getVariants=function(){return Object.getOwnPropertyNames(this._variantHandlers)},t.prototype._getMissingVariants=function(){var t=this._getVariants();return this._getSplit().getVariants().filter(function(e){return!t.includes(e)})},t}(),Ut=function(){function t(t){var e=t.id,r=t.assignments,n=t.ttOffline;if(this._id=e,this._assignments=r,this._ttOffline=n,!this._id)throw new Error("must provide id");if(!this._assignments)throw new Error("must provide assignments");this._errorLogger=function(t){window.console.error(t)},this.analytics=new St}return t.loadVisitor=function(e){if(e){var r=vt.getAssignments();return r?Promise.resolve(new t({id:e,assignments:r,ttOffline:!1})):wt.get("/v1/visitors/"+e,{timeout:5e3}).then(function(e){var r=e.data;return new t({id:r.id,assignments:n.fromJsonArray(r.assignments),ttOffline:!1})}).catch(function(){return new t({id:e,assignments:[],ttOffline:!0})})}return Promise.resolve(new t({id:jt(),assignments:[],ttOffline:!1}))},t.prototype.getId=function(){return this._id},t.prototype.getAssignmentRegistry=function(){return this._assignmentRegistry||(this._assignmentRegistry=this._assignments.reduce(function(t,e){var r;return lt(lt({},t),((r={})[e.getSplitName()]=e,r))},{})),this._assignmentRegistry},t.prototype.vary=function(t,e){if("object"!=typeof e.variants)throw new Error("must provide variants object to `vary` for "+t);if(!e.context)throw new Error("must provide context to `vary` for "+t);if(!e.defaultVariant&&!1!==e.defaultVariant)throw new Error("must provide defaultVariant to `vary` for "+t);var r=e.defaultVariant.toString(),n=e.variants,i=e.context;if(!n.hasOwnProperty(r))throw new Error("defaultVariant: "+r+" must be represented in variants object");var o=this._getAssignmentFor(t,i),s=new kt({assignment:o,visitor:this});for(var a in n)n.hasOwnProperty(a)&&(a===r?s.default(a,n[a]):s.when(a,n[a]));s.run(),s.isDefaulted()&&(o.setVariant(s.getDefaultVariant()),o.setUnsynced(!0),o.setContext(i)),this.notifyUnsyncedAssignments()},t.prototype.ab=function(t,e){var r=new bt({splitName:t,trueVariant:e.trueVariant,visitor:this}).getVariants(),n={};n[r.true.toString()]=function(){e.callback(!0)},n[r.false.toString()]=function(){e.callback(!1)},this.vary(t,{context:e.context,variants:n,defaultVariant:r.false})},t.prototype.setErrorLogger=function(t){if("function"!=typeof t)throw new Error("must provide function for errorLogger");this._errorLogger=t},t.prototype.logError=function(t){this._errorLogger.call(null,t)},t.prototype.linkIdentifier=function(t,e){var r=this;return new At({identifierType:t,value:e,visitorId:this.getId()}).save().then(function(t){r._merge(t),r.notifyUnsyncedAssignments()})},t.prototype.setAnalytics=function(t){if("object"!=typeof t)throw new Error("must provide object for setAnalytics");this.analytics=t},t.prototype.notifyUnsyncedAssignments=function(){this._getUnsyncedAssignments().forEach(this._notify.bind(this))},t.prototype._getUnsyncedAssignments=function(){var t=this.getAssignmentRegistry();return Object.keys(t).reduce(function(e,r){var n=t[r];return n.isUnsynced()&&e.push(n),e},[])},t.prototype._merge=function(t){var e=this.getAssignmentRegistry(),r=t.getAssignmentRegistry();this._id=t.getId(),Object.assign(e,r)},t.prototype._getAssignmentFor=function(t,e){return this.getAssignmentRegistry()[t]||this._generateAssignmentFor(t,e)},t.prototype._generateAssignmentFor=function(t,e){var r=new Vt({visitor:this,splitName:t}).getVariant();r||(this._ttOffline=!0);var i=new n({splitName:t,variant:r,context:e,isUnsynced:!0});return this._assignments.push(i),this._assignmentRegistry=null,i},t.prototype._notify=function(t){try{if(this._ttOffline)return;new Ct({visitor:this,assignment:t}).send(),t.setUnsynced(!1)}catch(t){this.logError("test_track notify error: "+t)}},t}(),Tt=null,Pt=(new(function(){function t(){this._visitorLoaded=new Promise(function(t){return Tt=t})}return t.prototype.initialize=function(t){var e=r.get(vt.getCookieName());return Ut.loadVisitor(e).then(function(e){t&&t.analytics&&e.setAnalytics(t.analytics),t&&t.errorLogger&&e.setErrorLogger(t.errorLogger),t&&"function"==typeof t.onVisitorLoaded&&t.onVisitorLoaded.call(null,e),e.notifyUnsyncedAssignments(),Tt&&Tt(e)}),this._setCookie(),this._visitorLoaded},t.prototype.vary=function(t,e){return this._visitorLoaded.then(function(r){r.vary(t,e)})},t.prototype.ab=function(t,e){return this._visitorLoaded.then(function(r){r.ab(t,e)})},t.prototype.logIn=function(t,e){var r=this;return this._visitorLoaded.then(function(n){return n.linkIdentifier(t,e).then(function(){r._setCookie(),n.analytics.identify(n.getId())})})},t.prototype.signUp=function(t,e){var r=this;return this._visitorLoaded.then(function(n){return n.linkIdentifier(t,e).then(function(){r._setCookie(),n.analytics.alias(n.getId())})})},t.prototype._setCookie=function(){return this._visitorLoaded.then(function(t){r.set(vt.getCookieName(),t.getId(),{expires:365,path:"/",domain:vt.getCookieDomain()})})},t.prototype.getPublicAPI=function(){var t=this;return{vary:this.vary.bind(this),ab:this.ab.bind(this),logIn:this.logIn.bind(this),signUp:this.signUp.bind(this),initialize:this.initialize.bind(this),_crx:{loadInfo:function(){return t._visitorLoaded.then(function(t){var e={};for(var r in t.getAssignmentRegistry())e[r]=t.getAssignmentRegistry()[r].getVariant();return{visitorId:t.getId(),splitRegistry:vt.getSplitRegistry().asV1Hash(),assignmentRegistry:e}})},persistAssignment:function(e,r,i,o){return t._visitorLoaded.then(function(t){return new _t({visitor:t,username:i,password:o,assignment:new n({splitName:e,variant:r,context:"chrome_extension",isUnsynced:!0})}).persistAssignment()})}}}},t}())).getPublicAPI(),Lt=function(){window.dispatchEvent(new CustomEvent("tt:lib:loaded",{detail:{TestTrack:Pt}}))},Dt=function(){document.body.classList.add("_tt");try{window.dispatchEvent(new CustomEvent("tt:class:added"))}catch(t){}};try{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Dt):Dt(),Lt(),window.addEventListener("tt:listener:ready",Lt)}catch(t){}return Pt});