"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeMoveSubgraphIntoAction = exports.wrapMoveSubgraphOutOfData = exports.wrapMoveSubgraphIntoData = exports.makeAddUnitAction = exports.wrapAddUnitAction = exports.SET_SUB_COMPONENT_SIZE = exports.SET_COMPONENT_SIZE = exports.SET_UNIT_SIZE = exports.MOVE_SUBGRAPH_OUT_OF = exports.MOVE_SUBGRAPH_INTO = exports.COLLAPSE_UNITS = exports.EXPAND_UNIT = exports.BULK_EDIT = exports.SET_UNIT_PIN_METADATA = exports.SET_PIN_METADATA = exports.SET_UNIT_METADATA = exports.SET_METADATA = exports.SET_NAME = exports.SET_PIN_SET_REF = exports.SET_PIN_SET_DEFAULT_IGNORED = exports.SET_PIN_SET_FUNCTIONAL = exports.SET_PIN_SET_ID = exports.SET_UNIT_ID = exports.SET_UNIT_ERR = exports.COVER_UNIT_PIN_SET = exports.EXPOSE_UNIT_PIN_SET = exports.SET_UNIT_PIN_IGNORED = exports.SET_UNIT_PIN_CONSTANT = exports.REMOVE_UNIT_PIN_DATA = exports.SET_UNIT_PIN_SET_ID = exports.SET_UNIT_PIN_DATA = exports.REMOVE_PLUG_DATA = exports.SET_PLUG_DATA = exports.PLUG_PIN = exports.UNPLUG_PIN = exports.COVER_PIN = exports.COVER_PIN_SET = exports.EXPOSE_PIN_SET = exports.EXPOSE_PIN = exports.REMOVE_MERGES = exports.REMOVE_MERGE_DATA = exports.SET_MERGE_DATA = exports.REMOVE_MERGE = exports.REMOVE_PIN_FROM_MERGE = exports.ADD_PIN_TO_MERGE = exports.ADD_MERGE = exports.TAKE_UNIT_ERR = exports.REMOVE_UNIT = exports.ADD_UNIT = exports.ADD_UNIT_SPEC = void 0;
exports.makeSetComponentSizeAction = exports.wrapSetComponentSizeAction = exports.wrapSetSubComponentSizeAction = exports.makeSetSubComponentSizeAction = exports.makeSetUnitSizeAction = exports.wrapSetUnitSizeAction = exports.makeSetUnitMetadataAction = exports.wrapSetUnitMetadataAction = exports.makeRemoveUnitPinDataAction = exports.wrapRemoveUnitPinDataAction = exports.makeSetUnitPinIgnoredAction = exports.makeSetUnitPinConstantAction = exports.makeSetUnitPinDataAction = exports.wrapSetUnitPinSetIdAction = exports.makeSetUnitPinSetIdAction = exports.wrapSetUnitPinDataAction = exports.wrapRemovePlugDataAction = exports.makeRemovePlugDataAction = exports.wrapSetPlugDataAction = exports.makeSetPlugDataAction = exports.makeCoverPinOrSetAction = exports.makeCoverPinAction = exports.wrapCoverPinAction = exports.makeUnplugPinAction = exports.wrapUnplugPinAction = exports.makePlugPinAction = exports.wrapPlugPinAction = exports.makeCoverPinSetAction = exports.wrapCoverPinSetAction = exports.makeExposePinSetAction = exports.makeCoverUnitPinSetAction = exports.wrapCoverUnitPinSet = exports.wrapExposePinSetAction = exports.makeExposeUnitPinSetAction = exports.wrapExposeUnitPinSet = exports.wrapSetPinSetDefaultIgnoredAction = exports.makeSetPinSetDefaultIgnoredAction = exports.wrapSetPinSetFunctionalAction = exports.wrapSetUnitIdAction = exports.makeSetUnitIdAction = exports.makeSetPinSetFunctionalAction = exports.wrapSetPinSetIdAction = exports.makeSetPinSetIdAction = exports.makeExposePinAction = exports.wrapExposePinAction = exports.makeTakeUnitErrAction = exports.makeRemoveUnitAction = exports.wrapMakeTakeUnitErrAction = exports.wrapMakeRemoveUnitAction = exports.makeMoveSubgraphOutOfAction = void 0;
exports.bulkEdit_ = exports.bulkEdit = exports.processActions = exports.act = exports.processAction = exports.makeBulkEditAction = exports.wrapBulkEditData = exports.makeRemovePinFromMergeAction = exports.wrapRemovePinFromMergeData = exports.makeAddPinToMergeAction = exports.wrapAddPinToMergeData = exports.wrapRemoveMergeDataAction = exports.makeRemoveMergeDataAction = exports.wrapSetMergeDataAction = exports.makeSetMergeDataAction = exports.makeRemoveMergeAction = exports.wrapRemoveMergeActionData = exports.makeAddMergeAction = exports.wrapAddMergeActionData = exports.makeSetUnitPinMetadataAction = exports.wrapSetUnitPinMetadataAction = exports.makeSetPinMetadataAction = exports.wrapSetPinMetadataAction = exports.makeSetMetadataAction = exports.wrapSetMetadataAction = exports.makeSetNameAction = void 0;
const clone_1 = require("../../util/clone");
const weakMerge_1 = require("../../weakMerge");
const component_1 = require("../reducers/component");
const spec_1 = require("../reducers/spec");
const util_1 = require("../util");
const spec_2 = require("../util/spec");
exports.ADD_UNIT_SPEC = 'addUnitSpec';
exports.ADD_UNIT = 'addUnit';
exports.REMOVE_UNIT = 'removeUnit';
exports.TAKE_UNIT_ERR = 'takeUnitErr';
exports.ADD_MERGE = 'addMerge';
exports.ADD_PIN_TO_MERGE = 'addPinToMerge';
exports.REMOVE_PIN_FROM_MERGE = 'removePinFromMerge';
exports.REMOVE_MERGE = 'removeMerge';
exports.SET_MERGE_DATA = 'setMergeData';
exports.REMOVE_MERGE_DATA = 'removeMergeData';
exports.REMOVE_MERGES = 'removeMerges';
exports.EXPOSE_PIN = 'exposePin';
exports.EXPOSE_PIN_SET = 'exposePinSet';
exports.COVER_PIN_SET = 'coverPinSet';
exports.COVER_PIN = 'coverPin';
exports.UNPLUG_PIN = 'unplugPin';
exports.PLUG_PIN = 'plugPin';
exports.SET_PLUG_DATA = 'setPlugData';
exports.REMOVE_PLUG_DATA = 'removePlugData';
exports.SET_UNIT_PIN_DATA = 'setUnitPinData';
exports.SET_UNIT_PIN_SET_ID = 'setUnitPinSetId';
exports.REMOVE_UNIT_PIN_DATA = 'removeUnitPinData';
exports.SET_UNIT_PIN_CONSTANT = 'setUnitPinConstant';
exports.SET_UNIT_PIN_IGNORED = 'setUnitPinIgnored';
exports.EXPOSE_UNIT_PIN_SET = 'exposeUnitPinSet';
exports.COVER_UNIT_PIN_SET = 'coverUnitPinSet';
exports.SET_UNIT_ERR = 'setUnitErr';
exports.SET_UNIT_ID = 'setUnitId';
exports.SET_PIN_SET_ID = 'setPinSetId';
exports.SET_PIN_SET_FUNCTIONAL = 'setPinSetFunctional';
exports.SET_PIN_SET_DEFAULT_IGNORED = 'setPinSetDefaultIgnored';
exports.SET_PIN_SET_REF = 'setPinSetRef';
exports.SET_NAME = 'setName';
exports.SET_METADATA = 'setMetadata';
exports.SET_UNIT_METADATA = 'setUnitMetadata';
exports.SET_PIN_METADATA = 'setPinMetadata';
exports.SET_UNIT_PIN_METADATA = 'setUnitPinMetadata';
exports.BULK_EDIT = 'bulkEdit';
exports.EXPAND_UNIT = 'expandUnit';
exports.COLLAPSE_UNITS = 'collapseUnits';
exports.MOVE_SUBGRAPH_INTO = 'moveSubgraphInto';
exports.MOVE_SUBGRAPH_OUT_OF = 'moveSubgraphOutOf';
exports.SET_UNIT_SIZE = 'setUnitSize';
exports.SET_COMPONENT_SIZE = 'setComponentSize';
exports.SET_SUB_COMPONENT_SIZE = 'setSubComponentSize';
const wrapAddUnitAction = (data) => {
    return {
        type: exports.ADD_UNIT_SPEC,
        data,
    };
};
exports.wrapAddUnitAction = wrapAddUnitAction;
const makeAddUnitAction = (unitId, bundle, merges, plugs, parentId, parentSlot, parentIndex, children, childrenSlot, position, pinPosition, layoutPosition) => {
    return (0, exports.wrapAddUnitAction)({
        unitId,
        bundle,
        position,
        pinPosition,
        layoutPosition,
        parentId,
        parentSlot,
        parentIndex,
        children,
        childrenSlot,
        merges,
        plugs,
    });
};
exports.makeAddUnitAction = makeAddUnitAction;
const wrapMoveSubgraphIntoData = (data) => {
    return {
        type: exports.MOVE_SUBGRAPH_INTO,
        data,
    };
};
exports.wrapMoveSubgraphIntoData = wrapMoveSubgraphIntoData;
const wrapMoveSubgraphOutOfData = (data) => {
    return {
        type: exports.MOVE_SUBGRAPH_OUT_OF,
        data,
    };
};
exports.wrapMoveSubgraphOutOfData = wrapMoveSubgraphOutOfData;
const makeMoveSubgraphIntoAction = (graphId, spec, selection, mapping, moves) => {
    return (0, exports.wrapMoveSubgraphIntoData)({
        graphId,
        spec,
        selection,
        moves,
        mapping,
    });
};
exports.makeMoveSubgraphIntoAction = makeMoveSubgraphIntoAction;
const makeMoveSubgraphOutOfAction = (graphId, spec, selection, mapping, moves) => {
    return (0, exports.wrapMoveSubgraphOutOfData)({
        graphId,
        spec,
        selection,
        moves,
        mapping,
    });
};
exports.makeMoveSubgraphOutOfAction = makeMoveSubgraphOutOfAction;
const wrapMakeRemoveUnitAction = (data) => {
    return {
        type: exports.REMOVE_UNIT,
        data,
    };
};
exports.wrapMakeRemoveUnitAction = wrapMakeRemoveUnitAction;
const wrapMakeTakeUnitErrAction = (data) => {
    return {
        type: exports.TAKE_UNIT_ERR,
        data,
    };
};
exports.wrapMakeTakeUnitErrAction = wrapMakeTakeUnitErrAction;
const makeRemoveUnitAction = (unitId, bundle, merges, plugs, parentId, parentSlot, parentIndex, children, childrenSlot, position, pinPosition, layoutPosition) => {
    return (0, exports.wrapMakeRemoveUnitAction)({
        unitId,
        bundle,
        position,
        pinPosition,
        layoutPosition,
        parentId,
        parentSlot,
        parentIndex,
        children,
        childrenSlot,
        merges,
        plugs,
    });
};
exports.makeRemoveUnitAction = makeRemoveUnitAction;
const makeTakeUnitErrAction = (unitId) => {
    return (0, exports.wrapMakeTakeUnitErrAction)({
        unitId,
    });
};
exports.makeTakeUnitErrAction = makeTakeUnitErrAction;
const wrapExposePinAction = (data) => {
    return {
        type: exports.EXPOSE_PIN,
        data,
    };
};
exports.wrapExposePinAction = wrapExposePinAction;
const makeExposePinAction = (type, pinId, subPinId, subPinSpec) => {
    return (0, exports.wrapExposePinAction)({ type, pinId, subPinId, subPinSpec });
};
exports.makeExposePinAction = makeExposePinAction;
const makeSetPinSetIdAction = (type, pinId, newPinId) => {
    return (0, exports.wrapSetPinSetIdAction)({ type, pinId, newPinId });
};
exports.makeSetPinSetIdAction = makeSetPinSetIdAction;
const wrapSetPinSetIdAction = (data) => {
    return {
        type: exports.SET_PIN_SET_ID,
        data,
    };
};
exports.wrapSetPinSetIdAction = wrapSetPinSetIdAction;
const makeSetPinSetFunctionalAction = (type, pinId, functional) => {
    return (0, exports.wrapSetPinSetFunctionalAction)({ type, pinId, functional });
};
exports.makeSetPinSetFunctionalAction = makeSetPinSetFunctionalAction;
const makeSetUnitIdAction = (unitId, newUnitId, name, lastName, specId, lastSpecId) => {
    return (0, exports.wrapSetUnitIdAction)({
        unitId,
        newUnitId,
        name,
        lastName,
        specId,
        lastSpecId,
    });
};
exports.makeSetUnitIdAction = makeSetUnitIdAction;
const wrapSetUnitIdAction = (data) => {
    return {
        type: exports.SET_UNIT_ID,
        data,
    };
};
exports.wrapSetUnitIdAction = wrapSetUnitIdAction;
const wrapSetPinSetFunctionalAction = (data) => {
    return {
        type: exports.SET_PIN_SET_DEFAULT_IGNORED,
        data,
    };
};
exports.wrapSetPinSetFunctionalAction = wrapSetPinSetFunctionalAction;
const makeSetPinSetDefaultIgnoredAction = (type, pinId, defaultIgnored) => {
    return (0, exports.wrapSetPinSetDefaultIgnoredAction)({ type, pinId, defaultIgnored });
};
exports.makeSetPinSetDefaultIgnoredAction = makeSetPinSetDefaultIgnoredAction;
const wrapSetPinSetDefaultIgnoredAction = (data) => {
    return {
        type: exports.SET_PIN_SET_DEFAULT_IGNORED,
        data,
    };
};
exports.wrapSetPinSetDefaultIgnoredAction = wrapSetPinSetDefaultIgnoredAction;
const wrapExposeUnitPinSet = (data) => {
    return {
        type: exports.EXPOSE_UNIT_PIN_SET,
        data,
    };
};
exports.wrapExposeUnitPinSet = wrapExposeUnitPinSet;
const makeExposeUnitPinSetAction = (unitId, type, pinId, pinSpec, position) => {
    return (0, exports.wrapExposeUnitPinSet)({ type, unitId, pinId, pinSpec, position });
};
exports.makeExposeUnitPinSetAction = makeExposeUnitPinSetAction;
const wrapExposePinSetAction = (data) => {
    return {
        type: exports.EXPOSE_PIN_SET,
        data,
    };
};
exports.wrapExposePinSetAction = wrapExposePinSetAction;
const wrapCoverUnitPinSet = (data) => {
    return {
        type: exports.COVER_UNIT_PIN_SET,
        data,
    };
};
exports.wrapCoverUnitPinSet = wrapCoverUnitPinSet;
const makeCoverUnitPinSetAction = (unitId, type, pinId, pinSpec, position) => {
    return (0, exports.wrapCoverUnitPinSet)({ type, unitId, pinId, pinSpec, position });
};
exports.makeCoverUnitPinSetAction = makeCoverUnitPinSetAction;
const makeExposePinSetAction = (type, pinId, pinSpec, data, flags) => {
    return (0, exports.wrapExposePinSetAction)({ type, pinId, pinSpec, data, ...flags });
};
exports.makeExposePinSetAction = makeExposePinSetAction;
const wrapCoverPinSetAction = (data) => {
    return {
        type: exports.COVER_PIN_SET,
        data,
    };
};
exports.wrapCoverPinSetAction = wrapCoverPinSetAction;
const makeCoverPinSetAction = (type, pinId, pinSpec) => {
    return (0, exports.wrapCoverPinSetAction)({ type, pinId, pinSpec });
};
exports.makeCoverPinSetAction = makeCoverPinSetAction;
const wrapPlugPinAction = (data) => {
    return {
        type: exports.PLUG_PIN,
        data,
    };
};
exports.wrapPlugPinAction = wrapPlugPinAction;
const makePlugPinAction = (type, pinId, subPinId, subPinSpec) => {
    return (0, exports.wrapPlugPinAction)({ type, pinId, subPinId, subPinSpec });
};
exports.makePlugPinAction = makePlugPinAction;
const wrapUnplugPinAction = (data) => {
    return {
        type: exports.UNPLUG_PIN,
        data,
    };
};
exports.wrapUnplugPinAction = wrapUnplugPinAction;
const makeUnplugPinAction = (type, pinId, subPinId, subPinSpec, take) => {
    return (0, exports.wrapUnplugPinAction)({ type, pinId, subPinId, subPinSpec, take });
};
exports.makeUnplugPinAction = makeUnplugPinAction;
const wrapCoverPinAction = (data) => {
    return {
        type: exports.COVER_PIN,
        data,
    };
};
exports.wrapCoverPinAction = wrapCoverPinAction;
const makeCoverPinAction = (type, pinId, subPinId, subPinSpec, pinSpec) => {
    return (0, exports.wrapCoverPinAction)({ type, pinId, subPinId, subPinSpec, pinSpec });
};
exports.makeCoverPinAction = makeCoverPinAction;
const makeCoverPinOrSetAction = (spec, type, pinId, subPinId) => {
    const pin = (0, spec_2.getPinSpec)(spec, type, pinId);
    const subPin = (0, spec_2.getSubPinSpec)(spec, type, pinId, subPinId);
    const subPinCount = (0, spec_2.getPlugCount)(spec, type, pinId);
    if (subPinCount > 1) {
        return (0, exports.makeCoverPinAction)(type, pinId, subPinId, subPin);
    }
    else {
        return (0, exports.makeCoverPinSetAction)(type, pinId, pin);
    }
};
exports.makeCoverPinOrSetAction = makeCoverPinOrSetAction;
const makeSetPlugDataAction = (type, pinId, subPinId, data, lastData) => {
    return (0, exports.wrapSetPlugDataAction)({
        type,
        pinId,
        subPinId,
        data,
        lastData,
    });
};
exports.makeSetPlugDataAction = makeSetPlugDataAction;
const wrapSetPlugDataAction = (data) => {
    return {
        type: exports.SET_PLUG_DATA,
        data,
    };
};
exports.wrapSetPlugDataAction = wrapSetPlugDataAction;
const makeRemovePlugDataAction = (type, pinId, subPinId, data) => {
    return (0, exports.wrapSetPlugDataAction)({
        type,
        pinId,
        subPinId,
        data,
    });
};
exports.makeRemovePlugDataAction = makeRemovePlugDataAction;
const wrapRemovePlugDataAction = (data) => {
    return {
        type: exports.REMOVE_PLUG_DATA,
        data,
    };
};
exports.wrapRemovePlugDataAction = wrapRemovePlugDataAction;
const wrapSetUnitPinDataAction = (data) => {
    return {
        type: exports.SET_UNIT_PIN_DATA,
        data,
    };
};
exports.wrapSetUnitPinDataAction = wrapSetUnitPinDataAction;
const makeSetUnitPinSetIdAction = (unitId, type, pinId, newPinId) => {
    return (0, exports.wrapSetUnitPinSetIdAction)({
        unitId,
        type,
        pinId,
        newPinId,
    });
};
exports.makeSetUnitPinSetIdAction = makeSetUnitPinSetIdAction;
const wrapSetUnitPinSetIdAction = (data) => {
    return {
        type: exports.SET_UNIT_PIN_SET_ID,
        data,
    };
};
exports.wrapSetUnitPinSetIdAction = wrapSetUnitPinSetIdAction;
const makeSetUnitPinDataAction = (unitId, type, pinId, data) => {
    return (0, exports.wrapSetUnitPinDataAction)({
        unitId,
        type,
        pinId,
        data,
    });
};
exports.makeSetUnitPinDataAction = makeSetUnitPinDataAction;
const makeSetUnitPinConstantAction = (unitId, type, pinId, constant) => {
    return {
        type: exports.SET_UNIT_PIN_CONSTANT,
        data: {
            unitId,
            type,
            pinId,
            constant,
        },
    };
};
exports.makeSetUnitPinConstantAction = makeSetUnitPinConstantAction;
const makeSetUnitPinIgnoredAction = (unitId, type, pinId, ignored) => {
    return {
        type: exports.SET_UNIT_PIN_IGNORED,
        data: {
            unitId,
            type,
            pinId,
            ignored,
        },
    };
};
exports.makeSetUnitPinIgnoredAction = makeSetUnitPinIgnoredAction;
const wrapRemoveUnitPinDataAction = (data) => {
    return {
        type: exports.REMOVE_UNIT_PIN_DATA,
        data,
    };
};
exports.wrapRemoveUnitPinDataAction = wrapRemoveUnitPinDataAction;
const makeRemoveUnitPinDataAction = (unitId, type, pinId, data) => {
    return (0, exports.wrapRemoveUnitPinDataAction)({
        unitId,
        type,
        pinId,
        data,
    });
};
exports.makeRemoveUnitPinDataAction = makeRemoveUnitPinDataAction;
const wrapSetUnitMetadataAction = (data) => {
    return {
        type: exports.SET_UNIT_METADATA,
        data,
    };
};
exports.wrapSetUnitMetadataAction = wrapSetUnitMetadataAction;
const makeSetUnitMetadataAction = (unitId, path, data) => {
    return (0, exports.wrapSetUnitMetadataAction)({
        unitId,
        path_: path,
        value: data,
    });
};
exports.makeSetUnitMetadataAction = makeSetUnitMetadataAction;
const wrapSetUnitSizeAction = (data) => {
    return {
        type: exports.SET_UNIT_SIZE,
        data,
    };
};
exports.wrapSetUnitSizeAction = wrapSetUnitSizeAction;
const makeSetUnitSizeAction = (unitId, width, height, prevWidth, prevHeight) => {
    return (0, exports.wrapSetUnitSizeAction)({
        unitId,
        width,
        height,
        prevWidth,
        prevHeight,
    });
};
exports.makeSetUnitSizeAction = makeSetUnitSizeAction;
const makeSetSubComponentSizeAction = (unitId, width, height, prevWidth, prevHeight) => {
    return (0, exports.wrapSetSubComponentSizeAction)({
        unitId,
        width,
        height,
        prevWidth,
        prevHeight,
    });
};
exports.makeSetSubComponentSizeAction = makeSetSubComponentSizeAction;
const wrapSetSubComponentSizeAction = (data) => {
    return {
        type: exports.SET_SUB_COMPONENT_SIZE,
        data,
    };
};
exports.wrapSetSubComponentSizeAction = wrapSetSubComponentSizeAction;
const wrapSetComponentSizeAction = (data) => {
    return {
        type: exports.SET_COMPONENT_SIZE,
        data,
    };
};
exports.wrapSetComponentSizeAction = wrapSetComponentSizeAction;
const makeSetComponentSizeAction = (width, height, prevWidth, prevHeight) => {
    return (0, exports.wrapSetComponentSizeAction)({
        width,
        height,
        prevWidth,
        prevHeight,
    });
};
exports.makeSetComponentSizeAction = makeSetComponentSizeAction;
const makeSetNameAction = (path, name) => {
    return {
        type: exports.SET_METADATA,
        data: {
            path,
            name,
        },
    };
};
exports.makeSetNameAction = makeSetNameAction;
const wrapSetMetadataAction = (data) => {
    return {
        type: exports.SET_METADATA,
        data,
    };
};
exports.wrapSetMetadataAction = wrapSetMetadataAction;
const makeSetMetadataAction = (path_, value) => {
    return (0, exports.wrapSetMetadataAction)({ path_, value });
};
exports.makeSetMetadataAction = makeSetMetadataAction;
const wrapSetPinMetadataAction = (data) => {
    return {
        type: exports.SET_PIN_METADATA,
        data,
    };
};
exports.wrapSetPinMetadataAction = wrapSetPinMetadataAction;
const makeSetPinMetadataAction = (type, pinId, path_, value) => {
    return (0, exports.wrapSetPinMetadataAction)({
        type,
        pinId,
        path_,
        value,
    });
};
exports.makeSetPinMetadataAction = makeSetPinMetadataAction;
const wrapSetUnitPinMetadataAction = (data) => {
    return {
        type: exports.SET_UNIT_PIN_METADATA,
        data,
    };
};
exports.wrapSetUnitPinMetadataAction = wrapSetUnitPinMetadataAction;
const makeSetUnitPinMetadataAction = (unitId, type, pinId, path_, value) => {
    return (0, exports.wrapSetUnitPinMetadataAction)({
        unitId,
        type,
        pinId,
        path_,
        value,
    });
};
exports.makeSetUnitPinMetadataAction = makeSetUnitPinMetadataAction;
const wrapAddMergeActionData = (data) => {
    return {
        type: exports.ADD_MERGE,
        data,
    };
};
exports.wrapAddMergeActionData = wrapAddMergeActionData;
const makeAddMergeAction = (mergeId, mergeSpec, position) => {
    return (0, exports.wrapAddMergeActionData)({
        mergeId,
        mergeSpec,
        position,
    });
};
exports.makeAddMergeAction = makeAddMergeAction;
const wrapRemoveMergeActionData = (data) => {
    return {
        type: exports.REMOVE_MERGE,
        data,
    };
};
exports.wrapRemoveMergeActionData = wrapRemoveMergeActionData;
const makeRemoveMergeAction = (mergeId, mergeSpec, position) => {
    return (0, exports.wrapRemoveMergeActionData)({
        mergeId,
        mergeSpec,
        position,
    });
};
exports.makeRemoveMergeAction = makeRemoveMergeAction;
const makeSetMergeDataAction = (mergeId, data) => {
    return (0, exports.wrapSetMergeDataAction)({
        mergeId,
        data,
    });
};
exports.makeSetMergeDataAction = makeSetMergeDataAction;
const wrapSetMergeDataAction = (data) => {
    return {
        type: exports.SET_MERGE_DATA,
        data,
    };
};
exports.wrapSetMergeDataAction = wrapSetMergeDataAction;
const makeRemoveMergeDataAction = (mergeId, data) => {
    return (0, exports.wrapRemoveMergeDataAction)({
        mergeId,
        data,
    });
};
exports.makeRemoveMergeDataAction = makeRemoveMergeDataAction;
const wrapRemoveMergeDataAction = (data) => {
    return {
        type: exports.REMOVE_MERGE_DATA,
        data,
    };
};
exports.wrapRemoveMergeDataAction = wrapRemoveMergeDataAction;
const wrapAddPinToMergeData = (data) => {
    return {
        type: exports.ADD_PIN_TO_MERGE,
        data,
    };
};
exports.wrapAddPinToMergeData = wrapAddPinToMergeData;
const makeAddPinToMergeAction = (mergeId, unitId, type, pinId) => {
    return (0, exports.wrapAddPinToMergeData)({
        mergeId,
        unitId,
        type,
        pinId,
    });
};
exports.makeAddPinToMergeAction = makeAddPinToMergeAction;
const wrapRemovePinFromMergeData = (data) => {
    return {
        type: exports.REMOVE_PIN_FROM_MERGE,
        data,
    };
};
exports.wrapRemovePinFromMergeData = wrapRemovePinFromMergeData;
const makeRemovePinFromMergeAction = (mergeId, unitId, type, pinId) => {
    return (0, exports.wrapRemovePinFromMergeData)({
        mergeId,
        unitId,
        type,
        pinId,
    });
};
exports.makeRemovePinFromMergeAction = makeRemovePinFromMergeAction;
const wrapBulkEditData = (data) => {
    return {
        type: exports.BULK_EDIT,
        data,
    };
};
exports.wrapBulkEditData = wrapBulkEditData;
const makeBulkEditAction = (actions) => {
    return (0, exports.wrapBulkEditData)({
        actions,
    });
};
exports.makeBulkEditAction = makeBulkEditAction;
const processAction = (self, action, method, fallback) => {
    const { type, data } = action;
    if (!method[type] && !fallback) {
        throw new Error(`no method for ${type}`);
    }
    ;
    (method[type] ?? fallback).call(self, data);
};
exports.processAction = processAction;
const act = (specs, spec, type, data) => {
    ;
    ({
        coverPinSet: (data) => {
            (0, spec_1.coverPinSet)(data, spec);
        },
        exposePinSet: (data) => {
            (0, spec_1.exposePinSet)(data, spec);
        },
        addUnitSpec: (data) => {
            (0, spec_1.addUnitSpec)(data, spec);
            const { unitId } = data;
            const specs_ = (0, weakMerge_1.weakMerge)(specs, data.bundle.specs ?? {});
            const unitSpec = (0, util_1.getSpec)(specs_, data.bundle.unit.id);
            if ((0, util_1.isComponentSpec)(unitSpec)) {
                (0, component_1.setSubComponent)({ unitId, subComponent: {} }, spec.component);
                (0, component_1.appendRoot)({ childId: unitId }, spec.component);
            }
        },
        removeUnit: (data) => {
            (0, spec_1.removeUnit)(data, spec);
        },
        addMerge: (data) => {
            (0, spec_1.addMerge)(data, spec);
        },
        removeMerge: (data) => {
            (0, spec_1.removeMerge)(data, spec);
        },
        removeUnitPinData: (data) => {
            (0, spec_1.removeUnitPinData)(data, spec);
        },
        addPinToMerge: (data) => {
            (0, spec_1.addPinToMerge)(data, spec);
        },
        coverPin: (data) => {
            (0, spec_1.coverPin)(data, spec);
        },
        exposePin: (data) => {
            (0, spec_1.exposePin)(data, spec);
        },
        unplugPin: (data) => {
            (0, spec_1.unplugPin)(data, spec);
        },
        plugPin: (data) => {
            (0, spec_1.plugPin)(data, spec);
        },
        setSubComponentSize: (data) => {
            (0, component_1.setSubComponentSize)(data, spec.component);
        },
        setUnitSize: (data) => {
            (0, spec_1.setUnitSize)(data, spec);
        },
        setUnitPinData: (data) => {
            (0, spec_1.setUnitPinData)(data, spec, {}, {});
        },
        setComponentSize: (data) => {
            (0, spec_1.setComponentSize)(data, spec);
        },
        moveSubComponentRoot: (data) => {
            (0, component_1.moveSubComponentRoot)(data, spec.component);
        },
        removePinFromMerge: (data) => {
            (0, spec_1.removePinFromMerge)(data, spec);
        },
        setUnitPinConstant: (data) => {
            (0, spec_1.setUnitPinConstant)(data, spec);
        },
        setPlugData: (data) => {
            //
        },
    })[type](data);
};
exports.act = act;
const processActions = (self, actions, method, fallback) => {
    actions.forEach((action) => (0, exports.processAction)(self, action, method, fallback));
};
exports.processActions = processActions;
const bulkEdit = (spec_, actions) => {
    const spec = (0, clone_1.clone)(spec_);
    (0, exports.bulkEdit)(spec, actions);
    return spec;
};
exports.bulkEdit = bulkEdit;
const bulkEdit_ = (specs, spec, actions) => {
    for (const action of actions) {
        (0, exports.act)(specs, spec, action.type, (0, clone_1.clone)(action.data));
    }
};
exports.bulkEdit_ = bulkEdit_;
//# sourceMappingURL=G.js.map