function serviceHeader(){return new ServiceHeader(31,"DeepL","DeepL trains artificial intelligence to understand and translate texts."+Const.NL2+"https://www.deepl.com",Capability.TRANSLATE|Capability.DETECT_LANGUAGE)}function serviceHost(a,b,e){return"https://www2.deepl.com"}
function serviceLink(a,b,e){var c="https://www.deepl.com/translator";a&&isLanguage(b)&&isLanguage(e)&&(c+=format("#{0}/{1}/{2}",codeFromLanguage(b).toLowerCase(),codeFromLanguage(e).toLowerCase(),encodeGetParam(a)));return c}SupportedLanguages=[-1,"auto",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"NL","EN",-1,-1,-1,"FR",-1,"DE",-1,-1,-1,-1,-1,-1,-1,"IT",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,"PL","PT",-1,"RU",-1,-1,-1,"ES",-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];
function parseText(a){var b=/^\s+|(?:\s*\n)+\s*|[.!?\":;\u0964](?:\s+)|\s+$/g,e=[],c,d=0;(a=prepareSource(a))&&a.length>Const.MAX_QUERY_LEN&&(a=a.slice(0,Const.MAX_QUERY_LEN));for(var f;null!==(c=b.exec(a));){f=c[0];var g=/[.!?\":;\u0964](?:\s+)/.test(f);d<c.index&&(c=a.substr(d,c.index+(g?1:0)-d),e.push({type:1,text:c}),d+=c.length);e.push({type:0,text:g?f.slice(1):f});d+=f.length-(g?1:0)}d<a.length&&e.push({type:1,text:a.substr(d,a.length-d)});return e}
function splitText(a){return parseText(a).filter(function(a){return 1===a.type}).map(function(a){return a.text.replace(/\s+/g," ")})}function getSourceLanguage(a,b){return a&&a.result&&a.result[b]?languageFromCode(a.result[b]):UNKNOWN_LANGUAGE}
function serviceDetectLanguageRequest(a){a.length>Const.MAX_QUERY_LEN&&(a=a.slice(0,Const.MAX_QUERY_LEN));return new RequestData(HttpMethod.POST,"/jsonrpc",stringifyJSON({id:1,jsonrpc:"2.0",method:"LMT_split_into_sentences",params:{texts:[a],lang:{lang_user_selected:"auto",user_preferred_langs:["EN"]}}}))}function serviceDetectLanguageResponse(a){a=parseJSON(a);return getSourceLanguage(a,"lang")}
function serviceTranslateRequest(a,b,e){a=splitText(a);b=codeFromLanguage(b);e=codeFromLanguage(e);a=a.map(function(a){return{kind:"default",raw_en_sentence:a}});var c=1;a.forEach(function(a){c+=((a.raw_en_sentence||"").match(/[i]/g)||[]).length});var d=(new Date).getTime();b={id:2,jsonrpc:"2.0",method:"LMT_handle_jobs",params:{jobs:a,lang:{user_preferred_langs:[isLanguage(b)?b:"EN",e],source_lang_user_selected:b,target_lang:e},priority:1,timestamp:d+(c-d%c)}};return new RequestData(HttpMethod.POST,
"/jsonrpc",stringifyJSON(b))}function serviceTranslateResponse(a,b,e,c){b=parseJSON(b);var d="";if(b&&b.result&&b.result.translations){var f=b.result.translations.map(function(a){return a.beams&&0<a.beams.length?a.beams[0].postprocessed_sentence:""});parseText(a).forEach(function(a){d=0===a.type?d+a.text:d+f.shift()});isLanguage(e)||(e=getSourceLanguage(b,"source_lang"))}return new ResponseData(d,e,c,"")};
