text: import { default as Window } from './../UI/Window';
  
  export default class BroadcastReceiver {
  
  	constructor (object) {
  		if (object && object.apiName && object.apiName.endsWith('.Android.BroadcastReceiver')) {
  			this._object = object;
  		} else {
  			this._object = Titanium.Android.createBroadcastReceiver(normalize(object));
  		}
  	}
  
  	// constants
  	static get apiName () {
  		return Titanium.Android.BroadcastReceiver.apiName;
  	}
  
  	// properties
  	get apiName () {
  		return this._object.apiName;
  	}
  	get bubbleParent () {
  		return this._object.bubbleParent;
  	}
  	set bubbleParent (value) {
  		this._object.bubbleParent = value;
  	}
  	get lifecycleContainer () {
  		return new Window(this._object.lifecycleContainer);
  	}
  	set lifecycleContainer (value) {
  		this._object.lifecycleContainer = value;
  	}
  	get onReceived () {
  		return this._object.onReceived;
  	}
  	set onReceived (value) {
  		this._object.onReceived = value;
  	}
  	get url () {
  		return this._object.url;
  	}
  	set url (value) {
  		this._object.url = value;
  	}
  
  	// methods
  	addEventListener (name, callback) {
  		if (!callback) {
  			return new Promise(resolve => this._object.addEventListener(name, resolve));
  		}
  		return this._object.addEventListener(name, callback);
  	}
  	applyProperties (props) {
  		props = normalize(props);
  		return this._object.applyProperties(props);
  	}
  	fireEvent (name, event) {
  		event = normalize(event);
  		return this._object.fireEvent(name, event);
  	}
  	removeEventListener (name, callback) {
  		if (!callback) {
  			return new Promise(resolve => this._object.removeEventListener(name, resolve));
  		}
  		return this._object.removeEventListener(name, callback);
  	}
  	getApiName () {
  		return this._object.getApiName();
  	}
  	getBubbleParent () {
  		return this._object.getBubbleParent();
  	}
  	setBubbleParent (bubbleParent) {
  		return this._object.setBubbleParent(bubbleParent);
  	}
  	getLifecycleContainer () {
  		return new Window(this._object.getLifecycleContainer());
  	}
  	setLifecycleContainer (lifecycleContainer) {
  		lifecycleContainer = normalize(lifecycleContainer);
  		return this._object.setLifecycleContainer(lifecycleContainer);
  	}
  	getOnReceived () {
  		return this._object.getOnReceived();
  	}
  	setOnReceived (onReceived) {
  		return this._object.setOnReceived(onReceived);
  	}
  	getUrl () {
  		return this._object.getUrl();
  	}
  	setUrl (url) {
  		return this._object.setUrl(url);
  	}
  
  	// modules
  };
  Object.freeze(BroadcastReceiver);
  
  function normalize (object) {
  	if (typeof object === 'object') {
  		if (object._object) {
  			return object._object;
  		}
  
  		for (let key in object) {
  			if (typeof object[key] === 'object') {
  				if (object[key]._object) {
  					object[key] = object[key]._object;
  				}
  			}
  		}
  	}
  
  	return object;
  }