configcat-vue 2.6.5 → 2.6.6
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 +9 -11
- package/dist/configcat-vue.js +1 -1
- package/dist/configcat-vue.umd.cjs +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/configcat-vue)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Welcome to the Vue.js SDK for ConfigCat Feature Flags. This community-maintained SDK was designed to streamline your feature development workflow. Whether you're a seasoned developer or just starting, **configcat-vue offers a comprehensive way to leverage all the benefits of using ConfigCat feature flags in your Vue.js applications**. This package includes all the features provided by other [ConfigCat SDKs](https://configcat.com/docs/sdk-reference/overview/) and is based on [configcat-js](https://www.npmjs.com/package/configcat-js).
|
|
5
|
+
A community-maintained Vue.js SDK for ConfigCat Feature Flags. This package includes all the features provided by other [ConfigCat SDKs](https://configcat.com/docs/sdk-reference/overview/) and is based on the [ConfigCat SDK for JavaScript](https://www.npmjs.com/package/@configcat/sdk).
|
|
8
6
|
|
|
9
7
|
## What you can do with this SDK
|
|
10
8
|
|
|
11
|
-
- Easily toggle features in your Vue.js app
|
|
12
|
-
- Experiment with new features
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- Conduct A/B testing of your
|
|
9
|
+
- Easily toggle features in your Vue.js app, even after deployment.
|
|
10
|
+
- Experiment with new features, rolling them back instantly if needed, without taking your app offline.
|
|
11
|
+
- Target feature releases based on user demographics, such as country, email, or custom attributes like eye color.
|
|
12
|
+
- Release new features gradually to a specific percentage of users.
|
|
13
|
+
- Conduct effortless A/B testing of your app's features.
|
|
16
14
|
|
|
17
15
|
## Documentation
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
For more in-depth guidance, explore the official ConfigCat documentation: https://configcat.com/docs/sdk-reference/community/vue/
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
Interested in helping make this project better?
|
|
22
20
|
|
|
23
|
-
Whether you're good at coding, writing documentation, testing, or bug reporting, feel free to contribute
|
|
21
|
+
Whether you're good at coding, writing documentation, testing, or bug reporting, feel free to contribute [here](https://github.com/codedbychavez/configcat-vue).
|
package/dist/configcat-vue.js
CHANGED
|
@@ -3079,7 +3079,7 @@ class Ln extends Ji {
|
|
|
3079
3079
|
};
|
|
3080
3080
|
}
|
|
3081
3081
|
}
|
|
3082
|
-
const Gi = "2.6.
|
|
3082
|
+
const Gi = "2.6.6", is = {
|
|
3083
3083
|
// Vue's `App.prototype.use` does not play nicely with generic `install` functions, so we resort to using a discriminated union.
|
|
3084
3084
|
install: (n, e) => {
|
|
3085
3085
|
const { sdkKey: t, pollingMode: i, clientOptions: s } = e, r = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(h,$){typeof exports=="object"&&typeof module<"u"?$(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],$):(h=typeof globalThis<"u"?globalThis:h||self,$(h["configcat-vue"]={},h.Vue))})(this,function(h,$){"use strict";class xe{constructor(){this.callbacks=[]}get aborted(){return!this.callbacks}abort(){if(!this.aborted){const e=this.callbacks;this.callbacks=void 0;for(const t of e)t()}}registerCallback(e){return this.aborted?(e(),()=>{}):(this.callbacks.push(e),()=>{const t=this.callbacks;let i;t&&(i=t.indexOf(e))>=0&&t.splice(i,1)})}}function Ot(n,e){let t;return new Promise(i=>{const s=e?.registerCallback(()=>{clearTimeout(t),i(!1)});t=setTimeout(()=>{s?.(),i(!0)},n)})}const Ct=typeof performance<"u"&&P(performance?.now)?()=>performance.now():()=>new Date().getTime();function Tt(n){return new Cn(n)}const Cn=typeof WeakRef=="function"?WeakRef:Tn();function Tn(){const n=function(e){this.target=e};return n.prototype.deref=function(){return this.target},n.isFallback=!0,n}function L(n){try{return typeof n=="symbol"?"[symbol]":typeof n=="object"&&n!==null&&!P(n.toString)?Object.prototype.toString.call(n):String(n)}catch{return"[unknown]"}}function G(n,e=!1){return n instanceof Error?t(n,""):L(n);function t(i,s,r){const o=i.toString();let a=(s&&s.substring(4)+"--> ")+o;if(e&&i.stack){let l=i.stack.trim();l.lastIndexOf(o,0)===0&&(l=l.substring(o.length).trim()),a+=`
|
|
1
|
+
(function(h,$){typeof exports=="object"&&typeof module<"u"?$(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],$):(h=typeof globalThis<"u"?globalThis:h||self,$(h["configcat-vue"]={},h.Vue))})(this,(function(h,$){"use strict";class xe{constructor(){this.callbacks=[]}get aborted(){return!this.callbacks}abort(){if(!this.aborted){const e=this.callbacks;this.callbacks=void 0;for(const t of e)t()}}registerCallback(e){return this.aborted?(e(),()=>{}):(this.callbacks.push(e),()=>{const t=this.callbacks;let i;t&&(i=t.indexOf(e))>=0&&t.splice(i,1)})}}function Ot(n,e){let t;return new Promise(i=>{const s=e?.registerCallback(()=>{clearTimeout(t),i(!1)});t=setTimeout(()=>{s?.(),i(!0)},n)})}const Ct=typeof performance<"u"&&P(performance?.now)?()=>performance.now():()=>new Date().getTime();function Tt(n){return new Cn(n)}const Cn=typeof WeakRef=="function"?WeakRef:Tn();function Tn(){const n=function(e){this.target=e};return n.prototype.deref=function(){return this.target},n.isFallback=!0,n}function L(n){try{return typeof n=="symbol"?"[symbol]":typeof n=="object"&&n!==null&&!P(n.toString)?Object.prototype.toString.call(n):String(n)}catch{return"[unknown]"}}function G(n,e=!1){return n instanceof Error?t(n,""):L(n);function t(i,s,r){const o=i.toString();let a=(s&&s.substring(4)+"--> ")+o;if(e&&i.stack){let l=i.stack.trim();l.lastIndexOf(o,0)===0&&(l=l.substring(o.length).trim()),a+=`
|
|
2
2
|
`+l.replace(/^\s*(?:at\s)?/gm,s+" at ")}if(typeof AggregateError=="function"&&i instanceof AggregateError){(r??(r=[])).push(i);for(const l of i.errors)if(l instanceof Error){if(r.indexOf(l)>=0)continue;a+=`
|
|
3
3
|
`+t(l,s+" ",r)}else a+=`
|
|
4
|
-
`+s+"--> "+L(l);r.pop()}return a}}function F(){return Object.create(null)}const bt=P(Object.setPrototypeOf)?Object.setPrototypeOf:(n,e)=>(n.__proto__=e,n);function je(n,e){n instanceof e||bt(n,e.prototype)}function D(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ve(n){return typeof n=="boolean"}function W(n){return typeof n=="number"}function It(n,e,t){return W(n)&&e<=n&&n<=t}const Be=P(Number.isSafeInteger)?Number.isSafeInteger:n=>W(n)&&isFinite(n)&&Math.floor(n)===n&&Math.abs(n)<=9007199254740991;function Ke(n,e,t){return Be(n)&&e<=n&&n<=t}function S(n){return typeof n=="string"}function Se(n){return typeof n=="object"&&n!==null&&!M(n)}function M(n){return Array.isArray(n)}function wt(n){return M(n)&&!n.some(e=>!S(e))}function P(n){return typeof n=="function"}function Rt(n){return P(n?.then)}function We(n,e,t){return Ve(n)||re(n,e,"boolean",t),n}function Nt(n,e,t){return W(n)||re(n,e,"number",t),n}function Ae(n,e,t,i,s){return Nt(n,e,s),i(n)||Q(e,`Expected a value ${t}, got ${n}.`,s,RangeError),n}function ee(n,e,t,i,s){return Nt(n,e,s),i(n)||Q(e,`Expected a valid \`${t}\` value, got '${n}'.`,s,RangeError),n}function Y(n,e,t,i){return S(n)||re(n,e,"string",i),n.length||!t||Q(e,"Expected a non-empty string.",i),n}function Ft(n,e,t){return P(n)||re(n,e,"function",t),n}function _(n,e,t,i){if(Se(n)||re(n,e,"object",i),t)for(const s in t){const r=t[s];(!(s in n)||r&&!P(n[s]))&&Q(e,`Expected an object with ${r?"method":"property"} \`${s}\`.`,i,TypeError)}return n}function re(n,e,t,i){Q(e,`Expected a value of type ${t}, got ${n===null?"null":typeof n}.`,i,TypeError)}function Q(n,e,t,i){const s=t?"property":(t="","argument");throw(i??Error)(`Invalid ${s} \`${n}${t}\`. ${e}`)}function ze(n,e=0,t,i=", "){const s=n.length;if(!s)return"";let r="";return e>0&&s>e&&(n=n.slice(0,e),t&&(r=t(s-e))),"'"+n.join("'"+i+"'")+"'"+r}function oe(n){function e(o,a){const l=o.charCodeAt(a);if(55296<=l&&l<56320){const c=o.charCodeAt(a+1);if(56320<=c&&c<=57343)return(l<<10)+c-56613888}return l}let t="",i=0;const s=String.fromCharCode;let r;for(r=0;r<n.length;r++){const o=e(n,r);o<=127||(t+=n.slice(i,r),o<=2047?(t+=s(192|o>>6),t+=s(128|o&63)):o<=65535?(t+=s(224|o>>12),t+=s(128|o>>6&63),t+=s(128|o&63)):(t+=s(240|o>>18),t+=s(128|o>>12&63),t+=s(128|o>>6&63),t+=s(128|o&63),++r),i=r+1)}return t+=n.slice(i,r)}function bn(n){if(!n.length||!/^\s*[+-]?\d+\s*$/.test(n))return NaN;const e=+n;return Be(e)?e:NaN}function Je(n){return!n.length||/^\s*$|^\s*0[^\d.eE]/.test(n)?NaN:+n}function Lt(n,e){const t={};for(const i in n)if(D(n,i)){const s=n[i];t[i]=e?e(i,s):s}return t}class ae{constructor(e,t){this.state=e,this.factoryOrValue=t}toString(){let{factoryOrValue:e}=this;return S(e)||(this.factoryOrValue=e=e(this.state),this.state=void 0),e}}class Dt{constructor(){this.events=F(),this.eventCount=0}addListenerCore(e,t,i){if(!P(t))throw TypeError("Listener must be a function");const s=this.events[e],r={fn:t,once:i};return s?M(s)?s.push(r):this.events[e]=[s,r]:(this.events[e]=r,this.eventCount++),this}removeListenerCore(e,t,i){const s=this.events[e];if(!s)return this;if(M(s)){for(let r=s.length-1;r>=0;r--)if(i(s[r],t)){s.splice(r,1),s.length?s.length===1&&(this.events[e]=s[0]):this.removeEvent(e);break}}else i(s,t)&&this.removeEvent(e);return this}removeEvent(e){--this.eventCount===0?this.events=F():delete this.events[e]}on(e,t){return this.addListenerCore(e,t,!1)}once(e,t){return this.addListenerCore(e,t,!0)}removeListener(e,t){if(!P(t))throw TypeError("Listener must be a function");return this.removeListenerCore(e,t,(i,s)=>i.fn===s)}removeAllListeners(e){return arguments.length?this.events[e]&&this.removeEvent(e):(this.events=F(),this.eventCount=0),this}listeners(e){const t=this.events[e];if(!t)return[];if(!M(t))return[t.fn];const i=t.length,s=new Array(i);for(let r=0;r<i;r++)s[r]=t[r].fn;return s}listenerCount(e){const t=this.events[e];return t?M(t)?t.length:1:0}eventNames(){const e=[];if(this.eventCount===0)return e;const t=this.events;for(const i in t)e.push(i);return P(Object.getOwnPropertySymbols)?e.concat(Object.getOwnPropertySymbols(t)):e}emit(e,t,i,s,r,...o){let a=this.events[e];if(!a)return!1;let l,c;M(a)?(a=a.slice(),[l,c]=[a[0],a.length]):[l,c]=[a,1];const f=arguments.length-1;for(let u=0;;){switch(l.once&&this.removeListenerCore(e,l,(g,d)=>g===d),f){case 0:l.fn.call(this);break;case 1:l.fn.call(this,t);break;case 2:l.fn.call(this,t,i);break;case 3:l.fn.call(this,t,i,s);break;case 4:l.fn.call(this,t,i,s,r);break;default:const g=new Array(f);for(let d=0;d<f;d++)g[d]=arguments[d+1];l.fn.apply(this,g);break}if(++u>=c)break;l=a[u]}return!0}}const Oe=Dt.prototype;Oe.addListener=Oe.on,Oe.off=Oe.removeListener;var Ge;(function(n){n[n.No=0]="No",n[n.Should=1]="Should",n[n.Force=2]="Force"})(Ge||(Ge={})),h.SettingType=void 0,function(n){n[n.Boolean=0]="Boolean",n[n.String=1]="String",n[n.Int=2]="Int",n[n.Double=3]="Double"}(h.SettingType||(h.SettingType={})),h.UserComparator=void 0,function(n){n[n.TextIsOneOf=0]="TextIsOneOf",n[n.TextIsNotOneOf=1]="TextIsNotOneOf",n[n.TextContainsAnyOf=2]="TextContainsAnyOf",n[n.TextNotContainsAnyOf=3]="TextNotContainsAnyOf",n[n.SemVerIsOneOf=4]="SemVerIsOneOf",n[n.SemVerIsNotOneOf=5]="SemVerIsNotOneOf",n[n.SemVerLess=6]="SemVerLess",n[n.SemVerLessOrEquals=7]="SemVerLessOrEquals",n[n.SemVerGreater=8]="SemVerGreater",n[n.SemVerGreaterOrEquals=9]="SemVerGreaterOrEquals",n[n.NumberEquals=10]="NumberEquals",n[n.NumberNotEquals=11]="NumberNotEquals",n[n.NumberLess=12]="NumberLess",n[n.NumberLessOrEquals=13]="NumberLessOrEquals",n[n.NumberGreater=14]="NumberGreater",n[n.NumberGreaterOrEquals=15]="NumberGreaterOrEquals",n[n.SensitiveTextIsOneOf=16]="SensitiveTextIsOneOf",n[n.SensitiveTextIsNotOneOf=17]="SensitiveTextIsNotOneOf",n[n.DateTimeBefore=18]="DateTimeBefore",n[n.DateTimeAfter=19]="DateTimeAfter",n[n.SensitiveTextEquals=20]="SensitiveTextEquals",n[n.SensitiveTextNotEquals=21]="SensitiveTextNotEquals",n[n.SensitiveTextStartsWithAnyOf=22]="SensitiveTextStartsWithAnyOf",n[n.SensitiveTextNotStartsWithAnyOf=23]="SensitiveTextNotStartsWithAnyOf",n[n.SensitiveTextEndsWithAnyOf=24]="SensitiveTextEndsWithAnyOf",n[n.SensitiveTextNotEndsWithAnyOf=25]="SensitiveTextNotEndsWithAnyOf",n[n.SensitiveArrayContainsAnyOf=26]="SensitiveArrayContainsAnyOf",n[n.SensitiveArrayNotContainsAnyOf=27]="SensitiveArrayNotContainsAnyOf",n[n.TextEquals=28]="TextEquals",n[n.TextNotEquals=29]="TextNotEquals",n[n.TextStartsWithAnyOf=30]="TextStartsWithAnyOf",n[n.TextNotStartsWithAnyOf=31]="TextNotStartsWithAnyOf",n[n.TextEndsWithAnyOf=32]="TextEndsWithAnyOf",n[n.TextNotEndsWithAnyOf=33]="TextNotEndsWithAnyOf",n[n.ArrayContainsAnyOf=34]="ArrayContainsAnyOf",n[n.ArrayNotContainsAnyOf=35]="ArrayNotContainsAnyOf"}(h.UserComparator||(h.UserComparator={})),h.PrerequisiteFlagComparator=void 0,function(n){n[n.Equals=0]="Equals",n[n.NotEquals=1]="NotEquals"}(h.PrerequisiteFlagComparator||(h.PrerequisiteFlagComparator={})),h.SegmentComparator=void 0,function(n){n[n.IsIn=0]="IsIn",n[n.IsNotIn=1]="IsNotIn"}(h.SegmentComparator||(h.SegmentComparator={}));const In=Object.freeze(Object.defineProperty({__proto__:null,get PrerequisiteFlagComparator(){return h.PrerequisiteFlagComparator},get RedirectMode(){return Ge},get SegmentComparator(){return h.SegmentComparator},get SettingType(){return h.SettingType},get UserComparator(){return h.UserComparator}},Symbol.toStringTag,{value:"Module"}));class b{static contentEquals(e,t){return e.httpETag&&t.httpETag?e.httpETag===t.httpETag:e.configJson===t.configJson}constructor(e,t,i,s){this.configJson=e,this.config=t,this.timestamp=i,this.httpETag=s}with(e){return new b(this.configJson,this.config,e,this.httpETag)}get isEmpty(){return!this.config}isExpired(e){return this===b.empty||this.timestamp+e<b.generateTimestamp()}static generateTimestamp(){return new Date().getTime()}static serialize(e){var t,i;return e.timestamp+`
|
|
4
|
+
`+s+"--> "+L(l);r.pop()}return a}}function F(){return Object.create(null)}const bt=P(Object.setPrototypeOf)?Object.setPrototypeOf:(n,e)=>(n.__proto__=e,n);function je(n,e){n instanceof e||bt(n,e.prototype)}function D(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ve(n){return typeof n=="boolean"}function W(n){return typeof n=="number"}function It(n,e,t){return W(n)&&e<=n&&n<=t}const Be=P(Number.isSafeInteger)?Number.isSafeInteger:n=>W(n)&&isFinite(n)&&Math.floor(n)===n&&Math.abs(n)<=9007199254740991;function Ke(n,e,t){return Be(n)&&e<=n&&n<=t}function S(n){return typeof n=="string"}function Se(n){return typeof n=="object"&&n!==null&&!M(n)}function M(n){return Array.isArray(n)}function wt(n){return M(n)&&!n.some(e=>!S(e))}function P(n){return typeof n=="function"}function Rt(n){return P(n?.then)}function We(n,e,t){return Ve(n)||re(n,e,"boolean",t),n}function Nt(n,e,t){return W(n)||re(n,e,"number",t),n}function Ae(n,e,t,i,s){return Nt(n,e,s),i(n)||Q(e,`Expected a value ${t}, got ${n}.`,s,RangeError),n}function ee(n,e,t,i,s){return Nt(n,e,s),i(n)||Q(e,`Expected a valid \`${t}\` value, got '${n}'.`,s,RangeError),n}function Y(n,e,t,i){return S(n)||re(n,e,"string",i),n.length||!t||Q(e,"Expected a non-empty string.",i),n}function Ft(n,e,t){return P(n)||re(n,e,"function",t),n}function _(n,e,t,i){if(Se(n)||re(n,e,"object",i),t)for(const s in t){const r=t[s];(!(s in n)||r&&!P(n[s]))&&Q(e,`Expected an object with ${r?"method":"property"} \`${s}\`.`,i,TypeError)}return n}function re(n,e,t,i){Q(e,`Expected a value of type ${t}, got ${n===null?"null":typeof n}.`,i,TypeError)}function Q(n,e,t,i){const s=t?"property":(t="","argument");throw(i??Error)(`Invalid ${s} \`${n}${t}\`. ${e}`)}function ze(n,e=0,t,i=", "){const s=n.length;if(!s)return"";let r="";return e>0&&s>e&&(n=n.slice(0,e),t&&(r=t(s-e))),"'"+n.join("'"+i+"'")+"'"+r}function oe(n){function e(o,a){const l=o.charCodeAt(a);if(55296<=l&&l<56320){const c=o.charCodeAt(a+1);if(56320<=c&&c<=57343)return(l<<10)+c-56613888}return l}let t="",i=0;const s=String.fromCharCode;let r;for(r=0;r<n.length;r++){const o=e(n,r);o<=127||(t+=n.slice(i,r),o<=2047?(t+=s(192|o>>6),t+=s(128|o&63)):o<=65535?(t+=s(224|o>>12),t+=s(128|o>>6&63),t+=s(128|o&63)):(t+=s(240|o>>18),t+=s(128|o>>12&63),t+=s(128|o>>6&63),t+=s(128|o&63),++r),i=r+1)}return t+=n.slice(i,r)}function bn(n){if(!n.length||!/^\s*[+-]?\d+\s*$/.test(n))return NaN;const e=+n;return Be(e)?e:NaN}function Je(n){return!n.length||/^\s*$|^\s*0[^\d.eE]/.test(n)?NaN:+n}function Lt(n,e){const t={};for(const i in n)if(D(n,i)){const s=n[i];t[i]=e?e(i,s):s}return t}class ae{constructor(e,t){this.state=e,this.factoryOrValue=t}toString(){let{factoryOrValue:e}=this;return S(e)||(this.factoryOrValue=e=e(this.state),this.state=void 0),e}}class Dt{constructor(){this.events=F(),this.eventCount=0}addListenerCore(e,t,i){if(!P(t))throw TypeError("Listener must be a function");const s=this.events[e],r={fn:t,once:i};return s?M(s)?s.push(r):this.events[e]=[s,r]:(this.events[e]=r,this.eventCount++),this}removeListenerCore(e,t,i){const s=this.events[e];if(!s)return this;if(M(s)){for(let r=s.length-1;r>=0;r--)if(i(s[r],t)){s.splice(r,1),s.length?s.length===1&&(this.events[e]=s[0]):this.removeEvent(e);break}}else i(s,t)&&this.removeEvent(e);return this}removeEvent(e){--this.eventCount===0?this.events=F():delete this.events[e]}on(e,t){return this.addListenerCore(e,t,!1)}once(e,t){return this.addListenerCore(e,t,!0)}removeListener(e,t){if(!P(t))throw TypeError("Listener must be a function");return this.removeListenerCore(e,t,(i,s)=>i.fn===s)}removeAllListeners(e){return arguments.length?this.events[e]&&this.removeEvent(e):(this.events=F(),this.eventCount=0),this}listeners(e){const t=this.events[e];if(!t)return[];if(!M(t))return[t.fn];const i=t.length,s=new Array(i);for(let r=0;r<i;r++)s[r]=t[r].fn;return s}listenerCount(e){const t=this.events[e];return t?M(t)?t.length:1:0}eventNames(){const e=[];if(this.eventCount===0)return e;const t=this.events;for(const i in t)e.push(i);return P(Object.getOwnPropertySymbols)?e.concat(Object.getOwnPropertySymbols(t)):e}emit(e,t,i,s,r,...o){let a=this.events[e];if(!a)return!1;let l,c;M(a)?(a=a.slice(),[l,c]=[a[0],a.length]):[l,c]=[a,1];const f=arguments.length-1;for(let u=0;;){switch(l.once&&this.removeListenerCore(e,l,(g,d)=>g===d),f){case 0:l.fn.call(this);break;case 1:l.fn.call(this,t);break;case 2:l.fn.call(this,t,i);break;case 3:l.fn.call(this,t,i,s);break;case 4:l.fn.call(this,t,i,s,r);break;default:const g=new Array(f);for(let d=0;d<f;d++)g[d]=arguments[d+1];l.fn.apply(this,g);break}if(++u>=c)break;l=a[u]}return!0}}const Oe=Dt.prototype;Oe.addListener=Oe.on,Oe.off=Oe.removeListener;var Ge;(function(n){n[n.No=0]="No",n[n.Should=1]="Should",n[n.Force=2]="Force"})(Ge||(Ge={})),h.SettingType=void 0,(function(n){n[n.Boolean=0]="Boolean",n[n.String=1]="String",n[n.Int=2]="Int",n[n.Double=3]="Double"})(h.SettingType||(h.SettingType={})),h.UserComparator=void 0,(function(n){n[n.TextIsOneOf=0]="TextIsOneOf",n[n.TextIsNotOneOf=1]="TextIsNotOneOf",n[n.TextContainsAnyOf=2]="TextContainsAnyOf",n[n.TextNotContainsAnyOf=3]="TextNotContainsAnyOf",n[n.SemVerIsOneOf=4]="SemVerIsOneOf",n[n.SemVerIsNotOneOf=5]="SemVerIsNotOneOf",n[n.SemVerLess=6]="SemVerLess",n[n.SemVerLessOrEquals=7]="SemVerLessOrEquals",n[n.SemVerGreater=8]="SemVerGreater",n[n.SemVerGreaterOrEquals=9]="SemVerGreaterOrEquals",n[n.NumberEquals=10]="NumberEquals",n[n.NumberNotEquals=11]="NumberNotEquals",n[n.NumberLess=12]="NumberLess",n[n.NumberLessOrEquals=13]="NumberLessOrEquals",n[n.NumberGreater=14]="NumberGreater",n[n.NumberGreaterOrEquals=15]="NumberGreaterOrEquals",n[n.SensitiveTextIsOneOf=16]="SensitiveTextIsOneOf",n[n.SensitiveTextIsNotOneOf=17]="SensitiveTextIsNotOneOf",n[n.DateTimeBefore=18]="DateTimeBefore",n[n.DateTimeAfter=19]="DateTimeAfter",n[n.SensitiveTextEquals=20]="SensitiveTextEquals",n[n.SensitiveTextNotEquals=21]="SensitiveTextNotEquals",n[n.SensitiveTextStartsWithAnyOf=22]="SensitiveTextStartsWithAnyOf",n[n.SensitiveTextNotStartsWithAnyOf=23]="SensitiveTextNotStartsWithAnyOf",n[n.SensitiveTextEndsWithAnyOf=24]="SensitiveTextEndsWithAnyOf",n[n.SensitiveTextNotEndsWithAnyOf=25]="SensitiveTextNotEndsWithAnyOf",n[n.SensitiveArrayContainsAnyOf=26]="SensitiveArrayContainsAnyOf",n[n.SensitiveArrayNotContainsAnyOf=27]="SensitiveArrayNotContainsAnyOf",n[n.TextEquals=28]="TextEquals",n[n.TextNotEquals=29]="TextNotEquals",n[n.TextStartsWithAnyOf=30]="TextStartsWithAnyOf",n[n.TextNotStartsWithAnyOf=31]="TextNotStartsWithAnyOf",n[n.TextEndsWithAnyOf=32]="TextEndsWithAnyOf",n[n.TextNotEndsWithAnyOf=33]="TextNotEndsWithAnyOf",n[n.ArrayContainsAnyOf=34]="ArrayContainsAnyOf",n[n.ArrayNotContainsAnyOf=35]="ArrayNotContainsAnyOf"})(h.UserComparator||(h.UserComparator={})),h.PrerequisiteFlagComparator=void 0,(function(n){n[n.Equals=0]="Equals",n[n.NotEquals=1]="NotEquals"})(h.PrerequisiteFlagComparator||(h.PrerequisiteFlagComparator={})),h.SegmentComparator=void 0,(function(n){n[n.IsIn=0]="IsIn",n[n.IsNotIn=1]="IsNotIn"})(h.SegmentComparator||(h.SegmentComparator={}));const In=Object.freeze(Object.defineProperty({__proto__:null,get PrerequisiteFlagComparator(){return h.PrerequisiteFlagComparator},get RedirectMode(){return Ge},get SegmentComparator(){return h.SegmentComparator},get SettingType(){return h.SettingType},get UserComparator(){return h.UserComparator}},Symbol.toStringTag,{value:"Module"}));class b{static contentEquals(e,t){return e.httpETag&&t.httpETag?e.httpETag===t.httpETag:e.configJson===t.configJson}constructor(e,t,i,s){this.configJson=e,this.config=t,this.timestamp=i,this.httpETag=s}with(e){return new b(this.configJson,this.config,e,this.httpETag)}get isEmpty(){return!this.config}isExpired(e){return this===b.empty||this.timestamp+e<b.generateTimestamp()}static generateTimestamp(){return new Date().getTime()}static serialize(e){var t,i;return e.timestamp+`
|
|
5
5
|
`+((t=e.httpETag)!==null&&t!==void 0?t:"")+`
|
|
6
6
|
`+((i=e.configJson)!==null&&i!==void 0?i:"")}static deserialize(e){const t=Array(2);let i=0;for(let f=0;f<t.length;f++){if(i=e.indexOf(`
|
|
7
|
-
`,i),i<0)throw Error("Number of values is fewer than expected.");t[f]=i++}let s=t[0],r=e.substring(0,s);const o=parseInt(r);if(isNaN(o))throw Error("Invalid fetch time: "+r);i=s+1,s=t[1],r=e.substring(i,s);const a=r.length>0?r:void 0;i=s+1,r=e.substring(i);let l,c;return r.length>0&&(l=Ye(r),c=r),new b(c,l,o,a)}}b.serializationFormatVersion="v2",b.empty=new b(void 0,void 0,0,void 0);function V(n){return n?new Date(n.timestamp):void 0}function Ye(n){Y(n,"configJson",!0);const e=JSON.parse(n);return Qe(e)}function Qe(n){var e;wn(n,["$"]);const t=n.f;if(t){const i=(e=n.p)===null||e===void 0?void 0:e.s,s=n.s;for(const r in t)if(D(t,r)){const o=t[r];o._configJsonSalt=i,o._configSegments=s}}return n}function Xe(n){const e=Object.create(Ze);return e.t=-1,e.v=n,e}const Ze=Object.create(null);Ze.toString=function(){return Object.prototype.toString.call(this)};function wn(n,e){n==null&&tt(e),k(n,e),p(n,"p",e,Rn),p(n,"s",e,Nn),p(n,"f",e,Ln)}function Rn(n,e){k(n,e),p(n,"r",e,z),p(n,"u",e,x),p(n,"s",e,x)}function Nn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,Fn)}function Fn(n,e){k(n,e),p(n,"n",e,x,!0),p(n,"r",e,Mn)}function Ln(n,e){k(n,e);for(const t in n)D(n,t)&&p(n,t,e,Dn,!0)}function Dn(n,e){k(n,e),p(n,"t",e,z,!0),p(n,"a",e,x),p(n,"r",e,kn),p(n,"p",e,$t),et(n,e)}function kn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,$n)}function $n(n,e){k(n,e),p(n,"c",e,Un),p(n,"s",e,et),p(n,"p",e,$t)}function Un(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,Pn)}function Mn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,kt)}function Pn(n,e){k(n,e),p(n,"u",e,kt),p(n,"p",e,qn),p(n,"s",e,Hn)}function kt(n,e){k(n,e),p(n,"a",e,x,!0),p(n,"c",e,z,!0),p(n,"s",e,x),p(n,"d",e,Mt),p(n,"l",e,_n)}function _n(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,x)}function qn(n,e){k(n,e),p(n,"f",e,x,!0),p(n,"c",e,z,!0),p(n,"v",e,Ut,!0)}function Hn(n,e){k(n,e),p(n,"s",e,z,!0),p(n,"c",e,z,!0)}function $t(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,xn)}function xn(n,e){k(n,e),p(n,"p",e,z,!0),et(n,e)}function et(n,e){k(n,e),p(n,"v",e,Ut,!0),p(n,"i",e,x)}function Ut(n,e){k(n,e),p(n,"b",e,jn),p(n,"s",e,x),p(n,"i",e,z),p(n,"d",e,Mt)}function te(n,e,t,i){const s=n[e];t.push(`[${e}]`),s==null&&tt(t),i(s,t),t.pop()}function p(n,e,t,i,s){const r=n[e];t.push(`.${e}`),r==null?s&&tt(t):i(r,t),t.pop()}function ne(n,e){M(n)||ie(e)}function k(n,e){Se(n)||ie(e),bt(n,Ze)}function jn(n,e){Ve(n)||ie(e)}function x(n,e){S(n)||ie(e)}function z(n,e){Be(n)||ie(e)}function Mt(n,e){W(n)||ie(e)}function tt(n){throw TypeError(`Invalid config JSON content. Missing required value at ${n.join("")}`)}function ie(n){throw TypeError(`Invalid config JSON content. Type mismatch at ${n.join("")}`)}function Vn(n){return h.SettingType[n]}function nt(n){const e=n.t;if(Ke(e,0,3)||e===-1&&Kn(n))return e;I("Setting type is invalid.")}function it(n){switch(typeof n){case"boolean":return 0;case"string":return 1;case"number":return 3}}function Bn(n,e){switch(e){case 0:return Ve(n);case 1:return S(n);case 2:case 3:return W(n);default:return!1}}function st(n){return it(n)!==void 0}function Kn(n){var e,t;return!(!((e=n.r)===null||e===void 0)&&e.length)&&!(!((t=n.p)===null||t===void 0)&&t.length)}function rt(n,e){const t=n.s,i=n.p;if(t!=null){if(i==null)return!1}else if(i?.length)return!0;e||I("Targeting rule THEN part is missing or invalid.")}function Wn(n){let e,t;return t=n.u,t!=null&&(e="u"),t=n.p,t!=null&&(e=e?!1:"p"),t=n.s,t!=null&&(e=e?!1:"s"),e||I("Condition is missing or invalid."),e}function q(n,e,t){switch(e){case 0:{const i=n.b;if(i!=null)return i;break}case 1:{const i=n.s;if(i!=null)return i;break}case 2:{const i=n.i;if(i!=null)return i;break}case 3:{const i=n.d;if(i!=null)return i;break}case-1:if(st(n))return n;default:t||I(n===null?"Setting value is null.":n===void 0?"Setting value is undefined.":`Setting value '${L(n)}' is of an unsupported type (${typeof n}).`);return}t||I("Setting value is missing or invalid.")}function I(n){throw new le(n)}class le extends Error{constructor(e){super(e),this.message=e,this.name=le.name,je(this,le)}}class Pt{constructor(){this.cachedConfig=b.empty}set(e,t){this.cachedConfig=t}get(e){return this.cachedConfig}getInMemory(){return this.cachedConfig}}class Ce{constructor(e,t){this.cache=e,this.logger=t,this.cachedConfig=b.empty,this.cachedSerializedConfig=void 0}async set(e,t){try{if(!t.isEmpty)this.cachedSerializedConfig=b.serialize(t),this.cachedConfig=t;else{this.cachedSerializedConfig=void 0,this.cachedConfig=t;return}await this.cache.set(e,this.cachedSerializedConfig)}catch(i){this.logger.configServiceCacheWriteError(i)}}updateCachedConfig(e){if(e==null||e===this.cachedSerializedConfig)return this.cachedConfig;const t=b.deserialize(e),i=!b.contentEquals(t,this.cachedConfig);return this.cachedConfig=t,this.cachedSerializedConfig=e,i?[this.cachedConfig]:this.cachedConfig}get(e){let t;try{const i=this.cache.get(e);if(Rt(i))return(async s=>{let r;try{r=this.updateCachedConfig(await s)}catch(o){r=this.cachedConfig,this.logger.configServiceCacheReadError(o)}return r})(i);t=this.updateCachedConfig(i)}catch(i){t=this.cachedConfig,this.logger.configServiceCacheReadError(i)}return t}getInMemory(){return this.cachedConfig}}h.LogLevel=void 0,function(n){n[n.Debug=4]="Debug",n[n.Info=3]="Info",n[n.Warn=2]="Warn",n[n.Error=1]="Error",n[n.Off=-1]="Off"}(h.LogLevel||(h.LogLevel={}));function _t(n){return h.LogLevel[n]}class m{static from(...e){return(t,...i)=>new m(t,e,i)}constructor(e,t,i){this.strings=e,this.argNames=t,this.argValues=i,this.cachedDefaultFormattedMessage=void 0}get defaultFormattedMessage(){let e=this.cachedDefaultFormattedMessage;if(!S(e)){e="";const{strings:t,argValues:i}=this;let s=0;for(;s<t.length-1;s++)e+=t[s],e+=L(i[s]);e+=t[s],this.cachedDefaultFormattedMessage=e}return e}toString(){return this.defaultFormattedMessage}}function B(n){var e;return S(n)?n:(e=n.cachedDefaultFormattedMessage)!==null&&e!==void 0?e:new ae(n,t=>t.defaultFormattedMessage)}class zn{get level(){var e;return(e=this.logger.level)!==null&&e!==void 0?e:2}get eol(){var e;return(e=this.logger.eol)!==null&&e!==void 0?e:`
|
|
7
|
+
`,i),i<0)throw Error("Number of values is fewer than expected.");t[f]=i++}let s=t[0],r=e.substring(0,s);const o=parseInt(r);if(isNaN(o))throw Error("Invalid fetch time: "+r);i=s+1,s=t[1],r=e.substring(i,s);const a=r.length>0?r:void 0;i=s+1,r=e.substring(i);let l,c;return r.length>0&&(l=Ye(r),c=r),new b(c,l,o,a)}}b.serializationFormatVersion="v2",b.empty=new b(void 0,void 0,0,void 0);function V(n){return n?new Date(n.timestamp):void 0}function Ye(n){Y(n,"configJson",!0);const e=JSON.parse(n);return Qe(e)}function Qe(n){var e;wn(n,["$"]);const t=n.f;if(t){const i=(e=n.p)===null||e===void 0?void 0:e.s,s=n.s;for(const r in t)if(D(t,r)){const o=t[r];o._configJsonSalt=i,o._configSegments=s}}return n}function Xe(n){const e=Object.create(Ze);return e.t=-1,e.v=n,e}const Ze=Object.create(null);Ze.toString=function(){return Object.prototype.toString.call(this)};function wn(n,e){n==null&&tt(e),k(n,e),p(n,"p",e,Rn),p(n,"s",e,Nn),p(n,"f",e,Ln)}function Rn(n,e){k(n,e),p(n,"r",e,z),p(n,"u",e,x),p(n,"s",e,x)}function Nn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,Fn)}function Fn(n,e){k(n,e),p(n,"n",e,x,!0),p(n,"r",e,Mn)}function Ln(n,e){k(n,e);for(const t in n)D(n,t)&&p(n,t,e,Dn,!0)}function Dn(n,e){k(n,e),p(n,"t",e,z,!0),p(n,"a",e,x),p(n,"r",e,kn),p(n,"p",e,$t),et(n,e)}function kn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,$n)}function $n(n,e){k(n,e),p(n,"c",e,Un),p(n,"s",e,et),p(n,"p",e,$t)}function Un(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,Pn)}function Mn(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,kt)}function Pn(n,e){k(n,e),p(n,"u",e,kt),p(n,"p",e,qn),p(n,"s",e,Hn)}function kt(n,e){k(n,e),p(n,"a",e,x,!0),p(n,"c",e,z,!0),p(n,"s",e,x),p(n,"d",e,Mt),p(n,"l",e,_n)}function _n(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,x)}function qn(n,e){k(n,e),p(n,"f",e,x,!0),p(n,"c",e,z,!0),p(n,"v",e,Ut,!0)}function Hn(n,e){k(n,e),p(n,"s",e,z,!0),p(n,"c",e,z,!0)}function $t(n,e){ne(n,e);for(let t=0;t<n.length;t++)te(n,t,e,xn)}function xn(n,e){k(n,e),p(n,"p",e,z,!0),et(n,e)}function et(n,e){k(n,e),p(n,"v",e,Ut,!0),p(n,"i",e,x)}function Ut(n,e){k(n,e),p(n,"b",e,jn),p(n,"s",e,x),p(n,"i",e,z),p(n,"d",e,Mt)}function te(n,e,t,i){const s=n[e];t.push(`[${e}]`),s==null&&tt(t),i(s,t),t.pop()}function p(n,e,t,i,s){const r=n[e];t.push(`.${e}`),r==null?s&&tt(t):i(r,t),t.pop()}function ne(n,e){M(n)||ie(e)}function k(n,e){Se(n)||ie(e),bt(n,Ze)}function jn(n,e){Ve(n)||ie(e)}function x(n,e){S(n)||ie(e)}function z(n,e){Be(n)||ie(e)}function Mt(n,e){W(n)||ie(e)}function tt(n){throw TypeError(`Invalid config JSON content. Missing required value at ${n.join("")}`)}function ie(n){throw TypeError(`Invalid config JSON content. Type mismatch at ${n.join("")}`)}function Vn(n){return h.SettingType[n]}function nt(n){const e=n.t;if(Ke(e,0,3)||e===-1&&Kn(n))return e;I("Setting type is invalid.")}function it(n){switch(typeof n){case"boolean":return 0;case"string":return 1;case"number":return 3}}function Bn(n,e){switch(e){case 0:return Ve(n);case 1:return S(n);case 2:case 3:return W(n);default:return!1}}function st(n){return it(n)!==void 0}function Kn(n){var e,t;return!(!((e=n.r)===null||e===void 0)&&e.length)&&!(!((t=n.p)===null||t===void 0)&&t.length)}function rt(n,e){const t=n.s,i=n.p;if(t!=null){if(i==null)return!1}else if(i?.length)return!0;e||I("Targeting rule THEN part is missing or invalid.")}function Wn(n){let e,t;return t=n.u,t!=null&&(e="u"),t=n.p,t!=null&&(e=e?!1:"p"),t=n.s,t!=null&&(e=e?!1:"s"),e||I("Condition is missing or invalid."),e}function q(n,e,t){switch(e){case 0:{const i=n.b;if(i!=null)return i;break}case 1:{const i=n.s;if(i!=null)return i;break}case 2:{const i=n.i;if(i!=null)return i;break}case 3:{const i=n.d;if(i!=null)return i;break}case-1:if(st(n))return n;default:t||I(n===null?"Setting value is null.":n===void 0?"Setting value is undefined.":`Setting value '${L(n)}' is of an unsupported type (${typeof n}).`);return}t||I("Setting value is missing or invalid.")}function I(n){throw new le(n)}class le extends Error{constructor(e){super(e),this.message=e,this.name=le.name,je(this,le)}}class Pt{constructor(){this.cachedConfig=b.empty}set(e,t){this.cachedConfig=t}get(e){return this.cachedConfig}getInMemory(){return this.cachedConfig}}class Ce{constructor(e,t){this.cache=e,this.logger=t,this.cachedConfig=b.empty,this.cachedSerializedConfig=void 0}async set(e,t){try{if(!t.isEmpty)this.cachedSerializedConfig=b.serialize(t),this.cachedConfig=t;else{this.cachedSerializedConfig=void 0,this.cachedConfig=t;return}await this.cache.set(e,this.cachedSerializedConfig)}catch(i){this.logger.configServiceCacheWriteError(i)}}updateCachedConfig(e){if(e==null||e===this.cachedSerializedConfig)return this.cachedConfig;const t=b.deserialize(e),i=!b.contentEquals(t,this.cachedConfig);return this.cachedConfig=t,this.cachedSerializedConfig=e,i?[this.cachedConfig]:this.cachedConfig}get(e){let t;try{const i=this.cache.get(e);if(Rt(i))return(async s=>{let r;try{r=this.updateCachedConfig(await s)}catch(o){r=this.cachedConfig,this.logger.configServiceCacheReadError(o)}return r})(i);t=this.updateCachedConfig(i)}catch(i){t=this.cachedConfig,this.logger.configServiceCacheReadError(i)}return t}getInMemory(){return this.cachedConfig}}h.LogLevel=void 0,(function(n){n[n.Debug=4]="Debug",n[n.Info=3]="Info",n[n.Warn=2]="Warn",n[n.Error=1]="Error",n[n.Off=-1]="Off"})(h.LogLevel||(h.LogLevel={}));function _t(n){return h.LogLevel[n]}class m{static from(...e){return(t,...i)=>new m(t,e,i)}constructor(e,t,i){this.strings=e,this.argNames=t,this.argValues=i,this.cachedDefaultFormattedMessage=void 0}get defaultFormattedMessage(){let e=this.cachedDefaultFormattedMessage;if(!S(e)){e="";const{strings:t,argValues:i}=this;let s=0;for(;s<t.length-1;s++)e+=t[s],e+=L(i[s]);e+=t[s],this.cachedDefaultFormattedMessage=e}return e}toString(){return this.defaultFormattedMessage}}function B(n){var e;return S(n)?n:(e=n.cachedDefaultFormattedMessage)!==null&&e!==void 0?e:new ae(n,t=>t.defaultFormattedMessage)}class zn{get level(){var e;return(e=this.logger.level)!==null&&e!==void 0?e:2}get eol(){var e;return(e=this.logger.eol)!==null&&e!==void 0?e:`
|
|
8
8
|
`}constructor(e,t,i){this.logger=e,this.filter=t,this.hooks=i}isEnabled(e){return this.level>=e}log(e,t,i,s){var r;return this.isEnabled(e)&&(!this.filter||this.filter(e,t,i,s))&&this.logger.log(e,t,i,s),e===1&&((r=this.hooks)===null||r===void 0||r.emit("clientError",B(i),s)),i}debug(e,t){this.log(4,0,e,t)}configJsonIsNotPresent(e){return this.log(1,1e3,m.from("DEFAULT_RETURN_VALUE")`Config JSON is not present. Returning ${e}.`)}configJsonIsNotPresentSingle(e,t,i){return this.log(1,1e3,m.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")`Config JSON is not present when evaluating setting '${e}'. Returning the \`${t}\` parameter that you specified in your application: '${i}'.`)}settingEvaluationFailedDueToMissingKey(e,t,i,s){return this.log(1,1001,m.from("KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE","AVAILABLE_KEYS")`Failed to evaluate setting '${e}' (the key was not found in config JSON). Returning the \`${t}\` parameter that you specified in your application: '${i}'. Available keys: [${s}].`)}settingEvaluationError(e,t,i){return this.log(1,1002,m.from("METHOD_NAME","DEFAULT_RETURN_VALUE")`Error occurred in the \`${e}\` method. Returning ${t}.`,i)}settingEvaluationErrorSingle(e,t,i,s,r){return this.log(1,1002,m.from("METHOD_NAME","KEY","DEFAULT_PARAM_NAME","DEFAULT_PARAM_VALUE")`Error occurred in the \`${e}\` method while evaluating setting '${t}'. Returning the \`${i}\` parameter that you specified in your application: '${s}'.`,r)}clientMethodError(e,t){return this.log(1,1003,m.from("METHOD_NAME")`Error occurred in the \`${e}\` method.`,t)}fetchFailedDueToInvalidSdkKey(e,t){return e=Ht(e),this.log(1,1100,t==null?m.from("SDK_KEY")`Your SDK Key seems to be wrong: '${e}'. You can find the valid SDK Key at https://app.configcat.com/sdkkey`:m.from("SDK_KEY","RAY_ID")`Your SDK Key seems to be wrong: '${e}'. You can find the valid SDK Key at https://app.configcat.com/sdkkey (Ray ID: ${t})`)}fetchFailedDueToUnexpectedHttpResponse(e,t,i){return this.log(1,1101,i==null?m.from("STATUS_CODE","REASON_PHRASE")`Unexpected HTTP response was received while trying to fetch config JSON: ${e} ${t}`:m.from("STATUS_CODE","REASON_PHRASE","RAY_ID")`Unexpected HTTP response was received while trying to fetch config JSON: ${e} ${t} (Ray ID: ${i})`)}fetchFailedDueToRequestTimeout(e,t){return this.log(1,1102,m.from("TIMEOUT")`Request timed out while trying to fetch config JSON. Timeout value: ${e}ms`,t)}fetchFailedDueToUnexpectedError(e){return this.log(1,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)}fetchFailedDueToRedirectLoop(e){return this.log(1,1104,e==null?"Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/":m.from("RAY_ID")`Redirection loop encountered while trying to fetch config JSON. Please contact us at https://configcat.com/support/ (Ray ID: ${e})`)}fetchReceived200WithInvalidBody(e,t){return this.log(1,1105,e==null?"Fetching config JSON was successful but the HTTP response content was invalid.":m.from("RAY_ID")`Fetching config JSON was successful but the HTTP response content was invalid. (Ray ID: ${e})`,t)}fetchReceived304WhenLocalCacheIsEmpty(e,t,i){return this.log(1,1106,i==null?m.from("STATUS_CODE","REASON_PHRASE")`Unexpected HTTP response was received when no config JSON is cached locally: ${e} ${t}`:m.from("STATUS_CODE","REASON_PHRASE","RAY_ID")`Unexpected HTTP response was received when no config JSON is cached locally: ${e} ${t} (Ray ID: ${i})`)}autoPollConfigServiceErrorDuringPolling(e){return this.log(1,1200,"Error occurred during auto polling.",e)}settingForVariationIdIsNotPresent(e){return this.log(1,2011,m.from("VARIATION_ID")`Could not find the setting for the specified variation ID: '${e}'.`)}configServiceCacheReadError(e){return this.log(1,2200,"Error occurred while reading the cache.",e)}configServiceCacheWriteError(e){return this.log(1,2201,"Error occurred while writing the cache.",e)}clientIsAlreadyCreated(e){return e=Ht(e),this.log(2,3e3,m.from("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}'.`)}userObjectIsMissing(e){return this.log(2,3001,m.from("KEY")`Cannot evaluate targeting rules and % options for setting '${e}' (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/`)}dataGovernanceIsOutOfSync(){return this.log(2,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/")}userObjectAttributeIsMissingPercentage(e,t){return this.log(2,3003,m.from("KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")`Cannot evaluate % options for setting '${e}' (the User.${t} attribute is missing). You should set the User.${t} attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`)}userObjectAttributeIsMissingCondition(e,t,i){return this.log(2,3003,m.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (the User.${i} attribute is missing). You should set the User.${i} attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/`)}userObjectAttributeIsInvalid(e,t,i,s){return this.log(2,3004,m.from("CONDITION","KEY","REASON","ATTRIBUTE_NAME")`Cannot evaluate condition (${e}) for setting '${t}' (${i}). Please check the User.${s} attribute and make sure that its value corresponds to the comparison operator.`)}userObjectAttributeIsAutoConverted(e,t,i,s){return this.log(2,3005,m.from("CONDITION","KEY","ATTRIBUTE_NAME","ATTRIBUTE_VALUE")`Evaluation of condition (${e}) for setting '${t}' may not produce the expected result (the User.${i} attribute is not a string value, thus it was automatically converted to the string value '${s}'). Please make sure that using a non-string value was intended.`)}configServiceCannotInitiateHttpCalls(){return this.log(2,3200,"Client is in offline mode, it cannot initiate HTTP calls.")}configServiceMethodHasNoEffectDueToDisposedClient(e){return this.log(2,3201,m.from("METHOD_NAME")`The client object is already disposed, thus \`${e}()\` has no effect.`)}configServiceMethodHasNoEffectDueToOverrideBehavior(e,t){return this.log(2,3202,m.from("OVERRIDE_BEHAVIOR","METHOD_NAME")`Client is configured to use the \`${e}\` override behavior, thus \`${t}()\` has no effect.`)}settingEvaluated(e){return this.log(3,5e3,m.from("EVALUATE_LOG")`${e}`)}configServiceStatusChanged(e){return this.log(3,5200,m.from("MODE")`Switched to ${e.toUpperCase()} mode.`)}}class qt{constructor(e=2,t=`
|
|
9
|
-
`){this.level=e,this.eol=t,this.SOURCE="ConfigCat"}log(e,t,i,s){const[r,o]=e===4?[console.info,"DEBUG"]:e===3?[console.info,"INFO"]:e===2?[console.warn,"WARN"]:e===1?[console.error,"ERROR"]:[console.log,_t(e).toUpperCase()],a=s!==void 0?this.eol+G(s,!0):"";r(`${this.SOURCE} - ${o} - [${t}] ${i}${a}`)}}function Ht(n){return n.substring(0,n.length-6).replace(/[^/]/g,"*")+n.substring(n.length-6)}var xt;(function(n){n[n.Fetched=0]="Fetched",n[n.NotModified=1]="NotModified",n[n.Errored=2]="Errored"})(xt||(xt={}));function Jn(n){return{status:0,config:n,errorCode:0}}function Gn(n){return{status:1,config:n,errorCode:0}}function ce(n,e,t,i){return{status:2,config:n,errorCode:e,errorMessage:t,errorException:i}}class jt{constructor(e,t,i,s){this.url=e,this.lastETag=t,this.headers=i,this.timeoutMs=s}}class ot{constructor(e,t,i,s){this.statusCode=e,this.reasonPhrase=t,this.body=s,this.eTag=void 0,this.rayId=void 0;let r,o;for(const[a,l]of i){const c=a.toLowerCase();if(r==null&&c==="etag"){if(this.eTag=r=l,o!=null)break}else if(o==null&&c==="cf-ray"&&(this.rayId=o=l,r!=null))break}}}class H extends Error{constructor(e,...t){super(((i,s)=>{switch(i){case"abort":return"Request was aborted.";case"timeout":const[r]=s;return`Request timed out. Timeout value: ${r}ms`;case"failure":const[o]=s,a="Request failed due to a network or protocol error.";return o?a+" "+(o instanceof Error?o.message:L(o)):a}})(e,t)),this.cause=e,this.name=H.name,je(this,H),this.args=t}}h.RefreshErrorCode=void 0,function(n){n[n.UnexpectedError=-1]="UnexpectedError",n[n.None=0]="None",n[n.LocalOnlyClient=1]="LocalOnlyClient",n[n.OfflineClient=3200]="OfflineClient",n[n.InvalidSdkKey=1100]="InvalidSdkKey",n[n.UnexpectedHttpResponse=1101]="UnexpectedHttpResponse",n[n.HttpRequestTimeout=1102]="HttpRequestTimeout",n[n.HttpRequestFailure=1103]="HttpRequestFailure",n[n.InvalidHttpResponseContent=1105]="InvalidHttpResponseContent",n[n.InvalidHttpResponseWhenLocalCacheIsEmpty=1106]="InvalidHttpResponseWhenLocalCacheIsEmpty"}(h.RefreshErrorCode||(h.RefreshErrorCode={}));function Vt(){return{isSuccess:!0,errorCode:0}}function Te(n,e,t){return{isSuccess:!1,errorCode:n,_errorMessage:e,get errorMessage(){var i;return(i=this._errorMessage)===null||i===void 0?void 0:i.toString()},errorException:t}}function Bt(n){return n.status!==2?Vt():Te(n.errorCode,n.errorMessage,n.errorException)}h.ClientCacheState=void 0,function(n){n[n.NoFlagData=0]="NoFlagData",n[n.HasLocalOverrideFlagDataOnly=1]="HasLocalOverrideFlagDataOnly",n[n.HasCachedFlagDataOnly=2]="HasCachedFlagDataOnly",n[n.HasUpToDateFlagData=3]="HasUpToDateFlagData"}(h.ClientCacheState||(h.ClientCacheState={}));var at;(function(n){n[n.Online=0]="Online",n[n.Offline=1]="Offline",n[n.Disposed=2]="Disposed"})(at||(at={}));function Kt(n){return at[n]}class lt{constructor(e){this.options=e,this.pendingCacheSyncUp=null,this.pendingConfigRefresh=null,this.cacheKey=e.getCacheKey(),this.configFetcher=e.configFetcher,this.requestHeaders=[["User-Agent",e.clientVersion],["X-ConfigCat-UserAgent",e.clientVersion]],this.status=e.offline?1:0}prepareClientForEvents(){var e;const t=(e=this.options.hooks.unwrap())===null||e===void 0?void 0:e.configCatClient,i=t?.initConfigService;P(i)&&i.call(t,this)}dispose(){this.status=2}get disposed(){return this.status===2}async refreshConfigAsync(){const e=await this.syncUpWithCache();if(this.isOffline){if(this.options.cache instanceof Ce)return[Vt(),e];{const t=this.options.logger.configServiceCannotInitiateHttpCalls();return[Te(3200,B(t)),e]}}else{const[t,i]=await this.refreshConfigCoreAsync(e,!0);return[Bt(t),i]}}refreshConfigCoreAsync(e,t){if(this.pendingConfigRefresh)return this.pendingConfigRefresh;const i=(async s=>{const r=await this.fetchAsync(s);return(r.status===0||r.status===1||r.config.timestamp>s.timestamp&&(!r.config.isEmpty||this.options.cache.getInMemory().isEmpty))&&(await this.options.cache.set(this.cacheKey,r.config),s=r.config),this.onConfigFetched(r,t),r.status===0&&this.onConfigChanged(r.config),[r,s]})(e);this.pendingConfigRefresh=i;try{i.finally(()=>this.pendingConfigRefresh=null)}catch(s){throw this.pendingConfigRefresh=null,s}return i}onConfigFetched(e,t){this.options.logger.debug("config fetched"),this.options.hooks.emit("configFetched",Bt(e),t)}onConfigChanged(e){var t;this.options.logger.debug("config changed"),this.options.hooks.emit("configChanged",(t=e.config)!==null&&t!==void 0?t:Qe({}))}async fetchAsync(e){const t=this.options;t.logger.debug("ConfigServiceBase.fetchAsync() called.");let i;try{const[s,r,o]=await this.fetchRequestAsync(e.httpETag);switch(s.statusCode){case 200:return r?(t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was successful. Returning new config."),Jn(new b(s.body,r,b.generateTimestamp(),s.eTag))):(i=t.logger.fetchReceived200WithInvalidBody(s.rayId,o),t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received but the HTTP response content was invalid. Returning null.`),ce(e,1105,B(i),o));case 304:return e.isEmpty?(i=t.logger.fetchReceived304WhenLocalCacheIsEmpty(s.statusCode,s.reasonPhrase,s.rayId),t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received when no config is cached locally. Returning null.`),ce(e,1106,B(i))):(t.logger.debug("ConfigServiceBase.fetchAsync(): content was not modified. Returning last config with updated timestamp."),Gn(e.with(b.generateTimestamp())));case 403:case 404:return i=t.logger.fetchFailedDueToInvalidSdkKey(t.sdkKey,s.rayId),t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."),ce(e.with(b.generateTimestamp()),1100,B(i));default:return i=t.logger.fetchFailedDueToUnexpectedHttpResponse(s.statusCode,s.reasonPhrase,s.rayId),t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),ce(e,1101,B(i))}}catch(s){let r;return[r,i]=s instanceof H&&s.cause==="timeout"?[1102,t.logger.fetchFailedDueToRequestTimeout(s.args[0],s)]:[1103,t.logger.fetchFailedDueToUnexpectedError(s)],t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),ce(e,r,B(i),s)}}async fetchRequestAsync(e,t=2){const i=this.options;i.logger.debug("ConfigServiceBase.fetchRequestAsync() called.");for(let s=0;;s++){i.logger.debug(`ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()${s>0?`, retry ${s}/${t}`:""}.`);const r=new jt(i.getUrl(),e,this.requestHeaders,i.requestTimeoutMs),o=await this.configFetcher.fetchAsync(r);if(o.statusCode!==200)return[o];if(!o.body)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."),[o,void 0,Error("No response body.")];let a;try{a=Ye(o.body)}catch(u){return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."),[o,void 0,u]}const l=a.p;if(!l)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences are missing or invalid."),[o,a];const c=l.u;if(c==null||c===i.baseUrl)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."),[o,a];const f=l.r;if(i.baseUrlOverriden&&f!==2)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."),[o,a];if(i.baseUrl=c,f===0)return[o,a];if(f===1&&i.logger.dataGovernanceIsOutOfSync(),s>=t)return i.logger.fetchFailedDueToRedirectLoop(o.rayId),[o,a]}}get isOfflineExactly(){return this.status===1}get isOffline(){return this.status!==0}goOnline(){}setOnline(){this.status===1?(this.goOnline(),this.status=0,this.options.logger.configServiceStatusChanged(Kt(this.status))):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline")}setOffline(){this.status===0?(this.status=1,this.options.logger.configServiceStatusChanged(Kt(this.status))):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline")}syncUpWithCache(){const{cache:e}=this.options;if(e instanceof Pt)return e.get(this.cacheKey);if(this.pendingCacheSyncUp)return this.pendingCacheSyncUp;const t=e.get(this.cacheKey);if(!Rt(t))return this.onCacheSynced(t);const i=t.then(s=>this.onCacheSynced(s));this.pendingCacheSyncUp=i;try{i.finally(()=>this.pendingCacheSyncUp=null)}catch(s){throw this.pendingCacheSyncUp=null,s}return i}onCacheSynced(e){if(!M(e))return e;const[t]=e;return t.isEmpty||this.onConfigChanged(t),t}async waitForReadyAsync(e){return this.getCacheState(await e)}getReadyPromise(e){return this.waitForReadyAsync(e).then(t=>(this.options.hooks.emit("clientReady",t),t))}}const Yn=500;class Qn extends lt{constructor(e){super(e),this.signalInitialization=()=>{},this.stopToken=new xe,this.pollIntervalMs=e.pollIntervalSeconds*1e3,this.pollExpirationMs=this.pollIntervalMs-Yn,this.prepareClientForEvents();const t=this.syncUpWithCache();if(e.maxInitWaitTimeSeconds!==0){this.initialized=!1;const i=new Promise(s=>this.signalInitialization=s);this.initializationPromise=this.waitForInitializationAsync(i).then(s=>(this.initialized=!0,s))}else this.initialized=!0,this.initializationPromise=Promise.resolve(!1);this.readyPromise=this.getReadyPromise(t),this.startRefreshWorker(t,this.stopToken)}async waitForInitializationAsync(e){if(this.options.maxInitWaitTimeSeconds<0)return await e,!0;const t=new xe,i=await Promise.race([e.then(()=>!0),Ot(this.options.maxInitWaitTimeSeconds*1e3,t).then(()=>!1)]);return t.abort(),i}async waitForReadyAsync(){return await this.initializationPromise,this.getCacheState(this.options.cache.getInMemory())}async getConfigAsync(){this.options.logger.debug("AutoPollConfigService.getConfigAsync() called.");let e=await this.syncUpWithCache();if(!e.isExpired(this.pollIntervalMs))this.signalInitialization();else if(!this.isOffline&&!this.initialized)this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired, waiting for initialization."),await this.initializationPromise,e=this.options.cache.getInMemory();else return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired."),e;return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - returning value from cache."),e}refreshConfigAsync(){return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."),super.refreshConfigAsync()}dispose(){this.options.logger.debug("AutoPollConfigService.dispose() called."),super.dispose(),this.stopToken.aborted||this.stopRefreshWorker()}onConfigFetched(e,t){this.signalInitialization(),super.onConfigFetched(e,t)}goOnline(){this.stopRefreshWorker(),this.stopToken=new xe,this.startRefreshWorker(null,this.stopToken)}async startRefreshWorker(e,t){for(this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called.");!t.aborted;){try{const i=Ct()+this.pollIntervalMs;try{await this.refreshWorkerLogic(e)}catch(r){this.options.logger.autoPollConfigServiceErrorDuringPolling(r)}const s=i-Ct();s>0&&await Ot(s,t)}catch(i){this.options.logger.autoPollConfigServiceErrorDuringPolling(i)}e=null}}stopRefreshWorker(){this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."),this.stopToken.abort()}async refreshWorkerLogic(e){this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() called.");const t=await(e??this.syncUpWithCache());if(t.isExpired(this.pollExpirationMs)&&(e?!this.isOfflineExactly:!this.isOffline)){await this.refreshConfigCoreAsync(t,!1);return}this.signalInitialization()}getCacheState(e){return e.isEmpty?0:e.isExpired(this.pollIntervalMs)?2:3}}class be{on(){return this}once(){return this}removeListener(){return this}removeAllListeners(){return this}listeners(){return[]}listenerCount(){return 0}eventNames(){return[]}emit(){return!1}}const Ie=be.prototype;Ie.addListener=Ie.on,Ie.off=Ie.removeListener,h.OverrideBehaviour=void 0,function(n){n[n.LocalOnly=0]="LocalOnly",n[n.LocalOverRemote=1]="LocalOverRemote",n[n.RemoteOverLocal=2]="RemoteOverLocal"}(h.OverrideBehaviour||(h.OverrideBehaviour={}));function we(n){return h.OverrideBehaviour[n]}class Xn{constructor(e,t){this.initialSettings=Wt(e),this.map=t?e:null}getOverrides(){return this.map?Wt(this.map):this.initialSettings}}function Wt(n){const e={};for(const t in n)D(n,t)&&(e[t]=Xe(n[t]));return e}const Zn="cc-",Re=";str";class ei{get currentValue(){if(!(typeof location>"u"||location===null))return location.search}}let Ne;class ti{constructor(e,t,i){this.watchChanges=!!e,this.paramPrefix=t??Zn,i??(i=Ne??(Ne=new ei)),this.queryStringProvider=i;const s=i.currentValue;this.settings=Jt(s,this.paramPrefix),this.queryString=zt(s)}getOverrides(){if(this.watchChanges){const e=this.queryStringProvider.currentValue,t=zt(e);this.queryString!==t&&(this.settings=Jt(e,this.paramPrefix),this.queryString=t)}return this.settings}}function zt(n){if(n==null)return"";if(S(n))return n;let e="",t="?";for(const i in n){if(!D(n,i))continue;const s=n[i];let r,o;if(!M(s))r=s,o=1;else if(s.length)r=s[0],o=s.length;else continue;for(let a=0;e+=t+encodeURIComponent(i)+"="+encodeURIComponent(r),!(++a>=o);)t="&",r=s[a]}return e}function Jt(n,e){const t={};return S(n)?ii(n,e,t):n!=null&&ni(n,e,t),t}function ni(n,e,t){for(const i in n){if(!D(n,i))continue;const s=n[i];let r,o;if(!M(s))r=s,o=1;else if(s.length)r=s[0],o=s.length;else continue;for(let a=0;Gt(i,r,e,t),!(++a>=o);)r=s[a]}}function ii(n,e,t){if(!n||n.lastIndexOf("?",0)<0)return;const i=n.substring(1).split("&");for(let s of i){s=s.replace(/\+/g," ");const r=s.indexOf("="),o=decodeURIComponent(r>=0?s.substring(0,r):s),a=r>=0?decodeURIComponent(s.substring(r+1)):"";Gt(o,a,e,t)}}function Gt(n,e,t,i){if(!n||n.length<=t.length||n.lastIndexOf(t,0)<0)return;n=n.substring(t.length),n.length>Re.length&&n.indexOf(Re,n.length-Re.length)>=0?n=n.substring(0,n.length-Re.length):e=si(e),i[n]=Xe(e)}function si(n){switch(n.toLowerCase()){case"false":return!1;case"true":return!0;default:const e=Je(n);return isNaN(e)?n:e}}function Yt(n){function e(N,j){var He=N<<j|N>>>32-j;return He}var t,i,s,r=new Array(80),o=1732584193,a=4023233417,l=2562383102,c=271733878,f=3285377520,u,g,d,v,A,O;n=oe(n);var y=n.length,T=new Array;for(i=0;i<y-3;i+=4)s=n.charCodeAt(i)<<24|n.charCodeAt(i+1)<<16|n.charCodeAt(i+2)<<8|n.charCodeAt(i+3),T.push(s);switch(y%4){case 0:i=2147483648;break;case 1:i=n.charCodeAt(y-1)<<24|8388608;break;case 2:i=n.charCodeAt(y-2)<<24|n.charCodeAt(y-1)<<16|32768;break;case 3:i=n.charCodeAt(y-3)<<24|n.charCodeAt(y-2)<<16|n.charCodeAt(y-1)<<8|128;break}for(T.push(i);T.length%16!=14;)T.push(0);for(T.push(y>>>29),T.push(y<<3&4294967295),t=0;t<T.length;t+=16){for(i=0;i<16;i++)r[i]=T[t+i];for(i=16;i<=79;i++)r[i]=e(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);for(u=o,g=a,d=l,v=c,A=f,i=0;i<=19;i++)O=e(u,5)+(g&d|~g&v)+A+r[i]+1518500249&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=20;i<=39;i++)O=e(u,5)+(g^d^v)+A+r[i]+1859775393&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=40;i<=59;i++)O=e(u,5)+(g&d|g&v|d&v)+A+r[i]+2400959708&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=60;i<=79;i++)O=e(u,5)+(g^d^v)+A+r[i]+3395469782&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;o=o+u&4294967295,a=a+g&4294967295,l=l+d&4294967295,c=c+v&4294967295,f=f+A&4294967295}return Qt([o,a,l,c,f])}const ri=Object.create(null);function oi(n){function e(An,On){return An>>>On|An<<32-On}const t="length";var i=Math.pow,s=i(2,32),r,o,a=ri,l=a.h,c=a.k;if(!c){l=[],c=[];for(var f=F(),u=2,g=0;g<64;u++)if(!f[u]){for(r=0;r<313;r+=u)f[r]=u;l[g]=i(u,.5)*s|0,c[g++]=i(u,1/3)*s|0}a.h=l=l.slice(0,8),a.k=c}var d=n[t]*8;n+="";for(var v=[];n[t]%64-56;)n+="\0";for(r=0;r<n[t];r++)o=n.charCodeAt(r),v[r>>2]|=o<<(3-r)%4*8;for(v[v[t]]=d/s|0,v[v[t]]=d,o=0;o<v[t];){var A=v.slice(o,o+=16),O=l;for(l=l.slice(0,8),r=0;r<64;r++){var y=A[r-15],T=A[r-2],N=l[0],j=l[4],He=l[7]+(e(j,6)^e(j,11)^e(j,25))+(j&l[5]^~j&l[6])+c[r]+(A[r]=r<16?A[r]:A[r-16]+(e(y,7)^e(y,18)^y>>>3)+A[r-7]+(e(T,17)^e(T,19)^T>>>10)|0),ji=(e(N,2)^e(N,13)^e(N,22))+(N&l[1]^N&l[2]^l[1]&l[2]);l=[He+ji|0].concat(l),l[4]=l[4]+He|0}for(r=0;r<8;r++)l[r]=l[r]+O[r]|0}return Qt(l,8)}function Qt(n,e){const t="0123456789abcdef";var i="";e??(e=n.length);for(let s=0;s<e;s++)for(let r=3;r>=0;r--){const o=n[s]>>(r<<3)&255;i+=t[o>>4],i+=t[o&15]}return i}const Xt=new be;class ct{constructor(e){this.eventEmitter=e;const t=Object.create(null);t.get=()=>this.configCatClient,t.enumerable=!0,Object.defineProperty(e,"configCatClient",t)}tryDisconnect(){const e=this.eventEmitter;return this.eventEmitter=Xt,e!==Xt}on(e,t){return this.eventEmitter.on(e,t),this}once(e,t){return this.eventEmitter.once(e,t),this}removeListener(e,t){return this.eventEmitter.removeListener(e,t),this}removeAllListeners(e){return this.eventEmitter.removeAllListeners(e),this}listeners(e){return this.eventEmitter.listeners(e)}listenerCount(e){return this.eventEmitter.listenerCount(e)}eventNames(){return this.eventEmitter.eventNames()}emit(e,...t){return this.eventEmitter.emit(e,...t)}}const Fe=ct.prototype;Fe.addListener=Fe.on,Fe.off=Fe.removeListener;class ai extends lt{constructor(e){super(e),this.cacheTimeToLiveMs=e.cacheTimeToLiveSeconds*1e3,this.prepareClientForEvents();const t=this.syncUpWithCache();this.readyPromise=this.getReadyPromise(t)}async getConfigAsync(){this.options.logger.debug("LazyLoadConfigService.getConfigAsync() called.");function e(i,s=""){i.debug(`LazyLoadConfigService.getConfigAsync(): cache is empty or expired${s}.`)}let t=await this.syncUpWithCache();return t.isExpired(this.cacheTimeToLiveMs)?(this.isOffline?e(this.options.logger):(e(this.options.logger,", calling refreshConfigCoreAsync()"),[,t]=await this.refreshConfigCoreAsync(t,!1)),t):(this.options.logger.debug("LazyLoadConfigService.getConfigAsync(): cache is valid, returning from cache."),t)}refreshConfigAsync(){return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."),super.refreshConfigAsync()}getCacheState(e){return e.isEmpty?0:e.isExpired(this.cacheTimeToLiveMs)?2:3}}class li extends lt{constructor(e){super(e),this.prepareClientForEvents();const t=this.syncUpWithCache();this.readyPromise=this.getReadyPromise(t)}getCacheState(e){return e.isEmpty?0:2}async getConfigAsync(){return this.options.logger.debug("ManualPollService.getConfigAsync() called."),await this.syncUpWithCache()}refreshConfigAsync(){return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."),super.refreshConfigAsync()}}const ut="configcat-proxy/";h.PollingMode=void 0,function(n){n[n.AutoPoll=0]="AutoPoll",n[n.LazyLoad=1]="LazyLoad",n[n.ManualPoll=2]="ManualPoll"}(h.PollingMode||(h.PollingMode={})),h.DataGovernance=void 0,function(n){n[n.Global=0]="Global",n[n.EuOnly=1]="EuOnly"}(h.DataGovernance||(h.DataGovernance={}));function ci(n){return h.DataGovernance[n]}class X{constructor(e,t,i,s){var r,o,a,l;this.requestTimeoutMs=3e4,this.dataGovernance=0,this.flagOverrides=null,this.defaultUser=void 0,this.offline=!1,this.sdkKey=e,this.clientVersion=i;const c=(o=(r=t.eventEmitterFactory)===null||r===void 0?void 0:r.call(t))!==null&&o!==void 0?o:new be,f=new ct(c);this.hooks={hooks:f,unwrap(){return this.hooks},emit(O,...y){var T,N;return(N=(T=this.unwrap())===null||T===void 0?void 0:T.emit(O,...y))!==null&&N!==void 0?N:!1}};let u,g,d,v,A;if(s){const O="options";if(s.logFilter!=null&&(u=Ft(s.logFilter,O,".logFilter")),s.logger!=null){const y=F();y.log=!0,g=_(s.logger,O,y,".logger")}if(s.cache!=null){const y=F();y.get=y.set=!0,d=_(s.cache,O,y,".cache")}if(s.configFetcher!=null){const y=F();y.fetchAsync=!0,v=_(s.configFetcher,O,y,".configFetcher")}if(s.requestTimeoutMs!=null&&(this.requestTimeoutMs=Ae(s.requestTimeoutMs,O,"greater than 0",y=>y>0,".requestTimeoutMs")),s.dataGovernance!=null&&(this.dataGovernance=ee(s.dataGovernance,O,"DataGovernance",y=>ci(y)!==void 0,".dataGovernance")),s.baseUrl!=null&&(A=Y(s.baseUrl,O,!0,".baseUrl")),s.flagOverrides!=null){const y=F();y.behaviour=y.dataSource=!1;const T=_(s.flagOverrides,O,y,".flagOverrides");ee(T.behaviour,O,"OverrideBehaviour",j=>we(j)!==void 0,".flagOverrides.behaviour");const N=F();N.getOverrides=!0,_(T.dataSource,O,N,".flagOverrides.dataSource"),this.flagOverrides=T}s.defaultUser!=null&&(this.defaultUser=_(s.defaultUser,O,void 0,".defaultUser")),s.offline!=null&&(this.offline=We(s.offline,O,".offline")),s.setupHooks!=null&&Ft(s.setupHooks,O,".setupHooks")(f)}(this.baseUrlOverriden=A!=null)?this.baseUrl=A:this.baseUrl=this.dataGovernance===1?"https://cdn-eu.configcat.com":"https://cdn-global.configcat.com",this.logger=new zn(g??new qt,u,this.hooks),this.cache=d?new Ce(d,this.logger):(l=(a=t.defaultCacheFactory)===null||a===void 0?void 0:a.call(t,this))!==null&&l!==void 0?l:new Pt,this.configFetcher=v??t.configFetcherFactory(this)}yieldHooks(){var e;const t=this.hooks,i=(e=t.unwrap())!==null&&e!==void 0?e:new ct(new be);return t.hooks=Tt(i),t.unwrap=function(){return this.hooks.deref()},i}getUrl(){const{baseUrl:e}=this;return e+(e.charCodeAt(e.length-1)!==47?"/":"")+"configuration-files/"+this.sdkKey+"/"+X.configFileName+"?sdk="+this.clientVersion}getCacheKey(){return Yt(`${this.sdkKey}_${X.configFileName}_${b.serializationFormatVersion}`)}}X.configFileName="config_v6.json";const Zt="/"+ut,ui=/^https?:\/\/(?:[a-z0-9-]+\.)+configcat\.com\.?(?:[:/]|$)/i;function en(n){if(!ui.test(n))return!1;let e=n.indexOf("?");return e=n.lastIndexOf(Zt,(e>=0?e:n.length)-Zt.length),e<0}class fi extends X{constructor(e,t,i){if(super(e,t,t.sdkType+"/a-"+t.sdkVersion,i),this.pollIntervalSeconds=60,this.maxInitWaitTimeSeconds=5,i){const s="options";i.pollIntervalSeconds!=null&&(this.pollIntervalSeconds=Ae(i.pollIntervalSeconds,s,"between 1 and 2147483",l=>It(l,1,2147483),".pollIntervalSeconds")),i.maxInitWaitTimeSeconds!=null&&(this.maxInitWaitTimeSeconds=Ae(i.maxInitWaitTimeSeconds,s,"less than or equal to 2147483",a=>a<=2147483,".maxInitWaitTimeSeconds"))}}createConfigService(){return new Qn(this)}}class hi extends X{constructor(e,t,i){super(e,t,t.sdkType+"/m-"+t.sdkVersion,i)}createConfigService(){return new li(this)}}class gi extends X{constructor(e,t,i){if(super(e,t,t.sdkType+"/l-"+t.sdkVersion,i),this.cacheTimeToLiveSeconds=60,i){const s="options";i.cacheTimeToLiveSeconds!=null&&(this.cacheTimeToLiveSeconds=Ae(i.cacheTimeToLiveSeconds,s,"between 1 and 2147483647",a=>It(a,1,2147483647),".cacheTimeToLiveSeconds")),i.cacheTimeToLiveSeconds!=null&&(this.cacheTimeToLiveSeconds=i.cacheTimeToLiveSeconds)}}createConfigService(){return new ai(this)}}const tn="<invalid value>",di="<invalid name>",ft="<invalid operator>",nn="<invalid reference>",vi=10;class sn{constructor(e){this.eol=e,this.log="",this.indent=""}resetIndent(){return this.indent="",this}increaseIndent(){return this.indent+=" ",this}decreaseIndent(){return this.indent=this.indent.slice(0,-2),this}newLine(e){return this.log+=this.eol+this.indent+(e??""),this}append(e){return this.log+=e,this}toString(){return this.log}appendUserConditionCore(e,t,i){return this.append(`User.${e} ${ht(t)} '${i??tn}'`)}appendUserConditionString(e,t,i,s){return i==null?this.appendUserConditionCore(e,t):this.appendUserConditionCore(e,t,s?"<hashed value>":i)}appendUserConditionStringList(e,t,i,s){if(i==null)return this.appendUserConditionCore(e,t);const r="value",o="values",a=ht(t);if(s)return this.append(`User.${e} ${a} [<${i.length} hashed ${i.length===1?r:o}>]`);{const l=ze(i,vi,c=>`, ... <${c} more ${c===1?r:o}>`);return this.append(`User.${e} ${a} [${l}]`)}}appendUserConditionNumber(e,t,i,s){if(i==null)return this.appendUserConditionCore(e,t);const r=ht(t);let o;return s&&!isNaN(o=new Date(i*1e3))?this.append(`User.${e} ${r} '${i}' (${o.toISOString()} UTC)`):this.append(`User.${e} ${r} '${i}'`)}appendUserCondition(e){const t=e.a,i=e.c;switch(i){case 0:case 1:case 2:case 3:case 4:case 5:case 30:case 31:case 32:case 33:case 34:case 35:return this.appendUserConditionStringList(t,i,e.l,!1);case 6:case 7:case 8:case 9:case 28:case 29:return this.appendUserConditionString(t,i,e.s,!1);case 10:case 11:case 12:case 13:case 14:case 15:return this.appendUserConditionNumber(t,i,e.d);case 16:case 17:case 22:case 23:case 24:case 25:case 26:case 27:return this.appendUserConditionStringList(t,i,e.l,!0);case 18:case 19:return this.appendUserConditionNumber(t,i,e.d,!0);case 20:case 21:return this.appendUserConditionString(t,i,e.s,!0);default:{const s=yi(e);return S(s)?this.appendUserConditionString(t,i,s,!1):W(s)?this.appendUserConditionNumber(t,i,s):s?this.appendUserConditionCore(t,i):this.appendUserConditionStringList(t,i,s,!1)}}}appendPrerequisiteFlagCondition(e,t){const i=D(t,e.f)?e.f:nn,s=e.c,r=on(e.v);return this.append(`Flag '${i}' ${pi(s)} '${ue(r)}'`)}appendSegmentCondition(e,t){const i=e.s;let s;t&&Ke(i,0,t.length-1)?(s=t[i].n,s.length||(s=di)):s=nn;const r=e.c;return this.append(`User ${rn(r)} '${s}'`)}appendConditionResult(e){return this.append(`${e}`)}appendConditionConsequence(e){return this.append(" => ").appendConditionResult(e),e?this:this.append(", skipping the remaining AND conditions")}appendTargetingRuleThenPart(e,t,i){if((i?this.newLine():this.append(" ")).append("THEN"),!rt(e,!0)){const s=e.s,r=q(s.v,t,!0);return this.append(` '${ue(r)}'`)}return this.append(" % options")}appendTargetingRuleConsequence(e,t,i,s){return this.increaseIndent(),this.appendTargetingRuleThenPart(e,t,s).append(" => ").append(i===!0?"MATCH, applying rule":i===!1?"no match":i),this.decreaseIndent()}}function ht(n){switch(n){case 0:case 16:case 4:return"IS ONE OF";case 1:case 17:case 5:return"IS NOT ONE OF";case 2:return"CONTAINS ANY OF";case 3:return"NOT CONTAINS ANY OF";case 6:case 12:return"<";case 7:case 13:return"<=";case 8:case 14:return">";case 9:case 15:return">=";case 10:return"=";case 11:return"!=";case 18:return"BEFORE";case 19:return"AFTER";case 28:case 20:return"EQUALS";case 29:case 21:return"NOT EQUALS";case 30:case 22:return"STARTS WITH ANY OF";case 31:case 23:return"NOT STARTS WITH ANY OF";case 32:case 24:return"ENDS WITH ANY OF";case 33:case 25:return"NOT ENDS WITH ANY OF";case 34:case 26:return"ARRAY CONTAINS ANY OF";case 35:case 27:return"ARRAY NOT CONTAINS ANY OF";default:return ft}}function gt(n){return new sn("").appendUserCondition(n).toString()}function pi(n){switch(n){case 0:return"EQUALS";case 1:return"NOT EQUALS";default:return ft}}function rn(n){switch(n){case 0:return"IS IN SEGMENT";case 1:return"IS NOT IN SEGMENT";default:return ft}}function ue(n){return st(n)?n.toString():tn}function on(n){let e,t;if(e=n.b,t=n.s,t!=null){if(e!=null)return;e=t}if(t=n.i,t!=null){if(e!=null)return;e=t}if(t=n.d,t!=null){if(e!=null)return;e=t}return e??void 0}function yi(n){let e,t;if(e=n.s,t=n.d,t!=null){if(e!=null)return;e=t}if(t=n.l,t!=null){if(e!=null)return;e=t}return e??void 0}const an=/^[0-9]+$/,fe=(n,e)=>{const t=an.test(n),i=an.test(e);return t&&i&&(n=+n,e=+e),n===e?0:t&&!i?-1:i&&!t?1:n<e?-1:1},dt=256,Le=Number.MAX_SAFE_INTEGER||9007199254740991,he=[],C=[],E={};let mi=0;const w=(n,e)=>{const t=mi++;E[n]=t,C[t]=e,he[t]=new RegExp(e)};w("NUMERICIDENTIFIER","0|[1-9]\\d*"),w("NUMERICIDENTIFIERLOOSE","[0-9]+"),w("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),w("MAINVERSION",`(${C[E.NUMERICIDENTIFIER]})\\.(${C[E.NUMERICIDENTIFIER]})\\.(${C[E.NUMERICIDENTIFIER]})`),w("MAINVERSIONLOOSE",`(${C[E.NUMERICIDENTIFIERLOOSE]})\\.(${C[E.NUMERICIDENTIFIERLOOSE]})\\.(${C[E.NUMERICIDENTIFIERLOOSE]})`),w("PRERELEASEIDENTIFIER",`(?:${C[E.NUMERICIDENTIFIER]}|${C[E.NONNUMERICIDENTIFIER]})`),w("PRERELEASEIDENTIFIERLOOSE",`(?:${C[E.NUMERICIDENTIFIERLOOSE]}|${C[E.NONNUMERICIDENTIFIER]})`),w("PRERELEASE",`(?:-(${C[E.PRERELEASEIDENTIFIER]}(?:\\.${C[E.PRERELEASEIDENTIFIER]})*))`),w("PRERELEASELOOSE",`(?:-?(${C[E.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${C[E.PRERELEASEIDENTIFIERLOOSE]})*))`),w("BUILDIDENTIFIER","[0-9A-Za-z-]+"),w("BUILD",`(?:\\+(${C[E.BUILDIDENTIFIER]}(?:\\.${C[E.BUILDIDENTIFIER]})*))`),w("FULLPLAIN",`v?${C[E.MAINVERSION]}${C[E.PRERELEASE]}?${C[E.BUILD]}?`),w("FULL",`^${C[E.FULLPLAIN]}$`),w("LOOSEPLAIN",`[v=\\s]*${C[E.MAINVERSIONLOOSE]}${C[E.PRERELEASELOOSE]}?${C[E.BUILD]}?`),w("LOOSE",`^${C[E.LOOSEPLAIN]}$`);class U{constructor(e,t){if((!t||typeof t!="object")&&(t={loose:!!t,includePrerelease:!1}),e instanceof U){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw TypeError(`Invalid Version: ${e}`);if(e.length>dt)throw TypeError(`version is longer than ${dt} characters`);this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const i=e.trim().match(t.loose?he[E.LOOSE]:he[E.FULL]);if(!i)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>Le||this.major<0)throw TypeError("Invalid major version");if(this.minor>Le||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>Le||this.patch<0)throw TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){const r=+s;if(r>=0&&r<Le)return r}return s}):this.prerelease=[],this.build=i[5]?i[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(!(e instanceof U)){if(typeof e=="string"&&e===this.version)return 0;e=new U(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof U||(e=new U(e,this.options)),fe(this.major,e.major)||fe(this.minor,e.minor)||fe(this.patch,e.patch)}comparePre(e){if(e instanceof U||(e=new U(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;let t=0;do{const i=this.prerelease[t],s=e.prerelease[t];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(i===s)continue;return fe(i,s)}while(++t)}compareBuild(e){e instanceof U||(e=new U(e,this.options));let t=0;do{const i=this.build[t],s=e.build[t];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(i===s)continue;return fe(i,s)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);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{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);i===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}}const vt=(n,e)=>{if((!e||typeof e!="object")&&(e={loose:!!e,includePrerelease:!1}),n instanceof U)return n;if(typeof n!="string"||n.length>dt||!(e.loose?he[E.LOOSE]:he[E.FULL]).test(n))return null;try{return new U(n,e)}catch{return null}};class Ei{constructor(e,t,i,s={}){this.identifier=e,this.email=t,this.country=i,this.custom=s}}function ln(n){var e;return(e=n.identifier)!==null&&e!==void 0?e:""}function cn(n,e){switch(e){case"Identifier":return ln(n);case"Email":return n.email;case"Country":return n.country;default:return n.custom&&D(n.custom,e)?n.custom[e]:void 0}}function un(n){var e;const t=F(),i="Identifier",s="Email",r="Country";if(t[i]=(e=n.identifier)!==null&&e!==void 0?e:"",n.email!=null&&(t[s]=n.email),n.country!=null&&(t[r]=n.country),n.custom!=null){const o=[i,s,r];for(const a in n.custom){let l;D(n.custom,a)&&(l=n.custom[a])!=null&&o.indexOf(a)<0&&(t[a]=l)}}return t}class ge{get settingType(){var e;return(e=this._settingType)!==null&&e!==void 0?e:this._settingType=nt(this.setting)}get visitedFlags(){var e;return(e=this._visitedFlags)!==null&&e!==void 0?e:this._visitedFlags=[]}constructor(e,t,i,s){this.key=e,this.setting=t,this.user=i,this.settings=s,this._settingType=void 0,this._visitedFlags=void 0,this.isMissingUserObjectLogged=!1,this.isMissingUserObjectAttributeLogged=!1}static forPrerequisiteFlag(e,t,i){const s=new ge(e,t,i.user,i.settings);return s._visitedFlags=i.visitedFlags,s.logBuilder=i.logBuilder,s}}const fn="The current targeting rule is ignored and the evaluation continues with the next rule.",pt="cannot evaluate, User Object is missing",Si=n=>`cannot evaluate, the User.${n} attribute is missing`,Ai=(n,e)=>`cannot evaluate, the User.${n} attribute is invalid (${e})`;class Oi{constructor(e){this.logger=e}evaluate(e,t){this.logger.debug("RolloutEvaluator.evaluate() called.");const i=t.logBuilder=this.logger.isEnabled(3)?new sn(this.logger.eol):null;i&&(i.append(`Evaluating '${t.key}'`),t.user&&i.append(` for User '${JSON.stringify(un(t.user))}'`),i.increaseIndent());let s;try{const r=t.settingType,o=r!==-1?r:it(t.setting.v);if(e!=null&&o!==void 0&&!Bn(e,o)){const l=Vn(o);throw new ve(2,`The type of a setting must match the type of the specified default value. Setting's type was ${l} but the default value's type was ${typeof e}. Please use a default value which corresponds to the setting type ${l}. Learn more: https://configcat.com/docs/sdk-reference/js/overview/#setting-type-mapping`)}const a=this.evaluateSetting(t);return a.returnValue=s=q(a.selectedValue.v,r),a}catch(r){throw i?.resetIndent().increaseIndent(),s=e,r}finally{i&&(i.newLine(`Returning '${s}'.`).decreaseIndent(),this.logger.settingEvaluated(i.toString()))}}evaluateSetting(e){let t;const i=e.setting.r;if(i?.length&&(t=this.evaluateTargetingRules(i,e)))return t;const s=e.setting.p;return s?.length&&(t=this.evaluatePercentageOptions(s,void 0,e))?t:yt(e.setting)}evaluateTargetingRules(e,t){const i=t.logBuilder;i?.newLine("Evaluating targeting rules and applying the first match if any:");for(let s=0;s<e.length;s++){const r=e[s],o=r.c,a=this.evaluateConditions(o,void 0,r,t.key,t);if(a!==!0){S(a)&&i?.increaseIndent().newLine(fn).decreaseIndent();continue}if(!rt(r))return yt(r.s,r);const l=r.p;i?.increaseIndent();const c=this.evaluatePercentageOptions(l,r,t);if(c)return i?.decreaseIndent(),c;i?.newLine(fn).decreaseIndent()}}evaluatePercentageOptions(e,t,i){const s=i.logBuilder;if(!i.user){s?.newLine("Skipping % options because the User Object is missing."),i.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(i.key),i.isMissingUserObjectLogged=!0);return}let r=i.setting.a,o;if(r==null?(r="Identifier",o=ln(i.user)):o=cn(i.user,r),o==null){s?.newLine(`Skipping % options because the User.${r} attribute is missing.`),i.isMissingUserObjectAttributeLogged||(this.logger.userObjectAttributeIsMissingPercentage(i.key,r),i.isMissingUserObjectAttributeLogged=!0);return}s?.newLine(`Evaluating % options based on the User.${r} attribute:`);const a=Yt(i.key+gn(o)),l=parseInt(a.substring(0,7),16)%100;s?.newLine(`- Computing hash in the [0..99] range from User.${r} => ${l} (this value is sticky and consistent across all SDKs)`);let c=0;for(let f=0;f<e.length;f++){const u=e[f],g=u.p;if(g<0&&I("Percentage option percentage is invalid."),c+=g,!(l>=c)){if(s){const d=q(u.v,i.settingType,!0);s.newLine(`- Hash value ${l} selects % option ${f+1} (${g}%), '${ue(d)}'.`)}return yt(u,t,u)}}I("Sum of percentage option percentages is less than 100.")}evaluateConditions(e,t,i,s,r){var o;let a=!0;const l=r.logBuilder;let c=!1;l?.newLine("- ");const f=!t;for(let u=0,g=(o=e?.length)!==null&&o!==void 0?o:0;u<g;u++){let d;if(f){const A=e[u];t=Wn(A),d=A[t]}else d=e[u];switch(l&&(u?l.increaseIndent().newLine("AND "):l.append("IF ").increaseIndent()),t){case"u":a=this.evaluateUserCondition(d,s,r),c=g>1;break;case"p":a=this.evaluatePrerequisiteFlagCondition(d,r),c=!0;break;case"s":a=this.evaluateSegmentCondition(d,r),c=!S(a)||a!==pt||g>1;break;default:throw Error()}const v=a===!0;if(l&&((!i||g>1)&&l.appendConditionConsequence(v),l.decreaseIndent()),!v)break}return i&&l?.appendTargetingRuleConsequence(i,r.settingType,a,c),a}evaluateUserCondition(e,t,i){const s=i.logBuilder;if(s?.appendUserCondition(e),!i.user)return i.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(i.key),i.isMissingUserObjectLogged=!0),pt;const r=e.a,o=cn(i.user,r);if(o==null||o===""){const g=new ae(e,d=>gt(d));return this.logger.userObjectAttributeIsMissingCondition(g,i.key,r),Si(r)}let a,l,c,f;const u=e.c;switch(u){case 28:case 29:return a=K(r,o,e,i.key,this.logger),this.evaluateTextEquals(a,R(e.s),u===29);case 20:case 21:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextEquals(a,R(e.s),de(i.setting),t,u===21);case 0:case 1:return a=K(r,o,e,i.key,this.logger),this.evaluateTextIsOneOf(a,R(e.l),u===1);case 16:case 17:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextIsOneOf(a,R(e.l),de(i.setting),t,u===17);case 30:case 31:return a=K(r,o,e,i.key,this.logger),this.evaluateTextSliceEqualsAnyOf(a,R(e.l),!0,u===31);case 22:case 23:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(a,R(e.l),de(i.setting),t,!0,u===23);case 32:case 33:return a=K(r,o,e,i.key,this.logger),this.evaluateTextSliceEqualsAnyOf(a,R(e.l),!1,u===33);case 24:case 25:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(a,R(e.l),de(i.setting),t,!1,u===25);case 2:case 3:return a=K(r,o,e,i.key,this.logger),this.evaluateTextContainsAnyOf(a,R(e.l),u===3);case 4:case 5:return l=dn(r,o,e,i.key,this.logger),S(l)?l:this.evaluateSemVerIsOneOf(l,R(e.l),u===5);case 6:case 7:case 8:case 9:return l=dn(r,o,e,i.key,this.logger),S(l)?l:this.evaluateSemVerRelation(l,u,R(e.s));case 10:case 11:case 12:case 13:case 14:case 15:return c=Ci(r,o,e,i.key,this.logger),S(c)?c:this.evaluateNumberRelation(c,u,R(e.d));case 18:case 19:return c=Ti(r,o,e,i.key,this.logger),S(c)?c:this.evaluateDateTimeRelation(c,R(e.d),u===18);case 34:case 35:return f=vn(r,o,e,i.key,this.logger),S(f)?f:this.evaluateArrayContainsAnyOf(f,R(e.l),u===35);case 26:case 27:return f=vn(r,o,e,i.key,this.logger),S(f)?f:this.evaluateSensitiveArrayContainsAnyOf(f,R(e.l),de(i.setting),t,u===27);default:I("Comparison operator is invalid.")}}evaluateTextEquals(e,t,i){return e===t!==i}evaluateSensitiveTextEquals(e,t,i,s,r){return mt(e,i,s)===t!==r}evaluateTextIsOneOf(e,t,i){return t.indexOf(e)>=0!==i}evaluateSensitiveTextIsOneOf(e,t,i,s,r){const o=mt(e,i,s);return t.indexOf(o)>=0!==r}evaluateTextSliceEqualsAnyOf(e,t,i,s){for(let r=0;r<t.length;r++){const o=t[r];if(e.length<o.length)continue;if((i?e.lastIndexOf(o,0):e.indexOf(o,e.length-o.length))>=0)return!s}return s}evaluateSensitiveTextSliceEqualsAnyOf(e,t,i,s,r,o){const a=oe(e);for(let l=0;l<t.length;l++){const c=t[l];let f,u;const g=c.indexOf("_");if((g<0||isNaN(f=bn(c.slice(0,g)))||f<0||!(u=c.slice(g+1)))&&I("Comparison value is invalid."),a.length<f)continue;const d=r?a.slice(0,f):a.slice(a.length-f);if(hn(d,i,s)===u)return!o}return o}evaluateTextContainsAnyOf(e,t,i){for(let s=0;s<t.length;s++)if(e.indexOf(t[s])>=0)return!i;return i}evaluateSemVerIsOneOf(e,t,i){let s=!1;for(let r=0;r<t.length;r++){const o=t[r];if(!o.length)continue;const a=vt(o.trim());if(!a)return!1;!s&&e.compare(a)===0&&(s=!0)}return s!==i}evaluateSemVerRelation(e,t,i){const s=vt(i.trim());if(!s)return!1;const r=e.compare(s);switch(t){case 6:return r<0;case 7:return r<=0;case 8:return r>0;case 9:return r>=0}}evaluateNumberRelation(e,t,i){switch(t){case 10:return e===i;case 11:return e!==i;case 12:return e<i;case 13:return e<=i;case 14:return e>i;case 15:return e>=i}}evaluateDateTimeRelation(e,t,i){return i?e<t:e>t}evaluateArrayContainsAnyOf(e,t,i){for(let s=0;s<e.length;s++)if(t.indexOf(e[s])>=0)return!i;return i}evaluateSensitiveArrayContainsAnyOf(e,t,i,s,r){for(let o=0;o<e.length;o++){const a=mt(e[o],i,s);if(t.indexOf(a)>=0)return!r}return r}evaluatePrerequisiteFlagCondition(e,t){const i=t.logBuilder;i?.appendPrerequisiteFlagCondition(e,t.settings);const s=e.f,r=D(t.settings,s)?t.settings[s]:I("Prerequisite flag is missing."),o=nt(r);let a,l;if(o!==-1)a=o,l=q(e.v,o,!0);else if(a=it(r.v),a!==void 0&&(l=q(e.v,a,!0),a===3)){const v=q(e.v,2,!0);l===void 0?l=v:v!==void 0&&(l=void 0)}l===void 0&&a!==void 0&&(l=on(e.v),I(`Type mismatch between comparison value '${ue(l)}' and prerequisite flag '${s}'.`));const c=t.visitedFlags;if(c.push(t.key),c.indexOf(s)>=0){c.push(s);const v=ze(c,void 0,void 0," -> ");I(`Circular dependency detected between the following depending flags: ${v}.`)}const f=ge.forPrerequisiteFlag(s,r,t);i?.newLine("(").increaseIndent().newLine(`Evaluating prerequisite flag '${s}':`);const u=this.evaluateSetting(f);c.pop();const g=q(u.selectedValue.v,o);let d;switch(e.c){case 0:d=g===l;break;case 1:d=g!==l;break;default:I("Comparison operator is invalid.")}return i?.newLine(`Prerequisite flag evaluation result: '${ue(g)}'.`).newLine("Condition (").appendPrerequisiteFlagCondition(e,t.settings).append(") evaluates to ").appendConditionResult(d).append(".").decreaseIndent().newLine(")"),d}evaluateSegmentCondition(e,t){const i=t.setting._configSegments,s=t.logBuilder;if(s?.appendSegmentCondition(e,i),!t.user)return t.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(t.key),t.isMissingUserObjectLogged=!0),pt;const r=e?.s;(!i||!Ke(r,0,i.length-1))&&I("Segment reference is invalid.");const o=i[r],a=o?.n;a.length||I("Segment name is missing."),s?.newLine("(").increaseIndent().newLine(`Evaluating segment '${a}':`);const l=o?.r,c=this.evaluateConditions(l,"u",void 0,a,t);let f=c;if(!S(f))switch(e.c){case 0:break;case 1:f=!f;break;default:I("Comparison operator is invalid.")}return s&&(s.newLine("Segment evaluation result: "),(S(f)?s.append(f):s.append(`User ${rn(c?0:1)}`)).append("."),s.newLine("Condition (").appendSegmentCondition(e,i).append(")"),(S(f)?s.append(" failed to evaluate"):s.append(" evaluates to ").appendConditionResult(f)).append("."),s.decreaseIndent().newLine(")")),f}}function yt(n,e,t){return{selectedValue:n,matchedTargetingRule:e,matchedPercentageOption:t}}function mt(n,e,t){return hn(oe(n),e,t)}function hn(n,e,t){return oi(n+oe(e)+oe(t))}function gn(n){return S(n)?n:n instanceof Date?String(n.getTime()/1e3):wt(n)?JSON.stringify(n):L(n)}function K(n,e,t,i,s){if(S(e))return e;e=gn(e);const r=new ae(t,o=>gt(o));return s.userObjectAttributeIsAutoConverted(r,i,n,e),e}function dn(n,e,t,i,s){let r;return S(e)&&(r=vt(e.trim()))?r:De(s,t,i,n,`'${L(e)}' is not a valid semantic version`)}function Ci(n,e,t,i,s){if(W(e))return e;let r;return S(e)&&(!isNaN(r=Je(e.replace(",",".")))||e.trim()==="NaN")?r:De(s,t,i,n,`'${L(e)}' is not a valid decimal number`)}function Ti(n,e,t,i,s){if(e instanceof Date)return e.getTime()/1e3;if(W(e))return e;let r;return S(e)&&(!isNaN(r=Je(e.replace(",",".")))||e.trim()==="NaN")?r:De(s,t,i,n,`'${L(e)}' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)`)}function vn(n,e,t,i,s){let r=e;if(S(r))try{r=JSON.parse(r)}catch{}return wt(r)?r:De(s,t,i,n,`'${L(e)}' is not a valid string array`)}function De(n,e,t,i,s){const r=new ae(e,o=>gt(o));return n.userObjectAttributeIsInvalid(r,t,s,i),Ai(i,s)}function de(n){var e;return(e=n._configJsonSalt)!==null&&e!==void 0?e:I("Config JSON salt is missing.")}function R(n){return n??I("Comparison value is missing.")}h.EvaluationErrorCode=void 0,function(n){n[n.UnexpectedError=-1]="UnexpectedError",n[n.None=0]="None",n[n.InvalidConfigModel=1]="InvalidConfigModel",n[n.SettingValueTypeMismatch=2]="SettingValueTypeMismatch",n[n.ConfigJsonNotAvailable=1e3]="ConfigJsonNotAvailable",n[n.SettingKeyMissing=1001]="SettingKeyMissing"}(h.EvaluationErrorCode||(h.EvaluationErrorCode={}));function pn(n,e,t,i){return{key:n,value:e.returnValue,variationId:e.selectedValue.i,fetchTime:t,user:i,isDefaultValue:!1,matchedTargetingRule:e.matchedTargetingRule,matchedPercentageOption:e.matchedPercentageOption,errorCode:0}}function Z(n,e,t,i,s,r,o=-1){return{key:n,value:e,fetchTime:t,user:i,isDefaultValue:!0,errorCode:o,_errorMessage:s,get errorMessage(){var a;return(a=this._errorMessage)===null||a===void 0?void 0:a.toString()},errorException:r}}function ke(n,e,t,i,s,r,o){let a;if(!e)return a=o.configJsonIsNotPresentSingle(t,"defaultValue",i),Z(t,i,V(r),s,B(a),void 0,1e3);if(!D(e,t)){const c=new ae(e,f=>ze(Object.keys(f)));return a=o.settingEvaluationFailedDueToMissingKey(t,"defaultValue",i,c),Z(t,i,V(r),s,B(a),void 0,1001)}const l=n.evaluate(i,new ge(t,e[t],s,e));return pn(t,l,V(r),s)}function yn(n,e,t,i,s,r){let o;if(!Et(e,s,r))return[[],o];const a=[];for(const l in e){if(!D(e,l))continue;const c=e[l];let f;try{const u=n.evaluate(null,new ge(l,c,t,e));f=pn(l,u,V(i),t)}catch(u){o??(o=[]),o.push(u),f=Z(l,null,V(i),t,G(u),u,pe(u))}a.push(f)}return[a,o]}function Et(n,e,t){return n?!0:(e.configJsonIsNotPresent(t),!1)}function mn(n,e,t,i){if(!Et(n,t,i))return null;for(const s in n){if(!D(n,s))continue;const r=n[s],o=nt(r);if(e===r.i)return{settingKey:s,settingValue:q(r.v,o)};const a=r.r;if(a?.length)for(let c=0;c<a.length;c++){const f=a[c];if(rt(f)){const u=f.p;for(let g=0;g<u.length;g++){const d=u[g];if(e===d.i)return{settingKey:s,settingValue:q(d.v,o)}}}else{const u=f.s;if(e===u.i)return{settingKey:s,settingValue:q(u.v,o)}}}const l=r.p;if(l?.length)for(let c=0;c<l.length;c++){const f=l[c];if(e===f.i)return{settingKey:s,settingValue:q(f.v,o)}}}return t.settingForVariationIdIsNotPresent(e),null}class ve extends Error{constructor(e,t){super(t),this.errorCode=e,this.message=t,this.name=ve.name,je(this,ve)}}function pe(n){return n instanceof Error?n instanceof ve?n.errorCode:n instanceof le?1:-1:-1}class bi{constructor(){this.instances=F()}getOrCreate(e){let t;const i=this.instances[e.sdkKey];if(i){const[r]=i;if(t=r.deref(),t)return[t,!0]}const s={};return t=new J(e,s),this.instances[e.sdkKey]=[Tt(t),s],[t,!1]}remove(e,t){const i=this.instances[e];if(i){const[s,r]=i,o=!!s.deref();if(!o||r===t)return delete this.instances[e],o}return!1}clear(){const e=[];for(const t in this.instances){const[i]=this.instances[t],s=i.deref();s&&e.push(s),delete this.instances[t]}return e}}const ye=new bi;class J{static get instanceCache(){return ye}static get(e,t,i,s){var r;Y(e,"sdkKey",!0),i==null||_(i,"options");const o=t===0?new fi(e,s,i):t===2?new hi(e,s,i):t===1?new gi(e,s,i):ee(t,"pollingMode","PollingMode",()=>!1);((r=o.flagOverrides)===null||r===void 0?void 0:r.behaviour)!==0&&!Ii(e,o.baseUrlOverriden)&&Q("sdkKey",`Expected a string matching the SDK Key format, got '${L(e)}'.`);const[a,l]=ye.getOrCreate(o);return l&&i&&o.logger.clientIsAlreadyCreated(e),a}constructor(e,t){var i;this.cacheToken=t,this.options=e,e.logger.isEnabled(4)&&e.logger.debug(m.from("OPTIONS")`Initializing ConfigCatClient. Options: ${JSON.stringify(wi(e))}`),this.hooks=e.yieldHooks(),this.hooks.configCatClient=this,this.defaultUser=e.defaultUser,this.evaluator=new Oi(e.logger),((i=e.flagOverrides)===null||i===void 0?void 0:i.behaviour)!==0?this.configService=e.createConfigService():(this.configService=null,this.hooks.emit("clientReady",1)),this.suppressFinalize=Pe(this,{sdkKey:e.sdkKey,cacheToken:t,configService:this.configService,logger:e.logger})}initConfigService(e){this.configService=e}static finalize(e){var t;(t=e.logger)===null||t===void 0||t.debug("finalize() called."),e.cacheToken&&ye.remove(e.sdkKey,e.cacheToken),J.close(e.configService,e.logger)}static close(e,t,i){t?.debug("close() called."),i?.tryDisconnect(),e?.dispose()}dispose(){const e=this.options;e.logger.debug("dispose() called."),this.cacheToken&&ye.remove(e.sdkKey,this.cacheToken),J.close(this.configService,e.logger,this.hooks),this.suppressFinalize()}static disposeAll(){const e=ye.clear();let t;for(const i of e)try{J.close(i.configService,i.options.logger,i.hooks),i.suppressFinalize()}catch(s){t??(t=[]),t.push(s)}if(t)throw typeof AggregateError=="function"?AggregateError(t):t.pop()}async getValueAsync(e,t,i){this.options.logger.debug("getValueAsync() called."),Ue(e),Me(t),se(i);let s,r,o=null;i??(i=this.defaultUser);try{let a;[a,o]=await this.getSettingsAsync(),r=ke(this.evaluator,a,e,t,i,o,this.options.logger),s=r.value}catch(a){this.options.logger.settingEvaluationErrorSingle("getValueAsync",e,"defaultValue",t,a),r=Z(e,t,V(o),i,G(a),a,pe(a)),s=t}return this.hooks.emit("flagEvaluated",r),s}async getValueDetailsAsync(e,t,i){this.options.logger.debug("getValueDetailsAsync() called."),Ue(e),Me(t),se(i);let s,r=null;i??(i=this.defaultUser);try{let o;[o,r]=await this.getSettingsAsync(),s=ke(this.evaluator,o,e,t,i,r,this.options.logger)}catch(o){this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync",e,"defaultValue",t,o),s=Z(e,t,V(r),i,G(o),o,pe(o))}return this.hooks.emit("flagEvaluated",s),s}async getAllKeysAsync(){this.options.logger.debug("getAllKeysAsync() called.");const e="empty array";try{const[t]=await this.getSettingsAsync();return Et(t,this.options.logger,e)?Object.keys(t):[]}catch(t){return this.options.logger.settingEvaluationError("getAllKeysAsync",e,t),[]}}async getAllValuesAsync(e){this.options.logger.debug("getAllValuesAsync() called."),se(e);const t="empty array";let i,s,r;e??(e=this.defaultUser);try{const[o,a]=await this.getSettingsAsync();[s,r]=yn(this.evaluator,o,e,a,this.options.logger,t),i=s.map(l=>({settingKey:l.key,settingValue:l.value}))}catch(o){return this.options.logger.settingEvaluationError("getAllValuesAsync",t,o),[]}r?.length&&this.options.logger.settingEvaluationError("getAllValuesAsync","evaluation result",typeof AggregateError=="function"?AggregateError(r):r.pop());for(const o of s)this.hooks.emit("flagEvaluated",o);return i}async getAllValueDetailsAsync(e){this.options.logger.debug("getAllValueDetailsAsync() called."),se(e);const t="empty array";let i,s;e??(e=this.defaultUser);try{const[r,o]=await this.getSettingsAsync();[i,s]=yn(this.evaluator,r,e,o,this.options.logger,t)}catch(r){return this.options.logger.settingEvaluationError("getAllValueDetailsAsync",t,r),[]}s?.length&&this.options.logger.settingEvaluationError("getAllValueDetailsAsync","evaluation result",typeof AggregateError=="function"?AggregateError(s):s.pop());for(const r of i)this.hooks.emit("flagEvaluated",r);return i}async getKeyAndValueAsync(e){this.options.logger.debug("getKeyAndValueAsync() called."),En(e);const t="null";try{const[i]=await this.getSettingsAsync();return mn(i,e,this.options.logger,t)}catch(i){return this.options.logger.settingEvaluationError("getKeyAndValueAsync",t,i),null}}async forceRefreshAsync(){if(this.options.logger.debug("forceRefreshAsync() called."),this.configService)try{const[e]=await this.configService.refreshConfigAsync();return e}catch(e){return this.options.logger.clientMethodError("forceRefreshAsync",e),Te(-1,G(e),e)}else return Te(1,"Client is configured to use the LocalOnly override behavior, which prevents synchronization with external cache and making HTTP requests.")}setDefaultUser(e){this.defaultUser=_(e,"defaultUser")}clearDefaultUser(){this.defaultUser=void 0}get isOffline(){var e,t;return(t=(e=this.configService)===null||e===void 0?void 0:e.isOffline)!==null&&t!==void 0?t:!0}setOnline(){this.configService?this.configService.setOnline():this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(we(0),"setOnline")}setOffline(){var e;(e=this.configService)===null||e===void 0||e.setOffline()}waitForReady(){const e=this.configService;return e?e.readyPromise:Promise.resolve(1)}snapshot(){const e=()=>{var s;const r=this.options.cache.getInMemory();return[r.isEmpty?null:(s=r.config.f)!==null&&s!==void 0?s:F(),r]};let t,i;try{const{flagOverrides:s}=this.options;if(s){const r=s.dataSource.getOverrides();switch(s.behaviour){case 0:return new me(r,null,this);case 1:return[t,i]=e(),new me(Object.assign(Object.assign({},t),r),i,this);case 2:return[t,i]=e(),new me(Object.assign(Object.assign({},r),t),i,this)}}return[t,i]=e(),new me(t,i,this)}catch(s){return this.options.logger.clientMethodError("snapshot",s),new me(F(),null,this)}}async getSettingsAsync(){this.options.logger.debug("getSettingsAsync() called.");const e=async()=>{var i;const s=await this.configService.getConfigAsync();return[s.isEmpty?null:(i=s.config.f)!==null&&i!==void 0?i:F(),s]},{flagOverrides:t}=this.options;if(t){let i,s;const r=t.dataSource.getOverrides();switch(t.behaviour){case 0:return[r,null];case 1:return[i,s]=await e(),[Object.assign(Object.assign({},i),r),s];case 2:return[i,s]=await e(),[Object.assign(Object.assign({},r),i),s]}}return await e()}on(e,t){return this.hooks.on(e,t),this}once(e,t){return this.hooks.once(e,t),this}removeListener(e,t){return this.hooks.removeListener(e,t),this}removeAllListeners(e){return this.hooks.removeAllListeners(e),this}listeners(e){return this.hooks.listeners(e)}listenerCount(e){return this.hooks.listenerCount(e)}eventNames(){return this.hooks.eventNames()}}const $e=J.prototype;$e.addListener=$e.on,$e.off=$e.removeListener;class me{constructor(e,t,i){this.mergedSettings=e,this.remoteConfig=t,this.defaultUser=i.defaultUser,this.evaluator=i.evaluator,this.options=i.options,this.cacheState=t?i.configService.getCacheState(t):1}get fetchedConfig(){const e=this.remoteConfig;return e&&!e.isEmpty?e.config:null}getAllKeys(){return this.mergedSettings?Object.keys(this.mergedSettings):[]}getValue(e,t,i){this.options.logger.debug("Snapshot.getValue() called."),Ue(e),Me(t),se(i);let s,r;i??(i=this.defaultUser);try{r=ke(this.evaluator,this.mergedSettings,e,t,i,this.remoteConfig,this.options.logger),s=r.value}catch(o){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue",e,"defaultValue",t,o),r=Z(e,t,V(this.remoteConfig),i,G(o),o,pe(o)),s=t}return this.options.hooks.emit("flagEvaluated",r),s}getValueDetails(e,t,i){this.options.logger.debug("Snapshot.getValueDetails() called."),Ue(e),Me(t),se(i);let s;i??(i=this.defaultUser);try{s=ke(this.evaluator,this.mergedSettings,e,t,i,this.remoteConfig,this.options.logger)}catch(r){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails",e,"defaultValue",t,r),s=Z(e,t,V(this.remoteConfig),i,G(r),r,pe(r))}return this.options.hooks.emit("flagEvaluated",s),s}getKeyAndValue(e){this.options.logger.debug("Snapshot.getKeyAndValue() called."),En(e);const t="null";try{return mn(this.mergedSettings,e,this.options.logger,t)}catch(i){return this.options.logger.settingEvaluationError("Snapshot.getKeyAndValue",t,i),null}}}function Ii(n,e){if(e&&n.length>ut.length&&n.lastIndexOf(ut,0)===0)return!0;const t=n.split("/"),i=22;switch(t.length){case 2:return t[0].length===i&&t[1].length===i;case 3:return t[0]==="configcat-sdk-1"&&t[1].length===i&&t[2].length===i;default:return!1}}function Ue(n){Y(n,"key",!0)}function Me(n){n!=null&&!st(n)&&Q("defaultValue","The default value must be boolean, number, string, null or undefined.",void 0,TypeError)}function se(n){n==null||_(n,"user")}function En(n){Y(n,"variationId",!0)}function wi(n){return Lt(n,(e,t)=>t==null?t:e==="defaultUser"?un(t):e==="flagOverrides"?Lt(t,(i,s)=>Se(s)?L(s):s):Se(t)?L(t):t)}let Pe=function(n,e){if(typeof FinalizationRegistry=="function"){const t=new FinalizationRegistry(i=>J.finalize(i));Pe=(i,s)=>{const r={};return t.register(i,s,r),()=>t.unregister(r)}}else Pe=()=>()=>{};return Pe(n,e)};function Ri(n,e,t,i){return J.get(n,e,t,i)}function Ni(n,e){return ee(n,"logLevel","LogLevel",t=>_t(t)!==void 0),e==null||Y(e,"eol",!0),new qt(n,e)}function Fi(n,e,t){return _(n,"map"),ee(e,"behaviour","OverrideBehaviour",i=>we(i)!==void 0),t==null||We(t,"watchChanges"),{dataSource:new Xn(n,t),behaviour:e}}function Li(n,e,t,i){return ee(n,"behaviour","OverrideBehaviour",s=>we(s)!==void 0),e==null||We(e,"watchChanges"),t==null||Y(t,"paramPrefix"),i==null||_(i,"queryStringProvider"),{dataSource:new ti(e,t,i),behaviour:n}}const Ee="configCache";class St{static tryGetFactory(){const e=Di();if(e)return t=>new Ce(new St(e),t.logger)}constructor(e){this.dbConnectionFactory=e}async set(e,t){const i=await this.dbConnectionFactory();try{await new Promise((s,r)=>{const o=i.transaction(Ee,"readwrite");o.oncomplete=()=>s(),o.onerror=l=>r(l.target.error),o.objectStore(Ee).put(t,e)})}finally{i.close()}}async get(e){const t=await this.dbConnectionFactory();try{return await new Promise((i,s)=>{const r=t.transaction(Ee,"readonly");let o;r.oncomplete=()=>i(o),r.onerror=c=>s(c.target.error);const l=r.objectStore(Ee).get(e);l.onsuccess=c=>o=c.target.result})}finally{t.close()}}}function Di(){if(typeof indexedDB<"u")try{const n=()=>new Promise((e,t)=>{const i=indexedDB.open("@configcat/sdk");i.onupgradeneeded=s=>s.target.result.createObjectStore(Ee),i.onsuccess=s=>e(s.target.result),i.onerror=s=>t(s.target.error)});return n().then(e=>e.close()).catch(()=>{}),n}catch{}}class _e{static tryGetFactory(){const e=ki();if(e)return t=>new Ce(new _e(e),t.logger)}constructor(e){this.storage=e}set(e,t){this.storage.setItem(e,$i(t))}get(e){const t=this.storage.getItem(e);if(t)return Ui(t)}}function ki(){if(typeof localStorage<"u"){const n="__configcat_localStorage_test";try{const e=localStorage;e.setItem(n,n);let t;try{t=e.getItem(n)}finally{e.removeItem(n)}if(t===n)return e}catch{}}}function $i(n){return n=encodeURIComponent(n),n=n.replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))),btoa(n)}function Ui(n){return n=atob(n),n=n.replace(/[%\x80-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16)),decodeURIComponent(n)}class qe{constructor(){this.logger=null}static getFactory(){return e=>{const t=new qe;return t.logger=e.logger,t}}handleStateChange(e,t,i){try{if(e.readyState===4){const{status:s,statusText:r}=e;if(s){const o=Mi(e),a=s===200?e.responseText:void 0;t(new ot(s,r,o,a))}}}catch(s){i(s)}}fetchAsync(e){return new Promise((t,i)=>{var s;try{(s=this.logger)===null||s===void 0||s.debug("XmlHttpRequestConfigFetcher.fetchAsync() called.");let{url:r}=e;const o=!en(r),{lastETag:a,timeoutMs:l}=e;a&&(r+="&ccetag="+encodeURIComponent(a));const c=new XMLHttpRequest;c.onreadystatechange=()=>this.handleStateChange(c,t,i),c.ontimeout=()=>i(new H("timeout",l)),c.onabort=()=>i(new H("abort")),c.onerror=()=>i(new H("failure")),c.open("GET",r,!0),c.timeout=l,o&&this.setRequestHeaders(c,e.headers),c.send(null)}catch(r){i(r)}})}setRequestHeaders(e,t){}}function Mi(n){const e=[];return t("ETag",n,e),t("CF-RAY",n,e),e;function t(i,s,r){const o=s.getResponseHeader(i);o!=null&&r.push([i,o])}}class Pi{constructor(e){this.runsOnServerSide=e,this.logger=null}async fetchAsync(e){var t,i,s;(t=this.logger)===null||t===void 0||t.debug("FetchApiConfigFetcher.fetchAsync() called.");let{url:r}=e;const o=!en(r),{lastETag:a,timeoutMs:l}=e,c=Object.create(null);c.method="GET",o?this.setRequestHeaders(c,e.headers):this.runsOnServerSide&&Sn(c,e.headers),a&&(this.runsOnServerSide?((i=c.headers)!==null&&i!==void 0?i:c.headers=[]).push(["If-None-Match",a]):r+="&ccetag="+encodeURIComponent(a));let f;if(typeof AbortController=="function"){const u=new AbortController,g=setTimeout(()=>u.abort(),l);c.signal=u.signal,f=()=>clearTimeout(g)}try{const u=await fetch(r,c),{status:g,statusText:d}=u,v=_i(u),A=g===200?await u.text():void 0;return new ot(g,d,v,A)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?!((s=c.signal)===null||s===void 0)&&s.aborted?new H("timeout",l):new H("abort"):new H("failure",u)}finally{f?.()}}setRequestHeaders(e,t){this.runsOnServerSide&&Sn(e,t)}}function Sn(n,e){var t;for(const[i,s]of e)((t=n.headers)!==null&&t!==void 0?t:n.headers=[]).push([i,s])}function _i(n){const e=[];return t("ETag",n,e),t("CF-RAY",n,e),e;function t(i,s,r){const o=s.headers.get(i);o!=null&&r.push([i,o])}}class At extends Pi{static getFactory(){return e=>{const t=new At;return t.logger=e.logger,t}}}const qi="2.6.5",Hi={install:(n,e)=>{const{sdkKey:t,pollingMode:i,clientOptions:s}=e,r={sdkType:"ConfigCat-Vue",sdkVersion:qi,eventEmitterFactory:()=>new Dt,defaultCacheFactory:_e.tryGetFactory(),configFetcherFactory:qe.getFactory()},o=Ri(t,i??h.PollingMode.AutoPoll,s,r);n.provide("configCatClient",o);const a=n.unmount;n.unmount=function(){a.apply(arguments),o.dispose()}}},xi=$.defineComponent({__name:"FeatureWrapper",props:{featureKey:{},userObject:{}},emits:["flagValueChanged"],setup(n,{emit:e}){const t=e,i=n,s=$.ref(null),r=$.inject("configCatClient")??(()=>{throw new Error("ConfigCatPlugin was not installed.")})(),o=()=>{const l=r.snapshot().getValue(i.featureKey,!1,i.userObject);s.value!==l&&(s.value=l,t("flagValueChanged",l))};return $.onBeforeMount(()=>{const a=r.snapshot(),l=a.cacheState;l==h.ClientCacheState.HasUpToDateFlagData||l==h.ClientCacheState.HasLocalOverrideFlagDataOnly?(s.value=a.getValue(i.featureKey,!1,i.userObject),r.on("configChanged",o)):r.getValueAsync(i.featureKey,!1,i.userObject).then(c=>{const f=o;f&&(s.value=c,r.on("configChanged",f))})}),$.onUnmounted(()=>{r.off("configChanged",o)}),(a,l)=>s.value===!0?$.renderSlot(a.$slots,"default",{key:0}):s.value===!1?$.renderSlot(a.$slots,"else",{key:1}):$.renderSlot(a.$slots,"loading",{key:2})}});h.ClientSideFetchApiConfigFetcher=At,h.ConfigCatPlugin=Hi,h.ConfigJson=In,h.FeatureWrapper=xi,h.FetchError=H,h.FetchRequest=jt,h.FetchResponse=ot,h.FormattableLogMessage=m,h.IndexedDBConfigCache=St,h.LocalStorageConfigCache=_e,h.User=Ei,h.XmlHttpRequestConfigFetcher=qe,h.createConsoleLogger=Ni,h.createFlagOverridesFromMap=Fi,h.createFlagOverridesFromQueryParams=Li,h.createSettingFromValue=Xe,h.deserializeConfig=Ye,h.prepareConfig=Qe,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
`){this.level=e,this.eol=t,this.SOURCE="ConfigCat"}log(e,t,i,s){const[r,o]=e===4?[console.info,"DEBUG"]:e===3?[console.info,"INFO"]:e===2?[console.warn,"WARN"]:e===1?[console.error,"ERROR"]:[console.log,_t(e).toUpperCase()],a=s!==void 0?this.eol+G(s,!0):"";r(`${this.SOURCE} - ${o} - [${t}] ${i}${a}`)}}function Ht(n){return n.substring(0,n.length-6).replace(/[^/]/g,"*")+n.substring(n.length-6)}var xt;(function(n){n[n.Fetched=0]="Fetched",n[n.NotModified=1]="NotModified",n[n.Errored=2]="Errored"})(xt||(xt={}));function Jn(n){return{status:0,config:n,errorCode:0}}function Gn(n){return{status:1,config:n,errorCode:0}}function ce(n,e,t,i){return{status:2,config:n,errorCode:e,errorMessage:t,errorException:i}}class jt{constructor(e,t,i,s){this.url=e,this.lastETag=t,this.headers=i,this.timeoutMs=s}}class ot{constructor(e,t,i,s){this.statusCode=e,this.reasonPhrase=t,this.body=s,this.eTag=void 0,this.rayId=void 0;let r,o;for(const[a,l]of i){const c=a.toLowerCase();if(r==null&&c==="etag"){if(this.eTag=r=l,o!=null)break}else if(o==null&&c==="cf-ray"&&(this.rayId=o=l,r!=null))break}}}class H extends Error{constructor(e,...t){super(((i,s)=>{switch(i){case"abort":return"Request was aborted.";case"timeout":const[r]=s;return`Request timed out. Timeout value: ${r}ms`;case"failure":const[o]=s,a="Request failed due to a network or protocol error.";return o?a+" "+(o instanceof Error?o.message:L(o)):a}})(e,t)),this.cause=e,this.name=H.name,je(this,H),this.args=t}}h.RefreshErrorCode=void 0,(function(n){n[n.UnexpectedError=-1]="UnexpectedError",n[n.None=0]="None",n[n.LocalOnlyClient=1]="LocalOnlyClient",n[n.OfflineClient=3200]="OfflineClient",n[n.InvalidSdkKey=1100]="InvalidSdkKey",n[n.UnexpectedHttpResponse=1101]="UnexpectedHttpResponse",n[n.HttpRequestTimeout=1102]="HttpRequestTimeout",n[n.HttpRequestFailure=1103]="HttpRequestFailure",n[n.InvalidHttpResponseContent=1105]="InvalidHttpResponseContent",n[n.InvalidHttpResponseWhenLocalCacheIsEmpty=1106]="InvalidHttpResponseWhenLocalCacheIsEmpty"})(h.RefreshErrorCode||(h.RefreshErrorCode={}));function Vt(){return{isSuccess:!0,errorCode:0}}function Te(n,e,t){return{isSuccess:!1,errorCode:n,_errorMessage:e,get errorMessage(){var i;return(i=this._errorMessage)===null||i===void 0?void 0:i.toString()},errorException:t}}function Bt(n){return n.status!==2?Vt():Te(n.errorCode,n.errorMessage,n.errorException)}h.ClientCacheState=void 0,(function(n){n[n.NoFlagData=0]="NoFlagData",n[n.HasLocalOverrideFlagDataOnly=1]="HasLocalOverrideFlagDataOnly",n[n.HasCachedFlagDataOnly=2]="HasCachedFlagDataOnly",n[n.HasUpToDateFlagData=3]="HasUpToDateFlagData"})(h.ClientCacheState||(h.ClientCacheState={}));var at;(function(n){n[n.Online=0]="Online",n[n.Offline=1]="Offline",n[n.Disposed=2]="Disposed"})(at||(at={}));function Kt(n){return at[n]}class lt{constructor(e){this.options=e,this.pendingCacheSyncUp=null,this.pendingConfigRefresh=null,this.cacheKey=e.getCacheKey(),this.configFetcher=e.configFetcher,this.requestHeaders=[["User-Agent",e.clientVersion],["X-ConfigCat-UserAgent",e.clientVersion]],this.status=e.offline?1:0}prepareClientForEvents(){var e;const t=(e=this.options.hooks.unwrap())===null||e===void 0?void 0:e.configCatClient,i=t?.initConfigService;P(i)&&i.call(t,this)}dispose(){this.status=2}get disposed(){return this.status===2}async refreshConfigAsync(){const e=await this.syncUpWithCache();if(this.isOffline){if(this.options.cache instanceof Ce)return[Vt(),e];{const t=this.options.logger.configServiceCannotInitiateHttpCalls();return[Te(3200,B(t)),e]}}else{const[t,i]=await this.refreshConfigCoreAsync(e,!0);return[Bt(t),i]}}refreshConfigCoreAsync(e,t){if(this.pendingConfigRefresh)return this.pendingConfigRefresh;const i=(async s=>{const r=await this.fetchAsync(s);return(r.status===0||r.status===1||r.config.timestamp>s.timestamp&&(!r.config.isEmpty||this.options.cache.getInMemory().isEmpty))&&(await this.options.cache.set(this.cacheKey,r.config),s=r.config),this.onConfigFetched(r,t),r.status===0&&this.onConfigChanged(r.config),[r,s]})(e);this.pendingConfigRefresh=i;try{i.finally(()=>this.pendingConfigRefresh=null)}catch(s){throw this.pendingConfigRefresh=null,s}return i}onConfigFetched(e,t){this.options.logger.debug("config fetched"),this.options.hooks.emit("configFetched",Bt(e),t)}onConfigChanged(e){var t;this.options.logger.debug("config changed"),this.options.hooks.emit("configChanged",(t=e.config)!==null&&t!==void 0?t:Qe({}))}async fetchAsync(e){const t=this.options;t.logger.debug("ConfigServiceBase.fetchAsync() called.");let i;try{const[s,r,o]=await this.fetchRequestAsync(e.httpETag);switch(s.statusCode){case 200:return r?(t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was successful. Returning new config."),Jn(new b(s.body,r,b.generateTimestamp(),s.eTag))):(i=t.logger.fetchReceived200WithInvalidBody(s.rayId,o),t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received but the HTTP response content was invalid. Returning null.`),ce(e,1105,B(i),o));case 304:return e.isEmpty?(i=t.logger.fetchReceived304WhenLocalCacheIsEmpty(s.statusCode,s.reasonPhrase,s.rayId),t.logger.debug(`ConfigServiceBase.fetchAsync(): ${s.statusCode} ${s.reasonPhrase} was received when no config is cached locally. Returning null.`),ce(e,1106,B(i))):(t.logger.debug("ConfigServiceBase.fetchAsync(): content was not modified. Returning last config with updated timestamp."),Gn(e.with(b.generateTimestamp())));case 403:case 404:return i=t.logger.fetchFailedDueToInvalidSdkKey(t.sdkKey,s.rayId),t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning last config (if any) with updated timestamp."),ce(e.with(b.generateTimestamp()),1100,B(i));default:return i=t.logger.fetchFailedDueToUnexpectedHttpResponse(s.statusCode,s.reasonPhrase,s.rayId),t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),ce(e,1101,B(i))}}catch(s){let r;return[r,i]=s instanceof H&&s.cause==="timeout"?[1102,t.logger.fetchFailedDueToRequestTimeout(s.args[0],s)]:[1103,t.logger.fetchFailedDueToUnexpectedError(s)],t.logger.debug("ConfigServiceBase.fetchAsync(): fetch was unsuccessful. Returning null."),ce(e,r,B(i),s)}}async fetchRequestAsync(e,t=2){const i=this.options;i.logger.debug("ConfigServiceBase.fetchRequestAsync() called.");for(let s=0;;s++){i.logger.debug(`ConfigServiceBase.fetchRequestAsync(): calling fetchLogic()${s>0?`, retry ${s}/${t}`:""}.`);const r=new jt(i.getUrl(),e,this.requestHeaders,i.requestTimeoutMs),o=await this.configFetcher.fetchAsync(r);if(o.statusCode!==200)return[o];if(!o.body)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body."),[o,void 0,Error("No response body.")];let a;try{a=Ye(o.body)}catch(u){return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body."),[o,void 0,u]}const l=a.p;if(!l)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): preferences are missing or invalid."),[o,a];const c=l.u;if(c==null||c===i.baseUrl)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): baseUrl OK."),[o,a];const f=l.r;if(i.baseUrlOverriden&&f!==2)return i.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2."),[o,a];if(i.baseUrl=c,f===0)return[o,a];if(f===1&&i.logger.dataGovernanceIsOutOfSync(),s>=t)return i.logger.fetchFailedDueToRedirectLoop(o.rayId),[o,a]}}get isOfflineExactly(){return this.status===1}get isOffline(){return this.status!==0}goOnline(){}setOnline(){this.status===1?(this.goOnline(),this.status=0,this.options.logger.configServiceStatusChanged(Kt(this.status))):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOnline")}setOffline(){this.status===0?(this.status=1,this.options.logger.configServiceStatusChanged(Kt(this.status))):this.disposed&&this.options.logger.configServiceMethodHasNoEffectDueToDisposedClient("setOffline")}syncUpWithCache(){const{cache:e}=this.options;if(e instanceof Pt)return e.get(this.cacheKey);if(this.pendingCacheSyncUp)return this.pendingCacheSyncUp;const t=e.get(this.cacheKey);if(!Rt(t))return this.onCacheSynced(t);const i=t.then(s=>this.onCacheSynced(s));this.pendingCacheSyncUp=i;try{i.finally(()=>this.pendingCacheSyncUp=null)}catch(s){throw this.pendingCacheSyncUp=null,s}return i}onCacheSynced(e){if(!M(e))return e;const[t]=e;return t.isEmpty||this.onConfigChanged(t),t}async waitForReadyAsync(e){return this.getCacheState(await e)}getReadyPromise(e){return this.waitForReadyAsync(e).then(t=>(this.options.hooks.emit("clientReady",t),t))}}const Yn=500;class Qn extends lt{constructor(e){super(e),this.signalInitialization=()=>{},this.stopToken=new xe,this.pollIntervalMs=e.pollIntervalSeconds*1e3,this.pollExpirationMs=this.pollIntervalMs-Yn,this.prepareClientForEvents();const t=this.syncUpWithCache();if(e.maxInitWaitTimeSeconds!==0){this.initialized=!1;const i=new Promise(s=>this.signalInitialization=s);this.initializationPromise=this.waitForInitializationAsync(i).then(s=>(this.initialized=!0,s))}else this.initialized=!0,this.initializationPromise=Promise.resolve(!1);this.readyPromise=this.getReadyPromise(t),this.startRefreshWorker(t,this.stopToken)}async waitForInitializationAsync(e){if(this.options.maxInitWaitTimeSeconds<0)return await e,!0;const t=new xe,i=await Promise.race([e.then(()=>!0),Ot(this.options.maxInitWaitTimeSeconds*1e3,t).then(()=>!1)]);return t.abort(),i}async waitForReadyAsync(){return await this.initializationPromise,this.getCacheState(this.options.cache.getInMemory())}async getConfigAsync(){this.options.logger.debug("AutoPollConfigService.getConfigAsync() called.");let e=await this.syncUpWithCache();if(!e.isExpired(this.pollIntervalMs))this.signalInitialization();else if(!this.isOffline&&!this.initialized)this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired, waiting for initialization."),await this.initializationPromise,e=this.options.cache.getInMemory();else return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - cache is empty or expired."),e;return this.options.logger.debug("AutoPollConfigService.getConfigAsync() - returning value from cache."),e}refreshConfigAsync(){return this.options.logger.debug("AutoPollConfigService.refreshConfigAsync() called."),super.refreshConfigAsync()}dispose(){this.options.logger.debug("AutoPollConfigService.dispose() called."),super.dispose(),this.stopToken.aborted||this.stopRefreshWorker()}onConfigFetched(e,t){this.signalInitialization(),super.onConfigFetched(e,t)}goOnline(){this.stopRefreshWorker(),this.stopToken=new xe,this.startRefreshWorker(null,this.stopToken)}async startRefreshWorker(e,t){for(this.options.logger.debug("AutoPollConfigService.startRefreshWorker() called.");!t.aborted;){try{const i=Ct()+this.pollIntervalMs;try{await this.refreshWorkerLogic(e)}catch(r){this.options.logger.autoPollConfigServiceErrorDuringPolling(r)}const s=i-Ct();s>0&&await Ot(s,t)}catch(i){this.options.logger.autoPollConfigServiceErrorDuringPolling(i)}e=null}}stopRefreshWorker(){this.options.logger.debug("AutoPollConfigService.stopRefreshWorker() called."),this.stopToken.abort()}async refreshWorkerLogic(e){this.options.logger.debug("AutoPollConfigService.refreshWorkerLogic() called.");const t=await(e??this.syncUpWithCache());if(t.isExpired(this.pollExpirationMs)&&(e?!this.isOfflineExactly:!this.isOffline)){await this.refreshConfigCoreAsync(t,!1);return}this.signalInitialization()}getCacheState(e){return e.isEmpty?0:e.isExpired(this.pollIntervalMs)?2:3}}class be{on(){return this}once(){return this}removeListener(){return this}removeAllListeners(){return this}listeners(){return[]}listenerCount(){return 0}eventNames(){return[]}emit(){return!1}}const Ie=be.prototype;Ie.addListener=Ie.on,Ie.off=Ie.removeListener,h.OverrideBehaviour=void 0,(function(n){n[n.LocalOnly=0]="LocalOnly",n[n.LocalOverRemote=1]="LocalOverRemote",n[n.RemoteOverLocal=2]="RemoteOverLocal"})(h.OverrideBehaviour||(h.OverrideBehaviour={}));function we(n){return h.OverrideBehaviour[n]}class Xn{constructor(e,t){this.initialSettings=Wt(e),this.map=t?e:null}getOverrides(){return this.map?Wt(this.map):this.initialSettings}}function Wt(n){const e={};for(const t in n)D(n,t)&&(e[t]=Xe(n[t]));return e}const Zn="cc-",Re=";str";class ei{get currentValue(){if(!(typeof location>"u"||location===null))return location.search}}let Ne;class ti{constructor(e,t,i){this.watchChanges=!!e,this.paramPrefix=t??Zn,i??(i=Ne??(Ne=new ei)),this.queryStringProvider=i;const s=i.currentValue;this.settings=Jt(s,this.paramPrefix),this.queryString=zt(s)}getOverrides(){if(this.watchChanges){const e=this.queryStringProvider.currentValue,t=zt(e);this.queryString!==t&&(this.settings=Jt(e,this.paramPrefix),this.queryString=t)}return this.settings}}function zt(n){if(n==null)return"";if(S(n))return n;let e="",t="?";for(const i in n){if(!D(n,i))continue;const s=n[i];let r,o;if(!M(s))r=s,o=1;else if(s.length)r=s[0],o=s.length;else continue;for(let a=0;e+=t+encodeURIComponent(i)+"="+encodeURIComponent(r),!(++a>=o);)t="&",r=s[a]}return e}function Jt(n,e){const t={};return S(n)?ii(n,e,t):n!=null&&ni(n,e,t),t}function ni(n,e,t){for(const i in n){if(!D(n,i))continue;const s=n[i];let r,o;if(!M(s))r=s,o=1;else if(s.length)r=s[0],o=s.length;else continue;for(let a=0;Gt(i,r,e,t),!(++a>=o);)r=s[a]}}function ii(n,e,t){if(!n||n.lastIndexOf("?",0)<0)return;const i=n.substring(1).split("&");for(let s of i){s=s.replace(/\+/g," ");const r=s.indexOf("="),o=decodeURIComponent(r>=0?s.substring(0,r):s),a=r>=0?decodeURIComponent(s.substring(r+1)):"";Gt(o,a,e,t)}}function Gt(n,e,t,i){if(!n||n.length<=t.length||n.lastIndexOf(t,0)<0)return;n=n.substring(t.length),n.length>Re.length&&n.indexOf(Re,n.length-Re.length)>=0?n=n.substring(0,n.length-Re.length):e=si(e),i[n]=Xe(e)}function si(n){switch(n.toLowerCase()){case"false":return!1;case"true":return!0;default:const e=Je(n);return isNaN(e)?n:e}}function Yt(n){function e(N,j){var He=N<<j|N>>>32-j;return He}var t,i,s,r=new Array(80),o=1732584193,a=4023233417,l=2562383102,c=271733878,f=3285377520,u,g,d,v,A,O;n=oe(n);var y=n.length,T=new Array;for(i=0;i<y-3;i+=4)s=n.charCodeAt(i)<<24|n.charCodeAt(i+1)<<16|n.charCodeAt(i+2)<<8|n.charCodeAt(i+3),T.push(s);switch(y%4){case 0:i=2147483648;break;case 1:i=n.charCodeAt(y-1)<<24|8388608;break;case 2:i=n.charCodeAt(y-2)<<24|n.charCodeAt(y-1)<<16|32768;break;case 3:i=n.charCodeAt(y-3)<<24|n.charCodeAt(y-2)<<16|n.charCodeAt(y-1)<<8|128;break}for(T.push(i);T.length%16!=14;)T.push(0);for(T.push(y>>>29),T.push(y<<3&4294967295),t=0;t<T.length;t+=16){for(i=0;i<16;i++)r[i]=T[t+i];for(i=16;i<=79;i++)r[i]=e(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);for(u=o,g=a,d=l,v=c,A=f,i=0;i<=19;i++)O=e(u,5)+(g&d|~g&v)+A+r[i]+1518500249&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=20;i<=39;i++)O=e(u,5)+(g^d^v)+A+r[i]+1859775393&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=40;i<=59;i++)O=e(u,5)+(g&d|g&v|d&v)+A+r[i]+2400959708&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;for(i=60;i<=79;i++)O=e(u,5)+(g^d^v)+A+r[i]+3395469782&4294967295,A=v,v=d,d=e(g,30),g=u,u=O;o=o+u&4294967295,a=a+g&4294967295,l=l+d&4294967295,c=c+v&4294967295,f=f+A&4294967295}return Qt([o,a,l,c,f])}const ri=Object.create(null);function oi(n){function e(An,On){return An>>>On|An<<32-On}const t="length";var i=Math.pow,s=i(2,32),r,o,a=ri,l=a.h,c=a.k;if(!c){l=[],c=[];for(var f=F(),u=2,g=0;g<64;u++)if(!f[u]){for(r=0;r<313;r+=u)f[r]=u;l[g]=i(u,.5)*s|0,c[g++]=i(u,1/3)*s|0}a.h=l=l.slice(0,8),a.k=c}var d=n[t]*8;n+="";for(var v=[];n[t]%64-56;)n+="\0";for(r=0;r<n[t];r++)o=n.charCodeAt(r),v[r>>2]|=o<<(3-r)%4*8;for(v[v[t]]=d/s|0,v[v[t]]=d,o=0;o<v[t];){var A=v.slice(o,o+=16),O=l;for(l=l.slice(0,8),r=0;r<64;r++){var y=A[r-15],T=A[r-2],N=l[0],j=l[4],He=l[7]+(e(j,6)^e(j,11)^e(j,25))+(j&l[5]^~j&l[6])+c[r]+(A[r]=r<16?A[r]:A[r-16]+(e(y,7)^e(y,18)^y>>>3)+A[r-7]+(e(T,17)^e(T,19)^T>>>10)|0),ji=(e(N,2)^e(N,13)^e(N,22))+(N&l[1]^N&l[2]^l[1]&l[2]);l=[He+ji|0].concat(l),l[4]=l[4]+He|0}for(r=0;r<8;r++)l[r]=l[r]+O[r]|0}return Qt(l,8)}function Qt(n,e){const t="0123456789abcdef";var i="";e??(e=n.length);for(let s=0;s<e;s++)for(let r=3;r>=0;r--){const o=n[s]>>(r<<3)&255;i+=t[o>>4],i+=t[o&15]}return i}const Xt=new be;class ct{constructor(e){this.eventEmitter=e;const t=Object.create(null);t.get=()=>this.configCatClient,t.enumerable=!0,Object.defineProperty(e,"configCatClient",t)}tryDisconnect(){const e=this.eventEmitter;return this.eventEmitter=Xt,e!==Xt}on(e,t){return this.eventEmitter.on(e,t),this}once(e,t){return this.eventEmitter.once(e,t),this}removeListener(e,t){return this.eventEmitter.removeListener(e,t),this}removeAllListeners(e){return this.eventEmitter.removeAllListeners(e),this}listeners(e){return this.eventEmitter.listeners(e)}listenerCount(e){return this.eventEmitter.listenerCount(e)}eventNames(){return this.eventEmitter.eventNames()}emit(e,...t){return this.eventEmitter.emit(e,...t)}}const Fe=ct.prototype;Fe.addListener=Fe.on,Fe.off=Fe.removeListener;class ai extends lt{constructor(e){super(e),this.cacheTimeToLiveMs=e.cacheTimeToLiveSeconds*1e3,this.prepareClientForEvents();const t=this.syncUpWithCache();this.readyPromise=this.getReadyPromise(t)}async getConfigAsync(){this.options.logger.debug("LazyLoadConfigService.getConfigAsync() called.");function e(i,s=""){i.debug(`LazyLoadConfigService.getConfigAsync(): cache is empty or expired${s}.`)}let t=await this.syncUpWithCache();return t.isExpired(this.cacheTimeToLiveMs)?(this.isOffline?e(this.options.logger):(e(this.options.logger,", calling refreshConfigCoreAsync()"),[,t]=await this.refreshConfigCoreAsync(t,!1)),t):(this.options.logger.debug("LazyLoadConfigService.getConfigAsync(): cache is valid, returning from cache."),t)}refreshConfigAsync(){return this.options.logger.debug("LazyLoadConfigService.refreshConfigAsync() called."),super.refreshConfigAsync()}getCacheState(e){return e.isEmpty?0:e.isExpired(this.cacheTimeToLiveMs)?2:3}}class li extends lt{constructor(e){super(e),this.prepareClientForEvents();const t=this.syncUpWithCache();this.readyPromise=this.getReadyPromise(t)}getCacheState(e){return e.isEmpty?0:2}async getConfigAsync(){return this.options.logger.debug("ManualPollService.getConfigAsync() called."),await this.syncUpWithCache()}refreshConfigAsync(){return this.options.logger.debug("ManualPollService.refreshConfigAsync() called."),super.refreshConfigAsync()}}const ut="configcat-proxy/";h.PollingMode=void 0,(function(n){n[n.AutoPoll=0]="AutoPoll",n[n.LazyLoad=1]="LazyLoad",n[n.ManualPoll=2]="ManualPoll"})(h.PollingMode||(h.PollingMode={})),h.DataGovernance=void 0,(function(n){n[n.Global=0]="Global",n[n.EuOnly=1]="EuOnly"})(h.DataGovernance||(h.DataGovernance={}));function ci(n){return h.DataGovernance[n]}class X{constructor(e,t,i,s){var r,o,a,l;this.requestTimeoutMs=3e4,this.dataGovernance=0,this.flagOverrides=null,this.defaultUser=void 0,this.offline=!1,this.sdkKey=e,this.clientVersion=i;const c=(o=(r=t.eventEmitterFactory)===null||r===void 0?void 0:r.call(t))!==null&&o!==void 0?o:new be,f=new ct(c);this.hooks={hooks:f,unwrap(){return this.hooks},emit(O,...y){var T,N;return(N=(T=this.unwrap())===null||T===void 0?void 0:T.emit(O,...y))!==null&&N!==void 0?N:!1}};let u,g,d,v,A;if(s){const O="options";if(s.logFilter!=null&&(u=Ft(s.logFilter,O,".logFilter")),s.logger!=null){const y=F();y.log=!0,g=_(s.logger,O,y,".logger")}if(s.cache!=null){const y=F();y.get=y.set=!0,d=_(s.cache,O,y,".cache")}if(s.configFetcher!=null){const y=F();y.fetchAsync=!0,v=_(s.configFetcher,O,y,".configFetcher")}if(s.requestTimeoutMs!=null&&(this.requestTimeoutMs=Ae(s.requestTimeoutMs,O,"greater than 0",y=>y>0,".requestTimeoutMs")),s.dataGovernance!=null&&(this.dataGovernance=ee(s.dataGovernance,O,"DataGovernance",y=>ci(y)!==void 0,".dataGovernance")),s.baseUrl!=null&&(A=Y(s.baseUrl,O,!0,".baseUrl")),s.flagOverrides!=null){const y=F();y.behaviour=y.dataSource=!1;const T=_(s.flagOverrides,O,y,".flagOverrides");ee(T.behaviour,O,"OverrideBehaviour",j=>we(j)!==void 0,".flagOverrides.behaviour");const N=F();N.getOverrides=!0,_(T.dataSource,O,N,".flagOverrides.dataSource"),this.flagOverrides=T}s.defaultUser!=null&&(this.defaultUser=_(s.defaultUser,O,void 0,".defaultUser")),s.offline!=null&&(this.offline=We(s.offline,O,".offline")),s.setupHooks!=null&&Ft(s.setupHooks,O,".setupHooks")(f)}(this.baseUrlOverriden=A!=null)?this.baseUrl=A:this.baseUrl=this.dataGovernance===1?"https://cdn-eu.configcat.com":"https://cdn-global.configcat.com",this.logger=new zn(g??new qt,u,this.hooks),this.cache=d?new Ce(d,this.logger):(l=(a=t.defaultCacheFactory)===null||a===void 0?void 0:a.call(t,this))!==null&&l!==void 0?l:new Pt,this.configFetcher=v??t.configFetcherFactory(this)}yieldHooks(){var e;const t=this.hooks,i=(e=t.unwrap())!==null&&e!==void 0?e:new ct(new be);return t.hooks=Tt(i),t.unwrap=function(){return this.hooks.deref()},i}getUrl(){const{baseUrl:e}=this;return e+(e.charCodeAt(e.length-1)!==47?"/":"")+"configuration-files/"+this.sdkKey+"/"+X.configFileName+"?sdk="+this.clientVersion}getCacheKey(){return Yt(`${this.sdkKey}_${X.configFileName}_${b.serializationFormatVersion}`)}}X.configFileName="config_v6.json";const Zt="/"+ut,ui=/^https?:\/\/(?:[a-z0-9-]+\.)+configcat\.com\.?(?:[:/]|$)/i;function en(n){if(!ui.test(n))return!1;let e=n.indexOf("?");return e=n.lastIndexOf(Zt,(e>=0?e:n.length)-Zt.length),e<0}class fi extends X{constructor(e,t,i){if(super(e,t,t.sdkType+"/a-"+t.sdkVersion,i),this.pollIntervalSeconds=60,this.maxInitWaitTimeSeconds=5,i){const s="options";i.pollIntervalSeconds!=null&&(this.pollIntervalSeconds=Ae(i.pollIntervalSeconds,s,"between 1 and 2147483",l=>It(l,1,2147483),".pollIntervalSeconds")),i.maxInitWaitTimeSeconds!=null&&(this.maxInitWaitTimeSeconds=Ae(i.maxInitWaitTimeSeconds,s,"less than or equal to 2147483",a=>a<=2147483,".maxInitWaitTimeSeconds"))}}createConfigService(){return new Qn(this)}}class hi extends X{constructor(e,t,i){super(e,t,t.sdkType+"/m-"+t.sdkVersion,i)}createConfigService(){return new li(this)}}class gi extends X{constructor(e,t,i){if(super(e,t,t.sdkType+"/l-"+t.sdkVersion,i),this.cacheTimeToLiveSeconds=60,i){const s="options";i.cacheTimeToLiveSeconds!=null&&(this.cacheTimeToLiveSeconds=Ae(i.cacheTimeToLiveSeconds,s,"between 1 and 2147483647",a=>It(a,1,2147483647),".cacheTimeToLiveSeconds")),i.cacheTimeToLiveSeconds!=null&&(this.cacheTimeToLiveSeconds=i.cacheTimeToLiveSeconds)}}createConfigService(){return new ai(this)}}const tn="<invalid value>",di="<invalid name>",ft="<invalid operator>",nn="<invalid reference>",vi=10;class sn{constructor(e){this.eol=e,this.log="",this.indent=""}resetIndent(){return this.indent="",this}increaseIndent(){return this.indent+=" ",this}decreaseIndent(){return this.indent=this.indent.slice(0,-2),this}newLine(e){return this.log+=this.eol+this.indent+(e??""),this}append(e){return this.log+=e,this}toString(){return this.log}appendUserConditionCore(e,t,i){return this.append(`User.${e} ${ht(t)} '${i??tn}'`)}appendUserConditionString(e,t,i,s){return i==null?this.appendUserConditionCore(e,t):this.appendUserConditionCore(e,t,s?"<hashed value>":i)}appendUserConditionStringList(e,t,i,s){if(i==null)return this.appendUserConditionCore(e,t);const r="value",o="values",a=ht(t);if(s)return this.append(`User.${e} ${a} [<${i.length} hashed ${i.length===1?r:o}>]`);{const l=ze(i,vi,c=>`, ... <${c} more ${c===1?r:o}>`);return this.append(`User.${e} ${a} [${l}]`)}}appendUserConditionNumber(e,t,i,s){if(i==null)return this.appendUserConditionCore(e,t);const r=ht(t);let o;return s&&!isNaN(o=new Date(i*1e3))?this.append(`User.${e} ${r} '${i}' (${o.toISOString()} UTC)`):this.append(`User.${e} ${r} '${i}'`)}appendUserCondition(e){const t=e.a,i=e.c;switch(i){case 0:case 1:case 2:case 3:case 4:case 5:case 30:case 31:case 32:case 33:case 34:case 35:return this.appendUserConditionStringList(t,i,e.l,!1);case 6:case 7:case 8:case 9:case 28:case 29:return this.appendUserConditionString(t,i,e.s,!1);case 10:case 11:case 12:case 13:case 14:case 15:return this.appendUserConditionNumber(t,i,e.d);case 16:case 17:case 22:case 23:case 24:case 25:case 26:case 27:return this.appendUserConditionStringList(t,i,e.l,!0);case 18:case 19:return this.appendUserConditionNumber(t,i,e.d,!0);case 20:case 21:return this.appendUserConditionString(t,i,e.s,!0);default:{const s=yi(e);return S(s)?this.appendUserConditionString(t,i,s,!1):W(s)?this.appendUserConditionNumber(t,i,s):s?this.appendUserConditionCore(t,i):this.appendUserConditionStringList(t,i,s,!1)}}}appendPrerequisiteFlagCondition(e,t){const i=D(t,e.f)?e.f:nn,s=e.c,r=on(e.v);return this.append(`Flag '${i}' ${pi(s)} '${ue(r)}'`)}appendSegmentCondition(e,t){const i=e.s;let s;t&&Ke(i,0,t.length-1)?(s=t[i].n,s.length||(s=di)):s=nn;const r=e.c;return this.append(`User ${rn(r)} '${s}'`)}appendConditionResult(e){return this.append(`${e}`)}appendConditionConsequence(e){return this.append(" => ").appendConditionResult(e),e?this:this.append(", skipping the remaining AND conditions")}appendTargetingRuleThenPart(e,t,i){if((i?this.newLine():this.append(" ")).append("THEN"),!rt(e,!0)){const s=e.s,r=q(s.v,t,!0);return this.append(` '${ue(r)}'`)}return this.append(" % options")}appendTargetingRuleConsequence(e,t,i,s){return this.increaseIndent(),this.appendTargetingRuleThenPart(e,t,s).append(" => ").append(i===!0?"MATCH, applying rule":i===!1?"no match":i),this.decreaseIndent()}}function ht(n){switch(n){case 0:case 16:case 4:return"IS ONE OF";case 1:case 17:case 5:return"IS NOT ONE OF";case 2:return"CONTAINS ANY OF";case 3:return"NOT CONTAINS ANY OF";case 6:case 12:return"<";case 7:case 13:return"<=";case 8:case 14:return">";case 9:case 15:return">=";case 10:return"=";case 11:return"!=";case 18:return"BEFORE";case 19:return"AFTER";case 28:case 20:return"EQUALS";case 29:case 21:return"NOT EQUALS";case 30:case 22:return"STARTS WITH ANY OF";case 31:case 23:return"NOT STARTS WITH ANY OF";case 32:case 24:return"ENDS WITH ANY OF";case 33:case 25:return"NOT ENDS WITH ANY OF";case 34:case 26:return"ARRAY CONTAINS ANY OF";case 35:case 27:return"ARRAY NOT CONTAINS ANY OF";default:return ft}}function gt(n){return new sn("").appendUserCondition(n).toString()}function pi(n){switch(n){case 0:return"EQUALS";case 1:return"NOT EQUALS";default:return ft}}function rn(n){switch(n){case 0:return"IS IN SEGMENT";case 1:return"IS NOT IN SEGMENT";default:return ft}}function ue(n){return st(n)?n.toString():tn}function on(n){let e,t;if(e=n.b,t=n.s,t!=null){if(e!=null)return;e=t}if(t=n.i,t!=null){if(e!=null)return;e=t}if(t=n.d,t!=null){if(e!=null)return;e=t}return e??void 0}function yi(n){let e,t;if(e=n.s,t=n.d,t!=null){if(e!=null)return;e=t}if(t=n.l,t!=null){if(e!=null)return;e=t}return e??void 0}const an=/^[0-9]+$/,fe=(n,e)=>{const t=an.test(n),i=an.test(e);return t&&i&&(n=+n,e=+e),n===e?0:t&&!i?-1:i&&!t?1:n<e?-1:1},dt=256,Le=Number.MAX_SAFE_INTEGER||9007199254740991,he=[],C=[],E={};let mi=0;const w=(n,e)=>{const t=mi++;E[n]=t,C[t]=e,he[t]=new RegExp(e)};w("NUMERICIDENTIFIER","0|[1-9]\\d*"),w("NUMERICIDENTIFIERLOOSE","[0-9]+"),w("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),w("MAINVERSION",`(${C[E.NUMERICIDENTIFIER]})\\.(${C[E.NUMERICIDENTIFIER]})\\.(${C[E.NUMERICIDENTIFIER]})`),w("MAINVERSIONLOOSE",`(${C[E.NUMERICIDENTIFIERLOOSE]})\\.(${C[E.NUMERICIDENTIFIERLOOSE]})\\.(${C[E.NUMERICIDENTIFIERLOOSE]})`),w("PRERELEASEIDENTIFIER",`(?:${C[E.NUMERICIDENTIFIER]}|${C[E.NONNUMERICIDENTIFIER]})`),w("PRERELEASEIDENTIFIERLOOSE",`(?:${C[E.NUMERICIDENTIFIERLOOSE]}|${C[E.NONNUMERICIDENTIFIER]})`),w("PRERELEASE",`(?:-(${C[E.PRERELEASEIDENTIFIER]}(?:\\.${C[E.PRERELEASEIDENTIFIER]})*))`),w("PRERELEASELOOSE",`(?:-?(${C[E.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${C[E.PRERELEASEIDENTIFIERLOOSE]})*))`),w("BUILDIDENTIFIER","[0-9A-Za-z-]+"),w("BUILD",`(?:\\+(${C[E.BUILDIDENTIFIER]}(?:\\.${C[E.BUILDIDENTIFIER]})*))`),w("FULLPLAIN",`v?${C[E.MAINVERSION]}${C[E.PRERELEASE]}?${C[E.BUILD]}?`),w("FULL",`^${C[E.FULLPLAIN]}$`),w("LOOSEPLAIN",`[v=\\s]*${C[E.MAINVERSIONLOOSE]}${C[E.PRERELEASELOOSE]}?${C[E.BUILD]}?`),w("LOOSE",`^${C[E.LOOSEPLAIN]}$`);class U{constructor(e,t){if((!t||typeof t!="object")&&(t={loose:!!t,includePrerelease:!1}),e instanceof U){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw TypeError(`Invalid Version: ${e}`);if(e.length>dt)throw TypeError(`version is longer than ${dt} characters`);this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const i=e.trim().match(t.loose?he[E.LOOSE]:he[E.FULL]);if(!i)throw TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>Le||this.major<0)throw TypeError("Invalid major version");if(this.minor>Le||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>Le||this.patch<0)throw TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map(s=>{if(/^[0-9]+$/.test(s)){const r=+s;if(r>=0&&r<Le)return r}return s}):this.prerelease=[],this.build=i[5]?i[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(!(e instanceof U)){if(typeof e=="string"&&e===this.version)return 0;e=new U(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof U||(e=new U(e,this.options)),fe(this.major,e.major)||fe(this.minor,e.minor)||fe(this.patch,e.patch)}comparePre(e){if(e instanceof U||(e=new U(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;let t=0;do{const i=this.prerelease[t],s=e.prerelease[t];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(i===s)continue;return fe(i,s)}while(++t)}compareBuild(e){e instanceof U||(e=new U(e,this.options));let t=0;do{const i=this.build[t],s=e.build[t];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(i===s)continue;return fe(i,s)}while(++t)}inc(e,t){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t),this.inc("pre",t);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{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);i===-1&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw Error(`invalid increment argument: ${e}`)}return this.format(),this.raw=this.version,this}}const vt=(n,e)=>{if((!e||typeof e!="object")&&(e={loose:!!e,includePrerelease:!1}),n instanceof U)return n;if(typeof n!="string"||n.length>dt||!(e.loose?he[E.LOOSE]:he[E.FULL]).test(n))return null;try{return new U(n,e)}catch{return null}};class Ei{constructor(e,t,i,s={}){this.identifier=e,this.email=t,this.country=i,this.custom=s}}function ln(n){var e;return(e=n.identifier)!==null&&e!==void 0?e:""}function cn(n,e){switch(e){case"Identifier":return ln(n);case"Email":return n.email;case"Country":return n.country;default:return n.custom&&D(n.custom,e)?n.custom[e]:void 0}}function un(n){var e;const t=F(),i="Identifier",s="Email",r="Country";if(t[i]=(e=n.identifier)!==null&&e!==void 0?e:"",n.email!=null&&(t[s]=n.email),n.country!=null&&(t[r]=n.country),n.custom!=null){const o=[i,s,r];for(const a in n.custom){let l;D(n.custom,a)&&(l=n.custom[a])!=null&&o.indexOf(a)<0&&(t[a]=l)}}return t}class ge{get settingType(){var e;return(e=this._settingType)!==null&&e!==void 0?e:this._settingType=nt(this.setting)}get visitedFlags(){var e;return(e=this._visitedFlags)!==null&&e!==void 0?e:this._visitedFlags=[]}constructor(e,t,i,s){this.key=e,this.setting=t,this.user=i,this.settings=s,this._settingType=void 0,this._visitedFlags=void 0,this.isMissingUserObjectLogged=!1,this.isMissingUserObjectAttributeLogged=!1}static forPrerequisiteFlag(e,t,i){const s=new ge(e,t,i.user,i.settings);return s._visitedFlags=i.visitedFlags,s.logBuilder=i.logBuilder,s}}const fn="The current targeting rule is ignored and the evaluation continues with the next rule.",pt="cannot evaluate, User Object is missing",Si=n=>`cannot evaluate, the User.${n} attribute is missing`,Ai=(n,e)=>`cannot evaluate, the User.${n} attribute is invalid (${e})`;class Oi{constructor(e){this.logger=e}evaluate(e,t){this.logger.debug("RolloutEvaluator.evaluate() called.");const i=t.logBuilder=this.logger.isEnabled(3)?new sn(this.logger.eol):null;i&&(i.append(`Evaluating '${t.key}'`),t.user&&i.append(` for User '${JSON.stringify(un(t.user))}'`),i.increaseIndent());let s;try{const r=t.settingType,o=r!==-1?r:it(t.setting.v);if(e!=null&&o!==void 0&&!Bn(e,o)){const l=Vn(o);throw new ve(2,`The type of a setting must match the type of the specified default value. Setting's type was ${l} but the default value's type was ${typeof e}. Please use a default value which corresponds to the setting type ${l}. Learn more: https://configcat.com/docs/sdk-reference/js/overview/#setting-type-mapping`)}const a=this.evaluateSetting(t);return a.returnValue=s=q(a.selectedValue.v,r),a}catch(r){throw i?.resetIndent().increaseIndent(),s=e,r}finally{i&&(i.newLine(`Returning '${s}'.`).decreaseIndent(),this.logger.settingEvaluated(i.toString()))}}evaluateSetting(e){let t;const i=e.setting.r;if(i?.length&&(t=this.evaluateTargetingRules(i,e)))return t;const s=e.setting.p;return s?.length&&(t=this.evaluatePercentageOptions(s,void 0,e))?t:yt(e.setting)}evaluateTargetingRules(e,t){const i=t.logBuilder;i?.newLine("Evaluating targeting rules and applying the first match if any:");for(let s=0;s<e.length;s++){const r=e[s],o=r.c,a=this.evaluateConditions(o,void 0,r,t.key,t);if(a!==!0){S(a)&&i?.increaseIndent().newLine(fn).decreaseIndent();continue}if(!rt(r))return yt(r.s,r);const l=r.p;i?.increaseIndent();const c=this.evaluatePercentageOptions(l,r,t);if(c)return i?.decreaseIndent(),c;i?.newLine(fn).decreaseIndent()}}evaluatePercentageOptions(e,t,i){const s=i.logBuilder;if(!i.user){s?.newLine("Skipping % options because the User Object is missing."),i.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(i.key),i.isMissingUserObjectLogged=!0);return}let r=i.setting.a,o;if(r==null?(r="Identifier",o=ln(i.user)):o=cn(i.user,r),o==null){s?.newLine(`Skipping % options because the User.${r} attribute is missing.`),i.isMissingUserObjectAttributeLogged||(this.logger.userObjectAttributeIsMissingPercentage(i.key,r),i.isMissingUserObjectAttributeLogged=!0);return}s?.newLine(`Evaluating % options based on the User.${r} attribute:`);const a=Yt(i.key+gn(o)),l=parseInt(a.substring(0,7),16)%100;s?.newLine(`- Computing hash in the [0..99] range from User.${r} => ${l} (this value is sticky and consistent across all SDKs)`);let c=0;for(let f=0;f<e.length;f++){const u=e[f],g=u.p;if(g<0&&I("Percentage option percentage is invalid."),c+=g,!(l>=c)){if(s){const d=q(u.v,i.settingType,!0);s.newLine(`- Hash value ${l} selects % option ${f+1} (${g}%), '${ue(d)}'.`)}return yt(u,t,u)}}I("Sum of percentage option percentages is less than 100.")}evaluateConditions(e,t,i,s,r){var o;let a=!0;const l=r.logBuilder;let c=!1;l?.newLine("- ");const f=!t;for(let u=0,g=(o=e?.length)!==null&&o!==void 0?o:0;u<g;u++){let d;if(f){const A=e[u];t=Wn(A),d=A[t]}else d=e[u];switch(l&&(u?l.increaseIndent().newLine("AND "):l.append("IF ").increaseIndent()),t){case"u":a=this.evaluateUserCondition(d,s,r),c=g>1;break;case"p":a=this.evaluatePrerequisiteFlagCondition(d,r),c=!0;break;case"s":a=this.evaluateSegmentCondition(d,r),c=!S(a)||a!==pt||g>1;break;default:throw Error()}const v=a===!0;if(l&&((!i||g>1)&&l.appendConditionConsequence(v),l.decreaseIndent()),!v)break}return i&&l?.appendTargetingRuleConsequence(i,r.settingType,a,c),a}evaluateUserCondition(e,t,i){const s=i.logBuilder;if(s?.appendUserCondition(e),!i.user)return i.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(i.key),i.isMissingUserObjectLogged=!0),pt;const r=e.a,o=cn(i.user,r);if(o==null||o===""){const g=new ae(e,d=>gt(d));return this.logger.userObjectAttributeIsMissingCondition(g,i.key,r),Si(r)}let a,l,c,f;const u=e.c;switch(u){case 28:case 29:return a=K(r,o,e,i.key,this.logger),this.evaluateTextEquals(a,R(e.s),u===29);case 20:case 21:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextEquals(a,R(e.s),de(i.setting),t,u===21);case 0:case 1:return a=K(r,o,e,i.key,this.logger),this.evaluateTextIsOneOf(a,R(e.l),u===1);case 16:case 17:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextIsOneOf(a,R(e.l),de(i.setting),t,u===17);case 30:case 31:return a=K(r,o,e,i.key,this.logger),this.evaluateTextSliceEqualsAnyOf(a,R(e.l),!0,u===31);case 22:case 23:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(a,R(e.l),de(i.setting),t,!0,u===23);case 32:case 33:return a=K(r,o,e,i.key,this.logger),this.evaluateTextSliceEqualsAnyOf(a,R(e.l),!1,u===33);case 24:case 25:return a=K(r,o,e,i.key,this.logger),this.evaluateSensitiveTextSliceEqualsAnyOf(a,R(e.l),de(i.setting),t,!1,u===25);case 2:case 3:return a=K(r,o,e,i.key,this.logger),this.evaluateTextContainsAnyOf(a,R(e.l),u===3);case 4:case 5:return l=dn(r,o,e,i.key,this.logger),S(l)?l:this.evaluateSemVerIsOneOf(l,R(e.l),u===5);case 6:case 7:case 8:case 9:return l=dn(r,o,e,i.key,this.logger),S(l)?l:this.evaluateSemVerRelation(l,u,R(e.s));case 10:case 11:case 12:case 13:case 14:case 15:return c=Ci(r,o,e,i.key,this.logger),S(c)?c:this.evaluateNumberRelation(c,u,R(e.d));case 18:case 19:return c=Ti(r,o,e,i.key,this.logger),S(c)?c:this.evaluateDateTimeRelation(c,R(e.d),u===18);case 34:case 35:return f=vn(r,o,e,i.key,this.logger),S(f)?f:this.evaluateArrayContainsAnyOf(f,R(e.l),u===35);case 26:case 27:return f=vn(r,o,e,i.key,this.logger),S(f)?f:this.evaluateSensitiveArrayContainsAnyOf(f,R(e.l),de(i.setting),t,u===27);default:I("Comparison operator is invalid.")}}evaluateTextEquals(e,t,i){return e===t!==i}evaluateSensitiveTextEquals(e,t,i,s,r){return mt(e,i,s)===t!==r}evaluateTextIsOneOf(e,t,i){return t.indexOf(e)>=0!==i}evaluateSensitiveTextIsOneOf(e,t,i,s,r){const o=mt(e,i,s);return t.indexOf(o)>=0!==r}evaluateTextSliceEqualsAnyOf(e,t,i,s){for(let r=0;r<t.length;r++){const o=t[r];if(e.length<o.length)continue;if((i?e.lastIndexOf(o,0):e.indexOf(o,e.length-o.length))>=0)return!s}return s}evaluateSensitiveTextSliceEqualsAnyOf(e,t,i,s,r,o){const a=oe(e);for(let l=0;l<t.length;l++){const c=t[l];let f,u;const g=c.indexOf("_");if((g<0||isNaN(f=bn(c.slice(0,g)))||f<0||!(u=c.slice(g+1)))&&I("Comparison value is invalid."),a.length<f)continue;const d=r?a.slice(0,f):a.slice(a.length-f);if(hn(d,i,s)===u)return!o}return o}evaluateTextContainsAnyOf(e,t,i){for(let s=0;s<t.length;s++)if(e.indexOf(t[s])>=0)return!i;return i}evaluateSemVerIsOneOf(e,t,i){let s=!1;for(let r=0;r<t.length;r++){const o=t[r];if(!o.length)continue;const a=vt(o.trim());if(!a)return!1;!s&&e.compare(a)===0&&(s=!0)}return s!==i}evaluateSemVerRelation(e,t,i){const s=vt(i.trim());if(!s)return!1;const r=e.compare(s);switch(t){case 6:return r<0;case 7:return r<=0;case 8:return r>0;case 9:return r>=0}}evaluateNumberRelation(e,t,i){switch(t){case 10:return e===i;case 11:return e!==i;case 12:return e<i;case 13:return e<=i;case 14:return e>i;case 15:return e>=i}}evaluateDateTimeRelation(e,t,i){return i?e<t:e>t}evaluateArrayContainsAnyOf(e,t,i){for(let s=0;s<e.length;s++)if(t.indexOf(e[s])>=0)return!i;return i}evaluateSensitiveArrayContainsAnyOf(e,t,i,s,r){for(let o=0;o<e.length;o++){const a=mt(e[o],i,s);if(t.indexOf(a)>=0)return!r}return r}evaluatePrerequisiteFlagCondition(e,t){const i=t.logBuilder;i?.appendPrerequisiteFlagCondition(e,t.settings);const s=e.f,r=D(t.settings,s)?t.settings[s]:I("Prerequisite flag is missing."),o=nt(r);let a,l;if(o!==-1)a=o,l=q(e.v,o,!0);else if(a=it(r.v),a!==void 0&&(l=q(e.v,a,!0),a===3)){const v=q(e.v,2,!0);l===void 0?l=v:v!==void 0&&(l=void 0)}l===void 0&&a!==void 0&&(l=on(e.v),I(`Type mismatch between comparison value '${ue(l)}' and prerequisite flag '${s}'.`));const c=t.visitedFlags;if(c.push(t.key),c.indexOf(s)>=0){c.push(s);const v=ze(c,void 0,void 0," -> ");I(`Circular dependency detected between the following depending flags: ${v}.`)}const f=ge.forPrerequisiteFlag(s,r,t);i?.newLine("(").increaseIndent().newLine(`Evaluating prerequisite flag '${s}':`);const u=this.evaluateSetting(f);c.pop();const g=q(u.selectedValue.v,o);let d;switch(e.c){case 0:d=g===l;break;case 1:d=g!==l;break;default:I("Comparison operator is invalid.")}return i?.newLine(`Prerequisite flag evaluation result: '${ue(g)}'.`).newLine("Condition (").appendPrerequisiteFlagCondition(e,t.settings).append(") evaluates to ").appendConditionResult(d).append(".").decreaseIndent().newLine(")"),d}evaluateSegmentCondition(e,t){const i=t.setting._configSegments,s=t.logBuilder;if(s?.appendSegmentCondition(e,i),!t.user)return t.isMissingUserObjectLogged||(this.logger.userObjectIsMissing(t.key),t.isMissingUserObjectLogged=!0),pt;const r=e?.s;(!i||!Ke(r,0,i.length-1))&&I("Segment reference is invalid.");const o=i[r],a=o?.n;a.length||I("Segment name is missing."),s?.newLine("(").increaseIndent().newLine(`Evaluating segment '${a}':`);const l=o?.r,c=this.evaluateConditions(l,"u",void 0,a,t);let f=c;if(!S(f))switch(e.c){case 0:break;case 1:f=!f;break;default:I("Comparison operator is invalid.")}return s&&(s.newLine("Segment evaluation result: "),(S(f)?s.append(f):s.append(`User ${rn(c?0:1)}`)).append("."),s.newLine("Condition (").appendSegmentCondition(e,i).append(")"),(S(f)?s.append(" failed to evaluate"):s.append(" evaluates to ").appendConditionResult(f)).append("."),s.decreaseIndent().newLine(")")),f}}function yt(n,e,t){return{selectedValue:n,matchedTargetingRule:e,matchedPercentageOption:t}}function mt(n,e,t){return hn(oe(n),e,t)}function hn(n,e,t){return oi(n+oe(e)+oe(t))}function gn(n){return S(n)?n:n instanceof Date?String(n.getTime()/1e3):wt(n)?JSON.stringify(n):L(n)}function K(n,e,t,i,s){if(S(e))return e;e=gn(e);const r=new ae(t,o=>gt(o));return s.userObjectAttributeIsAutoConverted(r,i,n,e),e}function dn(n,e,t,i,s){let r;return S(e)&&(r=vt(e.trim()))?r:De(s,t,i,n,`'${L(e)}' is not a valid semantic version`)}function Ci(n,e,t,i,s){if(W(e))return e;let r;return S(e)&&(!isNaN(r=Je(e.replace(",",".")))||e.trim()==="NaN")?r:De(s,t,i,n,`'${L(e)}' is not a valid decimal number`)}function Ti(n,e,t,i,s){if(e instanceof Date)return e.getTime()/1e3;if(W(e))return e;let r;return S(e)&&(!isNaN(r=Je(e.replace(",",".")))||e.trim()==="NaN")?r:De(s,t,i,n,`'${L(e)}' is not a valid Unix timestamp (number of seconds elapsed since Unix epoch)`)}function vn(n,e,t,i,s){let r=e;if(S(r))try{r=JSON.parse(r)}catch{}return wt(r)?r:De(s,t,i,n,`'${L(e)}' is not a valid string array`)}function De(n,e,t,i,s){const r=new ae(e,o=>gt(o));return n.userObjectAttributeIsInvalid(r,t,s,i),Ai(i,s)}function de(n){var e;return(e=n._configJsonSalt)!==null&&e!==void 0?e:I("Config JSON salt is missing.")}function R(n){return n??I("Comparison value is missing.")}h.EvaluationErrorCode=void 0,(function(n){n[n.UnexpectedError=-1]="UnexpectedError",n[n.None=0]="None",n[n.InvalidConfigModel=1]="InvalidConfigModel",n[n.SettingValueTypeMismatch=2]="SettingValueTypeMismatch",n[n.ConfigJsonNotAvailable=1e3]="ConfigJsonNotAvailable",n[n.SettingKeyMissing=1001]="SettingKeyMissing"})(h.EvaluationErrorCode||(h.EvaluationErrorCode={}));function pn(n,e,t,i){return{key:n,value:e.returnValue,variationId:e.selectedValue.i,fetchTime:t,user:i,isDefaultValue:!1,matchedTargetingRule:e.matchedTargetingRule,matchedPercentageOption:e.matchedPercentageOption,errorCode:0}}function Z(n,e,t,i,s,r,o=-1){return{key:n,value:e,fetchTime:t,user:i,isDefaultValue:!0,errorCode:o,_errorMessage:s,get errorMessage(){var a;return(a=this._errorMessage)===null||a===void 0?void 0:a.toString()},errorException:r}}function ke(n,e,t,i,s,r,o){let a;if(!e)return a=o.configJsonIsNotPresentSingle(t,"defaultValue",i),Z(t,i,V(r),s,B(a),void 0,1e3);if(!D(e,t)){const c=new ae(e,f=>ze(Object.keys(f)));return a=o.settingEvaluationFailedDueToMissingKey(t,"defaultValue",i,c),Z(t,i,V(r),s,B(a),void 0,1001)}const l=n.evaluate(i,new ge(t,e[t],s,e));return pn(t,l,V(r),s)}function yn(n,e,t,i,s,r){let o;if(!Et(e,s,r))return[[],o];const a=[];for(const l in e){if(!D(e,l))continue;const c=e[l];let f;try{const u=n.evaluate(null,new ge(l,c,t,e));f=pn(l,u,V(i),t)}catch(u){o??(o=[]),o.push(u),f=Z(l,null,V(i),t,G(u),u,pe(u))}a.push(f)}return[a,o]}function Et(n,e,t){return n?!0:(e.configJsonIsNotPresent(t),!1)}function mn(n,e,t,i){if(!Et(n,t,i))return null;for(const s in n){if(!D(n,s))continue;const r=n[s],o=nt(r);if(e===r.i)return{settingKey:s,settingValue:q(r.v,o)};const a=r.r;if(a?.length)for(let c=0;c<a.length;c++){const f=a[c];if(rt(f)){const u=f.p;for(let g=0;g<u.length;g++){const d=u[g];if(e===d.i)return{settingKey:s,settingValue:q(d.v,o)}}}else{const u=f.s;if(e===u.i)return{settingKey:s,settingValue:q(u.v,o)}}}const l=r.p;if(l?.length)for(let c=0;c<l.length;c++){const f=l[c];if(e===f.i)return{settingKey:s,settingValue:q(f.v,o)}}}return t.settingForVariationIdIsNotPresent(e),null}class ve extends Error{constructor(e,t){super(t),this.errorCode=e,this.message=t,this.name=ve.name,je(this,ve)}}function pe(n){return n instanceof Error?n instanceof ve?n.errorCode:n instanceof le?1:-1:-1}class bi{constructor(){this.instances=F()}getOrCreate(e){let t;const i=this.instances[e.sdkKey];if(i){const[r]=i;if(t=r.deref(),t)return[t,!0]}const s={};return t=new J(e,s),this.instances[e.sdkKey]=[Tt(t),s],[t,!1]}remove(e,t){const i=this.instances[e];if(i){const[s,r]=i,o=!!s.deref();if(!o||r===t)return delete this.instances[e],o}return!1}clear(){const e=[];for(const t in this.instances){const[i]=this.instances[t],s=i.deref();s&&e.push(s),delete this.instances[t]}return e}}const ye=new bi;class J{static get instanceCache(){return ye}static get(e,t,i,s){var r;Y(e,"sdkKey",!0),i==null||_(i,"options");const o=t===0?new fi(e,s,i):t===2?new hi(e,s,i):t===1?new gi(e,s,i):ee(t,"pollingMode","PollingMode",()=>!1);((r=o.flagOverrides)===null||r===void 0?void 0:r.behaviour)!==0&&!Ii(e,o.baseUrlOverriden)&&Q("sdkKey",`Expected a string matching the SDK Key format, got '${L(e)}'.`);const[a,l]=ye.getOrCreate(o);return l&&i&&o.logger.clientIsAlreadyCreated(e),a}constructor(e,t){var i;this.cacheToken=t,this.options=e,e.logger.isEnabled(4)&&e.logger.debug(m.from("OPTIONS")`Initializing ConfigCatClient. Options: ${JSON.stringify(wi(e))}`),this.hooks=e.yieldHooks(),this.hooks.configCatClient=this,this.defaultUser=e.defaultUser,this.evaluator=new Oi(e.logger),((i=e.flagOverrides)===null||i===void 0?void 0:i.behaviour)!==0?this.configService=e.createConfigService():(this.configService=null,this.hooks.emit("clientReady",1)),this.suppressFinalize=Pe(this,{sdkKey:e.sdkKey,cacheToken:t,configService:this.configService,logger:e.logger})}initConfigService(e){this.configService=e}static finalize(e){var t;(t=e.logger)===null||t===void 0||t.debug("finalize() called."),e.cacheToken&&ye.remove(e.sdkKey,e.cacheToken),J.close(e.configService,e.logger)}static close(e,t,i){t?.debug("close() called."),i?.tryDisconnect(),e?.dispose()}dispose(){const e=this.options;e.logger.debug("dispose() called."),this.cacheToken&&ye.remove(e.sdkKey,this.cacheToken),J.close(this.configService,e.logger,this.hooks),this.suppressFinalize()}static disposeAll(){const e=ye.clear();let t;for(const i of e)try{J.close(i.configService,i.options.logger,i.hooks),i.suppressFinalize()}catch(s){t??(t=[]),t.push(s)}if(t)throw typeof AggregateError=="function"?AggregateError(t):t.pop()}async getValueAsync(e,t,i){this.options.logger.debug("getValueAsync() called."),Ue(e),Me(t),se(i);let s,r,o=null;i??(i=this.defaultUser);try{let a;[a,o]=await this.getSettingsAsync(),r=ke(this.evaluator,a,e,t,i,o,this.options.logger),s=r.value}catch(a){this.options.logger.settingEvaluationErrorSingle("getValueAsync",e,"defaultValue",t,a),r=Z(e,t,V(o),i,G(a),a,pe(a)),s=t}return this.hooks.emit("flagEvaluated",r),s}async getValueDetailsAsync(e,t,i){this.options.logger.debug("getValueDetailsAsync() called."),Ue(e),Me(t),se(i);let s,r=null;i??(i=this.defaultUser);try{let o;[o,r]=await this.getSettingsAsync(),s=ke(this.evaluator,o,e,t,i,r,this.options.logger)}catch(o){this.options.logger.settingEvaluationErrorSingle("getValueDetailsAsync",e,"defaultValue",t,o),s=Z(e,t,V(r),i,G(o),o,pe(o))}return this.hooks.emit("flagEvaluated",s),s}async getAllKeysAsync(){this.options.logger.debug("getAllKeysAsync() called.");const e="empty array";try{const[t]=await this.getSettingsAsync();return Et(t,this.options.logger,e)?Object.keys(t):[]}catch(t){return this.options.logger.settingEvaluationError("getAllKeysAsync",e,t),[]}}async getAllValuesAsync(e){this.options.logger.debug("getAllValuesAsync() called."),se(e);const t="empty array";let i,s,r;e??(e=this.defaultUser);try{const[o,a]=await this.getSettingsAsync();[s,r]=yn(this.evaluator,o,e,a,this.options.logger,t),i=s.map(l=>({settingKey:l.key,settingValue:l.value}))}catch(o){return this.options.logger.settingEvaluationError("getAllValuesAsync",t,o),[]}r?.length&&this.options.logger.settingEvaluationError("getAllValuesAsync","evaluation result",typeof AggregateError=="function"?AggregateError(r):r.pop());for(const o of s)this.hooks.emit("flagEvaluated",o);return i}async getAllValueDetailsAsync(e){this.options.logger.debug("getAllValueDetailsAsync() called."),se(e);const t="empty array";let i,s;e??(e=this.defaultUser);try{const[r,o]=await this.getSettingsAsync();[i,s]=yn(this.evaluator,r,e,o,this.options.logger,t)}catch(r){return this.options.logger.settingEvaluationError("getAllValueDetailsAsync",t,r),[]}s?.length&&this.options.logger.settingEvaluationError("getAllValueDetailsAsync","evaluation result",typeof AggregateError=="function"?AggregateError(s):s.pop());for(const r of i)this.hooks.emit("flagEvaluated",r);return i}async getKeyAndValueAsync(e){this.options.logger.debug("getKeyAndValueAsync() called."),En(e);const t="null";try{const[i]=await this.getSettingsAsync();return mn(i,e,this.options.logger,t)}catch(i){return this.options.logger.settingEvaluationError("getKeyAndValueAsync",t,i),null}}async forceRefreshAsync(){if(this.options.logger.debug("forceRefreshAsync() called."),this.configService)try{const[e]=await this.configService.refreshConfigAsync();return e}catch(e){return this.options.logger.clientMethodError("forceRefreshAsync",e),Te(-1,G(e),e)}else return Te(1,"Client is configured to use the LocalOnly override behavior, which prevents synchronization with external cache and making HTTP requests.")}setDefaultUser(e){this.defaultUser=_(e,"defaultUser")}clearDefaultUser(){this.defaultUser=void 0}get isOffline(){var e,t;return(t=(e=this.configService)===null||e===void 0?void 0:e.isOffline)!==null&&t!==void 0?t:!0}setOnline(){this.configService?this.configService.setOnline():this.options.logger.configServiceMethodHasNoEffectDueToOverrideBehavior(we(0),"setOnline")}setOffline(){var e;(e=this.configService)===null||e===void 0||e.setOffline()}waitForReady(){const e=this.configService;return e?e.readyPromise:Promise.resolve(1)}snapshot(){const e=()=>{var s;const r=this.options.cache.getInMemory();return[r.isEmpty?null:(s=r.config.f)!==null&&s!==void 0?s:F(),r]};let t,i;try{const{flagOverrides:s}=this.options;if(s){const r=s.dataSource.getOverrides();switch(s.behaviour){case 0:return new me(r,null,this);case 1:return[t,i]=e(),new me(Object.assign(Object.assign({},t),r),i,this);case 2:return[t,i]=e(),new me(Object.assign(Object.assign({},r),t),i,this)}}return[t,i]=e(),new me(t,i,this)}catch(s){return this.options.logger.clientMethodError("snapshot",s),new me(F(),null,this)}}async getSettingsAsync(){this.options.logger.debug("getSettingsAsync() called.");const e=async()=>{var i;const s=await this.configService.getConfigAsync();return[s.isEmpty?null:(i=s.config.f)!==null&&i!==void 0?i:F(),s]},{flagOverrides:t}=this.options;if(t){let i,s;const r=t.dataSource.getOverrides();switch(t.behaviour){case 0:return[r,null];case 1:return[i,s]=await e(),[Object.assign(Object.assign({},i),r),s];case 2:return[i,s]=await e(),[Object.assign(Object.assign({},r),i),s]}}return await e()}on(e,t){return this.hooks.on(e,t),this}once(e,t){return this.hooks.once(e,t),this}removeListener(e,t){return this.hooks.removeListener(e,t),this}removeAllListeners(e){return this.hooks.removeAllListeners(e),this}listeners(e){return this.hooks.listeners(e)}listenerCount(e){return this.hooks.listenerCount(e)}eventNames(){return this.hooks.eventNames()}}const $e=J.prototype;$e.addListener=$e.on,$e.off=$e.removeListener;class me{constructor(e,t,i){this.mergedSettings=e,this.remoteConfig=t,this.defaultUser=i.defaultUser,this.evaluator=i.evaluator,this.options=i.options,this.cacheState=t?i.configService.getCacheState(t):1}get fetchedConfig(){const e=this.remoteConfig;return e&&!e.isEmpty?e.config:null}getAllKeys(){return this.mergedSettings?Object.keys(this.mergedSettings):[]}getValue(e,t,i){this.options.logger.debug("Snapshot.getValue() called."),Ue(e),Me(t),se(i);let s,r;i??(i=this.defaultUser);try{r=ke(this.evaluator,this.mergedSettings,e,t,i,this.remoteConfig,this.options.logger),s=r.value}catch(o){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValue",e,"defaultValue",t,o),r=Z(e,t,V(this.remoteConfig),i,G(o),o,pe(o)),s=t}return this.options.hooks.emit("flagEvaluated",r),s}getValueDetails(e,t,i){this.options.logger.debug("Snapshot.getValueDetails() called."),Ue(e),Me(t),se(i);let s;i??(i=this.defaultUser);try{s=ke(this.evaluator,this.mergedSettings,e,t,i,this.remoteConfig,this.options.logger)}catch(r){this.options.logger.settingEvaluationErrorSingle("Snapshot.getValueDetails",e,"defaultValue",t,r),s=Z(e,t,V(this.remoteConfig),i,G(r),r,pe(r))}return this.options.hooks.emit("flagEvaluated",s),s}getKeyAndValue(e){this.options.logger.debug("Snapshot.getKeyAndValue() called."),En(e);const t="null";try{return mn(this.mergedSettings,e,this.options.logger,t)}catch(i){return this.options.logger.settingEvaluationError("Snapshot.getKeyAndValue",t,i),null}}}function Ii(n,e){if(e&&n.length>ut.length&&n.lastIndexOf(ut,0)===0)return!0;const t=n.split("/"),i=22;switch(t.length){case 2:return t[0].length===i&&t[1].length===i;case 3:return t[0]==="configcat-sdk-1"&&t[1].length===i&&t[2].length===i;default:return!1}}function Ue(n){Y(n,"key",!0)}function Me(n){n!=null&&!st(n)&&Q("defaultValue","The default value must be boolean, number, string, null or undefined.",void 0,TypeError)}function se(n){n==null||_(n,"user")}function En(n){Y(n,"variationId",!0)}function wi(n){return Lt(n,(e,t)=>t==null?t:e==="defaultUser"?un(t):e==="flagOverrides"?Lt(t,(i,s)=>Se(s)?L(s):s):Se(t)?L(t):t)}let Pe=function(n,e){if(typeof FinalizationRegistry=="function"){const t=new FinalizationRegistry(i=>J.finalize(i));Pe=(i,s)=>{const r={};return t.register(i,s,r),()=>t.unregister(r)}}else Pe=()=>()=>{};return Pe(n,e)};function Ri(n,e,t,i){return J.get(n,e,t,i)}function Ni(n,e){return ee(n,"logLevel","LogLevel",t=>_t(t)!==void 0),e==null||Y(e,"eol",!0),new qt(n,e)}function Fi(n,e,t){return _(n,"map"),ee(e,"behaviour","OverrideBehaviour",i=>we(i)!==void 0),t==null||We(t,"watchChanges"),{dataSource:new Xn(n,t),behaviour:e}}function Li(n,e,t,i){return ee(n,"behaviour","OverrideBehaviour",s=>we(s)!==void 0),e==null||We(e,"watchChanges"),t==null||Y(t,"paramPrefix"),i==null||_(i,"queryStringProvider"),{dataSource:new ti(e,t,i),behaviour:n}}const Ee="configCache";class St{static tryGetFactory(){const e=Di();if(e)return t=>new Ce(new St(e),t.logger)}constructor(e){this.dbConnectionFactory=e}async set(e,t){const i=await this.dbConnectionFactory();try{await new Promise((s,r)=>{const o=i.transaction(Ee,"readwrite");o.oncomplete=()=>s(),o.onerror=l=>r(l.target.error),o.objectStore(Ee).put(t,e)})}finally{i.close()}}async get(e){const t=await this.dbConnectionFactory();try{return await new Promise((i,s)=>{const r=t.transaction(Ee,"readonly");let o;r.oncomplete=()=>i(o),r.onerror=c=>s(c.target.error);const l=r.objectStore(Ee).get(e);l.onsuccess=c=>o=c.target.result})}finally{t.close()}}}function Di(){if(typeof indexedDB<"u")try{const n=()=>new Promise((e,t)=>{const i=indexedDB.open("@configcat/sdk");i.onupgradeneeded=s=>s.target.result.createObjectStore(Ee),i.onsuccess=s=>e(s.target.result),i.onerror=s=>t(s.target.error)});return n().then(e=>e.close()).catch(()=>{}),n}catch{}}class _e{static tryGetFactory(){const e=ki();if(e)return t=>new Ce(new _e(e),t.logger)}constructor(e){this.storage=e}set(e,t){this.storage.setItem(e,$i(t))}get(e){const t=this.storage.getItem(e);if(t)return Ui(t)}}function ki(){if(typeof localStorage<"u"){const n="__configcat_localStorage_test";try{const e=localStorage;e.setItem(n,n);let t;try{t=e.getItem(n)}finally{e.removeItem(n)}if(t===n)return e}catch{}}}function $i(n){return n=encodeURIComponent(n),n=n.replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))),btoa(n)}function Ui(n){return n=atob(n),n=n.replace(/[%\x80-\xFF]/g,e=>"%"+e.charCodeAt(0).toString(16)),decodeURIComponent(n)}class qe{constructor(){this.logger=null}static getFactory(){return e=>{const t=new qe;return t.logger=e.logger,t}}handleStateChange(e,t,i){try{if(e.readyState===4){const{status:s,statusText:r}=e;if(s){const o=Mi(e),a=s===200?e.responseText:void 0;t(new ot(s,r,o,a))}}}catch(s){i(s)}}fetchAsync(e){return new Promise((t,i)=>{var s;try{(s=this.logger)===null||s===void 0||s.debug("XmlHttpRequestConfigFetcher.fetchAsync() called.");let{url:r}=e;const o=!en(r),{lastETag:a,timeoutMs:l}=e;a&&(r+="&ccetag="+encodeURIComponent(a));const c=new XMLHttpRequest;c.onreadystatechange=()=>this.handleStateChange(c,t,i),c.ontimeout=()=>i(new H("timeout",l)),c.onabort=()=>i(new H("abort")),c.onerror=()=>i(new H("failure")),c.open("GET",r,!0),c.timeout=l,o&&this.setRequestHeaders(c,e.headers),c.send(null)}catch(r){i(r)}})}setRequestHeaders(e,t){}}function Mi(n){const e=[];return t("ETag",n,e),t("CF-RAY",n,e),e;function t(i,s,r){const o=s.getResponseHeader(i);o!=null&&r.push([i,o])}}class Pi{constructor(e){this.runsOnServerSide=e,this.logger=null}async fetchAsync(e){var t,i,s;(t=this.logger)===null||t===void 0||t.debug("FetchApiConfigFetcher.fetchAsync() called.");let{url:r}=e;const o=!en(r),{lastETag:a,timeoutMs:l}=e,c=Object.create(null);c.method="GET",o?this.setRequestHeaders(c,e.headers):this.runsOnServerSide&&Sn(c,e.headers),a&&(this.runsOnServerSide?((i=c.headers)!==null&&i!==void 0?i:c.headers=[]).push(["If-None-Match",a]):r+="&ccetag="+encodeURIComponent(a));let f;if(typeof AbortController=="function"){const u=new AbortController,g=setTimeout(()=>u.abort(),l);c.signal=u.signal,f=()=>clearTimeout(g)}try{const u=await fetch(r,c),{status:g,statusText:d}=u,v=_i(u),A=g===200?await u.text():void 0;return new ot(g,d,v,A)}catch(u){throw u instanceof DOMException&&u.name==="AbortError"?!((s=c.signal)===null||s===void 0)&&s.aborted?new H("timeout",l):new H("abort"):new H("failure",u)}finally{f?.()}}setRequestHeaders(e,t){this.runsOnServerSide&&Sn(e,t)}}function Sn(n,e){var t;for(const[i,s]of e)((t=n.headers)!==null&&t!==void 0?t:n.headers=[]).push([i,s])}function _i(n){const e=[];return t("ETag",n,e),t("CF-RAY",n,e),e;function t(i,s,r){const o=s.headers.get(i);o!=null&&r.push([i,o])}}class At extends Pi{static getFactory(){return e=>{const t=new At;return t.logger=e.logger,t}}}const qi="2.6.6",Hi={install:(n,e)=>{const{sdkKey:t,pollingMode:i,clientOptions:s}=e,r={sdkType:"ConfigCat-Vue",sdkVersion:qi,eventEmitterFactory:()=>new Dt,defaultCacheFactory:_e.tryGetFactory(),configFetcherFactory:qe.getFactory()},o=Ri(t,i??h.PollingMode.AutoPoll,s,r);n.provide("configCatClient",o);const a=n.unmount;n.unmount=function(){a.apply(arguments),o.dispose()}}},xi=$.defineComponent({__name:"FeatureWrapper",props:{featureKey:{},userObject:{}},emits:["flagValueChanged"],setup(n,{emit:e}){const t=e,i=n,s=$.ref(null),r=$.inject("configCatClient")??(()=>{throw new Error("ConfigCatPlugin was not installed.")})(),o=()=>{const l=r.snapshot().getValue(i.featureKey,!1,i.userObject);s.value!==l&&(s.value=l,t("flagValueChanged",l))};return $.onBeforeMount(()=>{const a=r.snapshot(),l=a.cacheState;l==h.ClientCacheState.HasUpToDateFlagData||l==h.ClientCacheState.HasLocalOverrideFlagDataOnly?(s.value=a.getValue(i.featureKey,!1,i.userObject),r.on("configChanged",o)):r.getValueAsync(i.featureKey,!1,i.userObject).then(c=>{const f=o;f&&(s.value=c,r.on("configChanged",f))})}),$.onUnmounted(()=>{r.off("configChanged",o)}),(a,l)=>s.value===!0?$.renderSlot(a.$slots,"default",{key:0}):s.value===!1?$.renderSlot(a.$slots,"else",{key:1}):$.renderSlot(a.$slots,"loading",{key:2})}});h.ClientSideFetchApiConfigFetcher=At,h.ConfigCatPlugin=Hi,h.ConfigJson=In,h.FeatureWrapper=xi,h.FetchError=H,h.FetchRequest=jt,h.FetchResponse=ot,h.FormattableLogMessage=m,h.IndexedDBConfigCache=St,h.LocalStorageConfigCache=_e,h.User=Ei,h.XmlHttpRequestConfigFetcher=qe,h.createConsoleLogger=Ni,h.createFlagOverridesFromMap=Fi,h.createFlagOverridesFromQueryParams=Li,h.createSettingFromValue=Xe,h.deserializeConfig=Ye,h.prepareConfig=Qe,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|