import { collection, fields } from '@keystatic/core';
import { createBaseArticleFields } from '@fields/base-article.ts';
import { createContentField } from '@fields/content.ts';

export const elements = collection({
  label: 'Elements',
  slugField: 'title',
  path: 'src/content/crucible/elements/*/',
  columns: ['category'],

  format: {
    contentField: 'body',
  },
  schema: {
    ...createBaseArticleFields(),
    body: createContentField(),
    category: fields.select({
      label: 'Category',
      options: [
        {
          label: 'Prime',
          value: 'prime',
        },
        {
          label: 'Essence',
          value: 'essence',
        },
        {
          label: 'Aspect',
          value: 'aspect',
        },
      ],
      defaultValue: 'prime',
    }),
    symbol: fields.conditional(
      fields.select({
        label: 'Type',
        defaultValue: 'font',
        options: [
          { label: 'Font', value: 'font' },
          { label: 'SVG', value: 'svg' },
        ],
      }),
      {
        svg: fields.text({
          label: 'SVG Markup',
          multiline: true,
        }),
        font: fields.object({
          family: fields.select({
            label: 'Font Family',
            defaultValue: 'Unigrim Dee',
            options: [
              { label: 'Unigrim Dee', value: 'Unigrim Dee' },
              { label: 'Unigrim Hochenheim', value: 'Unigrim Hochenheim' },
              { label: 'Unigrim Trithemius', value: 'Unigrim Trithemius' },
            ],
          }),
          character: fields.text({
            label: 'Character',
          }),
        }),
      },
    ),
  },
});
