(function() {
// $source: com/ibm/rave/accessibility/internal/nativeImpl/ModuleHeader
/************************************************************************
** IBM Confidential
**
** IBM Business Analytics: Rapidly Adaptive Visualization Engine
**
** (C) Copyright IBM Corp. 2014, 2015
**
** The source code for this program is not published or otherwise divested of its trade secrets, 
** irrespective of what has been deposited with the U.S. Copyright Office.
************************************************************************/
// setup 
var rave = window["rave"], rave_document = rave["_"]["rave_document"], rave_externs={},
	com_ibm_rave_core_Rave = rave,
	com_ibm_rave_core_nativeImpl_Declare = rave["_"]["com_ibm_rave_core_nativeImpl_Declare"],
	com_ibm_rave_core_selector_Selector = rave["internal"]["Selector"],
	com_ibm_rave_core_selector_SelectorDelegate = rave["internal"]["SelectorDelegate"],
	com_ibm_rave_navigation_focus_FocusController = rave["navigation"]["internal"]["FocusController"],
	com_ibm_rave_navigation_Navigation = rave["navigation"];

// $source: com/ibm/rave/accessibility/AccessibilityConstants
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
var com_ibm_rave_accessibility_AccessibilityConstants = rave_externs["AccessibilityConstants"] = {


};

/**
 * Key for the accessibility selector. To access accessibility methods on a selector, get the accessibility selector from the core selector this way: <code> AccessibilitySelector a11ySelector = (AccessibilitySelector) Rave.select("id").extension( Accessibility.SELECTOR_ID); </code> 
 */
/** @expose */ 
com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID = "raveAccessibility";
/**
 * Property key for accessible info. The accessible info must be of type {@link (Object) AccessibleInfo} .
 */
/** @expose */ 
com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY = "__accessibleInfo__";
/**
 * Property key for shadow tree builder. The shadow tree builder must be of type  {@link (com.ibm.rave.accessibility.ShadowTreeBuilder) ShadowTreeBuilder} .
 */
/** @expose */ 
com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY = "__shadowTreeBuilder__";


// $source: com/ibm/rave/accessibility/internal/AccessibleNavigationSceneNodeExtension
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/core/Rave (static) // Rave
//@import com/ibm/rave/accessibility/internal/AccessibilityUtil (runtime) // getShadowTreeBuilder, recursiveSetShadowTreeBuilder
//@import com/ibm/rave/accessibility/AccessibilityConstants (runtime) // AccessibilityConstants
var com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension = {

	//constructor : function() {}
};

com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.extend = function(baseNode) {
	var oriAppendChild = baseNode.appendChild;
	baseNode.appendChild = function(node) {
		oriAppendChild.call(this, node);
		com_ibm_rave_core_Rave.configuration.extendRecursive(node);
		var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
		if (builder) {
			com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, builder);
			builder.onAppend(this, node);
		}
	};
	var oriInsertBefore = baseNode.insertBefore;
	baseNode.insertBefore = function(node, before) {
		oriInsertBefore.call(this, node, before);
		com_ibm_rave_core_Rave.configuration.extendRecursive(node);
		var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
		if (builder) {
			com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, builder);
			builder.onInsert(this, node, before);
		}
	};
	var oriRemoveChild = baseNode.removeChild;
	baseNode.removeChild = function(node) {
		var i = this.rave_getChildNodes().indexOf(node);
		if (i != -1) {
			oriRemoveChild.call(this, node);
			com_ibm_rave_core_Rave.configuration.extendRecursive(node);
			var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(node);
			if (builder) {
				builder.onRemove(this, node, i);
				com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, null);
			}
			return true;
		}
		return false;
	};
	var oriSetProperty = baseNode.rave_setProperty;
	baseNode.rave_setProperty = function(key, value) {
		oriSetProperty.call(this, key, value);
		if (com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY == key) {
			var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
			if (builder) {
				builder.onChange(this);
			}
		}
	};
};

com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.register = function() {
	com_ibm_rave_core_Rave.configuration.addSceneNodeExtensionFactory("http://www.w3.org/2000/svg", function(node, context) {
		if ((context && context.rave_hasProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY)) || node.rave_hasProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY)) {
			com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.extend(node);
		}
	}, 0);
};


// $source: com/ibm/rave/accessibility/internal/AccessibilityUtil
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/accessibility/AccessibilityConstants (static) // AccessibilityConstants
//@import com/ibm/rave/core/selector/Selector (static) // extension
//@import com/ibm/rave/accessibility/selector/AccessibilitySelector (runtime) // new
var com_ibm_rave_accessibility_internal_AccessibilityUtil = {

	//constructor : function() {}
};

com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder = function(node) {
	return node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY);
};

com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo = function(node) {
	return node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY) != null;
};

com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder = function(node, builder) {
	node.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY, builder);
	if (node.rave_hasChildNodes()) {
		for (var __i_enFor0 = 0, __exp_enFor0 = node.rave_getChildNodes(), __len_enFor0 = __exp_enFor0.length;
				__i_enFor0 < __len_enFor0; ++__i_enFor0) {
			var child = __exp_enFor0[__i_enFor0];
			com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(child, builder);
		}
	}
};

com_ibm_rave_accessibility_internal_AccessibilityUtil.registerSelector = function() {
	com_ibm_rave_core_selector_Selector.extension(com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID, function() {
		return new com_ibm_rave_accessibility_selector_AccessibilitySelector();
	});
};


// $source: com/ibm/rave/accessibility/selector/AccessibilitySelector
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
//@import com/ibm/rave/core/selector/SelectorDelegate (loadtime) // superclass
//@import com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext (runtime) // getDescription, setDescription
//@import com/ibm/rave/accessibility/AccessibilityConstants (runtime) // AccessibilityConstants
/**
 * Accessibility extension to  {@link (com.ibm.rave.core.selector.SelectorDelegate) SelectorDelegate} . Adds the ability to perform accessibility related functions to a selector.
 */
var com_ibm_rave_accessibility_selector_AccessibilitySelector = rave_externs["AccessibilitySelector"] = com_ibm_rave_core_nativeImpl_Declare(com_ibm_rave_core_selector_SelectorDelegate, {

	/**
	 * Constructor
	 */
	/** @expose */ 
	constructor : function() {},

	/**
	 * @see   {@link this.SelectorDelegate#this.create}
	 */
	/** @expose */ 
	create : function(s) {
		var as = new com_ibm_rave_accessibility_selector_AccessibilitySelector();
		return as.setDelegate(s);
	},

	/**
	 * Get the accessible description for the first SceneNode in this Selector. In JavaScript, this gets the "aria-label".
	 * @return (String)  the accessible description of the first SceneNode in this Selector
	 */
	description$0 : function() {
		var node = this.node();
		var owner = node ? node.rave_getOwner() : null;
		return !owner ? null : com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.getDescription(owner);
	},

	/**
	 * Set an accessible description for each owner of SceneNode in this Selector. In JavaScript, this sets the "aria-label".
	 * @param (String) description the description
	 * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector)  this  {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
	 */
	description$1 : function(description) {
		this.each(function(data, index, groupIndex) {
			var owner = this.rave_getOwner();
			if (owner) {
				com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.setDescription(owner, description);
				if (description != null) {
					var info = owner.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
					if (!info) {
						info = {};
						info["label"] = description;
						owner.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
					}
				}
			}
		});
		return this;
	},

	/**
	 * Set an accessible description for each owner of SceneNode in this Selector. In JavaScript, this sets the "aria-label".
	 * @param (com.ibm.rave.core.selector.ValueFunction) valueFunction a function which returns a description
	 * @return (com.ibm.rave.core.selector.Selector)  this  {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
	 */
	description$2 : function(valueFunction) {
		this.each(function(data, index, groupIndex) {
			var owner = this.rave_getOwner();
			if (owner) {
				var value = valueFunction.call(owner, owner.rave_getData(), index, groupIndex);
				var description = value != null ? value + "" : "";
				com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.setDescription(owner, description);
				if (description != null) {
					var info = owner.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
					if (!info) {
						info = {};
						info["label"] = description;
						owner.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
					}
				}
			}
		});
		return this;
	},

	/**
	 * Get the accessible info for the first SceneNode in this Selector.
	 * @return (Object)  the accessible info of the first SceneNode in this Selector
	 */
	info$0 : function() {
		var node = this.node();
		return !node ? null : node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
	},

	/**
	 * Set an accessible info for each SceneNode in this Selector.
	 * @param (Object) info the accessible info
	 * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector)  this  {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
	 */
	info$1 : function(info) {
		this.each(function(data, index, groupIndex) {
			this.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
		});
		return this;
	},

	/**
	 * Set an accessible info for each SceneNode in this Selector.
	 * @param (com.ibm.rave.core.selector.ValueFunction) valueFunction a function which returns a  {@link (Object) AccessibleInfo}
	 * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector)  this  {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
	 */
	info$2 : function(valueFunction) {
		this.each(function(data, index, groupIndex) {
			this.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, valueFunction.call(this, data, index, groupIndex));
		});
		return this;
	},

	/** @expose */ 
	description : function(a0) {
		var args = arguments;
		if (args.length == 0) {
			return this.description$0();
		}
		if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
			return this.description$1(a0);
		}
		return this.description$2(a0);
	},

	/** @expose */ 
	info : function(a0) {
		var args = arguments;
		if (args.length == 0) {
			return this.info$0();
		}
		if (args.length == 1 && typeof a0 === "function") {
			return this.info$2(a0);
		}
		return this.info$1(a0);
	}
});


// $source: com/ibm/rave/accessibility/internal/nativeImpl/ShadowDOMBuilder
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2014, 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/

// @import com/ibm/rave/core/nativeImpl/Declare
// @import com/ibm/rave/accessibility/AccessibilityConstants
// @import com/ibm/rave/core/internal/nativeImpl/event/Event

var com_ibm_rave_accessibility_internal_nativeImpl_ShadowDOMBuilder = (function() {
	
	var shadowDomNodeKey = "__shadowDomNode__";
	var sceneNodeKey = "__sceneNode__";
	
	function removeShadowDomNode(domNode) {
		if (domNode[shadowDomNodeKey]) {
			delete domNode[shadowDomNodeKey][sceneNodeKey];
			delete domNode[shadowDomNodeKey];
		}
		var childNodes = domNode.childNodes;
		for (var i = 0; i < childNodes.length; i++) {
			removeShadowDomNode(childNodes[i]);
		}
	}
	
	function setAttributes(shadowDomNode, info) {
		// set the known properties
		shadowDomNode.setAttribute("aria-label", info["label"] || "");
		shadowDomNode.setAttribute("aria-hint", info["hint"] || "");
		shadowDomNode.setAttribute("role", info["role"] || "");
		
		// clear all custom properties
		for (var i = 0, nodeName, atts = shadowDomNode.attributes; i < atts.length; i++) {
			nodeName = atts[i].nodeName;
			if (nodeName.indexOf("data-") == 0) {
				shadowDomNode.removeAttribute(nodeName);
			}
		}
		
		// set all custom properties
		for (var key in info) {
			if (info.hasOwnProperty(key)) {
				switch (key) {
				case "label":
				case "hint":
				case "role":
					break;
				default:
					shadowDomNode.setAttribute("data-" + key, info[key]);
				}
			}
		}
		
	}
	
	function setText(shadowDomNode, info) {
		if (info && info["label"] && info["label"].length) {
			shadowDomNode.textContent = info["label"];
		}
	}
	
	function appendOrInsert(parent, child, before) {
		var info = child.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
		
		if (info) {
			var shadowDomNode = child.rave_getProperty(shadowDomNodeKey),
					ps = rave.select(parent.rave_getProperty(shadowDomNodeKey)),
					ul = ps.select("ul");
			if (!shadowDomNode) {
				if (ul.empty()) {
					ul = ps.append("ul");
				}
				
				shadowDomNode = rave_document.createElement("li");
				shadowDomNode[sceneNodeKey] = child;
				child.rave_setProperty(shadowDomNodeKey, shadowDomNode);
				
				setAttributes(shadowDomNode, info);
				setText(shadowDomNode, info);
				
				// recursively add its children
				if (child.rave_hasChildNodes()) {
					var children = child.rave_getChildNodes();
					for (var i = 0; i < children.length; i++) {
						this.onAppend(child, children[i]);
					}
				}
			}
			
			// get the real ul dom node
			ul = ul.node();
			
			if (arguments.length == 3) {
				ul.insertBefore(shadowDomNode, before.rave_getProperty(shadowDomNodeKey));
			} else {
				ul.appendChild(shadowDomNode);
			}
		}
	}
	
	return com_ibm_rave_core_nativeImpl_Declare({
		onAppend : appendOrInsert,
		
		onInsert : appendOrInsert,
		
		onRemove : function(parent, child, index) {
			var shadowDomNode = child[shadowDomNodeKey], newFocus;
			if (shadowDomNode == this._currentFocus) {
				newFocus = shadowDomNode.previousElementSibling;
				if (!newFocus) {
					newFocus = shadowDomNode.nextElementSibling;
					if (!newFocus) {
						// -> ul -> next parent
						newFocus = shadowDomNode.parentNode.parentNode;
					}
				}
			}
			
			this.tearDown(child);
			
			if (newFocus) {
				// select the scene node
				this._focusEventHandler.fireFocus(newFocus[sceneNodeKey]);
			}
		},
		
		onChange : function(domNode) {
			var info = domNode.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY),
			shadowDomNode = domNode.rave_getProperty(shadowDomNodeKey);
	
			if (!info) {
				// if no info remove the shadow dom node
				if (shadowDomNode) {
					this.tearDown(domNode);
				}
			} else if (!shadowDomNode) {
				var parentNode = domNode.parentNode;
				if (parentNode) {
					appendOrInsert(parentNode, domNode);
				}
			} else {
				// update attributes
				setAttributes(shadowDomNode, info);
				
				// cannot use #setText because text may be spread across multiple text nodes
				// remove all text nodes
				var childNodes = shadowDomNode.childNodes;
				for (var i = 0; i < childNodes.length; i++) {
					if (childNodes[i].nodeType == 3) {
						shadowDomNode.removeChild(childNodes[i]);
					}
				}
				if (info.label && info.label.length) {
					// add new text node
					shadowDomNode.insertBefore(rave_document.createTextNode(info.label), shadowDomNode.firstChild);
				}
			}
		},
		
		setUp : function(domNode, focusEventHandler) {
			this._focusEventHandler = focusEventHandler;
			var shadowDomNode = domNode[shadowDomNodeKey],
					info = domNode.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
			
			if (!info) {
				info = {};
				domNode.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
			}
			
			if (!shadowDomNode) {
				shadowDomNode = rave_document.createElement("div");
				shadowDomNode[sceneNodeKey] = domNode;
				shadowDomNode.setAttribute("class", "rave-a11y");
				
				rave.select(shadowDomNode).style({
					"width": 0,
					"height": 0,
					"left": -10000,
					"top": -10000,
					"position": "absolute",
					"overflow": "hidden"
				}, "important");
				domNode.parentNode.insertBefore(shadowDomNode, domNode);
				domNode[shadowDomNodeKey] = shadowDomNode;
				
				setAttributes(shadowDomNode, info);
				setText(shadowDomNode, info);
				
				if (domNode.rave_hasChildNodes()) {
					var children = domNode.rave_getChildNodes();
					for (var i = 0; i < children.length; i++) {
						this.onAppend(domNode, children[i]);
					}
				}
				
				// make the visualization focusable
				this._tabIndex = +domNode.getAttribute("tabindex");
				domNode.removeAttribute("tabindex");
				
				// set the current focus to the root shadow dom node
				this._currentFocus = shadowDomNode;
				this._currentFocus.setAttribute("tabindex", this._tabIndex);
			}
		},
		
		tearDown : function(domNode) {
			shadowDomNode = domNode[shadowDomNodeKey];
			
			if (shadowDomNode) {
				// remove from the DOM
				shadowDomNode.parentNode.removeChild(shadowDomNode);
				// remove stored data from the scene tree
				removeShadowDomNode(domNode);
			}
		},
			
		focus : function(domNode) {
			var shadowDomNode;
			if (domNode) {
				shadowDomNode = domNode[shadowDomNodeKey];
			}
			if (this._currentFocus != shadowDomNode) {
				var refocus = document.activeElement === this._currentFocus;
				if (this._currentFocus) {
					this._currentFocus.removeAttribute("tabindex");
					this._currentFocus.blur();
				}
				if (shadowDomNode) {
					shadowDomNode.setAttribute("tabindex", this._tabIndex);
					if (refocus) {
						shadowDomNode.focus();
					}
				}
				this._currentFocus = shadowDomNode;
			}
		}
	});
})();

// $source: com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2014
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/

// Utility to setup accessible context on a scene node

// @import ./ShadowDOMBuilder

var com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext = {

	getDescription : function(node) {
		return node.getAttribute("aria-label");
	},
	
	setDescription : function(node, description) {
		node.setAttribute("aria-label", description);
	},
	
	createShadowTreeBuilder : function() {
		return new com_ibm_rave_accessibility_internal_nativeImpl_ShadowDOMBuilder();
	}

};


// $source: com/ibm/rave/accessibility/navigation/AccessibleNavigation
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
//@import com/ibm/rave/accessibility/navigation/AccessibleKeyboard (runtime) // new
var com_ibm_rave_accessibility_navigation_AccessibleNavigation = com_ibm_rave_core_nativeImpl_Declare({

	/**
	 * Creates a new instance of  {@link (com.ibm.rave.accessibility.navigation.AccessibleKeyboard) AccessibleKeyboard} .
	 * @return (com.ibm.rave.accessibility.navigation.AccessibleKeyboard)  new instance of  {@link (com.ibm.rave.accessibility.navigation.AccessibleKeyboard) AccessibleKeyboard}
	 */
	/** @expose */ 
	keyboard : function() {
		return new com_ibm_rave_accessibility_navigation_AccessibleKeyboard();
	}

	//constructor : function() {}
});

/** @expose */ 
com_ibm_rave_accessibility_navigation_AccessibleNavigation.INSTANCE = new com_ibm_rave_accessibility_navigation_AccessibleNavigation();

// $source: com/ibm/rave/accessibility/Accessibility
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/accessibility/internal/AccessibleNavigationSceneNodeExtension (static) // register
//@import com/ibm/rave/accessibility/internal/AccessibilityUtil (static) // registerSelector
//@import com/ibm/rave/accessibility/AccessibilityConstants (static) // AccessibilityConstants
//@import com/ibm/rave/accessibility/navigation/AccessibleNavigation (static) // AccessibleNavigation
/**
 * The accessibility layer. Provides entry points into functionality provided by the accessibility layer.
 */
var com_ibm_rave_accessibility_Accessibility = rave_externs["Accessibility"] = {

	//constructor : function() {}
};

/**
 * Initialize the Accessibility feature.  This needs to be called before using any accessibility features.  
 */
/** @expose */ 
com_ibm_rave_accessibility_Accessibility.init = function() {
	com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.register();
	com_ibm_rave_accessibility_internal_AccessibilityUtil.registerSelector();
};

/**
 * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY
 */
/** @expose */ 
com_ibm_rave_accessibility_Accessibility.ACCESSIBLE_INFO_KEY = com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY;
/**
 * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY
 */
/** @expose */ 
com_ibm_rave_accessibility_Accessibility.SHADOW_TREE_BUILDER_KEY = com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY;
/**
 * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID
 */
/** @expose */ 
com_ibm_rave_accessibility_Accessibility.SELECTOR_ID = com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID;
/**
 * @see (com.ibm.rave.accessibility.navigation.AccessibleNavigation) AccessibleNavigation
 */
/** @expose */ 
com_ibm_rave_accessibility_Accessibility.navigation = com_ibm_rave_accessibility_navigation_AccessibleNavigation.INSTANCE;

// $source: com/ibm/rave/accessibility/internal/nativeImpl/Module
/************************************************************************
** IBM Confidential
**
** IBM Business Analytics: Rapidly Adaptive Visualization Engine
**
** (C) Copyright IBM Corp. 2014
**
** The source code for this program is not published or otherwise divested of its trade secrets, 
** irrespective of what has been deposited with the U.S. Copyright Office.
************************************************************************/
// @OnDemandLoad("rave-accessibility")

// Must be the first import
// @import ./ModuleHeader

// Other module dependencies
// @import com/ibm/rave/navigation/internal/nativeImpl/Module

// @import com/ibm/rave/accessibility/Accessibility

com_ibm_rave_accessibility_Accessibility.init();

// expose a11y class to the global variable rave
rave["accessibility"] = com_ibm_rave_accessibility_Accessibility;

// $source: com/ibm/rave/accessibility/navigation/AccessibleKeyboard
/************************************************************************
 ** IBM Confidential
 **
 ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
 **
 ** (C) Copyright IBM Corp. 2015
 **
 ** The source code for this program is not published or otherwise divested of its trade secrets, 
 ** irrespective of what has been deposited with the U.S. Copyright Office.
 ************************************************************************/
// GENERATED
//@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
//@import com/ibm/rave/navigation/Navigation (runtime) // keybinding
//@import com/ibm/rave/core/Rave (runtime) // select, Rave
//@import com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext (runtime) // createShadowTreeBuilder
//@import com/ibm/rave/navigation/focus/FocusController (runtime) // nextFocusableNode, nextLevelFocusableNode, previousFocusableNodeFromEnd, previousLevelFocusableNode, nextFocusableNodeFromStart, previousFocusableNode
//@import com/ibm/rave/accessibility/internal/AccessibilityUtil (runtime) // getShadowTreeBuilder, recursiveSetShadowTreeBuilder, hasAccessibleInfo
var com_ibm_rave_accessibility_navigation_AccessibleKeyboard = rave_externs["AccessibleKeyboard"] = com_ibm_rave_core_nativeImpl_Declare({

	//kb : null,

	//eventHandler : null,

	//treeBuilder : null,

	//next : null,

	//previous : null,

	//nextStep : null,

	//previousStep : null,

	//first : null,

	//last : null,

	//nextLevel : null,

	//previousLevel : null,

	_$functionClassMethod : function() {
		var _$self = function(args) {
			if (args !== null || arguments.length > 1){
				args = Array.prototype.slice.call(arguments, 0);
			}
			{
				_$self.bind(args[0]);
				return null;
			}
		};
		return _$self;
	},

	constructor : function() {
		this.kb = com_ibm_rave_navigation_Navigation.keybinding();
		this.eventHandler = com_ibm_rave_core_Rave.behavior.focusEventHandler();
		this.treeBuilder = function(data, index, groupIndex) {
			return com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.createShadowTreeBuilder();
		};

		{
			var self = this;
			this.next = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var nextSibling = focused;
						while ((nextSibling = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(nextSibling))) {
							if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(nextSibling)) {
								self.eventHandler.fireFocus(nextSibling);
								break;
							}
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.previous = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var previousSibling = focused;
						while ((previousSibling = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(previousSibling))) {
							if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(previousSibling)) {
								self.eventHandler.fireFocus(previousSibling);
								break;
							}
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.nextStep = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var stepCount = 0;
						var nextSibling = focused, temp = focused;
						while (stepCount < 20 && temp) {
							temp = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(temp);
							if (temp) {
								if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(temp)) {
									nextSibling = temp;
									stepCount++;
								}
							}
						}
						if (nextSibling != focused) {
							self.eventHandler.fireFocus(nextSibling);
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.previousStep = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var stepCount = 0;
						var previousSibling = focused, temp = focused;
						while (stepCount < 20 && temp) {
							temp = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(temp);
							if (temp) {
								if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(temp)) {
									previousSibling = temp;
									stepCount++;
								}
							}
						}
						if (previousSibling != focused) {
							self.eventHandler.fireFocus(previousSibling);
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.first = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var firstNode = com_ibm_rave_navigation_focus_FocusController.nextFocusableNodeFromStart(focused);
						if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(firstNode))) {
							while ((firstNode = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(firstNode))) {
								if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(firstNode)) {
									break;
								}
							}
						}
						if (firstNode && focused != firstNode) {
							self.eventHandler.fireFocus(firstNode);
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.last = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var lastNode = com_ibm_rave_navigation_focus_FocusController.previousFocusableNodeFromEnd(focused);
						if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(lastNode))) {
							while ((lastNode = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(lastNode))) {
								if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(lastNode)) {
									break;
								}
							}
						}
						if (lastNode && focused != lastNode) {
							self.eventHandler.fireFocus(lastNode);
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.nextLevel = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused) {
						if (focused.rave_hasChildNodes()) {
							var child = com_ibm_rave_navigation_focus_FocusController.nextLevelFocusableNode(focused);
							if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(child))) {
								while ((child = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(child))) {
									if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(child)) {
										break;
									}
								}
							}
							if (child) {
								self.eventHandler.fireFocus(child);
							}
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
			this.previousLevel = function(args) {
				if (args !== null || arguments.length > 1){
					args = Array.prototype.slice.call(arguments, 0);
				}
				{
					var focused = self.eventHandler.focusedNode;
					if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
						var parent = com_ibm_rave_navigation_focus_FocusController.previousLevelFocusableNode(focused);
						if (parent) {
							self.eventHandler.fireFocus(parent);
						}
					}
					rave.event.preventDefault();
					return null;
				}
			};
		}

		{
			this.kb.on(40, this.next).on(38, this.previous).on(34, this.nextStep).on(33, this.previousStep).on(36, this.first).on(35, this.last).on(39, this.nextLevel).on(37, this.previousLevel);
		}
	},

	/** @expose */ 
	bind : function(g) {
		var self = this;
		g.each(function(data, index, groupIndex) {
			var s = com_ibm_rave_core_Rave.select(this);
			var stb = self.treeBuilder.call(this, data, index, groupIndex);
			com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(this, stb);
			com_ibm_rave_core_Rave.configuration.extendRecursive(this);
			stb.setUp(this, self.eventHandler);
			s.on("ravefocus", com_ibm_rave_accessibility_navigation_AccessibleKeyboard.FOCUS_LISTENER);
			com_ibm_rave_core_Rave.select(this.rave_getOwner()).call(self.kb);
			s.property(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT, true);
			self.eventHandler.focusedNode = this;
		});
	},

	shadowTreeBuilder$0 : function() {
		return this.treeBuilder;
	},

	shadowTreeBuilder$1 : function(shadowTreeBuilder) {
		this.treeBuilder = shadowTreeBuilder;
		return this;
	},

	/** @expose */ 
	keyBinding : function() {
		return this.kb;
	},

	focusEventHandler$0 : function() {
		return this.eventHandler;
	},

	focusEventHandler$1 : function(handler) {
		this.eventHandler = handler;
		return this;
	},

	/** @expose */ 
	shadowTreeBuilder : function(a0) {
		var args = arguments;
		if (args.length == 0) {
			return this.shadowTreeBuilder$0();
		}
		return this.shadowTreeBuilder$1(a0);
	},

	/** @expose */ 
	focusEventHandler : function(a0) {
		var args = arguments;
		if (args.length == 0) {
			return this.focusEventHandler$0();
		}
		return this.focusEventHandler$1(a0);
	}
});

com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot = function(item) {
	return item.rave_getProperty(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT) != null;
};

com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT = "__rave-kbnav-root__";
com_ibm_rave_accessibility_navigation_AccessibleKeyboard.STEP = 20;

com_ibm_rave_accessibility_navigation_AccessibleKeyboard.FOCUS_LISTENER = function(data, index, groupIndex, event) {
	var stb = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(event.target);
	if (event.target) {
		stb.focus(event.target);
	} else {
		stb.focus(null);
	}
};

})();