"""
Project:    Shuffle & Skirmish Market Scraper
Author:     Edward Middleton-Smith
            Shuffle & Skirmish

Technology: Business Objects
Feature:    Magic Madhouse Product Scraper Class
"""

# Internal
from product_scraper import Product_Scraper
# External

class Magic_Madhouse_Product_Scraper(Product_Scraper):
    NAME_DOMAIN_MAGIC_MADHOUSE: str = 'Magic Madhouse'

    def __init__(self):
        super().__init__(domain = self.NAME_DOMAIN_MAGIC_MADHOUSE)

    @classmethod
    def parse_cost(cls, cost_text):
        return super().parse_cost(cost_text = cost_text)
        
    async def scrape_cost_and_active_playwright(self, browser, url):
        page_load_element_selector = '.productView-title'
        cost_selector = 'div.body > div.container > div > div.productView > section.productView-details > div.productView-options > form > div.productView-options-selections > div.productView-product > div.productView-info > div.price-rating > div.productView-price > div.price-section.actual-price > span.price'
        active_selector = '.alertBox.alertBox--error'
        cost_text, active = await super().scrape_cost_and_active_playwright(
              browser = browser
            , url = url
            , page_load_element_selector = page_load_element_selector
            , cost_selector = cost_selector
            , active_selector = active_selector
            , invalid_active_statuses = []
        )
        cost = self.parse_cost(cost_text = cost_text)
        return cost, active
