@ -2,38 +2,53 @@ 
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					import  {  register  }  from  "register-service-worker" ;  
					 
					 
					import  {  register  }  from  "register-service-worker" ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					// Only register service worker if explicitly enabled and in production
  
					 
					 
					// Add debug logging for environment variables
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					console . log ( '[ServiceWorker] Environment variables:' ,  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  VITE_PWA_ENABLED : process.env.VITE_PWA_ENABLED ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  NODE_ENV : process.env.NODE_ENV ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  BASE_URL : process.env.BASE_URL ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  CAN_REGISTER : process.env.VITE_PWA_ENABLED  ===  "true"  &&  process . env . NODE_ENV  ===  "production"  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					} ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					// Modified condition to handle both string and boolean true
  
				
			 
			
		
	
		
		
			
				
					 
					 
					if  (  
					 
					 
					if  (  
				
			 
			
		
	
		
		
			
				
					 
					 
					  process . env . VITE_PWA_ENABLED  ===  "true"  &&  
					 
					 
					  process . env . VITE_PWA_ENABLED  ===  "true"  &&  
				
			 
			
		
	
		
		
			
				
					 
					 
					  process . env . NODE_ENV  ===  "production"  
					 
					 
					  process . env . NODE_ENV  ===  "production"  
				
			 
			
		
	
		
		
			
				
					 
					 
					)  {  
					 
					 
					)  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					  register ( ` ${ process . env . BASE_URL } sw.js ` ,  {  
					 
					 
					  console . log ( '[ServiceWorker] Attempting to register service worker...' ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  // Use '/' as fallback if BASE_URL is undefined
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  const  baseUrl  =  process . env . BASE_URL  ||  '/' ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					  register ( ` ${ baseUrl } sw.js ` ,  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					    ready() {  
					 
					 
					    ready() {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      console . log ( "Service worker is active." ) ;  
					 
					 
					      console . log ( "[ServiceWorker]  Service worker is active." ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    registered() {  
					 
					 
					    registered ( registration )   {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      console . log ( "Service worker has been registered."  ) ;  
					 
					 
					      console . log ( "[ServiceWorker] Service worker has been registered:" ,  registration  ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    cached() {  
					 
					 
					    cached ( registration )   {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      console . log ( "Content has been cached for offline use."  ) ;  
					 
					 
					      console . log ( "[ServiceWorker] Content has been cached for offline use:" ,  registration  ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    updatefound() {  
					 
					 
					    updatefound ( registration )   {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      console . log ( "New content is downloading."  ) ;  
					 
					 
					      console . log ( "[ServiceWorker] New content is downloading:" ,  registration  ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    updated() {  
					 
					 
					    updated ( registration )   {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					      console . log ( "New content is available; please refresh."  ) ;  
					 
					 
					      console . log ( "[ServiceWorker] New content is available:" ,  registration  ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    offline() {  
					 
					 
					    offline() {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      console . log (  
					 
					 
					      console . log ( "[ServiceWorker] No internet connection found. App is running in offline mode." ) ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					 
					 
					        "No internet connection found. App is running in offline mode." ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					      ) ;  
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					    error ( error )  {  
					 
					 
					    error ( error )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      console . error ( "Error during service worker registration:" ,  error ) ;  
					 
					 
					      console . error ( "[ServiceWorker]  Error during service worker registration:" ,  error ) ;  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					    } ,  
					 
					 
					    } ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					  } ) ;  
					 
					 
					  } ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  else  {  
					 
					 
					}  else  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					  console . log (  
					 
					 
					  console . log (  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    "Service worker registration skipped - not enabled or not in production" ,  
					 
					 
					    "[ServiceWorker] Registration skipped:" ,  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      enabled : process.env.VITE_PWA_ENABLED  ===  "true" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      production : process.env.NODE_ENV  ===  "production" ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      value : process.env.VITE_PWA_ENABLED ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      type :  typeof  process . env . VITE_PWA_ENABLED  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					 
					 
					  ) ;  
					 
					 
					  ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  
					 
					 
					}