@unleash/proxy-client-vue 0.0.7-beta.3 → 0.0.7-beta.4

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.
@@ -0,0 +1,65 @@
1
+ import { UnleashClient } from "unleash-proxy-client";
2
+ declare const _sfc_main: import("vue").DefineComponent<{
3
+ config: {
4
+ type: null;
5
+ required: false;
6
+ };
7
+ unleashClient: {
8
+ type: null;
9
+ required: false;
10
+ };
11
+ startClient: {
12
+ type: BooleanConstructor;
13
+ required: false;
14
+ };
15
+ }, {
16
+ context: import("vue").ToRefs<{
17
+ on: (event: string, args_0: Function, args_1: any) => UnleashClient | undefined;
18
+ updateContext: (context: import("unleash-proxy-client").IContext) => Promise<void>;
19
+ isEnabled: (name: string) => boolean | undefined;
20
+ getVariant: (name: string) => import("unleash-proxy-client").IVariant | undefined;
21
+ client: {
22
+ getAllToggles: () => import("unleash-proxy-client").IToggle[];
23
+ isEnabled: (toggleName: string) => boolean;
24
+ getVariant: (toggleName: string) => import("unleash-proxy-client").IVariant;
25
+ updateContext: (context: import("unleash-proxy-client").IMutableContext) => Promise<void>;
26
+ getContext: () => {
27
+ appName: string;
28
+ environment?: string | undefined;
29
+ userId?: string | undefined;
30
+ sessionId?: string | undefined;
31
+ remoteAddress?: string | undefined;
32
+ properties?: {
33
+ [key: string]: string;
34
+ } | undefined;
35
+ };
36
+ setContextField: (field: string, value: string) => void;
37
+ start: () => Promise<void>;
38
+ stop: () => void;
39
+ on: (event: string, callback: Function, ctx?: any) => UnleashClient;
40
+ once: (event: string, callback: Function, ctx?: any) => UnleashClient;
41
+ emit: (event: string, ...args: any[]) => UnleashClient;
42
+ off: (event: string, callback?: Function | undefined) => UnleashClient;
43
+ } | undefined;
44
+ flagsReady: boolean;
45
+ flagsError: null;
46
+ }>;
47
+ start: () => void;
48
+ update: (property: string, value: any) => void;
49
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
50
+ config: {
51
+ type: null;
52
+ required: false;
53
+ };
54
+ unleashClient: {
55
+ type: null;
56
+ required: false;
57
+ };
58
+ startClient: {
59
+ type: BooleanConstructor;
60
+ required: false;
61
+ };
62
+ }>>, {
63
+ startClient: boolean;
64
+ }>;
65
+ export default _sfc_main;
package/dist/env.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
3
  declare module '*.vue' {
4
- import type { DefineComponent } from 'vue-demi'
4
+ import type { DefineComponent } from 'vue'
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6
6
  const component: DefineComponent<{}, {}, any>
7
7
  export default component
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export type { IConfig, IContext, IMutableContext, IVariant, IToggle, IStorageProvider } from 'unleash-proxy-client';
2
2
  export { UnleashClient, LocalStorageProvider, InMemoryStorageProvider } from 'unleash-proxy-client';
3
3
  import { ContextStateSymbol, ContextUpdateSymbol } from './context';
4
- import FlagProvider from './FlagProvider';
4
+ import FlagProvider from './FlagProvider.vue';
5
5
  import useFlag from './useFlag';
6
6
  import useFlagsStatus from './useFlagsStatus';
7
7
  import useVariant from './useVariant';
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ref, reactive, toRefs, defineComponent, provide, onMounted, inject, onUnmounted } from "vue";
1
+ import { toRefs, ref, reactive, defineComponent, provide, onMounted, renderSlot, inject, onUnmounted } from "vue";
2
2
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
3
3
  function getAugmentedNamespace(n) {
4
4
  if (n.__esModule)
@@ -974,21 +974,20 @@ var EventsHandler = function() {
974
974
  EventsHandler2.prototype.generateEventId = function() {
975
975
  return (0, uuid_1.v4)();
976
976
  };
977
- EventsHandler2.prototype.createImpressionEvent = function(context, enabled, featureName, eventType, impressionData, variant) {
978
- var baseEvent = this.createBaseEvent(context, enabled, featureName, eventType, impressionData);
977
+ EventsHandler2.prototype.createImpressionEvent = function(context, enabled, featureName, eventType, variant) {
978
+ var baseEvent = this.createBaseEvent(context, enabled, featureName, eventType);
979
979
  if (variant) {
980
980
  return __assign(__assign({}, baseEvent), { variant });
981
981
  }
982
982
  return baseEvent;
983
983
  };
984
- EventsHandler2.prototype.createBaseEvent = function(context, enabled, featureName, eventType, impressionData) {
984
+ EventsHandler2.prototype.createBaseEvent = function(context, enabled, featureName, eventType) {
985
985
  return {
986
986
  eventType,
987
987
  eventId: this.generateEventId(),
988
988
  context,
989
989
  enabled,
990
- featureName,
991
- impressionData
990
+ featureName
992
991
  };
993
992
  };
994
993
  return EventsHandler2;
@@ -1190,7 +1189,7 @@ util.notNullOrUndefined = notNullOrUndefined;
1190
1189
  var UnleashClient2 = function(_super) {
1191
1190
  __extends(UnleashClient3, _super);
1192
1191
  function UnleashClient3(_a) {
1193
- var storageProvider = _a.storageProvider, url = _a.url, clientKey = _a.clientKey, _b = _a.disableRefresh, disableRefresh = _b === void 0 ? false : _b, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 30 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 30 : _d, _e = _a.disableMetrics, disableMetrics = _e === void 0 ? false : _e, appName = _a.appName, _f = _a.environment, environment = _f === void 0 ? "default" : _f, context = _a.context, _g = _a.fetch, fetch2 = _g === void 0 ? (0, exports.resolveFetch)() : _g, bootstrap = _a.bootstrap, _h = _a.bootstrapOverride, bootstrapOverride = _h === void 0 ? true : _h, _j = _a.headerName, headerName = _j === void 0 ? "Authorization" : _j, _k = _a.customHeaders, customHeaders = _k === void 0 ? {} : _k, _l = _a.impressionDataAll, impressionDataAll = _l === void 0 ? false : _l;
1192
+ var storageProvider = _a.storageProvider, url = _a.url, clientKey = _a.clientKey, _b = _a.disableRefresh, disableRefresh = _b === void 0 ? false : _b, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 30 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 30 : _d, _e = _a.disableMetrics, disableMetrics = _e === void 0 ? false : _e, appName = _a.appName, _f = _a.environment, environment = _f === void 0 ? "default" : _f, context = _a.context, _g = _a.fetch, fetch2 = _g === void 0 ? (0, exports.resolveFetch)() : _g, bootstrap = _a.bootstrap, _h = _a.bootstrapOverride, bootstrapOverride = _h === void 0 ? true : _h, _j = _a.headerName, headerName = _j === void 0 ? "Authorization" : _j, _k = _a.customHeaders, customHeaders = _k === void 0 ? {} : _k;
1194
1193
  var _this = _super.call(this) || this;
1195
1194
  _this.toggles = [];
1196
1195
  _this.etag = "";
@@ -1205,7 +1204,6 @@ util.notNullOrUndefined = notNullOrUndefined;
1205
1204
  throw new Error("appName is required.");
1206
1205
  }
1207
1206
  _this.eventsHandler = new events_handler_1.default();
1208
- _this.impressionDataAll = impressionDataAll;
1209
1207
  _this.toggles = bootstrap && bootstrap.length > 0 ? bootstrap : [];
1210
1208
  _this.url = url instanceof URL ? url : new URL(url);
1211
1209
  _this.clientKey = clientKey;
@@ -1248,8 +1246,8 @@ util.notNullOrUndefined = notNullOrUndefined;
1248
1246
  });
1249
1247
  var enabled = toggle ? toggle.enabled : false;
1250
1248
  this.metrics.count(toggleName, enabled);
1251
- if ((toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) || this.impressionDataAll) {
1252
- var event_1 = this.eventsHandler.createImpressionEvent(this.context, enabled, toggleName, IMPRESSION_EVENTS.IS_ENABLED, (toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) || void 0);
1249
+ if (toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) {
1250
+ var event_1 = this.eventsHandler.createImpressionEvent(this.context, enabled, toggleName, IMPRESSION_EVENTS.IS_ENABLED);
1253
1251
  this.emit(exports.EVENTS.IMPRESSION, event_1);
1254
1252
  }
1255
1253
  return enabled;
@@ -1258,14 +1256,17 @@ util.notNullOrUndefined = notNullOrUndefined;
1258
1256
  var toggle = this.toggles.find(function(t) {
1259
1257
  return t.name === toggleName;
1260
1258
  });
1261
- var enabled = (toggle === null || toggle === void 0 ? void 0 : toggle.enabled) || false;
1262
- var variant = toggle ? toggle.variant : defaultVariant;
1263
- this.metrics.count(toggleName, true);
1264
- if ((toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) || this.impressionDataAll) {
1265
- var event_2 = this.eventsHandler.createImpressionEvent(this.context, enabled, toggleName, IMPRESSION_EVENTS.GET_VARIANT, (toggle === null || toggle === void 0 ? void 0 : toggle.impressionData) || void 0, variant.name);
1266
- this.emit(exports.EVENTS.IMPRESSION, event_2);
1259
+ if (toggle) {
1260
+ this.metrics.count(toggleName, true);
1261
+ if (toggle.impressionData) {
1262
+ var event_2 = this.eventsHandler.createImpressionEvent(this.context, toggle.enabled, toggleName, IMPRESSION_EVENTS.GET_VARIANT, toggle.variant.name);
1263
+ this.emit(exports.EVENTS.IMPRESSION, event_2);
1264
+ }
1265
+ return toggle.variant;
1266
+ } else {
1267
+ this.metrics.count(toggleName, false);
1268
+ return defaultVariant;
1267
1269
  }
1268
- return variant;
1269
1270
  };
1270
1271
  UnleashClient3.prototype.updateContext = function(context) {
1271
1272
  return __awaiter2(this, void 0, void 0, function() {
@@ -1278,8 +1279,7 @@ util.notNullOrUndefined = notNullOrUndefined;
1278
1279
  }
1279
1280
  staticContext = {
1280
1281
  environment: this.context.environment,
1281
- appName: this.context.appName,
1282
- sessionId: this.context.sessionId
1282
+ appName: this.context.appName
1283
1283
  };
1284
1284
  this.context = __assign2(__assign2({}, staticContext), context);
1285
1285
  if (!this.timerRef)
@@ -1431,10 +1431,10 @@ util.notNullOrUndefined = notNullOrUndefined;
1431
1431
  switch (_a.label) {
1432
1432
  case 0:
1433
1433
  if (!this.fetch)
1434
- return [3, 8];
1434
+ return [3, 7];
1435
1435
  _a.label = 1;
1436
1436
  case 1:
1437
- _a.trys.push([1, 7, , 8]);
1437
+ _a.trys.push([1, 6, , 7]);
1438
1438
  context = this.context;
1439
1439
  urlWithQuery_1 = new URL(this.url.toString());
1440
1440
  Object.entries(context).filter(util_1.notNullOrUndefined).forEach(function(_a2) {
@@ -1467,24 +1467,15 @@ util.notNullOrUndefined = notNullOrUndefined;
1467
1467
  this.emit(exports.EVENTS.READY);
1468
1468
  this.readyEventEmitted = true;
1469
1469
  }
1470
- return [3, 6];
1470
+ _a.label = 5;
1471
1471
  case 5:
1472
- if (!response.ok && response.status !== 304) {
1473
- console.error("Unleash: Fetching feature toggles did not have an ok response");
1474
- this.emit(exports.EVENTS.ERROR, {
1475
- type: "HttpError",
1476
- code: response.status
1477
- });
1478
- }
1479
- _a.label = 6;
1472
+ return [3, 7];
1480
1473
  case 6:
1481
- return [3, 8];
1482
- case 7:
1483
1474
  e_1 = _a.sent();
1484
1475
  console.error("Unleash: unable to fetch feature toggles", e_1);
1485
1476
  this.emit(exports.EVENTS.ERROR, e_1);
1486
- return [3, 8];
1487
- case 8:
1477
+ return [3, 7];
1478
+ case 7:
1488
1479
  return [2];
1489
1480
  }
1490
1481
  });
@@ -1506,10 +1497,8 @@ function useUnleashProvide({
1506
1497
  const flagsReady = ref(false);
1507
1498
  const flagsError = ref(null);
1508
1499
  if (!config && !unleashClient) {
1509
- console.warn(
1510
- `You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
1511
- checking if the client exists before rendering.`
1512
- );
1500
+ console.warn(`You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
1501
+ checking if the client exists before rendering.`);
1513
1502
  }
1514
1503
  if (!client.value && config) {
1515
1504
  client.value = new build.UnleashClient(config);
@@ -1560,99 +1549,86 @@ function useUnleashProvide({
1560
1549
  start
1561
1550
  };
1562
1551
  }
1563
- var FlagProvider = defineComponent({
1564
- name: "FlagProvider",
1552
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1553
+ __name: "FlagProvider",
1565
1554
  props: {
1566
- config: {
1567
- type: Object,
1568
- required: false
1569
- },
1570
- unleashClient: {
1571
- type: Object,
1572
- required: false
1573
- },
1574
- startClient: {
1575
- type: Boolean,
1576
- required: false,
1577
- default: true
1578
- }
1555
+ config: null,
1556
+ unleashClient: null,
1557
+ startClient: { type: Boolean }
1579
1558
  },
1580
- setup(props, { slots }) {
1581
- const { context, update, start } = useUnleashProvide({
1582
- config: props.config,
1583
- unleashClient: props.unleashClient,
1584
- startClient: props.startClient
1585
- });
1559
+ setup(__props) {
1560
+ const {
1561
+ config,
1562
+ unleashClient,
1563
+ startClient = true
1564
+ } = __props;
1565
+ const { context, start, update } = useUnleashProvide({ config, unleashClient, startClient });
1586
1566
  provide(ContextStateSymbol, context);
1587
1567
  provide(ContextUpdateSymbol, update);
1588
1568
  onMounted(() => {
1589
1569
  start();
1590
1570
  });
1591
- return () => {
1592
- var _a;
1593
- return (_a = slots.default) == null ? void 0 : _a.call(slots);
1571
+ return (_ctx, _cache) => {
1572
+ return renderSlot(_ctx.$slots, "default");
1594
1573
  };
1595
1574
  }
1596
1575
  });
1597
1576
  const useFlag = (name) => {
1598
- const { isEnabled, client } = inject(ContextStateSymbol) || {};
1599
- const flag = ref(!!isEnabled.value(name));
1577
+ const { isEnabled, client } = inject(ContextStateSymbol, {});
1578
+ const flag = ref(Boolean(isEnabled == null ? void 0 : isEnabled.value(name)));
1600
1579
  function onUpdate() {
1601
- const enabled = isEnabled.value(name);
1580
+ const enabled = isEnabled == null ? void 0 : isEnabled.value(name);
1602
1581
  if (enabled !== flag.value) {
1603
1582
  flag.value = !!enabled;
1604
1583
  }
1605
1584
  }
1606
1585
  function onReady() {
1607
- flag.value = isEnabled.value(name);
1586
+ flag.value = Boolean(isEnabled == null ? void 0 : isEnabled.value(name));
1608
1587
  }
1609
- client.value.on("ready", onReady);
1610
- client.value.on("update", onUpdate);
1588
+ client == null ? void 0 : client.value.on("ready", onReady);
1589
+ client == null ? void 0 : client.value.on("update", onUpdate);
1611
1590
  onUnmounted(() => {
1612
- client.value.off("ready", onReady);
1613
- client.value.off("update", onUpdate);
1591
+ client == null ? void 0 : client.value.off("ready", onReady);
1592
+ client == null ? void 0 : client.value.off("update", onUpdate);
1614
1593
  });
1615
1594
  return flag;
1616
1595
  };
1617
1596
  const useFlagsStatus = () => {
1618
- const { flagsReady, flagsError } = inject(ContextStateSymbol) || {};
1597
+ const { flagsReady, flagsError } = inject(ContextStateSymbol, {});
1619
1598
  return { flagsReady, flagsError };
1620
1599
  };
1621
1600
  const useVariant = (name) => {
1622
- const { getVariant, client } = inject(ContextStateSymbol) || {};
1623
- const variant = ref(getVariant.value(name));
1601
+ const { getVariant, client } = inject(ContextStateSymbol, {});
1602
+ const variant = ref(getVariant == null ? void 0 : getVariant.value(name));
1624
1603
  function onUpdate() {
1625
- const newVariant = getVariant.value(name);
1626
- if (newVariant.name !== variant.value.name || newVariant.enabled !== variant.value.enabled) {
1604
+ var _a, _b;
1605
+ const newVariant = getVariant == null ? void 0 : getVariant.value(name);
1606
+ if ((newVariant == null ? void 0 : newVariant.name) !== ((_a = variant.value) == null ? void 0 : _a.name) || (newVariant == null ? void 0 : newVariant.enabled) !== ((_b = variant.value) == null ? void 0 : _b.enabled)) {
1627
1607
  variant.value = newVariant;
1628
1608
  }
1629
1609
  }
1630
1610
  function onReady() {
1631
- variant.value = getVariant.value(name);
1611
+ variant.value = getVariant == null ? void 0 : getVariant.value(name);
1632
1612
  }
1633
- client.value.on("ready", onReady);
1634
- client.value.on("update", onUpdate);
1613
+ client == null ? void 0 : client.value.on("ready", onReady);
1614
+ client == null ? void 0 : client.value.on("update", onUpdate);
1635
1615
  onUnmounted(() => {
1636
- client.value.off("ready", onReady);
1637
- client.value.off("update", onUpdate);
1616
+ client == null ? void 0 : client.value.off("ready", onReady);
1617
+ client == null ? void 0 : client.value.off("update", onUpdate);
1638
1618
  });
1639
1619
  return variant || {};
1640
1620
  };
1641
1621
  const useUnleashContext = () => {
1642
- const { updateContext } = inject(ContextStateSymbol) || {};
1643
- return updateContext.value;
1622
+ const { updateContext } = inject(ContextStateSymbol, {});
1623
+ return updateContext == null ? void 0 : updateContext.value;
1644
1624
  };
1645
1625
  const useUnleashClient = () => {
1646
- const { client } = inject(ContextStateSymbol) || {};
1647
- return client.value;
1626
+ const { client } = inject(ContextStateSymbol, {});
1627
+ return client == null ? void 0 : client.value;
1648
1628
  };
1649
1629
  const plugin = {
1650
1630
  install(app, { config, unleashClient, startClient }) {
1651
- const { context, update, start } = useUnleashProvide({
1652
- config,
1653
- unleashClient,
1654
- startClient
1655
- });
1631
+ const { context, update, start } = useUnleashProvide({ config, unleashClient, startClient });
1656
1632
  app.provide(ContextStateSymbol, context);
1657
1633
  app.provide(ContextUpdateSymbol, update);
1658
1634
  start();
@@ -1661,4 +1637,4 @@ const plugin = {
1661
1637
  var InMemoryStorageProvider = build.InMemoryStorageProvider;
1662
1638
  var LocalStorageProvider$1 = build.LocalStorageProvider;
1663
1639
  var UnleashClient = build.UnleashClient;
1664
- export { ContextStateSymbol, ContextUpdateSymbol, FlagProvider, InMemoryStorageProvider, LocalStorageProvider$1 as LocalStorageProvider, UnleashClient, FlagProvider as default, plugin, useFlag, useFlagsStatus, useUnleashClient, useUnleashContext, useVariant };
1640
+ export { ContextStateSymbol, ContextUpdateSymbol, _sfc_main as FlagProvider, InMemoryStorageProvider, LocalStorageProvider$1 as LocalStorageProvider, UnleashClient, _sfc_main as default, plugin, useFlag, useFlagsStatus, useUnleashClient, useUnleashContext, useVariant };
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(_,I){typeof exports=="object"&&typeof module!="undefined"?I(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],I):(_=typeof globalThis!="undefined"?globalThis:_||self,I(_["proxy-client-vue"]={},_.Vue))})(this,function(_,I){"use strict";var g=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function xe(t){if(t.__esModule)return t;var i=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),i}var F={},z={exports:{}};function Z(){}Z.prototype={on:function(t,i,e){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:i,ctx:e}),this},once:function(t,i,e){var n=this;function a(){n.off(t,a),i.apply(e,arguments)}return a._=i,this.on(t,a,e)},emit:function(t){var i=[].slice.call(arguments,1),e=((this.e||(this.e={}))[t]||[]).slice(),n=0,a=e.length;for(n;n<a;n++)e[n].fn.apply(e[n].ctx,i);return this},off:function(t,i){var e=this.e||(this.e={}),n=e[t],a=[];if(n&&i)for(var r=0,o=n.length;r<o;r++)n[r].fn!==i&&n[r].fn._!==i&&a.push(n[r]);return a.length?e[t]=a:delete e[t],this}},z.exports=Z,z.exports.TinyEmitter=Z;var W={},q=g&&g.__assign||function(){return q=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},q.apply(this,arguments)},Ae=g&&g.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function h(d){try{s(n.next(d))}catch(m){o(m)}}function v(d){try{s(n.throw(d))}catch(m){o(m)}}function s(d){d.done?r(d.value):a(d.value).then(h,v)}s((n=n.apply(t,i||[])).next())})},Ce=g&&g.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function h(s){return function(d){return v([s,d])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(d){s=[6,d],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(W,"__esModule",{value:!0});var Me=function(){function t(i){var e=i.onError,n=i.appName,a=i.metricsInterval,r=i.disableMetrics,o=r===void 0?!1:r,h=i.url,v=i.clientKey,s=i.fetch,d=i.headerName;this.onError=e,this.disabled=o,this.metricsInterval=a*1e3,this.appName=n,this.url=h instanceof URL?h:new URL(h),this.clientKey=v,this.bucket=this.createEmptyBucket(),this.fetch=s,this.headerName=d}return t.prototype.start=function(){var i=this;if(this.disabled)return!1;typeof this.metricsInterval=="number"&&this.metricsInterval>0&&setTimeout(function(){i.startTimer(),i.sendMetrics()},2e3)},t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer)},t.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},t.prototype.sendMetrics=function(){return Ae(this,void 0,void 0,function(){var i,e,n,a;return Ce(this,function(r){switch(r.label){case 0:if(i="".concat(this.url,"/client/metrics"),e=this.getPayload(),this.bucketIsEmpty(e))return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.fetch(i,{cache:"no-cache",method:"POST",headers:(a={},a[this.headerName]=this.clientKey,a.Accept="application/json",a["Content-Type"]="application/json",a),body:JSON.stringify(e)})];case 2:return r.sent(),[3,4];case 3:return n=r.sent(),console.error("Unleash: unable to send feature metrics",n),this.onError(n),[3,4];case 4:return[2]}})})},t.prototype.count=function(i,e){return this.disabled||!this.bucket?!1:(this.assertBucket(i),this.bucket.toggles[i][e?"yes":"no"]++,!0)},t.prototype.assertBucket=function(i){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[i]||(this.bucket.toggles[i]={yes:0,no:0})},t.prototype.startTimer=function(){var i=this;this.timer=setInterval(function(){i.sendMetrics()},this.metricsInterval)},t.prototype.bucketIsEmpty=function(i){return Object.keys(i.bucket.toggles).length===0},t.prototype.getPayload=function(){var i=q(q({},this.bucket),{stop:new Date});return this.bucket=this.createEmptyBucket(),{bucket:i,appName:this.appName,instanceId:"browser"}},t}();W.default=Me;var ee={},de=g&&g.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function h(d){try{s(n.next(d))}catch(m){o(m)}}function v(d){try{s(n.throw(d))}catch(m){o(m)}}function s(d){d.done?r(d.value):a(d.value).then(h,v)}s((n=n.apply(t,i||[])).next())})},he=g&&g.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function h(s){return function(d){return v([s,d])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(d){s=[6,d],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(ee,"__esModule",{value:!0});var ke=function(){function t(){this.store=new Map}return t.prototype.save=function(i,e){return de(this,void 0,void 0,function(){return he(this,function(n){return this.store.set(i,e),[2]})})},t.prototype.get=function(i){return de(this,void 0,void 0,function(){return he(this,function(e){return[2,this.store.get(i)]})})},t}();ee.default=ke;var te={},Pe=g&&g.__awaiter||function(t,i,e,n){function a(r){return r instanceof e?r:new e(function(o){o(r)})}return new(e||(e=Promise))(function(r,o){function h(d){try{s(n.next(d))}catch(m){o(m)}}function v(d){try{s(n.throw(d))}catch(m){o(m)}}function s(d){d.done?r(d.value):a(d.value).then(h,v)}s((n=n.apply(t,i||[])).next())})},je=g&&g.__generator||function(t,i){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,o;return o={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function h(s){return function(d){return v([s,d])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=i.call(t,e)}catch(d){s=[6,d],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(te,"__esModule",{value:!0});var Ve=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(i,e){return Pe(this,void 0,void 0,function(){var n,a;return je(this,function(r){n=JSON.stringify(e),a="".concat(this.prefix,":").concat(i);try{window.localStorage.setItem(a,n)}catch(o){console.error(o)}return[2]})})},t.prototype.get=function(i){try{var e="".concat(this.prefix,":").concat(i),n=window.localStorage.getItem(e);return n?JSON.parse(n):void 0}catch(a){console.error(a)}},t}();te.default=Ve;var re={},$,De=new Uint8Array(16);function ve(){if(!$&&($=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!$))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $(De)}var Le=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function G(t){return typeof t=="string"&&Le.test(t)}for(var R=[],ne=0;ne<256;++ne)R.push((ne+256).toString(16).substr(1));function B(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(R[t[i+0]]+R[t[i+1]]+R[t[i+2]]+R[t[i+3]]+"-"+R[t[i+4]]+R[t[i+5]]+"-"+R[t[i+6]]+R[t[i+7]]+"-"+R[t[i+8]]+R[t[i+9]]+"-"+R[t[i+10]]+R[t[i+11]]+R[t[i+12]]+R[t[i+13]]+R[t[i+14]]+R[t[i+15]]).toLowerCase();if(!G(e))throw TypeError("Stringified UUID is invalid");return e}var pe,ae,ie=0,oe=0;function He(t,i,e){var n=i&&e||0,a=i||new Array(16);t=t||{};var r=t.node||pe,o=t.clockseq!==void 0?t.clockseq:ae;if(r==null||o==null){var h=t.random||(t.rng||ve)();r==null&&(r=pe=[h[0]|1,h[1],h[2],h[3],h[4],h[5]]),o==null&&(o=ae=(h[6]<<8|h[7])&16383)}var v=t.msecs!==void 0?t.msecs:Date.now(),s=t.nsecs!==void 0?t.nsecs:oe+1,d=v-ie+(s-oe)/1e4;if(d<0&&t.clockseq===void 0&&(o=o+1&16383),(d<0||v>ie)&&t.nsecs===void 0&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ie=v,oe=s,ae=o,v+=122192928e5;var m=((v&268435455)*1e4+s)%4294967296;a[n++]=m>>>24&255,a[n++]=m>>>16&255,a[n++]=m>>>8&255,a[n++]=m&255;var M=v/4294967296*1e4&268435455;a[n++]=M>>>8&255,a[n++]=M&255,a[n++]=M>>>24&15|16,a[n++]=M>>>16&255,a[n++]=o>>>8|128,a[n++]=o&255;for(var k=0;k<6;++k)a[n+k]=r[k];return i||B(a)}function ye(t){if(!G(t))throw TypeError("Invalid UUID");var i,e=new Uint8Array(16);return e[0]=(i=parseInt(t.slice(0,8),16))>>>24,e[1]=i>>>16&255,e[2]=i>>>8&255,e[3]=i&255,e[4]=(i=parseInt(t.slice(9,13),16))>>>8,e[5]=i&255,e[6]=(i=parseInt(t.slice(14,18),16))>>>8,e[7]=i&255,e[8]=(i=parseInt(t.slice(19,23),16))>>>8,e[9]=i&255,e[10]=(i=parseInt(t.slice(24,36),16))/1099511627776&255,e[11]=i/4294967296&255,e[12]=i>>>24&255,e[13]=i>>>16&255,e[14]=i>>>8&255,e[15]=i&255,e}function Ke(t){t=unescape(encodeURIComponent(t));for(var i=[],e=0;e<t.length;++e)i.push(t.charCodeAt(e));return i}var Fe="6ba7b810-9dad-11d1-80b4-00c04fd430c8",qe="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ge(t,i,e){function n(a,r,o,h){if(typeof a=="string"&&(a=Ke(a)),typeof r=="string"&&(r=ye(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var v=new Uint8Array(16+a.length);if(v.set(r),v.set(a,r.length),v=e(v),v[6]=v[6]&15|i,v[8]=v[8]&63|128,o){h=h||0;for(var s=0;s<16;++s)o[h+s]=v[s];return o}return B(v)}try{n.name=t}catch{}return n.DNS=Fe,n.URL=qe,n}function $e(t){if(typeof t=="string"){var i=unescape(encodeURIComponent(t));t=new Uint8Array(i.length);for(var e=0;e<i.length;++e)t[e]=i.charCodeAt(e)}return Ge(Be(Ye(t),t.length*8))}function Ge(t){for(var i=[],e=t.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var r=t[a>>5]>>>a%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);i.push(o)}return i}function me(t){return(t+64>>>9<<4)+14+1}function Be(t,i){t[i>>5]|=128<<i%32,t[me(i)-1]=i;for(var e=1732584193,n=-271733879,a=-1732584194,r=271733878,o=0;o<t.length;o+=16){var h=e,v=n,s=a,d=r;e=U(e,n,a,r,t[o],7,-680876936),r=U(r,e,n,a,t[o+1],12,-389564586),a=U(a,r,e,n,t[o+2],17,606105819),n=U(n,a,r,e,t[o+3],22,-1044525330),e=U(e,n,a,r,t[o+4],7,-176418897),r=U(r,e,n,a,t[o+5],12,1200080426),a=U(a,r,e,n,t[o+6],17,-1473231341),n=U(n,a,r,e,t[o+7],22,-45705983),e=U(e,n,a,r,t[o+8],7,1770035416),r=U(r,e,n,a,t[o+9],12,-1958414417),a=U(a,r,e,n,t[o+10],17,-42063),n=U(n,a,r,e,t[o+11],22,-1990404162),e=U(e,n,a,r,t[o+12],7,1804603682),r=U(r,e,n,a,t[o+13],12,-40341101),a=U(a,r,e,n,t[o+14],17,-1502002290),n=U(n,a,r,e,t[o+15],22,1236535329),e=x(e,n,a,r,t[o+1],5,-165796510),r=x(r,e,n,a,t[o+6],9,-1069501632),a=x(a,r,e,n,t[o+11],14,643717713),n=x(n,a,r,e,t[o],20,-373897302),e=x(e,n,a,r,t[o+5],5,-701558691),r=x(r,e,n,a,t[o+10],9,38016083),a=x(a,r,e,n,t[o+15],14,-660478335),n=x(n,a,r,e,t[o+4],20,-405537848),e=x(e,n,a,r,t[o+9],5,568446438),r=x(r,e,n,a,t[o+14],9,-1019803690),a=x(a,r,e,n,t[o+3],14,-187363961),n=x(n,a,r,e,t[o+8],20,1163531501),e=x(e,n,a,r,t[o+13],5,-1444681467),r=x(r,e,n,a,t[o+2],9,-51403784),a=x(a,r,e,n,t[o+7],14,1735328473),n=x(n,a,r,e,t[o+12],20,-1926607734),e=A(e,n,a,r,t[o+5],4,-378558),r=A(r,e,n,a,t[o+8],11,-2022574463),a=A(a,r,e,n,t[o+11],16,1839030562),n=A(n,a,r,e,t[o+14],23,-35309556),e=A(e,n,a,r,t[o+1],4,-1530992060),r=A(r,e,n,a,t[o+4],11,1272893353),a=A(a,r,e,n,t[o+7],16,-155497632),n=A(n,a,r,e,t[o+10],23,-1094730640),e=A(e,n,a,r,t[o+13],4,681279174),r=A(r,e,n,a,t[o],11,-358537222),a=A(a,r,e,n,t[o+3],16,-722521979),n=A(n,a,r,e,t[o+6],23,76029189),e=A(e,n,a,r,t[o+9],4,-640364487),r=A(r,e,n,a,t[o+12],11,-421815835),a=A(a,r,e,n,t[o+15],16,530742520),n=A(n,a,r,e,t[o+2],23,-995338651),e=C(e,n,a,r,t[o],6,-198630844),r=C(r,e,n,a,t[o+7],10,1126891415),a=C(a,r,e,n,t[o+14],15,-1416354905),n=C(n,a,r,e,t[o+5],21,-57434055),e=C(e,n,a,r,t[o+12],6,1700485571),r=C(r,e,n,a,t[o+3],10,-1894986606),a=C(a,r,e,n,t[o+10],15,-1051523),n=C(n,a,r,e,t[o+1],21,-2054922799),e=C(e,n,a,r,t[o+8],6,1873313359),r=C(r,e,n,a,t[o+15],10,-30611744),a=C(a,r,e,n,t[o+6],15,-1560198380),n=C(n,a,r,e,t[o+13],21,1309151649),e=C(e,n,a,r,t[o+4],6,-145523070),r=C(r,e,n,a,t[o+11],10,-1120210379),a=C(a,r,e,n,t[o+2],15,718787259),n=C(n,a,r,e,t[o+9],21,-343485551),e=D(e,h),n=D(n,v),a=D(a,s),r=D(r,d)}return[e,n,a,r]}function Ye(t){if(t.length===0)return[];for(var i=t.length*8,e=new Uint32Array(me(i)),n=0;n<i;n+=8)e[n>>5]|=(t[n/8]&255)<<n%32;return e}function D(t,i){var e=(t&65535)+(i&65535),n=(t>>16)+(i>>16)+(e>>16);return n<<16|e&65535}function Je(t,i){return t<<i|t>>>32-i}function Y(t,i,e,n,a,r){return D(Je(D(D(i,t),D(n,r)),a),e)}function U(t,i,e,n,a,r,o){return Y(i&e|~i&n,t,i,a,r,o)}function x(t,i,e,n,a,r,o){return Y(i&n|e&~n,t,i,a,r,o)}function A(t,i,e,n,a,r,o){return Y(i^e^n,t,i,a,r,o)}function C(t,i,e,n,a,r,o){return Y(e^(i|~n),t,i,a,r,o)}var Qe=ge("v3",48,$e),Xe=Qe;function ze(t,i,e){t=t||{};var n=t.random||(t.rng||ve)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,i){e=e||0;for(var a=0;a<16;++a)i[e+a]=n[a];return i}return B(n)}function Ze(t,i,e,n){switch(t){case 0:return i&e^~i&n;case 1:return i^e^n;case 2:return i&e^i&n^e&n;case 3:return i^e^n}}function se(t,i){return t<<i|t>>>32-i}function We(t){var i=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var n=unescape(encodeURIComponent(t));t=[];for(var a=0;a<n.length;++a)t.push(n.charCodeAt(a))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var r=t.length/4+2,o=Math.ceil(r/16),h=new Array(o),v=0;v<o;++v){for(var s=new Uint32Array(16),d=0;d<16;++d)s[d]=t[v*64+d*4]<<24|t[v*64+d*4+1]<<16|t[v*64+d*4+2]<<8|t[v*64+d*4+3];h[v]=s}h[o-1][14]=(t.length-1)*8/Math.pow(2,32),h[o-1][14]=Math.floor(h[o-1][14]),h[o-1][15]=(t.length-1)*8&4294967295;for(var m=0;m<o;++m){for(var M=new Uint32Array(80),k=0;k<16;++k)M[k]=h[m][k];for(var P=16;P<80;++P)M[P]=se(M[P-3]^M[P-8]^M[P-14]^M[P-16],1);for(var w=e[0],T=e[1],j=e[2],S=e[3],p=e[4],u=0;u<80;++u){var f=Math.floor(u/20),c=se(w,5)+Ze(f,T,j,S)+p+i[f]+M[u]>>>0;p=S,S=j,j=se(T,30)>>>0,T=w,w=c}e[0]=e[0]+w>>>0,e[1]=e[1]+T>>>0,e[2]=e[2]+j>>>0,e[3]=e[3]+S>>>0,e[4]=e[4]+p>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var et=ge("v5",80,We),tt=et,rt="00000000-0000-0000-0000-000000000000";function nt(t){if(!G(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}var at=Object.freeze(Object.defineProperty({__proto__:null,v1:He,v3:Xe,v4:ze,v5:tt,NIL:rt,version:nt,validate:G,stringify:B,parse:ye},Symbol.toStringTag,{value:"Module"})),it=xe(at),J=g&&g.__assign||function(){return J=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++){i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},J.apply(this,arguments)};Object.defineProperty(re,"__esModule",{value:!0});var ot=it,st=function(){function t(){}return t.prototype.generateEventId=function(){return(0,ot.v4)()},t.prototype.createImpressionEvent=function(i,e,n,a,r,o){var h=this.createBaseEvent(i,e,n,a,r);return o?J(J({},h),{variant:o}):h},t.prototype.createBaseEvent=function(i,e,n,a,r){return{eventType:a,eventId:this.generateEventId(),context:i,enabled:e,featureName:n,impressionData:r}},t}();re.default=st;var Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.notNullOrUndefined=void 0;var ut=function(t){var i=t[1];return i!=null};Q.notNullOrUndefined=ut,function(t){var i=g&&g.__extends||function(){var S=function(p,u){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,c){f.__proto__=c}||function(f,c){for(var l in c)Object.prototype.hasOwnProperty.call(c,l)&&(f[l]=c[l])},S(p,u)};return function(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");S(p,u);function f(){this.constructor=p}p.prototype=u===null?Object.create(u):(f.prototype=u.prototype,new f)}}(),e=g&&g.__assign||function(){return e=Object.assign||function(S){for(var p,u=1,f=arguments.length;u<f;u++){p=arguments[u];for(var c in p)Object.prototype.hasOwnProperty.call(p,c)&&(S[c]=p[c])}return S},e.apply(this,arguments)},n=g&&g.__awaiter||function(S,p,u,f){function c(l){return l instanceof u?l:new u(function(E){E(l)})}return new(u||(u=Promise))(function(l,E){function N(O){try{y(f.next(O))}catch(H){E(H)}}function V(O){try{y(f.throw(O))}catch(H){E(H)}}function y(O){O.done?l(O.value):c(O.value).then(N,V)}y((f=f.apply(S,p||[])).next())})},a=g&&g.__generator||function(S,p){var u={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},f,c,l,E;return E={next:N(0),throw:N(1),return:N(2)},typeof Symbol=="function"&&(E[Symbol.iterator]=function(){return this}),E;function N(y){return function(O){return V([y,O])}}function V(y){if(f)throw new TypeError("Generator is already executing.");for(;u;)try{if(f=1,c&&(l=y[0]&2?c.return:y[0]?c.throw||((l=c.return)&&l.call(c),0):c.next)&&!(l=l.call(c,y[1])).done)return l;switch(c=0,l&&(y=[y[0]&2,l.value]),y[0]){case 0:case 1:l=y;break;case 4:return u.label++,{value:y[1],done:!1};case 5:u.label++,c=y[1],y=[0];continue;case 7:y=u.ops.pop(),u.trys.pop();continue;default:if(l=u.trys,!(l=l.length>0&&l[l.length-1])&&(y[0]===6||y[0]===2)){u=0;continue}if(y[0]===3&&(!l||y[1]>l[0]&&y[1]<l[3])){u.label=y[1];break}if(y[0]===6&&u.label<l[1]){u.label=l[1],l=y;break}if(l&&u.label<l[2]){u.label=l[2],u.ops.push(y);break}l[2]&&u.ops.pop(),u.trys.pop();continue}y=p.call(S,u)}catch(O){y=[6,O],c=0}finally{f=l=0}if(y[0]&5)throw y[1];return{value:y[0]?y[1]:void 0,done:!0}}},r=g&&g.__spreadArray||function(S,p,u){if(u||arguments.length===2)for(var f=0,c=p.length,l;f<c;f++)(l||!(f in p))&&(l||(l=Array.prototype.slice.call(p,0,f)),l[f]=p[f]);return S.concat(l||Array.prototype.slice.call(p))};Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorageProvider=t.LocalStorageProvider=t.UnleashClient=t.resolveFetch=t.EVENTS=void 0;var o=z.exports,h=W,v=ee;t.InMemoryStorageProvider=v.default;var s=te;t.LocalStorageProvider=s.default;var d=re,m=Q,M=["userId","sessionId","remoteAddress"];t.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression"};var k={IS_ENABLED:"isEnabled",GET_VARIANT:"getVariant"},P={name:"disabled",enabled:!1},w="repo",T=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(S){console.error('Unleash failed to resolve "fetch"',S)}};t.resolveFetch=T;var j=function(S){i(p,S);function p(u){var f=u.storageProvider,c=u.url,l=u.clientKey,E=u.disableRefresh,N=E===void 0?!1:E,V=u.refreshInterval,y=V===void 0?30:V,O=u.metricsInterval,H=O===void 0?30:O,X=u.disableMetrics,fe=X===void 0?!1:X,ce=u.appName,Ee=u.environment,pt=Ee===void 0?"default":Ee,yt=u.context,Ie=u.fetch,le=Ie===void 0?(0,t.resolveFetch)():Ie,K=u.bootstrap,Se=u.bootstrapOverride,gt=Se===void 0?!0:Se,_e=u.headerName,Te=_e===void 0?"Authorization":_e,Ne=u.customHeaders,mt=Ne===void 0?{}:Ne,Oe=u.impressionDataAll,bt=Oe===void 0?!1:Oe,b=S.call(this)||this;if(b.toggles=[],b.etag="",b.readyEventEmitted=!1,!c)throw new Error("url is required");if(!l)throw new Error("clientKey is required");if(!ce)throw new Error("appName is required.");return b.eventsHandler=new d.default,b.impressionDataAll=bt,b.toggles=K&&K.length>0?K:[],b.url=c instanceof URL?c:new URL(c),b.clientKey=l,b.headerName=Te,b.customHeaders=mt,b.storage=f||new s.default,b.refreshInterval=N?0:y*1e3,b.context=e({appName:ce,environment:pt},yt),b.ready=new Promise(function(Re){b.init().then(Re).catch(function(Ue){console.error(Ue),b.emit(t.EVENTS.ERROR,Ue),Re()})}),le||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),b.fetch=le,b.bootstrap=K&&K.length>0?K:void 0,b.bootstrapOverride=gt,b.metrics=new h.default({onError:b.emit.bind(b,t.EVENTS.ERROR),appName:ce,metricsInterval:H,disableMetrics:fe,url:b.url,clientKey:l,fetch:le,headerName:Te}),b}return p.prototype.getAllToggles=function(){return r([],this.toggles,!0)},p.prototype.isEnabled=function(u){var f=this.toggles.find(function(E){return E.name===u}),c=f?f.enabled:!1;if(this.metrics.count(u,c),(f==null?void 0:f.impressionData)||this.impressionDataAll){var l=this.eventsHandler.createImpressionEvent(this.context,c,u,k.IS_ENABLED,(f==null?void 0:f.impressionData)||void 0);this.emit(t.EVENTS.IMPRESSION,l)}return c},p.prototype.getVariant=function(u){var f=this.toggles.find(function(N){return N.name===u}),c=(f==null?void 0:f.enabled)||!1,l=f?f.variant:P;if(this.metrics.count(u,!0),(f==null?void 0:f.impressionData)||this.impressionDataAll){var E=this.eventsHandler.createImpressionEvent(this.context,c,u,k.GET_VARIANT,(f==null?void 0:f.impressionData)||void 0,l.name);this.emit(t.EVENTS.IMPRESSION,E)}return l},p.prototype.updateContext=function(u){return n(this,void 0,void 0,function(){var f;return a(this,function(c){switch(c.label){case 0:return(u.appName||u.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext."),f={environment:this.context.environment,appName:this.context.appName,sessionId:this.context.sessionId},this.context=e(e({},f),u),this.timerRef?[4,this.fetchToggles()]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},p.prototype.getContext=function(){return e({},this.context)},p.prototype.setContextField=function(u,f){var c,l;if(M.includes(u))this.context=e(e({},this.context),(c={},c[u]=f,c));else{var E=e(e({},this.context.properties),(l={},l[u]=f,l));this.context=e(e({},this.context),{properties:E})}this.timerRef&&this.fetchToggles()},p.prototype.init=function(){return n(this,void 0,void 0,function(){var u,f;return a(this,function(c){switch(c.label){case 0:return[4,this.resolveSessionId()];case 1:return u=c.sent(),this.context=e({sessionId:u},this.context),f=this,[4,this.storage.get(w)];case 2:return f.toggles=c.sent()||[],this.bootstrap&&(this.bootstrapOverride||this.toggles.length===0)?[4,this.storage.save(w,this.bootstrap)]:[3,4];case 3:c.sent(),this.toggles=this.bootstrap,this.emit(t.EVENTS.READY),c.label=4;case 4:return this.emit(t.EVENTS.INIT),[2]}})})},p.prototype.start=function(){return n(this,void 0,void 0,function(){var u,f=this;return a(this,function(c){switch(c.label){case 0:return this.timerRef?(console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again."),[2]):[4,this.ready];case 1:return c.sent(),this.metrics.start(),u=this.refreshInterval,[4,this.fetchToggles()];case 2:return c.sent(),u>0&&(this.timerRef=setInterval(function(){return f.fetchToggles()},u)),[2]}})})},p.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},p.prototype.resolveSessionId=function(){return n(this,void 0,void 0,function(){var u;return a(this,function(f){switch(f.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return u=f.sent(),u?[3,4]:(u=Math.floor(Math.random()*1e9),[4,this.storage.save("sessionId",u)]);case 3:f.sent(),f.label=4;case 4:return[2,u]}})})},p.prototype.getHeaders=function(){var u,f=(u={},u[this.headerName]=this.clientKey,u.Accept="application/json",u["Content-Type"]="application/json",u["If-None-Match"]=this.etag,u);return Object.entries(this.customHeaders).filter(m.notNullOrUndefined).forEach(function(c){var l=c[0],E=c[1];return f[l]=E}),f},p.prototype.storeToggles=function(u){return n(this,void 0,void 0,function(){return a(this,function(f){switch(f.label){case 0:return this.toggles=u,this.emit(t.EVENTS.UPDATE),[4,this.storage.save(w,u)];case 1:return f.sent(),[2]}})})},p.prototype.fetchToggles=function(){return n(this,void 0,void 0,function(){var u,f,c,l,E;return a(this,function(N){switch(N.label){case 0:if(!this.fetch)return[3,8];N.label=1;case 1:return N.trys.push([1,7,,8]),u=this.context,f=new URL(this.url.toString()),Object.entries(u).filter(m.notNullOrUndefined).forEach(function(V){var y=V[0],O=V[1];y==="properties"&&O?Object.entries(O).filter(m.notNullOrUndefined).forEach(function(H){var X=H[0],fe=H[1];return f.searchParams.append("properties[".concat(X,"]"),fe)}):f.searchParams.append(y,O)}),[4,this.fetch(f.toString(),{cache:"no-cache",headers:this.getHeaders()})];case 2:return c=N.sent(),c.ok&&c.status!==304?(this.etag=c.headers.get("ETag")||"",[4,c.json()]):[3,5];case 3:return l=N.sent(),[4,this.storeToggles(l.toggles)];case 4:return N.sent(),!this.bootstrap&&!this.readyEventEmitted&&(this.emit(t.EVENTS.READY),this.readyEventEmitted=!0),[3,6];case 5:!c.ok&&c.status!==304&&(console.error("Unleash: Fetching feature toggles did not have an ok response"),this.emit(t.EVENTS.ERROR,{type:"HttpError",code:c.status})),N.label=6;case 6:return[3,8];case 7:return E=N.sent(),console.error("Unleash: unable to fetch feature toggles",E),this.emit(t.EVENTS.ERROR,E),[3,8];case 8:return[2]}})})},p}(o.TinyEmitter);t.UnleashClient=j}(F);const L=Symbol("Context state identifier"),ue=Symbol("Context update identifier");function be({config:t,unleashClient:i,startClient:e=!0}){var k,P;const n=I.ref(i),a=I.ref(!1),r=I.ref(null);!t&&!i&&console.warn(`You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
2
- checking if the client exists before rendering.`),!n.value&&t&&(n.value=new F.UnleashClient(t)),(k=n.value)==null||k.on("ready",()=>{a.value=!0}),(P=n.value)==null||P.on("error",w=>{r.value=w});const o=async w=>{var T;await((T=n.value)==null?void 0:T.updateContext(w))},h=w=>{var T;return(T=n.value)==null?void 0:T.isEnabled(w)},v=w=>{var T;return(T=n.value)==null?void 0:T.getVariant(w)},s=(w,...T)=>{var j;return(j=n.value)==null?void 0:j.on(w,...T)},d=I.reactive({on:s,updateContext:o,isEnabled:h,getVariant:v,client:n,flagsReady:a,flagsError:r}),m=(w,T)=>{d[w]=T},M=()=>{var w;(e||!i)&&((w=n==null?void 0:n.value)==null||w.start())};return{context:I.toRefs(d),update:m,start:M}}var we=I.defineComponent({name:"FlagProvider",props:{config:{type:Object,required:!1},unleashClient:{type:Object,required:!1},startClient:{type:Boolean,required:!1,default:!0}},setup(t,{slots:i}){const{context:e,update:n,start:a}=be({config:t.config,unleashClient:t.unleashClient,startClient:t.startClient});return I.provide(L,e),I.provide(ue,n),I.onMounted(()=>{a()}),()=>{var r;return(r=i.default)==null?void 0:r.call(i)}}});const ft=t=>{const{isEnabled:i,client:e}=I.inject(L)||{},n=I.ref(!!i.value(t));function a(){const o=i.value(t);o!==n.value&&(n.value=!!o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),I.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n},ct=()=>{const{flagsReady:t,flagsError:i}=I.inject(L)||{};return{flagsReady:t,flagsError:i}},lt=t=>{const{getVariant:i,client:e}=I.inject(L)||{},n=I.ref(i.value(t));function a(){const o=i.value(t);(o.name!==n.value.name||o.enabled!==n.value.enabled)&&(n.value=o)}function r(){n.value=i.value(t)}return e.value.on("ready",r),e.value.on("update",a),I.onUnmounted(()=>{e.value.off("ready",r),e.value.off("update",a)}),n||{}},dt=()=>{const{updateContext:t}=I.inject(L)||{};return t.value},ht=()=>{const{client:t}=I.inject(L)||{};return t.value},vt={install(t,{config:i,unleashClient:e,startClient:n}){const{context:a,update:r,start:o}=be({config:i,unleashClient:e,startClient:n});t.provide(L,a),t.provide(ue,r),o()}};_.ContextStateSymbol=L,_.ContextUpdateSymbol=ue,_.FlagProvider=we,_.InMemoryStorageProvider=F.InMemoryStorageProvider,_.LocalStorageProvider=F.LocalStorageProvider,_.UnleashClient=F.UnleashClient,_.default=we,_.plugin=vt,_.useFlag=ft,_.useFlagsStatus=ct,_.useUnleashClient=ht,_.useUnleashContext=dt,_.useVariant=lt,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(_,b){typeof exports=="object"&&typeof module!="undefined"?b(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],b):(_=typeof globalThis!="undefined"?globalThis:_||self,b(_["proxy-client-vue"]={},_.Vue))})(this,function(_,b){"use strict";var g=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function xe(t){if(t.__esModule)return t;var o=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach(function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}),o}var F={},z={exports:{}};function Z(){}Z.prototype={on:function(t,o,e){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:o,ctx:e}),this},once:function(t,o,e){var n=this;function a(){n.off(t,a),o.apply(e,arguments)}return a._=o,this.on(t,a,e)},emit:function(t){var o=[].slice.call(arguments,1),e=((this.e||(this.e={}))[t]||[]).slice(),n=0,a=e.length;for(n;n<a;n++)e[n].fn.apply(e[n].ctx,o);return this},off:function(t,o){var e=this.e||(this.e={}),n=e[t],a=[];if(n&&o)for(var r=0,i=n.length;r<i;r++)n[r].fn!==o&&n[r].fn._!==o&&a.push(n[r]);return a.length?e[t]=a:delete e[t],this}},z.exports=Z,z.exports.TinyEmitter=Z;var W={},$=g&&g.__assign||function(){return $=Object.assign||function(t){for(var o,e=1,n=arguments.length;e<n;e++){o=arguments[e];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(t[a]=o[a])}return t},$.apply(this,arguments)},Re=g&&g.__awaiter||function(t,o,e,n){function a(r){return r instanceof e?r:new e(function(i){i(r)})}return new(e||(e=Promise))(function(r,i){function d(h){try{s(n.next(h))}catch(m){i(m)}}function v(h){try{s(n.throw(h))}catch(m){i(m)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,o||[])).next())})},Me=g&&g.__generator||function(t,o){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,i;return i={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=o.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(W,"__esModule",{value:!0});var Ae=function(){function t(o){var e=o.onError,n=o.appName,a=o.metricsInterval,r=o.disableMetrics,i=r===void 0?!1:r,d=o.url,v=o.clientKey,s=o.fetch,h=o.headerName;this.onError=e,this.disabled=i,this.metricsInterval=a*1e3,this.appName=n,this.url=d instanceof URL?d:new URL(d),this.clientKey=v,this.bucket=this.createEmptyBucket(),this.fetch=s,this.headerName=h}return t.prototype.start=function(){var o=this;if(this.disabled)return!1;typeof this.metricsInterval=="number"&&this.metricsInterval>0&&setTimeout(function(){o.startTimer(),o.sendMetrics()},2e3)},t.prototype.stop=function(){this.timer&&(clearTimeout(this.timer),delete this.timer)},t.prototype.createEmptyBucket=function(){return{start:new Date,stop:null,toggles:{}}},t.prototype.sendMetrics=function(){return Re(this,void 0,void 0,function(){var o,e,n,a;return Me(this,function(r){switch(r.label){case 0:if(o="".concat(this.url,"/client/metrics"),e=this.getPayload(),this.bucketIsEmpty(e))return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.fetch(o,{cache:"no-cache",method:"POST",headers:(a={},a[this.headerName]=this.clientKey,a.Accept="application/json",a["Content-Type"]="application/json",a),body:JSON.stringify(e)})];case 2:return r.sent(),[3,4];case 3:return n=r.sent(),console.error("Unleash: unable to send feature metrics",n),this.onError(n),[3,4];case 4:return[2]}})})},t.prototype.count=function(o,e){return this.disabled||!this.bucket?!1:(this.assertBucket(o),this.bucket.toggles[o][e?"yes":"no"]++,!0)},t.prototype.assertBucket=function(o){if(this.disabled||!this.bucket)return!1;this.bucket.toggles[o]||(this.bucket.toggles[o]={yes:0,no:0})},t.prototype.startTimer=function(){var o=this;this.timer=setInterval(function(){o.sendMetrics()},this.metricsInterval)},t.prototype.bucketIsEmpty=function(o){return Object.keys(o.bucket.toggles).length===0},t.prototype.getPayload=function(){var o=$($({},this.bucket),{stop:new Date});return this.bucket=this.createEmptyBucket(),{bucket:o,appName:this.appName,instanceId:"browser"}},t}();W.default=Ae;var ee={},he=g&&g.__awaiter||function(t,o,e,n){function a(r){return r instanceof e?r:new e(function(i){i(r)})}return new(e||(e=Promise))(function(r,i){function d(h){try{s(n.next(h))}catch(m){i(m)}}function v(h){try{s(n.throw(h))}catch(m){i(m)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,o||[])).next())})},de=g&&g.__generator||function(t,o){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,i;return i={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=o.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(ee,"__esModule",{value:!0});var ke=function(){function t(){this.store=new Map}return t.prototype.save=function(o,e){return he(this,void 0,void 0,function(){return de(this,function(n){return this.store.set(o,e),[2]})})},t.prototype.get=function(o){return he(this,void 0,void 0,function(){return de(this,function(e){return[2,this.store.get(o)]})})},t}();ee.default=ke;var te={},Ce=g&&g.__awaiter||function(t,o,e,n){function a(r){return r instanceof e?r:new e(function(i){i(r)})}return new(e||(e=Promise))(function(r,i){function d(h){try{s(n.next(h))}catch(m){i(m)}}function v(h){try{s(n.throw(h))}catch(m){i(m)}}function s(h){h.done?r(h.value):a(h.value).then(d,v)}s((n=n.apply(t,o||[])).next())})},Pe=g&&g.__generator||function(t,o){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,a,r,i;return i={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(s){return function(h){return v([s,h])}}function v(s){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,a&&(r=s[0]&2?a.return:s[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,s[1])).done)return r;switch(a=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,a=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){e.label=s[1];break}if(s[0]===6&&e.label<r[1]){e.label=r[1],r=s;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(s);break}r[2]&&e.ops.pop(),e.trys.pop();continue}s=o.call(t,e)}catch(h){s=[6,h],a=0}finally{n=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(te,"__esModule",{value:!0});var je=function(){function t(){this.prefix="unleash:repository"}return t.prototype.save=function(o,e){return Ce(this,void 0,void 0,function(){var n,a;return Pe(this,function(r){n=JSON.stringify(e),a="".concat(this.prefix,":").concat(o);try{window.localStorage.setItem(a,n)}catch(i){console.error(i)}return[2]})})},t.prototype.get=function(o){try{var e="".concat(this.prefix,":").concat(o),n=window.localStorage.getItem(e);return n?JSON.parse(n):void 0}catch(a){console.error(a)}},t}();te.default=je;var re={},q,De=new Uint8Array(16);function ve(){if(!q&&(q=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!q))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return q(De)}var Le=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function G(t){return typeof t=="string"&&Le.test(t)}for(var O=[],ne=0;ne<256;++ne)O.push((ne+256).toString(16).substr(1));function B(t){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(O[t[o+0]]+O[t[o+1]]+O[t[o+2]]+O[t[o+3]]+"-"+O[t[o+4]]+O[t[o+5]]+"-"+O[t[o+6]]+O[t[o+7]]+"-"+O[t[o+8]]+O[t[o+9]]+"-"+O[t[o+10]]+O[t[o+11]]+O[t[o+12]]+O[t[o+13]]+O[t[o+14]]+O[t[o+15]]).toLowerCase();if(!G(e))throw TypeError("Stringified UUID is invalid");return e}var ye,ae,oe=0,ie=0;function Ve(t,o,e){var n=o&&e||0,a=o||new Array(16);t=t||{};var r=t.node||ye,i=t.clockseq!==void 0?t.clockseq:ae;if(r==null||i==null){var d=t.random||(t.rng||ve)();r==null&&(r=ye=[d[0]|1,d[1],d[2],d[3],d[4],d[5]]),i==null&&(i=ae=(d[6]<<8|d[7])&16383)}var v=t.msecs!==void 0?t.msecs:Date.now(),s=t.nsecs!==void 0?t.nsecs:ie+1,h=v-oe+(s-ie)/1e4;if(h<0&&t.clockseq===void 0&&(i=i+1&16383),(h<0||v>oe)&&t.nsecs===void 0&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");oe=v,ie=s,ae=i,v+=122192928e5;var m=((v&268435455)*1e4+s)%4294967296;a[n++]=m>>>24&255,a[n++]=m>>>16&255,a[n++]=m>>>8&255,a[n++]=m&255;var A=v/4294967296*1e4&268435455;a[n++]=A>>>8&255,a[n++]=A&255,a[n++]=A>>>24&15|16,a[n++]=A>>>16&255,a[n++]=i>>>8|128,a[n++]=i&255;for(var C=0;C<6;++C)a[n+C]=r[C];return o||B(a)}function pe(t){if(!G(t))throw TypeError("Invalid UUID");var o,e=new Uint8Array(16);return e[0]=(o=parseInt(t.slice(0,8),16))>>>24,e[1]=o>>>16&255,e[2]=o>>>8&255,e[3]=o&255,e[4]=(o=parseInt(t.slice(9,13),16))>>>8,e[5]=o&255,e[6]=(o=parseInt(t.slice(14,18),16))>>>8,e[7]=o&255,e[8]=(o=parseInt(t.slice(19,23),16))>>>8,e[9]=o&255,e[10]=(o=parseInt(t.slice(24,36),16))/1099511627776&255,e[11]=o/4294967296&255,e[12]=o>>>24&255,e[13]=o>>>16&255,e[14]=o>>>8&255,e[15]=o&255,e}function Ke(t){t=unescape(encodeURIComponent(t));for(var o=[],e=0;e<t.length;++e)o.push(t.charCodeAt(e));return o}var He="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Fe="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ge(t,o,e){function n(a,r,i,d){if(typeof a=="string"&&(a=Ke(a)),typeof r=="string"&&(r=pe(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var v=new Uint8Array(16+a.length);if(v.set(r),v.set(a,r.length),v=e(v),v[6]=v[6]&15|o,v[8]=v[8]&63|128,i){d=d||0;for(var s=0;s<16;++s)i[d+s]=v[s];return i}return B(v)}try{n.name=t}catch{}return n.DNS=He,n.URL=Fe,n}function $e(t){if(typeof t=="string"){var o=unescape(encodeURIComponent(t));t=new Uint8Array(o.length);for(var e=0;e<o.length;++e)t[e]=o.charCodeAt(e)}return qe(Ge(Be(t),t.length*8))}function qe(t){for(var o=[],e=t.length*32,n="0123456789abcdef",a=0;a<e;a+=8){var r=t[a>>5]>>>a%32&255,i=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);o.push(i)}return o}function me(t){return(t+64>>>9<<4)+14+1}function Ge(t,o){t[o>>5]|=128<<o%32,t[me(o)-1]=o;for(var e=1732584193,n=-271733879,a=-1732584194,r=271733878,i=0;i<t.length;i+=16){var d=e,v=n,s=a,h=r;e=U(e,n,a,r,t[i],7,-680876936),r=U(r,e,n,a,t[i+1],12,-389564586),a=U(a,r,e,n,t[i+2],17,606105819),n=U(n,a,r,e,t[i+3],22,-1044525330),e=U(e,n,a,r,t[i+4],7,-176418897),r=U(r,e,n,a,t[i+5],12,1200080426),a=U(a,r,e,n,t[i+6],17,-1473231341),n=U(n,a,r,e,t[i+7],22,-45705983),e=U(e,n,a,r,t[i+8],7,1770035416),r=U(r,e,n,a,t[i+9],12,-1958414417),a=U(a,r,e,n,t[i+10],17,-42063),n=U(n,a,r,e,t[i+11],22,-1990404162),e=U(e,n,a,r,t[i+12],7,1804603682),r=U(r,e,n,a,t[i+13],12,-40341101),a=U(a,r,e,n,t[i+14],17,-1502002290),n=U(n,a,r,e,t[i+15],22,1236535329),e=x(e,n,a,r,t[i+1],5,-165796510),r=x(r,e,n,a,t[i+6],9,-1069501632),a=x(a,r,e,n,t[i+11],14,643717713),n=x(n,a,r,e,t[i],20,-373897302),e=x(e,n,a,r,t[i+5],5,-701558691),r=x(r,e,n,a,t[i+10],9,38016083),a=x(a,r,e,n,t[i+15],14,-660478335),n=x(n,a,r,e,t[i+4],20,-405537848),e=x(e,n,a,r,t[i+9],5,568446438),r=x(r,e,n,a,t[i+14],9,-1019803690),a=x(a,r,e,n,t[i+3],14,-187363961),n=x(n,a,r,e,t[i+8],20,1163531501),e=x(e,n,a,r,t[i+13],5,-1444681467),r=x(r,e,n,a,t[i+2],9,-51403784),a=x(a,r,e,n,t[i+7],14,1735328473),n=x(n,a,r,e,t[i+12],20,-1926607734),e=R(e,n,a,r,t[i+5],4,-378558),r=R(r,e,n,a,t[i+8],11,-2022574463),a=R(a,r,e,n,t[i+11],16,1839030562),n=R(n,a,r,e,t[i+14],23,-35309556),e=R(e,n,a,r,t[i+1],4,-1530992060),r=R(r,e,n,a,t[i+4],11,1272893353),a=R(a,r,e,n,t[i+7],16,-155497632),n=R(n,a,r,e,t[i+10],23,-1094730640),e=R(e,n,a,r,t[i+13],4,681279174),r=R(r,e,n,a,t[i],11,-358537222),a=R(a,r,e,n,t[i+3],16,-722521979),n=R(n,a,r,e,t[i+6],23,76029189),e=R(e,n,a,r,t[i+9],4,-640364487),r=R(r,e,n,a,t[i+12],11,-421815835),a=R(a,r,e,n,t[i+15],16,530742520),n=R(n,a,r,e,t[i+2],23,-995338651),e=M(e,n,a,r,t[i],6,-198630844),r=M(r,e,n,a,t[i+7],10,1126891415),a=M(a,r,e,n,t[i+14],15,-1416354905),n=M(n,a,r,e,t[i+5],21,-57434055),e=M(e,n,a,r,t[i+12],6,1700485571),r=M(r,e,n,a,t[i+3],10,-1894986606),a=M(a,r,e,n,t[i+10],15,-1051523),n=M(n,a,r,e,t[i+1],21,-2054922799),e=M(e,n,a,r,t[i+8],6,1873313359),r=M(r,e,n,a,t[i+15],10,-30611744),a=M(a,r,e,n,t[i+6],15,-1560198380),n=M(n,a,r,e,t[i+13],21,1309151649),e=M(e,n,a,r,t[i+4],6,-145523070),r=M(r,e,n,a,t[i+11],10,-1120210379),a=M(a,r,e,n,t[i+2],15,718787259),n=M(n,a,r,e,t[i+9],21,-343485551),e=L(e,d),n=L(n,v),a=L(a,s),r=L(r,h)}return[e,n,a,r]}function Be(t){if(t.length===0)return[];for(var o=t.length*8,e=new Uint32Array(me(o)),n=0;n<o;n+=8)e[n>>5]|=(t[n/8]&255)<<n%32;return e}function L(t,o){var e=(t&65535)+(o&65535),n=(t>>16)+(o>>16)+(e>>16);return n<<16|e&65535}function Ye(t,o){return t<<o|t>>>32-o}function Y(t,o,e,n,a,r){return L(Ye(L(L(o,t),L(n,r)),a),e)}function U(t,o,e,n,a,r,i){return Y(o&e|~o&n,t,o,a,r,i)}function x(t,o,e,n,a,r,i){return Y(o&n|e&~n,t,o,a,r,i)}function R(t,o,e,n,a,r,i){return Y(o^e^n,t,o,a,r,i)}function M(t,o,e,n,a,r,i){return Y(e^(o|~n),t,o,a,r,i)}var Je=ge("v3",48,$e),Qe=Je;function Xe(t,o,e){t=t||{};var n=t.random||(t.rng||ve)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,o){e=e||0;for(var a=0;a<16;++a)o[e+a]=n[a];return o}return B(n)}function ze(t,o,e,n){switch(t){case 0:return o&e^~o&n;case 1:return o^e^n;case 2:return o&e^o&n^e&n;case 3:return o^e^n}}function se(t,o){return t<<o|t>>>32-o}function Ze(t){var o=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var n=unescape(encodeURIComponent(t));t=[];for(var a=0;a<n.length;++a)t.push(n.charCodeAt(a))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var r=t.length/4+2,i=Math.ceil(r/16),d=new Array(i),v=0;v<i;++v){for(var s=new Uint32Array(16),h=0;h<16;++h)s[h]=t[v*64+h*4]<<24|t[v*64+h*4+1]<<16|t[v*64+h*4+2]<<8|t[v*64+h*4+3];d[v]=s}d[i-1][14]=(t.length-1)*8/Math.pow(2,32),d[i-1][14]=Math.floor(d[i-1][14]),d[i-1][15]=(t.length-1)*8&4294967295;for(var m=0;m<i;++m){for(var A=new Uint32Array(80),C=0;C<16;++C)A[C]=d[m][C];for(var P=16;P<80;++P)A[P]=se(A[P-3]^A[P-8]^A[P-14]^A[P-16],1);for(var w=e[0],T=e[1],j=e[2],I=e[3],y=e[4],u=0;u<80;++u){var f=Math.floor(u/20),c=se(w,5)+ze(f,T,j,I)+y+o[f]+A[u]>>>0;y=I,I=j,j=se(T,30)>>>0,T=w,w=c}e[0]=e[0]+w>>>0,e[1]=e[1]+T>>>0,e[2]=e[2]+j>>>0,e[3]=e[3]+I>>>0,e[4]=e[4]+y>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var We=ge("v5",80,Ze),et=We,tt="00000000-0000-0000-0000-000000000000";function rt(t){if(!G(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}var nt=Object.freeze(Object.defineProperty({__proto__:null,v1:Ve,v3:Qe,v4:Xe,v5:et,NIL:tt,version:rt,validate:G,stringify:B,parse:pe},Symbol.toStringTag,{value:"Module"})),at=xe(nt),J=g&&g.__assign||function(){return J=Object.assign||function(t){for(var o,e=1,n=arguments.length;e<n;e++){o=arguments[e];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(t[a]=o[a])}return t},J.apply(this,arguments)};Object.defineProperty(re,"__esModule",{value:!0});var ot=at,it=function(){function t(){}return t.prototype.generateEventId=function(){return(0,ot.v4)()},t.prototype.createImpressionEvent=function(o,e,n,a,r){var i=this.createBaseEvent(o,e,n,a);return r?J(J({},i),{variant:r}):i},t.prototype.createBaseEvent=function(o,e,n,a){return{eventType:a,eventId:this.generateEventId(),context:o,enabled:e,featureName:n}},t}();re.default=it;var Q={};Object.defineProperty(Q,"__esModule",{value:!0}),Q.notNullOrUndefined=void 0;var st=function(t){var o=t[1];return o!=null};Q.notNullOrUndefined=st,function(t){var o=g&&g.__extends||function(){var I=function(y,u){return I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,c){f.__proto__=c}||function(f,c){for(var l in c)Object.prototype.hasOwnProperty.call(c,l)&&(f[l]=c[l])},I(y,u)};return function(y,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");I(y,u);function f(){this.constructor=y}y.prototype=u===null?Object.create(u):(f.prototype=u.prototype,new f)}}(),e=g&&g.__assign||function(){return e=Object.assign||function(I){for(var y,u=1,f=arguments.length;u<f;u++){y=arguments[u];for(var c in y)Object.prototype.hasOwnProperty.call(y,c)&&(I[c]=y[c])}return I},e.apply(this,arguments)},n=g&&g.__awaiter||function(I,y,u,f){function c(l){return l instanceof u?l:new u(function(S){S(l)})}return new(u||(u=Promise))(function(l,S){function k(N){try{p(f.next(N))}catch(K){S(K)}}function D(N){try{p(f.throw(N))}catch(K){S(K)}}function p(N){N.done?l(N.value):c(N.value).then(k,D)}p((f=f.apply(I,y||[])).next())})},a=g&&g.__generator||function(I,y){var u={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},f,c,l,S;return S={next:k(0),throw:k(1),return:k(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function k(p){return function(N){return D([p,N])}}function D(p){if(f)throw new TypeError("Generator is already executing.");for(;u;)try{if(f=1,c&&(l=p[0]&2?c.return:p[0]?c.throw||((l=c.return)&&l.call(c),0):c.next)&&!(l=l.call(c,p[1])).done)return l;switch(c=0,l&&(p=[p[0]&2,l.value]),p[0]){case 0:case 1:l=p;break;case 4:return u.label++,{value:p[1],done:!1};case 5:u.label++,c=p[1],p=[0];continue;case 7:p=u.ops.pop(),u.trys.pop();continue;default:if(l=u.trys,!(l=l.length>0&&l[l.length-1])&&(p[0]===6||p[0]===2)){u=0;continue}if(p[0]===3&&(!l||p[1]>l[0]&&p[1]<l[3])){u.label=p[1];break}if(p[0]===6&&u.label<l[1]){u.label=l[1],l=p;break}if(l&&u.label<l[2]){u.label=l[2],u.ops.push(p);break}l[2]&&u.ops.pop(),u.trys.pop();continue}p=y.call(I,u)}catch(N){p=[6,N],c=0}finally{f=l=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},r=g&&g.__spreadArray||function(I,y,u){if(u||arguments.length===2)for(var f=0,c=y.length,l;f<c;f++)(l||!(f in y))&&(l||(l=Array.prototype.slice.call(y,0,f)),l[f]=y[f]);return I.concat(l||Array.prototype.slice.call(y))};Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorageProvider=t.LocalStorageProvider=t.UnleashClient=t.resolveFetch=t.EVENTS=void 0;var i=z.exports,d=W,v=ee;t.InMemoryStorageProvider=v.default;var s=te;t.LocalStorageProvider=s.default;var h=re,m=Q,A=["userId","sessionId","remoteAddress"];t.EVENTS={INIT:"initialized",ERROR:"error",READY:"ready",UPDATE:"update",IMPRESSION:"impression"};var C={IS_ENABLED:"isEnabled",GET_VARIANT:"getVariant"},P={name:"disabled",enabled:!1},w="repo",T=function(){try{if("fetch"in window)return fetch.bind(window);if("fetch"in globalThis)return fetch.bind(globalThis)}catch(I){console.error('Unleash failed to resolve "fetch"',I)}};t.resolveFetch=T;var j=function(I){o(y,I);function y(u){var f=u.storageProvider,c=u.url,l=u.clientKey,S=u.disableRefresh,k=S===void 0?!1:S,D=u.refreshInterval,p=D===void 0?30:D,N=u.metricsInterval,K=N===void 0?30:N,X=u.disableMetrics,fe=X===void 0?!1:X,ce=u.appName,Ee=u.environment,vt=Ee===void 0?"default":Ee,yt=u.context,Ie=u.fetch,le=Ie===void 0?(0,t.resolveFetch)():Ie,H=u.bootstrap,Se=u.bootstrapOverride,pt=Se===void 0?!0:Se,_e=u.headerName,Te=_e===void 0?"Authorization":_e,Ne=u.customHeaders,gt=Ne===void 0?{}:Ne,E=I.call(this)||this;if(E.toggles=[],E.etag="",E.readyEventEmitted=!1,!c)throw new Error("url is required");if(!l)throw new Error("clientKey is required");if(!ce)throw new Error("appName is required.");return E.eventsHandler=new h.default,E.toggles=H&&H.length>0?H:[],E.url=c instanceof URL?c:new URL(c),E.clientKey=l,E.headerName=Te,E.customHeaders=gt,E.storage=f||new s.default,E.refreshInterval=k?0:p*1e3,E.context=e({appName:ce,environment:vt},yt),E.ready=new Promise(function(Oe){E.init().then(Oe).catch(function(Ue){console.error(Ue),E.emit(t.EVENTS.ERROR,Ue),Oe()})}),le||console.error('Unleash: You must either provide your own "fetch" implementation or run in an environment where "fetch" is available.'),E.fetch=le,E.bootstrap=H&&H.length>0?H:void 0,E.bootstrapOverride=pt,E.metrics=new d.default({onError:E.emit.bind(E,t.EVENTS.ERROR),appName:ce,metricsInterval:K,disableMetrics:fe,url:E.url,clientKey:l,fetch:le,headerName:Te}),E}return y.prototype.getAllToggles=function(){return r([],this.toggles,!0)},y.prototype.isEnabled=function(u){var f=this.toggles.find(function(S){return S.name===u}),c=f?f.enabled:!1;if(this.metrics.count(u,c),f!=null&&f.impressionData){var l=this.eventsHandler.createImpressionEvent(this.context,c,u,C.IS_ENABLED);this.emit(t.EVENTS.IMPRESSION,l)}return c},y.prototype.getVariant=function(u){var f=this.toggles.find(function(l){return l.name===u});if(f){if(this.metrics.count(u,!0),f.impressionData){var c=this.eventsHandler.createImpressionEvent(this.context,f.enabled,u,C.GET_VARIANT,f.variant.name);this.emit(t.EVENTS.IMPRESSION,c)}return f.variant}else return this.metrics.count(u,!1),P},y.prototype.updateContext=function(u){return n(this,void 0,void 0,function(){var f;return a(this,function(c){switch(c.label){case 0:return(u.appName||u.environment)&&console.warn("appName and environment are static. They can't be updated with updateContext."),f={environment:this.context.environment,appName:this.context.appName},this.context=e(e({},f),u),this.timerRef?[4,this.fetchToggles()]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},y.prototype.getContext=function(){return e({},this.context)},y.prototype.setContextField=function(u,f){var c,l;if(A.includes(u))this.context=e(e({},this.context),(c={},c[u]=f,c));else{var S=e(e({},this.context.properties),(l={},l[u]=f,l));this.context=e(e({},this.context),{properties:S})}this.timerRef&&this.fetchToggles()},y.prototype.init=function(){return n(this,void 0,void 0,function(){var u,f;return a(this,function(c){switch(c.label){case 0:return[4,this.resolveSessionId()];case 1:return u=c.sent(),this.context=e({sessionId:u},this.context),f=this,[4,this.storage.get(w)];case 2:return f.toggles=c.sent()||[],this.bootstrap&&(this.bootstrapOverride||this.toggles.length===0)?[4,this.storage.save(w,this.bootstrap)]:[3,4];case 3:c.sent(),this.toggles=this.bootstrap,this.emit(t.EVENTS.READY),c.label=4;case 4:return this.emit(t.EVENTS.INIT),[2]}})})},y.prototype.start=function(){return n(this,void 0,void 0,function(){var u,f=this;return a(this,function(c){switch(c.label){case 0:return this.timerRef?(console.error("Unleash SDK has already started, if you want to restart the SDK you should call client.stop() before starting again."),[2]):[4,this.ready];case 1:return c.sent(),this.metrics.start(),u=this.refreshInterval,[4,this.fetchToggles()];case 2:return c.sent(),u>0&&(this.timerRef=setInterval(function(){return f.fetchToggles()},u)),[2]}})})},y.prototype.stop=function(){this.timerRef&&(clearInterval(this.timerRef),this.timerRef=void 0),this.metrics.stop()},y.prototype.resolveSessionId=function(){return n(this,void 0,void 0,function(){var u;return a(this,function(f){switch(f.label){case 0:return this.context.sessionId?[2,this.context.sessionId]:[3,1];case 1:return[4,this.storage.get("sessionId")];case 2:return u=f.sent(),u?[3,4]:(u=Math.floor(Math.random()*1e9),[4,this.storage.save("sessionId",u)]);case 3:f.sent(),f.label=4;case 4:return[2,u]}})})},y.prototype.getHeaders=function(){var u,f=(u={},u[this.headerName]=this.clientKey,u.Accept="application/json",u["Content-Type"]="application/json",u["If-None-Match"]=this.etag,u);return Object.entries(this.customHeaders).filter(m.notNullOrUndefined).forEach(function(c){var l=c[0],S=c[1];return f[l]=S}),f},y.prototype.storeToggles=function(u){return n(this,void 0,void 0,function(){return a(this,function(f){switch(f.label){case 0:return this.toggles=u,this.emit(t.EVENTS.UPDATE),[4,this.storage.save(w,u)];case 1:return f.sent(),[2]}})})},y.prototype.fetchToggles=function(){return n(this,void 0,void 0,function(){var u,f,c,l,S;return a(this,function(k){switch(k.label){case 0:if(!this.fetch)return[3,7];k.label=1;case 1:return k.trys.push([1,6,,7]),u=this.context,f=new URL(this.url.toString()),Object.entries(u).filter(m.notNullOrUndefined).forEach(function(D){var p=D[0],N=D[1];p==="properties"&&N?Object.entries(N).filter(m.notNullOrUndefined).forEach(function(K){var X=K[0],fe=K[1];return f.searchParams.append("properties[".concat(X,"]"),fe)}):f.searchParams.append(p,N)}),[4,this.fetch(f.toString(),{cache:"no-cache",headers:this.getHeaders()})];case 2:return c=k.sent(),c.ok&&c.status!==304?(this.etag=c.headers.get("ETag")||"",[4,c.json()]):[3,5];case 3:return l=k.sent(),[4,this.storeToggles(l.toggles)];case 4:k.sent(),!this.bootstrap&&!this.readyEventEmitted&&(this.emit(t.EVENTS.READY),this.readyEventEmitted=!0),k.label=5;case 5:return[3,7];case 6:return S=k.sent(),console.error("Unleash: unable to fetch feature toggles",S),this.emit(t.EVENTS.ERROR,S),[3,7];case 7:return[2]}})})},y}(i.TinyEmitter);t.UnleashClient=j}(F);const V=Symbol("Context state identifier"),ue=Symbol("Context update identifier");function be({config:t,unleashClient:o,startClient:e=!0}){var C,P;const n=b.ref(o),a=b.ref(!1),r=b.ref(null);!t&&!o&&console.warn(`You must provide either a config or an unleash client to the flag provider. If you are initializing the client in useEffect, you can avoid this warning by
2
+ checking if the client exists before rendering.`),!n.value&&t&&(n.value=new F.UnleashClient(t)),(C=n.value)==null||C.on("ready",()=>{a.value=!0}),(P=n.value)==null||P.on("error",w=>{r.value=w});const i=async w=>{var T;await((T=n.value)==null?void 0:T.updateContext(w))},d=w=>{var T;return(T=n.value)==null?void 0:T.isEnabled(w)},v=w=>{var T;return(T=n.value)==null?void 0:T.getVariant(w)},s=(w,...T)=>{var j;return(j=n.value)==null?void 0:j.on(w,...T)},h=b.reactive({on:s,updateContext:i,isEnabled:d,getVariant:v,client:n,flagsReady:a,flagsError:r}),m=(w,T)=>{h[w]=T},A=()=>{var w;(e||!o)&&((w=n==null?void 0:n.value)==null||w.start())};return{context:b.toRefs(h),update:m,start:A}}const we=b.defineComponent({__name:"FlagProvider",props:{config:null,unleashClient:null,startClient:{type:Boolean}},setup(t){const{config:o,unleashClient:e,startClient:n=!0}=t,{context:a,start:r,update:i}=be({config:o,unleashClient:e,startClient:n});return b.provide(V,a),b.provide(ue,i),b.onMounted(()=>{r()}),(d,v)=>b.renderSlot(d.$slots,"default")}}),ut=t=>{const{isEnabled:o,client:e}=b.inject(V,{}),n=b.ref(Boolean(o==null?void 0:o.value(t)));function a(){const i=o==null?void 0:o.value(t);i!==n.value&&(n.value=!!i)}function r(){n.value=Boolean(o==null?void 0:o.value(t))}return e==null||e.value.on("ready",r),e==null||e.value.on("update",a),b.onUnmounted(()=>{e==null||e.value.off("ready",r),e==null||e.value.off("update",a)}),n},ft=()=>{const{flagsReady:t,flagsError:o}=b.inject(V,{});return{flagsReady:t,flagsError:o}},ct=t=>{const{getVariant:o,client:e}=b.inject(V,{}),n=b.ref(o==null?void 0:o.value(t));function a(){var d,v;const i=o==null?void 0:o.value(t);((i==null?void 0:i.name)!==((d=n.value)==null?void 0:d.name)||(i==null?void 0:i.enabled)!==((v=n.value)==null?void 0:v.enabled))&&(n.value=i)}function r(){n.value=o==null?void 0:o.value(t)}return e==null||e.value.on("ready",r),e==null||e.value.on("update",a),b.onUnmounted(()=>{e==null||e.value.off("ready",r),e==null||e.value.off("update",a)}),n||{}},lt=()=>{const{updateContext:t}=b.inject(V,{});return t==null?void 0:t.value},ht=()=>{const{client:t}=b.inject(V,{});return t==null?void 0:t.value},dt={install(t,{config:o,unleashClient:e,startClient:n}){const{context:a,update:r,start:i}=be({config:o,unleashClient:e,startClient:n});t.provide(V,a),t.provide(ue,r),i()}};_.ContextStateSymbol=V,_.ContextUpdateSymbol=ue,_.FlagProvider=we,_.InMemoryStorageProvider=F.InMemoryStorageProvider,_.LocalStorageProvider=F.LocalStorageProvider,_.UnleashClient=F.UnleashClient,_.default=we,_.plugin=dt,_.useFlag=ut,_.useFlagsStatus=ft,_.useUnleashClient=ht,_.useUnleashContext=lt,_.useVariant=ct,Object.defineProperties(_,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/plugin.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Plugin } from 'vue-demi';
1
+ import { Plugin } from 'vue';
2
2
  declare const plugin: Plugin;
3
3
  export default plugin;
package/dist/useFlag.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- declare const useFlag: (name: string) => import("vue-demi").Ref<boolean>;
1
+ import { Ref } from 'vue';
2
+ declare const useFlag: (name: string) => Ref<boolean>;
2
3
  export default useFlag;
@@ -1,5 +1,6 @@
1
+ import { Ref } from 'vue';
1
2
  declare const useFlagsStatus: () => {
2
- flagsReady: any;
3
- flagsError: any;
3
+ flagsReady: Ref<boolean> | undefined;
4
+ flagsError: Ref<boolean> | undefined;
4
5
  };
5
6
  export default useFlagsStatus;
@@ -1,2 +1,3 @@
1
- declare const useUnleashContext: () => any;
1
+ import { IContext } from 'unleash-proxy-client';
2
+ declare const useUnleashContext: () => ((context: IContext) => Promise<void>) | undefined;
2
3
  export default useUnleashContext;
@@ -1,12 +1,41 @@
1
- import { UnleashClient, IConfig } from 'unleash-proxy-client';
1
+ import { UnleashClient, IConfig, IContext } from 'unleash-proxy-client';
2
2
  export interface IProvideOptions {
3
3
  config?: IConfig;
4
4
  unleashClient?: UnleashClient;
5
5
  startClient?: boolean;
6
6
  }
7
- export declare type ProviderContext = Record<string, any>;
8
7
  declare function useUnleashProvide({ config, unleashClient, startClient }: IProvideOptions): {
9
- context: import("vue-demi").ToRefs<ProviderContext>;
8
+ context: import("vue").ToRefs<{
9
+ on: (event: string, args_0: Function, args_1: any) => UnleashClient | undefined;
10
+ updateContext: (context: IContext) => Promise<void>;
11
+ isEnabled: (name: string) => boolean | undefined;
12
+ getVariant: (name: string) => import("unleash-proxy-client").IVariant | undefined;
13
+ client: {
14
+ getAllToggles: () => import("unleash-proxy-client").IToggle[];
15
+ isEnabled: (toggleName: string) => boolean;
16
+ getVariant: (toggleName: string) => import("unleash-proxy-client").IVariant;
17
+ updateContext: (context: import("unleash-proxy-client").IMutableContext) => Promise<void>;
18
+ getContext: () => {
19
+ appName: string;
20
+ environment?: string | undefined;
21
+ userId?: string | undefined;
22
+ sessionId?: string | undefined;
23
+ remoteAddress?: string | undefined;
24
+ properties?: {
25
+ [key: string]: string;
26
+ } | undefined;
27
+ };
28
+ setContextField: (field: string, value: string) => void;
29
+ start: () => Promise<void>;
30
+ stop: () => void;
31
+ on: (event: string, callback: Function, ctx?: any) => UnleashClient;
32
+ once: (event: string, callback: Function, ctx?: any) => UnleashClient;
33
+ emit: (event: string, ...args: any[]) => UnleashClient;
34
+ off: (event: string, callback?: Function | undefined) => UnleashClient;
35
+ } | undefined;
36
+ flagsReady: boolean;
37
+ flagsError: null;
38
+ }>;
10
39
  update: (property: string, value: any) => void;
11
40
  start: () => void;
12
41
  };
@@ -1,2 +1,10 @@
1
- declare const useVariant: (name: string) => any;
1
+ import { Ref } from 'vue';
2
+ declare const useVariant: (name: string) => Ref<{
3
+ name: string;
4
+ enabled: boolean;
5
+ payload?: {
6
+ type: string;
7
+ value: string;
8
+ } | undefined;
9
+ } | undefined>;
2
10
  export default useVariant;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unleash/proxy-client-vue",
3
- "version": "0.0.7-beta.3",
3
+ "version": "0.0.7-beta.4",
4
4
  "description": "Vue interface for working with Unleash",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -28,16 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "unleash-proxy-client": "^2.1.0",
31
- "vue-demi": "^0.13.11"
32
- },
33
- "peerDependencies": {
34
- "@vue/composition-api": "^1.0.0-rc.1",
35
- "vue": "^2.0.0 || >=3.0.0"
36
- },
37
- "peerDependenciesMeta": {
38
- "@vue/composition-api": {
39
- "optional": true
40
- }
31
+ "vue": "^3.2.45"
41
32
  },
42
33
  "devDependencies": {
43
34
  "@types/node": "^17.0.24",
@@ -45,7 +36,6 @@
45
36
  "typescript": "^4.5.4",
46
37
  "vite": "^2.9.2",
47
38
  "vite-plugin-dts": "^1.6.4",
48
- "vue-tsc": "^0.29.8",
49
- "vue": "^3.2.25"
39
+ "vue-tsc": "^1.0.10"
50
40
  }
51
41
  }
@@ -1,35 +0,0 @@
1
- import { UnleashClient, IConfig } from 'unleash-proxy-client';
2
- declare const _default: import("vue-demi").DefineComponent<{
3
- config: {
4
- type: () => IConfig;
5
- required: false;
6
- };
7
- unleashClient: {
8
- type: () => UnleashClient;
9
- required: false;
10
- };
11
- startClient: {
12
- type: BooleanConstructor;
13
- required: false;
14
- default: boolean;
15
- };
16
- }, () => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
17
- [key: string]: any;
18
- }>[] | undefined, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
19
- config: {
20
- type: () => IConfig;
21
- required: false;
22
- };
23
- unleashClient: {
24
- type: () => UnleashClient;
25
- required: false;
26
- };
27
- startClient: {
28
- type: BooleanConstructor;
29
- required: false;
30
- default: boolean;
31
- };
32
- }>>, {
33
- startClient: boolean;
34
- }>;
35
- export default _default;