<?php

namespace wpsolr\core\classes\hosting_api;

use wpsolr\core\classes\engines\opensearch_vector_php\WPSOLR_Opensearch_Vector_Constants;
use wpsolr\core\classes\engines\WPSOLR_AbstractEngineClient;

class WPSOLR_Hosting_Api_OpenSearch_Vector_None extends WPSOLR_Hosting_Api_OpenSearch_None {

	const HOSTING_API_ID = 'none_opensearch_vector';

	/**
	 * @inheritdoc
	 */
	public function get_label() {
		return sprintf( self::NONE_LABEL, WPSOLR_AbstractEngineClient::ENGINE_OPENSEARCH_VECTOR_NAME );
	}

	/**
	 * @inheritdoc
	 */
	public function get_search_engine() {
		return WPSOLR_AbstractEngineClient::ENGINE_OPENSEARCH_VECTOR;
	}

	/**
	 * @inheritdoc
	 */
	public function get_ui_fields_child() {

		$pretrained_models_url = '<a href="https://docs.opensearch.org/latest/ml-commons-plugin/pretrained-models#sentence-transformers" target="_new">Choose from Opensearch predefined sentence transformers models list</a>';

		$result = array_merge( parent::get_ui_fields_child(),
			[
				[
					self::FIELD_NAME_LLM_PROVIDER => [
						self::FIELD_NAME_LABEL                 => 'Model type',
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
						self::FIELD_NAME_DEFAULT_VALUE         => WPSOLR_Opensearch_Vector_Constants::MODEL_LOCAL_PRETRAINED_TRANSFORMER,
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_MANDATORY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'a model type',
						],
						self::FIELD_NAME_SELECT_VALUES         => [
							

							WPSOLR_Opensearch_Vector_Constants::MODEL_LOCAL_PRETRAINED_TRANSFORMER => [
								'label'                     => 'Predefined transformer model (local)',
								'is_default'                => true,
								'hide_fields_when_selected' => [
									self::FIELD_NAME_FIELDS_INDEX_API_KEY,
								],
								'show_fields_when_selected' => [
									self::FIELD_NAME_FIELDS_INDEX_LANGUAGE_CODE,
									self::FIELD_NAME_FIELDS_INDEX_CATALOG_BRANCH,
									self::FIELD_NAME_FIELDS_INDEX_WEAVIATE_HUGGINGFACE_CONFIG_MODEL,
								],
							],
							

						],
					],
				],
				[
					self::FIELD_NAME_FIELDS_INDEX_LANGUAGE_CODE => [
						self::FIELD_NAME_LABEL                 => "Model name<br>{$pretrained_models_url}",
						self::FIELD_NAME_PLACEHOLDER           => 'Example: huggingface/sentence-transformers/all-MiniLM-L6-v2',
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_NOT_MANDATORY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'your embedding model name',
						],
						self::FIELD_NAME_IS_RELATED            => true,
					]
				],
				[
					self::FIELD_NAME_FIELDS_INDEX_WEAVIATE_HUGGINGFACE_CONFIG_MODEL => [
						self::FIELD_NAME_LABEL                 => "Model version<br>Depends on the model name<br>{$pretrained_models_url}",
						self::FIELD_NAME_PLACEHOLDER           => 'Example: 1.0.2',
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_NOT_MANDATORY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'your model version',
						],
						self::FIELD_NAME_IS_RELATED            => true,
					]
				],
				[
					self::FIELD_NAME_FIELDS_INDEX_CATALOG_BRANCH => [
						self::FIELD_NAME_LABEL                 => "Vector dimensions<br>Depends on the model name<br>{$pretrained_models_url}",
						self::FIELD_NAME_PLACEHOLDER           => 'Example with huggingface/sentence-transformers/all-MiniLM-L6-v2: 384',
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_NOT_MANDATORY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'your vector dimensions',
						],
						self::FIELD_NAME_IS_RELATED            => true,
					]
				],
				[
					self::FIELD_NAME_FIELDS_INDEX_WEAVIATE_HUGGINGFACE_CONFIG_MODEL_QUERY => [
						self::FIELD_NAME_LABEL                 => "Model id",
						self::FIELD_NAME_PLACEHOLDER           => '',
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => true,
						self::FIELD_NAME_FORMAT_IS_UPDATE_ONLY => true,
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_READONLY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'your vector dimensions',
						],
						#self::FIELD_NAME_IS_RELATED            => true,
					]
				],
				[
					self::FIELD_NAME_FIELDS_INDEX_API_KEY => [
						self::FIELD_NAME_LABEL                 => 'External embedding API key',
						self::FIELD_NAME_PLACEHOLDER           => 'Your API key',
						self::FIELD_NAME_FORMAT                => [
							self::FIELD_NAME_FORMAT_TYPE        => self::FIELD_NAME_FORMAT_TYPE_NOT_MANDATORY,
							self::FIELD_NAME_FORMAT_ERROR_LABEL => self::PLEASE_ENTER . 'your API key',
						],
						self::FIELD_NAME_FORMAT_IS_CREATE_ONLY => false,
						self::FIELD_NAME_IS_RELATED            => true,
					]
				]
			] );

		return $result;
	}
}