configcat-vue 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Here's a quick overview of what you can do with this package:
18
18
 
19
19
  ## Documentation
20
20
 
21
- [Read the documentation](https://github.com/codedbychavez/configcat-vue/wiki/Documentation)
21
+ [Read the documentation on ConfigCat](https://configcat.com/docs/sdk-reference/community/vue/)
22
22
 
23
23
  ## With you in mind
24
24
 
@@ -2798,7 +2798,7 @@ function br(t) {
2798
2798
  function Tr(t) {
2799
2799
  return t = atob(t), t = t.replace(/[%\x80-\xFF]/g, (e) => "%" + e.charCodeAt(0).toString(16)), decodeURIComponent(t);
2800
2800
  }
2801
- const Ir = "2.2.2", Rr = {
2801
+ const Ir = "2.2.3", Rr = {
2802
2802
  // Vue's `App.prototype.use` does not play nicely with generic `install` functions, so we resort to using a discriminated union.
2803
2803
  install: (t, e) => {
2804
2804
  const { sdkKey: r, pollingMode: n, clientOptions: i } = e, s = ke.setup({
@@ -3,4 +3,4 @@
3
3
  `+((n=e.configJson)!==null&&n!==void 0?n:"")},t.deserialize=function(e){for(var r=Array(2),n=0,i=0;i<r.length;i++){if(n=e.indexOf(`
4
4
  `,n),n<0)throw new Error("Number of values is fewer than expected.");r[i]=n++}var o=r[0],a=e.substring(0,o),u=parseInt(a);if(isNaN(u))throw new Error("Invalid fetch time: "+a);n=o+1,o=r[1],a=e.substring(n,o);var l=a.length>0?a:void 0;n=o+1,a=e.substring(n);var c,f;return a.length>0&&(c=X.deserialize(a),f=a),new t(f,c,u,l)},t.serializationFormatVersion="v2",t.empty=new t(void 0,void 0,0,void 0),t}(),X=function(){function t(e){var r=this,n,i;this.preferences=e.p!=null?new wt(e.p):void 0,this.segments=(i=(n=e.s)===null||n===void 0?void 0:n.map(function(o){return new Nt(o)}))!==null&&i!==void 0?i:[],this.settings=e.f!=null?Object.fromEntries(Object.entries(e.f).map(function(o){var a=o[0],u=o[1];return[a,new we(u,r)]})):{}}return t.deserialize=function(e){var r=JSON.parse(e);if(typeof r!="object"||!r)throw new Error("Invalid config JSON content:"+e);return new t(r)},Object.defineProperty(t.prototype,"salt",{get:function(){var e;return(e=this.preferences)===null||e===void 0?void 0:e.salt},enumerable:!1,configurable:!0}),t}(),wt=function(){function t(e){this.baseUrl=e.u,this.redirectMode=e.r,this.salt=e.s}return t}(),Nt=function(){function t(e){var r,n;this.name=e.n,this.conditions=(n=(r=e.r)===null||r===void 0?void 0:r.map(function(i){return new Le(i)}))!==null&&n!==void 0?n:[]}return t}(),ce=function(){function t(e,r){r===void 0&&(r=!1),this.value=r?e.v:Ue(e.v),this.variationId=e.i}return t}(),we=function(t){R(e,t);function e(r,n){var i,o,a,u,l,c,f=t.call(this,r,r.t<0)||this;f.type=r.t;var h="Identifier";return f.percentageOptionsAttribute=(i=r.a)!==null&&i!==void 0?i:h,f.targetingRules=(a=(o=r.r)===null||o===void 0?void 0:o.map(function(g){return new Lt(g,n)}))!==null&&a!==void 0?a:[],f.percentageOptions=(l=(u=r.p)===null||u===void 0?void 0:u.map(function(g){return new Ne(g)}))!==null&&l!==void 0?l:[],f.configJsonSalt=(c=n==null?void 0:n.salt)!==null&&c!==void 0?c:"",f}return e.fromValue=function(r){return new e({t:-1,v:r})},e}(ce),Lt=function(){function t(e,r){var n,i;this.conditions=(i=(n=e.c)===null||n===void 0?void 0:n.map(function(o){return o.u!=null?new Le(o.u):o.p!=null?new Ut(o.p):o.s!=null?new Rt(o.s,r):void 0}))!==null&&i!==void 0?i:[],this.then=e.p!=null?e.p.map(function(o){return new Ne(o)}):new ce(e.s)}return t}(),Ne=function(t){R(e,t);function e(r){var n=t.call(this,r)||this;return n.percentage=r.p,n}return e}(ce),Le=function(){function t(e){var r,n;this.type="UserCondition",this.comparisonAttribute=e.a,this.comparator=e.c,this.comparisonValue=(n=(r=e.s)!==null&&r!==void 0?r:e.d)!==null&&n!==void 0?n:e.l}return t}(),Ut=function(){function t(e){this.type="PrerequisiteFlagCondition",this.prerequisiteFlagKey=e.f,this.comparator=e.c,this.comparisonValue=Ue(e.v)}return t}(),Rt=function(){function t(e,r){this.type="SegmentCondition",this.segment=r.segments[e.s],this.comparator=e.c}return t}();function Ue(t){var e,r,n;return(n=(r=(e=t.b)!==null&&e!==void 0?e:t.s)!==null&&r!==void 0?r:t.i)!==null&&n!==void 0?n:t.d}var _=function(){function t(e,r){this.errorMessage=e,this.errorException=r}return Object.defineProperty(t.prototype,"isSuccess",{get:function(){return this.errorMessage===null},enumerable:!1,configurable:!0}),t.from=function(e){return e.status!==q.Errored?t.success():t.failure(e.errorMessage,e.errorException)},t.success=function(){return new t(null)},t.failure=function(e,r){return new t(e,r)},t}();s.ClientCacheState=void 0,function(t){t[t.NoFlagData=0]="NoFlagData",t[t.HasLocalOverrideFlagDataOnly=1]="HasLocalOverrideFlagDataOnly",t[t.HasCachedFlagDataOnly=2]="HasCachedFlagDataOnly",t[t.HasUpToDateFlagData=3]="HasUpToDateFlagData"}(s.ClientCacheState||(s.ClientCacheState={}));var w;(function(t){t[t.Online=0]="Online",t[t.Offline=1]="Offline",t[t.Disposed=2]="Disposed"})(w||(w={}));var fe=function(){function t(e,r){this.configFetcher=e,this.options=r,this.pendingFetch=null,this.cacheKey=r.getCacheKey(),this.configFetcher=e,this.options=r,this.status=r.offline?w.Offline:w.Online}return t.prototype.dispose=function(){this.status=w.Disposed},Object.defineProperty(t.prototype,"disposed",{get:function(){return this.status===w.Disposed},enumerable:!1,configurable:!0}),t.prototype.refreshConfigAsync=function(){return m(this,void 0,void 0,function(){var e,r,n,i,o;return E(this,function(a){switch(a.label){case 0:return[4,this.options.cache.get(this.cacheKey)];case 1:return e=a.sent(),this.isOffline?[3,3]:[4,this.refreshConfigCoreAsync(e)];case 2:return r=a.sent(),n=r[0],i=r[1],[2,[_.from(n),i]];case 3:return o=this.options.logger.configServiceCannotInitiateHttpCalls().toString(),[2,[_.failure(o),e]]}})})},t.prototype.refreshConfigCoreAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i;return E(this,function(o){switch(o.label){case 0:return[4,this.fetchAsync(e)];case 1:return r=o.sent(),n=!1,i=r.status===q.Fetched,i||r.config.timestamp>e.timestamp&&(!r.config.isEmpty||e.isEmpty)?[4,this.options.cache.set(this.cacheKey,r.config)]:[3,3];case 2:o.sent(),n=i&&!U.equals(r.config,e),e=r.config,o.label=3;case 3:return this.onConfigFetched(r.config),n&&this.onConfigChanged(r.config),[2,[r,e]]}})})},t.prototype.onConfigFetched=function(e){},t.prototype.onConfigChanged=function(e){var r;this.options.logger.debug("config changed"),this.options.hooks.emit("configChanged",(r=e.config)!==null&&r!==void 0?r:new X({}))},t.prototype.fetchAsync=function(e){var r=this,n;return(n=this.pendingFetch)!==null&&n!==void 0?n:this.pendingFetch=function(){return m(r,void 0,void 0,function(){return E(this,function(i){switch(i.label){case 0:return i.trys.push([0,,2,3]),[4,this.fetchLogicAsync(e)];case 1:return[2,i.sent()];case 2:return this.pendingFetch=null,[7];case 3:return[2]}})})}()},t.prototype.fetchLogicAsync=function(e){var r;return m(this,void 0,void 0,function(){var n,i,o,a,u,l;return E(this,function(c){switch(c.label){case 0:n=this.options,n.logger.debug("ConfigServiceBase.fetchLogicAsync() - called."),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.fetchRequestAsync((r=e.httpETag)!==null&&r!==void 0?r:null)];case 2:switch(o=c.sent(),a=o[0],u=o[1],a.statusCode){case 200:return u instanceof X?(n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config."),[2,M.success(new U(a.body,u,U.generateTimestamp(),a.eTag))]):(i=n.logger.fetchReceived200WithInvalidBody(u).toString(),n.logger.debug("ConfigServiceBase.fetchLogicAsync(): "+a.statusCode+" "+a.reasonPhrase+" was received but the HTTP response content was invalid. Returning null."),[2,M.error(e,i,u)]);case 304:return e?(n.logger.debug("ConfigServiceBase.fetchLogicAsync(): content was not modified. Returning last config with updated timestamp."),[2,M.notModified(e.with(U.generateTimestamp()))]):(i=n.logger.fetchReceived304WhenLocalCacheIsEmpty(a.statusCode,a.reasonPhrase).toString(),n.logger.debug("ConfigServiceBase.fetchLogicAsync(): "+a.statusCode+" "+a.reasonPhrase+" was received when no config is cached locally. Returning null."),[2,M.error(e,i)]);case 403:case 404:return i=n.logger.fetchFailedDueToInvalidSdkKey().toString(),n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."),[2,M.error(e.with(U.generateTimestamp()),i)];default:return i=n.logger.fetchFailedDueToUnexpectedHttpResponse(a.statusCode,a.reasonPhrase).toString(),n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."),[2,M.error(e,i)]}return[3,4];case 3:return l=c.sent(),i=(l instanceof Q&&l.cause==="timeout"?n.logger.fetchFailedDueToRequestTimeout(l.args[0],l):n.logger.fetchFailedDueToUnexpectedError(l)).toString(),n.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was unsuccessful. Returning null."),[2,M.error(e,i,l)];case 4:return[2]}})})},t.prototype.fetchRequestAsync=function(e,r){return r===void 0&&(r=2),m(this,void 0,void 0,function(){var n,i,o,a,u,l,c;return E(this,function(f){switch(f.label){case 0:n=this.options,n.logger.debug("ConfigServiceBase.fetchRequestAsync() - called."),i=0,f.label=1;case 1:return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()"+(i>0?", retry "+i+"/"+r:"")),[4,this.configFetcher.fetchLogic(n,e)];case 2:if(o=f.sent(),o.statusCode!==200)return[2,[o]];if(!o.body)return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."),[2,[o,new Error("No response body.")]];a=void 0;try{a=X.deserialize(o.body)}catch(h){return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."),[2,[o,h]]}if(u=a.preferences,!u)return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences is empty."),[2,[o,a]];if(l=u.baseUrl,!l||l===n.baseUrl)return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."),[2,[o,a]];if(c=u.redirectMode,n.baseUrlOverriden&&c!==B.Force)return n.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."),[2,[o,a]];if(n.baseUrl=l,c===B.No)return[2,[o,a]];if(c===B.Should&&n.logger.dataGovernanceIsOutOfSync(),i>=r)return n.logger.fetchFailedDueToRedirectLoop(),[2,[o,a]];f.label=3;case 3:return i++,[3,1];case 4:return[2]}})})},Object.defineProperty(t.prototype,"isOfflineExactly",{get:function(){return this.status===w.Offline},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOffline",{get:function(){return this.status!==w.Online},enumerable:!1,configurable:!0}),t.prototype.setOnlineCore=function(){},t.prototype.setOnline=function(){this.status===w.Offline?(this.setOnlineCore(),this.status=w.Online,this.options.logger.configServiceStatusChanged(w[this.status])):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline")},t.prototype.setOfflineCore=function(){},t.prototype.setOffline=function(){this.status===w.Online?(this.setOfflineCore(),this.status=w.Offline,this.options.logger.configServiceStatusChanged(w[this.status])):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline")},t.prototype.syncUpWithCache=function(){return this.options.cache.get(this.cacheKey)},t.prototype.getReadyPromise=function(e,r){return m(this,void 0,void 0,function(){var n;return E(this,function(i){switch(i.label){case 0:return[4,r(e)];case 1:return n=i.sent(),this.options.hooks.emit("clientReady",n),[2,n]}})})},t}();function Ft(t,e){var r,n=new Promise(function(i){return r=setTimeout(i,t)});return e&&(e.clearTimer=function(){return clearTimeout(r)}),n}function W(t,e){return e===void 0&&(e=!1),t instanceof Error?e&&t.stack?t.stack:t.toString():t+""}function Re(t){throw t}function Z(t){return Array.isArray(t)}function Dt(t){var e;return typeof((e=t)===null||e===void 0?void 0:e.then)=="function"}function he(t,e,r,n){e===void 0&&(e=0),n===void 0&&(n=", ");var i=t.length;if(!i)return"";var o="";return e>0&&i>e&&(t=t.slice(0,e),r&&(o=r==null?void 0:r(i-e))),"'"+t.join("'"+n+"'")+"'"+o}function H(t){function e(u,l){var c=u.charCodeAt(l);if(55296<=c&&c<56320){var f=u.charCodeAt(l+1);if(56320<=f&&f<=57343)return(c<<10)+f-56613888}return c}var r="",n=0,i=String.fromCharCode,o;for(o=0;o<t.length;o++){var a=e(t,o);a<=127||(r+=t.slice(n,o),a<=2047?(r+=i(192|a>>6),r+=i(128|a&63)):a<=65535?(r+=i(224|a>>12),r+=i(128|a>>6&63),r+=i(128|a&63)):(r+=i(240|a>>18),r+=i(128|a>>12&63),r+=i(128|a>>6&63),r+=i(128|a&63),++o),n=o+1)}return r+=t.slice(n,o)}function Fe(t){return typeof t=="number"?t:typeof t!="string"||!t.length||/^\s*$|^\s*0[^\d.e]/.test(t)?NaN:+t}var kt=function(t){R(e,t);function e(r,n){var i=t.call(this,r,n)||this;i.signalInitialization=function(){},i.pollIntervalMs=n.pollIntervalSeconds*1e3;var o=i.syncUpWithCache();if(n.maxInitWaitTimeSeconds!==0){i.initialized=!1;var a=new Promise(function(u){return i.signalInitialization=u});i.initializationPromise=i.waitForInitializationAsync(a).then(function(u){return i.initialized=!0,u})}else i.initialized=!0,i.initializationPromise=Promise.resolve(!1);return i.readyPromise=i.getReadyPromise(i.initializationPromise,function(u){return m(i,void 0,void 0,function(){return E(this,function(l){switch(l.label){case 0:return[4,u];case 1:return l.sent(),[2,this.getCacheState(this.options.cache.getInMemory())]}})})}),n.offline||i.startRefreshWorker(o),i}return e.prototype.waitForInitializationAsync=function(r){return m(this,void 0,void 0,function(){var n,i;return E(this,function(o){switch(o.label){case 0:return this.options.maxInitWaitTimeSeconds<0?[4,r]:[3,2];case 1:return o.sent(),[2,!0];case 2:return n={},[4,Promise.race([r.then(function(){return!0}),Ft(this.options.maxInitWaitTimeSeconds*1e3,n).then(function(){return!1})])];case 3:return i=o.sent(),n.clearTimer(),[2,i]}})})},e.prototype.getConfig=function(){return m(this,void 0,void 0,function(){function r(i){i.debug("AutoPollConfigService.getConfig() - returning value from cache.")}var n;return E(this,function(i){switch(i.label){case 0:return this.options.logger.debug("AutoPollConfigService.getConfig() called."),!this.isOffline&&!this.initialized?[4,this.options.cache.get(this.cacheKey)]:[3,3];case 1:return n=i.sent(),n.isExpired(this.pollIntervalMs)?(this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired, waiting for initialization."),[4,this.initializationPromise]):(r(this.options.logger),[2,n]);case 2:i.sent(),i.label=3;case 3:return[4,this.options.cache.get(this.cacheKey)];case 4:return n=i.sent(),n.isExpired(this.pollIntervalMs)?this.options.logger.debug("AutoPollConfigService.getConfig() - cache is empty or expired."):r(this.options.logger),[2,n]}})})},e.prototype.refreshConfigAsync=function(){return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."),t.prototype.refreshConfigAsync.call(this)},e.prototype.dispose=function(){this.options.logger.debug("AutoPollConfigService.dispose() called."),t.prototype.dispose.call(this),this.workerTimerId&&this.stopRefreshWorker()},e.prototype.onConfigFetched=function(r){t.prototype.onConfigFetched.call(this,r),this.signalInitialization()},e.prototype.setOnlineCore=function(){this.startRefreshWorker()},e.prototype.setOfflineCore=function(){this.stopRefreshWorker()},e.prototype.startRefreshWorker=function(r){return m(this,void 0,void 0,function(){var n,i,o=this;return E(this,function(a){switch(a.label){case 0:return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called."),n=this.pollIntervalMs,[4,r??this.options.cache.get(this.cacheKey)];case 1:return i=a.sent(),i.isExpired(this.pollIntervalMs)?this.isOfflineExactly?[3,3]:[4,this.refreshConfigCoreAsync(i)]:[3,4];case 2:a.sent(),a.label=3;case 3:return[3,5];case 4:this.signalInitialization(),a.label=5;case 5:return this.options.logger.debug("AutoPollConfigService.startRefreshWorker() - calling refreshWorkerLogic()'s setTimeout."),this.workerTimerId=setTimeout(function(u){return o.refreshWorkerLogic(u)},n,n),[2]}})})},e.prototype.stopRefreshWorker=function(){this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() - clearing setTimeout."),clearTimeout(this.workerTimerId)},e.prototype.refreshWorkerLogic=function(r){return m(this,void 0,void 0,function(){var n,i=this;return E(this,function(o){switch(o.label){case 0:return this.disposed?(this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called on a disposed client."),[2]):(this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - called."),this.isOffline?[3,3]:[4,this.options.cache.get(this.cacheKey)]);case 1:return n=o.sent(),[4,this.refreshConfigCoreAsync(n)];case 2:o.sent(),o.label=3;case 3:return this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() - calling refreshWorkerLogic()'s setTimeout."),this.workerTimerId=setTimeout(function(a){return i.refreshWorkerLogic(a)},r,r),[2]}})})},e.prototype.getCacheState=function(r){return r.isEmpty?s.ClientCacheState.NoFlagData:r.isExpired(this.pollIntervalMs)?s.ClientCacheState.HasCachedFlagDataOnly:s.ClientCacheState.HasUpToDateFlagData},e}(fe),Pt=function(){function t(){this.cachedConfig=U.empty}return t.prototype.set=function(e,r){this.cachedConfig=r},t.prototype.get=function(e){return this.cachedConfig},t.prototype.getInMemory=function(){return this.cachedConfig},t}(),De=function(){function t(e,r){this.cache=e,this.logger=r,this.cachedConfig=U.empty}return t.prototype.set=function(e,r){return m(this,void 0,void 0,function(){var n;return E(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!r.isEmpty)this.cachedSerializedConfig=U.serialize(r),this.cachedConfig=r;else return this.cachedSerializedConfig=void 0,this.cachedConfig=r,[2];return[4,this.cache.set(e,this.cachedSerializedConfig)];case 1:return i.sent(),[3,3];case 2:return n=i.sent(),this.logger.configServiceCacheWriteError(n),[3,3];case 3:return[2]}})})},t.prototype.updateCachedConfig=function(e){e==null||e===this.cachedSerializedConfig||(this.cachedConfig=U.deserialize(e),this.cachedSerializedConfig=e)},t.prototype.get=function(e){var r=this;try{var n=this.cache.get(e);if(Dt(n))return function(i){return m(r,void 0,void 0,function(){var o,a;return E(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),o=this.updateCachedConfig,[4,i];case 1:return o.apply(this,[u.sent()]),[3,3];case 2:return a=u.sent(),this.logger.configServiceCacheReadError(a),[3,3];case 3:return[2,this.cachedConfig]}})})}(n);this.updateCachedConfig(n)}catch(i){this.logger.configServiceCacheReadError(i)}return Promise.resolve(this.cachedConfig)},t.prototype.getInMemory=function(){return this.cachedConfig},t}();s.LogLevel=void 0,function(t){t[t.Debug=4]="Debug",t[t.Info=3]="Info",t[t.Warn=2]="Warn",t[t.Error=1]="Error",t[t.Off=-1]="Off"}(s.LogLevel||(s.LogLevel={}));var S=function(){function t(e,r,n){this.strings=e,this.argNames=r,this.argValues=n}return t.from=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return function(n){for(var i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];return new t(n,e,i)}},Object.defineProperty(t.prototype,"defaultFormattedMessage",{get:function(){var e=this.cachedDefaultFormattedMessage;if(e===void 0){e="";for(var r=this,n=r.strings,i=r.argValues,o=0;o<n.length-1;o++)e+=n[o],e+=i[o];e+=n[o],this.cachedDefaultFormattedMessage=e}return e},enumerable:!1,configurable:!0}),t.prototype.toString=function(){return this.defaultFormattedMessage},t}(),qt=function(){function t(e,r){this.logger=e,this.hooks=r}return Object.defineProperty(t.prototype,"level",{get:function(){var e;return(e=this.logger.level)!==null&&e!==void 0?e:s.LogLevel.Warn},enumerable:!1,configurable:!0}),t.prototype.isEnabled=function(e){return this.level>=e},t.prototype.log=function(e,r,n,i){var o;return this.isEnabled(e)&&this.logger.log(e,r,n,i),e===s.LogLevel.Error&&((o=this.hooks)===null||o===void 0||o.emit("clientError",n.toString(),i)),n},t.prototype.debug=function(e){this.log(s.LogLevel.Debug,0,e)},t.prototype.configJsonIsNotPresent=function(e){return this.log(s.LogLevel.Error,1e3,S.from("DEFAULT_RETURN_VALUE")(Pe||(Pe=A(["Config JSON is not present. Returning ","."],["Config JSON is not present. Returning ","."])),e))},t.prototype.configJsonIsNotPresentSingle=function(e,r,n){return this.log(s.LogLevel.Error,1e3,S.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")(qe||(qe=A(["Config JSON is not present when evaluating setting '","'. Returning the `","` parameter that you specified in your application: '","'."],["Config JSON is not present when evaluating setting '","'. Returning the \\`","\\` parameter that you specified in your application: '","'."])),e,r,n))},t.prototype.settingEvaluationFailedDueToMissingKey=function(e,r,n,i){return this.log(s.LogLevel.Error,1001,S.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE","AVAILABLE_KEYS")(Me||(Me=A(["Failed to evaluate setting '","' (the key was not found in config JSON). Returning the `","` parameter that you specified in your application: '","'. Available keys: [","]."],["Failed to evaluate setting '","' (the key was not found in config JSON). Returning the \\`","\\` parameter that you specified in your application: '","'. Available keys: [","]."])),e,r,n,i))},t.prototype.settingEvaluationError=function(e,r,n){return this.log(s.LogLevel.Error,1002,S.from("METHOD_NAME","DEFAULT_RETURN_VALUE")(We||(We=A(["Error occurred in the `","` method. Returning ","."],["Error occurred in the \\`","\\` method. Returning ","."])),e,r),n)},t.prototype.settingEvaluationErrorSingle=function(e,r,n,i,o){return this.log(s.LogLevel.Error,1002,S.from("METHOD_NAME","KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")(Ve||(Ve=A(["Error occurred in the `","` method while evaluating setting '","'. Returning the `","` parameter that you specified in your application: '","'."],["Error occurred in the \\`","\\` method while evaluating setting '","'. Returning the \\`","\\` parameter that you specified in your application: '","'."])),e,r,n,i),o)},t.prototype.forceRefreshError=function(e,r){return this.log(s.LogLevel.Error,1003,S.from("METHOD_NAME")(je||(je=A(["Error occurred in the `","` method."],["Error occurred in the \\`","\\` method."])),e),r)},t.prototype.fetchFailedDueToInvalidSdkKey=function(){return this.log(s.LogLevel.Error,1100,"Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey")},t.prototype.fetchFailedDueToUnexpectedHttpResponse=function(e,r){return this.log(s.LogLevel.Error,1101,S.from("STATUS_CODE","REASON_PHRASE")(Be||(Be=A(["Unexpected HTTP response was received while trying to fetch config JSON: "," ",""],["Unexpected HTTP response was received while trying to fetch config JSON: "," ",""])),e,r))},t.prototype.fetchFailedDueToRequestTimeout=function(e,r){return this.log(s.LogLevel.Error,1102,S.from("TIMEOUT")(_e||(_e=A(["Request timed out while trying to fetch config JSON. Timeout value: ","ms"],["Request timed out while trying to fetch config JSON. Timeout value: ","ms"])),e),r)},t.prototype.fetchFailedDueToUnexpectedError=function(e){return this.log(s.LogLevel.Error,1103,"Unexpected error occurred while trying to fetch config JSON. It is most likely due to a local network issue. Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.",e)},t.prototype.fetchFailedDueToRedirectLoop=function(){return this.log(s.LogLevel.Error,1104,"Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/")},t.prototype.fetchReceived200WithInvalidBody=function(e){return this.log(s.LogLevel.Error,1105,"Fetching config JSON was successful but the HTTP response content was invalid.",e)},t.prototype.fetchReceived304WhenLocalCacheIsEmpty=function(e,r){return this.log(s.LogLevel.Error,1106,S.from("STATUS_CODE","REASON_PHRASE")(He||(He=A(["Unexpected HTTP response was received when no config JSON is cached locally: "," ",""],["Unexpected HTTP response was received when no config JSON is cached locally: "," ",""])),e,r))},t.prototype.settingForVariationIdIsNotPresent=function(e){return this.log(s.LogLevel.Error,2011,S.from("VARIATION_ID")(Ke||(Ke=A(["Could not find the setting for the specified variation ID: '","'."],["Could not find the setting for the specified variation ID: '","'."])),e))},t.prototype.configServiceCacheReadError=function(e){return this.log(s.LogLevel.Error,2200,"Error occurred while reading the cache.",e)},t.prototype.configServiceCacheWriteError=function(e){return this.log(s.LogLevel.Error,2201,"Error occurred while writing the cache.",e)},t.prototype.clientIsAlreadyCreated=function(e){return this.log(s.LogLevel.Warn,3e3,S.from("SDK_KEY")(ze||(ze=A(["There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '","'."],["There is an existing client instance for the specified SDK Key. No new client instance will be created and the specified options are ignored. Returning the existing client instance. SDK Key: '","'."])),e))},t.prototype.userObjectIsMissing=function(e){return this.log(s.LogLevel.Warn,3001,S.from("KEY")(Ge||(Ge=A(["Cannot evaluate targeting rules and % options for setting '","' (User Object is missing). You should pass a User Object to the evaluation methods like `getValueAsync()` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate targeting rules and % options for setting '","' (User Object is missing). You should pass a User Object to the evaluation methods like \\`getValueAsync()\\` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e))},t.prototype.dataGovernanceIsOutOfSync=function(){return this.log(s.LogLevel.Warn,3002,"The `dataGovernance` parameter specified at the client initialization is not in sync with the preferences on the ConfigCat Dashboard. Read more: https://configcat.com/docs/advanced/data-governance/")},t.prototype.userObjectAttributeIsMissingPercentage=function(e,r){return this.log(s.LogLevel.Warn,3003,S.from("KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")(Je||(Je=A(["Cannot evaluate % options for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate % options for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e,r,r))},t.prototype.userObjectAttributeIsMissingCondition=function(e,r,n){return this.log(s.LogLevel.Warn,3003,S.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")(Ye||(Ye=A(["Cannot evaluate condition (",") for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"],["Cannot evaluate condition (",") for setting '","' (the User."," attribute is missing). You should set the User."," attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/"])),e,r,n,n))},t.prototype.userObjectAttributeIsInvalid=function(e,r,n,i){return this.log(s.LogLevel.Warn,3004,S.from("CONDITION","KEY","REASON","ATTRIBUTE_NAME")($e||($e=A(["Cannot evaluate condition (",") for setting '","' (","). Please check the User."," attribute and make sure that its value corresponds to the comparison operator."],["Cannot evaluate condition (",") for setting '","' (","). Please check the User."," attribute and make sure that its value corresponds to the comparison operator."])),e,r,n,i))},t.prototype.userObjectAttributeIsAutoConverted=function(e,r,n,i){return this.log(s.LogLevel.Warn,3005,S.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_VALUE")(Qe||(Qe=A(["Evaluation of condition (",") for setting '","' may not produce the expected result (the User."," attribute is not a string value, thus it was automatically converted to the string value '","'). Please make sure that using a non-string value was intended."],["Evaluation of condition (",") for setting '","' may not produce the expected result (the User."," attribute is not a string value, thus it was automatically converted to the string value '","'). Please make sure that using a non-string value was intended."])),e,r,n,i))},t.prototype.configServiceCannotInitiateHttpCalls=function(){return this.log(s.LogLevel.Warn,3200,"Client is in offline mode, it cannot initiate HTTP calls.")},t.prototype.configServiceMethodHasNoEffectDueToDisposedClient=function(e){return this.log(s.LogLevel.Warn,3201,S.from("METHOD_NAME")(Xe||(Xe=A(["The client object is already disposed, thus `","()` has no effect."],["The client object is already disposed, thus \\`","()\\` has no effect."])),e))},t.prototype.configServiceMethodHasNoEffectDueToOverrideBehavior=function(e,r){return this.log(s.LogLevel.Warn,3202,S.from("OVERRIDE_BEHAVIOR","METHOD_NAME")(Ze||(Ze=A(["Client is configured to use the `","` override behavior, thus `","()` has no effect."],["Client is configured to use the \\`","\\` override behavior, thus \\`","()\\` has no effect."])),e,r))},t.prototype.settingEvaluated=function(e){return this.log(s.LogLevel.Info,5e3,S.from("EVALUATE_LOG")(xe||(xe=A(["",""],["",""])),e))},t.prototype.configServiceStatusChanged=function(e){return this.log(s.LogLevel.Info,5200,S.from("MODE")(et||(et=A(["Switched to "," mode."],["Switched to "," mode."])),e.toUpperCase()))},t}(),ke=function(){function t(e){e===void 0&&(e=s.LogLevel.Warn),this.level=e,this.SOURCE="ConfigCat"}return t.prototype.log=function(e,r,n,i){var o=e===s.LogLevel.Debug?[console.info,"DEBUG"]:e===s.LogLevel.Info?[console.info,"INFO"]:e===s.LogLevel.Warn?[console.warn,"WARN"]:e===s.LogLevel.Error?[console.error,"ERROR"]:[console.log,s.LogLevel[e].toUpperCase()],a=o[0],u=o[1],l=i!==void 0?`
5
5
  `+W(i,!0):"";a(this.SOURCE+" - "+u+" - ["+r+"] "+n+l)},t}(),Pe,qe,Me,We,Ve,je,Be,_e,He,Ke,ze,Ge,Je,Ye,$e,Qe,Xe,Ze,xe,et;function K(t){return!!t.fn}var Mt=function(){function t(){this.events={},this.eventCount=0,this.addListener=this.on,this.off=this.removeListener}return t.prototype.addListenerCore=function(e,r,n){if(typeof r!="function")throw new TypeError("Listener must be a function");var i=this.events[e],o={fn:r,once:n};return i?K(i)?this.events[e]=[i,o]:i.push(o):(this.events[e]=o,this.eventCount++),this},t.prototype.removeListenerCore=function(e,r,n){var i=this.events[e];if(!i)return this;if(K(i))n(i,r)&&this.removeEvent(e);else for(var o=i.length-1;o>=0;o--)if(n(i[o],r)){i.splice(o,1),i.length?i.length===1&&(this.events[e]=i[0]):this.removeEvent(e);break}return this},t.prototype.removeEvent=function(e){--this.eventCount===0?this.events={}:delete this.events[e]},t.prototype.on=function(e,r){return this.addListenerCore(e,r,!1)},t.prototype.once=function(e,r){return this.addListenerCore(e,r,!0)},t.prototype.removeListener=function(e,r){if(typeof r!="function")throw new TypeError("Listener must be a function");return this.removeListenerCore(e,r,function(n,i){return n.fn===i})},t.prototype.removeAllListeners=function(e){return e?this.events[e]&&this.removeEvent(e):(this.events={},this.eventCount=0),this},t.prototype.listeners=function(e){var r=this.events[e];if(!r)return[];if(K(r))return[r.fn];for(var n=r.length,i=new Array(n),o=0;o<n;o++)i[o]=r[o].fn;return i},t.prototype.listenerCount=function(e){var r=this.events[e];return r?K(r)?1:r.length:0},t.prototype.eventNames=function(){var e=[];if(this.eventCount===0)return e;var r=this.events;for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e},t.prototype.emit=function(e,r,n,i,o){var a,u,l=this.events[e];if(!l)return!1;var c,f;K(l)?(a=[l,1],c=a[0],f=a[1]):(l=l.slice(),u=[l[0],l.length],c=u[0],f=u[1]);for(var h=arguments.length-1,g=0;;){switch(c.once&&this.removeListenerCore(e,c,function(p,C){return p===C}),h){case 0:c.fn.call(this);break;case 1:c.fn.call(this,r);break;case 2:c.fn.call(this,r,n);break;case 3:c.fn.call(this,r,n,i);break;case 4:c.fn.call(this,r,n,i,o);break;default:for(var v=new Array(h),d=0;d<h;d++)v[d]=arguments[d+1];c.fn.apply(this,v);break}if(++g>=f)break;c=l[g]}return!0},t}(),tt=function(){function t(){this.addListener=this.on,this.off=this.removeListener}return t.prototype.on=function(){return this},t.prototype.once=function(){return this},t.prototype.removeListener=function(){return this},t.prototype.removeAllListeners=function(){return this},t.prototype.listeners=function(){return[]},t.prototype.listenerCount=function(){return 0},t.prototype.eventNames=function(){return[]},t.prototype.emit=function(){return!1},t}();function rt(t){function e(k,P){var ue=k<<P|k>>>32-P;return ue}var r,n,i,o=new Array(80),a=1732584193,u=4023233417,l=2562383102,c=271733878,f=3285377520,h,g,v,d,p,C;t=H(t);var b=t.length,T=new Array;for(n=0;n<b-3;n+=4)i=t.charCodeAt(n)<<24|t.charCodeAt(n+1)<<16|t.charCodeAt(n+2)<<8|t.charCodeAt(n+3),T.push(i);switch(b%4){case 0:n=2147483648;break;case 1:n=t.charCodeAt(b-1)<<24|8388608;break;case 2:n=t.charCodeAt(b-2)<<24|t.charCodeAt(b-1)<<16|32768;break;case 3:n=t.charCodeAt(b-3)<<24|t.charCodeAt(b-2)<<16|t.charCodeAt(b-1)<<8|128;break}for(T.push(n);T.length%16!=14;)T.push(0);for(T.push(b>>>29),T.push(b<<3&4294967295),r=0;r<T.length;r+=16){for(n=0;n<16;n++)o[n]=T[r+n];for(n=16;n<=79;n++)o[n]=e(o[n-3]^o[n-8]^o[n-14]^o[n-16],1);for(h=a,g=u,v=l,d=c,p=f,n=0;n<=19;n++)C=e(h,5)+(g&v|~g&d)+p+o[n]+1518500249&4294967295,p=d,d=v,v=e(g,30),g=h,h=C;for(n=20;n<=39;n++)C=e(h,5)+(g^v^d)+p+o[n]+1859775393&4294967295,p=d,d=v,v=e(g,30),g=h,h=C;for(n=40;n<=59;n++)C=e(h,5)+(g&v|g&d|v&d)+p+o[n]+2400959708&4294967295,p=d,d=v,v=e(g,30),g=h,h=C;for(n=60;n<=79;n++)C=e(h,5)+(g^v^d)+p+o[n]+3395469782&4294967295,p=d,d=v,v=e(g,30),g=h,h=C;a=a+h&4294967295,u=u+g&4294967295,l=l+v&4294967295,c=c+d&4294967295,f=f+p&4294967295}return it([a,u,l,c,f])}function nt(t){function e(Tt,It){return Tt>>>It|Tt<<32-It}var r="length",n=Math.pow,i=n(2,32),o,a,u=nt,l=u.h,c=u.k;if(!c){l=[],c=[];for(var f={},h=2,g=0;g<64;h++)if(!f[h]){for(o=0;o<313;o+=h)f[o]=h;l[g]=n(h,.5)*i|0,c[g++]=n(h,1/3)*i|0}u.h=l=l.slice(0,8),u.k=c}var v=t[r]*8;t+="€";for(var d=[];t[r]%64-56;)t+="\0";for(o=0;o<t[r];o++)a=t.charCodeAt(o),d[o>>2]|=a<<(3-o)%4*8;for(d[d[r]]=v/i|0,d[d[r]]=v,a=0;a<d[r];){var p=d.slice(a,a+=16),C=l;for(l=l.slice(0,8),o=0;o<64;o++){var b=p[o-15],T=p[o-2],k=l[0],P=l[4],ue=l[7]+(e(P,6)^e(P,11)^e(P,25))+(P&l[5]^~P&l[6])+c[o]+(p[o]=o<16?p[o]:p[o-16]+(e(b,7)^e(b,18)^b>>>3)+p[o-7]+(e(T,17)^e(T,19)^T>>>10)|0),yr=(e(k,2)^e(k,13)^e(k,22))+(k&l[1]^k&l[2]^l[1]&l[2]);l=[ue+yr|0].concat(l),l[4]=l[4]+ue|0}for(o=0;o<8;o++)l[o]=l[o]+C[o]|0}return it(l,8)}function it(t,e){var r="0123456789abcdef",n="";e??(e=t.length);for(var i=0;i<e;i++)for(var o=3;o>=0;o--){var a=t[i]>>(o<<3)&255;n+=r[a>>4],n+=r[a&15]}return n}var ot=new tt,at=function(){function t(e){this.addListener=this.on,this.off=this.removeListener,this.eventEmitter=e}return t.prototype.tryDisconnect=function(){var e=this.eventEmitter;return this.eventEmitter=ot,e!==ot},t.prototype.on=function(e,r){return this.eventEmitter.on(e,r),this},t.prototype.once=function(e,r){return this.eventEmitter.once(e,r),this},t.prototype.removeListener=function(e,r){return this.eventEmitter.removeListener(e,r),this},t.prototype.removeAllListeners=function(e){return this.eventEmitter.removeAllListeners(e),this},t.prototype.listeners=function(e){return this.eventEmitter.listeners(e)},t.prototype.listenerCount=function(e){return this.eventEmitter.listenerCount(e)},t.prototype.eventNames=function(){return this.eventEmitter.eventNames()},t.prototype.emit=function(e){for(var r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return(r=this.eventEmitter).emit.apply(r,Ie([e],n))},t}();function Wt(){typeof Object.values>"u"&&(Object.values=Vt),typeof Object.entries>"u"&&(Object.entries=jt),typeof Object.fromEntries>"u"&&(Object.fromEntries=Bt)}function Vt(t){for(var e=[],r=0,n=Object.keys(t);r<n.length;r++){var i=n[r];e.push(t[i])}return e}function jt(t){for(var e=[],r=0,n=Object.keys(t);r<n.length;r++){var i=n[r];e.push([i,t[i]])}return e}function Bt(t){var e,r={};if(Array.isArray(t))for(var n=0,i=t;n<i.length;n++){var o=i[n],a=o[0],u=o[1];r[a]=u}else if(typeof Symbol<"u"&&(t!=null&&t[Symbol.iterator]))for(var l=t[Symbol.iterator](),c=void 0,f=void 0;e=l.next(),c=e.value,f=e.done,!f;){var a=c[0],u=c[1];r[a]=u}else throw new TypeError("Object.fromEntries() requires a single iterable argument");return r}function st(){var t=function(e){this.target=e};return t.prototype.deref=function(){return this.target},t.isFallback=!0,t}var ut=function(){return typeof WeakRef=="function"};s.PollingMode=void 0,function(t){t[t.AutoPoll=0]="AutoPoll",t[t.LazyLoad=1]="LazyLoad",t[t.ManualPoll=2]="ManualPoll"}(s.PollingMode||(s.PollingMode={})),s.DataGovernance=void 0,function(t){t[t.Global=0]="Global",t[t.EuOnly=1]="EuOnly"}(s.DataGovernance||(s.DataGovernance={}));var ge=function(){function t(e,r,n,i,o){var a,u,l;if(this.requestTimeoutMs=3e4,this.baseUrlOverriden=!1,this.proxy="",this.offline=!1,!e)throw new Error("Invalid 'sdkKey' value");switch(this.sdkKey=e,this.clientVersion=r,this.dataGovernance=(a=n==null?void 0:n.dataGovernance)!==null&&a!==void 0?a:s.DataGovernance.Global,this.dataGovernance){case s.DataGovernance.EuOnly:this.baseUrl="https://cdn-eu.configcat.com";break;default:this.baseUrl="https://cdn-global.configcat.com";break}var c=(u=o==null?void 0:o())!==null&&u!==void 0?u:new Mt,f=new at(c),h=new(ut()?WeakRef:st())(f);this.hooks={hooks:f,hooksWeakRef:h,emit:function(d){for(var p,C,b=[],T=1;T<arguments.length;T++)b[T-1]=arguments[T];return(C=(p=this.hooksWeakRef.deref())===null||p===void 0?void 0:p.emit.apply(p,Ie([d],b)))!==null&&C!==void 0?C:!1}};var g,v;if(n){if(g=n.logger,v=n.cache,n.requestTimeoutMs){if(n.requestTimeoutMs<0)throw new Error("Invalid 'requestTimeoutMs' value");this.requestTimeoutMs=n.requestTimeoutMs}n.baseUrl&&(this.baseUrl=n.baseUrl,this.baseUrlOverriden=!0),n.proxy&&(this.proxy=n.proxy),n.flagOverrides&&(this.flagOverrides=n.flagOverrides),n.defaultUser&&(this.defaultUser=n.defaultUser),n.offline&&(this.offline=n.offline),(l=n.setupHooks)===null||l===void 0||l.call(n,f)}this.logger=new qt(g??new ke,this.hooks),this.cache=v?new De(v,this.logger):i?i(this):new Pt}return t.prototype.yieldHooks=function(){var e=this.hooks,r=e.hooks;return delete e.hooks,r??new at(new tt)},t.prototype.getUrl=function(){return this.baseUrl+"/configuration-files/"+this.sdkKey+"/"+t.configFileName+"?sdk="+this.clientVersion},t.prototype.getCacheKey=function(){return rt(this.sdkKey+"_"+t.configFileName+"_"+U.serializationFormatVersion)},t.configFileName="config_v6.json",t}(),lt=function(t){R(e,t);function e(r,n,i,o,a,u){var l=t.call(this,r,n+"/a-"+i,o,a,u)||this;l.pollIntervalSeconds=60,l.maxInitWaitTimeSeconds=5,o&&(o.pollIntervalSeconds!=null&&(l.pollIntervalSeconds=o.pollIntervalSeconds),o.maxInitWaitTimeSeconds!=null&&(l.maxInitWaitTimeSeconds=o.maxInitWaitTimeSeconds));var c=2147483;if(!(typeof l.pollIntervalSeconds=="number"&&1<=l.pollIntervalSeconds&&l.pollIntervalSeconds<=c))throw new Error("Invalid 'pollIntervalSeconds' value");if(!(typeof l.maxInitWaitTimeSeconds=="number"&&l.maxInitWaitTimeSeconds<=c))throw new Error("Invalid 'maxInitWaitTimeSeconds' value");return l}return e}(ge),ct=function(t){R(e,t);function e(r,n,i,o,a,u){return t.call(this,r,n+"/m-"+i,o,a,u)||this}return e}(ge),ft=function(t){R(e,t);function e(r,n,i,o,a,u){var l=t.call(this,r,n+"/l-"+i,o,a,u)||this;if(l.cacheTimeToLiveSeconds=60,o&&o.cacheTimeToLiveSeconds!=null&&(l.cacheTimeToLiveSeconds=o.cacheTimeToLiveSeconds),!(typeof l.cacheTimeToLiveSeconds=="number"&&1<=l.cacheTimeToLiveSeconds&&l.cacheTimeToLiveSeconds<=2147483647))throw new Error("Invalid 'cacheTimeToLiveSeconds' value");return l}return e}(ge);s.OverrideBehaviour=void 0,function(t){t[t.LocalOnly=0]="LocalOnly",t[t.LocalOverRemote=1]="LocalOverRemote",t[t.RemoteOverLocal=2]="RemoteOverLocal"}(s.OverrideBehaviour||(s.OverrideBehaviour={}));var _t=function(){function t(e,r){this.initialSettings=this.constructor.getCurrentSettings(e),r&&(this.map=e)}return t.getCurrentSettings=function(e){return Object.fromEntries(Object.entries(e).map(function(r){var n=r[0],i=r[1];return[n,we.fromValue(i)]}))},t.prototype.getOverrides=function(){return Promise.resolve(this.getOverridesSync())},t.prototype.getOverridesSync=function(){return this.map?this.constructor.getCurrentSettings(this.map):this.initialSettings},t}(),Ht=function(){function t(e,r){this.dataSource=e,this.behaviour=r}return t}(),Kt=function(t){R(e,t);function e(r,n){var i=t.call(this,r,n)||this;i.cacheTimeToLiveMs=n.cacheTimeToLiveSeconds*1e3;var o=i.syncUpWithCache();return i.readyPromise=i.getReadyPromise(o,function(a){return m(i,void 0,void 0,function(){var u;return E(this,function(l){switch(l.label){case 0:return u=this.getCacheState,[4,a];case 1:return[2,u.apply(this,[l.sent()])]}})})}),i}return e.prototype.getConfig=function(){return m(this,void 0,void 0,function(){function r(o,a){a===void 0&&(a=""),o.debug("LazyLoadConfigService.getConfig(): cache is empty or expired"+a+".")}var n,i;return E(this,function(o){switch(o.label){case 0:return this.options.logger.debug("LazyLoadConfigService.getConfig() called."),[4,this.options.cache.get(this.cacheKey)];case 1:return n=o.sent(),n.isExpired(this.cacheTimeToLiveMs)?this.isOffline?[3,3]:(r(this.options.logger,", calling refreshConfigCoreAsync()"),[4,this.refreshConfigCoreAsync(n)]):[3,5];case 2:return i=o.sent(),n=i[1],[3,4];case 3:r(this.options.logger),o.label=4;case 4:return[2,n];case 5:return this.options.logger.debug("LazyLoadConfigService.getConfig(): cache is valid, returning from cache."),[2,n]}})})},e.prototype.refreshConfigAsync=function(){return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."),t.prototype.refreshConfigAsync.call(this)},e.prototype.getCacheState=function(r){return r.isEmpty?s.ClientCacheState.NoFlagData:r.isExpired(this.cacheTimeToLiveMs)?s.ClientCacheState.HasCachedFlagDataOnly:s.ClientCacheState.HasUpToDateFlagData},e}(fe),zt=function(t){R(e,t);function e(r,n){var i=t.call(this,r,n)||this,o=i.syncUpWithCache();return i.readyPromise=i.getReadyPromise(o,function(a){return m(i,void 0,void 0,function(){var u;return E(this,function(l){switch(l.label){case 0:return u=this.getCacheState,[4,a];case 1:return[2,u.apply(this,[l.sent()])]}})})}),i}return e.prototype.getCacheState=function(r){return r.isEmpty?s.ClientCacheState.NoFlagData:s.ClientCacheState.HasCachedFlagDataOnly},e.prototype.getConfig=function(){return m(this,void 0,void 0,function(){return E(this,function(r){switch(r.label){case 0:return this.options.logger.debug("ManualPollService.getConfig() called."),[4,this.options.cache.get(this.cacheKey)];case 1:return[2,r.sent()]}})})},e.prototype.refreshConfigAsync=function(){return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."),t.prototype.refreshConfigAsync.call(this)},e}(fe),ht="<invalid value>",Gt="<invalid name>",ve="<invalid operator>",Jt="<invalid reference>",Yt=10,gt=function(){function t(){this.log="",this.indent=""}return t.prototype.resetIndent=function(){return this.indent="",this},t.prototype.increaseIndent=function(){return this.indent+=" ",this},t.prototype.decreaseIndent=function(){return this.indent=this.indent.slice(0,-2),this},t.prototype.newLine=function(e){return this.log+=`
6
- `+this.indent+(e??""),this},t.prototype.append=function(e){return this.log+=e,this},t.prototype.toString=function(){return this.log},t.prototype.appendEvaluationResult=function(e){return this.append(""+e)},t.prototype.appendUserConditionCore=function(e,r,n){return this.append("User."+e+" "+de(r)+" '"+(n??ht)+"'")},t.prototype.appendUserConditionString=function(e,r,n,i){return this.appendUserConditionCore(e,r,i?"<hashed value>":n)},t.prototype.appendUserConditionStringList=function(e,r,n,i){if(n==null)return this.appendUserConditionCore(e,r);var o="value",a="values",u=de(r);if(i)return this.append("User."+e+" "+u+" [<"+n.length+" hashed "+(n.length===1?o:a)+">]");var l=he(n,Yt,function(c){return", ... <"+c+" more "+(c===1?o:a)+">"});return this.append("User."+e+" "+u+" ["+l+"]")},t.prototype.appendUserConditionNumber=function(e,r,n,i){if(n==null)return this.appendUserConditionCore(e,r);var o=de(r),a;return i&&!isNaN(a=new Date(n*1e3))?this.append("User."+e+" "+o+" '"+n+"' ("+a.toISOString()+" UTC)"):this.append("User."+e+" "+o+" '"+n+"'")},t.prototype.appendUserCondition=function(e){var r=e.comparisonAttribute,n=e.comparator;switch(e.comparator){case s.UserComparator.IsOneOf:case s.UserComparator.IsNotOneOf:case s.UserComparator.ContainsAnyOf:case s.UserComparator.NotContainsAnyOf:case s.UserComparator.SemVerIsOneOf:case s.UserComparator.SemVerIsNotOneOf:case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.TextNotStartsWithAnyOf:case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.TextNotEndsWithAnyOf:case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.ArrayNotContainsAnyOf:return this.appendUserConditionStringList(r,n,e.comparisonValue,!1);case s.UserComparator.SemVerLess:case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.SemVerGreater:case s.UserComparator.SemVerGreaterOrEquals:case s.UserComparator.TextEquals:case s.UserComparator.TextNotEquals:return this.appendUserConditionString(r,n,e.comparisonValue,!1);case s.UserComparator.NumberEquals:case s.UserComparator.NumberNotEquals:case s.UserComparator.NumberLess:case s.UserComparator.NumberLessOrEquals:case s.UserComparator.NumberGreater:case s.UserComparator.NumberGreaterOrEquals:return this.appendUserConditionNumber(r,n,e.comparisonValue);case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SensitiveIsNotOneOf:case s.UserComparator.SensitiveTextStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:case s.UserComparator.SensitiveTextEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:case s.UserComparator.SensitiveArrayContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return this.appendUserConditionStringList(r,n,e.comparisonValue,!0);case s.UserComparator.DateTimeBefore:case s.UserComparator.DateTimeAfter:return this.appendUserConditionNumber(r,n,e.comparisonValue,!0);case s.UserComparator.SensitiveTextEquals:case s.UserComparator.SensitiveTextNotEquals:return this.appendUserConditionString(r,n,e.comparisonValue,!0);default:return this.appendUserConditionCore(r,n,e.comparisonValue)}},t.prototype.appendPrerequisiteFlagCondition=function(e){var r=e.prerequisiteFlagKey,n=e.comparator,i=e.comparisonValue;return this.append("Flag '"+r+"' "+$t(n)+" '"+x(i)+"'")},t.prototype.appendSegmentCondition=function(e){var r,n=e.segment,i=e.comparator,o=(r=n==null?void 0:n.name)!==null&&r!==void 0?r:n==null?Jt:Gt;return this.append("User "+vt(i)+" '"+o+"'")},t.prototype.appendConditionConsequence=function(e){return this.append(" => ").appendEvaluationResult(e),e?this:this.append(", skipping the remaining AND conditions")},t.prototype.appendTargetingRuleThenPart=function(e,r){(r?this.newLine():this.append(" ")).append("THEN");var n=e.then;return this.append(Z(n)?" % options":" '"+x(n.value)+"'")},t.prototype.appendTargetingRuleConsequence=function(e,r,n){return this.increaseIndent(),this.appendTargetingRuleThenPart(e,n).append(" => ").append(r===!0?"MATCH, applying rule":r===!1?"no match":r),this.decreaseIndent()},t}();function de(t){switch(t){case s.UserComparator.IsOneOf:case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SemVerIsOneOf:return"IS ONE OF";case s.UserComparator.IsNotOneOf:case s.UserComparator.SensitiveIsNotOneOf:case s.UserComparator.SemVerIsNotOneOf:return"IS NOT ONE OF";case s.UserComparator.ContainsAnyOf:return"CONTAINS ANY OF";case s.UserComparator.NotContainsAnyOf:return"NOT CONTAINS ANY OF";case s.UserComparator.SemVerLess:case s.UserComparator.NumberLess:return"<";case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.NumberLessOrEquals:return"<=";case s.UserComparator.SemVerGreater:case s.UserComparator.NumberGreater:return">";case s.UserComparator.SemVerGreaterOrEquals:case s.UserComparator.NumberGreaterOrEquals:return">=";case s.UserComparator.NumberEquals:return"=";case s.UserComparator.NumberNotEquals:return"!=";case s.UserComparator.DateTimeBefore:return"BEFORE";case s.UserComparator.DateTimeAfter:return"AFTER";case s.UserComparator.TextEquals:case s.UserComparator.SensitiveTextEquals:return"EQUALS";case s.UserComparator.TextNotEquals:case s.UserComparator.SensitiveTextNotEquals:return"NOT EQUALS";case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.SensitiveTextStartsWithAnyOf:return"STARTS WITH ANY OF";case s.UserComparator.TextNotStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:return"NOT STARTS WITH ANY OF";case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.SensitiveTextEndsWithAnyOf:return"ENDS WITH ANY OF";case s.UserComparator.TextNotEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:return"NOT ENDS WITH ANY OF";case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.SensitiveArrayContainsAnyOf:return"ARRAY CONTAINS ANY OF";case s.UserComparator.ArrayNotContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return"ARRAY NOT CONTAINS ANY OF";default:return ve}}function pe(t){return new gt().appendUserCondition(t).toString()}function $t(t){switch(t){case s.PrerequisiteFlagComparator.Equals:return"EQUALS";case s.PrerequisiteFlagComparator.NotEquals:return"NOT EQUALS";default:return ve}}function vt(t){switch(t){case s.SegmentComparator.IsIn:return"IS IN SEGMENT";case s.SegmentComparator.IsNotIn:return"IS NOT IN SEGMENT";default:return ve}}function x(t){return Y(t)?t.toString():ht}var dt=/^[0-9]+$/,z=function(t,e){var r=dt.test(t),n=dt.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:t<e?-1:1},ye=256,ee=Number.MAX_SAFE_INTEGER||9007199254740991,G=[],O=[],y={},Qt=0,I=function(t,e){var r=Qt++;y[t]=r,O[r]=e,G[r]=new RegExp(e)};I("NUMERICIDENTIFIER","0|[1-9]\\d*"),I("NUMERICIDENTIFIERLOOSE","[0-9]+"),I("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),I("MAINVERSION","("+O[y.NUMERICIDENTIFIER]+")\\."+("("+O[y.NUMERICIDENTIFIER]+")\\.")+("("+O[y.NUMERICIDENTIFIER]+")")),I("MAINVERSIONLOOSE","("+O[y.NUMERICIDENTIFIERLOOSE]+")\\."+("("+O[y.NUMERICIDENTIFIERLOOSE]+")\\.")+("("+O[y.NUMERICIDENTIFIERLOOSE]+")")),I("PRERELEASEIDENTIFIER","(?:"+O[y.NUMERICIDENTIFIER]+"|"+O[y.NONNUMERICIDENTIFIER]+")"),I("PRERELEASEIDENTIFIERLOOSE","(?:"+O[y.NUMERICIDENTIFIERLOOSE]+"|"+O[y.NONNUMERICIDENTIFIER]+")"),I("PRERELEASE","(?:-("+O[y.PRERELEASEIDENTIFIER]+"(?:\\."+O[y.PRERELEASEIDENTIFIER]+")*))"),I("PRERELEASELOOSE","(?:-?("+O[y.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+O[y.PRERELEASEIDENTIFIERLOOSE]+")*))"),I("BUILDIDENTIFIER","[0-9A-Za-z-]+"),I("BUILD","(?:\\+("+O[y.BUILDIDENTIFIER]+"(?:\\."+O[y.BUILDIDENTIFIER]+")*))"),I("FULLPLAIN","v?"+O[y.MAINVERSION]+O[y.PRERELEASE]+"?"+O[y.BUILD]+"?"),I("FULL","^"+O[y.FULLPLAIN]+"$"),I("LOOSEPLAIN","[v=\\s]*"+O[y.MAINVERSIONLOOSE]+O[y.PRERELEASELOOSE]+"?"+O[y.BUILD]+"?"),I("LOOSE","^"+O[y.LOOSEPLAIN]+"$");var pt=function(){function t(e,r){if((!r||typeof r!="object")&&(r={loose:!!r,includePrerelease:!1}),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError("Invalid Version: "+e);if(e.length>ye)throw new TypeError("version is longer than "+ye+" characters");this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;var n=e.trim().match(r.loose?G[y.LOOSE]:G[y.FULL]);if(!n)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>ee||this.major<0)throw new TypeError("Invalid major version");if(this.minor>ee||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>ee||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(function(i){if(/^[0-9]+$/.test(i)){var o=+i;if(o>=0&&o<ee)return o}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}return t.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},t.prototype.toString=function(){return this.version},t.prototype.compare=function(e){if(!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)},t.prototype.compareMain=function(e){return e instanceof t||(e=new t(e,this.options)),z(this.major,e.major)||z(this.minor,e.minor)||z(this.patch,e.patch)},t.prototype.comparePre=function(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var r=0;do{var n=this.prerelease[r],i=e.prerelease[r];if(n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return z(n,i)}while(++r)},t.prototype.compareBuild=function(e){e instanceof t||(e=new t(e,this.options));var r=0;do{var n=this.build[r],i=e.build[r];if(n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return z(n,i)}while(++r)},t.prototype.inc=function(e,r){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{for(var n=this.prerelease.length;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t}(),me=function(t,e){if((!e||typeof e!="object")&&(e={loose:!!e,includePrerelease:!1}),t instanceof pt)return t;if(typeof t!="string"||t.length>ye)return null;var r=e.loose?G[y.LOOSE]:G[y.FULL];if(!r.test(t))return null;try{return new pt(t,e)}catch{return null}},Xt=function(){function t(e,r,n,i){i===void 0&&(i={}),this.identifier=e,this.email=r,this.country=n,this.custom=i}return t}();function Zt(t){var e,r={},n="Identifier",i="Email",o="Country";if(r[n]=(e=t.identifier)!==null&&e!==void 0?e:"",t.email!=null&&(r[i]=t.email),t.country!=null&&(r[o]=t.country),t.custom!=null)for(var a=[n,i,o],u=0,l=Object.entries(t.custom);u<l.length;u++){var c=l[u],f=c[0],h=c[1];h!=null&&a.indexOf(f)<0&&(r[f]=h)}return r}var Ee=function(){function t(e,r,n,i){this.key=e,this.setting=r,this.user=n,this.settings=i}return Object.defineProperty(t.prototype,"userAttributes",{get:function(){var e=this.$userAttributes;return e!==void 0?e:this.$userAttributes=this.user?Zt(this.user):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visitedFlags",{get:function(){var e;return(e=this.$visitedFlags)!==null&&e!==void 0?e:this.$visitedFlags=[]},enumerable:!1,configurable:!0}),t.forPrerequisiteFlag=function(e,r,n){var i=new t(e,r,n.user,n.settings);return i.$userAttributes=n.userAttributes,i.$visitedFlags=n.visitedFlags,i.logBuilder=n.logBuilder,i},t}(),yt="The current targeting rule is ignored and the evaluation continues with the next rule.",Oe="cannot evaluate, User Object is missing",xt=function(t){return"cannot evaluate, the User."+t+" attribute is missing"},er=function(t,e){return"cannot evaluate, the User."+t+" attribute is invalid ("+e+")"},tr=function(){function t(e){this.logger=e}return t.prototype.evaluate=function(e,r){this.logger.debug("RolloutEvaluator.evaluate() called.");var n=r.logBuilder;this.logger.isEnabled(s.LogLevel.Info)&&(r.logBuilder=n=new gt,n.append("Evaluating '"+r.key+"'"),r.userAttributes&&n.append(" for User '"+JSON.stringify(r.userAttributes)+"'"),n.increaseIndent());var i;try{var o=void 0,a=void 0;if(e!=null){var u=r.setting.type;if(u>=0&&!ir(e,u))throw new TypeError("The type of a setting must match the type of the specified default value. "+("Setting's type was "+s.SettingType[u]+" but the default value's type was "+typeof e+". ")+("Please use a default value which corresponds to the setting type "+s.SettingType[u]+". ")+"Learn more: https://configcat.com/docs/sdk-reference/js/#setting-type-mapping");o=this.evaluateSetting(r),i=o.selectedValue.value,a=typeof i==typeof e}else o=this.evaluateSetting(r),i=o.selectedValue.value,a=Y(i);return a||Ae(i),o}catch(l){throw n==null||n.resetIndent().increaseIndent(),i=e,l}finally{n&&(n.newLine("Returning '"+i+"'.").decreaseIndent(),this.logger.settingEvaluated(n.toString()))}},t.prototype.evaluateSetting=function(e){var r,n=e.setting.targetingRules;if(n.length>0&&(r=this.evaluateTargetingRules(n,e)))return r;var i=e.setting.percentageOptions;return i.length>0&&(r=this.evaluatePercentageOptions(i,void 0,e))?r:{selectedValue:e.setting}},t.prototype.evaluateTargetingRules=function(e,r){var n=r.logBuilder;n==null||n.newLine("Evaluating targeting rules and applying the first match if any:");for(var i=0;i<e.length;i++){var o=e[i],a=o.conditions,u=this.evaluateConditions(a,o,r.key,r);if(u!==!0){J(u)&&(n==null||n.increaseIndent().newLine(yt).decreaseIndent());continue}if(!Z(o.then))return{selectedValue:o.then,matchedTargetingRule:o};var l=o.then;n==null||n.increaseIndent();var c=this.evaluatePercentageOptions(l,o,r);if(c)return n==null||n.decreaseIndent(),c;n==null||n.newLine(yt).decreaseIndent()}},t.prototype.evaluatePercentageOptions=function(e,r,n){var i=n.logBuilder;if(!n.userAttributes){i==null||i.newLine("Skipping % options because the User Object is missing."),n.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(n.key),n.isMissingUserObjectLogged=!0);return}var o=n.setting.percentageOptionsAttribute,a=n.userAttributes[o];if(a==null){i==null||i.newLine("Skipping % options because the User."+o+" attribute is missing."),n.isMissingUserObjectAttributeLogged||(this.logger.userObjectAttributeIsMissingPercentage(n.key,o),n.isMissingUserObjectAttributeLogged=!0);return}i==null||i.newLine("Evaluating % options based on the User."+o+" attribute:");var u=rt(n.key+Ot(a)),l=parseInt(u.substring(0,7),16)%100;i==null||i.newLine("- Computing hash in the [0..99] range from User."+o+" => "+l+" (this value is sticky and consistent across all SDKs)");for(var c=0,f=0;f<e.length;f++){var h=e[f];if(c+=h.percentage,!(l>=c))return i==null||i.newLine("- Hash value "+l+" selects % option "+(f+1)+" ("+h.percentage+"%), '"+x(h.value)+"'."),{selectedValue:h,matchedTargetingRule:r,matchedPercentageOption:h}}throw new Error("Sum of percentage option percentages are less than 100.")},t.prototype.evaluateConditions=function(e,r,n,i){var o=!0,a=i.logBuilder,u=!1;a==null||a.newLine("- ");for(var l=0;l<e.length;l++){var c=e[l];switch(a&&(l?a.increaseIndent().newLine("AND "):a.append("IF ").increaseIndent()),c.type){case"UserCondition":o=this.evaluateUserCondition(c,n,i),u=e.length>1;break;case"PrerequisiteFlagCondition":o=this.evaluatePrerequisiteFlagCondition(c,i),u=!0;break;case"SegmentCondition":o=this.evaluateSegmentCondition(c,i),u=!J(o)||o!==Oe||e.length>1;break;default:throw new Error}var f=o===!0;if(a&&((!r||e.length>1)&&a.appendConditionConsequence(f),a.decreaseIndent()),!f)break}return r&&(a==null||a.appendTargetingRuleConsequence(r,o,u)),o},t.prototype.evaluateUserCondition=function(e,r,n){var i=n.logBuilder;if(i==null||i.appendUserCondition(e),!n.userAttributes)return n.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(n.key),n.isMissingUserObjectLogged=!0),Oe;var o=e.comparisonAttribute,a=n.userAttributes[o];if(a==null||a==="")return this.logger.userObjectAttributeIsMissingCondition(pe(e),n.key,o),xt(o);var u,l,c,f;switch(e.comparator){case s.UserComparator.TextEquals:case s.UserComparator.TextNotEquals:return u=F(o,a,e,n.key,this.logger),this.evaluateTextEquals(u,e.comparisonValue,e.comparator===s.UserComparator.TextNotEquals);case s.UserComparator.SensitiveTextEquals:case s.UserComparator.SensitiveTextNotEquals:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextEquals(u,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveTextNotEquals);case s.UserComparator.IsOneOf:case s.UserComparator.IsNotOneOf:return u=F(o,a,e,n.key,this.logger),this.evaluateIsOneOf(u,e.comparisonValue,e.comparator===s.UserComparator.IsNotOneOf);case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SensitiveIsNotOneOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveIsOneOf(u,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveIsNotOneOf);case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.TextNotStartsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateTextSliceEqualsAnyOf(u,e.comparisonValue,!0,e.comparator===s.UserComparator.TextNotStartsWithAnyOf);case s.UserComparator.SensitiveTextStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(u,e.comparisonValue,n.setting.configJsonSalt,r,!0,e.comparator===s.UserComparator.SensitiveTextNotStartsWithAnyOf);case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.TextNotEndsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateTextSliceEqualsAnyOf(u,e.comparisonValue,!1,e.comparator===s.UserComparator.TextNotEndsWithAnyOf);case s.UserComparator.SensitiveTextEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(u,e.comparisonValue,n.setting.configJsonSalt,r,!1,e.comparator===s.UserComparator.SensitiveTextNotEndsWithAnyOf);case s.UserComparator.ContainsAnyOf:case s.UserComparator.NotContainsAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateContainsAnyOf(u,e.comparisonValue,e.comparator===s.UserComparator.NotContainsAnyOf);case s.UserComparator.SemVerIsOneOf:case s.UserComparator.SemVerIsNotOneOf:return l=Ct(o,a,e,n.key,this.logger),typeof l!="string"?this.evaluateSemVerIsOneOf(l,e.comparisonValue,e.comparator===s.UserComparator.SemVerIsNotOneOf):l;case s.UserComparator.SemVerLess:case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.SemVerGreater:case s.UserComparator.SemVerGreaterOrEquals:return l=Ct(o,a,e,n.key,this.logger),typeof l!="string"?this.evaluateSemVerRelation(l,e.comparator,e.comparisonValue):l;case s.UserComparator.NumberEquals:case s.UserComparator.NumberNotEquals:case s.UserComparator.NumberLess:case s.UserComparator.NumberLessOrEquals:case s.UserComparator.NumberGreater:case s.UserComparator.NumberGreaterOrEquals:return c=rr(o,a,e,n.key,this.logger),typeof c!="string"?this.evaluateNumberRelation(c,e.comparator,e.comparisonValue):c;case s.UserComparator.DateTimeBefore:case s.UserComparator.DateTimeAfter:return c=nr(o,a,e,n.key,this.logger),typeof c!="string"?this.evaluateDateTimeRelation(c,e.comparisonValue,e.comparator===s.UserComparator.DateTimeBefore):c;case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.ArrayNotContainsAnyOf:return f=St(o,a,e,n.key,this.logger),typeof f!="string"?this.evaluateArrayContainsAnyOf(f,e.comparisonValue,e.comparator===s.UserComparator.ArrayNotContainsAnyOf):f;case s.UserComparator.SensitiveArrayContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return f=St(o,a,e,n.key,this.logger),typeof f!="string"?this.evaluateSensitiveArrayContainsAnyOf(f,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveArrayNotContainsAnyOf):f;default:throw new Error}},t.prototype.evaluateTextEquals=function(e,r,n){return e===r!==n},t.prototype.evaluateSensitiveTextEquals=function(e,r,n,i,o){var a=Ce(e,n,i);return a===r!==o},t.prototype.evaluateIsOneOf=function(e,r,n){var i=r.indexOf(e)>=0;return i!==n},t.prototype.evaluateSensitiveIsOneOf=function(e,r,n,i,o){var a=Ce(e,n,i),u=r.indexOf(a)>=0;return u!==o},t.prototype.evaluateTextSliceEqualsAnyOf=function(e,r,n,i){for(var o=0;o<r.length;o++){var a=r[o];if(!(e.length<a.length)){var u=(n?e.lastIndexOf(a,0):e.indexOf(a,e.length-a.length))>=0;if(u)return!i}}return i},t.prototype.evaluateSensitiveTextSliceEqualsAnyOf=function(e,r,n,i,o,a){for(var u=H(e),l=0;l<r.length;l++){var c=r[l],f=c.indexOf("_"),h=parseInt(c.slice(0,f));if(!(u.length<h)){var g=o?u.slice(0,h):u.slice(u.length-h),v=Et(g,n,i),d=v===c.slice(f+1);if(d)return!a}}return a},t.prototype.evaluateContainsAnyOf=function(e,r,n){for(var i=0;i<r.length;i++)if(e.indexOf(r[i])>=0)return!n;return n},t.prototype.evaluateSemVerIsOneOf=function(e,r,n){for(var i=!1,o=0;o<r.length;o++){var a=r[o];if(a.length){var u=me(a.trim());if(!u)return!1;!i&&e.compare(u)===0&&(i=!0)}}return i!==n},t.prototype.evaluateSemVerRelation=function(e,r,n){var i=me(n.trim());if(!i)return!1;var o=e.compare(i);switch(r){case s.UserComparator.SemVerLess:return o<0;case s.UserComparator.SemVerLessOrEquals:return o<=0;case s.UserComparator.SemVerGreater:return o>0;case s.UserComparator.SemVerGreaterOrEquals:return o>=0}},t.prototype.evaluateNumberRelation=function(e,r,n){switch(r){case s.UserComparator.NumberEquals:return e===n;case s.UserComparator.NumberNotEquals:return e!==n;case s.UserComparator.NumberLess:return e<n;case s.UserComparator.NumberLessOrEquals:return e<=n;case s.UserComparator.NumberGreater:return e>n;case s.UserComparator.NumberGreaterOrEquals:return e>=n}},t.prototype.evaluateDateTimeRelation=function(e,r,n){return n?e<r:e>r},t.prototype.evaluateArrayContainsAnyOf=function(e,r,n){for(var i=0;i<e.length;i++){var o=r.indexOf(e[i])>=0;if(o)return!n}return n},t.prototype.evaluateSensitiveArrayContainsAnyOf=function(e,r,n,i,o){for(var a=0;a<e.length;a++){var u=Ce(e[a],n,i),l=r.indexOf(u)>=0;if(l)return!o}return o},t.prototype.evaluatePrerequisiteFlagCondition=function(e,r){var n=r.logBuilder;n==null||n.appendPrerequisiteFlagCondition(e);var i=e.prerequisiteFlagKey,o=r.settings[i];if(r.visitedFlags.push(r.key),r.visitedFlags.indexOf(i)>=0){r.visitedFlags.push(i);var a=he(r.visitedFlags,void 0,void 0," -> ");throw new Error("Circular dependency detected between the following depending flags: "+a+".")}var u=Ee.forPrerequisiteFlag(i,o,r);n==null||n.newLine("(").increaseIndent().newLine("Evaluating prerequisite flag '"+i+"':");var l=this.evaluateSetting(u);r.visitedFlags.pop();var c=l.selectedValue.value;if(typeof c!=typeof e.comparisonValue){if(Y(c))throw new Error("Type mismatch between comparison value '"+e.comparisonValue+"' and prerequisite flag '"+i+"'.");Ae(c)}var f;switch(e.comparator){case s.PrerequisiteFlagComparator.Equals:f=c===e.comparisonValue;break;case s.PrerequisiteFlagComparator.NotEquals:f=c!==e.comparisonValue;break;default:throw new Error}return n==null||n.newLine("Prerequisite flag evaluation result: '"+x(c)+"'.").newLine("Condition (").appendPrerequisiteFlagCondition(e).append(") evaluates to ").appendEvaluationResult(f).append(".").decreaseIndent().newLine(")"),f},t.prototype.evaluateSegmentCondition=function(e,r){var n=r.logBuilder;if(n==null||n.appendSegmentCondition(e),!r.userAttributes)return r.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(r.key),r.isMissingUserObjectLogged=!0),Oe;var i=e.segment;n==null||n.newLine("(").increaseIndent().newLine("Evaluating segment '"+i.name+"':");var o=this.evaluateConditions(i.conditions,void 0,i.name,r),a=o;if(!J(a))switch(e.comparator){case s.SegmentComparator.IsIn:break;case s.SegmentComparator.IsNotIn:a=!a;break;default:throw new Error}return n&&(n.newLine("Segment evaluation result: "),(J(a)?n.append(a):n.append("User "+vt(o?s.SegmentComparator.IsIn:s.SegmentComparator.IsNotIn))).append("."),n.newLine("Condition (").appendSegmentCondition(e).append(")"),(J(a)?n.append(" failed to evaluate"):n.append(" evaluates to ").appendEvaluationResult(a)).append("."),n.decreaseIndent().newLine(")")),a},t}();function J(t){return typeof t=="string"}function mt(t){return Z(t)&&!t.some(function(e){return typeof e!="string"})}function Ce(t,e,r){return Et(H(t),e,r)}function Et(t,e,r){return nt(t+H(e)+H(r))}function Ot(t){return typeof t=="string"?t:t instanceof Date?t.getTime()/1e3+"":mt(t)?JSON.stringify(t):t+""}function F(t,e,r,n,i){return typeof e=="string"||(e=Ot(e),i.userObjectAttributeIsAutoConverted(pe(r),n,t,e)),e}function Ct(t,e,r,n,i){var o;return typeof e=="string"&&(o=me(e.trim()))?o:te(i,r,n,t,"'"+e+"' is not a valid semantic version")}function rr(t,e,r,n,i){if(typeof e=="number")return e;var o;return typeof e=="string"&&(!isNaN(o=Fe(e.replace(",",".")))||e==="NaN")?o:te(i,r,n,t,"'"+e+"' is not a valid decimal number")}function nr(t,e,r,n,i){if(e instanceof Date)return e.getTime()/1e3;if(typeof e=="number")return e;var o;return typeof e=="string"&&(!isNaN(o=Fe(e.replace(",",".")))||e==="NaN")?o:te(i,r,n,t,"'"+e+"' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)")}function St(t,e,r,n,i){var o=e;if(typeof o=="string")try{o=JSON.parse(o)}catch{}return mt(o)?o:te(i,r,n,t,"'"+e+"' is not a valid string array")}function te(t,e,r,n,i){return t.userObjectAttributeIsInvalid(pe(e),r,i,n),er(n,i)}function At(t,e,r,n){return{key:t,value:e.selectedValue.value,variationId:e.selectedValue.variationId,fetchTime:r,user:n,isDefaultValue:!1,matchedTargetingRule:e.matchedTargetingRule,matchedPercentageOption:e.matchedPercentageOption}}function V(t,e,r,n,i,o){return{key:t,value:e,fetchTime:r,user:n,isDefaultValue:!0,errorMessage:i,errorException:o}}function re(t,e,r,n,i,o,a){var u;if(!e)return u=a.configJsonIsNotPresentSingle(r,"defaultValue",n).toString(),V(r,n,D(o),i,u);var l=e[r];if(!l)return u=a.settingEvaluationFailedDueToMissingKey(r,"defaultValue",n,he(Object.keys(e))).toString(),V(r,n,D(o),i,u);var c=t.evaluate(n,new Ee(r,l,i,e));return At(r,c,D(o),i)}function bt(t,e,r,n,i,o){var a;if(!Se(e,i,o))return[[],a];for(var u=[],l=0,c=Object.entries(e);l<c.length;l++){var f=c[l],h=f[0],g=f[1],v=void 0;try{var d=t.evaluate(null,new Ee(h,g,r,e));v=At(h,d,D(n),r)}catch(p){a??(a=[]),a.push(p),v=V(h,null,D(n),r,W(p),p)}u.push(v)}return[u,a]}function Se(t,e,r){return t?!0:(e.configJsonIsNotPresent(r),!1)}function Y(t){return typeof t=="boolean"||typeof t=="string"||typeof t=="number"}function ir(t,e){switch(e){case s.SettingType.Boolean:return typeof t=="boolean";case s.SettingType.String:return typeof t=="string";case s.SettingType.Int:case s.SettingType.Double:return typeof t=="number";default:return!1}}function Ae(t){throw new TypeError(t===null?"Setting value is null.":t===void 0?"Setting value is undefined.":"Setting value '"+t+"' is of an unsupported type ("+typeof t+").")}function D(t){return t?new Date(t.timestamp):void 0}var or=function(){function t(){this.instances={}}return t.prototype.getOrCreate=function(e,r){var n,i=this.instances[e.sdkKey];if(i){var o=i[0];if(n=o.deref(),n)return[n,!0]}var a={};n=new be(e,r,a);var u=ut()?WeakRef:st();return this.instances[e.sdkKey]=[new u(n),a],[n,!1]},t.prototype.remove=function(e,r){var n=this.instances[e];if(n){var i=n[0],o=n[1],a=!!i.deref();if(!a||o===r)return delete this.instances[e],a}return!1},t.prototype.clear=function(){for(var e=[],r=0,n=Object.entries(this.instances);r<n.length;r++){var i=n[r],o=i[0],a=i[1][0],u=a.deref();u&&e.push(u),delete this.instances[o]}return e},t}(),$=new or,be=function(){function t(e,r,n){var i;if(this.cacheToken=n,this.addListener=this.on,this.off=this.removeListener,!e)throw new Error("Invalid 'options' value");if(this.options=e,this.options.logger.debug("Initializing ConfigCatClient. Options: "+JSON.stringify(this.options)),!r)throw new Error("Invalid 'configCatKernel' value");if(!r.configFetcher)throw new Error("Invalid 'configCatKernel.configFetcher' value");this.hooks=e.yieldHooks(),e.defaultUser&&this.setDefaultUser(e.defaultUser),this.evaluator=new tr(e.logger),((i=e.flagOverrides)===null||i===void 0?void 0:i.behaviour)!==s.OverrideBehaviour.LocalOnly?this.configService=e instanceof lt?new kt(r.configFetcher,e):e instanceof ct?new zt(r.configFetcher,e):e instanceof ft?new Kt(r.configFetcher,e):Re(new Error("Invalid 'options' value")):this.hooks.emit("clientReady",s.ClientCacheState.HasLocalOverrideFlagDataOnly),this.suppressFinalize=se(this,{sdkKey:e.sdkKey,cacheToken:n,configService:this.configService,logger:e.logger})}return Object.defineProperty(t,"instanceCache",{get:function(){return $},enumerable:!1,configurable:!0}),t.get=function(e,r,n,i){var o,a="Invalid 'sdkKey' value";if(!e)throw new Error(a);var u=r===s.PollingMode.AutoPoll?lt:r===s.PollingMode.ManualPoll?ct:r===s.PollingMode.LazyLoad?ft:Re(new Error("Invalid 'pollingMode' value")),l=new u(e,i.sdkType,i.sdkVersion,n,i.defaultCacheFactory,i.eventEmitterFactory);if(((o=l.flagOverrides)===null||o===void 0?void 0:o.behaviour)!==s.OverrideBehaviour.LocalOnly&&!ar(e,l.baseUrlOverriden))throw new Error(a);var c=$.getOrCreate(l,i),f=c[0],h=c[1];return h&&n&&l.logger.clientIsAlreadyCreated(e),f},t.finalize=function(e){var r;(r=e.logger)===null||r===void 0||r.debug("finalize() called"),e.cacheToken&&$.remove(e.sdkKey,e.cacheToken),t.close(e.configService,e.logger)},t.close=function(e,r,n){r==null||r.debug("close() called"),n==null||n.tryDisconnect(),e==null||e.dispose()},t.prototype.dispose=function(){var e=this.options;e.logger.debug("dispose() called"),this.cacheToken&&$.remove(e.sdkKey,this.cacheToken),t.close(this.configService,e.logger,this.hooks),this.suppressFinalize()},t.disposeAll=function(){for(var e=$.clear(),r,n=0,i=e;n<i.length;n++){var o=i[n];try{t.close(o.configService,o.options.logger,o.hooks),o.suppressFinalize()}catch(a){r??(r=[]),r.push(a)}}if(r)throw typeof AggregateError<"u"?new AggregateError(r):r.pop()},t.prototype.getValueAsync=function(e,r,n){return m(this,void 0,void 0,function(){var i,o,a,u,l,c;return E(this,function(f){switch(f.label){case 0:this.options.logger.debug("getValueAsync() called."),ie(e),oe(r),a=null,n??(n=this.defaultUser),f.label=1;case 1:return f.trys.push([1,3,,4]),u=void 0,[4,this.getSettingsAsync()];case 2:return c=f.sent(),u=c[0],a=c[1],o=re(this.evaluator,u,e,r,n,a,this.options.logger),i=o.value,[3,4];case 3:return l=f.sent(),this.options.logger.settingEvaluationErrorSingle("getValueAsync",e,"defaultValue",r,l),o=V(e,r,D(a),n,W(l),l),i=r,[3,4];case 4:return this.hooks.emit("flagEvaluated",o),[2,i]}})})},t.prototype.getValueDetailsAsync=function(e,r,n){return m(this,void 0,void 0,function(){var i,o,a,u,l;return E(this,function(c){switch(c.label){case 0:this.options.logger.debug("getValueDetailsAsync() called."),ie(e),oe(r),o=null,n??(n=this.defaultUser),c.label=1;case 1:return c.trys.push([1,3,,4]),a=void 0,[4,this.getSettingsAsync()];case 2:return l=c.sent(),a=l[0],o=l[1],i=re(this.evaluator,a,e,r,n,o,this.options.logger),[3,4];case 3:return u=c.sent(),this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync",e,"defaultValue",r,u),i=V(e,r,D(o),n,W(u),u),[3,4];case 4:return this.hooks.emit("flagEvaluated",i),[2,i]}})})},t.prototype.getAllKeysAsync=function(){return m(this,void 0,void 0,function(){var e,r,n;return E(this,function(i){switch(i.label){case 0:this.options.logger.debug("getAllKeysAsync() called."),e="empty array",i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return r=i.sent()[0],Se(r,this.options.logger,e)?[2,Object.keys(r)]:[2,[]];case 3:return n=i.sent(),this.options.logger.settingEvaluationError("getAllKeysAsync",e,n),[2,[]];case 4:return[2]}})})},t.prototype.getAllValuesAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f,h,g,v;return E(this,function(d){switch(d.label){case 0:this.options.logger.debug("getAllValuesAsync() called."),r="empty array",e??(e=this.defaultUser),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return a=d.sent(),u=a[0],l=a[1],v=bt(this.evaluator,u,e,l,this.options.logger,r),i=v[0],o=v[1],n=i.map(function(p){return new j(p.key,p.value)}),[3,4];case 3:return c=d.sent(),this.options.logger.settingEvaluationError("getAllValuesAsync",r,c),[2,[]];case 4:for(o!=null&&o.length&&this.options.logger.settingEvaluationError("getAllValuesAsync","evaluation result",typeof AggregateError<"u"?new AggregateError(o):o.pop()),f=0,h=i;f<h.length;f++)g=h[f],this.hooks.emit("flagEvaluated",g);return[2,n]}})})},t.prototype.getAllValueDetailsAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f,h,g;return E(this,function(v){switch(v.label){case 0:this.options.logger.debug("getAllValueDetailsAsync() called."),r="empty array",e??(e=this.defaultUser),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return o=v.sent(),a=o[0],u=o[1],g=bt(this.evaluator,a,e,u,this.options.logger,r),n=g[0],i=g[1],[3,4];case 3:return l=v.sent(),this.options.logger.settingEvaluationError("getAllValueDetailsAsync",r,l),[2,[]];case 4:for(i!=null&&i.length&&this.options.logger.settingEvaluationError("getAllValueDetailsAsync","evaluation result",typeof AggregateError<"u"?new AggregateError(i):i.pop()),c=0,f=n;c<f.length;c++)h=f[c],this.hooks.emit("flagEvaluated",h);return[2,n]}})})},t.prototype.getKeyAndValueAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,v,f,h,d,g,v,d,p;return E(this,function(C){switch(C.label){case 0:this.options.logger.debug("getKeyAndValueAsync() called."),r="null",C.label=1;case 1:return C.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:if(n=C.sent()[0],!Se(n,this.options.logger,r))return[2,null];for(i=0,o=Object.entries(n);i<o.length;i++){if(a=o[i],u=a[0],l=a[1],e===l.variationId)return[2,new j(u,ae(l.value))];if(c=n[u].targetingRules,c&&c.length>0){for(v=0;v<c.length;v++)if(f=c[v].then,Z(f)){for(h=0;h<f.length;h++)if(d=f[h],e===d.variationId)return[2,new j(u,ae(d.value))]}else if(e===f.variationId)return[2,new j(u,ae(f.value))]}if(g=n[u].percentageOptions,g&&g.length>0){for(v=0;v<g.length;v++)if(d=g[v],e===d.variationId)return[2,new j(u,ae(d.value))]}}return this.options.logger.settingForVariationIdIsNotPresent(e),[3,4];case 3:return p=C.sent(),this.options.logger.settingEvaluationError("getKeyAndValueAsync",r,p),[3,4];case 4:return[2,null]}})})},t.prototype.forceRefreshAsync=function(){return m(this,void 0,void 0,function(){var e,r;return E(this,function(n){switch(n.label){case 0:if(this.options.logger.debug("forceRefreshAsync() called."),!this.configService)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.configService.refreshConfigAsync()];case 2:return e=n.sent()[0],[2,e];case 3:return r=n.sent(),this.options.logger.forceRefreshError("forceRefreshAsync",r),[2,_.failure(W(r),r)];case 4:return[3,6];case 5:return[2,_.failure("Client is configured to use the LocalOnly override behavior, which prevents making HTTP requests.")];case 6:return[2]}})})},t.prototype.setDefaultUser=function(e){this.defaultUser=e},t.prototype.clearDefaultUser=function(){this.defaultUser=void 0},Object.defineProperty(t.prototype,"isOffline",{get:function(){var e,r;return(r=(e=this.configService)===null||e===void 0?void 0:e.isOffline)!==null&&r!==void 0?r:!0},enumerable:!1,configurable:!0}),t.prototype.setOnline=function(){this.configService?this.configService.setOnline():this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(s.OverrideBehaviour[s.OverrideBehaviour.LocalOnly],"setOnline")},t.prototype.setOffline=function(){var e;(e=this.configService)===null||e===void 0||e.setOffline()},t.prototype.waitForReady=function(){var e=this.configService;return e?e.readyPromise:Promise.resolve(s.ClientCacheState.HasLocalOverrideFlagDataOnly)},t.prototype.snapshot=function(){var e,r,n,i=this,o,a=function(){var h=i.options.cache.getInMemory(),g=h.isEmpty?null:h.config.settings;return[g,h]},u,l,c=(o=this.options)===null||o===void 0?void 0:o.flagOverrides;if(c){var f=c.dataSource.getOverridesSync();switch(c.behaviour){case s.OverrideBehaviour.LocalOnly:return new ne(f,null,this);case s.OverrideBehaviour.LocalOverRemote:return e=a(),u=e[0],l=e[1],new ne(L(L({},u??{}),f),l,this);case s.OverrideBehaviour.RemoteOverLocal:return r=a(),u=r[0],l=r[1],new ne(L(L({},f),u??{}),l,this)}}return n=a(),u=n[0],l=n[1],new ne(u,l,this)},t.prototype.getSettingsAsync=function(){var e;return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f=this;return E(this,function(h){switch(h.label){case 0:return this.options.logger.debug("getSettingsAsync() called."),r=function(){return m(f,void 0,void 0,function(){var g,v;return E(this,function(d){switch(d.label){case 0:return[4,this.configService.getConfig()];case 1:return g=d.sent(),v=g.isEmpty?null:g.config.settings,[2,[v,g]]}})})},n=(e=this.options)===null||e===void 0?void 0:e.flagOverrides,n?(i=void 0,o=void 0,[4,n.dataSource.getOverrides()]):[3,7];case 1:switch(a=h.sent(),u=n.behaviour,u){case s.OverrideBehaviour.LocalOnly:return[3,2];case s.OverrideBehaviour.LocalOverRemote:return[3,3];case s.OverrideBehaviour.RemoteOverLocal:return[3,5]}return[3,7];case 2:return[2,[a,null]];case 3:return[4,r()];case 4:return l=h.sent(),i=l[0],o=l[1],[2,[L(L({},i??{}),a),o]];case 5:return[4,r()];case 6:return c=h.sent(),i=c[0],o=c[1],[2,[L(L({},a),i??{}),o]];case 7:return[4,r()];case 8:return[2,h.sent()]}})})},t.prototype.on=function(e,r){return this.hooks.on(e,r),this},t.prototype.once=function(e,r){return this.hooks.once(e,r),this},t.prototype.removeListener=function(e,r){return this.hooks.removeListener(e,r),this},t.prototype.removeAllListeners=function(e){return this.hooks.removeAllListeners(e),this},t.prototype.listeners=function(e){return this.hooks.listeners(e)},t.prototype.listenerCount=function(e){return this.hooks.listenerCount(e)},t.prototype.eventNames=function(){return this.hooks.eventNames()},t}(),ne=function(){function t(e,r,n){this.mergedSettings=e,this.remoteConfig=r,this.defaultUser=n.defaultUser,this.evaluator=n.evaluator,this.options=n.options,this.cacheState=r?n.configService.getCacheState(r):s.ClientCacheState.HasLocalOverrideFlagDataOnly}return Object.defineProperty(t.prototype,"fetchedConfig",{get:function(){var e=this.remoteConfig;return e&&!e.isEmpty?e.config:null},enumerable:!1,configurable:!0}),t.prototype.getAllKeys=function(){return this.mergedSettings?Object.keys(this.mergedSettings):[]},t.prototype.getValue=function(e,r,n){this.options.logger.debug("Snapshot.getValue() called."),ie(e),oe(r);var i,o;n??(n=this.defaultUser);try{o=re(this.evaluator,this.mergedSettings,e,r,n,this.remoteConfig,this.options.logger),i=o.value}catch(a){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue",e,"defaultValue",r,a),o=V(e,r,D(this.remoteConfig),n,W(a),a),i=r}return this.options.hooks.emit("flagEvaluated",o),i},t.prototype.getValueDetails=function(e,r,n){this.options.logger.debug("Snapshot.getValueDetails() called."),ie(e),oe(r);var i;n??(n=this.defaultUser);try{i=re(this.evaluator,this.mergedSettings,e,r,n,this.remoteConfig,this.options.logger)}catch(o){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails",e,"defaultValue",r,o),i=V(e,r,D(this.remoteConfig),n,W(o),o)}return this.options.hooks.emit("flagEvaluated",i),i},t}(),j=function(){function t(e,r){this.settingKey=e,this.settingValue=r}return t}();function ar(t,e){var r="configcat-proxy/";if(e&&t.length>r.length&&t.lastIndexOf(r,0)===0)return!0;var n=t.split("/"),i=22;switch(n.length){case 2:return n[0].length===i&&n[1].length===i;case 3:return n[0]==="configcat-sdk-1"&&n[1].length===i&&n[2].length===i;default:return!1}}function ie(t){if(!t)throw new Error("Invalid 'key' value")}function oe(t){if(t!=null&&!Y(t))throw new TypeError("The default value must be boolean, number, string, null or undefined.")}function ae(t){return Y(t)?t:Ae(t)}var se=function(t,e){if(typeof FinalizationRegistry<"u"){var r=new FinalizationRegistry(function(n){return be.finalize(n)});se=function(n,i){var o={};return r.register(n,i,o),function(){return r.unregister(o)}}}else se=function(){return function(){}};return se(t,e)};Wt();function sr(t,e,r,n){return be.get(t,e,r,n)}function ur(t){return new ke(t)}function lr(t,e,r){return new Ht(new _t(t,r),e)}class cr{handleStateChange(e,r,n){try{if(e.readyState===4){const{status:i,statusText:o}=e;if(i===200){const a=e.getResponseHeader("ETag")??void 0;r({statusCode:i,reasonPhrase:o,eTag:a,body:e.responseText})}else i&&r({statusCode:i,reasonPhrase:o})}}catch(i){n(i)}}fetchLogic(e,r){return new Promise((n,i)=>{try{e.logger.debug("HttpConfigFetcher.fetchLogic() called.");const o=new XMLHttpRequest;o.onreadystatechange=()=>this.handleStateChange(o,n,i),o.ontimeout=()=>i(new Q("timeout",e.requestTimeoutMs)),o.onabort=()=>i(new Q("abort")),o.onerror=()=>i(new Q("failure"));let a=e.getUrl();r&&(a+="&ccetag="+encodeURIComponent(r)),o.open("GET",a,!0),o.timeout=e.requestTimeoutMs,o.send(null)}catch(o){i(o)}})}}class Te{constructor(e){this.storage=e}static setup(e,r){const n=(r??fr)();return n&&(e.defaultCacheFactory=i=>new De(new Te(n),i.logger)),e}set(e,r){this.storage.setItem(e,hr(r))}get(e){const r=this.storage.getItem(e);if(r)return gr(r)}}function fr(){const t="__configcat_localStorage_test";try{const e=window.localStorage;e.setItem(t,t);let r;try{r=e.getItem(t)}finally{e.removeItem(t)}if(r===t)return e}catch{}return null}function hr(t){return t=encodeURIComponent(t),t=t.replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16))),btoa(t)}function gr(t){return t=atob(t),t=t.replace(/[%\x80-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16)),decodeURIComponent(t)}const vr="2.2.2",dr={install:(t,e)=>{const{sdkKey:r,pollingMode:n,clientOptions:i}=e,o=Te.setup({sdkType:"ConfigCat-Vue",sdkVersion:vr,configFetcher:new cr}),a=sr(r,n??s.PollingMode.AutoPoll,i,o);t.provide("configCatClient",a);const u=t.unmount;t.unmount=function(){u.apply(arguments),a.dispose()}}},pr=N.defineComponent({__name:"FeatureWrapper",props:{featureKey:{},userObject:{}},emits:["flagValueChanged"],setup(t,{emit:e}){const r=t,n=N.ref(null),i=N.inject("configCatClient")??(()=>{throw new Error("ConfigCatPlugin was not installed.")})(),o=()=>{const u=i.snapshot().getValue(r.featureKey,!1,r.userObject);n.value!==u&&(n.value=u,e("flagValueChanged",u))};return N.onBeforeMount(()=>{const a=i.snapshot(),u=a.cacheState;u==s.ClientCacheState.HasUpToDateFlagData||u==s.ClientCacheState.HasLocalOverrideFlagDataOnly?(n.value=a.getValue(r.featureKey,!1,r.userObject),i.on("configChanged",o)):i.getValueAsync(r.featureKey,!1,r.userObject).then(l=>{const c=o;c&&(n.value=l,i.on("configChanged",c))})}),N.onUnmounted(()=>{i.off("configChanged",o)}),(a,u)=>n.value===!0?N.renderSlot(a.$slots,"default",{key:0}):n.value===!1?N.renderSlot(a.$slots,"else",{key:1}):N.renderSlot(a.$slots,"loading",{key:2})}});s.ConfigCatPlugin=dr,s.FeatureWrapper=pr,s.FormattableLogMessage=S,s.RefreshResult=_,s.SettingKeyValue=j,s.User=Xt,s.createConsoleLogger=ur,s.createFlagOverridesFromMap=lr,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
6
+ `+this.indent+(e??""),this},t.prototype.append=function(e){return this.log+=e,this},t.prototype.toString=function(){return this.log},t.prototype.appendEvaluationResult=function(e){return this.append(""+e)},t.prototype.appendUserConditionCore=function(e,r,n){return this.append("User."+e+" "+de(r)+" '"+(n??ht)+"'")},t.prototype.appendUserConditionString=function(e,r,n,i){return this.appendUserConditionCore(e,r,i?"<hashed value>":n)},t.prototype.appendUserConditionStringList=function(e,r,n,i){if(n==null)return this.appendUserConditionCore(e,r);var o="value",a="values",u=de(r);if(i)return this.append("User."+e+" "+u+" [<"+n.length+" hashed "+(n.length===1?o:a)+">]");var l=he(n,Yt,function(c){return", ... <"+c+" more "+(c===1?o:a)+">"});return this.append("User."+e+" "+u+" ["+l+"]")},t.prototype.appendUserConditionNumber=function(e,r,n,i){if(n==null)return this.appendUserConditionCore(e,r);var o=de(r),a;return i&&!isNaN(a=new Date(n*1e3))?this.append("User."+e+" "+o+" '"+n+"' ("+a.toISOString()+" UTC)"):this.append("User."+e+" "+o+" '"+n+"'")},t.prototype.appendUserCondition=function(e){var r=e.comparisonAttribute,n=e.comparator;switch(e.comparator){case s.UserComparator.IsOneOf:case s.UserComparator.IsNotOneOf:case s.UserComparator.ContainsAnyOf:case s.UserComparator.NotContainsAnyOf:case s.UserComparator.SemVerIsOneOf:case s.UserComparator.SemVerIsNotOneOf:case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.TextNotStartsWithAnyOf:case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.TextNotEndsWithAnyOf:case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.ArrayNotContainsAnyOf:return this.appendUserConditionStringList(r,n,e.comparisonValue,!1);case s.UserComparator.SemVerLess:case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.SemVerGreater:case s.UserComparator.SemVerGreaterOrEquals:case s.UserComparator.TextEquals:case s.UserComparator.TextNotEquals:return this.appendUserConditionString(r,n,e.comparisonValue,!1);case s.UserComparator.NumberEquals:case s.UserComparator.NumberNotEquals:case s.UserComparator.NumberLess:case s.UserComparator.NumberLessOrEquals:case s.UserComparator.NumberGreater:case s.UserComparator.NumberGreaterOrEquals:return this.appendUserConditionNumber(r,n,e.comparisonValue);case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SensitiveIsNotOneOf:case s.UserComparator.SensitiveTextStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:case s.UserComparator.SensitiveTextEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:case s.UserComparator.SensitiveArrayContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return this.appendUserConditionStringList(r,n,e.comparisonValue,!0);case s.UserComparator.DateTimeBefore:case s.UserComparator.DateTimeAfter:return this.appendUserConditionNumber(r,n,e.comparisonValue,!0);case s.UserComparator.SensitiveTextEquals:case s.UserComparator.SensitiveTextNotEquals:return this.appendUserConditionString(r,n,e.comparisonValue,!0);default:return this.appendUserConditionCore(r,n,e.comparisonValue)}},t.prototype.appendPrerequisiteFlagCondition=function(e){var r=e.prerequisiteFlagKey,n=e.comparator,i=e.comparisonValue;return this.append("Flag '"+r+"' "+$t(n)+" '"+x(i)+"'")},t.prototype.appendSegmentCondition=function(e){var r,n=e.segment,i=e.comparator,o=(r=n==null?void 0:n.name)!==null&&r!==void 0?r:n==null?Jt:Gt;return this.append("User "+vt(i)+" '"+o+"'")},t.prototype.appendConditionConsequence=function(e){return this.append(" => ").appendEvaluationResult(e),e?this:this.append(", skipping the remaining AND conditions")},t.prototype.appendTargetingRuleThenPart=function(e,r){(r?this.newLine():this.append(" ")).append("THEN");var n=e.then;return this.append(Z(n)?" % options":" '"+x(n.value)+"'")},t.prototype.appendTargetingRuleConsequence=function(e,r,n){return this.increaseIndent(),this.appendTargetingRuleThenPart(e,n).append(" => ").append(r===!0?"MATCH, applying rule":r===!1?"no match":r),this.decreaseIndent()},t}();function de(t){switch(t){case s.UserComparator.IsOneOf:case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SemVerIsOneOf:return"IS ONE OF";case s.UserComparator.IsNotOneOf:case s.UserComparator.SensitiveIsNotOneOf:case s.UserComparator.SemVerIsNotOneOf:return"IS NOT ONE OF";case s.UserComparator.ContainsAnyOf:return"CONTAINS ANY OF";case s.UserComparator.NotContainsAnyOf:return"NOT CONTAINS ANY OF";case s.UserComparator.SemVerLess:case s.UserComparator.NumberLess:return"<";case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.NumberLessOrEquals:return"<=";case s.UserComparator.SemVerGreater:case s.UserComparator.NumberGreater:return">";case s.UserComparator.SemVerGreaterOrEquals:case s.UserComparator.NumberGreaterOrEquals:return">=";case s.UserComparator.NumberEquals:return"=";case s.UserComparator.NumberNotEquals:return"!=";case s.UserComparator.DateTimeBefore:return"BEFORE";case s.UserComparator.DateTimeAfter:return"AFTER";case s.UserComparator.TextEquals:case s.UserComparator.SensitiveTextEquals:return"EQUALS";case s.UserComparator.TextNotEquals:case s.UserComparator.SensitiveTextNotEquals:return"NOT EQUALS";case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.SensitiveTextStartsWithAnyOf:return"STARTS WITH ANY OF";case s.UserComparator.TextNotStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:return"NOT STARTS WITH ANY OF";case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.SensitiveTextEndsWithAnyOf:return"ENDS WITH ANY OF";case s.UserComparator.TextNotEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:return"NOT ENDS WITH ANY OF";case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.SensitiveArrayContainsAnyOf:return"ARRAY CONTAINS ANY OF";case s.UserComparator.ArrayNotContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return"ARRAY NOT CONTAINS ANY OF";default:return ve}}function pe(t){return new gt().appendUserCondition(t).toString()}function $t(t){switch(t){case s.PrerequisiteFlagComparator.Equals:return"EQUALS";case s.PrerequisiteFlagComparator.NotEquals:return"NOT EQUALS";default:return ve}}function vt(t){switch(t){case s.SegmentComparator.IsIn:return"IS IN SEGMENT";case s.SegmentComparator.IsNotIn:return"IS NOT IN SEGMENT";default:return ve}}function x(t){return Y(t)?t.toString():ht}var dt=/^[0-9]+$/,z=function(t,e){var r=dt.test(t),n=dt.test(e);return r&&n&&(t=+t,e=+e),t===e?0:r&&!n?-1:n&&!r?1:t<e?-1:1},ye=256,ee=Number.MAX_SAFE_INTEGER||9007199254740991,G=[],O=[],y={},Qt=0,I=function(t,e){var r=Qt++;y[t]=r,O[r]=e,G[r]=new RegExp(e)};I("NUMERICIDENTIFIER","0|[1-9]\\d*"),I("NUMERICIDENTIFIERLOOSE","[0-9]+"),I("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),I("MAINVERSION","("+O[y.NUMERICIDENTIFIER]+")\\."+("("+O[y.NUMERICIDENTIFIER]+")\\.")+("("+O[y.NUMERICIDENTIFIER]+")")),I("MAINVERSIONLOOSE","("+O[y.NUMERICIDENTIFIERLOOSE]+")\\."+("("+O[y.NUMERICIDENTIFIERLOOSE]+")\\.")+("("+O[y.NUMERICIDENTIFIERLOOSE]+")")),I("PRERELEASEIDENTIFIER","(?:"+O[y.NUMERICIDENTIFIER]+"|"+O[y.NONNUMERICIDENTIFIER]+")"),I("PRERELEASEIDENTIFIERLOOSE","(?:"+O[y.NUMERICIDENTIFIERLOOSE]+"|"+O[y.NONNUMERICIDENTIFIER]+")"),I("PRERELEASE","(?:-("+O[y.PRERELEASEIDENTIFIER]+"(?:\\."+O[y.PRERELEASEIDENTIFIER]+")*))"),I("PRERELEASELOOSE","(?:-?("+O[y.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+O[y.PRERELEASEIDENTIFIERLOOSE]+")*))"),I("BUILDIDENTIFIER","[0-9A-Za-z-]+"),I("BUILD","(?:\\+("+O[y.BUILDIDENTIFIER]+"(?:\\."+O[y.BUILDIDENTIFIER]+")*))"),I("FULLPLAIN","v?"+O[y.MAINVERSION]+O[y.PRERELEASE]+"?"+O[y.BUILD]+"?"),I("FULL","^"+O[y.FULLPLAIN]+"$"),I("LOOSEPLAIN","[v=\\s]*"+O[y.MAINVERSIONLOOSE]+O[y.PRERELEASELOOSE]+"?"+O[y.BUILD]+"?"),I("LOOSE","^"+O[y.LOOSEPLAIN]+"$");var pt=function(){function t(e,r){if((!r||typeof r!="object")&&(r={loose:!!r,includePrerelease:!1}),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError("Invalid Version: "+e);if(e.length>ye)throw new TypeError("version is longer than "+ye+" characters");this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;var n=e.trim().match(r.loose?G[y.LOOSE]:G[y.FULL]);if(!n)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>ee||this.major<0)throw new TypeError("Invalid major version");if(this.minor>ee||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>ee||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(function(i){if(/^[0-9]+$/.test(i)){var o=+i;if(o>=0&&o<ee)return o}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}return t.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},t.prototype.toString=function(){return this.version},t.prototype.compare=function(e){if(!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)},t.prototype.compareMain=function(e){return e instanceof t||(e=new t(e,this.options)),z(this.major,e.major)||z(this.minor,e.minor)||z(this.patch,e.patch)},t.prototype.comparePre=function(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var r=0;do{var n=this.prerelease[r],i=e.prerelease[r];if(n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return z(n,i)}while(++r)},t.prototype.compareBuild=function(e){e instanceof t||(e=new t(e,this.options));var r=0;do{var n=this.build[r],i=e.build[r];if(n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n===i)continue;return z(n,i)}while(++r)},t.prototype.inc=function(e,r){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r),this.inc("pre",r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r),this.inc("pre",r);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{for(var n=this.prerelease.length;--n>=0;)typeof this.prerelease[n]=="number"&&(this.prerelease[n]++,n=-2);n===-1&&this.prerelease.push(0)}r&&(this.prerelease[0]===r?isNaN(this.prerelease[1])&&(this.prerelease=[r,0]):this.prerelease=[r,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t}(),me=function(t,e){if((!e||typeof e!="object")&&(e={loose:!!e,includePrerelease:!1}),t instanceof pt)return t;if(typeof t!="string"||t.length>ye)return null;var r=e.loose?G[y.LOOSE]:G[y.FULL];if(!r.test(t))return null;try{return new pt(t,e)}catch{return null}},Xt=function(){function t(e,r,n,i){i===void 0&&(i={}),this.identifier=e,this.email=r,this.country=n,this.custom=i}return t}();function Zt(t){var e,r={},n="Identifier",i="Email",o="Country";if(r[n]=(e=t.identifier)!==null&&e!==void 0?e:"",t.email!=null&&(r[i]=t.email),t.country!=null&&(r[o]=t.country),t.custom!=null)for(var a=[n,i,o],u=0,l=Object.entries(t.custom);u<l.length;u++){var c=l[u],f=c[0],h=c[1];h!=null&&a.indexOf(f)<0&&(r[f]=h)}return r}var Ee=function(){function t(e,r,n,i){this.key=e,this.setting=r,this.user=n,this.settings=i}return Object.defineProperty(t.prototype,"userAttributes",{get:function(){var e=this.$userAttributes;return e!==void 0?e:this.$userAttributes=this.user?Zt(this.user):null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visitedFlags",{get:function(){var e;return(e=this.$visitedFlags)!==null&&e!==void 0?e:this.$visitedFlags=[]},enumerable:!1,configurable:!0}),t.forPrerequisiteFlag=function(e,r,n){var i=new t(e,r,n.user,n.settings);return i.$userAttributes=n.userAttributes,i.$visitedFlags=n.visitedFlags,i.logBuilder=n.logBuilder,i},t}(),yt="The current targeting rule is ignored and the evaluation continues with the next rule.",Oe="cannot evaluate, User Object is missing",xt=function(t){return"cannot evaluate, the User."+t+" attribute is missing"},er=function(t,e){return"cannot evaluate, the User."+t+" attribute is invalid ("+e+")"},tr=function(){function t(e){this.logger=e}return t.prototype.evaluate=function(e,r){this.logger.debug("RolloutEvaluator.evaluate() called.");var n=r.logBuilder;this.logger.isEnabled(s.LogLevel.Info)&&(r.logBuilder=n=new gt,n.append("Evaluating '"+r.key+"'"),r.userAttributes&&n.append(" for User '"+JSON.stringify(r.userAttributes)+"'"),n.increaseIndent());var i;try{var o=void 0,a=void 0;if(e!=null){var u=r.setting.type;if(u>=0&&!ir(e,u))throw new TypeError("The type of a setting must match the type of the specified default value. "+("Setting's type was "+s.SettingType[u]+" but the default value's type was "+typeof e+". ")+("Please use a default value which corresponds to the setting type "+s.SettingType[u]+". ")+"Learn more: https://configcat.com/docs/sdk-reference/js/#setting-type-mapping");o=this.evaluateSetting(r),i=o.selectedValue.value,a=typeof i==typeof e}else o=this.evaluateSetting(r),i=o.selectedValue.value,a=Y(i);return a||Ae(i),o}catch(l){throw n==null||n.resetIndent().increaseIndent(),i=e,l}finally{n&&(n.newLine("Returning '"+i+"'.").decreaseIndent(),this.logger.settingEvaluated(n.toString()))}},t.prototype.evaluateSetting=function(e){var r,n=e.setting.targetingRules;if(n.length>0&&(r=this.evaluateTargetingRules(n,e)))return r;var i=e.setting.percentageOptions;return i.length>0&&(r=this.evaluatePercentageOptions(i,void 0,e))?r:{selectedValue:e.setting}},t.prototype.evaluateTargetingRules=function(e,r){var n=r.logBuilder;n==null||n.newLine("Evaluating targeting rules and applying the first match if any:");for(var i=0;i<e.length;i++){var o=e[i],a=o.conditions,u=this.evaluateConditions(a,o,r.key,r);if(u!==!0){J(u)&&(n==null||n.increaseIndent().newLine(yt).decreaseIndent());continue}if(!Z(o.then))return{selectedValue:o.then,matchedTargetingRule:o};var l=o.then;n==null||n.increaseIndent();var c=this.evaluatePercentageOptions(l,o,r);if(c)return n==null||n.decreaseIndent(),c;n==null||n.newLine(yt).decreaseIndent()}},t.prototype.evaluatePercentageOptions=function(e,r,n){var i=n.logBuilder;if(!n.userAttributes){i==null||i.newLine("Skipping % options because the User Object is missing."),n.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(n.key),n.isMissingUserObjectLogged=!0);return}var o=n.setting.percentageOptionsAttribute,a=n.userAttributes[o];if(a==null){i==null||i.newLine("Skipping % options because the User."+o+" attribute is missing."),n.isMissingUserObjectAttributeLogged||(this.logger.userObjectAttributeIsMissingPercentage(n.key,o),n.isMissingUserObjectAttributeLogged=!0);return}i==null||i.newLine("Evaluating % options based on the User."+o+" attribute:");var u=rt(n.key+Ot(a)),l=parseInt(u.substring(0,7),16)%100;i==null||i.newLine("- Computing hash in the [0..99] range from User."+o+" => "+l+" (this value is sticky and consistent across all SDKs)");for(var c=0,f=0;f<e.length;f++){var h=e[f];if(c+=h.percentage,!(l>=c))return i==null||i.newLine("- Hash value "+l+" selects % option "+(f+1)+" ("+h.percentage+"%), '"+x(h.value)+"'."),{selectedValue:h,matchedTargetingRule:r,matchedPercentageOption:h}}throw new Error("Sum of percentage option percentages are less than 100.")},t.prototype.evaluateConditions=function(e,r,n,i){var o=!0,a=i.logBuilder,u=!1;a==null||a.newLine("- ");for(var l=0;l<e.length;l++){var c=e[l];switch(a&&(l?a.increaseIndent().newLine("AND "):a.append("IF ").increaseIndent()),c.type){case"UserCondition":o=this.evaluateUserCondition(c,n,i),u=e.length>1;break;case"PrerequisiteFlagCondition":o=this.evaluatePrerequisiteFlagCondition(c,i),u=!0;break;case"SegmentCondition":o=this.evaluateSegmentCondition(c,i),u=!J(o)||o!==Oe||e.length>1;break;default:throw new Error}var f=o===!0;if(a&&((!r||e.length>1)&&a.appendConditionConsequence(f),a.decreaseIndent()),!f)break}return r&&(a==null||a.appendTargetingRuleConsequence(r,o,u)),o},t.prototype.evaluateUserCondition=function(e,r,n){var i=n.logBuilder;if(i==null||i.appendUserCondition(e),!n.userAttributes)return n.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(n.key),n.isMissingUserObjectLogged=!0),Oe;var o=e.comparisonAttribute,a=n.userAttributes[o];if(a==null||a==="")return this.logger.userObjectAttributeIsMissingCondition(pe(e),n.key,o),xt(o);var u,l,c,f;switch(e.comparator){case s.UserComparator.TextEquals:case s.UserComparator.TextNotEquals:return u=F(o,a,e,n.key,this.logger),this.evaluateTextEquals(u,e.comparisonValue,e.comparator===s.UserComparator.TextNotEquals);case s.UserComparator.SensitiveTextEquals:case s.UserComparator.SensitiveTextNotEquals:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextEquals(u,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveTextNotEquals);case s.UserComparator.IsOneOf:case s.UserComparator.IsNotOneOf:return u=F(o,a,e,n.key,this.logger),this.evaluateIsOneOf(u,e.comparisonValue,e.comparator===s.UserComparator.IsNotOneOf);case s.UserComparator.SensitiveIsOneOf:case s.UserComparator.SensitiveIsNotOneOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveIsOneOf(u,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveIsNotOneOf);case s.UserComparator.TextStartsWithAnyOf:case s.UserComparator.TextNotStartsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateTextSliceEqualsAnyOf(u,e.comparisonValue,!0,e.comparator===s.UserComparator.TextNotStartsWithAnyOf);case s.UserComparator.SensitiveTextStartsWithAnyOf:case s.UserComparator.SensitiveTextNotStartsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(u,e.comparisonValue,n.setting.configJsonSalt,r,!0,e.comparator===s.UserComparator.SensitiveTextNotStartsWithAnyOf);case s.UserComparator.TextEndsWithAnyOf:case s.UserComparator.TextNotEndsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateTextSliceEqualsAnyOf(u,e.comparisonValue,!1,e.comparator===s.UserComparator.TextNotEndsWithAnyOf);case s.UserComparator.SensitiveTextEndsWithAnyOf:case s.UserComparator.SensitiveTextNotEndsWithAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(u,e.comparisonValue,n.setting.configJsonSalt,r,!1,e.comparator===s.UserComparator.SensitiveTextNotEndsWithAnyOf);case s.UserComparator.ContainsAnyOf:case s.UserComparator.NotContainsAnyOf:return u=F(o,a,e,n.key,this.logger),this.evaluateContainsAnyOf(u,e.comparisonValue,e.comparator===s.UserComparator.NotContainsAnyOf);case s.UserComparator.SemVerIsOneOf:case s.UserComparator.SemVerIsNotOneOf:return l=Ct(o,a,e,n.key,this.logger),typeof l!="string"?this.evaluateSemVerIsOneOf(l,e.comparisonValue,e.comparator===s.UserComparator.SemVerIsNotOneOf):l;case s.UserComparator.SemVerLess:case s.UserComparator.SemVerLessOrEquals:case s.UserComparator.SemVerGreater:case s.UserComparator.SemVerGreaterOrEquals:return l=Ct(o,a,e,n.key,this.logger),typeof l!="string"?this.evaluateSemVerRelation(l,e.comparator,e.comparisonValue):l;case s.UserComparator.NumberEquals:case s.UserComparator.NumberNotEquals:case s.UserComparator.NumberLess:case s.UserComparator.NumberLessOrEquals:case s.UserComparator.NumberGreater:case s.UserComparator.NumberGreaterOrEquals:return c=rr(o,a,e,n.key,this.logger),typeof c!="string"?this.evaluateNumberRelation(c,e.comparator,e.comparisonValue):c;case s.UserComparator.DateTimeBefore:case s.UserComparator.DateTimeAfter:return c=nr(o,a,e,n.key,this.logger),typeof c!="string"?this.evaluateDateTimeRelation(c,e.comparisonValue,e.comparator===s.UserComparator.DateTimeBefore):c;case s.UserComparator.ArrayContainsAnyOf:case s.UserComparator.ArrayNotContainsAnyOf:return f=St(o,a,e,n.key,this.logger),typeof f!="string"?this.evaluateArrayContainsAnyOf(f,e.comparisonValue,e.comparator===s.UserComparator.ArrayNotContainsAnyOf):f;case s.UserComparator.SensitiveArrayContainsAnyOf:case s.UserComparator.SensitiveArrayNotContainsAnyOf:return f=St(o,a,e,n.key,this.logger),typeof f!="string"?this.evaluateSensitiveArrayContainsAnyOf(f,e.comparisonValue,n.setting.configJsonSalt,r,e.comparator===s.UserComparator.SensitiveArrayNotContainsAnyOf):f;default:throw new Error}},t.prototype.evaluateTextEquals=function(e,r,n){return e===r!==n},t.prototype.evaluateSensitiveTextEquals=function(e,r,n,i,o){var a=Ce(e,n,i);return a===r!==o},t.prototype.evaluateIsOneOf=function(e,r,n){var i=r.indexOf(e)>=0;return i!==n},t.prototype.evaluateSensitiveIsOneOf=function(e,r,n,i,o){var a=Ce(e,n,i),u=r.indexOf(a)>=0;return u!==o},t.prototype.evaluateTextSliceEqualsAnyOf=function(e,r,n,i){for(var o=0;o<r.length;o++){var a=r[o];if(!(e.length<a.length)){var u=(n?e.lastIndexOf(a,0):e.indexOf(a,e.length-a.length))>=0;if(u)return!i}}return i},t.prototype.evaluateSensitiveTextSliceEqualsAnyOf=function(e,r,n,i,o,a){for(var u=H(e),l=0;l<r.length;l++){var c=r[l],f=c.indexOf("_"),h=parseInt(c.slice(0,f));if(!(u.length<h)){var g=o?u.slice(0,h):u.slice(u.length-h),v=Et(g,n,i),d=v===c.slice(f+1);if(d)return!a}}return a},t.prototype.evaluateContainsAnyOf=function(e,r,n){for(var i=0;i<r.length;i++)if(e.indexOf(r[i])>=0)return!n;return n},t.prototype.evaluateSemVerIsOneOf=function(e,r,n){for(var i=!1,o=0;o<r.length;o++){var a=r[o];if(a.length){var u=me(a.trim());if(!u)return!1;!i&&e.compare(u)===0&&(i=!0)}}return i!==n},t.prototype.evaluateSemVerRelation=function(e,r,n){var i=me(n.trim());if(!i)return!1;var o=e.compare(i);switch(r){case s.UserComparator.SemVerLess:return o<0;case s.UserComparator.SemVerLessOrEquals:return o<=0;case s.UserComparator.SemVerGreater:return o>0;case s.UserComparator.SemVerGreaterOrEquals:return o>=0}},t.prototype.evaluateNumberRelation=function(e,r,n){switch(r){case s.UserComparator.NumberEquals:return e===n;case s.UserComparator.NumberNotEquals:return e!==n;case s.UserComparator.NumberLess:return e<n;case s.UserComparator.NumberLessOrEquals:return e<=n;case s.UserComparator.NumberGreater:return e>n;case s.UserComparator.NumberGreaterOrEquals:return e>=n}},t.prototype.evaluateDateTimeRelation=function(e,r,n){return n?e<r:e>r},t.prototype.evaluateArrayContainsAnyOf=function(e,r,n){for(var i=0;i<e.length;i++){var o=r.indexOf(e[i])>=0;if(o)return!n}return n},t.prototype.evaluateSensitiveArrayContainsAnyOf=function(e,r,n,i,o){for(var a=0;a<e.length;a++){var u=Ce(e[a],n,i),l=r.indexOf(u)>=0;if(l)return!o}return o},t.prototype.evaluatePrerequisiteFlagCondition=function(e,r){var n=r.logBuilder;n==null||n.appendPrerequisiteFlagCondition(e);var i=e.prerequisiteFlagKey,o=r.settings[i];if(r.visitedFlags.push(r.key),r.visitedFlags.indexOf(i)>=0){r.visitedFlags.push(i);var a=he(r.visitedFlags,void 0,void 0," -> ");throw new Error("Circular dependency detected between the following depending flags: "+a+".")}var u=Ee.forPrerequisiteFlag(i,o,r);n==null||n.newLine("(").increaseIndent().newLine("Evaluating prerequisite flag '"+i+"':");var l=this.evaluateSetting(u);r.visitedFlags.pop();var c=l.selectedValue.value;if(typeof c!=typeof e.comparisonValue){if(Y(c))throw new Error("Type mismatch between comparison value '"+e.comparisonValue+"' and prerequisite flag '"+i+"'.");Ae(c)}var f;switch(e.comparator){case s.PrerequisiteFlagComparator.Equals:f=c===e.comparisonValue;break;case s.PrerequisiteFlagComparator.NotEquals:f=c!==e.comparisonValue;break;default:throw new Error}return n==null||n.newLine("Prerequisite flag evaluation result: '"+x(c)+"'.").newLine("Condition (").appendPrerequisiteFlagCondition(e).append(") evaluates to ").appendEvaluationResult(f).append(".").decreaseIndent().newLine(")"),f},t.prototype.evaluateSegmentCondition=function(e,r){var n=r.logBuilder;if(n==null||n.appendSegmentCondition(e),!r.userAttributes)return r.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(r.key),r.isMissingUserObjectLogged=!0),Oe;var i=e.segment;n==null||n.newLine("(").increaseIndent().newLine("Evaluating segment '"+i.name+"':");var o=this.evaluateConditions(i.conditions,void 0,i.name,r),a=o;if(!J(a))switch(e.comparator){case s.SegmentComparator.IsIn:break;case s.SegmentComparator.IsNotIn:a=!a;break;default:throw new Error}return n&&(n.newLine("Segment evaluation result: "),(J(a)?n.append(a):n.append("User "+vt(o?s.SegmentComparator.IsIn:s.SegmentComparator.IsNotIn))).append("."),n.newLine("Condition (").appendSegmentCondition(e).append(")"),(J(a)?n.append(" failed to evaluate"):n.append(" evaluates to ").appendEvaluationResult(a)).append("."),n.decreaseIndent().newLine(")")),a},t}();function J(t){return typeof t=="string"}function mt(t){return Z(t)&&!t.some(function(e){return typeof e!="string"})}function Ce(t,e,r){return Et(H(t),e,r)}function Et(t,e,r){return nt(t+H(e)+H(r))}function Ot(t){return typeof t=="string"?t:t instanceof Date?t.getTime()/1e3+"":mt(t)?JSON.stringify(t):t+""}function F(t,e,r,n,i){return typeof e=="string"||(e=Ot(e),i.userObjectAttributeIsAutoConverted(pe(r),n,t,e)),e}function Ct(t,e,r,n,i){var o;return typeof e=="string"&&(o=me(e.trim()))?o:te(i,r,n,t,"'"+e+"' is not a valid semantic version")}function rr(t,e,r,n,i){if(typeof e=="number")return e;var o;return typeof e=="string"&&(!isNaN(o=Fe(e.replace(",",".")))||e==="NaN")?o:te(i,r,n,t,"'"+e+"' is not a valid decimal number")}function nr(t,e,r,n,i){if(e instanceof Date)return e.getTime()/1e3;if(typeof e=="number")return e;var o;return typeof e=="string"&&(!isNaN(o=Fe(e.replace(",",".")))||e==="NaN")?o:te(i,r,n,t,"'"+e+"' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)")}function St(t,e,r,n,i){var o=e;if(typeof o=="string")try{o=JSON.parse(o)}catch{}return mt(o)?o:te(i,r,n,t,"'"+e+"' is not a valid string array")}function te(t,e,r,n,i){return t.userObjectAttributeIsInvalid(pe(e),r,i,n),er(n,i)}function At(t,e,r,n){return{key:t,value:e.selectedValue.value,variationId:e.selectedValue.variationId,fetchTime:r,user:n,isDefaultValue:!1,matchedTargetingRule:e.matchedTargetingRule,matchedPercentageOption:e.matchedPercentageOption}}function V(t,e,r,n,i,o){return{key:t,value:e,fetchTime:r,user:n,isDefaultValue:!0,errorMessage:i,errorException:o}}function re(t,e,r,n,i,o,a){var u;if(!e)return u=a.configJsonIsNotPresentSingle(r,"defaultValue",n).toString(),V(r,n,D(o),i,u);var l=e[r];if(!l)return u=a.settingEvaluationFailedDueToMissingKey(r,"defaultValue",n,he(Object.keys(e))).toString(),V(r,n,D(o),i,u);var c=t.evaluate(n,new Ee(r,l,i,e));return At(r,c,D(o),i)}function bt(t,e,r,n,i,o){var a;if(!Se(e,i,o))return[[],a];for(var u=[],l=0,c=Object.entries(e);l<c.length;l++){var f=c[l],h=f[0],g=f[1],v=void 0;try{var d=t.evaluate(null,new Ee(h,g,r,e));v=At(h,d,D(n),r)}catch(p){a??(a=[]),a.push(p),v=V(h,null,D(n),r,W(p),p)}u.push(v)}return[u,a]}function Se(t,e,r){return t?!0:(e.configJsonIsNotPresent(r),!1)}function Y(t){return typeof t=="boolean"||typeof t=="string"||typeof t=="number"}function ir(t,e){switch(e){case s.SettingType.Boolean:return typeof t=="boolean";case s.SettingType.String:return typeof t=="string";case s.SettingType.Int:case s.SettingType.Double:return typeof t=="number";default:return!1}}function Ae(t){throw new TypeError(t===null?"Setting value is null.":t===void 0?"Setting value is undefined.":"Setting value '"+t+"' is of an unsupported type ("+typeof t+").")}function D(t){return t?new Date(t.timestamp):void 0}var or=function(){function t(){this.instances={}}return t.prototype.getOrCreate=function(e,r){var n,i=this.instances[e.sdkKey];if(i){var o=i[0];if(n=o.deref(),n)return[n,!0]}var a={};n=new be(e,r,a);var u=ut()?WeakRef:st();return this.instances[e.sdkKey]=[new u(n),a],[n,!1]},t.prototype.remove=function(e,r){var n=this.instances[e];if(n){var i=n[0],o=n[1],a=!!i.deref();if(!a||o===r)return delete this.instances[e],a}return!1},t.prototype.clear=function(){for(var e=[],r=0,n=Object.entries(this.instances);r<n.length;r++){var i=n[r],o=i[0],a=i[1][0],u=a.deref();u&&e.push(u),delete this.instances[o]}return e},t}(),$=new or,be=function(){function t(e,r,n){var i;if(this.cacheToken=n,this.addListener=this.on,this.off=this.removeListener,!e)throw new Error("Invalid 'options' value");if(this.options=e,this.options.logger.debug("Initializing ConfigCatClient. Options: "+JSON.stringify(this.options)),!r)throw new Error("Invalid 'configCatKernel' value");if(!r.configFetcher)throw new Error("Invalid 'configCatKernel.configFetcher' value");this.hooks=e.yieldHooks(),e.defaultUser&&this.setDefaultUser(e.defaultUser),this.evaluator=new tr(e.logger),((i=e.flagOverrides)===null||i===void 0?void 0:i.behaviour)!==s.OverrideBehaviour.LocalOnly?this.configService=e instanceof lt?new kt(r.configFetcher,e):e instanceof ct?new zt(r.configFetcher,e):e instanceof ft?new Kt(r.configFetcher,e):Re(new Error("Invalid 'options' value")):this.hooks.emit("clientReady",s.ClientCacheState.HasLocalOverrideFlagDataOnly),this.suppressFinalize=se(this,{sdkKey:e.sdkKey,cacheToken:n,configService:this.configService,logger:e.logger})}return Object.defineProperty(t,"instanceCache",{get:function(){return $},enumerable:!1,configurable:!0}),t.get=function(e,r,n,i){var o,a="Invalid 'sdkKey' value";if(!e)throw new Error(a);var u=r===s.PollingMode.AutoPoll?lt:r===s.PollingMode.ManualPoll?ct:r===s.PollingMode.LazyLoad?ft:Re(new Error("Invalid 'pollingMode' value")),l=new u(e,i.sdkType,i.sdkVersion,n,i.defaultCacheFactory,i.eventEmitterFactory);if(((o=l.flagOverrides)===null||o===void 0?void 0:o.behaviour)!==s.OverrideBehaviour.LocalOnly&&!ar(e,l.baseUrlOverriden))throw new Error(a);var c=$.getOrCreate(l,i),f=c[0],h=c[1];return h&&n&&l.logger.clientIsAlreadyCreated(e),f},t.finalize=function(e){var r;(r=e.logger)===null||r===void 0||r.debug("finalize() called"),e.cacheToken&&$.remove(e.sdkKey,e.cacheToken),t.close(e.configService,e.logger)},t.close=function(e,r,n){r==null||r.debug("close() called"),n==null||n.tryDisconnect(),e==null||e.dispose()},t.prototype.dispose=function(){var e=this.options;e.logger.debug("dispose() called"),this.cacheToken&&$.remove(e.sdkKey,this.cacheToken),t.close(this.configService,e.logger,this.hooks),this.suppressFinalize()},t.disposeAll=function(){for(var e=$.clear(),r,n=0,i=e;n<i.length;n++){var o=i[n];try{t.close(o.configService,o.options.logger,o.hooks),o.suppressFinalize()}catch(a){r??(r=[]),r.push(a)}}if(r)throw typeof AggregateError<"u"?new AggregateError(r):r.pop()},t.prototype.getValueAsync=function(e,r,n){return m(this,void 0,void 0,function(){var i,o,a,u,l,c;return E(this,function(f){switch(f.label){case 0:this.options.logger.debug("getValueAsync() called."),ie(e),oe(r),a=null,n??(n=this.defaultUser),f.label=1;case 1:return f.trys.push([1,3,,4]),u=void 0,[4,this.getSettingsAsync()];case 2:return c=f.sent(),u=c[0],a=c[1],o=re(this.evaluator,u,e,r,n,a,this.options.logger),i=o.value,[3,4];case 3:return l=f.sent(),this.options.logger.settingEvaluationErrorSingle("getValueAsync",e,"defaultValue",r,l),o=V(e,r,D(a),n,W(l),l),i=r,[3,4];case 4:return this.hooks.emit("flagEvaluated",o),[2,i]}})})},t.prototype.getValueDetailsAsync=function(e,r,n){return m(this,void 0,void 0,function(){var i,o,a,u,l;return E(this,function(c){switch(c.label){case 0:this.options.logger.debug("getValueDetailsAsync() called."),ie(e),oe(r),o=null,n??(n=this.defaultUser),c.label=1;case 1:return c.trys.push([1,3,,4]),a=void 0,[4,this.getSettingsAsync()];case 2:return l=c.sent(),a=l[0],o=l[1],i=re(this.evaluator,a,e,r,n,o,this.options.logger),[3,4];case 3:return u=c.sent(),this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync",e,"defaultValue",r,u),i=V(e,r,D(o),n,W(u),u),[3,4];case 4:return this.hooks.emit("flagEvaluated",i),[2,i]}})})},t.prototype.getAllKeysAsync=function(){return m(this,void 0,void 0,function(){var e,r,n;return E(this,function(i){switch(i.label){case 0:this.options.logger.debug("getAllKeysAsync() called."),e="empty array",i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return r=i.sent()[0],Se(r,this.options.logger,e)?[2,Object.keys(r)]:[2,[]];case 3:return n=i.sent(),this.options.logger.settingEvaluationError("getAllKeysAsync",e,n),[2,[]];case 4:return[2]}})})},t.prototype.getAllValuesAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f,h,g,v;return E(this,function(d){switch(d.label){case 0:this.options.logger.debug("getAllValuesAsync() called."),r="empty array",e??(e=this.defaultUser),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return a=d.sent(),u=a[0],l=a[1],v=bt(this.evaluator,u,e,l,this.options.logger,r),i=v[0],o=v[1],n=i.map(function(p){return new j(p.key,p.value)}),[3,4];case 3:return c=d.sent(),this.options.logger.settingEvaluationError("getAllValuesAsync",r,c),[2,[]];case 4:for(o!=null&&o.length&&this.options.logger.settingEvaluationError("getAllValuesAsync","evaluation result",typeof AggregateError<"u"?new AggregateError(o):o.pop()),f=0,h=i;f<h.length;f++)g=h[f],this.hooks.emit("flagEvaluated",g);return[2,n]}})})},t.prototype.getAllValueDetailsAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f,h,g;return E(this,function(v){switch(v.label){case 0:this.options.logger.debug("getAllValueDetailsAsync() called."),r="empty array",e??(e=this.defaultUser),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:return o=v.sent(),a=o[0],u=o[1],g=bt(this.evaluator,a,e,u,this.options.logger,r),n=g[0],i=g[1],[3,4];case 3:return l=v.sent(),this.options.logger.settingEvaluationError("getAllValueDetailsAsync",r,l),[2,[]];case 4:for(i!=null&&i.length&&this.options.logger.settingEvaluationError("getAllValueDetailsAsync","evaluation result",typeof AggregateError<"u"?new AggregateError(i):i.pop()),c=0,f=n;c<f.length;c++)h=f[c],this.hooks.emit("flagEvaluated",h);return[2,n]}})})},t.prototype.getKeyAndValueAsync=function(e){return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,v,f,h,d,g,v,d,p;return E(this,function(C){switch(C.label){case 0:this.options.logger.debug("getKeyAndValueAsync() called."),r="null",C.label=1;case 1:return C.trys.push([1,3,,4]),[4,this.getSettingsAsync()];case 2:if(n=C.sent()[0],!Se(n,this.options.logger,r))return[2,null];for(i=0,o=Object.entries(n);i<o.length;i++){if(a=o[i],u=a[0],l=a[1],e===l.variationId)return[2,new j(u,ae(l.value))];if(c=n[u].targetingRules,c&&c.length>0){for(v=0;v<c.length;v++)if(f=c[v].then,Z(f)){for(h=0;h<f.length;h++)if(d=f[h],e===d.variationId)return[2,new j(u,ae(d.value))]}else if(e===f.variationId)return[2,new j(u,ae(f.value))]}if(g=n[u].percentageOptions,g&&g.length>0){for(v=0;v<g.length;v++)if(d=g[v],e===d.variationId)return[2,new j(u,ae(d.value))]}}return this.options.logger.settingForVariationIdIsNotPresent(e),[3,4];case 3:return p=C.sent(),this.options.logger.settingEvaluationError("getKeyAndValueAsync",r,p),[3,4];case 4:return[2,null]}})})},t.prototype.forceRefreshAsync=function(){return m(this,void 0,void 0,function(){var e,r;return E(this,function(n){switch(n.label){case 0:if(this.options.logger.debug("forceRefreshAsync() called."),!this.configService)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.configService.refreshConfigAsync()];case 2:return e=n.sent()[0],[2,e];case 3:return r=n.sent(),this.options.logger.forceRefreshError("forceRefreshAsync",r),[2,_.failure(W(r),r)];case 4:return[3,6];case 5:return[2,_.failure("Client is configured to use the LocalOnly override behavior, which prevents making HTTP requests.")];case 6:return[2]}})})},t.prototype.setDefaultUser=function(e){this.defaultUser=e},t.prototype.clearDefaultUser=function(){this.defaultUser=void 0},Object.defineProperty(t.prototype,"isOffline",{get:function(){var e,r;return(r=(e=this.configService)===null||e===void 0?void 0:e.isOffline)!==null&&r!==void 0?r:!0},enumerable:!1,configurable:!0}),t.prototype.setOnline=function(){this.configService?this.configService.setOnline():this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(s.OverrideBehaviour[s.OverrideBehaviour.LocalOnly],"setOnline")},t.prototype.setOffline=function(){var e;(e=this.configService)===null||e===void 0||e.setOffline()},t.prototype.waitForReady=function(){var e=this.configService;return e?e.readyPromise:Promise.resolve(s.ClientCacheState.HasLocalOverrideFlagDataOnly)},t.prototype.snapshot=function(){var e,r,n,i=this,o,a=function(){var h=i.options.cache.getInMemory(),g=h.isEmpty?null:h.config.settings;return[g,h]},u,l,c=(o=this.options)===null||o===void 0?void 0:o.flagOverrides;if(c){var f=c.dataSource.getOverridesSync();switch(c.behaviour){case s.OverrideBehaviour.LocalOnly:return new ne(f,null,this);case s.OverrideBehaviour.LocalOverRemote:return e=a(),u=e[0],l=e[1],new ne(L(L({},u??{}),f),l,this);case s.OverrideBehaviour.RemoteOverLocal:return r=a(),u=r[0],l=r[1],new ne(L(L({},f),u??{}),l,this)}}return n=a(),u=n[0],l=n[1],new ne(u,l,this)},t.prototype.getSettingsAsync=function(){var e;return m(this,void 0,void 0,function(){var r,n,i,o,a,u,l,c,f=this;return E(this,function(h){switch(h.label){case 0:return this.options.logger.debug("getSettingsAsync() called."),r=function(){return m(f,void 0,void 0,function(){var g,v;return E(this,function(d){switch(d.label){case 0:return[4,this.configService.getConfig()];case 1:return g=d.sent(),v=g.isEmpty?null:g.config.settings,[2,[v,g]]}})})},n=(e=this.options)===null||e===void 0?void 0:e.flagOverrides,n?(i=void 0,o=void 0,[4,n.dataSource.getOverrides()]):[3,7];case 1:switch(a=h.sent(),u=n.behaviour,u){case s.OverrideBehaviour.LocalOnly:return[3,2];case s.OverrideBehaviour.LocalOverRemote:return[3,3];case s.OverrideBehaviour.RemoteOverLocal:return[3,5]}return[3,7];case 2:return[2,[a,null]];case 3:return[4,r()];case 4:return l=h.sent(),i=l[0],o=l[1],[2,[L(L({},i??{}),a),o]];case 5:return[4,r()];case 6:return c=h.sent(),i=c[0],o=c[1],[2,[L(L({},a),i??{}),o]];case 7:return[4,r()];case 8:return[2,h.sent()]}})})},t.prototype.on=function(e,r){return this.hooks.on(e,r),this},t.prototype.once=function(e,r){return this.hooks.once(e,r),this},t.prototype.removeListener=function(e,r){return this.hooks.removeListener(e,r),this},t.prototype.removeAllListeners=function(e){return this.hooks.removeAllListeners(e),this},t.prototype.listeners=function(e){return this.hooks.listeners(e)},t.prototype.listenerCount=function(e){return this.hooks.listenerCount(e)},t.prototype.eventNames=function(){return this.hooks.eventNames()},t}(),ne=function(){function t(e,r,n){this.mergedSettings=e,this.remoteConfig=r,this.defaultUser=n.defaultUser,this.evaluator=n.evaluator,this.options=n.options,this.cacheState=r?n.configService.getCacheState(r):s.ClientCacheState.HasLocalOverrideFlagDataOnly}return Object.defineProperty(t.prototype,"fetchedConfig",{get:function(){var e=this.remoteConfig;return e&&!e.isEmpty?e.config:null},enumerable:!1,configurable:!0}),t.prototype.getAllKeys=function(){return this.mergedSettings?Object.keys(this.mergedSettings):[]},t.prototype.getValue=function(e,r,n){this.options.logger.debug("Snapshot.getValue() called."),ie(e),oe(r);var i,o;n??(n=this.defaultUser);try{o=re(this.evaluator,this.mergedSettings,e,r,n,this.remoteConfig,this.options.logger),i=o.value}catch(a){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue",e,"defaultValue",r,a),o=V(e,r,D(this.remoteConfig),n,W(a),a),i=r}return this.options.hooks.emit("flagEvaluated",o),i},t.prototype.getValueDetails=function(e,r,n){this.options.logger.debug("Snapshot.getValueDetails() called."),ie(e),oe(r);var i;n??(n=this.defaultUser);try{i=re(this.evaluator,this.mergedSettings,e,r,n,this.remoteConfig,this.options.logger)}catch(o){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails",e,"defaultValue",r,o),i=V(e,r,D(this.remoteConfig),n,W(o),o)}return this.options.hooks.emit("flagEvaluated",i),i},t}(),j=function(){function t(e,r){this.settingKey=e,this.settingValue=r}return t}();function ar(t,e){var r="configcat-proxy/";if(e&&t.length>r.length&&t.lastIndexOf(r,0)===0)return!0;var n=t.split("/"),i=22;switch(n.length){case 2:return n[0].length===i&&n[1].length===i;case 3:return n[0]==="configcat-sdk-1"&&n[1].length===i&&n[2].length===i;default:return!1}}function ie(t){if(!t)throw new Error("Invalid 'key' value")}function oe(t){if(t!=null&&!Y(t))throw new TypeError("The default value must be boolean, number, string, null or undefined.")}function ae(t){return Y(t)?t:Ae(t)}var se=function(t,e){if(typeof FinalizationRegistry<"u"){var r=new FinalizationRegistry(function(n){return be.finalize(n)});se=function(n,i){var o={};return r.register(n,i,o),function(){return r.unregister(o)}}}else se=function(){return function(){}};return se(t,e)};Wt();function sr(t,e,r,n){return be.get(t,e,r,n)}function ur(t){return new ke(t)}function lr(t,e,r){return new Ht(new _t(t,r),e)}class cr{handleStateChange(e,r,n){try{if(e.readyState===4){const{status:i,statusText:o}=e;if(i===200){const a=e.getResponseHeader("ETag")??void 0;r({statusCode:i,reasonPhrase:o,eTag:a,body:e.responseText})}else i&&r({statusCode:i,reasonPhrase:o})}}catch(i){n(i)}}fetchLogic(e,r){return new Promise((n,i)=>{try{e.logger.debug("HttpConfigFetcher.fetchLogic() called.");const o=new XMLHttpRequest;o.onreadystatechange=()=>this.handleStateChange(o,n,i),o.ontimeout=()=>i(new Q("timeout",e.requestTimeoutMs)),o.onabort=()=>i(new Q("abort")),o.onerror=()=>i(new Q("failure"));let a=e.getUrl();r&&(a+="&ccetag="+encodeURIComponent(r)),o.open("GET",a,!0),o.timeout=e.requestTimeoutMs,o.send(null)}catch(o){i(o)}})}}class Te{constructor(e){this.storage=e}static setup(e,r){const n=(r??fr)();return n&&(e.defaultCacheFactory=i=>new De(new Te(n),i.logger)),e}set(e,r){this.storage.setItem(e,hr(r))}get(e){const r=this.storage.getItem(e);if(r)return gr(r)}}function fr(){const t="__configcat_localStorage_test";try{const e=window.localStorage;e.setItem(t,t);let r;try{r=e.getItem(t)}finally{e.removeItem(t)}if(r===t)return e}catch{}return null}function hr(t){return t=encodeURIComponent(t),t=t.replace(/%([0-9A-F]{2})/g,(e,r)=>String.fromCharCode(parseInt(r,16))),btoa(t)}function gr(t){return t=atob(t),t=t.replace(/[%\x80-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16)),decodeURIComponent(t)}const vr="2.2.3",dr={install:(t,e)=>{const{sdkKey:r,pollingMode:n,clientOptions:i}=e,o=Te.setup({sdkType:"ConfigCat-Vue",sdkVersion:vr,configFetcher:new cr}),a=sr(r,n??s.PollingMode.AutoPoll,i,o);t.provide("configCatClient",a);const u=t.unmount;t.unmount=function(){u.apply(arguments),a.dispose()}}},pr=N.defineComponent({__name:"FeatureWrapper",props:{featureKey:{},userObject:{}},emits:["flagValueChanged"],setup(t,{emit:e}){const r=t,n=N.ref(null),i=N.inject("configCatClient")??(()=>{throw new Error("ConfigCatPlugin was not installed.")})(),o=()=>{const u=i.snapshot().getValue(r.featureKey,!1,r.userObject);n.value!==u&&(n.value=u,e("flagValueChanged",u))};return N.onBeforeMount(()=>{const a=i.snapshot(),u=a.cacheState;u==s.ClientCacheState.HasUpToDateFlagData||u==s.ClientCacheState.HasLocalOverrideFlagDataOnly?(n.value=a.getValue(r.featureKey,!1,r.userObject),i.on("configChanged",o)):i.getValueAsync(r.featureKey,!1,r.userObject).then(l=>{const c=o;c&&(n.value=l,i.on("configChanged",c))})}),N.onUnmounted(()=>{i.off("configChanged",o)}),(a,u)=>n.value===!0?N.renderSlot(a.$slots,"default",{key:0}):n.value===!1?N.renderSlot(a.$slots,"else",{key:1}):N.renderSlot(a.$slots,"loading",{key:2})}});s.ConfigCatPlugin=dr,s.FeatureWrapper=pr,s.FormattableLogMessage=S,s.RefreshResult=_,s.SettingKeyValue=j,s.User=Xt,s.createConsoleLogger=ur,s.createFlagOverridesFromMap=lr,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configcat-vue",
3
- "description": "A simple and easy to use Vue3 plugin for using ConfigCat Feature Flags in your Vue.js Application",
3
+ "description": "A community-maintained SDK for integrating ConfigCat feature flags into Vue.js applications.",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -19,7 +19,7 @@
19
19
  }
20
20
  }
21
21
  },
22
- "version": "2.2.3",
22
+ "version": "2.2.5",
23
23
  "keywords": [
24
24
  "configcat",
25
25
  "ConfigCat",
@@ -43,17 +43,21 @@
43
43
  "scripts": {
44
44
  "dev": "vite",
45
45
  "build": "vue-tsc && vite build",
46
- "preview": "vite preview"
46
+ "preview": "vite preview",
47
+ "test": "vitest"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "vue": "^3.0.0"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@types/node": "^20.8.6",
53
- "@vitejs/plugin-vue": "^4.2.3",
54
+ "@vitejs/plugin-vue": "^4.6.2",
55
+ "@vue/test-utils": "^2.4.3",
56
+ "happy-dom": "^13.2.1",
54
57
  "typescript": "^5.0.2",
55
58
  "vite": "^4.4.5",
56
59
  "vite-plugin-dts": "^3.6.0",
60
+ "vitest": "^1.2.1",
57
61
  "vue-tsc": "^1.8.5"
58
62
  },
59
63
  "dependencies": {