-const getBoxes = function getBoxes ({left, top, right, bottom}) {
- return [
- `box.ov."(${left},${top},${right},${bottom})"`,
- `box.ov."(${left+maxSize},${top+maxSize},${right+maxSize},${bottom+maxSize})"`,
- `box.ov."(${left+maxSize},${top},${right+maxSize},${bottom})"`,
- `box.ov."(${left},${top+maxSize},${right},${bottom+maxSize})"`
- ]
+const getBoxes = function getBoxes({ left, top, right, bottom }) {
+ const results = [
+ `box.ov."((${left},${top}),(${right},${bottom}))"`,
+ `box.ov."((${left + maxSize},${top + maxSize}),(${right + maxSize},${bottom + maxSize}))"`,
+ `box.ov."((${left + maxSize},${top}),(${right + maxSize},${bottom}))"`,
+ `box.ov."((${left},${top + maxSize}),(${right},${bottom + maxSize}))"`,
+ `box.ov."((${left - maxSize},${top - maxSize}),(${right - maxSize},${bottom - maxSize}))"`,
+ `box.ov."((${left - maxSize},${top}),(${right - maxSize},${bottom}))"`,
+ `box.ov."((${left},${top - maxSize}),(${right},${bottom - maxSize}))"`
+ ];
+
+ return results;
+};
+
+const serialize = function serialize(widget) {
+ const boxComponents = widget.box.match(boxParser).slice(1, 5).map(Number);
+ const box = {
+ left: Math.min(boxComponents[0], boxComponents[2]),
+ right: Math.max(boxComponents[0], boxComponents[2]),
+ top: Math.min(boxComponents[1], boxComponents[3]),
+ bottom: Math.max(boxComponents[1], boxComponents[3])
+ };
+
+ return { ...widget, box };