import{_ as T}from"./BdjjM40W.js";import{v as Z,r as N,n as U,_ as E}from"./BmsEUx_s.js";import{_ as G}from"./BVhh3E6B.js";import{k as H,ag as M,a as u,b as y,G as O,M as P,Q as f,I as $,O as Q,u as v,z as w,a3 as W}from"./BO9AmBA3.js";const j={class:"relative flex-col flex bg-white p-8 mt-4"},q="max-w-[20rem]",X=H({__name:"LayoutHeaderShopSelect",props:{controller:{}},setup(x){const _=x,{controller:B}=M(_),{getCurrentSalesChannel:R,getCurrentLanguage:k,salesChannels:z}=Z(),r=R(),d=k(),g=[...z].filter(t=>t.displayInRegionSelector||t.id===r.id),m=u(r),p=u(r==null?void 0:r.id),s=u(r==null?void 0:r.languages),o=u(d),c=u(d==null?void 0:d.name),{startLoading:A}=N();y(p,(t,l)=>{var i,a;const e=[...g].find(n=>n.id===t);e&&e.region!=="Region"&&(m.value=e,e.languages.length===1?(o.value=e.languages[0],c.value=e.languages[0].name,s.value=[o.value]):(s.value=[...(i=m==null?void 0:m.value)==null?void 0:i.languages],o.value=(a=s==null?void 0:s.value)==null?void 0:a.find(n=>n.name===(c==null?void 0:c.value))))}),y(c,(t,l)=>{var e;o.value=(e=s==null?void 0:s.value)==null?void 0:e.find(i=>i.name===t)});const I=async()=>{var n,b,h,V;const{pathname:t,origin:l}=location,e=(n=t==null?void 0:t.replace(/^\/[a-zA-Z]{2}-[a-zA-Z]{2}(?![a-zA-Z])/,""))==null?void 0:n.replace(/\/\//,""),i=t.includes("account");let a="";(b=o==null?void 0:o.value)!=null&&b.path.length?i?a=`${l}/${(h=o==null?void 0:o.value)==null?void 0:h.path}`:a=`${l}/${(V=o==null?void 0:o.value)==null?void 0:V.path}${e}`:e.length?i?a=l:a=`${l}${e}`:a=l,B.value.close(),A(),U(a,{external:!0,replace:!0})};return(t,l)=>{const e=T,i=E,a=G;return O(),P("div",null,[f(a,{controller:_.controller,"custom-width":q,side:"right"},{default:$(()=>[Q("div",j,[f(e,{modelValue:v(p),"onUpdate:modelValue":l[0]||(l[0]=n=>w(p)?p.value=n:null),name:"ytind-saleschannel-select",id:"ytind-saleschannel-select",class:"py-0.5 mb-4 bg-white headline-3 border-b cursor-pointer",theme:"transparent",options:v(g),"value-field":"id","label-field":"region"},null,8,["modelValue","options"]),f(e,{modelValue:v(c),"onUpdate:modelValue":l[1]||(l[1]=n=>w(c)?c.value=n:null),name:"ytind-language-select",id:"ytind-language-select",class:"py-0.5 mb-2 bg-white headline-3 border-b cursor-pointer",theme:"transparent",options:v(s),"value-field":"name","label-field":"name"},null,8,["modelValue","options"]),f(i,{theme:"white",class:"mt-10",onClick:I},{default:$(()=>[W("Let's Roll")]),_:1})])]),_:1},8,["controller"])])}}});export{X as _};