import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/ae_api/api';

// Updated 2026-03-25
export async function check_hosted_file_obj_w_hash({
    api_cfg,
    hosted_file_hash,
    check_for_local = true, // Forces a check on the host server for the file.
    params = {},
    return_meta = false,
    log_lvl = 0
}: {
    api_cfg: any;
    hosted_file_hash: string;
    check_for_local?: boolean;
    params?: key_val;
    return_meta?: boolean;
    log_lvl?: number;
}) {
    console.log('*** stores_event_api.js: check_hosted_file_obj_w_hash() ***');

    const endpoint = `/v3/action/hosted_file/hash/${hosted_file_hash}`;
    if (check_for_local) {
        params['check_for_local'] = true;
    }
    const check_hosted_file_obj_w_hash_get_promise = await api.get_object({
        api_cfg: api_cfg,
        endpoint: endpoint,
        params: params,
        return_meta: return_meta,
        log_lvl: log_lvl
    });
    return check_hosted_file_obj_w_hash_get_promise;
}
