| 
									
										
										
										
											2025-09-20 11:42:22 +00:00
										 |  |  | import { domtools } from '@design.estate/dees-element'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class PdfManager { | 
					
						
							|  |  |  |   private static pdfjsLib: any; | 
					
						
							|  |  |  |   private static initialized = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public static async initialize() { | 
					
						
							|  |  |  |     if (this.initialized) return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // @ts-ignore
 | 
					
						
							|  |  |  |     this.pdfjsLib = await import('https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/+esm'); | 
					
						
							|  |  |  |     this.pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@4.0.379/build/pdf.worker.mjs'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.initialized = true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public static async loadDocument(url: string): Promise<any> { | 
					
						
							|  |  |  |     await this.initialize(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-20 21:28:43 +00:00
										 |  |  |     // IMPORTANT: Disabled caching to ensure component isolation
 | 
					
						
							|  |  |  |     // Each viewer instance gets its own document to prevent state sharing
 | 
					
						
							|  |  |  |     // This fixes issues where multiple viewers interfere with each other
 | 
					
						
							| 
									
										
										
										
											2025-09-20 11:42:22 +00:00
										 |  |  |     const loadingTask = this.pdfjsLib.getDocument(url); | 
					
						
							|  |  |  |     const document = await loadingTask.promise; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return document; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-20 21:28:43 +00:00
										 |  |  |   public static releaseDocument(_url: string) { | 
					
						
							|  |  |  |     // No-op since we're not caching documents anymore
 | 
					
						
							|  |  |  |     // Each viewer manages its own document lifecycle
 | 
					
						
							| 
									
										
										
										
											2025-09-20 11:42:22 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-20 21:28:43 +00:00
										 |  |  |   // Cache methods removed to ensure component isolation
 | 
					
						
							|  |  |  |   // Each viewer now manages its own document lifecycle
 | 
					
						
							|  |  |  | } |