|  |  |  | @ -1,17 +1,20 @@ | 
		
	
		
			
				|  |  |  |  | export function normalizeUserIdentifier(input: string): string { | 
		
	
		
			
				|  |  |  |  |   console.log('Normalizing user identifier:', input); | 
		
	
		
			
				|  |  |  |  |    | 
		
	
		
			
				|  |  |  |  |   // Handle JID format (12345678@s.whatsapp.net)
 | 
		
	
		
			
				|  |  |  |  |   // Handle group JID format (120363418564126395@g.us)
 | 
		
	
		
			
				|  |  |  |  |   if (input.endsWith('@g.us')) { | 
		
	
		
			
				|  |  |  |  |     return input; // Return group JID as-is
 | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  |    | 
		
	
		
			
				|  |  |  |  |   // Handle user JID format (12345678@s.whatsapp.net)
 | 
		
	
		
			
				|  |  |  |  |   if (input.includes('@s.whatsapp.net')) { | 
		
	
		
			
				|  |  |  |  |     const [phone, domain] = input.split('@'); | 
		
	
		
			
				|  |  |  |  |     const cleanPhone = phone.replace(/\D/g, ''); | 
		
	
		
			
				|  |  |  |  |     return `${cleanPhone}@${domain}`; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   // Remove @ prefix if present
 | 
		
	
		
			
				|  |  |  |  |   // Handle raw input (phone number or @mention)
 | 
		
	
		
			
				|  |  |  |  |   const cleanInput = input.startsWith('@') ? input.slice(1) : input; | 
		
	
		
			
				|  |  |  |  |    | 
		
	
		
			
				|  |  |  |  |   // Remove any non-numeric characters
 | 
		
	
		
			
				|  |  |  |  |   const phoneNumber = cleanInput.replace(/\D/g, ''); | 
		
	
		
			
				|  |  |  |  |    | 
		
	
		
			
				|  |  |  |  |   // Validate phone number length
 | 
		
	
	
		
			
				
					|  |  |  | 
 |