import { useState } from 'react';

interface UseApplicationDetailsUIStateParams {
  currentUser: any;
  initialTab?: string;
}

export function useApplicationDetailsUIState({ initialTab = 'questionnaire' }: UseApplicationDetailsUIStateParams) {
  const [showFirmTypeModal, setShowFirmTypeModal] = useState(false);
  const [updatingFirmType, setUpdatingFirmType] = useState(false);
  const [tempFirmType, setTempFirmType] = useState('');
  const [activeTab, setActiveTab] = useState(initialTab);
  const [showApproveModal, setShowApproveModal] = useState(false);
  const [showOnboardModal, setShowOnboardModal] = useState(false);
  const [isOnboarding, setIsOnboarding] = useState(false);
  const [showRejectModal, setShowRejectModal] = useState(false);
  const [rejectionReason, setRejectionReason] = useState('');
  const [scheduledInterviewParticipants, setScheduledInterviewParticipants] = useState<any[]>([]);
  const [showScheduleModal, setShowScheduleModal] = useState(false);
  const [showCancelInterviewModal, setShowCancelInterviewModal] = useState(false);
  const [interviewIdToCancel, setInterviewIdToCancel] = useState('');
  const [interviewToReschedule, setInterviewToReschedule] = useState<any>(null);
  const [showKTMatrixModal, setShowKTMatrixModal] = useState(false);
  const [showLevel2FeedbackModal, setShowLevel2FeedbackModal] = useState(false);
  const [showLevel3FeedbackModal, setShowLevel3FeedbackModal] = useState(false);
  const [showDocumentsModal, setShowDocumentsModal] = useState(false);
  const [showAssignModal, setShowAssignModal] = useState(false);
  const [selectedStage, setSelectedStage] = useState<string | null>(null);
  const [interviewMode, setInterviewMode] = useState('virtual');
  const [approvalRemark, setApprovalRemark] = useState('');
  const [expandedBranches, setExpandedBranches] = useState<Record<string, boolean>>({});
  const [users, setUsers] = useState<any[]>([]);
  const [selectedUser, setSelectedUser] = useState('');
  const [participantType, setParticipantType] = useState('contributor');
  const [interviewDate, setInterviewDate] = useState('');
  const [interviewType, setInterviewType] = useState('level1');
  const [meetingLink, setMeetingLink] = useState('');
  const [location, setLocation] = useState('');
  const [showUploadForm, setShowUploadForm] = useState(false);
  const [uploadFile, setUploadFile] = useState<File | null>(null);
  const [uploadDocType, setUploadDocType] = useState('');
  const [approvalFile, setApprovalFile] = useState<File | null>(null);
  const [isUploading, setIsUploading] = useState(false);
  const [previewDoc, setPreviewDoc] = useState<any>(null);
  const [showPreviewModal, setShowPreviewModal] = useState(false);
  const [selectedInterviewerId, setSelectedInterviewerId] = useState('');
  const [isEditingStatutory, setIsEditingStatutory] = useState(false);
  const [statutoryForm, setStatutoryForm] = useState<any>({});
  const [isSavingStatutory, setIsSavingStatutory] = useState(false);
  const [interviews, setInterviews] = useState<any[]>([]);
  const [isScheduling, setIsScheduling] = useState(false);
  const [isCancellingInterview, setIsCancellingInterview] = useState(false);
  const [showAssignArchitectureModal, setShowAssignArchitectureModal] = useState(false);
  const [architectureLeadId, setArchitectureLeadId] = useState('');
  const [isAssigningArchitecture, setIsAssigningArchitecture] = useState(false);
  const [showArchitectureStatusModal, setShowArchitectureStatusModal] = useState(false);
  const [architectureStatus, setArchitectureStatus] = useState('');
  const [architectureRemarks, setArchitectureRemarks] = useState('');
  const [isUpdatingArchitecture, setIsUpdatingArchitecture] = useState(false);
  const [isAssigningParticipant, setIsAssigningParticipant] = useState(false);
  const [documentConfigs, setDocumentConfigs] = useState<any[]>([]);
  const [fddAgencies, setFddAgencies] = useState<any[]>([]);
  const [selectedAgencyId, setSelectedAgencyId] = useState('');
  const [isAssigningAgency, setIsAssigningAgency] = useState(false);
  const [showAssignFddModal, setShowAssignFddModal] = useState(false);
  const [isApproving, setIsApproving] = useState(false);
  const [isRejecting, setIsRejecting] = useState(false);
  const [ktMatrixScores, setKtMatrixScores] = useState<Record<string, number>>({});
  const [ktMatrixSelectedValues, setKtMatrixSelectedValues] = useState<Record<string, string>>({});
  const [ktMatrixRemarks, setKtMatrixRemarks] = useState<string>('');
  const [ktMatrixRecommendation, setKtMatrixRecommendation] = useState<string>('Approve');
  const [isSubmittingKT, setIsSubmittingKT] = useState(false);
  const [selectedInterviewForFeedback, setSelectedInterviewForFeedback] = useState<any>(null);
  const [showFddFinalizeModal, setShowFddFinalizeModal] = useState(false);
  const [showFddFlagModal, setShowFddFlagModal] = useState(false);
  const [fddAuditRecommendation, setFddAuditRecommendation] = useState<string>('Recommended');
  const [fddAuditFindings, setFddAuditFindings] = useState<string>('');
  const [isFinalizingFdd, setIsFinalizingFdd] = useState(false);
  const [isFddFlagging, setIsFddFlagging] = useState(false);
  const [level2Feedback, setLevel2Feedback] = useState<any>({});
  const [level2Recommendation, setLevel2Recommendation] = useState<string>('Approve');
  const [isSubmittingLevel2, setIsSubmittingLevel2] = useState(false);
  const [level3Feedback, setLevel3Feedback] = useState<any>({});
  const [level3Recommendation, setLevel3Recommendation] = useState<string>('Approve');
  const [isSubmittingLevel3, setIsSubmittingLevel3] = useState(false);
  const [selectedEvaluationForView, setSelectedEvaluationForView] = useState<any>(null);
  const [showFeedbackDetailsModal, setShowFeedbackDetailsModal] = useState(false);

  return {
    showFirmTypeModal, setShowFirmTypeModal,
    updatingFirmType, setUpdatingFirmType,
    tempFirmType, setTempFirmType,
    activeTab, setActiveTab,
    showApproveModal, setShowApproveModal,
    showOnboardModal, setShowOnboardModal,
    isOnboarding, setIsOnboarding,
    showRejectModal, setShowRejectModal,
    rejectionReason, setRejectionReason,
    scheduledInterviewParticipants, setScheduledInterviewParticipants,
    showScheduleModal, setShowScheduleModal,
    showCancelInterviewModal, setShowCancelInterviewModal,
    interviewIdToCancel, setInterviewIdToCancel,
    interviewToReschedule, setInterviewToReschedule,
    showKTMatrixModal, setShowKTMatrixModal,
    showLevel2FeedbackModal, setShowLevel2FeedbackModal,
    showLevel3FeedbackModal, setShowLevel3FeedbackModal,
    showDocumentsModal, setShowDocumentsModal,
    showAssignModal, setShowAssignModal,
    selectedStage, setSelectedStage,
    interviewMode, setInterviewMode,
    approvalRemark, setApprovalRemark,
    expandedBranches, setExpandedBranches,
    users, setUsers,
    selectedUser, setSelectedUser,
    participantType, setParticipantType,
    interviewDate, setInterviewDate,
    interviewType, setInterviewType,
    meetingLink, setMeetingLink,
    location, setLocation,
    showUploadForm, setShowUploadForm,
    uploadFile, setUploadFile,
    uploadDocType, setUploadDocType,
    approvalFile, setApprovalFile,
    isUploading, setIsUploading,
    previewDoc, setPreviewDoc,
    showPreviewModal, setShowPreviewModal,
    selectedInterviewerId, setSelectedInterviewerId,
    isEditingStatutory, setIsEditingStatutory,
    statutoryForm, setStatutoryForm,
    isSavingStatutory, setIsSavingStatutory,
    interviews, setInterviews,
    isScheduling, setIsScheduling,
    isCancellingInterview, setIsCancellingInterview,
    showAssignArchitectureModal, setShowAssignArchitectureModal,
    architectureLeadId, setArchitectureLeadId,
    isAssigningArchitecture, setIsAssigningArchitecture,
    showArchitectureStatusModal, setShowArchitectureStatusModal,
    architectureStatus, setArchitectureStatus,
    architectureRemarks, setArchitectureRemarks,
    isUpdatingArchitecture, setIsUpdatingArchitecture,
    isAssigningParticipant, setIsAssigningParticipant,
    documentConfigs, setDocumentConfigs,
    fddAgencies, setFddAgencies,
    selectedAgencyId, setSelectedAgencyId,
    isAssigningAgency, setIsAssigningAgency,
    showAssignFddModal, setShowAssignFddModal,
    isApproving, setIsApproving,
    isRejecting, setIsRejecting,
    ktMatrixScores, setKtMatrixScores,
    ktMatrixSelectedValues, setKtMatrixSelectedValues,
    ktMatrixRemarks, setKtMatrixRemarks,
    ktMatrixRecommendation, setKtMatrixRecommendation,
    isSubmittingKT, setIsSubmittingKT,
    selectedInterviewForFeedback, setSelectedInterviewForFeedback,
    showFddFinalizeModal, setShowFddFinalizeModal,
    showFddFlagModal, setShowFddFlagModal,
    fddAuditRecommendation, setFddAuditRecommendation,
    fddAuditFindings, setFddAuditFindings,
    isFinalizingFdd, setIsFinalizingFdd,
    isFddFlagging, setIsFddFlagging,
    level2Feedback, setLevel2Feedback,
    level2Recommendation, setLevel2Recommendation,
    isSubmittingLevel2, setIsSubmittingLevel2,
    level3Feedback, setLevel3Feedback,
    level3Recommendation, setLevel3Recommendation,
    isSubmittingLevel3, setIsSubmittingLevel3,
    selectedEvaluationForView, setSelectedEvaluationForView,
    showFeedbackDetailsModal, setShowFeedbackDetailsModal,
  };
}
