<script>
import { emit, listen } from '@tauri-apps/api/event';
import { invoke } from '@tauri-apps/api/tauri';

import { currentView } from './lib/routing.js';
import queue from './lib/queue.js';
const VIEWS = import.meta.glob('./views/*.svelte', {eager: true});


var appState = {
    currentRequest: null,
    pendingRequests: queue(),
    credentialStatus: 'locked',
}

listen('credentials-request', (tauriEvent) => {
    appState.pendingRequests.put(tauriEvent.payload);
});
</script>


<svelte:component
    this={VIEWS[`./views/${$currentView}.svelte`].default}
    bind:appState={appState}
/>
<!-- <svelte:component this="{VIEWS['./views/ShowApproved.svelte'].default}" bind:appState="{appState}" /> -->
