import{logger as e}from"../../logger/index.mjs";import{translateJSON as t}from"./translateJSON/index.mjs";import{c as n,s as r}from"../../packages/@intlayer/chokidar/dist/esm/utils/chunkJSON.mjs";import{e as i}from"../../packages/@intlayer/chokidar/dist/esm/utils/reduceObjectFormat.mjs";import{e as a}from"../../packages/@intlayer/chokidar/dist/esm/utils/verifyIdenticObjectFormat.mjs";const o=e=>new Promise(t=>setTimeout(t,e)),s=async(e,t=3)=>{try{return await e()}catch(n){if(t<=0)throw n;return await o(2e3),s(e,t-1)}},c=async({content:o,sourceLocale:c,targetLocales:l,aiConfig:u,mode:d=`complete`,dictionaryDescription:f,applicationContext:p})=>{let m=r(o,3e3),h={};for(let r of l){e.info(`Translating to ${r}... (${m.length} chunks)`);let o=[];for(let e of m){let l=n(e),m=i(l,l),h=await s(async()=>{let e=await t({entryFileContent:l,presetOutputContent:m,entryLocale:c,outputLocale:r,mode:d,aiConfig:u,dictionaryDescription:f,applicationContext:p,tags:[]});if(!e?.fileContent)throw Error(`No content returned from AI`);let n=a(e.fileContent,l);if(!n.isIdentic)throw Error(`Format verification failed: ${n.error}`);return e.fileContent});o.push(h)}h[r]=mergeChunks(o)}return h};export{c as translateDictionaryDB};
//# sourceMappingURL=translateDictionaryDB.mjs.map