export class StripeCommissionCalculator extends HTMLDivElement {
    constructor() {
        super();
    }

    connectedCallback() {
        this.input = this.querySelector('input');
        this.display = this.querySelector('.commission-display');
        
        if (this.input && this.display) {
            this.input.addEventListener('input', this.calculate.bind(this));
            // Initial calculation
            this.calculate();
        }
    }

    calculate() {
        const value = parseFloat(this.input.value);
        if (!isNaN(value)) {
            const commission = (value * 0.015) + 0.25;
            this.display.textContent = `~ ${commission.toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} €`;
            this.display.parentElement.classList.remove('hidden');
        } else {
            this.display.parentElement.classList.add('hidden');
        }
    }
}
