function serviceHeader(){return new ServiceHeader(5,"Microsoft","Microsoft Translator is a cloud service that translates between 60+ languages."+Const.NL2+serviceHost()+"/translator/"+Const.NL2+"\u00a9 2019 Microsoft",Capability.TRANSLATE|Capability.DETECT_LANGUAGE)}function serviceHost(a,b,c){return"https://"+("cn"===Options.PreferredDomain||"cn"===Options.GoogleDomain?"cn.bing.com":"www.bing.com")}
function serviceLink(a,b,c){var e=serviceHost()+"/translator";a&&(b=isLanguage(b)?codeFromLanguage(b):"-",c=isLanguage(c)?codeFromLanguage(c):"-",e+=format("?text={0}&from={1}&to={2}",encodeGetParam(a),b,c));return e}
SupportedLanguages=[-1,"auto-detect","af",-1,-1,"ar",-1,-1,-1,"bg","ca","zh-Hans","zh-Hant","hr","cs","da","nl","en","et","fi","fil","fr",-1,"de","el","ht","he","hi","hu","is","id","it",-1,"ja",-1,"ko","lv","lt",-1,"ms","mt","no","fa","pl","pt","ro","ru","sr-Cyrl","sk","sl","es",-1,"sv","th","tr","uk","ur","vi","cy",-1,-1,"mww",-1,-1,-1,-1,-1,-1,"te",-1,-1,-1,"ta",-1];function _adjustSource(a){return a&&a.length>Const.MAX_QUERY_LEN?a.slice(0,Const.MAX_QUERY_LEN):a}
function serviceRequest(a,b,c){a=_adjustSource(a);a="text="+encodePostParam(a)+"&fromLang="+codeFromLanguage(b||AUTO_DETECT_LANGUAGE)+"&to="+codeFromLanguage(c||ENGLISH_LANGUAGE);b=postHeader();return new RequestData(HttpMethod.POST,"/ttranslatev3",a,b)}function getResponseObj(a){if((a=parseJSON(a))&&0<a.length)return a[0]}function getSourceLanguage(a){return a&&a.detectedLanguage?languageFromCode(a.detectedLanguage.language):UNKNOWN_LANGUAGE}
function serviceDetectLanguageRequest(a){return serviceRequest(a)}function serviceDetectLanguageResponse(a){a=getResponseObj(a);return getSourceLanguage(a)}function serviceTranslateRequest(a,b,c){return serviceRequest(a,b,c)}function serviceTranslateResponse(a,b,c,e){var d=getResponseObj(b);b="";d&&d.translations&&(b=d.translations[0].text);isLanguage(c)||(c=getSourceLanguage(d));a=a&&!/[\n\r]/.test(a)&&3>=a.split(" ").length?"dictionaryRequest":null;return new ResponseData(b,c,e,null,a)}
function dictionaryRequest(a,b,c){a=_adjustSource(a);a="text="+encodePostParam(a)+"&from="+codeFromLanguage(b)+"&to="+codeFromLanguage(c);b=getHeader();return new RequestData(HttpMethod.POST,"/tlookupv3",a,b,null,"dictionaryResponse")}
function dictionaryResponse(a,b,c,e){a=getResponseObj(b);b="";var d,l={ADJ:"Adjectives",ADV:"Adverbs",CONJ:"Conjunctions",DET:"Determiners",MODAL:"Verbs",NOUN:"Nouns",PREP:"Prepositions",PRON:"Pronouns",VERB:"Verbs"};if(a&&a.translations){var g={};for(d=0;d<a.translations.length;d++){var f=a.translations[d],h="    "+f.displayTarget;f.backTranslations&&(h+=" ("+f.backTranslations.map(function(a){return a.displayText}).join(", ")+")");g[f.posTag]?g[f.posTag].push(h):g[f.posTag]=[h]}for(var k in g)b+=
(l[k]||k)+":"+Const.NL,b+=g[k].join(Const.NL),b+=Const.NL2}b&&(b=Const.NL2+b);return new ResponseData(b,c,e)};
