/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Tiles
 */
import { IModelApp } from "../../../IModelApp";
import { MapLayerImageryProvider } from "../../internal";
/** Base class imagery map layer formats.  Subclasses should override formatId and [[MapLayerFormat.createImageryProvider]].
 * @internal
 */
export class MapBoxLayerImageryProvider extends MapLayerImageryProvider {
    constructor(settings) {
        super(settings, true);
        this._baseUrl = settings.url;
        this._zoomMin = 1;
        this._zoomMax = 20;
    }
    get tileWidth() { return 256; }
    get tileHeight() { return 256; }
    get minimumZoomLevel() { return this._zoomMin; }
    get maximumZoomLevel() { return this._zoomMax; }
    // construct the Url from the desired Tile
    async constructUrl(row, column, zoomLevel) {
        if (!this._settings.accessKey) {
            return "";
        }
        // from the template url, construct the tile url.
        // format: {baseUrl}/{tileSize}/{level}/{column}/{row}?access_token={token}
        let url = this._baseUrl.concat(this.tileWidth.toString());
        url = url.concat(`/${zoomLevel.toString()}/${column.toString()}/${row.toString()}`);
        url = url.concat(`?${this._settings.accessKey.key}=${this._settings.accessKey.value}`);
        return url;
    }
    addLogoCards(cards) {
        if (!cards.dataset.mapboxLogoCard) {
            cards.dataset.mapboxLogoCard = "true";
            cards.appendChild(IModelApp.makeLogoCard({ heading: "Mapbox", notice: IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.MapBoxCopyright") }));
        }
    }
    // no initialization needed for MapBoxImageryProvider.
    async initialize() { }
}
//# sourceMappingURL=MapBoxLayerImageryProvider.js.map