import{c as f}from"./chunk-ZMR6MHQ3.js";import{k as i}from"./chunk-QBEVFUYY.js";import{Ba as d,Sc as p,Z as l,ca as n,ua as u,xa as c}from"./chunk-QXTL7CSW.js";var L=class o{translocoService=n(f);platformId=n(c);request=n(p,{optional:!0});languages=[{code:"en",label:"toolbar.language.english",flagClass:"flag--us"},{code:"es",label:"toolbar.language.spanish",flagClass:"flag--es"},{code:"pt-BR",label:"toolbar.language.portuguese",flagClass:"flag--br"}];currentLanguage=u(this.getInitialLanguage());constructor(){d(()=>{let e=this.currentLanguage();this.translocoService.setActiveLang(e),i(this.platformId)&&(localStorage.setItem("app-language",e),document.cookie=`app-language=${e};path=/;max-age=31536000;SameSite=Lax`)})}setLanguage(e){this.currentLanguage.set(e)}getInitialLanguage(){if(!i(this.platformId)){let r=(this.request?.headers?.cookie||"").split("; ").find(s=>s.startsWith("app-language="))?.split("=")[1];return r&&this.languages.find(s=>s.code===r)?r:"en"}let e=document.cookie.split("; ").find(a=>a.startsWith("app-language="))?.split("=")[1];if(e&&this.languages.find(a=>a.code===e))return e;let t=localStorage.getItem("app-language");if(t&&this.languages.find(a=>a.code===t))return t;let g=navigator.language.split("-")[0];return g==="pt"?"pt-BR":this.languages.find(a=>a.code===g)?g:"en"}static \u0275fac=function(t){return new(t||o)};static \u0275prov=l({token:o,factory:o.\u0275fac,providedIn:"root"})};export{L as a};
