{"version":3,"sources":["../../packages/ketcher-core/src/domain/constants/elementColor.ts","../../packages/ketcher-core/src/domain/constants/elements.ts","../../packages/ketcher-core/src/domain/constants/generics.ts","../../packages/ketcher-core/src/domain/entities/atomList.ts","../../packages/ketcher-core/src/domain/entities/vec2.ts","../../packages/ketcher-core/src/domain/entities/atom.ts","../../packages/ketcher-core/src/domain/entities/pile.ts","../../packages/ketcher-core/src/domain/entities/fragment.ts","../../packages/ketcher-core/src/domain/entities/bond.ts","../../packages/ketcher-core/src/domain/helpers/scale.ts","../../packages/ketcher-core/src/domain/helpers/stereoValidator.ts","../../packages/ketcher-core/src/domain/helpers/functionalGroupsProvider.ts","../../packages/ketcher-core/src/domain/entities/box2Abs.ts","../../packages/ketcher-core/src/domain/entities/sgroup.ts","../../packages/ketcher-core/src/domain/entities/rxnArrow.ts","../../packages/ketcher-core/src/domain/entities/functionalGroup.ts","../../packages/ketcher-core/src/domain/entities/halfBond.ts","../../packages/ketcher-core/src/domain/entities/loop.ts","../../packages/ketcher-core/src/domain/entities/rgroup.ts","../../packages/ketcher-core/src/domain/entities/simpleObject.ts","../../packages/ketcher-core/src/domain/entities/rxnPlus.ts","../../packages/ketcher-core/src/domain/entities/sgroupForest.ts","../../packages/ketcher-core/src/domain/entities/pool.ts","../../packages/ketcher-core/src/domain/entities/struct.ts","../../packages/ketcher-core/src/domain/entities/text.ts","../../packages/ketcher-core/src/utilities/ifDef.ts","../../packages/ketcher-core/src/utilities/tfx.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/moleculeToKet.ts","../../packages/ketcher-core/src/domain/serializers/ket/fromKet/moleculeToStruct.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/prepare.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/rgroupToKet.ts","../../packages/ketcher-core/src/domain/serializers/ket/fromKet/rgroupToStruct.ts","../../packages/ketcher-core/src/domain/serializers/ket/fromKet/rxnToStruct.ts","../../packages/ketcher-core/src/domain/serializers/ket/fromKet/simpleObjectToStruct.ts","../../packages/ketcher-core/src/domain/serializers/ket/ketSerializer.ts","../../packages/ketcher-core/src/domain/serializers/ket/fromKet/textToStruct.ts","../../packages/ketcher-core/src/domain/serializers/ket/validate.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/headerToKet.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/rxnToKet.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/simpleObjectToKet.ts","../../packages/ketcher-core/src/domain/serializers/ket/toKet/textToKet.ts","../../packages/ketcher-core/src/domain/serializers/mol/utils.js","../../packages/ketcher-core/src/domain/serializers/mol/parseSGroup.js","../../packages/ketcher-core/src/domain/serializers/mol/v2000.js","../../packages/ketcher-core/src/domain/serializers/mol/v3000.js","../../packages/ketcher-core/src/domain/serializers/mol/common.js","../../packages/ketcher-core/src/domain/serializers/mol/molfile.ts","../../packages/ketcher-core/src/domain/serializers/mol/molSerializer.ts","../../packages/ketcher-core/src/domain/serializers/smi/cis_trans.js","../../packages/ketcher-core/src/domain/serializers/smi/dfs.js","../../packages/ketcher-core/src/domain/serializers/smi/stereocenters.js","../../packages/ketcher-core/src/domain/serializers/smi/smiles.js","../../packages/ketcher-core/src/domain/serializers/smi/smiSerializer.ts","../../packages/ketcher-core/src/domain/serializers/sdf/sdfSerializer.ts","../../packages/ketcher-core/src/domain/services/struct/structService.types.ts","../../packages/ketcher-core/src/infrastructure/services/struct/remoteStructService.ts","../../packages/ketcher-core/src/infrastructure/services/struct/remoteStructServiceProvider.ts","../../packages/ketcher-core/src/application/formatters/supportedFormatProperties.ts","../../packages/ketcher-core/src/application/formatters/formatProperties.ts","../../packages/ketcher-core/src/application/formatters/ketFormatter.ts","../../packages/ketcher-core/src/application/formatters/molfileV2000Formatter.ts","../../packages/ketcher-core/src/application/formatters/rxnFormatter.ts","../../packages/ketcher-core/src/application/render/restruct/generalEnumTypes.ts","../../packages/ketcher-core/src/application/formatters/serverFormatter.ts","../../packages/ketcher-core/src/application/formatters/smilesFormatter.ts","../../packages/ketcher-core/src/application/formatters/formatterFactory.ts","../../packages/ketcher-core/src/application/formatters/identifyStructFormat.ts","../../packages/ketcher-core/src/application/render/raphael-ext.js","../../packages/ketcher-core/src/application/render/restruct/visel.js","../../packages/ketcher-core/src/application/render/restruct/reobject.ts","../../packages/ketcher-core/src/application/render/util.js","../../packages/ketcher-core/src/application/render/draw.js","../../packages/ketcher-core/src/application/render/restruct/reatom.ts","../../packages/ketcher-core/src/application/render/restruct/rebond.ts","../../packages/ketcher-core/src/application/render/restruct/reenhancedFlag.ts","../../packages/ketcher-core/src/application/render/restruct/refrag.js","../../packages/ketcher-core/src/application/render/restruct/rergroup.js","../../packages/ketcher-core/src/application/render/restruct/rerxnarrow.ts","../../packages/ketcher-core/src/application/render/restruct/rerxnplus.js","../../packages/ketcher-core/src/application/render/restruct/redatasgroupdata.js","../../packages/ketcher-core/src/application/render/restruct/resgroup.js","../../packages/ketcher-core/src/application/render/restruct/resimpleObject.ts","../../packages/ketcher-core/src/application/render/restruct/reloop.js","../../packages/ketcher-core/src/application/render/restruct/retext.ts","../../packages/ketcher-core/src/application/render/restruct/restruct.ts","../../packages/ketcher-core/src/application/editor/shared/utils.js","../../packages/ketcher-core/src/application/render/raphaelRender.js","../../packages/ketcher-core/src/application/render/options.js","../../packages/ketcher-core/src/application/editor/operations/base.ts","../../packages/ketcher-core/src/application/editor/operations/OperationType.ts","../../packages/ketcher-core/src/application/editor/operations/atom/AtomAttr.ts","../../packages/ketcher-core/src/application/editor/operations/atom/AtomMove.ts","../../packages/ketcher-core/src/application/editor/operations/atom/index.ts","../../packages/ketcher-core/src/application/editor/operations/bond/BondAttr.ts","../../packages/ketcher-core/src/application/editor/operations/bond/BondMove.ts","../../packages/ketcher-core/src/application/editor/operations/bond/index.ts","../../packages/ketcher-core/src/application/editor/operations/CanvasLoad.ts","../../packages/ketcher-core/src/application/editor/operations/descriptors.ts","../../packages/ketcher-core/src/application/editor/operations/EnhancedFlagMove.ts","../../packages/ketcher-core/src/application/editor/operations/ifThen.ts","../../packages/ketcher-core/src/application/editor/operations/fragment.ts","../../packages/ketcher-core/src/application/editor/operations/fragmentStereoAtom.ts","../../packages/ketcher-core/src/application/editor/operations/FragmentStereoFlag.ts","../../packages/ketcher-core/src/application/editor/operations/calcimplicitH.ts","../../packages/ketcher-core/src/application/editor/operations/LoopMove.ts","../../packages/ketcher-core/src/application/editor/operations/rgroup/RGroupAttr.ts","../../packages/ketcher-core/src/application/editor/operations/rgroup/RGroupFragment.ts","../../packages/ketcher-core/src/application/editor/operations/rxn/RxnArrowMove.ts","../../packages/ketcher-core/src/application/editor/operations/rxn/RxnArrowResize.ts","../../packages/ketcher-core/src/application/editor/operations/rxn/plus/RxnPlusMove.ts","../../packages/ketcher-core/src/application/editor/operations/rxn/plus/index.ts","../../packages/ketcher-core/src/application/editor/operations/rxn/index.ts","../../packages/ketcher-core/src/application/editor/operations/simpleObject.ts","../../packages/ketcher-core/src/application/editor/operations/sgroup/sgroupAtom.ts","../../packages/ketcher-core/src/application/editor/operations/sgroup/SGroupAttr.ts","../../packages/ketcher-core/src/application/editor/operations/sgroup/SGroupDataMove.ts","../../packages/ketcher-core/src/application/editor/operations/sgroup/sgroupHierarchy.ts","../../packages/ketcher-core/src/application/editor/operations/sgroup/index.ts","../../packages/ketcher-core/src/application/editor/operations/Text/TextCreateDelete.ts","../../packages/ketcher-core/src/application/editor/operations/Text/TextUpdate.ts","../../packages/ketcher-core/src/application/editor/operations/Text/TextMove.ts","../../packages/ketcher-core/src/application/editor/actions/action.ts","../../packages/ketcher-core/src/application/editor/actions/aromaticFusing.ts","../../packages/ketcher-core/src/application/editor/shared/closest.js","../../packages/ketcher-core/src/application/editor/actions/utils.ts","../../packages/ketcher-core/src/application/editor/actions/rgroup.ts","../../packages/ketcher-core/src/application/editor/actions/sgroup.ts","../../packages/ketcher-core/src/application/editor/actions/bond.ts","../../packages/ketcher-core/src/application/editor/actions/atom.ts","../../packages/ketcher-core/src/application/editor/actions/basic.ts","../../packages/ketcher-core/src/application/editor/actions/chain.ts","../../packages/ketcher-core/src/application/editor/actions/closelyFusing.ts","../../packages/ketcher-core/src/application/editor/actions/fragment.ts","../../packages/ketcher-core/src/application/editor/actions/erase.ts","../../packages/ketcher-core/src/application/editor/actions/paste.ts","../../packages/ketcher-core/src/application/editor/actions/reaction.ts","../../packages/ketcher-core/src/application/editor/actions/rotate.ts","../../packages/ketcher-core/src/application/editor/actions/simpleobject.ts","../../packages/ketcher-core/src/application/editor/actions/template.ts","../../packages/ketcher-core/src/application/editor/actions/text.ts","../../packages/ketcher-core/src/application/editor/shared/constants.js","../../packages/ketcher-core/src/application/editor/index.ts","../../packages/ketcher-core/src/application/ketcher.ts","../../packages/ketcher-core/src/application/ketcherBuilder.ts","App.tsx","../../packages/ketcher-react/src/script/api.ts","../../packages/ketcher-react/src/contexts/appContext.tsx","../../packages/ketcher-react/src/contexts/errorsContext.tsx","../../packages/ketcher-react/src/contexts/settingsContext.tsx","../../packages/ketcher-react/src/contexts/formContext.tsx","../../packages/ketcher-react/src/script/ui/action/atoms.js","../../packages/ketcher-react/src/script/ui/action/copyAs.js","../../packages/ketcher-react/src/script/ui/action/copyImageToClipboard.js","../../packages/ketcher-react/src/script/ui/action/isHidden.ts","../../packages/ketcher-react/src/script/ui/action/debug.js","../../packages/ketcher-react/src/script/ui/component/cliparea/cliparea.jsx","../../packages/ketcher-react/src/script/ui/data/schema/options-schema.ts","../../packages/ketcher-react/src/script/ui/storage-ext.js","../../packages/ketcher-react/src/script/ui/state/options/index.js","../../packages/ketcher-react/src/script/ui/data/schema/schema-helper.js","../../packages/ketcher-react/src/script/ui/data/schema/sdata-schema.js","../../packages/ketcher-react/src/script/ui/state/modal/sdata.js","../../packages/ketcher-react/src/script/ui/state/modal/form.js","../../packages/ketcher-react/src/script/ui/state/request/request.types.ts","../../packages/ketcher-react/src/script/ui/state/request/index.ts","../../packages/ketcher-react/src/script/ui/state/constants.js","../../packages/ketcher-react/src/script/ui/data/schema/struct-schema.js","../../packages/ketcher-react/src/script/ui/data/convert/structconv.js","../../packages/ketcher-react/src/script/ui/action/tools.js","../../packages/ketcher-react/src/script/ui/state/shared.js","../../packages/ketcher-react/src/script/ui/state/server/index.js","../../packages/ketcher-react/src/script/ui/action/server.js","../../packages/ketcher-react/src/script/ui/data/templates.js","../../packages/ketcher-react/src/script/ui/action/templates.js","../../packages/ketcher-react/src/script/ui/action/zoom.js","../../packages/ketcher-react/src/script/ui/action/functionalGroups.ts","../../packages/ketcher-react/src/script/ui/action/index.js","../../packages/ketcher-react/src/icons/index.tsx","../../packages/ketcher-react/src/script/ui/component/view/icon.jsx","../../packages/ketcher-react/src/script/ui/views/toolbars/shortcutStr.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ActionButton/ActionButton.tsx","../../packages/ketcher-react/src/script/ui/Portal/Portal.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/variants/DefaultMultiTool/DefaultMultiTool.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/variants/GroupedMultiTool/GroupedMultiTool.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/ToolbarMultiToolItem.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/usePortalOpening.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/usePortalStyle.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarMultiToolItem/variants/chooseMultiTool.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/ToolbarGroupItem.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/BottomToolbar/TemplatesList/TemplatesList.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/BottomToolbar/BottomToolbar.tsx","../../packages/ketcher-react/src/script/ui/state/templates/init-lib.js","../../packages/ketcher-react/src/script/ui/state/modal/index.js","../../packages/ketcher-react/src/script/ui/state/templates/index.js","../../packages/ketcher-react/src/script/ui/state/action/index.js","../../packages/ketcher-react/src/script/ui/state/toolbar/index.js","../../packages/ketcher-react/src/script/ui/state/functionalGroups/index.ts","../../packages/ketcher-react/src/script/ui/state/index.js","../../packages/ketcher-react/src/script/ui/views/toolbars/BottomToolbar/BottomToolbar.container.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ToolbarGroupItem/utils/makeItems.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/Bond/options.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/leftToolbarOptions.ts","../../packages/ketcher-react/src/hooks/useSettingsContext.ts","../../packages/ketcher-react/src/hooks/useResizeObserver.ts","../../packages/ketcher-react/src/hooks/useFormContext.tsx","../../packages/ketcher-react/src/hooks/useAppContext.ts","../../packages/ketcher-react/src/hooks/useInterval.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/ArrowScroll/ArrowScroll.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/mediaSizes.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/Bond/Bond.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/RGroup/RGroup.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/Shape/Shape.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/Transform/Transform.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/LeftToolbar.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/LeftToolbar/LeftToolbar.container.ts","../../packages/ketcher-react/src/script/ui/component/view/Atom/Atom.jsx","../../packages/ketcher-react/src/script/ui/views/toolbars/RightToolbar/AtomsList/AtomsList.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/RightToolbar/RightToolbar.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/RightToolbar/RightToolbar.container.ts","../../packages/ketcher-react/src/script/ui/views/toolbars/TopToolbar/ZoomList/ZoomList.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/TopToolbar/HelpLink/HelpLink.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/TopToolbar/TopToolbar.tsx","../../packages/ketcher-react/src/script/ui/views/toolbars/TopToolbar/TopToolbar.container.ts","../../packages/ketcher-react/src/script/ui/data/convert/keynorm.js","../../packages/ketcher-react/src/script/ui/state/hotkeys.js","../../packages/ketcher-react/src/script/ui/views/AppClipArea.tsx","../../packages/ketcher-react/src/script/ui/App/AppHidden/AppHidden.container.ts","../../packages/ketcher-react/src/script/ui/App/AppHidden/AppHidden.tsx","../../packages/ketcher-react/src/script/ui/views/modal/mediaSizes.ts","../../packages/ketcher-react/src/script/ui/views/components/Dialog/Dialog.tsx","../../packages/ketcher-react/src/script/ui/views/components/Spinner/Spinner.tsx","../../packages/ketcher-react/src/script/editor/shared/closest.js","../../packages/ketcher-react/src/script/editor/tool/apoint.js","../../packages/ketcher-react/src/script/editor/shared/utils.js","../../packages/ketcher-react/src/script/editor/tool/atom.js","../../packages/ketcher-react/src/script/editor/tool/attach.js","../../packages/ketcher-react/src/script/editor/tool/bond.js","../../packages/ketcher-react/src/script/editor/tool/chain.js","../../packages/ketcher-react/src/script/editor/tool/charge.js","../../packages/ketcher-react/src/script/editor/tool/helper/locate.js","../../packages/ketcher-react/src/script/editor/tool/helper/lasso.js","../../packages/ketcher-react/src/script/editor/tool/sgroup.js","../../packages/ketcher-react/src/script/editor/tool/select.ts","../../packages/ketcher-react/src/script/editor/tool/eraser.js","../../packages/ketcher-react/src/script/editor/tool/paste.js","../../packages/ketcher-react/src/script/editor/tool/rgroupatom.js","../../packages/ketcher-react/src/script/editor/tool/rgroupfragment.js","../../packages/ketcher-react/src/script/editor/tool/reactionarrow.js","../../packages/ketcher-react/src/script/editor/tool/reactionmap.js","../../packages/ketcher-react/src/script/editor/tool/reactionplus.js","../../packages/ketcher-react/src/script/editor/tool/reactionunmap.js","../../packages/ketcher-react/src/script/editor/tool/rotate.js","../../packages/ketcher-react/src/script/editor/tool/simpleobject.js","../../packages/ketcher-react/src/script/editor/tool/template.js","../../packages/ketcher-react/src/script/editor/tool/text.ts","../../packages/ketcher-react/src/script/editor/tool/index.js","../../packages/ketcher-react/src/script/editor/tool/enhanced-stereo.ts","../../packages/ketcher-react/src/script/editor/Editor.ts","../../packages/ketcher-react/src/script/editor/utils/customOnChangeHandler.ts","../../packages/ketcher-react/src/script/ui/component/ContextMenu/ContextMenu.tsx","../../packages/ketcher-react/src/script/ui/views/components/StructEditor/StructEditor.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/meta/About/About.jsx","../../packages/ketcher-react/src/script/ui/component/form/input.jsx","../../packages/ketcher-react/src/script/ui/component/form/form/form.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/meta/Settings/components/Accordion/Accordion.tsx","../../packages/ketcher-react/src/script/ui/component/form/colorPicker/ColorPicker.tsx","../../packages/ketcher-react/src/script/ui/component/form/measure-input.jsx","../../packages/ketcher-react/src/script/ui/component/view/openbutton.jsx","../../packages/ketcher-react/src/script/ui/component/view/savebutton.jsx","../../packages/ketcher-react/src/script/ui/component/form/select-checkbox.jsx","../../packages/ketcher-react/src/script/ui/component/form/systemfonts.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/meta/Settings/Settings.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Check/components/ErrorsCheck.jsx","../../packages/ketcher-react/src/script/ui/component/view/Tabs/Tabs.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Check/Check.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Analyse/components/FormulaInput/FormulaInput.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Analyse/components/FrozenInput/FrozenInput.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Analyse/Analyse.jsx","../../packages/ketcher-react/src/script/ui/component/view/spin.jsx","../../packages/ketcher-react/src/script/ui/component/structrender.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Recognize/Recognize.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/process/Miew/Miew.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/ElementNumber/ElementNumber.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Atom/Atom.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Attach/Attach.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Attach/Attach.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Automap/Automap.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Automap/Automap.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/Bond/Bond.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/RgroupLogic/components/IfThenSelect/IfThenSelect.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/RgroupLogic/RgroupLogic.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/RgroupLogic/RgroupLogic.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/document/Open/Open.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/document/Open/Open.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/document/Save/SaveImageTab.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/document/Save/Save.jsx","../../packages/ketcher-react/src/script/ui/data/convert/structConverter.ts","../../packages/ketcher-react/src/script/ui/dialog/toolbox/enhancedStereo/enhancedStereo.tsx","../../packages/ketcher-react/src/script/ui/dialog/template/EmptySearchResult.tsx","../../packages/ketcher-react/src/script/ui/utils/index.ts","../../packages/ketcher-react/src/script/ui/dialog/template/TemplateTable.tsx","../../packages/ketcher-react/src/script/ui/state/functionalGroups/selectors/index.ts","../../packages/ketcher-react/src/script/ui/views/components/FunctionalGroups/FunctionalGroups.tsx","../../packages/ketcher-react/src/script/ui/dialog/toolbox/labeledit.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/AtomInfo/AtomInfo.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/ElementsTable/components/Header.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/ElementsTable/components/MainRow.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/ElementsTable/components/OutinerRow.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/ElementsTable/ElementsTable.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/GenericGroups/components/components/GenSet.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/GenericGroups/components/GenGroup.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/GenericGroups/GenericGroups.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/components/TypeChoice/TypeChoice.jsx","../../packages/ketcher-react/src/script/ui/views/modal/components/PeriodTable/PeriodTable.jsx","../../packages/ketcher-react/src/script/ui/component/form/buttonlist.jsx","../../packages/ketcher-react/src/script/ui/dialog/toolbox/rgroup/rgroup.jsx","../../packages/ketcher-react/src/script/ui/component/form/combobox/combobox.jsx","../../packages/ketcher-react/src/script/ui/dialog/toolbox/sdata.jsx","../../packages/ketcher-react/src/script/ui/dialog/toolbox/sgroup.jsx","../../packages/ketcher-react/src/script/ui/dialog/template/template-attach.jsx","../../packages/ketcher-react/src/script/ui/component/form/select.jsx","../../packages/ketcher-react/src/script/ui/dialog/template/TemplateDialog.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/Text/FontControl/FontControl.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/Text/TextButton/TextButton.tsx","../../packages/ketcher-react/src/script/ui/views/modal/components/Text/Text.tsx","../../packages/ketcher-react/src/script/ui/dialog/index.ts","../../packages/ketcher-react/src/script/ui/views/modal/components/toolbox/FG/RemoveFG.tsx","../../packages/ketcher-react/src/script/ui/views/modal/Modal.container.ts","../../packages/ketcher-react/src/script/ui/views/modal/Modal.tsx","../../packages/ketcher-react/src/script/ui/state/editor/index.js","../../packages/ketcher-react/src/script/ui/views/Editor.jsx","../../packages/ketcher-react/src/script/ui/App/App.container.ts","../../packages/ketcher-react/src/script/ui/App/App.tsx","../../packages/ketcher-react/src/script/ui/App/initApp.tsx","../../packages/ketcher-react/src/script/builders/ketcher/KetcherBuilder.ts","../../packages/ketcher-react/src/script/index.ts","../../packages/ketcher-react/src/Editor.tsx","ErrorModal/ErrorModal.tsx","index.tsx","../../packages/ketcher-standalone/src/infrastructure/services/struct/indigoWorker.types.ts","../../packages/ketcher-standalone/src/infrastructure/services/struct/standaloneStructService.ts","../../packages/ketcher-standalone/src/infrastructure/services/struct/standaloneStructServiceProvider.ts"],"names":["ElementColor","H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","Ds","Rg","Cn","Nh","Fl","Mc","Lv","Ts","Og","elementsArray","number","label","period","group","title","state","origin","type","mass","leftH","elementsMap","reduce","acc","element","set","Map","Elements","get","key","filter","predicate","Generics","atom","any","labels","metal","halogen","acyclic","carbo","alkynyl","alkyl","alkenyl","hetero","alkoxy","cyclic","aryl","cycloalkyl","cycloalkenyl","special","AtomList","params","this","notList","ids","id","currenElement","push","labelList","join","atomList","sort","toString","Vec2","args","length","x","y","z","arguments","parseFloat","Error","Math","sqrt","v","s","y1","f","scaled","l","toFixed","assert","max","min","ceil","floor","angle","sin","cos","rotateSC","atan2","a","b","diff","v1","v2","cross","dot","i","addScaled","f1","f2","lc2","StereoLabel","Pile","item","setB","isSuperset","subset","has","expression","Array","from","union","add","Set","getValueOrDefault","value","defaultValue","radicalElectrons","radical","Atom","PATTERN","RADICAL","DOUPLET","SINGLET","TRIPLET","attributes","fragment","alias","attrlist","isotope","charge","rglabel","attpnt","explicitValence","valence","implicitH","pp","sgs","ringBondCount","substitutionCount","unsaturatedAtom","hCount","aam","invRet","exactChangeFlag","rxnFragmentType","stereoLabel","stereoParity","neighbors","badConn","Object","defineProperty","enumerable","fidMap","ret","conn","isQuery","groupno","rad","hyd","absCharge","abs","attrs","attr","NONE","STEREO_PARITY","ODD","EVEN","EITHER","StereoFlag","Bond","begin","end","xxx","stereo","STEREO","topology","TOPOLOGY","reactingCenterStatus","len","sb","sa","center","struct","p1","atoms","p2","sub","normalized","aidMap","cp","bond","calcStereoFlag","stereoAids","filteredStereoAtoms","map","aid","stereoFlag","hasAnotherLabel","some","Mixed","match","Abs","And","Or","TYPE","SINGLE","DOUBLE","TRIPLE","AROMATIC","SINGLE_OR_DOUBLE","SINGLE_OR_AROMATIC","DOUBLE_OR_AROMATIC","ANY","DATIVE","HYDROGEN","UP","DOWN","CIS_TRANS","RING","CHAIN","REACTING_CENTER","NOT_CENTER","UNMARKED","CENTER","UNCHANGED","MADE_OR_BROKEN","ORDER_CHANGED","MADE_OR_BROKEN_AND_CHANGED","Fragment","stereoAtoms","stereoFlagPosition","fr","frId","isAdd","includes","bonds","values","atomId","fragmentId","getFragment","bb","getCoordBoundingBox","Scale","scaled2obj","options","scale","obj2scaled","StereoValidator","isCorrectStereoCenter","beginNeighs","endNeighs","beginAtom","EndAtomNeigh","NaN","Number","atomGetNeighbors","FunctionalGroupsProvider","functionalGroupsList","list","instance","Box2Abs","p0","lp","rb","p","ext","d","centre","relBox","width","height","b1","b2","c","dc","dd","da","db","SGroupBracketParams","w","h","n","SGroup","bracketBox","bracketDir","areas","highlight","highlighting","selected","selectionPlate","patoms","xBonds","neiAtoms","data","mul","connectivity","name","subscript","expanded","undefined","attached","absolute","showUnits","nCharsToDisplay","tagChar","daspPos","fieldType","fieldName","fieldValue","units","query","queryOp","keys","forEach","oldValue","offset","sum","topLeftPoint","context","contentBoxes","contentBB","direction","pos","bba","extend","bbb","include","sgroups","size","descriptorIntersects","sAtom","sAtomPP","getMassCentre","sgroup","newAtoms","j","_mol","sg","atomMap","removeNegative","filterAtoms","field","elem","allAtoms","splice","mol","parentAtomSet","crossBonds","bid","sGroup","crossBondsPerAtom","flat","getCenter","braketBox","vext","atomSet","brackets","crossBondsPerAtomValues","bracketWidth","sz","cl","cr","bracketHeight","negated","cl0","cr0","dr","dl","getDir","a0","_atom","getAtoms","indexOf","inBonds","xAtom1","xAtom2","crossBond","bond1","bond2","tailAtom","amap","aid2","newBond","newCrossBond","xBond2","sGroupForest","getPathToRoot","reverse","sgid","atomAddToSGroup","sgBottomRightPoint","bottomRightPoint","segmentIntersection","SUP","MUL","SRU","MON","MER","COP","CRO","MOD","GRA","COM","MIX","FOR","DAT","GEN","RxnArrowMode","FunctionalGroup","getInstance","getFunctionalGroupsList","functionalGroups","relatedSGroup","molecule","fg","getBonds","relatedSGroupId","functionalGroup","isFunctionalGroup","sgroupsFromReStruct","contractedFunctionalGroups","isContractedFunctionalGroup","contractedFunctionalGroupsAtoms","sgroupId","isExpanded","HalfBond","dir","norm","ang","loop","contra","next","leftSin","leftCos","leftNeighbor","rightSin","rightCos","rightNeighbor","Loop","hbs","isConvex","dblBonds","aromatic","convex","hb","halfBonds","RGroup","atrributes","frags","resth","range","ifthen","fid","rgroups","frid","find","_rgid","rgroup","SimpleObjectMode","RxnArrow","currentP","mode","RxnPlus","SGroupForest","parent","children","atomSets","order","queue","shift","newId","isStrictSuperset","isSubset","equals","parents","childs","findIndex","childId","path","guess","getAtomSetRelations","resetParentLink","parentId","childIndex","checkOverlapping","res","sid","sgAtoms","SimpleObject","line","rectangle","Pool","nextId","entries","arrayAddIfMissing","array","TextCommand","Struct","loops","isReaction","rxnArrows","rxnPluses","simpleObjects","texts","_aid","hasRxnProps","_bid","hasRxnArrow","hasRxnPluses","bondSet","dropRxnSymbols","simpleObjectsSet","textsSet","mergeInto","rg","_fnum","clone","getFragmentIds","keepAllRGroups","fidMask","_frag","rgroupsIds","rgid","keepGroup","newfid","oldfid","bidMap","insert","soid","initHalfBonds","initNeighbors","updateHalfBonds","sortNeighbors","findLoops","addAtom","a1","a2","hb1","hb2","hbid","dist","turnLeft","oxAngle","clear","bondInitHalfBonds","left","hbl","ir","il","setHbNext","halfBondSetAngle","nei","nei2","nextNei","atomSortNeighbors","halfBondUpdate","atomUpdateHalfBonds","remove","position","vec","global","totalLength","cnt","bld","getBondLengthData","minDist","k","totalDist","firstaid","pop","neiId","discardExistingFragments","addedAtoms","components","component","findConnectedComponent","idSet","frag","updateStereoAtom","findConnectedComponents","comp","markFragment","avg","getAvgBondLength","getAvgClosestAtomDistance","hbi","ai","bi","hbj","aj","bj","subloops","continueFlag","atomToHalfBond","aid1","subloop","slice","hbid1","hbid2","hba","hbb","every","loopArr","halfBondAngle","totalAngle","PI","hbida","hbidb","hbIdNext","newLoops","bondsToMark","hbId","partitionLoop","loopId","loopIsInner","loopHasSelfIntersections","loopIsConvex","calcConn","isAromatic","correctConn","hasImplicitH","calcValenceMinusHyd","calcValence","calcImplicitHydrogen","connectedComponents","barriers","arrowPos","reactants","products","defineRxnFragmentTypeForAtomset","atomset","arrowpos","Text","content","ifDef","target","isArray","tfx","moleculeToKet","body","source","result","refsToRGroups","rgi","val","fromRlabel","rgnumber","rglabelToKet","atomListToKet","stereoCare","weight","parseInt","atomToKet","bondToKet","toUpperCase","sgroupToKet","moleculeToStruct","ketItem","location","attachmentPoints","toRlabel","$refs","el","rglabelToStruct","elements","atomListToStruct","mapping","atomToStruct","bondToStruct","toLowerCase","placement","display","fieldData","sgroupToStruct","markFragments","bindSGroupsToFunctionalGroups","getFragmentCenter","rgroupLogicToKet","rglogic","rgroupToStruct","rgroupLogicToStruct","rlogic","_value","rxnToStruct","simpleObjectToStruct","object","radius","pos0","ellipse","circleToEllipse","parseNode","node","currentStruct","textToStruct","KetSerializer","resultingStruct","ket","JSON","parse","Validator","validate","schema","valid","header","moleculeName","nodes","root","$ref","headerToKet","ketNodes","rgFrags","fragsAtoms","fragAtoms","ketNode","filteredSGroups","filteredSGroupsMap","index","prepareStructForKet","moleculeId","rgroupToKet","plusNode","coord","prop","plusToKet","stringify","fmtInfo","bondTypeMap","bondStereoMap","v30bondStereoMap","bondTopologyMap","countsLinePartition","atomLinePartition","bondLinePartition","atomListHeaderPartition","atomListHeaderLength","atomListHeaderItemLength","chargeMap","valenceMap","implicitHydrogenMap","v30atomPropMap","CHG","RAD","MASS","VAL","HCOUNT","INVRET","SUBST","UNSAT","RBCNT","rxnItemsPartition","FRAGMENT","paddedNum","precision","numStr","replace","padStart","parseDecimalInt","str","isNaN","partitionLine","parts","withspace","partitionLineFixed","itemLength","rxnMerge","mols","nReactants","nProducts","nAgents","shouldReactionRelayout","bbReact","bbAgent","bbProd","molReact","molAgent","molProd","bondLengthData","bondLengthDataMol","bb1","bb2","avgBondLength","getCoordBoundingBoxObj","fragmentType","shiftMol","xorig","over","add_","bbReactAll","bbProdAll","arrowCenter","arrowStart","arrowEnd","rgMerge","scaffold","ctab","readKeyValuePairs","valueString","partition","utils","count","trim","postLoadMul","atomReductionMap","m","raid","patomsMap","identityMap","bondsToRemove","beginIn","endIn","postLoadSru","postLoadSup","postLoadGen","postLoadDat","postLoadMon","postLoadMer","postLoadCop","postLoadCro","postLoadMod","postLoadGra","postLoadCom","postLoadMix","postLoadFor","postLoadAny","applyDataSGroupInfo","propData","split","applyDataSGroupData","finalize","startsWith","endsWith","substr","readKeyMultiValuePairs","loadSGroup","postLoadMap","initSGroup","sGroups","applySGroupProp","propName","numeric","core","kv","applySGroupArrayProp","num","part","strArray","toIntArray","concat","applyDataSGroupName","applyDataSGroupQuery","applyDataSGroupQueryOp","applyDataSGroupDesc","applyDataSGroupInfoLine","applyDataSGroupDataLine","applyDataSGroupExpand","parseAtomLine","atomLine","atomSplit","massDifference","parseBondLine","bondLine","bondSplit","parseAtomListLine","atomListLine","parseCTabV2000","ctabLines","countsSplit","atomCount","bondCount","atomListCount","isAbs","isAnd","stextLinesCount","propertyLinesCount","atomLines","bondLines","atomListLines","pair","rLogic","props","charAt","propValue","isPseudo","test","propertyData","rglabels","a2rs","a2ri","a2r","iii","hhh","ooo","logic","pool","parsePropertyLineAtomList","eg","sGroupId","parsePropertyLines","propId","propVal","applyAtomProp","psg","call","emptyGroups","parseRg2000","coreLines","fragmentLines","parseCTab","strId","hdr","lst","labelsListToIds","parseRxn2000","lines","search","parseAtomLineV3000","subsplit","spacebarsplit","atomListParams","matchNotListInfo","matchedSubstr","splitonce","ival","rgrsplit","parseBondLineV3000","v3000parseCollection","v3000parseSGroup","stripV30","splitSGroupDef","parseBracedNumberList","brkxyzStrs","brkxyz","stripQuotes","parseCTabV3000","norgroups","vals","substring","readRGroups3000","rfrags","rfrag","rlsplit","bracketEquality","currentIndex","firstSliceIndex","quoted","currentSymbol","closingBracketIndex","delim","braceBalance","parseRxn3000","findCtabEnd","findRGroupEnd","molLinesReactants","molLinesProducts","current","rGroups","molLines","version","v2000","v3000","prepareForSaving","prepareMulForSaving","message","saveToMolfile","sgMap","bondMap","idstr","makeAtomBondLines","smtLine","bracketsToMolfile","sdtLine","padEnd","sddLine","nCharnCharsToDisplay","nlRe","chars","prefix","rem","salLine","getCrossBonds","bracketPos","getBracketParameters","bracket","yComplement","parseMol","parseRxn","Molfile","molfile","reaction","bondMapping","molfileLines","common","skipErrors","preserveIndigoDesc","toRemove","errors","getSGroupsBFS","errorIgnore","ex","sGroupDelete","prepareSGroups","writeCTab2000","skipSGroupErrors","getComponents","all","saver","submol","saveMolecule","getCTab","getScaffold","writePaddedNumber","writeHeader","date","Date","writeCR","writeWhiteSpace","write","getMonth","getDate","getFullYear","getHours","getMinutes","repeat","isAbsFlag","enhancedStereoFlag","writeCTab2000Header","atomsIds","atomsProps","writeAtom","writeBond","writeAtomProps","chargeList","isotopeList","radicalList","rglabelList","rglogicList","aplabelList","rbcountList","unsaturatedList","substcountList","writeAtomPropList","writePadded","sgmap","sgmapback","q","expandedGroups","expandedGroupsLine","atomLabel","writePaddedFloat","MolSerializer","DefaultOptions","parseCTFile","reactionRelayout","badHeaderRecover","ex1","ex2","ignoreErrors","noRgroups","CisTrans","neighborsFunc","getNeighbors","swap","arr","i1","i2","tmp","Dfs","atomData","atom_data","nComponentsInReactants","vertices","VertexDesc","edges","EdgeDesc","v_seq","Stereocenters","Smiles","smiles","writtenAtoms","writtenComponents","PARITY","CIS","TRANS","prototype","each","func","getParity","idx","parity","getSubstituents","substituents","sameside","beg","neiBeg","neiEnd","normalize","normBeg","normEnd","prodBeg","prodEnd","samesides","iBeg","iEnd","iNeiBeg","iNeiEnd","sortSubstituents","h0","pureHydrogen","h1","h2","h3","isGeomStereoBond","bondIdx","label1","label2","neiBegin","neiЕnd","build","excludeBonds","ct","sign","dfs_state","parent_vertex","parent_edge","branches","opening_cycles","closing_cycle","SeqElem","vIdx","parVertex","parEdge","walk","vStack","cid","parentVertex","seqElem","atomD","neighbours","neiIdx","edgeIdx","edgeClosingCycle","eIdx","numBranches","numOpeningCycles","buildFromBonds","alleneMask","neiList","nei1","nei1nei","nei2nei","stereocenter","buildOneCenter","allowed_stereocenters","degree","n_double_bonds","implicit_degree","atomIdx","implicitDegree","pyramid","edgeIds","lastAtomDir","nDoubleBonds","nPureHydrogens","neiAtom","edge_idx","nei_idx","rank","as","xyz1","xyz2","main1","main2","side1","side2","mainDir","getBondStereo","xyzzy","stereo0","stereo1","stereo2","nUp","nDown","xyz","centerIdx","u","eps","sine1","cosine1","sine2","cosine2","v3","isPyramidMappingRigid","rigid","_Atom","lowercase","chirality","branch_cnt","paren_written","h_count","isBondInRing","inLoop","setImplicitHydrogen","allowedLowercase","prepareLoopStructure","bondsInLoops","hbids","touchedCistransbonds","markCisTrans","componentsAll","seqEl","vPrevIdx","openingCycles","stereocenters","sc","implicitHIdx","pyramidMapping","counter","cycleNumbers","firstComponent","writeCycleNumber","calcBondDirection","comma","writeRadicals","needBrackets","hydro","cis_trans","dbonds","ctbond_beg","ctbond_end","saved","aromFailBeg","aromFailEnd","updateSideBonds","subst","sidebonds","findBondId","n1","n2","n3","n4","vprev","ntouched","marked","SmiSerializer","_content","ChemicalMimeType","DelimeterRegex","SdfSerializer","molSerializer","exec","chunk","propChunks","deserialize","pc","isFinite","sdfItems","serialize","request","method","url","headers","responseHandler","requestUrl","_","parametrizeUrl","response","fetch","assign","Accept","credentials","then","json","ok","Promise","reject","error","indigoCall","baseUrl","defaultOptions","RemoteStructService","apiPath","isAvailable","indigoVersion","imagoVersions","blob","parVersion","req","status","bind","process","upload_id","complete","timeGap","startTimeGap","resolve","setTimeout","iterate","e","err","metadata","mol_str","outputFormat","resp","text","RemoteStructServiceProvider","currentApiPath","URLSearchParams","document","SupportedFormatProperties","mime","extensions","supportsCoords","formatProperties","Mol","molV3000","rxn","Rxn","rxnV3000","DaylightSmiles","smilesExt","ExtendedSmiles","smarts","DaylightSmarts","inChI","InChI","inChIAuxInfo","InChIAuxInfo","cml","CML","KET","cdxml","CDXML","getPropertiesByFormat","format","KetFormatter","serializer","MolfileV2000Formatter","molfileManager","stringifiedMolfile","stringifiedStruct","RxnFormatter","LayerMap","StereoColoringType","StereLabelStyleType","ServerFormatter","structService","ketSerializer","info","convert","output_format","convertResult","withCoords","promise","layout","parsedStruct","rescale","formatError","SmilesFormatter","smiSerializer","getStructureFromStringAsync","FormatterFactory","structServiceOptions","molfileParseOptions","formatter","separateOptions","molSerializerOptions","identifyStructFormat","sanitizedString","er","Raphael","translateAbs","delta","transform","st","Visel","paths","boxes","boundingBox","exts","vector","translate","ReObject","viselType","visel","render","vbox","highLight","noredraw","removed","show","paper","setStart","drawHighlight","setFinish","hide","restruct","styles","util","box","shiftRayBox","r","rc","rd","pid","nid","id0","id1","makeStroke","dashedPath","dash","t0","t1","black","t2","coordStr","recenterText","rbb","vml","gap","arrow","startPoint","endPoint","OpenAngle","arrowLength","arrowAngle","b0x","transformedPath","svgPath","rotate","lineattr","arrowOpenAngle","FilledTriangle","triangleLength","triangleWidth","fill","arrowFilledTriangle","FilledBow","arrowHeadLength","arrowHeadWidth","arrowHeadAttr","arrowFilledBow","DashedOpenAngle","dashInterval","arrowDashedOpenAngle","Failed","failSignWidth","arrowFailed","BothEndsFilledTriangle","arrowBothEndsFilledTriangle","EquilibriumFilledHalfBow","arrowLen","lineOffset","arrowOffset","arrowEquilibriumFilledHalfBow","EquilibriumFilledTriangle","arrowEquilibriumFilledTriangle","EquilibriumOpenAngle","arrowEquilibriumOpenAngle","UnbalancedEquilibriumFilledHalfBow","unbalanceVal","arrowUnbalancedEquilibriumFilledHalfBow","UnbalancedEquilibriumOpenHalfAngle","arrowUnbalancedEquilibriumOpenHalfAngle","UnbalancedEquilibriumLargeFilledHalfBow","arrowUnbalancedEquilibriumLargeFilledHalfBow","UnbalancedEquilibriumFilleHalfTriangle","arrowUnbalancedEquilibriumFilleHalfTriangle","plus","aromaticBondPaths","a3","b3","mask","bondSingle","color","stroke","bondSingleUp","bondSingleStereoBold","a4","bondDoubleStereoBold","sgBondPath","bondSingleDown","nlines","step","bsp","stereoBond","bondSingleEither","bondDouble","cisTrans","bondSingleOrDouble","nSect","pi","bondSpace","bondTriple","bondAromatic","bondShift","l1","l2","bondAny","bondHydrogen","bondDative","reactingCenter","pathdesc","topologyMark","mark","font","fontszsub","getBBox","radicalCap","lineWidth","dw","dh","radicalBullet","circle","b0","sgroupBracketStyle","selectionRectangle","rect","lassoStyle","selectionPolygon","pstr","selectionLine","rx","ry","rectangleWithAngle","polyline","ShowHydrogenLabels","ReAtom","showLabel","hydrogenOnTheLeft","getVBoxObj","makeHighlightPlate","addReObjectPath","ps","isAtomInContractedFunctionalGroup","atomSelectionPlateRadius","highlightStyle","selectionStyle","isFirstAtomInFunctionalGroup","sgroupName","rightMargin","leftMargin","implh","isHydrogen","Boolean","yl","yr","nl","nr","setHydrogenPos","visibleTerminal","showHydrogenLabels","Off","Hetero","carbonExplicitly","showValenceWarnings","isLabelVisible","pseudo","getLabelText","atomColoring","fontsz","draw","pathAndRBoxTranslate","buildLabel","zoom","showAtomIds","indices","setHighlight","hydroIndex","showHydroIndex","hshift","vshift","showRadical","showIsotope","hydrogenLabels","On","Terminal","TerminalAndHetero","displayHydrogen","hydrogenLeft","hydrogen","showHydrogen","showCharge","showValence","mapValence","showExplicitValence","warning","showWarning","warnings","lsb","asterisk","attpntText","pos1","attpntPath1","attpntRbb","lsbn","fromRelBox","shiftBondEnd","arrowLeft","arrowRight","attpntPath","showAttpnt","bisectLargestSector","aamText","getAamText","queryAttrsText","getQueryAttrsText","labelStyle","flag","stereoLabelType","Classic","IUPAC","shouldDisplayStereoLabel","stereoLabelStyle","aamPath","colorStereogenicCenters","BondsOnly","getColorFromStereoLabel","getStereoAtomColor","childNodes","setAttribute","opacity","stereoLabelNumber","autoFadeOfStereoLabels","getStereoAtomOpacity","aamBox","t","colorOfAndCenters","colorOfOrCenters","colorOfAbsoluteCenters","angles","daMax","margin","ReBond","doubleBondShift","bondRecalc","isBondInContractedFunctionalGroup","bid0","halfbonds","findIncomingStereoUpBond","boldStereo","checkStereoBold","loop1","loop2","selectDoubleBondShiftChain","d1","d2","selectDoubleBondShift","setDoubleBondShift","shiftA","shiftB","findIncomingUpBonds","neihbid1","neihbid2","getBondSingleStereoBoldPath","coords","stereoUpBondGetCoordinates","getStereoBondColor","getBondSingleUpPath","interval","getBondSingleDownPath","getBondSingleEitherPath","getBondLineShift","getBondDoubleStereoBoldPath","s1","s2","getBondDoublePath","getBondAromaticPath","getSingleOrDoublePath","getBondPath","lw","bs","alongIntRc","alongIntMadeBroken","alongSz","acrossInt","acrossSz","tiltTan","getReactingCenterPath","fixed","getTopologyMark","ipath","bondIdxOff","subFontSize","showBondIds","getIdsPath","showHalfBondIds","showLoopIds","includeBoldStereoBond","neibond","defaultColor","beginAtomStereoLabel","endAtomStereoLabel","LabelsOnly","coords1","coords2","neihbid","neihb","cosHalf","biss","dashdotPattern","getAromaticBondPaths","param1","param2","pb","lc","irbb","atom1","atom2","nLeft","nRight","ReEnhancedFlag","highlightPath","getDefaultStereoFlagPosition","stereoFlagMap","absFlagLabel","andFlagLabel","mixedFlagLabel","orFlagLabel","showStereoFlags","ReFrag","firstFrag","secondFrag","_ui_editor","calcBBox","keyOf","BORDER_EXT","ReRGroup","labelBox","fragGetAtoms","fragGetBonds","bbf","rGroupdrawBrackets","labelSet","fontRLabel","logicStyle","fontRLogic","rLogicToString","logicPath","logicBox","_draw","fnum","drawing","cy","leftBracket","rightBracket","ifThen","rangeExists","restH","nextRg","ReRxnArrow","distRef","point","per","calculateDistanceToLine","refPoint","getReferencePointDistance","getReferencePoints","rp","generatePath","refPoints","_paper","scaleFactor","selectionSet","scaledRP","arrowParams","getArrowParams","x1","x2","y2","_id","ReRxnPlus","ReDataSGroupData","dataArea","ReSGroup","remol","firstSgroupAtom","SGroupdrawBrackets","calculatePP","nameI","showValue","boxI","sboxI","drawAttachedDat","sbox","sgroupData","drawAbsoluteDat","drawGroupDat","getHighlighPathInfo","startX","startY","sGroupItem","lowerIndexText","upperIndexText","indexAttribute","BracketParams","crossBondsValues","tl","tr","tt","tb","cc","dt","bracketR","renderIndex","indexPos","indexPath","indexBox","toFront","contractedFunctionalGroupSize","highlightPp","ReSimpleObject","simpleObject","pointToCenter","topX","topY","bottomX","bottomY","distances","onlyOnObject","poly","atan","stylesApplied","enhPath","highlightStyleSimpleObject","ReLoop","rlid","apos","bpos","aromaticCircle","pathStr","halfAngle","qi","ReText","getRelBox","topLeft","leftEdge","firstRow","topEdge","widestRow","nextRow","getRowWidth","lastElOfWidestRow","rightEdge","lastRow","bottomEdge","row","rowWidth","paperScale","shiftY","rawContentState","blocks","block","ranges","getRanges","shiftX","start","flatten","getStyles","nextStyles","isEqual","inlineStyleRanges","inlineRange","customFontSize","style","FontSize","textRange","Bold","Italic","Subscript","Superscript","ReStruct","initLayers","clearMarks","lid","reloops","enhancedFlags","reAtom","adjacentComponents","neighbor","halfBond","compId","aidSet","getConnectedComponent","ccFragmentType","ccid","removeConnectedComponent","addConnectedComponent","layers","class","visible","parentNode","insertBefore","maps","structChanged","markItem","mapChanged","clearVisel","selection","isSelectionEmpty","eachItem","scaleRPath","scaleVisel","force","initialized","_item","atomsChanged","connectedComponentRemoveAtom","clearConnectedComponents","atomsChangedArray","assignConnectedComponents","verifyLoops","updLoops","updateLoops","showLabels","showBonds","showLoops","showReactionSymbols","showSGroups","showFragments","showRGroups","showEnhancedFlags","showSimpleObjects","showTexts","reloop","markBond","simpleObjectsChanged","textsChanged","rxnArrowsChanged","rxnPlusesChanged","resgroup","bondlist","markAtom","isValid","loopRemove","enhancedFlagsChanged","chid","bondsChanged","redraw","mapValues","isSelectable","sGroupAtoms","showItemSelection","exists","items","isSelectionSvgObjectExists","makeSelectionPlate","FRAC","calcAngle","fracAngle","angle2","round","degrees","calcNewAtomPos","ctrlKey","setFracAngle","mergeBondsParams","struct1","struct2","begin1","begin2","end1","end2","mergeAngle","merged","inRange","Render","clientArea","opt","renderWidth","clientWidth","renderHeight","clientHeight","userOpts","ZERO","rotationStep","labelFontSize","autoScale","autoScaleMargin","maxBondLength","hideImplicitHydrogen","hideTerminalLabels","doubleBondWidth","stereoBondWidth","bondThickness","view2obj","isRelative","scroll","scrollPos","useOldZoom","obj2view","scrollLeft","scrollTop","page2obj","pagePos","curtop","curleft","offsetTop","offsetLeft","offsetParent","top","cumulativeOffset","pageX","pageY","setPaperSize","setSize","setViewBox","setOffset","newoffset","setZoom","setScrollOffset","cx","sSz","x0","y0","ey","calcExtend","update","setScale","canvas","setMolecule","viewSz","changes","setSelection","sf","sz1","marg","mv","csz","sz2","UNIT","eb","vb","cb","oldCb","oldBb","BaseOperation","priority","execute","_inverted","invert","level","halfBondId","invalidateLoop","bondId","halfBond1","halfBond2","invalidateAtom","invalidateBond","invalidateItem","OperationType","freeze","ATOM_ADD","ATOM_DELETE","ATOM_ATTR","ATOM_MOVE","CALC_IMPLICIT_H","BOND_ADD","BOND_DELETE","BOND_ATTR","BOND_MOVE","LOOP_MOVE","S_GROUP_ATOM_ADD","S_GROUP_ATOM_REMOVE","S_GROUP_ATTR","S_GROUP_CREATE","S_GROUP_DELETE","S_GROUP_ADD_TO_HIERACHY","S_GROUP_REMOVE_FROM_HIERACHY","R_GROUP_ATTR","R_GROUP_FRAGMENT","UPDATE_IF_THEN","RESTORE_IF_THEN","RXN_ARROW_ADD","RXN_ARROW_DELETE","RXN_ARROW_MOVE","RXN_ARROW_RESIZE","RXN_PLUS_ADD","RXN_PLUS_DELETE","RXN_PLUS_MOVE","S_GROUP_DATA_MOVE","CANVAS_LOAD","ALIGN_DESCRIPTORS","SIMPLE_OBJECT_ADD","SIMPLE_OBJECT_DELETE","SIMPLE_OBJECT_MOVE","SIMPLE_OBJECT_RESIZE","RESTORE_DESCRIPTORS_POSITION","FRAGMENT_ADD","FRAGMENT_DELETE","FRAGMENT_STEREO_FLAG","FRAGMENT_ADD_STEREO_ATOM","FRAGMENT_DELETE_STEREO_ATOM","ENHANCED_FLAG_MOVE","TEXT_CREATE","TEXT_UPDATE","TEXT_DELETE","TEXT_MOVE","AtomAttr","attribute","data2","inverted","AtomMove","noinvalidate","reatom","AtomAdd","atomSetPos","AtomDelete","restructedAtom","markItemRemoved","BondAttr","BondMove","BondAdd","structBond","atomAddNeighbor","BondDelete","rebond","prev","CanvasLoad","oldStruct","clearVisels","AlignDescriptors","history","structBox","alignPoint","RestoreDescriptorsPosition","EnhancedFlagMove","currentPosition","newPosition","UpdateIfThen","rgNew","rgOld","skipRgids","rgid_new","rgid_old","ifThenHistory","RestoreIfThen","rgValue","FragmentAdd","FragmentDelete","enhancedFalg","FragmentAddStereoAtom","invalidateEnhancedFlag","FragmentDeleteStereoAtom","FragmentStereoFlag","updateStereoFlag","CalcImplicitH","aids","atomIds","aIds","LoopMove","RGroupAttr","rgroupId","rgp","RGroupFragment","rg_new","rg_old","findRGroupByFragment","removeOld","setNew","RxnArrowMove","Base","move","RxnArrowResize","anchor","previousPos0","get_xy0","previousPos1","RxnPlusMove","RxnPlusAdd","plid","newRxn","structRxn","rxnPlusSetPos","RxnPlusDelete","RxnArrowAdd","itemId","positions","rxnArrowSetPos","RxnArrowDelete","performed","SimpleObjectAdd","toCircle","makeCircleFromEllipse","simpleObjectSetPos","SimpleObjectDelete","SimpleObjectMove","handleRectangleChangeWithAnchor","SimpleObjectResize","circlePoint","position0","position1","SGroupAtomAdd","SGroupAtomRemove","removeAtom","SGroupAttr","setAttr","SGroupDataMove","SGroupAddToHierarchy","relations","SGroupRemoveFromHierarchy","SGroupCreate","SGroupDelete","relatedFGroupId","fgid","TextCreate","textSetPosition","TextDelete","TextUpdate","previousContent","TextMove","difference","Action","operations","operation","isDummy","action","invertedOperation","perform","addOp","fromAromaticTemplateOnBond","template","events","simpleFusing","getBondFragment","atomsInStruct","getFragmentWithBondMap","SELECTION_DISTANCE_COEFFICIENT","findMaps","findClosestAtom","findClosestBond","inBox","xDist","firstAtomPp","pg","rxnArrow","calcDistance","ref","skip","closestAtom","closestBond","contains","cursorPosition","referencePoints","skipId","closestBondCenter","maxMinDist","minCDist","mid","cdist","mp","merge","srcId","atomGetAttr","atomGetDegree","atomGetSGroups","atomGetPos","findStereoAtoms","structSelection","atomForNewBond","prevBondId","prevBondType","neiPos","maxI","maxAngle","neiNeighbours","neiV","neiAngle","neiNei","neiNeiPos","vDiff","prevBondAngle","closest","getRelSgroupsBySelection","selectedAtoms","_sgid","fromRGroupAttrs","fromRGroupFragment","rgidNew","fromUpdateIfThen","rgidOld","fromSeveralSgroupAddition","descriptors","fromSgroupAddition","fValue","localAttrs","mergeWith","setExpandSGroup","fromAtomsAttrs","sGroupAttributeAction","fromSgroupDeletion","sG","sGroupsRecalcCrossBonds","getAttrs","asteriskAction","plainCarbon","isPlainCarbon","fromSgroupAttrs","fromSgroupAction","newSg","sourceAtoms","SgContexts","currSelection","getAtomsBondIds","uniq","bondid","fromBondAction","atomsFromBonds","newSourceAtoms","fromGroupAction","Multifragment","fromMultiFragmentAction","Group","fromAtomAction","targetAtoms","allFragments","fragId","removeAtomFromSgroupIfNeeded","removeSgroupIfNeeded","sgCounts","fromBondAddition","pos2","mergeFragments","mergeSgroups","bnd","fromBondStereoUpdate","mergeFragmentsIfNeeded","fromBondsAttrs","reset","attrGetDefault","withReverse","beginFrId","endFrId","fragmentStereoBonds","getStereoAtomsMap","stereoProp","aId","fromStereoAtomAttrs","stereoAtomsMap","correctAtomIds","getStereoParity","newAtomParity","bondChangingAction","itemID","bondProps","newItemId","isInteger","fromBondFlipping","plainBondTypes","fromAtomAddition","atomNeighbors","fromAtomsFragmentAttr","newfrid","oldfrid","fromAtomMerge","dstId","fragAction","mergeBondId","getAttrHash","dstAtomNeighbors","frid2","fridAtoms","atomsToNewFrag","moveAtomsAction","srcAtoms","dstAtom","without","fromNewCanvas","fromDescriptorsAlign","fromChain","dx","dy","chainItems","fromItemsFuse","usedAtoms","dst","src","mergeMap","atomPairs","bondCI","fromBondsMerge","getItemsToFuse","editor","mergeItems","closestMap","closestToMerge","findMerge","getHoverToFuse","hoverItems","now","fromMultipleMove","lists","atomsToInvalidate","rxnPulse","sgData","fromStereoFlagUpdate","processAtom","usedIds","fromFragmentSplit","rgForRemove","fromOneAtomDeletion","fromFragmentDeletion","fromBondDeletion","skipAtoms","atomsToRemove","fromOneBondDeletion","frids","actionRemoveDataSGroups","actionRemoveBonds","frid3","fromPaste","pstruct","xy0","getStructCenter","fridMap","pasteItems","tmpAtom","newsgid","oper","__frag","newRgId","onlyOneStructsSgroupId","xmin","ymin","xmax","ymax","fromArrowAddition","fromArrowResizing","fromArrowDeletion","fromPlusAddition","fromPlusDeletion","fromFlip","fids","allFragmentsOfStructure","selectedFragmentsOfStructure","bbox","calcCenter","flipItemByCenter","fromRotate","rotateDelta","did","stereoFlags","flagId","fromBondAlign","fromSimpleObjectDeletion","fromSimpleObjectAddition","fromSimpleObjectResizing","fromTemplateOnCanvas","fromTemplateOnAtom","extraBond","tmpl","extraRes","additionalAtom","middleAtom","actionRes","extraBondAction","angle0","fromTemplateOnBondAction","flip","fromTemplateOnBond","tmplBond","tmplBegin","atomsMap","bondAtoms","mergeA","tBond","existId","fromTextCreation","fromTextUpdating","fromTextDeletion","parseStruct","structStr","create","getStructure","structureFormat","formatterFactory","getStructureFromStructAsync","Ketcher","isExtended","molfileFormat","containsReaction","rxnfile","withAuxInfo","meta","generateImageAsBase64","base64","byteCharacters","atob","byteNumbers","charCodeAt","byteArray","Uint8Array","Blob","DefaultStructServiceOptions","structServiceProvider","serviceOptions","mergedServiceOptions","createStructService","ketcher","Miew","StandaloneStructServiceProvider","require","App","hiddenButtonsConfig","hiddenButtons","window","button","hidden","getHiddenButtonsConfig","useState","hasError","setHasError","errorMessage","setErrorMessage","errorHandler","buttons","staticResourcesUrl","onInit","close","createApi","clean","aromatize","dearomatize","calculateCip","automap","check","calculate","recognize","appContext","React","createContext","errorsContext","settingsContext","formContext","basicAtoms","atomCuts","A","shortcut","tool","opts","copyAs","currentState","structSelected","structData","clipboardData","setData","navigator","clipboard","writeText","server","factory","service","generateImage","backgroundColor","image","ClipboardItem","isHidden","buttonName","debugObj","molStr","molQs","encodeURIComponent","qs","ieCb","ClipArea","textAreaRef","createRef","listeners","mouseup","event","cliparea","isActiveElement","focused","focus","select","mousedown","shiftKey","preventDefault","copy","onCopy","cut","onCut","paste","onPaste","formats","getData","fmt","en","addEventListener","removeEventListener","_jsx","className","clsx","classes","contentEditable","autoFocus","suppressContentEditableWarning","Component","tagName","actions","enabled","queryCommandSupported","execCommand","ClipboardEvent","default","enum","enumNames","LabelsAndBonds","minimum","maximum","SERVER_OPTIONS","miew","miewMode","miewTheme","miewAtomLabel","MIEW_OPTIONS","optionsSchema","required","properties","resetToSelect","getDefaultOptions","storage","localStorage","getItem","isSet","setItem","initOptionsState","app","templates","analyse","roundWeight","roundMass","roundElAnalysis","checkOptions","file","settings","errProps","jsonschema","property","validation","getServerSettings","pick","appUpdate","dispatch","recognizeActions","setStruct","mapOf","oneOf","desc","constant","radioButtonsSchema","contextSchema","sData","radiobuttons","minLength","invalidMessage","sdataCustomSchema","sdataSchema","firstKeyOf","obj","getSdataDefault","correctErrors","payload","onContextChange","onFieldNameChange","formsState","atomProps","primary","secondary","moleculeErrors","labelEdit","rgroupLogic","save","filename","attach","sdata","initSdata","updateFormState","formReducer","formName","init","actionContext","actionFieldName","newstate","sdataReducer","INDIGO_VERIFICATION","indigoVerification","initialState","supportedSGroupTypes","maxLength","pattern","rgroupSchema","sgroupMap","minium","attachSchema","fromElement","selem","satom","fromAtom","ap","sap","toElement","toAtomList","capitalize","toAtom","pch","atomSchema","conv","toBond","toBondType","caption","bondCaptionMap","fromBondType","single","up","down","updown","double","crossed","triple","singledouble","singlearomatic","doublearomatic","dative","fromSgroup","ssgroup","toSgroup","toolActions","erase","chain","transforms","arrows","shapes","bondCuts","typeSchema","bondSchema","onAction","dialog","thunk","load","getState","formatterOptions","confirm","sgId","getOffset","updateOffset","stereAtomsMap","isBlank","tools","optsTypes","ketcherErrors","checkParams","badVal","ketcherCheck","types","serverCall","serverTransform","loadedStruct","explicitSelected","omit","config","disabled","arom","dearom","cip","standalone","templateLib","_tool","zoomList","findLastIndex","functionalGroupsLib","__","open","undo","historySize","redo","dontClipMessage","hasSelection","copies","copyImageToClipboard","active","help","about","selectionTool","toolbar","visibleTools","alignDescriptors","debug","icons","CopyIcon","dropdown","logo","emptyIcon","Icon","hasOwnProperty","findIconByName","shortcutAliasMap","Escape","Delete","Mod","platform","shortcutStr","ActionButton","disableableButtons","_jsxs","onClick","stopPropagation","Portal","createElement","isElementInDom","isOpen","addElementInDOM","addClassName","updateStyle","removeElementFromDOM","prevProps","removeClassNames","querySelector","appendChild","removeChild","classNames","classList","prevStyle","ReactDOM","createPortal","DefaultMultiTool","toolbarItem","currentStatus","GroupedMultiTool","groups","descriptor","ToolbarMultiToolItem","variant","opened","vertical","onOpen","useRef","setIsOpen","useEffect","currentId","usePortalOpening","portalStyle","setPortalStyle","getBoundingClientRect","scrollOffset","scrollingElement","usePortalStyle","selectedTool","displayMultiToolItem","option","actionButtonProps","defaultClasses","chooseMultiTool","portalClassName","ToolbarGroupItem","TemplatesList","isTemplate","makeAction","initLib","lib","initTmplLib","cacheEl","deserializeSdfTemplates","userLib","userTmpls","fileName","sdfSerializer","prefetchStatic","tmpls","prefetch","files","prefetchSplit","fn","svgs","svgContent","innerHTML","prefetchRender","cachedFiles","pr","prerender","openDialog","dialogName","onResult","onCancel","updateLocalStore","initTmplsState","tmplActions","attachActions","activeTool","actObj","actionName","pickBy","initial","freqAtoms","currentAtom","updateVisibleTools","visibleTool","regExp","menuHeight","innerHeight","addFreqAtom","toolInMenu","toolName","sel","getElementById","base","findEl","getComputedStyle","overflow","hiddenAncestor","shared","combineReducers","actionState","isEmpty","newState","correctTools","isSelected","menuName","modal","formState","form","store","loading","requestsStatuses","setEditor","restOptions","initState","middleware","rootReducer","sh","finalState","getRootReducer","createStore","applyMiddleware","BottomToolbarContainer","connect","rest","makeItems","bondCommon","bondStereo","bondQuery","bondSpecial","groupOptions","groupDescriptors","accum","rGroupOptions","shapeOptions","transformOptions","selectOptions","arrowsOptions","mappingOptions","useSettingsContext","useContext","SettingsContext","useThrottleResizeObserver","onResize","useMemo","throttle","useResizeObserver","useFormContext","FormContext","useAppContext","AppContext","useInterval","callback","delay","savedCallback","setInterval","clearInterval","ArrowScroll","startInView","endInView","scrollUp","scrollDown","isScrollDown","setScrollDown","isScrollUp","setScrollUp","onMouseUp","onMouseDown","mediaSizes","Shape","Transform","LeftToolbarContainer","scrollRef","useInView","threshold","startRef","endRef","sizeRef","Item","visibleItems","_createElement","offsetHeight","AtomsList","forwardRef","isAtom","RightToolbarContainer","toPercent","ZoomList","onChange","parsedValue","HelpLink","href","rel","copyOptions","TopToolbarContainer","isZoomListHidden","mac","normalizeKeyName","alt","ctrl","mod","normalizeKeyMap","modifiers","altKey","metaKey","rusToEng","KN","keyCode","normalizeKeyEvent","isChar","keyNorm","KeyboardEvent","initKeydownListener","hotKeys","act","actName","setHotKey","initHotKeys","actionTool","atomsSelected","letter","lookup","checkGroupOnTool","clipArea","newAction","keyHandle","baseName","rxnTextPlain","initClipboard","debAction","debounce","loadStruct","clipData","AppClipArea","AppHiddenContainer","onInitTmpls","Dialog","dialogRef","useLayoutEffect","getElementsByClassName","exit","role","onSubmit","onKeyDown","activeElement","activeTextarea","tabIndex","Spinner","APointTool","mousemove","ci","findItem","hover","click","atomResult","atomsInFunctionalGroup","elementEdit","newatom","fgId","findFunctionalGroupByAtom","removeFG","fgIds","AtomTool","atomLongtapEvent","dragCtx","atomid","fgs","timeout","quickEdit","stopTapping","clearTimeout","AttachTool","attachPoints","BondTool","ChainTool","ChargeTool","isPointInPolygon","v0","n0","d0","w0","flag1","flag0","w1","selectedSgroup","firstAtom","extraNeighbour","rnd","newAtomPos","bondResult","bondsInFunctionalGroup","attachEdit","findFunctionalGroupByBond","endAtom","beginPos","endPos","closestSGroup","fGroupId","fGroup","fGroupAtoms","MAX_VALUE","xy1","xy","bondAddition","sectCount","newItems","cancel","mouseleave","inRectangle","bondList","relatedFGId","rxnArrowsList","rxnPlusesList","simpleObjectsList","enhancedFlagList","sgroupDataList","textsList","inPolygon","rr","LassoHelper","getSelection","locate","points","running","addPoint","dp","searchMaps","SGroupTool","actualSgroupId","extraAtoms","newSelected","atomsResult","atomFromStruct","sgroupAtoms","sgroupBonds","sgroupDialog","lassoHelper","defaultType","eventName","manyComponentsSelected","singleComponentSelected","sgBonds","anyChainedBonds","getContextBySgroup","getContextBySelection","fromContextType","allBondsSelected","fixedBond","countOfSelectedComponents","bondFromStruct","extraBonds","bondsResult","selMerge","SelectTool","selectedSgroups","selectFragment","closestToSel","previous","expSel","ra","selectionAtoms","bondEdit","bondsSelection","newbond","reversible","dest","xor","uniqArray","EraserTool","PasteTool","lastEvent","RGroupAtomTool","propsDialog","RGroupFragmentTool","ReactionArrowTool","getDefaultLengthPos","newPos","ReactionMapTool","isValidMap","rcs","ri","ro","po","ReactionPlusTool","ReactionUnmapTool","RotateTool","SimpleObjectTool","TemplateTool","findItems","getSign","preResult","ce","rgroupEdit","newRg","isNew","updateLine","aam1","aam2","rotId","rotAll","neiHb","angle1","closestItem","sGroupResult","frIds","sign1","sign2","extra_bond","completeAction","TextTool","origilContent","rgroupatom","eraser","rgroupfragment","apoint","reactionarrow","reactionplus","reactionmap","reactionunmap","enhancedStereo","EnhancedStereoTool","stereoLabels","stereoAtom","enhancedStereoEdit","changeAtomsStereoAction","simpleobject","structObjects","highlightTargets","selectStereoFlagsIfNecessary","expAtoms","atomsOfFragments","shouldSelSFlag","Editor","_selection","historyStack","historyPtr","Subscription","PipelineSubscription","sgroupEdit","sdataEdit","change","selectionChange","aromatizeStruct","dearomatizeStruct","DOMSubscription","subs","which","isMouseRight","nodeName","EditorTool","domEventSetup","toolMap","recoordinate","newTool","item1","item2","ignoreHistory","HISTORY_SIZE","handler","subscriber","subscribeFuncWrapper","op","to","arid","customOnChangeHandler","srcItems","isRxn","FGContextMenu","getKetcherInstance","showSGroupMenu","setShowSGroupMenu","targetItems","setTargetItems","ContextMenu","onShow","selectedItems","detail","fgroup","showMenu","MenuItem","expandData","divider","setupEditor","oldProps","toolOpts","upperFirst","StructEditor","editorRef","logRef","nextProps","msg","parsedInfo","removeEditorHandlers","Tag","onSelectionChange","onElementEdit","onEnhancedStereoEdit","onQuickEdit","onBondEdit","onRgroupEdit","onSgroupEdit","onSdataEdit","onRemoveFG","onMessage","onAromatizeStruct","onDearomatizeStruct","onAttachEdit","onCipChange","hideMenu","holdToDisplay","About","indigoInfo","Logo","buildDate","GenericInput","onInput","TextArea","CheckBox","checked","Select","onSelect","multiple","enumSchema","FieldSet","defaultChecked","cbOrIndex","isTypeValue","ctrlMap","testVal","ev","multipleSelectCtrl","singleSelectCtrl","inputCtrl","input","isNumber","o","selectedIndex","fieldset","querySelectorAll","inp","Input","componentMap","shallowCompare","Form","onUpdate","propSchema","errs","getErrorsObj","customValid","updateState","self","dataError","Provider","stateStore","Label","labelPos","Field","fieldOpts","formField","SelectOneOf","selectDesc","validator","customFormats","inst","rewrite","serializeRewrite","deserializeRewrite","serializeMap","deserializeMap","getInvalidMessage","Accordion","setState","prevState","childrenWithProps","Children","child","isActive","groupIsActive","onActive","isValidElement","cloneElement","ColorPicker","handleChange","useCallback","HexColorPicker","HexColorInput","MeasureInput","cust","meas","calcValue","handleMeasChange","convValue","convertValue","onBlur","measureMap","px","cm","pt","inch","measureFrom","measureTo","OpenButton","FileReader","throughFileReader","ActiveXObject","fso","fd","OpenTextFile","ReadAll","Close","throughFileSystemObject","fileOpener","opener","noop","onLoad","onError","btn","accept","onload","msClose","onerror","readAsText","SaveButton","onSave","saveFile","fileSaver","saveImage","saveAs","SelectCheckbox","currentSchema","commonFonts","SystemFonts","availableFonts","setAvailableFonts","onChangeCallback","mounted","availableFontsPromises","fontName","FontFaceObserver","checkInSystem","results","fonts","Settings","appOpts","ownProps","onOpenFile","newOpts","onReset","onOk","newSettings","settingsSchema","ErrorsCheck","checkSchema","moleculeErrorsTypes","getOptionName","nameIndex","Tabs","changeTab","tabs","contentClassName","tabPanel","componentProps","Check","checkState","onCheck","captions","formulaRegexp","errorRegexp","formulaInputMarkdown","onKeyPress","FormulaInput","cnd","FrozenInput","spellCheck","roundOff","AnalyseDialog","onAnalyse","onChangeRound","withSelector","ErrorsContext","Analyse","serverSettings","roundName","changeRound","Spin","StructRender","tagRef","renderStruct","isImage","URL","webkitURL","createObjectURL","Recognize","isFragment","onImage","changeImage","onRecognize","ver","rec","onChangeImago","partProps","canPreviewImage","setCanPreviewImage","clearFile","BACKGROUND_COLOR","dark","light","MIEW_TX_TYPES","no","bright","colorer","blackAndWhite","bg","createMiewOptions","autoPreset","editing","inversePanning","reps","textMode","selector","showBg","TXoptions","MiewDialog","miewOpts","viewer","container","miewContainer","run","sourceType","fileType","setOptions","cmlStruct","exportCML","onExportCML","ElementNumber","readOnly","AtomContainer","currentLabel","setCurrentLabel","onLabelChangeCallback","newValue","atomValid","chargeValid","AttachPointsContainer","attachmentPointsSchema","automapSchema","AutomapContainer","BondContainer","IfThenSelect","rgroupLabels","rgroupLabel","RgroupLogicContainer","rangeConv","OpenContainer","setStructStr","setFragment","structAcceptMimes","SaveImageTab","changeImageFormat","extension","renderOptions","saveSchema","SaveDialog","disableControls","onResetForm","saveWarning","formatName","rxnArrowsSize","hasGenerics","rxnArrowMode","isRg","ind","isVal","structFormat","showStructWarningMessage","imageFormat","getWarnings","changeType","isCleanStruct","isMoleculeContain","onTmplSave","renderSaveFile","getButtons","tab","Save","saveUserTmpl","findStereLabels","maxAnd","stereLabels","numbers","maxOfAnds","maxOr","maxOfOrs","andNumber","orNumber","EmptySearchResult","textInfo","GREEK_SIMBOLS","Alpha","alpha","Beta","beta","Gamma","gamma","greekRe","RegExp","greekify","sym","tmplName","RenderTmpl","TemplateTable","onDelete","onAttach","ITEMS_COUNT","ITEM_SIZE","tmplStyles","minWidth","functionalGroupsSelector","modeSelector","labelEditSchema","AtomInfo","isInfo","numberStyle","fontSize","elemStyle","fontWeight","Header","MainRow","refer","currentEvents","atomClassNames","colSpan","OutinerRow","metalPrefix","beforeSpan","ACTINIDE","LANTHANIDE","main","lanthanides","actinides","ElementsTable","callbacks","table","summary","getAtomClassNames","main_row","outiner_row","GenSet","viewSchema","GenGroup","gen","pk","subgroup","GenericGroups","col","TypeChoice","Table","firstType","onMouseEnter","onMouseLeave","genType","periodicTable","changeTabType","mapSelectionToProps","PeriodTable","ButtonList","disabledIds","multipl","oneOrMore","ComboBox","suggestsHidden","blur","updateInput","textContent","suggestList","suggestListStyles","autoComplete","SelectInput","inputSelect","formSchema","schemes","EDITOR_STYLES","Attach","normTmpl","structNormalization","initTmpl","onNameEdit","getScale","checkUniqueName","placeholder","initAttach","setTmplName","normStruct","cbb","rxnPlus","SelectList","splitIndexes","isSplitIndex","filterLibSelector","createSelector","re","escapeRegExp","flow","_filter","onFilter","changeFilter","selectTmpl","onChangeGroup","changeGroup","formData","editTmpl","deleteUserTmpl","deleteTmpl","String","dialog_body","tableGroupWrap","singleColLayout","g","FontControl","editorState","setEditorState","defaultFontSize","isShowingFontSizeMenu","setIsShowingFontSizeMenu","currentFontSize","setCurrentFontSize","currentStyle","fontSizes","MAX_FONT_SIZE","fontSizeOptions","newEditorState","setFontSize","TextButton","command","toggleStyle","createStyles","customStyleFn","EditorState","moveFocusToEnd","createWithContent","convertFromRaw","entityMap","getCurrentInlineStyle","RichUtils","toggleInlineStyle","getCurrentContent","hasText","convertToRaw","keyBindingFn","getDefaultKeyBinding","customStyleMap","SUBSCRIPT","verticalAlign","transformOrigin","SUPERSCRIPT","Open","Rgroup","TemplateAttach","TemplatesDialog","AttachPoints","Automap","EnhancedStereo","LabelEdit","RgroupLogic","Sgroup","Sdata","fGroups","useDispatch","useSelector","setSelected","setFilter","filteredLib","setFilteredLib","expandedTemplates","filterFGLib","handleOk","handleResult","molSaveData","ModalContainer","_result","stateProps","dispatchProps","initProps","containerRef","modals","initEditor","updateAction","sleep","time","selectMode","resetOption","acts","dlg","fromStereoLabel","toStereoLabel","sbond","serverOpts","mapDispatchToProps","checkServer","AppContainer","provider","setFunctionalGroupsList","AppModalContainer","initApp","KetcherBuilder","serviceMode","buildNumber","initialMol","builder","appendApiAsync","appendServiceMode","appendUiAsync","rootElRef","buildKetcherAsync","ErrorModal","Command","SupportedFormat","convertMimeTypeToOutputFormat","mimeType","Smarts","Ket","IndigoService","worker","IndigoWorker","onmessage","terminate","postMessage","Info","commandOptions","commandData","inputMessage","Convert","Layout","Clean","Aromatize","Dearomatize","CalculateCip","curr","mappedProperty","mapWarningGroup","calculatedProperties","mappedPropertyName","mapCalculatedPropertyName","Calculate","GenerateImageAsBase64","StandaloneStructService"],"mappings":"kxGAsBaA,EAAiC,CAC5CC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,EAAG,UACHC,EAAG,UACHC,EAAG,UACHC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,EAAG,UACHC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJC,GAAI,UACJ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8F,EAAIxxB,SAGPntC,EAAO2+D,EAAI1+D,OAFXmB,EAAQu9D,EAAIhoB,UAMhB,IAAM0pC,EAAc,OACf,EAAKjgF,gBACL8mD,GAGCo5B,EAAwC,CAC5C1kH,OAAQ+G,EACRg/B,aAAcA,GAAgB,MAC9BmuC,gBAAiBA,EACjBpwE,QAAS2gH,GAGLE,EAAuD,CAC3DlvH,KAAMmuH,EAAQ6B,sBACd1+G,KAAM29G,GAGRP,EAAOI,YAAYI,U,EA5dnBT,GC1HArzC,a,yCACgB,c,+CAEpB,SAAoB/sE,GAClB,OAAO,IAAI4hH,EAAwB5hH,O,EAJjC+sE,K","file":"static/js/main.730396f6.chunk.js","sourcesContent":["/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport type { ElementLabel } from './element.types'\n\ntype ElementColorType = {\n [key in ElementLabel]: string\n}\n\nexport const ElementColor: ElementColorType = {\n H: '#000000',\n He: '#89a1a1',\n Li: '#bd77ed',\n Be: '#8fbc00',\n B: '#c18989',\n C: '#000000',\n N: '#304ff7',\n O: '#ff0d0d',\n F: '#78bc42',\n Ne: '#80a2af',\n Na: '#ab5cf2',\n Mg: '#6fcd00',\n Al: '#a99393',\n Si: '#b29478',\n P: '#ff8000',\n S: '#c99a19',\n Cl: '#1fd01f',\n Ar: '#69acba',\n K: '#8f40d4',\n Ca: '#38e900',\n Sc: '#999999',\n Ti: '#979a9e',\n V: '#99999e',\n Cr: '#8a99c7',\n Mn: '#9c7ac7',\n Fe: '#e06633',\n Co: '#d37e8e',\n Ni: '#4ece4e',\n Cu: '#c78033',\n Zn: '#7d80b0',\n Ga: '#bc8b8b',\n Ge: '#668f8f',\n As: '#b87ddd',\n Se: '#e59100',\n Br: '#a62929',\n Kr: '#59b1c9',\n Rb: '#702eb0',\n Sr: '#00ff00',\n Y: '#66afaf',\n Zr: '#71abab',\n Nb: '#67aeb4',\n Mo: '#54b5b5',\n Tc: '#3b9e9e',\n Ru: '#248f8f',\n Rh: '#0a7d8c',\n Pd: '#006985',\n Ag: '#9a9a9a',\n Cd: '#b29764',\n In: '#a67573',\n Sn: '#668080',\n Sb: '#9e63b5',\n Te: '#d47a00',\n I: '#940094',\n Xe: '#429eb0',\n Cs: '#57178f',\n Ba: '#00c900',\n La: '#5caed1',\n Ce: '#9d9d7b',\n Pr: '#8ca581',\n Nd: '#84a984',\n Pm: '#71b18a',\n Sm: '#66b68e',\n Eu: '#4ac298',\n Gd: '#37cb9e',\n Tb: '#28d1a4',\n Dy: '#1bd7a8',\n Ho: '#00e98f',\n Er: '#00e675',\n Tm: '#00d452',\n Yb: '#00bf38',\n Lu: '#00ab24',\n Hf: '#47b3ec',\n Ta: '#4da6ff',\n W: '#2194d6',\n Re: '#267dab',\n Os: '#266696',\n Ir: '#175487',\n Pt: '#9898a3',\n Au: '#c19e1c',\n Hg: '#9797ac',\n Tl: '#a6544d',\n Pb: '#575961',\n Bi: '#9e4fb5',\n Po: '#ab5c00',\n At: '#754f45',\n Rn: '#428296',\n Fr: '#420066',\n Ra: '#007d00',\n Ac: '#6aa2ec',\n Th: '#00baff',\n Pa: '#00a1ff',\n U: '#008fff',\n Np: '#0080ff',\n Pu: '#006bff',\n Am: '#545cf2',\n Cm: '#785ce3',\n Bk: '#8a4fe3',\n Cf: '#a136d4',\n Es: '#b31fd4',\n // Need to fix colors for the elements below (c)\n Fm: '#000000',\n Md: '#000000',\n No: '#000000',\n Lr: '#000000',\n Rf: '#47b3ec',\n Db: '#4da6ff',\n Sg: '#2194d6',\n Bh: '#267dab',\n Hs: '#266696',\n Mt: '#175487',\n Ds: '#9898a3',\n Rg: '#c19e1c',\n Cn: '#9797ac',\n Nh: '#000000',\n Fl: '#000000',\n Mc: '#000000',\n Lv: '#000000',\n Ts: '#000000',\n Og: '#000000'\n} as const\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport type { Element } from './element.types'\n\nconst elementsArray: Array = [\n {\n number: 1,\n label: 'H',\n period: 1,\n group: 1,\n title: 'Hydrogen',\n state: 'gas',\n origin: 'primordial',\n type: 'diatomic',\n mass: 1.00794\n },\n {\n number: 2,\n label: 'He',\n period: 1,\n group: 8,\n title: 'Helium',\n state: 'gas',\n origin: 'primordial',\n type: 'noble',\n mass: 4.0026022\n },\n {\n number: 3,\n label: 'Li',\n period: 2,\n group: 1,\n title: 'Lithium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkali',\n mass: 6.94\n },\n {\n number: 4,\n label: 'Be',\n period: 2,\n group: 2,\n title: 'Beryllium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkaline-earth',\n mass: 9.01218315\n },\n {\n number: 5,\n label: 'B',\n period: 2,\n group: 3,\n title: 'Boron',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 10.81\n },\n {\n number: 6,\n label: 'C',\n period: 2,\n group: 4,\n title: 'Carbon',\n state: 'solid',\n origin: 'primordial',\n type: 'polyatomic',\n mass: 12.011\n },\n {\n number: 7,\n label: 'N',\n period: 2,\n group: 5,\n title: 'Nitrogen',\n state: 'gas',\n origin: 'primordial',\n type: 'diatomic',\n mass: 14.007\n },\n {\n number: 8,\n label: 'O',\n period: 2,\n group: 6,\n leftH: true,\n title: 'Oxygen',\n state: 'gas',\n origin: 'primordial',\n type: 'diatomic',\n mass: 15.999\n },\n {\n number: 9,\n label: 'F',\n period: 2,\n group: 7,\n leftH: true,\n title: 'Fluorine',\n state: 'gas',\n origin: 'primordial',\n type: 'diatomic',\n mass: 18.9984031636\n },\n {\n number: 10,\n label: 'Ne',\n period: 2,\n group: 8,\n title: 'Neon',\n state: 'gas',\n origin: 'primordial',\n type: 'noble',\n mass: 20.17976\n },\n {\n number: 11,\n label: 'Na',\n period: 3,\n group: 1,\n title: 'Sodium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkali',\n mass: 22.989769282\n },\n {\n number: 12,\n label: 'Mg',\n period: 3,\n group: 2,\n title: 'Magnesium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkaline-earth',\n mass: 24.305\n },\n {\n number: 13,\n label: 'Al',\n period: 3,\n group: 3,\n title: 'Aluminium',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 26.98153857\n },\n {\n number: 14,\n label: 'Si',\n period: 3,\n group: 4,\n title: 'Silicon',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 28.085\n },\n {\n number: 15,\n label: 'P',\n period: 3,\n group: 5,\n title: 'Phosphorus',\n state: 'solid',\n origin: 'primordial',\n type: 'polyatomic',\n mass: 30.9737619985\n },\n {\n number: 16,\n label: 'S',\n period: 3,\n group: 6,\n leftH: true,\n title: 'Sulfur',\n state: 'solid',\n origin: 'primordial',\n type: 'polyatomic',\n mass: 32.06\n },\n {\n number: 17,\n label: 'Cl',\n period: 3,\n group: 7,\n leftH: true,\n title: 'Chlorine',\n state: 'gas',\n origin: 'primordial',\n type: 'diatomic',\n mass: 35.45\n },\n {\n number: 18,\n label: 'Ar',\n period: 3,\n group: 8,\n title: 'Argon',\n state: 'gas',\n origin: 'primordial',\n type: 'noble',\n mass: 39.9481\n },\n {\n number: 19,\n label: 'K',\n period: 4,\n group: 1,\n title: 'Potassium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkali',\n mass: 39.09831\n },\n {\n number: 20,\n label: 'Ca',\n period: 4,\n group: 2,\n title: 'Calcium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkaline-earth',\n mass: 40.0784\n },\n {\n number: 21,\n label: 'Sc',\n period: 4,\n group: 3,\n title: 'Scandium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 44.9559085\n },\n {\n number: 22,\n label: 'Ti',\n period: 4,\n group: 4,\n title: 'Titanium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 47.8671\n },\n {\n number: 23,\n label: 'V',\n period: 4,\n group: 5,\n title: 'Vanadium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 50.94151\n },\n {\n number: 24,\n label: 'Cr',\n period: 4,\n group: 6,\n title: 'Chromium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 51.99616\n },\n {\n number: 25,\n label: 'Mn',\n period: 4,\n group: 7,\n title: 'Manganese',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 54.9380443\n },\n {\n number: 26,\n label: 'Fe',\n period: 4,\n group: 8,\n title: 'Iron',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 55.8452\n },\n {\n number: 27,\n label: 'Co',\n period: 4,\n group: 8,\n title: 'Cobalt',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 58.9331944\n },\n {\n number: 28,\n label: 'Ni',\n period: 4,\n group: 8,\n title: 'Nickel',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 58.69344\n },\n {\n number: 29,\n label: 'Cu',\n period: 4,\n group: 1,\n title: 'Copper',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 63.5463\n },\n {\n number: 30,\n label: 'Zn',\n period: 4,\n group: 2,\n title: 'Zinc',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 65.382\n },\n {\n number: 31,\n label: 'Ga',\n period: 4,\n group: 3,\n title: 'Gallium',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 69.7231\n },\n {\n number: 32,\n label: 'Ge',\n period: 4,\n group: 4,\n title: 'Germanium',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 72.6308\n },\n {\n number: 33,\n label: 'As',\n period: 4,\n group: 5,\n title: 'Arsenic',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 74.9215956\n },\n {\n number: 34,\n label: 'Se',\n period: 4,\n group: 6,\n leftH: true,\n title: 'Selenium',\n state: 'solid',\n origin: 'primordial',\n type: 'polyatomic',\n mass: 78.9718\n },\n {\n number: 35,\n label: 'Br',\n period: 4,\n group: 7,\n leftH: true,\n title: 'Bromine',\n state: 'liquid',\n origin: 'primordial',\n type: 'diatomic',\n mass: 79.904\n },\n {\n number: 36,\n label: 'Kr',\n period: 4,\n group: 8,\n title: 'Krypton',\n state: 'gas',\n origin: 'primordial',\n type: 'noble',\n mass: 83.7982\n },\n {\n number: 37,\n label: 'Rb',\n period: 5,\n group: 1,\n title: 'Rubidium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkali',\n mass: 85.46783\n },\n {\n number: 38,\n label: 'Sr',\n period: 5,\n group: 2,\n title: 'Strontium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkaline-earth',\n mass: 87.621\n },\n {\n number: 39,\n label: 'Y',\n period: 5,\n group: 3,\n title: 'Yttrium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 88.905842\n },\n {\n number: 40,\n label: 'Zr',\n period: 5,\n group: 4,\n title: 'Zirconium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 91.2242\n },\n {\n number: 41,\n label: 'Nb',\n period: 5,\n group: 5,\n title: 'Niobium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 92.906372\n },\n {\n number: 42,\n label: 'Mo',\n period: 5,\n group: 6,\n title: 'Molybdenum',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 95.951\n },\n {\n number: 43,\n label: 'Tc',\n period: 5,\n group: 7,\n title: 'Technetium',\n state: 'solid',\n origin: 'decay',\n type: 'transition',\n mass: 98\n },\n {\n number: 44,\n label: 'Ru',\n period: 5,\n group: 8,\n title: 'Ruthenium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 101.072\n },\n {\n number: 45,\n label: 'Rh',\n period: 5,\n group: 8,\n title: 'Rhodium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 102.905502\n },\n {\n number: 46,\n label: 'Pd',\n period: 5,\n group: 8,\n title: 'Palladium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 106.421\n },\n {\n number: 47,\n label: 'Ag',\n period: 5,\n group: 1,\n title: 'Silver',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 107.86822\n },\n {\n number: 48,\n label: 'Cd',\n period: 5,\n group: 2,\n title: 'Cadmium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 112.4144\n },\n {\n number: 49,\n label: 'In', // 49\n period: 5,\n group: 3,\n title: 'Indium',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 114.8181\n },\n {\n number: 50,\n label: 'Sn',\n period: 5,\n group: 4,\n title: 'Tin',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 118.7107\n },\n {\n number: 51,\n label: 'Sb',\n period: 5,\n group: 5,\n title: 'Antimony',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 121.7601\n },\n {\n number: 52,\n label: 'Te',\n period: 5,\n group: 6,\n title: 'Tellurium',\n state: 'solid',\n origin: 'primordial',\n type: 'metalloid',\n mass: 127.603\n },\n {\n number: 53,\n label: 'I',\n period: 5,\n group: 7,\n leftH: true,\n title: 'Iodine',\n state: 'solid',\n origin: 'primordial',\n type: 'diatomic',\n mass: 126.904473\n },\n {\n number: 54,\n label: 'Xe',\n period: 5,\n group: 8,\n title: 'Xenon',\n state: 'gas',\n origin: 'primordial',\n type: 'noble',\n mass: 131.2936\n },\n {\n number: 55,\n label: 'Cs',\n period: 6,\n group: 1,\n title: 'Caesium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkali',\n mass: 132.905451966\n },\n {\n number: 56,\n label: 'Ba',\n period: 6,\n group: 2,\n title: 'Barium',\n state: 'solid',\n origin: 'primordial',\n type: 'alkaline-earth',\n mass: 137.3277\n },\n {\n number: 57,\n label: 'La',\n period: 6,\n group: 3,\n title: 'Lanthanum',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 138.905477\n },\n {\n number: 58,\n label: 'Ce',\n period: 6,\n group: 3,\n title: 'Cerium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 140.1161\n },\n {\n number: 59,\n label: 'Pr',\n period: 6,\n group: 3,\n title: 'Praseodymium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 140.907662\n },\n {\n number: 60,\n label: 'Nd',\n period: 6,\n group: 3,\n title: 'Neodymium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 144.2423\n },\n {\n number: 61,\n label: 'Pm',\n period: 6,\n group: 3,\n title: 'Promethium',\n state: 'solid',\n origin: 'decay',\n type: 'lanthanide',\n mass: 145\n },\n {\n number: 62,\n label: 'Sm',\n period: 6,\n group: 3,\n title: 'Samarium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 150.362\n },\n {\n number: 63,\n label: 'Eu',\n period: 6,\n group: 3,\n title: 'Europium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 151.9641\n },\n {\n number: 64,\n label: 'Gd',\n period: 6,\n group: 3,\n title: 'Gadolinium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 157.253\n },\n {\n number: 65,\n label: 'Tb',\n period: 6,\n group: 3,\n title: 'Terbium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 158.925352\n },\n {\n number: 66,\n label: 'Dy',\n period: 6,\n group: 3,\n title: 'Dysprosium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 162.5001\n },\n {\n number: 67,\n label: 'Ho',\n period: 6,\n group: 3,\n title: 'Holmium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 164.930332\n },\n {\n number: 68,\n label: 'Er',\n period: 6,\n group: 3,\n title: 'Erbium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 167.2593\n },\n {\n number: 69,\n label: 'Tm',\n period: 6,\n group: 3,\n title: 'Thulium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 168.934222\n },\n {\n number: 70,\n label: 'Yb',\n period: 6,\n group: 3,\n title: 'Ytterbium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 173.0451\n },\n {\n number: 71,\n label: 'Lu',\n period: 6,\n group: 3,\n title: 'Lutetium',\n state: 'solid',\n origin: 'primordial',\n type: 'lanthanide',\n mass: 174.96681\n },\n {\n number: 72,\n label: 'Hf',\n period: 6,\n group: 4,\n title: 'Hafnium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 178.492\n },\n {\n number: 73,\n label: 'Ta',\n period: 6,\n group: 5,\n title: 'Tantalum',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 180.947882\n },\n {\n number: 74,\n label: 'W',\n period: 6,\n group: 6,\n title: 'Tungsten',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 183.841\n },\n {\n number: 75,\n label: 'Re',\n period: 6,\n group: 7,\n title: 'Rhenium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 186.2071\n },\n {\n number: 76,\n label: 'Os',\n period: 6,\n group: 8,\n title: 'Osmium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 190.233\n },\n {\n number: 77,\n label: 'Ir',\n period: 6,\n group: 8,\n title: 'Iridium',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 192.2173\n },\n {\n number: 78,\n label: 'Pt',\n period: 6,\n group: 8,\n title: 'Platinum',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 195.0849\n },\n {\n number: 79,\n label: 'Au',\n period: 6,\n group: 1,\n title: 'Gold',\n state: 'solid',\n origin: 'primordial',\n type: 'transition',\n mass: 196.9665695\n },\n {\n number: 80,\n label: 'Hg',\n period: 6,\n group: 2,\n title: 'Mercury',\n state: 'liquid',\n origin: 'primordial',\n type: 'transition',\n mass: 200.5923\n },\n {\n number: 81,\n label: 'Tl',\n period: 6,\n group: 3,\n title: 'Thallium',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 204.38\n },\n {\n number: 82,\n label: 'Pb',\n period: 6,\n group: 4,\n title: 'Lead',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 207.21\n },\n {\n number: 83,\n label: 'Bi',\n period: 6,\n group: 5,\n title: 'Bismuth',\n state: 'solid',\n origin: 'primordial',\n type: 'post-transition',\n mass: 208.980401\n },\n {\n number: 84,\n label: 'Po',\n period: 6,\n group: 6,\n title: 'Polonium',\n state: 'solid',\n origin: 'decay',\n type: 'post-transition',\n mass: 209\n },\n {\n number: 85,\n label: 'At',\n period: 6,\n group: 7,\n title: 'Astatine',\n state: 'solid',\n origin: 'decay',\n type: 'metalloid',\n mass: 210\n },\n {\n number: 86,\n label: 'Rn',\n period: 6,\n group: 8,\n title: 'Radon',\n state: 'gas',\n origin: 'decay',\n type: 'noble',\n mass: 222\n },\n {\n number: 87,\n label: 'Fr',\n period: 7,\n group: 1,\n title: 'Francium',\n state: 'solid',\n origin: 'decay',\n type: 'alkali',\n mass: 223\n },\n {\n number: 88,\n label: 'Ra',\n period: 7,\n group: 2,\n title: 'Radium',\n state: 'solid',\n origin: 'decay',\n type: 'alkaline-earth',\n mass: 226\n },\n {\n number: 89,\n label: 'Ac',\n period: 7,\n group: 3,\n title: 'Actinium',\n state: 'solid',\n origin: 'decay',\n type: 'actinide',\n mass: 227\n },\n {\n number: 90,\n label: 'Th',\n period: 7,\n group: 3,\n title: 'Thorium',\n state: 'solid',\n origin: 'primordial',\n type: 'actinide',\n mass: 232.03774\n },\n {\n number: 91,\n label: 'Pa',\n period: 7,\n group: 3,\n title: 'Protactinium',\n state: 'solid',\n origin: 'decay',\n type: 'actinide',\n mass: 231.035882\n },\n {\n number: 92,\n label: 'U',\n period: 7,\n group: 3,\n title: 'Uranium',\n state: 'solid',\n origin: 'primordial',\n type: 'actinide',\n mass: 238.028913\n },\n {\n number: 93,\n label: 'Np',\n period: 7,\n group: 3,\n title: 'Neptunium',\n state: 'solid',\n origin: 'decay',\n type: 'actinide',\n mass: 237\n },\n {\n number: 94,\n label: 'Pu',\n period: 7,\n group: 3,\n title: 'Plutonium',\n state: 'solid',\n origin: 'decay',\n type: 'actinide',\n mass: 244\n },\n {\n number: 95,\n label: 'Am',\n period: 7,\n group: 3,\n title: 'Americium',\n state: 'solid',\n origin: 'synthetic',\n type: 'actinide',\n mass: 243\n },\n {\n number: 96,\n label: 'Cm',\n period: 7,\n group: 3,\n title: 'Curium',\n state: 'solid',\n origin: 'synthetic',\n type: 'actinide',\n mass: 247\n },\n {\n number: 97,\n label: 'Bk',\n period: 7,\n group: 3,\n title: 'Berkelium',\n state: 'solid',\n origin: 'synthetic',\n type: 'actinide',\n mass: 247\n },\n {\n number: 98,\n label: 'Cf',\n period: 7,\n group: 3,\n title: 'Californium',\n state: 'solid',\n origin: 'synthetic',\n type: 'actinide',\n mass: 251\n },\n {\n number: 99,\n label: 'Es',\n period: 7,\n group: 3,\n title: 'Einsteinium',\n state: 'solid',\n origin: 'synthetic',\n type: 'actinide',\n mass: 252\n },\n {\n number: 100,\n label: 'Fm',\n period: 7,\n group: 3,\n title: 'Fermium',\n origin: 'synthetic',\n type: 'actinide',\n mass: 257\n },\n {\n number: 101,\n label: 'Md',\n period: 7,\n group: 3,\n title: 'Mendelevium',\n origin: 'synthetic',\n type: 'actinide',\n mass: 258\n },\n {\n number: 102,\n label: 'No',\n period: 7,\n group: 3,\n title: 'Nobelium',\n origin: 'synthetic',\n type: 'actinide',\n mass: 259\n },\n {\n number: 103,\n label: 'Lr',\n period: 7,\n group: 3,\n title: 'Lawrencium',\n origin: 'synthetic',\n type: 'actinide',\n mass: 266\n },\n {\n number: 104,\n label: 'Rf',\n period: 7,\n group: 4,\n title: 'Rutherfordium',\n origin: 'synthetic',\n type: 'transition',\n mass: 267\n },\n {\n number: 105,\n label: 'Db',\n period: 7,\n group: 5,\n title: 'Dubnium',\n origin: 'synthetic',\n type: 'transition',\n mass: 268\n },\n {\n number: 106,\n label: 'Sg',\n period: 7,\n group: 6,\n title: 'Seaborgium',\n origin: 'synthetic',\n type: 'transition',\n mass: 269\n },\n {\n number: 107,\n label: 'Bh',\n period: 7,\n group: 7,\n title: 'Bohrium',\n origin: 'synthetic',\n type: 'transition',\n mass: 270\n },\n {\n number: 108,\n label: 'Hs',\n period: 7,\n group: 8,\n title: 'Hassium',\n origin: 'synthetic',\n type: 'transition',\n mass: 269\n },\n {\n number: 109,\n label: 'Mt',\n period: 7,\n group: 8,\n title: 'Meitnerium',\n origin: 'synthetic',\n mass: 278\n },\n {\n number: 110,\n label: 'Ds',\n period: 7,\n group: 8,\n title: 'Darmstadtium',\n origin: 'synthetic',\n mass: 281\n },\n {\n number: 111,\n label: 'Rg',\n period: 7,\n group: 1,\n title: 'Roentgenium',\n origin: 'synthetic',\n mass: 282\n },\n {\n number: 112,\n label: 'Cn',\n period: 7,\n group: 2,\n title: 'Copernicium',\n origin: 'synthetic',\n type: 'transition',\n mass: 285\n },\n {\n number: 113,\n label: 'Nh',\n period: 7,\n group: 3,\n title: 'Nihonium',\n origin: 'synthetic',\n mass: 286\n },\n {\n number: 114,\n label: 'Fl',\n period: 7,\n group: 4,\n title: 'Flerovium',\n origin: 'synthetic',\n type: 'post-transition',\n mass: 289\n },\n {\n number: 115,\n label: 'Mc',\n period: 7,\n group: 5,\n title: 'Moscovium',\n origin: 'synthetic',\n mass: 289\n },\n {\n number: 116,\n label: 'Lv',\n period: 7,\n group: 6,\n title: 'Livermorium',\n origin: 'synthetic',\n mass: 293\n },\n {\n number: 117,\n label: 'Ts',\n period: 7,\n group: 7,\n title: 'Tennessine',\n origin: 'synthetic',\n mass: 294\n },\n {\n number: 118,\n label: 'Og',\n period: 7,\n group: 8,\n title: 'Oganesson',\n origin: 'synthetic',\n mass: 294\n }\n]\n\nconst elementsMap = elementsArray.reduce((acc, element) => {\n acc.set(element.label, element)\n acc.set(element.number, element)\n return acc\n}, new Map())\n\nexport const Elements = {\n get: (key: number | string): Element | undefined => elementsMap.get(key),\n filter: (predicate: (element: Element) => boolean): Array => {\n return elementsArray.filter(predicate)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const Generics = {\n atom: {\n any: {\n labels: ['A', 'AH']\n },\n 'no-carbon': {\n labels: ['Q', 'QH']\n },\n metal: {\n labels: ['M', 'MH']\n },\n halogen: {\n labels: ['X', 'XH']\n }\n },\n group: {\n labels: ['G', 'GH', 'G*', 'GH*'],\n acyclic: {\n labels: ['ACY', 'ACH'],\n carbo: {\n labels: ['ABC', 'ABH'],\n alkynyl: {\n labels: ['AYL', 'AYH']\n },\n alkyl: {\n labels: ['ALK', 'ALH']\n },\n alkenyl: {\n labels: ['AEL', 'AEH']\n }\n },\n hetero: {\n labels: ['AHC', 'AHH'],\n alkoxy: {\n labels: ['AOX', 'AOH']\n }\n }\n },\n cyclic: {\n labels: ['CYC', 'CYH'],\n 'no-carbon': {\n labels: ['CXX', 'CXH']\n },\n carbo: {\n labels: ['CBC', 'CBH'],\n aryl: {\n labels: ['ARY', 'ARH']\n },\n cycloalkyl: {\n labels: ['CAL', 'CAH']\n },\n cycloalkenyl: {\n labels: ['CEL', 'CEH']\n }\n },\n hetero: {\n labels: ['CHC', 'CHH'],\n aryl: {\n labels: ['HAR', 'HAH']\n }\n }\n }\n },\n special: {\n labels: ['H+', 'D', 'T', 'R', 'Pol']\n }\n} as const\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ElementLabel, Elements } from 'domain/constants'\n\nexport interface AtomListParams {\n readonly notList: boolean\n readonly ids: Array\n}\n\nexport class AtomList {\n notList: boolean\n ids: Array\n\n constructor(params: AtomListParams) {\n this.notList = params.notList\n this.ids = params.ids\n }\n\n labelList() {\n const labels: Array = []\n for (let id of this.ids) {\n const currenElement = Elements.get(id)\n currenElement && labels.push(currenElement!.label)\n }\n\n return labels\n }\n\n label() {\n let label = '[' + this.labelList().join(',') + ']'\n if (this.notList) {\n label = '!' + label\n }\n return label\n }\n\n equals(atomList: AtomList) {\n return (\n this.notList === atomList.notList &&\n (this.ids || []).sort().toString() ===\n (atomList.ids || []).sort().toString()\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport assert from 'assert'\n\nexport interface Point {\n x?: number\n y?: number\n z?: number\n}\nexport class Vec2 {\n static ZERO = new Vec2(0, 0)\n static UNIT = new Vec2(1, 1)\n\n x: number\n y: number\n z: number\n\n constructor(point: Point)\n constructor(x?: number, y?: number, z?: number)\n constructor(...args: Array) {\n if (args.length === 0) {\n this.x = 0\n this.y = 0\n this.z = 0\n } else if (arguments.length === 1) {\n this.x = parseFloat(args[0].x || 0)\n this.y = parseFloat(args[0].y || 0)\n this.z = parseFloat(args[0].z || 0)\n } else if (arguments.length === 2) {\n this.x = parseFloat(args[0] || 0)\n this.y = parseFloat(args[1] || 0)\n this.z = 0\n } else if (arguments.length === 3) {\n this.x = parseFloat(args[0])\n this.y = parseFloat(args[1])\n this.z = parseFloat(args[2])\n } else {\n throw new Error('Vec2(): invalid arguments')\n }\n }\n\n static dist(a: Vec2, b: Vec2): number {\n return Vec2.diff(a, b).length()\n }\n\n static max(v1: Vec2, v2: Vec2): Vec2 {\n return new Vec2(\n Math.max(v1.x, v2.x),\n Math.max(v1.y, v2.y),\n Math.max(v1.z, v2.z)\n )\n }\n\n static min(v1: Vec2, v2: Vec2): Vec2 {\n return new Vec2(\n Math.min(v1.x, v2.x),\n Math.min(v1.y, v2.y),\n Math.min(v1.z, v2.z)\n )\n }\n\n static sum(v1: Vec2, v2: Vec2): Vec2 {\n return new Vec2(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)\n }\n\n static dot(v1: Vec2, v2: Vec2): number {\n return v1.x * v2.x + v1.y * v2.y\n }\n\n static cross(v1: Vec2, v2: Vec2): number {\n return v1.x * v2.y - v1.y * v2.x\n }\n\n static angle(v1: Vec2, v2: Vec2): number {\n return Math.atan2(Vec2.cross(v1, v2), Vec2.dot(v1, v2))\n }\n\n static diff(v1: Vec2, v2: Vec2): Vec2 {\n return new Vec2(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z)\n }\n\n // assume arguments v1, f1, v2, f2, v3, f3, etc.\n // where v[i] are vectors and f[i] are corresponding coefficients\n static lc(...args: Array): Vec2 {\n let v = new Vec2()\n for (let i = 0; i < arguments.length / 2; ++i)\n v = v.addScaled(args[2 * i] as Vec2, args[2 * i + 1] as number)\n return v\n }\n\n static lc2(v1: Vec2, f1: number, v2: Vec2, f2: number): Vec2 {\n return new Vec2(\n v1.x * f1 + v2.x * f2,\n v1.y * f1 + v2.y * f2,\n v1.z * f1 + v2.z * f2\n )\n }\n\n static centre(v1: Vec2, v2: Vec2) {\n return Vec2.lc2(v1, 0.5, v2, 0.5)\n }\n\n length(): number {\n return Math.sqrt(this.x * this.x + this.y * this.y)\n }\n\n equals(v: Vec2): boolean {\n return this.x === v.x && this.y === v.y && this.z === v.z\n }\n\n add(v: Vec2): Vec2 {\n return new Vec2(this.x + v.x, this.y + v.y, this.z + v.z)\n }\n\n add_(v: Vec2): void {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n }\n\n get_xy0(): Vec2 {\n return new Vec2(this.x, this.y)\n }\n\n sub(v: Vec2): Vec2 {\n return new Vec2(this.x - v.x, this.y - v.y, this.z - v.z)\n }\n\n scaled(s: number): Vec2 {\n return new Vec2(this.x * s, this.y * s, this.z * s)\n }\n\n negated(): Vec2 {\n return new Vec2(-this.x, -this.y, -this.z)\n }\n\n yComplement(y1: number): Vec2 {\n y1 = y1 || 0\n return new Vec2(this.x, y1 - this.y, this.z)\n }\n\n addScaled(v: Vec2, f: number): Vec2 {\n return new Vec2(this.x + v.x * f, this.y + v.y * f, this.z + v.z * f)\n }\n\n normalized(): Vec2 {\n return this.scaled(1 / this.length())\n }\n\n normalize(): boolean {\n const l = this.length()\n\n if (l < 0.000001) return false\n\n this.x /= l\n this.y /= l\n\n return true\n }\n\n turnLeft(): Vec2 {\n return new Vec2(-this.y, this.x, this.z)\n }\n\n coordStr(): string {\n return this.x.toString() + ' , ' + this.y.toString()\n }\n\n toString(): string {\n return '(' + this.x.toFixed(2) + ',' + this.y.toFixed(2) + ')'\n }\n\n max(v: Vec2): Vec2 {\n assert(v != null)\n\n return Vec2.max(this, v)\n }\n\n min(v: Vec2): Vec2 {\n return Vec2.min(this, v)\n }\n\n ceil(): Vec2 {\n return new Vec2(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z))\n }\n\n floor(): Vec2 {\n return new Vec2(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z))\n }\n\n rotate(angle: number) {\n const sin = Math.sin(angle)\n const cos = Math.cos(angle)\n\n return this.rotateSC(sin, cos)\n }\n\n rotateSC(sin: number, cos: number): Vec2 {\n assert(sin === 0 || !!sin)\n assert(cos === 0 || !!cos)\n\n return new Vec2(\n this.x * cos - this.y * sin,\n this.x * sin + this.y * cos,\n this.z\n )\n }\n\n oxAngle(): number {\n return Math.atan2(this.y, this.x)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AtomList, AtomListParams } from './atomList'\nimport { Point, Vec2 } from './vec2'\n\nimport { Elements } from 'domain/constants'\nimport { Pile } from './pile'\n\nfunction getValueOrDefault(value: T | undefined, defaultValue: T): T {\n return typeof value !== 'undefined' ? value : defaultValue\n}\n\nfunction getPseudo(label: string) {\n return !Elements.get(label) &&\n label !== 'L' &&\n label !== 'L#' &&\n label !== 'R#'\n ? label\n : ''\n}\n\nexport function radicalElectrons(radical: any) {\n radical -= 0\n if (radical === Atom.PATTERN.RADICAL.DOUPLET) return 1\n else if (\n radical === Atom.PATTERN.RADICAL.SINGLET ||\n radical === Atom.PATTERN.RADICAL.TRIPLET\n )\n return 2\n else {\n return 0\n }\n}\n\nexport enum StereoLabel {\n Abs = 'abs',\n And = '&',\n Or = 'or'\n}\n\nexport interface AtomAttributes {\n stereoParity?: number\n stereoLabel?: string | null\n exactChangeFlag?: number\n rxnFragmentType?: number\n invRet?: number\n aam?: number\n hCount?: number\n unsaturatedAtom?: number\n substitutionCount?: number\n ringBondCount?: number\n explicitValence?: number\n attpnt?: any\n rglabel?: string | null\n charge?: number\n radical?: number\n isotope?: number\n alias?: string | null\n pseudo?: string\n atomList?: AtomListParams | null\n label: string\n fragment?: number\n pp?: Point\n implicitH?: number\n}\n\nexport class Atom {\n static PATTERN = {\n RADICAL: {\n NONE: 0,\n SINGLET: 1,\n DOUPLET: 2,\n TRIPLET: 3\n },\n STEREO_PARITY: {\n NONE: 0,\n ODD: 1,\n EVEN: 2,\n EITHER: 3\n }\n }\n\n //TODO: rename\n static attrlist = {\n alias: null,\n label: 'C',\n isotope: 0,\n radical: 0,\n charge: 0,\n explicitValence: -1,\n ringBondCount: 0,\n substitutionCount: 0,\n unsaturatedAtom: 0,\n hCount: 0,\n atomList: null,\n invRet: 0,\n exactChangeFlag: 0,\n rglabel: null,\n attpnt: null,\n aam: 0,\n // enhanced stereo\n stereoLabel: null,\n stereoParity: 0\n }\n\n label: string\n fragment: number\n atomList: AtomList | null\n attpnt: any\n isotope: number\n hCount: number\n radical: number\n charge: number\n explicitValence: number\n ringBondCount: number\n unsaturatedAtom: number\n substitutionCount: number\n valence: number\n implicitH: number\n pp: Vec2\n neighbors: Array\n sgs: Pile\n badConn: boolean\n alias: string | null\n rglabel: string | null\n aam: number\n invRet: number\n exactChangeFlag: number\n rxnFragmentType: number\n stereoLabel?: string | null\n stereoParity: number\n hasImplicitH?: boolean\n pseudo!: string\n\n constructor(attributes: AtomAttributes) {\n this.label = attributes.label\n this.fragment = getValueOrDefault(attributes.fragment, -1)\n this.alias = getValueOrDefault(attributes.alias, Atom.attrlist.alias)\n this.isotope = getValueOrDefault(attributes.isotope, Atom.attrlist.isotope)\n this.radical = getValueOrDefault(attributes.radical, Atom.attrlist.radical)\n this.charge = getValueOrDefault(attributes.charge, Atom.attrlist.charge)\n this.rglabel = getValueOrDefault(attributes.rglabel, Atom.attrlist.rglabel)\n this.attpnt = getValueOrDefault(attributes.attpnt, Atom.attrlist.attpnt)\n this.explicitValence = getValueOrDefault(\n attributes.explicitValence,\n Atom.attrlist.explicitValence\n )\n\n this.valence = 0\n this.implicitH = attributes.implicitH || 0 // implicitH is not an attribute\n this.pp = attributes.pp ? new Vec2(attributes.pp) : new Vec2()\n\n // sgs should only be set when an atom is added to an s-group by an appropriate method,\n // or else a copied atom might think it belongs to a group, but the group be unaware of the atom\n // TODO: make a consistency check on atom/s-group assignments\n this.sgs = new Pile()\n\n // query\n this.ringBondCount = getValueOrDefault(\n attributes.ringBondCount,\n Atom.attrlist.ringBondCount\n )\n this.substitutionCount = getValueOrDefault(\n attributes.substitutionCount,\n Atom.attrlist.substitutionCount\n )\n this.unsaturatedAtom = getValueOrDefault(\n attributes.unsaturatedAtom,\n Atom.attrlist.unsaturatedAtom\n )\n this.hCount = getValueOrDefault(attributes.hCount, Atom.attrlist.hCount)\n\n // reaction\n this.aam = getValueOrDefault(attributes.aam, Atom.attrlist.aam)\n this.invRet = getValueOrDefault(attributes.invRet, Atom.attrlist.invRet)\n this.exactChangeFlag = getValueOrDefault(\n attributes.exactChangeFlag,\n Atom.attrlist.exactChangeFlag\n )\n this.rxnFragmentType = getValueOrDefault(attributes.rxnFragmentType, -1)\n\n // stereo\n this.stereoLabel = getValueOrDefault(\n attributes.stereoLabel,\n Atom.attrlist.stereoLabel\n )\n this.stereoParity = getValueOrDefault(\n attributes.stereoParity,\n Atom.attrlist.stereoParity\n )\n\n this.atomList = attributes.atomList\n ? new AtomList(attributes.atomList)\n : null\n this.neighbors = [] // set of half-bonds having this atom as their origin\n this.badConn = false\n\n Object.defineProperty(this, 'pseudo', {\n enumerable: true,\n get: function () {\n return getPseudo(this.label)\n }\n })\n }\n\n static getAttrHash(atom: Atom) {\n const attrs = {}\n for (let attr in Atom.attrlist) {\n if (typeof atom[attr] !== 'undefined') attrs[attr] = atom[attr]\n }\n return attrs\n }\n\n static attrGetDefault(attr: string) {\n if (attr in Atom.attrlist) {\n return Atom.attrlist[attr]\n }\n }\n\n clone(fidMap: Map): Atom {\n const ret = new Atom(this)\n if (fidMap && fidMap.has(this.fragment))\n ret.fragment = fidMap.get(this.fragment)!\n return ret\n }\n\n isQuery(): boolean {\n return (\n this.atomList !== null || this.label === 'A' || this.attpnt || this.hCount\n )\n }\n\n pureHydrogen(): boolean {\n return this.label === 'H' && this.isotope === 0\n }\n\n isPlainCarbon(): boolean {\n return (\n this.label === 'C' &&\n this.isotope === 0 &&\n this.radical === 0 &&\n this.charge === 0 &&\n this.explicitValence < 0 &&\n this.ringBondCount === 0 &&\n this.substitutionCount === 0 &&\n this.unsaturatedAtom === 0 &&\n this.hCount === 0 &&\n !this.atomList\n )\n }\n\n isPseudo(): boolean {\n // TODO: handle reaxys generics separately\n return !this.atomList && !this.rglabel && !Elements.get(this.label)\n }\n\n hasRxnProps(): boolean {\n return !!(\n this.invRet ||\n this.exactChangeFlag ||\n this.attpnt !== null ||\n this.aam\n )\n }\n\n calcValence(conn: number): boolean {\n const label = this.label\n const charge = this.charge\n if (this.isQuery()) {\n this.implicitH = 0\n return true\n }\n const element = Elements.get(label)\n if (!element) {\n this.implicitH = 0\n return true\n }\n\n var groupno = element.group\n var rad = radicalElectrons(this.radical)\n var valence = conn\n var hyd = 0\n var absCharge = Math.abs(charge)\n if (groupno === 1) {\n if (\n label === 'H' ||\n label === 'Li' ||\n label === 'Na' ||\n label === 'K' ||\n label === 'Rb' ||\n label === 'Cs' ||\n label === 'Fr'\n ) {\n valence = 1\n hyd = 1 - rad - conn - absCharge\n }\n } else if (groupno === 2) {\n if (conn + rad + absCharge === 2 || conn + rad + absCharge === 0)\n valence = 2\n else hyd = -1\n } else if (groupno === 3) {\n if (label === 'B' || label === 'Al' || label === 'Ga' || label === 'In') {\n if (charge === -1) {\n valence = 4\n hyd = 4 - rad - conn\n } else {\n valence = 3\n hyd = 3 - rad - conn - absCharge\n }\n } else if (label === 'Tl') {\n if (charge === -1) {\n if (rad + conn <= 2) {\n valence = 2\n hyd = 2 - rad - conn\n } else {\n valence = 4\n hyd = 4 - rad - conn\n }\n } else if (charge === -2) {\n if (rad + conn <= 3) {\n valence = 3\n hyd = 3 - rad - conn\n } else {\n valence = 5\n hyd = 5 - rad - conn\n }\n } else if (rad + conn + absCharge <= 1) {\n valence = 1\n hyd = 1 - rad - conn - absCharge\n } else {\n valence = 3\n hyd = 3 - rad - conn - absCharge\n }\n }\n } else if (groupno === 4) {\n if (label === 'C' || label === 'Si' || label === 'Ge') {\n valence = 4\n hyd = 4 - rad - conn - absCharge\n } else if (label === 'Sn' || label === 'Pb') {\n if (conn + rad + absCharge <= 2) {\n valence = 2\n hyd = 2 - rad - conn - absCharge\n } else {\n valence = 4\n hyd = 4 - rad - conn - absCharge\n }\n }\n } else if (groupno === 5) {\n if (label === 'N' || label === 'P') {\n if (charge === 1) {\n valence = 4\n hyd = 4 - rad - conn\n } else if (charge === 2) {\n valence = 3\n hyd = 3 - rad - conn\n } else if (label === 'N' || rad + conn + absCharge <= 3) {\n valence = 3\n hyd = 3 - rad - conn - absCharge\n } else {\n // ELEM_P && rad + conn + absCharge > 3\n valence = 5\n hyd = 5 - rad - conn - absCharge\n }\n } else if (label === 'Bi' || label === 'Sb' || label === 'As') {\n if (charge === 1) {\n if (rad + conn <= 2 && label !== 'As') {\n valence = 2\n hyd = 2 - rad - conn\n } else {\n valence = 4\n hyd = 4 - rad - conn\n }\n } else if (charge === 2) {\n valence = 3\n hyd = 3 - rad - conn\n } else if (rad + conn <= 3) {\n valence = 3\n hyd = 3 - rad - conn - absCharge\n } else {\n valence = 5\n hyd = 5 - rad - conn - absCharge\n }\n }\n } else if (groupno === 6) {\n if (label === 'O') {\n if (charge >= 1) {\n valence = 3\n hyd = 3 - rad - conn\n } else {\n valence = 2\n hyd = 2 - rad - conn - absCharge\n }\n } else if (label === 'S' || label === 'Se' || label === 'Po') {\n if (charge === 1) {\n if (conn <= 3) {\n valence = 3\n hyd = 3 - rad - conn\n } else {\n valence = 5\n hyd = 5 - rad - conn\n }\n } else if (conn + rad + absCharge <= 2) {\n valence = 2\n hyd = 2 - rad - conn - absCharge\n } else if (conn + rad + absCharge <= 4) {\n // See examples in PubChem\n // [S] : CID 16684216\n // [Se]: CID 5242252\n // [Po]: no example, just following ISIS/Draw logic here\n valence = 4\n hyd = 4 - rad - conn - absCharge\n } else {\n // See examples in PubChem\n // [S] : CID 46937044\n // [Se]: CID 59786\n // [Po]: no example, just following ISIS/Draw logic here\n valence = 6\n hyd = 6 - rad - conn - absCharge\n }\n } else if (label === 'Te') {\n if (charge === -1) {\n if (conn <= 2) {\n valence = 2\n hyd = 2 - rad - conn - absCharge\n }\n } else if (charge === 0 || charge === 2) {\n if (conn <= 2) {\n valence = 2\n hyd = 2 - rad - conn - absCharge\n } else if (conn <= 4) {\n valence = 4\n hyd = 4 - rad - conn - absCharge\n } else if (charge === 0 && conn <= 6) {\n valence = 6\n hyd = 6 - rad - conn - absCharge\n } else {\n hyd = -1\n }\n }\n }\n } else if (groupno === 7) {\n if (label === 'F') {\n valence = 1\n hyd = 1 - rad - conn - absCharge\n } else if (\n label === 'Cl' ||\n label === 'Br' ||\n label === 'I' ||\n label === 'At'\n ) {\n if (charge === 1) {\n if (conn <= 2) {\n valence = 2\n hyd = 2 - rad - conn\n } else if (conn === 3 || conn === 5 || conn >= 7) {\n hyd = -1\n }\n } else if (charge === 0) {\n if (conn <= 1) {\n valence = 1\n hyd = 1 - rad - conn\n // While the halogens can have valence 3, they can not have\n // hydrogens in that case.\n } else if (conn === 2 || conn === 4 || conn === 6) {\n if (rad === 1) {\n valence = conn\n hyd = 0\n } else {\n hyd = -1 // will throw an error in the end\n }\n } else if (conn > 7) {\n hyd = -1 // will throw an error in the end\n }\n }\n }\n } else if (groupno === 8) {\n if (conn + rad + absCharge === 0) valence = 1\n else hyd = -1\n }\n\n this.valence = valence\n this.implicitH = hyd\n if (this.implicitH < 0) {\n this.valence = conn\n this.implicitH = 0\n this.badConn = true\n return false\n }\n return true\n }\n\n calcValenceMinusHyd(conn: number): number {\n const charge = this.charge\n const label = this.label\n const element = Elements.get(this.label)\n if (!element) {\n // query atom, skip\n this.implicitH = 0\n return 0\n }\n\n var groupno = element.group\n var rad = radicalElectrons(this.radical)\n\n if (groupno === 3) {\n if (label === 'B' || label === 'Al' || label === 'Ga' || label === 'In') {\n if (charge === -1) {\n if (rad + conn <= 4) return rad + conn\n }\n }\n } else if (groupno === 5) {\n if (label === 'N' || label === 'P') {\n if (charge === 1) return rad + conn\n if (charge === 2) return rad + conn\n } else if (label === 'Sb' || label === 'Bi' || label === 'As') {\n if (charge === 1) return rad + conn\n else if (charge === 2) return rad + conn\n }\n } else if (groupno === 6) {\n if (label === 'O') {\n if (charge >= 1) return rad + conn\n } else if (label === 'S' || label === 'Se' || label === 'Po') {\n if (charge === 1) return rad + conn\n }\n } else if (groupno === 7) {\n if (label === 'Cl' || label === 'Br' || label === 'I' || label === 'At') {\n if (charge === 1) return rad + conn\n }\n }\n\n return rad + conn + Math.abs(charge)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport class Pile extends Set {\n // TODO: it's used only in dfs.js in one place in some strange way.\n // Should be removed after dfs.js refactoring\n find(predicate: (item: TValue) => boolean) {\n for (const item of this) {\n if (predicate(item)) return item\n }\n\n return null\n }\n\n equals(setB: Pile): boolean {\n return this.isSuperset(setB) && setB.isSuperset(this)\n }\n\n isSuperset(subset: Pile): boolean {\n for (const item of subset) {\n if (!this.has(item)) return false\n }\n\n return true\n }\n\n filter(expression: (arg: TValue) => boolean): Pile {\n return new Pile(Array.from(this).filter(expression))\n }\n\n union(setB: Pile): Pile {\n const union = new Pile(this)\n\n for (const item of setB) union.add(item)\n\n return union\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Point, Vec2 } from './vec2'\n\nimport { Bond } from './bond'\nimport { StereoLabel } from './atom'\nimport { Struct } from './struct'\n\nexport enum StereoFlag {\n Mixed = 'MIXED',\n Abs = 'ABS',\n And = 'AND',\n Or = 'OR'\n}\n\nfunction calcStereoFlag(\n struct: Struct,\n stereoAids: Array\n): StereoFlag | undefined {\n if (!stereoAids || stereoAids.length === 0) return undefined\n const filteredStereoAtoms = stereoAids\n .map(aid => struct.atoms.get(aid))\n .filter(atom => atom?.stereoLabel)\n if (!filteredStereoAtoms.length) return undefined\n\n const atom = filteredStereoAtoms[0]!\n const stereoLabel = atom.stereoLabel! // {string | null} \"-\"\n\n const hasAnotherLabel = filteredStereoAtoms.some(\n atom => atom?.stereoLabel !== stereoLabel\n )\n\n let stereoFlag: StereoFlag\n if (hasAnotherLabel) {\n stereoFlag = StereoFlag.Mixed\n } else {\n const label = stereoLabel.match(/\\D+/g)?.[0]\n switch (label) {\n case StereoLabel.Abs: {\n stereoFlag = StereoFlag.Abs\n break\n }\n case StereoLabel.And: {\n stereoFlag = StereoFlag.And\n break\n }\n case StereoLabel.Or: {\n stereoFlag = StereoFlag.Or\n break\n }\n default: {\n throw new Error(`Unsupported stereo label: ${label}.`)\n }\n }\n }\n return stereoFlag\n}\n\nexport class Fragment {\n #enhancedStereoFlag?: StereoFlag\n stereoFlagPosition?: Vec2\n #stereoAtoms: Array\n\n get stereoAtoms(): Array {\n return [...this.#stereoAtoms]\n }\n\n get enhancedStereoFlag() {\n return this.#enhancedStereoFlag\n }\n\n constructor(stereoAtoms: Array = [], stereoFlagPosition?: Point) {\n if (stereoFlagPosition) {\n this.stereoFlagPosition = new Vec2(stereoFlagPosition)\n }\n\n this.#stereoAtoms = stereoAtoms\n }\n\n static getDefaultStereoFlagPosition(\n struct: Struct,\n fragmentId: number\n ): Vec2 | undefined {\n const fragment = struct.getFragment(fragmentId)\n if (!fragment) return undefined\n const bb = fragment.getCoordBoundingBox()\n return new Vec2(bb.max.x, bb.min.y - 1)\n }\n\n clone(aidMap: Map) {\n const stereoAtoms = this.#stereoAtoms.map(aid => aidMap.get(aid)!)\n const fr = new Fragment(stereoAtoms, this.stereoFlagPosition)\n fr.#enhancedStereoFlag = this.#enhancedStereoFlag\n return fr\n }\n\n updateStereoFlag(struct: Struct) {\n this.#enhancedStereoFlag = calcStereoFlag(struct, this.stereoAtoms)\n return this.#enhancedStereoFlag\n }\n\n //TODO: split to 'add' and 'remove methods\n updateStereoAtom(struct: Struct, aid: number, frId: number, isAdd: boolean) {\n if (isAdd && !this.#stereoAtoms.includes(aid)) this.#stereoAtoms.push(aid)\n if (\n !isAdd &&\n (struct.atoms.get(aid)?.fragment !== frId ||\n !Array.from(struct.bonds.values())\n .filter(bond => bond.stereo && bond.type !== Bond.PATTERN.TYPE.DOUBLE)\n .some(bond => bond.begin === aid))\n ) {\n this.#stereoAtoms = this.stereoAtoms.filter(item => item !== aid)\n }\n\n this.#enhancedStereoFlag = calcStereoFlag(struct, this.stereoAtoms)\n }\n\n addStereoAtom(atomId: number): boolean {\n if (!this.#stereoAtoms.includes(atomId)) {\n this.stereoAtoms.push(atomId)\n return true\n }\n return false\n }\n\n deleteStereoAtom(\n struct: Struct,\n fragmentId: number,\n atomId: number\n ): boolean {\n if (\n struct.atoms.get(atomId)?.fragment !== fragmentId ||\n !Array.from(struct.bonds.values())\n .filter(bond => bond.stereo && bond.type !== Bond.PATTERN.TYPE.DOUBLE)\n .some(bond => bond.begin === atomId)\n ) {\n this.#stereoAtoms = this.#stereoAtoms.filter(item => item !== atomId)\n return true\n }\n return false\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from './vec2'\n\nexport interface BondAttributes {\n reactingCenterStatus?: number\n topology?: number\n stereo?: number\n xxx?: string\n type: number\n end: number\n begin: number\n}\n\nexport class Bond {\n static PATTERN = {\n TYPE: {\n SINGLE: 1,\n DOUBLE: 2,\n TRIPLE: 3,\n AROMATIC: 4,\n SINGLE_OR_DOUBLE: 5,\n SINGLE_OR_AROMATIC: 6,\n DOUBLE_OR_AROMATIC: 7,\n ANY: 8,\n DATIVE: 9,\n HYDROGEN: 10\n },\n\n STEREO: {\n NONE: 0,\n UP: 1,\n EITHER: 4,\n DOWN: 6,\n CIS_TRANS: 3\n },\n\n TOPOLOGY: {\n EITHER: 0,\n RING: 1,\n CHAIN: 2\n },\n\n REACTING_CENTER: {\n NOT_CENTER: -1,\n UNMARKED: 0,\n CENTER: 1,\n UNCHANGED: 2,\n MADE_OR_BROKEN: 4,\n ORDER_CHANGED: 8,\n MADE_OR_BROKEN_AND_CHANGED: 12\n }\n }\n\n static attrlist = {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.NONE,\n topology: Bond.PATTERN.TOPOLOGY.EITHER,\n reactingCenterStatus: Bond.PATTERN.REACTING_CENTER.UNMARKED\n }\n\n begin: number\n end: number\n readonly type: number\n readonly xxx: string\n readonly stereo: number\n readonly topology: number\n readonly reactingCenterStatus: number\n len: number\n sb: number\n sa: number\n hb1?: number\n hb2?: number\n angle: number\n center: Vec2\n\n constructor(attributes: BondAttributes) {\n this.begin = attributes.begin\n this.end = attributes.end\n this.type = attributes.type\n this.xxx = attributes.xxx || ''\n this.stereo = Bond.PATTERN.STEREO.NONE\n this.topology = Bond.PATTERN.TOPOLOGY.EITHER\n this.reactingCenterStatus = 0\n this.len = 0\n this.sb = 0\n this.sa = 0\n this.angle = 0\n\n if (attributes.stereo) this.stereo = attributes.stereo\n if (attributes.topology) this.topology = attributes.topology\n if (attributes.reactingCenterStatus)\n this.reactingCenterStatus = attributes.reactingCenterStatus\n\n this.center = new Vec2()\n }\n\n static getAttrHash(bond: Bond) {\n let attrs = {}\n for (let attr in Bond.attrlist) {\n if (bond[attr] || attr === 'stereo') {\n attrs[attr] = bond[attr]\n }\n }\n return attrs\n }\n\n static attrGetDefault(attr: string) {\n if (attr in Bond.attrlist) {\n return Bond.attrlist[attr]\n }\n }\n\n hasRxnProps(): boolean {\n return !!this.reactingCenterStatus\n }\n\n getCenter(struct: any): Vec2 {\n const p1 = struct.atoms.get(this.begin).pp\n const p2 = struct.atoms.get(this.end).pp\n return Vec2.lc2(p1, 0.5, p2, 0.5)\n }\n\n getDir(struct: any): Vec2 {\n const p1 = struct.atoms.get(this.begin)!.pp\n const p2 = struct.atoms.get(this.end)!.pp\n return p2.sub(p1).normalized()\n }\n\n clone(aidMap?: Map | null): Bond {\n const cp = new Bond(this)\n if (aidMap) {\n cp.begin = aidMap.get(cp.begin)!\n cp.end = aidMap.get(cp.end)!\n }\n return cp\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from 'domain/entities'\n\nexport interface ScaleOptions {\n scale: number\n}\n\nfunction scaled2obj(v: Vec2, options: ScaleOptions): Vec2 {\n return v.scaled(1 / options.scale)\n}\n\nfunction obj2scaled(v: Vec2, options: ScaleOptions): Vec2 {\n return v.scaled(options.scale)\n}\n\nexport const Scale = {\n scaled2obj,\n obj2scaled\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond, Neighbor, Struct } from 'domain/entities'\n\nfunction isCorrectStereoCenter(\n bond: Bond,\n beginNeighs: Array | undefined,\n endNeighs: Array | undefined,\n struct: Struct\n) {\n const beginAtom = struct.atoms.get(bond.begin)\n\n let EndAtomNeigh: number | undefined = NaN\n\n if (endNeighs?.length === 2) {\n EndAtomNeigh =\n endNeighs[0].aid === bond.begin ? endNeighs[1].aid : endNeighs[0].aid\n }\n\n if (bond.stereo > 0) {\n if (\n endNeighs?.length === 1 &&\n beginNeighs?.length === 2 &&\n Number(beginAtom?.implicitH) % 2 === 0\n ) {\n return false\n }\n\n if (\n endNeighs?.length === 2 &&\n beginNeighs?.length === 2 &&\n Number(beginAtom?.implicitH) % 2 === 0 &&\n struct.atomGetNeighbors(EndAtomNeigh)?.length === 1\n ) {\n return false\n }\n\n if (beginNeighs?.length === 1) {\n return false\n }\n\n return true\n } else {\n return false\n }\n}\n\nexport const StereoValidator = {\n isCorrectStereoCenter\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\nimport { Struct } from '../entities'\n\nexport class FunctionalGroupsProvider {\n private static instance: FunctionalGroupsProvider\n functionalGroupsList: Struct[]\n constructor() {\n this.functionalGroupsList = []\n }\n\n public static getInstance(): FunctionalGroupsProvider {\n if (!FunctionalGroupsProvider.instance) {\n FunctionalGroupsProvider.instance = new FunctionalGroupsProvider()\n }\n return FunctionalGroupsProvider.instance\n }\n\n public getFunctionalGroupsList() {\n return this.functionalGroupsList\n }\n\n public setFunctionalGroupsList(list: Struct[]): void {\n this.functionalGroupsList = list\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from './vec2'\nimport assert from 'assert'\n\nexport class Box2Abs {\n readonly p0: Vec2\n readonly p1: Vec2\n\n constructor()\n constructor(p: Vec2)\n constructor(p0: Vec2, p1: Vec2)\n constructor(x0: number, y0: number, x1: number, y1: number)\n constructor(...args: Array) {\n if (args.length === 1 && 'min' in args[0] && 'max' in args[0]) {\n this.p0 = args[0].min\n this.p1 = args[0].max\n }\n\n if (args.length === 2) {\n this.p0 = args[0]\n this.p1 = args[1]\n } else if (args.length === 4) {\n this.p0 = new Vec2(args[0], args[1])\n this.p1 = new Vec2(args[2], args[3])\n } else if (args.length === 0) {\n this.p0 = new Vec2()\n this.p1 = new Vec2()\n } else {\n throw new Error(\n 'Box2Abs constructor only accepts 4 numbers or 2 vectors or no args!'\n )\n }\n }\n\n toString(): string {\n return this.p0.toString() + ' ' + this.p1.toString()\n }\n\n clone(): Box2Abs {\n return new Box2Abs(this.p0, this.p1)\n }\n\n extend(lp: Vec2, rb: Vec2): Box2Abs {\n rb = rb || lp\n return new Box2Abs(this.p0.sub(lp), this.p1.add(rb))\n }\n\n include(p: Vec2): Box2Abs {\n assert(p != null)\n\n return new Box2Abs(this.p0.min(p), this.p1.max(p))\n }\n\n contains(p: Vec2, ext: number = 0.0): boolean {\n assert(p != null)\n\n return (\n p.x >= this.p0.x - ext &&\n p.x <= this.p1.x + ext &&\n p.y >= this.p0.y - ext &&\n p.y <= this.p1.y + ext\n )\n }\n\n translate(d: Vec2): Box2Abs {\n return new Box2Abs(this.p0.add(d), this.p1.add(d))\n }\n\n transform(f: (p: Vec2, options: any) => Vec2, options: any): Box2Abs {\n assert(typeof f === 'function')\n\n return new Box2Abs(f(this.p0, options), f(this.p1, options))\n }\n\n sz(): Vec2 {\n return this.p1.sub(this.p0)\n }\n\n centre(): Vec2 {\n return Vec2.centre(this.p0, this.p1)\n }\n\n pos() {\n return this.p0\n }\n\n static fromRelBox(relBox: any): Box2Abs {\n return new Box2Abs(\n relBox.x,\n relBox.y,\n relBox.x + relBox.width,\n relBox.y + relBox.height\n )\n }\n\n static union(b1: Box2Abs, b2: Box2Abs): Box2Abs {\n return new Box2Abs(Vec2.min(b1.p0, b2.p0), Vec2.max(b1.p1, b2.p1))\n }\n\n static segmentIntersection(a: Vec2, b: Vec2, c: Vec2, d: Vec2): boolean {\n const dc = (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x)\n const dd = (a.x - d.x) * (b.y - d.y) - (a.y - d.y) * (b.x - d.x)\n const da = (c.x - a.x) * (d.y - a.y) - (c.y - a.y) * (d.x - a.x)\n const db = (c.x - b.x) * (d.y - b.y) - (c.y - b.y) * (d.x - b.x)\n\n return dc * dd <= 0 && da * db <= 0\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom } from './atom'\nimport { Bond } from './bond'\nimport { Box2Abs } from './box2Abs'\nimport { Pile } from './pile'\nimport { Struct } from './struct'\nimport { Vec2 } from './vec2'\n\nexport class SGroupBracketParams {\n readonly c: Vec2\n readonly d: Vec2\n readonly n: Vec2\n readonly w: number\n readonly h: number\n\n constructor(c: Vec2, d: Vec2, w: number, h: number) {\n this.c = c\n this.d = d\n this.n = d.rotateSC(1, 0)\n this.w = w\n this.h = h\n }\n}\n\nexport class SGroup {\n static TYPES = {\n SUP: 'SUP',\n MUL: 'MUL',\n SRU: 'SRU',\n MON: 'MON',\n MER: 'MER',\n COP: 'COP',\n CRO: 'CRO',\n MOD: 'MOD',\n GRA: 'GRA',\n COM: 'COM',\n MIX: 'MIX',\n FOR: 'FOR',\n DAT: 'DAT',\n ANY: 'ANY',\n GEN: 'GEN'\n }\n\n type: string\n id: number\n label: number\n bracketBox: any\n bracketDir: Vec2\n areas: any\n highlight: boolean\n highlighting: any\n selected: boolean\n selectionPlate: any\n atoms: any\n atomSet: any\n parentAtomSet: any\n patoms?: any\n allAtoms: any\n bonds: any\n xBonds: any\n neiAtoms: any\n pp: Vec2 | null\n data: any\n\n constructor(type: string) {\n this.type = type\n this.id = -1\n this.label = -1\n this.bracketBox = null\n this.bracketDir = new Vec2(1, 0)\n this.areas = []\n\n this.highlight = false\n this.highlighting = null\n this.selected = false\n this.selectionPlate = null\n\n this.atoms = []\n this.patoms = []\n this.bonds = []\n this.xBonds = []\n this.neiAtoms = []\n this.pp = null\n this.data = {\n mul: 1, // multiplication count for MUL group\n connectivity: 'ht', // head-to-head, head-to-tail or either-unknown\n name: '',\n subscript: 'n',\n expanded: undefined,\n // data s-group fields\n attached: false,\n absolute: true,\n showUnits: false,\n nCharsToDisplay: -1,\n tagChar: '',\n daspPos: 1,\n fieldType: 'F',\n fieldName: '',\n fieldValue: '',\n units: '',\n query: '',\n queryOp: ''\n }\n }\n\n // TODO: these methods should be overridden\n // and should only accept valid attributes for each S-group type.\n // The attributes should be accessed via these methods only and not directly through this.data.\n // stub\n getAttr(attr: string): any {\n return this.data[attr]\n }\n\n // TODO: should be group-specific\n getAttrs(): any {\n var attrs = {}\n Object.keys(this.data).forEach(attr => {\n attrs[attr] = this.data[attr]\n })\n return attrs\n }\n\n // stub\n setAttr(attr: string, value: any): any {\n var oldValue = this.data[attr]\n this.data[attr] = value\n return oldValue\n }\n\n // stub\n checkAttr(attr: string, value: any): boolean {\n return this.data[attr] === value\n }\n\n updateOffset(offset: Vec2): void {\n this.pp = Vec2.sum(this.bracketBox.p1, offset)\n }\n\n calculatePP(struct: Struct): void {\n let topLeftPoint\n\n if (this.data.context === 'Atom' || this.data.context === 'Bond') {\n const contentBoxes: Array = []\n let contentBB: Box2Abs | null = null\n const direction = new Vec2(1, 0)\n\n this.atoms.forEach(aid => {\n const atom = struct.atoms.get(aid)\n const pos = new Vec2(atom!.pp)\n const ext = new Vec2(0.05 * 3, 0.05 * 3)\n const bba = new Box2Abs(pos, pos).extend(ext, ext)\n contentBoxes.push(bba)\n })\n contentBoxes.forEach(bba => {\n var bbb: Box2Abs | null = null\n ;[bba.p0.x, bba.p1.x].forEach(x => {\n ;[bba.p0.y, bba.p1.y].forEach(y => {\n var v = new Vec2(x, y)\n var p = new Vec2(\n Vec2.dot(v, direction),\n Vec2.dot(v, direction.rotateSC(1, 0))\n )\n bbb = !bbb ? new Box2Abs(p, p) : bbb!.include(p)\n })\n })\n contentBB = !contentBB ? bbb : Box2Abs.union(contentBB, bbb!)\n })\n\n topLeftPoint = contentBB!.p0\n } else {\n topLeftPoint = this.bracketBox.p1.add(new Vec2(0.5, 0.5))\n }\n\n const sgroups = Array.from(struct.sgroups.values())\n for (let i = 0; i < struct.sgroups.size; ++i) {\n if (!descriptorIntersects(sgroups as [], topLeftPoint)) break\n\n topLeftPoint = topLeftPoint.add(new Vec2(0, 0.5))\n }\n\n // TODO: the code below is a temporary solution that will be removed after the implementation of the internal format\n // TODO: in schema.json required fields [\"context\", \"FieldValue\"] in sgroups type DAT must be returned\n if (this.data.fieldName === 'INDIGO_CIP_DESC') {\n if (this.atoms.length === 1) {\n const sAtom = this.atoms[0]\n const sAtomPP = struct.atoms.get(sAtom)?.pp\n\n if (sAtomPP) {\n topLeftPoint = sAtomPP\n }\n } else {\n topLeftPoint = SGroup.getMassCentre(struct, this.atoms)\n }\n }\n\n this.pp = topLeftPoint\n }\n\n static getOffset(sgroup: SGroup): null | Vec2 {\n if (!sgroup?.pp) return null\n return Vec2.diff(sgroup.pp, sgroup.bracketBox.p1)\n }\n\n static filterAtoms(atoms: any, map: any) {\n var newAtoms: Array = []\n for (var i = 0; i < atoms.length; ++i) {\n var aid = atoms[i]\n if (typeof map[aid] !== 'number') newAtoms.push(aid)\n else if (map[aid] >= 0) newAtoms.push(map[aid])\n else newAtoms.push(-1)\n }\n return newAtoms\n }\n\n static removeNegative(atoms: any) {\n var newAtoms: Array = []\n for (var j = 0; j < atoms.length; ++j) {\n if (atoms[j] >= 0) newAtoms.push(atoms[j])\n }\n return newAtoms\n }\n\n static filter(_mol, sg, atomMap) {\n sg.atoms = SGroup.removeNegative(SGroup.filterAtoms(sg.atoms, atomMap))\n }\n\n static clone(sgroup: SGroup, aidMap: Map): SGroup {\n const cp = new SGroup(sgroup.type)\n\n Object.keys(sgroup.data).forEach(field => {\n cp.data[field] = sgroup.data[field]\n })\n\n cp.atoms = sgroup.atoms.map(elem => aidMap.get(elem))\n cp.pp = sgroup.pp\n cp.bracketBox = sgroup.bracketBox\n cp.patoms = null\n cp.bonds = null\n cp.allAtoms = sgroup.allAtoms\n cp.data.expanded = sgroup.data.expanded\n return cp\n }\n\n static addAtom(sgroup: SGroup, aid: number): void {\n sgroup.atoms.push(aid)\n }\n\n static removeAtom(sgroup: SGroup, aid: number): void {\n for (var i = 0; i < sgroup.atoms.length; ++i) {\n if (sgroup.atoms[i] === aid) {\n sgroup.atoms.splice(i, 1)\n return\n }\n }\n }\n\n static getCrossBonds(\n mol: any,\n parentAtomSet: Pile\n ): { [key: number]: Array } {\n const crossBonds: { [key: number]: Array } = {}\n mol.bonds.forEach((bond, bid) => {\n if (parentAtomSet.has(bond.begin) && !parentAtomSet.has(bond.end)) {\n if (!crossBonds[bond.begin]) {\n crossBonds[bond.begin] = []\n }\n crossBonds[bond.begin].push(bid)\n } else if (\n parentAtomSet.has(bond.end) &&\n !parentAtomSet.has(bond.begin)\n ) {\n if (!crossBonds[bond.end]) {\n crossBonds[bond.end] = []\n }\n crossBonds[bond.end].push(bid)\n }\n })\n return crossBonds\n }\n\n static bracketPos(\n sGroup,\n mol,\n crossBondsPerAtom: { [key: number]: Array }\n ): void {\n var atoms = sGroup.atoms\n const crossBonds = Object.values(crossBondsPerAtom).flat()\n if (!crossBonds || crossBonds.length !== 2) {\n sGroup.bracketDir = new Vec2(1, 0)\n } else {\n var p1 = mol.bonds.get(crossBonds[0]).getCenter(mol)\n var p2 = mol.bonds.get(crossBonds[1]).getCenter(mol)\n sGroup.bracketDir = Vec2.diff(p2, p1).normalized()\n }\n var d = sGroup.bracketDir\n\n var braketBox: Box2Abs | null = null\n var contentBoxes: Array = []\n atoms.forEach(aid => {\n var atom = mol.atoms.get(aid)\n var pos = new Vec2(atom.pp)\n var ext = new Vec2(0.05 * 3, 0.05 * 3)\n var bba = new Box2Abs(pos, pos).extend(ext, ext)\n contentBoxes.push(bba)\n })\n contentBoxes.forEach(bba => {\n var bbb: Box2Abs | null = null\n ;[bba.p0.x, bba.p1.x].forEach(x => {\n ;[bba.p0.y, bba.p1.y].forEach(y => {\n var v = new Vec2(x, y)\n var p = new Vec2(Vec2.dot(v, d), Vec2.dot(v, d.rotateSC(1, 0)))\n bbb = !bbb ? new Box2Abs(p, p) : bbb!.include(p)\n })\n })\n braketBox = !braketBox ? bbb : Box2Abs.union(braketBox, bbb!)\n })\n var vext = new Vec2(0.2, 0.4)\n if (braketBox) braketBox = (braketBox as Box2Abs).extend(vext, vext)\n sGroup.bracketBox = braketBox\n }\n\n static getBracketParameters(\n mol,\n crossBondsPerAtom: { [key: number]: Array },\n atomSet: Pile,\n bb,\n d,\n n\n ): Array {\n var brackets: Array = []\n const crossBondsPerAtomValues = Object.values(crossBondsPerAtom)\n const crossBonds = crossBondsPerAtomValues.flat()\n if (crossBonds.length < 2) {\n ;(function () {\n d = d || new Vec2(1, 0)\n n = n || d.rotateSC(1, 0)\n var bracketWidth = Math.min(0.25, bb.sz().x * 0.3)\n var cl = Vec2.lc2(d, bb.p0.x, n, 0.5 * (bb.p0.y + bb.p1.y))\n var cr = Vec2.lc2(d, bb.p1.x, n, 0.5 * (bb.p0.y + bb.p1.y))\n var bracketHeight = bb.sz().y\n\n brackets.push(\n new SGroupBracketParams(cl, d.negated(), bracketWidth, bracketHeight),\n new SGroupBracketParams(cr, d, bracketWidth, bracketHeight)\n )\n })()\n } else if (\n crossBonds.length === 2 &&\n crossBondsPerAtomValues.length === 2\n ) {\n ;(function () {\n var b1 = mol.bonds.get(crossBonds[0])\n var b2 = mol.bonds.get(crossBonds[1])\n var cl0 = b1.getCenter(mol)\n var cr0 = b2.getCenter(mol)\n var dr = Vec2.diff(cr0, cl0).normalized()\n var dl = dr.negated()\n\n var bracketWidth = 0.25\n var bracketHeight = 1.5\n brackets.push(\n new SGroupBracketParams(\n cl0.addScaled(dl, 0),\n dl,\n bracketWidth,\n bracketHeight\n ),\n new SGroupBracketParams(\n cr0.addScaled(dr, 0),\n dr,\n bracketWidth,\n bracketHeight\n )\n )\n })()\n } else {\n ;(function () {\n for (var i = 0; i < crossBonds.length; ++i) {\n var b = mol.bonds.get(crossBonds[i])\n var c = b.getCenter(mol)\n var d = atomSet.has(b.begin) ? b.getDir(mol) : b.getDir(mol).negated()\n brackets.push(new SGroupBracketParams(c, d, 0.2, 1.0))\n }\n })()\n }\n return brackets\n }\n\n static getObjBBox(atoms, mol): Box2Abs {\n var a0 = mol.atoms.get(atoms[0]).pp\n var bb = new Box2Abs(a0, a0)\n for (var i = 1; i < atoms.length; ++i) {\n var aid = atoms[i]\n var atom = mol.atoms.get(aid)\n var p = atom.pp\n bb = bb.include(p)\n }\n return bb\n }\n\n static getAtoms(mol, sg): Array {\n if (!sg.allAtoms) return sg.atoms\n var atoms: Array = []\n mol.atoms.forEach((_atom, aid) => {\n atoms.push(aid)\n })\n return atoms\n }\n\n static getBonds(mol, sg): Array {\n var atoms = SGroup.getAtoms(mol, sg)\n var bonds: Array = []\n mol.bonds.forEach((bond, bid) => {\n if (atoms.indexOf(bond.begin) >= 0 && atoms.indexOf(bond.end) >= 0)\n bonds.push(bid)\n })\n return bonds\n }\n\n static prepareMulForSaving(sgroup, mol): void {\n sgroup.atoms.sort((a, b) => a - b)\n sgroup.atomSet = new Pile(sgroup.atoms)\n sgroup.parentAtomSet = new Pile(sgroup.atomSet)\n var inBonds: Array = []\n var xBonds: Array = []\n\n mol.bonds.forEach((bond, bid) => {\n if (\n sgroup.parentAtomSet.has(bond.begin) &&\n sgroup.parentAtomSet.has(bond.end)\n )\n inBonds.push(bid)\n else if (\n sgroup.parentAtomSet.has(bond.begin) ||\n sgroup.parentAtomSet.has(bond.end)\n )\n xBonds.push(bid)\n })\n\n if (xBonds.length !== 0 && xBonds.length !== 2)\n throw Error('Unsupported cross-bonds number')\n\n var xAtom1 = -1\n var xAtom2 = -1\n var crossBond = null\n if (xBonds.length === 2) {\n var bond1 = mol.bonds.get(xBonds[0])\n xAtom1 = sgroup.parentAtomSet.has(bond1.begin) ? bond1.begin : bond1.end\n\n var bond2 = mol.bonds.get(xBonds[1])\n xAtom2 = sgroup.parentAtomSet.has(bond2.begin) ? bond2.begin : bond2.end\n crossBond = bond2\n }\n\n var tailAtom = xAtom2\n\n var newAtoms: Array = []\n for (var j = 0; j < sgroup.data.mul - 1; j++) {\n let amap = {}\n sgroup.atoms.forEach(aid => {\n var atom = mol.atoms.get(aid)\n var aid2 = mol.atoms.add(new Atom(atom))\n newAtoms.push(aid2)\n sgroup.atomSet.add(aid2)\n amap[aid] = aid2\n })\n inBonds.forEach(bid => {\n var bond = mol.bonds.get(bid)\n var newBond = new Bond(bond)\n newBond.begin = amap[newBond.begin]\n newBond.end = amap[newBond.end]\n mol.bonds.add(newBond)\n })\n if (crossBond !== null) {\n var newCrossBond = new Bond(crossBond)\n newCrossBond.begin = tailAtom\n newCrossBond.end = amap[xAtom1]\n mol.bonds.add(newCrossBond)\n tailAtom = amap[xAtom2]\n }\n }\n if (tailAtom >= 0) {\n var xBond2 = mol.bonds.get(xBonds[1])\n if (xBond2.begin === xAtom2) xBond2.begin = tailAtom\n else xBond2.end = tailAtom\n }\n sgroup.bonds = xBonds\n\n newAtoms.forEach(aid => {\n mol.sGroupForest\n .getPathToRoot(sgroup.id)\n .reverse()\n .forEach(sgid => {\n mol.atomAddToSGroup(sgid, aid)\n })\n })\n }\n\n static getMassCentre(mol, atoms): Vec2 {\n var c = new Vec2() // mass centre\n for (var i = 0; i < atoms.length; ++i)\n c = c.addScaled(mol.atoms.get(atoms[i]).pp, 1.0 / atoms.length)\n return c\n }\n}\n\nfunction descriptorIntersects(sgroups: [], topLeftPoint: Vec2): boolean {\n return sgroups.some((sg: SGroup) => {\n if (!sg.pp) return false\n\n const sgBottomRightPoint = sg.pp.add(new Vec2(0.5, 0.5))\n const bottomRightPoint = topLeftPoint.add(new Vec2(0.5, 0.5))\n\n return Box2Abs.segmentIntersection(\n sg.pp,\n sgBottomRightPoint,\n topLeftPoint,\n bottomRightPoint\n )\n })\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Point, Vec2 } from './vec2'\n\nexport enum RxnArrowMode {\n OpenAngle = 'open-angle',\n FilledTriangle = 'filled-triangle',\n FilledBow = 'filled-bow',\n DashedOpenAngle = 'dashed-open-angle',\n Failed = 'failed',\n BothEndsFilledTriangle = 'both-ends-filled-triangle',\n EquilibriumFilledTriangle = 'equilibrium-filled-triangle',\n EquilibriumFilledHalfBow = 'equilibrium-filled-half-bow',\n EquilibriumOpenAngle = 'equilibrium-open-angle',\n UnbalancedEquilibriumFilledHalfBow = 'unbalanced-equilibrium-filled-half-bow',\n UnbalancedEquilibriumOpenHalfAngle = 'unbalanced-equilibrium-open-half-angle',\n UnbalancedEquilibriumLargeFilledHalfBow = 'unbalanced-equilibrium-large-filled-half-bow',\n UnbalancedEquilibriumFilleHalfTriangle = 'unbalanced-equilibrium-fille-half-triangle'\n}\n\nexport interface RxnArrowAttributes {\n mode: RxnArrowMode\n pos?: Array\n}\n\nexport class RxnArrow {\n mode: RxnArrowMode\n pos: Array\n\n constructor(atrributes: RxnArrowAttributes) {\n this.pos = []\n\n if (atrributes.pos) {\n for (let i = 0; i < atrributes.pos.length; i++) {\n const currentP = atrributes.pos[i]\n this.pos[i] = currentP ? new Vec2(atrributes.pos[i]) : new Vec2()\n }\n }\n\n this.mode = atrributes.mode\n }\n\n clone() {\n return new RxnArrow(this)\n }\n\n center(): Vec2 {\n return Vec2.centre(this.pos[0], this.pos[1])\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\nimport { FunctionalGroupsProvider } from '../helpers'\nimport { SGroup } from './sgroup'\nimport assert from 'assert'\n\nexport class FunctionalGroup {\n #sgroup: SGroup\n\n constructor(sgroup: SGroup) {\n assert(sgroup != null)\n\n this.#sgroup = sgroup\n }\n\n get name(): string {\n return this.#sgroup.data.name\n }\n\n get relatedSGroupId(): number {\n return this.#sgroup.id\n }\n\n get isExpanded(): boolean {\n return this.#sgroup.data.expanded\n }\n\n get relatedSGroup(): SGroup {\n return this.#sgroup\n }\n\n static isFunctionalGroup(sgroup): boolean {\n const provider = FunctionalGroupsProvider.getInstance()\n const types = provider.getFunctionalGroupsList()\n return (\n types.some(type => type.name === sgroup.data.name) &&\n sgroup.type === 'SUP'\n )\n }\n\n static atomsInFunctionalGroup(functionalGroups, atom): number | null {\n if (functionalGroups.size === 0) {\n return null\n }\n for (let fg of functionalGroups.values()) {\n if (fg.relatedSGroup.atoms.includes(atom)) return atom\n }\n return null\n }\n\n static bondsInFunctionalGroup(\n molecule,\n functionalGroups,\n bond\n ): number | null {\n if (functionalGroups.size === 0) {\n return null\n }\n for (let fg of functionalGroups.values()) {\n const bonds = SGroup.getBonds(molecule, fg.relatedSGroup)\n if (bonds.includes(bond)) return bond\n }\n return null\n }\n\n static findFunctionalGroupByAtom(functionalGroups, atom): number | null {\n for (let fg of functionalGroups.values()) {\n if (fg.relatedSGroup.atoms.includes(atom)) return fg.relatedSGroupId\n }\n return null\n }\n\n static findFunctionalGroupByBond(\n molecule,\n functionalGroups,\n bond\n ): number | null {\n for (let fg of functionalGroups.values()) {\n const bonds = SGroup.getBonds(molecule, fg.relatedSGroup)\n if (bonds.includes(bond)) return fg.relatedSGroupId\n }\n return null\n }\n\n static clone(functionalGroup: FunctionalGroup): FunctionalGroup {\n return new FunctionalGroup(functionalGroup.#sgroup)\n }\n\n static isFirstAtomInFunctionalGroup(sgroups, aid): boolean {\n for (let sg of sgroups.values()) {\n if (FunctionalGroup.isFunctionalGroup(sg) && aid === sg.atoms[0]) {\n return true\n }\n }\n return false\n }\n\n static isAtomInContractedFunctionalGroup(\n atom,\n sgroups,\n functionalGroups,\n sgroupsFromReStruct: boolean\n ): boolean {\n const contractedFunctionalGroups: number[] = []\n if (sgroupsFromReStruct) {\n sgroups.forEach(sg => {\n if (\n FunctionalGroup.isContractedFunctionalGroup(\n sg.item.id,\n functionalGroups\n )\n ) {\n contractedFunctionalGroups.push(sg.item.id)\n }\n })\n } else {\n sgroups.forEach(sg => {\n if (\n FunctionalGroup.isContractedFunctionalGroup(sg.id, functionalGroups)\n ) {\n contractedFunctionalGroups.push(sg.id)\n }\n })\n }\n return contractedFunctionalGroups.some(sg => atom.sgs.has(sg))\n }\n\n static isBondInContractedFunctionalGroup(\n bond,\n sgroups,\n functionalGroups,\n sgroupsFromReStruct: boolean\n ): boolean {\n const contractedFunctionalGroupsAtoms: number[] = []\n if (sgroupsFromReStruct) {\n sgroups.forEach(sg => {\n if (\n FunctionalGroup.isContractedFunctionalGroup(\n sg.item.id,\n functionalGroups\n )\n ) {\n contractedFunctionalGroupsAtoms.push(...sg.item.atoms)\n }\n })\n } else {\n sgroups.forEach(sg => {\n if (\n FunctionalGroup.isContractedFunctionalGroup(sg.id, functionalGroups)\n ) {\n contractedFunctionalGroupsAtoms.push(...sg.atoms)\n }\n })\n }\n return (\n contractedFunctionalGroupsAtoms.includes(bond.begin) &&\n contractedFunctionalGroupsAtoms.includes(bond.end)\n )\n }\n\n static isContractedFunctionalGroup(sgroupId, functionalGroups): boolean {\n let isFunctionalGroup = false\n let expanded = false\n functionalGroups.forEach(fg => {\n if (fg.relatedSGroupId === sgroupId) {\n isFunctionalGroup = true\n expanded = fg.isExpanded\n }\n })\n return !expanded && isFunctionalGroup\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from './vec2'\nimport assert from 'assert'\n\nexport class HalfBond {\n begin: number\n end: number\n bid: number\n dir: Vec2\n norm: Vec2\n ang: number\n p: Vec2\n loop: number\n contra: number\n next: number\n leftSin: number\n leftCos: number\n leftNeighbor: number\n rightSin: number\n rightCos: number\n rightNeighbor: number\n\n constructor(begin: number, end: number, bid: number) {\n assert(arguments.length === 3, 'Invalid parameter number.')\n\n this.begin = begin\n this.end = end\n this.bid = bid\n\n // rendering properties\n this.dir = new Vec2() // direction\n this.norm = new Vec2() // left normal\n this.ang = 0 // angle to (1,0), used for sorting the bonds\n this.p = new Vec2() // corrected origin position\n this.loop = -1 // left loop id if the half-bond is in a loop, otherwise -1\n this.contra = -1 // the half bond contrary to this one\n this.next = -1 // the half-bond next ot this one in CCW order\n this.leftSin = 0\n this.leftCos = 0\n this.leftNeighbor = 0\n this.rightSin = 0\n this.rightCos = 0\n this.rightNeighbor = 0\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond } from './bond'\nimport { Struct } from './struct'\n\nexport class Loop {\n hbs: number[]\n dblBonds: number\n aromatic: boolean\n convex: boolean\n\n constructor(hbs: Array, struct: Struct, isConvex: boolean) {\n this.hbs = hbs // set of half-bonds involved\n this.dblBonds = 0 // number of double bonds in the loop\n this.aromatic = true\n this.convex = isConvex || false\n\n hbs.forEach(hb => {\n const bond: Bond = struct.bonds.get(struct.halfBonds.get(hb)!.bid)!\n if (bond.type !== Bond.PATTERN.TYPE.AROMATIC) this.aromatic = false\n if (bond.type === Bond.PATTERN.TYPE.DOUBLE) this.dblBonds++\n })\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Pile } from './pile'\nimport { Pool } from './pool'\n\nexport interface RGroupAttributes {\n ifthen?: number\n resth?: boolean\n range?: string\n}\nexport class RGroup {\n frags: Pile\n resth: boolean\n range: string\n ifthen: number\n\n constructor(atrributes?: RGroupAttributes) {\n this.frags = new Pile()\n this.resth = atrributes?.resth || false\n this.range = atrributes?.range || ''\n this.ifthen = atrributes?.ifthen || 0\n }\n\n static findRGroupByFragment(rgroups: Pool, frid: number) {\n return rgroups.find((_rgid, rgroup) => rgroup.frags.has(frid))\n }\n\n getAttrs(): RGroupAttributes {\n return {\n resth: this.resth,\n range: this.range,\n ifthen: this.ifthen\n }\n }\n\n clone(fidMap?: Map | null): RGroup {\n const ret = new RGroup(this)\n this.frags.forEach(fid => {\n ret.frags.add(fidMap ? fidMap.get(fid)! : fid)\n })\n return ret\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Point, Vec2 } from './vec2'\n\nexport enum SimpleObjectMode {\n ellipse = 'ellipse',\n rectangle = 'rectangle',\n line = 'line'\n}\n\nexport interface SimpleObjectAttributes {\n mode: SimpleObjectMode\n pos?: Array\n}\n\nexport class SimpleObject {\n pos: Array\n mode: SimpleObjectMode\n\n constructor(attributes?: SimpleObjectAttributes) {\n this.pos = []\n\n if (attributes?.pos) {\n for (let i = 0; i < attributes.pos.length; i++) {\n const currentP = attributes.pos[i]\n this.pos[i] = currentP ? new Vec2(attributes.pos[i]) : new Vec2()\n }\n }\n\n this.mode = attributes?.mode || SimpleObjectMode.line\n }\n\n clone(): SimpleObject {\n return new SimpleObject(this)\n }\n\n center(): Vec2 {\n switch (this.mode) {\n case SimpleObjectMode.rectangle: {\n return Vec2.centre(this.pos[0], this.pos[1])\n }\n default:\n return this.pos[0]\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Point, Vec2 } from './vec2'\n\nexport interface RxnPlusAttributes {\n pp?: Point\n}\n\nexport class RxnPlus {\n pp: Vec2\n\n constructor(attributes?: RxnPlusAttributes) {\n this.pp = attributes?.pp ? new Vec2(attributes.pp) : new Vec2()\n }\n\n clone() {\n return new RxnPlus(this)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Pile } from './pile'\nimport { SGroup } from './sgroup'\nimport assert from 'assert'\n\nexport class SGroupForest {\n /** node id -> parent id */\n parent: Map\n /** node id -> list of child ids */\n children: Map\n atomSets: Map\n\n constructor() {\n this.parent = new Map()\n this.children = new Map()\n\n this.children.set(-1, []) // extra root node\n this.atomSets = new Map()\n }\n\n /** returns an array or s-group ids in the order of breadth-first search */\n getSGroupsBFS(): number[] {\n const order: number[] = []\n const queue = Array.from(this.children.get(-1) as Array)\n while (queue.length > 0) {\n const id = queue.shift()\n if (typeof id !== 'number') {\n break\n }\n const children = this.children.get(id)\n if (typeof children === 'undefined') {\n break\n }\n\n children.forEach(id => {\n queue.push(id)\n })\n\n order.push(id)\n }\n\n return order\n }\n\n getAtomSetRelations(newId: any, atoms: any) {\n // find the lowest superset in the hierarchy\n const isStrictSuperset = new Map()\n const isSubset = new Map()\n\n this.atomSets.delete(newId)\n\n this.atomSets.forEach((atomSet, id) => {\n isSubset.set(id, atomSet.isSuperset(atoms))\n isStrictSuperset.set(\n id,\n atoms.isSuperset(atomSet) && !atomSet.equals(atoms)\n )\n })\n\n const parents = Array.from(this.atomSets.keys()).filter(sgid => {\n if (!isSubset.get(sgid)) {\n return false\n }\n const childs = this.children.get(sgid)\n return childs && childs.findIndex(childId => isSubset.get(childId)) < 0\n })\n\n const children = Array.from(this.atomSets.keys()).filter(\n id =>\n isStrictSuperset.get(id) && !isStrictSuperset.get(this.parent.get(id))\n )\n\n return {\n children,\n parent: parents.length === 0 ? -1 : parents[0]\n }\n }\n\n getPathToRoot(sgid): number[] {\n const path: number[] = []\n for (let id = sgid; id >= 0; id = this.parent.get(id)) {\n path.push(id)\n }\n return path\n }\n\n insert({ id, atoms }, parent?: number, children?: number[]) {\n assert(!this.parent.has(id), 'sgid already present in the forest')\n assert(!this.children.has(id), 'sgid already present in the forest')\n\n if (!parent || !children) {\n // if these are not provided, deduce automatically\n const guess = this.getAtomSetRelations(id, new Pile(atoms))\n parent = guess.parent\n children = guess.children\n }\n\n // TODO: make children Map instead of Map?\n children.forEach(childId => {\n this.resetParentLink(childId, id)\n })\n this.children.set(\n id,\n children.filter(id => this.parent.get(id))\n )\n this.parent.set(id, parent)\n this.children.get(parent)?.push(id)\n this.atomSets.set(id, new Pile(atoms))\n\n return { parent, children }\n }\n\n private resetParentLink(childId, id) {\n const parentId = this.parent.get(childId)\n if (typeof parentId === 'undefined') {\n return\n }\n\n const childs = this.children.get(parentId)\n if (!childs) {\n return\n }\n\n const childIndex = childs.indexOf(childId)\n childs.splice(childIndex, 1)\n this.parent.set(childId, id)\n }\n\n remove(id) {\n assert(this.parent.has(id), 'sgid is not in the forest')\n assert(this.children.has(id), 'sgid is not in the forest')\n\n const parentId = this.parent.get(id) as any\n const childs = this.children.get(parentId) as any\n this.children.get(id)?.forEach(childId => {\n this.parent.set(childId, parentId)\n this.children.get(parentId)?.push(childId)\n })\n\n const i = childs.indexOf(id)\n childs.splice(i, 1)\n\n this.children.delete(id)\n this.parent.delete(id)\n this.atomSets.delete(id)\n }\n}\n\nexport function checkOverlapping(struct, atoms) {\n const sgroups = atoms.reduce((res, aid) => {\n const atom = struct.atoms.get(aid)\n return res.union(atom.sgs)\n }, new Pile())\n\n return Array.from(sgroups).some(sid => {\n const sg = struct.sgroups.get(sid)\n if (sg.type === 'DAT') return false\n const sgAtoms = SGroup.getAtoms(struct, sg)\n\n return sgAtoms.length < atoms.length\n ? sgAtoms.findIndex(aid => atoms.indexOf(aid) === -1) >= 0\n : atoms.findIndex(aid => sgAtoms.indexOf(aid) === -1) >= 0\n })\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport class Pool extends Map {\n private nextId: number = 0\n\n add(item: TValue): number {\n const id = this.nextId++\n super.set(id, item)\n return id\n }\n\n newId(): number {\n return this.nextId++\n }\n\n keyOf(item: TValue): number | null {\n for (const [key, value] of this.entries()) {\n if (value === item) return key\n }\n\n return null\n }\n\n find(predicate: (key: number, value: TValue) => boolean): number | null {\n for (const [key, value] of this.entries()) {\n if (predicate(key, value)) return key\n }\n\n return null\n }\n\n filter(predicate: (key: number, value: TValue) => boolean): Pool {\n return new Pool(\n Array.from(this).filter(([key, value]) => predicate(key, value))\n )\n }\n\n some(predicate: (value: TValue) => boolean): boolean {\n for (const value of this.values()) {\n if (predicate(value)) {\n return true\n }\n }\n\n return false\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, radicalElectrons } from './atom'\n\nimport { Bond } from './bond'\nimport { Box2Abs } from './box2Abs'\nimport { Elements } from 'domain/constants'\nimport { Fragment } from './fragment'\nimport { FunctionalGroup } from './functionalGroup'\nimport { HalfBond } from './halfBond'\nimport { Loop } from './loop'\nimport { Pile } from './pile'\nimport { Pool } from './pool'\nimport { RGroup } from './rgroup'\nimport { RxnArrow } from './rxnArrow'\nimport { RxnPlus } from './rxnPlus'\nimport { SGroup } from './sgroup'\nimport { SGroupForest } from './sgroupForest'\nimport { SimpleObject } from './simpleObject'\nimport { Text } from './text'\nimport { Vec2 } from './vec2'\n\nexport type Neighbor = {\n aid: number\n bid: number\n}\n\nfunction arrayAddIfMissing(array, item) {\n for (var i = 0; i < array.length; ++i) {\n if (array[i] === item) return false\n }\n array.push(item)\n return true\n}\n\nexport class Struct {\n atoms: Pool\n bonds: Pool\n sgroups: Pool\n halfBonds: Pool\n loops: Pool\n isReaction: boolean\n rxnArrows: Pool\n rxnPluses: Pool\n frags: Pool\n rgroups: Pool\n name: string\n sGroupForest: SGroupForest\n simpleObjects: Pool\n texts: Pool\n functionalGroups: Pool\n\n constructor() {\n this.atoms = new Pool()\n this.bonds = new Pool()\n this.sgroups = new Pool()\n this.halfBonds = new Pool()\n this.loops = new Pool()\n this.isReaction = false\n this.rxnArrows = new Pool()\n this.rxnPluses = new Pool()\n this.frags = new Pool()\n this.rgroups = new Pool()\n this.name = ''\n this.sGroupForest = new SGroupForest()\n this.simpleObjects = new Pool()\n this.texts = new Pool()\n this.functionalGroups = new Pool()\n }\n\n hasRxnProps(): boolean {\n return !!(\n this.atoms.find((_aid, atom) => atom.hasRxnProps()) ||\n this.bonds.find((_bid, bond) => bond.hasRxnProps())\n )\n }\n\n hasRxnArrow(): boolean {\n return this.rxnArrows.size === 1\n }\n\n hasRxnPluses(): boolean {\n return this.rxnPluses.size > 0\n }\n\n isRxn(): boolean {\n return this.hasRxnArrow() || this.hasRxnPluses()\n }\n\n isBlank(): boolean {\n return (\n this.atoms.size === 0 &&\n this.rxnArrows.size === 0 &&\n this.rxnPluses.size === 0 &&\n this.simpleObjects.size === 0 &&\n this.texts.size === 0\n )\n }\n\n clone(\n atomSet?: Pile | null,\n bondSet?: Pile | null,\n dropRxnSymbols?: boolean,\n aidMap?: Map | null,\n simpleObjectsSet?: Pile | null,\n textsSet?: Pile | null\n ): Struct {\n return this.mergeInto(\n new Struct(),\n atomSet,\n bondSet,\n dropRxnSymbols,\n false,\n aidMap,\n simpleObjectsSet,\n textsSet\n )\n }\n\n getScaffold(): Struct {\n const atomSet = new Pile()\n this.atoms.forEach((_atom, aid) => {\n atomSet.add(aid)\n })\n\n this.rgroups.forEach(rg => {\n rg.frags.forEach((_fnum, fid) => {\n this.atoms.forEach((atom, aid) => {\n if (atom.fragment === fid) atomSet.delete(aid)\n })\n })\n })\n\n return this.clone(atomSet)\n }\n\n getFragmentIds(fid: number): Pile {\n const atomSet = new Pile()\n\n this.atoms.forEach((atom, aid) => {\n if (atom.fragment === fid) atomSet.add(aid)\n })\n\n return atomSet\n }\n\n getFragment(fid: number): Struct {\n return this.clone(this.getFragmentIds(fid), null, true)\n }\n\n mergeInto(\n cp: Struct,\n atomSet?: Pile | null,\n bondSet?: Pile | null,\n dropRxnSymbols?: boolean,\n keepAllRGroups?: boolean,\n aidMap?: Map | null,\n simpleObjectsSet?: Pile | null,\n textsSet?: Pile | null\n ): Struct {\n atomSet = atomSet || new Pile(this.atoms.keys())\n bondSet = bondSet || new Pile(this.bonds.keys())\n simpleObjectsSet =\n simpleObjectsSet || new Pile(this.simpleObjects.keys())\n textsSet = textsSet || new Pile(this.texts.keys())\n aidMap = aidMap || new Map()\n\n bondSet = bondSet.filter(bid => {\n const bond = this.bonds.get(bid)!\n return atomSet!.has(bond.begin) && atomSet!.has(bond.end)\n })\n\n const fidMask = new Pile()\n this.atoms.forEach((atom, aid) => {\n if (atomSet!.has(aid)) fidMask.add(atom.fragment)\n })\n\n const fidMap = new Map()\n this.frags.forEach((_frag, fid) => {\n if (fidMask.has(fid)) fidMap.set(fid, cp.frags.add(null))\n })\n\n const rgroupsIds: Array = []\n this.rgroups.forEach((rgroup, rgid) => {\n let keepGroup = keepAllRGroups\n if (!keepGroup) {\n rgroup.frags.forEach((_fnum, fid) => {\n rgroupsIds.push(fid)\n if (fidMask.has(fid)) keepGroup = true\n })\n\n if (!keepGroup) return\n }\n\n const rg = cp.rgroups.get(rgid)\n if (rg) {\n rgroup.frags.forEach((_fnum, fid) => {\n rgroupsIds.push(fid)\n if (fidMask.has(fid)) rg.frags.add(fidMap.get(fid))\n })\n } else {\n cp.rgroups.set(rgid, rgroup.clone(fidMap))\n }\n })\n\n // atoms in not RGroup\n this.atoms.forEach((atom, aid) => {\n if (atomSet!.has(aid) && rgroupsIds.indexOf(atom.fragment) === -1)\n aidMap!.set(aid, cp.atoms.add(atom.clone(fidMap)))\n })\n // atoms in RGroup\n this.atoms.forEach((atom, aid) => {\n if (atomSet!.has(aid) && rgroupsIds.indexOf(atom.fragment) !== -1)\n aidMap!.set(aid, cp.atoms.add(atom.clone(fidMap)))\n })\n\n fidMap.forEach((newfid, oldfid) => {\n const fragment = this.frags.get(oldfid)\n\n // TODO: delete type check\n if (fragment && fragment instanceof Fragment) {\n cp.frags.set(newfid, this.frags.get(oldfid)!.clone(aidMap!)) // clone Fragments\n }\n })\n\n const bidMap = new Map()\n this.bonds.forEach((bond, bid) => {\n if (bondSet!.has(bid)) bidMap.set(bid, cp.bonds.add(bond.clone(aidMap!)))\n })\n\n this.sgroups.forEach(sg => {\n if (sg.atoms.some(aid => !atomSet!.has(aid))) return\n\n sg = SGroup.clone(sg, aidMap!)\n const id = cp.sgroups.add(sg)\n sg.id = id\n\n sg.atoms.forEach(aid => {\n const atom = cp.atoms.get(aid)\n if (atom) {\n atom.sgs.add(id)\n }\n })\n\n if (sg.type === 'DAT') cp.sGroupForest.insert(sg, -1, [])\n else cp.sGroupForest.insert(sg)\n })\n\n this.functionalGroups.forEach(fg => {\n fg = FunctionalGroup.clone(fg)\n cp.functionalGroups.add(fg)\n })\n\n simpleObjectsSet.forEach(soid => {\n cp.simpleObjects.add(this.simpleObjects.get(soid)!.clone())\n })\n\n textsSet.forEach(id => {\n cp.texts.add(this.texts.get(id)!.clone())\n })\n\n if (!dropRxnSymbols) {\n cp.isReaction = this.isReaction\n this.rxnArrows.forEach(item => {\n cp.rxnArrows.add(item.clone())\n })\n this.rxnPluses.forEach(item => {\n cp.rxnPluses.add(item.clone())\n })\n }\n\n cp.name = this.name\n\n return cp\n }\n\n // NB: this updates the structure without modifying the corresponding ReStruct.\n // To be applied to standalone structures only.\n prepareLoopStructure() {\n this.initHalfBonds()\n this.initNeighbors()\n this.updateHalfBonds(Array.from(this.atoms.keys()))\n this.sortNeighbors(Array.from(this.atoms.keys()))\n this.findLoops()\n }\n\n atomAddToSGroup(sgid, aid) {\n // TODO: [MK] make sure the addition does not break the hierarchy?\n SGroup.addAtom(this.sgroups.get(sgid)!, aid)\n this.atoms.get(aid)!.sgs.add(sgid)\n }\n\n calcConn(atom) {\n let conn = 0\n for (let i = 0; i < atom.neighbors.length; ++i) {\n const hb = this.halfBonds.get(atom.neighbors[i])!\n const bond = this.bonds.get(hb.bid)!\n switch (bond.type) {\n case Bond.PATTERN.TYPE.SINGLE:\n conn += 1\n break\n case Bond.PATTERN.TYPE.DOUBLE:\n conn += 2\n break\n case Bond.PATTERN.TYPE.TRIPLE:\n conn += 3\n break\n case Bond.PATTERN.TYPE.DATIVE:\n break\n case Bond.PATTERN.TYPE.HYDROGEN:\n break\n case Bond.PATTERN.TYPE.AROMATIC:\n if (atom.neighbors.length === 1) return [-1, true]\n return [atom.neighbors.length, true]\n default:\n return [-1, false]\n }\n }\n return [conn, false]\n }\n\n findBondId(begin, end) {\n return this.bonds.find(\n (_bid, bond) =>\n (bond.begin === begin && bond.end === end) ||\n (bond.begin === end && bond.end === begin)\n )\n }\n\n initNeighbors() {\n this.atoms.forEach(atom => {\n atom.neighbors = []\n })\n\n this.bonds.forEach(bond => {\n const a1 = this.atoms.get(bond.begin)!\n const a2 = this.atoms.get(bond.end)!\n a1.neighbors.push(bond.hb1!)\n a2.neighbors.push(bond.hb2!)\n })\n }\n\n bondInitHalfBonds(bid, bond?: Bond) {\n bond = bond || this.bonds.get(bid)!\n bond.hb1 = 2 * bid\n bond.hb2 = 2 * bid + 1 // eslint-disable-line no-mixed-operators\n this.halfBonds.set(bond.hb1, new HalfBond(bond.begin, bond.end, bid))\n this.halfBonds.set(bond.hb2, new HalfBond(bond.end, bond.begin, bid))\n const hb1 = this.halfBonds.get(bond.hb1)!\n const hb2 = this.halfBonds.get(bond.hb2)!\n hb1.contra = bond.hb2\n hb2.contra = bond.hb1\n }\n\n halfBondUpdate(hbid: number) {\n const hb = this.halfBonds.get(hbid)!\n const p1 = this.atoms.get(hb.begin)!.pp\n const p2 = this.atoms.get(hb.end)!.pp\n const d = Vec2.diff(p2, p1).normalized()\n hb.dir = Vec2.dist(p2, p1) > 1e-4 ? d : new Vec2(1, 0)\n hb.norm = hb.dir.turnLeft()\n hb.ang = hb.dir.oxAngle()\n if (hb.loop < 0) hb.loop = -1\n }\n\n initHalfBonds() {\n this.halfBonds.clear()\n this.bonds.forEach((bond, bid) => {\n this.bondInitHalfBonds(bid, bond)\n })\n }\n\n setHbNext(hbid, next) {\n this.halfBonds.get(this.halfBonds.get(hbid)!.contra)!.next = next\n }\n\n halfBondSetAngle(hbid, left) {\n const hb = this.halfBonds.get(hbid)!\n const hbl = this.halfBonds.get(left)!\n\n hbl.rightCos = Vec2.dot(hbl.dir, hb.dir)\n hb.leftCos = Vec2.dot(hbl.dir, hb.dir)\n\n hbl.rightSin = Vec2.cross(hbl.dir, hb.dir)\n hb.leftSin = Vec2.cross(hbl.dir, hb.dir)\n\n hb.leftNeighbor = left\n hbl.rightNeighbor = hbid\n }\n\n atomAddNeighbor(hbid) {\n const hb = this.halfBonds.get(hbid)!\n const atom = this.atoms.get(hb.begin)!\n\n for (var i = 0; i < atom.neighbors.length; ++i) {\n if (this.halfBonds.get(atom.neighbors[i])!.ang > hb.ang) break\n }\n atom.neighbors.splice(i, 0, hbid)\n var ir = atom.neighbors[(i + 1) % atom.neighbors.length]\n var il =\n atom.neighbors[(i + atom.neighbors.length - 1) % atom.neighbors.length]\n this.setHbNext(il, hbid)\n this.setHbNext(hbid, ir)\n this.halfBondSetAngle(hbid, il)\n this.halfBondSetAngle(ir, hbid)\n }\n\n atomSortNeighbors(aid) {\n const atom = this.atoms.get(aid)!\n const halfBonds = this.halfBonds\n\n atom.neighbors\n .sort((nei, nei2) => halfBonds.get(nei)!.ang - halfBonds.get(nei2)!.ang)\n .forEach((nei, i) => {\n const nextNei = atom.neighbors[(i + 1) % atom.neighbors.length]\n this.halfBonds.get(this.halfBonds.get(nei)!.contra)!.next = nextNei\n this.halfBondSetAngle(nextNei, nei)\n })\n }\n\n sortNeighbors(list) {\n if (!list) {\n this.atoms.forEach((_atom, aid) => {\n this.atomSortNeighbors(aid)\n })\n } else {\n list.forEach(aid => {\n this.atomSortNeighbors(aid)\n })\n }\n }\n\n atomUpdateHalfBonds(aid) {\n this.atoms.get(aid)!.neighbors.forEach(hbid => {\n this.halfBondUpdate(hbid)\n this.halfBondUpdate(this.halfBonds.get(hbid)!.contra)\n })\n }\n\n updateHalfBonds(list) {\n if (!list) {\n this.atoms.forEach((_atom, aid) => {\n this.atomUpdateHalfBonds(aid)\n })\n } else {\n list.forEach(aid => {\n this.atomUpdateHalfBonds(aid)\n })\n }\n }\n\n sGroupsRecalcCrossBonds() {\n this.sgroups.forEach(sg => {\n sg.xBonds = []\n sg.neiAtoms = []\n })\n\n this.bonds.forEach((bond, bid) => {\n const a1 = this.atoms.get(bond.begin)!\n const a2 = this.atoms.get(bond.end)!\n\n a1.sgs.forEach(sgid => {\n if (!a2.sgs.has(sgid)) {\n const sg = this.sgroups.get(sgid)!\n sg.xBonds.push(bid)\n arrayAddIfMissing(sg.neiAtoms, bond.end)\n }\n })\n\n a2.sgs.forEach(sgid => {\n if (!a1.sgs.has(sgid)) {\n const sg = this.sgroups.get(sgid)!\n sg.xBonds.push(bid)\n arrayAddIfMissing(sg.neiAtoms, bond.begin)\n }\n })\n })\n }\n\n sGroupDelete(sgid: number) {\n this.sgroups.get(sgid)!.atoms.forEach(atom => {\n this.atoms.get(atom)!.sgs.delete(sgid)\n })\n\n this.sGroupForest.remove(sgid)\n this.sgroups.delete(sgid)\n }\n\n atomSetPos(id: number, pp: Vec2): void {\n const item = this.atoms.get(id)!\n item.pp = pp\n }\n\n rxnPlusSetPos(id: number, pp: Vec2): void {\n const item = this.rxnPluses.get(id)!\n item.pp = pp\n }\n\n rxnArrowSetPos(id: number, pos: Array): void {\n const item = this.rxnArrows.get(id)\n if (item) {\n item.pos = pos\n }\n }\n\n simpleObjectSetPos(id: number, pos: Array) {\n const item = this.simpleObjects.get(id)!\n item.pos = pos\n }\n\n textSetPosition(id: number, position: Vec2): void {\n const item = this.texts.get(id)\n\n if (item) {\n item.position = position\n }\n }\n\n getCoordBoundingBox(atomSet?: Pile) {\n let bb: any = null\n function extend(pp) {\n if (!bb) {\n bb = {\n min: pp,\n max: pp\n }\n } else {\n if (pp instanceof Array) {\n pp.forEach(vec => {\n bb.min = Vec2.min(bb.min, vec)\n bb.max = Vec2.max(bb.max, vec)\n })\n } else {\n bb.min = Vec2.min(bb.min, pp)\n bb.max = Vec2.max(bb.max, pp)\n }\n }\n }\n\n let global = !atomSet || atomSet.size === 0\n\n this.atoms.forEach((atom, aid) => {\n if (global || atomSet!.has(aid)) extend(atom.pp)\n })\n if (global) {\n this.rxnPluses.forEach(item => {\n extend(item.pp)\n })\n this.rxnArrows.forEach(item => {\n extend(item.pos)\n })\n this.simpleObjects.forEach(item => {\n extend(item.pos)\n })\n this.texts.forEach(item => {\n extend(item.position)\n })\n }\n if (!bb && global) {\n bb = {\n min: new Vec2(0, 0),\n max: new Vec2(1, 1)\n }\n }\n return bb\n }\n\n getCoordBoundingBoxObj() {\n var bb: any = null\n function extend(pp) {\n if (!bb) {\n bb = {\n min: new Vec2(pp),\n max: new Vec2(pp)\n }\n } else {\n bb.min = Vec2.min(bb.min, pp)\n bb.max = Vec2.max(bb.max, pp)\n }\n }\n\n this.atoms.forEach(atom => {\n extend(atom.pp)\n })\n return bb\n }\n\n getBondLengthData() {\n let totalLength = 0\n let cnt = 0\n this.bonds.forEach(bond => {\n totalLength += Vec2.dist(\n this.atoms.get(bond.begin)!.pp,\n this.atoms.get(bond.end)!.pp\n )\n cnt++\n })\n return { cnt, totalLength }\n }\n\n getAvgBondLength(): number {\n const bld = this.getBondLengthData()\n return bld.cnt > 0 ? bld.totalLength / bld.cnt : -1\n }\n\n getAvgClosestAtomDistance(): number {\n var totalDist = 0\n var minDist\n var dist = 0\n var keys = Array.from(this.atoms.keys())\n var k\n var j\n for (k = 0; k < keys.length; ++k) {\n minDist = -1\n for (j = 0; j < keys.length; ++j) {\n if (j === k) continue // eslint-disable-line no-continue\n dist = Vec2.dist(\n this.atoms.get(keys[j])!.pp,\n this.atoms.get(keys[k])!.pp\n )\n if (minDist < 0 || minDist > dist) minDist = dist\n }\n totalDist += minDist\n }\n\n return keys.length > 0 ? totalDist / keys.length : -1\n }\n\n checkBondExists(begin: number, end: number): boolean {\n const key = this.bonds.find(\n (_bid, bond) =>\n (bond.begin === begin && bond.end === end) ||\n (bond.end === begin && bond.begin === end)\n )\n\n return key !== undefined\n }\n\n findConnectedComponent(firstaid: number): Pile {\n const list = [firstaid]\n const ids = new Pile()\n while (list.length > 0) {\n const aid = list.pop()!\n ids.add(aid)\n const atom = this.atoms.get(aid)!\n atom.neighbors.forEach(nei => {\n const neiId = this.halfBonds.get(nei)!.end\n if (!ids.has(neiId)) list.push(neiId)\n })\n }\n\n return ids\n }\n\n findConnectedComponents(discardExistingFragments?: boolean) {\n // NB: this is a hack\n // TODO: need to maintain half-bond and neighbor structure permanently\n if (!this.halfBonds.size) {\n this.initHalfBonds()\n this.initNeighbors()\n this.updateHalfBonds(Array.from(this.atoms.keys()))\n this.sortNeighbors(Array.from(this.atoms.keys()))\n }\n\n let addedAtoms = new Pile()\n\n const components: Array = []\n this.atoms.forEach((atom, aid) => {\n if (\n (discardExistingFragments || atom.fragment < 0) &&\n !addedAtoms.has(aid)\n ) {\n const component = this.findConnectedComponent(aid)\n components.push(component)\n addedAtoms = addedAtoms.union(component)\n }\n })\n\n return components\n }\n\n markFragment(idSet: Pile) {\n const frag = new Fragment()\n const fid = this.frags.add(frag)\n\n idSet.forEach(aid => {\n const atom = this.atoms.get(aid)!\n if (atom.stereoLabel) frag.updateStereoAtom(this, aid, fid, true)\n atom.fragment = fid\n })\n }\n\n markFragments() {\n const components = this.findConnectedComponents()\n components.forEach(comp => {\n this.markFragment(comp)\n })\n }\n\n scale(scale: number) {\n if (scale === 1) return\n\n this.atoms.forEach(atom => {\n atom.pp = atom.pp.scaled(scale)\n })\n\n this.rxnPluses.forEach(item => {\n item.pp = item.pp.scaled(scale)\n })\n\n this.rxnArrows.forEach(item => {\n item.pos = item.pos.map(p => p.scaled(scale))\n })\n\n this.sgroups.forEach(item => {\n item.pp = item.pp ? item.pp.scaled(scale) : null\n })\n }\n\n rescale() {\n let avg = this.getAvgBondLength()\n if (avg < 0 && !this.isReaction)\n // TODO [MK] this doesn't work well for reactions as the distances between\n // the atoms in different components are generally larger than those between atoms of a single component\n // (KETCHER-341)\n avg = this.getAvgClosestAtomDistance()\n if (avg < 1e-3) avg = 1\n\n const scale = 1 / avg\n this.scale(scale)\n }\n\n loopHasSelfIntersections(hbs: Array) {\n for (let i = 0; i < hbs.length; ++i) {\n const hbi = this.halfBonds.get(hbs[i])!\n const ai = this.atoms.get(hbi.begin)!.pp\n const bi = this.atoms.get(hbi.end)!.pp\n const set = new Pile([hbi.begin, hbi.end])\n\n for (let j = i + 2; j < hbs.length; ++j) {\n const hbj = this.halfBonds.get(hbs[j])!\n if (set.has(hbj.begin) || set.has(hbj.end)) continue // skip edges sharing an atom\n\n const aj = this.atoms.get(hbj.begin)!.pp\n const bj = this.atoms.get(hbj.end)!.pp\n\n if (Box2Abs.segmentIntersection(ai, bi, aj, bj)) return true\n }\n }\n\n return false\n }\n\n // partition a cycle into simple cycles\n // TODO: [MK] rewrite the detection algorithm to only find simple ones right away?\n partitionLoop(loop: any) {\n // eslint-disable-line max-statements\n const subloops: Array = []\n let continueFlag = true\n while (continueFlag) {\n const atomToHalfBond = {} // map from every atom in the loop to the index of the first half-bond starting from that atom in the uniqHb array\n continueFlag = false\n\n for (let l = 0; l < loop.length; ++l) {\n const hbid = loop[l]\n const aid1 = this.halfBonds.get(hbid)!.begin\n const aid2 = this.halfBonds.get(hbid)!.end\n if (aid2 in atomToHalfBond) {\n // subloop found\n const s = atomToHalfBond[aid2] // where the subloop begins\n const subloop = loop.slice(s, l + 1)\n subloops.push(subloop)\n if (l < loop.length)\n // remove half-bonds corresponding to the subloop\n loop.splice(s, l - s + 1)\n continueFlag = true\n break\n }\n atomToHalfBond[aid1] = l\n }\n if (!continueFlag) subloops.push(loop) // we're done, no more subloops found\n }\n return subloops\n }\n\n halfBondAngle(hbid1: number, hbid2: number): number {\n const hba = this.halfBonds.get(hbid1)!\n const hbb = this.halfBonds.get(hbid2)!\n return Math.atan2(Vec2.cross(hba.dir, hbb.dir), Vec2.dot(hba.dir, hbb.dir))\n }\n\n loopIsConvex(loop: Array): boolean {\n return loop.every((item, k, loopArr) => {\n const angle = this.halfBondAngle(item, loopArr[(k + 1) % loopArr.length])\n return angle <= 0\n })\n }\n\n // check whether a loop is on the inner or outer side of the polygon\n // by measuring the total angle between bonds\n loopIsInner(loop: Array): boolean {\n let totalAngle = 2 * Math.PI\n loop.forEach((hbida, k, loopArr) => {\n const hbidb = loopArr[(k + 1) % loopArr.length]\n const hbb = this.halfBonds.get(hbidb)!\n const angle = this.halfBondAngle(hbida, hbidb)\n totalAngle += hbb.contra === hbida ? Math.PI : angle // back and forth along the same edge\n })\n return Math.abs(totalAngle) < Math.PI\n }\n\n findLoops() {\n const newLoops: Array = []\n const bondsToMark = new Pile()\n\n /*\n Starting from each half-bond not known to be in a loop yet,\n follow the 'next' links until the initial half-bond is reached or\n the length of the sequence exceeds the number of half-bonds available.\n In a planar graph, as long as every bond is a part of some \"loop\" -\n either an outer or an inner one - every iteration either yields a loop\n or doesn't start at all. Thus this has linear complexity in the number\n of bonds for planar graphs.\n */\n\n let hbIdNext, c, loop\n this.halfBonds.forEach((hb, hbId) => {\n if (hb.loop !== -1) return\n\n for (\n hbIdNext = hbId, c = 0, loop = [];\n c <= this.halfBonds.size;\n hbIdNext = this.halfBonds.get(hbIdNext)!.next, ++c\n ) {\n if (!(c > 0 && hbIdNext === hbId)) {\n loop.push(hbIdNext)\n continue // eslint-disable-line no-continue\n }\n\n // loop found\n const subloops = this.partitionLoop(loop)\n subloops.forEach(loop => {\n let loopId\n if (this.loopIsInner(loop) && !this.loopHasSelfIntersections(loop)) {\n /*\n loop is internal\n use lowest half-bond id in the loop as the loop id\n this ensures that the loop gets the same id if it is discarded and then recreated,\n which in turn is required to enable redrawing while dragging, as actions store item id's\n */\n loopId = Math.min(...loop)\n this.loops.set(\n loopId,\n new Loop(loop, this, this.loopIsConvex(loop))\n )\n } else {\n loopId = -2\n }\n\n loop.forEach(hbid => {\n this.halfBonds.get(hbid)!.loop = loopId\n bondsToMark.add(this.halfBonds.get(hbid)!.bid)\n })\n\n if (loopId >= 0) newLoops.push(loopId)\n })\n break\n }\n })\n\n return {\n newLoops,\n bondsToMark: Array.from(bondsToMark)\n }\n }\n\n calcImplicitHydrogen(aid: number) {\n const atom = this.atoms.get(aid)!\n const [conn, isAromatic] = this.calcConn(atom)\n let correctConn = conn\n atom.badConn = false\n\n if (isAromatic) {\n if (atom.label === 'C' && atom.charge === 0) {\n if (conn === 3) {\n atom.implicitH = -radicalElectrons(atom.radical)\n return\n }\n if (conn === 2) {\n atom.implicitH = 1 - radicalElectrons(atom.radical)\n return\n }\n } else if (\n (atom.label === 'O' && atom.charge === 0) ||\n (atom.label === 'N' && atom.charge === 0 && conn === 3) ||\n (atom.label === 'N' && atom.charge === 1 && conn === 3) ||\n (atom.label === 'S' && atom.charge === 0 && conn === 3)\n ) {\n atom.implicitH = 0\n return\n } else if (!atom.hasImplicitH) {\n correctConn++\n }\n }\n\n if (correctConn < 0 || atom.isQuery()) {\n atom.implicitH = 0\n return\n }\n\n if (atom.explicitValence >= 0) {\n const elem = Elements.get(atom.label)\n atom.implicitH = !!elem\n ? atom.explicitValence - atom.calcValenceMinusHyd(correctConn)\n : 0\n if (atom.implicitH < 0) {\n atom.implicitH = 0\n atom.badConn = true\n }\n } else {\n atom.calcValence(correctConn)\n }\n }\n\n setImplicitHydrogen(list?: Array) {\n this.sgroups.forEach(item => {\n if (item.data.fieldName === 'MRV_IMPLICIT_H')\n this.atoms.get(item.atoms[0])!.hasImplicitH = true\n })\n\n if (!list) {\n this.atoms.forEach((_atom, aid) => {\n this.calcImplicitHydrogen(aid)\n })\n } else {\n list.forEach(aid => {\n if (this.atoms.get(aid)) {\n this.calcImplicitHydrogen(aid)\n }\n })\n }\n }\n\n atomGetNeighbors(aid: number): Array | undefined {\n return this.atoms.get(aid)?.neighbors.map(nei => {\n const hb = this.halfBonds.get(nei)!\n return {\n aid: hb.end,\n bid: hb.bid\n }\n })\n }\n\n getComponents() {\n // eslint-disable-line max-statements\n /* saver */\n const connectedComponents = this.findConnectedComponents(true)\n const barriers: Array = []\n let arrowPos: number | null = null\n\n this.rxnArrows.forEach(item => {\n // there's just one arrow\n arrowPos = item.center().x\n })\n\n this.rxnPluses.forEach(item => {\n barriers.push(item.pp.x)\n })\n\n if (arrowPos !== null) barriers.push(arrowPos)\n\n barriers.sort((a, b) => a - b)\n\n const components: Array = []\n\n connectedComponents.forEach(component => {\n const bb = this.getCoordBoundingBox(component)\n const c = Vec2.lc2(bb.min, 0.5, bb.max, 0.5)\n let j = 0\n\n while (c.x > barriers[j]) ++j\n\n components[j] = components[j] || new Pile()\n components[j] = components[j].union(component)\n })\n\n const submolTexts: Array = []\n const reactants: Array = []\n const products: Array = []\n\n components.forEach(component => {\n if (!component) {\n submolTexts.push('')\n return\n }\n\n const rxnFragmentType = this.defineRxnFragmentTypeForAtomset(\n component,\n arrowPos || 0\n )\n\n if (rxnFragmentType === 1) reactants.push(component)\n else products.push(component)\n })\n\n return {\n reactants,\n products\n }\n }\n\n defineRxnFragmentTypeForAtomset(atomset: Pile, arrowpos: number) {\n const bb = this.getCoordBoundingBox(atomset)\n const c = Vec2.lc2(bb.min, 0.5, bb.max, 0.5)\n return c.x < arrowpos ? 1 : 2\n }\n\n getBondFragment(bid: number) {\n const aid = this.bonds.get(bid)?.begin\n return aid && this.atoms.get(aid)?.fragment\n }\n\n bindSGroupsToFunctionalGroups() {\n this.sgroups.forEach(sgroup => {\n if (FunctionalGroup.isFunctionalGroup(sgroup)) {\n this.functionalGroups.add(new FunctionalGroup(sgroup))\n }\n })\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from './vec2'\n\n//TODO: move to infrastructure\nexport enum TextCommand {\n Bold = 'BOLD',\n Italic = 'ITALIC',\n Subscript = 'SUBSCRIPT',\n Superscript = 'SUPERSCRIPT',\n FontSize = 'CUSTOM_FONT_SIZE'\n}\n\nexport interface TextAttributes {\n //TODO: add Interface for content type\n content?: string\n position?: Vec2\n}\n\nexport class Text {\n content: string\n position: Vec2\n\n constructor(attributes?: TextAttributes) {\n this.content = attributes?.content || ''\n this.position = attributes?.position\n ? new Vec2(attributes.position)\n : new Vec2()\n }\n\n clone(): Text {\n return new Text(this)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport function ifDef(\n target: any,\n key: string,\n value: TValue,\n defaultValue?: TValue\n) {\n if (\n value !== undefined &&\n value !== null &&\n value !== defaultValue &&\n !(Array.isArray(value) && value.length === 0)\n )\n target[key] = value\n}\n","export function tfx(value: TValue): string {\n let parsedValue: number\n if (typeof value == 'number') {\n parsedValue = value\n } else {\n parsedValue = parseFloat(value)\n }\n return parsedValue.toFixed(8)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { SGroup, Struct } from 'domain/entities'\n\nimport { ifDef } from 'utilities'\n\nfunction fromRlabel(rg) {\n const res: Array = []\n let rgi\n let val\n for (rgi = 0; rgi < 32; rgi++) {\n if (rg & (1 << rgi)) {\n val = rgi + 1\n res.push(val) // push the string\n }\n }\n return res\n}\n\nexport function moleculeToKet(struct: Struct): any {\n const body: any = {\n atoms: Array.from(struct.atoms.values()).map(atom => {\n if (atom.label === 'R#') return rglabelToKet(atom)\n if (atom.label === 'L#') return atomListToKet(atom)\n return atomToKet(atom)\n })\n }\n\n if (struct.bonds.size !== 0)\n body.bonds = Array.from(struct.bonds.values()).map(bondToKet)\n\n if (struct.sgroups.size !== 0)\n body.sgroups = Array.from(struct.sgroups.values()).map(sGroup =>\n sgroupToKet(struct, sGroup)\n )\n\n const fragment = struct.frags.get(0)\n if (fragment) {\n ifDef(body, 'stereoFlagPosition', fragment.stereoFlagPosition, null)\n }\n return {\n type: 'molecule',\n ...body\n }\n}\n\nfunction atomToKet(source) {\n const result = {}\n ifDef(result, 'label', source.label)\n ifDef(result, 'alias', source.alias)\n ifDef(result, 'location', [source.pp.x, -source.pp.y, source.pp.z])\n ifDef(result, 'charge', source.charge, 0)\n ifDef(result, 'explicitValence', source.explicitValence, -1)\n ifDef(result, 'isotope', source.isotope, 0)\n ifDef(result, 'radical', source.radical, 0)\n ifDef(result, 'attachmentPoints', source.attpnt, 0)\n // stereo\n ifDef(result, 'stereoLabel', source.stereoLabel, null)\n ifDef(result, 'stereoParity', source.stereoCare, 0)\n ifDef(result, 'weight', source.weight, 0)\n // query\n ifDef(result, 'ringBondCount', source.ringBondCount, 0)\n ifDef(result, 'substitutionCount', source.substitutionCount, 0)\n ifDef(result, 'unsaturatedAtom', !!source.unsaturatedAtom, false)\n ifDef(result, 'hCount', source.hCount, 0)\n // reaction\n ifDef(result, 'mapping', parseInt(source.aam), 0)\n ifDef(result, 'invRet', source.invRet, 0)\n ifDef(result, 'exactChangeFlag', !!source.exactChangeFlag, false)\n return result\n}\n\nfunction rglabelToKet(source) {\n const result = {\n type: 'rg-label'\n }\n ifDef(result, 'location', [source.pp.x, source.pp.y, source.pp.z])\n ifDef(result, 'attachmentPoints', source.attpnt, 0)\n\n const refsToRGroups = fromRlabel(source.rglabel).map(\n rgnumber => `rg-${rgnumber}`\n )\n ifDef(result, '$refs', refsToRGroups)\n\n return result\n}\n\nfunction atomListToKet(source) {\n const result = {\n type: 'atom-list'\n }\n ifDef(result, 'location', [source.pp.x, source.pp.y, source.pp.z])\n ifDef(result, 'attachmentPoints', source.attpnt, 0)\n ifDef(result, 'elements', source.atomList.labelList())\n ifDef(result, 'notList', source.atomList.notList, false)\n return result\n}\n\nfunction bondToKet(source) {\n const result = {}\n\n ifDef(result, 'type', source.type)\n ifDef(result, 'atoms', [source.begin, source.end])\n ifDef(result, 'stereo', source.stereo, 0)\n ifDef(result, 'topology', source.topology, 0)\n ifDef(result, 'center', source.reactingCenterStatus, 0)\n\n return result\n}\n\nfunction sgroupToKet(struct, source) {\n const result = {}\n\n ifDef(result, 'type', source.type)\n ifDef(result, 'atoms', source.atoms)\n\n switch (source.type) {\n case 'GEN':\n break\n case 'MUL': {\n ifDef(result, 'mul', source.data.mul || 1)\n break\n }\n case 'SRU': {\n ifDef(result, 'subscript', source.data.subscript || 'n')\n ifDef(\n result,\n 'connectivity',\n source.data.connectivity.toUpperCase() || 'ht'\n )\n break\n }\n case 'SUP': {\n ifDef(result, 'name', source.data.name || '')\n ifDef(result, 'expanded', source.data.expanded)\n ifDef(result, 'id', source.id)\n break\n }\n case 'DAT': {\n const data = source.data\n ifDef(result, 'placement', data.absolute, true)\n ifDef(result, 'display', data.attached, false)\n ifDef(result, 'context', data.context)\n ifDef(result, 'fieldName', data.fieldName)\n ifDef(result, 'fieldData', data.fieldValue)\n ifDef(result, 'bonds', SGroup.getBonds(struct, source))\n break\n }\n default:\n break\n }\n\n return result\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, Bond, SGroup, Struct } from 'domain/entities'\n\nimport { Elements } from 'domain/constants'\nimport { ifDef } from 'utilities'\n\nexport function toRlabel(values) {\n let res = 0\n values.forEach(val => {\n const rgi = val - 1\n res |= 1 << rgi\n })\n return res\n}\n\nexport function moleculeToStruct(ketItem: any): Struct {\n const struct = new Struct()\n ketItem.atoms.forEach(atom => {\n if (atom.type === 'rg-label') struct.atoms.add(rglabelToStruct(atom))\n if (atom.type === 'atom-list') struct.atoms.add(atomListToStruct(atom))\n if (!atom.type) struct.atoms.add(atomToStruct(atom))\n })\n\n if (ketItem.bonds)\n ketItem.bonds.forEach(bond => struct.bonds.add(bondToStruct(bond)))\n\n if (ketItem.sgroups)\n ketItem.sgroups.forEach(sgroup =>\n struct.sgroups.add(sgroupToStruct(sgroup))\n )\n\n struct.initHalfBonds()\n struct.initNeighbors()\n struct.markFragments()\n struct.bindSGroupsToFunctionalGroups()\n\n return struct\n}\n\nexport function atomToStruct(source) {\n const params: any = {}\n\n ifDef(params, 'label', source.label)\n ifDef(params, 'alias', source.alias)\n ifDef(params, 'pp', {\n x: source.location[0],\n y: -source.location[1],\n z: source.location[2] || 0.0\n })\n ifDef(params, 'charge', source.charge)\n ifDef(params, 'explicitValence', source.explicitValence)\n ifDef(params, 'isotope', source.isotope)\n ifDef(params, 'radical', source.radical)\n ifDef(params, 'attpnt', source.attachmentPoints)\n // stereo\n ifDef(params, 'stereoLabel', source.stereoLabel)\n ifDef(params, 'stereoParity', source.stereoParity)\n ifDef(params, 'weight', source.weight)\n // query\n ifDef(params, 'ringBondCount', source.ringBondCount)\n ifDef(params, 'substitutionCount', source.substitutionCount)\n ifDef(params, 'unsaturatedAtom', source.unsaturatedAtom)\n ifDef(params, 'hCount', source.hCount)\n // reaction\n ifDef(params, 'aam', source.mapping)\n ifDef(params, 'invRet', source.invRet)\n ifDef(params, 'exactChangeFlag', !!source.exactChangeFlag)\n return new Atom(params)\n}\n\nexport function rglabelToStruct(source) {\n const params: any = {}\n params.label = 'R#'\n ifDef(params, 'pp', {\n x: source.location[0],\n y: source.location[1],\n z: source.location[2] || 0.0\n })\n ifDef(params, 'attpnt', source.attachmentPoints)\n const rglabel = toRlabel(source.$refs.map(el => parseInt(el.slice(3))))\n ifDef(params, 'rglabel', rglabel)\n return new Atom(params)\n}\n\nexport function atomListToStruct(source) {\n const params: any = {}\n params.label = 'L#'\n ifDef(params, 'pp', {\n x: source.location[0],\n y: source.location[1],\n z: source.location[2] || 0.0\n })\n ifDef(params, 'attpnt', source.attachmentPoints)\n const ids = source.elements\n .map(el => Elements.get(el)?.number)\n .filter(id => id)\n ifDef(params, 'atomList', {\n ids,\n notList: source.notList\n })\n return new Atom(params)\n}\n\nexport function bondToStruct(source) {\n const params: any = {}\n\n ifDef(params, 'type', source.type)\n ifDef(params, 'topology', source.topology)\n ifDef(params, 'reactingCenterStatus', source.center)\n ifDef(params, 'stereo', source.stereo)\n // if (params.stereo)\n // \tparams.stereo = params.stereo > 1 ? params.stereo * 2 : params.stereo;\n // params.xxx = 0;\n ifDef(params, 'begin', source.atoms[0])\n ifDef(params, 'end', source.atoms[1])\n\n return new Bond(params)\n}\n\nexport function sgroupToStruct(source) {\n const sgroup = new SGroup(source.type)\n ifDef(sgroup, 'atoms', source.atoms)\n switch (source.type) {\n case 'GEN':\n break\n case 'MUL': {\n ifDef(sgroup.data, 'mul', source.mul)\n break\n }\n case 'SRU': {\n ifDef(sgroup.data, 'subscript', source.subscript)\n ifDef(sgroup.data, 'connectivity', source.connectivity.toLowerCase())\n break\n }\n case 'SUP': {\n ifDef(sgroup.data, 'name', source.name)\n ifDef(sgroup.data, 'expanded', source.expanded)\n ifDef(sgroup, 'id', source.id)\n break\n }\n case 'DAT': {\n ifDef(sgroup.data, 'absolute', source.placement)\n ifDef(sgroup.data, 'attached', source.display)\n ifDef(sgroup.data, 'context', source.context)\n ifDef(sgroup.data, 'fieldName', source.fieldName)\n ifDef(sgroup.data, 'fieldValue', source.fieldData)\n break\n }\n default:\n break\n }\n return sgroup\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\nimport { Pile, Struct, Vec2, SGroup } from 'domain/entities'\n\nexport function prepareStructForKet(struct: Struct) {\n const ketNodes: any = []\n\n const rgFrags = new Set() // skip this when writing molecules\n for (const [rgnumber, rgroup] of struct.rgroups.entries()) {\n // RGroups writing\n rgroup.frags.forEach(frid => rgFrags.add(frid))\n\n const fragsAtoms = Array.from(rgroup.frags.values()).reduce(\n (res, frid) => res.union(struct.getFragmentIds(frid)),\n new Pile()\n )\n\n ketNodes.push({\n type: 'rgroup',\n fragment: struct.clone(fragsAtoms),\n center: getFragmentCenter(struct, fragsAtoms),\n data: { rgnumber, rgroup }\n })\n }\n\n Array.from(struct.frags.keys())\n .filter(fid => !rgFrags.has(fid))\n .forEach(fid => {\n const fragAtoms = struct.getFragmentIds(fid)\n ketNodes.push({\n type: 'molecule',\n fragment: struct.clone(fragAtoms),\n center: getFragmentCenter(struct, fragAtoms)\n })\n })\n\n struct.rxnArrows.forEach(item => {\n ketNodes.push({\n type: 'arrow',\n center: item.pos[0],\n data: {\n mode: item.mode,\n pos: item.pos\n }\n })\n })\n\n struct.rxnPluses.forEach(item => {\n ketNodes.push({\n type: 'plus',\n center: item.pp,\n data: {}\n })\n })\n\n struct.simpleObjects.forEach(item => {\n ketNodes.push({\n type: 'simpleObject',\n center: item.pos[0],\n data: {\n mode: item.mode,\n pos: item.pos\n }\n })\n })\n\n struct.texts.forEach(item => {\n ketNodes.push({\n type: 'text',\n center: item.position,\n data: {\n content: item.content,\n position: item.position\n }\n })\n })\n\n ketNodes.forEach(ketNode => {\n if (ketNode.fragment) {\n const sgroups: SGroup[] = Array.from(ketNode.fragment.sgroups.values())\n const filteredSGroups = sgroups.filter((sg: SGroup) =>\n sg.atoms.every(atom => atom !== undefined)\n )\n const filteredSGroupsMap = new Map()\n filteredSGroups.forEach((sg, index) => {\n filteredSGroupsMap.set(index, sg)\n })\n ketNode.fragment.sgroups = filteredSGroupsMap\n }\n })\n\n //TODO: check if this sorting operation is needed\n //return ketNodes.sort((a, b) => a.center.x - b.center.x)\n return ketNodes\n}\n\nfunction getFragmentCenter(struct, atomSet) {\n const bb = struct.getCoordBoundingBox(atomSet)\n return Vec2.centre(bb.min, bb.max)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Struct } from 'domain/entities'\nimport { ifDef } from 'utilities'\nimport { moleculeToKet } from './moleculeToKet'\n\nexport function rgroupToKet(struct: Struct, data) {\n const body = {\n rlogic: rgroupLogicToKet(data.rgnumber, data.rgroup),\n ...moleculeToKet(struct)\n }\n\n return {\n ...body,\n type: 'rgroup'\n }\n}\n\nfunction rgroupLogicToKet(rgnumber, rglogic) {\n const result = {}\n\n ifDef(result, 'number', rgnumber)\n ifDef(result, 'range', rglogic.range, '')\n ifDef(result, 'resth', rglogic.resth, false)\n ifDef(result, 'ifthen', rglogic.ifthen, 0)\n\n return result\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RGroup, Struct } from 'domain/entities'\n\nimport { ifDef } from 'utilities'\nimport { moleculeToStruct } from './moleculeToStruct'\n\nexport function rgroupToStruct(ketItem): Struct {\n const struct = moleculeToStruct(ketItem)\n const rgroup = rgroupLogicToStruct(ketItem.rlogic)\n struct.frags.forEach((_value: any, key) => {\n rgroup.frags.add(key)\n })\n if (ketItem.rlogic) struct.rgroups.set(ketItem.rlogic.number, rgroup)\n return struct\n}\n\nexport function rgroupLogicToStruct(rglogic) {\n const params = {}\n ifDef(params, 'range', rglogic.range)\n ifDef(params, 'resth', rglogic.resth)\n ifDef(params, 'ifthen', rglogic.ifthen)\n\n return new RGroup(params)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RxnArrow, RxnPlus, Struct } from 'domain/entities'\n\nexport function rxnToStruct(ketItem: any, struct: Struct): Struct {\n if (ketItem.type === 'arrow') {\n struct.rxnArrows.add(new RxnArrow(ketItem.data))\n } else {\n struct.rxnPluses.add(\n new RxnPlus({\n pp: {\n x: ketItem.location[0],\n y: ketItem.location[1],\n z: ketItem.location[2]\n }\n })\n )\n }\n return struct\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { SimpleObject, SimpleObjectMode, Struct, Vec2 } from 'domain/entities'\n\nexport function simpleObjectToStruct(ketItem: any, struct: Struct): Struct {\n const object =\n ketItem.data.mode === 'circle' ? circleToEllipse(ketItem) : ketItem.data\n struct.simpleObjects.add(new SimpleObject(object))\n return struct\n}\n\n/**\n * @deprecated TODO to remove after release 2.3\n * As circle has been migrated to ellipses here is function for converting old files data with circles to ellipse type\n * @param ketItem\n */\nfunction circleToEllipse(ketItem) {\n const radius = Vec2.dist(ketItem.data.pos[1], ketItem.data.pos[0])\n const pos0 = ketItem.data.pos[0]\n return {\n mode: SimpleObjectMode.ellipse,\n pos: [\n {\n x: pos0.x - Math.abs(radius),\n y: pos0.y - Math.abs(radius),\n z: pos0.z - Math.abs(radius)\n },\n {\n x: pos0.x + Math.abs(radius),\n y: pos0.y + Math.abs(radius),\n z: pos0.z + Math.abs(radius)\n }\n ]\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Struct, Vec2 } from 'domain/entities'\nimport { arrowToKet, plusToKet } from './toKet/rxnToKet'\n\nimport { Serializer } from '../serializers.types'\nimport { headerToKet } from './toKet/headerToKet'\nimport { moleculeToKet } from './toKet/moleculeToKet'\nimport { moleculeToStruct } from './fromKet/moleculeToStruct'\nimport { prepareStructForKet } from './toKet/prepare'\nimport { rgroupToKet } from './toKet/rgroupToKet'\nimport { rgroupToStruct } from './fromKet/rgroupToStruct'\nimport { rxnToStruct } from './fromKet/rxnToStruct'\nimport { simpleObjectToKet } from './toKet/simpleObjectToKet'\nimport { simpleObjectToStruct } from './fromKet/simpleObjectToStruct'\nimport { textToKet } from './toKet/textToKet'\nimport { textToStruct } from './fromKet/textToStruct'\nimport { validate } from './validate'\n\nfunction parseNode(node: any, struct: any) {\n const type = node.type\n switch (type) {\n case 'arrow':\n rxnToStruct(node, struct)\n break\n case 'plus':\n rxnToStruct(node, struct)\n break\n case 'simpleObject':\n simpleObjectToStruct(node, struct)\n break\n case 'molecule':\n const currentStruct = moleculeToStruct(node)\n if (node.stereoFlagPosition) {\n const fragment = currentStruct.frags.get(0)!\n fragment.stereoFlagPosition = new Vec2(node.stereoFlagPosition)\n }\n\n currentStruct.mergeInto(struct)\n break\n case 'rgroup':\n rgroupToStruct(node).mergeInto(struct)\n break\n case 'text':\n textToStruct(node, struct)\n break\n default:\n break\n }\n}\nexport class KetSerializer implements Serializer {\n deserialize(content: string): Struct {\n const resultingStruct = new Struct()\n const ket = JSON.parse(content)\n if (!validate(ket)) {\n throw new Error('Cannot deserialize input JSON.')\n }\n resultingStruct.name = ket.header ? ket.header.moleculeName : null\n const nodes = ket.root.nodes\n Object.keys(nodes).forEach(i => {\n if (nodes[i].type) parseNode(nodes[i], resultingStruct)\n else if (nodes[i].$ref) parseNode(ket[nodes[i].$ref], resultingStruct)\n })\n\n return resultingStruct\n }\n\n serialize(struct: Struct): string {\n const result: any = {\n root: {\n nodes: []\n }\n }\n\n const header = headerToKet(struct)\n if (header) result.header = header\n\n const ketNodes = prepareStructForKet(struct)\n\n let moleculeId = 0\n ketNodes.forEach(item => {\n switch (item.type) {\n case 'molecule': {\n result.root.nodes.push({ $ref: `mol${moleculeId}` })\n result[`mol${moleculeId++}`] = moleculeToKet(item.fragment)\n break\n }\n case 'rgroup': {\n result.root.nodes.push({ $ref: `rg${item.data!.rgnumber}` })\n result[`rg${item.data!.rgnumber}`] = rgroupToKet(\n item.fragment,\n item.data\n )\n break\n }\n case 'plus': {\n result.root.nodes.push(plusToKet(item))\n break\n }\n case 'arrow': {\n result.root.nodes.push(arrowToKet(item))\n break\n }\n case 'simpleObject': {\n result.root.nodes.push(simpleObjectToKet(item))\n break\n }\n case 'text': {\n result.root.nodes.push(textToKet(item))\n break\n }\n default:\n break\n }\n })\n\n return JSON.stringify(result, null, 4)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Struct, Text } from 'domain/entities'\n\nexport function textToStruct(ketItem: any, struct: Struct) {\n const object = ketItem.data\n struct.texts.add(new Text(object))\n\n return struct\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Validator } from 'jsonschema'\nimport schema from './schema.json'\n\nexport function validate(ket: any): boolean {\n const validator = new Validator()\n const result = validator.validate(ket, schema)\n return result.valid\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Struct } from 'domain/entities'\nimport { ifDef } from 'utilities'\n\nexport function headerToKet(struct: Struct): any {\n const header = {}\n\n ifDef(header, 'moleculeName', struct.name, '')\n ifDef(header, 'creatorProgram', null, '')\n ifDef(header, 'comment', null, '')\n\n return Object.keys(header).length !== 0 ? header : null\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport function arrowToKet(arrowNode) {\n return {\n type: 'arrow',\n data: arrowNode.data\n }\n}\n\nexport function plusToKet(plusNode) {\n const coord = plusNode.center\n return {\n type: 'plus',\n location: [coord.x, coord.y, coord.z],\n prop: plusNode.data\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport function simpleObjectToKet(simpleObjectNode) {\n return {\n type: 'simpleObject',\n data: simpleObjectNode.data\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport function textToKet(textNode) {\n return {\n type: 'text',\n data: textNode.data\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\nimport {\n Bond,\n RxnArrow,\n RxnPlus,\n Struct,\n Vec2,\n RGroup,\n Fragment\n} from 'domain/entities'\n\nfunction paddedNum(number, width, precision) {\n number = parseFloat(number)\n\n var numStr = number.toFixed(precision || 0).replace(',', '.') // Really need to replace?\n if (numStr.length > width) throw new Error('number does not fit')\n\n return numStr.padStart(width)\n}\n\nfunction parseDecimalInt(str) {\n /* reader */\n var val = parseInt(str, 10)\n\n return isNaN(val) ? 0 : val // eslint-disable-line\n}\n\nfunction partitionLine(\n /* string*/ str,\n /* array of int*/ parts,\n /* bool*/ withspace\n) {\n /* reader */\n var res = []\n for (var i = 0, shift = 0; i < parts.length; ++i) {\n res.push(str.slice(shift, shift + parts[i]))\n if (withspace) shift++\n shift += parts[i]\n }\n return res\n}\n\nfunction partitionLineFixed(\n /* string*/ str,\n /* int*/ itemLength,\n /* bool*/ withspace\n) {\n /* reader */\n var res = []\n for (var shift = 0; shift < str.length; shift += itemLength) {\n res.push(str.slice(shift, shift + itemLength))\n if (withspace) shift++\n }\n return res\n}\n\nvar fmtInfo = {\n bondTypeMap: {\n 1: Bond.PATTERN.TYPE.SINGLE,\n 2: Bond.PATTERN.TYPE.DOUBLE,\n 3: Bond.PATTERN.TYPE.TRIPLE,\n 4: Bond.PATTERN.TYPE.AROMATIC,\n 5: Bond.PATTERN.TYPE.SINGLE_OR_DOUBLE,\n 6: Bond.PATTERN.TYPE.SINGLE_OR_AROMATIC,\n 7: Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC,\n 8: Bond.PATTERN.TYPE.ANY,\n 9: Bond.PATTERN.TYPE.DATIVE,\n 10: Bond.PATTERN.TYPE.HYDROGEN\n },\n bondStereoMap: {\n 0: Bond.PATTERN.STEREO.NONE,\n 1: Bond.PATTERN.STEREO.UP,\n 4: Bond.PATTERN.STEREO.EITHER,\n 6: Bond.PATTERN.STEREO.DOWN,\n 3: Bond.PATTERN.STEREO.CIS_TRANS\n },\n v30bondStereoMap: {\n 0: Bond.PATTERN.STEREO.NONE,\n 1: Bond.PATTERN.STEREO.UP,\n 2: Bond.PATTERN.STEREO.EITHER,\n 3: Bond.PATTERN.STEREO.DOWN\n },\n bondTopologyMap: {\n 0: Bond.PATTERN.TOPOLOGY.EITHER,\n 1: Bond.PATTERN.TOPOLOGY.RING,\n 2: Bond.PATTERN.TOPOLOGY.CHAIN\n },\n countsLinePartition: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6],\n atomLinePartition: [10, 10, 10, 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],\n bondLinePartition: [3, 3, 3, 3, 3, 3, 3],\n atomListHeaderPartition: [3, 1, 1, 4, 1, 1],\n atomListHeaderLength: 11, // = atomListHeaderPartition.reduce(function(a,b) { return a + b; }, 0)\n atomListHeaderItemLength: 4,\n chargeMap: [0, +3, +2, +1, 0, -1, -2, -3],\n valenceMap: [undefined, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0],\n implicitHydrogenMap: [undefined, 0, 1, 2, 3, 4],\n v30atomPropMap: {\n CHG: 'charge',\n RAD: 'radical',\n MASS: 'isotope',\n VAL: 'explicitValence',\n HCOUNT: 'hCount',\n INVRET: 'invRet',\n SUBST: 'substitutionCount',\n UNSAT: 'unsaturatedAtom',\n RBCNT: 'ringBondCount'\n },\n rxnItemsPartition: [3, 3, 3]\n}\n\nvar FRAGMENT = {\n NONE: 0,\n REACTANT: 1,\n PRODUCT: 2,\n AGENT: 3\n}\n\nvar SHOULD_RESCALE_MOLECULES = true\n\nfunction rxnMerge(\n mols,\n nReactants,\n nProducts,\n nAgents,\n shouldReactionRelayout\n) /* Struct */ {\n // eslint-disable-line max-statements\n /* reader */\n var ret = new Struct()\n var bbReact = [],\n bbAgent = [],\n bbProd = []\n var molReact = [],\n molAgent = [],\n molProd = []\n var j\n var bondLengthData = { cnt: 0, totalLength: 0 }\n for (j = 0; j < mols.length; ++j) {\n var mol = mols[j]\n var bondLengthDataMol = mol.getBondLengthData()\n bondLengthData.cnt += bondLengthDataMol.cnt\n bondLengthData.totalLength += bondLengthDataMol.totalLength\n }\n if (SHOULD_RESCALE_MOLECULES) {\n var avgBondLength =\n 1 /\n (bondLengthData.cnt == 0\n ? 1\n : bondLengthData.totalLength / bondLengthData.cnt)\n for (j = 0; j < mols.length; ++j) {\n mol = mols[j]\n mol.scale(avgBondLength)\n }\n }\n\n for (j = 0; j < mols.length; ++j) {\n mol = mols[j]\n var bb = mol.getCoordBoundingBoxObj()\n if (!bb) continue // eslint-disable-line no-continue\n\n var fragmentType =\n j < nReactants\n ? FRAGMENT.REACTANT // eslint-disable-line no-nested-ternary\n : j < nReactants + nProducts\n ? FRAGMENT.PRODUCT\n : FRAGMENT.AGENT\n if (fragmentType == FRAGMENT.REACTANT) {\n bbReact.push(bb)\n molReact.push(mol)\n } else if (fragmentType == FRAGMENT.AGENT) {\n bbAgent.push(bb)\n molAgent.push(mol)\n } else if (fragmentType == FRAGMENT.PRODUCT) {\n bbProd.push(bb)\n molProd.push(mol)\n }\n\n mol.atoms.forEach(atom => {\n atom.rxnFragmentType = fragmentType\n })\n }\n\n function shiftMol(ret, mol, bb, xorig, over) {\n // eslint-disable-line max-params\n var d = new Vec2(\n xorig - bb.min.x,\n over ? 1 - bb.min.y : -(bb.min.y + bb.max.y) / 2\n )\n mol.atoms.forEach(atom => {\n atom.pp.add_(d) // eslint-disable-line no-underscore-dangle\n })\n\n mol.sgroups.forEach(item => {\n if (item.pp) item.pp.add_(d) // eslint-disable-line no-underscore-dangle\n })\n bb.min.add_(d) // eslint-disable-line no-underscore-dangle\n bb.max.add_(d) // eslint-disable-line no-underscore-dangle\n mol.mergeInto(ret)\n return bb.max.x - bb.min.x\n }\n\n if (shouldReactionRelayout) {\n // reaction fragment layout\n var xorig = 0\n for (j = 0; j < molReact.length; ++j)\n xorig += shiftMol(ret, molReact[j], bbReact[j], xorig, false) + 2.0\n xorig += 2.0\n for (j = 0; j < molAgent.length; ++j)\n xorig += shiftMol(ret, molAgent[j], bbAgent[j], xorig, true) + 2.0\n xorig += 2.0\n\n for (j = 0; j < molProd.length; ++j)\n xorig += shiftMol(ret, molProd[j], bbProd[j], xorig, false) + 2.0\n } else {\n for (j = 0; j < molReact.length; ++j) molReact[j].mergeInto(ret)\n for (j = 0; j < molAgent.length; ++j) molAgent[j].mergeInto(ret)\n for (j = 0; j < molProd.length; ++j) molProd[j].mergeInto(ret)\n }\n\n var bb1\n var bb2\n var x\n var y\n var bbReactAll = null\n var bbProdAll = null\n for (j = 0; j < bbReact.length - 1; ++j) {\n bb1 = bbReact[j]\n bb2 = bbReact[j + 1]\n\n x = (bb1.max.x + bb2.min.x) / 2\n y = (bb1.max.y + bb1.min.y + bb2.max.y + bb2.min.y) / 4\n\n ret.rxnPluses.add(new RxnPlus({ pp: new Vec2(x, y) }))\n }\n for (j = 0; j < bbReact.length; ++j) {\n if (j == 0) {\n bbReactAll = {}\n bbReactAll.max = new Vec2(bbReact[j].max)\n bbReactAll.min = new Vec2(bbReact[j].min)\n } else {\n bbReactAll.max = Vec2.max(bbReactAll.max, bbReact[j].max)\n bbReactAll.min = Vec2.min(bbReactAll.min, bbReact[j].min)\n }\n }\n for (j = 0; j < bbProd.length - 1; ++j) {\n bb1 = bbProd[j]\n bb2 = bbProd[j + 1]\n\n x = (bb1.max.x + bb2.min.x) / 2\n y = (bb1.max.y + bb1.min.y + bb2.max.y + bb2.min.y) / 4\n\n ret.rxnPluses.add(new RxnPlus({ pp: new Vec2(x, y) }))\n }\n for (j = 0; j < bbProd.length; ++j) {\n if (j == 0) {\n bbProdAll = {}\n bbProdAll.max = new Vec2(bbProd[j].max)\n bbProdAll.min = new Vec2(bbProd[j].min)\n } else {\n bbProdAll.max = Vec2.max(bbProdAll.max, bbProd[j].max)\n bbProdAll.min = Vec2.min(bbProdAll.min, bbProd[j].min)\n }\n }\n bb1 = bbReactAll\n bb2 = bbProdAll\n const defaultArrowLength = 2\n\n if (!bb1 && !bb2) {\n ret.rxnArrows.add(\n new RxnArrow({\n mode: 'open-angle',\n pos: [new Vec2(0, 0), new Vec2(defaultArrowLength, 0)]\n })\n )\n } else {\n var v1 = bb1 ? new Vec2(bb1.max.x, (bb1.max.y + bb1.min.y) / 2) : null\n var v2 = bb2 ? new Vec2(bb2.min.x, (bb2.max.y + bb2.min.y) / 2) : null\n var defaultOffset = 3\n if (!v1) v1 = new Vec2(v2.x - defaultOffset, v2.y)\n if (!v2) v2 = new Vec2(v1.x + defaultOffset, v1.y)\n const arrowCenter = Vec2.lc2(v1, 0.5, v2, 0.5)\n const arrowStart = new Vec2(\n arrowCenter.x - 0.5 * defaultArrowLength,\n arrowCenter.y,\n arrowCenter.z\n )\n const arrowEnd = new Vec2(\n arrowCenter.x + 0.5 * defaultArrowLength,\n arrowCenter.y,\n arrowCenter.z\n )\n ret.rxnArrows.add(\n new RxnArrow({\n mode: 'open-angle',\n pos: [arrowStart, arrowEnd]\n })\n )\n }\n ret.isReaction = true\n return ret\n}\n\nfunction rgMerge(scaffold, rgroups) /* Struct */ {\n /* reader */\n const ret = new Struct()\n\n scaffold.mergeInto(ret, null, null, false, true)\n\n Object.keys(rgroups).forEach(id => {\n const rgid = parseInt(id, 10)\n\n for (let j = 0; j < rgroups[rgid].length; ++j) {\n const ctab = rgroups[rgid][j]\n ctab.rgroups.set(rgid, new RGroup())\n const frag = new Fragment()\n const frid = ctab.frags.add(frag)\n ctab.rgroups.get(rgid).frags.add(frid)\n ctab.atoms.forEach(atom => {\n atom.fragment = frid\n })\n ctab.mergeInto(ret)\n }\n })\n\n return ret\n}\n\nexport default {\n fmtInfo,\n paddedNum,\n parseDecimalInt,\n partitionLine,\n partitionLineFixed,\n rxnMerge,\n rgMerge\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Pool, SGroup, Vec2 } from 'domain/entities'\n\nimport utils from './utils'\n\n/**\n * @param str { string }\n * @param valueString { boolean }\n * @returns { Pool }\n */\nfunction readKeyValuePairs(str, valueString) {\n const ret = new Pool()\n const partition = utils.partitionLineFixed(str, 3, true)\n const count = utils.parseDecimalInt(partition[0])\n\n for (let i = 0; i < count; ++i) {\n const key = utils.parseDecimalInt(partition[2 * i + 1]) - 1\n const value = valueString\n ? partition[2 * i + 2].trim()\n : utils.parseDecimalInt(partition[2 * i + 2])\n\n ret.set(key, value)\n }\n\n return ret\n}\n\n/**\n * @param str { string }\n * @param valueString { boolean }\n * @returns { Array }\n */\nfunction readKeyMultiValuePairs(str, valueString) {\n /* reader */\n var ret = []\n var partition = utils.partitionLineFixed(str, 3, true)\n var count = utils.parseDecimalInt(partition[0])\n for (var i = 0; i < count; ++i) {\n ret.push([\n /* eslint-disable no-mixed-operators*/\n utils.parseDecimalInt(partition[2 * i + 1]) - 1,\n valueString\n ? partition[2 * i + 2].trim()\n : utils.parseDecimalInt(partition[2 * i + 2])\n /* eslint-enable no-mixed-operators*/\n ])\n }\n return ret\n}\n\nfunction postLoadMul(sgroup, mol, atomMap) {\n // eslint-disable-line max-statements\n sgroup.data.mul = sgroup.data.subscript - 0\n var atomReductionMap = {}\n\n sgroup.atoms = SGroup.filterAtoms(sgroup.atoms, atomMap)\n sgroup.patoms = SGroup.filterAtoms(sgroup.patoms, atomMap)\n\n // mark repetitions for removal\n for (var k = 1; k < sgroup.data.mul; ++k) {\n for (var m = 0; m < sgroup.patoms.length; ++m) {\n var raid = sgroup.atoms[k * sgroup.patoms.length + m] // eslint-disable-line no-mixed-operators\n if (raid < 0) continue // eslint-disable-line no-continue\n if (sgroup.patoms[m] < 0) throw new Error('parent atom missing')\n atomReductionMap[raid] = sgroup.patoms[m] // \"merge\" atom in parent\n }\n }\n sgroup.patoms = SGroup.removeNegative(sgroup.patoms)\n\n var patomsMap = identityMap(sgroup.patoms)\n\n var bondsToRemove = []\n mol.bonds.forEach((bond, bid) => {\n var beginIn = bond.begin in atomReductionMap\n var endIn = bond.end in atomReductionMap\n // if both adjacent atoms of a bond are to be merged, remove it\n /* eslint-disable no-mixed-operators*/\n if (\n (beginIn && endIn) ||\n (beginIn && bond.end in patomsMap) ||\n (endIn && bond.begin in patomsMap)\n )\n bondsToRemove.push(bid)\n /* eslint-enable no-mixed-operators*/\n // if just one atom is merged, modify the bond accordingly\n else if (beginIn) bond.begin = atomReductionMap[bond.begin]\n else if (endIn) bond.end = atomReductionMap[bond.end]\n }, sgroup)\n\n // apply removal lists\n for (var b = 0; b < bondsToRemove.length; ++b)\n mol.bonds.delete(bondsToRemove[b])\n for (var a in atomReductionMap) {\n mol.atoms.delete(+a)\n atomMap[a] = -1\n }\n sgroup.atoms = sgroup.patoms\n sgroup.patoms = null\n}\n\nfunction postLoadSru(sgroup) {\n sgroup.data.connectivity = (sgroup.data.connectivity || 'EU')\n .trim()\n .toLowerCase()\n}\n\nfunction postLoadSup(sgroup) {\n sgroup.data.name = (sgroup.data.subscript || '').trim()\n sgroup.data.subscript = ''\n}\n\nfunction postLoadGen(sgroup, mol, atomMap) {\n // eslint-disable-line no-unused-vars\n}\n\nfunction postLoadDat(sgroup, mol) {\n if (!sgroup.data.absolute)\n sgroup.pp = sgroup.pp.add(SGroup.getMassCentre(mol, sgroup.atoms))\n}\n\nfunction postLoadMon(sgroup) {\n // TODO: Implement after adding MON type support\n}\n\nfunction postLoadMer(sgroup) {\n // TODO: Implement after adding MER type support\n}\n\nfunction postLoadCop(sgroup) {\n // TODO: Implement after adding COP type support\n}\n\nfunction postLoadCro(sgroup) {\n // TODO: Implement after adding CRO type support\n}\n\nfunction postLoadMod(sgroup) {\n // TODO: Implement after adding MOD type support\n}\n\nfunction postLoadGra(sgroup) {\n // TODO: Implement after adding GRA type support\n}\n\nfunction postLoadCom(sgroup) {\n // TODO: Implement after adding COM type support\n}\n\nfunction postLoadMix(sgroup) {\n // TODO: Implement after adding MIX type support\n}\n\nfunction postLoadFor(sgroup) {\n // TODO: Implement after adding FOR type support\n}\n\nfunction postLoadAny(sgroup) {\n // TODO: Implement after adding ANY type support\n}\n\nfunction loadSGroup(mol, sg, atomMap) {\n const postLoadMap = {\n SUP: postLoadSup,\n MUL: postLoadMul,\n SRU: postLoadSru,\n MON: postLoadMon,\n MER: postLoadMer,\n COP: postLoadCop,\n CRO: postLoadCro,\n MOD: postLoadMod,\n GRA: postLoadGra,\n COM: postLoadCom,\n MIX: postLoadMix,\n FOR: postLoadFor,\n DAT: postLoadDat,\n ANY: postLoadAny,\n GEN: postLoadGen\n }\n\n // add the group to the molecule\n sg.id = mol.sgroups.add(sg)\n\n // apply type-specific post-processing\n postLoadMap[sg.type](sg, mol, atomMap)\n // mark atoms in the group as belonging to it\n for (let s = 0; s < sg.atoms.length; ++s) {\n if (mol.atoms.has(sg.atoms[s])) mol.atoms.get(sg.atoms[s]).sgs.add(sg.id)\n }\n\n if (sg.type === 'DAT') mol.sGroupForest.insert(sg, -1, [])\n else mol.sGroupForest.insert(sg)\n\n return sg.id\n}\n\nfunction initSGroup(sGroups, propData) {\n /* reader */\n const kv = readKeyValuePairs(propData, true)\n for (const [key, type] of kv) {\n const sg = new SGroup(type)\n sg.number = key\n sGroups[key] = sg\n }\n}\n\nfunction applySGroupProp(sGroups, propName, propData, numeric, core) {\n // eslint-disable-line max-params\n const kv = readKeyValuePairs(propData, !numeric)\n // \"core\" properties are stored directly in an sgroup, not in sgroup.data\n for (const key of kv.keys())\n (core ? sGroups[key] : sGroups[key].data)[propName] = kv.get(key)\n}\n\nfunction applySGroupArrayProp(sGroups, propName, propData, shift) {\n /* reader */\n const sid = utils.parseDecimalInt(propData.slice(1, 4)) - 1\n const num = utils.parseDecimalInt(propData.slice(4, 8))\n let part = toIntArray(utils.partitionLineFixed(propData.slice(8), 3, true))\n\n if (part.length !== num) throw new Error('File format invalid')\n if (shift) part = part.map(v => v + shift)\n\n sGroups[sid][propName] = sGroups[sid][propName].concat(part)\n}\n\nfunction applyDataSGroupName(sg, name) {\n /* reader */\n sg.data.fieldName = name\n}\n\nfunction applyDataSGroupExpand(sg, expanded) {\n sg.data.expanded = expanded\n}\n\nfunction applyDataSGroupQuery(sg, query) {\n /* reader */\n sg.data.query = query\n}\n\nfunction applyDataSGroupQueryOp(sg, queryOp) {\n /* reader */\n sg.data.queryOp = queryOp\n}\n\nfunction applyDataSGroupDesc(sGroups, propData) {\n /* reader */\n var split = utils.partitionLine(propData, [4, 31, 2, 20, 2, 3], false)\n var id = utils.parseDecimalInt(split[0]) - 1\n var fieldName = split[1].trim()\n var fieldType = split[2].trim()\n var units = split[3].trim()\n var query = split[4].trim()\n var queryOp = split[5].trim()\n var sGroup = sGroups[id]\n sGroup.data.fieldType = fieldType\n sGroup.data.fieldName = fieldName\n sGroup.data.units = units\n sGroup.data.query = query\n sGroup.data.queryOp = queryOp\n}\n\nfunction applyDataSGroupInfo(sg, propData) {\n // eslint-disable-line max-statements\n /* reader */\n var split = utils.partitionLine(\n propData,\n [\n 10 /* x.x*/, 10 /* y.y*/, 4 /* eee*/, 1 /* f*/, 1 /* g*/, 1 /* h*/,\n 3 /* i */, 3 /* jjj*/, 3 /* kkk*/, 3 /* ll*/, 2 /* m*/, 3 /* n*/,\n 2 /* oo*/\n ],\n false\n )\n\n var x = parseFloat(split[0])\n var y = parseFloat(split[1])\n var attached = split[3].trim() == 'A'\n var absolute = split[4].trim() == 'A'\n var showUnits = split[5].trim() == 'U'\n var nCharsToDisplay = split[7].trim()\n nCharsToDisplay =\n nCharsToDisplay == 'ALL' ? -1 : utils.parseDecimalInt(nCharsToDisplay)\n var tagChar = split[10].trim()\n var daspPos = utils.parseDecimalInt(split[11].trim())\n\n sg.pp = new Vec2(x, -y)\n sg.data.attached = attached\n sg.data.absolute = absolute\n sg.data.showUnits = showUnits\n sg.data.nCharsToDisplay = nCharsToDisplay\n sg.data.tagChar = tagChar\n sg.data.daspPos = daspPos\n}\n\nfunction applyDataSGroupInfoLine(sGroups, propData) {\n /* reader */\n var id = utils.parseDecimalInt(propData.substr(0, 4)) - 1\n var sg = sGroups[id]\n applyDataSGroupInfo(sg, propData.substr(5))\n}\n\nfunction applyDataSGroupData(sg, data, finalize) {\n /* reader */\n sg.data.fieldValue = (sg.data.fieldValue || '') + data\n if (finalize) {\n sg.data.fieldValue = trimRight(sg.data.fieldValue)\n if (sg.data.fieldValue.startsWith('\"') && sg.data.fieldValue.endsWith('\"'))\n sg.data.fieldValue = sg.data.fieldValue.substr(\n 1,\n sg.data.fieldValue.length - 2\n )\n }\n}\n\nfunction applyDataSGroupDataLine(sGroups, propData, finalize) {\n /* reader */\n var id = utils.parseDecimalInt(propData.substr(0, 5)) - 1\n var data = propData.substr(5)\n var sg = sGroups[id]\n applyDataSGroupData(sg, data, finalize)\n}\n\n// Utilities functions\nfunction toIntArray(strArray) {\n /* reader */\n var ret = []\n for (var j = 0; j < strArray.length; ++j)\n ret[j] = utils.parseDecimalInt(strArray[j])\n return ret\n}\n\nfunction trimRight(str) {\n return str.replace(/\\s+$/, '')\n}\n\nfunction identityMap(array) {\n var map = {}\n for (var i = 0; i < array.length; ++i) map[array[i]] = array[i]\n return map\n}\n\nexport default {\n readKeyValuePairs,\n readKeyMultiValuePairs,\n loadSGroup,\n initSGroup,\n applySGroupProp,\n applySGroupArrayProp,\n applyDataSGroupName,\n applyDataSGroupQuery,\n applyDataSGroupQueryOp,\n applyDataSGroupDesc,\n applyDataSGroupInfo,\n applyDataSGroupData,\n applyDataSGroupInfoLine,\n applyDataSGroupDataLine,\n applyDataSGroupExpand\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\n/* eslint-disable guard-for-in */ // todo\n\nimport {\n Atom,\n AtomList,\n Bond,\n Pool,\n RGroup,\n SGroup,\n StereoLabel,\n Struct,\n Vec2\n} from 'domain/entities'\n\nimport { Elements } from 'domain/constants'\nimport sGroup from './parseSGroup'\nimport utils from './utils'\n\nconst loadRGroupFragments = true // TODO: set to load the fragments\n\nfunction parseAtomLine(atomLine) {\n /* reader */\n var atomSplit = utils.partitionLine(atomLine, utils.fmtInfo.atomLinePartition)\n var params = {\n // generic\n pp: new Vec2(\n parseFloat(atomSplit[0]),\n -parseFloat(atomSplit[1]),\n parseFloat(atomSplit[2])\n ),\n label: atomSplit[4].trim(),\n explicitValence:\n utils.fmtInfo.valenceMap[utils.parseDecimalInt(atomSplit[10])],\n\n // obsolete\n massDifference: utils.parseDecimalInt(atomSplit[5]),\n charge: utils.fmtInfo.chargeMap[utils.parseDecimalInt(atomSplit[6])],\n\n // query\n hCount: utils.parseDecimalInt(utils.parseDecimalInt(atomSplit[8])),\n stereoCare: utils.parseDecimalInt(atomSplit[9]) !== 0,\n\n // reaction\n aam: utils.parseDecimalInt(atomSplit[14]),\n invRet: utils.parseDecimalInt(atomSplit[15]),\n\n // reaction query\n exactChangeFlag: utils.parseDecimalInt(atomSplit[16]) !== 0\n }\n return new Atom(params)\n}\n\nfunction parseBondLine(bondLine) {\n /* reader */\n var bondSplit = utils.partitionLine(bondLine, utils.fmtInfo.bondLinePartition)\n\n var params = {\n begin: utils.parseDecimalInt(bondSplit[0]) - 1,\n end: utils.parseDecimalInt(bondSplit[1]) - 1,\n type: utils.fmtInfo.bondTypeMap[utils.parseDecimalInt(bondSplit[2])],\n stereo: utils.fmtInfo.bondStereoMap[utils.parseDecimalInt(bondSplit[3])],\n xxx: bondSplit[4],\n topology:\n utils.fmtInfo.bondTopologyMap[utils.parseDecimalInt(bondSplit[5])],\n reactingCenterStatus: utils.parseDecimalInt(bondSplit[6])\n }\n\n return new Bond(params)\n}\n\nfunction parseAtomListLine(/* string */ atomListLine) {\n /* reader */\n var split = utils.partitionLine(\n atomListLine,\n utils.fmtInfo.atomListHeaderPartition\n )\n\n var number = utils.parseDecimalInt(split[0]) - 1\n var notList = split[2].trim() === 'T'\n var count = utils.parseDecimalInt(split[4].trim())\n\n var ids = atomListLine.slice(utils.fmtInfo.atomListHeaderLength)\n var list = []\n var itemLength = utils.fmtInfo.atomListHeaderItemLength\n for (var i = 0; i < count; ++i)\n list[i] = utils.parseDecimalInt(\n ids.slice(i * itemLength, (i + 1) * itemLength - 1)\n )\n\n return {\n aid: number,\n atomList: new AtomList({\n notList,\n ids: list\n })\n }\n}\n\n/**\n * @param ctab\n * @param ctabLines\n * @param shift\n * @param end\n * @param sGroups\n * @param rLogic\n * @returns { Pool }\n */\nfunction parsePropertyLines(ctab, ctabLines, shift, end, sGroups, rLogic) {\n // eslint-disable-line max-statements, max-params\n /* reader */\n const props = new Pool()\n\n while (shift < end) {\n var line = ctabLines[shift]\n if (line.charAt(0) === 'A') {\n var propValue = ctabLines[++shift]\n //TODO: Atom entity only have pseudo getter. Check during refactoring\n //this type of pseudo labeling is not used in current BIOVIA products. See ctab documentation 2020\n // https://discover.3ds.com/sites/default/files/2020-08/biovia_ctfileformats_2020.pdf (page 47)\n var isPseudo = /'.+'/.test(propValue)\n if (isPseudo && !props.get('pseudo')) props.set('pseudo', new Pool())\n if (!isPseudo && !props.get('alias')) props.set('alias', new Pool())\n if (isPseudo) propValue = propValue.replace(/'/g, '')\n props\n .get(isPseudo ? 'pseudo' : 'alias')\n .set(utils.parseDecimalInt(line.slice(3, 6)) - 1, propValue)\n } else if (line.charAt(0) === 'M') {\n var type = line.slice(3, 6)\n var propertyData = line.slice(6)\n if (type === 'END') {\n break\n } else if (type === 'CHG') {\n if (!props.get('charge'))\n props.set('charge', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'RAD') {\n if (!props.get('radical'))\n props.set('radical', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'ISO') {\n if (!props.get('isotope'))\n props.set('isotope', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'RBC') {\n if (!props.get('ringBondCount'))\n props.set('ringBondCount', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'SUB') {\n if (!props.get('substitutionCount'))\n props.set('substitutionCount', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'UNS') {\n if (!props.get('unsaturatedAtom'))\n props.set('unsaturatedAtom', sGroup.readKeyValuePairs(propertyData))\n // else if (type == \"LIN\") // link atom\n } else if (type === 'RGP') {\n // rgroup atom\n if (!props.get('rglabel')) props.set('rglabel', new Pool())\n var rglabels = props.get('rglabel')\n var a2rs = sGroup.readKeyMultiValuePairs(propertyData)\n for (var a2ri = 0; a2ri < a2rs.length; a2ri++) {\n var a2r = a2rs[a2ri]\n rglabels.set(\n a2r[0],\n (rglabels.get(a2r[0]) || 0) | (1 << (a2r[1] - 1))\n )\n }\n } else if (type === 'LOG') {\n // rgroup atom\n propertyData = propertyData.slice(4)\n var rgid = utils.parseDecimalInt(propertyData.slice(0, 3).trim())\n var iii = utils.parseDecimalInt(propertyData.slice(4, 7).trim())\n var hhh = utils.parseDecimalInt(propertyData.slice(8, 11).trim())\n var ooo = propertyData.slice(12).trim()\n var logic = {}\n if (iii > 0) logic.ifthen = iii\n logic.resth = hhh === 1\n logic.range = ooo\n rLogic[rgid] = logic\n } else if (type === 'APO') {\n if (!props.get('attpnt'))\n props.set('attpnt', sGroup.readKeyValuePairs(propertyData))\n } else if (type === 'ALS') {\n // atom list\n const pool = parsePropertyLineAtomList(\n utils.partitionLine(propertyData, [1, 3, 3, 1, 1, 1]),\n utils.partitionLineFixed(propertyData.slice(10), 4, false)\n )\n\n if (!props.get('atomList')) props.set('atomList', new Pool())\n if (!props.get('label')) props.set('label', new Pool())\n\n pool.forEach((atomList, aid) => {\n props.get('label').set(aid, 'L#')\n props.get('atomList').set(aid, atomList)\n })\n } else if (type === 'STY') {\n // introduce s-group\n sGroup.initSGroup(sGroups, propertyData)\n } else if (type === 'SST') {\n sGroup.applySGroupProp(sGroups, 'subtype', propertyData)\n } else if (type === 'SLB') {\n sGroup.applySGroupProp(sGroups, 'label', propertyData, true)\n } else if (type === 'SPL') {\n sGroup.applySGroupProp(sGroups, 'parent', propertyData, true, true)\n } else if (type === 'SCN') {\n sGroup.applySGroupProp(sGroups, 'connectivity', propertyData)\n } else if (type === 'SAL') {\n sGroup.applySGroupArrayProp(sGroups, 'atoms', propertyData, -1)\n } else if (type === 'SBL') {\n sGroup.applySGroupArrayProp(sGroups, 'bonds', propertyData, -1)\n } else if (type === 'SPA') {\n sGroup.applySGroupArrayProp(sGroups, 'patoms', propertyData, -1)\n } else if (type === 'SMT') {\n var sid = utils.parseDecimalInt(propertyData.slice(0, 4)) - 1\n sGroups[sid].data.subscript = propertyData.slice(4).trim()\n } else if (type === 'SDT') {\n sGroup.applyDataSGroupDesc(sGroups, propertyData)\n } else if (type === 'SDD') {\n sGroup.applyDataSGroupInfoLine(sGroups, propertyData)\n } else if (type === 'SCD') {\n sGroup.applyDataSGroupDataLine(sGroups, propertyData, false)\n } else if (type === 'SED') {\n sGroup.applyDataSGroupDataLine(sGroups, propertyData, true)\n } else if (type === 'SDS') {\n const expandedSGroups = propertyData.slice(7).trim().split(' ')\n expandedSGroups.forEach(eg => {\n const sGroupId = Number(eg) - 1\n sGroups[sGroupId].data.expanded = true\n })\n }\n }\n ++shift\n }\n return props\n}\n\n/**\n * @param atoms { Pool }\n * @param values { Pool }\n * @param propId { string }\n */\nfunction applyAtomProp(atoms, values, propId) {\n /* reader */\n values.forEach((propVal, aid) => {\n atoms.get(aid)[propId] = propVal\n })\n}\n\nfunction parseCTabV2000(ctabLines, countsSplit) {\n // eslint-disable-line max-statements\n /* reader */\n const ctab = new Struct()\n let i\n const atomCount = utils.parseDecimalInt(countsSplit[0])\n const bondCount = utils.parseDecimalInt(countsSplit[1])\n const atomListCount = utils.parseDecimalInt(countsSplit[2])\n const isAbs = utils.parseDecimalInt(countsSplit[4]) === 1\n const isAnd = utils.parseDecimalInt(countsSplit[4]) === 0\n const stextLinesCount = utils.parseDecimalInt(countsSplit[5])\n const propertyLinesCount = utils.parseDecimalInt(countsSplit[10])\n let shift = 0\n const atomLines = ctabLines.slice(shift, shift + atomCount)\n shift += atomCount\n const bondLines = ctabLines.slice(shift, shift + bondCount)\n shift += bondCount\n const atomListLines = ctabLines.slice(shift, shift + atomListCount)\n shift += atomListCount + stextLinesCount\n\n const atoms = atomLines.map(parseAtomLine)\n atoms.forEach(atom => ctab.atoms.add(atom))\n\n const bonds = bondLines.map(parseBondLine)\n bonds.forEach(bond => {\n if (bond.stereo && isAbs)\n ctab.atoms.get(bond.begin).stereoLabel = StereoLabel.Abs\n if (bond.stereo && isAnd)\n ctab.atoms.get(bond.begin).stereoLabel = `${StereoLabel.And}1`\n ctab.bonds.add(bond)\n })\n\n const atomLists = atomListLines.map(parseAtomListLine)\n atomLists.forEach(pair => {\n ctab.atoms.get(pair.aid).atomList = pair.atomList\n ctab.atoms.get(pair.aid).label = 'L#'\n })\n\n const sGroups = {}\n const rLogic = {}\n const props = parsePropertyLines(\n ctab,\n ctabLines,\n shift,\n Math.min(ctabLines.length, shift + propertyLinesCount),\n sGroups,\n rLogic\n )\n props.forEach((values, propId) => {\n applyAtomProp(ctab.atoms, values, propId)\n })\n\n const atomMap = {}\n let sid\n for (sid in sGroups) {\n const sg = sGroups[sid]\n if (sg.type === 'DAT' && sg.atoms.length === 0) {\n const parent = sGroups[sid].parent\n if (parent >= 0) {\n const psg = sGroups[parent - 1]\n if (psg.type === 'GEN') sg.atoms = [].slice.call(psg.atoms)\n }\n }\n }\n for (sid in sGroups) sGroup.loadSGroup(ctab, sGroups[sid], atomMap)\n const emptyGroups = []\n for (sid in sGroups) {\n // TODO: why do we need that?\n SGroup.filter(ctab, sGroups[sid], atomMap)\n if (sGroups[sid].atoms.length === 0 && !sGroups[sid].allAtoms)\n emptyGroups.push(+sid)\n }\n for (i = 0; i < emptyGroups.length; ++i) {\n ctab.sGroupForest.remove(emptyGroups[i])\n ctab.sgroups.delete(emptyGroups[i])\n }\n for (const id in rLogic) {\n const rgid = parseInt(id, 10)\n ctab.rgroups.set(rgid, new RGroup(rLogic[rgid]))\n }\n return ctab\n}\n\nfunction parseRg2000(/* string[] */ ctabLines) /* Struct */ {\n // eslint-disable-line max-statements\n ctabLines = ctabLines.slice(7)\n if (ctabLines[0].trim() !== '$CTAB') throw new Error('RGFile format invalid')\n var i = 1\n while (ctabLines[i].charAt(0) !== '$') i++\n if (ctabLines[i].trim() !== '$END CTAB')\n throw new Error('RGFile format invalid')\n var coreLines = ctabLines.slice(1, i)\n ctabLines = ctabLines.slice(i + 1)\n var fragmentLines = {}\n while (true) {\n // eslint-disable-line no-constant-condition\n if (ctabLines.length === 0) throw new Error('Unexpected end of file')\n var line = ctabLines[0].trim()\n if (line === '$END MOL') {\n ctabLines = ctabLines.slice(1)\n break\n }\n if (line !== '$RGP') throw new Error('RGFile format invalid')\n\n const rgid = parseInt(ctabLines[1].trim(), 10)\n fragmentLines[rgid] = []\n ctabLines = ctabLines.slice(2)\n while (true) {\n // eslint-disable-line no-constant-condition\n if (ctabLines.length === 0) throw new Error('Unexpected end of file')\n line = ctabLines[0].trim()\n if (line === '$END RGP') {\n ctabLines = ctabLines.slice(1)\n break\n }\n if (line !== '$CTAB') throw new Error('RGFile format invalid')\n i = 1\n while (ctabLines[i].charAt(0) !== '$') i++\n if (ctabLines[i].trim() !== '$END CTAB')\n throw new Error('RGFile format invalid')\n fragmentLines[rgid].push(ctabLines.slice(1, i))\n ctabLines = ctabLines.slice(i + 1)\n }\n }\n\n var core = parseCTab(coreLines)\n var frag = {}\n if (loadRGroupFragments) {\n for (var strId in fragmentLines) {\n const id = parseInt(strId, 10)\n frag[id] = []\n for (var j = 0; j < fragmentLines[id].length; ++j)\n frag[id].push(parseCTab(fragmentLines[id][j]))\n }\n }\n return utils.rgMerge(core, frag)\n}\n\nfunction parseRxn2000(\n /* string[] */ ctabLines,\n shouldReactionRelayout\n) /* Struct */ {\n // eslint-disable-line max-statements\n /* reader */\n ctabLines = ctabLines.slice(4)\n var countsSplit = utils.partitionLine(\n ctabLines[0],\n utils.fmtInfo.rxnItemsPartition\n )\n var nReactants = countsSplit[0] - 0,\n nProducts = countsSplit[1] - 0,\n nAgents = countsSplit[2] - 0\n ctabLines = ctabLines.slice(1) // consume counts line\n var mols = []\n while (ctabLines.length > 0 && ctabLines[0].substr(0, 4) === '$MOL') {\n ctabLines = ctabLines.slice(1)\n var n = 0\n while (n < ctabLines.length && ctabLines[n].substr(0, 4) !== '$MOL') n++\n\n var lines = ctabLines.slice(0, n)\n var struct\n if (lines[0].search('\\\\$MDL') === 0) {\n struct = parseRg2000(lines)\n } else {\n struct = parseCTab(lines.slice(3))\n struct.name = lines[0].trim()\n }\n mols.push(struct)\n ctabLines = ctabLines.slice(n)\n }\n return utils.rxnMerge(\n mols,\n nReactants,\n nProducts,\n nAgents,\n shouldReactionRelayout\n )\n}\n\nfunction parseCTab(/* string */ ctabLines) /* Struct */ {\n /* reader */\n var countsSplit = utils.partitionLine(\n ctabLines[0],\n utils.fmtInfo.countsLinePartition\n )\n ctabLines = ctabLines.slice(1)\n return parseCTabV2000(ctabLines, countsSplit)\n}\n\nfunction labelsListToIds(labels) {\n /* reader */\n var ids = []\n for (var i = 0; i < labels.length; ++i) {\n const element = Elements.get(labels[i].trim())\n if (element) {\n ids.push(element.number)\n }\n }\n\n return ids\n}\n\n/**\n * @param hdr\n * @param lst\n * @returns { Pool }\n */\nfunction parsePropertyLineAtomList(hdr, lst) {\n /* reader */\n var aid = utils.parseDecimalInt(hdr[1]) - 1\n var count = utils.parseDecimalInt(hdr[2])\n var notList = hdr[4].trim() === 'T'\n var ids = labelsListToIds(lst.slice(0, count))\n var ret = new Pool()\n ret.set(\n aid,\n new AtomList({\n notList,\n ids\n })\n )\n return ret\n}\n\nexport default {\n parseCTabV2000,\n parseRg2000,\n parseRxn2000\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Atom,\n AtomList,\n Bond,\n RGroup,\n SGroup,\n Struct,\n Vec2\n} from 'domain/entities'\n\nimport { Elements } from 'domain/constants'\nimport sGroup from './parseSGroup'\nimport utils from './utils'\n\nfunction parseAtomLineV3000(line) {\n // eslint-disable-line max-statements\n /* reader */\n var split, subsplit, key, value, i\n split = spacebarsplit(line)\n var params = {\n pp: new Vec2(\n parseFloat(split[2]),\n -parseFloat(split[3]),\n parseFloat(split[4])\n ),\n aam: split[5].trim()\n }\n var label = split[1].trim()\n if (label.charAt(0) == '\"' && label.charAt(label.length - 1) == '\"')\n label = label.substr(1, label.length - 2) // strip qutation marks\n if (label.charAt(label.length - 1) == ']') {\n // assume atom list\n label = label.substr(0, label.length - 1) // remove ']'\n var atomListParams = {}\n atomListParams.notList = false\n const matchNotListInfo = label.match(/NOT ?\\[/)\n if (matchNotListInfo) {\n atomListParams.notList = true\n const [matchedSubstr] = matchNotListInfo\n label = label.substr(matchedSubstr.length) // remove 'NOT [' or 'NOT['\n } else if (label.charAt(0) != '[') {\n throw new Error(\"Error: atom list expected, found '\" + label + \"'\")\n } else {\n label = label.substr(1) // remove '['\n }\n atomListParams.ids = labelsListToIds(label.split(','))\n params['atomList'] = new AtomList(atomListParams)\n params['label'] = 'L#'\n } else {\n params['label'] = label\n }\n split.splice(0, 6)\n for (i = 0; i < split.length; ++i) {\n subsplit = splitonce(split[i], '=')\n key = subsplit[0]\n value = subsplit[1]\n if (key in utils.fmtInfo.v30atomPropMap) {\n var ival = utils.parseDecimalInt(value)\n if (key == 'VAL') {\n if (ival == 0) continue // eslint-disable-line no-continue\n if (ival == -1) ival = 0\n }\n params[utils.fmtInfo.v30atomPropMap[key]] = ival\n } else if (key == 'RGROUPS') {\n value = value.trim().substr(1, value.length - 2)\n var rgrsplit = value.split(' ').slice(1)\n params.rglabel = 0\n for (var j = 0; j < rgrsplit.length; ++j)\n params.rglabel |= 1 << (rgrsplit[j] - 1)\n } else if (key == 'ATTCHPT') {\n params.attpnt = value.trim() - 0\n }\n }\n\n return new Atom(params)\n}\n\nfunction parseBondLineV3000(line) {\n /* reader */\n var split, subsplit, key, value, i\n split = spacebarsplit(line)\n var params = {\n begin: utils.parseDecimalInt(split[2]) - 1,\n end: utils.parseDecimalInt(split[3]) - 1,\n type: utils.fmtInfo.bondTypeMap[utils.parseDecimalInt(split[1])]\n }\n split.splice(0, 4)\n for (i = 0; i < split.length; ++i) {\n subsplit = splitonce(split[i], '=')\n key = subsplit[0]\n value = subsplit[1]\n if (key == 'CFG') {\n params.stereo =\n utils.fmtInfo.v30bondStereoMap[utils.parseDecimalInt(value)]\n if (\n params.type == Bond.PATTERN.TYPE.DOUBLE &&\n params.stereo == Bond.PATTERN.STEREO.EITHER\n )\n params.stereo = Bond.PATTERN.STEREO.CIS_TRANS\n } else if (key == 'TOPO') {\n params.topology =\n utils.fmtInfo.bondTopologyMap[utils.parseDecimalInt(value)]\n } else if (key == 'RXCTR') {\n params.reactingCenterStatus = utils.parseDecimalInt(value)\n } else if (key == 'STBOX') {\n params.stereoCare = utils.parseDecimalInt(value)\n }\n }\n return new Bond(params)\n}\n\nfunction v3000parseCollection(ctab, ctabLines, shift) {\n /* reader */\n shift++\n while (ctabLines[shift].trim() != 'M V30 END COLLECTION') shift++\n shift++\n return shift\n}\n\nfunction v3000parseSGroup(ctab, ctabLines, sgroups, atomMap, shift) {\n // eslint-disable-line max-params, max-statements\n /* reader */\n var line = ''\n shift++\n while (shift < ctabLines.length) {\n line = stripV30(ctabLines[shift++]).trim()\n if (line.trim() == 'END SGROUP') return shift\n while (line.charAt(line.length - 1) == '-')\n line = (\n line.substr(0, line.length - 1) + stripV30(ctabLines[shift++])\n ).trim()\n var split = splitSGroupDef(line)\n var type = split[1]\n var sg = new SGroup(type)\n sg.number = split[0] - 0\n sg.type = type\n sg.label = split[2] - 0\n sgroups[sg.number] = sg\n var props = {}\n for (var i = 3; i < split.length; ++i) {\n var subsplit = splitonce(split[i], '=')\n if (subsplit.length != 2)\n throw new Error(\n \"A record of form AAA=BBB or AAA=(...) expected, got '\" +\n split[i] +\n \"'\"\n )\n var name = subsplit[0]\n if (!(name in props)) props[name] = []\n props[name].push(subsplit[1])\n }\n sg.atoms = parseBracedNumberList(props['ATOMS'][0], -1)\n if (props['PATOMS'])\n sg.patoms = parseBracedNumberList(props['PATOMS'][0], -1)\n sg.bonds = props['BONDS']\n ? parseBracedNumberList(props['BONDS'][0], -1)\n : []\n var brkxyzStrs = props['BRKXYZ']\n sg.brkxyz = []\n if (brkxyzStrs) {\n for (var j = 0; j < brkxyzStrs.length; ++j)\n sg.brkxyz.push(parseBracedNumberList(brkxyzStrs[j]))\n }\n if (props['MULT']) sg.data.subscript = props['MULT'][0] - 0\n if (props['LABEL']) sg.data.subscript = props['LABEL'][0].trim()\n if (props['CONNECT'])\n sg.data.connectivity = props['CONNECT'][0].toLowerCase()\n if (props['FIELDDISP'])\n sGroup.applyDataSGroupInfo(sg, stripQuotes(props['FIELDDISP'][0]))\n if (props['FIELDDATA'])\n sGroup.applyDataSGroupData(sg, props['FIELDDATA'][0], true)\n if (props['FIELDNAME'])\n sGroup.applyDataSGroupName(sg, props['FIELDNAME'][0])\n if (props['QUERYTYPE'])\n sGroup.applyDataSGroupQuery(sg, props['QUERYTYPE'][0])\n if (props['QUERYOP']) sGroup.applyDataSGroupQueryOp(sg, props['QUERYOP'][0])\n sGroup.loadSGroup(ctab, sg, atomMap)\n if (props['ESTATE']) sGroup.applyDataSGroupExpand(sg, props['ESTATE'][0])\n }\n throw new Error('S-group declaration incomplete.')\n}\n\nfunction parseCTabV3000(ctabLines, norgroups) {\n // eslint-disable-line max-statements\n /* reader */\n var ctab = new Struct()\n\n var shift = 0\n if (ctabLines[shift++].trim() !== 'M V30 BEGIN CTAB')\n throw Error('CTAB V3000 invalid')\n if (ctabLines[shift].slice(0, 13) !== 'M V30 COUNTS')\n throw Error('CTAB V3000 invalid')\n var vals = ctabLines[shift].slice(14).split(' ')\n const isAbs = utils.parseDecimalInt(vals[4]) === 1\n shift++\n\n if (ctabLines[shift].trim() === 'M V30 BEGIN ATOM') {\n shift++\n var line\n while (shift < ctabLines.length) {\n line = stripV30(ctabLines[shift++]).trim()\n if (line === 'END ATOM') break\n while (line.charAt(line.length - 1) === '-')\n line = (\n line.substring(0, line.length - 1) + stripV30(ctabLines[shift++])\n ).trim()\n ctab.atoms.add(parseAtomLineV3000(line))\n }\n\n if (ctabLines[shift].trim() === 'M V30 BEGIN BOND') {\n shift++\n while (shift < ctabLines.length) {\n line = stripV30(ctabLines[shift++]).trim()\n if (line === 'END BOND') break\n while (line.charAt(line.length - 1) === '-')\n line = (\n line.substring(0, line.length - 1) + stripV30(ctabLines[shift++])\n ).trim()\n const bond = parseBondLineV3000(line)\n if (bond.stereo && isAbs) ctab.atoms.get(bond.begin).stereoLabel = 'abs'\n ctab.bonds.add(bond)\n }\n }\n\n // TODO: let sections follow in arbitrary order\n var sgroups = {}\n var atomMap = {}\n\n while (ctabLines[shift].trim() !== 'M V30 END CTAB') {\n if (ctabLines[shift].trim() === 'M V30 BEGIN COLLECTION')\n // TODO: read collection information\n shift = v3000parseCollection(ctab, ctabLines, shift)\n else if (ctabLines[shift].trim() === 'M V30 BEGIN SGROUP')\n shift = v3000parseSGroup(ctab, ctabLines, sgroups, atomMap, shift)\n else throw Error('CTAB V3000 invalid')\n }\n }\n if (ctabLines[shift++].trim() !== 'M V30 END CTAB')\n throw Error('CTAB V3000 invalid')\n\n if (!norgroups) readRGroups3000(ctab, ctabLines.slice(shift))\n\n return ctab\n}\n\nfunction readRGroups3000(ctab, /* string */ ctabLines) /* Struct */ {\n // eslint-disable-line max-statements\n /* reader */\n var rfrags = {}\n var rLogic = {}\n var shift = 0\n while (\n shift < ctabLines.length &&\n ctabLines[shift].search('M V30 BEGIN RGROUP') === 0\n ) {\n var id = ctabLines[shift++].split(' ').pop()\n rfrags[id] = []\n rLogic[id] = {}\n while (true) {\n // eslint-disable-line no-constant-condition\n var line = ctabLines[shift].trim()\n if (line.search('M V30 RLOGIC') === 0) {\n line = line.slice(13)\n var rlsplit = line.trim().split(/\\s+/g)\n var iii = utils.parseDecimalInt(rlsplit[0])\n var hhh = utils.parseDecimalInt(rlsplit[1])\n var ooo = rlsplit.slice(2).join(' ')\n var logic = {}\n if (iii > 0) logic.ifthen = iii\n logic.resth = hhh == 1\n logic.range = ooo\n rLogic[id] = logic\n shift++\n continue // eslint-disable-line no-continue\n }\n if (line != 'M V30 BEGIN CTAB') throw Error('CTAB V3000 invalid')\n for (var i = 0; i < ctabLines.length; ++i) {\n if (ctabLines[shift + i].trim() == 'M V30 END CTAB') break\n }\n var lines = ctabLines.slice(shift, shift + i + 1)\n var rfrag = parseCTabV3000(lines, true)\n rfrags[id].push(rfrag)\n shift = shift + i + 1\n if (ctabLines[shift].trim() == 'M V30 END RGROUP') {\n shift++\n break\n }\n }\n }\n\n Object.keys(rfrags).forEach(rgid => {\n rfrags[rgid].forEach(rg => {\n rg.rgroups.set(rgid, new RGroup(rLogic[rgid]))\n const frid = rg.frags.add({})\n rg.rgroups.get(rgid).frags.add(frid)\n rg.atoms.forEach(atom => {\n atom.fragment = frid\n })\n rg.mergeInto(ctab)\n })\n })\n}\n\nfunction parseRxn3000(\n /* string[] */ ctabLines,\n shouldReactionRelayout\n) /* Struct */ {\n // eslint-disable-line max-statements\n /* reader */\n ctabLines = ctabLines.slice(4)\n var countsSplit = ctabLines[0].split(/\\s+/g).slice(3)\n var nReactants = countsSplit[0] - 0,\n nProducts = countsSplit[1] - 0,\n nAgents = countsSplit.length > 2 ? countsSplit[2] - 0 : 0\n\n function findCtabEnd(i) {\n for (var j = i; j < ctabLines.length; ++j) {\n if (ctabLines[j].trim() == 'M V30 END CTAB') return j\n }\n\n return console.error('CTab format invalid')\n }\n\n function findRGroupEnd(i) {\n for (var j = i; j < ctabLines.length; ++j) {\n if (ctabLines[j].trim() == 'M V30 END RGROUP') return j\n }\n return console.error('CTab format invalid')\n }\n\n var molLinesReactants = []\n var molLinesProducts = []\n var current = null\n var rGroups = []\n for (var i = 0; i < ctabLines.length; ++i) {\n var line = ctabLines[i].trim()\n var j\n\n if (line.startsWith('M V30 COUNTS')) {\n // do nothing\n } else if (line === 'M END') {\n break // stop reading\n } else if (line === 'M V30 BEGIN PRODUCT') {\n current = molLinesProducts\n } else if (line === 'M V30 END PRODUCT') {\n current = null\n } else if (line === 'M V30 BEGIN REACTANT') {\n current = molLinesReactants\n } else if (line === 'M V30 END REACTANT') {\n current = null\n } else if (line.startsWith('M V30 BEGIN RGROUP')) {\n j = findRGroupEnd(i)\n rGroups.push(ctabLines.slice(i, j + 1))\n i = j\n } else if (line === 'M V30 BEGIN CTAB') {\n j = findCtabEnd(i)\n current.push(ctabLines.slice(i, j + 1))\n i = j\n } else {\n throw new Error('line unrecognized: ' + line)\n }\n }\n var mols = []\n var molLines = molLinesReactants.concat(molLinesProducts)\n for (j = 0; j < molLines.length; ++j) {\n var mol = parseCTabV3000(molLines[j], countsSplit)\n mols.push(mol)\n }\n var ctab = utils.rxnMerge(\n mols,\n nReactants,\n nProducts,\n nAgents,\n shouldReactionRelayout\n )\n\n readRGroups3000(\n ctab,\n (function (array) {\n var res = []\n for (var k = 0; k < array.length; ++k) res = res.concat(array[k])\n return res\n })(rGroups)\n )\n\n return ctab\n}\n\n// split a line by spaces outside parentheses\nfunction spacebarsplit(line) {\n // eslint-disable-line max-statements\n /* reader */\n const split = []\n let bracketEquality = 0\n let currentIndex = 0\n let firstSliceIndex = -1\n let quoted = false\n\n for (currentIndex; currentIndex < line.length; currentIndex += 1) {\n const currentSymbol = line[currentIndex]\n if (line.substr(currentIndex, 3) === 'NOT') {\n const closingBracketIndex = line.indexOf(']')\n split.push(line.slice(currentIndex, closingBracketIndex + 1))\n currentIndex = closingBracketIndex + 1\n firstSliceIndex = currentIndex\n } else if (currentSymbol === '(') bracketEquality += 1\n else if (currentSymbol === ')') bracketEquality -= 1\n else if (currentSymbol === '\"') quoted = !quoted\n else if (!quoted && line[currentIndex] === ' ' && bracketEquality === 0) {\n if (currentIndex > firstSliceIndex + 1)\n split.push(line.slice(firstSliceIndex + 1, currentIndex))\n firstSliceIndex = currentIndex\n }\n }\n if (currentIndex > firstSliceIndex + 1)\n split.push(line.slice(firstSliceIndex + 1, currentIndex))\n return split\n}\n\n// utils\nfunction stripQuotes(str) {\n if (str[0] === '\"' && str[str.length - 1] === '\"')\n return str.substr(1, str.length - 2)\n return str\n}\n\nfunction splitonce(line, delim) {\n /* reader */\n var p = line.indexOf(delim)\n return [line.slice(0, p), line.slice(p + 1)]\n}\n\nfunction splitSGroupDef(line) {\n // eslint-disable-line max-statements\n /* reader */\n var split = []\n var braceBalance = 0\n var quoted = false\n for (var i = 0; i < line.length; ++i) {\n var c = line.charAt(i)\n if (c == '\"') {\n quoted = !quoted\n } else if (!quoted) {\n if (c == '(') {\n braceBalance++\n } else if (c == ')') {\n braceBalance--\n } else if (c == ' ' && braceBalance == 0) {\n split.push(line.slice(0, i))\n line = line.slice(i + 1).trim()\n i = 0\n }\n }\n }\n if (braceBalance != 0)\n throw new Error('Brace balance broken. S-group properies invalid!')\n if (line.length > 0) split.push(line.trim())\n return split\n}\n\nfunction parseBracedNumberList(line, shift) {\n /* reader */\n if (!line) return null\n var list = []\n line = line.trim()\n line = line.substr(1, line.length - 2)\n var split = line.split(' ')\n shift = shift || 0\n\n for (var i = 1; i < split.length; ++i) {\n var value = parseInt(split[i])\n if (!isNaN(value))\n // eslint-disable-line\n list.push(value + shift)\n }\n\n return list\n}\n\nfunction stripV30(line) {\n /* reader */\n if (line.slice(0, 7) != 'M V30 ') throw new Error('Prefix invalid')\n return line.slice(7)\n}\n\nfunction labelsListToIds(labels) {\n /* reader */\n var ids = []\n for (var i = 0; i < labels.length; ++i) {\n const element = Elements.get(labels[i].trim())\n if (element) {\n ids.push(element.number)\n }\n }\n\n return ids\n}\n\nexport default {\n parseCTabV3000,\n readRGroups3000,\n parseRxn3000\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Pile, SGroup } from 'domain/entities'\n\nimport utils from './utils'\nimport v2000 from './v2000'\nimport v3000 from './v3000'\n\nconst loadRGroupFragments = true // TODO: set to load the fragments\n\n/* Parse Mol */\nfunction parseMol(/* string */ ctabLines) /* Struct */ {\n /* reader */\n if (ctabLines[0].search('\\\\$MDL') === 0) {\n const struct = v2000.parseRg2000(ctabLines)\n struct.name = ctabLines[3].trim()\n return struct\n }\n const struct = parseCTab(ctabLines.slice(3))\n struct.name = ctabLines[0].trim()\n return struct\n}\n\nfunction parseCTab(/* string */ ctabLines) /* Struct */ {\n /* reader */\n const countsSplit = partitionLine(\n ctabLines[0],\n utils.fmtInfo.countsLinePartition\n )\n const version = countsSplit[11].trim()\n ctabLines = ctabLines.slice(1)\n if (version === 'V2000') return v2000.parseCTabV2000(ctabLines, countsSplit)\n else if (version === 'V3000')\n return v3000.parseCTabV3000(ctabLines, !loadRGroupFragments)\n else throw new Error('Molfile version unknown: ' + version) // eslint-disable-line no-else-return\n}\n\n/* Parse Rxn */\nfunction parseRxn(\n /* string[] */ ctabLines,\n shouldReactionRelayout\n) /* Struct */ {\n /* reader */\n const split = ctabLines[0].trim().split(' ')\n if (split.length > 1 && split[1] === 'V3000')\n return v3000.parseRxn3000(ctabLines, shouldReactionRelayout)\n\n const struct = v2000.parseRxn2000(ctabLines, shouldReactionRelayout)\n struct.name = ctabLines[1].trim()\n return struct\n}\n\n/* Prepare For Saving */\nconst prepareForSaving = {\n MUL: SGroup.prepareMulForSaving,\n SRU: prepareSruForSaving,\n SUP: prepareSupForSaving,\n DAT: prepareDatForSaving,\n GEN: prepareGenForSaving\n}\n\nfunction prepareSruForSaving(sgroup, mol) {\n const xBonds = []\n mol.bonds.forEach((bond, bid) => {\n const a1 = mol.atoms.get(bond.begin)\n const a2 = mol.atoms.get(bond.end)\n /* eslint-disable no-mixed-operators*/\n if (\n (a1.sgs.has(sgroup.id) && !a2.sgs.has(sgroup.id)) ||\n (a2.sgs.has(sgroup.id) && !a1.sgs.has(sgroup.id))\n )\n /* eslint-enable no-mixed-operators*/\n xBonds.push(bid)\n }, sgroup)\n if (xBonds.length !== 0 && xBonds.length !== 2) {\n throw {\n // eslint-disable-line no-throw-literal\n id: sgroup.id,\n 'error-type': 'cross-bond-number',\n message: 'Unsupported cross-bonds number'\n }\n }\n sgroup.bonds = xBonds\n}\n\nfunction prepareSupForSaving(sgroup, mol) {\n // This code is also used for GroupSru and should be moved into a separate common method\n // It seems that such code should be used for any sgroup by this this should be checked\n const xBonds = []\n mol.bonds.forEach((bond, bid) => {\n const a1 = mol.atoms.get(bond.begin)\n const a2 = mol.atoms.get(bond.end)\n /* eslint-disable no-mixed-operators*/\n if (\n (a1.sgs.has(sgroup.id) && !a2.sgs.has(sgroup.id)) ||\n (a2.sgs.has(sgroup.id) && !a1.sgs.has(sgroup.id))\n )\n /* eslint-enable no-mixed-operators*/\n xBonds.push(bid)\n }, sgroup)\n sgroup.bonds = xBonds\n}\n\nfunction prepareGenForSaving(sgroup, mol) {\n // eslint-disable-line no-unused-vars\n}\n\nfunction prepareDatForSaving(sgroup, mol) {\n sgroup.atoms = SGroup.getAtoms(mol, sgroup)\n}\n\n/* Save To Molfile */\nconst saveToMolfile = {\n MUL: saveMulToMolfile,\n SRU: saveSruToMolfile,\n SUP: saveSupToMolfile,\n DAT: saveDatToMolfile,\n GEN: saveGenToMolfile\n}\n\nfunction saveMulToMolfile(sgroup, mol, sgMap, atomMap, bondMap) {\n // eslint-disable-line max-params\n const idstr = (sgMap[sgroup.id] + '').padStart(3)\n\n let lines = []\n lines = lines.concat(\n makeAtomBondLines(\n 'SAL',\n idstr,\n Array.from(sgroup.atomSet.values()),\n atomMap\n )\n ) // TODO: check atomSet\n lines = lines.concat(\n makeAtomBondLines(\n 'SPA',\n idstr,\n Array.from(sgroup.parentAtomSet.values()),\n atomMap\n )\n )\n lines = lines.concat(makeAtomBondLines('SBL', idstr, sgroup.bonds, bondMap))\n const smtLine = 'M SMT ' + idstr + ' ' + sgroup.data.mul\n lines.push(smtLine)\n lines = lines.concat(bracketsToMolfile(mol, sgroup, idstr))\n return lines.join('\\n')\n}\n\nfunction saveSruToMolfile(sgroup, mol, sgMap, atomMap, bondMap) {\n // eslint-disable-line max-params\n const idstr = (sgMap[sgroup.id] + '').padStart(3)\n\n let lines = []\n lines = lines.concat(makeAtomBondLines('SAL', idstr, sgroup.atoms, atomMap))\n lines = lines.concat(makeAtomBondLines('SBL', idstr, sgroup.bonds, bondMap))\n lines = lines.concat(bracketsToMolfile(mol, sgroup, idstr))\n return lines.join('\\n')\n}\n\nfunction saveSupToMolfile(sgroup, mol, sgMap, atomMap, bondMap) {\n // eslint-disable-line max-params\n const idstr = (sgMap[sgroup.id] + '').padStart(3)\n\n let lines = []\n lines = lines.concat(makeAtomBondLines('SAL', idstr, sgroup.atoms, atomMap))\n lines = lines.concat(makeAtomBondLines('SBL', idstr, sgroup.bonds, bondMap))\n if (sgroup.data.name && sgroup.data.name !== '')\n lines.push('M SMT ' + idstr + ' ' + sgroup.data.name)\n return lines.join('\\n')\n}\n\nfunction saveDatToMolfile(sgroup, mol, sgMap, atomMap) {\n const idstr = (sgMap[sgroup.id] + '').padStart(3)\n\n const data = sgroup.data\n let pp = sgroup.pp\n if (!data.absolute) pp = pp.sub(SGroup.getMassCentre(mol, sgroup.atoms))\n let lines = []\n lines = lines.concat(makeAtomBondLines('SAL', idstr, sgroup.atoms, atomMap))\n let sdtLine =\n 'M SDT ' +\n idstr +\n ' ' +\n (data.fieldName || '').padEnd(30) +\n (data.fieldType || '').padStart(2) +\n (data.units || '').padEnd(20) +\n (data.query || '').padStart(2)\n\n if (data.queryOp)\n // see gitlab #184\n sdtLine += data.queryOp.padEnd(80 - 65)\n\n lines.push(sdtLine)\n const sddLine =\n 'M SDD ' +\n idstr +\n ' ' +\n utils.paddedNum(pp.x, 10, 4) +\n utils.paddedNum(-pp.y, 10, 4) +\n ' ' + // ' eee'\n (data.attached ? 'A' : 'D') + // f\n (data.absolute ? 'A' : 'R') + // g\n (data.showUnits ? 'U' : ' ') + // h\n ' ' + // i\n (data.nCharnCharsToDisplay >= 0\n ? utils.paddedNum(data.nCharnCharsToDisplay, 3)\n : 'ALL') + // jjj\n ' 1 ' + // 'kkk ll '\n (data.tagChar || ' ') + // m\n ' ' +\n utils.paddedNum(data.daspPos, 1) + // n\n ' ' // oo\n lines.push(sddLine)\n const val = normalizeNewlines(data.fieldValue).replace(/\\n*$/, '')\n const charsPerLine = 69\n val.split('\\n').forEach(chars => {\n while (chars.length > charsPerLine) {\n lines.push('M SCD ' + idstr + ' ' + chars.slice(0, charsPerLine))\n chars = chars.slice(charsPerLine)\n }\n lines.push('M SED ' + idstr + ' ' + chars)\n })\n return lines.join('\\n')\n}\n\nfunction saveGenToMolfile(sgroup, mol, sgMap, atomMap, bondMap) {\n // eslint-disable-line max-params\n const idstr = (sgMap[sgroup.id] + '').padStart(3)\n\n let lines = []\n lines = lines.concat(makeAtomBondLines('SAL', idstr, sgroup.atoms, atomMap))\n lines = lines.concat(makeAtomBondLines('SBL', idstr, sgroup.bonds, bondMap))\n lines = lines.concat(bracketsToMolfile(mol, sgroup, idstr))\n return lines.join('\\n')\n}\n\nfunction makeAtomBondLines(prefix, idstr, ids, map) {\n if (!ids) return []\n const lines = []\n for (let i = 0; i < Math.floor((ids.length + 14) / 15); ++i) {\n const rem = Math.min(ids.length - 15 * i, 15) // eslint-disable-line no-mixed-operators\n let salLine = 'M ' + prefix + ' ' + idstr + ' ' + utils.paddedNum(rem, 2)\n for (let j = 0; j < rem; ++j)\n salLine += ' ' + utils.paddedNum(map[ids[i * 15 + j]], 3) // eslint-disable-line no-mixed-operators\n lines.push(salLine)\n }\n return lines\n}\n\nfunction bracketsToMolfile(mol, sg, idstr) {\n // eslint-disable-line max-statements\n const atomSet = new Pile(sg.atoms)\n const crossBonds = SGroup.getCrossBonds(mol, atomSet)\n SGroup.bracketPos(sg, mol, crossBonds)\n const bb = sg.bracketBox\n const d = sg.bracketDir\n const n = d.rotateSC(1, 0)\n const brackets = SGroup.getBracketParameters(\n mol,\n crossBonds,\n atomSet,\n bb,\n d,\n n\n )\n const lines = []\n for (let i = 0; i < brackets.length; ++i) {\n const bracket = brackets[i]\n const a0 = bracket.c.addScaled(bracket.n, -0.5 * bracket.h).yComplement()\n const a1 = bracket.c.addScaled(bracket.n, 0.5 * bracket.h).yComplement()\n let line = 'M SDI ' + idstr + utils.paddedNum(4, 3)\n const coord = [a0.x, a0.y, a1.x, a1.y]\n for (let j = 0; j < coord.length; ++j)\n line += utils.paddedNum(coord[j], 10, 4)\n lines.push(line)\n }\n return lines\n}\n\n// According Unicode Consortium sould be\n// nlRe = /\\r\\n|[\\n\\v\\f\\r\\x85\\u2028\\u2029]/g;\n// http://www.unicode.org/reports/tr18/#Line_Boundaries\nconst nlRe = /\\r\\n|[\\n\\r]/g\nfunction normalizeNewlines(str) {\n return str.replace(nlRe, '\\n')\n}\n\nfunction partitionLine(\n /* string*/ str,\n /* array of int*/ parts,\n /* bool*/ withspace\n) {\n /* reader */\n const res = []\n for (let i = 0, shift = 0; i < parts.length; ++i) {\n res.push(str.slice(shift, shift + parts[i]))\n if (withspace) shift++\n shift += parts[i]\n }\n return res\n}\n\nexport default {\n parseCTab,\n parseMol,\n parseRxn,\n prepareForSaving,\n saveToMolfile\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { StereoFlag, Struct } from 'domain/entities'\n\nimport { Elements } from 'domain/constants'\nimport common from './common'\nimport utils from './utils'\n\nconst END_V2000 = '2D 1 1.00000 0.00000 0'\n\ntype Mapping = {\n [key in number]: number\n}\ntype NumberTuple = [number, number]\n\nexport class Molfile {\n molecule: Struct\n molfile: string | null\n reaction: boolean\n mapping: Mapping\n bondMapping: Mapping\n\n constructor() {\n // @ts-ignore\n this.molecule = null\n this.molfile = null\n\n this.reaction = false\n this.mapping = {}\n this.bondMapping = {}\n }\n\n parseCTFile(molfileLines: string[], shouldReactionRelayout?: boolean) {\n let ret\n if (molfileLines[0].search('\\\\$RXN') === 0) {\n ret = common.parseRxn(molfileLines, shouldReactionRelayout)\n } else {\n ret = common.parseMol(molfileLines)\n }\n ret.initHalfBonds()\n ret.initNeighbors()\n ret.bindSGroupsToFunctionalGroups()\n\n return ret\n }\n\n prepareSGroups(skipErrors: boolean, preserveIndigoDesc?: boolean) {\n let mol = this.molecule\n let toRemove: any[] = []\n let errors = 0\n\n this.molecule.sGroupForest\n .getSGroupsBFS()\n .reverse()\n .forEach(id => {\n let sgroup = mol.sgroups.get(id)!\n let errorIgnore = false\n\n try {\n common.prepareForSaving[sgroup.type](sgroup, mol)\n } catch (ex: any) {\n if (!skipErrors || typeof ex.id != 'number') {\n throw new Error(`Error: ${ex.message}`)\n }\n errorIgnore = true\n }\n /* eslint-disable no-mixed-operators*/\n if (\n errorIgnore ||\n (!preserveIndigoDesc &&\n /^INDIGO_.+_DESC$/i.test(sgroup.data.fieldName))\n ) {\n /* eslint-enable no-mixed-operators*/\n // @ts-ignore\n errors += errorIgnore\n toRemove.push(sgroup.id)\n }\n }, this)\n\n if (errors) {\n throw new Error(\n 'Warning: ' +\n errors +\n ' invalid S-groups were detected. They will be omitted.'\n )\n }\n\n for (let i = 0; i < toRemove.length; ++i) {\n mol.sGroupDelete(toRemove[i])\n }\n }\n\n getCTab(molecule: Struct, rgroups?: Map) {\n /* saver */\n this.molecule = molecule.clone()\n this.prepareSGroups(false, false)\n this.molfile = ''\n this.writeCTab2000(rgroups)\n return this.molfile\n }\n\n saveMolecule(\n molecule: Struct,\n skipSGroupErrors: boolean,\n norgroups?: boolean,\n preserveIndigoDesc?: boolean\n ) {\n // eslint-disable-line max-statements\n /* saver */\n this.reaction = molecule.hasRxnArrow()\n this.molfile = '' + molecule.name\n if (this.reaction) {\n if (molecule.rgroups.size > 0) {\n throw new Error(\n 'Reactions with r-groups are not supported at the moment'\n )\n }\n let components = molecule.getComponents()\n\n let reactants = components.reactants\n let products = components.products\n let all = reactants.concat(products)\n this.molfile =\n '$RXN\\n' +\n molecule.name +\n '\\n\\n\\n' +\n utils.paddedNum(reactants.length, 3) +\n utils.paddedNum(products.length, 3) +\n utils.paddedNum(0, 3) +\n '\\n'\n for (let i = 0; i < all.length; ++i) {\n const saver = new Molfile()\n const submol = molecule.clone(all[i], null, true)\n const molfile = saver.saveMolecule(submol, false, true)\n this.molfile += '$MOL\\n' + molfile\n }\n return this.molfile\n }\n\n if (molecule.rgroups.size > 0) {\n if (norgroups) {\n molecule = molecule.getScaffold()\n } else {\n let scaffold = new Molfile().getCTab(\n molecule.getScaffold(),\n molecule.rgroups\n )\n this.molfile =\n '$MDL REV 1\\n$MOL\\n$HDR\\n' + molecule.name + '\\n\\n\\n$END HDR\\n'\n this.molfile += '$CTAB\\n' + scaffold + '$END CTAB\\n'\n\n molecule.rgroups.forEach((rg, rgid) => {\n this.molfile += '$RGP\\n'\n this.writePaddedNumber(rgid, 3)\n this.molfile += '\\n'\n rg.frags.forEach(fid => {\n const group = new Molfile().getCTab(molecule.getFragment(fid))\n this.molfile += '$CTAB\\n' + group + '$END CTAB\\n'\n })\n this.molfile += '$END RGP\\n'\n })\n this.molfile += '$END MOL\\n'\n\n return this.molfile\n }\n }\n\n this.molecule = molecule.clone()\n\n this.prepareSGroups(skipSGroupErrors, preserveIndigoDesc)\n\n this.writeHeader()\n this.writeCTab2000()\n\n return this.molfile\n }\n\n writeHeader() {\n /* saver */\n\n let date = new Date()\n\n this.writeCR() // TODO: write structure name\n this.writeWhiteSpace(2)\n this.write('Ketcher')\n this.writeWhiteSpace()\n this.writeCR(\n (date.getMonth() + 1 + '').padStart(2) +\n (date.getDate() + '').padStart(2) +\n ((date.getFullYear() % 100) + '').padStart(2) +\n (date.getHours() + '').padStart(2) +\n (date.getMinutes() + '').padStart(2) +\n END_V2000\n )\n this.writeCR()\n }\n\n write(str: string) {\n /* saver */\n this.molfile += str\n }\n\n writeCR(str?: string) {\n /* saver */\n if (arguments.length === 0) {\n str = ''\n }\n\n this.molfile += str + '\\n'\n }\n\n writeWhiteSpace(length: number = 0) {\n /* saver */\n if (arguments.length === 0) {\n length = 1\n }\n\n this.write(' '.repeat(Math.max(length, 0)))\n }\n\n writePadded(str: string, width: number) {\n /* saver */\n this.write(str)\n this.writeWhiteSpace(width - str.length)\n }\n\n writePaddedNumber(number: number, width: number) {\n /* saver */\n let str = (number - 0).toString()\n\n this.writeWhiteSpace(width - str.length)\n this.write(str)\n }\n\n writePaddedFloat(number: string | number, width: number, precision: number) {\n /* saver */\n this.write(utils.paddedNum(number, width, precision))\n }\n\n writeCTab2000Header() {\n /* saver */\n this.writePaddedNumber(this.molecule.atoms.size, 3)\n this.writePaddedNumber(this.molecule.bonds.size, 3)\n\n this.writePaddedNumber(0, 3)\n this.writePaddedNumber(0, 3)\n const isAbsFlag = Array.from(this.molecule.frags.values()).some(fr =>\n fr ? fr.enhancedStereoFlag === StereoFlag.Abs : false\n )\n this.writePaddedNumber(isAbsFlag ? 1 : 0, 3)\n this.writePaddedNumber(0, 3)\n this.writeWhiteSpace(12)\n this.writePaddedNumber(999, 3)\n this.writeCR(' V2000')\n }\n\n writeCTab2000(rgroups?: Map) {\n // eslint-disable-line max-statements\n /* saver */\n this.writeCTab2000Header()\n\n this.mapping = {}\n let i = 1\n\n const atomsIds: number[] = []\n const atomsProps: {\n id: number\n value: string\n }[] = []\n this.molecule.atoms.forEach((atom, id) => {\n let label = atom.label\n if (atom.atomList != null) {\n label = 'L'\n atomsIds.push(id)\n } else if (atom['pseudo']) {\n if (atom['pseudo'].length > 3) {\n label = 'A'\n atomsProps.push({ id, value: `'${atom['pseudo']}'` })\n }\n } else if (atom['alias']) {\n atomsProps.push({ id, value: atom['alias'] })\n } else if (\n !Elements.get(atom.label) &&\n ['A', 'Q', 'X', '*', 'R#'].indexOf(atom.label) === -1\n ) {\n // search in generics?\n label = 'C'\n atomsProps.push({ id, value: atom.label })\n }\n\n this.writeAtom(atom, label)\n\n this.mapping[id] = i++\n }, this)\n\n this.bondMapping = {}\n i = 1\n this.molecule.bonds.forEach((bond, id) => {\n this.bondMapping[id] = i++\n this.writeBond(bond)\n }, this)\n\n while (atomsProps.length > 0) {\n this.writeAtomProps(atomsProps[0])\n atomsProps.splice(0, 1)\n }\n\n const chargeList: NumberTuple[] = []\n const isotopeList: NumberTuple[] = []\n const radicalList: NumberTuple[] = []\n const rglabelList: NumberTuple[] = []\n const rglogicList: string[] = []\n const aplabelList: NumberTuple[] = []\n const rbcountList: NumberTuple[] = []\n const unsaturatedList: NumberTuple[] = []\n const substcountList: NumberTuple[] = []\n\n this.molecule.atoms.forEach((atom, id) => {\n if (atom.charge !== 0) {\n chargeList.push([id, atom.charge])\n }\n if (atom.isotope !== 0) {\n isotopeList.push([id, atom.isotope])\n }\n if (atom.radical !== 0) {\n radicalList.push([id, atom.radical])\n }\n if (atom.rglabel != null && atom.label === 'R#') {\n // TODO need to force rglabel=null when label is not 'R#'\n for (let rgi = 0; rgi < 32; rgi++) {\n if ((atom.rglabel as any) & (1 << rgi)) {\n rglabelList.push([id, rgi + 1])\n }\n }\n }\n if (atom.attpnt != null) {\n aplabelList.push([id, atom.attpnt])\n }\n if (atom.ringBondCount !== 0) {\n rbcountList.push([id, atom.ringBondCount])\n }\n if (atom.substitutionCount !== 0) {\n substcountList.push([id, atom.substitutionCount])\n }\n if (atom.unsaturatedAtom !== 0) {\n unsaturatedList.push([id, atom.unsaturatedAtom])\n }\n })\n\n if (rgroups) {\n rgroups.forEach((rg, rgid) => {\n if (rg.resth || rg.ifthen > 0 || rg.range.length > 0) {\n let line =\n ' 1 ' +\n utils.paddedNum(rgid, 3) +\n ' ' +\n utils.paddedNum(rg.ifthen, 3) +\n ' ' +\n utils.paddedNum(rg.resth ? 1 : 0, 3) +\n ' ' +\n rg.range\n rglogicList.push(line)\n }\n })\n }\n\n this.writeAtomPropList('M CHG', chargeList)\n this.writeAtomPropList('M ISO', isotopeList)\n this.writeAtomPropList('M RAD', radicalList)\n this.writeAtomPropList('M RGP', rglabelList)\n for (let j = 0; j < rglogicList.length; ++j) {\n this.write('M LOG' + rglogicList[j] + '\\n')\n }\n\n this.writeAtomPropList('M APO', aplabelList)\n this.writeAtomPropList('M RBC', rbcountList)\n this.writeAtomPropList('M SUB', substcountList)\n this.writeAtomPropList('M UNS', unsaturatedList)\n\n if (atomsIds.length > 0) {\n for (let j = 0; j < atomsIds.length; ++j) {\n let atomId = atomsIds[j]\n let atomList = this.molecule.atoms.get(atomId)!.atomList!\n this.write('M ALS')\n this.writePaddedNumber(atomId + 1, 4)\n this.writePaddedNumber(atomList.ids.length, 3)\n this.writeWhiteSpace()\n this.write(atomList.notList ? 'T' : 'F')\n\n let labelList = atomList.labelList()\n for (let k = 0; k < labelList.length; ++k) {\n this.writeWhiteSpace()\n this.writePadded(labelList[k], 3)\n }\n this.writeCR()\n }\n }\n\n const sgmap = {}\n let cnt = 1\n const sgmapback = {}\n const sgorder = this.molecule.sGroupForest.getSGroupsBFS()\n sgorder.forEach(id => {\n sgmapback[cnt] = id\n sgmap[id] = cnt++\n })\n for (let q = 1; q < cnt; ++q) {\n // each group on its own\n const id = sgmapback[q]\n const sgroup = this.molecule.sgroups.get(id)!\n this.write('M STY')\n this.writePaddedNumber(1, 3)\n this.writeWhiteSpace(1)\n this.writePaddedNumber(q, 3)\n this.writeWhiteSpace(1)\n this.writePadded(sgroup.type, 3)\n this.writeCR()\n\n // TODO: write subtype, M SST\n\n this.write('M SLB')\n this.writePaddedNumber(1, 3)\n this.writeWhiteSpace(1)\n this.writePaddedNumber(q, 3)\n this.writeWhiteSpace(1)\n this.writePaddedNumber(q, 3)\n this.writeCR()\n\n const parentId = this.molecule.sGroupForest.parent.get(id)!\n if (parentId >= 0) {\n this.write('M SPL')\n this.writePaddedNumber(1, 3)\n this.writeWhiteSpace(1)\n this.writePaddedNumber(q, 3)\n this.writeWhiteSpace(1)\n this.writePaddedNumber(sgmap[parentId], 3)\n this.writeCR()\n }\n\n // connectivity\n if (sgroup.type === 'SRU' && sgroup.data.connectivity) {\n const connectivity = ` ${q.toString().padStart(3)} ${(\n sgroup.data.connectivity || ''\n ).padEnd(3)}`\n\n this.write('M SCN')\n this.writePaddedNumber(1, 3)\n this.write(connectivity.toUpperCase())\n this.writeCR()\n }\n\n if (sgroup.type === 'SRU') {\n this.write('M SMT ')\n this.writePaddedNumber(q, 3)\n this.writeWhiteSpace()\n this.write(sgroup.data.subscript || 'n')\n this.writeCR()\n }\n\n this.writeCR(\n common.saveToMolfile[sgroup.type](\n sgroup,\n this.molecule,\n sgmap,\n this.mapping,\n this.bondMapping\n )\n )\n }\n\n // TODO: write M APO\n // TODO: write M AAL\n // TODO: write M RGP\n // TODO: write M LOG\n\n const expandedGroups: number[] = []\n this.molecule.sgroups.forEach(sg => {\n if (sg.data.expanded) expandedGroups.push(sg.id + 1)\n })\n\n if (expandedGroups.length) {\n const expandedGroupsLine = `M SDS EXP ${\n expandedGroups.length\n } ${expandedGroups.join(' ')}`\n this.writeCR(expandedGroupsLine)\n }\n\n this.writeCR('M END')\n }\n\n private writeAtom(atom, atomLabel: string) {\n this.writePaddedFloat(atom.pp.x, 10, 4)\n this.writePaddedFloat(-atom.pp.y, 10, 4)\n this.writePaddedFloat(atom.pp.z, 10, 4)\n this.writeWhiteSpace()\n this.writePadded(atomLabel, 3)\n this.writePaddedNumber(0, 2)\n this.writePaddedNumber(0, 3)\n this.writePaddedNumber(0, 3)\n\n if (typeof atom.hCount === 'undefined') {\n atom.hCount = 0\n }\n this.writePaddedNumber(atom.hCount, 3)\n\n if (typeof atom.stereoCare === 'undefined') {\n atom.stereoCare = 0\n }\n this.writePaddedNumber(atom.stereoCare, 3)\n\n let number: number\n if (atom.explicitValence < 0) {\n number = 0\n } else if (atom.explicitValence === 0) {\n number = 15\n } else {\n number = atom.explicitValence\n }\n this.writePaddedNumber(number, 3)\n\n this.writePaddedNumber(0, 3)\n this.writePaddedNumber(0, 3)\n this.writePaddedNumber(0, 3)\n\n if (typeof atom.aam === 'undefined') {\n atom.aam = 0\n }\n this.writePaddedNumber(atom.aam, 3)\n\n if (typeof atom.invRet === 'undefined') {\n atom.invRet = 0\n }\n this.writePaddedNumber(atom.invRet, 3)\n\n if (typeof atom.exactChangeFlag === 'undefined') {\n atom.exactChangeFlag = 0\n }\n this.writePaddedNumber(atom.exactChangeFlag, 3)\n\n this.writeCR()\n }\n\n private writeBond(bond) {\n this.writePaddedNumber(this.mapping[bond.begin], 3)\n this.writePaddedNumber(this.mapping[bond.end], 3)\n this.writePaddedNumber(bond.type, 3)\n\n if (typeof bond.stereo === 'undefined') {\n bond.stereo = 0\n }\n this.writePaddedNumber(bond.stereo, 3)\n\n this.writePadded(bond.xxx, 3)\n\n if (typeof bond.topology === 'undefined') {\n bond.topology = 0\n }\n this.writePaddedNumber(bond.topology, 3)\n\n if (typeof bond.reactingCenterStatus === 'undefined') {\n bond.reactingCenterStatus = 0\n }\n this.writePaddedNumber(bond.reactingCenterStatus, 3)\n\n this.writeCR()\n }\n\n private writeAtomProps(props) {\n this.write('A ')\n this.writePaddedNumber(props.id + 1, 3)\n this.writeCR()\n this.writeCR(props.value)\n }\n\n private writeAtomPropList(propId: string, values: NumberTuple[]) {\n while (values.length > 0) {\n const part: NumberTuple[] = []\n\n while (values.length > 0 && part.length < 8) {\n part.push(values[0])\n values.splice(0, 1)\n }\n\n this.write(propId)\n this.writePaddedNumber(part.length, 3)\n\n part.forEach(value => {\n this.writeWhiteSpace()\n this.writePaddedNumber(this.mapping[value[0]], 3)\n this.writeWhiteSpace()\n this.writePaddedNumber(value[1], 3)\n })\n\n this.writeCR()\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializerOptions } from './mol.types'\nimport { Molfile } from './molfile'\nimport { Serializer } from '../serializers.types'\nimport { Struct } from 'domain/entities'\n\nexport class MolSerializer implements Serializer {\n static DefaultOptions: MolSerializerOptions = {\n badHeaderRecover: false,\n ignoreErrors: false,\n noRgroups: false,\n preserveIndigoDesc: false,\n reactionRelayout: false\n }\n\n readonly options: MolSerializerOptions\n\n constructor(options?: Partial) {\n this.options = { ...MolSerializer.DefaultOptions, ...options }\n }\n\n deserialize(content: string): Struct {\n const molfile = new Molfile()\n const lines = content?.split(/\\r\\n|[\\n\\r]/g)\n try {\n return molfile.parseCTFile(lines, this.options.reactionRelayout)\n } catch (ex) {\n if (this.options.badHeaderRecover) {\n try {\n // check whether there's an extra empty line on top\n // this often happens when molfile text is pasted into the dialog window\n return molfile.parseCTFile(\n lines.slice(1),\n this.options.reactionRelayout\n )\n } catch (ex1) {\n //\n }\n try {\n // check for a missing first line\n // this sometimes happens when pasting\n return molfile.parseCTFile(\n [''].concat(lines),\n this.options.reactionRelayout\n )\n } catch (ex2) {\n //\n }\n }\n throw ex\n }\n }\n\n serialize(struct: Struct): string {\n return new Molfile().saveMolecule(\n struct,\n this.options.ignoreErrors,\n this.options.noRgroups,\n this.options.preserveIndigoDesc\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond, Pool, Vec2 } from 'domain/entities'\n\nfunction CisTrans(mol, neighborsFunc, context) {\n this.molecule = mol\n this.bonds = new Pool()\n this.getNeighbors = neighborsFunc\n this.context = context\n}\n\nCisTrans.PARITY = {\n NONE: 0,\n CIS: 1,\n TRANS: 2\n}\n\nCisTrans.prototype.each = function (func) {\n this.bonds.forEach(func)\n}\n\nCisTrans.prototype.getParity = function (idx) {\n return this.bonds.get(idx).parity\n}\n\nCisTrans.prototype.getSubstituents = function (idx) {\n return this.bonds.get(idx).substituents\n}\n\nCisTrans.prototype.sameside = function (beg, end, neiBeg, neiEnd) {\n var diff = Vec2.diff(beg, end)\n var norm = new Vec2(-diff.y, diff.x)\n\n if (!norm.normalize()) return 0\n\n var normBeg = Vec2.diff(neiBeg, beg)\n var normEnd = Vec2.diff(neiEnd, end)\n\n if (!normBeg.normalize()) return 0\n if (!normEnd.normalize()) return 0\n\n var prodBeg = Vec2.dot(normBeg, norm)\n var prodEnd = Vec2.dot(normEnd, norm)\n\n if (Math.abs(prodBeg) < 0.001 || Math.abs(prodEnd) < 0.001) return 0\n\n return prodBeg * prodEnd > 0 ? 1 : -1\n}\n\nCisTrans.prototype.samesides = function (iBeg, iEnd, iNeiBeg, iNeiEnd) {\n return this.sameside(\n this.molecule.atoms.get(iBeg).pp,\n this.molecule.atoms.get(iEnd).pp,\n this.molecule.atoms.get(iNeiBeg).pp,\n this.molecule.atoms.get(iNeiEnd).pp\n )\n}\n\nCisTrans.prototype.sortSubstituents = function (substituents) {\n // eslint-disable-line max-statements\n var h0 = this.molecule.atoms.get(substituents[0]).pureHydrogen()\n var h1 =\n substituents[1] < 0 ||\n this.molecule.atoms.get(substituents[1]).pureHydrogen()\n var h2 = this.molecule.atoms.get(substituents[2]).pureHydrogen()\n var h3 =\n substituents[3] < 0 ||\n this.molecule.atoms.get(substituents[3]).pureHydrogen()\n\n if (h0 && h1) return false\n if (h2 && h3) return false\n\n if (h1) {\n substituents[1] = -1\n } else if (h0) {\n substituents[0] = substituents[1]\n substituents[1] = -1\n } else if (substituents[0] > substituents[1]) {\n swap(substituents, 0, 1)\n }\n\n if (h3) {\n substituents[3] = -1\n } else if (h2) {\n substituents[2] = substituents[3]\n substituents[3] = -1\n } else if (substituents[2] > substituents[3]) {\n swap(substituents, 2, 3)\n }\n\n return true\n}\n\nCisTrans.prototype.isGeomStereoBond = function (bondIdx, substituents) {\n // eslint-disable-line max-statements\n // it must be [C,N,Si]=[C,N,Si] bond\n var bond = this.molecule.bonds.get(bondIdx)\n\n if (bond.type != Bond.PATTERN.TYPE.DOUBLE) return false\n\n var label1 = this.molecule.atoms.get(bond.begin).label\n var label2 = this.molecule.atoms.get(bond.end).label\n\n if (label1 != 'C' && label1 != 'N' && label1 != 'Si' && label1 != 'Ge')\n return false\n if (label2 != 'C' && label2 != 'N' && label2 != 'Si' && label2 != 'Ge')\n return false\n\n // the atoms should have 1 or 2 single bonds\n // (apart from the double bond under consideration)\n var neiBegin = this.getNeighbors.call(this.context, bond.begin)\n var neiЕnd = this.getNeighbors.call(this.context, bond.end)\n\n if (\n neiBegin.length < 2 ||\n neiBegin.length > 3 ||\n neiЕnd.length < 2 ||\n neiЕnd.length > 3\n )\n return false\n\n substituents[0] = -1\n substituents[1] = -1\n substituents[2] = -1\n substituents[3] = -1\n\n var i\n var nei\n\n for (i = 0; i < neiBegin.length; i++) {\n nei = neiBegin[i]\n\n if (nei.bid == bondIdx) continue // eslint-disable-line no-continue\n\n if (this.molecule.bonds.get(nei.bid).type != Bond.PATTERN.TYPE.SINGLE)\n return false\n\n if (substituents[0] == -1) substituents[0] = nei.aid\n // (substituents[1] == -1)\n else substituents[1] = nei.aid\n }\n\n for (i = 0; i < neiЕnd.length; i++) {\n nei = neiЕnd[i]\n\n if (nei.bid == bondIdx) continue // eslint-disable-line no-continue\n\n if (this.molecule.bonds.get(nei.bid).type != Bond.PATTERN.TYPE.SINGLE)\n return false\n\n if (substituents[2] == -1) substituents[2] = nei.aid\n // (substituents[3] == -1)\n else substituents[3] = nei.aid\n }\n\n if (\n substituents[1] != -1 &&\n this.samesides(bond.begin, bond.end, substituents[0], substituents[1]) != -1\n )\n return false\n if (\n substituents[3] != -1 &&\n this.samesides(bond.begin, bond.end, substituents[2], substituents[3]) != -1\n )\n return false\n\n return true\n}\n\nCisTrans.prototype.build = function (excludeBonds) {\n this.molecule.bonds.forEach((bond, bid) => {\n const ct = {\n parity: 0,\n substituents: []\n }\n this.bonds.set(bid, ct)\n\n if (Array.isArray(excludeBonds) && excludeBonds[bid]) return\n\n if (!this.isGeomStereoBond(bid, ct.substituents)) return\n\n if (!this.sortSubstituents(ct.substituents)) return\n\n const sign = this.samesides(\n bond.begin,\n bond.end,\n ct.substituents[0],\n ct.substituents[2]\n )\n\n if (sign === 1) ct.parity = CisTrans.PARITY.CIS\n else if (sign === -1) ct.parity = CisTrans.PARITY.TRANS\n })\n}\n\nfunction swap(arr, i1, i2) {\n var tmp = arr[i1]\n arr[i1] = arr[i2]\n arr[i2] = tmp\n}\n\nexport default CisTrans\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nfunction Dfs(mol, atomData, components, nReactants) {\n this.molecule = mol\n this.atom_data = atomData\n this.components = components\n this.nComponentsInReactants = -1\n this.nReactants = nReactants\n\n this.vertices = new Array(this.molecule.atoms.size) // Minimum size\n this.molecule.atoms.forEach((atom, aid) => {\n this.vertices[aid] = new Dfs.VertexDesc()\n }, this)\n\n this.edges = new Array(this.molecule.bonds.size) // Minimum size\n this.molecule.bonds.forEach((bond, bid) => {\n this.edges[bid] = new Dfs.EdgeDesc()\n }, this)\n\n this.v_seq = []\n}\n\nDfs.VertexDesc = function () {\n this.dfs_state = 0 // 0 -- not on stack\n // 1 -- on stack\n // 2 -- removed from stack\n this.parent_vertex = 0 // parent vertex in DFS tree\n this.parent_edge = 0 // edge to parent vertex\n this.branches = 0 // how many DFS branches go out from this vertex}\n}\n\nDfs.EdgeDesc = function () {\n this.opening_cycles = 0 // how many cycles are\n // (i) starting with this edge\n // and (ii) ending in this edge's first vertex\n this.closing_cycle = 0 // 1 if this edge closes a cycle\n}\n\nDfs.SeqElem = function (vIdx, parVertex, parEdge) {\n this.idx = vIdx // index of vertex in _graph\n this.parent_vertex = parVertex // parent vertex in DFS tree\n this.parent_edge = parEdge // edge to parent vertex\n}\n\nDfs.prototype.walk = function () {\n // eslint-disable-line max-statements\n var vStack = []\n var i, j\n var cid = 0\n var component = 0\n\n while (true) {\n // eslint-disable-line no-constant-condition\n if (vStack.length < 1) {\n var selected = -1\n\n while (cid < this.components.length && selected == -1) {\n selected = this.components[cid].find(aid => {\n if (this.vertices[aid].dfs_state === 0) {\n selected = aid\n return true\n }\n return false\n })\n if (selected === null) {\n selected = -1\n cid++\n }\n if (cid == this.nReactants) this.nComponentsInReactants = component\n }\n if (selected < -1) {\n this.molecule.atoms.find(aid => {\n if (this.vertices[aid].dfs_state === 0) {\n selected = aid\n return true\n }\n return false\n })\n }\n if (selected == -1) break\n this.vertices[selected].parent_vertex = -1\n this.vertices[selected].parent_edge = -1\n vStack.push(selected)\n component++\n }\n\n var vIdx = vStack.pop()\n var parentVertex = this.vertices[vIdx].parent_vertex\n\n var seqElem = new Dfs.SeqElem(\n vIdx,\n parentVertex,\n this.vertices[vIdx].parent_edge\n )\n this.v_seq.push(seqElem)\n\n this.vertices[vIdx].dfs_state = 2\n\n var atomD = this.atom_data[vIdx]\n\n for (i = 0; i < atomD.neighbours.length; i++) {\n var neiIdx = atomD.neighbours[i].aid\n var edgeIdx = atomD.neighbours[i].bid\n\n if (neiIdx == parentVertex) continue // eslint-disable-line no-continue\n\n if (this.vertices[neiIdx].dfs_state == 2) {\n this.edges[edgeIdx].closing_cycle = 1\n\n j = vIdx\n\n while (j != -1 && this.vertices[j].parent_vertex != neiIdx)\n j = this.vertices[j].parent_vertex\n\n if (j == -1) throw new Error('cycle unwind error')\n\n this.edges[this.vertices[j].parent_edge].opening_cycles++\n this.vertices[vIdx].branches++\n\n seqElem = new Dfs.SeqElem(neiIdx, vIdx, edgeIdx)\n this.v_seq.push(seqElem)\n } else {\n if (this.vertices[neiIdx].dfs_state == 1) {\n j = vStack.indexOf(neiIdx)\n\n if (j == -1)\n // eslint-disable-line max-depth\n throw new Error('internal: removing vertex from stack')\n\n vStack.splice(j, 1)\n\n var parent = this.vertices[neiIdx].parent_vertex\n\n if (parent >= 0)\n // eslint-disable-line max-depth\n this.vertices[parent].branches--\n }\n\n this.vertices[vIdx].branches++\n this.vertices[neiIdx].parent_vertex = vIdx\n this.vertices[neiIdx].parent_edge = edgeIdx\n this.vertices[neiIdx].dfs_state = 1\n vStack.push(neiIdx)\n }\n }\n }\n}\n\nDfs.prototype.edgeClosingCycle = function (eIdx) {\n return this.edges[eIdx].closing_cycle !== 0\n}\n\nDfs.prototype.numBranches = function (vIdx) {\n return this.vertices[vIdx].branches\n}\n\nDfs.prototype.numOpeningCycles = function (eIdx) {\n return this.edges[eIdx].opening_cycles\n}\n\nDfs.prototype.toString = function () {\n var str = ''\n this.v_seq.forEach(seqElem => {\n str += seqElem.idx + ' -> '\n })\n str += '*'\n return str\n}\n\nexport default Dfs\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond, Pile, Pool, Vec2 } from 'domain/entities'\n\nfunction Stereocenters(mol, neighborsFunc, context) {\n this.molecule = mol\n this.atoms = new Pool()\n this.getNeighbors = neighborsFunc\n this.context = context\n}\n\nStereocenters.prototype.each = function (func, context) {\n this.atoms.forEach(func, context)\n}\n\nStereocenters.prototype.buildFromBonds = function (\n /* const int *atom_types, const int *atom_groups, const int *bond_orientations, */ ignoreErrors\n) {\n var atoms = this.molecule.atoms\n var bonds = this.molecule.bonds\n\n /*\n\t\tthis is a set of atoms that are likely to belong to allene structures and\n\t\ttherefore should not be considered as potential stereocenters in the code below,\n\t\tas allenes cannot be encoded in the SMILES notation\n\t*/\n\n var alleneMask = new Pile()\n atoms.forEach((atom, aid) => {\n var neiList = this.getNeighbors.call(this.context, aid)\n if (neiList.length !== 2) return false\n var nei1 = neiList[0]\n var nei2 = neiList[1]\n // check atom labels\n if (\n [aid, nei1.aid, nei2.aid].findIndex(\n aid => ['C', 'Si'].indexOf(atoms.get(aid).label) < 0,\n this\n ) >= 0\n )\n return false\n\n // check adjacent bond types\n if (\n [nei1.bid, nei2.bid].findIndex(\n bid => bonds.get(bid).type !== Bond.PATTERN.TYPE.DOUBLE,\n this\n ) >= 0\n )\n return false\n\n // get the other neighbors of the two adjacent atoms except for the central atom\n var nei1nei = this.getNeighbors\n .call(this.context, nei1.aid)\n .filter(nei => nei.aid != aid)\n var nei2nei = this.getNeighbors\n .call(this.context, nei2.aid)\n .filter(nei => nei.aid != aid)\n if (\n nei1nei.length < 1 ||\n nei1nei.length > 2 ||\n nei2nei.length < 1 ||\n nei2nei.length > 2\n )\n return false\n\n if (\n nei1nei\n .concat(nei2nei)\n .findIndex(\n nei => bonds.get(nei.bid).type != Bond.PATTERN.TYPE.SINGLE,\n this\n ) >= 0\n )\n return false\n\n if (\n nei1nei\n .concat(nei2nei)\n .findIndex(\n nei => bonds.get(nei.bid).stereo == Bond.PATTERN.STEREO.EITHER,\n this\n ) >= 0\n )\n return false\n alleneMask.add(nei1.aid).add(nei2.aid)\n return true\n })\n\n if (alleneMask.size > 0)\n //TODO: add error handler call\n //legacy message: This structure may contain allenes, which cannot be represented in the SMILES notation. Relevant stereo-information will be discarded.\n\n atoms.forEach((atom, aid) => {\n if (alleneMask.has(aid)) return\n /*\n if (atom_types[atom_idx] == 0)\n continue;\n */\n var neiList = this.getNeighbors.call(this.context, aid)\n var stereocenter = false\n\n neiList.find(function (nei) {\n var bond = this.molecule.bonds.get(nei.bid)\n\n if (bond.type === Bond.PATTERN.TYPE.SINGLE && bond.begin == aid) {\n if (\n bond.stereo === Bond.PATTERN.STEREO.UP ||\n bond.stereo == Bond.PATTERN.STEREO.DOWN\n ) {\n stereocenter = true\n return true\n }\n }\n return false\n }, this)\n\n if (!stereocenter) return\n\n if (ignoreErrors)\n this.buildOneCenter(\n aid /* , atom_groups[atom_idx], atom_types[atom_idx], bond_orientations*/\n )\n else\n this.buildOneCenter(\n aid /* , atom_groups[atom_idx], atom_types[atom_idx], bond_orientations*/\n )\n })\n}\n\nStereocenters.allowed_stereocenters = [\n { elem: 'C', charge: 0, degree: 3, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'C', charge: 0, degree: 4, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'Si', charge: 0, degree: 3, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'Si', charge: 0, degree: 4, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'N', charge: 1, degree: 3, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'N', charge: 1, degree: 4, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'N', charge: 0, degree: 3, n_double_bonds: 0, implicit_degree: 3 },\n { elem: 'S', charge: 0, degree: 4, n_double_bonds: 2, implicit_degree: 4 },\n { elem: 'S', charge: 1, degree: 3, n_double_bonds: 0, implicit_degree: 3 },\n { elem: 'S', charge: 0, degree: 3, n_double_bonds: 1, implicit_degree: 3 },\n { elem: 'P', charge: 0, degree: 3, n_double_bonds: 0, implicit_degree: 3 },\n { elem: 'P', charge: 1, degree: 4, n_double_bonds: 0, implicit_degree: 4 },\n { elem: 'P', charge: 0, degree: 4, n_double_bonds: 1, implicit_degree: 4 }\n]\n\nStereocenters.prototype.buildOneCenter = function (\n atomIdx /* , int group, int type, const int *bond_orientations*/\n) {\n // eslint-disable-line max-statements\n var atom = this.molecule.atoms.get(atomIdx)\n\n var neiList = this.getNeighbors.call(this.context, atomIdx)\n var degree = neiList.length\n var implicitDegree = -1\n\n var stereocenter = {\n group: 0, // = group;\n type: 0, // = type;\n pyramid: []\n }\n\n var edgeIds = []\n\n var lastAtomDir = 0\n var nDoubleBonds = 0\n\n stereocenter.pyramid[0] = -1\n stereocenter.pyramid[1] = -1\n stereocenter.pyramid[2] = -1\n stereocenter.pyramid[3] = -1\n\n var nPureHydrogens = 0\n\n if (degree > 4)\n throw new Error('stereocenter with %d bonds are not supported' + degree)\n\n neiList.forEach((nei, neiIdx) => {\n var neiAtom = this.molecule.atoms.get(nei.aid)\n var bond = this.molecule.bonds.get(nei.bid)\n edgeIds[neiIdx] = {\n edge_idx: nei.bid,\n nei_idx: nei.aid,\n rank: nei.aid,\n vec: Vec2.diff(neiAtom.pp, atom.pp).yComplement()\n }\n\n if (neiAtom.pureHydrogen()) {\n nPureHydrogens++\n edgeIds[neiIdx].rank = 10000\n } else if (neiAtom.label === 'H') {\n edgeIds[neiIdx].rank = 5000\n }\n\n if (!edgeIds[neiIdx].vec.normalize()) throw new Error('zero bond length')\n\n if (bond.type === Bond.PATTERN.TYPE.TRIPLE)\n throw new Error('non-single bonds not allowed near stereocenter')\n else if (bond.type === Bond.PATTERN.TYPE.AROMATIC)\n throw new Error('aromatic bonds not allowed near stereocenter')\n else if (bond.type === Bond.PATTERN.TYPE.DOUBLE) nDoubleBonds++\n })\n\n Stereocenters.allowed_stereocenters.find(as => {\n if (\n as.elem === atom.label &&\n as.charge === atom.charge &&\n as.degree === degree &&\n as.n_double_bonds === nDoubleBonds\n ) {\n implicitDegree = as.implicit_degree\n return true\n }\n return false\n })\n\n if (implicitDegree === -1)\n throw new Error(\n 'unknown stereocenter configuration: ' +\n atom.label +\n ', charge ' +\n atom.charge +\n ', ' +\n degree +\n ' bonds (' +\n nDoubleBonds +\n ' double)'\n )\n\n if (degree === 4 && nPureHydrogens > 1)\n throw new Error(nPureHydrogens + ' hydrogens near stereocenter')\n\n if (degree === 3 && implicitDegree === 4 && nPureHydrogens > 0)\n throw new Error(\n 'have hydrogen(s) besides implicit hydrogen near stereocenter'\n )\n\n if (degree === 4) {\n // sort by neighbor atom index (ascending)\n if (edgeIds[0].rank > edgeIds[1].rank) swap(edgeIds, 0, 1)\n if (edgeIds[1].rank > edgeIds[2].rank) swap(edgeIds, 1, 2)\n if (edgeIds[2].rank > edgeIds[3].rank) swap(edgeIds, 2, 3)\n if (edgeIds[1].rank > edgeIds[2].rank) swap(edgeIds, 1, 2)\n if (edgeIds[0].rank > edgeIds[1].rank) swap(edgeIds, 0, 1)\n if (edgeIds[1].rank > edgeIds[2].rank) swap(edgeIds, 1, 2)\n\n var main1 = -1\n var main2 = -1\n var side1 = -1\n var side2 = -1\n var mainDir = 0\n\n for (var neiIdx = 0; neiIdx < 4; neiIdx++) {\n var stereo = this.getBondStereo(atomIdx, edgeIds[neiIdx].edge_idx)\n\n if (\n stereo === Bond.PATTERN.STEREO.UP ||\n stereo == Bond.PATTERN.STEREO.DOWN\n ) {\n main1 = neiIdx\n mainDir = stereo\n break\n }\n }\n\n if (main1 === -1)\n throw new Error('none of 4 bonds going from stereocenter is stereobond')\n\n var xyz1, xyz2\n\n // find main2 as opposite to main1\n if (main2 === -1) {\n xyz1 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 1) % 4].vec,\n edgeIds[(main1 + 2) % 4].vec\n )\n xyz2 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 1) % 4].vec,\n edgeIds[(main1 + 3) % 4].vec\n )\n\n if (xyz1 + xyz2 == 3 || xyz1 + xyz2 == 12) {\n main2 = (main1 + 1) % 4\n side1 = (main1 + 2) % 4\n side2 = (main1 + 3) % 4\n }\n }\n if (main2 == -1) {\n xyz1 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 2) % 4].vec,\n edgeIds[(main1 + 1) % 4].vec\n )\n xyz2 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 2) % 4].vec,\n edgeIds[(main1 + 3) % 4].vec\n )\n\n if (xyz1 + xyz2 == 3 || xyz1 + xyz2 == 12) {\n main2 = (main1 + 2) % 4\n side1 = (main1 + 1) % 4\n side2 = (main1 + 3) % 4\n }\n }\n if (main2 == -1) {\n xyz1 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 3) % 4].vec,\n edgeIds[(main1 + 1) % 4].vec\n )\n xyz2 = Stereocenters.xyzzy(\n edgeIds[main1].vec,\n edgeIds[(main1 + 3) % 4].vec,\n edgeIds[(main1 + 2) % 4].vec\n )\n\n if (xyz1 + xyz2 == 3 || xyz1 + xyz2 == 12) {\n main2 = (main1 + 3) % 4\n side1 = (main1 + 2) % 4\n side2 = (main1 + 1) % 4\n }\n }\n\n if (main2 == -1)\n throw new Error('internal error: can not find opposite bond')\n\n if (\n mainDir == Bond.PATTERN.STEREO.UP &&\n this.getBondStereo(atomIdx, edgeIds[main2].edge_idx) ==\n Bond.PATTERN.STEREO.DOWN\n )\n throw new Error('stereo types of the opposite bonds mismatch')\n if (\n mainDir == Bond.PATTERN.STEREO.DOWN &&\n this.getBondStereo(atomIdx, edgeIds[main2].edge_idx) ==\n Bond.PATTERN.STEREO.UP\n )\n throw new Error('stereo types of the opposite bonds mismatch')\n\n if (mainDir == this.getBondStereo(atomIdx, edgeIds[side1].edge_idx))\n throw new Error('stereo types of non-opposite bonds match')\n if (mainDir == this.getBondStereo(atomIdx, edgeIds[side2].edge_idx))\n throw new Error('stereo types of non-opposite bonds match')\n\n if (main1 == 3 || main2 == 3) lastAtomDir = mainDir\n else\n lastAtomDir =\n mainDir == Bond.PATTERN.STEREO.UP\n ? Bond.PATTERN.STEREO.DOWN\n : Bond.PATTERN.STEREO.UP\n\n sign = Stereocenters.sign(edgeIds[0].vec, edgeIds[1].vec, edgeIds[2].vec)\n\n if (\n (lastAtomDir == Bond.PATTERN.STEREO.UP && sign > 0) ||\n (lastAtomDir == Bond.PATTERN.STEREO.DOWN && sign < 0)\n ) {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[1].nei_idx\n stereocenter.pyramid[2] = edgeIds[2].nei_idx\n } else {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[2].nei_idx\n stereocenter.pyramid[2] = edgeIds[1].nei_idx\n }\n\n stereocenter.pyramid[3] = edgeIds[3].nei_idx\n } else if (degree === 3) {\n // sort by neighbor atom index (ascending)\n if (edgeIds[0].rank > edgeIds[1].rank) swap(edgeIds, 0, 1)\n if (edgeIds[1].rank > edgeIds[2].rank) swap(edgeIds, 1, 2)\n if (edgeIds[0].rank > edgeIds[1].rank) swap(edgeIds, 0, 1)\n\n var stereo0 = this.getBondStereo(atomIdx, edgeIds[0].edge_idx)\n var stereo1 = this.getBondStereo(atomIdx, edgeIds[1].edge_idx)\n var stereo2 = this.getBondStereo(atomIdx, edgeIds[2].edge_idx)\n\n var nUp = 0\n var nDown = 0\n\n nUp += stereo0 === Bond.PATTERN.STEREO.UP ? 1 : 0\n nUp += stereo1 === Bond.PATTERN.STEREO.UP ? 1 : 0\n nUp += stereo2 === Bond.PATTERN.STEREO.UP ? 1 : 0\n\n nDown += stereo0 === Bond.PATTERN.STEREO.DOWN ? 1 : 0\n nDown += stereo1 === Bond.PATTERN.STEREO.DOWN ? 1 : 0\n nDown += stereo2 === Bond.PATTERN.STEREO.DOWN ? 1 : 0\n\n if (implicitDegree == 4) {\n // have implicit hydrogen\n if (nUp == 3) throw new Error('all 3 bonds up near stereoatom')\n if (nDown == 3) throw new Error('all 3 bonds down near stereoatom')\n\n if (nUp == 0 && nDown == 0)\n throw new Error('no up/down bonds near stereoatom -- indefinite case')\n if (nUp == 1 && nDown == 1)\n throw new Error('one bond up, one bond down -- indefinite case')\n\n mainDir = 0\n\n if (nUp == 2) {\n lastAtomDir = Bond.PATTERN.STEREO.DOWN\n } else if (nDown == 2) {\n lastAtomDir = Bond.PATTERN.STEREO.UP\n } else {\n main1 = -1\n side1 = -1\n side2 = -1\n\n for (neiIdx = 0; neiIdx < 3; neiIdx++) {\n dir = this.getBondStereo(atomIdx, edgeIds[neiIdx].edge_idx)\n\n if (\n dir == Bond.PATTERN.STEREO.UP ||\n dir == Bond.PATTERN.STEREO.DOWN\n ) {\n // eslint-disable-line max-depth\n main1 = neiIdx\n mainDir = dir\n side1 = (neiIdx + 1) % 3\n side2 = (neiIdx + 2) % 3\n break\n }\n }\n\n if (main1 == -1)\n throw new Error('internal error: can not find up or down bond')\n\n var xyz = Stereocenters.xyzzy(\n edgeIds[side1].vec,\n edgeIds[side2].vec,\n edgeIds[main1].vec\n )\n\n if (xyz == 3 || xyz == 4)\n throw new Error('degenerate case for 3 bonds near stereoatom')\n\n if (xyz == 1) lastAtomDir = mainDir\n else\n lastAtomDir =\n mainDir == Bond.PATTERN.STEREO.UP\n ? Bond.PATTERN.STEREO.DOWN\n : Bond.PATTERN.STEREO.UP\n }\n\n var sign = Stereocenters.sign(\n edgeIds[0].vec,\n edgeIds[1].vec,\n edgeIds[2].vec\n )\n\n if (\n (lastAtomDir == Bond.PATTERN.STEREO.UP && sign > 0) ||\n (lastAtomDir == Bond.PATTERN.STEREO.DOWN && sign < 0)\n ) {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[1].nei_idx\n stereocenter.pyramid[2] = edgeIds[2].nei_idx\n } else {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[2].nei_idx\n stereocenter.pyramid[2] = edgeIds[1].nei_idx\n }\n\n stereocenter.pyramid[3] = -1\n } else {\n // 3-connected P, N or S; no implicit hydrogens\n var dir\n\n if (nDown > 0 && nUp > 0)\n throw new Error('one bond up, one bond down -- indefinite case')\n else if (nDown == 0 && nUp == 0)\n throw new Error('no up-down bonds attached to stereocenter')\n else if (nUp > 0) dir = 1\n else dir = -1\n\n if (\n Stereocenters.xyzzy(edgeIds[0].vec, edgeIds[1].vec, edgeIds[2].vec) ===\n 1 ||\n Stereocenters.xyzzy(edgeIds[0].vec, edgeIds[2].vec, edgeIds[1].vec) ===\n 1 ||\n Stereocenters.xyzzy(edgeIds[2].vec, edgeIds[1].vec, edgeIds[0].vec) ===\n 1\n )\n // all bonds belong to the same half-plane\n dir = -dir\n\n sign = Stereocenters.sign(edgeIds[0].vec, edgeIds[1].vec, edgeIds[2].vec)\n\n if (sign == dir) {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[2].nei_idx\n stereocenter.pyramid[2] = edgeIds[1].nei_idx\n } else {\n stereocenter.pyramid[0] = edgeIds[0].nei_idx\n stereocenter.pyramid[1] = edgeIds[1].nei_idx\n stereocenter.pyramid[2] = edgeIds[2].nei_idx\n }\n stereocenter.pyramid[3] = -1\n }\n }\n this.atoms.set(atomIdx, stereocenter)\n}\n\nStereocenters.prototype.getBondStereo = function (centerIdx, edgeIdx) {\n var bond = this.molecule.bonds.get(edgeIdx)\n\n if (centerIdx != bond.begin)\n // TODO: check this\n return 0\n\n return bond.stereo\n}\n\n// 1 -- in the smaller angle, 2 -- in the bigger angle,\n// 4 -- in the 'positive' straight angle, 8 -- in the 'negative' straight angle\nStereocenters.xyzzy = function (v1, v2, u) {\n var eps = 0.001\n\n var sine1 = Vec2.cross(v1, v2)\n var cosine1 = Vec2.dot(v1, v2)\n\n var sine2 = Vec2.cross(v1, u)\n var cosine2 = Vec2.dot(v1, u)\n\n if (Math.abs(sine1) < eps) {\n if (Math.abs(sine2) < eps)\n throw new Error('degenerate case -- bonds overlap')\n\n return sine2 > 0 ? 4 : 8\n }\n\n if (sine1 * sine2 < -eps * eps) return 2\n\n if (cosine2 < cosine1) return 2\n\n return 1\n}\n\nStereocenters.sign = function (v1, v2, v3) {\n var res = (v1.x - v3.x) * (v2.y - v3.y) - (v1.y - v3.y) * (v2.x - v3.x) // eslint-disable-line no-mixed-operators\n var eps = 0.001\n\n if (res > eps) return 1\n if (res < -eps) return -1\n\n throw new Error('degenerate triangle')\n}\n\nStereocenters.isPyramidMappingRigid = function (mapping) {\n var arr = mapping.slice()\n var rigid = true\n\n if (arr[0] > arr[1]) {\n swap(arr, 0, 1)\n rigid = !rigid\n }\n if (arr[1] > arr[2]) {\n swap(arr, 1, 2)\n rigid = !rigid\n }\n if (arr[2] > arr[3]) {\n swap(arr, 2, 3)\n rigid = !rigid\n }\n if (arr[1] > arr[2]) {\n swap(arr, 1, 2)\n rigid = !rigid\n }\n if (arr[0] > arr[1]) {\n swap(arr, 0, 1)\n rigid = !rigid\n }\n if (arr[1] > arr[2]) {\n swap(arr, 1, 2)\n rigid = !rigid\n }\n\n return rigid\n}\n\nfunction swap(arr, i1, i2) {\n var tmp = arr[i1]\n arr[i1] = arr[i2]\n arr[i2] = tmp\n}\n\nexport default Stereocenters\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, Bond, Pile, SGroup } from 'domain/entities'\n\nimport CisTrans from './cis_trans'\nimport Dfs from './dfs'\nimport Stereocenters from './stereocenters'\n\nexport function Smiles() {\n this.smiles = ''\n this.writtenAtoms = []\n this.writtenComponents = 0\n\n this.ignoreErrors = false\n}\n\nSmiles._Atom = function (hCount) {\n // eslint-disable-line no-underscore-dangle\n this.neighbours = [] // Array of integer pairs {a, b}\n this.aromatic = false // has aromatic bond\n this.lowercase = false // aromatic and has to be written lowercase\n this.chirality = 0 // 0 means no chirality, 1 means CCW pyramid, 2 means CW pyramid\n this.branch_cnt = 0 // runs from 0 to (branches - 1)\n this.paren_written = false\n this.h_count = hCount\n this.parent = -1\n}\n\n// NB: only loops of length up to 6 are included here\nSmiles.prototype.isBondInRing = function (bid) {\n return this.inLoop[bid]\n}\n\nSmiles.prototype.saveMolecule = function (struct, ignoreErrors) {\n // eslint-disable-line max-statements\n var i, j, k\n\n if (!ignoreErrors) this.ignoreErrors = ignoreErrors\n\n // [RB]: KETCHER-498 (Incorrect smile-string for multiple Sgroup)\n // TODO the fix is temporary, still need to implement error handling/reporting\n // BEGIN\n struct = struct.clone(\n undefined,\n undefined,\n !struct.hasRxnArrow(), // make it drop multiple reactions\n undefined,\n undefined,\n undefined\n )\n struct.initHalfBonds()\n struct.initNeighbors()\n struct.sortNeighbors()\n struct.setImplicitHydrogen()\n struct.sgroups.forEach(sg => {\n if (sg.type === 'MUL') {\n try {\n SGroup.prepareMulForSaving(sg, struct)\n } catch (ex) {\n throw Error('Bad s-group (' + ex.message + ')')\n }\n }\n // 'SMILES data format doesn\\'t support s-groups'\n })\n // END\n\n this.atoms = new Array(struct.atoms.size)\n\n struct.atoms.forEach((atom, aid) => {\n this.atoms[aid] = new Smiles._Atom(atom.implicitH) // eslint-disable-line no-underscore-dangle\n })\n\n // From the SMILES specification:\n // Please note that only atoms on the following list\n // can be considered aromatic: C, N, O, P, S, As, Se, and * (wildcard).\n var allowedLowercase = ['B', 'C', 'N', 'O', 'P', 'S', 'Se', 'As']\n\n // Detect atoms that have aromatic bonds and count neighbours\n struct.bonds.forEach((bond, bid) => {\n if (bond.type === Bond.PATTERN.TYPE.AROMATIC) {\n this.atoms[bond.begin].aromatic = true\n if (allowedLowercase.indexOf(struct.atoms.get(bond.begin).label) !== -1)\n this.atoms[bond.begin].lowercase = true\n this.atoms[bond.end].aromatic = true\n if (allowedLowercase.indexOf(struct.atoms.get(bond.end).label) !== -1)\n this.atoms[bond.end].lowercase = true\n }\n this.atoms[bond.begin].neighbours.push({ aid: bond.end, bid })\n this.atoms[bond.end].neighbours.push({ aid: bond.begin, bid })\n })\n\n this.inLoop = (function () {\n struct.prepareLoopStructure()\n let bondsInLoops = new Pile()\n struct.loops.forEach(loop => {\n if (loop.hbs.length <= 6) {\n const hbids = loop.hbs.map(hbid => struct.halfBonds.get(hbid).bid)\n bondsInLoops = bondsInLoops.union(new Pile(hbids))\n }\n })\n const inLoop = {}\n bondsInLoops.forEach(bid => {\n inLoop[bid] = 1\n })\n return inLoop\n })()\n\n this.touchedCistransbonds = 0\n this.markCisTrans(struct)\n\n var components = struct.getComponents()\n var componentsAll = components.reactants.concat(components.products)\n\n var walk = new Dfs(\n struct,\n this.atoms,\n componentsAll,\n components.reactants.length\n )\n\n walk.walk()\n this.atoms.forEach(atom => {\n atom.neighbours = []\n })\n\n // fill up neighbor lists for the stereocenters calculation\n for (i = 0; i < walk.v_seq.length; i++) {\n var seqEl = walk.v_seq[i]\n var vIdx = seqEl.idx\n var eIdx = seqEl.parent_edge\n var vPrevIdx = seqEl.parent_vertex\n\n if (eIdx >= 0) {\n var atom = this.atoms[vIdx]\n\n var openingCycles = walk.numOpeningCycles(eIdx)\n\n for (j = 0; j < openingCycles; j++)\n this.atoms[vPrevIdx].neighbours.push({ aid: -1, bid: -1 })\n\n if (walk.edgeClosingCycle(eIdx)) {\n for (k = 0; k < atom.neighbours.length; k++) {\n if (atom.neighbours[k].aid === -1) {\n // eslint-disable-line max-depth\n atom.neighbours[k].aid = vPrevIdx\n atom.neighbours[k].bid = eIdx\n break\n }\n }\n if (k === atom.neighbours.length)\n throw new Error('internal: can not put closing bond to its place')\n } else {\n atom.neighbours.push({ aid: vPrevIdx, bid: eIdx })\n atom.parent = vPrevIdx\n }\n this.atoms[vPrevIdx].neighbours.push({ aid: vIdx, bid: eIdx })\n }\n }\n\n try {\n // detect chiral configurations\n var stereocenters = new Stereocenters(\n struct,\n function (idx) {\n return this.atoms[idx].neighbours\n },\n this\n )\n stereocenters.buildFromBonds(this.ignoreErrors)\n\n stereocenters.each((sc, atomIdx) => {\n // eslint-disable-line max-statements\n // if (sc.type < MoleculeStereocenters::ATOM_AND)\n // continue;\n\n var implicitHIdx = -1\n\n if (sc.pyramid[3] == -1) implicitHIdx = 3\n /*\n\t\t\telse for (j = 0; j < 4; j++)\n\t\t\t\tif (ignored_vertices[pyramid[j]])\n\t\t\t\t{\n\t\t\t\t\timplicit_h_idx = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t*/\n\n var pyramidMapping = []\n var counter = 0\n\n var atom = this.atoms[atomIdx]\n\n if (atom.parent != -1) {\n for (k = 0; k < 4; k++) {\n if (sc.pyramid[k] == atom.parent) {\n pyramidMapping[counter++] = k\n break\n }\n }\n }\n\n if (implicitHIdx !== -1) pyramidMapping[counter++] = implicitHIdx\n\n for (j = 0; j !== atom.neighbours.length; j++) {\n if (atom.neighbours[j].aid == atom.parent) continue // eslint-disable-line no-continue\n\n for (k = 0; k < 4; k++) {\n if (atom.neighbours[j].aid == sc.pyramid[k]) {\n if (counter >= 4) throw new Error('internal: pyramid overflow')\n pyramidMapping[counter++] = k\n break\n }\n }\n }\n\n if (counter === 4) {\n // move the 'from' atom to the end\n counter = pyramidMapping[0]\n pyramidMapping[0] = pyramidMapping[1]\n pyramidMapping[1] = pyramidMapping[2]\n pyramidMapping[2] = pyramidMapping[3]\n pyramidMapping[3] = counter\n } else if (counter !== 3) {\n throw new Error('cannot calculate chirality')\n }\n\n if (Stereocenters.isPyramidMappingRigid(pyramidMapping))\n this.atoms[atomIdx].chirality = 1\n else this.atoms[atomIdx].chirality = 2\n })\n } catch (ex) {\n //TODO: add error handler call\n }\n\n // write the SMILES itself\n\n // cycle_numbers[i] == -1 means that the number is available\n // cycle_numbers[i] == n means that the number is used by vertex n\n var cycleNumbers = []\n\n cycleNumbers.push(0) // never used\n\n var firstComponent = true\n\n for (i = 0; i < walk.v_seq.length; i++) {\n seqEl = walk.v_seq[i]\n vIdx = seqEl.idx\n eIdx = seqEl.parent_edge\n vPrevIdx = seqEl.parent_vertex\n var writeAtom = true\n\n if (vPrevIdx >= 0) {\n if (walk.numBranches(vPrevIdx) > 1) {\n if (\n this.atoms[vPrevIdx].branch_cnt > 0 &&\n this.atoms[vPrevIdx].paren_written\n )\n this.smiles += ')'\n }\n\n openingCycles = walk.numOpeningCycles(eIdx)\n\n for (j = 0; j < openingCycles; j++) {\n for (k = 1; k < cycleNumbers.length; k++) {\n if (cycleNumbers[k] == -1)\n // eslint-disable-line max-depth\n break\n }\n if (k === cycleNumbers.length) cycleNumbers.push(vPrevIdx)\n else cycleNumbers[k] = vPrevIdx\n\n this.writeCycleNumber(k)\n }\n\n if (vPrevIdx >= 0) {\n var branches = walk.numBranches(vPrevIdx)\n\n if (branches > 1 && this.atoms[vPrevIdx].branch_cnt < branches - 1) {\n if (walk.edgeClosingCycle(eIdx)) {\n // eslint-disable-line max-depth\n this.atoms[vPrevIdx].paren_written = false\n } else {\n this.smiles += '('\n this.atoms[vPrevIdx].paren_written = true\n }\n }\n\n this.atoms[vPrevIdx].branch_cnt++\n\n if (this.atoms[vPrevIdx].branch_cnt > branches)\n throw new Error('unexpected branch')\n }\n\n var bond = struct.bonds.get(eIdx)\n\n var dir = 0\n\n if (bond.type == Bond.PATTERN.TYPE.SINGLE)\n dir = this.calcBondDirection(struct, eIdx, vPrevIdx)\n\n if ((dir == 1 && vIdx == bond.end) || (dir == 2 && vIdx == bond.begin))\n this.smiles += '/'\n else if (\n (dir == 2 && vIdx == bond.end) ||\n (dir == 1 && vIdx == bond.begin)\n )\n this.smiles += '\\\\'\n else if (bond.type == Bond.PATTERN.TYPE.ANY) {\n this.smiles += '~'\n } else if (bond.type == Bond.PATTERN.TYPE.DOUBLE) {\n this.smiles += '='\n } else if (bond.type == Bond.PATTERN.TYPE.TRIPLE) {\n this.smiles += '#'\n } else if (bond.type == Bond.PATTERN.TYPE.SINGLE_OR_AROMATIC) {\n this.smiles += '-,:'\n } else if (bond.type == Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC) {\n this.smiles += '=,:'\n } else if (bond.type == Bond.PATTERN.TYPE.SINGLE_OR_DOUBLE) {\n this.smiles += '-,='\n } else if (\n bond.type == Bond.PATTERN.TYPE.AROMATIC &&\n (!this.atoms[bond.begin].lowercase ||\n !this.atoms[bond.end].lowercase ||\n !this.isBondInRing(eIdx))\n )\n this.smiles += ':'\n // TODO: Check if this : is needed\n else if (\n bond.type == Bond.PATTERN.TYPE.SINGLE &&\n this.atoms[bond.begin].aromatic &&\n this.atoms[bond.end].aromatic\n )\n this.smiles += '-'\n\n if (walk.edgeClosingCycle(eIdx)) {\n for (j = 1; j < cycleNumbers.length; j++) {\n if (cycleNumbers[j] == vIdx) break\n }\n\n if (j === cycleNumbers.length) throw new Error('cycle number not found')\n\n this.writeCycleNumber(j)\n\n cycleNumbers[j] = -1\n writeAtom = false\n }\n } else {\n if (!firstComponent) {\n this.smiles +=\n this.writtenComponents === walk.nComponentsInReactants &&\n walk.nReactants !== 0\n ? '>>'\n : '.' // when walk.nReactants === 0 - not reaction\n }\n firstComponent = false\n this.writtenComponents++\n }\n if (writeAtom) {\n this.writeAtom(\n struct,\n vIdx,\n this.atoms[vIdx].aromatic,\n this.atoms[vIdx].lowercase,\n this.atoms[vIdx].chirality\n )\n this.writtenAtoms.push(seqEl.idx)\n }\n }\n\n this.comma = false\n\n // this._writeStereogroups(mol, atoms);\n this.writeRadicals(struct)\n // this._writePseudoAtoms(mol);\n // this._writeHighlighting();\n\n if (this.comma) this.smiles += '|'\n\n return this.smiles\n}\n\nSmiles.prototype.writeCycleNumber = function (n) {\n if (n > 0 && n < 10) this.smiles += n\n else if (n >= 10 && n < 100) this.smiles += '%' + n\n else if (n >= 100 && n < 1000) this.smiles += '%%' + n\n else throw new Error('bad cycle number: ' + n)\n}\n\nSmiles.prototype.writeAtom = function (\n mol,\n idx,\n aromatic,\n lowercase,\n chirality\n) {\n // eslint-disable-line max-params, max-statements\n var atom = mol.atoms.get(idx)\n var needBrackets = false\n var hydro = -1\n var aam = 0\n\n /*\n\tif (mol.haveQueryAtoms())\n\t{\n\t query_atom = &mol.getQueryAtom(idx);\n\n\t if (query_atom->type == QUERY_ATOM_RGROUP)\n\t {\n\t\t if (mol.getRGroups()->isRGroupAtom(idx))\n\t\t {\n\t\t\tconst Array &rg = mol.getRGroups()->getSiteRGroups(idx);\n\n\t\t\tif (rg.length != 1)\n\t\t\t throw Error(\"rgroup count %d\", rg.length);\n\n\t\t\t_output.printf(\"[&%d]\", rg[0] + 1);\n\t\t }\n\t\t else\n\t\t\t_output.printf(\"[&%d]\", 1);\n\n\t\t return;\n\t }\n\t}\n\t*/\n\n if (atom.label === 'A') {\n this.smiles += '*'\n return\n }\n\n if (atom.label === 'R' || atom.label === 'R#') {\n this.smiles += '[*]'\n return\n }\n\n // KETCHER-598 (Ketcher does not save AAM into reaction SMILES)\n // BEGIN\n // if (this.atom_atom_mapping)\n // aam = atom_atom_mapping[idx];\n aam = atom.aam\n // END\n\n if (\n atom.label !== 'C' &&\n atom.label !== 'P' &&\n atom.label !== 'N' &&\n atom.label !== 'S' &&\n atom.label !== 'O' &&\n atom.label !== 'Cl' &&\n atom.label !== 'F' &&\n atom.label !== 'Br' &&\n atom.label !== 'B' &&\n atom.label !== 'I'\n )\n needBrackets = true\n\n if (\n atom.explicitValence >= 0 ||\n atom.radical !== 0 ||\n chirality > 0 ||\n (aromatic && atom.label !== 'C' && atom.label !== 'O') ||\n (aromatic &&\n atom.label === 'C' &&\n this.atoms[idx].neighbours.length < 3 &&\n this.atoms[idx].h_count === 0)\n )\n hydro = this.atoms[idx].h_count\n\n var label = atom.label\n if (atom.atomList && !atom.atomList.notList) {\n label = atom.atomList.label()\n needBrackets = false // atom list label already has brackets\n } else if (atom.isPseudo() || (atom.atomList && atom.atomList.notList)) {\n label = '*'\n needBrackets = false\n } else if (\n chirality ||\n atom.charge !== 0 ||\n atom.isotope > 0 ||\n hydro >= 0 ||\n aam > 0\n ) {\n needBrackets = true\n }\n\n if (needBrackets) {\n if (hydro === -1) hydro = this.atoms[idx].h_count\n this.smiles += '['\n }\n\n if (atom.isotope > 0) this.smiles += atom.isotope\n\n if (lowercase) this.smiles += label.toLowerCase()\n else this.smiles += label\n\n if (chirality > 0) {\n if (chirality === 1) this.smiles += '@'\n // chirality == 2\n else this.smiles += '@@'\n\n if (atom.implicitH > 1)\n throw new Error(atom.implicitH + ' implicit H near stereocenter')\n }\n\n if (atom.label !== 'H') {\n if (hydro > 1 || (hydro === 0 && !needBrackets)) this.smiles += 'H' + hydro\n else if (hydro === 1) this.smiles += 'H'\n }\n\n if (atom.charge > 1) this.smiles += '+' + atom.charge\n else if (atom.charge < -1) this.smiles += atom.charge\n else if (atom.charge === 1) this.smiles += '+'\n else if (atom.charge === -1) this.smiles += '-'\n\n if (aam > 0) this.smiles += ':' + aam\n\n if (needBrackets) this.smiles += ']'\n\n /*\n\tif (mol.getRGroupFragment() != 0)\n\t{\n\t for (i = 0; i < 2; i++)\n\t {\n\t\t int j;\n\n\t\t for (j = 0; mol.getRGroupFragment()->getAttachmentPoint(i, j) != -1; j++)\n\t\t\tif (idx == mol.getRGroupFragment()->getAttachmentPoint(i, j))\n\t\t\t{\n\t\t\t _output.printf(\"([*])\");\n\t\t\t break;\n\t\t\t}\n\n\t\t if (mol.getRGroupFragment()->getAttachmentPoint(i, j) != -1)\n\t\t\tbreak;\n\t }\n\t}\n\t*/\n}\n\nSmiles.prototype.markCisTrans = function (mol) {\n this.cis_trans = new CisTrans(\n mol,\n function (idx) {\n return this.atoms[idx].neighbours\n },\n this\n )\n this.cis_trans.build()\n this.dbonds = new Array(mol.bonds.size)\n\n mol.bonds.forEach((bond, bid) => {\n this.dbonds[bid] = {\n ctbond_beg: -1,\n ctbond_end: -1,\n saved: 0\n }\n })\n\n this.cis_trans.each((ct, bid) => {\n var bond = mol.bonds.get(bid)\n\n if (ct.parity !== 0 && !this.isBondInRing(bid)) {\n var neiBeg = this.atoms[bond.begin].neighbours\n var neiEnd = this.atoms[bond.end].neighbours\n var aromFailBeg = true\n var aromFailEnd = true\n\n neiBeg.forEach(nei => {\n if (\n nei.bid !== bid &&\n mol.bonds.get(nei.bid).type === Bond.PATTERN.TYPE.SINGLE\n )\n aromFailBeg = false\n })\n\n neiEnd.forEach(nei => {\n if (\n nei.bid !== bid &&\n mol.bonds.get(nei.bid).type === Bond.PATTERN.TYPE.SINGLE\n )\n aromFailEnd = false\n })\n\n if (aromFailBeg || aromFailEnd) return\n\n neiBeg.forEach(nei => {\n if (nei.bid === bid) return\n if (mol.bonds.get(nei.bid).begin === bond.begin)\n this.dbonds[nei.bid].ctbond_beg = bid\n else this.dbonds[nei.bid].ctbond_end = bid\n })\n\n neiEnd.forEach(nei => {\n if (nei.bid === bid) return\n if (mol.bonds.get(nei.bid).begin === bond.end)\n this.dbonds[nei.bid].ctbond_beg = bid\n else this.dbonds[nei.bid].ctbond_end = bid\n })\n }\n })\n}\n\nSmiles.prototype.updateSideBonds = function (mol, bondIdx) {\n // eslint-disable-line max-statements\n var bond = mol.bonds.get(bondIdx)\n var subst = this.cis_trans.getSubstituents(bondIdx)\n var parity = this.cis_trans.getParity(bondIdx)\n\n var sidebonds = [-1, -1, -1, -1]\n\n sidebonds[0] = mol.findBondId(subst[0], bond.begin)\n if (subst[1] != -1) sidebonds[1] = mol.findBondId(subst[1], bond.begin)\n\n sidebonds[2] = mol.findBondId(subst[2], bond.end)\n if (subst[3] != -1) sidebonds[3] = mol.findBondId(subst[3], bond.end)\n\n var n1 = 0\n var n2 = 0\n var n3 = 0\n var n4 = 0\n\n if (this.dbonds[sidebonds[0]].saved != 0) {\n if (\n (this.dbonds[sidebonds[0]].saved == 1 &&\n mol.bonds.get(sidebonds[0]).begin == bond.begin) ||\n (this.dbonds[sidebonds[0]].saved == 2 &&\n mol.bonds.get(sidebonds[0]).end == bond.begin)\n )\n n1++\n else n2++\n }\n if (sidebonds[1] != -1 && this.dbonds[sidebonds[1]].saved != 0) {\n if (\n (this.dbonds[sidebonds[1]].saved == 2 &&\n mol.bonds.get(sidebonds[1]).begin == bond.begin) ||\n (this.dbonds[sidebonds[1]].saved == 1 &&\n mol.bonds.get(sidebonds[1]).end == bond.begin)\n )\n n1++\n else n2++\n }\n if (this.dbonds[sidebonds[2]].saved != 0) {\n if (\n (this.dbonds[sidebonds[2]].saved == 1 &&\n mol.bonds.get(sidebonds[2]).begin == bond.end) ||\n (this.dbonds[sidebonds[2]].saved == 2 &&\n mol.bonds.get(sidebonds[2]).end == bond.end)\n )\n n3++\n else n4++\n }\n if (sidebonds[3] != -1 && this.dbonds[sidebonds[3]].saved != 0) {\n if (\n (this.dbonds[sidebonds[3]].saved == 2 &&\n mol.bonds.get(sidebonds[3]).begin == bond.end) ||\n (this.dbonds[sidebonds[3]].saved == 1 &&\n mol.bonds.get(sidebonds[3]).end == bond.end)\n )\n n3++\n else n4++\n }\n\n if (parity == CisTrans.PARITY.CIS) {\n n1 += n3\n n2 += n4\n } else {\n n1 += n4\n n2 += n3\n }\n\n if (n1 > 0 && n2 > 0) throw new Error('incompatible cis-trans configuration')\n\n if (n1 === 0 && n2 === 0) return false\n\n if (n1 > 0) {\n this.dbonds[sidebonds[0]].saved =\n mol.bonds.get(sidebonds[0]).begin == bond.begin ? 1 : 2\n if (sidebonds[1] != -1) {\n this.dbonds[sidebonds[1]].saved =\n mol.bonds.get(sidebonds[1]).begin == bond.begin ? 2 : 1\n }\n\n this.dbonds[sidebonds[2]].saved =\n (mol.bonds.get(sidebonds[2]).begin == bond.end) ==\n (parity == CisTrans.PARITY.CIS)\n ? 1\n : 2\n if (sidebonds[3] != -1) {\n this.dbonds[sidebonds[3]].saved =\n (mol.bonds.get(sidebonds[3]).begin == bond.end) ==\n (parity == CisTrans.PARITY.CIS)\n ? 2\n : 1\n }\n }\n if (n2 > 0) {\n this.dbonds[sidebonds[0]].saved =\n mol.bonds.get(sidebonds[0]).begin == bond.begin ? 2 : 1\n if (sidebonds[1] != -1) {\n this.dbonds[sidebonds[1]].saved =\n mol.bonds.get(sidebonds[1]).begin == bond.begin ? 1 : 2\n }\n\n this.dbonds[sidebonds[2]].saved =\n (mol.bonds.get(sidebonds[2]).begin == bond.end) ==\n (parity == CisTrans.PARITY.CIS)\n ? 2\n : 1\n if (sidebonds[3] != -1) {\n this.dbonds[sidebonds[3]].saved =\n (mol.bonds.get(sidebonds[3]).begin == bond.end) ==\n (parity == CisTrans.PARITY.CIS)\n ? 1\n : 2\n }\n }\n\n return true\n}\n\nSmiles.prototype.calcBondDirection = function (mol, idx, vprev) {\n var ntouched\n\n if (this.dbonds[idx].ctbond_beg == -1 && this.dbonds[idx].ctbond_end == -1)\n return 0\n\n if (mol.bonds.get(idx).type != Bond.PATTERN.TYPE.SINGLE)\n throw new Error('internal: directed bond type ' + mol.bonds.get(idx).type)\n\n while (true) {\n // eslint-disable-line no-constant-condition\n ntouched = 0\n this.cis_trans.each((ct, bid) => {\n if (ct.parity !== 0 && !this.isBondInRing(bid)) {\n if (this.updateSideBonds(mol, bid)) ntouched++\n }\n })\n if (ntouched === this.touchedCistransbonds) break\n this.touchedCistransbonds = ntouched\n }\n\n if (this.dbonds[idx].saved === 0) {\n if (vprev === mol.bonds.get(idx).begin) this.dbonds[idx].saved = 1\n else this.dbonds[idx].saved = 2\n }\n\n return this.dbonds[idx].saved\n}\n\nSmiles.prototype.writeRadicals = function (mol) {\n // eslint-disable-line max-statements\n var marked = new Array(this.writtenAtoms.length)\n var i, j\n\n for (i = 0; i < this.writtenAtoms.length; i++) {\n if (marked[i]) continue // eslint-disable-line no-continue\n\n var radical = mol.atoms.get(this.writtenAtoms[i]).radical\n\n if (radical === 0) continue // eslint-disable-line no-continue\n\n if (this.comma) {\n this.smiles += ','\n } else {\n this.smiles += ' |'\n this.comma = true\n }\n\n if (radical == Atom.PATTERN.RADICAL.SINGLET) this.smiles += '^3:'\n else if (radical == Atom.PATTERN.RADICAL.DOUPLET) this.smiles += '^1:'\n // RADICAL_TRIPLET\n else this.smiles += '^4:'\n\n this.smiles += i\n\n for (j = i + 1; j < this.writtenAtoms.length; j++) {\n if (mol.atoms.get(this.writtenAtoms[j]).radical === radical) {\n marked[j] = true\n this.smiles += ',' + j\n }\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Serializer } from '../serializers.types'\nimport { SmiSerializerOptions } from './smi.types'\nimport { Smiles } from './smiles'\nimport { Struct } from 'domain/entities'\n\nexport class SmiSerializer implements Serializer {\n static DefaultOptions: SmiSerializerOptions = {\n ignoreErrors: false\n }\n\n private readonly options: SmiSerializerOptions\n\n constructor(options?: Partial) {\n this.options = { ...SmiSerializer.DefaultOptions, ...options }\n }\n\n deserialize(_content: string): Struct {\n throw new Error('Not implemented yet.')\n }\n\n serialize(struct: Struct): string {\n return new Smiles().saveMolecule(struct, this.options.ignoreErrors)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { SdfItem, StructAssociatedData } from './sdf.types'\n\nimport { MolSerializer } from '../mol/molSerializer'\nimport { Serializer } from '../serializers.types'\n\nconst DelimeterRegex = /^[^]+?\\$\\$\\$\\$$/gm\nexport class SdfSerializer implements Serializer> {\n deserialize(content: string): Array {\n let m: any\n const result: Array = []\n const molSerializer = new MolSerializer()\n while ((m = DelimeterRegex.exec(content)) !== null) {\n const chunk = m[0].replace(/\\r/g, '').trim() // TODO: normalize newline?\n var end = chunk.indexOf('M END')\n if (end !== -1) {\n const propChunks: any = chunk\n .substr(end + 7)\n .trim()\n .split(/^$\\n?/m)\n\n const struct = molSerializer.deserialize(chunk.substring(0, end + 6))\n const props = propChunks.reduce(\n (acc: StructAssociatedData, pc: string) => {\n var m = pc.match(/^> [ \\d]*<(\\S+)>/)\n if (m) {\n const field = m[1]\n const value = pc.split('\\n')[1].trim()\n acc[field] = Number.isFinite(value) ? +value : value.toString() // eslint-disable-line\n }\n return acc\n },\n {} as StructAssociatedData\n )\n\n result.push({ struct, props })\n }\n }\n return result\n }\n\n serialize(sdfItems: Array): string {\n const molSerializer = new MolSerializer()\n return sdfItems.reduce((res, item) => {\n res += molSerializer.serialize(item.struct)\n\n Object.keys(item.props).forEach(prop => {\n res += '> <' + prop + '>\\n'\n res += item.props[prop] + '\\n\\n'\n })\n\n return res + '$$$$'\n }, '')\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport enum ChemicalMimeType {\n Mol = 'chemical/x-mdl-molfile',\n Rxn = 'chemical/x-mdl-rxnfile',\n DaylightSmiles = 'chemical/x-daylight-smiles',\n ExtendedSmiles = 'chemical/x-chemaxon-cxsmiles',\n DaylightSmarts = 'chemical/x-daylight-smarts',\n InChI = 'chemical/x-inchi',\n InChIAuxInfo = 'chemical/x-inchi-aux',\n CDXML = 'chemical/x-cdxml',\n CML = 'chemical/x-cml',\n KET = 'chemical/x-indigo-ket'\n}\n\nexport interface WithStruct {\n struct: string\n}\n\nexport interface WithFormat {\n format: ChemicalMimeType\n}\n\nexport interface WithOutputFormat {\n output_format: ChemicalMimeType\n}\n\nexport interface WithSelection {\n selected?: Array\n}\n\nexport interface CheckData extends WithStruct {\n types: Array\n}\n\nexport interface CheckResult {\n [key: string]: string\n}\n\nexport interface ConvertData extends WithStruct, WithOutputFormat {}\n\nexport interface ConvertResult extends WithStruct, WithFormat {}\n\nexport interface LayoutData extends WithStruct, WithOutputFormat {}\n\nexport interface LayoutResult extends WithStruct, WithFormat {}\n\nexport interface CleanData\n extends WithStruct,\n WithSelection,\n WithOutputFormat {}\n\nexport interface CleanResult extends WithStruct, WithFormat {}\n\nexport interface AromatizeData extends WithStruct, WithOutputFormat {}\n\nexport interface AromatizeResult extends WithStruct, WithFormat {}\n\nexport interface DearomatizeData extends WithStruct, WithOutputFormat {}\n\nexport interface DearomatizeResult extends WithStruct, WithFormat {}\n\nexport interface CalculateCipData extends WithStruct, WithOutputFormat {}\n\nexport interface CalculateCipResult extends WithStruct, WithFormat {}\n\nexport interface CalculateData extends WithStruct, WithSelection {\n properties: Array\n}\n\nexport interface CalculateResult {\n [key: string]: string | number | boolean\n}\n\nexport interface AutomapData extends WithStruct, WithOutputFormat {\n mode: string\n}\n\nexport interface AutomapResult extends WithStruct, WithFormat {}\n\nexport interface InfoResult {\n indigoVersion: string\n imagoVersions: Array\n isAvailable: boolean\n}\n\nexport interface RecognizeResult extends WithStruct, WithOutputFormat {}\n\nexport interface StructServiceOptions {\n [key: string]: string | number | boolean | undefined\n}\n\nexport type OutputFormatType = 'png' | 'svg'\nexport interface GenerateImageOptions extends StructServiceOptions {\n outputFormat: OutputFormatType\n backgroundColor?: string\n}\n\nexport interface StructService {\n info: () => Promise\n convert: (\n data: ConvertData,\n options?: StructServiceOptions\n ) => Promise\n layout: (\n data: LayoutData,\n options?: StructServiceOptions\n ) => Promise\n clean: (\n data: CleanData,\n options?: StructServiceOptions\n ) => Promise\n aromatize: (\n data: AromatizeData,\n options?: StructServiceOptions\n ) => Promise\n dearomatize: (\n data: DearomatizeData,\n options?: StructServiceOptions\n ) => Promise\n calculateCip: (\n data: CalculateCipData,\n options?: StructServiceOptions\n ) => Promise\n automap: (\n data: AutomapData,\n options?: StructServiceOptions\n ) => Promise\n check: (\n data: CheckData,\n options?: StructServiceOptions\n ) => Promise\n calculate: (\n data: CalculateData,\n options?: StructServiceOptions\n ) => Promise\n recognize: (blob: Blob, version: string) => Promise\n generateImageAsBase64: (\n data: string,\n options?: GenerateImageOptions\n ) => Promise\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AromatizeData,\n AromatizeResult,\n AutomapData,\n AutomapResult,\n CalculateCipData,\n CalculateCipResult,\n CalculateData,\n CalculateResult,\n CheckData,\n CheckResult,\n CleanData,\n CleanResult,\n ConvertData,\n ConvertResult,\n DearomatizeData,\n DearomatizeResult,\n GenerateImageOptions,\n InfoResult,\n LayoutData,\n LayoutResult,\n OutputFormatType,\n RecognizeResult,\n StructService,\n StructServiceOptions\n} from 'domain/services'\n\nfunction pollDeferred(process, complete, timeGap, startTimeGap) {\n return new Promise((resolve, reject) => {\n function iterate() {\n process().then(\n val => {\n try {\n if (complete(val)) resolve(val)\n else setTimeout(iterate, timeGap)\n } catch (e) {\n reject(e)\n }\n },\n err => reject(err)\n )\n }\n setTimeout(iterate, startTimeGap || 0)\n })\n}\n\nfunction parametrizeUrl(url, params) {\n return url.replace(/:(\\w+)/g, (_, val) => params[val])\n}\n\nfunction request(\n method: string,\n url: string,\n data?: any,\n headers?: any,\n responseHandler?: (promise: Promise) => Promise\n) {\n let requestUrl = url\n if (data && method === 'GET') requestUrl = parametrizeUrl(url, data)\n let response: any = fetch(requestUrl, {\n method,\n headers: Object.assign(\n {\n Accept: 'application/json'\n },\n headers\n ),\n body: method !== 'GET' ? data : undefined,\n credentials: 'same-origin'\n })\n\n if (responseHandler) {\n response = responseHandler(response)\n } else {\n response = response.then(response =>\n response\n .json()\n .then(res => (response.ok ? res : Promise.reject(res.error)))\n )\n }\n\n return response\n}\n\nfunction indigoCall(\n method: string,\n url: string,\n baseUrl: string,\n defaultOptions: any\n) {\n return function (\n data,\n options,\n responseHandler?: (promise: Promise) => Promise\n ) {\n const body = Object.assign({}, data)\n body.options = Object.assign(body.options || {}, defaultOptions, options)\n return request(\n method,\n baseUrl + url,\n JSON.stringify(body),\n {\n 'Content-Type': 'application/json'\n },\n responseHandler\n )\n }\n}\n\nexport class RemoteStructService implements StructService {\n private readonly apiPath: string\n private readonly defaultOptions: StructServiceOptions\n\n constructor(apiPath: string, defaultOptions: StructServiceOptions) {\n this.apiPath = apiPath\n this.defaultOptions = defaultOptions\n }\n\n async info(): Promise {\n let indigoVersion: string\n let imagoVersions: Array\n let isAvailable: boolean = false\n\n try {\n const response = await request('GET', this.apiPath + 'info')\n indigoVersion = response['indigo_version']\n imagoVersions = response['imago_versions']\n isAvailable = true\n } catch (e) {\n indigoVersion = ''\n imagoVersions = []\n isAvailable = false\n }\n\n return {\n indigoVersion,\n imagoVersions,\n isAvailable\n }\n }\n\n convert(\n data: ConvertData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/convert',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n layout(\n data: LayoutData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/layout',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n clean(data: CleanData, options?: StructServiceOptions): Promise {\n return indigoCall(\n 'POST',\n 'indigo/clean',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n aromatize(\n data: AromatizeData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/aromatize',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n dearomatize(\n data: DearomatizeData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/dearomatize',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n calculateCip(\n data: CalculateCipData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/calculate_cip',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n automap(\n data: AutomapData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/automap',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n check(data: CheckData, options?: StructServiceOptions): Promise {\n return indigoCall(\n 'POST',\n 'indigo/check',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n calculate(\n data: CalculateData,\n options?: StructServiceOptions\n ): Promise {\n return indigoCall(\n 'POST',\n 'indigo/calculate',\n this.apiPath,\n this.defaultOptions\n )(data, options)\n }\n\n recognize(blob: Blob, version: string): Promise {\n const parVersion = version ? `?version=${version}` : ''\n const req = request(\n 'POST',\n this.apiPath + `imago/uploads${parVersion}`,\n blob,\n {\n 'Content-Type': blob.type || 'application/octet-stream'\n }\n )\n const status = request.bind(null, 'GET', this.apiPath + 'imago/uploads/:id')\n return req\n .then(data =>\n pollDeferred(\n status.bind(null, { id: data.upload_id }),\n (response: any) => {\n if (response.state === 'FAILURE') throw response\n return response.state === 'SUCCESS'\n },\n 500,\n 300\n )\n )\n .then((response: any) => ({ struct: response.metadata.mol_str }))\n }\n\n generateImageAsBase64(\n data: string,\n options?: GenerateImageOptions\n ): Promise {\n const outputFormat: OutputFormatType = options?.outputFormat || 'png'\n return indigoCall(\n 'POST',\n 'indigo/render',\n this.apiPath,\n this.defaultOptions\n )({ struct: data }, { 'render-output-format': outputFormat }, response =>\n response.then(resp => resp.text())\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ServiceMode,\n StructService,\n StructServiceOptions,\n StructServiceProvider\n} from 'domain/services'\n\nimport { RemoteStructService } from './remoteStructService'\n\nexport class RemoteStructServiceProvider implements StructServiceProvider {\n private readonly apiPath: string\n mode: ServiceMode = 'remote'\n\n constructor(apiPath: string) {\n let currentApiPath = apiPath\n const params = new URLSearchParams(document.location.search)\n if (params.has('api_path')) {\n currentApiPath = params.get('api_path')!\n }\n this.apiPath =\n !currentApiPath || /\\/$/.test(currentApiPath)\n ? currentApiPath\n : currentApiPath + '/'\n }\n\n createStructService(options: StructServiceOptions): StructService {\n return new RemoteStructService(this.apiPath, options)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ChemicalMimeType } from 'domain/services'\n\nexport class SupportedFormatProperties {\n name: string\n mime: ChemicalMimeType\n extensions: string[]\n supportsCoords?: boolean\n options?: any\n\n constructor(\n name: string,\n mime: ChemicalMimeType,\n extensions: string[],\n supportsCoords?: boolean,\n options?: any\n ) {\n this.name = name\n this.mime = mime\n this.extensions = extensions\n this.supportsCoords = supportsCoords || false\n this.options = options || {}\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ChemicalMimeType } from 'domain/services'\nimport { SupportedFormat } from './structFormatter.types'\nimport { SupportedFormatProperties } from './supportedFormatProperties'\n\ntype FormatPropertiesMap = {\n [key in SupportedFormat]: SupportedFormatProperties\n}\n\nconst formatProperties: FormatPropertiesMap = {\n mol: new SupportedFormatProperties(\n 'MDL Molfile V2000',\n ChemicalMimeType.Mol,\n ['.mol'],\n true\n ),\n molV3000: new SupportedFormatProperties(\n 'MDL Molfile V3000',\n ChemicalMimeType.Mol,\n ['.mol'],\n true,\n { 'molfile-saving-mode': '3000' }\n ),\n rxn: new SupportedFormatProperties(\n 'MDL Rxnfile V2000',\n ChemicalMimeType.Rxn,\n ['.rxn'],\n true\n ),\n rxnV3000: new SupportedFormatProperties(\n 'MDL Rxnfile V3000',\n ChemicalMimeType.Rxn,\n ['.rxn'],\n true,\n { 'molfile-saving-mode': '3000' }\n ),\n smiles: new SupportedFormatProperties(\n 'Daylight SMILES',\n ChemicalMimeType.DaylightSmiles,\n ['.smi', '.smiles']\n ),\n smilesExt: new SupportedFormatProperties(\n 'Extended SMILES',\n ChemicalMimeType.ExtendedSmiles,\n ['.cxsmi', '.cxsmiles']\n ),\n smarts: new SupportedFormatProperties(\n 'Daylight SMARTS',\n ChemicalMimeType.DaylightSmarts,\n ['.smarts']\n ),\n inChI: new SupportedFormatProperties('InChI', ChemicalMimeType.InChI, [\n '.inchi'\n ]),\n inChIAuxInfo: new SupportedFormatProperties(\n 'InChI AuxInfo',\n ChemicalMimeType.InChIAuxInfo,\n ['.inchi']\n ),\n cml: new SupportedFormatProperties(\n 'CML',\n ChemicalMimeType.CML,\n ['.cml', '.mrv'],\n true\n ),\n ket: new SupportedFormatProperties('Ket Format', ChemicalMimeType.KET, [\n '.ket'\n ]),\n cdxml: new SupportedFormatProperties(\n 'CDXML',\n ChemicalMimeType.CDXML,\n ['.cdxml'],\n true\n )\n}\n\nfunction getPropertiesByFormat(format: SupportedFormat) {\n return formatProperties[format]\n}\n\nexport { formatProperties, getPropertiesByFormat }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { KetSerializer } from 'domain/serializers'\nimport { Struct } from 'domain/entities'\nimport { StructFormatter } from './structFormatter.types'\n\nexport class KetFormatter implements StructFormatter {\n constructor(private readonly serializer: KetSerializer) {}\n\n async getStructureFromStructAsync(struct: Struct): Promise {\n const ket = this.serializer.serialize(struct)\n return ket\n }\n\n async getStructureFromStringAsync(content: string): Promise {\n return this.serializer.deserialize(content)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializer } from 'domain/serializers'\nimport { Struct } from 'domain/entities'\nimport { StructFormatter } from './structFormatter.types'\n\nexport class MolfileV2000Formatter implements StructFormatter {\n constructor(private readonly molfileManager: MolSerializer) {}\n\n async getStructureFromStructAsync(struct: Struct): Promise {\n const stringifiedMolfile = this.molfileManager.serialize(struct)\n return stringifiedMolfile\n }\n\n async getStructureFromStringAsync(\n stringifiedStruct: string\n ): Promise {\n const struct = this.molfileManager.deserialize(stringifiedStruct)\n return struct\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializer } from 'domain/serializers'\nimport { Struct } from 'domain/entities'\nimport { StructFormatter } from './structFormatter.types'\n\nexport class RxnFormatter implements StructFormatter {\n constructor(private readonly molfileManager: MolSerializer) {}\n\n async getStructureFromStructAsync(struct: Struct): Promise {\n const stringifiedMolfile = this.molfileManager.serialize(struct)\n return stringifiedMolfile\n }\n\n async getStructureFromStringAsync(\n stringifiedStruct: string\n ): Promise {\n const struct = this.molfileManager.deserialize(stringifiedStruct)\n return struct\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport enum LayerMap {\n background = 'background',\n selectionPlate = 'selectionPlate',\n highlighting = 'highlighting',\n warnings = 'warnings',\n data = 'data',\n indices = 'indices'\n}\n\nexport enum StereoColoringType {\n LabelsOnly = 'LabelsOnly',\n BondsOnly = 'BondsOnly',\n LabelsAndBonds = 'LabelsAndBonds',\n Off = 'Off'\n}\n\nexport enum StereLabelStyleType {\n IUPAC = 'Iupac',\n Classic = 'Classic',\n On = 'On',\n Off = 'Off'\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ConvertData,\n ConvertResult,\n LayoutData,\n LayoutResult,\n StructService,\n StructServiceOptions\n} from 'domain/services'\nimport { StructFormatter, SupportedFormat } from './structFormatter.types'\n\nimport { KetSerializer } from 'domain/serializers'\nimport { Struct } from 'domain/entities'\nimport { getPropertiesByFormat } from './formatProperties'\n\nexport class ServerFormatter implements StructFormatter {\n constructor(\n private readonly structService: StructService,\n private readonly ketSerializer: KetSerializer,\n private readonly format: SupportedFormat,\n private readonly options?: StructServiceOptions\n ) {}\n\n async getStructureFromStructAsync(struct: Struct): Promise {\n const infoResult = await this.structService.info()\n if (!infoResult.isAvailable) {\n throw new Error('Server is not available')\n }\n\n const formatProperties = getPropertiesByFormat(this.format)\n\n try {\n const stringifiedStruct = this.ketSerializer.serialize(struct)\n const convertResult = await this.structService.convert(\n {\n struct: stringifiedStruct,\n output_format: formatProperties.mime\n },\n { ...this.options, ...formatProperties.options }\n )\n\n return convertResult.struct\n } catch (error: any) {\n let message\n if (error.message === 'Server is not compatible') {\n message = `${formatProperties.name} is not supported.`\n } else {\n message = `Convert error!\\n${error.message || error}`\n }\n\n throw new Error(message)\n }\n }\n\n async getStructureFromStringAsync(\n stringifiedStruct: string\n ): Promise {\n const infoResult = await this.structService.info()\n if (!infoResult.isAvailable) {\n throw new Error('Server is not available')\n }\n\n type ConvertPromise = (\n data: ConvertData,\n options?: StructServiceOptions\n ) => Promise\n\n type LayoutPromise = (\n data: LayoutData,\n options?: StructServiceOptions\n ) => Promise\n\n let promise: LayoutPromise | ConvertPromise\n\n let data: ConvertData | LayoutData = {\n struct: undefined as any,\n output_format: getPropertiesByFormat('ket').mime\n }\n\n const withCoords = getPropertiesByFormat(this.format).supportsCoords\n if (withCoords) {\n promise = this.structService.convert\n data.struct = stringifiedStruct\n } else {\n promise = this.structService.layout\n data.struct = stringifiedStruct.trim()\n }\n\n try {\n const result = await promise(data, this.options)\n const parsedStruct = this.ketSerializer.deserialize(result.struct)\n if (!withCoords) {\n parsedStruct.rescale()\n }\n return parsedStruct\n } catch (error: any) {\n if (error.message !== 'Server is not compatible') {\n throw Error(`Convert error!\\n${error.message || error}`)\n }\n\n const formatError =\n this.format === 'smiles'\n ? `${getPropertiesByFormat('smilesExt').name} and opening of ${\n getPropertiesByFormat('smiles').name\n }`\n : getPropertiesByFormat(this.format).name\n\n throw Error(`${formatError} is not supported in standalone mode.`)\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { KetSerializer, SmiSerializer } from 'domain/serializers'\nimport { StructFormatter, SupportedFormat } from './structFormatter.types'\nimport { StructService, StructServiceOptions } from 'domain/services'\n\nimport { ServerFormatter } from './serverFormatter'\nimport { Struct } from 'domain/entities'\n\nexport class SmilesFormatter implements StructFormatter {\n constructor(\n private readonly smiSerializer: SmiSerializer,\n\n // only for ServerFormatter\n\n private readonly structService: StructService,\n private readonly ketSerializer: KetSerializer,\n private readonly format: SupportedFormat,\n private readonly options?: StructServiceOptions\n ) {}\n\n async getStructureFromStructAsync(struct: Struct): Promise {\n const stringifiedMolfile = this.smiSerializer.serialize(struct)\n return stringifiedMolfile\n }\n\n getStructureFromStringAsync(stringifiedStruct: string): Promise {\n const serverFormatter = new ServerFormatter(\n this.structService,\n this.ketSerializer,\n this.format,\n this.options\n )\n\n return serverFormatter.getStructureFromStringAsync(stringifiedStruct)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n FormatterFactoryOptions,\n StructFormatter,\n SupportedFormat\n} from './structFormatter.types'\nimport {\n KetSerializer,\n MolSerializer,\n MolSerializerOptions,\n SmiSerializer\n} from 'domain/serializers'\nimport { StructService, StructServiceOptions } from 'domain/services'\n\nimport { KetFormatter } from './ketFormatter'\nimport { MolfileV2000Formatter } from './molfileV2000Formatter'\nimport { RxnFormatter } from './rxnFormatter'\nimport { ServerFormatter } from './serverFormatter'\nimport { SmilesFormatter } from './smilesFormatter'\n\nexport class FormatterFactory {\n constructor(private readonly structService: StructService) {}\n\n private separateOptions(\n options?: FormatterFactoryOptions\n ): [Partial, StructServiceOptions | {}] {\n if (!options) {\n return [{}, {}]\n }\n\n const { reactionRelayout, badHeaderRecover, ...structServiceOptions } =\n options\n\n let molfileParseOptions: Partial = {}\n\n if (typeof reactionRelayout === 'boolean') {\n molfileParseOptions.reactionRelayout = reactionRelayout\n }\n if (typeof badHeaderRecover === 'boolean') {\n molfileParseOptions.badHeaderRecover = badHeaderRecover\n }\n\n return [molfileParseOptions, structServiceOptions]\n }\n\n create(\n format: SupportedFormat,\n options?: FormatterFactoryOptions\n ): StructFormatter {\n const [molSerializerOptions, structServiceOptions] =\n this.separateOptions(options)\n\n let formatter: StructFormatter\n switch (format) {\n case 'ket':\n formatter = new KetFormatter(new KetSerializer())\n break\n\n case 'mol':\n formatter = new MolfileV2000Formatter(\n new MolSerializer(molSerializerOptions)\n )\n break\n\n case 'rxn':\n formatter = new RxnFormatter(new MolSerializer(molSerializerOptions))\n break\n\n case 'smiles':\n formatter = new SmilesFormatter(\n new SmiSerializer(),\n\n // only for ServerFormatter, because 'getStructureFromStringAsync' is delegated to it\n\n this.structService,\n new KetSerializer(),\n format,\n structServiceOptions\n )\n break\n\n case 'cml':\n case 'inChIAuxInfo':\n case 'inChI':\n case 'molV3000':\n case 'rxnV3000':\n case 'smilesExt':\n case 'smarts':\n case 'cdxml':\n default:\n formatter = new ServerFormatter(\n this.structService,\n new KetSerializer(),\n format,\n structServiceOptions\n )\n }\n\n return formatter\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { SupportedFormat } from './structFormatter.types'\n\nexport function identifyStructFormat(\n stringifiedStruct: string\n): SupportedFormat {\n // Mimic Indigo/molecule_auto_loader.cpp as much as possible\n const sanitizedString = stringifiedStruct.trim()\n\n try {\n if (JSON.parse(sanitizedString)) {\n return 'ket'\n }\n } catch (er) {} // eslint-disable-line\n\n if (sanitizedString.indexOf('$RXN') !== -1) {\n return 'rxn'\n }\n\n if (sanitizedString.indexOf('V3000') !== -1) {\n return 'molV3000'\n }\n\n const match = sanitizedString.match(/^(M {2}END|\\$END MOL)$/m)\n\n if (match) {\n const end = (match.index || 0) + match[0].length\n if (\n end === sanitizedString.length ||\n sanitizedString.slice(end, end + 20).search(/^\\$(MOL|END CTAB)$/m) !== -1\n ) {\n return 'mol'\n }\n }\n if (\n sanitizedString[0] === '<' &&\n sanitizedString.indexOf(' {\n el.translateAbs(x, y)\n })\n}\n\nexport default Raphael\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\n// Visel is a shorthand for VISual ELement\n// It corresponds to a visualization (i.e. set of paths) of an atom or a bond.\nimport { Box2Abs, Vec2 } from 'domain/entities'\n\nclass Visel {\n constructor(type) {\n this.type = type\n this.paths = []\n this.boxes = []\n this.boundingBox = null\n this.exts = []\n }\n add(path, bb, ext) {\n this.paths.push(path)\n if (bb) {\n this.boxes.push(bb)\n this.boundingBox =\n this.boundingBox == null ? bb : Box2Abs.union(this.boundingBox, bb)\n }\n if (ext) this.exts.push(ext)\n }\n clear() {\n this.paths = []\n this.boxes = []\n this.exts = []\n this.boundingBox = null\n }\n translate(...args) {\n if (args.length > 2)\n // TODO: replace to debug time assert\n throw new Error('One vector or two scalar arguments expected')\n if (args.length === 1) {\n const vector = args[0]\n this.translate(vector.x, vector.y)\n } else {\n const x = args[0]\n const y = args[1]\n var delta = new Vec2(x, y)\n for (var i = 0; i < this.paths.length; ++i)\n this.paths[i].translateAbs(x, y)\n for (var j = 0; j < this.boxes.length; ++j)\n this.boxes[j] = this.boxes[j].translate(delta)\n if (this.boundingBox !== null)\n this.boundingBox = this.boundingBox.translate(delta)\n }\n }\n}\n\nexport default Visel\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs } from 'domain/entities'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\nimport Visel from './visel'\n\nclass ReObject {\n public visel: Visel\n public highlight: boolean = false\n public highlighting: any = null\n public selected: boolean = false\n public selectionPlate: any = null\n\n constructor(viselType: string) {\n this.visel = new Visel(viselType)\n }\n\n getVBoxObj(render: Render): Box2Abs | null {\n var vbox = this.visel.boundingBox\n if (vbox === null) return null\n if (render.options.offset)\n vbox = vbox.translate(render.options.offset.negated())\n return vbox.transform(Scale.scaled2obj, render.options)\n }\n\n setHighlight(highLight: boolean, render: Render): void {\n // TODO render should be field\n if (highLight) {\n let noredraw = 'highlighting' in this && this.highlighting !== null // && !this.highlighting.removed;\n if (noredraw) {\n if (this.highlighting.type === 'set') {\n if (!this.highlighting[0]) return\n noredraw = !this.highlighting[0].removed\n } else {\n noredraw = !this.highlighting.removed\n }\n }\n if (noredraw) {\n this.highlighting.show()\n } else {\n render.paper.setStart()\n this.drawHighlight(render)\n this.highlighting = render.paper.setFinish()\n }\n } else if (this.highlighting) {\n this.highlighting.hide()\n }\n\n this.highlight = highLight\n }\n\n // @ts-ignore\n drawHighlight(render: Render): any {\n throw new Error('ReObject.drawHighlight is not overridden.')\n }\n\n // @ts-ignore\n makeSelectionPlate(restruct: ReStruct, paper: any, styles: any): any {\n throw new Error('ReObject.makeSelectionPlate is not overridden')\n }\n}\n\nexport default ReObject\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from 'domain/entities'\nimport assert from 'assert'\n\nfunction tfx(v) {\n return parseFloat(v).toFixed(8)\n}\n\nfunction relBox(box) {\n return {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height\n }\n}\n\n/**\n * Finds intersection of a ray and a box and\n * Returns the shift magnitude to avoid it\n * @param p { Vec2 }\n * @param d { Vec2 }\n * @param bb { Box2Abs }\n */\nfunction shiftRayBox(p, d, bb) {\n assert(!!p)\n assert(!!d)\n assert(!!bb)\n\n // four corner points of the box\n const b = [\n bb.p0,\n new Vec2(bb.p1.x, bb.p0.y),\n bb.p1,\n new Vec2(bb.p0.x, bb.p1.y)\n ]\n\n const r = b.map(v => v.sub(p)) // b relative to p\n\n d = d.normalized()\n\n const rc = r.map(v => Vec2.cross(v, d)) // cross prods\n const rd = r.map(v => Vec2.dot(v, d)) // dot prods\n\n // find foremost points on the right and on the left of the ray\n let pid = -1\n let nid = -1\n\n for (let i = 0; i < 4; ++i) {\n if (rc[i] > 0) {\n if (pid < 0 || rd[pid] < rd[i]) pid = i\n } else if (nid < 0 || rd[nid] < rd[i]) {\n nid = i\n }\n }\n\n if (nid < 0 || pid < 0)\n // no intersection, no shift\n return 0\n\n // check the order\n const id0 = rd[pid] > rd[nid] ? nid : pid\n const id1 = rd[pid] > rd[nid] ? pid : nid\n\n // simple proportion to calculate the shift\n /* eslint-disable no-mixed-operators*/\n return (\n rd[id0] +\n (Math.abs(rc[id0]) * (rd[id1] - rd[id0])) /\n (Math.abs(rc[id0]) + Math.abs(rc[id1]))\n )\n}\n\nconst util = {\n tfx,\n relBox,\n shiftRayBox\n}\n\nexport default util\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RxnArrowMode, Vec2 } from 'domain/entities'\n\nimport Raphael from './raphael-ext'\nimport svgPath from 'svgpath'\nimport util from './util'\n\nconst tfx = util.tfx\n\nfunction rectangle(paper, pos, options) {\n return paper.rect(\n tfx(Math.min(pos[0].x, pos[1].x)),\n tfx(Math.min(pos[0].y, pos[1].y)),\n tfx(Math.abs(pos[1].x - pos[0].x)),\n tfx(Math.abs(pos[1].y - pos[0].y))\n )\n}\n\nfunction rectangleWithAngle(paper, a, b, length, angle, options) {\n const wOffset = 5\n const hOffset = 8\n\n const b0x = a.x + length\n\n const path =\n `M${tfx(a.x - wOffset)},${tfx(a.y)}` +\n `L${tfx(a.x - wOffset)},${tfx(a.y + hOffset)}` +\n `L${tfx(b0x + wOffset)},${tfx(a.y + hOffset)}` +\n `L${tfx(b0x + wOffset)},${tfx(a.y - hOffset)}` +\n `L${tfx(a.x - wOffset)},${tfx(a.y - hOffset)}Z`\n\n const transformedPath = svgPath(path).rotate(angle, a.x, a.y).toString()\n\n return transformedPath\n}\n\nfunction ellipse(paper, pos, options) {\n const rad = Vec2.diff(pos[1], pos[0])\n const rx = rad.x / 2\n const ry = rad.y / 2\n return paper.ellipse(pos[0].x + rx, pos[0].y + ry, Math.abs(rx), Math.abs(ry))\n}\n\nfunction polyline(paper, pos, options) {\n let path = ['M', pos[0].x, pos[0].y]\n for (let i = 1; i < pos.length; i++) path.push('L', pos[i].x, pos[i].y)\n return paper.path(path)\n}\n\nfunction line(paper, pos, options) {\n let path = ['M', pos[0].x, pos[0].y]\n path.push('L', pos[1].x, pos[1].y)\n return paper.path(path)\n}\n\nfunction arrow(paper, startPoint, endPoint, length, angle, options, type) {\n switch (type) {\n case RxnArrowMode.OpenAngle: {\n return arrowOpenAngle(paper, startPoint, endPoint, length, angle, options)\n }\n case RxnArrowMode.FilledTriangle: {\n return arrowFilledTriangle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.FilledBow: {\n return arrowFilledBow(paper, startPoint, endPoint, length, angle, options)\n }\n case RxnArrowMode.DashedOpenAngle: {\n return arrowDashedOpenAngle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.Failed: {\n return arrowFailed(paper, startPoint, endPoint, length, angle, options)\n }\n case RxnArrowMode.BothEndsFilledTriangle: {\n return arrowBothEndsFilledTriangle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.EquilibriumFilledHalfBow: {\n return arrowEquilibriumFilledHalfBow(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.EquilibriumFilledTriangle: {\n return arrowEquilibriumFilledTriangle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.EquilibriumOpenAngle: {\n return arrowEquilibriumOpenAngle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.UnbalancedEquilibriumFilledHalfBow: {\n return arrowUnbalancedEquilibriumFilledHalfBow(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.UnbalancedEquilibriumOpenHalfAngle: {\n return arrowUnbalancedEquilibriumOpenHalfAngle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.UnbalancedEquilibriumLargeFilledHalfBow: {\n return arrowUnbalancedEquilibriumLargeFilledHalfBow(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n case RxnArrowMode.UnbalancedEquilibriumFilleHalfTriangle: {\n return arrowUnbalancedEquilibriumFilleHalfTriangle(\n paper,\n startPoint,\n endPoint,\n length,\n angle,\n options\n )\n }\n }\n}\n\nfunction arrowOpenAngle(paper, a, b, arrowLength, arrowAngle, options) {\n const width = 5\n const length = 7\n\n const b0x = a.x + arrowLength\n\n const path =\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - length)},${tfx(a.y - width)}` +\n `M${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - length)}, ${tfx(a.y + width)}`\n\n const transformedPath = svgPath(path).rotate(arrowAngle, a.x, a.y).toString()\n\n return paper.path(transformedPath).attr(options.lineattr)\n}\n\nfunction arrowFilledTriangle(paper, a, b, arrowLength, arrowAngle, options) {\n const triangleLength = 10\n const triangleWidth = 5\n\n const b0x = a.x + arrowLength\n\n const path =\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y + triangleWidth)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y - triangleWidth)}` +\n `L${tfx(b0x)},${tfx(a.y)}Z`\n\n const transformedPath = svgPath(path).rotate(arrowAngle, a.x, a.y).toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowFilledBow(paper, a, b, arrowLength, arrowAngle, options) {\n const arrowHeadLength = 10\n const arrowHeadWidth = 5\n const arrowHeadAttr = 4\n\n const b0x = a.x + arrowLength\n\n const path =\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - arrowHeadLength)},${tfx(a.y + arrowHeadWidth)}` +\n `L${tfx(b0x - arrowHeadLength + arrowHeadAttr)},${tfx(a.y)}` +\n `L${tfx(b0x - arrowHeadLength)},${tfx(a.y - arrowHeadWidth)}` +\n `L${tfx(b0x)},${tfx(a.y)}Z`\n\n const transformedPath = svgPath(path).rotate(arrowAngle, a.x, a.y).toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowDashedOpenAngle(paper, a, b, arrowLength, arrowAngle, options) {\n const triangleLength = 10\n const triangleWidth = 5\n const dashInterval = 3.5\n\n const path = []\n\n const b0x = a.x + arrowLength\n\n // Dashed arrow\n for (let i = 0; i < arrowLength / dashInterval; i++) {\n if (i % 2) {\n path.push(`L${tfx(a.x + i * dashInterval)},${tfx(a.y)}`)\n } else {\n path.push(`M${tfx(a.x + i * dashInterval)},${tfx(a.y)}`)\n }\n }\n\n // Arrowhead\n path.push(\n `M${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y + triangleWidth)}` +\n `M${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y - triangleWidth)}`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowFailed(paper, a, b, arrowLength, arrowAngle, options) {\n const arrowHeadLength = 10\n const arrowHeadWidth = 5\n const arrowHeadAttr = 4\n const failSignWidth = 8\n\n const b0x = a.x + arrowLength\n\n const arrowCenter = b0x - (b0x - a.x) / 2\n\n const path = []\n\n // Arrow with arrowhead\n path.push(\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - arrowHeadLength)},${tfx(a.y + arrowHeadWidth)}` +\n `L${tfx(b0x - arrowHeadLength + arrowHeadAttr)},${tfx(a.y)}` +\n `L${tfx(b0x - arrowHeadLength)},${tfx(a.y - arrowHeadWidth)}` +\n `L${tfx(b0x)},${tfx(a.y)}Z`\n )\n\n // Failed sign line 1\n path.push(\n `M${tfx(arrowCenter + failSignWidth)},${tfx(a.y + failSignWidth)}` +\n `L${tfx(arrowCenter - failSignWidth)},${tfx(a.y - failSignWidth)}`\n )\n\n // Failed sign line 2\n path.push(\n `M${tfx(arrowCenter + failSignWidth)},${tfx(a.y - failSignWidth)}` +\n `L${tfx(arrowCenter - failSignWidth)},${tfx(a.y + failSignWidth)}`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowBothEndsFilledTriangle(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const triangleLength = 10\n const triangleWidth = 5\n\n const b0x = a.x + arrowLength\n\n const path =\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y + triangleWidth)}` +\n `L${tfx(b0x - triangleLength)},${tfx(a.y - triangleWidth)}` +\n `L${tfx(b0x)},${tfx(a.y)}` +\n `M${tfx(a.x)},${tfx(a.y)}` +\n `L${tfx(a.x + triangleLength)},${tfx(a.y - triangleWidth)}` +\n `L${tfx(a.x + triangleLength)},${tfx(a.y + triangleWidth)}` +\n `L${tfx(a.x)},${tfx(a.y)}`\n\n const transformedPath = svgPath(path).rotate(arrowAngle, a.x, a.y).toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowEquilibriumFilledHalfBow(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n const arrowHeadAttr = 2\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // Arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - arrowOffset)}` +\n `L${tfx(b0x - arrowLen + arrowHeadAttr)},${tfx(a.y - lineOffset)}Z`\n )\n\n // Arrowhead\n path.push(\n `M${tfx(b0x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen)},${tfx(a.y + arrowOffset)}` +\n `L${tfx(a.x + arrowLen - arrowHeadAttr)},${a.y + lineOffset}Z`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowEquilibriumFilledTriangle(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - arrowOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}Z`\n )\n\n // Second arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen)},${tfx(a.y + arrowOffset)}` +\n `L${tfx(a.x + arrowLen)},${a.y + lineOffset}Z` +\n `L${tfx(a.x + arrowLen)},${tfx(a.y)}` +\n `L${tfx(a.x + arrowLen)},${a.y + lineOffset}Z`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowEquilibriumOpenAngle(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const width = 5\n const length = 7\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - length)},${tfx(a.y - width - lineOffset)}`\n )\n\n // Second arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen)},${tfx(a.y + lineOffset + width)}`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr(options.lineattr)\n}\n\nfunction arrowUnbalancedEquilibriumFilledHalfBow(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n const arrowHeadAttr = 2\n const unbalanceVal = 15\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - arrowOffset)}` +\n `L${tfx(b0x - arrowLen + arrowHeadAttr)},${tfx(a.y - lineOffset)}Z`\n )\n\n // Second (Unbalanced) arrow\n path.push(\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x - unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen + unbalanceVal)},${tfx(a.y + arrowOffset)}` +\n `L${tfx(a.x + arrowLen - arrowHeadAttr + unbalanceVal)},${\n a.y + lineOffset\n }Z`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowUnbalancedEquilibriumOpenHalfAngle(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const width = 5\n const length = 7\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n const unbalanceVal = 15\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - length)},${tfx(a.y - width - lineOffset)}`\n )\n\n // Second (Unbalanced) arrow\n path.push(\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x - unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen + unbalanceVal)},${tfx(a.y + lineOffset + width)}`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr(options.lineattr)\n}\n\nfunction arrowUnbalancedEquilibriumLargeFilledHalfBow(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 10\n const arrowHeadAttr = 2\n const unbalanceVal = 15\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - arrowOffset)}` +\n `L${tfx(b0x - arrowLen + arrowHeadAttr)},${tfx(a.y - lineOffset)}Z`\n )\n\n // Second (Unbalanced) arrow\n path.push(\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x - unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen + unbalanceVal)},${tfx(a.y + arrowOffset)}` +\n `L${tfx(a.x + arrowLen - arrowHeadAttr + unbalanceVal)},${\n a.y + lineOffset\n }Z`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction arrowUnbalancedEquilibriumFilleHalfTriangle(\n paper,\n a,\n b,\n arrowLength,\n arrowAngle,\n options\n) {\n const arrowLen = 9\n const lineOffset = 3.5\n const arrowOffset = 7\n const unbalanceVal = 15\n\n const b0x = a.x + arrowLength\n\n const path = []\n\n // First arrow\n path.push(\n `M${tfx(a.x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x)},${tfx(a.y - lineOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - arrowOffset)}` +\n `L${tfx(b0x - arrowLen)},${tfx(a.y - lineOffset)}Z`\n )\n\n // Second (Unbalanced) arrow\n path.push(\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(b0x - unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `M${tfx(a.x + unbalanceVal)},${tfx(a.y + lineOffset)}` +\n `L${tfx(a.x + arrowLen + unbalanceVal)},${tfx(a.y + arrowOffset)}` +\n `L${tfx(a.x + arrowLen + unbalanceVal)},${a.y + lineOffset}Z`\n )\n\n const transformedPath = svgPath(path.join(''))\n .rotate(arrowAngle, a.x, a.y)\n .toString()\n\n return paper.path(transformedPath).attr({ ...options.lineattr, fill: '#000' })\n}\n\nfunction plus(paper, c, options) {\n var s = options.scale / 5\n return paper\n .path(\n 'M{0},{4}L{0},{5}M{2},{1}L{3},{1}',\n tfx(c.x),\n tfx(c.y),\n tfx(c.x - s),\n tfx(c.x + s),\n tfx(c.y - s),\n tfx(c.y + s)\n )\n .attr(options.lineattr)\n}\n\nfunction bondSingle(paper, hb1, hb2, options, color = '#000') {\n var a = hb1.p,\n b = hb2.p\n return paper.path(makeStroke(a, b)).attr(options.lineattr).attr({\n fill: color,\n stroke: color\n })\n}\n\nfunction bondSingleUp(paper, a, b2, b3, options, color = '#000') {\n // eslint-disable-line max-params\n return paper\n .path(\n 'M{0},{1}L{2},{3}L{4},{5}Z',\n tfx(a.x),\n tfx(a.y),\n tfx(b2.x),\n tfx(b2.y),\n tfx(b3.x),\n tfx(b3.y)\n )\n .attr(options.lineattr)\n .attr({\n fill: color,\n stroke: color\n })\n}\n\nfunction bondSingleStereoBold(paper, a1, a2, a3, a4, options, color = '#000') {\n // eslint-disable-line max-params\n const bond = paper\n .path(\n 'M{0},{1}L{2},{3}L{4},{5}L{6},{7}Z',\n tfx(a1.x),\n tfx(a1.y),\n tfx(a2.x),\n tfx(a2.y),\n tfx(a3.x),\n tfx(a3.y),\n tfx(a4.x),\n tfx(a4.y)\n )\n .attr(options.lineattr)\n bond.attr({\n stroke: color,\n fill: color\n })\n return bond\n}\n\nfunction bondDoubleStereoBold(\n paper,\n sgBondPath,\n b1,\n b2,\n options,\n color = '#000'\n) {\n // eslint-disable-line max-params\n return paper.set([\n sgBondPath,\n paper\n .path('M{0},{1}L{2},{3}', tfx(b1.x), tfx(b1.y), tfx(b2.x), tfx(b2.y))\n .attr(options.lineattr)\n .attr({\n stroke: color,\n fill: color\n })\n ])\n}\n\nfunction bondSingleDown(paper, hb1, d, nlines, step, options, color = '#000') {\n // eslint-disable-line max-params\n var a = hb1.p,\n n = hb1.norm\n var bsp = 0.7 * options.stereoBond\n\n var path = '',\n p,\n q,\n r\n for (var i = 0; i < nlines; ++i) {\n r = a.addScaled(d, step * i)\n p = r.addScaled(n, (bsp * (i + 0.5)) / (nlines - 0.5))\n q = r.addScaled(n, (-bsp * (i + 0.5)) / (nlines - 0.5))\n path += makeStroke(p, q)\n }\n return paper.path(path).attr(options.lineattr).attr({\n fill: color,\n stroke: color\n })\n}\n\nfunction bondSingleEither(\n paper,\n hb1,\n d,\n nlines,\n step,\n options,\n color = '#000'\n) {\n // eslint-disable-line max-params\n var a = hb1.p,\n n = hb1.norm\n var bsp = 0.7 * options.stereoBond\n\n var path = 'M' + tfx(a.x) + ',' + tfx(a.y),\n r = a\n for (var i = 0; i < nlines; ++i) {\n r = a\n .addScaled(d, step * (i + 0.5))\n .addScaled(n, ((i & 1 ? -1 : +1) * bsp * (i + 0.5)) / (nlines - 0.5))\n path += 'L' + tfx(r.x) + ',' + tfx(r.y)\n }\n return paper.path(path).attr(options.lineattr).attr({\n fill: color,\n stroke: color\n })\n}\n\nfunction bondDouble(paper, a1, a2, b1, b2, cisTrans, options) {\n // eslint-disable-line max-params\n return paper\n .path(\n cisTrans\n ? 'M{0},{1}L{6},{7}M{4},{5}L{2},{3}'\n : 'M{0},{1}L{2},{3}M{4},{5}L{6},{7}',\n tfx(a1.x),\n tfx(a1.y),\n tfx(b1.x),\n tfx(b1.y),\n tfx(a2.x),\n tfx(a2.y),\n tfx(b2.x),\n tfx(b2.y)\n )\n .attr(options.lineattr)\n}\n\nfunction bondSingleOrDouble(paper, hb1, hb2, nSect, options) {\n // eslint-disable-line max-statements, max-params\n var a = hb1.p,\n b = hb2.p,\n n = hb1.norm\n var bsp = options.bondSpace / 2\n\n var path = '',\n pi,\n pp = a\n for (var i = 1; i <= nSect; ++i) {\n pi = Vec2.lc2(a, (nSect - i) / nSect, b, i / nSect)\n if (i & 1) {\n path += makeStroke(pp, pi)\n } else {\n path += makeStroke(pp.addScaled(n, bsp), pi.addScaled(n, bsp))\n path += makeStroke(pp.addScaled(n, -bsp), pi.addScaled(n, -bsp))\n }\n pp = pi\n }\n return paper.path(path).attr(options.lineattr)\n}\n\nfunction bondTriple(paper, hb1, hb2, options, color = '#000') {\n var a = hb1.p,\n b = hb2.p,\n n = hb1.norm\n var a2 = a.addScaled(n, options.bondSpace)\n var b2 = b.addScaled(n, options.bondSpace)\n var a3 = a.addScaled(n, -options.bondSpace)\n var b3 = b.addScaled(n, -options.bondSpace)\n return paper\n .path(makeStroke(a, b) + makeStroke(a2, b2) + makeStroke(a3, b3))\n .attr(options.lineattr)\n .attr({\n fill: color,\n stroke: color\n })\n}\n\nfunction bondAromatic(paper, paths, bondShift, options) {\n var l1 = paper.path(paths[0]).attr(options.lineattr)\n var l2 = paper.path(paths[1]).attr(options.lineattr)\n if (bondShift !== undefined && bondShift !== null)\n (bondShift > 0 ? l1 : l2).attr({ 'stroke-dasharray': '- ' })\n\n return paper.set([l1, l2])\n}\n\nfunction bondAny(paper, hb1, hb2, options) {\n var a = hb1.p,\n b = hb2.p\n return paper\n .path(makeStroke(a, b))\n .attr(options.lineattr)\n .attr({ 'stroke-dasharray': '- ' })\n}\n\nfunction bondHydrogen(paper, hb1, hb2, options) {\n var a = hb1.p,\n b = hb2.p\n return paper.path(makeStroke(a, b)).attr(options.lineattr).attr({\n 'stroke-dasharray': '.',\n 'stroke-linecap': 'square'\n })\n}\n\nfunction bondDative(paper, hb1, hb2, options) {\n var a = hb1.p,\n b = hb2.p\n return paper\n .path(makeStroke(a, b))\n .attr(options.lineattr)\n .attr({ 'arrow-end': 'block-midium-long' })\n}\n\nfunction reactingCenter(paper, p, options) {\n var pathdesc = ''\n for (var i = 0; i < p.length / 2; ++i)\n pathdesc += makeStroke(p[2 * i], p[2 * i + 1])\n return paper.path(pathdesc).attr(options.lineattr)\n}\n\nfunction topologyMark(paper, p, mark, options) {\n var path = paper.text(p.x, p.y, mark).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: '#000'\n })\n var rbb = util.relBox(path.getBBox())\n recenterText(path, rbb)\n return path\n}\n\nfunction radicalCap(paper, p, options) {\n var s = options.lineWidth * 0.9\n var dw = s,\n dh = 2 * s\n return paper\n .path(\n 'M{0},{1}L{2},{3}L{4},{5}',\n tfx(p.x - dw),\n tfx(p.y + dh),\n tfx(p.x),\n tfx(p.y),\n tfx(p.x + dw),\n tfx(p.y + dh)\n )\n .attr({\n stroke: '#000',\n 'stroke-width': options.lineWidth * 0.7,\n 'stroke-linecap': 'square',\n 'stroke-linejoin': 'miter'\n })\n}\n\nfunction radicalBullet(paper, p, options) {\n return paper.circle(tfx(p.x), tfx(p.y), options.lineWidth).attr({\n stroke: null,\n fill: '#000'\n })\n}\n\nfunction bracket(paper, d, n, c, bracketWidth, bracketHeight, options) {\n // eslint-disable-line max-params\n bracketWidth = bracketWidth || 0.25\n bracketHeight = bracketHeight || 1.0\n var a0 = c.addScaled(n, -0.5 * bracketHeight)\n var a1 = c.addScaled(n, 0.5 * bracketHeight)\n var b0 = a0.addScaled(d, -bracketWidth)\n var b1 = a1.addScaled(d, -bracketWidth)\n\n return paper\n .path(\n 'M{0},{1}L{2},{3}L{4},{5}L{6},{7}',\n tfx(b0.x),\n tfx(b0.y),\n tfx(a0.x),\n tfx(a0.y),\n tfx(a1.x),\n tfx(a1.y),\n tfx(b1.x),\n tfx(b1.y)\n )\n .attr(options.sgroupBracketStyle)\n}\n\nfunction selectionRectangle(paper, p0, p1, options) {\n return paper\n .rect(\n tfx(Math.min(p0.x, p1.x)),\n tfx(Math.min(p0.y, p1.y)),\n tfx(Math.abs(p1.x - p0.x)),\n tfx(Math.abs(p1.y - p0.y))\n )\n .attr(options.lassoStyle)\n}\n\nfunction selectionPolygon(paper, r, options) {\n var v = r[r.length - 1]\n var pstr = 'M' + tfx(v.x) + ',' + tfx(v.y)\n for (var i = 0; i < r.length; ++i)\n pstr += 'L' + tfx(r[i].x) + ',' + tfx(r[i].y)\n return paper.path(pstr).attr(options.lassoStyle)\n}\n\nfunction selectionLine(paper, p0, p1, options) {\n return paper.path(makeStroke(p0, p1)).attr(options.lassoStyle)\n}\n\nfunction makeStroke(a, b) {\n return 'M' + tfx(a.x) + ',' + tfx(a.y) + 'L' + tfx(b.x) + ',' + tfx(b.y) + '\t'\n}\n\nfunction dashedPath(p0, p1, dash) {\n var t0 = 0\n var t1 = Vec2.dist(p0, p1)\n var d = Vec2.diff(p1, p0).normalized()\n var black = true\n var path = ''\n var i = 0\n\n while (t0 < t1) {\n var len = dash[i % dash.length]\n var t2 = t0 + Math.min(len, t1 - t0)\n if (black)\n path +=\n 'M ' +\n p0.addScaled(d, t0).coordStr() +\n ' L ' +\n p0.addScaled(d, t2).coordStr()\n t0 += len\n black = !black\n i++\n }\n return path\n}\n\nfunction aromaticBondPaths(a2, a3, b2, b3, mask, dash) {\n // eslint-disable-line max-params\n var l1 = dash && mask & 1 ? dashedPath(a2, b2, dash) : makeStroke(a2, b2)\n var l2 = dash && mask & 2 ? dashedPath(a3, b3, dash) : makeStroke(a3, b3)\n\n return [l1, l2]\n}\n\nfunction recenterText(path, rbb) {\n // TODO: find a better way\n if (Raphael.vml) {\n var gap = rbb.height * 0.16\n path.translateAbs(0, gap)\n rbb.y += gap\n }\n}\n\nexport default {\n recenterText,\n arrow,\n plus,\n aromaticBondPaths,\n bondSingle,\n bondSingleUp,\n bondSingleStereoBold,\n bondDoubleStereoBold,\n bondSingleDown,\n bondSingleEither,\n bondDouble,\n bondSingleOrDouble,\n bondTriple,\n bondAromatic,\n bondAny,\n bondHydrogen,\n bondDative,\n reactingCenter,\n topologyMark,\n radicalCap,\n radicalBullet,\n bracket,\n selectionRectangle,\n selectionPolygon,\n selectionLine,\n ellipse,\n rectangle,\n rectangleWithAngle,\n polyline,\n line\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Atom,\n Bond,\n Box2Abs,\n FunctionalGroup,\n StereoFlag,\n StereoLabel,\n Struct,\n Vec2\n} from 'domain/entities'\nimport { ElementColor, Elements } from 'domain/constants'\nimport {\n LayerMap,\n StereLabelStyleType,\n StereoColoringType\n} from './generalEnumTypes'\n\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\ninterface ElemAttr {\n text: string\n path: any\n rbb: { x: number; y: number; width: number; height: number }\n}\n\nconst StereoLabelMinOpacity = 0.3\n\nenum ShowHydrogenLabels {\n Off = 'off',\n Hetero = 'Hetero',\n Terminal = 'Terminal',\n TerminalAndHetero = 'Terminal and Hetero',\n On = 'on'\n}\n\nclass ReAtom extends ReObject {\n a: Atom\n showLabel: boolean\n hydrogenOnTheLeft: boolean\n color: string\n component: number\n label?: ElemAttr\n\n constructor(atom: Atom) {\n super('atom')\n this.a = atom // TODO rename a to item\n this.showLabel = false\n\n this.hydrogenOnTheLeft = false\n\n this.color = '#000000'\n this.component = -1\n }\n static isSelectable(): true {\n return true\n }\n getVBoxObj(render: Render): Box2Abs | null {\n if (this.visel.boundingBox)\n return ReObject.prototype.getVBoxObj.call(this, render)\n return new Box2Abs(this.a.pp, this.a.pp)\n }\n drawHighlight(render: Render) {\n const ret = this.makeHighlightPlate(render)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n makeHighlightPlate(render: Render) {\n const paper = render.paper\n const options = render.options\n const ps = Scale.obj2scaled(this.a.pp, options)\n const atom = this.a\n const sgroups = render.ctab.sgroups\n const functionalGroups = render.ctab.molecule.functionalGroups\n if (\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom,\n sgroups,\n functionalGroups,\n true\n )\n )\n return null\n return paper\n .circle(ps.x, ps.y, options.atomSelectionPlateRadius)\n .attr(options.highlightStyle)\n }\n makeSelectionPlate(restruct: ReStruct, paper: any, styles: any) {\n const atom = this.a\n const sgroups = restruct.render.ctab.sgroups\n const functionalGroups = restruct.render.ctab.molecule.functionalGroups\n if (\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom,\n sgroups,\n functionalGroups,\n true\n )\n )\n return null\n\n const ps = Scale.obj2scaled(this.a.pp, restruct.render.options)\n return paper\n .circle(ps.x, ps.y, styles.atomSelectionPlateRadius)\n .attr(styles.selectionStyle)\n }\n show(restruct: ReStruct, aid: number, options: any): void {\n // eslint-disable-line max-statements\n const atom = restruct.molecule.atoms.get(aid)\n const sgroups = restruct.molecule.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n const render = restruct.render\n const ps = Scale.obj2scaled(this.a.pp, render.options)\n\n if (\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom,\n sgroups,\n functionalGroups,\n false\n )\n ) {\n if (FunctionalGroup.isFirstAtomInFunctionalGroup(sgroups, aid)) {\n let sgroupName\n for (let sg of sgroups.values()) {\n if (aid === sg.atoms[0]) sgroupName = sg.data.name\n }\n const path = render.paper.text(ps.x, ps.y, sgroupName).attr({\n 'font-weight': 700,\n 'font-size': 14\n })\n restruct.addReObjectPath(LayerMap.data, this.visel, path, ps, true)\n }\n return\n }\n\n this.hydrogenOnTheLeft = setHydrogenPos(restruct.molecule, this)\n this.showLabel = isLabelVisible(restruct, render.options, this)\n this.color = 'black' // reset colour\n\n let delta\n let rightMargin\n let leftMargin\n let implh\n let isHydrogen\n let label\n let index: any = null\n\n if (this.showLabel) {\n label = buildLabel(this, render.paper, ps, options)\n delta = 0.5 * options.lineWidth\n rightMargin =\n (label.rbb.width / 2) * (options.zoom > 1 ? 1 : options.zoom)\n leftMargin =\n (-label.rbb.width / 2) * (options.zoom > 1 ? 1 : options.zoom)\n implh = Math.floor(this.a.implicitH)\n isHydrogen = label.text === 'H'\n restruct.addReObjectPath(LayerMap.data, this.visel, label.path, ps, true)\n if (options.showAtomIds) {\n index = {}\n index.text = aid.toString()\n index.path = render.paper.text(ps.x, ps.y, index.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: '#070'\n })\n index.rbb = util.relBox(index.path.getBBox())\n draw.recenterText(index.path, index.rbb)\n restruct.addReObjectPath(LayerMap.indices, this.visel, index.path, ps)\n }\n this.setHighlight(this.highlight, render)\n }\n\n if (this.showLabel && !this.a.pseudo) {\n let hydroIndex: any = null\n if (isHydrogen && implh > 0) {\n hydroIndex = showHydroIndex(this, render, implh, rightMargin)\n rightMargin += hydroIndex.rbb.width + delta\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n hydroIndex.path,\n ps,\n true\n )\n }\n\n if (this.a.radical != 0) {\n const radical = showRadical(this, render)\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n radical.path,\n ps,\n true\n )\n }\n if (this.a.isotope != 0) {\n const isotope = showIsotope(this, render, leftMargin)\n leftMargin -= isotope.rbb.width + delta\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n isotope.path,\n ps,\n true\n )\n }\n if (\n !isHydrogen &&\n !this.a.alias &&\n implh > 0 &&\n displayHydrogen(options.showHydrogenLabels, this)\n ) {\n const data = showHydrogen(this, render, implh, {\n hydrogen: {},\n hydroIndex,\n rightMargin,\n leftMargin\n })\n const hydrogen = data.hydrogen\n hydroIndex = data.hydroIndex\n rightMargin = data.rightMargin\n leftMargin = data.leftMargin\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n hydrogen.path,\n ps,\n true\n )\n if (hydroIndex != null)\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n hydroIndex.path,\n ps,\n true\n )\n }\n\n if (this.a.charge != 0 && options.showCharge) {\n const charge = showCharge(this, render, rightMargin)\n rightMargin += charge.rbb.width + delta\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n charge.path,\n ps,\n true\n )\n }\n if (this.a.explicitValence >= 0 && options.showValence) {\n const valence = showExplicitValence(this, render, rightMargin)\n rightMargin += valence.rbb.width + delta\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n valence.path,\n ps,\n true\n )\n }\n\n if (this.a.badConn && options.showValenceWarnings) {\n const warning = showWarning(this, render, leftMargin, rightMargin)\n restruct.addReObjectPath(\n LayerMap.warnings,\n this.visel,\n warning.path,\n ps,\n true\n )\n }\n if (index) {\n /* eslint-disable no-mixed-operators */\n pathAndRBoxTranslate(\n index.path,\n index.rbb,\n -0.5 * label.rbb.width - 0.5 * index.rbb.width - delta,\n 0.3 * label.rbb.height\n )\n /* eslint-enable no-mixed-operators */\n }\n }\n\n if (this.a.attpnt) {\n const lsb = bisectLargestSector(this, restruct.molecule)\n showAttpnt(this, render, lsb, restruct.addReObjectPath.bind(restruct))\n }\n\n const stereoLabel = this.a.stereoLabel // Enhanced Stereo\n const aamText = getAamText(this)\n const queryAttrsText = !this.a.pseudo ? getQueryAttrsText(this) : ''\n\n // we render them together to avoid possible collisions\n\n const fragmentId = Number(restruct.atoms.get(aid)?.a.fragment)\n //TODO: fragment should not be null\n const fragment = restruct.molecule.frags.get(fragmentId)\n\n const text =\n (shouldDisplayStereoLabel(\n stereoLabel,\n options.stereoLabelStyle,\n fragment?.enhancedStereoFlag\n )\n ? `${stereoLabel}\\n`\n : '') +\n (queryAttrsText.length > 0 ? `${queryAttrsText}\\n` : '') +\n (aamText.length > 0 ? `.${aamText}.` : '')\n if (text.length > 0) {\n const elem = Elements.get(this.a.label)\n const aamPath = render.paper.text(ps.x, ps.y, text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: options.atomColoring && elem ? ElementColor[this.a.label] : '#000'\n })\n if (stereoLabel) {\n //use dom element to change color of stereo label which is the first element\n //of just created text\n //text -> tspan\n const color = getStereoAtomColor(render.options, stereoLabel)\n aamPath.node.childNodes[0].setAttribute('fill', color)\n const opacity = getStereoAtomOpacity(render.options, stereoLabel)\n aamPath.node.childNodes[0].setAttribute('fill-opacity', opacity)\n }\n const aamBox = util.relBox(aamPath.getBBox())\n draw.recenterText(aamPath, aamBox)\n const visel = this.visel\n let t = 3\n let dir = bisectLargestSector(this, restruct.molecule)\n // estimate the shift to clear the atom label\n for (let i = 0; i < visel.exts.length; ++i)\n t = Math.max(t, util.shiftRayBox(ps, dir, visel.exts[i].translate(ps)))\n // estimate the shift backwards to account for the size of the aam/query text box itself\n t += util.shiftRayBox(ps, dir.negated(), Box2Abs.fromRelBox(aamBox))\n dir = dir.scaled(8 + t)\n pathAndRBoxTranslate(aamPath, aamBox, dir.x, dir.y)\n restruct.addReObjectPath(LayerMap.data, this.visel, aamPath, ps, true)\n }\n }\n}\n\nfunction getStereoAtomColor(options, stereoLabel) {\n if (\n !stereoLabel ||\n options.colorStereogenicCenters === StereoColoringType.Off ||\n options.colorStereogenicCenters === StereoColoringType.BondsOnly\n ) {\n return '#000'\n }\n\n return getColorFromStereoLabel(options, stereoLabel)\n}\n\nexport function getColorFromStereoLabel(options, stereoLabel) {\n const stereoLabelType = stereoLabel.match(/\\D+/g)[0]\n\n switch (stereoLabelType) {\n case StereoLabel.And:\n return options.colorOfAndCenters\n case StereoLabel.Or:\n return options.colorOfOrCenters\n case StereoLabel.Abs:\n return options.colorOfAbsoluteCenters\n default:\n return '#000'\n }\n}\n\nfunction getStereoAtomOpacity(options, stereoLabel) {\n const stereoLabelType = stereoLabel.match(/\\D+/g)[0]\n const stereoLabelNumber = +stereoLabel.replace(stereoLabelType, '')\n if (\n !options.autoFadeOfStereoLabels ||\n stereoLabelType === StereoLabel.Abs ||\n options.colorStereogenicCenters === StereoColoringType.Off ||\n options.colorStereogenicCenters === StereoColoringType.BondsOnly\n ) {\n return 1\n }\n return Math.max(1 - (stereoLabelNumber - 1) / 10, StereoLabelMinOpacity)\n}\n\nfunction shouldDisplayStereoLabel(\n stereoLabel,\n labelStyle,\n flag: StereoFlag | undefined\n): Boolean {\n if (!stereoLabel) {\n return false\n }\n const stereoLabelType = stereoLabel.match(/\\D+/g)[0]\n switch (labelStyle) {\n // Off\n case StereLabelStyleType.Off:\n return false\n // On\n case StereLabelStyleType.On:\n return true\n // Classic\n case StereLabelStyleType.Classic:\n return flag === StereoFlag.Mixed || stereoLabelType === StereoLabel.Or\n ? true\n : false\n // IUPAC\n case StereLabelStyleType.IUPAC:\n return flag === StereoFlag.Mixed && stereoLabelType !== StereoLabel.Abs\n ? true\n : false\n default:\n return true\n }\n}\n\nfunction isLabelVisible(restruct, options, atom) {\n const visibleTerminal =\n options.showHydrogenLabels !== ShowHydrogenLabels.Off &&\n options.showHydrogenLabels !== ShowHydrogenLabels.Hetero\n\n const neighborsLength =\n atom.a.neighbors.length === 0 ||\n (atom.a.neighbors.length < 2 && visibleTerminal)\n\n const shouldBeVisible =\n neighborsLength ||\n options.carbonExplicitly ||\n atom.a.alias ||\n atom.a.isotope !== 0 ||\n atom.a.radical !== 0 ||\n atom.a.charge !== 0 ||\n atom.a.explicitValence >= 0 ||\n atom.a.atomList !== null ||\n atom.a.rglabel !== null ||\n (atom.a.badConn && options.showValenceWarnings) ||\n atom.a.label.toLowerCase() !== 'c'\n\n if (shouldBeVisible) return true\n\n if (atom.a.neighbors.length === 2) {\n const nei1 = atom.a.neighbors[0]\n const nei2 = atom.a.neighbors[1]\n const hb1 = restruct.molecule.halfBonds.get(nei1)\n const hb2 = restruct.molecule.halfBonds.get(nei2)\n const bond1 = restruct.bonds.get(hb1.bid)\n const bond2 = restruct.bonds.get(hb2.bid)\n\n const sameNotStereo =\n bond1.b.type === bond2.b.type &&\n bond1.b.stereo === Bond.PATTERN.STEREO.NONE &&\n bond2.b.stereo === Bond.PATTERN.STEREO.NONE\n\n if (sameNotStereo && Math.abs(Vec2.cross(hb1.dir, hb2.dir)) < 0.2)\n return true\n }\n\n return false\n}\n\nfunction displayHydrogen(hydrogenLabels, atom) {\n return (\n hydrogenLabels === ShowHydrogenLabels.On ||\n (hydrogenLabels === ShowHydrogenLabels.Terminal &&\n atom.a.neighbors.length < 2) ||\n (hydrogenLabels === ShowHydrogenLabels.Hetero &&\n atom.label.text.toLowerCase() !== 'c') ||\n (hydrogenLabels === ShowHydrogenLabels.TerminalAndHetero &&\n (atom.a.neighbors.length < 2 || atom.label.text.toLowerCase() !== 'c'))\n )\n}\n\nfunction setHydrogenPos(struct, atom) {\n // check where should the hydrogen be put on the left of the label\n if (atom.a.neighbors.length === 0) {\n const element = Elements.get(atom.a.label)\n return !element || Boolean(element.leftH)\n }\n\n let yl = 1\n let yr = 1\n let nl = 0\n let nr = 0\n\n atom.a.neighbors.forEach(nei => {\n const d = struct.halfBonds.get(nei).dir\n\n if (d.x <= 0) {\n yl = Math.min(yl, Math.abs(d.y))\n nl++\n } else {\n yr = Math.min(yr, Math.abs(d.y))\n nr++\n }\n })\n\n return yl < 0.51 || yr < 0.51 ? yr < yl : nr > nl\n}\n\nfunction buildLabel(\n atom: ReAtom,\n paper: any,\n ps: Vec2,\n options: any\n): ElemAttr {\n // eslint-disable-line max-statements\n let label: any = {}\n label.text = getLabelText(atom.a)\n\n if (label.text === '') label = 'R#' // for structures that missed 'M RGP' tag in molfile\n\n if (label.text === atom.a.label) {\n const element = Elements.get(label.text)\n if (options.atomColoring && element)\n atom.color = ElementColor[label.text] || '#000'\n }\n\n label.path = paper.text(ps.x, ps.y, label.text).attr({\n font: options.font,\n 'font-size': options.fontsz,\n fill: atom.color,\n 'font-style': atom.a.pseudo ? 'italic' : ''\n })\n\n label.rbb = util.relBox(label.path.getBBox())\n draw.recenterText(label.path, label.rbb)\n\n if (atom.a.atomList !== null)\n pathAndRBoxTranslate(\n label.path,\n label.rbb,\n ((atom.hydrogenOnTheLeft ? -1 : 1) *\n (label.rbb.width - label.rbb.height)) /\n 2,\n 0\n )\n\n atom.label = label\n return label\n}\n\nfunction getLabelText(atom) {\n if (atom.atomList !== null) return atom.atomList.label()\n\n if (atom.pseudo) return atom.pseudo\n\n if (atom.alias) return atom.alias\n\n if (atom.label === 'R#' && atom.rglabel !== null) {\n let text = ''\n\n for (let rgi = 0; rgi < 32; rgi++) {\n if (atom.rglabel & (1 << rgi))\n // eslint-disable-line max-depth\n text += 'R' + (rgi + 1).toString()\n }\n\n return text\n }\n\n return atom.label\n}\n\nfunction showHydroIndex(atom, render, implh, rightMargin): ElemAttr {\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const delta = 0.5 * options.lineWidth\n const hydroIndex: any = {}\n hydroIndex.text = (implh + 1).toString()\n hydroIndex.path = render.paper.text(ps.x, ps.y, hydroIndex.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: atom.color\n })\n hydroIndex.rbb = util.relBox(hydroIndex.path.getBBox())\n draw.recenterText(hydroIndex.path, hydroIndex.rbb)\n /* eslint-disable no-mixed-operators*/\n pathAndRBoxTranslate(\n hydroIndex.path,\n hydroIndex.rbb,\n rightMargin + 0.5 * hydroIndex.rbb.width + delta,\n 0.2 * atom.label.rbb.height\n )\n /* eslint-enable no-mixed-operators*/\n return hydroIndex\n}\n\nfunction showRadical(atom: ReAtom, render: Render): Omit {\n const ps: Vec2 = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const paper: any = render.paper\n const radical: any = {}\n let hshift\n switch (atom.a.radical) {\n case 1:\n radical.path = paper.set()\n hshift = 1.6 * options.lineWidth\n radical.path.push(\n draw.radicalBullet(paper, ps.add(new Vec2(-hshift, 0)), options),\n draw.radicalBullet(paper, ps.add(new Vec2(hshift, 0)), options)\n )\n radical.path.attr('fill', atom.color)\n break\n case 2:\n radical.path = paper.set()\n radical.path.push(draw.radicalBullet(paper, ps, options))\n radical.path.attr('fill', atom.color)\n break\n case 3:\n radical.path = paper.set()\n hshift = 1.6 * options.lineWidth\n radical.path.push(\n draw.radicalCap(paper, ps.add(new Vec2(-hshift, 0)), options),\n draw.radicalCap(paper, ps.add(new Vec2(hshift, 0)), options)\n )\n radical.path.attr('stroke', atom.color)\n break\n default:\n break\n }\n radical.rbb = util.relBox(radical.path.getBBox())\n let vshift = -0.5 * (atom.label!.rbb.height + radical.rbb.height)\n if (atom.a.radical === 3) vshift -= options.lineWidth / 2\n pathAndRBoxTranslate(radical.path, radical.rbb, 0, vshift)\n return radical\n}\n\nfunction showIsotope(\n atom: ReAtom,\n render: Render,\n leftMargin: number\n): ElemAttr {\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const delta = 0.5 * options.lineWidth\n const isotope: any = {}\n isotope.text = atom.a.isotope.toString()\n isotope.path = render.paper.text(ps.x, ps.y, isotope.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: atom.color\n })\n isotope.rbb = util.relBox(isotope.path.getBBox())\n draw.recenterText(isotope.path, isotope.rbb)\n /* eslint-disable no-mixed-operators*/\n pathAndRBoxTranslate(\n isotope.path,\n isotope.rbb,\n leftMargin - 0.5 * isotope.rbb.width - delta,\n -0.3 * atom.label!.rbb.height\n )\n /* eslint-enable no-mixed-operators*/\n return isotope\n}\n\nfunction showCharge(\n atom: ReAtom,\n render: Render,\n rightMargin: number\n): ElemAttr {\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const delta = 0.5 * options.lineWidth\n const charge: any = {}\n charge.text = ''\n const absCharge = Math.abs(atom.a.charge)\n if (absCharge !== 1) charge.text = absCharge.toString()\n if (atom.a.charge < 0) charge.text += '\\u2013'\n else charge.text += '+'\n\n charge.path = render.paper.text(ps.x, ps.y, charge.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: atom.color\n })\n charge.rbb = util.relBox(charge.path.getBBox())\n draw.recenterText(charge.path, charge.rbb)\n /* eslint-disable no-mixed-operators*/\n pathAndRBoxTranslate(\n charge.path,\n charge.rbb,\n rightMargin + 0.5 * charge.rbb.width + delta,\n -0.3 * atom.label!.rbb.height\n )\n /* eslint-enable no-mixed-operators*/\n return charge\n}\n\nfunction showExplicitValence(\n atom: ReAtom,\n render: Render,\n rightMargin: number\n): ElemAttr {\n const mapValence = {\n 0: '0',\n 1: 'I',\n 2: 'II',\n 3: 'III',\n 4: 'IV',\n 5: 'V',\n 6: 'VI',\n 7: 'VII',\n 8: 'VIII',\n 9: 'IX',\n 10: 'X',\n 11: 'XI',\n 12: 'XII',\n 13: 'XIII',\n 14: 'XIV'\n }\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const delta = 0.5 * options.lineWidth\n const valence: any = {}\n valence.text = mapValence[atom.a.explicitValence]\n if (!valence.text)\n throw new Error('invalid valence ' + atom.a.explicitValence.toString())\n valence.text = '(' + valence.text + ')'\n valence.path = render.paper.text(ps.x, ps.y, valence.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: atom.color\n })\n valence.rbb = util.relBox(valence.path.getBBox())\n draw.recenterText(valence.path, valence.rbb)\n /* eslint-disable no-mixed-operators*/\n pathAndRBoxTranslate(\n valence.path,\n valence.rbb,\n rightMargin + 0.5 * valence.rbb.width + delta,\n -0.3 * atom.label!.rbb.height\n )\n /* eslint-enable no-mixed-operators*/\n return valence\n}\n\nfunction showHydrogen(\n atom: ReAtom,\n render: Render,\n implh: number,\n data: {\n hydrogen: any\n hydroIndex: number\n rightMargin: number\n leftMargin: number\n }\n): {\n hydrogen: ElemAttr\n hydroIndex: ElemAttr\n rightMargin: number\n leftMargin: number\n} {\n // eslint-disable-line max-statements\n let hydroIndex: any = data.hydroIndex\n const hydrogenLeft = atom.hydrogenOnTheLeft\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const delta = 0.5 * options.lineWidth\n const hydrogen = data.hydrogen\n hydrogen.text = 'H'\n hydrogen.path = render.paper.text(ps.x, ps.y, hydrogen.text).attr({\n font: options.font,\n 'font-size': options.fontsz,\n fill: atom.color\n })\n hydrogen.rbb = util.relBox(hydrogen.path.getBBox())\n draw.recenterText(hydrogen.path, hydrogen.rbb)\n if (!hydrogenLeft) {\n pathAndRBoxTranslate(\n hydrogen.path,\n hydrogen.rbb,\n data.rightMargin + 0.5 * hydrogen.rbb.width + delta,\n 0\n )\n data.rightMargin += hydrogen.rbb.width + delta\n }\n if (implh > 1) {\n hydroIndex = {}\n hydroIndex.text = implh.toString()\n hydroIndex.path = render.paper.text(ps.x, ps.y, hydroIndex.text).attr({\n font: options.font,\n 'font-size': options.fontszsub,\n fill: atom.color\n })\n hydroIndex.rbb = util.relBox(hydroIndex.path.getBBox())\n draw.recenterText(hydroIndex.path, hydroIndex.rbb)\n if (!hydrogenLeft) {\n pathAndRBoxTranslate(\n hydroIndex.path,\n hydroIndex.rbb,\n data.rightMargin +\n 0.5 * hydroIndex.rbb.width * (options.zoom > 1 ? 1 : options.zoom) +\n delta,\n 0.2 * atom.label!.rbb.height\n )\n data.rightMargin += hydroIndex.rbb.width + delta\n }\n }\n if (hydrogenLeft) {\n if (hydroIndex != null) {\n pathAndRBoxTranslate(\n hydroIndex.path,\n hydroIndex.rbb,\n data.leftMargin - 0.5 * hydroIndex.rbb.width - delta,\n 0.2 * atom.label!.rbb.height\n )\n data.leftMargin -= hydroIndex.rbb.width + delta\n }\n pathAndRBoxTranslate(\n hydrogen.path,\n hydrogen.rbb,\n data.leftMargin -\n 0.5 *\n hydrogen.rbb.width *\n (implh > 1 && options.zoom < 1 ? options.zoom : 1) -\n delta,\n 0\n )\n data.leftMargin -= hydrogen.rbb.width + delta\n }\n return Object.assign(data, { hydrogen, hydroIndex })\n}\n\nfunction showWarning(\n atom,\n render,\n leftMargin,\n rightMargin\n): { rbb: DOMRect; path: any } {\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const delta = 0.5 * render.options.lineWidth\n const tfx = util.tfx\n const warning: any = {}\n const y = ps.y + atom.label.rbb.height / 2 + delta\n warning.path = render.paper\n .path(\n 'M{0},{1}L{2},{3}',\n tfx(ps.x + leftMargin),\n tfx(y),\n tfx(ps.x + rightMargin),\n tfx(y)\n )\n .attr(render.options.lineattr)\n .attr({ stroke: '#F00' })\n warning.rbb = util.relBox(warning.path.getBBox())\n return warning\n}\n\nfunction showAttpnt(atom, render, lsb, addReObjectPath) {\n // eslint-disable-line max-statements\n const asterisk = '∗'\n const ps = Scale.obj2scaled(atom.a.pp, render.options)\n const options = render.options\n const tfx = util.tfx\n let i, j\n for (i = 0; i < 4; ++i) {\n let attpntText = ''\n if (atom.a.attpnt & (1 << i)) {\n if (attpntText.length > 0) attpntText += ' '\n attpntText += asterisk\n for (j = 0; j < (i == 0 ? 0 : i + 1); ++j) attpntText += \"'\"\n let pos0 = new Vec2(ps)\n let pos1 = ps.addScaled(lsb, 0.7 * options.scale)\n\n const attpntPath1 = render.paper.text(pos1.x, pos1.y, attpntText).attr({\n font: options.font,\n 'font-size': options.fontsz,\n fill: atom.color\n })\n const attpntRbb = util.relBox(attpntPath1.getBBox())\n draw.recenterText(attpntPath1, attpntRbb)\n\n const lsbn = lsb.negated()\n /* eslint-disable no-mixed-operators*/\n pos1 = pos1.addScaled(\n lsbn,\n util.shiftRayBox(pos1, lsbn, Box2Abs.fromRelBox(attpntRbb)) +\n options.lineWidth / 2\n )\n /* eslint-enable no-mixed-operators*/\n pos0 = shiftBondEnd(atom, pos0, lsb, options.lineWidth)\n const n = lsb.rotateSC(1, 0)\n const arrowLeft = pos1\n .addScaled(n, 0.05 * options.scale)\n .addScaled(lsbn, 0.09 * options.scale)\n const arrowRight = pos1\n .addScaled(n, -0.05 * options.scale)\n .addScaled(lsbn, 0.09 * options.scale)\n const attpntPath = render.paper.set()\n attpntPath.push(\n attpntPath1,\n render.paper\n .path(\n 'M{0},{1}L{2},{3}M{4},{5}L{2},{3}L{6},{7}',\n tfx(pos0.x),\n tfx(pos0.y),\n tfx(pos1.x),\n tfx(pos1.y),\n tfx(arrowLeft.x),\n tfx(arrowLeft.y),\n tfx(arrowRight.x),\n tfx(arrowRight.y)\n )\n .attr(render.options.lineattr)\n .attr({ 'stroke-width': options.lineWidth / 2 })\n )\n addReObjectPath(LayerMap.indices, atom.visel, attpntPath, ps)\n lsb = lsb.rotate(Math.PI / 6)\n }\n }\n}\n\n// function getStereoLabelText(atom, aid, render) {\n// \tconst struct = render.ctab.molecule;\n// \tconst frag = struct.frags.get(atom.a.fragment);\n// \tconst stereo = frag.getStereoAtomMark(aid);\n// \tif (!stereo.type) return null;\n//\n// \treturn stereo.type + (stereo.number || '');\n// }\n\nfunction getAamText(atom) {\n let aamText = ''\n if (atom.a.aam > 0) aamText += atom.a.aam\n if (atom.a.invRet > 0) {\n if (aamText.length > 0) aamText += ','\n if (atom.a.invRet == 1) aamText += 'Inv'\n else if (atom.a.invRet == 2) aamText += 'Ret'\n else throw new Error('Invalid value for the invert/retain flag')\n }\n if (atom.a.exactChangeFlag > 0) {\n if (aamText.length > 0) aamText += ','\n if (atom.a.exactChangeFlag == 1) aamText += 'ext'\n else throw new Error('Invalid value for the exact change flag')\n }\n return aamText\n}\n\nfunction getQueryAttrsText(atom) {\n let queryAttrsText = ''\n if (atom.a.ringBondCount != 0) {\n if (atom.a.ringBondCount > 0)\n queryAttrsText += 'rb' + atom.a.ringBondCount.toString()\n else if (atom.a.ringBondCount == -1) queryAttrsText += 'rb0'\n else if (atom.a.ringBondCount == -2) queryAttrsText += 'rb*'\n else throw new Error('Ring bond count invalid')\n }\n if (atom.a.substitutionCount != 0) {\n if (queryAttrsText.length > 0) queryAttrsText += ','\n if (atom.a.substitutionCount > 0)\n queryAttrsText += 's' + atom.a.substitutionCount.toString()\n else if (atom.a.substitutionCount == -1) queryAttrsText += 's0'\n else if (atom.a.substitutionCount == -2) queryAttrsText += 's*'\n else throw new Error('Substitution count invalid')\n }\n if (atom.a.unsaturatedAtom > 0) {\n if (queryAttrsText.length > 0) queryAttrsText += ','\n if (atom.a.unsaturatedAtom == 1) queryAttrsText += 'u'\n else throw new Error('Unsaturated atom invalid value')\n }\n if (atom.a.hCount > 0) {\n if (queryAttrsText.length > 0) queryAttrsText += ','\n queryAttrsText += 'H' + (atom.a.hCount - 1).toString()\n }\n return queryAttrsText\n}\n\nfunction pathAndRBoxTranslate(path, rbb, x, y) {\n path.translateAbs(x, y)\n rbb.x += x\n rbb.y += y\n}\n\nfunction bisectLargestSector(atom: ReAtom, struct: Struct) {\n let angles: Array = []\n atom.a.neighbors.forEach(hbid => {\n const hb = struct.halfBonds.get(hbid)\n hb && angles.push(hb.ang)\n })\n angles = angles.sort((a, b) => a - b)\n const da: Array = []\n for (let i = 0; i < angles.length - 1; ++i) {\n da.push(angles[(i + 1) % angles.length] - angles[i])\n }\n da.push(angles[0] - angles[angles.length - 1] + 2 * Math.PI)\n let daMax = 0\n let ang = -Math.PI / 2\n for (let i = 0; i < angles.length; ++i) {\n if (da[i] > daMax) {\n daMax = da[i]\n ang = angles[i] + da[i] / 2\n }\n }\n return new Vec2(Math.cos(ang), Math.sin(ang))\n}\n\nfunction shiftBondEnd(atom, pos0, dir, margin) {\n let t = 0\n const visel = atom.visel\n for (let k = 0; k < visel.exts.length; ++k) {\n const box = visel.exts[k].translate(pos0)\n t = Math.max(t, util.shiftRayBox(pos0, dir, box))\n }\n if (t > 0) pos0 = pos0.addScaled(dir, t + margin)\n return pos0\n}\n\nexport default ReAtom\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Atom,\n Bond,\n FunctionalGroup,\n HalfBond,\n Struct,\n Vec2\n} from 'domain/entities'\nimport { LayerMap, StereoColoringType } from './generalEnumTypes'\nimport ReAtom, { getColorFromStereoLabel } from './reatom'\n\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\nclass ReBond extends ReObject {\n b: Bond\n doubleBondShift: number\n path: any\n neihbid1: number = -1\n neihbid2: number = -1\n boldStereo?: boolean\n rbb?: { x: number; y: number; width: number; height: number }\n\n constructor(bond: Bond) {\n super('bond')\n this.b = bond // TODO rename b to item\n this.doubleBondShift = 0\n }\n static isSelectable() {\n return true\n }\n drawHighlight(render: Render) {\n const ret = this.makeHighlightPlate(render)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n makeHighlightPlate(render: Render) {\n const options = render.options\n bondRecalc(this, render.ctab, options)\n const bond = this.b\n const sgroups = render.ctab.sgroups\n const functionalGroups = render.ctab.molecule.functionalGroups\n if (\n FunctionalGroup.isBondInContractedFunctionalGroup(\n bond,\n sgroups,\n functionalGroups,\n true\n )\n )\n return null\n\n const c = Scale.obj2scaled(this.b.center, options)\n return render.paper\n .circle(c.x, c.y, 0.8 * options.atomSelectionPlateRadius)\n .attr(options.highlightStyle)\n }\n makeSelectionPlate(restruct: ReStruct, paper: any, options: any) {\n bondRecalc(this, restruct, options)\n const bond = this.b\n const sgroups = restruct.render.ctab.sgroups\n const functionalGroups = restruct.render.ctab.molecule.functionalGroups\n if (\n FunctionalGroup.isBondInContractedFunctionalGroup(\n bond,\n sgroups,\n functionalGroups,\n true\n )\n )\n return null\n\n const c = Scale.obj2scaled(this.b.center, options)\n return paper\n .circle(c.x, c.y, 0.8 * options.atomSelectionPlateRadius)\n .attr(options.selectionStyle)\n }\n\n show(restruct: ReStruct, bid: number, options: any): void {\n // eslint-disable-line max-statements\n const render = restruct.render\n const struct = restruct.molecule\n const bond = restruct.molecule.bonds.get(bid)\n const sgroups = restruct.molecule.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n if (\n FunctionalGroup.isBondInContractedFunctionalGroup(\n bond,\n sgroups,\n functionalGroups,\n false\n )\n )\n return\n\n const paper = render.paper\n const hb1 =\n this.b.hb1 !== undefined ? struct.halfBonds.get(this.b.hb1) : null,\n hb2 = this.b.hb2 !== undefined ? struct.halfBonds.get(this.b.hb2) : null\n\n checkStereoBold(bid, this, restruct)\n bondRecalc(this, restruct, options)\n setDoubleBondShift(this, struct)\n if (!hb1 || !hb2) return\n this.path = getBondPath(restruct, this, hb1, hb2)\n this.rbb = util.relBox(this.path.getBBox())\n restruct.addReObjectPath(LayerMap.data, this.visel, this.path, null, true)\n const reactingCenter: any = {}\n reactingCenter.path = getReactingCenterPath(render, this, hb1, hb2)\n if (reactingCenter.path) {\n reactingCenter.rbb = util.relBox(reactingCenter.path.getBBox())\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n reactingCenter.path,\n null,\n true\n )\n }\n const topology: any = {}\n topology.path = getTopologyMark(render, this, hb1, hb2)\n if (topology.path) {\n topology.rbb = util.relBox(topology.path.getBBox())\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n topology.path,\n null,\n true\n )\n }\n this.setHighlight(this.highlight, render)\n\n let ipath = null\n const bondIdxOff = options.subFontSize * 0.6\n if (options.showBondIds) {\n ipath = getIdsPath(bid, paper, hb1, hb2, bondIdxOff, 0.5, 0.5, hb1.norm)\n restruct.addReObjectPath(LayerMap.indices, this.visel, ipath)\n }\n if (options.showHalfBondIds) {\n ipath = getIdsPath(\n this.b.hb1!,\n paper,\n hb1,\n hb2,\n bondIdxOff,\n 0.8,\n 0.2,\n hb1.norm\n )\n restruct.addReObjectPath(LayerMap.indices, this.visel, ipath)\n ipath = getIdsPath(\n this.b.hb2!,\n paper,\n hb1,\n hb2,\n bondIdxOff,\n 0.2,\n 0.8,\n hb2.norm\n )\n restruct.addReObjectPath(LayerMap.indices, this.visel, ipath)\n }\n if (options.showLoopIds && !options.showBondIds) {\n ipath = getIdsPath(\n hb1.loop,\n paper,\n hb1,\n hb2,\n bondIdxOff,\n 0.5,\n 0.5,\n hb2.norm\n )\n restruct.addReObjectPath(LayerMap.indices, this.visel, ipath)\n ipath = getIdsPath(\n hb2.loop,\n paper,\n hb1,\n hb2,\n bondIdxOff,\n 0.5,\n 0.5,\n hb1.norm\n )\n restruct.addReObjectPath(LayerMap.indices, this.visel, ipath)\n }\n }\n}\n\nfunction findIncomingStereoUpBond(\n atom: Atom,\n bid0: number,\n includeBoldStereoBond: boolean,\n restruct: ReStruct\n): number {\n return atom.neighbors.findIndex(hbid => {\n const hb = restruct.molecule.halfBonds.get(hbid)\n\n if (!hb || hb.bid === bid0) return false\n\n const neibond = restruct.bonds.get(hb.bid)\n\n if (!neibond) return false\n const singleUp =\n neibond.b.type === Bond.PATTERN.TYPE.SINGLE &&\n neibond.b.stereo === Bond.PATTERN.STEREO.UP\n\n if (singleUp)\n return (\n neibond.b.end === hb.begin ||\n (neibond.boldStereo && includeBoldStereoBond)\n )\n\n return !!(\n neibond.b.type === Bond.PATTERN.TYPE.DOUBLE &&\n neibond.b.stereo === Bond.PATTERN.STEREO.NONE &&\n includeBoldStereoBond &&\n neibond.boldStereo\n )\n })\n}\n\nfunction findIncomingUpBonds(\n bid0: number,\n bond: ReBond,\n restruct: ReStruct\n): void {\n const halfbonds = [bond.b.begin, bond.b.end].map(aid => {\n const atom = restruct.molecule.atoms.get(aid)\n if (!atom) return -1\n const pos = findIncomingStereoUpBond(atom, bid0, true, restruct)\n return pos < 0 ? -1 : atom.neighbors[pos]\n })\n\n bond.neihbid1 = restruct.atoms.get(bond.b.begin)?.showLabel\n ? -1\n : halfbonds[0]\n bond.neihbid2 = restruct.atoms.get(bond.b.end)?.showLabel ? -1 : halfbonds[1]\n}\n\nfunction checkStereoBold(bid0, bond, restruct) {\n const halfbonds = [bond.b.begin, bond.b.end].map(aid => {\n const atom = restruct.molecule.atoms.get(aid)\n const pos = findIncomingStereoUpBond(atom, bid0, false, restruct)\n return pos < 0 ? -1 : atom.neighbors[pos]\n })\n bond.boldStereo = halfbonds[0] >= 0 && halfbonds[1] >= 0\n}\n\nfunction getBondPath(\n restruct: ReStruct,\n bond: ReBond,\n hb1: HalfBond,\n hb2: HalfBond\n) {\n let path = null\n const render = restruct.render\n const struct = restruct.molecule\n const shiftA = !restruct.atoms.get(hb1.begin)?.showLabel\n const shiftB = !restruct.atoms.get(hb2.begin)?.showLabel\n\n switch (bond.b.type) {\n case Bond.PATTERN.TYPE.SINGLE:\n switch (bond.b.stereo) {\n case Bond.PATTERN.STEREO.UP:\n findIncomingUpBonds(hb1.bid, bond, restruct)\n if (bond.boldStereo && bond.neihbid1 >= 0 && bond.neihbid2 >= 0)\n path = getBondSingleStereoBoldPath(render, hb1, hb2, bond, struct)\n else path = getBondSingleUpPath(render, hb1, hb2, bond, struct)\n break\n case Bond.PATTERN.STEREO.DOWN:\n path = getBondSingleDownPath(render, hb1, hb2, bond, struct)\n break\n case Bond.PATTERN.STEREO.EITHER:\n path = getBondSingleEitherPath(render, hb1, hb2, bond, struct)\n break\n default:\n path = draw.bondSingle(\n render.paper,\n hb1,\n hb2,\n render.options,\n getStereoBondColor(render.options, bond, struct)\n )\n break\n }\n break\n case Bond.PATTERN.TYPE.DOUBLE:\n findIncomingUpBonds(hb1.bid, bond, restruct)\n if (\n bond.b.stereo === Bond.PATTERN.STEREO.NONE &&\n bond.boldStereo &&\n bond.neihbid1 >= 0 &&\n bond.neihbid2 >= 0\n )\n path = getBondDoubleStereoBoldPath(\n render,\n hb1,\n hb2,\n bond,\n struct,\n shiftA,\n shiftB\n )\n else path = getBondDoublePath(render, hb1, hb2, bond, shiftA, shiftB)\n break\n case Bond.PATTERN.TYPE.TRIPLE:\n path = draw.bondTriple(render.paper, hb1, hb2, render.options)\n break\n case Bond.PATTERN.TYPE.AROMATIC:\n const inAromaticLoop =\n (hb1.loop >= 0 && struct.loops.get(hb1.loop)?.aromatic) ||\n (hb2.loop >= 0 && struct.loops.get(hb2.loop)?.aromatic)\n path = inAromaticLoop\n ? draw.bondSingle(render.paper, hb1, hb2, render.options)\n : getBondAromaticPath(render, hb1, hb2, bond, shiftA, shiftB)\n break\n case Bond.PATTERN.TYPE.SINGLE_OR_DOUBLE:\n path = getSingleOrDoublePath(render, hb1, hb2)\n break\n case Bond.PATTERN.TYPE.SINGLE_OR_AROMATIC:\n path = getBondAromaticPath(render, hb1, hb2, bond, shiftA, shiftB)\n break\n case Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC:\n path = getBondAromaticPath(render, hb1, hb2, bond, shiftA, shiftB)\n break\n case Bond.PATTERN.TYPE.ANY:\n path = draw.bondAny(render.paper, hb1, hb2, render.options)\n break\n case Bond.PATTERN.TYPE.HYDROGEN:\n path = draw.bondHydrogen(render.paper, hb1, hb2, render.options)\n break\n case Bond.PATTERN.TYPE.DATIVE:\n path = draw.bondDative(render.paper, hb1, hb2, render.options)\n break\n default:\n throw new Error('Bond type ' + bond.b.type + ' not supported')\n }\n return path\n}\n\n/* Get Path */\nfunction getBondSingleUpPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n struct: Struct\n) {\n // eslint-disable-line max-params\n const a = hb1.p,\n b = hb2.p,\n n = hb1.norm\n const options = render.options\n const bsp = 0.7 * options.stereoBond\n let b2 = b.addScaled(n, bsp)\n let b3 = b.addScaled(n, -bsp)\n if (bond.neihbid2 >= 0) {\n // if the end is shared with another up-bond heading this way\n var coords = stereoUpBondGetCoordinates(\n hb2,\n bond.neihbid2,\n options.stereoBond,\n struct\n )\n b2 = coords[0]\n b3 = coords[1]\n }\n return draw.bondSingleUp(\n render.paper,\n a,\n b2,\n b3,\n options,\n getStereoBondColor(options, bond, struct)\n )\n}\n\nfunction getStereoBondColor(\n options: any,\n bond: ReBond,\n struct: Struct\n): string {\n const defaultColor = '#000'\n\n if (bond.b.stereo === 0) return defaultColor\n\n const beginAtomStereoLabel = struct.atoms.get(bond.b.begin)?.stereoLabel\n const endAtomStereoLabel = struct.atoms.get(bond.b.end)?.stereoLabel\n\n let stereoLabel = ''\n if (beginAtomStereoLabel && !endAtomStereoLabel) {\n stereoLabel = beginAtomStereoLabel\n } else if (!beginAtomStereoLabel && endAtomStereoLabel) {\n stereoLabel = endAtomStereoLabel\n }\n\n if (\n // if no stereolabel presents or presents in both then use default color\n !stereoLabel ||\n options.colorStereogenicCenters === StereoColoringType.Off ||\n options.colorStereogenicCenters === StereoColoringType.LabelsOnly\n ) {\n return defaultColor\n }\n\n return getColorFromStereoLabel(options, stereoLabel)\n}\n\nfunction getBondSingleStereoBoldPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n struct: Struct\n) {\n // eslint-disable-line max-params\n const options = render.options\n const coords1 = stereoUpBondGetCoordinates(\n hb1,\n bond.neihbid1,\n options.stereoBond,\n struct\n )\n const coords2 = stereoUpBondGetCoordinates(\n hb2,\n bond.neihbid2,\n options.stereoBond,\n struct\n )\n const a1 = coords1[0]\n const a2 = coords1[1]\n const a3 = coords2[0]\n const a4 = coords2[1]\n return draw.bondSingleStereoBold(\n render.paper,\n a1,\n a2,\n a3,\n a4,\n options,\n getStereoBondColor(options, bond, struct)\n )\n}\n\nfunction getBondDoubleStereoBoldPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n struct: Struct,\n shiftA: boolean,\n shiftB: boolean\n) {\n // eslint-disable-line max-params\n const a = hb1.p,\n b = hb2.p,\n n = hb1.norm,\n shift = bond.doubleBondShift\n const bsp = 1.5 * render.options.stereoBond\n let b1 = a.addScaled(n, bsp * shift)\n let b2 = b.addScaled(n, bsp * shift)\n if (shift > 0) {\n if (shiftA)\n b1 = b1.addScaled(\n hb1.dir,\n bsp * getBondLineShift(hb1.rightCos, hb1.rightSin)\n )\n if (shiftB)\n b2 = b2.addScaled(\n hb1.dir,\n -bsp * getBondLineShift(hb2.leftCos, hb2.leftSin)\n )\n } else if (shift < 0) {\n if (shiftA)\n b1 = b1.addScaled(\n hb1.dir,\n bsp * getBondLineShift(hb1.leftCos, hb1.leftSin)\n )\n if (shiftB)\n b2 = b2.addScaled(\n hb1.dir,\n -bsp * getBondLineShift(hb2.rightCos, hb2.rightSin)\n )\n }\n const sgBondPath = getBondSingleStereoBoldPath(render, hb1, hb2, bond, struct)\n return draw.bondDoubleStereoBold(\n render.paper,\n sgBondPath,\n b1,\n b2,\n render.options,\n getStereoBondColor(render.options, bond, struct)\n )\n}\n\nfunction getBondLineShift(cos: number, sin: number): number {\n if (sin < 0 || Math.abs(cos) > 0.9) return 0\n return sin / (1 - cos)\n}\n\nfunction stereoUpBondGetCoordinates(\n hb: HalfBond,\n neihbid: number,\n bondSpace: any,\n struct: Struct\n): [Vec2, Vec2] {\n const neihb = struct.halfBonds.get(neihbid)\n const cos = Vec2.dot(hb.dir, neihb!.dir)\n const sin = Vec2.cross(hb.dir, neihb!.dir)\n const cosHalf = Math.sqrt(0.5 * (1 - cos))\n const biss = neihb!.dir.rotateSC(\n (sin >= 0 ? -1 : 1) * cosHalf,\n Math.sqrt(0.5 * (1 + cos))\n )\n\n const denomAdd = 0.3\n const scale = 0.7\n const a1 = hb.p.addScaled(biss, (scale * bondSpace) / (cosHalf + denomAdd))\n const a2 = hb.p.addScaled(\n biss.negated(),\n (scale * bondSpace) / (cosHalf + denomAdd)\n )\n return sin > 0 ? [a1, a2] : [a2, a1]\n}\n\nfunction getBondSingleDownPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n struct: Struct\n) {\n const a = hb1.p,\n b = hb2.p\n const options = render.options\n let d = b.sub(a)\n const len = d.length() + 0.2\n d = d.normalized()\n const interval = 1.2 * options.lineWidth\n const nlines =\n Math.max(\n Math.floor((len - options.lineWidth) / (options.lineWidth + interval)),\n 0\n ) + 2\n const step = len / (nlines - 1)\n return draw.bondSingleDown(\n render.paper,\n hb1,\n d,\n nlines,\n step,\n options,\n getStereoBondColor(options, bond, struct)\n )\n}\n\nfunction getBondSingleEitherPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n struct: Struct\n) {\n const a = hb1.p,\n b = hb2.p\n const options = render.options\n let d = b.sub(a)\n const len = d.length()\n d = d.normalized()\n const interval = 0.6 * options.lineWidth\n const nlines =\n Math.max(\n Math.floor((len - options.lineWidth) / (options.lineWidth + interval)),\n 0\n ) + 2\n const step = len / (nlines - 0.5)\n return draw.bondSingleEither(\n render.paper,\n hb1,\n d,\n nlines,\n step,\n options,\n getStereoBondColor(options, bond, struct)\n )\n}\n\nfunction getBondDoublePath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n shiftA: boolean,\n shiftB: boolean\n) {\n // eslint-disable-line max-params, max-statements\n const cisTrans = bond.b.stereo === Bond.PATTERN.STEREO.CIS_TRANS\n\n const a = hb1.p\n const b = hb2.p\n const n = hb1.norm\n const shift = cisTrans ? 0 : bond.doubleBondShift\n\n const options = render.options\n const bsp = options.bondSpace / 2\n const s1 = bsp + shift * bsp\n const s2 = -bsp + shift * bsp\n\n let a1 = a.addScaled(n, s1)\n let b1 = b.addScaled(n, s1)\n let a2 = a.addScaled(n, s2)\n let b2 = b.addScaled(n, s2)\n\n if (shift > 0) {\n if (shiftA) {\n a1 = a1.addScaled(\n hb1.dir,\n options.bondSpace * getBondLineShift(hb1.rightCos, hb1.rightSin)\n )\n }\n if (shiftB) {\n b1 = b1.addScaled(\n hb1.dir,\n -options.bondSpace * getBondLineShift(hb2.leftCos, hb2.leftSin)\n )\n }\n } else if (shift < 0) {\n if (shiftA) {\n a2 = a2.addScaled(\n hb1.dir,\n options.bondSpace * getBondLineShift(hb1.leftCos, hb1.leftSin)\n )\n }\n if (shiftB) {\n b2 = b2.addScaled(\n hb1.dir,\n -options.bondSpace * getBondLineShift(hb2.rightCos, hb2.rightSin)\n )\n }\n }\n\n return draw.bondDouble(render.paper, a1, a2, b1, b2, cisTrans, options)\n}\n\nfunction getSingleOrDoublePath(render: Render, hb1: HalfBond, hb2: HalfBond) {\n const a = hb1.p,\n b = hb2.p\n const options = render.options\n\n let nSect =\n Vec2.dist(a, b) / Number((options.bondSpace + options.lineWidth).toFixed())\n if (!(nSect & 1)) nSect += 1\n return draw.bondSingleOrDouble(render.paper, hb1, hb2, nSect, options)\n}\n\nfunction getBondAromaticPath(\n render: Render,\n hb1: HalfBond,\n hb2: HalfBond,\n bond: ReBond,\n shiftA: boolean,\n shiftB: boolean\n) {\n // eslint-disable-line max-params\n const dashdotPattern = [0.125, 0.125, 0.005, 0.125]\n let mark: number | null = null,\n dash: number[] | null = null\n const options = render.options\n const bondShift = bond.doubleBondShift\n\n if (bond.b.type === Bond.PATTERN.TYPE.SINGLE_OR_AROMATIC) {\n mark = bondShift > 0 ? 1 : 2\n dash = dashdotPattern.map(v => v * options.scale)\n }\n if (bond.b.type === Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC) {\n mark = 3\n dash = dashdotPattern.map(v => v * options.scale)\n }\n const paths = getAromaticBondPaths(\n hb1,\n hb2,\n bondShift,\n shiftA,\n shiftB,\n options.bondSpace,\n mark,\n dash\n )\n return draw.bondAromatic(render.paper, paths, bondShift, options)\n}\n\nfunction getAromaticBondPaths(\n hb1: HalfBond,\n hb2: HalfBond,\n shift: number,\n shiftA: boolean,\n shiftB: boolean,\n bondSpace: number,\n mask: number | null,\n dash: number[] | null\n) {\n // eslint-disable-line max-params, max-statements\n const a = hb1.p,\n b = hb2.p,\n n = hb1.norm\n const bsp = bondSpace / 2\n const s1 = bsp + shift * bsp,\n s2 = -bsp + shift * bsp\n let a2 = a.addScaled(n, s1)\n let b2 = b.addScaled(n, s1)\n let a3 = a.addScaled(n, s2)\n let b3 = b.addScaled(n, s2)\n if (shift > 0) {\n if (shiftA) {\n a2 = a2.addScaled(\n hb1.dir,\n bondSpace * getBondLineShift(hb1.rightCos, hb1.rightSin)\n )\n }\n if (shiftB) {\n b2 = b2.addScaled(\n hb1.dir,\n -bondSpace * getBondLineShift(hb2.leftCos, hb2.leftSin)\n )\n }\n } else if (shift < 0) {\n if (shiftA) {\n a3 = a3.addScaled(\n hb1.dir,\n bondSpace * getBondLineShift(hb1.leftCos, hb1.leftSin)\n )\n }\n if (shiftB) {\n b3 = b3.addScaled(\n hb1.dir,\n -bondSpace * getBondLineShift(hb2.rightCos, hb2.rightSin)\n )\n }\n }\n return draw.aromaticBondPaths(a2, a3, b2, b3, mask, dash)\n}\n\nfunction getReactingCenterPath(\n render: Render,\n bond: ReBond,\n hb1: HalfBond,\n hb2: HalfBond\n) {\n // eslint-disable-line max-statements\n const a = hb1.p,\n b = hb2.p\n const c = b.add(a).scaled(0.5)\n const d = b.sub(a).normalized()\n const n = d.rotateSC(1, 0)\n\n const p: Array = []\n\n const lw = render.options.lineWidth,\n bs = render.options.bondSpace / 2\n const alongIntRc = lw, // half interval along for CENTER\n alongIntMadeBroken = 2 * lw, // half interval between along for MADE_OR_BROKEN\n alongSz = 1.5 * bs, // half size along for CENTER\n acrossInt = 1.5 * bs, // half interval across for CENTER\n acrossSz = 3.0 * bs, // half size across for all\n tiltTan = 0.2 // tangent of the tilt angle\n\n switch (bond.b.reactingCenterStatus) {\n case Bond.PATTERN.REACTING_CENTER.NOT_CENTER: // X\n p.push(c.addScaled(n, acrossSz).addScaled(d, tiltTan * acrossSz))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, -tiltTan * acrossSz))\n p.push(c.addScaled(n, acrossSz).addScaled(d, -tiltTan * acrossSz))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, tiltTan * acrossSz))\n break\n case Bond.PATTERN.REACTING_CENTER.CENTER: // #\n p.push(\n c\n .addScaled(n, acrossSz)\n .addScaled(d, tiltTan * acrossSz)\n .addScaled(d, alongIntRc)\n )\n p.push(\n c\n .addScaled(n, -acrossSz)\n .addScaled(d, -tiltTan * acrossSz)\n .addScaled(d, alongIntRc)\n )\n p.push(\n c\n .addScaled(n, acrossSz)\n .addScaled(d, tiltTan * acrossSz)\n .addScaled(d, -alongIntRc)\n )\n p.push(\n c\n .addScaled(n, -acrossSz)\n .addScaled(d, -tiltTan * acrossSz)\n .addScaled(d, -alongIntRc)\n )\n p.push(c.addScaled(d, alongSz).addScaled(n, acrossInt))\n p.push(c.addScaled(d, -alongSz).addScaled(n, acrossInt))\n p.push(c.addScaled(d, alongSz).addScaled(n, -acrossInt))\n p.push(c.addScaled(d, -alongSz).addScaled(n, -acrossInt))\n break\n // case Bond.PATTERN.REACTING_CENTER.UNCHANGED: draw a circle\n case Bond.PATTERN.REACTING_CENTER.MADE_OR_BROKEN:\n p.push(c.addScaled(n, acrossSz).addScaled(d, alongIntMadeBroken))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, alongIntMadeBroken))\n p.push(c.addScaled(n, acrossSz).addScaled(d, -alongIntMadeBroken))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, -alongIntMadeBroken))\n break\n case Bond.PATTERN.REACTING_CENTER.ORDER_CHANGED:\n p.push(c.addScaled(n, acrossSz))\n p.push(c.addScaled(n, -acrossSz))\n break\n case Bond.PATTERN.REACTING_CENTER.MADE_OR_BROKEN_AND_CHANGED:\n p.push(c.addScaled(n, acrossSz).addScaled(d, alongIntMadeBroken))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, alongIntMadeBroken))\n p.push(c.addScaled(n, acrossSz).addScaled(d, -alongIntMadeBroken))\n p.push(c.addScaled(n, -acrossSz).addScaled(d, -alongIntMadeBroken))\n p.push(c.addScaled(n, acrossSz))\n p.push(c.addScaled(n, -acrossSz))\n break\n default:\n return null\n }\n return draw.reactingCenter(render.paper, p, render.options)\n}\n\nfunction getTopologyMark(\n render: Render,\n bond: ReBond,\n hb1: HalfBond,\n hb2: HalfBond\n) {\n // eslint-disable-line max-statements\n const options = render.options\n let mark: string | null = null\n\n if (bond.b.topology === Bond.PATTERN.TOPOLOGY.RING) mark = 'rng'\n else if (bond.b.topology === Bond.PATTERN.TOPOLOGY.CHAIN) mark = 'chn'\n else return null\n\n const a = hb1.p,\n b = hb2.p\n const c = b.add(a).scaled(0.5)\n const d = b.sub(a).normalized()\n let n = d.rotateSC(1, 0)\n let fixed = options.lineWidth\n if (bond.doubleBondShift > 0) n = n.scaled(-bond.doubleBondShift)\n else if (bond.doubleBondShift == 0) fixed += options.bondSpace / 2\n\n const s = new Vec2(2, 1).scaled(options.bondSpace)\n if (bond.b.type == Bond.PATTERN.TYPE.TRIPLE) fixed += options.bondSpace\n const p = c.add(new Vec2(n.x * (s.x + fixed), n.y * (s.y + fixed)))\n\n return draw.topologyMark(render.paper, p, mark, options)\n}\n\nfunction getIdsPath(\n bid: number,\n paper: any,\n hb1: HalfBond,\n hb2: HalfBond,\n bondIdxOff: number,\n param1: number,\n param2: number,\n norm: Vec2\n) {\n // eslint-disable-line max-params\n const pb = Vec2.lc(hb1.p, param1, hb2.p, param2, norm, bondIdxOff)\n const ipath = paper.text(pb.x, pb.y, bid.toString())\n const irbb = util.relBox(ipath.getBBox())\n draw.recenterText(ipath, irbb)\n return ipath\n}\n/* ----- */\n\nfunction setDoubleBondShift(bond: ReBond, struct: Struct): void {\n let loop1, loop2\n const hb1 = bond.b.hb1\n const hb2 = bond.b.hb2\n\n if ((!hb1 && hb1 !== 0) || (!hb2 && hb2 !== 0)) {\n bond.doubleBondShift = selectDoubleBondShiftChain(struct, bond)\n return\n }\n\n loop1 = struct.halfBonds.get(hb1)?.loop\n loop2 = struct.halfBonds.get(hb2)?.loop\n if (loop1 >= 0 && loop2 >= 0) {\n const d1 = struct.loops.get(loop1)!.dblBonds\n const d2 = struct.loops.get(loop2)!.dblBonds\n const n1 = struct.loops.get(loop1)!.hbs.length\n const n2 = struct.loops.get(loop2)!.hbs.length\n bond.doubleBondShift = selectDoubleBondShift(n1, n2, d1, d2)\n } else if (loop1 >= 0) {\n bond.doubleBondShift = -1\n } else if (loop2 >= 0) {\n bond.doubleBondShift = 1\n } else {\n bond.doubleBondShift = selectDoubleBondShiftChain(struct, bond)\n }\n}\n\nfunction bondRecalc(bond: ReBond, restruct: ReStruct, options: any): void {\n const render = restruct.render\n const atom1 = restruct.atoms.get(bond.b.begin)\n const atom2 = restruct.atoms.get(bond.b.end)\n\n if (!atom1 || !atom2 || bond.b.hb1 === undefined || bond.b.hb2 === undefined)\n return\n\n const p1 = Scale.obj2scaled(atom1.a.pp, render.options)\n const p2 = Scale.obj2scaled(atom2.a.pp, render.options)\n const hb1 = restruct.molecule.halfBonds.get(bond.b.hb1)\n const hb2 = restruct.molecule.halfBonds.get(bond.b.hb2)\n\n if (!hb1?.dir || !hb2?.dir) return\n\n hb1.p = shiftBondEnd(atom1, p1, hb1.dir, 2 * options.lineWidth)\n hb2.p = shiftBondEnd(atom2, p2, hb2.dir, 2 * options.lineWidth)\n bond.b.center = Vec2.lc2(atom1.a.pp, 0.5, atom2.a.pp, 0.5)\n bond.b.len = Vec2.dist(p1, p2)\n bond.b.sb = options.lineWidth * 5\n /* eslint-disable no-mixed-operators*/\n bond.b.sa = Math.max(bond.b.sb, bond.b.len / 2 - options.lineWidth * 2)\n /* eslint-enable no-mixed-operators*/\n bond.b.angle = (Math.atan2(hb1.dir.y, hb1.dir.x) * 180) / Math.PI\n}\n\nfunction shiftBondEnd(\n atom: ReAtom,\n pos0: Vec2,\n dir: Vec2,\n margin: number\n): Vec2 {\n let t = 0\n const visel = atom.visel\n for (var k = 0; k < visel.exts.length; ++k) {\n var box = visel.exts[k].translate(pos0)\n t = Math.max(t, util.shiftRayBox(pos0, dir, box))\n }\n if (t > 0) pos0 = pos0.addScaled(dir, t + margin)\n return pos0\n}\n\nfunction selectDoubleBondShift(\n n1: number,\n n2: number,\n d1: number,\n d2: number\n): number {\n if (n1 == 6 && n2 != 6 && (d1 > 1 || d2 == 1)) return -1\n if (n2 == 6 && n1 != 6 && (d2 > 1 || d1 == 1)) return 1\n if (n2 * d1 > n1 * d2) return -1\n if (n2 * d1 < n1 * d2) return 1\n if (n2 > n1) return -1\n return 1\n}\n\nfunction selectDoubleBondShiftChain(struct: Struct, bond: ReBond): number {\n if ((!bond.b.hb1 && bond.b.hb1 !== 0) || (!bond.b.hb2 && bond.b.hb2 !== 0))\n return 0\n\n const hb1 = struct.halfBonds.get(bond.b.hb1)\n const hb2 = struct.halfBonds.get(bond.b.hb2)\n if (!hb1 || !hb2) return 0\n const nLeft = (hb1.leftSin > 0.3 ? 1 : 0) + (hb2.rightSin > 0.3 ? 1 : 0)\n const nRight = (hb2.leftSin > 0.3 ? 1 : 0) + (hb1.rightSin > 0.3 ? 1 : 0)\n if (nLeft > nRight) return -1\n if (nLeft < nRight) return 1\n if ((hb1.leftSin > 0.3 ? 1 : 0) + (hb1.rightSin > 0.3 ? 1 : 0) == 1) return 1\n return 0\n}\n\nexport default ReBond\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, Fragment, StereoFlag } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\n\nclass ReEnhancedFlag extends ReObject {\n #path: any\n\n constructor() {\n super('enhancedFlag')\n }\n\n static isSelectable() {\n return true\n }\n highlightPath(render: Render): any {\n var box = Box2Abs.fromRelBox(this.#path.getBBox())\n var sz = box.p1.sub(box.p0)\n var p0 = box.p0.sub(render.options.offset)\n return render.paper.rect(p0.x, p0.y, sz.x, sz.y)\n }\n drawHighlight(render: Render): any {\n // TODO: after the enhanced flag stops being displayed, need to remove the reEnhancedflag object from ctab\n if (!this.#path?.attrs) return null\n var ret = this.highlightPath(render).attr(render.options.highlightStyle)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n // @ts-ignore\n makeSelectionPlate(restruct: ReStruct, paper: any, options: any): any {\n // TODO: after the enhanced flag stops being displayed, need to remove the reEnhancedflag object from ctab\n if (!this.#path?.attrs) return null\n return this.highlightPath(restruct.render).attr(options.selectionStyle)\n }\n\n show(restruct: ReStruct, fragmentId: number, options: any): void {\n const render = restruct.render\n const fragment = restruct.molecule.frags.get(fragmentId)\n if (!fragment?.enhancedStereoFlag) return\n\n const position = fragment.stereoFlagPosition\n ? fragment.stereoFlagPosition\n : Fragment.getDefaultStereoFlagPosition(restruct.molecule, fragmentId)!\n\n const paper = render.paper\n const ps = Scale.obj2scaled(position, options)\n\n const stereoFlagMap = {\n [StereoFlag.Abs]: options.absFlagLabel,\n [StereoFlag.And]: options.andFlagLabel,\n [StereoFlag.Mixed]: options.mixedFlagLabel,\n [StereoFlag.Or]: options.orFlagLabel\n }\n\n if (options.showStereoFlags) {\n this.#path = paper\n .text(\n ps.x,\n ps.y,\n fragment.enhancedStereoFlag\n ? stereoFlagMap[fragment.enhancedStereoFlag]\n : ''\n )\n .attr({\n font: options.font,\n 'font-size': options.fontsz,\n fill: '#000'\n })\n }\n render.ctab.addReObjectPath(\n LayerMap.data,\n this.visel,\n this.#path,\n null,\n true\n )\n }\n}\n\nexport default ReEnhancedFlag\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, Vec2 } from 'domain/entities'\n\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\n\nclass ReFrag extends ReObject {\n constructor(/* Struct.Fragment */ frag) {\n super('frag')\n this.item = frag\n }\n static isSelectable() {\n return false\n }\n fragGetAtoms(restruct, fid) {\n return Array.from(restruct.atoms.keys()).filter(\n aid => restruct.atoms.get(aid).a.fragment === fid\n )\n }\n fragGetBonds(restruct, fid) {\n return Array.from(restruct.bonds.keys()).filter(bid => {\n const bond = restruct.bonds.get(bid).b\n\n const firstFrag = restruct.atoms.get(bond.begin).a.fragment\n const secondFrag = restruct.atoms.get(bond.end).a.fragment\n\n return firstFrag === fid && secondFrag === fid\n })\n }\n calcBBox(restruct, fid, render) {\n // TODO need to review parameter list\n var ret\n restruct.atoms.forEach(atom => {\n if (atom.a.fragment !== fid) return\n\n // TODO ReObject.calcBBox to be used instead\n let bba = atom.visel.boundingBox\n if (!bba) {\n bba = new Box2Abs(atom.a.pp, atom.a.pp)\n const ext = new Vec2(0.05 * 3, 0.05 * 3)\n bba = bba.extend(ext, ext)\n } else {\n if (!render) render = global._ui_editor.render // eslint-disable-line\n bba = bba\n .translate((render.options.offset || new Vec2()).negated())\n .transform(Scale.scaled2obj, render.options)\n }\n ret = ret ? Box2Abs.union(ret, bba) : bba\n })\n\n return ret\n }\n // TODO need to review parameter list\n _draw(render, fid, attrs) {\n // eslint-disable-line no-underscore-dangle\n const bb = this.calcBBox(render.ctab, fid, render)\n\n if (bb) {\n const p0 = Scale.obj2scaled(new Vec2(bb.p0.x, bb.p0.y), render.options)\n const p1 = Scale.obj2scaled(new Vec2(bb.p1.x, bb.p1.y), render.options)\n return render.paper\n .rect(p0.x, p0.y, p1.x - p0.x, p1.y - p0.y, 0)\n .attr(attrs)\n }\n\n // TODO abnormal situation, empty fragments must be destroyed by tools\n return\n }\n draw(render) {\n // eslint-disable-line no-unused-vars\n return null // this._draw(render, fid, { 'stroke' : 'lightgray' }); // [RB] for debugging only\n }\n drawHighlight(render) {\n // eslint-disable-line no-unused-vars\n // Do nothing. This method shouldn't actually be called.\n }\n setHighlight(highLight, render) {\n let fid = render.ctab.frags.keyOf(this)\n\n if (!fid && fid !== 0) {\n console.warn('Fragment does not belong to the render')\n return\n }\n\n fid = parseInt(fid, 10)\n\n render.ctab.atoms.forEach(atom => {\n if (atom.a.fragment === fid) atom.setHighlight(highLight, render)\n })\n\n render.ctab.bonds.forEach(bond => {\n if (render.ctab.atoms.get(bond.b.begin).a.fragment === fid)\n bond.setHighlight(highLight, render)\n })\n }\n}\nexport default ReFrag\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, Vec2 } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\nvar BORDER_EXT = new Vec2(0.05 * 3, 0.05 * 3)\nclass ReRGroup extends ReObject {\n constructor(/* RGroup*/ rgroup) {\n super('rgroup')\n this.labelBox = null\n this.item = rgroup\n }\n static isSelectable() {\n return false\n }\n getAtoms(render) {\n var ret = []\n this.item.frags.forEach(fid => {\n ret = ret.concat(\n render.ctab.frags.get(fid).fragGetAtoms(render.ctab, fid)\n )\n })\n return ret\n }\n getBonds(render) {\n var ret = []\n this.item.frags.forEach(fid => {\n ret = ret.concat(\n render.ctab.frags.get(fid).fragGetBonds(render.ctab, fid)\n )\n })\n return ret\n }\n calcBBox(render) {\n let ret = null\n this.item.frags.forEach(fid => {\n const bbf = render.ctab.frags.get(fid).calcBBox(render.ctab, fid, render)\n if (bbf) ret = ret ? Box2Abs.union(ret, bbf) : bbf\n })\n\n if (ret) ret = ret.extend(BORDER_EXT, BORDER_EXT)\n\n return ret\n }\n // TODO need to review parameter list\n draw(render, options) {\n // eslint-disable-line max-statements\n const bb = this.calcBBox(render)\n\n if (!bb) {\n console.error(\n 'Abnormal situation, empty fragments must be destroyed by tools'\n )\n return {}\n }\n\n const ret = { data: [] }\n const p0 = Scale.obj2scaled(bb.p0, options)\n const p1 = Scale.obj2scaled(bb.p1, options)\n const brackets = render.paper.set()\n\n rGroupdrawBrackets(brackets, render, bb) // eslint-disable-line new-cap\n\n ret.data.push(brackets)\n const key = render.ctab.rgroups.keyOf(this)\n const labelSet = render.paper.set()\n const label = render.paper\n .text(p0.x, (p0.y + p1.y) / 2, 'R' + key + '=')\n .attr({\n font: options.font,\n 'font-size': options.fontRLabel,\n fill: 'black'\n })\n\n const labelBox = util.relBox(label.getBBox())\n label.translateAbs(-labelBox.width / 2 - options.lineWidth, 0)\n\n labelSet.push(label)\n const logicStyle = {\n font: options.font,\n 'font-size': options.fontRLogic,\n fill: 'black'\n }\n\n const logic = [rLogicToString(key, this.item)]\n\n let shift = labelBox.height / 2 + options.lineWidth / 2\n for (let i = 0; i < logic.length; ++i) {\n const logicPath = render.paper\n .text(p0.x, (p0.y + p1.y) / 2, logic[i])\n .attr(logicStyle)\n const logicBox = util.relBox(logicPath.getBBox())\n shift += logicBox.height / 2\n logicPath.translateAbs(-logicBox.width / 2 - 6 * options.lineWidth, shift)\n shift += logicBox.height / 2 + options.lineWidth / 2\n ret.data.push(logicPath)\n labelSet.push(logicPath)\n }\n\n ret.data.push(label)\n this.labelBox = Box2Abs.fromRelBox(labelSet.getBBox()).transform(\n Scale.scaled2obj,\n render.options\n )\n return ret\n }\n // TODO need to review parameter list\n _draw(render, rgid, attrs) {\n // eslint-disable-line no-underscore-dangle\n if (!this.getVBoxObj(render)) return null\n const bb = this.getVBoxObj(render).extend(BORDER_EXT, BORDER_EXT) // eslint-disable-line no-underscore-dangle\n\n if (!bb) return null\n\n const p0 = Scale.obj2scaled(bb.p0, render.options)\n const p1 = Scale.obj2scaled(bb.p1, render.options)\n return render.paper\n .rect(p0.x, p0.y, p1.x - p0.x, p1.y - p0.y, 0)\n .attr(attrs)\n }\n drawHighlight(render) {\n const rgid = render.ctab.rgroups.keyOf(this)\n\n if (!rgid) {\n console.error(\n 'Abnormal situation, fragment does not belong to the render'\n )\n return null\n }\n\n const ret = this._draw(\n render,\n rgid,\n render.options.highlightStyle /* { 'fill' : 'red' }*/\n ) // eslint-disable-line no-underscore-dangle\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n\n this.item.frags.forEach((fnum, fid) => {\n render.ctab.frags.get(fid).drawHighlight(render)\n })\n\n return ret\n }\n show(restruct, id, options) {\n const drawing = this.draw(restruct.render, options)\n\n Object.keys(drawing).forEach(group => {\n while (drawing[group].length > 0)\n restruct.addReObjectPath(\n LayerMap.data,\n this.visel,\n drawing[group].shift(),\n null,\n true\n )\n })\n // TODO rgroup selection & highlighting\n }\n}\n\nfunction rGroupdrawBrackets(set, render, bb, d) {\n d = Scale.obj2scaled(d || new Vec2(1, 0), render.options)\n var bracketWidth = Math.min(0.25, bb.sz().x * 0.3)\n var bracketHeight = bb.p1.y - bb.p0.y\n var cy = 0.5 * (bb.p1.y + bb.p0.y)\n\n var leftBracket = draw.bracket(\n render.paper,\n d.negated(),\n d.negated().rotateSC(1, 0),\n Scale.obj2scaled(new Vec2(bb.p0.x, cy), render.options),\n bracketWidth,\n bracketHeight,\n render.options\n )\n\n var rightBracket = draw.bracket(\n render.paper,\n d,\n d.rotateSC(1, 0),\n Scale.obj2scaled(new Vec2(bb.p1.x, cy), render.options),\n bracketWidth,\n bracketHeight,\n render.options\n )\n\n return set.push(leftBracket, rightBracket)\n}\n\nfunction rLogicToString(id, rLogic) {\n const ifThen = rLogic.ifthen > 0 ? 'IF ' : ''\n\n const rangeExists =\n rLogic.range.startsWith('>') ||\n rLogic.range.startsWith('<') ||\n rLogic.range.startsWith('=')\n\n let range = null\n if (rLogic.range.length > 0)\n range = rangeExists ? rLogic.range : '=' + rLogic.range\n else range = '>0'\n\n const restH = rLogic.resth ? ' (RestH)' : ''\n const nextRg = rLogic.ifthen > 0 ? '\\nTHEN R' + rLogic.ifthen.toString() : ''\n\n return `${ifThen}R${id.toString()}${range}${restH}${nextRg}`\n}\n\nexport default ReRGroup\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, Vec2 } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport Raphael from '../raphael-ext'\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\ntype Arrow = {\n pos: Array\n mode: string\n}\n\ntype ArrowParams = {\n length: number\n angle: number\n}\ninterface MinDistanceWithReferencePoint {\n minDist: number\n refPoint: Vec2 | null\n}\n\nclass ReRxnArrow extends ReObject {\n item: Arrow\n\n constructor(/* chem.RxnArrow*/ arrow: Arrow) {\n super('rxnArrow')\n this.item = arrow\n }\n static isSelectable(): boolean {\n return true\n }\n\n calcDistance(p: Vec2, s: any): MinDistanceWithReferencePoint {\n const point: Vec2 = new Vec2(p.x, p.y)\n let dist: number\n let distRef: MinDistanceWithReferencePoint\n const item = this.item\n\n const pos = item.pos\n\n dist = calculateDistanceToLine(pos, point)\n\n distRef = this.getReferencePointDistance(p)\n const refPoint: Vec2 | null =\n distRef.minDist <= 8 / s ? distRef.refPoint : null\n // distance is a smallest between dist to figure and it's reference points\n dist = Math.min(distRef.minDist, dist)\n return { minDist: dist, refPoint }\n }\n\n getReferencePointDistance(p: Vec2): MinDistanceWithReferencePoint {\n let dist: any = []\n const refPoints = this.getReferencePoints()\n refPoints.forEach(rp => {\n dist.push({ minDist: Math.abs(Vec2.dist(p, rp)), refPoint: rp })\n })\n\n const minDist: MinDistanceWithReferencePoint = dist.reduce(\n (acc, current) =>\n !acc ? current : acc.minDist < current.minDist ? acc : current,\n null\n )\n\n return minDist\n }\n\n highlightPath(render: Render) {\n const path = this.generatePath(render, render.options, 'selection')\n\n return render.paper.path(path)\n }\n\n drawHighlight(render: Render) {\n const ret = this.highlightPath(render).attr(render.options.highlightStyle)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n\n getReferencePoints(): Array {\n const refPoints: Array = []\n\n this.item.pos.forEach(i => refPoints.push(new Vec2(i.x, i.y, 0)))\n\n return refPoints\n }\n\n makeSelectionPlate(restruct: ReStruct, _paper, styles) {\n const render = restruct.render\n const options = restruct.render.options\n\n const refPoints = this.getReferencePoints()\n const scaleFactor = options.scale\n const selectionSet = restruct.render.paper.set()\n selectionSet.push(\n render.paper\n .path(this.generatePath(render, options, 'selection'))\n .attr(styles.selectionStyle)\n )\n\n refPoints.forEach(rp => {\n const scaledRP = Scale.obj2scaled(rp, restruct.render.options)\n selectionSet.push(\n restruct.render.paper\n .circle(scaledRP.x, scaledRP.y, scaleFactor / 8)\n .attr({ fill: 'black' })\n )\n })\n return selectionSet\n }\n\n generatePath(render: Render, options, type) {\n let path\n\n const pos = this.item.pos.map(p => {\n return Scale.obj2scaled(p, options) || new Vec2()\n })\n\n const arrowParams: ArrowParams = this.getArrowParams(\n pos[0].x,\n pos[0].y,\n pos[1].x,\n pos[1].y\n )\n\n const startPoint = new Vec2(pos[0].x, pos[0].y)\n const endPoint = new Vec2(pos[1].x, pos[1].y)\n\n switch (type) {\n case 'selection':\n path = draw.rectangleWithAngle(\n render.paper,\n startPoint,\n endPoint,\n arrowParams.length,\n arrowParams.angle,\n options\n )\n break\n case 'arrow':\n path = draw.arrow(\n render.paper,\n startPoint,\n endPoint,\n arrowParams.length,\n arrowParams.angle,\n options,\n this.item.mode\n )\n break\n }\n\n return path\n }\n\n getArrowParams(x1, y1, x2, y2): ArrowParams {\n const length = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\n const angle = Raphael.angle(x1, y1, x2, y2) - 180\n\n return { length, angle }\n }\n\n show(restruct: ReStruct, _id, options) {\n const path = this.generatePath(restruct.render, options, 'arrow')\n\n const offset = options.offset\n if (offset != null) path.translateAbs(offset.x, offset.y)\n\n this.visel.add(path, Box2Abs.fromRelBox(util.relBox(path.getBBox())))\n }\n}\n\nfunction calculateDistanceToLine(pos: Array, point: Vec2): number {\n let dist: number\n if (\n (point.x < Math.min(pos[0].x, pos[1].x) ||\n point.x > Math.max(pos[0].x, pos[1].x)) &&\n (point.y < Math.min(pos[0].y, pos[1].y) ||\n point.y > Math.max(pos[0].y, pos[1].y))\n )\n dist = Math.min(Vec2.dist(pos[0], point), Vec2.dist(pos[1], point))\n else {\n const a = Vec2.dist(pos[0], pos[1])\n const b = Vec2.dist(pos[0], point)\n const c = Vec2.dist(pos[1], point)\n const per = (a + b + c) / 2\n dist = (2 / a) * Math.sqrt(per * (per - a) * (per - b) * (per - c))\n }\n return dist\n}\n\nexport default ReRxnArrow\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs } from 'domain/entities'\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\nclass ReRxnPlus extends ReObject {\n constructor(/* chem.RxnPlus*/ plus) {\n super('rxnPlus')\n this.item = plus\n }\n static isSelectable() {\n return true\n }\n highlightPath(render) {\n var p = Scale.obj2scaled(this.item.pp, render.options)\n var s = render.options.scale\n /* eslint-disable no-mixed-operators*/\n return render.paper.rect(p.x - s / 4, p.y - s / 4, s / 2, s / 2, s / 8)\n /* eslint-enable no-mixed-operators*/\n }\n drawHighlight(render) {\n var ret = this.highlightPath(render).attr(render.options.highlightStyle)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n makeSelectionPlate(restruct, paper, styles) {\n // TODO [MK] review parameters\n return this.highlightPath(restruct.render).attr(styles.selectionStyle)\n }\n show(restruct, id, options) {\n var render = restruct.render\n var centre = Scale.obj2scaled(this.item.pp, options)\n var path = draw.plus(render.paper, centre, options)\n var offset = options.offset\n if (offset != null) path.translateAbs(offset.x, offset.y)\n this.visel.add(path, Box2Abs.fromRelBox(util.relBox(path.getBBox())))\n }\n}\n\nexport default ReRxnPlus\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\n\nclass ReDataSGroupData extends ReObject {\n constructor(sgroup) {\n super('sgroupData')\n this.sgroup = sgroup\n }\n static isSelectable() {\n return true\n }\n highlightPath(render) {\n var box = this.sgroup.dataArea\n var p0 = Scale.obj2scaled(box.p0, render.options)\n var sz = Scale.obj2scaled(box.p1, render.options).sub(p0)\n return render.paper.rect(p0.x, p0.y, sz.x, sz.y)\n }\n drawHighlight(render) {\n var ret = this.highlightPath(render).attr(render.options.highlightStyle)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n makeSelectionPlate(restruct, paper, styles) {\n // TODO [MK] review parameters\n return this.highlightPath(restruct.render).attr(styles.selectionStyle)\n }\n}\n\nexport default ReDataSGroupData\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, FunctionalGroup, Pile, SGroup, Vec2 } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReDataSGroupData from './redatasgroupdata'\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\nconst tfx = util.tfx\n\nclass ReSGroup extends ReObject {\n constructor(sgroup) {\n super('sgroup')\n this.item = sgroup\n }\n static isSelectable() {\n return false\n }\n draw(remol, sgroup) {\n this.render = remol.render\n let set = this.render.paper.set()\n const atomSet = new Pile(sgroup.atoms)\n const crossBonds = SGroup.getCrossBonds(remol.molecule, atomSet)\n SGroup.bracketPos(sgroup, remol.molecule, crossBonds)\n const bracketBox = sgroup.bracketBox\n const d = sgroup.bracketDir\n sgroup.areas = [bracketBox]\n const functionalGroups = remol.molecule.functionalGroups\n if (\n FunctionalGroup.isContractedFunctionalGroup(sgroup.id, functionalGroups)\n ) {\n sgroup.firstSgroupAtom = remol.molecule.atoms.get(sgroup.atoms[0])\n sgroup.functionalGroup = true\n } else {\n switch (sgroup.type) {\n case 'MUL':\n SGroupdrawBrackets(\n set,\n this.render,\n sgroup,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n sgroup.data.mul\n )\n break\n case 'SRU':\n let connectivity = sgroup.data.connectivity || 'eu'\n if (connectivity === 'ht') connectivity = ''\n const subscript = sgroup.data.subscript || 'n'\n SGroupdrawBrackets(\n set,\n this.render,\n sgroup,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n subscript,\n connectivity\n )\n break\n case 'SUP':\n SGroupdrawBrackets(\n set,\n this.render,\n sgroup,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n sgroup.data.name,\n null,\n { 'font-style': 'italic' }\n )\n break\n case 'GEN':\n SGroupdrawBrackets(\n set,\n this.render,\n sgroup,\n crossBonds,\n atomSet,\n bracketBox,\n d\n )\n break\n case 'DAT':\n set = drawGroupDat(remol, sgroup)\n break\n default:\n break\n }\n }\n return set\n }\n makeSelectionPlate(restruct, paper, options) {\n const sgroup = this.item\n const { startX, startY, size } = getHighlighPathInfo(sgroup, options)\n const functionalGroups = restruct.molecule.functionalGroups\n if (\n FunctionalGroup.isContractedFunctionalGroup(sgroup.id, functionalGroups)\n ) {\n return paper.rect(startX, startY, size, size).attr(options.selectionStyle)\n }\n }\n drawHighlight(render) {\n // eslint-disable-line max-statements\n var options = render.options\n var paper = render.paper\n var sGroupItem = this.item\n const { a0, a1, b0, b1 } = getHighlighPathInfo(sGroupItem, options)\n\n const functionalGroups = render.ctab.molecule.functionalGroups\n var set = paper.set()\n if (\n FunctionalGroup.isContractedFunctionalGroup(\n sGroupItem.id,\n functionalGroups\n )\n ) {\n const { startX, startY, size } = getHighlighPathInfo(sGroupItem, options)\n sGroupItem.highlighting = paper\n .rect(startX, startY, size, size)\n .attr(options.highlightStyle)\n } else {\n sGroupItem.highlighting = paper\n .path(\n 'M{0},{1}L{2},{3}L{4},{5}L{6},{7}L{0},{1}',\n tfx(a0.x),\n tfx(a0.y),\n tfx(a1.x),\n tfx(a1.y),\n tfx(b1.x),\n tfx(b1.y),\n tfx(b0.x),\n tfx(b0.y)\n )\n .attr(options.highlightStyle)\n }\n set.push(sGroupItem.highlighting)\n\n SGroup.getAtoms(render.ctab.molecule, sGroupItem).forEach(aid => {\n set.push(render.ctab.atoms.get(aid).makeHighlightPlate(render))\n }, this)\n SGroup.getBonds(render.ctab.molecule, sGroupItem).forEach(bid => {\n set.push(render.ctab.bonds.get(bid).makeHighlightPlate(render))\n }, this)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, set)\n }\n show(restruct) {\n var render = restruct.render\n var sgroup = this.item\n if (sgroup.data.fieldName !== 'MRV_IMPLICIT_H') {\n var remol = render.ctab\n var path = this.draw(remol, sgroup)\n restruct.addReObjectPath(LayerMap.data, this.visel, path, null, true)\n this.setHighlight(this.highlight, render) // TODO: fix this\n }\n }\n}\n\nfunction SGroupdrawBrackets(\n set,\n render,\n sg,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n lowerIndexText,\n upperIndexText,\n indexAttribute\n) {\n // eslint-disable-line max-params\n var brackets = getBracketParameters(\n render.ctab.molecule,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n render,\n sg.id\n )\n var ir = -1\n for (var i = 0; i < brackets.length; ++i) {\n var bracket = brackets[i]\n var path = draw.bracket(\n render.paper,\n Scale.obj2scaled(bracket.d, render.options),\n Scale.obj2scaled(bracket.n, render.options),\n Scale.obj2scaled(bracket.c, render.options),\n bracket.w,\n bracket.h,\n render.options\n )\n set.push(path)\n if (\n ir < 0 ||\n brackets[ir].d.x < bracket.d.x ||\n (brackets[ir].d.x === bracket.d.x && brackets[ir].d.y > bracket.d.y)\n )\n ir = i\n }\n var bracketR = brackets[ir]\n function renderIndex(text, shift) {\n var indexPos = Scale.obj2scaled(\n bracketR.c.addScaled(bracketR.n, shift * bracketR.h),\n render.options\n )\n var indexPath = render.paper.text(indexPos.x, indexPos.y, text).attr({\n font: render.options.font,\n 'font-size': render.options.fontszsub\n })\n if (indexAttribute) indexPath.attr(indexAttribute)\n var indexBox = Box2Abs.fromRelBox(util.relBox(indexPath.getBBox()))\n var t =\n Math.max(util.shiftRayBox(indexPos, bracketR.d.negated(), indexBox), 3) +\n 2\n indexPath.translateAbs(t * bracketR.d.x, t * bracketR.d.y)\n set.push(indexPath)\n }\n if (lowerIndexText) renderIndex(lowerIndexText, 0.5)\n if (upperIndexText) renderIndex(upperIndexText, -0.5)\n}\n\nfunction showValue(paper, pos, sg, options) {\n var text = paper.text(pos.x, pos.y, sg.data.fieldValue).attr({\n font: options.font,\n 'font-size': options.fontsz\n })\n var box = text.getBBox()\n var rect = paper.rect(\n box.x - 1,\n box.y - 1,\n box.width + 2,\n box.height + 2,\n 3,\n 3\n )\n rect = sg.selected\n ? rect.attr(options.selectionStyle)\n : rect.attr({ fill: '#fff', stroke: '#fff' })\n var st = paper.set()\n st.push(rect, text.toFront())\n return st\n}\n\nfunction drawGroupDat(restruct, sgroup) {\n sgroup.areas = sgroup.bracketBox ? [sgroup.bracketBox] : []\n\n if (sgroup.pp === null) sgroup.calculatePP(restruct.molecule)\n\n return sgroup.data.attached\n ? drawAttachedDat(restruct, sgroup)\n : drawAbsoluteDat(restruct, sgroup)\n}\n\nfunction drawAbsoluteDat(restruct, sgroup) {\n const render = restruct.render\n const options = render.options\n const paper = render.paper\n const set = paper.set()\n\n const ps = sgroup.pp.scaled(options.scale)\n const name = showValue(paper, ps, sgroup, options)\n const box = util.relBox(name.getBBox())\n\n name.translateAbs(0.5 * box.width, -0.5 * box.height)\n set.push(name)\n\n const sbox = Box2Abs.fromRelBox(util.relBox(name.getBBox()))\n sgroup.dataArea = sbox.transform(Scale.scaled2obj, render.options)\n\n if (!restruct.sgroupData.has(sgroup.id))\n restruct.sgroupData.set(sgroup.id, new ReDataSGroupData(sgroup))\n\n return set\n}\n\nfunction drawAttachedDat(restruct, sgroup) {\n const render = restruct.render\n const options = render.options\n const paper = render.paper\n const set = paper.set()\n\n SGroup.getAtoms(restruct, sgroup).forEach(aid => {\n const atom = restruct.atoms.get(aid)\n const p = Scale.obj2scaled(atom.a.pp, options)\n const bb = atom.visel.boundingBox\n\n if (bb !== null) p.x = Math.max(p.x, bb.p1.x)\n\n p.x += options.lineWidth // shift a bit to the right\n\n const nameI = showValue(paper, p, sgroup, options)\n const boxI = util.relBox(nameI.getBBox())\n\n nameI.translateAbs(0.5 * boxI.width, -0.3 * boxI.height)\n set.push(nameI)\n\n let sboxI = Box2Abs.fromRelBox(util.relBox(nameI.getBBox()))\n sboxI = sboxI.transform(Scale.scaled2obj, render.options)\n sgroup.areas.push(sboxI)\n })\n\n return set\n}\n\nfunction getBracketParameters(\n mol,\n crossBonds,\n atomSet,\n bracketBox,\n d,\n render,\n id\n) {\n // eslint-disable-line max-params\n function BracketParams(c, d, w, h) {\n this.c = c\n this.d = d\n this.n = d.rotateSC(1, 0)\n this.w = w\n this.h = h\n }\n var brackets = []\n var n = d.rotateSC(1, 0)\n\n const crossBondsPerAtom = Object.values(crossBonds)\n const crossBondsValues = crossBondsPerAtom.flat()\n if (crossBondsValues.length < 2) {\n ;(function () {\n d = d || new Vec2(1, 0)\n n = n || d.rotateSC(1, 0)\n var bracketWidth = Math.min(0.25, bracketBox.sz().x * 0.3)\n var cl = Vec2.lc2(\n d,\n bracketBox.p0.x,\n n,\n 0.5 * (bracketBox.p0.y + bracketBox.p1.y)\n )\n var cr = Vec2.lc2(\n d,\n bracketBox.p1.x,\n n,\n 0.5 * (bracketBox.p0.y + bracketBox.p1.y)\n )\n var bracketHeight = bracketBox.sz().y\n\n brackets.push(\n new BracketParams(cl, d.negated(), bracketWidth, bracketHeight),\n new BracketParams(cr, d, bracketWidth, bracketHeight)\n )\n })()\n } else if (crossBondsValues.length === 2 && crossBondsPerAtom.length === 2) {\n ;(function () {\n // eslint-disable-line max-statements\n var b1 = mol.bonds.get(crossBondsValues[0])\n var b2 = mol.bonds.get(crossBondsValues[1])\n var cl0 = b1.getCenter(mol)\n var cr0 = b2.getCenter(mol)\n var tl = -1\n var tr = -1\n var tt = -1\n var tb = -1\n var cc = Vec2.centre(cl0, cr0)\n var dr = Vec2.diff(cr0, cl0).normalized()\n var dl = dr.negated()\n var dt = dr.rotateSC(1, 0)\n var db = dt.negated()\n\n mol.sGroupForest.children.get(id).forEach(sgid => {\n var bba = render.ctab.sgroups.get(sgid).visel.boundingBox\n bba = bba\n .translate((render.options.offset || new Vec2()).negated())\n .transform(Scale.scaled2obj, render.options)\n tl = Math.max(tl, util.shiftRayBox(cl0, dl, bba))\n tr = Math.max(tr, util.shiftRayBox(cr0, dr, bba))\n tt = Math.max(tt, util.shiftRayBox(cc, dt, bba))\n tb = Math.max(tb, util.shiftRayBox(cc, db, bba))\n }, this)\n tl = Math.max(tl + 0.2, 0)\n tr = Math.max(tr + 0.2, 0)\n tt = Math.max(Math.max(tt, tb) + 0.1, 0)\n var bracketWidth = 0.25\n var bracketHeight = 1.5 + tt\n brackets.push(\n new BracketParams(\n cl0.addScaled(dl, tl),\n dl,\n bracketWidth,\n bracketHeight\n ),\n new BracketParams(\n cr0.addScaled(dr, tr),\n dr,\n bracketWidth,\n bracketHeight\n )\n )\n })()\n } else {\n ;(function () {\n for (var i = 0; i < crossBondsValues.length; ++i) {\n var b = mol.bonds.get(crossBondsValues[i])\n var c = b.getCenter(mol)\n var d = atomSet.has(b.begin) ? b.getDir(mol) : b.getDir(mol).negated()\n brackets.push(new BracketParams(c, d, 0.2, 1.0))\n }\n })()\n }\n return brackets\n}\n\nfunction getHighlighPathInfo(sgroup, options) {\n let bracketBox = sgroup.bracketBox.transform(Scale.obj2scaled, options)\n const lineWidth = options.lineWidth\n const vext = new Vec2(lineWidth * 4, lineWidth * 6)\n bracketBox = bracketBox.extend(vext, vext)\n const d = sgroup.bracketDir,\n n = d.rotateSC(1, 0)\n const a0 = Vec2.lc2(d, bracketBox.p0.x, n, bracketBox.p0.y)\n const a1 = Vec2.lc2(d, bracketBox.p0.x, n, bracketBox.p1.y)\n const b0 = Vec2.lc2(d, bracketBox.p1.x, n, bracketBox.p0.y)\n const b1 = Vec2.lc2(d, bracketBox.p1.x, n, bracketBox.p1.y)\n const size = options.contractedFunctionalGroupSize\n let startX = (b0.x + a0.x) / 2 - size / 2\n let startY = (a1.y + a0.y) / 2 - size / 2\n if (sgroup.firstSgroupAtom) {\n const shift = new Vec2(size / 2, size / 2, 0)\n const highlightPp = Vec2.diff(sgroup.firstSgroupAtom.pp.scaled(40), shift)\n startX = highlightPp.x\n startY = highlightPp.y\n }\n return {\n a0,\n a1,\n b0,\n b1,\n startX,\n startY,\n size\n }\n}\n\nexport default ReSGroup\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, SimpleObjectMode, Vec2 } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Render } from '../raphaelRender'\nimport { Scale } from 'domain/helpers'\nimport draw from '../draw'\nimport util from '../util'\n\nconst tfx = util.tfx\ninterface MinDistanceWithReferencePoint {\n minDist: number\n refPoint: Vec2 | null\n}\ninterface StyledPath {\n path: any\n stylesApplied: boolean\n}\nclass ReSimpleObject extends ReObject {\n private item: any\n\n constructor(simpleObject: any) {\n super('simpleObject')\n this.item = simpleObject\n }\n static isSelectable(): boolean {\n return true\n }\n calcDistance(p: Vec2, s: any): MinDistanceWithReferencePoint {\n const point: Vec2 = new Vec2(p.x, p.y)\n let dist: number\n let distRef: MinDistanceWithReferencePoint\n const item = this.item\n const mode = item.mode\n const pos = item.pos\n\n switch (mode) {\n case SimpleObjectMode.ellipse: {\n const rad = Vec2.diff(pos[1], pos[0])\n const rx = rad.x / 2\n const ry = rad.y / 2\n const center = Vec2.sum(pos[0], new Vec2(rx, ry))\n const pointToCenter = Vec2.diff(point, center)\n if (rx !== 0 && ry !== 0) {\n dist = Math.abs(\n 1 -\n (pointToCenter.x * pointToCenter.x) / (rx * rx) -\n (pointToCenter.y * pointToCenter.y) / (ry * ry)\n )\n } else {\n // in case rx or ry is equal to 0 we have a line as a trivial case of ellipse\n // in such case distance need to be calculated as a distance between line and current point\n dist = calculateDistanceToLine(pos, point)\n }\n break\n }\n case SimpleObjectMode.rectangle: {\n const topX = Math.min(pos[0].x, pos[1].x)\n const topY = Math.min(pos[0].y, pos[1].y)\n const bottomX = Math.max(pos[0].x, pos[1].x)\n const bottomY = Math.max(pos[0].y, pos[1].y)\n\n const distances: Array = []\n\n if (point.x >= topX && point.x <= bottomX) {\n if (point.y < topY) {\n distances.push(topY - point.y)\n } else if (point.y > bottomY) {\n distances.push(point.y - bottomY)\n } else {\n distances.push(point.y - topY, bottomY - point.y)\n }\n }\n if (point.x < topX && point.y < topY) {\n distances.push(Vec2.dist(new Vec2(topX, topY), point))\n }\n if (point.x > bottomX && point.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(bottomX, bottomY), point))\n }\n if (point.x < topX && point.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(topX, bottomY), point))\n }\n if (point.x > bottomX && point.y < topY) {\n distances.push(Vec2.dist(new Vec2(bottomX, topY), point))\n }\n if (point.y >= topY && point.y <= bottomY) {\n if (point.x < topX) {\n distances.push(topX - point.x)\n } else if (point.x > bottomX) {\n distances.push(point.x - bottomX)\n } else {\n distances.push(point.x - topX, bottomX - point.x)\n }\n }\n dist = Math.min(...distances)\n break\n }\n case SimpleObjectMode.line: {\n dist = calculateDistanceToLine(pos, point)\n break\n }\n\n default: {\n throw new Error('Unsupported shape type')\n }\n }\n\n distRef = this.getReferencePointDistance(p)\n const refPoint: Vec2 | null =\n distRef.minDist <= 8 / s ? distRef.refPoint : null\n // distance is a smallest between dist to figure and it's reference points\n dist = Math.min(distRef.minDist, dist)\n return { minDist: dist, refPoint }\n }\n\n getReferencePointDistance(p: Vec2): MinDistanceWithReferencePoint {\n let dist: any = []\n const refPoints = this.getReferencePoints()\n refPoints.forEach(rp => {\n dist.push({ minDist: Math.abs(Vec2.dist(p, rp)), refPoint: rp })\n })\n\n const minDist: MinDistanceWithReferencePoint = dist.reduce(\n (acc, current) =>\n !acc ? current : acc.minDist < current.minDist ? acc : current,\n null\n )\n\n return minDist\n }\n getReferencePoints(onlyOnObject: boolean = false): Array {\n const refPoints: Array = []\n switch (this.item.mode) {\n case SimpleObjectMode.ellipse:\n case SimpleObjectMode.rectangle: {\n const p0: Vec2 = new Vec2(\n Math.min(this.item.pos[0].x, this.item.pos[1].x),\n Math.min(this.item.pos[0].y, this.item.pos[1].y)\n )\n const w = Math.abs(Vec2.diff(this.item.pos[0], this.item.pos[1]).x)\n const h = Math.abs(Vec2.diff(this.item.pos[0], this.item.pos[1]).y)\n\n refPoints.push(\n new Vec2(p0.x + 0.5 * w, p0.y),\n new Vec2(p0.x + w, p0.y + 0.5 * h),\n new Vec2(p0.x + 0.5 * w, p0.y + h),\n new Vec2(p0.x, p0.y + 0.5 * h)\n )\n if (!onlyOnObject || this.item.mode === SimpleObjectMode.rectangle) {\n refPoints.push(\n p0,\n new Vec2(p0.x, p0.y + h),\n new Vec2(p0.x + w, p0.y + h),\n new Vec2(p0.x + w, p0.y)\n )\n }\n break\n }\n case SimpleObjectMode.line: {\n this.item.pos.forEach(i => refPoints.push(new Vec2(i.x, i.y, 0)))\n break\n }\n\n default: {\n throw new Error('Unsupported shape type')\n }\n }\n return refPoints\n }\n highlightPath(render: Render): Array {\n const point: Array = []\n\n this.item.pos.forEach((p, index) => {\n point[index] = Scale.obj2scaled(p, render.options)\n })\n const scaleFactor = render.options.scale\n\n const path: Array = []\n\n //TODO: It seems that inheritance will be the better approach here\n switch (this.item.mode) {\n case SimpleObjectMode.ellipse: {\n const rad = Vec2.diff(point[1], point[0])\n const rx = rad.x / 2\n const ry = rad.y / 2\n path.push(\n render.paper.ellipse(\n tfx(point[0].x + rx),\n tfx(point[0].y + ry),\n tfx(Math.abs(rx) + scaleFactor / 8),\n tfx(Math.abs(ry) + scaleFactor / 8)\n )\n )\n if (\n Math.abs(rx) - scaleFactor / 8 > 0 &&\n Math.abs(ry) - scaleFactor / 8 > 0\n )\n path.push(\n render.paper.ellipse(\n tfx(point[0].x + rx),\n tfx(point[0].y + ry),\n tfx(Math.abs(rx) - scaleFactor / 8),\n tfx(Math.abs(ry) - scaleFactor / 8)\n )\n )\n break\n }\n\n case SimpleObjectMode.rectangle: {\n path.push(\n render.paper.rect(\n tfx(Math.min(point[0].x, point[1].x) - scaleFactor / 8),\n tfx(Math.min(point[0].y, point[1].y) - scaleFactor / 8),\n tfx(\n Math.max(point[0].x, point[1].x) -\n Math.min(point[0].x, point[1].x) +\n scaleFactor / 4\n ),\n tfx(\n Math.max(point[0].y, point[1].y) -\n Math.min(point[0].y, point[1].y) +\n scaleFactor / 4\n )\n )\n )\n\n if (\n Math.max(point[0].x, point[1].x) -\n Math.min(point[0].x, point[1].x) -\n scaleFactor / 4 >\n 0 &&\n Math.max(point[0].y, point[1].y) -\n Math.min(point[0].y, point[1].y) -\n scaleFactor / 4 >\n 0\n )\n path.push(\n render.paper.rect(\n tfx(Math.min(point[0].x, point[1].x) + scaleFactor / 8),\n tfx(Math.min(point[0].y, point[1].y) + scaleFactor / 8),\n tfx(\n Math.max(point[0].x, point[1].x) -\n Math.min(point[0].x, point[1].x) -\n scaleFactor / 4\n ),\n tfx(\n Math.max(point[0].y, point[1].y) -\n Math.min(point[0].y, point[1].y) -\n scaleFactor / 4\n )\n )\n )\n\n break\n }\n case SimpleObjectMode.line: {\n //TODO: reuse this code for polyline\n const poly: Array = []\n\n let angle = Math.atan(\n (point[1].y - point[0].y) / (point[1].x - point[0].x)\n )\n\n const p0 = { x: 0, y: 0 }\n const p1 = { x: 0, y: 0 }\n\n const k = point[0].x > point[1].x ? -1 : 1\n\n p0.x = point[0].x - k * ((scaleFactor / 8) * Math.cos(angle))\n p0.y = point[0].y - k * ((scaleFactor / 8) * Math.sin(angle))\n p1.x = point[1].x + k * ((scaleFactor / 8) * Math.cos(angle))\n p1.y = point[1].y + k * ((scaleFactor / 8) * Math.sin(angle))\n\n poly.push(\n 'M',\n p0.x + ((k * scaleFactor) / 8) * Math.sin(angle),\n p0.y - ((k * scaleFactor) / 8) * Math.cos(angle)\n )\n poly.push(\n 'L',\n p1.x + ((k * scaleFactor) / 8) * Math.sin(angle),\n p1.y - ((k * scaleFactor) / 8) * Math.cos(angle)\n )\n poly.push(\n 'L',\n p1.x - ((k * scaleFactor) / 8) * Math.sin(angle),\n p1.y + ((k * scaleFactor) / 8) * Math.cos(angle)\n )\n poly.push(\n 'L',\n p0.x - ((k * scaleFactor) / 8) * Math.sin(angle),\n p0.y + ((k * scaleFactor) / 8) * Math.cos(angle)\n )\n poly.push(\n 'L',\n p0.x + ((k * scaleFactor) / 8) * Math.sin(angle),\n p0.y - ((k * scaleFactor) / 8) * Math.cos(angle)\n )\n\n path.push(render.paper.path(poly))\n break\n }\n default: {\n throw new Error('Unsupported shape type')\n }\n }\n\n const enhPaths: Array = path.map(p => {\n return { path: p, stylesApplied: false }\n })\n\n return enhPaths\n }\n\n drawHighlight(render: Render): Array {\n const paths: Array = this.highlightPath(render).map(enhPath => {\n if (!enhPath.stylesApplied) {\n return enhPath.path.attr(render.options.highlightStyle)\n }\n return enhPath.path\n })\n\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, paths)\n return paths\n }\n\n makeSelectionPlate(restruct: ReStruct, paper: any, styles: any): any {\n const pos = this.item.pos.map(p => {\n return Scale.obj2scaled(p, restruct.render.options) || new Vec2()\n })\n\n const refPoints = this.getReferencePoints()\n const scaleFactor = restruct.render.options.scale\n var selectionSet = restruct.render.paper.set()\n selectionSet.push(\n generatePath(this.item.mode, paper, pos).attr(\n styles.highlightStyleSimpleObject\n )\n )\n refPoints.forEach(rp => {\n const scaledRP = Scale.obj2scaled(rp, restruct.render.options)\n selectionSet.push(\n restruct.render.paper\n .circle(scaledRP.x, scaledRP.y, scaleFactor / 8)\n .attr({ fill: 'black' })\n )\n })\n return selectionSet\n }\n show(restruct: ReStruct, options: any): void {\n const render = restruct.render\n const pos = this.item.pos.map(p => {\n return Scale.obj2scaled(p, options) || new Vec2()\n })\n\n const path = generatePath(this.item.mode, render.paper, pos, options)\n\n var offset = options.offset\n if (offset != null) path.translateAbs(offset.x, offset.y)\n\n // @ts-ignore\n this.visel.add(path, Box2Abs.fromRelBox(util.relBox(path.getBBox())))\n }\n}\nfunction calculateDistanceToLine(pos: Array, point: Vec2): number {\n let dist: number\n if (\n (point.x < Math.min(pos[0].x, pos[1].x) ||\n point.x > Math.max(pos[0].x, pos[1].x)) &&\n (point.y < Math.min(pos[0].y, pos[1].y) ||\n point.y > Math.max(pos[0].y, pos[1].y))\n )\n dist = Math.min(Vec2.dist(pos[0], point), Vec2.dist(pos[1], point))\n else {\n const a = Vec2.dist(pos[0], pos[1])\n const b = Vec2.dist(pos[0], point)\n const c = Vec2.dist(pos[1], point)\n const per = (a + b + c) / 2\n dist = (2 / a) * Math.sqrt(per * (per - a) * (per - b) * (per - c))\n }\n return dist\n}\n\nfunction generatePath(mode: SimpleObjectMode, paper, pos: Vec2, options?): any {\n let path: any\n switch (mode) {\n case SimpleObjectMode.ellipse: {\n path = draw.ellipse(paper, pos, options)\n break\n }\n case SimpleObjectMode.rectangle: {\n path = draw.rectangle(paper, pos, options)\n break\n }\n case SimpleObjectMode.line: {\n path = draw.line(paper, pos, options)\n break\n }\n default: {\n throw new Error('Unsupported shape type')\n }\n }\n\n return path\n}\n\nexport default ReSimpleObject\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond, Vec2 } from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport { Scale } from 'domain/helpers'\nimport util from '../util'\n\nconst tfx = util.tfx\n\nclass ReLoop extends ReObject {\n constructor(loop) {\n super('loop')\n this.loop = loop\n this.centre = new Vec2()\n this.radius = new Vec2()\n }\n static isSelectable() {\n return false\n }\n show(restruct, rlid, options) {\n // eslint-disable-line max-statements\n var render = restruct.render\n var paper = render.paper\n var molecule = restruct.molecule\n var loop = this.loop\n this.centre = new Vec2()\n loop.hbs.forEach(hbid => {\n var hb = molecule.halfBonds.get(hbid)\n var bond = restruct.bonds.get(hb.bid)\n var apos = Scale.obj2scaled(restruct.atoms.get(hb.begin).a.pp, options)\n if (bond.b.type !== Bond.PATTERN.TYPE.AROMATIC) loop.aromatic = false\n this.centre.add_(apos) // eslint-disable-line no-underscore-dangle\n })\n loop.convex = true\n for (var k = 0; k < this.loop.hbs.length; ++k) {\n var hba = molecule.halfBonds.get(loop.hbs[k])\n var hbb = molecule.halfBonds.get(loop.hbs[(k + 1) % loop.hbs.length])\n var angle = Math.atan2(\n Vec2.cross(hba.dir, hbb.dir),\n Vec2.dot(hba.dir, hbb.dir)\n )\n if (angle > 0) loop.convex = false\n }\n\n this.centre = this.centre.scaled(1.0 / loop.hbs.length)\n this.radius = -1\n loop.hbs.forEach(hbid => {\n var hb = molecule.halfBonds.get(hbid)\n var apos = Scale.obj2scaled(restruct.atoms.get(hb.begin).a.pp, options)\n var bpos = Scale.obj2scaled(restruct.atoms.get(hb.end).a.pp, options)\n var n = Vec2.diff(bpos, apos).rotateSC(1, 0).normalized()\n var dist = Vec2.dot(Vec2.diff(apos, this.centre), n)\n this.radius = this.radius < 0 ? dist : Math.min(this.radius, dist)\n })\n this.radius *= 0.7\n if (!loop.aromatic) return\n var path = null\n if (loop.convex && options.aromaticCircle) {\n path = paper.circle(this.centre.x, this.centre.y, this.radius).attr({\n stroke: '#000',\n 'stroke-width': options.lineattr['stroke-width']\n })\n } else {\n var pathStr = ''\n for (k = 0; k < loop.hbs.length; ++k) {\n hba = molecule.halfBonds.get(loop.hbs[k])\n hbb = molecule.halfBonds.get(loop.hbs[(k + 1) % loop.hbs.length])\n angle = Math.atan2(\n Vec2.cross(hba.dir, hbb.dir),\n Vec2.dot(hba.dir, hbb.dir)\n )\n var halfAngle = (Math.PI - angle) / 2\n var dir = hbb.dir.rotate(halfAngle)\n var pi = Scale.obj2scaled(restruct.atoms.get(hbb.begin).a.pp, options)\n var sin = Math.sin(halfAngle)\n var minSin = 0.1\n if (Math.abs(sin) < minSin) sin = (sin * minSin) / Math.abs(sin)\n var offset = options.bondSpace / sin\n var qi = pi.addScaled(dir, -offset)\n pathStr += k === 0 ? 'M' : 'L'\n pathStr += tfx(qi.x) + ',' + tfx(qi.y)\n }\n pathStr += 'Z'\n path = paper.path(pathStr).attr({\n stroke: '#000',\n 'stroke-width': options.lineattr['stroke-width'],\n 'stroke-dasharray': '- '\n })\n }\n restruct.addReObjectPath(LayerMap.data, this.visel, path, null, true)\n }\n isValid(struct, rlid) {\n const halfBonds = struct.halfBonds\n return this.loop.hbs.every(\n hbid => halfBonds.has(hbid) && halfBonds.get(hbid).loop === rlid\n )\n }\n}\n\nexport default ReLoop\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n DraftInlineStyleType,\n RawDraftContentBlock,\n RawDraftContentState,\n RawDraftInlineStyleRange\n} from 'draft-js'\nimport { Text, TextCommand, Vec2 } from 'domain/entities'\nimport { flatten, isEqual } from 'lodash/fp'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReObject from './reobject'\nimport ReStruct from './restruct'\nimport { Scale } from 'domain/helpers'\n\nclass ReText extends ReObject {\n private item: Text\n paths: Array> = []\n\n constructor(text: Text) {\n super('text')\n this.item = text\n }\n static isSelectable() {\n return true\n }\n\n getReferencePoints(): Array {\n const { p0, p1 } = this.getRelBox(this.paths)\n\n const p = this.item.position\n const w = Math.abs(Vec2.diff(p0, p1).x) / 40\n const h = Math.abs(Vec2.diff(p0, p1).y) / 40\n\n const refPoints: Array = []\n\n refPoints.push(\n this.item.position,\n new Vec2(p.x, p.y + h),\n new Vec2(p.x + w, p.y + h),\n new Vec2(p.x + w, p.y)\n )\n\n return refPoints\n }\n\n highlightPath(render: any): any {\n const { p0, p1 } = this.getRelBox(this.paths)\n const topLeft = p0.sub(render.options.offset)\n const { x: width, y: height } = p1.sub(p0)\n\n return render.paper.rect(topLeft.x, topLeft.y, width, height, 5)\n }\n\n getRelBox(paths: Array>): { p0: Vec2; p1: Vec2 } {\n const firstElOfFirstRow: any = paths[0][0]\n const leftEdge = firstElOfFirstRow.getBBox().x\n\n const firstRow: Array = paths[0]\n const topEdge: number = Math.min(...firstRow.map(path => path.getBBox().y))\n\n const widestRow: Array = paths.reduce(\n (widestRow, nextRow) =>\n this.getRowWidth(nextRow) > this.getRowWidth(widestRow)\n ? nextRow\n : widestRow,\n paths[0]\n )\n const lastElOfWidestRow: any = widestRow[widestRow.length - 1]\n const rightEdge: number =\n lastElOfWidestRow.getBBox().x + lastElOfWidestRow.getBBox().width\n\n const lastRow: Array = paths[paths.length - 1]\n const bottomEdge: number = Math.max(\n ...lastRow.map(path => path.getBBox().y + path.getBBox().height)\n )\n\n return {\n p0: new Vec2(leftEdge, topEdge),\n p1: new Vec2(rightEdge, bottomEdge)\n }\n }\n\n getRowWidth(row: Array): number {\n return row.reduce((rowWidth, nextRow) => {\n rowWidth += nextRow.getBBox().width\n return rowWidth\n }, 0)\n }\n\n drawHighlight(render: any): any {\n if (!this.paths.length) return null\n const ret = this.highlightPath(render).attr(render.options.highlightStyle)\n render.ctab.addReObjectPath(LayerMap.highlighting, this.visel, ret)\n return ret\n }\n\n makeSelectionPlate(restruct: ReStruct, paper: any, options: any): any {\n if (!this.paths.length || !paper) return null\n return this.highlightPath(restruct.render).attr(options.selectionStyle)\n }\n\n show(restruct: ReStruct, _id: number, options: any): void {\n const render = restruct.render\n const paper = render.paper\n const paperScale = Scale.obj2scaled(this.item.position, options)\n\n let shiftY: number = 0\n this.paths = []\n //TODO: create parser in ketcher-core package\n const rawContentState: RawDraftContentState | null = this.item.content\n ? (JSON.parse(this.item.content) as RawDraftContentState)\n : null\n if (!rawContentState) return\n rawContentState.blocks.forEach((block: RawDraftContentBlock) => {\n const ranges: Array<[number, number, Record]> =\n this.getRanges(block, options)\n let shiftX: number = 0\n const row: Array = []\n ranges.forEach(([start, end, styles]) => {\n block.text = block.text.replace(/[^\\S\\r\\n]/g, '\\u00a0')\n\n const path = paper\n .text(\n paperScale.x,\n paperScale.y,\n block.text.substring(start, end + 1) || '\\u00a0'\n )\n .attr({\n font: options.font,\n 'font-size': options.fontsz,\n 'text-anchor': 'start',\n fill: '#000000',\n ...styles\n })\n\n path.translateAbs(shiftX, shiftY + (styles.shiftY || 0))\n\n row.push(path)\n shiftX += path.getBBox().width\n })\n\n this.paths.push(row)\n\n const { p0, p1 } = this.getRelBox([row])\n shiftY += Math.abs(Vec2.diff(p0, p1).y)\n })\n\n render.ctab.addReObjectPath(\n LayerMap.data,\n this.visel,\n flatten(this.paths),\n null,\n true\n )\n }\n\n getRanges(\n block: RawDraftContentBlock,\n options: any\n ): Array<[number, number, Record]> {\n const ranges: Array<[number, number, Record]> = []\n\n let start: number = 0\n let styles: Record = this.getStyles(block, start, options)\n for (let i = 1; i < block.text.length; i++) {\n const nextStyles = this.getStyles(block, i, options)\n\n if (!isEqual(styles, nextStyles)) {\n ranges.push([start, i - 1, styles])\n styles = nextStyles\n start = i\n }\n }\n ranges.push([start, block.text.length - 1, styles])\n\n return ranges\n }\n\n getStyles(\n block: RawDraftContentBlock,\n index: number,\n options: any\n ): Record {\n const ranges = block.inlineStyleRanges.filter(\n (inlineRange: CustomRawDraftInlineStyleRange) =>\n inlineRange.offset <= index &&\n index < inlineRange.offset + inlineRange.length\n )\n\n const customFontSize: number | null = ranges.reduce(\n (acc: number | null, range: any) => {\n if (range.style.includes(TextCommand.FontSize)) {\n return range.style.match(/\\d+/)?.[0]\n }\n return acc\n },\n null\n )\n\n return ranges.reduce(\n (styles: any, textRange: CustomRawDraftInlineStyleRange) => {\n const fontsz = customFontSize || options.fontsz\n const fontszsub = (customFontSize || options.fontszsub) * 0.8\n switch (textRange.style) {\n case TextCommand.Bold:\n styles['font-weight'] = 'bold'\n break\n\n case TextCommand.Italic:\n styles['font-style'] = 'italic'\n break\n\n case TextCommand.Subscript:\n styles['font-size'] = fontszsub + 'px'\n styles.shiftY = fontsz / 3\n\n break\n\n case TextCommand.Superscript:\n styles['font-size'] = fontszsub + 'px'\n styles.shiftY = -fontsz / 3\n break\n\n case `${TextCommand.FontSize}_${customFontSize}px`:\n styles['font-size'] = customFontSize + 'px'\n break\n\n default:\n }\n\n return styles\n },\n {}\n )\n }\n}\n\ninterface CustomRawDraftInlineStyleRange\n extends Omit {\n style:\n | DraftInlineStyleType\n | TextCommand.Subscript\n | TextCommand.Superscript\n | TextCommand.FontSize\n}\n\nexport default ReText\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Box2Abs,\n FunctionalGroup,\n Pile,\n Pool,\n Struct,\n Vec2\n} from 'domain/entities'\n\nimport { LayerMap } from './generalEnumTypes'\nimport ReAtom from './reatom'\nimport ReBond from './rebond'\nimport ReDataSGroupData from './redatasgroupdata'\nimport ReEnhancedFlag from './reenhancedFlag'\nimport ReFrag from './refrag'\nimport ReLoop from './reloop'\nimport ReRGroup from './rergroup'\nimport ReRxnArrow from './rerxnarrow'\nimport ReRxnPlus from './rerxnplus'\nimport ReSGroup from './resgroup'\nimport ReSimpleObject from './resimpleObject'\nimport ReText from './retext'\nimport { Render } from '../raphaelRender'\nimport Visel from './visel'\nimport util from '../util'\n\nclass ReStruct {\n public static maps = {\n atoms: ReAtom,\n bonds: ReBond,\n rxnPluses: ReRxnPlus,\n rxnArrows: ReRxnArrow,\n frags: ReFrag,\n rgroups: ReRGroup,\n sgroupData: ReDataSGroupData,\n enhancedFlags: ReEnhancedFlag,\n sgroups: ReSGroup,\n reloops: ReLoop,\n simpleObjects: ReSimpleObject,\n texts: ReText\n }\n public render: Render\n public molecule: Struct\n public atoms: Map = new Map()\n public bonds: Map = new Map()\n public reloops: Map = new Map()\n public rxnPluses: Map = new Map()\n public rxnArrows: Map = new Map()\n public frags: Pool = new Pool()\n public rgroups: Pool = new Pool()\n public sgroups: Map = new Map()\n public sgroupData: Map = new Map()\n public enhancedFlags: Map = new Map()\n private simpleObjects: Map = new Map()\n public texts: Map = new Map()\n private initialized: boolean = false\n private layers: Array = []\n public connectedComponents: Pool = new Pool()\n private ccFragmentType: Pool = new Pool()\n private structChanged: boolean = false\n\n private atomsChanged: Map = new Map()\n private simpleObjectsChanged: Map = new Map()\n private rxnArrowsChanged: Map = new Map()\n private rxnPlusesChanged: Map = new Map()\n private enhancedFlagsChanged: Map = new Map()\n private bondsChanged: Map = new Map()\n private textsChanged: Map = new Map()\n constructor(molecule, render: Render) {\n // eslint-disable-line max-statements\n this.render = render\n this.molecule = molecule || new Struct()\n this.initLayers()\n this.clearMarks()\n // TODO: eachItem ?\n\n molecule.atoms.forEach((atom, aid) => {\n this.atoms.set(aid, new ReAtom(atom))\n })\n\n molecule.bonds.forEach((bond, bid) => {\n this.bonds.set(bid, new ReBond(bond))\n })\n\n molecule.loops.forEach((loop, lid) => {\n this.reloops.set(lid, new ReLoop(loop))\n })\n\n molecule.rxnPluses.forEach((item, id) => {\n this.rxnPluses.set(id, new ReRxnPlus(item))\n })\n\n molecule.rxnArrows.forEach((item, id) => {\n this.rxnArrows.set(id, new ReRxnArrow(item))\n })\n\n molecule.simpleObjects.forEach((item, id) => {\n this.simpleObjects.set(id, new ReSimpleObject(item))\n })\n\n molecule.texts.forEach((item, id) => {\n this.texts.set(id, new ReText(item))\n })\n\n molecule.frags.forEach((item, id) => {\n this.frags.set(id, new ReFrag(item))\n if (item) this.enhancedFlags.set(id, new ReEnhancedFlag())\n })\n\n molecule.rgroups.forEach((item, id) => {\n this.rgroups.set(id, new ReRGroup(item))\n })\n\n molecule.sgroups.forEach((item, id) => {\n this.sgroups.set(id, new ReSGroup(item))\n if (item.type === 'DAT' && !item.data.attached)\n this.sgroupData.set(id, new ReDataSGroupData(item)) // [MK] sort of a hack, we use the SGroup id for the data field id\n if (FunctionalGroup.isFunctionalGroup(item)) {\n this.molecule.functionalGroups.set(id, new FunctionalGroup(item))\n }\n })\n }\n\n connectedComponentRemoveAtom(aid: number, reAtom?: ReAtom): void {\n const atom = reAtom || this.atoms.get(aid)\n if (!atom || atom.component < 0) return\n var cc = this.connectedComponents.get(atom.component)\n\n cc.delete(aid)\n if (cc.size < 1) this.connectedComponents.delete(atom.component)\n\n atom.component = -1\n }\n\n clearConnectedComponents(): void {\n this.connectedComponents.clear()\n this.atoms.forEach(atom => {\n atom.component = -1\n })\n }\n\n getConnectedComponent(\n aid: Array | number,\n adjacentComponents: Pile\n ): Pile {\n const list = Array.isArray(aid) ? Array.from(aid) : [aid]\n const ids = new Pile()\n\n while (list.length > 0) {\n const aid = list.pop()!\n ids.add(aid)\n const atom = this.atoms.get(aid)\n if (!atom) continue\n if (atom.component >= 0) adjacentComponents.add(atom.component)\n\n atom.a.neighbors.forEach(neighbor => {\n let halfBond = this.molecule.halfBonds.get(neighbor)\n if (!halfBond) return\n const neiId = halfBond.end\n if (!ids.has(neiId)) list.push(neiId)\n })\n }\n\n return ids\n }\n\n addConnectedComponent(idSet: Pile): number {\n const compId = this.connectedComponents.add(idSet)\n const adjacentComponents = new Pile()\n const aidSet = this.getConnectedComponent(\n Array.from(idSet),\n adjacentComponents\n )\n\n adjacentComponents.delete(compId)\n\n let type = -1\n aidSet.forEach(aid => {\n const atom = this.atoms.get(aid)\n if (!atom) return\n atom.component = compId\n if (atom.a.rxnFragmentType !== -1) type = atom.a.rxnFragmentType\n })\n\n this.ccFragmentType.set(compId, type)\n return compId\n }\n\n removeConnectedComponent(ccid: number): boolean {\n this.connectedComponents.get(ccid).forEach(aid => {\n const atom = this.atoms.get(aid)\n if (atom) atom.component = -1\n })\n\n return this.connectedComponents.delete(ccid)\n }\n\n assignConnectedComponents(): void {\n this.atoms.forEach((atom, aid) => {\n if (atom.component >= 0) return\n\n const adjacentComponents = new Pile()\n const idSet = this.getConnectedComponent(aid, adjacentComponents)\n adjacentComponents.forEach(ccid => {\n this.removeConnectedComponent(ccid)\n })\n\n this.addConnectedComponent(idSet)\n })\n }\n\n initLayers(): void {\n for (const group in LayerMap) {\n this.layers[LayerMap[group]] = this.render.paper\n .rect(0, 0, 10, 10)\n .attr({\n class: group + 'Layer',\n fill: '#000',\n opacity: '0.0'\n })\n .toFront()\n }\n }\n\n addReObjectPath(\n group: LayerMap,\n visel: Visel,\n path,\n pos: Vec2 | null = null,\n visible: boolean = false\n ): void {\n // eslint-disable-line max-params\n if (!path || !this.layers[group].node.parentNode) return\n\n const paths = Array.isArray(path) ? path : [path]\n\n paths.forEach(path => {\n const offset = this.render.options.offset\n let bb = visible ? Box2Abs.fromRelBox(util.relBox(path.getBBox())) : null\n const ext = pos && bb ? bb.translate(pos.negated()) : null\n if (offset !== null) {\n path.translateAbs(offset.x, offset.y)\n bb = bb ? bb.translate(offset) : null\n }\n visel.add(path, bb, ext)\n path.insertBefore(this.layers[LayerMap[group]])\n })\n }\n\n clearMarks(): void {\n Object.keys(ReStruct.maps).forEach(map => {\n this[map + 'Changed'] = new Map()\n })\n\n this.structChanged = false\n }\n\n markItemRemoved(): void {\n this.structChanged = true\n }\n\n markBond(bid: number, mark: number): void {\n this.markItem('bonds', bid, mark)\n }\n\n markAtom(aid: number, mark: number): void {\n this.markItem('atoms', aid, mark)\n }\n\n markItem(map: string, id: number, mark: number): void {\n const mapChanged = this[map + 'Changed']\n\n const value = mapChanged.has(id) ? Math.max(mark, mapChanged.get(id)) : mark\n\n mapChanged.set(id, value)\n\n if (this[map].has(id)) this.clearVisel(this[map].get(id).visel)\n }\n\n clearVisel(visel: Visel): void {\n visel.paths.forEach(path => {\n path.remove()\n })\n visel.clear()\n }\n\n eachItem(func) {\n Object.keys(ReStruct.maps).forEach(map => {\n this[map].forEach(func)\n })\n }\n\n getVBoxObj(selection): Box2Abs | null {\n selection = selection || {}\n\n if (isSelectionEmpty(selection)) {\n Object.keys(ReStruct.maps).forEach(map => {\n selection[map] = Array.from(this[map].keys())\n })\n }\n\n let vbox: Box2Abs | null = null\n Object.keys(ReStruct.maps).forEach(map => {\n if (!selection[map]) return\n\n selection[map].forEach(id => {\n const box = this[map].get(id).getVBoxObj(this.render)\n if (box) vbox = vbox ? Box2Abs.union(vbox, box) : box.clone()\n })\n })\n\n vbox = vbox || new Box2Abs(0, 0, 0, 0)\n return vbox\n }\n\n translate(d): void {\n this.eachItem(item => item.visel.translate(d))\n }\n\n scale(s: number): void {\n // NOTE: bounding boxes are not valid after scaling\n this.eachItem(item => scaleVisel(item.visel, s))\n }\n\n clearVisels(): void {\n this.eachItem(item => this.clearVisel(item.visel))\n }\n\n update(force: boolean): boolean {\n // eslint-disable-line max-statements\n force = force || !this.initialized\n\n // check items to update\n Object.keys(ReStruct.maps).forEach(map => {\n const mapChanged = this[map + 'Changed']\n if (force) {\n this[map].forEach((_item, id) => mapChanged.set(id, 1))\n } else {\n // check if some of the items marked are already gone\n mapChanged.forEach((_value, id) => {\n if (!this[map].has(id)) mapChanged.delete(id)\n })\n }\n })\n\n this.atomsChanged.forEach((_value, aid) =>\n this.connectedComponentRemoveAtom(aid)\n )\n\n // clean up empty fragments\n // TODO: fragment removal should be triggered by the action responsible for the fragment contents removal and form an operation of its own\n const emptyFrags = this.frags.filter(\n (fid, frag) => !frag.calcBBox(this.render.ctab, fid, this.render)\n )\n\n emptyFrags.forEach((frag, fid) => {\n this.clearVisel(frag.visel)\n this.frags.delete(fid)\n this.molecule.frags.delete(fid)\n })\n\n Object.keys(ReStruct.maps).forEach(map => {\n const mapChanged = this[map + 'Changed']\n\n mapChanged.forEach((_value, id) => {\n this.clearVisel(this[map].get(id).visel)\n this.structChanged = this.structChanged || mapChanged.get(id) > 0\n })\n })\n\n // TODO: when to update sgroup?\n this.sgroups.forEach(sgroup => {\n this.clearVisel(sgroup.visel)\n sgroup.highlighting = null\n sgroup.selectionPlate = null\n })\n\n // TODO [RB] need to implement update-on-demand for fragments and r-groups\n this.frags.forEach(frag => {\n this.clearVisel(frag.visel)\n })\n\n this.rgroups.forEach(rgroup => {\n this.clearVisel(rgroup.visel)\n })\n\n if (force) {\n // clear and recreate all half-bonds\n this.clearConnectedComponents()\n this.molecule.initHalfBonds()\n this.molecule.initNeighbors()\n }\n\n // only update half-bonds adjacent to atoms that have moved\n const atomsChangedArray = Array.from(this.atomsChanged.keys())\n this.molecule.updateHalfBonds(atomsChangedArray)\n this.molecule.sortNeighbors(atomsChangedArray)\n\n this.assignConnectedComponents()\n this.initialized = true\n\n this.verifyLoops()\n const updLoops = force || this.structChanged\n if (updLoops) this.updateLoops()\n this.showLabels()\n this.showBonds()\n if (updLoops) this.showLoops()\n this.showReactionSymbols()\n this.showSGroups()\n\n this.showFragments()\n this.showRGroups()\n this.showEnhancedFlags()\n this.showSimpleObjects()\n this.showTexts()\n this.clearMarks()\n\n return true\n }\n\n updateLoops(): void {\n this.reloops.forEach(reloop => {\n this.clearVisel(reloop.visel)\n })\n const ret = this.molecule.findLoops()\n ret.bondsToMark.forEach(bid => {\n this.markBond(bid, 1)\n })\n ret.newLoops.forEach(loopId => {\n this.reloops.set(loopId, new ReLoop(this.molecule.loops.get(loopId)))\n })\n }\n\n showLoops(): void {\n const options = this.render.options\n this.reloops.forEach((reloop, rlid) => {\n reloop.show(this, rlid, options)\n })\n }\n\n showSimpleObjects(): void {\n const options = this.render.options\n\n this.simpleObjectsChanged.forEach((_value, id) => {\n const simpleObject = this.simpleObjects.get(id)\n if (simpleObject) simpleObject.show(this, options)\n })\n }\n\n showTexts() {\n const options = this.render.options\n\n this.textsChanged.forEach((_value, id) => {\n const text = this.texts.get(id)\n if (text) text.show(this, id, options)\n })\n }\n\n showReactionSymbols(): void {\n const options = this.render.options\n\n this.rxnArrowsChanged.forEach((_value, id) => {\n const arrow = this.rxnArrows.get(id)\n if (arrow) arrow.show(this, id, options)\n })\n\n this.rxnPlusesChanged.forEach((_value, id) => {\n const plus = this.rxnPluses.get(id)\n if (plus) plus.show(this, id, options)\n })\n }\n\n showSGroups(): void {\n this.molecule.sGroupForest\n .getSGroupsBFS()\n .reverse()\n .forEach(id => {\n const resgroup = this.sgroups.get(id)\n if (!resgroup) return\n resgroup.show(this)\n })\n }\n\n showFragments(): void {\n this.frags.forEach((frag, id) => {\n const path = frag.draw(this.render, id)\n if (path)\n this.addReObjectPath(LayerMap.data, frag.visel, path, null, true)\n // TODO fragment selection & highlighting\n })\n }\n\n showRGroups(): void {\n const options = this.render.options\n this.rgroups.forEach((rgroup, id) => {\n rgroup.show(this, id, options)\n })\n }\n\n loopRemove(loopId: number): void {\n const reloop = this.reloops.get(loopId)\n if (!reloop) {\n return\n }\n this.clearVisel(reloop.visel)\n\n const bondlist: Array = []\n\n reloop.loop.hbs.forEach(hbid => {\n const hb = this.molecule.halfBonds.get(hbid)\n if (!hb) return\n hb.loop = -1\n this.markBond(hb.bid, 1)\n this.markAtom(hb.begin, 1)\n bondlist.push(hb.bid)\n })\n\n this.reloops.delete(loopId)\n this.molecule.loops.delete(loopId)\n }\n\n verifyLoops(): void {\n this.reloops.forEach((reloop, rlid) => {\n if (!reloop.isValid(this.molecule, rlid)) this.loopRemove(rlid)\n })\n }\n\n showLabels(): void {\n // eslint-disable-line max-statements\n const options = this.render.options\n\n this.atomsChanged.forEach((_value, aid) => {\n const atom = this.atoms.get(aid)\n if (atom) atom.show(this, aid, options)\n })\n }\n\n showEnhancedFlags(): void {\n const options = this.render.options\n\n this.enhancedFlagsChanged.forEach((_value, chid) => {\n const flag = this.enhancedFlags.get(chid)\n if (flag) flag.show(this, chid, options)\n })\n }\n\n showBonds(): void {\n // eslint-disable-line max-statements\n const options = this.render.options\n\n this.bondsChanged.forEach((_value, bid) => {\n const bond = this.bonds.get(bid)\n if (bond) bond.show(this, bid, options)\n })\n }\n\n setSelection(selection) {\n const redraw = arguments.length === 0 // render.update only\n const atoms: { selected: boolean; sgroup: number }[] = []\n\n Object.keys(ReStruct.maps).forEach(map => {\n const [mapValues] = this[map].values() // hack to include ReSGroup, figure out better solution\n if (ReStruct.maps[map].isSelectable() || mapValues instanceof ReSGroup) {\n this[map].forEach((item, id) => {\n if (item instanceof ReAtom) {\n let sgroup\n for (let sgId of item.a.sgs.values()) {\n sgroup = sgId\n }\n atoms.push({\n selected: item.selected,\n sgroup: sgroup\n })\n }\n if (\n item instanceof ReSGroup &&\n FunctionalGroup.isContractedFunctionalGroup(\n item.item.id,\n this.molecule.functionalGroups\n )\n ) {\n const sGroupAtoms = atoms.filter(\n atom => atom.sgroup === item.item.id\n )\n item.selected = sGroupAtoms.length > 0 && sGroupAtoms[0].selected\n }\n const selected = redraw\n ? item.selected\n : selection && selection[map] && selection[map].indexOf(id) > -1\n\n this.showItemSelection(item, selected)\n })\n }\n })\n }\n showItemSelection(item, selected) {\n var exists = isSelectionSvgObjectExists(item)\n // TODO: simplify me, who sets `removed`?\n item.selected = selected\n if (item instanceof ReDataSGroupData) item.sgroup.selected = selected\n if (selected) {\n if (!exists) {\n var render = this.render\n var options = render.options\n var paper = render.paper\n\n item.selectionPlate = item.makeSelectionPlate(this, paper, options)\n this.addReObjectPath(\n LayerMap.selectionPlate,\n item.visel,\n item.selectionPlate\n )\n }\n if (item.selectionPlate) item.selectionPlate.show() // TODO [RB] review\n } else if (exists && item.selectionPlate) {\n item.selectionPlate.hide() // TODO [RB] review\n }\n }\n}\n\nfunction isSelectionEmpty(selection) {\n if (!selection) return true\n\n const anySelection = Object.keys(ReStruct.maps).some(\n map => selection[map] && selection[map].length > 0\n )\n\n return !anySelection\n}\n\nfunction scaleRPath(path, scaleFactor: number): void {\n if (path.type == 'set') {\n // TODO: rework scaling\n for (var i = 0; i < path.length; ++i) scaleRPath(path[i], scaleFactor)\n } else {\n if (!(typeof path.attrs === 'undefined')) {\n if ('font-size' in path.attrs)\n path.attr('font-size', path.attrs['font-size'] * scaleFactor)\n else if ('stroke-width' in path.attrs)\n path.attr('stroke-width', path.attrs['stroke-width'] * scaleFactor)\n }\n path.scale(scaleFactor, scaleFactor, 0, 0)\n }\n}\n\nfunction scaleVisel(visel, s) {\n for (let i = 0; i < visel.paths.length; ++i) scaleRPath(visel.paths[i], s)\n}\n\n/**\n * SelectionPlate could be an item then value would be in it\n * or it could be a set of items then removed value need to be check on at least one of items in set\n * @param item\n * @returns {boolean}\n */\nfunction isSelectionSvgObjectExists(item) {\n return (\n item &&\n item.selectionPlate !== null &&\n ((!item.selectionPlate?.items && !item.selectionPlate?.removed) ||\n (Array.isArray(item.selectionPlate?.items) &&\n !item.selectionPlate[0]?.removed))\n )\n}\n\nexport default ReStruct\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from 'domain/entities'\nimport { inRange } from 'lodash'\n\nlet FRAC = Math.PI / 12 // '15º'\n\nfunction setFracAngle(angle) {\n FRAC = (Math.PI / 180) * angle\n}\n\nfunction calcAngle(pos0, pos1) {\n const v = Vec2.diff(pos1, pos0)\n return Math.atan2(v.y, v.x)\n}\n\nfunction fracAngle(angle, angle2) {\n if (angle2) angle = calcAngle(angle, angle2)\n return Math.round(angle / FRAC) * FRAC\n}\n\nfunction calcNewAtomPos(pos0, pos1, ctrlKey) {\n const v = new Vec2(1, 0).rotate(\n ctrlKey ? calcAngle(pos0, pos1) : fracAngle(pos0, pos1)\n )\n v.add_(pos0) // eslint-disable-line no-underscore-dangle\n return v\n}\n\nfunction degrees(angle) {\n let degree = Math.round((angle / Math.PI) * 180)\n if (degree > 180) degree -= 360\n else if (degree <= -180) degree += 360\n return degree\n}\n\nconst BONDS_MERGE_ANGLE = 10 // 'º'\nconst BONDS_MERGE_SCALE = 0.2\n\nfunction mergeBondsParams(struct1, bond1, struct2, bond2) {\n const begin1 = struct1.atoms.get(bond1.begin)\n const begin2 = struct2.atoms.get(bond2.begin)\n const end1 = struct1.atoms.get(bond1.end)\n const end2 = struct2.atoms.get(bond2.end)\n\n const angle = calcAngle(begin1.pp, end1.pp) - calcAngle(begin2.pp, end2.pp)\n const mergeAngle = Math.abs(degrees(angle) % 180)\n\n const scale = Vec2.dist(begin1.pp, end1.pp) / Vec2.dist(begin2.pp, end2.pp)\n\n const merged =\n !inRange(mergeAngle, BONDS_MERGE_ANGLE, 180 - BONDS_MERGE_ANGLE) &&\n inRange(scale, 1 - BONDS_MERGE_SCALE, 1 + BONDS_MERGE_SCALE)\n\n return { merged, angle, scale, cross: Math.abs(degrees(angle)) > 90 }\n}\n\nexport default {\n calcAngle,\n fracAngle,\n calcNewAtomPos,\n degrees,\n setFracAngle,\n mergeBondsParams\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Box2Abs, Struct, Vec2 } from 'domain/entities'\n\nimport Raphael from './raphael-ext'\nimport { ReStruct } from './restruct'\nimport { Scale } from 'domain/helpers'\nimport defaultOptions from './options'\nimport draw from './draw'\n\nexport function Render(clientArea, opt) {\n let renderWidth = clientArea.clientWidth - 10\n let renderHeight = clientArea.clientHeight - 10\n renderWidth = renderWidth > 0 ? renderWidth : 0\n renderHeight = renderHeight > 0 ? renderHeight : 0\n\n this.userOpts = opt\n this.clientArea = clientArea\n this.paper = new Raphael(clientArea, renderWidth, renderHeight)\n this.sz = Vec2.ZERO\n this.ctab = new ReStruct(new Struct(), this)\n this.options = defaultOptions(this.userOpts)\n}\n\nRender.prototype.selectionPolygon = function (r) {\n return draw.selectionPolygon(this.paper, r, this.options)\n}\n\nRender.prototype.selectionLine = function (p0, p1) {\n return draw.selectionLine(this.paper, p0, p1, this.options)\n}\n\nRender.prototype.selectionRectangle = function (p0, p1) {\n return draw.selectionRectangle(this.paper, p0, p1, this.options)\n}\n\nRender.prototype.view2obj = function (p, isRelative) {\n var scroll = this.scrollPos()\n if (!this.useOldZoom) {\n p = p.scaled(1 / this.options.zoom)\n scroll = scroll.scaled(1 / this.options.zoom)\n }\n p = isRelative ? p : p.add(scroll).sub(this.options.offset)\n return Scale.scaled2obj(p, this.options)\n}\n\nRender.prototype.obj2view = function (v, isRelative) {\n var p = Scale.obj2scaled(v, this.options)\n p = isRelative\n ? p\n : p\n .add(this.options.offset)\n .sub(this.scrollPos().scaled(1 / this.options.zoom))\n if (!this.useOldZoom) p = p.scaled(this.options.zoom)\n return p\n}\n\nRender.prototype.scrollPos = function () {\n return new Vec2(this.clientArea.scrollLeft, this.clientArea.scrollTop)\n}\n\nfunction cumulativeOffset(el) {\n var curtop = 0\n var curleft = 0\n if (el.parentNode) {\n do {\n curtop += el.offsetTop || 0\n curleft += el.offsetLeft || 0\n el = el.offsetParent\n } while (el)\n }\n return { left: curleft, top: curtop }\n}\n\nRender.prototype.page2obj = function (pagePos) {\n var offset = cumulativeOffset(this.clientArea)\n var pp = new Vec2(pagePos.pageX - offset.left, pagePos.pageY - offset.top)\n return this.view2obj(pp)\n}\n\nRender.prototype.setPaperSize = function (sz) {\n this.sz = sz\n this.paper.setSize(sz.x * this.options.zoom, sz.y * this.options.zoom)\n this.setViewBox(this.options.zoom)\n}\n\nRender.prototype.setOffset = function (newoffset) {\n var delta = new Vec2(\n newoffset.x - this.options.offset.x,\n newoffset.y - this.options.offset.y\n )\n this.clientArea.scrollLeft += delta.x\n this.clientArea.scrollTop += delta.y\n this.options.offset = newoffset\n}\n\nRender.prototype.setZoom = function (zoom) {\n // when scaling the canvas down it may happen that the scaled canvas is smaller than the view window\n // don't forget to call setScrollOffset after zooming (or use extendCanvas directly)\n this.options.zoom = zoom\n this.paper.setSize(this.sz.x * zoom, this.sz.y * zoom)\n this.setViewBox(zoom)\n}\n\nfunction calcExtend(sSz, x0, y0, x1, y1) {\n // eslint-disable-line max-params\n var ex = x0 < 0 ? -x0 : 0\n var ey = y0 < 0 ? -y0 : 0\n\n if (sSz.x < x1) ex += x1 - sSz.x\n if (sSz.y < y1) ey += y1 - sSz.y\n return new Vec2(ex, ey)\n}\n\nRender.prototype.setScrollOffset = function (x, y) {\n var clientArea = this.clientArea\n var cx = clientArea.clientWidth\n var cy = clientArea.clientHeight\n var e = calcExtend(\n this.sz.scaled(this.options.zoom),\n x,\n y,\n cx + x,\n cy + y\n ).scaled(1 / this.options.zoom)\n if (e.x > 0 || e.y > 0) {\n this.setPaperSize(this.sz.add(e))\n var d = new Vec2(x < 0 ? -x : 0, y < 0 ? -y : 0).scaled(\n 1 / this.options.zoom\n )\n if (d.x > 0 || d.y > 0) {\n this.ctab.translate(d)\n this.setOffset(this.options.offset.add(d))\n }\n }\n clientArea.scrollLeft = x\n clientArea.scrollTop = y\n // TODO: store drag position in scaled systems\n // scrollLeft = clientArea.scrollLeft;\n // scrollTop = clientArea.scrollTop;\n this.update(false)\n}\n\nRender.prototype.setScale = function (z) {\n if (this.options.offset)\n this.options.offset = this.options.offset.scaled(1 / z).scaled(z)\n this.userOpts.scale *= z\n this.options = null\n this.update(true)\n}\n\nRender.prototype.setViewBox = function (z) {\n if (!this.useOldZoom)\n this.paper.canvas.setAttribute(\n 'viewBox',\n '0 0 ' + this.sz.x + ' ' + this.sz.y\n )\n else this.setScale(z)\n}\n\nRender.prototype.setMolecule = function (ctab) {\n this.paper.clear()\n this.ctab = new ReStruct(ctab, this)\n this.options.offset = new Vec2()\n this.update(false)\n}\n\nRender.prototype.update = function (force = false, viewSz = null) {\n // eslint-disable-line max-statements\n viewSz =\n viewSz ||\n new Vec2(\n this.clientArea.clientWidth || 100,\n this.clientArea.clientHeight || 100\n )\n\n var changes = this.ctab.update(force)\n this.ctab.setSelection() // [MK] redraw the selection bits where necessary\n if (changes) {\n var sf = this.options.scale\n var bb = this.ctab\n .getVBoxObj()\n .transform(Scale.obj2scaled, this.options)\n .translate(this.options.offset || new Vec2())\n\n if (!this.options.autoScale) {\n var ext = Vec2.UNIT.scaled(sf)\n var eb = bb.sz().length() > 0 ? bb.extend(ext, ext) : bb\n var vb = new Box2Abs(\n this.scrollPos(),\n viewSz.scaled(1 / this.options.zoom).sub(Vec2.UNIT.scaled(20))\n )\n var cb = Box2Abs.union(vb, eb)\n if (!this.oldCb) this.oldCb = new Box2Abs()\n\n var sz = cb.sz().floor()\n var delta = this.oldCb.p0.sub(cb.p0).ceil()\n this.oldBb = bb\n if (!this.sz || sz.x != this.sz.x || sz.y != this.sz.y)\n this.setPaperSize(sz)\n\n this.options.offset = this.options.offset || new Vec2()\n if (delta.x != 0 || delta.y != 0) {\n this.setOffset(this.options.offset.add(delta))\n this.ctab.translate(delta)\n }\n } else {\n var sz1 = bb.sz()\n var marg = this.options.autoScaleMargin\n var mv = new Vec2(marg, marg)\n var csz = viewSz\n if (csz.x < 2 * marg + 1 || csz.y < 2 * marg + 1)\n throw new Error('View box too small for the given margin')\n var rescale = Math.max(\n sz1.x / (csz.x - 2 * marg),\n sz1.y / (csz.y - 2 * marg)\n )\n if (this.options.maxBondLength / rescale > 1.0) rescale = 1.0\n var sz2 = sz1.add(mv.scaled(2 * rescale))\n /* eslint-disable no-mixed-operators*/\n this.paper.setViewBox(\n bb.pos().x - marg * rescale - (csz.x * rescale - sz2.x) / 2,\n bb.pos().y - marg * rescale - (csz.y * rescale - sz2.y) / 2,\n csz.x * rescale,\n csz.y * rescale\n )\n /* eslint-enable no-mixed-operators*/\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2 } from 'domain/entities'\nimport utils from '../editor/shared/utils'\n\nfunction defaultOptions(opt) {\n const scaleFactor = opt.scale || 100\n\n if (opt.rotationStep) utils.setFracAngle(opt.rotationStep)\n\n const labelFontSize = Math.ceil(1.9 * (scaleFactor / 6))\n const subFontSize = Math.ceil(0.7 * labelFontSize)\n\n const defaultOptions = {\n // flags for debugging\n showAtomIds: false,\n showBondIds: false,\n showHalfBondIds: false,\n showLoopIds: false,\n // rendering customization flags\n // TODO: hide enhanced flags opts\n showValenceWarnings: true,\n autoScale: false, // scale structure to fit into the given view box, used in view mode\n autoScaleMargin: 0,\n maxBondLength: 0, // 0 stands for \"not specified\"\n atomColoring: true,\n hideImplicitHydrogen: false,\n hideTerminalLabels: false,\n // atoms\n carbonExplicitly: false,\n showCharge: true,\n showHydrogenLabels: 'on',\n showValence: true,\n // bonds\n aromaticCircle: true,\n\n scale: scaleFactor,\n zoom: 1.0,\n offset: new Vec2(),\n\n lineWidth: scaleFactor / 20,\n bondSpace: opt.doubleBondWidth || scaleFactor / 7,\n stereoBond: opt.stereoBondWidth || scaleFactor / 7,\n subFontSize,\n font: '30px Arial',\n fontsz: labelFontSize,\n fontszsub: subFontSize,\n fontRLabel: labelFontSize * 1.2,\n fontRLogic: labelFontSize * 0.7,\n\n /* styles */\n lineattr: {\n stroke: '#000',\n 'stroke-width': opt.bondThickness || scaleFactor / 20,\n 'stroke-linecap': 'round',\n 'stroke-linejoin': 'round'\n },\n /* eslint-enable quote-props */\n selectionStyle: {\n fill: '#7f7',\n stroke: 'none'\n },\n highlightStyle: {\n stroke: '#0c0',\n 'stroke-width': (0.6 * scaleFactor) / 20\n },\n sgroupBracketStyle: {\n stroke: 'darkgray',\n 'stroke-width': (0.5 * scaleFactor) / 20\n },\n lassoStyle: {\n stroke: 'gray',\n 'stroke-width': '1px'\n },\n highlightStyleSimpleObject: {\n stroke: '#0c0',\n 'stroke-width': scaleFactor / 4,\n 'stroke-linecap': 'round',\n 'stroke-opacity': 0.6\n },\n atomSelectionPlateRadius: labelFontSize * 1.2,\n contractedFunctionalGroupSize: 50\n }\n\n return Object.assign({}, defaultOptions, opt)\n}\n\nexport default defaultOptions\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\n// todo: rename file in another PR\nimport { ReStruct, StereLabelStyleType } from '../../render'\n\nimport { OperationType } from './OperationType'\n\ntype ValueOf = Readonly\ntype OperationType = ValueOf\n\nclass BaseOperation {\n private _inverted: BaseOperation | undefined\n type: OperationType\n priority: number\n\n constructor(type: OperationType, priority = 0) {\n this.type = type\n this.priority = priority\n }\n\n // @ts-ignore\n execute(restruct: ReStruct): void {\n throw new Error('Operation.execute() is not implemented')\n }\n\n perform(restruct: ReStruct): BaseOperation {\n this.execute(restruct)\n if (!this._inverted) {\n this._inverted = this.invert()\n this._inverted._inverted = this\n }\n return this._inverted\n }\n\n invert(): BaseOperation {\n throw new Error('Operation.invert() is not implemented')\n }\n\n // @ts-ignore\n isDummy(restruct: ReStruct): boolean {\n return false\n }\n\n protected static invalidateAtom(restruct: ReStruct, atomId: number, level?) {\n const atom = restruct.atoms.get(atomId)\n if (!atom) {\n return\n }\n\n restruct.markAtom(atomId, level ? 1 : 0)\n\n const halfBonds = restruct.molecule.halfBonds\n\n atom.a.neighbors.forEach(halfBondId => {\n if (!halfBonds.has(halfBondId)) {\n return\n }\n\n const halfBond = halfBonds.get(halfBondId)\n if (!halfBond) {\n return\n }\n\n restruct.markBond(halfBond.bid, 1)\n restruct.markAtom(halfBond.end, 0)\n\n if (level) {\n BaseOperation.invalidateLoop(restruct, halfBond.bid)\n }\n })\n\n const fragment = atom.a.fragment\n const stereoLabelStyle = restruct.render.options.stereoLabelStyle\n\n restruct.atoms.forEach((atom, atomId) => {\n if (\n stereoLabelStyle === StereLabelStyleType.IUPAC ||\n stereoLabelStyle === StereLabelStyleType.Classic\n ) {\n if (atom.a.fragment === fragment) restruct.markAtom(atomId, 0)\n }\n })\n }\n\n protected static invalidateLoop(restruct: ReStruct, bondId: number) {\n const bond = restruct.bonds.get(bondId)\n if (!bond || !bond.b.hb1 || !bond.b.hb2) {\n return\n }\n\n const halfBond1 = restruct.molecule.halfBonds.get(bond.b.hb1)\n const halfBond2 = restruct.molecule.halfBonds.get(bond.b.hb2)\n\n if (halfBond1 && halfBond1.loop >= 0) {\n restruct.loopRemove(halfBond1.loop)\n }\n\n if (halfBond2 && halfBond2.loop >= 0) {\n restruct.loopRemove(halfBond2.loop)\n }\n }\n\n protected static invalidateBond(restruct: ReStruct, bondId: number) {\n BaseOperation.invalidateLoop(restruct, bondId)\n\n const bond = restruct.bonds.get(bondId)\n if (!bond) {\n return\n }\n BaseOperation.invalidateAtom(restruct, bond.b.begin, 0)\n BaseOperation.invalidateAtom(restruct, bond.b.end, 0)\n }\n\n protected static invalidateItem(\n restruct: ReStruct,\n map,\n id: number,\n level?: any\n ) {\n if (map === 'atoms') {\n BaseOperation.invalidateAtom(restruct, id, level)\n return\n }\n\n if (map === 'bonds') {\n BaseOperation.invalidateBond(restruct, id)\n\n if (level > 0) {\n BaseOperation.invalidateLoop(restruct, id)\n }\n return\n }\n\n restruct.markItem(map, id, level)\n }\n\n protected static invalidateEnhancedFlag(\n restruct: ReStruct,\n fragmentId: number\n ) {\n BaseOperation.invalidateItem(restruct, 'enhancedFlags', fragmentId, 1)\n }\n}\n\nexport { BaseOperation }\nexport default BaseOperation\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const OperationType = Object.freeze({\n ATOM_ADD: 'Add atom',\n ATOM_DELETE: 'Delete atom',\n ATOM_ATTR: 'Set atom attribute',\n ATOM_MOVE: 'Move atom',\n CALC_IMPLICIT_H: 'Calculate implicit hydrogen',\n BOND_ADD: 'Add bond',\n BOND_DELETE: 'Delete bond',\n BOND_ATTR: 'Set bond attribute',\n BOND_MOVE: 'Move bond',\n LOOP_MOVE: 'Move loop',\n S_GROUP_ATOM_ADD: 'Add atom to s-group',\n S_GROUP_ATOM_REMOVE: 'Remove atom from s-group',\n S_GROUP_ATTR: 'Set s-group attribute',\n S_GROUP_CREATE: 'Create s-group',\n S_GROUP_DELETE: 'Delete s-group',\n S_GROUP_ADD_TO_HIERACHY: 'Add s-group to hierarchy',\n S_GROUP_REMOVE_FROM_HIERACHY: 'Delete s-group from hierarchy',\n R_GROUP_ATTR: 'Set r-group attribute',\n R_GROUP_FRAGMENT: 'R-group fragment',\n UPDATE_IF_THEN: 'Update',\n RESTORE_IF_THEN: 'Restore',\n RXN_ARROW_ADD: 'Add rxn arrow',\n RXN_ARROW_DELETE: 'Delete rxn arrow',\n RXN_ARROW_MOVE: 'Move rxn arrow',\n RXN_ARROW_RESIZE: 'Resize rxn arrow',\n RXN_PLUS_ADD: 'Add rxn plus',\n RXN_PLUS_DELETE: 'Delete rxn plus',\n RXN_PLUS_MOVE: 'Move rxn plus',\n S_GROUP_DATA_MOVE: 'Move s-group data',\n CANVAS_LOAD: 'Load canvas',\n ALIGN_DESCRIPTORS: 'Align descriptors',\n SIMPLE_OBJECT_ADD: 'Add simple object',\n SIMPLE_OBJECT_DELETE: 'Delete simple object',\n SIMPLE_OBJECT_MOVE: 'Move simple object',\n SIMPLE_OBJECT_RESIZE: 'Resize simple object',\n RESTORE_DESCRIPTORS_POSITION: 'Restore descriptors position',\n FRAGMENT_ADD: 'Add fragment',\n FRAGMENT_DELETE: 'Delete fragment',\n FRAGMENT_STEREO_FLAG: 'Add fragment stereo flag',\n FRAGMENT_ADD_STEREO_ATOM: 'Add stereo atom to fragment',\n FRAGMENT_DELETE_STEREO_ATOM: 'Delete stereo atom from fragment',\n ENHANCED_FLAG_MOVE: 'Move enhanced flag',\n TEXT_CREATE: 'Add text',\n TEXT_UPDATE: 'Edit text',\n TEXT_DELETE: 'Delete text',\n TEXT_MOVE: 'Move text'\n})\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\ntype Data = {\n aid?: any\n attribute?: any\n value?: any\n}\n\nexport class AtomAttr extends BaseOperation {\n data: Data\n data2: Data | null\n\n constructor(atomId?: any, attribute?: any, value?: any) {\n super(OperationType.ATOM_ATTR, 1)\n this.data = { aid: atomId, attribute, value }\n this.data2 = null\n }\n\n execute(restruct: ReStruct) {\n const { aid, attribute, value } = this.data\n\n const atom = restruct.molecule.atoms.get(aid)!\n if (!this.data2) {\n this.data2 = {\n aid,\n attribute,\n value: atom[attribute]\n }\n }\n\n atom[attribute] = value\n BaseOperation.invalidateAtom(restruct, aid)\n }\n\n invert() {\n const inverted = new AtomAttr()\n // @ts-ignore\n inverted.data = this.data2\n inverted.data2 = this.data\n return inverted\n }\n\n isDummy(restruct: ReStruct) {\n return (\n restruct.molecule.atoms.get(this.data.aid)![this.data.attribute] ===\n this.data.value\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\nimport { Scale } from 'domain/helpers'\n\nexport class AtomMove extends BaseOperation {\n data: {\n aid: any\n d: any\n noinvalidate: any\n }\n\n constructor(atomId?: any, d?: any, noinvalidate?: any) {\n super(OperationType.ATOM_MOVE, 2)\n this.data = { aid: atomId, d, noinvalidate }\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const { aid, d } = this.data\n const atom = struct.atoms.get(aid)\n if (!atom) return\n atom!.pp.add_(d) // eslint-disable-line no-underscore-dangle\n const reatom = restruct.atoms.get(aid)\n if (reatom) {\n const scaled = Scale.obj2scaled(d, restruct.render.options)\n reatom.visel.translate(scaled)\n }\n\n this.data.d = d.negated()\n\n if (!this.data.noinvalidate) {\n BaseOperation.invalidateAtom(restruct, aid, 1)\n }\n }\n\n invert() {\n const inverted = new AtomMove()\n inverted.data = this.data\n return inverted\n }\n\n isDummy() {\n const { d } = this.data\n return d.x === 0 && d.y === 0\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, Pile, Vec2 } from 'domain/entities'\nimport { ReAtom, ReStruct } from '../../../render'\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n aid: any\n atom: any\n pos: any\n}\n\nclass AtomAdd extends BaseOperation {\n data: Data\n\n constructor(atom?: any, pos?: any) {\n super(OperationType.ATOM_ADD)\n this.data = { atom, pos, aid: null }\n }\n\n execute(restruct: ReStruct) {\n const { atom, pos } = this.data\n\n const struct = restruct.molecule\n\n const pp: { label?: string } = {}\n if (atom) {\n Object.keys(atom).forEach(p => {\n pp[p] = atom[p]\n })\n }\n\n pp.label = pp.label || 'C'\n if (typeof this.data.aid !== 'number') {\n // @ts-ignore\n this.data.aid = struct.atoms.add(new Atom(pp))\n } else {\n // @ts-ignore\n struct.atoms.set(this.data.aid, new Atom(pp))\n }\n\n const { aid } = this.data\n\n // notifyAtomAdded\n const atomData = new ReAtom(struct.atoms.get(aid)!)\n\n atomData.component = restruct.connectedComponents.add(new Pile([aid]))\n restruct.atoms.set(aid, atomData)\n restruct.markAtom(aid, 1)\n\n struct.atomSetPos(aid, new Vec2(pos))\n\n const arrow = struct.rxnArrows.get(0)\n if (arrow) {\n const atom = struct.atoms.get(aid)!\n atom.rxnFragmentType = struct.defineRxnFragmentTypeForAtomset(\n new Pile([aid]),\n arrow.pos[0].x\n )\n }\n }\n\n invert() {\n const inverted = new AtomDelete()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass AtomDelete extends BaseOperation {\n data: Data\n\n constructor(atomId?: any) {\n super(OperationType.ATOM_DELETE, 5)\n this.data = { aid: atomId, atom: null, pos: null }\n }\n\n execute(restruct: ReStruct) {\n const { aid } = this.data\n\n const struct = restruct.molecule\n if (!this.data.atom) {\n this.data.atom = struct.atoms.get(aid)\n this.data.pos = this.data.atom.pp\n }\n\n // notifyAtomRemoved(aid);\n const restructedAtom = restruct.atoms.get(aid)\n if (!restructedAtom) {\n return\n }\n\n const set = restruct.connectedComponents.get(restructedAtom.component)\n set.delete(aid)\n if (set.size === 0) {\n restruct.connectedComponents.delete(restructedAtom.component)\n }\n\n restruct.clearVisel(restructedAtom.visel)\n restruct.atoms.delete(aid)\n restruct.markItemRemoved()\n struct.atoms.delete(aid)\n }\n\n invert() {\n const inverted = new AtomAdd()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { AtomAdd, AtomDelete }\nexport * from './AtomAttr'\nexport * from './AtomMove'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\ntype Data = {\n bid: any\n attribute: any\n value: any\n}\n\nexport class BondAttr extends BaseOperation {\n data: Data\n data2: Data | null\n\n constructor(bondId?: any, attribute?: any, value?: any) {\n super(OperationType.BOND_ATTR, 2)\n this.data = { bid: bondId, attribute, value }\n this.data2 = null\n }\n\n execute(restruct: ReStruct) {\n const { attribute, bid, value } = this.data\n const bond = restruct.molecule.bonds.get(bid)!\n\n if (!this.data2) {\n this.data2 = {\n bid: bid,\n attribute: attribute,\n value: bond[attribute]\n }\n }\n\n bond[attribute] = value\n\n BaseOperation.invalidateBond(restruct, bid)\n if (attribute === 'type') {\n BaseOperation.invalidateLoop(restruct, bid)\n }\n }\n\n isDummy(restruct: ReStruct) {\n const { attribute, bid, value } = this.data\n const bond = restruct.molecule.bonds.get(bid)!\n return bond[attribute] === value\n }\n\n invert() {\n const inverted = new BondAttr()\n // @ts-ignore\n inverted.data = this.data2\n inverted.data2 = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\nimport { Scale } from 'domain/helpers'\n\nexport class BondMove extends BaseOperation {\n data: {\n bid: any\n d: any\n }\n\n constructor(bondId?: any, d?: any) {\n super(OperationType.BOND_MOVE, 2)\n this.data = { bid: bondId, d }\n }\n\n execute(restruct: ReStruct) {\n const { bid, d } = this.data\n const bond = restruct.bonds.get(bid)\n if (!bond) return\n\n const scaled = Scale.obj2scaled(d, restruct.render.options)\n bond.visel.translate(scaled)\n this.data.d = d.negated()\n }\n\n invert() {\n const inverted = new BondMove()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReBond, ReStruct } from '../../../render'\n\nimport { BaseOperation } from '../base'\nimport { Bond } from 'domain/entities'\nimport { OperationType } from '../OperationType'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n bond: any\n begin: any\n end: any\n bid: any\n}\n\nclass BondAdd extends BaseOperation {\n data: Data\n\n constructor(begin?: any, end?: any, bond?: any) {\n super(OperationType.BOND_ADD, 1)\n this.data = { bond, begin, end, bid: null }\n }\n\n execute(restruct: ReStruct) {\n const { begin, bond, end } = this.data\n // eslint-disable-line max-statements\n const struct = restruct.molecule\n\n if (begin === end) {\n throw new Error('Distinct atoms expected')\n }\n\n BaseOperation.invalidateAtom(restruct, begin, 1)\n BaseOperation.invalidateAtom(restruct, end, 1)\n\n const pp: {\n type?: any\n begin?: any\n end?: any\n } = {}\n\n if (bond) {\n Object.keys(bond).forEach(p => {\n pp[p] = bond[p]\n })\n }\n\n pp.type = pp.type || Bond.PATTERN.TYPE.SINGLE\n pp.begin = begin\n pp.end = end\n\n // @ts-ignore\n const newBond = new Bond(pp)\n if (typeof this.data.bid === 'number') {\n struct.bonds.set(this.data.bid, newBond)\n } else {\n this.data.bid = struct.bonds.add(newBond)\n }\n\n const { bid } = this.data\n const structBond = struct.bonds.get(bid)!\n\n struct.bondInitHalfBonds(bid)\n struct.atomAddNeighbor(structBond.hb1)\n struct.atomAddNeighbor(structBond.hb2)\n\n // notifyBondAdded\n restruct.bonds.set(bid, new ReBond(structBond))\n restruct.markBond(bid, 1)\n }\n\n invert() {\n const inverted = new BondDelete()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass BondDelete extends BaseOperation {\n data: Data\n\n constructor(bondId?: any) {\n super(OperationType.BOND_DELETE, 3)\n this.data = { bid: bondId, bond: null, begin: null, end: null }\n }\n\n execute(restruct: ReStruct) {\n const { bid } = this.data\n\n // eslint-disable-line max-statements\n const struct = restruct.molecule\n if (!this.data.bond) {\n this.data.bond = struct.bonds.get(bid)\n this.data.begin = this.data.bond.begin\n this.data.end = this.data.bond.end\n }\n\n BaseOperation.invalidateBond(restruct, bid)\n\n // notifyBondRemoved\n const rebond = restruct.bonds.get(bid)\n if (!rebond) return\n ;[rebond.b.hb1, rebond.b.hb2].forEach(hbid => {\n if (hbid === undefined) return\n const halfBond = restruct.molecule.halfBonds.get(hbid)\n if (halfBond && halfBond.loop >= 0) {\n restruct.loopRemove(halfBond.loop)\n }\n }, restruct)\n restruct.clearVisel(rebond.visel)\n restruct.bonds.delete(bid)\n restruct.markItemRemoved()\n\n const structBond = struct.bonds.get(bid)!\n ;[structBond.hb1, structBond.hb2].forEach(hbid => {\n const halfBond = struct.halfBonds.get(hbid!)\n if (!halfBond) {\n return\n }\n\n const atom = struct.atoms.get(halfBond.begin)!\n const pos = atom.neighbors.indexOf(hbid!)\n const prev = (pos + atom.neighbors.length - 1) % atom.neighbors.length\n const next = (pos + 1) % atom.neighbors.length\n struct.setHbNext(atom.neighbors[prev], atom.neighbors[next])\n atom.neighbors.splice(pos, 1)\n })\n struct.halfBonds.delete(structBond.hb1!)\n struct.halfBonds.delete(structBond.hb2!)\n\n struct.bonds.delete(bid)\n }\n\n invert() {\n const inverted = new BondAdd()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { BondAdd, BondDelete }\nexport * from './BondAttr'\nexport * from './BondMove'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\nimport { Struct } from 'domain/entities'\n\nexport class CanvasLoad extends BaseOperation {\n data: {\n struct?: Struct\n }\n\n constructor(struct?: Struct) {\n super(OperationType.CANVAS_LOAD)\n this.data = { struct }\n }\n\n execute(restruct: ReStruct) {\n const oldStruct = restruct.molecule\n restruct.clearVisels() // TODO: What is it?\n restruct.render.setMolecule(this.data.struct)\n this.data.struct = oldStruct\n }\n\n invert() {\n const inverted = new CanvasLoad()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\nimport { Vec2 } from 'domain/entities'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\nclass AlignDescriptors extends BaseOperation {\n history: any\n\n constructor() {\n super(OperationType.ALIGN_DESCRIPTORS)\n this.history = {}\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const sgroups: any[] = Array.from(struct.sgroups.values()).reverse()\n\n const structBox: any = struct.getCoordBoundingBoxObj()\n let alignPoint = new Vec2(structBox.max.x, structBox.min.y).add(\n new Vec2(2.0, -1.0)\n )\n\n sgroups.forEach(sgroup => {\n this.history[sgroup.id] = new Vec2(sgroup.pp)\n alignPoint = alignPoint.add(new Vec2(0.0, 0.5))\n sgroup.pp = alignPoint\n struct.sgroups.set(sgroup.id, sgroup)\n BaseOperation.invalidateItem(restruct, 'sgroupData', sgroup.id, 1)\n })\n }\n\n invert() {\n return new RestoreDescriptorsPosition(this.history)\n }\n}\n\nclass RestoreDescriptorsPosition extends BaseOperation {\n history: any\n\n constructor(history: any) {\n super(OperationType.RESTORE_DESCRIPTORS_POSITION)\n this.history = history\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const sgroups: any[] = Array.from(struct.sgroups.values())\n\n sgroups.forEach(sgroup => {\n sgroup.pp = this.history[sgroup.id]\n struct.sgroups.set(sgroup.id, sgroup)\n BaseOperation.invalidateItem(restruct, 'sgroupData', sgroup.id, 1)\n })\n }\n\n invert() {\n return new AlignDescriptors()\n }\n}\n\nexport { AlignDescriptors, RestoreDescriptorsPosition }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Fragment, Vec2 } from 'domain/entities'\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\n\nexport class EnhancedFlagMove extends BaseOperation {\n data: {\n frid: any\n p: any\n }\n\n constructor(fragmentId?: any, p?: any) {\n super(OperationType.ENHANCED_FLAG_MOVE)\n this.data = { frid: fragmentId, p }\n }\n\n execute(restruct: ReStruct) {\n const { frid } = this.data\n const { p } = this.data\n const fragment = restruct.molecule.frags.get(frid)\n if (!fragment) return\n\n const currentPosition = fragment.stereoFlagPosition\n ? new Vec2(fragment.stereoFlagPosition.x, fragment.stereoFlagPosition.y)\n : Fragment.getDefaultStereoFlagPosition(restruct.molecule, frid)!\n\n const newPosition = Vec2.sum(currentPosition, p)\n fragment.stereoFlagPosition = newPosition\n\n this.data.p = p.negated()\n BaseOperation.invalidateItem(restruct, 'enhancedFlags', frid, 1)\n }\n\n invert() {\n const inverted = new EnhancedFlagMove()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\nclass UpdateIfThen extends BaseOperation {\n rgid_new: any\n rgid_old: any\n ifThenHistory: any\n skipRgids: any[]\n\n constructor(rgNew: any, rgOld: any, skipRgids: any = []) {\n super(OperationType.UPDATE_IF_THEN)\n this.rgid_new = rgNew\n this.rgid_old = rgOld\n this.ifThenHistory = new Map()\n this.skipRgids = skipRgids || []\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n\n struct.rgroups.forEach((rg, rgid) => {\n if (rg.ifthen === this.rgid_old && !this.skipRgids.includes(rgid)) {\n rg.ifthen = this.rgid_new\n this.ifThenHistory.set(rgid, this.rgid_old)\n struct.rgroups.set(rgid, rg)\n }\n })\n }\n\n invert() {\n return new RestoreIfThen(this.rgid_new, this.rgid_old, this.ifThenHistory)\n }\n}\n\nclass RestoreIfThen extends BaseOperation {\n rgid_new: any\n rgid_old: any\n ifThenHistory: any\n\n constructor(rgNew: any, rgOld: any, history: any) {\n super(OperationType.RESTORE_IF_THEN)\n this.rgid_new = rgNew\n this.rgid_old = rgOld\n this.ifThenHistory = history || new Map()\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n\n this.ifThenHistory.forEach((rg, rgid) => {\n const rgValue = struct.rgroups.get(rgid)!\n rgValue.ifthen = rg\n struct.rgroups.set(rgid, rgValue)\n })\n }\n\n invert() {\n return new UpdateIfThen(this.rgid_old, this.rgid_new)\n }\n}\n\nexport { UpdateIfThen, RestoreIfThen }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReEnhancedFlag, ReFrag, ReStruct } from '../../render'\n\nimport { BaseOperation } from './base'\nimport { Fragment } from 'domain/entities'\nimport { OperationType } from './OperationType'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\nclass FragmentAdd extends BaseOperation {\n frid: any\n\n constructor(fragmentId?: any) {\n super(OperationType.FRAGMENT_ADD)\n this.frid = typeof fragmentId === 'undefined' ? null : fragmentId\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const frag = new Fragment()\n\n if (this.frid === null) {\n this.frid = struct.frags.add(frag)\n } else {\n struct.frags.set(this.frid, frag)\n }\n\n restruct.frags.set(this.frid, new ReFrag(frag)) // TODO add restruct.notifyFragmentAdded\n restruct.enhancedFlags.set(this.frid, new ReEnhancedFlag())\n }\n\n invert() {\n return new FragmentDelete(this.frid)\n }\n}\n\nclass FragmentDelete extends BaseOperation {\n frid: any\n\n constructor(fragmentId: any) {\n super(OperationType.FRAGMENT_DELETE, 100)\n this.frid = fragmentId\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n if (!struct.frags.get(this.frid)) {\n return\n }\n\n BaseOperation.invalidateItem(restruct, 'frags', this.frid, 1)\n restruct.frags.delete(this.frid)\n struct.frags.delete(this.frid) // TODO add restruct.notifyFragmentRemoved\n\n const enhancedFalg = restruct.enhancedFlags.get(this.frid)\n if (!enhancedFalg) return\n restruct.clearVisel(enhancedFalg.visel)\n restruct.enhancedFlags.delete(this.frid)\n }\n\n invert() {\n return new FragmentAdd(this.frid)\n }\n}\n\nexport { FragmentAdd, FragmentDelete }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n frid: any\n aid: any\n}\n\n// todo : merge add and delete stereo atom\nclass FragmentAddStereoAtom extends BaseOperation {\n data: Data\n\n constructor(fragmentId: any, atomId: any) {\n super(OperationType.FRAGMENT_ADD_STEREO_ATOM, 100)\n this.data = { frid: fragmentId, aid: atomId }\n }\n\n execute(restruct: ReStruct) {\n const { aid, frid } = this.data\n\n const frag = restruct.molecule.frags.get(frid)\n if (frag) {\n frag.updateStereoAtom(restruct.molecule, aid, frid, true)\n\n BaseOperation.invalidateEnhancedFlag(restruct, frid)\n }\n }\n\n invert() {\n return new FragmentDeleteStereoAtom(this.data.frid, this.data.aid)\n }\n}\n\nclass FragmentDeleteStereoAtom extends BaseOperation {\n data: Data\n\n constructor(fragmentId: any, atomId: any) {\n super(OperationType.FRAGMENT_DELETE_STEREO_ATOM, 90)\n this.data = { frid: fragmentId, aid: atomId }\n }\n\n execute(restruct: ReStruct) {\n const { aid, frid } = this.data\n\n const frag = restruct.molecule.frags.get(frid)\n if (frag) {\n frag.updateStereoAtom(restruct.molecule, aid, frid, false)\n\n BaseOperation.invalidateEnhancedFlag(restruct, frid)\n }\n }\n\n invert() {\n const { aid, frid } = this.data\n return new FragmentAddStereoAtom(frid, aid)\n }\n}\n\nexport { FragmentAddStereoAtom, FragmentDeleteStereoAtom }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\n\nexport class FragmentStereoFlag extends BaseOperation {\n frid: number\n\n constructor(fragmentId: number) {\n super(OperationType.FRAGMENT_STEREO_FLAG, 6)\n this.frid = fragmentId\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n\n const fragment = struct.frags.get(this.frid)!\n fragment.updateStereoFlag(struct)\n\n BaseOperation.invalidateEnhancedFlag(restruct, this.frid)\n }\n\n invert() {\n const inverted = new FragmentStereoFlag(this.frid)\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\n\nexport class CalcImplicitH extends BaseOperation {\n atomIds: Array\n\n constructor(aids: Array) {\n super(OperationType.CALC_IMPLICIT_H, 10)\n this.atomIds = aids\n }\n\n execute(restruct: ReStruct) {\n const aIds = this.atomIds\n\n restruct.molecule.setImplicitHydrogen(aIds)\n }\n\n invert() {\n return new CalcImplicitH(this.atomIds)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from './base'\nimport { OperationType } from './OperationType'\nimport { ReStruct } from '../../render'\nimport { Scale } from 'domain/helpers'\n\nexport class LoopMove extends BaseOperation {\n data: {\n id: any\n d: any\n }\n\n constructor(id?: any, d?: any) {\n super(OperationType.LOOP_MOVE)\n this.data = { id, d }\n }\n\n execute(restruct: ReStruct) {\n // not sure if there should be an action to move a loop in the first place\n // but we have to somehow move the aromatic ring,\n // which is associated with the loop, rather than with any of the bonds\n const { id, d } = this.data\n const reloop = restruct.reloops.get(id)\n\n if (reloop && reloop.visel) {\n const scaled = Scale.obj2scaled(d, restruct.render.options)\n reloop.visel.translate(scaled)\n }\n this.data.d = d.negated()\n }\n\n invert() {\n const inverted = new LoopMove()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\ntype Data = {\n rgid: any\n attribute: any\n value: any\n}\n\nexport class RGroupAttr extends BaseOperation {\n data: Data\n data2: Data | null\n\n constructor(rgroupId?: any, attribute?: any, value?: any) {\n super(OperationType.R_GROUP_ATTR)\n this.data = { rgid: rgroupId, attribute, value }\n this.data2 = null\n }\n\n execute(restruct: ReStruct) {\n const { rgid, attribute, value } = this.data\n\n const rgp = restruct.molecule.rgroups.get(rgid)!\n\n if (!rgp) {\n return\n }\n\n if (!this.data2) {\n this.data2 = {\n rgid,\n attribute,\n value: rgp[attribute]\n }\n }\n\n rgp[attribute] = value\n\n BaseOperation.invalidateItem(restruct, 'rgroups', rgid)\n }\n\n invert() {\n const inverted = new RGroupAttr()\n // @ts-ignore\n inverted.data = this.data2\n inverted.data2 = this.data\n return inverted\n }\n\n isDummy(restruct: ReStruct) {\n const { rgid, attribute, value } = this.data\n const rgroup = restruct.molecule.rgroups.get(rgid)!\n return rgroup[attribute] === value\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReRGroup, ReStruct } from '../../../render'\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { RGroup } from 'domain/entities'\n\nexport class RGroupFragment extends BaseOperation {\n rgid_new: any\n rg_new: any\n rgid_old: any\n rg_old: any\n frid: any\n\n constructor(rgroupId: any, fragmentId: any, rg?: any) {\n super(OperationType.R_GROUP_FRAGMENT)\n this.rgid_new = rgroupId\n this.rg_new = rg\n this.rgid_old = null\n this.rg_old = null\n this.frid = fragmentId\n }\n\n execute(restruct: ReStruct) {\n // eslint-disable-line max-statements\n const struct = restruct.molecule\n this.rgid_old =\n this.rgid_old || RGroup.findRGroupByFragment(struct.rgroups, this.frid)\n\n this.rg_old = this.rgid_old ? struct.rgroups.get(this.rgid_old) : null\n\n this.removeOld(struct, restruct)\n this.setNew(struct, restruct)\n }\n\n private removeOld(struct: any, restruct: any) {\n if (!this.rg_old) {\n return\n }\n\n this.rg_old.frags.delete(this.frid)\n restruct.clearVisel(restruct.rgroups.get(this.rgid_old).visel)\n\n if (this.rg_old.frags.size === 0) {\n restruct.rgroups.delete(this.rgid_old)\n struct.rgroups.delete(this.rgid_old)\n restruct.markItemRemoved()\n } else {\n restruct.markItem('rgroups', this.rgid_old, 1)\n }\n }\n\n private setNew(struct: any, restruct: ReStruct) {\n if (!this.rgid_new) {\n return\n }\n\n let rgNew = struct.rgroups.get(this.rgid_new)\n if (!rgNew) {\n rgNew = this.rg_new || new RGroup()\n struct.rgroups.set(this.rgid_new, rgNew)\n restruct.rgroups.set(this.rgid_new, new ReRGroup(rgNew))\n } else {\n restruct.markItem('rgroups', this.rgid_new, 1)\n }\n\n rgNew.frags.add(this.frid)\n }\n\n invert() {\n return new RGroupFragment(this.rgid_old, this.frid, this.rg_old)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport Base from '../base'\nimport { OperationType } from '../OperationType'\nimport { Scale } from 'domain/helpers'\n\ninterface RxnArrowMoveData {\n id: number\n d: any\n noinvalidate: boolean\n}\n\nexport class RxnArrowMove extends Base {\n data: RxnArrowMoveData\n\n constructor(id?: any, d?: any, noinvalidate?: any) {\n super(OperationType.RXN_ARROW_MOVE)\n this.data = { id, d, noinvalidate }\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const id = this.data.id\n const d = this.data.d\n const item = struct.rxnArrows.get(id)\n item.pos.forEach(p => p.add_(d))\n restruct.rxnArrows\n .get(id)\n .visel.translate(Scale.obj2scaled(d, restruct.render.options))\n this.data.d = d.negated()\n if (!this.data.noinvalidate) {\n Base.invalidateItem(restruct, 'rxnArrows', id, 1)\n }\n }\n\n invert() {\n const move = new RxnArrowMove(\n this.data.id,\n this.data.d,\n this.data.noinvalidate\n )\n move.data = this.data\n return move\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport Base from '../base'\nimport { OperationType } from '../OperationType'\nimport { Scale } from 'domain/helpers'\nimport { Vec2 } from 'domain/entities'\nimport { tfx } from 'utilities'\n\ninterface RxnArrowResizeData {\n id: number\n d: any\n current: Vec2\n anchor: Vec2\n noinvalidate: boolean\n}\n\nexport class RxnArrowResize extends Base {\n data: RxnArrowResizeData\n\n constructor(\n id: number,\n d: any,\n current: Vec2,\n anchor: any,\n noinvalidate: boolean\n ) {\n super(OperationType.RXN_ARROW_RESIZE)\n this.data = { id, d, current, anchor, noinvalidate }\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const id = this.data.id\n const d = this.data.d\n const current = this.data.current\n const item = struct.rxnArrows.get(id)\n const anchor = this.data.anchor\n\n if (anchor) {\n const previousPos0 = item.pos[0].get_xy0()\n const previousPos1 = item.pos[1].get_xy0()\n\n if (\n tfx(anchor.x) === tfx(item.pos[1].x) &&\n tfx(anchor.y) === tfx(item.pos[1].y)\n ) {\n item.pos[1].x = anchor.x = current.x\n current.x = previousPos1.x\n item.pos[1].y = anchor.y = current.y\n current.y = previousPos1.y\n }\n\n if (\n tfx(anchor.x) === tfx(item.pos[0].x) &&\n tfx(anchor.y) === tfx(item.pos[0].y)\n ) {\n item.pos[0].x = anchor.x = current.x\n current.x = previousPos0.x\n item.pos[0].y = anchor.y = current.y\n current.y = previousPos0.y\n }\n } else item.pos[1].add_(d)\n\n restruct.rxnArrows\n .get(id)\n .visel.translate(Scale.obj2scaled(d, restruct.render.options))\n this.data.d = d.negated()\n\n if (!this.data.noinvalidate) {\n Base.invalidateItem(\n restruct,\n 'rxnArrows',\n // @ts-ignore\n id,\n 1\n )\n }\n }\n\n invert(): Base {\n return new RxnArrowResize(\n this.data.id,\n this.data.d,\n this.data.current,\n this.data.anchor,\n this.data.noinvalidate\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../../base'\nimport { OperationType } from '../../OperationType'\nimport { ReStruct } from '../../../../render'\nimport { Scale } from 'domain/helpers'\n\nexport class RxnPlusMove extends BaseOperation {\n data: {\n id: any\n d: any\n noinvalidate: any\n }\n\n constructor(id?: any, d?: any, noinvalidate?: any) {\n super(OperationType.RXN_PLUS_MOVE)\n this.data = { id, d, noinvalidate }\n }\n\n execute(restruct: ReStruct) {\n const { id, d, noinvalidate } = this.data\n\n const struct = restruct.molecule\n struct.rxnPluses.get(id)!.pp.add_(d) // eslint-disable-line no-underscore-dangle\n\n const rxn = restruct.rxnPluses.get(id)!\n const scaled = Scale.obj2scaled(d, restruct.render.options)\n rxn.visel.translate(scaled)\n\n this.data.d = d.negated()\n\n if (!noinvalidate) {\n BaseOperation.invalidateItem(restruct, 'rxnPluses', id, 1)\n }\n }\n\n invert() {\n const inverted = new RxnPlusMove()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReRxnPlus, ReStruct } from '../../../../render'\nimport { RxnPlus, Vec2 } from 'domain/entities'\n\nimport { BaseOperation } from '../../base'\nimport { OperationType } from '../../OperationType'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n plid: any\n pos: any\n}\n\nclass RxnPlusAdd extends BaseOperation {\n data: Data\n\n constructor(pos?: any) {\n super(OperationType.RXN_PLUS_ADD)\n this.data = { plid: null, pos }\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n\n const newRxn = new RxnPlus()\n if (typeof this.data.plid === 'number') {\n struct.rxnPluses.set(this.data.plid, newRxn)\n } else {\n this.data.plid = struct.rxnPluses.add(newRxn)\n }\n\n const { pos, plid } = this.data\n\n const structRxn = struct.rxnPluses.get(plid)\n // notifyRxnPlusAdded\n restruct.rxnPluses.set(plid, new ReRxnPlus(structRxn))\n\n struct.rxnPlusSetPos(plid, new Vec2(pos))\n\n BaseOperation.invalidateItem(restruct, 'rxnPluses', plid, 1)\n }\n\n invert() {\n const inverted = new RxnPlusDelete()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass RxnPlusDelete extends BaseOperation {\n data: Data\n\n constructor(plid?: any) {\n super(OperationType.RXN_PLUS_DELETE)\n this.data = { plid, pos: null }\n }\n\n execute(restruct: ReStruct) {\n const { plid } = this.data\n\n const struct = restruct.molecule\n if (!this.data.pos) {\n this.data.pos = struct.rxnPluses.get(plid)!.pp\n }\n\n // notifyRxnPlusRemoved\n restruct.markItemRemoved()\n const rxn = restruct.rxnPluses.get(plid)\n if (!rxn) return\n restruct.clearVisel(rxn.visel)\n restruct.rxnPluses.delete(plid)\n\n struct.rxnPluses.delete(plid)\n }\n\n invert() {\n const inverted = new RxnPlusAdd()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { RxnPlusAdd, RxnPlusDelete }\nexport * from './RxnPlusMove'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RxnArrow, RxnArrowMode, Vec2 } from 'domain/entities'\n\nimport Base from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReRxnArrow } from '../../../render'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype RxnArrowAddData = {\n id?: number\n pos: Array\n mode: RxnArrowMode\n}\n\nclass RxnArrowAdd extends Base {\n data: RxnArrowAddData\n\n constructor(\n pos: Array = [],\n mode: RxnArrowMode = RxnArrowMode.OpenAngle,\n id?: number\n ) {\n super(OperationType.RXN_ARROW_ADD)\n this.data = { pos, mode, id }\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const item = new RxnArrow({ mode: this.data.mode })\n\n if (this.data.id == null) {\n const index = struct.rxnArrows.add(item)\n this.data.id = index\n } else {\n struct.rxnArrows.set(this.data.id!, item)\n }\n\n const itemId = this.data.id!\n\n restruct.rxnArrows.set(itemId, new ReRxnArrow(item))\n\n const positions = [...this.data.pos]\n\n struct.rxnArrowSetPos(\n itemId,\n positions.map(p => new Vec2(p))\n )\n\n Base.invalidateItem(restruct, 'rxnArrows', itemId, 1)\n }\n invert(): Base {\n return new RxnArrowDelete(this.data.id!)\n }\n}\n\ninterface RxnArrowDeleteData {\n id: number\n pos?: Array\n mode?: RxnArrowMode\n}\n\nclass RxnArrowDelete extends Base {\n data: RxnArrowDeleteData\n performed: boolean\n\n constructor(id: number) {\n super(OperationType.RXN_ARROW_DELETE)\n this.data = { id, pos: [], mode: RxnArrowMode.OpenAngle }\n this.performed = false\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const item = struct.rxnArrows.get(this.data.id) as any\n this.data.pos = item.pos\n this.data.mode = item.mode\n this.performed = true\n\n restruct.markItemRemoved()\n restruct.clearVisel(restruct.rxnArrows.get(this.data.id).visel)\n restruct.rxnArrows.delete(this.data.id)\n\n struct.rxnArrows.delete(this.data.id)\n }\n\n invert(): Base {\n return new RxnArrowAdd(this.data.pos, this.data.mode, this.data.id)\n }\n}\n\nexport { RxnArrowAdd, RxnArrowDelete }\nexport * from './RxnArrowMove'\nexport * from './RxnArrowResize'\nexport * from './plus'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { SimpleObject, SimpleObjectMode, Vec2 } from 'domain/entities'\n\nimport Base from './base'\nimport { OperationType } from './OperationType'\nimport { ReSimpleObject } from '../../render'\nimport { Scale } from 'domain/helpers'\nimport { tfx } from 'utilities'\n\ninterface SimpleObjectAddData {\n id?: number\n pos: Array\n mode: SimpleObjectMode\n toCircle: boolean\n}\nexport class SimpleObjectAdd extends Base {\n data: SimpleObjectAddData\n\n constructor(\n pos: Array = [],\n mode: SimpleObjectMode = SimpleObjectMode.line,\n toCircle: boolean = false,\n id?: number\n ) {\n super(OperationType.SIMPLE_OBJECT_ADD)\n this.data = { pos, mode, toCircle, id }\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const item = new SimpleObject({ mode: this.data.mode })\n\n if (this.data.id == null) {\n const index = struct.simpleObjects.add(item)\n this.data.id = index\n } else {\n struct.simpleObjects.set(this.data.id!, item)\n }\n\n const itemId = this.data.id!\n\n restruct.simpleObjects.set(itemId, new ReSimpleObject(item))\n\n const positions = [...this.data.pos]\n if (this.data.toCircle) {\n positions[1] = makeCircleFromEllipse(positions[0], positions[1])\n }\n struct.simpleObjectSetPos(\n itemId,\n positions.map(p => new Vec2(p))\n )\n\n Base.invalidateItem(restruct, 'simpleObjects', itemId, 1)\n }\n invert(): Base {\n return new SimpleObjectDelete(this.data.id!)\n }\n}\n\ninterface SimpleObjectDeleteData {\n id: number\n pos?: Array\n mode?: SimpleObjectMode\n toCircle?: boolean\n}\n\nexport class SimpleObjectDelete extends Base {\n data: SimpleObjectDeleteData\n performed: boolean\n\n constructor(id: number) {\n super(OperationType.SIMPLE_OBJECT_DELETE)\n this.data = { id, pos: [], mode: SimpleObjectMode.line, toCircle: false }\n this.performed = false\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const item = struct.simpleObjects.get(this.data.id) as any\n //save to data current values. In future they could be used in invert for restoring simple object\n this.data.pos = item.pos\n this.data.mode = item.mode\n this.data.toCircle = item.toCircle\n this.performed = true\n\n restruct.markItemRemoved()\n restruct.clearVisel(restruct.simpleObjects.get(this.data.id).visel)\n restruct.simpleObjects.delete(this.data.id)\n\n struct.simpleObjects.delete(this.data.id)\n }\n\n invert(): Base {\n return new SimpleObjectAdd(\n this.data.pos,\n this.data.mode,\n this.data.toCircle,\n this.data.id\n )\n }\n}\n\ninterface SimpleObjectMoveData {\n id: number\n d: any\n noinvalidate: boolean\n}\n\nexport class SimpleObjectMove extends Base {\n data: SimpleObjectMoveData\n\n constructor(id: number, d: any, noinvalidate: boolean) {\n super(OperationType.SIMPLE_OBJECT_MOVE)\n this.data = { id, d, noinvalidate }\n }\n execute(restruct: any): void {\n const struct = restruct.molecule\n const id = this.data.id\n const d = this.data.d\n const item = struct.simpleObjects.get(id)\n item.pos.forEach(p => p.add_(d))\n restruct.simpleObjects\n .get(id)\n .visel.translate(Scale.obj2scaled(d, restruct.render.options))\n this.data.d = d.negated()\n if (!this.data.noinvalidate) {\n Base.invalidateItem(restruct, 'simpleObjects', id, 1)\n }\n }\n\n invert(): Base {\n const move = new SimpleObjectMove(\n this.data.id,\n this.data.d,\n this.data.noinvalidate\n )\n //todo Need further investigation on why this is needed?\n move.data = this.data\n return move\n }\n}\n\ninterface SimpleObjectResizeData {\n id: number\n d: any\n current: Vec2\n anchor: Vec2\n noinvalidate: boolean\n toCircle: boolean\n}\n\nfunction handleRectangleChangeWithAnchor(item, anchor, current) {\n const previousPos0 = item.pos[0].get_xy0()\n const previousPos1 = item.pos[1].get_xy0()\n\n if (tfx(anchor.x) === tfx(item.pos[1].x)) {\n item.pos[1].x = anchor.x = current.x\n current.x = previousPos1.x\n }\n if (tfx(anchor.y) === tfx(item.pos[1].y)) {\n item.pos[1].y = anchor.y = current.y\n current.y = previousPos1.y\n }\n if (tfx(anchor.x) === tfx(item.pos[0].x)) {\n item.pos[0].x = anchor.x = current.x\n current.x = previousPos0.x\n }\n if (tfx(anchor.y) === tfx(item.pos[0].y)) {\n item.pos[0].y = anchor.y = current.y\n current.y = previousPos0.y\n }\n}\n\nexport class SimpleObjectResize extends Base {\n data: SimpleObjectResizeData\n\n constructor(\n id: number,\n d: any,\n current: Vec2,\n anchor: any,\n noinvalidate: boolean,\n toCircle: boolean\n ) {\n super(OperationType.SIMPLE_OBJECT_RESIZE)\n this.data = { id, d, current, anchor, noinvalidate, toCircle }\n }\n\n execute(restruct: any): void {\n const struct = restruct.molecule\n const id = this.data.id\n const d = this.data.d\n const current = this.data.current\n const item = struct.simpleObjects.get(id)\n const anchor = this.data.anchor\n if (item.mode === SimpleObjectMode.ellipse) {\n if (anchor) {\n handleRectangleChangeWithAnchor(item, anchor, current)\n } else if (this.data.toCircle) {\n const previousPos1 = item.pos[1].get_xy0()\n const circlePoint = makeCircleFromEllipse(item.pos[0], current)\n item.pos[1].x = circlePoint.x\n item.pos[1].y = circlePoint.y\n this.data.current = previousPos1\n } else {\n const previousPos1 = item.pos[1].get_xy0()\n item.pos[1].x = current.x\n item.pos[1].y = current.y\n this.data.current = previousPos1\n }\n } else if (item.mode === SimpleObjectMode.line && anchor) {\n const previousPos0 = item.pos[0].get_xy0()\n const previousPos1 = item.pos[1].get_xy0()\n\n if (\n tfx(anchor.x) === tfx(item.pos[1].x) &&\n tfx(anchor.y) === tfx(item.pos[1].y)\n ) {\n item.pos[1].x = anchor.x = current.x\n current.x = previousPos1.x\n item.pos[1].y = anchor.y = current.y\n current.y = previousPos1.y\n }\n\n if (\n tfx(anchor.x) === tfx(item.pos[0].x) &&\n tfx(anchor.y) === tfx(item.pos[0].y)\n ) {\n item.pos[0].x = anchor.x = current.x\n current.x = previousPos0.x\n item.pos[0].y = anchor.y = current.y\n current.y = previousPos0.y\n }\n } else if (item.mode === SimpleObjectMode.rectangle && anchor) {\n handleRectangleChangeWithAnchor(item, anchor, current)\n } else item.pos[1].add_(d)\n\n restruct.simpleObjects\n .get(id)\n .visel.translate(Scale.obj2scaled(d, restruct.render.options))\n this.data.d = d.negated()\n if (!this.data.noinvalidate) {\n Base.invalidateItem(\n restruct,\n 'simpleObjects',\n // @ts-ignore\n id,\n 1\n )\n }\n }\n invert(): Base {\n return new SimpleObjectResize(\n this.data.id,\n this.data.d,\n this.data.current,\n this.data.anchor,\n this.data.noinvalidate,\n this.data.toCircle\n )\n }\n}\n\nexport function makeCircleFromEllipse(position0: Vec2, position1: Vec2): Vec2 {\n const diff = Vec2.diff(position1, position0)\n const min = Math.abs(diff.x) < Math.abs(diff.y) ? diff.x : diff.y\n return new Vec2(\n position0.x + (diff.x > 0 ? 1 : -1) * Math.abs(min),\n position0.y + (diff.y > 0 ? 1 : -1) * Math.abs(min),\n 0\n )\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\nimport { SGroup } from 'domain/entities'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n sgid: any\n aid: any\n}\n\nclass SGroupAtomAdd extends BaseOperation {\n data: Data\n\n constructor(sgroupId?: any, aid?: any) {\n super(OperationType.S_GROUP_ATOM_ADD, 3)\n this.data = { sgid: sgroupId, aid }\n }\n\n execute(restruct: ReStruct) {\n const { aid, sgid } = this.data\n\n const struct = restruct.molecule\n const atom = struct.atoms.get(aid)!\n const sgroup = struct.sgroups.get(sgid)!\n\n if (sgroup.atoms.indexOf(aid) >= 0) {\n throw new Error(\n 'The same atom cannot be added to an S-group more than once'\n )\n }\n\n if (!atom) {\n throw new Error('OpSGroupAtomAdd: Atom ' + aid + ' not found')\n }\n\n struct.atomAddToSGroup(sgid, aid)\n BaseOperation.invalidateAtom(restruct, aid)\n }\n\n invert() {\n const inverted = new SGroupAtomRemove()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass SGroupAtomRemove extends BaseOperation {\n data: Data\n\n constructor(sgroupId?: any, aid?: any) {\n super(OperationType.S_GROUP_ATOM_REMOVE, 4)\n this.data = { sgid: sgroupId, aid }\n }\n\n execute(restruct: ReStruct) {\n const { aid, sgid } = this.data\n\n const struct = restruct.molecule\n const atom = struct.atoms.get(aid)!\n const sgroup = struct.sgroups.get(sgid)!\n\n SGroup.removeAtom(sgroup, aid)\n atom.sgs.delete(sgid)\n BaseOperation.invalidateAtom(restruct, aid)\n }\n\n invert() {\n const inverted = new SGroupAtomAdd()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { SGroupAtomAdd, SGroupAtomRemove }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\nexport class SGroupAttr extends BaseOperation {\n data: {\n sgid: any\n attr: any\n value: any\n }\n\n constructor(sgroupId?: any, attribute?: any, value?: any) {\n super(OperationType.S_GROUP_ATTR, 4)\n this.data = {\n sgid: sgroupId,\n attr: attribute,\n value\n }\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const sgroupId = this.data.sgid\n const sgroup = struct.sgroups.get(sgroupId)!\n\n const sgroupData = restruct.sgroupData.get(sgroupId)\n if (sgroup.type === 'DAT' && sgroupData) {\n // clean the stuff here, else it might be left behind if the sgroups is set to \"attached\"\n restruct.clearVisel(sgroupData.visel)\n restruct.sgroupData.delete(sgroupId)\n }\n\n this.data.value = sgroup.setAttr(this.data.attr, this.data.value)\n }\n\n invert() {\n const inverted = new SGroupAttr()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\nexport class SGroupDataMove extends BaseOperation {\n data: {\n id: any\n d: any\n }\n\n constructor(id?: any, d?: any) {\n super(OperationType.S_GROUP_DATA_MOVE)\n this.data = { id, d }\n }\n\n execute(restruct: ReStruct) {\n const { d, id } = this.data\n const { sgroups } = restruct.molecule\n\n sgroups.get(id)!.pp?.add_(d) // eslint-disable-line no-underscore-dangle\n this.data.d = d.negated()\n\n // [MK] this currently does nothing since the DataSGroupData Visel only contains the highlighting/selection and SGroups are redrawn every time anyway\n BaseOperation.invalidateItem(restruct, 'sgroupData', id, 1)\n }\n\n invert() {\n const inverted = new SGroupDataMove()\n inverted.data = this.data\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n sgid: any\n parent?: any\n children?: any\n}\n\nclass SGroupAddToHierarchy extends BaseOperation {\n data: Data\n\n constructor(sgroupId?: any, parent?: any, children?: any) {\n super(OperationType.S_GROUP_ADD_TO_HIERACHY, 100)\n this.data = { sgid: sgroupId, parent, children }\n }\n\n execute(restruct: ReStruct) {\n const { sgid, parent, children } = this.data\n\n const struct = restruct.molecule\n const sgroup = struct.sgroups.get(sgid)!\n const relations = struct.sGroupForest.insert(sgroup, parent, children)\n\n this.data.parent = relations.parent\n this.data.children = relations.children\n }\n\n invert() {\n const inverted = new SGroupRemoveFromHierarchy()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass SGroupRemoveFromHierarchy extends BaseOperation {\n data: Data\n\n constructor(sgroupId?: any) {\n super(OperationType.S_GROUP_REMOVE_FROM_HIERACHY, 110)\n this.data = { sgid: sgroupId }\n }\n\n execute(restruct: any) {\n const { sgid } = this.data\n const struct = restruct.molecule\n\n this.data.parent = struct.sGroupForest.parent.get(sgid)\n this.data.children = struct.sGroupForest.children.get(sgid)\n struct.sGroupForest.remove(sgid)\n }\n\n invert() {\n const inverted = new SGroupAddToHierarchy()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { SGroupAddToHierarchy, SGroupRemoveFromHierarchy }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FunctionalGroup, SGroup, Vec2 } from 'domain/entities'\nimport { ReSGroup, ReStruct } from '../../../render'\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\n\n// todo: separate classes: now here is circular dependency in `invert` method\n\ntype Data = {\n sgid: any\n type?: any\n pp?: any\n expanded?: boolean\n name?: string\n}\n\nclass SGroupCreate extends BaseOperation {\n data: Data\n\n constructor(\n sgroupId?: any,\n type?: any,\n pp?: any,\n expanded?: boolean,\n name?: string\n ) {\n super(OperationType.S_GROUP_CREATE)\n this.data = {\n sgid: sgroupId,\n type,\n pp,\n expanded,\n name\n }\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const sgroup = new SGroup(this.data.type)\n const { sgid, pp, expanded, name } = this.data\n\n sgroup.id = sgid\n struct.sgroups.set(sgid, sgroup)\n\n if (pp) {\n struct.sgroups.get(sgid)!.pp = new Vec2(pp)\n }\n\n if (expanded) {\n sgroup.data.expanded = expanded\n }\n\n if (name) {\n sgroup.data.name = name\n }\n\n restruct.sgroups.set(sgid, new ReSGroup(struct.sgroups.get(sgid)))\n if (FunctionalGroup.isFunctionalGroup(sgroup)) {\n restruct.molecule.functionalGroups.add(new FunctionalGroup(sgroup))\n }\n this.data.sgid = sgid\n }\n\n invert() {\n const inverted = new SGroupDelete()\n inverted.data = this.data\n return inverted\n }\n}\n\nclass SGroupDelete extends BaseOperation {\n data: Data\n\n constructor(sgroupId?: any) {\n super(OperationType.S_GROUP_DELETE, 95)\n this.data = { sgid: sgroupId }\n }\n\n execute(restruct: ReStruct) {\n const struct = restruct.molecule\n const { sgid } = this.data\n const sgroup = restruct.sgroups.get(sgid)\n const sgroupData = restruct.sgroupData.get(sgid)\n if (!sgroup) return\n this.data.type = sgroup.item.type\n this.data.pp = sgroup.item.pp\n\n if (sgroup.item.type === 'DAT' && sgroupData) {\n restruct.clearVisel(sgroupData.visel)\n restruct.sgroupData.delete(sgid)\n }\n\n restruct.clearVisel(sgroup.visel)\n if (sgroup.item.atoms.length !== 0) {\n throw new Error('S-Group not empty!')\n }\n\n if (FunctionalGroup.isFunctionalGroup(sgroup.item)) {\n let relatedFGroupId\n this.data.name = sgroup.item.data.name\n this.data.expanded = sgroup.item.expanded\n restruct.molecule.functionalGroups.forEach((fg, fgid) => {\n if (fg.relatedSGroupId === sgid) {\n relatedFGroupId = fgid\n }\n })\n restruct.molecule.functionalGroups.delete(relatedFGroupId)\n }\n\n restruct.sgroups.delete(sgid)\n struct.sgroups.delete(sgid)\n }\n\n invert() {\n const inverted = new SGroupCreate()\n inverted.data = this.data\n return inverted\n }\n}\n\nexport { SGroupCreate, SGroupDelete }\nexport * from './sgroupAtom'\nexport * from './SGroupAttr'\nexport * from './SGroupDataMove'\nexport * from './sgroupHierarchy'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReStruct, ReText } from '../../../render'\nimport { Text, Vec2 } from 'domain/entities'\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\n\ninterface TextCreateData {\n id?: number\n content: string\n position: Vec2\n}\n\nexport class TextCreate extends BaseOperation {\n data: TextCreateData\n\n constructor(content: string, position: Vec2, id?: number) {\n super(OperationType.TEXT_CREATE)\n this.data = { content: content, position, id }\n }\n\n execute(restruct: ReStruct): void {\n const struct = restruct.molecule\n const item = new Text(this.data)\n\n if (this.data.id == null) {\n const index = struct.texts.add(item)\n this.data.id = index\n } else {\n struct.texts.set(this.data.id!, item)\n }\n\n const itemId = this.data.id!\n\n restruct.texts.set(itemId, new ReText(item))\n\n struct.textSetPosition(itemId, new Vec2(this.data.position))\n BaseOperation.invalidateItem(restruct, 'texts', itemId, 1)\n }\n\n invert(): BaseOperation {\n return new TextDelete(this.data.id!)\n }\n}\n\ninterface TextDeleteData {\n id: number\n content?: string\n position?: Vec2\n}\n\nexport class TextDelete extends BaseOperation {\n data: TextDeleteData\n\n constructor(id: number) {\n super(OperationType.TEXT_DELETE)\n this.data = { id }\n }\n\n execute(restruct: ReStruct): void {\n const struct = restruct.molecule\n const item = struct.texts.get(this.data.id)!\n if (!item) return\n\n this.data.content = item.content!\n this.data.position = item.position\n\n restruct.markItemRemoved()\n\n restruct.clearVisel(restruct.texts.get(this.data.id)!.visel)\n restruct.texts.delete(this.data.id)\n\n struct.texts.delete(this.data.id)\n }\n\n invert(): BaseOperation {\n return new TextCreate(this.data.content!, this.data.position!, this.data.id)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\n\ninterface TextUpdateData {\n id: number\n content: string\n previousContent?: string\n}\n\nexport class TextUpdate extends BaseOperation {\n data: TextUpdateData\n\n constructor(id: number, content: string) {\n super(OperationType.TEXT_UPDATE)\n this.data = { id, content: content }\n }\n\n execute(restruct: ReStruct) {\n const { id, content } = this.data\n const text = restruct.molecule.texts.get(id)\n\n if (text) {\n this.data.previousContent = text.content!\n text.content = content\n }\n\n BaseOperation.invalidateItem(restruct, 'texts', id, 1)\n }\n\n invert() {\n const inverted = new TextUpdate(this.data.id, this.data.previousContent!)\n\n inverted.data.previousContent = this.data.content\n return inverted\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../base'\nimport { OperationType } from '../OperationType'\nimport { ReStruct } from '../../../render'\nimport { Scale } from 'domain/helpers'\n\ninterface TextMoveData {\n id: any\n d: any\n noinvalidate: boolean\n}\n\nexport class TextMove extends BaseOperation {\n data: TextMoveData\n\n constructor(id: any, d: any, noinvalidate: boolean) {\n super(OperationType.TEXT_MOVE)\n this.data = { id, d, noinvalidate }\n }\n\n execute(restruct: ReStruct): void {\n const struct = restruct.molecule\n const id = this.data.id\n const difference = this.data.d\n const item = struct.texts.get(id)\n\n item?.position?.add_(difference)\n restruct.texts\n .get(id)\n ?.visel.translate(Scale.obj2scaled(difference, restruct.render.options))\n\n this.data.d = difference.negated()\n\n if (!this.data.noinvalidate) {\n BaseOperation.invalidateItem(restruct, 'texts', id, 1)\n }\n }\n\n invert(): BaseOperation {\n const move = new TextMove(this.data.id, this.data.d, this.data.noinvalidate)\n\n move.data = this.data\n\n return move\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { BaseOperation } from '../operations/base'\nimport { ReStruct } from '../../render'\n//\n// Undo/redo actions\n//\nexport class Action {\n operations: BaseOperation[]\n\n constructor(operations = []) {\n this.operations = operations\n }\n\n addOp(operation: BaseOperation, restruct?: ReStruct): BaseOperation {\n if (!restruct || !operation.isDummy(restruct)) {\n this.operations.push(operation)\n }\n\n return operation\n }\n\n mergeWith(action) {\n this.operations = this.operations.concat(action.operations)\n return this\n }\n\n // Perform action and return inverted one\n perform(restruct: ReStruct) {\n const action = new Action()\n const sortedOperations = [...this.operations].sort(\n (a, b) => a.priority - b.priority\n )\n sortedOperations.forEach(operation => {\n const invertedOperation = operation.perform(restruct)\n action.addOp(invertedOperation)\n })\n\n return action\n }\n\n isDummy(restruct?: ReStruct) {\n return (\n this.operations.find(\n // TODO [RB] the condition is always true for op.* operations\n operation => (restruct ? !operation.isDummy(restruct) : true)\n ) === undefined\n )\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Action } from './action'\nimport { Bond } from 'domain/entities'\nimport { BondAttr } from '../operations'\nimport { MolSerializer } from 'domain/serializers'\n\n/**\n * @param restruct { ReStruct }\n * @param events { Array }\n * @param bid { number }\n * @param template {{\n * \t\tmolecule: Struct,\n * \t\tbid: number\n * }}\n * @param simpleFusing { Function }\n * @returns { Promise }\n */\nexport function fromAromaticTemplateOnBond(\n restruct,\n template,\n bid,\n events,\n simpleFusing\n) {\n const tmpl = template.molecule\n const struct = restruct.molecule\n\n const frid = struct.getBondFragment(bid)\n const beforeMerge = getFragmentWithBondMap(struct, frid)\n let afterMerge: any = null\n let pasteItems: any = null\n\n let action = new Action()\n\n if (true) {\n action = simpleFusing(restruct, template, bid)\n return Promise.resolve(action)\n }\n\n const molSerialzer = new MolSerializer()\n\n return Promise.all([\n events.aromatizeStruct\n .dispatch(beforeMerge.frag)\n .then(res => molSerialzer.deserialize(res.struct)),\n events.aromatizeStruct\n .dispatch(tmpl)\n .then(res => molSerialzer.deserialize(res.struct))\n ])\n .then(([astruct, atmpl]) => {\n // aromatize restruct fragment\n const aromatizeAction = fromAromatize(\n restruct,\n astruct,\n beforeMerge.bondMap\n )\n // merge template with fragment\n const aromTemplate = { bid: template.bid, molecule: atmpl }\n const templateFusingAction = simpleFusing(restruct, aromTemplate, bid)\n pasteItems = templateFusingAction[1]\n\n action = templateFusingAction[0].mergeWith(aromatizeAction)\n\n afterMerge = getFragmentWithBondMap(restruct.molecule, frid)\n\n return events.dearomatizeStruct\n .dispatch(afterMerge.frag)\n .then(res => molSerialzer.deserialize(res.struct))\n })\n .then(destruct => {\n destruct.bonds.forEach(bond => {\n if (bond.type === Bond.PATTERN.TYPE.AROMATIC)\n throw Error('Bad dearomatize')\n })\n\n // dearomatize restruct fragment\n const dearomatizeAction = fromDearomatize(\n restruct,\n destruct,\n afterMerge.bondMap\n )\n action = dearomatizeAction.mergeWith(action)\n\n return [action, pasteItems]\n })\n .catch(err => {\n console.info(err.message)\n action.perform(restruct) // revert actions if error\n\n return simpleFusing(restruct, template, bid)\n })\n}\n\nfunction fromAromatize(restruct, astruct, bondMap) {\n const action = new Action()\n\n astruct.bonds.forEach((bond, bid) => {\n if (bond.type !== Bond.PATTERN.TYPE.AROMATIC) return\n action.addOp(\n new BondAttr(\n bondMap.get(bid),\n 'type',\n Bond.PATTERN.TYPE.AROMATIC\n ).perform(restruct)\n )\n })\n\n return action\n}\n\n/**\n * @param restruct { ReStruct }\n * @param dastruct { ReStruct }\n * @param bondMap { Map }\n * @returns { Action }\n */\nfunction fromDearomatize(restruct, dastruct, bondMap) {\n const action = new Action()\n\n dastruct.bonds.forEach((bond, bid) => {\n action.addOp(\n new BondAttr(bondMap.get(bid), 'type', bond.type).perform(restruct)\n )\n })\n\n return action\n}\n\n/* UTILS */\n\n// @ts-ignore\nfunction canBeAromatized(struct) {\n // TODO correct this checking && move to chem.Struct ??\n if (struct.loops.size === 0) struct.prepareLoopStructure()\n\n const hasAromLoop = struct.loops.find((_id, loop) => loop.aromatic)\n if (struct.loops.size === 0 || hasAromLoop) return false\n\n const correctDblBonds = struct.loops.find(\n (_id, loop) => loop.dblBonds === loop.hbs.length / 2\n )\n\n return correctDblBonds !== undefined\n}\n\n/**\n * @param struct { Struct }\n * @param frid { number }\n * @returns {{\n * \t\tfrag: Struct,\n * \t\tbondMap: Map\n * }}\n */\nfunction getFragmentWithBondMap(struct, frid) {\n const atomSet = struct.getFragmentIds(frid)\n const atomsInStruct = Array.from(atomSet)\n\n const frag = struct.clone(atomSet)\n const bondMap = new Map()\n frag.bonds.forEach((bond, bid) => {\n bondMap.set(\n bid,\n struct.findBondId(atomsInStruct[bond.begin], atomsInStruct[bond.end])\n )\n })\n\n return { frag, bondMap }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Fragment, Vec2 } from 'domain/entities'\n\nconst SELECTION_DISTANCE_COEFFICIENT = 0.4\nconst SELECTION_WITHIN_TEXT = 0\n\nconst findMaps = {\n atoms: findClosestAtom,\n bonds: findClosestBond,\n enhancedFlags: findClosestEnhancedFlag,\n sgroupData: findClosestDataSGroupData,\n sgroups: findClosestSGroup,\n rxnArrows: findClosestRxnArrow,\n rxnPluses: findClosestRxnPlus,\n frags: findClosestFrag,\n rgroups: findClosestRGroup,\n simpleObjects: findClosestSimpleObject,\n texts: findClosestText\n}\n\nfunction findClosestText(restruct, cursorPosition) {\n let minDist = null\n let ret = null\n\n restruct.texts.forEach((text, id) => {\n const referencePoints = text.getReferencePoints(restruct)\n const topX = referencePoints[0].x\n const topY = referencePoints[0].y\n const bottomX = referencePoints[2].x\n const bottomY = referencePoints[2].y\n\n const distances = []\n\n if (cursorPosition.x >= topX && cursorPosition.x <= bottomX) {\n if (cursorPosition.y < topY) {\n distances.push(topY - cursorPosition.y)\n } else if (cursorPosition.y > bottomY) {\n distances.push(cursorPosition.y - bottomY)\n } else {\n distances.push(cursorPosition.y - topY, bottomY - cursorPosition.y)\n }\n }\n\n if (cursorPosition.x < topX && cursorPosition.y < topY) {\n distances.push(Vec2.dist(new Vec2(topX, topY), cursorPosition))\n }\n\n if (cursorPosition.x > bottomX && cursorPosition.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(bottomX, bottomY), cursorPosition))\n }\n\n if (cursorPosition.x < topX && cursorPosition.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(topX, bottomY), cursorPosition))\n }\n\n if (cursorPosition.x > bottomX && cursorPosition.y < topY) {\n distances.push(Vec2.dist(new Vec2(bottomX, topY), cursorPosition))\n }\n\n if (cursorPosition.y >= topY && cursorPosition.y <= bottomY) {\n if (cursorPosition.x < topX) {\n distances.push(topX - cursorPosition.x)\n } else if (cursorPosition.x > bottomX) {\n distances.push(cursorPosition.x - bottomX)\n } else {\n distances.push(SELECTION_WITHIN_TEXT)\n }\n }\n\n let dist = Math.min(...distances)\n\n if (dist < SELECTION_DISTANCE_COEFFICIENT && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n return ret\n}\n\nfunction findClosestSimpleObject(restruct, pos) {\n let minDist = null\n let refPoint = null\n let ret = null\n\n restruct.simpleObjects.forEach((simpleObject, id) => {\n const dist = simpleObject.calcDistance(pos, restruct.render.options.scale)\n\n if (dist.minDist < 0.3 && (!ret || dist.minDist < minDist)) {\n minDist = dist.minDist\n refPoint = dist.refPoint\n\n ret = { id, dist: minDist, ref: refPoint }\n }\n })\n return ret\n}\n\nfunction findClosestAtom(restruct, pos, skip, minDist) {\n let closestAtom = null\n const maxMinDist = SELECTION_DISTANCE_COEFFICIENT\n const skipId = skip && skip.map === 'atoms' ? skip.id : null\n\n minDist = minDist || maxMinDist\n minDist = Math.min(minDist, maxMinDist)\n\n restruct.atoms.forEach((atom, aid) => {\n if (aid === skipId) return\n\n const dist = Vec2.dist(pos, atom.a.pp)\n\n if (dist < minDist) {\n closestAtom = aid\n minDist = dist\n }\n })\n\n if (closestAtom !== null) {\n return {\n id: closestAtom,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestBond(restruct, pos, skip, minDist, scale) {\n // eslint-disable-line max-params\n let closestBond = null\n let closestBondCenter = null\n const maxMinDist = 0.8 * SELECTION_DISTANCE_COEFFICIENT\n const skipId = skip && skip.map === 'bonds' ? skip.id : null\n\n minDist = minDist || maxMinDist\n minDist = Math.min(minDist, maxMinDist)\n\n let minCDist = minDist\n\n restruct.bonds.forEach((bond, bid) => {\n if (bid === skipId) return\n\n const p1 = restruct.atoms.get(bond.b.begin).a.pp\n const p2 = restruct.atoms.get(bond.b.end).a.pp\n\n const mid = Vec2.lc2(p1, 0.5, p2, 0.5)\n const cdist = Vec2.dist(pos, mid)\n\n if (cdist < minCDist) {\n minCDist = cdist\n closestBondCenter = bid\n }\n })\n\n restruct.bonds.forEach((bond, bid) => {\n if (bid === skipId) return\n\n const hb = restruct.molecule.halfBonds.get(bond.b.hb1)\n const dir = hb.dir\n const norm = hb.norm\n\n const p1 = restruct.atoms.get(bond.b.begin).a.pp\n const p2 = restruct.atoms.get(bond.b.end).a.pp\n\n const inStripe = Vec2.dot(pos.sub(p1), dir) * Vec2.dot(pos.sub(p2), dir) < 0\n\n if (inStripe) {\n const dist = Math.abs(Vec2.dot(pos.sub(p1), norm))\n\n if (dist < minDist) {\n closestBond = bid\n minDist = dist\n }\n }\n })\n\n if (closestBondCenter !== null) {\n return {\n id: closestBondCenter,\n dist: minCDist\n }\n }\n\n if (\n closestBond !== null &&\n minDist > SELECTION_DISTANCE_COEFFICIENT * scale\n ) {\n return {\n id: closestBond,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestEnhancedFlag(restruct, pos) {\n let minDist\n let ret = null\n restruct.enhancedFlags.forEach((item, id) => {\n const fragment = restruct.molecule.frags.get(id)\n if (!fragment) return\n\n const p = fragment.stereoFlagPosition\n ? new Vec2(fragment.stereoFlagPosition.x, fragment.stereoFlagPosition.y)\n : Fragment.getDefaultStereoFlagPosition(restruct.molecule, id)\n if (!p || Math.abs(pos.x - p.x) >= 1.0) return\n\n const dist = Math.abs(pos.y - p.y)\n\n if (dist < 0.3 && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n return ret\n}\n\nfunction findClosestDataSGroupData(restruct, pos) {\n let minDist = null\n let ret = null\n\n restruct.sgroupData.forEach((item, id) => {\n if (item.sgroup.type !== 'DAT') throw new Error('Data group expected')\n\n if (item.sgroup.data.fieldName !== 'MRV_IMPLICIT_H') {\n const box = item.sgroup.dataArea\n const inBox =\n box.p0.y < pos.y &&\n box.p1.y > pos.y &&\n box.p0.x < pos.x &&\n box.p1.x > pos.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pos.x),\n Math.abs(box.p1.x - pos.x)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = { id, dist: xDist }\n minDist = xDist\n }\n }\n })\n\n return ret\n}\n\nfunction findClosestFrag(restruct, pos, skip, minDist, scale) {\n minDist = Math.min(\n minDist || SELECTION_DISTANCE_COEFFICIENT,\n SELECTION_DISTANCE_COEFFICIENT\n )\n\n const struct = restruct.molecule\n\n const closestAtom = findClosestAtom(restruct, pos, skip, minDist)\n\n if (closestAtom) {\n return {\n id: struct.atoms.get(closestAtom.id).fragment,\n dist: closestAtom.dist\n }\n }\n\n const closestBond = findClosestBond(restruct, pos, skip, minDist, scale)\n\n if (closestBond) {\n const atomId = struct.bonds.get(closestBond.id).begin\n return {\n id: struct.atoms.get(atomId).fragment,\n dist: closestBond.dist\n }\n }\n\n return null\n}\n\nfunction findClosestRGroup(restruct, pos, skip, minDist) {\n minDist = Math.min(\n minDist || SELECTION_DISTANCE_COEFFICIENT,\n SELECTION_DISTANCE_COEFFICIENT\n )\n\n let ret = null\n\n restruct.rgroups.forEach((rgroup, rgid) => {\n if (\n rgid !== skip &&\n rgroup.labelBox &&\n rgroup.labelBox.contains(pos, 0.5)\n ) {\n const dist = Vec2.dist(rgroup.labelBox.centre(), pos)\n\n if (!ret || dist < minDist) {\n minDist = dist\n ret = { id: rgid, dist: minDist }\n }\n }\n })\n\n return ret\n}\n\nfunction findClosestRxnArrow(restruct, pos) {\n let minDist = null\n let refPoint = null\n let ret = null\n\n restruct.rxnArrows.forEach((rxnArrow, id) => {\n const dist = rxnArrow.calcDistance(pos, restruct.render.options.scale)\n\n if (dist.minDist < 0.3 && (!ret || dist.minDist < minDist)) {\n minDist = dist.minDist\n refPoint = dist.refPoint\n\n ret = { id, dist: minDist, ref: refPoint }\n }\n })\n return ret\n}\n\nfunction findClosestRxnPlus(restruct, pos) {\n let minDist = null\n let ret = null\n\n restruct.rxnPluses.forEach((plus, id) => {\n const p = plus.item.pp\n const dist = Math.max(Math.abs(pos.x - p.x), Math.abs(pos.y - p.y))\n\n if (dist < 0.3 && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n\n return ret\n}\n\nfunction findClosestSGroup(restruct, pos) {\n let ret = null\n let minDist = SELECTION_DISTANCE_COEFFICIENT\n\n restruct.molecule.sgroups.forEach((sg, sgid) => {\n if (sg.functionalGroup && !sg.expanded) {\n const firstAtomPp = sg.firstSgroupAtom.pp\n const d = sg.bracketDir\n const n = d.rotateSC(1, 0)\n const pg = new Vec2(Vec2.dot(pos, d), Vec2.dot(pos, n))\n const shift = new Vec2(0.625, 0.625)\n const box = {\n p0: Vec2.diff(firstAtomPp, shift),\n p1: Vec2.sum(firstAtomPp, shift)\n }\n\n const inBox =\n box.p0.y < pg.y && box.p1.y > pg.y && box.p0.x < pg.x && box.p1.x > pg.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pg.x),\n Math.abs(box.p1.x - pg.x)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = sgid\n minDist = xDist\n }\n } else {\n const d = sg.bracketDir\n const n = d.rotateSC(1, 0)\n const pg = new Vec2(Vec2.dot(pos, d), Vec2.dot(pos, n))\n\n sg.areas.forEach(box => {\n const inBox =\n box.p0.y < pg.y &&\n box.p1.y > pg.y &&\n box.p0.x < pg.x &&\n box.p1.x > pg.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pg.x),\n Math.abs(box.p1.x - pg.x)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = sgid\n minDist = xDist\n }\n })\n }\n })\n\n if (ret !== null) {\n return {\n id: ret,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestItem(restruct, pos, maps, skip, scale) {\n // eslint-disable-line max-params\n maps = maps || Object.keys(findMaps)\n\n return maps.reduce((res, mp) => {\n const minDist = res ? res.dist : null\n const item = findMaps[mp](restruct, pos, skip, minDist, scale)\n\n if (item !== null && (res === null || item.dist < res.dist)) {\n const { id, dist, ...other } = item\n return {\n map: mp,\n id: id,\n dist: dist,\n ...other\n }\n }\n\n return res\n }, null)\n}\n\n/**\n * @param restruct { ReStruct }\n * @param selected { object }\n * @param maps { Array }\n * @param scale { number }\n * @return {{\n * \t\tatoms: Map?\n * \t\tbonds: Map?\n * }}\n */\nfunction findCloseMerge(restruct, selected, maps = ['atoms', 'bonds'], scale) {\n const pos = {\n atoms: new Map(), // aid -> position\n bonds: new Map() // bid -> position\n }\n\n const struct = restruct.molecule\n\n selected.atoms.forEach(aid => {\n pos.atoms.set(aid, struct.atoms.get(aid).pp)\n })\n\n selected.bonds.forEach(bid => {\n const bond = struct.bonds.get(bid)\n pos.bonds.set(\n bid,\n Vec2.lc2(\n struct.atoms.get(bond.begin).pp,\n 0.5,\n struct.atoms.get(bond.end).pp,\n 0.5\n )\n )\n })\n\n const result = {}\n maps.forEach(mp => {\n result[mp] = Array.from(pos[mp].keys()).reduce((res, srcId) => {\n const skip = { map: mp, id: srcId }\n const item = findMaps[mp](restruct, pos[mp].get(srcId), skip, null, scale)\n\n if (item && !selected[mp].includes(item.id)) res.set(srcId, item.id)\n\n return res\n }, new Map())\n })\n\n return result\n}\n\nexport default {\n atom: findClosestAtom, // used in Actions\n item: findClosestItem,\n merge: findCloseMerge\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Bond, Vec2 } from 'domain/entities'\n\nimport closest from '../shared/closest'\nimport { difference } from 'lodash'\n\nexport function atomGetAttr(restruct, aid, name) {\n return restruct.molecule.atoms.get(aid)[name]\n}\n\nexport function atomGetDegree(restruct, aid) {\n return restruct.atoms.get(aid).a.neighbors.length\n}\n\nexport function atomGetSGroups(restruct, aid) {\n return Array.from(restruct.atoms.get(aid).a.sgs)\n}\n\nexport function atomGetPos(restruct, id) {\n return restruct.molecule.atoms.get(id).pp\n}\n\nexport function findStereoAtoms(struct, aids) {\n return aids.filter(aid => struct.atoms.get(aid).stereoLabel !== null)\n}\n\nexport function structSelection(struct) {\n return [\n 'atoms',\n 'bonds',\n 'frags',\n 'sgroups',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'simpleObjects',\n 'texts'\n ].reduce((res, key) => {\n res[key] = Array.from(struct[key].keys())\n return res\n }, {})\n}\n\n// Get new atom id/label and pos for bond being added to existing atom\nexport function atomForNewBond(restruct, id, bond?) {\n // eslint-disable-line max-statements\n const neighbours: Array = []\n const pos = atomGetPos(restruct, id)\n const prevBondId = restruct.molecule.findBondId(\n id,\n restruct.molecule.atomGetNeighbors(id)[0].aid\n )\n const prevBondType = restruct.molecule.bonds.get(prevBondId).type\n\n restruct.molecule.atomGetNeighbors(id).forEach(nei => {\n const neiPos = atomGetPos(restruct, nei.aid)\n\n if (Vec2.dist(pos, neiPos) < 0.1) return\n\n neighbours.push({ id: nei.aid, v: Vec2.diff(neiPos, pos) })\n })\n\n neighbours.sort(\n (nei1, nei2) =>\n Math.atan2(nei1.v.y, nei1.v.x) - Math.atan2(nei2.v.y, nei2.v.x)\n )\n\n var i\n var maxI = 0\n var angle\n var maxAngle = 0\n\n // TODO: impove layout: tree, ...\n\n for (i = 0; i < neighbours.length; i++) {\n angle = Vec2.angle(\n neighbours[i].v,\n neighbours[(i + 1) % neighbours.length].v\n )\n\n if (angle < 0) angle += 2 * Math.PI\n\n if (angle > maxAngle) {\n maxI = i\n maxAngle = angle\n }\n }\n\n let v = new Vec2(1, 0)\n\n if (neighbours.length > 0) {\n if (neighbours.length === 1) {\n maxAngle = -((4 * Math.PI) / 3)\n\n // zig-zag\n const nei = restruct.molecule.atomGetNeighbors(id)[0]\n if (atomGetDegree(restruct, nei.aid) > 1) {\n const neiNeighbours: Array = []\n const neiPos = atomGetPos(restruct, nei.aid)\n const neiV = Vec2.diff(pos, neiPos)\n const neiAngle = Math.atan2(neiV.y, neiV.x)\n\n restruct.molecule.atomGetNeighbors(nei.aid).forEach(neiNei => {\n const neiNeiPos = atomGetPos(restruct, neiNei.aid)\n\n if (neiNei.bid === nei.bid || Vec2.dist(neiPos, neiNeiPos) < 0.1)\n return\n\n const vDiff = Vec2.diff(neiNeiPos, neiPos)\n let ang = Math.atan2(vDiff.y, vDiff.x) - neiAngle\n\n if (ang < 0) ang += 2 * Math.PI\n\n neiNeighbours.push(ang)\n })\n neiNeighbours.sort((nei1, nei2) => nei1 - nei2)\n\n if (\n neiNeighbours[0] <= Math.PI * 1.01 &&\n neiNeighbours[neiNeighbours.length - 1] <= 1.01 * Math.PI\n )\n maxAngle *= -1\n }\n }\n\n const shallBe180DegToPrevBond =\n (neighbours.length === 1 &&\n prevBondType === bond?.type &&\n (bond?.type === Bond.PATTERN.TYPE.DOUBLE ||\n bond?.type === Bond.PATTERN.TYPE.TRIPLE)) ||\n (prevBondType === Bond.PATTERN.TYPE.SINGLE &&\n bond?.type === Bond.PATTERN.TYPE.TRIPLE) ||\n (prevBondType === Bond.PATTERN.TYPE.TRIPLE &&\n bond?.type === Bond.PATTERN.TYPE.SINGLE)\n\n if (shallBe180DegToPrevBond) {\n const prevBondAngle = restruct.molecule.bonds.get(prevBondId).angle\n if (prevBondAngle > -90 && prevBondAngle < 90 && neighbours[0].v.x > 0) {\n angle = (prevBondAngle * Math.PI) / 180 + Math.PI\n } else {\n angle = (prevBondAngle * Math.PI) / 180\n }\n } else {\n angle =\n maxAngle / 2 + Math.atan2(neighbours[maxI].v.y, neighbours[maxI].v.x)\n }\n\n v = v.rotate(angle)\n }\n\n v.add_(pos) // eslint-disable-line no-underscore-dangle\n\n let a: any = closest.atom(restruct, v, null, 0.1)\n a = a === null ? { label: 'C' } : a.id\n\n return { atom: a, pos: v }\n}\n\nexport function getRelSgroupsBySelection(restruct, selectedAtoms) {\n return restruct.molecule.sgroups.filter(\n (_sgid, sg) =>\n !sg.data.attached &&\n !sg.data.absolute &&\n difference(sg.atoms, selectedAtoms).length === 0\n )\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RGroupAttr, RGroupFragment, UpdateIfThen } from '../operations'\n\nimport { Action } from './action'\n\nexport function fromRGroupAttrs(restruct, id, attrs) {\n const action = new Action()\n\n Object.keys(attrs).forEach(key => {\n action.addOp(new RGroupAttr(id, key, attrs[key]))\n })\n\n return action.perform(restruct)\n}\n\nexport function fromRGroupFragment(restruct, rgidNew, frid) {\n const action = new Action()\n action.addOp(new RGroupFragment(rgidNew, frid))\n\n return action.perform(restruct)\n}\n\nexport function fromUpdateIfThen(\n restruct,\n rgidNew,\n rgidOld,\n skipRgids: Array = []\n) {\n const action = new Action()\n if (!restruct.molecule.rgroups.get(rgidOld))\n action.addOp(new UpdateIfThen(rgidNew, rgidOld, skipRgids))\n\n return action.perform(restruct)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AtomAttr,\n SGroupAddToHierarchy,\n SGroupAtomAdd,\n SGroupAtomRemove,\n SGroupAttr,\n SGroupCreate,\n SGroupDelete,\n SGroupRemoveFromHierarchy\n} from '../operations'\nimport { Pile, SGroup } from 'domain/entities'\nimport { atomGetAttr, atomGetDegree, atomGetSGroups } from './utils'\n\nimport { Action } from './action'\nimport { SgContexts } from '..'\nimport { uniq } from 'lodash/fp'\nimport { fromAtomsAttrs } from './atom'\n\nexport function fromSeveralSgroupAddition(restruct, type, atoms, attrs) {\n const descriptors = attrs.fieldValue\n\n if (typeof descriptors === 'string' || type !== 'DAT')\n return fromSgroupAddition(\n restruct,\n type,\n atoms,\n attrs,\n restruct.molecule.sgroups.newId()\n )\n\n return descriptors.reduce((acc, fValue) => {\n const localAttrs = Object.assign({}, attrs)\n localAttrs.fieldValue = fValue\n\n return acc.mergeWith(\n fromSgroupAddition(\n restruct,\n type,\n atoms,\n localAttrs,\n restruct.molecule.sgroups.newId()\n )\n )\n }, new Action())\n}\n\nexport function fromSgroupAttrs(restruct, id, attrs) {\n const action = new Action()\n\n Object.keys(attrs).forEach(key => {\n action.addOp(new SGroupAttr(id, key, attrs[key]))\n })\n\n return action.perform(restruct)\n}\n\nexport function setExpandSGroup(restruct, sgid, attrs) {\n const action = new Action()\n\n Object.keys(attrs).forEach(key => {\n action.addOp(new SGroupAttr(sgid, key, attrs[key]))\n })\n\n const sgroup = restruct.molecule.sgroups.get(sgid)\n if (sgroup.firstSgroupAtom) delete sgroup.firstSgroupAtom\n const atoms = SGroup.getAtoms(restruct, sgroup)\n\n atoms.forEach(aid => {\n action.mergeWith(\n fromAtomsAttrs(restruct, aid, restruct.atoms.get(aid).a, false)\n )\n })\n\n return action.perform(restruct)\n}\n\nexport function sGroupAttributeAction(id, attrs) {\n const action = new Action()\n\n Object.keys(attrs).forEach(key => {\n action.addOp(new SGroupAttr(id, key, attrs[key]))\n })\n\n return action\n}\n\nexport function fromSgroupDeletion(restruct, id) {\n let action = new Action()\n const struct = restruct.molecule\n\n const sG = restruct.sgroups.get(id).item\n\n if (sG.type === 'SRU') {\n struct.sGroupsRecalcCrossBonds()\n\n sG.neiAtoms.forEach(aid => {\n if (atomGetAttr(restruct, aid, 'label') === '*')\n action.addOp(new AtomAttr(aid, 'label', 'C'))\n })\n }\n\n const sg = struct.sgroups.get(id)\n const atoms = SGroup.getAtoms(struct, sg)\n const attrs = sg.getAttrs()\n\n action.addOp(new SGroupRemoveFromHierarchy(id))\n\n atoms.forEach(atom => {\n action.addOp(new SGroupAtomRemove(id, atom))\n })\n\n action.addOp(new SGroupDelete(id))\n\n action = action.perform(restruct)\n\n action.mergeWith(sGroupAttributeAction(id, attrs))\n\n return action\n}\n\nexport function fromSgroupAddition(\n restruct,\n type,\n atoms,\n attrs,\n sgid,\n pp?,\n expanded?,\n name?\n) {\n // eslint-disable-line\n let action = new Action()\n\n // TODO: shoud the id be generated when OpSGroupCreate is executed?\n // if yes, how to pass it to the following operations?\n sgid = sgid - 0 === sgid ? sgid : restruct.molecule.sgroups.newId()\n\n if (type === 'SUP') {\n action.addOp(new SGroupCreate(sgid, type, pp, expanded, name))\n } else {\n action.addOp(new SGroupCreate(sgid, type, pp))\n }\n\n atoms.forEach(atom => {\n action.addOp(new SGroupAtomAdd(sgid, atom))\n })\n\n action.addOp(\n type !== 'DAT'\n ? new SGroupAddToHierarchy(sgid)\n : new SGroupAddToHierarchy(sgid, -1, [])\n )\n\n action = action.perform(restruct)\n\n if (type === 'SRU') {\n restruct.molecule.sGroupsRecalcCrossBonds()\n let asteriskAction = new Action()\n\n restruct.sgroups.get(sgid).item.neiAtoms.forEach(aid => {\n const plainCarbon = restruct.atoms.get(aid).a.isPlainCarbon()\n\n if (atomGetDegree(restruct, aid) === 1 && plainCarbon)\n asteriskAction.addOp(new AtomAttr(aid, 'label', '*'))\n })\n\n asteriskAction = asteriskAction.perform(restruct)\n asteriskAction.mergeWith(action)\n action = asteriskAction\n }\n\n return fromSgroupAttrs(restruct, sgid, attrs).mergeWith(action)\n}\n\nexport function fromSgroupAction(\n context,\n restruct,\n newSg,\n sourceAtoms,\n selection\n) {\n if (context === SgContexts.Bond)\n return fromBondAction(restruct, newSg, sourceAtoms, selection)\n\n const atomsFromBonds = getAtomsFromBonds(restruct.molecule, selection.bonds)\n const newSourceAtoms = uniq(sourceAtoms.concat(atomsFromBonds))\n\n if (context === SgContexts.Fragment)\n return fromGroupAction(\n restruct,\n newSg,\n newSourceAtoms,\n Array.from(restruct.atoms.keys())\n )\n\n if (context === SgContexts.Multifragment)\n return fromMultiFragmentAction(restruct, newSg, newSourceAtoms)\n\n if (context === SgContexts.Group)\n return fromGroupAction(restruct, newSg, newSourceAtoms, newSourceAtoms)\n\n if (context === SgContexts.Atom)\n return fromAtomAction(restruct, newSg, newSourceAtoms)\n\n return {\n action: fromSeveralSgroupAddition(\n restruct,\n newSg.type,\n sourceAtoms,\n newSg.attrs\n )\n }\n}\n\nfunction fromAtomAction(restruct, newSg, sourceAtoms) {\n return sourceAtoms.reduce(\n (acc, atom) => {\n acc.action = acc.action.mergeWith(\n fromSeveralSgroupAddition(restruct, newSg.type, [atom], newSg.attrs)\n )\n return acc\n },\n {\n action: new Action(),\n selection: {\n atoms: sourceAtoms,\n bonds: []\n }\n }\n )\n}\n\nfunction fromGroupAction(restruct, newSg, sourceAtoms, targetAtoms) {\n const allFragments = new Pile(\n sourceAtoms.map(aid => restruct.atoms.get(aid).a.fragment)\n )\n\n return Array.from(allFragments).reduce(\n (acc, fragId) => {\n const atoms = targetAtoms.reduce((res, aid) => {\n const atom = restruct.atoms.get(aid).a\n if (fragId === atom.fragment) res.push(aid)\n\n return res\n }, [])\n\n const bonds = getAtomsBondIds(restruct.molecule, atoms)\n\n acc.action = acc.action.mergeWith(\n fromSeveralSgroupAddition(restruct, newSg.type, atoms, newSg.attrs)\n )\n\n acc.selection.atoms = acc.selection.atoms.concat(atoms)\n acc.selection.bonds = acc.selection.bonds.concat(bonds)\n\n return acc\n },\n {\n action: new Action(),\n selection: {\n atoms: [],\n bonds: []\n }\n }\n )\n}\n\nfunction fromBondAction(restruct, newSg, sourceAtoms, currSelection) {\n const struct = restruct.molecule\n let bonds = getAtomsBondIds(struct, sourceAtoms)\n\n if (currSelection.bonds) bonds = uniq(bonds.concat(currSelection.bonds))\n\n return bonds.reduce(\n (acc: any, bondid) => {\n const bond = struct.bonds.get(bondid)\n\n acc.action = acc.action.mergeWith(\n fromSeveralSgroupAddition(\n restruct,\n newSg.type,\n [bond.begin, bond.end],\n newSg.attrs\n )\n )\n\n acc.selection.bonds.push(bondid)\n\n return acc\n },\n {\n action: new Action(),\n selection: {\n atoms: sourceAtoms,\n bonds: []\n }\n }\n )\n}\n\nfunction fromMultiFragmentAction(restruct, newSg, atoms) {\n const bonds = getAtomsBondIds(restruct.molecule, atoms)\n return {\n action: fromSeveralSgroupAddition(restruct, newSg.type, atoms, newSg.attrs),\n selection: {\n atoms,\n bonds\n }\n }\n}\n\n// Add action operation to remove atom from s-group if needed\nexport function removeAtomFromSgroupIfNeeded(action, restruct, id) {\n const sgroups = atomGetSGroups(restruct, id)\n\n if (sgroups.length > 0) {\n sgroups.forEach(sid => {\n action.addOp(new SGroupAtomRemove(sid, id))\n })\n\n return true\n }\n\n return false\n}\n\n// Add action operations to remove whole s-group if needed\nexport function removeSgroupIfNeeded(action, restruct, atoms) {\n const struct = restruct.molecule\n const sgCounts = new Map()\n\n atoms.forEach(id => {\n const sgroups = atomGetSGroups(restruct, id)\n\n sgroups.forEach(sid => {\n sgCounts.set(sid, sgCounts.has(sid) ? sgCounts.get(sid) + 1 : 1)\n })\n })\n\n sgCounts.forEach((count, sid) => {\n const sG = restruct.sgroups.get(sid).item\n const sgAtoms = SGroup.getAtoms(restruct.molecule, sG)\n\n if (sgAtoms.length === count) {\n // delete whole s-group\n const sgroup = struct.sgroups.get(sid)\n action.mergeWith(sGroupAttributeAction(sid, sgroup.getAttrs()))\n action.addOp(new SGroupRemoveFromHierarchy(sid))\n action.addOp(new SGroupDelete(sid))\n }\n })\n}\n\nfunction getAtomsBondIds(struct, atoms) {\n const atomSet = new Pile(atoms)\n\n return Array.from(struct.bonds.keys()).filter(bid => {\n const bond = struct.bonds.get(bid)\n return atomSet.has(bond.begin) && atomSet.has(bond.end)\n })\n}\n\nfunction getAtomsFromBonds(struct, bonds) {\n bonds = bonds || []\n return bonds.reduce((acc, bondid) => {\n const bond = struct.bonds.get(bondid)\n acc = acc.concat([bond.begin, bond.end])\n return acc\n }, [])\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Atom,\n Bond,\n Neighbor,\n StereoLabel,\n Struct,\n Vec2\n} from 'domain/entities'\nimport {\n AtomAdd,\n AtomAttr,\n BondAdd,\n BondAttr,\n BondDelete,\n CalcImplicitH,\n FragmentAdd,\n FragmentStereoFlag\n} from '../operations'\nimport { atomForNewBond, atomGetAttr } from './utils'\nimport {\n fromAtomMerge,\n fromStereoAtomAttrs,\n mergeFragmentsIfNeeded,\n mergeSgroups\n} from './atom'\n\nimport { Action } from './action'\nimport { ReStruct } from '../../render'\nimport { StereoValidator } from 'domain/helpers'\nimport utils from '../shared/utils'\n\nexport function fromBondAddition(\n restruct: ReStruct,\n bond: any,\n begin: any,\n end: any,\n pos?: Vec2,\n pos2?: Vec2\n): [Action, number, number, number] {\n // eslint-disable-line\n if (end === undefined) {\n const atom = atomForNewBond(restruct, begin, bond)\n end = atom.atom\n pos = atom.pos\n }\n const action = new Action()\n const struct = restruct.molecule\n let mergeFragments = false\n\n let frid = null\n\n if (!(typeof begin === 'number')) {\n if (typeof end === 'number') frid = atomGetAttr(restruct, end, 'fragment')\n } else {\n frid = atomGetAttr(restruct, begin, 'fragment')\n if (typeof end === 'number') mergeFragments = true\n }\n\n if (frid == null)\n frid = (action.addOp(new FragmentAdd().perform(restruct)) as FragmentAdd)\n .frid\n\n if (!(typeof begin === 'number')) {\n begin.fragment = frid\n begin = (action.addOp(new AtomAdd(begin, pos).perform(restruct)) as AtomAdd)\n .data.aid\n if (typeof end === 'number') mergeSgroups(action, restruct, [begin], end)\n pos = pos2\n } else if (atomGetAttr(restruct, begin, 'label') === '*') {\n action.addOp(new AtomAttr(begin, 'label', 'C').perform(restruct))\n }\n\n if (!(typeof end === 'number')) {\n end.fragment = frid\n // TODO: .data.aid here is a hack, need a better way to access the id of a created atom\n end = (action.addOp(new AtomAdd(end, pos).perform(restruct)) as AtomAdd)\n .data.aid\n if (typeof begin === 'number') mergeSgroups(action, restruct, [end], begin)\n } else if (atomGetAttr(restruct, end, 'label') === '*') {\n action.addOp(new AtomAttr(end, 'label', 'C').perform(restruct))\n }\n\n const bid = (\n action.addOp(new BondAdd(begin, end, bond).perform(restruct)) as BondAdd\n ).data.bid\n\n const bnd = struct.bonds.get(bid)\n\n if (bnd) {\n action.addOp(new CalcImplicitH([bnd.begin, bnd.end]).perform(restruct))\n action.mergeWith(fromBondStereoUpdate(restruct, bnd))\n }\n\n action.operations.reverse()\n\n if (mergeFragments) mergeFragmentsIfNeeded(action, restruct, begin, end)\n\n if (struct.frags.get(frid || 0)?.stereoAtoms && !bond.stereo) {\n action.addOp(new FragmentStereoFlag(frid || 0).perform(restruct))\n }\n\n return [action, begin, end, bid]\n}\n\nexport function fromBondsAttrs(\n restruct: ReStruct,\n ids: Array | number,\n attrs: Bond,\n reset?: boolean\n): Action {\n const struct = restruct.molecule\n const action = new Action()\n const bids = Array.isArray(ids) ? ids : [ids]\n\n bids.forEach(bid => {\n Object.keys(Bond.attrlist).forEach(key => {\n if (!(key in attrs) && !reset) return\n\n const value = key in attrs ? attrs[key] : Bond.attrGetDefault(key)\n\n action.addOp(new BondAttr(bid, key, value).perform(restruct))\n if (key === 'stereo' && key in attrs) {\n const bond = struct.bonds.get(bid)\n if (bond) {\n action.addOp(\n new CalcImplicitH([bond.begin, bond.end]).perform(restruct)\n )\n action.mergeWith(fromBondStereoUpdate(restruct, bond))\n }\n }\n })\n })\n\n return action\n}\n\nexport function fromBondsMerge(\n restruct: ReStruct,\n mergeMap: Map\n): Action {\n const struct = restruct.molecule\n\n const atomPairs = new Map()\n let action = new Action()\n\n mergeMap.forEach((dstId, srcId) => {\n const bond = struct.bonds.get(srcId)\n const bondCI = struct.bonds.get(dstId)\n if (!bond || !bondCI) return\n const params = utils.mergeBondsParams(struct, bond, struct, bondCI)\n if (!params.merged) return\n atomPairs.set(bond.begin, !params.cross ? bondCI.begin : bondCI.end)\n atomPairs.set(bond.end, !params.cross ? bondCI.end : bondCI.begin)\n })\n\n atomPairs.forEach((dst, src) => {\n action = fromAtomMerge(restruct, src, dst).mergeWith(action)\n })\n\n return action\n}\n\nfunction fromBondFlipping(restruct: ReStruct, id: number): Action {\n const bond = restruct.molecule.bonds.get(id)\n\n const action = new Action()\n action.addOp(new BondDelete(id).perform(restruct))\n\n // TODO: find better way to avoid problem with bond.begin = 0\n if (Number.isInteger(bond?.end) && Number.isInteger(bond?.begin)) {\n action.addOp(new BondAdd(bond?.end, bond?.begin, bond).perform(restruct))\n }\n\n // todo: swap atoms stereoLabels and stereoAtoms in fragment\n\n return action\n}\n\nexport function fromBondStereoUpdate(\n restruct: ReStruct,\n bond: Bond,\n withReverse?: boolean\n): Action {\n const action = new Action()\n const struct = restruct.molecule\n\n const beginFrId = struct.atoms.get(bond?.begin)?.fragment\n const endFrId = struct.atoms.get(bond?.end)?.fragment\n\n const fragmentStereoBonds: Array = []\n\n struct.bonds.forEach(bond => {\n if (struct.atoms.get(bond.begin)?.fragment === beginFrId) {\n fragmentStereoBonds.push(bond)\n }\n\n if (\n beginFrId !== endFrId &&\n struct.atoms.get(bond.begin)?.fragment === endFrId\n ) {\n fragmentStereoBonds.push(bond)\n }\n })\n\n const stereoAtomsMap = getStereoAtomsMap(struct, fragmentStereoBonds, bond)\n\n stereoAtomsMap.forEach((stereoProp, aId) => {\n if (struct.atoms.get(aId)?.stereoLabel !== stereoProp.stereoLabel) {\n action.mergeWith(\n fromStereoAtomAttrs(restruct, aId, stereoProp, withReverse)\n )\n }\n })\n\n return action\n}\n\nexport function getStereoAtomsMap(\n struct: Struct,\n bonds: Array,\n bond?: Bond\n) {\n const stereoAtomsMap = new Map()\n const correctAtomIds: Array = []\n\n bonds.forEach((bond: Bond | undefined) => {\n if (bond) {\n const beginNeighs: Array | undefined = struct.atomGetNeighbors(\n bond.begin\n )\n const endNeighs: Array | undefined = struct.atomGetNeighbors(\n bond.end\n )\n\n if (\n StereoValidator.isCorrectStereoCenter(\n bond,\n beginNeighs,\n endNeighs,\n struct\n )\n ) {\n const stereoLabel = struct.atoms.get(bond.begin)?.stereoLabel\n if (\n stereoLabel == null ||\n stereoAtomsMap.get(bond.begin)?.stereoLabel == null\n ) {\n stereoAtomsMap.set(bond.begin, {\n stereoParity: getStereoParity(bond.stereo),\n stereoLabel: stereoLabel || `${StereoLabel.Abs}`\n })\n }\n correctAtomIds.push(bond.begin)\n } else {\n if (!correctAtomIds.includes(bond.begin)) {\n stereoAtomsMap.set(bond.begin, {\n stereoParity: Atom.PATTERN.STEREO_PARITY.NONE,\n stereoLabel: null\n })\n }\n if (!correctAtomIds.includes(bond.end)) {\n stereoAtomsMap.set(bond.end, {\n stereoParity: Atom.PATTERN.STEREO_PARITY.NONE,\n stereoLabel: null\n })\n }\n }\n }\n })\n\n // in case the stereo band is flipped, changed or removed\n // TODO the duplication of the code below should be fixed, mayby by function\n if (bond) {\n if (!correctAtomIds.includes(bond.begin)) {\n stereoAtomsMap.set(bond.begin, {\n stereoParity: Atom.PATTERN.STEREO_PARITY.NONE,\n stereoLabel: null\n })\n }\n if (!correctAtomIds.includes(bond.end)) {\n stereoAtomsMap.set(bond.end, {\n stereoParity: Atom.PATTERN.STEREO_PARITY.NONE,\n stereoLabel: null\n })\n }\n }\n\n return stereoAtomsMap\n}\n\nfunction getStereoParity(stereo: Number): number | null {\n let newAtomParity: number | null = null\n switch (stereo) {\n case Bond.PATTERN.STEREO.UP:\n newAtomParity = Atom.PATTERN.STEREO_PARITY.ODD\n break\n case Bond.PATTERN.STEREO.EITHER:\n newAtomParity = Atom.PATTERN.STEREO_PARITY.EITHER\n break\n case Bond.PATTERN.STEREO.DOWN:\n newAtomParity = Atom.PATTERN.STEREO_PARITY.EVEN\n break\n }\n return newAtomParity\n}\n\nexport function bondChangingAction(\n restruct: ReStruct,\n itemID: number,\n bond: Bond,\n bondProps: any\n): Action {\n const action = new Action()\n let newItemId = itemID\n if (\n ((bondProps.stereo !== Bond.PATTERN.STEREO.NONE && //\n bondProps.type === Bond.PATTERN.TYPE.SINGLE) ||\n bond.type === Bond.PATTERN.TYPE.DATIVE) &&\n bond.type === bondProps.type &&\n bond.stereo === bondProps.stereo\n ) {\n action.mergeWith(fromBondFlipping(restruct, itemID))\n newItemId = (action.operations[1] as BondAdd).data.bid\n }\n // if bondTool is stereo and equal to bond for change\n\n const loop = plainBondTypes.includes(bondProps.type) ? plainBondTypes : null\n if (\n bondProps.stereo === Bond.PATTERN.STEREO.NONE &&\n bondProps.type === Bond.PATTERN.TYPE.SINGLE &&\n bond.stereo === Bond.PATTERN.STEREO.NONE &&\n loop\n )\n // if `Single bond` tool is chosen and bond for change in `plainBondTypes`\n bondProps.type = loop[(loop.indexOf(bond.type) + 1) % loop.length]\n\n return fromBondsAttrs(restruct, newItemId, bondProps).mergeWith(action)\n}\n\nconst plainBondTypes = [\n Bond.PATTERN.TYPE.SINGLE,\n Bond.PATTERN.TYPE.DOUBLE,\n Bond.PATTERN.TYPE.TRIPLE\n]\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, Bond, RGroup } from 'domain/entities'\nimport {\n AtomAdd,\n AtomAttr,\n AtomDelete,\n BondAdd,\n BondAttr,\n BondDelete,\n CalcImplicitH,\n FragmentAdd,\n FragmentAddStereoAtom,\n FragmentDelete,\n FragmentDeleteStereoAtom,\n SGroupAtomAdd\n} from '../operations'\nimport { atomGetAttr, atomGetDegree, atomGetSGroups } from './utils'\nimport { fromRGroupFragment, fromUpdateIfThen } from './rgroup'\nimport { removeAtomFromSgroupIfNeeded, removeSgroupIfNeeded } from './sgroup'\n\nimport { Action } from './action'\nimport { fromBondStereoUpdate } from './bond'\nimport { without } from 'lodash/fp'\n\nexport function fromAtomAddition(restruct, pos, atom) {\n atom = Object.assign({}, atom)\n const action = new Action()\n atom.fragment = (\n action.addOp(new FragmentAdd().perform(restruct)) as FragmentAdd\n ).frid\n\n const aid = (\n action.addOp(new AtomAdd(atom, pos).perform(restruct)) as AtomAdd\n ).data.aid\n action.addOp(new CalcImplicitH([aid]).perform(restruct))\n\n return action\n}\n\n/**\n * @param restruct { ReStruct }\n * @param ids { Array|number }\n * @param attrs { object }\n * @param reset { boolean? }\n */\nexport function fromAtomsAttrs(restruct, ids, attrs, reset) {\n const action = new Action()\n const aids = Array.isArray(ids) ? ids : [ids]\n\n aids.forEach(aid => {\n Object.keys(Atom.attrlist).forEach(key => {\n if (key === 'attpnt' && !(key in attrs)) return\n if (!(key in attrs) && !reset) return\n\n const value = key in attrs ? attrs[key] : Atom.attrGetDefault(key)\n\n switch (key) {\n case 'stereoLabel':\n if (key in attrs && value)\n action.addOp(new AtomAttr(aid, key, value).perform(restruct))\n break\n case 'stereoParity':\n if (key in attrs && value)\n action.addOp(new AtomAttr(aid, key, value).perform(restruct))\n break\n default:\n action.addOp(new AtomAttr(aid, key, value).perform(restruct))\n break\n }\n })\n\n if (\n !reset &&\n 'label' in attrs &&\n attrs.label !== null &&\n attrs.label !== 'L#' &&\n !attrs['atomList']\n )\n action.addOp(new AtomAttr(aid, 'atomList', null).perform(restruct))\n\n action.addOp(new CalcImplicitH([aid]).perform(restruct))\n\n const atomNeighbors = restruct.molecule.atomGetNeighbors(aid)\n const bond = restruct.molecule.bonds.get(atomNeighbors[0]?.bid)\n if (bond) {\n action.mergeWith(fromBondStereoUpdate(restruct, bond))\n }\n })\n\n return action\n}\n\nexport function fromStereoAtomAttrs(restruct, aid, attrs, withReverse) {\n const action = new Action()\n const atom = restruct.molecule.atoms.get(aid)\n if (atom) {\n const frid = atom.fragment\n\n if ('stereoParity' in attrs)\n action.addOp(\n new AtomAttr(aid, 'stereoParity', attrs['stereoParity']).perform(\n restruct\n )\n )\n if ('stereoLabel' in attrs) {\n action.addOp(\n new AtomAttr(aid, 'stereoLabel', attrs['stereoLabel']).perform(restruct)\n )\n if (attrs['stereoLabel'] === null) {\n action.addOp(new FragmentDeleteStereoAtom(frid, aid).perform(restruct))\n } else {\n action.addOp(new FragmentAddStereoAtom(frid, aid).perform(restruct))\n }\n }\n if (withReverse) action.operations.reverse()\n }\n\n return action\n}\n\nexport function fromAtomsFragmentAttr(restruct, aids, newfrid) {\n const action = new Action()\n\n aids.forEach(aid => {\n const atom = restruct.molecule.atoms.get(aid)\n const oldfrid = atom.fragment\n action.addOp(new AtomAttr(aid, 'fragment', newfrid))\n\n if (atom.stereoLabel !== null) {\n action.addOp(new FragmentAddStereoAtom(newfrid, aid))\n action.addOp(new FragmentDeleteStereoAtom(oldfrid, aid))\n }\n })\n\n return action.perform(restruct)\n}\n\n/**\n * @param restruct { ReStruct }\n * @param srcId { number }\n * @param dstId { number }\n * @return { Action }\n */\nexport function fromAtomMerge(restruct, srcId, dstId) {\n if (srcId === dstId) return new Action()\n\n const fragAction = new Action()\n mergeFragmentsIfNeeded(fragAction, restruct, srcId, dstId)\n\n const action = new Action()\n\n const atomNeighbors = restruct.molecule.atomGetNeighbors(srcId)\n atomNeighbors.forEach(nei => {\n const bond = restruct.molecule.bonds.get(nei.bid)\n\n if (dstId === bond.begin || dstId === bond.end) {\n // src & dst have one nei\n action.addOp(new BondDelete(nei.bid))\n return\n }\n\n const begin = bond.begin === nei.aid ? nei.aid : dstId\n const end = bond.begin === nei.aid ? dstId : nei.aid\n\n const mergeBondId = restruct.molecule.findBondId(begin, end)\n\n if (mergeBondId === null) {\n action.addOp(new BondAdd(begin, end, bond))\n } else {\n // replace old bond with new bond\n const attrs = Bond.getAttrHash(bond)\n Object.keys(attrs).forEach(key => {\n action.addOp(new BondAttr(mergeBondId, key, attrs[key]))\n })\n }\n\n action.addOp(new BondDelete(nei.bid))\n })\n\n const attrs = Atom.getAttrHash(restruct.molecule.atoms.get(srcId))\n\n if (atomGetDegree(restruct, srcId) === 1 && attrs['label'] === '*')\n attrs['label'] = 'C'\n\n Object.keys(attrs).forEach(key => {\n if (key !== 'stereoLabel' && key !== 'stereoParity') {\n action.addOp(new AtomAttr(dstId, key, attrs[key]))\n }\n })\n\n const sgChanged = removeAtomFromSgroupIfNeeded(action, restruct, srcId)\n\n if (sgChanged) removeSgroupIfNeeded(action, restruct, [srcId])\n\n action.addOp(new AtomDelete(srcId))\n action.addOp(new CalcImplicitH([dstId]))\n const dstAtomNeighbors = restruct.molecule.atomGetNeighbors(dstId)\n const bond = restruct.molecule.bonds.get(\n dstAtomNeighbors[0]?.bid || atomNeighbors[0]?.bid\n )\n\n return action\n .perform(restruct)\n .mergeWith(fragAction)\n .mergeWith(fromBondStereoUpdate(restruct, bond))\n}\n\nexport function mergeFragmentsIfNeeded(action, restruct, srcId, dstId) {\n const frid = atomGetAttr(restruct, srcId, 'fragment')\n const frid2 = atomGetAttr(restruct, dstId, 'fragment')\n if (frid2 === frid || typeof frid2 !== 'number') return\n\n const struct = restruct.molecule\n\n const rgid = RGroup.findRGroupByFragment(struct.rgroups, frid2)\n if (!(typeof rgid === 'undefined')) {\n action\n .mergeWith(fromRGroupFragment(restruct, null, frid2))\n .mergeWith(fromUpdateIfThen(restruct, 0, rgid))\n }\n\n const fridAtoms = struct.getFragmentIds(frid)\n\n const atomsToNewFrag: Array = []\n struct.atoms.forEach((atom, aid) => {\n if (atom.fragment === frid2) atomsToNewFrag.push(aid)\n })\n const moveAtomsAction = fromAtomsFragmentAttr(restruct, atomsToNewFrag, frid)\n\n mergeSgroups(action, restruct, fridAtoms, dstId)\n action.addOp(new FragmentDelete(frid2).perform(restruct))\n action.mergeWith(moveAtomsAction)\n}\n\nexport function mergeSgroups(action, restruct, srcAtoms, dstAtom) {\n const sgroups = atomGetSGroups(restruct, dstAtom)\n\n sgroups.forEach(sid => {\n const sgroup = restruct.molecule.sgroups.get(sid)\n const notExpandedContexts = ['Atom', 'Bond', 'Group']\n if (\n sgroup.type === 'DAT' &&\n notExpandedContexts.includes(sgroup.data.context)\n )\n return\n const atomsToSgroup: any = without(sgroup.atoms, srcAtoms)\n atomsToSgroup.forEach(aid =>\n action.addOp(new SGroupAtomAdd(sid, aid).perform(restruct))\n )\n })\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AlignDescriptors, CanvasLoad } from '../operations'\n\nimport { Action } from './action'\n\nexport function fromNewCanvas(restruct, struct) {\n var action = new Action()\n\n action.addOp(new CanvasLoad(struct))\n return action.perform(restruct)\n}\n\nexport function fromDescriptorsAlign(restruct) {\n const action = new Action()\n action.addOp(new AlignDescriptors())\n return action.perform(restruct)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AtomAdd, FragmentAdd } from '../operations'\n\nimport { Action } from './action'\nimport { Vec2 } from 'domain/entities'\nimport { atomGetAttr } from './utils'\nimport { fromBondAddition } from './bond'\n\nexport function fromChain(restruct, p0, v, nSect, atomId) {\n // eslint-disable-line max-params\n const dx = Math.cos(Math.PI / 6)\n const dy = Math.sin(Math.PI / 6)\n\n let action = new Action()\n\n const frid =\n atomId !== null\n ? atomGetAttr(restruct, atomId, 'fragment')\n : (action.addOp(new FragmentAdd().perform(restruct)) as FragmentAdd).frid\n\n const chainItems: any = {\n atoms: [],\n bonds: []\n }\n\n let id0 =\n atomId !== null\n ? atomId\n : (\n action.addOp(\n new AtomAdd({ label: 'C', fragment: frid }, p0).perform(restruct)\n ) as AtomAdd\n ).data.aid\n\n chainItems.atoms.push(id0)\n action.operations.reverse()\n\n for (let i = 0; i < nSect; i++) {\n const pos = new Vec2(dx * (i + 1), i & 1 ? 0 : dy).rotate(v).add(p0)\n\n const ret = fromBondAddition(restruct, {}, id0, {}, pos)\n action = ret[0].mergeWith(action)\n id0 = ret[2]\n chainItems.bonds.push(ret[3])\n chainItems.atoms.push(id0)\n }\n\n return [action, chainItems]\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Action } from './action'\nimport { fromAtomMerge } from './atom'\nimport { fromBondsMerge } from './bond'\nimport utils from '../shared/utils'\n\nexport function fromItemsFuse(restruct, items) {\n let action = new Action()\n\n if (!items) return action\n\n const usedAtoms = new Set()\n\n // merge single atoms\n items.atoms.forEach((dst, src) => {\n if (usedAtoms.has(dst) || usedAtoms.has(src)) return\n\n action = fromAtomMerge(restruct, src, dst).mergeWith(action)\n usedAtoms.add(dst).add(src)\n })\n\n // merge bonds\n action = fromBondsMerge(restruct, items.bonds).mergeWith(action)\n\n return action\n}\n\nexport function getItemsToFuse(editor, items) {\n const struct = editor.render.ctab.molecule\n\n const mergeItems = items || {\n atoms: Array.from(struct.atoms.keys()),\n bonds: Array.from(struct.bonds.keys())\n }\n\n return closestToMerge(\n struct,\n editor.findMerge(mergeItems, ['atoms', 'bonds'])\n )\n}\n\nexport function getHoverToFuse(items) {\n if (!items) return null\n\n const hoverItems = {\n atoms: Array.from(items.atoms.values()),\n bonds: Array.from(items.bonds.values())\n }\n\n return { map: 'merge', id: +Date.now(), items: hoverItems }\n}\n\n/**\n * @param struct\n * @param closestMap {{\n * \t\tatoms: Map,\n * \t\tbonds: Map\n * }}\n * @return {{\n * \t\tatoms: Map,\n * \t\tbonds: Map\n * }}\n */\nfunction closestToMerge(struct, closestMap) {\n const mergeMap = {\n atoms: new Map(closestMap.atoms),\n bonds: new Map(closestMap.bonds)\n }\n\n closestMap.bonds.forEach((dstId, srcId) => {\n const bond = struct.bonds.get(srcId)\n const bondCI = struct.bonds.get(dstId)\n\n if (utils.mergeBondsParams(struct, bond, struct, bondCI).merged) {\n mergeMap.atoms.delete(bond.begin)\n mergeMap.atoms.delete(bond.end)\n } else {\n mergeMap.bonds.delete(srcId)\n }\n })\n\n if (mergeMap.atoms.size === 0 && mergeMap.bonds.size === 0) return null\n\n return mergeMap\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AtomMove,\n BondMove,\n EnhancedFlagMove,\n FragmentAdd,\n FragmentDelete,\n FragmentDeleteStereoAtom,\n FragmentStereoFlag,\n LoopMove,\n RxnArrowMove,\n RxnPlusMove,\n SGroupDataMove,\n SimpleObjectMove,\n TextMove\n} from '../operations'\nimport { Pile, RGroup, Vec2 } from 'domain/entities'\nimport { fromRGroupFragment, fromUpdateIfThen } from './rgroup'\n\nimport { Action } from './action'\nimport { fromAtomsFragmentAttr } from './atom'\nimport { getRelSgroupsBySelection } from './utils'\n\nexport function fromMultipleMove(restruct, lists, d) {\n d = new Vec2(d)\n\n const action = new Action()\n const struct = restruct.molecule\n const loops = new Pile()\n const atomsToInvalidate = new Pile()\n\n if (lists.atoms) {\n const atomSet = new Pile(lists.atoms)\n const bondlist: Array = []\n\n restruct.bonds.forEach((bond, bid) => {\n if (atomSet.has(bond.b.begin) && atomSet.has(bond.b.end)) {\n bondlist.push(bid)\n // add all adjacent loops\n // those that are not completely inside the structure will get redrawn anyway\n ;['hb1', 'hb2'].forEach(hb => {\n const loop = struct.halfBonds.get(bond.b[hb]).loop\n if (loop >= 0) loops.add(loop)\n })\n return\n }\n\n if (atomSet.has(bond.b.begin)) {\n atomsToInvalidate.add(bond.b.begin)\n return\n }\n\n if (atomSet.has(bond.b.end)) atomsToInvalidate.add(bond.b.end)\n })\n\n bondlist.forEach(bond => {\n action.addOp(new BondMove(bond, d))\n })\n\n loops.forEach(loopId => {\n if (restruct.reloops.get(loopId) && restruct.reloops.get(loopId).visel)\n // hack\n action.addOp(new LoopMove(loopId, d))\n })\n\n lists.atoms.forEach(aid => {\n action.addOp(new AtomMove(aid, d, !atomsToInvalidate.has(aid)))\n })\n\n if (lists.sgroupData && lists.sgroupData.length === 0) {\n const sgroups = getRelSgroupsBySelection(restruct, lists.atoms)\n sgroups.forEach(sg => {\n action.addOp(new SGroupDataMove(sg.id, d))\n })\n }\n }\n\n if (lists.rxnArrows) {\n lists.rxnArrows.forEach(rxnArrow => {\n action.addOp(new RxnArrowMove(rxnArrow, d, true))\n })\n }\n\n if (lists.rxnPluses) {\n lists.rxnPluses.forEach(rxnPulse => {\n action.addOp(new RxnPlusMove(rxnPulse, d, true))\n })\n }\n\n if (lists.simpleObjects) {\n lists.simpleObjects.forEach(simpleObject => {\n action.addOp(new SimpleObjectMove(simpleObject, d, true))\n })\n }\n\n if (lists.sgroupData) {\n lists.sgroupData.forEach(sgData => {\n action.addOp(new SGroupDataMove(sgData, d))\n })\n }\n\n if (lists.enhancedFlags) {\n lists.enhancedFlags.forEach(fid => {\n action.addOp(new EnhancedFlagMove(fid, d))\n })\n }\n\n if (lists.texts) {\n lists.texts.forEach(text => {\n action.addOp(new TextMove(text, d, true))\n })\n }\n\n return action.perform(restruct)\n}\n\nexport function fromStereoFlagUpdate(restruct, frid, flag = null) {\n const action = new Action()\n\n if (!flag) {\n const struct = restruct.molecule\n const frag = restruct.molecule.frags.get(frid)\n frag.stereoAtoms.forEach(aid => {\n if (struct.atoms.get(aid).stereoLabel === null)\n action.addOp(new FragmentDeleteStereoAtom(frid, aid))\n })\n }\n\n action.addOp(new FragmentStereoFlag(frid))\n return action.perform(restruct)\n}\n\n/**\n * @param restruct { ReStruct }\n * @param aid { number }\n * @param frid { number }\n * @param newfrid { number }\n * @returns { Action }\n */\nfunction processAtom(restruct, aid, frid, newfrid) {\n const queue = [aid]\n const usedIds = new Pile(queue)\n\n while (queue.length > 0) {\n const id = queue.shift()\n\n restruct.molecule.atomGetNeighbors(id).forEach(nei => {\n if (\n restruct.molecule.atoms.get(nei.aid).fragment === frid &&\n !usedIds.has(nei.aid)\n ) {\n usedIds.add(nei.aid)\n queue.push(nei.aid)\n }\n })\n }\n\n return fromAtomsFragmentAttr(restruct, usedIds, newfrid)\n}\n\n/**\n * @param restruct { ReStruct }\n * @param frid { number }\n * @param rgForRemove\n * @return { Action }\n */\n// TODO [RB] the thing is too tricky :) need something else in future\nexport function fromFragmentSplit(\n restruct,\n frid,\n rgForRemove: Array = []\n) {\n const action = new Action()\n const rgid = RGroup.findRGroupByFragment(restruct.molecule.rgroups, frid)\n\n restruct.molecule.atoms.forEach((atom, aid) => {\n if (atom.fragment === frid) {\n const newfrid = (\n action.addOp(new FragmentAdd().perform(restruct)) as FragmentAdd\n ).frid\n\n action.mergeWith(processAtom(restruct, aid, frid, newfrid))\n\n if (rgid) action.mergeWith(fromRGroupFragment(restruct, rgid, newfrid))\n }\n })\n\n if (frid !== -1) {\n action.mergeWith(fromRGroupFragment(restruct, 0, frid))\n action.addOp(new FragmentDelete(frid).perform(restruct))\n action.mergeWith(fromUpdateIfThen(restruct, 0, rgid, rgForRemove))\n }\n\n action.operations.reverse()\n return action\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AtomDelete,\n BondDelete,\n CalcImplicitH,\n RxnArrowDelete,\n RxnPlusDelete,\n SimpleObjectDelete,\n TextDelete\n} from '../operations'\nimport { Pile, RGroup } from 'domain/entities'\nimport {\n fromSgroupDeletion,\n removeAtomFromSgroupIfNeeded,\n removeSgroupIfNeeded\n} from './sgroup'\n\nimport { Action } from './action'\nimport assert from 'assert'\nimport { atomGetDegree } from './utils'\nimport { fromBondStereoUpdate } from '../actions/bond'\nimport { fromFragmentSplit } from './fragment'\n\nexport function fromOneAtomDeletion(restruct, id) {\n return fromFragmentDeletion(restruct, { atoms: [id] })\n}\n\nfunction fromBondDeletion(restruct, bid: number, skipAtoms: Array = []) {\n let action = new Action()\n const bond: any = restruct.molecule.bonds.get(bid)\n const atomsToRemove: Array = []\n\n action.addOp(new BondDelete(bid))\n\n if (\n !skipAtoms.includes(bond.begin) &&\n atomGetDegree(restruct, bond.begin) === 1\n ) {\n if (removeAtomFromSgroupIfNeeded(action, restruct, bond.begin))\n atomsToRemove.push(bond.begin)\n\n action.addOp(new AtomDelete(bond.begin))\n }\n\n if (\n !skipAtoms.includes(bond.end) &&\n atomGetDegree(restruct, bond.end) === 1\n ) {\n if (removeAtomFromSgroupIfNeeded(action, restruct, bond.end))\n atomsToRemove.push(bond.end)\n\n action.addOp(new AtomDelete(bond.end))\n }\n\n removeSgroupIfNeeded(action, restruct, atomsToRemove)\n action = action.perform(restruct)\n action.addOp(new CalcImplicitH([bond.begin, bond.end]).perform(restruct))\n action.mergeWith(fromBondStereoUpdate(restruct, bond, false))\n\n action.operations.reverse()\n\n return action\n}\n\nexport function fromOneBondDeletion(restruct, id) {\n const frid = restruct.molecule.getBondFragment(id)\n let action = fromBondDeletion(restruct, id)\n\n action = fromFragmentSplit(restruct, frid).mergeWith(action)\n\n return action\n}\n\nexport function fromFragmentDeletion(restruct, selection) {\n assert(!!selection != null)\n\n let action = new Action()\n const atomsToRemove: Array = []\n const frids: Array = []\n\n selection = {\n // TODO: refactor me\n atoms: selection.atoms || [],\n bonds: selection.bonds || [],\n rxnPluses: selection.rxnPluses || [],\n rxnArrows: selection.rxnArrows || [],\n sgroupData: selection.sgroupData || [],\n simpleObjects: selection.simpleObjects || [],\n texts: selection.texts || []\n }\n\n const actionRemoveDataSGroups = new Action()\n restruct.molecule.sgroups.forEach((sg, id) => {\n if (\n selection.sgroupData.includes(id) ||\n new Pile(selection.atoms).isSuperset(new Pile(sg.atoms))\n )\n actionRemoveDataSGroups.mergeWith(fromSgroupDeletion(restruct, id))\n })\n\n selection.atoms.forEach(aid => {\n restruct.molecule.atomGetNeighbors(aid).forEach(nei => {\n if (selection.bonds.indexOf(nei.bid) === -1) {\n selection.bonds = selection.bonds.concat([nei.bid])\n }\n })\n })\n\n const actionRemoveBonds = new Action()\n selection.bonds.forEach(bid => {\n const frid = restruct.molecule.getBondFragment(bid)\n if (frids.indexOf(frid) < 0) frids.push(frid)\n\n actionRemoveBonds.mergeWith(\n fromBondDeletion(restruct, bid, selection.atoms)\n )\n })\n\n selection.atoms.forEach(aid => {\n const frid3 = restruct.molecule.atoms.get(aid).fragment\n if (frids.indexOf(frid3) < 0) frids.push(frid3)\n\n if (removeAtomFromSgroupIfNeeded(action, restruct, aid))\n atomsToRemove.push(aid)\n\n action.addOp(new AtomDelete(aid))\n })\n\n removeSgroupIfNeeded(action, restruct, atomsToRemove)\n\n selection.rxnArrows.forEach(id => {\n action.addOp(new RxnArrowDelete(id))\n })\n\n selection.rxnPluses.forEach(id => {\n action.addOp(new RxnPlusDelete(id))\n })\n\n selection.simpleObjects.forEach(id => {\n action.addOp(new SimpleObjectDelete(id))\n })\n\n selection.texts.forEach(id => {\n action.addOp(new TextDelete(id))\n })\n\n action = action.perform(restruct)\n action.mergeWith(actionRemoveBonds)\n\n const rgForRemove: Array = frids.map(\n frid => RGroup.findRGroupByFragment(restruct.molecule.rgroups, frid)!\n )\n\n while (frids.length > 0)\n action = fromFragmentSplit(restruct, frids.pop(), rgForRemove).mergeWith(\n action\n )\n\n action.mergeWith(actionRemoveDataSGroups)\n\n return action\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AtomAdd,\n BondAdd,\n FragmentAdd,\n FragmentAddStereoAtom,\n RGroupFragment,\n RxnArrowAdd,\n RxnPlusAdd,\n SimpleObjectAdd,\n TextCreate\n} from '../operations'\nimport { fromRGroupAttrs, fromUpdateIfThen } from './rgroup'\n\nimport { Action } from './action'\nimport { Vec2 } from 'domain/entities'\nimport { fromSgroupAddition } from './sgroup'\n\nexport function fromPaste(restruct, pstruct, point, angle = 0) {\n const xy0 = getStructCenter(pstruct)\n const offset = Vec2.diff(point, xy0)\n\n const action = new Action()\n\n const aidMap = new Map()\n const fridMap = new Map()\n\n const pasteItems: any = {\n // only atoms and bonds now\n atoms: [],\n bonds: []\n }\n\n pstruct.atoms.forEach((atom, aid) => {\n if (!fridMap.has(atom.fragment))\n fridMap.set(\n atom.fragment,\n (action.addOp(new FragmentAdd().perform(restruct)) as FragmentAdd).frid\n )\n\n const tmpAtom = Object.assign(atom.clone(), {\n fragment: fridMap.get(atom.fragment)\n })\n const operation = new AtomAdd(\n tmpAtom,\n Vec2.diff(atom.pp, xy0).rotate(angle).add(point)\n ).perform(restruct) as AtomAdd\n action.addOp(operation)\n aidMap.set(aid, operation.data.aid)\n\n pasteItems.atoms.push(operation.data.aid)\n })\n\n pstruct.frags.forEach((frag, frid) => {\n if (!frag) return\n frag.stereoAtoms.forEach(aid =>\n action.addOp(\n new FragmentAddStereoAtom(fridMap.get(frid), aidMap.get(aid)).perform(\n restruct\n )\n )\n )\n })\n\n pstruct.bonds.forEach(bond => {\n const operation = new BondAdd(\n aidMap.get(bond.begin),\n aidMap.get(bond.end),\n bond\n ).perform(restruct) as BondAdd\n action.addOp(operation)\n\n pasteItems.bonds.push(operation.data.bid)\n })\n\n pstruct.sgroups.forEach(sg => {\n const newsgid = restruct.molecule.sgroups.newId()\n const sgAtoms = sg.atoms.map(aid => aidMap.get(aid))\n const sgAction = fromSgroupAddition(\n restruct,\n sg.type,\n sgAtoms,\n sg.data,\n newsgid,\n sg.pp ? sg.pp.add(offset) : null,\n sg.type === 'SUP' ? sg.data.expanded : null,\n sg.data.name\n )\n sgAction.operations.reverse().forEach(oper => {\n action.addOp(oper)\n })\n })\n\n pstruct.rxnArrows.forEach(rxnArrow => {\n action.addOp(\n new RxnArrowAdd(\n rxnArrow.pos.map(p => p.add(offset)),\n rxnArrow.mode\n ).perform(restruct)\n )\n })\n\n pstruct.rxnPluses.forEach(plus => {\n action.addOp(new RxnPlusAdd(plus.pp.add(offset)).perform(restruct))\n })\n\n pstruct.simpleObjects.forEach(simpleObject => {\n action.addOp(\n new SimpleObjectAdd(\n simpleObject.pos.map(p => p.add(offset)),\n simpleObject.mode\n ).perform(restruct)\n )\n })\n\n pstruct.texts.forEach(text => {\n action.addOp(\n new TextCreate(text.content, text.position.add(offset)).perform(restruct)\n )\n })\n\n pstruct.rgroups.forEach((rg, rgid) => {\n rg.frags.forEach((__frag, frid) => {\n action.addOp(\n new RGroupFragment(rgid, fridMap.get(frid)).perform(restruct)\n )\n })\n const ifThen = pstruct.rgroups.get(rgid).ifthen\n const newRgId = pstruct.rgroups.get(ifThen) ? ifThen : 0\n action\n .mergeWith(fromRGroupAttrs(restruct, rgid, rg.getAttrs()))\n .mergeWith(fromUpdateIfThen(restruct, newRgId, rg.ifthen))\n })\n\n action.operations.reverse()\n return [action, pasteItems]\n}\n\nfunction getStructCenter(struct) {\n //TODO: Review, function may not work sometimes\n const onlyOneStructsSgroupId = struct.sgroups.keys().next().value\n if (\n struct.sgroups.size === 1 &&\n !struct.sgroups.get(onlyOneStructsSgroupId).data.expanded\n ) {\n return struct.atoms.get(0).pp\n }\n if (struct.atoms.size > 0) {\n let xmin = 1e50\n let ymin = xmin\n let xmax = -xmin\n let ymax = -ymin\n\n struct.atoms.forEach(atom => {\n xmin = Math.min(xmin, atom.pp.x)\n ymin = Math.min(ymin, atom.pp.y)\n xmax = Math.max(xmax, atom.pp.x)\n ymax = Math.max(ymax, atom.pp.y)\n })\n return new Vec2((xmin + xmax) / 2, (ymin + ymax) / 2) // TODO: check\n }\n if (struct.rxnArrows.size > 0) return struct.rxnArrows.get(0).center()\n if (struct.rxnPluses.size > 0) return struct.rxnPluses.get(0).pp\n if (struct.simpleObjects.size > 0) return struct.simpleObjects.get(0).center()\n if (struct.texts.size > 0) return struct.texts.get(0).position\n\n return null\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n RxnArrowAdd,\n RxnArrowDelete,\n RxnArrowResize,\n RxnPlusAdd,\n RxnPlusDelete\n} from '../operations'\n\nimport { Action } from './action'\n\nexport function fromArrowAddition(restruct, pos, mode) {\n const action = new Action()\n action.addOp(new RxnArrowAdd(pos, mode))\n return action.perform(restruct)\n}\n\nexport function fromArrowResizing(restruct, id, d, current, anchor) {\n var action = new Action()\n action.addOp(new RxnArrowResize(id, d, current, anchor, false))\n return action.perform(restruct)\n}\n\nexport function fromArrowDeletion(restruct, id) {\n var action = new Action()\n action.addOp(new RxnArrowDelete(id))\n return action.perform(restruct)\n}\n\nexport function fromPlusAddition(restruct, pos) {\n var action = new Action()\n action.addOp(new RxnPlusAdd(pos).perform(restruct))\n return action\n}\n\nexport function fromPlusDeletion(restruct, id) {\n var action = new Action()\n action.addOp(new RxnPlusDelete(id))\n return action.perform(restruct)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n AtomMove,\n BondAttr,\n EnhancedFlagMove,\n RxnArrowMove,\n RxnPlusMove,\n SGroupDataMove\n} from '../operations'\nimport { Bond, Fragment, Pile, Vec2 } from 'domain/entities'\nimport { getRelSgroupsBySelection, structSelection } from './utils'\n\nimport { Action } from './action'\nimport utils from '../shared/utils'\n\nexport function fromFlip(restruct, selection, dir, center) {\n // eslint-disable-line max-statements\n const struct = restruct.molecule\n\n const action = new Action()\n\n if (!selection) {\n selection = structSelection(struct)\n }\n\n if (!selection.atoms) {\n return action.perform(restruct)\n }\n\n const fids = selection.atoms.reduce((acc, aid) => {\n const atom = struct.atoms.get(aid)\n\n if (!acc[atom.fragment]) {\n acc[atom.fragment] = []\n }\n\n acc[atom.fragment].push(aid)\n return acc\n }, {})\n\n const fidsNumberKeys = Object.keys(fids).map(frag => parseInt(frag, 10))\n\n const isFragFound = fidsNumberKeys.find(frag => {\n const allFragmentsOfStructure = struct.getFragmentIds(frag)\n const selectedFragmentsOfStructure = new Pile(fids[frag])\n const res = allFragmentsOfStructure.equals(selectedFragmentsOfStructure)\n return !res\n })\n\n if (typeof isFragFound === 'number') {\n return action // empty action\n }\n\n Object.keys(fids).forEach(frag => {\n const fragment = new Pile(fids[frag])\n\n const bbox = struct.getCoordBoundingBox(fragment)\n const calcCenter =\n center ||\n new Vec2((bbox.max.x + bbox.min.x) / 2, (bbox.max.y + bbox.min.y) / 2)\n\n fragment.forEach(aid => {\n const atom = struct.atoms.get(aid)\n const d = flipItemByCenter(atom, calcCenter, dir)\n action.addOp(new AtomMove(aid, d))\n })\n\n const sgroups = getRelSgroupsBySelection(restruct, Array.from(fragment))\n sgroups.forEach(sg => {\n const d = flipItemByCenter(sg, calcCenter, dir)\n action.addOp(new SGroupDataMove(sg.id, d))\n })\n })\n\n if (selection.bonds) {\n selection.bonds.forEach(bid => {\n const bond = struct.bonds.get(bid)\n\n if (bond.type !== Bond.PATTERN.TYPE.SINGLE) {\n return\n }\n\n if (bond.stereo === Bond.PATTERN.STEREO.UP) {\n action.addOp(new BondAttr(bid, 'stereo', Bond.PATTERN.STEREO.DOWN))\n return\n }\n\n if (bond.stereo === Bond.PATTERN.STEREO.DOWN)\n action.addOp(new BondAttr(bid, 'stereo', Bond.PATTERN.STEREO.UP))\n })\n }\n\n return action.perform(restruct)\n}\n\nfunction flipItemByCenter(item, center, dir) {\n const d = new Vec2()\n /* eslint-disable no-mixed-operators*/\n if (dir === 'horizontal') {\n d.x =\n center.x > item.pp.x\n ? 2 * (center.x - item.pp.x)\n : -2 * (item.pp.x - center.x)\n } else {\n // 'vertical'\n d.y =\n center.y > item.pp.y\n ? 2 * (center.y - item.pp.y)\n : -2 * (item.pp.y - center.y)\n }\n /* eslint-enable no-mixed-operators*/\n return d\n}\n\nexport function fromRotate(restruct, selection, center, angle) {\n // eslint-disable-line\n const struct = restruct.molecule\n\n const action = new Action()\n\n if (!selection) {\n selection = structSelection(struct)\n }\n\n if (selection.atoms) {\n selection.atoms.forEach(aid => {\n const atom = struct.atoms.get(aid)\n action.addOp(new AtomMove(aid, rotateDelta(atom.pp, center, angle)))\n })\n\n if (!selection.sgroupData) {\n const sgroups = getRelSgroupsBySelection(restruct, selection.atoms)\n\n sgroups.forEach(sg => {\n action.addOp(\n new SGroupDataMove(sg.id, rotateDelta(sg.pp, center, angle))\n )\n })\n }\n }\n\n if (selection.rxnArrows) {\n selection.rxnArrows.forEach(aid => {\n var arrow = struct.rxnArrows.get(aid)\n action.addOp(\n new RxnArrowMove(aid, rotateDelta(arrow.center(), center, angle))\n )\n })\n }\n\n if (selection.rxnPluses) {\n selection.rxnPluses.forEach(pid => {\n var plus = struct.rxnPluses.get(pid)\n action.addOp(new RxnPlusMove(pid, rotateDelta(plus.pp, center, angle)))\n })\n }\n\n if (selection.sgroupData) {\n selection.sgroupData.forEach(did => {\n var data = struct.sgroups.get(did)\n action.addOp(new SGroupDataMove(did, rotateDelta(data.pp, center, angle)))\n })\n }\n\n const stereoFlags =\n selection.enhancedFlags || Array.from(restruct.enhancedFlags.keys())\n if (stereoFlags) {\n stereoFlags.forEach(flagId => {\n const frId = flagId\n const frag = restruct.molecule.frags.get(frId)\n action.addOp(\n new EnhancedFlagMove(\n flagId,\n rotateDelta(\n frag.stereoFlagPosition ||\n Fragment.getDefaultStereoFlagPosition(restruct.molecule, frId),\n center,\n angle\n )\n )\n )\n })\n }\n\n return action.perform(restruct)\n}\n\nexport function fromBondAlign(restruct, bid, dir) {\n const struct = restruct.molecule\n const bond = struct.bonds.get(bid)\n const begin = struct.atoms.get(bond.begin)\n const end = struct.atoms.get(bond.end)\n\n const center = begin.pp.add(end.pp).scaled(0.5)\n let angle = utils.calcAngle(begin.pp, end.pp)\n const atoms = Array.from(struct.getFragmentIds(begin.fragment))\n\n // TODO: choose minimal angle\n angle = dir === 'horizontal' ? -angle : Math.PI / 2 - angle\n\n if (angle === 0 || Math.abs(angle) === Math.PI)\n return fromFlip(restruct, { atoms }, dir, center)\n\n return fromRotate(restruct, { atoms }, center, angle)\n}\n\nfunction rotateDelta(v, center, angle) {\n var v1 = v.sub(center)\n v1 = v1.rotate(angle)\n v1.add_(center) // eslint-disable-line no-underscore-dangle\n return v1.sub(v)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n SimpleObjectAdd,\n SimpleObjectDelete,\n SimpleObjectResize\n} from '../operations'\n\nimport { Action } from './action'\n\nexport function fromSimpleObjectDeletion(restruct, id) {\n const action = new Action()\n action.addOp(new SimpleObjectDelete(id))\n return action.perform(restruct)\n}\n\nexport function fromSimpleObjectAddition(restruct, pos, mode, toCircle) {\n var action = new Action()\n action.addOp(new SimpleObjectAdd(pos, mode, toCircle))\n return action.perform(restruct)\n}\n\nexport function fromSimpleObjectResizing(\n restruct,\n id,\n d,\n current,\n anchor,\n toCircle\n) {\n var action = new Action()\n action.addOp(new SimpleObjectResize(id, d, current, anchor, false, toCircle))\n return action.perform(restruct)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Atom, Vec2 } from 'domain/entities'\nimport { AtomAdd, BondAdd, CalcImplicitH } from '../operations'\nimport { atomForNewBond, atomGetAttr } from './utils'\nimport { fromAtomsAttrs, mergeSgroups } from './atom'\nimport { fromBondAddition, fromBondStereoUpdate, fromBondsAttrs } from './bond'\n\nimport { Action } from './action'\nimport closest from '../shared/closest'\nimport { fromAromaticTemplateOnBond } from './aromaticFusing'\nimport { fromPaste } from './paste'\nimport utils from '../shared/utils'\nimport { fromSgroupAddition } from './sgroup'\n\nexport function fromTemplateOnCanvas(restruct, template, pos, angle) {\n const [action, pasteItems] = fromPaste(\n restruct,\n template.molecule,\n pos,\n angle\n )\n\n action.addOp(new CalcImplicitH(pasteItems.atoms).perform(restruct))\n\n return [action, pasteItems]\n}\n\nfunction extraBondAction(restruct, aid, angle) {\n let action = new Action()\n const frid = atomGetAttr(restruct, aid, 'fragment')\n let additionalAtom: any = null\n\n if (angle === null) {\n const middleAtom = atomForNewBond(restruct, aid)\n const actionRes = fromBondAddition(\n restruct,\n { type: 1 },\n aid,\n middleAtom.atom,\n middleAtom.pos.get_xy0()\n )\n action = actionRes[0]\n action.operations.reverse()\n additionalAtom = actionRes[2]\n } else {\n const operation = new AtomAdd(\n { label: 'C', fragment: frid },\n new Vec2(1, 0)\n .rotate(angle)\n .add(restruct.molecule.atoms.get(aid).pp)\n .get_xy0()\n ).perform(restruct) as AtomAdd\n\n action.addOp(operation)\n action.addOp(\n new BondAdd(aid, operation.data.aid, { type: 1 }).perform(restruct)\n )\n\n additionalAtom = operation.data.aid\n }\n\n return { action, aid1: additionalAtom }\n}\n\nexport function fromTemplateOnAtom(restruct, template, aid, angle, extraBond) {\n let action = new Action()\n\n const tmpl = template.molecule\n const struct = restruct.molecule\n\n let atom = struct.atoms.get(aid) // aid - the atom that was clicked on\n let aid1 = aid // aid1 - the atom on the other end of the extra bond || aid\n\n let delta: any = null\n\n if (extraBond) {\n // create extra bond after click on atom\n const extraRes = extraBondAction(restruct, aid, angle)\n action = extraRes.action\n aid1 = extraRes.aid1\n\n atom = struct.atoms.get(aid1)\n delta = utils.calcAngle(struct.atoms.get(aid).pp, atom.pp) - template.angle0\n } else {\n if (angle === null)\n angle = utils.calcAngle(atom.pp, atomForNewBond(restruct, aid).pos)\n delta = angle - template.angle0\n }\n\n const map = new Map()\n const xy0 = tmpl.atoms.get(template.aid).pp\n const frid = atomGetAttr(restruct, aid, 'fragment')\n\n /* For merge */\n const pasteItems: any = {\n // only atoms and bonds now\n atoms: [],\n bonds: []\n }\n /* ----- */\n\n tmpl.atoms.forEach((a, id) => {\n const attrs: any = Atom.getAttrHash(a)\n attrs.fragment = frid\n\n if (id === template.aid) {\n action.mergeWith(fromAtomsAttrs(restruct, aid1, attrs, true))\n map.set(id, aid1)\n pasteItems.atoms.push(aid1)\n } else {\n const v = Vec2.diff(a.pp, xy0).rotate(delta).add(atom.pp)\n\n const operation = new AtomAdd(attrs, v.get_xy0()).perform(\n restruct\n ) as AtomAdd\n action.addOp(operation)\n map.set(id, operation.data.aid)\n pasteItems.atoms.push(operation.data.aid)\n }\n })\n mergeSgroups(action, restruct, pasteItems.atoms, aid)\n\n tmpl.bonds.forEach(bond => {\n const operation = new BondAdd(\n map.get(bond.begin),\n map.get(bond.end),\n bond\n ).perform(restruct) as BondAdd\n action.addOp(operation)\n\n pasteItems.bonds.push(operation.data.bid)\n })\n\n tmpl.sgroups.forEach(sg => {\n const newsgid = restruct.molecule.sgroups.newId()\n const sgAtoms = sg.atoms.map(aid => map.get(aid))\n const sgAction = fromSgroupAddition(\n restruct,\n sg.type,\n sgAtoms,\n sg.data,\n newsgid,\n atom.pp,\n sg.type === 'SUP' ? sg.expanded : null,\n sg.data.name\n )\n sgAction.operations.reverse().forEach(oper => {\n action.addOp(oper)\n })\n })\n\n action.operations.reverse()\n\n action.addOp(new CalcImplicitH(pasteItems.atoms).perform(restruct))\n action.mergeWith(\n fromBondStereoUpdate(\n restruct,\n restruct.molecule.bonds.get(pasteItems.bonds[0])\n )\n )\n\n return [action, pasteItems]\n}\n\nexport function fromTemplateOnBondAction(\n restruct,\n template,\n bid,\n events,\n flip,\n force\n) {\n if (!force) return fromTemplateOnBond(restruct, template, bid, flip)\n\n const simpleFusing = (restruct, template, bid) =>\n fromTemplateOnBond(restruct, template, bid, flip) // eslint-disable-line\n /* aromatic merge (Promise)*/\n return fromAromaticTemplateOnBond(\n restruct,\n template,\n bid,\n events,\n simpleFusing\n )\n}\n\nfunction fromTemplateOnBond(restruct, template, bid, flip) {\n // TODO: refactor function !!\n const action = new Action()\n\n const tmpl = template.molecule\n const struct = restruct.molecule\n\n const bond = struct.bonds.get(bid)\n const tmplBond = tmpl.bonds.get(template.bid)\n\n const tmplBegin = tmpl.atoms.get(flip ? tmplBond.end : tmplBond.begin)\n\n const atomsMap = new Map([\n [tmplBond.begin, flip ? bond.end : bond.begin],\n [tmplBond.end, flip ? bond.begin : bond.end]\n ])\n\n // calc angle\n const bondAtoms = {\n begin: flip ? tmplBond.end : tmplBond.begin,\n end: flip ? tmplBond.begin : tmplBond.end\n }\n const { angle, scale } = utils.mergeBondsParams(struct, bond, tmpl, bondAtoms)\n\n const frid = struct.getBondFragment(bid)\n\n /* For merge */\n const pasteItems: any = {\n // only atoms and bonds now\n atoms: [],\n bonds: []\n }\n /* ----- */\n\n tmpl.atoms.forEach((atom, id) => {\n const attrs: any = Atom.getAttrHash(atom)\n attrs.fragment = frid\n if (id === tmplBond.begin || id === tmplBond.end) {\n action.mergeWith(fromAtomsAttrs(restruct, atomsMap.get(id), attrs, true))\n return\n }\n\n const v = Vec2.diff(atom.pp, tmplBegin.pp)\n .rotate(angle)\n .scaled(scale)\n .add(struct.atoms.get(bond.begin).pp)\n const mergeA = closest.atom(restruct, v, null, 0.1)\n\n if (mergeA === null) {\n const operation = new AtomAdd(attrs, v).perform(restruct) as AtomAdd\n action.addOp(operation)\n atomsMap.set(id, operation.data.aid)\n pasteItems.atoms.push(operation.data.aid)\n } else {\n atomsMap.set(id, mergeA.id)\n\n action.mergeWith(fromAtomsAttrs(restruct, atomsMap.get(id), attrs, true))\n // TODO [RB] need to merge fragments?\n }\n })\n mergeSgroups(action, restruct, pasteItems.atoms, bond.begin)\n\n tmpl.bonds.forEach(tBond => {\n const existId = struct.findBondId(\n atomsMap.get(tBond.begin),\n atomsMap.get(tBond.end)\n )\n if (existId === null) {\n const operation = new BondAdd(\n atomsMap.get(tBond.begin),\n atomsMap.get(tBond.end),\n tBond\n ).perform(restruct) as BondAdd\n action.addOp(operation)\n\n pasteItems.bonds.push(operation.data.bid)\n } else {\n action.mergeWith(fromBondsAttrs(restruct, existId, tmplBond, true))\n }\n })\n\n if (pasteItems.atoms.length) {\n action.addOp(\n new CalcImplicitH([bond.begin, bond.end, ...pasteItems.atoms]).perform(\n restruct\n )\n )\n }\n\n if (pasteItems.bonds.length) {\n action.mergeWith(\n fromBondStereoUpdate(\n restruct,\n restruct.molecule.bonds.get(pasteItems.bonds[0])\n )\n )\n }\n\n action.operations.reverse()\n\n return [action, pasteItems]\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { TextCreate, TextDelete, TextUpdate } from '../operations'\n\nimport { Action } from './action'\nimport { ReStruct } from '../../render'\nimport { Vec2 } from 'domain/entities'\n\nexport function fromTextCreation(\n restruct: ReStruct,\n content: string,\n position: Vec2\n) {\n const action = new Action()\n action.addOp(new TextCreate(content, position))\n return action.perform(restruct)\n}\n\nexport function fromTextUpdating(\n restruct: ReStruct,\n id: number,\n content: string\n) {\n const action = new Action()\n action.addOp(new TextUpdate(id, content))\n return action.perform(restruct)\n}\n\nexport function fromTextDeletion(restruct: ReStruct, id: number) {\n const action = new Action()\n\n action.addOp(new TextDelete(id))\n\n return action.perform(restruct)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const SgContexts = {\n Fragment: 'Fragment',\n Multifragment: 'Multifragment',\n Bond: 'Bond',\n Atom: 'Atom',\n Group: 'Group'\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport utils from './shared/utils'\n\n// TODO: delete it\nexport const fracAngle = utils.fracAngle\nexport * from './operations'\nexport * from './actions'\nexport * from './shared/constants'\nexport * from './editor.types'\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n FormatterFactory,\n SupportedFormat,\n identifyStructFormat\n} from './formatters'\nimport { GenerateImageOptions, StructService } from 'domain/services'\n\nimport { Editor } from './editor'\nimport { MolfileFormat } from 'domain/serializers'\nimport { Struct } from 'domain/entities'\nimport assert from 'assert'\n\nfunction parseStruct(structStr: string, structService: StructService) {\n const format = identifyStructFormat(structStr)\n const factory = new FormatterFactory(structService)\n\n const service = factory.create(format)\n return service.getStructureFromStringAsync(structStr)\n}\n\nfunction getStructure(\n structureFormat: SupportedFormat = 'rxn',\n formatterFactory: FormatterFactory,\n struct: Struct\n): Promise {\n const formatter = formatterFactory.create(structureFormat)\n return formatter.getStructureFromStructAsync(struct)\n}\n\nexport class Ketcher {\n #structService: StructService\n #formatterFactory: FormatterFactory\n #editor: Editor\n\n get editor(): Editor {\n return this.#editor\n }\n\n constructor(\n editor: Editor,\n structService: StructService,\n formatterFactory: FormatterFactory\n ) {\n assert(editor != null)\n assert(structService != null)\n assert(formatterFactory != null)\n\n this.#editor = editor\n this.#structService = structService\n this.#formatterFactory = formatterFactory\n }\n\n getSmiles(isExtended: boolean = false): Promise {\n const format: SupportedFormat = isExtended ? 'smilesExt' : 'smiles'\n return getStructure(format, this.#formatterFactory, this.editor.struct())\n }\n\n async getMolfile(molfileFormat: MolfileFormat = 'v2000'): Promise {\n if (this.containsReaction()) {\n throw Error(\n 'The structure cannot be saved as *.MOL due to reaction arrrows.'\n )\n }\n\n const format: SupportedFormat =\n molfileFormat === 'v3000' ? 'molV3000' : 'mol'\n const molfile = await getStructure(\n format,\n this.#formatterFactory,\n this.#editor.struct()\n )\n\n return molfile\n }\n\n async getRxn(molfileFormat: MolfileFormat = 'v2000'): Promise {\n if (!this.containsReaction()) {\n throw Error(\n 'The structure cannot be saved as *.RXN: there is no reaction arrows.'\n )\n }\n const format: SupportedFormat =\n molfileFormat === 'v3000' ? 'rxnV3000' : 'rxn'\n const rxnfile = await getStructure(\n format,\n this.#formatterFactory,\n this.#editor.struct()\n )\n\n return rxnfile\n }\n\n getKet(): Promise {\n return getStructure('ket', this.#formatterFactory, this.#editor.struct())\n }\n\n getSmarts(): Promise {\n return getStructure('smarts', this.#formatterFactory, this.#editor.struct())\n }\n\n getCml(): Promise {\n return getStructure('cml', this.#formatterFactory, this.#editor.struct())\n }\n\n getInchi(withAuxInfo = false): Promise {\n return getStructure(\n withAuxInfo ? 'inChIAuxInfo' : 'inChI',\n this.#formatterFactory,\n this.#editor.struct()\n )\n }\n\n containsReaction(): boolean {\n return this.editor.struct().hasRxnArrow()\n }\n\n async setMolecule(structStr: string): Promise {\n assert(typeof structStr === 'string')\n\n const struct: Struct = await parseStruct(structStr, this.#structService)\n this.#editor.struct(struct)\n }\n\n async addFragment(fragment: string): Promise {\n assert(typeof fragment === 'string')\n\n throw Error('not implemented yet')\n }\n\n async generateImage(\n data: string,\n options: GenerateImageOptions = { outputFormat: 'png' }\n ): Promise {\n let meta = ''\n\n switch (options.outputFormat) {\n case 'svg':\n meta = 'image/svg+xml'\n break\n\n case 'png':\n default:\n meta = 'image/png'\n options.outputFormat = 'png'\n }\n\n const base64 = await this.#structService.generateImageAsBase64(\n data,\n options\n )\n const byteCharacters = atob(base64)\n const byteNumbers = new Array(byteCharacters.length)\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i)\n }\n const byteArray = new Uint8Array(byteNumbers)\n const blob = new Blob([byteArray], { type: meta })\n return blob\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n StructService,\n StructServiceOptions,\n StructServiceProvider\n} from 'domain/services'\n\nimport { Editor } from 'application/editor'\nimport { FormatterFactory } from 'application/formatters'\nimport { Ketcher } from './ketcher'\nimport assert from 'assert'\n\nconst DefaultStructServiceOptions = {\n 'smart-layout': true,\n 'ignore-stereochemistry-errors': true,\n 'mass-skip-error-on-pseudoatoms': false,\n 'gross-formula-add-rsites': true,\n 'aromatize-skip-superatoms': true\n}\n\nexport class KetcherBuilder {\n #structServiceProvider?: StructServiceProvider\n\n withStructServiceProvider(\n structServiceProvider: StructServiceProvider\n ): KetcherBuilder {\n this.#structServiceProvider = structServiceProvider\n return this\n }\n\n build(editor: Editor, serviceOptions?: StructServiceOptions): Ketcher {\n assert(editor != null)\n assert(this.#structServiceProvider != null)\n\n const mergedServiceOptions: StructServiceOptions = {\n ...DefaultStructServiceOptions,\n ...serviceOptions\n }\n const structService: StructService =\n this.#structServiceProvider!.createStructService(mergedServiceOptions)\n const ketcher = new Ketcher(\n editor,\n structService,\n new FormatterFactory(structService)\n )\n ketcher[this.#structServiceProvider.mode] = true\n\n return ketcher\n }\n}\n","import 'miew/dist/Miew.min.css'\nimport 'ketcher-react/dist/index.css'\n\nimport { ButtonsConfig, Editor } from 'ketcher-react'\nimport { Ketcher, RemoteStructServiceProvider } from 'ketcher-core'\n\nimport ErrorModal from './ErrorModal/ErrorModal'\n// @ts-ignore\nimport Miew from 'miew'\nimport { useState } from 'react'\n\nconst getHiddenButtonsConfig = (): ButtonsConfig => {\n const searchParams = new URLSearchParams(window.location.search)\n const hiddenButtons = searchParams.get('hiddenControls')\n\n if (!hiddenButtons) return {}\n\n return hiddenButtons.split(',').reduce((acc, button) => {\n if (button) acc[button] = { hidden: true }\n\n return acc\n }, {})\n}\n\n;(global as any).Miew = Miew\n\nlet structServiceProvider: any = new RemoteStructServiceProvider(\n process.env.API_PATH || process.env.REACT_APP_API_PATH!\n)\nif (process.env.MODE === 'standalone') {\n const { StandaloneStructServiceProvider } = require('ketcher-standalone')\n structServiceProvider = new StandaloneStructServiceProvider()\n}\n\nconst App = () => {\n const hiddenButtonsConfig = getHiddenButtonsConfig()\n const [hasError, setHasError] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n\n return (\n <>\n {\n setHasError(true)\n setErrorMessage(message.toString())\n }}\n buttons={hiddenButtonsConfig}\n staticResourcesUrl={process.env.PUBLIC_URL}\n structServiceProvider={structServiceProvider}\n onInit={(ketcher: Ketcher) => {\n ;(global as any).ketcher = ketcher\n }}\n />\n {hasError && (\n setHasError(false)} />\n )}\n \n )\n}\n\nexport default App\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n InfoResult,\n StructService,\n StructServiceOptions,\n StructServiceProvider\n} from 'ketcher-core'\n\ntype Api = StructService & Promise\n\n// todo: remove\nfunction createApi(\n structServiceProvider: StructServiceProvider,\n defaultOptions: StructServiceOptions\n): Api {\n const structService =\n structServiceProvider.createStructService(defaultOptions)\n const info = structService.info()\n\n return Object.assign(info, {\n info: structService.info.bind(structService),\n convert: structService.convert.bind(structService),\n layout: structService.layout.bind(structService),\n clean: structService.clean.bind(structService),\n aromatize: structService.aromatize.bind(structService),\n dearomatize: structService.dearomatize.bind(structService),\n calculateCip: structService.calculateCip.bind(structService),\n automap: structService.automap.bind(structService),\n check: structService.check.bind(structService),\n calculate: structService.calculate.bind(structService),\n recognize: structService.recognize.bind(structService),\n generateImageAsBase64:\n structService.generateImageAsBase64.bind(structService)\n })\n}\n\nexport default createApi\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Ketcher } from 'ketcher-core'\nimport React from 'react'\n\nexport interface IAppContext {\n getKetcherInstance: () => Ketcher\n}\n\nconst appContext = React.createContext({} as IAppContext)\n\nexport default appContext\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport React from 'react'\n\nexport interface IErrorsContext {\n errorHandler: (message: string) => void\n}\n\nconst errorsContext = React.createContext({} as IErrorsContext)\n\nexport default errorsContext\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport React from 'react'\n\nexport interface ISettingsContext {\n staticResourcesUrl: string\n}\n\nconst settingsContext = React.createContext(\n {} as ISettingsContext\n)\n\nexport default settingsContext\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport React from 'react'\n\nconst formContext = React.createContext(null)\n\nexport default formContext\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const basicAtoms = ['H', 'C', 'N', 'O', 'S', 'P', 'F', 'Cl', 'Br', 'I']\n\nexport const atomCuts = {\n H: 'h',\n C: 'c',\n N: 'n',\n O: 'o',\n S: 's',\n P: 'p',\n F: 'f',\n Cl: 'Shift+c',\n Br: 'Shift+b',\n I: 'i',\n A: 'a'\n}\n\nexport default Object.keys(atomCuts).reduce((res, label) => {\n res[`atom-${label.toLowerCase()}`] = {\n title: `Atom ${label}`,\n shortcut: atomCuts[label],\n action: {\n tool: 'atom',\n opts: { label }\n }\n }\n return res\n}, {})\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { KetSerializer, MolSerializer } from 'ketcher-core'\n\nexport default function copyAs(type) {\n const state = global.currentState\n const editor = state.editor\n const struct = editor.structSelected()\n const errorHandler = editor.errorHandler\n let serializer\n try {\n switch (type) {\n case 'mol': {\n serializer = new MolSerializer()\n break\n }\n case 'ket': {\n serializer = new KetSerializer()\n break\n }\n default: {\n serializer = new KetSerializer()\n break\n }\n }\n\n const simpleObjectOrText = Boolean(\n struct.simpleObjects.size || struct.texts.size\n )\n\n if (simpleObjectOrText && serializer instanceof MolSerializer) {\n errorHandler(\n 'This feature is not available for Simple objects and Text objects'\n )\n return null\n }\n\n const structData = serializer.serialize(struct)\n\n if (window.clipboardData) {\n window.clipboardData.setData('text', structData)\n } else {\n navigator.clipboard.writeText(structData)\n }\n } catch {\n errorHandler('This feature is not available in your browser')\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FormatterFactory, Ketcher } from 'ketcher-core'\n\nasync function copyImageToClipboard() {\n const state = global.currentState\n const editor = state.editor\n const server = state.server\n const options = state.options\n const struct = editor.structSelected()\n const errorHandler = editor.errorHandler\n\n try {\n const factory = new FormatterFactory(server)\n const service = factory.create('mol', options)\n const structStr = await service.getStructureFromStructAsync(struct)\n const ketcher = new Ketcher(editor, server, {}, factory)\n const image = await ketcher.generateImage(structStr, {\n outputFormat: 'png',\n backgroundColor: '255, 255, 255'\n })\n const item = new ClipboardItem({ [image.type]: image }) // eslint-disable-line no-undef\n await navigator.clipboard.write([item])\n } catch {\n errorHandler('This feature is not available in your browser')\n }\n}\n\nexport default copyImageToClipboard\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport default function isHidden(\n options: { buttons?: {} },\n buttonName: string\n): boolean {\n return Boolean(options.buttons?.[buttonName]?.hidden)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializer } from 'ketcher-core'\nimport isHidden from './isHidden'\n\nconst debugObj = {\n // original: for dev purposes\n 'force-update': {\n shortcut: 'Ctrl+Shift+r',\n action: editor => {\n editor.update(true)\n },\n hidden: options => isHidden(options, 'force-update')\n },\n 'qs-serialize': {\n shortcut: 'Alt+Shift+r',\n action: editor => {\n const molSerializer = new MolSerializer()\n const molStr = molSerializer.serialize(editor.struct())\n const molQs = 'mol=' + encodeURIComponent(molStr).replace(/%20/g, '+')\n const qs = document.location.search\n document.location.search = !qs\n ? '?' + molQs // eslint-disable-line\n : qs.search('mol=') === -1\n ? qs + '&' + molQs\n : qs.replace(/mol=[^&$]*/, molQs)\n }\n },\n hidden: options => isHidden(options, 'qs-serialize')\n}\n\nexport default debugObj\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Component, createRef } from 'react'\nimport clsx from 'clsx'\nimport classes from './cliparea.module.less'\n\nconst ieCb = window.clipboardData\n\nclass ClipArea extends Component {\n constructor(props) {\n super(props)\n this.textAreaRef = createRef()\n }\n\n componentDidMount() {\n const el = this.textAreaRef.current\n this.target = this.props.target || el.parentNode\n\n this.listeners = {\n mouseup: event => {\n if (\n el === event.target ||\n (!isActiveElement(event.target) && this.props.focused())\n )\n autofocus(el)\n },\n mousedown: event => {\n if (event.shiftKey && !isActiveElement(event.target))\n event.preventDefault()\n },\n copy: event => {\n if (this.props.focused() && this.props.onCopy) {\n const data = this.props.onCopy()\n\n if (data) copy(event.clipboardData, data)\n\n event.preventDefault()\n }\n },\n cut: event => {\n if (this.props.focused() && this.props.onCut) {\n const data = this.props.onCut()\n\n if (data) copy(event.clipboardData, data)\n\n event.preventDefault()\n }\n },\n paste: event => {\n if (this.props.focused() && this.props.onPaste) {\n const data = paste(event.clipboardData, this.props.formats)\n\n if (data) this.props.onPaste(data)\n\n event.preventDefault()\n }\n }\n }\n\n Object.keys(this.listeners).forEach(en => {\n this.target.addEventListener(en, this.listeners[en])\n })\n }\n\n shouldComponentUpdate() {\n return false\n }\n\n componentWillUnmount() {\n Object.keys(this.listeners).forEach(en => {\n this.target.removeEventListener(en, this.listeners[en])\n })\n }\n\n render() {\n return (\n \n )\n }\n}\n\nfunction isActiveElement(el) {\n if (el.tagName === 'INPUT' && el.type === 'button') return false\n return ['INPUT', 'SELECT', 'TEXTAREA', 'OPTION', 'LABEL'].includes(el.tagName)\n}\n\nfunction autofocus(cliparea) {\n cliparea.value = ' '\n cliparea.focus()\n cliparea.select()\n}\n\nfunction copy(cb, data) {\n if (!cb && ieCb) {\n ieCb.setData('text', data['text/plain'])\n } else {\n let curFmt = null\n cb.setData('text/plain', data['text/plain'])\n try {\n Object.keys(data).forEach(fmt => {\n curFmt = fmt\n cb.setData(fmt, data[fmt])\n })\n } catch (ex) {\n console.info(`Could not write exact type ${curFmt}`)\n }\n }\n}\n\nfunction paste(cb, formats) {\n let data = {}\n if (!cb && ieCb) {\n data['text/plain'] = ieCb.getData('text')\n } else {\n data['text/plain'] = cb.getData('text/plain')\n data = formats.reduce((res, fmt) => {\n const d = cb.getData(fmt)\n if (d) res[fmt] = d\n return res\n }, data)\n }\n return data\n}\n\nexport const actions = ['cut', 'copy', 'paste']\n\nexport function exec(action) {\n let enabled = document.queryCommandSupported(action)\n if (enabled) {\n try {\n enabled = document.execCommand(action) || window.ClipboardEvent || ieCb\n } catch (ex) {\n // FF < 41\n enabled = false\n }\n }\n return enabled\n}\n\nexport default ClipArea\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { StereLabelStyleType, StereoColoringType } from 'ketcher-core'\nimport jsonschema, { Schema } from 'jsonschema'\n\ntype ExtendedSchema = Schema & { enumNames?: Array; default?: any }\n\nconst editor: {\n resetToSelect: ExtendedSchema\n rotationStep: ExtendedSchema\n} = {\n resetToSelect: {\n title: 'Reset to Select Tool',\n enum: [true, 'paste', false],\n enumNames: ['on', 'After Paste', 'off'],\n default: 'paste'\n },\n rotationStep: {\n title: 'Rotation Step, º',\n type: 'integer',\n minimum: 1,\n maximum: 90,\n default: 15\n }\n}\n\nconst render: {\n showValenceWarnings: ExtendedSchema\n atomColoring: ExtendedSchema\n showStereoFlags: ExtendedSchema\n stereoLabelStyle: ExtendedSchema\n colorOfAbsoluteCenters: ExtendedSchema\n colorOfAndCenters: ExtendedSchema\n colorOfOrCenters: ExtendedSchema\n colorStereogenicCenters: ExtendedSchema\n autoFadeOfStereoLabels: ExtendedSchema\n absFlagLabel: ExtendedSchema\n andFlagLabel: ExtendedSchema\n mixedFlagLabel: ExtendedSchema\n orFlagLabel: ExtendedSchema\n font: ExtendedSchema\n fontsz: ExtendedSchema\n fontszsub: ExtendedSchema\n carbonExplicitly: ExtendedSchema\n showCharge: ExtendedSchema\n showValence: ExtendedSchema\n showHydrogenLabels: ExtendedSchema\n aromaticCircle: ExtendedSchema\n doubleBondWidth: ExtendedSchema\n bondThickness: ExtendedSchema\n stereoBondWidth: ExtendedSchema\n} = {\n showValenceWarnings: {\n title: 'Show valence warnings',\n type: 'boolean',\n default: true\n },\n atomColoring: {\n title: 'Atom coloring',\n type: 'boolean',\n default: true\n },\n showStereoFlags: {\n title: 'Show the Stereo flags',\n type: 'boolean',\n default: true\n },\n stereoLabelStyle: {\n title: 'Label display at stereogenic centers',\n enum: [\n StereLabelStyleType.IUPAC,\n StereLabelStyleType.Classic,\n StereLabelStyleType.On,\n StereLabelStyleType.Off\n ],\n enumNames: ['IUPAC style', 'Classic', 'On', 'Off'],\n default: StereLabelStyleType.IUPAC\n },\n colorOfAbsoluteCenters: {\n title: ' Color of Absolute Center',\n type: 'string',\n default: '#ff0000'\n },\n colorOfAndCenters: {\n title: 'Color of AND Centers',\n type: 'string',\n default: '#0000cd'\n },\n colorOfOrCenters: {\n title: 'Color of OR Centers',\n type: 'string',\n default: '#228b22'\n },\n colorStereogenicCenters: {\n title: 'Color stereogenic centers',\n enum: [\n StereoColoringType.LabelsOnly,\n StereoColoringType.BondsOnly,\n StereoColoringType.LabelsAndBonds,\n StereoColoringType.Off\n ],\n enumNames: ['Labels Only', 'Bonds Only', 'Labels And Bonds', 'Off'],\n default: StereoColoringType.LabelsOnly\n },\n autoFadeOfStereoLabels: {\n title: 'Auto fade And/Or center labels',\n type: 'boolean',\n default: true\n },\n absFlagLabel: {\n title: 'Text of Absolute flag',\n type: 'String',\n default: 'ABS (Chiral)'\n },\n andFlagLabel: {\n title: 'Text of AND flag',\n type: 'String',\n default: 'AND Enantiomer'\n },\n mixedFlagLabel: {\n title: 'Text of Mixed flag',\n type: 'String',\n default: 'Mixed'\n },\n orFlagLabel: {\n title: 'Text of OR flag',\n type: 'String',\n default: 'OR Enantiomer'\n },\n font: {\n title: 'Font',\n type: 'string',\n default: '30px Arial'\n },\n fontsz: {\n title: 'Font size',\n type: 'integer',\n default: 13,\n minimum: 1,\n maximum: 96\n },\n fontszsub: {\n title: 'Sub font size',\n type: 'integer',\n default: 13,\n minimum: 1,\n maximum: 96\n },\n // Atom\n carbonExplicitly: {\n title: 'Display carbon explicitly',\n type: 'boolean',\n default: false\n },\n showCharge: {\n title: 'Display charge',\n type: 'boolean',\n default: true\n },\n showValence: {\n title: 'Display valence',\n type: 'boolean',\n default: true\n },\n showHydrogenLabels: {\n title: 'Show hydrogen labels',\n enum: ['off', 'Hetero', 'Terminal', 'Terminal and Hetero', 'on'],\n default: 'on'\n },\n // Bonds\n aromaticCircle: {\n title: 'Aromatic Bonds as circle',\n type: 'boolean',\n default: true\n },\n doubleBondWidth: {\n title: 'Double bond width',\n type: 'integer',\n default: 6,\n minimum: 1,\n maximum: 96\n },\n bondThickness: {\n title: 'Bond thickness',\n type: 'integer',\n default: 2,\n minimum: 1,\n maximum: 96\n },\n stereoBondWidth: {\n title: 'Stereo (Wedge) bond width',\n type: 'integer',\n default: 6,\n minimum: 1,\n maximum: 96\n }\n}\n\nconst server: {\n 'smart-layout': ExtendedSchema\n 'ignore-stereochemistry-errors': ExtendedSchema\n 'mass-skip-error-on-pseudoatoms': ExtendedSchema\n 'gross-formula-add-rsites': ExtendedSchema\n 'gross-formula-add-isotopes': ExtendedSchema\n} = {\n 'smart-layout': {\n title: 'Smart-layout',\n type: 'boolean',\n default: true\n },\n 'ignore-stereochemistry-errors': {\n title: 'Ignore stereochemistry errors',\n type: 'boolean',\n default: true\n },\n 'mass-skip-error-on-pseudoatoms': {\n title: 'Ignore pseudoatoms at mass',\n type: 'boolean',\n default: false\n },\n 'gross-formula-add-rsites': {\n title: 'Add Rsites at mass calculation',\n type: 'boolean',\n default: true\n },\n 'gross-formula-add-isotopes': {\n title: 'Add Isotopes at mass calculation',\n type: 'boolean',\n default: true\n }\n}\n\nexport const SERVER_OPTIONS = Object.keys(server)\n\nconst debug: {\n showAtomIds: ExtendedSchema\n showBondIds: ExtendedSchema\n showHalfBondIds: ExtendedSchema\n showLoopIds: ExtendedSchema\n} = {\n showAtomIds: {\n title: 'Show atom Ids',\n type: 'boolean',\n default: false\n },\n showBondIds: {\n title: 'Show bonds Ids',\n type: 'boolean',\n default: false\n },\n showHalfBondIds: {\n title: 'Show half bonds Ids',\n type: 'boolean',\n default: false\n },\n showLoopIds: {\n title: 'Show loop Ids',\n type: 'boolean',\n default: false\n }\n}\n\nconst miew: {\n miewMode: ExtendedSchema\n miewTheme: ExtendedSchema\n miewAtomLabel: ExtendedSchema\n} = {\n miewMode: {\n title: 'Display mode',\n enum: ['LN', 'BS', 'LC'],\n enumNames: ['Lines', 'Balls and Sticks', 'Licorice'],\n default: 'LN'\n },\n miewTheme: {\n title: 'Background color',\n enum: ['light', 'dark'],\n enumNames: ['Light', 'Dark'],\n default: 'light'\n },\n miewAtomLabel: {\n title: 'Label coloring',\n enum: ['no', 'bright', 'blackAndWhite', 'black'],\n enumNames: ['No', 'Bright', 'Black and White', 'Black'],\n default: 'bright'\n }\n}\n\nexport const MIEW_OPTIONS = Object.keys(miew)\n\nconst optionsSchema: ExtendedSchema = {\n title: 'Settings',\n type: 'object',\n required: [],\n properties: {\n ...editor,\n ...render,\n ...server,\n ...debug,\n ...miew\n }\n}\n\nexport default optionsSchema\n\nexport function getDefaultOptions(): Record {\n if (!optionsSchema.properties) return {}\n\n return Object.keys(optionsSchema.properties).reduce((res, prop) => {\n res[prop] = (optionsSchema.properties![prop] as ExtendedSchema).default\n return res\n }, {})\n}\n\nexport function validation(settings): Record | null {\n if (typeof settings !== 'object' || settings === null) return null\n\n const v = new jsonschema.Validator()\n const { errors } = v.validate(settings, optionsSchema)\n const errProps = errors.map(err => err.property.split('.')[1])\n\n return Object.keys(settings).reduce((res, prop) => {\n if (!optionsSchema.properties) return res\n\n if (optionsSchema.properties[prop] && errProps.indexOf(prop) === -1)\n res[prop] = settings[prop]\n\n return res\n }, {})\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\n/* local storage */\nexport const storage = {\n warningMessage:\n 'Your changes will be lost after the tab closing. See Help (Note 2).',\n isAvailable() {\n try {\n return localStorage\n } catch (ex) {\n return false\n }\n },\n getItem(key) {\n let item = null\n try {\n item = JSON.parse(localStorage.getItem(key))\n } catch (ex) {\n console.info('LocalStorage:', ex.name)\n }\n return item\n },\n setItem(key, data) {\n let isSet = null\n try {\n localStorage.setItem(key, JSON.stringify(data))\n isSet = true\n } catch (ex) {\n console.info('LocalStorage:', ex.name)\n isSet = false\n }\n return isSet\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n SERVER_OPTIONS,\n getDefaultOptions,\n validation\n} from '../../data/schema/options-schema'\n\nimport { pick } from 'lodash/fp'\nimport { storage } from '../../storage-ext'\n\nexport const initOptionsState = {\n app: {\n server: false,\n templates: false,\n functionalGroups: false\n },\n analyse: {\n values: null,\n roundWeight: 3,\n roundMass: 3,\n roundElAnalysis: 1\n },\n check: {\n checkOptions: [\n 'valence',\n 'radicals',\n 'pseudoatoms',\n 'stereo',\n 'query',\n 'overlapping_atoms',\n 'overlapping_bonds',\n 'rgroups',\n 'chiral',\n '3d',\n 'chiral_flag'\n ]\n },\n recognize: {\n file: null,\n structStr: null,\n fragment: false,\n version: null\n },\n settings: Object.assign(\n getDefaultOptions(),\n validation(storage.getItem('ketcher-opts'))\n ),\n getServerSettings() {\n return pick(SERVER_OPTIONS, this.settings)\n }\n}\n\nexport function appUpdate(data) {\n return dispatch => {\n dispatch({ type: 'APP_OPTIONS', data })\n dispatch({ type: 'UPDATE' })\n }\n}\n\n/* SETTINGS */\nexport function saveSettings(newSettings) {\n storage.setItem('ketcher-opts', newSettings)\n return {\n type: 'SAVE_SETTINGS',\n data: newSettings\n }\n}\n\n/* ANALYZE */\nexport function changeRound(roundName, value) {\n return {\n type: 'CHANGE_ANALYSE',\n data: { [roundName]: value }\n }\n}\n\n/* RECOGNIZE */\nconst recognizeActions = [\n 'SET_RECOGNIZE_STRUCT',\n 'CHANGE_RECOGNIZE_FILE',\n 'CHANGE_IMAGO_VERSION',\n 'IS_FRAGMENT_RECOGNIZE'\n]\n\nexport function setStruct(str) {\n return {\n type: 'SET_RECOGNIZE_STRUCT',\n data: { structStr: str }\n }\n}\n\nexport function changeVersion(version) {\n return {\n type: 'CHANGE_IMAGO_VERSION',\n data: { version }\n }\n}\n\nexport function changeImage(file) {\n return {\n type: 'CHANGE_RECOGNIZE_FILE',\n data: {\n file,\n structStr: null\n }\n }\n}\n\nexport function shouldFragment(isFrag) {\n return {\n type: 'IS_FRAGMENT_RECOGNIZE',\n data: { fragment: isFrag }\n }\n}\n\n/* CHECK */\nexport function checkOpts(data) {\n return {\n type: 'SAVE_CHECK_OPTS',\n data\n }\n}\n\n/* REDUCER */\nfunction optionsReducer(state = {}, action) {\n const { type, data } = action\n\n if (type === 'APP_OPTIONS')\n return { ...state, app: { ...state.app, ...data } }\n\n if (type === 'SAVE_SETTINGS') return { ...state, settings: data }\n\n if (type === 'SAVE_CHECK_OPTS') return { ...state, check: data }\n\n if (type === 'CHANGE_ANALYSE')\n return { ...state, analyse: { ...state.analyse, ...data, loading: false } }\n\n if (type === 'ANALYSE_LOADING')\n return { ...state, analyse: { ...state.analyse, loading: true } }\n\n if (recognizeActions.includes(type))\n return { ...state, recognize: { ...state.recognize, ...data } }\n return state\n}\n\nexport default optionsReducer\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\n/* schema utils */\nfunction constant(schema, prop) {\n const desc = schema.properties[prop]\n return desc.constant || desc.enum[0] // see https://git.io/v6hyP\n}\n\nexport function mapOf(schema, prop) {\n console.assert(schema.oneOf)\n return schema.oneOf.reduce((res, desc) => {\n res[constant(desc, prop)] = desc\n return res\n }, {})\n}\n\nexport function selectListOf(schema, prop) {\n const desc = schema.properties && schema.properties[prop]\n if (desc) {\n return desc.enum.map((value, i) => {\n const title = desc.enumNames && desc.enumNames[i]\n return title ? { title, value } : value\n })\n }\n return schema.oneOf.map(ds =>\n !ds.title\n ? constant(ds, prop)\n : {\n title: ds.title,\n value: constant(ds, prop)\n }\n )\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { mapOf } from './schema-helper'\n\nconst radioButtonsSchema = {\n enum: ['Absolute', 'Relative', 'Attached'],\n default: 'Absolute'\n}\n\nconst contextSchema = {\n title: 'Context',\n enum: ['Fragment', 'Multifragment', 'Bond', 'Atom', 'Group'],\n default: 'Fragment'\n}\n\nconst sData = {\n Fragment: {\n title: 'Fragment',\n type: 'Object',\n oneOf: [\n {\n key: 'FRG_STR',\n title: 'MDLBG_FRAGMENT_STEREO',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_FRAGMENT_STEREO'],\n default: 'MDLBG_FRAGMENT_STEREO'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: [\n 'abs',\n '(+)-enantiomer',\n '(-)-enantiomer',\n 'racemate',\n 'steric',\n 'rel',\n 'R(a)',\n 'S(a)',\n 'R(p)',\n 'S(p)'\n ]\n },\n default: ['abs']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n },\n {\n key: 'FRG_COEFF',\n title: 'MDLBG_FRAGMENT_COEFFICIENT',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_FRAGMENT_COEFFICIENT'],\n default: 'MDLBG_FRAGMENT_COEFFICIENT'\n },\n fieldValue: {\n title: 'Field value',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, specify field name'\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n },\n {\n key: 'FRG_CHRG',\n title: 'MDLBG_FRAGMENT_CHARGE',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_FRAGMENT_CHARGE'],\n default: 'MDLBG_FRAGMENT_CHARGE'\n },\n fieldValue: {\n title: 'Field value',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, specify field name'\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n },\n {\n key: 'FRG_RAD',\n title: 'MDLBG_FRAGMENT_RADICALS',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_FRAGMENT_RADICALS'],\n default: 'MDLBG_FRAGMENT_RADICALS'\n },\n fieldValue: {\n title: 'Field value',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, specify field name'\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n }\n ]\n },\n Multifragment: {\n title: 'Multifragment',\n type: 'Object',\n oneOf: [\n {\n key: 'MLT_FRG',\n title: 'KETCHER_MULTIPLE_FRAGMENT',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['KETCHER_MULTIPLE_FRAGMENT'],\n default: 'KETCHER_MULTIPLE_FRAGMENT'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: [\n 'aerosol',\n 'alloy',\n 'catenane',\n 'complex',\n 'composite',\n 'co-polymer',\n 'emulsion',\n 'host-guest complex',\n 'mixture',\n 'rotaxane',\n 'suspension'\n ]\n },\n default: ['aerosol']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n }\n ]\n },\n Bond: {\n title: 'Bond',\n type: 'Object',\n oneOf: [\n {\n key: 'SB_STR',\n title: 'MDLBG_STEREO_KEY',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_STEREO_KEY'],\n default: 'MDLBG_STEREO_KEY'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: [\n 'erythro',\n 'threo',\n 'alpha',\n 'beta',\n 'endo',\n 'exo',\n 'anti',\n 'syn',\n 'ECL',\n 'STG'\n ]\n },\n default: ['erythro']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n },\n {\n key: 'SB_BND',\n title: 'MDLBG_BOND_KEY',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_BOND_KEY'],\n default: 'MDLBG_BOND_KEY'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: ['Value=4']\n },\n default: ['Value=4']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n }\n ]\n },\n Atom: {\n title: 'Atom',\n type: 'Object',\n oneOf: [\n {\n key: 'AT_STR',\n title: 'MDLBG_STEREO_KEY',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_STEREO_KEY'],\n default: 'MDLBG_STEREO_KEY'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: [\n 'RS',\n 'SR',\n 'P-3',\n 'P-3-PI',\n 'SP-4',\n 'SP-4-PI',\n 'T-4',\n 'T-4-PI',\n 'SP-5',\n 'SP-5-PI',\n 'TB-5',\n 'TB-5-PI',\n 'OC-6',\n 'TP-6',\n 'PB-7',\n 'CU-8',\n 'SA-8',\n 'DD-8',\n 'HB-9',\n 'TPS-9'\n ]\n },\n default: ['RS']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n }\n ]\n },\n Group: {\n title: 'Group',\n type: 'Object',\n oneOf: [\n {\n key: 'GRP_STR',\n title: 'MDLBG_STEREO_KEY',\n properties: {\n type: { enum: ['DAT'] },\n fieldName: {\n title: 'Field name',\n enum: ['MDLBG_STEREO_KEY'],\n default: 'MDLBG_STEREO_KEY'\n },\n fieldValue: {\n title: 'Field value',\n type: 'array',\n items: {\n enum: ['cis', 'trans']\n },\n default: ['cis']\n },\n radiobuttons: radioButtonsSchema\n },\n required: ['fieldName', 'fieldValue', 'radiobuttons']\n }\n ]\n }\n}\n\nexport const sdataCustomSchema = {\n key: 'Custom',\n properties: {\n type: { enum: ['DAT'] },\n context: {\n title: 'Context',\n enum: ['Fragment', 'Multifragment', 'Bond', 'Atom', 'Group'],\n default: 'Fragment'\n },\n fieldName: {\n title: 'Field name',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, specify field name'\n },\n fieldValue: {\n title: 'Field value',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, specify field value'\n },\n radiobuttons: {\n enum: ['Absolute', 'Relative', 'Attached'],\n default: 'Absolute'\n }\n },\n required: ['context', 'fieldName', 'fieldValue', 'radiobuttons']\n}\n\nexport const sdataSchema = Object.keys(sData).reduce((acc, title) => {\n acc[title] = mapOf(sData[title], 'fieldName')\n Object.keys(acc[title]).forEach(fieldName => {\n acc[title][fieldName].properties.context = contextSchema\n })\n return acc\n}, {})\n\n/**\n * Returns first key of passed object\n * @param obj { object }\n */\nfunction firstKeyOf(obj) {\n return Object.keys(obj)[0]\n}\n\n/**\n * Returns schema default values. Depends on passed arguments:\n * pass schema only -> returns default context\n * pass schema & context -> returns default fieldName\n * pass schema & context & fieldName -> returns default fieldValue\n * @param context? { string }\n * @param fieldName? { string }\n * @returns { string }\n */\nexport function getSdataDefault(context, fieldName) {\n if (!context && !fieldName) return firstKeyOf(sdataSchema)\n\n if (!fieldName) return firstKeyOf(sdataSchema[context])\n\n return sdataSchema[context][fieldName]\n ? sdataSchema[context][fieldName].properties.fieldValue.default\n : ''\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { getSdataDefault, sdataSchema } from '../../data/schema/sdata-schema'\n\nexport const initSdata = () => {\n const context = getSdataDefault()\n const fieldName = getSdataDefault(context)\n const fieldValue = getSdataDefault(context, fieldName)\n const radiobuttons = 'Absolute'\n\n return {\n errors: {},\n valid: true,\n result: {\n context,\n fieldName,\n fieldValue,\n radiobuttons,\n type: 'DAT'\n }\n }\n}\n\nexport function sdataReducer(state, action) {\n if (action.data.result.init) {\n return correctErrors(\n {\n ...state,\n result: Object.assign({}, state.result, action.data.result)\n },\n action.data\n )\n }\n\n const actionContext = action.data.result.context\n const actionFieldName = action.data.result.fieldName\n\n let newstate = null\n\n if (actionContext !== state.result.context)\n newstate = onContextChange(state, action.data.result)\n else if (actionFieldName !== state.result.fieldName)\n newstate = onFieldNameChange(state, action.data.result)\n\n newstate = newstate || {\n ...state,\n result: Object.assign({}, state.result, action.data.result)\n }\n\n return correctErrors(newstate, action.data)\n}\n\nconst correctErrors = (state, payload) => {\n const { valid, errors } = payload\n const { fieldName, fieldValue } = state.result\n\n return {\n result: state.result,\n valid: valid && !!fieldName && !!fieldValue,\n errors\n }\n}\n\nconst onContextChange = (state, payload) => {\n const { context, fieldValue } = payload\n\n const fieldName = getSdataDefault(context)\n\n let fValue = fieldValue\n if (fValue === state.result.fieldValue)\n fValue = getSdataDefault(context, fieldName)\n\n return {\n result: {\n ...payload,\n context,\n fieldName,\n fieldValue: fValue\n }\n }\n}\n\nconst onFieldNameChange = (state, payload) => {\n const { fieldName } = payload\n\n const context = state.result.context\n\n let fieldValue = payload.fieldValue\n\n if (sdataSchema[context][fieldName])\n fieldValue = getSdataDefault(context, fieldName)\n\n if (\n fieldValue === state.result.fieldValue &&\n sdataSchema[context][state.result.fieldName]\n )\n fieldValue = ''\n\n return {\n result: {\n ...payload,\n fieldName,\n fieldValue\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { initSdata, sdataReducer } from './sdata'\n\nimport { getDefaultOptions } from '../../data/schema/options-schema'\n\nexport const formsState = {\n // TODO: create from schema.{smth}.defaultValue\n // TODO: change validation method, no 'valid:true' props as default\n atomProps: {\n errors: {},\n valid: true,\n result: {\n label: '',\n charge: 0,\n explicitValence: -1,\n hCount: 0,\n invRet: 0,\n isotope: 0,\n radical: 0,\n ringBondCount: 0,\n substitutionCount: 0\n }\n },\n attachmentPoints: {\n errors: {},\n valid: true,\n result: {\n primary: false,\n secondary: false\n }\n },\n automap: {\n errors: {},\n valid: true,\n result: {\n mode: 'discard'\n }\n },\n bondProps: {\n errors: {},\n valid: true,\n result: {\n type: 'single',\n topology: 0,\n center: 0\n }\n },\n check: {\n errors: {},\n moleculeErrors: {}\n },\n labelEdit: {\n errors: {},\n valid: true,\n result: {\n label: ''\n }\n },\n rgroup: {\n errors: {},\n valid: true,\n result: {\n values: []\n }\n },\n rgroupLogic: {\n errors: {},\n valid: true,\n result: {\n ifthen: 0,\n range: '>0',\n resth: false\n }\n },\n save: {\n errors: {},\n valid: true,\n result: {\n filename: 'ketcher',\n format: 'mol'\n }\n },\n settings: {\n errors: {},\n valid: true,\n result: getDefaultOptions()\n },\n sgroup: {\n errors: {},\n valid: true,\n result: {\n type: 'GEN'\n }\n },\n text: {\n errors: {},\n valid: true,\n result: {}\n },\n attach: {\n errors: {},\n valid: true,\n result: {}\n },\n sdata: initSdata()\n}\n\nexport function updateFormState(data) {\n return {\n type: 'UPDATE_FORM',\n data\n }\n}\n\nexport function checkErrors(errors) {\n return {\n type: 'UPDATE_FORM',\n data: { moleculeErrors: errors }\n }\n}\n\nexport function setDefaultSettings() {\n return {\n type: 'UPDATE_FORM',\n data: {\n result: getDefaultOptions(),\n valid: true,\n errors: {}\n }\n }\n}\n\nexport function formReducer(state, action, formName) {\n if (formName === 'sdata') return sdataReducer(state, action)\n\n return Object.assign({}, state, action.data)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const INDIGO_VERIFICATION = 'INDIGO_VERIFICATION'\n\nexport interface RequestState {\n indigoVerification: boolean\n}\n\ninterface IndigoVerificationAction {\n type: typeof INDIGO_VERIFICATION\n data: boolean\n}\n\nexport type RequestActionTypes = IndigoVerificationAction\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n INDIGO_VERIFICATION,\n RequestActionTypes,\n RequestState\n} from './request.types'\n\nexport function indigoVerification(data: boolean): RequestActionTypes {\n return {\n type: INDIGO_VERIFICATION,\n data\n }\n}\n\nconst initialState = {\n indigoVerification: false\n}\n\nexport default function (\n state = initialState,\n action: RequestActionTypes\n): RequestState {\n const { type, data } = action\n\n switch (type) {\n case INDIGO_VERIFICATION: {\n return {\n ...state,\n indigoVerification: data\n }\n }\n default:\n return state\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nexport const supportedSGroupTypes = {\n MUL: 'MUL',\n SRU: 'SRU',\n SUP: 'SUP',\n DAT: 'DAT',\n GEN: 'GEN'\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { mapOf } from './schema-helper'\nimport { range } from 'lodash/fp'\n\nexport const atom = {\n title: 'Atom',\n type: 'object',\n required: 'label',\n properties: {\n label: {\n title: 'Label',\n type: 'string', // TODO:should really be enum of elements\n maxLength: 3,\n invalidMessage: 'Wrong label'\n },\n alias: {\n title: 'Alias',\n type: 'string',\n invalidMessage: 'Leading and trailing spaces are not allowed'\n },\n charge: {\n title: 'Charge',\n type: 'string',\n pattern: /^([+-]?)(\\d{1,3}|1000)([+-]?)$/,\n maxLength: 5,\n default: '0',\n invalidMessage: 'Invalid charge value'\n },\n explicitValence: {\n title: 'Valence',\n enum: [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8],\n enumNames: ['', '0', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'],\n default: -1\n },\n isotope: {\n title: 'Isotope',\n type: 'integer',\n minimum: 0,\n default: 0,\n invalidMessage: 'There must be integer'\n },\n radical: {\n title: 'Radical',\n enum: [0, 2, 1, 3],\n enumNames: [\n '',\n 'Monoradical',\n 'Diradical (singlet)',\n 'Diradical (triplet)'\n ],\n default: 0\n },\n ringBondCount: {\n title: 'Ring bond count',\n enum: [0, -2, -1, 2, 3, 4],\n enumNames: ['', 'As drawn', '0', '2', '3', '4'],\n default: 0\n },\n hCount: {\n title: 'H count',\n enum: [0, 1, 2, 3, 4, 5],\n enumNames: ['', '0', '1', '2', '3', '4'],\n default: 0\n },\n substitutionCount: {\n title: 'Substitution count',\n enum: [0, -2, -1, 1, 2, 3, 4, 5, 6],\n enumNames: ['', 'As drawn', '0', '1', '2', '3', '4', '5', '6'],\n default: 0\n },\n unsaturatedAtom: {\n title: 'Unsaturated',\n type: 'boolean',\n default: false\n },\n invRet: {\n title: 'Inversion',\n enum: [0, 1, 2],\n enumNames: ['', 'Inverts', 'Retains'],\n default: 0\n },\n exactChangeFlag: {\n title: 'Exact change',\n type: 'boolean',\n default: false\n }\n }\n}\n\nexport const rgroupSchema = {\n title: 'R-group',\n type: 'object',\n properties: {\n values: {\n type: 'array',\n items: {\n type: 'string',\n enum: range(1, 33),\n enumNames: range(1, 33).map(item => 'R' + item)\n }\n }\n }\n}\n\nexport const labelEdit = {\n title: 'Label Edit',\n type: 'object',\n required: ['label'],\n properties: {\n label: {\n title: 'Atom',\n default: '',\n invalidMessage: 'Wrong atom symbol'\n }\n }\n}\n\nexport const attachmentPoints = {\n title: 'Attachment Points',\n type: 'object',\n properties: {\n primary: {\n title: 'Primary attachment point',\n type: 'boolean'\n },\n secondary: {\n title: 'Secondary attachment point',\n type: 'boolean'\n }\n }\n}\n\nexport const bond = {\n title: 'Bond',\n type: 'object',\n required: ['type'],\n properties: {\n type: {\n title: 'Type',\n enum: [\n 'single',\n 'up',\n 'down',\n 'updown',\n 'double',\n 'crossed',\n 'triple',\n 'aromatic',\n 'any',\n 'hydrogen',\n 'singledouble',\n 'singlearomatic',\n 'doublearomatic',\n 'dative'\n ],\n enumNames: [\n 'Single',\n 'Single Up',\n 'Single Down',\n 'Single Up/Down',\n 'Double',\n 'Double Cis/Trans',\n 'Triple',\n 'Aromatic',\n 'Any',\n 'Hydrogen',\n 'Single/Double',\n 'Single/Aromatic',\n 'Double/Aromatic',\n 'Dative'\n ],\n default: 'single'\n },\n topology: {\n title: 'Topology',\n enum: [0, 1, 2],\n enumNames: ['Either', 'Ring', 'Chain'],\n default: 0\n },\n center: {\n title: 'Reacting Center',\n enum: [0, -1, 1, 2, 4, 8, 12], // 5, 9, 13\n enumNames: [\n 'Unmarked',\n 'Not center',\n 'Center',\n 'No change',\n 'Made/broken',\n 'Order changes',\n 'Made/broken and changes'\n ], // \"Order changes\" x 3\n default: 0\n }\n }\n}\n\nconst sgroup = {\n title: 'SGroup',\n type: 'object',\n required: ['type'],\n oneOf: [\n {\n key: 'GEN',\n title: 'Generic',\n properties: {\n type: { enum: ['GEN'] }\n }\n },\n {\n key: 'MUL',\n title: 'Multiple group',\n type: 'object',\n properties: {\n type: { enum: ['MUL'] },\n mul: {\n title: 'Repeat count',\n type: 'integer',\n default: 1,\n minimum: 1,\n maximum: 1000,\n invalidMessage: 'Value out of range: must be between 1 and 1000'\n }\n },\n required: ['mul']\n },\n {\n key: 'SRU',\n title: 'SRU polymer',\n properties: {\n type: { enum: ['SRU'] },\n subscript: {\n title: 'Polymer label',\n type: 'string',\n default: 'n',\n pattern: /^[a-zA-Z]$/,\n invalidMessage: 'SRU subscript should consist of a single letter'\n },\n connectivity: {\n title: 'Repeat Pattern',\n enum: ['ht', 'hh', 'eu'],\n enumNames: ['Head-to-tail', 'Head-to-head', 'Either unknown'],\n default: 'ht'\n }\n },\n required: ['subscript', 'connectivity']\n },\n {\n key: 'SUP',\n title: 'Superatom',\n properties: {\n type: { enum: ['SUP'] },\n name: {\n title: 'Name',\n type: 'string',\n default: '',\n minLength: 1,\n invalidMessage: 'Please, provide a name for the superatom'\n }\n },\n required: ['name']\n }\n ]\n}\nexport const sgroupMap = mapOf(sgroup, 'type')\n\nexport const rgroupLogic = {\n title: 'R-Group',\n type: 'object',\n properties: {\n range: {\n title: 'Occurrence',\n type: 'string',\n maxLength: 50,\n invalidMessage: 'Wrong value'\n },\n resth: {\n title: 'RestH',\n type: 'boolean'\n },\n ifthen: {\n title: 'Condition',\n type: 'integer',\n minium: 0\n }\n }\n}\n\nexport const textSchema = {\n title: 'Text Edit',\n type: 'object',\n required: ['label'],\n properties: {\n label: {\n default: '',\n type: 'string'\n }\n }\n}\n\nexport const attachSchema = {\n title: 'Template Edit',\n type: 'object',\n required: ['name'],\n properties: {\n name: {\n title: 'Template name',\n type: 'string',\n minLength: 1,\n maxLength: 128,\n invalidMessage:\n 'Template must have a unique name and no more than 128 symbols in length'\n }\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AtomList, Bond, Elements, StereoLabel } from 'ketcher-core'\n\nimport { atom as atomSchema } from '../schema/struct-schema'\nimport { capitalize } from 'lodash/fp'\nimport { sdataSchema } from '../schema/sdata-schema'\n\nconst DefaultStereoGroupNumber = 1\n\nexport function fromElement(selem) {\n if (selem.label === 'R#') {\n return {\n type: 'rlabel',\n values: fromRlabel(selem.rglabel),\n ...selem\n }\n }\n if (selem.label === 'L#') return fromAtomList(selem)\n\n if (Elements.get(selem.label)) return fromAtom(selem)\n\n if (!selem.label && 'attpnt' in selem) return { ap: fromApoint(selem.attpnt) }\n\n return selem // probably generic\n}\n\nexport function toElement(elem) {\n if (elem.type === 'rlabel') {\n return {\n label: elem.values.length ? 'R#' : 'C',\n rglabel: elem.values.length === 0 ? null : toRlabel(elem.values)\n }\n }\n if (elem.type === 'list' || elem.type === 'not-list') return toAtomList(elem)\n\n if (!elem.label && 'ap' in elem) return { attpnt: toApoint(elem.ap) }\n\n if (Elements.get(capitalize(elem.label))) return toAtom(elem)\n\n if (\n elem.label === 'A' ||\n elem.label === '*' ||\n elem.label === 'Q' ||\n elem.label === 'X' ||\n elem.label === 'R'\n ) {\n elem.pseudo = elem.label\n return toAtom(elem)\n }\n\n return elem\n}\n\nfunction fromAtom(satom) {\n const alias = satom.alias || ''\n const charge = satom.charge.toString()\n\n return {\n alias,\n label: satom.label,\n charge,\n isotope: satom.isotope,\n explicitValence: satom.explicitValence,\n radical: satom.radical,\n invRet: satom.invRet,\n exactChangeFlag: !!satom.exactChangeFlag,\n ringBondCount: satom.ringBondCount,\n substitutionCount: satom.substitutionCount,\n unsaturatedAtom: !!satom.unsaturatedAtom,\n hCount: satom.hCount,\n stereoParity: satom.stereoParity\n }\n}\n\nfunction toAtom(atom) {\n // TODO merge this to Atom.attrlist?\n // see ratomtool\n const chargeRegexp = atomSchema.properties.charge.pattern\n const pch = chargeRegexp.exec(atom.charge)\n const charge = pch ? parseInt(pch[1] + pch[3] + pch[2]) : atom.charge\n\n const conv = Object.assign({}, atom, {\n label: capitalize(atom.label),\n alias: atom.alias || null\n })\n if (charge !== undefined) conv.charge = charge\n return conv\n}\n\nfunction fromAtomList(satom) {\n return {\n type: satom.atomList.notList ? 'not-list' : 'list',\n values: satom.atomList.ids.map(i => Elements.get(i).label)\n }\n}\n\nfunction toAtomList(atom) {\n return {\n pseudo: null,\n label: 'L#',\n atomList: new AtomList({\n notList: atom.type === 'not-list',\n ids: atom.values.map(el => Elements.get(el).number)\n })\n }\n}\n\nexport function fromStereoLabel(stereoLabel) {\n if (stereoLabel === null) return { type: null }\n const type = stereoLabel.match(/\\D+/g)[0]\n const number = +stereoLabel.replace(type, '')\n\n if (type === StereoLabel.Abs) {\n return {\n type: stereoLabel,\n orNumber: DefaultStereoGroupNumber,\n andNumber: DefaultStereoGroupNumber\n }\n }\n\n if (type === StereoLabel.And) {\n return {\n type: type,\n orNumber: DefaultStereoGroupNumber,\n andNumber: number\n }\n }\n\n if (type === StereoLabel.Or) {\n return {\n type: type,\n orNumber: number,\n andNumber: DefaultStereoGroupNumber\n }\n }\n}\n\nexport function toStereoLabel(stereoLabel) {\n switch (stereoLabel.type) {\n case StereoLabel.And:\n return `${StereoLabel.And}${stereoLabel.andNumber || 1}`\n\n case StereoLabel.Or:\n return `${StereoLabel.Or}${stereoLabel.orNumber || 1}`\n\n default:\n return stereoLabel.type\n }\n}\n\nfunction fromApoint(sap) {\n return {\n primary: ((sap || 0) & 1) > 0,\n secondary: ((sap || 0) & 2) > 0\n }\n}\n\nfunction toApoint(ap) {\n return (ap.primary && 1) + (ap.secondary && 2)\n}\n\nfunction fromRlabel(rg) {\n const res = []\n let rgi\n let val\n for (rgi = 0; rgi < 32; rgi++) {\n if (rg & (1 << rgi)) {\n val = rgi + 1\n res.push(val) // push the string\n }\n }\n return res\n}\n\nfunction toRlabel(values) {\n let res = 0\n values.forEach(val => {\n const rgi = val - 1\n res |= 1 << rgi\n })\n return res\n}\n\nexport function fromBond(sbond) {\n const type = sbond.type\n const stereo = sbond.stereo\n return {\n type: fromBondType(type, stereo),\n topology: sbond.topology || 0,\n center: sbond.reactingCenterStatus || 0\n }\n}\n\nexport function toBond(bond) {\n return {\n topology: bond.topology,\n reactingCenterStatus: bond.center,\n ...toBondType(bond.type)\n }\n}\n\nexport function toBondType(caption) {\n return Object.assign({}, bondCaptionMap[caption])\n}\n\nfunction fromBondType(type, stereo) {\n for (const caption in bondCaptionMap) {\n if (\n bondCaptionMap[caption].type === type &&\n bondCaptionMap[caption].stereo === stereo\n )\n return caption\n }\n throw Error('No such bond caption')\n}\n\nconst bondCaptionMap = {\n single: {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n up: {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.UP\n },\n down: {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.DOWN\n },\n updown: {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.EITHER\n },\n double: {\n type: Bond.PATTERN.TYPE.DOUBLE,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n crossed: {\n type: Bond.PATTERN.TYPE.DOUBLE,\n stereo: Bond.PATTERN.STEREO.CIS_TRANS\n },\n triple: {\n type: Bond.PATTERN.TYPE.TRIPLE,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n aromatic: {\n type: Bond.PATTERN.TYPE.AROMATIC,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n singledouble: {\n type: Bond.PATTERN.TYPE.SINGLE_OR_DOUBLE,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n singlearomatic: {\n type: Bond.PATTERN.TYPE.SINGLE_OR_AROMATIC,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n doublearomatic: {\n type: Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n any: {\n type: Bond.PATTERN.TYPE.ANY,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n hydrogen: {\n type: Bond.PATTERN.TYPE.HYDROGEN,\n stereo: Bond.PATTERN.STEREO.NONE\n },\n dative: {\n type: Bond.PATTERN.TYPE.DATIVE,\n stereo: Bond.PATTERN.STEREO.NONE\n }\n}\n\nexport function fromSgroup(ssgroup) {\n const type = ssgroup.type || 'GEN'\n const { context, fieldName, fieldValue, absolute, attached } = ssgroup.attrs\n\n if (absolute === false && attached === false)\n ssgroup.attrs.radiobuttons = 'Relative'\n else ssgroup.attrs.radiobuttons = attached ? 'Attached' : 'Absolute'\n\n if (\n sdataSchema[context][fieldName] &&\n sdataSchema[context][fieldName].properties.fieldValue.items\n )\n ssgroup.attrs.fieldValue = fieldValue.split('\\n')\n\n return Object.assign({ type }, ssgroup.attrs)\n}\n\nexport function toSgroup(sgroup) {\n const { type, radiobuttons, ...props } = sgroup\n const attrs = { ...props }\n\n const absolute = 'absolute'\n const attached = 'attached'\n\n switch (radiobuttons) {\n case 'Absolute':\n attrs[absolute] = true\n attrs[attached] = false\n break\n case 'Attached':\n attrs[absolute] = false\n attrs[attached] = true\n break\n case 'Relative':\n attrs[absolute] = false\n attrs[attached] = false\n break\n default:\n break\n }\n\n if (attrs.fieldName) attrs.fieldName = attrs.fieldName.trim()\n\n if (attrs.fieldValue) {\n attrs.fieldValue =\n typeof attrs.fieldValue === 'string'\n ? attrs.fieldValue.trim()\n : attrs.fieldValue\n }\n\n return {\n type,\n attrs\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RxnArrowMode, SimpleObjectMode } from 'ketcher-core'\n\nimport { bond as bondSchema } from '../data/schema/struct-schema'\nimport isHidden from './isHidden'\nimport { toBondType } from '../data/convert/structconv'\n\nconst toolActions = {\n 'select-lasso': {\n title: 'Lasso Selection',\n shortcut: 'Escape',\n action: { tool: 'select', opts: 'lasso' }\n },\n 'select-rectangle': {\n title: 'Rectangle Selection',\n shortcut: 'Escape',\n action: { tool: 'select', opts: 'rectangle' },\n hidden: options => isHidden(options, 'select-rectangle')\n },\n 'select-fragment': {\n title: 'Fragment Selection',\n shortcut: 'Escape',\n action: { tool: 'select', opts: 'fragment' },\n hidden: options => isHidden(options, 'select-fragment')\n },\n erase: {\n title: 'Erase',\n shortcut: ['Delete', 'Backspace'],\n action: { tool: 'eraser', opts: 1 }, // TODO last selector mode is better\n hidden: options => isHidden(options, 'erase')\n },\n chain: {\n title: 'Chain',\n action: { tool: 'chain' },\n hidden: options => isHidden(options, 'chain')\n },\n 'enhanced-stereo': {\n shortcut: 'Alt+e',\n title: 'Stereochemistry',\n action: { tool: 'enhancedStereo' },\n hidden: options => isHidden(options, 'enhanced-stereo')\n },\n 'charge-plus': {\n shortcut: '5',\n title: 'Charge Plus',\n action: { tool: 'charge', opts: 1 },\n hidden: options => isHidden(options, 'charge-plus')\n },\n 'charge-minus': {\n shortcut: '5',\n title: 'Charge Minus',\n action: { tool: 'charge', opts: -1 },\n hidden: options => isHidden(options, 'charge-minus')\n },\n transforms: {\n hidden: options => isHidden(options, 'transforms')\n },\n 'transform-rotate': {\n shortcut: 'Alt+r',\n title: 'Rotate Tool',\n action: { tool: 'rotate' },\n hidden: options => isHidden(options, 'transform-rotate')\n },\n 'transform-flip-h': {\n shortcut: 'Alt+h',\n title: 'Horizontal Flip',\n action: { tool: 'rotate', opts: 'horizontal' },\n hidden: options => isHidden(options, 'transform-flip-h')\n },\n 'transform-flip-v': {\n shortcut: 'Alt+v',\n title: 'Vertical Flip',\n action: { tool: 'rotate', opts: 'vertical' },\n hidden: options => isHidden(options, 'transform-flip-v')\n },\n sgroup: {\n shortcut: 'Mod+g',\n title: 'S-Group',\n action: { tool: 'sgroup' },\n hidden: options => isHidden(options, 'sgroup')\n },\n 'sgroup-data': {\n shortcut: 'Mod+g',\n title: 'Data S-Group',\n action: { tool: 'sgroup', opts: 'DAT' },\n hidden: options => isHidden(options, 'sgroup-data')\n },\n arrows: {\n hidden: options => isHidden(options, 'arrows')\n },\n 'reaction-arrow-open-angle': {\n title: 'Arrow Open Angle Tool',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.OpenAngle },\n hidden: options => isHidden(options, 'reaction-arrow-open-angle')\n },\n 'reaction-arrow-filled-triangle': {\n title: 'Arrow Filled Triangle',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.FilledTriangle },\n hidden: options => isHidden(options, 'reaction-arrow-filled-triangle')\n },\n 'reaction-arrow-filled-bow': {\n title: 'Arrow Filled Bow Tool',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.FilledBow },\n hidden: options => isHidden(options, 'reaction-arrow-filled-bow')\n },\n 'reaction-arrow-dashed-open-angle': {\n title: 'Arrow Dashed Open Angle Tool',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.DashedOpenAngle },\n hidden: options => isHidden(options, 'reaction-arrow-dashed-open-angle')\n },\n 'reaction-arrow-failed': {\n title: 'Failed Arrow Tool',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.Failed },\n hidden: options => isHidden(options, 'reaction-arrow-failed')\n },\n 'reaction-arrow-both-ends-filled-triangle': {\n title: 'Arrow Both Ends Filled Triangle Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.BothEndsFilledTriangle\n },\n hidden: options =>\n isHidden(options, 'reaction-arrow-both-ends-filled-triangle')\n },\n 'reaction-arrow-equilibrium-filled-half-bow': {\n title: 'Arrow Equilibrium Filled Half Bow Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.EquilibriumFilledHalfBow\n },\n hidden: options =>\n isHidden(options, 'reaction-arrow-equilibrium-filled-half-bow')\n },\n 'reaction-arrow-equilibrium-filled-triangle': {\n title: 'Arrow Equilibrium Filled Triangle Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.EquilibriumFilledTriangle\n },\n hidden: options =>\n isHidden(options, 'reaction-arrow-equilibrium-filled-triangle')\n },\n 'reaction-arrow-equilibrium-open-angle': {\n title: 'Arrow Equilibrium Open Angle Tool',\n action: { tool: 'reactionarrow', opts: RxnArrowMode.EquilibriumOpenAngle },\n hidden: options =>\n isHidden(options, 'reaction-arrow-equilibrium-open-angle')\n },\n 'reaction-arrow-unbalanced-equilibrium-filled-half-bow': {\n title: 'Arrow Unbalanced Equilibrium Filled Half Bow Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.UnbalancedEquilibriumFilledHalfBow\n },\n hidden: options =>\n isHidden(options, 'reaction-arrow-unbalanced-equilibrium-filled-half-bow')\n },\n 'reaction-arrow-unbalanced-equilibrium-open-half-angle': {\n title: 'Arrow Unbalanced Equilibrium Open Half Angle Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.UnbalancedEquilibriumOpenHalfAngle\n },\n hidden: options =>\n isHidden(options, 'reaction-arrow-unbalanced-equilibrium-open-half-angle')\n },\n 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow': {\n title: 'Arrow Unbalanced Equilibrium Large Filled Half Bow Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.UnbalancedEquilibriumLargeFilledHalfBow\n },\n hidden: options =>\n isHidden(\n options,\n 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow'\n )\n },\n 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle': {\n title: 'Arrow Unbalanced Equilibrium Filled Half Triangle Tool',\n action: {\n tool: 'reactionarrow',\n opts: RxnArrowMode.UnbalancedEquilibriumFilleHalfTriangle\n },\n hidden: options =>\n isHidden(\n options,\n 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle'\n )\n },\n 'reaction-plus': {\n title: 'Reaction Plus Tool',\n action: { tool: 'reactionplus' },\n hidden: options => isHidden(options, 'reaction-plus')\n },\n 'reaction-mapping-tools': {\n hidden: options => isHidden(options, 'reaction-mapping-tools')\n },\n 'reaction-map': {\n title: 'Reaction Mapping Tool',\n action: { tool: 'reactionmap' },\n hidden: options => isHidden(options, 'reaction-map')\n },\n 'reaction-unmap': {\n title: 'Reaction Unmapping Tool',\n action: { tool: 'reactionunmap' },\n hidden: options => isHidden(options, 'reaction-unmap')\n },\n rgroup: {\n hidden: options => isHidden(options, 'rgroup')\n },\n 'rgroup-label': {\n shortcut: 'Mod+r',\n title: 'R-Group Label Tool',\n action: { tool: 'rgroupatom' },\n hidden: options => isHidden(options, 'rgroup-label')\n },\n 'rgroup-fragment': {\n shortcut: ['Mod+Shift+r', 'Mod+r'],\n title: 'R-Group Fragment Tool',\n action: { tool: 'rgroupfragment' },\n hidden: options => isHidden(options, 'rgroup-fragment')\n },\n 'rgroup-attpoints': {\n shortcut: 'Mod+r',\n title: 'Attachment Point Tool',\n action: { tool: 'apoint' },\n hidden: options => isHidden(options, 'rgroup-attpoints')\n },\n shapes: {\n hidden: options => isHidden(options, 'shapes')\n },\n 'shape-ellipse': {\n title: 'Shape Ellipse',\n action: { tool: 'simpleobject', opts: SimpleObjectMode.ellipse },\n hidden: options => isHidden(options, 'shape-ellipse')\n },\n 'shape-rectangle': {\n title: 'Shape Rectangle',\n action: { tool: 'simpleobject', opts: SimpleObjectMode.rectangle },\n hidden: options => isHidden(options, 'shape-rectangle')\n },\n 'shape-line': {\n title: 'Shape Line',\n action: { tool: 'simpleobject', opts: SimpleObjectMode.line },\n hidden: options => isHidden(options, 'shape-line')\n },\n text: {\n title: 'Add text',\n action: { tool: 'text' },\n hidden: options => isHidden(options, 'text')\n },\n bonds: {\n hidden: options => isHidden(options, 'bonds')\n }\n}\n\nconst bondCuts = {\n single: '1',\n double: '2',\n triple: '3',\n up: '1',\n down: '1',\n updown: '1',\n crossed: '2',\n any: '0',\n aromatic: '4'\n}\n\nconst typeSchema = bondSchema.properties.type\n\nexport default typeSchema.enum.reduce((res, type, i) => {\n res[`bond-${type}`] = {\n title: `${typeSchema.enumNames[i]} Bond`,\n shortcut: bondCuts[type],\n action: {\n tool: 'bond',\n opts: toBondType(type)\n },\n hidden: options => isHidden(options, `bond-${type}`)\n }\n return res\n}, toolActions)\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n FormatterFactory,\n Pile,\n SGroup,\n getStereoAtomsMap,\n identifyStructFormat\n} from 'ketcher-core'\n\nimport { supportedSGroupTypes } from './constants'\nimport tools from '../action/tools'\n\nexport function onAction(action) {\n if (action && action.dialog) {\n return {\n type: 'MODAL_OPEN',\n data: { name: action.dialog }\n }\n }\n if (action && action.thunk) {\n return action.thunk\n }\n\n return {\n type: 'ACTION',\n action\n }\n}\n\nexport function loadStruct(struct) {\n return (dispatch, getState) => {\n const editor = getState().editor\n editor.struct(struct)\n }\n}\n\nfunction parseStruct(struct, server, options) {\n if (typeof struct === 'string') {\n options = options || {}\n const { rescale, fragment, ...formatterOptions } = options\n\n const format = identifyStructFormat(struct)\n const factory = new FormatterFactory(server)\n\n const service = factory.create(format, formatterOptions)\n return service.getStructureFromStringAsync(struct)\n } else {\n return Promise.resolve(struct)\n }\n}\n\nexport function load(struct, options) {\n return (dispatch, getState) => {\n const state = getState()\n const editor = state.editor\n const server = state.server\n const errorHandler = editor.errorHandler\n\n options = options || {}\n\n return parseStruct(struct, server, options)\n .then(\n struct => {\n const { fragment } = options\n\n if (\n struct.sgroups.some(sGroup => !supportedSGroupTypes[sGroup.type])\n ) {\n const isConfirmed = window.confirm(\n `Unsupported S-group type found. Would you like to import structure without it?`\n )\n\n if (!isConfirmed) {\n return\n }\n\n struct.sgroups = struct.sgroups.filter(\n (key, sGroup) => supportedSGroupTypes[sGroup.type]\n )\n }\n\n struct.rescale() // TODO: move out parsing?\n\n if (editor.struct().atoms.size) {\n //NB: reset id\n const oldStruct = editor.struct().clone()\n\n struct.sgroups.forEach((sg, sgId) => {\n const offset = SGroup.getOffset(oldStruct.sgroups.get(sgId))\n const atomSet = new Pile(sg.atoms)\n const crossBonds = SGroup.getCrossBonds(struct, atomSet)\n SGroup.bracketPos(sg, struct, crossBonds)\n if (offset) sg.updateOffset(offset)\n })\n }\n\n struct.findConnectedComponents()\n struct.setImplicitHydrogen()\n\n const stereAtomsMap = getStereoAtomsMap(\n struct,\n Array.from(struct.bonds.values())\n )\n\n struct.atoms.forEach((atom, id) => {\n if (struct.atomGetNeighbors(id).length === 0) {\n atom.stereoLabel = null\n atom.stereoParity = 0\n } else {\n const stereoProp = stereAtomsMap.get(id)\n if (stereoProp) {\n atom.stereoLabel = stereoProp.stereoLabel\n atom.stereoParity = stereoProp.stereoParity\n }\n }\n })\n\n struct.markFragments()\n\n if (fragment) {\n if (struct.isBlank()) {\n dispatch({ type: 'ACTION', action: tools['select-lasso'].action })\n } else {\n dispatch(onAction({ tool: 'paste', opts: struct }))\n }\n } else {\n editor.struct(struct)\n }\n\n dispatch({ type: 'MODAL_CLOSE' })\n },\n err => {\n errorHandler(err.message)\n }\n )\n .catch(err => {\n errorHandler(err.message)\n })\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ChemicalMimeType, KetSerializer } from 'ketcher-core'\nimport { appUpdate, setStruct } from '../options'\nimport { omit, without } from 'lodash/fp'\n\nimport { checkErrors } from '../modal/form'\nimport { indigoVerification } from '../request'\nimport { load } from '../shared'\n\nexport function checkServer() {\n return (dispatch, getState) => {\n const { editor, server } = getState()\n\n server.then(\n res =>\n dispatch(\n appUpdate({\n indigoVersion: res?.indigoVersion,\n imagoVersions: res?.imagoVersions,\n server: res?.isAvailable\n })\n ),\n e => editor.errorHandler(e)\n )\n }\n}\n\nexport function recognize(file, version) {\n return (dispatch, getState) => {\n const rec = getState().server.recognize\n const editor = getState().editor\n\n const process = rec(file, version).then(\n res => {\n dispatch(setStruct(res.struct))\n },\n e => {\n dispatch(setStruct(null))\n editor.errorHandler(e)\n }\n )\n dispatch(setStruct(process))\n }\n}\n\nfunction ketcherCheck(struct, checkParams) {\n const errors = {}\n\n if (checkParams.includes('chiral_flag')) {\n const isAbs = Array.from(struct.frags.values()).some(fr =>\n fr ? fr.enhancedStereoFlag === 'abs' : false\n )\n if (isAbs) errors['chiral_flag'] = 'Chiral flag is present on the canvas'\n }\n\n if (checkParams.includes('valence')) {\n let badVal = 0\n struct.atoms.forEach(atom => atom.badConn && badVal++)\n if (badVal > 0)\n errors['valence'] = `Structure contains ${badVal} atom${\n badVal !== 1 ? 's' : ''\n } with bad valence`\n }\n\n return errors\n}\n\nexport function check(optsTypes) {\n return (dispatch, getState) => {\n const { editor, server } = getState()\n const ketcherErrors = ketcherCheck(editor.struct(), optsTypes)\n\n const options = getState().options.getServerSettings()\n options.data = { types: without(['valence', 'chiral_flag'], optsTypes) }\n\n return serverCall(editor, server, 'check', options)\n .then(res => {\n res = Object.assign(res, ketcherErrors) // merge Indigo check with Ketcher check\n dispatch(checkErrors(res))\n })\n .catch(e => {\n editor.errorHandler(e)\n })\n }\n}\n\nexport function automap(res) {\n return serverTransform('automap', res)\n}\n\nexport function analyse() {\n return (dispatch, getState) => {\n //reset values to initial state\n dispatch({\n type: 'ANALYSE_LOADING'\n })\n const { editor, server, options } = getState()\n const serverSettings = options.getServerSettings()\n serverSettings.data = {\n properties: [\n 'molecular-weight',\n 'most-abundant-mass',\n 'monoisotopic-mass',\n 'gross',\n 'mass-composition'\n ]\n }\n\n return serverCall(editor, server, 'calculate', serverSettings)\n .then(values =>\n dispatch({\n type: 'CHANGE_ANALYSE',\n data: { values }\n })\n )\n .catch(e => {\n editor.errorHandler(e)\n })\n }\n}\n\nexport function serverTransform(method, data, struct) {\n return (dispatch, getState) => {\n const state = getState()\n const opts = state.options.getServerSettings()\n opts.data = data\n dispatch(indigoVerification(true))\n\n serverCall(state.editor, state.server, method, opts, struct)\n .then(res => {\n const loadedStruct = new KetSerializer().deserialize(res.struct)\n\n return dispatch(\n load(loadedStruct, {\n rescale: method === 'layout',\n reactionRelayout: method === 'clean'\n })\n )\n })\n .catch(e => {\n state.editor.errorHandler(e)\n })\n .finally(() => {\n dispatch(indigoVerification(false))\n })\n // TODO: notification\n }\n}\n\n//TODO: serverCall function should not be exported\nexport function serverCall(editor, server, method, options, struct) {\n const selection = editor.selection()\n let selectedAtoms = []\n const aidMap = new Map()\n const currentStruct = (struct || editor.struct()).clone(\n null,\n null,\n false,\n aidMap\n )\n if (selection) {\n selectedAtoms = (\n selection.atoms ? selection.atoms : editor.explicitSelected().atoms\n ).map(aid => aidMap.get(aid))\n }\n const ketSerializer = new KetSerializer()\n return server.then(() =>\n server[method](\n Object.assign(\n {\n struct: ketSerializer.serialize(currentStruct)\n },\n method !== 'calculate' && method !== 'check'\n ? {\n output_format: ChemicalMimeType.KET\n }\n : null,\n selectedAtoms && selectedAtoms.length > 0\n ? {\n selected: selectedAtoms\n }\n : null,\n options.data\n ),\n omit('data', options)\n )\n )\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport isHidden from './isHidden'\nimport { serverTransform } from '../state/server'\n\nconst config = {\n layout: {\n shortcut: 'Mod+l',\n title: 'Layout',\n action: {\n thunk: serverTransform('layout')\n },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'layout')\n },\n clean: {\n shortcut: 'Mod+Shift+l',\n title: 'Clean Up',\n action: {\n thunk: serverTransform('clean')\n },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'clean')\n },\n arom: {\n title: 'Aromatize',\n action: {\n thunk: serverTransform('aromatize')\n },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'arom')\n },\n dearom: {\n title: 'Dearomatize',\n action: {\n thunk: serverTransform('dearomatize')\n },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'dearom')\n },\n cip: {\n shortcut: 'Mod+p',\n title: 'Calculate CIP',\n action: {\n thunk: serverTransform('calculateCip')\n },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'cip')\n },\n check: {\n title: 'Check Structure',\n action: { dialog: 'check' },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'check')\n },\n analyse: {\n title: 'Calculated Values',\n action: { dialog: 'analyse' },\n disabled: (editor, server, options) => !options.app.server,\n hidden: options => isHidden(options, 'analyse')\n },\n recognize: {\n title: 'Recognize Molecule',\n action: { dialog: 'recognize' },\n disabled: (editor, server, options) =>\n //TODO: provide the list of disabled functions as array\n !options.app.server ||\n global.ketcher.standalone ||\n !options.app.imagoVersions,\n hidden: options => isHidden(options, 'recognize')\n },\n miew: {\n title: '3D Viewer',\n action: { dialog: 'miew' },\n disabled: () => !window.Miew,\n hidden: options => isHidden(options, 'miew')\n }\n}\n\nexport default config\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializer } from 'ketcher-core'\n\nconst molSerializer = new MolSerializer()\n\nexport default [\n 'Benzene\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 6 6 0 0 0 999 V2000\\n' +\n ' 0.8660 2.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7320 1.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7320 0.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.8660 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 0.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 1.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 2 3 2 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 4 5 2 0 0 0\\n' +\n ' 5 6 1 0 0 0\\n' +\n ' 6 1 2 0 0 0\\n' +\n 'M END\\n',\n 'Cyclopentadiene\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 5 5 0 0 0 999 V2000\\n' +\n ' 0.0000 1.4257 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.8090 0.8379 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.5000 -0.1132 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -0.5000 -0.1132 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -0.8090 0.8379 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 2 3 2 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 4 5 2 0 0 0\\n' +\n ' 5 1 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cyclohexane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 6 6 0 0 0 999 V2000\\n' +\n ' 0.8660 2.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7320 1.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7320 0.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.8660 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 0.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 1.5000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 2 3 1 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 4 5 1 0 0 0\\n' +\n ' 5 6 1 0 0 0\\n' +\n ' 6 1 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cyclopentane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 5 5 0 0 0 999 V2000\\n' +\n ' 0.8090 1.5389 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.6180 0.9511 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.3090 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.3090 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 0.9511 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 2 3 1 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 4 5 1 0 0 0\\n' +\n ' 5 1 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cyclopropane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 3 3 0 0 0 999 V2000\\n' +\n ' -3.2250 -0.2750 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -2.2250 -0.2750 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -2.7250 0.5910 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 2 3 1 0 0 0\\n' +\n ' 1 3 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cyclobutane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 4 4 0 0 0 999 V2000\\n' +\n ' -3.8250 1.5500 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -3.8250 0.5500 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -2.8250 1.5500 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' -2.8250 0.5500 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n ' 1 3 1 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 4 2 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cycloheptane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 7 7 0 0 0 999 V2000\\n' +\n ' 0.0000 1.6293 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.7835 2.2465 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7559 2.0242 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 2.1897 1.1289 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 0.6228 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7566 0.2224 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.7835 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 6 7 1 0 0 0\\n' +\n ' 5 7 1 0 0 0\\n' +\n ' 1 5 1 0 0 0\\n' +\n ' 4 6 1 0 0 0\\n' +\n ' 3 4 1 0 0 0\\n' +\n ' 2 3 1 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n 'M END\\n',\n\n 'Cyclooctane\\n' +\n ' Ketcher 11161218352D 1 1.00000 0.00000 0\\n' +\n '\\n' +\n ' 8 8 0 0 0 999 V2000\\n' +\n ' 0.0000 0.7053 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.0000 1.7078 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.7053 2.4131 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 0.7056 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7079 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 2.4133 0.7053 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 2.4133 1.7078 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 1.7079 2.4131 0.0000 C 0 0 0 0 0 0 0 0 0\\n' +\n ' 8 3 1 0 0 0\\n' +\n ' 7 8 1 0 0 0\\n' +\n ' 6 7 1 0 0 0\\n' +\n ' 5 6 1 0 0 0\\n' +\n ' 4 5 1 0 0 0\\n' +\n ' 1 4 1 0 0 0\\n' +\n ' 2 3 1 0 0 0\\n' +\n ' 1 2 1 0 0 0\\n' +\n 'M END\\n'\n].map(structStr => molSerializer.deserialize(structStr))\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport templates from '../data/templates'\nimport isHidden from './isHidden'\n\nconst templateLib = {\n 'template-lib': {\n shortcut: 'Shift+t',\n title: 'Custom Templates',\n action: { dialog: 'templates' },\n selected: editor => editor._tool.mode === 'classic',\n disabled: (editor, server, options) => !options.app.templates,\n hidden: options => isHidden(options, 'template-lib')\n }\n}\n\nexport default templates.reduce((res, struct, i) => {\n res[`template-${i}`] = {\n title: `${struct.name}`,\n shortcut: 't',\n action: {\n tool: 'template',\n opts: { struct }\n }\n }\n return res\n}, templateLib)\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { findIndex, findLastIndex } from 'lodash/fp'\nimport isHidden from './isHidden'\n\nexport const zoomList = [\n 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.7, 2,\n 2.5, 3, 3.5, 4\n]\n\nexport default {\n zoom: {\n selected: editor => editor.zoom(),\n hidden: options => isHidden(options, 'zoom')\n },\n 'zoom-out': {\n shortcut: ['-', '_', 'Shift+-'],\n title: 'Zoom Out',\n disabled: editor => editor.zoom() <= zoomList[0], // unsave\n action: editor => {\n const zoom = editor.zoom()\n const i = findIndex(z => z >= zoom, zoomList)\n editor.zoom(zoomList[zoomList[i] === zoom && i > 0 ? i - 1 : i])\n },\n hidden: options => isHidden(options, 'zoom-out')\n },\n 'zoom-in': {\n shortcut: ['+', '=', 'Shift+='],\n title: 'Zoom In',\n disabled: editor => zoomList[zoomList.length - 1] <= editor.zoom(),\n action: editor => {\n const zoom = editor.zoom()\n const i = findLastIndex(z => z <= zoom, zoomList)\n editor.zoom(\n zoomList[zoomList[i] === zoom && i < zoomList.length - 1 ? i + 1 : i]\n )\n },\n hidden: options => isHidden(options, 'zoom-in')\n },\n 'zoom-list': {\n hidden: options => isHidden(options, 'zoom-list')\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport isHidden from './isHidden'\n\nconst functionalGroupsLib = {\n 'functional-groups': {\n shortcut: 'Shift+f',\n // TODO Update HELP about current tools\n title: 'Functional Groups',\n action: { dialog: 'fGroups' },\n selected: editor => editor._tool.mode === 'fg',\n disabled: (_, __, options) => {\n return !options.app.functionalGroups\n },\n hidden: options => isHidden(options, 'functional-groups')\n }\n}\n\nexport default functionalGroupsLib\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport atoms from './atoms'\nimport copyAs from './copyAs'\nimport copyImageToClipboard from './copyImageToClipboard'\nimport debug from './debug'\nimport { exec } from '../component/cliparea/cliparea'\nimport isHidden from './isHidden'\nimport server from './server'\nimport templates from './templates'\nimport tools from './tools'\nimport zoom from './zoom'\nimport functionalGroups from './functionalGroups'\n\nexport * from './action.types'\n\nconst config = {\n clear: {\n shortcut: 'Mod+Delete',\n title: 'Clear Canvas',\n action: {\n thunk: (dispatch, getState) => {\n const editor = getState().editor\n if (!editor.struct().isBlank()) editor.struct(null)\n dispatch({ type: 'ACTION', action: tools['select-lasso'].action })\n }\n },\n hidden: options => isHidden(options, 'clear')\n },\n open: {\n shortcut: 'Mod+o',\n title: 'Open…',\n action: { dialog: 'open' },\n hidden: options => isHidden(options, 'open')\n },\n save: {\n shortcut: 'Mod+s',\n title: 'Save As…',\n action: { dialog: 'save' },\n hidden: options => isHidden(options, 'save')\n },\n undo: {\n shortcut: 'Mod+z',\n title: 'Undo',\n action: editor => {\n editor.undo()\n },\n disabled: editor => editor.historySize().undo === 0,\n hidden: options => isHidden(options, 'undo')\n },\n redo: {\n shortcut: ['Mod+Shift+z', 'Mod+y'],\n title: 'Redo',\n action: editor => {\n editor.redo()\n },\n disabled: editor => editor.historySize().redo === 0,\n hidden: options => isHidden(options, 'redo')\n },\n cut: {\n shortcut: 'Mod+x',\n title: 'Cut',\n action: editor => {\n exec('cut') || dontClipMessage('Cut', editor.errorHandler) // eslint-disable-line no-unused-expressions\n },\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'cut')\n },\n copies: {\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'copies')\n },\n copy: {\n shortcut: 'Mod+c',\n title: 'Copy',\n action: editor => {\n exec('copy') || dontClipMessage('Copy', editor.errorHandler) // eslint-disable-line no-unused-expressions\n },\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'copy')\n },\n 'copy-image': {\n shortcut: 'Mod+Shift+f',\n title: 'Copy Image',\n action: () => {\n copyImageToClipboard()\n },\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'copy-image')\n },\n 'copy-mol': {\n shortcut: 'Mod+m',\n title: 'Copy as MOL',\n action: () => {\n copyAs('mol')\n },\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'copy-mol')\n },\n 'copy-ket': {\n shortcut: 'Mod+Shift+k',\n title: 'Copy as KET',\n action: () => {\n copyAs('ket')\n },\n disabled: editor => !hasSelection(editor),\n hidden: options => isHidden(options, 'copy-ket')\n },\n paste: {\n shortcut: 'Mod+v',\n title: 'Paste',\n action: editor => {\n exec('paste') || dontClipMessage('Paste', editor.errorHandler) // eslint-disable-line no-unused-expressions\n },\n selected: ({ actions }) =>\n actions && // TMP\n actions.active &&\n actions.active.tool === 'paste',\n hidden: options => isHidden(options, 'paste')\n },\n settings: {\n title: 'Settings',\n action: { dialog: 'settings' },\n hidden: options => isHidden(options, 'settings')\n },\n help: {\n hidden: options => isHidden(options, 'help')\n },\n about: {\n title: 'About',\n action: { dialog: 'about' },\n hidden: options => isHidden(options, 'about')\n },\n 'reaction-automap': {\n title: 'Reaction Auto-Mapping Tool',\n action: { dialog: 'automap' },\n hidden: options => isHidden(options, 'reaction-automap'),\n disabled: (editor, server, options) =>\n !options.app.server || !editor.struct().hasRxnArrow()\n },\n 'period-table': {\n title: 'Periodic Table',\n action: { dialog: 'period-table' },\n hidden: options => isHidden(options, 'period-table')\n },\n 'select-all': {\n title: 'Select All',\n shortcut: 'Mod+a',\n action: {\n thunk: (dispatch, getState) => {\n getState().editor.selection('all')\n const selectionTool = getState().toolbar.visibleTools.select\n dispatch({ type: 'ACTION', action: tools[selectionTool].action })\n }\n },\n hidden: options => isHidden(options, 'select-all')\n },\n 'deselect-all': {\n title: 'Deselect All',\n shortcut: 'Mod+Shift+a',\n action: editor => {\n editor.selection(null)\n },\n hidden: options => isHidden(options, 'deselect-all')\n },\n 'select-descriptors': {\n title: 'Select descriptors',\n shortcut: 'Mod+d',\n action: {\n thunk: (dispatch, getState) => {\n const selectionTool = getState().toolbar.visibleTools.select\n const editor = getState().editor\n editor.alignDescriptors()\n editor.selection('descriptors')\n dispatch({ type: 'ACTION', action: tools[selectionTool].action })\n }\n },\n hidden: options => isHidden(options, 'select-descriptors')\n },\n ...server,\n ...debug,\n ...tools,\n ...atoms,\n ...zoom,\n ...templates,\n ...functionalGroups\n}\n\nfunction hasSelection(editor) {\n const selection = editor.selection()\n return (\n selection && // if not only sgroupData selected\n Object.keys(selection).filter(key => !['sgroupData'].includes(key)).length >\n 0\n )\n}\n\nfunction dontClipMessage(title, errorHandler) {\n errorHandler(\n 'This action is unavailable via menu.\\n' + // eslint-disable-line no-undef\n 'Instead, use shortcut to ' +\n title +\n '.'\n )\n}\n\nexport default config\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport AboutIcon from './files/about.svg'\nimport AnalyseIcon from './files/analyse.svg'\nimport AromIcon from './files/arom.svg'\nimport BondAnyIcon from './files/bond-any.svg'\nimport BondAromaticIcon from './files/bond-aromatic.svg'\nimport BondCrossedIcon from './files/bond-crossed.svg'\nimport BondDative from './files/bond-dative.svg'\nimport BondDoubleAromaticIcon from './files/bond-doublearomatic.svg'\nimport BondDoubleIcon from './files/bond-double.svg'\nimport BondDownIcon from './files/bond-down.svg'\nimport BondHydrogenIcon from './files/bond-hydrogen.svg'\nimport BondSingleAromaticIcon from './files/bond-singlearomatic.svg'\nimport BondSingleDoubleIcon from './files/bond-singledouble.svg'\nimport BondSingleIcon from './files/bond-single.svg'\nimport BondTripleIcon from './files/bond-triple.svg'\nimport BondUpIcon from './files/bond-up.svg'\nimport BondUpdownIcon from './files/bond-updown.svg'\nimport ChainIcon from './files/chain.svg'\nimport ChargeMinusIcon from './files/charge-minus.svg'\nimport ChargePlusIcon from './files/charge-plus.svg'\nimport CheckIcon from './files/check.svg'\nimport ChiralFlagIcon from './files/chiral-flag.svg'\nimport CipIcon from './files/cip.svg'\nimport CleanIcon from './files/clean.svg'\nimport CopyIcon from './files/copy.svg'\nimport CopyImageIcon from './files/copy-image.svg'\nimport CopyKetIcon from './files/copy-ket.svg'\nimport CopyMolIcon from './files/copy-mol.svg'\nimport CutIcon from './files/cut.svg'\nimport DearomIcon from './files/dearom.svg'\nimport DropdownIcon from './files/dropdown.svg'\nimport EnhancedStereoIcon from './files/enhanced-stereo.svg'\nimport EraseIcon from './files/erase.svg'\nimport GenericGroupsIcon from './files/generic-groups.svg'\nimport HelpIcon from './files/help.svg'\nimport LayoutIcon from './files/layout.svg'\nimport LogoIcon from './files/logo.svg'\nimport MiewIcon from './files/miew.svg'\nimport ClearIcon from './files/clear.svg'\nimport OpenIcon from './files/open.svg'\nimport PasteIcon from './files/paste.svg'\nimport PeriodTableIcon from './files/period-table.svg'\nimport ReactionArrowBothEndsFilledTriangle from './files/reaction-arrow-both-ends-filled-triangle.svg'\nimport ReactionArrowDashedOpenAngle from './files/reaction-arrow-dashed-open-angle.svg'\nimport ReactionArrowEquilibriumFilledHalfBow from './files/reaction-arrow-equilibrium-filled-half-bow.svg'\nimport ReactionArrowEquilibriumFilledTriangle from './files/reaction-arrow-equilibrium-filled-triangle.svg'\nimport ReactionArrowEquilibriumOpenAngle from './files/reaction-arrow-equilibrium-open-angle.svg'\nimport ReactionArrowFailed from './files/reaction-arrow-failed.svg'\nimport ReactionArrowFilledBow from './files/reaction-arrow-filled-bow.svg'\nimport ReactionArrowFilledTriangle from './files/reaction-arrow-filled-triangle.svg'\nimport ReactionArrowOpenAngleIcon from './files/reaction-arrow-open-angle.svg'\nimport ReactionArrowUnbalancedEquilibriumFilledHalfBow from './files/reaction-arrow-unbalanced-equilibrium-filled-half-bow.svg'\nimport ReactionArrowUnbalancedEquilibriumFilledHalfTriangle from './files/reaction-arrow-unbalanced-equilibrium-fille-half-triangle.svg'\nimport ReactionArrowUnbalancedEquilibriumLargeFilledHalfBow from './files/reaction-arrow-unbalanced-equilibrium-large-filled-half-bow.svg'\nimport ReactionArrowUnbalancedEquilibriumOpenHalfAngle from './files/reaction-arrow-unbalanced-equilibrium-open-half-angle.svg'\nimport ReactionAutomapIcon from './files/reaction-automap.svg'\nimport ReactionMapIcon from './files/reaction-map.svg'\nimport ReactionPlusIcon from './files/reaction-plus.svg'\nimport ReactionUnmapIcon from './files/reaction-unmap.svg'\nimport RecognizeIcon from './files/recognize.svg'\nimport RedoIcon from './files/redo.svg'\nimport RgroupAttpointsIcon from './files/rgroup-attpoints.svg'\nimport RgroupFragmentIcon from './files/rgroup-fragment.svg'\nimport RgroupLabelIcon from './files/rgroup-label.svg'\nimport SaveIcon from './files/save.svg'\nimport SelectFragmentIcon from './files/select-fragment.svg'\nimport SelectLassoIcon from './files/select-lasso.svg'\nimport SelectRectangleIcon from './files/select-rectangle.svg'\nimport SettingsIcon from './files/settings.svg'\nimport SgroupDataIcon from './files/sgroup-data.svg'\nimport SgroupIcon from './files/sgroup.svg'\nimport ShapeEllipseIcon from './files/shape-ellipse.svg'\nimport ShapeLineIcon from './files/shape-line.svg'\nimport ShapePolylineIcon from './files/shape-polyline.svg'\nimport ShapeRectangleIcon from './files/shape-rectangle.svg'\nimport Template0Icon from './files/template-0.svg'\nimport Template1Icon from './files/template-1.svg'\nimport Template2Icon from './files/template-2.svg'\nimport Template3Icon from './files/template-3.svg'\nimport Template4Icon from './files/template-4.svg'\nimport Template5Icon from './files/template-5.svg'\nimport Template6Icon from './files/template-6.svg'\nimport Template7Icon from './files/template-7.svg'\nimport TemplateLibIcon from './files/template-lib.svg'\nimport TextBold from './files/text-bold.svg'\nimport TextIcon from './files/text.svg'\nimport TextItalic from './files/text-italic.svg'\nimport TextSubscript from './files/text-subscript.svg'\nimport TextSuperscript from './files/text-superscript.svg'\nimport TransformRotateIcon from './files/transform-rotate.svg'\nimport TransfromFlipHIcon from './files/transform-flip-h.svg'\nimport TransfromFlipVIcon from './files/transform-flip-v.svg'\nimport UndoIcon from './files/undo.svg'\nimport ZoomInIcon from './files/zoom-in.svg'\nimport ZoomOutIcon from './files/zoom-out.svg'\nimport FunctionalGroupsIcon from './files/functional-groups.svg'\n\nconst icons = {\n about: AboutIcon,\n analyse: AnalyseIcon,\n arom: AromIcon,\n 'bond-any': BondAnyIcon,\n 'bond-aromatic': BondAromaticIcon,\n 'bond-crossed': BondCrossedIcon,\n 'bond-hydrogen': BondHydrogenIcon,\n 'bond-dative': BondDative,\n 'bond-double': BondDoubleIcon,\n 'bond-doublearomatic': BondDoubleAromaticIcon,\n 'bond-down': BondDownIcon,\n 'bond-single': BondSingleIcon,\n 'bond-singlearomatic': BondSingleAromaticIcon,\n 'bond-singledouble': BondSingleDoubleIcon,\n 'bond-triple': BondTripleIcon,\n 'bond-up': BondUpIcon,\n 'bond-updown': BondUpdownIcon,\n chain: ChainIcon,\n 'charge-minus': ChargeMinusIcon,\n 'charge-plus': ChargePlusIcon,\n check: CheckIcon,\n 'chiral-flag': ChiralFlagIcon,\n cip: CipIcon,\n clean: CleanIcon,\n copies: CopyIcon,\n copy: CopyIcon,\n 'copy-image': CopyImageIcon,\n 'copy-mol': CopyMolIcon,\n 'copy-ket': CopyKetIcon,\n cut: CutIcon,\n dearom: DearomIcon,\n dropdown: DropdownIcon,\n 'enhanced-stereo': EnhancedStereoIcon,\n erase: EraseIcon,\n 'functional-groups': FunctionalGroupsIcon,\n 'generic-groups': GenericGroupsIcon,\n help: HelpIcon,\n layout: LayoutIcon,\n logo: LogoIcon,\n miew: MiewIcon,\n clear: ClearIcon,\n open: OpenIcon,\n paste: PasteIcon,\n 'period-table': PeriodTableIcon,\n 'reaction-arrow-open-angle': ReactionArrowOpenAngleIcon,\n 'reaction-arrow-filled-triangle': ReactionArrowFilledTriangle,\n 'reaction-arrow-filled-bow': ReactionArrowFilledBow,\n 'reaction-arrow-dashed-open-angle': ReactionArrowDashedOpenAngle,\n 'reaction-arrow-failed': ReactionArrowFailed,\n 'reaction-arrow-both-ends-filled-triangle':\n ReactionArrowBothEndsFilledTriangle,\n 'reaction-arrow-equilibrium-filled-half-bow':\n ReactionArrowEquilibriumFilledHalfBow,\n 'reaction-arrow-equilibrium-filled-triangle':\n ReactionArrowEquilibriumFilledTriangle,\n 'reaction-arrow-equilibrium-open-angle': ReactionArrowEquilibriumOpenAngle,\n 'reaction-arrow-unbalanced-equilibrium-filled-half-bow':\n ReactionArrowUnbalancedEquilibriumFilledHalfBow,\n 'reaction-arrow-unbalanced-equilibrium-open-half-angle':\n ReactionArrowUnbalancedEquilibriumOpenHalfAngle,\n 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow':\n ReactionArrowUnbalancedEquilibriumLargeFilledHalfBow,\n 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle':\n ReactionArrowUnbalancedEquilibriumFilledHalfTriangle,\n 'reaction-automap': ReactionAutomapIcon,\n 'reaction-map': ReactionMapIcon,\n 'reaction-plus': ReactionPlusIcon,\n 'reaction-unmap': ReactionUnmapIcon,\n recognize: RecognizeIcon,\n redo: RedoIcon,\n 'rgroup-attpoints': RgroupAttpointsIcon,\n 'rgroup-fragment': RgroupFragmentIcon,\n 'rgroup-label': RgroupLabelIcon,\n save: SaveIcon,\n 'select-fragment': SelectFragmentIcon,\n 'select-lasso': SelectLassoIcon,\n 'select-rectangle': SelectRectangleIcon,\n settings: SettingsIcon,\n 'sgroup-data': SgroupDataIcon,\n sgroup: SgroupIcon,\n 'template-0': Template0Icon,\n 'template-1': Template1Icon,\n 'template-2': Template2Icon,\n 'template-3': Template3Icon,\n 'template-4': Template4Icon,\n 'template-5': Template5Icon,\n 'template-6': Template6Icon,\n 'template-7': Template7Icon,\n 'template-lib': TemplateLibIcon,\n text: TextIcon,\n 'text-bold': TextBold,\n 'text-italic': TextItalic,\n 'text-subscript': TextSubscript,\n 'text-superscript': TextSuperscript,\n 'transform-flip-h': TransfromFlipHIcon,\n 'transform-flip-v': TransfromFlipVIcon,\n 'transform-rotate': TransformRotateIcon,\n undo: UndoIcon,\n 'zoom-in': ZoomInIcon,\n 'zoom-out': ZoomOutIcon,\n 'shape-ellipse': ShapeEllipseIcon,\n 'shape-rectangle': ShapeRectangleIcon,\n 'shape-polyline': ShapePolylineIcon,\n 'shape-line': ShapeLineIcon\n}\n\nfunction emptyIcon() {\n return null\n}\n\nexport default function findIconByName(name) {\n if (name && icons.hasOwnProperty(name)) {\n const component = icons[name]\n return component\n } else {\n return emptyIcon\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport findIconByName from './../../../../icons'\n\nfunction Icon({ name, ...props }) {\n const Component = findIconByName(name)\n return \n}\nexport default Icon\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nconst isMac = /Mac/.test(navigator.platform) // eslint-disable-line no-undef\nconst shortcutAliasMap = {\n Escape: 'Esc',\n Delete: 'Del',\n Mod: isMac ? '⌘' : 'Ctrl'\n}\n\nexport function shortcutStr(shortcut?: string | string[]) {\n if (!shortcut) {\n return ''\n }\n\n const shortcutKey = Array.isArray(shortcut) ? shortcut[0] : shortcut\n return shortcutKey.replace(\n /(\\b[a-z]\\b$|Mod|Escape|Delete)/g,\n key => shortcutAliasMap[key] || key.toUpperCase()\n )\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { UiAction, UiActionAction } from '../../../../action'\n\nimport Icon from '../../../../component/view/icon'\nimport classes from './ActionButton.module.less'\nimport clsx from 'clsx'\nimport { shortcutStr } from '../../shortcutStr'\n\ninterface ActionButtonProps {\n name: string\n action?: UiAction\n status?: {\n disabled?: boolean\n hidden?: boolean\n }\n selected?: boolean\n disableableButtons: string[]\n indigoVerification: boolean\n className?: string\n}\n\ninterface ActionButtonCallProps {\n onAction: (action: UiActionAction) => void\n}\n\ntype Props = ActionButtonProps & ActionButtonCallProps\n\nconst ActionButton = (props: Props) => {\n const {\n name,\n action,\n status = {},\n selected = false,\n disableableButtons,\n indigoVerification,\n className,\n onAction\n } = props\n\n if (status.hidden) {\n return null\n }\n\n const shortcut = shortcutStr(action?.shortcut)\n const disabled =\n status.disabled || (indigoVerification && disableableButtons.includes(name))\n\n const handleClick = event => {\n if (action?.action) {\n onAction(action.action)\n }\n event.stopPropagation()\n }\n\n return (\n \n \n {shortcut}\n \n )\n}\n\nexport type { ActionButtonProps, ActionButtonCallProps }\nexport { ActionButton }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { CSSProperties, Component } from 'react'\n\nimport ReactDOM from 'react-dom'\n\nconst CLASSNAME_SEPARATOR = ' '\n\ninterface PortalProps {\n isOpen: boolean\n className?: string\n style?: CSSProperties\n}\n\ntype Props = PortalProps\n\nclass Portal extends Component {\n private readonly element: HTMLDivElement\n private isElementInDom: boolean\n\n constructor(props) {\n super(props)\n this.element = document.createElement('div')\n this.isElementInDom = false\n }\n\n componentDidMount() {\n if (!this.isElementInDom && this.props.isOpen) {\n this.addElementInDOM()\n }\n\n const { className, style } = this.props\n if (className) {\n this.addClassName(className)\n }\n if (style) {\n this.updateStyle(style)\n }\n }\n\n componentWillUnmount() {\n if (this.isElementInDom) {\n this.removeElementFromDOM()\n }\n }\n\n componentDidUpdate(prevProps: Readonly) {\n const { isOpen, className, style } = this.props\n if (className !== prevProps.className) {\n this.removeClassNames(prevProps.className)\n this.addClassName(className)\n }\n\n if (style !== prevProps.style) {\n this.updateStyle(style, prevProps.style)\n }\n\n if (isOpen === prevProps.isOpen) {\n return\n }\n\n if (isOpen && !this.isElementInDom) {\n this.addElementInDOM()\n } else if (this.isElementInDom) {\n this.removeElementFromDOM()\n }\n }\n\n private addElementInDOM() {\n document.querySelector('body')?.appendChild(this.element)\n this.isElementInDom = true\n }\n\n private removeElementFromDOM() {\n document.querySelector('body')?.removeChild(this.element)\n this.isElementInDom = false\n }\n\n private removeClassNames(classNames?: string) {\n if (!classNames) {\n return\n }\n\n classNames.split(CLASSNAME_SEPARATOR).forEach(className => {\n this.element.classList.remove(className)\n })\n }\n\n private addClassName(classNames?: string) {\n if (!classNames) {\n return\n }\n\n classNames.split(CLASSNAME_SEPARATOR).forEach(className => {\n this.element.classList.add(className)\n })\n }\n\n private updateStyle(style?: CSSProperties, prevStyle?: CSSProperties) {\n if (prevStyle) {\n Object.keys(prevStyle).forEach(property => {\n this.element.style[property] = ''\n }, this)\n }\n\n if (!style) {\n return\n }\n\n Object.keys(style).forEach(property => {\n this.element.style[property] = style[property]\n }, this)\n }\n\n render() {\n const { children } = this.props\n return ReactDOM.createPortal(children, this.element)\n }\n}\n\nexport { Portal }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MultiToolCallProps, MultiToolProps } from '../variants.types'\n\nimport { ActionButton } from '../../../ActionButton'\nimport action from '../../../../../../action'\n\ninterface DefaultMultiToolProps extends MultiToolProps {}\ninterface DefaultMultiToolCallProps extends MultiToolCallProps {}\n\ntype Props = DefaultMultiToolProps & DefaultMultiToolCallProps\n\nconst DefaultMultiTool = (props: Props) => {\n const { options, status, disableableButtons, indigoVerification, onAction } =\n props\n\n return (\n <>\n {options.map(toolbarItem => {\n const currentStatus = status[toolbarItem.id]\n return (\n \n )\n })}\n \n )\n}\n\nexport type { DefaultMultiToolProps, DefaultMultiToolCallProps }\nexport { DefaultMultiTool }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MultiToolCallProps, MultiToolProps } from '../variants.types'\n\nimport { ActionButton } from '../../../ActionButton'\nimport action from '../../../../../../action'\nimport classes from './GroupedMultiTool.module.less'\n\ninterface GroupedMultiToolProps extends MultiToolProps {}\ninterface GroupedMultiToolCallProps extends MultiToolCallProps {}\n\ntype Props = GroupedMultiToolProps & GroupedMultiToolCallProps\n\nconst GroupedMultiTool = (props: Props) => {\n const {\n groups,\n options,\n status,\n disableableButtons,\n indigoVerification,\n onAction\n } = props\n\n if (!groups) {\n return null\n }\n\n return (\n <>\n {groups.map(descriptor => (\n
\n {options.slice(descriptor.start, descriptor.end).map(toolbarItem => {\n const currentStatus = status[toolbarItem.id]\n return (\n \n )\n })}\n
\n ))}\n \n )\n}\n\nexport type { GroupedMultiToolProps, GroupedMultiToolCallProps }\nexport { GroupedMultiTool }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ActionButton,\n ActionButtonCallProps,\n ActionButtonProps\n} from '../ActionButton'\nimport { GroupDescriptor, MultiToolVariant } from './variants/variants.types'\nimport { useRef } from 'react'\nimport { ToolbarItem, ToolbarItemVariant } from '../../toolbar.types'\nimport action, { UiAction, UiActionAction } from '../../../../action'\n\nimport Icon from '../../../../component/view/icon'\nimport { Portal } from '../../../../Portal'\nimport { chooseMultiTool } from './variants/chooseMultiTool'\nimport classes from './ToolbarMultiToolItem.module.less'\nimport clsx from 'clsx'\nimport { usePortalOpening } from './usePortalOpening'\nimport { usePortalStyle } from './usePortalStyle'\n\ninterface ToolbarMultiToolItemProps {\n id: ToolbarItemVariant\n options: ToolbarItem[]\n groups?: GroupDescriptor[]\n variant?: MultiToolVariant\n status: {\n [key in string]?: UiAction\n }\n opened: string | null\n disableableButtons: string[]\n indigoVerification: boolean\n className?: string\n vertical?: boolean\n}\n\ninterface ToolbarMultiToolItemCallProps {\n onAction: (action: UiActionAction) => void\n onOpen: (menuName: string, isSelected: boolean) => void\n}\n\ntype Props = ToolbarMultiToolItemProps & ToolbarMultiToolItemCallProps\n\nconst ToolbarMultiToolItem = (props: Props) => {\n const {\n id,\n options,\n groups,\n variant,\n status,\n opened,\n indigoVerification,\n disableableButtons,\n className,\n vertical,\n onAction,\n onOpen\n } = props\n\n const ref = useRef(null)\n const [isOpen] = usePortalOpening([id, opened, options])\n const [portalStyle] = usePortalStyle([ref, isOpen])\n\n let selected = false\n let currentId = id\n\n const selectedTool = options.find(\n toolbarItem => status[toolbarItem.id]?.selected\n )\n if (selectedTool) {\n currentId = selectedTool.id\n selected = true\n }\n\n const currentStatus = status[currentId]\n // todo: #type find out real type, possible GetActionState is no acceptable here\n // and check this type convert is redundant\n selected = selected || Boolean(currentStatus?.selected)\n\n const allInnerItemsHidden: boolean = options.every(\n option => status[option.id]?.hidden\n )\n\n const displayMultiToolItem: boolean = !(\n allInnerItemsHidden || currentStatus?.hidden\n )\n\n if (!currentStatus && options.length) {\n currentId =\n options.filter(option => !status[option.id]?.hidden)[0]?.id ||\n options[0].id\n }\n\n const actionButtonProps: Omit<\n ActionButtonProps & ActionButtonCallProps,\n 'name' | 'status' | 'action'\n > = {\n disableableButtons,\n indigoVerification,\n onAction\n }\n\n const onOpenOptions = () => {\n // todo: same as #type above\n onOpen(id, Boolean(currentStatus?.selected))\n }\n\n const [Component, portalClassName] = chooseMultiTool(variant)\n\n return displayMultiToolItem ? (\n
\n \n \n\n {isOpen ? (\n \n \n \n ) : null}\n
\n ) : null\n}\n\nexport type { ToolbarMultiToolItemProps, ToolbarMultiToolItemCallProps }\nexport { ToolbarMultiToolItem }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { useEffect, useState } from 'react'\n\nimport { ToolbarItem } from '../../toolbar.types'\n\ntype HookParams = [string, string | null, ToolbarItem[]]\n\nfunction usePortalOpening([id, opened, options]: HookParams): [boolean] {\n const [isOpen, setIsOpen] = useState(false)\n\n useEffect(() => {\n const currentId = (options.length && options![0].id) || ''\n const newState = opened === id || opened === currentId\n setIsOpen(newState)\n }, [opened, options])\n\n return [isOpen]\n}\n\nexport { usePortalOpening }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { CSSProperties, RefObject, useEffect, useState } from 'react'\n\ntype HookParams = [RefObject, boolean]\n\nfunction usePortalStyle([ref, isOpen]: HookParams): [CSSProperties] {\n const [portalStyle, setPortalStyle] = useState({})\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n const rect = ref.current.getBoundingClientRect()\n // if content is bigger than page height and user scrolled document, we should correct portal position\n const scrollOffset = document.scrollingElement?.scrollTop || 0\n const top = rect.top + scrollOffset\n\n const spaceBetween = 4\n const left = rect.left + rect.width + spaceBetween\n\n setPortalStyle({ top: `${top}px`, left: `${left}px` })\n }, [ref, ref.current, isOpen])\n\n return [portalStyle]\n}\n\nexport { usePortalStyle }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { DefaultMultiTool, classes as defaultClasses } from './DefaultMultiTool'\nimport {\n MultiToolCallProps,\n MultiToolProps,\n MultiToolVariant\n} from './variants.types'\n\nimport { ComponentType } from 'react'\nimport { GroupedMultiTool } from './GroupedMultiTool'\n\nexport function chooseMultiTool(\n variant: MultiToolVariant = 'default'\n): [ComponentType, string?] {\n switch (variant) {\n case 'default':\n return [DefaultMultiTool, defaultClasses.default]\n\n case 'grouped':\n return [GroupedMultiTool]\n\n default:\n throw new Error(`Unsupported variant ${variant}`)\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport action, { UiAction, UiActionAction } from '../../../action'\n\nimport { ActionButton } from './ActionButton'\nimport { ToolbarItem } from '../toolbar.types'\nimport { ToolbarMultiToolItem } from './ToolbarMultiToolItem'\n\ninterface ToolbarGroupItemProps extends ToolbarItem {\n status: {\n [key in string]?: UiAction\n }\n opened: string | null\n disableableButtons: string[]\n indigoVerification: boolean\n className?: string\n vertical?: boolean\n}\n\ninterface ToolbarGroupItemCallProps {\n onAction: (action: UiActionAction) => void\n onOpen: (menuName: string, isSelected: boolean) => void\n}\n\ntype Props = ToolbarGroupItemProps & ToolbarGroupItemCallProps\n\nconst ToolbarGroupItem = (props: Props) => {\n const {\n id,\n options,\n status,\n className,\n opened,\n indigoVerification,\n disableableButtons,\n vertical,\n onAction,\n onOpen\n } = props\n\n if (!options?.length) {\n return (\n \n )\n }\n\n return (\n \n )\n}\n\nexport type { ToolbarGroupItemProps, ToolbarGroupItemCallProps }\nexport { ToolbarGroupItem }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport action, { UiAction, UiActionAction } from '../../../../action'\n\nimport { ActionButton } from '../../ToolbarGroupItem/ActionButton'\nimport templates from '../../../../data/templates'\n\ninterface TemplatesListProps {\n active?: {\n tool?: string\n opts: {\n struct: any\n }\n }\n disableableButtons: string[]\n indigoVerification: boolean\n}\n\ninterface TemplatesListCallProps {\n onAction: (action: UiActionAction) => void\n}\n\ntype Props = TemplatesListProps & TemplatesListCallProps\n\nconst TemplatesList = (props: Props) => {\n const { active, disableableButtons, indigoVerification, onAction } = props\n\n const isTemplate = active && active.tool === 'template'\n\n const makeAction = (struct, index): UiAction => ({\n shortcut: action[`template-${index}`].shortcut,\n action: { tool: 'template', opts: { struct } },\n title: struct.name\n })\n\n return (\n <>\n {templates.map((struct, index) => (\n \n ))}\n \n )\n}\n\nexport type { TemplatesListProps, TemplatesListCallProps }\nexport { TemplatesList }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FC } from 'react'\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../ToolbarGroupItem'\n\nimport { TemplatesList } from './TemplatesList'\nimport classes from './BottomToolbar.module.less'\nimport clsx from 'clsx'\n\nconst Group: FC<{ className?: string }> = ({ children, className }) => (\n
{children}
\n)\n\ninterface BottomToolbarProps\n extends Omit {\n className?: string\n active?: {\n opts: any\n tool: string\n }\n}\n\ninterface BottomToolbarCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = BottomToolbarProps & BottomToolbarCallProps\n\nconst BottomToolbar = (props: Props) => {\n const { className, ...rest } = props\n const { active, disableableButtons, indigoVerification, onAction } = rest\n\n return (\n
\n \n \n \n\n \n \n \n \n
\n )\n}\n\nexport type { BottomToolbarProps, BottomToolbarCallProps }\nexport { BottomToolbar }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { MolSerializer, SdfSerializer } from 'ketcher-core'\n\nimport { appUpdate } from '../options'\nimport { storage } from '../../storage-ext'\n\nexport function initLib(lib) {\n return {\n type: 'TMPL_INIT',\n data: { lib }\n }\n}\n\nexport default function initTmplLib(dispatch, baseUrl, cacheEl) {\n const fileName = 'library.sdf'\n return deserializeSdfTemplates(baseUrl, cacheEl, fileName).then(res => {\n const lib = res.concat(userTmpls())\n dispatch(initLib(lib))\n dispatch(appUpdate({ templates: true }))\n })\n}\n\nconst deserializeSdfTemplates = (baseUrl, cacheEl, fileName) => {\n const sdfSerializer = new SdfSerializer()\n return prefetchStatic(`${baseUrl}/templates/${fileName}`).then(text => {\n const tmpls = sdfSerializer.deserialize(text)\n const prefetch = prefetchRender(tmpls, baseUrl + '/templates/', cacheEl)\n\n return prefetch.then(cachedFiles =>\n tmpls.map(tmpl => {\n const pr = prefetchSplit(tmpl)\n if (pr.file)\n tmpl.props.prerender =\n cachedFiles.indexOf(pr.file) !== -1 ? `#${pr.id}` : ''\n\n return tmpl\n })\n )\n })\n}\n\nfunction userTmpls() {\n const userLib = storage.getItem('ketcher-tmpls')\n if (!Array.isArray(userLib) || userLib.length === 0) return []\n const molSerializer = new MolSerializer()\n return userLib\n .map(tmpl => {\n try {\n if (tmpl.props === '') tmpl.props = {}\n tmpl.props.group = 'User Templates'\n\n return {\n struct: molSerializer.deserialize(tmpl.struct),\n props: tmpl.props\n }\n } catch (ex) {\n return null\n }\n })\n .filter(tmpl => tmpl !== null)\n}\n\nexport function prefetchStatic(url) {\n return fetch(url, { credentials: 'same-origin' }).then(resp => {\n if (resp.ok) return resp.text()\n throw Error('Could not fetch ' + url)\n })\n}\n\nfunction prefetchSplit(tmpl) {\n const pr = tmpl.props.prerender\n const res = pr && pr.split('#', 2)\n\n return {\n file: pr && res[0],\n id: pr && res[1]\n }\n}\n\nfunction prefetchRender(tmpls, baseUrl, cacheEl) {\n const files = tmpls.reduce((res, tmpl) => {\n const file = prefetchSplit(tmpl).file\n\n if (file && res.indexOf(file) === -1) res.push(file)\n\n return res\n }, [])\n const fetch = Promise.all(\n files.map(fn => prefetchStatic(baseUrl + fn).catch(() => null))\n )\n\n return fetch.then(svgs => {\n svgs.forEach(svgContent => {\n if (svgContent) cacheEl.innerHTML += svgContent\n })\n\n return files.filter((file, i) => !!svgs[i])\n })\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { formReducer, formsState } from './form'\n\nexport function openDialog(dispatch, dialogName, props) {\n return new Promise((resolve, reject) => {\n dispatch({\n type: 'MODAL_OPEN',\n data: {\n name: dialogName,\n prop: {\n ...props,\n onResult: resolve,\n onCancel: reject\n }\n }\n })\n })\n}\n\nfunction modalReducer(state = null, action) {\n const { type, data } = action\n\n if (type === 'UPDATE_FORM') {\n const formState = formReducer(state.form, action, state.name)\n return { ...state, form: formState }\n }\n\n switch (type) {\n case 'MODAL_CLOSE':\n return null\n case 'MODAL_OPEN':\n return {\n name: data.name,\n form: formsState[data.name] || null,\n prop: data.prop || null\n }\n default:\n return state\n }\n}\n\nexport default modalReducer\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport initTmplLib, { initLib } from './init-lib'\n\nimport { MolSerializer } from 'ketcher-core'\nimport { omit } from 'lodash/fp'\nimport { openDialog } from '../modal'\nimport { storage } from '../../storage-ext'\n\nexport { initTmplLib }\n\n/* TEMPLATES */\nexport function selectTmpl(tmpl) {\n return {\n type: 'TMPL_SELECT',\n data: { selected: tmpl }\n }\n}\n\nexport function changeGroup(group) {\n return {\n type: 'TMPL_CHANGE_GROUP',\n data: { group, selected: null }\n }\n}\n\nexport function changeFilter(filter) {\n return {\n type: 'TMPL_CHANGE_FILTER',\n data: { filter: filter.trim(), selected: null } // TODO: change this\n }\n}\n\n/* TEMPLATE-ATTACH-EDIT */\nexport function initAttach(name, attach) {\n return {\n type: 'INIT_ATTACH',\n data: {\n name,\n atomid: attach.atomid,\n bondid: attach.bondid\n }\n }\n}\n\nexport function setAttachPoints(attach) {\n return {\n type: 'SET_ATTACH_POINTS',\n data: {\n atomid: attach.atomid,\n bondid: attach.bondid\n }\n }\n}\n\nexport function setTmplName(name) {\n return {\n type: 'SET_TMPL_NAME',\n data: { name }\n }\n}\n\nexport function editTmpl(tmpl) {\n return (dispatch, getState) => {\n openDialog(dispatch, 'attach', { tmpl })\n .then(\n formData => {\n tmpl.struct.name = formData ? formData.name.trim() : tmpl.struct.name\n tmpl.props = formData\n ? Object.assign({}, tmpl.props, formData.attach)\n : tmpl.props\n\n if (tmpl.props.group === 'User Templates')\n updateLocalStore(getState().templates.lib)\n },\n () => null\n )\n .then(() => openDialog(dispatch, 'templates').catch(() => null))\n }\n}\n\nexport function deleteUserTmpl(tmpl) {\n return {\n type: 'TMPL_DELETE',\n data: {\n tmpl: tmpl\n }\n }\n}\n\nexport function deleteTmpl(tmpl) {\n return (dispatch, getState) => {\n const lib = getState().templates.lib.filter(value => value !== tmpl)\n dispatch(deleteUserTmpl(tmpl))\n updateLocalStore(lib)\n }\n}\n\n/* SAVE */\nexport function saveUserTmpl(struct) {\n // TODO: structStr can be not in mol format => structformat.toString ...\n const tmpl = { struct: struct.clone(), props: {} }\n\n return (dispatch, getState) => {\n openDialog(dispatch, 'attach', { tmpl })\n .then(({ name, attach }) => {\n tmpl.struct.name = name.trim()\n tmpl.props = { ...attach, group: 'User Templates' }\n\n const lib = getState().templates.lib.concat(tmpl)\n dispatch(initLib(lib))\n updateLocalStore(lib)\n })\n .catch(() => null)\n }\n}\n\nfunction updateLocalStore(lib) {\n const molSerializer = new MolSerializer()\n const userLib = lib\n .filter(item => item.props.group === 'User Templates')\n .map(item => ({\n struct: molSerializer.serialize(item.struct),\n props: Object.assign({}, omit(['group'], item.props))\n }))\n\n storage.setItem('ketcher-tmpls', userLib)\n}\n\n/* REDUCER */\nexport const initTmplsState = {\n lib: [],\n selected: null,\n filter: '',\n group: null,\n attach: {},\n mode: 'classic'\n}\n\nconst tmplActions = [\n 'TMPL_INIT',\n 'TMPL_SELECT',\n 'TMPL_CHANGE_GROUP',\n 'TMPL_CHANGE_FILTER'\n]\n\nconst attachActions = ['INIT_ATTACH', 'SET_ATTACH_POINTS', 'SET_TMPL_NAME']\n\nfunction templatesReducer(state = initTmplsState, action) {\n if (tmplActions.includes(action.type))\n return Object.assign({}, state, action.data)\n\n if (attachActions.includes(action.type)) {\n const attach = Object.assign({}, state.attach, action.data)\n return { ...state, attach }\n }\n\n if (action.type === 'TMPL_DELETE') {\n const currentState = Object.assign({}, state)\n const lib = currentState.lib.filter(value => value !== action.data.tmpl)\n return { ...currentState, lib: lib }\n }\n\n return state\n}\n\nexport default templatesReducer\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { isEmpty, isEqual, pickBy } from 'lodash/fp'\n\nimport actions from '../../action'\n\nfunction execute(activeTool, { action, editor, server, options }) {\n if (action.tool) {\n if (editor.tool(action.tool, action.opts)) {\n return action\n }\n } else if (typeof action === 'function') {\n action(editor, server, options)\n } else {\n console.info('no action')\n }\n return activeTool\n}\n\nfunction selected(actObj, activeTool, { editor, server }) {\n if (typeof actObj.selected === 'function')\n return actObj.selected(editor, server)\n else if (actObj.action && actObj.action.tool)\n return isEqual(activeTool, actObj.action)\n return false\n}\n\nfunction disabled(actObj, { editor, server, options }) {\n if (typeof actObj.disabled === 'function')\n return actObj.disabled(editor, server, options)\n return false\n}\n\nfunction hidden(actObj, { options }) {\n if (typeof actObj.hidden === 'function') return actObj.hidden(options)\n return false\n}\n\nfunction status(actionName, activeTool, params) {\n const actObj = actions[actionName]\n return pickBy(x => x, {\n selected: selected(actObj, activeTool, params),\n disabled: disabled(actObj, params),\n hidden: hidden(actObj, params)\n })\n}\n\nexport default function (state = null, { type, action, ...params }) {\n let activeTool\n switch (type) {\n case 'INIT':\n action = actions['select-lasso'].action\n case 'ACTION': // eslint-disable-line no-case-declarations\n activeTool = execute(state && state.activeTool, {\n ...params,\n action\n })\n case 'UPDATE':\n return Object.keys(actions).reduce(\n (res, actionName) => {\n const value = status(actionName, res.activeTool, params)\n if (!isEmpty(value)) res[actionName] = value\n return res\n },\n { activeTool: activeTool || state.activeTool }\n )\n default:\n return state\n }\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { capitalize, isEqual, throttle } from 'lodash/fp'\n\nimport { basicAtoms } from '../../action/atoms'\nimport tools from '../../action/tools'\n\nconst initial = {\n freqAtoms: [],\n currentAtom: 0,\n opened: null,\n visibleTools: {\n select: 'select-lasso'\n }\n}\nconst MAX_ATOMS = 7\n\nfunction updateVisibleTools(visibleTool, activeTool) {\n const regExp = /(bond)(-)(common|stereo|query)/\n const menuHeight = window.innerHeight\n\n return Object.keys(visibleTool).reduce(\n (res, key) => {\n if (key === 'bond' && menuHeight > 700) return res // TODO remove me after update styles\n if (key === 'transform' && menuHeight > 800) return res\n if (key === 'rgroup' && menuHeight > 850) return res\n if (key === 'shape' && menuHeight > 900) return res\n if (!key.match(regExp) || menuHeight > 700) res[key] = visibleTool[key]\n return res\n },\n { ...activeTool }\n )\n}\n\nexport function initResize() {\n return function (dispatch, getState) {\n const onResize = throttle(250, () => {\n const state = getState()\n state.editor.render.update()\n dispatch({ type: 'CLEAR_VISIBLE', data: state.actionState.activeTool })\n })\n addEventListener('resize', onResize) // eslint-disable-line\n }\n}\n\n/* REDUCER */\nexport default function (state = initial, action) {\n const { type, data } = action\n\n switch (type) {\n case 'ACTION': {\n const visibleTool = toolInMenu(action.action)\n return visibleTool\n ? {\n ...state,\n opened: null,\n visibleTools: { ...state.visibleTools, ...visibleTool }\n }\n : { ...state, opened: null }\n }\n case 'ADD_ATOMS': {\n const newState = addFreqAtom(data, state.freqAtoms, state.currentAtom)\n return { ...state, ...newState }\n }\n case 'CLEAR_VISIBLE': {\n const activeTool = toolInMenu(action.data)\n const correctTools = updateVisibleTools(state.visibleTools, activeTool)\n return { ...state, opened: null, visibleTools: { ...correctTools } }\n }\n case 'OPENED': {\n return data.isSelected && state.opened\n ? { ...state, opened: null }\n : { ...state, opened: data.menuName }\n }\n case 'UPDATE':\n return { ...state, opened: null }\n case 'MODAL_OPEN':\n return { ...state, opened: null }\n default:\n return state\n }\n}\n/* ------- */\n\nfunction addFreqAtom(label, freqAtoms, index) {\n label = capitalize(label)\n if (basicAtoms.indexOf(label) > -1 || freqAtoms.indexOf(label) !== -1)\n return { freqAtoms }\n\n freqAtoms[index] = label\n index = (index + 1) % MAX_ATOMS\n\n return { freqAtoms, currentAtom: index }\n}\n\nexport function addAtoms(atomLabel) {\n return {\n type: 'ADD_ATOMS',\n data: atomLabel\n }\n}\n\nfunction toolInMenu(action) {\n const tool = Object.keys(tools).find(toolName =>\n isEqual(action, tools[toolName].action)\n )\n\n const sel = document.getElementById(tool)\n const dropdown = sel && hiddenAncestor(sel)\n\n return dropdown && dropdown.id !== '' ? { [dropdown.id]: sel.id } : null\n}\n\nexport function hiddenAncestor(el, base) {\n base = base || document.body\n let findEl = el\n\n while (\n findEl &&\n window.getComputedStyle(findEl).overflow !== 'hidden' &&\n !findEl.classList.contains('opened')\n ) {\n if (findEl === base) return null\n findEl = findEl.parentNode\n }\n\n return findEl\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AnyAction } from 'redux'\nimport { appUpdate } from '../options'\nimport {\n FunctionalGroupsProvider,\n SdfItem,\n SdfSerializer,\n Struct\n} from 'ketcher-core'\nimport { prefetchStatic } from '../templates/init-lib'\n\ninterface FGState {\n lib: []\n mode: string\n}\n\nconst initialState: FGState = {\n lib: [],\n mode: 'fg'\n}\n\nconst functionalGroupsReducer = (\n state = initialState,\n { type, payload }: AnyAction\n) => {\n switch (type) {\n case 'FG_INIT':\n return { ...state, ...payload }\n\n default:\n return state\n }\n}\n\nconst initFGroups = (lib: SdfItem[]) => ({ type: 'FG_INIT', payload: { lib } })\n\nexport function initFGTemplates(baseUrl: string) {\n return async dispatch => {\n const fileName = 'fg.sdf'\n const url = `${baseUrl}/templates/${fileName}`\n const provider = FunctionalGroupsProvider.getInstance()\n const sdfSerializer = new SdfSerializer()\n const text = await prefetchStatic(url)\n const templates = sdfSerializer.deserialize(text)\n const functionalGroups = templates.reduce(\n (acc: Struct[], { struct }) => [...acc, struct],\n []\n )\n provider.setFunctionalGroupsList(functionalGroups)\n dispatch(initFGroups(templates))\n dispatch(appUpdate({ functionalGroups: true }))\n }\n}\n\nexport default functionalGroupsReducer\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { applyMiddleware, combineReducers, createStore } from 'redux'\nimport { load, onAction } from './shared'\nimport optionsReducer, { initOptionsState } from './options'\nimport templatesReducer, { initTmplsState } from './templates'\n\nimport actionStateReducer from './action'\nimport { logger } from 'redux-logger'\nimport modalReducer from './modal'\nimport { pick } from 'lodash/fp'\nimport requestReducer from './request'\nimport thunk from 'redux-thunk'\nimport toolbarReducer from './toolbar'\nimport functionalGroupsReducer from './functionalGroups'\n\nexport { onAction, load }\n\nconst shared = combineReducers({\n actionState: actionStateReducer,\n toolbar: toolbarReducer,\n modal: modalReducer,\n server: (store = null) => store,\n editor: (store = null) => store,\n options: optionsReducer,\n templates: templatesReducer,\n functionalGroups: functionalGroupsReducer,\n requestsStatuses: requestReducer\n})\n\nfunction getRootReducer(setEditor) {\n return function root(state, action) {\n switch (\n action.type // eslint-disable-line default-case\n ) {\n case 'INIT':\n setEditor(action.editor)\n\n case 'UPDATE': // eslint-disable-line no-case-declarations\n const { type, ...data } = action\n if (data) state = { ...state, ...data }\n }\n\n const sh = shared(state, {\n ...action,\n ...pick(['editor', 'server', 'options'], state)\n })\n\n const finalState =\n sh === state.shared\n ? state\n : {\n ...state,\n ...sh\n }\n\n //TODO: temporary solution. Need to review work with redux store\n global.currentState = finalState\n return finalState\n }\n}\n\nexport default function (options, server, setEditor) {\n const { buttons = {}, ...restOptions } = options\n\n // TODO: redux localStorage here\n const initState = {\n actionState: null,\n editor: null,\n modal: null,\n options: Object.assign(initOptionsState, { app: restOptions, buttons }),\n server: server || Promise.reject(new Error('Standalone mode!')),\n templates: initTmplsState\n }\n\n const middleware = [thunk]\n\n if (process.env.NODE_ENV !== 'production') middleware.push(logger)\n\n const rootReducer = getRootReducer(setEditor)\n return createStore(rootReducer, initState, applyMiddleware(...middleware))\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n BottomToolbar,\n BottomToolbarCallProps,\n BottomToolbarProps\n} from './BottomToolbar'\n\nimport { ComponentType } from 'react'\nimport { Dispatch } from 'redux'\nimport { connect } from 'react-redux'\nimport { onAction } from '../../../state'\n\ntype StateProps = Omit\ntype OwnProps = Pick\n\nconst mapStateToProps = (state): StateProps => ({\n active: state.actionState && state.actionState.activeTool,\n status: state.actionState || {},\n opened: state.toolbar.opened,\n indigoVerification: state.requestsStatuses.indigoVerification,\n disableableButtons: []\n})\n\nconst mapDispatchToProps = (dispatch: Dispatch): BottomToolbarCallProps => ({\n onAction: action => dispatch(onAction(action)),\n onOpen: (menuName, isSelected) =>\n dispatch({\n type: 'OPENED',\n data: { menuName, isSelected }\n })\n})\n\nconst BottomToolbarContainer: ComponentType = connect(\n mapStateToProps,\n mapDispatchToProps\n)(BottomToolbar)\n\nexport { BottomToolbarContainer }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ToolbarItem, ToolbarItemVariant } from '../../toolbar.types'\n\nfunction makeItems(ids: ToolbarItemVariant[]): ToolbarItem[] {\n return ids.map(id => ({ id }))\n}\n\nexport { makeItems }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { GroupDescriptor } from '../../ToolbarGroupItem/ToolbarMultiToolItem/variants/variants.types'\nimport { ToolbarItem } from '../../toolbar.types'\nimport { makeItems } from '../../ToolbarGroupItem/utils'\n\nconst bondCommon: ToolbarItem[] = makeItems([\n 'bond-single',\n 'bond-double',\n 'bond-triple'\n])\nconst bondStereo: ToolbarItem[] = makeItems([\n 'bond-up',\n 'bond-down',\n 'bond-updown',\n 'bond-crossed'\n])\nconst bondQuery: ToolbarItem[] = makeItems([\n 'bond-any',\n 'bond-aromatic',\n 'bond-singledouble',\n 'bond-singlearomatic',\n 'bond-doublearomatic'\n])\nconst bondSpecial: ToolbarItem[] = makeItems(['bond-dative', 'bond-hydrogen'])\n\nconst groups = [bondCommon, bondStereo, bondQuery, bondSpecial]\nconst groupOptions = groups.flat()\nconst groupDescriptors = groups.reduce((accum, group, index) => {\n const start = accum[index - 1]?.end || 0\n\n accum.push({\n start: start,\n end: start + group.length\n })\n\n return accum\n}, [] as GroupDescriptor[])\n\nexport {\n bondCommon,\n bondStereo,\n bondQuery,\n bondSpecial,\n groupOptions,\n groupDescriptors\n}\n","import { bondCommon, bondQuery, bondSpecial, bondStereo } from './Bond/options'\nimport { makeItems } from '../ToolbarGroupItem/utils'\nimport { ToolbarItem } from '../toolbar.types'\n\nconst rGroupOptions: ToolbarItem[] = makeItems([\n 'rgroup-label',\n 'rgroup-fragment',\n 'rgroup-attpoints'\n])\n\nconst shapeOptions: ToolbarItem[] = makeItems([\n 'shape-ellipse',\n 'shape-rectangle',\n 'shape-line'\n])\n\nconst transformOptions: ToolbarItem[] = makeItems([\n 'transform-rotate',\n 'transform-flip-h',\n 'transform-flip-v'\n])\n\nconst selectOptions: ToolbarItem[] = makeItems([\n 'select-lasso',\n 'select-rectangle',\n 'select-fragment'\n])\n\nconst arrowsOptions: ToolbarItem[] = makeItems([\n 'reaction-arrow-open-angle',\n 'reaction-arrow-filled-triangle',\n 'reaction-arrow-filled-bow',\n 'reaction-arrow-dashed-open-angle',\n 'reaction-arrow-failed',\n 'reaction-arrow-both-ends-filled-triangle',\n 'reaction-arrow-equilibrium-filled-half-bow',\n 'reaction-arrow-equilibrium-filled-triangle',\n 'reaction-arrow-equilibrium-open-angle',\n 'reaction-arrow-unbalanced-equilibrium-filled-half-bow',\n 'reaction-arrow-unbalanced-equilibrium-open-half-angle',\n 'reaction-arrow-unbalanced-equilibrium-large-filled-half-bow',\n 'reaction-arrow-unbalanced-equilibrium-filled-half-triangle'\n])\n\nconst mappingOptions: ToolbarItem[] = makeItems([\n 'reaction-map',\n 'reaction-unmap',\n 'reaction-automap'\n])\n\nexport {\n rGroupOptions,\n bondCommon,\n bondQuery,\n bondSpecial,\n bondStereo,\n shapeOptions,\n transformOptions,\n selectOptions,\n arrowsOptions,\n mappingOptions\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport React from 'react'\nimport SettingsContext from './../contexts/settingsContext'\n\nexport function useSettingsContext() {\n return React.useContext(SettingsContext)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { RefCallback, RefObject, useMemo, useState } from 'react'\n\nimport { throttle } from 'lodash'\nimport useResizeObserver from 'use-resize-observer/polyfilled'\n\nconst throttleMilliseconds = 100\n\ntype Size = {\n width: number | undefined\n height: number | undefined\n}\n\ntype Options = {\n ref?: RefObject | THTMLElement | null | undefined\n}\n\ntype HookResponse = {\n ref: RefCallback\n width: number | undefined\n height: number | undefined\n}\n\nfunction useThrottleResizeObserver(\n options: Options = {}\n): HookResponse {\n const [size, setSize] = useState({\n height: undefined,\n width: undefined\n })\n\n const onResize = useMemo(() => throttle(setSize, throttleMilliseconds), [])\n\n const { ref } = useResizeObserver({ onResize, ...options })\n return { ref, ...size }\n}\n\nexport { useThrottleResizeObserver as useResizeObserver }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport FormContext from './../contexts/formContext'\nimport React from 'react'\n\nexport function useFormContext() {\n return React.useContext(FormContext)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport AppContext from '../contexts/appContext'\nimport React from 'react'\n\nexport const useAppContext = () => React.useContext(AppContext)\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { useEffect, useRef } from 'react'\n\nexport const useInterval = (callback: () => void, delay: number | null) => {\n const savedCallback = useRef(callback)\n\n // Remember the latest callback if it changes.\n useEffect(() => {\n savedCallback.current = callback\n }, [callback])\n\n // Set up the interval.\n useEffect(() => {\n // Don't schedule if no delay is specified.\n if (delay === null) {\n return\n }\n\n const id = setInterval(() => savedCallback.current(), delay)\n\n return () => clearInterval(id)\n }, [delay])\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport classes from './ArrowScroll.module.less'\nimport clsx from 'clsx'\nimport { useEffect, useState } from 'react'\nimport { useInterval } from '../../../../../hooks'\n\ninterface ArrowScrollProps {\n startInView: boolean\n endInView: boolean\n scrollUp: any\n scrollDown: any\n}\n\nconst ArrowScroll = ({\n startInView,\n endInView,\n scrollUp,\n scrollDown\n}: ArrowScrollProps) => {\n const [isScrollDown, setScrollDown] = useState(false)\n const [isScrollUp, setScrollUp] = useState(false)\n useInterval(scrollDown, isScrollDown ? 100 : null)\n useInterval(scrollUp, isScrollUp ? 100 : null)\n\n useEffect(() => {\n return () => {\n setScrollUp(false)\n }\n }, [startInView])\n\n useEffect(() => {\n return () => {\n setScrollDown(false)\n }\n }, [endInView])\n\n return (\n
\n {endInView ? (\n <>\n ) : (\n scrollDown()}\n onMouseUp={() => setScrollDown(false)}\n onMouseDown={() => setScrollDown(true)}\n className={clsx(classes.button, classes.down)}\n >\n ▼\n \n )}\n {startInView ? (\n <>\n ) : (\n scrollUp()}\n onMouseUp={() => setScrollUp(false)}\n onMouseDown={() => setScrollUp(true)}\n className={clsx(classes.button, classes.up)}\n >\n ▲\n \n )}\n
\n )\n}\n\nexport { ArrowScroll }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nconst mediaSizes = {\n topSeparatorsShowingWidth: 1080,\n zoomShowingWidth: 780,\n infoShowingWidth: 790,\n bondCollapsableHeight: 770,\n rGroupCollapsableHeight: 1000,\n shapeCollapsableHeight: 1000,\n transformCollapsableHeight: 870\n}\n\nexport { mediaSizes }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../../ToolbarGroupItem'\nimport {\n bondCommon,\n bondQuery,\n bondSpecial,\n bondStereo,\n groupDescriptors,\n groupOptions\n} from './options'\n\nimport { ToolbarMultiToolItem } from '../../ToolbarGroupItem/ToolbarMultiToolItem'\nimport { mediaSizes } from '../../mediaSizes'\n\ninterface BondProps extends Omit {\n height?: number\n}\ninterface BondCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = BondProps & BondCallProps\n\nconst Bond = (props: Props) => {\n const { height, ...rest } = props\n\n if (height && height <= mediaSizes.bondCollapsableHeight) {\n return (\n \n )\n }\n\n return (\n <>\n \n \n \n \n \n )\n}\n\nexport type { BondProps, BondCallProps }\nexport { Bond }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../../ToolbarGroupItem'\n\nimport { rGroupOptions } from '../leftToolbarOptions'\n\ninterface RGroupProps extends Omit {\n height?: number\n}\ninterface RGroupCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = RGroupProps & RGroupCallProps\n\nconst RGroup = (props: Props) => {\n return \n}\n\nexport type { RGroupProps, RGroupCallProps }\nexport { RGroup }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../../ToolbarGroupItem'\n\nimport { shapeOptions } from '../leftToolbarOptions'\n\ninterface ShapeProps extends Omit {\n height?: number\n}\ninterface ShapeCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = ShapeProps & ShapeCallProps\n\nconst Shape = (props: Props) => {\n return \n}\n\nexport type { ShapeProps, ShapeCallProps }\nexport { Shape }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../../ToolbarGroupItem'\n\nimport { transformOptions } from '../leftToolbarOptions'\nimport { mediaSizes } from '../../mediaSizes'\n\ninterface TransformProps extends Omit {\n height?: number\n}\ninterface TransformCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = TransformProps & TransformCallProps\n\nconst Transform = (props: Props) => {\n const { height, ...rest } = props\n\n if (height && height <= mediaSizes.transformCollapsableHeight) {\n return (\n \n )\n }\n\n return (\n <>\n \n \n \n \n )\n}\n\nexport type { TransformProps, TransformCallProps }\nexport { Transform }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FC, MutableRefObject, useRef } from 'react'\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../ToolbarGroupItem'\nimport { ToolbarItem, ToolbarItemVariant } from '../toolbar.types'\nimport {\n arrowsOptions,\n bondCommon,\n bondQuery,\n bondSpecial,\n bondStereo,\n mappingOptions,\n rGroupOptions,\n selectOptions,\n shapeOptions,\n transformOptions\n} from './leftToolbarOptions'\n\nimport { ArrowScroll } from '../ArrowScroll'\nimport { Bond } from './Bond'\nimport { RGroup } from './RGroup'\nimport { Shape } from './Shape'\nimport { Transform } from './Transform'\nimport classes from './LeftToolbar.module.less'\nimport clsx from 'clsx'\nimport { useInView } from 'react-intersection-observer'\nimport { useResizeObserver } from '../../../../../hooks'\n\ninterface LeftToolbarProps\n extends Omit {\n className?: string\n}\n\ninterface LeftToolbarCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = LeftToolbarProps & LeftToolbarCallProps\n\nconst LeftToolbar = (props: Props) => {\n const { className, ...rest } = props\n const { ref, height } = useResizeObserver()\n const scrollRef = useRef() as MutableRefObject\n const [startRef, startInView] = useInView({ threshold: 0.8 })\n const [endRef, endInView] = useInView({ threshold: 0.8 })\n const sizeRef = useRef() as MutableRefObject\n\n type ItemProps = {\n id: ToolbarItemVariant\n options?: ToolbarItem[]\n }\n const Item = ({ id, options }: ItemProps) =>\n ToolbarGroupItem({ id, options, ...rest })\n\n const scrollUp = () => {\n scrollRef.current.scrollTop -= sizeRef.current.offsetHeight\n }\n\n const scrollDown = () => {\n scrollRef.current.scrollTop += sizeRef.current.offsetHeight\n }\n\n const status = rest.status\n\n type GroupItem = ItemProps\n\n const Group: FC<{ items?: GroupItem[]; className?: string }> = ({\n items,\n className\n }) => {\n const visibleItems: GroupItem[] = []\n if (items) {\n items.forEach(item => {\n let visible = true\n if (status[item.id]?.hidden) {\n visible = false\n } else if (item.options?.every(option => status[option.id]?.hidden)) {\n visible = false\n }\n if (visible) visibleItems.push(item)\n })\n }\n return visibleItems.length ? (\n
\n {visibleItems.map(item => {\n switch (item.id) {\n case 'bond-common':\n return \n case 'transform-rotate':\n return \n case 'rgroup':\n return \n case 'shapes':\n return \n default:\n return \n }\n })}\n
\n ) : null\n }\n\n return (\n
\n
\n
\n \n
\n\n \n\n \n\n \n\n \n\n \n
\n \n
\n\n \n\n
\n \n
\n
\n \n
\n )\n}\n\nexport type { LeftToolbarProps, LeftToolbarCallProps }\nexport { LeftToolbar }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n LeftToolbar,\n LeftToolbarCallProps,\n LeftToolbarProps\n} from './LeftToolbar'\n\nimport { Dispatch } from 'redux'\nimport { connect } from 'react-redux'\nimport { onAction } from '../../../state'\n\ntype StateProps = Omit\n\nconst mapStateToProps = (state: any): StateProps => ({\n status: state.actionState || {},\n opened: state.toolbar.opened,\n indigoVerification: state.requestsStatuses.indigoVerification,\n disableableButtons: []\n})\n\nconst mapDispatchToProps = (dispatch: Dispatch): LeftToolbarCallProps => ({\n onAction: action => dispatch(onAction(action)),\n onOpen: (menuName, isSelected) =>\n dispatch({\n type: 'OPENED',\n data: { menuName, isSelected }\n })\n})\n\nconst LeftToolbarContainer = connect(\n mapStateToProps,\n mapDispatchToProps\n)(LeftToolbar)\n\nexport { LeftToolbarContainer }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ElementColor } from 'ketcher-core'\n\nfunction Atom({ el, shortcut, className, ...props }) {\n return (\n \n {el.label}\n \n )\n}\n\nexport default Atom\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { atomCuts, basicAtoms } from '../../../../action/atoms'\n\nimport Atom from '../../../../component/view/Atom'\nimport { Elements } from 'ketcher-core'\nimport { UiActionAction } from '../../../../action'\nimport classes from '../../ToolbarGroupItem/ActionButton/ActionButton.module.less'\nimport clsx from 'clsx'\nimport { shortcutStr } from '../../shortcutStr'\nimport { forwardRef } from 'react'\n\ninterface AtomsListProps {\n atoms: string[]\n active?: {\n tool?: string\n opts: {\n label: any\n }\n }\n}\n\ninterface AtomsListCallProps {\n onAction: (action: UiActionAction) => void\n}\n\ntype Props = AtomsListProps & AtomsListCallProps\n\nconst AtomsList = forwardRef((props: Props, ref) => {\n const { atoms, active, onAction } = props\n const isAtom = active && active.tool === 'atom'\n\n return (\n <>\n {atoms.map(label => {\n const element = Elements.get(label)\n const shortcut =\n basicAtoms.indexOf(label) > -1 ? shortcutStr(atomCuts[label]) : null\n\n if (basicAtoms.indexOf(label) === 0) {\n return (\n // @ts-ignore\n
\n onAction({ tool: 'atom', opts: { label } })}\n />\n
\n )\n }\n return (\n onAction({ tool: 'atom', opts: { label } })}\n />\n )\n })}\n \n )\n})\n\nexport type { AtomsListProps, AtomsListCallProps }\nexport { AtomsList }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FC, MutableRefObject, useRef } from 'react'\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../ToolbarGroupItem'\n\nimport { ArrowScroll } from '../ArrowScroll'\nimport { AtomsList } from './AtomsList'\nimport { basicAtoms } from '../../../action/atoms'\nimport classes from './RightToolbar.module.less'\nimport clsx from 'clsx'\nimport { useInView } from 'react-intersection-observer'\n\nconst Group: FC<{ className?: string }> = ({ children, className }) => (\n
{children}
\n)\n\ninterface RightToolbarProps\n extends Omit {\n className?: string\n active?: {\n opts: any\n tool: string\n }\n freqAtoms: any[]\n}\n\ninterface RightToolbarCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = RightToolbarProps & RightToolbarCallProps\n\nconst RightToolbar = (props: Props) => {\n const { className, ...rest } = props\n const { active, onAction, freqAtoms } = rest\n const [startRef, startInView] = useInView({ threshold: 0.9 })\n const [endRef, endInView] = useInView({ threshold: 0.9 })\n const sizeRef = useRef() as MutableRefObject\n const scrollRef = useRef() as MutableRefObject\n\n const scrollUp = () => {\n scrollRef.current.scrollTop -= sizeRef.current.offsetHeight\n }\n\n const scrollDown = () => {\n scrollRef.current.scrollTop += sizeRef.current.offsetHeight\n }\n\n return (\n
\n
\n \n \n \n \n\n \n
\n \n
\n
\n
\n \n \n \n
\n
\n \n
\n )\n}\n\nexport type { RightToolbarProps, RightToolbarCallProps }\nexport { RightToolbar }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n RightToolbar,\n RightToolbarCallProps,\n RightToolbarProps\n} from './RightToolbar'\n\nimport { ComponentType } from 'react'\nimport { Dispatch } from 'redux'\nimport { connect } from 'react-redux'\nimport { onAction } from '../../../state'\n\ntype StateProps = Omit\ntype OwnProps = Pick\n\nconst mapStateToProps = (state): StateProps => ({\n active: state.actionState && state.actionState.activeTool,\n status: state.actionState || {},\n freqAtoms: state.toolbar.freqAtoms,\n opened: state.toolbar.opened,\n indigoVerification: state.requestsStatuses.indigoVerification,\n disableableButtons: []\n})\n\nconst mapDispatchToProps = (dispatch: Dispatch): RightToolbarCallProps => ({\n onAction: action => dispatch(onAction(action)),\n onOpen: (menuName, isSelected) =>\n dispatch({\n type: 'OPENED',\n data: { menuName, isSelected }\n })\n})\n\nconst RightToolbarContainer: ComponentType = connect(\n mapStateToProps,\n mapDispatchToProps\n)(RightToolbar)\n\nexport { RightToolbarContainer }\nexport default RightToolbarContainer\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { UiActionAction } from '../../../../action'\nimport { zoomList } from '../../../../action/zoom'\n\nfunction toPercent(value: number): string {\n const percentLimit = 100\n return (value * percentLimit).toFixed()\n}\n\ninterface ZoomListProps {\n status: {\n zoom?: {\n selected?: number\n }\n }\n}\n\ninterface ZoomListCallProps {\n onAction: (action: UiActionAction) => void\n}\n\ntype Props = ZoomListProps & ZoomListCallProps\n\nconst ZoomList = (props: Props) => {\n const { status = {}, onAction } = props\n const zoom = status.zoom && status.zoom.selected // TMP\n\n const handleChange = event => {\n const parsedValue = parseFloat(event.target.value)\n onAction(editor => editor.zoom(parsedValue))\n }\n\n return (\n \n )\n}\n\nexport type { ZoomListProps, ZoomListCallProps }\nexport { ZoomList }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport Icon from '../../../../component/view/icon'\nimport { shortcutStr } from '../../shortcutStr'\nimport classes from './HelpLink.module.less'\n\nconst HelpLink = ({ status }) => {\n if (status?.hidden) {\n return null\n }\n const shortcut = shortcutStr(['?', '&', 'Shift+/'])\n const helpLink = process.env.HELP_LINK\n\n return (\n \n \n {shortcut}\n \n )\n}\n\nexport { HelpLink }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FC } from 'react'\nimport {\n ToolbarGroupItem,\n ToolbarGroupItemCallProps,\n ToolbarGroupItemProps\n} from '../ToolbarGroupItem'\nimport { ToolbarItem, ToolbarItemVariant } from '../toolbar.types'\n\nimport { ZoomList } from './ZoomList'\nimport classes from './TopToolbar.module.less'\nimport clsx from 'clsx'\nimport { makeItems } from '../ToolbarGroupItem/utils'\nimport { mediaSizes } from '../mediaSizes'\nimport { useResizeObserver } from '../../../../../hooks'\nimport { HelpLink } from './HelpLink/HelpLink'\n\nconst Group: FC<{ className?: string }> = ({ children, className }) => (\n
{children}
\n)\n\nconst copyOptions: ToolbarItem[] = makeItems([\n 'copy',\n 'copy-mol',\n 'copy-ket',\n 'copy-image'\n])\n\ninterface TopToolbarProps\n extends Omit {\n className?: string\n}\n\ninterface TopToolbarCallProps extends ToolbarGroupItemCallProps {}\n\ntype Props = TopToolbarProps & TopToolbarCallProps\n\nconst TopToolbar = (props: Props) => {\n const { className, status, ...rest } = props\n const { ref, width } = useResizeObserver()\n const isZoomListHidden = !status['zoom-list']?.hidden\n\n type ItemProps = {\n id: ToolbarItemVariant\n options?: ToolbarItem[]\n className?: string\n vertical?: boolean\n }\n const Item = ({ id, options, className, vertical }: ItemProps) =>\n ToolbarGroupItem({ id, options, className, vertical, status, ...rest })\n\n return (\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n\n \n {width && width >= mediaSizes.zoomShowingWidth ? (\n <>\n \n \n \n ) : null}\n {isZoomListHidden && (\n \n )}\n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n\n \n \n {width && width >= mediaSizes.infoShowingWidth ? (\n <>\n \n \n \n ) : null}\n \n \n )\n}\n\nexport type { TopToolbarProps, TopToolbarCallProps }\nexport { TopToolbar }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { TopToolbar, TopToolbarCallProps, TopToolbarProps } from './TopToolbar'\n\nimport { Dispatch } from 'redux'\nimport { connect } from 'react-redux'\nimport { onAction } from '../../../state'\n\ntype StateProps = Omit\n\nconst mapStateToProps = (state: any): StateProps => ({\n status: state.actionState || {},\n opened: state.toolbar.opened,\n indigoVerification: state.requestsStatuses.indigoVerification,\n disableableButtons: ['layout', 'clean', 'arom', 'dearom', 'cip']\n})\n\nconst mapDispatchToProps = (dispatch: Dispatch): TopToolbarCallProps => ({\n onAction: action => dispatch(onAction(action)),\n onOpen: (menuName, isSelected) =>\n dispatch({\n type: 'OPENED',\n data: { menuName, isSelected }\n })\n})\n\nconst TopToolbarContainer = connect(\n mapStateToProps,\n mapDispatchToProps\n)(TopToolbar)\n\nexport { TopToolbarContainer }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport * as KN from 'w3c-keyname'\n\nconst mac =\n typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false // eslint-disable-line no-undef\n\nfunction normalizeKeyName(name) {\n const parts = name.split(/\\+(?!$)/)\n let result = parts[parts.length - 1]\n if (result === 'Space') result = ' '\n let alt\n let ctrl\n let shift\n let meta\n\n for (let i = 0; i < parts.length - 1; i++) {\n const mod = parts[i]\n if (/^(cmd|meta|m)$/i.test(mod)) meta = true\n else if (/^a(lt)?$/i.test(mod)) alt = true\n else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true\n else if (/^s(hift)?$/i.test(mod)) shift = true\n else if (/^mod$/i.test(mod))\n if (mac) meta = true\n else ctrl = true\n else throw new Error('Unrecognized modifier name: ' + mod)\n }\n\n if (alt) result = 'Alt+' + result\n if (ctrl) result = 'Ctrl+' + result\n if (meta) result = 'Meta+' + result\n if (shift) result = 'Shift+' + result\n\n return result\n}\n\nfunction normalizeKeyMap(map) {\n const copy = Object.create(null)\n\n Object.keys(map).forEach(prop => {\n copy[normalizeKeyName(prop)] = map[prop]\n })\n\n return copy\n}\n\nfunction modifiers(name, event, shift) {\n if (event.altKey) name = 'Alt+' + name\n if (event.ctrlKey) name = 'Ctrl+' + name\n if (event.metaKey) name = 'Meta+' + name\n if (shift !== false && event.shiftKey) name = 'Shift+' + name\n\n return name\n}\n\nfunction rusToEng(name, event) {\n return name\n .replace(/[а-я]/, KN.base[event.keyCode])\n .replace(/[А-Я]/, KN.shift[event.keyCode])\n}\n\nfunction normalizeKeyEvent(event, base = false) {\n const name = rusToEng(KN.keyName(event), event)\n const isChar = name.length === 1 && name !== ' '\n\n return isChar && !base\n ? modifiers(name, event, !isChar)\n : modifiers(KN.base[event.keyCode], event, true)\n}\n\nfunction keyNorm(obj) {\n if (obj instanceof KeyboardEvent)\n // eslint-disable-line no-undef\n return normalizeKeyEvent(...arguments) // eslint-disable-line prefer-rest-params\n\n return typeof obj === 'object' ? normalizeKeyMap(obj) : normalizeKeyName(obj)\n}\n\nfunction lookup(map, event) {\n let name = rusToEng(KN.keyName(event), event)\n if (name === 'Add') name = '+' // numpad '+' and '-'\n if (name === 'Subtract') name = '-'\n\n const isChar = name.length === 1 && name !== ' '\n let res = map[modifiers(name, event, !isChar)]\n let baseName\n\n if (event.shiftKey && isChar && (baseName = KN.base[event.keyCode]))\n res = map[modifiers(baseName, event, true)] || res\n\n return res\n}\n\nkeyNorm.lookup = lookup\n\nexport default keyNorm\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport * as clipArea from '../component/cliparea/cliparea'\n\nimport {\n KetSerializer,\n MolSerializer,\n formatProperties,\n ChemicalMimeType\n} from 'ketcher-core'\nimport { debounce, isEqual } from 'lodash/fp'\nimport { load, onAction } from './shared'\n\nimport actions from '../action'\nimport keyNorm from '../data/convert/keynorm'\nimport { openDialog } from './modal'\n\nexport function initKeydownListener(element) {\n return function (dispatch, getState) {\n const hotKeys = initHotKeys()\n element.addEventListener('keydown', event =>\n keyHandle(dispatch, getState(), hotKeys, event)\n )\n }\n}\n\n/* HotKeys */\nfunction keyHandle(dispatch, state, hotKeys, event) {\n if (state.modal) return\n\n const editor = state.editor\n const actionState = state.actionState\n const actionTool = actionState.activeTool\n\n const key = keyNorm(event)\n const atomsSelected = editor.selection() && editor.selection().atoms\n\n let group = null\n\n if (key && key.length === 1 && atomsSelected && key.match(/\\w/)) {\n openDialog(dispatch, 'labelEdit', { letter: key })\n .then(res => {\n dispatch(onAction({ tool: 'atom', opts: res }))\n })\n .catch(() => null)\n event.preventDefault()\n } else if ((group = keyNorm.lookup(hotKeys, event)) !== undefined) {\n let index = checkGroupOnTool(group, actionTool) // index currentTool in group || -1\n index = (index + 1) % group.length\n\n const actName = group[index]\n if (actionState[actName] && actionState[actName].disabled === true) {\n event.preventDefault()\n return\n }\n if (clipArea.actions.indexOf(actName) === -1) {\n const newAction = actions[actName].action\n dispatch(onAction(newAction))\n event.preventDefault()\n } else if (window.clipboardData) {\n // IE support\n clipArea.exec(event)\n }\n }\n}\n\nfunction setHotKey(key, actName, hotKeys) {\n if (Array.isArray(hotKeys[key])) hotKeys[key].push(actName)\n else hotKeys[key] = [actName]\n}\n\nfunction initHotKeys() {\n const hotKeys = {}\n let act\n\n Object.keys(actions).forEach(actName => {\n act = actions[actName]\n if (!act.shortcut) return\n\n if (Array.isArray(act.shortcut)) {\n act.shortcut.forEach(key => {\n setHotKey(key, actName, hotKeys)\n })\n } else {\n setHotKey(act.shortcut, actName, hotKeys)\n }\n })\n\n return keyNorm(hotKeys)\n}\n\nfunction checkGroupOnTool(group, actionTool) {\n let index = group.indexOf(actionTool.tool)\n\n group.forEach((actName, i) => {\n if (isEqual(actions[actName].action, actionTool)) index = i\n })\n\n return index\n}\n\nconst rxnTextPlain = /\\$RXN\\n+\\s+0\\s+0\\s+0\\n*/\n\n/* ClipArea */\nexport function initClipboard(dispatch, getState) {\n const formats = Object.keys(formatProperties).map(\n format => formatProperties[format].mime\n )\n\n const debAction = debounce(0, action => dispatch(onAction(action)))\n const loadStruct = debounce(0, (structStr, opts) =>\n dispatch(load(structStr, opts))\n )\n\n return {\n formats,\n focused() {\n const state = global.currentState\n return !state.modal\n },\n onCut() {\n const state = global.currentState\n const editor = state.editor\n const data = clipData(editor)\n if (data) debAction({ tool: 'eraser', opts: 1 })\n else editor.selection(null)\n return data\n },\n onCopy() {\n const state = global.currentState\n const editor = state.editor\n const data = clipData(editor)\n editor.selection(null)\n return data\n },\n onPaste(data) {\n const structStr =\n data[ChemicalMimeType.KET] ||\n data[ChemicalMimeType.Mol] ||\n data[ChemicalMimeType.Rxn] ||\n data['text/plain']\n\n if (structStr || !rxnTextPlain.test(data['text/plain']))\n loadStruct(structStr, { fragment: true })\n }\n }\n}\n\nfunction clipData(editor) {\n const res = {}\n const struct = editor.structSelected()\n const errorHandler = editor.errorHandler\n\n if (struct.isBlank()) return null\n const simpleObjectOrText = Boolean(\n struct.simpleObjects.size || struct.texts.size\n )\n if (simpleObjectOrText && window.clipboardData) {\n errorHandler(\n 'The structure you are trying to copy contains Simple object or/and Text object.' +\n 'To copy Simple object or Text object in Internet Explorer try \"Copy as KET\" button'\n )\n return null\n }\n const molSerializer = new MolSerializer()\n try {\n const serializer = new KetSerializer()\n const ket = serializer.serialize(struct)\n res[ChemicalMimeType.KET] = ket\n\n const type = struct.isReaction ? ChemicalMimeType.Mol : ChemicalMimeType.Rxn\n const data = molSerializer.serialize(struct)\n res['text/plain'] = data\n res[type] = data\n\n // res['chemical/x-daylight-smiles'] = smiles.stringify(struct);\n return res\n } catch (ex) {\n errorHandler(ex.message)\n }\n\n return null\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport ClipArea from '../component/cliparea/cliparea'\nimport { connect } from 'react-redux'\nimport { initClipboard } from '../state/hotkeys'\n\nconst AppClipArea = connect(null, dispatch => dispatch(initClipboard as any))(\n ClipArea\n)\n\nexport default AppClipArea\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { AppHidden, AppHiddenCallProps } from './AppHidden'\n\nimport { Dispatch } from 'redux'\nimport { connect } from 'react-redux'\nimport { initTmplLib } from '../../state/templates'\n\nconst mapDispatchToProps = (dispatch: Dispatch): AppHiddenCallProps => ({\n onInitTmpls: (cacheEl, url) => {\n initTmplLib(dispatch, url, cacheEl)\n }\n})\n\nconst AppHiddenContainer = connect(null, mapDispatchToProps)(AppHidden)\n\nexport { AppHiddenContainer }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { useEffect, useRef } from 'react'\nimport { useSettingsContext } from '../../../../hooks'\n\ninterface AppHiddenCallProps {\n onInitTmpls: (cacheEl, url) => void\n}\n\ntype Props = AppHiddenCallProps\n// todo: come up with better name\nconst AppHidden = (props: Props) => {\n const { onInitTmpls } = props\n\n const ref = useRef(null)\n const { staticResourcesUrl } = useSettingsContext()\n\n useEffect(() => {\n onInitTmpls(ref.current, staticResourcesUrl)\n }, [])\n\n return
\n}\n\nexport type { AppHiddenCallProps }\nexport { AppHidden }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nconst mediaSizes = {\n smallWidth: 600,\n smallHeight: 600\n}\n\nexport default mediaSizes\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport * as KN from 'w3c-keyname'\n\nimport { FC, useLayoutEffect, useRef, ReactElement } from 'react'\n\nimport clsx from 'clsx'\nimport styles from './Dialog.module.less'\n\ninterface DialogProps {\n title: string\n params: DialogParams\n buttons?: Array\n className: string\n}\nexport interface DialogParams extends DialogParamsCallProps {\n className?: string\n}\n\ninterface DialogParamsCallProps {\n onCancel: () => void\n onOk: (result: any) => void\n}\n\ninterface DialogCallProps {\n result: () => any\n valid?: () => boolean\n}\n\ntype Props = DialogProps & DialogCallProps\n\nconst Dialog: FC = props => {\n const {\n children,\n title,\n params,\n result = () => null,\n valid = () => !!result(),\n buttons = ['Cancel', 'OK'],\n className,\n ...rest\n } = props\n const dialogRef = useRef(null)\n\n useLayoutEffect(() => {\n ;(dialogRef.current as any).focus()\n return () => {\n ;(\n dialogRef.current\n ?.closest('.Ketcher-root')\n ?.getElementsByClassName('cliparea')[0] as any\n ).focus()\n }\n }, [])\n\n const exit = mode => {\n const key = mode === 'OK' ? 'onOk' : 'onCancel'\n if (params && key in params && (key !== 'onOk' || valid()))\n params[key](result())\n }\n\n const keyDown = event => {\n const key = KN.keyName(event)\n const active = document.activeElement\n const activeTextarea = active && active.tagName === 'TEXTAREA'\n if (key === 'Escape' || (key === 'Enter' && !activeTextarea)) {\n exit(key === 'Enter' ? 'OK' : 'Cancel')\n event.preventDefault()\n event.stopPropagation()\n }\n }\n\n return (\n event.preventDefault()}\n onKeyDown={keyDown}\n tabIndex={-1}\n className={clsx(styles.form, className, params.className)}\n {...rest}\n >\n
{title}
\n
{children}
\n\n
\n {buttons.map(button =>\n typeof button !== 'string' ? (\n button\n ) : (\n exit(button)}\n />\n )\n )}\n
\n
\n )\n}\n\nexport default Dialog\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { ReactElement } from 'react'\n\nimport classes from './Spinner.module.less'\n\nfunction Spinner(): ReactElement {\n return
\n}\n\nexport default Spinner\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Fragment, FunctionalGroup, Vec2 } from 'ketcher-core'\n\nconst SELECTION_DISTANCE_COEFFICIENT = 0.4\nconst SELECTION_WITHIN_TEXT = 0\n\nconst findMaps = {\n atoms: findClosestAtom,\n bonds: findClosestBond,\n enhancedFlags: findClosestEnhancedFlag,\n sgroupData: findClosestDataSGroupData,\n sgroups: findClosestSGroup,\n functionalGroups: findClosestFG,\n rxnArrows: findClosestRxnArrow,\n rxnPluses: findClosestRxnPlus,\n frags: findClosestFrag,\n rgroups: findClosestRGroup,\n simpleObjects: findClosestSimpleObject,\n texts: findClosestText\n}\n\nfunction findClosestText(restruct, cursorPosition) {\n let minDist = null\n let ret = null\n\n restruct.texts.forEach((text, id) => {\n const referencePoints = text.getReferencePoints(restruct)\n const topX = referencePoints[0].x\n const topY = referencePoints[0].y\n const bottomX = referencePoints[2].x\n const bottomY = referencePoints[2].y\n\n const distances = []\n\n if (cursorPosition.x >= topX && cursorPosition.x <= bottomX) {\n if (cursorPosition.y < topY) {\n distances.push(topY - cursorPosition.y)\n } else if (cursorPosition.y > bottomY) {\n distances.push(cursorPosition.y - bottomY)\n } else {\n distances.push(cursorPosition.y - topY, bottomY - cursorPosition.y)\n }\n }\n\n if (cursorPosition.x < topX && cursorPosition.y < topY) {\n distances.push(Vec2.dist(new Vec2(topX, topY), cursorPosition))\n }\n\n if (cursorPosition.x > bottomX && cursorPosition.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(bottomX, bottomY), cursorPosition))\n }\n\n if (cursorPosition.x < topX && cursorPosition.y > bottomY) {\n distances.push(Vec2.dist(new Vec2(topX, bottomY), cursorPosition))\n }\n\n if (cursorPosition.x > bottomX && cursorPosition.y < topY) {\n distances.push(Vec2.dist(new Vec2(bottomX, topY), cursorPosition))\n }\n\n if (cursorPosition.y >= topY && cursorPosition.y <= bottomY) {\n if (cursorPosition.x < topX) {\n distances.push(topX - cursorPosition.x)\n } else if (cursorPosition.x > bottomX) {\n distances.push(cursorPosition.x - bottomX)\n } else {\n distances.push(SELECTION_WITHIN_TEXT)\n }\n }\n\n let dist = Math.min(...distances)\n\n if (dist < SELECTION_DISTANCE_COEFFICIENT && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n return ret\n}\n\nfunction findClosestSimpleObject(restruct, pos) {\n let minDist = null\n let refPoint = null\n let ret = null\n\n restruct.simpleObjects.forEach((simpleObject, id) => {\n const dist = simpleObject.calcDistance(pos, restruct.render.options.scale)\n\n if (dist.minDist < 0.3 && (!ret || dist.minDist < minDist)) {\n minDist = dist.minDist\n refPoint = dist.refPoint\n\n ret = { id, dist: minDist, ref: refPoint }\n }\n })\n return ret\n}\n\nfunction findClosestAtom(restruct, pos, skip, minDist) {\n let closestAtom = null\n const maxMinDist = SELECTION_DISTANCE_COEFFICIENT\n const skipId = skip && skip.map === 'atoms' ? skip.id : null\n const sGroups = restruct.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n\n minDist = minDist || maxMinDist\n minDist = Math.min(minDist, maxMinDist)\n\n restruct.atoms.forEach((atom, aid) => {\n if (\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom.a,\n sGroups,\n functionalGroups,\n true\n )\n )\n return null\n if (aid === skipId) return\n\n const dist = Vec2.dist(pos, atom.a.pp)\n\n if (dist < minDist) {\n closestAtom = aid\n minDist = dist\n }\n })\n\n if (closestAtom !== null) {\n return {\n id: closestAtom,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestBond(restruct, pos, skip, minDist, scale) {\n // eslint-disable-line max-params\n let closestBond = null\n let closestBondCenter = null\n const maxMinDist = 0.8 * SELECTION_DISTANCE_COEFFICIENT\n const skipId = skip && skip.map === 'bonds' ? skip.id : null\n const sGroups = restruct.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n\n minDist = minDist || maxMinDist\n minDist = Math.min(minDist, maxMinDist)\n\n let minCDist = minDist\n\n restruct.bonds.forEach((bond, bid) => {\n if (bid === skipId) return\n\n const a1 = restruct.atoms.get(bond.b.begin).a\n const a2 = restruct.atoms.get(bond.b.end).a\n if (\n FunctionalGroup.isBondInContractedFunctionalGroup(\n bond.b,\n sGroups,\n functionalGroups,\n true\n )\n )\n return null\n\n const mid = Vec2.lc2(a1.pp, 0.5, a2.pp, 0.5)\n const cdist = Vec2.dist(pos, mid)\n\n if (cdist < minCDist) {\n minCDist = cdist\n closestBondCenter = bid\n }\n })\n\n restruct.bonds.forEach((bond, bid) => {\n if (bid === skipId) return\n if (\n FunctionalGroup.isBondInContractedFunctionalGroup(\n bond.b,\n sGroups,\n functionalGroups,\n true\n )\n )\n return null\n\n const hb = restruct.molecule.halfBonds.get(bond.b.hb1)\n const dir = hb.dir\n const norm = hb.norm\n\n const p1 = restruct.atoms.get(bond.b.begin).a.pp\n const p2 = restruct.atoms.get(bond.b.end).a.pp\n\n const inStripe = Vec2.dot(pos.sub(p1), dir) * Vec2.dot(pos.sub(p2), dir) < 0\n\n if (inStripe) {\n const dist = Math.abs(Vec2.dot(pos.sub(p1), norm))\n\n if (dist < minDist) {\n closestBond = bid\n minDist = dist\n }\n }\n })\n\n if (closestBondCenter !== null) {\n return {\n id: closestBondCenter,\n dist: minCDist\n }\n }\n\n if (\n closestBond !== null &&\n minDist > SELECTION_DISTANCE_COEFFICIENT * scale\n ) {\n return {\n id: closestBond,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestEnhancedFlag(restruct, pos) {\n let minDist\n let ret = null\n restruct.enhancedFlags.forEach((item, id) => {\n const fragment = restruct.molecule.frags.get(id)\n if (!fragment) return\n\n const p = fragment.stereoFlagPosition\n ? new Vec2(fragment.stereoFlagPosition.x, fragment.stereoFlagPosition.y)\n : Fragment.getDefaultStereoFlagPosition(restruct.molecule, id)\n if (!p || Math.abs(pos.x - p.x) >= 1.0) return\n\n const dist = Math.abs(pos.y - p.y)\n\n if (dist < 0.3 && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n return ret\n}\n\nfunction findClosestDataSGroupData(restruct, pos) {\n let minDist = null\n let ret = null\n\n restruct.sgroupData.forEach((item, id) => {\n if (item.sgroup.type !== 'DAT') throw new Error('Data group expected')\n\n if (item.sgroup.data.fieldName !== 'MRV_IMPLICIT_H') {\n const box = item.sgroup.dataArea\n const inBox =\n box.p0.y < pos.y &&\n box.p1.y > pos.y &&\n box.p0.x < pos.x &&\n box.p1.x > pos.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pos.x),\n Math.abs(box.p1.x - pos.x)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = { id, dist: xDist }\n minDist = xDist\n }\n }\n })\n\n return ret\n}\n\nfunction findClosestFrag(restruct, pos, skip, minDist, scale) {\n minDist = Math.min(\n minDist || SELECTION_DISTANCE_COEFFICIENT,\n SELECTION_DISTANCE_COEFFICIENT\n )\n\n const struct = restruct.molecule\n\n const closestAtom = findClosestAtom(restruct, pos, skip, minDist)\n\n if (closestAtom) {\n return {\n id: struct.atoms.get(closestAtom.id).fragment,\n dist: closestAtom.dist\n }\n }\n\n const closestBond = findClosestBond(restruct, pos, skip, minDist, scale)\n\n if (closestBond) {\n const atomId = struct.bonds.get(closestBond.id).begin\n return {\n id: struct.atoms.get(atomId).fragment,\n dist: closestBond.dist\n }\n }\n\n return null\n}\n\nfunction findClosestRGroup(restruct, pos, skip, minDist) {\n minDist = Math.min(\n minDist || SELECTION_DISTANCE_COEFFICIENT,\n SELECTION_DISTANCE_COEFFICIENT\n )\n\n let ret = null\n\n restruct.rgroups.forEach((rgroup, rgid) => {\n if (\n rgid !== skip &&\n rgroup.labelBox &&\n rgroup.labelBox.contains(pos, 0.5)\n ) {\n const dist = Vec2.dist(rgroup.labelBox.centre(), pos)\n\n if (!ret || dist < minDist) {\n minDist = dist\n ret = { id: rgid, dist: minDist }\n }\n }\n })\n\n return ret\n}\n\nfunction findClosestRxnArrow(restruct, pos) {\n let minDist = null\n let refPoint = null\n let ret = null\n\n restruct.rxnArrows.forEach((rxnArrow, id) => {\n const dist = rxnArrow.calcDistance(pos, restruct.render.options.scale)\n\n if (dist.minDist < 0.3 && (!ret || dist.minDist < minDist)) {\n minDist = dist.minDist\n refPoint = dist.refPoint\n\n ret = { id, dist: minDist, ref: refPoint }\n }\n })\n return ret\n}\n\nfunction findClosestRxnPlus(restruct, pos) {\n let minDist = null\n let ret = null\n\n restruct.rxnPluses.forEach((plus, id) => {\n const p = plus.item.pp\n const dist = Math.max(Math.abs(pos.x - p.x), Math.abs(pos.y - p.y))\n\n if (dist < 0.3 && (!ret || dist < minDist)) {\n minDist = dist\n ret = { id, dist: minDist }\n }\n })\n\n return ret\n}\n\nfunction findClosestSGroup(restruct, pos) {\n let ret = null\n let minDist = SELECTION_DISTANCE_COEFFICIENT\n\n restruct.molecule.sgroups.forEach((sg, sgid) => {\n if (sg.functionalGroup && !sg.expanded && sg.firstSgroupAtom) return null\n\n const d = sg.bracketDir\n const n = d.rotateSC(1, 0)\n const pg = new Vec2(Vec2.dot(pos, d), Vec2.dot(pos, n))\n\n sg.areas.forEach(box => {\n const inBox =\n box.p0.y < pg.y && box.p1.y > pg.y && box.p0.x < pg.x && box.p1.x > pg.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pg.x),\n Math.abs(box.p1.x - pg.x)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = sgid\n minDist = xDist\n }\n })\n })\n\n if (ret !== null) {\n return {\n id: ret,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestFG(restruct, pos) {\n let ret = null\n let minDist = SELECTION_DISTANCE_COEFFICIENT\n restruct.molecule.sgroups.forEach((sg, sgid) => {\n if (sg.functionalGroup && !sg.data.expanded && sg.firstSgroupAtom) {\n const firstAtomPp = sg.firstSgroupAtom.pp\n const shift = new Vec2(0.625, 0.625)\n const box = {\n p0: Vec2.diff(firstAtomPp, shift),\n p1: Vec2.sum(firstAtomPp, shift)\n }\n\n const inBox =\n box.p0.y < pos.y &&\n box.p1.y > pos.y &&\n box.p0.x < pos.x &&\n box.p1.x > pos.x\n const xDist = Math.min(\n Math.abs(box.p0.x - pos.x),\n Math.abs(box.p0.y - pos.y),\n Math.abs(box.p1.x - pos.x),\n Math.abs(box.p0.y - pos.y)\n )\n\n if (inBox && (ret === null || xDist < minDist)) {\n ret = sgid\n minDist = xDist\n }\n }\n })\n if (ret !== null) {\n return {\n id: ret,\n dist: minDist\n }\n }\n\n return null\n}\n\nfunction findClosestItem(restruct, pos, maps, skip, scale) {\n // eslint-disable-line max-params\n maps = maps || Object.keys(findMaps)\n\n return maps.reduce((res, mp) => {\n const minDist = res ? res.dist : null\n const item = findMaps[mp](restruct, pos, skip, minDist, scale)\n\n if (item !== null && (res === null || item.dist < res.dist)) {\n const { id, dist, ...other } = item\n return {\n map: mp,\n id: id,\n dist: dist,\n ...other\n }\n }\n\n return res\n }, null)\n}\n\n/**\n * @param restruct { ReStruct }\n * @param selected { object }\n * @param maps { Array }\n * @param scale { number }\n * @return {{\n * \t\tatoms: Map?\n * \t\tbonds: Map?\n * }}\n */\nfunction findCloseMerge(restruct, selected, maps = ['atoms', 'bonds'], scale) {\n const pos = {\n atoms: new Map(), // aid -> position\n bonds: new Map() // bid -> position\n }\n\n const struct = restruct.molecule\n\n selected.atoms.forEach(aid => {\n pos.atoms.set(aid, struct.atoms.get(aid).pp)\n })\n\n selected.bonds.forEach(bid => {\n const bond = struct.bonds.get(bid)\n pos.bonds.set(\n bid,\n Vec2.lc2(\n struct.atoms.get(bond.begin).pp,\n 0.5,\n struct.atoms.get(bond.end).pp,\n 0.5\n )\n )\n })\n\n const result = {}\n maps.forEach(mp => {\n result[mp] = Array.from(pos[mp].keys()).reduce((res, srcId) => {\n const skip = { map: mp, id: srcId }\n const item = findMaps[mp](restruct, pos[mp].get(srcId), skip, null, scale)\n\n if (item && !selected[mp].includes(item.id)) res.set(srcId, item.id)\n\n return res\n }, new Map())\n })\n\n return result\n}\n\nexport default {\n atom: findClosestAtom, // used in Actions\n item: findClosestItem,\n merge: findCloseMerge\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { fromAtomsAttrs, FunctionalGroup } from 'ketcher-core'\n\nfunction APointTool(editor) {\n if (!(this instanceof APointTool)) return new APointTool(editor)\n\n this.editor = editor\n this.sgroups = editor.render.ctab.sgroups\n this.struct = editor.render.ctab\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n this.editor.selection(null)\n}\n\nAPointTool.prototype.mousemove = function (event) {\n const struct = this.editor.render.ctab.molecule\n const ci = this.editor.findItem(event, ['atoms'])\n if (ci) {\n const atom = struct.atoms.get(ci.id)\n if (atom.label !== 'R#' && atom.rglabel === null) this.editor.hover(ci)\n } else {\n this.editor.hover(null)\n }\n}\n\nAPointTool.prototype.click = function (event) {\n var editor = this.editor\n var struct = editor.render.ctab.molecule\n var ci = editor.findItem(event, ['atoms'])\n const atomResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (ci && ci.map === 'atoms') {\n this.editor.hover(null)\n var atom = struct.atoms.get(ci.id)\n if (atom.label === 'R#' && atom.rglabel !== null) return\n var res = editor.event.elementEdit.dispatch({\n attpnt: atom.attpnt\n })\n Promise.resolve(res)\n .then(newatom => {\n if (atom.attpnt !== newatom.attpnt) {\n var action = fromAtomsAttrs(editor.render.ctab, ci.id, newatom)\n editor.update(action)\n }\n })\n .catch(() => null) // w/o changes\n return true\n }\n return true\n}\n\nexport default APointTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Vec2, fracAngle } from 'ketcher-core'\n\nimport { inRange } from 'lodash'\n\nfunction calcAngle(pos0, pos1) {\n const v = Vec2.diff(pos1, pos0)\n return Math.atan2(v.y, v.x)\n}\n\nfunction calcNewAtomPos(pos0, pos1, ctrlKey) {\n const v = new Vec2(1, 0).rotate(\n ctrlKey ? calcAngle(pos0, pos1) : fracAngle(pos0, pos1)\n )\n v.add_(pos0) // eslint-disable-line no-underscore-dangle\n return v\n}\n\nfunction degrees(angle) {\n let degree = Math.round((angle / Math.PI) * 180)\n if (degree > 180) degree -= 360\n else if (degree <= -180) degree += 360\n return degree\n}\n\nconst BONDS_MERGE_ANGLE = 10 // 'º'\nconst BONDS_MERGE_SCALE = 0.2\n\nfunction mergeBondsParams(struct1, bond1, struct2, bond2) {\n const begin1 = struct1.atoms.get(bond1.begin)\n const begin2 = struct2.atoms.get(bond2.begin)\n const end1 = struct1.atoms.get(bond1.end)\n const end2 = struct2.atoms.get(bond2.end)\n\n const angle = calcAngle(begin1.pp, end1.pp) - calcAngle(begin2.pp, end2.pp)\n const mergeAngle = Math.abs(degrees(angle) % 180)\n\n const scale = Vec2.dist(begin1.pp, end1.pp) / Vec2.dist(begin2.pp, end2.pp)\n\n const merged =\n !inRange(mergeAngle, BONDS_MERGE_ANGLE, 180 - BONDS_MERGE_ANGLE) &&\n inRange(scale, 1 - BONDS_MERGE_SCALE, 1 + BONDS_MERGE_SCALE)\n\n return { merged, angle, scale, cross: Math.abs(degrees(angle)) > 90 }\n}\n\nexport default {\n calcAngle,\n fracAngle,\n calcNewAtomPos,\n degrees,\n mergeBondsParams\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Action,\n Atom,\n Bond,\n fromAtomAddition,\n fromAtomsAttrs,\n fromBondAddition,\n fromFragmentDeletion,\n fromSgroupDeletion,\n FunctionalGroup,\n SGroup\n} from 'ketcher-core'\n\nimport utils from '../shared/utils'\n\nfunction AtomTool(editor, atomProps) {\n if (!(this instanceof AtomTool)) {\n if (!editor.selection() || !editor.selection().atoms)\n return new AtomTool(editor, atomProps)\n\n const action = fromAtomsAttrs(\n editor.render.ctab,\n editor.selection().atoms,\n atomProps,\n true\n )\n editor.update(action)\n editor.selection(null)\n return null\n }\n\n this.editor = editor\n this.atomProps = atomProps\n this.struct = editor.render.ctab\n this.bondProps = { type: 1, stereo: Bond.PATTERN.STEREO.NONE }\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n}\n\nAtomTool.prototype.mousedown = function (event) {\n this.editor.hover(null)\n this.editor.selection(null)\n const ci = this.editor.findItem(event, ['atoms', 'functionalGroups'])\n if (\n ci &&\n ci.map === 'functionalGroups' &&\n this.functionalGroups &&\n FunctionalGroup.isContractedFunctionalGroup(ci.id, this.functionalGroups)\n ) {\n const action = new Action()\n const selectedSgroup = this.sgroups.get(ci.id)\n const sGroupAtoms = SGroup.getAtoms(this.molecule, selectedSgroup.item)\n const [firstAtom, ...atoms] = sGroupAtoms\n const atomNeighbours = this.struct.molecule.atomGetNeighbors(firstAtom)\n const extraNeighbour = atomNeighbours.some(\n atom => !sGroupAtoms.includes(atom.aid)\n )\n if (extraNeighbour) {\n action.mergeWith(fromSgroupDeletion(this.struct, ci.id))\n action.mergeWith(fromFragmentDeletion(this.struct, { atoms: atoms }))\n action.mergeWith(\n fromAtomsAttrs(this.struct, firstAtom, this.atomProps, true)\n )\n } else {\n const firstAtomPp = this.struct.atoms.get(firstAtom).a.pp\n action.mergeWith(\n fromFragmentDeletion(this.struct, {\n atoms: SGroup.getAtoms(this.molecule, selectedSgroup.item),\n bonds: SGroup.getBonds(this.molecule, selectedSgroup.item)\n })\n )\n action.mergeWith(\n fromAtomAddition(this.struct, firstAtomPp, this.atomProps)\n )\n }\n this.editor.update(action)\n }\n const atomResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n if (!ci) {\n // ci.type == 'Canvas'\n this.dragCtx = {}\n } else if (ci.map === 'atoms') {\n this.dragCtx = { item: ci }\n }\n}\n\nAtomTool.prototype.mousemove = function (event) {\n const rnd = this.editor.render\n if (!this.dragCtx || !this.dragCtx.item) {\n this.editor.hover(\n this.editor.findItem(event, ['atoms', 'functionalGroups'])\n )\n return\n }\n\n const dragCtx = this.dragCtx\n const ci = this.editor.findItem(event, ['atoms'])\n\n if (ci && ci.map === 'atoms' && ci.id === dragCtx.item.id) {\n // fromAtomsAttrs\n this.editor.hover(this.editor.findItem(event, ['atoms']))\n return\n }\n\n // fromAtomAddition\n const atom = rnd.ctab.molecule.atoms.get(dragCtx.item.id)\n let angle = utils.calcAngle(atom.pp, rnd.page2obj(event))\n if (!event.ctrlKey) angle = utils.fracAngle(angle)\n const degrees = utils.degrees(angle)\n this.editor.event.message.dispatch({ info: degrees + 'º' })\n const newAtomPos = utils.calcNewAtomPos(\n atom.pp,\n rnd.page2obj(event),\n event.ctrlKey\n )\n if (dragCtx.action) dragCtx.action.perform(rnd.ctab)\n\n dragCtx.action = fromBondAddition(\n rnd.ctab,\n this.bondProps,\n dragCtx.item.id,\n Object.assign({}, this.atomProps),\n newAtomPos,\n newAtomPos\n )[0]\n this.editor.update(dragCtx.action, true)\n}\n\nAtomTool.prototype.mouseup = function (event) {\n const ci = this.editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const result = []\n if (ci && this.functionalGroups && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (this.dragCtx) {\n const dragCtx = this.dragCtx\n const rnd = this.editor.render\n\n this.editor.update(\n dragCtx.action ||\n (dragCtx.item\n ? fromAtomsAttrs(rnd.ctab, dragCtx.item.id, this.atomProps, true)\n : fromAtomAddition(rnd.ctab, rnd.page2obj(event), this.atomProps))\n )\n\n delete this.dragCtx\n }\n this.editor.event.message.dispatch({\n info: false\n })\n}\n\nexport function atomLongtapEvent(tool, render) {\n const { dragCtx, editor } = tool\n const atomid = dragCtx.item?.id\n const fgs = render.ctab.molecule.functionalGroups\n // edit atom or add atom\n const atom =\n atomid !== undefined && atomid !== null\n ? render.ctab.molecule.atoms.get(atomid)\n : new Atom({ label: '' })\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(fgs, atomid)\n // TODO: longtab event\n dragCtx.timeout = setTimeout(() => {\n delete tool.dragCtx\n if (fgId != null) {\n editor.event.removeFG.dispatch({ fgIds: [fgId] })\n return\n }\n editor.selection(null)\n const res = editor.event.quickEdit.dispatch(atom)\n Promise.resolve(res)\n .then(newatom => {\n const action = atomid\n ? fromAtomsAttrs(render.ctab, atomid, newatom)\n : fromAtomAddition(render.ctab, dragCtx.xy0, newatom)\n editor.update(action)\n })\n .catch(() => null) // w/o changes\n }, 750)\n\n dragCtx.stopTapping = function () {\n if (dragCtx.timeout) {\n clearTimeout(dragCtx.timeout)\n delete dragCtx.timeout\n }\n }\n}\n\nexport default AtomTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Elements, FunctionalGroup } from 'ketcher-core'\n\nfunction AttachTool(editor, attachPoints) {\n if (!(this instanceof AttachTool)) return new AttachTool(editor, attachPoints)\n\n this.attach = {\n atomid: attachPoints.atomid || 0,\n bondid: attachPoints.bondid || 0\n }\n this.editor = editor\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n\n this.editor.selection({\n atoms: [this.attach.atomid],\n bonds: [this.attach.bondid]\n })\n}\n\nAttachTool.prototype.mousemove = function (event) {\n const rnd = this.editor.render\n\n const ci = this.editor.findItem(event, ['atoms', 'bonds'])\n const struct = rnd.ctab.molecule\n if (\n ci &&\n ((ci.map === 'atoms' && Elements.get(struct.atoms.get(ci.id)?.label)) ||\n ci.map === 'bonds')\n )\n this.editor.hover(ci)\n else this.editor.hover(null)\n return true\n}\n\nAttachTool.prototype.click = function (event) {\n const editor = this.editor\n const rnd = editor.render\n const struct = rnd.ctab.molecule\n const ci = editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const bondResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (ci && this.functionalGroups.size && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ci.id\n )\n if (bondId !== null) bondResult.push(bondId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (\n ci &&\n ((ci.map === 'atoms' && Elements.get(struct.atoms.get(ci.id)?.label)) ||\n ci.map === 'bonds')\n ) {\n if (ci.map === 'atoms') this.attach.atomid = ci.id\n else this.attach.bondid = ci.id\n\n this.editor.selection({\n atoms: [this.attach.atomid],\n bonds: [this.attach.bondid]\n })\n this.editor.event.attachEdit.dispatch(this.attach)\n }\n return true\n}\n\nexport default AttachTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Bond,\n Vec2,\n bondChangingAction,\n fromBondAddition,\n fromBondsAttrs,\n FunctionalGroup,\n SGroup\n} from 'ketcher-core'\n\nimport utils from '../shared/utils'\n\nfunction BondTool(editor, bondProps) {\n if (!(this instanceof BondTool)) {\n if (!editor.selection() || !editor.selection().bonds)\n return new BondTool(editor, bondProps)\n\n const action = fromBondsAttrs(\n editor.render.ctab,\n editor.selection().bonds,\n bondProps\n )\n editor.update(action)\n editor.selection(null)\n return null\n }\n\n this.editor = editor\n this.atomProps = { label: 'C' }\n this.bondProps = bondProps\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n}\n\nBondTool.prototype.mousedown = function (event) {\n if (this.dragCtx) return\n const ci = this.editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const bondResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (ci && this.functionalGroups.size && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ci.id\n )\n if (bondId !== null) bondResult.push(bondId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n const rnd = this.editor.render\n this.editor.hover(null)\n this.editor.selection(null)\n this.dragCtx = {\n xy0: rnd.page2obj(event),\n item: this.editor.findItem(event, ['atoms', 'bonds'])\n }\n if (!this.dragCtx.item)\n // ci.type == 'Canvas'\n delete this.dragCtx.item\n return true\n}\n\nBondTool.prototype.mousemove = function (event) {\n // eslint-disable-line max-statements\n const editor = this.editor\n const rnd = editor.render\n if ('dragCtx' in this) {\n const dragCtx = this.dragCtx\n\n const pos = rnd.page2obj(event)\n let angle = utils.calcAngle(dragCtx.xy0, pos)\n if (!event.ctrlKey) angle = utils.fracAngle(angle)\n\n const degrees = utils.degrees(angle)\n this.editor.event.message.dispatch({ info: degrees + 'º' })\n\n if (!('item' in dragCtx) || dragCtx.item.map === 'atoms') {\n if ('action' in dragCtx) dragCtx.action.perform(rnd.ctab)\n let beginAtom\n let endAtom\n let beginPos\n let endPos\n const extraNeighbour = []\n if ('item' in dragCtx && dragCtx.item.map === 'atoms') {\n // first mousedown event intersect with any atom\n beginAtom = dragCtx.item.id\n endAtom = editor.findItem(event, ['atoms'], dragCtx.item)\n const closestSGroup = editor.findItem(event, ['functionalGroups'])\n if (\n closestSGroup &&\n FunctionalGroup.isContractedFunctionalGroup(\n closestSGroup.id,\n this.functionalGroups\n )\n ) {\n const sGroup = this.sgroups.get(closestSGroup.id)\n const sGroupAtoms = SGroup.getAtoms(this.molecule, sGroup.item)\n endAtom = {\n id: sGroupAtoms[0],\n map: 'atoms'\n }\n }\n const fGroupId =\n endAtom &&\n FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n endAtom.id\n )\n const fGroup =\n typeof fGroupId === 'number' && this.sgroups.get(fGroupId)\n const fGroupAtoms =\n fGroup && SGroup.getAtoms(this.molecule, fGroup.item)\n if (endAtom && fGroup && endAtom.id !== fGroupAtoms[0]) {\n this.editor.event.removeFG.dispatch({ fgIds: [fGroupId] })\n endAtom = null\n }\n if (endAtom && fGroup && endAtom.id === fGroupAtoms[0]) {\n const atomNeighbours = this.molecule.atomGetNeighbors(endAtom.id)\n atomNeighbours.forEach(nei => {\n !fGroupAtoms.includes(nei.aid) &&\n !extraNeighbour.includes(nei.aid) &&\n extraNeighbour.push(nei.aid)\n })\n }\n if (extraNeighbour.length >= 1) {\n endAtom = null\n }\n } else {\n // first mousedown event intersect with any canvas\n beginAtom = this.atomProps\n beginPos = dragCtx.xy0\n endAtom = editor.findItem(event, ['atoms'])\n const atomResult = []\n const result = []\n if (\n endAtom &&\n endAtom.map === 'atoms' &&\n this.functionalGroups.size &&\n this.dragCtx\n ) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n endAtom.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n fgId !== null && !result.includes(fgId) && result.push(fgId)\n }\n }\n if (result.length > 0) {\n this.editor.event.removeFG.dispatch({ fgIds: result })\n delete this.dragCtx\n return\n }\n }\n let dist = Number.MAX_VALUE\n if (endAtom && endAtom.map === 'atoms') {\n // after mousedown events is appered, cursor is moved and then cursor intersects any atoms\n endAtom = endAtom.id\n } else {\n endAtom = this.atomProps\n const xy1 = rnd.page2obj(event)\n dist = Vec2.dist(dragCtx.xy0, xy1)\n if (beginPos) {\n // rotation only, leght of bond = 1;\n endPos = utils.calcNewAtomPos(beginPos, xy1, event.ctrlKey)\n } else {\n // first mousedown event intersect with any atom and\n // rotation only, leght of bond = 1;\n const atom = rnd.ctab.molecule.atoms.get(beginAtom)\n beginPos = utils.calcNewAtomPos(atom.pp.get_xy0(), xy1, event.ctrlKey)\n }\n }\n // don't rotate the bond if the distance between the start and end point is too small\n if (dist > 0.3)\n dragCtx.action = fromBondAddition(\n rnd.ctab,\n this.bondProps,\n beginAtom,\n endAtom,\n beginPos,\n endPos\n )[0]\n else delete dragCtx.action\n this.editor.update(dragCtx.action, true)\n return true\n }\n }\n this.editor.hover(this.editor.findItem(event, ['atoms', 'bonds']))\n return true\n}\n\nBondTool.prototype.mouseup = function (event) {\n // eslint-disable-line max-statements\n if ('dragCtx' in this) {\n var dragCtx = this.dragCtx\n var rnd = this.editor.render\n var struct = rnd.ctab.molecule\n if ('action' in dragCtx) {\n this.editor.update(dragCtx.action)\n } else if (!('item' in dragCtx)) {\n var xy = rnd.page2obj(event)\n var v = new Vec2(1.0 / 2, 0).rotate(\n this.bondProps.type === Bond.PATTERN.TYPE.SINGLE ? -Math.PI / 6 : 0\n )\n var bondAddition = fromBondAddition(\n rnd.ctab,\n this.bondProps,\n { label: 'C' },\n { label: 'C' },\n Vec2.diff(xy, v),\n Vec2.sum(xy, v)\n )\n\n this.editor.update(bondAddition[0])\n } else if (dragCtx.item.map === 'atoms') {\n // when does it hapend?\n this.editor.update(\n fromBondAddition(rnd.ctab, this.bondProps, dragCtx.item.id)[0]\n )\n } else if (dragCtx.item.map === 'bonds') {\n var bondProps = Object.assign({}, this.bondProps)\n var bond = struct.bonds.get(dragCtx.item.id)\n\n this.editor.update(\n bondChangingAction(rnd.ctab, dragCtx.item.id, bond, bondProps)\n )\n }\n delete this.dragCtx\n }\n this.editor.event.message.dispatch({\n info: false\n })\n return true\n}\n\nexport default BondTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Bond,\n Vec2,\n bondChangingAction,\n fromChain,\n fromItemsFuse,\n getHoverToFuse,\n getItemsToFuse,\n FunctionalGroup\n} from 'ketcher-core'\n\nimport { atomLongtapEvent } from './atom'\nimport utils from '../shared/utils'\n\nfunction ChainTool(editor) {\n if (!(this instanceof ChainTool)) return new ChainTool(editor)\n\n this.editor = editor\n this.editor.selection(null)\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n}\n\nChainTool.prototype.mousedown = function (event) {\n if (this.dragCtx) return\n const rnd = this.editor.render\n const ci = this.editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const bondResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (ci && this.functionalGroups.size && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ci.id\n )\n if (bondId !== null) bondResult.push(bondId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n this.editor.hover(null)\n this.dragCtx = {\n xy0: rnd.page2obj(event),\n item: ci\n }\n if (ci && ci.map === 'atoms') {\n this.editor.selection({ atoms: [ci.id] }) // for change atom\n // this event has to be stopped in others events by `tool.dragCtx.stopTapping()`\n atomLongtapEvent(this, rnd)\n }\n if (!this.dragCtx.item)\n // ci.type == 'Canvas'\n delete this.dragCtx.item\n return true\n}\n\nChainTool.prototype.mousemove = function (event) {\n // eslint-disable-line max-statements\n const editor = this.editor\n const restruct = editor.render.ctab\n const dragCtx = this.dragCtx\n\n editor.hover(this.editor.findItem(event, ['atoms', 'bonds']))\n if (!dragCtx) return true\n\n if (dragCtx && dragCtx.stopTapping) dragCtx.stopTapping()\n\n editor.selection(null)\n\n if (!dragCtx.item || dragCtx.item.map === 'atoms') {\n if (dragCtx.action) dragCtx.action.perform(restruct)\n\n const atoms = restruct.molecule.atoms\n\n const pos0 = dragCtx.item ? atoms.get(dragCtx.item.id).pp : dragCtx.xy0\n\n const pos1 = editor.render.page2obj(event)\n const sectCount = Math.ceil(Vec2.diff(pos1, pos0).length())\n\n const angle = event.ctrlKey\n ? utils.calcAngle(pos0, pos1)\n : utils.fracAngle(pos0, pos1)\n\n const [action, newItems] = fromChain(\n restruct,\n pos0,\n angle,\n sectCount,\n dragCtx.item ? dragCtx.item.id : null\n )\n\n editor.event.message.dispatch({\n info: sectCount + ' sectors'\n })\n\n dragCtx.action = action\n editor.update(dragCtx.action, true)\n\n dragCtx.mergeItems = getItemsToFuse(editor, newItems)\n editor.hover(getHoverToFuse(dragCtx.mergeItems))\n\n return true\n }\n\n return true\n}\n\nChainTool.prototype.mouseup = function () {\n let atom\n const atomResult = []\n const result = []\n if (this.dragCtx && this.dragCtx.mergeItems && this.functionalGroups.size) {\n atom = this.dragCtx.mergeItems.atoms.values().next().value\n }\n if (atom) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n atom\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n const dragCtx = this.dragCtx\n if (!dragCtx) return true\n delete this.dragCtx\n\n const editor = this.editor\n const restruct = editor.render.ctab\n const struct = restruct.molecule\n\n if (dragCtx.stopTapping) dragCtx.stopTapping()\n\n if (!dragCtx.action && dragCtx.item && dragCtx.item.map === 'bonds') {\n const bond = struct.bonds.get(dragCtx.item.id)\n\n dragCtx.action = bondChangingAction(restruct, dragCtx.item.id, bond, {\n type: Bond.PATTERN.TYPE.SINGLE,\n stereo: Bond.PATTERN.STEREO.NONE\n })\n } else {\n dragCtx.action = dragCtx.action\n ? fromItemsFuse(restruct, dragCtx.mergeItems).mergeWith(dragCtx.action)\n : fromItemsFuse(restruct, dragCtx.mergeItems)\n }\n\n editor.selection(null)\n editor.hover(null)\n\n if (dragCtx.action) editor.update(dragCtx.action)\n\n editor.event.message.dispatch({\n info: false\n })\n\n return true\n}\n\nChainTool.prototype.cancel = ChainTool.prototype.mouseup\n\nChainTool.prototype.mouseleave = ChainTool.prototype.mouseup\n\nexport default ChainTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Elements, fromAtomsAttrs, FunctionalGroup } from 'ketcher-core'\n\nfunction ChargeTool(editor, charge) {\n if (!(this instanceof ChargeTool)) return new ChargeTool(editor, charge)\n\n this.editor = editor\n this.editor.selection(null)\n this.charge = charge\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n}\n\nChargeTool.prototype.mousemove = function (event) {\n var rnd = this.editor.render\n var ci = this.editor.findItem(event, ['atoms'])\n var struct = rnd.ctab.molecule\n if (ci && ci.map === 'atoms' && Elements.get(struct.atoms.get(ci.id)?.label))\n this.editor.hover(ci)\n else this.editor.hover(null)\n return true\n}\n\nChargeTool.prototype.click = function (event) {\n var editor = this.editor\n var rnd = editor.render\n var struct = rnd.ctab.molecule\n const ci = editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n if (\n ci &&\n ci.map === 'atoms' &&\n Elements.get(struct.atoms.get(ci.id)?.label)\n ) {\n this.editor.hover(null)\n this.editor.update(\n fromAtomsAttrs(rnd.ctab, ci.id, {\n charge: struct.atoms.get(ci.id).charge + this.charge\n })\n )\n }\n return true\n}\n\nexport default ChargeTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { FunctionalGroup, Vec2 } from 'ketcher-core'\n\nfunction getElementsInRectangle(restruct, p0, p1) {\n const bondList = []\n const atomList = []\n const sGroups = restruct.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n\n const x0 = Math.min(p0.x, p1.x)\n const x1 = Math.max(p0.x, p1.x)\n const y0 = Math.min(p0.y, p1.y)\n const y1 = Math.max(p0.y, p1.y)\n\n restruct.bonds.forEach((bond, bid) => {\n const centre = Vec2.lc2(\n restruct.atoms.get(bond.b.begin).a.pp,\n 0.5,\n restruct.atoms.get(bond.b.end).a.pp,\n 0.5\n )\n if (\n centre.x > x0 &&\n centre.x < x1 &&\n centre.y > y0 &&\n centre.y < y1 &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n bond.b,\n sGroups,\n functionalGroups,\n true\n )\n )\n bondList.push(bid)\n })\n\n restruct.atoms.forEach((atom, aid) => {\n const relatedFGId = FunctionalGroup.findFunctionalGroupByAtom(\n functionalGroups,\n aid\n )\n const sGroup = restruct.sgroups.get(relatedFGId)\n if (\n atom.a.pp.x > x0 &&\n atom.a.pp.x < x1 &&\n atom.a.pp.y > y0 &&\n atom.a.pp.y < y1 &&\n (!FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom.a,\n sGroups,\n functionalGroups,\n true\n ) ||\n aid === sGroup.item.atoms[0])\n )\n atomList.push(aid)\n })\n\n const rxnArrowsList = []\n const rxnPlusesList = []\n const simpleObjectsList = []\n\n restruct.rxnArrows.forEach((item, id) => {\n if (\n item.item.center().x > x0 &&\n item.item.center().x < x1 &&\n item.item.center().y > y0 &&\n item.item.center().y < y1\n )\n rxnArrowsList.push(id)\n })\n\n restruct.rxnPluses.forEach((item, id) => {\n if (\n item.item.pp.x > x0 &&\n item.item.pp.x < x1 &&\n item.item.pp.y > y0 &&\n item.item.pp.y < y1\n )\n rxnPlusesList.push(id)\n })\n\n restruct.simpleObjects.forEach((item, id) => {\n const referencePoints = item.getReferencePoints(true)\n const referencePointInRectangle = referencePoints.find(\n point => point.x > x0 && point.x < x1 && point.y > y0 && point.y < y1\n )\n if (referencePointInRectangle) simpleObjectsList.push(id)\n })\n\n const enhancedFlagList = []\n restruct.enhancedFlags.forEach((item, id) => {\n if (!item.pp) return\n if (item.pp.x > x0 && item.pp.x < x1 && item.pp.y > y0 && item.pp.y < y1)\n enhancedFlagList.push(id)\n })\n\n const sgroupDataList = []\n restruct.sgroupData.forEach((item, id) => {\n if (\n item.sgroup.pp.x > x0 &&\n item.sgroup.pp.x < x1 &&\n item.sgroup.pp.y > y0 &&\n item.sgroup.pp.y < y1\n )\n sgroupDataList.push(id)\n })\n\n const textsList = []\n restruct.texts.forEach((item, id) => {\n const referencePoints = item.getReferencePoints()\n const referencePointInRectangle = referencePoints.find(point => {\n return point.x > x0 && point.x < x1 && point.y > y0 && point.y < y1\n })\n\n if (referencePointInRectangle) {\n textsList.push(id)\n }\n })\n\n return {\n atoms: atomList,\n bonds: bondList,\n rxnArrows: rxnArrowsList,\n rxnPluses: rxnPlusesList,\n enhancedFlags: enhancedFlagList,\n sgroupData: sgroupDataList,\n simpleObjects: simpleObjectsList,\n texts: textsList\n }\n}\n\nfunction getElementsInPolygon(restruct, rr) {\n // eslint-disable-line max-statements\n const bondList = []\n const atomList = []\n const r = []\n const sGroups = restruct.sgroups\n const functionalGroups = restruct.molecule.functionalGroups\n\n for (let i = 0; i < rr.length; ++i) r[i] = new Vec2(rr[i].x, rr[i].y)\n\n restruct.bonds.forEach((bond, bid) => {\n const centre = Vec2.lc2(\n restruct.atoms.get(bond.b.begin).a.pp,\n 0.5,\n restruct.atoms.get(bond.b.end).a.pp,\n 0.5\n )\n if (\n isPointInPolygon(r, centre) &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n bond.b,\n sGroups,\n functionalGroups,\n true\n )\n )\n bondList.push(bid)\n })\n\n restruct.atoms.forEach((atom, aid) => {\n const relatedFGId = FunctionalGroup.findFunctionalGroupByAtom(\n functionalGroups,\n aid\n )\n const sGroup = restruct.sgroups.get(relatedFGId)\n if (\n isPointInPolygon(r, atom.a.pp) &&\n (!FunctionalGroup.isAtomInContractedFunctionalGroup(\n atom.a,\n sGroups,\n functionalGroups,\n true\n ) ||\n aid === sGroup.item.atoms[0])\n )\n atomList.push(aid)\n })\n\n const rxnArrowsList = []\n const rxnPlusesList = []\n const simpleObjectsList = []\n const textsList = []\n\n restruct.rxnArrows.forEach((item, id) => {\n const referencePoints = item.getReferencePoints(true)\n const referencePointInPolygon = referencePoints.find(point =>\n isPointInPolygon(r, point)\n )\n if (referencePointInPolygon) rxnArrowsList.push(id)\n })\n\n restruct.rxnPluses.forEach((item, id) => {\n if (isPointInPolygon(r, item.item.pp)) rxnPlusesList.push(id)\n })\n\n restruct.simpleObjects.forEach((item, id) => {\n const referencePoints = item.getReferencePoints(true)\n const referencePointInPolygon = referencePoints.find(point =>\n isPointInPolygon(r, point)\n )\n if (referencePointInPolygon) simpleObjectsList.push(id)\n })\n\n restruct.texts.forEach((item, id) => {\n const referencePoints = item.getReferencePoints()\n const referencePointInPolygon = referencePoints.find(point =>\n isPointInPolygon(r, point)\n )\n\n if (referencePointInPolygon) {\n textsList.push(id)\n }\n })\n\n const enhancedFlagList = []\n restruct.enhancedFlags.forEach((item, id) => {\n if (item.pp && isPointInPolygon(r, item.pp)) enhancedFlagList.push(id)\n })\n\n const sgroupDataList = []\n restruct.sgroupData.forEach((item, id) => {\n if (isPointInPolygon(r, item.sgroup.pp)) sgroupDataList.push(id)\n })\n\n return {\n atoms: atomList,\n bonds: bondList,\n rxnArrows: rxnArrowsList,\n rxnPluses: rxnPlusesList,\n enhancedFlags: enhancedFlagList,\n sgroupData: sgroupDataList,\n simpleObjects: simpleObjectsList,\n texts: textsList\n }\n}\n\n// TODO: test me see testPolygon from\n// 'Remove unused methods from render' commit\nfunction isPointInPolygon(r, p) {\n // eslint-disable-line max-statements\n var d = new Vec2(0, 1)\n var n = d.rotate(Math.PI / 2)\n var v0 = Vec2.diff(r[r.length - 1], p)\n var n0 = Vec2.dot(n, v0)\n var d0 = Vec2.dot(d, v0)\n var w0 = null\n var counter = 0\n var eps = 1e-5\n var flag1 = false\n var flag0 = false\n\n for (var i = 0; i < r.length; ++i) {\n var v1 = Vec2.diff(r[i], p)\n var w1 = Vec2.diff(v1, v0)\n var n1 = Vec2.dot(n, v1)\n var d1 = Vec2.dot(d, v1)\n flag1 = false\n if (n1 * n0 < 0) {\n if (d1 * d0 > -eps) {\n if (d0 > -eps) flag1 = true\n /* eslint-disable no-mixed-operators*/\n } else if (\n (Math.abs(n0) * Math.abs(d1) - Math.abs(n1) * Math.abs(d0)) * d1 >\n 0\n ) {\n /* eslint-enable no-mixed-operators*/\n flag1 = true\n }\n }\n if (flag1 && flag0 && Vec2.dot(w1, n) * Vec2.dot(w0, n) >= 0) flag1 = false\n if (flag1) counter++\n v0 = v1\n n0 = n1\n d0 = d1\n w0 = w1\n flag0 = flag1\n }\n return counter % 2 !== 0\n}\n\nexport default {\n inRectangle: getElementsInRectangle,\n inPolygon: getElementsInPolygon\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Scale } from 'ketcher-core'\nimport locate from './locate'\n\nfunction LassoHelper(mode, editor, fragment) {\n this.mode = mode\n this.fragment = fragment\n this.editor = editor\n}\n\nLassoHelper.prototype.getSelection = function () {\n const rnd = this.editor.render\n\n if (this.mode === 0) return locate.inPolygon(rnd.ctab, this.points)\n\n if (this.mode === 1)\n return locate.inRectangle(rnd.ctab, this.points[0], this.points[1])\n\n throw new Error('Selector mode unknown') // eslint-disable-line no-else-return\n}\n\nLassoHelper.prototype.begin = function (event) {\n const rnd = this.editor.render\n this.points = [rnd.page2obj(event)]\n if (this.mode === 1) this.points.push(this.points[0])\n}\n\nLassoHelper.prototype.running = function () {\n return !!this.points\n}\n\nLassoHelper.prototype.addPoint = function (event) {\n if (!this.points) return null\n\n const rnd = this.editor.render\n\n if (this.mode === 0) this.points.push(rnd.page2obj(event))\n else if (this.mode === 1) this.points = [this.points[0], rnd.page2obj(event)]\n\n this.update()\n return this.getSelection()\n}\n\nLassoHelper.prototype.update = function () {\n if (this.selection) {\n this.selection.remove()\n this.selection = null\n }\n\n if (this.points && this.points.length > 1) {\n const rnd = this.editor.render\n const dp = this.points.map(p =>\n Scale.obj2scaled(p, rnd.options).add(rnd.options.offset)\n )\n this.selection =\n this.mode === 0\n ? rnd.selectionPolygon(dp)\n : rnd.selectionRectangle(dp[0], dp[1])\n }\n}\n\nLassoHelper.prototype.end = function () {\n const ret = this.getSelection()\n this.points = null\n this.update(null)\n return ret\n}\n\nLassoHelper.prototype.cancel = function () {\n this.points = null\n this.update(null)\n}\n\nexport default LassoHelper\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Pile,\n SgContexts,\n checkOverlapping,\n fromSeveralSgroupAddition,\n fromSgroupAction,\n fromSgroupDeletion,\n FunctionalGroup,\n SGroup\n} from 'ketcher-core'\n\nimport LassoHelper from './helper/lasso'\nimport { isEqual } from 'lodash/fp'\nimport { selMerge } from './select'\n\nconst searchMaps = [\n 'atoms',\n 'bonds',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData'\n]\n\nfunction SGroupTool(editor, type) {\n if (!(this instanceof SGroupTool)) {\n var selection = editor.selection() || {}\n if (!selection.atoms && !selection.bonds)\n return new SGroupTool(editor, type)\n\n var sgroups = editor.render.ctab.molecule.sgroups\n var selectedAtoms = editor.selection().atoms\n const molecule = editor.render.ctab.molecule\n const struct = editor.render.ctab\n const newSelected = { atoms: [], bonds: [] }\n let actualSgroupId\n let atomsResult = []\n let extraAtoms\n const functionalGroups = editor.render.ctab.molecule.functionalGroups\n const result = []\n\n var id = sgroups.find((_, sgroup) => isEqual(sgroup.atoms, selectedAtoms))\n\n if (selectedAtoms && functionalGroups.size) {\n for (let atom of selectedAtoms) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n functionalGroups,\n atom\n )\n if (atomId == null) extraAtoms = true\n const atomFromStruct = atomId !== null && struct.atoms.get(atomId).a\n\n if (atomFromStruct) {\n for (let sgId of atomFromStruct.sgs.values()) {\n actualSgroupId = sgId\n }\n }\n if (\n atomFromStruct &&\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n sgroups,\n functionalGroups,\n false\n )\n ) {\n const sgroupAtoms =\n actualSgroupId !== undefined &&\n SGroup.getAtoms(molecule, sgroups.get(actualSgroupId))\n const sgroupBonds =\n actualSgroupId !== undefined &&\n SGroup.getBonds(molecule, sgroups.get(actualSgroupId))\n atom === sgroupAtoms[0] &&\n newSelected.atoms.push(...sgroupAtoms) &&\n newSelected.bonds.push(...sgroupBonds)\n }\n\n if (atomFromStruct) atomsResult.push(atomId)\n }\n }\n if (extraAtoms) atomsResult = []\n\n if (atomsResult && atomsResult.length > 0) {\n for (let id of atomsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) result.push(fgId)\n }\n }\n\n if (result.length) {\n editor.selection(null)\n editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n sgroupDialog(editor, id !== undefined ? id : null, type)\n return null\n }\n\n this.editor = editor\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n this.type = type\n\n this.lassoHelper = new LassoHelper(1, editor)\n this.editor.selection(null)\n}\n\nSGroupTool.prototype.mousedown = function (event) {\n var ci = this.editor.findItem(event, searchMaps)\n const atomResult = []\n const bondResult = []\n const result = []\n if (ci && this.functionalGroups.size && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n const atomFromStruct = atomId !== null && this.struct.atoms.get(atomId).a\n if (\n atomFromStruct &&\n !FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n atomResult.push(atomId)\n }\n if (ci && this.functionalGroups.size && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ci.id\n )\n const bondFromStruct = bondId !== null && this.struct.bonds.get(bondId).b\n if (\n bondFromStruct &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n bondFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n bondResult.push(bondId)\n }\n if (ci && this.functionalGroups.size && ci.map === 'functionalGroups') {\n const sgroup = this.sgroups.get(ci.id)\n if (FunctionalGroup.isFunctionalGroup(sgroup.item)) {\n this.editor.event.removeFG.dispatch({ fgIds: [ci.id] })\n return\n }\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n if (!ci)\n // ci.type == 'Canvas'\n this.lassoHelper.begin(event)\n}\n\nSGroupTool.prototype.mousemove = function (event) {\n if (this.lassoHelper.running(event))\n this.editor.selection(this.lassoHelper.addPoint(event))\n else this.editor.hover(this.editor.findItem(event, searchMaps))\n}\n\nSGroupTool.prototype.mouseleave = function (event) {\n if (this.lassoHelper.running(event)) this.lassoHelper.end(event)\n}\n\nSGroupTool.prototype.mouseup = function (event) {\n let ci = this.editor.findItem(event, searchMaps)\n const selected = this.editor.selection()\n let newSelected = { atoms: [], bonds: [] }\n let actualSgroupId\n let atomsResult = []\n let extraAtoms\n let bondsResult = []\n let extraBonds\n const result = []\n\n if (\n ci &&\n ci.map === 'functionalGroups' &&\n this.functionalGroups.size &&\n FunctionalGroup.isContractedFunctionalGroup(ci.id, this.functionalGroups)\n )\n return\n\n if (selected && this.functionalGroups.size && selected.atoms) {\n for (let atom of selected.atoms) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n atom\n )\n if (atomId == null) extraAtoms = true\n const atomFromStruct = atomId !== null && this.struct.atoms.get(atomId).a\n\n if (atomFromStruct) {\n for (let sgId of atomFromStruct.sgs.values()) {\n actualSgroupId = sgId\n }\n }\n if (\n atomFromStruct &&\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n ) {\n const sgroupAtoms =\n actualSgroupId !== undefined &&\n SGroup.getAtoms(\n this.molecule,\n this.struct.sgroups.get(actualSgroupId).item\n )\n const sgroupBonds =\n actualSgroupId !== undefined &&\n SGroup.getBonds(\n this.molecule,\n this.struct.sgroups.get(actualSgroupId).item\n )\n atom === sgroupAtoms[0] &&\n newSelected.atoms.push(...sgroupAtoms) &&\n newSelected.bonds.push(...sgroupBonds)\n }\n\n if (atomFromStruct) atomsResult.push(atomId)\n }\n }\n if (selected && this.functionalGroups.size && selected.bonds) {\n for (let bond of selected.bonds) {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n bond\n )\n if (bondId === null) extraBonds = true\n const bondFromStruct = bondId !== null && this.struct.bonds.get(bondId).b\n if (bondFromStruct) bondsResult.push(bondId)\n }\n }\n\n if (atomsResult.length) {\n atomsResult.forEach(id => {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n const sgroupAtoms = SGroup.getAtoms(\n this.molecule,\n this.struct.sgroups.get(fgId).item\n )\n newSelected.atoms.push(...sgroupAtoms)\n })\n }\n if (bondsResult.length) {\n bondsResult.forEach(id => {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n const sgroupBonds = SGroup.getBonds(\n this.molecule,\n this.struct.sgroups.get(fgId).item\n )\n newSelected.bonds.push(...sgroupBonds)\n })\n }\n if (extraAtoms || extraBonds) {\n atomsResult = null\n bondsResult = null\n }\n if (atomsResult && atomsResult.length > 0) {\n for (let id of atomsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n }\n if (bondsResult && bondsResult.length > 0) {\n for (let id of bondsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n }\n if (result.length === 1) {\n this.editor.selection(null)\n this.lassoHelper.cancel()\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n var id = null // id of an existing group, if we're editing one\n var selection = null // atoms to include in a newly created group\n if (this.lassoHelper.running(event)) {\n // TODO it catches more events than needed, to be re-factored\n selection =\n newSelected.atoms.length > 0\n ? selMerge(this.lassoHelper.end(event), newSelected)\n : this.lassoHelper.end(event)\n this.editor.selection(selection)\n } else {\n if (!ci)\n // ci.type == 'Canvas'\n return\n this.editor.hover(null)\n\n if (ci.map === 'atoms') {\n // if we click the SGroup tool on a single atom or bond, make a group out of those\n selection = { atoms: [ci.id] }\n } else if (ci.map === 'bonds') {\n var bond = this.editor.render.ctab.bonds.get(ci.id)\n selection = { atoms: [bond.b.begin, bond.b.end] }\n } else if (ci.map === 'sgroups' || ci.map === 'sgroupData') {\n id = ci.id\n } else {\n return\n }\n }\n\n // TODO: handle click on an existing group?\n if (id !== null || (selection && selection.atoms))\n sgroupDialog(this.editor, id, this.type)\n}\n\nSGroupTool.prototype.cancel = function () {\n if (this.lassoHelper.running()) this.lassoHelper.end()\n this.editor.selection(null)\n}\n\nexport function sgroupDialog(editor, id, defaultType) {\n const restruct = editor.render.ctab\n const struct = restruct.molecule\n const selection = editor.selection() || {}\n const sg = id !== null ? struct.sgroups.get(id) : null\n const type = sg ? sg.type : defaultType\n const eventName = type === 'DAT' ? 'sdataEdit' : 'sgroupEdit'\n\n if (!selection.atoms && !selection.bonds && !sg) {\n console.info('There is no selection or sgroup')\n return\n }\n\n let attrs = null\n if (sg) {\n attrs = sg.getAttrs()\n attrs.context = getContextBySgroup(restruct, sg.atoms)\n } else {\n attrs = {\n context: getContextBySelection(restruct, selection)\n }\n }\n\n const res = editor.event[eventName].dispatch({\n type,\n attrs\n })\n\n Promise.resolve(res)\n .then(newSg => {\n // TODO: check before signal\n if (\n newSg.type !== 'DAT' && // when data s-group separates\n checkOverlapping(struct, selection.atoms || [])\n ) {\n editor.event.message.dispatch({\n error: 'Partial S-group overlapping is not allowed.'\n })\n } else {\n if (\n !sg &&\n newSg.type !== 'DAT' &&\n (!selection.atoms || selection.atoms.length === 0)\n )\n return\n\n const isDataSg = sg && sg.getAttrs().context === newSg.attrs.context\n\n if (isDataSg) {\n const action = fromSeveralSgroupAddition(\n restruct,\n newSg.type,\n sg.atoms,\n newSg.attrs\n ).mergeWith(fromSgroupDeletion(restruct, id))\n\n editor.update(action)\n editor.selection(selection)\n return\n }\n\n const result = fromContextType(id, editor, newSg, selection)\n editor.update(result.action)\n editor.selection(null)\n }\n })\n .catch(() => null)\n}\n\nfunction getContextBySgroup(restruct, sgAtoms) {\n const struct = restruct.molecule\n\n if (sgAtoms.length === 1) return SgContexts.Atom\n\n if (manyComponentsSelected(restruct, sgAtoms)) return SgContexts.Multifragment\n\n if (singleComponentSelected(restruct, sgAtoms)) return SgContexts.Fragment\n\n const atomSet = new Pile(sgAtoms)\n\n const sgBonds = Array.from(struct.bonds.values()).filter(\n bond => atomSet.has(bond.begin) && atomSet.has(bond.end)\n )\n\n return anyChainedBonds(sgBonds) ? SgContexts.Group : SgContexts.Bond\n}\n\nfunction getContextBySelection(restruct, selection) {\n const struct = restruct.molecule\n\n if (selection.atoms && !selection.bonds) return SgContexts.Atom\n\n const bonds = selection.bonds.map(bondid => struct.bonds.get(bondid))\n\n if (!anyChainedBonds(bonds)) return SgContexts.Bond\n\n selection.atoms = selection.atoms || []\n\n const atomSet = new Pile(selection.atoms)\n const allBondsSelected = bonds.every(\n bond => atomSet.has(bond.begin) && atomSet.has(bond.end)\n )\n\n if (singleComponentSelected(restruct, selection.atoms) && allBondsSelected)\n return SgContexts.Fragment\n\n return manyComponentsSelected(restruct, selection.atoms)\n ? SgContexts.Multifragment\n : SgContexts.Group\n}\n\nfunction fromContextType(id, editor, newSg, currSelection) {\n const restruct = editor.render.ctab\n const sg = restruct.molecule.sgroups.get(id)\n const sourceAtoms = (sg && sg.atoms) || currSelection.atoms || []\n const context = newSg.attrs.context\n\n const result = fromSgroupAction(\n context,\n restruct,\n newSg,\n sourceAtoms,\n currSelection\n )\n\n result.selection = result.selection || currSelection\n\n if (id !== null && id !== undefined)\n result.action = result.action.mergeWith(fromSgroupDeletion(restruct, id))\n\n editor.selection(result.selection)\n\n return result\n}\n\nfunction anyChainedBonds(bonds) {\n if (bonds.length === 0) return true\n\n for (let i = 0; i < bonds.length; ++i) {\n const fixedBond = bonds[i]\n for (let j = 0; j < bonds.length; ++j) {\n if (i === j) continue\n\n const bond = bonds[j]\n\n if (fixedBond.end === bond.begin || fixedBond.end === bond.end)\n return true\n }\n }\n\n return false\n}\n\nfunction singleComponentSelected(restruct, atoms) {\n return countOfSelectedComponents(restruct, atoms) === 1\n}\n\nfunction manyComponentsSelected(restruct, atoms) {\n return countOfSelectedComponents(restruct, atoms) > 1\n}\n\nfunction countOfSelectedComponents(restruct, atoms) {\n const atomSet = new Pile(atoms)\n\n return Array.from(restruct.connectedComponents.values()).reduce(\n (acc, component) => acc + (atomSet.isSuperset(component) ? 1 : 0),\n 0\n )\n}\n\nexport default SGroupTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Action,\n SGroup,\n fromAtomsAttrs,\n fromBondsAttrs,\n fromItemsFuse,\n fromMultipleMove,\n fromTextDeletion,\n fromTextUpdating,\n getHoverToFuse,\n getItemsToFuse,\n FunctionalGroup,\n fromSimpleObjectResizing,\n fromArrowResizing\n} from 'ketcher-core'\n\nimport LassoHelper from './helper/lasso'\nimport { atomLongtapEvent } from './atom'\nimport { sgroupDialog } from './sgroup'\nimport utils from '../shared/utils'\nimport { xor } from 'lodash/fp'\nimport { Editor } from '../Editor'\n\nclass SelectTool {\n #mode: string\n #lassoHelper: any\n editor: Editor\n dragCtx: any\n\n constructor(editor, mode) {\n this.editor = editor\n this.#mode = mode\n this.#lassoHelper = new LassoHelper(\n this.#mode === 'lasso' ? 0 : 1,\n editor,\n this.#mode === 'fragment'\n )\n }\n\n mousedown(event) {\n const rnd = this.editor.render\n const ctab = rnd.ctab\n const molecule = ctab.molecule\n const functionalGroups = molecule.functionalGroups\n const selectedSgroups: any[] = []\n const newSelected = { atoms: [] as any[], bonds: [] as any[] }\n let actualSgroupId\n\n this.editor.hover(null) // TODO review hovering for touch devicess\n\n const selectFragment = this.#lassoHelper.fragment || event.ctrlKey\n const ci = this.editor.findItem(\n event,\n selectFragment\n ? [\n 'frags',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n ]\n : [\n 'atoms',\n 'bonds',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n ],\n null\n )\n\n if (ci && ci.map === 'atoms' && functionalGroups.size) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n functionalGroups,\n ci.id\n )\n const atomFromStruct = atomId !== null && ctab.atoms.get(ci.id)?.a\n\n if (atomFromStruct) {\n for (let sgId of atomFromStruct.sgs.values()) {\n actualSgroupId = sgId\n }\n }\n if (\n atomFromStruct &&\n actualSgroupId !== undefined &&\n !selectedSgroups.includes(actualSgroupId)\n )\n selectedSgroups.push(actualSgroupId)\n }\n if (ci && ci.map === 'bonds' && functionalGroups.size) {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n molecule,\n functionalGroups,\n ci.id\n )\n const sGroupId = FunctionalGroup.findFunctionalGroupByBond(\n molecule,\n functionalGroups,\n bondId\n )\n if (sGroupId !== null && !selectedSgroups.includes(sGroupId))\n selectedSgroups.push(sGroupId)\n }\n\n if (selectedSgroups.length) {\n for (let sgId of selectedSgroups) {\n const sgroup = ctab.sgroups.get(sgId)\n if (sgroup) {\n const sgroupAtoms = SGroup.getAtoms(molecule, sgroup.item)\n const sgroupBonds = SGroup.getBonds(molecule, sgroup.item)\n newSelected.atoms.push(...sgroupAtoms) &&\n newSelected.bonds.push(...sgroupBonds)\n }\n }\n this.editor.selection(newSelected)\n }\n\n this.dragCtx = {\n item: ci,\n xy0: rnd.page2obj(event)\n }\n\n if (!ci || ci.map === 'atoms') {\n atomLongtapEvent(this, rnd)\n }\n\n if (!ci) {\n // ci.type == 'Canvas'\n this.editor.selection(null)\n delete this.dragCtx.item\n if (!this.#lassoHelper.fragment) this.#lassoHelper.begin(event)\n return true\n }\n\n let sel = closestToSel(ci)\n let sgroups = ctab.sgroups.get(ci.id)\n const selection = this.editor.selection()\n if (ci.map === 'frags') {\n const frag = ctab.frags.get(ci.id)\n sel = {\n atoms: frag.fragGetAtoms(ctab, ci.id),\n bonds: frag.fragGetBonds(ctab, ci.id)\n }\n } else if (\n (ci.map === 'sgroups' || ci.map === 'functionalGroups') &&\n sgroups\n ) {\n const sgroup = sgroups.item\n sel = {\n atoms: SGroup.getAtoms(molecule, sgroup),\n bonds: SGroup.getBonds(molecule, sgroup)\n }\n } else if (ci.map === 'rgroups') {\n const rgroup = ctab.rgroups.get(ci.id)\n sel = {\n atoms: rgroup.getAtoms(rnd),\n bonds: rgroup.getBonds(rnd)\n }\n } else if (ci.map === 'sgroupData') {\n if (isSelected(selection, ci)) return true\n }\n\n if (!event.shiftKey) {\n this.editor.selection(isSelected(selection, ci) ? selection : sel)\n } else {\n this.editor.selection(selMerge(sel, selection, true))\n }\n return true\n }\n\n mousemove(event) {\n const editor = this.editor\n const rnd = editor.render\n const restruct = editor.render.ctab\n const dragCtx = this.dragCtx\n if (dragCtx && dragCtx.stopTapping) dragCtx.stopTapping()\n if (dragCtx && dragCtx.item) {\n const atoms = restruct.molecule.atoms\n const selection = editor.selection()\n const shouldDisplayDegree =\n dragCtx.item.map === 'atoms' &&\n atoms?.get(dragCtx.item.id)?.neighbors.length === 1 &&\n selection?.atoms?.length === 1 &&\n !selection.bonds\n if (shouldDisplayDegree) {\n // moving selected objects\n const pos = rnd.page2obj(event)\n const angle = utils.calcAngle(dragCtx.xy0, pos)\n const degrees = utils.degrees(angle)\n this.editor.event.message.dispatch({ info: degrees + 'º' })\n }\n if (dragCtx.item.map === 'simpleObjects' && dragCtx.item.ref) {\n if (dragCtx?.action) dragCtx.action.perform(rnd.ctab)\n const current = rnd.page2obj(event)\n const diff = current.sub(this.dragCtx.xy0)\n dragCtx.action = fromSimpleObjectResizing(\n rnd.ctab,\n dragCtx.item.id,\n diff,\n current,\n dragCtx.item.ref,\n event.shiftKey\n )\n editor.update(dragCtx.action, true)\n return true\n }\n if (dragCtx.item.map === 'rxnArrows' && dragCtx.item.ref) {\n if (dragCtx?.action) dragCtx.action.perform(rnd.ctab)\n const current = rnd.page2obj(event)\n const diff = current.sub(dragCtx.xy0)\n dragCtx.previous = current\n dragCtx.action = fromArrowResizing(\n rnd.ctab,\n dragCtx.item.id,\n diff,\n current,\n dragCtx.item.ref\n )\n editor.update(dragCtx.action, true)\n return true\n }\n if (dragCtx.action) {\n dragCtx.action.perform(restruct)\n // redraw the elements in unshifted position, lest the have different offset\n editor.update(dragCtx.action, true)\n }\n\n const expSel = editor.explicitSelected()\n dragCtx.action = fromMultipleMove(\n restruct,\n expSel,\n editor.render.page2obj(event).sub(dragCtx.xy0)\n )\n\n dragCtx.mergeItems = getItemsToFuse(editor, expSel)\n editor.hover(getHoverToFuse(dragCtx.mergeItems))\n\n editor.update(dragCtx.action, true)\n return true\n }\n\n if (this.#lassoHelper.running()) {\n const sel = this.#lassoHelper.addPoint(event)\n editor.selection(\n !event.shiftKey ? sel : selMerge(sel, editor.selection(), false)\n )\n return true\n }\n\n const maps =\n this.#lassoHelper.fragment || event.ctrlKey\n ? [\n 'frags',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n ]\n : [\n 'atoms',\n 'bonds',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n ]\n\n editor.hover(editor.findItem(event, maps, null))\n\n return true\n }\n\n mouseup(event) {\n const editor = this.editor\n const selected = editor.selection()\n const struct = editor.render.ctab\n const molecule = struct.molecule\n const functionalGroups = molecule.functionalGroups\n const selectedSgroups: any[] = []\n const newSelected = { atoms: [] as any[], bonds: [] as any[] }\n let actualSgroupId\n\n if (selected && functionalGroups.size && selected.atoms) {\n for (let atom of selected.atoms) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n functionalGroups,\n atom\n )\n const atomFromStruct = atomId !== null && struct.atoms.get(atomId)?.a\n\n if (atomFromStruct) {\n for (let sgId of atomFromStruct.sgs.values()) {\n actualSgroupId = sgId\n }\n }\n if (\n atomFromStruct &&\n actualSgroupId !== undefined &&\n !selectedSgroups.includes(actualSgroupId)\n )\n selectedSgroups.push(actualSgroupId)\n }\n }\n\n if (selected && functionalGroups.size && selected.bonds) {\n for (let atom of selected.bonds) {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n molecule,\n functionalGroups,\n atom\n )\n const sGroupId = FunctionalGroup.findFunctionalGroupByBond(\n molecule,\n functionalGroups,\n bondId\n )\n if (sGroupId !== null && !selectedSgroups.includes(sGroupId))\n selectedSgroups.push(sGroupId)\n }\n }\n\n if (selectedSgroups.length) {\n for (let sgId of selectedSgroups) {\n const sgroup = struct.sgroups.get(sgId)\n if (sgroup) {\n const sgroupAtoms = SGroup.getAtoms(molecule, sgroup.item)\n const sgroupBonds = SGroup.getBonds(molecule, sgroup.item)\n newSelected.atoms.push(...sgroupAtoms) &&\n newSelected.bonds.push(...sgroupBonds)\n }\n }\n }\n\n const dragCtx = this.dragCtx\n\n if (dragCtx && dragCtx.stopTapping) dragCtx.stopTapping()\n\n if (dragCtx && dragCtx.item) {\n dragCtx.action = dragCtx.action\n ? fromItemsFuse(struct, dragCtx.mergeItems).mergeWith(dragCtx.action)\n : fromItemsFuse(struct, dragCtx.mergeItems)\n\n editor.hover(null)\n if (dragCtx.mergeItems) editor.selection(null)\n if (dragCtx.action.operations.length !== 0) editor.update(dragCtx.action)\n\n delete this.dragCtx\n } else if (this.#lassoHelper.running()) {\n // TODO it catches more events than needed, to be re-factored\n const sel =\n newSelected.atoms.length > 0\n ? selMerge(this.#lassoHelper.end(), newSelected, false)\n : this.#lassoHelper.end()\n editor.selection(\n !event.shiftKey ? sel : selMerge(sel, editor.selection(), false)\n )\n } else if (this.#lassoHelper.fragment) {\n if (!event.shiftKey) editor.selection(null)\n }\n editor.event.message.dispatch({\n info: false\n })\n return true\n }\n\n dblclick(event) {\n const editor = this.editor\n const struct = editor.render.ctab\n const { molecule, sgroups } = struct\n const functionalGroups = molecule.functionalGroups\n const rnd = editor.render\n const ci = editor.findItem(\n event,\n ['atoms', 'bonds', 'sgroups', 'functionalGroups', 'sgroupData', 'texts'],\n null\n )\n\n const atomResult: any[] = []\n const bondResult: any[] = []\n const result: any[] = []\n if (ci && functionalGroups && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n functionalGroups,\n ci.id\n )\n const atomFromStruct = atomId !== null && struct.atoms.get(atomId)?.a\n if (\n atomId !== null &&\n !FunctionalGroup.isAtomInContractedFunctionalGroup(\n // TODO: examine if this code is really needed, seems like its a hack\n atomFromStruct,\n sgroups,\n functionalGroups,\n true\n )\n )\n atomResult.push(atomId)\n }\n if (ci && functionalGroups && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n molecule,\n functionalGroups,\n ci.id\n )\n const bondFromStruct = bondId !== null && struct.bonds.get(bondId)?.b\n if (\n bondId !== null &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n // TODO: examine if this code is really needed, seems like its a hack\n bondFromStruct,\n sgroups,\n functionalGroups,\n true\n )\n )\n bondResult.push(bondId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n molecule,\n functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n if (!ci) return true\n\n const selection = this.editor.selection()\n\n if (ci.map === 'atoms') {\n const action = new Action()\n var atom = molecule.atoms.get(ci.id)\n var ra = editor.event.elementEdit.dispatch(atom)\n if (selection?.atoms) {\n const selectionAtoms = selection.atoms\n Promise.resolve(ra)\n .then(newatom => {\n // TODO: deep compare to not produce dummy, e.g.\n // atom.label != attrs.label || !atom.atomList.equals(attrs.atomList)\n selectionAtoms.forEach(aid => {\n action.mergeWith(fromAtomsAttrs(struct, aid, newatom, false))\n })\n editor.update(action)\n })\n .catch(() => null)\n }\n } else if (ci.map === 'bonds') {\n const bond = rnd.ctab.bonds.get(ci.id)?.b\n const rb = editor.event.bondEdit.dispatch(bond)\n\n if (selection?.bonds) {\n const action = new Action()\n const bondsSelection = selection.bonds\n Promise.resolve(rb)\n .then(newbond => {\n bondsSelection.forEach(bid => {\n action.mergeWith(fromBondsAttrs(struct, bid, newbond))\n })\n editor.update(action)\n })\n .catch(() => null) // w/o changes\n }\n } else if (\n (ci.map === 'sgroups' &&\n !FunctionalGroup.isFunctionalGroup(molecule.sgroups.get(ci.id))) ||\n ci.map === 'sgroupData'\n ) {\n editor.selection(closestToSel(ci))\n sgroupDialog(editor, ci.id)\n } else if (ci.map === 'texts') {\n editor.selection(closestToSel(ci))\n const text = molecule.texts.get(ci.id)\n const dialog = editor.event.elementEdit.dispatch({\n ...text,\n type: 'text'\n })\n\n dialog\n .then(({ content }) => {\n if (!content) {\n editor.update(fromTextDeletion(struct, ci.id))\n } else if (content !== text?.content) {\n editor.update(fromTextUpdating(struct, ci.id, content))\n }\n })\n .catch(() => null)\n }\n return true\n }\n\n mouseleave(_) {\n if (this.dragCtx && this.dragCtx.stopTapping) this.dragCtx.stopTapping()\n\n if (this.dragCtx && this.dragCtx.action) {\n var action = this.dragCtx.action\n this.editor.update(action)\n }\n if (this.#lassoHelper.running())\n this.editor.selection(this.#lassoHelper.end())\n\n delete this.dragCtx\n\n this.editor.hover(null)\n }\n}\nfunction closestToSel(ci) {\n const res = {}\n res[ci.map] = [ci.id]\n return res\n}\n\n// TODO: deep-merge?\nexport function selMerge(selection, add, reversible: boolean) {\n if (add) {\n Object.keys(add).forEach(item => {\n if (!selection[item]) selection[item] = add[item].slice()\n else selection[item] = uniqArray(selection[item], add[item], reversible)\n })\n }\n return selection\n}\n\nfunction isSelected(selection, item) {\n return (\n selection && selection[item.map] && selection[item.map].includes(item.id)\n )\n}\n\nfunction uniqArray(dest, add, reversible: boolean) {\n return add.reduce((_, item) => {\n if (reversible) dest = xor(dest, [item])\n else if (!dest.includes(item)) dest.push(item)\n return dest\n }, [])\n}\n\nexport default SelectTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n fromArrowDeletion,\n fromFragmentDeletion,\n fromOneAtomDeletion,\n fromOneBondDeletion,\n fromPlusDeletion,\n fromSgroupDeletion,\n fromSimpleObjectDeletion,\n fromTextDeletion,\n FunctionalGroup,\n SGroup\n} from 'ketcher-core'\n\nimport LassoHelper from './helper/lasso'\nimport { selMerge } from './select'\n\nfunction EraserTool(editor, mode) {\n if (!(this instanceof EraserTool)) {\n if (!editor.selection()) return new EraserTool(editor, mode)\n\n const action = fromFragmentDeletion(editor.render.ctab, editor.selection())\n editor.update(action)\n editor.selection(null)\n return null\n }\n\n this.editor = editor\n this.sgroups = editor.render.ctab.sgroups\n this.struct = editor.render.ctab\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n\n this.maps = [\n 'atoms',\n 'bonds',\n 'rxnArrows',\n 'rxnPluses',\n 'sgroups',\n 'functionalGroups',\n 'sgroupData',\n 'simpleObjects',\n 'texts'\n ]\n this.lassoHelper = new LassoHelper(mode || 0, editor)\n}\n\nEraserTool.prototype.mousedown = function (event) {\n const ci = this.editor.findItem(event, this.maps)\n if (!ci)\n // ci.type == 'Canvas'\n this.lassoHelper.begin(event)\n}\n\nEraserTool.prototype.mousemove = function (event) {\n if (this.lassoHelper.running())\n this.editor.selection(this.lassoHelper.addPoint(event))\n else this.editor.hover(this.editor.findItem(event, this.maps))\n}\n\nEraserTool.prototype.mouseup = function (event) {\n const selected = this.editor.selection()\n let newSelected = { atoms: [], bonds: [] }\n let actualSgroupId\n const atomsResult = []\n const bondsResult = []\n const preResult = []\n\n if (selected && this.functionalGroups.size && selected.atoms) {\n for (let atom of selected.atoms) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n atom\n )\n const atomFromStruct = atomId !== null && this.struct.atoms.get(atomId).a\n\n if (atomFromStruct) {\n for (let sgId of atomFromStruct.sgs.values()) {\n actualSgroupId = sgId\n }\n }\n if (\n atomFromStruct &&\n FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n ) {\n const sgroupAtoms =\n actualSgroupId !== undefined &&\n SGroup.getAtoms(\n this.molecule,\n this.struct.sgroups.get(actualSgroupId).item\n )\n const sgroupBonds =\n actualSgroupId !== undefined &&\n SGroup.getBonds(\n this.molecule,\n this.struct.sgroups.get(actualSgroupId).item\n )\n atom === sgroupAtoms[0] &&\n newSelected.atoms.push(...sgroupAtoms) &&\n newSelected.bonds.push(...sgroupBonds)\n }\n\n if (\n atomFromStruct &&\n !FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n atomsResult.push(atomId)\n }\n }\n if (selected && this.functionalGroups.size && selected.bonds) {\n for (let bond of selected.bonds) {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n bond\n )\n const bondFromStruct = bondId !== null && this.struct.bonds.get(bondId).b\n if (\n bondFromStruct &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n bondFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n bondsResult.push(bondId)\n }\n }\n if (atomsResult.length > 0) {\n for (let id of atomsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n fgId !== null && !preResult.includes(fgId) && preResult.push(fgId)\n }\n }\n if (bondsResult.length > 0) {\n for (let id of bondsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n fgId !== null && !preResult.includes(fgId) && preResult.push(fgId)\n }\n }\n if (preResult.length > 0) {\n const result = []\n const sgroups = this.sgroups\n preResult.forEach(fgId => {\n const sgAtoms = sgroups.get(fgId).item.atoms\n sgAtoms.forEach(atom => {\n !atomsResult.includes(atom) &&\n !result.includes(fgId) &&\n result.push(fgId)\n })\n })\n if (result.length > 0) {\n this.editor.selection(null)\n this.editor.event.removeFG.dispatch({ fgIds: result })\n this.lassoHelper.cancel()\n }\n }\n\n // eslint-disable-line max-statements\n const rnd = this.editor.render\n\n if (this.lassoHelper.running()) {\n // TODO it catches more events than needed, to be re-factored\n const sel =\n newSelected.atoms.length > 0\n ? selMerge(this.lassoHelper.end(event), newSelected)\n : this.lassoHelper.end(event)\n this.editor.update(fromFragmentDeletion(rnd.ctab, sel))\n this.editor.selection(null)\n }\n}\n\nEraserTool.prototype.click = function (event) {\n const rnd = this.editor.render\n const restruct = this.editor.render.ctab\n const ci = this.editor.findItem(event, this.maps)\n const atomResult = []\n const bondResult = []\n const result = []\n\n if (\n ci &&\n this.functionalGroups &&\n ci.map === 'functionalGroups' &&\n !FunctionalGroup.isContractedFunctionalGroup(ci.id, this.functionalGroups)\n ) {\n const sGroup = this.sgroups.get(ci.id)\n if (FunctionalGroup.isFunctionalGroup(sGroup.item)) {\n result.push(ci.id)\n }\n } else if (ci && this.functionalGroups && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n const atomFromStruct = atomId !== null && this.struct.atoms.get(atomId).a\n if (\n atomFromStruct &&\n !FunctionalGroup.isAtomInContractedFunctionalGroup(\n atomFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n atomResult.push(atomId)\n } else if (ci && this.functionalGroups && ci.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ci.id\n )\n const bondFromStruct = bondId !== null && this.struct.bonds.get(bondId).b\n if (\n bondFromStruct &&\n !FunctionalGroup.isBondInContractedFunctionalGroup(\n bondFromStruct,\n this.sgroups,\n this.functionalGroups,\n true\n )\n )\n bondResult.push(bondId)\n }\n if (atomResult.length) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n } else if (bondResult.length) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n }\n if (result.length) {\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (!ci) return // ci.type == 'Canvas'\n\n this.editor.hover(null)\n if (ci.map === 'atoms') {\n this.editor.update(fromOneAtomDeletion(restruct, ci.id))\n } else if (ci.map === 'bonds') {\n this.editor.update(fromOneBondDeletion(restruct, ci.id))\n } else if (\n ci.map === 'functionalGroups' &&\n FunctionalGroup.isContractedFunctionalGroup(ci.id, this.functionalGroups)\n ) {\n const sGroup = this.sgroups.get(ci.id)\n this.editor.update(\n fromFragmentDeletion(rnd.ctab, {\n atoms: [...SGroup.getAtoms(this.molecule, sGroup.item)],\n bonds: [...SGroup.getBonds(this.molecule, sGroup.item)]\n })\n )\n } else if (ci.map === 'sgroups' || ci.map === 'sgroupData') {\n const sGroup = this.sgroups.get(ci.id)\n if (FunctionalGroup.isFunctionalGroup(sGroup.item)) {\n this.editor.event.removeFG.dispatch({ fgIds: [ci.id] })\n } else {\n this.editor.update(fromSgroupDeletion(restruct, ci.id))\n }\n } else if (ci.map === 'rxnArrows') {\n this.editor.update(fromArrowDeletion(restruct, ci.id))\n } else if (ci.map === 'rxnPluses') {\n this.editor.update(fromPlusDeletion(restruct, ci.id))\n } else if (ci.map === 'simpleObjects') {\n this.editor.update(fromSimpleObjectDeletion(restruct, ci.id))\n } else if (ci.map === 'texts') {\n this.editor.update(fromTextDeletion(restruct, ci.id))\n } else {\n // TODO re-factoring needed - should be \"map-independent\"\n console.error(\n 'EraserTool: unable to delete the object ' + ci.map + '[' + ci.id + ']'\n )\n return\n }\n this.editor.selection(null)\n}\n\nEraserTool.prototype.mouseleave = EraserTool.prototype.mouseup\n\nEraserTool.prototype.cancel = function () {\n if (this.lassoHelper.running()) this.lassoHelper.end()\n this.editor.selection(null)\n}\n\nexport default EraserTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n fromItemsFuse,\n fromPaste,\n FunctionalGroup,\n getHoverToFuse,\n getItemsToFuse\n} from 'ketcher-core'\n\nfunction PasteTool(editor, struct) {\n if (!(this instanceof PasteTool)) return new PasteTool(editor, struct)\n\n this.editor = editor\n this.editor.selection(null)\n this.struct = struct\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n\n const rnd = editor.render\n const point = editor.lastEvent ? rnd.page2obj(editor.lastEvent) : null\n\n const [action, pasteItems] = fromPaste(rnd.ctab, this.struct, point)\n this.action = action\n this.editor.update(this.action, true)\n\n this.mergeItems = getItemsToFuse(this.editor, pasteItems)\n this.editor.hover(getHoverToFuse(this.mergeItems), this)\n}\n\nPasteTool.prototype.mousemove = function (event) {\n const rnd = this.editor.render\n\n if (this.action) this.action.perform(rnd.ctab)\n\n const [action, pasteItems] = fromPaste(\n rnd.ctab,\n this.struct,\n rnd.page2obj(event)\n )\n this.action = action\n this.editor.update(this.action, true)\n\n this.mergeItems = getItemsToFuse(this.editor, pasteItems)\n this.editor.hover(getHoverToFuse(this.mergeItems))\n}\n\nPasteTool.prototype.mouseup = function () {\n const atomsResult = []\n const bondsResult = []\n const result = []\n if (\n this.mergeItems &&\n this.functionalGroups.size &&\n this.mergeItems.atoms.size\n ) {\n for (let id of this.mergeItems.atoms.values()) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n id\n )\n if (atomId !== null) atomsResult.push(atomId)\n }\n }\n if (\n this.mergeItems &&\n this.functionalGroups.size &&\n this.mergeItems.bonds.size\n ) {\n for (let id of this.mergeItems.bonds.values()) {\n const bondId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n id\n )\n if (bondId !== null) bondsResult.push(bondId)\n }\n }\n if (atomsResult.length > 0) {\n for (let id of atomsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondsResult.length > 0) {\n for (let id of bondsResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n const editor = this.editor\n const restruct = editor.render.ctab\n\n editor.selection(null)\n\n this.action = this.action\n ? fromItemsFuse(restruct, this.mergeItems).mergeWith(this.action)\n : fromItemsFuse(restruct, this.mergeItems)\n\n editor.hover(null)\n\n if (this.action) {\n const action = this.action\n delete this.action\n this.editor.update(action)\n }\n}\n\nPasteTool.prototype.cancel = function () {\n const rnd = this.editor.render\n this.editor.hover(null)\n if (this.action) {\n this.action.perform(rnd.ctab) // revert the action\n delete this.action\n rnd.update()\n }\n}\nPasteTool.prototype.mouseleave = PasteTool.prototype.cancel\n\nexport default PasteTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Atom,\n fromAtomAddition,\n fromAtomsAttrs,\n FunctionalGroup\n} from 'ketcher-core'\n\nfunction RGroupAtomTool(editor) {\n if (!(this instanceof RGroupAtomTool)) {\n // TODO: map atoms with labels\n editor.selection(null)\n return new RGroupAtomTool(editor)\n }\n\n this.editor = editor\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.functionalGroups = editor.render.ctab.molecule.functionalGroups\n}\n\nRGroupAtomTool.prototype.mousemove = function (event) {\n const struct = this.editor.render.ctab.molecule\n const ci = this.editor.findItem(event, ['atoms'])\n if (ci) {\n const atom = struct.atoms.get(ci.id)\n if (atom.attpnt === null) this.editor.hover(ci)\n } else {\n this.editor.hover(null)\n }\n}\n\nRGroupAtomTool.prototype.click = function (event) {\n const rnd = this.editor.render\n const ci = this.editor.findItem(event, ['atoms'])\n const atomResult = []\n const result = []\n if (ci && this.functionalGroups && ci.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ci.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (!ci) {\n // ci.type == 'Canvas'\n this.editor.hover(null)\n propsDialog(this.editor, null, rnd.page2obj(event))\n return true\n } else if (ci.map === 'atoms') {\n this.editor.hover(null)\n const struct = this.editor.render.ctab.molecule\n const atom = struct.atoms.get(ci.id)\n if (atom.attpnt !== null) return\n propsDialog(this.editor, ci.id)\n return true\n }\n return true\n}\n\nfunction propsDialog(editor, id, pos) {\n const struct = editor.render.ctab.molecule\n const atom = id || id === 0 ? struct.atoms.get(id) : null\n const rglabel = atom ? atom.rglabel : 0\n const label = atom ? atom.label : 'R#'\n\n const res = editor.event.elementEdit.dispatch({\n label: 'R#',\n rglabel,\n fragId: atom ? atom.fragment : null\n })\n\n Promise.resolve(res)\n .then(elem => {\n // TODO review: using Atom.attrlist as a source of default property values\n elem = Object.assign({}, Atom.attrlist, elem)\n\n if (!id && id !== 0 && elem.rglabel) {\n editor.update(fromAtomAddition(editor.render.ctab, pos, elem))\n } else if (rglabel !== elem.rglabel) {\n elem.aam = atom.aam // WTF??\n elem.attpnt = atom.attpnt\n\n if (!elem.rglabel && label !== 'R#') elem.label = label\n\n editor.update(fromAtomsAttrs(editor.render.ctab, id, elem))\n }\n })\n .catch(() => null) // w/o changes\n}\n\nexport default RGroupAtomTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n RGroup,\n fromRGroupAttrs,\n fromRGroupFragment,\n fromUpdateIfThen,\n FunctionalGroup\n} from 'ketcher-core'\n\nfunction RGroupFragmentTool(editor) {\n if (!(this instanceof RGroupFragmentTool)) {\n // TODO: check if it's a fragments already\n editor.selection(null)\n return new RGroupFragmentTool(editor)\n }\n\n this.editor = editor\n this.struct = editor.render.ctab\n this.sgroups = editor.render.ctab.sgroups\n this.molecule = editor.render.ctab.molecule\n this.functionalGroups = this.molecule.functionalGroups\n}\n\nRGroupFragmentTool.prototype.mousemove = function (event) {\n this.editor.hover(this.editor.findItem(event, ['frags', 'rgroups']))\n}\n\nRGroupFragmentTool.prototype.click = function (event) {\n const editor = this.editor\n const struct = editor.render.ctab.molecule\n const ci = editor.findItem(event, ['frags', 'rgroups'])\n const ce = editor.findItem(event, ['atoms', 'bonds'])\n const atomResult = []\n const bondResult = []\n const result = []\n if (ce && this.functionalGroups && ce.map === 'atoms') {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n this.functionalGroups,\n ce.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (ce && this.functionalGroups && ce.map === 'bonds') {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n this.functionalGroups,\n ce.id\n )\n if (bondId !== null) bondResult.push(bondId)\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n } else if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n this.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n\n if (!ci) return true\n\n this.editor.hover(null)\n\n const label =\n ci.map === 'rgroups'\n ? ci.id\n : RGroup.findRGroupByFragment(struct.rgroups, ci.id)\n\n const rg = Object.assign(\n { label },\n ci.map === 'frags' ? { fragId: ci.id } : struct.rgroups.get(ci.id)\n )\n\n const res = editor.event.rgroupEdit.dispatch(rg)\n\n Promise.resolve(res)\n .then(newRg => {\n const restruct = editor.render.ctab\n\n let action = null\n if (ci.map !== 'rgroups') {\n const rgidOld = RGroup.findRGroupByFragment(\n restruct.molecule.rgroups,\n ci.id\n )\n\n action = fromRGroupFragment(restruct, newRg.label, ci.id).mergeWith(\n fromUpdateIfThen(restruct, newRg.label, rgidOld)\n )\n } else {\n action = fromRGroupAttrs(restruct, ci.id, newRg)\n }\n\n editor.update(action)\n })\n .catch(() => null) // w/o changes\n\n return true\n}\n\nRGroupFragmentTool.prototype.cancel = function () {\n this.editor.hover(null)\n}\n\nexport default RGroupFragmentTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Vec2,\n fromArrowAddition,\n fromArrowDeletion,\n fromArrowResizing,\n fromMultipleMove\n} from 'ketcher-core'\n\nfunction ReactionArrowTool(editor, mode) {\n if (!(this instanceof ReactionArrowTool))\n return new ReactionArrowTool(editor, mode)\n\n this.mode = mode\n this.editor = editor\n this.editor.selection(null)\n}\n\nReactionArrowTool.prototype.mousedown = function (event) {\n var rnd = this.editor.render\n const p0 = rnd.page2obj(event)\n this.dragCtx = { p0 }\n\n var ci = this.editor.findItem(event, ['rxnArrows'])\n if (ci && ci.map === 'rxnArrows') {\n this.editor.hover(null)\n this.editor.selection({ rxnArrows: [ci.id] })\n this.dragCtx.ci = ci\n } else {\n this.dragCtx.isNew = true\n this.editor.selection(null)\n }\n}\n\nReactionArrowTool.prototype.mousemove = function (event) {\n var rnd = this.editor.render\n if (this.dragCtx) {\n const current = rnd.page2obj(event)\n const diff = current.sub(this.dragCtx.p0)\n this.dragCtx.previous = current\n if (this.dragCtx.ci) {\n if (this.dragCtx.action) this.dragCtx.action.perform(rnd.ctab)\n if (!this.dragCtx.ci.ref) {\n this.dragCtx.action = fromMultipleMove(\n rnd.ctab,\n this.editor.selection() || {},\n diff\n )\n } else {\n this.dragCtx.action = fromArrowResizing(\n rnd.ctab,\n this.dragCtx.ci.id,\n diff,\n current,\n this.dragCtx.ci.ref\n )\n }\n this.editor.update(this.dragCtx.action, true)\n } else {\n if (!this.dragCtx.action) {\n const action = fromArrowAddition(\n rnd.ctab,\n [this.dragCtx.p0, this.dragCtx.p0],\n this.mode\n )\n //TODO: need to rework actions/operations logic\n const addOperation = action.operations[0]\n const itemId = addOperation.data.id\n this.dragCtx.itemId = itemId\n this.dragCtx.action = action\n this.editor.update(this.dragCtx.action, true)\n } else {\n this.dragCtx.action.perform(rnd.ctab)\n }\n\n this.dragCtx.action = fromArrowResizing(\n rnd.ctab,\n this.dragCtx.itemId,\n diff,\n current,\n null\n )\n this.editor.update(this.dragCtx.action, true)\n }\n } else {\n const items = this.editor.findItem(event, ['rxnArrows'])\n this.editor.hover(items)\n }\n}\n\nReactionArrowTool.prototype.mouseup = function (event) {\n if (!this.dragCtx) return true\n const rnd = this.editor.render\n\n const p0 = this.dragCtx.p0\n const p1 = getDefaultLengthPos(p0, this.dragCtx.previous)\n\n if (this.dragCtx.action) {\n if (this.dragCtx.isNew) {\n this.editor.update(fromArrowDeletion(rnd.ctab, this.dragCtx.itemId), true)\n this.dragCtx.action = fromArrowAddition(rnd.ctab, [p0, p1], this.mode)\n }\n this.editor.update(this.dragCtx.action)\n }\n delete this.dragCtx\n return true\n}\n\nReactionArrowTool.prototype.click = function (event) {\n const rnd = this.editor.render\n const ci = this.editor.findItem(event, ['rxnArrows'])\n const p0 = rnd.page2obj(event)\n if (!ci) {\n this.editor.update(\n fromArrowAddition(rnd.ctab, [p0, getDefaultLengthPos(p0)], this.mode)\n )\n }\n}\n\nfunction getArrowParams(x1, y1, x2, y2) {\n const length = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\n const angle = calcAngle(x2, y2, x1, y1)\n return { length, angle }\n}\n\nfunction getDefaultLengthPos(pos1, pos2) {\n const minLength = 1.5\n const defaultLength = 2\n if (!pos2) {\n return new Vec2(pos1.x + defaultLength, pos1.y)\n }\n const arrowParams = getArrowParams(pos1.x, pos1.y, pos2.x, pos2.y)\n if (arrowParams.length <= minLength) {\n const newPos = new Vec2()\n newPos.x =\n pos1.x + defaultLength * Math.cos((Math.PI * arrowParams.angle) / 180)\n newPos.y =\n pos1.y + defaultLength * Math.sin((Math.PI * arrowParams.angle) / 180)\n return newPos\n }\n return pos2\n}\n\nfunction calcAngle(x1, y1, x2, y2) {\n const x = x1 - x2,\n y = y1 - y2\n if (!x && !y) {\n return 0\n }\n return (180 + (Math.atan2(-y, -x) * 180) / Math.PI + 360) % 360\n}\n\nexport default ReactionArrowTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Action, Scale, fromAtomsAttrs } from 'ketcher-core'\n\nfunction ReactionMapTool(editor) {\n if (!(this instanceof ReactionMapTool)) return new ReactionMapTool(editor)\n\n this.editor = editor\n this.editor.selection(null)\n}\n\nReactionMapTool.prototype.mousedown = function (event) {\n const rnd = this.editor.render\n this.rcs = rnd.ctab.molecule.getComponents()\n\n const ci = this.editor.findItem(event, ['atoms'])\n if (ci && ci.map === 'atoms') {\n this.editor.hover(null)\n this.dragCtx = {\n item: ci,\n xy0: rnd.page2obj(event)\n }\n }\n}\nReactionMapTool.prototype.mousemove = function (event) {\n var rnd = this.editor.render\n if ('dragCtx' in this) {\n var ci = this.editor.findItem(event, ['atoms'], this.dragCtx.item)\n var atoms = rnd.ctab.molecule.atoms\n if (\n ci &&\n ci.map === 'atoms' &&\n isValidMap(this.rcs, this.dragCtx.item.id, ci.id)\n ) {\n this.editor.hover(ci)\n this.updateLine(atoms.get(this.dragCtx.item.id).pp, atoms.get(ci.id).pp)\n } else {\n this.editor.hover(null)\n this.updateLine(atoms.get(this.dragCtx.item.id).pp, rnd.page2obj(event))\n }\n } else {\n this.editor.hover(this.editor.findItem(event, ['atoms']))\n }\n}\n\nReactionMapTool.prototype.updateLine = function (p1, p2) {\n if (this.line) {\n this.line.remove()\n this.line = null\n }\n if (p1 && p2) {\n var rnd = this.editor.render\n this.line = rnd.selectionLine(\n Scale.obj2scaled(p1, rnd.options).add(rnd.options.offset),\n Scale.obj2scaled(p2, rnd.options).add(rnd.options.offset)\n )\n }\n}\n\nReactionMapTool.prototype.mouseup = function (event) {\n // eslint-disable-line max-statements\n if ('dragCtx' in this) {\n var rnd = this.editor.render\n var ci = this.editor.findItem(event, ['atoms'], this.dragCtx.item)\n if (\n ci &&\n ci.map === 'atoms' &&\n isValidMap(this.rcs, this.dragCtx.item.id, ci.id)\n ) {\n var action = new Action()\n var atoms = rnd.ctab.molecule.atoms\n var atom1 = atoms.get(this.dragCtx.item.id)\n var atom2 = atoms.get(ci.id)\n var aam1 = atom1.aam\n var aam2 = atom2.aam\n if (!aam1 || aam1 !== aam2) {\n if ((aam1 && aam1 !== aam2) || (!aam1 && aam2)) {\n // eslint-disable-line no-mixed-operators\n atoms.forEach((atom, aid) => {\n if (\n aid !== this.dragCtx.item.id &&\n ((aam1 && atom.aam === aam1) || (aam2 && atom.aam === aam2))\n )\n action.mergeWith(fromAtomsAttrs(rnd.ctab, aid, { aam: 0 }))\n })\n }\n if (aam1) {\n action.mergeWith(fromAtomsAttrs(rnd.ctab, ci.id, { aam: aam1 }))\n } else {\n var aam = 0\n atoms.forEach(atom => {\n aam = Math.max(aam, atom.aam || 0)\n })\n action.mergeWith(\n fromAtomsAttrs(rnd.ctab, this.dragCtx.item.id, { aam: aam + 1 })\n )\n action.mergeWith(fromAtomsAttrs(rnd.ctab, ci.id, { aam: aam + 1 }))\n }\n this.editor.update(action)\n }\n }\n this.updateLine(null)\n delete this.dragCtx\n }\n this.editor.hover(null)\n}\n\nfunction isValidMap(rcs, aid1, aid2) {\n var t1\n var t2\n for (var ri = 0; (!t1 || !t2) && ri < rcs.reactants.length; ri++) {\n var ro = Array.from(rcs.reactants[ri])\n if (!t1 && ro.indexOf(aid1) >= 0) t1 = 'r'\n if (!t2 && ro.indexOf(aid2) >= 0) t2 = 'r'\n }\n for (var pi = 0; (!t1 || !t2) && pi < rcs.products.length; pi++) {\n var po = Array.from(rcs.products[pi])\n if (!t1 && po.indexOf(aid1) >= 0) t1 = 'p'\n if (!t2 && po.indexOf(aid2) >= 0) t2 = 'p'\n }\n return t1 && t2 && t1 !== t2\n}\n\nexport default ReactionMapTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { fromMultipleMove, fromPlusAddition } from 'ketcher-core'\n\nfunction ReactionPlusTool(editor) {\n if (!(this instanceof ReactionPlusTool)) return new ReactionPlusTool(editor)\n\n this.editor = editor\n this.editor.selection(null)\n}\n\nReactionPlusTool.prototype.mousedown = function (event) {\n var rnd = this.editor.render\n var ci = this.editor.findItem(event, ['rxnPluses'])\n if (ci && ci.map === 'rxnPluses') {\n this.editor.hover(null)\n this.editor.selection({ rxnPluses: [ci.id] })\n this.dragCtx = { xy0: rnd.page2obj(event) }\n }\n}\n\nReactionPlusTool.prototype.mousemove = function (event) {\n var rnd = this.editor.render\n if ('dragCtx' in this) {\n if (this.dragCtx.action) this.dragCtx.action.perform(rnd.ctab)\n this.dragCtx.action = fromMultipleMove(\n rnd.ctab,\n this.editor.selection() || {},\n rnd.page2obj(event).sub(this.dragCtx.xy0)\n )\n this.editor.update(this.dragCtx.action, true)\n } else {\n this.editor.hover(this.editor.findItem(event, ['rxnPluses']))\n }\n}\n\nReactionPlusTool.prototype.mouseup = function () {\n if (!this.dragCtx) return true\n\n if (this.dragCtx.action) {\n this.editor.update(this.dragCtx.action) // TODO investigate, subsequent undo/redo fails\n }\n\n delete this.dragCtx\n return true\n}\n\nReactionPlusTool.prototype.click = function (event) {\n const rnd = this.editor.render\n const ci = this.editor.findItem(event, ['rxnPluses'])\n if (!ci) {\n this.editor.update(fromPlusAddition(rnd.ctab, rnd.page2obj(event)))\n }\n}\n\nexport default ReactionPlusTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Action, fromAtomsAttrs } from 'ketcher-core'\n\nfunction ReactionUnmapTool(editor) {\n if (!(this instanceof ReactionUnmapTool)) return new ReactionUnmapTool(editor)\n\n this.editor = editor\n this.editor.selection(null)\n}\nReactionUnmapTool.prototype.mousemove = function (event) {\n var ci = this.editor.findItem(event, ['atoms'])\n if (ci && ci.map === 'atoms')\n this.editor.hover(\n this.editor.render.ctab.molecule.atoms.get(ci.id).aam ? ci : null\n )\n else this.editor.hover(null)\n}\nReactionUnmapTool.prototype.mouseup = function (event) {\n var ci = this.editor.findItem(event, ['atoms'])\n var atoms = this.editor.render.ctab.molecule.atoms\n if (ci && ci.map === 'atoms' && atoms.get(ci.id).aam) {\n var action = new Action()\n var aam = atoms.get(ci.id).aam\n atoms.forEach((atom, aid) => {\n if (atom.aam === aam)\n action.mergeWith(\n fromAtomsAttrs(this.editor.render.ctab, aid, { aam: 0 })\n )\n })\n this.editor.update(action)\n }\n this.editor.hover(null)\n}\n\nexport default ReactionUnmapTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Vec2,\n fromBondAlign,\n fromFlip,\n fromItemsFuse,\n fromRotate,\n getHoverToFuse,\n getItemsToFuse\n} from 'ketcher-core'\n\nimport utils from '../shared/utils'\n\nfunction RotateTool(editor, dir) {\n if (!(this instanceof RotateTool)) {\n if (!dir) return new RotateTool(editor)\n\n const restruct = editor.render.ctab\n const selection = editor.selection()\n const singleBond =\n selection &&\n selection.bonds &&\n Object.keys(selection).length === 1 &&\n selection.bonds.length === 1\n const action = !singleBond\n ? fromFlip(restruct, selection, dir)\n : fromBondAlign(restruct, selection.bonds[0], dir)\n editor.update(action)\n return null\n }\n\n this.editor = editor\n\n if (!editor.selection() || !editor.selection().atoms)\n // otherwise, clear selection\n this.editor.selection(null)\n}\n\nRotateTool.prototype.mousedown = function (event) {\n var xy0 = new Vec2()\n var selection = this.editor.selection()\n var rnd = this.editor.render\n var struct = rnd.ctab.molecule\n\n if (selection && selection.atoms) {\n var rotId = null\n var rotAll = false\n\n selection.atoms.forEach(aid => {\n var atom = struct.atoms.get(aid)\n\n xy0.add_(atom.pp) // eslint-disable-line no-underscore-dangle\n\n if (rotAll) return\n\n atom.neighbors.find(nei => {\n var hb = struct.halfBonds.get(nei)\n\n if (selection.atoms.indexOf(hb.end) === -1) {\n if (hb.loop >= 0) {\n var neiAtom = struct.atoms.get(aid)\n if (\n !neiAtom.neighbors.find(neiNei => {\n var neiHb = struct.halfBonds.get(neiNei)\n return (\n neiHb.loop >= 0 && selection.atoms.indexOf(neiHb.end) !== -1\n )\n })\n ) {\n rotAll = true\n return true\n }\n }\n if (rotId == null) {\n rotId = aid\n } else if (rotId !== aid) {\n rotAll = true\n return true\n }\n }\n return false\n })\n })\n\n if (!rotAll && rotId !== null) xy0 = struct.atoms.get(rotId).pp\n else xy0 = xy0.scaled(1 / selection.atoms.length)\n } else if (struct.atoms?.size) {\n struct.atoms.forEach(atom => {\n xy0.add_(atom.pp)\n }) // eslint-disable-line no-underscore-dangle, max-len\n // poor man struct center (without sdata, etc)\n xy0 = xy0.scaled(1 / struct.atoms.size)\n } else {\n xy0 = rnd.page2obj(event)\n }\n this.dragCtx = {\n xy0,\n angle1: utils.calcAngle(xy0, rnd.page2obj(event))\n }\n return true\n}\n\nRotateTool.prototype.mousemove = function (event) {\n // eslint-disable-line max-statements\n if (!this.dragCtx) return true\n\n const rnd = this.editor.render\n const dragCtx = this.dragCtx\n\n const pos = rnd.page2obj(event)\n let angle = utils.calcAngle(dragCtx.xy0, pos) - dragCtx.angle1\n if (!event.ctrlKey) angle = utils.fracAngle(angle)\n\n const degrees = utils.degrees(angle)\n\n if ('angle' in dragCtx && dragCtx.angle === degrees) return true\n if ('action' in dragCtx) dragCtx.action.perform(rnd.ctab)\n\n dragCtx.angle = degrees\n dragCtx.action = fromRotate(\n rnd.ctab,\n this.editor.selection(),\n dragCtx.xy0,\n angle\n )\n\n this.editor.event.message.dispatch({ info: degrees + 'º' })\n\n const expSel = this.editor.explicitSelected()\n dragCtx.mergeItems = getItemsToFuse(this.editor, expSel)\n this.editor.hover(getHoverToFuse(dragCtx.mergeItems))\n\n this.editor.update(dragCtx.action, true)\n return true\n}\n\nRotateTool.prototype.mouseup = function () {\n if (!this.dragCtx) return true\n const dragCtx = this.dragCtx\n const restruct = this.editor.render.ctab\n\n const action = dragCtx.action\n ? fromItemsFuse(restruct, dragCtx.mergeItems).mergeWith(dragCtx.action)\n : fromItemsFuse(restruct, dragCtx.mergeItems)\n delete this.dragCtx\n\n this.editor.update(action)\n this.editor.hover(null)\n if (dragCtx.mergeItems) this.editor.selection(null)\n this.editor.event.message.dispatch({\n info: false\n })\n return true\n}\n\nRotateTool.prototype.cancel = RotateTool.prototype.mouseup\nRotateTool.prototype.mouseleave = RotateTool.prototype.mouseup\n\nexport default RotateTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n fromMultipleMove,\n fromSimpleObjectAddition,\n fromSimpleObjectDeletion,\n fromSimpleObjectResizing\n} from 'ketcher-core'\n\nfunction SimpleObjectTool(editor, mode) {\n if (!(this instanceof SimpleObjectTool))\n return new SimpleObjectTool(editor, mode)\n\n this.mode = mode\n this.editor = editor\n this.editor.selection(null)\n}\n\nSimpleObjectTool.prototype.mousedown = function (event) {\n var rnd = this.editor.render\n const p0 = rnd.page2obj(event)\n this.dragCtx = { p0 }\n\n var ci = this.editor.findItem(event, ['simpleObjects'])\n if (ci && ci.map === 'simpleObjects') {\n this.editor.hover(null)\n this.editor.selection({ simpleObjects: [ci.id] })\n this.dragCtx.ci = ci\n } else {\n this.dragCtx.isNew = true\n this.editor.selection(null)\n }\n}\n\nSimpleObjectTool.prototype.mousemove = function (event) {\n var rnd = this.editor.render\n if (this.dragCtx) {\n const current = rnd.page2obj(event)\n const diff = current.sub(this.dragCtx.p0)\n this.dragCtx.previous = current\n if (this.dragCtx.ci) {\n if (this.dragCtx.action) this.dragCtx.action.perform(rnd.ctab)\n if (!this.dragCtx.ci.ref) {\n this.dragCtx.action = fromMultipleMove(\n rnd.ctab,\n this.editor.selection() || {},\n diff\n )\n } else {\n this.dragCtx.action = fromSimpleObjectResizing(\n rnd.ctab,\n this.dragCtx.ci.id,\n diff,\n current,\n this.dragCtx.ci.ref,\n event.shiftKey\n )\n }\n this.editor.update(this.dragCtx.action, true)\n } else {\n if (!this.dragCtx.action) {\n const action = fromSimpleObjectAddition(\n rnd.ctab,\n [this.dragCtx.p0, this.dragCtx.p0],\n this.mode\n )\n //TODO: need to rework actions/operations logic\n const addOperation = action.operations[0]\n const itemId = addOperation.data.id\n this.dragCtx.itemId = itemId\n this.dragCtx.action = action\n this.editor.update(this.dragCtx.action, true)\n } else {\n this.dragCtx.action.perform(rnd.ctab)\n }\n\n this.dragCtx.action = fromSimpleObjectResizing(\n rnd.ctab,\n this.dragCtx.itemId,\n diff,\n current,\n null,\n event.shiftKey\n )\n this.editor.update(this.dragCtx.action, true)\n }\n } else {\n const items = this.editor.findItem(event, ['simpleObjects'])\n this.editor.hover(items)\n }\n}\n\nSimpleObjectTool.prototype.mouseup = function (event) {\n if (!this.dragCtx) return true\n\n if (this.dragCtx.action) {\n if (this.dragCtx.isNew) {\n const rnd = this.editor.render\n this.editor.update(\n fromSimpleObjectDeletion(rnd.ctab, this.dragCtx.itemId),\n true\n )\n this.dragCtx.action = fromSimpleObjectAddition(\n rnd.ctab,\n [this.dragCtx.p0, this.dragCtx.previous],\n this.mode,\n event.shiftKey\n )\n }\n this.editor.update(this.dragCtx.action)\n }\n\n delete this.dragCtx\n return true\n}\n\nexport default SimpleObjectTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Vec2,\n fromItemsFuse,\n fromTemplateOnAtom,\n fromTemplateOnBondAction,\n fromTemplateOnCanvas,\n getHoverToFuse,\n getItemsToFuse,\n FunctionalGroup\n} from 'ketcher-core'\n\nimport utils from '../shared/utils'\n\nfunction TemplateTool(editor, tmpl) {\n // eslint-disable-line max-statements\n if (!(this instanceof TemplateTool)) return new TemplateTool(editor, tmpl)\n\n this.editor = editor\n this.mode = tmpl.mode\n this.struct = editor.render.ctab\n this.sgroups = this.struct.sgroups\n this.molecule = this.struct.molecule\n this.functionalGroups = this.molecule.functionalGroups\n this.editor.selection(null)\n\n this.template = {\n aid: parseInt(tmpl.aid) || 0,\n bid: parseInt(tmpl.bid) || 0\n }\n\n const frag = tmpl.struct\n frag.rescale()\n\n const xy0 = new Vec2()\n frag.atoms.forEach(atom => {\n xy0.add_(atom.pp) // eslint-disable-line no-underscore-dangle\n })\n\n this.template.molecule = frag // preloaded struct\n this.findItems = []\n this.template.xy0 = xy0.scaled(1 / (frag.atoms.size || 1)) // template center\n\n const atom = frag.atoms.get(this.template.aid)\n if (atom) {\n this.template.angle0 = utils.calcAngle(atom.pp, this.template.xy0) // center tilt\n this.findItems.push('atoms')\n }\n\n const bond = frag.bonds.get(this.template.bid)\n if (bond && this.mode !== 'fg') {\n // template location sign against attachment bond\n this.template.sign = getSign(frag, bond, this.template.xy0)\n this.findItems.push('bonds')\n }\n\n const sgroup = frag.sgroups.size\n if (sgroup) {\n this.findItems.push('sgroups')\n }\n}\n\nTemplateTool.prototype.mousedown = function (event) {\n const closestItem = this.editor.findItem(event, [\n 'atoms',\n 'bonds',\n 'sgroups',\n 'functionalGroups'\n ])\n const struct = this.editor.struct()\n const atomResult = []\n const bondResult = []\n const sGroupResult = []\n const result = []\n\n if (\n closestItem &&\n struct.functionalGroups.size &&\n closestItem.map === 'functionalGroups' &&\n FunctionalGroup.isContractedFunctionalGroup(\n closestItem.id,\n struct.functionalGroups\n )\n ) {\n sGroupResult.push(closestItem.id)\n }\n if (\n closestItem &&\n struct.functionalGroups.size &&\n closestItem.map === 'atoms'\n ) {\n const atomId = FunctionalGroup.atomsInFunctionalGroup(\n struct.functionalGroups,\n closestItem.id\n )\n if (atomId !== null) atomResult.push(atomId)\n }\n if (\n closestItem &&\n struct.functionalGroups.size &&\n closestItem.map === 'bonds'\n ) {\n const bondId = FunctionalGroup.bondsInFunctionalGroup(\n this.molecule,\n struct.functionalGroups,\n closestItem.id\n )\n if (bondId !== null) bondResult.push(bondId)\n }\n if (sGroupResult.length > 0) {\n for (let id of sGroupResult) {\n if (!result.includes(id)) result.push(id)\n }\n }\n if (atomResult.length > 0) {\n for (let id of atomResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n struct.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n }\n if (bondResult.length > 0) {\n for (let id of bondResult) {\n const fgId = FunctionalGroup.findFunctionalGroupByBond(\n this.molecule,\n struct.functionalGroups,\n id\n )\n if (fgId !== null && !result.includes(fgId)) {\n result.push(fgId)\n }\n }\n }\n if (result.length) {\n this.editor.event.removeFG.dispatch({ fgIds: result })\n return\n }\n // eslint-disable-line max-statements\n const editor = this.editor\n const restruct = editor.render.ctab\n this.editor.hover(null)\n\n this.dragCtx = {\n xy0: editor.render.page2obj(event),\n item: editor.findItem(event, this.findItems)\n }\n\n const dragCtx = this.dragCtx\n const ci = dragCtx.item\n\n if (!ci) {\n // ci.type == 'Canvas'\n delete dragCtx.item\n return true\n }\n\n if (ci.map === 'bonds' && this.mode !== 'fg') {\n // calculate fragment center\n const molecule = restruct.molecule\n const xy0 = new Vec2()\n const bond = molecule.bonds.get(ci.id)\n const frid = molecule.atoms.get(bond.begin).fragment\n const frIds = molecule.getFragmentIds(frid)\n let count = 0\n\n let loop = molecule.halfBonds.get(bond.hb1).loop\n\n if (loop < 0) loop = molecule.halfBonds.get(bond.hb2).loop\n\n if (loop >= 0) {\n const loopHbs = molecule.loops.get(loop).hbs\n loopHbs.forEach(hb => {\n xy0.add_(molecule.atoms.get(molecule.halfBonds.get(hb).begin).pp) // eslint-disable-line no-underscore-dangle, max-len\n count++\n })\n } else {\n frIds.forEach(id => {\n xy0.add_(molecule.atoms.get(id).pp) // eslint-disable-line no-underscore-dangle\n count++\n })\n }\n\n dragCtx.v0 = xy0.scaled(1 / count)\n\n const sign = getSign(molecule, bond, dragCtx.v0)\n\n // calculate default template flip\n dragCtx.sign1 = sign || 1\n dragCtx.sign2 = this.template.sign\n }\n\n return true\n}\n\nTemplateTool.prototype.mousemove = function (event) {\n // eslint-disable-line max-statements\n const restruct = this.editor.render.ctab\n\n if (!this.dragCtx) {\n this.editor.hover(this.editor.findItem(event, this.findItems))\n return true\n }\n\n const dragCtx = this.dragCtx\n const ci = dragCtx.item\n let pos0 = null\n const pos1 = this.editor.render.page2obj(event)\n const struct = restruct.molecule\n\n /* moving when attached to bond */\n if (ci && ci.map === 'bonds' && this.mode !== 'fg') {\n const bond = struct.bonds.get(ci.id)\n let sign = getSign(struct, bond, pos1)\n\n if (dragCtx.sign1 * this.template.sign > 0) sign = -sign\n\n if (sign !== dragCtx.sign2 || !dragCtx.action) {\n if (dragCtx.action) dragCtx.action.perform(restruct) // undo previous action\n\n dragCtx.sign2 = sign\n let [action, pasteItems] = fromTemplateOnBondAction(\n restruct,\n this.template,\n ci.id,\n this.editor.event,\n dragCtx.sign1 * dragCtx.sign2 > 0,\n false\n )\n\n dragCtx.action = action\n this.editor.update(dragCtx.action, true)\n\n dragCtx.mergeItems = getItemsToFuse(this.editor, pasteItems)\n this.editor.hover(getHoverToFuse(dragCtx.mergeItems))\n }\n return true\n }\n /* end */\n\n let extraBond = null\n // calc initial pos and is extra bond needed\n if (!ci) {\n // ci.type == 'Canvas'\n pos0 = dragCtx.xy0\n } else if (ci.map === 'atoms') {\n pos0 = struct.atoms.get(ci.id).pp\n extraBond = this.mode === 'fg' ? true : Vec2.dist(pos0, pos1) > 1\n }\n\n // calc angle\n let angle = utils.calcAngle(pos0, pos1)\n if (!event.ctrlKey) angle = utils.fracAngle(angle)\n const degrees = utils.degrees(angle)\n this.editor.event.message.dispatch({ info: degrees + 'º' })\n\n // check if anything changed since last time\n if (\n dragCtx.hasOwnProperty('angle') &&\n dragCtx.angle === degrees && // eslint-disable-line no-prototype-builtins\n (!dragCtx.hasOwnProperty('extra_bond') || dragCtx.extra_bond === extraBond)\n )\n // eslint-disable-line no-prototype-builtins\n return true\n\n // undo previous action\n if (dragCtx.action) dragCtx.action.perform(restruct)\n\n // create new action\n dragCtx.angle = degrees\n let action = null\n let pasteItems\n\n if (!ci) {\n // ci.type == 'Canvas'\n ;[action, pasteItems] = fromTemplateOnCanvas(\n restruct,\n this.template,\n pos0,\n angle\n )\n } else if (ci.map === 'atoms') {\n ;[action, pasteItems] = fromTemplateOnAtom(\n restruct,\n this.template,\n ci.id,\n angle,\n extraBond\n )\n dragCtx.extra_bond = extraBond\n }\n dragCtx.action = action\n\n this.editor.update(dragCtx.action, true)\n\n if (this.mode !== 'fg') {\n dragCtx.mergeItems = getItemsToFuse(this.editor, pasteItems)\n this.editor.hover(getHoverToFuse(dragCtx.mergeItems))\n }\n\n return true\n}\n\nTemplateTool.prototype.mouseup = function (event) {\n // eslint-disable-line max-statements\n const dragCtx = this.dragCtx\n if (!dragCtx) return true\n delete this.dragCtx\n\n const restruct = this.editor.render.ctab\n const struct = restruct.molecule\n const ci = dragCtx.item\n\n /* after moving around bond */\n if (dragCtx.action && ci && ci.map === 'bonds' && this.mode !== 'fg') {\n dragCtx.action.perform(restruct) // revert drag action\n fromTemplateOnBondAction(\n restruct,\n this.template,\n ci.id,\n this.editor.event,\n dragCtx.sign1 * dragCtx.sign2 > 0,\n true\n ).then(([action, pasteItems]) => {\n const mergeItems = getItemsToFuse(this.editor, pasteItems)\n action = fromItemsFuse(restruct, mergeItems).mergeWith(action)\n this.editor.update(action)\n })\n return true\n }\n /* end */\n\n let action\n let pasteItems = null\n\n if (!dragCtx.action) {\n if (!ci) {\n // ci.type == 'Canvas'\n ;[action, pasteItems] = fromTemplateOnCanvas(\n restruct,\n this.template,\n dragCtx.xy0,\n 0\n )\n dragCtx.action = action\n } else if (ci.map === 'atoms') {\n const degree = restruct.atoms.get(ci.id).a.neighbors.length\n let angle\n let extraBond\n\n if (degree > 1) {\n // common case\n angle = null\n extraBond = true\n } else if (degree === 1) {\n // on chain end\n const atom = struct.atoms.get(ci.id)\n const neiId = struct.halfBonds.get(atom.neighbors[0]).end\n const nei = struct.atoms.get(neiId)\n\n angle = event.ctrlKey\n ? utils.calcAngle(nei.pp, atom.pp)\n : utils.fracAngle(utils.calcAngle(nei.pp, atom.pp))\n extraBond = false\n } else {\n // on single atom\n angle = 0\n extraBond = false\n }\n\n ;[action, pasteItems] = fromTemplateOnAtom(\n restruct,\n this.template,\n ci.id,\n angle,\n extraBond\n )\n dragCtx.action = action\n } else if (ci.map === 'bonds' && this.mode !== 'fg') {\n fromTemplateOnBondAction(\n restruct,\n this.template,\n ci.id,\n this.editor.event,\n dragCtx.sign1 * dragCtx.sign2 > 0,\n true\n ).then(([action, pasteItems]) => {\n // eslint-disable-line no-shadow\n if (this.mode !== 'fg') {\n const mergeItems = getItemsToFuse(this.editor, pasteItems)\n action = fromItemsFuse(restruct, mergeItems).mergeWith(action)\n this.editor.update(action)\n }\n })\n\n return true\n }\n }\n\n this.editor.selection(null)\n\n if (!dragCtx.mergeItems && pasteItems && this.mode !== 'fg')\n dragCtx.mergeItems = getItemsToFuse(this.editor, pasteItems)\n dragCtx.action = dragCtx.action\n ? fromItemsFuse(restruct, dragCtx.mergeItems).mergeWith(dragCtx.action)\n : fromItemsFuse(restruct, dragCtx.mergeItems)\n\n this.editor.hover(null)\n const completeAction = dragCtx.action\n if (completeAction && !completeAction.isDummy())\n this.editor.update(completeAction)\n this.editor.event.message.dispatch({\n info: false\n })\n\n return true\n}\n\nTemplateTool.prototype.cancel = TemplateTool.prototype.mouseup\nTemplateTool.prototype.mouseleave = TemplateTool.prototype.mouseup\n\nfunction getSign(molecule, bond, v) {\n const begin = molecule.atoms.get(bond.begin).pp\n const end = molecule.atoms.get(bond.end).pp\n\n const sign = Vec2.cross(Vec2.diff(begin, end), Vec2.diff(v, end))\n\n if (sign > 0) return 1\n if (sign < 0) return -1\n return 0\n}\n\nexport default TemplateTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Action,\n Text,\n Vec2,\n fromMultipleMove,\n fromTextCreation,\n fromTextDeletion,\n fromTextUpdating\n} from 'ketcher-core'\n\ninterface Result {\n content: string\n}\n\nclass TextTool {\n editor: any\n dragCtx: any\n\n constructor(editor) {\n this.editor = editor\n this.editor.selection(null)\n }\n\n mousedown(event) {\n const render = this.editor.render\n const ci = this.editor.findItem(event, ['texts'])\n\n this.editor.selection(null)\n\n if (ci && ci.map === 'texts') {\n this.editor.hover(null)\n this.editor.selection({ texts: [ci.id] })\n this.dragCtx = {\n xy0: render.page2obj(event),\n action: new Action()\n }\n }\n }\n\n mousemove(event) {\n const render = this.editor.render\n\n if (this.dragCtx) {\n if (this.dragCtx.action) {\n this.dragCtx.action.perform(render.ctab)\n }\n\n this.dragCtx.action = fromMultipleMove(\n render.ctab,\n this.editor.selection() || {},\n render.page2obj(event).sub(this.dragCtx.xy0)\n )\n this.editor.update(this.dragCtx.action, true)\n } else {\n this.editor.hover(this.editor.findItem(event, ['texts']))\n }\n }\n\n mouseup() {\n if (this.dragCtx) {\n this.editor.update(this.dragCtx.action)\n delete this.dragCtx\n }\n return true\n }\n\n click(event) {\n const render = this.editor.render\n const ci = this.editor.findItem(event, ['texts'])\n this.editor.hover(null)\n\n if (!ci) {\n propsDialog(this.editor, null, render.page2obj(event))\n }\n\n return true\n }\n\n dblclick(event) {\n const ci = this.editor.findItem(event, ['texts'])\n this.editor.hover(null)\n\n if (ci.map === 'texts') {\n propsDialog(this.editor, ci.id, ci.position)\n }\n\n return true\n }\n}\n\nfunction propsDialog(editor: any, id: number | null, position: Vec2) {\n const struct = editor.render.ctab.molecule\n const text: Text | null = id || id === 0 ? struct.texts.get(id) : null\n const origilContent = text ? text.content : ''\n\n const res = editor.event.elementEdit.dispatch({\n content: origilContent,\n id,\n position,\n type: 'text'\n })\n\n res\n .then(({ content }: Result) => {\n if (!id && id !== 0 && content) {\n editor.update(fromTextCreation(editor.render.ctab, content, position))\n } else if (!content) {\n editor.update(fromTextDeletion(editor.render.ctab, id!))\n } else if (content !== origilContent) {\n editor.update(fromTextUpdating(editor.render.ctab, id!, content))\n }\n })\n .catch(() => null)\n}\n\nexport default function TextToolWrapper(editor) {\n return new TextTool(editor)\n}\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport APointTool from './apoint'\nimport AtomTool from './atom'\nimport AttachTool from './attach'\nimport BondTool from './bond'\nimport ChainTool from './chain'\nimport ChargeTool from './charge'\nimport EnhancedStereoTool from './enhanced-stereo'\nimport EraserTool from './eraser'\nimport PasteTool from './paste'\nimport RGroupAtomTool from './rgroupatom'\nimport RGroupFragmentTool from './rgroupfragment'\nimport ReactionArrowTool from './reactionarrow'\nimport ReactionMapTool from './reactionmap'\nimport ReactionPlusTool from './reactionplus'\nimport ReactionUnmapTool from './reactionunmap'\nimport RotateTool from './rotate'\nimport SGroupTool from './sgroup'\nimport SelectTool from './select'\nimport SimpleObjectTool from './simpleobject'\nimport TemplateTool from './template'\nimport TextToolWrapper from './text'\n\nconst tools = {\n rgroupatom: RGroupAtomTool,\n select: SelectTool,\n sgroup: SGroupTool,\n eraser: EraserTool,\n atom: AtomTool,\n bond: BondTool,\n chain: ChainTool,\n template: TemplateTool,\n charge: ChargeTool,\n rgroupfragment: RGroupFragmentTool,\n apoint: APointTool,\n attach: AttachTool,\n reactionarrow: ReactionArrowTool,\n reactionplus: ReactionPlusTool,\n reactionmap: ReactionMapTool,\n reactionunmap: ReactionUnmapTool,\n paste: PasteTool,\n rotate: RotateTool,\n enhancedStereo: EnhancedStereoTool,\n simpleobject: SimpleObjectTool,\n text: TextToolWrapper\n}\n\nexport default tools\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Action,\n findStereoAtoms,\n fromAtomsAttrs,\n fromStereoFlagUpdate\n} from 'ketcher-core'\n\nimport Editor from '../Editor'\n\nfunction EnhancedStereoTool(\n this: typeof EnhancedStereoTool,\n editor: Editor\n): null | void {\n if (!(this instanceof EnhancedStereoTool)) {\n const selection = editor.selection()\n\n const stereoAtoms = findStereoAtoms(\n editor.struct(),\n selection\n ? selection.atoms || []\n : Array.from(editor.struct().atoms.keys())\n )\n\n if (stereoAtoms.length === 0) return null\n\n changeAtomsStereoAction(editor, stereoAtoms).then(\n action => action && editor.update(action)\n )\n }\n}\n\nfunction changeAtomsStereoAction(\n editor: Editor,\n stereoAtoms: number[]\n): Promise {\n const struct = editor.struct()\n const restruct = editor.render.ctab\n const stereoLabels = stereoAtoms.map(stereoAtom => {\n const atom = struct.atoms.get(stereoAtom)\n return atom && atom.stereoLabel\n })\n const hasAnotherLabel = stereoLabels.some(\n stereoLabel => stereoLabel !== stereoLabels[0]\n )\n const res = editor.event.enhancedStereoEdit.dispatch({\n stereoLabel: hasAnotherLabel ? null : stereoLabels[0]\n })\n return res.then(stereoLabel => {\n if (!stereoLabel) return null\n const action = stereoAtoms.reduce(\n (acc, stereoAtom) => {\n return acc.mergeWith(\n fromStereoFlagUpdate(restruct, struct.atoms.get(stereoAtom)?.fragment)\n )\n },\n fromAtomsAttrs(\n restruct,\n stereoAtoms,\n {\n stereoLabel\n },\n false\n )\n )\n action.operations.reverse()\n return action\n })\n}\n\nexport default EnhancedStereoTool\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport {\n Action,\n Editor as KetcherEditor,\n Pile,\n Render,\n Struct,\n Vec2,\n fromDescriptorsAlign,\n fromNewCanvas\n} from 'ketcher-core'\nimport {\n DOMSubscription,\n PipelineSubscription,\n Subscription\n} from 'subscription'\n\nimport closest from './shared/closest'\nimport { customOnChangeHandler } from './utils'\nimport { isEqual } from 'lodash/fp'\nimport toolMap from './tool'\n\nconst SCALE = 40\nconst HISTORY_SIZE = 32 // put me to options\n\nconst structObjects = [\n 'atoms',\n 'bonds',\n 'frags',\n 'sgroups',\n 'sgroupData',\n 'rgroups',\n 'rxnArrows',\n 'rxnPluses',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n]\n\nconst highlightTargets = [\n 'atoms',\n 'bonds',\n 'rxnArrows',\n 'rxnPluses',\n 'functionalGroups',\n 'frags',\n 'merge',\n 'rgroups',\n 'sgroups',\n 'sgroupData',\n 'enhancedFlags',\n 'simpleObjects',\n 'texts'\n]\n\nfunction selectStereoFlagsIfNecessary(\n atoms: any,\n expAtoms: number[]\n): number[] {\n const atomsOfFragments = {}\n atoms.forEach((atom, atomId) => {\n atomsOfFragments[atom.fragment]\n ? atomsOfFragments[atom.fragment].push(atomId)\n : (atomsOfFragments[atom.fragment] = [atomId])\n })\n\n let stereoFlags: number[] = []\n\n Object.keys(atomsOfFragments).forEach(fragId => {\n let shouldSelSFlag: boolean = true\n atomsOfFragments[fragId].forEach(atomId => {\n if (!expAtoms.includes(atomId)) shouldSelSFlag = false\n })\n shouldSelSFlag && stereoFlags.push(Number(fragId))\n })\n return stereoFlags\n}\n\ninterface Selection {\n atoms?: Array\n bonds?: Array\n enhancedFlags?: Array\n rxnPluses?: Array\n rxnArrows?: Array\n}\nclass Editor implements KetcherEditor {\n #origin?: any\n render: Render\n _selection: Selection | null\n _tool: any\n historyStack: any\n historyPtr: any\n errorHandler: ((message: string) => void) | null\n event: {\n message: Subscription\n elementEdit: PipelineSubscription\n bondEdit: PipelineSubscription\n rgroupEdit: PipelineSubscription\n sgroupEdit: PipelineSubscription\n sdataEdit: PipelineSubscription\n quickEdit: PipelineSubscription\n attachEdit: PipelineSubscription\n removeFG: PipelineSubscription\n change: Subscription\n selectionChange: PipelineSubscription\n aromatizeStruct: PipelineSubscription\n dearomatizeStruct: PipelineSubscription\n enhancedStereoEdit: PipelineSubscription\n }\n lastEvent: any\n\n constructor(clientArea, options) {\n this.render = new Render(\n clientArea,\n Object.assign(\n {\n scale: SCALE\n },\n options\n )\n )\n\n this._selection = null // eslint-disable-line\n this._tool = null // eslint-disable-line\n this.historyStack = []\n this.historyPtr = 0\n this.errorHandler = null\n\n this.event = {\n message: new Subscription(),\n elementEdit: new PipelineSubscription(),\n bondEdit: new PipelineSubscription(),\n rgroupEdit: new PipelineSubscription(),\n sgroupEdit: new PipelineSubscription(),\n sdataEdit: new PipelineSubscription(),\n quickEdit: new PipelineSubscription(),\n attachEdit: new PipelineSubscription(),\n removeFG: new PipelineSubscription(),\n change: new Subscription(),\n selectionChange: new PipelineSubscription(),\n aromatizeStruct: new PipelineSubscription(),\n dearomatizeStruct: new PipelineSubscription(),\n // TODO: correct\n enhancedStereoEdit: new PipelineSubscription()\n }\n\n domEventSetup(this, clientArea)\n }\n\n isDitrty(): boolean {\n const position = this.historyPtr\n const length = this.historyStack.length\n if (!length || !this.#origin) {\n return false\n }\n return !isEqual(this.historyStack[position - 1], this.#origin)\n }\n\n setOrigin(): void {\n const position = this.historyPtr\n this.#origin = position ? this.historyStack[position - 1] : null\n }\n\n tool(name?: any, opts?: any) {\n /* eslint-disable no-underscore-dangle */\n if (arguments.length === 0) {\n return this._tool\n }\n\n if (this._tool && this._tool.cancel) {\n this._tool.cancel()\n }\n\n // TODO: when all tools are refactored to classes, remove this check\n // and use new keyword for every tool\n let tool\n if (name === 'select') {\n tool = new toolMap[name](this, opts)\n } else {\n tool = toolMap[name](this, opts)\n }\n if (!tool) {\n return null\n }\n\n this._tool = tool\n return this._tool\n /* eslint-enable no-underscore-dangle */\n }\n\n clear() {\n this.struct(undefined)\n }\n\n struct(value?: Struct): Struct {\n if (arguments.length === 0) {\n return this.render.ctab.molecule\n }\n\n this.selection(null)\n const struct = value || new Struct()\n const action = fromNewCanvas(this.render.ctab, struct)\n this.update(action)\n\n const structCenter = getStructCenter(this.render.ctab)\n recoordinate(this, structCenter)\n return this.render.ctab.molecule\n }\n\n options(value?: any) {\n if (arguments.length === 0) {\n return this.render.options\n }\n\n const struct = this.render.ctab.molecule\n const zoom = this.render.options.zoom\n this.render.clientArea.innerHTML = ''\n\n this.render = new Render(\n this.render.clientArea,\n Object.assign({ scale: SCALE }, value)\n )\n this.render.setMolecule(struct) // TODO: reuse this.struct here?\n this.render.setZoom(zoom)\n this.render.update()\n return this.render.options\n }\n\n zoom(value?: any) {\n if (arguments.length === 0) {\n return this.render.options.zoom\n }\n\n this.render.setZoom(value)\n\n const selection = this.selection()\n const structCenter = getStructCenter(this.render.ctab, selection)\n recoordinate(this, structCenter)\n\n this.render.update()\n return this.render.options.zoom\n }\n\n selection(ci?: any) {\n if (arguments.length === 0) {\n return this._selection // eslint-disable-line\n }\n\n let ReStruct = this.render.ctab\n\n this._selection = null // eslint-disable-line\n if (ci === 'all') {\n // TODO: better way will be this.struct()\n ci = structObjects.reduce((res, key) => {\n res[key] = Array.from(ReStruct[key].keys())\n return res\n }, {})\n }\n\n if (ci === 'descriptors') {\n ReStruct = this.render.ctab\n ci = { sgroupData: Array.from(ReStruct['sgroupData'].keys()) }\n }\n\n if (ci) {\n let res: Selection = {}\n\n Object.keys(ci).forEach(key => {\n if (ci[key].length > 0)\n // TODO: deep merge\n res[key] = ci[key].slice()\n })\n\n if (Object.keys(res).length !== 0) {\n this._selection = res // eslint-disable-line\n }\n const stereoFlags = selectStereoFlagsIfNecessary(\n this.struct().atoms,\n this.explicitSelected().atoms\n )\n if (stereoFlags.length !== 0) {\n this._selection && this._selection.enhancedFlags\n ? (this._selection.enhancedFlags = Array.from(\n new Set([...this._selection.enhancedFlags, ...stereoFlags])\n ))\n : (res.enhancedFlags = stereoFlags)\n }\n }\n\n this.render.ctab.setSelection(this._selection) // eslint-disable-line\n this.event.selectionChange.dispatch(this._selection) // eslint-disable-line\n\n this.render.update()\n return this._selection // eslint-disable-line\n }\n\n hover(ci: any, newTool?: any) {\n const tool = newTool || this._tool // eslint-disable-line\n\n if (\n 'ci' in tool &&\n (!ci || tool.ci.map !== ci.map || tool.ci.id !== ci.id)\n ) {\n this.highlight(tool.ci, false)\n delete tool.ci\n }\n\n if (ci && this.highlight(ci, true)) tool.ci = ci\n }\n\n highlight(ci: any, visible: any) {\n if (highlightTargets.indexOf(ci.map) === -1) {\n return false\n }\n\n const render = this.render\n let item: any = null\n\n if (ci.map === 'merge') {\n Object.keys(ci.items).forEach(mp => {\n ci.items[mp].forEach(dstId => {\n item = render.ctab[mp].get(dstId)!\n\n if (item) {\n item.setHighlight(visible, render)\n }\n })\n })\n\n return true\n }\n\n if (ci.map === 'functionalGroups') ci.map = 'sgroups' // TODO: Refactor object\n\n item = (render.ctab[ci.map] as Map).get(ci.id)\n if (!item) {\n return true // TODO: fix, attempt to highlight a deleted item\n }\n\n if (\n (ci.map === 'sgroups' && item.item.type === 'DAT') ||\n ci.map === 'sgroupData'\n ) {\n // set highlight for both the group and the data item\n const item1 = render.ctab.sgroups.get(ci.id)\n if (item1) {\n item1.setHighlight(visible, render)\n }\n\n const item2 = render.ctab.sgroupData.get(ci.id)\n if (item2) {\n item2.setHighlight(visible, render)\n }\n } else {\n item.setHighlight(visible, render)\n }\n return true\n }\n\n update(action: Action | true, ignoreHistory?) {\n if (action === true) {\n this.render.update(true) // force\n } else {\n if (!ignoreHistory && !action.isDummy()) {\n this.historyStack.splice(this.historyPtr, HISTORY_SIZE + 1, action)\n if (this.historyStack.length > HISTORY_SIZE) {\n this.historyStack.shift()\n }\n this.historyPtr = this.historyStack.length\n this.event.change.dispatch(action) // TODO: stoppable here\n }\n this.render.update()\n }\n }\n\n historySize() {\n return {\n undo: this.historyPtr,\n redo: this.historyStack.length - this.historyPtr\n }\n }\n\n undo() {\n if (this.historyPtr === 0) {\n throw new Error('Undo stack is empty')\n }\n if (this.tool() && this.tool().cancel) {\n this.tool().cancel()\n }\n\n this.selection(null)\n\n if (this._tool instanceof toolMap['paste']) {\n this.event.change.dispatch()\n return\n }\n\n this.historyPtr--\n const stack = this.historyStack[this.historyPtr]\n const action = stack.perform(this.render.ctab)\n\n this.historyStack[this.historyPtr] = action\n this.event.change.dispatch(action)\n this.render.update()\n }\n\n redo() {\n if (this.historyPtr === this.historyStack.length) {\n throw new Error('Redo stack is empty')\n }\n\n if (this.tool() && this.tool().cancel) {\n this.tool().cancel()\n }\n\n this.selection(null)\n if (this._tool instanceof toolMap['paste']) {\n this.event.change.dispatch()\n return\n }\n\n const action = this.historyStack[this.historyPtr].perform(this.render.ctab)\n this.historyStack[this.historyPtr] = action\n this.historyPtr++\n this.event.change.dispatch(action)\n this.render.update()\n }\n\n subscribe(eventName: any, handler: any) {\n let subscriber = {\n handler: handler\n }\n\n switch (eventName) {\n case 'change':\n const subscribeFuncWrapper = action =>\n customOnChangeHandler(action, handler)\n subscriber.handler = subscribeFuncWrapper\n this.event[eventName].add(subscribeFuncWrapper)\n break\n\n default:\n this.event[eventName].add(handler)\n }\n\n return subscriber\n }\n\n unsubscribe(eventName: any, subscriber: any) {\n //Only for event type - subscription\n this.event[eventName].remove(subscriber.handler)\n }\n\n findItem(event: any, maps: any, skip: any) {\n const pos = new Vec2(this.render.page2obj(event))\n\n return closest.item(this.render.ctab, pos, maps, skip, this.render.options)\n }\n\n findMerge(srcItems: any, maps: any) {\n return closest.merge(this.render.ctab, srcItems, maps, this.render.options)\n }\n\n explicitSelected() {\n const selection = this.selection() || {}\n const res = structObjects.reduce((acc, key) => {\n acc[key] = selection[key] ? selection[key].slice() : []\n return acc\n }, {} as any)\n\n const struct = this.render.ctab.molecule\n\n // \"auto-select\" the atoms for the bonds in selection\n if (res.bonds) {\n res.bonds.forEach(bid => {\n const bond = struct.bonds.get(bid)!\n res.atoms = res.atoms || []\n if (res.atoms.indexOf(bond.begin) < 0) {\n res.atoms.push(bond.begin)\n }\n\n if (res.atoms.indexOf(bond.end) < 0) {\n res.atoms.push(bond.end)\n }\n })\n }\n\n // \"auto-select\" the bonds with both atoms selected\n if (res.atoms && res.bonds) {\n struct.bonds.forEach((bond, bid) => {\n if (\n res.bonds.indexOf(bid) >= 0 &&\n res.atoms.indexOf(bond.begin) >= 0 &&\n res.atoms.indexOf(bond.end) >= 0\n ) {\n res.bonds = res.bonds || []\n res.bonds.push(bid)\n }\n })\n }\n\n return res\n }\n\n structSelected() {\n const struct = this.render.ctab.molecule\n const selection = this.explicitSelected()\n const dst = struct.clone(\n new Pile(selection.atoms),\n new Pile(selection.bonds),\n true,\n null,\n new Pile(selection.simpleObjects),\n new Pile(selection.texts)\n )\n\n // Copy by its own as Struct.clone doesn't support\n // arrows/pluses id sets\n struct.rxnArrows.forEach((item, id) => {\n if (selection.rxnArrows.indexOf(id) !== -1)\n dst.rxnArrows.add(item.clone())\n })\n struct.rxnPluses.forEach((item, id) => {\n if (selection.rxnPluses.indexOf(id) !== -1)\n dst.rxnPluses.add(item.clone())\n })\n\n dst.isReaction = struct.isReaction && struct.isRxn()\n\n return dst\n }\n\n alignDescriptors() {\n this.selection(null)\n const action = fromDescriptorsAlign(this.render.ctab)\n this.update(action)\n this.render.update(true)\n }\n}\n\nfunction isMouseRight(event) {\n return (\n (event.which && event.which === 3) || (event.button && event.button === 2)\n )\n}\n\nfunction domEventSetup(editor: Editor, clientArea) {\n // TODO: addEventListener('resize', ...);\n ;[\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseleave'\n ].forEach(eventName => {\n editor.event[eventName] = new DOMSubscription()\n const subs = editor.event[eventName]\n clientArea.addEventListener(eventName, subs.dispatch.bind(subs))\n\n subs.add(event => {\n if (eventName !== 'mouseup' && eventName !== 'mouseleave') {\n // to complete drag actions\n if (\n isMouseRight(event) ||\n !event.target ||\n event.target.nodeName === 'DIV'\n ) {\n // click on scroll\n editor.hover(null)\n return true\n }\n }\n const EditorTool = editor.tool()\n editor.lastEvent = event\n if (EditorTool && eventName in EditorTool) {\n EditorTool[eventName](event)\n }\n return true\n }, -1)\n })\n}\n\nfunction recoordinate(editor: Editor, rp /* , vp*/) {\n // rp is a point in scaled coordinates, which will be positioned\n // vp is the point where the reference point should now be (in view coordinates)\n // or the center if not set\n console.assert(rp, 'Reference point not specified')\n editor.render.setScrollOffset(0, 0)\n}\n\nfunction getStructCenter(ReStruct, selection?) {\n const bb = ReStruct.getVBoxObj(selection || {})\n return Vec2.lc2(bb.p0, 0.5, bb.p1, 0.5)\n}\n\nexport { Editor }\nexport default Editor\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { OperationType } from 'ketcher-core'\n\ntype Data = {\n operation: any\n id?: number\n label?: string\n position?: {\n x: number\n y: number\n }\n attribute?: any\n from?: any\n to?: any\n atomId?: any\n fragId?: any\n sGroupId?: any\n type?: any\n mode?: any\n}\n\nexport function customOnChangeHandler(action, handler) {\n const data: Data[] = []\n\n action.operations.reverse().forEach(operation => {\n const op = operation._inverted\n switch (op.type) {\n case OperationType.ATOM_ADD:\n case OperationType.ATOM_DELETE:\n data.push({\n operation: op.type,\n id: op.data.aid,\n label: op.data.atom.label ? op.data.atom.label : '',\n position: {\n x: +op.data.pos.x.toFixed(2),\n y: +op.data.pos.y.toFixed(2)\n }\n })\n break\n\n case OperationType.ATOM_ATTR:\n data.push({\n operation: operation.type,\n id: operation.data.aid,\n attribute: operation.data.attribute,\n from: operation.data.value,\n to: operation.data2.value\n })\n break\n\n case OperationType.ATOM_MOVE:\n data.push({\n operation: op.type,\n id: op.data.aid,\n position: {\n x: +op.data.d.x.toFixed(2),\n y: +op.data.d.y.toFixed(2)\n }\n })\n break\n\n case OperationType.BOND_ADD:\n case OperationType.BOND_DELETE:\n data.push({\n operation: op.type,\n id: op.data.bid\n })\n break\n\n case OperationType.FRAGMENT_ADD:\n case OperationType.FRAGMENT_DELETE:\n data.push({\n operation: op.type,\n id: op.frid\n })\n break\n\n case OperationType.FRAGMENT_ADD_STEREO_ATOM:\n case OperationType.FRAGMENT_DELETE_STEREO_ATOM:\n data.push({\n operation: op.type,\n atomId: op.data.aid,\n fragId: op.data.frid\n })\n break\n\n case OperationType.S_GROUP_ATOM_ADD:\n case OperationType.S_GROUP_ATOM_REMOVE:\n data.push({\n operation: op.type,\n atomId: op.data.aid,\n sGroupId: op.data.sgid\n })\n break\n\n case OperationType.S_GROUP_CREATE:\n case OperationType.S_GROUP_DELETE:\n data.push({\n operation: op.type,\n type: op.data.type,\n sGroupId: op.data.sgid\n })\n break\n\n case OperationType.RXN_ARROW_ADD:\n case OperationType.RXN_ARROW_DELETE:\n data.push({\n operation: op.type,\n id: op.data.arid,\n position: {\n x: +op.data.pos.x.toFixed(2),\n y: +op.data.pos.y.toFixed(2)\n }\n })\n break\n\n case OperationType.RXN_ARROW_RESIZE:\n data.push({\n operation: op.type,\n id: op.data.id\n })\n break\n\n case OperationType.RXN_ARROW_MOVE:\n data.push({\n operation: op.type,\n id: op.data.id,\n position: {\n x: +op.data.d.x.toFixed(2),\n y: +op.data.d.y.toFixed(2)\n }\n })\n break\n\n case OperationType.R_GROUP_FRAGMENT:\n data.push({\n operation: operation.type,\n id: op.frid\n })\n break\n\n case OperationType.SIMPLE_OBJECT_ADD:\n case OperationType.SIMPLE_OBJECT_DELETE:\n data.push({\n operation: op.type,\n id: op.data.id,\n mode: op.data.mode\n })\n break\n\n case OperationType.SIMPLE_OBJECT_RESIZE:\n data.push({\n operation: op.type,\n id: op.data.id\n })\n break\n\n case OperationType.SIMPLE_OBJECT_MOVE:\n data.push({\n operation: operation.type,\n id: operation.data.id,\n position: {\n x: +operation.data.d.x.toFixed(2),\n y: +operation.data.d.y.toFixed(2)\n }\n })\n break\n\n default:\n data.push({\n operation: op.type\n })\n }\n })\n\n return handler(data)\n}\n","import { ContextMenu, MenuItem } from 'react-contextmenu'\nimport { useState } from 'react'\nimport {\n FunctionalGroup,\n setExpandSGroup,\n fromSgroupDeletion,\n Action\n} from 'ketcher-core'\nimport { useAppContext } from '../../../../hooks'\nimport clsx from 'clsx'\nimport classes from './ContextMenu.module.less'\n\nconst FGContextMenu = () => {\n const { getKetcherInstance } = useAppContext()\n\n const handleExpand = () => {\n const editor = getKetcherInstance().editor as any\n const action = new Action()\n const expandData = targetItems[0].isExpanded\n targetItems?.forEach(item => {\n action.mergeWith(\n setExpandSGroup(editor.render.ctab, item.relatedSGroupId, {\n expanded: !expandData\n })\n )\n })\n editor.update(action)\n setShowSGroupMenu(false)\n setTargetItems([])\n }\n\n const handleRemove = function () {\n const editor = getKetcherInstance().editor as any\n const action = new Action()\n targetItems?.forEach(item => {\n action.mergeWith(\n fromSgroupDeletion(editor.render.ctab, item.relatedSGroupId)\n )\n })\n editor.update(action)\n setShowSGroupMenu(false)\n setTargetItems([])\n }\n\n const [showSGroupMenu, setShowSGroupMenu] = useState(false)\n const [targetItems, setTargetItems] = useState([] as Array)\n\n function showMenu(e) {\n const editor = getKetcherInstance().editor as any\n const struct = editor.struct()\n const selection = editor.selection()\n setShowSGroupMenu(false)\n setTargetItems([])\n const selectedItems = [] as Array\n let fgId\n\n const ci = editor.findItem(\n {\n pageX: e.detail.position.x,\n pageY: e.detail.position.y\n },\n ['sgroups', 'functionalGroups', 'atoms', 'bonds']\n )\n if (ci) {\n switch (ci.map) {\n case 'atoms':\n fgId = FunctionalGroup.findFunctionalGroupByAtom(\n struct.functionalGroups,\n ci.id\n )\n fgId !== null &&\n struct.functionalGroups.forEach(fg => {\n fg.relatedSGroupId === fgId &&\n !selectedItems.includes(fg) &&\n selectedItems.push(fg)\n })\n break\n case 'bonds':\n fgId = FunctionalGroup.findFunctionalGroupByBond(\n struct,\n struct.functionalGroups,\n ci.id\n )\n fgId !== null &&\n struct.functionalGroups.forEach(fg => {\n fg.relatedSGroupId === fgId &&\n !selectedItems.includes(fg) &&\n selectedItems.push(fg)\n })\n break\n case 'sgroups':\n const sgroup = struct.sgroups.get(ci.id)\n if (FunctionalGroup.isFunctionalGroup(sgroup)) {\n struct.functionalGroups.forEach(fg => {\n fg.relatedSGroupId === sgroup?.id &&\n !selectedItems.includes(fg) &&\n selectedItems.push(fg)\n })\n }\n break\n case 'functionalGroups':\n const fgroup = struct.sgroups.get(ci.id)\n if (FunctionalGroup.isFunctionalGroup(fgroup)) {\n struct.functionalGroups.forEach(fg => {\n fg.relatedSGroupId === fgroup?.id &&\n !selectedItems.includes(fg) &&\n selectedItems.push(fg)\n })\n }\n break\n }\n }\n\n if (selection && selection.atoms) {\n selection.atoms.forEach(aid => {\n const fgId = FunctionalGroup.findFunctionalGroupByAtom(\n struct.functionalGroups,\n aid\n )\n fgId !== null &&\n struct.functionalGroups.forEach(fg => {\n fg.relatedSGroupId === fgId &&\n !selectedItems.includes(fg) &&\n selectedItems.push(fg)\n })\n })\n }\n if (selectedItems.length) {\n setTargetItems(selectedItems)\n setShowSGroupMenu(true)\n }\n }\n\n return (\n showMenu(e)}\n className={clsx({\n [classes.isHidden]: !showSGroupMenu\n })}\n >\n \n {targetItems.length && targetItems[0].isExpanded\n ? 'Contract '\n : 'Expand '}\n Abbreviation\n \n \n Remove Abbreviation\n \n )\n}\n\nexport { FGContextMenu }\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Component, createRef } from 'react'\n\nimport Editor from '../../../../editor'\nimport Spinner from '../Spinner'\nimport classes from './StructEditor.module.less'\nimport clsx from 'clsx'\nimport { upperFirst } from 'lodash/fp'\nimport { FGContextMenu } from '../../../component/ContextMenu/ContextMenu'\nimport { ContextMenuTrigger, hideMenu } from 'react-contextmenu'\n\n//TODO: need to update component after making refactoring of store\nfunction setupEditor(editor, props, oldProps = {}) {\n const { struct, tool, toolOpts, options } = props\n\n if (struct !== oldProps.struct) editor.struct(struct)\n\n if (tool !== oldProps.tool || toolOpts !== oldProps.toolOpts) {\n editor.tool(tool, toolOpts)\n if (toolOpts !== oldProps.toolOpts) {\n editor.event.message.dispatch({ info: JSON.stringify(toolOpts) })\n }\n }\n\n if (oldProps.options && options !== oldProps.options) editor.options(options)\n\n Object.keys(editor.event).forEach(name => {\n const eventName = `on${upperFirst(name)}`\n\n if (props[eventName] !== oldProps[eventName]) {\n if (oldProps[eventName]) editor.event[name].remove(oldProps[eventName])\n\n if (props[eventName]) editor.event[name].add(props[eventName])\n }\n })\n}\n\nfunction removeEditorHandlers(editor, props) {\n Object.keys(editor.event).forEach(name => {\n const eventName = `on${upperFirst(name)}`\n\n if (props[eventName]) editor.event[name].remove(props[eventName])\n })\n}\n\nclass StructEditor extends Component {\n constructor(props) {\n super(props)\n this.editorRef = createRef()\n this.logRef = createRef()\n }\n\n shouldComponentUpdate(nextProps) {\n return this.props.indigoVerification !== nextProps.indigoVerification\n }\n\n UNSAFE_componentWillReceiveProps(props) {\n setupEditor(this.editor, props, this.props)\n }\n\n componentDidMount() {\n this.editor = new Editor(this.editorRef.current, {\n ...this.props.options\n })\n setupEditor(this.editor, this.props)\n if (this.props.onInit) this.props.onInit(this.editor)\n\n this.editor.event.message.add(msg => {\n const el = this.logRef.current\n if (msg.info) {\n try {\n const parsedInfo = JSON.parse(msg.info)\n el.innerHTML = `Atom Id: ${parsedInfo.atomid}, Bond Id: ${parsedInfo.bondid}`\n } catch {\n el.innerHTML = msg.info\n }\n el.classList.add(classes.visible)\n } else {\n el.classList.remove(classes.visible)\n }\n })\n\n this.editor.event.message.dispatch({\n info: JSON.stringify(this.props.toolOpts)\n })\n }\n\n componentWillUnmount() {\n removeEditorHandlers(this.editor, this.props)\n }\n\n render() {\n const {\n Tag = 'div',\n struct,\n tool,\n toolOpts,\n options,\n onInit,\n onSelectionChange,\n onElementEdit,\n onEnhancedStereoEdit,\n onQuickEdit,\n onBondEdit,\n onRgroupEdit,\n onSgroupEdit,\n onSdataEdit,\n onRemoveFG,\n onMessage,\n onAromatizeStruct,\n onDearomatizeStruct,\n onAttachEdit,\n indigoVerification,\n onCipChange,\n className,\n ...props\n } = this.props\n\n return (\n event.preventDefault()}\n {...props}\n >\n \n event.preventDefault()}\n >\n {/* svg here */}\n
\n
\n {indigoVerification && (\n
\n \n
\n )}\n \n \n \n )\n }\n}\n\nexport default StructEditor\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Dialog } from '../../../../components'\nimport Logo from './logo.svg'\nimport classes from './About.module.less'\nimport { connect } from 'react-redux'\n\nfunction AboutDialog(props) {\n const indigoInfo = props.indigoVersion && props.indigoVersion.split('.r') // Indigo version and build info\n\n return (\n \n \n \n \n
\n
\n \n Ketcher\n \n
\n
\n version\n {props.version}\n
\n
\n build at \n
\n {props.indigoVersion ? (\n
\n
\n \n Indigo Toolkit\n \n
\n
\n version\n {indigoInfo[0]}\n
\n
\n build #{indigoInfo[1]}\n
\n
\n ) : (\n
standalone
\n )}\n
\n \n EPAM Life Sciences\n \n
\n
\n \n Feedback\n \n
\n
\n \n )\n}\n\nconst mapStateToProps = state => ({ ...state.options.app })\n\nconst About = connect(mapStateToProps)(AboutDialog)\n\nexport default About\n","/****************************************************************************\n * Copyright 2021 EPAM Systems\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ***************************************************************************/\n\nimport { Component } from 'react'\n\nimport { omit } from 'lodash/fp'\nimport classes from './input.module.less'\n\nfunction GenericInput({\n schema,\n value = '',\n onChange,\n type = 'text',\n ...props\n}) {\n return (\n \n )\n}\n\nGenericInput.val = function (ev, schema) {\n const input = ev.target\n const isNumber =\n input.type === 'number' ||\n input.type === 'range' ||\n (schema && (schema.type === 'number' || schema.type === 'integer'))\n const value = isNumber ? input.value.replace(/,/g, '.') : input.value\n\n return isNumber && !isNaN(value - 0) ? value - 0 : value // eslint-disable-line\n}\n\nfunction TextArea({ schema, value, onChange, ...rest }) {\n return