var LanguageDirection,TranslationStatusResult,TranslatorProvider,UrlLanguageLocation,exports={};Object.defineProperty(exports,"__esModule",{value:!0}),function(t){t[t.ltr=0]="ltr",t[t.rtl=1]="rtl"}(LanguageDirection=exports.LanguageDirection||(exports.LanguageDirection={})),function(t){t[t.ignored=1]="ignored",t[t.succeeded=2]="succeeded",t[t.failed=3]="failed"}(TranslationStatusResult=exports.TranslationStatusResult||(exports.TranslationStatusResult={})),function(t){t[t.none=0]="none",t[t.Azure=1]="Azure"}(TranslatorProvider=exports.TranslatorProvider||(exports.TranslatorProvider={})),function(t){t[t.none=0]="none",t[t.subdirectory=1]="subdirectory"}(UrlLanguageLocation=exports.UrlLanguageLocation||(exports.UrlLanguageLocation={})),Object.defineProperty(exports,"__esModule",{value:!0});var Translations=function(){return function(){this.translation=[]}}();exports.Translations=Translations;var TranslationValue=function(){return function(){}}();exports.TranslationValue=TranslationValue;var Language=function(){return function(){}}();exports.Language=Language;var TranslationStatus=function(){return function(t,e,n){this.element=t,this.result=e,this.text=n}}();exports.TranslationStatus=TranslationStatus,Object.defineProperty(exports,"__esModule",{value:!0});var __awaiter=this&&this.__awaiter||function(t,e,n,a){return new(n||(n=Promise))(function(r,o){function i(t){try{u(a.next(t))}catch(t){o(t)}}function s(t){try{u(a.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,s)}u((a=a.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,a,r,o,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,a&&(r=2&o[0]?a.return:o[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,o[1])).done)return r;switch(a=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,a=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){i=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1] *"]},enumerable:!0,configurable:!0}),Object.defineProperty(t,"stylePropertiesToSwitch",{get:function(){var t=[];return["padding","margin"].forEach(function(e){t.push(e+"-left"),t.push(e+"-right")}),t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"stylePropertiesToOpposite",{get:function(){return["text-align","float","background-position-x"]},enumerable:!0,configurable:!0}),Object.defineProperty(t,"translatorProviderKey",{get:function(){return this._settings.translatorProviderKey},enumerable:!0,configurable:!0}),Object.defineProperty(t,"translatorProvider",{get:function(){return this._settings.translatorProvider},enumerable:!0,configurable:!0}),Object.defineProperty(t,"urlLanguageLocation",{get:function(){return this._settings.urlLanguageLocation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"logTranslationsFromProvider",{get:function(){return this._settings.logTranslationsFromProvider},enumerable:!0,configurable:!0}),Object.defineProperty(t,"supportsTranslateAttribute",{get:function(){return void 0!==this._supportsTranslateAttribute?this._supportsTranslateAttribute:this._supportsTranslateAttribute=void 0!==$("body")[0].translate},enumerable:!0,configurable:!0}),t.doTranslateElement=function(t){if(this.supportsTranslateAttribute)return!1!==t.translate&&(void 0===$(t).closest("*[translate]")[0]||!1!==$(t).closest("*[translate]")[0].translate);var e=$(t).attr("translate");return void 0===e?void 0===$(t).closest("*[translate]")[0]||"no"!==$(t).closest("*[translate]").attr("translate").toLowerCase():"no"!==e.toLowerCase()},Object.defineProperty(t,"defaultLanguage",{get:function(){var t=this;return void 0!==this._defaultLanguage?this._defaultLanguage:(this.languages.forEach(function(e){e.code.toLowerCase()===t._settings.defaultLanguage.toLowerCase()&&(t._defaultLanguage=e)}),this._defaultLanguage)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"languages",{get:function(){return this._settings.languages},enumerable:!0,configurable:!0}),t.parseLanguage=function(t){var e;return t=t.trim().toLowerCase(),this.languages.forEach(function(n){n.code.toLowerCase()===t&&(e=n)}),void 0!==e?e:(-1!==t.indexOf("-")&&this.languages.forEach(function(n){n.code.toLowerCase()===t.split("-")[0]&&(e=n)}),void 0!==e?e:this.defaultLanguage)},Object.defineProperty(t,"direction",{get:function(){return this.currentLanguage.direction},enumerable:!0,configurable:!0}),t.translations=function(){return __awaiter(this,void 0,void 0,function(){var e,n,a,r,o,i,s,u;return __generator(this,function(l){switch(l.label){case 0:return void 0!==(e=this.getTranslations(t.currentLanguage.code))&&null===e.translation?[2,void 0]:void 0!==e?[2,e]:(n="translation/"+this.currentLanguage.code.toLowerCase()+".json",[4,fetch(n)]);case 1:return(a=l.sent()).ok?[3,3]:(n=location.protocol+"//"+location.host+"/"+n,[4,fetch(n)]);case 2:if(!(a=l.sent()).ok)return(r=new Translations).languageCode=t.currentLanguage.code,r.translation=null,this._translationsList.push(r),[2,void 0];l.label=3;case 3:return[4,a.json()];case 4:for(o=l.sent(),i=0,s=o;i0&&-1===t.indexOf(" ")&&(e=!0)}),e},t.azureAutoTranslate=function(t){return __awaiter(this,void 0,void 0,function(){var e,n,a,r,o,i=this;return __generator(this,function(s){switch(s.label){case 0:if(0===t.length)return[2,[]];e="",t.forEach(function(t){e+='{"Text": "'+t+'"},'}),n=[],s.label=1;case 1:return s.trys.push([1,3,,4]),[4,$.ajax({url:"https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from="+this.defaultLanguage.code+"&to="+this.currentLanguage.code,type:"POST",dataType:"json",data:"["+e+"]",cache:!0,beforeSend:function(t){t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Ocp-Apim-Subscription-Key",i.translatorProviderKey)}})];case 2:return a=s.sent(),r=[],$.each(a,function(e,a){n[e]=a.translations[0].text,i.logTranslationsFromProvider&&r.push('{"o": "'+t[e].trim()+'", "t": "'+n[e].trim()+'"}')}),this.logTranslationsFromProvider&&console.log("["+r.join(",")+"]"),[3,4];case 3:return o=s.sent(),console.log(o.responseJSON.error.message),console.log(e),[3,4];case 4:return[2,n]}})})},t.scrollToTop=function(t){var e=0,n=(window.pageYOffset-e)/2,a=0,r=window.performance.now();window.requestAnimationFrame(function o(i){var s=i-r;if(s>100&&(s=30),!((a+=Math.PI/(t/s))>=Math.PI)){var u=Math.round(e+n+n*Math.cos(a));window.scrollTo(0,u),r=i,window.requestAnimationFrame(o)}})},t.updateCurrentLanguage=function(){var t,e,n,a,r;try{a=localStorage.getItem("lang")}catch(t){console.log("localStorage is not supported."),a=null}(null!==a&&(t=this.parseLanguage(a)),void 0!==this.urlLanguageLocation)&&(this.urlLanguageLocation===UrlLanguageLocation.subdirectory&&(r=window.location.pathname.split("/")[1]),void 0!==r&&(2===r.length||5===r.length&&2===r.indexOf("-"))&&(this.languages.forEach(function(t){t.code.toLowerCase()===r.toLowerCase()&&(a=t.code)}),-1!==r.indexOf("-")&&void 0===a&&(r=r.split("-")[0],this.languages.forEach(function(t){t.code.toLowerCase()===r.toLowerCase()&&(a=t.code)})),void 0!==a&&(e=this.parseLanguage(a))));void 0!==(a=navigator.language||navigator.userLanguage)&&(n=this.parseLanguage(a)),void 0!==e?this.setCurrentLanguage(e.code):void 0!==t?this.setCurrentLanguage(t.code):void 0!==n?this.setCurrentLanguage(n.code):this.setCurrentLanguage(this.defaultLanguage.code)},Object.defineProperty(t,"currentLanguage",{get:function(){return void 0!==this._currentLanguage?this._currentLanguage:(this.updateCurrentLanguage(),this._currentLanguage)},enumerable:!0,configurable:!0}),t.updateUrlLanguage=function(){if(void 0!==this.urlLanguageLocation&&this.urlLanguageLocation===UrlLanguageLocation.subdirectory){var t=window.location.pathname.split("/"),e=t[1];2===e.length||5===e.length&&2===e.indexOf("-")?t[1]=this.currentLanguage.code:t.splice(1,0,this.currentLanguage.code),history.replaceState(null,null,t.join("/"))}},t.setCurrentLanguage=function(t){this._currentLanguage=this.parseLanguage(t);try{localStorage.setItem("lang",this._currentLanguage.code)}catch(t){console.log("localStorage is not supported.")}this.updateUrlLanguage()},t.translateDOM=function(){return __awaiter(this,void 0,void 0,function(){var e,n,a,r,o,i,s,u,l,c,g,d;return __generator(this,function(f){switch(f.label){case 0:$("html").attr("lang",t.currentLanguage.code),t.direction===LanguageDirection.rtl?$("html").attr("dir","rtl"):$("html").removeAttr("dir"),$.each(document.styleSheets,function(t,n){try{$.each(n.cssRules||n.rules,function(t,a){'html[dir="rtl"] { direction: rtl; }'===a.cssText&&(e=n)})}catch(t){}}),t.direction===LanguageDirection.rtl&&void 0===e&&t.addRTLCSS(),n="*",t.nonTranslatedElements.forEach(function(t){n+=':not("'+t+'")'}),a=[],r=0,o=$(n).toArray(),f.label=1;case 1:if(!(r"+t.displayName+"")})}},t}();exports.CloudTranslation=CloudTranslation;