<script lang="ts">
import { untrack } from 'svelte';
let log_lvl: number = 0;

// *** Import Svelte specific
// import { page } from '$app/state';

// *** Import Aether specific variables and functions
import {
    ae_snip,
    ae_loc,
    ae_sess,
    ae_api,
    ae_trig,
    slct,
    slct_trigger
} from '$lib/stores/ae_stores';
import {
    idaa_loc,
    idaa_sess,
    idaa_slct,
    idaa_trig,
    idaa_prom
} from '$lib/stores/ae_idaa_stores';
// import { events_func } from '$lib/ae_events/ae_events_functions';

interface Props {
    /** @type {import('./$types').LayoutData} */
    data: any;
    children?: import('svelte').Snippet;
}

let { data, children }: Props = $props();

// NOTE: Derived from data.account_id (prop) instead of $slct.account_id (store)
// to prevent circular dependency loops during hydration.
let ae_acct = $derived(data[data.account_id]);

$effect(() => {
    if (log_lvl > 1) {
        console.log(`ae_idaa_recovery_meetings +layout.svelte`, data);
    }

    // *** Quickly pull out data from parent(s)
    untrack(() => {
        $slct.account_id = data.account_id;
    });
});

$effect(() => {
    if (log_lvl) {
        console.log(`ae_acct = `, ae_acct);
    }

    if (ae_acct) {
        untrack(() => {
            $idaa_slct.event_obj_li = ae_acct.slct.event_obj_li;
        });
    }
});

// *** Set initial variables
</script>

{@render children?.()}
