import {
  API_PRESETS_REGISTRY,
  getPresetsForEndpoint,
  getPresetsByMethod,
  getAllPresets,
  hasPresets
} from "@nextsparkjs/registries/api-presets-registry";
class ApiPresetsService {
  // ==================== Query Methods ====================
  /**
   * Get all presets for an endpoint
   *
   * @param endpoint - The endpoint path (e.g., '/api/v1/customers')
   * @returns Endpoint presets config or undefined if not found
   *
   * @example
   * const config = ApiPresetsService.getByEndpoint('/api/v1/customers')
   * if (config) {
   *   console.log(`Found ${config.presets.length} presets`)
   * }
   */
  static getByEndpoint(endpoint) {
    return getPresetsForEndpoint(endpoint);
  }
  /**
   * Get presets filtered by HTTP method
   *
   * @param endpoint - The endpoint path
   * @param method - The HTTP method (GET, POST, etc.)
   * @returns Array of presets for that method
   *
   * @example
   * const getPresets = ApiPresetsService.getByEndpointAndMethod('/api/v1/customers', 'GET')
   */
  static getByEndpointAndMethod(endpoint, method) {
    return getPresetsByMethod(endpoint, method);
  }
  /**
   * Get all endpoint presets configurations
   *
   * @returns Array of all endpoint preset configs
   */
  static getAll() {
    return getAllPresets();
  }
  /**
   * Check if an endpoint has presets defined
   *
   * @param endpoint - The endpoint path
   * @returns True if presets exist for this endpoint
   */
  static hasPresets(endpoint) {
    return hasPresets(endpoint);
  }
  // ==================== Metadata Methods ====================
  /**
   * Get registry metadata
   *
   * @returns Object with totalEndpoints, totalPresets, generatedAt, themeName
   */
  static getMeta() {
    return API_PRESETS_REGISTRY.meta;
  }
  /**
   * Get total count of presets
   *
   * @returns Total number of presets across all endpoints
   */
  static getTotalPresets() {
    return API_PRESETS_REGISTRY.meta.totalPresets;
  }
  /**
   * Get total count of endpoints with presets
   *
   * @returns Total number of endpoints that have presets defined
   */
  static getTotalEndpoints() {
    return API_PRESETS_REGISTRY.meta.totalEndpoints;
  }
  // ==================== Search Methods ====================
  /**
   * Search presets by tag
   *
   * @param tag - The tag to search for
   * @returns Array of presets that have this tag
   */
  static getByTag(tag) {
    var _a;
    const allConfigs = getAllPresets();
    const results = [];
    for (const config of allConfigs) {
      for (const preset of config.presets) {
        if ((_a = preset.tags) == null ? void 0 : _a.includes(tag)) {
          results.push(preset);
        }
      }
    }
    return results;
  }
  /**
   * Get all unique tags across all presets
   *
   * @returns Array of unique tag strings
   */
  static getAllTags() {
    const allConfigs = getAllPresets();
    const tags = /* @__PURE__ */ new Set();
    for (const config of allConfigs) {
      for (const preset of config.presets) {
        if (preset.tags) {
          preset.tags.forEach((tag) => tags.add(tag));
        }
      }
    }
    return Array.from(tags).sort();
  }
}
export {
  ApiPresetsService
};
