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.4.3 to 3.4.4

lib/internal/util/NullCheckUtil.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 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}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function u(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=e.log,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,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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}(),E=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}(),v=function(t,e){this.id=t,this.key=e},d=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),m=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:c.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),N=function(t){this.conditions=t},R=function(t,e){this.key=t,this.match=e},_=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},I=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},O=function(t,e){this.target=t,this.action=e},w=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 M=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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new F(parseInt(i,10),parseInt(u,10),parseInt(a,10)),b.parse(c),b.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}(),F=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}(),b=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}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"],D=["STRING","NUMBER","BOOLEAN","VERSION"],S=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],C=["VARIATION","BUCKET"],U=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],L=["USER_ID","USER_PROPERTY"],k=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}(),x=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}(),H=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new G((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new V((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),G=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[d.ID],identifiers:this.user.identifiers,userProperties:x.filteredProperties(this.user.properties||{}),hackleProperties:x.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(H),V=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[d.ID],identifiers:this.user.identifiers,userProperties:x.filteredProperties(this.user.properties||{}),hackleProperties:x.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:x.filteredProperties(this.event.properties||{})}},e}(H),B=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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),K=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),Y=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),X=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),z=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}(),W=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}(),q=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}(),$=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}(),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.isLessThanOrEqualTo(e)},t}(),tt=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 z,t.CONTAINS_MATCHER=new W,t.STARTS_WITH_MATCHER=new j,t.ENDS_WITH_MATCHER=new q,t.GT_MATCHER=new Z,t.GTE_MATCHER=new $,t.LT_MATCHER=new Q,t.LTE_MATCHER=new J,t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),it=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=M.tryParse(e),i=M.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),ot=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 et,t.NUMBER_MATCHER=new rt,t.BOOLEAN_MATCHER=new nt,t.VERSION_MATCHER=new it,t}(),ut=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!!n&&this.valueOperatorMatcher.matches(n,t.match)},t}(),st=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),at=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),ct=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),ft=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 ut(new st,new X(new ot,new tt)),t.SEGMENT_CONDITION_MATCHER=new at(new ct(t.USER_CONDITION_MATCHER)),t}(),pt=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),ht={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},lt=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=ht.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),Et=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):B.of(e,n,h.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=a(n.reverse()),s=u.next();!s.done;s=u.next()){var c=s.value;o=new t(c,o)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),yt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return B.withVariation(o,h.OVERRIDDEN);case"FEATURE_FLAG":return B.withVariation(o,h.INDIVIDUAL_TARGET_MATCH)}},t}(),Tt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?B.of(e,n,h.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return B.of(e,n,h.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return B.of(e,n,h.FEATURE_FLAG_INACTIVE)}},t}(),dt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return B.withVariation(o,h.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),mt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):B.of(e,n,h.NOT_IN_EXPERIMENT_TARGET)},t}(),Nt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?B.of(e,n,h.VARIATION_DROPPED):B.withVariation(o,h.TRAFFIC_ALLOCATED):B.of(e,n,h.TRAFFIC_NOT_ALLOCATED)},t}(),Rt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return B.withVariation(u,h.TARGET_RULE_MATCH)},t}(),_t=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return B.of(e,n,h.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return B.withVariation(o,h.DEFAULT_RULE)},t}(),At=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),It=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),Ot=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),wt=function(){function t(){var t=new Y(new ft),e=new pt(new lt),r=new Ot(t,e);this.abTestFlow=Et.of(new yt(r),new mt(new At(t)),new Tt,new vt,new dt,new Nt(e)),this.featureFlagFlow=Et.of(new Tt,new vt,new dt,new yt(r),new Rt(new It(t),e),new _t(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),gt=e.log,Mt=function(){function t(t,e,r){this.evaluator=new K(new wt),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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return gt.error("experimentKey must not be empty"),f.of(r,h.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return gt.warn("SDK not ready."),f.of(r,h.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return gt.warn("Experiment does not exist."),f.of(r,h.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(H.exposure(i,e,o)),f.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return gt.error("featureKey must not be empty"),p.off(h.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return gt.warn("SDK not ready."),p.off(h.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return gt.warn("FeatureFlag does not exist."),p.off(h.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(H.exposure(n,e,i)),"A"===i.variationKey?p.off(i.reason):p.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new v(0,t.key);this.eventProcessor.process(H.track(n,t,e))}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=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;gt.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),o=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(o),e({success:!0})}),(function(t){clearTimeout(o),e({success:!1,error:t})})),Promise.race([this.readyPromise,i]).then((function(t){return t.success?gt.debug("HackleClient onInitialized Success"):t.error instanceof Error?gt.error("HackleClient onInitialized Failed. ".concat(t.error.message)):gt.error("HackleClient onInitialized Failed. ".concat(t.error)),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();function Ft(t){var e=new Array,r=new Array;return t.forEach((function(t){H.isExposure(t)?e.push(t.toDto()):H.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}}var bt=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}(),Pt=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 bt({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}(),Dt=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 Pt(this.drainQueue.bind(this),St,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 St(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var Ct=e.log,Ut=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},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,i=this.experimentStatusOrNull(r.execution.status),o=r.variations.map((function(t){return new E(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,k.IDENTIFIER)})),a=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t,k.PROPERTY)})),c=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t,k.PROPERTY)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return i&&f&&new l(r.id,r.key,e,r.identifierType,i,r.version,o,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 Ct.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 O(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(C,t.type);return e&&new I(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new N(i)},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 R(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(U,t.type);return e&&new _(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(P,t.type),r=this.parseOrNull(S,t.operator),n=this.parseOrNull(D,t.valueType);return e&&r&&n&&new A(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(L,t.type);return r&&new w(t.id,t.key,r,this.mapNotUndefined(t.targets,(function(t){return e.toTargetOrNull(t,k.SEGMENT)})))},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||Ct.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,F as CoreVersion,r as DEFAULT_ON_READY_TIMEOUT,f as Decision,h as DecisionReason,Pt as DefaultEventQueue,H as Event,Dt as EventProcessor,v as EventType,l as Experiment,G as Exposure,p as FeatureFlagDecision,Mt as HackleInternalClient,d as IdentifierType,m as IdentifiersBuilder,e as Logger,S as MATCH_OPERATORS,P as MATCH_TYPES,D as MATCH_VALUE_TYPES,b as MetaVersion,L as SEGMENT_TYPES,w as Segment,T as Slot,C as TARGET_ACTION_TYPES,U as TARGET_KEY_TYPES,N as Target,I as TargetAction,R as TargetCondition,_ as TargetKey,A as TargetMatch,O as TargetRule,k as TargetingType,V as Track,E as Variation,M as Version,Ut as Workspace,t as logLevels,Ft 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 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}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function u(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=e.log,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,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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}(),E=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}(),v=function(t,e){this.id=t,this.key=e},d=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),N=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:c.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),m=function(t){this.conditions=t},R=function(t,e){this.key=t,this.match=e},_=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},O=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},I=function(t,e){this.target=t,this.action=e},w=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 M=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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new F(parseInt(i,10),parseInt(u,10),parseInt(a,10)),b.parse(c),b.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}(),F=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}(),b=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}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"],D=["STRING","NUMBER","BOOLEAN","VERSION"],S=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],U=["VARIATION","BUCKET"],C=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],L=["USER_ID","USER_PROPERTY"],k=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}(),x=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}(),H=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new G((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new V((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),G=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[d.ID],identifiers:this.user.identifiers,userProperties:x.filteredProperties(this.user.properties||{}),hackleProperties:x.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(H),V=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return i(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[d.ID],identifiers:this.user.identifiers,userProperties:x.filteredProperties(this.user.properties||{}),hackleProperties:x.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:x.filteredProperties(this.event.properties||{})}},e}(H),B=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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),K=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),Y=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),X=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),z=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}(),W=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}(),q=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}(),$=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}(),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.isLessThanOrEqualTo(e)},t}(),tt=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 z,t.CONTAINS_MATCHER=new W,t.STARTS_WITH_MATCHER=new j,t.ENDS_WITH_MATCHER=new q,t.GT_MATCHER=new Z,t.GTE_MATCHER=new $,t.LT_MATCHER=new Q,t.LTE_MATCHER=new J,t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),it=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=M.tryParse(e),i=M.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),ot=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 et,t.NUMBER_MATCHER=new rt,t.BOOLEAN_MATCHER=new nt,t.VERSION_MATCHER=new it,t}(),ut=function(){function t(){}return t.isNullOrUndefined=function(t){return null==t},t}(),st=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!ut.isNullOrUndefined(n)&&this.valueOperatorMatcher.matches(n,t.match)},t}(),at=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),ct=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),ft=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),pt=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 st(new at,new X(new ot,new tt)),t.SEGMENT_CONDITION_MATCHER=new ct(new ft(t.USER_CONDITION_MATCHER)),t}(),ht=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),lt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},Et=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=lt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),yt=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):B.of(e,n,h.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=a(n.reverse()),s=u.next();!s.done;s=u.next()){var c=s.value;o=new t(c,o)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),Tt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return B.withVariation(o,h.OVERRIDDEN);case"FEATURE_FLAG":return B.withVariation(o,h.INDIVIDUAL_TARGET_MATCH)}},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?B.of(e,n,h.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),dt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return B.of(e,n,h.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return B.of(e,n,h.FEATURE_FLAG_INACTIVE)}},t}(),Nt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return B.withVariation(o,h.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),mt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):B.of(e,n,h.NOT_IN_EXPERIMENT_TARGET)},t}(),Rt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?B.of(e,n,h.VARIATION_DROPPED):B.withVariation(o,h.TRAFFIC_ALLOCATED):B.of(e,n,h.TRAFFIC_NOT_ALLOCATED)},t}(),_t=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return B.withVariation(u,h.TARGET_RULE_MATCH)},t}(),At=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return B.of(e,n,h.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return B.withVariation(o,h.DEFAULT_RULE)},t}(),Ot=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),It=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),wt=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),gt=function(){function t(){var t=new Y(new pt),e=new ht(new Et),r=new wt(t,e);this.abTestFlow=yt.of(new Tt(r),new mt(new Ot(t)),new vt,new dt,new Nt,new Rt(e)),this.featureFlagFlow=yt.of(new vt,new dt,new Nt,new Tt(r),new _t(new It(t),e),new At(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),Mt=e.log,Ft=function(){function t(t,e,r){this.evaluator=new K(new gt),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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return Mt.error("experimentKey must not be empty"),f.of(r,h.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Mt.warn("SDK not ready."),f.of(r,h.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return Mt.warn("Experiment does not exist."),f.of(r,h.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(H.exposure(i,e,o)),f.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return Mt.error("featureKey must not be empty"),p.off(h.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return Mt.warn("SDK not ready."),p.off(h.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return Mt.warn("FeatureFlag does not exist."),p.off(h.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(H.exposure(n,e,i)),"A"===i.variationKey?p.off(i.reason):p.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new v(0,t.key);this.eventProcessor.process(H.track(n,t,e))}else Mt.warn("Event key must be not null. or event key must be string type.");else Mt.warn("Event must be event type.");else Mt.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;Mt.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),o=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(o),e({success:!0})}),(function(t){clearTimeout(o),e({success:!1,error:t})})),Promise.race([this.readyPromise,i]).then((function(t){return t.success?Mt.debug("HackleClient onInitialized Success"):t.error instanceof Error?Mt.error("HackleClient onInitialized Failed. ".concat(t.error.message)):Mt.error("HackleClient onInitialized Failed. ".concat(t.error)),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();function bt(t){var e=new Array,r=new Array;return t.forEach((function(t){H.isExposure(t)?e.push(t.toDto()):H.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}}var Pt=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}(),Dt=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 Pt({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}(),St=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 Dt(this.drainQueue.bind(this),Ut,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 Ut(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var Ct=e.log,Lt=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},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,i=this.experimentStatusOrNull(r.execution.status),o=r.variations.map((function(t){return new E(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,k.IDENTIFIER)})),a=t.mapNotUndefined(r.execution.targetAudiences,(function(t){return n.toTargetOrNull(t,k.PROPERTY)})),c=t.mapNotUndefined(r.execution.targetRules,(function(t){return n.toTargetRuleOrNull(t,k.PROPERTY)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return i&&f&&new l(r.id,r.key,e,r.identifierType,i,r.version,o,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 Ct.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 I(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(U,t.type);return e&&new O(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new m(i)},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 R(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(C,t.type);return e&&new _(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(P,t.type),r=this.parseOrNull(S,t.operator),n=this.parseOrNull(D,t.valueType);return e&&r&&n&&new A(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(L,t.type);return r&&new w(t.id,t.key,r,this.mapNotUndefined(t.targets,(function(t){return e.toTargetOrNull(t,k.SEGMENT)})))},t.parseOrNull=function(t,e){var r=t.find((function(t){return t===e}));return r||Ct.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,F as CoreVersion,r as DEFAULT_ON_READY_TIMEOUT,f as Decision,h as DecisionReason,Dt as DefaultEventQueue,H as Event,St as EventProcessor,v as EventType,l as Experiment,G as Exposure,p as FeatureFlagDecision,Ft as HackleInternalClient,d as IdentifierType,N as IdentifiersBuilder,e as Logger,S as MATCH_OPERATORS,P as MATCH_TYPES,D as MATCH_VALUE_TYPES,b as MetaVersion,L as SEGMENT_TYPES,w as Segment,T as Slot,U as TARGET_ACTION_TYPES,C as TARGET_KEY_TYPES,m as Target,O as TargetAction,R as TargetCondition,_ as TargetKey,A as TargetMatch,I as TargetRule,k as TargetingType,V as Track,E as Variation,M as Version,Lt as Workspace,t as logLevels,bt 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 i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=e.log,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,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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},T=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}(),y=function(t,e){this.id=t,this.key=e},v=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),d=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:a.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),m=function(t){this.conditions=t},N=function(t,e){this.key=t,this.match=e},R=function(t,e){this.type=t,this.name=e},_=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},g=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 O(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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new M(parseInt(i,10),parseInt(u,10),parseInt(a,10)),P.parse(c),P.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}(),M=function(){function t(t,e,r){this.major=t,this.minor=e,this.patch=r}return t.prototype.compareTo=function(t){return O(this.major,t.major)||O(this.minor,t.minor)||O(this.patch,t.patch)},t}(),P=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}return O(this.identifiers.length,e.identifiers.length)},t.compareIdentifiers=function(e,r){return t.numericIdentifierRegExp.test(e)&&t.numericIdentifierRegExp.test(r)?O(+e,+r):e===r?0:e<r?-1:1},t.EMPTY=new t([]),t.numericIdentifierRegExp=/^(0|[1-9]\d*)$/,t}(),F=["MATCH","NOT_MATCH"],D=["STRING","NUMBER","BOOLEAN","VERSION"],x=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],b=["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 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}(),k=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new H((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new V((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),H=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[v.ID],identifiers:this.user.identifiers,userProperties:L.filteredProperties(this.user.properties||{}),hackleProperties:L.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(k),V=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[v.ID],identifiers:this.user.identifiers,userProperties:L.filteredProperties(this.user.properties||{}),hackleProperties:L.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:L.filteredProperties(this.event.properties||{})}},e}(k),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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),B=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),K=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),Y=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),X=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}(),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.includes(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!1},t.prototype.stringMatches=function(t,e){return t.startsWith(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.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},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.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}(),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}(),$=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 X,t.CONTAINS_MATCHER=new z,t.STARTS_WITH_MATCHER=new W,t.ENDS_WITH_MATCHER=new j,t.GT_MATCHER=new q,t.GTE_MATCHER=new Z,t.LT_MATCHER=new Q,t.LTE_MATCHER=new $,t}(),tt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=w.tryParse(e),i=w.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),it=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 tt,t.NUMBER_MATCHER=new et,t.BOOLEAN_MATCHER=new rt,t.VERSION_MATCHER=new nt,t}(),ot=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!!n&&this.valueOperatorMatcher.matches(n,t.match)},t}(),ut=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),st=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),at=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),ct=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 ut,new Y(new it,new J)),t.SEGMENT_CONDITION_MATCHER=new st(new at(t.USER_CONDITION_MATCHER)),t}(),ft=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),pt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},ht=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=pt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),lt=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):G.of(e,n,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=s(n.reverse()),a=u.next();!a.done;a=u.next()){var c=a.value;o=new t(c,o)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),Tt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return G.withVariation(o,p.OVERRIDDEN);case"FEATURE_FLAG":return G.withVariation(o,p.INDIVIDUAL_TARGET_MATCH)}},t}(),Et=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?G.of(e,n,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),yt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return G.of(e,n,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return G.of(e,n,p.FEATURE_FLAG_INACTIVE)}},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return G.withVariation(o,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),dt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):G.of(e,n,p.NOT_IN_EXPERIMENT_TARGET)},t}(),mt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?G.of(e,n,p.VARIATION_DROPPED):G.withVariation(o,p.TRAFFIC_ALLOCATED):G.of(e,n,p.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,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(u,p.TARGET_RULE_MATCH)},t}(),Rt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return G.of(e,n,p.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(o,p.DEFAULT_RULE)},t}(),_t=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),At=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),gt=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),It=function(){function t(){var t=new K(new ct),e=new ft(new ht),r=new gt(t,e);this.abTestFlow=lt.of(new Tt(r),new dt(new _t(t)),new Et,new yt,new vt,new mt(e)),this.featureFlagFlow=lt.of(new Et,new yt,new vt,new Tt(r),new Nt(new At(t),e),new Rt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),Ot=e.log,wt=function(){function t(t,e,r){this.evaluator=new B(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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return Ot.error("experimentKey must not be empty"),c.of(r,p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Ot.warn("SDK not ready."),c.of(r,p.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return Ot.warn("Experiment does not exist."),c.of(r,p.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(k.exposure(i,e,o)),c.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return Ot.error("featureKey must not be empty"),f.off(p.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return Ot.warn("SDK not ready."),f.off(p.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return Ot.warn("FeatureFlag does not exist."),f.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(k.exposure(n,e,i)),"A"===i.variationKey?f.off(i.reason):f.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new y(0,t.key);this.eventProcessor.process(k.track(n,t,e))}else Ot.warn("Event key must be not null. or event key must be string type.");else Ot.warn("Event must be event type.");else Ot.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;Ot.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),o=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(o),e({success:!0})}),(function(t){clearTimeout(o),e({success:!1,error:t})})),Promise.race([this.readyPromise,i]).then((function(t){return t.success?Ot.debug("HackleClient onInitialized Success"):t.error instanceof Error?Ot.error("HackleClient onInitialized Failed. ".concat(t.error.message)):Ot.error("HackleClient onInitialized Failed. ".concat(t.error)),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();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}(),Pt=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}(),Ft=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 Pt(this.drainQueue.bind(this),Dt,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 o(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 Dt(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var xt=e.log,bt=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},t.toBucket=function(t){return new T(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,i=this.experimentStatusOrNull(r.execution.status),o=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 i&&f&&new h(r.id,r.key,e,r.identifierType,i,r.version,o,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 xt.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 g(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(b,t.type);return e&&new A(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new m(i)},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 R(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(F,t.type),r=this.parseOrNull(x,t.operator),n=this.parseOrNull(D,t.valueType);return e&&r&&n&&new _(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||xt.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=T,exports.CoreVersion=M,exports.DEFAULT_ON_READY_TIMEOUT=3e3,exports.Decision=c,exports.DecisionReason=p,exports.DefaultEventQueue=Pt,exports.Event=k,exports.EventProcessor=Ft,exports.EventType=y,exports.Experiment=h,exports.Exposure=H,exports.FeatureFlagDecision=f,exports.HackleInternalClient=wt,exports.IdentifierType=v,exports.IdentifiersBuilder=d,exports.Logger=e,exports.MATCH_OPERATORS=x,exports.MATCH_TYPES=F,exports.MATCH_VALUE_TYPES=D,exports.MetaVersion=P,exports.SEGMENT_TYPES=C,exports.Segment=I,exports.Slot=E,exports.TARGET_ACTION_TYPES=b,exports.TARGET_KEY_TYPES=S,exports.Target=m,exports.TargetAction=A,exports.TargetCondition=N,exports.TargetKey=R,exports.TargetMatch=_,exports.TargetRule=g,exports.TargetingType=U,exports.Track=V,exports.Variation=l,exports.Version=w,exports.Workspace=bt,exports.logLevels=t,exports.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}};
"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 i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=e.log,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,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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},T=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}(),y=function(t,e){this.id=t,this.key=e},v=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),d=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:a.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),N=function(t){this.conditions=t},m=function(t,e){this.key=t,this.match=e},R=function(t,e){this.type=t,this.name=e},_=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},O=function(t,e){this.target=t,this.action=e},g=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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new M(parseInt(i,10),parseInt(u,10),parseInt(a,10)),P.parse(c),P.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}(),M=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}(),P=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}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}(),F=["MATCH","NOT_MATCH"],D=["STRING","NUMBER","BOOLEAN","VERSION"],x=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],b=["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 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}(),k=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new H((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new V((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),H=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[v.ID],identifiers:this.user.identifiers,userProperties:L.filteredProperties(this.user.properties||{}),hackleProperties:L.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(k),V=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return n(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[v.ID],identifiers:this.user.identifiers,userProperties:L.filteredProperties(this.user.properties||{}),hackleProperties:L.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:L.filteredProperties(this.event.properties||{})}},e}(k),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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),B=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),K=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),Y=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),X=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}(),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.includes(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!1},t.prototype.stringMatches=function(t,e){return t.startsWith(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.endsWith(e)},t.prototype.versionMatches=function(t,e){return!1},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.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}(),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}(),$=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 X,t.CONTAINS_MATCHER=new z,t.STARTS_WITH_MATCHER=new W,t.ENDS_WITH_MATCHER=new j,t.GT_MATCHER=new q,t.GTE_MATCHER=new Z,t.LT_MATCHER=new Q,t.LTE_MATCHER=new $,t}(),tt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),et=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=w.tryParse(e),i=w.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),it=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 tt,t.NUMBER_MATCHER=new et,t.BOOLEAN_MATCHER=new rt,t.VERSION_MATCHER=new nt,t}(),ot=function(){function t(){}return t.isNullOrUndefined=function(t){return null==t},t}(),ut=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!ot.isNullOrUndefined(n)&&this.valueOperatorMatcher.matches(n,t.match)},t}(),st=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),at=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),ct=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),ft=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 ut(new st,new Y(new it,new J)),t.SEGMENT_CONDITION_MATCHER=new at(new ct(t.USER_CONDITION_MATCHER)),t}(),pt=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),ht={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},lt=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=ht.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),Tt=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):G.of(e,n,p.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=s(n.reverse()),a=u.next();!a.done;a=u.next()){var c=a.value;o=new t(c,o)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),Et=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return G.withVariation(o,p.OVERRIDDEN);case"FEATURE_FLAG":return G.withVariation(o,p.INDIVIDUAL_TARGET_MATCH)}},t}(),yt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?G.of(e,n,p.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return G.of(e,n,p.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return G.of(e,n,p.FEATURE_FLAG_INACTIVE)}},t}(),dt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return G.withVariation(o,p.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),Nt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):G.of(e,n,p.NOT_IN_EXPERIMENT_TARGET)},t}(),mt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?G.of(e,n,p.VARIATION_DROPPED):G.withVariation(o,p.TRAFFIC_ALLOCATED):G.of(e,n,p.TRAFFIC_NOT_ALLOCATED)},t}(),Rt=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(u,p.TARGET_RULE_MATCH)},t}(),_t=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return G.of(e,n,p.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return G.withVariation(o,p.DEFAULT_RULE)},t}(),At=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),Ot=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),gt=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),It=function(){function t(){var t=new K(new ft),e=new pt(new lt),r=new gt(t,e);this.abTestFlow=Tt.of(new Et(r),new Nt(new At(t)),new yt,new vt,new dt,new mt(e)),this.featureFlagFlow=Tt.of(new yt,new vt,new dt,new Et(r),new Rt(new Ot(t),e),new _t(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),wt=e.log,Mt=function(){function t(t,e,r){this.evaluator=new B(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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return wt.error("experimentKey must not be empty"),c.of(r,p.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return wt.warn("SDK not ready."),c.of(r,p.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return wt.warn("Experiment does not exist."),c.of(r,p.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(k.exposure(i,e,o)),c.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return wt.error("featureKey must not be empty"),f.off(p.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return wt.warn("SDK not ready."),f.off(p.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return wt.warn("FeatureFlag does not exist."),f.off(p.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(k.exposure(n,e,i)),"A"===i.variationKey?f.off(i.reason):f.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new y(0,t.key);this.eventProcessor.process(k.track(n,t,e))}else wt.warn("Event key must be not null. or event key must be string type.");else wt.warn("Event must be event type.");else wt.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;wt.debug("Start HackleClient initializing");var i=new Promise((function(t){e=t})),o=setTimeout((function(){e({success:!1})}),n);return this.readyPromise.then((function(){clearTimeout(o),e({success:!0})}),(function(t){clearTimeout(o),e({success:!1,error:t})})),Promise.race([this.readyPromise,i]).then((function(t){return t.success?wt.debug("HackleClient onInitialized Success"):t.error instanceof Error?wt.error("HackleClient onInitialized Failed. ".concat(t.error.message)):wt.error("HackleClient onInitialized Failed. ".concat(t.error)),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var Pt=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}(),Ft=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 Pt({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}(),Dt=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 Ft(this.drainQueue.bind(this),xt,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 o(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 xt(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var bt=e.log,St=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},t.toBucket=function(t){return new T(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,i=this.experimentStatusOrNull(r.execution.status),o=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 i&&f&&new h(r.id,r.key,e,r.identifierType,i,r.version,o,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 bt.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 O(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(b,t.type);return e&&new A(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new N(i)},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 m(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(S,t.type);return e&&new R(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(F,t.type),r=this.parseOrNull(x,t.operator),n=this.parseOrNull(D,t.valueType);return e&&r&&n&&new _(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(C,t.type);return r&&new g(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||bt.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=T,exports.CoreVersion=M,exports.DEFAULT_ON_READY_TIMEOUT=3e3,exports.Decision=c,exports.DecisionReason=p,exports.DefaultEventQueue=Ft,exports.Event=k,exports.EventProcessor=Dt,exports.EventType=y,exports.Experiment=h,exports.Exposure=H,exports.FeatureFlagDecision=f,exports.HackleInternalClient=Mt,exports.IdentifierType=v,exports.IdentifiersBuilder=d,exports.Logger=e,exports.MATCH_OPERATORS=x,exports.MATCH_TYPES=F,exports.MATCH_VALUE_TYPES=D,exports.MetaVersion=P,exports.SEGMENT_TYPES=C,exports.Segment=g,exports.Slot=E,exports.TARGET_ACTION_TYPES=b,exports.TARGET_KEY_TYPES=S,exports.Target=N,exports.TargetAction=A,exports.TargetCondition=m,exports.TargetKey=R,exports.TargetMatch=_,exports.TargetRule=O,exports.TargetingType=U,exports.Track=V,exports.Variation=l,exports.Version=w,exports.Workspace=St,exports.logLevels=t,exports.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}};
//# 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,i=function(t,e){return i=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])},i(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}i(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 i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},u.apply(this,arguments)};function s(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=r.log,p=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),h=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}(),l=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}(),T=function(){function t(t,e,r,n,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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}(),E=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},d=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},m=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),N=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:f.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),R=function(t){this.conditions=t},_=function(t,e){this.key=t,this.match=e},A=function(t,e){this.type=t,this.name=e},g=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},I=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},O=function(t,e){this.target=t,this.action=e},w=function(t,e,r,n){this.id=t,this.key=e,this.type=r,this.targets=n};function M(t,e){return t-e}var P=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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new F(parseInt(i,10),parseInt(u,10),parseInt(a,10)),D.parse(c),D.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}(),F=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}(),D=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}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}(),b=["MATCH","NOT_MATCH"],S=["STRING","NUMBER","BOOLEAN","VERSION"],C=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],U=["VARIATION","BUCKET"],L=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],k=["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}(),H=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 u(u({},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}(),V=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new G((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new B((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),G=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[m.ID],identifiers:this.user.identifiers,userProperties:H.filteredProperties(this.user.properties||{}),hackleProperties:H.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(V),B=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[m.ID],identifiers:this.user.identifiers,userProperties:H.filteredProperties(this.user.properties||{}),hackleProperties:H.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:H.filteredProperties(this.event.properties||{})}},e}(V),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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),Y=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),X=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),z=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),j=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}(),W=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}(),q=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}(),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.isGreaterThan(e)},t}(),$=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}(),tt=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}(),et=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 j,t.CONTAINS_MATCHER=new W,t.STARTS_WITH_MATCHER=new q,t.ENDS_WITH_MATCHER=new Z,t.GT_MATCHER=new Q,t.GTE_MATCHER=new $,t.LT_MATCHER=new J,t.LTE_MATCHER=new tt,t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),it=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),ot=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=P.tryParse(e),i=P.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),ut=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 rt,t.NUMBER_MATCHER=new nt,t.BOOLEAN_MATCHER=new it,t.VERSION_MATCHER=new ot,t}(),st=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!!n&&this.valueOperatorMatcher.matches(n,t.match)},t}(),at=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),ct=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),ft=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),pt=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 st(new at,new z(new ut,new et)),t.SEGMENT_CONDITION_MATCHER=new ct(new ft(t.USER_CONDITION_MATCHER)),t}(),ht=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),lt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},Tt=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=lt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),Et=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):K.of(e,n,l.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=c(n.reverse()),s=u.next();!s.done;s=u.next()){var a=s.value;o=new t(a,o)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),yt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return K.withVariation(o,l.OVERRIDDEN);case"FEATURE_FLAG":return K.withVariation(o,l.INDIVIDUAL_TARGET_MATCH)}},t}(),dt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?K.of(e,n,l.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return K.of(e,n,l.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return K.of(e,n,l.FEATURE_FLAG_INACTIVE)}},t}(),mt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return K.withVariation(o,l.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),Nt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):K.of(e,n,l.NOT_IN_EXPERIMENT_TARGET)},t}(),Rt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?K.of(e,n,l.VARIATION_DROPPED):K.withVariation(o,l.TRAFFIC_ALLOCATED):K.of(e,n,l.TRAFFIC_NOT_ALLOCATED)},t}(),_t=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return K.withVariation(u,l.TARGET_RULE_MATCH)},t}(),At=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return K.of(e,n,l.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return K.withVariation(o,l.DEFAULT_RULE)},t}(),gt=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),It=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),Ot=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),wt=function(){function t(){var t=new X(new pt),e=new ht(new Tt),r=new Ot(t,e);this.abTestFlow=Et.of(new yt(r),new Nt(new gt(t)),new dt,new vt,new mt,new Rt(e)),this.featureFlagFlow=Et.of(new dt,new vt,new mt,new yt(r),new _t(new It(t),e),new At(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),Mt=r.log,Pt=function(){function t(t,e,r){this.evaluator=new Y(new wt),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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return Mt.error("experimentKey must not be empty"),p.of(r,l.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Mt.warn("SDK not ready."),p.of(r,l.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return Mt.warn("Experiment does not exist."),p.of(r,l.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(V.exposure(i,e,o)),p.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return Mt.error("featureKey must not be empty"),h.off(l.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return Mt.warn("SDK not ready."),h.off(l.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return Mt.warn("FeatureFlag does not exist."),h.off(l.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(V.exposure(n,e,i)),"A"===i.variationKey?h.off(i.reason):h.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new v(0,t.key);this.eventProcessor.process(V.track(n,t,e))}else Mt.warn("Event key must be not null. or event key must be string type.");else Mt.warn("Event must be event type.");else Mt.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,i=void 0===r?n:r;Mt.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),u=setTimeout((function(){e({success:!1})}),i);return this.readyPromise.then((function(){clearTimeout(u),e({success:!0})}),(function(t){clearTimeout(u),e({success:!1,error:t})})),Promise.race([this.readyPromise,o]).then((function(t){return t.success?Mt.debug("HackleClient onInitialized Success"):t.error instanceof Error?Mt.error("HackleClient onInitialized Failed. ".concat(t.error.message)):Mt.error("HackleClient onInitialized Failed. ".concat(t.error)),Promise.resolve({success:t.success})}))},t.prototype._close=function(){this.workspaceFetcher.close(),this.eventProcessor.close()},t}();var Ft=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}(),Dt=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 Ft({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 Dt(this.drainQueue.bind(this),St,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 St(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var Ct=r.log,Ut=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},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 d(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,i=this.experimentStatusOrNull(r.execution.status),o=r.variations.map((function(t){return new E(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)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return i&&f&&new T(r.id,r.key,e,r.identifierType,i,r.version,o,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 Ct.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 O(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(U,t.type);return e&&new I(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new R(i)},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 _(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(L,t.type);return e&&new A(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(b,t.type),r=this.parseOrNull(C,t.operator),n=this.parseOrNull(S,t.valueType);return e&&r&&n&&new g(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(k,t.type);return r&&new w(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||Ct.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=F,t.DEFAULT_ON_READY_TIMEOUT=n,t.Decision=p,t.DecisionReason=l,t.DefaultEventQueue=Dt,t.Event=V,t.EventProcessor=bt,t.EventType=v,t.Experiment=T,t.Exposure=G,t.FeatureFlagDecision=h,t.HackleInternalClient=Pt,t.IdentifierType=m,t.IdentifiersBuilder=N,t.Logger=r,t.MATCH_OPERATORS=C,t.MATCH_TYPES=b,t.MATCH_VALUE_TYPES=S,t.MetaVersion=D,t.SEGMENT_TYPES=k,t.Segment=w,t.Slot=d,t.TARGET_ACTION_TYPES=U,t.TARGET_KEY_TYPES=L,t.Target=R,t.TargetAction=I,t.TargetCondition=_,t.TargetKey=A,t.TargetMatch=g,t.TargetRule=O,t.TargetingType=x,t.Track=B,t.Variation=E,t.Version=P,t.Workspace=Ut,t.logLevels=e,t.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){V.isExposure(t)?e.push(t.toDto()):V.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,i=function(t,e){return i=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])},i(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}i(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 i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},u.apply(this,arguments)};function s(t,e,r,n){return new(r||(r=Promise))((function(i,o){function u(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(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,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,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=r.log,p=function(){function t(t,e){this.variation=t,this.reason=e}return t.of=function(e,r){return new t(e,r)},t}(),h=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}(),l=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}(),T=function(){function t(t,e,r,n,i,o,u,s,a,c,f,p,h){this.id=t,this.key=e,this.type=r,this.identifierType=n,this.status=i,this.version=o,this.variations=u,this.userOverrides=s,this.segmentOverrides=a,this.targetAudiences=c,this.targetRules=f,this.defaultRule=p,this._winnerVariationId=h}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}(),E=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},d=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},m=function(){function t(){}return t.ID="$id",t.USER="$userId",t.DEVICE="$deviceId",t}(),N=function(){function t(){this.identifiers={}}return t.prototype.addIdentifiers=function(t){for(var e in t)this.add(e,t[e]);return this},t.prototype.add=function(t,e){return e&&this._isValid(t,e)?this.identifiers[t]=e:f.warn("Invalid user identifier [type=".concat(t,", value=").concat(e,"]")),this},t.prototype._isValid=function(t,e){return!!t&&("string"==typeof t&&(!(t.length>128)&&(!!e&&("string"==typeof e&&!(e.length>512)))))},t.prototype.build=function(){return this.identifiers},t}(),R=function(t){this.conditions=t},_=function(t,e){this.key=t,this.match=e},A=function(t,e){this.type=t,this.name=e},g=function(t,e,r,n){this.type=t,this.operator=e,this.valueType=r,this.values=n},O=function(t,e,r){this.type=t,this.variationId=e,this.bucketId=r},I=function(t,e){this.target=t,this.action=e},w=function(t,e,r,n){this.id=t,this.key=e,this.type=r,this.targets=n};function M(t,e){return t-e}var P=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,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}(r,6);n[0];var i=n[1],o=n[2],u=void 0===o?"0":o,s=n[3],a=void 0===s?"0":s,c=n[4],f=n[5];return new t(new F(parseInt(i,10),parseInt(u,10),parseInt(a,10)),D.parse(c),D.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}(),F=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}(),D=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 i=t.compareIdentifiers(this.identifiers[n],e.identifiers[n]);if(0!==i)return i}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}(),b=["MATCH","NOT_MATCH"],S=["STRING","NUMBER","BOOLEAN","VERSION"],C=["IN","CONTAINS","STARTS_WITH","ENDS_WITH","GT","GTE","LT","LTE"],U=["VARIATION","BUCKET"],L=["USER_ID","USER_PROPERTY","HACKLE_PROPERTY","SEGMENT"],k=["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}(),H=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 u(u({},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}(),V=function(){function t(t,e){this.timestamp=t,this.user=e}return t.exposure=function(t,e,r){return new G((new Date).getTime(),e,t,r.variationId,r.variationKey,r.reason)},t.track=function(t,e,r){return new B((new Date).getTime(),r,t,e)},t.isExposure=function(t){return void 0!==t.experiment},t.isTrack=function(t){return void 0!==t.eventType},t}(),G=function(t){function e(e,r,n,i,o,u){var s=t.call(this,e,r)||this;return s.experiment=n,s.variationId=i,s.variationKey=o,s.decisionReason=u,s}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[m.ID],identifiers:this.user.identifiers,userProperties:H.filteredProperties(this.user.properties||{}),hackleProperties:H.filteredProperties(this.user.hackleProperties||{}),experimentId:this.experiment.id,experimentKey:this.experiment.key,experimentType:this.experiment.type,experimentVersion:this.experiment.version,variationId:this.variationId,variationKey:this.variationKey,decisionReason:this.decisionReason.toString()}},e}(V),B=function(t){function e(e,r,n,i){var o=t.call(this,e,r)||this;return o.eventType=n,o.event=i,o}return o(e,t),e.prototype.toDto=function(){return{timestamp:this.timestamp,userId:this.user.identifiers[m.ID],identifiers:this.user.identifiers,userProperties:H.filteredProperties(this.user.properties||{}),hackleProperties:H.filteredProperties(this.user.hackleProperties||{}),eventTypeId:this.eventType.id,eventTypeKey:this.eventType.key,value:this.event.value||0,properties:H.filteredProperties(this.event.properties||{})}},e}(V),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 i=e._getVariationByKeyOrNull(r);return i?t.withVariation(i,n):t.withKey(r,n)},t}(),Y=function(){function t(t){this.evaluationFlowFactory=t}return t.prototype.evaluate=function(t,e,r,n){return this.evaluationFlowFactory.getFlow(e.type).evaluate(t,e,r,n)},t}(),X=function(){function t(t){this.conditionMatcherFactory=t}return t.prototype.matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){return this.conditionMatcherFactory.getMatcher(t.key.type).matches(t,e,r)},t}(),z=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),i=e.values.some((function(e){return r.matches(n,t,e)}));return this._matches(e.type,i)},t.prototype._matches=function(t,e){switch(t){case"MATCH":return e;case"NOT_MATCH":return!e}},t}(),j=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}(),W=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}(),q=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}(),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.isGreaterThan(e)},t}(),$=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}(),tt=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}(),et=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 j,t.CONTAINS_MATCHER=new W,t.STARTS_WITH_MATCHER=new q,t.ENDS_WITH_MATCHER=new Z,t.GT_MATCHER=new Q,t.GTE_MATCHER=new $,t.LT_MATCHER=new J,t.LTE_MATCHER=new tt,t}(),rt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"string"==typeof e&&"string"==typeof r&&t.stringMatches(e,r)},t}(),nt=function(){function t(){}return t.prototype.matches=function(t,e,r){return"number"==typeof e&&"number"==typeof r&&t.numberMatches(e,r)},t}(),it=function(){function t(){}return t.prototype.matches=function(t,e,r){return"boolean"==typeof e&&"boolean"==typeof r&&t.booleanMatches(e,r)},t}(),ot=function(){function t(){}return t.prototype.matches=function(t,e,r){var n=P.tryParse(e),i=P.tryParse(r);return!(!n||!i)&&t.versionMatches(n,i)},t}(),ut=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 rt,t.NUMBER_MATCHER=new nt,t.BOOLEAN_MATCHER=new it,t.VERSION_MATCHER=new ot,t}(),st=function(){function t(){}return t.isNullOrUndefined=function(t){return null==t},t}(),at=function(){function t(t,e){this.userValueResolver=t,this.valueOperatorMatcher=e}return t.prototype.matches=function(t,e,r){var n=this.userValueResolver.resolveOrNull(r,t.key);return!st.isNullOrUndefined(n)&&this.valueOperatorMatcher.matches(n,t.match)},t}(),ct=function(){function t(){}return t.prototype.resolveOrNull=function(t,e){switch(e.type){case"USER_ID":return t.identifiers[e.name];case"USER_PROPERTY":return t.properties[e.name];case"HACKLE_PROPERTY":return t.hackleProperties[e.name];case"SEGMENT":throw new Error("Unsupported TargetKeyType [".concat(e.type,"]"))}},t}(),ft=function(){function t(t){this.segmentMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;if("SEGMENT"!=t.key.type)throw new Error("Unsupported TargetKeyType [".concat(t.key.type,"]"));var i=t.match.values.some((function(t){return n._matches(t,e,r)}));switch(t.match.type){case"MATCH":return i;case"NOT_MATCH":return!i}},t.prototype._matches=function(t,e,r){if("string"!=typeof t)throw new Error("SegmentKey[".concat(t,"]"));var n=e.getSegmentOrNull(t);if(!n)throw new Error("Segment[".concat(t,"]"));return this.segmentMatcher.matches(n,e,r)},t}(),pt=function(){function t(t){this.userConditionMatcher=t}return t.prototype.matches=function(t,e,r){var n=this;return t.targets.some((function(t){return n._matches(t,e,r)}))},t.prototype._matches=function(t,e,r){var n=this;return t.conditions.every((function(t){return n.userConditionMatcher.matches(t,e,r)}))},t}(),ht=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 at(new ct,new z(new ut,new et)),t.SEGMENT_CONDITION_MATCHER=new ft(new pt(t.USER_CONDITION_MATCHER)),t}(),lt=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 i=e.getBucketOrNull(t.bucketId),o=n.identifiers[r.identifierType];if(o){var u=this.bucketer.bucketing(i,o);if(u)return r._getVariationByIdOrNull(u.variationId)}},t}(),Tt={murmurhash3_x86_32:function(t,e,r,n){void 0===n&&(n=t.length);for(var i,o=3432918353,u=461845907,s=-4&n,a=e,c=0;c<s;c+=4)i=255&t.charCodeAt(c)|(255&t.charCodeAt(c+1))<<8|(255&t.charCodeAt(c+2))<<16|(255&t.charCodeAt(c+3))<<24,i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a=5*(a=(524287&(a^=i=this.mul32(i,u)))<<13|a>>>19)+3864292196|0;switch(i=0,n%4){case 3:i=(255&t.charCodeAt(s+2))<<16;case 2:i|=(255&t.charCodeAt(s+1))<<8;case 1:i|=255&t.charCodeAt(s),i=(131071&(i=this.mul32(i,o)))<<15|i>>>17,a^=i=this.mul32(i,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}},Et=function(){function t(){}return t.prototype.bucketing=function(t,e){var r=this.calculateSlotNumber(t.seed,t.slotSize,e);return t.slots.find((function(t){return t.contains(r)}))},t.prototype.calculateSlotNumber=function(t,e,r){var n=Tt.murmurhash3_x86_32(r,t);return Math.abs(n)%Math.abs(e)},t}(),yt=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){return this.flowEvaluator&&this.nextFlow?this.flowEvaluator.evaluate(t,e,r,n,this.nextFlow):K.of(e,n,l.TRAFFIC_NOT_ALLOCATED)},t.of=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=new t;try{for(var u=c(n.reverse()),s=u.next();!s.done;s=u.next()){var a=s.value;o=new t(a,o)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return o},t}(),dt=function(){function t(t){this.overrideResolver=t}return t.prototype.evaluate=function(t,e,r,n,i){var o=this.overrideResolver.resolveOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return K.withVariation(o,l.OVERRIDDEN);case"FEATURE_FLAG":return K.withVariation(o,l.INDIVIDUAL_TARGET_MATCH)}},t}(),vt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){return"DRAFT"===e.status?K.of(e,n,l.EXPERIMENT_DRAFT):i.evaluate(t,e,r,n)},t}(),mt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("PAUSED"!==e.status)return i.evaluate(t,e,r,n);switch(e.type){case"AB_TEST":return K.of(e,n,l.EXPERIMENT_PAUSED);case"FEATURE_FLAG":return K.of(e,n,l.FEATURE_FLAG_INACTIVE)}},t}(),Nt=function(){function t(){}return t.prototype.evaluate=function(t,e,r,n,i){if("COMPLETED"===e.status){var o=e._winnerVariationOrNull();if(!o)throw new Error("winner variation [".concat(e.id,"]"));return K.withVariation(o,l.EXPERIMENT_COMPLETED)}return i.evaluate(t,e,r,n)},t}(),Rt=function(){function t(t){this.experimentTargetDeterminer=t}return t.prototype.evaluate=function(t,e,r,n,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)?i.evaluate(t,e,r,n):K.of(e,n,l.NOT_IN_EXPERIMENT_TARGET)},t}(),_t=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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 o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);return o?o.isDropped?K.of(e,n,l.VARIATION_DROPPED):K.withVariation(o,l.TRAFFIC_ALLOCATED):K.of(e,n,l.TRAFFIC_NOT_ALLOCATED)},t}(),At=function(){function t(t,e){this.targetRuleDeterminer=t,this.actionResolver=e}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return i.evaluate(t,e,r,n);var o=this.targetRuleDeterminer.determineTargetRuleOrNull(t,e,r);if(!o)return i.evaluate(t,e,r,n);var u=this.actionResolver.resolveOrNull(o.action,t,e,r);if(!u)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return K.withVariation(u,l.TARGET_RULE_MATCH)},t}(),gt=function(){function t(t){this.actionResolver=t}return t.prototype.evaluate=function(t,e,r,n,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,"]"));if(!r.identifiers[e.identifierType])return K.of(e,n,l.DEFAULT_RULE);var o=this.actionResolver.resolveOrNull(e.defaultRule,t,e,r);if(!o)throw new Error("FeatureFlag must decide the Variation [".concat(e.id,"]"));return K.withVariation(o,l.DEFAULT_RULE)},t}(),Ot=function(){function t(t){this.targetMatcher=t}return t.prototype.isUserInExperimentTarget=function(t,e,r){var n=this;return 0===e.targetAudiences.length||e.targetAudiences.some((function(e){return n.targetMatcher.matches(e,t,r)}))},t}(),It=function(){function t(t){this.targetMatcher=t}return t.prototype.determineTargetRuleOrNull=function(t,e,r){var n=this;return e.targetRules.find((function(e){return n.targetMatcher.matches(e.target,t,r)}))},t}(),wt=function(){function t(t,e){this.targetMatcher=t,this.actionResolver=e}return t.prototype.resolveOrNull=function(t,e,r){var n=this._resolveUserOverride(e,r);return n||this._resolveSegmentOverride(t,e,r)},t.prototype._resolveUserOverride=function(t,e){var r=e.identifiers[t.identifierType];if(r){var n=t.userOverrides.get(r);if(n)return t._getVariationByIdOrNull(n)}},t.prototype._resolveSegmentOverride=function(t,e,r){var n=this,i=e.segmentOverrides.find((function(e){return n.targetMatcher.matches(e.target,t,r)}));if(i)return this.actionResolver.resolveOrNull(i.action,t,e,r)},t}(),Mt=function(){function t(){var t=new X(new ht),e=new lt(new Et),r=new wt(t,e);this.abTestFlow=yt.of(new dt(r),new Rt(new Ot(t)),new vt,new mt,new Nt,new _t(e)),this.featureFlagFlow=yt.of(new vt,new mt,new Nt,new dt(r),new At(new It(t),e),new gt(e))}return t.prototype.getFlow=function(t){switch(t){case"AB_TEST":return this.abTestFlow;case"FEATURE_FLAG":return this.featureFlagFlow}},t}(),Pt=r.log,Ft=function(){function t(t,e,r){this.evaluator=new Y(new Mt),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(t){return{success:!1,error:t}}))}return t.prototype._experiment=function(t,e,r){if(!t)return Pt.error("experimentKey must not be empty"),p.of(r,l.INVALID_INPUT);var n=this.workspaceFetcher.get();if(!n)return Pt.warn("SDK not ready."),p.of(r,l.SDK_NOT_READY);var i=n.getExperimentOrNull(t);if(!i)return Pt.warn("Experiment does not exist."),p.of(r,l.EXPERIMENT_NOT_FOUND);var o=this.evaluator.evaluate(n,i,e,r);return this.eventProcessor.process(V.exposure(i,e,o)),p.of(o.variationKey,o.reason)},t.prototype._featureFlag=function(t,e){if(!t)return Pt.error("featureKey must not be empty"),h.off(l.INVALID_INPUT);var r=this.workspaceFetcher.get();if(!r)return Pt.warn("SDK not ready."),h.off(l.SDK_NOT_READY);var n=r.getFeatureFlagOrNull(t);if(!n)return Pt.warn("FeatureFlag does not exist."),h.off(l.FEATURE_FLAG_NOT_FOUND);var i=this.evaluator.evaluate(r,n,e,"A");return this.eventProcessor.process(V.exposure(n,e,i)),"A"===i.variationKey?h.off(i.reason):h.on(i.reason)},t.prototype._track=function(t,e){var r;if(t)if("object"==typeof t)if("object"!=typeof t||t.key&&"string"==typeof t.key){var n=(null===(r=this.workspaceFetcher.get())||void 0===r?void 0:r.getEventTypeOrNull(t.key))||new v(0,t.key);this.eventProcessor.process(V.track(n,t,e))}else Pt.warn("Event key must be not null. or event key must be string type.");else Pt.warn("Event must be event type.");else Pt.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,i=void 0===r?n:r;Pt.debug("Start HackleClient initializing");var o=new Promise((function(t){e=t})),u=setTimeout((function(){e({success:!1})}),i);return this.readyPromise.then((function(){clearTimeout(u),e({success:!0})}),(function(t){clearTimeout(u),e({success:!1,error:t})})),Promise.race([this.readyPromise,o]).then((function(t){return t.success?Pt.debug("HackleClient onInitialized Success"):t.error instanceof Error?Pt.error("HackleClient onInitialized Failed. ".concat(t.error.message)):Pt.error("HackleClient onInitialized Failed. ".concat(t.error)),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}(),bt=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}(),St=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 bt(this.drainQueue.bind(this),Ct,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 Ct(t,e){return t.timestamp==e.timestamp&&t.user.identifiers==e.user.identifiers&&t.user.properties==e.user.properties}var Ut=r.log,Lt=function(){function t(t,e,r,n,i){this.experiments=t,this.featureFlags=e,this.buckets=r,this.eventTypes=n,this.segments=i}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){return this.eventTypes.get(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)]})),i=t.associateBy(t.mapNotUndefined(e.experiments,(function(t){return r.toExperimentOrNull("AB_TEST",t)})),(function(t){return t.key})),o=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(i,o,n,u,s)},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 d(e,r,n)})))},t.toExperimentOrNull=function(e,r){var n=this,i=this.experimentStatusOrNull(r.execution.status),o=r.variations.map((function(t){return new E(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)})),f=this.toTargetActionOrNull(r.execution.defaultRule);return i&&f&&new T(r.id,r.key,e,r.identifierType,i,r.version,o,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 Ut.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 I(r,n)},t.toTargetActionOrNull=function(t){var e=this.parseOrNull(U,t.type);return e&&new O(e,t.variationId,t.bucketId)},t.toTargetOrNull=function(e,r){var n=this,i=t.mapNotUndefined(e.conditions,(function(t){return n.toConditionOrNull(t,r)}));return new R(i)},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 _(r,n)}},t.toTargetKeyOrNull=function(t){var e=this.parseOrNull(L,t.type);return e&&new A(e,t.name)},t.toTargetMatchOrNull=function(t){var e=this.parseOrNull(b,t.type),r=this.parseOrNull(C,t.operator),n=this.parseOrNull(S,t.valueType);return e&&r&&n&&new g(e,r,n,t.values)},t.toSegmentOrNull=function(t){var e=this,r=this.parseOrNull(k,t.type);return r&&new w(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||Ut.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=F,t.DEFAULT_ON_READY_TIMEOUT=n,t.Decision=p,t.DecisionReason=l,t.DefaultEventQueue=bt,t.Event=V,t.EventProcessor=St,t.EventType=v,t.Experiment=T,t.Exposure=G,t.FeatureFlagDecision=h,t.HackleInternalClient=Ft,t.IdentifierType=m,t.IdentifiersBuilder=N,t.Logger=r,t.MATCH_OPERATORS=C,t.MATCH_TYPES=b,t.MATCH_VALUE_TYPES=S,t.MetaVersion=D,t.SEGMENT_TYPES=k,t.Segment=w,t.Slot=d,t.TARGET_ACTION_TYPES=U,t.TARGET_KEY_TYPES=L,t.Target=R,t.TargetAction=O,t.TargetCondition=_,t.TargetKey=A,t.TargetMatch=g,t.TargetRule=I,t.TargetingType=x,t.Track=B,t.Variation=E,t.Version=P,t.Workspace=Lt,t.logLevels=e,t.toPayload=function(t){var e=new Array,r=new Array;return t.forEach((function(t){V.isExposure(t)?e.push(t.toDto()):V.isTrack(t)&&r.push(t.toDto())})),{exposureEvents:e,trackEvents:r}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@hackler/sdk-core",
"version": "3.4.3",
"version": "3.4.4",
"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

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