import { AcuityClient } from '../clients/acuity.js';

export const formTools = [
  {
    name: 'acuity_list_forms',
    description: 'List all intake forms',
    inputSchema: {
      type: 'object',
      properties: {},
    },
    handler: async (args: any, client: AcuityClient) => {
      const forms = await client.getForms();
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(forms, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_get_form',
    description: 'Get a specific form by ID',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Form ID',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const form = await client.getForm(args.id);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(form, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_create_form',
    description: 'Create a new intake form',
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Form name',
        },
        description: {
          type: 'string',
          description: 'Form description',
        },
      },
      required: ['name'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const form = await client.createForm(args);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(form, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_update_form',
    description: 'Update an existing form',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Form ID',
        },
        name: {
          type: 'string',
          description: 'Updated name',
        },
        description: {
          type: 'string',
          description: 'Updated description',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      const { id, ...updateParams } = args;
      const form = await client.updateForm(id, updateParams);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(form, null, 2),
          },
        ],
      };
    },
  },
  {
    name: 'acuity_delete_form',
    description: 'Delete a form',
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Form ID to delete',
        },
      },
      required: ['id'],
    },
    handler: async (args: any, client: AcuityClient) => {
      await client.deleteForm(args.id);
      return {
        content: [
          {
            type: 'text',
            text: `Form ${args.id} deleted successfully`,
          },
        ],
      };
    },
  },
];
