import { L as LogUtility } from './global-slimmer-registry-0a7aa308.js';
import k from './index-bfc6dfa2.js';

/**
 * The concrete feature flag map that we are going to use to determine if a feature is enabled or not.
 */
const FeatureFlagsMap = {
  'VEGA_DATE_PICKER.COMPONENT_LOAD_REQUIRED_DECORATOR': {
    description: `Feature flag to enable the required decorator for the date picker component. <br/> <b>Note: This feature flag is for demonstration purpose and will be persisted permanently.</b>`,
    createdTimestamp: 1660330561422,
    createdAtVersion: '1.2.0',
    removedAfterVersion: '1.11.1',
  },
  'VEGA_COMPONENT.SANITIZE_VEGA_COMPONENT': {
    description: `Feature flag to enable sanitize vega components.`,
    createdTimestamp: 1664262689486,
    createdAtVersion: '1.8.1',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_TEXT.LABEL_OR_CONTENT_NESTED_VEGA_TEXT_COMPONENT': {
    description: 'Feature flag to enable the label or content of other component nested vega-text component.',
    createdTimestamp: 1665218525140,
    createdAtVersion: '1.8.1',
    removedAfterVersion: '1.9.1',
  },
  'VEGA_FLEX.ENABLE_DIRECTION_ONLY': {
    description: `Feature flag to make direction take effect only regardless of breakpoint for vega-flex component.`,
    createdTimestamp: 1665639912117,
    createdAtVersion: '1.9.0',
  },
  'VEGA_FIELD_LABEL.SHOW_LABEL': {
    description: `Feature flag to enable the vega-field-label component for vega-input, vega-input-select and vega-date-picker.`,
    createdTimestamp: 1666184962131,
    createdAtVersion: '1.9.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_FLEX.USE_NATIVE_FLEX_BEHAVIOR': {
    description: `Feature flag to enable the **default** use of native flex behavior for vega-flex component.`,
    createdTimestamp: 1668059639449,
    createdAtVersion: '1.11.1',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_TABLE.DEPRECATED_ROW_SELECTION_CHANGE_PROP': {
    description: `Feature flag to deprecate the rowSelection.onSelectChange and rowSelection.onSelectAllChange`,
    createdTimestamp: 1673321949321,
    createdAtVersion: '1.18.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_ICON.USE_SIZE_PROP_FOR_THIRD_PARTY_ICONS': {
    description: `Feature flag to make size prop of vega-icon to take effect for third party icons.`,
    createdTimestamp: 1675752744795,
    createdAtVersion: '1.20.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_INJECT_FORM_FIELD_CONTROLLER.ADD_DATA_VEGA_FORM_FILTER': {
    description: `Feature flag to deprecate the form field should validate only have data-vega-from attribute`,
    createdTimestamp: 1676017004107,
    createdAtVersion: '1.19.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_FORM_FIELD.CHANGE_BLOCK_TO_INLINE_BLOCK': {
    description: `Feature flag to deprecate the form fields like input/datePicker/timePicker should use inline block`,
    createdTimestamp: 1676512727310,
    createdAtVersion: '1.20.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_CHECKBOX_RADIO_GROUP.FLEX_DIRECTION_COL_DEFAULT': {
    description: `Feature flag to make the checkbox group and radio group prop vegaFlexProp default direction to col`,
    createdTimestamp: 1681171200000,
    createdAtVersion: '1.27.3',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_REACT.PREVENT_SSR': {
    description: `Feature flag to prevent the SSR in vega-react`,
    createdTimestamp: 1679450185124,
    createdAtVersion: '1.25.0',
    disabledByDefault: true,
  },
  'VEGA_STEPPER.INPUT_DISABLED': {
    description: `Feature flag to rename the prop input-editable to input-disabled `,
    createdTimestamp: 1683252081350,
    createdAtVersion: '1.30.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_FLEX.ALIGNITEM_JUSTIFYCONTENT_USE_PREFIX_V_INSTEAD_OF_VEGA': {
    description: `Feature flag to render vega-flex prop alignItems and justifyContent classes by using v- instead of vega-`,
    createdTimestamp: 1684128467390,
    createdAtVersion: '1.32.0',
    removedAfterVersion: '1.48.3',
  },
  'VEGA_ANGULAR.USE_JUGGLE_RESIZE_OBSERVER': {
    description: `Feature flag to enable the @juggle/resizeObserver to instead window resizeObserver`,
    createdTimestamp: 1684203399089,
    createdAtVersion: '1.31.0',
  },
  'VEGA_INPUT.FOCUS_ON_INPUT_BY_CLICK_CLEAR_BUTTON': {
    description: `Feature flag to keep the input focused whenever click the clear button`,
    createdTimestamp: 1685513925082,
    createdAtVersion: '1.34.0',
    removedAfterVersion: '1.38.2',
  },
  'VEGA_VUE.EMIT_CAMEL_CASE_EVENT_NAME': {
    description: `Feature flag to emit camel case event name for Vue framework`,
    createdTimestamp: 1688971026741,
    createdAtVersion: '1.37.0',
  },
  'VEGA_ITEM_TOGGLE_ISERROR_DEPRECATED': {
    description: `Feature flag to deprecated the component vega-item-toggle property isError`,
    createdTimestamp: 1687934508330,
    createdAtVersion: '1.36.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_BUTTON_LINK.DEPRECATED_EVENTFUL': {
    description: `Feature flag to deprecated eventful property`,
    createdTimestamp: 1689313658898,
    createdAtVersion: '1.36.1',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_DROPDOWN.RENAME_PREFIX_TO_PREFIX_ICON': {
    description: `Feature flag to rename prefix to prefixIcon`,
    createdTimestamp: 1689576347049,
    createdAtVersion: '1.37.0',
    removedAfterVersion: '2.0.0',
  },
  'VEGA_REACT.PREVENT_CALL_WATCH_METHOD_BEFORE_COMPONENT_LOAD': {
    description: `Feature flag to prevent call watch method before componnentDidLoad`,
    createdTimestamp: 1706598728908,
    createdAtVersion: '2.0.0',
  },
  'VEGA_FRAMEWORK.PREVENT_CALL_WATCH_METHOD_BEFORE_COMPONENT_LOAD': {
    description: `Feature flag to prevent call watch method before componnentDidLoad in all framework`,
    createdTimestamp: 1708495728180,
    createdAtVersion: '2.0.0',
  },
  'VEGA_REACT.ENABLE_ON_CHANGE_HANDLE_UNDER_LOW_VERSION': {
    description: `Feature flag to enable the onChange event handle under react version 19 or below`,
    createdTimestamp: 1709603823660,
    createdAtVersion: '2.0.0',
  },
  'VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD': {
    description: `Feature flag to enable the hide card number mask upon initial loading of the credit card.`,
    createdTimestamp: 1715932781059,
    createdAtVersion: '2.9.0',
  },
  'VEGA_TABLE.ENABLE_NEW_CELL_BREAK_WORDS_STYLE': {
    description: `Feature flag to enable the new cell words break style`,
    createdTimestamp: 1719282763075,
    createdAtVersion: '2.11.2',
  },
  'VEGA_TELEMETRY.ENABLE_COLLECT_COMPONENTS_USAGE': {
    description: `Feature flag to enable the collection of component usage.`,
    createdTimestamp: 1717468723384,
    createdAtVersion: '2.11.3',
  },
  'VEGA_TELEMETRY.ENABLE_COLLECT_FEATURE_FLAG_OVERRIDDEN': {
    description: `Feature flag to enable the feature flag overridden.`,
    createdTimestamp: 1717468723384,
    createdAtVersion: '2.11.3',
  },
  'VEGA_REACT.ENABLE_ON_CLOSE_HANDLE_UNDER_LOW_VERSION': {
    description: `Feature flag to enable the onClose event handle under react version 19 or below`,
    createdTimestamp: 1719910557333,
    createdAtVersion: '2.12.0',
  },
  'VEGA_BANNER_DEPRECATED_ACTION_BUTTON_PROP_VEGA_CLICK': {
    description: `Feature flag to deprecated the vega-banner component property actionButtons property vegaClick`,
    createdTimestamp: 1723449433833,
    createdAtVersion: '2.18.0',
  },
  'VEGA_REACT.SKIP_NATIVE_EVENT_PREVENT_BY_DEFAULT': {
    description: `Feature flag to skip the native event prevent logic in default`,
    createdTimestamp: 1723996800000,
    createdAtVersion: '2.18.1',
    disabledByDefault: true,
  },
  'VEGA_TELEMETRY.ENABLE_COLLECT_PUBLIC_API': {
    description: `Feature flag to enable the collection of public api.`,
    createdTimestamp: 1727232497961,
    createdAtVersion: '2.21.0',
  },
  'VEGA_LEFT_NAV.DISABLE_ANIMATION_ON_LOAD': {
    description: `Feature flag that disables the transition animation of the left nav.`,
    createdTimestamp: 1730361348399,
    createdAtVersion: '2.26.0',
  },
  'VEGA_DATE_PICKER.ENABLE_CALCULATION_POSITION_BY_SCREEN': {
    description: `Feature flag that enable use screen to calculation position.`,
    createdTimestamp: 1733293586535,
    createdAtVersion: '2.29.0',
  },
  'VEGA_TABLE.REVERSE_SORT_ORDER': {
    description: `Feature flag that reverses table column sorting order from default>asc>desc to default>desc>asc`,
    createdTimestamp: 1737521148363,
    createdAtVersion: '2.32.0',
    disabledByDefault: false,
  },
  'VEGA_PAGINATION.ENABLE_EXTENSIONS_RESPONSIVE_DEFAULT_VALUE': {
    description: `Feature flag to enable responsive default values for the extensions property in vega-pagination.`,
    createdTimestamp: 1744876233415,
    createdAtVersion: '2.42.0',
    disabledByDefault: true,
  },
  'VEGA_COMPONENT.CORNERS_USE_OLD_BEHAVIOR': {
    description: `Feature flag that the component corners style weights are sorted according to the [0, 9999, 2, 4, 8, ..., 48]`,
    createdTimestamp: 1744772429681,
    createdAtVersion: '2.41.0',
    disabledByDefault: true,
  },
  'VEGA_INPUT_PHONE_NUMBER.ENABLE_CALCULATION_POSITION_BY_SCREEN': {
    description: `Feature flag that enable use screen to calculation position.`,
    createdTimestamp: 1750317683577,
    createdAtVersion: '2.48.1',
    disabledByDefault: true,
  },
  'VEGA_ELEMENT_APPENDER.AUTO_PLACEMENT': {
    description: `A feature flag to automatic placement for appendable pop-ups when isScreenPosition is enabled.`,
    createdTimestamp: 1770940800000,
    createdAtVersion: '2.76.0',
    disabledByDefault: false,
  },
};
const FeatureFlagsMap$1 = Object.freeze(FeatureFlagsMap);

/**
 * Feature flag controller to manage feature flags.
 *
 * @class FeatureFlag
 * @property {Set<FeatureFlagKey>} enabledFeatureFlagKeySet - Set of feature flags that are enabled.
 */
class FeatureFlagController {
  /**
   * During constructor, It enables all the feature flags given by {@link FeatureFlagsMap} expect default disabled flags.
   */
  constructor() {
    this.enabledFeatureFlagKeySet = new Set();
    this.init();
  }
  /**
   * This function enables the feature flags with the given keys.
   *
   * @param {FeatureFlagKey[]} featureFlagKeys - The feature flags to enable.
   * @vegaVersion 1.3.0
   */
  enable(...featureFlagKeys) {
    featureFlagKeys.forEach((featureFlagKey) => {
      if (this.versionGuard(featureFlagKey)) {
        this.enabledFeatureFlagKeySet.add(featureFlagKey);
        this.sendFeatureFlagKeyToTelemetry(featureFlagKey, true);
      }
    });
  }
  /**
   * Disable the feature flags with the given keys.
   *
   * @param {FeatureFlagKey[]} featureFlagKeys - The feature flags to disable.
   * @vegaVersion 1.3.0
   */
  disable(...featureFlagKeys) {
    featureFlagKeys.forEach((featureFlagKey) => {
      if (this.versionGuard(featureFlagKey)) {
        this.enabledFeatureFlagKeySet.delete(featureFlagKey);
        this.sendFeatureFlagKeyToTelemetry(featureFlagKey, false);
      }
    });
  }
  /**
   * If the feature flag key is in the set of enabled feature flag keys, then return true, otherwise return false.
   *
   * @param {FeatureFlagKey} featureFlagKey - The feature flag key to check.
   * @returns {boolean} - True if the feature flag key is in the set of enabled feature flag keys, otherwise false.
   * @vegaVersion 1.3.0
   */
  isEnabled(featureFlagKey) {
    return this.enabledFeatureFlagKeySet.has(featureFlagKey);
  }
  /**
   * The `init` function initializes a set of enabled feature flags based on a map of feature flags,
   * excluding those disabled by default or removed.
   */
  init() {
    Object.keys(FeatureFlagsMap$1).map((flagKey) => {
      if (!FeatureFlagsMap$1[flagKey].disabledByDefault && !this.isRemoved(flagKey)) {
        this.enabledFeatureFlagKeySet.add(flagKey);
      }
    });
  }
  /**
   * Verify if the flag is valid
   *
   * @param {FeatureFlagKey} featureFlagKey - the feature flag key
   * @returns {boolean} return false and console error if the feature flag is removedAfterVersion is not empty
   */
  versionGuard(featureFlagKey) {
    if (this.isRemoved(featureFlagKey)) {
      LogUtility.error(`The feature flag key '${featureFlagKey}' has been removed after v${FeatureFlagsMap$1[featureFlagKey].removedAfterVersion}`);
      return false;
    }
    return true;
  }
  /**
   * Verify if the flag is removed or not
   *
   * @param {FeatureFlagKey} featureFlagKey - the feature flag key
   * @returns {boolean} return true if the feature flag removedAfterVersion is not empty
   */
  isRemoved(featureFlagKey) {
    return !!FeatureFlagsMap$1[featureFlagKey].removedAfterVersion;
  }
  /**
   * The function sends a feature flag key and its value to telemetry if a specific feature flag is
   * enabled.
   *
   * @param {FeatureFlagKey} featureFlagName - The `featureFlagName` parameter is a key that represents
   * a specific feature flag. It is used to identify and reference a particular feature
   * flag when checking its status or sending telemetry data related to it.
   * @param {boolean} featureFlagValue - The `featureFlagValue` parameter is a boolean value that
   * represents the value of a feature flag. It indicates whether the feature flag is enabled (`true`)
   * or disabled (`false`).
   */
  sendFeatureFlagKeyToTelemetry(featureFlagName, featureFlagValue) {
    if (this.canSendFeatureFlagsToTelemetry(featureFlagName, featureFlagValue)) {
      k.emit('featureFlagOverridden', {
        featureFlagName: featureFlagName,
        featureFlagOverriddenValue: featureFlagValue,
      });
    }
  }
  /**
   * The function `canSendFeatureFlagsToTelemetry` checks if a specific feature flag can be sent to
   * telemetry based on certain conditions.
   *
   * @param {FeatureFlagKey} featureFlagName - The `featureFlagName` parameter represents the key or
   * identifier of a feature flag. It is used to look up the corresponding feature flag in the
   * `FeatureFlagsMap` object.
   * @param {boolean} featureFlagValue - The `featureFlagValue` parameter in the
   * `canSendFeatureFlagsToTelemetry` function represents the value of a specific feature flag. It is a
   * boolean value that indicates whether the feature flag is enabled (`true`) or disabled (`false`).
   * @returns {boolean} The function `canSendFeatureFlagsToTelemetry` is returning a boolean value.
   */
  canSendFeatureFlagsToTelemetry(featureFlagName, featureFlagValue) {
    return !!FeatureFlagsMap$1[featureFlagName].disabledByDefault === featureFlagValue;
  }
}
const FeatureFlag = new FeatureFlagController();

export { FeatureFlag };
