#!/usr/bin/env python3
"""Update Payment Methods block on all Irish casino review pages. Main-page style, unique text per casino, crypto everywhere."""

import re
from pathlib import Path

BASE = Path(__file__).resolve().parent / "irish-online-casino"
EXCLUDE = {"terms", "privacy", "responsible-gambling", "disclaimer", "trust-badges"}

# slug -> (min_dep, paypal_desc, card_desc, apple_desc, ewallet_desc, bank_desc, crypto_supported, crypto_desc)
PAYMENTS = {
    "spin": ("€10", "E-wallets (Skrill, NETELLER, ecoPayz, MuchBetter, eZeeWallet) typically process within 2–24 hours at Spin Casino.", "Visa and Mastercard accepted. Withdrawals 1–5 business days.", "Apple Pay not listed on official Ireland payment page; methods may vary.", "Skrill, NETELLER, ecoPayz, MuchBetter and eZeeWallet offer the fastest payouts (2–24h).", "Bank transfer (Swift), AstroPay and MiFinity available for withdrawals. Neosurf for deposits only.", False, "Cryptocurrency is not accepted at Spin Casino Ireland. The site focuses on cards and e-wallets."),
    "zodiac": ("€1", "Zodiac Casino processes PayPal withdrawals in 24–48 hours. Ideal for Irish players seeking quick payouts.", "Visa and Mastercard supported. Card withdrawals often take 3–5 days.", "Apple Pay accepted for instant deposits on iOS.", "Skrill and Neteller provide faster processing than cards.", "Bank transfer available; typically 5–7 days.", False, "Crypto is not currently supported; Zodiac offers PayPal, cards and e-wallets."),
    "mega": ("€10", "PayPal payouts at Mega Casino usually complete within 24–48 hours.", "Visa and Mastercard accepted; card withdrawals may take up to 5 days.", "Apple Pay available for mobile deposits.", "Skrill and Neteller speed up both deposits and withdrawals.", "Bank transfer for larger amounts; 5–7 day processing.", False, "Bitcoin and other crypto are not accepted; Mega Casino uses traditional payment methods."),
    "boo": ("€20", "PayPal at Boo Casino typically delivers withdrawals in 24–48 hours.", "Visa and Mastercard accepted; processing 3–5 business days.", "Apple Pay for quick deposits on iPhone and iPad.", "Skrill and Neteller offer faster payouts.", "Bank transfer available; 5–7 days typical.", False, "Crypto (Bitcoin, Ethereum) is not available; Boo accepts cards, PayPal and e-wallets."),
    "bizzo": ("€20", "Bizzo Casino processes PayPal withdrawals quickly, often within 24–48 hours.", "Visa and Mastercard supported; card withdrawals 3–5 days.", "Apple Pay for instant mobile deposits.", "Skrill and Neteller for faster e-wallet payouts.", "Bank transfer for larger sums; 5–7 days.", False, "Cryptocurrency is not supported; Bizzo offers PayPal, cards and e-wallets."),
    "21-casino": ("€10", "21 Casino PayPal withdrawals typically complete in 24–48 hours.", "Visa and Mastercard accepted; 3–5 day processing.", "Apple Pay for mobile deposits.", "Skrill and Neteller for quicker payouts.", "Bank transfer available; 5–7 days.", False, "Crypto is not accepted; 21 Casino focuses on cards and e-wallets."),
    "energy": ("€10", "Energy Casino PayPal payouts usually within 24–48 hours.", "Visa and Mastercard; card withdrawals 3–5 days.", "Apple Pay for fast deposits.", "Skrill and Neteller for speed and privacy.", "Bank transfer for larger amounts.", False, "Bitcoin and crypto not available; Energy uses cards, PayPal and e-wallets."),
    "mr-play": ("€10", "Mr Play Casino processes PayPal in 24–48 hours.", "Visa and Mastercard accepted; 3–5 day card withdrawals.", "Apple Pay for quick mobile deposits.", "Skrill and Neteller available.", "Bank transfer; 5–7 days.", False, "Crypto is not accepted; Mr Play offers cards, PayPal and e-wallets."),
    "playzee": ("€10", "Playzee PayPal withdrawals typically 24–48 hours.", "Visa and Mastercard; card payouts 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller for faster processing.", "Bank transfer available.", False, "Cryptocurrency not supported; Playzee accepts cards, PayPal and e-wallets."),
    "dunder": ("€10", "Dunder Casino PayPal payouts often within 24–48 hours.", "Visa and Mastercard; 3–5 day card withdrawals.", "Apple Pay available.", "Skrill and Neteller for speed.", "Bank transfer; 5–7 days.", False, "Crypto is not available; Dunder uses cards, PayPal and e-wallets."),
    "blackjack-casino": ("€10", "Blackjack Casino PayPal withdrawals in 24–48 hours.", "Visa and Mastercard; 3–5 day processing.", "Apple Pay for deposits.", "Skrill and Neteller available.", "Bank transfer for larger sums.", False, "Bitcoin and crypto not accepted; Blackjack Casino focuses on traditional methods."),
    "vip-casino": ("€10", "VIP Casino PayPal payouts typically 24–48 hours.", "Visa and Mastercard; 3–5 day card withdrawals.", "Apple Pay for mobile deposits.", "Skrill and Neteller for faster payouts.", "Bank transfer available.", False, "Crypto not supported; VIP Casino accepts cards and e-wallets."),
    "golden-star": ("€10", "Golden Star Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not available; Golden Star uses cards and e-wallets."),
    "mystake": ("€10", "Mystake processes PayPal in 24–48 hours. Crypto withdrawals are often faster, within 1 hour.", "Visa and Mastercard accepted; 3–5 day processing.", "Apple Pay for deposits.", "Skrill, Neteller, MuchBetter available.", "Bank transfer; 3–7 days.", True, "Bitcoin, Ethereum, Litecoin, USDT, XRP, BCH and more. Instant deposits and withdrawals often within 1 hour. Ideal for Irish players who prefer crypto."),
    "doggo": ("€20", "Doggo Casino PayPal typically 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Doggo offers cards, PayPal and e-wallets."),
    "supersport": ("€10", "Supersport Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 day card payouts.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; Supersport uses cards and e-wallets."),
    "spinia": ("€10", "Spinia Casino PayPal withdrawals 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer for larger amounts.", False, "Crypto is not accepted; Spinia offers cards, PayPal and e-wallets."),
    "betiton": ("€10", "Betiton PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Cryptocurrency not supported; Betiton accepts cards and e-wallets."),
    "hopa": ("€10", "Hopa Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not available; Hopa uses cards and e-wallets."),
    "friday-casino": ("€10", "Friday Casino PayPal typically 24–48 hours.", "Visa and Mastercard; 3–5 day withdrawals.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Bitcoin and crypto not accepted; Friday Casino offers cards and e-wallets."),
    "777-online": ("€20", "777 Online Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not supported; 777 Online uses cards and e-wallets."),
    "polestar": ("€10", "Polestar Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer available.", False, "Cryptocurrency not available; Polestar accepts cards and e-wallets."),
    "netent-casino": ("€10", "NetEnt Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not accepted; NetEnt Casino uses cards and e-wallets."),
    "powbet": ("€20", "Powbet PayPal typically 24–48 hours. Crypto payouts are often faster.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill, Neteller, MuchBetter, Revolut.", "Bank transfer; Trustly available.", True, "Crypto-friendly casino. Bitcoin and other cryptocurrencies accepted alongside traditional methods. Instant deposits, fast withdrawals."),
    "mansion": ("€20", "Mansion Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; Mansion focuses on cards and e-wallets."),
    "scatters": ("€10", "Scatters Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Scatters uses cards and e-wallets."),
    "star-casino": ("€10", "Star Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not supported; Star Casino accepts cards and e-wallets."),
    "axe": ("€20", "Axe Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not available; Axe uses cards and e-wallets."),
    "captain-cooks": ("€10", "Captain Cooks Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not accepted; Captain Cooks offers cards and e-wallets."),
    "tsars": ("€10", "Tsars Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not supported; Tsars uses cards and e-wallets."),
    "revolution": ("€10", "Revolution Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not available; Revolution accepts cards and e-wallets."),
    "quatro": ("€10", "Quatro Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Quatro offers cards and e-wallets."),
    "dolly": ("€10", "Dolly Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; Dolly uses cards and e-wallets."),
    "rollino": ("€10", "Rollino Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not available; Rollino accepts cards and e-wallets."),
    "quickwin": ("€10", "Quickwin Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not supported; Quickwin uses cards and e-wallets."),
    "cocoa": ("€10", "Cocoa Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Cocoa offers cards and e-wallets."),
    "barz": ("€10", "Barz Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; Barz uses cards and e-wallets."),
    "winnerz": ("€10", "Winnerz Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not available; Winnerz accepts cards and e-wallets."),
    "cookie-casino": ("€5", "Cookie Casino PayPal in 24–48 hours. Low min deposit €5.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not supported; Cookie offers cards and e-wallets with low minimums."),
    "lucky-dreams": ("€10", "Lucky Dreams Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Lucky Dreams uses cards and e-wallets."),
    "boho": ("€10", "Boho Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; Boho offers cards and e-wallets."),
    "d1-casino": ("€5", "D1 Casino PayPal 24–48 hours. Min deposit €5.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not available; D1 accepts cards and e-wallets with low minimums."),
    "phone-casino": ("€10", "Phone Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for mobile deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Cryptocurrency not supported; Phone Casino uses cards and e-wallets."),
    "carlton": ("€10", "Carlton Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer available.", False, "Crypto not accepted; Carlton offers cards and e-wallets."),
    "my-empire": ("€10", "My Empire Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Bitcoin and crypto not supported; My Empire uses cards and e-wallets."),
    "grand-mondial": ("€10", "Grand Mondial Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not available; Grand Mondial accepts cards and e-wallets."),
    "karamba": ("€10", "Karamba Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Cryptocurrency not supported; Karamba uses cards and e-wallets."),
    "arena": ("€10", "Arena Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not accepted; Arena offers cards and e-wallets."),
    "betinia": ("€10", "Betinia Casino PayPal in 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill and Neteller.", "Bank transfer available.", False, "Bitcoin and crypto not supported; Betinia uses cards and e-wallets."),
    "victoria": ("€10", "Victoria Casino PayPal 24–48 hours.", "Visa and Mastercard; 3–5 days.", "Apple Pay available.", "Skrill and Neteller.", "Bank transfer; 5–7 days.", False, "Crypto not available; Victoria accepts cards and e-wallets."),
    "20bet": ("€10", "20bet PayPal in 24–48 hours. Crypto withdrawals often faster, within 24h.", "Visa and Mastercard; 3–5 days.", "Apple Pay for deposits.", "Skrill, Neteller, ecoPayz.", "Bank transfer available.", True, "Bitcoin, Ethereum, Litecoin, Dogecoin, XRP, Cardano, Solana, BNB and USDT. Instant deposits, fast crypto withdrawals. Popular with Irish players who prefer crypto."),
}

DEFAULT = (
    "€10",
    "PayPal withdrawals typically process within 24–48 hours. One of the fastest options for Irish players.",
    "Visa and Mastercard accepted. Withdrawals may take 3–5 business days.",
    "Apple Pay available for quick mobile deposits.",
    "Skrill and Neteller offer faster payouts than cards.",
    "Bank transfer available for larger withdrawals; 5–7 day processing.",
    False,
    "Crypto (Bitcoin, Ethereum) is not accepted; the casino focuses on cards, PayPal and e-wallets."
)


def build_payment_block(casino_name: str, slug: str, name_lower: str) -> str:
    data = PAYMENTS.get(slug, DEFAULT)
    min_dep, paypal_desc, card_desc, apple_desc, ewallet_desc, bank_desc, crypto_ok, crypto_desc = data

    blocks = f'''<h2>{casino_name} Casino Payment Methods</h2>
<p>Choose from cards, e-wallets and bank transfer. Min deposit {min_dep}. Withdrawal times vary by method.</p>

<div class="irish-payment-block"><img src="/publics/logos/paypal.png" alt="PayPal" class="irish-pay-inline" width="48" height="30"/> <strong>PayPal</strong> — {paypal_desc}</div>

<div class="irish-payment-block"><img src="/publics/logos/visa.png" alt="Visa" class="irish-pay-inline" width="48" height="30"/> <strong>Visa &amp; Mastercard</strong> — {card_desc}</div>

<div class="irish-payment-block"><img src="/publics/logos/applepay.jpg" alt="Apple Pay" class="irish-pay-inline" width="48" height="30"/> <strong>Apple Pay</strong> — {apple_desc}</div>

<div class="irish-payment-block"><img src="/publics/logos/ewallet.svg" alt="E-wallet" class="irish-pay-inline" width="48" height="30"/> <strong>E-wallets</strong> (Skrill, Neteller) — {ewallet_desc}</div>

<div class="irish-payment-block"><img src="/publics/logos/banktransfer.webp" alt="Bank transfer" class="irish-pay-inline" width="48" height="30"/> <strong>Bank transfer</strong> — {bank_desc}</div>

'''
    if crypto_ok:
        blocks += f'''<div class="irish-payment-block"><img src="/publics/logos/crypto.png" alt="Crypto" class="irish-pay-inline" width="48" height="30"/> <strong>Crypto</strong> — {crypto_desc}</div>
'''
    else:
        blocks += f'''<div class="irish-payment-block"><img src="/publics/logos/crypto.png" alt="Crypto" class="irish-pay-inline" width="48" height="30"/> <strong>Crypto</strong> — {crypto_desc}</div>
'''
    return blocks


def main():
    for p in sorted(BASE.iterdir()):
        if not p.is_dir() or p.name in EXCLUDE:
            continue
        index = p / "index.html"
        if not index.exists():
            continue
        content = index.read_text(encoding="utf-8")

        m = re.search(r'<h1>([^<]+) Casino Review', content)
        casino_name = m.group(1).strip() if m else p.name.replace("-", " ").title()
        name_lower = casino_name.lower() if casino_name != "21" else "21"

        new_block = build_payment_block(casino_name, p.name, name_lower)

        old = re.search(
            r'<h2>[^<]+ Casino Payment Methods</h2>\s*'
            r'<h3>Deposit Options</h3>\s*<p>[^<]*</p>\s*'
            r'<h3>Withdrawal Process</h3>\s*<p>[^<]*</p>',
            content,
            re.DOTALL
        )
        if old:
            content = content.replace(old.group(0), new_block.rstrip(), 1)
            index.write_text(content, encoding="utf-8")
            print(p.name)
    print("Done.")


if __name__ == "__main__":
    main()
