@featurevisor/sdk 1.27.4 → 1.27.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/CHANGELOG.md +19 -0
- package/LICENSE +1 -1
- package/coverage/clover.xml +58 -58
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/bucket.ts.html +1 -1
- package/coverage/lcov-report/conditions.ts.html +14 -5
- package/coverage/lcov-report/datafileReader.ts.html +1 -1
- package/coverage/lcov-report/emitter.ts.html +1 -1
- package/coverage/lcov-report/feature.ts.html +1 -1
- package/coverage/lcov-report/index.html +5 -5
- package/coverage/lcov-report/instance.ts.html +1 -1
- package/coverage/lcov-report/logger.ts.html +1 -1
- package/coverage/lcov-report/segments.ts.html +1 -1
- package/coverage/lcov.info +110 -107
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -8
- package/src/conditions.ts +4 -1
- package/src/logger.spec.ts +1 -3
- package/.eslintcache +0 -1
- package/.eslintrc.js +0 -18
- package/.prettierignore +0 -5
- package/prettier.config.js +0 -8
|
@@ -109,7 +109,7 @@ export function getBucketedNumber(bucketKey: string): number {
|
|
|
109
109
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
110
110
|
Code coverage generated by
|
|
111
111
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
112
|
-
at
|
|
112
|
+
at 2025-01-20T19:49:22.527Z
|
|
113
113
|
</div>
|
|
114
114
|
<script src="prettify.js"></script>
|
|
115
115
|
<script>
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">96.96% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>64/66</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -187,7 +187,10 @@
|
|
|
187
187
|
<a name='L122'></a><a href='#L122'>122</a>
|
|
188
188
|
<a name='L123'></a><a href='#L123'>123</a>
|
|
189
189
|
<a name='L124'></a><a href='#L124'>124</a>
|
|
190
|
-
<a name='L125'></a><a href='#L125'>125</a
|
|
190
|
+
<a name='L125'></a><a href='#L125'>125</a>
|
|
191
|
+
<a name='L126'></a><a href='#L126'>126</a>
|
|
192
|
+
<a name='L127'></a><a href='#L127'>127</a>
|
|
193
|
+
<a name='L128'></a><a href='#L128'>128</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">3x</span>
|
|
191
194
|
<span class="cline-any cline-neutral"> </span>
|
|
192
195
|
<span class="cline-any cline-neutral"> </span>
|
|
193
196
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -213,6 +216,9 @@
|
|
|
213
216
|
<span class="cline-any cline-neutral"> </span>
|
|
214
217
|
<span class="cline-any cline-yes">45x</span>
|
|
215
218
|
<span class="cline-any cline-neutral"> </span>
|
|
219
|
+
<span class="cline-any cline-neutral"> </span>
|
|
220
|
+
<span class="cline-any cline-neutral"> </span>
|
|
221
|
+
<span class="cline-any cline-neutral"> </span>
|
|
216
222
|
<span class="cline-any cline-yes">8x</span>
|
|
217
223
|
<span class="cline-any cline-neutral"> </span>
|
|
218
224
|
<span class="cline-any cline-yes">8x</span>
|
|
@@ -335,7 +341,10 @@ export function conditionIsMatched(condition: PlainCondition, context: Context):
|
|
|
335
341
|
return operator === "before"
|
|
336
342
|
? dateInContext < dateInCondition
|
|
337
343
|
: dateInContext > dateInCondition;
|
|
338
|
-
} else if (
|
|
344
|
+
} else if (
|
|
345
|
+
Array.isArray(value) &&
|
|
346
|
+
(["string", "number"].indexOf(typeof context[attribute]) !== -1 || <span class="branch-2 cbranch-no" title="branch not covered" >context[attribute] === null)</span>
|
|
347
|
+
) {
|
|
339
348
|
// array
|
|
340
349
|
const valueInContext = context[attribute] as string;
|
|
341
350
|
|
|
@@ -442,7 +451,7 @@ export function allConditionsAreMatched(
|
|
|
442
451
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
443
452
|
Code coverage generated by
|
|
444
453
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
445
|
-
at
|
|
454
|
+
at 2025-01-20T19:49:22.527Z
|
|
446
455
|
</div>
|
|
447
456
|
<script src="prettify.js"></script>
|
|
448
457
|
<script>
|
|
@@ -289,7 +289,7 @@ export class DatafileReader {
|
|
|
289
289
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
290
290
|
Code coverage generated by
|
|
291
291
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
292
|
-
at
|
|
292
|
+
at 2025-01-20T19:49:22.527Z
|
|
293
293
|
</div>
|
|
294
294
|
<script src="prettify.js"></script>
|
|
295
295
|
<script>
|
|
@@ -229,7 +229,7 @@ export class Emitter {
|
|
|
229
229
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
230
230
|
Code coverage generated by
|
|
231
231
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
232
|
-
at
|
|
232
|
+
at 2025-01-20T19:49:22.527Z
|
|
233
233
|
</div>
|
|
234
234
|
<script src="prettify.js"></script>
|
|
235
235
|
<script>
|
|
@@ -463,7 +463,7 @@ export function findForceFromFeature(
|
|
|
463
463
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
464
464
|
Code coverage generated by
|
|
465
465
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
466
|
-
at
|
|
466
|
+
at 2025-01-20T19:49:22.527Z
|
|
467
467
|
</div>
|
|
468
468
|
<script src="prettify.js"></script>
|
|
469
469
|
<script>
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">85.
|
|
33
|
+
<span class="strong">85.75% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>283/330</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
</td>
|
|
101
101
|
<td data-value="94.28" class="pct high">94.28%</td>
|
|
102
102
|
<td data-value="70" class="abs high">66/70</td>
|
|
103
|
-
<td data-value="
|
|
104
|
-
<td data-value="
|
|
103
|
+
<td data-value="96.96" class="pct high">96.96%</td>
|
|
104
|
+
<td data-value="66" class="abs high">64/66</td>
|
|
105
105
|
<td data-value="100" class="pct high">100%</td>
|
|
106
106
|
<td data-value="6" class="abs high">6/6</td>
|
|
107
107
|
<td data-value="94.02" class="pct high">94.02%</td>
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
207
207
|
Code coverage generated by
|
|
208
208
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
209
|
-
at
|
|
209
|
+
at 2025-01-20T19:49:22.527Z
|
|
210
210
|
</div>
|
|
211
211
|
<script src="prettify.js"></script>
|
|
212
212
|
<script>
|
|
@@ -4150,7 +4150,7 @@ export function createInstance(options: InstanceOptions): FeaturevisorInstance {
|
|
|
4150
4150
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
4151
4151
|
Code coverage generated by
|
|
4152
4152
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
4153
|
-
at
|
|
4153
|
+
at 2025-01-20T19:49:22.527Z
|
|
4154
4154
|
</div>
|
|
4155
4155
|
<script src="prettify.js"></script>
|
|
4156
4156
|
<script>
|
|
@@ -340,7 +340,7 @@ export function createLogger(options: CreateLoggerOptions = {}): Logger {
|
|
|
340
340
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
341
341
|
Code coverage generated by
|
|
342
342
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
343
|
-
at
|
|
343
|
+
at 2025-01-20T19:49:22.527Z
|
|
344
344
|
</div>
|
|
345
345
|
<script src="prettify.js"></script>
|
|
346
346
|
<script>
|
|
@@ -244,7 +244,7 @@ export function allGroupSegmentsAreMatched(
|
|
|
244
244
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
245
245
|
Code coverage generated by
|
|
246
246
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
247
|
-
at
|
|
247
|
+
at 2025-01-20T19:49:22.527Z
|
|
248
248
|
</div>
|
|
249
249
|
<script src="prettify.js"></script>
|
|
250
250
|
<script>
|
package/coverage/lcov.info
CHANGED
|
@@ -20,11 +20,11 @@ end_of_record
|
|
|
20
20
|
TN:
|
|
21
21
|
SF:src/conditions.ts
|
|
22
22
|
FN:7,conditionIsMatched
|
|
23
|
-
FN:
|
|
24
|
-
FN:
|
|
25
|
-
FN:
|
|
26
|
-
FN:
|
|
27
|
-
FN:
|
|
23
|
+
FN:80,allConditionsAreMatched
|
|
24
|
+
FN:102,(anonymous_2)
|
|
25
|
+
FN:106,(anonymous_3)
|
|
26
|
+
FN:111,(anonymous_4)
|
|
27
|
+
FN:123,(anonymous_5)
|
|
28
28
|
FNF:6
|
|
29
29
|
FNH:6
|
|
30
30
|
FNDA:414,conditionIsMatched
|
|
@@ -46,60 +46,60 @@ DA:19,8
|
|
|
46
46
|
DA:20,8
|
|
47
47
|
DA:22,8
|
|
48
48
|
DA:25,45
|
|
49
|
-
DA:
|
|
50
|
-
DA:
|
|
51
|
-
DA:
|
|
52
|
-
DA:
|
|
53
|
-
DA:
|
|
54
|
-
DA:
|
|
55
|
-
DA:
|
|
56
|
-
DA:
|
|
57
|
-
DA:
|
|
58
|
-
DA:
|
|
59
|
-
DA:
|
|
60
|
-
DA:
|
|
61
|
-
DA:
|
|
62
|
-
DA:
|
|
63
|
-
DA:
|
|
64
|
-
DA:
|
|
65
|
-
DA:
|
|
66
|
-
DA:
|
|
67
|
-
DA:
|
|
68
|
-
DA:
|
|
69
|
-
DA:
|
|
70
|
-
DA:
|
|
71
|
-
DA:
|
|
72
|
-
DA:
|
|
73
|
-
DA:
|
|
74
|
-
DA:
|
|
75
|
-
DA:
|
|
76
|
-
DA:
|
|
77
|
-
DA:
|
|
78
|
-
DA:
|
|
79
|
-
DA:
|
|
80
|
-
DA:
|
|
81
|
-
DA:66,4
|
|
82
|
-
DA:67,6
|
|
83
|
-
DA:68,2
|
|
49
|
+
DA:30,8
|
|
50
|
+
DA:32,8
|
|
51
|
+
DA:33,4
|
|
52
|
+
DA:34,4
|
|
53
|
+
DA:35,4
|
|
54
|
+
DA:37,37
|
|
55
|
+
DA:39,25
|
|
56
|
+
DA:41,25
|
|
57
|
+
DA:42,3
|
|
58
|
+
DA:43,22
|
|
59
|
+
DA:44,3
|
|
60
|
+
DA:45,19
|
|
61
|
+
DA:46,3
|
|
62
|
+
DA:47,16
|
|
63
|
+
DA:48,3
|
|
64
|
+
DA:49,13
|
|
65
|
+
DA:50,2
|
|
66
|
+
DA:51,11
|
|
67
|
+
DA:52,2
|
|
68
|
+
DA:53,9
|
|
69
|
+
DA:54,2
|
|
70
|
+
DA:55,7
|
|
71
|
+
DA:56,3
|
|
72
|
+
DA:57,4
|
|
73
|
+
DA:58,2
|
|
74
|
+
DA:59,2
|
|
75
|
+
DA:60,2
|
|
76
|
+
DA:62,12
|
|
77
|
+
DA:64,12
|
|
78
|
+
DA:66,12
|
|
79
|
+
DA:67,2
|
|
80
|
+
DA:68,10
|
|
84
81
|
DA:69,4
|
|
85
|
-
DA:70,
|
|
86
|
-
DA:
|
|
87
|
-
DA:
|
|
88
|
-
DA:
|
|
89
|
-
DA:
|
|
90
|
-
DA:
|
|
91
|
-
DA:
|
|
92
|
-
DA:
|
|
93
|
-
DA:
|
|
94
|
-
DA:
|
|
95
|
-
DA:
|
|
96
|
-
DA:
|
|
97
|
-
DA:
|
|
98
|
-
DA:
|
|
99
|
-
DA:
|
|
100
|
-
DA:
|
|
101
|
-
DA:
|
|
102
|
-
DA:
|
|
82
|
+
DA:70,6
|
|
83
|
+
DA:71,2
|
|
84
|
+
DA:72,4
|
|
85
|
+
DA:73,4
|
|
86
|
+
DA:77,0
|
|
87
|
+
DA:80,3
|
|
88
|
+
DA:85,842
|
|
89
|
+
DA:86,414
|
|
90
|
+
DA:87,414
|
|
91
|
+
DA:89,0
|
|
92
|
+
DA:97,0
|
|
93
|
+
DA:101,428
|
|
94
|
+
DA:102,37
|
|
95
|
+
DA:105,405
|
|
96
|
+
DA:106,38
|
|
97
|
+
DA:109,383
|
|
98
|
+
DA:110,6
|
|
99
|
+
DA:112,9
|
|
100
|
+
DA:122,377
|
|
101
|
+
DA:123,380
|
|
102
|
+
DA:126,0
|
|
103
103
|
LF:67
|
|
104
104
|
LH:63
|
|
105
105
|
BRDA:10,0,0,359
|
|
@@ -118,55 +118,58 @@ BRDA:22,6,0,4
|
|
|
118
118
|
BRDA:22,6,1,4
|
|
119
119
|
BRDA:25,7,0,8
|
|
120
120
|
BRDA:25,7,1,37
|
|
121
|
-
BRDA:
|
|
122
|
-
BRDA:
|
|
123
|
-
BRDA:
|
|
124
|
-
BRDA:
|
|
125
|
-
BRDA:
|
|
126
|
-
BRDA:34,
|
|
127
|
-
BRDA:
|
|
128
|
-
BRDA:
|
|
129
|
-
BRDA:
|
|
130
|
-
BRDA:
|
|
131
|
-
BRDA:
|
|
132
|
-
BRDA:
|
|
133
|
-
BRDA:
|
|
134
|
-
BRDA:
|
|
135
|
-
BRDA:
|
|
136
|
-
BRDA:
|
|
137
|
-
BRDA:
|
|
138
|
-
BRDA:
|
|
139
|
-
BRDA:
|
|
140
|
-
BRDA:
|
|
141
|
-
BRDA:
|
|
142
|
-
BRDA:
|
|
143
|
-
BRDA:
|
|
144
|
-
BRDA:
|
|
145
|
-
BRDA:
|
|
146
|
-
BRDA:
|
|
147
|
-
BRDA:
|
|
148
|
-
BRDA:
|
|
149
|
-
BRDA:59,
|
|
150
|
-
BRDA:
|
|
151
|
-
BRDA:
|
|
152
|
-
BRDA:
|
|
153
|
-
BRDA:
|
|
154
|
-
BRDA:
|
|
155
|
-
BRDA:
|
|
156
|
-
BRDA:
|
|
157
|
-
BRDA:
|
|
158
|
-
BRDA:
|
|
159
|
-
BRDA:
|
|
160
|
-
BRDA:
|
|
161
|
-
BRDA:
|
|
162
|
-
BRDA:
|
|
163
|
-
BRDA:
|
|
164
|
-
BRDA:
|
|
165
|
-
BRDA:
|
|
166
|
-
BRDA:
|
|
167
|
-
BRDA:
|
|
168
|
-
|
|
169
|
-
|
|
121
|
+
BRDA:26,8,0,45
|
|
122
|
+
BRDA:26,8,1,8
|
|
123
|
+
BRDA:26,8,2,0
|
|
124
|
+
BRDA:32,9,0,4
|
|
125
|
+
BRDA:32,9,1,4
|
|
126
|
+
BRDA:34,10,0,4
|
|
127
|
+
BRDA:37,11,0,25
|
|
128
|
+
BRDA:37,11,1,12
|
|
129
|
+
BRDA:37,12,0,37
|
|
130
|
+
BRDA:37,12,1,25
|
|
131
|
+
BRDA:41,13,0,3
|
|
132
|
+
BRDA:41,13,1,22
|
|
133
|
+
BRDA:43,14,0,3
|
|
134
|
+
BRDA:43,14,1,19
|
|
135
|
+
BRDA:45,15,0,3
|
|
136
|
+
BRDA:45,15,1,16
|
|
137
|
+
BRDA:47,16,0,3
|
|
138
|
+
BRDA:47,16,1,13
|
|
139
|
+
BRDA:49,17,0,2
|
|
140
|
+
BRDA:49,17,1,11
|
|
141
|
+
BRDA:51,18,0,2
|
|
142
|
+
BRDA:51,18,1,9
|
|
143
|
+
BRDA:53,19,0,2
|
|
144
|
+
BRDA:53,19,1,7
|
|
145
|
+
BRDA:55,20,0,3
|
|
146
|
+
BRDA:55,20,1,4
|
|
147
|
+
BRDA:57,21,0,2
|
|
148
|
+
BRDA:57,21,1,2
|
|
149
|
+
BRDA:59,22,0,2
|
|
150
|
+
BRDA:62,23,0,12
|
|
151
|
+
BRDA:62,24,0,12
|
|
152
|
+
BRDA:62,24,1,12
|
|
153
|
+
BRDA:66,25,0,2
|
|
154
|
+
BRDA:66,25,1,10
|
|
155
|
+
BRDA:68,26,0,4
|
|
156
|
+
BRDA:68,26,1,6
|
|
157
|
+
BRDA:70,27,0,2
|
|
158
|
+
BRDA:70,27,1,4
|
|
159
|
+
BRDA:72,28,0,4
|
|
160
|
+
BRDA:85,29,0,414
|
|
161
|
+
BRDA:101,30,0,23
|
|
162
|
+
BRDA:101,31,0,428
|
|
163
|
+
BRDA:101,31,1,23
|
|
164
|
+
BRDA:105,32,0,22
|
|
165
|
+
BRDA:105,33,0,405
|
|
166
|
+
BRDA:105,33,1,22
|
|
167
|
+
BRDA:109,34,0,6
|
|
168
|
+
BRDA:109,35,0,383
|
|
169
|
+
BRDA:109,35,1,6
|
|
170
|
+
BRDA:122,36,0,377
|
|
171
|
+
BRF:66
|
|
172
|
+
BRH:64
|
|
170
173
|
end_of_record
|
|
171
174
|
TN:
|
|
172
175
|
SF:src/datafileReader.ts
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{var e={480:(e,t,r)=>{"use strict";r.r(t),r.d(t,{compare:()=>n,compareVersions:()=>i,satisfies:()=>o,validate:()=>a});const i=(e,t)=>{const r=u(e),i=u(t),a=r.pop(),n=i.pop(),o=d(r,i);return 0!==o?o:a&&n?d(a.split("."),n.split(".")):a||n?a?-1:1:0},a=e=>"string"==typeof e&&/^[v\d]/.test(e)&&s.test(e),n=(e,t,r)=>{v(r);const a=i(e,t);return h[r].includes(a)},o=(e,t)=>{if(t.includes("||"))return t.split("||").some((t=>o(e,t)));if(t.includes(" "))return t.trim().replace(/\s{2,}/g," ").split(" ").every((t=>o(e,t)));const r=t.match(/^([<>=~^]+)/),i=r?r[1]:"=";if("^"!==i&&"~"!==i)return n(e,t,i);const[a,s,l,,f]=u(e),[c,h,g,,v]=u(t),y=[a,s,l],p=[c,null!=h?h:"x",null!=g?g:"x"];if(v){if(!f)return!1;if(0!==d(y,p))return!1;if(-1===d(f.split("."),v.split(".")))return!1}const b=p.findIndex((e=>"0"!==e))+1,m="~"===i?2:b>1?b:1;return 0===d(y.slice(0,m),p.slice(0,m))&&-1!==d(y.slice(m),p.slice(m))},s=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,u=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(s);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},l=e=>"*"===e||"x"===e||"X"===e,f=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},c=(e,t)=>{if(l(e)||l(t))return 0;const[r,i]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(f(e),f(t));return r>i?1:r<i?-1:0},d=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const i=c(e[r]||"0",t[r]||"0");if(0!==i)return i}return 0},h={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},g=Object.keys(h),v=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===g.indexOf(e))throw new Error(`Invalid operator, expected one of ${g.join("|")}`)}},77:e=>{!function(){const t=e=>(new TextEncoder).encode(e);function r(e,r){let i,a,n,o,s,u,l,f;for("string"==typeof e&&(e=t(e)),i=3&e.length,a=e.length-i,n=r,s=3432918353,u=461845907,f=0;f<a;)l=255&e[f]|(255&e[++f])<<8|(255&e[++f])<<16|(255&e[++f])<<24,++f,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*u+(((l>>>16)*u&65535)<<16)&4294967295,n^=l,n=n<<13|n>>>19,o=5*(65535&n)+((5*(n>>>16)&65535)<<16)&4294967295,n=27492+(65535&o)+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e[f+2])<<16;case 2:l^=(255&e[f+1])<<8;case 1:l^=255&e[f],l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*u+(((l>>>16)*u&65535)<<16)&4294967295,n^=l}return n^=e.length,n^=n>>>16,n=2246822507*(65535&n)+((2246822507*(n>>>16)&65535)<<16)&4294967295,n^=n>>>13,n=3266489909*(65535&n)+((3266489909*(n>>>16)&65535)<<16)&4294967295,n^=n>>>16,n>>>0}const i=r;i.v2=function(e,r){"string"==typeof e&&(e=t(e));let i,a=e.length,n=r^a,o=0;for(;a>=4;)i=255&e[o]|(255&e[++o])<<8|(255&e[++o])<<16|(255&e[++o])<<24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^i,a-=4,++o;switch(a){case 3:n^=(255&e[o+2])<<16;case 2:n^=(255&e[o+1])<<8;case 1:n^=255&e[o],n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)}return n^=n>>>13,n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16),n^=n>>>15,n>>>0},i.v3=r,e.exports=i}()},293:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBucketedNumber=t.MAX_BUCKETED_NUMBER=void 0;var i=r(77),a=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5,t.getBucketedNumber=function(e){var r=i.v3(e,1)/a;return Math.floor(r*t.MAX_BUCKETED_NUMBER)}},739:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allConditionsAreMatched=t.conditionIsMatched=void 0;var i=r(480);function a(e,t){var r=e.attribute,a=e.operator,n=e.value;if("equals"===a)return t[r]===n;if("notEquals"===a)return t[r]!==n;if("before"===a||"after"===a){var o=(u=t[r])instanceof Date?u:new Date(u),s=n instanceof Date?n:new Date(n);return"before"===a?o<s:o>s}if(Array.isArray(n)){var u=t[r];if("in"===a)return-1!==n.indexOf(u);if("notIn"===a)return-1===n.indexOf(u)}else if("string"==typeof t[r]&&"string"==typeof n){if(u=t[r],"contains"===a)return-1!==u.indexOf(n);if("notContains"===a)return-1===u.indexOf(n);if("startsWith"===a)return u.startsWith(n);if("endsWith"===a)return u.endsWith(n);if("semverEquals"===a)return 0===(0,i.compareVersions)(u,n);if("semverNotEquals"===a)return 0!==(0,i.compareVersions)(u,n);if("semverGreaterThan"===a)return 1===(0,i.compareVersions)(u,n);if("semverGreaterThanOrEquals"===a)return(0,i.compareVersions)(u,n)>=0;if("semverLessThan"===a)return-1===(0,i.compareVersions)(u,n);if("semverLessThanOrEquals"===a)return(0,i.compareVersions)(u,n)<=0}else if("number"==typeof t[r]&&"number"==typeof n){if(u=t[r],"greaterThan"===a)return u>n;if("greaterThanOrEquals"===a)return u>=n;if("lessThan"===a)return u<n;if("lessThanOrEquals"===a)return u<=n}return!1}t.conditionIsMatched=a,t.allConditionsAreMatched=function e(t,r,i){if("attribute"in t)try{return a(t,r)}catch(e){return i.warn(e.message,{error:e,details:{condition:t,context:r}}),!1}return"and"in t&&Array.isArray(t.and)?t.and.every((function(t){return e(t,r,i)})):"or"in t&&Array.isArray(t.or)?t.or.some((function(t){return e(t,r,i)})):"not"in t&&Array.isArray(t.not)?t.not.every((function(){return!1===e({and:t.not},r,i)})):!!Array.isArray(t)&&t.every((function(t){return e(t,r,i)}))}},74:(e,t)=>{"use strict";function r(e,t){if("string"==typeof e[t]&&"*"!==e[t])try{e[t]=JSON.parse(e[t])}catch(e){console.error("Error parsing JSON",e)}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=t.parseJsonConditionsIfStringified=void 0,t.parseJsonConditionsIfStringified=r;var i=function(){function e(e){this.schemaVersion=e.schemaVersion,this.revision=e.revision,this.segments=e.segments,this.attributes=e.attributes,this.features=e.features}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getAllAttributes=function(){return this.attributes},e.prototype.getAttribute=function(e){return this.attributes.find((function(t){return t.key===e}))},e.prototype.getSegment=function(e){var t=this.segments.find((function(t){return t.key===e}));if(t)return r(t,"conditions")},e.prototype.getFeature=function(e){var t=this.features.find((function(t){return t.key===e}));if(t)return t},e}();t.DatafileReader=i},193:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this._listeners={}}return e.prototype.addListener=function(e,t){void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t)},e.prototype.removeListener=function(e,t){if(void 0!==this._listeners[e]){var r=this._listeners[e].indexOf(t);-1!==r&&this._listeners[e].splice(r,1)}},e.prototype.removeAllListeners=function(e){var t=this;e?this._listeners[e]=[]:Object.keys(this._listeners).forEach((function(e){t._listeners[e]=[]}))},e.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];void 0!==this._listeners[e]&&this._listeners[e].forEach((function(e){e.apply(void 0,t)}))},e}();t.Emitter=r},596:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findForceFromFeature=t.getMatchedTrafficAndAllocation=t.getMatchedTraffic=t.parseFromStringifiedSegments=t.getMatchedAllocation=void 0;var i=r(993),a=r(739);function n(e,t){for(var r=0,i=e.allocation;r<i.length;r++){var a=i[r],n=a.range,o=n[0],s=n[1];if(a.range&&o<=t&&s>=t)return a}}function o(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e}t.getMatchedAllocation=n,t.parseFromStringifiedSegments=o,t.getMatchedTraffic=function(e,t,r,a){return e.find((function(e){return!!(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,r,a)}))},t.getMatchedTrafficAndAllocation=function(e,t,r,a,s){var u=e.find((function(e){return(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,a,s)}));return u?{matchedTraffic:u,matchedAllocation:n(u,r)}:{matchedTraffic:void 0,matchedAllocation:void 0}},t.findForceFromFeature=function(e,t,r,n){var o={force:void 0,forceIndex:void 0};if(!e.force)return o;for(var s=0;s<e.force.length;s++){var u=e.force[s];if(u.conditions&&(0,a.allConditionsAreMatched)(u.conditions,t,n)){o.force=u,o.forceIndex=s;break}if(u.segments&&(0,i.allGroupSegmentsAreMatched)(u.segments,t,r,n)){o.force=u,o.forceIndex=s;break}}return o}},27:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,a)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(293),t),a(r(396),t),a(r(255),t),a(r(739),t),a(r(193),t)},396:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createInstance=t.FeaturevisorInstance=t.getValueByType=t.EvaluationReason=void 0;var i,a=r(255),n=r(74),o=r(193),s=r(293),u=r(596),l=r(739),f=r(993),c=".",d={schemaVersion:"1",revision:"unknown",attributes:[],segments:[],features:[]};function h(e,t){return t?t(e):fetch(e).then((function(e){return e.json()}))}function g(e,t){try{if(void 0===e)return;switch(t){case"string":return"string"==typeof e?e:void 0;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:void 0;case"object":return"object"==typeof e?e:void 0;default:return e}}catch(e){return}}!function(e){e.NOT_FOUND="not_found",e.NO_VARIATIONS="no_variations",e.NO_MATCH="no_match",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.FORCED="forced",e.INITIAL="initial",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.DEFAULTED="defaulted",e.OVERRIDE="override",e.ERROR="error"}(i=t.EvaluationReason||(t.EvaluationReason={})),t.getValueByType=g;var v=function(){function e(e){var t=this;this.bucketKeySeparator=e.bucketKeySeparator||c,this.configureBucketKey=e.configureBucketKey,this.configureBucketValue=e.configureBucketValue,this.datafileUrl=e.datafileUrl,this.handleDatafileFetch=e.handleDatafileFetch,this.initialFeatures=e.initialFeatures,this.interceptContext=e.interceptContext,this.logger=e.logger||(0,a.createLogger)(),this.refreshInterval=e.refreshInterval,this.stickyFeatures=e.stickyFeatures,this.emitter=new o.Emitter,this.statuses={ready:!1,refreshInProgress:!1},e.onReady&&this.emitter.addListener("ready",e.onReady),e.onRefresh&&this.emitter.addListener("refresh",e.onRefresh),e.onUpdate&&this.emitter.addListener("update",e.onUpdate),e.onActivation&&this.emitter.addListener("activation",e.onActivation);var r=this.emitter.addListener.bind(this.emitter);this.on=r,this.addListener=r;var i=this.emitter.removeListener.bind(this.emitter);if(this.off=i,this.removeListener=i,this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter),e.datafileUrl)this.setDatafile(e.datafile||d),h(e.datafileUrl,e.handleDatafileFetch).then((function(e){t.setDatafile(e),t.statuses.ready=!0,t.emitter.emit("ready"),t.refreshInterval&&t.startRefreshing()})).catch((function(e){t.logger.error("failed to fetch datafile",{error:e})}));else{if(!e.datafile)throw new Error("Featurevisor SDK instance cannot be created without both `datafile` and `datafileUrl` options");this.setDatafile(e.datafile),this.statuses.ready=!0,setTimeout((function(){t.emitter.emit("ready")}),0)}}return e.prototype.setLogLevels=function(e){this.logger.setLevels(e)},e.prototype.onReady=function(){var e=this;return new Promise((function(t){if(e.statuses.ready)return t(e);var r=function(){e.emitter.removeListener("ready",r),t(e)};e.emitter.addListener("ready",r)}))},e.prototype.setDatafile=function(e){try{this.datafileReader=new n.DatafileReader("string"==typeof e?JSON.parse(e):e)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setStickyFeatures=function(e){this.stickyFeatures=e},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return"string"==typeof e?this.datafileReader.getFeature(e):e},e.prototype.getBucketKey=function(e,t){var r,i,a=e.key;if("string"==typeof e.bucketBy)r="plain",i=[e.bucketBy];else if(Array.isArray(e.bucketBy))r="and",i=e.bucketBy;else{if("object"!=typeof e.bucketBy||!Array.isArray(e.bucketBy.or))throw this.logger.error("invalid bucketBy",{featureKey:a,bucketBy:e.bucketBy}),new Error("invalid bucketBy");r="or",i=e.bucketBy.or}var n=[];i.forEach((function(e){var i=t[e];void 0!==i&&("plain"===r||"and"===r||0===n.length)&&n.push(i)})),n.push(a);var o=n.join(this.bucketKeySeparator);return this.configureBucketKey?this.configureBucketKey(e,t,o):o},e.prototype.getBucketValue=function(e,t){var r=this.getBucketKey(e,t),i=(0,s.getBucketedNumber)(r);return this.configureBucketValue?{bucketKey:r,bucketValue:this.configureBucketValue(e,t,i)}:{bucketKey:r,bucketValue:i}},e.prototype.isReady=function(){return this.statuses.ready},e.prototype.refresh=function(){var e=this;return this.logger.debug("refreshing datafile"),this.statuses.refreshInProgress?this.logger.warn("refresh in progress, skipping"):this.datafileUrl?(this.statuses.refreshInProgress=!0,void h(this.datafileUrl,this.handleDatafileFetch).then((function(t){var r=e.getRevision()!==t.revision;e.setDatafile(t),e.logger.info("refreshed datafile"),e.emitter.emit("refresh"),r&&e.emitter.emit("update"),e.statuses.refreshInProgress=!1})).catch((function(t){e.logger.error("failed to refresh datafile",{error:t}),e.statuses.refreshInProgress=!1}))):this.logger.error("cannot refresh since `datafileUrl` is not provided")},e.prototype.startRefreshing=function(){var e=this;return this.datafileUrl?this.intervalId?this.logger.warn("refreshing has already started"):this.refreshInterval?void(this.intervalId=setInterval((function(){e.refresh()}),1e3*this.refreshInterval)):this.logger.warn("no `refreshInterval` option provided"):this.logger.error("cannot start refreshing since `datafileUrl` is not provided")},e.prototype.stopRefreshing=function(){if(!this.intervalId)return this.logger.warn("refreshing has not started yet");clearInterval(this.intervalId)},e.prototype.evaluateFlag=function(e,t){var r,a=this;void 0===t&&(t={});try{var n="string"==typeof e?e:e.key;if(this.stickyFeatures&&this.stickyFeatures[n]&&void 0!==this.stickyFeatures[n].enabled)return r={featureKey:n,reason:i.STICKY,sticky:this.stickyFeatures[n],enabled:this.stickyFeatures[n].enabled},this.logger.debug("using sticky enabled",r),r;if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[n]&&void 0!==this.initialFeatures[n].enabled)return r={featureKey:n,reason:i.INITIAL,initial:this.initialFeatures[n],enabled:this.initialFeatures[n].enabled},this.logger.debug("using initial enabled",r),r;var o=this.getFeature(e);if(!o)return r={featureKey:n,reason:i.NOT_FOUND},this.logger.warn("feature not found",r),r;o.deprecated&&this.logger.warn("feature is deprecated",{featureKey:o.key});var s=this.interceptContext?this.interceptContext(t):t,l=(0,u.findForceFromFeature)(o,t,this.datafileReader,this.logger),f=l.force,c=l.forceIndex;if(f&&void 0!==f.enabled)return r={featureKey:o.key,reason:i.FORCED,forceIndex:c,force:f,enabled:f.enabled},this.logger.debug("forced enabled found",r),r;if(o.required&&o.required.length>0){var d=o.required.every((function(e){var t,r;return"string"==typeof e?t=e:(t=e.key,r=e.variation),!!a.isEnabled(t,s)&&(void 0===r||a.getVariation(t,s)===r)}));if(!d)return r={featureKey:o.key,reason:i.REQUIRED,required:o.required,enabled:d},this.logger.debug("required features not enabled",r),r}var h=this.getBucketValue(o,s),g=h.bucketKey,v=h.bucketValue,y=(0,u.getMatchedTraffic)(o.traffic,s,this.datafileReader,this.logger);if(y){if(o.ranges&&o.ranges.length>0)return o.ranges.find((function(e){return v>=e[0]&&v<e[1]}))?(r={featureKey:o.key,reason:i.ALLOCATED,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:void 0===y.enabled||y.enabled},this.logger.debug("matched",r),r):(r={featureKey:o.key,reason:i.OUT_OF_RANGE,bucketKey:g,bucketValue:v,enabled:!1},this.logger.debug("not matched",r),r);if(void 0!==y.enabled)return r={featureKey:o.key,reason:i.OVERRIDE,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:y.enabled},this.logger.debug("override from rule",r),r;if(v<=y.percentage)return r={featureKey:o.key,reason:i.RULE,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:!0},this.logger.debug("matched traffic",r),r}return r={featureKey:o.key,reason:i.NO_MATCH,bucketKey:g,bucketValue:v,enabled:!1},this.logger.debug("nothing matched",r),r}catch(t){return r={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,error:t},this.logger.error("error",r),r}},e.prototype.isEnabled=function(e,t){void 0===t&&(t={});try{return!0===this.evaluateFlag(e,t).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t){var r;void 0===t&&(t={});try{var a="string"==typeof e?e:e.key;if(!1===this.evaluateFlag(e,t).enabled)return r={featureKey:a,reason:i.DISABLED},this.logger.debug("feature is disabled",r),r;if(this.stickyFeatures&&this.stickyFeatures[a]&&void 0!==(n=this.stickyFeatures[a].variation))return r={featureKey:a,reason:i.STICKY,variationValue:n},this.logger.debug("using sticky variation",r),r;if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[a]&&void 0!==this.initialFeatures[a].variation){var n=this.initialFeatures[a].variation;return r={featureKey:a,reason:i.INITIAL,variationValue:n},this.logger.debug("using initial variation",r),r}var o=this.getFeature(e);if(!o)return r={featureKey:a,reason:i.NOT_FOUND},this.logger.warn("feature not found",r),r;if(!o.variations||0===o.variations.length)return r={featureKey:a,reason:i.NO_VARIATIONS},this.logger.warn("no variations",r),r;var s=this.interceptContext?this.interceptContext(t):t,l=(0,u.findForceFromFeature)(o,t,this.datafileReader,this.logger),f=l.force,c=l.forceIndex;if(f&&f.variation&&(b=o.variations.find((function(e){return e.value===f.variation}))))return r={featureKey:o.key,reason:i.FORCED,forceIndex:c,force:f,variation:b},this.logger.debug("forced variation found",r),r;var d=this.getBucketValue(o,s),h=d.bucketKey,g=d.bucketValue,v=(0,u.getMatchedTrafficAndAllocation)(o.traffic,s,g,this.datafileReader,this.logger),y=v.matchedTraffic,p=v.matchedAllocation;if(y){var b;if(y.variation&&(b=o.variations.find((function(e){return e.value===y.variation}))))return r={featureKey:o.key,reason:i.RULE,bucketKey:h,bucketValue:g,ruleKey:y.key,traffic:y,variation:b},this.logger.debug("override from rule",r),r;if(p&&p.variation&&(b=o.variations.find((function(e){return e.value===p.variation}))))return r={featureKey:o.key,reason:i.ALLOCATED,bucketKey:h,bucketValue:g,ruleKey:y.key,traffic:y,variation:b},this.logger.debug("allocated variation",r),r}return r={featureKey:o.key,reason:i.NO_MATCH,bucketKey:h,bucketValue:g},this.logger.debug("no matched variation",r),r}catch(t){return r={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,error:t},this.logger.error("error",r),r}},e.prototype.getVariation=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t);return void 0!==r.variationValue?r.variationValue:r.variation?r.variation.value:void 0}catch(t){return void this.logger.error("getVariation",{featureKey:e,error:t})}},e.prototype.activate=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t),i=r.variation?r.variation.value:r.variationValue;if(void 0===i)return;var a=this.interceptContext?this.interceptContext(t):t,n={};return this.datafileReader.getAllAttributes().filter((function(e){return!0===e.capture})).forEach((function(e){void 0!==a[e.key]&&(n[e.key]=t[e.key])})),this.emitter.emit("activation",e,i,a,n,r),i}catch(t){return void this.logger.error("activate",{featureKey:e,error:t})}},e.prototype.evaluateVariable=function(e,t,r){var a,n=this;void 0===r&&(r={});try{var o,s="string"==typeof e?e:e.key;if(!1===this.evaluateFlag(e,r).enabled)return a={featureKey:s,reason:i.DISABLED},this.logger.debug("feature is disabled",a),a;if(this.stickyFeatures&&this.stickyFeatures[s]&&(o=this.stickyFeatures[s].variables)){var c=o[t];if(void 0!==c)return a={featureKey:s,reason:i.STICKY,variableKey:t,variableValue:c},this.logger.debug("using sticky variable",a),a}if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[s]&&(o=this.initialFeatures[s].variables)&&void 0!==o[t])return a={featureKey:s,reason:i.INITIAL,variableKey:t,variableValue:o[t]},this.logger.debug("using initial variable",a),a;var d=this.getFeature(e);if(!d)return a={featureKey:s,reason:i.NOT_FOUND,variableKey:t},this.logger.warn("feature not found in datafile",a),a;var h=Array.isArray(d.variablesSchema)?d.variablesSchema.find((function(e){return e.key===t})):void 0;if(!h)return a={featureKey:s,reason:i.NOT_FOUND,variableKey:t},this.logger.warn("variable schema not found",a),a;var g=this.interceptContext?this.interceptContext(r):r,v=(0,u.findForceFromFeature)(d,r,this.datafileReader,this.logger),y=v.force,p=v.forceIndex;if(y&&y.variables&&void 0!==y.variables[t])return a={featureKey:d.key,reason:i.FORCED,forceIndex:p,force:y,variableKey:t,variableSchema:h,variableValue:y.variables[t]},this.logger.debug("forced variable",a),a;var b=this.getBucketValue(d,g),m=b.bucketKey,k=b.bucketValue,A=(0,u.getMatchedTrafficAndAllocation)(d.traffic,g,k,this.datafileReader,this.logger),K=A.matchedTraffic,V=A.matchedAllocation;if(K){if(K.variables&&void 0!==K.variables[t])return a={featureKey:d.key,reason:i.RULE,bucketKey:m,bucketValue:k,ruleKey:K.key,traffic:K,variableKey:t,variableSchema:h,variableValue:K.variables[t]},this.logger.debug("override from rule",a),a;var F;if(y&&y.variation?F=y.variation:V&&V.variation&&(F=V.variation),F&&Array.isArray(d.variations)){var O=d.variations.find((function(e){return e.value===F}));if(O&&O.variables){var I=O.variables.find((function(e){return e.key===t}));if(I){if(I.overrides){var E=I.overrides.find((function(e){return e.conditions?(0,l.allConditionsAreMatched)("string"==typeof e.conditions?JSON.parse(e.conditions):e.conditions,g,n.logger):!!e.segments&&(0,f.allGroupSegmentsAreMatched)((0,u.parseFromStringifiedSegments)(e.segments),g,n.datafileReader,n.logger)}));if(E)return a={featureKey:d.key,reason:i.OVERRIDE,bucketKey:m,bucketValue:k,ruleKey:K.key,traffic:K,variableKey:t,variableSchema:h,variableValue:E.value},this.logger.debug("variable override",a),a}if(void 0!==I.value)return a={featureKey:d.key,reason:i.ALLOCATED,bucketKey:m,bucketValue:k,ruleKey:K.key,traffic:K,variableKey:t,variableSchema:h,variableValue:I.value},this.logger.debug("allocated variable",a),a}}}}return a={featureKey:d.key,reason:i.DEFAULTED,bucketKey:m,bucketValue:k,variableKey:t,variableSchema:h,variableValue:h.defaultValue},this.logger.debug("using default value",a),a}catch(r){return a={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,variableKey:t,error:r},this.logger.error("error",a),a}},e.prototype.getVariable=function(e,t,r){void 0===r&&(r={});try{var i=this.evaluateVariable(e,t,r);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:void 0}catch(r){return void this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r})}},e.prototype.getVariableBoolean=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"boolean")},e.prototype.getVariableString=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"string")},e.prototype.getVariableInteger=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"integer")},e.prototype.getVariableDouble=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"double")},e.prototype.getVariableArray=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"array")},e.prototype.getVariableObject=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"object")},e.prototype.getVariableJSON=function(e,t,r){return void 0===r&&(r={}),g(this.getVariable(e,t,r),"json")},e}();t.FeaturevisorInstance=v,t.createInstance=function(e){return new v(e)}},255:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createLogger=t.Logger=t.defaultLogHandler=t.defaultLogLevels=t.loggerPrefix=void 0,t.loggerPrefix="[Featurevisor]",t.defaultLogLevels=["warn","error"],t.defaultLogHandler=function(e,r,i){switch(void 0===i&&(i={}),e){case"debug":console.log(t.loggerPrefix,r,i);break;case"info":console.info(t.loggerPrefix,r,i);break;case"warn":console.warn(t.loggerPrefix,r,i);break;case"error":console.error(t.loggerPrefix,r,i)}};var r=function(){function e(e){this.levels=e.levels,this.handle=e.handler}return e.prototype.setLevels=function(e){this.levels=e},e.prototype.log=function(e,t,r){-1!==this.levels.indexOf(e)&&this.handle(e,t,r)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e}();t.Logger=r,t.createLogger=function(e){void 0===e&&(e={});var i=e.levels||t.defaultLogLevels,a=e.handler||t.defaultLogHandler;return new r({levels:i,handler:a})}},993:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allGroupSegmentsAreMatched=t.segmentIsMatched=void 0;var i=r(739);function a(e,t,r){return(0,i.allConditionsAreMatched)(e.conditions,t,r)}t.segmentIsMatched=a,t.allGroupSegmentsAreMatched=function e(t,r,i,n){if("*"===t)return!0;if("string"==typeof t){var o=i.getSegment(t);return!!o&&a(o,r,n)}if("object"==typeof t){if("and"in t&&Array.isArray(t.and))return t.and.every((function(t){return e(t,r,i,n)}));if("or"in t&&Array.isArray(t.or))return t.or.some((function(t){return e(t,r,i,n)}));if("not"in t&&Array.isArray(t.not))return t.not.every((function(t){return!1===e(t,r,i,n)}))}return!!Array.isArray(t)&&t.every((function(t){return e(t,r,i,n)}))}}},t={};function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(27)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorSDK=t():e.FeaturevisorSDK=t()}(this,(()=>(()=>{var e={393:(e,t,r)=>{"use strict";r.r(t),r.d(t,{compare:()=>n,compareVersions:()=>i,satisfies:()=>o,validate:()=>a});const i=(e,t)=>{const r=u(e),i=u(t),a=r.pop(),n=i.pop(),o=d(r,i);return 0!==o?o:a&&n?d(a.split("."),n.split(".")):a||n?a?-1:1:0},a=e=>"string"==typeof e&&/^[v\d]/.test(e)&&s.test(e),n=(e,t,r)=>{v(r);const a=i(e,t);return h[r].includes(a)},o=(e,t)=>{if(t.includes("||"))return t.split("||").some((t=>o(e,t)));if(t.includes(" "))return t.trim().replace(/\s{2,}/g," ").split(" ").every((t=>o(e,t)));const r=t.match(/^([<>=~^]+)/),i=r?r[1]:"=";if("^"!==i&&"~"!==i)return n(e,t,i);const[a,s,l,,f]=u(e),[c,h,g,,v]=u(t),y=[a,s,l],b=[c,null!=h?h:"x",null!=g?g:"x"];if(v){if(!f)return!1;if(0!==d(y,b))return!1;if(-1===d(f.split("."),v.split(".")))return!1}const p=b.findIndex((e=>"0"!==e))+1,k="~"===i?2:p>1?p:1;return 0===d(y.slice(0,k),b.slice(0,k))&&-1!==d(y.slice(k),b.slice(k))},s=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,u=e=>{if("string"!=typeof e)throw new TypeError("Invalid argument expected string");const t=e.match(s);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},l=e=>"*"===e||"x"===e||"X"===e,f=e=>{const t=parseInt(e,10);return isNaN(t)?e:t},c=(e,t)=>{if(l(e)||l(t))return 0;const[r,i]=((e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t])(f(e),f(t));return r>i?1:r<i?-1:0},d=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){const i=c(e[r]||"0",t[r]||"0");if(0!==i)return i}return 0},h={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1]},g=Object.keys(h),v=e=>{if("string"!=typeof e)throw new TypeError("Invalid operator type, expected string but got "+typeof e);if(-1===g.indexOf(e))throw new Error(`Invalid operator, expected one of ${g.join("|")}`)}},784:e=>{!function(){const t=e=>(new TextEncoder).encode(e);function r(e,r){let i,a,n,o,s,u,l,f;for("string"==typeof e&&(e=t(e)),i=3&e.length,a=e.length-i,n=r,s=3432918353,u=461845907,f=0;f<a;)l=255&e[f]|(255&e[++f])<<8|(255&e[++f])<<16|(255&e[++f])<<24,++f,l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*u+(((l>>>16)*u&65535)<<16)&4294967295,n^=l,n=n<<13|n>>>19,o=5*(65535&n)+((5*(n>>>16)&65535)<<16)&4294967295,n=27492+(65535&o)+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e[f+2])<<16;case 2:l^=(255&e[f+1])<<8;case 1:l^=255&e[f],l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295,l=l<<15|l>>>17,l=(65535&l)*u+(((l>>>16)*u&65535)<<16)&4294967295,n^=l}return n^=e.length,n^=n>>>16,n=2246822507*(65535&n)+((2246822507*(n>>>16)&65535)<<16)&4294967295,n^=n>>>13,n=3266489909*(65535&n)+((3266489909*(n>>>16)&65535)<<16)&4294967295,n^=n>>>16,n>>>0}const i=r;i.v2=function(e,r){"string"==typeof e&&(e=t(e));let i,a=e.length,n=r^a,o=0;for(;a>=4;)i=255&e[o]|(255&e[++o])<<8|(255&e[++o])<<16|(255&e[++o])<<24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),i^=i>>>24,i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^i,a-=4,++o;switch(a){case 3:n^=(255&e[o+2])<<16;case 2:n^=(255&e[o+1])<<8;case 1:n^=255&e[o],n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)}return n^=n>>>13,n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16),n^=n>>>15,n>>>0},i.v3=r,e.exports=i}()},906:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_BUCKETED_NUMBER=void 0,t.getBucketedNumber=function(e){var r=i.v3(e,a)/n;return Math.floor(r*t.MAX_BUCKETED_NUMBER)};var i=r(784),a=1,n=Math.pow(2,32);t.MAX_BUCKETED_NUMBER=1e5},186:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.conditionIsMatched=a,t.allConditionsAreMatched=function e(t,r,i){if("attribute"in t)try{return a(t,r)}catch(e){return i.warn(e.message,{error:e,details:{condition:t,context:r}}),!1}return"and"in t&&Array.isArray(t.and)?t.and.every((function(t){return e(t,r,i)})):"or"in t&&Array.isArray(t.or)?t.or.some((function(t){return e(t,r,i)})):"not"in t&&Array.isArray(t.not)?t.not.every((function(){return!1===e({and:t.not},r,i)})):!!Array.isArray(t)&&t.every((function(t){return e(t,r,i)}))};var i=r(393);function a(e,t){var r=e.attribute,a=e.operator,n=e.value;if("equals"===a)return t[r]===n;if("notEquals"===a)return t[r]!==n;if("before"===a||"after"===a){var o=(u=t[r])instanceof Date?u:new Date(u),s=n instanceof Date?n:new Date(n);return"before"===a?o<s:o>s}if(!Array.isArray(n)||-1===["string","number"].indexOf(typeof t[r])&&null!==t[r]){if("string"==typeof t[r]&&"string"==typeof n){if(u=t[r],"contains"===a)return-1!==u.indexOf(n);if("notContains"===a)return-1===u.indexOf(n);if("startsWith"===a)return u.startsWith(n);if("endsWith"===a)return u.endsWith(n);if("semverEquals"===a)return 0===(0,i.compareVersions)(u,n);if("semverNotEquals"===a)return 0!==(0,i.compareVersions)(u,n);if("semverGreaterThan"===a)return 1===(0,i.compareVersions)(u,n);if("semverGreaterThanOrEquals"===a)return(0,i.compareVersions)(u,n)>=0;if("semverLessThan"===a)return-1===(0,i.compareVersions)(u,n);if("semverLessThanOrEquals"===a)return(0,i.compareVersions)(u,n)<=0}else if("number"==typeof t[r]&&"number"==typeof n){if(u=t[r],"greaterThan"===a)return u>n;if("greaterThanOrEquals"===a)return u>=n;if("lessThan"===a)return u<n;if("lessThanOrEquals"===a)return u<=n}}else{var u=t[r];if("in"===a)return-1!==n.indexOf(u);if("notIn"===a)return-1===n.indexOf(u)}return!1}},649:(e,t)=>{"use strict";function r(e,t){if("string"==typeof e[t]&&"*"!==e[t])try{e[t]=JSON.parse(e[t])}catch(e){console.error("Error parsing JSON",e)}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.DatafileReader=void 0,t.parseJsonConditionsIfStringified=r;var i=function(){function e(e){this.schemaVersion=e.schemaVersion,this.revision=e.revision,this.segments=e.segments,this.attributes=e.attributes,this.features=e.features}return e.prototype.getRevision=function(){return this.revision},e.prototype.getSchemaVersion=function(){return this.schemaVersion},e.prototype.getAllAttributes=function(){return this.attributes},e.prototype.getAttribute=function(e){return this.attributes.find((function(t){return t.key===e}))},e.prototype.getSegment=function(e){var t=this.segments.find((function(t){return t.key===e}));if(t)return r(t,"conditions")},e.prototype.getFeature=function(e){var t=this.features.find((function(t){return t.key===e}));if(t)return t},e}();t.DatafileReader=i},40:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var r=function(){function e(){this._listeners={}}return e.prototype.addListener=function(e,t){void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t)},e.prototype.removeListener=function(e,t){if(void 0!==this._listeners[e]){var r=this._listeners[e].indexOf(t);-1!==r&&this._listeners[e].splice(r,1)}},e.prototype.removeAllListeners=function(e){var t=this;e?this._listeners[e]=[]:Object.keys(this._listeners).forEach((function(e){t._listeners[e]=[]}))},e.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];void 0!==this._listeners[e]&&this._listeners[e].forEach((function(e){e.apply(void 0,t)}))},e}();t.Emitter=r},512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMatchedAllocation=n,t.parseFromStringifiedSegments=o,t.getMatchedTraffic=function(e,t,r,a){return e.find((function(e){return!!(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,r,a)}))},t.getMatchedTrafficAndAllocation=function(e,t,r,a,s){var u=e.find((function(e){return(0,i.allGroupSegmentsAreMatched)(o(e.segments),t,a,s)}));return u?{matchedTraffic:u,matchedAllocation:n(u,r)}:{matchedTraffic:void 0,matchedAllocation:void 0}},t.findForceFromFeature=function(e,t,r,n){var o={force:void 0,forceIndex:void 0};if(!e.force)return o;for(var s=0;s<e.force.length;s++){var u=e.force[s];if(u.conditions&&(0,a.allConditionsAreMatched)(u.conditions,t,n)){o.force=u,o.forceIndex=s;break}if(u.segments&&(0,i.allGroupSegmentsAreMatched)(u.segments,t,r,n)){o.force=u,o.forceIndex=s;break}}return o};var i=r(826),a=r(186);function n(e,t){for(var r=0,i=e.allocation;r<i.length;r++){var a=i[r],n=a.range,o=n[0],s=n[1];if(a.range&&o<=t&&s>=t)return a}}function o(e){return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?JSON.parse(e):e}},166:function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,a)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(906),t),a(r(247),t),a(r(584),t),a(r(186),t),a(r(40),t)},247:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeaturevisorInstance=t.EvaluationReason=void 0,t.getValueByType=h,t.createInstance=function(e){return new g(e)};var i,a=r(584),n=r(649),o=r(40),s=r(906),u=r(512),l=r(186),f=r(826),c={schemaVersion:"1",revision:"unknown",attributes:[],segments:[],features:[]};function d(e,t){return t?t(e):fetch(e).then((function(e){return e.json()}))}function h(e,t){try{if(void 0===e)return;switch(t){case"string":return"string"==typeof e?e:void 0;case"integer":return parseInt(e,10);case"double":return parseFloat(e);case"boolean":return!0===e;case"array":return Array.isArray(e)?e:void 0;case"object":return"object"==typeof e?e:void 0;default:return e}}catch(e){return}}!function(e){e.NOT_FOUND="not_found",e.NO_VARIATIONS="no_variations",e.NO_MATCH="no_match",e.DISABLED="disabled",e.REQUIRED="required",e.OUT_OF_RANGE="out_of_range",e.FORCED="forced",e.INITIAL="initial",e.STICKY="sticky",e.RULE="rule",e.ALLOCATED="allocated",e.DEFAULTED="defaulted",e.OVERRIDE="override",e.ERROR="error"}(i||(t.EvaluationReason=i={}));var g=function(){function e(e){var t=this;this.bucketKeySeparator=e.bucketKeySeparator||".",this.configureBucketKey=e.configureBucketKey,this.configureBucketValue=e.configureBucketValue,this.datafileUrl=e.datafileUrl,this.handleDatafileFetch=e.handleDatafileFetch,this.initialFeatures=e.initialFeatures,this.interceptContext=e.interceptContext,this.logger=e.logger||(0,a.createLogger)(),this.refreshInterval=e.refreshInterval,this.stickyFeatures=e.stickyFeatures,this.emitter=new o.Emitter,this.statuses={ready:!1,refreshInProgress:!1},e.onReady&&this.emitter.addListener("ready",e.onReady),e.onRefresh&&this.emitter.addListener("refresh",e.onRefresh),e.onUpdate&&this.emitter.addListener("update",e.onUpdate),e.onActivation&&this.emitter.addListener("activation",e.onActivation);var r=this.emitter.addListener.bind(this.emitter);this.on=r,this.addListener=r;var i=this.emitter.removeListener.bind(this.emitter);if(this.off=i,this.removeListener=i,this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter),e.datafileUrl)this.setDatafile(e.datafile||c),d(e.datafileUrl,e.handleDatafileFetch).then((function(e){t.setDatafile(e),t.statuses.ready=!0,t.emitter.emit("ready"),t.refreshInterval&&t.startRefreshing()})).catch((function(e){t.logger.error("failed to fetch datafile",{error:e})}));else{if(!e.datafile)throw new Error("Featurevisor SDK instance cannot be created without both `datafile` and `datafileUrl` options");this.setDatafile(e.datafile),this.statuses.ready=!0,setTimeout((function(){t.emitter.emit("ready")}),0)}}return e.prototype.setLogLevels=function(e){this.logger.setLevels(e)},e.prototype.onReady=function(){var e=this;return new Promise((function(t){if(e.statuses.ready)return t(e);var r=function(){e.emitter.removeListener("ready",r),t(e)};e.emitter.addListener("ready",r)}))},e.prototype.setDatafile=function(e){try{this.datafileReader=new n.DatafileReader("string"==typeof e?JSON.parse(e):e)}catch(e){this.logger.error("could not parse datafile",{error:e})}},e.prototype.setStickyFeatures=function(e){this.stickyFeatures=e},e.prototype.getRevision=function(){return this.datafileReader.getRevision()},e.prototype.getFeature=function(e){return"string"==typeof e?this.datafileReader.getFeature(e):e},e.prototype.getBucketKey=function(e,t){var r,i,a=e.key;if("string"==typeof e.bucketBy)r="plain",i=[e.bucketBy];else if(Array.isArray(e.bucketBy))r="and",i=e.bucketBy;else{if("object"!=typeof e.bucketBy||!Array.isArray(e.bucketBy.or))throw this.logger.error("invalid bucketBy",{featureKey:a,bucketBy:e.bucketBy}),new Error("invalid bucketBy");r="or",i=e.bucketBy.or}var n=[];i.forEach((function(e){var i=t[e];void 0!==i&&("plain"===r||"and"===r||0===n.length)&&n.push(i)})),n.push(a);var o=n.join(this.bucketKeySeparator);return this.configureBucketKey?this.configureBucketKey(e,t,o):o},e.prototype.getBucketValue=function(e,t){var r=this.getBucketKey(e,t),i=(0,s.getBucketedNumber)(r);return this.configureBucketValue?{bucketKey:r,bucketValue:this.configureBucketValue(e,t,i)}:{bucketKey:r,bucketValue:i}},e.prototype.isReady=function(){return this.statuses.ready},e.prototype.refresh=function(){var e=this;return this.logger.debug("refreshing datafile"),this.statuses.refreshInProgress?this.logger.warn("refresh in progress, skipping"):this.datafileUrl?(this.statuses.refreshInProgress=!0,void d(this.datafileUrl,this.handleDatafileFetch).then((function(t){var r=e.getRevision()!==t.revision;e.setDatafile(t),e.logger.info("refreshed datafile"),e.emitter.emit("refresh"),r&&e.emitter.emit("update"),e.statuses.refreshInProgress=!1})).catch((function(t){e.logger.error("failed to refresh datafile",{error:t}),e.statuses.refreshInProgress=!1}))):this.logger.error("cannot refresh since `datafileUrl` is not provided")},e.prototype.startRefreshing=function(){var e=this;return this.datafileUrl?this.intervalId?this.logger.warn("refreshing has already started"):this.refreshInterval?void(this.intervalId=setInterval((function(){e.refresh()}),1e3*this.refreshInterval)):this.logger.warn("no `refreshInterval` option provided"):this.logger.error("cannot start refreshing since `datafileUrl` is not provided")},e.prototype.stopRefreshing=function(){if(!this.intervalId)return this.logger.warn("refreshing has not started yet");clearInterval(this.intervalId)},e.prototype.evaluateFlag=function(e,t){var r,a=this;void 0===t&&(t={});try{var n="string"==typeof e?e:e.key;if(this.stickyFeatures&&this.stickyFeatures[n]&&void 0!==this.stickyFeatures[n].enabled)return r={featureKey:n,reason:i.STICKY,sticky:this.stickyFeatures[n],enabled:this.stickyFeatures[n].enabled},this.logger.debug("using sticky enabled",r),r;if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[n]&&void 0!==this.initialFeatures[n].enabled)return r={featureKey:n,reason:i.INITIAL,initial:this.initialFeatures[n],enabled:this.initialFeatures[n].enabled},this.logger.debug("using initial enabled",r),r;var o=this.getFeature(e);if(!o)return r={featureKey:n,reason:i.NOT_FOUND},this.logger.warn("feature not found",r),r;o.deprecated&&this.logger.warn("feature is deprecated",{featureKey:o.key});var s=this.interceptContext?this.interceptContext(t):t,l=(0,u.findForceFromFeature)(o,t,this.datafileReader,this.logger),f=l.force,c=l.forceIndex;if(f&&void 0!==f.enabled)return r={featureKey:o.key,reason:i.FORCED,forceIndex:c,force:f,enabled:f.enabled},this.logger.debug("forced enabled found",r),r;if(o.required&&o.required.length>0){var d=o.required.every((function(e){var t,r;return"string"==typeof e?t=e:(t=e.key,r=e.variation),!!a.isEnabled(t,s)&&(void 0===r||a.getVariation(t,s)===r)}));if(!d)return r={featureKey:o.key,reason:i.REQUIRED,required:o.required,enabled:d},this.logger.debug("required features not enabled",r),r}var h=this.getBucketValue(o,s),g=h.bucketKey,v=h.bucketValue,y=(0,u.getMatchedTraffic)(o.traffic,s,this.datafileReader,this.logger);if(y){if(o.ranges&&o.ranges.length>0)return o.ranges.find((function(e){return v>=e[0]&&v<e[1]}))?(r={featureKey:o.key,reason:i.ALLOCATED,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:void 0===y.enabled||y.enabled},this.logger.debug("matched",r),r):(r={featureKey:o.key,reason:i.OUT_OF_RANGE,bucketKey:g,bucketValue:v,enabled:!1},this.logger.debug("not matched",r),r);if(void 0!==y.enabled)return r={featureKey:o.key,reason:i.OVERRIDE,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:y.enabled},this.logger.debug("override from rule",r),r;if(v<=y.percentage)return r={featureKey:o.key,reason:i.RULE,bucketKey:g,bucketValue:v,ruleKey:y.key,traffic:y,enabled:!0},this.logger.debug("matched traffic",r),r}return r={featureKey:o.key,reason:i.NO_MATCH,bucketKey:g,bucketValue:v,enabled:!1},this.logger.debug("nothing matched",r),r}catch(t){return r={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,error:t},this.logger.error("error",r),r}},e.prototype.isEnabled=function(e,t){void 0===t&&(t={});try{return!0===this.evaluateFlag(e,t).enabled}catch(t){return this.logger.error("isEnabled",{featureKey:e,error:t}),!1}},e.prototype.evaluateVariation=function(e,t){var r;void 0===t&&(t={});try{var a="string"==typeof e?e:e.key;if(!1===this.evaluateFlag(e,t).enabled)return r={featureKey:a,reason:i.DISABLED},this.logger.debug("feature is disabled",r),r;if(this.stickyFeatures&&this.stickyFeatures[a]&&void 0!==(n=this.stickyFeatures[a].variation))return r={featureKey:a,reason:i.STICKY,variationValue:n},this.logger.debug("using sticky variation",r),r;if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[a]&&void 0!==this.initialFeatures[a].variation){var n=this.initialFeatures[a].variation;return r={featureKey:a,reason:i.INITIAL,variationValue:n},this.logger.debug("using initial variation",r),r}var o=this.getFeature(e);if(!o)return r={featureKey:a,reason:i.NOT_FOUND},this.logger.warn("feature not found",r),r;if(!o.variations||0===o.variations.length)return r={featureKey:a,reason:i.NO_VARIATIONS},this.logger.warn("no variations",r),r;var s=this.interceptContext?this.interceptContext(t):t,l=(0,u.findForceFromFeature)(o,t,this.datafileReader,this.logger),f=l.force,c=l.forceIndex;if(f&&f.variation&&(p=o.variations.find((function(e){return e.value===f.variation}))))return r={featureKey:o.key,reason:i.FORCED,forceIndex:c,force:f,variation:p},this.logger.debug("forced variation found",r),r;var d=this.getBucketValue(o,s),h=d.bucketKey,g=d.bucketValue,v=(0,u.getMatchedTrafficAndAllocation)(o.traffic,s,g,this.datafileReader,this.logger),y=v.matchedTraffic,b=v.matchedAllocation;if(y){var p;if(y.variation&&(p=o.variations.find((function(e){return e.value===y.variation}))))return r={featureKey:o.key,reason:i.RULE,bucketKey:h,bucketValue:g,ruleKey:y.key,traffic:y,variation:p},this.logger.debug("override from rule",r),r;if(b&&b.variation&&(p=o.variations.find((function(e){return e.value===b.variation}))))return r={featureKey:o.key,reason:i.ALLOCATED,bucketKey:h,bucketValue:g,ruleKey:y.key,traffic:y,variation:p},this.logger.debug("allocated variation",r),r}return r={featureKey:o.key,reason:i.NO_MATCH,bucketKey:h,bucketValue:g},this.logger.debug("no matched variation",r),r}catch(t){return r={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,error:t},this.logger.error("error",r),r}},e.prototype.getVariation=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t);return void 0!==r.variationValue?r.variationValue:r.variation?r.variation.value:void 0}catch(t){return void this.logger.error("getVariation",{featureKey:e,error:t})}},e.prototype.activate=function(e,t){void 0===t&&(t={});try{var r=this.evaluateVariation(e,t),i=r.variation?r.variation.value:r.variationValue;if(void 0===i)return;var a=this.interceptContext?this.interceptContext(t):t,n={};return this.datafileReader.getAllAttributes().filter((function(e){return!0===e.capture})).forEach((function(e){void 0!==a[e.key]&&(n[e.key]=t[e.key])})),this.emitter.emit("activation",e,i,a,n,r),i}catch(t){return void this.logger.error("activate",{featureKey:e,error:t})}},e.prototype.evaluateVariable=function(e,t,r){var a,n=this;void 0===r&&(r={});try{var o,s="string"==typeof e?e:e.key;if(!1===this.evaluateFlag(e,r).enabled)return a={featureKey:s,reason:i.DISABLED},this.logger.debug("feature is disabled",a),a;if(this.stickyFeatures&&this.stickyFeatures[s]&&(o=this.stickyFeatures[s].variables)){var c=o[t];if(void 0!==c)return a={featureKey:s,reason:i.STICKY,variableKey:t,variableValue:c},this.logger.debug("using sticky variable",a),a}if(this.statuses&&!this.statuses.ready&&this.initialFeatures&&this.initialFeatures[s]&&(o=this.initialFeatures[s].variables)&&void 0!==o[t])return a={featureKey:s,reason:i.INITIAL,variableKey:t,variableValue:o[t]},this.logger.debug("using initial variable",a),a;var d=this.getFeature(e);if(!d)return a={featureKey:s,reason:i.NOT_FOUND,variableKey:t},this.logger.warn("feature not found in datafile",a),a;var h=Array.isArray(d.variablesSchema)?d.variablesSchema.find((function(e){return e.key===t})):void 0;if(!h)return a={featureKey:s,reason:i.NOT_FOUND,variableKey:t},this.logger.warn("variable schema not found",a),a;var g=this.interceptContext?this.interceptContext(r):r,v=(0,u.findForceFromFeature)(d,r,this.datafileReader,this.logger),y=v.force,b=v.forceIndex;if(y&&y.variables&&void 0!==y.variables[t])return a={featureKey:d.key,reason:i.FORCED,forceIndex:b,force:y,variableKey:t,variableSchema:h,variableValue:y.variables[t]},this.logger.debug("forced variable",a),a;var p=this.getBucketValue(d,g),k=p.bucketKey,m=p.bucketValue,K=(0,u.getMatchedTrafficAndAllocation)(d.traffic,g,m,this.datafileReader,this.logger),A=K.matchedTraffic,V=K.matchedAllocation;if(A){if(A.variables&&void 0!==A.variables[t])return a={featureKey:d.key,reason:i.RULE,bucketKey:k,bucketValue:m,ruleKey:A.key,traffic:A,variableKey:t,variableSchema:h,variableValue:A.variables[t]},this.logger.debug("override from rule",a),a;var O;if(y&&y.variation?O=y.variation:V&&V.variation&&(O=V.variation),O&&Array.isArray(d.variations)){var F=d.variations.find((function(e){return e.value===O}));if(F&&F.variables){var E=F.variables.find((function(e){return e.key===t}));if(E){if(E.overrides){var I=E.overrides.find((function(e){return e.conditions?(0,l.allConditionsAreMatched)("string"==typeof e.conditions?JSON.parse(e.conditions):e.conditions,g,n.logger):!!e.segments&&(0,f.allGroupSegmentsAreMatched)((0,u.parseFromStringifiedSegments)(e.segments),g,n.datafileReader,n.logger)}));if(I)return a={featureKey:d.key,reason:i.OVERRIDE,bucketKey:k,bucketValue:m,ruleKey:A.key,traffic:A,variableKey:t,variableSchema:h,variableValue:I.value},this.logger.debug("variable override",a),a}if(void 0!==E.value)return a={featureKey:d.key,reason:i.ALLOCATED,bucketKey:k,bucketValue:m,ruleKey:A.key,traffic:A,variableKey:t,variableSchema:h,variableValue:E.value},this.logger.debug("allocated variable",a),a}}}}return a={featureKey:d.key,reason:i.DEFAULTED,bucketKey:k,bucketValue:m,variableKey:t,variableSchema:h,variableValue:h.defaultValue},this.logger.debug("using default value",a),a}catch(r){return a={featureKey:"string"==typeof e?e:e.key,reason:i.ERROR,variableKey:t,error:r},this.logger.error("error",a),a}},e.prototype.getVariable=function(e,t,r){void 0===r&&(r={});try{var i=this.evaluateVariable(e,t,r);return void 0!==i.variableValue?i.variableSchema&&"json"===i.variableSchema.type&&"string"==typeof i.variableValue?JSON.parse(i.variableValue):i.variableValue:void 0}catch(r){return void this.logger.error("getVariable",{featureKey:e,variableKey:t,error:r})}},e.prototype.getVariableBoolean=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"boolean")},e.prototype.getVariableString=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"string")},e.prototype.getVariableInteger=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"integer")},e.prototype.getVariableDouble=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"double")},e.prototype.getVariableArray=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"array")},e.prototype.getVariableObject=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"object")},e.prototype.getVariableJSON=function(e,t,r){return void 0===r&&(r={}),h(this.getVariable(e,t,r),"json")},e}();t.FeaturevisorInstance=g},584:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=t.defaultLogHandler=t.defaultLogLevels=t.loggerPrefix=void 0,t.createLogger=function(e){void 0===e&&(e={});var i=e.levels||t.defaultLogLevels,a=e.handler||t.defaultLogHandler;return new r({levels:i,handler:a})},t.loggerPrefix="[Featurevisor]",t.defaultLogLevels=["warn","error"],t.defaultLogHandler=function(e,r,i){switch(void 0===i&&(i={}),e){case"debug":console.log(t.loggerPrefix,r,i);break;case"info":console.info(t.loggerPrefix,r,i);break;case"warn":console.warn(t.loggerPrefix,r,i);break;case"error":console.error(t.loggerPrefix,r,i)}};var r=function(){function e(e){this.levels=e.levels,this.handle=e.handler}return e.prototype.setLevels=function(e){this.levels=e},e.prototype.log=function(e,t,r){-1!==this.levels.indexOf(e)&&this.handle(e,t,r)},e.prototype.debug=function(e,t){this.log("debug",e,t)},e.prototype.info=function(e,t){this.log("info",e,t)},e.prototype.warn=function(e,t){this.log("warn",e,t)},e.prototype.error=function(e,t){this.log("error",e,t)},e}();t.Logger=r},826:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.segmentIsMatched=a,t.allGroupSegmentsAreMatched=function e(t,r,i,n){if("*"===t)return!0;if("string"==typeof t){var o=i.getSegment(t);return!!o&&a(o,r,n)}if("object"==typeof t){if("and"in t&&Array.isArray(t.and))return t.and.every((function(t){return e(t,r,i,n)}));if("or"in t&&Array.isArray(t.or))return t.or.some((function(t){return e(t,r,i,n)}));if("not"in t&&Array.isArray(t.not))return t.not.every((function(t){return!1===e(t,r,i,n)}))}return!!Array.isArray(t)&&t.every((function(t){return e(t,r,i,n)}))};var i=r(186);function a(e,t,r){return(0,i.allConditionsAreMatched)(e.conditions,t,r)}}},t={};function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,r),n.exports}return r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(166)})()));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|