{"version":3,"file":"base64-DH0STixb.mjs","names":[],"sources":["../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n  GTJSON: ['GTJSON'],\n  JSON: ['JSON'],\n  PO: ['PO'],\n  // POT templates can produce translated PO catalog files.\n  POT: ['POT', 'PO'],\n  YAML: ['YAML'],\n  MDX: ['MDX'],\n  MD: ['MD'],\n  TS: ['TS'],\n  JS: ['JS'],\n  HTML: ['HTML'],\n  TXT: ['TXT'],\n  TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format.\n * @param to - The target file format.\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n  from: FileFormat,\n  to: FileFormat\n): boolean {\n  const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n  return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n  fileFormat?: FileFormat;\n  transformFormat?: FileFormat;\n  fileName?: string;\n  fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n  file: FileFormatTransformInput\n): string | undefined {\n  if (!file.transformFormat) return undefined;\n  const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n  if (!file.fileFormat) {\n    return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n  }\n  if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n    return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n  }\n  return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n  files: FileFormatTransformInput[]\n): void {\n  for (const file of files) {\n    const error = getFileFormatTransformError(file);\n    if (error) throw new Error(error);\n  }\n}\n","// Encode a string to base64\nexport function encode(data: string): string {\n  if (typeof Buffer !== 'undefined') {\n    // Node.js path.\n    return Buffer.from(data, 'utf8').toString('base64');\n  }\n  // Browser path.\n  const bytes = new TextEncoder().encode(data);\n  let binary = '';\n  for (let i = 0; i < bytes.length; i++) {\n    binary += String.fromCharCode(bytes[i]);\n  }\n  return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n  if (typeof Buffer !== 'undefined') {\n    // Node.js path.\n    return Buffer.from(base64, 'base64').toString('utf8');\n  }\n  // Browser path.\n  const binary = atob(base64);\n  const bytes = new Uint8Array(binary.length);\n  for (let i = 0; i < binary.length; i++) {\n    bytes[i] = binary.charCodeAt(i);\n  }\n  return new TextDecoder().decode(bytes);\n}\n"],"mappings":";AAAA,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC7C;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;;;;;ACfpC,SAAg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