'''
Created on 04-Jul-2021

@author: rishi_priyansh
'''


from xv.util import HtmlUtil

from xv.util import UtilClass

class BaseHelper(UtilClass):
    _EXTERNAL_LINKS_FILE_PATH = 'resources/_physics_external_links.csv'
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self._cache_processor = None

        self._web_link_helper = None

        self._overview_helper = None

        self._gauss_law_helper = None
        self._black_hole_helper = None
        self._quantum_eraser_helper = None
        self._loop_quantum_gravity_helper = None
        self._holographic_universe_helper = None
        self._planck_length_helper = None
        self._string_theory_helper = None
        self._time_helper = None
        self._fundamental_forces_helper = None
        self._newtonian_space_time_helper = None
        self._point_mass_helper = None
        self._fluid_mechanics_helper = None
        self._pressure_helper = None
        self._particle_mechanics_helper = None
        self._schem_draw_helper = None
        self._physics_schem_draw_helper = None
        self._formula_helper = None
        self._force_field_helper = None
        self._radio_activity_helper = None
        self._theory_of_relativity_helper = None
      
        
        self._diff_eq_helper = None
        
        
        self._quantum_atomic_model_helper = None

        self._optics_helper = None
        self._wave_helper = None
        self._waves_plotter_2d = None
        
        self._additive_property_helper = None
        self._electric_circuit_helper = None
        self._wave_mechanics_helper = None
        self._light_mechanics_helper = None
        self._kinematics_helper = None
        
        
        self._thermodynamics_helper = None
        
        self._periodic_trends_helper = None

        self._sympy_unit_system = None
        
        self._kwargs = kwargs
        
        self.htmlUtil = HtmlUtil()

        pass

    def call_plot_method(self, method, *args, **kwargs):
        '''
        returns plot_code, svg_str
        
        @method: method to be called
        
        Pass these two methods to use cache util. Any other params passed will be subsequently 
        passed to the method to be called.
        @use_cache = True/False
        @refresh_cache = False/True
        '''
        cache_processor = self.get_cache_processor()
        plot_code, svg_str = cache_processor.get_svg_and_runnable_code(method, 
                                                                       *args, 
                                                                       **kwargs)
        plot_code = plot_code.replace("self.verbose", "False")
        return plot_code, svg_str
        pass

    def get_cache_processor(self):
        if self._cache_processor is None:
            self._init_cache_processor(**self._kwargs)
        return self._cache_processor
        pass

    def _init_cache_processor(self, **kwargs):  
        from xv.util.data import CacheProcessor
        self._cache_processor = CacheProcessor(**kwargs)
        pass


    def get_web_link_helper(self):
        if self._web_link_helper is None:
            self._init_web_link_helper(**self._kwargs)
            
        return self._web_link_helper
        pass

    def _init_web_link_helper(self, **kwargs):  
        import pathlib
        file_path = BaseHelper._EXTERNAL_LINKS_FILE_PATH
        root_folder = pathlib.Path(__file__).parent.absolute()

        from xv.km.helper import WebLinkHelper
        self._web_link_helper = WebLinkHelper(file_path = file_path,
                                              root_folder = root_folder,
                                              verbose = self.verbose)
        pass



    def get_overview_helper(self):
        if self._overview_helper is None:
            self._init_overview_helper(**self._kwargs)
        return self._overview_helper
        pass

    def _init_overview_helper(self, **kwargs):  
        from ._overview_helper import OverviewHelper
        self._overview_helper = OverviewHelper(verbose = self.verbose)
        pass
    
    

    def get_gauss_law_helper(self):
        if self._gauss_law_helper is None:
            self._init_gauss_law_helper(**self._kwargs)
        return self._gauss_law_helper
        pass

    def _init_gauss_law_helper(self, **kwargs):  
        from ._gauss_law_helper import GaussLawHelper
        self._gauss_law_helper = GaussLawHelper(verbose = self.verbose)
        pass
    
    def get_black_hole_helper(self):
        if self._black_hole_helper is None:
            self._init_black_hole_helper(**self._kwargs)
        return self._black_hole_helper
        pass

    def _init_black_hole_helper(self, **kwargs):  
        from ._black_hole_helper import BlackHoleHelper
        self._black_hole_helper = BlackHoleHelper(verbose = self.verbose)
        pass

    def get_quantum_eraser_helper(self):
        if self._quantum_eraser_helper is None:
            self._init_quantum_eraser_helper(**self._kwargs)
        return self._quantum_eraser_helper
        pass

    def _init_quantum_eraser_helper(self, **kwargs):  
        from ._quantum_eraser_helper import QuantumEraserHelper
        self._quantum_eraser_helper = QuantumEraserHelper(verbose = self.verbose)
        pass
    
    def get_loop_quantum_gravity_helper(self):
        if self._loop_quantum_gravity_helper is None:
            self._init_loop_quantum_gravity_helper(**self._kwargs)
        return self._loop_quantum_gravity_helper
        pass

    def _init_loop_quantum_gravity_helper(self, **kwargs):  
        from ._loop_quantum_gravity_helper import LoopQuantumGravityHelper
        self._loop_quantum_gravity_helper = LoopQuantumGravityHelper(verbose = self.verbose)
        pass
    
    def get_holographic_universe_helper(self):
        if self._holographic_universe_helper is None:
            self._init_holographic_universe_helper(**self._kwargs)
        return self._holographic_universe_helper
        pass

    def _init_holographic_universe_helper(self, **kwargs):  
        from ._holographic_universe_helper import HolographicUniverseHelper
        self._holographic_universe_helper = HolographicUniverseHelper(verbose = self.verbose)
        pass

    def get_planck_length_helper(self):
        if self._planck_length_helper is None:
            self._init_planck_length_helper(**self._kwargs)
        return self._planck_length_helper
        pass

    def _init_planck_length_helper(self, **kwargs):  
        from ._planck_length_helper import PlanckLengthHelper
        self._planck_length_helper = PlanckLengthHelper(verbose = self.verbose)
        pass

    def get_string_theory_helper(self):
        if self._string_theory_helper is None:
            self._init_string_theory_helper(**self._kwargs)
        return self._string_theory_helper
        pass

    def _init_string_theory_helper(self, **kwargs):  
        from ._string_theory_helper import StringTheoryHelper
        self._string_theory_helper = StringTheoryHelper(verbose = self.verbose)
        pass

    def get_time_helper(self):
        if self._time_helper is None:
            self._init_time_helper(**self._kwargs)
        return self._time_helper
        pass

    def _init_time_helper(self, **kwargs):  
        from ._time_helper import TimeHelper
        self._time_helper = TimeHelper(verbose = self.verbose)
        pass
    

    def get_fundamental_forces_helper(self):
        if self._fundamental_forces_helper is None:
            self._init_fundamental_forces_helper(**self._kwargs)
        return self._fundamental_forces_helper
        pass

    def _init_fundamental_forces_helper(self, **kwargs):  
        from ._fundamental_forces_helper import FundamentalForcesHelper
        self._fundamental_forces_helper = FundamentalForcesHelper(verbose = self.verbose)
        pass
    
    def get_newtonian_space_time_helper(self):
        if self._newtonian_space_time_helper is None:
            self._init_newtonian_space_time_helper(**self._kwargs)
        return self._newtonian_space_time_helper
        pass

    def _init_newtonian_space_time_helper(self, **kwargs):  
        from ._newtonian_space_time_helper import NewtonianSpaceTimeHelper
        self._newtonian_space_time_helper = NewtonianSpaceTimeHelper(verbose = self.verbose)
        pass


    def get_point_mass_helper(self):
        if self._point_mass_helper is None:
            self._init_point_mass_helper(**self._kwargs)
        return self._point_mass_helper
        pass

    def _init_point_mass_helper(self, **kwargs):  
        from ._point_mass_helper import PointMassHelper
        self._point_mass_helper = PointMassHelper(verbose = self.verbose)
        pass
    
    def get_fluid_mechanics_helper(self):
        if self._fluid_mechanics_helper is None:
            self._init_fluid_mechanics_helper(**self._kwargs)
        return self._fluid_mechanics_helper
        pass

    def _init_fluid_mechanics_helper(self, **kwargs):  
        from ._fluid_mechanics_helper import FluidMechanicsHelper
        self._fluid_mechanics_helper = FluidMechanicsHelper(verbose = self.verbose)
        pass
    
    def get_pressure_helper(self):
        if self._pressure_helper is None:
            self._init_pressure_helper(**self._kwargs)
        return self._pressure_helper
        pass

    def _init_pressure_helper(self, **kwargs):  
        from ._pressure_helper import PressureHelper
        self._pressure_helper = PressureHelper(verbose = self.verbose)
        pass
    
    
    
    def get_particle_mechanics_helper(self):
        if self._particle_mechanics_helper is None:
            self._init_particle_mechanics_helper(**self._kwargs)
        return self._particle_mechanics_helper
        pass

    def _init_particle_mechanics_helper(self, **kwargs):  
        from ._particle_mechanics_helper import ParticleMechanicsHelper
        self._particle_mechanics_helper = ParticleMechanicsHelper(verbose = self.verbose)
        pass
    

    def get_schem_draw_helper(self):
        if self._schem_draw_helper is None:
            self._init_schem_draw_helper(**self._kwargs)
        return self._schem_draw_helper
        pass

    def _init_schem_draw_helper(self, **kwargs):  
        from xv.plotter.helper import SchemDrawHelper
        self._schem_draw_helper = SchemDrawHelper(verbose = self.verbose)
        pass
    
    def get_physics_schem_draw_helper(self):
        if self._physics_schem_draw_helper is None:
            self._init_physics_schem_draw_helper(**self._kwargs)
        return self._physics_schem_draw_helper
        pass

    def _init_physics_schem_draw_helper(self, **kwargs):  
        from ._physics_schem_draw_helper import PhysicsSchemDrawHelper
        self._physics_schem_draw_helper = PhysicsSchemDrawHelper(verbose = self.verbose)
        pass
    
    def get_formula_helper(self):
        if self._formula_helper is None:
            self._init_formula_helper(**self._kwargs)
        return self._formula_helper
        pass

    def _init_formula_helper(self, **kwargs):  
        from xv.math.formulae import FormulaHelper
        self._formula_helper = FormulaHelper(verbose = self.verbose)
        pass
    
   
    def get_force_field_helper(self):
        if self._force_field_helper is None:
            self._init_force_field_helper(**self._kwargs)
        return self._force_field_helper
        pass

    def _init_force_field_helper(self, **kwargs):  
        from ._force_field_helper import ForceFieldHelper
        self._force_field_helper = ForceFieldHelper(verbose = self.verbose)
        pass
    
   
    def get_radio_activity_helper(self):
        if self._radio_activity_helper is None:
            self._init_radio_activity_helper(**self._kwargs)
        return self._radio_activity_helper
        pass

    def _init_radio_activity_helper(self, **kwargs):  
        from ._radio_activity_helper import RadioActivityHelper
        self._radio_activity_helper = RadioActivityHelper(verbose = self.verbose)
        pass
    
    def get_theory_of_relativity_helper(self):
        if self._theory_of_relativity_helper is None:
            self._init_theory_of_relativity_helper(**self._kwargs)
        return self._theory_of_relativity_helper
        pass

    def _init_theory_of_relativity_helper(self, **kwargs):  
        from ._theory_of_relativity_helper import TheoryOfRelativityHelper
        self._theory_of_relativity_helper = TheoryOfRelativityHelper(verbose = self.verbose)
        pass

    def get_diff_eq_helper(self):
        if self._diff_eq_helper is None:
            self._init_diff_eq_helper(**self._kwargs)
        return self._diff_eq_helper
        pass

    def _init_diff_eq_helper(self, **kwargs):  
        from ._diff_eq_helper import DiffEqHelper
        self._diff_eq_helper = DiffEqHelper(verbose = self.verbose)
        pass

    def get_optics_helper(self):
        if self._optics_helper is None:
            self._init_optics_helper(**self._kwargs)
        return self._optics_helper
        pass

    def _init_optics_helper(self, **kwargs):  
        from ._optics_helper import OpticsHelper
        self._optics_helper = OpticsHelper(verbose = self.verbose)
        pass

    def get_quantum_atomic_model_helper(self):
        if self._quantum_atomic_model_helper is None:
            self._init_quantum_atomic_model_helper(**self._kwargs)
        return self._quantum_atomic_model_helper
        pass

    def _init_quantum_atomic_model_helper(self, **kwargs):  
        from ._quantum_atomic_model_helper import QuantumAtomicModelHelper
        self._quantum_atomic_model_helper = QuantumAtomicModelHelper(verbose = self.verbose)
        pass

    def get_wave_helper(self):
        if self._wave_helper is None:
            self._init_wave_helper(**self._kwargs)
        return self._wave_helper
        pass

    def _init_wave_helper(self, **kwargs):  
        from ._wave_helper import WaveHelper
        self._wave_helper = WaveHelper(verbose = self.verbose)
        pass

    def get_waves_plotter_2d(self):
        if self._waves_plotter_2d is None:
            self._init_waves_plotter_2d(**self._kwargs)
        return self._waves_plotter_2d
        pass

    def _init_waves_plotter_2d(self, **kwargs):  
        from xv.plotter import WavesPlotter2d
        self._waves_plotter_2d = WavesPlotter2d(verbose = self.verbose)
        pass

    def get_additive_property_helper(self):
        if self._additive_property_helper is None:
            self._init_additive_property_helper(**self._kwargs)
        return self._additive_property_helper
        pass

    def _init_additive_property_helper(self, **kwargs):  
        from ._additive_property_helper import AdditivePropertyHelper
        self._additive_property_helper = AdditivePropertyHelper(verbose = self.verbose)
        pass

    def get_electric_circuit_helper(self):
        if self._electric_circuit_helper is None:
            self._init_electric_circuit_helper(**self._kwargs)
        return self._electric_circuit_helper
        pass

    def _init_electric_circuit_helper(self, **kwargs):  
        from ._electric_circuit_helper import ElectricCircuitHelper
        self._electric_circuit_helper = ElectricCircuitHelper(verbose = self.verbose)
        pass

    def get_wave_mechanics_helper(self):
        if self._wave_mechanics_helper is None:
            self._init_wave_mechanics_helper(**self._kwargs)
        return self._wave_mechanics_helper
        pass

    def _init_wave_mechanics_helper(self, **kwargs):  
        from ._wave_mechanics_helper import WaveMechanicsHelper
        self._wave_mechanics_helper = WaveMechanicsHelper(verbose = self.verbose)
        pass

    def get_light_mechanics_helper(self):
        if self._light_mechanics_helper is None:
            self._init_light_mechanics_helper(**self._kwargs)
        return self._light_mechanics_helper
        pass

    def _init_light_mechanics_helper(self, **kwargs):  
        from ._light_mechanics_helper import LightMechanicsHelper
        self._light_mechanics_helper = LightMechanicsHelper(verbose = self.verbose)
        pass


    def get_kinematics_helper(self):
        if self._kinematics_helper is None:
            self._init_kinematics_helper(**self._kwargs)
        return self._kinematics_helper
        pass

    def _init_kinematics_helper(self, **kwargs):  
        from ._kinematics_helper import KinematicsHelper
        self._kinematics_helper = KinematicsHelper(**kwargs) 
        pass


    def get_thermodynamics_helper(self):
        if self._thermodynamics_helper is None:
            self._init_thermodynamics_helper(**self._kwargs)
        return self._thermodynamics_helper
        pass

    def _init_thermodynamics_helper(self, **kwargs):  
        from ._thermodynamics_helper import ThermodynamicsHelper
        self._thermodynamics_helper = ThermodynamicsHelper(**kwargs) 
        pass


    def get_periodic_trends_helper(self):
        if self._periodic_trends_helper is None:
            self._init_periodic_trends_helper(**self._kwargs)
        return self._periodic_trends_helper
        pass

    def _init_periodic_trends_helper(self, **kwargs):  
        from xv.chemistry.helper import PeriodicTrendsHelper
        self._periodic_trends_helper = PeriodicTrendsHelper(verbose = self.verbose)
        pass


    def get_sympy_unit_system(self):
        if self._sympy_unit_system is None:
            self._init_sympy_unit_system(**self._kwargs)
        return self._sympy_unit_system
        pass

    def _init_sympy_unit_system(self, **kwargs):  
        from xv.km.util import SympyUnitSystem
        self._sympy_unit_system = SympyUnitSystem(verbose = self.verbose)
        pass



    pass
#class BaseHelper:
