import{_ as B,T as R,aH as x,G as I,I as Z,k as z,U as P,S as E,r as g,o as n,b as a,O as A,W as V,l as f,w as h,p as l,n as y,v as d,a as C,q as _,u as L,aC as O,F as v,e as S,h as G}from"./main-DtyiNRRn.js";import{a as J}from"./fieldTransformations-DY2-qceq.js";const j={name:"CountrySelectionListFi",components:{TextInputFi:R,CountryFlagFi:x,GridContainerFi:I,IconFi:Z},mixins:[z],inject:["fields"],props:{countriesFilter:{type:String,default:null},countryUrlKey:{type:String,default:null},redirectLayer:{type:Boolean,default:!1}},data(){return{countryData:null,filteredCountryData:null,search:"",mobileSearchActivated:!1,showRedirectLayer:!1,activeCountry:null,isMounted:!1}},computed:{title(){return this.$dict.get("global-Labels.Country-Selection.Title")},subtitle(){return this.$dict.get("global-Labels.Country-Selection.Subtitle")},description(){return this.$dict.get("global-Labels.Country-Selection.Description")},countryList(){return this.filteredCountryData||this.countryData},continents(){var e,t;return(t=(e=this.countryList)==null?void 0:e.continents)==null?void 0:t.continents},showNoCountryFoundHint(){var e;return(e=this.filteredCountryData)==null?void 0:e.continents.continents.every(t=>{var i;return!t.countries||((i=t.countries)==null?void 0:i.length)===0})}},mounted(){this.isMounted=!0},async created(){return this.fetchCountries()},serverPrefetch(){return this.fetchCountries()},methods:{getPreparedPlaceholderValue:J,getApi(){return"/api/i18n/countries"},async fetchCountries(){if(!this.countryData)try{const e=this.getApi(),t={language:this.$fischer.siteLanguage()},{data:i}=await P.get(e,{params:t});this.countryData=i}catch(e){console.error(e),E(e)}},countryUrl(e,t){var i,m,o;return this.countryUrlKey&&((i=e[this.countryUrlKey])!=null&&i.url)?(m=e[this.countryUrlKey])==null?void 0:m.url:`${(o=e.link)==null?void 0:o.url}/${t.iso_Code.toLowerCase()}`},filteredCountries(e){return this.countriesFilter?e==null?void 0:e.filter(t=>{var i;return(i=t[this.countriesFilter])==null?void 0:i.url}):e},filterCountries(){this.filteredCountryData=JSON.parse(JSON.stringify(this.countryData)),this.filteredCountryData.continents.continents.forEach(e=>{var t;e.countries=(t=e.countries)==null?void 0:t.filter(i=>i.displayName.toLowerCase().includes(this.search.toLowerCase())||i.title.toLowerCase().includes(this.search.toLowerCase())||i.localizations.some(m=>m.name.toLowerCase().includes(this.search.toLowerCase())))})},change(){this.filterCountries()},onCountryClick(e){this.activeCountry=e,this.showRedirectLayer=!0},closeRedirectLayer(){this.showRedirectLayer=!1},redirectToCountry(){var t,i;let e=(t=this.activeCountry.link)==null?void 0:t.url;this.countryUrlKey&&((i=this.activeCountry[this.countryUrlKey])!=null&&i.url)&&(e=this.activeCountry[this.countryUrlKey].url),window.location.href=e}}},q={class:"country-selection-list-fi"},W={class:"country-selection-list-fi__search-container"},Q={class:"country-selection-list-fi__search-title"},X={class:"country-selection-list-fi__search-input-wrapper"},Y=["innerHTML"],$={class:"country-selection-list-fi__container"},ee={ref:"continents",class:"country-selection-list-fi__list"},te={class:"country-selection-list-fi__continent-header"},ie={key:0,class:"country-selection-list-fi__list-title"},se={class:"country-selection-list-fi__redirect-content"},re={class:"country-selection-list-fi__redirect-text-content"},ne={class:"country-selection-list-fi__redirect-headline"},le=["innerHTML"],oe={class:"country-selection-list-fi__redirect-controls"},ce={class:"country-selection-list-fi__redirect-disagree"},ae={class:"country-selection-list-fi__redirect-agree"};function ue(e,t,i,m,o,r){var F,U;const H=g("text-input-fi"),w=g("icon-fi"),p=g("grid-container-fi"),K=g("country-flag-fi"),D=g("button-fi");return n(),a("div",q,[A(f(p,null,{default:h(()=>[l("div",W,[l("div",{class:y({"country-selection-list-fi__search":!0,"country-selection-list-fi__search--mobile-search-activated":o.mobileSearchActivated&&!e.isSM})},[l("span",Q,d(e.$dict.get("global-Labels.Country-Selection.Search-Title")),1),l("span",X,[f(H,{ref:"country-search",modelValue:o.search,"onUpdate:modelValue":[t[0]||(t[0]=c=>o.search=c),r.change],modelModifiers:{trim:!0},name:"country-search",class:"country-selection-list-fi__search-input",label:e.$dict.get("global-Labels.Country-Selection.Search-Input-Label"),icon:o.mobileSearchActivated&&!e.isSM?"close":"search",clear:!0,type:"search",large:e.isSM,"data-test":"country-search-input",onIconClicked:t[1]||(t[1]=c=>o.mobileSearchActivated=!1)},null,8,["modelValue","label","icon","large","onUpdate:modelValue"]),o.mobileSearchActivated?_("",!0):(n(),C(w,{key:0,icon:"search",class:"country-selection-list-fi__search-icon-mobile",onClick:t[2]||(t[2]=c=>o.mobileSearchActivated=!o.mobileSearchActivated)}))])],2),A(l("div",{class:"country-selection-list-fi__no-result",innerHTML:e.$dict.get("global-Labels.Country-Selection.Search-No-Results",["<span id='search-term'></span>"])},null,8,Y),[[V,r.showNoCountryFoundHint]]),o.isMounted?(n(),C(O,{key:0,to:"#search-term"},[L(d(o.search),1)])):_("",!0)])]),_:1},512),[[V,(F=r.continents)==null?void 0:F.length]]),(U=r.continents)!=null&&U.length&&!r.showNoCountryFoundHint?(n(),C(p,{key:0},{default:h(()=>[l("div",$,[l("ul",ee,[(n(!0),a(v,null,S(r.continents,(c,b)=>{var u;return n(),a(v,{key:c.displayName},[((u=r.filteredCountries(c.countries))==null?void 0:u.length)>0?(n(),a("li",{key:0,class:y(["country-selection-list-fi__continent-container",b<r.continents.length-1?"lg:fi-col-span-12":"lg:fi-col-span-6"])},[l("div",te,d(c.displayName),1),f(p,{container:!1},{default:h(()=>[(n(!0),a(v,null,S(r.filteredCountries(c.countries),s=>{var N,M,T;return n(),a("div",{key:s.displayName,class:"country-selection-list-fi__continent-wrapper"},[s!=null&&s.value&&s.value!=="en-ZZ"?(n(),C(K,{key:0,country:s.value.toLowerCase(),class:"country-selection-list-fi__icon"},null,8,["country"])):(n(),C(w,{key:1,size:"0_8",icon:"globe",class:"country-selection-list-fi__icon country-selection-list-fi__icon--svg"})),s.value!=="en-ZZ"?(n(),a(v,{key:2},[s!=null&&s.title?(n(),a("span",ie," fischer "+d(s.title),1)):_("",!0),t[3]||(t[3]=l("br",{class:"country-selection-list-fi__break"},null,-1))],64)):_("",!0),(N=s==null?void 0:s.localizations)!=null&&N.length&&(i.countryUrlKey?(M=s[i.countryUrlKey])!=null&&M.url:(T=s.link)!=null&&T.url)?(n(),a("span",{key:3,class:y({"country-selection-list-fi__languages":!0,"country-selection-list-fi__languages--international":s.value==="en-ZZ"})},[(n(!0),a(v,null,S(s.localizations,k=>(n(),C(G(i.redirectLayer?"span":"a"),{key:k.title,href:i.redirectLayer?null:r.countryUrl(s,k),class:y({"country-selection-list-fi__url":!0,"country-selection-list-fi__url--redirect":i.redirectLayer}),onClick:de=>r.onCountryClick(s)},{default:h(()=>[L(d(k.name),1)]),_:2},1032,["href","class","onClick"]))),128))],2)):_("",!0)])}),128))]),_:2},1024)],2)):_("",!0)],64)}),128))],512)])]),_:1})):_("",!0),i.redirectLayer?(n(),a("div",{key:1,class:y({"country-selection-list-fi__redirect-layer":!0,"country-selection-list-fi__redirect-layer--active":o.showRedirectLayer})},[f(p,null,{default:h(()=>{var c,b;return[l("div",se,[l("div",re,[l("div",ne,d((c=r.fields.redirectLayerHeadline)==null?void 0:c.value),1),l("div",{class:"country-selection-list-fi__redirect-description",innerHTML:r.getPreparedPlaceholderValue(r.fields,"redirectLayerDescription",(b=o.activeCountry)==null?void 0:b.title)},null,8,le)]),l("div",oe,[l("div",ce,[f(D,{class:y({"button-fi__tertiary button-fi__xs-streched":!0,"button-fi--large":e.isSM}),type:"button",onClick:r.closeRedirectLayer},{default:h(()=>{var u;return[L(d((u=r.fields.redirectLayerBtnDisagree)==null?void 0:u.value),1)]}),_:1},8,["class","onClick"])]),l("div",ae,[f(D,{class:y({"button-fi__primary button-fi__xs-streched":!0,"button-fi--large":e.isSM}),type:"button",onClick:r.redirectToCountry},{default:h(()=>{var u;return[L(d((u=r.fields.redirectLayerBtnAgree)==null?void 0:u.value),1)]}),_:1},8,["class","onClick"])])])])]}),_:1})],2)):_("",!0)])}const ye=B(j,[["render",ue],["__scopeId","data-v-73208981"]]);export{ye as C};