<script setup lang="ts">
import { CharacterBuilder } from '#shared/character.util';
import { unifySlug } from '~/shared/general.util';

definePageMeta({
    guestsGoesTo: '/user/login',
});
const id = unifySlug(useRouter().currentRoute.value.params.id ?? "new");
const container = useTemplateRef('container');

onMounted(() => {
    queueMicrotask(() => {
        if(container.value)
        {
            const builder = new CharacterBuilder(container.value, id === 'new' ? undefined : id);

            useShortcuts({
                "Meta_S": () => builder.save(false),
            })
        }
    });
})
</script>

<template>
    <div class="flex flex-1 max-w-full flex-col align-center" ref="container"></div>
</template>