"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isAutocompleteDebugEnabled = void 0;
/**
 * Contextual Typeahead Completions (CTC) debug logging utility.
 *
 * Logs are silent by default. Enable in any environment (dev, staging, prod):
 *
 *   // Live, for the current session (no reload required):
 *   __atlCtcDebug__.enable()
 *
 *   // To disable:
 *   __atlCtcDebug__.disable()
 *
 *   // From initial page load (survives reload) — append to the URL:
 *   ?atlCtcDebug=1
 *
 * Storage-free by design: avoids browser-storage consent controls (BSC), which can
 * block uncategorized localStorage/sessionStorage/cookie writes in some products.
 */

var hasUrlDebugFlag = function hasUrlDebugFlag() {
  if (typeof window === 'undefined') {
    return false;
  }
  try {
    return new URLSearchParams(window.location.search).get('atlCtcDebug') === '1';
  } catch (_unused) {
    return false;
  }
};

// State lives on the window object (not a module closure) so duplicate copies of this
// module across separate bundles/realms share one source of truth and the console API
// controls them all. In-memory only; persisted across reload via the URL flag.
var getDebugApi = function getDebugApi() {
  if (typeof window === 'undefined') {
    return undefined;
  }
  if (!window.__atlCtcDebug__) {
    var debugEnabled = hasUrlDebugFlag();
    window.__atlCtcDebug__ = {
      enable: function enable() {
        debugEnabled = true;
      },
      disable: function disable() {
        debugEnabled = false;
      },
      isEnabled: function isEnabled() {
        return debugEnabled;
      }
    };
  }
  return window.__atlCtcDebug__;
};
var isAutocompleteDebugEnabled = exports.isAutocompleteDebugEnabled = function isAutocompleteDebugEnabled() {
  var _getDebugApi$isEnable, _getDebugApi;
  return (_getDebugApi$isEnable = (_getDebugApi = getDebugApi()) === null || _getDebugApi === void 0 ? void 0 : _getDebugApi.isEnabled()) !== null && _getDebugApi$isEnable !== void 0 ? _getDebugApi$isEnable : false;
};

// Eagerly install so the console API is available on load, regardless of call order.
getDebugApi();