{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "title": "Map's inputs configuration",
    "description": "The Configuration of the map's inputs",
    "type": "object",
    "$id": "arlas-map.schema.json",
    "properties": {
        "displayScale": {
            "description": "Whether the scale is displayed",
            "type": "boolean"
        },
        "displayLayerSwitcher": {
            "description": "Whether the layer switcher controll is displayed. If not, the map component uses the default style group and with its default style.",
            "type": "boolean"
        },
        "maxWidthScale": {
            "description": "Max width of the scale in px. Default value is 100px.",
            "type": "number"
        },
        "unitScale": {
            "description": "Unit of the scale. Default value is 'metric'.",
            "type": "string"
        },
        "mapLayers": {
            "$id": "/properties/mapLayers",
            "type": "object",
            "properties": {
                "layers": {
                    "description": "List of layers",
                    "type": "array"
                },
                "events": {
                    "type": "object",
                    "properties": {
                        "onHover": {
                            "description": "List of layers ids to listen to on hover",
                            "type": "array"
                        },
                        "emitOnClick": {
                            "description": "List of layers ids to listen to on click event in order to emit features",
                            "type": "array"
                        },
                        "zoomOnClick": {
                            "description": "List of layers ids to listen to on click event in order to trigger zoom action",
                            "type": "array"
                        }
                    },
                    "required": [
                        "onHover", "emitOnClick", "zoomOnClick"
                    ]
                }
            },
            "required": [
                "layers", "events"
            ]
        },
        "mapSources": {
            "description": "List of sources to add to the map as basemaps",
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "description": "Id of the source.",
                        "type": "string"
                    },
                    "source": {
                        "description": "source.",
                        "type": "object",
                        "properties": {
                            "type": {
                                "description": "Type of the source. Possible values : 'vector' | 'raster' | 'geojson' | 'image' | 'video' | 'canvas'",
                                "type": "string"
                            },
                            "minzoom": {
                                "description": "Minimum zoom to display the source layers",
                                "type": "integer"
                            },
                            "maxzoom": {
                                "description": "Maximum zoom to display the source layers",
                                "type": "integer"
                            },
                            "url": {
                                "description": "Url to the source (for `vector`, `raster`, `image`, `video` types).",
                                "type": "string"
                            },
                            "tiles": {
                                "description": "List of tiles (for `vector` and `raster` types).",
                                "type": "array"
                            },
                            "coordinates": {
                                "description": "The 4 corners coordinates of the canvas/image/video, given as [longitude, latitude].",
                                "type": "array"
                            },
                            "data": {
                                "description": "A geojson object or a url to a geojson file (for `geosjson` type).",
                                "type": "array"
                            },
                            "canvas": {
                                "description": "Id of the canvas element (for `canvas` type)",
                                "type": "string"
                            },
                            "animate": {
                                "description": "Whether the canvas source is animated (for `canvas` type)",
                                "type": "boolean"
                            }
                        },
                        "required": [
                            "type"
                        ]
                    }
                },
                "required": [
                    "id", "source"
                ]
            }
        },
        "defaultBasemapStyle": {
            "description": "Defines the name and default basemap style.",
            "type": "object",
            "properties": {
                "name": {
                    "description": "name of the style",
                    "type": "string"
                },
                "styleFile": {
                    "description": "url to basemap style or a `maplibre.Style`",
                    "type": ["string", "object"]
                }
            },
            "required": [
                "name", "styleFile"
            ]
        },
        "basemapStyles": {
            "description": "List of basemaps styles",
            "type": "array",
            "items": {
                "description": "Defines the name and the basemap style.",
                "type": "object",
                "properties": {
                    "name": {
                        "description": "name of the style",
                        "type": "string"
                    },
                    "styleFile": {
                        "description": "url to basemap style or a `maplibre.Style`",
                        "type": ["string", "object"]
                    }
                },
                "required": [
                    "name", "styleFile"
                ]
            }
        },
        "initCenter": {
            "description": "Coordinates of the map's center when it's initialized.",
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": [
                {
                    "description": "Longitude",
                    "type": "number"
                },
                {
                    "description": "Latitude",
                    "type": "number"
                }
            ]
        },
        "initZoom": {
            "description": "Zoom of the map when it's initialized",
            "type": "number"
        },
        "minZoom": {
            "description": "Min zoom of the map",
            "type": "number"
        },
        "maxZoom": {
            "description": "Max zoom of the map",
            "type": "number"
        },
        "margePanForLoad": {
            "description": "Margin applied to the map extent. Data is loaded in all this extent",
            "type": "number"
        },
        "margePanForTest": {
            "description": "Margin applied to the map extent. Before loading data, the components checks first if there are features already loaded in this extent.",
            "type": "number"
        },
        "drawButtonEnabled": {
            "description": "Whether the draw tools are activated.",
            "type": "boolean"
        },
        "drawPolygonVerticesLimit": {
            "description": "Maximum number of vertices allowed when drawing a polygon."
        },
        "visualisationSetsConfig": {
            "description": "List of visualisation sets",
            "type": "array",
            "items": {
                "description": "A Visualisation set is an entity where layers are grouped together.",
                "type": "object",
                "properties": {
                    "name": {
                        "description": "Name of the visualisation set.",
                        "type": "string"
                    },
                    "layers": {
                        "description": "List of layers ids grouped in this visualisation set.",
                        "type": "array",
                        "items": {
                            "description": "layer id",
                            "type": "string"
                        }
                    },
                    "enabled": {
                        "description": "If enabled, all the layers can be displayed on the map, otherwise the layers are removed from the map.",
                        "type": "boolean"
                    }
                }
            }
        },
        "icons": {
            "description": "List of icons to add to the map and to use in layers styling.",
            "type": "array",
            "items": {
                "description": "Icon to add",
                "type": "object",
                "properties": {
                    "path": {
                        "description": "path to the icon. The icon should be placed at `assest/icons` folder and should be `png` or `jpeg`. Example : 'path': 'name_of_icon.png'",
                        "type": "string"
                    },
                    "recolorable": {
                        "description": "Whether to allow recolorising the icon or not.",
                        "type": "boolean"
                    }
                }
            }
        }
    },
    "required": [
        "mapLayers", "margePanForLoad", "margePanForTest"
    ]
}
