Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hackler/sdk-core

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hackler/sdk-core - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/internal/evaluation/target/OverrideResolver.d.ts

2

lib/index.es.min.js

@@ -1,2 +0,2 @@

var t={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},e=function(){function e(){}return e.setLogLevel=function(e){void 0===e&&(e=t.INFO),this.logLevel=e},e._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},e.logLevel=t.INFO,e.log={error:function(r){e.logLevel>=t.ERROR&&e._log("ERROR",r)},warn:function(r){e.logLevel>=t.WARN&&e._log("WARN",r)},info:function(r){e.logLevel>=t.INFO&&e._log("INFO",r)},debug:function(r){e.logLevel>=t.DEBUG&&e._log("DEBUG",r)}},e}(),r=3e3,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};function u(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var c=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),f=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),p=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),h=function(){function t(t,e,r,n,o,i,u,s,a,c){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.overrides=i,this.targetAudiences=u,this.targetRules=s,this.defaultRule=a,this._winnerVariationId=c}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t.prototype._getOverriddenVariation=function(t){var e=this.overrides.get(t.id);return e?this._getVariationByIdOrNull(e):void 0},t}(),l=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},y=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},T=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),E=function(t,e){this.id=t,this.key=e},v=function(t){this.conditions=t},d=function(t,e){this.key=t,this.match=e},N=function(t,e){this.type=t,this.name=e},m=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},A=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},_=function(t,e){this.target=t,this.action=e};function R(t,e){return t-e}var I=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new w(parseInt(o,10),parseInt(u,10),parseInt(a,10)),O.parse(c),O.parse(f))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),w=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return R(this.major,t.major)||R(this.minor,t.minor)||R(this.patch,t.patch)},t}(),O=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return R(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?R(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),g=["MATCH","NOT_MATCH"],M=["STRING","NUMBER","BOOLEAN","VERSION"],b=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],F=["VARIATION","BUCKET"],P=["HACKLE_PROPERTY","USER_PROPERTY"],D=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var o;return i(i({},r),((o={})[n]=e.filteredPropertiesValue(t[n]),o))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),L=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new C((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new U((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),C=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:D.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:D.filteredProperties(this.hackleProperties||{})}},e}(L),U=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:D.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:D.filteredProperties(this.event.properties||{}),hackleProperties:D.filteredProperties(this.hackleProperties||{})}},e}(L),k=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),x=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),S=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),V=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),H=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),G=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),B=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),K=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),W=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),j=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new H,t.CONTAINS_MATCHER=new G,t.STARTS_WITH_MATCHER=new B,t.ENDS_WITH_MATCHER=new K,t.GT_MATCHER=new X,t.GTE_MATCHER=new z,t.LT_MATCHER=new Y,t.LTE_MATCHER=new W,t}(),q=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),Z=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),Q=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),$=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=I.tryParse(e),o=I.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),J=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new q,t.NUMBER_MATCHER=new Z,t.BOOLEAN_MATCHER=new Q,t.VERSION_MATCHER=new $,t}(),tt=function(){function t(t){this.valueOperatorMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this._resolveProperty(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t.prototype._resolveProperty=function(t,e,r){switch(r.type){case"HACKLE_PROPERTY":return e[r.name];case"USER_PROPERTY":return t.properties&&t.properties[r.name]}},t}(),et=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.PROPERTY_CONDITION_MATCHER}},t.PROPERTY_CONDITION_MATCHER=new tt(new V(new J,new j)),t}(),rt=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),nt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},ot=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=nt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),it=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):k.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=a(n.reverse()),s=u.next();!s.done;s=u.next()){var c=s.value;i=new t(c,i)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),ut=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=e._getOverriddenVariation(r);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return k.withVariation(u,p.OVERRIDDEN);case"FEATURE_FLAG":return k.withVariation(u,p.INDIVIDUAL_TARGET_MATCH)}},t}(),st=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?k.of(e,o,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),at=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return k.of(e,o,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return k.of(e,o,p.FEATURE_FLAG_INACTIVE)}},t}(),ct=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return k.withVariation(u,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),ft=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):k.of(e,o,p.NOT_IN_EXPERIMENT_TARGET)},t}(),pt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?k.of(e,o,p.VARIATION_DROPPED):k.withVariation(u,p.TRAFFIC_ALLOCATED):k.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t}(),ht=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return k.withVariation(s,p.TARGET_RULE_MATCH)},t}(),lt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return k.withVariation(u,p.DEFAULT_RULE)},t}(),yt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),Tt=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),Et=function(){function t(){var t=new S(new et),e=new rt(new ot);this.abTestFlow=it.of(new ut,new ft(new yt(t)),new st,new at,new ct,new pt(e)),this.featureFlagFlow=it.of(new st,new at,new ct,new ut,new ht(new Tt(t),e),new lt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),vt=e.log,dt=function(){function t(t,e,r){this.evaluator=new x(new Et),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return vt.error("experimentKey must not be empty"),c.of(n,p.INVALID_INPUT);if(!e)return vt.error("user must not be null."),c.of(n,p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return vt.error("user.id must not be null and must be string type"),c.of(n,p.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return vt.warn("SDK not ready."),c.of(n,p.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return vt.warn("Experiment does not exist."),c.of(n,p.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(L.exposure(i,e,u,r)),c.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return vt.error("featureKey must not be empty"),f.off(p.INVALID_INPUT);if(!e)return vt.error("user must not be null."),f.off(p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return vt.error("user.id must not be null and must be string type"),f.off(p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return vt.warn("SDK not ready."),f.off(p.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return vt.warn("FeatureFlag does not exist."),f.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(L.exposure(o,e,i,r)),"A"===i.variationKey?f.off(i.reason):f.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(L.track(o,t,e,r))}else vt.warn("SDK not ready")}else vt.error("Id must not be null. or Id must be string type");else vt.error("User must not be null.");else vt.warn("Event key must be not null. or event key must be string type.");else vt.warn("Event must be event type.");else vt.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=3e3),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,n=void 0===r?3e3:r;vt.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),i=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(i),e({success:!0})})),Promise.race([this.readyPromise,o]).then((function(t){return vt.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();function Nt(t){var e=new Array,r=new Array;return t.forEach((function(t){L.isExposure(t)?e.push(t.toDto()):L.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}}var mt=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),At=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new mt({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),_t=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new At(this.drainQueue.bind(this),Rt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function Rt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var It=e.log,wt=function(){function t(t,e,r,n){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new E(0,t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new E(t.id,t.key)]}));return new t(o,i,n,u)},t.toBucket=function(t){return new y(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new T(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new l(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t)})),a=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t)})),c=this.toTargetActionOrNull(r.execution.defaultRule);return o&&c&&new h(r.id,r.key,e,o,i,u,s,a,c,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void It.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t){var e=this.toTargetOrNull(t.target),r=this.toTargetActionOrNull(t.action);return e&&r&&new _(e,r)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(F,t.type);return e&&new A(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e){var r=this,n=t.mapNotUndefined(e.conditions,(function(t){return r.toConditionOrNull(t)}));return new v(n)},t.toConditionOrNull=function(t){var e=this.toTargetKeyOrNull(t.key),r=this.toTargetMatchOrNull(t.match);return e&&r&&new d(e,r)},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(P,t.type);return e&&new N(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(g,t.type),r=this.parseOrNull(b,t.operator),n=this.parseOrNull(M,t.valueType);return e&&r&&n&&new m(e,r,n,t.values)},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||It.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();export{y as Bucket,w as CoreVersion,r as DEFAULT_ON_READY_TIMEOUT,c as Decision,p as DecisionReason,At as DefaultEventQueue,L as Event,_t as EventProcessor,E as EventType,h as Experiment,C as Exposure,f as FeatureFlagDecision,dt as HackleInternalClient,e as Logger,b as MATCH_OPERATORS,g as MATCH_TYPES,M as MATCH_VALUE_TYPES,O as MetaVersion,T as Slot,F as TARGET_ACTION_TYPES,P as TARGET_KEY_TYPES,v as Target,A as TargetAction,d as TargetCondition,N as TargetKey,m as TargetMatch,_ as TargetRule,U as Track,l as Variation,I as Version,wt as Workspace,t as logLevels,Nt as toPayload};
var t={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},e=function(){function e(){}return e.setLogLevel=function(e){void 0===e&&(e=t.INFO),this.logLevel=e},e._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},e.logLevel=t.INFO,e.log={error:function(r){e.logLevel>=t.ERROR&&e._log("ERROR",r)},warn:function(r){e.logLevel>=t.WARN&&e._log("WARN",r)},info:function(r){e.logLevel>=t.INFO&&e._log("INFO",r)},debug:function(r){e.logLevel>=t.DEBUG&&e._log("DEBUG",r)}},e}(),r=3e3,n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)};function u(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var c=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),f=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),p=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),h=function(){function t(t,e,r,n,o,i,u,s,a,c,f){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.userOverrides=i,this.segmentOverrides=u,this.targetAudiences=s,this.targetRules=a,this.defaultRule=c,this._winnerVariationId=f}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t}(),l=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},E=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},T=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),y=function(t,e){this.id=t,this.key=e},v=function(t){this.conditions=t},d=function(t,e){this.key=t,this.match=e},N=function(t,e){this.type=t,this.name=e},m=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},R=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},_=function(t,e){this.target=t,this.action=e},A=function(t,e,r,n){this.id=t,this.key=e,this.type=r,this.targets=n};function I(t,e){return t-e}var w=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new O(parseInt(o,10),parseInt(u,10),parseInt(a,10)),g.parse(c),g.parse(f))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),O=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return I(this.major,t.major)||I(this.minor,t.minor)||I(this.patch,t.patch)},t}(),g=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return I(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?I(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),M=["MATCH","NOT_MATCH"],b=["STRING","NUMBER","BOOLEAN","VERSION"],P=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],F=["VARIATION","BUCKET"],D=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],S=["USER_ID","USER_PROPERTY"],U=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.supportedKeyTypes=t}return t.prototype.supports=function(t){return this.supportedKeyTypes.includes(t)},t.IDENTIFIER=new t("SEGMENT"),t.PROPERTY=new t("SEGMENT","USER_PROPERTY","HACKLE_PROPERTY"),t.SEGMENT=new t("USER_ID","USER_PROPERTY","HACKLE_PROPERTY"),t}(),C=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var o;return i(i({},r),((o={})[n]=e.filteredPropertiesValue(t[n]),o))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),L=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new k((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new x((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),k=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:C.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:C.filteredProperties(this.hackleProperties||{})}},e}(L),x=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:C.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:C.filteredProperties(this.event.properties||{}),hackleProperties:C.filteredProperties(this.hackleProperties||{})}},e}(L),G=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),V=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),H=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),B=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),K=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),W=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),j=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),q=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),Z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),Q=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new K,t.CONTAINS_MATCHER=new Y,t.STARTS_WITH_MATCHER=new X,t.ENDS_WITH_MATCHER=new z,t.GT_MATCHER=new W,t.GTE_MATCHER=new j,t.LT_MATCHER=new q,t.LTE_MATCHER=new Z,t}(),$=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),J=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),tt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=w.tryParse(e),o=w.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),rt=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new $,t.NUMBER_MATCHER=new J,t.BOOLEAN_MATCHER=new tt,t.VERSION_MATCHER=new et,t}(),nt=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r,n){var o=this.userValueResolver.resolveOrNull(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t}(),ot=function(){function t(){}return t.prototype.resolveOrNull=function(t,e,r){switch(r.type){case"USER_ID":return t.id;case"USER_PROPERTY":return t.properties&&t.properties[r.name];case"HACKLE_PROPERTY":return e[r.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(r.type,"]"))}},t}(),it=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return o._matches(t,e,r,n)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r,n){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var o=e.getSegmentOrNull(t);if(!o)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(o,e,r,n)},t}(),ut=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.targets.some((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o.userConditionMatcher.matches(t,e,r,n)}))},t}(),st=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_ID":case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.USER_CONDITION_MATCHER;case"SEGMENT":return t.SEGMENT_CONDITION_MATCHER}},t.USER_CONDITION_MATCHER=new nt(new ot,new B(new rt,new Q)),t.SEGMENT_CONDITION_MATCHER=new it(new ut(t.USER_CONDITION_MATCHER)),t}(),at=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),ct={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},ft=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=ct.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),pt=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):G.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=a(n.reverse()),s=u.next();!s.done;s=u.next()){var c=s.value;i=new t(c,i)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),ht=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=this.overrideResolver.resolveOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return G.withVariation(u,p.OVERRIDDEN);case"FEATURE_FLAG":return G.withVariation(u,p.INDIVIDUAL_TARGET_MATCH)}},t}(),lt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?G.of(e,o,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),Et=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return G.of(e,o,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return G.of(e,o,p.FEATURE_FLAG_INACTIVE)}},t}(),Tt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return G.withVariation(u,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),yt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):G.of(e,o,p.NOT_IN_EXPERIMENT_TARGET)},t}(),vt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?G.of(e,o,p.VARIATION_DROPPED):G.withVariation(u,p.TRAFFIC_ALLOCATED):G.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t}(),dt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(s,p.TARGET_RULE_MATCH)},t}(),Nt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(u,p.DEFAULT_RULE)},t}(),mt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),Rt=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),_t=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r,n){var o=this,i=e.userOverrides.get(r.id);if(i)return e._getVariationByIdOrNull(i);var u=e.segmentOverrides.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}));return u?this.actionResolver.resolveOrNull(u.action,t,e,r):void 0},t}(),At=function(){function t(){var t=new H(new st),e=new at(new ft),r=new _t(t,e);this.abTestFlow=pt.of(new ht(r),new yt(new mt(t)),new lt,new Et,new Tt,new vt(e)),this.featureFlagFlow=pt.of(new lt,new Et,new Tt,new ht(r),new dt(new Rt(t),e),new Nt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),It=e.log,wt=function(){function t(t,e,r){this.evaluator=new V(new At),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return It.error("experimentKey must not be empty"),c.of(n,p.INVALID_INPUT);if(!e)return It.error("user must not be null."),c.of(n,p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return It.error("user.id must not be null and must be string type"),c.of(n,p.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return It.warn("SDK not ready."),c.of(n,p.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return It.warn("Experiment does not exist."),c.of(n,p.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(L.exposure(i,e,u,r)),c.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return It.error("featureKey must not be empty"),f.off(p.INVALID_INPUT);if(!e)return It.error("user must not be null."),f.off(p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return It.error("user.id must not be null and must be string type"),f.off(p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return It.warn("SDK not ready."),f.off(p.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return It.warn("FeatureFlag does not exist."),f.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(L.exposure(o,e,i,r)),"A"===i.variationKey?f.off(i.reason):f.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(L.track(o,t,e,r))}else It.warn("SDK not ready")}else It.error("Id must not be null. or Id must be string type");else It.error("User must not be null.");else It.warn("Event key must be not null. or event key must be string type.");else It.warn("Event must be event type.");else It.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=3e3),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,n=void 0===r?3e3:r;It.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),i=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(i),e({success:!0})})),Promise.race([this.readyPromise,o]).then((function(t){return It.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();function Ot(t){var e=new Array,r=new Array;return t.forEach((function(t){L.isExposure(t)?e.push(t.toDto()):L.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}}var gt=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),Mt=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new gt({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),bt=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new Mt(this.drainQueue.bind(this),Pt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function Pt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var Ft=e.log,Dt=function(){function t(t,e,r,n,o){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=o}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new y(0,t)},t.prototype.getSegmentOrNull=function(t){return this.segments.get(t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new y(t.id,t.key)]})),s=t.associateBy(t.mapNotUndefined(e.segments,(function(t){return r.toSegmentOrNull(t)})),(function(t){return t.key}));return new t(o,i,n,u,s)},t.toBucket=function(t){return new E(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new T(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new l(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.segmentOverrides,(function(t){return n.toTargetRuleOrNull(t,U.IDENTIFIER)})),a=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t,U.PROPERTY)})),c=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t,U.PROPERTY)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return o&&f&&new h(r.id,r.key,e,o,i,u,s,a,c,f,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void Ft.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t,e){var r=this.toTargetOrNull(t.target,e),n=this.toTargetActionOrNull(t.action);return r&&n&&new _(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(F,t.type);return e&&new R(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,o=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new v(o)},t.toConditionOrNull=function(t,e){var r=this.toTargetKeyOrNull(t.key);if(r&&e.supports(r.type)){var n=this.toTargetMatchOrNull(t.match);return n&&new d(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(D,t.type);return e&&new N(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(M,t.type),r=this.parseOrNull(P,t.operator),n=this.parseOrNull(b,t.valueType);return e&&r&&n&&new m(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(S,t.type);return r&&new A(t.id,t.key,r,this.mapNotUndefined(t.targets,(function(t){return e.toTargetOrNull(t,U.SEGMENT)})))},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||Ft.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();export{E as Bucket,O as CoreVersion,r as DEFAULT_ON_READY_TIMEOUT,c as Decision,p as DecisionReason,Mt as DefaultEventQueue,L as Event,bt as EventProcessor,y as EventType,h as Experiment,k as Exposure,f as FeatureFlagDecision,wt as HackleInternalClient,e as Logger,P as MATCH_OPERATORS,M as MATCH_TYPES,b as MATCH_VALUE_TYPES,g as MetaVersion,S as SEGMENT_TYPES,A as Segment,T as Slot,F as TARGET_ACTION_TYPES,D as TARGET_KEY_TYPES,v as Target,R as TargetAction,d as TargetCondition,N as TargetKey,m as TargetMatch,_ as TargetRule,U as TargetingType,x as Track,l as Variation,w as Version,Dt as Workspace,t as logLevels,Ot as toPayload};
//# sourceMappingURL=index.es.min.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},e=function(){function e(){}return e.setLogLevel=function(e){void 0===e&&(e=t.INFO),this.logLevel=e},e._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},e.logLevel=t.INFO,e.log={error:function(r){e.logLevel>=t.ERROR&&e._log("ERROR",r)},warn:function(r){e.logLevel>=t.WARN&&e._log("WARN",r)},info:function(r){e.logLevel>=t.INFO&&e._log("INFO",r)},debug:function(r){e.logLevel>=t.DEBUG&&e._log("DEBUG",r)}},e}(),r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)};function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function u(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var a=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),c=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),p=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),f=function(){function t(t,e,r,n,o,i,u,s,a,c){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.overrides=i,this.targetAudiences=u,this.targetRules=s,this.defaultRule=a,this._winnerVariationId=c}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t.prototype._getOverriddenVariation=function(t){var e=this.overrides.get(t.id);return e?this._getVariationByIdOrNull(e):void 0},t}(),h=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},l=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},T=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),y=function(t,e){this.id=t,this.key=e},E=function(t){this.conditions=t},v=function(t,e){this.key=t,this.match=e},d=function(t,e){this.type=t,this.name=e},A=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},_=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},N=function(t,e){this.target=t,this.action=e};function m(t,e){return t-e}var R=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],p=n[5];return new t(new I(parseInt(o,10),parseInt(u,10),parseInt(a,10)),w.parse(c),w.parse(p))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),I=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return m(this.major,t.major)||m(this.minor,t.minor)||m(this.patch,t.patch)},t}(),w=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return m(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?m(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),g=["MATCH","NOT_MATCH"],O=["STRING","NUMBER","BOOLEAN","VERSION"],M=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],b=["VARIATION","BUCKET"],P=["HACKLE_PROPERTY","USER_PROPERTY"],F=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var i;return o(o({},r),((i={})[n]=e.filteredPropertiesValue(t[n]),i))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),x=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new D((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new L((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),D=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:F.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:F.filteredProperties(this.hackleProperties||{})}},e}(x),L=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:F.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:F.filteredProperties(this.event.properties||{}),hackleProperties:F.filteredProperties(this.hackleProperties||{})}},e}(x),C=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),U=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),k=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),S=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),V=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),H=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),G=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),B=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),K=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),W=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new V,t.CONTAINS_MATCHER=new H,t.STARTS_WITH_MATCHER=new G,t.ENDS_WITH_MATCHER=new B,t.GT_MATCHER=new K,t.GTE_MATCHER=new Y,t.LT_MATCHER=new X,t.LTE_MATCHER=new z,t}(),j=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),q=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),Z=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),Q=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=R.tryParse(e),o=R.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),$=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new j,t.NUMBER_MATCHER=new q,t.BOOLEAN_MATCHER=new Z,t.VERSION_MATCHER=new Q,t}(),J=function(){function t(t){this.valueOperatorMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this._resolveProperty(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t.prototype._resolveProperty=function(t,e,r){switch(r.type){case"HACKLE_PROPERTY":return e[r.name];case"USER_PROPERTY":return t.properties&&t.properties[r.name]}},t}(),tt=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.PROPERTY_CONDITION_MATCHER}},t.PROPERTY_CONDITION_MATCHER=new J(new S(new $,new W)),t}(),et=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),rt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},nt=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=rt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),ot=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):C.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=s(n.reverse()),a=u.next();!a.done;a=u.next()){var c=a.value;i=new t(c,i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),it=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=e._getOverriddenVariation(r);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return C.withVariation(u,p.OVERRIDDEN);case"FEATURE_FLAG":return C.withVariation(u,p.INDIVIDUAL_TARGET_MATCH)}},t}(),ut=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?C.of(e,o,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),st=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return C.of(e,o,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return C.of(e,o,p.FEATURE_FLAG_INACTIVE)}},t}(),at=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return C.withVariation(u,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),ct=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):C.of(e,o,p.NOT_IN_EXPERIMENT_TARGET)},t}(),pt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?C.of(e,o,p.VARIATION_DROPPED):C.withVariation(u,p.TRAFFIC_ALLOCATED):C.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t}(),ft=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return C.withVariation(s,p.TARGET_RULE_MATCH)},t}(),ht=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return C.withVariation(u,p.DEFAULT_RULE)},t}(),lt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),Tt=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),yt=function(){function t(){var t=new k(new tt),e=new et(new nt);this.abTestFlow=ot.of(new it,new ct(new lt(t)),new ut,new st,new at,new pt(e)),this.featureFlagFlow=ot.of(new ut,new st,new at,new it,new ft(new Tt(t),e),new ht(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),Et=e.log,vt=function(){function t(t,e,r){this.evaluator=new U(new yt),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return Et.error("experimentKey must not be empty"),a.of(n,p.INVALID_INPUT);if(!e)return Et.error("user must not be null."),a.of(n,p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return Et.error("user.id must not be null and must be string type"),a.of(n,p.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return Et.warn("SDK not ready."),a.of(n,p.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return Et.warn("Experiment does not exist."),a.of(n,p.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(x.exposure(i,e,u,r)),a.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return Et.error("featureKey must not be empty"),c.off(p.INVALID_INPUT);if(!e)return Et.error("user must not be null."),c.off(p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return Et.error("user.id must not be null and must be string type"),c.off(p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Et.warn("SDK not ready."),c.off(p.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return Et.warn("FeatureFlag does not exist."),c.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(x.exposure(o,e,i,r)),"A"===i.variationKey?c.off(i.reason):c.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(x.track(o,t,e,r))}else Et.warn("SDK not ready")}else Et.error("Id must not be null. or Id must be string type");else Et.error("User must not be null.");else Et.warn("Event key must be not null. or event key must be string type.");else Et.warn("Event must be event type.");else Et.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=3e3),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,n=void 0===r?3e3:r;Et.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),i=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(i),e({success:!0})})),Promise.race([this.readyPromise,o]).then((function(t){return Et.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var dt=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),At=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new dt({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),_t=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new At(this.drainQueue.bind(this),Nt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return i(this,void 0,void 0,(function(){return u(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function Nt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var mt=e.log,Rt=function(){function t(t,e,r,n){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new y(0,t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new y(t.id,t.key)]}));return new t(o,i,n,u)},t.toBucket=function(t){return new l(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new T(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new h(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t)})),a=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t)})),c=this.toTargetActionOrNull(r.execution.defaultRule);return o&&c&&new f(r.id,r.key,e,o,i,u,s,a,c,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void mt.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t){var e=this.toTargetOrNull(t.target),r=this.toTargetActionOrNull(t.action);return e&&r&&new N(e,r)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(b,t.type);return e&&new _(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e){var r=this,n=t.mapNotUndefined(e.conditions,(function(t){return r.toConditionOrNull(t)}));return new E(n)},t.toConditionOrNull=function(t){var e=this.toTargetKeyOrNull(t.key),r=this.toTargetMatchOrNull(t.match);return e&&r&&new v(e,r)},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(P,t.type);return e&&new d(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(g,t.type),r=this.parseOrNull(M,t.operator),n=this.parseOrNull(O,t.valueType);return e&&r&&n&&new A(e,r,n,t.values)},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||mt.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();exports.Bucket=l,exports.CoreVersion=I,exports.DEFAULT_ON_READY_TIMEOUT=3e3,exports.Decision=a,exports.DecisionReason=p,exports.DefaultEventQueue=At,exports.Event=x,exports.EventProcessor=_t,exports.EventType=y,exports.Experiment=f,exports.Exposure=D,exports.FeatureFlagDecision=c,exports.HackleInternalClient=vt,exports.Logger=e,exports.MATCH_OPERATORS=M,exports.MATCH_TYPES=g,exports.MATCH_VALUE_TYPES=O,exports.MetaVersion=w,exports.Slot=T,exports.TARGET_ACTION_TYPES=b,exports.TARGET_KEY_TYPES=P,exports.Target=E,exports.TargetAction=_,exports.TargetCondition=v,exports.TargetKey=d,exports.TargetMatch=A,exports.TargetRule=N,exports.Track=L,exports.Variation=h,exports.Version=R,exports.Workspace=Rt,exports.logLevels=t,exports.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){x.isExposure(t)?e.push(t.toDto()):x.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},e=function(){function e(){}return e.setLogLevel=function(e){void 0===e&&(e=t.INFO),this.logLevel=e},e._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},e.logLevel=t.INFO,e.log={error:function(r){e.logLevel>=t.ERROR&&e._log("ERROR",r)},warn:function(r){e.logLevel>=t.WARN&&e._log("WARN",r)},info:function(r){e.logLevel>=t.INFO&&e._log("INFO",r)},debug:function(r){e.logLevel>=t.DEBUG&&e._log("DEBUG",r)}},e}(),r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)};function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function u(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var a=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),c=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),p=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),f=function(){function t(t,e,r,n,o,i,u,s,a,c,p){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.userOverrides=i,this.segmentOverrides=u,this.targetAudiences=s,this.targetRules=a,this.defaultRule=c,this._winnerVariationId=p}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t}(),h=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},l=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},T=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),E=function(t,e){this.id=t,this.key=e},y=function(t){this.conditions=t},v=function(t,e){this.key=t,this.match=e},d=function(t,e){this.type=t,this.name=e},N=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},m=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},R=function(t,e){this.target=t,this.action=e},_=function(t,e,r,n){this.id=t,this.key=e,this.type=r,this.targets=n};function A(t,e){return t-e}var I=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],p=n[5];return new t(new g(parseInt(o,10),parseInt(u,10),parseInt(a,10)),O.parse(c),O.parse(p))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),g=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return A(this.major,t.major)||A(this.minor,t.minor)||A(this.patch,t.patch)},t}(),O=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return A(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?A(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),w=["MATCH","NOT_MATCH"],M=["STRING","NUMBER","BOOLEAN","VERSION"],P=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],b=["VARIATION","BUCKET"],D=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],F=["USER_ID","USER_PROPERTY"],x=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.supportedKeyTypes=t}return t.prototype.supports=function(t){return this.supportedKeyTypes.includes(t)},t.IDENTIFIER=new t("SEGMENT"),t.PROPERTY=new t("SEGMENT","USER_PROPERTY","HACKLE_PROPERTY"),t.SEGMENT=new t("USER_ID","USER_PROPERTY","HACKLE_PROPERTY"),t}(),S=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var i;return o(o({},r),((i={})[n]=e.filteredPropertiesValue(t[n]),i))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),C=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new U((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new L((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),U=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:S.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:S.filteredProperties(this.hackleProperties||{})}},e}(C),L=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:S.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:S.filteredProperties(this.event.properties||{}),hackleProperties:S.filteredProperties(this.hackleProperties||{})}},e}(C),k=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),V=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),G=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),H=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),B=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),K=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),W=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),j=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),q=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),Z=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new B,t.CONTAINS_MATCHER=new K,t.STARTS_WITH_MATCHER=new Y,t.ENDS_WITH_MATCHER=new X,t.GT_MATCHER=new z,t.GTE_MATCHER=new W,t.LT_MATCHER=new j,t.LTE_MATCHER=new q,t}(),Q=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),$=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),J=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),tt=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=I.tryParse(e),o=I.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),et=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new Q,t.NUMBER_MATCHER=new $,t.BOOLEAN_MATCHER=new J,t.VERSION_MATCHER=new tt,t}(),rt=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r,n){var o=this.userValueResolver.resolveOrNull(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t}(),nt=function(){function t(){}return t.prototype.resolveOrNull=function(t,e,r){switch(r.type){case"USER_ID":return t.id;case"USER_PROPERTY":return t.properties&&t.properties[r.name];case"HACKLE_PROPERTY":return e[r.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(r.type,"]"))}},t}(),ot=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return o._matches(t,e,r,n)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r,n){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var o=e.getSegmentOrNull(t);if(!o)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(o,e,r,n)},t}(),it=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.targets.some((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o.userConditionMatcher.matches(t,e,r,n)}))},t}(),ut=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_ID":case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.USER_CONDITION_MATCHER;case"SEGMENT":return t.SEGMENT_CONDITION_MATCHER}},t.USER_CONDITION_MATCHER=new rt(new nt,new H(new et,new Z)),t.SEGMENT_CONDITION_MATCHER=new ot(new it(t.USER_CONDITION_MATCHER)),t}(),st=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),at={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},ct=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=at.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),pt=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):k.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=s(n.reverse()),a=u.next();!a.done;a=u.next()){var c=a.value;i=new t(c,i)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),ft=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=this.overrideResolver.resolveOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return k.withVariation(u,p.OVERRIDDEN);case"FEATURE_FLAG":return k.withVariation(u,p.INDIVIDUAL_TARGET_MATCH)}},t}(),ht=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?k.of(e,o,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),lt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return k.of(e,o,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return k.of(e,o,p.FEATURE_FLAG_INACTIVE)}},t}(),Tt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return k.withVariation(u,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),Et=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):k.of(e,o,p.NOT_IN_EXPERIMENT_TARGET)},t}(),yt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?k.of(e,o,p.VARIATION_DROPPED):k.withVariation(u,p.TRAFFIC_ALLOCATED):k.of(e,o,p.TRAFFIC_NOT_ALLOCATED)},t}(),vt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return k.withVariation(s,p.TARGET_RULE_MATCH)},t}(),dt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return k.withVariation(u,p.DEFAULT_RULE)},t}(),Nt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),mt=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),Rt=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r,n){var o=this,i=e.userOverrides.get(r.id);if(i)return e._getVariationByIdOrNull(i);var u=e.segmentOverrides.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}));return u?this.actionResolver.resolveOrNull(u.action,t,e,r):void 0},t}(),_t=function(){function t(){var t=new G(new ut),e=new st(new ct),r=new Rt(t,e);this.abTestFlow=pt.of(new ft(r),new Et(new Nt(t)),new ht,new lt,new Tt,new yt(e)),this.featureFlagFlow=pt.of(new ht,new lt,new Tt,new ft(r),new vt(new mt(t),e),new dt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),At=e.log,It=function(){function t(t,e,r){this.evaluator=new V(new _t),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return At.error("experimentKey must not be empty"),a.of(n,p.INVALID_INPUT);if(!e)return At.error("user must not be null."),a.of(n,p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return At.error("user.id must not be null and must be string type"),a.of(n,p.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return At.warn("SDK not ready."),a.of(n,p.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return At.warn("Experiment does not exist."),a.of(n,p.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(C.exposure(i,e,u,r)),a.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return At.error("featureKey must not be empty"),c.off(p.INVALID_INPUT);if(!e)return At.error("user must not be null."),c.off(p.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return At.error("user.id must not be null and must be string type"),c.off(p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return At.warn("SDK not ready."),c.off(p.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return At.warn("FeatureFlag does not exist."),c.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(C.exposure(o,e,i,r)),"A"===i.variationKey?c.off(i.reason):c.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(C.track(o,t,e,r))}else At.warn("SDK not ready")}else At.error("Id must not be null. or Id must be string type");else At.error("User must not be null.");else At.warn("Event key must be not null. or event key must be string type.");else At.warn("Event must be event type.");else At.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=3e3),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,n=void 0===r?3e3:r;At.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),i=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(i),e({success:!0})})),Promise.race([this.readyPromise,o]).then((function(t){return At.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var gt=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),Ot=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new gt({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),wt=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new Ot(this.drainQueue.bind(this),Mt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return i(this,void 0,void 0,(function(){return u(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function Mt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var Pt=e.log,bt=function(){function t(t,e,r,n,o){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=o}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new E(0,t)},t.prototype.getSegmentOrNull=function(t){return this.segments.get(t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new E(t.id,t.key)]})),s=t.associateBy(t.mapNotUndefined(e.segments,(function(t){return r.toSegmentOrNull(t)})),(function(t){return t.key}));return new t(o,i,n,u,s)},t.toBucket=function(t){return new l(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new T(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new h(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.segmentOverrides,(function(t){return n.toTargetRuleOrNull(t,x.IDENTIFIER)})),a=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t,x.PROPERTY)})),c=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t,x.PROPERTY)})),p=this.toTargetActionOrNull(r.execution.defaultRule);return o&&p&&new f(r.id,r.key,e,o,i,u,s,a,c,p,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void Pt.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t,e){var r=this.toTargetOrNull(t.target,e),n=this.toTargetActionOrNull(t.action);return r&&n&&new R(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(b,t.type);return e&&new m(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,o=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new y(o)},t.toConditionOrNull=function(t,e){var r=this.toTargetKeyOrNull(t.key);if(r&&e.supports(r.type)){var n=this.toTargetMatchOrNull(t.match);return n&&new v(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(D,t.type);return e&&new d(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(w,t.type),r=this.parseOrNull(P,t.operator),n=this.parseOrNull(M,t.valueType);return e&&r&&n&&new N(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(F,t.type);return r&&new _(t.id,t.key,r,this.mapNotUndefined(t.targets,(function(t){return e.toTargetOrNull(t,x.SEGMENT)})))},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||Pt.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();exports.Bucket=l,exports.CoreVersion=g,exports.DEFAULT_ON_READY_TIMEOUT=3e3,exports.Decision=a,exports.DecisionReason=p,exports.DefaultEventQueue=Ot,exports.Event=C,exports.EventProcessor=wt,exports.EventType=E,exports.Experiment=f,exports.Exposure=U,exports.FeatureFlagDecision=c,exports.HackleInternalClient=It,exports.Logger=e,exports.MATCH_OPERATORS=P,exports.MATCH_TYPES=w,exports.MATCH_VALUE_TYPES=M,exports.MetaVersion=O,exports.SEGMENT_TYPES=F,exports.Segment=_,exports.Slot=T,exports.TARGET_ACTION_TYPES=b,exports.TARGET_KEY_TYPES=D,exports.Target=y,exports.TargetAction=m,exports.TargetCondition=v,exports.TargetKey=d,exports.TargetMatch=N,exports.TargetRule=R,exports.TargetingType=x,exports.Track=L,exports.Variation=h,exports.Version=I,exports.Workspace=bt,exports.logLevels=t,exports.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){C.isExposure(t)?e.push(t.toDto()):C.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}};
//# sourceMappingURL=index.min.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Hackle={})}(this,(function(t){"use strict";var e={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},r=function(){function t(){}return t.setLogLevel=function(t){void 0===t&&(t=e.INFO),this.logLevel=t},t._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},t.logLevel=e.INFO,t.log={error:function(r){t.logLevel>=e.ERROR&&t._log("ERROR",r)},warn:function(r){t.logLevel>=e.WARN&&t._log("WARN",r)},info:function(r){t.logLevel>=e.INFO&&t._log("INFO",r)},debug:function(r){t.logLevel>=e.DEBUG&&t._log("DEBUG",r)}},t}(),n=3e3,o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},o(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var u=function(){return u=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)};function s(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var f=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),p=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),h=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),l=function(){function t(t,e,r,n,o,i,u,s,a,c){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.overrides=i,this.targetAudiences=u,this.targetRules=s,this.defaultRule=a,this._winnerVariationId=c}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t.prototype._getOverriddenVariation=function(t){var e=this.overrides.get(t.id);return e?this._getVariationByIdOrNull(e):void 0},t}(),T=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},y=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},E=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),v=function(t,e){this.id=t,this.key=e},d=function(t){this.conditions=t},A=function(t,e){this.key=t,this.match=e},_=function(t,e){this.type=t,this.name=e},m=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},N=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},R=function(t,e){this.target=t,this.action=e};function I(t,e){return t-e}var w=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new g(parseInt(o,10),parseInt(u,10),parseInt(a,10)),O.parse(c),O.parse(f))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),g=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return I(this.major,t.major)||I(this.minor,t.minor)||I(this.patch,t.patch)},t}(),O=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return I(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?I(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),M=["MATCH","NOT_MATCH"],b=["STRING","NUMBER","BOOLEAN","VERSION"],P=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],F=["VARIATION","BUCKET"],D=["HACKLE_PROPERTY","USER_PROPERTY"],L=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var o;return u(u({},r),((o={})[n]=e.filteredPropertiesValue(t[n]),o))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),C=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new U((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new k((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),U=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:L.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:L.filteredProperties(this.hackleProperties||{})}},e}(C),k=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:L.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:L.filteredProperties(this.event.properties||{}),hackleProperties:L.filteredProperties(this.hackleProperties||{})}},e}(C),S=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),x=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),V=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),H=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),G=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),B=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),K=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),j=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),W=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),q=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new G,t.CONTAINS_MATCHER=new B,t.STARTS_WITH_MATCHER=new K,t.ENDS_WITH_MATCHER=new Y,t.GT_MATCHER=new X,t.GTE_MATCHER=new j,t.LT_MATCHER=new z,t.LTE_MATCHER=new W,t}(),Z=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),Q=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),$=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),J=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=w.tryParse(e),o=w.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),tt=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new Z,t.NUMBER_MATCHER=new Q,t.BOOLEAN_MATCHER=new $,t.VERSION_MATCHER=new J,t}(),et=function(){function t(t){this.valueOperatorMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this._resolveProperty(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t.prototype._resolveProperty=function(t,e,r){switch(r.type){case"HACKLE_PROPERTY":return e[r.name];case"USER_PROPERTY":return t.properties&&t.properties[r.name]}},t}(),rt=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.PROPERTY_CONDITION_MATCHER}},t.PROPERTY_CONDITION_MATCHER=new et(new H(new tt,new q)),t}(),nt=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),ot={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},it=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=ot.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),ut=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):S.of(e,o,h.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=c(n.reverse()),s=u.next();!s.done;s=u.next()){var a=s.value;i=new t(a,i)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),st=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=e._getOverriddenVariation(r);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return S.withVariation(u,h.OVERRIDDEN);case"FEATURE_FLAG":return S.withVariation(u,h.INDIVIDUAL_TARGET_MATCH)}},t}(),at=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?S.of(e,o,h.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),ct=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return S.of(e,o,h.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return S.of(e,o,h.FEATURE_FLAG_INACTIVE)}},t}(),ft=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return S.withVariation(u,h.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),pt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):S.of(e,o,h.NOT_IN_EXPERIMENT_TARGET)},t}(),ht=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?S.of(e,o,h.VARIATION_DROPPED):S.withVariation(u,h.TRAFFIC_ALLOCATED):S.of(e,o,h.TRAFFIC_NOT_ALLOCATED)},t}(),lt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return S.withVariation(s,h.TARGET_RULE_MATCH)},t}(),Tt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return S.withVariation(u,h.DEFAULT_RULE)},t}(),yt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),Et=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),vt=function(){function t(){var t=new V(new rt),e=new nt(new it);this.abTestFlow=ut.of(new st,new pt(new yt(t)),new at,new ct,new ft,new ht(e)),this.featureFlagFlow=ut.of(new at,new ct,new ft,new st,new lt(new Et(t),e),new Tt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),dt=r.log,At=function(){function t(t,e,r){this.evaluator=new x(new vt),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return dt.error("experimentKey must not be empty"),f.of(n,h.INVALID_INPUT);if(!e)return dt.error("user must not be null."),f.of(n,h.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return dt.error("user.id must not be null and must be string type"),f.of(n,h.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return dt.warn("SDK not ready."),f.of(n,h.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return dt.warn("Experiment does not exist."),f.of(n,h.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(C.exposure(i,e,u,r)),f.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return dt.error("featureKey must not be empty"),p.off(h.INVALID_INPUT);if(!e)return dt.error("user must not be null."),p.off(h.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return dt.error("user.id must not be null and must be string type"),p.off(h.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return dt.warn("SDK not ready."),p.off(h.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return dt.warn("FeatureFlag does not exist."),p.off(h.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(C.exposure(o,e,i,r)),"A"===i.variationKey?p.off(i.reason):p.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(C.track(o,t,e,r))}else dt.warn("SDK not ready")}else dt.error("Id must not be null. or Id must be string type");else dt.error("User must not be null.");else dt.warn("Event key must be not null. or event key must be string type.");else dt.warn("Event must be event type.");else dt.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=n),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,o=void 0===r?n:r;dt.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),u=setTimeout((function(){e({success:!1})}),o);return this.readyPromise.then((function(){clearTimeout(u),e({success:!0})})),Promise.race([this.readyPromise,i]).then((function(t){return dt.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var _t=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),mt=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new _t({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),Nt=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new mt(this.drainQueue.bind(this),Rt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function Rt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var It=r.log,wt=function(){function t(t,e,r,n){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new v(0,t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new v(t.id,t.key)]}));return new t(o,i,n,u)},t.toBucket=function(t){return new y(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new E(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new T(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t)})),a=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t)})),c=this.toTargetActionOrNull(r.execution.defaultRule);return o&&c&&new l(r.id,r.key,e,o,i,u,s,a,c,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void It.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t){var e=this.toTargetOrNull(t.target),r=this.toTargetActionOrNull(t.action);return e&&r&&new R(e,r)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(F,t.type);return e&&new N(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e){var r=this,n=t.mapNotUndefined(e.conditions,(function(t){return r.toConditionOrNull(t)}));return new d(n)},t.toConditionOrNull=function(t){var e=this.toTargetKeyOrNull(t.key),r=this.toTargetMatchOrNull(t.match);return e&&r&&new A(e,r)},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(D,t.type);return e&&new _(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(M,t.type),r=this.parseOrNull(P,t.operator),n=this.parseOrNull(b,t.valueType);return e&&r&&n&&new m(e,r,n,t.values)},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||It.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();t.Bucket=y,t.CoreVersion=g,t.DEFAULT_ON_READY_TIMEOUT=n,t.Decision=f,t.DecisionReason=h,t.DefaultEventQueue=mt,t.Event=C,t.EventProcessor=Nt,t.EventType=v,t.Experiment=l,t.Exposure=U,t.FeatureFlagDecision=p,t.HackleInternalClient=At,t.Logger=r,t.MATCH_OPERATORS=P,t.MATCH_TYPES=M,t.MATCH_VALUE_TYPES=b,t.MetaVersion=O,t.Slot=E,t.TARGET_ACTION_TYPES=F,t.TARGET_KEY_TYPES=D,t.Target=d,t.TargetAction=N,t.TargetCondition=A,t.TargetKey=_,t.TargetMatch=m,t.TargetRule=R,t.Track=k,t.Variation=T,t.Version=w,t.Workspace=wt,t.logLevels=e,t.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){C.isExposure(t)?e.push(t.toDto()):C.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Hackle={})}(this,(function(t){"use strict";var e={DISABLE:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},r=function(){function t(){}return t.setLogLevel=function(t){void 0===t&&(t=e.INFO),this.logLevel=t},t._log=function(t,e){var r;switch(t){case"WARN":r="orange";break;case"ERROR":r="red";break;default:r="#AAAAAA"}try{console.log("%c[".concat(t,"] Hackle: ").concat(e),"color: ".concat(r))}catch(t){}},t.logLevel=e.INFO,t.log={error:function(r){t.logLevel>=e.ERROR&&t._log("ERROR",r)},warn:function(r){t.logLevel>=e.WARN&&t._log("WARN",r)},info:function(r){t.logLevel>=e.INFO&&t._log("INFO",r)},debug:function(r){t.logLevel>=e.DEBUG&&t._log("DEBUG",r)}},t}(),n=3e3,o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},o(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var u=function(){return u=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)};function s(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}a((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function c(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var f=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),p=function(){function t(t,e){this.isOn=t,this.reason=e}return t.on=function(e){return new t(!0,e)},t.off=function(e){return new t(!1,e)},t}(),h=function(){function t(){}return t.SDK_NOT_READY="SDK_NOT_READY",t.EXCEPTION="EXCEPTION",t.INVALID_INPUT="INVALID_INPUT",t.EXPERIMENT_NOT_FOUND="EXPERIMENT_NOT_FOUND",t.EXPERIMENT_DRAFT="EXPERIMENT_DRAFT",t.EXPERIMENT_PAUSED="EXPERIMENT_PAUSED",t.EXPERIMENT_COMPLETED="EXPERIMENT_COMPLETED",t.OVERRIDDEN="OVERRIDDEN",t.TRAFFIC_NOT_ALLOCATED="TRAFFIC_NOT_ALLOCATED",t.VARIATION_DROPPED="VARIATION_DROPPED",t.TRAFFIC_ALLOCATED="TRAFFIC_ALLOCATED",t.NOT_IN_EXPERIMENT_TARGET="NOT_IN_EXPERIMENT_TARGET",t.FEATURE_FLAG_NOT_FOUND="FEATURE_FLAG_NOT_FOUND",t.FEATURE_FLAG_INACTIVE="FEATURE_FLAG_INACTIVE",t.INDIVIDUAL_TARGET_MATCH="INDIVIDUAL_TARGET_MATCH",t.TARGET_RULE_MATCH="TARGET_RULE_MATCH",t.DEFAULT_RULE="DEFAULT_RULE",t}(),l=function(){function t(t,e,r,n,o,i,u,s,a,c,f){this.id=t,this.key=e,this.type=r,this.status=n,this.variations=o,this.userOverrides=i,this.segmentOverrides=u,this.targetAudiences=s,this.targetRules=a,this.defaultRule=c,this._winnerVariationId=f}return t.prototype._winnerVariationOrNull=function(){if(this._winnerVariationId)return this._getVariationByIdOrNull(this._winnerVariationId)},t.prototype._getVariationByIdOrNull=function(t){return this.variations.find((function(e){return e.id===t}))},t.prototype._getVariationByKeyOrNull=function(t){return this.variations.find((function(e){return e.key===t}))},t}(),T=function(t,e,r){this.id=t,this.key=e,this.isDropped=r},E=function(t,e,r){this.seed=t,this.slotSize=e,this.slots=r},y=function(){function t(t,e,r){this.startInclusive=t,this.endExclusive=e,this.variationId=r}return t.prototype.contains=function(t){return this.startInclusive<=t&&t<this.endExclusive},t}(),v=function(t,e){this.id=t,this.key=e},d=function(t){this.conditions=t},N=function(t,e){this.key=t,this.match=e},m=function(t,e){this.type=t,this.name=e},R=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},_=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},A=function(t,e){this.target=t,this.action=e},I=function(t,e,r,n){this.id=t,this.key=e,this.type=r,this.targets=n};function g(t,e){return t-e}var O=function(){function t(t,e,r){this.coreVersion=t,this.prerelease=e,this.build=r}return t.tryParse=function(e){var r=t.regExp.exec(e);if(r){var n=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}(r,6);n[0];var o=n[1],i=n[2],u=void 0===i?"0":i,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new w(parseInt(o,10),parseInt(u,10),parseInt(a,10)),M.parse(c),M.parse(f))}},t.prototype.compareTo=function(t){return this.coreVersion.compareTo(t.coreVersion)||this.prerelease.compareTo(t.prerelease)},t.prototype.isEqualTo=function(t){return 0===this.compareTo(t)},t.prototype.isGreaterThan=function(t){return this.compareTo(t)>0},t.prototype.isGreaterThanOrEqualTo=function(t){return this.compareTo(t)>=0},t.prototype.isLessThan=function(t){return this.compareTo(t)<0},t.prototype.isLessThanOrEqualTo=function(t){return this.compareTo(t)<=0},t.regExp=/^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,t}(),w=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return g(this.major,t.major)||g(this.minor,t.minor)||g(this.patch,t.patch)},t}(),M=function(){function t(t){this.identifiers=t}return t.parse=function(e){return e?new t(e.split(".")):t.EMPTY},t.prototype.isEmpty=function(){return 0===this.identifiers.length},t.prototype.isNotEmpty=function(){return!this.isEmpty()},t.prototype.compareTo=function(t){return this.isEmpty()&&t.isEmpty()?0:this.isEmpty()&&t.isNotEmpty()?1:this.isNotEmpty()&&t.isEmpty()?-1:this.compareIdentifiers(t)},t.prototype.compareIdentifiers=function(e){for(var r=Math.min(this.identifiers.length,e.identifiers.length),n=0;n<r;n++){var o=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==o)return o}return g(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?g(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),P=["MATCH","NOT_MATCH"],b=["STRING","NUMBER","BOOLEAN","VERSION"],D=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],F=["VARIATION","BUCKET"],S=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],C=["USER_ID","USER_PROPERTY"],U=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.supportedKeyTypes=t}return t.prototype.supports=function(t){return this.supportedKeyTypes.includes(t)},t.IDENTIFIER=new t("SEGMENT"),t.PROPERTY=new t("SEGMENT","USER_PROPERTY","HACKLE_PROPERTY"),t.SEGMENT=new t("USER_ID","USER_PROPERTY","HACKLE_PROPERTY"),t}(),L=function(){function t(){}return t.validate=function(t){if(t){if("object"!=typeof t)return!1;for(var e in t)if(!this.validProperty(e,t[e]))return!1}return!0},t.filteredProperties=function(t){var e=this;return Object.keys(t).filter((function(r){return e.validProperty(r,t[r])})).reduce((function(r,n){var o;return u(u({},r),((o={})[n]=e.filteredPropertiesValue(t[n]),o))}),{})},t.filteredPropertiesValue=function(t){return"string"==typeof t&&t.length>1024?t.slice(0,1024):t},t.validProperty=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&("string"==typeof e||("boolean"==typeof e||"number"==typeof e&&(!isNaN(e)&&isFinite(e))))))},t}(),k=function(){function t(t,e,r){this.timestamp=t,this.user=e,this.hackleProperties=r}return t.exposure=function(t,e,r,n){return void 0===n&&(n={}),new x((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason,n)},t.track=function(t,e,r,n){return void 0===n&&(n={}),new V((new Date).getTime(),r,t,e,n)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),x=function(t){function e(e,r,n,o,i,u,s){var a=t.call(this,e,r,s)||this;return a.experiment=n,a.variationId=o,a.variationKey=i,a.decisionReason=u,a}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:L.filteredProperties(this.user.properties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString(),hackleProperties:L.filteredProperties(this.hackleProperties||{})}},e}(k),V=function(t){function e(e,r,n,o,i){var u=t.call(this,e,r,i)||this;return u.eventType=n,u.event=o,u}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.id,userProperties:L.filteredProperties(this.user.properties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:L.filteredProperties(this.event.properties||{}),hackleProperties:L.filteredProperties(this.hackleProperties||{})}},e}(k),H=function(){function t(t,e,r){this.variationId=t,this.variationKey=e,this.reason=r}return t.withVariation=function(e,r){return new t(e.id,e.key,r)},t.withKey=function(e,r){return new t(void 0,e,r)},t.of=function(e,r,n){var o=e._getVariationByKeyOrNull(r);return o?t.withVariation(o,n):t.withKey(r,n)},t}(),G=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n,o){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n,o)},t}(),B=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r,n)},t}(),K=function(){function t(t,e){this.valueMatcherFactory=t,this.operatorMatcherFactory=e}return t.prototype.matches=function(t,e){var r=this.valueMatcherFactory.getMatcher(e.valueType),n=this.operatorMatcherFactory.getMatcher(e.operator),o=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,o)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),Y=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return t===e},t.prototype.numberMatches=function(t,e){return t===e},t.prototype.stringMatches=function(t,e){return t===e},t.prototype.versionMatches=function(t,e){return t.isEqualTo(e)},t}(),X=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.includes(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),j=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.startsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return!1},t.prototype.stringMatches=function(t,e){return t.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},t}(),W=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThan(e)},t}(),q=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t>=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isGreaterThanOrEqualTo(e)},t}(),Z=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThan(e)},t}(),Q=function(){function t(){}return t.prototype.booleanMatches=function(t,e){return!1},t.prototype.numberMatches=function(t,e){return t<=e},t.prototype.stringMatches=function(t,e){return!1},t.prototype.versionMatches=function(t,e){return t.isLessThanOrEqualTo(e)},t}(),$=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"IN":return t.IN_MATCHER;case"CONTAINS":return t.CONTAINS_MATCHER;case"STARTS_WITH":return t.STARTS_WITH_MATCHER;case"ENDS_WITH":return t.ENDS_WITH_MATCHER;case"GT":return t.GT_MATCHER;case"GTE":return t.GTE_MATCHER;case"LT":return t.LT_MATCHER;case"LTE":return t.LTE_MATCHER}},t.IN_MATCHER=new Y,t.CONTAINS_MATCHER=new X,t.STARTS_WITH_MATCHER=new j,t.ENDS_WITH_MATCHER=new z,t.GT_MATCHER=new W,t.GTE_MATCHER=new q,t.LT_MATCHER=new Z,t.LTE_MATCHER=new Q,t}(),J=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),tt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=O.tryParse(e),o=O.tryParse(r);return!(!n||!o)&&t.versionMatches(n,o)},t}(),nt=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"STRING":return t.STRING_MATCHER;case"NUMBER":return t.NUMBER_MATCHER;case"BOOLEAN":return t.BOOLEAN_MATCHER;case"VERSION":return t.VERSION_MATCHER}},t.STRING_MATCHER=new J,t.NUMBER_MATCHER=new tt,t.BOOLEAN_MATCHER=new et,t.VERSION_MATCHER=new rt,t}(),ot=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r,n){var o=this.userValueResolver.resolveOrNull(r,n,t.key);return!!o&&this.valueOperatorMatcher.matches(o,t.match)},t}(),it=function(){function t(){}return t.prototype.resolveOrNull=function(t,e,r){switch(r.type){case"USER_ID":return t.id;case"USER_PROPERTY":return t.properties&&t.properties[r.name];case"HACKLE_PROPERTY":return e[r.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(r.type,"]"))}},t}(),ut=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return o._matches(t,e,r,n)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r,n){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var o=e.getSegmentOrNull(t);if(!o)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(o,e,r,n)},t}(),st=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r,n){var o=this;return t.targets.some((function(t){return o._matches(t,e,r,n)}))},t.prototype._matches=function(t,e,r,n){var o=this;return t.conditions.every((function(t){return o.userConditionMatcher.matches(t,e,r,n)}))},t}(),at=function(){function t(){}return t.prototype.getMatcher=function(e){switch(e){case"USER_ID":case"USER_PROPERTY":case"HACKLE_PROPERTY":return t.USER_CONDITION_MATCHER;case"SEGMENT":return t.SEGMENT_CONDITION_MATCHER}},t.USER_CONDITION_MATCHER=new ot(new it,new K(new nt,new $)),t.SEGMENT_CONDITION_MATCHER=new ut(new st(t.USER_CONDITION_MATCHER)),t}(),ct=function(){function t(t){this.bucketer=t}return t.prototype.resolveOrNull=function(t,e,r,n){switch(t.type){case"VARIATION":return this._resolveVariation(t,r);case"BUCKET":return this._resolveBucket(t,e,r,n)}},t.prototype._resolveVariation=function(t,e){return e._getVariationByIdOrNull(t.variationId)},t.prototype._resolveBucket=function(t,e,r,n){var o=e.getBucketOrNull(t.bucketId),i=this.bucketer.bucketing(o,n);if(i)return r._getVariationByIdOrNull(i.variationId)},t}(),ft={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var o,i=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)o=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a=5*(a=(524287&(a^=o=this.mul32(o,u)))<<13|a>>>19)+3864292196|0;switch(o=0,n%4){case 3:o=(255&t.charCodeAt(s+2))<<16;case 2:o|=(255&t.charCodeAt(s+1))<<8;case 1:o|=255&t.charCodeAt(s),o=(131071&(o=this.mul32(o,i)))<<15|o>>>17,a^=o=this.mul32(o,u)}return a^=n,a^=a>>>16,a=this.mul32(a,2246822507),a^=a>>>13,a=this.mul32(a,3266489909),a^=a>>>16},mul32:function(t,e){var r=65535&e;return((e-r)*t|0)+(r*t|0)|0}},pt=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e.id);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=ft.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),ht=function(){function t(t,e){void 0===t&&(t=void 0),void 0===e&&(e=void 0),this.flowEvaluator=t,this.nextFlow=e}return t.prototype.evaluate=function(t,e,r,n,o){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,o,this.nextFlow):H.of(e,o,h.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=new t;try{for(var u=c(n.reverse()),s=u.next();!s.done;s=u.next()){var a=s.value;i=new t(a,i)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return i},t}(),lt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){var u=this.overrideResolver.resolveOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return H.withVariation(u,h.OVERRIDDEN);case"FEATURE_FLAG":return H.withVariation(u,h.INDIVIDUAL_TARGET_MATCH)}},t}(),Tt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){return"DRAFT"===e.status?H.of(e,o,h.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n,o)},t}(),Et=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n,o);switch(e.type){case"AB_TEST":return H.of(e,o,h.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return H.of(e,o,h.FEATURE_FLAG_INACTIVE)}},t}(),yt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,o,i){if("COMPLETED"===e.status){var u=e._winnerVariationOrNull();if(!u)throw new Error("winner variation [".concat(e.id,"]"));return H.withVariation(u,h.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n,o)},t}(),vt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));return this.experimentTargetDeterminer.isUserInExperimentTarget(t,e,r,n)?i.evaluate(t,e,r,n,o):H.of(e,o,h.NOT_IN_EXPERIMENT_TARGET)},t}(),dt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("AB_TEST"!==e.type)throw new Error("experiment type bust be AB_TEST [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return u?u.isDropped?H.of(e,o,h.VARIATION_DROPPED):H.withVariation(u,h.TRAFFIC_ALLOCATED):H.of(e,o,h.TRAFFIC_NOT_ALLOCATED)},t}(),Nt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r,n);if(!u)return i.evaluate(t,e,r,n,o);var s=this.actionResolver.resolveOrNull(u.action,t,e,r);if(!s)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return H.withVariation(s,h.TARGET_RULE_MATCH)},t}(),mt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,o,i){if("RUNNING"!==e.status)throw new Error("experiment status must be RUNNING [".concat(e.id,"]"));if("FEATURE_FLAG"!==e.type)throw new Error("experiment type bust be FEATURE_FLAG [".concat(e.id,"]"));var u=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return H.withVariation(u,h.DEFAULT_RULE)},t}(),Rt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r,n){var o=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return o.targetMatcher.matches(e,t,r,n)}))},t}(),_t=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r,n){var o=this;return e.targetRules.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}))},t}(),At=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r,n){var o=this,i=e.userOverrides.get(r.id);if(i)return e._getVariationByIdOrNull(i);var u=e.segmentOverrides.find((function(e){return o.targetMatcher.matches(e.target,t,r,n)}));return u?this.actionResolver.resolveOrNull(u.action,t,e,r):void 0},t}(),It=function(){function t(){var t=new B(new at),e=new ct(new pt),r=new At(t,e);this.abTestFlow=ht.of(new lt(r),new vt(new Rt(t)),new Tt,new Et,new yt,new dt(e)),this.featureFlagFlow=ht.of(new Tt,new Et,new yt,new lt(r),new Nt(new _t(t),e),new mt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),gt=r.log,Ot=function(){function t(t,e,r){this.evaluator=new G(new It),this.workspaceFetcher=t,this.eventProcessor=e,this.eventEmitter=r,this.workspaceFetcher.start(),this.eventProcessor.start(),this.readyPromise=this.workspaceFetcher.onReady().then((function(){return{success:!0}}),(function(){return{success:!1}}))}return t.prototype._experiment=function(t,e,r,n){if(!t)return gt.error("experimentKey must not be empty"),f.of(n,h.INVALID_INPUT);if(!e)return gt.error("user must not be null."),f.of(n,h.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return gt.error("user.id must not be null and must be string type"),f.of(n,h.INVALID_INPUT);var o=this.workspaceFetcher.get();if(!o)return gt.warn("SDK not ready."),f.of(n,h.SDK_NOT_READY);var i=o.getExperimentOrNull(t);if(!i)return gt.warn("Experiment does not exist."),f.of(n,h.EXPERIMENT_NOT_FOUND);var u=this.evaluator.evaluate(o,i,e,r,n);return this.eventProcessor.process(k.exposure(i,e,u,r)),f.of(u.variationKey,u.reason)},t.prototype._featureFlag=function(t,e,r){if(!t)return gt.error("featureKey must not be empty"),p.off(h.INVALID_INPUT);if(!e)return gt.error("user must not be null."),p.off(h.INVALID_INPUT);if(!e.id||"string"!=typeof e.id)return gt.error("user.id must not be null and must be string type"),p.off(h.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return gt.warn("SDK not ready."),p.off(h.SDK_NOT_READY);var o=n.getFeatureFlagOrNull(t);if(!o)return gt.warn("FeatureFlag does not exist."),p.off(h.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(n,o,e,r,"A");return this.eventProcessor.process(k.exposure(o,e,i,r)),"A"===i.variationKey?p.off(i.reason):p.on(i.reason)},t.prototype._track=function(t,e,r){if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key)if(e)if(e.id&&"string"==typeof e.id){var n=this.workspaceFetcher.get();if(n){var o=n.getEventTypeOrNull(t.key);this.eventProcessor.process(k.track(o,t,e,r))}else gt.warn("SDK not ready")}else gt.error("Id must not be null. or Id must be string type");else gt.error("User must not be null.");else gt.warn("Event key must be not null. or event key must be string type.");else gt.warn("Event must be event type.");else gt.warn("event must not be null.")},t.prototype._onReady=function(t,e){void 0===e&&(e=n),this._onInitialized({timeout:e}).then((function(){return t()}))},t.prototype._onInitialized=function(t){var e,r=t.timeout,o=void 0===r?n:r;gt.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),u=setTimeout((function(){e({success:!1})}),o);return this.readyPromise.then((function(){clearTimeout(u),e({success:!0})})),Promise.race([this.readyPromise,i]).then((function(t){return gt.debug("HackleClient onInitialized"),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var wt=function(){function t(t){var e=t.timeout,r=t.callback;this.timeout=Math.max(e,0),this.callback=r}return t.prototype.start=function(){this.timeoutId=setTimeout(this.callback,this.timeout)},t.prototype.refresh=function(){this.stop(),this.start()},t.prototype.stop=function(){this.timeoutId&&clearTimeout(this.timeoutId)},t}(),Mt=function(){function t(t,e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=1e4),this.buffer=[],this.sink=t,this.maxQueueSize=r,this.batchComparator=e,this.timer=new wt({callback:this.flush.bind(this),timeout:n}),this.started=!1}return t.prototype.start=function(){this.started=!0},t.prototype.stop=function(){this.started=!1;var t=this.sink(this.buffer,!0);return this.buffer=[],this.timer.stop(),t},t.prototype.enqueue=function(t){this.started&&(0===this.buffer.length&&this.timer.refresh(),this.buffer.push(t),this.buffer.length>=this.maxQueueSize&&this.flush())},t.prototype.flush=function(){this.sink(this.buffer),this.buffer=[],this.timer.stop()},t.prototype.close=function(){this.stop()},t}(),Pt=function(){function t(e,r,n){void 0===r&&(r=1e3),void 0===n&&(n=t.DEFAULT_FLUSH_INTERVAL),this.flushInterval=t.DEFAULT_FLUSH_INTERVAL,this.eventDispatcher=e,this.flushInterval=n,this.queue=new Mt(this.drainQueue.bind(this),bt,r,n)}return t.prototype.drainQueue=function(t,e){var r=this;return new Promise((function(n){0!==t.length?e?r.eventDispatcher.dispatchXhrOrBeacon(t,(function(){n()})):r.eventDispatcher.dispatch(t,(function(){n()})):n()}))},t.prototype.process=function(t){this.queue.enqueue(t)},t.prototype.start=function(){return s(this,void 0,void 0,(function(){return a(this,(function(t){return this.queue.start(),[2]}))}))},t.prototype.stop=function(){try{this.queue.close()}catch(t){}return Promise.resolve()},t.prototype.close=function(){this.stop()},t.DEFAULT_FLUSH_INTERVAL=1e4,t}();function bt(t,e){return t.timestamp==e.timestamp&&t.user.id==e.user.id&&t.user.properties==e.user.properties}var Dt=r.log,Ft=function(){function t(t,e,r,n,o){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=o}return t.prototype.getExperimentOrNull=function(t){return this.experiments.get(t)},t.prototype.getFeatureFlagOrNull=function(t){return this.featureFlags.get(t)},t.prototype.getBucketOrNull=function(t){return this.buckets.get(t)},t.prototype.getEventTypeOrNull=function(t){var e=this.eventTypes.get(t);return e||new v(0,t)},t.prototype.getSegmentOrNull=function(t){return this.segments.get(t)},t.from=function(e){var r=this,n=t.associate(e.buckets,(function(t){return[t.id,r.toBucket(t)]})),o=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),i=t.associateBy(t.mapNotUndefined(e.featureFlags,(function(t){return r.toExperimentOrNull("FEATURE_FLAG",t)})),(function(t){return t.key})),u=t.associate(e.events,(function(t){return[t.key,new v(t.id,t.key)]})),s=t.associateBy(t.mapNotUndefined(e.segments,(function(t){return r.toSegmentOrNull(t)})),(function(t){return t.key}));return new t(o,i,n,u,s)},t.toBucket=function(t){return new E(t.seed,t.slotSize,t.slots.map((function(t){var e=t.startInclusive,r=t.endExclusive,n=t.variationId;return new y(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,o=this.experimentStatusOrNull(r.execution.status),i=r.variations.map((function(t){return new T(t.id,t.key,"DROPPED"===t.status)})),u=t.associate(r.execution.userOverrides,(function(t){return[t.userId,t.variationId]})),s=t.mapNotUndefined(r.execution.segmentOverrides,(function(t){return n.toTargetRuleOrNull(t,U.IDENTIFIER)})),a=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t,U.PROPERTY)})),c=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t,U.PROPERTY)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return o&&f&&new l(r.id,r.key,e,o,i,u,s,a,c,f,r.winnerVariationId)},t.experimentStatusOrNull=function(t){switch(t){case"READY":return"DRAFT";case"RUNNING":return"RUNNING";case"PAUSED":return"PAUSED";case"STOPPED":return"COMPLETED";default:return void Dt.debug("Unsupported status [".concat(t,"]"))}},t.toTargetRuleOrNull=function(t,e){var r=this.toTargetOrNull(t.target,e),n=this.toTargetActionOrNull(t.action);return r&&n&&new A(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(F,t.type);return e&&new _(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,o=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new d(o)},t.toConditionOrNull=function(t,e){var r=this.toTargetKeyOrNull(t.key);if(r&&e.supports(r.type)){var n=this.toTargetMatchOrNull(t.match);return n&&new N(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(S,t.type);return e&&new m(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(P,t.type),r=this.parseOrNull(D,t.operator),n=this.parseOrNull(b,t.valueType);return e&&r&&n&&new R(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(C,t.type);return r&&new I(t.id,t.key,r,this.mapNotUndefined(t.targets,(function(t){return e.toTargetOrNull(t,U.SEGMENT)})))},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||Dt.debug("Unsupported type [".concat(e,"]. Please use the latest version of sdk.")),r},t.mapNotUndefined=function(t,e){return t.reduce((function(t,r){var n=e(r);return n&&t.push(n),t}),Array())},t.associateTo=function(t,e,r){return t.reduce((function(t,e){var n=r(e);return t.set(n[0],n[1]),t}),e)},t.associate=function(e,r){return t.associateTo(e,new Map,r)},t.associateBy=function(t,e){return this.associateTo(t,new Map,(function(t){return[e(t),t]}))},t}();t.Bucket=E,t.CoreVersion=w,t.DEFAULT_ON_READY_TIMEOUT=n,t.Decision=f,t.DecisionReason=h,t.DefaultEventQueue=Mt,t.Event=k,t.EventProcessor=Pt,t.EventType=v,t.Experiment=l,t.Exposure=x,t.FeatureFlagDecision=p,t.HackleInternalClient=Ot,t.Logger=r,t.MATCH_OPERATORS=D,t.MATCH_TYPES=P,t.MATCH_VALUE_TYPES=b,t.MetaVersion=M,t.SEGMENT_TYPES=C,t.Segment=I,t.Slot=y,t.TARGET_ACTION_TYPES=F,t.TARGET_KEY_TYPES=S,t.Target=d,t.TargetAction=_,t.TargetCondition=N,t.TargetKey=m,t.TargetMatch=R,t.TargetRule=A,t.TargetingType=U,t.Track=V,t.Variation=T,t.Version=O,t.Workspace=Ft,t.logLevels=e,t.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){k.isExposure(t)?e.push(t.toDto()):k.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map

@@ -8,2 +8,3 @@ import Workspace from "../../workspace/Workspace";

import TargetRuleDeterminer from "../target/TargetRuleDeterminer";
import OverrideResolver from "../target/OverrideResolver";
export default interface FlowEvaluator {

@@ -13,2 +14,4 @@ evaluate(workspace: Workspace, experiment: Experiment, user: User, hackleProperties: Properties, defaultVariationKey: VariationKey, nextFlow: EvaluationFlow): Evaluation;

export declare class OverrideEvaluator implements FlowEvaluator {
private overrideResolver;
constructor(overrideResolver: OverrideResolver);
evaluate(workspace: Workspace, experiment: Experiment, user: User, hackleProperties: Properties, defaultVariationKey: VariationKey, nextFlow: EvaluationFlow): Evaluation;

@@ -15,0 +18,0 @@ }

@@ -7,5 +7,6 @@ import { Properties, TargetCondition, TargetKeyType, User } from "../../model/model";

export declare class ConditionMatcherFactory {
private static PROPERTY_CONDITION_MATCHER;
private static USER_CONDITION_MATCHER;
private static SEGMENT_CONDITION_MATCHER;
getMatcher(type: TargetKeyType): ConditionMatcher;
}
//# sourceMappingURL=ConditionMatcher.d.ts.map

@@ -13,2 +13,3 @@ export declare type Int = number;

export declare type EventKey = string;
export declare type SegmentKey = string;
/**

@@ -114,3 +115,4 @@ * An object that contains the decided variation and the reason for the decision.

variations: Variation[];
overrides: Map<UserId, VariationId>;
userOverrides: Map<UserId, VariationId>;
segmentOverrides: TargetRule[];
targetAudiences: Target[];

@@ -120,7 +122,6 @@ targetRules: TargetRule[];

_winnerVariationId: VariationId | undefined;
constructor(id: ExperimentId, key: ExperimentKey, type: ExperimentType, status: ExperimentStatus, variations: Variation[], overrides: Map<UserId, VariationId>, targetAudiences: Target[], targetRules: TargetRule[], defaultRule: TargetAction, winnerVariationId: VariationId | undefined);
constructor(id: ExperimentId, key: ExperimentKey, type: ExperimentType, status: ExperimentStatus, variations: Variation[], userOverrides: Map<UserId, VariationId>, segmentOverrides: TargetRule[], targetAudiences: Target[], targetRules: TargetRule[], defaultRule: TargetAction, winnerVariationId: VariationId | undefined);
_winnerVariationOrNull(): Variation | undefined;
_getVariationByIdOrNull(variationId: VariationId): Variation | undefined;
_getVariationByKeyOrNull(variationKey: VariationKey): Variation | undefined;
_getOverriddenVariation(user: User): Variation | undefined;
}

@@ -195,2 +196,9 @@ export declare class Variation {

}
export declare class Segment {
id: Long;
key: SegmentKey;
type: SegmentType;
targets: Target[];
constructor(id: Long, key: SegmentKey, type: SegmentType, targets: Target[]);
}
export declare class Version {

@@ -233,3 +241,4 @@ readonly coreVersion: CoreVersion;

export declare const TARGET_ACTION_TYPES: readonly ["VARIATION", "BUCKET"];
export declare const TARGET_KEY_TYPES: readonly ["HACKLE_PROPERTY", "USER_PROPERTY"];
export declare const TARGET_KEY_TYPES: readonly ["USER_ID", "USER_PROPERTY", "HACKLE_PROPERTY", "SEGMENT"];
export declare const SEGMENT_TYPES: readonly ["USER_ID", "USER_PROPERTY"];
export declare type MatchType = typeof MATCH_TYPES[number];

@@ -240,2 +249,11 @@ export declare type MatchValueType = typeof MATCH_VALUE_TYPES[number];

export declare type TargetKeyType = typeof TARGET_KEY_TYPES[number];
export declare type SegmentType = typeof SEGMENT_TYPES[number];
export declare class TargetingType {
static IDENTIFIER: TargetingType;
static PROPERTY: TargetingType;
static SEGMENT: TargetingType;
private supportedKeyTypes;
constructor(...supportedKeyTypes: TargetKeyType[]);
supports(keyType: TargetKeyType): boolean;
}
//# sourceMappingURL=model.d.ts.map

@@ -7,2 +7,3 @@ import { List, Long } from "../model/model";

events: List<EventTypeDto>;
segments: List<SegmentDto>;
}

@@ -26,2 +27,3 @@ export interface ExperimentDto {

userOverrides: List<UserOverrideDto>;
segmentOverrides: List<TargetRuleDto>;
targetAudiences: List<TargetDto>;

@@ -76,2 +78,8 @@ targetRules: List<TargetRuleDto>;

}
export interface SegmentDto {
id: Long;
key: string;
type: string;
targets: List<TargetDto>;
}
//# sourceMappingURL=dto.d.ts.map

@@ -1,2 +0,2 @@

import { Bucket, BucketId, EventKey, EventType, Experiment, ExperimentKey } from "../model/model";
import { Bucket, BucketId, EventKey, EventType, Experiment, ExperimentKey, Segment, SegmentKey } from "../model/model";
import { WorkspaceDto } from "./dto";

@@ -8,3 +8,4 @@ export default class Workspace {

private eventTypes;
constructor(experiments: Map<ExperimentKey, Experiment>, featureFlags: Map<ExperimentKey, Experiment>, buckets: Map<BucketId, Bucket>, eventTypes: Map<EventKey, EventType>);
private segments;
constructor(experiments: Map<ExperimentKey, Experiment>, featureFlags: Map<ExperimentKey, Experiment>, buckets: Map<BucketId, Bucket>, eventTypes: Map<EventKey, EventType>, segments: Map<SegmentKey, Segment>);
getExperimentOrNull(experimentKey: ExperimentKey): Experiment | undefined;

@@ -14,2 +15,3 @@ getFeatureFlagOrNull(featureKey: ExperimentKey): Experiment | undefined;

getEventTypeOrNull(eventKey: EventKey): EventType;
getSegmentOrNull(segmentKey: SegmentKey): Segment | undefined;
static from(dto: WorkspaceDto): Workspace;

@@ -25,2 +27,3 @@ private static toBucket;

private static toTargetMatchOrNull;
private static toSegmentOrNull;
private static parseOrNull;

@@ -27,0 +30,0 @@ private static mapNotUndefined;

{
"name": "@hackler/sdk-core",
"version": "3.2.0",
"version": "3.3.0",
"description": "JavaScript SDK-core",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc