import{a as h}from"./chunk-HQVZGJHJ.js";import{B as d,j as s}from"./chunk-BJ2UHOXD.js";import{i as u}from"./chunk-E56JCP42.js";import{a as p}from"./chunk-QF2OXJMJ.js";import{C as f,b as m}from"./chunk-3T7NQNCJ.js";import{ub as o}from"./chunk-SGK554CS.js";import{e as l,hc as g,j as a}from"./chunk-YR2ZOLW3.js";import{Y as c}from"./chunk-VI2VOVRS.js";var P=(()=>{class n{constructor(r,e,t,i,v){this.botsService=r,this.langService=e,this.translateService=t,this.configService=i,this._document=v}cleanAlternateLangContent(){this._document.querySelectorAll('[id^="alternate-lang"]').forEach(e=>e.remove())}doForEveryAvailableLanguage(r){this.botsService.isBot()&&this.langService.getLanguages().pipe(c()).subscribe(e=>{e.filter(t=>t.id!==this.translateService.currentLang).forEach(t=>{r(t.id)})})}replaceUrlWithLanguage(r,e){let t=new URL(r),i=t.pathname.replace("/","").split("/");return i[0]=e,t.pathname=i.join("/"),t.toString()}setAlternateLangContent(r,e){let t=this.createIsoCode(e),i=this._document.createElement("link");i.setAttribute("id",`alternate-lang-${t}`),i.setAttribute("rel","alternate"),i.setAttribute("href",this.adapterHref(r)),i.setAttribute("hreflang",t),this._document.head.appendChild(i)}adapterHref(r){let e=new URL(r),t=d.getPageFromURL(r);return e.searchParams.delete(o.page),e.search=t&&t>1?`${o.page}=${t}`:"",e.toString()}createIsoCode(r){let e=r===s.vl?s.ca:r;return this.configService.isEnabledHrefLangRegion()?h.transformLanguageIdIntoIsoCode(e,this.configService.getDefaultCountryId()):e}static{this.\u0275fac=function(e){return new(e||n)(a(p),a(u),a(m),a(f),a(g))}}static{this.\u0275prov=l({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();export{P as a};