@featurevisor/sdk
Advanced tools
Comparing version
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.1.0](https://github.com/featurevisor/featurevisor/compare/v2.0.3...v2.1.0) (2025-07-21) | ||
### Features | ||
* allow creating SDK instance without any options ([#363](https://github.com/featurevisor/featurevisor/issues/363)) ([29e714f](https://github.com/featurevisor/featurevisor/commit/29e714f7fa64f034ca6c1d7be691011d1242aa11)) | ||
## [2.0.3](https://github.com/featurevisor/featurevisor/compare/v2.0.2...v2.0.3) (2025-07-20) | ||
@@ -8,0 +19,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{"use strict";var e={481:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=function(e){var r=(0,i.MurmurHashV3)(e,n)/o;return Math.floor(r*t.MAX_BUCKETED_NUMBER)},t.getBucketKey=function(e){var t,r,i=e.featureKey,n=e.bucketBy,o=e.context,u=e.logger;if("string"==typeof n)t="plain",r=[n];else if(Array.isArray(n))t="and",r=n;else{if("object"!=typeof n||!Array.isArray(n.or))throw u.error("invalid bucketBy",{featureKey:i,bucketBy:n}),new Error("invalid bucketBy");t="or",r=n.or}var l=[];return r.forEach((function(e){var r=(0,a.getValueFromContext)(o,e);void 0!==r&&("plain"===t||"and"===t||0===l.length)&&l.push(r)})),l.push(i),l.join(s)};var a=r(186),i=r(400),n=1,o=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5;var s="."},608:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorChildInstance=void 0;var i=r(40),n=r(985),o=function(){function e(e){this.parent=e.parent,this.context=e.context,this.sticky=e.sticky||{},this.emitter=new i.Emitter}return e.prototype.on=function(e,t){return"context_set"===e||"sticky_set"===e?this.emitter.on(e,t):this.parent.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return this.parent.getContext(a(a({},this.context),e))},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,n.getParamsForStickySetEvent)(r,this.sticky,t);this.emitter.trigger("sticky_set",i)},e.prototype.isEnabled=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.isEnabled(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.getVariation(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariable(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableBoolean=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableBoolean(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableString=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableString(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableInteger=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableInteger(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableDouble=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableDouble(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableArray=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableArray(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableObject=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableObject(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableJSON=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableJSON(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getAllEvaluations=function(e,t,r){return void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={}),this.parent.getAllEvaluations(a(a({},this.context),e),t,a({sticky:this.sticky},r))},e}();t.FeaturevisorChildInstance=o},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},a=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(a(e),a(t)),n=i[0],o=i[1];return n>o?1:n<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var a=i(e[r]||"0",t[r]||"0");if(0!==a)return a}return 0},t.compareVersions=function(e,r){var a=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),n=a.pop(),o=i.pop(),s=(0,t.compareSegments)(a,i);return 0!==s?s:n&&o?(0,t.compareSegments)(n.split("."),o.split(".")):n||o?n?-1:1:0}},186:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueFromContext=i,t.conditionIsMatched=function(e,t,r){var n=e.attribute,o=e.operator,s=e.value,u=e.regexFlags,l=i(t,n);if("equals"===o)return l===s;if("notEquals"===o)return l!==s;if("before"===o||"after"===o){var c=(d=l)instanceof Date?d:new Date(d),f=s instanceof Date?s:new Date(s);return"before"===o?c<f:c>f}if(!Array.isArray(s)||-1===["string","number"].indexOf(typeof l)&&null!==l)if("string"==typeof l&&"string"==typeof s){if(d=l,"contains"===o)return-1!==d.indexOf(s);if("notContains"===o)return-1===d.indexOf(s);if("startsWith"===o)return d.startsWith(s);if("endsWith"===o)return d.endsWith(s);if("semverEquals"===o)return 0===(0,a.compareVersions)(d,s);if("semverNotEquals"===o)return 0!==(0,a.compareVersions)(d,s);if("semverGreaterThan"===o)return 1===(0,a.compareVersions)(d,s);if("semverGreaterThanOrEquals"===o)return(0,a.compareVersions)(d,s)>=0;if("semverLessThan"===o)return-1===(0,a.compareVersions)(d,s);if("semverLessThanOrEquals"===o)return(0,a.compareVersions)(d,s)<=0;if("matches"===o)return r(s,u||"").test(d);if("notMatches"===o)return!r(s,u||"").test(d)}else if("number"==typeof l&&"number"==typeof s){if(d=l,"greaterThan"===o)return d>s;if("greaterThanOrEquals"===o)return d>=s;if("lessThan"===o)return d<s;if("lessThanOrEquals"===o)return d<=s}else{if("exists"===o)return void 0!==l;if("notExists"===o)return void 0===l;if(Array.isArray(l)&&"string"==typeof s){if(d=l,"includes"===o)return d.indexOf(s)>-1;if("notIncludes"===o)return-1===d.indexOf(s)}}else{var d=l;if("in"===o)return-1!==s.indexOf(d);if("notIn"===o)return-1===s.indexOf(d)}return!1};var a=r(108);function i(e,t){return-1===t.indexOf(".")?e[t]:t.split(".").reduce((function(e,t){return e?e[t]:void 0}),e)}},649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0;var a=r(186),i=function(){function e(e){var t=e.datafile,r=e.logger;this.logger=r,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.segments=t.segments,this.features=t.features,this.regexCache={}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return t.conditions=this.parseConditionsIfStringified(t.conditions),t},e.prototype.getFeatureKeys=function(){return Object.keys(this.features)},e.prototype.getFeature=function(e){return this.features[e]},e.prototype.getVariableKeys=function(e){var t=this.getFeature(e);return t?Object.keys(t.variablesSchema||{}):[]},e.prototype.hasVariations=function(e){var t=this.getFeature(e);return!!t&&Array.isArray(t.variations)&&t.variations.length>0},e.prototype.getRegex=function(e,t){var r=t||"",a="".concat(e,"-").concat(r);if(this.regexCache[a])return this.regexCache[a];var i=new RegExp(e,r);return this.regexCache[a]=i,i},e.prototype.allConditionsAreMatched=function(e,t){var r=this;if("string"==typeof e)return"*"===e;if("attribute"in e)try{return(0,a.conditionIsMatched)(e,t,(function(e,t){return r.getRegex(e,t)}))}catch(r){return this.logger.warn(r.message,{error:r,details:{condition:e,context:t}}),!1}return"and"in e&&Array.isArray(e.and)?e.and.every((function(e){return r.allConditionsAreMatched(e,t)})):"or"in e&&Array.isArray(e.or)?e.or.some((function(e){return r.allConditionsAreMatched(e,t)})):"not"in e&&Array.isArray(e.not)?e.not.every((function(){return!1===r.allConditionsAreMatched({and:e.not},t)})):!!Array.isArray(e)&&e.every((function(e){return r.allConditionsAreMatched(e,t)}))},e.prototype.segmentIsMatched=function(e,t){return this.allConditionsAreMatched(e.conditions,t)},e.prototype.allSegmentsAreMatched=function(e,t){var r=this;if("*"===e)return!0;if("string"==typeof e){var a=this.getSegment(e);return!!a&&this.segmentIsMatched(a,t)}if("object"==typeof e){if("and"in e&&Array.isArray(e.and))return e.and.every((function(e){return r.allSegmentsAreMatched(e,t)}));if("or"in e&&Array.isArray(e.or))return e.or.some((function(e){return r.allSegmentsAreMatched(e,t)}));if("not"in e&&Array.isArray(e.not))return e.not.every((function(e){return!1===r.allSegmentsAreMatched(e,t)}))}return!!Array.isArray(e)&&e.every((function(e){return r.allSegmentsAreMatched(e,t)}))},e.prototype.getMatchedTraffic=function(e,t){var r=this;return e.find((function(e){return!!r.allSegmentsAreMatched(r.parseSegmentsIfStringified(e.segments),t)}))},e.prototype.getMatchedAllocation=function(e,t){if(e.allocation)for(var r=0,a=e.allocation;r<a.length;r++){var i=a[r],n=i.range,o=n[0],s=n[1];if(i.range&&o<=t&&s>=t)return i}},e.prototype.getMatchedForce=function(e,t){var r={force:void 0,forceIndex:void 0},a="string"==typeof e?this.getFeature(e):e;if(!a||!a.force)return r;for(var i=0;i<a.force.length;i++){var n=a.force[i];if(n.conditions&&this.allConditionsAreMatched(this.parseConditionsIfStringified(n.conditions),t)){r.force=n,r.forceIndex=i;break}if(n.segments&&this.allSegmentsAreMatched(this.parseSegmentsIfStringified(n.segments),t)){r.force=n,r.forceIndex=i;break}}return r},e.prototype.parseConditionsIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e.prototype.parseSegmentsIfStringified=function(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e},e}();t.DatafileReader=i},40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var a=!0;return function(){if(a){a=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach((function(e){try{e(t)}catch(e){console.error(e)}}))},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},335:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluateWithHooks=function(e){try{for(var t=e.hooksManager,r=t.getAll(),a=e,n=0,s=t.getAll();n<s.length;n++)(f=s[n]).before&&(a=f.before(a));var u=o(a);void 0!==a.defaultVariationValue&&"variation"===u.type&&void 0===u.variationValue&&(u.variationValue=a.defaultVariationValue),void 0!==a.defaultVariableValue&&"variable"===u.type&&void 0===u.variableValue&&(u.variableValue=a.defaultVariableValue);for(var l=0,c=r;l<c.length;l++){var f;(f=c[l]).after&&(u=f.after(u,a))}return u}catch(t){var d=e.type,v=e.featureKey,y=e.variableKey,g=e.logger;return u={type:d,featureKey:v,variableKey:y,reason:i.ERROR,error:t},g.error("error during evaluation",u),u}},t.evaluate=o;var i,n=r(481);function o(e){var t,r=e.type,s=e.featureKey,u=e.variableKey,l=e.context,c=e.logger,f=e.datafileReader,d=e.sticky,v=e.hooksManager.getAll();try{if("flag"!==r&&!1===o(a(a({},e),{type:"flag"})).enabled){t={type:r,featureKey:s,reason:i.DISABLED};var y=f.getFeature(s);if("variable"===r&&y&&u&&y.variablesSchema&&y.variablesSchema[u]){var g=y.variablesSchema[u];void 0!==g.disabledValue?t={type:r,featureKey:s,reason:i.VARIABLE_DISABLED,variableKey:u,variableValue:g.disabledValue,variableSchema:g,enabled:!1}:g.useDefaultWhenDisabled&&(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,variableKey:u,variableValue:g.defaultValue,variableSchema:g,enabled:!1})}return"variation"===r&&y&&y.disabledVariationValue&&(t={type:r,featureKey:s,reason:i.VARIATION_DISABLED,variationValue:y.disabledVariationValue,enabled:!1}),c.debug("feature is disabled",t),t}if(d&&d[s]){if("flag"===r&&void 0!==d[s].enabled)return t={type:r,featureKey:s,reason:i.STICKY,sticky:d[s],enabled:d[s].enabled},c.debug("using sticky enabled",t),t;if("variation"===r){var h=d[s].variation;if(void 0!==h)return t={type:r,featureKey:s,reason:i.STICKY,variationValue:h},c.debug("using sticky variation",t),t}if(u){var p=d[s].variables;if(p){var b=p[u];if(void 0!==b)return t={type:r,featureKey:s,reason:i.STICKY,variableKey:u,variableValue:b},c.debug("using sticky variable",t),t}}}var V="string"==typeof s?f.getFeature(s):s;if(!V)return t={type:r,featureKey:s,reason:i.FEATURE_NOT_FOUND},c.warn("feature not found",t),t;"flag"===r&&V.deprecated&&c.warn("feature is deprecated",{featureKey:s});var k=void 0;if(u){if(V.variablesSchema&&V.variablesSchema[u]&&(k=V.variablesSchema[u]),!k)return t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u},c.warn("variable schema not found",t),t;k.deprecated&&c.warn("variable is deprecated",{featureKey:s,variableKey:u})}if("variation"===r&&(!V.variations||0===V.variations.length))return t={type:r,featureKey:s,reason:i.NO_VARIATIONS},c.warn("no variations",t),t;var m=f.getMatchedForce(V,l),A=m.force,K=m.forceIndex;if(A){if("flag"===r&&void 0!==A.enabled)return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,enabled:A.enabled},c.debug("forced enabled found",t),t;if("variation"===r&&A.variation&&V.variations&&(T=V.variations.find((function(e){return e.value===A.variation}))))return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variation:T},c.debug("forced variation found",t),t;if(u&&A.variables&&void 0!==A.variables[u])return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variableKey:u,variableSchema:k,variableValue:A.variables[u]},c.debug("forced variable",t),t}if("flag"===r&&V.required&&V.required.length>0){var x=V.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!o(a(a({},e),{type:"flag",featureKey:r})).enabled)return!1;if(void 0!==i){var n=o(a(a({},e),{type:"variation",featureKey:r})),s=void 0;return n.variationValue?s=n.variationValue:n.variation&&(s=n.variation.value),s===i}return!0}));if(!x)return t={type:r,featureKey:s,reason:i.REQUIRED,required:V.required,enabled:x},c.debug("required features not enabled",t),t}for(var O=(0,n.getBucketKey)({featureKey:s,bucketBy:V.bucketBy,context:l,logger:c}),E=0,_=v;E<_.length;E++)(L=_[E]).bucketKey&&(O=L.bucketKey({featureKey:s,context:l,bucketBy:V.bucketBy,bucketKey:O}));for(var S,R,M=(0,n.getBucketedNumber)(O),I=0,D=v;I<D.length;I++){var L;(L=D[I]).bucketValue&&(M=L.bucketValue({featureKey:s,bucketKey:O,context:l,bucketValue:M}))}if("flag"!==r?(S=f.getMatchedTraffic(V.traffic,l))&&(R=f.getMatchedAllocation(S,M)):S=f.getMatchedTraffic(V.traffic,l),S){if(0===S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!1},c.debug("matched rule with 0 percentage",t),t;if("flag"===r){if(V.ranges&&V.ranges.length>0)return V.ranges.find((function(e){return M>=e[0]&&M<e[1]}))?(t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:void 0===S.enabled||S.enabled},c.debug("matched",t),t):(t={type:r,featureKey:s,reason:i.OUT_OF_RANGE,bucketKey:O,bucketValue:M,enabled:!1},c.debug("not matched",t),t);if(void 0!==S.enabled)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:S.enabled},c.debug("override from rule",t),t;if(M<=S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!0},c.debug("matched traffic",t),t}if("variation"===r&&V.variations){if(S.variation&&(T=V.variations.find((function(e){return e.value===S.variation}))))return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("override from rule",t),t;if(R&&R.variation&&(T=V.variations.find((function(e){return e.value===R.variation}))))return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("allocated variation",t),t}}if("variable"===r&&u){if(S&&S.variables&&void 0!==S.variables[u])return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:S.variables[u]},c.debug("override from rule",t),t;var F;if(A&&A.variation?F=A.variation:S&&S.variation?F=S.variation:R&&R.variation&&(F=R.variation),F&&Array.isArray(V.variations)){var T;if((T=V.variations.find((function(e){return e.value===F})))&&T.variableOverrides&&T.variableOverrides[u]){var C=T.variableOverrides[u].find((function(e){return e.conditions?f.allConditionsAreMatched("string"==typeof e.conditions&&"*"!==e.conditions?JSON.parse(e.conditions):e.conditions,l):!!e.segments&&f.allSegmentsAreMatched(f.parseSegmentsIfStringified(e.segments),l)}));if(C)return t={type:r,featureKey:s,reason:i.VARIABLE_OVERRIDE,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:C.value},c.debug("variable override",t),t}if(T&&T.variables&&void 0!==T.variables[u])return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:T.variables[u]},c.debug("allocated variable",t),t}}return"variation"===r?(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M},c.debug("no matched variation",t),t):"variable"===r?k?(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,bucketKey:O,bucketValue:M,variableKey:u,variableSchema:k,variableValue:k.defaultValue},c.debug("using default value",t),t):(t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u,bucketKey:O,bucketValue:M},c.debug("variable not found",t),t):(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M,enabled:!1},c.debug("nothing matched",t),t)}catch(e){return t={type:r,featureKey:s,variableKey:u,reason:i.ERROR,error:e},c.error("error",t),t}}!function(e){e.FEATURE_NOT_FOUND="feature_not_found",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.NO_VARIATIONS="no_variations",e.VARIATION_DISABLED="variation_disabled",e.VARIABLE_NOT_FOUND="variable_not_found",e.VARIABLE_DEFAULT="variable_default",e.VARIABLE_DISABLED="variable_disabled",e.VARIABLE_OVERRIDE="variable_override",e.NO_MATCH="no_match",e.FORCED="forced",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},985:function(e,t){var r=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var a,i=0,n=t.length;i<n;i++)!a&&i in t||(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.getParamsForStickySetEvent=function(e,t,a){void 0===e&&(e={}),void 0===t&&(t={});var i=Object.keys(e),n=Object.keys(t),o=r(r([],i,!0),n,!0);return{features:o.filter((function(e,t){return o.indexOf(e)===t})),replaced:a}},t.getParamsForDatafileSetEvent=function(e,t){for(var a=e.getRevision(),i=e.getFeatureKeys(),n=t.getRevision(),o=t.getFeatureKeys(),s=[],u=[],l=[],c=0,f=i;c<f.length;c++){var d=f[c];if(-1!==o.indexOf(d)){var v=e.getFeature(d),y=t.getFeature(d);(null==v?void 0:v.hash)!==(null==y?void 0:y.hash)&&u.push(d)}else s.push(d)}for(var g=0,h=o;g<h.length;g++){var p=h[g];-1===i.indexOf(p)&&l.push(p)}return{revision:n,previousRevision:a,revisionChanged:a!==n,features:r(r(r([],s,!0),u,!0),l,!0).filter((function(e,t,r){return r.indexOf(e)===t}))}}},943:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueByType=function(e,t){try{if(void 0===e)return null;switch(t){case"string":return"string"==typeof e?e:null;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:null;case"object":return"object"==typeof e?e:null;default:return e}}catch(e){return null}}},438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HooksManager=void 0;var r=function(){function e(e){var t=this;this.hooks=[],this.logger=e.logger,e.hooks&&e.hooks.forEach((function(e){t.add(e)}))}return e.prototype.add=function(e){var t=this;if(!this.hooks.some((function(t){return t.name===e.name})))return this.hooks.push(e),function(){t.remove(e.name)};this.logger.error('Hook with name "'.concat(e.name,'" already exists.'),{name:e.name,hook:e})},e.prototype.remove=function(e){this.hooks=this.hooks.filter((function(t){return t.name!==e}))},e.prototype.getAll=function(){return this.hooks},e}();t.HooksManager=r},166:function(e,t,r){var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(481),t),i(r(247),t),i(r(584),t),i(r(186),t),i(r(335),t),i(r(649),t),i(r(608),t)},247:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.createInstance=function(e){return new v(e)};var i=r(584),n=r(438),o=r(40),s=r(649),u=r(335),l=r(608),c=r(985),f=r(943),d={schemaVersion:"2",revision:"unknown",segments:{},features:{}},v=function(){function e(e){this.context={},this.context=e.context||{},this.logger=e.logger||(0,i.createLogger)({level:e.logLevel||i.Logger.defaultLevel}),this.hooksManager=new n.HooksManager({hooks:e.hooks||[],logger:this.logger}),this.emitter=new o.Emitter,this.sticky=e.sticky,this.datafileReader=new s.DatafileReader({datafile:d,logger:this.logger}),e.datafile&&(this.datafileReader=new s.DatafileReader({datafile:"string"==typeof e.datafile?JSON.parse(e.datafile):e.datafile,logger:this.logger})),this.logger.info("Featurevisor SDK initialized")}return e.prototype.setLogLevel=function(e){this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new s.DatafileReader({datafile:"string"==typeof e?JSON.parse(e):e,logger:this.logger}),r=(0,c.getParamsForDatafileSetEvent)(this.datafileReader,t);this.datafileReader=t,this.logger.info("datafile set",r),this.emitter.trigger("datafile_set",r)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,c.getParamsForStickySetEvent)(r,this.sticky,t);this.logger.info("sticky features set",i),this.emitter.trigger("sticky_set",i)},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return this.datafileReader.getFeature(e)},e.prototype.addHook=function(e){return this.hooksManager.add(e)},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t}),this.logger.debug(t?"context replaced":"context updated",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return e?a(a({},this.context),e):this.context},e.prototype.spawn=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),new l.FeaturevisorChildInstance({parent:this,context:this.getContext(e),sticky:t.sticky})},e.prototype.getEvaluationDependencies=function(e,t){return void 0===t&&(t={}),{context:this.getContext(e),logger:this.logger,hooksManager:this.hooksManager,datafileReader:this.datafileReader,sticky:t.sticky?a(a({},this.sticky),t.sticky):this.sticky,defaultVariationValue:t.defaultVariationValue,defaultVariableValue:t.defaultVariableValue}},e.prototype.evaluateFlag=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"flag",featureKey:e}))},e.prototype.isEnabled=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{return!0===this.evaluateFlag(e,t,r).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"variation",featureKey:e}))},e.prototype.getVariation=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{var a=this.evaluateVariation(e,t,r);return void 0!==a.variationValue?a.variationValue:a.variation?a.variation.value:null}catch(t){return this.logger.error("getVariation",{featureKey:e,error:t}),null}},e.prototype.evaluateVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(r,i)),{type:"variable",featureKey:e,variableKey:t}))},e.prototype.getVariable=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});try{var i=this.evaluateVariable(e,t,r,a);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:null}catch(r){return this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r}),null}},e.prototype.getVariableBoolean=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"boolean")},e.prototype.getVariableString=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"string")},e.prototype.getVariableInteger=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"integer")},e.prototype.getVariableDouble=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"double")},e.prototype.getVariableArray=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"array")},e.prototype.getVariableObject=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"object")},e.prototype.getVariableJSON=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"json")},e.prototype.getAllEvaluations=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={});for(var a={},i=0,n=t.length>0?t:this.datafileReader.getFeatureKeys();i<n.length;i++){var o=n[i],s={enabled:this.isEnabled(o,e,r)};if(this.datafileReader.hasVariations(o)){var u=this.getVariation(o,e,r);u&&(s.variation=u)}var l=this.datafileReader.getVariableKeys(o);if(l.length>0){s.variables={};for(var c=0,f=l;c<f.length;c++){var d=f[c];s.variables[d]=this.getVariable(o,d,e,r)}}a[o]=s}return a},e}();t.FeaturevisorInstance=v},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Featurevisor]",t.defaultLogHandler=function(e,r,a){void 0===a&&(a={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,a)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,a){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,a)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var a,i,n,o,s,u,l,c;for("string"==typeof e&&(e=r(e)),a=3&e.length,i=e.length-a,n=t,s=3432918353,u=461845907,c=0;c<i;)l=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,a){case 3:l^=(255&e[c+2])<<16;case 2:l^=(255&e[c+1])<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e[c]))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}}},t={};return function r(a){var i=t[a];if(void 0!==i)return i.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,r),n.exports}(166)})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{"use strict";var e={481:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=function(e){var r=(0,i.MurmurHashV3)(e,n)/o;return Math.floor(r*t.MAX_BUCKETED_NUMBER)},t.getBucketKey=function(e){var t,r,i=e.featureKey,n=e.bucketBy,o=e.context,u=e.logger;if("string"==typeof n)t="plain",r=[n];else if(Array.isArray(n))t="and",r=n;else{if("object"!=typeof n||!Array.isArray(n.or))throw u.error("invalid bucketBy",{featureKey:i,bucketBy:n}),new Error("invalid bucketBy");t="or",r=n.or}var l=[];return r.forEach((function(e){var r=(0,a.getValueFromContext)(o,e);void 0!==r&&("plain"===t||"and"===t||0===l.length)&&l.push(r)})),l.push(i),l.join(s)};var a=r(186),i=r(400),n=1,o=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5;var s="."},608:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorChildInstance=void 0;var i=r(40),n=r(985),o=function(){function e(e){this.parent=e.parent,this.context=e.context,this.sticky=e.sticky||{},this.emitter=new i.Emitter}return e.prototype.on=function(e,t){return"context_set"===e||"sticky_set"===e?this.emitter.on(e,t):this.parent.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return this.parent.getContext(a(a({},this.context),e))},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,n.getParamsForStickySetEvent)(r,this.sticky,t);this.emitter.trigger("sticky_set",i)},e.prototype.isEnabled=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.isEnabled(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),this.parent.getVariation(e,a(a({},this.context),t),a({sticky:this.sticky},r))},e.prototype.getVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariable(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableBoolean=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableBoolean(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableString=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableString(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableInteger=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableInteger(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableDouble=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableDouble(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableArray=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableArray(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableObject=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableObject(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getVariableJSON=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),this.parent.getVariableJSON(e,t,a(a({},this.context),r),a({sticky:this.sticky},i))},e.prototype.getAllEvaluations=function(e,t,r){return void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={}),this.parent.getAllEvaluations(a(a({},this.context),e),t,a({sticky:this.sticky},r))},e}();t.FeaturevisorChildInstance=o},108:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.compareVersions=t.compareSegments=t.validateAndParse=t.semver=void 0,t.semver=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,t.validateAndParse=function(e){if("string"!=typeof e)throw new TypeError("Invalid argument expected string");var r=e.match(t.semver);if(!r)throw new Error("Invalid argument not valid semver ('".concat(e,"' received)"));return r.shift(),r};var r=function(e){return"*"===e||"x"===e||"X"===e},a=function(e){var t=parseInt(e,10);return isNaN(t)?e:t},i=function(e,t){if(r(e)||r(t))return 0;var i=function(e,t){return typeof e!=typeof t?[String(e),String(t)]:[e,t]}(a(e),a(t)),n=i[0],o=i[1];return n>o?1:n<o?-1:0};t.compareSegments=function(e,t){for(var r=0;r<Math.max(e.length,t.length);r++){var a=i(e[r]||"0",t[r]||"0");if(0!==a)return a}return 0},t.compareVersions=function(e,r){var a=(0,t.validateAndParse)(e),i=(0,t.validateAndParse)(r),n=a.pop(),o=i.pop(),s=(0,t.compareSegments)(a,i);return 0!==s?s:n&&o?(0,t.compareSegments)(n.split("."),o.split(".")):n||o?n?-1:1:0}},186:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueFromContext=i,t.conditionIsMatched=function(e,t,r){var n=e.attribute,o=e.operator,s=e.value,u=e.regexFlags,l=i(t,n);if("equals"===o)return l===s;if("notEquals"===o)return l!==s;if("before"===o||"after"===o){var c=(d=l)instanceof Date?d:new Date(d),f=s instanceof Date?s:new Date(s);return"before"===o?c<f:c>f}if(!Array.isArray(s)||-1===["string","number"].indexOf(typeof l)&&null!==l)if("string"==typeof l&&"string"==typeof s){if(d=l,"contains"===o)return-1!==d.indexOf(s);if("notContains"===o)return-1===d.indexOf(s);if("startsWith"===o)return d.startsWith(s);if("endsWith"===o)return d.endsWith(s);if("semverEquals"===o)return 0===(0,a.compareVersions)(d,s);if("semverNotEquals"===o)return 0!==(0,a.compareVersions)(d,s);if("semverGreaterThan"===o)return 1===(0,a.compareVersions)(d,s);if("semverGreaterThanOrEquals"===o)return(0,a.compareVersions)(d,s)>=0;if("semverLessThan"===o)return-1===(0,a.compareVersions)(d,s);if("semverLessThanOrEquals"===o)return(0,a.compareVersions)(d,s)<=0;if("matches"===o)return r(s,u||"").test(d);if("notMatches"===o)return!r(s,u||"").test(d)}else if("number"==typeof l&&"number"==typeof s){if(d=l,"greaterThan"===o)return d>s;if("greaterThanOrEquals"===o)return d>=s;if("lessThan"===o)return d<s;if("lessThanOrEquals"===o)return d<=s}else{if("exists"===o)return void 0!==l;if("notExists"===o)return void 0===l;if(Array.isArray(l)&&"string"==typeof s){if(d=l,"includes"===o)return d.indexOf(s)>-1;if("notIncludes"===o)return-1===d.indexOf(s)}}else{var d=l;if("in"===o)return-1!==s.indexOf(d);if("notIn"===o)return-1===s.indexOf(d)}return!1};var a=r(108);function i(e,t){return-1===t.indexOf(".")?e[t]:t.split(".").reduce((function(e,t){return e?e[t]:void 0}),e)}},649:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0;var a=r(186),i=function(){function e(e){var t=e.datafile,r=e.logger;this.logger=r,this.schemaVersion=t.schemaVersion,this.revision=t.revision,this.segments=t.segments,this.features=t.features,this.regexCache={}}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getSegment=function(e){var t=this.segments[e];if(t)return t.conditions=this.parseConditionsIfStringified(t.conditions),t},e.prototype.getFeatureKeys=function(){return Object.keys(this.features)},e.prototype.getFeature=function(e){return this.features[e]},e.prototype.getVariableKeys=function(e){var t=this.getFeature(e);return t?Object.keys(t.variablesSchema||{}):[]},e.prototype.hasVariations=function(e){var t=this.getFeature(e);return!!t&&Array.isArray(t.variations)&&t.variations.length>0},e.prototype.getRegex=function(e,t){var r=t||"",a="".concat(e,"-").concat(r);if(this.regexCache[a])return this.regexCache[a];var i=new RegExp(e,r);return this.regexCache[a]=i,i},e.prototype.allConditionsAreMatched=function(e,t){var r=this;if("string"==typeof e)return"*"===e;if("attribute"in e)try{return(0,a.conditionIsMatched)(e,t,(function(e,t){return r.getRegex(e,t)}))}catch(r){return this.logger.warn(r.message,{error:r,details:{condition:e,context:t}}),!1}return"and"in e&&Array.isArray(e.and)?e.and.every((function(e){return r.allConditionsAreMatched(e,t)})):"or"in e&&Array.isArray(e.or)?e.or.some((function(e){return r.allConditionsAreMatched(e,t)})):"not"in e&&Array.isArray(e.not)?e.not.every((function(){return!1===r.allConditionsAreMatched({and:e.not},t)})):!!Array.isArray(e)&&e.every((function(e){return r.allConditionsAreMatched(e,t)}))},e.prototype.segmentIsMatched=function(e,t){return this.allConditionsAreMatched(e.conditions,t)},e.prototype.allSegmentsAreMatched=function(e,t){var r=this;if("*"===e)return!0;if("string"==typeof e){var a=this.getSegment(e);return!!a&&this.segmentIsMatched(a,t)}if("object"==typeof e){if("and"in e&&Array.isArray(e.and))return e.and.every((function(e){return r.allSegmentsAreMatched(e,t)}));if("or"in e&&Array.isArray(e.or))return e.or.some((function(e){return r.allSegmentsAreMatched(e,t)}));if("not"in e&&Array.isArray(e.not))return e.not.every((function(e){return!1===r.allSegmentsAreMatched(e,t)}))}return!!Array.isArray(e)&&e.every((function(e){return r.allSegmentsAreMatched(e,t)}))},e.prototype.getMatchedTraffic=function(e,t){var r=this;return e.find((function(e){return!!r.allSegmentsAreMatched(r.parseSegmentsIfStringified(e.segments),t)}))},e.prototype.getMatchedAllocation=function(e,t){if(e.allocation)for(var r=0,a=e.allocation;r<a.length;r++){var i=a[r],n=i.range,o=n[0],s=n[1];if(i.range&&o<=t&&s>=t)return i}},e.prototype.getMatchedForce=function(e,t){var r={force:void 0,forceIndex:void 0},a="string"==typeof e?this.getFeature(e):e;if(!a||!a.force)return r;for(var i=0;i<a.force.length;i++){var n=a.force[i];if(n.conditions&&this.allConditionsAreMatched(this.parseConditionsIfStringified(n.conditions),t)){r.force=n,r.forceIndex=i;break}if(n.segments&&this.allSegmentsAreMatched(this.parseSegmentsIfStringified(n.segments),t)){r.force=n,r.forceIndex=i;break}}return r},e.prototype.parseConditionsIfStringified=function(e){if("string"!=typeof e)return e;if("*"===e)return e;try{return JSON.parse(e)}catch(t){return this.logger.error("Error parsing conditions",{error:t,details:{conditions:e}}),e}},e.prototype.parseSegmentsIfStringified=function(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e},e}();t.DatafileReader=i},40:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]);var r=this.listeners[e];r.push(t);var a=!0;return function(){if(a){a=!1;var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.trigger=function(e,t){void 0===t&&(t={});var r=this.listeners[e];r&&r.forEach((function(e){try{e(t)}catch(e){console.error(e)}}))},e.prototype.clearAll=function(){this.listeners={}},e}();t.Emitter=r},335:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.EvaluationReason=void 0,t.evaluateWithHooks=function(e){try{for(var t=e.hooksManager,r=t.getAll(),a=e,n=0,s=t.getAll();n<s.length;n++)(f=s[n]).before&&(a=f.before(a));var u=o(a);void 0!==a.defaultVariationValue&&"variation"===u.type&&void 0===u.variationValue&&(u.variationValue=a.defaultVariationValue),void 0!==a.defaultVariableValue&&"variable"===u.type&&void 0===u.variableValue&&(u.variableValue=a.defaultVariableValue);for(var l=0,c=r;l<c.length;l++){var f;(f=c[l]).after&&(u=f.after(u,a))}return u}catch(t){var d=e.type,v=e.featureKey,y=e.variableKey,g=e.logger;return u={type:d,featureKey:v,variableKey:y,reason:i.ERROR,error:t},g.error("error during evaluation",u),u}},t.evaluate=o;var i,n=r(481);function o(e){var t,r=e.type,s=e.featureKey,u=e.variableKey,l=e.context,c=e.logger,f=e.datafileReader,d=e.sticky,v=e.hooksManager.getAll();try{if("flag"!==r&&!1===o(a(a({},e),{type:"flag"})).enabled){t={type:r,featureKey:s,reason:i.DISABLED};var y=f.getFeature(s);if("variable"===r&&y&&u&&y.variablesSchema&&y.variablesSchema[u]){var g=y.variablesSchema[u];void 0!==g.disabledValue?t={type:r,featureKey:s,reason:i.VARIABLE_DISABLED,variableKey:u,variableValue:g.disabledValue,variableSchema:g,enabled:!1}:g.useDefaultWhenDisabled&&(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,variableKey:u,variableValue:g.defaultValue,variableSchema:g,enabled:!1})}return"variation"===r&&y&&y.disabledVariationValue&&(t={type:r,featureKey:s,reason:i.VARIATION_DISABLED,variationValue:y.disabledVariationValue,enabled:!1}),c.debug("feature is disabled",t),t}if(d&&d[s]){if("flag"===r&&void 0!==d[s].enabled)return t={type:r,featureKey:s,reason:i.STICKY,sticky:d[s],enabled:d[s].enabled},c.debug("using sticky enabled",t),t;if("variation"===r){var h=d[s].variation;if(void 0!==h)return t={type:r,featureKey:s,reason:i.STICKY,variationValue:h},c.debug("using sticky variation",t),t}if(u){var p=d[s].variables;if(p){var b=p[u];if(void 0!==b)return t={type:r,featureKey:s,reason:i.STICKY,variableKey:u,variableValue:b},c.debug("using sticky variable",t),t}}}var V="string"==typeof s?f.getFeature(s):s;if(!V)return t={type:r,featureKey:s,reason:i.FEATURE_NOT_FOUND},c.warn("feature not found",t),t;"flag"===r&&V.deprecated&&c.warn("feature is deprecated",{featureKey:s});var k=void 0;if(u){if(V.variablesSchema&&V.variablesSchema[u]&&(k=V.variablesSchema[u]),!k)return t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u},c.warn("variable schema not found",t),t;k.deprecated&&c.warn("variable is deprecated",{featureKey:s,variableKey:u})}if("variation"===r&&(!V.variations||0===V.variations.length))return t={type:r,featureKey:s,reason:i.NO_VARIATIONS},c.warn("no variations",t),t;var m=f.getMatchedForce(V,l),A=m.force,K=m.forceIndex;if(A){if("flag"===r&&void 0!==A.enabled)return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,enabled:A.enabled},c.debug("forced enabled found",t),t;if("variation"===r&&A.variation&&V.variations&&(T=V.variations.find((function(e){return e.value===A.variation}))))return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variation:T},c.debug("forced variation found",t),t;if(u&&A.variables&&void 0!==A.variables[u])return t={type:r,featureKey:s,reason:i.FORCED,forceIndex:K,force:A,variableKey:u,variableSchema:k,variableValue:A.variables[u]},c.debug("forced variable",t),t}if("flag"===r&&V.required&&V.required.length>0){var x=V.required.every((function(t){var r,i;if("string"==typeof t?r=t:(r=t.key,i=t.variation),!o(a(a({},e),{type:"flag",featureKey:r})).enabled)return!1;if(void 0!==i){var n=o(a(a({},e),{type:"variation",featureKey:r})),s=void 0;return n.variationValue?s=n.variationValue:n.variation&&(s=n.variation.value),s===i}return!0}));if(!x)return t={type:r,featureKey:s,reason:i.REQUIRED,required:V.required,enabled:x},c.debug("required features not enabled",t),t}for(var O=(0,n.getBucketKey)({featureKey:s,bucketBy:V.bucketBy,context:l,logger:c}),E=0,_=v;E<_.length;E++)(L=_[E]).bucketKey&&(O=L.bucketKey({featureKey:s,context:l,bucketBy:V.bucketBy,bucketKey:O}));for(var S,R,M=(0,n.getBucketedNumber)(O),I=0,D=v;I<D.length;I++){var L;(L=D[I]).bucketValue&&(M=L.bucketValue({featureKey:s,bucketKey:O,context:l,bucketValue:M}))}if("flag"!==r?(S=f.getMatchedTraffic(V.traffic,l))&&(R=f.getMatchedAllocation(S,M)):S=f.getMatchedTraffic(V.traffic,l),S){if(0===S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!1},c.debug("matched rule with 0 percentage",t),t;if("flag"===r){if(V.ranges&&V.ranges.length>0)return V.ranges.find((function(e){return M>=e[0]&&M<e[1]}))?(t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:void 0===S.enabled||S.enabled},c.debug("matched",t),t):(t={type:r,featureKey:s,reason:i.OUT_OF_RANGE,bucketKey:O,bucketValue:M,enabled:!1},c.debug("not matched",t),t);if(void 0!==S.enabled)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:S.enabled},c.debug("override from rule",t),t;if(M<=S.percentage)return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,enabled:!0},c.debug("matched traffic",t),t}if("variation"===r&&V.variations){if(S.variation&&(T=V.variations.find((function(e){return e.value===S.variation}))))return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("override from rule",t),t;if(R&&R.variation&&(T=V.variations.find((function(e){return e.value===R.variation}))))return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variation:T},c.debug("allocated variation",t),t}}if("variable"===r&&u){if(S&&S.variables&&void 0!==S.variables[u])return t={type:r,featureKey:s,reason:i.RULE,bucketKey:O,bucketValue:M,ruleKey:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:S.variables[u]},c.debug("override from rule",t),t;var F;if(A&&A.variation?F=A.variation:S&&S.variation?F=S.variation:R&&R.variation&&(F=R.variation),F&&Array.isArray(V.variations)){var T;if((T=V.variations.find((function(e){return e.value===F})))&&T.variableOverrides&&T.variableOverrides[u]){var C=T.variableOverrides[u].find((function(e){return e.conditions?f.allConditionsAreMatched("string"==typeof e.conditions&&"*"!==e.conditions?JSON.parse(e.conditions):e.conditions,l):!!e.segments&&f.allSegmentsAreMatched(f.parseSegmentsIfStringified(e.segments),l)}));if(C)return t={type:r,featureKey:s,reason:i.VARIABLE_OVERRIDE,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:C.value},c.debug("variable override",t),t}if(T&&T.variables&&void 0!==T.variables[u])return t={type:r,featureKey:s,reason:i.ALLOCATED,bucketKey:O,bucketValue:M,ruleKey:null==S?void 0:S.key,traffic:S,variableKey:u,variableSchema:k,variableValue:T.variables[u]},c.debug("allocated variable",t),t}}return"variation"===r?(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M},c.debug("no matched variation",t),t):"variable"===r?k?(t={type:r,featureKey:s,reason:i.VARIABLE_DEFAULT,bucketKey:O,bucketValue:M,variableKey:u,variableSchema:k,variableValue:k.defaultValue},c.debug("using default value",t),t):(t={type:r,featureKey:s,reason:i.VARIABLE_NOT_FOUND,variableKey:u,bucketKey:O,bucketValue:M},c.debug("variable not found",t),t):(t={type:r,featureKey:s,reason:i.NO_MATCH,bucketKey:O,bucketValue:M,enabled:!1},c.debug("nothing matched",t),t)}catch(e){return t={type:r,featureKey:s,variableKey:u,reason:i.ERROR,error:e},c.error("error",t),t}}!function(e){e.FEATURE_NOT_FOUND="feature_not_found",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.NO_VARIATIONS="no_variations",e.VARIATION_DISABLED="variation_disabled",e.VARIABLE_NOT_FOUND="variable_not_found",e.VARIABLE_DEFAULT="variable_default",e.VARIABLE_DISABLED="variable_disabled",e.VARIABLE_OVERRIDE="variable_override",e.NO_MATCH="no_match",e.FORCED="forced",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.ERROR="error"}(i||(t.EvaluationReason=i={}))},985:function(e,t){var r=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var a,i=0,n=t.length;i<n;i++)!a&&i in t||(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.getParamsForStickySetEvent=function(e,t,a){void 0===e&&(e={}),void 0===t&&(t={});var i=Object.keys(e),n=Object.keys(t),o=r(r([],i,!0),n,!0);return{features:o.filter((function(e,t){return o.indexOf(e)===t})),replaced:a}},t.getParamsForDatafileSetEvent=function(e,t){for(var a=e.getRevision(),i=e.getFeatureKeys(),n=t.getRevision(),o=t.getFeatureKeys(),s=[],u=[],l=[],c=0,f=i;c<f.length;c++){var d=f[c];if(-1!==o.indexOf(d)){var v=e.getFeature(d),y=t.getFeature(d);(null==v?void 0:v.hash)!==(null==y?void 0:y.hash)&&u.push(d)}else s.push(d)}for(var g=0,h=o;g<h.length;g++){var p=h[g];-1===i.indexOf(p)&&l.push(p)}return{revision:n,previousRevision:a,revisionChanged:a!==n,features:r(r(r([],s,!0),u,!0),l,!0).filter((function(e,t,r){return r.indexOf(e)===t}))}}},943:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getValueByType=function(e,t){try{if(void 0===e)return null;switch(t){case"string":return"string"==typeof e?e:null;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:null;case"object":return"object"==typeof e?e:null;default:return e}}catch(e){return null}}},438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HooksManager=void 0;var r=function(){function e(e){var t=this;this.hooks=[],this.logger=e.logger,e.hooks&&e.hooks.forEach((function(e){t.add(e)}))}return e.prototype.add=function(e){var t=this;if(!this.hooks.some((function(t){return t.name===e.name})))return this.hooks.push(e),function(){t.remove(e.name)};this.logger.error('Hook with name "'.concat(e.name,'" already exists.'),{name:e.name,hook:e})},e.prototype.remove=function(e){this.hooks=this.hooks.filter((function(t){return t.name!==e}))},e.prototype.getAll=function(){return this.hooks},e}();t.HooksManager=r},166:function(e,t,r){var a=this&&this.__createBinding||(Object.create?function(e,t,r,a){void 0===a&&(a=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,a,i)}:function(e,t,r,a){void 0===a&&(a=r),e[a]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||a(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(481),t),i(r(247),t),i(r(584),t),i(r(186),t),i(r(335),t),i(r(649),t),i(r(608),t)},247:function(e,t,r){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=void 0,t.createInstance=function(e){return void 0===e&&(e={}),new v(e)};var i=r(584),n=r(438),o=r(40),s=r(649),u=r(335),l=r(608),c=r(985),f=r(943),d={schemaVersion:"2",revision:"unknown",segments:{},features:{}},v=function(){function e(e){this.context={},this.context=e.context||{},this.logger=e.logger||(0,i.createLogger)({level:e.logLevel||i.Logger.defaultLevel}),this.hooksManager=new n.HooksManager({hooks:e.hooks||[],logger:this.logger}),this.emitter=new o.Emitter,this.sticky=e.sticky,this.datafileReader=new s.DatafileReader({datafile:d,logger:this.logger}),e.datafile&&(this.datafileReader=new s.DatafileReader({datafile:"string"==typeof e.datafile?JSON.parse(e.datafile):e.datafile,logger:this.logger})),this.logger.info("Featurevisor SDK initialized")}return e.prototype.setLogLevel=function(e){this.logger.setLevel(e)},e.prototype.setDatafile=function(e){try{var t=new s.DatafileReader({datafile:"string"==typeof e?JSON.parse(e):e,logger:this.logger}),r=(0,c.getParamsForDatafileSetEvent)(this.datafileReader,t);this.datafileReader=t,this.logger.info("datafile set",r),this.emitter.trigger("datafile_set",r)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setSticky=function(e,t){void 0===t&&(t=!1);var r=this.sticky||{};this.sticky=a(t?{}:a({},this.sticky),e);var i=(0,c.getParamsForStickySetEvent)(r,this.sticky,t);this.logger.info("sticky features set",i),this.emitter.trigger("sticky_set",i)},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return this.datafileReader.getFeature(e)},e.prototype.addHook=function(e){return this.hooksManager.add(e)},e.prototype.on=function(e,t){return this.emitter.on(e,t)},e.prototype.close=function(){this.emitter.clearAll()},e.prototype.setContext=function(e,t){void 0===t&&(t=!1),this.context=t?e:a(a({},this.context),e),this.emitter.trigger("context_set",{context:this.context,replaced:t}),this.logger.debug(t?"context replaced":"context updated",{context:this.context,replaced:t})},e.prototype.getContext=function(e){return e?a(a({},this.context),e):this.context},e.prototype.spawn=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),new l.FeaturevisorChildInstance({parent:this,context:this.getContext(e),sticky:t.sticky})},e.prototype.getEvaluationDependencies=function(e,t){return void 0===t&&(t={}),{context:this.getContext(e),logger:this.logger,hooksManager:this.hooksManager,datafileReader:this.datafileReader,sticky:t.sticky?a(a({},this.sticky),t.sticky):this.sticky,defaultVariationValue:t.defaultVariationValue,defaultVariableValue:t.defaultVariableValue}},e.prototype.evaluateFlag=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"flag",featureKey:e}))},e.prototype.isEnabled=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{return!0===this.evaluateFlag(e,t,r).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(t,r)),{type:"variation",featureKey:e}))},e.prototype.getVariation=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});try{var a=this.evaluateVariation(e,t,r);return void 0!==a.variationValue?a.variationValue:a.variation?a.variation.value:null}catch(t){return this.logger.error("getVariation",{featureKey:e,error:t}),null}},e.prototype.evaluateVariable=function(e,t,r,i){return void 0===r&&(r={}),void 0===i&&(i={}),(0,u.evaluateWithHooks)(a(a({},this.getEvaluationDependencies(r,i)),{type:"variable",featureKey:e,variableKey:t}))},e.prototype.getVariable=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});try{var i=this.evaluateVariable(e,t,r,a);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:null}catch(r){return this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r}),null}},e.prototype.getVariableBoolean=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"boolean")},e.prototype.getVariableString=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"string")},e.prototype.getVariableInteger=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"integer")},e.prototype.getVariableDouble=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"double")},e.prototype.getVariableArray=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"array")},e.prototype.getVariableObject=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"object")},e.prototype.getVariableJSON=function(e,t,r,a){void 0===r&&(r={}),void 0===a&&(a={});var i=this.getVariable(e,t,r,a);return(0,f.getValueByType)(i,"json")},e.prototype.getAllEvaluations=function(e,t,r){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===r&&(r={});for(var a={},i=0,n=t.length>0?t:this.datafileReader.getFeatureKeys();i<n.length;i++){var o=n[i],s={enabled:this.isEnabled(o,e,r)};if(this.datafileReader.hasVariations(o)){var u=this.getVariation(o,e,r);u&&(s.variation=u)}var l=this.datafileReader.getVariableKeys(o);if(l.length>0){s.variables={};for(var c=0,f=l;c<f.length;c++){var d=f[c];s.variables[d]=this.getVariable(o,d,e,r)}}a[o]=s}return a},e}();t.FeaturevisorInstance=v},584:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.loggerPrefix=void 0,t.createLogger=function(e){return void 0===e&&(e={}),new r(e)},t.loggerPrefix="[Featurevisor]",t.defaultLogHandler=function(e,r,a){void 0===a&&(a={});var i="log";"info"===e?i="info":"warn"===e?i="warn":"error"===e&&(i="error"),console[i](t.loggerPrefix,r,a)};var r=function(){function e(r){this.level=r.level||e.defaultLevel,this.handle=r.handler||t.defaultLogHandler}return e.prototype.setLevel=function(e){this.level=e},e.prototype.log=function(t,r,a){e.allLevels.indexOf(this.level)>=e.allLevels.indexOf(t)&&this.handle(t,r,a)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e.allLevels=["fatal","error","warn","info","debug"],e.defaultLevel="info",e}();t.Logger=r},400:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHashV3=function(e,t){var a,i,n,o,s,u,l,c;for("string"==typeof e&&(e=r(e)),a=3&e.length,i=e.length-a,n=t,s=3432918353,u=461845907,c=0;c<i;)l=255&e[c]|(255&e[++c])<<8|(255&e[++c])<<16|(255&e[++c])<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,a){case 3:l^=(255&e[c+2])<<16;case 2:l^=(255&e[c+1])<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e[c]))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*u+(((l>>>16)*u&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};var r=function(e){return(new TextEncoder).encode(e)}}},t={};return function r(a){var i=t[a];if(void 0!==i)return i.exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,r),n.exports}(166)})())); | ||
//# sourceMappingURL=index.js.map |
@@ -67,2 +67,2 @@ import type { Context, Feature, FeatureKey, StickyFeatures, EvaluatedFeatures, VariableValue, VariationValue, VariableKey, DatafileContent } from "@featurevisor/types"; | ||
} | ||
export declare function createInstance(options: InstanceOptions): FeaturevisorInstance; | ||
export declare function createInstance(options?: InstanceOptions): FeaturevisorInstance; |
@@ -67,2 +67,2 @@ import type { Context, Feature, FeatureKey, StickyFeatures, EvaluatedFeatures, VariableValue, VariationValue, VariableKey, DatafileContent } from "@featurevisor/types"; | ||
} | ||
export declare function createInstance(options: InstanceOptions): FeaturevisorInstance; | ||
export declare function createInstance(options?: InstanceOptions): FeaturevisorInstance; |
{ | ||
"name": "@featurevisor/sdk", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Featurevisor SDK for Node.js and the browser", | ||
@@ -54,3 +54,3 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"gitHead": "5522c5cb67b648aac05c100733390e92a42f694b" | ||
"gitHead": "96ac5672adf1043ab215b75ba825885d0a6f76bf" | ||
} |
@@ -442,4 +442,4 @@ import type { | ||
export function createInstance(options: InstanceOptions): FeaturevisorInstance { | ||
export function createInstance(options: InstanceOptions = {}): FeaturevisorInstance { | ||
return new FeaturevisorInstance(options); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1097937
0.07%7671
0.01%