import { View } from '../View';
import { LoadOptions } from './LoadOptions';
import { Venue } from './Venue';
import { ViewCreateOptions } from './ViewCreateOptions';

/**
 * This interface is the main contract. It allows loading and unloading Venues.
 *
 * It will be created by a factory method call like "{@link createVisioOne | createVisioOne()}"
 */
export interface VisioOne {
    /**
     * This method will load the venue data given a hash and the other options.
     *
     * Note that when it is not used anymore, the venue must be unloaded, using the {@link unloadVenue} method.
     *
     * @param options the options used to load the venue.
     * @return a Promise that will resolve on the loaded venue
     * @throws {@link VenueNotFoundError} the venue cannot be found either because the hash is invalid or the baseURL is invalid.
     * @throws {@link UnauthorizedError} the venue cannot be found (or loaded) because the authorization token is missing or invalid.
     * @example
     * // Load a Venue
     * const venue = await visioOne.loadVenue({ hash: 'kabcd' });
     */
    loadVenue(options: LoadOptions): Promise<Venue>;
    /**
     * This method will unload a venue and will destroy all the views attached to it.
     *
     * @param venue the venue to unload
     * @return this method is asynchronous, hence it returns a Promise
     */
    unloadVenue(venue: Venue): Promise<void>;
    /**
     * This method can be used to display an VisioOne related error.
     * When no container is provided the error will be displayed in the developer console.
     * @param error the error to be displayed. It can be cought by a try/catch block or a .catch method chained to a Promise.
     * @param container when specified and a loader has been initiated it will display the error within the loader UI.
     */
    showError(error: Error, container?: HTMLElement): void;
    /**
     * Show the Visioglobe loader in the specified container.
     * This loader will automatically be removed after the createView method is fulfilled.
     * @param container an Element where the loader must be created.
     */
    showLoader(container: HTMLElement): void;
    /**
     * Creates a view in order to have a visual representation of the venue.
     * @param container an Element where the view content will reside. The potential content of this element will be removed when the view will be created.
     * @param venue The Venue that'll be used as provider for data to display in the View.
     * @param options Parameters to custom the view creation.
     * @return a Promise to a view.
     * @category View
     */
    createView(container: HTMLElement, venue: Venue, options?: ViewCreateOptions): Promise<View>;
    /**
     * Destroy the view and free all the resources that were used by it.
     * @param view the view to destroy
     * @return this method is asynchronous but do not return a value that can be exploited later.
     * @category View
     */
    destroyView(view: View): Promise<void>;
    /**
     * Retrieve the VisioOne version.
     */
    get version(): string;
}
