<script lang="ts">
interface Props {
    /** @type {import('./$types').PageData} */
    data: any;
}
let { data }: Props = $props();

let log_lvl: number = $state(0);
// console.log(`ae_events_pres_mgmt event [slug] +page.svelte data:`, data);

import { page } from '$app/stores';

import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';

import { liveQuery } from "dexie";
// import { core_func } from '$lib/ae_core_functions';
import { db_events } from "$lib/ae_events/db_events";
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
import { events_func } from '$lib/ae_events_functions';

import Event_reports_page_menu from './event_reports_page_menu.svelte';
import Reports_sessions from './reports_sessions.svelte';
import Reports_presenters from './reports_presenters.svelte';
import Reports_files from './reports_files.svelte';
// import Comp_event_file_obj_tbl from '../../ae_comp__event_file_obj_tbl.svelte';


// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
// $slct.account_id = data.account_id;
console.log(`$slct.account_id = `, $slct.account_id);
let ae_acct = data[$slct.account_id];
console.log(`ae_acct = `, ae_acct);

// console.log(`TEST data`, data);
// console.log(`TEST data.url`, data?.url);
// console.log(`TEST data.url.hash`, data?.url?.hash);
// console.log(`TEST $page.url`, $page?.url);
console.log(`TEST $page.url.hash`, $page?.url?.hash);

$events_slct.event_id = ae_acct.slct.event_id;
$events_slct.event_obj = ae_acct.slct.event_obj;
$events_slct.event_session_obj_li = ae_acct.slct.event_session_obj_li;

let lq__event_obj = $derived(liveQuery(async () => {
    let results = await db_events.event
        .get(ae_acct.slct.event_id);
    return results;
}));

// It is important that these not be set to a value! It messes with the Dexie LiveQuery.
let event_file_id_random_li: Array<string> = $state();
let event_session_id_random_li: Array<string> = $state();
// let event_presentation_id_random_li: Array<string>;
// let event_presenter_id_random_li: Array<string> = $state();

// let load_obj_li_results: Promise<any>|key_val;
// let search_submit_results: Promise<any>|key_val;

let ae_promises: key_val = $state({});
let ae_tmp: key_val = {};
let ae_triggers: key_val = $state({
    rpt__event_files: true,
    rpt__event_sessions: true,
    rpt__event_presenters: true,
});

let url_hash: string = $state($page?.url?.hash);

$effect(() => {
    if (url_hash) {
        url_hash = url_hash.replace('#', '');
        if (log_lvl) {
            console.log(`URL hash changed: ${url_hash}`);
        }
        $events_loc.pres_mgmt.show_report = url_hash;
    }
});


// async function handle_qry__event_file(
//         {
//             created_on_offset = null,
//             min_file_size = null, // in bytes
//             file_purpose = null,
//             ft_search_str = '',
//             lk_search_str = '',
//             limit = $events_loc.pres_mgmt.qry_limit__files ?? 0,
//             try_cache = true,
//             log_lvl = 0,
//         }: {
//             created_on_offset?: null|number,
//             min_file_size?: null|number,
//             file_purpose?: null|string,
//             ft_search_str?: string,
//             lk_search_str?: string,
//             limit?: number,
//             try_cache?: boolean,
//             log_lvl?: number,
//         }
//     ) {
//     console.log('handle_qry__event_file()');

//     $events_sess.pres_mgmt.status_qry__search = 'loading';
//     $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'loading';

//     let created_on_str = null;
//     if (created_on_offset) {
//         // Calculate the datetime to pass based on the selected offset.
//         let offset = created_on_offset ?? 0;

//         let current_datetime = new Date();
//         console.log(`Current time:`, current_datetime);

//         // It is very important to know that all of the created_on and updated_on timestamps are in ET timezone. Sorry...?
//         let for_et_tz_datetime = new Date(current_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
//         const adjust_minutes = for_et_tz_datetime.getTimezoneOffset(); // Usually 240 minutes for ET.
//         const adjusted_for_et_tz_datetime = new Date(for_et_tz_datetime.getTime() - adjust_minutes * 60 * 1000);
//         const adjusted_for_et_tz_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
//         console.log(`Adjusted for ET TZ time:`, adjusted_for_et_tz_datetime_iso_str);

//         let offset_datetime = adjusted_for_et_tz_datetime;
//         offset_datetime.setSeconds(offset_datetime.getSeconds() - offset);
//         console.log(`Offset time:`, offset_datetime);
//         // .slice(0, 19).replace('T', ' '), // '2024-10-15 13:59:59'
//         const offset_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
//         console.log(`Offset time ET ISO: ${offset_datetime_iso_str}`);

//         created_on_str = offset_datetime_iso_str;

//         // Convert to US Eastern time and output as ISO string.
//         // let offset_datetime_local = new Date(offset_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
//         // console.log(`Test time local ET: ${offset_datetime_local}`);

//         // let formatted_str = offset_datetime_local.toLocaleString('en-US', {
//         //     year: 'numeric',
//         //     month: '2-digit',
//         //     day: '2-digit',
//         //     hour: '2-digit',
//         //     minute: '2-digit',
//         //     second: '2-digit',
//         //     timeZone: 'UTC'
//         //     });
//         // console.log(`Test time local ET: ${formatted_str}`);

//         // let offset_datetime_local_str = offset_datetime_local.toISOString();
//         // console.log(`Test time local ET: ${offset_datetime_local_str}`);

//         // created_on_str = offset_datetime_local_str;
//     }

//     ae_promises.search__event_file = events_func.qry__event_file({
//         api_cfg: $ae_api,
//         event_id: $events_slct.event_id,
//         qry_created_on: created_on_str,
//         qry_min_file_size: min_file_size,
//         qry_file_purpose: file_purpose,
//         // fulltext_search_qry_str: ft_search_str,
//         // like_search_qry_str: lk_search_str,
//         // external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
//         enabled: $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
//         hidden: $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
//         limit: limit,
//         // params: params,
//         try_cache: try_cache,
//         log_lvl: log_lvl,
//     })
//     .then(function (search_results) {
//         // Processing the results from the search.
//         $events_sess.pres_mgmt.status_qry__search = 'processing';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'processing';
//         $events_slct.event_file_obj_li = search_results;
//         // console.log(search_results);
//         // $events_sess.pres_mgmt.status_qry__search = 'done';
//     })
//     .finally(() => {
//         if (log_lvl) {
//             console.log('TEST SEARCH - Search done. Pulling out the event_file_id_randoms.');
//         }
//         // console.log(`TEST search: ${$lq_kv__event_file_obj_li}`);

//         event_file_id_random_li = [];

//         // We need to loop through the array of objects and get the event_file_id_random from each object a new list of event_file_id_randoms. Then we can use this list to get the full objects from the database.
//         let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
//         for (let i = 0; i < $events_slct.event_file_obj_li.length; i++) {
//             tmp_li.push($events_slct.event_file_obj_li[i].event_file_id_random);
//         }
//         event_file_id_random_li = tmp_li;

//         // event_file_id_random_li = $events_slct.event_file_obj_li.map(file_obj => file_obj.event_file_id_random);

//         // Finally done with the search.
//         $events_sess.pres_mgmt.status_qry__search = 'done';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'done';

//         if (log_lvl > 1) {
//             console.log(`TEST SEARCH - event_file_id_random_li:`, event_file_id_random_li);
//             // console.log(`TEST SEARCH - search live query: ${$lq_kv__event_file_obj_li}`);
//         }

//     });

// }

// async function handle_search__event_session(
//         {
//             poc_agree = null,
//             ft_search_str = '',
//             lk_search_str = '',
//             params = {
//                 'qry__enabled': $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
//                 'qry__hidden': $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
//                 'qry__limit': $events_loc.pres_mgmt.qry_limit__sessions ?? 150,
//             },
//             try_cache=true,
//             log_lvl=0,
//         }: {
//             poc_agree?: null|boolean,
//             ft_search_str?: string,
//             lk_search_str?: string,
//             params?: key_val,
//             try_cache?: boolean,
//             log_lvl?: number,
//         }
//     ) {
//     if (log_lvl) {
//         console.log('handle_search__event_session()');
//     }

//     $events_sess.pres_mgmt.status_qry__search = 'loading';
//     $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'loading';

//     ae_promises.handle_search__event_session = events_func.search__event_session({
//         api_cfg: $ae_api,
//         event_id: $events_slct.event_id,
//         poc_agree: poc_agree,
//         fulltext_search_qry_str: ft_search_str,
//         like_search_qry_str: lk_search_str,
//         // external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
//         params: params,
//         try_cache: try_cache,
//         log_lvl: log_lvl,
//     })
//     .then(function (search_results) {
//         // Processing the results from the search.
//         $events_sess.pres_mgmt.status_qry__search = 'processing';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'processing';
//         $events_slct.event_session_obj_li = search_results;
//         console.log(search_results);
//         // $events_sess.pres_mgmt.status_qry__search = 'done';
//     })
//     .finally(() => {
//         if (log_lvl) {
//             console.log('API query done. Pulling out the event_session_id_random values.');
//         }
//         // console.log(`TEST search: ${$lq_kv__event_session_obj_li}`);

//         event_session_id_random_li = [];

//         // We need to loop through the array of objects and get the event_session_id_random from each object a new list of event_session_id_randoms. Then we can use this list to get the full objects from the database.
//         let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
//         if ($events_slct.event_session_obj_li) {
//             for (let i = 0; i < $events_slct.event_session_obj_li.length; i++) {
//                 tmp_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
//             }
//         }
//         event_session_id_random_li = tmp_li;

//         // event_session_id_random_li = $events_slct.event_session_obj_li.map(session_obj => session_obj.event_session_id_random);

//         // Finally done with the search.
//         $events_sess.pres_mgmt.status_qry__search = 'done';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'done';

//         if (log_lvl > 1) {
//             console.log(`TEST SEARCH - event_session_id_random_li:`, event_session_id_random_li);
//             // console.log(`TEST SEARCH - search live query: ${$lq_kv__event_session_obj_li}`);
//         }

//     });

// }


// async function handle_search__event_presenter(
//         {
//             agree = null,
//             biography = null,
//             ft_search_str = '',
//             lk_search_str = '',
//             enabled = $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
//             hidden = $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
//             limit = $events_loc.pres_mgmt.qry_limit__presenters ?? 150,
//             order_by_li = {'updated_on': 'DESC', 'priority': 'DESC', 'sort': 'DESC', 'given_name': 'ASC', 'family_name': 'ASC', 'email': 'ASC', 'created_on': 'DESC'},
//             // params = {
//             //     'qry__enabled': $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
//             //     'qry__hidden': $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
//             //     'qry__limit': $events_loc.pres_mgmt.qry_limit__presenters ?? 199,
//             // },
//             // try_cache = true,
//             log_lvl = 0,
//         }: {
//             agree?: null|boolean,
//             biography?: null|boolean,
//             ft_search_str?: string,
//             lk_search_str?: string,
//             // search_delay?: number, // In milliseconds
//             // max_tries?: number,
//             enabled?: string,
//             hidden?: string,
//             limit?: number,
//             order_by_li?: key_val, // Order by fields and directions.
//             // params?: key_val,
//             // try_cache?: boolean,
//             log_lvl?: number,
//         }
//     ) {
//     log_lvl = 2;
//     if (log_lvl) {
//         console.log('handle_search__event_presenter()');
//     }

//     $events_sess.pres_mgmt.status_qry__search = 'loading';
//     $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'loading';

//     $events_sess.event_presenter_obj_li = [];
//     $events_slct.event_presenter_obj_li = []; // Clear out any previous results.

//     // let order_by_li = {'updated_on': 'DESC', 'priority': 'DESC', 'sort': 'DESC', 'given_name': 'ASC', 'family_name': 'ASC', 'email': 'ASC', 'created_on': 'DESC'};

//     ae_promises.search__event_presenter = events_func.search__event_presenter({
//         api_cfg: $ae_api,
//         event_id: $events_slct.event_id,
//         agree: agree,
//         biography: biography,
//         fulltext_search_qry_str: ft_search_str,
//         ft_presenter_search_qry_str: null,
//         like_search_qry_str: lk_search_str,
//         like_presentation_search_qry_str: lk_search_str,
//         like_presenter_search_qry_str: lk_search_str,
//         // external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
//         enabled: enabled,
//         hidden: hidden,
//         limit: limit,
//         order_by_li: order_by_li,
//         // try_cache: try_cache,
//         log_lvl: log_lvl,
//     })
//     .then(function (search_results) {
//         // Processing the results from the search.
//         $events_sess.pres_mgmt.status_qry__search = 'processing';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'processing';
//         $events_sess.event_presenter_obj_li = search_results;
//         // $events_slct.event_presenter_obj_li = search_results;
//         console.log(search_results);
//         // $events_sess.pres_mgmt.status_qry__search = 'done';
//     })
//     .finally(() => {
//         if (log_lvl) {
//             console.log('TEST SEARCH - Search done. Pulling out the event_presenter_id_randoms.');
//         }
//         // console.log(`TEST search: ${$lq_kv__event_presenter_obj_li}`);

//         // event_presenter_id_random_li = [];

//         // We need to loop through the array of objects and get the event_presenter_id_random from each object a new list of event_presenter_id_randoms. Then we can use this list to get the full objects from the database.
//         // let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
//         // for (let i = 0; i < $events_slct.event_presenter_obj_li.length; i++) {
//         //     tmp_li.push($events_slct.event_presenter_obj_li[i].event_presenter_id_random);
//         // }
//         // event_presenter_id_random_li = tmp_li;

//         // event_presenter_id_random_li = $events_slct.event_presenter_obj_li.map(presenter_obj => presenter_obj.event_presenter_id_random);

//         // Finally done with the search.
//         $events_sess.pres_mgmt.status_qry__search = 'done';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'done';

//         // if (log_lvl > 1) {
//         //     console.log(`TEST SEARCH - event_presenter_id_random_li:`, event_presenter_id_random_li);
//         //     // console.log(`TEST SEARCH - search live query: ${$lq_kv__event_presenter_obj_li}`);
//         // }

//     });
// }


// // Updated 2024-10-15
// async function handle_qry__event_session(
//         {
//             qry_files = null,
//             // file_count = false,
//             // file_count_all = null,
//             // ft_search_str = '',
//             // lk_search_str = '',
//             qry_poc_agree = null,
//             qry_poc_kv_json = null,
//             qry_poc_bios = null,
//             enabled = $events_loc.pres_mgmt.qry_enabled ?? 'enabled',
//             hidden = $events_loc.pres_mgmt.qry_hidden ?? 'not_hidden',
//             limit = $events_loc.pres_mgmt.qry_limit__sessions ?? 150,
//             log_lvl = 0,
//         }: {
//             qry_files?: null|boolean,
//             // file_count?: boolean,
//             // file_count_all?: null|number,
//             // ft_search_str?: string,
//             // lk_search_str?: string,
//             qry_poc_agree?: null|boolean,
//             qry_poc_kv_json?: null|boolean,
//             qry_poc_bios?: null|boolean,
//             enabled?: string,
//             hidden?: string,
//             limit?: number,
//             log_lvl?: number,
//         }
//     ) {
//     if (log_lvl) {
//         console.log('handle_qry__event_session()');
//     }

//     $events_sess.pres_mgmt.status_qry__search = 'loading';
//     $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'loading';

//     ae_promises.handle_qry__event_session = events_func.qry__event_session({
//         api_cfg: $ae_api,
//         event_id: $events_slct.event_id,
//         // file_count_all: file_count_all,
//         // fulltext_search_qry_str: ft_search_str,
//         // like_search_qry_str: lk_search_str,
//         // external_event_id: $events_loc.pres_mgmt.default__external_registration_id,
//         qry_files: qry_files,
//         qry_start_datetime: null,
//         qry_poc_agree: qry_poc_agree,
//         qry_poc_kv_json: qry_poc_kv_json,
//         enabled: enabled,
//         hidden: hidden,
//         limit: limit,
//         log_lvl: log_lvl,
//     })
//     .then(function (search_results) {
//         // Processing the results from the search.
//         $events_sess.pres_mgmt.status_qry__search = 'processing';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'processing';
//         $events_slct.event_session_obj_li = search_results;
//         if (log_lvl) {
//             console.log(`Search results:`, search_results);
//         }
//         // $events_sess.pres_mgmt.status_qry__search = 'done';
//     })
//     .finally(() => {
//         if (log_lvl) {
//             console.log('API query done. Pulling out the event_session_id_random values.');
//         }
//         // console.log(`TEST search: ${$lq_kv__event_session_obj_li}`);

//         event_session_id_random_li = [];

//         // We need to loop through the array of objects and get the event_session_id_random from each object a new list of event_session_id_randoms. Then we can use this list to get the full objects from the database.
//         let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
//         if ($events_slct.event_session_obj_li) {
//             for (let i = 0; i < $events_slct.event_session_obj_li.length; i++) {
//                 if (qry_poc_bios && $events_slct.event_session_obj_li[i].poc_kv_json) {
//                     if ($events_slct.event_session_obj_li[i].poc_kv_json['champion']?.biography.length > 1) {
//                         console.log(`Biography for session:`, $events_slct.event_session_obj_li[i]);
//                         tmp_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
//                     } else {
//                         console.log(`No biography for session:`, $events_slct.event_session_obj_li[i]);
//                     }
//                 } else {
//                     // console.log(`Pushing session to array (no biography):`, $events_slct.event_session_obj_li[i]);
//                     tmp_li.push($events_slct.event_session_obj_li[i].event_session_id_random);
//                 }
//             }
//         }
//         event_session_id_random_li = tmp_li;

//         // event_session_id_random_li = $events_slct.event_session_obj_li.map(session_obj => session_obj.event_session_id_random);

//         // Finally done with the search.
//         $events_sess.pres_mgmt.status_qry__search = 'done';
//         $events_sess.pres_mgmt.status_rpt[$events_loc.pres_mgmt.show_report] = 'done';

//         if (log_lvl > 1) {
//             console.log(`TEST SEARCH - event_session_id_random_li:`, event_session_id_random_li);
//             // console.log(`TEST SEARCH - search live query: ${$lq_kv__event_session_obj_li}`);
//         }

//     });

// }

</script>

<svelte:head>
	<title>
        Reports: {ae_util.shorten_string({string: $lq__event_obj?.name, max_length: 12})}
        ({$lq__event_obj?.event_id}) - Pres Mgmt - {$events_loc?.title}
    </title>
</svelte:head>


<Event_reports_page_menu
    data={data}
    lq__event_obj={lq__event_obj}
    />

{#if !$lq__event_obj}

<div>
    <span class="fas fa-spinner fa-spin m-1"></span>
    <span>Loading event information...</span>
</div>

{:else}

<header class="ae_module_header">
    <!-- <span
        class="flex flex-row flex-wrap gap-1 items-center justify-center"
        > -->

        <!-- rounded-md p-1 px-2 -->
        <!-- preset-filled-surface-400-600 text-neutral-800/90 -->
    <h2
        class="
            h2 text-center
            flex flex-row gap-0.25 items-center justify-between w-full
            "
        >
        <span
            class="flex flex-row gap-1 items-center"
            >
            <span class="fas fa-chart-line m-1 text-neutral-800/80"></span>
            Reports
        </span>
        <!-- Reports for: -->
        {#if $lq__event_obj?.cfg_json?.short_name}
            {@html $lq__event_obj?.cfg_json.short_name ?? ae_snip.html__not_set}
        {:else}
            {@html $lq__event_obj?.name ?? ae_snip.html__not_set}
        {/if}
    </h2>

</header>


<div class="preset-tonal-success border border-success-500 my-2 p-2 rounded-md flex flex-row flex-wrap gap-1 items-center justify-center">

    <span class="border border-gray-200 rounded-md p-1">

        <!-- Sessions without files uploaded -->
        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_sessions = true;
                $events_loc.pres_mgmt.show_report = 'session_no_files';
            }}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Toggle to show sessions with and without files uploaded."
            >
            {#if $events_loc.pres_mgmt?.show_report == 'session_no_files' && $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else}
                <span class="fas fa-clipboard-list m-1"></span>
            {/if}
            Sessions
            {#if $events_loc.pres_mgmt?.rpt__session_no_files}
                With
            {:else}
                Without
            {/if}
            Files
        </button>

        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_sessions = true;
                $events_loc.pres_mgmt.show_report = 'sessions_poc_agree';
            }}
            class:hidden={!$events_loc.pres_mgmt?.require__session_agree}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Toggle to show POCs who have agreed to session terms and conditions."
            >
            {#if $events_loc.pres_mgmt?.show_report == 'sessions_poc_agree' && $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else if $events_loc.pres_mgmt?.rpt__session_poc_agree}
                <span class="fas fa-check m-1"></span>
            {:else}
                <span class="fas fa-times m-1"></span>
            {/if}
            {#if $events_loc.pres_mgmt?.rpt__session_poc_agree}
                Session {$events_loc.pres_mgmt?.label__session_poc_name}s
                Agreed
            {:else}
                Session {$events_loc.pres_mgmt?.label__session_poc_name}s
                Not Agreed
            {/if}
        </button>

        <!-- Sessions without POC bios -->
        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_sessions = true;
                $events_loc.pres_mgmt.show_report = 'session_no_bio';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.session_no_bio && !$ae_loc.edit_mode}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show sessions without POC bios."
            >
            {#if $events_loc.pres_mgmt?.show_report == 'session_no_bio' && $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else}
                <span class="fas fa-id-card m-1"></span>
                <!-- <span class="fas fa-book m-1"></span> -->
            {/if}
            Session {$events_loc.pres_mgmt?.label__session_poc_name} Bios
        </button>

    </span>

    <span class="border border-gray-200 rounded-md p-1">

        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_presenters = true;
                $events_loc.pres_mgmt.show_report = 'presenters_agree';
            }}
            class:hidden={!$events_loc.pres_mgmt?.require__presenter_agree}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show presenters who have agreed to present."
            >
            {#if $events_loc.pres_mgmt?.show_report == 'presenters_agree' && $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else if $events_loc.pres_mgmt.rpt__presenter_agree}
                <span class="fas fa-check m-1"></span>
            {:else}
                <span class="fas fa-times m-1"></span>
            {/if}
            Presenters
            {#if $events_loc.pres_mgmt.rpt__presenter_agree}
                Agreed
            {:else}
                Not Agreed
            {/if}
        </button>

        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_presenters = true;
                $events_loc.pres_mgmt.show_report = 'presenters_biography';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.presenter_no_bio && !$ae_loc.edit_mode}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show presenters with bios."
            >
            {#if $events_loc.pres_mgmt?.show_report == 'presenters_biography' &&  $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else}
                <span class="fas fa-id-card m-1"></span>
                <!-- <span class="fas fa-book m-1"></span> -->
            {/if}
            Presenter Bios
        </button>

        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_presenters = true;
                $events_loc.pres_mgmt.show_report = 'presenters_overview';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.presenter_overview}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show overview of presenters' statuses. (A work in progress for LCI)"
            >
            {#if $events_loc.pres_mgmt?.show_report == 'presenters_overview' && $events_sess.pres_mgmt?.status_qry__search == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {:else}
                <span class="fas fa-tasks m-1"></span>
            {/if}
            Overview of Presenters
        </button>

    </span>

    <span class="border border-gray-200 rounded-md p-1">

        <!-- <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_files = true;
                $events_loc.pres_mgmt.show_report = 'recent_files';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.recent_files}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show recent file uploads."
            >
            {#if $events_sess.pres_mgmt?.show_report == 'recent_files' &&  $events_sess.pres_mgmt.status_rpt[$events_sess.pres_mgmt?.show_report] == 'loading'}
                <span class="fas fa-spinner fa-spin m-1"></span>
            {:else}
                <span class="fas fa-file m-1"></span>
            {/if}
            Recent File Uploads
        </button> -->

        <!-- <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_files = true;
                $events_loc.pres_mgmt.show_report = 'large_files';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.large_files}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show large file uploads."
            >
            {#if $events_sess.pres_mgmt?.show_report == 'large_files' &&  $events_sess.pres_mgmt.status_rpt[$events_sess.pres_mgmt?.show_report] == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {/if}
            <span class="fas fa-file m-1"></span>
            Large File Uploads
        </button> -->

        <button
            type="button"
            disabled={!$ae_loc.trusted_access}
            onclick={() => {
                ae_triggers.rpt__event_files = true;
                $events_loc.pres_mgmt.show_report = 'event_files';
            }}
            class:hidden={$lq__event_obj?.mod_pres_mgmt_json?.hide__report_kv.event_files}
            class="btn btn-sm preset-tonal-success border border-success-500 hover:preset-filled-success-500 transition-all m-1"
            title="Show large file uploads."
            >
            {#if $events_sess.pres_mgmt?.show_report == 'event_files' &&  $events_sess.pres_mgmt.status_rpt[$events_sess.pres_mgmt?.show_report] == 'loading'}
                <span class="fas fa-spinner fa-spin"></span>
            {/if}
            <span class="fas fa-file m-1"></span>
            Event Files
        </button>

    </span>


</div>


<!-- All Event Session related reports -->
{#if $events_loc.pres_mgmt.show_report == 'session_no_files' || $events_loc.pres_mgmt.show_report == 'session_no_bio' || $events_loc.pres_mgmt.show_report == 'sessions_poc_agree'}
    <Reports_sessions
        lq__event_obj={lq__event_obj}
        event_session_obj_li={$events_sess.event_session_obj_li}

        rpt__name={$events_loc.pres_mgmt.show_report}
        rpt__sort={$events_loc.pres_mgmt.qry__session_sort}
        rpt__enabled={$events_loc.pres_mgmt.qry_enabled}
        rpt__hidden={$events_loc.pres_mgmt.qry_hidden}
        rpt__limit={$events_loc.pres_mgmt.qry_limit__sessions}

        bind:qry__status={$events_sess.pres_mgmt.status_qry__search}
        qry__count={$events_sess.event_session_obj_li?.length ?? 0}

        bind:qry__trigger={ae_triggers.rpt__event_sessions}

        hide_session_code={$events_loc.pres_mgmt?.hide__session_code}

        log_lvl={log_lvl}
        />
{/if}


<!-- All Event Presenter related reports -->
{#if $events_loc.pres_mgmt.show_report == 'presenters_agree' || $events_loc.pres_mgmt.show_report == 'presenters_biography' || $events_loc.pres_mgmt.show_report == 'presenters_overview'}
    <Reports_presenters
        lq__event_obj={lq__event_obj}
        event_presenter_obj_li={$events_sess.event_presenter_obj_li}

        rpt__name={$events_loc.pres_mgmt.show_report}
        rpt__sort={$events_loc.pres_mgmt.qry__presenter_sort}
        rpt__enabled={$events_loc.pres_mgmt.qry_enabled}
        rpt__hidden={$events_loc.pres_mgmt.qry_hidden}
        rpt__limit={$events_loc.pres_mgmt.qry_limit__presenters}

        bind:qry__status={$events_sess.pres_mgmt.status_qry__search}
        qry__count={$events_sess.event_presenter_obj_li?.length ?? 0}

        bind:qry__trigger={ae_triggers.rpt__event_presenters}

        hide_session_code={$events_loc.pres_mgmt?.hide__session_code}

        log_lvl={log_lvl}
        />
{/if}


<!-- All Event File related reports -->
{#if $events_loc.pres_mgmt.show_report == 'event_files' ||$events_loc.pres_mgmt.show_report == 'recent_files' || $events_loc.pres_mgmt.show_report == 'large_files'}
    <Reports_files
        lq__event_obj={lq__event_obj}
        event_file_obj_li={$events_sess.event_file_obj_li}

        rpt__name={$events_loc.pres_mgmt.show_report}
        rpt__sort={$events_loc.pres_mgmt.qry__files_sort}
        rpt__enabled={$events_loc.pres_mgmt.qry_enabled}
        rpt__hidden={$events_loc.pres_mgmt.qry_hidden}
        rpt__limit={$events_loc.pres_mgmt.qry_limit__files}

        bind:qry__status={$events_sess.pres_mgmt.status_qry__search}
        qry__count={$events_sess.event_file_obj_li?.length ?? 0}

        bind:qry__trigger={ae_triggers.rpt__event_files}

        hide_session_code={$events_loc.pres_mgmt?.hide__session_code}

        log_lvl={log_lvl}
        />
{/if}

{/if}