<?php
if ( ! defined( 'ABSPATH' ) ) exit;

class PBUAIV_Onboarding {

    private static ?PBUAIV_Onboarding $instance = null;

    public static function instance() : self {
        if ( null === self::$instance ) self::$instance = new self();
        return self::$instance;
    }

    private function __construct() {
        add_action( 'wp_ajax_pbuaiv_complete_onboarding', [ $this, 'complete' ] );
    }

    public function complete() : void {
        check_ajax_referer( 'pbuaiv_admin', 'nonce' );
        update_option( 'pbuaiv_onboarding_done', true );
        wp_send_json_success( [ 'redirect' => admin_url( 'admin.php?page=pbuaiv-settings' ) ] );
    }
}
