import TextureOptions from "../textures/TextureOptions";
import TextureAtlas from "../textures/TextureAtlas";
import Texture from "../textures/Texture";
import BitmapFont from "../text/BitmapFont";
import EventDispatcher from "../events/EventDispatcher";
import DataLoader from "./DataLoader";
import AssetFactory from "./AssetFactory";
import ByteArray from "openfl/utils/ByteArray";
import SoundTransform from "openfl/media/SoundTransform";
import SoundChannel from "openfl/media/SoundChannel";
import Sound from "openfl/media/Sound";
import Vector from "openfl/Vector";
declare namespace starling.assets {
	/**
	 *  Dispatched when all textures have been restored after a context loss. 
	 */
	export class AssetManager extends EventDispatcher {
		/**
		 *  Create a new instance with the given scale factor. 
		 */
		constructor(scaleFactor?: number);
		/**
		 *  Disposes all assets and purges the queue.
		 *      *
		 *      *  <p>Beware that all references to the assets will remain intact, even though the assets
		 *      *  are no longer valid. Call 'purge' if you want to remove all resources and reuse
		 *      *  the AssetManager later.</p>
		 *      
		 */
		dispose(): void;
		/**
		 *  Removes assets of all types (disposing them along the way), empties the queue and
		 *      *  aborts any pending load operations. 
		 */
		purge(): void;
		/**
		 *  Enqueues one or more raw assets; they will only be available after successfully
		 *      *  executing the "loadQueue" method. This method accepts a variety of different objects:
		 *      *
		 *      *  <ul>
		 *      *    <li>Strings or URLRequests containing an URL to a local or remote resource. Supported
		 *      *        types: <code>png, jpg, gif, atf, mp3, xml, fnt, json, binary</code>.</li>
		 *      *    <li>Instances of the File class (AIR only) pointing to a directory or a file.
		 *      *        Directories will be scanned recursively for all supported types.</li>
		 *      *    <li>Classes that contain <code>static</code> embedded assets.</li>
		 *      *    <li>If the file extension is not recognized, the data is analyzed to see if
		 *      *        contains XML or JSON data. If it's neither, it is stored as ByteArray.</li>
		 *      *  </ul>
		 *      *
		 *      *  <p>Suitable object names are extracted automatically: A file named "image.png" will be
		 *      *  accessible under the name "image". When enqueuing embedded assets via a class,
		 *      *  the variable name of the embedded object will be used as its name. An exception
		 *      *  are texture atlases: they will have the same name as the actual texture they are
		 *      *  referencing.</p>
		 *      *
		 *      *  <p>XMLs are made available via "getXml()"; this includes XMLs containing texture
		 *      *  atlases or bitmap fonts, which are processed along the way. Bitmap fonts are also
		 *      *  registered at the TextField class.</p>
		 *      *
		 *      *  <p>If you pass in JSON data, it will be parsed into an object and will be available via
		 *      *  "getObject()".</p>
		 *      
		 */
		enqueue(assets: Array<any>): void;
		/**
		 *  Enqueues a single asset with a custom name that can be used to access it later.
		 *      *  If the asset is a texture, you can also add custom texture options.
		 *      *
		 *      *  @param asset    The asset that will be enqueued; accepts the same objects as the
		 *      *                  'enqueue' method.
		 *      *  @param name     The name under which the asset will be found later. If you pass null or
		 *      *                  omit the parameter, it's attempted to generate a name automatically.
		 *      *  @param options  Custom options that will be used if 'asset' points to texture data.
		 *      *  @return         the name with which the asset was registered.
		 *      
		 */
		enqueueSingle(asset: any, name?: string, options?: TextureOptions): string;
		/**
		 *  Removes the asset(s) with the given name(s) from the queue. Note that this won't work
		 * 	 *  after loading has started, even if these specific assets have not yet been processed. 
		 */
		dequeue(assetNames: Array<string>): void;
		/**
		 *  Empties the queue and aborts any pending load operations. 
		 */
		purgeQueue(): void;
		/**
		 *  Loads all enqueued assets asynchronously. The 'onComplete' callback will be executed
		 *      *  once all assets have been loaded - even when there have been errors, which are
		 *      *  forwarded to the optional 'onError' callback. The 'onProgress' function will be called
		 *      *  with a 'ratio' between '0.0' and '1.0' and is also optional. Furthermore, all
		 *      *  parameters of all the callbacks are optional.
		 *      *
		 *      *  <p>When you call this method, the manager will save a reference to "Starling.current";
		 *      *  all textures that are loaded will be accessible only from within this instance. Thus,
		 *      *  if you are working with more than one Starling instance, be sure to call
		 *      *  "makeCurrent()" on the appropriate instance before processing the queue.</p>
		 *      *
		 *      *  @param onComplete   <code>function(manager:AssetManager):void;</code>
		 *      *  @param onError      <code>function(error:String, asset:AssetReference):void;</code>
		 *      *  @param onProgress   <code>function(ratio:Number):void;</code>
		 *      
		 */
		loadQueue(onComplete: () => void, onError?: (arg0: string) => void, onProgress?: (arg0: number) => void): void;
		/**
		 *  Add an asset with a certain name and type.
		 *      *
		 *      *  <p>Beware: if the slot (name + type) was already taken, the existing object will be
		 *      *  disposed and replaced by the new one.</p>
		 *      *
		 *      *  @param name    The name with which the asset can be retrieved later. Must be
		 *      *                 unique within this asset type.
		 *      *  @param asset   The actual asset to add (e.g. a texture, a sound, etc).
		 *      *  @param type    The type of the asset. If omitted, the type will be determined
		 *      *                 automatically (which works for all standard types defined within
		 *      *                 the 'AssetType' class).
		 *      
		 */
		addAsset(name: string, asset: any, type?: string): void;
		/**
		 *  Retrieves an asset of the given type, with the given name. If 'recursive' is true,
		 *      *  the method will traverse included texture atlases and asset managers.
		 *      *
		 *      *  <p>Typically, you will use one of the type-safe convenience methods instead, like
		 *      *  'getTexture', 'getSound', etc.</p>
		 *      
		 */
		getAsset(type: string, name: string, recursive?: boolean): any;
		/**
		 *  Retrieves an alphabetically sorted list of all assets that have the given type and
		 *      *  start with the given prefix. If 'recursive' is true, the method will traverse included
		 *      *  texture atlases and asset managers. 
		 */
		getAssetNames(assetType: string, prefix?: string, recursive?: boolean, out?: Vector<string>): Vector<string>;
		/**
		 *  Removes the asset with the given name and type, and will optionally dispose it. 
		 */
		removeAsset(assetType: string, name: string, dispose?: boolean): void;
		/**
		 *  Returns a texture with a certain name. Includes textures stored inside atlases. 
		 */
		getTexture(name: string): Texture;
		/**
		 *  Returns all textures that start with a certain string, sorted alphabetically
		 *      *  (especially useful for "MovieClip"). Includes textures stored inside atlases. 
		 */
		getTextures(prefix?: string, out?: Vector<Texture>): Vector<Texture>;
		/**
		 *  Returns all texture names that start with a certain string, sorted alphabetically.
		 *      *  Includes textures stored inside atlases. 
		 */
		getTextureNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns a texture atlas with a certain name, or null if it's not found. 
		 */
		getTextureAtlas(name: string): TextureAtlas;
		/**
		 *  Returns all texture atlas names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getTextureAtlasNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns a sound with a certain name, or null if it's not found. 
		 */
		getSound(name: string): Sound;
		/**
		 *  Returns all sound names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getSoundNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Generates a new SoundChannel object to play back the sound. This method returns a
		 *      *  SoundChannel object, which you can access to stop the sound and to control volume. 
		 */
		playSound(name: string, startTime?: number, loops?: number, transform?: SoundTransform): SoundChannel;
		/**
		 *  Returns an XML with a certain name, or null if it's not found. 
		 */
		getXml(name: string): any;
		/**
		 *  Returns all XML names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getXmlNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns an object with a certain name, or null if it's not found. Enqueued JSON
		 *      *  data is parsed and can be accessed with this method. 
		 */
		getObject(name: string): any;
		/**
		 *  Returns all object names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getObjectNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns a byte array with a certain name, or null if it's not found. 
		 */
		getByteArray(name: string): ByteArray;
		/**
		 *  Returns all byte array names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getByteArrayNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns a bitmap font with a certain name, or null if it's not found. 
		 */
		getBitmapFont(name: string): BitmapFont;
		/**
		 *  Returns all bitmap font names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getBitmapFontNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Returns an asset manager with a certain name, or null if it's not found. 
		 */
		getAssetManager(name: string): AssetManager;
		/**
		 *  Returns all asset manager names that start with a certain string, sorted alphabetically.
		 *      *  If you pass an <code>out</code>-vector, the names will be added to that vector. 
		 */
		getAssetManagerNames(prefix?: string, out?: Vector<string>): Vector<string>;
		/**
		 *  Removes a certain texture, optionally disposing it. 
		 */
		removeTexture(name: string, dispose?: boolean): void;
		/**
		 *  Removes a certain texture atlas, optionally disposing it. 
		 */
		removeTextureAtlas(name: string, dispose?: boolean): void;
		/**
		 *  Removes a certain sound. 
		 */
		removeSound(name: string): void;
		/**
		 *  Removes a certain Xml object, optionally disposing it. 
		 */
		removeXml(name: string, dispose?: boolean): void;
		/**
		 *  Removes a certain object. 
		 */
		removeObject(name: string): void;
		/**
		 *  Removes a certain byte array, optionally disposing its memory right away. 
		 */
		removeByteArray(name: string, dispose?: boolean): void;
		/**
		 *  Removes a certain bitmap font, optionally disposing it. 
		 */
		removeBitmapFont(name: string, dispose?: boolean): void;
		/**
		 *  Removes a certain asset manager and optionally disposes it right away. 
		 */
		removeAssetManager(name: string, dispose?: boolean): void;
		/**
		 *  Registers a custom AssetFactory. If you use any priority > 0, the factory will
		 *      *  be called before the default factories. The final factory to be invoked is the
		 *      *  'ByteArrayFactory', which is using a priority of '-100'. 
		 */
		registerFactory(factory: AssetFactory, priority?: number): void;
		/**
		 *  Unregisters the specified AssetFactory. 
		 */
		unregisterFactory(factory: AssetFactory): void;
		/**
		 *  When activated, the class will trace information about added/enqueued assets.
		 *      *  @default true 
		 */
		get verbose(): boolean;
		set verbose(value: boolean)
		/**
		 *  Returns the number of raw assets that have been enqueued, but not yet loaded. 
		 */
		get numQueuedAssets(): number;
		/**
		 *  The maximum number of parallel connections that are spawned when loading the queue.
		 *      *  More connections can reduce loading times, but require more memory. @default 3. 
		 */
		get numConnections(): number;
		set numConnections(value: number)
		/**
		 *  Textures will be created with the options set up in this object at the time of
		 *      *  enqueuing. 
		 */
		get textureOptions(): TextureOptions;
		set textureOptions(value: TextureOptions)
		/**
		 *  The DataLoader is used to load any data from files or URLs. If you need to customize
		 *      *  its behavior (e.g. to add a caching mechanism), assign your custom instance here. 
		 */
		get dataLoader(): DataLoader;
		set dataLoader(value: DataLoader)
		/**
		 *  Indicates if bitmap fonts should be registered with their "face" attribute from the
		 *      *  font XML file. Per default, they are registered with the name of the texture file.
		 *      *  @default false 
		 */
		get registerBitmapFontsWithFontFace(): boolean;
		set registerBitmapFontsWithFontFace(value: boolean)
	}
}
export default starling.assets.AssetManager;