var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import React from 'react';
import uuid from 'uuid/v1';
import Object3D from '../lib/object3dts/Object3D';
import { Icon } from '@bitbloq/ui';
var config = {
    colors: [
        '#ff6900',
        '#fcb900',
        '#7bdcb5',
        '#00d084',
        '#8ed1fc',
        '#0693e3',
        '#abb8c3',
        '#eb144c',
        '#f78da7',
        '#9900ef',
    ],
    objectTypes: [
        {
            name: 'Cube',
            label: 'Cube',
            icon: React.createElement(Icon, { name: "cube" }),
            parameters: function () { return [
                {
                    name: 'width',
                    label: 'Width',
                    type: 'integer',
                    unit: 'mm',
                    min: 0,
                },
                {
                    name: 'height',
                    label: 'Height',
                    type: 'integer',
                    unit: 'mm',
                    min: 0,
                },
                {
                    name: 'depth',
                    label: 'Depth',
                    type: 'integer',
                    unit: 'mm',
                    min: 0,
                },
            ]; },
            create: function () { return ({
                id: uuid(),
                type: 'Cube',
                parameters: {
                    width: 10,
                    height: 10,
                    depth: 10,
                },
                operations: [],
            }); },
        },
        {
            name: 'Sphere',
            label: 'Sphere',
            icon: React.createElement(Icon, { name: "sphere" }),
            parameters: function () { return [
                {
                    name: 'radius',
                    label: 'Radius',
                    type: 'integer',
                    unit: 'mm',
                    min: 0,
                },
            ]; },
            create: function () { return ({
                id: uuid(),
                type: 'Sphere',
                parameters: {
                    radius: 5,
                },
                operations: [],
            }); },
        },
        {
            name: 'Cylinder',
            label: 'Cylinder',
            icon: React.createElement(Icon, { name: "cylinder" }),
            parameters: function () { return [
                {
                    name: 'r0',
                    label: 'Radius Bottom',
                    type: 'integer',
                    unit: 'mm',
                },
                {
                    name: 'r1',
                    label: 'Radius Top',
                    type: 'integer',
                    unit: 'mm',
                },
                {
                    name: 'height',
                    label: 'Height',
                    type: 'integer',
                    unit: 'mm',
                },
            ]; },
            create: function () { return ({
                id: uuid(),
                type: 'Cylinder',
                parameters: {
                    r0: 5,
                    r1: 5,
                    height: 10,
                },
                operations: [],
            }); },
        },
        {
            name: 'Prism',
            label: 'Prism',
            icon: React.createElement(Icon, { name: "prism" }),
            parameters: function () { return [
                {
                    name: 'sides',
                    label: 'Number of sides',
                    type: 'integer',
                },
                {
                    name: 'length',
                    label: 'Length of sides',
                    type: 'integer',
                    unit: 'mm',
                },
                {
                    name: 'height',
                    label: 'Height',
                    type: 'integer',
                    unit: 'mm',
                },
            ]; },
            create: function () { return ({
                id: uuid(),
                type: 'Prism',
                parameters: {
                    sides: 6,
                    length: 5,
                    height: 15,
                },
                operations: [],
            }); },
        },
        {
            name: 'STLObject',
            label: 'STL Object',
            icon: React.createElement(Icon, { name: "stl" }),
            parameters: function () { return [
                {
                    name: 'geometry',
                    label: 'File',
                    type: 'file',
                },
            ]; },
            create: function () { return ({
                id: uuid(),
                type: 'STLObject',
                parameters: {
                    geometry: 0,
                },
                operations: [],
            }); },
        },
        {
            name: 'Union',
            label: 'Union',
            icon: React.createElement(Icon, { name: "union" }),
            canUndo: true,
            undoLabel: 'Undo union',
            parameters: function () { return []; },
        },
        {
            name: 'Difference',
            label: 'Difference',
            icon: React.createElement(Icon, { name: "difference" }),
            canUndo: true,
            undoLabel: 'Undo difference',
            showBaseObject: true,
            parameters: function () { return []; },
        },
        {
            name: 'Intersection',
            label: 'Intersection',
            icon: React.createElement(Icon, { name: "intersection" }),
            canUndo: true,
            undoLabel: 'Undo intersection',
            parameters: function () { return []; },
        },
        {
            name: 'ObjectsGroup',
            label: 'Group',
            icon: React.createElement(Icon, { name: "group" }),
            canUngroup: true,
            withoutColor: true,
            parameters: function () { return []; },
        },
        {
            name: 'RepetitionObject',
            label: 'Repetition',
            icon: React.createElement(Icon, { name: "repeat" }),
            withoutColor: true,
            canConverToGroup: true,
            parameters: function (_a) {
                var type = _a.parameters.type;
                if (type === 'cartesian') {
                    return [
                        {
                            name: 'num',
                            label: 'Repetitions',
                            type: 'integer',
                        },
                        {
                            name: 'x',
                            label: 'x',
                            type: 'integer',
                            unit: 'mm',
                        },
                        {
                            name: 'y',
                            label: 'y',
                            type: 'integer',
                            unit: 'mm',
                        },
                        {
                            name: 'z',
                            label: 'z',
                            type: 'integer',
                            unit: 'mm',
                        },
                    ];
                }
                if (type === 'polar') {
                    return [
                        {
                            name: 'num',
                            label: 'Repetitions',
                            type: 'integer',
                        },
                        {
                            name: 'axis',
                            label: 'Axis',
                            type: 'select',
                            options: [
                                {
                                    label: 'X',
                                    value: 'x',
                                },
                                {
                                    label: 'Y',
                                    value: 'y',
                                },
                                {
                                    label: 'Z',
                                    value: 'z',
                                },
                            ],
                        },
                        {
                            name: 'angle',
                            label: 'Angle',
                            type: 'integer',
                            unit: '°',
                        },
                    ];
                }
            },
        },
    ],
    objectOperations: [
        {
            name: 'translation',
            label: 'Translation',
            basicLabel: 'Position',
            icon: React.createElement(Icon, { name: "translation" }),
            color: '#dd5b0c',
            create: function () { return (__assign({ id: uuid() }, Object3D.createTranslateOperation(0, 0, 0, false))); },
            parameters: [
                {
                    name: 'relative',
                    label: 'Relative',
                    type: 'boolean',
                    advancedMode: true
                },
                {
                    name: 'x',
                    label: 'X',
                    type: 'integer',
                    unit: 'mm',
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'translation',
                        axis: 'x',
                        relative: operation.relative,
                    }); },
                },
                {
                    name: 'y',
                    label: 'Y',
                    type: 'integer',
                    unit: 'mm',
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'translation',
                        axis: 'y',
                        relative: operation.relative,
                    }); },
                },
                {
                    name: 'z',
                    label: 'Z',
                    type: 'integer',
                    unit: 'mm',
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'translation',
                        axis: 'z',
                        relative: operation.relative,
                    }); },
                },
            ],
        },
        {
            name: 'rotation',
            label: 'Rotation',
            icon: React.createElement(Icon, { name: "rotation" }),
            color: '#d8af31',
            create: function () { return (__assign({ id: uuid() }, Object3D.createRotateOperation(0, 0, 0, false))); },
            parameters: [
                {
                    name: 'x',
                    label: 'X',
                    type: 'integer',
                    unit: '°',
                    basicMode: true,
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'rotation',
                        axis: 'x',
                        relative: operation.relative,
                    }); },
                },
                {
                    name: 'y',
                    label: 'Y',
                    type: 'integer',
                    unit: '°',
                    basicMode: true,
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'rotation',
                        axis: 'y',
                        relative: operation.relative,
                    }); },
                },
                {
                    name: 'z',
                    label: 'Z',
                    type: 'integer',
                    unit: '°',
                    basicMode: true,
                    activeOperation: function (object, operation) { return ({
                        object: object,
                        type: 'rotation',
                        axis: 'z',
                        relative: operation.relative,
                    }); },
                },
                {
                    name: 'relative',
                    label: 'Relative',
                    type: 'boolean',
                    advancedMode: true
                },
                {
                    name: 'axis',
                    label: 'Axis',
                    type: 'select',
                    advancedMode: true,
                    options: [
                        {
                            label: 'X',
                            value: 'x',
                        },
                        {
                            label: 'Y',
                            value: 'y',
                        },
                        {
                            label: 'Z',
                            value: 'z',
                        },
                    ],
                    getValue: function (operation) {
                        if (operation.x !== 0) {
                            return 'x';
                        }
                        if (operation.y !== 0) {
                            return 'y';
                        }
                        if (operation.z !== 0) {
                            return 'z';
                        }
                    },
                    setValue: function (operation, value) {
                        var x = operation.x, y = operation.y, z = operation.z;
                        var angle = x || y || z;
                        return __assign({}, operation, { x: value === 'x' ? angle : 0, y: value === 'y' ? angle : 0, z: value === 'z' ? angle : 0, axis: value });
                    }
                },
                {
                    name: 'angle',
                    label: 'Angle',
                    type: 'integer',
                    unit: '°',
                    advancedMode: true,
                    activeOperation: function (object, _a) {
                        var x = _a.x, y = _a.y, z = _a.z, relative = _a.relative, _b = _a.axis, axis = _b === void 0 ? 'x' : _b;
                        return ({
                            object: object,
                            type: 'rotation',
                            axis: (x && 'x') || (y && 'y') || (z && 'z') || axis,
                            relative: relative,
                        });
                    },
                    getValue: function (operation) {
                        var x = operation.x, y = operation.y, z = operation.z;
                        return x || y || z;
                    },
                    setValue: function (operation, value) {
                        var _a;
                        var x = operation.x, y = operation.y, z = operation.z, _b = operation.axis, axis = _b === void 0 ? 'x' : _b;
                        if (x || y || z) {
                            return __assign({}, operation, { x: x ? value : 0, y: y ? value : 0, z: z ? value : 0 });
                        }
                        else {
                            return __assign({}, operation, (_a = {}, _a[axis] = value, _a));
                        }
                    }
                },
            ],
        },
        {
            name: 'scale',
            label: 'Scale',
            icon: React.createElement(Icon, { name: "scale" }),
            color: '#59b52e',
            create: function () { return (__assign({ id: uuid() }, Object3D.createScaleOperation(1, 1, 1))); },
            parameters: [
                {
                    name: 'x',
                    label: 'x',
                    type: 'integer',
                },
                {
                    name: 'y',
                    label: 'y',
                    type: 'integer',
                },
                {
                    name: 'z',
                    label: 'z',
                    type: 'integer',
                },
            ],
        },
        {
            name: 'mirror',
            label: 'Reflection',
            icon: React.createElement(Icon, { name: "reflection" }),
            color: '#00c1c7',
            create: function () { return Object3D.createMirrorOperation(); },
            parameters: [
                {
                    name: 'plane',
                    label: 'Plane',
                    type: 'select',
                    options: [
                        {
                            label: 'X - Y',
                            value: 'xy',
                        },
                        {
                            label: 'Y - Z',
                            value: 'yz',
                        },
                        {
                            label: 'Z - X',
                            value: 'zx',
                        },
                    ],
                }
            ]
        }
    ],
    defaultOperations: function (isAdvancedMode) {
        if (isAdvancedMode) {
            return [];
        }
        else {
            return [
                Object3D.createTranslateOperation(0, 0, 0, false),
                Object3D.createRotateOperation(0, 0, 0, true),
                Object3D.createScaleOperation(1, 1, 1),
            ];
        }
    },
    compositionOperations: [
        {
            name: 'Union',
            label: 'Union',
            icon: React.createElement(Icon, { name: "union" }),
            minObjects: 2,
            create: function (children) { return ({
                id: uuid(),
                type: 'Union',
                children: children,
                operations: [],
            }); },
        },
        {
            name: 'Difference',
            label: 'Difference',
            icon: React.createElement(Icon, { name: "difference" }),
            minObjects: 2,
            create: function (children) { return ({
                id: uuid(),
                type: 'Difference',
                children: children,
                operations: [],
            }); },
        },
        {
            name: 'Intersection',
            label: 'Intersection',
            icon: React.createElement(Icon, { name: "intersection" }),
            minObjects: 2,
            create: function (children) { return ({
                id: uuid(),
                type: 'Intersection',
                children: children,
                operations: [],
            }); },
        },
        {
            name: 'ObjectsGroup',
            label: 'Group',
            icon: React.createElement(Icon, { name: "group" }),
            minObjects: 2,
            advancedMode: true,
            create: function (children) { return ({
                id: uuid(),
                type: 'ObjectsGroup',
                children: children,
                operations: [],
            }); },
        },
        {
            name: 'CartesianRepetition',
            label: 'Repeat',
            icon: React.createElement(Icon, { name: "repeat" }),
            minObjects: 1,
            maxObjects: 1,
            advancedMode: true,
            create: function (children) { return ({
                type: 'RepetitionObject',
                children: children,
                parameters: {
                    type: 'cartesian',
                    num: 2,
                    x: 10,
                    y: 10,
                    z: 10,
                },
                operations: [],
            }); },
        },
        {
            name: 'PolarRepetition',
            label: 'Repeat Polar',
            icon: React.createElement(Icon, { name: "repeat-polar" }),
            minObjects: 1,
            maxObjects: 1,
            advancedMode: true,
            create: function (children) { return ({
                type: 'RepetitionObject',
                children: children,
                parameters: {
                    type: 'polar',
                    num: 4,
                    axis: 'x',
                    angle: 180,
                },
                operations: [],
            }); },
        },
    ],
};
export default config;
//# sourceMappingURL=threed.js.map