import{d as C,r as u,c as _,o as B,V as z,y as n,A as r,k,K as l,z as y,N as D,G as N,J as h,F as V,I as E,u as I,B as o,D as S}from"./vendor-vue-CcL5gLKJ.js";import{G as b,_ as x,H as F,d as G}from"./index-96Zm5C3V.js";import{u as O}from"./vendor-i18n-xZjp_O9P.js";/* empty css                                                                       */const R=["disabled","title"],U={class:"text-base"},$={class:"hidden sm:inline"},A={key:0,class:"absolute right-0 z-50 mt-1 w-32 overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-dark-700 dark:bg-dark-800"},H=["disabled","onClick"],J={class:"text-base"},K=C({__name:"LocaleSwitcher",setup(M){const{locale:m}=O(),e=u(!1),c=u(null),s=u(!1),i=_(()=>m.value),d=_(()=>b.find(a=>a.code===m.value));function w(){e.value=!e.value}async function L(a){if(s.value||a===i.value){e.value=!1;return}s.value=!0;try{await F(a),e.value=!1}finally{s.value=!1}}function f(a){c.value&&!c.value.contains(a.target)&&(e.value=!1)}return B(()=>{document.addEventListener("click",f)}),z(()=>{document.removeEventListener("click",f)}),(a,T)=>{var v,p,g;return o(),n("div",{class:"relative",ref_key:"dropdownRef",ref:c},[r("button",{onClick:w,disabled:s.value,class:"flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-dark-700",title:(v=d.value)==null?void 0:v.name},[r("span",U,l((p=d.value)==null?void 0:p.flag),1),r("span",$,l((g=d.value)==null?void 0:g.code.toUpperCase()),1),k(x,{name:"chevronDown",size:"xs",class:y(["text-gray-400 transition-transform duration-200",{"rotate-180":e.value}])},null,8,["class"])],8,R),k(D,{name:"dropdown"},{default:N(()=>[e.value?(o(),n("div",A,[(o(!0),n(V,null,E(I(b),t=>(o(),n("button",{key:t.code,disabled:s.value,onClick:j=>L(t.code),class:y(["flex w-full items-center gap-2 px-3 py-2 text-sm text-gray-700 transition-colors hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-dark-700",{"bg-primary-50 text-primary-600 dark:bg-primary-900/20 dark:text-primary-400":t.code===i.value}])},[r("span",J,l(t.flag),1),r("span",null,l(t.name),1),t.code===i.value?(o(),S(x,{key:0,name:"check",size:"sm",class:"ml-auto text-primary-500"})):h("",!0)],10,H))),128))])):h("",!0)]),_:1})],512)}}}),X=G(K,[["__scopeId","data-v-62fd3b7c"]]);export{X as L};
