//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright © 2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;


namespace Css{
	
	/// <summary>
	/// A direction aware property. For example, margin-inline-start.
	/// </summary>
	
	public class DirectionAwareProperty:CssPropertyAlias{
		
		/// <summary>The logical index.</summary>
		public int LogicalIndex;
		
		public DirectionAwareProperty(){}
		
		public DirectionAwareProperty(CssProperty target,int[] index):base(target,index){
			
			// Last one becomes our logical index:
			LogicalIndex=index[index.Length-1];
			index[index.Length-1]=-1;
			
		}
		
		public override int RemapIndex(Css.Style style){
			
			// Only remap if we've got a CS:
			ComputedStyle cs=style as ComputedStyle;
			
			if(cs==null){
				return LogicalIndex;
			}
			
			// Get the mapping (typically pulls a cached version):
			int[] mapping=Css.Properties.SparkWritingSystem.GlobalProperty.RequireMap(cs);
			
			// Map the index:
			return mapping[LogicalIndex];
			
		}
		
	}
	
}