<?php
require __DIR__.'/_bootstrap.php';

use Zoo\Database;
use Zoo\Auth\PlayerAuthService;
use Zoo\Wallet\WalletQuery;

try {
    $db=Database::connect();
    $player=(new PlayerAuthService($db))->authenticate([]);
    $wallet=(new WalletQuery($db))->get((int)$player['user_id']);

    json_out([
        'ok'=>true,
        'player'=>[
            'user_id'=>(int)$player['user_id'],
            'public_id'=>$player['public_id']??null,
            'account_type'=>$player['account_type']??null,
            'auth_mode'=>$player['auth_mode']??null
        ],
        'wallet'=>$wallet
    ]);
} catch(Throwable $e) {
    json_out(['ok'=>false,'error'=>$e->getMessage()],401);
}
