import{r as e}from"./rolldown-runtime-CpWojdLp.js";import{n as t,r as n,t as r}from"./jsx-runtime-BrKkGzFB.js";import{t as i}from"./utils--B3oMbdy.js";import{O as a}from"./app-KzKSswgw.js";import{n as o}from"./countries-B5kGBc6Z.js";var s=t(),c=e(n(),1),l=r();function u(e,t){let n=o(t),r=(e??``).trim();if(t===`OTHER`){let[,e=``,t=``]=r.match(/^(\+\d+)\s*(.*)$/)??[];return{manualCode:e,phoneNumber:t}}return n&&r.startsWith(n)?{manualCode:n,phoneNumber:r.slice(n.length).trim()}:{manualCode:n,phoneNumber:r}}function d(e){let t=(0,s.c)(30),{country:n,defaultValue:r,id:d,tabIndex:f,className:p}=e,m=r===void 0?``:r,h=d===void 0?`contact_number`:d,g;t[0]!==n||t[1]!==m?(g=u(m,n),t[0]=n,t[1]=m,t[2]=g):g=t[2];let _=g,[v,y]=(0,c.useState)(_.manualCode),[b,x]=(0,c.useState)(_.phoneNumber),S;t[3]!==n||t[4]!==v?(S=n===`OTHER`?v:o(n),t[3]=n,t[4]=v,t[5]=S):S=t[5];let C=S,w;t[6]!==C||t[7]!==b?(w=[C,b].filter(Boolean),t[6]=C,t[7]=b,t[8]=w):w=t[8];let T=w.join(` `),E;t[9]===T?E=t[10]:(E=T.trim(),t[9]=T,t[10]=E);let D=E,O;t[11]===p?O=t[12]:(O=i(`flex gap-2`,p),t[11]=p,t[12]=O);let k;t[13]===D?k=t[14]:(k=(0,l.jsx)(`input`,{name:`contact_number`,readOnly:!0,type:`hidden`,value:D}),t[13]=D,t[14]=k);let A;t[15]!==C||t[16]!==n||t[17]!==v||t[18]!==f?(A=n===`OTHER`?(0,l.jsx)(a,{"aria-label":`Código de país`,className:`w-28`,inputMode:`tel`,onChange:e=>y(e.target.value),placeholder:`+000`,required:!0,tabIndex:f,type:`tel`,value:v}):(0,l.jsx)(`div`,{className:`flex h-9 min-w-20 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground`,children:C||`+000`}),t[15]=C,t[16]=n,t[17]=v,t[18]=f,t[19]=A):A=t[19];let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>x(e.target.value),t[20]=j):j=t[20];let M=n===`OTHER`?void 0:f,N;t[21]!==h||t[22]!==b||t[23]!==M?(N=(0,l.jsx)(a,{id:h,autoComplete:`tel-national`,className:`flex-1`,inputMode:`tel`,onChange:j,placeholder:`Número de contacto`,required:!0,tabIndex:M,type:`tel`,value:b}),t[21]=h,t[22]=b,t[23]=M,t[24]=N):N=t[24];let P;return t[25]!==A||t[26]!==N||t[27]!==O||t[28]!==k?(P=(0,l.jsxs)(`div`,{className:O,children:[k,A,N]}),t[25]=A,t[26]=N,t[27]=O,t[28]=k,t[29]=P):P=t[29],P}export{d as t};