use crate::properties::{PropertyId, PropertyList, PropertyValue};
use crate::Result;
pub(super) fn expand_four_sides(
properties: &mut PropertyList,
value: &PropertyValue,
top_id: PropertyId,
right_id: PropertyId,
bottom_id: PropertyId,
left_id: PropertyId,
) -> Result<()> {
match value {
PropertyValue::List(values) => {
match values.len() {
1 => {
let val = values[0].clone();
properties.set(top_id, val.clone());
properties.set(right_id, val.clone());
properties.set(bottom_id, val.clone());
properties.set(left_id, val);
}
2 => {
let tb = values[0].clone();
let lr = values[1].clone();
properties.set(top_id, tb.clone());
properties.set(bottom_id, tb);
properties.set(right_id, lr.clone());
properties.set(left_id, lr);
}
3 => {
let top = values[0].clone();
let lr = values[1].clone();
let bottom = values[2].clone();
properties.set(top_id, top);
properties.set(right_id, lr.clone());
properties.set(left_id, lr);
properties.set(bottom_id, bottom);
}
4 => {
properties.set(top_id, values[0].clone());
properties.set(right_id, values[1].clone());
properties.set(bottom_id, values[2].clone());
properties.set(left_id, values[3].clone());
}
_ => {
if let Some(first) = values.first() {
let val = first.clone();
properties.set(top_id, val.clone());
properties.set(right_id, val.clone());
properties.set(bottom_id, val.clone());
properties.set(left_id, val);
}
}
}
}
_ => {
properties.set(top_id, value.clone());
properties.set(right_id, value.clone());
properties.set(bottom_id, value.clone());
properties.set(left_id, value.clone());
}
}
Ok(())
}