import { modalManager } from './ModalManager.js'; import { showToast } from '../utils/uiHelpers.js'; import { LoadingManager } from './LoadingManager.js'; import { state } from '../state/index.js'; import { resetAndReload } from '../api/loraApi.js'; export class ImportManager { constructor() { this.recipeImage = null; this.recipeData = null; this.recipeName = ''; this.recipeTags = []; this.missingLoras = []; // Add initialization check this.initialized = false; this.selectedFolder = ''; // Add LoadingManager instance this.loadingManager = new LoadingManager(); this.folderClickHandler = null; this.updateTargetPath = this.updateTargetPath.bind(this); } showImportModal() { console.log('Showing import modal...'); if (!this.initialized) { // Check if modal exists const modal = document.getElementById('importModal'); if (!modal) { console.error('Import modal element not found'); return; } this.initialized = true; } modalManager.showModal('importModal', null, () => { // Cleanup handler when modal closes this.cleanupFolderBrowser(); }); this.resetSteps(); } resetSteps() { document.querySelectorAll('.import-step').forEach(step => step.style.display = 'none'); document.getElementById('uploadStep').style.display = 'block'; // Reset file input const fileInput = document.getElementById('recipeImageUpload'); if (fileInput) { fileInput.value = ''; } // Reset error message const errorElement = document.getElementById('uploadError'); if (errorElement) { errorElement.textContent = ''; } // Reset preview const previewElement = document.getElementById('imagePreview'); if (previewElement) { previewElement.innerHTML = '