!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define("i18nextBrowserLanguageDetector",o):e.i18nextBrowserLanguageDetector=o()}(this,function(){"use strict";function e(e){return a.call(i.call(arguments,1),function(o){if(o)for(var t in o)void 0===e[t]&&(e[t]=o[t])}),e}function o(){return{order:["querystring","cookie","localStorage","navigator"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",caches:["localStorage"]}}var t={};t.classCallCheck=function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")},t.createClass=function(){function e(e,o){for(var t=0;t0){var r=n[a].substring(0,i);r===e.lookupQuerystring&&(o=n[a].substring(i+1))}}return o}},s={setItem:function(e,o){if(window.localStorage)try{window.localStorage.setItem(e,o)}catch(t){}},getItem:function(e,o){if(window.localStorage)try{return window.localStorage.getItem(e,o)}catch(t){return}}},l={name:"localStorage",lookup:function(e){var o=void 0;if(e.lookupLocalStorage&&"undefined"!=typeof window&&window.localStorage){var t=s.getItem(e.lookupLocalStorage);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupLocalStorage&&"undefined"!=typeof window&&window.localStorage&&s.setItem(o.lookupLocalStorage,e)}},g={name:"navigator",lookup:function(e){var o=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var t=0;t0?o:void 0}},f=function(){function n(e){var o=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];t.classCallCheck(this,n),this.type="languageDetector",this.detectors={},this.init(e,o)}return t.createClass(n,[{key:"init",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],a=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];this.services=t,this.options=e(n,this.options||{},o()),this.i18nOptions=a,this.addDetector(c),this.addDetector(u),this.addDetector(l),this.addDetector(g)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var o=this;e||(e=this.options.order);var t=[];e.forEach(function(e){if(o.detectors[e]){var n=o.detectors[e].lookup(o.options);n&&"string"==typeof n&&(n=[n]),n&&(t=t.concat(n))}});var n=void 0;return t.forEach(function(e){if(!n){var t=o.services.languageUtils.formatLanguageCode(e);o.services.languageUtils.isWhitelisted(t)&&(n=t)}}),n||this.i18nOptions.fallbackLng[0]}},{key:"cacheUserLanguage",value:function(e,o){var t=this;o||(o=this.options.caches),o&&o.forEach(function(o){t.detectors[o]&&t.detectors[o].cacheUserLanguage(e,t.options)})}}]),n}();return f.type="languageDetector",f});