# coding: utf-8
#
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Domain objects for configuration properties."""

from __future__ import annotations

from core import feconf
from core import schema_utils
from core.constants import constants
from core.domain import caching_services
from core.domain import change_domain
from core.platform import models

(config_models, suggestion_models,) = models.Registry.import_models(
    [models.NAMES.config, models.NAMES.suggestion])

CMD_CHANGE_PROPERTY_VALUE = 'change_property_value'

LIST_OF_FEATURED_TRANSLATION_LANGUAGES_DICTS_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_LIST,
    'items': {
        'type': schema_utils.SCHEMA_TYPE_DICT,
        'properties': [{
            'name': 'language_code',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE,
                'validators': [{
                    'id': 'is_supported_audio_language_code',
                }]
            },
        }, {
            'name': 'explanation',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE
            }
        }]
    }
}

SET_OF_STRINGS_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_LIST,
    'items': {
        'type': schema_utils.SCHEMA_TYPE_UNICODE,
    },
    'validators': [{
        'id': 'is_uniquified',
    }],
}

SET_OF_CLASSROOM_DICTS_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_LIST,
    'items': {
        'type': schema_utils.SCHEMA_TYPE_DICT,
        'properties': [{
            'name': 'name',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE
            }
        }, {
            'name': 'url_fragment',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE,
                'validators': [{
                    'id': 'is_url_fragment',
                }, {
                    'id': 'has_length_at_most',
                    'max_value': constants.MAX_CHARS_IN_CLASSROOM_URL_FRAGMENT
                }]
            },
        }, {
            'name': 'course_details',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE,
                'ui_config': {
                    'rows': 8,
                }
            }
        }, {
            'name': 'topic_list_intro',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE,
                'ui_config': {
                    'rows': 5,
                }
            }
        }, {
            'name': 'topic_ids',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_LIST,
                'items': {
                    'type': schema_utils.SCHEMA_TYPE_UNICODE,
                },
                'validators': [{
                    'id': 'is_uniquified',
                }]
            }
        }]
    }
}

VMID_SHARED_SECRET_KEY_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_LIST,
    'items': {
        'type': schema_utils.SCHEMA_TYPE_DICT,
        'properties': [{
            'name': 'vm_id',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE
            }
        }, {
            'name': 'shared_secret_key',
            'schema': {
                'type': schema_utils.SCHEMA_TYPE_UNICODE
            }
        }]
    }
}

BOOL_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_BOOL
}

UNICODE_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_UNICODE
}

FLOAT_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_FLOAT
}

INT_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_INT
}

POSITIVE_INT_SCHEMA = {
    'type': schema_utils.SCHEMA_TYPE_CUSTOM,
    'obj_type': 'PositiveInt'
}