(()=>{"use strict";function e(e){const t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}function t(t){const n=`${t}-callback`;return"https"===(e("deeplinkScheme")||"").toLowerCase()?`https://${function(){const e=window.location.hostname||"";return e.endsWith("bitwarden.eu")?"bitwarden.eu":e.endsWith("bitwarden.pw")?"bitwarden.pw":"bitwarden.com"}()}/${n}`:`bitwarden://${n}`}var n=function(e,t,n,o){return new(n||(n=Promise))(function(a,s){function i(e){try{l(o.next(e))}catch(t){s(t)}}function r(e){try{l(o.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((o=o.apply(e,t||[])).next())})};class o{constructor(e,t,n){this.systemLanguage=e,this.localesDirectory=t,this.getLocalesJson=n,this.supportedTranslationLocales=["en"],this.defaultLocale="en",this.localeNames=new Map([["af","Afrikaans"],["ar","العربية الفصحى"],["az","Azərbaycanca"],["be","Беларуская"],["bg","български"],["bn","বাংলা"],["bs","bosanski jezik"],["ca","català"],["cs","čeština"],["cy","Cymraeg, y Gymraeg"],["da","dansk"],["de","Deutsch"],["el","Ελληνικά"],["en","English"],["en-GB","English (British)"],["en-IN","English (India)"],["eo","Esperanto"],["es","español"],["et","eesti"],["eu","euskara"],["fa","فارسی"],["fi","suomi"],["fil","Wikang Filipino"],["fr","français"],["gl","galego"],["he","עברית"],["hi","हिन्दी"],["hr","hrvatski"],["hu","magyar"],["id","Bahasa Indonesia"],["it","italiano"],["ja","日本語"],["ka","ქართული"],["km","ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ"],["kn","ಕನ್ನಡ"],["ko","한국어"],["lt","lietuvių kalba"],["lv","Latvietis"],["me","црногорски"],["ml","മലയാളം"],["mr","मराठी"],["my","ဗမာစကား"],["nb","norsk (bokmål)"],["ne","नेपाली"],["nl","Nederlands"],["nn","Norsk Nynorsk"],["or","ଓଡ଼ିଆ"],["pl","polski"],["pt-BR","português do Brasil"],["pt-PT","português"],["ro","română"],["ru","русский"],["si","සිංහල"],["sk","slovenčina"],["sl","Slovenski jezik, Slovenščina"],["sr","Српски"],["sv","svenska"],["ta","தமிழ்"],["te","తెలుగు"],["th","ไทย"],["tr","Türkçe"],["uk","українська"],["vi","Tiếng Việt"],["zh-CN","中文(中国大陆)"],["zh-TW","中文(台灣)"]]),this.defaultMessages={},this.localeMessages={},this.systemLanguage=e.replace("_","-")}init(e){return n(this,void 0,void 0,function*(){if(this.inited)throw new Error("i18n already initialized.");if(null==this.supportedTranslationLocales||0===this.supportedTranslationLocales.length)throw new Error("supportedTranslationLocales not set.");this.inited=!0,this.translationLocale=null!=e?e:this.systemLanguage;try{this.collator=new Intl.Collator(this.translationLocale,{numeric:!0,sensitivity:"base"})}catch(t){this.collator=null}-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.translationLocale.slice(0,2),-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.defaultLocale)),null!=this.localesDirectory&&(yield this.loadMessages(this.translationLocale,this.localeMessages),this.translationLocale!==this.defaultLocale&&(yield this.loadMessages(this.defaultLocale,this.defaultMessages)))})}t(e,t,n,o){return this.translate(e,t,n,o)}translate(e,t,n,o){let a;return a=this.localeMessages.hasOwnProperty(e)&&this.localeMessages[e]?this.localeMessages[e]:this.defaultMessages.hasOwnProperty(e)&&this.defaultMessages[e]?this.defaultMessages[e]:"",""!==a&&(null!=t&&(a=a.split("__$1__").join(t.toString())),null!=n&&(a=a.split("__$2__").join(n.toString())),null!=o&&(a=a.split("__$3__").join(o.toString()))),a}loadMessages(e,t){return n(this,void 0,void 0,function*(){const n=e.replace("-","_"),o=yield this.getLocalesJson(n);for(const e in o)if(o.hasOwnProperty(e)&&(t[e]=o[e].message,o[e].placeholders))for(const n in o[e].placeholders){if(!o[e].placeholders.hasOwnProperty(n)||!o[e].placeholders[n].content)continue;const a="\\$"+n.toUpperCase()+"\\$";let s=o[e].placeholders[n].content;"$1"!==s&&"$2"!==s&&"$3"!==s||(s="__$"+s+"__"),t[e]=t[e].replace(new RegExp(a,"g"),s)}})}}const a=["en","af","ar","az","be","bg","bn","bs","ca","cs","cy","da","de","el","en-GB","en-IN","eo","es","et","eu","fa","fi","fil","fr","gl","he","hi","hr","hu","id","it","ja","ka","km","kn","ko","lv","ml","mr","my","nb","ne","nl","nn","or","pl","pt-PT","pt-BR","ro","ru","si","sk","sl","sr","sv","ta","te","th","tr","uk","vi","zh-CN","zh-TW"];var s=function(e,t,n,o){return new(n||(n=Promise))(function(a,s){function i(e){try{l(o.next(e))}catch(t){s(t)}}function r(e){try{l(o.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((o=o.apply(e,t||[])).next())})};class i extends o{constructor(e,t){super(e||"en-US",t,e=>s(this,void 0,void 0,function*(){const t=this.localesDirectory+"/"+e+"/messages.json?cache=r5ktz",n=yield fetch(t);return yield n.json()})),this.supportedTranslationLocales=a}get translationLocale(){return this._translationLocale}set translationLocale(e){this._translationLocale=e}}var r=function(e,t,n,o){return new(n||(n=Promise))(function(a,s){function i(e){try{l(o.next(e))}catch(t){s(t)}}function r(e){try{l(o.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((o=o.apply(e,t||[])).next())})};let l=null;function c(e){var t;const n=document.getElementById("content");if(!n)throw new Error("content element not found");n.className="tw-text-center",n.innerHTML="";const o=document.createElement("h1"),a=document.createElement("p");if(!l)throw new Error("localeService is not initialized");if(o.textContent=l.t("youSuccessfullyLoggedIn"),a.textContent="web"==e?l.t("thisWindowWillCloseIn5Seconds"):l.t("youMayCloseThisWindow"),o.className="tw-font-medium",a.className="tw-mb-4",n.appendChild(o),n.appendChild(a),"web"==e){const e=document.createElement("button");if(e.textContent=l.t("close"),e.className="tw-bg-primary-600 hover:tw-bg-primary-700 tw-text-contrast tw-px-4 tw-py-2 tw-rounded-md tw-transition tw-border-transparent tw-text-center focus:tw-outline-none",e.addEventListener("click",()=>{window.close()}),n.appendChild(e),null===a.textContent)throw new Error("count down container is null");const o=(null===(t=a.textContent.match(/\d+/))||void 0===t?void 0:t[0])||null;if(!o)throw new Error("count down time cannot be null");let s=Number(o);const i=setInterval(()=>{if(s>1){if(null===a.textContent)throw new Error("count down container is null");a.textContent=a.textContent.replace(String(s),String(s-1)),s--}else clearInterval(i),window.close()},1e3)}}window.addEventListener("load",()=>r(void 0,void 0,void 0,function*(){const n=e("duoFramelessUrl");if(n)return void function(e){const t=/^api-[a-zA-Z0-9]+\.(duosecurity|duofederal)\.com$/,n=new URL(e);if(n.username||n.password)throw new Error("Invalid redirect URL: embedded credentials not allowed");if("https:"!==n.protocol)throw new Error("Invalid redirect URL: invalid protocol");if(n.port&&"443"!==n.port)throw new Error("Invalid redirect URL: port not allowed");if("/oauth/v1/authorize"!==n.pathname)throw new Error("Invalid redirect URL: invalid pathname");if(!t.test(n.hostname))throw new Error("Invalid redirect URL");window.location.href=e}(n);const o=e("client"),a=e("code"),s=e("state");if(!o)throw new Error("client is null");if(!a)throw new Error("code is null");if(!s)throw new Error("state is null");if(l=new i(navigator.language,"locales"),yield l.init(),"web"===o){const e=new BroadcastChannel("duoResult");e.postMessage({code:a,state:s}),e.close(),c(o)}else"browser"===o?(window.postMessage({command:"duoResult",code:a,state:s},window.location.origin),c(o)):"mobile"===o?document.location.replace(t("duo")+"?code="+encodeURIComponent(a)+"&state="+encodeURIComponent(s)):"desktop"===o&&(c(o),document.location.replace("bitwarden://duo-callback?code="+encodeURIComponent(a)+"&state="+encodeURIComponent(s)))}))})(); //# sourceMappingURL=duo-redirect.49480b58af3f78165050.js.map