"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const _sdk = require("@lingo.dev/_sdk");
const index = require("./index-QSf6WJj0.cjs");
class LingoDotDevService {
  static {
    this.engine = new _sdk.LingoDotDevEngine({
      apiKey: index.LINGO_DOT_DEV_API_KEY
    });
  }
  /**
   * Localizes text from one language to another
   * @param text The text to localize
   * @param sourceLocale The source language locale
   * @param targetLocale The target language locale
   * @returns The localized text
   */
  static async localizeText(text, sourceLocale, targetLocale) {
    if (!text?.trim()) {
      return null;
    }
    try {
      const result = await this.engine.localizeText(text, {
        sourceLocale,
        targetLocale
      });
      return result;
    } catch (error) {
      index.logger.error(`LingoDotDevEngine.localizeText() failed for targetLocale: ${targetLocale} - ${error}`);
      return null;
    }
  }
  /**
   * Localize a text string to multiple target locales
   * @param text The text to localize
   * @param sourceLocale The source language locale
   * @param targetLocales Array of the target language locales
   * @returns The localized texts
   */
  static async batchLocalizeText(text, sourceLocale, targetLocales) {
    try {
      const result = await this.engine.batchLocalizeText(text, {
        sourceLocale,
        targetLocales
      });
      return result;
    } catch (error) {
      index.logger.error(`LingoDotDevEngine.batchLocalizeText() failed: ${error}`);
      return [];
    }
  }
  /**
   * Localizes an array of texts from one language to another
   * @param texts Array of texts to localize
   * @param sourceLocale The source language locale
   * @param targetLocale The target language locale
   * @returns The localized texts array
   */
  static async localizeTexts(texts, sourceLocale, targetLocale) {
    if (!texts.length) {
      return texts;
    }
    try {
      const result = await this.engine.localizeChat(
        texts.map((text) => ({ name: "NO_NAME", text: text.trim() })),
        {
          sourceLocale,
          targetLocale
        }
      );
      return result.map((chat) => chat.text);
    } catch (error) {
      index.logger.error(`LingoDotDevEngine.localizeTexts() failed: ${error}`);
      return texts;
    }
  }
}
exports.LingoDotDevService = LingoDotDevService;
