'''
Created on 16-Apr-2021

@author: bthakur

https://vixra.org/pdf/1304.0081v1.pdf
Implement https://eecs.ceas.uc.edu/~cahaymm/QuantumSystems/Pauli.pdf
https://www.lkouniv.ac.in/site/writereaddata/siteContent/202006151236284892NK-Paulis%20Exclusion%20Principle.pdf
https://www.chem.uci.edu/~unicorn/old/H2A/handouts/PDFs/LectureA6.pdf
https://www.physics.rutgers.edu/~ohsean/361/Lectures/lecture21.pdf

'''

import random
import inspect
import traceback

from ..helper import BaseHelper

from xv.km.managers import BaseManager
from xv.km.kelements import KProblemTemplate

# _quantum_manager 
# QuantumManager   
   
class QuantumManager(BaseManager):
    '''
    Quantum chemistry


    Minimum Grade: 6
    Maximum Grade: 12


    Examples
    --------
        ke = QuantumManager()
        ke
        
        ke.printProblemTypes()
        
        ke.getRandomProblem()
        ke.getRandomProblem(problem_type = 0)
        ...
        
        ke.printProblem()
        ke.printAnswer()
        ke.printSolution()
    
        
    doc_style: xv_doc
    ''' 
      
    def __new__(cls, *args, **kwargs):
        instance = super(QuantumManager, cls).__new__(cls, *args, **kwargs)
        for base_class in QuantumManager.__bases__:
            base_class.__init__(instance, *args, **kwargs)
        return instance
    
    def __init__(self, *args, **kwargs):
        self.base_helper = BaseHelper(**kwargs)
        pass
    

    def _init_problem_types(self, *args, **kwargs):
        self._append_problem_types([
                '_problem_overview_of_quantum_properties',
                '_problem_nature_of_strong_force',
             ])
        pass
    
    def _problem_overview_of_quantum_properties(self, *args, **kwargs):
        """

        doc_style: xv_doc
        """

        
        category = 'quantum_properties'
        wl_helper = self.base_helper.get_web_link_helper()
        result = wl_helper.get_links_for_category_as_strs(
                            category, 
                            *args, 
                            **kwargs)

        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')
        
        if result is None:
            problemTemplate.add_problem(f"""
            No result found matching: 
                category = '{category}'
                args = {args}
                kwargs = {kwargs}
            """.strip(), 'text/html')
            return problemTemplate

        problem_s = f"""
        Video links related to quantum properties.
        
        """
        problemTemplate.add_problem(problem_s.strip(), 'text/html')

        problem_s = result['anchors_str']
        problemTemplate.add_problem(problem_s.strip(), 'text/html',
                                     add_html_line_break = False)
        
        soln_s = result['anchors_str']
        problemTemplate.add_solution(soln_s.strip(), 'text/html',
                                     add_html_line_break = False)
        
        answer_s = soln_s
        problemTemplate.add_answer(answer_s.strip(), 'text/html',
                                   add_html_line_break = False)
        
        return problemTemplate
                
        pass

    def _problem_nature_of_strong_force(self, *args, **kwargs):
        """

        doc_style: xv_doc
        """
        periodic_trends_helper = self.base_helper.get_periodic_trends_helper()
        result = periodic_trends_helper.get_problem_radioactivity(*args, **kwargs)
        
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')


        prob_s = f"""
        How does the nature of nuclear force change between attractive or 
        repulsive based on distance?
        """
        problemTemplate.add_problem(prob_s.replace("\n", " ").strip(), 'text/html')

        soln_s = f"""
        <a target="_blank" 
        href="https://physics.stackexchange.com/questions/84970/how-does-the-nature-of-nuclear-force-change-between-attractive-or-repulsive-base">
        See this link.
        </a>
        """
        problemTemplate.add_solution(soln_s.replace("\n", " ").strip(), 'text/html')

        answer_s = f"""
        The question assumes that the nuclear force does have 
        an attraction at long distances and a repulsive core at short distances. 
        The reality is more complicated than that, and there is in fact no unambiguous 
        way to decide whether this assumption is really correct.
        <br/>

        The strong force between two quarks is often modeled with a 
        potential $V \\propto r^n$, where $n \\geq 1$, 
        so that the interaction doesn't get weaker with distance. 
        This feature of these models reproduces the fact that single 
        quarks are never observed free.

        """
        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        return problemTemplate
        pass




    pass