<?php
/**
 * File: app/Admin/config/playground.php
 *
 * @package KimaAI
 * @since 1.1.0
 */

use KimaAI\Helper;

return [
  'order' => 3,
  'schema' => [
    'type' => 'object',
    'title' => __('Playground', 'kimaai'),
    'icon' => 'customPostType',
    'properties' => [
      'chat' => [
        'type' => 'object',
        'title' => __('Chat', 'kimaai'),
        'link' => 'playground-chat',
        'pageTitle' => __('Chat Playground', 'kimaai'),
        'pageDescription' => __('Here you can play with the chatbot', 'kimaai'),
        'component' => 'PlaygroundChat',
        'properties' => [
          'aiProvider' => [
            'type' => 'string',
            'default' => 'default',
            'component' => 'SelectField',
            'props' => [
              'label' => __('AI Provider', 'kimaai'),
              'options' => Helper::getAiEnvsOptions(true, true),
            ],
          ],
          'aiModel' => [
            'type' => 'string',
            'default' => 'dall-e-2',
            'component' => 'SelectField',
            'props' => [
              'label' => __('AI Model', 'kimaai'),
              'options' => Helper::aiProviderModelOptions('aiProvider', ['completion']),
            ],
          ],
          'temperature' => [
            'type' => 'number',
            'default' => 1.00,
            'component' => 'RangeField',
            'props' => [
              'label' => __('Temperature', 'kimaai'),
              'initialPosition' => 0.7,
              'min' => 0.0,
              'max' => 2.0,
              'step' => 0.01,
            ],
          ],
          'maxOutputTokens' => [
            'type' => 'integer',
            'default' => 1000,
            'component' => 'RangeField',
            'props' => [
              'type' => 'text',
              'label' => __('Max Tokens', 'kimaai'),
              'initialPosition' => 1000,
              'min' => 1,
              'max' => 4000,
              'step' => 1,
            ],
          ],
          'topP' => [
            'type' => 'number',
            'default' => 1.00,
            'component' => 'RangeField',
            'props' => [
              'label' => __('Top P', 'kimaai'),
              'initialPosition' => 1.0,
              'min' => 0.0,
              'max' => 1.0,
              'step' => 0.01,
            ],
          ],
        ],
      ],
      'image' => [
        'type' => 'object',
        'title' => __('Image', 'kimaai'),
        'link' => 'playground-image',
        'pageTitle' => __('Image Playground', 'kimaai'),
        'pageDescription' => __('Here you can play with the image generator', 'kimaai'),
        'component' => 'PlaygroundImage',
        'properties' => [
          'aiProvider' => [
            'type' => 'string',
            'default' => 'default',
            'component' => 'SelectField',
            'props' => [
              'label' => __('AI Provider', 'kimaai'),
              'options' => Helper::getAiEnvsOptions(true, true, ['openrouter']),
            ],
          ],
          'aiModel' => [
            'type' => 'string',
            'default' => 'dall-e-2',
            'component' => 'SelectField',
            'props' => [
              'label' => __('AI Model', 'kimaai'),
              'options' => [
                [
                  'value' => 'dall-e-2',
                  'label' => 'DALL-E 2',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'openai',
                  ],
                ],
                [
                  'value' => 'dall-e-3',
                  'label' => 'DALL-E 3',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'openai',
                  ],
                ],
                [
                  'value' => 'gpt-image-1',
                  'label' => 'GPT Image 1',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'openai',
                  ],
                ],
                [
                  'value' => 'black-forest-labs/flux-schnell',
                  'label' => 'FLUX Schnell',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'replicate',
                  ],
                ],
                [
                  'value' => 'black-forest-labs/flux-dev',
                  'label' => 'Flux Dev',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'replicate',
                  ],
                ],
              ],
            ],
          ],
          'size' => [
            'type' => 'string',
            'default' => '512x512',
            'component' => 'SelectField',
            'props' => [
              'label' => __('Image Size', 'kimaai'),
              'options' => [
                [
                  'value' => '256x256',
                  'label' => '256x256',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => '=',
                    'value' => 'dall-e-2',
                  ],
                ],
                [
                  'value' => '512x512',
                  'label' => '512x512',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'dall-e-2',
                  ],
                ],
                [
                  'value' => 'auto',
                  'label' => __('Auto', 'kimaai'),
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'gpt-image-1',
                  ],
                ],
                [
                  'value' => '1024x1024',
                  'label' => '1024x1024',
                ],
                [
                  'value' => '1792x1024',
                  'label' => '1792x1024',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'dall-e-3',
                  ],
                ],
                [
                  'value' => '1024x1792',
                  'label' => '1024x1792',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'dall-e-3',
                  ],
                ],
                [
                  'value' => '1024x1536',
                  'label' => '1024x1536',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'gpt-image-1',
                  ],
                ],
                [
                  'value' => '1536x1024',
                  'label' => '1536x1024',
                  'condition' => [
                    'field' => 'aiModel',
                    'operator' => 'contains',
                    'value' => 'gpt-image-1',
                  ],
                ],
              ],
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'openai',
            ],
          ],
          'aspectRatio' => [
            'type' => 'string',
            'default' => '1:1',
            'component' => 'SelectField',
            'props' => [
              'label' => __('Image Aspect Ratio', 'kimaai'),
              'options' => [
                [
                  'value' => '1:1',
                  'label' => __('Square 1:1', 'kimaai'),
                ],
                [
                  'value' => '16:9',
                  'label' => __('Wide 16:9', 'kimaai'),
                ],
                [
                  'value' => '21:9',
                  'label' => __('Ultra Wide 21:9', 'kimaai'),
                ],
                [
                  'value' => '3:2',
                  'label' => __('Landscape 3:2', 'kimaai'),
                ],
                [
                  'value' => '2:3',
                  'label' => __('Portrait 2:3', 'kimaai'),
                ],
                [
                  'value' => '4:5',
                  'label' => __('Portrait 4:5', 'kimaai'),
                ],
                [
                  'value' => '5:4',
                  'label' => __('Portrait 5:4', 'kimaai'),
                ],
                [
                  'value' => '3:4',
                  'label' => __('Portrait 3:4', 'kimaai'),
                ],
                [
                  'value' => '4:3',
                  'label' => __('Portrait 4:3', 'kimaai'),
                ],
                [
                  'value' => '9:16',
                  'label' => __('Tall 9:16', 'kimaai'),
                ],
                [
                  'value' => '9:21',
                  'label' => __('Tall 9:21', 'kimaai'),
                ],
              ],
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'replicate',
            ],
          ],
          'numInferenceSteps' => [
            'type' => 'integer',
            'default' => 4,
            'component' => 'RangeField',
            'props' => [
              'label' => __('Number of Inference Steps', 'kimaai'),
              'initialPosition' => 4,
              'min' => 1,
              'max' => 4,
              'step' => 1,
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'replicate',
            ],
          ],
          'n' => [
            'type' => 'integer',
            'default' => 1,
            'component' => 'RangeField',
            'props' => [
              'label' => __('Number of Images', 'kimaai'),
              'initialPosition' => 1,
              'min' => 1,
              'max' => 4,
              'step' => 1,
            ],
          ],
          'responseFormat' => [
            'type' => 'string',
            'default' => 'url',
            'component' => 'SelectField',
            'props' => [
              'label' => __('Response Format', 'kimaai'),
              'options' => [
                [
                  'value' => 'webp',
                  'label' => 'WebP',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'replicate',
                  ],
                ],
                [
                  'value' => 'png',
                  'label' => 'PNG',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'replicate',
                  ],
                ],
                [
                  'value' => 'jpg',
                  'label' => 'JPG',
                  'condition' => [
                    'field' => 'aiProvider',
                    'operator' => 'contains',
                    'value' => 'replicate',
                  ],
                ],
              ],
            ],
          ],
          'outputQuality' => [
            'type' => 'integer',
            'default' => 80,
            'component' => 'RangeField',
            'props' => [
              'label' => __('Output Quality', 'kimaai'),
              'initialPosition' => 80,
              'min' => 1,
              'max' => 100,
              'step' => 1,
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'replicate',
            ],
          ],
          'disableSafety' => [
            'type' => 'boolean',
            'default' => false,
            'component' => 'ToggleField',
            'props' => [
              'label' => __('Disable Safety Checker', 'kimaai'),
              'checked' => false,
              'description' => __('Disable safety checker for the image generation.', 'kimaai'),
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'replicate',
            ],
          ],
          'goFast' => [
            'type' => 'boolean',
            'default' => true,
            'component' => 'ToggleField',
            'props' => [
              'label' => __('Use Fast Mode', 'kimaai'),
              'checked' => true,
              'description' => __('Run faster predictions with the speed-optimized model; disable to use original bf16.', 'kimaai'),
            ],
            'condition' => [
              'field' => 'aiProvider',
              'operator' => 'contains',
              'value' => 'replicate',
            ],
          ],
        ],
      ],
      'imageHistory' => [
        'type' => null,
        'title' => __('Image History', 'kimaai'),
        'link' => 'playground-image-history',
        'pageTitle' => __('Playground Image History', 'kimaai'),
        'pageDescription' => __('On this page, you can see the image history', 'kimaai'),
        'component' => 'PlaygroundImageHistory',
        'showSaveButton' => false,
      ],
    ],
  ],
];
