import { PersistedState } from 'runed';

const events_auth_loc_defaults = {
    auth__person: {
        id: null as string | null,
        person_id: null as string | null,
        entered_key: null as string | null,
        email: null as string | null,
        full_name: null as string | null,
        presenter_id: null as string | null,
        presentation_id: null as string | null,
        session_id: null as string | null
    },
    auth__kv: {
        event: {} as Record<string, any>,
        exhibit: {} as Record<string, any>,
        location: {} as Record<string, any>,
        session: {} as Record<string, any>,
        presentation: {} as Record<string, any>,
        presenter: {} as Record<string, any>,
        person: {} as Record<string, any>
    }
};

export const events_auth_loc = new PersistedState('ae_events_auth_loc', events_auth_loc_defaults, {
    serializer: {
        serialize: JSON.stringify,
        deserialize: (raw: string) => ({ ...events_auth_loc_defaults, ...JSON.parse(raw) })
    }
});
