aldehyde 0.2.98 → 0.2.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/bundle.021f784b1c84781461d2.js +1 -0
- package/dist/bundle.03c542ca824e205fe307.js +2 -0
- package/dist/bundle.03c542ca824e205fe307.js.LICENSE.txt +27 -0
- package/dist/bundle.03c542ca824e205fe307.js.gz +0 -0
- package/dist/bundle.15cb660c34802f6cccf5.js +1 -0
- package/dist/bundle.15cb660c34802f6cccf5.js.gz +0 -0
- package/dist/bundle.2f9c2d692fe0277a37aa.js +2 -0
- package/dist/bundle.2f9c2d692fe0277a37aa.js.LICENSE.txt +1 -0
- package/dist/bundle.2f9c2d692fe0277a37aa.js.gz +0 -0
- package/dist/bundle.320c02187dd135005102.js +2 -0
- package/dist/bundle.320c02187dd135005102.js.LICENSE.txt +6 -0
- package/dist/bundle.320c02187dd135005102.js.gz +0 -0
- package/dist/bundle.35a4af7e2d0da1942d79.js +10 -0
- package/dist/bundle.35a4af7e2d0da1942d79.js.gz +0 -0
- package/dist/bundle.3f9072b1629cdb384b46.js +2 -0
- package/dist/bundle.3f9072b1629cdb384b46.js.LICENSE.txt +5 -0
- package/dist/bundle.3f9072b1629cdb384b46.js.gz +0 -0
- package/dist/bundle.46e2295b5360a725bcd5.js +1 -0
- package/dist/bundle.46e2295b5360a725bcd5.js.gz +0 -0
- package/dist/bundle.4c3c988531c3cf360b87.js +1 -0
- package/dist/bundle.4c3c988531c3cf360b87.js.gz +0 -0
- package/dist/bundle.4df89546fd2e9d665dfb.js +2 -0
- package/dist/bundle.4df89546fd2e9d665dfb.js.LICENSE.txt +5 -0
- package/dist/bundle.4df89546fd2e9d665dfb.js.gz +0 -0
- package/dist/bundle.5a9afb9ee6cceca506fa.js +5 -0
- package/dist/bundle.5a9afb9ee6cceca506fa.js.LICENSE.txt +10 -0
- package/dist/bundle.5a9afb9ee6cceca506fa.js.gz +0 -0
- package/dist/bundle.5e6cccd06b34a0e3a2ff.js +1 -0
- package/dist/bundle.5e6cccd06b34a0e3a2ff.js.gz +0 -0
- package/dist/bundle.62c62e6aaa7f3c20761e.js +2 -0
- package/dist/bundle.62c62e6aaa7f3c20761e.js.LICENSE.txt +17 -0
- package/dist/bundle.62c62e6aaa7f3c20761e.js.gz +0 -0
- package/dist/bundle.6fd2dadd29083268c5a6.js +2 -0
- package/dist/bundle.6fd2dadd29083268c5a6.js.LICENSE.txt +17 -0
- package/dist/bundle.6fd2dadd29083268c5a6.js.gz +0 -0
- package/dist/bundle.8241d8d05e35988dd480.js +1 -0
- package/dist/bundle.8241d8d05e35988dd480.js.gz +0 -0
- package/dist/bundle.829683dfa6a98c78c58e.js +2 -0
- package/dist/bundle.829683dfa6a98c78c58e.js.LICENSE.txt +14 -0
- package/dist/bundle.829683dfa6a98c78c58e.js.gz +0 -0
- package/dist/bundle.840e28984e710e12f467.js +75 -0
- package/dist/bundle.840e28984e710e12f467.js.LICENSE.txt +8 -0
- package/dist/bundle.840e28984e710e12f467.js.gz +0 -0
- package/dist/bundle.85ce5221fe6ab1d91f7d.js +2 -0
- package/dist/bundle.85ce5221fe6ab1d91f7d.js.LICENSE.txt +1 -0
- package/dist/bundle.85ce5221fe6ab1d91f7d.js.gz +0 -0
- package/dist/bundle.9cfd99a04bde7f781c30.js +1 -0
- package/dist/bundle.9cfd99a04bde7f781c30.js.gz +0 -0
- package/dist/bundle.a049dc8814bbbf59160f.js +1 -0
- package/dist/bundle.a049dc8814bbbf59160f.js.gz +0 -0
- package/dist/bundle.a94f7811fac19aa9d6a3.js +2 -0
- package/dist/bundle.a94f7811fac19aa9d6a3.js.LICENSE.txt +1 -0
- package/dist/bundle.a94f7811fac19aa9d6a3.js.gz +0 -0
- package/dist/bundle.abdde6e82ee9f60d1bf3.js +2 -0
- package/dist/bundle.abdde6e82ee9f60d1bf3.js.LICENSE.txt +30 -0
- package/dist/bundle.abdde6e82ee9f60d1bf3.js.gz +0 -0
- package/dist/bundle.b207a66d5902f39d0c5a.js +1 -0
- package/dist/bundle.b207a66d5902f39d0c5a.js.gz +0 -0
- package/dist/bundle.b7b86a025aa95dea0e19.js +2 -0
- package/dist/bundle.b7b86a025aa95dea0e19.js.LICENSE.txt +8 -0
- package/dist/bundle.b7b86a025aa95dea0e19.js.gz +0 -0
- package/dist/bundle.b7e3eb480b649b3de67b.js +2 -0
- package/dist/bundle.b7e3eb480b649b3de67b.js.LICENSE.txt +5 -0
- package/dist/bundle.b7e3eb480b649b3de67b.js.gz +0 -0
- package/dist/bundle.c1c6028fd703ebf78c2e.js +2 -0
- package/dist/bundle.c1c6028fd703ebf78c2e.js.LICENSE.txt +5 -0
- package/dist/bundle.c1c6028fd703ebf78c2e.js.gz +0 -0
- package/dist/bundle.cd10ae07e0e0c36d0dee.js +2 -0
- package/dist/bundle.cd10ae07e0e0c36d0dee.js.LICENSE.txt +22 -0
- package/dist/bundle.cd10ae07e0e0c36d0dee.js.gz +0 -0
- package/dist/bundle.cf6a1933769c2aee4e6e.js +1 -0
- package/dist/bundle.cf6a1933769c2aee4e6e.js.gz +0 -0
- package/dist/bundle.d158d417d1d7a8acb2a1.js +1 -0
- package/dist/bundle.d158d417d1d7a8acb2a1.js.gz +0 -0
- package/dist/bundle.db40aa107272f4303ece.js +1 -0
- package/dist/bundle.db40aa107272f4303ece.js.gz +0 -0
- package/dist/bundle.ddefe6d8f235ef95d470.js +1 -0
- package/dist/bundle.ddefe6d8f235ef95d470.js.gz +0 -0
- package/dist/bundle.e02a7a16b4a6b3bb412f.js +2 -0
- package/dist/bundle.e02a7a16b4a6b3bb412f.js.LICENSE.txt +16 -0
- package/dist/bundle.e02a7a16b4a6b3bb412f.js.gz +0 -0
- package/dist/bundle.e760a70171cf0ae4567b.js +1 -0
- package/dist/bundle.e760a70171cf0ae4567b.js.gz +0 -0
- package/dist/bundle.f3ce062a620fe456c152.js +1 -0
- package/dist/bundle.f6e1c4fda58154810fe2.js +2 -0
- package/dist/bundle.f6e1c4fda58154810fe2.js.LICENSE.txt +41 -0
- package/dist/bundle.f6e1c4fda58154810fe2.js.gz +0 -0
- package/dist/bundle.fe9c09b8ace9c3117b0a.js +1 -0
- package/dist/bundle.fe9c09b8ace9c3117b0a.js.gz +0 -0
- package/dist/bundle.feaa17bec2057a4ee54f.js +1 -0
- package/dist/bundle.feaa17bec2057a4ee54f.js.gz +0 -0
- package/dist/css/chemstruc-graph-6437e59640f8b99b774f.css +12 -0
- package/dist/css/chemstruc-graph-6437e59640f8b99b774f.css.gz +0 -0
- package/dist/css/common-901df6b21f13391f2a53.css +56 -0
- package/dist/css/html-editor-draft-5e8e152675ab7d201c00.css +886 -0
- package/dist/css/html-editor-draft-5e8e152675ab7d201c00.css.gz +0 -0
- package/dist/css/main-f3c8fdebab315e61e7be.css +865 -0
- package/dist/css/main-f3c8fdebab315e61e7be.css.gz +0 -0
- package/dist/images/development-30de07a0.png +0 -0
- package/dist/images/logo-54b328b7.png +0 -0
- package/dist/images/pain-point-8f02421e.png +0 -0
- package/dist/images/target-13a5b4b9.png +0 -0
- package/dist/images/time-cost-cb40d2c2.png +0 -0
- package/dist/images/time-prograss-44b86b36.png +0 -0
- package/dist/index.html +4 -0
- package/lib/controls/action/index.d.ts +16 -7
- package/lib/controls/action/index.d.ts.map +1 -1
- package/lib/controls/action/index.js +64 -48
- package/lib/controls/action/index.js.map +1 -1
- package/lib/controls/action/utils.d.ts +1 -1
- package/lib/controls/action/utils.d.ts.map +1 -1
- package/lib/controls/action/utils.js +6 -4
- package/lib/controls/action/utils.js.map +1 -1
- package/lib/controls/auto-complete/index.d.ts +1 -1
- package/lib/controls/auto-complete/index.d.ts.map +1 -1
- package/lib/controls/auto-complete/index.js +12 -6
- package/lib/controls/auto-complete/index.js.map +1 -1
- package/lib/controls/chemstruc/graph.d.ts +13 -4
- package/lib/controls/chemstruc/graph.d.ts.map +1 -1
- package/lib/controls/chemstruc/graph.js +40 -27
- package/lib/controls/chemstruc/graph.js.map +1 -1
- package/lib/controls/collapse-card/index.d.ts +11 -2
- package/lib/controls/collapse-card/index.d.ts.map +1 -1
- package/lib/controls/collapse-card/index.js +18 -16
- package/lib/controls/collapse-card/index.js.map +1 -1
- package/lib/controls/color-picker/index.d.ts +11 -2
- package/lib/controls/color-picker/index.d.ts.map +1 -1
- package/lib/controls/color-picker/index.js +23 -19
- package/lib/controls/color-picker/index.js.map +1 -1
- package/lib/controls/cquery/cquick-button.d.ts +11 -2
- package/lib/controls/cquery/cquick-button.d.ts.map +1 -1
- package/lib/controls/cquery/cquick-button.js +30 -28
- package/lib/controls/cquery/cquick-button.js.map +1 -1
- package/lib/controls/entity-select/entity-select.d.ts +12 -3
- package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.js +67 -66
- package/lib/controls/entity-select/entity-select.js.map +1 -1
- package/lib/controls/entity-select/lab-tree-select.d.ts +11 -2
- package/lib/controls/entity-select/lab-tree-select.d.ts.map +1 -1
- package/lib/controls/entity-select/lab-tree-select.js +26 -21
- package/lib/controls/entity-select/lab-tree-select.js.map +1 -1
- package/lib/controls/entity-select/popover-entity-select.d.ts +11 -2
- package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/popover-entity-select.js +30 -26
- package/lib/controls/entity-select/popover-entity-select.js.map +1 -1
- package/lib/controls/entry-control.d.ts +1 -1
- package/lib/controls/entry-control.d.ts.map +1 -1
- package/lib/controls/entry-control.js +153 -98
- package/lib/controls/entry-control.js.map +1 -1
- package/lib/controls/html-editor/tinymce.d.ts.map +1 -1
- package/lib/controls/input-number/index.d.ts +1 -1
- package/lib/controls/input-number/index.d.ts.map +1 -1
- package/lib/controls/input-number/index.js +31 -23
- package/lib/controls/input-number/index.js.map +1 -1
- package/lib/controls/input-range/index.d.ts +1 -1
- package/lib/controls/input-range/index.d.ts.map +1 -1
- package/lib/controls/input-range/index.js +9 -8
- package/lib/controls/input-range/index.js.map +1 -1
- package/lib/controls/password-setter/index.d.ts +9 -3
- package/lib/controls/password-setter/index.d.ts.map +1 -1
- package/lib/controls/password-setter/index.js +22 -14
- package/lib/controls/password-setter/index.js.map +1 -1
- package/lib/controls/progress/index.d.ts +1 -1
- package/lib/controls/progress/index.d.ts.map +1 -1
- package/lib/controls/progress/index.js +13 -6
- package/lib/controls/progress/index.js.map +1 -1
- package/lib/controls/relation-existion/index.d.ts +11 -2
- package/lib/controls/relation-existion/index.d.ts.map +1 -1
- package/lib/controls/relation-existion/index.js +30 -18
- package/lib/controls/relation-existion/index.js.map +1 -1
- package/lib/controls/rfield/index.d.ts +11 -2
- package/lib/controls/rfield/index.d.ts.map +1 -1
- package/lib/controls/rfield/index.js +33 -35
- package/lib/controls/rfield/index.js.map +1 -1
- package/lib/controls/signature/index.d.ts +10 -1
- package/lib/controls/signature/index.d.ts.map +1 -1
- package/lib/controls/signature/index.js +56 -31
- package/lib/controls/signature/index.js.map +1 -1
- package/lib/controls/steps/index.d.ts +1 -1
- package/lib/controls/steps/index.d.ts.map +1 -1
- package/lib/controls/steps/index.js +8 -6
- package/lib/controls/steps/index.js.map +1 -1
- package/lib/controls/text/ellipsis-text.d.ts +9 -0
- package/lib/controls/text/ellipsis-text.d.ts.map +1 -1
- package/lib/controls/text/ellipsis-text.js +13 -11
- package/lib/controls/text/ellipsis-text.js.map +1 -1
- package/lib/controls/upload/index.d.ts +10 -1
- package/lib/controls/upload/index.d.ts.map +1 -1
- package/lib/controls/upload/index.js +30 -21
- package/lib/controls/upload/index.js.map +1 -1
- package/lib/controls/view-control.d.ts +1 -1
- package/lib/controls/view-control.d.ts.map +1 -1
- package/lib/controls/view-control.js +118 -85
- package/lib/controls/view-control.js.map +1 -1
- package/lib/custom-page/def-custom-page.d.ts +5 -6
- package/lib/custom-page/def-custom-page.d.ts.map +1 -1
- package/lib/custom-page/def-custom-page.js +13 -12
- package/lib/custom-page/def-custom-page.js.map +1 -1
- package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts +10 -1
- package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts.map +1 -1
- package/lib/custom-page/dtmpl-custom-edit-modal-page.js +19 -7
- package/lib/custom-page/dtmpl-custom-edit-modal-page.js.map +1 -1
- package/lib/detail/button/bottom-submit-button-bar.d.ts +11 -2
- package/lib/detail/button/bottom-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/button/bottom-submit-button-bar.js +20 -12
- package/lib/detail/button/bottom-submit-button-bar.js.map +1 -1
- package/lib/detail/button/cquery-button-bar.d.ts +12 -3
- package/lib/detail/button/cquery-button-bar.d.ts.map +1 -1
- package/lib/detail/button/cquery-button-bar.js +22 -18
- package/lib/detail/button/cquery-button-bar.js.map +1 -1
- package/lib/detail/button/fix-right-submit-button-bar.d.ts +11 -2
- package/lib/detail/button/fix-right-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/button/fix-right-submit-button-bar.js +28 -23
- package/lib/detail/button/fix-right-submit-button-bar.js.map +1 -1
- package/lib/detail/edit/fields-edit-card.d.ts +11 -2
- package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/fields-edit-card.js +18 -19
- package/lib/detail/edit/fields-edit-card.js.map +1 -1
- package/lib/detail/edit/modal-row-edit.d.ts +11 -2
- package/lib/detail/edit/modal-row-edit.d.ts.map +1 -1
- package/lib/detail/edit/modal-row-edit.js +14 -11
- package/lib/detail/edit/modal-row-edit.js.map +1 -1
- package/lib/detail/edit/post-result/index.d.ts +1 -1
- package/lib/detail/edit/post-result/index.d.ts.map +1 -1
- package/lib/detail/edit/post-result/index.js +17 -12
- package/lib/detail/edit/post-result/index.js.map +1 -1
- package/lib/detail/edit/row-edit-card.d.ts +11 -2
- package/lib/detail/edit/row-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/row-edit-card.js +23 -23
- package/lib/detail/edit/row-edit-card.js.map +1 -1
- package/lib/detail/rightbar/index.d.ts +12 -3
- package/lib/detail/rightbar/index.d.ts.map +1 -1
- package/lib/detail/rightbar/index.js +16 -9
- package/lib/detail/rightbar/index.js.map +1 -1
- package/lib/detail/view/act-dtmpl-view.d.ts +11 -2
- package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/act-dtmpl-view.js +26 -25
- package/lib/detail/view/act-dtmpl-view.js.map +1 -1
- package/lib/detail/view/dtmpl-view.d.ts +2 -2
- package/lib/detail/view/dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/dtmpl-view.js +40 -40
- package/lib/detail/view/dtmpl-view.js.map +1 -1
- package/lib/detail/view/field-view-group.d.ts +10 -1
- package/lib/detail/view/field-view-group.d.ts.map +1 -1
- package/lib/detail/view/field-view-group.js +17 -11
- package/lib/detail/view/field-view-group.js.map +1 -1
- package/lib/detail/view/modal-dtmpl-view.d.ts +10 -1
- package/lib/detail/view/modal-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/modal-dtmpl-view.js +11 -8
- package/lib/detail/view/modal-dtmpl-view.js.map +1 -1
- package/lib/detail/view/snapshot-timeline.d.ts +11 -2
- package/lib/detail/view/snapshot-timeline.d.ts.map +1 -1
- package/lib/detail/view/snapshot-timeline.js +18 -16
- package/lib/detail/view/snapshot-timeline.js.map +1 -1
- package/lib/exportor/export-frame.d.ts +11 -2
- package/lib/exportor/export-frame.d.ts.map +1 -1
- package/lib/exportor/export-frame.js +41 -42
- package/lib/exportor/export-frame.js.map +1 -1
- package/lib/form/criteria-form.d.ts +2 -2
- package/lib/form/criteria-form.d.ts.map +1 -1
- package/lib/form/criteria-form.js +58 -45
- package/lib/form/criteria-form.js.map +1 -1
- package/lib/form/dtmpl-form.d.ts +11 -2
- package/lib/form/dtmpl-form.d.ts.map +1 -1
- package/lib/form/dtmpl-form.js +77 -65
- package/lib/form/dtmpl-form.js.map +1 -1
- package/lib/form/field-group-form.d.ts +12 -3
- package/lib/form/field-group-form.d.ts.map +1 -1
- package/lib/form/field-group-form.js +26 -18
- package/lib/form/field-group-form.js.map +1 -1
- package/lib/form/form-Item-group.d.ts +10 -1
- package/lib/form/form-Item-group.d.ts.map +1 -1
- package/lib/form/form-Item-group.js +43 -26
- package/lib/form/form-Item-group.js.map +1 -1
- package/lib/import/excel-import.d.ts +12 -3
- package/lib/import/excel-import.d.ts.map +1 -1
- package/lib/import/excel-import.js +69 -55
- package/lib/import/excel-import.js.map +1 -1
- package/lib/index.d.ts +42 -39
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +43 -39
- package/lib/index.js.map +1 -1
- package/lib/layout/MainPage.d.ts +1 -1
- package/lib/layout/MainPage.d.ts.map +1 -1
- package/lib/layout/MainPage.js +47 -37
- package/lib/layout/MainPage.js.map +1 -1
- package/lib/layout/footer/index.d.ts.map +1 -1
- package/lib/layout/header/index.d.ts +1 -1
- package/lib/layout/header/index.d.ts.map +1 -1
- package/lib/layout/header/index.js +15 -13
- package/lib/layout/header/index.js.map +1 -1
- package/lib/layout/menu/block.d.ts +13 -1
- package/lib/layout/menu/block.d.ts.map +1 -1
- package/lib/layout/menu/block.js +66 -8
- package/lib/layout/menu/block.js.map +1 -1
- package/lib/layout/menu/l2menu-quick-bar.d.ts +11 -2
- package/lib/layout/menu/l2menu-quick-bar.d.ts.map +1 -1
- package/lib/layout/menu/l2menu-quick-bar.js +24 -19
- package/lib/layout/menu/l2menu-quick-bar.js.map +1 -1
- package/lib/layout/menu/menu-2layers.d.ts +10 -0
- package/lib/layout/menu/menu-2layers.d.ts.map +1 -1
- package/lib/layout/menu/menu-2layers.js +32 -9
- package/lib/layout/menu/menu-2layers.js.map +1 -1
- package/lib/layout/menu/reset-password.d.ts +12 -3
- package/lib/layout/menu/reset-password.d.ts.map +1 -1
- package/lib/layout/menu/reset-password.js +52 -36
- package/lib/layout/menu/reset-password.js.map +1 -1
- package/lib/layout/menu/user-bar.d.ts +12 -3
- package/lib/layout/menu/user-bar.d.ts.map +1 -1
- package/lib/layout/menu/user-bar.js +72 -42
- package/lib/layout/menu/user-bar.js.map +1 -1
- package/lib/layout/menu/userinfo-bar.d.ts +10 -1
- package/lib/layout/menu/userinfo-bar.d.ts.map +1 -1
- package/lib/layout/menu/userinfo-bar.js +11 -10
- package/lib/layout/menu/userinfo-bar.js.map +1 -1
- package/lib/layout/sidebar/index.css +15 -4
- package/lib/layout/sidebar/index.d.ts +2 -2
- package/lib/layout/sidebar/index.d.ts.map +1 -1
- package/lib/layout/sidebar/index.js +21 -13
- package/lib/layout/sidebar/index.js.map +1 -1
- package/lib/locale/LocaleButton.d.ts +4 -0
- package/lib/locale/LocaleButton.d.ts.map +1 -0
- package/lib/locale/LocaleButton.js +24 -0
- package/lib/locale/LocaleButton.js.map +1 -0
- package/lib/locale/LocaleProvider.d.ts +13 -0
- package/lib/locale/LocaleProvider.d.ts.map +1 -0
- package/lib/locale/LocaleProvider.js +137 -0
- package/lib/locale/LocaleProvider.js.map +1 -0
- package/lib/locale/langMp.d.ts +16 -0
- package/lib/locale/langMp.d.ts.map +1 -0
- package/lib/locale/langMp.js +29 -0
- package/lib/locale/langMp.js.map +1 -0
- package/lib/locale/translate.d.ts +3 -0
- package/lib/locale/translate.d.ts.map +1 -0
- package/lib/locale/translate.js +76 -0
- package/lib/locale/translate.js.map +1 -0
- package/lib/locale/useLocale.d.ts +14 -0
- package/lib/locale/useLocale.d.ts.map +1 -0
- package/lib/locale/useLocale.js +34 -0
- package/lib/locale/useLocale.js.map +1 -0
- package/lib/login/login.d.ts +13 -3
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +38 -25
- package/lib/login/login.js.map +1 -1
- package/lib/login/router-login.d.ts +2 -2
- package/lib/login/router-login.d.ts.map +1 -1
- package/lib/login/router-login.js +33 -19
- package/lib/login/router-login.js.map +1 -1
- package/lib/module/dtmpl-edit-card.d.ts +11 -2
- package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-card.js +22 -14
- package/lib/module/dtmpl-edit-card.js.map +1 -1
- package/lib/module/dtmpl-edit-page.d.ts +12 -3
- package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-page.js +42 -31
- package/lib/module/dtmpl-edit-page.js.map +1 -1
- package/lib/module/ltmpl-modal.d.ts +10 -1
- package/lib/module/ltmpl-modal.d.ts.map +1 -1
- package/lib/module/ltmpl-modal.js +15 -8
- package/lib/module/ltmpl-modal.js.map +1 -1
- package/lib/module/ltmpl-table.d.ts +11 -2
- package/lib/module/ltmpl-table.d.ts.map +1 -1
- package/lib/module/ltmpl-table.js +39 -39
- package/lib/module/ltmpl-table.js.map +1 -1
- package/lib/routable/ltmpl-route.d.ts +2 -2
- package/lib/routable/ltmpl-route.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.js +22 -21
- package/lib/routable/ltmpl-route.js.map +1 -1
- package/lib/table/act-table.d.ts +12 -3
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +269 -208
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/column/column-selector.d.ts.map +1 -1
- package/lib/table/column/column-selector.js +20 -18
- package/lib/table/column/column-selector.js.map +1 -1
- package/lib/table/control-table-x-axis-wrapper.d.ts +5 -0
- package/lib/table/control-table-x-axis-wrapper.d.ts.map +1 -0
- package/lib/table/control-table-x-axis-wrapper.js +60 -0
- package/lib/table/control-table-x-axis-wrapper.js.map +1 -0
- package/lib/table/l2-act-table.d.ts +1 -1
- package/lib/table/pagination.d.ts +11 -2
- package/lib/table/pagination.d.ts.map +1 -1
- package/lib/table/pagination.js +13 -12
- package/lib/table/pagination.js.map +1 -1
- package/lib/table/query-table.d.ts +10 -1
- package/lib/table/query-table.d.ts.map +1 -1
- package/lib/table/query-table.js +47 -40
- package/lib/table/query-table.js.map +1 -1
- package/lib/table/relation-table.d.ts +13 -4
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/relation-table.js +118 -109
- package/lib/table/relation-table.js.map +1 -1
- package/lib/table/selected-rows-card.d.ts +10 -1
- package/lib/table/selected-rows-card.d.ts.map +1 -1
- package/lib/table/selected-rows-card.js +10 -9
- package/lib/table/selected-rows-card.js.map +1 -1
- package/lib/table/stat/restat.d.ts +10 -1
- package/lib/table/stat/restat.d.ts.map +1 -1
- package/lib/table/stat/restat.js +10 -9
- package/lib/table/stat/restat.js.map +1 -1
- package/lib/tmpl/hc-data-source.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.js +21 -14
- package/lib/tmpl/hc-data-source.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts +2 -0
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js +127 -100
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/model-struc-v3.d.ts.map +1 -1
- package/lib/tmpl/model-struc-v3.js +19 -18
- package/lib/tmpl/model-struc-v3.js.map +1 -1
- package/lib/tmpl/superagent.d.ts +2 -2
- package/lib/tmpl/superagent.d.ts.map +1 -1
- package/lib/tmpl/superagent.js +28 -23
- package/lib/tmpl/superagent.js.map +1 -1
- package/lib/tree/act-tree.d.ts +10 -1
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/act-tree.js +26 -20
- package/lib/tree/act-tree.js.map +1 -1
- package/lib/tree/tmpl-tree.d.ts +11 -2
- package/lib/tree/tmpl-tree.d.ts.map +1 -1
- package/lib/tree/tmpl-tree.js +85 -64
- package/lib/tree/tmpl-tree.js.map +1 -1
- package/lib/tree/tree-node.d.ts.map +1 -1
- package/lib/tree/tree-node.js.map +1 -1
- package/lib/units/index.d.ts.map +1 -1
- package/lib/welcome/HCWelcome.js +7 -23
- package/lib/welcome/HCWelcome.js.map +1 -1
- package/lib/welcome/HCWelcome1.d.ts +4 -0
- package/lib/welcome/HCWelcome1.d.ts.map +1 -0
- package/lib/welcome/HCWelcome1.js +192 -0
- package/lib/welcome/HCWelcome1.js.map +1 -0
- package/lib/welcome/quick-entrance.d.ts +12 -3
- package/lib/welcome/quick-entrance.d.ts.map +1 -1
- package/lib/welcome/quick-entrance.js +21 -17
- package/lib/welcome/quick-entrance.js.map +1 -1
- package/lib/welcome/workbench.d.ts +12 -3
- package/lib/welcome/workbench.d.ts.map +1 -1
- package/lib/welcome/workbench.js +23 -19
- package/lib/welcome/workbench.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/action/index.tsx +329 -221
- package/src/aldehyde/controls/action/utils.tsx +6 -4
- package/src/aldehyde/controls/auto-complete/index.tsx +64 -60
- package/src/aldehyde/controls/chemstruc/graph.tsx +175 -139
- package/src/aldehyde/controls/collapse-card/index.tsx +96 -54
- package/src/aldehyde/controls/color-picker/index.tsx +107 -78
- package/src/aldehyde/controls/cquery/cquick-button.tsx +129 -89
- package/src/aldehyde/controls/entity-select/entity-select.tsx +643 -523
- package/src/aldehyde/controls/entity-select/lab-tree-select.tsx +140 -131
- package/src/aldehyde/controls/entity-select/popover-entity-select.tsx +178 -133
- package/src/aldehyde/controls/entry-control.tsx +374 -248
- package/src/aldehyde/controls/input-number/index.tsx +131 -86
- package/src/aldehyde/controls/input-range/index.tsx +51 -40
- package/src/aldehyde/controls/password-setter/index.js +81 -63
- package/src/aldehyde/controls/progress/index.tsx +59 -46
- package/src/aldehyde/controls/relation-existion/index.tsx +125 -87
- package/src/aldehyde/controls/rfield/index.tsx +178 -151
- package/src/aldehyde/controls/signature/index.tsx +215 -151
- package/src/aldehyde/controls/steps/index.tsx +44 -42
- package/src/aldehyde/controls/text/ellipsis-text.tsx +79 -53
- package/src/aldehyde/controls/upload/index.tsx +125 -109
- package/src/aldehyde/controls/view-control.tsx +250 -188
- package/src/aldehyde/custom-page/def-custom-page.tsx +17 -0
- package/src/aldehyde/custom-page/dtmpl-custom-edit-modal-page.tsx +75 -66
- package/src/aldehyde/detail/button/bottom-submit-button-bar.tsx +79 -43
- package/src/aldehyde/detail/button/cquery-button-bar.tsx +129 -98
- package/src/aldehyde/detail/button/fix-right-submit-button-bar.tsx +161 -113
- package/src/aldehyde/detail/edit/fields-edit-card.tsx +124 -87
- package/src/aldehyde/detail/edit/modal-row-edit.tsx +81 -60
- package/src/aldehyde/detail/edit/post-result/index.tsx +80 -47
- package/src/aldehyde/detail/edit/row-edit-card.tsx +158 -107
- package/src/aldehyde/detail/rightbar/index.tsx +79 -63
- package/src/aldehyde/detail/view/act-dtmpl-view.tsx +177 -124
- package/src/aldehyde/detail/view/dtmpl-view.tsx +284 -178
- package/src/aldehyde/detail/view/field-view-group.tsx +62 -47
- package/src/aldehyde/detail/view/modal-dtmpl-view.tsx +67 -54
- package/src/aldehyde/detail/view/snapshot-timeline.tsx +143 -110
- package/src/aldehyde/exportor/export-frame.tsx +258 -200
- package/src/aldehyde/form/criteria-form.tsx +309 -201
- package/src/aldehyde/form/dtmpl-form.tsx +460 -307
- package/src/aldehyde/form/field-group-form.tsx +87 -66
- package/src/aldehyde/form/form-Item-group.tsx +190 -132
- package/src/aldehyde/import/excel-import.tsx +414 -331
- package/src/aldehyde/index.tsx +90 -45
- package/src/aldehyde/layout/MainPage.tsx +280 -245
- package/src/aldehyde/layout/header/index.tsx +59 -53
- package/src/aldehyde/layout/menu/block.less +11 -0
- package/src/aldehyde/layout/menu/block.tsx +132 -72
- package/src/aldehyde/layout/menu/l2menu-quick-bar.tsx +137 -118
- package/src/aldehyde/layout/menu/menu-2layers.tsx +99 -64
- package/src/aldehyde/layout/menu/reset-password.tsx +213 -162
- package/src/aldehyde/layout/menu/user-bar.tsx +216 -147
- package/src/aldehyde/layout/menu/userinfo-bar.tsx +58 -41
- package/src/aldehyde/layout/sidebar/index.css +15 -4
- package/src/aldehyde/layout/sidebar/index.tsx +70 -38
- package/src/aldehyde/locale/LocaleButton.tsx +31 -0
- package/src/aldehyde/locale/LocaleProvider.tsx +166 -0
- package/src/aldehyde/locale/langMp.ts +33 -0
- package/src/aldehyde/locale/translate.ts +81 -0
- package/src/aldehyde/locale/useLocale.ts +50 -0
- package/src/aldehyde/login/login.tsx +192 -141
- package/src/aldehyde/login/router-login.tsx +54 -21
- package/src/aldehyde/module/dtmpl-edit-card.tsx +225 -160
- package/src/aldehyde/module/dtmpl-edit-page.tsx +334 -212
- package/src/aldehyde/module/ltmpl-modal.tsx +57 -53
- package/src/aldehyde/module/ltmpl-table.tsx +329 -240
- package/src/aldehyde/routable/ltmpl-route.tsx +220 -196
- package/src/aldehyde/table/act-table.tsx +1244 -795
- package/src/aldehyde/table/column/column-selector.tsx +111 -72
- package/src/aldehyde/table/control-table-x-axis-wrapper.tsx +52 -0
- package/src/aldehyde/table/pagination.tsx +66 -59
- package/src/aldehyde/table/query-table.tsx +354 -303
- package/src/aldehyde/table/relation-table.tsx +781 -571
- package/src/aldehyde/table/selected-rows-card.tsx +61 -48
- package/src/aldehyde/table/stat/restat.tsx +112 -69
- package/src/aldehyde/tmpl/hc-data-source.tsx +381 -296
- package/src/aldehyde/tmpl/hcservice-v3.tsx +991 -796
- package/src/aldehyde/tmpl/model-struc-v3.tsx +95 -91
- package/src/aldehyde/tmpl/superagent.js +148 -142
- package/src/aldehyde/tree/act-tree.tsx +206 -138
- package/src/aldehyde/tree/tmpl-tree.tsx +627 -353
- package/src/aldehyde/tree/tree-node.tsx +0 -3
- package/src/aldehyde/welcome/HCWelcome.js +78 -110
- package/src/aldehyde/welcome/HCWelcome1.js +260 -0
- package/src/aldehyde/welcome/quick-entrance.tsx +82 -71
- package/src/aldehyde/welcome/workbench.tsx +83 -68
- package/src/aldehyde/custom-page/def-custom-page.js +0 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkaldehyde=self.webpackChunkaldehyde||[]).push([[16],{1016:function(e,t,r){r.d(t,{v:function(){return wu}});var n=r(2543),i=r(88864);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(e,"prototype",{value:Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),writable:!1}),t&&u(e,t)}function f(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function m(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||m(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},y.apply(this,arguments)},_={lines:12,length:7,width:5,radius:10,scale:1,corners:1,color:"#000",fadeColor:"transparent",animation:"spinner-line-fade-default",rotate:0,direction:1,speed:1,zIndex:2e9,className:"spinner",top:"50%",left:"50%",shadow:"0 0 1px transparent",position:"absolute"},g=function(){function e(e){void 0===e&&(e={}),this.opts=y(y({},_),e)}return e.prototype.spin=function(e){return this.stop(),this.el=document.createElement("div"),this.el.className=this.opts.className,this.el.setAttribute("role","progressbar"),x(this.el,{position:this.opts.position,width:0,zIndex:this.opts.zIndex,left:this.opts.left,top:this.opts.top,transform:"scale("+this.opts.scale+")"}),e&&e.insertBefore(this.el,e.firstChild||null),function(e,t){var r=Math.round(t.corners*t.width*500)/1e3+"px",n="none";!0===t.shadow?n="0 2px 4px #000":"string"==typeof t.shadow&&(n=t.shadow);for(var i=function(e){for(var t=/^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/,r=[],n=0,i=e.split(",");n<i.length;n++){var o=i[n].match(t);if(null!==o){var s=+o[2],a=+o[5],l=o[4],c=o[7];0!==s||l||(l=c),0!==a||c||(c=l),l===c&&r.push({prefix:o[1]||"",x:s,y:a,xUnits:l,yUnits:c,end:o[8]})}}return r}(n),o=0;o<t.lines;o++){var s=~~(360/t.lines*o+t.rotate),a=x(document.createElement("div"),{position:"absolute",top:-t.width/2+"px",width:t.length+t.width+"px",height:t.width+"px",background:b(t.fadeColor,o),borderRadius:r,transformOrigin:"left",transform:"rotate("+s+"deg) translateX("+t.radius+"px)"}),l=o*t.direction/t.lines/t.speed;l-=1/t.speed;var c=x(document.createElement("div"),{width:"100%",height:"100%",background:b(t.color,o),borderRadius:r,boxShadow:w(i,s),animation:1/t.speed+"s linear "+l+"s infinite "+t.animation});a.appendChild(c),e.appendChild(a)}}(this.el,this.opts),this},e.prototype.stop=function(){return this.el&&("undefined"!=typeof requestAnimationFrame?cancelAnimationFrame(this.animateId):clearTimeout(this.animateId),this.el.parentNode&&this.el.parentNode.removeChild(this.el),this.el=void 0),this},e}();function x(e,t){for(var r in t)e.style[r]=t[r];return e}function b(e,t){return"string"==typeof e?e:e[t%e.length]}function w(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n],s=S(o.x,o.y,t);r.push(o.prefix+s[0]+o.xUnits+" "+s[1]+o.yUnits+o.end)}return r.join(", ")}function S(e,t,r){var n=r*Math.PI/180,i=Math.sin(n),o=Math.cos(n);return[Math.round(1e3*(e*o+t*i))/1e3,Math.round(1e3*(-e*i+t*o))/1e3]}var R,C=function(){function e(){s(this,e),this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}return l(e,[{key:"start",value:function(){this.startTime=e.now(),this.oldTime=this.startTime,this.running=!0}},{key:"stop",value:function(){this.getElapsedTime(),this.running=!1}},{key:"getElapsedTime",value:function(){return this.update(),this.elapsedTime}},{key:"update",value:function(){var t=0;if(this.running){var r=e.now();t=.001*(r-this.oldTime),this.oldTime=r,this.elapsedTime+=t}return t}}]),e}();C.now=(R="undefined"!=typeof window&&window.performance)&&R.now?R.now.bind(R):Date.now;var k=C.now;function A(e,t,r){var n=document.createElement(e);return n.id=t,n.style.cssText=r,n}var E=function(){function e(){s(this,e),this.domElement=A("div","stats","padding:8px"),this._text=A("p","fps","margin:0;color:silver;font-size:large"),this.domElement.appendChild(this._text),this._startTime=k(),this._prevTime=this._startTime,this._deltas=new Array(20),this._index=0,this._total=0,this._count=0}return l(e,[{key:"end",value:function(){var e=k(),t=e-this._startTime;return this._count<this._deltas.length?this._count++:this._total-=this._deltas[this._index],this._total+=t,this._deltas[this._index]=t,this._index=(this._index+1)%this._deltas.length,this.ms=this._total/this._count,this.fps=1e3/this.ms,e>this._prevTime+1e3&&(this._text.textContent=this.fps.toPrecision(2),this._prevTime=e),e}},{key:"update",value:function(){this._startTime=this.end()}},{key:"show",value:function(e){void 0===e&&(e=!0),this.domElement.style.display=e?"block":"none"}}]),e}();function P(e,t,r){return P=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&u(i,r.prototype),i},P.apply(null,arguments)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return P(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},T(e)}function M(e,t){return!e||e===t}function I(){this._handlers={}}I.prototype.addEventListener=function(e,t,r){var i=this._handlers[e];i||(this._handlers[e]=[],i=this._handlers[e]);var o=[t,r];void 0===(0,n.find)(i,(function(e){return e[0]===o[0]&&e[1]===o[1]}))&&i.push(o)},I.prototype.removeEventListener=function(e,t,r){var i=this;(0,n.forEach)(i._handlers,(function(o,s){(0,n.remove)(o,(function(n){return M(e,s)&&M(t,n[0])&&M(r,n[1]||i)}))})),this._handlers=(0,n.omitBy)(i._handlers,(function(e){return 0===e.length}))},I.prototype.dispatchEvent=function(e){var t=this;(0,n.forEach)(this._handlers[e.type],(function(r){var n=r[1]||t;r[0].apply(n,[e])}))};var N={debug:0,info:1,report:2,warn:3,error:4};function O(){I.call(this),this.console=!1,this._priority=N.warn}function L(e){if(!(0,n.isNumber)(e))throw new Error("Wrong log level specified!");return e}O.prototype=Object.create(I.prototype),O.prototype.constructor=O,O.prototype.instantiate=function(){return new O},Object.defineProperty(O.prototype,"level",{get:function(){var e=this;return(0,n.findKey)(N,(function(t){return t===e._priority}))},set:function(e){this._priority=L(N[e])}}),O.prototype.levels=function(){return Object.keys(N)},O.prototype.message=function(e,t){var r=L(N[e]);this._message(r,t)},O.prototype.debug=function(e){this._message(N.debug,e)},O.prototype.info=function(e){this._message(N.info,e)},O.prototype.report=function(e){this._message(N.report,e)},O.prototype.warn=function(e){this._message(N.warn,e)},O.prototype.error=function(e){this._message(N.error,e)},O.prototype._message=function(e,t){if(!(e<this._priority)){var r=(0,n.findKey)(N,(function(t){return t===e}));if(t=String(t),this.console){var i="miew:".concat(r,": ").concat(t);"error"===r?console.error(i):"warn"===r?console.warn(i):console.log(i)}this.dispatchEvent({type:"message",level:r,message:t})}};var B=new O;var D={DEFAULT:0,SAFARI:1};function z(e){return decodeURIComponent(e.replace(/\+/g," "))}function F(e){for(var t,r=(e=e||window.location.search).substring(e.indexOf("?")+1),n=/([^&=]+)=?([^&]*)/g,i=[];null!==(t=n.exec(r));)i.push([z(t[1]),z(t[2])]);return i}function V(e){var t=!1;this.enable=function(e){t=e};var r=0,n=Object.keys(e);function i(e,n){return function(){var i=V.spaces.substr(0,2*r);t&&B.debug("".concat(i+n," {")),r++;for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var l=e.apply(this,s);return r--,t&&B.debug("".concat(i,"} // ").concat(n)),l}}for(var o=0,s=n.length;o<s;++o){var a=n[o],l=e[a];l instanceof Function&&"constructor"!==a&&(e[a]=i(l,a))}}V.spaces=" ";var U=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return s(this,i),(t=n.call(this)).name="OutOfMemoryError",t.message=e,t}return l(i)}(T(Error));function j(e){for(var t=new Uint8Array(e),r="",n=0;n<t.byteLength;n++)r+=String.fromCharCode(t[n]);return window.btoa(r)}function G(e){for(var t=window.atob(e),r=new Uint8Array(t.length),n=0;n<r.length;++n)r[n]=t[n].charCodeAt(0);return r.buffer}function H(e){if((0,n.isPlainObject)(e))return!0;var t=e&&Object.getPrototypeOf(e);return!!t&&!t.hasOwnProperty("constructor")&&H(t)}function q(e){return e.slice(Math.max(0,e.lastIndexOf("."))||1/0)}function W(e){var t=e.split(/[:;,]/),r=t.length;return r>=3&&"base64"===t[r-2]?new Blob([G(t[r-1])]):null}var Y=/^[a-zA-Z0-9_]*$/,X=['"',"",'"'],$={browserType:D,encodeQueryComponent:function(e,t){return encodeURIComponent(e).replace(t,(function(e){return String.fromCharCode(parseInt(e.substr(1),16))})).replace(/%20/g,"+")},decodeQueryComponent:z,getUrlParameters:F,getUrlParametersAsDict:function(e){for(var t={},r=F(e),n=0;n<r.length;++n){var i=v(r[n],2),o=i[0],s=i[1];t[o]=s}return t},resolveURL:function(e){if("undefined"!=typeof URL)try{return"undefined"!=typeof window?new URL(e,window.location).href:new URL(e).href}catch(e){}if("undefined"!=typeof document){var t=document.createElement("a");return t.href=e,t.href}return e},generateRegExp:function(e){for(var t=[],r=0,n=e.length;r<n;++r)t[t.length]=e[r].charCodeAt(0).toString(16);var i=t.join("|");return new RegExp("%(?:".concat(i,")"),"gi")},createElement:function(e,t,r){var n,i,o=document.createElement(e);if(t){var s=Object.keys(t);for(n=0,i=s.length;n<i;++n){var a=s[n];o.setAttribute(a,t[a])}}if(r)for(r instanceof Array||(r=[r]),n=0,i=r.length;n<i;++n){var l=r[n];"string"==typeof l?o.appendChild(document.createTextNode(l)):l instanceof HTMLElement&&o.appendChild(l)}return o},deriveClass:function(e,t,r,i){return e.prototype=(0,n.assign)(Object.create(t.prototype),{constructor:e},r),i&&(0,n.assign)(e,i),e},deriveDeep:function e(t,r){var n,i,o=t;if(t instanceof Array)for(o=new Array(t.length),n=0,i=t.length;n<i;++n)o[n]=e(t[n]);else if(t instanceof Object){o=Object.create(t);var s=Object.keys(t);for(n=0,i=s.length;n<i;++n){var a=s[n],l=t[a],c=e(l);c!==l&&(o[a]=c)}r&&Object.keys(o).length>0&&(o=Object.create(o))}return o},hexColor:function(e){var t="0000000".concat(e.toString(16)).substr(-6);return"#".concat(t)},DebugTracer:V,OutOfMemoryError:U,allocateTyped:function(e,t){var r=null;try{r=new e(t)}catch(e){throw e instanceof RangeError?new U(e.message):e}return r},bytesFromBase64:G,bytesToBase64:j,arrayFromBase64:function(e,t){return Array.prototype.slice.call(new t(G(e)))},arrayToBase64:function(e,t){return j(new t(e).buffer)},compareOptionsWithDefaults:function(e,t){var r=[];if(t&&e){for(var n=Object.keys(e),i=0;i<n.length;++i){var o=n[i],s=e[o];s instanceof Object||void 0===t[o]||t[o]===s||r.push("".concat(o,":").concat(s))}if(r.length>0)return"!".concat(r.join())}return""},objectsDiff:function e(t,r){var i={};return(0,n.forIn)(t,(function(t,o){var s=r[o];if(H(t)&&H(s)){var a=e(t,s);(0,n.isEmpty)(a)||(i[o]=a)}else(0,n.isEqual)(t,s)||(i[o]=t)})),i},forInRecursive:function(e,t){!function e(r,i){(0,n.forIn)(r,(function(r,n){var o=i+(i.length>0?".":"");r instanceof Object?e(r,o+n):void 0!==r&&t(r,o+n)}))}(e,"")},enquoteString:function(e){return(0,n.isString)(e)?'"'.concat(e.replace(/"/g,'\\"'),'"'):e},unquoteString:function(e){if(!(0,n.isString)(e))return e;if('"'===e[0]&&'"'===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\"/g,'"');if("'"===e[0]&&"'"===e[e.length-1])return(e=e.slice(1,e.length-1)).replace(/\\'/g,"'");throw new SyntaxError("Incorrect string format, can't unqute it")},getBrowser:function(){return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&-1===navigator.userAgent.indexOf("CriOS")&&-1===navigator.userAgent.indexOf("FxiOS")?D.SAFARI:D.DEFAULT},shotOpen:function(e){"undefined"!=typeof window&&window.open().document.write('<body style="margin:0"><img src="'.concat(e,'" /></body>'))},shotDownload:function(e,t){if(e&&"data:"===e.substr(0,5))if(t||(t=["screenshot-",+new Date,".png"].join("")),"undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(W(e),t);else if("undefined"!=typeof document){var r=document.createElement("a");r.download=t,r.innerHTML="download",r.href=window.URL.createObjectURL(W(e)),document.body.appendChild(r),r.click(),document.body.removeChild(r)}},copySubArrays:function(e,t,r,n){for(var i=0,o=r.length;i<o;++i)for(var s=0;s<n;++s)t[i*n+s]=e[r[i]*n+s]},shallowCloneNode:function(e){var t=e.cloneNode(!0);return t.worldPos=e.worldPos,t},correctSelectorIdentifier:function(e){return Y.test(e)?e:(X[1]=e,X.join(""))},getFileExtension:q,splitFileName:function(e){var t=q(e);return[e.slice(0,e.length-t.length),t]},download:function(e,t,r){var n=new Blob([e]);if(t||(t=["data",+new Date].join("")),t+=r?".".concat(r):n.type||".bin","undefined"!=typeof window&&window.navigator&&window.navigator.msSaveBlob)window.navigator.msSaveBlob(n,t);else if("undefined"!=typeof document){var i=document.createElement("a");i.download=t,i.innerHTML="download",i.href=window.URL.createObjectURL(n),document.body.appendChild(i),i.click(),document.body.removeChild(i)}},concatTypedArraysUnsafe:function(e,t){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r},mergeTypedArraysUnsafe:function(e){if(e.length<=0)return null;for(var t=e.reduce((function(e,t){return e+t.length}),0),r=new e[0].constructor(t),n=0,i=0;n<e.length;n++){var o=e[n].length;r.set(e[n],i),i+=o}return r}};var Z=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;return s(this,i),(e=n.call(this))._shouldCancel=!1,e}return l(i,[{key:"cancel",value:function(){this._shouldCancel=!0,this.dispatchEvent({type:"cancel"})}},{key:"shouldCancel",value:function(){return this._shouldCancel}},{key:"notify",value:function(e){this.dispatchEvent({type:"notification",slaveEvent:e})}}]),i}(I),Q={modes:{BS:{atom:.23,bond:.15,space:.5,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},VW:{polyComplexity:{poor:4,low:6,medium:8,high:16,ultra:32}},LN:{multibond:!0,showarom:!0,offsarom:.2,chunkarom:10,atom:.23,lineWidth:2},LC:{bond:.2,space:0,multibond:!0,aromrad:.1,showarom:!0,polyComplexity:{poor:3,low:4,medium:6,high:12,ultra:32}},SA:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},SE:{zClip:!1,probeRadius:1.5,subset:"",wireframe:!1,polyComplexity:{poor:6,low:8,medium:16,high:30,ultra:60}},QS:{isoValue:.5,gaussLim:{poor:1.5,low:2,medium:2.5,high:3,ultra:4},scale:1,wireframe:!1,gridSpacing:{poor:2,low:1.5,medium:1,high:.5,ultra:.25},subset:"",zClip:!1},CS:{probeRadius:1.4,isoValue:1.5,wireframe:!1,probePositions:30,polyComplexity:{poor:.5,low:1,medium:1.5,high:1.75,ultra:2},subset:"",zClip:!1},TR:{radius:.3,polyComplexity:{poor:12,low:16,medium:32,high:64,ultra:64}},TU:{radius:.3,heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:4,low:6,medium:10,high:18,ultra:34}},CA:{radius:.3,depth:.25,ss:{helix:{width:1,arrow:2},strand:{width:1,arrow:2}},heightSegmentsRatio:1.5,tension:-.7,polyComplexity:{poor:4,low:6,medium:10,high:18,ultra:34}},TX:{template:"{{Chain}}.{{Residue}}{{Sequence}}.{{Name}}",horizontalAlign:"center",verticalAlign:"middle",dx:0,dy:0,dz:1,fg:"none",bg:"0x202020",showBg:!0},VD:{kSigma:1,kSigmaMed:2,kSigmaMax:4,frame:!0,isoMode:!1,polyComplexity:{poor:2,low:3,medium:4,high:8,ultra:10}}},colorers:{EL:{carbon:-1},UN:{color:16777215},CO:{subset:"charged",color:16711680,baseColor:16777215},CB:{color:9474192,factor:.6},SQ:{gradient:"rainbow"},TM:{gradient:"temp",min:5,max:40},OC:{gradient:"reds"},HY:{gradient:"blue-red"},MO:{gradient:"rainbow"}},antialias:!0,camFov:45,camNear:.5,camFar:100,camDistance:2.5,radiusToFit:1,fogNearFactor:.5,fogFarFactor:1,fogAlpha:1,fogColor:0,fogColorEnable:!1,palette:"JM",resolution:"medium",autoResolution:!1,autoPreset:!0,preset:"default",presets:{default:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],empty:[],wire:[{mode:"LN",colorer:"EL",selector:"all",material:"SF"}],small:[{mode:"BS",colorer:"EL",selector:"all",material:"SF"}],macro:[{mode:"CA",colorer:"SS",selector:"not hetatm",material:"SF"},{mode:"BS",colorer:"EL",selector:"hetatm and not water",material:"SF"}]},objects:{line:{color:4294967295,dashSize:.3,gapSize:.05}},bg:{color:2105376,transparent:!1},draft:{clipPlane:!1,clipPlaneFactor:.5,clipPlaneSpeed:3e-5},plugins:{},axes:!0,fog:!0,fps:!0,zSprites:!0,isoSurfaceFakeOpacity:!0,suspendRender:!0,nowater:!1,autobuild:!0,fxaa:!0,outline:{on:!1,color:0,threshold:.1,thickness:1},ao:!1,shadow:{on:!1,type:"random",radius:1},autoRotation:0,maxfps:30,fbxprec:4,autoRotationAxisFixed:!0,zooming:!0,picking:!0,pick:"atom",editing:!1,aromatic:!1,singleUnit:!0,stereo:"NONE",interpolateViews:!0,transparency:"prepass",translationSpeed:2,debug:{example:3.5,text:"hello!",good:!0,ssaoKernelRadius:.7,ssaoFactor:.7,stereoBarrel:.25},use:{multiFile:!1}};function K(){I.call(this),this.old=null,this.now={},this._changed={},this.reset()}$.deriveClass(K,I,{defaults:Q,set:function(e,t){if((0,n.isString)(e))(0,n.get)(this.now,e)!==t&&((0,n.set)(this.now,e,t),this._notifyChange(e,t));else{var r=$.objectsDiff(e,this.now);(0,n.isEmpty)(r)||((0,n.merge)(this.now,r),this._notifyChanges(r))}},get:function(e,t){return(0,n.get)(this.now,e,t)},reset:function(){var e=$.objectsDiff(Q,this.now);this.now=(0,n.cloneDeep)(Q),this.old=null,this._notifyChanges(e),this._changed={}},checkpoint:function(){this.old=(0,n.cloneDeep)(this.now),this._changed={}},_notifyChange:function(e,t){this._changed[e]=!0,this.dispatchEvent({type:"change:".concat(e),value:t})},_notifyChanges:function(e){var t=this;$.forInRecursive(e,(function(e,r){t._notifyChange(r,e)}))},changed:function(){if(!this.old)return[];var e=this.old,t=this.now;return(0,n.filter)(Object.keys(this._changed),(function(r){return(0,n.get)(e,r)!==(0,n.get)(t,r)}))},applyDiffs:function(e){if(e.hasOwnProperty("VERSION")&&0!==e.VERSION)throw new Error("Settings version does not match!");delete e.VERSION,this.reset(),this.set(e)},getDiffs:function(e){var t=$.objectsDiff(this.now,Q);return e&&(t.VERSION=0),t},setPluginOpts:function(e,t){Q.plugins[e]=(0,n.cloneDeep)(t),this.now.plugins[e]=(0,n.cloneDeep)(t)}});var J=new K,ee=0;function te(e){return!(!e||"0"===e||(0,n.isString)(e)&&"false"===e.toLowerCase())}var re={string:String,number:Number,boolean:te},ne=":",ie=",",oe="$;@/?",se=$.generateRegExp(oe+":,");function ae(e){return $.encodeQueryComponent(e,se)}var le=$.generateRegExp(oe+" ");function ce(e){return $.encodeQueryComponent(e,le)}function ue(e){var t=e.reps;if(!t){var r=J.now.presets,n=e.preset||J.now.preset;(t=r[n])||(B.warn('Unknown preset "'.concat(n,'"')),t=r[n=v(Object.keys(r),1)[0]]),e.preset=n,e.reps=$.deriveDeep(t,!0)}}function he(e,t,r){ue(e);var n=e.reps[ee];n.hasOwnProperty(t)&&(ee=e.reps.length,e.reps[ee]=$.deriveDeep(n,!0)),void 0!==r&&(e.reps[ee][t]=r)}function fe(e,t,r){if(e){var i=e.indexOf("!"),s=function(e,t){var r=e.indexOf(",");return r>=0?(t.push(e.substr(r+1).split(",")),e.substr(0,r)):e}(e.substr(0,i>=0?i:void 0),r);if(i>=0){var a=e.substr(i+1).split(ie);if(e=s,t){var l=t[e],c=$.deriveDeep(l,!0);a.forEach((function(t){var r=t.split(ne,2),i=decodeURIComponent(r[0]),s=decodeURIComponent(r[1]),a=re[o((0,n.get)(l,i))];a?(0,n.set)(c,i,a(s)):B.warn('Unknown argument "'.concat(i,'" for option "').concat(e,'"'))})),Object.keys(c).length>0&&(e=[e,c])}}else e=s}return e}var de={l:"load",load:String,t:"type",type:String,v:"view",view:String,u:"unit",unit:Number,menu:te,o:"object",object:function(e,t){var r=[],n=fe(e,J.defaults.objects,r);Array.isArray(n)||(n=[n]),function(e,t,r){void 0===e._objects&&(e._objects=[]);var n=v(r,2),i=n[0],o=n[1],s={type:i,params:t};void 0!==o&&(s.opts=o),e._objects[e._objects.length]=s}(t,r[0],n)},p:"preset",preset:function(e,t){t.preset=e,t.reps=null,ue(t)},r:"rep",rep:function(e,t){ue(t),(ee=(ee=Number(e))<=t.reps.length?ee<0?0:ee:t.reps.length)===t.reps.length&&(t.reps[ee]=ee>0?$.deriveDeep(t.reps[ee-1],!0):$.deriveDeep(J.defaults.presets.default[0],!0))},s:"select",select:function(e,t){he(t,"selector",e)},m:"mode",mode:function(e,t){he(t,"mode",fe(e,J.defaults.modes))},c:"color",color:function(e,t){he(t,"colorer",fe(e,J.defaults.colorers))},mt:"material",material:function(e,t){he(t,"material",fe(e,J.defaults.materials))},dup:function(e,t){ue(t);var r=t.reps,n=r[ee];r[ee=r.length]=$.deriveDeep(n,!0)},ar:"autoResolution"};function pe(e){ee=0;for(var t={},r=0,i=e.length;r<i;++r){var s=e[r],a=s[0],l=s[1];if(de.hasOwnProperty(a)){for(var c=de[a];(0,n.isString)(c);)c=de[a=c];if("function"==typeof c){var u=c(l,t);void 0!==u&&(t[a]=u)}}else{var h=re[o((0,n.get)(J.defaults,a))];h?(0,n.set)(t,"settings.".concat(a),h(l)):B.warn('Unknown option "'.concat(a,'"'))}}return t}function me(e){var t=[],r=0;return $.forInRecursive(e,(function(e,n){t[r++]=ce(n)+ne+ce(e)})),t.join(ie)}function ve(e){return(0,n.isArray)(e)?e.length<2?e[0]:"".concat(e[0]).concat("!").concat(me(e[1])):e}function ye(e){if(e&&e.type){var t=e.type;return(0,n.isArray)(e.params)&&e.params.length>0&&(t+=",".concat(e.params.join(","))),e.opts&&(t+="!"+me(e.opts)),t}}function _e(e){var t=[],r=0;return $.forInRecursive(e,(function(e,n){t[r++]="".concat(n,"=").concat($.enquoteString(e))})),t.join(" ")}function ge(e){return(0,n.isArray)(e)?e.length<2?e[0]:"".concat(e[0]," ").concat(_e(e[1])):e}function xe(e){if(e&&e.type){var t=e.type;return(0,n.isArray)(e.params)&&e.params.length>0&&(t+=" ".concat(e.params.map($.enquoteString).join(" "))),e.opts&&(t+=" ".concat(_e(e.opts))),t}}function be(e,t){var r=[],i=0;function o(e,t){null!=t&&(r[i++]=e+t)}return(0,n.isEmpty)(e)?null:(o("",t),o("s=",$.enquoteString(e.selector)),o("m=",ge(e.mode)),o("c=",ge(e.colorer)),o("mt=",ge(e.material)),r.join(" "))}var we={fromURL:function(e){return pe($.getUrlParameters(e))},fromAttr:function(e){return pe($.getUrlParameters("?".concat(e||"")))},adapters:re,toURL:function(e){var t=[],r=0;function i(e,n){null!=n&&(t[r++]=ae(e)+"="+ae(n))}i("l",e.load),i("u",e.unit),i("p",e.preset),function(e){if(e)for(var t=0,r=e.length;t<r;++t)(0,n.isEmpty)(e[t])||(i("r",t),i("s",e[t].selector),i("m",ve(e[t].mode)),i("c",ve(e[t].colorer)),i("mt",ve(e[t].material)))}(e.reps),function(e){if(e)for(var t=0,r=e.length;t<r;++t)i("o",ye(e[t]))}(e._objects),i("v",e.view),$.forInRecursive(e.settings,(function(e,t){"preset"!==t&&i(t,e)}));var o="";if("undefined"!=typeof window){var s=window.location;o="".concat(s.protocol,"//").concat(s.host).concat(s.pathname)}return t.length>0&&(o+="?".concat(t.join("&"))),o},toScript:function(e){var t=[],r=0;function n(e,n,i){if(null!=n){var o="string"==typeof n&&i?'"':"";t[r++]="".concat(e," ").concat(o).concat(n).concat(o).trim()}}return n("set","autobuild false"),n("load",e.load,!0),n("unit",e.unit),n("preset",e.preset),function(e){if(e)for(var t=0,r=e.length;t<r;++t)n("rep",be(e[t],t))}(e.reps),function(e){if(e)for(var t=0,r=e.length;t<r;++t)n("",xe(e[t]))}(e._objects),$.forInRecursive(e.settings,(function(e,t){"preset"!==t&&n("set ".concat(t),e,!0)})),n("view",e.view),n("set","autobuild true"),t.join("\n")}};function Se(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Re=function(){function e(t,r,n,i,o,a,l,c,u,h,f){s(this,e),this.index=-1,this.residue=t,this.name=r,this.element=n,this.position=i,this.role=o,this.mask=1,this.het=a,this.serial=l,this.location=(c||" ").charCodeAt(0),this.occupancy=u||1,this.temperature=h,this.charge=f,this.hydrogenCount=-1,this.radicalCount=0,this.valence=-1,this.bonds=[],this.flags=0,"H"===n.name?this.flags|=e.Flags.HYDROGEN:"C"===n.name&&(this.flags|=e.Flags.CARBON)}return l(e,[{key:"isHet",value:function(){return this.het}},{key:"isHydrogen",value:function(){return 1===this.element.number}},{key:"getVisualName",value:function(){var e=this.name;return e.length>0?e:this.element.name.trim()}},{key:"forEachBond",value:function(e){for(var t=this.bonds,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"getFullName",value:function(){var e="";return null!==this.residue&&(null!==this.residue._chain&&(e+="".concat(this.residue._chain.getName(),".")),e+="".concat(this.residue._sequence,".")),e+this.name}}]),e}();Se(Re,"Flags",{CARBON:1,HYDROGEN:8,NONPOLARH:4104});var Ce=l((function e(t,r,n,i,o,a,l){s(this,e),this.number=t,this.name=r,this.fullName=n,this.weight=i,this.radius=o,this.radiusBonding=a,this.hydrogenValency=l}));Se(Ce,"Constants",{U1:1,Lead:2,U2:3,Wing:4,U18:18}),Se(Ce,"Role",{N:Ce.Constants.U1,CA:Ce.Constants.Lead,C:Ce.Constants.U2,O:Ce.Constants.Wing,SG:Ce.Constants.U18}),Se(Ce,"ByAtomicNumber",[null,new Ce(1,"H","Hydrogen",1.008,1.2,.23,[1]),new Ce(2,"HE","Helium",4.003,1.4,.93,[0]),new Ce(3,"LI","Lithium",6.941,1.82,.68,[1]),new Ce(4,"BE","Beryllium",9.012,1.7,.35,[2]),new Ce(5,"B","Boron",10.81,2.08,.83,[3]),new Ce(6,"C","Carbon",12.011,1.95,.68,[4]),new Ce(7,"N","Nitrogen",14.007,1.85,.68,[3,5]),new Ce(8,"O","Oxygen",15.999,1.7,.68,[2,4]),new Ce(9,"F","Fluorine",18.998,1.73,.64,[1]),new Ce(10,"NE","Neon",20.18,1.54,1.12,[0]),new Ce(11,"NA","Sodium",22.99,2.27,.97,[1]),new Ce(12,"MG","Magnesium",24.305,1.73,1.1,[2]),new Ce(13,"AL","Aluminum",26.981,2.05,1.35,[3]),new Ce(14,"SI","Silicon",28.086,2.1,1.2,[4]),new Ce(15,"P","Phosphorus",30.974,2.08,.75,[3,5]),new Ce(16,"S","Sulfur",32.07,2,1.02,[2,4,6]),new Ce(17,"CL","Chlorine",35.453,1.97,.99,[1,3,5,7]),new Ce(18,"AR","Argon",39.948,1.88,1.57,[0]),new Ce(19,"K","Potassium",39.1,2.75,1.33,[1]),new Ce(20,"CA","Calcium",40.08,1.973,.99,[2]),new Ce(21,"SC","Scandium",44.956,1.7,1.44,[0]),new Ce(22,"TI","Titanium",47.88,1.7,1.47,[0]),new Ce(23,"V","Vanadium",50.941,1.7,1.33,[0]),new Ce(24,"CR","Chromium",52,1.7,1.35,[0]),new Ce(25,"MN","Manganese",54.938,1.7,1.35,[0]),new Ce(26,"FE","Iron",55.847,1.7,1.34,[0]),new Ce(27,"CO","Cobalt",58.93,1.7,1.33,[0]),new Ce(28,"NI","Nickel",58.69,1.63,1.5,[0]),new Ce(29,"CU","Copper",63.55,1.4,1.52,[0]),new Ce(30,"ZN","Zinc",65.39,1.39,1.45,[0]),new Ce(31,"GA","Gallium",69.72,1.87,1.22,[3]),new Ce(32,"GE","Germanium",72.61,1.7,1.17,[4]),new Ce(33,"AS","Arsenic",74.92,1.85,1.21,[3,5]),new Ce(34,"SE","Selenium",78.96,1.9,1.22,[2,4,6]),new Ce(35,"BR","Bromine",79.9,2.1,1.21,[1,3,5,7]),new Ce(36,"KR","Krypton",83.8,2.02,1.91,[0]),new Ce(37,"RB","Rubidium",85.47,1.7,1.47,[1]),new Ce(38,"SR","Strontium",87.62,1.7,1.12,[2]),new Ce(39,"Y","Yttrium",88.91,1.7,1.78,[0]),new Ce(40,"ZR","Zirconium",91.22,1.7,1.56,[0]),new Ce(41,"NB","Niobium",92.91,1.7,1.48,[0]),new Ce(42,"MO","Molybdenum",95.94,1.7,1.47,[0]),new Ce(43,"TC","Technetium",98.91,1.7,1.35,[0]),new Ce(44,"RU","Ruthenium",101.07,1.7,1.4,[0]),new Ce(45,"RH","Rhodium",102.91,1.7,1.45,[0]),new Ce(46,"PD","Palladium",106.42,1.63,1.5,[0]),new Ce(47,"AG","Silver",107.87,1.72,1.59,[0]),new Ce(48,"CD","Cadmium",112.41,1.58,1.69,[0]),new Ce(49,"IN","Indium",114.82,1.93,1.63,[3]),new Ce(50,"SN","Tin",118.71,2.17,1.46,[2,4]),new Ce(51,"SB","Antimony",121.75,2.2,1.46,[3,5]),new Ce(52,"TE","Tellurium",127.6,2.06,1.47,[2,4,6]),new Ce(53,"I","Iodine",126.91,2.15,1.4,[1,3,5,7]),new Ce(54,"XE","Xenon",131.29,2.16,1.98,[0]),new Ce(55,"CS","Cesium",132.91,1.7,1.67,[1]),new Ce(56,"BA","Barium",137.33,1.7,1.34,[2]),new Ce(57,"LA","Lanthanum",138.91,1.7,1.87,[0]),new Ce(58,"CE","Cerium",140.12,1.7,1.83,[0]),new Ce(59,"PR","Praseodymium",140.91,1.7,1.82,[0]),new Ce(60,"ND","Neodymium",144.24,1.7,1.81,[0]),new Ce(61,"PM","Promethium",144.9,1.7,1.8,[0]),new Ce(62,"SM","Samarium",150.36,1.7,1.8,[0]),new Ce(63,"EU","Europium",151.96,1.7,1.99,[0]),new Ce(64,"GD","Gadolinium",157.25,1.7,1.79,[0]),new Ce(65,"TB","Terbium",158.93,1.7,1.76,[0]),new Ce(66,"DY","Dysprosium",162.5,1.7,1.75,[0]),new Ce(67,"HO","Holmium",164.93,1.7,1.74,[0]),new Ce(68,"ER","Erbium",167.26,1.7,1.73,[0]),new Ce(69,"TM","Thulium",168.93,1.7,1.72,[0]),new Ce(70,"YB","Ytterbium",173.04,1.7,1.94,[0]),new Ce(71,"LU","Lutetium",174.97,1.7,1.72,[0]),new Ce(72,"HF","Hafnium",178.49,1.7,1.57,[0]),new Ce(73,"TA","Tantalum",180.95,1.7,1.43,[0]),new Ce(74,"W","Tungsten",183.85,1.7,1.37,[0]),new Ce(75,"RE","Rhenium",186.21,1.7,1.35,[0]),new Ce(76,"OS","Osmium",190.2,1.7,1.37,[0]),new Ce(77,"IR","Iridium",192.22,1.7,1.32,[0]),new Ce(78,"PT","Platinum",195.08,1.72,1.5,[0]),new Ce(79,"AU","Gold",196.97,1.66,1.5,[0]),new Ce(80,"HG","Mercury",200.59,1.55,1.7,[0]),new Ce(81,"TL","Thallium",204.38,1.96,1.55,[1,3]),new Ce(82,"PB","Lead",207.2,2.02,1.54,[2,4]),new Ce(83,"BI","Bismuth",208.98,1.7,1.54,[3,5]),new Ce(84,"PO","Polonium",210,1.7,1.68,[2,4,6]),new Ce(85,"AT","Astatine",210,1.7,1.7,[1,3,5,7]),new Ce(86,"RN","Radon",222,1.7,2.4,[0]),new Ce(87,"FR","Francium",223,1.7,2,[1]),new Ce(88,"RA","Radium",226.03,1.7,1.9,[2]),new Ce(89,"AC","Actinium",227.03,1.7,1.88,[0]),new Ce(90,"TH","Thorium",232.04,1.7,1.79,[0]),new Ce(91,"PA","Protactinium",231.04,1.7,1.61,[0]),new Ce(92,"U","Uranium",238.03,1.86,1.58,[0]),new Ce(93,"NP","Neptunium",237.05,1.7,1.55,[0]),new Ce(94,"PU","Plutonium",239.1,1.7,1.53,[0]),new Ce(95,"AM","Americium",243.1,1.7,1.51,[0]),new Ce(96,"CM","Curium",247.1,1.7,1.5,[0]),new Ce(97,"BK","Berkelium",247.1,1.7,1.5,[0]),new Ce(98,"CF","Californium",252.1,1.7,1.5,[0]),new Ce(99,"ES","Einsteinium",252.1,1.7,1.5,[0]),new Ce(100,"FM","Fermium",257.1,1.7,1.5,[0]),new Ce(101,"MD","Mendelevium",256.1,1.7,1.5,[0]),new Ce(102,"NO","Nobelium",259.1,1.7,1.5,[0]),new Ce(103,"LR","Lawrencium",260.1,1.7,1.5,[0]),new Ce(104,"RF","Rutherfordium",261,1.7,1.6,[0]),new Ce(105,"DB","Dubnium",262,1.7,1.6,[0]),new Ce(106,"SG","Seaborgium",263,1.7,1.6,[0]),new Ce(107,"BH","Bohrium",262,1.7,1.6,[0]),new Ce(108,"HS","Hassium",265,1.7,1.6,[0]),new Ce(109,"MT","Meitnerium",268,1.7,1.6,[0])]),Se(Ce,"ByName",{D:new Ce(1,"D","Deuterium",2.014,1.2,.23,[1]),T:new Ce(1,"T","Tritium",3.016,1.2,.23,[1])}),function(){for(var e=Ce.ByAtomicNumber,t=Ce.ByName,r=0,n=e.length;r<n;++r){var i=e[r];i&&(t[i.name]=i)}}(),Ce.getByName=function(e){var t=Ce.ByName[e];return t||(t=Ce.ByName[e]=new Ce(0,e,"Unknown",0,1,.01,[0])),t};var ke={UNKNOWN:0,COVALENT:1,AROMATIC:2};function Ae(e){return e.position}var Ee=function(){function e(t,r,n,i,o){if(s(this,e),this._left=t,this._right=r,this._fixed=o,this._index=-1,t>r)throw new Error("In a bond atom indices must be in increasing order");this._order=n,this._type=i}return l(e,[{key:"getLeft",value:function(){return this._left}},{key:"getRight",value:function(){return this._right}},{key:"getOrder",value:function(){return this._order}},{key:"calcLength",value:function(){return this._left.position.distanceTo(this._right.position)}},{key:"_forEachNeighbour",value:function(e,t){for(var r=e.bonds,n=0,i=r.length;n<i;++n)t(r[n]._left!==e?r[n]._left:r[n]._right)}},{key:"forEachLevelOne",value:function(e){var t=this._left,r=this._right;this._forEachNeighbour(t,(function(t){t!==r&&e(t)})),this._forEachNeighbour(r,(function(r){r!==t&&e(r)}))}},{key:"forEachLevelTwo",value:function(e){var t=this._left,r=this._right,n=this;n._forEachNeighbour(t,(function(i){i!==r&&n._forEachNeighbour(i,(function(r){r!==t&&e(r)}))})),n._forEachNeighbour(r,(function(i){i!==t&&n._forEachNeighbour(i,(function(t){t!==r&&e(t)}))}))}},{key:"_fixDir",value:function(e,t,r){var n=0,i=0,o=e.clone();function s(s){o.copy(r(s)),o.sub(e),t.dot(o)>0?++n:++i}function a(e){"C"===e.element.name&&s(e)}for(var l=[[this.forEachLevelOne,a],[this.forEachLevelOne,s],[this.forEachLevelTwo,a],[this.forEachLevelTwo,s]],c=0;c<l.length;++c){if(l[c][0].call(this,l[c][1]),i>n)return t.multiplyScalar(-1);if(i<n)return t}return t}},{key:"calcNormalDir",value:function(e){var t=this._left,r=this._right,n=t,i=r;e=void 0===e?Ae:e,t.bonds.length>r.bonds.length&&(n=r,i=t);for(var o=n,s=0,a=i.bonds,l=0,c=a.length;l<c;++l){var u=a[l]._left;a[l]._left===i&&(u=a[l]._right),u.bonds.length>s&&u!==n&&(o=u,s=u.bonds.length)}var h=e(i),f=e(n).clone().sub(h),d=e(o).clone().sub(h);return d.crossVectors(f,d),d.lengthSq()<1e-4&&d.set(0,1,0),f.normalize(),d.normalize(),f.crossVectors(d,f),f.lengthSq()<1e-4&&f.set(0,1,0),f.normalize(),this._fixDir(h,f,e)}}]),e}();Se(Ee,"BondType",ke),Ee.prototype.BondType=ke;var Pe=["C3'","C3*","P","H5T","H3T"],Te=["OP1","O1P"],Me=["OP2","O2P"],Ie=["C3'","C3*","C1","C1'","C1*","P"],Ne=[{types:["A","DA","G","DG"],atoms:["N1"]},{types:["C","DC"],atoms:["N3"]},{types:["T","DT","U","DU"],atoms:["O4"]}],Oe=function(){function e(t,r,n,i){s(this,e),this._chain=t,this._component=null,this._type=r,this._sequence=n,this._icode=i,this._mask=1,this._index=-1,this._atoms=[],this._secondary=null,this._firstAtom=null,this._leadAtom=null,this._wingAtom=null,this._lastAtom=null,this._controlPoint=null,this._midPoint=null,this._wingVector=null,this._cylinders=null,this._isValid=!0,this._het=!1,this._molecule=null,this.temperature=null,this.occupancy=null}return l(e,[{key:"getChain",value:function(){return this._chain}},{key:"getMolecule",value:function(){return this._molecule}},{key:"getType",value:function(){return this._type}},{key:"getSequence",value:function(){return this._sequence}},{key:"getSecondary",value:function(){return this._secondary}},{key:"getICode",value:function(){return this._icode}},{key:"addAtom",value:function(e,t,r,n,i,o,s,a,l,c){var u=new Re(this,e,t,r,n,i,o,s,a,l,c);return this._chain.getComplex().addAtom(u),this._atoms.push(u),this._het=this._het||i,u}},{key:"getAtomCount",value:function(){return this._atoms.length}},{key:"forEachAtom",value:function(e){for(var t=this._atoms,r=0,n=t.length;r<n&&!e(t[r]);++r);}},{key:"_findAtomByName",value:function(e){var t=null;return this.forEachAtom((function(r){return r.name===e&&(t=r,!0)})),t}},{key:"_findFirstAtomInList",value:function(e){for(var t=null,r=0;r<e.length;++r)if(null!==(t=this._findAtomByName(e[r])))return t;return t}},{key:"collectMask",value:function(){for(var e=4294967295,t=this._atoms,r=0,n=t.length;r<n;++r)e&=t[r].mask;this._mask=e}},{key:"getCylinderTargetList",value:function(){for(var e=this._type._name,t=0,r=Ne.length;t<r;++t)for(var n=0,i=Ne[t].types.length;n<i;++n)if(e===Ne[t].types[n])return Ne[t].atoms;return null}},{key:"_detectLeadWing",value:function(e,t,r){var n=this._findFirstAtomInList(Pe),i=this._findFirstAtomInList(Te),o=this._findFirstAtomInList(Me);if(null===i&&null!==t&&(i=t._findFirstAtomInList(Te)),null===o&&null!==t&&(o=t._findFirstAtomInList(Me)),null!==n&&null!==i&&null!==o){e._leadAtom=n,e._controlPoint=r(n),e._wingVector=r(o).clone().sub(r(i)),e._isValid=!0;var s=this._findFirstAtomInList(Ie),a=this.getCylinderTargetList(),l=null!==a?this._findFirstAtomInList(a):null;null!==s&&null!==l&&(e._cylinders=[r(s),r(l)])}}},{key:"calcWing",value:function(e,t,r,n){var i=t.clone().sub(e),o=e.clone().sub(r);return o.crossVectors(i,o),o.crossVectors(i,o).normalize(),null!==n&&n.length()>1e-4&&o.length()>1e-4&&Math.abs(n.angleTo(o))>Math.PI/2&&o.negate(),o}},{key:"_innerFinalize",value:function(e,t,r,n,o,s){var a=null===t,l=s(this._leadAtom),c=new i.Pq0(l.x,l.y,l.z);if(o)this._detectLeadWing(n,r,s);else{if(a)n._midPoint=s(this._firstAtom).clone();else{var u=t._controlPoint;n._midPoint=u.clone().lerp(c,.5),n._wingVector=this.calcWing(u,c,s(e._wingAtom),t._wingVector)}n._controlPoint=c}}},{key:"_finalize2",value:function(e,t,r){this._innerFinalize(e,e,t,this,r,(function(e){return e.position}))}},{key:"isConnected",value:function(e){if(this._chain!==e._chain)return!1;if(this===e)return!0;var t=!1;return this.forEachAtom((function(r){for(var n=r.bonds,i=0,o=n.length;i<o;++i){var s=n[i];if(s._left.residue===e||s._right.residue===e)return t=!0,!0}return!1})),t}},{key:"_finalize",value:function(){var e=this,t=v(this._atoms,1);this._firstAtom=t[0],this._lastAtom=this._atoms[this._atoms.length-1],this._leadAtom=null,this._wingAtom=null;var r=0,n=0,i=0,o=0;this.forEachAtom((function(t){return null===e._leadAtom&&t.role===Ce.Constants.Lead&&(e._leadAtom=t),null===e._wingAtom&&t.role===Ce.Constants.Wing&&(e._wingAtom=t),t.temperature&&(n+=t.temperature,r++),t.occupancy&&(o+=t.occupancy,i++),null!==e._leadAtom&&null!==e._wingAtom})),r>0&&(this.temperature=n/r),i>0&&(this.occupancy=o/i),null!==this._leadAtom&&null!==this._wingAtom||(this._isValid=!1),null===this._leadAtom&&(this._leadAtom=this._firstAtom),null===this._wingAtom&&(this._wingAtom=this._lastAtom)}}]),e}(),Le=function(){function e(t,r,n){s(this,e),this._name=t,this._fullName=r,this.letterCode=n,this.flags=0}return l(e,[{key:"getName",value:function(){return this._name}}]),e}();function Be(e,t){for(var r=0,n=t.length;r<n;++r){var i=Le.StandardTypes[t[r]];i&&(i.flags|=e)}}Se(Le,"StandardTypes",{ALA:new Le("ALA","Alanine","A"),ARG:new Le("ARG","Arginine","R"),ASN:new Le("ASN","Asparagine","N"),ASP:new Le("ASP","Aspartic Acid","D"),CYS:new Le("CYS","Cysteine","C"),GLN:new Le("GLN","Glutamine","Q"),GLU:new Le("GLU","Glutamic Acid","E"),GLY:new Le("GLY","Glycine","G"),HIS:new Le("HIS","Histidine","H"),ILE:new Le("ILE","Isoleucine","I"),LEU:new Le("LEU","Leucine","L"),LYS:new Le("LYS","Lysine","K"),MET:new Le("MET","Methionine","M"),PHE:new Le("PHE","Phenylalanine","F"),PRO:new Le("PRO","Proline","P"),PYL:new Le("PYL","Pyrrolysine","O"),SEC:new Le("SEC","Selenocysteine","U"),SER:new Le("SER","Serine","S"),THR:new Le("THR","Threonine","T"),TRP:new Le("TRP","Tryptophan","W"),TYR:new Le("TYR","Tyrosine","Y"),VAL:new Le("VAL","Valine","V"),A:new Le("A","Adenine","A"),C:new Le("C","Cytosine","C"),G:new Le("G","Guanine","G"),I:new Le("I","Inosine","I"),T:new Le("T","Thymine","T"),U:new Le("U","Uracil","U"),DA:new Le("DA","Adenine","A"),DC:new Le("DC","Cytosine","C"),DG:new Le("DG","Guanine","G"),DI:new Le("DI","Inosine","I"),DT:new Le("DT","Thymine","T"),DU:new Le("DU","Uracil","U"),"+A":new Le("+A","Adenine","A"),"+C":new Le("+C","Cytosine","C"),"+G":new Le("+G","Guanine","G"),"+I":new Le("+I","Inosine","I"),"+T":new Le("+T","Thymine","T"),"+U":new Le("+U","Uracil","U"),WAT:new Le("WAT","Water",""),H2O:new Le("H2O","Water",""),HOH:new Le("HOH","Water",""),DOD:new Le("DOD","Water",""),UNK:new Le("UNK","Unknown",""),UNL:new Le("UNL","Unknown Ligand","")}),Se(Le,"Flags",{PROTEIN:1,BASIC:2,ACIDIC:4,POLAR:8,NONPOLAR:16,AROMATIC:32,NUCLEIC:256,PURINE:512,PYRIMIDINE:1024,DNA:2048,RNA:4096,WATER:65536});var De=Le.Flags;Be(De.WATER,["WAT","H2O","HOH","DOD"]),Be(De.PROTEIN,["ALA","ARG","ASN","ASP","CYS","GLY","GLU","GLN","HIS","ILE","LEU","LYS","MET","PHE","PRO","PYL","SEC","SER","THR","TRP","TYR","VAL"]),Be(De.BASIC,["ARG","HIS","LYS"]),Be(De.ACIDIC,["ASP","GLU"]),Be(De.POLAR,["ASN","CYS","GLN","SER","THR","TYR"]),Be(De.NONPOLAR,["ALA","ILE","LEU","MET","PHE","PRO","TRP","VAL","GLY"]),Be(De.AROMATIC,["PHE","TRP","TYR"]),Be(De.NUCLEIC,["A","G","I","DA","DG","DI","+A","+G","+I","C","T","U","DC","DT","DU","+C","+T","+U"]),Be(De.PURINE,["A","G","I","DA","DG","DI","+A","+G","+I"]),Be(De.PYRIMIDINE,["C","T","U","DC","DT","DU","+C","+T","+U"]),Be(De.DNA,["DA","DG","DI","DC","DT","DU"]),Be(De.RNA,["A","G","I","C","T","U"]),function(e,t){for(var r=Object.keys(t),n=0,i=r.length;n<i;++n){var o=r[n],s=t[o];Le.StandardTypes[o].hydrophobicity=s}}(0,{ILE:4.5,VAL:4.2,LEU:3.8,PHE:2.8,CYS:2.5,MET:1.9,ALA:1.8,GLY:-.4,THR:-.7,SER:-.8,TRP:-.9,TYR:-1.3,PRO:-1.6,HIS:-3.2,GLU:-3.5,GLN:-3.5,ASP:-3.5,ASN:-3.5,LYS:-3.9,ARG:-4.5});var ze,Fe=function(){function e(t,r){s(this,e),this._complex=t,this._name=r,this._mask=1,this._index=-1,this._residues=[],this.minSequence=Number.POSITIVE_INFINITY,this.maxSequence=Number.NEGATIVE_INFINITY}return l(e,[{key:"getComplex",value:function(){return this._complex}},{key:"getName",value:function(){return this._name}},{key:"getResidues",value:function(){return this._residues}},{key:"_determineType",value:function(){var e=this._residues,t=Le.Flags,r=t.PROTEIN,n=t.NUCLEIC;this.type=0;for(var i=0,o=e.length;i<o;++i){var s=e[i]._type.flags;if(s&n){this.type=2;break}if(s&r){this.type=1;break}}}},{key:"findResidue",value:function(e,t){for(var r=this._residues,n=0,i=r.length;n<i;++n){var o=r[n];if(o._sequence===e&&o._icode===t)return[o,n]}return null}},{key:"_finalize",value:function(){this._determineType();for(var e=this._residues,t=null,r=0,n=e.length;r<n;++r){var o=r+1<n?e[r+1]:null,s=e[r];s._finalize2(t,o,2===this.type),t=s}if(e.length>1&&e[1]._wingVector){var a=e[1]._wingVector;e[0]._wingVector=new i.Pq0(a.x,a.y,a.z)}else e.length>0&&(e[0]._wingVector=new i.Pq0(1,0,0))}},{key:"updateToFrame",value:function(e){var t=this._residues,r=null,n=null,o=e._residues,s=t.length;function a(t){return e.getAtomPos(t.index)}for(var l=0;l<s;++l){var c=t[l],u=o[c._index],h=l+1<s?t[l+1]:null;c._innerFinalize(r,n,h,u,2===this.type,a),r=c,n=u}o[t[0]._index]._wingVector=s>1?o[t[1]._index]._wingVector:new i.Pq0(1,0,0)}},{key:"addResidue",value:function(e,t,r){var n=this._complex.getResidueType(e);null===n&&(n=this._complex.addResidueType(e));var i=new Oe(this,n,t,r);return this._complex.addResidue(i),this._residues.push(i),n.flags&(Le.Flags.NUCLEIC|Le.Flags.PROTEIN)&&(this.maxSequence<t&&(this.maxSequence=t),this.minSequence>t&&(this.minSequence=t)),i}},{key:"getResidueCount",value:function(){return this._residues.length}},{key:"forEachResidue",value:function(e){for(var t=this._residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"collectMask",value:function(){for(var e=4294967295,t=this._residues,r=0,n=t.length;r<n;++r)e&=t[r]._mask;this._mask=e}}]),e}(),Ve=function(){function e(t,r,n){s(this,e),this.type=t,this.generic=e.genericByType[this.type]||"loop",this.init=r,this.term=n}return l(e,[{key:"_finalize",value:function(e,t,r){if(!(this.init instanceof Oe&&this.term instanceof Oe)){for(var n=r.splitUnifiedSerial(this.init),i=r.splitUnifiedSerial(this.term),o=n.chain;o<=i.chain;o++)for(var s=n.serial;s<=i.serial;s++)for(var a=n.iCode;a<=i.iCode;a++){var l=r.getUnifiedSerial(o,s,a);t[l]&&(t[l]._secondary=this)}this.init=t[this.init],this.term=t[this.term]}}}]),e}();Ve.Type={STRAND:"E",BRIDGE:"B",HELIX_310:"G",HELIX_ALPHA:"H",HELIX_PI:"I",HELIX:"X",TURN_310:"3",TURN_ALPHA:"4",TURN_PI:"5",TURN:"T",BEND:"S",COIL:"C"},Ve.Generic={STRAND:"strand",HELIX:"helix",LOOP:"loop"};var Ue=Ve.Type,je=Ve.Generic;Ve.genericByType=(Se(ze={},Ue.STRAND,je.STRAND),Se(ze,Ue.HELIX_310,je.HELIX),Se(ze,Ue.HELIX_ALPHA,je.HELIX),Se(ze,Ue.HELIX_PI,je.HELIX),Se(ze,Ue.HELIX,je.HELIX),ze);var Ge=Ve.Type,He={1:Ge.HELIX_ALPHA,3:Ge.HELIX_PI,5:Ge.HELIX_310},qe=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,c){var u;return s(this,i),(u=n.call(this,He[e]||Ve.Type.HELIX,t,r)).serial=o,u.name=a,u.comment=l,u.length=c,u}return l(i)}(Ve);function We(){return We="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},We.apply(this,arguments)}var Ye=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l){var c;return s(this,i),(c=n.call(this,Ve.Type.STRAND,t,r)).sheet=e,c.sense=o,c.atomCur=a,c.atomPrev=l,c}return l(i,[{key:"_finalize",value:function(e,t,r){We(d(i.prototype),"_finalize",this).call(this,e,t,r);var n=this.atomCur;null===n||Number.isNaN(n)||(this.atomCur=e[n]),null===(n=this.atomPrev)||Number.isNaN(n)||(this.atomPrev=e[n])}}]),i}(Ve),Xe=function(){function e(t,r){s(this,e),this._name=t,this._width=r,this._strands=[]}return l(e,[{key:"getName",value:function(){return this._name}},{key:"getWidth",value:function(){return this._width}},{key:"addStrand",value:function(e){this._strands.push(e),this._width=this._strands.length}},{key:"addEmptyStrand",value:function(){this._strands.push(new Ye(null,null,null,null,null,null))}},{key:"_finalize",value:function(e,t,r){for(var n=this._strands,i=0,o=n.length;i<o;++i)n[i]._finalize(e,t,r);if(this._width||(this._width=n.length),n.length!==this._width)throw new Error("Sheet ".concat(this._name," is inconsistent."))}}]),e}(),$e=function(){function e(t,r,n,o,a){s(this,e),this._id=t,this._name=r,this._position=n||new i.Pq0,this._atoms=o||[],this._charge=0,this._repeat=1,this._center=null,this.xmlNodeRef=a||null}return l(e,[{key:"getName",value:function(){return this._name}},{key:"getPosition",value:function(){return this._position}},{key:"getCentralPoint",value:function(){return this._center}},{key:"_rebuildSGroupOnAtomChange",value:function(){var e=1e8;if(null!==this._center){for(var t=new i.Pq0(e,e,e),r=new i.Pq0(-e,-e,-e),n=0,o=this._atoms.length;n<o;n++){var s=this._atoms[n].position;t.set(Math.min(t.x,s.x),Math.min(t.y,s.y),Math.min(t.z,s.z)),r.set(Math.max(r.x,s.x),Math.max(r.y,s.y),Math.max(r.z,s.z))}this._center.addVectors(t,r),this._center.multiplyScalar(.5)}}}]),e}(),Ze="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},Qe=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[1,4],r=[1,5],n=[1,6],i=[1,7],o=[1,8],s=[1,9],a=[1,11],l=[1,12],c=[5,7,8,11],u=[1,17],h=[1,22],f=[1,20],d=[1,21],p=[5,7,8,11,19],m={trace:function(){},yy:{},symbols_:{error:2,Program:3,Expression:4,EOF:5,Selector:6,OR:7,AND:8,NOT:9,"(":10,")":11,SELECTOR:12,NAMED_SELECTOR:13,SELECTOR_RANGED:14,RangeList:15,SELECTOR_NAMED:16,NameList:17,Range:18,",":19,NUMBER:20,":":21,Name:22,IDENTIFIER:23,STRING:24,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"OR",8:"AND",9:"NOT",10:"(",11:")",12:"SELECTOR",13:"NAMED_SELECTOR",14:"SELECTOR_RANGED",16:"SELECTOR_NAMED",19:",",20:"NUMBER",21:":",23:"IDENTIFIER",24:"STRING"},productions_:[0,[3,2],[4,1],[4,3],[4,3],[4,2],[4,3],[6,1],[6,1],[6,2],[6,2],[15,1],[15,3],[18,1],[18,3],[17,1],[17,3],[22,1],[22,1],[22,1]],performAction:function(e,t,r,n,i,o,s){var a=o.length-1;switch(i){case 1:return o[a-1];case 3:this.$=n.keyword("or")(o[a-2],o[a]);break;case 4:this.$=n.keyword("and")(o[a-2],o[a]);break;case 5:this.$=n.keyword("not")(o[a]);break;case 6:this.$=o[a-1];break;case 7:this.$=n.keyword(o[a])();break;case 8:this.$=n.GetSelector(o[a].toLowerCase().slice(1,o[a].length));break;case 9:case 10:this.$=n.keyword(o[a-1])(o[a]);break;case 11:this.$=new n.RangeList(o[a]);break;case 12:case 16:this.$=o[a-2].append(o[a]);break;case 13:this.$=new n.Range(Number(o[a]));break;case 14:this.$=new n.Range(Number(o[a-2]),Number(o[a]));break;case 15:this.$=new n.ValueList(o[a])}},table:[{3:1,4:2,6:3,9:t,10:r,12:n,13:i,14:o,16:s},{1:[3]},{5:[1,10],7:a,8:l},e(c,[2,2]),{4:13,6:3,9:t,10:r,12:n,13:i,14:o,16:s},{4:14,6:3,9:t,10:r,12:n,13:i,14:o,16:s},e(c,[2,7]),e(c,[2,8]),{15:15,18:16,20:u},{17:18,20:h,22:19,23:f,24:d},{1:[2,1]},{4:23,6:3,9:t,10:r,12:n,13:i,14:o,16:s},{4:24,6:3,9:t,10:r,12:n,13:i,14:o,16:s},e(c,[2,5]),{7:a,8:l,11:[1,25]},e(c,[2,9],{19:[1,26]}),e(p,[2,11]),e(p,[2,13],{21:[1,27]}),e(c,[2,10],{19:[1,28]}),e(p,[2,15]),e(p,[2,17]),e(p,[2,18]),e(p,[2,19]),e([5,7,11],[2,3],{8:l}),e(c,[2,4]),e(c,[2,6]),{18:29,20:u},{20:[1,30]},{20:h,22:31,23:f,24:d},e(p,[2,12]),e(p,[2,14]),e(p,[2,16])],defaultActions:{10:[2,1]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=[0],r=[],n=[null],i=[],o=this.table,s="",a=0,l=0,c=i.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(h.yy[f]=this.yy[f]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;i.push(d);var p=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,y,_,g,x,b,w,S,R={};;){if(v=t[t.length-1],this.defaultActions[v]?y=this.defaultActions[v]:(null==m&&(S=void 0,"number"!=typeof(S=r.pop()||u.lex()||1)&&(S instanceof Array&&(S=(r=S).pop()),S=this.symbols_[S]||S),m=S),y=o[v]&&o[v][m]),void 0===y||!y.length||!y[0]){var C;for(g in w=[],o[v])this.terminals_[g]&&g>2&&w.push("'"+this.terminals_[g]+"'");C=u.showPosition?"Parse error on line "+(a+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(C,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,s=u.yytext,a=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],R.$=n[n.length-x],R._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(R._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(R,[s,l,a,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(R.$),i.push(R._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},v=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;o<i.length;o++)if((r=this._input.match(this.rules[i[o]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:return 20;case 2:return 7;case 3:return 8;case 4:return 9;case 5:return 12;case 6:return 16;case 7:return 14;case 8:return 10;case 9:return 11;case 10:return 19;case 11:return 21;case 12:return"<=";case 13:return">=";case 14:return"<";case 15:return">";case 16:return t.yytext=t.yytext.substr(1,t.yyleng-2),24;case 17:return 13;case 18:return 23;case 19:return 5;case 20:return"INVALID"}},rules:[/^(?:\s+)/i,/^(?:(-?(?:[1-9][0-9]+|[0-9]))\b)/i,/^(?:OR\b)/i,/^(?:AND\b)/i,/^(?:NOT\b)/i,/^(?:((ALL|NONE|HETATM|PROTEIN|BASIC|ACIDIC|CHARGED|POLAR|NONPOLAR|AROMATIC|NUCLEIC|PURINE|PYRIMIDINE|WATER|POLARH|NONPOLARH))\b)/i,/^(?:((NAME|ELEM|TYPE|RESIDUE|ICODE|CHAIN|ALTLOC))\b)/i,/^(?:((SERIAL|SEQUENCE|RESIDX))\b)/i,/^(?:\()/i,/^(?:\))/i,/^(?:,)/i,/^(?::)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:(@[_A-Z0-9]+))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return e}();function y(){this.yy={}}return m.lexer=v,y.prototype=m,m.Parser=y,new y}(),Ke={parser:Qe};function Je(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var et=function(){function e(t,r){s(this,e),this.min=t,this.max=void 0===r?t:r}return l(e,[{key:"includes",value:function(e){return this.min<=e&&e<=this.max}},{key:"toString",value:function(){var e=this.min,t=this.max;return e===t?String(e):[e,t].join(":")}},{key:"toJSON",value:function(){return[this.min,this.max]}}]),e}(),tt=function(){function e(t){if(s(this,e),t instanceof this.constructor)return t;this._values=t instanceof Array?t.slice(0):t?[t]:[]}return l(e,[{key:"append",value:function(e){var t=this._values;return t[t.length]=e,this}},{key:"remove",value:function(e){var t=this._values,r=t.indexOf(e);return r>=0&&t.splice(r,1),this}},{key:"toString",value:function(){return this._values.join(",")}},{key:"toJSON",value:function(){for(var e=this._values,t=[],r=0,n=e.length;r<n;++r){var i=e[r];t[r]=i.toJSON?i.toJSON():i}return t}}]),e}(),rt=function(e){h(r,e);var t=Je(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includes",value:function(e){for(var t=this._values,r=0,n=t.length;r<n;++r)if(t[r].includes(e))return!0;return!1}}]),r}(tt),nt=[],it=function(e){h(r,e);var t=Je(r);function r(e,n){var i;s(this,r);var o=i=t.call(this,e);if(n){i.upperOnly=!0;for(var a=o._values,l=0,c=a.length;l<c;++l){var u=a[l];"string"==typeof u&&(a[l]=u.toUpperCase())}}else i.upperOnly=!1;return f(i,o)}return l(r,[{key:"includes",value:function(e){return-1!==this._values.indexOf(e)}},{key:"toString",value:function(){var e=this._values;nt.length=0;for(var t=0,r=e.length;t<r;++t)nt[t]=$.correctSelectorIdentifier(String(e[t]));return nt.join(",")}},{key:"_validate",value:function(e){return this.upperOnly&&"string"==typeof e?e.toUpperCase():e}},{key:"append",value:function(e){return We(d(r.prototype),"append",this).call(this,this._validate(e)),this}},{key:"remove",value:function(e){return We(d(r.prototype),"remove",this).call(this,this._validate(e)),this}}]),r}(tt);function ot(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var st=function(){function e(){s(this,e)}return l(e,[{key:"toString",value:function(){return this.keyword}},{key:"toJSON",value:function(){return[this.name]}}]),e}();st.prototype.name="Error",st.prototype.keyword="error";var at=function(e){h(r,e);var t=ot(r);function r(e){var n;return s(this,r),(n=t.call(this)).list=e,n}return l(r,[{key:"toString",value:function(){return"".concat(this.keyword," ").concat(this.list)}},{key:"toJSON",value:function(){return[this.name,this.list.toJSON()]}}]),r}(st),lt=function(e){h(r,e);var t=ot(r);function r(e){return s(this,r),t.call(this,new rt(e))}return l(r)}(at),ct=function(e){h(r,e);var t=ot(r);function r(e,n){return s(this,r),t.call(this,new it(e,!n))}return l(r)}(at),ut=function(e){h(r,e);var t=ot(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!1}}]),r}(st);ut.prototype.name="None",ut.prototype.keyword="none";var ht=function(e){h(r,e);var t=ot(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!0}}]),r}(st);function ft(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}ht.prototype.name="All",ht.prototype.keyword="all";var dt=new ut,pt=function(e){h(r,e);var t=ft(r);function r(e){var n;return s(this,r),(n=t.call(this)).rhs=e||dt,n}return l(r,[{key:"toString",value:function(){var e=this.rhs.priority&&this.rhs.priority>this.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(this.keyword," ").concat(e)}},{key:"toJSON",value:function(){return[this.name,this.rhs.toJSON()]}}]),r}(st);pt.prototype.priority=1;var mt=function(e){h(r,e);var t=ft(r);function r(e,n){var i;return s(this,r),(i=t.call(this)).lhs=e||dt,i.rhs=n||dt,i}return l(r,[{key:"toString",value:function(){var e=this.lhs.priority&&this.lhs.priority>this.priority?"(".concat(this.lhs,")"):this.lhs,t=this.rhs.priority&&this.rhs.priority>this.priority?"(".concat(this.rhs,")"):this.rhs;return"".concat(e," ").concat(this.keyword," ").concat(t)}},{key:"toJSON",value:function(){return[this.name,this.lhs.toJSON(),this.rhs.toJSON()]}}]),r}(st);function vt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}mt.prototype.priority=1e3;var yt={};function _t(e,t){var r=e.toLowerCase();t.prototype.keyword=r,t.prototype.name=e;var n=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return P(t,r)};return n.SelectorClass=t,yt[r]=n,t}_t("Serial",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.serial)}}]),r}(lt)),_t("Name",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.name)}}]),r}(ct)),_t("AltLoc",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(String.fromCharCode(e.location))}}]),r}(ct)),_t("Elem",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.element.name)}}]),r}(ct)),_t("Residue",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._type._name)}}]),r}(ct)),_t("Sequence",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._sequence)}}]),r}(lt)),_t("ICode",function(e){h(r,e);var t=vt(r);function r(e){return s(this,r),t.call(this,e,!0)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._icode)}}]),r}(ct)),_t("ResIdx",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._index)}}]),r}(lt)),_t("Chain",function(e){h(r,e);var t=vt(r);function r(e){return s(this,r),t.call(this,e,!0)}return l(r,[{key:"includesAtom",value:function(e){return this.list.includes(e.residue._chain._name)}}]),r}(ct)),_t("Hetatm",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return e.het}}]),r}(st)),_t("PolarH",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return(e.flags&Re.Flags.NONPOLARH)===Re.Flags.HYDROGEN}}]),r}(st)),_t("NonPolarH",function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return(e.flags&Re.Flags.NONPOLARH)===Re.Flags.NONPOLARH}}]),r}(st)),_t("All",ht),_t("None",ut);var gt=yt.none();function xt(e,t,r){return r.prototype.priority=t,_t(e,r)}function bt(e,t){return _t(t,function(t){h(n,t);var r=vt(n);function n(){return s(this,n),r.apply(this,arguments)}return l(n,[{key:"includesAtom",value:function(t){return!!(t.residue._type.flags&e)}}]),n}(st))}xt("Not",1,function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return!this.rhs.includesAtom(e)}}]),r}(pt)),xt("And",2,function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.lhs.includesAtom(e)&&this.rhs.includesAtom(e)}}]),r}(mt)),xt("Or",3,function(e){h(r,e);var t=vt(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"includesAtom",value:function(e){return this.lhs.includesAtom(e)||this.rhs.includesAtom(e)}}]),r}(mt)),bt(Le.Flags.PROTEIN,"Protein"),bt(Le.Flags.BASIC,"Basic"),bt(Le.Flags.ACIDIC,"Acidic"),bt(Le.Flags.BASIC|Le.Flags.ACIDIC,"Charged"),bt(Le.Flags.POLAR,"Polar"),bt(Le.Flags.NONPOLAR,"NonPolar"),bt(Le.Flags.AROMATIC,"Aromatic"),bt(Le.Flags.NUCLEIC,"Nucleic"),bt(Le.Flags.PURINE,"Purine"),bt(Le.Flags.PYRIMIDINE,"Pyrimidine"),bt(Le.Flags.WATER,"Water");var wt=Object.create(yt);wt.Selector=st,wt.RangeListSelector=lt,wt.ValueListSelector=ct,wt.Range=et,wt.RangeList=rt,wt.ValueList=it,wt.PrefixOperator=pt,wt.InfixOperator=mt,wt.Context=Object.create({}),wt.GetSelector=function(e){if(!wt.Context.hasOwnProperty(e))throw{message:"selector ".concat(e," is not registered")};return wt.Context[e]||gt},wt.ClearContext=function(){Object.keys(wt.Context).forEach((function(e){delete wt.Context[e]}))},wt.keyword=function(e){return yt[e.toLowerCase()]||yt.none},wt.parse=function(e){var t={};try{t.selector=Ke.parser.parse(e)}catch(e){t.selector=gt,t.error=e.message}return t},Ke.parser.yy=wt,Ke.parser.yy.parseError=Ke.parser.parseError;var St=function(){function e(t){s(this,e),this._complex=t,this._selector=wt.keyword("All")(),this._boundaries={boundingBox:new i.NRn,boundingSphere:new i.iyt}}return l(e,[{key:"computeBoundaries",value:function(){var e=this._complex._atoms,t=e.length,r=this._selector,n=this._boundaries.boundingBox;if(n.makeEmpty(),1===t){n.expandByPoint(e[0].position);var o=new i.Pq0;n.getCenter(o);var s=2*e[0].element.radius;n.setFromCenterAndSize(o,new i.Pq0(s,s,s))}else for(var a=0;a<t;++a)r.includesAtom(e[a])&&n.expandByPoint(e[a].position);var l=0,c=new i.Pq0;if(n.getCenter(c),1===t)this._boundaries.boundingSphere.set(c,e[0].element.radius);else{for(var u=0;u<t;++u)if(r.includesAtom(e[u])){var h=e[u].position,f=c.distanceToSquared(h);l<f&&(l=f)}this._boundaries.boundingSphere.set(c,Math.sqrt(l))}}},{key:"getTransforms",value:function(){return[]}},{key:"getSelector",value:function(){return this._selector}},{key:"getBoundaries",value:function(){return this._boundaries}},{key:"finalize",value:function(){}}]),e}();var Rt=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return s(this,o),(t=n.call(this,e)).chains=[],t.matrices=[],t}return l(o,[{key:"computeBoundaries",value:function(){We(d(o.prototype),"computeBoundaries",this).call(this);var e=this.matrices,t=this._boundaries.boundingSphere.center,r=this._boundaries.boundingSphere.radius,n=this._boundaries.boundingBox=new i.NRn;n.makeEmpty();for(var s=0,a=e.length;s<a;++s)n.expandByPoint(t.clone().applyMatrix4(e[s]));var l=n.max.distanceTo(n.min)/2+r,c=new i.Pq0;n.getCenter(c),this._boundaries.boundingSphere=(new i.iyt).set(c,l),n.max.addScalar(r),n.min.subScalar(r)}},{key:"addChain",value:function(e){this.chains[this.chains.length]=e}},{key:"addMatrix",value:function(e){this.matrices[this.matrices.length]=e}},{key:"getTransforms",value:function(){return this.matrices}},{key:"finalize",value:function(){this.chains.length>0?this._selector=wt.keyword("Chain")(this.chains):this._selector=wt.keyword("None")()}}]),o}(St),Ct=function(){function e(t){s(this,e),this._complex=t,this._index=-1,this._residueIndices=[],this._cycles=[],this._subDivs=[],this._residueCount=0}return l(e,[{key:"getResidues",value:function(){return this._complex._residues}},{key:"getResidueCount",value:function(){return this._residueCount}},{key:"forEachResidue",value:function(e){for(var t=this._complex._residues,r=this._residueIndices,n=0,i=r.length;n<i;++n)for(var o=r[n].start,s=r[n].end;o<=s;++o)e(t[o])}},{key:"setSubDivs",value:function(e){this._subDivs=e;for(var t=0,r=[],n=0,i=0,o=e.length;i<o;++i)if(i===o-1||e[i].end+1!==e[i+1].start){var s=e[t].start,a=e[i].end;r[r.length]={start:s,end:a},n+=a-s+1,t=i+1}this._residueIndices=r,this._residueCount=n}},{key:"getComplex",value:function(){return this._complex}},{key:"forEachBond",value:function(e){for(var t=this._complex._bonds,r=0,n=t.length;r<n;++r){var i=t[r];i._left.residue._component===this&&e(i)}}},{key:"update",value:function(){this.forEachCycle((function(e){e.update()}))}},{key:"forEachAtom",value:function(e){this.forEachResidue((function(t){t.forEachAtom(e)}))}},{key:"addCycle",value:function(e){this._cycles.push(e)}},{key:"forEachCycle",value:function(e){for(var t=this._cycles,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"markResidues",value:function(){var e=this;e.forEachResidue((function(t){t._component=e}))}},{key:"_forEachSubChain",value:function(e,t){for(var r=this._complex._residues,n=this._subDivs,i=0,o=n.length;i<o;++i)for(var s=n[i].start,a=n[i].end;s<=a;++s){var l=r[s];if(e&l._mask&&l._isValid){for(var c=s+1;c<=a;++c){var u=r[c];if(!(e&u._mask&&u._isValid))break}t(i,s,c-1),s=c}}}},{key:"getMaskedSequences",value:function(e){var t=[],r=0;return this._forEachSubChain(e,(function(e,n,i){t[r++]={start:n,end:i}})),t}},{key:"getMaskedSubdivSequences",value:function(e){var t=[],r=-1,n=-1,i=this._subDivs;return this._forEachSubChain(e,(function(e,o,s){n!==e&&(++r,t[r]={arr:[],boundaries:i[e]},n=e),t[r].arr[t[r].arr.length]={start:o,end:s}})),t}}]),e}(),kt=function(){function e(t){s(this,e),this.numPairs=0,this.numMaxPairs=t,this.intBuffer=$.allocateTyped(Int32Array,4*t);for(var r=0;r<4*t;r++)this.intBuffer[r]=-1;this.hashBuffer=$.allocateTyped(Int32Array,33554432);for(var n=0;n<33554432;n++)this.hashBuffer[n]=-1}return l(e,[{key:"destroy",value:function(){this.intBuffer=null,this.hashBuffer=null}},{key:"addPair",value:function(e,t){for(var r=e<t?e:t,n=e>t?e:t,i=r+(n<<14),o=32*(r+89237*n&1048575),s=0;s<32;s++){var a=this.hashBuffer[o+s];if(-1===a)break;if(a===i)return!1}if(s>=32)throw new Error("addPair: increase cMaxPairsForHashCode");if(this.hashBuffer[o+s]=i,this.numPairs>=this.numMaxPairs)throw new Error("addPair: increase num pairs");return o=4*this.numPairs,this.intBuffer[o]=r,this.intBuffer[o+1]=n,this.intBuffer[o+2]=i,this.numPairs++,!0}}]),e}();function At(e){var t=e.element;if(t)return t.radiusBonding;throw new Error("_getBondingRadius: Logic error.")}var Et,Pt,Tt,Mt=function(){function e(t){s(this,e),this._complex=t,this._maxRad=1.8;var r=this._complex.getDefaultBoundaries().boundingBox;this._vBoxMin=r.min.clone(),this._vBoxMax=r.max.clone(),this._pairCollection=null}return l(e,[{key:"_addExistingPairs",value:function(){for(var e=this._complex.getAtoms(),t=e.length,r=0,n=this._pairCollection;r<t;r++)for(var i=e[r].bonds,o=i.length,s=0;s<o;s++){var a=i[s];a._left.index===r&&n.addPair(r,a._right.index)}return 0}},{key:"_findPairs",value:function(){var e=this._complex.getVoxelWorld();if(null!==e)for(var t,r,n,i,o,s,a=this._complex._atoms,l=a.length,c=this,u=function(e){if(!r||!e.isHydrogen()){var s=e.location;if(32===i||32===s||i===s){var a=n.distanceToSquared(e.position),l=e.element.radiusBonding,u=t+l+.45;a>u*u||a<.001||c._pairCollection.addPair(o.index,e.index)}}},h=0;h<l;++h)(!(s=o=a[h]).isHet()||s.bonds&&0===s.bonds.length)&&(t=o.element.radiusBonding,r=o.isHydrogen(),n=o.position,i=o.location,e.forEachAtomWithinRadius(n,2*this._maxRad+.45,u))}},{key:"_addPairs",value:function(){for(var e=this._complex._atoms,t=0,r=0;t<this._pairCollection.numPairs;t++,r+=4){var n=this._pairCollection.intBuffer[r],i=this._pairCollection.intBuffer[r+1];this._addPair(e[n],e[i])}}},{key:"_addPair",value:function(e,t){for(var r=e.bonds,n=e.index,i=t.index,o=0,s=r.length;o<s;++o){var a=r[o];if(a._left.index===i||a._right.index===i)return}var l=n<i?e:t,c=n<i?t:e,u=this._complex.addBond(l,c,0,Ee.BondType.UNKNOWN,!1);r.push(u),t.bonds.push(u)}},{key:"build",value:function(){this._buildInner()}},{key:"_buildInner",value:function(){var e=this._complex._atoms;if(!(e.length<2)){if(e[0].index<0)throw new Error("AutoBond: Atoms in complex were not indexed.");this._calcBoundingBox(),this._pairCollection=new kt(4*e.length),this._addExistingPairs(),this._findPairs(),this._addPairs()}}},{key:"_calcBoundingBox",value:function(){for(var e=this._complex._atoms,t=e.length,r=At(e[0]),n=1;n<t;++n)r=Math.max(r,At(e[n]));this._vBoxMax.addScalar(r),this._vBoxMin.addScalar(-r),this._maxRad=1.2*r}},{key:"destroy",value:function(){this._pairCollection&&this._pairCollection.destroy()}}]),e}(),It=Ee.BondType.AROMATIC,Nt=[Ce.ByName.C.number,Ce.ByName.N.number],Ot=(Et=new i.Pq0,Pt=new i.Pq0,Tt=new i.Pq0,function(e,t){return Et.copy(e).normalize(),Pt.copy(t).normalize(),Tt.crossVectors(Et,Pt),!(Tt.length()>.1)&&Et.dot(Pt)>=0});function Lt(e,t){for(var r=0;r<e.length&&e[r]<t;)++r;e.splice(r,0,t)}function Bt(e,t){return e._left===t?e._right:e._left}function Dt(e){e._type=It}var zt=function(){function e(t){s(this,e),this.atoms=t,this.update()}return l(e,[{key:"update",value:function(){for(var e=this.atoms,t=new i.Pq0,r=e.length,n=0;n<r;++n)t.add(e[n].position);t.multiplyScalar(1/r),this.center=t,this.radius=t.distanceTo(e[0].position.clone().lerp(e[1].position,.5))}},{key:"forEachBond",value:function(e){var t,r=this.atoms,n=r.length,i=r[0];function o(r){r._left!==t&&r._right!==t||e(r)}for(var s=0;s<n;++s)t=r[(s+1)%n],i.forEachBond(o),i=t}}]),e}();function Ft(e){return e._type===It}function Vt(e){if(e.type===It)return!0;var t=Nt.indexOf(e._right.element.number),r=Nt.indexOf(e._left.element.number);return-1!==t&&-1!==r}function Ut(e){return e.length>3}function jt(e){return console.assert(e.length>2),!0}var Gt=function(){function e(t){s(this,e),this._complex=t;for(var r=new Array(t._bonds.length),n=new Array(t._bonds.length),i=0,o=r.length;i<o;++i)r[i]=[],n[i]=!1;this._bondsData=r,this._bondMarks=n,this._resetCycles()}return l(e,[{key:"_resetCycles",value:function(){this._cycles=[],this._currIdx=-1}},{key:"_haveSameCycle",value:function(e,t,r){for(var n=e[t._index],i=e[r._index],o=n.length,s=i.length,a=0,l=0;a<o&&l<s;){if(n[a]===i[l])return!0;n[a]>i[l]?++l:++a}return!1}},{key:"_tryBond",value:function(e,t,r){var n=[],o=this._bondsData,s=Bt(e,t),a=t.position.clone().sub(s.position),l=this._currStart,c=this,u=this._bondMarks,h=this._checkBond;u[e._index]=!0,h=void 0===h?Ft:h,t.forEachBond((function(s){if(h(s)&&s!==e&&!u[s._index]&&!c._haveSameCycle(o,e,s)){var f,d,p,m=Bt(s,t),v=m.position.clone().sub(t.position),y=m===l?-2:1-(d=v,p=(f=a).dot(d)/Math.sqrt(f.lengthSq()*d.lengthSq()),i.cj9.clamp(p,-1,1)),_=v.cross(a);if(Ot(_,r)){for(var g=0;g<n.length&&n[g].val<y;)++g;n.splice(g,0,{bond:s,val:y,dir:_})}}}));for(var f=0,d=n.length;f<d;++f){var p=n[f].bond,m=p._left===t?p._right:p._left;if(m===l)return++this._currIdx,this._cycles.push([t]),u[e._index]=!1,!0;if(this._tryBond(p,m,n[f].dir))return Lt(o[p._index],this._currIdx),this._cycles[this._currIdx].push(t),u[e._index]=!1,!0}return u[e._index]=!1,!1}},{key:"_startCycle",value:function(e){this._currStart=e._left,this._tryBond(e,e._right,new i.Pq0)&&(Lt(this._bondsData[e._index],this._currIdx),this._cycles[this._currIdx].push(e._left))}},{key:"_findLoops",value:function(e,t){this._checkBond=e;var r=this._complex,n=this;r.forEachComponent((function(r){n._resetCycles(),r.forEachBond((function(t){e(t)&&n._startCycle(t)}));for(var i=n._cycles,o=0,s=i.length;o<s;++o){var a=i[o];if(t(a)){var l=new zt(a);l.forEachBond(Dt),r.addCycle(l)}}}))}},{key:"markCycles",value:function(){this._findLoops(Ft,Ut)}},{key:"detectCycles",value:function(){this._findLoops(Vt,jt)}}]),e}();function Ht(e,t,r,n){var i=r-e.z,o=n-e.z,s=Math.sqrt(Math.max(t*t-i*i,0)),a=Math.sqrt(Math.max(t*t-o*o,0));return[Math.min(s,a),r<=e.z&&n>=e.z?t:Math.max(s,a)]}function qt(e,t,r,n){var i=r-e.y,o=n-e.y,s=Math.sqrt(Math.max(t*t-i*i,0)),a=Math.sqrt(Math.max(t*t-o*o,0));return[Math.min(s,a),r<=e.y&&n>=e.y?t:Math.max(s,a)]}var Wt=function(){function e(t,r){s(this,e),this._box=t.clone();var n=new i.Pq0;t.getSize(n),this._count=n.clone().divide(r).floor().max(new i.Pq0(1,1,1)),this._last=this._count.clone().subScalar(1),this._cellSize=n.clone().divide(this._count),this._cellInnerR=.5*Math.min(Math.min(this._cellSize.x,this._cellSize.y),this._cellSize.z),this._cellOuterR=.5*Math.sqrt(this._cellSize.dot(this._cellSize));var o=this._count.x*this._count.y*this._count.z;this._voxels=$.allocateTyped(Int32Array,o);for(var a=0;a<o;++a)this._voxels[a]=-1;this._atoms=[]}return l(e,[{key:"addAtoms",value:function(e){var t=this,r=this._atoms.length;this._atoms.length+=2*e.getAtomCount(),e.forEachAtom((function(e){var n=t._findVoxel(e.position);t._atoms[r]=e,t._atoms[r+1]=t._voxels[n],t._voxels[n]=r,r+=2}))}},{key:"_findVoxel",value:function(t){var r=e._zero,n=e._voxel;return n.copy(t).sub(this._box.min).divide(this._cellSize).floor().clamp(r,this._last),n.x+this._count.x*(n.y+this._count.y*n.z)}},{key:"_forEachAtomInVoxel",value:function(e,t){for(var r=this._voxels[e];r>=0;r=this._atoms[r+1])t(this._atoms[r])}},{key:"_forEachVoxelWithinRadius",value:function(t,r,n){var i=e._xRange,o=e._yRange,s=e._zRange;if(r/this._cellInnerR<10)this._forEachVoxelWithinRadiusSimple(t,r,n);else{var a,l,c,u,h,f,d,p;s.set(t.z-r,t.z+r),s.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor().clampScalar(0,this._count.z-1);for(var m=s.x;m<=s.y;++m){h=[this._box.min.z+m*this._cellSize.z,this._box.min.z+(m+1)*this._cellSize.z],p=t.z-r<=h[0]&&h[1]<=t.z+r,a=Ht(t,r,h[0],h[1]),o.set(t.y-a[1],t.y+a[1]),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor().clampScalar(0,this._count.y-1);for(var v=o.x;v<=o.y;++v){u=[this._box.min.y+v*this._cellSize.y,this._box.min.y+(v+1)*this._cellSize.y],d=t.y-a[0]<=u[0]&&u[1]<=t.y+a[0],l=qt(t,a[1],u[0],u[1]),i.set(t.x-l[1],t.x+l[1]),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor().clampScalar(0,this._count.x-1);for(var y=i.x;y<=i.y;++y)c=[this._box.min.x+y*this._cellSize.x,this._box.min.x+(y+1)*this._cellSize.x],f=t.x-l[0]<=c[0]&&c[1]<=t.x+l[0],n(y+this._count.x*(v+this._count.y*m),f&&d&&p)}}}}},{key:"_forEachVoxelWithinRadiusSimple",value:function(t,r,n){var i=e._xRange,o=e._yRange,s=e._zRange,a=e._vCenter,l=(r+this._cellOuterR)*(r+this._cellOuterR),c=-1;r>this._cellOuterR&&(c=(r-this._cellOuterR)*(r-this._cellOuterR)),i.set(t.x-r,t.x+r),i.subScalar(this._box.min.x).divideScalar(this._cellSize.x).floor(),i.x=Math.min(Math.max(i.x,0),this._count.x-1),i.y=Math.min(Math.max(i.y,0),this._count.x-1),o.set(t.y-r,t.y+r),o.subScalar(this._box.min.y).divideScalar(this._cellSize.y).floor(),o.x=Math.min(Math.max(o.x,0),this._count.y-1),o.y=Math.min(Math.max(o.y,0),this._count.y-1),s.set(t.z-r,t.z+r),s.subScalar(this._box.min.z).divideScalar(this._cellSize.z).floor(),s.x=Math.min(Math.max(s.x,0),this._count.z-1),s.y=Math.min(Math.max(s.y,0),this._count.z-1);for(var u=s.x;u<=s.y;++u){var h=[this._box.min.z+u*this._cellSize.z,this._box.min.z+(u+1)*this._cellSize.z];a.z=.5*(h[0]+h[1]);for(var f=o.x;f<=o.y;++f){var d=[this._box.min.y+f*this._cellSize.y,this._box.min.y+(f+1)*this._cellSize.y];a.y=.5*(d[0]+d[1]);for(var p=i.x;p<=i.y;++p){var m=[this._box.min.x+p*this._cellSize.x,this._box.min.x+(p+1)*this._cellSize.x];a.x=.5*(m[0]+m[1]);var v=t.distanceToSquared(a);v<=l&&n(p+this._count.x*(f+this._count.y*u),v<=c)}}}}},{key:"forEachAtomWithinRadius",value:function(e,t,r){var n=this,i=t*t;n._forEachVoxelWithinRadius(e,t,(function(t,o){o?n._forEachAtomInVoxel(t,r):n._forEachAtomInVoxel(t,(function(t){e.distanceToSquared(t.position)<=i&&r(t)}))}))}},{key:"forEachAtomWithinDistFromMasked",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){e.mask&t&&r(e)}))}),r,n)}},{key:"forEachAtomWithinDistFromSelected",value:function(e,t,r,n){this._forEachAtomWithinDistFromGroup((function(r){e.forEachAtom((function(e){t.includesAtom(e)&&r(e)}))}),r,n)}},{key:"_forEachAtomWithinDistFromGroup",value:function(e,t,r){var n,i=this,o=t*t,s=[],a=[],l=0;e((function(e){i._forEachVoxelWithinRadius(e.position,t,(function(t,r){r?s[t]=-1:void 0===s[t]?(a.push(e),a.push(-1),s[t]=l,l+=2):-1!==s[t]&&(a.push(e),a.push(s[t]),s[t]=l,l+=2)}))}));var c=function(e){if(void 0!==s[n])if(-1!==(l=s[n])){for(;l>=0;l=a[l+1])if(e.position.distanceToSquared(a[l].position)<o){r(e);break}}else r(e)};for(n in s)s.hasOwnProperty(n)&&i._forEachAtomInVoxel(n,c)}}]),e}();Se(Wt,"_zero",new i.Pq0(0,0,0)),Se(Wt,"_voxel",new i.Pq0),Se(Wt,"_xRange",new i.I9Y),Se(Wt,"_yRange",new i.I9Y),Se(Wt,"_zRange",new i.I9Y),Se(Wt,"_vCenter",new i.Pq0);var Yt=.5,Xt=-9.9,$t=-27.888,Zt=function(){function e(t){s(this,e),this._complex=t,this._hbonds=[],this._complex._residues.length>1e3?this._buildVW():this._build()}return l(e,[{key:"isBond",value:function(e,t){if(this._hbonds[e]){var r=v(this._hbonds[e].acceptor,2),n=r[0],i=r[1];if(n&&n.residue===t&&n.energy<-.5)return!0;if(i&&i.residue===t&&i.energy<-.5)return!0}return!1}},{key:"_build",value:function(){for(var e=0;e<this._complex._residues.length-1;++e){var t=this._complex._residues[e];if(t.getType().flags&Le.Flags.PROTEIN){var r=null;e>0&&this._complex._residues[e-1].getType().flags&Le.Flags.PROTEIN&&t._sequence===this._complex._residues[e-1]._sequence+1&&(r=this._complex._residues[e-1]);for(var n=e+1;n<this._complex._residues.length;++n){var i=this._complex._residues[n];if(i.getType().flags&Le.Flags.PROTEIN){var o=null;this._complex._residues[n-1].getType().flags&Le.Flags.PROTEIN&&i._sequence===this._complex._residues[n-1]._sequence+1&&(o=this._complex._residues[n-1]),this._calcHBondEnergy(r,t,i),n!==e+1&&this._calcHBondEnergy(o,i,t)}}}}}},{key:"_buildVW",value:function(){var e,t,r=this,n=this._complex._residues,i=this._complex.getVoxelWorld();if(null!==i)for(var o=new kt(this._complex._residues.length*this._complex._residues.length/2),s=0;s<n.length-1;++s)(e=n[s]).getType().flags&Le.Flags.PROTEIN&&(!(t=s>0?n[s-1]:null)||t.getType().flags&Le.Flags.PROTEIN&&e._sequence===t._sequence+1||(t=null),i.forEachAtomWithinRadius(this._residueGetCAlpha(e),5,a));function a(i){var s=i.residue;if(s._index!==e._index&&s.getType().flags&Le.Flags.PROTEIN&&o.addPair(e._index,s._index)){var a=s._index>0?n[s._index-1]:null;!a||a.getType().flags&Le.Flags.PROTEIN&&s._sequence===a._sequence+1||(a=null),r._calcHBondEnergy(t,e,s),s._index!==e._index+1&&r._calcHBondEnergy(a,s,e)}}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t<e._atoms.length;++t){var r=e._atoms[t].name;if("CA"===r||"C1"===r)return e._atoms[t].position}return null}},{key:"_residueGetCO",value:function(e){var t=null,r=null;return e.forEachAtom((function(e){"C"===e.name?t=e.position:"O"===e.name&&(r=e.position)})),[t,r]}},{key:"_residueGetNH",value:function(e,t){var r,n=v(this._residueGetCO(e),2),i=n[0],o=n[1];if(t.forEachAtom((function(e){"N"===e.name&&(r=e.position)})),i&&o&&r){var s=i.clone();return s.sub(o),s.multiplyScalar(1/s.length()),s.add(r),[r,s]}return[null,null]}},{key:"_calcHBondEnergy",value:function(e,t,r){var n=0;if(null===e)return n;if("PRO"!==t.getType().getName()){var i=v(this._residueGetNH(e,t),2),o=i[0],s=i[1],a=v(this._residueGetCO(r),2),l=a[0],c=a[1];if(null===o||null===s||null===l||null===c)return n;var u=s.distanceTo(c),h=s.distanceTo(l),f=o.distanceTo(l),d=o.distanceTo(c);n=u<Yt||h<Yt||f<Yt||d<Yt?Xt:$t/u-$t/h+$t/f-$t/d,(n=Math.round(1e3*n)/1e3)<Xt&&(n=Xt)}void 0===this._hbonds[t._index]&&(this._hbonds[t._index]={donor:[],acceptor:[]});var p=this._hbonds[t._index];p.acceptor.length<2&&p.acceptor.push({residue:r._index,energy:n}),p.acceptor.length>1&&(n<p.acceptor[0].energy?(p.acceptor[1].residue=p.acceptor[0].residue,p.acceptor[1].energy=p.acceptor[0].energy,p.acceptor[0].residue=r._index,p.acceptor[0].energy=n):n<p.acceptor[1].energy&&(p.acceptor[1].residue=r._index,p.acceptor[1].energy=n)),void 0===this._hbonds[r._index]&&(this._hbonds[r._index]={donor:[],acceptor:[]});var m=this._hbonds[r._index];return m.donor.length<2&&m.donor.push({residue:t._index,energy:n}),m.donor.length>1&&(n<m.donor[0].energy?(m.donor[1].residue=m.donor[0].residue,m.donor[1].energy=m.donor[0].energy,m.donor[0].residue=t._index,m.donor[0].energy=n):n<m.donor[1].energy&&(m.donor[1].residue=t._index,m.donor[1].energy=n)),n}}]),e}();function Qt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Kt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Kt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Kt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Jt,er,tr=Object.freeze({NO_BRIDGE:0,PARALLEL:1,ANTI_PARALLEL:2}),rr=Object.freeze({START:1,MIDDLE:2,END:3,START_AND_END:4}),nr=Object.freeze({STRAND:"E",BRIDGE:"B",HELIX_310:"G",HELIX_ALPHA:"H",HELIX_PI:"I",TURN:"T",BEND:"S",LOOP:" "}),ir=function(){function e(t){s(this,e),this._complex=t,this._build()}return l(e,[{key:"_build",value:function(){this._hbonds=new Zt(this._complex),this._ss=[],this._sheet=[],this._betaPartners=[],this._bend=[];for(var e=0;e<this._complex.getResidues().length;++e)this._betaPartners[e]=[];this._helixFlags=[],this._helixFlags[3]=[],this._helixFlags[4]=[],this._helixFlags[5]=[],this._chainLengths=[];for(var t=0;t<this._complex._chains.length;++t){for(var r=this._complex._chains[t].getResidues(),n=0;n<r.length&&r[n].getType().flags&Le.Flags.PROTEIN;++n);this._chainLengths[t]=n}this._buildBetaSheets();for(var i=0;i<this._complex._chains.length;++i)this._buildAlphaHelices(this._complex._chains[i].getResidues(),this._chainLengths[i],!1)}},{key:"_buildAlphaHelices",value:function(e,t,r){for(var n=3;n<=5&&!(e.length<n);++n)for(var i=0;i+n<t;++i)if(this._hbonds.isBond(e[i+n]._index,e[i]._index)){this._helixFlags[n][e[i+n]._index]=rr.END;for(var o=i+1;o<i+n;++o)void 0===this._helixFlags[n][e[o]._index]&&(this._helixFlags[n][e[o]._index]=rr.MIDDLE);this._helixFlags[n][e[i]._index]===rr.END?this._helixFlags[n][e[i]._index]=rr.START_AND_END:this._helixFlags[n][e[i]._index]=rr.START}for(var s=2;s<t-2;++s){var a=this._kappa(e[s-2],e[s],e[s+2]);this._bend[e[s]._index]=360!==a&&a>70}for(var l=1;l+4<t;++l)if(this._isHelixStart(e[l]._index,4)&&this._isHelixStart(e[l-1]._index,4))for(var c=l;c<=l+3;++c)this._ss[e[c]._index]=nr.HELIX_ALPHA;for(var u=1;u+3<t;++u)if(this._isHelixStart(e[u]._index,3)&&this._isHelixStart(e[u-1]._index,3)){for(var h=!0,f=u;h&&f<=u+2;++f)h=void 0===this._ss[e[f]._index]||this._ss[e[f]._index]===nr.HELIX_310;if(h)for(var d=u;d<=u+2;++d)this._ss[e[d]._index]=nr.HELIX_310}for(var p=1;p+5<t;++p)if(this._isHelixStart(e[p]._index,5)&&this._isHelixStart(e[p-1]._index,5)){for(var m=!0,v=p;m&&v<=p+4;++v)m=void 0===this._ss[e[v]._index]||this._ss[e[v]._index]===nr.HELIX_PI||r&&this._ss[e[v]._index]===nr.HELIX_ALPHA;if(m)for(var y=p;y<=p+4;++y)this._ss[e[y]._index]=nr.HELIX_PI}for(var _=1;_+1<t;++_)if(void 0===this._ss[e[_]._index]){for(var g=!1,x=3;x<=5&&!g;++x)for(var b=1;b<x&&!g;++b)g=_>=b&&this._isHelixStart(e[_-b]._index,x);g?this._ss[e[_]._index]=nr.TURN:this._bend[e[_]._index]&&(this._ss[e[_]._index]=nr.BEND)}}},{key:"_residueGetCAlpha",value:function(e){for(var t=0;t<e._atoms.length;++t){var r=e._atoms[t].name;if("CA"===r||"C1"===r)return e._atoms[t].position}return null}},{key:"_cosinusAngle",value:function(e,t,r,n){var i=e.clone().sub(t),o=r.clone().sub(n),s=0,a=i.dot(i)*o.dot(o);return a>0&&(s=i.dot(o)/Math.sqrt(a)),s}},{key:"_kappa",value:function(e,t,r){var n=this._residueGetCAlpha(t),i=this._residueGetCAlpha(e),o=this._residueGetCAlpha(r);if(null===n||null===i||null===o)return 180;var s=this._cosinusAngle(n,i,o,n),a=Math.sqrt(1-s*s);return 180*Math.atan2(a,s)/Math.PI}},{key:"_isHelixStart",value:function(e,t){return this._helixFlags[t][e]===rr.START||this._helixFlags[t][e]===rr.START_AND_END}},{key:"_buildBetaSheets",value:function(){for(var e=[],t=0;t<this._complex._chains.length;++t){var r=this._chainLengths[t];if(!(r<=4))for(var n=this._complex._chains[t].getResidues(),i=t;i<this._complex._chains.length;++i){var o=this._chainLengths[i];if(!(o<=4))for(var s=this._complex._chains[i].getResidues(),a=1;a+1<r;++a){var l=n[a],c=1;for(i===t&&(c=a+3);c+1<o;++c){var u=s[c],h=this._testBridge(n,a,s,c);if(h!==tr.NO_BRIDGE){var f,d=!1,p=Qt(e);try{for(p.s();!(f=p.n()).done;){var m=f.value;if(h===m.type&&l._index===m.i[m.i.length-1]+1){if(h===tr.PARALLEL&&m.j[m.j.length-1]+1===u._index){m.i.push(l._index),m.j.push(u._index),d=!0;break}if(h===tr.ANTI_PARALLEL&&m.j[0]-1===u._index){m.i.push(l._index),m.j.unshift(u._index),d=!0;break}}}}catch(e){p.e(e)}finally{p.f()}d||e.push({type:h,i:[l._index],chainI:l.getChain()._index,j:[u._index],chainJ:u.getChain()._index})}}}}}e.sort((function(e,t){return e.chainI<t.chainI||e.chainI===t.chainI&&e.i[0]<t.i[0]?-1:1}));for(var v=0;v<e.length;++v)for(var y=v+1;y<e.length;++y){var _=e[v].i[0],g=e[v].i[e[v].i.length-1],x=e[v].j[0],b=e[v].j[e[v].j.length-1],w=e[y].i[0],S=e[y].i[e[y].i.length-1],R=e[y].j[0],C=e[y].j[e[y].j.length-1];e[v].type!==e[y].type||this._hasChainBreak(Math.min(_,w),Math.max(g,S))||this._hasChainBreak(Math.min(x,R),Math.max(b,C))||w-g>=6||g>=w&&_<=S||(e[v].type===tr.PARALLEL?R-b<6&&w-g<3||R-b<3:x-C<6&&w-g<3||x-C<3)&&(e[v].i=e[v].i.concat(e[y].i),e[v].type===tr.PARALLEL?e[v].j=e[v].j.concat(e[y].j):e[v].j=e[y].j.concat(e[v].j),e.splice(y--,1))}for(var k=new Set,A=0;A<e.length;++A)k.add(e[A]);for(var E=1,P=0;k.size>0;){var T=k.values().next().value;k.delete(T);var M=new Set;M.add(T);var I=void 0;do{I=new Set;var N,O=Qt(M.values());try{for(O.s();!(N=O.n()).done;){var L,B=N.value,D=Qt(k.values());try{for(D.s();!(L=D.n()).done;){var z=L.value;this._areBridgesLinked(B,z)&&I.add(z)}}catch(e){D.e(e)}finally{D.f()}}}catch(e){O.e(e)}finally{O.f()}var F,V=Qt(I.values());try{for(V.s();!(F=V.n()).done;)T=F.value,M.add(T),k.delete(T)}catch(e){V.e(e)}finally{V.f()}}while(I.size>0);var U,j=Qt(M.values());try{for(j.s();!(U=j.n()).done;)(T=U.value).ladder=P,T.sheet=E,T.link=M,++P}catch(e){j.e(e)}finally{j.f()}++E}for(var G=0;G<e.length;++G){for(var H=e[G],q=0,W=0,Y=0;Y<H.i.length;++Y)if(this._betaPartners[H.i[Y]][0]){q=1;break}for(var X=0;X<H.j.length;++X)if(this._betaPartners[H.j[X]][0]){W=1;break}var $=nr.BRIDGE;if(H.i.length>1&&($=nr.STRAND),H.type===tr.PARALLEL){for(var Z=0,Q=0;Q<H.i.length;++Q)this._betaPartners[H.i[Q]][q]={residue:H.j[Z++],ladder:H.ladder,parallel:!0};Z=0;for(var K=0;K<H.j.length;++K)this._betaPartners[H.j[K]][W]={residue:H.i[Z++],ladder:H.ladder,parallel:!0}}else{for(var J=H.j.length-1,ee=0;ee<H.i.length;++ee)this._betaPartners[H.i[ee]][q]={residue:H.j[J--],ladder:H.ladder,parallel:!1};J=H.i.length-1;for(var te=0;te<H.j.length;++te)this._betaPartners[H.j[te]][W]={residue:H.i[J--],ladder:H.ladder,parallel:!1}}for(var re=H.i[0];re<=H.i[H.i.length-1];++re)this._ss[re]!==nr.STRAND&&(this._ss[re]=$,this._sheet[re]=H.sheet);for(var ne=H.j[0];ne<=H.j[H.j.length-1];++ne)this._ss[ne]!==nr.STRAND&&(this._ss[ne]=$,this._sheet[ne]=H.sheet)}}},{key:"_testBridge",value:function(e,t,r,n){var i=tr.NO_BRIDGE,o=e[t-1]._index,s=e[t]._index,a=e[t+1]._index,l=r[n-1]._index,c=r[n]._index,u=r[n+1]._index,h=this._hbonds.isBond.bind(this._hbonds);return h(a,c)&&h(c,o)||h(u,s)&&h(s,l)?i=tr.PARALLEL:(h(a,l)&&h(u,o)||h(c,s)&&h(s,c))&&(i=tr.ANTI_PARALLEL),i}},{key:"_areBridgesLinked",value:function(e,t){var r,n=new Set(e.i),i=new Set(e.j),o=Qt(t.i);try{for(o.s();!(r=o.n()).done;){var s=r.value;if(n.has(s)||i.has(s))return!0}}catch(e){o.e(e)}finally{o.f()}var a,l=Qt(t.j);try{for(l.s();!(a=l.n()).done;){var c=a.value;if(n.has(c)||i.has(c))return!0}}catch(e){l.e(e)}finally{l.f()}return!1}},{key:"_hasChainBreak",value:function(e,t){for(var r=e+1;r<=t;++r)if(this._complex._residues[r]._sequence!==this._complex._residues[r-1]._sequence+1)return!0;return!1}}]),e}();ir.StructureType=nr;var or=ir.StructureType,sr=Ve.Type,ar=(Se(Jt={},or.HELIX_ALPHA,1),Se(Jt,or.HELIX_PI,3),Se(Jt,or.HELIX_310,5),Jt),lr=(Se(er={},or.BRIDGE,sr.BRIDGE),Se(er,or.TURN,sr.TURN),Se(er,or.BEND,sr.BEND),Se(er,or.LOOP,sr.COIL),er),cr=function(){function e(){s(this,e),this._chains=[],this._components=[],this._helices=[],this._sheets=[],this.structures=[],this._residueTypes=Object.create(Le.StandardTypes),this._atoms=[],this._residues=[],this._bonds=[],this._sgroups=[],this._molecules=[],this._maskNeedsUpdate=!1,this.metadata={},this.symmetry=[],this.units=[new St(this)],this._currentUnit=0}return l(e,[{key:"addAtom",value:function(e){var t=this._atoms.length;return this._atoms.push(e),t}},{key:"addSheet",value:function(e){var t=this._sheets.length;return this._sheets.push(e),t}},{key:"addHelix",value:function(e){var t=this._helices.length;return this._helices.push(e),t}},{key:"getAtoms",value:function(){return this._atoms}},{key:"getBonds",value:function(){return this._bonds}},{key:"getAtomCount",value:function(){return this._atoms.length}},{key:"addResidue",value:function(e){var t=this._residues.length;return this._residues.push(e),t}},{key:"updateToFrame",value:function(e){this.forEachChain((function(t){t.updateToFrame(e)}))}},{key:"addResidueType",value:function(e){return this._residueTypes[e]=new Le(e,"Unknown","")}},{key:"getResidueCount",value:function(){return this._residues.length}},{key:"getResidues",value:function(){return this._residues}},{key:"getSGroupCount",value:function(){return this._sgroups.length}},{key:"getSGroups",value:function(){return this._sgroups}},{key:"getAtomByFullname",value:function(e){var t=e.split(".");if(3!==t.length)return null;var r=t[0],n=parseInt(t[1],10);if(Number.isNaN(n))return null;var i=t[2].toUpperCase(),o=null;return this.forEachChain((function(e){o||0===e._name.localeCompare(r)&&e.forEachResidue((function(e){o||e._sequence===n&&e.forEachAtom((function(e){o||0===i.localeCompare(e.name)&&(o=e)}))}))})),o}},{key:"addChain",value:function(e){var t=new Fe(this,e);return this._chains.push(t),t}},{key:"getChain",value:function(e){for(var t=0,r=this._chains.length;t<r;++t){var n=this._chains[t];if(n.getName()===e)return n}return null}},{key:"getChainCount",value:function(){return this._chains.length}},{key:"getMolecules",value:function(){return this._molecules}},{key:"getMoleculeCount",value:function(){return this._molecules.length}},{key:"forEachAtom",value:function(e){for(var t=this._atoms,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachBond",value:function(e){for(var t=this._bonds,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachResidue",value:function(e){for(var t=this._residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachChain",value:function(e){for(var t=this._chains,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachMolecule",value:function(e){for(var t=this._molecules,r=t.length,n=0;n<r;++n)e(t[n])}},{key:"forEachSGroup",value:function(e){for(var t=this._sgroups,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachComponent",value:function(e){for(var t=this._components,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"forEachVisibleComponent",value:function(e){for(var t=this._components,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"addBond",value:function(e,t,r,n,i){var o=new Ee(e,t,r,n,i);return this._bonds.push(o),o}},{key:"getBondCount",value:function(){return this._bonds.length}},{key:"getResidueType",value:function(e){return this._residueTypes[e]||null}},{key:"getUnifiedSerial",value:function(e,t,r){return t+65536*r+16777216*e}},{key:"splitUnifiedSerial",value:function(e){var t=16777216,r=Math.floor(e/t),n=e-r*t,i=Math.floor(n/65536);return{chain:r,serial:n-65536*i,iCode:i}}},{key:"_fillCmpEdit",value:function(){var e=this,t=this._components;function r(){var r=new Ct(e);return r._index=t.length,t[r._index]=r,r}this.forEachChain((function(e){var t=e._residues,n=t.length;if(!(n<1))for(var i=r(),o=t[0]._index,s=0;s<n;++s){var a=t[s];a._component=i;var l=s===n-1?null:t[s+1];l&&a.isConnected(l)&&a._index===l._index-1||(i.setSubDivs([{start:o,end:a._index}]),l&&(o=l._index,i=r()))}}))}},{key:"_fillCmpNoedit",value:function(){var e=new Ct(this);e._index=0;var t=this._residues,r=t.length;if(0!==r){for(var n=[],i=0,o=0;o<r;++o){var s=t[o];s._component=e;var a=o===r-1?null:t[o+1];a&&s.isConnected(a)||(n[n.length]={start:i,end:o},a&&(i=o+1))}e.setSubDivs(n),this._components[e._index]=e}}},{key:"_fillComponents",value:function(e){e?this._fillCmpEdit():this._fillCmpNoedit()}},{key:"getCurrentUnit",value:function(){return this._currentUnit}},{key:"getDefaultBoundaries",value:function(){return this.units[0].getBoundaries()}},{key:"getBoundaries",value:function(){return this.units[this._currentUnit].getBoundaries()}},{key:"getTransforms",value:function(){return this.units[this._currentUnit].getTransforms()}},{key:"getSelector",value:function(){return this.units[this._currentUnit].getSelector()}},{key:"resetCurrentUnit",value:function(){this._currentUnit=0,this.setCurrentUnit(1)}},{key:"setCurrentUnit",value:function(e){return null!=e&&e!==this._currentUnit&&e>=0&&e<this.units.length&&(this._currentUnit=e,!0)}},{key:"_computeBounds",value:function(){for(var e=this.units,t=0,r=e.length;t<r;++t)e[t].computeBoundaries()}},{key:"onAtomPositionChanged",value:function(){this.forEachChain((function(e){e._finalize()})),this.forEachComponent((function(e){e.update()})),this._computeBounds(),this._finalizeBonds(),this.forEachSGroup((function(e){e._rebuildSGroupOnAtomChange()}))}},{key:"update",value:function(){this._maskNeedsUpdate&&(this.updateStructuresMask(),this._maskNeedsUpdate=!1)}},{key:"_finalizeBonds",value:function(){for(var e=this.getBonds(),t=e.length,r=0;r<t;++r)e[r]._index=r}},{key:"finalize",value:function(e){e=e||{};var t,r,n=this._bonds;for(t=n.length-1;t>=0;t--){var i=n[t];null===i._left||null===i._right?n.splice(t,1):(i._left.bonds.push(i),i._right.bonds.push(i))}var o=this._residues;for(t=0,r=o.length;t<r;++t)o[t]._finalize();this.forEachChain((function(e){e._finalize()}));var s=this.units;for(t=0,r=s.length;t<r;++t)s[t].finalize();this.setCurrentUnit(1);var a={};for(t=0,r=o.length;t<r;++t){var l=o[t];a[this.getUnifiedSerial(l.getChain().getName().charCodeAt(0),l.getSequence(),l.getICode().charCodeAt(0))]=l}var c=this.structures;for(t=0,r=c.length;t<r;++t)c[t]._finalize(e.serialAtomMap,a,this);var u=this._helices;for(t=0,r=u.length;t<r;++t)u[t]._finalize(e.serialAtomMap,a,this);var h=this._sheets;for(t=0,r=h.length;t<r;++t)h[t]._finalize(e.serialAtomMap,a,this);this._computeBounds();var f=this._atoms;for(t=0,r=f.length;t<r;++t)f[t].index=t;if(e.needAutoBonding){var d=new Mt(this);d.build(),d.destroy()}var p=this._chains;for(t=0,r=p.length;t<r;++t)p[t]._index=t;for(t=0,r=o.length;t<r;++t)o[t]._index=t;for(t=0,r=f.length;t<r;++t){var m=f[t];if(m.flags&Re.Flags.HYDROGEN&&1===m.bonds.length){var v=m.bonds[0];(v._left!==m&&v._left||v._right).flags&Re.Flags.CARBON&&(m.flags|=Re.Flags.NONPOLARH)}}this._finalizeBonds(),this._fillComponents(e.enableEditing);var y=new Gt(this);y.markCycles(),e.detectAromaticLoops&&y.detectCycles(),this._finalizeMolecules()}},{key:"_finalizeMolecules",value:function(){for(var e=0;e<this._molecules.length;e++)for(var t=this._molecules[e],r=t.residues.length,n=0;n<r;n++)t.residues[n]._molecule=t}},{key:"updateStructuresMask",value:function(){var e=function(e){return e.collectMask()};this.forEachResidue(e),this.forEachChain(e),this.forEachMolecule(e)}},{key:"countAtomsByMask",value:function(e){var t=0;return this.forEachAtom((function(r){r.mask&e&&t++})),t}},{key:"getNumAtomsBySelector",value:function(e){var t=0;return this.forEachAtom((function(r){e.includesAtom(r)&&t++})),t}},{key:"resetAtomMask",value:function(e){this.forEachAtom((function(t){t.mask=e}))}},{key:"markAtoms",value:function(e,t){var r=t,n=~r,i=0,o=wt.keyword("And")(e,this.getSelector());return this.forEachAtom((function(e){o.includesAtom(e)?(e.mask|=r,i++):e.mask&=n})),this._maskNeedsUpdate=!0,i}},{key:"markAtomsAdditionally",value:function(e,t){var r=t,n=0;return this.forEachAtom((function(i){e.includesAtom(i)&&(i.mask&t)!==t&&(i.mask|=r,n++)})),n}},{key:"clearAtomBits",value:function(e){var t=~e;this.forEachAtom((function(e){e.mask&=t}));var r=function(e){e._mask&=t};this.forEachAtom(r),this.forEachResidue(r),this.forEachChain(r),this.forEachMolecule(r)}},{key:"getAtomNames",value:function(){if(this.hasOwnProperty("_atomNames"))return this._atomNames;var e={};return this.forEachAtom((function(t){e[t.name]=1})),this._atomNames=Object.keys(e),this._atomNames}},{key:"getElements",value:function(){if(this.hasOwnProperty("_elements"))return this._elements;var e={};return this.forEachAtom((function(t){e[t.element.name]=1})),this._elements=Object.keys(e),this._elements}},{key:"getResidueNames",value:function(){if(this.hasOwnProperty("_residueNames"))return this._residueNames;var e={};return this.forEachResidue((function(t){e[t._type._name]=1})),this._residueNames=Object.keys(e),this._residueNames}},{key:"getChainNames",value:function(){if(this.hasOwnProperty("_chainNames"))return this._chainNames;var e={};return this.forEachChain((function(t){e[t._name]=1})),this._chainNames=Object.keys(e),this._chainNames}},{key:"getAltLocNames",value:function(){if(this.hasOwnProperty("_altlocNames"))return this._altlocNames;var e={};return this.forEachAtom((function(t){e[String.fromCharCode(t.location)]=1})),this._altlocNames=Object.keys(e),this._altlocNames}},{key:"getVoxelWorld",value:function(){if(!this.hasOwnProperty("_voxelWorld"))try{this._voxelWorld=new Wt(this.getDefaultBoundaries().boundingBox,new i.Pq0(5,5,5)),this._voxelWorld.addAtoms(this)}catch(e){B.warn("Unable to create voxel world"),this._voxelWorld=null}return this._voxelWorld}},{key:"addElement",value:function(e,t,r,n){for(var i=e.length,o=0;o<i;++o){var s=e[o];n(s,r),t.push(s)}}},{key:"joinComplexes",value:function(e){this._chains=[],this._components=[],this._helices=[],this._sheets=[],this.structures=[],this._atoms=[],this._residues=[],this._bonds=[],this._sgroups=[];var t=this,r=0,n=0,i=0,o=0,s=0;function a(e,t){e.serial+=t,e.index+=t}function l(e,t){e._index+=t}function c(e,t){e._index+=t}function u(e,r){e._complex=t,e._index+=r}function h(e,r){e._complex=t,e._index+=r}function f(){}for(var d=0;d<e.length;++d){var p=e[d];for(var m in this.addElement(p._atoms,this._atoms,r,a),this.addElement(p._bonds,this._bonds,n,l),this.addElement(p._residues,this._residues,i,c),this.addElement(p._chains,this._chains,o,u),this.addElement(p._sheets,this._sheets,0,f),this.addElement(p._helices,this._helices,0,f),this.addElement(p._sgroups,this._sgroups,0,f),this.addElement(p._components,this._components,s,h),this.addElement(p.structures,this.structures,0,f),p._residueTypes)p._residueTypes.hasOwnProperty(m)&&(this._residueTypes[m]=p._residueTypes[m]);r+=p._atoms.length,n+=p._bonds.length,i+=p._residues.length,o+=p._chains.length,s+=p._components.length}this._computeBounds()}},{key:"dssp",value:function(){for(var e,t,r,n,i=new ir(this),o=this.structures=[],s=this._helices=[],a=this._sheets=[],l=0,c=null,u=0,h=this._residues.length;u<h;++u){var f=i._ss[u],d=this._residues[u],p=i._sheet[u];if(f!==e||p!==t){var m=ar[f],v=lr[f];if(f===or.STRAND){var y=(n=void 0,(n=a[r=p])||(n=a[r]=new Xe(String(r),0)),n);c=new Ye(y,d,d,0,null,null),y.addStrand(c)}else void 0!==m?(l++,c=new qe(m,d,d,l,String(l),"",1),s.push(c)):c=void 0!==v?new Ve(v,d,d):null;c&&o.push(c),d._secondary=c,e=f,t=p}else d._secondary=c,c&&(c.term=d),c instanceof qe&&c.length++}this._sheets=a.filter((function(e){return!0}))}}]),e}();function ur(e){var t=2;for(e=e-1>>1;e;)t<<=1,e>>=1;return t}cr.prototype.id="Complex",cr.prototype.name="";var hr=function(){function e(t,r,n,i,o,a){if(s(this,e),this._box=n.clone(),this._dimVec=Math.max(Math.floor(i||1),1),this._volumeInfo=a,r instanceof Array){var l=v(r,3);this._dimX=l[0],this._dimY=l[1],this._dimZ=l[2]}else this._dimX=r.x,this._dimY=r.y,this._dimZ=r.z;switch(this._dimX=Math.max(Math.floor(this._dimX),1),this._dimY=Math.max(Math.floor(this._dimY),1),this._dimZ=Math.max(Math.floor(this._dimZ),1),this._rowElements=this._dimVec*this._dimX,this._planeElements=this._rowElements*this._dimY,this._totalElements=this._planeElements*this._dimZ,this._data=o||$.allocateTyped(t,this._totalElements),this._dimVec){case 1:break;case 2:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1]]},this.setValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]=n,this._data[o+1]=i},this.addValue=function(e,t,r,n,i){var o=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[o]+=n,this._data[o+1]+=i};break;case 3:this.getValue=function(e,t,r){var n=e*this._dimVec+t*this._rowElements+r*this._planeElements;return[this._data[n],this._data[n+1],this._data[n+2]]},this.setValue=function(e,t,r,n,i,o){var s=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[s]=n,this._data[s+1]=i,this._data[s+2]=o},this.addValue=function(e,t,r,n,i,o){var s=e*this._dimVec+t*this._rowElements+r*this._planeElements;this._data[s]+=n,this._data[s+1]+=i,this._data[s+2]+=o};break;default:throw new Error("Volume: invalid vector dimension")}}return l(e,[{key:"getValue",value:function(e,t,r){return this._data[e+t*this._rowElements+r*this._planeElements]}},{key:"setValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]=n}},{key:"addValue",value:function(e,t,r,n){this._data[e+t*this._rowElements+r*this._planeElements]+=n}},{key:"getDimensions",value:function(){return[this._dimX,this._dimY,this._dimZ]}},{key:"getBox",value:function(){return this._box}},{key:"getVolumeInfo",value:function(){return this._volumeInfo}},{key:"getCellSize",value:function(){var e=new i.Pq0;this._box.getSize(e);var t=new i.Pq0;return t.x=this._dimX>1?e.x/(this._dimX-1):0,t.y=this._dimY>1?e.y/(this._dimY-1):0,t.z=this._dimZ>1?e.z/(this._dimZ-1):0,t}},{key:"computeGradient",value:function(){if(1!==this._dimVec)return null;var t=new e(Float32Array,[this._dimX,this._dimY,this._dimZ],this._box,3),r=this.getCellSize(),n=new i.Pq0(-.5/r.x,-.5/r.y,-.5/r.z);function o(e,t,r){return Math.min(r,Math.max(t,e))}var s=this._dimX,a=this._dimY,l=this._dimZ,c=this._data;function u(e,t,r){return c[r*s*a+t*s+e]}for(var h=0;h<l;++h)for(var f=o(h-1,0,l-1),d=o(h+1,0,l-1),p=0;p<a;++p)for(var m=o(p-1,0,a-1),v=o(p+1,0,a-1),y=0;y<s;++y){var _=o(y-1,0,s-1),g=o(y+1,0,s-1);t.setValue(y,p,h,(u(g,p,h)-u(_,p,h))*n.x,(u(y,v,h)-u(y,m,h))*n.y,(u(y,p,d)-u(y,p,f))*n.z)}return t}},{key:"normalize",value:function(){for(var e=this._data,t=e[0],r=e[0],n=1;n<e.length;++n)t=Math.min(t,e[n]),r=Math.max(r,e[n]);var i=1/(r-t);if(0!==i)for(var o=0;o<e.length;++o)e[o]=i*(e[o]-t)}},{key:"getTiledTextureStride",value:function(){return[this._dimX+2,this._dimY+2]}},{key:"buildTiledTexture",value:function(){var e=Math.ceil(Math.sqrt(this._dimZ*this._dimY/this._dimX)),t=e*(this._dimX+2)-1;t=ur(t),e=Math.floor(t/(this._dimX+2));var r=Math.ceil(this._dimZ/e),n=r*(this._dimY+2)-1;n=ur(n);for(var o,s,a=new Uint8Array(t*n),l=0;l<r;++l)for(var c=0;c<this._dimY;++c){o=l*e*this._planeElements+c*this._rowElements,s=t*(l*(this._dimY+2)+c);for(var u=0;u<e;++u){for(var h=0;h<this._dimX;++h)a[s++]=255*this._data[o++];a[s++]=255*this._data[o-1],u<e-1&&(o+=this._planeElements-this._rowElements,a[s++]=255*this._data[o])}}for(var f=0;f<r;++f){s=(o=t*(f*(this._dimY+2)+this._dimY-1))+t;for(var d=0;d<t;++d)a[s++]=a[o++];if(f<r-1){s=(o=t*(f+1)*(this._dimY+2))-t;for(var p=0;p<t;++p)a[s++]=a[o++]}}var m=new i.GYF(a,t,n,i.Kzv,i.OUM,i.UTZ,i.ghU,i.ghU,i.k6q,i.k6q);return m.needsUpdate=!0,m}},{key:"getData",value:function(){return this._data}},{key:"getDirectIdx",value:function(e,t,r){return e*this._dimVec+t*this._rowElements+r*this._planeElements}},{key:"getStrideX",value:function(){return this._dimVec}},{key:"getStrideY",value:function(){return this._rowElements}},{key:"getStrideZ",value:function(){return this._planeElements}}]),e}();hr.prototype.id="Volume";var fr=function(){function e(t,r,n){s(this,e),this.complex=t,this.name=r||"",this.residues=[],this.mask=1,this.index=n||-1}return l(e,[{key:"forEachResidue",value:function(e){for(var t=this.residues,r=0,n=t.length;r<n;++r)e(t[r])}},{key:"collectMask",value:function(){for(var e=4294967295,t=this.residues,r=0,n=t.length;r<n;++r)e&=t[r]._mask;this.mask=e}}]),e}(),dr={Atom:Re,Element:Ce,Bond:Ee,Residue:Oe,ResidueType:Le,Chain:Fe,Helix:qe,Strand:Ye,Sheet:Xe,SGroup:$e,Assembly:Rt,Complex:cr,Volume:hr,VoxelWorld:Wt,selectors:wt,Molecule:fr};var pr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;s(this,i);var r=c(t=n.call(this));return t._element=e,t._element.style.position="absolute",t.addEventListener("removed",(function(){null!==r._element.parentNode&&r._element.parentNode.removeChild(r._element)})),t}return l(i,[{key:"getElement",value:function(){return this._element}},{key:"setTransparency",value:function(e){var t=this.getElement();if(null!==t)if(1!==e){t.style.display="inline";var r=1-e,n=r.toString(),i=100*r;t.style.opacity=n,t.style.filter="alpha(opacity=".concat(i,")")}else t.style.display="none"}},{key:"clone",value:function(){var e=new i(this._element);return e.copy(this),e}}]),i}(i.B69);var mr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){if(this.visible)for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].raycast(e,t)}},{key:"enableSubset",value:function(e,t){for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].enableSubset&&r[n].enableSubset(e,t)}},{key:"disableSubset",value:function(e,t){for(var r=this.children,n=0,i=r.length;n<i;++n)r[n].disableSubset&&r[n].disableSubset(e,t)}},{key:"isEmpty",value:function(){return 0===this.children.length}},{key:"updateToFrame",value:function(e){for(var t=this.children,r=0,n=t.length;r<n;++r)t[r].updateToFrame&&t[r].updateToFrame(e)}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=n.length;i<o;++i)n[i].getSubset&&Array.prototype.push.apply(r,n[i].getSubset(e,t));return r}}]),i}(i.YJl),vr="uniform mat4 projectionMatrix;\r\nuniform mat4 modelViewMatrix;\r\n\r\nattribute vec2 uv;\r\nattribute vec3 position;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vUv = uv;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\r\n}\r\n";var yr,_r,gr={DEFAULT:0,VOLUME:1,TRANSPARENT:2,PREPASS_TRANSPARENT:3,VOLUME_BFPLANE:4,COLOR_FROM_POSITION:5,SHADOWMAP:6},xr=[gr.DEFAULT,gr.TRANSPARENT];i.B69.prototype.resetTransform=function(){this.position.set(0,0,0),this.quaternion.set(0,0,0,1),this.scale.set(1,1,1)},i.B69.prototype.updateMatrixWorldRecursive=function(){null!=this.parent&&this.parent.updateMatrixWorldRecursive(),this.updateMatrixWorld()},i.B69.prototype.addSavingWorldTransform=(yr=new i.kn4,function(e){e instanceof i.B69&&(yr.copy(this.matrixWorld).invert(),yr.multiply(e.matrixWorld),e.matrix.copy(yr),e.matrix.decompose(e.position,e.quaternion,e.scale),this.add(e))}),i.JeP.prototype.renderDummyQuad=function(){var e=new i.V9B({transparent:!0,opacity:0,depthWrite:!1}),t=new i.Z58,r=new i.eaF(new i.pxj(.01,.01),e);t.add(r);var n=new i.qUd(-.5,.5,.5,-.5,-1e4,1e4);return n.position.z=100,function(){this.render(t,n)}}(),i.JeP.prototype.renderScreenQuad=function(){var e=new i.Z58,t=new i.eaF(new i.pxj(1,1));e.add(t);var r=new i.qUd(-.5,.5,.5,-.5,-1e4,1e4);return r.position.z=100,function(n){t.material=n,this.render(e,r)}}(),i.kn4.prototype.isIdentity=(_r=new i.kn4,function(){return _r.equals(this)}),i.kn4.prototype.applyToPointsArray=function(e,t,r){if(!e||!t||t<3)return e;r=r||0;for(var n=this.elements,i=0;i<e.length;i+=t){var o=e[i],s=e[i+1],a=e[i+2],l=1/(n[3]*o+n[7]*s+n[11]*a+n[15]);e[i]=(n[0]*o+n[4]*s+n[8]*a+n[12]*r)*l,e[i+1]=(n[1]*o+n[5]*s+n[9]*a+n[13]*r)*l,e[i+2]=(n[2]*o+n[6]*s+n[10]*a+n[14]*r)*l}return e};var br,wr,Sr=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return s(this,i),void 0===e.uniforms&&(e.uniforms={}),e.uniforms.srcTex={type:"t",value:null},e.vertexShader=vr,e.transparent=!1,e.depthTest=!1,e.depthWrite=!1,n.call(this,e)}return l(i)}(i.D$Q);function Rr(e){e.traverse((function(e){(e instanceof i.eaF||e instanceof i.DXC||e instanceof i.N1A)&&e.geometry.dispose()})),function(e){for(var t=e.children,r=0,n=t.length;r<n;++r){var i=t[r];i.parent=null,i.dispatchEvent({type:"removed"})}e.children=[]}(e)}i.JeP.prototype.renderScreenQuadFromTex=(br=new Sr({uniforms:{opacity:{type:"f",value:1}},fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform float opacity;\r\n\r\nvoid main() {\r\n vec4 color = texture2D(srcTex, vUv);\r\n gl_FragColor = vec4(color.xyz, color.a * opacity);\r\n}\r\n",transparent:!0}),function(e,t){br.uniforms.srcTex.value=e,br.transparent=t<1,br.uniforms.opacity.value=t,this.renderScreenQuad(br)}),i.JeP.prototype.renderScreenQuadFromTexWithDistortion=function(){var e=new Sr({uniforms:{coef:{type:"f",value:1}},fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform float coef;\r\n\r\nvoid main() {\r\n vec2 uv = vUv * 2.0 - 1.0;\r\n float r2 = dot(uv, uv);\r\n vec2 tc = uv * (1.0 + coef * r2);\r\n if (!all(lessThan(abs(tc), vec2(1.0))))\r\n discard;\r\n tc = 0.5 * (tc + 1.0);\r\n gl_FragColor = texture2D(srcTex, tc);\r\n}\r\n"});return function(t,r){e.uniforms.srcTex.value=t,e.uniforms.coef.value=r,this.renderScreenQuad(e)}}(),i.ubm.prototype.setMinimalFov=function(e){this.aspect>=1?this.fov=e:this.fov=i.cj9.radToDeg(2*Math.atan(Math.tan(.5*i.cj9.degToRad(e))/this.aspect))},i.keZ.prototype.updateHalfSized=function(e,t){var r=e.aspect,n=e.fov;e.aspect=r/2,e.setMinimalFov(t),e.updateProjectionMatrix(),this.update(e),e.aspect=r,e.fov=n,e.updateProjectionMatrix()},i.ubm.prototype.setDistanceToFit=function(e,t){this.position.z=e/Math.sin(.5*i.cj9.degToRad(t))},i.tBo.prototype.intersectVisibleObject=function(e,t,r,n){var o=this.intersectObject(e,!1);if(0===o.length)return null;var s,a=Math.min(t.near,r),l=o[0],c=new i.Pq0;for(s=0;s<o.length&&(l=o[s],c.copy(l.point),c.applyMatrix4(t.matrixWorldInverse),!(c.z<=-a));++s);if(s===o.length)return null;var u=Math.min(t.far,n);return c.copy(l.point),c.applyMatrix4(t.matrixWorldInverse),c.z<=-u?null:l},i.kn4.prototype.extractScale=(wr=new i.Pq0,function(e){void 0===e&&(B.debug("extractScale(): new is too expensive operation to do it on-the-fly"),e=wr.clone());var t=this.elements;return e.x=wr.set(t[0],t[1],t[2]).length(),e.y=wr.set(t[4],t[5],t[6]).length(),e.z=wr.set(t[8],t[9],t[10]).length(),this.determinant()<0&&(e.x=-e.x),e}),i.THS.prototype.copyAtList=function(e,t){console.assert(this.itemSize===e.itemSize,"false: BufferAttribute.copyAtList buffers have different item size.");for(var r=this.itemSize,n=0,i=t.length;n<i;++n)for(var o=0;o<r;++o)this.array[n*r+o]=e.array[t[n]*r+o];return this};var Cr=i.CmU.prototype.copy;i.CmU.prototype.copy=function(e){Cr.call(this,e),void 0===this.instanceCount&&(this.instanceCount=1/0)};var kr={calcCylinderMatrix:function(e,t,r){var n=e.clone().lerp(t,.5),o=new i.kn4;o.makeScale(r,e.distanceTo(t),r);var s=new i.kn4;s.makeRotationX(Math.PI/2);var a=new i.kn4,l=new i.Pq0(0,1,0);return a.lookAt(n,t,l),a.multiply(s),a.multiply(o),a.setPosition(n),a},calcChunkMatrix:function(e,t,r,n){var o=new i.kn4;o.makeScale(n.x,n.y,0);var s=new i.kn4;return s.lookAt(e,t,r),s.multiply(o),s.setPosition(e),s},groupHasGeometryToRender:function(e){var t=!1;return e.traverse((function(e){(e.hasOwnProperty("geometry")||e instanceof pr)&&(t=!0)})),t},buildDistorionMesh:function(e,t,r){function n(e){for(var t=0,n=e,i=1;Math.abs(n-t)>1e-5;)t=n,n=e/((i=1+r*n)*i);return 1/i}for(var o=new i.pxj(2,2,e,t),s=o.getAttribute("position"),a=0;a<s.count;++a){var l=s.array[3*a],c=s.array[3*a+1],u=n(l*l+c*c);s.setXY(a,u*l,u*c)}return o},RCGroup:mr,fillArray:function(e,t,r,n){r=void 0!==r?r:0,n=void 0!==n?n:e.length;for(var i=r;i<n;++i)e[i]=t},clearTree:Rr,destroyObject:function(e){Rr(e),e.parent?e.parent.remove(e):e.dispatchEvent({type:"removed"})},belongToSelectLayers:function(e){for(var t=0;t<xr.length;t++)if(1==(e.layers.mask>>xr[t]&1))return!0;return!1},processObjRenderOrder:function(e,t){var r=+("BA"!==t);e.traverse((function(e){e.isGroup&&(e.renderOrder=r)}))},applySelectionMaterial:function(e){e.traverse((function(e){"material"in e&&(e.material=e.material.clone(!0),e.material.setValues({depthFunc:i.xSv,overrideColor:!0,fog:!1,lights:!1,shadowmap:!1}),e.material.setUberOptions({fixedColor:new i.Q1f(16776960),zOffset:-1e-6}))}))},getMiddlePoint:function(e,t,r){var n=r||new i.Pq0;return n.set(0,0,0),n.addScaledVector(e,.5),n.addScaledVector(t,.5),n},LAYERS:gr};var Ar={boundingBox:new i.NRn(new i.Pq0(-1,-1,-1),new i.Pq0(1,1,1)),boundingSphere:new i.iyt(new i.Pq0(0,0,0),1)},Er=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this,e,t)).name=e,r._dataSource=t,r}return l(i,[{key:"release",value:function(){this.parent&&this.parent.remove(this)}},{key:"getDataSource",value:function(){return this._dataSource}},{key:"getBoundaries",value:function(){return Ar}}]),i}(kr.RCGroup);function Pr(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Tr(e){return null==e||Array.isArray(e)?e:[e]}var Mr=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["id"];s(this,e),this._list=[],this._dict={},this._indices=Pr(n),this._indices.forEach((function(e){t._dict[e]={}})),r.forEach((function(e){return t.register(e)}))}return l(e,[{key:"register",value:function(t){var r=this;e.registerInList(this._list,t),this._indices.forEach((function(n){e.registerInDict(r._dict[n],Tr(t[n]),t)}))}},{key:"unregister",value:function(t){var r=this;e.unregisterFromList(this._list,t),this._indices.forEach((function(n){e.unregisterFromDict(r._dict[n],Tr(t[n]),t)}))}},{key:"all",get:function(){return Pr(this._list)}},{key:"first",get:function(){return this._list[0]}},{key:"keys",value:function(e){return Object.keys(this._dict[e||this._indices[0]])}},{key:"get",value:function(e,t){var r=this._dict[t||this._indices[0]];if(r){var n=r[e&&e.toLowerCase()];return n&&n.length>0?n[0]:void 0}}}],[{key:"registerInList",value:function(e,t){e.includes(t)||e.push(t)}},{key:"unregisterFromList",value:function(e,t){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},{key:"registerInDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t]=e[t]||[];n.includes(r)||n.push(r)}))}},{key:"unregisterFromDict",value:function(e,t,r){t.forEach((function(t){t=t.toLowerCase();var n=e[t];if(n){var i=n.indexOf(r);-1!==i&&n.splice(i,1),0===n.length&&delete e[t]}}))}}]),e}();function Ir(e){Object.defineProperties(e,{logger:{get:function(){return this.context&&this.context.logger?this.context.logger:B}},settings:{get:function(){return this.context&&this.context.settings?this.context.settings:J}}})}var Nr=function(){function e(t,r){s(this,e),this._position=t,this._radius=r}return l(e,[{key:"raycast",value:function(t){var r=e._sphere;r.set(this._position,this._radius);var n=new i.Pq0;return t.ray.intersectSphere(r,n)?{distance:t.ray.origin.distanceTo(n),point:n}:null}}]),e}();Se(Nr,"_sphere",new i.iyt);var Or=function(e){return function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;s(this,o);for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return(t=n.call.apply(n,[this].concat(i)))._objects=new Array(e),t.boundingSphere=null,t.boundingBox=null,t}return l(o,[{key:"setSphere",value:function(e,t,r){this._objects[e]=new Nr(t,r)}},{key:"raycast",value:function(e,t){for(var r=0,n=this._objects.length;r<n;++r){var i=this._objects[r].raycast(e);i&&(i.chunkIdx=r,t.push(i))}}},{key:"computeBoundingBox",value:function(){var e=this._objects,t=this.boundingBox;null===t&&(this.boundingBox=t=new i.NRn),t.makeEmpty();for(var r=0,n=e.length;r<n;++r)t.expandByPoint(e[r]._position)}},{key:"computeBoundingSphere",value:function(){this.computeBoundingBox();var e=this._objects,t=this.boundingBox,r=0,n=new i.Pq0;t.getCenter(n);for(var o=0,s=e.length;o<s;++o){var a=e[o]._position,l=n.distanceToSquared(a);r<l&&(r=l)}null===this.boundingSphere&&(this.boundingSphere=new i.iyt),this.boundingSphere.set(n,Math.sqrt(r))}}]),o}(e)};var Lr=new i.Q1f,Br=$.copySubArrays,Dr=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t,r){var n;return s(this,a),(n=o.call(this,e))._sphGeometry=r?new i.pxj(2,2,1,1):new i.WBH(1,2*t,t,0,2*Math.PI,0,Math.PI),n._init(e,n._sphGeometry),n}return l(a,[{key:"setItem",value:function(e,t,r){var n,i,o,s,a,l;n=this._offsets,i=4*e,o=t.x,s=t.y,a=t.z,l=r,n[i]=o,n[i+1]=s,n[i+2]=a,n[i+3]=l,this.setSphere(e,t,r)}},{key:"setColor",value:function(e,t){var r,n,i,o,s;Lr.set(t),r=this._colors,n=3*e,i=Lr.r,o=Lr.g,s=Lr.b,r[n]=i,r[n+1]=o,r[n+2]=s}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("offset").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,n=0,i=e.length;n<i;++n)r[e[n]]=t;this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubset",value:function(e){var t=e.length,r=new i.CmU;return this._init.call(r,t,this._sphGeometry),Br(this._offsets,r._offsets,e,4),Br(this._colors,r._colors,e,3),r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e,t){this.copy(t),this._offsets=$.allocateTyped(Float32Array,4*e),this._colors=$.allocateTyped(Float32Array,3*e);var r=this._alpha=$.allocateTyped(Float32Array,e);(0,n.fill)(r,1),this.setAttribute("offset",new i.uWO(this._offsets,4,!1,1)),this.setAttribute("color",new i.uWO(this._colors,3,!1,1)),this.setAttribute("alphaColor",new i.uWO(r,1,!1,1))}}]),a}(Or(i.CmU));var zr=new i.Q1f,Fr=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;if(s(this,a),(r=o.call(this)).constructor===a)throw new Error("Can not instantiate abstract class!");return r._chunkGeo=e,r._init(e,t),r}return l(a,[{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("position").needsUpdate=!0,this.getAttribute("normal").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0}},{key:"setColor",value:function(e,t){zr.set(t);for(var r=this._colors,n=this._chunkSize,i=e*n,o=i+n;i<o;++i){var s=3*i;r[s]=zr.r,r[s+1]=zr.g,r[s+2]=zr.b}}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,i=this._chunkSize,o=0,s=e.length;o<s;++o){var a=e[o]*i;(0,n.fill)(r,t,a,a+i)}this.getAttribute("alphaColor").needsUpdate=!0}},{key:"raycast",value:function(e,t){var r=[],n=new i.eaF;n.geometry=this,n.raycast(e,r);for(var o=this._chunkGeo.index.count/3,s=0,a=r.length;s<a;++s)r[s].hasOwnProperty("faceIndex")&&(r[s].chunkIdx=Math.floor(r[s].faceIndex/o),t.push(r[s]))}},{key:"getSubset",value:function(e){var t=e.length,r=new i.LoY;this._init.call(r,this._chunkGeo,t);for(var n=this._positions,o=this._normals,s=this._colors,a=r._positions,l=r._normals,c=r._colors,u=3*this._chunkSize,h=0,f=e.length;h<f;++h){var d=h*u,p=e[h]*u,m=p+u;a.set(n.subarray(p,m),d),l.set(o.subarray(p,m),d),c.set(s.subarray(p,m),d)}return r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e,t){var r=this._chunkSize=e.attributes.position.count,o=e.index.array,s=o.length,a=this._chunkSize*t,l=a>65535,c=s*t,u=this._index=$.allocateTyped(l?Uint32Array:Uint16Array,c);this._positions=$.allocateTyped(Float32Array,3*a),this._normals=$.allocateTyped(Float32Array,3*a),this._colors=$.allocateTyped(Float32Array,3*a);var h=this._alpha=$.allocateTyped(Float32Array,a);(0,n.fill)(h,1);for(var f=0;f<t;++f){var d=f*s,p=f*r;u.set(o,d);for(var m=0;m<s;++m)u[d+m]+=p}this.setIndex(new i.THS(this._index,1)),this.setAttribute("position",new i.THS(this._positions,3)),this.setAttribute("normal",new i.THS(this._normals,3)),this.setAttribute("color",new i.THS(this._colors,3)),this.setAttribute("alphaColor",new i.THS(h,1))}}]),a}(i.LoY);var Vr=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;s(this,o);var a=new i.WBH(1,2*t,t,0,2*Math.PI,0,Math.PI),l=(r=n.call(this,e,a,e))._normals,c=a.attributes.normal.array,u=r._chunkSize;r._chunkPos=r._chunkGeo.attributes.position.array,r._tmpPositions=$.allocateTyped(Float32Array,3*u);for(var h=0;h<e;++h)l.set(c,3*u*h);return r}return l(o,[{key:"setItem",value:function(e,t,r){for(var n=this._tmpPositions,i=this._chunkSize,o=this._chunkPos,s=0;s<i;++s){var a=3*s;n[a]=t.x+o[a]*r,n[a+1]=t.y+o[a+1]*r,n[a+2]=t.z+o[a+2]*r}this._positions.set(n,i*e*3),this.setSphere(e,t,r)}}]),o}(Or(Fr));var Ur=new i.Pq0,jr=new i.Pq0,Gr=new i.dwI,Hr=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;s(this,o);var a=new i.Vgf(1,1,1,Math.max(3,t),2,!0),l=(r=n.call(this,a,2*e))._chunkSize;return r._chunkPos=r._chunkGeo.attributes.position.array,r._chunkNorms=r._chunkGeo.attributes.normal.array,r._tmpVector=$.allocateTyped(Float32Array,3*l),r}return l(o,[{key:"setItem",value:function(e,t,r,n){var i=this._chunkSize,o=2*i*e*3,s=o+3*i,a=this._tmpVector,l=this._chunkPos,c=this._chunkNorms;Ur.lerpVectors(t,r,.5);var u,h=kr.calcCylinderMatrix(t,Ur,n);Gr.getNormalMatrix(h);for(var f=0;f<i;++f)u=3*f,jr.fromArray(l,u),jr.applyMatrix4(h),jr.toArray(a,u);this._positions.set(a,o),Ur.sub(t);for(var d=0;d<i;++d)a[u=3*d]+=Ur.x,a[u+1]+=Ur.y,a[u+2]+=Ur.z;this._positions.set(a,s);for(var p=0;p<i;++p)u=3*p,jr.fromArray(c,u),jr.applyMatrix3(Gr),jr.toArray(a,u);this._normals.set(a,o),this._normals.set(a,s)}},{key:"setColor",value:function(e,t,r){var n=2*e;We(d(o.prototype),"setColor",this).call(this,n,t);var i=n+1;We(d(o.prototype),"setColor",this).call(this,i,r)}}]),o}(Fr);var qr=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r,a,l,c){var u;s(this,o),u=n.call(this);var h=2*Math.PI;u.type="CylinderBufferGeometry",u.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:a,heightSegments:l,openEnded:c};var f=!1===c&&e>0,d=!1===c&&t>0,p=(l+1)*a+f*(a+1)+d*(a+1),m=(2*l+f+d)*a,v=r/2,y=new i.THS($.allocateTyped(Float32Array,3*p),3),_=new i.THS($.allocateTyped(Float32Array,3*p),3),g=new i.A$4($.allocateTyped(Uint16Array,3*m),1),x=new i.THS($.allocateTyped(Float32Array,2*p),2);console.assert(p<65536,"false: Cylinder Geometry has too many vertices (65536 max).");for(var b=0,w=0,S=-(t-e)/r,R=0;R<=l;R++){if(R!==l)for(var C=0;C<a;C++){var k=b+C,A=b+a+C,E=b+a+(C+1)%a,P=b+(C+1)%a;g.setXYZ(3*w,k,P,A),w++,g.setXYZ(3*w,A,P,E),w++}for(var T=R/l,M=T*(t-e)+e,I=0;I<a;I++){var N=I/a,O=M*Math.sin(N*h+0),L=T*r-v,B=M*Math.cos(N*h+0),D=new i.Pq0(O,Math.sqrt(O*O+B*B)*S,B).normalize();y.setXYZ(b,O,L,B),_.setXYZ(b,D.x,D.y,D.z),x.setXY(b,N,T),++b}}if(f){for(var z=b,F=b+a,V=0;V<a;++V){var U=b-a;y.setXYZ(b,y.getX(U),y.getY(U),y.getZ(U)),_.setXYZ(b,0,1,0),x.setXY(b,1,1);var j=z+(V+1)%a;g.setXYZ(3*w,b,j,F),w++,b++}y.setXYZ(b,0,v,0),_.setXYZ(b,0,1,0),x.setXY(b,1,1),++b}if(d){for(var G=b,H=b+a,q=0;q<a;++q){var W=q;y.setXYZ(b,y.getX(W),y.getY(W),y.getZ(W)),_.setXYZ(b,0,-1,0),x.setXY(b,0,0);var Y=G+(q+1)%a;g.setXYZ(3*w,Y,b,H),w++,b++}y.setXYZ(b,0,-v,0),_.setXYZ(b,0,-1,0),x.setXY(b,0,0)}return u.setIndex(g),u.setAttribute("position",y),u.setAttribute("normal",_),u.setAttribute("uv",x),u}return l(o,[{key:"clone",value:function(){var e=this.parameters;return new o(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded)}}]),o}(i.LoY);var Wr=new i.Q1f,Yr=new i.kn4,Xr=$.copySubArrays;function $r(e,t,r,n,i){e[t]=r,e[t+1]=n,e[t+2]=i}function Zr(e,t,r,n,i,o){e[t]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o}function Qr(e,t){return e-t}var Kr=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t,r,n){var l;return s(this,a),(l=o.call(this))._useZSprites=r,l._cylGeometry=r?new i.pxj(2,2,1,1):new qr(1,1,1,Math.max(3,t),2,n),l._init(e,l._cylGeometry,l._useZSprites),l._collisionGeo=new Hr(e,3),l}return l(a,[{key:"setItem",value:function(e,t,r,n){var i=kr.calcCylinderMatrix(t,r,n),o=i.elements,s=4*e;this._collisionGeo.setItem(e,t,r,n),Zr(this._matVector1,s,o[0],o[4],o[8],o[12]),Zr(this._matVector2,s,o[1],o[5],o[9],o[13]),Zr(this._matVector3,s,o[2],o[6],o[10],o[14]),this._useZSprites&&(Yr.copy(i).invert(),o=Yr.elements,Zr(this._invmatVector1,s,o[0],o[4],o[8],o[12]),Zr(this._invmatVector2,s,o[1],o[5],o[9],o[13]),Zr(this._invmatVector3,s,o[2],o[6],o[10],o[14]))}},{key:"setColor",value:function(e,t,r){var n=3*e;Wr.set(t),$r(this._color1,n,Wr.r,Wr.g,Wr.b),Wr.set(r),$r(this._color2,n,Wr.r,Wr.g,Wr.b)}},{key:"computeBoundingSphere",value:function(){this._collisionGeo.computeBoundingSphere(),this.boundingSphere=this._collisionGeo.boundingSphere}},{key:"computeBoundingBox",value:function(){this._collisionGeo.computeBoundingBox(),this.boundingBox=this._collisionGeo.boundingBox}},{key:"raycast",value:function(e,t){this._collisionGeo.raycast(e,t)}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("matVector1").needsUpdate=!0,this.getAttribute("matVector2").needsUpdate=!0,this.getAttribute("matVector3").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0,this.getAttribute("color2").needsUpdate=!0,this.getAttribute("alphaColor").needsUpdate=!0,this._useZSprites&&(this.getAttribute("invmatVector1").needsUpdate=!0,this.getAttribute("invmatVector2").needsUpdate=!0,this.getAttribute("invmatVector3").needsUpdate=!0),this._collisionGeo.finishUpdate()}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._alpha,n=0,i=e.length;n<i;++n)r[Math.floor(e[n]/2)]=t;this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubset",value:function(e){var t=function(e){e.sort(Qr);for(var t=[],r=[],n=0,i=e.length;n<i;++n){var o=e[n],s={first:!1,second:!1};(0|o)%2==0?(s.first=!0,s.second=n+1<i&&e[n+1]===e[n]+1,s.second&&++n):s.second=!0,t.push(Math.floor(o/2)),r.push(s)}return{indices:t,cylinderInfo:r}}(e),r=t.indices,n=r.length,o=new i.CmU;return this._init.call(o,n,this._cylGeometry,this._useZSprites),Xr(this._matVector1,o._matVector1,r,4),Xr(this._matVector2,o._matVector2,r,4),Xr(this._matVector3,o._matVector3,r,4),this._useZSprites&&(Xr(this._invmatVector1,o._invmatVector1,r,4),Xr(this._invmatVector2,o._invmatVector2,r,4),Xr(this._invmatVector3,o._invmatVector3,r,4)),Xr(this._color1,o._color1,r,3),Xr(this._color2,o._color2,r,3),function(e,t,r){for(var n=0,i=e.length;n<i;++n){var o=e[n];o.first||(t[3*n]=-.5),o.second||(r[3*n]=-.5)}}(t.cylinderInfo,o._color1,o._color2),o.boundingSphere=this.boundingSphere,o.boundingBox=this.boundingBox,[o]}},{key:"getGeoParams",value:function(){return this._cylGeometry.parameters}},{key:"_init",value:function(e,t,r){this.copy(t),this._matVector1=$.allocateTyped(Float32Array,4*e),this._matVector2=$.allocateTyped(Float32Array,4*e),this._matVector3=$.allocateTyped(Float32Array,4*e),this._color1=$.allocateTyped(Float32Array,3*e),this._color2=$.allocateTyped(Float32Array,3*e);var o=this._alpha=$.allocateTyped(Float32Array,e);(0,n.fill)(o,1),this.setAttribute("matVector1",new i.uWO(this._matVector1,4,!1,1)),this.setAttribute("matVector2",new i.uWO(this._matVector2,4,!1,1)),this.setAttribute("matVector3",new i.uWO(this._matVector3,4,!1,1)),this.setAttribute("color",new i.uWO(this._color1,3,!1,1)),this.setAttribute("color2",new i.uWO(this._color2,3,!1,1)),this.setAttribute("alphaColor",new i.uWO(this._alpha,1,!1,1)),r&&(this._invmatVector1=$.allocateTyped(Float32Array,4*e),this._invmatVector2=$.allocateTyped(Float32Array,4*e),this._invmatVector3=$.allocateTyped(Float32Array,4*e),this.setAttribute("invmatVector1",new i.uWO(this._invmatVector1,4,!1,1)),this.setAttribute("invmatVector2",new i.uWO(this._invmatVector2,4,!1,1)),this.setAttribute("invmatVector3",new i.uWO(this._invmatVector3,4,!1,1)))}}]),a}(i.CmU);var Jr=new i.Pq0,en=new i.Pq0,tn=new i.Pq0,rn=new i.Pq0(1,0,0),nn=new i.Pq0,on=new i.Pq0,sn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r){var a;s(this,o);var l=function(e,t){for(var r=new i.LoY,n=e.length,o=n*t,s=o<=65536?Uint16Array:Uint32Array,a=(t-1)*n*2,l=new i.THS($.allocateTyped(s,3*a),1),c=0,u=0,h=0;h<t;h++){if(h!==t-1)for(var f=0;f<n;f++){var d=c+f,p=c+n+f,m=c+n+(f+1)%n,v=c+(f+1)%n;l.setXYZ(3*u,d,v,p),u++,l.setXYZ(3*u,p,v,m),u++}c+=n}r.setIndex(l);var y=$.allocateTyped(Float32Array,3*o);return r.setAttribute("position",new i.THS(y,3)),r._positions=e,r}(e,t);(a=n.call(this,l,r))._ringsCount=t;for(var c=a._tmpShape=[],u=0;u<e.length;++u)c[u]=new i.Pq0;return a}return l(o,[{key:"setItem",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=this._chunkGeo._positions.length,o=this._ringsCount,s=i*this._ringsCount*e*3;this._setPoints(t,i,o,s),r?this._setSlopeNormals(i,o,s):this._setBaseNormals(i,o,s),n&&this._addCut(i,o,s)}},{key:"_setPoints",value:function(e,t,r,n){for(var i=this._tmpShape,o=this._positions,s=this._chunkGeo._positions,a=0,l=n;a<r;++a)for(var c=e[a],u=0;u<t;++u,l+=3)i[u].copy(s[u]).applyMatrix4(c).toArray(o,l)}},{key:"_setBaseNormals",value:function(e,t,r){for(var n=3*e,i=0,o=r;i<t;++i,o+=n)this._countNormalsInRing(e,o,!1)}},{key:"_setSlopeNormals",value:function(e,t,r){for(var n=this._normals,i=3*e,o=r,s=0;s<e;++s,o+=3)rn.toArray(n,o);if(o-2*i>0)for(var a=0;a<e;++a,o+=3)tn.fromArray(n,o-2*i).toArray(n,o);else this._countNormalsInRing(e,o,!0,+i),o+=i;for(var l=2;l<t;++l,o+=i)this._countNormalsInRing(e,o,!0,-i)}},{key:"_countNormalsInRing",value:function(e,t,r,n){var i=this._tmpShape,o=this._normals;i[0].fromArray(this._positions,t),i[e-1].fromArray(this._positions,t+3*(e-1));for(var s=0;s<e;++s,t+=3)s<e-1&&i[s+1].fromArray(this._positions,t+3),r?(on.fromArray(this._positions,t+n),Jr.subVectors(i[(s+e-1)%e],i[(s+1)%e]).normalize(),en.subVectors(i[s],on).normalize(),tn.crossVectors(en,Jr).normalize().toArray(o,t)):(Jr.subVectors(i[s],i[(s+e-1)%e]).normalize(),en.subVectors(i[s],i[(s+1)%e]).normalize(),tn.addVectors(Jr,en).normalize().toArray(o,t))}},{key:"_addCut",value:function(e,t,r){if(!(e<3||t<2)){var n=this._positions,i=this._normals,o=this._tmpShape,s=3*e;o[0].fromArray(n,r),o[1].fromArray(n,r+3),o[2].fromArray(n,r+6),Jr.subVectors(o[1],o[0]).normalize(),en.subVectors(o[1],o[2]).normalize(),nn.crossVectors(Jr,en).normalize();for(var a=r,l=0;l<2*e;++l,a+=3)nn.toArray(i,a);if(t>2)for(var c=0;c<e;++c,a+=3)tn.fromArray(n,a-s).toArray(n,a)}}}]),o}(Fr);var an=new i.Q1f,ln=new i.Pq0;function cn(e,t,r,n,i){e[t]=r,e[t+1]=n,e[t+2]=i}function un(e,t,r,n,i,o){e[t]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o}function hn(e,t,r,n){var i=4*t,o=i+4*r;return e.subarray(i*n,o*n)}var fn=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e){var t;return s(this,a),(t=o.call(this))._initVertices(e),t}return l(a,[{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.getAttribute("position").needsUpdate=!0,this.getAttribute("color").needsUpdate=!0,this.getAttribute("alphaColor").needsUpdate=!0,this.getAttribute("direction").needsUpdate=!0}},{key:"setColor",value:function(e,t){an.set(t);var r=4*e*3;cn(this._colors,r,an.r,an.g,an.b),r+=3,cn(this._colors,r,an.r,an.g,an.b),r+=3,cn(this._colors,r,an.r,an.g,an.b),r+=3,cn(this._colors,r,an.r,an.g,an.b)}},{key:"setSegment",value:function(e,t,r){ln.subVectors(t,r),ln.normalize();var n=this._positions,i=this._directions,o=4*e*4,s=4*e*3;un(n,o,t.x,t.y,t.z,.5),cn(i,s,ln.x,ln.y,ln.z),s+=3,un(n,o+=4,t.x,t.y,t.z,-.5),cn(i,s,ln.x,ln.y,ln.z),s+=3,un(n,o+=4,r.x,r.y,r.z,.5),cn(i,s,ln.x,ln.y,ln.z),s+=3,un(n,o+=4,r.x,r.y,r.z,-.5),cn(i,s,ln.x,ln.y,ln.z)}},{key:"setOpacity",value:function(e,t,r){var i=4*e,o=4*t;(0,n.fill)(this.alpha,r,o,i),this.getAttribute("alphaColor").needsUpdate=!0}},{key:"getSubsetSegments",value:function(e,t){return[hn(this._positions,e,t,4),hn(this._directions,e,t,3)]}},{key:"getSubsetColors",value:function(e,t){return hn(this._colors,e,t,3)}},{key:"getSubsetOpacities",value:function(e,t){return hn(this._alpha,e,t,1)}},{key:"getNumVertexPerSegment",value:function(){return 4}},{key:"getPositionSize",value:function(){return 4}},{key:"setSegments",value:function(e,t){var r=4*e*4;if(t instanceof Array&&2===t.length){this._positions.set(t[0],r);var n=4*e*3;this._directions.set(t[1],n)}else this._positions.set(t,r)}},{key:"setColors",value:function(e,t){var r=4*e*3;this._colors.set(t,r)}},{key:"_initVertices",value:function(e){this._buffersSize=4*e;var t=this._buffersSize,r=t>65535;this._index=$.allocateTyped(r?Uint32Array:Uint16Array,6*e),this._positions=$.allocateTyped(Float32Array,4*t),this._colors=$.allocateTyped(Float32Array,3*t),this._directions=$.allocateTyped(Float32Array,3*t);var o=this._alpha=$.allocateTyped(Float32Array,t);(0,n.fill)(o,1);for(var s=this._index,a=0,l=0,c=0;c<e;c++,a+=6,l+=4)s[a]=l,s[a+1]=l+1,s[a+2]=l+3,s[a+3]=l,s[a+4]=l+2,s[a+5]=l+3;this.setIndex(new i.THS(this._index,1)),this.setAttribute("position",new i.THS(this._positions,4)),this.setAttribute("color",new i.THS(this._colors,3)),this.setAttribute("alphaColor",new i.THS(o,1)),this.setAttribute("direction",new i.THS(this._directions,3))}}]),a}(i.LoY);var dn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"startUpdate",value:function(){return!0}},{key:"computeBoundingSphere",value:function(){var e=this.boundingBox,t=0,r=new i.Pq0;e&&e.getCenter(r);for(var n=this._positions,o=this.boundingSphere||new i.iyt,s=this._positions.length,a=new i.Pq0,l=this.getPositionSize(),c=0;c<s;c+=l){a.set(n[c],n[c+1],n[c+2]);var u=r.distanceToSquared(a);t<u&&(t=u)}o.set(r,Math.sqrt(t)),this.boundingSphere=o}},{key:"computeBoundingBox",value:function(){for(var e=this._positions,t=new i.NRn,r=this._positions.length,n=new i.Pq0,o=this.getPositionSize(),s=0;s<r;s+=o)n.set(e[s],e[s+1],e[s+2]),t.expandByPoint(n);this.boundingBox=t}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}}]),o}(fn);var pn=new i.Pq0,mn=new i.dwI,vn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;s(this,o);var a=new i.Vgf(1,1,1,Math.max(3,t),2,!0),l=(r=n.call(this,a,e))._chunkSize;return r._chunkPos=r._chunkGeo.attributes.position.array,r._chunkNorms=r._chunkGeo.attributes.normal.array,r._tmpVector=$.allocateTyped(Float32Array,3*l),r}return l(o,[{key:"setItem",value:function(e,t,r,n){var i,o=this._chunkSize,s=o*e*3,a=this._tmpVector,l=this._chunkPos,c=this._chunkNorms,u=kr.calcCylinderMatrix(t,r,n);mn.getNormalMatrix(u);for(var h=0;h<o;++h)i=3*h,pn.fromArray(l,i),pn.applyMatrix4(u),pn.toArray(a,i);this._positions.set(a,s);for(var f=0;f<o;++f)i=3*f,pn.fromArray(c,i),pn.applyMatrix3(mn),pn.toArray(a,i);this._normals.set(a,s)}}]),o}(Fr);var yn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r){var o;return s(this,i),(o=n.call(this,e*t))._init(t),o._collisionGeo=r?new vn(e*t,3):null,o}return l(i,[{key:"startUpdate",value:function(){return!0}},{key:"computeBoundingSphere",value:function(){var e=this._collisionGeo;if(e)return e.computeBoundingSphere(),void(this.boundingSphere=e.boundingSphere);We(d(i.prototype),"computeBoundingSphere",this).call(this)}},{key:"computeBoundingBox",value:function(){var e=this._collisionGeo;if(e)return e.computeBoundingBox(),void(this.boundingBox=e.boundingBox);We(d(i.prototype),"computeBoundingBox",this).call(this)}},{key:"raycast",value:function(e,t){if(this._collisionGeo){var r=this._chunkSize;this._collisionGeo.raycast(e,t);for(var n=0,i=t.length;n<i;++n){var o=t[n].chunkIdx;void 0!==o&&(o=o/r|0,t[n].chunkIdx=o)}}}},{key:"setColor",value:function(e,t){for(var r=this._chunkSize,n=e*r,o=n+r;n<o;++n)We(d(i.prototype),"setColor",this).call(this,n,t)}},{key:"setSegment",value:function(e,t,r,n){var o=this._chunkSize,s=e*o+t;We(d(i.prototype),"setSegment",this).call(this,s,r,n),this._collisionGeo&&this._collisionGeo.setItem(e*o+t,r,n,.1)}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"setOpacity",value:function(e,t){for(var r=this._chunkSize,n=0,o=e.length;n<o;++n){var s=e[n]*r;We(d(i.prototype),"setOpacity",this).call(this,s,s+r-1,t)}}},{key:"getSubset",value:function(e){for(var t=e.length,r=this._chunkSize,n=new i(t,r,!1),o=0,s=e.length;o<s;++o){var a=o*r,l=e[o]*r;n.setSegments(a,this.getSubsetSegments(l,r)),n.setColors(a,this.getSubsetColors(l,r))}return n.boundingSphere=this.boundingSphere,n.boundingBox=this.boundingBox,[n]}},{key:"_init",value:function(e){this._chunkSize=e}}]),i}(dn);var _n=new i.Pq0,gn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return s(this,i),(t=n.call(this,2*e))._init(e),t._collisionGeo=new Hr(e,3),t}return l(i,[{key:"setItem",value:function(e,t,r){this._collisionGeo.setItem(e,t,r,.3);var n=2*e;_n.lerpVectors(t,r,.5),We(d(i.prototype),"setSegment",this).call(this,n,t,_n),We(d(i.prototype),"setSegment",this).call(this,n+1,_n,r)}},{key:"setColor",value:function(e,t,r){var n=2*e;We(d(i.prototype),"setColor",this).call(this,n,t),We(d(i.prototype),"setColor",this).call(this,n+1,r)}},{key:"raycast",value:function(e,t){this._collisionGeo&&this._collisionGeo.raycast(e,t)}},{key:"getSubset",value:function(e){for(var t=e.length,r=new i(t,!1),n=0,o=t;n<o;++n){var s=e[n];r.setSegments(n,this.getSubsetSegments(s,1)),r.setColors(n,this.getSubsetColors(s,1))}return r.boundingSphere=this.boundingSphere,r.boundingBox=this.boundingBox,[r]}},{key:"_init",value:function(e){this._segCounts=2*e}}]),i}(dn);var xn=[new i.Pq0(1,0,0),new i.Pq0(-1,0,0),new i.Pq0(0,1,0),new i.Pq0(0,-1,0),new i.Pq0(0,0,1),new i.Pq0(0,0,-1)],bn=xn.length,wn=new i.Pq0,Sn=new i.Pq0,Rn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return s(this,i),n.call(this,e,e,bn/2|0,!1)}return l(i,[{key:"setItem",value:function(e,t,r){this.setSphere(e,t,r);for(var n=0;n<bn/2;++n){var i=2*n;wn.x=t.x+xn[i].x*r,wn.y=t.y+xn[i].y*r,wn.z=t.z+xn[i].z*r;var o=i+1;Sn.x=t.x+xn[o].x*r,Sn.y=t.y+xn[o].y*r,Sn.z=t.z+xn[o].z*r,this.setSegment(e,n,wn,Sn)}}}]),i}(Or(yn));var Cn=new i.Q1f,kn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this))._opts=t,r.zClip=r._opts.zClip,r._posRad=$.allocateTyped(Float32Array,4*e),r._colors=$.allocateTyped(Float32Array,3*e),r}return l(i,[{key:"setItem",value:function(e,t,r){var n=this._posRad,i=4*e;n[i++]=t.x,n[i++]=t.y,n[i++]=t.z,n[i]=r}},{key:"setColor",value:function(e,t){Cn.set(t);var r=this._colors,n=3*e;r[n++]=Cn.r,r[n++]=Cn.g,r[n]=Cn.b}},{key:"finalize",value:function(){this.finishUpdate(),this.computeBoundingSphere()}},{key:"finishUpdate",value:function(){this._build()}},{key:"setOpacity",value:function(){}},{key:"raycast",value:function(){}},{key:"getSubset",value:function(){return[]}}]),i}(i.LoY),An=function(){function e(){s(this,e),this.pointsValuesLinear=null,this.hasIntersection=null,this.bitsInside=null}return l(e,[{key:"create",value:function(e){var t=e*e*e;if(t>117440512)throw new Error("Too large cube dimension: lead to memory huge uasge");return this.pointsValuesLinear=$.allocateTyped(Float32Array,32*t),this.hasIntersection=$.allocateTyped(Int32Array,t),this.bitsInside=$.allocateTyped(Int32Array,t),0}},{key:"destroy",value:function(){this.bitsInside=null,this.hasIntersection=null,this.pointsValuesLinear=null}}]),e}();An.prototype.striIndicesMarchCube=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1];var En=[0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0],Pn=l((function e(){s(this,e),this._arrSize=8,this.p=new Array(this._arrSize),this.g=new Array(this._arrSize),this.val=new Array(this._arrSize);for(var t=0;t<this._arrSize;++t)this.p[t]=new i.Pq0,this.g[t]=new i.Pq0;this.cubeIndex=0})),Tn=l((function e(){s(this,e),this.a={p:new i.Pq0,n:new i.Pq0},this.b={p:new i.Pq0,n:new i.Pq0},this.c={p:new i.Pq0,n:new i.Pq0}}));function Mn(e){for(var t=new Array(e),r=0;r<e;++r)t[r]=new i.Pq0;return t}var In=function(){function e(){s(this,e),this._numTriangles=0,this._numVertices=0,this._position=[],this._normals=[],this._colors=null,this._indices=[],this._volumetricData=null,this._xAxis=new i.Pq0,this._yAxis=new i.Pq0,this._zAxis=new i.Pq0,this._xDir=new i.Pq0,this._yDir=new i.Pq0,this._zDir=new i.Pq0}return l(e,[{key:"_prepareAxesAndDirs",value:function(){var e=this._volumetricData.getCellSize(),t=this._xAxis,r=this._yAxis,n=this._zAxis,o=this._xDir,s=this._yDir,a=this._zDir;t.set(e.x,0,0),r.set(0,e.y,0),n.set(0,0,e.z),o.set(1,0,0),s.set(0,1,0),a.set(0,0,1);var l=new i.Pq0;if(l.crossVectors(o,s),l.dot(a)<0&&(o.negate(),s.negate(),a.negate()),o.x<0||o.y<0||o.z<0||s.x<0||s.y<0||s.z<0||a.x<0||a.y<0||a.z<0)return!1;var c=function(e){return Math.abs(e)>Number.EPSILON};return!(c(t.y)||c(t.z)||c(r.x)||c(r.z)||c(n.x)||c(n.y))}},{key:"_vertexInterp",value:function(e,t,r,n,i,o){var s=t.p[r],a=t.p[n],l=t.g[r],c=t.g[n],u=t.val[r],h=e-u,f=t.val[n]-u,d=0;Math.abs(f)>0&&(d=h/f),d=d>1?1:d,i.lerpVectors(s,a,d),o.lerpVectors(l,c,d)}},{key:"_polygonize",value:function(t,r,n){for(var i=t.cubeIndex,o=0,s=e._arrSize,a=e._firstIndices,l=e._secondIndices,c=e._vertexList,u=e._normalList;o<s;++o)En[i]&1<<o&&this._vertexInterp(r,t,a[o],l[o],c[o],u[o]);var h=0,f=16*i,d=e._triTable;for(o=0;-1!==d[f+o];o+=3)n[h].a.p.copy(c[d[f+o]]),n[h].a.n.copy(u[d[f+o]]),n[h].b.p.copy(c[d[f+o+1]]),n[h].b.n.copy(u[d[f+o+1]]),n[h].c.p.copy(c[d[f+o+2]]),n[h].c.n.copy(u[d[f+o+2]]),++h;return h}},{key:"_doGridPosNorms",value:function(e,t,r){for(var n,o=this._volumetricData,s=this._volumetricData.getData(),a=o.getDimensions(),l=a[0],c=a[1],u=a[2],h=t*o.getStrideX(),f=t*o.getStrideY(),d=t*o.getStrideZ(),p=new Pn,m=p.val,v=p.val.length,y=[new i.Pq0(0,0,0),new i.Pq0(t,0,0),new i.Pq0(t,t,0),new i.Pq0(0,t,0),new i.Pq0(0,0,t),new i.Pq0(t,0,t),new i.Pq0(t,t,t),new i.Pq0(0,t,t)],_=new Array(5),g=0;g<5;++g)_[g]=new Tn;var x,b=this,w=this._position,S=this._normals;r?(x=new i.Pq0(b._xAxis.x,b._yAxis.y,b._zAxis.z),n=function(e){var t=e.p.clone();t.multiply(x),w.push(t.add(b._origin)),S.push(e.n.clone())}):n=function(){var e=new i.dwI;e.set(b._xAxis.x,b._yAxis.x,b._zAxis.x,b._xAxis.y,b._yAxis.y,b._zAxis.y,b._xAxis.z,b._yAxis.z,b._zAxis.z);var t=new i.dwI;return t.set(b._xDir.x,b._yDir.x,b._zDir.x,b._xDir.y,b._yDir.y,b._zDir.y,b._xDir.z,b._yDir.z,b._zDir.z),function(r){w.push(r.p.clone().applyMatrix3(e).add(b._origin)),S.push(r.n.clone().applyMatrix3(t))}}();for(var R,C,k,A,E=this._indices,P=0,T=0;T<u-t;T+=t)for(var M=0;M<c-t;M+=t)for(var I=o.getDirectIdx(0,M,T),N=0;N<l-t;N+=t,I+=h){m[0]=s[I],m[1]=s[I+h],m[3]=s[I+f],m[2]=s[I+h+f],m[4]=s[I+d],m[5]=s[I+h+d],m[7]=s[I+f+d],m[6]=s[I+h+f+d];for(var O=0,L=0;L<v;++L)m[L]<e&&(O|=1<<L);if(0!==En[O]){for(p.cubeIndex=O,L=0;L<v;++L)p.p[L].set(N+y[L].x,M+y[L].y,T+y[L].z),R=this._gradient,C=p.p[L],k=p.g[L],void 0,A=R.getValue(C.x,C.y,C.z),k.set(A[0],A[1],A[2]);var B=this._polygonize(p,e,_);for(P+=B,L=0;L<B;++L)E.push(3*this._numTriangles),E.push(3*this._numTriangles+1),E.push(3*this._numTriangles+2),++this._numTriangles,n(_[L].a),n(_[L].b),n(_[L].c)}}return P}},{key:"compute",value:function(e,t,r,n){this._volumetricData=e,this._origin=t,this._gradient=e.computeGradient(),this._doGridPosNorms(r,n,this._prepareAxesAndDirs())}},{key:"_remapIndices",value:function(e,t){for(var r=this._indices,n=$.allocateTyped(Uint32Array,t),i=0;i<t;++i)r[i]=e[r[i]],n[i]=r[i];this._indices=n}},{key:"_remapVertices",value:function(e,t,r){for(var n=$.allocateTyped(Float32Array,3*r),i=$.allocateTyped(Float32Array,3*r),o=0;o<r;++o){var s=e[o];n[3*o]=s.x,n[3*o+1]=s.y,n[3*o+2]=s.z;var a=t[o].normalize();i[3*o]=a.x,i[3*o+1]=a.y,i[3*o+2]=a.z}this._position=n,this._normals=i}},{key:"vertexFusion",value:function(e,t){var r=this._indices.length,n=this._position,i=this._normals,o=0|n.length;if(0!==r&&0!==o){var s=$.allocateTyped(Uint32Array,o);s[0]=0;for(var a=1,l=1;l<o;++l){for(var c=a-e<0?0:a-e,u=c+t>a?a:c+t,h=-1,f=c;f<u;++f)if(Math.abs(n[l]-n[f])<Number.EPSILON){h=f;break}-1!==h?s[l]=h:(n[a].copy(n[l]),i[a].copy(i[l]),s[l]=a,++a)}this._remapIndices(s,r),this._remapVertices(n,i,a)}}},{key:"setColorVolTex",value:function(e,t,r,n){var i,o,s,a,l,c,u=this._position.length/3,h=this._position,f=this._origin,d=this._volumetricData.getDimensions(),p=d[0]-1,m=d[1]-1,v=d[2]-1,y=e.getData(),_=e.getStrideX(),g=e.getStrideY(),x=e.getStrideZ();null!==n&&(s=r.getData(),a=r.getStrideX(),l=r.getStrideY(),c=r.getStrideZ());var b=1/this._xAxis.x,w=1/this._yAxis.y,S=1/this._zAxis.z,R=[],C=[],k=$.allocateTyped(Float32Array,3*u);function A(e,t,r,n){n[0]=(1-e)*y[t]+e*y[r],n[1]=(1-e)*y[t+1]+e*y[r+1],n[2]=(1-e)*y[t+2]+e*y[r+2]}function E(e,r,n,i){var o=t[e];if(null!=o){R[o.index]=o;var a=r*n*i*s[e];void 0===C[o.index]?C[o.index]=a:C[o.index]+=a}}var P=$.allocateTyped(Int32Array,u),T=0;for(i=0;i<u;i++){var M=3*i,I=(h[M]-f.x)*b,N=(h[M+1]-f.y)*w,O=(h[M+2]-f.z)*S,L=0|Math.min(Math.max(I,0),p),B=0|Math.min(Math.max(N,0),m),D=0|Math.min(Math.max(O,0),v),z=I-L,F=N-B,V=O-D;if(null!=n){R=[],C=[],E(o=r.getDirectIdx(L,B,D),1-z,1-F,1-V),E(o+a,z,1-F,1-V),E(o+l,1-z,F,1-V),E(o+a+l,z,F,1-V),E(o+c,1-z,1-F,V),E(o+a+c,z,1-F,V),E(o+l+c,1-z,F,V),E(o+a+l+c,z,F,V);var U=0,j=-1;for(var G in C)C[G]>U&&(j=G,U=C[G]);if(j<0||!n.includesAtom(R[j])){P[i]=-1;continue}}P[i]=T++;var H=L<p?_:0,q=B<m?g:0,W=D<v?x:0,Y=[0,0,0],X=[0,0,0],Z=[0,0,0],Q=[0,0,0];A(z,o=e.getDirectIdx(L,B,D),o+H,Y),A(z,o+q,o+H+q,X),A(z,o+W,o+H+W,Z),A(z,o+q+W,o+H+q+W,Q);var K=[0,0,0];K[0]=(1-F)*Y[0]+F*X[0],K[1]=(1-F)*Y[1]+F*X[1],K[2]=(1-F)*Y[2]+F*X[2];var J=[0,0,0];J[0]=(1-F)*Z[0]+F*Q[0],J[1]=(1-F)*Z[1]+F*Q[1],J[2]=(1-F)*Z[2]+F*Q[2],k[M]=(1-V)*K[0]+V*J[0],k[M+1]=(1-V)*K[1]+V*J[1],k[M+2]=(1-V)*K[2]+V*J[2]}if(this._colors=k,null!=n){for(i=0;i<u;++i){var ee=P[i];ee<0||(this._position[3*ee]=this._position[3*i],this._position[3*ee+1]=this._position[3*i+1],this._position[3*ee+2]=this._position[3*i+2],this._normals[3*ee]=this._normals[3*i],this._normals[3*ee+1]=this._normals[3*i+1],this._normals[3*ee+2]=this._normals[3*i+2],this._colors[3*ee]=this._colors[3*i],this._colors[3*ee+1]=this._colors[3*i+1],this._colors[3*ee+2]=this._colors[3*i+2])}var te=this._indices.length/3,re=0;for(i=0;i<te;++i){var ne=P[this._indices[3*i]],ie=P[this._indices[3*i+1]],oe=P[this._indices[3*i+2]];ne>=0&&ie>=0&&oe>=0&&(this._indices[3*re]=ne,this._indices[3*re+1]=ie,this._indices[3*re+2]=oe,++re)}this._position=new Float32Array(this._position.buffer.slice(0,3*T*4)),this._normals=new Float32Array(this._normals.buffer.slice(0,3*T*4)),this._colors=new Float32Array(this._colors.buffer.slice(0,3*T*4)),this._indices=new Uint32Array(this._indices.buffer.slice(0,3*re*4))}}},{key:"toMesh",value:function(){var e=new i.LoY;return e.setIndex(new i.THS(this._indices,1)),e.setAttribute("position",new i.THS(this._position,3)),e.setAttribute("normal",new i.THS(this._normals,3)),e.setAttribute("color",new i.THS(this._colors,3)),e.computeBoundingSphere(),e}}]),e}();Se(In,"_triTable",An.prototype.striIndicesMarchCube),Se(In,"_arrSize",12),Se(In,"_firstIndices",[0,1,2,3,4,5,6,7,0,1,2,3]),Se(In,"_secondIndices",[1,2,3,0,5,6,7,4,4,5,6,7]),Se(In,"_vertexList",Mn(In._arrSize)),Se(In,"_normalList",Mn(In._arrSize));var Nn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){var e=this._opts;this.numVoxels=[128,128,128],this.xAxis=new i.Pq0(1,0,0),this.yAxis=new i.Pq0(0,1,0),this.zAxis=new i.Pq0(0,0,1),this.origin=new i.Pq0(0,0,0),this._visibilitySelector=e.visibilitySelector,this._calcSurface(e)}},{key:"_findMinMax",value:function(e){for(var t=e.length/4,r=[e[0],e[1],e[2],e[3]],n=[e[0],e[1],e[2],e[3]],i=1;i<t;++i)for(var o=4*i,s=0;s<4;++s){var a=e[o+s];r[s]=Math.max(a,r[s]),n[s]=Math.min(a,n[s])}return{maxPosRad:r,minPosRad:n}}},{key:"_findNumVoxels",value:function(e,t){var r=this.numVoxels,n=this._findMinMax(e),i=n.minPosRad,o=n.maxPosRad;i[3]>4&&(t.gridSpacing*=i[3]);var s=t.radScale*o[3]*1.7,a=s;a=.65*Math.sqrt(4/3*Math.PI*a*a*a),s=Math.max(s,a);for(var l=0;l<3;++l)i[l]-=s,o[l]+=s;for(l=0;l<3;++l)r[l]=Math.ceil((o[l]-i[l])/t.gridSpacing);this.xAxis.x=(r[0]-1)*t.gridSpacing,this.yAxis.y=(r[1]-1)*t.gridSpacing,this.zAxis.z=(r[2]-1)*t.gridSpacing;var c=v(i,3);return this.origin.x=c[0],this.origin.y=c[1],this.origin.z=c[2],{bbox:n,dim:r}}},{key:"_makeSurface",value:function(e,t){var r=new In;r.compute(e.volMap,this.origin,t.isoValue,1),r.vertexFusion(9,9),r._numTriangles>0?(r.setColorVolTex(e.volTexMap,e.atomMap,e.atomWeightMap,this._visibilitySelector),this.setIndex(new i.THS(r._indices,1)),this.setAttribute("position",new i.THS(r._position,3)),this.setAttribute("normal",new i.THS(r._normals,3)),this.setAttribute("color",new i.THS(r._colors,3))):this.setAttribute("position",new i.THS($.allocateTyped(Float32Array,0),3))}},{key:"_calcSurface",value:function(e){var t={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};if(0!==t.posRad.length){var r=this._findNumVoxels(t.posRad,e),n=new i.NRn(this.origin,new i.Pq0(this.xAxis.x,this.yAxis.y,this.zAxis.z).add(this.origin)),o=this._computeSurface(t,n,r,e);this._makeSurface(o,e)}}}]),o}(kn);var On=dr.Volume,Ln=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){this._shiftByOrigin(e.posRad);var i={volMap:new On(Float32Array,this.numVoxels,t),volTexMap:new On(Float32Array,this.numVoxels,t,3)};return null!=this._visibilitySelector&&(i.atomMap=[],i.atomWeightMap=new On(Float32Array,this.numVoxels,t)),this.gaussdensity(i,e,null,n),i}},{key:"gaussdensity",value:function(e,t,r,n){var i,o=t.posRad.length/4,s=t.posRad,a=t.colors,l=this.numVoxels,c=n.radScale,u=n.gaussLim,h=n.gridSpacing,f=1/n.isoValue,d=1/h,p=l[0]-1,m=l[1]-1,v=l[2]-1,y=e.volMap,_=e.volTexMap,g=y.getData(),x=y.getStrideX(),b=_.getData(),w=_.getStrideX();null!=this._visibilitySelector&&(i=e.atomWeightMap.getData());for(var S=e.atomMap,R=0;R<o;++R){var C=4*R,k=s[C+3]*c,A=null===r?1:r[R],E=1/(2*k*k),P=u*k,T=P*P;P*=d;var M=s[C]*d,I=Math.max(M-P|0,0),N=Math.min(M+P|0,p);M=s[C+1]*d;var O=Math.max(M-P|0,0),L=Math.min(M+P|0,m);M=s[C+2]*d;for(var B=Math.max(M-P|0,0),D=Math.min(M+P|0,v),z=B*h-s[C+2],F=B;F<=D;++F,z+=h)for(var V=O*h-s[C+1],U=O;U<=L;++U,V+=h){var j=V*V+z*z;if(!(j>=T))for(var G=y.getDirectIdx(I,U,F),H=_.getDirectIdx(I,U,F),q=I*h-s[C],W=I;W<=N;++W,q+=h,G+=x,H+=w){var Y=-(q*q+j)*E,X=Math.exp(Y)*A;null!=this._visibilitySelector&&X>i[G]&&(i[G]=X,S[G]=t.atoms[R]),g[G]+=X,X*=f;var $=3*R;b[H]+=X*a[$],b[H+1]+=X*a[$+1],b[H+2]+=X*a[$+2]}}}}},{key:"_shiftByOrigin",value:function(e){for(var t=this.origin.x,r=this.origin.y,n=this.origin.z,i=e.length/4,o=0;o<i;++o){var s=4*o;e[s]-=t,e[s+1]-=r,e[s+2]-=n}}}]),i}(Nn);function Bn(e,t,r,n){var i=e.length/4,o=t[0],s=t[1],a=t[2],l=r[0],c=r[1],u=r[2];function h(e,t){return Math.floor((e-t)/n)}var f,d,p,m,v,y=h(l,o)+1,_=h(c,s)+1,g=h(u,a)+1,x=y*_*g,b=_*g,w=[];for(f=0;f<i;f++){var S=4*f;p=e[S],m=e[S+1],v=e[S+2],void 0===w[d=(h(p,o)*_+h(m,s))*g+h(v,a)]?w[d]=[f]:w[d].push(f)}var R,C=$.allocateTyped(Uint32Array,x),k=$.allocateTyped(Uint16Array,x),A=$.allocateTyped(Uint32Array,i),E=0,P=0;for(f=0;f<x;f++){var T=C[f]=E,M=w[f];if(void 0!==M)for(R=0;R<M.length;R++)A[E]=M[R],E++;var I=E-T;k[f]=I,I>P&&(P=I)}this.neighbourListLength=27*P+1,this.withinRadii=function(t,r,n,i,l){var c=0,u=h(t,o),p=h(r,s),m=h(n,a),v=Math.max(0,u-1),x=Math.max(0,p-1),w=Math.max(0,m-1),S=Math.min(y-1,u+1),E=Math.min(_-1,p+1),P=Math.min(g-1,m+1);for(f=v;f<=S;++f){var T=f*b;for(R=x;R<=E;++R)for(var M=R*g,I=w;I<=P;++I)for(var N=C[d=T+M+I],O=N+k[d],L=N;L<O;L++){var B=4*A[L],D=e[B]-t,z=e[B+1]-r,F=e[B+2]-n,V=e[B+3]+i;D*D+z*z+F*F<=V*V&&(l[c++]=A[L])}}l[c]=-1}}function Dn(e,t,r,n){var o,s,a,l,c,u,h,f,d,p,m,v,y,_,g,x,b,w=4,S=e.posRad,R=e.colors,C=e.atoms,k=S.length/w,A=t.bbox,E=A.minPosRad,P=A.maxPosRad,T=-1,M=null,I=null,N=null,O=new i.Pq0(0,0,0),L=new i.Pq0(0,0,0),B=new i.Pq0(0,0,0);function D(e,t,r){for(var n=0;n<e.length;n++)e[n]=t+r*n}function z(){a=r.probeRadius,l=r.scaleFactor,c=r.probePositions,N=r.visibilitySelector,o=$.allocateTyped(Float32Array,k),s=0;for(var e=0;e<k;++e){var n=S[e*w+3]+=a;n>s&&(s=n),o[e]=n*n}(function(){l=r.scaleFactor,u=t.dim,b=Math.min(5,2+Math.floor(a*l));var e=u[0]*u[1]*u[2];h=function(e,t,r){for(var n=$.allocateTyped(e,t),i=0;i<t;++i)n[i]=-1001;return n}(Float32Array,e),f=$.allocateTyped(Float32Array,3*e),d=$.allocateTyped(Float32Array,e),N&&(M=$.allocateTyped(Float32Array,e),I=[]),p=$.allocateTyped(Float32Array,u[0]),m=$.allocateTyped(Float32Array,u[1]),v=$.allocateTyped(Float32Array,u[2]),D(p,E[0],1/l),D(m,E[1],1/l),D(v,E[2],1/l)})(),function(){var e=0,t=2*Math.PI/c;_=$.allocateTyped(Float32Array,c),y=$.allocateTyped(Float32Array,c);for(var r=0;r<c;r++)_[r]=Math.cos(e),y[r]=Math.sin(e),e+=t}(),g=new Bn(S,E,P,2.01*s),x=new Int32Array(g.neighbourListLength),T=-1}function F(e,t,r,n){var i=w*e,s=o[e],a=S[i]-t,l=S[i+1]-r,c=S[i+2]-n;return a*a+l*l+c*c<s}function V(e,t,r,n,i){var o;if(-1!==T){if((o=T)!==n&&o!==i&&F(o,e,t,r))return o;T=-1}var s=0;for(o=x[s];o>=0;){if(o!==n&&o!==i&&F(o,e,t,r))return T=o,o;o=x[++s]}return T=-1,-1}function U(e,t){var r=w*e,n=w*t,i=S[r],o=S[r+1],s=S[r+2],a=S[r+3],f=O.x=S[n]-i,d=O.y=S[n+1]-o,g=O.z=S[n+2]-s,x=S[n+3],R=f*f+d*d+g*g,C=Math.sqrt(R),k=a*((a*a+C*C-x*x)/(2*a*C));O.normalize(),function(e,t){e.x=e.y=e.z=1,0!==t.x?e.x=(t.y+t.z)/-t.x:0!==t.y?e.y=(t.x+t.z)/-t.y:0!==t.z&&(e.z=(t.x+t.y)/-t.z)}(L,O),L.normalize(),B.crossVectors(O,L),B.normalize();var A=Math.sqrt(a*a-k*k);L.multiplyScalar(A),B.multiplyScalar(A),O.multiplyScalar(k),O.x+=i,O.y+=o,O.z+=s,T=-1;for(var P=b,M=0;M<c;M++){var I=_[M],N=y[M],D=O.x+I*L.x+N*B.x,z=O.y+I*L.y+N*B.y,F=O.z+I*L.z+N*B.z;if(-1===V(D,z,F,e,t))for(var U=Math.floor(l*(D-E[0])),j=Math.floor(l*(z-E[1])),G=Math.floor(l*(F-E[2])),H=Math.max(0,U-P),q=Math.max(0,j-P),W=Math.max(0,G-P),Y=Math.min(u[0],U+P+2),X=Math.min(u[1],j+P+2),$=Math.min(u[2],G+P+2),Z=W;Z<$;Z++){g=F-v[Z];for(var Q=u[1]*u[0]*Z,K=q;K<X;K++)for(var J=g*g+(d=z-m[K])*d,ee=Q+u[0]*K,te=H;te<Y;te++){R=J+(f=D-p[te])*f;var re=te+ee,ne=h[re];ne>0&&R<ne*ne&&(h[re]=Math.sqrt(R))}}}}this.build=function(){console.time("ContactSurface.getVolume"),console.time("ContactSurface.init"),z(),console.timeEnd("ContactSurface.init"),console.time("ContactSurface.projectPoints"),function(){for(var e=0;e<k;e++){var t=w*e,r=S[t],n=S[t+1],i=S[t+2],s=S[t+3],a=o[e];g.withinRadii(r,n,i,s,x);for(var c=Math.ceil(s*l),y=Math.floor(l*(r-E[0])),_=Math.floor(l*(n-E[1])),b=Math.floor(l*(i-E[2])),A=Math.max(0,y-c),P=Math.max(0,_-c),T=Math.max(0,b-c),O=Math.min(u[0],y+c+2),L=Math.min(u[1],_+c+2),B=Math.min(u[2],b+c+2),D=3*e,z=R[D],F=R[D+1],U=R[D+2],j=T;j<B;j++)for(var G=v[j]-i,H=u[1]*u[0]*j,q=P;q<L;q++)for(var W=m[q]-n,Y=G*G+W*W,X=H+u[0]*q,$=A;$<O;$++){var Z=$+X,Q=p[$]-r,K=Y+Q*Q;if(K<a){var J=Math.exp(.28125*-K),ee=3*Z;f[ee]+=z*J,f[ee+1]+=F*J,f[ee+2]+=U*J,d[Z]+=J,null!==N&&J>M[Z]&&(M[Z]=J,I[Z]=C[e]),h[Z]<0&&(h[Z]=-h[Z]);var te=Math.sqrt(K),re=s/te,ne=Q*re,ie=W*re,oe=G*re;if(-1===V(ne+=r,ie+=n,oe+=i,e,-1)){var se=s-te;se<h[Z]&&(h[Z]=se)}}}}}(),console.timeEnd("ContactSurface.projectPoints"),console.time("ContactSurface.projectTorii"),function(){for(var e=0;e<k;e++){var t=w*e;g.withinRadii(S[t],S[t+1],S[t+2],S[t+3],x);for(var r=0,n=x[r];n>=0;)e<n&&U(e,n),n=x[++r]}}(),console.timeEnd("ContactSurface.projectTorii"),function(){for(var e=0,t=h.length;e<t;e++){h[e]<0&&(h[e]=0);var r=d[e];if(r>0){r=1/r;var n=3*e;f[n]*=r,f[n+1]*=r,f[n+2]*=r}}}(),console.timeEnd("ContactSurface.getVolume"),this.volTexMap=f,this.weightsMap=M,this.atomMap=I,this.volMap=h}}var zn=dr.Volume,Fn=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_computeSurface",value:function(e,t,r,n){var i=new Dn(e,r,n);return i.build(),{volMap:new zn(Float32Array,this.numVoxels,t,1,i.volMap),volTexMap:new zn(Float32Array,this.numVoxels,t,3,i.volTexMap),atomMap:i.atomMap,atomWeightMap:new zn(Float32Array,this.numVoxels,t,1,i.weightsMap)}}}]),i}(Nn),Vn=l((function e(t,r){s(this,e),this.coord=new i.Pq0,this.coord.copy(t),this.radius=r,this.colorX=.99999,this.colorY=0,this.colorZ=0,this.atomType=0,this.srcAtom=null})),Un=function(){function e(t,r,n,o,a){s(this,e),this._numAtoms=t,this._atoms=r,this._vBoxMin=new i.Pq0,this._vBoxMax=new i.Pq0,this._vBoxMin.copy(n),this._vBoxMax.copy(o),this._probeRadius=a,this._atomsList=null,this._voxelList=null}return l(e,[{key:"createVoxels",value:function(){var e,t,r=0|this._numAtoms,n=this._atoms,i=this._vBoxMax.x-this._vBoxMin.x,o=this._vBoxMax.y-this._vBoxMin.y,s=this._vBoxMax.z-this._vBoxMin.z,a=i<o?i:o;a=s<a?s:a;var l,c=0,u=0;for(l=0;l<r;l++)c=(t=2*(n[l].radius+this._probeRadius))>c?t:c,u+=t;var h=Math.floor(a/c);h<2&&(h=2),u/=r,this._numCells=h,this._aveRad=u,this._maxRad=c;var f=h,d=h*h,p=h*h*h,m=this._xScale=1/(this._vBoxMax.x-this._vBoxMin.x),v=this._yScale=1/(this._vBoxMax.y-this._vBoxMin.y),y=this._zScale=1/(this._vBoxMax.z-this._vBoxMin.z),_=0,g=m*h,x=v*h,b=y*h;for(l=0;l<r;l++){var w=4.5*(n[l].radius+this._probeRadius)*2,S=Math.floor(g*w+.8),R=Math.floor(x*w+.8),C=Math.floor(b*w+.8);_+=++S*++R*++C}this._voxelList=$.allocateTyped(Int32Array,p);var k=[];if(k.length=_,null===this._voxelList||null===k)return-1;for(l=0;l<p;l++)this._voxelList[l]=-1;for(e=0,l=0;l<r;l++){t=4.5*(n[l].radius+this._probeRadius);var A=Math.floor((n[l].coord.x-this._vBoxMin.x-t)*h*m),E=Math.floor((n[l].coord.y-this._vBoxMin.y-t)*h*v),P=Math.floor((n[l].coord.z-this._vBoxMin.z-t)*h*y),T=Math.floor((n[l].coord.x-this._vBoxMin.x+t)*h*m),M=Math.floor((n[l].coord.y-this._vBoxMin.y+t)*h*v),I=Math.floor((n[l].coord.z-this._vBoxMin.z+t)*h*y);A=A>=0?A:0,E=E>=0?E:0,T=T<h?T:h-1,M=M<h?M:h-1,I=I<h?I:h-1;for(var N=P=P>=0?P:0;N<=I;N++)for(var O=E;O<=M;O++)for(var L=A;L<=T;L++){var B=L+O*f+N*d;if(this._voxelList[B]<0)k[2*e+0]=l,k[2*e+1]=-1,this._voxelList[B]=e,e++;else{var D=this._voxelList[B];this._voxelList[B]=e,k[2*e+0]=l,k[2*e+1]=D,e++}}}return this._atomsList=Int32Array.from(k),0}},{key:"destroyVoxels",value:function(){this._atomsList=null,this._voxelList=null,this._atoms=null,this._vertices=null,this._vBoxMin=null,this._vBoxMax=null}},{key:"forEachRelatedAtom",value:function(e,t){for(var r=Math.floor((e.x-this._vBoxMin.x)*this._numCells*this._xScale),n=Math.floor((e.y-this._vBoxMin.y)*this._numCells*this._yScale),i=Math.floor((e.z-this._vBoxMin.z)*this._numCells*this._zScale),o=r+n*this._numCells+i*this._numCells*this._numCells,s=this._atoms,a=this._voxelList[o];a>=0;a=this._atomsList[2*a+1])t(s[this._atomsList[2*a]])}},{key:"getClosestAtom",value:function(e){var t=null,r=Number.MAX_VALUE;return this.forEachRelatedAtom(e,(function(n){var i=e.distanceToSquared(n.coord);i<r&&(r=i,t=n)})),t}},{key:"buildNormals",value:function(e,t,r){for(var n,i=this,o=0,s=0,a=0,l=0,c=0,u=0,h=0,f=0,d=0,p=2.5*this._aveRad,m=p*p,v=.1*-this._aveRad,y=function(e){var t=s-e.coord.x,r=a-e.coord.y,p=l-e.coord.z;if(!((n=t*t+r*r+p*p)>m)){var y=e.radius+i._probeRadius;(f=n-y*y)<0&&(f=-f),d=Math.exp(v*f),c+=t*d,u+=r*d,h+=p*d,o++}},_=0;_<e;_++)s=t[_].x,a=t[_].y,l=t[_].z,o=0,c=u=h=0,this.forEachRelatedAtom(t[_],y),n=c*c+u*u+h*h,o>0&&(f=1/Math.sqrt(n),c*=f,u*=f,h*=f),r[_].x=c,r[_].y=u,r[_].z=h;return 0}},{key:"buildColors",value:function(e,t,r,n){for(var i=this,o=0,s=0,a=0,l=0,c=0,u=n*n,h=[],f=[],d=0,p=function(e){var t=o-e.coord.x,r=s-e.coord.y,n=a-e.coord.z,p=t*t+r*r+n*n;if(!(p>u)){var m=e.radius+i._probeRadius;(l=p-m*m)<0&&(l=-l),c=1/(.8+l),h.push([e.colorX,e.colorY,e.colorZ]),f.push(c),d+=c}},m=0;m<e;m++){o=t[m].x,s=t[m].y,a=t[m].z,h=[],f=[],d=0,this.forEachRelatedAtom(t[m],p);for(var v=0;v<h.length;++v){var y=f[v]/d;r[m].x+=h[v][0]*y,r[m].y+=h[v][1]*y,r[m].z+=h[v][2]*y}}return 0}}]),e}(),jn=function(){function e(t,r,n){var o;for(s(this,e),this._maxNumVertices=t,this._maxNumTriangles=r,this._vertices=new Array(t),this._normals=new Array(t),this._colors=null,n&&(this._colors=new Array(t)),this._indices=new Array(3*r),this._numVertices=0,this._numTriangles=0,o=0;o<t;o++)this._vertices[o]=new i.Pq0,this._normals[o]=new i.Pq0;for(o=0;o<3*r;o++)this._indices[o]=-1;if(n)for(o=0;o<t;o++)this._colors[o]=new i.Pq0}return l(e,[{key:"destroy",value:function(){this._vertices=null,this._normals=null,this._indices=null}}]),e}();var Gn=dr.Element,Hn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){this._innerBuild();var e=this.getGeo();this.destroy(),this._fromGeo(e)}},{key:"_fromGeo",value:function(e){var t=null,r=$.allocateTyped(Float32Array,3*e._numVertices),n=$.allocateTyped(Float32Array,3*e._numVertices);null!==e._colors&&(t=$.allocateTyped(Float32Array,3*e._numVertices));for(var o=$.allocateTyped(Uint32Array,3*e._numTriangles),s=0,a=0;s<e._numVertices;s++)r[a+0]=e._vertices[s].x,r[a+1]=e._vertices[s].y,r[a+2]=e._vertices[s].z,n[a+0]=e._normals[s].x,n[a+1]=e._normals[s].y,n[a+2]=e._normals[s].z,a+=3;if(null!==t)for(var l=0,c=0;l<e._numVertices;l++,c+=3)t[c+0]=e._colors[l].x,t[c+1]=e._colors[l].y,t[c+2]=e._colors[l].z;for(var u=3*e._numTriangles,h=0;h<u;h++)o[h]=e._indices[h];this.setIndex(new i.THS(o,1)),this.setAttribute("position",new i.THS(r,3)),this.setAttribute("normal",new i.THS(n,3)),this.setAttribute("color",new i.THS(t,3)),this.computeBoundingBox(),this.computeBoundingSphere(),e.destroy()}},{key:"convertToAtomsColored",value:function(e,t){for(var r=e.atoms,n=e.colors,i=0,o=r.length;i<o;i++){var s=r[i].position,a=r[i].element.radius;t[i]=new Vn(s,a);var l=r[i].element.number;t[i].atomType=this.getType(l);var c=3*i;t[i].colorX=n[c++],t[i].colorY=n[c++],t[i].colorZ=n[c],t[i].srcAtom=r[i]}}},{key:"getGeo",value:function(){return this.geoOut}},{key:"destroy",value:function(){this.atoms=null,this.hashLines=null,this.hashEntries=null}},{key:"getBoundingBox",value:function(e,t,r){var n=1e7;t.x=t.y=t.z=n,r.x=r.y=r.z=0-n;for(var i=this.probeRadius*this.atomRadiusScale,o=0,s=0,a=e.length;s<a;s++){var l=e[s].coord,c=e[s].radius+i;o=c>o?c:o,l.x-c<t.x&&(t.x=l.x-c),l.y-c<t.y&&(t.y=l.y-c),l.z-c<t.z&&(t.z=l.z-c),l.x+c>r.x&&(r.x=l.x+c),l.y+c>r.y&&(r.y=l.y+c),l.z+c>r.z&&(r.z=l.z+c)}t.x-=o,t.y-=o,t.z-=o,r.x+=o,r.y+=o,r.z+=o}},{key:"getCornerCoord",value:function(e,t,r,n,i,o,s){var a=1/(o-1),l=r*a,c=n*a,u=i*a;s.x=e.x*(1-l)+t.x*l,s.y=e.y*(1-c)+t.y*c,s.z=e.z*(1-u)+t.z*u}},{key:"buildEdgePoint",value:function(e,t,r,n,i,o){if(r[e]^r[t]){var s=(0-n.pointsValuesLinear[i+24+e])/(n.pointsValuesLinear[i+24+t]-n.pointsValuesLinear[i+24+e]),a=n.pointsValuesLinear[i+3*e+0],l=n.pointsValuesLinear[i+3*e+1],c=n.pointsValuesLinear[i+3*e+2],u=n.pointsValuesLinear[i+3*t+0],h=n.pointsValuesLinear[i+3*t+1],f=n.pointsValuesLinear[i+3*t+2];o.x=a*(1-s)+u*s,o.y=l*(1-s)+h*s,o.z=c*(1-s)+f*s}}},{key:"isTriangleVisible",value:function(e,t,r){var n=this.voxelWorld.getClosestAtom(e),i=this.voxelWorld.getClosestAtom(t),o=this.voxelWorld.getClosestAtom(r);return null!==n&&null!==i&&null!==o&&null!==n.srcAtom&&null!==i.srcAtom&&null!==o.srcAtom&&this.visibilitySelector.includesAtom(n.srcAtom)&&this.visibilitySelector.includesAtom(i.srcAtom)&&this.visibilitySelector.includesAtom(o.srcAtom)}},{key:"addTriangle",value:function(e,t,r){if(this.visibilitySelector&&!this.isTriangleVisible(e,t,r))return!0;var n=this.geoOut;if(n._numTriangles>=this.maxNumTriangles)return!1;var i=this.addVertexToGeo(n,e),o=this.addVertexToGeo(n,t),s=this.addVertexToGeo(n,r);if((i|o|s)<0)return!1;var a=3*n._numTriangles;return n._indices[a+0]=i,n._indices[a+1]=o,n._indices[a+2]=s,n._numTriangles++,!0}},{key:"buildGeoFromCorners",value:function(e,t,r,n,o,s){for(var a=e-1,l=e,c=e*e,u=new Array(12),h=0;h<12;h++)u[h]=new i.Pq0;for(var f=[],d=0;d<8;d++)f[d]=1;for(var p=new i.Pq0,m=0,v=0,y=0;y<a;y++,v+=c)for(var _=0,g=0;g<a;g++,_+=l)for(var x=0;x<a;x++)if(s.hasIntersection[m]){var b=s.bitsInside[m];this.getCornerCoord(t,r,x,y,g,e,p);for(var w=32*m,S=0,R=0;S<8;S++)s.pointsValuesLinear[w+R++]=p.x,s.pointsValuesLinear[w+R++]=p.y,s.pointsValuesLinear[w+R++]=p.z;s.pointsValuesLinear[w+3]+=o.x,s.pointsValuesLinear[w+6]+=o.x,s.pointsValuesLinear[w+15]+=o.x,s.pointsValuesLinear[w+18]+=o.x,s.pointsValuesLinear[w+6+2]+=o.z,s.pointsValuesLinear[w+9+2]+=o.z,s.pointsValuesLinear[w+18+2]+=o.z,s.pointsValuesLinear[w+21+2]+=o.z,s.pointsValuesLinear[w+12+1]+=o.y,s.pointsValuesLinear[w+15+1]+=o.y,s.pointsValuesLinear[w+18+1]+=o.y,s.pointsValuesLinear[w+21+1]+=o.y;for(var C=w+24,k=0;k<8;++k)f[k]=s.pointsValuesLinear[C+k]<0?1:0;this.buildEdgePoint(0,1,f,s,w,u[0]),this.buildEdgePoint(1,2,f,s,w,u[1]),this.buildEdgePoint(2,3,f,s,w,u[2]),this.buildEdgePoint(3,0,f,s,w,u[3]),this.buildEdgePoint(4,5,f,s,w,u[4]),this.buildEdgePoint(5,6,f,s,w,u[5]),this.buildEdgePoint(6,7,f,s,w,u[6]),this.buildEdgePoint(7,4,f,s,w,u[7]),this.buildEdgePoint(0,4,f,s,w,u[8]),this.buildEdgePoint(1,5,f,s,w,u[9]),this.buildEdgePoint(2,6,f,s,w,u[10]),this.buildEdgePoint(3,7,f,s,w,u[11]);for(var A=16*b,E=0,P=0;E<6;E++,P+=3){var T=s.striIndicesMarchCube[A+P];if(T<0)break;var M=s.striIndicesMarchCube[A+P+1],I=s.striIndicesMarchCube[A+P+2];if(!this.addTriangle(u[T],u[M],u[I]))return-2}m++}else m++;return 0}},{key:"getNumIntersectedCells",value:function(e,t,r,n){for(var i=e*e,o=0,s=0,a=0,l=0;l<t;l++,a+=i)for(var c=0,u=0;u<t;u++,c+=e)for(var h=0;h<t;h++){var f=32*s+24,d=h+c+a;n.pointsValuesLinear[f]=r[d],n.pointsValuesLinear[f+1]=r[d+1],n.pointsValuesLinear[f+2]=r[d+e+1],n.pointsValuesLinear[f+3]=r[d+e],n.pointsValuesLinear[f+4]=r[i+d],n.pointsValuesLinear[f+5]=r[i+d+1],n.pointsValuesLinear[f+6]=r[i+d+e+1],n.pointsValuesLinear[f+7]=r[i+d+e];for(var p=0,m=0;m<8;++m)n.pointsValuesLinear[f+m]<0&&(p|=1<<m);0===p||255===p?n.hasIntersection[s]=!1:(n.hasIntersection[s]=!0,o++),n.bitsInside[s]=p,s++}return o}},{key:"getType",value:function(e){var t=[0,0,1,1,2,6,3,6,4,6,5,6,6,0,7,3,8,2,9,6,10,6,11,6,12,6,13,6,14,6,15,4,16,5,17,6,18,6,19,6,20,6,21,6,22,6,23,6,24,6,25,6,26,6,27,6,28,6,29,6,30,6,31,6,32,6,33,6,34,6,35,6,36,6,37,6,38,6,39,6,40,6,41,6,42,6,43,6,44,6,45,6,46,6,47,6,48,6,49,6,50,6,51,6,52,6,53,6,54,6,55,6,56,6,57,6,58,6,59,6,60,6,61,6,62,6,63,6,64,6,65,6,66,6,67,6,68,6,69,6,70,6,71,6,72,6,73,6,74,6,75,6,76,6,77,6,78,6,79,6,80,6,81,6,82,6,83,6,84,6,85,6,86,6,87,6,88,6,89,6,90,6,91,6,92,6,93,6,94,6,95,6,96,6,97,6,98,6,99,6,100,6,101,6,102,6,103,6,104,6,105,6,106,6,107,6,108,6,109,6];if(e<1||e>t.length/2||2*Object.keys(Gn.ByAtomicNumber).length!==t.length)throw new Error("atomT.length should be equal Element.ByAtomicNumber.length * 2");return t[2*e]}},{key:"calculateGridCorners",value:function(e,t,r,n,o,s){for(var a=t*t,l=a*t,c=new i.Pq0,u=new i.Pq0,h=0;h<l;h++)e[h]=1e12;for(var f=(t-1)/(n.x-r.x),d=(t-1)/(n.y-r.y),p=(t-1)/(n.z-r.z),m=0,v=o.length;m<v;m++){var y=o[m],_=y.radius+s,g=(y.coord.x-_-r.x)*f,x=(y.coord.y-_-r.y)*d,b=(y.coord.z-_-r.z)*p,w=Math.floor(g),S=Math.floor(x),R=Math.floor(b),C=Math.floor((y.coord.x+_-r.x)*f),k=Math.floor((y.coord.y+_-r.y)*d),A=Math.floor((y.coord.z+_-r.z)*p);C=++C<=t-1?C:t-1,k=++k<=t-1?k:t-1,A=++A<=t-1?A:t-1;for(var E=S;E<=k;E++)for(var P=E*a,T=R;T<=A;T++)for(var M=T*t,I=w;I<=C;I++){var N=P+M+I;this.getCornerCoord(r,n,I,E,T,t,c),u.x=c.x-y.coord.x,u.y=c.y-y.coord.y,u.z=c.z-y.coord.z;var O=Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z)-_;O<e[N]&&(e[N]=O)}}}},{key:"createVertexHash",value:function(e,t){if(this.hashLines=$.allocateTyped(Int32Array,65536),null===this.hashLines)return-1;for(var r=0,n=0;r<32768;r++)this.hashLines[n++]=0,this.hashLines[n++]=-1;if(this.maxNumVertices=e,this.maxNumTriangles=t,this.numHashEtriesAllocated=e,this.hashEntries=$.allocateTyped(Int32Array,2*this.numHashEtriesAllocated),null===this.hashEntries)return-1;for(var i=0,o=0;i<this.numHashEtriesAllocated;i++)this.hashEntries[o++]=-1,this.hashEntries[o++]=-1;return this.numHashEntryIndex=0,0}},{key:"getNewHashEntry",value:function(){if(this.numHashEntryIndex<this.numHashEtriesAllocated){var e=this.numHashEntryIndex;return this.numHashEntryIndex++,e}return-1}},{key:"addVertexToGeo",value:function(e,t){var r,n=.01,o=this.marCubeResoultion<<2,s=new i.Pq0,a=Math.floor(o*(t.x-this.vBoxMin.x)/(this.vBoxMax.x+n-this.vBoxMin.x)),l=Math.floor(o*(t.y-this.vBoxMin.y)/(this.vBoxMax.y+n-this.vBoxMin.y)),c=815851*a+37633*Math.floor(o*(t.z-this.vBoxMin.z)/(this.vBoxMax.z+n-this.vBoxMin.z))+2453543*l,u=(c&=32767)+c;if(null!==this.vBoxMin&&null!==this.vBoxMax)for(r=this.hashLines[u+1];r>=0;r=this.hashEntries[2*r+1]){var h=this.hashEntries[2*r+0];if(s.copy(e._vertices[h]),s.x-=t.x,s.y-=t.y,s.z-=t.z,s.x*s.x+s.y*s.y+s.z*s.z<1e-6)return h}if(e._numVertices>=this.maxNumVertices)return-1;var f=e._numVertices;if(e._vertices[f].copy(t),null!==this.vBoxMin&&null!==this.vBoxMax){if((r=this.getNewHashEntry())<0)return-1;var d=this.hashLines[u+1];this.hashLines[u+1]=r,this.hashEntries[2*r+0]=f,this.hashEntries[2*r+1]=d,this.hashLines[u+0]++}return e._numVertices++,f}},{key:"modifyExcludedFromGeo",value:function(e,t,r,n,i,o){for(var s,a,l=e*e,c=(e-1)/(n.x-r.x),u=(e-1)/(n.y-r.y),h=(e-1)/(n.z-r.z),f=2*t*(2*t),d=1/(e-1),p=0;p<i._numVertices;p++){var m=i._vertices[p],v=1.1*t,y=Math.floor((m.x-v-r.x)*c),_=Math.floor((m.y-v-r.y)*u),g=Math.floor((m.z-v-r.z)*h),x=Math.floor((m.x+v-r.x)*c),b=Math.floor((m.y+v-r.y)*u),w=Math.floor((m.z+v-r.z)*h);y=y>=0?y:0,g=g>=0?g:0,x=x<=e-1?x:e-1,b=b<=e-1?b:e-1,w=w<=e-1?w:e-1;for(var S=_=_>=0?_:0;S<=b;S++)for(var R=S*l,C=g;C<=w;C++)for(var k=C*e,A=y;A<=x;A++){s=R+k+A;var E=A*d,P=r.x*(1-E)+n.x*E;E=S*d;var T=r.y*(1-E)+n.y*E;E=C*d;var M=r.z*(1-E)+n.z*E,I=P-m.x,N=T-m.y,O=M-m.z,L=I*I+N*N+O*O;L<f&&((a=-(Math.sqrt(L)-t))>0?(o[s]<0&&(o[s]=a),a>o[s]&&(o[s]=a)):a>o[s]&&(o[s]=a))}}return 0}},{key:"_innerBuild",value:function(){var e,t=1.2,r={posRad:this._posRad,colors:this._colors,atoms:this._opts.atoms};this.complex=this._opts.parent,this.atoms=r.atoms,this.meshResolution=this._opts.gridSpacing,this.atomRadiusScale=this._opts.radScale,this.colorMode=this._opts.colorMode,this.probeRadius=this._opts.probeRadius,this.useVertexColors=!0,this.excludeProbe=this._opts.excludeProbe,this.visibilitySelector=this._opts.visibilitySelector,this.geoOut=null,this.hashLines=null,this.hashEntries=null,this.numHashEtriesAllocated=0,this.numHashEntryIndex=0,this.maxNumVertices=0,this.maxNumTriangles=0;var n=new Array(this.atoms.length);this.convertToAtomsColored(r,n);var o=this.vBoxMin=new i.Pq0,s=this.vBoxMax=new i.Pq0;this.getBoundingBox(n,o,s);var a=this.marCubeResoultion=4*this.meshResolution,l=a,c=l*l*l,u=$.allocateTyped(Float32Array,c),h=this.probeRadius*this.atomRadiusScale;this.calculateGridCorners(u,l,o,s,n,h);var f=a-1,d=new An;if((e=d.create(f))<0)return e;var p=new i.Pq0;p.x=(s.x-o.x)/f,p.y=(s.y-o.y)/f,p.z=(s.z-o.z)/f;var m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2);if(this.geoOut=new jn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;var _=h;if(this.excludeProbe&&(_=.01),this.voxelWorld=new Un(n.length,n,o,s,_),this.voxelWorld.createVoxels(),e=this.buildGeoFromCorners(a,o,s,u,p,d),this.excludeProbe){if(this.modifyExcludedFromGeo(l,h,o,s,this.geoOut,u),this.geoOut._vertices=null,this.geoOut._colors=null,this.geoOut._indices=null,this.geoOut._normals=null,this.geoOut._numVertices=0,this.geoOut._numTriangles=0,this.geoOut=null,m=this.getNumIntersectedCells(l,f,u,d),v=Math.floor(m*t),y=Math.floor(m*t*2),this.geoOut=new jn(v,y,this.useVertexColors),(e=this.createVertexHash(v,y))<0)return e;e=this.buildGeoFromCorners(l,o,s,u,p,d)}this.voxelWorld.buildNormals(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._normals);var g=6.5;return this.excludeProbe&&(g-=1.5),this.useVertexColors&&this.voxelWorld.buildColors(this.geoOut._vertices.length,this.geoOut._vertices,this.geoOut._colors,g),this.voxelWorld.destroyVoxels(),this.voxelWorld=null,d.destroy(),e}}]),o}(kn);var qn=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;s(this,o),(r=n.call(this))._opts=t,r.items=[],r.needsUpdate=!1;var a=-50,l=-50;switch(t.horizontalAlign){case"left":a=0;break;case"right":a=-100}switch(t.verticalAlign){case"top":l=-100;break;case"bottom":l=0}var c=new i.Pq0(t.dx||0,t.dy||0,t.dz||0);return r.userData={translation:"translate(".concat(a,"%, ").concat(l,"%)"),offset:c},r}return l(o,[{key:"setItem",value:function(e,t,r){var n=this._opts,o=this.items[e]||function(e,t){var r=document.createElement("div");if(r.className="label","string"==typeof e){var n=document.createElement("span");n.style.fontSize="150%";for(var o=e.split("\n"),s=0,a=o.length;s<a;++s){var l=document.createElement("span"),c=document.createTextNode(o[s]);l.appendChild(c),n.appendChild(l),s<a-1&&n.appendChild(document.createElement("br"))}r.appendChild(n)}else r.appendChild(e);return r.worldPos=new i.Pq0,r}(r);o.worldPos.copy(t),o.style.textAlign=n.horizontalAlign,o.style.verticalAlign=n.verticalAlign,this.items[e]=o}},{key:"setColor",value:function(e,t,r){this.items[e].opts={color:t,background:r}}},{key:"startUpdate",value:function(){return!0}},{key:"finishUpdate",value:function(){this.needsUpdate=!0,this.dispatchEvent({type:"update"})}},{key:"finalize",value:function(){this.finishUpdate()}},{key:"raycast",value:function(){}},{key:"setOpacity",value:function(){}},{key:"getSubset",value:function(){return[]}}]),o}(I),Wn={InstancedSpheresGeometry:Dr,SimpleSpheresGeometry:Vr,Simple2CCylindersGeometry:Hr,Instanced2CCylindersGeometry:Kr,ExtrudedObjectsGeometry:sn,ChunkedLinesGeometry:yn,TwoColorLinesGeometry:gn,CrossGeometry:Rn,QuickSurfGeometry:Ln,ContactSurfaceGeometry:Fn,SSIsosurfaceGeometry:Hn,LabelsGeometry:qn},Yn={precision:"mediump",init:function(e){this.precision=e.capabilities.getMaxPrecision("highp")}},Xn=new Uint8Array([24,52,0,254,145,0,122,0,0,7,170,0,34,214,0,173,8,0,86,249,0,160,4,0,226,46,0,224,211,0,3,157,0,174,247,0,12,182,0,220,216,0,1,109,0,253,154,0]),$n=i.GJx,Zn=i.GJx,Qn=i.hxR,Kn=i.hxR,Jn=i.UTZ,ei=new i.GYF(Xn,4,4,i.HIg,i.OUM,Jn,$n,Zn,Kn,Qn,1);ei.needsUpdate=!0;var ti={noiseWidth:4,noiseHeight:4,noiseTexture:ei};function ri(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ni(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ri(Object(r),!0).forEach((function(t){Se(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ri(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ii=[new i.I9Y(-.541978,.840393),new i.I9Y(.125533,-.992089),new i.I9Y(.374329,.927296),new i.I9Y(-.105475,.994422)],oi=i.LlO.merge([i.fCn.fog,i.fCn.lights,{diffuse:{value:new i.Q1f(15658734)},opacity:{value:1},specular:{type:"c",value:new i.Q1f(1118481)},shininess:{type:"f",value:30},fixedColor:{type:"c",value:new i.Q1f(16777215)},zOffset:{type:"f",value:0},zClipValue:{type:"f",value:0},clipPlaneValue:{type:"f",value:0},nearPlaneValue:{type:"f",value:-.5},invModelViewMatrix:{type:"4fv",value:new i.kn4},world2colorMatrix:{type:"4fv",value:new i.kn4},dashedLineSize:{type:"f",value:.1},dashedLinePeriod:{type:"f",value:.2},projMatrixInv:{type:"4fv",value:new i.kn4},viewport:{type:"v2",value:new i.I9Y},lineWidth:{type:"f",value:2},fogAlpha:{type:"f",value:1},samplesKernel:{type:"v2v",value:null},noiseTex:{type:"t",value:null},noiseTexelSize:{type:"v2",value:null},srcTexelSize:{type:"v2",value:null}}]),si=["shininess","opacity","zOffset","diffuse","specular","fixedColor","zClipCoef","zClipValue","clipPlaneValue","world2colorMatrix","dashedLineSize","dashedLinePeriod","projMatrixInv","viewport","lineWidth","fogAlpha","samplesKernel","noiseTex","noiseTexelSize","srcTexelSize"],ai={diffuse:new i.Q1f(16777215),specular:new i.Q1f(1118481),shininess:30,opacity:1,fixedColor:new i.Q1f(16777215),zOffset:0,zClipCoef:2,zClipValue:0,clipPlaneValue:0,world2colorMatrix:new i.kn4,dashedLineSize:.1,dashedLinePeriod:.3,projMatrixInv:new i.kn4,viewport:new i.I9Y(800,600),lineWidth:2,fogAlpha:1,samplesKernel:ii,noiseTex:ti.noiseTexture,noiseTexelSize:new i.I9Y(1/ti.noiseWidth,1/ti.noiseHeight),srcTexelSize:new i.I9Y(1/800,1/600),copy:function(e){this.diffuse.copy(e.diffuse),this.specular.copy(e.specular),this.shininess=e.shininess,this.opacity=e.opacity,this.fixedColor.copy(e.fixedColor),this.zOffset=e.zOffset,this.zClipCoef=e.zClipCoef,this.zClipValue=e.zClipValue,this.clipPlaneValue=e.clipPlaneValue,this.world2colorMatrix.copy(e.world2colorMatrix),this.dashedLineSize=e.dashedLineSize,this.dashedLinePeriod=e.dashedLinePeriod,this.projMatrixInv=e.projMatrixInv,this.viewport=e.viewport,this.lineWidth=e.lineWidth,this.toonShading=e.toonShading,this.fogAlpha=e.fogAlpha,this.samplesKernel=e.samplesKernel,this.noiseTex=e.noiseTex,this.noiseTexelSize=e.noiseTexelSize,this.srcTexelSize=e.srcTexelSize}},li=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return s(this,o),(t=n.call(this,e)).fog=!0,t.instancedPos=!1,t.instancedMatrix=!1,t.attrColor=!1,t.attrColor2=!1,t.attrAlphaColor=!1,t.overrideColor=!1,t.sphereSprite=!1,t.cylinderSprite=!1,t.zClip=!1,t.clipPlane=!1,t.fakeOpacity=!1,t.prepassTransparancy=!1,t.colorFromPos=!1,t.shadowmap=!1,t.shadowmapType="random",t.colorFromDepth=!1,t.orthoCam=!1,t.dashedLine=!1,t.transparent=!0,t.thickLine=!1,t.fogTransparent=!1,t.normalsToGBuffer=!1,t.toonShading=!1,t.uberOptions=ai,t.setValues(ni({uniforms:i.LlO.clone(oi),vertexShader:t.precisionString()+"float INSTANCED_SPRITE_OVERSCALE = 1.3;\r\n\r\nattribute vec3 normal;\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n varying vec3 viewNormal;\r\n#endif\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n varying vec3 vNormal;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec4 position; // W contains vert pos or neg offset\r\n#else\r\n attribute vec3 position;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition;\r\nvarying vec3 vViewPosition;\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n attribute float alphaColor;\r\n varying float alphaCol;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n attribute vec3 color;\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n attribute vec3 color2;\r\n varying vec3 vColor2;\r\n attribute vec2 uv;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_POS\r\n attribute vec4 offset;\r\n #ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n attribute vec4 matVector1;\r\n attribute vec4 matVector2;\r\n attribute vec4 matVector3;\r\n attribute vec4 invmatVector1;\r\n attribute vec4 invmatVector2;\r\n attribute vec4 invmatVector3;\r\n\r\n #ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n varying vec4 spritePosEye;\r\n #endif\r\n#endif\r\n\r\nuniform mat4 modelViewMatrix; // optional\r\nuniform mat4 projectionMatrix; // optional\r\nuniform mat3 normalMatrix; // optional\r\nuniform mat4 modelMatrix; // optional\r\n\r\n#ifdef DASHED_LINE\r\n attribute float lineDistance;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n#ifdef THICK_LINE\r\n attribute vec3 direction;\r\n uniform mat4 projMatrixInv;\r\n uniform vec2 viewport;\r\n uniform float lineWidth;\r\n\r\n vec4 transform(vec4 coord){\r\n return projectionMatrix * modelViewMatrix * coord;\r\n }\r\n\r\n vec2 project(vec4 device){\r\n vec3 device_normal = device.xyz/device.w;\r\n vec2 clip_pos = (device_normal*0.5+0.5).xy;\r\n return clip_pos * viewport;\r\n }\r\n\r\n vec4 unproject(vec2 screen, float z, float w){\r\n vec2 clip_pos = screen/viewport;\r\n vec2 device_normal = clip_pos*2.0-1.0;\r\n return vec4(device_normal*w, z, w);\r\n }\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n alphaCol = alphaColor;\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n vec3 objectNormal = vec3(\r\n dot(normal, matVector1.xyz),\r\n dot(normal, matVector2.xyz),\r\n dot(normal, matVector3.xyz));\r\n#else\r\n vec3 objectNormal = vec3( normal );\r\n#endif\r\n\r\nvec3 transformedNormal = normalMatrix * objectNormal;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n vNormal = normalize(transformedNormal);\r\n#endif\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n viewNormal = normalize(mat3(modelViewMatrix)*objectNormal);\r\n#endif\r\n\r\n vec4 localPos = vec4(position.xyz, 1.0);\r\n vec4 worldPos = modelMatrix * localPos;\r\n vec4 mvPosition = modelViewMatrix * localPos;\r\n\r\n// make thick line offset\r\n#ifdef THICK_LINE\r\n // get screen pos\r\n vec4 dPos = transform(vec4(position.xyz, 1.0));\r\n vec2 sPos = project(dPos);\r\n // move pos forward\r\n vec3 position2 = position.xyz + direction.xyz * 0.5;\r\n // get screen offset pos\r\n vec4 dPos2 = transform(vec4(position2.xyz, 1.0));\r\n vec2 sPos2 = project(dPos2);\r\n // screen line direction\r\n vec2 sDir = normalize(sPos2 - sPos);\r\n // vertex offset (orthogonal to line direction)\r\n vec2 offset1 = vec2(-sDir.y, sDir.x);\r\n // move screen vertex\r\n vec2 newPos = sPos + offset1 * position.w * lineWidth;\r\n // get moved pos in view space\r\n vec4 dNewPos = unproject(newPos, dPos.z, dPos.w);\r\n mvPosition.xyz = (projMatrixInv * dNewPos).xyz;\r\n#endif // THICK_LINE\r\n\r\n#ifdef INSTANCED_POS\r\n #ifdef SPHERE_SPRITE\r\n instOffset = offset;\r\n\r\n vec4 posEye = modelViewMatrix * vec4( offset.xyz, 1.0 );\r\n float scale = length(modelViewMatrix[0]);\r\n mvPosition = posEye + vec4( position.xyz * offset.w * scale * INSTANCED_SPRITE_OVERSCALE, 0.0 );\r\n posEye.w = offset.w * scale;\r\n\r\n spritePosEye = posEye;\r\n #else\r\n localPos = vec4( offset.xyz + position.xyz * offset.w, 1.0 );\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n#ifdef INSTANCED_MATRIX\r\n #ifdef CYLINDER_SPRITE\r\n matVec1 = matVector1;\r\n matVec2 = matVector2;\r\n matVec3 = matVector3;\r\n invmatVec1 = invmatVector1;\r\n invmatVec2 = invmatVector2;\r\n invmatVec3 = invmatVector3;\r\n\r\n // calculate eye coords of cylinder endpoints\r\n vec4 v = vec4(0, -0.5, 0, 1);\r\n vec4 p1 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n v.y = 0.5;\r\n vec4 p2 = modelViewMatrix * vec4(dot(v, matVector1), dot(v, matVector2), dot(v, matVector3), 1.0);\r\n\r\n // sprite is placed at the center of cylinder\r\n vec4 posEye;\r\n posEye.xyz = mix(p1.xyz, p2.xyz, 0.5);\r\n posEye.w = 1.0;\r\n spritePosEye = posEye;\r\n\r\n // cylinder radius in eye space\r\n float rad = length(modelViewMatrix[0]) * length(vec3(matVector1.x, matVector2.x, matVector3.x));\r\n vec2 spriteSize;\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // In ortho projection we skip z coordinate\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy - p1.xy);\r\n\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * (spriteSizeScreen + 2.0 * rad);\r\n #else\r\n // basic sprite size at screen plane (covers only cylinder axis)\r\n vec2 spriteSizeScreen = abs(p2.xy / p2.z - p1.xy / p1.z);\r\n\r\n // full sprite size in eye coords\r\n float minZ = min(abs(p1.z), abs(p2.z));\r\n spriteSize = vec2(1.0, 1.0) * INSTANCED_SPRITE_OVERSCALE * abs(posEye.z) * (spriteSizeScreen + 2.0 * rad / minZ);\r\n #endif\r\n\r\n mvPosition = posEye + vec4( position.xy * 0.5 * spriteSize, 0, 0 );\r\n #else\r\n localPos = vec4(dot(localPos, matVector1), dot(localPos, matVector2), dot(localPos, matVector3), 1.0);\r\n worldPos = modelMatrix * localPos;\r\n mvPosition = modelViewMatrix * localPos;\r\n #endif\r\n#endif\r\n\r\n gl_Position = projectionMatrix * mvPosition;\r\n\r\n vWorldPosition = worldPos.xyz;\r\n vViewPosition = - mvPosition.xyz;\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t vec4 worldPosition;\r\n\t // see THREE.WebGLProgram.unrollLoops\r\n\t #pragma unroll_loop_start\r\n\t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * vec4(vWorldPosition, 1.0);\r\n vDirectionalShadowNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(objectNormal, 0.0))).xyz;\r\n\t }\r\n\t #pragma unroll_loop_end\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n vColor = color.xyz;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n vColor2 = color2;\r\n #ifndef CYLINDER_SPRITE\r\n vUv = uv;\r\n #endif\r\n#endif\r\n\r\n#ifdef DASHED_LINE\r\n vLineDistance = lineDistance;\r\n#endif\r\n}\r\n",fragmentShader:t.precisionString()+"#if defined (NORMALS_TO_G_BUFFER)\r\n #define fragColor gl_FragData[0]\r\n#else\r\n #define fragColor gl_FragColor\r\n#endif\r\n\r\n#ifdef ATTR_ALPHA_COLOR\r\n varying float alphaCol;\r\n#endif\r\n\r\n#ifdef COLOR_FROM_POS\r\n uniform mat4 world2colorMatrix;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n\t#if NUM_DIR_LIGHTS > 0\r\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\r\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ]; //only for sprites\r\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\r\n\t\tvarying vec3 vDirectionalShadowNormal[ NUM_DIR_LIGHTS ];\r\n vec4 vDirLightWorldCoord[ NUM_DIR_LIGHTS ];\r\n vec3 vDirLightWorldNormal[ NUM_DIR_LIGHTS ];\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n // We use 4 instead uniform variable or define because this value is used in for(... i < value; ...) with\r\n // unroll_loop and unroll_loop has pattern:\r\n // /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g\r\n uniform vec2 samplesKernel[4]; // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n uniform sampler2D noiseTex;\r\n uniform vec2 noiseTexelSize;\r\n uniform vec2 srcTexelSize;\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\t#endif\r\n#endif\r\n\r\n#ifdef ATTR_COLOR\r\n varying vec3 vColor;\r\n#endif\r\n\r\n#ifdef ATTR_COLOR2\r\n varying vec3 vColor2;\r\n #ifndef CYLINDER_SPRITE\r\n varying vec2 vUv;\r\n #endif\r\n#endif\r\n\r\nuniform vec3 diffuse;\r\nuniform vec3 emissive;\r\nuniform vec3 specular;\r\nuniform float shininess;\r\nuniform vec3 fixedColor;\r\nuniform float opacity;\r\nuniform float zClipValue;\r\nuniform float clipPlaneValue;\r\n\r\n#ifdef NORMALS_TO_G_BUFFER\r\n varying vec3 viewNormal;\r\n#endif\r\n\r\n#define PI 3.14159265359\r\n#define RECIPROCAL_PI 0.31830988618\r\n#define saturate(a) clamp( a, 0.0, 1.0 )\r\n\r\n#ifdef USE_FOG\r\n uniform vec3 fogColor;\r\n uniform float fogAlpha;\r\n uniform float fogNear;\r\n uniform float fogFar;\r\n#endif\r\n\r\nvarying vec3 vWorldPosition; // world position of the pixel (invalid when INSTANCED_SPRITE is defined)\r\nvarying vec3 vViewPosition;\r\n\r\n#if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n varying vec3 vNormal;\r\n#endif\r\n\r\n/////////////////////////////////////////// ZSprites ////////////////////////////////////////////////\r\n#if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n uniform float nearPlaneValue;\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 spritePosEye;\r\n#endif\r\n\r\n#if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n uniform float zOffset;\r\n\r\n #if !defined(USE_LIGHTS) || !defined(SHADOWMAP) || !defined(SHADOWMAP_PCF_RAND) || !(NUM_DIR_LIGHTS > 0)\r\n uniform mat4 projectionMatrix;\r\n #endif\r\n\r\n float calcDepthForSprites(vec4 pixelPosEye, float zOffset, mat4 projMatrix) {\r\n vec4 pixelPosScreen = projMatrix * pixelPosEye;\r\n return 0.5 * (pixelPosScreen.z / pixelPosScreen.w + 1.0) + zOffset;\r\n }\r\n#endif\r\n\r\n#ifdef SPHERE_SPRITE\r\n varying vec4 instOffset;\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n\r\n bool intersect_ray_sphere(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray, ray);\r\n float b = dot(ray, origin);\r\n float c = dot(origin, origin) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n // choose nearest point inside frustum\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all spheres the point with smaller 't' is visible\r\n // t1 is always smaller than t2 (from calculations)\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_sphere_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into sphere local coords\r\n origin = pixelPosEye.xyz - spritePosEye.xyz;\r\n origin = (invModelViewMatrix * vec4(origin, 0.0)).xyz / instOffset.w;\r\n\r\n // transform camera orientation vector into sphere local coords\r\n ray = (invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n vec4 v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into sphere local coords\r\n v = invModelViewMatrix * v;\r\n origin = (v.xyz - instOffset.xyz) / instOffset.w;\r\n\r\n // transform vector from camera pos to curPixel into sphere local coords\r\n ray = (invModelViewMatrix * vec4(pixelPosEye, 0.0)).xyz;\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_sphere(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n varying vec4 matVec1;\r\n varying vec4 matVec2;\r\n varying vec4 matVec3;\r\n varying vec4 invmatVec1;\r\n varying vec4 invmatVec2;\r\n varying vec4 invmatVec3;\r\n\r\n uniform mat4 modelMatrix;\r\n uniform mat4 modelViewMatrix;\r\n uniform mat4 invModelViewMatrix;\r\n uniform mat3 normalMatrix;\r\n\r\n varying vec4 spritePosEye;\r\n\r\n bool intersect_ray_cylinder(in vec3 origin, in vec3 ray, out vec3 point, out float frontFaced) {\r\n\r\n // intersect XZ-projected ray with circle\r\n float a = dot(ray.xz, ray.xz);\r\n float b = dot(ray.xz, origin.xz);\r\n float c = dot(origin.xz, origin.xz) - 1.0;\r\n float det = b * b - a * c;\r\n if (det < 0.0) return false;\r\n float t1 = (-b - sqrt(det)) / a;\r\n float t2 = (-b + sqrt(det)) / a;\r\n\r\n // calculate both intersection points\r\n vec3 p1 = origin + ray * t1;\r\n vec3 p2 = origin + ray * t2;\r\n\r\n float halfHeight = 0.5;\r\n\r\n // choose nearest point\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // orthografic camera is used for dirLight sources. So in it for all cylinders the point with smaller 't' is visible\r\n // if it is not outside of cylinnder (t1 is always smaller than t2).\r\n if (p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #else\r\n // for perspective camera first intersection can be in front of near plane. If not intersection is p1 else - p2\r\n // t* = 0.0 corresponds to point of intersection near plane by the ray from camera to curPixel\r\n if (t1 >= 0.0 && p1.y >= -halfHeight && p1.y <= halfHeight) {\r\n point = p1;\r\n frontFaced = 1.0;\r\n return true;\r\n }\r\n if (t2 >= 0.0 && p2.y >= -halfHeight && p2.y <= halfHeight) {\r\n point = p2;\r\n frontFaced = -1.0;\r\n return true;\r\n }\r\n #endif\r\n\r\n return false;\r\n }\r\n\r\n bool get_cylinder_point(in vec3 pixelPosEye, out vec3 point, out float frontFaced) {\r\n vec3 origin, ray;\r\n vec4 v;\r\n\r\n #ifdef ORTHOGRAPHIC_CAMERA\r\n // transform vector from sprite center to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye.xyz - spritePosEye.xyz, 0.0);\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform camera orientation vector into cylinder local coords\r\n v = invModelViewMatrix * vec4(0.0, 0.0, -1.0, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #else\r\n // find point of intersection near plane by the ray from camera to curPixel\r\n v = vec4(-(nearPlaneValue / pixelPosEye.z) * pixelPosEye, 1.0);\r\n\r\n // transform intersection point into cylinder local coords\r\n v = invModelViewMatrix * v;\r\n origin = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n\r\n // transform vector from camera pos to curPixel into cylinder local coords\r\n v = invModelViewMatrix * vec4(pixelPosEye, 0.0);\r\n ray = vec3(dot(v, invmatVec1), dot(v, invmatVec2), dot(v, invmatVec3));\r\n #endif\r\n ray = normalize(ray);\r\n\r\n return intersect_ray_cylinder(origin, ray, point, frontFaced);\r\n }\r\n#endif\r\n\r\n///////////////////////////////////// Pack and unpack ///////////////////////////////////////////////\r\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\r\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\r\n\r\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\r\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\r\n\r\n\r\nconst float ShiftRight8 = 1. / 256.;\r\n\r\nvec4 packDepthToRGBA( const in float v ) {\r\n vec4 r = vec4( fract( v * PackFactors ), v );\r\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\r\n return r * PackUpscale;\r\n}\r\n\r\nfloat unpackRGBAToDepth( const in vec4 v ) {\r\n return dot( v, UnpackFactors );\r\n}\r\n\r\n////////////////////////////////////////// All Lighting /////////////////////////////////////////////////\r\n#ifdef TOON_SHADING\r\n #define LOW_TOON_BORDER 0.0\r\n #define MEDIUM_TOON_BORDER 0.7\r\n #define HIGH_TOON_BORDER 1.0\r\n\r\n #define MEDIUM_TOON_RANGE 0.5\r\n #define HIGH_TOON_RANGE 0.95\r\n#endif\r\n#if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n struct ReflectedLight {\r\n vec3 directDiffuse;\r\n vec3 directSpecular;\r\n vec3 indirectDiffuse;\r\n };\r\n\r\n struct BlinnPhongMaterial {\r\n vec3 diffuseColor;\r\n vec3 specularColor;\r\n float specularShininess;\r\n };\r\n\r\n struct GeometricContext {\r\n vec3 normal;\r\n vec3 viewDir;\r\n };\r\n\r\n struct DirectionalLight {\r\n vec3 direction;\r\n vec3 color;\r\n };\r\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\r\n\r\n struct DirectionalLightShadow {\r\n vec2 shadowMapSize;\r\n float shadowBias;\r\n float shadowRadius;\r\n };\r\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHTS ];\r\n\r\n uniform vec3 ambientLightColor;\r\n\r\n /////////////////////////////////////////// Shadowmap ////////////////////////////////////////////////\r\n\r\n #if defined(SHADOWMAP)\r\n \tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\r\n \t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\r\n \t}\r\n\r\n float getShadow( sampler2D shadowMap, DirectionalLightShadow dirLight, vec4 shadowCoord, vec3 vViewPosition, vec3 vNormal ) {\r\n \t float shadow = 0.0;\r\n\r\n // When shadows for sprites will appear use here for them normals as it done for G-buffer\r\n shadowCoord.xyz += dirLight.shadowBias * vNormal;\r\n shadowCoord.xyz /= shadowCoord.w;\r\n\r\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\r\n bool inFrustum = all( inFrustumVec );\r\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\r\n bool frustumTest = all( frustumTestVec );\r\n\r\n if ( frustumTest ) {\r\n #ifdef SHADOWMAP_BASIC\r\n \t shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\r\n \t#endif\r\n\r\n \t#ifdef SHADOWMAP_PCF_SHARP\r\n \t vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n float dx0 = - texelSize.x * dirLight.shadowRadius;\r\n float dy0 = - texelSize.y * dirLight.shadowRadius;\r\n float dx1 = + texelSize.x * dirLight.shadowRadius;\r\n float dy1 = + texelSize.y * dirLight.shadowRadius;\r\n\r\n shadow = (\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\r\n \ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\r\n ) * ( 1.0 / 9.0 );\r\n #endif\r\n\r\n #ifdef SHADOWMAP_PCF_RAND\r\n vec2 texelSize = vec2( 1.0 ) / dirLight.shadowMapSize;\r\n\r\n vec4 vUv = ((projectionMatrix * vec4(vViewPosition, 1.0)) + 1.0) / 2.0;\r\n vec2 vUvNoise = vUv.xy / srcTexelSize * noiseTexelSize;\r\n\r\n vec2 noiseVec = normalize(texture2D(noiseTex, vUvNoise).rg);\r\n mat2 mNoise = mat2(noiseVec.x, noiseVec.y, -noiseVec.y, noiseVec.x);\r\n\r\n vec2 offset;\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < 4; i ++ ) { // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n offset = mNoise * ( normalize( samplesKernel[ i ]) * texelSize * dirLight.shadowRadius );\r\n shadow += texture2DCompare( shadowMap, shadowCoord.xy + offset, shadowCoord.z );\r\n }\r\n #pragma unroll_loop_end\r\n shadow /= float( 4 ); // 4 is length of _samplesKernel which is defined in UberMaterial.js\r\n #endif\r\n }\r\n return shadow;//(shadow != 1.0) ? 0.5 : 1.0;//vec4(shadow, shadow, shadow, 1.0);\r\n }\r\n #endif\r\n\r\n /////////////////////////////////////////// Lighting /////////////////////////////////////////////////\r\n\r\n vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\r\n return RECIPROCAL_PI * diffuseColor;\r\n } // validated\r\n\r\n vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\r\n // Original approximation by Christophe Schlick '94\r\n //;float fresnel = pow( 1.0 - dotLH, 5.0 );\r\n // Optimized variant (presented by Epic at SIGGRAPH '13)\r\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\r\n return ( 1.0 - specularColor ) * fresnel + specularColor;\r\n } // validated\r\n\r\n float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\r\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\r\n return 0.25;\r\n }\r\n\r\n float D_BlinnPhong( const in float shininess, const in float dotNH ) {\r\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\r\n }\r\n\r\n vec3 BRDF_Specular_BlinnPhong( const in DirectionalLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\r\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\r\n float dotNH = saturate(dot( geometry.normal, halfDir ));\r\n float dotLH = saturate(dot( incidentLight.direction, halfDir ));\r\n\r\n vec3 F = F_Schlick( specularColor, dotLH );\r\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\r\n float D = D_BlinnPhong( shininess, dotNH );\r\n\r\n return F * ( G * D );\r\n } // validated\r\n\r\n void RE_Direct_BlinnPhong( const in DirectionalLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight, float penumbra ) {\r\n\r\n float dotNL = saturate( dot( geometry.normal, directLight.direction ));\r\n #ifdef TOON_SHADING\r\n if(dotNL < MEDIUM_TOON_RANGE){\r\n dotNL = LOW_TOON_BORDER;\r\n }\r\n else if(dotNL < HIGH_TOON_RANGE){\r\n dotNL = MEDIUM_TOON_BORDER;\r\n }\r\n else{\r\n dotNL = HIGH_TOON_BORDER;\r\n }\r\n #endif\r\n\r\n vec3 irradiance = dotNL * directLight.color * PI;\r\n reflectedLight.directDiffuse += penumbra * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n reflectedLight.directSpecular += penumbra * irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess );\r\n }\r\n\r\n void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\r\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\r\n }\r\n\r\n vec3 calcLighting(const in GeometricContext geometry, const in BlinnPhongMaterial material, vec3 vViewPosition) {\r\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ));\r\n vec3 irradiance = ambientLightColor * PI;\r\n\r\n float shadowMask = 1.0;\r\n // see THREE.WebGLProgram.unrollLoops\r\n \t#pragma unroll_loop_start\r\n \t for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n \t #ifdef SHADOWMAP\r\n \t shadowMask = getShadow( directionalShadowMap[ i ], directionalLightShadows[ i ], vDirLightWorldCoord[ i ], vViewPosition, vDirLightWorldNormal[ i ] );\r\n #endif\r\n\r\n \t\t if ( shadowMask > 0.0 ) RE_Direct_BlinnPhong( directionalLights[ i ], geometry, material, reflectedLight, shadowMask );\r\n \t\t}\r\n \t\t#pragma unroll_loop_end\r\n\r\n RE_IndirectDiffuse_BlinnPhong(irradiance, material, reflectedLight);\r\n\r\n return saturate(reflectedLight.indirectDiffuse + reflectedLight.directDiffuse + reflectedLight.directSpecular);\r\n }\r\n#endif\r\n\r\n/////////////////////////////////////////// Dashed Line ///////////////////////////////////////////////\r\n#ifdef DASHED_LINE\r\n uniform float dashedLineSize;\r\n uniform float dashedLinePeriod;\r\n varying float vLineDistance;\r\n#endif\r\n\r\n/////////////////////////////////////////// Main ///////////////////////////////////////////////\r\nvoid main() {\r\n\r\n#ifdef CLIP_PLANE\r\n if (vViewPosition.z < clipPlaneValue) discard;\r\n#endif\r\n\r\n#ifdef ZCLIP\r\n if (vViewPosition.z < zClipValue) discard;\r\n#endif\r\n\r\n#if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = vDirectionalShadowCoord[ i ];\r\n vDirLightWorldNormal[ i ] = vDirectionalShadowNormal[ i ];\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n#endif\r\n\r\n vec4 pixelPosWorld = vec4(vWorldPosition, 1.0);\r\n vec4 pixelPosEye;\r\n\r\n#ifdef SPHERE_SPRITE\r\n\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n vec3 normal;\r\n\r\n/* quick-and-dirty method\r\n normal.xy = ' + INSTANCED_SPRITE_OVERSCALE + ' * (2.0 * vUv - 1.0);\r\n float r2 = dot(normal.xy, normal.xy);\r\n if (r2 > 1.0) discard;\r\n float normalZ = sqrt(1.0 - r2);\r\n normal.z = normalZ;\r\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\r\n pixelPosEye = vec4(spritePosEye.xyz, 1.0);\r\n pixelPosEye.z += spritePosEye.w * normalZ;\r\n*/\r\n\r\n // ray-trace sphere surface\r\n {\r\n vec3 p;\r\n if (!get_sphere_point(-vViewPosition, p, frontFaced)) discard;\r\n vec4 v = vec4(instOffset.xyz + p * instOffset.w, 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n normal = normalize(normalMatrix * p);\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*p);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(p, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n }\r\n#endif\r\n\r\n#ifdef CYLINDER_SPRITE\r\n vec3 normal;\r\n vec3 viewNormalSprites;\r\n float frontFaced = 1.0;\r\n float cylinderY = 0.0;\r\n\r\n // ray-trace cylinder surface\r\n {\r\n vec3 p;\r\n if (!get_cylinder_point(-vViewPosition, p, frontFaced)) discard;\r\n\r\n cylinderY = 0.5 * (p.y + 1.0);\r\n\r\n vec4 v = vec4(p, 1.0);\r\n v = vec4(dot(v, matVec1), dot(v, matVec2), dot(v, matVec3), 1.0);\r\n pixelPosWorld = modelMatrix * v;\r\n pixelPosEye = modelViewMatrix * v;\r\n\r\n vec3 localNormal = normalize(vec3(p.x, 0.0, p.z));\r\n normal = vec3(\r\n dot(localNormal, matVec1.xyz),\r\n dot(localNormal, matVec2.xyz),\r\n dot(localNormal, matVec3.xyz));\r\n #ifdef NORMALS_TO_G_BUFFER\r\n viewNormalSprites = normalize(mat3(modelViewMatrix)*normal);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && defined(SHADOWMAP)\r\n #if NUM_DIR_LIGHTS > 0\r\n // see THREE.WebGLProgram.unrollLoops\r\n #pragma unroll_loop_start\r\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\r\n vDirLightWorldCoord[ i ] = directionalShadowMatrix[ i ] * pixelPosWorld;\r\n vDirLightWorldNormal[ i ] = (directionalShadowMatrix[ i ] * (modelMatrix * vec4(normal, 0.0))).xyz;\r\n }\r\n #pragma unroll_loop_end\r\n #endif\r\n #endif\r\n\r\n normal = normalize(normalMatrix * normal);\r\n }\r\n#endif\r\n\r\n #ifdef ATTR_COLOR\r\n vec3 vertexColor = vColor;\r\n #else\r\n vec3 vertexColor = vec3(1.0, 1.0, 1.0);\r\n #endif\r\n\r\n #ifdef ATTR_COLOR2\r\n #ifdef CYLINDER_SPRITE\r\n float colorCoef = cylinderY; // cylinder parameter is calculated from ray-tracing\r\n #else\r\n float colorCoef = vUv.y; // cylinder parameter is interpolated as tex coord\r\n #endif\r\n // choose either color or color2\r\n vertexColor = mix(vColor2, vColor, step(0.5, colorCoef));\r\n #endif\r\n\r\n // negative red component is a special condition\r\n if (vertexColor.x < 0.0) discard;\r\n\r\n #ifdef DASHED_LINE\r\n if ( mod( vLineDistance, dashedLinePeriod ) > dashedLineSize ) discard;\r\n #endif\r\n\r\n // transparency prepass writes only z, so we don't need to calc the color\r\n #ifdef PREPASS_TRANSP\r\n fragColor = vec4(1.0, 1.0, 1.0, 1.0);\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n return;\r\n #endif\r\n\r\n float totalOpacity = opacity;\r\n\r\n #ifdef ATTR_ALPHA_COLOR\r\n totalOpacity *= alphaCol;\r\n #endif\r\n\r\n // discard fully transparent pixels\r\n if (totalOpacity == 0.0) discard;\r\n\r\n #ifdef FAKE_OPACITY\r\n // discard pixels in checker pattern\r\n vec2 dm_coord = floor(gl_FragCoord.xy);\r\n dm_coord = fract(dm_coord * 0.5);\r\n if (totalOpacity < 1.0 && (dm_coord.x < 0.5 ^^ dm_coord.y < 0.5)) discard;\r\n vec4 diffuseColor = vec4(diffuse, 1.0);\r\n #else\r\n vec4 diffuseColor = vec4(diffuse, totalOpacity);\r\n #endif\r\n\r\n float flipNormal;\r\n #if !defined (SPHERE_SPRITE) && !defined (CYLINDER_SPRITE)\r\n flipNormal = 1.0;\r\n #ifdef DOUBLE_SIDED\r\n flipNormal = float( gl_FrontFacing );\r\n #endif\r\n vec3 normal = normalize( vNormal ) * flipNormal;\r\n #endif\r\n\r\n diffuseColor.rgb *= vertexColor;\r\n\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n #endif\r\n\r\n #ifdef NORMALS_TO_G_BUFFER\r\n #if defined (SPHERE_SPRITE) || defined (CYLINDER_SPRITE)\r\n vec3 viewNormaInColor = viewNormalSprites;\r\n #else\r\n vec3 viewNormaInColor = viewNormal;\r\n float frontFaced = float( gl_FrontFacing );\r\n #endif\r\n // [-1, 1] -> [0, 1]\r\n viewNormaInColor = 0.5 * viewNormaInColor + 0.5;\r\n gl_FragData[1] = vec4(viewNormaInColor, frontFaced);\r\n #endif\r\n\r\n #if defined(USE_LIGHTS) && NUM_DIR_LIGHTS > 0\r\n vec3 viewDir;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDir = -pixelPosEye.xyz;\r\n #else\r\n viewDir = vViewPosition;\r\n #endif\r\n GeometricContext geometry = GeometricContext(normal, normalize( viewDir ));\r\n BlinnPhongMaterial material = BlinnPhongMaterial(diffuseColor.rgb, specular, shininess);\r\n vec3 outgoingLight = calcLighting(geometry, material, viewDir);\r\n #else\r\n vec3 outgoingLight = diffuseColor.rgb;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_DEPTH\r\n float depth = 0.0;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n gl_FragDepthEXT = calcDepthForSprites(pixelPosEye, zOffset, projectionMatrix);\r\n depth = gl_FragDepthEXT;\r\n #else\r\n depth = gl_FragCoord.z;\r\n #endif\r\n fragColor = packDepthToRGBA(depth);\r\n return;\r\n #endif\r\n\r\n #ifdef COLOR_FROM_POS\r\n fragColor = world2colorMatrix * pixelPosWorld;\r\n #else\r\n #ifdef OVERRIDE_COLOR\r\n fragColor = vec4(fixedColor, diffuseColor.a);\r\n #else\r\n fragColor = vec4(outgoingLight, diffuseColor.a);//vec4(vNormal, 1.0);\r\n #endif\r\n\r\n #ifdef USE_FOG\r\n float viewDistance;\r\n #if defined(SPHERE_SPRITE) || defined(CYLINDER_SPRITE)\r\n viewDistance = abs(pixelPosEye.z);\r\n #else\r\n viewDistance = vViewPosition.z;\r\n #endif\r\n float fogFactor = smoothstep( fogNear, fogFar, viewDistance) * fogAlpha;\r\n #ifdef FOG_TRANSPARENT\r\n fragColor.a = fragColor.a * (1.0 - fogFactor);\r\n #else\r\n fragColor.rgb = mix( fragColor.rgb, fogColor, fogFactor );\r\n #endif\r\n #endif\r\n\r\n #endif\r\n}\r\n",lights:!0,fog:!0,side:i.$EB},e)),t}return l(o,[{key:"precisionString",value:function(){var e=Yn.precision;return"precision ".concat(e," float;\n")+"precision ".concat(e," int;\n\n")}},{key:"copy",value:function(e){return We(d(o.prototype),"copy",this).call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=i.LlO.clone(e.uniforms),this.defines=ni({},e.defines),this.extensions=e.extensions,this.fog=e.fog,this.instancedPos=e.instancedPos,this.instancedMatrix=e.instancedMatrix,this.attrColor=e.attrColor,this.attrColor2=e.attrColor2,this.attrAlphaColor=e.attrAlphaColor,this.overrideColor=e.overrideColor,this.sphereSprite=e.sphereSprite,this.cylinderSprite=e.cylinderSprite,this.zClip=e.zClip,this.clipPlane=e.clipPlane,this.fakeOpacity=e.fakeOpacity,this.colorFromPos=e.colorFromPos,this.shadowmap=e.shadowmap,this.shadowmapType=e.shadowmapType,this.colorFromDepth=e.colorFromDepth,this.orthoCam=e.orthoCam,this.prepassTransparancy=e.prepassTransparancy,this.dashedLine=e.dashedLine,this.thickLine=e.thickLine,this.fogTransparent=e.fogTransparent,this.normalsToGBuffer=e.normalsToGBuffer,this.toonShading=e.toonShading,this.uberOptions.copy(e.uberOptions),this}},{key:"createInstance",value:function(){var e=new o;return e.copy(this),e.uberOptions=Object.create(this.uberOptions),e}},{key:"setValues",value:function(e){if(void 0!==e){We(d(o.prototype),"setValues",this).call(this,e);var t={},r={};this.fog&&(t.USE_FOG=1),this.instancedPos&&(t.INSTANCED_POS=1),this.instancedMatrix&&(t.INSTANCED_MATRIX=1),this.attrColor&&(t.ATTR_COLOR=1),this.attrColor2&&(t.ATTR_COLOR2=1),this.attrAlphaColor&&(t.ATTR_ALPHA_COLOR=1),this.overrideColor&&(t.OVERRIDE_COLOR=1),this.sphereSprite&&(t.SPHERE_SPRITE=1,r.fragDepth=1),this.cylinderSprite&&(t.CYLINDER_SPRITE=1,r.fragDepth=1),this.zClip&&(t.ZCLIP=1),this.clipPlane&&(t.CLIP_PLANE=1),this.fakeOpacity&&(t.FAKE_OPACITY=1),this.lights&&(t.USE_LIGHTS=1),this.colorFromPos&&(t.COLOR_FROM_POS=1),this.shadowmap&&(t.SHADOWMAP=1,"pcf"===this.shadowmapType?t.SHADOWMAP_PCF_SHARP=1:"random"===this.shadowmapType?t.SHADOWMAP_PCF_RAND=1:t.SHADOWMAP_BASIC=1),this.colorFromDepth&&(t.COLOR_FROM_DEPTH=1),this.orthoCam&&(t.ORTHOGRAPHIC_CAMERA=1),this.prepassTransparancy&&(t.PREPASS_TRANSP=1),this.dashedLine&&(t.DASHED_LINE=1),this.thickLine&&(t.THICK_LINE=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.normalsToGBuffer&&(r.drawBuffers=1,t.NORMALS_TO_G_BUFFER=1),this.toonShading&&(t.TOON_SHADING=1),this.defines=t,this.extensions=r}}},{key:"setUberOptions",value:function(e){if(void 0!==e)for(var t in e)e.hasOwnProperty(t)&&(this.uberOptions[t]instanceof i.Q1f?this.uberOptions[t]=e[t].clone():this.uberOptions[t]=e[t])}},{key:"clone",value:function(e){return e?this.createInstance():i.imn.prototype.clone.call(this)}},{key:"updateUniforms",value:function(){var e=this;si.forEach((function(t){e.uniforms.hasOwnProperty(t)&&(e.uberOptions[t]instanceof i.Q1f||e.uberOptions[t]instanceof i.kn4?e.uniforms[t].value=e.uberOptions[t].clone():e.uniforms[t].value=e.uberOptions[t])}))}}]),o}(i.D$Q);function ci(e){var t=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;s(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).onBeforeRender=i.prototype.onBeforeRender,e}return l(i,[{key:"onBeforeRender",value:function(e,t,r,n,i,o){this._onBeforeRender(e,t,r,n,i,o),this._update()}},{key:"_onBeforeRender",value:function(){}},{key:"_update",value:function(){var e=this.material;e&&e instanceof li&&e.updateUniforms()}}]),i}(e);return t}var ui=ci(i.eaF),hi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;s(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).castShadow=!0,e.receiveShadow=!0,e}return l(i,[{key:"_onBeforeRender",value:function(e,t,r,n,i,o){ui.prototype._onBeforeRender.call(this,e,t,r);var s=this.material;s&&s.uniforms.invModelViewMatrix&&(this.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,this.matrixWorld),s.uniforms.invModelViewMatrix.value.copy(this.modelViewMatrix).invert(),s.uniforms.nearPlaneValue.value=r.near,s.uniformsNeedUpdate=!0)}}]),i}(ui);var fi=ci(i.eaF),di=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this,e,t)).castShadow=!0,r.receiveShadow=!0,r}return l(i,[{key:"_onBeforeRender",value:function(e,t,r){fi.prototype._onBeforeRender.call(this,e,t,r);var n=this.geometry,o=this.material;if(n.zClip&&o.uberOptions){var s=i._modelView,a=i._mvLength,l=i._center;s.multiplyMatrices(this.matrixWorld,r.matrixWorldInverse);var c=a.setFromMatrixColumn(s,0).length();l.copy(n.boundingSphere.center),this.localToWorld(l),o.uberOptions.zClipValue=r.position.z-l.z-c*(.5*n.boundingSphere.radius)}}}]),i}(fi);Se(di,"_mvLength",new i.Pq0),Se(di,"_center",new i.Pq0),Se(di,"_modelView",new i.kn4);var pi=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;s(this,o),(r=i.call(this)).geometry=e;var n=c(r);return n.initialized=!1,r.geometry.addEventListener("update",(function(){n.update()})),r}return l(o,[{key:"init",value:function(){for(var e=this.children,t=e.length-1;t>=0;--t)this.remove(e[t]);for(var r=this.geometry,i=r.items,o=r.userData,s=0,a=i.length;s<a;++s){var l=i[s];if(l){var c=$.shallowCloneNode(l),u=new pr(c);u.userData=(0,n.clone)(o),u.getElement().style.visibility="visible",u.source=l,this.add(u)}}this.initialized=!0}},{key:"update",value:function(){if(this.geometry.needsUpdate){var e=this.children;this.initialized||this.init();for(var t=0,r=e.length;t<r;++t){var n=e[t],i=n.source;n.position.copy(i.worldPos),n.userData.color=i.opts.color,n.userData.background=i.opts.background}}}}]),o}(i.YJl);var mi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this,e,t)).castShadow=!0,r.receiveShadow=!0,r}return l(i)}(ci(i.eaF));var vi=ci(i.eaF),yi=new i.I9Y,_i=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_onBeforeRender",value:function(e,t,r,n,i,o){var s=this.material;s.uberOptions&&(s.uberOptions.projMatrixInv.copy(r.projectionMatrix).invert(),e.getSize(yi),s.uberOptions.viewport.set(yi.width,yi.height))}}]),i}(vi);var gi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;s(this,i);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(e=n.call.apply(n,[this].concat(r))).castShadow=!0,e.receiveShadow=!0,e}return l(i)}(ci(i.eaF)),xi={ZClipped:di,ZSprite:hi,Text:pi,Line:ci(i.N1A),LineSegments:ci(i.DXC),Mesh:mi,ThickLineMesh:_i,Instanced:gi};function bi(e,t){return function(r){r.setValues(e),r.setUberOptions(t)}}function wi(e,t){return{Geometry:function(r,n){return new Wn.Instanced2CCylindersGeometry(r,n,e,t)},Object:e?xi.ZSprite:xi.Instanced,initMaterial:bi({instancedMatrix:!0,attrColor:!0,attrColor2:!0,attrAlphaColor:!0,cylinderSprite:e})}}function Si(e,t){var r=e.prototype instanceof fn,n=t.lineWidth||0;return{Geometry:e,Object:r?xi.ThickLineMesh:xi.LineSegments,initMaterial:bi({lights:!1,attrColor:!0,attrAlphaColor:!0,thickLine:r},{lineWidth:n})}}function Ri(e,t,r,n){var i={wireframe:!!n.wireframe,fakeOpacity:r.now.isoSurfaceFakeOpacity,zClip:n.zClip};return{Geometry:e,Object:xi.ZClipped,initMaterial:bi({attrColor:!0,attrAlphaColor:!1,wireframe:i.wireframe,fakeOpacity:i.fakeOpacity,zClip:i.zClip})}}var Ci=function(){function e(){s(this,e)}return l(e,null,[{key:"createSpheres",value:function(e,t){var r=t.now.zSprites;return{Geometry:function(e,t){return new Wn.InstancedSpheresGeometry(e,t,r)},Object:r?xi.ZSprite:xi.Instanced,initMaterial:bi({instancedPos:!0,attrColor:!0,attrAlphaColor:!0,sphereSprite:r})}}},{key:"create2CClosedCylinders",value:function(e,t){return wi(!1,!1)}},{key:"create2CCylinders",value:function(e,t){return wi(t.now.zSprites,!0)}},{key:"create2CLines",value:function(e,t,r){return Si(Wn.TwoColorLinesGeometry,r)}},{key:"createCrosses",value:function(e,t,r){return Si(Wn.CrossGeometry,r)}},{key:"createExtrudedChains",value:function(e,t){return{Geometry:Wn.ExtrudedObjectsGeometry,Object:xi.Mesh,initMaterial:bi({attrColor:!0,attrAlphaColor:!0})}}},{key:"createChunkedLines",value:function(e,t,r){return Si(Wn.ChunkedLinesGeometry,r)}},{key:"createQuickSurface",value:function(e,t,r){return Ri(Wn.QuickSurfGeometry,0,t,r)}},{key:"createContactSurface",value:function(e,t,r){return Ri(Wn.ContactSurfaceGeometry,0,t,r)}},{key:"createSASSES",value:function(e,t,r){return Ri(Wn.SSIsosurfaceGeometry,0,t,r)}},{key:"createLabels",value:function(e,t){return{Geometry:Wn.LabelsGeometry,Object:xi.Text,initMaterial:function(){}}}}]),e}();var ki=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t,r,a){var l;s(this,o),(l=n.call(this))._geometry=e,l._geoParams=t;var c=r.createInstance();t.initMaterial(c),l._material=c,l._transforms=a.length>0?a:[new i.kn4];for(var u=l._createMeshes(e),h=0,f=u.length;h<f;++h)l.add(u[h]);return l}return l(o,[{key:"raycast",value:function(e,t){var r=o._ray,n=o._inverseMatrix,i=this.children;r.copy(e.ray);for(var s=0,a=i.length;s<a;++s){var l=i[s];if(kr.belongToSelectLayers(l)){l.updateMatrixWorld();var c=l.matrixWorld;n.copy(c).invert(),e.ray.copy(r).applyMatrix4(n);var u=[];this._geometry.raycast(e,u);for(var h=0,f=u.length;h<f;++h){var d=u[h];d.point&&(d.point.applyMatrix4(c),d.distance=r.origin.distanceTo(d.point)),d.object=l,t[t.length]=d}}}e.ray.copy(r)}},{key:"getSubset",value:function(e){for(var t=this._geometry.getSubset(e),r=[],n=0,i=0,o=t.length;i<o;++i)for(var s=this._createMeshes(t[i]),a=0,l=s.length;a<l;++a)r[n++]=s[a];return r}},{key:"_createMeshes",value:function(e){for(var t=this._transforms,r=this._geoParams.Object,n=this._material,i=[],o=0,s=t.length;o<s;++o){var a=new r(e,n);a.applyMatrix4(t[o]),i[o]=a}return i}}]),o}(i.B69);Se(ki,"_inverseMatrix",new i.kn4),Se(ki,"_ray",new i.RlV);var Ai=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,c){var u,h,f,d;if(s(this,i),(u=n.call(this)).constructor===i)throw new Error("Can not instantiate abstract class!");return u._selection=t,u._mode=o,u._colorer=r,u._chunksIdc=t.chunks,u._polyComplexity=l,u._geo=new(h=e.Geometry,f=u._makeGeoArgs(),d=[h].concat(f),h.bind.apply(h,Pr(d))),u._mesh=new ki(u._geo,e,c,a),u.add(u._mesh),u._build(),u}return l(i,[{key:"_makeGeoArgs",value:function(){throw new Error("ChemGroup subclass must override _makeGeoArgs() method")}},{key:"getSubset",value:function(e,t){t=void 0!==t&&t;var r=this._calcChunksList(e,t);return 0===r.length?[]:this._mesh.getSubset(r)}},{key:"_changeSubsetOpacity",value:function(e,t,r){var n=this._calcChunksList(e,r);0!==n.length&&this._geo.setOpacity(n,t)}},{key:"enableSubset",value:function(e,t){t=void 0===t||t,this._changeSubsetOpacity(e,1,t)}},{key:"disableSubset",value:function(e,t){t=void 0===t||t,this._changeSubsetOpacity(e,0,t)}}]),i}(mr);var Ei=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.atoms,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,s=n.length;o<s;++o)if(n[o].hasOwnProperty("chunkIdx")){var a=i[n[o].chunkIdx];a<r.length&&(n[o].atom=r[a],t.push(n[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._selection.atoms,n=this._chunksIdc,i=0,o=n.length;i<o;++i)r[n[i]].mask&e&&t.push(i);return t}}]),i}(Ai);var Pi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[this._selection.chunks.length,this._polyComplexity]}},{key:"_build",value:function(){for(var e=this._selection.chunks,t=this._selection,r=t.atoms,n=t.parent,i=this._mode,o=this._colorer,s=this._geo,a=0,l=e.length;a<l;++a){var c=r[e[a]];s.setItem(a,c.position,i.calcAtomRadius(c)),s.setColor(a,o.getAtomColor(c,n))}s.finalize()}},{key:"updateToFrame",value:function(e){for(var t=this._selection.chunks,r=this._selection.atoms,n=this._mode,i=this._colorer,o=e.needsColorUpdate(i),s=this._geo,a=0,l=t.length;a<l;++a){var c=r[t[a]];s.setItem(a,e.getAtomPos(t[a]),n.calcAtomRadius(c)),o&&s.setColor(a,e.getAtomColor(i,c))}s.finalize()}}]),i}(Ei);var Ti=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=[],t=this._selection,r=t.atoms,n=t.chunks,i=n.length,o=0;o<i;++o)e[o]=r[n[o]];var s=this._mode.getSurfaceOpts();return s.atoms=e,[i,s]}}]),i}(Pi);var Mi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=[],t=this._selection,r=t.atoms,n=t.chunks,i=n.length,o=0;o<i;++o)e[o]=r[n[o]];var s=this._mode.getSurfaceOpts();return s.atoms=e,s.selection=this._selection,s.colorMode=this._colorer,[i,s]}}]),i}(Pi);function Ii(e){return null!==e.name.getNode()?e.name.getNode():e.getVisualName()}var Ni={none:function(e){return e},adjust:function(e){var t=e>>16&255,r=e>>8&255,n=255&e;return.2126*t+.7152*r+.0722*n>127?(t=3*t/10,r=3*r/10,n=3*n/10):(t=255-3*(255-t)/10,r=255-3*(255-r)/10,n=255-3*(255-n)/10),t<<16|r<<8|n},inverse:function(e){return 255-(e>>16&255)<<16|255-(e>>8&255)<<8|255-(255&e)}};function Oi(e,t){var r;if(Ni.hasOwnProperty(t))r=$.hexColor(Ni[t](e));else{var n=parseInt(t,16);r=!Number.isNaN(n)&&t.toLowerCase().startsWith("0x")?$.hexColor(n):"#000000"}return r}var Li={serial:function(e){return e.serial},name:function(e){return e.getVisualName()},elem:function(e){return e.element.name},residue:function(e){return e.residue.getType().getName()},sequence:function(e){return e.residue.getSequence()},chain:function(e){return e.residue.getChain().getName()},hetatm:function(e){return e.isHet()},water:function(e){return"HOH"===e.residue.getType().getName()||"WAT"===e.residue.getType().getName()}},Bi=function(e,t){return t.replace(/\{\{(\s*\w+\s*)\}\}/g,(function(t){var r=t.replace(/\s+/g,"");return r=r.substring(2,r.length-2).toLowerCase(),Li.hasOwnProperty(r)?Li[r](e):"null"}))},Di=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){var e=this._mode.getLabelOpts();return[this._selection.chunks.length,e]}},{key:"_build",value:function(){for(var e=this._mode.getLabelOpts(),t=this._selection.chunks,r=this._selection,n=r.atoms,i=r.parent,o=this._colorer,s=this._geo,a=0,l=t.length;a<l;++a){var c=n[t[a]],u=e.template?Bi(c,e.template):Ii(c);if(u){var h=o.getAtomColor(c,i),f=parseInt(Oi(h,e.fg).substring(1),16),d=e.showBg?parseInt(Oi(h,e.bg).substring(1),16):"transparent";s.setItem(a,c.position,u),s.setColor(a,f,d)}}s.finalize()}},{key:"updateToFrame",value:function(e){for(var t=this._mode.getLabelOpts(),r=this._selection.chunks,n=this._selection.atoms,i=this._colorer,o=this._geo,s=e.needsColorUpdate(i),a=0,l=r.length;a<l;++a){var c=n[r[a]],u=t.template?Bi(c,t.template):Ii(c);if(u){var h=e.getAtomColor(i,c),f=parseInt(Oi(h,t.fg).substring(1),16),d=t.showBg?parseInt(Oi(h,t.bg).substring(1),16):"transparent";o.setItem(a,e.getAtomPos(r[a]),u),s&&o.setColor(a,f,d)}}o.finalize()}}]),i}(Ei);function zi(e,t,r,n){var i=Math.sin(e);return t.clone().multiplyScalar(Math.sin((1-n)*e)/i).addScaledVector(r,Math.sin(n*e)/i)}var Fi=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_buildInner",value:function(e,t){for(var r=this._selection.chunks,n=new i.Pq0,o=new i.Pq0,s=this._segmentsHeight,a=1/s,l=this._colorer,c=this._selection,u=c.cycles,h=c.parent,f=0,d=r[f],p=0,m=u.length;p<m;++p){var v=u[p],y=v.atoms,_=[],g=[],x=v.center,b=v.radius-e,w=y.length,S=0,R=y[w-1].position,C=y[S].position;n.subVectors(R,x),o.subVectors(C,x);for(var k=o.clone().cross(n).normalize();S<w;++S){var A=n.angleTo(o);g[S]=zi(A,n,o,.5).normalize(),C=y[(S+1)%w].position,n.copy(o),o.subVectors(C,x)}for(S=0;S<w;++S)if(y[S].index===d){for(var E=g[S],P=g[(S+1)%w],T=l.getAtomColor(y[S],h),M=E.angleTo(P),I=0;I<=s;++I)_[I]=zi(M,E,P,I*a).multiplyScalar(b).add(x);t(f++,T,_,x,k),d=r[f]}}}}]),o}(Ei);function Vi(e,t){for(var r=[],n=0;n<t;++n){var o=-2*n/t*Math.PI;r.push(new i.Pq0(Math.cos(o)*e,Math.sin(o)*e,0))}return r}var Ui=kr.calcChunkMatrix,ji=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){var e=this._segmentsHeight,t=this._mode.getAromRadius(),r=new i.I9Y(t,t),n=this._mode.calcStickRadius()+2*t,o=new i.Pq0,s=[],a=this._geo;this._buildInner(n,(function(t,n,i,l,c){for(var u=0;u<=e;++u){var h=i[u],f=h.clone().sub(l).cross(c);o.addVectors(h,f),s[u]=Ui(h,o,c,r)}a.setItem(t,s),a.setColor(t,n)})),a.finalize()}},{key:"_makeGeoArgs",value:function(){return this._segmentsHeight=this._polyComplexity,[Vi(1,this._polyComplexity),this._segmentsHeight+1,this._selection.chunks.length]}}]),o}(Fi);var Gi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_build",value:function(){var e=this,t=this._geo,r=this._mode.getAromaticOffset();this._buildInner(r,(function(r,n,i){for(var o=i[0],s=1;s<=e._segmentsHeight;++s){var a=i[s];t.setSegment(r,s-1,o,a),o=a}t.setColor(r,n)})),t.finalize()}},{key:"_makeGeoArgs",value:function(){return this._segmentsHeight=this._mode.getAromaticArcChunks(),[this._selection.chunks.length,this._segmentsHeight,!0]}}]),i}(Fi);var Hi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.residues,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,s=n.length;o<s;++o)if(n[o].hasOwnProperty("chunkIdx")){var a=i[n[o].chunkIdx];a<r.length&&(n[o].residue=r[a],t.push(n[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._selection.residues,n=this._chunksIdc,i=0,o=n.length;i<o;++i)r[n[i]]._mask&e&&t.push(i);return t}}]),i}(Ai);var qi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"raycast",value:function(e,t){var r=this._selection.residues,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,s=n.length;o<s;++o)if(n[o].hasOwnProperty("chunkIdx")){var a=i[Math.floor(n[o].chunkIdx/2)];a<r.length&&(n[o].residue=r[a],t.push(n[o]))}}},{key:"_build",value:function(){for(var e=this._selection,t=e.residues,r=e.parent,n=this._colorer,i=this._geo,o=this._mode.calcStickRadius(),s=0,a=this._selection.chunks,l=0,c=a.length;l<c;++l){var u=t[a[l]],h=n.getResidueColor(u,r);this._processItem(s++,u._cylinders[0],u._cylinders[1],o,h)}i.finalize()}},{key:"_calcChunksList",value:function(e){for(var t=[],r=0,n=this._selection.residues,i=this._chunksIdc,o=0,s=i.length;o<s;++o)n[i[o]]._mask&e&&(t[r++]=2*o,t[r++]=2*o+1);return t}},{key:"updateToFrame",value:function(e){for(var t=e.getResidues(),r=this._selection.parent,n=this._colorer,i=this._geo,o=this._mode.calcStickRadius(),s=0,a=this._selection.chunks,l=0,c=a.length;l<c;++l){var u=t[a[l]],h=n.getResidueColor(u,r);this._processItem(s++,u._cylinders[0],u._cylinders[1],o,h)}i.finishUpdate()}}]),i}(Hi);var Wi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[this._selection.chunks.length,this._polyComplexity]}},{key:"_processItem",value:function(e,t,r,n,i){var o=this._geo;o.setItem(e,t,r,n),o.setColor(e,i,i)}}]),i}(qi);var Yi,Xi=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){return[2*this._selection.chunks.length,this._polyComplexity]}},{key:"_processItem",value:function(e,t,r,n,i){var o=this._geo,s=2*e;o.setItem(s,t,n),o.setColor(s,i),s++,o.setItem(s,r,n),o.setColor(s,i)}}]),i}(qi),$i={};Yi=$i,function(){var e,t,r,n,i,o,s,a,l,c,u,h,f,d,p,m,v,y,_,g,x,b,w,S,R,C,k=Object.prototype.hasOwnProperty,A=function(e,t){for(var r in t)k.call(t,r)&&(e[r]=t[r]);function n(){this.constructor=e}return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};for(m in h={method:(r={METHOD_NEAREST:"nearest",METHOD_LINEAR:"linear",METHOD_CUBIC:"cubic",METHOD_LANCZOS:"lanczos",METHOD_SINC:"sinc",CLIP_CLAMP:"clamp",CLIP_ZERO:"zero",CLIP_PERIODIC:"periodic",CLIP_MIRROR:"mirror",CUBIC_TENSION_DEFAULT:0,CUBIC_TENSION_CATMULL_ROM:0}).METHOD_CUBIC,cubicTension:r.CUBIC_TENSION_DEFAULT,clip:r.CLIP_CLAMP,scaleTo:0,sincFilterSize:2,sincWindow:void 0},l=function(e,t){return Math.max(0,Math.min(e,t-1))},u=function(e,t){return(e%=t)<0&&(e+=t),e},c=function(e,t){var r;return(e=u(e,r=2*(t-1)))>t-1&&(e=r-e),e},e=function(){function e(e,t){if(this.array=e.slice(0),this.length=this.array.length,!(this.clipHelper={clamp:this.clipHelperClamp,zero:this.clipHelperZero,periodic:this.clipHelperPeriodic,mirror:this.clipHelperMirror}[t.clip]))throw"Invalid clip: "+t.clip}return e.prototype.getClippedInput=function(e){return 0<=e&&e<this.length?this.array[e]:this.clipHelper(e)},e.prototype.clipHelperClamp=function(e){return this.array[l(e,this.length)]},e.prototype.clipHelperZero=function(e){return 0},e.prototype.clipHelperPeriodic=function(e){return this.array[u(e,this.length)]},e.prototype.clipHelperMirror=function(e){return this.array[c(e,this.length)]},e.prototype.interpolate=function(e){throw"Subclasses of AbstractInterpolator must override the interpolate() method."},e}(),i=function(e){function t(){t.__super__.constructor.apply(this,arguments)}return A(t,e),t.prototype.interpolate=function(e){return this.getClippedInput(Math.round(e))},t}(e),n=function(e){function t(){t.__super__.constructor.apply(this,arguments)}return A(t,e),t.prototype.interpolate=function(e){var t;return(1-(e-=t=Math.floor(e)))*this.getClippedInput(t)+e*this.getClippedInput(t+1)},t}(e),t=function(e){function t(e,r){this.tangentFactor=1-Math.max(-1,Math.min(1,r.cubicTension)),t.__super__.constructor.apply(this,arguments)}return A(t,e),t.prototype.getTangent=function(e){return this.tangentFactor*(this.getClippedInput(e+1)-this.getClippedInput(e-1))/2},t.prototype.interpolate=function(e){var t,r,n,i,o;return t=Math.floor(e),r=[this.getTangent(t),this.getTangent(t+1)],(2*(o=(e-=t)*(i=e*e))-3*i+1)*(n=[this.getClippedInput(t),this.getClippedInput(t+1)])[0]+(o-2*i+e)*r[0]+(-2*o+3*i)*n[1]+(o-i)*r[1]},t}(e),b=Math.sin,o=Math.PI,w=function(e){return 0===e?1:b(o*e)/(o*e)},v=function(e){return function(t){return w(t/e)}},_=function(e){return function(t){return w(t)*e(t)}},s=function(e){function t(e,r){if(t.__super__.constructor.apply(this,arguments),this.a=r.sincFilterSize,!r.sincWindow)throw"No sincWindow provided";this.kernel=_(r.sincWindow)}return A(t,e),t.prototype.interpolate=function(e){var t,r,n,i,o;for(n=0,r=i=(t=Math.floor(e))-this.a+1,o=t+this.a;i<=o?r<=o:r>=o;i<=o?r++:r--)n+=this.kernel(e-r)*this.getClippedInput(r);return n},t}(e),f=function(e,t){var r,n,i,o;for(o=[],n=0,i=e.length;n<i;n++)r=e[n],o.push(r[t]);return o},y=function(e,t,r){var n,i;return"0,1"===r.join?e:(n=t/(r[1]-r[0]),i=r[0],function(t){return e(n*(t-i))})},d=function(e){return Object.prototype.toString.call(e).slice(8,-1)},R=function(e){if(isNaN(e))throw"NaN in Smooth() input";if("Number"!==d(e))throw"Non-number in Smooth() input";if(!isFinite(e))throw"Infinity in Smooth() input"},C=function(e,t){var r,n,i;if("Array"!==d(e))throw"Non-vector in Smooth() input";if(e.length!==t)throw"Inconsistent dimension in Smooth() input";for(n=0,i=e.length;n<i;n++)r=e[n],R(r)},p=function(e){return"Number"===d(e)&&isFinite(e)&&!isNaN(e)},g=function(e){var t;switch(t="scaleTo param must be number or array of two numbers",d(e)){case"Number":if(!p(e))throw t;e=[0,e];break;case"Array":if(2!==e.length)throw t;if(!p(e[0])||!p(e[1]))throw t;break;default:throw t}return e},x=function(e){var t,r,n;for(r in t={},e)k.call(e,r)&&(n=e[r],t[r]=n);return t},a=function(e,r){var o,l,c,u,p,m,_,b,w,S,A;for(_ in null==r&&(r={}),w={},r=x(r),w.config=x(r),null==r.scaleTo&&(r.scaleTo=r.period),null==r.sincFilterSize&&(r.sincFilterSize=r.lanczosFilterSize),h)k.call(h,_)&&(A=h[_],null==r[_]&&(r[_]=A));if(!(p={nearest:i,linear:n,cubic:t,lanczos:s,sinc:s}[r.method]))throw"Invalid method: "+r.method;if("lanczos"===r.method&&(r.sincWindow=v(r.sincFilterSize)),e.length<2)throw"Array must have at least two elements";for(_ in w.count=e.length,S=function(){var t,n,i,o;switch(d(e[0])){case"Number":if(w.dimension="scalar",a.deepValidation)for(t=0,i=e.length;t<i;t++)b=e[t],R(b);return u=new p(e,r),function(e){return u.interpolate(e)};case"Array":if(w.dimension=l=e[0].length,!l)throw"Vectors must be non-empty";if(a.deepValidation)for(n=0,o=e.length;n<o;n++)A=e[n],C(A,l);return m=function(){var t;for(t=[],c=0;0<=l?c<l:c>l;0<=l?c++:c--)t.push(new p(f(e,c),r));return t}(),function(e){var t,r,n,i;for(i=[],r=0,n=m.length;r<n;r++)t=m[r],i.push(t.interpolate(e));return i};default:throw"Invalid element type: "+d(e[0])}}(),o="periodic"===r.clip?e.length:e.length-1,r.scaleTo||(r.scaleTo=o),w.domain=g(r.scaleTo),S=y(S,o,w.domain),w.domain.sort(),w)k.call(w,_)&&(A=w[_],S[_]=A);return S},r)k.call(r,m)&&(S=r[m],a[m]=S);a.deepValidation=!0,(null!==Yi?Yi:window).Smooth=a}.call(Ze);var Zi=dr.ResidueType,Qi=kr.calcChunkMatrix;function Ki(e,t){var r=$i.Smooth(e,{method:$i.Smooth.METHOD_CUBIC,clip:$i.Smooth.CLIP_CLAMP,cubicTension:t,scaleTo:1});return function(t,n){var o=n;null===o&&(o=function(t){return(t*(e.length-1-2)+1)/(e.length-1)});var s=o(t),a=r(s);return new i.Pq0(a[0],a[1],a[2])}}function Ji(e,t,r,n){if(!n._isValid)return e[r]=e[r-1],void(t[r]=t[r-1]);var i=n._controlPoint;e[r]=[i.x,i.y,i.z];var o=i.clone().add(n._wingVector);t[r]=[o.x,o.y,o.z]}var eo=function(){function e(t,r,n,i,o,a){s(this,e);var l=function(e,t,r,n){var i=n.start,o=n.end;function s(t){return t>i&&e[t-1]._isValid?t-1:t}function a(t){return t<o&&e[t+1]._isValid?t+1:t}var l=[],c=[],u=0;function h(t,r){var n=e[t]._controlPoint.clone().lerp(e[r]._controlPoint,-.25),i=n.clone().add(e[t]._wingVector);c[u]=[n.x,n.y,n.z],l[u++]=[i.x,i.y,i.z],c[u]=[n.x,n.y,n.z],l[u++]=[i.x,i.y,i.z]}var f=s(t),d=a(r);if(f===d)return function(e,t,r,n){var i,o,s=!!(n._type.flags&Zi.Flags.NUCLEIC),a=s?"C5'":"N",l=s?"C3'":"C";if(n.forEachAtom((function(e){var t=e.getVisualName();i||t!==a?o||t!==l||(o=e.position):i=e.position})),i&&o||(i=n._firstAtom.position,o=n._lastAtom.position),i&&o){var c=o.clone().sub(i),u=n._wingVector,h=n._controlPoint,f=h.clone().add(u),d=h.clone().sub(c),p=d.clone().add(u);e[r]=[d.x,d.y,d.z],t[r]=[p.x,p.y,p.z],e[++r]=[d.x,d.y,d.z],t[r]=[p.x,p.y,p.z],e[++r]=[h.x,h.y,h.z],t[r]=[f.x,f.y,f.z],++r;var m=h.clone().add(c),v=m.clone().add(u);e[r]=[m.x,m.y,m.z],t[r]=[v.x,v.y,v.z],e[++r]=[m.x,m.y,m.z],t[r]=[v.x,v.y,v.z]}}(c,l,u,e[t]),{centerPoints:c,topPoints:l};t===f?h(t,a(t)):(Ji(c,l,u++,e[s(f)]),Ji(c,l,u++,e[f]));for(var p=t;p<=r;++p)Ji(c,l,u++,e[p]);return d===a(d)?h(r,s(r)):(Ji(c,l,u++,e[d]),Ji(c,l,u,e[a(d)])),{centerPoints:c,topPoints:l}}(t,r,n,a);this._topInterp=Ki(l.topPoints,o),this._centerInterp=Ki(l.centerPoints,o),this._shift=.5/(n-r+2),this._valueStep=(1-2*this._shift)/(2*(n-r+1)*(i-1)),this._segmentsCount=i}return l(e,[{key:"prepareMatrices",value:function(e,t,r){for(var n=this._segmentsCount,o=new Array(n),s=new i.I9Y(0,0),a=this._topInterp,l=this._centerInterp,c=this._shift+this._valueStep*(n-1)*e,u=0;u<n;++u){var h=Math.min(1,u/(n-1));s.lerpVectors(t,r,h);var f=a(c,null),d=l(c,null),p=l(c+=this._valueStep,null);o[u]=Qi(d.clone(),p.clone(),f.clone().sub(d),s)}return o}}]),e}();function to(e,t){for(var r=[],n=0;n<t;++n){var o=Math.PI/2-2*Math.PI*n/t;r.push(new i.Pq0(Math.cos(o)*e,Math.sin(o)*e,0))}return r}function ro(e,t,r,n,i,o){for(var s=0,a=e.length;s<a;++s)for(var l=e[s].arr,c=e[s].boundaries,u=0,h=l.length;u<h;++u)for(var f=[l[u].start,l[u].end],d=new eo(t,f[0],f[1],r,n,c),p=null,m=2*l[u].start,v=2*l[u].end+1,y=i.getResidueRadius(t[0],0),_=m;_<=v;++_){var g=t[_/2|0],x=i.getResidueRadius(g,_%2),b=i.getResidueRadius(g,1+_%2),w=d.prepareMatrices(_-2*f[0],x,b);w.unshift(null===p?w[0]:p),o(g,w,x.x!==b.x||x.y!==b.y,x.x!==y.x||x.y!==y.y),p=w[r],y=b}}var no=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){var e=this._mode.getHeightSegmentsRatio();return this._segmentsHeight=this._polyComplexity*e|0,[to(1,this._polyComplexity),this._segmentsHeight+1,2*this._selection.chunks.length]}},{key:"_build",value:function(){var e=this._selection,t=e.residues,r=e.parent,n=this._mode,i=this._colorer,o=n.getTension(),s=this._geo,a=0,l=[];ro(this._selection.subdivs,t,this._segmentsHeight,o,n,(function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],c=i.getResidueColor(e,r);l[a]=e._index,s.setItem(a,t,n,o),s.setColor(a++,c)})),this._chunksIdc=l,s.finalize()}},{key:"updateToFrame",value:function(e){var t=this._selection.parent,r=this._mode,n=this._colorer,i=r.getTension(),o=this._geo,s=e.getResidues(),a=0,l=e.needsColorUpdate(n);ro(this._selection.subdivs,s,this._segmentsHeight,i,r,(function(e,r){o.setItem(a,r),l&&o.setColor(a,n.getResidueColor(e,t)),a++})),o.finalize()}}]),i}(Hi);var io=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=this._selection.subdivs,t=0,r=0,n=e.length;r<n;++r)for(var i=e[r].arr,o=0,s=i.length;o<s;++o)t+=i[o].end-i[o].start;return[t,this._polyComplexity]}},{key:"_build",value:function(){for(var e=this._selection,t=e.residues,r=e.parent,n=this._mode,i=this._colorer,o=this._geo,s=0,a=[],l=this._selection.subdivs,c=n.calcStickRadius(),u=0,h=l.length;u<h;++u)for(var f=l[u].arr,d=0,p=f.length;d<p;++d)for(var m=f[d].start,v=f[d].end,y=t[m],_=m+1;_<=v;++_){var g=t[_];a[s]={first:y._index,second:g._index},o.setItem(s,y._controlPoint,g._controlPoint,c),o.setColor(s,i.getResidueColor(y,r),i.getResidueColor(g,r)),s++,y=g}this._chunksIdc=a,o.finalize()}},{key:"updateToFrame",value:function(e){for(var t=e.getResidues(),r=this._selection.parent,n=this._mode,i=this._colorer,o=this._geo,s=0,a=this._selection.subdivs,l=n.calcStickRadius(),c=e.needsColorUpdate(i),u=0,h=a.length;u<h;++u)for(var f=a[u].arr,d=0,p=f.length;d<p;++d)for(var m=f[d].start,v=f[d].end,y=t[m],_=m+1;_<=v;++_){var g=t[_];o.setItem(s,y._controlPoint,g._controlPoint,l),c&&o.setColor(s,i.getResidueColor(y,r),i.getResidueColor(g,r)),s++,y=g}o.finalize()}},{key:"raycast",value:function(e,t){var r=[],n=this._selection.residues;this._mesh.raycast(e,r);for(var i=this._chunksIdc,o=0,s=r.length;o<s;++o)if(r[o].hasOwnProperty("chunkIdx")){var a=r[o].chunkIdx,l=i[Math.floor(a/2)],c=a%2==0?l.first:l.second;c<n.length&&(r[o].residue=n[c],t.push(r[o]))}}},{key:"_calcChunksList",value:function(e){for(var t=[],r=this._chunksIdc,n=this._selection.residues,i=0,o=r.length;i<o;++i){var s=r[i];n[s.first]._mask&e&&t.push(2*i),n[s.second]._mask&e&&t.push(2*i+1)}return t}}]),i}(Ai);var oo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_makeGeoArgs",value:function(){for(var e=this._mode.drawMultiorderBonds(),t=this._mode.showAromaticLoops(),r=this._selection.chunks,n=this._selection.bonds,i=0,o=0,s=r.length;o<s;++o)i+=this.getBondOrder(n[r[o]],e,t);return[i,this._polyComplexity]}},{key:"getBondOrder",value:function(e,t,r){var n=1;return!t||r&&e._type===Ee.BondType.AROMATIC||(n=function(e){return e<2?1:e}(e._order)),n}},{key:"raycast",value:function(e,t){var r=this._selection.bonds,n=[];this._mesh.raycast(e,n);for(var i=this._chunksIdc,o=0,s=n.length;o<s;++o)if(n[o].hasOwnProperty("chunkIdx")){var a=n[o].chunkIdx,l=i[Math.floor(a/2)];if(l<r.length){var c=r[l];n[o].atom=a%2==0?c._left:c._right,t.push(n[o])}}}},{key:"_calcChunksList",value:function(e,t){for(var r=[],n=this._selection.bonds,i=this._chunksIdc,o=0,s=i.length;o<s;++o){var a=n[i[o]];a._left.mask&e&&(!t||a._right.mask&e)&&r.push(2*o),a._right.mask&e&&(!t||a._left.mask&e)&&r.push(2*o+1)}return r}}]),i}(Ai);var so=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){for(var e,t=this._selection.chunks,r=this._selection,n=r.bonds,o=r.parent,s=this._mode,a=this._colorer,l=this._geo,c=s.drawMultiorderBonds(),u=s.showAromaticLoops(),h=s.calcStickRadius(),f=s.calcSpaceFraction(),d=new i.Pq0,p=new i.Pq0,m=0,v=[],y=0,_=t.length;y<_;++y){var g=n[t[y]],x=g._left,b=g._right,w=x.position,S=b.position;e=g.calcNormalDir();for(var R=this.getBondOrder(g,c,u),C=2*Math.min(s.calcAtomRadius(x),s.calcAtomRadius(b))/R,k=c?Math.min(h,.5*C*(1-f)):h,A=0;A<R;++A){var E=C*(R%2==0?(.5+(A/2|0))*(1-A%2*2):((A+1)/2|0)*(A%2*2-1));v[m]=g._index,d.copy(w),d.addScaledVector(e,E),p.copy(S),p.addScaledVector(e,E),l.setItem(m,d,p,k),l.setColor(m++,a.getAtomColor(x,o),a.getAtomColor(b,o))}}l.finalize(),this._chunksIdc=v}},{key:"updateToFrame",value:function(e){for(var t,r=this._selection.chunks,n=this._selection.bonds,o=this._mode,s=this._colorer,a=this._geo,l=o.drawMultiorderBonds(),c=o.showAromaticLoops(),u=o.calcStickRadius(),h=o.calcSpaceFraction(),f=new i.Pq0,d=new i.Pq0,p=0,m=e.needsColorUpdate(s),v=0,y=r.length;v<y;++v){var _=n[r[v]],g=_._left,x=_._right,b=e.getAtomPos(g.index).clone(),w=e.getAtomPos(x.index);t=_.calcNormalDir();for(var S=this.getBondOrder(_,l,c),R=2*Math.min(o.calcAtomRadius(g),o.calcAtomRadius(x))/S,C=l?Math.min(u,.5*R*(1-h)):u,k=0;k<S;++k){var A=R*(S%2==0?(.5+(k/2|0))*(1-k%2*2):((k+1)/2|0)*(k%2*2-1));f.copy(b),f.addScaledVector(t,A),d.copy(w),d.addScaledVector(t,A),a.setItem(p,f,d,C),m&&a.setColor(p,e.getAtomColor(s,g),e.getAtomColor(s,x)),p++}}a.finalize()}}]),o}(oo);var ao=.15,lo=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"_build",value:function(){for(var e=this._selection.chunks,t=this._selection,r=t.bonds,n=t.parent,o=this._mode,s=this._colorer,a=this._geo,l=o.drawMultiorderBonds(),c=o.showAromaticLoops(),u=new i.Pq0,h=new i.Pq0,f=new i.Pq0,d=0,p=[],m=0,v=e.length;m<v;++m){var y=r[e[m]],_=y._left,g=y._right,x=_.position,b=g.position,w=1===_.bonds.length,S=1===g.bonds.length;u.subVectors(b,x);for(var R=u.length(),C=y.calcNormalDir(),k=this.getBondOrder(y,l,c),A=0;A<k;++A){h.copy(x),f.copy(b);var E=k%2==0?(.5+(A/2|0))*(1-A%2*2):((A+1)/2|0)*(A%2*2-1);p[d]=y._index,2!==k||w||S||(E-=.5,E*=-1),!w&&!S&&k>1&&0!==E&&(h.lerpVectors(x,b,ao/R),f.lerpVectors(x,b,1-ao/R)),E*=ao,h.addScaledVector(C,E),f.addScaledVector(C,E),a.setItem(d,h,f),a.setColor(d++,s.getAtomColor(_,n),s.getAtomColor(g,n))}}a.finalize(),this._chunksIdc=p}},{key:"updateToFrame",value:function(e){for(var t=this._selection.chunks,r=this._selection.bonds,n=this._mode,o=this._colorer,s=this._geo,a=n.drawMultiorderBonds(),l=n.showAromaticLoops(),c=new i.Pq0,u=new i.Pq0,h=new i.Pq0,f=0,d=e.needsColorUpdate(o),p=0,m=t.length;p<m;++p){var v=r[t[p]],y=v._left,_=v._right,g=e.getAtomPos(y.index).clone(),x=e.getAtomPos(_.index),b=1===y.bonds.length,w=1===_.bonds.length;c.subVectors(x,g);for(var S=c.length(),R=v.calcNormalDir(),C=this.getBondOrder(v,a,l),k=0;k<C;++k){u.copy(g),h.copy(x);var A=C%2==0?(.5+(k/2|0))*(1-k%2*2):((k+1)/2|0)*(k%2*2-1);2!==C||b||w||(A-=.5,A*=-1),!b&&!w&&C>1&&0!==A&&(u.lerpVectors(g,x,ao/S),h.lerpVectors(g,x,1-ao/S)),A*=ao,u.addScaledVector(R,A),h.addScaledVector(R,A),s.setItem(f,u,h),d&&s.setColor(f,e.getAtomColor(o,y),e.getAtomColor(o,_)),f++}}s.finalize()}}]),o}(oo),co={AtomsSphereGroup:Pi,AtomsSurfaceGroup:Ti,AtomsSASSESGroupStub:Mi,AtomsTextGroup:Di,AromaticTorusGroup:ji,AromaticLinesGroup:Gi,NucleicCylindersGroup:Wi,NucleicSpheresGroup:Xi,ResiduesSubseqGroup:no,ResiduesTraceGroup:io,BondsCylinderGroup:so,BondsLinesGroup:lo};var uo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,u,h){var f;s(this,i);var d=c(f=n.call(this));f._complex=r,f._mode=a;var p=r.getAtoms(),m=r.getTransforms();return r.forEachComponent((function(n){var i=[],s=0;if(n.forEachAtom((function(e){d._checkAtom(e,u)&&(i[s++]=e.index)})),0!==s){var c=new e(t,{atoms:p,chunks:i,parent:r},o,a,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"_checkAtom",value:function(e,t){return e.mask&t}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,s=n.length;o<s;++o)if(n[o].getSubset)for(var a=n[o].getSubset(e,t),l=0,c=a.length;l<c;++l){var u=a[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(mr);var ho=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_checkAtom",value:function(e,t){if(!(e.mask&t))return!1;for(var r=e.bonds,n=0,i=r.length;n<i;++n)if(r[n]._left.mask&t&&r[n]._right.mask&t)return!1;return!0}}]),i}(uo);var fo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,u,h){var f;s(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getResidues(),m=r.getTransforms();return r.forEachComponent((function(n){var i=0,s=[];if(n.forEachResidue((function(e){d._checkResidue(e,u)&&(s[i++]=e._index)})),0!==i){var c=new e(t,{residues:p,chunks:s,parent:r},o,a,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"checkResidue",value:function(e,t){return e._mask&t}},{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,s=n.length;o<s;++o)if(n[o].getSubset)for(var a=n[o].getSubset(e,t),l=0,c=a.length;l<c;++l){var u=a[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(mr);var po=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_checkResidue",value:function(e,t){return t&e._mask&&null!==e._cylinders}}]),i}(fo);var mo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,u,h){var f;s(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getResidues(),m=r.getTransforms();return r.forEachComponent((function(n){for(var i=n.getMaskedSubdivSequences(u),s=0,c=[],f=0,v=i.length;f<v;++f)for(var y=i[f].arr,_=0,g=y.length;_<g;++_)for(var x=y[_].start,b=y[_].end;x<=b;++x)c[s++]=p[x]._index;if(0!==s){var w=new e(t,{residues:p,chunks:c,subdivs:i,parent:r},o,a,m,l,h);w._component=n,d.add(w)}})),f}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,s=n.length;o<s;++o)if(n[o].getSubset)for(var a=n[o].getSubset(e,t),l=0,c=a.length;l<c;++l){var u=a[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(mr);var vo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,u,h){var f;s(this,i);var d=c(f=n.call(this));f._complex=r;var p=r.getBonds(),m=r.getTransforms();return r.forEachComponent((function(n){var i=[],s=0;if(n.forEachBond((function(e){var t=e._left,r=e._right;t.mask&u&&r.mask&u&&(i[s++]=e._index)})),0!==s){var c=new e(t,{bonds:p,chunks:i,parent:r},o,a,m,l,h);c._component=n,d.add(c)}})),f}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,s=n.length;o<s;++o)if(n[o].getSubset)for(var a=n[o].getSubset(e,t),l=0,c=a.length;l<c;++l){var u=a[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(mr);var yo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r,o,a,l,u,h){var d;s(this,i);var p=c(d=n.call(this));d._complex=r;var m=r.getAtoms(),v=r.getTransforms();return a.showAromaticLoops()?(r.forEachComponent((function(n){var i=[],s=0,c=[],f=0;n.forEachCycle((function(e){for(var t=e.atoms,r=0,n=0,o=t.length;n<o;++n)t[n].mask&u&&(++r,i[s++]=t[n].index);r>0&&(c[f++]=e)}));var d=new e(t,{cycles:c,atoms:m,chunks:i,parent:r},o,a,v,l,h);d._component=n,p.add(d)})),d):f(d)}return l(i,[{key:"getSubset",value:function(e,t){for(var r=[],n=this.children,i=0,o=0,s=n.length;o<s;++o)if(n[o].getSubset)for(var a=n[o].getSubset(e,t),l=0,c=a.length;l<c;++l){var u=a[l];u._component=n[o]._component,r[i++]=u}return r}}]),i}(mr),_o={Atoms:uo,OrphanAtoms:ho,Residues:fo,Nucleic:po,Subseqs:mo,Bonds:vo,Aromatic:yo};function go(e,t,r){return function(n,i,o,s,a,l){return new t(r,e,n,i,o,s,a,l)}}var xo=function(){function e(){s(this,e)}return l(e,null,[{key:"AtomsSpheres",value:function(e,t){return go(Ci.createSpheres(e,t),_o.Atoms,co.AtomsSphereGroup)}},{key:"OrphanedAtomsCrosses",value:function(e,t,r){return go(Ci.createCrosses(e,t,r),_o.OrphanAtoms,co.AtomsSphereGroup)}},{key:"BondsCylinders",value:function(e,t){return go(Ci.create2CCylinders(e,t),_o.Bonds,co.BondsCylinderGroup)}},{key:"BondsLines",value:function(e,t,r){return go(Ci.create2CLines(e,t,r),_o.Bonds,co.BondsLinesGroup)}},{key:"CartoonChains",value:function(e,t){return go(Ci.createExtrudedChains(e,t),_o.Subseqs,co.ResiduesSubseqGroup)}},{key:"TraceChains",value:function(e,t){return go(Ci.create2CClosedCylinders(e,t),_o.Subseqs,co.ResiduesTraceGroup)}},{key:"NucleicSpheres",value:function(e,t){return go(Ci.createSpheres(e,t),_o.Nucleic,co.NucleicSpheresGroup)}},{key:"NucleicCylinders",value:function(e,t){return go(Ci.create2CCylinders(e,t),_o.Nucleic,co.NucleicCylindersGroup)}},{key:"ALoopsTorus",value:function(e,t){return go(Ci.createExtrudedChains(e,t),_o.Aromatic,co.AromaticTorusGroup)}},{key:"ALoopsLines",value:function(e,t,r){return go(Ci.createChunkedLines(e,t,r),_o.Aromatic,co.AromaticLinesGroup)}},{key:"QuickSurfGeo",value:function(e,t,r){return go(Ci.createQuickSurface(e,t,r),_o.Atoms,co.AtomsSurfaceGroup)}},{key:"ContactSurfaceGeo",value:function(e,t,r){return go(Ci.createContactSurface(e,t,r),_o.Atoms,co.AtomsSurfaceGroup)}},{key:"SASSESSurfaceGeo",value:function(e,t,r){return go(Ci.createSASSES(e,t,r),_o.Atoms,co.AtomsSASSESGroupStub)}},{key:"TextLabelsGeo",value:function(e,t){return go(Ci.createLabels(e,t),_o.Atoms,co.AtomsTextGroup)}}]),e}(),bo=function(){function e(t){if(s(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.opts=(0,n.merge)($.deriveDeep(this.settings.now.modes[this.id],!0),t)}return l(e,[{key:"identify",value:function(){var e=$.objectsDiff(this.opts,this.settings.now.modes[this.id]);return(0,n.isEmpty)(e)?this.id:[this.id,e]}},{key:"buildGeometry",value:function(e,t,r,i){for(var o=this.opts.polyComplexity?this.opts.polyComplexity[this.settings.now.resolution]:0,s=this.depGroups,a=s.length,l=new kr.RCGroup,c=0;c<a;++c){var u=s[c],h={};(0,n.isArray)(u)&&(h=u[1].call(this),u=v(u,1)[0]);var f=new(xo[u](null,this.settings,h))(e,t,this,o,r,i);f.children.length>0&&l.add(f)}return l}}]),e}();function wo(){return{lineWidth:this.opts.lineWidth}}Ir(bo.prototype),bo.prototype.id="__",bo.prototype.depGroups=[];var So=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;s(this,i),(t=n.call(this,e)).depGroups=t.depGroups.slice(0);for(var r=t.depGroups,o=0,a=r.length;o<a;++o)r[o]=[r[o],wo];return t}return l(i,[{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}},{key:"calcAtomRadius",value:function(){return this.opts.atom}},{key:"getAromaticOffset",value:function(){return this.opts.offsarom}},{key:"getAromaticArcChunks",value:function(){return this.opts.chunkarom}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}}]),i}(bo);Se(So,"id","LN"),So.prototype.id="LN",So.prototype.name="Lines",So.prototype.shortName="Lines",So.prototype.depGroups=["ALoopsLines","BondsLines","OrphanedAtomsCrosses"];var Ro=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return this.opts.bond}},{key:"calcStickRadius",value:function(){return this.opts.bond}},{key:"calcSpaceFraction",value:function(){return this.opts.space}},{key:"getAromRadius",value:function(){return this.opts.aromrad}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}},{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}}]),i}(bo);Se(Ro,"id","LC"),Ro.prototype.id="LC",Ro.prototype.name="Licorice",Ro.prototype.shortName="Licorice",Ro.prototype.depGroups=["AtomsSpheres","BondsCylinders","ALoopsTorus"];var Co=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius*this.opts.atom}},{key:"calcStickRadius",value:function(){return this.opts.bond}},{key:"getAromRadius",value:function(){return this.opts.aromrad}},{key:"showAromaticLoops",value:function(){return this.opts.showarom}},{key:"calcSpaceFraction",value:function(){return this.opts.space}},{key:"drawMultiorderBonds",value:function(){return this.opts.multibond}}]),i}(bo);Se(Co,"id","BS"),Co.prototype.id="BS",Co.prototype.name="Balls and Sticks",Co.prototype.shortName="Balls",Co.prototype.depGroups=["AtomsSpheres","BondsCylinders","ALoopsTorus"];var ko=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}}]),i}(bo);Se(ko,"id","VW"),ko.prototype.id="VW",ko.prototype.name="Van der Waals",ko.prototype.shortName="VDW",ko.prototype.depGroups=["AtomsSpheres"];var Ao=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"calcStickRadius",value:function(){return this.opts.radius}}]),i}(bo);Se(Ao,"id","TR"),Ao.prototype.id="TR",Ao.prototype.name="Trace",Ao.prototype.shortName="Trace",Ao.prototype.depGroups=["TraceChains"];var Eo=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),n.apply(this,arguments)}return l(o,[{key:"getResidueRadius",value:function(e){return this.TUBE_RADIUS}},{key:"getHeightSegmentsRatio",value:function(){return this.opts.heightSegmentsRatio}},{key:"getTension",value:function(){return this.opts.tension}},{key:"buildGeometry",value:function(e,t,r,n){var o=this.opts.radius;return this.TUBE_RADIUS=new i.I9Y(o,o),bo.prototype.buildGeometry.call(this,e,t,r,n)}}]),o}(bo);Se(Eo,"id","TU"),Eo.prototype.id="TU",Eo.prototype.name="Tube",Eo.prototype.shortName="Tube",Eo.prototype.depGroups=["CartoonChains"];var Po=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return s(this,o),(t=n.call(this,e)).secCache={},t}return l(o,[{key:"getResidueStartRadius",value:function(e){var t=e.getSecondary();if(!t||!t.generic)return this.TUBE_RADIUS;var r=this.secCache[t.generic];return r?t.term===e?r.start:r.center:this.TUBE_RADIUS}},{key:"getResidueEndRadius",value:function(e){var t=e.getSecondary();if(null===t||!t.generic)return this.TUBE_RADIUS;var r=this.secCache[t.generic];return r?t.term===e?this.ARROW_END:r.center:this.TUBE_RADIUS}},{key:"getResidueRadius",value:function(e,t){var r=this.getResidueStartRadius(e);if(0===t)return r;var n=this.getResidueEndRadius(e);return 2===t?n:r.clone().lerp(n,t/2)}},{key:"calcStickRadius",value:function(e){return this.opts.radius}},{key:"getHeightSegmentsRatio",value:function(){return this.opts.heightSegmentsRatio}},{key:"getTension",value:function(){return this.opts.tension}},{key:"buildGeometry",value:function(e,t,r,n){var o=this.opts.radius,s=this.opts.depth;this.TUBE_RADIUS=new i.I9Y(o,o),this.ARROW_END=new i.I9Y(s,o);var a={},l=this.opts.ss;for(var c in l)a[c]={center:new i.I9Y(s,l[c].width),start:new i.I9Y(s,l[c].arrow)};return this.secCache=a,bo.prototype.buildGeometry.call(this,e,t,r,n)}}]),o}(bo);Se(Po,"id","CA"),Po.prototype.id="CA",Po.prototype.name="Cartoon",Po.prototype.shortName="Cartoon",Po.prototype.depGroups=["CartoonChains","NucleicSpheres","NucleicCylinders"];var To=dr.selectors;function Mo(){return{wireframe:this.opts.wireframe,zClip:this.opts.zClip}}var Io=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;s(this,i),(t=n.call(this,e)).depGroups=t.depGroups.slice(0);for(var r=t.surfaceNames,o=t.depGroups,a=0,l=r.length;a<l;++a)o[o.length]=[r[a],Mo];return t}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}},{key:"getVisibilitySelector",value:function(){var e=null;if(""!==this.opts.subset){var t=To.parse(this.opts.subset);t.error||(e=t.selector)}return e}}]),i}(bo);Io.prototype.isSurface=!0,Io.prototype.surfaceNames=[];var No=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getSurfaceOpts",value:function(){return{useBeads:!1,isoValue:this.opts.isoValue,gaussLim:this.opts.gaussLim[this.settings.now.resolution],radScale:this.opts.scale,gridSpacing:this.opts.gridSpacing[this.settings.now.resolution],zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}}}]),i}(Io);Se(No,"id","QS"),No.prototype.id="QS",No.prototype.name="Quick Surface",No.prototype.shortName="Quick Surf",No.prototype.surfaceNames=["QuickSurfGeo"];var Oo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this,t))._excludeProbe=e,r}return l(i,[{key:"calcAtomRadius",value:function(e){return e.element.radius}},{key:"getSurfaceOpts",value:function(){return{gridSpacing:this.opts.polyComplexity[this.settings.now.resolution],radScale:this._radScale,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector(),probeRadius:this.opts.probeRadius,excludeProbe:this._excludeProbe}}}]),i}(Io);Oo.prototype.id="SU",Oo.prototype.name="Surface",Oo.prototype.shortName="Surface",Oo.prototype.surfaceNames=["SASSESSurfaceGeo"],Oo.prototype._radScale=1,Oo.prototype._excludeProbe=!1;var Lo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return s(this,i),n.call(this,!1,e)}return l(i)}(Oo);Se(Lo,"id","SA"),Lo.prototype.id="SA",Lo.prototype.name="Solvent Accessible Surface",Lo.prototype.shortName="SAS";var Bo=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){return s(this,i),n.call(this,!0,e)}return l(i)}(Oo);Se(Bo,"id","SE"),Bo.prototype.id="SE",Bo.prototype.name="Solvent Excluded Surface",Bo.prototype.shortName="SES";var Do=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getSurfaceOpts",value:function(){return{probeRadius:this.opts.probeRadius,radScale:this.opts.polyComplexity[this.settings.now.resolution],scaleFactor:this.opts.polyComplexity[this.settings.now.resolution],gridSpacing:1/this.opts.polyComplexity[this.settings.now.resolution],isoValue:this.opts.isoValue,probePositions:this.opts.probePositions,zClip:this.opts.zClip,visibilitySelector:this.getVisibilitySelector()}}}]),i}(Io);Se(Do,"id","CS"),Do.prototype.id="CS",Do.prototype.name="Contact Surface",Do.prototype.shortName="Contact Surf",Do.prototype.isSurface=!0,Do.prototype.surfaceNames=["ContactSurfaceGeo"];var zo=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){return s(this,o),i.apply(this,arguments)}return l(o,[{key:"getTemplateOptions",value:function(){return this.opts.template}},{key:"getLabelOpts",value:function(){return(0,n.merge)(this.opts,{colors:!0,adjustColor:!0,transparent:!0})}}]),o}(bo);Se(zo,"id","TX"),zo.prototype.id="TX",zo.prototype.name="Text mode",zo.prototype.shortName="Text",zo.prototype.depGroups=["TextLabelsGeo"];var Fo=new Mr([So,Ro,Co,ko,Ao,Eo,Po,No,Lo,Bo,Do,zo]);function Vo(e,t,r){return e<=r?e<0?0:e:r}var Uo=function(){function e(t,r){s(this,e),this.name=t||"Custom",this.id=r||"CP"}return l(e,[{key:"getElementColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.elementColors[e];return void 0!==r||t?r:this.defaultElementColor}},{key:"getResidueColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.residueColors[e];return void 0!==r||t?r:this.defaultResidueColor}},{key:"getChainColor",value:function(e){var t=e.charCodeAt(0);return t=(31&(t<0?0:t>=256?t-256:t))%this.chainColors.length,this.chainColors[t]}},{key:"getSecondaryColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.secondaryColors[e];return void 0!==r||t?r:this.defaultSecondaryColor}},{key:"getSequentialColor",value:function(e){var t=this.colors,r=t.length;return e<0?t[e%r+r]:t[e%r]}},{key:"getGradientColor",value:function(e,t){var r=this.gradients[t];if(!r)return this.defaultNamedColor;var n,i,o,s,a=r.length,l=e*(a-1),c=Math.floor(l),u=Vo(c+1,0,a-1);return(s=1-(o=l-(c=Vo(c,0,a-1))))*((n=r[c])>>16&255)+o*((i=r[u])>>16&255)<<16|s*(n>>8&255)+o*(i>>8&255)<<8|s*(255&n)+o*(255&i)}},{key:"getNamedColor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.namedColors[e];return void 0!==r||t?r:this.defaultNamedColor}}]),e}();(0,n.assign)(Uo.prototype,{colors:[16777215,16711680,65280,255,8421504],minRangeColor:0,midRangeColor:8355711,maxRangeColor:16777215,defaultElementColor:16777215,elementColors:{},defaultResidueColor:16777215,residueColors:{},chainColors:[16777215],defaultSecondaryColor:16777215,secondaryColors:{},defaultGradientColor:0,defaultNamedColor:16777215,namedColorsArray:[["indianred",13458524],["lightcoral",15761536],["salmon",16416882],["darksalmon",15308410],["lightsalmon",16752762],["crimson",14423100],["red",16711680],["firebrick",11674146],["darkred",9109504],["pink",16761035],["lightpink",16758465],["hotpink",16738740],["deeppink",16716947],["mediumvioletred",13047173],["palevioletred",14381203],["coral",16744272],["tomato",16737095],["orangered",16729344],["darkorange",16747520],["orange",16753920],["gold",16766720],["yellow",16776960],["lightyellow",16777184],["lemonchiffon",16775885],["lightgoldenrodyellow",16448210],["papayawhip",16773077],["moccasin",16770229],["peachpuff",16767673],["palegoldenrod",15657130],["khaki",15787660],["darkkhaki",12433259],["lavender",15132410],["thistle",14204888],["plum",14524637],["violet",15631086],["orchid",14315734],["fuchsia",16711935],["magenta",16711935],["mediumorchid",12211667],["mediumpurple",9662683],["rebeccapurple",6697881],["blueviolet",9055202],["darkviolet",9699539],["darkorchid",10040012],["darkmagenta",9109643],["purple",8388736],["indigo",4915330],["slateblue",6970061],["mediumslateblue",8087790],["darkslateblue",4734347],["greenyellow",11403055],["chartreuse",8388352],["lawngreen",8190976],["lime",65280],["limegreen",3329330],["palegreen",10025880],["lightgreen",9498256],["mediumspringgreen",64154],["springgreen",65407],["mediumseagreen",3978097],["seagreen",3050327],["forestgreen",2263842],["green",32768],["darkgreen",25600],["yellowgreen",10145074],["olivedrab",7048739],["olive",8421376],["darkolivegreen",5597999],["mediumaquamarine",6737322],["darkseagreen",9419919],["lightseagreen",2142890],["darkcyan",35723],["teal",32896],["aqua",65535],["cyan",65535],["lightcyan",14745599],["paleturquoise",11529966],["aquamarine",8388564],["turquoise",4251856],["mediumturquoise",4772300],["darkturquoise",52945],["cadetblue",6266528],["steelblue",4620980],["lightsteelblue",11584734],["powderblue",11591910],["lightblue",11393254],["skyblue",8900331],["lightskyblue",8900346],["deepskyblue",49151],["dodgerblue",2003199],["cornflowerblue",6591981],["royalblue",4286945],["blue",255],["mediumblue",205],["darkblue",139],["navy",128],["midnightblue",1644912],["cornsilk",16775388],["blanchedalmond",16772045],["bisque",16770244],["navajowhite",16768685],["wheat",16113331],["burlywood",14596231],["tan",13808780],["rosybrown",12357519],["sandybrown",16032864],["goldenrod",14329120],["darkgoldenrod",12092939],["peru",13468991],["chocolate",13789470],["saddlebrown",9127187],["sienna",10506797],["brown",10824234],["maroon",8388608],["white",16777215],["snow",16775930],["honeydew",15794160],["mintcream",16121850],["azure",15794175],["aliceblue",15792383],["ghostwhite",16316671],["whitesmoke",16119285],["seashell",16774638],["beige",16119260],["oldlace",16643558],["floralwhite",16775920],["ivory",16777200],["antiquewhite",16444375],["linen",16445670],["lavenderblush",16773365],["mistyrose",16770273],["gainsboro",14474460],["lightgray",13882323],["silver",12632256],["darkgray",11119017],["gray",8421504],["dimgray",6908265],["lightslategray",7833753],["slategray",7372944],["darkslategray",3100495],["black",0]],namedColors:{},gradients:{rainbow:[255,65535,65280,16776960,16711680],temp:[255,32767,16777215,16744192,16711680],hot:[16777215,16744192,16711680],cold:[16777215,32767,255],"blue-red":[255,16777215,16711680],reds:[16777215,16711680],blues:[16777215,255]}});for(var jo=Uo.prototype,Go=jo.namedColorsArray,Ho=jo.namedColors,qo=0,Wo=Go.length;qo<Wo;++qo){var Yo=v(Go[qo],2),Xo=Yo[0],$o=Yo[1];Ho[Xo]=$o}var Zo,Qo=new Uo("CPK","CP");Qo.elementColors={H:16777215,C:2105376,N:2121983,O:15605776,F:65280,P:8397055,S:16776960,CL:47872,FE:13684944,CO:13684944,NI:13684944,CU:13684944,BR:34816,I:21760};var Ko=new Uo("Jmol","JM");Ko.colors=[255,22015,44031,65535,65451,65365,65280,5635840,11271936,16776960,16755456,16733440,16711680,16711765,16711851,16711935,11206911,5570815],Ko.elementColors={H:16777215,D:16777152,T:16777120,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:4366e3,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998},Ko.defaultResidueColor=12492910,Ko.residueColors={ALA:13158600,ARG:1334015,ASN:56540,ASP:15075850,CYS:15132160,GLN:56540,GLU:15075850,GLY:15461355,HIS:8553170,ILE:1016335,LEU:1016335,LYS:1334015,MET:15132160,PHE:3289770,PRO:14456450,SER:16422400,THR:16422400,TRP:11819700,TYR:3289770,VAL:1016335,A:10526975,C:16747595,G:16740464,I:8454143,T:10551200,U:16744576,DA:10526975,DC:16747595,DG:16740464,DI:8454143,DT:10551200,DU:16744576,"+A":10526975,"+C":16747595,"+G":16740464,"+I":8454143,"+T":10551200,"+U":16744576},Ko.chainColors=[4294967295,4290826495,4289789872,4294951112,4294967168,4294951167,4289786096,4294955120,4293951616,4294303411,4278239231,4291648604,4284927402,4288335154,4293821166,4278243025,4278255487,4282168177,4278190219,4290623339,4278215680,4286578688,4286611456,4286578816,4278222976,4290283019,4289864226];var Jo,es=Ve.Type;Ko.secondaryColors=(Se(Zo={},es.HELIX_ALPHA,16711808),Se(Zo,es.HELIX_PI,6291584),Se(Zo,es.HELIX_310,10485888),Se(Zo,es.STRAND,16762880),Se(Zo,es.TURN,6324479),Se(Zo,"dna",11403518),Se(Zo,"rna",16580962),Zo);var ts=new Uo("VMD","VM");ts.colors=[255,16711680,6316128,16744448,16776960,8421427,10066329,65280,16777215,16751001,4243648,10879142,8447590,15099571,8408320,8421568],ts.defaultElementColor=8408320,ts.elementColors={H:16777215,C:4243391,N:255,O:16711680,P:8421427,S:16776960},ts.defaultResidueColor=4243648,ts.residueColors={ALA:255,ARG:16777215,ASN:8421427,ASP:16711680,CYS:16776960,GLN:16744448,GLU:16751001,GLY:16777215,HIS:4243648,ILE:65280,LEU:16751001,LYS:4243648,MET:16776960,PHE:10879142,PRO:8408064,SER:16776960,THR:15099571,TRP:10066329,TYR:65280,VAL:8421427,A:255,C:16744448,G:16776960,T:10879142,U:65280,DA:255,DC:16744448,DG:16776960,DT:10879142,DU:65280,"+A":255,"+C":16744448,"+G":16776960,"+T":10879142,"+U":65280,WAT:4243648,H2O:4243648,HOH:4243648},ts.chainColors=[16777215].concat(ts.colors);var rs=Ve.Type;ts.secondaryColors=(Se(Jo={},rs.HELIX_ALPHA,10879142),Se(Jo,rs.HELIX_310,255),Se(Jo,rs.HELIX_PI,16711680),Se(Jo,rs.STRAND,16776960),Se(Jo,rs.BRIDGE,8421427),Se(Jo,rs.TURN,4243648),Jo);var ns=new Mr([Qo,Ko,ts]),is=function(){function e(t){if(s(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.opts=(0,n.merge)($.deriveDeep(J.now.colorers[this.id],!0),t),this.palette=ns.first}return l(e,[{key:"identify",value:function(){var e=$.objectsDiff(this.opts,J.now.colorers[this.id]);return(0,n.isEmpty)(e)?this.id:[this.id,e]}}]),e}();is.prototype.id="__";var os=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r=e.element.name;return"C"===r&&this.opts.carbon>=0?this.opts.carbon:this.palette.getElementColor(r)}},{key:"getResidueColor",value:function(e,t){return this.palette.defaultResidueColor}}]),i}(is);Se(os,"id","EL"),os.prototype.id="EL",os.prototype.name="Element",os.prototype.shortName="Element";var ss=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getResidueColor(e._type._name)}}]),i}(is);Se(ss,"id","RT"),ss.prototype.id="RT",ss.prototype.name="Residue Type",ss.prototype.shortName="Residue";var as=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._chain;if(r.minSequence===Number.POSITIVE_INFINITY&&r.maxSequence===Number.NEGATIVE_INFINITY)return this.palette.defaultNamedColor;var n=r.minSequence,i=r.maxSequence>n?r.maxSequence:n+1;return this.palette.getGradientColor((e._sequence-n)/(i-n),this.opts.gradient)}}]),i}(is);Se(as,"id","SQ"),as.prototype.id="SQ",as.prototype.name="Sequence",as.prototype.shortName="Sequence";var ls=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){return this.palette.getChainColor(e.getChain()._name)}}]),i}(is);Se(ls,"id","CH"),ls.prototype.id="CH",ls.prototype.name="Chain",ls.prototype.shortName="Chain";var cs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){if(e._type.flags&Le.Flags.DNA)return this.palette.getSecondaryColor("dna");if(e._type.flags&Le.Flags.RNA)return this.palette.getSecondaryColor("rna");var r=e.getSecondary();if(r){var n=this.palette.getSecondaryColor(r.type,!0);return void 0===n&&(n=this.palette.getSecondaryColor(r.generic)),n}return this.palette.defaultSecondaryColor}}]),i}(is);Se(cs,"id","SS"),cs.prototype.id="SS",cs.prototype.name="Secondary Structure",cs.prototype.shortName="Structure";var us=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.opts.color}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(is);Se(us,"id","UN"),us.prototype.id="UN",us.prototype.name="Uniform",us.prototype.shortName="Uniform";var hs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;s(this,i),t=n.call(this,e);var r=wt.parse(t.opts.subset);return t._subsetCached=r.error?wt.none():r.selector,t}return l(i,[{key:"getAtomColor",value:function(e,t){return this._subsetCached.includesAtom(e)?this.opts.color:this.opts.baseColor}},{key:"getResidueColor",value:function(e,t){for(var r=this._subsetCached,n=e._atoms,i=0,o=n.length;i<o;++i)if(!r.includesAtom(n[i]))return this.opts.baseColor;return this.opts.color}}]),i}(is);Se(hs,"id","CO"),hs.prototype.id="CO",hs.prototype.name="Conditional",hs.prototype.shortName="Conditional";var fs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.palette.getChainColor(String.fromCharCode(e.location))}},{key:"getResidueColor",value:function(e,t){return this.palette.defaultResidueColor}}]),i}(is);Se(fs,"id","CF"),fs.prototype.id="CF",fs.prototype.name="Conformation",fs.prototype.shortName="Conformation";var ds=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r=this.opts,n=1;return e.temperature&&r?(n=r.min===r.max?e.temperature>r.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)):this.palette.defaultGradientColor}},{key:"getResidueColor",value:function(e,t){var r=this.opts;if(!r)return this.palette.defaultGradientColor;if(e.temperature){var n;return n=r.min===r.max?e.temperature>r.max?1:0:(e.temperature-r.min)/(r.max-r.min),this.palette.getGradientColor(n,r.gradient)}return this.palette.defaultGradientColor}}]),i}(is);Se(ds,"id","TM"),ds.prototype.id="TM",ds.prototype.name="Temperature",ds.prototype.shortName="Temperature";var ps=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"_getColorByOccupancy",value:function(e,t){if(void 0!==e){var r=1-e;return this.palette.getGradientColor(r,t.gradient)}return this.palette.defaultGradientColor}},{key:"getAtomColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}},{key:"getResidueColor",value:function(e,t){var r=this.opts;return this._getColorByOccupancy(e.occupancy,r)}}]),i}(is);Se(ps,"id","OC"),ps.prototype.id="OC",ps.prototype.name="Occupancy",ps.prototype.shortName="Occupancy";var ms=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=this.palette.defaultResidueColor;return void 0!==e._type.hydrophobicity&&(r=this.palette.getGradientColor((e._type.hydrophobicity- -4.5)/9,this.opts.gradient)),r}}]),i}(is);Se(ms,"id","HY"),ms.prototype.id="HY",ms.prototype.name="Hydrophobicity",ms.prototype.shortName="Hydrophobicity";var vs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){return this.getResidueColor(e.residue,t)}},{key:"getResidueColor",value:function(e,t){var r=e._molecule,n=t.getMoleculeCount();return n>1?this.palette.getGradientColor((r.index-1)/(n-1),this.opts.gradient):this.palette.getGradientColor(0,this.opts.gradient)}}]),i}(is);Se(vs,"id","MO"),vs.prototype.id="MO",vs.prototype.name="Molecule",vs.prototype.shortName="Molecule";var ys=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"getAtomColor",value:function(e,t){var r,n,i=this.opts.color,o=(r=i,(n=this.opts.factor)*(r>>16&255)<<16|n*(r>>8&255)<<8|n*(255&r));return e.flags&Re.Flags.CARBON?i:o}},{key:"getResidueColor",value:function(e,t){return this.opts.color}}]),i}(is);Se(ys,"id","CB"),ys.prototype.id="CB",ys.prototype.name="Carbon",ys.prototype.shortName="Carbon";var _s=new Mr([os,ss,as,ls,cs,us,hs,fs,ds,ps,ms,vs,ys]);function gs(e){return new i.Q1f(e,e,e)}var xs=new Mr([{id:"DF",name:"Diffuse",shortName:"Diffuse",uberOptions:{diffuse:gs(1),specular:gs(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"SF",name:"Soft Plastic",shortName:"Soft",uberOptions:{diffuse:gs(1),specular:gs(.1),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"PL",name:"Glossy Plastic",shortName:"Glossy",uberOptions:{diffuse:gs(.56),specular:gs(.28),shininess:100,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"ME",name:"Metal",shortName:"Metal",uberOptions:{diffuse:gs(.56),specular:gs(.55),shininess:30,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!1}},{id:"TR",name:"Transparent",shortName:"Transparent",uberOptions:{diffuse:gs(1),specular:gs(0),shininess:1,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"GL",name:"Glass",shortName:"Glass",uberOptions:{diffuse:gs(.5),specular:gs(.65),shininess:100,opacity:.5},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!0,toonShading:!1}},{id:"BA",name:"Backdrop",shortName:"Backdrop",uberOptions:{diffuse:gs(1),specular:gs(0),shininess:1,opacity:1},values:{lights:!1,fog:!1,depthWrite:!1,transparent:!1,toonShading:!1}},{id:"TN",name:"Toon",shortName:"Toon",uberOptions:{diffuse:gs(1),specular:gs(0),shininess:1,opacity:1},values:{lights:!0,fog:!0,depthWrite:!0,transparent:!1,toonShading:!0}},{id:"FL",name:"Flat",shortName:"Flat",uberOptions:{diffuse:gs(1),specular:gs(0),shininess:0,opacity:1},values:{lights:!1,fog:!0,depthWrite:!0,transparent:!1}}]);function bs(e,t,r){var n=e.material.createInstance();n.setValues(t);var i=new e.constructor(e.geometry,n);return i.material.needsUpdate=!0,i.applyMatrix4(e.matrix),i.layers.set(r),i}function ws(e,t,r){for(var n=function(e,t){var r=[];return e.traverse((function(e){for(var n=0;n<t.length;n++)if(e instanceof t[n]){r[r.length]=e;break}})),r}(e,t),i=0,o=n.length;i<o;++i){var s=n[i];s.parent&&r(s)}}var Ss,Rs=(Ss={prepassTransparancy:!0,fakeOpacity:!1,transparent:!1,colorFromDepth:!1,lights:!1,shadowmap:!1,fog:!1},function(e,t){t instanceof li&&ws(e,[i.eaF,i.DXC],(function(e){e.material.setValues({prepassTransparancy:!1,fakeOpacity:!1}),e.material.needsUpdate=!0,e.layers.set(kr.LAYERS.TRANSPARENT);var t=bs(e,Ss,kr.LAYERS.PREPASS_TRANSPARENT);e.parent.add(t)}))}),Cs=function(){var e={colorFromPos:!0,transparent:!1,colorFromDepth:!1,lights:!1,shadowmap:!1,fog:!1,overrideColor:!1,fogTransparent:!1,attrColor:!1,attrColor2:!1,attrAlphaColor:!1,fakeOpacity:!1};return function(t,r){r instanceof li&&ws(t,[i.eaF,i.DXC],(function(t){var r=bs(t,e,kr.LAYERS.COLOR_FROM_POSITION);t.parent.add(r)}))}}(),ks=function(){var e={colorFromDepth:!0,orthoCam:!0,lights:!1,shadowmap:!1,fog:!1};return function(t,r){r instanceof li&&ws(t,[i.eaF,i.DXC],(function(t){if(!t.receiveShadow&&t.material.shadowmap&&t.material.setValues({shadowmap:!1}),t.material.lights&&t.castShadow&&kr.belongToSelectLayers(t)){var r=bs(t,e,kr.LAYERS.SHADOWMAP);r.isShadowmapMesh=!0,t.parent.add(r)}}))}}();function As(e,t){!function e(r){r instanceof i.eaF&&t(r);for(var n=0,o=r.children.length;n<o;n++)e(r.children[n])}(e)}var Es={applyTransformsToMeshes:function(e,t){var r=t.length;r<1||ws(e,[i.eaF,i.DXC,i.N1A],(function(e){e.applyMatrix4(t[0]);for(var n=1;n<r;++n){var i=new e.constructor(e.geometry,e.material);e.parent.add(i),i.applyMatrix4(t[n])}}))},processTransparentMaterial:Rs,processColFromPosMaterial:Cs,createShadowmapMaterial:ks,removeShadowmapMaterial:function(e,t){t instanceof li&&ws(e,[i.eaF,i.DXC],(function(e){e.isShadowmapMesh&&e.parent.remove(e)}))},forEachMeshInGroup:As,countTriangles:function(e){var t=0;return As(e,(function(e){t+=function(e){var t=e.geometry;if(t instanceof i.CmU){var r=t.attributes;for(var n in r)if(r.hasOwnProperty(n)&&r[n]instanceof i.uWO){var o=r[n];return(t.index?t.index.array.length/3:0)*o.array.length/o.itemSize}return 0}return t instanceof i.LoY?t.index?t.index.array.length/3:0:t.faces?t.faces.length:0}(e)})),t}},Ps=dr.selectors,Ts=function(){function e(t,r,n,i){s(this,e);var o={clipPlane:J.now.draft.clipPlane,fogTransparent:J.now.bg.transparent,shadowmap:J.now.shadow.on,shadowmapType:J.now.shadow.type};this.index=t,this.mode=r,this.colorer=n,this.selector=i,this.selectorString="",this.count=0,this.material=new li,this.material.setValues(o),this.material.setUberOptions({fogAlpha:J.now.fogAlpha}),this.materialPreset=xs.first,this.needsRebuild=!0,this.visible=!0,this.setMode(r)}return l(e,[{key:"markAtoms",value:function(e){return this.count=e.markAtoms(this.selector,1<<this.index),this.needsRebuild=!0,this.count}},{key:"unmarkAtoms",value:function(e){e.clearAtomBits(1<<this.index),this.count=0}},{key:"setMode",value:function(e){this.mode=e}},{key:"setMaterialPreset",value:function(e){this.materialPreset=e,this.material.setUberOptions(e.uberOptions),this.material.setValues(e.values)}},{key:"reset",value:function(){this.geo=null,this.selectionGeo=null}},{key:"buildGeometry",value:function(e){return this.reset(),this.needsRebuild=!1,J.now.ao&&this.material.setValues({normalsToGBuffer:J.now.ao}),this.geo=this.mode.buildGeometry(e,this.colorer,1<<this.index,this.material),this.material.uberOptions.opacity<.99&&"prepass"===J.now.transparency&&Es.processTransparentMaterial(this.geo,this.material),this.geo.visible=this.visible,kr.processObjRenderOrder(this.geo,this.materialPreset.id),Es.processColFromPosMaterial(this.geo,this.material),J.now.shadow.on&&Es.createShadowmapMaterial(this.geo,this.material),this.geo}},{key:"buildSelectionGeometry",value:function(e){var t=null;if(this.geo&&"getSubset"in this.geo){var r=this.geo.getSubset(e);if(r&&r.length>0){(t=new i.YJl).matrixAutoUpdate=!1,t.matrix=this.geo.matrix;for(var n=0;n<r.length;n++){var o=r[n];t.add(o)}}}return t&&(t.visible=this.visible),this.selectionGeo=t,this.selectionGeo}},{key:"compare",value:function(e){var t={},r=String(this.selector);e&&r.valueOf()===String(e.selector).valueOf()||(t.selector=r);var n=this.mode.identify();e&&!Array.isArray(n)&&n===e.mode||(t.mode=n);var i=this.colorer.identify();return e&&!Array.isArray(i)&&i===e.colorer||(t.colorer=i),e&&this.materialPreset.id===e.material||(t.material=this.materialPreset.id),t}},{key:"change",value:function(e,t,r,i){var o={};if(e.selector){var s=Ps.parse(e.selector).selector,a=String(s);this.selectorString!==a&&(o.selector=a,this.selectorString=a,this.selector=s,this.markAtoms(t))}if(e.mode){var l=e.mode;(0,n.isEqual)(this.mode.identify(),l)||(o.mode=l,this.setMode(r))}if(e.colorer){var c=e.colorer;(0,n.isEqual)(this.colorer.identify(),c)||(o.colorer=c,this.colorer=i)}if(e.material){var u=e.material;(0,n.isEqual)(this.materialPreset.id,u)||(o.material=u,this.setMaterialPreset(xs.get(e.material)))}return o}},{key:"show",value:function(e){this.visible=e,this.geo&&(this.geo.visible=e),this.selectionGeo&&(this.selectionGeo.visible=e)}}]),e}();function Ms(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}function Is(e,t,r){var n=e.children;if(n)for(var i=0,o=n.length;i<o;++i){var s=n[i];s._component===t&&r(s),s instanceof kr.RCGroup&&Is(s,t,r)}}function Ns(){}var Os=function(e){h(r,e);var t=Ms(r);function r(e){var n;return s(this,r),(n=t.call(this))._complexVisual=e,n._inProgress=!1,n}return l(r,[{key:"begin",value:function(){var e=this._complexVisual.getComplex();this._componentTransforms=[];for(var t=0;t<e._components.length;++t){var r=e._components[t];this._componentTransforms[r._index]=new i.B69}return this._inProgress=!0,!0}},{key:"apply",value:function(){if(this._inProgress){for(var e=this._complexVisual.getComplex(),t=0;t<e._components.length;++t)this._bakeComponentTransform(e._components[t]);e.onAtomPositionChanged(),this._resetComponentTransform(),this._complexVisual.finalizeEdit()}}},{key:"discard",value:function(){this._inProgress&&(this._resetComponentTransform(),this._complexVisual.finalizeEdit())}},{key:"getAltObj",value:function(){var e={objects:[],pivot:new i.Pq0(0,0,0)},t=this._complexVisual,r=t.getSelectedComponent();if(null===r)return e;var n,o,s,a,l=this._complexVisual.getSelectionGeo(),c=1<<t.getSelectionBit();for(Is(t,r,(function(t){e.objects.push(t)})),n=0;n<l.children.length;++n)for(s=l.children[n],o=0;o<s.children.length;++o)(a=s.children[o]).hasOwnProperty("_component")&&a._component===r&&e.objects.push(a);e.objects.push(this._componentTransforms[r._index]);var u=new i.Pq0(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),h=new i.Pq0(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r.forEachResidue((function(e){var t=e._atoms;for(o=0;o<t.length;++o)t[o].mask&c&&(u.min(t[o].position),h.max(t[o].position))})),e.pivot.lerpVectors(u,h,.5),e}},{key:"_bakeComponentTransform",value:function(e){var t=this._componentTransforms[e._index];!t||0===t.position.x&&0===t.position.y&&0===t.position.z&&0===t.quaternion.x&&0===t.quaternion.y&&0===t.quaternion.z&&1===t.quaternion.w||(t.updateMatrix(),e.forEachResidue((function(e){for(var r=e._atoms,n=0;n<r.length;++n)r[n].position.applyMatrix4(t.matrix)})))}},{key:"_resetComponentTransform",value:function(){var e,t,r,n,i=this._complexVisual,o=this._complexVisual.getSelectionGeo();for(e=0;e<this._componentTransforms.length;++e)(n=this._componentTransforms[e]).position.set(0,0,0),n.quaternion.set(0,0,0,1);for(e=0;e<i.children.length;++e)for(r=i.children[e],t=0;t<r.children.length;++t)(n=r.children[t]).hasOwnProperty("_component")&&(n.position.set(0,0,0),n.quaternion.set(0,0,0,1));for(e=0;e<o.children.length;++e)for(r=o.children[e],t=0;t<r.children.length;++t)(n=r.children[t]).hasOwnProperty("_component")&&(n.position.set(0,0,0),n.quaternion.set(0,0,0,1))}}]),r}(Ns),Ls=function(e){h(r,e);var t=Ms(r);function r(e){var n;return s(this,r),(n=t.call(this))._complexVisual=e,n._inProgress=!1,n}return l(r,[{key:"begin",value:function(){var e=this._complexVisual,t=this._complexVisual.getSelectionGeo(),r=this._getSelectionBorderAtoms();if(r.length<1||r.length>2)return B.error("Can only edit fragments with one or two bound atoms."),!1;this._fragmentBoundAtoms=r;var n=1<<e.getSelectionBit();e.disableSubset(n,!0);for(var o=0;o<t.children.length;++o)t.children[o].visible=!1;var s=r[0].position.clone();2===r.length&&s.lerp(r[1].position,.5),this._fragmentGeo=new i.YJl,e.add(this._fragmentGeo),this._fragmentGeo.position.copy(s),this._fragmentSelectionGeo=new i.YJl,t.add(this._fragmentSelectionGeo),this._fragmentSelectionGeo.position.copy(s);var a=s.clone();a.negate();for(var l=0;l<e.children.length;++l){var c=e.children[l];if("getSubset"in c){var u=new i.YJl;this._fragmentGeo.add(u);var h=new i.YJl;this._fragmentSelectionGeo.add(h);for(var f=c.getSubset(n,!0),d=0;d<f.length;d++){var p=f[d];u.add(p),p.position.copy(a)}for(var m=c.getSubset(n,!0),v=0;v<m.length;v++){var y=m[v];h.add(y),y.position.copy(a)}}}return kr.applySelectionMaterial(this._fragmentSelectionGeo),this._inProgress=!0,!0}},{key:"apply",value:function(){if(this._inProgress){var e=this._complexVisual,t=e.getSelectionBit(),r=this._fragmentGeo.position,n=this._fragmentGeo.matrix.clone();n.multiply((new i.kn4).makeTranslation(-r.x,-r.y,-r.z)),this._bakeAtomTransform(n,1<<t),e.enableSubset(1<<t,!0),e.getComplex().onAtomPositionChanged(),e.finalizeEdit()}}},{key:"discard",value:function(){if(this._inProgress){var e=this._complexVisual,t=this._complexVisual.getSelectionGeo();this._fragmentGeo.parent.remove(this._fragmentGeo),e.enableSubset(1<<e.getSelectionBit(),!0);for(var r=0;r<t.children.length;++r){var n=t.children[r];n.visible?t.remove(n):n.visible=!0}e.finalizeEdit()}}},{key:"isFreeRotationAllowed",value:function(){return this._fragmentBoundAtoms.length<2}},{key:"getAltObj",value:function(){var e={objects:[],pivot:new i.Pq0(0,0,0)};e.objects.push(this._fragmentGeo,this._fragmentSelectionGeo);var t=this._fragmentBoundAtoms;if(1===t.length){if(1===t[0].bonds.length){var r=t[0].bonds[0];e.axis=(new i.Pq0).subVectors(r._right.position,r._left.position),e.axis.normalize(),e.axis.transformDirection(this._complexVisual.matrixWorld)}}else 2===t.length&&(e.axis=(new i.Pq0).subVectors(t[1].position,t[0].position),e.axis.normalize(),e.axis.transformDirection(this._complexVisual.matrixWorld));return e}},{key:"_getSelectionBorderAtoms",value:function(){var e=this._complexVisual.getComplex(),t=1<<this._complexVisual.getSelectionBit(),r={};e.forEachBond((function(e){e._left.mask&t?e._right.mask&t||(r[e._left.index]=1):e._right.mask&t&&(r[e._right.index]=1)}));for(var n=[],i=Object.keys(r),o=0,s=i.length;o<s;++o){var a=i[o];n.push(e._atoms[a])}return n}},{key:"_bakeAtomTransform",value:function(e,t){this._complexVisual.getComplex().forEachAtom((function(r){r.mask&t&&r.position.applyMatrix4(e)}))}}]),r}(Ns),Bs={ComponentEditor:Os,FragmentEditor:Ls};var Ds=dr.selectors;function zs(e,t){Array.isArray(t)||(t=[t]);var r=v(t,2),n=r[0],i=r[1];return new(e.get(n)||e.first)(i)}var Fs=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._complex=t,r._reprList=[],r._repr=null,r._reprListChanged=!0,r._selectionBit=0,r._reprUsedBits=0,r._selectionCount=0,r._selectionGeometry=new i.YJl,r}return l(a,[{key:"getBoundaries",value:function(){return this._complex.getBoundaries()}},{key:"release",value:function(){this._selectionGeometry.parent&&this._selectionGeometry.remove(this._selectionGeometry),Er.prototype.release.call(this)}},{key:"getComplex",value:function(){return this._complex}},{key:"getSelectionCount",value:function(){return this._selectionCount}},{key:"getSelectionGeo",value:function(){return this._selectionGeometry}},{key:"getSelectionBit",value:function(){return this._selectionBit}},{key:"getEditor",value:function(){return this._editor}},{key:"resetReps",value:function(e){this._complex&&this._complex.clearAtomBits(-1),this._reprListChanged=!0,this._reprUsedBits=0,this._reprList.length=e.length;for(var t=0,r=e.length;t<r;++t){var n=e[t],i=void 0,o=void 0;"string"==typeof n.selector?(o=n.selector,i=Ds.parse(o).selector):void 0===n.selector?(o=J.now.presets.default[0].selector,i=Ds.parse(o).selector):o=(i=n.selector).toString();var s=zs(Fo,n.mode),a=zs(_s,n.colorer),l=xs.get(n.material)||xs.first;this._reprList[t]=new Ts(t,s,a,i),this._reprList[t].setMaterialPreset(l),this._reprList[t].selectorString=o,this._complex&&this._complex.markAtoms(i,1<<t),this._reprUsedBits|=1<<t}this._repr=e.length>0?this._reprList[0]:null,this._selectionBit=e.length,this._reprUsedBits|=1<<this._selectionBit,this._selectionCount=0,this._complex&&this._complex.update()}},{key:"repCount",value:function(){return this._reprList.length}},{key:"repCurrent",value:function(e){return e>=0&&e<this._reprList.length?this._repr=this._reprList[e]:e=this._reprList.indexOf(this._repr),e}},{key:"rep",value:function(e,t){if(!t&&(void 0===e||e instanceof Object)&&(t=e,e=this.repCurrent()),e<0||e>this._reprList.length)return B.error("Rep ".concat(e," does not exist!")),null;if(e===this._reprList.length){var r=this.repAdd(t);return B.warn("Rep ".concat(e," does not exist! New representation was created.")),{desc:r.desc,index:e,status:"created"}}var i=this._reprList[e],o={selector:i.selectorString,mode:i.mode.identify(),colorer:i.colorer.identify(),material:i.materialPreset.id};if(t){var s=i.change(t,this._complex,zs(Fo,t.mode),zs(_s,t.colorer));if(!(0,n.isEmpty)(s)){for(var a in i.needsRebuild=!0,s)s.hasOwnProperty(a)&&(o[a]=s[a],B.debug("rep[".concat(e,"].").concat(a," changed to ").concat(s[a])));return s.mode&&i.mode.isSurface&&("ultra"===J.now.resolution||"high"===J.now.resolution)&&(B.report('Surface resolution was changed to "medium" to avoid hang-ups.'),J.set("resolution","medium")),{desc:o,index:e,status:"changed"}}}return{desc:o,index:e,status:""}}},{key:"repGet",value:function(e){return(void 0===e||e instanceof Object)&&(e=this.repCurrent()),e<0||e>=this._reprList.length?null:this._reprList[e]}},{key:"_getFreeReprIdx",value:function(){for(var e=this._reprUsedBits,t=0;t<=a.NUM_REPRESENTATION_BITS;++t,e>>=1)if(!(1&e))return t;return-1}},{key:"repAdd",value:function(e){if(this._reprList.length>=a.NUM_REPRESENTATION_BITS)return null;var t=this._getFreeReprIdx();if(t<0)return null;var r=this.buildSelectorFromMask(1<<this._selectionBit),i=J.now.presets.default[0],o=(0,n.merge)({selector:i.selector,mode:i.mode,colorer:i.colorer,material:i.material},e),s="string"==typeof o.selector?Ds.parse(o.selector).selector:o.selector,l=new Ts(this._selectionBit,zs(Fo,o.mode),zs(_s,o.colorer),s);return l.selectorString=s.toString(),l.setMaterialPreset(xs.get(o.material)),l.markAtoms(this._complex),this._reprList.push(l),this._selectionBit=t,this._reprUsedBits|=1<<this._selectionBit,this._complex.markAtoms(r,1<<this._selectionBit),{desc:o,index:this._reprList.length-1}}},{key:"repRemove",value:function(e){void 0===e&&(e=this.repCurrent());var t=this._reprList.length;if(!(e<0||e>=t||t<=1)){var r=this._reprList[e];r.unmarkAtoms(this._complex),this._reprUsedBits&=~(1<<r.index),this._reprList.splice(e,1),r===this._repr&&(e=e<--t?e:t-1,this._repr=this._reprList[e]),this._reprListChanged=!0}}},{key:"repHide",value:function(e,t){void 0===t&&(t=!0),e<0||e>=this._reprList.length||this._reprList[e].show(!t)}},{key:"select",value:function(e,t){t?this._selectionCount+=this._complex.markAtomsAdditionally(e,1<<this._selectionBit):this._selectionCount=this._complex.markAtoms(e,1<<this._selectionBit),this._complex.updateStructuresMask(),this.rebuildSelectionGeometry()}},{key:"resetSelectionMask",value:function(){0!==this._selectionCount&&(this._selectionCount=0,this._complex&&this._complex.clearAtomBits(1<<this._selectionBit))}},{key:"updateSelectionMask",value:function(e){var t=this,r=e.atom,n=e.residue,i=e.chain,o=e.molecule,s=1<<this._selectionBit,a=~s;if(r)n=r.residue,i=n._chain,o=n._molecule,r.mask&s?(r.mask&=a,n._mask&=a,i._mask&=a,o&&(o.mask&=a),this._selectionCount--):(r.mask|=s,this._selectionCount++,n.collectMask(),i.collectMask(),o&&o.collectMask());else if(n)i=n._chain,o=n._molecule,n._mask&s?(n._mask&=a,i._mask&=a,n.forEachAtom((function(e){e.mask&s&&(e.mask&=a,t._selectionCount--)}))):(n._mask|=s,n.forEachAtom((function(e){e.mask&s||(e.mask|=s,t._selectionCount++)})),i.collectMask(),o&&o.collectMask());else if(i||o){var l=i||o;l._mask&s?(l._mask&=a,l.forEachResidue((function(e){e._mask&s&&(e._mask&=a,e.forEachAtom((function(e){e.mask&s&&(e.mask&=a,t._selectionCount--)})),e._mask&=a)}))):(l._mask|=s,l.forEachResidue((function(e){if(!(e._mask&s)){e._mask|=s,e.forEachAtom((function(e){e.mask&s||(e.mask|=s,t._selectionCount++)}));var r=i?e.getMolecule():e.getChain();r&&r.collectMask()}})))}else this.resetSelectionMask()}},{key:"expandSelection",value:function(){var e=this,t=1<<this._selectionBit,r=1<<31;this._complex.forEachBond((function(e){e._left.mask&t?e._right.mask&t||(e._right.mask|=r):e._right.mask&t&&(e._left.mask|=r)}));var n=~r;this._complex.forEachAtom((function(i){i.mask&r&&(i.mask=i.mask&n|t,++e._selectionCount)})),this._complex.updateStructuresMask()}},{key:"shrinkSelection",value:function(){var e=this,t=1<<this._selectionBit,r=1<<31;this._complex.forEachBond((function(e){e._left.mask&t?e._right.mask&t||(e._left.mask|=r):e._right.mask&t&&(e._right.mask|=r)})),this._complex.forEachAtom((function(e){e.mask&t&&1===e.bonds.length&&(e.mask|=r)}));var n=~(t|r);this._complex.forEachAtom((function(t){t.mask&r&&(t.mask&=n,--e._selectionCount)})),this._complex.updateStructuresMask()}},{key:"getSelectedComponent",value:function(){var e=1<<this._selectionBit,t=null,r=!1;return this._complex.forEachAtom((function(n){n.mask&e&&(null===t?t=n.residue._component:t!==n.residue._component&&(r=!0))})),r?null:t}},{key:"getSelectionCenter",value:function(e,t,r){e.set(0,0,0);var n=0;return this._complex.forEachAtom((function(i){t(i,r)&&(e.add(i.position),n++)})),0!==n&&(e.divideScalar(n),e.applyMatrix4(this.matrix),!0)}},{key:"needsRebuild",value:function(){if(this._reprListChanged)return!0;for(var e=this._reprList,t=0,r=e.length;t<r;++t)if(e[t].needsRebuild)return!0;return!1}},{key:"rebuild",value:function(){var e=this;return kr.clearTree(this),new Promise((function(t){var r=e._complex;if(r){var n=!1;setTimeout((function(){console.time("build");for(var i=e._reprList,o=ns.get(J.now.palette)||ns.first,s=!1,a=0,l=i.length;a<l;++a){var c=i[a];if(c.colorer.palette=o,c.needsRebuild){c.reset();try{c.buildGeometry(r)}catch(e){if(!(e instanceof $.OutOfMemoryError))throw e;c.needsRebuild=!1,c.reset(),B.error("Not enough memory to build geometry for representation ".concat(c.index+1)),n=!0}}s=n||s||kr.groupHasGeometryToRender(c.geo),c.geo&&e.add(c.geo)}e._reprListChanged=!1,console.timeEnd("build"),t()}),10)}else t()}))}},{key:"setNeedsRebuild",value:function(){for(var e=this._reprList,t=0,r=e.length;t<r;++t)e[t].needsRebuild=!0}},{key:"rebuildSelectionGeometry",value:function(){var e=1<<this._selectionBit;kr.clearTree(this._selectionGeometry);for(var t=0,r=this._reprList.length;t<r;++t){var n=this._reprList[t].buildSelectionGeometry(e);if(n){this._selectionGeometry.add(n);for(var i=0;i<n.children.length;i++){var o=n.children[i];if(this._editor&&this._editor._componentTransforms){var s=this._editor._componentTransforms[o._component._index];s&&(o.position.copy(s.position),o.quaternion.copy(s.quaternion))}}kr.applySelectionMaterial(n)}}}},{key:"_buildSelectorFromSortedLists",value:function(e,t,r){var n=this._complex;function i(e){for(var t=[],r=0,n=NaN,i=NaN,o=0,s=e.length;o<s;++o){var a=e[o];a===i+1?i=a:(Number.isNaN(n)||(t[r++]=new Ds.Range(n,i)),n=i=a)}return Number.isNaN(n)||(t[r]=new Ds.Range(n,i)),t}var o=null;if(r.length===n._chains.length)o=Ds.all();else{var s;if(r.length>0&&(s=Ds.chain(r),o=o?Ds.or(o,s):s),Object.keys(t).length>0)for(var a in t)t.hasOwnProperty(a)&&(s=Ds.and(Ds.chain(a),Ds.residx(i(t[a]))),o=o?Ds.or(o,s):s);e.length>0&&(s=Ds.serial(i(e)),o=o?Ds.or(o,s):s),o||(o=Ds.none())}return o}},{key:"buildSelectorFromMask",value:function(e){var t=this._complex,r=[],n={},i=[];return t.forEachChain((function(t){t._mask&e&&r.push(t._name)})),t.forEachResidue((function(t){if(t._mask&e&&!(t._chain._mask&e)){var r=t._chain._name;r in n?n[r].push(t._index):n[r]=[t._index]}})),t.forEachAtom((function(t){t.mask&e&&!(t.residue._mask&e)&&i.push(t.serial)})),this._buildSelectorFromSortedLists(i,n,r)}},{key:"forSelectedResidues",value:function(e){var t=1<<this._selectionBit;this._complex.forEachResidue((function(r){r._mask&t&&e(r)}))}},{key:"beginComponentEdit",value:function(){if(this._editor)return null;var e=new Bs.ComponentEditor(this);return e.begin()?(this._editor=e,e):null}},{key:"beginFragmentEdit",value:function(){if(this._editor)return null;var e=new Bs.FragmentEditor(this);return e.begin()?(this._editor=e,e):null}},{key:"finalizeEdit",value:function(){this._editor=null}},{key:"setMaterialValues",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=0,o=this._reprList.length;n<o;++n){var s=this._reprList[n];s.material.setValues(e),t&&s.geo.traverse((function(t){t instanceof i.eaF&&(t.material.setValues(e),void 0!==r&&r(t),t.material.needsUpdate=!0)}))}}},{key:"setUberOptions",value:function(e){for(var t=0,r=this._reprList.length;t<r;++t)this._reprList[t].material.setUberOptions(e)}},{key:"within",value:function(e,t){var r=this._complex.getVoxelWorld();if(null===r)return!1;var n=1<<this._selectionBit;return this._complex.markAtoms(e,n),r&&r.forEachAtomWithinDistFromMasked(this._complex,n,Number(t),(function(e){e.mask|=n})),this._selectionCount=this._complex.countAtomsByMask(n),this._complex.updateStructuresMask(),this.buildSelectorFromMask(n)}}]),a}(Er);function Vs(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}Fs.NUM_REPRESENTATION_BITS=30;var Us=i.LlO.merge([{volumeDim:{type:"v3",value:new i.Pq0(512,512,512)},tileTex:{type:"t",value:null},tileTexSize:{type:"v2",value:new i.I9Y(512,512)},tileStride:{type:"v2",value:new i.I9Y(512,512)},boxAngles:{type:"v3",value:new i.Pq0(1,1,1)},delta:{type:"v3",value:new i.Pq0(0,0,0)},_isoLevel0:{type:"v2",value:new i.Pq0(.5,.75,1)},_flipV:{type:"f",value:0},_BFLeft:{type:"t",value:null},_BFRight:{type:"t",value:null},_FFLeft:{type:"t",value:null},_FFRight:{type:"t",value:null},_WFFLeft:{type:"t",value:null},_WFFRight:{type:"t",value:null}}]);function js(e,t){var r=i.LlO.clone(t);for(var n in e)r.hasOwnProperty(n)&&(r[n].value=e[n]);return r}function Gs(e,t){return{uniforms:js(e,{}),vertexShader:"varying vec3 pos;\r\n\r\nvoid main() {\r\n // we're assuming local position is in [-0.5, 0.5]\r\n // we need to offset it to be represented in RGB\r\n pos = position.xyz + 0.5;\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n}",fragmentShader:"varying vec3 pos;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(pos, 0.5);\r\n}",transparent:!1,depthTest:!1,depthWrite:!1,side:t}}var Hs=function(e){h(r,e);var t=Vs(r);function r(e){s(this,r);var n=Gs(e,i.hsX);return t.call(this,n)}return l(r)}(i.BKk),qs=l((function e(t,r,n,o){s(this,e),this.uniforms=js(t,r),this.vertexShader=n,this.fragmentShader=o,this.transparent=!1,this.depthTest=!1,this.depthWrite=!1,this.side=i.hB5})),Ws={BackFacePosMaterial:Hs,BackFacePosMaterialFarPlane:function(e){h(r,e);var t=Vs(r);function r(e){s(this,r);var n=i.LlO.merge([{aspectRatio:{type:"f",value:0},farZ:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},matWorld2Volume:{type:"4fv",value:new i.kn4}}]),o=new qs(e,n,"varying vec4 volPos;\r\nuniform float aspectRatio;\r\nuniform float farZ;\r\nuniform float tanHalfFOV;\r\nuniform mat4 matWorld2Volume;\r\n\r\nvoid main() {\r\n // rescale plane to fill in the whole far plane area seen from camera\r\n vec3 pos = position.xyz;\r\n pos.x = pos.x * tanHalfFOV * farZ * aspectRatio;\r\n pos.y = pos.y * tanHalfFOV * farZ;\r\n // common transformation\r\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\r\n // calc pos in volume CS\r\n volPos = matWorld2Volume * modelMatrix * vec4(pos, 1.0);\r\n // we're assuming local position is in [-0.5, 0.5]\r\n // we need to offset it to be represented in RGB\r\n volPos = volPos + 0.5;\r\n volPos.w = 0.5;\r\n}\r\n","varying vec4 volPos;\r\n\r\nvoid main() {\r\n gl_FragColor = volPos;\r\n}");return t.call(this,o)}return l(r)}(i.BKk),FrontFacePosMaterial:function(e){h(r,e);var t=Vs(r);function r(e){s(this,r);var n=Gs(e,i.hB5);return t.call(this,n)}return l(r)}(i.BKk),VolumeMaterial:function(e){h(r,e);var t=Vs(r);function r(e){var n;s(this,r);var i=new qs(e,Us,"varying vec4 screenSpacePos;\r\n\r\nvoid main() {\r\n screenSpacePos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n gl_Position = screenSpacePos;\r\n}","uniform mat4 projectionMatrix;\r\n\r\n// 3D volume texture\r\nuniform vec3 volumeDim; // volume dimensions, pixels\r\nuniform sampler2D tileTex; // tiled texture containing all Z-slices of a 3D data\r\nuniform vec2 tileTexSize; // size of tiled texture, pixels\r\nuniform vec2 tileStride; // UV stride between slices in tile tex, pixels\r\n\r\nuniform vec3 boxAngles;//value of angles({x: alpha, y:beta, z:gamma}) types 1 - if angle is obtuse, 0 - if acute\r\nuniform vec3 delta; //Projection box delta's from non-orthogonal origin axes; {x: XY, y : XZ, z: YZ}\r\n\r\nuniform vec3 _isoLevel0;\r\nuniform float _flipV;\r\nuniform sampler2D _BFLeft;\r\nuniform sampler2D _BFRight;\r\nuniform sampler2D _FFLeft;\r\nuniform sampler2D _FFRight;\r\nuniform sampler2D _WFFLeft;\r\nuniform sampler2D _WFFRight;\r\n\r\nvarying vec4 screenSpacePos;\r\n\r\n#define NO_COLOR vec4(0., 0., 0., 0.)\r\n\r\nvec4 sample3DTexture(vec3 texCoord) {\r\n // a pair of Z slices is determined by nearest slice border\r\n float zSliceBorder = floor(texCoord.z * volumeDim.z + 0.5);\r\n float zSliceNumber1 = max(zSliceBorder - 1.0, 0.0);\r\n float zSliceNumber2 = min(zSliceBorder, volumeDim.z - 1.0);\r\n\r\n float rowTiles = floor(tileTexSize.x / tileStride.x);\r\n\r\n // calculate coords in tile texture for both slices\r\n vec2 tileOffset = vec2(mod(zSliceNumber1, rowTiles), floor(zSliceNumber1 / rowTiles));\r\n vec2 texCoordSlice1 = (texCoord.xy * volumeDim.xy + tileOffset * tileStride) / tileTexSize.xy;\r\n tileOffset = vec2(mod(zSliceNumber2, rowTiles), floor(zSliceNumber2 / rowTiles));\r\n vec2 texCoordSlice2 = (texCoord.xy * volumeDim.xy + tileOffset * tileStride) / tileTexSize.xy;\r\n\r\n // bilinear filtering\r\n vec4 colorSlice1 = texture2D(tileTex, texCoordSlice1);\r\n vec4 colorSlice2 = texture2D(tileTex, texCoordSlice2);\r\n float weightSlice2 = texCoord.z * volumeDim.z - (zSliceNumber1 + 0.5);\r\n return mix(colorSlice1, colorSlice2, weightSlice2);\r\n}\r\n\r\nvec4 sample3DTextureInclined(vec3 boxCoord) { // delta:{ x: XY, y : XZ, z: YZ }\r\n vec3 textCoord = boxCoord;\r\n vec2 currDelta = mix(boxCoord.zz, vec2(1., 1.) - boxCoord.zz, boxAngles.yx) * delta.yz;\r\n\r\n textCoord.y = (boxCoord.y - currDelta.y) / (1. - delta.z);\r\n if (textCoord.y < 0.0 || textCoord.y > 1.0)\r\n return NO_COLOR;\r\n\r\n currDelta.x += mix(textCoord.y, 1.0 - textCoord.y, boxAngles.z) * delta.x;\r\n\r\n textCoord.x = (boxCoord.x - currDelta.x) / (1. - delta.x - delta.y);\r\n if (textCoord.x < 0.0 || textCoord.x > 1.0)\r\n return NO_COLOR;\r\n\r\n return sample3DTexture(textCoord);\r\n}\r\n\r\nfloat CalcColor(vec3 iter, vec3 dir) {\r\n float d = 1. / 128.;\r\n vec3 dx = vec3(d, 0.0, 0.0);\r\n vec3 dy = vec3(0.0, d, 0.0);\r\n vec3 dz = vec3(0.0, 0.0, d);\r\n\r\n // #Opt: coordInc.x:(iter + dx).x > 1. ? 0.: sample3DTextureInclined(iter + dx).x,\r\n vec3 coordInc = mix(\r\n vec3(\r\n sample3DTextureInclined(iter + dx).x,\r\n sample3DTextureInclined(iter + dy).x,\r\n sample3DTextureInclined(iter + dz).x\r\n ),\r\n vec3(0. ,0. , 0.),\r\n vec3(floor((iter + dx).x), floor((iter + dy).y), floor((iter + dz).z))\r\n );\r\n\r\n // #Opt: coordDec.x:(iter - dx).x < 0. ? 0.: sample3DTextureInclined(iter - dx).x,\r\n vec3 coordDec = mix(\r\n vec3(0. ,0. , 0.),\r\n vec3(\r\n sample3DTextureInclined(iter - dx).x,\r\n sample3DTextureInclined(iter - dy).x,\r\n sample3DTextureInclined(iter - dz).x\r\n ),\r\n vec3(ceil((iter - dx).x), ceil((iter - dy).y), ceil((iter - dz).z))\r\n );\r\n\r\n vec3 N = normalize(coordInc - coordDec);\r\n float dif = max(0.0, dot(N, dir));\r\n return dif;\r\n}\r\n\r\nvec3 AccuracyIso(vec3 left, vec3 right, float volLeft, float threshold) {\r\n for (int i = 0; i < 5; i++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if ((volLeft - threshold) * (vol - threshold) < 0.)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec3 CorrectIso(vec3 left, vec3 right, float tr) {\r\n for (int j = 0; j < 5; j++) {\r\n vec3 iterator = 0.5 * (left + right);\r\n float vol = sample3DTextureInclined(iterator).r;\r\n if (vol < tr)\r\n right = iterator;\r\n else\r\n left = iterator;\r\n }\r\n return 0.5 * (left + right);\r\n}\r\n\r\nvec4 GetIso1(vec3 start, vec3 back, float molDist, vec3 dir, float tr, int count) {\r\n float vol, stepSize = (float(count) + 2.) / float(STEPS_COUNT);\r\n vec3 step = stepSize * dir, iterator = start, left, right;\r\n vec4 acc = NO_COLOR;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n vol = sample3DTextureInclined(iterator).r;\r\n if (length(iterator - back) <= stepSize || (vol > tr))\r\n break;\r\n }\r\n\r\n if (vol > tr)\r\n acc = vec4(CorrectIso(iterator, iterator - step, tr).xyz, 1.);\r\n\r\n return acc;\r\n}\r\n\r\nfloat easeOut(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return 1.0 - (1.0 - t) * (1.0 - t);\r\n}\r\n\r\nfloat easeIn(float x0, float x1, float x) {\r\n float t = clamp((x - x0) / (x1 - x0), 0.0, 1.0);\r\n return t * t;\r\n}\r\n\r\nvec3 GetColSimple(float vol) {\r\n float t = easeOut(_isoLevel0.x, _isoLevel0.y, vol);\r\n float s = easeIn(_isoLevel0.y, _isoLevel0.z, vol);\r\n return vec3(0.5, 0.6, 0.7) * (1.0 - t) + 2.0 * vec3(s, 0, 0);\r\n}\r\n\r\nvec4 VolRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 acc = NO_COLOR, iso;\r\n vec3 iterator = start, sumColor = vec3(0., 0., 0.);\r\n float stepSize, alpha, sumAlpha = 0.0, vol, curStepSize, molD;\r\n vec3 step, col, colOld, right;\r\n float tr0 = _isoLevel0.x;\r\n float dif, r, kd, finish;\r\n int count = 0, stopMol = 0;\r\n\r\n for (int k = 0; k < 3; k++) {\r\n stepSize = (float(k) + 2.) / float(STEPS_COUNT);\r\n kd = 140. * tr0 * stepSize;\r\n r = 1. - kd;\r\n step = stepSize * dir;\r\n iso = GetIso1(iterator, back, molDist, dir, tr0, k);\r\n if (iso.a < 0.1 || length(iso.xyz - start) > molDist)\r\n break;\r\n iterator = iso.xyz;\r\n dif = 1.;// CalcColor(iterator, dir);\r\n colOld = GetColSimple(tr0);\r\n curStepSize = stepSize;\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n iterator = iterator + step;\r\n molD = length(iterator - start);\r\n vol = sample3DTextureInclined(iterator).r;\r\n finish = distance(iterator, back) - stepSize;\r\n if (finish < 0.0 || vol < tr0 || (sumAlpha > 0.97) || molD > molDist)\r\n break;\r\n alpha = (1. - r);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4.* colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n colOld = col;\r\n } // for i\r\n\r\n if (finish < 0.0 || sumAlpha > 0.97)\r\n break;\r\n\r\n if (molD > molDist) {\r\n curStepSize = stepSize - (molD - molDist);\r\n right = iterator - (molD - molDist) * dir;\r\n vol = sample3DTextureInclined(right).r;\r\n } else {\r\n vec3 left = iterator - step;\r\n right = CorrectIso(left, iterator, tr0);\r\n curStepSize = distance(left, right);\r\n vol = tr0;\r\n }\r\n\r\n alpha = (1. - r) * curStepSize / stepSize;\r\n dif = 1.;// CalcColor(right, dir);\r\n col = GetColSimple(vol);\r\n vol = sample3DTextureInclined(iterator - 0.5 * curStepSize / stepSize * step).r;\r\n vec3 colMid = GetColSimple(vol);\r\n sumColor += (1. - sumAlpha) * (colOld + 4. * colMid + col) * alpha / 6.;\r\n sumAlpha += (1. - sumAlpha) * alpha;// *(1. - 1.0*dif*dif);\r\n\r\n if (molD > molDist)\r\n break;\r\n } // for k\r\n acc.rgb = 1. * sumColor / sumAlpha;\r\n acc.a = sumAlpha;\r\n return acc;\r\n}\r\n\r\nvec4 VolRender1(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n float stepSize = 1.0 / float(STEPS_COUNT);\r\n float len = length(back - start);\r\n vec3 step = stepSize * dir;\r\n vec3 iterator = start;\r\n float acc = 0.0;\r\n\r\n for (int i = 0; i < STEPS_COUNT; i++) {\r\n if (float(i) * stepSize > len)\r\n break;\r\n iterator = iterator + step;\r\n if (sample3DTextureInclined(iterator).r > _isoLevel0.x)\r\n acc += 10. * sample3DTextureInclined(iterator).r / float(STEPS_COUNT);\r\n }\r\n\r\n return vec4(1.,1.,1., acc);\r\n}\r\n\r\nvec4 IsoRender(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n vec4 tst = GetIso1(start, back, 2., dir, _isoLevel0.x, 0);\r\n vec4 col = NO_COLOR;\r\n\r\n if (length(tst.xyz - start) < molDist && tst.a > 0.1) {\r\n float dif = CalcColor(tst.xyz, dir);\r\n dif = 0.9 * dif * dif;\r\n col = vec4(dif, dif, dif, 1);\r\n }\r\n return col;\r\n}\r\n\r\nvec4 VolRender2(vec3 start, vec3 back, float molDist, vec3 dir) {\r\n return sample3DTexture(start);\r\n}\r\n\r\nvoid main() {\r\n vec3 tc = screenSpacePos.xyz / screenSpacePos.w * 0.5 + 0.5;\r\n\r\n if (_flipV > 0.0) {\r\n tc.y = 1.0 - tc.y;\r\n }\r\n\r\n vec3 start;\r\n vec3 back;\r\n vec3 molBack;\r\n if (projectionMatrix[0][2] < 0.0) {\r\n start = texture2D(_FFLeft, tc.xy).xyz;\r\n back = texture2D(_BFLeft, tc.xy).xyz;\r\n molBack = texture2D(_WFFLeft, tc.xy).xyz;\r\n } else {\r\n start = texture2D(_FFRight, tc.xy).xyz;\r\n back = texture2D(_BFRight, tc.xy).xyz;\r\n molBack = texture2D(_WFFRight, tc.xy).xyz;\r\n }\r\n\r\n vec3 dir = normalize(back - start);\r\n\r\n float molDist = 2.0;\r\n if (length(molBack) > 0.001) {\r\n molDist = distance(start, molBack);\r\n }\r\n\r\n #ifdef ISO_MODE\r\n gl_FragColor = IsoRender(start, back, molDist, dir);\r\n #else\r\n gl_FragColor = VolRender(start, back, molDist, dir);\r\n #endif\r\n}\r\n");return i.transparent=!0,i.depthTest=!0,(n=t.call(this,i)).updateDefines(),n}return l(r,[{key:"updateDefines",value:function(){this.defines={ISO_MODE:J.now.modes.VD.isoMode,STEPS_COUNT:100*J.now.modes.VD.polyComplexity[J.now.resolution]},this.needsUpdate=!0}}]),r}(i.BKk)};var Ys=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;s(this,o);var t=new i.LoY;Se(c(e=n.call(this,t)),"volumeInfo",{}),e.clipPlane=new i.Zcv;var r=new i.Pq0(.5,.5,.5);return e.size=r,e.cullFlag=[!0,!0,!0,!0,!0,!0,!0,!0,!1,!1,!1,!1,!1,!1],e.faces=[{indices:[],norm:new i.Pq0(0,0,-1)},{indices:[],norm:new i.Pq0(0,0,1)},{indices:[],norm:new i.Pq0(0,-1,0)},{indices:[],norm:new i.Pq0(0,1,0)},{indices:[],norm:new i.Pq0(-1,0,0)},{indices:[],norm:new i.Pq0(1,0,0)},{indices:[],norm:new i.Pq0(0,0,0)}],e.vertices=[new i.Pq0(-r.x,-r.y,-r.z),new i.Pq0(-r.x,r.y,-r.z),new i.Pq0(r.x,-r.y,-r.z),new i.Pq0(r.x,r.y,-r.z),new i.Pq0(-r.x,-r.y,r.z),new i.Pq0(-r.x,r.y,r.z),new i.Pq0(r.x,-r.y,r.z),new i.Pq0(r.x,r.y,r.z),new i.Pq0(0,0,0),new i.Pq0(0,0,0),new i.Pq0(0,0,0),new i.Pq0(0,0,0),new i.Pq0(0,0,0),new i.Pq0(0,0,0)],t.setAttribute("position",new i.THS(new Float32Array(3*e.vertices.length),3)),e.name="VolumeMesh",e}return l(o,[{key:"_updateVertices",value:function(){var e,t=o._corners,r=o._edges,n=o._edgeIntersections,s=this.clipPlane.normal,a=this.clipPlane.constant,l=this.vertices,c=this.size,u=[0,0,0,0,0,0,0,0],h=[1,1,1,1,1,1,1,1,1,1,1,1],f=new i.Pq0,d=null;function p(){if(0===s.x)return 0;var e=-(s.dot(f)+a)/s.x;return-c.x<=e&&e<=c.x?(d.set(e,f.y,f.z),e===c.x?2:e===-c.x?-2:1):0}function m(){if(0===s.y)return 0;var e=-(s.dot(f)+a)/s.y;return-c.y<=e&&e<=c.y?(d.set(f.x,e,f.z),e===c.y?2:e===-c.y?-2:1):0}function v(){if(0===s.z)return 0;var e=-(s.dot(f)+a)/s.z;return-c.z<=e&&e<=c.z?(d.set(f.x,f.y,e),e===c.z?2:e===-c.z?-2:1):0}for(var y=0;y<12;++y){var _=r[y];d=n[y],f.set(_[2],_[3],_[4]),f.multiply(c);var g=0;0===_[2]&&(g=p()),0===_[3]&&(g=m()),0===_[4]&&(g=v()),-2===g?u[_[0]]=1:2===g?u[_[1]]=1:0===g&&(h[y]=0)}var x={indices:[],norm:s.clone().negate()},b=8;for(e=0;e<8;++e)1===u[e]&&(l[b].set(t[e][0],t[e][1],t[e][2]).multiply(c),x.indices.push(b++),h[t[e][3]]=0,h[t[e][4]]=0,h[t[e][5]]=0);for(e=0;e<12;++e)1===h[e]&&(l[b].copy(n[e]),x.indices.push(b++));this.faces[6]=x;var w=new i.Pq0,S=new i.Pq0;for(this.clipPlane.coplanarPoint(S),e=0;e<l.length;++e)this.cullFlag[e]=!1,e<8?(w.subVectors(l[e],S),this.cullFlag[e]=s.dot(w)>=0):e<8+x.indices.length&&(this.cullFlag[e]=!0);var R=this.geometry.getAttribute("position"),C=0;for(e=0;e<l.length;++e)R.array[C++]=l[e].x,R.array[C++]=l[e].y,R.array[C++]=l[e].z;R.needsUpdate=!0}},{key:"_collectVertices",value:function(e,t){var r,n=this.vertices;for(e.indices=[],r=0;r<n.length;++r)this.cullFlag[r]&&t(n[r])&&e.indices.push(r)}},{key:"_sortIndices",value:function(e,t){var r,n,o=this.vertices,s=[],a=new i.Pq0;for(r=1;r<e.indices.length;++r)a.subVectors(o[e.indices[r]],o[e.indices[0]]),a.normalize(),a.cross(t),a.negate(),s[r]=e.norm.dot(a);for(r=1;r<e.indices.length-1;++r)for(n=r+1;n<e.indices.length;++n)if(s[n]<s[r]){var l=s[r];s[r]=s[n],s[n]=l,l=e.indices[r],e.indices[r]=e.indices[n],e.indices[n]=l}}},{key:"_updateIndices",value:function(){var e,t,r,n=this.vertices,o=this.size;this._collectVertices(this.faces[0],(function(e){return e.z===-o.z})),this._collectVertices(this.faces[1],(function(e){return e.z===o.z})),this._collectVertices(this.faces[2],(function(e){return e.y===-o.y})),this._collectVertices(this.faces[3],(function(e){return e.y===o.y})),this._collectVertices(this.faces[4],(function(e){return e.x===-o.x})),this._collectVertices(this.faces[5],(function(e){return e.x===o.x}));var s=new i.Pq0,a=new i.Pq0,l=new i.Pq0;for(t=0;t<this.faces.length;++t)if(0!==(r=this.faces[t]).indices.length){for(s.set(0,0,0),e=0;e<r.indices.length;++e)s.add(n[r.indices[e]]);s.multiplyScalar(1/r.indices.length),a.subVectors(n[r.indices[0]],s),a.normalize();var c=[];for(e=0;e<r.indices.length;++e)l.subVectors(n[r.indices[e]],s),c[e]=l.dot(a);for(e=1;e<r.indices.length;++e)if(c[e]<c[0]){var u=c[0];c[0]=c[e],c[e]=u,u=v(r.indices,1)[0],r.indices[0]=r.indices[e],r.indices[e]=u}this._sortIndices(r,a)}var h=0;for(t=0;t<this.faces.length;++t)(r=this.faces[t]).indices.length>=3&&(h+=3*(r.indices.length-2));var f=0,d=new Uint16Array(h);for(t=0;t<this.faces.length;++t)for(r=this.faces[t],e=0;e<r.indices.length-2;++e)d[f]=r.indices[0],d[f+1]=r.indices[e+1],d[f+2]=r.indices[e+2],f+=3;this.geometry.setIndex(new i.THS(d,1))}},{key:"setDataSource",value:function(e){var t=new Ws.VolumeMaterial,r=e.getDimensions(),n=e.getTiledTextureStride(),i=e.buildTiledTexture(),o=e.getBox();t.uniforms.volumeDim.value.set(r[0],r[1],r[2]),t.uniforms.tileTex.value=i,t.uniforms.tileTexSize.value.set(i.image.width,i.image.height),t.uniforms.tileStride.value.set(n[0],n[1]),Object.assign(this.volumeInfo,e.getVolumeInfo());var s=this.volumeInfo;t.uniforms.delta.value.copy(s.delta),t.uniforms.boxAngles.value.set(s.obtuseAngle[0],s.obtuseAngle[1],s.obtuseAngle[2]),this.material=t,o.getSize(this.scale),o.getCenter(this.position)}},{key:"_updateIsoLevel",value:function(){var e=J.now.modes.VD,t=e.kSigma,r=e.kSigmaMed,n=e.kSigmaMax,i=this.volumeInfo,o=i.dmean-i.dmin,s=i.dmax-i.dmin,a=function(e){return(o+e*i.sd)/s};this.material.uniforms._isoLevel0.value.set(a(t),a(r),a(n))}},{key:"rebuild",value:function(e){var t=o._nearClipPlaneOffset,r=o._pos,n=o._norm,i=o._norm4D,s=o._matrixWorldToLocal,a=o._clipPlane;this._updateIsoLevel(),e.getWorldDirection(n),e.getWorldPosition(r),r.addScaledVector(n,e.near+t),s.copy(this.matrixWorld).invert(),r.applyMatrix4(s),i.set(n.x,n.y,n.z,0),i.applyMatrix4(s),n.copy(i),n.normalize(),a.setFromNormalAndCoplanarPoint(n,r),this.clipPlane.equals(a)||(this.clipPlane=a.clone(),this._updateVertices(),this._updateIndices())}}]),o}(i.eaF);Se(Ys,"_corners",[[-1,-1,-1,0,4,8],[1,-1,-1,0,5,9],[1,1,-1,1,5,10],[-1,1,-1,1,4,11],[-1,-1,1,2,6,8],[1,-1,1,2,7,9],[1,1,1,3,7,10],[-1,1,1,3,6,11]]),Se(Ys,"_edges",[[0,1,0,-1,-1],[2,3,0,1,-1],[4,5,0,-1,1],[6,7,0,1,1],[0,3,-1,0,-1],[1,2,1,0,-1],[4,7,-1,0,1],[5,6,1,0,1],[0,4,-1,-1,0],[1,5,1,-1,0],[2,6,-1,1,0],[3,7,1,1,0]]),Se(Ys,"_edgeIntersections",function(){for(var e=[],t=0;t<12;++t)e.push(new i.Pq0);return e}()),Se(Ys,"_nearClipPlaneOffset",.2),Se(Ys,"_pos",new i.Pq0),Se(Ys,"_norm",new i.Pq0),Se(Ys,"_norm4D",new i.IUQ),Se(Ys,"_matrixWorldToLocal",new i.kn4),Se(Ys,"_clipPlane",new i.Zcv);var Xs=function(){function e(t,r){s(this,e);var n=r.delta,o=r.obtuseAngle,a=new i.Pq0;t.getSize(a),a.multiplyScalar(.5);for(var l=this._getBaseVertices(n,o),c=new i.LoY,u=[],h=0;h<4;h++)u.push(l[h].clone().multiply(a)),u.push(l[(h+1)%4].clone().multiply(a));for(var f=new i.Pq0(2*a.x*(1-n.x-n.y),0,0),d=0;d<8;d++)u.push(u[d].clone().add(f));for(var p=0;p<4;p++)u.push(u[2*p].clone()),u.push(u[2*p+8].clone());var m=new i.Pq0;t.getCenter(m),u.forEach((function(e){return e.add(m)}));var v=function(e){for(var t=e.length,r=new Float32Array(3*t),n=0;n<t;++n){var i=3*n,o=e[n];r[i]=o.x,r[i+1]=o.y,r[i+2]=o.z}return r}(u);c.setAttribute("position",new i.THS(v,3)),this._lines=new i.DXC(c,new i.mrM({color:16777215})),this._lines.layers.set(kr.LAYERS.VOLUME)}return l(e,[{key:"_getBaseVertices",value:function(t,r){var n=e._projectionTable,o=function(e,i){var o=t[n[e][0]];return(-.5*(i-1)+i*r[n[e][1]])*o};return[new i.Pq0(2*(o("XZ",1)+o("XY",1))-1,2*o("YZ",1)-1,-1),new i.Pq0(2*(o("XZ",-1)+o("XY",1))-1,2*o("YZ",-1)-1,1),new i.Pq0(2*(o("XZ",-1)+o("XY",-1))-1,1-2*o("YZ",1),1),new i.Pq0(2*(o("XZ",1)+o("XY",-1))-1,1-2*o("YZ",-1),-1)]}},{key:"getMesh",value:function(){return this._lines}}]),e}();Se(Xs,"_projectionTable",{XY:["x",2],XZ:["y",1],YZ:["z",0]});var $s=function(){function e(t,r,n){s(this,e);var o=this._initPlaneGeo(r,n),a=new Ws.BackFacePosMaterialFarPlane;this._plane=new xi.Mesh(o,a),this._plane.frustumCulled=!1,this._plane.doubleSided=!0;var l=new i.kn4;this._plane._onBeforeRender=function(e,r,n,o,s,a){var c=this.material;if(t&&c){var u=new i.IUQ(0,0,-(n.far-.1),1);u.applyMatrix4(n.matrixWorld),this.matrix.identity(),this.matrix.makeTranslation(u.x,u.y,u.z),this.matrixWorld.copy(this.matrix),this.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,this.matrixWorld),this.normalMatrix.getNormalMatrix(this.modelViewMatrix);var h=t.matrixWorld;l.copy(h).invert(),c.uniforms.aspectRatio.value=n.aspect,c.uniforms.farZ.value=n.far,c.uniforms.tanHalfFOV.value=Math.tan(.5*i.cj9.DEG2RAD*n.fov),c.uniforms.matWorld2Volume.value=l}},this._plane.layers.set(kr.LAYERS.VOLUME_BFPLANE)}return l(e,[{key:"_initPlaneGeo",value:function(e,t){var r=new i.LoY;e=e||1,t=t||1;var n=new Float32Array([-.5*e,.5*t,0,.5*e,.5*t,0,-.5*e,-.5*t,0,.5*e,-.5*t,0]);return r.setAttribute("position",new i.THS(n,3)),r.setIndex([0,2,1,2,3,1]),r}},{key:"getMesh",value:function(){return this._plane}}]),e}();var Zs=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return s(this,o),(r=n.call(this,e,t))._mesh=new Ys,r._mesh.setDataSource(t),r.add(r._mesh),r._frame=new Xs(r.getBoundaries().boundingBox,r._mesh.volumeInfo),r.add(r._frame.getMesh()),r.showFrame(J.now.modes.VD.frame),r._farPlane=new $s(r._mesh,2,2),r.add(r._farPlane.getMesh()),r}return l(o,[{key:"getBoundaries",value:function(){var e=this._dataSource.getBox(),t=new i.iyt;return e.getBoundingSphere(t),{boundingBox:e,boundingSphere:t}}},{key:"getMesh",value:function(){return this._mesh}},{key:"showFrame",value:function(e){this._frame.getMesh().material.visible=e}}]),o}(Er);var Qs=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(this,i),n.call(this,e,["types"])}return l(i,[{key:"find",value:function(e){var t=[];if(e.type)t=this._dict.types[e.type.toLowerCase()]||[];else if(e.source)return this._list.filter((function(t){return t.canProbablyLoad&&t.canProbablyLoad(e.source)}));return Pr(t)}}]),i}(Mr);var Ks=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this))._source=e,r._options=t||{},r._abort=!1,r._agent=null,r}return l(i,[{key:"load",value:function(){return Promise.reject(new Error("Loading from this source is not implemented"))}},{key:"abort",value:function(){this._abort=!0,this._agent&&this._agent.abort()}}],[{key:"extractName",value:function(e){}}]),i}(I);Ir(Ks.prototype);var Js=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),t=(r=n.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new FileReader;i.addEventListener("load",(function(){t(i.result)})),i.addEventListener("error",(function(){r(i.error)})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),e._binary?i.readAsArrayBuffer(n):i.readAsText(n)}))}}],[{key:"canProbablyLoad",value:function(e){return File&&e instanceof File||Blob&&e instanceof Blob}},{key:"extractName",value:function(e){return e&&e.name}}]),i}(Ks);Js.types=["file","blob"];var ea=/^(https?|ftp):\/\//i,ta=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return s(this,o),t=(r=i.call(this,e,t))._options,r._binary=!0===t.binary,r}return l(o,[{key:"load",value:function(){var e=this;return new Promise((function(t,r){if(e._abort)throw new Error("Loading aborted");var n=e._source,i=e._agent=new XMLHttpRequest;i.addEventListener("load",(function(){200===i.status?t(i.response):r(new Error("HTTP ".concat(i.status," while fetching ").concat(n)))})),i.addEventListener("error",(function(){r(new Error("HTTP request failed"))})),i.addEventListener("abort",(function(){r(new Error("Loading aborted"))})),i.addEventListener("progress",(function(t){e.dispatchEvent(t)})),i.open("GET",n),e._binary?i.responseType="arraybuffer":i.responseType="text",i.send()}))}}],[{key:"canProbablyLoad",value:function(e){return(0,n.isString)(e)&&ea.test(e)}},{key:"extractName",value:function(e){if(e){var t=(e.indexOf("?")+1||e.lastIndexOf("#")+1||e.length+1)-1;return e.slice(e.lastIndexOf("/",t)+1,t)}}}]),o}(Ks);ta.types=["url"];var ra=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"load",value:function(){var e=this;return new Promise((function(t){if(e._abort)throw new Error("Loading aborted");t(e._source)}))}}],[{key:"canProbablyLoad",value:function(e){return!1}}]),i}(Ks);ra.types=["immediate"];var na=new Qs([Js,ta,ra]);var ia=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(this,i),n.call(this,e,["formats","extensions"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format?t=this._dict.formats[e.format.toLowerCase()]||[]:e.ext&&(t=this._dict.extensions[e.ext.toLowerCase()]||[]),0===t.length&&!e.format&&e.data?this._list.filter((function(t){return t.canProbablyParse&&t.canProbablyParse(e.data)})):Pr(t)}}]),i}(Mr),oa=function(){function e(t,r){s(this,e),this._data=t,this._options=r||{},this._abort=!1}return l(e,[{key:"parseSync",value:function(){throw new Error("Parsing this type of data is not implemented")}},{key:"parse",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Parsing aborted")):t(e.parseSync())}catch(e){return r(e)}}))}))}},{key:"getModel",value:function(){return this.model._parseHeader(this._data),this.model}},{key:"abort",value:function(){this._abort=!0}}]),e}();Ir(oa.prototype);var sa=function(){function e(){s(this,e),this.matrices=[],this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._matrix;if(" SMTRY"===e.readString(12,18)){var r=e.readCharCode(19)-49,n=e.readString(20,80).trim().split(/\s+/),o=parseInt(n[0],10);null!==this._matrix&&o===this._matrixIndex||(this._matrixIndex=o,this._matrix=t=new i.kn4,this.matrices[this.matrices.length]=t);var s=t.elements;s[r]=parseFloat(n[1]),s[r+4]=parseFloat(n[2]),s[r+8]=parseFloat(n[3]),s[r+12]=parseFloat(n[4])}}}]),e}();sa.prototype.id=290;var aa=dr.Assembly,la=function(){function e(t){s(this,e),this._complex=t,this.assemblies=[],this._assembly=null,this._matrix=null,this._matrixIndex=-1}return l(e,[{key:"parse",value:function(e){var t=this._assembly,r=this._matrix;if(t&&" BIOMT"===e.readString(12,18)){var n=e.readCharCode(19)-49,o=e.readString(20,80).trim().split(/\s+/),s=parseInt(o[0],10);null!==this._matrix&&s===this._matrixIndex||(this._matrixIndex=s,this._matrix=r=new i.kn4,t.addMatrix(r));var a=r.elements;a[n]=parseFloat(o[1]),a[n+4]=parseFloat(o[2]),a[n+8]=parseFloat(o[3]),a[n+12]=parseFloat(o[4])}else if(t&&"CHAINS:"===e.readString(35,41))for(var l=e.readString(42,80).split(","),c=0,u=l.length;c<u;++c){var h=l[c].trim();h.length>0&&t.addChain(h)}else"BIOMOLECULE:"===e.readString(12,23)&&(this._matrix=null,this._matrixIndex=-1,this._assembly=t=new aa(this._complex),this.assemblies.push(t))}}]),e}();la.prototype.id=350;var ca=function(){function e(t){s(this,e),this._data=t,this._start=0,this._nextCR=-1,this._nextLF=-1,this._next=-1,this._end=t.length,this.next()}return l(e,[{key:"readLine",value:function(){return this._data.slice(this._start,this._next)}},{key:"readChar",value:function(e){return(e=this._start+e-1)<this._next?this._data[e]:" "}},{key:"readCharCode",value:function(e){return(e=this._start+e-1)<this._next?this._data.charCodeAt(e):32}},{key:"readString",value:function(e,t){var r=this._start+e-1,n=this._start+t;return this._data.slice(r,n<this._next?n:this._next)}},{key:"readInt",value:function(e,t){return parseInt(this.readString(e,t),10)}},{key:"readFloat",value:function(e,t){return parseFloat(this.readString(e,t))}},{key:"end",value:function(){return this._start>=this._end}},{key:"next",value:function(){var e=this._next+1;this._start=e<this._end?e:this._end,this._start>this._nextCR&&(this._nextCR=(this._data.indexOf("\r",this._start)+1||this._end+1)-1),this._start>this._nextLF&&(this._nextLF=(this._data.indexOf("\n",this._start)+1||this._end+1)-1),this._next=this._nextCR+1<this._nextLF?this._nextCR:this._nextLF}}]),e}();var ua=dr.Complex,ha=dr.Element,fa=dr.Helix,da=dr.Sheet,pa=dr.Strand,ma=dr.Bond,va=dr.Molecule,ya=/^(HEADER\s|COMPND\s|REMARK\s|ATOM {2}|HETATM|MODEL )/i,_a={290:sa,350:la},ga=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._complex=null,r._chain=null,r._residue=null,r._sheet=null,r._serialAtomMap=null,r._modelId=1,r._compaundFound=!1,r._biomoleculeFound=!1,r._allowedChainsIDs=null,r._lastMolId=-1,r._remarks={},r._remark=null,r._molecules=[],r._molecule=null,r._compndCurrToken="",r._options.fileType="pdb",r}return l(a,[{key:"_finalize",value:function(){this._fixBondsArray(),this._fixChains();var e=this._remarks[290];this._complex.symmetry=(0,n.isUndefined)(e)?[]:e.matrices;var t=this._remarks[350];this._complex.units=this._complex.units.concat((0,n.isUndefined)(t)?[]:t.assemblies),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"_finalizeMolecules",value:function(){var e,t={},r=this._complex._chains;for(e=0;e<r.length;++e){var n=r[e];t[n._name]=n}for(e=0;e<this._molecules.length;e++){for(var i=this._molecules[e],o=[],s=0;s<i._chains.length;s++){var a=t[i._chains[s]];o=o.concat(a._residues.slice())}var l=new va(this._complex,i._name,e+1);l.residues=o,this._complex._molecules[e]=l}}},{key:"_fixChains",value:function(){for(var e={},t=this._complex,r=0;r<t._chains.length;r++){var n=t._chains[r];e[n._name.charCodeAt(0)]=n}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap={},t=this._complex,r=t._atoms,n=0,i=r.length;n<i;++n){var o=r[n];e[o.serial]=o}for(var s=t._bonds,a=this.logger,l=0,c=s.length;l<c;++l){var u=s[l];u._right<u._left&&a.debug("_fixBondsArray: Logic error."),u._left=e[u._left]||null,u._right=e[u._right]||null}}},{key:"_parseATOM",value:function(e){if(1===this._modelId){var t=72===e.readCharCode(1),r=t?e.readInt(7,11):e.readInt(6,11),n=e.readString(13,16),o=e.readChar(17),s=e.readString(18,20).trim(),a=e.readChar(22),l=e.readInt(23,26),c=e.readChar(27),u=e.readFloat(31,38),h=e.readFloat(39,46),f=e.readFloat(47,54),d=e.readFloat(55,60),p=e.readFloat(61,66),m=e.readString(77,78).trim()||function(e){var t=4===e.trim().length;return e.slice(0,t?1:2).trim()}(n),v=e.readInt(79,80)||0;if(!this.settings.now.nowater||"HOH"!==s&&"WAT"!==s){n=n.trim();var y=ha.getByName(m),_=ha.Role[n],g=this._chain;g&&g.getName()===a||(this._chain=g=this._complex.getChain(a)||this._complex.addChain(a),this._residue=null);var x=this._residue;x&&x.getSequence()===l&&x.getICode()===c||(this._residue=x=g.addResidue(s,l,c));var b=new i.Pq0(u,h,f);x.addAtom(n,y,b,_,t,r,o,d,p,v)}}}},{key:"_parseENDMDL",value:function(){this._modelId+=1}},{key:"_parseCONECT",value:function(e){var t=e.readInt(7,11),r=e.readInt(12,16),n=e.readInt(17,21),i=e.readInt(22,26),o=e.readInt(27,31),s=this._complex;r&&r>t&&s.addBond(t,r,0,ma.BondType.UNKNOWN,!0),n&&n>t&&s.addBond(t,n,0,ma.BondType.UNKNOWN,!0),i&&i>t&&s.addBond(t,i,0,ma.BondType.UNKNOWN,!0),o&&o>t&&s.addBond(t,o,0,ma.BondType.UNKNOWN,!0)}},{key:"_parseCOMPND",value:function(e){var t=e.readString(11,80),r=t.indexOf(":");if(this._compndCurrToken=r>0?t.substring(0,r).trim():this._compndCurrToken,"MOL_ID"===this._compndCurrToken)this._molecule={_index:"",_chains:[]},this._molecule._index=parseInt(t.substring(r+1,t.indexOf(";")),10),this._molecules.push(this._molecule);else if("MOLECULE"===this._compndCurrToken&&null!=this._molecule)this._molecule._name=t.substring(r+1,t.indexOf(";")).trim();else if("CHAIN"===this._compndCurrToken&&null!=this._molecule){var n=t.substring(r+1,80).trim(),i=n[n.length-1];";"!==i&&","!==i||(n=n.slice(0,-1));var o=(n=n.replace(/\s+/g,"")).split(",");this._molecule._chains=this._molecule._chains.concat(o)}}},{key:"_parseREMARK",value:function(e){var t=e.readInt(8,10),r=this._remarks[t];if((0,n.isUndefined)(r)){var i=_a[t];"function"==typeof i&&(this._remarks[t]=r=new i(this._complex))}(0,n.isUndefined)(r)||r.parse(e)}},{key:"_parseHELIX",value:function(e){var t=this;this._parseSTRUCTURE(e,[20,22,32,34],(function(e){t._complex.addHelix(e),t._complex.structures.push(e)}))}},{key:"_parseSHEET",value:function(e){var t=this;this._parseSTRUCTURE(e,[22,23,33,34],(function(e){t._complex.addSheet(e)}))}},{key:"_parseSTRUCTURE",value:function(e,t,r){var n=e.readInt(8,10),i=e.readString(12,14).trim(),o=e.readString(41,70).trim(),s=e.readInt(72,76),a=e.readInt(39,40),l=e.readInt(15,16),c=e.readInt(42,45),u=e.readInt(57,60),h=e.readString(t[0],t[2]+1).charCodeAt(0),f=e.readString(t[2],t[2]+1).charCodeAt(0),d=e.readInt(t[1],t[1]+3),p=e.readString(t[1]+4,t[1]+4),m=0;p.length>0&&(m=p.charCodeAt(0));var v,y=e.readInt(t[3],t[3]+3),_=0;(p=e.readString(t[3]+4,t[3]+4)).length>0&&(_=p.charCodeAt(0));var g=this._sheet;if(83===e.readCharCode(1)){null!==g&&g.getName()!==i&&(g=null,this._sheet=null),null===g?(this._sheet=v=new da(i,l),r(v)):v=g;var x=new pa(v,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),a,c,u);v.addStrand(x),this._complex.structures.push(x)}else r(v=new fa(a,this._complex.getUnifiedSerial(h,d,m),this._complex.getUnifiedSerial(f,y,_),n,i,o,s))}},{key:"_parseHEADER",value:function(e){var t=this._complex.metadata;t.classification=e.readString(11,50).trim(),t.date=e.readString(51,59).trim();var r=e.readString(63,66).trim();t.id=r,r&&(this._complex.name=r),t.format="pdb"}},{key:"_parseTITLE",value:function(e){var t=this._complex.metadata;t.title=t.title||[];var r=e.readInt(9,10)||1;t.title[r-1]=e.readString(11,80).trim()}},{key:"parseSync",value:function(){for(var e=new ca(this._data),t=this._complex=new ua;!e.end();){var r=e.readString(1,6),n=a.tagParsers[r];"function"==typeof n&&n.call(this,e),e.next()}if(this._finalize(),this._serialAtomMap=null,this._sheet=null,this._residue=null,this._chain=null,this._complex=null,0===t.getAtomCount())throw new Error("The data does not contain valid atoms");return t}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&ya.test(e)}}]),a}(oa);Se(ga,"tagParsers",{HEADER:ga.prototype._parseHEADER,"TITLE ":ga.prototype._parseTITLE,"ATOM ":ga.prototype._parseATOM,HETATM:ga.prototype._parseATOM,ENDMDL:ga.prototype._parseENDMDL,CONECT:ga.prototype._parseCONECT,COMPND:ga.prototype._parseCOMPND,REMARK:ga.prototype._parseREMARK,"HELIX ":ga.prototype._parseHELIX,"SHEET ":ga.prototype._parseSHEET,"ATOM 1":ga.prototype._parseATOM,"ATOM 2":ga.prototype._parseATOM,"ATOM 3":ga.prototype._parseATOM,"ATOM 4":ga.prototype._parseATOM,"ATOM 5":ga.prototype._parseATOM,"ATOM 6":ga.prototype._parseATOM,"ATOM 7":ga.prototype._parseATOM,"ATOM 8":ga.prototype._parseATOM,"ATOM 9":ga.prototype._parseATOM}),ga.formats=["pdb"],ga.extensions=[".pdb",".ent"];var xa=dr.Complex,ba=dr.Element,wa=dr.SGroup,Sa=dr.Bond,Ra={A:0,S:1,D:2,T:3},Ca=/\s*<\?xml\b[^?>]*\?>\s*<(?:cml|molecule)\b/i,ka=function(e){h(c,e);var t,r,a=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function c(e,t){var r;return s(this,c),(r=a.call(this,e,t))._complex=null,r._residue=null,r._serialAtomMap=null,r._modelId=1,r._lastMolId=-1,r._readOnlyOneMolecule=!1,r._options.fileType="cml",r}return l(c,[{key:"_rebuidBondIndexes",value:function(e,t){for(var r=e.length,n=0;n<r;n++)for(var i=e[n].id,o=t.length,s=0;s<o;s++){var a=t[s].atomRefs2.split(" ");a[0]===i&&(t[s].start=n),a[1]===i&&(t[s].end=n)}}},{key:"_createSGroup",value:function(e,t){var r=new wa(e.id,e.fieldData,new i.Pq0(parseFloat(e.x),parseFloat(e.y),0),e.atomRefs,e);"Relative"===e.placement&&(r._center=new i.Pq0(0,0,0)),"MDLBG_FRAGMENT_CHARGE"===e.fieldName&&(r._charge=parseInt(e.fieldData,10)||0),"MDLBG_FRAGMENT_COEFFICIENT"===e.fieldName&&(r._repeat=parseInt(e.fieldData,10)||1),t.push(r)}},{key:"_extractSGroup",value:function(e,t){if(Array.isArray(t)||(t=[]),e)if(Array.isArray(e))for(var r=e.length,n=0;n<r;n++)e[n].molecule&&(t=t.concat(this._extractSGroup(e[n].molecule))),this._createSGroup(e[n],t);else e.molecule&&e.molecule&&(t=t.concat(this._extractSGroup(e.molecule))),this._createSGroup(e,t);return t}},{key:"_extractSGroups",value:function(e,t){var r,n,o=this._extractSGroup(e),s=t.length;for(r=0;r<s;r++){var a=t[r].id;for(n=0;n<o.length;n++)o[n]._atoms.split(" ")[0]===a&&(t[r].sgroupRef||(t[r].sgroupRef=[]),t[r].sgroupRef.push(o[n]))}var l,c={},u=null,h=1e8,f=new i.Pq0(h,h,h),d=new i.Pq0(-h,-h,-h);function p(e){(u=c[e])&&o[n]._atoms.push(u.a)}function m(e){(u=c[e])&&(f.set(Math.min(f.x,u.x),Math.min(f.y,u.y),Math.min(f.z,u.z)),d.set(Math.max(d.x,u.x),Math.max(d.y,u.y),Math.max(d.z,u.z)),p(e))}for(r=0;r<t.length;r++)c[t[r].id]={},c[t[r].id].x=t[r].x2,t[r].x3&&(c[t[r].id].x=t[r].x3),c[t[r].id].x=parseFloat(c[t[r].id].x),c[t[r].id].y=t[r].y2,t[r].y3&&(c[t[r].id].y=t[r].y3),c[t[r].id].y=parseFloat(c[t[r].id].y),c[t[r].id].z="0.0",t[r].z3&&(c[t[r].id].z=t[r].z3),c[t[r].id].z=parseFloat(c[t[r].id].z),c[t[r].id].a=t[r];for(n=0;n<o.length;n++)null!==o[n]._center?(f.set(h,h,h),d.set(-h,-h,-h),l=o[n]._atoms.split(" "),o[n]._atoms=[],l.forEach(m),o[n]._center.addVectors(f,d),o[n]._center.multiplyScalar(.5)):(l=o[n]._atoms.split(" "),o[n]._atoms=[],l.forEach(p));c=null}},{key:"_traverseData",value:function(e){var t={};return e.childNodes.length&&function e(t,r){if("#text"!==t.nodeName||""!==t.nodeValue.trim()){var n={};n.xmlNode=t;var i,o,s,a=r[t.nodeName];if(a?(i=a,"[object Array]"!==Object.prototype.toString.apply(i)?r[t.nodeName]=[a,n]:r[t.nodeName].push(n)):r[t.nodeName]=n,t.attributes)for(o=t.attributes.length,s=0;s<o;s++){var l=t.attributes[s];n[l.nodeName]=l.nodeValue}for(o=t.childNodes.length,s=0;s<o;s++)e(t.childNodes[s],n)}}(e.childNodes[0],t),t}},{key:"_findSuitableMolecule",value:function(e,t){for(var r in e)if("xmlNode"!==r)if("molecule"===r){if(e.molecule&&(e.molecule.atomArray&&e.molecule.atomArray.atom&&t.push(e),Array.isArray(e.molecule)))for(var n=0;n<e.molecule.length;n++)e.molecule[n].atomArray&&e.molecule[n].atomArray.atom&&t.push({molecule:e.molecule[n]})}else e[r]&&null!==e[r]&&"object"===o(e[r])&&this._findSuitableMolecule(e[r],t)}},{key:"_selectComponents",value:function(e){var t,r=(new DOMParser).parseFromString(e,"application/xml"),n=this._traverseData(r),i=this;t=n.cml?n.cml:n;var o=[],s=[];return this._findSuitableMolecule(t,s),this._readOnlyOneMolecule&&s.length>1&&s.splice(1,s.length-1),s.forEach((function(e){var t=function(e){var t,n=[];if(e.molecule&&e.molecule.atomArray&&e.molecule.atomArray.atom)Array.isArray(e.molecule.atomArray.atom)?n=e.molecule.atomArray.atom:n.push(e.molecule.atomArray.atom);else if(!e.molecule)return{atomLabels:null,labelsCount:1};e.molecule.molecule&&i._extractSGroups(e.molecule.molecule,n);for(var o=n.length,s=0;s<o;s++)(t=n[s]).edges=[];var a,l=[];e.molecule.bondArray&&e.molecule.bondArray.bond&&(Array.isArray(e.molecule.bondArray.bond)?l=e.molecule.bondArray.bond:l.push(e.molecule.bondArray.bond)),o=l.length,i._rebuidBondIndexes(n,l);for(var c=0;c<o;c++)if((t=n[(a=l[c]).start])&&(t.edges.push(a.end),(t=n[a.end])&&(t.edges.push(a.start),1))){var u=a.xmlNode.getAttribute("order"),h=parseInt(u,10);if(l[c].order=0,l[c].type=Sa.BondType.UNKNOWN,h>1)l[c].order=h;else{var f=Ra[u];void 0!==f&&(l[c].order=f,"A"===u&&(l[c].type=Sa.BondType.AROMATIC))}}o=n.length;for(var d=0;d<o;d++)(t=n[d]).edges.sort();var p=i._breadWidthSearch(n,0),m={};return m.atoms=n,m.bonds=l,m.labels=p.atomLabels,m.count=Math.min(1,p.labelsCount),m.curr=-1,m.originalCML=r,m}(e);t.atoms.length>0&&o.push(t)})),o}},{key:"_packLabel",value:function(e,t){return(t<<16)+e}},{key:"_unpackLabel",value:function(e){return{molId:e>>>16,compId:65535&e}}},{key:"_breadWidthSearch",value:function(e,t){var r,n=new Array(e.length);for(r=0;r<n.length;r++)n[r]=this._packLabel(0,t);for(var i=[],o=0,s=e.length;s>0;){o++;var a=-1;for(r=0;r<n.length;r++)if(0===this._unpackLabel(n[r]).compId){a=r;break}if(a<0)break;for(i.push(e[a]),n[a]=this._packLabel(o,t),s--;i.length>0;){var l=i.shift();if(l)for(var c=0;c<l.edges.length;c++)n[l.edges[c]]!==o&&(i.push(e[l.edges[c]]),n[l.edges[c]]=o,s--)}}var u={};return u.atomLabels=n,u.labelsCount=o,u}},{key:"_parseBond",value:function(e,t,r,n){if(e>=0){var i=[Math.min(e,t),Math.max(e,t)];this._complex.addBond(i[0],i[1],r,n,!0)}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap={},t=this._complex,r=t._atoms,n=0,i=r.length;n<i;++n){var o=r[n];e[o.serial]=o}for(var s=t._bonds,a=this.logger,l=0,c=s.length;l<c;++l){var u=s[l];u._right<u._left&&a.debug("_fixBondsArray: Logic error."),u._left=e[u._left]||null,u._right=e[u._right]||null}}},{key:"_parseSet",value:function(e){var t,r,n,o=this._complex=new xa,s=e,a=s.curr,l=s.atoms,c=s.labels,u=null,h=l.length,f={},d=[];for(t=0;t<h;t++)d.push(t);for(d.sort((function(e,t){return c[e]-c[t]})),t=0;t<h;t++){var p=c[d[t]];if(this._unpackLabel(p).molId===this._unpackLabel(a).molId){var m=(u=l[d[t]]).elementType;if(u.sgroupRef)for(var v=u.sgroupRef.length,y=0;y<v;++y)o._sgroups.push(u.sgroupRef[y]);if(u.x3||u.x2){var _=this._unpackLabel(p).compId,g=" ",x=_,b=_.toString();1===b.length&&(b="0".concat(b));var w="N".concat(b),S=f[g];S&&S.getName()===g||(f[g]=S=this._complex.getChain(g)||this._complex.addChain(g),this._residue=null);var R=this._residue;R&&R.getSequence()===x&&" "===R.getICode()||(this._residue=R=S.addResidue(w,x," "));var C=null;u.x3?C=new i.Pq0(parseFloat(u.x3),parseFloat(u.y3),parseFloat(u.z3)):u.x2&&(C=new i.Pq0(parseFloat(u.x2),parseFloat(u.y2),0));var k=ba.ByName[u.elementType.toUpperCase()];k||((k=JSON.parse(JSON.stringify(ba.ByName[Object.keys(ba.ByName)[Object.keys(ba.ByName).length-1]]))).number+=1,k.name=u.elementType.toUpperCase(),k.fullName="Unknown",ba.ByName[u.elementType.toUpperCase()]=k);var A=parseInt(u.id.replace(/[^0-9]/,""),10),E=R.addAtom(m,k,C,ba.Role.SG,!0,A," ",1,0,0);u.hydrogenCount&&(E.hydrogenCount=parseInt(u.hydrogenCount,10)),u.mrvValence&&(E.valence=parseInt(u.mrvValence,10)),(n=E).xmlNodeRef=u,u.x2&&(u.x3=u.x2,delete u.x2),u.y2&&(u.y3=u.y2,delete u.y2),u.z3||(u.z3="0.0"),u.complexAtom=n}}}for(f=null,t=0;t<s.bonds.length;t++){var P=s.bonds[t];if(this._unpackLabel(c[P.start]).molId===this._unpackLabel(a).molId&&this._unpackLabel(c[P.end]).molId===this._unpackLabel(a).molId){if(!(u=l[P.start])||!l[P.end])continue;this._parseBond(parseInt(u.id.replace(/[^0-9]/,""),10),parseInt(l[P.end].id.replace(/[^0-9]/,""),10),P.order,P.type)}}for(t=0;t<this._complex.getSGroupCount();t++){var T=this._complex.getSGroups()[t];for(r=0;r<T._atoms.length;r++)T._atoms[r]=T._atoms[r].complexAtom}for(t=0;t<h;t++)this._unpackLabel(c[t]).molId===this._unpackLabel(a).molId&&((u=l[t]).complexAtom=null,delete u.complexAtom);return this._complex.originalCML=s.originalCML,this._fixBondsArray(),o.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._serialAtomMap=null,this._complex=null,o}},{key:"parseSync",value:function(){var e=[],t=this;this._selectComponents(this._data).forEach((function(r){r.curr=2,0===r.count&&(r.count=1);for(var n=0;n<r.count;n++)r.curr=n+1,e.push(t._parseSet(r,!1))}));var r=0;if(e.forEach((function(e){r+=e.getAtomCount()})),r<=0)throw new Error("The data does not contain valid atoms");if(e.length>1){var n=new xa;return n.joinComplexes(e),n.originalCML=e[0].originalCML,n}return 1===e.length?e[0]:new xa}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&Ca.test(e)}}]),c}(oa);ka.formats=["cml"],ka.extensions=[".cml"];var Aa={};!function(e,t){!function(e){function t(e,t,r){for(var n=(e.byteLength,0),i=r.length;i>n;n++){var o=r.charCodeAt(n);if(128>o)e.setUint8(t++,o>>>0&127);else if(2048>o)e.setUint8(t++,o>>>6&31|192),e.setUint8(t++,o>>>0&63|128);else if(65536>o)e.setUint8(t++,o>>>12&15|224),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128);else{if(!(1114112>o))throw new Error("bad codepoint "+o);e.setUint8(t++,o>>>18&7|240),e.setUint8(t++,o>>>12&63|128),e.setUint8(t++,o>>>6&63|128),e.setUint8(t++,o>>>0&63|128)}}}function r(e){for(var t=0,r=0,n=e.length;n>r;r++){var i=e.charCodeAt(r);if(128>i)t+=1;else if(2048>i)t+=2;else if(65536>i)t+=3;else{if(!(1114112>i))throw new Error("bad codepoint "+i);t+=4}}return t}function n(e,i,s){var a=o(e);if("string"===a){if(32>(l=r(e)))return i.setUint8(s,160|l),t(i,s+1,e),1+l;if(256>l)return i.setUint8(s,217),i.setUint8(s+1,l),t(i,s+2,e),2+l;if(65536>l)return i.setUint8(s,218),i.setUint16(s+1,l),t(i,s+3,e),3+l;if(4294967296>l)return i.setUint8(s,219),i.setUint32(s+1,l),t(i,s+5,e),5+l}if(e instanceof Uint8Array){var l=e.byteLength,c=new Uint8Array(i.buffer);if(256>l)return i.setUint8(s,196),i.setUint8(s+1,l),c.set(e,s+2),2+l;if(65536>l)return i.setUint8(s,197),i.setUint16(s+1,l),c.set(e,s+3),3+l;if(4294967296>l)return i.setUint8(s,198),i.setUint32(s+1,l),c.set(e,s+5),5+l}if("number"===a){if(!isFinite(e))throw new Error("Number not finite: "+e);if(Math.floor(e)!==e)return i.setUint8(s,203),i.setFloat64(s+1,e),9;if(e>=0){if(128>e)return i.setUint8(s,e),1;if(256>e)return i.setUint8(s,204),i.setUint8(s+1,e),2;if(65536>e)return i.setUint8(s,205),i.setUint16(s+1,e),3;if(4294967296>e)return i.setUint8(s,206),i.setUint32(s+1,e),5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return i.setInt8(s,e),1;if(e>=-128)return i.setUint8(s,208),i.setInt8(s+1,e),2;if(e>=-32768)return i.setUint8(s,209),i.setInt16(s+1,e),3;if(e>=-2147483648)return i.setUint8(s,210),i.setInt32(s+1,e),5;throw new Error("Number too small -0x"+(-e).toString(16).substr(1))}if(null===e)return i.setUint8(s,192),1;if("boolean"===a)return i.setUint8(s,e?195:194),1;if("object"===a){var u=0,h=Array.isArray(e);if(h)l=e.length;else{var f=Object.keys(e);l=f.length}if(16>l?(i.setUint8(s,l|(h?144:128)),u=1):65536>l?(i.setUint8(s,h?220:222),i.setUint16(s+1,l),u=3):4294967296>l&&(i.setUint8(s,h?221:223),i.setUint32(s+1,l),u=5),h)for(var d=0;l>d;d++)u+=n(e[d],i,s+u);else for(d=0;l>d;d++){var p=f[d];u+=n(p,i,s+u),u+=n(e[p],i,s+u)}return u}throw new Error("Unknown type "+a)}function i(e){var t=o(e);if("string"===t){if(32>(n=r(e)))return 1+n;if(256>n)return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if(e instanceof Uint8Array){if(256>(n=e.byteLength))return 2+n;if(65536>n)return 3+n;if(4294967296>n)return 5+n}if("number"===t){if(Math.floor(e)!==e)return 9;if(e>=0){if(128>e)return 1;if(256>e)return 2;if(65536>e)return 3;if(4294967296>e)return 5;throw new Error("Number too big 0x"+e.toString(16))}if(e>=-32)return 1;if(e>=-128)return 2;if(e>=-32768)return 3;if(e>=-2147483648)return 5;throw new Error("Number too small -0x"+e.toString(16).substr(1))}if("boolean"===t||null===e)return 1;if("object"===t){var n,s=0;if(Array.isArray(e)){n=e.length;for(var a=0;n>a;a++)s+=i(e[a])}else{var l=Object.keys(e);for(n=l.length,a=0;n>a;a++){var c=l[a];s+=i(c)+i(e[c])}}if(16>n)return 1+s;if(65536>n)return 3+s;if(4294967296>n)return 5+s;throw new Error("Array or object too long 0x"+n.toString(16))}throw new Error("Unknown type "+t)}function s(e){var t=new ArrayBuffer(i(e));return n(e,new DataView(t),0),new Uint8Array(t)}function a(e,t,r){return t?new e(t.buffer,t.byteOffset,t.byteLength/(r||1)):void 0}function l(e){return a(DataView,e)}function c(e){return a(Uint8Array,e)}function u(e){return a(Int8Array,e)}function h(e){return a(Int32Array,e,4)}function f(e,t){var r=e.length/2;t||(t=new Int16Array(r));for(var n=0,i=0;r>n;++n,i+=2)t[n]=e[i]<<8^e[i+1];return t}function d(e,t){var r=e.length/4;t||(t=new Int32Array(r));for(var n=0,i=0;r>n;++n,i+=4)t[n]=e[i]<<24^e[i+1]<<16^e[i+2]<<8^e[i+3];return t}function p(e,t){var r=e.length;t||(t=new Uint8Array(4*r));for(var n=l(t),i=0;r>i;++i)n.setInt32(4*i,e[i]);return c(t)}function m(e,t,r){var n=e.length,i=1/t;r||(r=new Float32Array(n));for(var o=0;n>o;++o)r[o]=e[o]*i;return r}function v(e,t,r){var n=e.length;r||(r=new Int32Array(n));for(var i=0;n>i;++i)r[i]=Math.round(e[i]*t);return r}function y(e,t){var r,n;if(!t){var i=0;for(r=0,n=e.length;n>r;r+=2)i+=e[r+1];t=new e.constructor(i)}var o=0;for(r=0,n=e.length;n>r;r+=2)for(var s=e[r],a=e[r+1],l=0;a>l;++l)t[o]=s,++o;return t}function _(e){if(0===e.length)return new Int32Array;var t,r,n=2;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]&&(n+=2);var i=new Int32Array(n),o=0,s=1;for(t=1,r=e.length;r>t;++t)e[t-1]!==e[t]?(i[o]=e[t-1],i[o+1]=s,s=1,o+=2):++s;return i[o]=e[e.length-1],i[o+1]=s,i}function g(e,t){var r=e.length;t||(t=new e.constructor(r)),r&&(t[0]=e[0]);for(var n=1;r>n;++n)t[n]=e[n]+t[n-1];return t}function x(e,t){var r=e.length;t||(t=new e.constructor(r)),t[0]=e[0];for(var n=1;r>n;++n)t[n]=e[n]-e[n-1];return t}function b(e,t){var r,n,i=e instanceof Int8Array?127:32767,o=-i-1,s=e.length;if(!t){var a=0;for(r=0;s>r;++r)e[r]<i&&e[r]>o&&++a;t=new Int32Array(a)}for(r=0,n=0;s>r;){for(var l=0;e[r]===i||e[r]===o;)l+=e[r],++r;l+=e[r],++r,t[n]=l,++n}return t}function w(e,t,r){return m(b(e,h(r)),t,r)}function S(e,t,r){var n=b(e,h(r));return function(e,t,r){return m(g(e,h(r)),t,r)}(n,t,function(e){return a(Float32Array,e,4)}(n))}function R(e,t,r){return function(e,t){var r,n=t?127:32767,i=-n-1,o=e.length,s=0;for(r=0;o>r;++r)0===(c=e[r])?++s:s+=c===n||c===i?2:c>0?Math.ceil(c/n):Math.ceil(c/i);var a=t?new Int8Array(s):new Int16Array(s),l=0;for(r=0;o>r;++r){var c;if((c=e[r])>=0)for(;c>=n;)a[l]=n,++l,c-=n;else for(;i>=c;)a[l]=i,++l,c-=i;a[l]=c,++l}return a}(function(e,t,r){return x(v(e,t),r)}(e,t),r)}function C(e,t,r,n){var i=new ArrayBuffer(12+n.byteLength),o=new Uint8Array(i),s=new DataView(i);return s.setInt32(0,e),s.setInt32(4,t),r&&o.set(r,8),o.set(n,12),o}function k(e){return C(2,e.length,void 0,c(e))}function A(e){return C(4,e.length,void 0,p(e))}function E(e,t){return C(5,e.length/t,p([t]),c(e))}function P(e){return C(6,e.length,void 0,p(_(e)))}function T(e){return C(8,e.length,void 0,p(function(e){return _(x(e))}(e)))}function M(e,t){return C(9,e.length,p([t]),p(function(e,t){return _(v(e,t))}(e,t)))}function I(e,t){return C(10,e.length,p([t]),function(e,t){var r=e.length;t||(t=new Uint8Array(2*r));for(var n=l(t),i=0;r>i;++i)n.setInt16(2*i,e[i]);return c(t)}(R(e,t)))}function N(e){var t={};return V.forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),e.bondAtomList&&(t.bondAtomList=A(e.bondAtomList)),e.bondOrderList&&(t.bondOrderList=k(e.bondOrderList)),t.xCoordList=I(e.xCoordList,1e3),t.yCoordList=I(e.yCoordList,1e3),t.zCoordList=I(e.zCoordList,1e3),e.bFactorList&&(t.bFactorList=I(e.bFactorList,100)),e.atomIdList&&(t.atomIdList=T(e.atomIdList)),e.altLocList&&(t.altLocList=P(e.altLocList)),e.occupancyList&&(t.occupancyList=M(e.occupancyList,100)),t.groupIdList=T(e.groupIdList),t.groupTypeList=A(e.groupTypeList),e.secStructList&&(t.secStructList=k(e.secStructList)),e.insCodeList&&(t.insCodeList=P(e.insCodeList)),e.sequenceIndexList&&(t.sequenceIndexList=T(e.sequenceIndexList)),t.chainIdList=E(e.chainIdList,4),e.chainNameList&&(t.chainNameList=E(e.chainNameList,4)),t}function O(e){function t(e){for(var t={},r=0;e>r;r++)t[o()]=o();return t}function r(t){var r=e.subarray(s,s+t);return s+=t,r}function n(t){var r=e.subarray(s,s+t);s+=t;var n=65535;if(t>n){for(var i=[],o=0;o<r.length;o+=n)i.push(String.fromCharCode.apply(null,r.subarray(o,o+n)));return i.join("")}return String.fromCharCode.apply(null,r)}function i(e){for(var t=new Array(e),r=0;e>r;r++)t[r]=o();return t}function o(){var o,l,c=e[s];if(!(128&c))return s++,c;if(128==(240&c))return s++,t(l=15&c);if(144==(240&c))return s++,i(l=15&c);if(160==(224&c))return s++,n(l=31&c);if(!(224&~c))return o=a.getInt8(s),s++,o;switch(c){case 192:return s++,null;case 194:return s++,!1;case 195:return s++,!0;case 196:return l=a.getUint8(s+1),s+=2,r(l);case 197:return l=a.getUint16(s+1),s+=3,r(l);case 198:return l=a.getUint32(s+1),s+=5,r(l);case 202:return o=a.getFloat32(s+1),s+=5,o;case 203:return o=a.getFloat64(s+1),s+=9,o;case 204:return o=e[s+1],s+=2,o;case 205:return o=a.getUint16(s+1),s+=3,o;case 206:return o=a.getUint32(s+1),s+=5,o;case 208:return o=a.getInt8(s+1),s+=2,o;case 209:return o=a.getInt16(s+1),s+=3,o;case 210:return o=a.getInt32(s+1),s+=5,o;case 217:return l=a.getUint8(s+1),s+=2,n(l);case 218:return l=a.getUint16(s+1),s+=3,n(l);case 219:return l=a.getUint32(s+1),s+=5,n(l);case 220:return l=a.getUint16(s+1),s+=3,i(l);case 221:return l=a.getUint32(s+1),s+=5,i(l);case 222:return l=a.getUint16(s+1),s+=3,t(l);case 223:return l=a.getUint32(s+1),s+=5,t(l)}throw new Error("Unknown type 0x"+c.toString(16))}var s=0,a=new DataView(e.buffer);return o()}function L(e,t,r,n){switch(e){case 1:return function(e,t){var r=e.length;t||(t=new Float32Array(r/4));for(var n=l(t),i=l(e),o=0,s=0,a=r/4;a>o;++o,s+=4)n.setFloat32(s,i.getFloat32(s),!0);return t}(t);case 2:return u(t);case 3:return f(t);case 4:return d(t);case 5:return c(t);case 6:return y(d(t),new Uint8Array(r));case 7:return y(d(t));case 8:return function(e,t){return g(y(e),t)}(d(t));case 9:return function(e,t,r){return m(y(e,h(r)),t,r)}(d(t),d(n)[0]);case 10:return S(f(t),d(n)[0]);case 11:return m(f(t),d(n)[0]);case 12:return w(f(t),d(n)[0]);case 13:return w(u(t),d(n)[0]);case 14:return b(f(t));case 15:return b(u(t))}}function B(e,t){var r=(t=t||{}).ignoreFields,n={};return U.forEach((function(t){var i=!!r&&-1!==r.indexOf(t),o=e[t];i||void 0===o||(o instanceof Uint8Array?n[t]=L.apply(null,function(e){var t=l(e),r=t.getInt32(0),n=t.getInt32(4),i=e.subarray(8,12);return[r,e=e.subarray(12),n,i]}(o)):n[t]=o)})),n}function D(e){return String.fromCharCode.apply(null,e).replace(/\0/g,"")}function z(e,t){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),B(e instanceof Uint8Array?O(e):e,t)}function F(e,t,r,n){var i=new XMLHttpRequest;i.addEventListener("load",(function(){try{var e=z(i.response);r(e)}catch(e){n(e)}}),!0),i.addEventListener("error",n,!0),i.responseType="arraybuffer",i.open("GET",t+e.toUpperCase()),i.send()}var V=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"],U=V.concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]),j="//mmtf.rcsb.org/v1.0/",G=j+"full/",H=j+"reduced/";e.encode=function(e){return s(N(e))},e.decode=z,e.traverse=function(e,t,r){var n,i,o,s,a,l,c=(r=r||{}).firstModelOnly,u=t.onModel,h=t.onChain,f=t.onGroup,d=t.onAtom,p=t.onBond,m=0,v=0,y=0,_=0,g=0,x=-1,b=e.chainNameList,w=e.secStructList,S=e.insCodeList,R=e.sequenceIndexList,C=e.atomIdList,k=e.bFactorList,A=e.altLocList,E=e.occupancyList,P=e.bondAtomList,T=e.bondOrderList;for(n=0,i=e.chainsPerModel.length;i>n&&!(c&&m>0);++n){var M=e.chainsPerModel[m];for(u&&u({chainCount:M,modelIndex:m}),o=0;M>o;++o){var I=e.groupsPerChain[v];if(h){var N=D(e.chainIdList.subarray(4*v,4*v+4)),O=null;b&&(O=D(b.subarray(4*v,4*v+4))),h({groupCount:I,chainIndex:v,modelIndex:m,chainId:N,chainName:O})}for(s=0;I>s;++s){var L=e.groupList[e.groupTypeList[y]],B=L.atomNameList.length;if(f){var z=null;w&&(z=w[y]);var F=null;e.insCodeList&&(F=String.fromCharCode(S[y]));var V=null;R&&(V=R[y]),f({atomCount:B,groupIndex:y,chainIndex:v,modelIndex:m,groupId:e.groupIdList[y],groupType:e.groupTypeList[y],groupName:L.groupName,singleLetterCode:L.singleLetterCode,chemCompType:L.chemCompType,secStruct:z,insCode:F,sequenceIndex:V})}for(a=0;B>a;++a){if(d){var U=null;C&&(U=C[_]);var j=null;k&&(j=k[_]);var G=null;A&&(G=String.fromCharCode(A[_]));var H=null;E&&(H=E[_]),d({atomIndex:_,groupIndex:y,chainIndex:v,modelIndex:m,atomId:U,element:L.elementList[a],atomName:L.atomNameList[a],formalCharge:L.formalChargeList[a],xCoord:e.xCoordList[_],yCoord:e.yCoordList[_],zCoord:e.zCoordList[_],bFactor:j,altLoc:G,occupancy:H})}_+=1}if(p){var q=L.bondAtomList;for(a=0,l=L.bondOrderList.length;l>a;++a)p({atomIndex1:_-B+q[2*a],atomIndex2:_-B+q[2*a+1],bondOrder:L.bondOrderList[a]})}y+=1}v+=1}if(g=x+1,x=_-1,p&&P)for(a=0,l=P.length;l>a;a+=2){var W=P[a],Y=P[a+1];(W>=g&&x>=W||Y>=g&&x>=Y)&&p({atomIndex1:W,atomIndex2:Y,bondOrder:T?T[a/2]:null})}m+=1}},e.fetch=function(e,t,r){F(e,G,t,r)},e.fetchReduced=function(e,t,r){F(e,H,t,r)},e.version="v1.1.0dev",e.fetchUrl=G,e.fetchReducedUrl=H,e.encodeMsgpack=s,e.encodeMmtf=N,e.decodeMsgpack=O,e.decodeMmtf=B}(t)}(0,Aa);var Ea=Aa;var Pa=dr.Complex,Ta=dr.Chain,Ma=dr.Atom,Ia=dr.Element,Na=dr.Helix,Oa=dr.Sheet,La=dr.Strand,Ba=dr.Bond,Da=dr.Assembly,za=dr.Molecule,Fa=function(){function e(t){s(this,e),this._original=Array.from(t),this._original.sort(),this._sum=0;for(var r=0;r<this._original.length;++r)this._sum+=this._original[r]}return l(e,[{key:"compare",value:function(e){var t=e.length;if(t!==this._original.length)return!1;var r,n=0;for(r=0;r<t;++r)n+=e[r];if(n!==this._sum)return!1;var i=Array.from(e);for(i.sort(),r=0;r<t;++r)if(i[r]!==this._original[r])return!1;return!0}}]),e}();Fa.prototype.constructor=Fa;var Va=Ve.Type,Ua=[Va.HELIX_PI,Va.BEND,Va.HELIX_ALPHA,Va.STRAND,Va.HELIX_310,Va.BRIDGE,Va.TURN,Va.COIL],ja=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._options.fileType="mmtf",r}return l(a,[{key:"_onModel",value:function(e){}},{key:"_onChain",value:function(e){if(0===e.modelIndex){var t=new Ta(this._complex,e.chainName);this._complex._chains[e.chainIndex]=t,t._index=e.chainIndex}}},{key:"_onGroup",value:function(e){if(0===e.modelIndex&&(!this.settings.now.nowater||"HOH"!==e.groupName&&"WAT"!==e.groupName)){var t=this._complex._chains[e.chainIndex],r=e.insCode.charCodeAt(0)?e.insCode:"",n=t.addResidue(e.groupName,e.groupId,r);n._index=e.groupIndex,this._updateSecStructure(this._complex,n,e)}}},{key:"_onAtom",value:function(e){if(0===e.modelIndex){var t=e.altLoc.charCodeAt(0)?e.altLoc:"",r=new Ma(e.groupIndex,e.atomName,Ia.getByName(e.element.toUpperCase()),new i.Pq0(e.xCoord,e.yCoord,e.zCoord),Ia.Role[e.atomName],!1,e.atomId,t,e.occupancy,e.bFactor,e.formalCharge);this._complex._atoms[e.atomIndex]=r,r.index=e.atomIndex,this._serialAtomMap[e.atomId]=r}}},{key:"_onBond",value:function(e){var t=Math.max(e.atomIndex1,e.atomIndex2);if(!(t>=this._complex._atoms.length)){var r=Math.min(e.atomIndex1,e.atomIndex2);this._complex.addBond(this._complex._atoms[r],this._complex._atoms[t],e.bondOrder,Ba.BondType.UNKNOWN,!0)}}},{key:"_updateSecStructure",value:function(e,t,r){if(!(0,n.isUndefined)(r)&&r.secStruct===this._ssType)return t._secondary=this._ssStruct,void(this._ssStruct&&(this._ssStruct.term=t));if(!(0,n.isUndefined)(r)){var i=Ua[r.secStruct];this._ssType=r.secStruct,this._ssStart=t;var o=null;switch(this._ssType){case-1:case 7:break;case 0:case 2:case 4:o=new Na([3,-1,1,-1,5][this._ssType],t,t,0,"","",0),e._helices.push(o);break;case 3:var s=new Oa("",0);e._sheets.push(s),o=new La(s,t,t,0,null,null);break;default:void 0!==i&&(o=new Ve(i,t,t))}this._ssStruct=o,t._secondary=o,o&&e.structures.push(o)}}},{key:"_updateMolecules",value:function(e){var t=e.entityList;if(t)for(var r=e.chainsPerModel[0],n=0;n<t.length;n++){for(var i=t[n],o=i.chainIndexList,s=[],a=0;a<o.length;a++){var l=o[a];if(!(l>=r)){var c=this._complex._chains[l];s=s.concat(c._residues.slice())}}var u=new za(this._complex,i.description,n+1);u.residues=s,this._complex._molecules[n]=u}}},{key:"_traverse",value:function(e){var t=this,r=this._complex.metadata;r.id=e.structureId,r.title=[],r.title[0]=e.title,r.date=e.releaseDate,r.format="mmtf";var n={onModel:function(e){t._onModel(e)},onChain:function(e){t._onChain(e)},onGroup:function(e){t._onGroup(e)},onAtom:function(e){t._onAtom(e)},onBond:function(e){t._onBond(e)}};this._ssType=-1,this._ssStruct=null,this._ssStart=null,Ea.traverse(e,n),this._updateSecStructure(this._complex),this._updateMolecules(e)}},{key:"_linkAtomsToResidues",value:function(){for(var e=0;e<this._complex._atoms.length;++e){var t=this._complex._atoms[e],r=this._complex._residues[t.residue];t.residue=r,r._atoms.push(t)}}},{key:"_findSynonymousChains",value:function(){for(var e={},t=0;t<this._complex._chains.length;++t){var r=this._complex._chains[t],n=r.getName();e.hasOwnProperty(n)||(e[n]=[]),e[n].push(r._index)}return e}},{key:"_parseAssemblyInfo",value:function(e){var t,r,n,o=[],s=this.logger;for(t=0;t<e.bioAssemblyList.length;++t){var a=e.bioAssemblyList[t];if(0!==a.transformList.length){var l=a.transformList[0].chainIndexList,c=new Fa(l),u={};for(r=0;r<l.length;++r)u[this._complex._chains[l[r]].getName()]=1;var h=[],f=void 0;for(f in u)u.hasOwnProperty(f)&&Array.prototype.push.apply(h,this._chainsByName[f]);c.compare(h)||s.debug("MMTF: Assembly is missing some of the synonymous chains. Skipping...");var d=new Da(this._complex);for(f in u)u.hasOwnProperty(f)&&d.addChain(f);for(d.addMatrix((new i.kn4).fromArray(a.transformList[0].matrix).transpose()),r=1;r<a.transformList.length;++r){var p=a.transformList[r];if(c.compare(p.chainIndexList)){var m=(new i.kn4).fromArray(p.matrix).transpose();for(n=0;n<d.matrices.length&&!d.matrices[n].equals(m);++n);n===d.matrices.length&&d.addMatrix(m)}else s.debug("MMTF: Chain lists differ for different transforms in one assembly. Skipping...")}d.finalize(),o.push(d)}}return o}},{key:"_markHeteroAtoms",value:function(e){for(var t=e.chainsPerModel[0],r=0;r<e.entityList.length;++r){var n=e.entityList[r];if("polymer"!==n.type)for(var i=0;i<n.chainIndexList.length;++i){var o=n.chainIndexList[i];if(!(o>=t))for(var s=this._complex._chains[o],a=0;a<s._residues.length;++a)for(var l=s._residues[a],c=0;c<l._atoms.length;++c)l._atoms[c].het=!0}}}},{key:"_joinSynonymousChains",value:function(){var e,t,r=[],n={};for(e=0;e<this._complex._chains.length;++e){var i=this._complex._chains[e],o=i.getName();if(n.hasOwnProperty(o)){var s=n[o];for(t=0;t<i._residues.length;++t){var a=i._residues[t];s._residues.push(a),a._chain=s}}else n[o]=i,i._index=r.length,r.push(i)}this._complex._chains=r}},{key:"parseSync",value:function(){var e=Ea.decode(this._data);return this._complex=new Pa,this._serialAtomMap={},this._traverse(e),this._linkAtomsToResidues(),this._markHeteroAtoms(e),this._chainsByName=this._findSynonymousChains(),Array.prototype.push.apply(this._complex.units,this._parseAssemblyInfo(e)),this._joinSynonymousChains(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._complex}}],[{key:"canProbablyParse",value:function(e){return(0,n.isArrayBuffer)(e)&&223==(1|new Uint8Array(e,0,1)[0])}}]),a}(oa);ja.formats=["mmtf"],ja.extensions=[".mmtf"],ja.binary=!0;var Ga=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t,r){var o;return s(this,i),o=n.call(this,"data:".concat(t,":").concat(r,": ").concat(e)),Error.captureStackTrace&&Error.captureStackTrace(c(o),i),o.name="ParsingError",o.parseLine=t,o.parseColumn=r,o}return l(i)}(T(Error));function Ha(e){return 32===e||10===e||13===e||9===e}function qa(e,t,r){for(var n=t.length,i=-1;r<n&&(i=t.charCodeAt(r))!==e&&10!==i;)++r;return i===e?r:-1}function Wa(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var Ya=dr.Complex,Xa=dr.Element,$a=dr.Helix,Za=dr.Sheet,Qa=dr.Strand,Ka=dr.Assembly,Ja=dr.Molecule,el=["auth_seq_id","Cartn_x","Cartn_y","Cartn_z","label_atom_id"],tl={helx:"helix",turn:"turn",strn:"strand"};function rl(e){return null==e||(0,n.isArray)(e)?e:[e]}function nl(e){var t=4===e.trim().length;return e.slice(0,t?1:2).trim()}var il=function(e){h(r,e);var t=Wa(r);function r(e){var n;return s(this,r),(n=t.call(this)).name="AtomDataError",n.message=e,n}return l(r)}(T(Error));function ol(e,t){for(var r=(e=(0,n.isString)(e)?e:"".concat(e)).replace(/\)\s*\(/g,"!").replace(/[()']/g,"").split("!"),o=[],s=0,a=r.length;s<a;++s){for(var l=r[s].split(","),c=[],u=0,h=0,f=l.length;h<f;++h){var d=l[h];if(d.includes("-"))for(var p=d.split("-"),m=parseInt(p[0],10),v=parseInt(p[1],10);m<=v;++m)c[u++]=t[m];else c[u++]=t[d]}o.push(c)}var y=[],_=0;return function e(t,r){for(var n=0,s=o[t].length;n<s;++n){var a=r?r.clone():new i.kn4;a.multiplyMatrices(o[t][n],a),0===t?y[_++]=a:e(t-1,a)}}(o.length-1),y}var sl=function(e){h(r,e);var t=Wa(r);function r(e,n){var i;return s(this,r),(i=t.call(this,e,n)).asymDict={},i.molecules=[],i._options.fileType="cif",i}return l(r,[{key:"parseSync",value:function(){this.logger.info("Parsing CIF file..");var e=function(e){var t,r,i,o,s=0,a=0,l=e.length,c=NaN,u=!0,h=1,f=1,d=0,p={},m={},v=[],y=0,_="",g=[],x=0;function b(){var t;if((46===c||63===c)&&(s+1>=l||Ha(e.charCodeAt(s+1))))return++f,void++s;if(u&&59===c){a=s;var r=0;do{if(-1===(a=qa(10,e,a+1)))throw new Ga("Unterminated text block found",h,f);++r}while(a+1<l&&e.charCodeAt(a+1)!==c||a+1>=l);return t=e.substring(s+1,a).replace(/\r/g,""),s=a+2,h+=r,f=1,u=!1,t}if(39===c||34===c){a=s;do{if(-1===(a=qa(c,e,a+1)))throw new Ga("Unterminated quoted string found",h,f)}while(a+1<l&&!Ha(e.charCodeAt(a+1)));return t=e.substring(s+1,a),f+=a-s+1,s=a+1,t}for(a=s;a<l&&!Ha(e.charCodeAt(a));)++a;t=e.substring(s,a),f+=a-s,s=a;var n=Number(t);return Number.isNaN(n)?t:n}for(;s<=l;){if(13===(c=e.charCodeAt(s)));else if(10===c)u=!0,++h,f=1;else{if(32!==c&&9!==c){if(35===c){if(-1===(s=qa(10,e,s+1)))break;continue}if(0===d){if(68!==c&&100!==c||"ata_"!==e.substr(s+1,4).toLowerCase()){if(Number.isNaN(c))break;throw new Ga("Unexpected character in state ".concat(d),h,f)}for(t=a=s+5;a<l&&!Ha(e.charCodeAt(a));)++a;if(f+=a-s,t<(s=a)){p[e.substring(t,s)]=m={},d=1;continue}throw new Ga("Data block name missing",h,f)}if(1===d){if(68!==c&&100!==c||"ata_"!==e.substr(s+1,4).toLowerCase()){if(95===c){for(t=a=s+1;a<l&&!Ha(e.charCodeAt(a));)++a;if(f+=a-s,t<(s=a)){_=e.substring(t,s),d=2;continue}throw new Ga("Tag name missing",h,f)}if(76!==c&&108!==c||"oop_"!==e.substr(s+1,4).toLowerCase()){if(Number.isNaN(c))break;throw new Ga("Unexpected character in state ".concat(d),h,f)}if(f+=5,(s+=5)<l&&!Ha(e.charCodeAt(s)))throw new Ga("Unexpected character in state ".concat(d),h,f);v=[],y=0,g=[],x=0,d=3;continue}d=0;continue}if(2===d){if(Number.isNaN(c))break;r=b(),(0,n.set)(m,_,r),d=1;continue}if(3===d){if(95===c){for(t=a=s+1;a<l&&!Ha(e.charCodeAt(a));)++a;if(f+=a-s,t<(s=a)){o=e.substring(t,s),v[y++]=o;continue}throw new Ga("Tag name missing",h,f)}if(y>0){for(var w=0;w<y;++w)r=[],g[w]=r,(0,n.set)(m,v[w],r);d=4;continue}throw new Ga("Data tags are missing inside a loop",h,f)}if(4===d){68!==c&&100!==c||"ata_"!==e.substr(s+1,4).toLowerCase()?95===c?d=1:76!==c&&108!==c||"oop_"!==e.substr(s+1,4).toLowerCase()?Number.isNaN(c)?d=0:(i=b(),g[x%y].push(i),++x):d=1:d=0;continue}throw new Ga("Unexpected internal state ".concat(d),h,f)}u=!1,++f}++s}if(2===d)throw new Ga("Unexpected end of file in state ".concat(d),h,f);return p}(this._data);return this._toComplex(e)}},{key:"_toComplex",value:function(e){var t=new Ya,r=e[Object.keys(e)[0]];return this._extractAtoms(t,r),this._extractSecondary(t,r),this._extractAssemblies(t,r),this._extractMolecules(t,r),this._extractMetadata(t,r),t.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing}),t}},{key:"_extractMetadata",value:function(e,t){var r=e.metadata;r.id=t.entry.id,r.classification=t.struct_keywords.pdbx_keywords;var n=t.database_PDB_rev;r.date=n&&n.date_original?n.date_original:"",r.format="cif",r.title=[],r.title[0]=t.struct.title}},{key:"_extractMolecules",value:function(e,t){var r,n=rl(t.entity.pdbx_description),i=n.length;for(r=0;r<i;r++)this.molecules[r]?this.molecules[r].name=n[r]:this.molecules[r]={name:n[r],residues:[]};var o=e.getMolecules();for(r=0;r<i;r++){var s=this.molecules[r];o[r]=new Ja(e,s.name,r+1),o[r].residues=s.residues}}},{key:"_extractAtoms",value:function(e,t){var r=t.atom_site;if(!r)throw new il("CIF parsing error: atom_site is not specified!");for(var n=0,o=el.length;n<o;++n)if(!r[el[n]])throw new il("CIF parsing error: requires field ".concat(el[n]," not found!"));for(var s=this.asymDict,a=rl(r.auth_seq_id),l=rl(r.Cartn_x),c=rl(r.Cartn_y),u=rl(r.Cartn_z),h=rl(r.label_atom_id),f=h.length,d=rl(r.group_PDB)||[],p=rl(r.auth_asym_id)||[],m=rl(r.label_asym_id)||[],v=rl(r.id)||[],y=rl(r.pdbx_PDB_ins_code)||[],_=rl(r.label_comp_id)||[],g=rl(r.type_symbol)||[],x=rl(r.B_iso_or_equiv)||[],b=rl(r.occupancy)||[],w=rl(r.pdbx_formal_charge)||[],S=rl(r.label_alt_id)||[],R=rl(r.pdbx_PDB_model_num)||[],C=rl(r.label_entity_id)||[],k=null,A=null,E=0;E<f;++E)if(1===(R[E]||1)){var P=String(p[E]||" ");k&&k.getName()===P||(k=e.getChain(P)||e.addChain(P)),s[String(m[E]||" ")]=P;var T=a[E],M=String(y[E]||" "),I=String(_[E]||"");if(!A||A.getSequence()!==T||A.getICode()!==M){A=k.addResidue(I,T,M);var N=C[E]-1,O=this.molecules[N];O||(this.molecules[N]={name:"",residues:[]},O=this.molecules[N]),O.residues.push(A)}var L=h[E],B=g[E]||nl(L),D=Xa.getByName(B),z=Xa.Role[L.trim()],F=new i.Pq0(l[E],c[E],u[E]),V="HETATM"===d[E]||!1,U=v[E]||E,j=x[E]||0,G=b[E]||0,H=String(S[E]||""),q=w[E]||0;A.addAtom(L,D,F,z,V,U,H,G,j,q)}}},{key:"_extractSecondary",value:function(e,t){t.struct_conf&&this._extractConfs(e,t.struct_conf),t.struct_sheet_range&&this._extractSheets(e,t.struct_sheet_range)}},{key:"_extractSheets",value:function(e,t){var r=this.asymDict;if(t.sheet_id&&t.id&&t.beg_label_seq_id&&t.end_label_seq_id&&t.beg_label_asym_id)for(var n=e._sheets,i=rl(t.sheet_id),o=rl(t.id),s=rl(t.beg_auth_seq_id),a=rl(t.end_auth_seq_id),l=rl(t.beg_label_asym_id),c=rl(t.pdbx_beg_PDB_ins_code)||[],u=rl(t.pdbx_end_PDB_ins_code)||[],h=0,f=o.length;h<f;++h){var d=e.getChain(r[l[h]]),p=R(i[h]),m=s[h],v=a[h],y=c[h]||" ",_=u[h]||" ",g=d.findResidue(m,y),x=d.findResidue(v,_);if(g&&x){for(var b=new Qa(p,g[0],x[0],0,null,null),w=d.getResidues(),S=g[1];S<=x[1];++S)w[S]._secondary=b;p.addStrand(b),e.structures.push(b)}}function R(e){for(var t=n.length,r=0;r<t;++r)if(n[r]._name===e)return n[r];return n[t]=new Za(e,0),n[t]}}},{key:"_extractConfs",value:function(e,t){var r=this.asymDict;if(t.conf_type_id&&t.beg_label_seq_id&&t.end_label_seq_id&&t.beg_label_asym_id)for(var n,i,o=rl(t.conf_type_id),s=rl(t.beg_auth_seq_id),a=rl(t.pdbx_beg_PDB_ins_code)||[],l=rl(t.end_auth_seq_id),c=rl(t.pdbx_end_PDB_ins_code)||[],u=rl(t.details)||[],h=rl(t.pdbx_PDB_helix_length)||[],f=rl(t.pdbx_PDB_helix_class)||[],d=rl(t.id)||[],p=rl(t.beg_label_asym_id),m=0,v=o.length;m<v;++m){var y=(n=o[m],i=void 0,(i=/[A-Za-z]+/.exec(n))?tl[i[0].toLowerCase()]:null);if(y){var _=d[m]||o[m],g=e.getChain(r[p[m]]),x=s[m],b=l[m],w=a[m]||" ",S=c[m]||" ",R=g.findResidue(x,w),C=g.findResidue(b,S);if(R&&C){var k=u[m]||"",A=h[m]||0,E=f[m]||" ",P=void 0;if("helix"===y){var T=e._helices.length;P=new $a(E,R[0],C[0],T,_,k,A),e.addHelix(P),e.structures.push(P)}else"turn"===y?(P=new Ve(Ve.Type.TURN,R[0],C[0]),e.structures.push(P)):P=null;if(P)for(var M=g.getResidues(),I=R[1];I<=C[1];++I)M[I]._secondary=P}}}}},{key:"_extractAssemblies",value:function(e,t){var r=this.asymDict,n=t.pdbx_struct_assembly_gen;if(n){var o=rl(n.assembly_id),s=rl(n.oper_expression),a=rl(n.asym_id_list);if(o&&s&&a){var l=function(e){if(!e)return null;var t=rl(e.id),r=e.matrix,n=e.vector;if(!t||!r||!n)return null;for(var o=[],s=0,a=t.length;s<a;++s){for(var l=new i.kn4,c=l.elements,u=0;u<3;++u){var h=r[u+1];c[u]=rl(h[1])[s],c[u+4]=rl(h[2])[s],c[u+8]=rl(h[3])[s],c[u+12]=rl(n[u+1])[s]}o[t[s]]=l}return o}(t.pdbx_struct_oper_list);if(l)for(var c=0,u=o.length;c<u;++c){for(var h=new Ka(e),f=ol(s[c],l),d=a[c].split(","),p=0,m=d.length;p<m;++p){var v=d[p].trim();v.length>0&&h.addChain(r[v])}h.matrices=f,e.units.push(h)}}}}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&/^\s*data_/i.test(e)}}]),r}(oa);sl.formats=["cif","mmcif"],sl.extensions=[".cif",".mmcif"];var al=function(){function e(){s(this,e),Se(this,"_xyz2crs",[]),Se(this,"_origin",new i.Pq0(0,0,0)),this._header={},this._boxSize=new i.Pq0,this._boxStart=new i.Pq0,this._header.delta={},this._header.extent=[],this._header.nstart=[],this._header.grid=[],this._header.crs2xyz=[],this._header.cellDims=new i.Pq0,this._header.angles=[],this._header.origin=new i.Pq0(0,0,0),this._header.dmin=0,this._header.dmean=0,this._header.dmax=0}return l(e,[{key:"_typedCheck",value:function(){if((0,n.isTypedArray)(this._buff))this._buff=this._buff.buffer;else if(!(0,n.isArrayBuffer)(this._buff))throw new TypeError("Expected ArrayBuffer or TypedArray")}},{key:"_fillHeader",value:function(e,t){for(var r in e)if(e.hasOwnProperty(r))switch(e[r][0]){case 0:this._header[r]=t[e[r][1]][e[r][2]];break;case 2:this._parseArray(this._header[r],t[e[r][1]],e[r][2]);break;case 1:this._parseVector(this._header[r],t[e[r][1]],e[r][2]);break;case 3:this._header[r]=new Uint8Array(t[e[r][1]],4*[e[r][2]],4*[e[r][3]])}}},{key:"_parseVector",value:function(e,t,r){var n=[t[r],t[r+1],t[r+2]];e.x=n[0],e.y=n[1],e.z=n[2]}},{key:"_parseArray",value:function(e,t,r){e[0]=t[r],e[1]=t[r+1],e[2]=t[r+2]}},{key:"_parseHeader",value:function(e){}},{key:"_setAxisIndices",value:function(){}},{key:"_setOrigins",value:function(){}},{key:"_getAxis",value:function(){var e=this._header,t=e.cellDims.x/e.grid[0],r=e.cellDims.y/e.grid[1],n=e.cellDims.z/e.grid[2],o=v(e.angles,3),s=o[0],a=o[1],l=o[2],c=Math.cos(a),u=(Math.cos(s)-Math.cos(a)*Math.cos(l))/Math.sin(l),h=Math.sqrt(1-c*c-u*u);return[new i.Pq0(t,0,0),new i.Pq0(Math.cos(l)*r,Math.sin(l)*r,0),new i.Pq0(c*n,u*n,h*n)]}},{key:"_getXYZdim",value:function(){return[this._header.extent[this._xyz2crs[0]],this._header.extent[this._xyz2crs[1]],this._header.extent[this._xyz2crs[2]]]}},{key:"_getVolumeInfo",value:function(){var e=(0,n.pick)(this._header,["dmean","dmin","dmax","sd","delta"]);return e.obtuseAngle=this._header.angles.map((function(e){return Number(e>=Math.PI/2)})),e}},{key:"_setBoxParams",value:function(e,t,r){var n=this,o=0,s=0,a=v(this._header.angles,3),l=a[0],c=a[1];a[2]>=Math.PI/2&&(o+=Math.abs(t.x)),c>=Math.PI/2&&(o+=Math.abs(r.x)),l>=Math.PI/2&&(s+=Math.abs(r.y)),this._boxStart=new i.Pq0(this._origin.x-o,this._origin.y-s,this._origin.z),this._boxSize=new i.Pq0(Math.abs(e.x)+Math.abs(t.x)+Math.abs(r.x),Math.abs(t.y)+Math.abs(r.y),Math.abs(r.z));var u=function(e,t){return Math.abs(e[t])/n._boxSize[t]};this._header.delta.x=u(t,"x"),this._header.delta.y=u(r,"x"),this._header.delta.z=u(r,"y")}},{key:"_getXYZbox",value:function(){return new i.NRn(this._boxStart.clone(),this._boxStart.clone().add(this._boxSize))}},{key:"_toXYZData",value:function(){}},{key:"parse",value:function(e){return this._parseHeader(e),this._setOrigins(),new hr(Float32Array,this._getXYZdim(),this._getXYZbox(),1,this._toXYZData(),this._getVolumeInfo())}}]),e}();function ll(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}var cl={extent:[2,"u32",0],type:[0,"u32",3],nstart:[2,"i32",4],grid:[2,"u32",7],cellDims:[1,"f32",10],angles:[2,"f32",13],crs2xyz:[2,"i32",16],dmin:[0,"f32",19],dmax:[0,"f32",20],dmean:[0,"f32",21],ispg:[0,"u32",22],nsymbt:[0,"u32",23],lksflg:[0,"u32",24],customData:[3,"buffer",25,9],origin:[1,"f32",34],map:[3,"buffer",52,1],machine:[0,"u32",53],sd:[0,"f32",54],nlabel:[0,"f32",55],label:[3,"buffer",56,200]},ul=function(e){h(r,e);var t=ll(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"_parseHeader",value:function(e){this._buff=e,this._typedCheck();var t={};t.u32=new Uint32Array(this._buff,0,56),t.i32=new Int32Array(this._buff,0,56),t.f32=new Float32Array(this._buff,0,56),t.buffer=this._buff;var r=this._header;this._fillHeader(cl,t),r.angles.forEach((function(e,t,r){r[t]*=Math.PI/180}))}},{key:"_setAxisIndices",value:function(){var e=this._header;0===e.cellDims.x&&0===e.cellDims.y&&0===e.cellDims.z&&e.cellDims.set(1,1,1);var t=this._header.crs2xyz;0===t[0]&&0===t[1]&&0===t[2]&&(t[0]=1,t[1]=2,t[2]=3);var r=this._xyz2crs;r[t[0]-1]=0,r[t[1]-1]=1,r[t[2]-1]=2}},{key:"_setOrigins",value:function(){var e=v(this._getAxis(),3),t=e[0],r=e[1],n=e[2];this._setAxisIndices();var i=this._header,o=this._xyz2crs;if(0===i.origin.x&&0===i.origin.y&&0===i.origin.z?(this._origin.addScaledVector(t,i.nstart[o[0]]),this._origin.addScaledVector(r,i.nstart[o[1]]),this._origin.addScaledVector(n,i.nstart[o[2]])):this._origin=i.origin,t.multiplyScalar(i.extent[o[0]]-1),r.multiplyScalar(i.extent[o[1]]-1),n.multiplyScalar(i.extent[o[2]]-1),2!==i.type)throw new Error("CCP4: Unsupported format ".concat(i.type));this._data=new Float32Array(this._buff,1024+i.nsymbt,i.extent[0]*i.extent[1]*i.extent[2]),this._setBoxParams(t,r,n)}},{key:"_toXYZData",value:function(){var e=this._header,t=this._data,r=this._xyz2crs,n=new Float32Array(t.length),i=this._getXYZdim(),o=i[0],s=i[1],a=0,l=[];for(l[2]=0;l[2]<e.extent[2];l[2]++)for(l[1]=0;l[1]<e.extent[1];l[1]++)for(l[0]=0;l[0]<e.extent[0];l[0]++,a++)n[l[r[0]]+o*(l[r[1]]+s*l[r[2]])]=t[a];return n}}]),r}(al),hl=function(e){h(r,e);var t=ll(r);function r(e,n){var i;return s(this,r),(i=t.call(this,e,n))._options.fileType="ccp4",i.model=new ul,i}return l(r,[{key:"parseSync",value:function(){return this.model.parse(this._data)}}],[{key:"canProbablyParse",value:function(e){return!1}}]),r}(oa);hl.formats=["ccp4"],hl.extensions=[".ccp4",".map",".mrc"],hl.binary=!0;var fl=dr.Complex,dl=dr.Element,pl=dr.Molecule,ml=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._complex=null,r._atomsInf=null,r._options.fileType="xyz",r._fileName=t.name,r}return l(a,[{key:"_parseToAtomsInf",value:function(e){var t=e.indexOf("\n"),r=parseInt(e.substring(0,t),10),n=e.indexOf("\n",t+1),i=e.slice(t+1,n).trim();0===i.length&&(i=this._fileName);var o=n+e.substring(n).search(/\S/);this._atomsInf=e.substring(o).split(/[\s,]*\n[\s,]*/),Number.isNaN(r)||this._atomsInf.length-1===r?(this._complex.metadata.format="xyz",this._complex.name=i):this._complex.error={message:"wrong number of atoms"}}},{key:"_parseAtomsInf",value:function(){for(var e=this._complex.addChain("A").addResidue("UNK",1," "),t=0;t<this._atomsInf.length-1;t++){var r=this._atomsInf[t].split(/[\s,]+/);if(4!==r.length){this._complex.error={message:"missed parameters"};break}var n=t+1,o=r[0],s=new i.Pq0(parseFloat(r[1]),parseFloat(r[2]),parseFloat(r[3])),a=dl.getByName(o);e.addAtom(o,a,s,void 0,!0,n," ",1,1,0)}var l=new pl(this._complex,this._complex.name,1);l.residues=e,this._complex._molecules[0]=l}},{key:"parseSync",value:function(){var e=this._complex=new fl;if(this._parseToAtomsInf(this._data),this._parseAtomsInf(),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap}),this._complex=null,this._atomsInf=null,e.error)throw new Error(e.error.message);return e}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&/^\s*\d+ *\n[^\n]*\n\s*\w{1,3}\s+-?\d/.test(e)}}]),a}(oa);Se(ml,"formats",["xyz"]),Se(ml,"extensions",[".xyz"]);var vl=dr.Complex,yl=dr.Element,_l=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._options.fileType="pubchem+json",r}return l(a,[{key:"parseSync",value:function(){return this.logger.info("Parsing PubChem JSON file..."),this._toComplex(JSON.parse(this._data))}},{key:"_toComplex",value:function(e){var t=new vl,r=e.PC_Compounds&&e.PC_Compounds[0];return r&&(this._extractAtoms(t,r),t.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing})),t}},{key:"_extractAtoms",value:function(e,t){var r=t.atoms&&t.atoms.aid,o=r&&t.atoms.element;if(!o||r.length!==o.length)throw new Error("Unable to parse atom elements");o=(0,n.fromPairs)((0,n.zip)(r,o));var s={},a=t.coords&&t.coords[0],l=a&&a.conformers&&a.conformers[0],c=l&&l.x,u=l&&l.y,h=l&&l.z||[];if(!(r=a&&a.aid)||!c||!u)throw new Error("Coordinates are not found in the file");for(var f=e.addChain(" ").addResidue("UNK",1," "),d=0,p=r.length;d<p;++d){var m=r[d],v=yl.ByAtomicNumber[o[m]],y=new i.Pq0(c[d],u[d],h[d]||0);s[m]=f.addAtom(v.name,v,y,void 0,!0,m," ",1,0,0)}var _=t.bonds&&t.bonds.aid1,g=t.bonds&&t.bonds.aid2,x=t.bonds&&t.bonds.order||[];if(_&&g&&_.length===g.length)for(var b=0,w=_.length;b<w;++b)e.addBond(s[_[b]],s[g[b]],x[b]||1,0,!0)}}],[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&"{"===e[0]}}]),a}(oa);_l.formats=["pubchem","pubchem+json","pc"],_l.extensions=[".json"];var gl=function(){function e(t){s(this,e),this._strings=t.split(/\r?\n|\r/),this._currentStart=0,this._currentStringIndx=0}return l(e,[{key:"setStart",value:function(e){e>=this._strings.length?(this._currentStart=this._strings.length-1,this._currentStringIndx=this._strings.length-1):(this._currentStart=e,this._currentStringIndx=e)}},{key:"getNextString",value:function(){return this._strings[++this._currentStringIndx]}},{key:"getCurrentString",value:function(){return this._strings[this._currentStringIndx]}},{key:"getStringFromStart",value:function(e){return this._currentStringIndx=this._currentStart+e,this._strings[this._currentStart+e]}},{key:"findNextDataItem",value:function(){for(var e=this.getNextString(),t=!1;!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();){if(e.match(/>\s+<(.*)>/)){t=!0;break}e=this.getNextString()}return t}},{key:"findNextCompoundStart",value:function(){for(var e=this.getCurrentString();!(0,n.isUndefined)(e)&&"$$$$"!==e.trim();)e=this.getNextString();return this.setStart(++this._currentStringIndx),this.probablyHaveDataToParse()}},{key:"probablyHaveDataToParse",value:function(){return this._currentStringIndx<this._strings.length-2}}]),e}();var xl=dr.Complex,bl=dr.Element,wl=dr.Bond,Sl=dr.Molecule,Rl=[0,3,2,1,0,-1,-2,-3],Cl=[0,1,2,3,1,1,1,2],kl=[wl.BondType.UNKNOWN,wl.BondType.COVALENT,wl.BondType.COVALENT,wl.BondType.COVALENT,wl.BondType.AROMATIC,wl.BondType.UNKNOWN,wl.BondType.AROMATIC,wl.BondType.AROMATIC],Al=/.*(M\s\sEND).*|.*(^$$$$).*|.*>\s+<(.+)>.*/,El=/.*($$$$).*|.*>\s+<(.+)>.*/,Pl=["name","id","title"],Tl={name:["PUBCHEM_IUPAC_TRADITIONAL_NAME",/PUBCHEM_(.+)_NAME/,/(.+)name/,/(.+)NAME/],id:["PUBCHEM_COMPOUND_CID","id","ID",/.*CID/,/.*ID/,/.*id/],title:["msg","MSG","message","title","description","desc"]},Ml=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._format="sdf",r._complex=null,r._chain=null,r._residue=null,r._molecules=null,r._metadata={},r._metadata.molecules=[],r._currentMolProps={},r._compoundIndx=-1,r._assemblies=[],r._atomsParsed=0,r._atomsIndexes=[],r}return l(a,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(e)&&Al.test(e)}},{key:"_parseHeader",value:function(e){var t={};t.name=e.getStringFromStart(0);var r=parseInt(e.getStringFromStart(1).substr(10,6).trim(),10);t.date=r.toString()||"",t.title=e.getStringFromStart(2),this._metadata.molecules.push(t)}},{key:"_parseAtoms",value:function(e,t){var r,n=this._atomsParsed,o=function(e){if(!e)return"A";for(var t=[];e;)t.push(65+e%26),e=Math.trunc(e/26);return t.length>1&&(t.reverse(),t[0]-=1),String.fromCharCode.apply(String,t)}(this._compoundIndx);this._chain=this._complex.getChain(o)||this._complex.addChain(o),this._residue=this._chain.addResidue("UNK",1," ");for(var s=0;s<t;s++){r=e.getNextString(),n++;var a=parseFloat(r.substr(0,10)),l=parseFloat(r.substr(10,10)),c=parseFloat(r.substr(20,10)),u=Rl[parseInt(r.substr(36,3),10)],h=new i.Pq0(a,l,c),f=r.substr(31,3).trim().toUpperCase(),d=bl.getByName(f);this._atomsIndexes[f]||(this._atomsIndexes[f]=0),this._atomsIndexes[f]+=1,f+=this._atomsIndexes[f],this._residue.addAtom(f,d,h,void 0,!0,n," ",1,0,u)}}},{key:"_parseBonds",value:function(e,t){for(var r,n=0;n<t;n++){r=e.getNextString();var i=parseInt(r.substr(0,3),10)+this._atomsParsed,o=parseInt(r.substr(3,3),10)+this._atomsParsed,s=parseInt(r.substr(6,3),10);if(i>o){var a=[o,i];i=a[0],o=a[1]}this._complex.addBond(i,o,Cl[s]||1,kl[s]||wl.BondType.UNKNOWN,!0)}}},{key:"_parseMOL",value:function(e){this._compoundIndx++,this._parseHeader(e);var t=e.getStringFromStart(3),r=parseInt(t.substr(0,3),10),n=parseInt(t.substr(3,3),10);this._parseAtoms(e,r),this._parseBonds(e,n),this._atomsParsed+=r,this._metadata.molecules[this._compoundIndx]._residues=[],this._metadata.molecules[this._compoundIndx]._residues.push(this._residue)}},{key:"_parseDataItem",value:function(e){for(var t=e.getCurrentString(),r=[],n=e.getNextString();""!==n.trim();)r.push(n),n=e.getNextString();1===r.length&&(r=v(r,1)[0]),this._currentMolProps[t.replace(/[<>]/g,"").trim()]=r}},{key:"_parseCompound",value:function(e){if(this._parseMOL(e),"sdf"===this._format){for(this._currentMolProps={};e.findNextDataItem();)this._parseDataItem(e);if(0!==Object.keys(this._currentMolProps).length){var t=this._metadata.molecules[this._compoundIndx];t.props=this._currentMolProps,this._tryToUpdateMoleculeData(t)}}}},{key:"_fixBondsArray",value:function(){for(var e=this._serialAtomMap,t=this._complex._bonds,r=0;r<t.length;r++){var n=t[r];n._right<n._left&&console.log("_fixBondsArray: Logic error."),n._left=e[n._left]||null,n._right=e[n._right]||null}}},{key:"_buildAssemblies",value:function(){var e=this._complex._chains;if(1===e.length)return this._assemblies;for(var t=0;t<e.length;t++){var r=new Rt(this._complex),n=new i.kn4;r.addMatrix(n),r.addChain(e[t]._name),this._assemblies.push(r)}return this._assemblies}},{key:"_buildMolecules",value:function(){this._complex._molecules=[];for(var e=this._metadata.molecules,t=0;t<e.length;t++){var r=new Sl(this._complex,e[t].name,t+1);r.residues=e[t]._residues,this._complex._molecules[t]=r}return this._complex._molecules}},{key:"_searchTag",value:function(e,t){for(var r=0;r<t.length;r++)if(e instanceof RegExp&&e.test(t[r].tag)||e===t[r].tag)return t[r].data}},{key:"_tryToFind",value:function(e,t){for(var r=0;r<e.length;r++){var n=this._searchTag(e[r],t);if(n)return n}}},{key:"_tryToUpdateMoleculeData",value:function(e){for(var t=!1,r=0;r<Pl.length;r++){var n=Tl[Pl[r]],i=this._tryToFind(n,e.props);i&&(e[Pl[r]]=i,t=!0)}return e.name=e.name||e.id,e.name.match(/^\d+$/)&&(e.name="CID: ".concat(e.name)),t}},{key:"_finalizeMetadata",value:function(){var e=this._metadata.molecules,t=this._complex.metadata,r=this._complex;if(1===e.length)r.name=e[0].name,t.title=e[0].title,t.date=e[0].date,t.properties=e[0].props;else if(e.length>1){t.molecules=[];for(var n=0;n<e.length;n++)t.molecules.push({name:e[n].name,date:e[n].date,title:e[n].title,properties:e[n].props})}}},{key:"_finalize",value:function(){for(var e=this._serialAtomMap={},t=this._complex._atoms,r=0;r<t.length;r++){var n=t[r];e[n.serial]=n}this._complex._finalizeBonds(),this._fixBondsArray(),this._finalizeMetadata(),this._buildAssemblies(),this._complex.units=this._complex.units.concat(this._assemblies),this._buildMolecules(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:!1,enableEditing:!1,serialAtomMap:this._serialAtomMap})}},{key:"defineFormat",value:function(e){return El.test(e)?"sdf":"mol"}},{key:"parseSync",value:function(){var e=this._complex=new xl,t=new gl(this._data);this._format=this.defineFormat(this._data),e.metadata.format=this._format;do{this._parseCompound(t)}while(t.findNextCompoundStart());return this._finalize(),e}}]),a}(oa);function Il(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return f(this,r)}}Ml.formats=["mol","sdf"],Ml.extensions=[".mol",".sdf"];var Nl={nstart:[2,"i16",0],extent:[2,"i16",3],grid:[2,"i16",6],cellDims:[1,"i16",9],angles:[2,"i16",12],div:[0,"i16",15],adder:[0,"i16",16],scaleFactor:[0,"i16",17]},Ol=function(e){h(r,e);var t=Il(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"_parseHeader",value:function(e){this._buff=e,this._typedCheck();var t={};if(t.i16=new Int16Array(this._buff),100!==t.i16[18])for(var r=0,n=t.i16.length;r<n;++r){var i=t.i16[r];t.i16[r]=(255&i)<<8|i>>8&255}if(100!==t.i16[18])throw new Error("DSN6: Incorrect format ");var o=this._header;this._fillHeader(Nl,t),o.cellDims.multiplyScalar(1/o.scaleFactor),o.angles.forEach((function(e,t,r){r[t]*=Math.PI/180/o.scaleFactor})),o.div/=100}},{key:"_setAxisIndices",value:function(){this._xyz2crs[0]=0,this._xyz2crs[1]=1,this._xyz2crs[2]=2}},{key:"_setOrigins",value:function(){var e=this._header,t=v(this._getAxis(),3),r=t[0],n=t[1],i=t[2];this._setAxisIndices(),this._origin.addScaledVector(r,e.nstart[0]),this._origin.addScaledVector(n,e.nstart[1]),this._origin.addScaledVector(i,e.nstart[2]),r.multiplyScalar(e.extent[0]),n.multiplyScalar(e.extent[1]),i.multiplyScalar(e.extent[2]),this._setBoxParams(r,n,i)}},{key:"_pointCalculate",value:function(e,t,r,n,i,o,s){var a=this._header;return i<a.extent[0]&&n<a.extent[1]&&r<a.extent[2]?(e[i+a.extent[0]*(n+a.extent[1]*r)]=(t[o.counter]-a.adder)/a.div,++o.counter,!0):(o.counter+=8-s,!1)}},{key:"_blockCalculate",value:function(e,t,r,n,i,o){for(var s=0;s<8;++s)for(var a=8*r+s,l=0;l<8;++l)for(var c=8*n+l,u=!0,h=0;u&&h<8;){var f=8*i+h;u=this._pointCalculate(e,t,a,c,f,o,h),h++}}},{key:"_toXYZData",value:function(){for(var e=this._header,t=new Uint8Array(this._buff),r=new Float32Array(e.extent[0]*e.extent[1]*e.extent[2]),n=new i.Pq0(e.extent[0]/8,e.extent[1]/8,e.extent[2]/8),o={counter:512},s=0;s<n.z;++s)for(var a=0;a<n.y;++a)for(var l=0;l<n.x;++l)this._blockCalculate(r,t,s,a,l,o);return this._calculateInfoParams(r),r}},{key:"_calculateInfoParams",value:function(e){this._header.dmean/=e.length;for(var t=0,r=e[0],n=e[0],i=0;i<e.length;i++)t+=Math.pow(this._header.dmean-e[i],2),e[i]<r&&(r=e[i]),e[i]>n&&(n=e[i]);this._header.sd=Math.sqrt(t/e.length),this._header.dmax=n,this._header.dmin=r}}]),r}(al),Ll=function(e){h(r,e);var t=Il(r);function r(e,n){var i;return s(this,r),(i=t.call(this,e,n))._options.fileType="dsn6",i.model=new Ol,i}return l(r,[{key:"parseSync",value:function(){return this.model.parse(this._data)}}],[{key:"canParse",value:function(e,t){return!!e&&e instanceof ArrayBuffer&&oa.checkDataTypeOptions(t,"dsn6")}},{key:"canProbablyParse",value:function(e){return!1}}]),r}(oa);Ll.formats=["dsn6"],Ll.extensions=[".dsn6",".omap"],Ll.binary=!0;var Bl=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e){var t;return s(this,i),(t=n.call(this,e))._next=-1,t.next(),t}return l(i,[{key:"getNext",value:function(){return this._next}}]),i}(ca);var Dl=dr.Complex,zl=dr.Element,Fl=dr.Molecule,Vl=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e,t){var r;return s(this,a),(r=o.call(this,e,t))._time=null,r._numAtoms=null,r._residueNumber=null,r._residueName="",r._atomName="",r._atomNumber=null,r._atomPosition=[],r._atomVelocity=[],r._complex=null,r._molecules=[],r._molecule=null,r._options.filetype="gro",r}return l(a,[{key:"canProbablyParse",value:function(e){return(0,n.isString)(this._data)&&/^\s*[^\n]*\n\s*\d+ *\n\s*\d+[^\n\d]{3}\s*\w+\s*\d+\s*-?\d/.test(e)}},{key:"_parseTitle",value:function(e){var t=this._complex.metadata;t.id=e.readLine().trim(),t.name=t.id.slice(t.id.lastIndexOf("\\")+1,t.id.lastIndexOf(".")),t.format="gro"}},{key:"_parseNumberOfAtoms",value:function(e){if(this._numAtoms=e.readInt(0,e.getNext()),Number.isNaN(this._numAtoms))throw new Error("Line 2 is not representing atom number. Consider checking input file")}},{key:"_parseAtom",value:function(e){this._residueNumber=e.readInt(1,5),this._residueName=e.readString(6,10).trim(),this._atomName=e.readString(11,15).trim(),this._atomNumber=e.readInt(16,20);var t=10*e.readFloat(21,28),r=10*e.readFloat(29,36),n=10*e.readFloat(37,45);if(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(n))this._complex.error={message:'Atom position is invalid in "'.concat(e.readLine(),'"')};else{var o=zl.getByName(this._atomName[0]);if("Unknown"!==o.fullName){var s=zl.Role[this._atomName],a=this._chain;a||(this._chain=a=this._complex.addChain("A"));var l=this._residue;l&&l.getSequence()===this._residueNumber||(this._residue=l=a.addResidue(this._residueName,this._residueNumber," ")),this._atomPosition=new i.Pq0(t,r,n),l.addAtom(this._atomName,o,this._atomPosition,s,!0,this._atomNumber," ",1,1,0)}else this._complex.error={message:"".concat(this._atomName[0]," hasn't been recognised as an atom name.")}}}},{key:"_finalize",value:function(){var e=new Fl(this._complex,this._complex.metadata.name,1);e.residues=this._chain._residues,e._chains=this._chain,this._complex._molecules[0]=e,this._molecules.push(e),this._complex.finalize({needAutoBonding:!0,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"parseSync",value:function(){var e=this._complex=new Dl,t=new Bl(this._data),r=0;for(this._parseTitle(t),t.next(),this._parseNumberOfAtoms(t),t.next(),r=0;r<this._numAtoms&&!t.end();++r)this._parseAtom(t),t.next();if(r<this._numAtoms&&(this._complex.error={message:"File ended unexpectedly."}),e.error)throw new Error(e.error.message);return this._finalize(),this._atomPosition=null,this._complex=null,this._molecules=null,this._molecule=null,e}}]),a}(oa);Vl.formats=["gro"],Vl.extensions=[".gro"];var Ul=dr.Complex,jl=dr.Element,Gl=dr.Bond,Hl=dr.Molecule,ql={un:0,1:1,2:2,3:3,ar:1,am:1,nc:0,du:1},Wl={un:Gl.BondType.UNKNOWN,1:Gl.BondType.COVALENT,2:Gl.BondType.COVALENT,3:Gl.BondType.COVALENT,ar:Gl.BondType.AROMATIC,am:Gl.BondType.COVALENT,nc:Gl.BondType.UNKNOWN,du:Gl.BondType.COVALENT},Yl=/\d+$/,Xl=/\s+/;function $l(e){return e.trim().split(Xl)}var Zl=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return s(this,o),(r=n.call(this,e,t))._complex=null,r._chain=null,r._residue=null,r._compoundIndx=-1,r._molecules=[],r._molecule=null,r._currPosIdx=0,r._currStartIdx=0,r._serialAtomMap={},r._options.fileType="mol2",r}return l(o,[{key:"_parseRawStrings",value:function(e){return e.split(/\r?\n|\r/)}},{key:"_toStringFromStart",value:function(e,t){var r=this._currStartIdx+e;this._currPosIdx=r<t.length?r:this._currStartIdx}},{key:"_toHeaderString",value:function(e,t){for(this._toStringFromStart(0,t);this._currPosIdx<t.length;){if(t[this._currPosIdx].match("@<TRIPOS>".concat(e)))return;this._currPosIdx++}this._toStringFromStart(0,t)}},{key:"_toStringFromHeader",value:function(e,t,r){this._toHeaderString(e,r);var n=this._currPosIdx+t;r[this._currPosIdx].match("@<TRIPOS>".concat(e))&&n<r.length&&(this._currPosIdx=n)}},{key:"_setStart",value:function(e,t){e>=t.length?this._currStartIdx=this._currPosIdx=t.length-1:this._currStartIdx=this._currPosIdx=e}},{key:"_probablyHaveDataToParse",value:function(e){return this._currPosIdx<e.length-2}},{key:"_findNextCompoundStart",value:function(e){for(;this._currPosIdx<e.length&&"@<TRIPOS>MOLECULE>"!==e[this._currPosIdx].trim();)this._currPosIdx++;return this._setStart(++this._currPosIdx,e),this._probablyHaveDataToParse(e)}},{key:"_parseMolecule",value:function(e){this._toHeaderString("MOLECULE",e);var t=this._complex.metadata;t.name=e[++this._currPosIdx],t.format="mol2",this._molecule={_index:"",_chains:[]},this._molecule._index=this._compoundIndx+1,this._molecules.push(this._molecule)}},{key:"_parseAtoms",value:function(e,t){this._toHeaderString("ATOM",t);for(var r=0;r<e;r++){var n=$l(t[++this._currPosIdx]);if(n.length<6)throw new Error("MOL2 parsing error: Not enough information to create atom!");var o=parseInt(n[0],10),s=n[1],a=parseFloat(n[2]),l=parseFloat(n[3]),c=parseFloat(n[4]),u=n[5].split(".")[0].toUpperCase(),h=0;n.length>=9&&(h=parseFloat(n[8])||0);var f=this._chain;if(f||(this._chain=f=this._complex.getChain("A")||this._complex.addChain("A"),this._residue=null),this._setResidue(n)){var d=jl.getByName(u),p=jl.Role[s],m=new i.Pq0(a,l,c);this._residue.addAtom(s,d,m,p,!1,o," ",1,0,h)}}}},{key:"_setResidue",value:function(e){var t=1,r="UNK";if(e.length>=7&&(t=parseInt(e[6],10)),e.length>=8&&"<0>"!==e[7]&&(r=e[7].replace(Yl,"")),this.settings.now.nowater&&("HOH"===r||"WAT"===r))return!1;var n=this._residue,i=this._chain;return n&&n.getSequence()===t||(this._residue=i.addResidue(r,t,"A")),!0}},{key:"_parseBonds",value:function(e,t){this._toHeaderString("BOND",t);for(var r=0;r<e;r++){var n=$l(t[++this._currPosIdx]);if(n.length<3)throw new Error("MOL2 parsing error: Missing information about bonds!");var i=parseInt(n[1],10),o=parseInt(n[2],10),s=n[3];if(i>o){var a=[o,i];i=a[0],o=a[1]}this._complex.addBond(i,o,ql[s]||0,Wl[s]||Gl.BondType.UNKNOWN,!0)}}},{key:"_fixSerialAtoms",value:function(){for(var e=this._complex._atoms,t=0;t<e.length;t++){var r=e[t];this._serialAtomMap[r.serial]=r}}},{key:"_fixBondsArray",value:function(){var e=this._serialAtomMap,t=this._complex;if(0===Object.keys(e).length)throw new Error("MOL2 parsing error: Missing atom information!");for(var r=t._bonds,n=0;n<r.length;n++){var i=r[n];i._left=e[i._left]||null,i._right=e[i._right]||null}}},{key:"_finalizeMolecules",value:function(){var e=this._complex._chains[0];this._complex._molecules=[];for(var t=0;t<this._molecules.length;t++){var r=this._molecules[t],n=e._residues,i=new Hl(this._complex,r._name,t+1);i.residues=n,this._complex._molecules[t]=i}}},{key:"_finalize",value:function(){this._complex._finalizeBonds(),this._fixSerialAtoms(),this._fixBondsArray(),this._finalizeMolecules(),this._complex.finalize({needAutoBonding:!1,detectAromaticLoops:this.settings.now.aromatic,enableEditing:this.settings.now.editing,serialAtomMap:this._serialAtomMap})}},{key:"_parseCompound",value:function(e){this._compoundIndx++,this._parseMolecule(e),this._toStringFromHeader("MOLECULE",2,e);var t=e[this._currPosIdx].trim().split(Xl),r=t[0],n=t[1];this._parseAtoms(r,e),this._parseBonds(n,e)}},{key:"parseSync",value:function(){var e=this._complex=new Ul,t=this._parseRawStrings(this._data);do{this._parseCompound(t)}while(this._findNextCompoundStart(t));return this._finalize(),e}}]),o}(oa);Zl.formats=["mol2"],Zl.extensions=[".mol2",".ml2",".sy2"];var Ql=new ia([ga,sl,ja,ml,ka,_l,Ml,hl,Ll,Vl,Zl]);var Kl=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(this,i),n.call(this,e,["formats"])}return l(i,[{key:"find",value:function(e){var t=[];return e.format&&(t=this._dict.formats[e.format.toLowerCase()]||[]),Pr(t)}}]),i}(Mr),Jl=function(){function e(t,r){s(this,e),this._source=t,this._options=r||{},this._abort=!1}return l(e,[{key:"exportSync",value:function(){throw new Error("Exporting to this source is not implemented")}},{key:"export",value:function(){var e=this;return new Promise((function(t,r){setTimeout((function(){try{return e._abort?r(new Error("Export aborted")):t(e.exportSync())}catch(e){return r(e)}}))}))}},{key:"abort",value:function(){this._abort=!0}}]),e}();Ir(Jl.prototype);var ec=function(){function e(){s(this,e),this._resultArray=[],this._currentStr=-1,this._tag=null,this._fixedNumeration=!1,this._numeration=!1,this._tagStrNum=0}return l(e,[{key:"getResult",value:function(){return this.writeString("\n",81,81),this._resultArray.join("")}},{key:"_currentStrLength",value:function(){var e=this._resultArray[this._currentStr];return e?e.length:0}},{key:"newTag",value:function(e,t){this._tag=e||null,(0,n.isUndefined)(t)?(this._numeration=!1,this._fixedNumeration=!1,this._tagStrNum=0):(0,n.isNumber)(t)?(this._tagStrNum=t,this._numeration=!0,this._fixedNumeration=!0):(0,n.isBoolean)(t)&&(this._tagStrNum=0,this._numeration=t,this._fixedNumeration=!1)}},{key:"newString",value:function(e){this.writeString("\n",81,81),this._currentStr++,this._resultArray.push(""),e?this.writeString(e,1,6):this._tag&&this.writeString(this._tag,1,6),this._numeration&&(this._fixedNumeration||this._tagStrNum++,1!==this._tagStrNum&&this.writeString(this._tagStrNum.toString(),10,8))}},{key:"writeEntireString",value:function(e,t,r){t||(t=81);for(var n=0;n<e.length;n++)this._currentStrLength()===t&&n!==e.length-1&&(this.newString(),r&&this.writeString(r.tag,r.begin,r.end)),"\n"===e[n]?this.newString():this.writeString(e[n])}},{key:"writeString",value:function(e,t,r){var i,o=this._resultArray[this._currentStr],s=o?o.length:0;if(!(0,n.isUndefined)(e)){(0,n.isNumber)(t)||(t=s+1),(0,n.isNumber)(r)||(r=s+e.length);var a=t<r?r:t,l=t<r?t:r;if((i=(0,n.isString)(e)?e:e.toString()).length>Math.abs(t-r)+1&&(i=i.substr(0,Math.abs(t-r+1))),l>s+1)this._resultArray[this._currentStr]+=" ".repeat(l-s-1);else if(l<=s){var c=this._resultArray[this._currentStr];this._resultArray[this._currentStr]=c.slice(0,l-1)}r<t&&(i=" ".repeat(t-r+1-i.length)+i),11===l&&this._numeration&&1!==this._tagStrNum&&(i=" ".concat(i)),this._resultArray[this._currentStr]+=i,a>(o=this._resultArray[this._currentStr]).length&&(this._resultArray[this._currentStr]+=" ".repeat(a-o.length))}}},{key:"writeBondsArray",value:function(e,t){for(var r=this._getSubArrays(e,4),n=0;n<r.length;n++){this.newString(),this.writeString(t.serial,11,7);for(var i=0;i<r[n].length;i++){var o=r[n][i]._left.serial===t.serial?r[n][i]._right.serial:r[n][i]._left.serial;this.writeString(o,16+5*i,12+5*i)}}}},{key:"_getSubArrays",value:function(e,t){for(var r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}},{key:"writeMatrix",value:function(e,t,r){for(var n=0;n<3;n++){this.newString(),this.writeString(r,14,18),this.writeString((n+1).toString(),19,19),this.writeString(t.toString(),23,20);for(var i=0;i<3;i++){var o=parseFloat(e.elements[4*n+i]).toFixed(6);this.writeString(o.toString(),33+10*i,24+10*i)}var s=parseFloat(e.elements[4*n+3]).toFixed(5);this.writeString(s.toString(),68,55)}}},{key:"writeMatrices",value:function(e,t){if(e)for(var r=new i.kn4,n=0;n<e.length;n++)r.copy(e[n]).transpose(),this.writeMatrix(r,n+1,t)}}]),e}();var tc=function(e){h(o,e);var t,r,i=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;return s(this,o),(r=i.call(this,e,t))._tags=["HEADER","TITLE","COMPND","REMARK","HELIX","SHEET","ATOM and HETATM","CONECT"],r._result=null,r._tagExtractors={HEADER:r._extractHEADER,TITLE:r._extractTITLE,"ATOM and HETATM":r._extractATOM,CONECT:r._extractCONECT,COMPND:r._extractCOMPND,REMARK:r._extractREMARK,HELIX:r._extractHELIX,SHEET:r._extractSHEET},r._stringForRemark350="COORDINATES FOR A COMPLETE MULTIMER REPRESENTING THE KNOWN\nBIOLOGICALLY SIGNIFICANT OLIGOMERIZATION STATE OF THE\nMOLECULE CAN BE GENERATED BY APPLYING BIOMT TRANSFORMATIONS\nGIVEN BELOW. BOTH NON-CRYSTALLOGRAPHIC AND\nCRYSTALLOGRAPHIC OPERATIONS ARE GIVEN.",r._stringForRemark290="CRYSTALLOGRAPHIC SYMMETRY TRANSFORMATIONS\nTHE FOLLOWING TRANSFORMATIONS OPERATE ON THE ATOM/HETATM\nRECORDS IN THIS ENTRY TO PRODUCE CRYSTALLOGRAPHICALLY\nRELATED MOLECULES.",r}return l(o,[{key:"exportSync",value:function(){var e=new ec;if(!this._source)return this._result;for(var t=0;t<this._tags.length;t++){var r=this._tags[t],n=this._tagExtractors[r];"function"==typeof n&&n.call(this,e)}return this._result=e.getResult(),this._result}},{key:"_extractHEADER",value:function(e){if(this._source.metadata){var t=this._source.metadata;e.newTag("HEADER"),e.newString(),t.classification&&e.writeString(t.classification,11,50),t.date&&e.writeString(t.date,51,59),t.id&&e.writeString(t.id,63,66)}}},{key:"_extractTITLE",value:function(e){if(this._source.metadata){var t=this._source.metadata;if(t.title){e.newTag("TITLE",!0);for(var r=0;r<t.title.length;r++)e.newString(),e.writeString(t.title[r],11,80)}}}},{key:"_extractCONECT",value:function(e){if(this._source._atoms){var t=this._source._atoms;e.newTag("CONECT");for(var r=0;r<t.length;r++){var n=t[r].bonds.filter((function(e){return e._fixed}));0!==n.length&&e.writeBondsArray(n.reverse(),t[r])}}}},{key:"_extractSHEET",value:function(e){if(this._source._sheets){e.newTag("SHEET");for(var t=this._source._sheets,r=0;r<t.length;r++)if(t[r]._strands)for(var n=t[r]._strands,i=0;i<n.length;i++)e.newString(),e.writeString(i+1,10,8),e.writeString(t[r]._name,14,12),e.writeString(n.length,16,15),e.writeString(n[i].init._type._name,18,20),e.writeString(n[i].init._chain._name,22,22),e.writeString(n[i].init._sequence,26,23),e.writeString(n[i].init._icode,27,27),e.writeString(n[i].term._type._name,29,31),e.writeString(n[i].init._chain._name,33,33),e.writeString(n[i].term._sequence,37,34),e.writeString(n[i].term._icode,38,38),e.writeString(n[i].sense,40,39)}}},{key:"_extractHELIX",value:function(e){if(this._source._helices){e.newTag("HELIX");for(var t=this._source._helices,r=0;r<t.length;r++){var i=t[r],o=(0,n.invert)(He);e.newString(),e.writeString(i.serial,10,8),e.writeString(i.name,14,12),e.writeString(i.init._type._name,16,18),e.writeString(i.init._chain._name,20,20),e.writeString(i.init._sequence,25,22),e.writeString(i.init._icode,26,26),e.writeString(i.term._type._name,28,30),e.writeString(i.term._chain._name,32,32),e.writeString(i.term._sequence,37,34),e.writeString(i.term._icode,38,38),e.writeString(o[i.type],40,39),e.writeString(i.comment,41,70),e.writeString(i.length,76,72)}}}},{key:"_extractATOM",value:function(e){if(this._source._atoms)for(var t=this._source._atoms,r=0;r<t.length;r++){var n=t[r].het?"HETATM":"ATOM";e.newString(n);var i=t[r].element.name.length>1||t[r].name.length>3?13:14;e.writeString(t[r].serial,11,7),e.writeString(t[r].name,i,16),e.writeString(String.fromCharCode(t[r].location),17,17),e.writeString(t[r].residue._type._name,20,18),e.writeString(t[r].residue._chain._name,22,22),e.writeString(t[r].residue._sequence,26,23),e.writeString(t[r].residue._icode,27,27),e.writeString(t[r].position.x.toFixed(3),38,31),e.writeString(t[r].position.y.toFixed(3),46,39),e.writeString(t[r].position.z.toFixed(3),54,47),e.writeString(t[r].occupancy.toFixed(2),60,55),e.writeString(t[r].temperature.toFixed(2),66,61),e.writeString(t[r].element.name,78,77),t[r].charge&&e.writeString(t[r].charge,79,80)}}},{key:"_extractCOMPND",value:function(e){if(this._source._molecules){var t=this._source._molecules;e.newTag("COMPND",!0);for(var r=0;r<t.length;r++){var n=this._getMoleculeChains(t[r]);e.newString(),e.writeString("MOL_ID: ".concat(t[r].index,";"),11,80),e.newString(),e.writeString("MOLECULE: ".concat(t[r].name,";"),11,80),e.newString(),e.writeString("CHAIN: ",11,18);var i="".concat(n.join(", "),";");e.writeEntireString(i,81)}}}},{key:"_extractREMARK",value:function(e){this._Remark290(e),this._Remark350(e)}},{key:"_Remark290",value:function(e){if(this._source.symmetry&&0!==this._source.symmetry.length){var t=this._source.symmetry;e.newTag("REMARK",290),e.newString(),e.newString(),e.writeEntireString(this._stringForRemark290),e.writeMatrices(t,"SMTRY"),e.newString(),e.newString(),e.writeString("REMARK: NULL",11,80)}}},{key:"_Remark350",value:function(e){if(this._source.units){var t=this._source.units,r=0;e.newTag("REMARK",350),e.newString(),e.newString(),e.writeEntireString(this._stringForRemark350);for(var n=t.filter((function(e){return e instanceof Rt})),i=0;i<n.length;i++){e.newString(),e.newString(),r++,e.writeString("BIOMOLECULE: ".concat(r),11,80);var o=n[i].chains.join(", ");e.newString(),e.writeString("APPLY THE FOLLOWING TO CHAINS: "),e.writeEntireString(o,69,{tag:"AND CHAINS: ",begin:31,end:42});var s=n[i].matrices;e.writeMatrices(s,"BIOMT")}}}},{key:"_getMoleculeChains",value:function(e){var t=e.residues.map((function(e){return e._chain._name}));return t.filter((function(e,r){return t.indexOf(e)===r}))}}]),o}(Jl);function rc(e,t,r,n){r[n]=e[t],r[n+1]=e[t+1],r[n+2]=e[t+2]}function nc(e,t,r,n,i){r[n]=e[t],r[n+1]=e[t+1],r[n+2]=e[t+2],r[n+3]=i}tc.formats=["pdb"],tc.SourceClass=cr;var ic=new i.IUQ;function oc(e,t,r,n,i){ic.set(e[t],e[t+1],e[t+2],i.w),ic.applyMatrix4(i.matrix),r[n]=ic.x,r[n+1]=ic.y,r[n+2]=ic.z}function sc(e,t,r,n,i){if(!((t.array.length-t.start)/t.stride<r||(e.array.length-e.start)/e.stride<r))if(e.stride===t.stride)t.array.set(e.array,t.start);else for(var o=t.start,s=e.start,a=0;a<r;++a,o+=t.stride,s+=e.stride)n(e.array,s,t.array,o,i)}var ac=function(){function e(){s(this,e),this.positions=null,this.normals=null,this.colors=null,this.indices=null,this.lastPos=0,this.lastNorm=0,this.lastCol=0,this.lastIdx=0}return l(e,[{key:"init",value:function(e,t){this.positions=new Float32Array(3*e),this.normals=new Float32Array(3*e),this.colors=new Float32Array(4*e),this.indices=new Int32Array(t)}},{key:"setPositions",value:function(e,t,r,n){sc({array:e,start:t,stride:n},{array:this.positions,start:this.lastPos,stride:3},r,rc),this.lastPos+=3*r}},{key:"setTransformedPositions",value:function(e,t,r,n,i){for(var o=this.lastPos,s=t,a={matrix:i,w:1},l=0;l<r;++l,s+=n,o+=3)oc(e,s,this.positions,o,a);this.lastPos+=3*r}},{key:"setNormals",value:function(e,t,r,n){sc({array:e,start:t,stride:n},{array:this.normals,start:this.lastNorm,stride:3},r,rc),this.lastNorm+=3*r}},{key:"setTransformedNormals",value:function(e,t,r,n,i){for(var o=this.lastNorm,s=t,a={matrix:i,w:0},l=0;l<r;++l,s+=n,o+=3)oc(e,s,this.normals,o,a);this.lastNorm+=3*r}},{key:"setColors",value:function(e,t,r,n){sc({array:e,start:t,stride:n},{array:this.colors,start:this.lastCol,stride:4},r,nc,1),this.lastCol+=4*r}},{key:"setIndices",value:function(e,t,r){this.indices.set(e,this.lastIdx),this.lastIdx+=r}},{key:"setShiftedIndices",value:function(e,t,r){var n=e.map((function(e){return e+r}));this.setIndices(n,0,t)}},{key:"getVerticesNumber",value:function(){return this.lastPos/3}},{key:"addInstance",value:function(e,t){var r=this.getVerticesNumber();this.setShiftedIndices(t.indices,t.indices.length,r);var n=t.itemSize;this.setTransformedPositions(t.positions,0,t.vertsCount,n.position,e),this.setTransformedNormals(t.normals,0,t.vertsCount,n.normal,e),this.setColors(t.colors,0,t.vertsCount,n.color)}}]),e}(),lc=function(){function e(){s(this,e),this.positions=null,this.normals=null,this.colors=null,this.indices=null,this.vertsCount=0,this.itemSize=null}return l(e,[{key:"init",value:function(e,t){var r=e.attributes;this.itemSize={position:r.position.itemSize,normal:r.normal.itemSize,color:r.color.itemSize}}}]),e}();var cc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){return s(this,i),n.apply(this,arguments)}return l(i,[{key:"init",value:function(e,t){We(d(i.prototype),"init",this).call(this,e,t);var r=e.attributes,n=r.position,o=r.normal,s=e.index;this.vertsCount=n.count,this.positions=n.array,this.normals=o.array,this.colors=new Float32Array(this.vertsCount*this.itemSize.color),this.indices=s.array}},{key:"setColors",value:function(e){for(var t=0,r=0,n=this.colors.length,i=this.itemSize.color;r<n;r+=i)this.colors[t++]=e.r,this.colors[t++]=e.g,this.colors[t++]=e.b}}]),i}(lc);var uc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;return s(this,i),(e=n.call(this))._cutRawStart=0,e._cutRawEnd=0,e._facesPerSlice=0,e}return l(i,[{key:"init",value:function(e,t){We(d(i.prototype),"init",this).call(this,e,t);var r=e.attributes.position,n=e.index;this.vertsCount=r.count+t.addPerCylinder,this._facesPerSlice=t.addPerCylinder,this.positions=new Float32Array(this.vertsCount*r.itemSize),this.normals=new Float32Array(this.vertsCount*this.itemSize.normal),this.colors=new Float32Array(this.vertsCount*this.itemSize.color),this._extendVertices(e,t),this.indices=new Uint32Array(n.count),this._extendIndices(e,t)}},{key:"_extendVertices",value:function(e,t){var r=e.attributes.position,n=e.attributes.normal,i=e.getGeoParams();this._cutRawStart=1*i.radialSegments,this._cutRawEnd=this._cutRawStart+t.addPerCylinder;var o=r.array.slice(0,this._cutRawEnd*r.itemSize);this.positions.set(o,0),o=n.array.slice(0,this._cutRawEnd*n.itemSize),this.normals.set(o,0);var s=r.array.slice(this._cutRawStart*r.itemSize,r.array.length);this.positions.set(s,this._cutRawEnd*r.itemSize),s=n.array.slice(this._cutRawStart*n.itemSize,n.array.length),this.normals.set(s,this._cutRawEnd*n.itemSize)}},{key:"_extendIndices",value:function(e,t){var r=e.index,n=6*t.addPerCylinder,i=t.addPerCylinder,o=r.array.slice(n,r.count);o=o.map((function(e){return e+i})),this.indices.set(r.array,0),this.indices.set(o,n)}},{key:"_setColorRange",value:function(e,t,r,n){for(var i=n.length,o=e;o<t;o+=i)r.set(n,o)}},{key:"setColors",value:function(e,t){var r=this.itemSize.color,n=this._cutRawEnd*r,i=2*n;if(this._setColorRange(0,n,this.colors,e.toArray()),this._setColorRange(n,i,this.colors,t.toArray()),i<this.colors.length){var o=(this._facesPerSlice+1)*r,s=i+o;this._setColorRange(i,s,this.colors,t.toArray());var a=s+o;this._setColorRange(s,a,this.colors,e.toArray())}}}]),i}(lc),hc=function(){function e(){s(this,e),this._materials=[],this._models=[]}return l(e,[{key:"process",value:function(e){this._extractModelsAndMaterials(e);var t=this._flattenModels();return{name:e.name,models:t,materials:this._materials}}},{key:"_extractModelsAndMaterials",value:function(e){var t=this,r=new i.zgK;r.set(kr.LAYERS.DEFAULT),r.enable(kr.LAYERS.TRANSPARENT),e.traverse((function(e){e instanceof i.eaF&&e.layers.test(r)&&t.checkExportAbility(e)&&("InstancedBufferGeometry"===e.geometry.type?t._collectInstancedGeoInfo(e):t._collectGeoInfo(e))}))}},{key:"_reworkIndices",value:function(e){for(var t=2;t<e.length;t+=3)e[t]*=-1,e[t]--}},{key:"_flattenModels",value:function(){var e=0;function t(t){return t+e}for(var r=[],n=0,i=this._models.length;n<i;n++){var o=this._models[n],s=[],a=[],l=[],c=[];e=0;for(var u=0;u<o.length;u++){var h=o[u];s.push(h.indices.map(t)),e+=h.getVerticesNumber(),a.push(h.positions),l.push(h.normals),c.push(h.colors)}s=$.mergeTypedArraysUnsafe(s),this._reworkIndices(s),a=$.mergeTypedArraysUnsafe(a),l=$.mergeTypedArraysUnsafe(l),c=$.mergeTypedArraysUnsafe(c),r.push({indices:s,positions:a,normals:l,colors:c,verticesCount:e})}return r}},{key:"checkExportAbility",value:function(e){return!(0===e.geometry.attributes.position.count||(e instanceof hi?(B.warn("Currently we cannot export 'sprites' modes, like BS, WV, LC. Please turn of settings 'zSprites' and try again"),1):e instanceof _i&&(B.warn("Currently we cannot export Lines mode"),1)))}},{key:"_collectGeoInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,i=r.color,o=r.normal,s=t.index,a=e.matrix,l=new ac,c=n.count;l.init(c,s.count),a.isIdentity()?(l.setPositions(n.array,0,c,n.itemSize),l.setNormals(o.array,0,c,o.itemSize)):(l.setTransformedPositions(n.array,0,c,n.itemSize,a),l.setTransformedNormals(o.array,0,c,o.itemSize,a)),l.setColors(i.array,0,c,i.itemSize),l.setIndices(s.array,0,s.count);var u=this._collectMaterialInfo(e);this._addToPool(l,u)}},{key:"_collectSpheresInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,o=r.color,s=t.index,a=e.matrix,l=new ac,c=e.geometry.instanceCount,u=n.count,h=s.count;l.init(c*u,c*h);var f=new cc;f.init(e.geometry);for(var d=new i.kn4,p=new i.kn4,m=new i.Q1f,v=0;v<c;++v){var y=v*o.itemSize;m.fromArray(o.array,y),f.setColors(m),this._getSphereInstanceMatrix(e.geometry,v,d),p.multiplyMatrices(a,d),l.addInstance(p,f)}var _=this._collectMaterialInfo(e);this._addToPool(l,_)}},{key:"_collectCylindersInfo",value:function(e){var t=e.geometry,r=t.attributes,n=r.position,o=r.color,s=r.color2,a=t.index,l=e.matrix,c=new ac,u=e.geometry.instanceCount,h=new cc;h.init(e.geometry);var f=this._gatherCylindersColoringInfo(e.geometry),d=null;f.needToSplit>0&&(d=new uc).init(e.geometry,f);var p=f.addPerCylinder*f.needToSplit,m=n.count,v=a.count;c.init(u*m+p,u*v);for(var y=new i.kn4,_=new i.kn4,g=new i.Q1f,x=new i.Q1f,b={},w=0;w<u;++w){var S=w*o.itemSize;f.is2Colored[w]?(g.fromArray(s.array,S),x.fromArray(o.array,S),d&&(d.setColors(g,x),b=d)):(g.fromArray(o.array,S),h.setColors(g),b=h),this._getCylinderInstanceMatrix(e.geometry,w,y),_.multiplyMatrices(l,y),c.addInstance(_,b)}var R=this._collectMaterialInfo(e);this._addToPool(c,R)}},{key:"_addToPool",value:function(e,t){var r=this._checkExistingMaterial(t);r<0?(this._models.push([e]),this._materials.push(t)):this._models[r].push(e)}},{key:"_checkExistingMaterial",value:function(e){return(0,n.findIndex)(this._materials,(function(t){return(0,n.isEqual)(t,e)}))}},{key:"_gatherCylindersColoringInfo",value:function(e){for(var t=e.instanceCount,r=e.attributes.color.array,n=e.attributes.color2.array,i=e.attributes.color.itemSize,o=new Array(t),s=0,a=0,l=0;l<t;l++,a+=i){var c=Math.abs(r[a]-n[a])>1e-7||Math.abs(r[a+1]-n[a+1])>1e-7||Math.abs(r[a+2]-n[a+2])>1e-7;o[l]=c,s+=c}return{is2Colored:o,needToSplit:s,addPerCylinder:e.getGeoParams().radialSegments}}},{key:"_collectInstancedGeoInfo",value:function(e){e.geometry instanceof Dr?this._collectSpheresInfo(e):e.geometry instanceof Kr&&this._collectCylindersInfo(e)}},{key:"_collectMaterialInfo",value:function(e){var t=e.material.uberOptions;return{diffuse:t.diffuse.toArray(),opacity:t.opacity,shininess:t.shininess,specular:t.specular.toArray()}}},{key:"_getCylinderInstanceMatrix",value:function(e,t,r){var n=e.attributes.matVector1.array,i=e.attributes.matVector2.array,o=e.attributes.matVector3.array,s=4*t;r.set(n[s],n[s+1],n[s+2],n[s+3],i[s],i[s+1],i[s+2],i[s+3],o[s],o[s+1],o[s+2],o[s+3],0,0,0,1)}},{key:"_getSphereInstanceMatrix",value:function(e,t,r){var n=e.attributes.offset,i=t*n.itemSize,o=n.array[i],s=n.array[i+1],a=n.array[i+2],l=n.array[i+3];r.set(l,0,0,o,0,l,0,s,0,0,l,a,0,0,0,1)}}]),e}(),fc=function(){function e(){s(this,e),this._resultArray=[],this._info=null}return l(e,[{key:"getResult",value:function(e){return this._info=e,this._resultArray.push(this._writeHeader()),this._resultArray.push(this._writeDefinitions()),this._resultArray.push(this._writeObjects(e.models,e.materials)),this._resultArray.push(this._writeRelations()),this._resultArray.push(this._writeConnections()),this._info=null,this._resultArray.join("")}},{key:"_writeHeader",value:function(){var e=new Date,t="Miew FBX Exporter v".concat(this._info.version);return"; FBX 6.1.0 project file\n; Created by ".concat(t," Copyright (c) 2015-2020 EPAM Systems, Inc.\n; For support please contact miew@epam.com\n; ----------------------------------------------------\n\nFBXHeaderExtension: {\n FBXHeaderVersion: ").concat(1003,"\n FBXVersion: ").concat(6100,"\n CreationTimeStamp: {\n Version: ").concat(1e3,"\n Year: ").concat(e.getFullYear(),"\n Month: ").concat(e.getMonth()+1," \n Day: ").concat(e.getDate(),"\n Hour: ").concat(e.getHours(),"\n Minute: ").concat(e.getMinutes(),"\n Second: ").concat(e.getSeconds(),"\n Millisecond: ").concat(e.getMilliseconds(),'\n }\n Creator: "').concat(t,'"\n OtherFlags: {\n FlagPLE: 0\n }\n}\nCreationTime: "').concat(e,'"\nCreator: "').concat(t,'" \n')}},{key:"_writeDefinitions",value:function(){return"\n; Object definitions\n;------------------------------------------------------------------\n\n".concat('\nDefinitions: {\n Version: 100\n Count: 3\n ObjectType: "Model" {\n Count: 1\n }\n ObjectType: "Geometry" {\n Count: 1\n }\n ObjectType: "Material" {\n Count: 1\n }\n ObjectType: "Pose" {\n Count: 1\n }\n ObjectType: "GlobalSettings" {\n Count: 1\n }\n} ',"\n")}},{key:"_models",value:function(){for(var e="",t=this._info.models,r=0;r<t.length;++r){var n=t[r],i=n.verticesCount;e+='\n Model: "Model::'.concat(this._info.name,"_").concat(r,'", "Mesh" {\n Version: ').concat(232," \n ").concat('Properties60: {\n Property: "QuaternionInterpolate", "bool", "",0\n Property: "Visibility", "Visibility", "A",1\n Property: "Lcl Translation", "Lcl Translation", "A",0.000000000000000,0.000000000000000,-1789.238037109375000\n Property: "Lcl Rotation", "Lcl Rotation", "A",0.000009334667643,-0.000000000000000,0.000000000000000\n Property: "Lcl Scaling", "Lcl Scaling", "A",1.000000000000000,1.000000000000000,1.000000000000000\n Property: "RotationOffset", "Vector3D", "",0,0,0\n Property: "RotationPivot", "Vector3D", "",0,0,0\n Property: "ScalingOffset", "Vector3D", "",0,0,0\n Property: "ScalingPivot", "Vector3D", "",0,0,0\n Property: "TranslationActive", "bool", "",0\n Property: "TranslationMin", "Vector3D", "",0,0,0\n Property: "TranslationMax", "Vector3D", "",0,0,0\n Property: "TranslationMinX", "bool", "",0\n Property: "TranslationMinY", "bool", "",0\n Property: "TranslationMinZ", "bool", "",0\n Property: "TranslationMaxX", "bool", "",0\n Property: "TranslationMaxY", "bool", "",0\n Property: "TranslationMaxZ", "bool", "",0\n Property: "RotationOrder", "enum", "",0\n Property: "RotationSpaceForLimitOnly", "bool", "",0\n Property: "AxisLen", "double", "",10\n Property: "PreRotation", "Vector3D", "",0,0,0\n Property: "PostRotation", "Vector3D", "",0,0,0\n Property: "RotationActive", "bool", "",0\n Property: "RotationMin", "Vector3D", "",0,0,0\n Property: "RotationMax", "Vector3D", "",0,0,0\n Property: "RotationMinX", "bool", "",0\n Property: "RotationMinY", "bool", "",0\n Property: "RotationMinZ", "bool", "",0\n Property: "RotationMaxX", "bool", "",0\n Property: "RotationMaxY", "bool", "",0\n Property: "RotationMaxZ", "bool", "",0\n Property: "RotationStiffnessX", "double", "",0\n Property: "RotationStiffnessY", "double", "",0\n Property: "RotationStiffnessZ", "double", "",0\n Property: "MinDampRangeX", "double", "",0\n Property: "MinDampRangeY", "double", "",0\n Property: "MinDampRangeZ", "double", "",0\n Property: "MaxDampRangeX", "double", "",0\n Property: "MaxDampRangeY", "double", "",0\n Property: "MaxDampRangeZ", "double", "",0\n Property: "MinDampStrengthX", "double", "",0\n Property: "MinDampStrengthY", "double", "",0\n Property: "MinDampStrengthZ", "double", "",0\n Property: "MaxDampStrengthX", "double", "",0\n Property: "MaxDampStrengthY", "double", "",0\n Property: "MaxDampStrengthZ", "double", "",0\n Property: "PreferedAngleX", "double", "",0\n Property: "PreferedAngleY", "double", "",0\n Property: "PreferedAngleZ", "double", "",0\n Property: "InheritType", "enum", "",0\n Property: "ScalingActive", "bool", "",0\n Property: "ScalingMin", "Vector3D", "",1,1,1\n Property: "ScalingMax", "Vector3D", "",1,1,1\n Property: "ScalingMinX", "bool", "",0\n Property: "ScalingMinY", "bool", "",0\n Property: "ScalingMinZ", "bool", "",0\n Property: "ScalingMaxX", "bool", "",0\n Property: "ScalingMaxY", "bool", "",0\n Property: "ScalingMaxZ", "bool", "",0\n Property: "GeometricTranslation", "Vector3D", "",0,0,0\n Property: "GeometricRotation", "Vector3D", "",0,0,0\n Property: "GeometricScaling", "Vector3D", "",1,1,1\n Property: "LookAtProperty", "object", ""\n Property: "UpVectorProperty", "object", ""\n Property: "Show", "bool", "",1\n Property: "NegativePercentShapeSupport", "bool", "",1\n Property: "DefaultAttributeIndex", "int", "",0\n Property: "Color", "Color", "A+",0,0,0\n Property: "Size", "double", "",100\n Property: "Look", "enum", "",1\n }',"\n ").concat(this._verticesIndices(n.positions,n.indices),"\n ").concat(this._normalLayer(n.normals)," \n ").concat(this._colorLayer(n.colors,i)," \n ").concat('\n LayerElementMaterial: 0 {\n Version: 101\n Name: ""\n MappingInformationType: "AllSame"\n ReferenceInformationType: "Direct"\n Materials: 0\n }'," \n ").concat('\n Layer: 0 {\n Version: 100\n LayerElement: {\n Type: "LayerElementNormal"\n TypedIndex: 0\n }\n LayerElement: {\n Type: "LayerElementColor"\n TypedIndex: 0\n }\n LayerElement: {\n Type: "LayerElementMaterial"\n TypedIndex: 0\n }\n }',"\n }")}return e}},{key:"_materials",value:function(){for(var e="",t=this._info.materials,r=0;r<t.length;++r){var n=t[r];e+='\n Material: "Material::'.concat(this._info.name,"_").concat(r,'_default", "" {\n Version: ').concat(102,'\n ShadingModel: "lambert"\n MultiLayer: 0\n ').concat(this._materialProperties(n),"\n }")}return e}},{key:"_writeObjects",value:function(){return"\n; Object properties\n;------------------------------------------------------------------\n\nObjects: {\n ".concat(this._models(),"\n ").concat(this._materials(),"\n ").concat('GlobalSettings: {\n Version: 1000\n Properties60: {\n Property: "UpAxis", "int", "",1\n Property: "UpAxisSign", "int", "",1\n Property: "FrontAxis", "int", "",2\n Property: "FrontAxisSign", "int", "",1\n Property: "CoordAxis", "int", "",0\n Property: "CoordAxisSign", "int", "",1\n Property: "UnitScaleFactor", "double", "",1\n }\n }',"\n}\n")}},{key:"_writeRelations",value:function(){for(var e="",t=0;t<this._info.models.length;++t)e+='\n Model: "Model::'.concat(this._info.name,"_").concat(t,'", "Mesh" {\n }');for(var r="",n=0;n<this._info.materials.length;++n)r+='\n Material: "Material::'.concat(this._info.name,"_").concat(n,'_default", "" {\n }');return"\n; Object relations\n;------------------------------------------------------------------\n\nRelations: {\n ".concat(e,'\n Model: "Model::Producer Perspective", "Camera" {\n }\n Model: "Model::Producer Top", "Camera" {\n }\n Model: "Model::Producer Bottom", "Camera" {\n }\n Model: "Model::Producer Front", "Camera" {\n }\n Model: "Model::Producer Back", "Camera" {\n }\n Model: "Model::Producer Right", "Camera" {\n }\n Model: "Model::Producer Left", "Camera" {\n }\n Model: "Model::Camera Switcher", "CameraSwitcher" {\n }\n ').concat(r,"\n}")}},{key:"_writeConnections",value:function(){for(var e="",t=this._info.name,r=0;r<this._info.models.length;++r)e+='\n Connect: "OO", "Model::'.concat(t,"_").concat(r,'", "Model::Scene"');for(var n="",i=0;i<this._info.materials.length;++i)n+='\n Connect: "OO", "Material::'.concat(t,"_").concat(i,'_default", "Model::').concat(t,"_").concat(i,'"');return"\n; Object connections\n;------------------------------------------------------------------\n\nConnections: {\n ".concat(e,"\n ").concat(n,"\n}")}},{key:"_floatArrayToString",value:function(e){for(var t=[],r=0;r<e.length;++r)t[r]=e[r].toFixed(6);return t.join(",")}},{key:"_colorLayer",value:function(e,t){var r=this._floatArrayToString(e),n=Pr(Array(t).keys());return"\n LayerElementColor: ".concat(0," {\n Version: ").concat(101,'\n Name: "').concat("",'"\n MappingInformationType: "ByVertice"\n ReferenceInformationType: "Direct"\n Colors: ').concat(r,"\n ColorIndex: ").concat(n,"\n }")}},{key:"_normalLayer",value:function(e){var t=this._floatArrayToString(e);return"\n LayerElementNormal: ".concat(0," {\n Version: ").concat(101,'\n Name: "').concat("",'"\n MappingInformationType: "ByVertice"\n ReferenceInformationType: "Direct" \n Normals: ').concat(t,"\n }")}},{key:"_verticesIndices",value:function(e,t){var r=this._floatArrayToString(e);return"MultiLayer: ".concat(0,"\n MultiTake: ").concat(1,"\n Shading: ").concat("Y",'\n Culling: "').concat("CullingOff",'"\n Vertices: ').concat(r,"\n PolygonVertexIndex: ").concat(t,"\n GeometryVersion: ").concat(124)}},{key:"_materialProperties",value:function(e){return'Properties60: {\n Property: "ShadingModel", "KString", "", "Lambert"\n Property: "MultiLayer", "bool", "",0\n Property: "EmissiveColor", "ColorRGB", "",0,0,0\n Property: "EmissiveFactor", "double", "",0.0000\n Property: "AmbientColor", "ColorRGB", "",1,1,1\n Property: "AmbientFactor", "double", "",0.0000\n Property: "DiffuseColor", "ColorRGB", "",'.concat(e.diffuse,'\n Property: "DiffuseFactor", "double", "",1.0000\n Property: "Bump", "Vector3D", "",0,0,0\n Property: "TransparentColor", "ColorRGB", "",1,1,1\n Property: "TransparencyFactor", "double", "",0.0000\n Property: "SpecularColor", "ColorRGB", "",').concat(e.specular,'\n Property: "SpecularFactor", "double", "",1.0000\n Property: "ShininessExponent", "double", "",').concat(e.shininess,'\n Property: "ReflectionColor", "ColorRGB", "",0,0,0\n Property: "ReflectionFactor", "double", "",1\n Property: "Ambient", "ColorRGB", "",1,1,1\n Property: "Diffuse", "ColorRGB", "",').concat(e.diffuse,'\n Property: "Specular", "ColorRGB", "",').concat(e.specular,'\n Property: "Shininess", "double", "",').concat(e.shininess,'\n Property: "Opacity", "double", "",').concat(e.opacity,'\n Property: "Reflectivity", "double", "",0\n }')}}]),e}();var dc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(e,t){var r;return s(this,i),(r=n.call(this,e,t))._data=e,r._version=t.miewVersion||"0.0-UNSPECIFIED",r._extractor=new hc,r}return l(i,[{key:"exportSync",value:function(){var e=new fc;if(!this._source)return this._result;var t=this._extractor.process(this._data);return t.version=this._version,this._result=e.getResult(t),this._result}}]),i}(Jl);dc.formats=["fbx"],dc.SourceClass=Fs;var pc,mc,vc,yc,_c,gc,xc,bc,wc,Sc,Rc,Cc,kc,Ac,Ec={loaders:na,parsers:Ql,exporters:new Kl([tc,dc])},Pc=new i.Q1f,Tc=function(){function e(){s(this,e),this._width=0,this._height=0,this._widthHalf=0,this._heightHalf=0,this._vector=new i.Pq0,this._viewMatrix=new i.kn4,this._projectionMatrix=new i.kn4,this._domElement=document.createElement("div"),this._domElement.style.overflow="hidden",this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.zIndex="0",this._domElement.style.pointerEvents="none"}return l(e,[{key:"getElement",value:function(){return this._domElement}},{key:"reset",value:function(){for(var e=this.getElement();e.firstChild;)e.removeChild(e.firstChild)}},{key:"setSize",value:function(e,t){this._width=e,this._height=t,this._widthHalf=this._width/2,this._heightHalf=this._height/2,this._domElement.style.width="".concat(e,"px"),this._domElement.style.height="".concat(t,"px")}},{key:"_renderObject",value:function(e,t,r){function n(e,t,r){return Pc.setHex(e),Pc.lerp(t,r),"#".concat(Pc.getHexString())}function o(e){return Pc.setHex(e),"#".concat(Pc.getHexString())}if(e instanceof pr){if(this._vector.setFromMatrixPosition(e.matrixWorld),void 0!==e.userData&&void 0!==e.userData.offset){var s=new i.Pq0(e.userData.offset.x,e.userData.offset.y,0);this._vector.add(s.multiplyScalar(e.matrixWorld.getMaxScaleOnAxis()))}this._vector.applyMatrix4(this._viewMatrix);var a=this._vector.z>-t.near?"hidden":"visible",l=1e4*(t.far- -this._vector.z)/(t.far-t.near),c=e.getElement();if(void 0===r.fog)c.style.color=o(e.userData.color),"transparent"!==e.userData.background&&(c.style.background=o(e.userData.background));else{var u=i.cj9.smoothstep(-this._vector.z,r.fog.near,r.fog.far);c.style.color=n(e.userData.color,r.fog.color,u),"transparent"!==e.userData.background&&(c.style.background=n(e.userData.background,r.fog.color,u))}this._vector.applyMatrix4(this._projectionMatrix);var h="".concat(e.userData!=={}?e.userData.translation:"translate(-50%, -50%) ","translate(").concat(this._vector.x*this._widthHalf+this._widthHalf,"px,").concat(-this._vector.y*this._heightHalf+this._heightHalf,"px)");c.style.visibility=a,c.style.WebkitTransform=h,c.style.MozTransform=h,c.style.oTransform=h,c.style.transform=h,c.style.zIndex=Number(l).toFixed(0),c.parentNode!==this._domElement&&this._domElement.appendChild(c)}for(var f=0,d=e.children.length;f<d;f++)this._renderObject(e.children[f],t,r)}},{key:"render",value:function(e,t){e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.copy(t.matrixWorld).invert(),this._viewMatrix.copy(t.matrixWorldInverse),this._projectionMatrix.copy(t.projectionMatrix),this._renderObject(e,t,e)}}]),e}(),Mc=-1,Ic=new i.PTz,Nc=new i.kn4;function Oc(e,t,r,n){this.objects=e;var o=v(e,1);this.object=o[0],this.camera=t,this.pivot=r,this.axis=new i.Pq0(0,0,1),this.options=n,this.lastRotation={axis:new i.Pq0,angle:0}}function Lc(e,t,r,n,o){I.call(this);var s=this;this.object=e,this.objectPivot=t,this.camera=r,this.domElement=void 0!==n?n:document,this.getAltObj=o,this.enabled=!0,this.hotkeysEnabled=!0,this.screen={left:0,top:0,width:0,height:0},this.options={rotateFactor:Math.PI,axisRotateFactor:4*Math.PI,intertia:!0,dynamicDampingFactor:.1,intertiaThreshold:.001},this._state=Mc,this._mousePrevPos=new i.I9Y,this._mouseCurPos=new i.I9Y,this._mainObj=new Oc([this.object],this.camera,new i.Pq0(0,0,0),this.options),this._altObj=new Oc([this.object],this.camera,new i.Pq0(0,0,0),this.options),this._affectedObj=this._mainObj,this._isAltObjFreeRotationAllowed=!0,this._isTranslationAllowed=!0,this._isKeysTranslatingObj=!1,this._pressedKeys=[],this._clock=new C,this._clock.start(),this._lastUpdateTime=this._clock.getElapsedTime(),this._listeners=[{obj:s.domElement,type:"mousedown",handler:function(e){s.mousedown(e)}},{obj:s.domElement,type:"mouseup",handler:function(e){s.mouseup(e)}},{obj:s.domElement,type:"mousemove",handler:function(e){s.mousemove(e)}},{obj:s.domElement,type:"mousewheel",handler:function(e){s.mousewheel(e)}},{obj:s.domElement,type:"DOMMouseScroll",handler:function(e){s.mousewheel(e)}},{obj:s.domElement,type:"mouseout",handler:function(e){s.mouseup(e)}},{obj:s.domElement,type:"touchstart",handler:function(e){s.touchstartend(e)}},{obj:s.domElement,type:"touchend",handler:function(e){s.touchstartend(e)}},{obj:s.domElement,type:"touchmove",handler:function(e){s.touchmove(e)}},{obj:s.getKeyBindObject(),type:"keydown",handler:function(e){s.keydownup(e)}},{obj:s.getKeyBindObject(),type:"keyup",handler:function(e){s.keydownup(e)}},{obj:window,type:"resize",handler:function(){s.handleResize()}},{obj:window,type:"blur",handler:function(){s.resetKeys()}},{obj:s.domElement,type:"contextmenu",handler:function(e){s.contextmenu(e)}}];for(var a=0;a<this._listeners.length;a++){var l=this._listeners[a];l.obj.addEventListener(l.type,l.handler)}this.handleResize(),this.resetKeys(),this.update()}function Bc(e,t,r){I.call(this);var n=this;this.gfxObj=e,this.camera=t,this.domElement=void 0!==r?r:document,this.screen={left:0,top:0,width:0,height:0},this._lastMousePos=new i.I9Y(0,0),this._mouseTotalDist=0,this._lastClickBeginTime=-1e3,this._lastClickPos=new i.I9Y(0,0),this._clickBeginTime=0,this._clock=new C,this._clock.start(),this._listeners=[{obj:n.domElement,type:"mousedown",handler:function(e){n.mousedown(e)}},{obj:n.domElement,type:"mouseup",handler:function(e){n.mouseup(e)}},{obj:n.domElement,type:"mousemove",handler:function(e){n.mousemove(e)}},{obj:n.domElement,type:"touchstart",handler:function(e){n.touchstart(e)}},{obj:n.domElement,type:"touchend",handler:function(e){n.touchend(e)}},{obj:window,type:"resize",handler:function(){n.handleResize()}}];for(var o=0;o<this._listeners.length;o++){var s=this._listeners[o];s.obj.addEventListener(s.type,s.handler)}this.handleResize()}Oc.prototype._rotate=function(){var e=new i.Pq0,t=new i.PTz,r=new i.Pq0,n=new i.kn4;return function(i){var o=0===this.pivot.x&&0===this.pivot.y&&0===this.pivot.z;if(n.copy(this.object.matrix),o?n.multiply(Nc.makeRotationFromQuaternion(i)):(n.multiply(Nc.makeTranslation(this.pivot.x,this.pivot.y,this.pivot.z)),n.multiply(Nc.makeRotationFromQuaternion(i)),n.multiply(Nc.makeTranslation(-this.pivot.x,-this.pivot.y,-this.pivot.z))),n.decompose(e,t,r),!o)for(var s=0;s<this.objects.length;++s)this.objects[s].position.copy(e);for(var a=0;a<this.objects.length;++a)this.objects[a].quaternion.copy(t),this.objects[a].updateMatrix()}}(),Oc.prototype.setObjects=function(e){this.objects=e;var t=v(e,1);this.object=t[0]},Oc.prototype.rotate=(pc={axis:new i.Pq0,angle:0},function(e,t,r,n){this.mouse2rotation(pc,t,r,n),e.setFromAxisAngle(pc.axis,pc.angle),pc.angle&&this._rotate(e),this.lastRotation=pc}),Oc.prototype.translate=(mc=new i.Pq0,vc=new i.Pq0,function(e){mc.set(e.x/this.camera.projectionMatrix.elements[0],e.y/this.camera.projectionMatrix.elements[5],0);var t=mc.length();mc.normalize(),mc.transformDirection(Nc.copy(this.object.matrixWorld).invert()),vc.copy(this.pivot),this.object.localToWorld(vc),t*=Math.abs(vc.z-this.camera.position.z),t/=this.object.matrixWorld.getMaxScaleOnAxis();for(var r=0;r<this.objects.length;++r)this.objects[r].translateOnAxis(mc,t)}),Oc.prototype.update=(yc=new i.Pq0,function(e,t){if(0!==J.now.autoRotation)return J.now.autoRotationAxisFixed||0===this.lastRotation.axis.length()?yc.set(0,1,0).transformDirection(Nc.copy(this.object.matrixWorld).invert()):yc.copy(this.lastRotation.axis),this._rotate(Ic.setFromAxisAngle(yc,J.now.autoRotation*e)),!0;if(this.options.intertia&&this.lastRotation.angle){var r=this.lastRotation.angle*Math.pow(1-this.options.dynamicDampingFactor,40*t);if(!(Math.abs(r)<=this.options.intertiaThreshold))return this._rotate(Ic.setFromAxisAngle(this.lastRotation.axis,r)),!0;this.lastRotation.angle=0}return!1}),Oc.prototype.stop=function(){this.lastRotation.angle=0},Oc.prototype.mouse2rotation=(_c=new i.Pq0,gc=new i.Pq0,xc=new i.Pq0,bc=new i.Pq0,wc=new i.Pq0,Sc=new i.Pq0,Rc=new i.I9Y,function(e,t,r,n){if(n)e.axis.copy(this.axis),e.angle=this.options.axisRotateFactor*(r.y-t.y);else{Rc.subVectors(r,t);var i=Rc.length();if(0===i)return;_c.copy(this.pivot),this.object.localToWorld(_c),gc.subVectors(this.camera.position,_c),xc.copy(gc).normalize(),bc.copy(this.camera.up).normalize(),wc.crossVectors(bc,xc).normalize(),bc.setLength(Rc.y),wc.setLength(Rc.x),Sc.copy(bc.add(wc)),e.axis.crossVectors(Sc,gc),e.angle=-i*this.options.rotateFactor}e.axis.transformDirection(Nc.copy(this.object.matrixWorld).invert()),e.angle<0&&(e.axis.negate(),e.angle=-e.angle)}),Lc.prototype=Object.create(I.prototype),Lc.prototype.constructor=Lc,Lc.prototype.resetKeys=function(){this._pressedKeys[37]=!1,this._pressedKeys[38]=!1,this._pressedKeys[39]=!1,this._pressedKeys[40]=!1},Lc.prototype.contextmenu=function(e){e.stopPropagation(),e.preventDefault()},Lc.prototype.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},Lc.prototype.enable=function(e){this.enabled=e},Lc.prototype.enableHotkeys=function(e){this.hotkeysEnabled=e},Lc.prototype.allowTranslation=function(e){this._isTranslationAllowed=e},Lc.prototype.allowAltObjFreeRotation=function(e){this._isAltObjFreeRotationAllowed=e},Lc.prototype.keysTranslateObj=function(e){this._isKeysTranslatingObj=e},Lc.prototype.isEditingAltObj=function(){return(0===this._state||1===this._state)&&this._affectedObj===this._altObj},Lc.prototype.convertMouseToOnCircle=function(e,t,r){var n=Math.min(this.screen.width,this.screen.height);0!==n?e.set((t-.5*this.screen.width-this.screen.left)/n,(.5*this.screen.height+this.screen.top-r)/n):e.set(0,0)},Lc.prototype.convertMouseToViewport=function(e,t,r){0!==this.screen.width&&0!==this.screen.height?e.set(2*(t-.5*this.screen.width-this.screen.left)/this.screen.width,2*(.5*this.screen.height+this.screen.top-r)/this.screen.height):e.set(0,0)},Lc.prototype.stop=function(){this._mainObj.stop(),this._altObj.stop()},Lc.prototype.rotateByMouse=(Cc=new i.PTz,function(e){this._affectedObj.rotate(Cc,this._mousePrevPos,this._mouseCurPos,e),this.dispatchEvent({type:"change",action:"rotate",quaternion:Cc})}),Lc.prototype.rotate=function(e){this.object.quaternion.multiply(e),this.dispatchEvent({type:"change",action:"rotate",quaternion:e})},Lc.prototype.getOrientation=function(){return this.object.quaternion},Lc.prototype.setOrientation=function(e){this.object.quaternion.copy(e)},Lc.prototype.translate=(kc=new i.I9Y,function(){kc.subVectors(this._mouseCurPos,this._mousePrevPos),this._affectedObj.translate(kc),this.dispatchEvent({type:"change",action:"translate"})}),Lc.prototype.getScale=function(){return this.object.scale.x},Lc.prototype.setScale=function(e){this.object.scale.set(e,e,e)},Lc.prototype.scale=function(e){e<=0||(this.setScale(this.object.scale.x*e),this.dispatchEvent({type:"change",action:"zoom",factor:e}))},Lc.prototype.update=(Ac=new i.I9Y,function(){var e=this._clock.getElapsedTime(),t=e-this._lastUpdateTime;if(this._state===Mc){var r=e-this._lastMouseMoveTime;(this._mainObj.update(t,r)||this._altObj.update(t,r))&&this.dispatchEvent({type:"change",action:"auto"})}if(this._isKeysTranslatingObj){var n=Number(this._pressedKeys[39])-Number(this._pressedKeys[37]),i=Number(this._pressedKeys[38])-Number(this._pressedKeys[40]);if(0!==n||0!==i){var o=t,s=this.getAltObj();s.objects.length>0&&(this._altObj.setObjects(s.objects),this._altObj.pivot=s.pivot,"axis"in s?this._altObj.axis=s.axis.clone():this._altObj.axis.set(0,0,1),Ac.set(o*n,o*i),this._altObj.translate(Ac),this.dispatchEvent({type:"change",action:"translate"}))}}this._lastUpdateTime=e}),Lc.prototype.reset=function(){this._state=Mc,this.object.quaternion.copy(Ic.set(0,0,0,1))},Lc.prototype.mousedown=function(e){if(!1!==this.enabled&&this._state===Mc){if(e.preventDefault(),e.stopPropagation(),this._state===Mc)if(0===e.button){this._affectedObj.stop();var t=!1;if(e.altKey){var r=this.getAltObj();(t=r.objects.length>0)&&(this._altObj.setObjects(r.objects),this._altObj.pivot=r.pivot,"axis"in r?this._altObj.axis=r.axis.clone():this._altObj.axis.set(0,0,1))}this._affectedObj=t?this._altObj:this._mainObj,this._state=t&&e.ctrlKey&&this._isTranslationAllowed?1:0}else 2===e.button&&(this._state=3);0===this._state&&(this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos)),1!==this._state&&3!==this._state||(this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this._mousePrevPos.copy(this._mouseCurPos))}},Lc.prototype.mousemove=function(e){if(!1!==this.enabled&&this._state!==Mc)switch(e.preventDefault(),e.stopPropagation(),this._state){case 0:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.pageX,e.pageY),this.rotateByMouse(e.altKey&&!this._isAltObjFreeRotationAllowed||e.shiftKey),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case 1:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translate();break;case 3:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToViewport(this._mouseCurPos,e.pageX,e.pageY),this.translatePivotByMouse()}},Lc.prototype.mousewheel=function(e){if(!1!==this.enabled&&J.now.zooming&&this._state===Mc&&!e.shiftKey){e.preventDefault();var t=0;e.wheelDelta?t=e.wheelDelta/40:e.detail&&(t=-e.detail/3);var r=1+.05*t;r=Math.max(r,.01),this.scale(r)}},Lc.prototype.mouseup=function(e){!1!==this.enabled&&this._state!==Mc&&(e.preventDefault(),e.stopPropagation(),this._state=Mc,this._clock.getElapsedTime()-this._lastMouseMoveTime>.1&&this._affectedObj.stop())},Lc.prototype.touchstartend=function(e){if(!1!==this.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:this._state=0,this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this._mousePrevPos.copy(this._mouseCurPos);break;case 2:this._mainObj.stop(),this._altObj.stop(),this._state=2;var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=this._touchDistanceStart=Math.sqrt(t*t+r*r),this._scaleStart=this.object.scale.x;break;default:this._state=Mc}},Lc.prototype.touchmove=function(e){if(!1!==this.enabled&&this._state!==Mc)switch(e.preventDefault(),e.stopPropagation(),this._state){case 0:this._mousePrevPos.copy(this._mouseCurPos),this.convertMouseToOnCircle(this._mouseCurPos,e.touches[0].pageX,e.touches[0].pageY),this.rotateByMouse(!1),this._lastMouseMoveTime=this._clock.getElapsedTime();break;case 2:if(J.now.zooming){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY;this._touchDistanceCur=Math.sqrt(t*t+r*r);var n=this._scaleStart*this._touchDistanceCur/this._touchDistanceStart/this.object.scale.x;this.scale(n)}}},Lc.prototype.keydownup=function(e){if(!1!==this.enabled&&!1!==this.hotkeysEnabled)switch(e.keyCode){case 37:case 38:case 39:case 40:this._pressedKeys[e.keyCode]="keydown"===e.type,e.preventDefault(),e.stopPropagation()}},Lc.prototype.getKeyBindObject=function(){return window.top},Lc.prototype.dispose=function(){for(var e=0;e<this._listeners.length;e++){var t=this._listeners[e];t.obj.removeEventListener(t.type,t.handler)}},Lc.prototype.translatePivotByMouse=function(){var e=new i.I9Y;return function(){e.subVectors(this._mouseCurPos,this._mousePrevPos),this.translatePivotInWorld(J.now.translationSpeed*e.x,J.now.translationSpeed*e.y,0)}}(),Lc.prototype.translatePivotInWorld=function(e,t,r){var n=this.objectPivot.position;n.applyMatrix4(this.object.matrixWorld),n.setX(n.x+e),n.setY(n.y+t),n.setZ(n.z+r),n.applyMatrix4(Nc.copy(this.object.matrixWorld).invert()),this.dispatchEvent({type:"change",action:"translatePivot"})},Lc.prototype.translatePivot=function(e,t,r){var n=this.objectPivot.position;n.setX(n.x+e),n.setY(n.y+t),n.setZ(n.z+r),this.dispatchEvent({type:"change",action:"translatePivot"})},Lc.prototype.setPivot=function(e){this.objectPivot.position.copy(e),this.dispatchEvent({type:"change",action:"translatePivot"})},Bc.prototype=Object.create(I.prototype),Bc.prototype.constructor=Bc,Bc.prototype.reset=function(){this.picked={},this.dispatchEvent({type:"newpick",obj:{}})},Bc.prototype.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},Bc.prototype.pickObject=function(e){if(!this.gfxObj)return this.picked={},void this.dispatchEvent({type:"newpick",obj:{}});var t=this.gfxObj,r=new i.tBo;r.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),r.ray.direction.set(e.x,e.y,.5).unproject(this.camera).sub(r.ray.origin).normalize();var n=J.now.draft.clipPlane&&this.clipPlaneValue?this.clipPlaneValue:1/0,o=J.now.fog&&this.fogFarValue?this.fogFarValue:1/0,s=r.intersectVisibleObject(t,this.camera,n,o);if(!s)return this.picked={},void this.dispatchEvent({type:"newpick",obj:{}});var a={};if(s.residue||s.atom){var l=s.residue||s.atom.residue;"chain"===J.now.pick?a={chain:l.getChain()}:"molecule"===J.now.pick?a={molecule:l.getMolecule()}:s.residue||"residue"===J.now.pick?a={residue:l}:s.atom&&(a={atom:s.atom})}this.picked=a,this.dispatchEvent({type:"newpick",obj:a})},Bc.prototype.getMouseInViewport=function(e,t){return new i.I9Y((e-this.screen.left)/this.screen.width*2-1,-(t-this.screen.top)/this.screen.height*2+1)},Bc.prototype.mousedown=function(e){e.preventDefault(),e.stopPropagation(),0===e.button&&(this._lastMousePos=this.getMouseInViewport(e.pageX,e.pageY),this._mouseTotalDist=0,this._clickBeginTime=this._clock.getElapsedTime())},Bc.prototype.mousemove=function(e){e.preventDefault(),e.stopPropagation();var t=this.getMouseInViewport(e.pageX,e.pageY);this._mouseTotalDist+=t.sub(this._lastMousePos).length()},Bc.prototype.mouseup=function(e){var t=this;if(e.preventDefault(),e.stopPropagation(),0===e.button&&this._mouseTotalDist<.01){var r=this._clock.getElapsedTime(),n=this.getMouseInViewport(e.pageX,e.pageY);if(r-this._lastClickBeginTime<.7&&(new i.I9Y).subVectors(n,this._lastClickPos).length()<.01)return this.dispatchEvent({type:"dblclick",obj:this.picked}),this._lastClickPos=n,void(this._lastClickBeginTime=-1e3);setTimeout((function(){t.pickObject(n)}),0),this._lastClickPos=n,this._lastClickBeginTime=this._clickBeginTime}},Bc.prototype.touchstart=function(e){e.preventDefault(),e.stopPropagation(),1===e.touches.length&&(this._lastTouchdownPos=this.getMouseInViewport(e.touches[0].pageX,e.touches[0].pageY))},Bc.prototype.touchend=function(e){var t=this;e.preventDefault(),e.stopPropagation(),0===e.touches.length&&1===e.changedTouches.length&&this.getMouseInViewport(e.changedTouches[0].pageX,e.changedTouches[0].pageY).sub(this._lastTouchdownPos).length()<.01&&setTimeout((function(){t.pickObject(t._lastTouchdownPos)}),0)},Bc.prototype.dispose=function(){for(var e=0;e<this._listeners.length;e++){var t=this._listeners[e];t.obj.removeEventListener(t.type,t.handler)}};var Dc=function(){function e(t,r){s(this,e),this._target=t,this._targetCamera=r,this._camera=new i.ubm(r.fov,r.aspect,1,100),this._object=new i.IzY(1),this._scene=new i.Z58,this._scene.add(this._object),this._full=new i.I9Y,this._update()}return l(e,[{key:"_update",value:function(){var e=this._targetCamera.fov,t=this._camera;t.aspect=this._targetCamera.aspect,t.setMinimalFov(e),t.setDistanceToFit(1,e),t.updateProjectionMatrix(),this._object.quaternion.copy(this._target.quaternion)}},{key:"render",value:function(e){this._update(),e.getSize(this._full);var t=.25*this._full.width,r=.25*this._full.height,n=e.autoClear;e.autoClear=!1,e.setViewport(0,0,t,r),e.clear(!1,!0,!1),e.render(this._scene,this._camera),e.setViewport(0,0,this._full.width,this._full.height),e.autoClear=n}}]),e}(),zc=["helix","strand"],Fc=["fs","ps","ns","us"];function Vc(e,t){for(var r=t._residues,n=r.length,i=new Uint8Array(n),o=t._atoms,s=0,a=e.length;s<a;++s)i[o[s].residue._index]=e[s];for(var l=[],c=0;c<n;){if(0!==i[c]){for(var u=c,h=i[c];c<n-1&&i[c+1]===h&&r[c].isConnected(r[c+1]);)++c;l.push({start:u,end:c,type:zc[h-1]})}++c}return l}function Uc(e){return e>=524288?e-1048576:e}var jc=function(){function e(t,r,n){s(this,e),this._complex=t,this._secondary=null,this.isLoading=!1,this._framesRange={start:0,end:-1},this.frameIsReady=!1,this._buffer=null,this._frameRequest=null,this._callbacks=n,"function"==typeof r?(this._framesRequestLength=1,this._downloadDataFn=r):this.parseBinaryData(r,!0),this.reset(),this.setFrame(0)}return l(e,[{key:"_prepareBuffer",value:function(e,t){if(null==e&&(e=0),null==t&&(t=e+this._framesRequestLength),void 0!==this._framesCount&&(t=Math.min(this._framesCount-1,t)),this._downloadDataFn){var r=this;this._buffer||(this._buffer={}),this._buffer.state="downloading",this.isLoading=!0,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),this._downloadDataFn({start:e,end:t+1},(function(n){if(r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onLoadStatusChanged&&r._callbacks.onLoadStatusChanged(),r._buffer={data:n,state:"ready",start:e,end:t},null!==r._frameRequest){var i=r._frameRequest;r._frameRequest=null,r.setFrame(i)}}),(function(){r.isLoading=!1,r._callbacks&&"function"==typeof r._callbacks.onError&&r._callbacks.onError("Streaming failed")}))}}},{key:"_parseBuffer",value:function(){if(this._buffer&&"ready"===this._buffer.state){this._framesRange={start:this._buffer.start,end:this._buffer.end},this.parseBinaryData(this._buffer.data,!1);var e=(this._buffer.end+1)%this._framesCount;if(e>=this._framesCount&&(e=0),this._buffer={state:"none"},this._prepareBuffer(e,e+this._framesRequestLength),null!==this._frameRequest){var t=this._frameRequest;this._frameRequest=null,this.setFrame(t)}}}},{key:"parseBinaryData",value:function(e){var t=new DataView(e),r=0,n=t.getUint32(r,!0);r+=4;var i=t.getUint32(r,!0);this._framesCount=i,this._framesRange.end=this._framesRange.end>0?Math.min(this._framesRange.end,i-1):i-1,r+=4,this._atomsCount=n,this._framesRequestLength=Math.ceil(1048576/(8*n));var o=this._framesRange.end-this._framesRange.start+1;if(n!==this._complex._atoms.length||e.byteLength!==12+o*n*8)throw new Error;for(var s=this._complex,a=t.getUint32(r,!0),l=0;a>1e3&&l<Fc.length-1;)a/=1e3,++l;this._timeStep="".concat(a.toString()," ").concat(Fc[l]),r+=4;for(var c=[],u=new Float32Array(o*n*3),h=0,f=new Int8Array(n),d=0;d<o;++d){for(var p=0;p<n;++p){var m=t.getUint32(r,!0);r+=4;var v=t.getUint32(r,!0);r+=4;var y=(4026531840&v)>>>28,_=Uc((268435200&v)>>>8|0),g=Uc((255&v)<<12|(4293918720&m)>>>20),x=Uc(1048575&m);f[p]=0,y>0&&y<4?f[p]=1:4===y&&(f[p]=2),u[h++]=_/100,u[h++]=g/100,u[h++]=x/100}c.push(Vc(f,s))}this._secondaryData=c,this._data=u}},{key:"nextFrame",value:function(){this.setFrame((this._currFrame+1)%this._framesCount)}},{key:"needsColorUpdate",value:function(e){return e instanceof cs}},{key:"getAtomColor",value:function(e,t){return e.getResidueColor(this._residues[t.residue._index],this._complex)}},{key:"getResidueColor",value:function(e,t){return e.getResidueColor(this._residues[t._index],this._complex)}},{key:"_updateSecondary",value:function(){var e,t=this._residues,r=t.length;for(e=0;e<r;++e)t[e]._secondary=null;var n=this._secondaryData[this._currFrame-this._framesRange.start];for(e=0,r=n.length;e<r;++e)for(var i=n[e],o=i.start,s=i.end,a={_start:t[o],_end:t[s],type:i.type,generic:i.generic},l=o;l<=s;++l)t[l]._secondary=a}},{key:"reset",value:function(){var e=this._complex._residues,t=e.length;this._residues=new Array(t);for(var r=this._residues,n=function(){return this._secondary},i=0;i<t;++i)r[i]={_type:e[i]._type,_isValid:e[i]._isValid,_controlPoint:null,_wingVector:null,_secondary:null,getSecondary:n}}},{key:"setFrame",value:function(e){if(this.frameIsReady=!1,e>=this._framesRange.start&&e<=this._framesRange.end)this._currFrame=e,this._cachedResidues=!1,this._updateSecondary(),this.frameIsReady=!0;else if(this._frameRequest=e,this._buffer)switch(this._buffer.state){case"none":this._prepareBuffer(e);break;case"ready":this._parseBuffer()}else this._prepareBuffer(e)}},{key:"disableEvents",value:function(){this._callbacks=null}},{key:"getAtomPos",value:function(t){var r=e._vec,n=this,i=n._data,o=3*(n._atomsCount*(n._currFrame-n._framesRange.start)+t);return r.set(i[o],i[o+1],i[o+2]),r}},{key:"getResidues",value:function(){return this._cachedResidues||this._complex.updateToFrame(this),this._residues}}]),e}();Se(jc,"_vec",new i.Pq0);var Gc=function(){function e(t,r){if(s(this,e),this.constructor===e)throw new Error("Can not instantiate abstract class!");this.params=t,this.opts=(0,n.merge)($.deriveDeep(J.now.objects[this.type],!0),r),this.needsRebuild=!1,this._mesh=null,this.id=null}return l(e,[{key:"identify",value:function(){var e={type:this.type,params:this.params},t=$.objectsDiff(this.opts,J.now.modes[this.id]);return(0,n.isEmpty)(t)||(e.opts=t),e}},{key:"toString",value:function(){return"o=".concat(this.type,",").concat(this.params.join(","))+$.compareOptionsWithDefaults(this.opts,J.defaults.objects[this.type])}},{key:"getGeometry",value:function(){return this._mesh}},{key:"destroy",value:function(){this._mesh&&kr.destroyObject(this._mesh)}}]),e}();Gc.prototype.type="__";var Hc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e,t){var r;if(s(this,o),r=n.call(this,e,t),e.length<2)throw new Error("Wrong number of argumets on line object creation!");var i=v(e,2);return r._id1=i[0],r._id2=i[1],r}return l(o,[{key:"_getAtomFromName",value:function(e,t){var r=e.getAtomByFullname(t);if(!r)throw new Error(t+" - Wrong atom format it must be '#CHAIN_NAME.#RESIDUE_NUMBER.#ATOM_NAME' (e.g. 'A.38.CO1')");return r}},{key:"build",value:function(e){var t=new i.LoY;this._atom1=this._getAtomFromName(e,this._id1),this._atom2=this._getAtomFromName(e,this._id2);var r=this._atom1.position,n=this._atom2.position,o=new Float32Array([r.x,r.y,r.z,n.x,n.y,n.z]);t.setAttribute("position",new i.THS(o,3)),t.computeBoundingBox();var s=new li;s.setValues({lights:!1,overrideColor:!0,dashedLine:!0,fogTransparent:J.now.bg.transparent}),this._line=new xi.Line(t,s),this._line.computeLineDistances(),this._line.material.setUberOptions({fixedColor:new i.Q1f(this.opts.color),dashedLineSize:this.opts.dashSize,dashedLinePeriod:this.opts.dashSize+this.opts.gapSize}),this._line.material.updateUniforms(),this._line.raycast=function(e,t){},this._mesh=this._line;var a=e.getTransforms();a.length>0&&(this._mesh=new i.YJl,this._mesh.add(this._line),Es.applyTransformsToMeshes(this._mesh,a))}},{key:"updateToFrame",value:function(e){if(this._atom1&&this._atom2&&this._line){var t=this._line.geometry;t.vertices[0].copy(e.getAtomPos(this._atom1.index)),t.vertices[1].copy(e.getAtomPos(this._atom2.index)),this._line.computeLineDistances(),t.computeBoundingSphere(),t.verticesNeedUpdate=!0}}}]),o}(Gc);Hc.prototype.constructor=Hc,Hc.prototype.type="line";var qc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;s(this,o),t=n.call(this,e);var r={uniforms:{srcTex:{type:"t",value:null},srcDepthTex:{type:"t",value:null},srcTexSize:{type:"v2",value:new i.I9Y(512,512)},color:{type:"v3",value:null},threshold:{type:"f",value:null},opacity:{type:"f",value:1},thickness:{type:"v2",value:new i.I9Y(1,1)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexSize;\r\nuniform vec2 thickness;\r\nvarying vec2 vUv;\r\n\r\n#ifdef DEPTH_OUTLINE\r\n uniform sampler2D srcDepthTex; //depthTexture\r\n uniform vec3 color;\r\n uniform float threshold;\r\n#endif\r\n\r\nvoid main() {\r\n\r\n vec2 pixelSize = thickness / srcTexSize;\r\n\r\n #ifdef DEPTH_OUTLINE\r\n float c00 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,-pixelSize.y)).x;\r\n float c01 = texture2D(srcDepthTex, vUv + vec2(0,-pixelSize.y)).x;\r\n float c02 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,-pixelSize.y)).x;\r\n float c10 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,0)).x;\r\n float c12 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,0)).x;\r\n float c20 = texture2D(srcDepthTex, vUv + vec2(-pixelSize.x,pixelSize.y)).x;\r\n float c21 = texture2D(srcDepthTex, vUv + vec2(0,pixelSize.y)).x;\r\n float c22 = texture2D(srcDepthTex, vUv + vec2(pixelSize.x,pixelSize.y)).x;\r\n\r\n float horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n float vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n float grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n\r\n gl_FragColor = ( grad > threshold ) ? vec4(color.rgb, 1.0) : gl_FragColor = texture2D(srcTex, vUv);\r\n\r\n #else\r\n vec4 c00 = texture2D(srcTex, vUv + vec2(-pixelSize.x,-pixelSize.y));\r\n vec4 c01 = texture2D(srcTex, vUv + vec2(0,-pixelSize.y));\r\n vec4 c02 = texture2D(srcTex, vUv + vec2(pixelSize.x,-pixelSize.y));\r\n vec4 c10 = texture2D(srcTex, vUv + vec2(-pixelSize.x,0));\r\n vec4 c12 = texture2D(srcTex, vUv + vec2(pixelSize.x,0));\r\n vec4 c20 = texture2D(srcTex, vUv + vec2(-pixelSize.x,pixelSize.y));\r\n vec4 c21 = texture2D(srcTex, vUv + vec2(0,pixelSize.y));\r\n vec4 c22 = texture2D(srcTex, vUv + vec2(pixelSize.x,pixelSize.y));\r\n\r\n vec4 horizEdge = - c00 - 2.0 * c01 - c02 + c20 + 2.0 * c21 + c22;\r\n vec4 vertEdge = - c00 - 2.0 * c10 - c20 + c02 + 2.0 * c12 + c22;\r\n\r\n vec4 grad = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);\r\n gl_FragColor = grad;\r\n #endif\r\n}\r\n",transparent:!0,depthTest:!1,depthWrite:!1};return t.setValues(r),t}return l(o,[{key:"copy",value:function(e){We(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){We(d(o.prototype),"setValues",this).call(this,e);var t={};this.depth&&(t.DEPTH_OUTLINE=1),this.defines=t}}}]),o}(i.D$Q);qc.prototype.depth=!1;var Wc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return s(this,o),(t=n.call(this,e)).setValues({uniforms:{srcTex:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.I9Y(1/512,1/512)},bgColor:{type:"c",value:new i.Q1f(16777215)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\n// edge end finding algorithm parameters\r\n#define FXAA_QUALITY_PS 8\r\n#define FXAA_QUALITY_P0 1.0\r\n#define FXAA_QUALITY_P1 1.5\r\n#define FXAA_QUALITY_P2 2.0\r\n#define FXAA_QUALITY_P3 2.0\r\n#define FXAA_QUALITY_P4 2.0\r\n#define FXAA_QUALITY_P5 2.0\r\n#define FXAA_QUALITY_P6 4.0\r\n#define FXAA_QUALITY_P7 12.0\r\n// constants\r\nfloat fxaaQualityEdgeThreshold = 0.125;\r\nfloat fxaaQualityEdgeThresholdMin = 0.0625;\r\nfloat fxaaQualitySubpix = 0.7; //0.65;\r\n// global params\r\nuniform sampler2D srcTex;\r\nuniform vec2 srcTexelSize;\r\nuniform vec3 bgColor;\r\n// from vs\r\nvarying vec2 vUv;\r\n//=====================================================================//\r\n// calc luminance from rgb\r\n//'float FxaaLuma(vec3 rgb) {return rgb.y * (0.587/0.299) + rgb.x; } // Lotte's idea about game luminance\r\nfloat FxaaLuma(vec3 rgb) {return dot(rgb, vec3(0.299, 0.587, 0.114)); } // real luminance calculation\r\n // for non-real scene rendering\r\n// texture sampling by pixel position(coords) and offset(in pixels)\r\n vec3 FxaaTex(sampler2D tex, vec2 pos, vec2 off, vec2 res ) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos + off * res );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos + off * res ).xyz;\r\n #endif\r\n}\r\nvec3 FxaaTexTop(sampler2D tex, vec2 pos) {\r\n #ifdef BG_TRANSPARENT\r\n vec4 color = texture2D( tex, pos );\r\n return mix(color.rgb, bgColor, 1.0 - color.a);\r\n #else\r\n return texture2D( tex, pos).xyz;\r\n #endif\r\n}\r\nvec4 FxaaTexTopAlpha(sampler2D tex, vec2 pos) {\r\n return texture2D( tex, pos);\r\n}\r\n\r\n//=====================================================================//\r\nvoid main() {\r\n // renaming\r\n vec2 posM = vUv;\r\n // get luminance for neighbours\r\n float lumaS = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, 1.0 ), srcTexelSize));\r\n float lumaE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 0.0 ), srcTexelSize));\r\n float lumaN = FxaaLuma(FxaaTex(srcTex, posM, vec2( 0.0, -1.0 ), srcTexelSize));\r\n float lumaW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 0.0 ), srcTexelSize));\r\n float lumaM = FxaaLuma(FxaaTexTop(srcTex, posM));\r\n // find max and min luminance\r\n float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM)));\r\n float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM)));\r\n // calc maximum non-edge range\r\n float rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\r\n float range = rangeMax - rangeMin;\r\n float rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\r\n // exit when luma contrast is small (is not edge)\r\n if(range < rangeMaxClamped){\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n return;\r\n }\r\n float subpixRcpRange = 1.0/range;\r\n // note: the sampling coordinates can be calculated in vertex shader but the approach doesn't affect performance\r\n // visibly, thus we decided to leave calculation here for better readability.\r\n // calc other neighbours luminance\r\n float lumaNE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, -1.0 ), srcTexelSize));\r\n float lumaSW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, 1.0 ), srcTexelSize));\r\n float lumaSE = FxaaLuma(FxaaTex(srcTex, posM, vec2( 1.0, 1.0 ), srcTexelSize));\r\n float lumaNW = FxaaLuma(FxaaTex(srcTex, posM, vec2( -1.0, -1.0 ), srcTexelSize));\r\n/*--------------span calculation and subpix amount calulation-----------------*/\r\n float lumaNS = lumaN + lumaS;\r\n float lumaWE = lumaW + lumaE;\r\n float subpixNSWE = lumaNS + lumaWE;\r\n float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\r\n float edgeVert1 = (-2.0 * lumaM) + lumaWE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNESE = lumaNE + lumaSE;\r\n float lumaNWNE = lumaNW + lumaNE;\r\n float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\r\n float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\r\n/*--------------------------------------------------------------------------*/\r\n float lumaNWSW = lumaNW + lumaSW;\r\n float lumaSWSE = lumaSW + lumaSE;\r\n float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\r\n float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\r\n float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\r\n float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\r\n float edgeHorz = abs(edgeHorz3) + edgeHorz4;\r\n float edgeVert = abs(edgeVert3) + edgeVert4;\r\n/*--------------------subpix amount calulation------------------------------*/\r\n float subpixNWSWNESE = lumaNWSW + lumaNESE;\r\n float lengthSign = srcTexelSize.x;\r\n bool horzSpan = edgeHorz >= edgeVert;\r\n // debug code edge span visualization\r\n/*' if (horzSpan)\r\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\r\n else\r\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\r\n return;*/\r\n float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\r\n/*--------------------------------------------------------------------------*/\r\n if(!horzSpan) lumaN = lumaW;\r\n if(!horzSpan) lumaS = lumaE;\r\n if(horzSpan) lengthSign = srcTexelSize.y;\r\n float subpixB = (subpixA * (1.0/12.0)) - lumaM;\r\n/*--------------------------------------------------------------------------*/\r\n float gradientN = lumaN - lumaM;\r\n float gradientS = lumaS - lumaM;\r\n float lumaNN = lumaN + lumaM;\r\n float lumaSS = lumaS + lumaM;\r\n bool pairN = abs(gradientN) >= abs(gradientS);\r\n float gradient = max(abs(gradientN), abs(gradientS));\r\n if(pairN) lengthSign = -lengthSign;\r\n float subpixC = clamp(abs(subpixB) * subpixRcpRange, 0.0, 1.0);\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posB;\r\n posB = posM;\r\n vec2 offNP;\r\n offNP.x = (!horzSpan) ? 0.0 : srcTexelSize.x;\r\n offNP.y = ( horzSpan) ? 0.0 : srcTexelSize.y;\r\n if(!horzSpan) posB.x += lengthSign * 0.5;\r\n if( horzSpan) posB.y += lengthSign * 0.5;\r\n/*--------------------------------------------------------------------------*/\r\n vec2 posN;\r\n posN = posB - offNP * FXAA_QUALITY_P0;\r\n vec2 posP;\r\n posP = posB + offNP * FXAA_QUALITY_P0;\r\n float subpixD = ((-2.0)*subpixC) + 3.0;\r\n float lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN));\r\n float subpixE = subpixC * subpixC;\r\n float lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP));\r\n/*--------------------------------------------------------------------------*/\r\n if(!pairN) lumaNN = lumaSS;\r\n float gradientScaled = gradient * 1.0/4.0;\r\n float lumaMM = lumaM - lumaNN * 0.5;\r\n float subpixF = subpixD * subpixE;\r\n bool lumaMLTZero = lumaMM < 0.0;\r\n/*---------------------looped edge-end search-------------------------------*/\r\n lumaEndN -= lumaNN * 0.5;\r\n lumaEndP -= lumaNN * 0.5;\r\n bool doneN = abs(lumaEndN) >= gradientScaled;\r\n bool doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P1;\r\n bool doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P1;\r\n/*--------------------------------------------------------------------------*/\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P2;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P2;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 3)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P3;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P3;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 4)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P4;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P4;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 5)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P5;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P5;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 6)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P6;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P6;\r\n/*--------------------------------------------------------------------------*/\r\n #if (FXAA_QUALITY_PS > 7)\r\n if(doneNP) {\r\n if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(srcTex, posN.xy));\r\n if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(srcTex, posP.xy));\r\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\r\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\r\n doneN = abs(lumaEndN) >= gradientScaled;\r\n doneP = abs(lumaEndP) >= gradientScaled;\r\n if(!doneN) posN -= offNP * FXAA_QUALITY_P7;\r\n doneNP = (!doneN) || (!doneP);\r\n if(!doneP) posP += offNP * FXAA_QUALITY_P7;\r\n/*--------------------------------------------------------------------------*/\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n #endif\r\n }\r\n/*----------------calculate subpix offset due to edge ends-------------------*/\r\n float dstN = posM.x - posN.x;\r\n float dstP = posP.x - posM.x;\r\n if(!horzSpan) dstN = posM.y - posN.y;\r\n if(!horzSpan) dstP = posP.y - posM.y;\r\n/*--------------------------------------------------------------------------*/\r\n bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\r\n float spanLength = (dstP + dstN);\r\n bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\r\n float spanLengthRcp = 1.0 / spanLength;\r\n/*--------------------------------------------------------------------------*/\r\n bool directionN = dstN < dstP;\r\n float dst = min(dstN, dstP);\r\n bool goodSpan = directionN ? goodSpanN : goodSpanP;\r\n float subpixG = subpixF * subpixF;\r\n float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\r\n float subpixH = subpixG * fxaaQualitySubpix;\r\n/*-----------------calc texture offest using subpix-------------------------*/\r\n float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\r\n float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\r\n\r\n float offset = pixelOffsetSubpix * lengthSign;\r\n #ifdef BG_TRANSPARENT\r\n // get original texel\r\n vec4 rgbaA = FxaaTexTopAlpha(srcTex, posM);\r\n // calc step to blended texel\r\n vec2 step = sign((!horzSpan) ? vec2 (offset, 0.0) : vec2 (0.0, offset));\r\n // get neighboring texel\r\n vec4 rgbaB = FxaaTexTopAlpha(srcTex, posM + step * srcTexelSize);\r\n // calc blend factor from offset\r\n float f = (!horzSpan) ? offset / srcTexelSize.x : offset / srcTexelSize.y;\r\n f = abs(f);\r\n // calc alpha (special formula to emulate blending with bg)\r\n gl_FragColor.a = 1.0 - mix(1.0 - rgbaA.a, 1.0 - rgbaB.a, f);\r\n // calc color (special formula to emulate blending with bg)\r\n gl_FragColor.rgb = mix(rgbaA.rgb * rgbaA.a, rgbaB.rgb * rgbaB.a, f) / gl_FragColor.a;\r\n #else\r\n if(!horzSpan) {\r\n posM.x += offset;\r\n } else {\r\n posM.y += offset;\r\n }\r\n gl_FragColor = FxaaTexTopAlpha(srcTex, posM);\r\n #endif\r\n return;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"copy",value:function(e){We(d(o.prototype),"copy",this).call(this,e),this.depth=e.depth}},{key:"setValues",value:function(e){if(void 0!==e){We(d(o.prototype),"setValues",this).call(this,e);var t={};this.bgTransparent&&(t.BG_TRANSPARENT=1),this.defines=t}}}]),o}(i.D$Q);Wc.prototype.bgTransparent=!1;var Yc=[new i.Pq0(.295184,.077723,.068429),new i.Pq0(-.271976,-.365221,.838363),new i.Pq0(.547713,.467576,.488515),new i.Pq0(.662808,-.031733,.584758),new i.Pq0(-.025717,.218955,.657094),new i.Pq0(-.310153,-.365223,.370701),new i.Pq0(-.101407,-.006313,.747665),new i.Pq0(-.769138,.360399,.086847),new i.Pq0(-.271988,-.27514,.905353),new i.Pq0(.09674,-.566901,.700151),new i.Pq0(.562872,-.735136,.094647),new i.Pq0(.379877,.359278,.190061),new i.Pq0(.519064,-.023055,.405068),new i.Pq0(-.301036,.114696,.088885),new i.Pq0(-.282922,.598305,.487214),new i.Pq0(-.181859,.25167,.679702),new i.Pq0(-.191463,-.635818,.512919),new i.Pq0(-.293655,.427423,.078921),new i.Pq0(-.267983,.680534,.13288),new i.Pq0(.139611,.319637,.477439),new i.Pq0(-.352086,.31104,.653913),new i.Pq0(.321032,.805279,.487345),new i.Pq0(.073516,.820734,.414183),new i.Pq0(-.155324,.589983,.41146),new i.Pq0(.335976,.170782,.527627),new i.Pq0(.46346,-.355658,.167689),new i.Pq0(.222654,.59655,.769406),new i.Pq0(.922138,-.04207,.147555),new i.Pq0(-.72705,-.329192,.369826),new i.Pq0(-.090731,.53382,.463767),new i.Pq0(-.323457,-.876559,.238524),new i.Pq0(-.663277,-.372384,.342856)],Xc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return s(this,o),(e=n.call(this)).setValues({uniforms:{noiseTexture:{type:"t",value:ti.noiseTexture},noiseTexelSize:{type:"v2",value:new i.I9Y(1/ti.noiseWidth,1/ti.noiseHeight)},diffuseTexture:{type:"t",value:null},normalTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.I9Y(1/512,1/512)},camNearFar:{type:"v2",value:new i.I9Y(1,10)},projMatrix:{type:"mat4",value:new i.kn4},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},samplesKernel:{type:"v3v",value:Yc},kernelRadius:{type:"f",value:1},depthThreshold:{type:"f",value:1},factor:{type:"f",value:1}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 32\r\nuniform vec3 samplesKernel[MAX_SAMPLES_COUNT];\r\nuniform sampler2D noiseTexture;\r\nuniform vec2 noiseTexelSize;\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D depthTexture;\r\nuniform sampler2D normalTexture;\r\nuniform vec2 srcTexelSize;\r\nuniform vec2 camNearFar;\r\nuniform mat4 projMatrix;\r\n\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\nuniform float kernelRadius;\r\nuniform float depthThreshold;\r\nuniform float factor;\r\n\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n // remap coordinates to prevent noise exture rescale\r\n vec2 vUvNoise = vUv / srcTexelSize * noiseTexelSize;\r\n vec4 normalData = texture2D(normalTexture, vUv);\r\n // return for background fragments (their normals are zero vectors)\r\n if (length(normalData.rgb) < EPSILON) {\r\n // 0.0 in alpha component means that it is background fragment\r\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\r\n return;\r\n }\r\n //[0, 1] -> [-1, 1]\r\n vec3 normal = (normalData.rgb * 2.0 - 1.0);\r\n // normalData.a store 1.0 if normal was build for frontfaced surface\r\n // and 0.0 in other case\r\n if (normalData.a < EPSILON) {\r\n normal *= -1.0;\r\n }\r\n // get random vector for sampling sphere rotation\r\n vec3 randN = texture2D(noiseTexture, vUvNoise).rgb * 2.0 - 1.0;\r\n randN = normalize(randN);\r\n // build TBN (randomly rotated around normal)\r\n vec3 tangent = normalize(randN - normal * dot(randN, normal));\r\n vec3 bitangent = cross(tangent, normal);\r\n mat3 TBN = mat3(tangent, bitangent, normal);\r\n // calc AO value\r\n float AO = 0.0;\r\n for (int i = 0 ; i < MAX_SAMPLES_COUNT ; i++) {\r\n // rotate sampling kernel around normal\r\n vec3 reflectedSample = TBN * samplesKernel[i];\r\n // get sample\r\n vec3 samplePos = viewPos + reflectedSample * kernelRadius;\r\n\r\n // project sample to screen to get sample's screen pos\r\n vec4 SampleScrPos = vec4(samplePos, 1.0);\r\n // eye -> clip\r\n SampleScrPos = projMatrix * SampleScrPos;\r\n // normalize\r\n SampleScrPos.xy /= SampleScrPos.w;\r\n //[-1, 1] -> [0, 1]\r\n SampleScrPos.xy = (SampleScrPos.xy + vec2(1.0)) * 0.5;\r\n\r\n // get view z for sample projected to the objct surface\r\n float sampleDepth = CalcViewZ(SampleScrPos.xy);\r\n // calc occlusion made by object surface at the sample\r\n AO += step(samplePos.z, sampleDepth);\r\n }\r\n // calc result AO-map color\r\n AO = 1.0 - max(0.0, AO / float(MAX_SAMPLES_COUNT) * factor);\r\n // write value to AO-map\r\n gl_FragColor = vec4(AO, AO, AO, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.D$Q);var $c=[-2,-1,0,1,2],Zc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(){var e;return s(this,o),(e=n.call(this)).setValues({uniforms:{depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.I9Y(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:$c}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = res;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x + samplesOffsets[i] * srcTexelSize.x, y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x + samplesOffsets[i] * srcTexelSize.x, y )).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb = res.rgb / weightSum;\r\n gl_FragColor = res;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),e}return l(o)}(i.D$Q);var Qc=[-2,-1,0,1,2],Kc=function(e){h(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function o(e){var t;return s(this,o),(t=n.call(this,e)).setValues({uniforms:{diffuseTexture:{type:"t",value:null},depthTexture:{type:"t",value:null},srcTexelSize:{type:"v2",value:new i.I9Y(1/512,1/512)},aoMap:{type:"t",value:null},samplesOffsets:{type:"fv1",value:Qc},projMatrix:{type:"mat4",value:new i.kn4},aspectRatio:{type:"f",value:0},tanHalfFOV:{type:"f",value:0},fogNearFar:{type:"v2",value:new i.I9Y(100,100)},fogColor:{type:"v4",value:new i.IUQ(0,.5,0,1)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n#define EPSILON 0.0000001\r\n\r\n#define MAX_SAMPLES_COUNT 5\r\nuniform float samplesOffsets[MAX_SAMPLES_COUNT];\r\nuniform sampler2D diffuseTexture;\r\nuniform sampler2D aoMap;\r\nuniform sampler2D depthTexture;\r\nuniform vec2 srcTexelSize;\r\n\r\nuniform mat4 projMatrix;\r\nuniform float aspectRatio;\r\nuniform float tanHalfFOV;\r\n\r\n#ifdef USE_FOG\r\n uniform vec2 fogNearFar;\r\n uniform vec4 fogColor;\r\n#endif\r\nvarying vec2 vUv;\r\n\r\nfloat CalcViewZ(vec2 screenPos)\r\n{\r\n float depth = texture2D(depthTexture, screenPos).x;\r\n // [0, 1]->[-1, 1]\r\n float clipedZ = 2.0 * depth - 1.0;\r\n // see THREE.js camera.makeFrustum for projection details\r\n return (-projMatrix[3][2] / (clipedZ + projMatrix[2][2]));\r\n}\r\n\r\nvec3 ViewPosFromDepth(vec2 screenPos)\r\n{\r\n vec3 viewPos;\r\n viewPos.z = CalcViewZ(screenPos);\r\n //[0, 1]->[-1, 1]\r\n vec2 projPos = 2.0 * screenPos - 1.0;\r\n // reconstruct viewposition in right-handed sc with z to viewer\r\n viewPos.xy = vec2(\r\n projPos.x * aspectRatio * tanHalfFOV * abs(viewPos.z),\r\n projPos.y * tanHalfFOV * abs(viewPos.z)\r\n );\r\n return viewPos;\r\n}\r\n\r\nvoid main() {\r\n vec3 viewPos = ViewPosFromDepth(vUv);\r\n float x = vUv.x;\r\n float y = vUv.y;\r\n vec4 color = texture2D(diffuseTexture, vec2(x, y));\r\n vec4 res = vec4(0.0);\r\n res.a = texture2D(aoMap, vec2(x, y )).a;\r\n // return for background fragments (0.0 in alpha component means that it is background fragment)\r\n if (res.a < EPSILON) {\r\n gl_FragColor = color;\r\n return;\r\n }\r\n\r\n float pixelDepth = texture2D(depthTexture, vec2(x, y)).x;\r\n float weightSum = 0.0;\r\n for (int i = 0; i < MAX_SAMPLES_COUNT; ++i) {\r\n if (texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).a < EPSILON) {\r\n continue;\r\n }\r\n vec2 samplePos = vec2(x, y + samplesOffsets[i] * srcTexelSize.y);\r\n float depth = texture2D(depthTexture, samplePos).x;\r\n float weight = (1.0 / (0.0001 + abs(depth - pixelDepth)));\r\n res.rgb += texture2D(aoMap, vec2(x, y + samplesOffsets[i] * srcTexelSize.y)).rgb * weight;\r\n weightSum += weight;\r\n }\r\n res.rgb /= weightSum;\r\n\r\n #if defined(USE_FOG) && !defined(FOG_TRANSPARENT)\r\n // Add fog to the result value\r\n // Proper way to get an image with fog and ao requires formula:\r\n // gl_FragColor = fragColor*AO*(1-fogFactor) + fogColor*fogFactor\r\n // But we have already fogged molecule to add AO too. Let's split the straight formula into our real steps!\r\n // We have: AO, fogFactor, fogColor,\r\n // color = fragColor*(1-fogFactor) + fogColor*fogFactor (it comes from diffuseTexture,\r\n // where molecule has been already drawn with fog)\r\n // Transform:\r\n // fragColor*AO*(1-fogFactor) + fogColor*fogFactor =\r\n // = [fragColor*(1-fogFactor) = color - fogColor*fogFactor] =\r\n // = (color - fogColor*fogFactor)*AO + fogColor*fogFactor =\r\n // = color*AO + fogColor*fogFactor*(1 - AO)\r\n // Result: gl_FragColor = color*AO + fogColor*fogFactor*(1 - AO)\r\n float fogFactor = smoothstep(fogNearFar.x, fogNearFar.y, - viewPos.z) * fogColor.a;\r\n gl_FragColor.rgb = color.rgb * res.rgb + fogColor.rgb * fogFactor *(vec3(1.0, 1.0, 1.0) - res.rgb);\r\n #else\r\n gl_FragColor.rgb = color.rgb * res.rgb;\r\n #endif\r\n gl_FragColor.a = color.a;\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1}),t.setValues(e),t}return l(o,[{key:"setValues",value:function(e){if(void 0!==e){We(d(o.prototype),"setValues",this).call(this,e);var t={};this.useFog&&(t.USE_FOG=1),this.fogTransparent&&(t.FOG_TRANSPARENT=1),this.defines=t}}}]),o}(i.D$Q);Kc.prototype.useFog=!0,Kc.prototype.fogTransparent=!1;var Jc=function(e){h(i,e);var t,r,n=(t=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function i(){var e;s(this,i),e=n.call(this);var t={uniforms:{srcL:{type:"t",value:null},srcR:{type:"t",value:null}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\nuniform sampler2D srcL;\r\nuniform sampler2D srcR;\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n vec4 l = texture2D(srcL, vUv);\r\n vec4 r = texture2D(srcR, vUv);\r\n gl_FragColor = vec4(l.r, r.g, r.b, 1.0);\r\n}\r\n",transparent:!1,depthTest:!1,depthWrite:!1};return e.setValues(t),e}return l(i)}(i.D$Q),eu=function(){function e(){s(this,e),this.position=new i.Pq0(0,0,0),this.scale=1,this.orientation=new i.PTz(0,0,0,1)}return l(e,[{key:"set",value:function(e,t,r){this.position=e,this.scale=t,this.orientation=r}}]),e}(),tu=function(){function e(){s(this,e)}return l(e,[{key:"setup",value:function(e,t){this._startTime=void 0,this._endTime=void 0,this._isPaused=!1,this._srcView=e,this._dstView=t,this._isMoving=!1}},{key:"isMoving",value:function(){return this._isMoving}},{key:"wasStarted",value:function(){return void 0!==this._startTime&&void 0!==this._endTime}},{key:"start",value:function(){this._startTime=Date.now();var e=J.now.interpolateViews?1500:0;this._endTime=this._startTime+e,this._isMoving=!0}},{key:"getCurrentView",value:function(){if(void 0===this._srcView||void 0===this._dstView||!this._isMoving||!this.wasStarted())return{success:!1};var e=this.createView(),t=Date.now();if(t>this._endTime)return e=this._dstView,this.reset(),{success:!0,view:e};var r=(t-this._startTime)/(this._endTime-this._startTime);return e.position.copy(this._srcView.position),e.position.lerp(this._dstView.position,r),e.scale=(1-r)*this._srcView.scale+r*this._dstView.scale,e.orientation.copy(this._srcView.orientation),e.orientation.slerp(this._dstView.orientation,r),{success:!0,view:e}}},{key:"reset",value:function(){this._startTime=this._endTime=0,this._isMoving=!1}},{key:"pause",value:function(){this._isPaused||(this.setup(this.getCurrentView().view,this._dstView),this._isPaused=!0)}},{key:"resume",value:function(){this._isPaused=!1}},{key:"createView",value:function(){return new eu}}]),e}();function ru(e,t){this.context=e,this._opts=(0,n.merge)({path:"/"},t)}Ir(ru.prototype),ru.prototype.removeCookie=function(e){var t=this._toCount(e),r=this._getSimpleCookie(t);if(r){this._removeSimpleCookie(t),r=parseInt(r,10);for(var n=0;n<r;++n)this._removeSimpleCookie(e+n)}else this._removeSimpleCookie(e)},ru.prototype.setCookie=function(e,t){this.removeCookie(e);var r=function(e,t){for(var r=e.length,n=[],i=0,o=0;o<r;i++,o+=t)n[i]=e.slice(o,o+t);return n}(t=encodeURIComponent(t),4e3-e.length-1),n=r.length;if(1!==n){var i=this._toCount(e);this._setSimpleCookie(i,n.toString());for(var o=0;o<n;++o)this._setSimpleCookie(e+o,r[o])}else this._setSimpleCookie(e,t)},ru.prototype.getCookie=function(e){var t=this._toCount(e),r=this._getSimpleCookie(t);if(!r)return this._getSimpleCookie(e);r=parseInt(r,10);for(var n=[],i=0;i<r;++i)n[i]=this._getSimpleCookie(e+i);return n.join("")},ru.prototype._toCount=function(e){return e+"Cnt"},ru.prototype._removeSimpleCookie=function(e){document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;")},ru.prototype._getExpirationDate=function(){var e=new Date;return e.setFullYear(e.getFullYear()+10),e},ru.prototype._setSimpleCookie=function(e,t){document.cookie="".concat(e,"=").concat(t,";expires=").concat(this._getExpirationDate().toUTCString(),";path=").concat(this._opts.path)},ru.prototype._getSimpleCookie=function(e){var t=document.cookie.match(new RegExp("(?:^|; )".concat(e,"=([^;]*)")));return t?decodeURIComponent(t[1]):""},ru.prototype._exists=function(e){return document.cookie.match(new RegExp("(?:^|; )".concat(e,"=([^;]*)")))};var nu=function(){function e(t){s(this,e),this._mainCamera=new i.ubm,this._button=null,this._onToggle=t,this._molContainer=new kr.RCGroup,this._user=new kr.RCGroup,this._scalingPivot=new i.B69,this._user.add(this._scalingPivot),this._controller1=null,this._controller2=null,this._pressedGripsCounter=0,this._distance=0,this._gfx=null}return l(e,[{key:"startScalingByControllers",value:function(){this._distance=this._controller1.position.distanceTo(this._controller2.position),kr.getMiddlePoint(this._controller1.position,this._controller2.position,this._scalingPivot.position),this._scalingPivot.scale.set(1,1,1),this._scalingPivot.updateMatrix(),this._scalingPivot.updateMatrixWorld(),this._scalingPivot.addSavingWorldTransform(this._molContainer)}},{key:"stopScalingByControllers",value:function(){this._gfx.scene.addSavingWorldTransform(this._molContainer)}},{key:"handleGripsDown",value:function(e){this._pressedGripsCounter++,2===this._pressedGripsCounter?this.startScalingByControllers():1===this._pressedGripsCounter&&e.target.addSavingWorldTransform(this._molContainer)}},{key:"handleGripsUp",value:function(e){this._pressedGripsCounter--,1===this._pressedGripsCounter?(this.stopScalingByControllers(),(e.target===this._controller1?this._controller2:this._controller1).addSavingWorldTransform(this._molContainer)):0===this._pressedGripsCounter&&this._gfx.scene.addSavingWorldTransform(this._molContainer)}},{key:"enable",value:function(e){if(e){this._gfx=e;var t=e.renderer,r=e.camera;if(!t)throw new Error("No renderer is available to toggle WebVR");if(!r)throw new Error("No camera is available to toggle WebVR");t.xr.enabled=!0,this._button?this._button.style.display="block":(this._button=function(e){function t(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="transparent",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator){var r=document.createElement("button");return r.style.display="none",t(r),navigator.xr.isSessionSupported("immersive-vr").then((function(t){return t?function(t){t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR";var r=null;function n(){r.removeEventListener("end",n),t.textContent="ENTER VR",r=null}function i(i){i.addEventListener("end",n),e._gfx.renderer.xr.setReferenceSpaceType("local"),e._gfx.renderer.xr.setSession(i),t.textContent="EXIT VR",r=i}t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){null===r?(navigator.xr.requestSession("immersive-vr",{optionalFeatures:["local-floor","bounded-floor"]}).then(i),e.moveSceneBehindHeadset()):r.end()}}(r):function(e){e.style.display="",e.style.cursor="auto",e.style.left="calc(50% - 75px)",e.style.width="150px",e.textContent="VR NOT FOUND",e.onmouseenter=null,e.onmouseleave=null,e.onclick=null}(r)})),r}var n=document.createElement("a");return n.href="https://webvr.info",n.innerHTML="WEBXR NOT SUPPORTED",n.style.left="calc(50% - 90px)",n.style.width="180px",n.style.textDecoration="none",t(n),n}(this),document.body.appendChild(this._button)),this._mainFog=J.now.fog,J.set("fog",!1),this._plugVRNodesIntoScene(e,t),this._setControllersListeners(),this._onToggle&&this._onToggle(!0)}else B.warn("WebVR couldn't be enabled, because gfx is not defined")}},{key:"_plugVRNodesIntoScene",value:function(e,t){this._mainCamera.copy(e.camera),e.scene.add(this._user),e.scene.add(this._molContainer),this._molContainer.add(e.root),this._controller1=t.xr.getController(0),this._controller2=t.xr.getController(1);var r=this._createControllerMesh();this._controller1.add(r),this._controller2.add(r.clone()),this._user.add(this._controller1),this._user.add(this._controller2)}},{key:"_setControllersListeners",value:function(){var e=this;this._controller1.addEventListener("selectstart",(function(t){e.handleGripsDown(t)})),this._controller1.addEventListener("selectend",(function(t){e.handleGripsUp(t)})),this._controller2.addEventListener("selectstart",(function(t){e.handleGripsDown(t)})),this._controller2.addEventListener("selectend",(function(t){e.handleGripsUp(t)})),this._controller1.addEventListener("squeezestart",(function(t){e.handleGripsDown(t)})),this._controller1.addEventListener("squeezeend",(function(t){e.handleGripsUp(t)})),this._controller2.addEventListener("squeezestart",(function(t){e.handleGripsDown(t)})),this._controller2.addEventListener("squeezeend",(function(t){e.handleGripsUp(t)}))}},{key:"disable",value:function(){if(this._gfx){var e=this._gfx,t=e.renderer,r=e.camera;if(!t)throw new Error("No renderer is available to toggle WebVR");t.setAnimationLoop(null);var n=t.xr.getSession();n&&n.end(),t.xr.enabled=!1,this._button&&(this._button.style.display="none"),J.set("fog",this._mainFog),this._unplugVRNodesFromScene(r),this._onToggle&&this._onToggle(!1)}}},{key:"_unplugVRNodesFromScene",value:function(e){this._mainCamera&&e&&e.copy(this._mainCamera);var t=this._molContainer.children[0];t&&this._gfx.scene.add(t),this._molContainer.parent.remove(this._molContainer),this._user&&this._gfx.scene.remove(this._user),this._molContainer=null,this._user=null,this._scalingPivot=null,this._user=null,this._controller1=null,this._controller2=null}},{key:"_createControllerMesh",value:function(){var e=new i.Ho_(.04,.04,.3),t=new li;t.setValues({lights:!1,overrideColor:!0}),t.setUberOptions({fixedColor:new i.Q1f(4474111)}),t.updateUniforms();var r=new i.eaF(e,t);return r.rotateX(-Math.PI/2),r}},{key:"updateMoleculeScale",value:function(){if(this._controller1&&this._controller2){var e=this;if(2===e._pressedGripsCounter){kr.getMiddlePoint(e._controller1.position,e._controller2.position,e._scalingPivot.position);var t=e._controller1.position.distanceTo(e._controller2.position),r=t/e._distance;e._scalingPivot.scale.multiplyScalar(r),e._distance=t}}}},{key:"moveSceneBehindHeadset",value:function(){var e=this._gfx,t=e.camera,r=this._molContainer;r.matrix.identity(),r.position.set(0,0,-4),r.updateMatrix(),r.matrixWorld.multiplyMatrices(t.matrixWorld,r.matrix),e.scene.addSavingWorldTransform(r),this._onToggle&&this._onToggle(!0)}},{key:"getCanvas",value:function(){var e=this._gfx;return e&&e.renderer?e.renderer.domElement:null}}]),e}();var iu=dr.selectors,ou=dr.Atom,su=dr.Residue,au=dr.Chain,lu=dr.Molecule,cu="Could not find suitable loader for this source",uu=$.createElement;function hu(e){var t=e.lastIndexOf(".");return t>=0&&(e=e.substr(0,t)),e}function fu(e,t,r){void 0!==r?e.debug("".concat(t,"... ").concat(Math.floor(100*r),"%")):e.debug("".concat(t,"..."))}function du(){return J.now.fogColorEnable?J.now.fogColor:J.now.bg.color}function pu(e,t){for(var r=e;r.firstChild;)r.removeChild(r.firstChild);r.appendChild(t)}function mu(e){return e.getExtension("EXT_frag_depth")}function vu(e){return e.getExtension("WEBGL_depth_texture")&&e.getExtension("WEBGL_draw_buffers")}var yu=/^(?:(pdb|cif|mmtf|ccp4|dsn6):\s*)?(\d[a-z\d]{3})$/i,_u=/^(?:pc|pubchem):\s*([a-z]+)$/i,gu=/^([a-z][a-z\d\-+.]*):/i;function xu(e,t){return e.mask&1<<t}function bu(e,t){return t.selector.includesAtom(e)}var wu=function(e){h(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=d(t);if(r){var i=d(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return f(this,e)});function a(e){var t;s(this,a),(t=o.call(this))._opts=(0,n.merge)({settingsCookie:"settings",cookiePath:"/"},e),t._gfx=null,t._interpolator=new tu,t._container=e&&e.container||document.getElementById("miew-container")||(0,n.head)(document.getElementsByClassName("miew-container"))||document.body,t._containerRoot=t._container,t._running=!1,t._halting=!1,t._building=!1,t._needRender=!0,t._hotKeysEnabled=!0,t.settings=J;var r=B;r.console=!1,r.level="info",t.logger=r,t._cookies=new ru(c(t)),t.restoreSettings(),e&&e.settings&&t.settings.set(e.settings),t._spinner=null,t._loading=[],t._animInterval=null,t._visuals={},t._curVisualName=null,t._objects=[],t._sourceWindow=null,t.reset(),t._repr&&r.debug("Selected ".concat(t._repr.mode.name," mode with ").concat(t._repr.colorer.name," colorer."));var l=c(t);return a.registeredPlugins.forEach((function(e){e.call(l)})),t._initOnSettingsChanged(),t.shadowMatrix=new i.kn4,t.direction=new i.Pq0,t.OBB={center:new i.Pq0,halfSize:new i.Pq0},t._bSphereForOneVisual=new i.iyt,t._bBoxForOneVisual=new i.NRn,t._bBox=new i.NRn,t._invMatrix=new i.kn4,t._points=[new i.Pq0,new i.Pq0,new i.Pq0,new i.Pq0],t._anaglyphMat=new Jc,t._size=new i.I9Y,t._scene=new i.Z58,t._camera=new i.qUd(-1,1,1,-1,-500,1e3),t._material=new i.D$Q({uniforms:{srcTex:{type:"t",value:null},aberration:{type:"fv3",value:new i.Pq0(1)}},vertexShader:vr,fragmentShader:"precision highp float;\r\n\r\nvarying vec2 vUv;\r\nuniform sampler2D srcTex;\r\nuniform vec3 aberration;\r\n\r\nvoid main() {\r\n vec2 uv = vUv * 2.0 - 1.0;\r\n \r\n gl_FragColor.r = texture2D(srcTex, 0.5 * (uv * aberration[0] + 1.0)).r;\r\n gl_FragColor.g = texture2D(srcTex, 0.5 * (uv * aberration[1] + 1.0)).g;\r\n gl_FragColor.b = texture2D(srcTex, 0.5 * (uv * aberration[2] + 1.0)).b;\r\n gl_FragColor.a = 1.0;\r\n}",transparent:!1,depthTest:!1,depthWrite:!1}),t._geo=kr.buildDistorionMesh(10,10,J.now.debug.stereoBarrel),t._outlineMaterial=new qc({depth:!0}),t.pars={minFilter:i.hxR,magFilter:i.hxR,format:i.GWd},t.VERSION="0.10.0+20220125.134627.b36f6a2-mod",t}return l(a,[{key:"getMaxRepresentationCount",value:function(){return Fs.NUM_REPRESENTATION_BITS}},{key:"_updateShadowCamera",value:function(){this._gfx.scene.updateMatrixWorld();for(var e=0;e<this._gfx.scene.children.length;e++)if("DirectionalLight"===this._gfx.scene.children[e].type){var t=this._gfx.scene.children[e];this.shadowMatrix.copy(t.shadow.camera.matrixWorldInverse),this.getOBB(this.shadowMatrix,this.OBB),this.direction.subVectors(t.target.position,t.position),t.position.subVectors(this.OBB.center,this.direction),t.target.position.copy(this.OBB.center),t.shadow.bias=.09,t.shadow.camera.bottom=-this.OBB.halfSize.y,t.shadow.camera.top=this.OBB.halfSize.y,t.shadow.camera.right=this.OBB.halfSize.x,t.shadow.camera.left=-this.OBB.halfSize.x,t.shadow.camera.near=this.direction.length()-this.OBB.halfSize.z,t.shadow.camera.far=this.direction.length()+this.OBB.halfSize.z,t.shadow.camera.updateProjectionMatrix()}}},{key:"init",value:function(){var e=this._container,t=$.createElement("div",{class:"miew-canvas"});pu(e,t),this._container=t;var r=document.createDocumentFragment();if(r.appendChild(this._msgMode=uu("div",{class:"mode-message overlay"},uu("p",{},"COMPONENT EDIT MODE"))),r.appendChild(this._msgAtomInfo=uu("div",{class:"atom-info overlay"},uu("p",{},""))),e.appendChild(r),null!==this._gfx)return!0;var n=this;this._showMessage("Viewer is being initialized...");try{this._initGfx(),this._initListeners(),this._spinner=new g({lines:13,length:28,width:14,radius:42,color:"#fff",zIndex:700}),window.top.addEventListener("keydown",(function(e){n._onKeyDown(e)})),window.top.addEventListener("keyup",(function(e){n._onKeyUp(e)})),this._objectControls=new Lc(this._gfx.root,this._gfx.pivot,this._gfx.camera,this._gfx.renderer.domElement,(function(){return n._getAltObj()})),this._objectControls.addEventListener("change",(function(e){switch(J.now.shadow.on&&n._updateShadowCamera(),e.action){case"rotate":n.dispatchEvent({type:"rotate",quaternion:e.quaternion});break;case"zoom":n.dispatchEvent({type:"zoom",factor:e.factor});break;default:n.dispatchEvent({type:e.action})}n.dispatchEvent({type:"transform"}),n._needRender=!0}));var i=this._gfx;this._picker=new Bc(i.root,i.camera,i.renderer.domElement),this._picker.addEventListener("newpick",(function(e){n._onPick(e)})),this._picker.addEventListener("dblclick",(function(e){n.center(e)}))}catch(e){if("TypeError"===e.name&&"Cannot read property 'getExtension' of null"===e.message)this._showMessage("Could not create WebGL context.");else{if(!(e.message.search(/webgl/i)>1))throw this._showMessage("Viewer initialization failed."),e;this._showMessage(e.message)}return!1}var o=this._opts&&this._opts.load;if(o){var s=this._opts&&this._opts.type;this.load(o,{fileType:s,keepRepsInfo:!0})}return!0}},{key:"term",value:function(){this._showMessage("Viewer has been terminated."),this._loading.forEach((function(e){e.cancel()})),this._loading.length=0,this.halt(),this._gfx=null}},{key:"_showMessage",value:function(e){var t=document.createElement("div");t.setAttribute("class","miew-message"),t.appendChild(document.createElement("p")).appendChild(document.createTextNode(e)),pu(this._container,t)}},{key:"_showCanvas",value:function(){pu(this._container,this._gfx.renderer.domElement)}},{key:"_requestAnimationFrame",value:function(e){var t=this._gfx.renderer.xr;t&&t.enabled?this._gfx.renderer.setAnimationLoop(e):requestAnimationFrame(e)}},{key:"_initGfx",value:function(){var e={width:this._container.clientWidth,height:this._container.clientHeight},t={preserveDrawingBuffer:!0,alpha:!0,premultipliedAlpha:!1};J.now.antialias&&(t.antialias=!0),e.renderer2d=new Tc,e.renderer=new i.S3G(t),e.renderer.shadowMap.enabled=J.now.shadow.on,e.renderer.shadowMap.autoUpdate=!1,e.renderer.shadowMap.type=i.QP0,Yn.init(e.renderer),mu(e.renderer.getContext())||J.set("zSprites",!1),vu(e.renderer.getContext())||J.set("ao",!1),e.renderer.autoClear=!1,e.renderer.setPixelRatio(window.devicePixelRatio),e.renderer.setSize(e.width,e.height),e.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),e.renderer.clearColor(),e.renderer2d.setSize(e.width,e.height),e.camera=new i.ubm(J.now.camFov,e.width/e.height,J.now.camNear,J.now.camFar),e.camera.setMinimalFov(J.now.camFov),e.camera.position.z=J.now.camDistance,e.camera.updateProjectionMatrix(),e.camera.layers.set(kr.LAYERS.DEFAULT),e.camera.layers.enable(kr.LAYERS.VOLUME),e.camera.layers.enable(kr.LAYERS.VOLUME_BFPLANE),e.stereoCam=new i.keZ,e.scene=new i.Z58;var r=du();e.scene.fog=new i.jUj(r,J.now.camNear,J.now.camFar),e.root=new kr.RCGroup,e.scene.add(e.root),e.pivot=new kr.RCGroup,e.root.add(e.pivot),e.selectionScene=new i.Z58,e.selectionRoot=new i.YJl,e.selectionRoot.matrixAutoUpdate=!1,e.selectionScene.add(e.selectionRoot),e.selectionPivot=new i.YJl,e.selectionPivot.matrixAutoUpdate=!1,e.selectionRoot.add(e.selectionPivot);var n=new i.ZyN(16777215,.45);n.position.set(0,.414,1),n.layers.enable(kr.LAYERS.TRANSPARENT),n.castShadow=!0,n.shadow.bias=.09,n.shadow.radius=J.now.shadow.radius,n.shadow.camera.layers.set(kr.LAYERS.SHADOWMAP);var o=e.renderer.getPixelRatio(),s=Math.max(e.width,e.height)*o;n.shadow.mapSize.width=s,n.shadow.mapSize.height=s,n.target.position.set(0,0,0),e.scene.add(n),e.scene.add(n.target);var a=new i.$p8(6710886);a.layers.enable(kr.LAYERS.TRANSPARENT),e.scene.add(a),e.axes=new Dc(e.root,e.camera);var l=e.width*o,c=e.height*o;e.offscreenBuf=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.hxR,format:i.GWd,depthBuffer:!0}),e.renderer.getContext().getExtension("WEBGL_depth_texture")&&(e.offscreenBuf.depthTexture=new i.VCu,e.offscreenBuf.depthTexture.type=i.cHt),e.offscreenBuf2=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,depthBuffer:!1}),e.offscreenBuf3=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,depthBuffer:!1}),e.offscreenBuf4=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,depthBuffer:!1}),e.volBFTex=e.offscreenBuf3,e.volFFTex=e.offscreenBuf4,e.volWFFTex=e.offscreenBuf,e.renderer.getContext().getExtension("OES_texture_float")?(e.offscreenBuf5=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,type:i.RQf,depthBuffer:!1}),e.offscreenBuf6=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,type:i.RQf,depthBuffer:!1}),e.offscreenBuf7=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,type:i.RQf,depthBuffer:!0}),e.volBFTex=e.offscreenBuf5,e.volFFTex=e.offscreenBuf6,e.volWFFTex=e.offscreenBuf7):this.logger.warn("Device doesn't support OES_texture_float extension"),e.stereoBufL=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,depthBuffer:!1}),e.stereoBufR=new i.nWS(l,c,{minFilter:i.k6q,magFilter:i.k6q,format:i.GWd,depthBuffer:!1}),this._gfx=e,this._showCanvas(),this._embedWebXR("WEBVR"===J.now.stereo),this._container.appendChild(e.renderer2d.getElement());var u=new E;u.domElement.style.position="absolute",u.domElement.style.right="0",u.domElement.style.bottom="0",this._container.appendChild(u.domElement),this._fps=u,this._fps.show(J.now.fps)}},{key:"_initListeners",value:function(){var e=this;window.addEventListener("resize",(function(){e._onResize()}))}},{key:"_makeUniqueVisualName",value:function(e){if(!e)return Math.random().toString();for(var t=e,r=1;this._visuals.hasOwnProperty(t);)t="".concat(e," (").concat(r.toString(),")"),r++;return t}},{key:"_addVisual",value:function(e){if(!e)return null;var t=this._makeUniqueVisualName(e.name);return e.name=t,this._visuals[t]=e,this._gfx.pivot.add(e),e.getSelectionGeo&&this._gfx.selectionPivot.add(e.getSelectionGeo()),t}},{key:"_removeVisual",value:function(e){var t="",r=null;e instanceof Er?(t=e.name,r=e):"string"==typeof e&&(t=e,r=this._visuals[t]),r&&this._visuals.hasOwnProperty(t)&&this._visuals[t]===r&&(t===this._curVisualName&&(this._curVisualName=void 0),delete this._visuals[t],r.release(),this._needRender=!0)}},{key:"_forEachVisual",value:function(e){for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&e(this._visuals[t])}},{key:"_releaseAllVisuals",value:function(){if(this._gfx&&this._gfx.pivot){for(var e in this._visuals)this._visuals.hasOwnProperty(e)&&this._visuals[e].release();this._visuals={}}}},{key:"_forEachComplexVisual",value:function(e){if(this._gfx&&this._gfx.pivot)for(var t in this._visuals)this._visuals.hasOwnProperty(t)&&this._visuals[t]instanceof Fs&&e(this._visuals[t])}},{key:"_getComplexVisual",value:function(e){e=e||this._curVisualName;var t=null,r=null;return this._forEachComplexVisual((function(n){t=n,n.name===e&&(r=n)})),r||t}},{key:"_getVolumeVisual",value:function(){var e=null;return this._forEachVisual((function(t){t instanceof Zs&&(e=t)})),e}},{key:"_getVisualForComplex",value:function(e){if(!e)return null;var t=null;return this._forEachComplexVisual((function(r){r.getComplex()===e&&(t=r)})),t}},{key:"getVisuals",value:function(){return Object.keys(this._visuals)}},{key:"getComplexVisualsCount",value:function(){var e=0;return this._forEachComplexVisual((function(){return e++})),e}},{key:"getCurrentVisual",value:function(){return this._curVisualName}},{key:"setCurrentVisual",value:function(e){this._visuals[e]&&(this._curVisualName=e)}},{key:"run",value:function(){var e=this;if(!this._running){if(this._running=!0,this._halting)return void(this._halting=!1);this._objectControls.enable(!0),this._interpolator.resume(),this._requestAnimationFrame((function(){return e._onTick()}))}}},{key:"halt",value:function(){this._running&&(this._discardComponentEdit(),this._discardFragmentEdit(),this._objectControls.enable(!1),this._interpolator.pause(),this._halting=!0)}},{key:"enableHotKeys",value:function(e){this._hotKeysEnabled=e,this._objectControls.enableHotkeys(e)}},{key:"_onResize",value:function(){this._needRender=!0;var e=this._gfx;e.width=this._container.clientWidth,e.height=this._container.clientHeight,e.camera.aspect=e.width/e.height,e.camera.setMinimalFov(J.now.camFov),e.camera.updateProjectionMatrix(),e.renderer.setSize(e.width,e.height),e.renderer2d.setSize(e.width,e.height),this.dispatchEvent({type:"resize"})}},{key:"_resizeOffscreenBuffers",value:function(e,t,r){var n=this._gfx,i="NONE"===(r=r||"NONE")||"ANAGLYPH"===r,o=i?1:.5;n.offscreenBuf.setSize(o*e,t),n.offscreenBuf2.setSize(o*e,t),n.offscreenBuf3.setSize(o*e,t),n.offscreenBuf4.setSize(o*e,t),n.offscreenBuf5&&n.offscreenBuf5.setSize(o*e,t),n.offscreenBuf6&&n.offscreenBuf6.setSize(o*e,t),n.offscreenBuf7&&n.offscreenBuf7.setSize(o*e,t),i&&(n.stereoBufL.setSize(e,t),n.stereoBufR.setSize(e,t))}},{key:"_onTick",value:function(){var e=this;if(this._halting)return this._running=!1,void(this._halting=!1);this._fps.update(),this._requestAnimationFrame((function(){return e._onTick()})),this._onUpdate(),this._needRender&&(this._onRender(),this._needRender=!J.now.suspendRender||"WEBVR"===J.now.stereo)}},{key:"_getBSphereRadius",value:function(){var e=0;return this._forEachVisual((function(t){e=Math.max(e,t.getBoundaries().boundingSphere.radius)})),e*this._objectControls.getScale()}},{key:"getOBB",value:function(e,t){var r=this;this._bBox.makeEmpty(),this._forEachVisual((function(t){r._bSphereForOneVisual.copy(t.getBoundaries().boundingSphere),r._bSphereForOneVisual.applyMatrix4(t.matrixWorld).applyMatrix4(e),r._bSphereForOneVisual.getBoundingBox(r._bBoxForOneVisual),r._bBox.union(r._bBoxForOneVisual)})),this._bBox.getCenter(t.center),this._invMatrix.copy(e).invert(),t.center.applyMatrix4(this._invMatrix);var n=this._bBox.min,i=this._bBox.max;this._points[0].set(n.x,n.y,n.z),this._points[1].set(i.x,n.y,n.z),this._points[2].set(n.x,i.y,n.z),this._points[3].set(n.x,n.y,i.z);for(var o=0,s=this._points.length;o<s;o++)this._points[o].applyMatrix4(this._invMatrix);t.halfSize.set(Math.abs(this._points[0].x-this._points[1].x),Math.abs(this._points[0].y-this._points[2].y),Math.abs(this._points[0].z-this._points[3].z)).multiplyScalar(.5)}},{key:"_updateFog",value:function(){var e=this._gfx;if(J.now.fog){if(void 0===e.scene.fog||null===e.scene.fog){var t=du();e.scene.fog=new i.jUj(t),this._setUberMaterialValues({fog:J.now.fog})}!function(e,t,r){e.near=t-r*J.now.fogNearFactor,e.far=t+r*J.now.fogFarFactor}(e.scene.fog,e.camera.position.z,this._getBSphereRadius())}else e.scene.fog&&(e.scene.fog=void 0,this._setUberMaterialValues({fog:J.now.fog}))}},{key:"_onUpdate",value:function(){void 0!==this.isScriptingCommandAvailable&&this.isScriptingCommandAvailable()&&!this._building&&this.callNextCmd(),this._objectControls.update(),this._forEachComplexVisual((function(e){e.getComplex().update()})),J.now.autobuild&&!this._loading.length&&!this._building&&this._needRebuild()&&this.rebuild(),this._loading.length||this._building||this._needRebuild()||this._updateView(),this._updateFog(),this._gfx.renderer.xr.enabled&&this.webVR.updateMoleculeScale()}},{key:"_onRender",value:function(){var e=this._gfx;e.scene.updateMatrixWorld(),e.camera.updateMatrixWorld(),this._clipPlaneUpdateValue(this._getBSphereRadius()),this._fogFarUpdateValue(),e.renderer.setRenderTarget(null),e.renderer.clear(),this._renderFrame(J.now.stereo)}},{key:"_renderFrame",value:function(e){var t=this._gfx,r=t.renderer;r.getSize(this._size),"NONE"!==e&&(t.camera.focus=t.camera.position.z,t.stereoCam.aspect=1,"ANAGLYPH"===e?t.stereoCam.update(t.camera):t.stereoCam.updateHalfSized(t.camera,J.now.camFov));var n=t.renderer.getPixelRatio();switch(this._resizeOffscreenBuffers(this._size.width*n,this._size.height*n,e),this._renderShadowMap(),e){case"WEBVR":case"NONE":this._renderScene(t.camera,!1);break;case"SIMPLE":case"DISTORTED":r.setScissorTest(!0),r.setScissor(0,0,this._size.width/2,this._size.height),r.setViewport(0,0,this._size.width/2,this._size.height),this._renderScene(this._gfx.stereoCam.cameraL,"DISTORTED"===e),r.setScissor(this._size.width/2,0,this._size.width/2,this._size.height),r.setViewport(this._size.width/2,0,this._size.width/2,this._size.height),this._renderScene(this._gfx.stereoCam.cameraR,"DISTORTED"===e),r.setScissorTest(!1);break;case"ANAGLYPH":this._renderScene(this._gfx.stereoCam.cameraL,!1,t.stereoBufL),this._renderScene(this._gfx.stereoCam.cameraR,!1,t.stereoBufR),r.setRenderTarget(null),this._anaglyphMat.uniforms.srcL.value=t.stereoBufL.texture,this._anaglyphMat.uniforms.srcR.value=t.stereoBufR.texture,t.renderer.renderScreenQuad(this._anaglyphMat)}t.renderer2d.render(t.scene,t.camera),J.now.axes&&t.axes&&!t.renderer.xr.enabled&&t.axes.render(r)}},{key:"_onBgColorChanged",value:function(){var e=this._gfx,t=du();e&&(e.scene.fog&&e.scene.fog.color.set(t),e.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent))),this._needRender=!0}},{key:"_onFogColorChanged",value:function(){var e=this._gfx,t=du();e&&e.scene.fog&&e.scene.fog.color.set(t),this._needRender=!0}},{key:"_setUberMaterialValues",value:function(e){this._gfx.root.traverse((function(t){(t instanceof i.eaF||t instanceof i.DXC||t instanceof i.N1A)&&t.material instanceof li&&(t.material.setValues(e),t.material.needsUpdate=!0)}))}},{key:"_enableMRT",value:function(e,t,r){var n=this._gfx,i=n.renderer.getContext(),o=i.getExtension("WEBGL_draw_buffers"),s=n.renderer.properties;if(e){n.renderer.setRenderTarget(r);var a=s.get(r.texture).__webglTexture;i.bindTexture(i.TEXTURE_2D,a),n.renderer.setRenderTarget(t);var l=s.get(t).__webglFramebuffer,c=s.get(t.texture).__webglTexture;i.bindFramebuffer(i.FRAMEBUFFER,l),l.width=t.width,l.height=t.height,i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,c,0),i.framebufferTexture2D(i.FRAMEBUFFER,o.COLOR_ATTACHMENT1_WEBGL,i.TEXTURE_2D,a,0),o.drawBuffersWEBGL([i.COLOR_ATTACHMENT0,o.COLOR_ATTACHMENT1_WEBGL])}else o.drawBuffersWEBGL([i.COLOR_ATTACHMENT0,null])}},{key:"_renderScene",value:function(e,t,r){t=t||!1,r=r||null;var n=this._gfx;if(n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(r),n.renderer.clear(),n.renderer.xr.enabled)n.renderer.render(n.scene,e);else{n.renderer.setClearColor(0,0),n.renderer.setRenderTarget(n.offscreenBuf4),n.renderer.clearColor(),n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.clear();var i=null!==this._getComplexVisual(),o=this._getVolumeVisual(),s=i&&J.now.ao;s&&this._enableMRT(!0,n.offscreenBuf,n.offscreenBuf4),"prepass"===J.now.transparency?this._renderWithPrepassTransparency(e,n.offscreenBuf):"standard"===J.now.transparency&&(n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.render(n.scene,e)),s&&this._enableMRT(!1,null,null);var a=i&&J.now.outline.on,l=i&&J.now.fxaa,c=null!==o&&null!=o.getMesh().material,u=s||a||c||l||t?n.offscreenBuf2:r,h=n.offscreenBuf;s?(this._performAO(h,n.offscreenBuf4,n.offscreenBuf.depthTexture,u,n.offscreenBuf3,n.offscreenBuf2),l||t||c||a||(h=u,u=r,n.renderer.setRenderTarget(u),n.renderer.renderScreenQuadFromTex(h.texture,1))):(n.renderer.setRenderTarget(u),n.renderer.renderScreenQuadFromTex(h.texture,1)),a&&(h=u,u=c||l||t?n.offscreenBuf3:r,null!=h&&this._renderOutline(e,n.offscreenBuf,h,u)),this._renderSelection(e,n.offscreenBuf,u),c&&(n.renderer.setRenderTarget(n.offscreenBuf),n.renderer.renderScreenQuadFromTex(u.texture,1),u=n.offscreenBuf,this._renderVolume(o,e,u,n.volBFTex,n.volFFTex,n.volWFFTex),l||t||(n.renderer.setRenderTarget(r),n.renderer.renderScreenQuadFromTex(u.texture,1))),h=u,l&&(u=t?n.offscreenBuf4:r,this._performFXAA(h,u),h=u),t&&(u=r,this._performDistortion(h,u,!0))}}},{key:"_performDistortion",value:function(e,t,r){this._scene.add(new xi.Mesh(this._geo,this._material)),this._gfx.renderer.setRenderTarget(t),this._gfx.renderer.clear(),r?(this._material.uniforms.srcTex.value=e.texture,this._material.uniforms.aberration.value.set(.995,1,1.01),this._gfx.renderer.render(this._scene,this._camera)):this._gfx.renderer.renderScreenQuadFromTexWithDistortion(e,J.now.debug.stereoBarrel)}},{key:"_renderOutline",value:function(e,t,r,n){var o=this._gfx;this._outlineMaterial.uniforms.srcTex.value=r.texture,this._outlineMaterial.uniforms.srcDepthTex.value=t.depthTexture,this._outlineMaterial.uniforms.srcTexSize.value.set(t.width,t.height),this._outlineMaterial.uniforms.color.value=new i.Q1f(J.now.outline.color),this._outlineMaterial.uniforms.threshold.value=J.now.outline.threshold,this._outlineMaterial.uniforms.thickness.value=new i.I9Y(J.now.outline.thickness,J.now.outline.thickness),o.renderer.setRenderTarget(n),o.renderer.renderScreenQuad(this._outlineMaterial)}},{key:"_renderShadowMap",value:function(){if(J.now.shadow.on){var e=this._gfx,t=e.renderer.getRenderTarget(),r=e.renderer.getActiveCubeFace(),n=e.renderer.getActiveMipmapLevel(),o=e.renderer.state;o.setBlending(i.XIg),o.buffers.color.setClear(1,1,1,1),o.buffers.depth.setTest(!0),o.setScissorTest(!1);for(var s=0;s<e.scene.children.length;s++)if("DirectionalLight"===e.scene.children[s].type){var a=e.scene.children[s];null==a.shadow.map&&(a.shadow.map=new i.nWS(a.shadow.mapSize.width,a.shadow.mapSize.height,this.pars),a.shadow.camera.updateProjectionMatrix()),a.shadow.updateMatrices(a),e.renderer.setRenderTarget(a.shadow.map),e.renderer.clear(),e.renderer.render(e.scene,a.shadow.camera)}e.renderer.setRenderTarget(t,r,n)}}},{key:"_hasSelectionToRender",value:function(){for(var e=this._gfx.selectionPivot,t=0;t<e.children.length;t++)if(e.children[t].children.length>0)return!0;return!1}},{key:"_renderSelection",value:function(e,t,r){var n=new qc,i=this._gfx;i.renderer.setClearColor("black",0),i.renderer.setRenderTarget(t),i.renderer.clear(!0,!1,!1),this._hasSelectionToRender()?(i.selectionRoot.matrix=i.root.matrix,i.selectionPivot.matrix=i.pivot.matrix,i.renderer.render(i.selectionScene,e)):i.renderer.renderDummyQuad(),i.renderer.setRenderTarget(r),i.renderer.renderScreenQuadFromTex(t.texture,.6),n.uniforms.srcTex.value=t.texture,n.uniforms.srcTexSize.value.set(t.width,t.height),i.renderer.renderScreenQuad(n)}},{key:"_checkVolumeRenderingSupport",value:function(e){if(!e)return!1;var t=this._gfx,r=t.renderer.getRenderTarget();t.renderer.setRenderTarget(e);var n=t.renderer.getContext(),i=n.checkFramebufferStatus(n.FRAMEBUFFER);return t.renderer.setRenderTarget(r),i===n.FRAMEBUFFER_COMPLETE||(this.logger.warn("Device doesn't support electron density rendering"),!1)}},{key:"_renderVolume",value:function(e,t,r,n,o,s){var a,l=new Ws.BackFacePosMaterial,c=new Ws.FrontFacePosMaterial,u=(new i.kn4).makeTranslation(.5,.5,.5),h=new i.kn4,f=this._gfx;if(void 0===a&&(a=this._checkVolumeRenderingSupport(n)),a){var d=e.getMesh();d.rebuild(f.camera),f.renderer.setClearColor("black",0),f.renderer.setRenderTarget(n),f.renderer.clear(),f.renderer.setRenderTarget(o),f.renderer.clear(),f.renderer.setRenderTarget(s),f.renderer.clear(),f.renderer.setRenderTarget(n),t.layers.set(kr.LAYERS.VOLUME_BFPLANE),f.renderer.render(f.scene,t),t.layers.set(kr.LAYERS.VOLUME),f.scene.overrideMaterial=l,f.renderer.render(f.scene,t),f.renderer.setRenderTarget(o),t.layers.set(kr.LAYERS.VOLUME),f.scene.overrideMaterial=c,f.renderer.render(f.scene,t),f.scene.overrideMaterial=null,t.layers.set(kr.LAYERS.DEFAULT),h.copy(d.matrixWorld).invert(),li.prototype.uberOptions.world2colorMatrix.multiplyMatrices(u,h),t.layers.set(kr.LAYERS.COLOR_FROM_POSITION),f.renderer.setRenderTarget(s),f.renderer.render(f.scene,t);var p=d.material;p.uniforms._BFRight.value=n.texture,p.uniforms._FFRight.value=o.texture,p.uniforms._WFFRight.value=s.texture,t.layers.set(kr.LAYERS.VOLUME),f.renderer.setRenderTarget(r),f.renderer.render(f.scene,t),t.layers.set(kr.LAYERS.DEFAULT)}}},{key:"_renderWithPrepassTransparency",value:function(e,t){var r=this._gfx;r.renderer.setRenderTarget(t),e.layers.set(kr.LAYERS.DEFAULT),r.renderer.render(r.scene,e),e.layers.set(kr.LAYERS.PREPASS_TRANSPARENT),r.renderer.getContext().colorMask(!1,!1,!1,!1),r.renderer.render(r.scene,e),r.renderer.getContext().colorMask(!0,!0,!0,!0),e.layers.set(kr.LAYERS.TRANSPARENT),r.renderer.render(r.scene,e),e.layers.set(kr.LAYERS.DEFAULT)}},{key:"_performFXAA",value:function(e,t){var r=new Wc;if(void 0!==e&&void 0!==t){var n=this._gfx;n.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),n.renderer.setRenderTarget(t),n.renderer.clear(),r.uniforms.srcTex.value=e.texture,r.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),r.uniforms.bgColor.value.set(J.now.bg.color),r.bgTransparent!==J.now.bg.transparent&&(r.setValues({bgTransparent:J.now.bg.transparent}),r.needsUpdate=!0),n.renderer.renderScreenQuad(r)}}},{key:"_performAO",value:function(e,t,r,n,o,s){var a=new Xc,l=new Zc,c=new Kc,u=new i.Pq0;if(e&&t&&r&&n&&o&&s){var h=this._gfx,f=Math.tan(.5*i.cj9.DEG2RAD*h.camera.fov);a.uniforms.diffuseTexture.value=e.texture,a.uniforms.depthTexture.value=r,a.uniforms.normalTexture.value=t.texture,a.uniforms.srcTexelSize.value.set(1/e.width,1/e.height),a.uniforms.camNearFar.value.set(h.camera.near,h.camera.far),a.uniforms.projMatrix.value=h.camera.projectionMatrix,a.uniforms.aspectRatio.value=h.camera.aspect,a.uniforms.tanHalfFOV.value=f,h.root.matrix.extractScale(u),a.uniforms.kernelRadius.value=J.now.debug.ssaoKernelRadius*u.x,a.uniforms.depthThreshold.value=2*this._getBSphereRadius(),a.uniforms.factor.value=J.now.debug.ssaoFactor,h.renderer.setRenderTarget(s),h.renderer.renderScreenQuad(a),l.uniforms.aoMap.value=s.texture,l.uniforms.srcTexelSize.value.set(1/s.width,1/s.height),l.uniforms.depthTexture.value=r,h.renderer.setRenderTarget(o),h.renderer.renderScreenQuad(l),c.uniforms.aoMap.value=o.texture,c.uniforms.diffuseTexture.value=e.texture,c.uniforms.srcTexelSize.value.set(1/o.width,1/o.height),c.uniforms.depthTexture.value=r,c.uniforms.projMatrix.value=h.camera.projectionMatrix,c.uniforms.aspectRatio.value=h.camera.aspect,c.uniforms.tanHalfFOV.value=f;var d=h.scene.fog;d&&(c.uniforms.fogNearFar.value.set(d.near,d.far),c.uniforms.fogColor.value.set(d.color.r,d.color.g,d.color.b,J.now.fogAlpha)),c.useFog===J.now.fog&&c.fogTransparent===J.now.bg.transparent||(c.setValues({useFog:J.now.fog,fogTransparent:J.now.bg.transparent}),c.needsUpdate=!0),h.renderer.setRenderTarget(n),h.renderer.renderScreenQuad(c)}}},{key:"reset",value:function(){this._picker&&this._picker.reset(),this._lastPick=null,this._releaseAllVisuals(),this._setEditMode(0),this._resetObjects(),this._gfx&&(kr.clearTree(this._gfx.pivot),this._gfx.renderer2d.reset()),this.setNeedRender()}},{key:"_resetScene",value:function(){this._objectControls.reset(),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.resetReps(),this.resetPivot(),this.rebuildAll()}},{key:"resetView",value:function(){this._picker&&this._picker.reset(),this._setEditMode(0),this._resetScene(),this._forEachComplexVisual((function(e){e.updateSelectionMask({}),e.rebuildSelectionGeometry()}))}},{key:"_export",value:function(e){var t=(0,n.head)(Ec.exporters.find({format:e}));if(!t)return this.logger.error("Could not find suitable exporter for this source"),Promise.reject(new Error("Could not find suitable exporter for this source"));if(this.dispatchEvent({type:"exporting"}),this._visuals[this._curVisualName]instanceof Fs){var r=null;return t.SourceClass===Fs?r=this._visuals[this._curVisualName]:t.SourceClass===cr&&(r=this._visuals[this._curVisualName]._complex),new t(r,{miewVersion:a.VERSION}).export().then((function(e){return e}))}return this._visuals[this._curVisualName]instanceof Zs?Promise.reject(new Error("Sorry, exporter for volume data not implemented yet")):Promise.reject(new Error("Unexpected format of data"))}},{key:"load",value:function(e,t){var r=this;t=(0,n.merge)({},t,{context:this}),this.settings.now.use.multiFile||(this._loading.length&&(this._loading.forEach((function(e){e.cancel()})),this._loading.length=0),t.animation||this.reset(!0)),this._interpolator.reset(),this.dispatchEvent({type:"loading",options:t,source:e});var i=new Z;this._loading.push(i),i.addEventListener("notification",(function(e){r.dispatchEvent(e.slaveEvent)})),this._spinner.spin(this._container);var o=function(e){var t=r._loading.indexOf(i);return-1!==t&&r._loading.splice(t,1),r._spinner.stop(),r._refreshTitle(),i.notify({type:"loadingDone",anything:e}),e};return function(e,t,r){return new Promise((function(i){if(r.shouldCancel())throw new Error("Operation cancelled");r.notify({type:"fetching"}),e=function(e,t){if(!(0,n.isString)(e))return e;var r=yu.exec(e);if(r){var i=v(r,3),o=i[1],s=void 0===o?"pdb":o,a=i[2];switch(s=s.toLowerCase(),a=a.toUpperCase(),s){case"pdb":e="https://files.rcsb.org/download/".concat(a,".pdb");break;case"cif":e="https://files.rcsb.org/download/".concat(a,".cif");break;case"mmtf":e="https://mmtf.rcsb.org/v1.0/full/".concat(a);break;case"ccp4":e="https://www.ebi.ac.uk/pdbe/coordinates/files/".concat(a.toLowerCase(),".ccp4");break;case"dsn6":e="https://edmaps.rcsb.org/maps/".concat(a.toLowerCase(),"_2fofc.dsn6");break;default:throw new Error("Unexpected data format shortcut")}return t.fileType=s,t.fileName="".concat(a,".").concat(s),t.sourceType="url",e}var l=_u.exec(e);if(l){var c=l[1].toLowerCase();return e="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/".concat(c,"/JSON?record_type=3d"),t.fileType="pubchem",t.fileName="".concat(c,".json"),t.sourceType="url",e}return"url"!==t.sourceType&&void 0!==t.sourceType||(t.sourceType="url",gu.test(e)||(e=$.resolveURL(e))),e}(e,t);var o=(0,n.head)(Ec.loaders.find({type:t.sourceType,source:e}));if(!o)throw new Error(cu);var s=t.fileName||o.extractName(e);if(s){var a=v($.splitFileName(s),2),l=a[0],c=a[1];(0,n.defaults)(t,{name:l,fileExt:c,fileName:s})}!function(e){var t=e.binary;if(void 0!==e.fileType){var r=(0,n.head)(Ec.parsers.find({format:e.fileType}));if(!r)throw new Error("Could not find suitable parser for this format");t=r.binary||!1}if(void 0===t&&void 0!==e.fileExt){var i=(0,n.head)(Ec.parsers.find({ext:e.fileExt}));i&&(t=i.binary||!1)}void 0!==e.fileExt&&".man"===e.fileExt.toLowerCase()&&(e.binary=!0,e.animation=!0),void 0!==t&&void 0!==e.binary&&e.binary!==t&&e.context.logger.warn("Overriding incorrect binary mode"),e.binary=t||!1}(t);var u=(0,n.get)(t,"preset.expression");if(!(0,n.isUndefined)(u)&&(u=JSON.parse(u))&&u.settings)for(var h=["singleUnit"],f=0,d=h.length;f<d;++f){var p=h[f],m=(0,n.get)(u.settings,p);(0,n.isUndefined)(m)||J.set(p,m)}var y=new o(e,t);y.context=t.context,r.addEventListener("cancel",(function(){return y.abort()})),y.addEventListener("progress",(function(e){e.lengthComputable&&e.total>0?fu(y.logger,"Fetching",e.loaded/e.total):fu(y.logger,"Fetching")})),console.time("fetch"),i(y.load().then((function(e){return console.timeEnd("fetch"),t.context.logger.info("Fetching finished"),r.notify({type:"fetchingDone",data:e}),e})).catch((function(e){throw console.timeEnd("fetch"),t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Fetching failed"),r.notify({type:"fetchingDone",error:e}),e})))}))}(e,t,i).then((function(e){return function(e,t,r){if(r.shouldCancel())return Promise.reject(new Error("Operation cancelled"));r.notify({type:"parsing"});var i=(0,n.head)(Ec.parsers.find({format:t.fileType,ext:t.fileExt,data:e}));if(!i)return Promise.reject(new Error("Could not find suitable parser"));var o=new i(e,t);return o.context=t.context,r.addEventListener("cancel",(function(){return o.abort()})),console.time("parse"),o.parse().then((function(e){return console.timeEnd("parse"),r.notify({type:"parsingDone",data:e}),e})).catch((function(e){throw console.timeEnd("parse"),t.error=e,t.context.logger.debug(e.message),e.stack&&t.context.logger.debug(e.stack),t.context.logger.error("Parsing failed"),r.notify({type:"parsingDone",error:e}),e}))}(e,t,i)})).then((function(e){var n=r._onLoad(e,t);return o(n)})).catch((function(e){throw r.logger.error("Could not load data"),r.logger.debug(e),o(e)}))}},{key:"unload",value:function(e){this._removeVisual(e||this.getCurrentVisual()),this.resetPivot(),J.now.shadow.on&&this._updateShadowCamera()}},{key:"_startAnimation",value:function(e){this._stopAnimation();var t=this,r=this._getComplexVisual();if(null!==r){try{this._frameInfo=new jc(r.getComplex(),e,{onLoadStatusChanged:function(){t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:!t._frameInfo||t._frameInfo.isLoading}})},onError:function(e){t._stopAnimation(),t.logger.error(e)}})}catch(e){return void this.logger.error("Animation file does not fit to current complex!")}this._continueAnimation()}else this.logger.error("Unable to start animation - no molecule is loaded.")}},{key:"_pauseAnimation",value:function(){null!==this._animInterval&&(this._isAnimating=!1,clearInterval(this._animInterval),this._animInterval=null,this._frameInfo&&this.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:this._isAnimating,isLoading:this._frameInfo.isLoading}}))}},{key:"_continueAnimation",value:function(){this._isAnimating=!0;var e=1e3/J.now.maxfps;e=Number.isNaN(e)?0:e;var t=this,r=t._gfx.pivot,n=this._getComplexVisual();n&&(n.resetSelectionMask(),n.rebuildSelectionGeometry(),this._msgAtomInfo.style.opacity=0),this._animInterval=setInterval((function(){if(t.dispatchEvent({type:"mdPlayerStateChanged",state:{isPlaying:t._isAnimating,isLoading:t._frameInfo.isLoading}}),t._frameInfo.frameIsReady){r.updateToFrame(t._frameInfo),t._updateObjsToFrame(t._frameInfo),t._refreshTitle(" Frame ".concat(t._frameInfo._currFrame," of ").concat(t._frameInfo._framesCount," time interval - ").concat(t._frameInfo._timeStep));try{t._frameInfo.nextFrame()}catch(e){return t.logger.error("Error during animation"),void t._stopAnimation()}t._needRender=!0}}),e)}},{key:"_stopAnimation",value:function(){null!==this._animInterval&&(clearInterval(this._animInterval),this._frameInfo.disableEvents(),this._frameInfo=null,this._animInterval=null,this.dispatchEvent({type:"mdPlayerStateChanged",state:null}))}},{key:"_onLoad",value:function(e,t){var r=this._gfx,i=null;if(t.animation)return this._refreshTitle(),this._startAnimation(e),null;if(this._stopAnimation(),t&&t.keepRepsInfo||(this._opts.reps=null,this._opts._objects=null),"Complex"===e.id){var o=e;t.fileName?o.name=o.name||hu(t.fileName).toUpperCase():t.amberFileName?o.name=o.name||hu(t.amberFileName).toUpperCase():o.name="Dynamic ".concat(t.fileType," molecule"),i=this._addVisual(new Fs(o.name,o)),this._curVisualName=i;var s=this.info();if(this.logger.info("Parsed ".concat(t.fileName," (").concat(s.atoms," atoms, ").concat(s.bonds," bonds, ").concat(s.residues," residues, ").concat(s.chains," chains).")),(0,n.isNumber)(this._opts.unit)&&o.setCurrentUnit(this._opts.unit),t.preset);else if(J.now.autoPreset)switch(t.fileType){case"cml":this.resetReps("small");break;case"pdb":case"mmtf":case"cif":!function(e){var t=!1;return e.forEachComponent((function(e){e.forEachResidue((function(e){e._isValid&&(t=!0)}))})),t}(o)?this.resetReps("small"):this.resetReps("macro");break;default:this.resetReps("default")}else this.resetReps("default")}else"Volume"===e.id&&(this.resetEd(),i=this._onLoadEd(e));return r.camera.updateProjectionMatrix(),this._updateFog(),r.root.resetTransform(),this.resetPivot(),this._objectControls.setScale(J.now.radiusToFit/this._getBSphereRadius()),this._resetObjects(),J.now.autoResolution&&this._tweakResolution(),J.now.shadow.on&&this._updateShadowCamera(),this._opts.view&&(this.view(this._opts.view),delete this._opts.view),this._refreshTitle(),i}},{key:"resetEd",value:function(){this._edLoader&&(this._edLoader.abort(),this._edLoader=null),this._removeVisual(this._getVolumeVisual()),this._needRender=!0}},{key:"loadEd",value:function(e){var t=this;this.resetEd();var r=(0,n.head)(Ec.loaders.find({source:e}));if(!r)return this.logger.error(cu),Promise.reject(new Error(cu));var i=this._edLoader=new r(e,{binary:!0});return i.context=this,i.load().then((function(e){var r=(0,n.head)(Ec.parsers.find({format:"ccp4"}));if(!r)throw new Error("Could not find suitable parser for this source");var i=new r(e);return i.context=t,i.parse().then((function(e){t._onLoadEd(e)}))})).catch((function(e){t.logger.error("Could not load ED data"),t.logger.debug(e)}))}},{key:"_onLoadEd",value:function(e){e.normalize();var t=new Zs("volume",e);t.getMesh().layers.set(kr.LAYERS.VOLUME);var r=this._addVisual(t);return this._needRender=!0,r}},{key:"_needRebuild",value:function(){var e=!1;return this._forEachComplexVisual((function(t){e=e||t.needsRebuild()})),e}},{key:"_rebuildObjects",value:function(){var e,t,r=this,n=this._gfx,i=[];for(e=0;e<n.pivot.children.length;++e){var o=n.pivot.children[e];o instanceof Er||i.push(o)}for(e=0;e<i.length;++e)i[e].parent.remove(i[e]);setTimeout((function(){var i=r._objects;for(e=0,t=i.length;e<t;++e){var o=i[e];o.needsRebuild&&o.build(),o.getGeometry()&&n.pivot.add(o.getGeometry())}}),10)}},{key:"changeUnit",value:function(e,t){var r,i,o=this._getComplexVisual(t);if(!o)throw new Error("There is no complex to change!");return void 0===e||((0,n.isString)(e)&&(e=Math.max(parseInt(e,10),0)),o.getComplex().setCurrentUnit(e)&&(this._resetScene(),this._updateInfoPanel())),r=o?o.getComplex().getCurrentUnit():0,i=r>0?"Bio molecule ".concat(r):"Asymmetric unit","Current unit: ".concat(r," (").concat(i,")")}},{key:"rebuild",value:function(){var e=this;if(this._building)this.logger.warn("Miew.rebuild(): already building!");else{this._building=!0,this.dispatchEvent({type:"rebuilding"}),this._rebuildObjects(),this._gfx.renderer2d.reset();var t=[];this._forEachComplexVisual((function(e){e.needsRebuild()&&t.push(e.rebuild().then((function(){return new Promise((function(t){e.rebuildSelectionGeometry(),t()}))})))}));var r=this;this._spinner.spin(this._container),Promise.all(t).then((function(){r._spinner.stop(),r._needRender=!0,r._refreshTitle(),e.dispatchEvent({type:"buildingDone"}),r._building=!1}))}}},{key:"rebuildAll",value:function(){this._forEachComplexVisual((function(e){e.setNeedsRebuild()}))}},{key:"_refreshTitle",value:function(e){var t;e=void 0===e?"":e;var r=this._getComplexVisual();if(r){t=r.getComplex().name;var n=r.repGet(r.repCurrent());t+=n?" – ".concat(n.mode.name," Mode"):""}else t=Object.keys(this._visuals).length>0?"Unknown":"No Data";t+=e,this.dispatchEvent({type:"titleChanged",data:t})}},{key:"setNeedRender",value:function(){this._needRender=!0}},{key:"_extractRepresentation",value:function(){var e=this,t=[];this._forEachComplexVisual((function(r){if(0!==r.getSelectionCount()){var n=r.buildSelectorFromMask(1<<r.getSelectionBit()),i=J.now.presets.default,o=r.repAdd({selector:n,mode:i[0].mode.id,colorer:i[0].colorer.id,material:i[0].material.id});o?(e.dispatchEvent({type:"repAdded",index:o.index,name:r.name}),r.repCurrent(o.index),t.push(r.name)):r.repCount()===Fs.NUM_REPRESENTATION_BITS&&e.logger.warn("Number of representations is limited to ".concat(Fs.NUM_REPRESENTATION_BITS))}})),t.length>0&&this.logger.report("New representation from selection for complexes: ".concat(t.join(", ")))}},{key:"_setReps",value:function(e){e=e||this._opts&&this._opts.reps||[],this._forEachComplexVisual((function(t){return t.resetReps(e)}))}},{key:"applyPreset",value:function(e){for(var t=J.now.presets,r=[e||J.defaults.preset,J.defaults.preset,Object.keys(t)[0]],n=null,i=0;!n&&i<r.length;++i)J.set("preset",r[i]),(n=t[J.now.preset])||this.logger.warn('Unknown preset "'.concat(J.now.preset,'"'));this._setReps(n)}},{key:"resetReps",value:function(e){var t=this._opts&&this._opts.reps;t?this._setReps(t):this.applyPreset(e)}},{key:"repCount",value:function(e){var t=this._getComplexVisual(e);return t?t.repCount():0}},{key:"repCurrent",value:function(e,t){var r=this._getComplexVisual(t),n=r?r.repCurrent(e):-1;return e&&n!==e&&this.logger.warn("Representation ".concat(e," was not found. Current rep remains unchanged.")),n}},{key:"rep",value:function(e,t){var r=this._getComplexVisual("");if(!r)return null;var n=r.rep(e,t);return"created"===n.status?this.dispatchEvent({type:"repAdded",index:n.index,name:r.name}):"changed"===n.status&&this.dispatchEvent({type:"repChanged",index:n.index,name:r.name}),n.desc}},{key:"repGet",value:function(e,t){var r=this._getComplexVisual(t);return r?r.repGet(e):null}},{key:"repAdd",value:function(e,t){var r=this._getComplexVisual(t);if(!r)return-1;var n=r.repAdd(e);return n?(this.dispatchEvent({type:"repAdded",index:n.index,name:t}),n.index):-1}},{key:"repRemove",value:function(e,t){var r=this._getComplexVisual(t);r&&(r.repRemove(e),this.dispatchEvent({type:"repRemoved",index:e,name:t}))}},{key:"repHide",value:function(e,t,r){this._needRender=!0;var n=this._getComplexVisual(r);return n?n.repHide(e,t):null}},{key:"_setEditMode",value:function(e){this._editMode=e;var t=this._msgMode;t&&(t.style.opacity=0===e?0:1,0!==e&&(t.getElementsByTagName("p")[0].innerHTML=1===e?"COMPONENT EDIT MODE":"FRAGMENT EDIT MODE")),this.dispatchEvent({type:"editModeChanged",data:0===e})}},{key:"_enterComponentEditMode",value:function(){if(0===this._editMode){var e=[];this._forEachComplexVisual((function(t){var r=t.beginComponentEdit();r&&e.push(r)})),e!==[]&&(this._editors=e,this.logger.info("COMPONENT EDIT MODE -- ON"),this._setEditMode(1),this._objectControls.keysTranslateObj(!0))}}},{key:"_applyComponentEdit",value:function(){if(1===this._editMode){this._objectControls.stop(),this._objectControls.keysTranslateObj(!1);for(var e=0;e<this._editors.length;++e)this._editors[e].apply();this._editors=[],this.logger.info("COMPONENT EDIT MODE -- OFF (applied)"),this._setEditMode(0),this.rebuildAll()}}},{key:"_discardComponentEdit",value:function(){if(1===this._editMode){this._objectControls.stop(),this._objectControls.keysTranslateObj(!1);for(var e=0;e<this._editors.length;++e)this._editors[e].discard();this._editors=[],this.logger.info("COMPONENT EDIT MODE -- OFF (discarded)"),this._setEditMode(0),this._needRender=!0,this.rebuildAll()}}},{key:"_enterFragmentEditMode",value:function(){if(0===this._editMode){var e=[];if(this._forEachComplexVisual((function(t){t instanceof Fs&&t.getSelectionCount()>0&&e.push(t)})),1===e.length){var t=e[0].beginFragmentEdit();t&&(this._editors=[t],this.logger.info("FRAGMENT EDIT MODE -- ON (single bond)"),this._setEditMode(2),this._objectControls.allowTranslation(!1),this._objectControls.allowAltObjFreeRotation(t.isFreeRotationAllowed()),this._needRender=!0)}}}},{key:"_applyFragmentEdit",value:function(){if(2===this._editMode){this._objectControls.stop();for(var e=0;e<this._editors.length;++e)this._editors[e].apply();this._editors=[],this.logger.info("FRAGMENT EDIT MODE -- OFF (applied)"),this._setEditMode(0),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this.rebuildAll()}}},{key:"_discardFragmentEdit",value:function(){if(2===this._editMode){this._objectControls.stop();for(var e=0;e<this._editors.length;++e)this._editors[e].discard();this._editors=[],this.logger.info("FRAGMENT EDIT MODE -- OFF (discarded)"),this._setEditMode(0),this._objectControls.allowTranslation(!0),this._objectControls.allowAltObjFreeRotation(!0),this._needRender=!0}}},{key:"_onPick",value:function(e){if(J.now.picking&&null===this._animInterval&&2!==this._editMode&&!this._objectControls.isEditingAltObj()){var t=null;if(e.obj.atom?(t=e.obj.atom.residue.getChain().getComplex(),this._lastPick=e.obj.atom):e.obj.residue?(t=e.obj.residue.getChain().getComplex(),this._lastPick=e.obj.residue):e.obj.chain?(t=e.obj.chain.getComplex(),this._lastPick=e.obj.chain):e.obj.molecule?(t=e.obj.molecule.complex,this._lastPick=e.obj.molecule):this._lastPick=null,t){var r=this._getVisualForComplex(t);r&&(n(r),this._needRender=!0)}else this._forEachComplexVisual(n),this._needRender=!0;this._updateInfoPanel(),this.dispatchEvent(e)}function n(t){t.updateSelectionMask(e.obj),t.rebuildSelectionGeometry()}}},{key:"_onKeyDown",value:function(e){if(this._running&&this._hotKeysEnabled)switch(e.keyCode){case"C".charCodeAt(0):J.now.editing&&this._enterComponentEditMode();break;case"F".charCodeAt(0):J.now.editing&&this._enterFragmentEditMode();break;case"A".charCodeAt(0):switch(this._editMode){case 1:this._applyComponentEdit();break;case 2:this._applyFragmentEdit()}break;case"D".charCodeAt(0):switch(this._editMode){case 1:this._discardComponentEdit();break;case 2:this._discardFragmentEdit()}break;case"S".charCodeAt(0):e.preventDefault(),e.stopPropagation(),J.set("ao",!J.now.ao),this._needRender=!0;break;case 107:e.preventDefault(),e.stopPropagation(),this._forEachComplexVisual((function(e){e.expandSelection(),e.rebuildSelectionGeometry()})),this._updateInfoPanel(),this._needRender=!0;break;case 109:e.preventDefault(),e.stopPropagation(),this._forEachComplexVisual((function(e){e.shrinkSelection(),e.rebuildSelectionGeometry()})),this._updateInfoPanel(),this._needRender=!0}}},{key:"_onKeyUp",value:function(e){this._running&&this._hotKeysEnabled&&e.keyCode==="X".charCodeAt(0)&&this._extractRepresentation()}},{key:"_updateInfoPanel",value:function(){var e,t,r=this._msgAtomInfo.getElementsByTagName("p")[0],n=0;for(this._forEachComplexVisual((function(e){n+=e.getSelectionCount()}));r.firstChild;)r.removeChild(r.firstChild);if(0!==n){var i="".concat(String(n)," atom").concat(1!==n?"s":""," selected");null!==this._lastPick&&(i+=", the last pick:");var o="",s="",a="";if(this._lastPick instanceof ou){t=(e=this._lastPick).residue,s=e.name;var l=32!==e.location?String.fromCharCode(e.location):"";o="".concat(e.element.fullName," #").concat(e.serial).concat(l,": ").concat(t._chain._name,".").concat(t._type._name).concat(t._sequence).concat(t._icode.trim(),"."),o+=s,a="Coord: (".concat(e.position.x.toFixed(2).toString(),", ").concat(e.position.y.toFixed(2).toString(),", ").concat(e.position.z.toFixed(2).toString(),")")}else this._lastPick instanceof su?(t=this._lastPick,o="".concat(t._type._fullName,": ").concat(t._chain._name,".").concat(t._type._name).concat(t._sequence).concat(t._icode.trim())):this._lastPick instanceof au?o="chain ".concat(this._lastPick._name):this._lastPick instanceof lu&&(o="molecule ".concat(this._lastPick._name));r.appendChild(document.createTextNode(i)),""!==o&&(r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(o))),""!==a&&(r.appendChild(document.createElement("br")),r.appendChild(document.createTextNode(a))),this._msgAtomInfo.style.opacity=1}else this._msgAtomInfo.style.opacity=0}},{key:"_getAltObj",value:function(){if(this._editors){for(var e=null,t=0;t<this._editors.length;++t){var r=this._editors[t].getAltObj();if(r.objects.length>0){if(e){e=null;break}e=r}}if(e)return e}return{objects:[],pivot:new i.Pq0(0,0,0)}}},{key:"resetPivot",value:function(){var e=new i.NRn,t=new i.Pq0;e.makeEmpty(),this._forEachVisual((function(t){e.union(t.getBoundaries().boundingBox)})),e.getCenter(t),this._objectControls.setPivot(t.negate()),this.dispatchEvent({type:"transform"})}},{key:"setPivotResidue",value:function(e){var t=new i.Pq0,r=this._getVisualForComplex(e.getChain().getComplex());if(r){if(e._controlPoint)t.copy(e._controlPoint);else{for(var n=0,o=0,s=0,a=e._atoms.length,l=0;l<a;++l){var c=e._atoms[l].position;n+=c.x/a,o+=c.y/a,s+=c.z/a}t.set(n,o,s)}t.applyMatrix4(r.matrix).negate(),this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"})}}},{key:"setPivotAtom",value:function(e){var t=new i.Pq0,r=this._getVisualForComplex(e.residue.getChain().getComplex());r&&(t.copy(e.position),t.applyMatrix4(r.matrix).negate(),this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"}))}},{key:"getSelectionCenter",value:function(e,t,r){var n=new i.Pq0(0,0,0);e.set(0,0,0);var o=0;return this._forEachComplexVisual((function(i){i.getSelectionCenter(n,t,r||i.getSelectionBit())&&(e.add(n),o++)})),0!==o&&(e.divideScalar(o),e.negate(),!0)}},{key:"setPivotSubset",value:function(e){var t=new i.Pq0(0,0,0),r=e?bu:xu;this.getSelectionCenter(t,r,e)?(this._objectControls.setPivot(t),this.dispatchEvent({type:"transform"})):this.logger.warn("selection is empty. Center operation not performed")}},{key:"screenshot",value:function(e,t){var r,n,o,s=this._gfx,a=s.renderer.domElement.width,l=s.renderer.domElement.height;function c(){var r;if($.getBrowser()===$.browserType.SAFARI){var n=document.createElement("canvas"),i=n.getContext("2d");n.width=void 0===e?a:e,n.height=void 0===t?l:t,i.drawImage(s.renderer.domElement,0,0,n.width,n.height),r=n.toDataURL("image/png")}else r=s.renderer.domElement.toDataURL("image/png");return r}if(t=t||e,void 0===e&&void 0===t||e===a&&t===l)r=c();else{var u=s.camera.aspect,h=s.camera.fov,f=(o=s.camera.fov,Math.tan(i.cj9.degToRad(.5*o))*Math.min(s.width,s.height)/s.height),d=e/t;s.renderer.setPixelRatio(1),s.camera.aspect=d,s.camera.fov=(n=f/Math.min(d,1),2*i.cj9.radToDeg(Math.atan(n))),s.camera.updateProjectionMatrix(),s.renderer.setDrawingBufferSize(e,t,1),this._renderFrame(J.now.stereo),r=c(),s.renderer.setPixelRatio(window.devicePixelRatio),s.camera.aspect=u,s.camera.fov=h,s.camera.updateProjectionMatrix(),s.renderer.setDrawingBufferSize(s.width,s.height,window.devicePixelRatio),this._needRender=!0}return r}},{key:"screenshotSave",value:function(e,t,r){var n=this.screenshot(t,r);$.shotDownload(n,e)}},{key:"save",value:function(e){var t=this;this._export(e.fileType).then((function(r){var n=t._visuals[t._curVisualName]._complex.name;$.download(r,n,e.fileType),t._refreshTitle(),t.dispatchEvent({type:"exportingDone"})})).catch((function(e){t.logger.error("Could not export data"),t.logger.debug(e),t._refreshTitle(),t.dispatchEvent({type:"exportingDone",error:e})}))}},{key:"_tweakResolution",value:function(){var e=[["poor",100],["low",500],["medium",1e3],["high",5e3],["ultra",Number.MAX_VALUE]],t=0;if(this._forEachComplexVisual((function(e){t+=e.getComplex().getAtomCount()})),t>0)for(var r=1e6*this._gfxScore/t,n=0;n<e.length;++n)if(r<e[n][1]){this._autoChangeResolution(e[n][0]);break}}},{key:"_autoChangeResolution",value:function(e){e!==J.now.resolution&&this.logger.report('Your rendering resolution was changed to "'.concat(e,'" for best performance.')),J.now.resolution=e}},{key:"saveSettings",value:function(){this._cookies.setCookie(this._opts.settingsCookie,JSON.stringify(this.settings.getDiffs(!0)))}},{key:"restoreSettings",value:function(){try{var e=this._cookies.getCookie(this._opts.settingsCookie),t=e?JSON.parse(e):{};this.settings.applyDiffs(t,!0)}catch(e){this.logger.error("Cookies parse error: ".concat(e.message))}}},{key:"resetSettings",value:function(){this.settings.reset()}},{key:"setOptions",value:function(e){"string"==typeof e&&(e=a.options.fromAttr(e)),e.reps&&(this._opts.reps=null),(0,n.merge)(this._opts,e),e.settings&&this.set(e.settings),this._opts._objects=e._objects,this._resetObjects(),e.load&&this.load(e.load,{fileType:e.type}),e.preset&&(J.now.preset=e.preset),e.reps&&this.resetReps(e.preset),this._opts.view&&(this.view(this._opts.view),delete this._opts.view);var t=this._getComplexVisual();t&&(t.getComplex().resetCurrentUnit(),(0,n.isNumber)(e.unit)&&t.getComplex().setCurrentUnit(e.unit),this.resetView(),this.rebuildAll())}},{key:"info",value:function(e){var t=this._getComplexVisual(e);if(!t)return{};var r=t.getComplex(),n=r.metadata;return{id:n.id||r.name||"UNKNOWN",title:n.title&&n.title.join(" ")||"UNKNOWN DATA",atoms:r.getAtomCount(),bonds:r.getBondCount(),residues:r.getResidueCount(),chains:r.getChainCount()}}},{key:"addObject",value:function(e,t){var r=null;if(e.type===Hc.prototype.type&&(r=Hc),null===r)throw new Error("Unknown scene object type - ".concat(e.type));try{var n=new r(e.params,e.opts);this._addSceneObject(n)}catch(e){if(t)throw e;this.logger.debug("Error during scene object creation: ".concat(e.message))}this._needRender=!0}},{key:"_addSceneObject",value:function(e){var t=this._getComplexVisual();e.build&&t&&(e.build(t.getComplex()),this._gfx.pivot.add(e.getGeometry()));var r=this._objects;r[r.length]=e}},{key:"_updateObjsToFrame",value:function(e){for(var t=this._objects,r=0,n=t.length;r<n;++r)t[r].updateToFrame&&t[r].updateToFrame(e)}},{key:"_resetObjects",value:function(){var e=this._opts._objects;if(this._objects=[],e)for(var t=0,r=e.length;t<r;++t)this.addObject(e[t],!1)}},{key:"removeObject",value:function(e){var t=this._objects[e];if(!t)throw new Error("Scene object with index ".concat(e," does not exist"));t.destroy(),this._objects.splice(e,1),this._needRender=!0}},{key:"getURL",value:function(e){return we.toURL(this.getState((0,n.defaults)(e,{compact:!0,settings:!1,view:!1})))}},{key:"getScript",value:function(e){return we.toScript(this.getState((0,n.defaults)(e,{compact:!0,settings:!0,view:!0})))}},{key:"_compareReps",value:function(e,t){var r={},i=0;e&&(i=e.repCount());var o=J.defaults.presets[J.now.preset],s=t;void 0===o||o.length>i?(s=!1,r.preset="empty"):J.now.preset!==J.defaults.preset&&(r.preset=J.now.preset);for(var a=[],l=!0,c=0,u=i;c<u;++c)a[c]=e.repGet(c).compare(s?o[c]:null),(0,n.isEmpty)(a[c])||(l=!1);return l||(r.reps=a),r}},{key:"getState",value:function(e){var t={};e=(0,n.defaults)(e,{compact:!0,settings:!1,view:!1});var r=this._getComplexVisual();if(null!==r){var i=r.getComplex(),o=i.metadata;if(o.id){var s=o.format?"".concat(o.format,":"):"";t.load=s+o.id}var a=i.getCurrentUnit();1!==a&&(t.unit=a)}var l=this._compareReps(r,e.compact);l.preset&&(t.preset=l.preset),l.reps&&(t.reps=l.reps);for(var c=this._objects,u=[],h=0,f=c.length;h<f;++h)u[h]=c[h].identify();if(c.length>0&&(t._objects=u),e.view&&(t.view=this.view()),e.settings){var d=this.settings.getDiffs(!1);(0,n.isEmpty)(d)||(t.settings=d)}return t}},{key:"get",value:function(e,t){return J.get(e,t)}},{key:"_clipPlaneUpdateValue",value:function(e){var t=Math.max(this._gfx.camera.position.z-e*J.now.draft.clipPlaneFactor,J.now.camNear),r={clipPlaneValue:t};this._forEachComplexVisual((function(e){e.setUberOptions(r)}));for(var n=0,i=this._objects.length;n<i;++n){var o=this._objects[n];o._line&&o._line.material.setUberOptions(r)}null!==this._picker&&(this._picker.clipPlaneValue=t)}},{key:"_fogFarUpdateValue",value:function(){null!==this._picker&&(this._gfx.scene.fog?this._picker.fogFarValue=this._gfx.scene.fog.far:this._picker.fogFarValue=void 0)}},{key:"_updateShadowmapMeshes",value:function(e){this._forEachComplexVisual((function(t){for(var r=t._reprList,n=0,i=r.length;n<i;++n){var o=r[n];e(o.geo,o.material)}}))}},{key:"_updateMaterials",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this._forEachComplexVisual((function(n){return n.setMaterialValues(e,t,r)}));for(var n=0,i=this._objects.length;n<i;++n){var o=this._objects[n];o._line&&(o._line.material.setValues(e),o._line.material.needsUpdate=!0)}}},{key:"_fogAlphaChanged",value:function(){this._forEachComplexVisual((function(e){e.setUberOptions({fogAlpha:J.now.fogAlpha})}))}},{key:"_embedWebXR",value:function(){var e=this;if("WEBVR"!==J.now.stereo)return this.webVR&&this.webVR.disable(),void(this.webVR=null);this.webVR||(this.webVR=new nu((function(){e._requestAnimationFrame((function(){return e._onTick()})),e._needRender=!0,e._onResize()}))),this.webVR.enable(this._gfx)}},{key:"_initOnSettingsChanged",value:function(){var e=this,t=function(t,r){(t=(0,n.isArray)(t)?t:[t]).forEach((function(t){e.settings.addEventListener("change:".concat(t),r)}))};t("modes.VD.frame",(function(){var t=e._getVolumeVisual();null!==t&&(t.showFrame(J.now.modes.VD.frame),e._needRender=!0)})),t("modes.VD.isoMode",(function(){var t=e._getVolumeVisual();null!==t&&(t.getMesh().material.updateDefines(),e._needRender=!0)})),t("bg.color",(function(){e._onBgColorChanged()})),t("ao",(function(){if(J.now.ao&&!vu(e._gfx.renderer.getContext()))e.logger.warn("Your device or browser does not support ao"),J.set("ao",!1);else{var t={normalsToGBuffer:J.now.ao};e._setUberMaterialValues(t)}})),t("zSprites",(function(){J.now.zSprites&&!mu(e._gfx.renderer.getContext())&&(e.logger.warn("Your device or browser does not support zSprites"),J.set("zSprites",!1)),e.rebuildAll()})),t("fogColor",(function(){e._onFogColorChanged()})),t("fogColorEnable",(function(){e._onFogColorChanged()})),t("bg.transparent",(function(t){var r=e._gfx;r&&r.renderer.setClearColor(J.now.bg.color,Number(!J.now.bg.transparent)),e._updateMaterials({fogTransparent:t.value}),e.rebuildAll()})),t("draft.clipPlane",(function(t){e._updateMaterials({clipPlane:t.value}),e.rebuildAll()})),t("shadow.on",(function(t){var r={shadowmap:t.value,shadowmapType:J.now.shadow.type},n=e._gfx;n&&(n.renderer.shadowMap.enabled=Boolean(r.shadowmap)),e._updateMaterials(r,!0),r.shadowmap?(e._updateShadowCamera(),e._updateShadowmapMeshes(Es.createShadowmapMaterial)):e._updateShadowmapMeshes(Es.removeShadowmapMaterial),e._needRender=!0})),t("shadow.type",(function(t){J.now.shadow.on&&(e._updateMaterials({shadowmapType:t.value},!0),e._needRender=!0)})),t("shadow.radius",(function(t){for(var r=0;r<e._gfx.scene.children.length;r++)void 0!==e._gfx.scene.children[r].shadow&&(e._gfx.scene.children[r].shadow.radius=t.value,e._needRender=!0)})),t("fps",(function(){e._fps.show(J.now.fps)})),t(["fog","fogNearFactor","fogFarFactor"],(function(){e._updateFog(),e._needRender=!0})),t("fogAlpha",(function(){var t=J.now.fogAlpha;(t<0||t>1)&&e.logger.warn("fogAlpha must belong range [0,1]"),e._fogAlphaChanged(),e._needRender=!0})),t("autoResolution",(function(t){t.value&&!e._gfxScore&&e.logger.warn("Benchmarks are missed, autoresolution will not work! Autoresolution should be set during miew startup.")})),t("stereo",(function(){e._embedWebXR("WEBVR"===J.now.stereo),e._needRender=!0})),t(["transparency","palette"],(function(){e.rebuildAll()})),t("resolution",(function(){e.rebuildAll();var t=e._getVolumeVisual();t&&(t.getMesh().material.updateDefines(),e._needRender=!0)})),t(["axes","fxaa","ao","outline.on","outline.color","outline.threshold","outline.thickness"],(function(){e._needRender=!0}))}},{key:"set",value:function(e,t){J.set(e,t)}},{key:"select",value:function(e,t){var r=this._getComplexVisual();if(r){var i=e;(0,n.isString)(e)&&(i=iu.parse(e).selector),r.select(i,t),this._lastPick=null,this._updateInfoPanel(),this._needRender=!0}}},{key:"view",value:function(e){var t,r,n,o=this,s=this._gfx.pivot,a=[];return void 0===e?(t=s.position,r=o._objectControls.getScale()/J.now.radiusToFit,(n=new i.O9p).setFromQuaternion(o._objectControls.getOrientation(),"ZXY"),a=[t.x,t.y,t.z,r,n.x,n.y,n.z],"1"+$.arrayToBase64(a,Float32Array)):(function(){40===e.length&&(e="0".concat(e));var t=e[0];if(a=$.arrayFromBase64(e.substr(1),Float32Array),"1"!==t){if("0"!==t)return void o.logger.warn("Encoded view version mismatch, stored as ".concat(t," vs ").concat("1"," expected"));a[3]/=8}var r=o._interpolator,n=r.createView();n.position.copy(s.position),n.scale=o._objectControls.getScale(),n.orientation.copy(o._objectControls.getOrientation());var l=r.createView();l.position.set(a[0],a[1],a[2]),o._getComplexVisual()&&l.position.sub(o._getComplexVisual().position),l.scale=a[3],l.orientation.setFromEuler(new i.O9p(a[4],a[5],a[6],"ZXY")),r.setup(n,l)}(),e)}},{key:"_updateView",value:function(){var e=this,t=this._gfx.pivot,r=this._interpolator;if(r.wasStarted()||r.start(),r.isMoving()){var n=r.getCurrentView();if(n.success){var i=n.view;t.position.copy(i.position),e._objectControls.setScale(i.scale*J.now.radiusToFit),e._objectControls.setOrientation(i.orientation),this.dispatchEvent({type:"transform"}),e._needRender=!0}}}},{key:"translate",value:function(e,t,r){this._objectControls.translatePivot(e,t,r),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"rotate",value:function(e,t,r){this._objectControls.rotate((new i.PTz).setFromEuler(new i.O9p(e,t,r,"XYZ"))),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"scale",value:function(e){if(e<=0)throw new RangeError("Scale should be greater than zero");this._objectControls.scale(e),this.dispatchEvent({type:"transform"}),this._needRender=!0}},{key:"center",value:function(e){if(void 0===e)return this.setPivotSubset(),void(this._needRender=!0);if(void 0!==e.obj&&("atom"in e.obj||"residue"in e.obj))return"atom"in e.obj?this.setPivotAtom(e.obj.atom):this.setPivotResidue(e.obj.residue),void(this._needRender=!0);if(void 0===e.obj&&""!==e){var t=iu.parse(e);if(void 0===t.error)return this.setPivotSubset(t),void(this._needRender=!0)}this.resetPivot(),this._needRender=!0}},{key:"within",value:function(e,t){var r=this._getComplexVisual();if(!r)return iu.None();e instanceof String&&(e=iu.parse(e));var n=r.within(e,t);return n&&(r.rebuildSelectionGeometry(),this._needRender=!0),n}},{key:"projected",value:function(e,t){var r=this._getComplexVisual(t);if(!r)return!1;var n=r.getComplex().getAtomByFullname(e);if(null===n)return!1;var i=n.position.clone();return this._gfx.pivot.updateMatrixWorldRecursive(),this._gfx.camera.updateMatrixWorldRecursive(),this._gfx.pivot.localToWorld(i),i.project(this._gfx.camera),{x:.5*(i.x+1)*this._gfx.width,y:.5*(1-i.y)*this._gfx.height}}},{key:"dssp",value:function(e){var t=this._getComplexVisual(e);t&&(t.getComplex().dssp(),t._reprList.forEach((function(e){"CA"!==e.mode.id&&"SS"!==e.colorer.id||(e.needsRebuild=!0)})))}},{key:"exportCML",value:function(){var e=this,t=e._getComplexVisual(),r=t?t.getComplex():null;return r&&r.originalCML?(function(t){var r=function(e){var t=new i.Pq0,r=new i.Pq0,n=new i.Pq0;e.extractBasis(t,r,n),t.normalize(),r.normalize(),n.normalize();var o=new i.kn4;return o.identity(),o.makeBasis(t,r,n),o}(e._gfx.root.matrixWorld),n=new i.IUQ(0,0,0,0),o=new i.IUQ(0,0,0,0),s=null,a=null;t.forEachAtom((function(e){e.xmlNodeRef&&e.xmlNodeRef.xmlNode&&(s=e.xmlNodeRef.xmlNode,a=e.position,n.set(a.x,a.y,a.z,1),n.applyMatrix4(r),s.setAttribute("x3",n.x.toString()),s.setAttribute("y3",n.y.toString()),s.setAttribute("z3",n.z.toString()),s.removeAttribute("x2"),s.removeAttribute("y2"))})),t.forEachSGroup((function(e){if(e.xmlNodeRef&&e.xmlNodeRef.xmlNode){s=e.xmlNodeRef.xmlNode,a=e.getPosition(),n.set(a.x,a.y,a.z,1);var t=e.getCentralPoint();null===t?n.applyMatrix4(r):(o.set(t.x,t.y,t.z,0),n.add(o),n.applyMatrix4(r),o.set(t.x,t.y,t.z,1),o.applyMatrix4(r),n.sub(o)),s.setAttribute("x",n.x.toString()),s.setAttribute("y",n.y.toString()),s.setAttribute("z",n.z.toString())}}))}(r),(new XMLSerializer).serializeToString(r.originalCML)):null}},{key:"motm",value:function(){J.set({fogColorEnable:!0,fogColor:0,outline:{on:!0,threshold:.01},bg:{color:16777215}}),this._forEachComplexVisual((function(e){for(var t=[],r=e.getComplex(),n=ns.get(J.now.palette),i=0;i<r.getChainCount();i++){var o=r._chains[i]._name,s=n.getChainColor(o);t[i]={selector:"chain ".concat(o),mode:"VW",colorer:["CB",{color:s,factor:.9}],material:"FL"}}e.resetReps(t)}))}}]),a}(I);(0,n.assign)(wu,{VERSION:wu.VERSION,registeredPlugins:[],chem:dr,io:Ec,modes:Fo,colorers:_s,materials:xs,palettes:ns,options:we,settings:J,utils:$,gfx:{Representation:Ts}});var Su=function(){var e=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r},t=[1,60],r=[1,62],n=[1,63],i=[1,65],o=[1,66],s=[1,67],a=[1,68],l=[1,69],c=[1,80],u=[1,72],h=[1,73],f=[1,74],d=[1,75],p=[1,99],m=[1,76],v=[1,100],y=[1,79],_=[1,51],g=[1,81],x=[1,82],b=[1,84],w=[1,83],S=[1,85],R=[1,96],C=[1,97],k=[1,98],A=[1,86],E=[1,87],P=[1,64],T=[1,70],M=[1,71],I=[1,77],N=[1,78],O=[1,53],L=[1,54],B=[1,55],D=[1,61],z=[1,88],F=[1,89],V=[1,90],U=[1,91],j=[1,92],G=[1,93],H=[1,94],q=[1,95],W=[1,101],Y=[1,102],X=[1,103],$=[1,104],Z=[1,105],Q=[1,56],K=[1,57],J=[1,58],ee=[1,59],te=[1,115],re=[1,111],ne=[1,114],ie=[1,112],oe=[1,113],se=[1,118],ae=[1,117],le=[1,134],ce=[1,149],ue=[1,150],he=[1,157],fe=[5,6,7,9,13,14,15,17,18,19,20,23,25,26,27,30,33,34,35,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,72,74,77,78,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101],de=[5,6,7,9,13,14,15,17,18,19,20,23,25,26,27,30,33,34,35,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,71,72,74,77,78,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101],pe=[5,6,7,9,13,15,17,18,19,20,23,25,26,27,30,33,34,37,38,41,43,45,46,49,52,54,55,56,58,59,62,64,65,66,70,72,82,83,84,85,86,87,88,89,90,91,92,93,94,95],me=[5,70,72],ve=[5,74],ye=[71,101],_e={trace:function(){},yy:{},symbols_:{error:2,Program:3,Command:4,EOF:5,RESET:6,BUILD:7,ALL:8,HELP:9,Path:10,MOTM:11,OneArgCommand:12,GET:13,STRING:14,SET:15,Value:16,SET_SAVE:17,SET_RESTORE:18,SET_RESET:19,PRESET:20,AddRepresentation:21,EditRepresentation:22,REMOVE:23,RepresentationReference:24,HIDE:25,SHOW:26,LIST:27,EXPAND_KEY:28,SELECTOR_KEY:29,SELECT:30,AS:31,WordAll:32,SELECTOR:33,WITHIN:34,NUMBER:35,OF:36,MATERIAL:37,IDENTIFIER:38,ModeCMD:39,ColorCMD:40,VIEW:41,BASE_64:42,UNIT:43,DSSP:44,SCALE:45,ROTATE:46,AxesList:47,TRANSLATE:48,CENTER:49,GetURLBranch:50,Screenshot:51,LINE:52,ArgList:53,LISTOBJ:54,REMOVEOBJ:55,URL:56,VIEW_KEY:57,SCREENSHOT:58,LOAD:59,Url:60,FILE_KEY:61,ADD:62,Description:63,REP:64,MODE:65,COLOR:66,Descriptor:67,RepresentationOwnProperty:68,RepresentationOwnPropertyOpts:69,DESC_KEY:70,"=":71,DESC_KEY_OPTS:72,AxesArg:73,DESC_KEY_AXES:74,Arg:75,PathWoDescKey:76,HEX:77,BOOL:78,Word:79,CommandSetWoDESC_KEY:80,DescKeys:81,CLEAR:82,FILE_LIST:83,FILE_REGISTER:84,FILE_DELETE:85,PRESET_ADD:86,PRESET_DELETE:87,PRESET_UPDATE:88,PRESET_RENAME:89,PRESET_OPEN:90,CREATE_SCENARIO:91,RESET_SCENARIO:92,DELETE_SCENARIO:93,ADD_SCENARIO_ITEM:94,LIST_SCENARIO:95,PDB_KEY:96,DELAY_KEY:97,PRST_KEY:98,DESCRIPTION_KEY:99,CommandSet:100,".":101,PresetPath:102,"/":103,HexOrNumber:104,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"RESET",7:"BUILD",8:"ALL",9:"HELP",11:"MOTM",13:"GET",14:"STRING",15:"SET",17:"SET_SAVE",18:"SET_RESTORE",19:"SET_RESET",20:"PRESET",23:"REMOVE",25:"HIDE",26:"SHOW",27:"LIST",28:"EXPAND_KEY",29:"SELECTOR_KEY",30:"SELECT",31:"AS",33:"SELECTOR",34:"WITHIN",35:"NUMBER",36:"OF",37:"MATERIAL",38:"IDENTIFIER",41:"VIEW",42:"BASE_64",43:"UNIT",44:"DSSP",45:"SCALE",46:"ROTATE",48:"TRANSLATE",49:"CENTER",52:"LINE",54:"LISTOBJ",55:"REMOVEOBJ",56:"URL",57:"VIEW_KEY",58:"SCREENSHOT",59:"LOAD",61:"FILE_KEY",62:"ADD",64:"REP",65:"MODE",66:"COLOR",70:"DESC_KEY",71:"=",72:"DESC_KEY_OPTS",74:"DESC_KEY_AXES",77:"HEX",78:"BOOL",82:"CLEAR",83:"FILE_LIST",84:"FILE_REGISTER",85:"FILE_DELETE",86:"PRESET_ADD",87:"PRESET_DELETE",88:"PRESET_UPDATE",89:"PRESET_RENAME",90:"PRESET_OPEN",91:"CREATE_SCENARIO",92:"RESET_SCENARIO",93:"DELETE_SCENARIO",94:"ADD_SCENARIO_ITEM",95:"LIST_SCENARIO",96:"PDB_KEY",97:"DELAY_KEY",98:"PRST_KEY",99:"DESCRIPTION_KEY",101:".",103:"/"},productions_:[0,[3,2],[3,1],[4,1],[4,1],[4,2],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,3],[4,3],[4,1],[4,1],[4,1],[4,1],[4,2],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,1],[4,2],[4,2],[4,2],[4,4],[4,2],[4,6],[4,2],[4,1],[4,1],[4,1],[4,2],[4,2],[4,1],[4,2],[4,1],[4,2],[4,2],[4,2],[4,1],[4,2],[4,1],[4,1],[4,3],[4,3],[4,4],[4,4],[4,1],[4,2],[50,1],[50,2],[50,2],[50,3],[50,3],[51,1],[51,2],[51,3],[12,2],[12,2],[12,2],[21,1],[21,2],[21,2],[21,3],[22,2],[22,3],[39,2],[39,3],[40,2],[40,3],[24,1],[24,1],[63,1],[63,2],[63,3],[63,4],[67,1],[67,1],[67,2],[68,3],[69,3],[47,1],[47,2],[73,2],[53,1],[53,2],[75,3],[16,1],[16,1],[16,1],[16,1],[16,1],[79,1],[79,1],[32,1],[32,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[80,1],[81,1],[81,1],[81,1],[81,1],[81,1],[81,1],[81,1],[100,1],[100,1],[76,1],[76,3],[76,3],[10,1],[10,1],[10,3],[10,3],[10,3],[60,1],[102,1],[102,3],[104,1],[104,1]],performAction:function(e,t,r,n,i,o,s){var a=o.length-1;switch(i){case 1:return o[a-1];case 3:this.$=n.miew.reset(!1),n.ClearContext(),n.miew.resetReps("empty");break;case 4:this.$=n.miew.rebuild();break;case 5:this.$=n.miew.rebuildAll(),n.miew.rebuild();break;case 6:this.$=n.echo(n.utils.help().toString());break;case 7:this.$=n.echo(n.utils.help(o[a]).toString());break;case 8:this.$=n.miew.motm();break;case 10:case 11:this.$=n.utils.propagateProp(o[a]),n.echo(n.miew.get(o[a]).toString());break;case 12:case 13:this.$=n.miew.set(o[a-1],n.utils.propagateProp(o[a-1],o[a]));break;case 14:this.$=n.miew.saveSettings();break;case 15:this.$=n.miew.restoreSettings();break;case 16:this.$=n.miew.resetSettings();break;case 17:this.$=n.miew.resetReps();break;case 18:this.$=n.miew.applyPreset(o[a]);break;case 21:this.$=n.miew.repRemove(o[a]),n.representations.remove(o[a]);break;case 22:this.$=n.miew.repHide(o[a]);break;case 23:this.$=n.miew.repHide(o[a],!1);break;case 24:this.$=n.echo(n.utils.listRep(n.miew,n.representations,o[a],"-e"));break;case 25:this.$=n.echo(n.utils.list(n.miew,n.representations));break;case 26:this.$=n.echo(n.utils.list(n.miew,n.representations,o[a]));break;case 27:this.$=n.echo(n.utils.listSelector(n.miew,n.Context));break;case 28:this.$=n.miew.select(n.utils.checkArg(o[a-1].toLowerCase(),o[a],!0));break;case 29:this.$=n.Context[o[a].toLowerCase()]=n.utils.checkArg(o[a-3].toLowerCase(),o[a-2],!0),n.miew.select(n.Context[o[a].toLowerCase()]);break;case 30:this.$=n.miew.rep(n.miew.repCurrent(),{selector:n.utils.checkArg(o[a-1].toLowerCase(),o[a])});break;case 31:this.$=n.Context[o[a].toLowerCase()]=n.miew.within(n.utils.checkArg("select",o[a-2],!0),Number(o[a-4]));break;case 32:this.$=n.miew.rep(n.miew.repCurrent(),{material:n.utils.checkArg(o[a-1].toLowerCase(),o[a].toUpperCase())});break;case 35:this.$=n.echo(n.miew.view());break;case 36:case 37:this.$=n.miew.view(o[a]);break;case 38:this.$=n.echo(n.miew.changeUnit());break;case 39:this.$=n.echo(n.miew.changeUnit(o[a]));break;case 40:this.$=n.miew.dssp();break;case 41:this.$=n.miew.scale(o[a]);break;case 42:for(var l=0,c=o[a].length;l<c;l++)n.miew.rotate(o[a][l].x*Math.PI/180,o[a][l].y*Math.PI/180,o[a][l].z*Math.PI/180);break;case 43:for(l=0,c=o[a].length;l<c;l++)n.miew.translate(o[a][l].x||0,o[a][l].y||0,o[a][l].z||0);break;case 44:this.$=n.miew.center();break;case 45:this.$=n.miew.center(o[a]);break;case 48:case 49:this.$=n.miew.addObject({type:"line",params:[o[a-1],o[a]]},!0);break;case 50:case 51:this.$=n.miew.addObject({type:"line",params:[o[a-2],o[a-1]],opts:o[a].toJSO(n.utils,"objects","line")},!0);break;case 52:this.$=n.echo(n.utils.listObjs(n.miew));break;case 53:this.$=n.miew.removeObject(o[a]);break;case 54:this.$=n.echo(n.miew.getURL({view:!1,settings:!1}));break;case 55:this.$=n.echo(n.miew.getURL({view:!1,settings:!0}));break;case 56:this.$=n.echo(n.miew.getURL({view:!0,settings:!1}));break;case 57:case 58:this.$=n.echo(n.miew.getURL({view:!0,settings:!0}));break;case 59:this.$=n.miew.screenshotSave();break;case 60:this.$=n.miew.screenshotSave("",Number(o[a]));break;case 61:this.$=n.miew.screenshotSave("",Number(o[a-1]),Number(o[a]));break;case 62:case 63:case 64:this.$=n.utils.load(n.miew,o[a]),n.representations.clear();break;case 65:this.$=n.echo(n.representations.add(n.miew.repAdd()));break;case 66:this.$=n.echo(n.representations.add(o[a],n.miew.repAdd()));break;case 67:this.$=n.echo(n.representations.add(n.miew.repAdd(o[a])));break;case 68:this.$=n.echo(n.representations.add(o[a-1],n.miew.repAdd(o[a])));break;case 69:this.$=n.miew.rep(o[a]),n.miew.repCurrent(o[a]);break;case 70:this.$=n.miew.rep(o[a-1],o[a]),n.miew.repCurrent(o[a-1]);break;case 71:this.$=n.miew.rep(n.miew.repCurrent(),{mode:n.utils.checkArg(o[a-1].toLowerCase(),o[a].toUpperCase())});break;case 72:this.$=n.miew.rep(n.miew.repCurrent(),{mode:new Array(n.utils.checkArg(o[a-2].toLowerCase(),o[a-1].toUpperCase()),o[a].toJSO(n.utils,o[a-2],o[a-1].toUpperCase()))});break;case 73:this.$=n.miew.rep(n.miew.repCurrent(),{colorer:n.utils.checkArg(o[a-1].toLowerCase(),o[a].toUpperCase())});break;case 74:this.$=n.miew.rep(n.miew.repCurrent(),{colorer:new Array(n.utils.checkArg(o[a-2].toLowerCase(),o[a-1].toUpperCase()),o[a].toJSO(n.utils,o[a-2],o[a-1].toUpperCase()))});break;case 75:this.$=Number(n.representations.get(o[a]));break;case 76:case 92:this.$=Number(o[a]);break;case 77:this.$=o[a];break;case 78:this.$=n.assign(o[a-1],o[a]);break;case 79:this.$=n.assign(o[a-2],o[a-1],o[a]);break;case 80:this.$=n.assign(o[a-3],o[a-2],o[a-1],o[a]);break;case 81:case 82:this.$=n.CreateObjectPair(o[a].key,o[a].val);break;case 83:this.$=n.CreateObjectPair(o[a-1].key,new Array(o[a-1].val,o[a].toJSO(n.utils,o[a-1].key,o[a-1].val)));break;case 84:case 85:this.$=Object.create({key:n.keyRemap(o[a-2]),val:n.utils.checkArg(o[a-2],o[a])});break;case 86:this.$=[o[a]];break;case 87:this.$=o[a-1].concat(o[a]);break;case 88:this.$=n.CreateObjectPair(o[a-1].toLowerCase(),Number(o[a]));break;case 89:this.$=new n.ArgList(o[a]);break;case 90:this.$=o[a-1].append(o[a]);break;case 91:this.$=new n.Arg(o[a-2],o[a]);break;case 93:this.$=parseInt(o[a]);break;case 94:this.$=JSON.parse(o[a]);break;case 95:case 96:this.$=String(o[a]);break;case 157:case 158:case 161:case 162:case 163:this.$=o[a-2]+o[a-1]+o[a];break;case 166:this.$=o[a-2]=o[a-2]+o[a-1]+o[a]}},table:[{3:1,4:2,5:[1,3],6:[1,4],7:[1,5],9:[1,6],11:[1,7],12:8,13:[1,9],15:[1,10],17:[1,11],18:[1,12],19:[1,13],20:[1,14],21:15,22:16,23:[1,17],25:[1,18],26:[1,19],27:[1,20],30:[1,21],33:[1,22],34:[1,23],37:[1,24],39:25,40:26,41:[1,27],43:[1,28],44:[1,29],45:[1,30],46:[1,31],48:[1,32],49:[1,33],50:34,51:35,52:[1,36],54:[1,37],55:[1,38],56:[1,44],58:[1,45],59:[1,39],62:[1,40],64:[1,41],65:[1,42],66:[1,43]},{1:[3]},{5:[1,46]},{1:[2,2]},{5:[2,3]},{5:[2,4],8:[1,47]},{5:[2,6],6:t,7:r,9:n,10:48,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{5:[2,8]},{5:[2,9]},{6:t,7:r,9:n,10:106,13:i,14:[1,107],15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{6:t,7:r,9:n,10:108,13:i,14:[1,109],15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{5:[2,14]},{5:[2,15]},{5:[2,16]},{5:[2,17],14:te,16:110,35:re,38:ne,77:ie,78:oe},{5:[2,19]},{5:[2,20]},{24:116,35:se,38:ae},{24:119,35:se,38:ae},{24:120,35:se,38:ae},{5:[2,25],24:121,28:[1,122],29:[1,123],35:se,38:ae},{14:[1,124]},{14:[1,125]},{35:[1,126]},{38:[1,127]},{5:[2,33]},{5:[2,34]},{5:[2,35],14:[1,128],42:[1,129]},{5:[2,38],35:[1,130]},{5:[2,40]},{35:[1,131]},{47:132,73:133,74:le},{47:135,73:133,74:le},{5:[2,44],14:[1,136]},{5:[2,46]},{5:[2,47]},{6:t,7:r,9:n,10:138,13:i,14:[1,137],15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{5:[2,52]},{35:[1,139]},{14:[1,143],38:[1,141],60:140,61:[1,142]},{5:[2,65],38:[1,144],63:145,67:146,68:147,69:148,70:ce,72:ue},{24:151,35:se,38:ae},{38:[1,152]},{38:[1,153]},{5:[2,54],29:[1,154],57:[1,155]},{5:[2,59],35:[1,156]},{1:[2,1]},{5:[2,5]},{5:[2,7],101:he},e(fe,[2,159]),e(fe,[2,160]),e(de,[2,97]),e(de,[2,98]),e(fe,[2,147]),e(fe,[2,148]),e(fe,[2,149]),e(fe,[2,150]),e(fe,[2,151]),e(fe,[2,152]),e(fe,[2,153]),e(de,[2,101]),e(de,[2,102]),e(de,[2,103]),e(de,[2,104]),e(de,[2,105]),e(de,[2,106]),e(de,[2,107]),e(de,[2,108]),e(de,[2,109]),e(de,[2,110]),e(de,[2,111]),e(de,[2,112]),e(de,[2,113]),e(de,[2,114]),e(de,[2,115]),e(de,[2,116]),e(de,[2,117]),e(de,[2,118]),e(de,[2,119]),e(de,[2,120]),e(de,[2,121]),e(de,[2,122]),e(de,[2,123]),e(de,[2,124]),e(de,[2,125]),e(de,[2,126]),e(de,[2,127]),e(de,[2,128]),e(de,[2,129]),e(de,[2,130]),e(de,[2,131]),e(de,[2,132]),e(de,[2,133]),e(de,[2,134]),e(de,[2,135]),e(de,[2,136]),e(de,[2,137]),e(de,[2,138]),e(de,[2,139]),e(de,[2,140]),e(de,[2,141]),e(de,[2,142]),e(de,[2,143]),e(de,[2,144]),e(de,[2,145]),e(de,[2,146]),{5:[2,10],101:he},{5:[2,11]},{14:te,16:158,35:re,38:ne,77:ie,78:oe,101:he},{14:te,16:159,35:re,38:ne,77:ie,78:oe},{5:[2,18]},e(pe,[2,92]),e(pe,[2,93]),e(pe,[2,94]),e(pe,[2,95]),e(pe,[2,96]),{5:[2,21]},e(me,[2,75]),e(me,[2,76]),{5:[2,22]},{5:[2,23]},{5:[2,24]},{5:[2,26]},{5:[2,27]},{5:[2,28],31:[1,160]},{5:[2,30]},{36:[1,161]},{5:[2,32]},{5:[2,36]},{5:[2,37]},{5:[2,39]},{5:[2,41]},{5:[2,42],73:162,74:le},e(ve,[2,86]),{35:[1,163]},{5:[2,43],73:162,74:le},{5:[2,45]},{14:[1,164]},{6:t,7:r,9:n,10:165,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:49,80:52,81:50,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee,101:he},{5:[2,53]},{5:[2,62]},{5:[2,63]},{5:[2,64]},{5:[2,164]},{5:[2,66],63:166,67:146,68:147,69:148,70:ce,72:ue},{5:[2,67]},{5:[2,77],67:167,68:147,69:148,70:ce,72:ue},e(me,[2,81]),e(me,[2,82],{80:52,53:168,75:169,76:170,79:171,6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z}),{71:[1,172]},{71:[1,173]},{5:[2,69],63:174,67:146,68:147,69:148,70:ce,72:ue},{5:[2,71],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:175,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,73],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:176,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,55],57:[1,177]},{5:[2,56],29:[1,178]},{5:[2,60],35:[1,179]},{6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,35:[1,181],37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:180,80:52,81:182,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{5:[2,12]},{5:[2,13]},{6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,32:183,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:184,80:52,81:185,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{14:[1,186]},e(ve,[2,87]),e(ve,[2,88]),{5:[2,48],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:187,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,49],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,53:188,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:169,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,101:he},{5:[2,68]},{5:[2,78],67:189,68:147,69:148,70:ce,72:ue},e(me,[2,83],{80:52,76:170,79:171,75:190,6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z}),e(pe,[2,89]),{71:[1,191],101:[1,192]},e(ye,[2,156]),{14:te,16:193,35:re,38:ne,77:ie,78:oe},{14:te,16:194,35:re,38:ne,77:ie,78:oe},{5:[2,70]},{5:[2,72],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,74],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,57]},{5:[2,58]},{5:[2,61]},e(fe,[2,161]),e(fe,[2,162]),e(fe,[2,163]),{5:[2,29]},{5:[2,99]},{5:[2,100]},{31:[1,195]},{5:[2,50],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,51],6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,75:190,76:170,79:171,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},{5:[2,79],67:196,68:147,69:148,70:ce,72:ue},e(pe,[2,90]),{14:te,16:197,35:re,38:ne,77:ie,78:oe},{6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,33:m,34:v,35:[1,199],37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,79:198,80:52,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z},e(me,[2,84]),e(pe,[2,85]),{6:t,7:r,9:n,13:i,15:o,17:s,18:a,19:l,20:c,23:u,25:h,26:f,27:d,30:p,32:200,33:m,34:v,37:y,38:_,41:g,43:x,45:b,46:w,49:S,52:R,54:C,55:k,56:A,58:E,59:P,62:T,64:M,65:I,66:N,70:O,72:L,74:B,79:184,80:52,81:185,82:D,83:z,84:F,85:V,86:U,87:j,88:G,89:H,90:q,91:W,92:Y,93:X,94:$,95:Z,96:Q,97:K,98:J,99:ee},{5:[2,80]},e(pe,[2,91]),e(ye,[2,157]),e(ye,[2,158]),{5:[2,31]}],defaultActions:{3:[2,2],4:[2,3],7:[2,8],8:[2,9],11:[2,14],12:[2,15],13:[2,16],15:[2,19],16:[2,20],25:[2,33],26:[2,34],29:[2,40],34:[2,46],35:[2,47],37:[2,52],46:[2,1],47:[2,5],107:[2,11],110:[2,18],116:[2,21],119:[2,22],120:[2,23],121:[2,24],122:[2,26],123:[2,27],125:[2,30],127:[2,32],128:[2,36],129:[2,37],130:[2,39],131:[2,41],136:[2,45],139:[2,53],140:[2,62],141:[2,63],142:[2,64],143:[2,164],145:[2,67],158:[2,12],159:[2,13],166:[2,68],174:[2,70],177:[2,57],178:[2,58],179:[2,61],183:[2,29],184:[2,99],185:[2,100],196:[2,80],200:[2,31]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=[0],r=[],n=[null],i=[],o=this.table,s="",a=0,l=0,c=i.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(h.yy[f]=this.yy[f]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;i.push(d);var p=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,y,_,g,x,b,w,S,R={};;){if(v=t[t.length-1],this.defaultActions[v]?y=this.defaultActions[v]:(null==m&&(S=void 0,"number"!=typeof(S=r.pop()||u.lex()||1)&&(S instanceof Array&&(S=(r=S).pop()),S=this.symbols_[S]||S),m=S),y=o[v]&&o[v][m]),void 0===y||!y.length||!y[0]){var C;for(g in w=[],o[v])this.terminals_[g]&&g>2&&w.push("'"+this.terminals_[g]+"'");C=u.showPosition?"Parse error on line "+(a+1)+":\n"+u.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(C,{text:u.match,token:this.terminals_[m]||m,line:u.yylineno,loc:d,expected:w})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(y[0]){case 1:t.push(m),n.push(u.yytext),i.push(u.yylloc),t.push(y[1]),m=null,l=u.yyleng,s=u.yytext,a=u.yylineno,d=u.yylloc;break;case 2:if(x=this.productions_[y[1]][1],R.$=n[n.length-x],R._$={first_line:i[i.length-(x||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(x||1)].first_column,last_column:i[i.length-1].last_column},p&&(R._$.range=[i[i.length-(x||1)].range[0],i[i.length-1].range[1]]),void 0!==(_=this.performAction.apply(R,[s,l,a,h.yy,y[1],n,i].concat(c))))return _;x&&(t=t.slice(0,-1*x*2),n=n.slice(0,-1*x),i=i.slice(0,-1*x)),t.push(this.productions_[y[1]][0]),n.push(R.$),i.push(R._$),b=o[t[t.length-2]][t[t.length-1]],t.push(b);break;case 3:return!0}}return!0}},ge=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var o in i)this[o]=i[o];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;o<i.length;o++)if((r=this._input.match(this.rules[i[o]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=o,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,i[o])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,i[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:break;case 1:case 2:return"";case 3:return 42;case 4:return 35;case 5:return 77;case 6:case 7:return 78;case 8:return 8;case 9:return 6;case 10:return 82;case 11:return 7;case 12:return 9;case 13:return 59;case 14:return 13;case 15:return 15;case 16:return 17;case 17:return 18;case 18:return 19;case 19:return 20;case 20:return 11;case 21:return 62;case 22:return 64;case 23:return 23;case 24:return 25;case 25:return 26;case 26:return 27;case 27:return 30;case 28:return 34;case 29:return 33;case 30:return 65;case 31:return 66;case 32:return 37;case 33:return 41;case 34:return 43;case 35:return 52;case 36:return 54;case 37:return 55;case 38:return 46;case 39:return 48;case 40:return 45;case 41:return 49;case 42:return 56;case 43:return 58;case 44:return 44;case 45:return 83;case 46:return 84;case 47:return 85;case 48:return 86;case 49:return 87;case 50:return 88;case 51:return 89;case 52:return 90;case 53:return 91;case 54:return 92;case 55:return 93;case 56:return 94;case 57:return 95;case 58:case 59:return 70;case 60:case 61:return 72;case 62:case 63:case 64:return 74;case 65:return 31;case 66:return 36;case 67:return 96;case 68:return 97;case 69:return 98;case 70:return 99;case 71:return t.yytext=e.utils.unquoteString(t.yytext),14;case 72:return 38;case 73:return 5;case 74:return 101;case 75:return 103;case 76:return"\\";case 77:return 28;case 78:return 61;case 79:return 29;case 80:return 57;case 81:return 71}},rules:[/^(?:\s+)/i,/^(?:[#].*)/i,/^(?:\/\/.*)/i,/^(?:([_A-Z0-9\/\+]+==))/i,/^(?:-?[0-9]+(\.[0-9]+)?\b)/i,/^(?:0[xX][0-9A-F]+\b)/i,/^(?:false\b)/i,/^(?:true\b)/i,/^(?:all\b)/i,/^(?:reset\b)/i,/^(?:clear\b)/i,/^(?:build\b)/i,/^(?:help\b)/i,/^(?:load\b)/i,/^(?:get\b)/i,/^(?:set\b)/i,/^(?:set_save\b)/i,/^(?:set_restore\b)/i,/^(?:set_reset\b)/i,/^(?:preset\b)/i,/^(?:motm\b)/i,/^(?:add\b)/i,/^(?:rep\b)/i,/^(?:remove\b)/i,/^(?:hide\b)/i,/^(?:show\b)/i,/^(?:list\b)/i,/^(?:select\b)/i,/^(?:within\b)/i,/^(?:selector\b)/i,/^(?:mode\b)/i,/^(?:color\b)/i,/^(?:material\b)/i,/^(?:view\b)/i,/^(?:unit\b)/i,/^(?:line\b)/i,/^(?:listobj\b)/i,/^(?:removeobj\b)/i,/^(?:rotate\b)/i,/^(?:translate\b)/i,/^(?:scale\b)/i,/^(?:center\b)/i,/^(?:url\b)/i,/^(?:screenshot\b)/i,/^(?:dssp\b)/i,/^(?:file_list\b)/i,/^(?:file_register\b)/i,/^(?:file_delete\b)/i,/^(?:preset_add\b)/i,/^(?:preset_delete\b)/i,/^(?:preset_update\b)/i,/^(?:preset_rename\b)/i,/^(?:preset_open\b)/i,/^(?:create_scenario\b)/i,/^(?:reset_scenario\b)/i,/^(?:delete_scenario\b)/i,/^(?:add_scenario_item\b)/i,/^(?:list_scenario\b)/i,/^(?:s\b)/i,/^(?:mt\b)/i,/^(?:m\b)/i,/^(?:c\b)/i,/^(?:x\b)/i,/^(?:y\b)/i,/^(?:z\b)/i,/^(?:as\b)/i,/^(?:of\b)/i,/^(?:pdb\b)/i,/^(?:delay\b)/i,/^(?:prst\b)/i,/^(?:desc\b)/i,/^(?:((?:"(?:\\.|[^\\"])*"|'(?:\\.|[^\\'])*')))/i,/^(?:([_A-Z0-9]+))/i,/^(?:$)/i,/^(?:\.)/i,/^(?:\/)/i,/^(?:\\)/i,/^(?:-e\b)/i,/^(?:-f\b)/i,/^(?:-s\b)/i,/^(?:-v\b)/i,/^(?:=)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81],inclusive:!0}}};return e}();function xe(){this.yy={}}return _e.lexer=ge,xe.prototype=_e,_e.Parser=xe,new xe}(),Ru={parser:Su},Cu={$help:["Rendering mode shortcut"," BS - balls and sticks mode"," LN - lines mode"," LC - licorice mode"," VW - van der waals mode"," TR - trace mode"," TU - tube mode"," CA - cartoon mode"," SA - isosurface mode"," QS - quick surface mode"," SE - solvent excluded mode"," TX - text mode"],BS:{$help:[" Balls and sticks"," aromrad = <number> #aromatic radius"," atom = <number> #atom radius"," bond = <number> #bond radius"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," space = <number> #space value\n"]},CA:{$help:[" Cartoon"," arrow = <number> #arrow size"," depth = <number> #depth of surface"," heightSegmentsRatio = <number>"," radius = <number> #tube radius"," tension = <number> #"," width = <number> #secondary width\n"]},LN:{$help:[" Lines"," atom = <number> #atom radius"," chunkarom = <number>"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," offsarom = <number>\n"]},LC:{$help:[" Licorice"," aromrad = <number> #aromatic radius"," bond = <number> #bond radius"," multibond = <bool> #use multibond"," showarom = <bool> #show aromatic"," space = <number> #space value\n"]},VW:{$help:[" Van der Waals"," nothing\n"]},TR:{$help:[" Trace"," radius = <number> #tube radius\n"]},TU:{$help:[" Tube"," heightSegmentsRatio = <number>"," radius = <number> #tube radius"," tension = <number> \n"]},SA:{$help:[" Surface"," zClip = <bool> #clip z plane\n"]},QS:{$help:[" Quick surface"," isoValue = <number>"," scale = <number>"," wireframe = <bool>"," zClip = <bool> #clip z plane\n"]},SE:{$help:[" Solvent excluded surface"," zClip = <bool> #clip z plane\n"]},TX:{$help:[" Text mode",' template = <format string> string that can include "{{ id }}"'," it will be replaced by value, id can be one of next:"," serial, name, type, sequence, residue, chain, hetatm, water\n",' horizontalAlign = <string> {"left", "right", "center"}',' verticalAlign = <string> {"top", "bottom", "middle"}'," dx = <number> #offset along x"," dy = <number> #offset along y"," dz = <number> #offset along z"," fg = <string> #text color modificator"," could be keyword, named color or hex"," fg = <string> #back color modificator"," could be keyword, named color or hex"," showBg = <bool> #if set show background"," plate under text"]}},ku={$help:["Coloring mode shortcut"," EL - color by element"," CH - color by chain"," SQ - color by sequence"," RT - color by residue type"," SS - color by secondary structure"," UN - uniform"],UN:{$help:["Parameters of coloring modes customization"," Uniform"," color = <number|color> #RGB->HEX->dec\n"],color:{$help:Object.keys(ns.get(J.now.palette).namedColors).sort().join("\n")}}},Au={$help:["Material shortcut"," DF - diffuse"," TR - transparent"," SF - soft plastic"," PL - glossy plastic"," ME - metal"," GL - glass"]},Eu={$help:["Short (packed) representation description as a set of variables"," s=<EXPRESSION>"," selector property"," m=<MODE_ID>[!<PARAMETER>:<VALUE>[,...]]"," render mode property"," c=<COLORER_ID>[!<PARAMETER>:<VALUE>[,...]]"," color mode property"," mt=<MATERIAL_ID>"," material property"],s:{$help:"Selection expression string as it is in menu->representations->selection"},m:Cu,c:ku,mt:Au},Pu={$help:["Parameters of rendering modes customization: modes","Parameters of colorer customization: colorers","Autobuild: autobuild = (<number>|<bool>)"],modes:Cu,colorers:ku},Tu={$help:["help (<cmd name>| <path to property>)","You can get detailed information about command options",' using "help cmd.opt.opt.[...]"\n'," you can use one line comments"," everything started from (#|//) will be skipped"," Example: >build //some comment\n","List of available commands:"],reset:{$help:["Reload current object, delete all representations"," Nothing will work until load new object"]},load:{$help:["load (<PDBID>|<URL>|-f [<*.NC FILE URL STRING>])"," Load new pdb object from selected source"],PDBID:{$help:"pdb id in remote molecule database"},URL:{$help:"url to source file"},f:{$help:["open file system dialog to fetch local file","optionally you can determine trajectory file","via URL for *.top model"]}},clear:{$help:"No args. Clear terminal"},add:{$help:["add [<REP_NAME>] [<DESCRIPTION>]"," Add new item to representation set with"," default or <DESCRIPTION> params"],REP_NAME:{$help:"Identifier string [_,a-z,A-Z,0-9] can not start from digit"},DESCRIPTION:Eu},rep:{$help:["rep [<REP_NAME>|<REP_INDEX>] [<DESCRIPTION>]"," set current representation by name or index"," edit current representation by <DESCRIPTION>"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"},DESCRIPTION:Eu},remove:{$help:["remove (<REP_NAME>|<REP_INDEX>)","Remove representation by name or index"],REP_NAME:{$help:["Identifier string [_,a-z,A-Z,0-9] can not start from digit","Must be declared before"]},REP_INDEX:{$help:"Index of available representation"}},selector:{$help:["selector <EXPRESSION>"," set selector from EXPRESSION to current representation"],EXPRESSION:{$help:"Selection expression string as it is in menu->representations->selection"}},mode:{$help:["mode <MODE_ID> [<PARAMETER>=<VALUE>...]"," set rendering mode and apply parameters to current representation"],MODE_ID:Cu},color:{$help:["color <COLORER_ID> [<PARAMETER>=<VALUE>...]"," set colorer and apply parameters to current representation"],COLORER_ID:ku},material:{$help:["material <MATERIAL_ID>"," set material to current representation"],MATERIAL_ID:Au},build:{$help:"build help str",add:{$help:"build.add",new:{$help:["add.new","add.new new line 1","add.new new line 2","add.new new line 3"]}},del:{$help:"build.del"}},list:{$help:["list [-e|-s|<REP_NAME>|<REP_INDEX>]","Print representations if no args print list of representations"," -e expand list and show all representations"," -s show all user-registered selectors"," <REP_NAME>|<REP_INDEX> show only current representation"]},hide:{$help:["hide (<REP_NAME>|<REP_INDEX>)","Hide representation referenced in args"]},show:{$help:["show (<REP_NAME>|<REP_INDEX>)","Show representation referenced in args"]},get:{$help:["get <PARAMETER>","Print <PARAMETER> value"," <PARAMETER> - path to option use get.PARAMETER to get more info"],PARAMETER:Pu},set:{$help:["set <PARAMETER> <VALUE>","Set <PARAMETER> with <VALUE>"," <PARAMETER> - path to option use set.PARAMETER to get more info"],PARAMETER:Pu},set_save:{$help:["set_save","Save current settings to cookie"]},set_restore:{$help:["set_restore","Load and apply settings from cookie"]},set_reset:{$help:["set_reset","Reset current settings to the defaults"]},preset:{$help:["preset [<PRESET>]","Reset current representation or set preset to <PRESET>"],PRESET:{$help:["default","wire","small","macro"]}},unit:{$help:["unit [<unit_id>]","Change current biological structure view. Zero <unit_id> value means asymmetric unit,","positive values set an assembly with corresponding number.","Being called with no parameters command prints current unit information."]},view:{$help:["view [<ENCODED_VIEW>]","Get current encoded view or set if ENCODED_VIEW placed as argument"],ENCODED_VIEW:{$help:["encoded view matrix string (binary code)"]}},rotate:{$help:["rotate (x|y|z) [<DEGREES>] [(x|y|z) [<DEGREES>]]...","Rotate scene"]},scale:{$help:["scale <SCALE>","Scale scene"]},select:{$help:["select <SELECTOR_STRING> [as <SELECTOR_NAME>]","Select atoms using selector defined in SELECTOR_STRING"," and if SELECTOR_NAME is defined register it in viewer"," you can use it later as a complex selector"]},within:{$help:["within <DISTANCE> of <SELECTOR_STRING> as <SELECTOR_NAME>","Build within named selector"," DISTANCE <number>"," SELECTOR_STRING <string(selection language)>"," SELECTOR_NAME <identifier>"]},url:{$help:["url [-s] [-v]","Report URL encoded scene"," if -s set that include settings in the URL"," if -v set that include view in the URL"]},screenshot:{$help:["screenshot [<WIDTH> [<HEIGHT>]]","Make a screenshot of the scene"," WIDTH <number> in pixels"," HEIGHT <number> in pixels, equal to WIDTH by default"]},line:{$help:["line <first_atom_path> <second_atom_path> [<PARAMETER>=<VALUE>]","Draw dashed line between two specified atoms"]},removeobj:{$help:["removeobj <id>","Remove scene object by its index. Indices could be obtained by <listobj> command"]},listobj:{$help:["listobj","Display the list of all existing scene objects"]}},Mu=wu.chem.selectors,Iu=wu.modes,Nu=wu.colorers,Ou=wu.materials,Lu=wu.palettes,Bu=wu.options,Du=wu.settings;var zu,Fu=(zu=new function(){},function(){return zu}),Vu=function(){function e(){s(this,e),this.representationMap={},this.representationID={}}return l(e,[{key:"get",value:function(e){return this.representationMap[e]||this.representationID[e]||"<no name>"}},{key:"add",value:function(e,t){if(-1===e)return"Can not create representation: there is no data";if(void 0!==t){if(this.representationMap.hasOwnProperty(e))return"This name has already existed, registered without name";this.representationMap[e.toString()]=t,this.representationID[t]=e.toString()}return"Representation ".concat(e," successfully added")}},{key:"remove",value:function(e){e&&this.representationID.hasOwnProperty(e)&&(delete this.representationMap[this.representationID[e]],delete this.representationID[e]);var t=Object.keys(this.representationID).sort();for(var r in t)if(t.hasOwnProperty(r)){var n=t[r];n>e&&(this.representationID[n-1]=this.representationID[n],this.representationMap[this.representationID[n]]-=1,delete this.representationID[n])}}},{key:"clear",value:function(){this.representationMap={},this.representationID={}}}]),e}(),Uu=new Vu;function ju(e){var t={s:"selector",m:"mode",c:"colorer",mt:"material",mode:"modes",color:"colorers",colorer:"colorers",select:"selector",material:"materials",selector:"selector"}[e];return void 0===t?e:t}var Gu=function(){function e(){s(this,e)}return l(e,[{key:"list",value:function(e,t,r){var n="";if(e&&void 0!==t&&(void 0===r||"-e"===r))for(var i=e.repCount(),o=0;o<i;o++)n+=this.listRep(e,t,o,r);return n}},{key:"listRep",value:function(e,t,r,n){var i="",o=e.repGet(r);if(!o)return B.warn("Rep ".concat(r," does not exist!")),i;var s=r,a=t.get(s),l=o.mode,c=o.colorer,u=o.selectorString,h=o.materialPreset;return i+="#".concat(s," : ").concat(l.name).concat("<no name>"===a?"":", ".concat(a),"\n"),void 0!==n&&(i+=' selection : "'.concat(u,'"\n'),i+=" mode : (".concat(l.id,"), ").concat(l.name,"\n"),i+=" colorer : (".concat(c.id,"), ").concat(c.name,"\n"),i+=" material : (".concat(h.id,"), ").concat(h.name,"\n")),i}},{key:"listSelector",value:function(e,t){var r="";for(var n in t)t.hasOwnProperty(n)&&(r+="".concat(n,' : "').concat(t[n],'"\n'));return r}},{key:"listObjs",value:function(e){var t=e._objects;if(!t||!Array.isArray(t)||0===t.length)return"There are no objects on the scene";for(var r=[],n=0,i=t.length;n<i;++n)r[n]="".concat(n,": ").concat(t[n].toString());return r.join("\n")}},{key:"joinHelpStr",value:function(e){return e instanceof Array?e.join("\n"):e}},{key:"help",value:function(e){if((0,n.isUndefined)(e))return"".concat(this.joinHelpStr(Tu.$help),"\n").concat((0,n.slice)((0,n.sortBy)((0,n.keys)(Tu)),1).join(", "),"\n");var t=(0,n.get)(Tu,e);return(0,n.isUndefined)(t)?this.help():"".concat(this.joinHelpStr(t.$help),"\n")}},{key:"load",value:function(e,t){if(void 0!==e&&void 0!==t&&"-f"!==t){e.awaitWhileCMDisInProcess();var r=function(){return e.finishAwaitingCMDInProcess()};e.load(t).then(r,r)}}},{key:"checkArg",value:function(e,t,r){if(void 0!==e&&void 0!==t){if("selector"===ju(e)){var n=Mu.parse(t);if(void 0!==n.error)throw{message:n.error};return void 0!==r&&r?n.selector:t}for(var i,o={colorers:Nu,modes:Iu,materials:Ou},s=e;s!==i;)s=ju(i=s);if(void 0===o[s].get(t))throw{message:"".concat(t," is not existed in ").concat(s)};return t}return Fu}},{key:"propagateProp",value:function(e,t){if(void 0!==e){var r=Bu.adapters[o((0,n.get)(Du.defaults,e))];if(void 0===r)throw{message:"".concat(e," is not existed")};if((e.endsWith(".color")||e.endsWith(".baseColor")||e.endsWith(".EL.carbon"))&&"number"!=typeof t&&(t=Lu.get(Du.now.palette).getNamedColor(t)),e.endsWith(".fg")||e.endsWith(".bg"))if("number"!=typeof t){var i=Lu.get(Du.now.palette).getNamedColor(t,!0);void 0!==i&&(t="0x".concat(i.toString(16)))}else t="0x".concat(t.toString(16));if(e.endsWith(".template")&&(t=t.replace(/\\n/g,"\n")),void 0!==t&&r(t)!==t&&r(t)!==t>0)throw{message:"".concat(e,' must be a "').concat(o((0,n.get)(Du.defaults,e)),'"')}}return t}},{key:"unquoteString",value:function(e){return $.unquoteString(e)}}]),e}(),Hu=new Gu;function qu(e){if(e instanceof this.constructor)return e;this._values=e instanceof Array?e.slice(0):e?[e]:[]}qu.prototype.append=function(e){var t=this._values;return t[t.length]=e,this},qu.prototype.remove=function(e){var t=this._values,r=t.indexOf(e);return r>=0&&t.splice(r,1),this},qu.prototype.toJSO=function(e,t,r){for(var i={},o=this._values,s=0,a=o.length;s<a;++s)(0,n.set)(i,o[s].id,e.propagateProp("".concat(ju(t),".").concat(r,".").concat(o[s].id),o[s].val));return i};var Wu=Object.create({});Wu.Arg=function(e,t){this.id=e,this.val=t},Wu.ArgList=qu,Wu.miew=null,Wu.echo=null,Wu.representations=Uu,Wu.utils=Hu,Wu.assign=n.assign,Wu.CreateObjectPair=function(e,t){var r={};return r[e]=t,r},Wu.keyRemap=ju,Wu.Context=Mu.Context,Wu.ClearContext=Mu.ClearContext,Wu.NULL=Fu,Wu.notimplemented=function(){return this.NULL},wu.prototype.script=function(e,t,r){Ru.parser.yy.miew=this,Ru.parser.yy.echo=t,Ru.parser.yy.error=r,void 0===this.cmdQueue&&(this.cmdQueue=[]),void 0===this.commandInAction&&(this.commandInAction=!1),this.cmdQueue=this.cmdQueue.concat(e.split("\n"))},wu.prototype.awaitWhileCMDisInProcess=function(){this.commandInAction=!0},wu.prototype.finishAwaitingCMDInProcess=function(){this.commandInAction=!1},wu.prototype.isScriptingCommandAvailable=function(){return void 0!==this.commandInAction&&!this.commandInAction&&void 0!==this.cmdQueue&&this.cmdQueue.length>0},wu.prototype.callNextCmd=function(){if(this.isScriptingCommandAvailable()){var e=this.cmdQueue.shift(),t={success:!1};try{Ru.parser.parse(e),t.success=!0}catch(e){t.error=e.message,Ru.parser.yy.error(t.error),this.finishAwaitingCMDInProcess()}return t}return""},Ru.parser.yy=Wu,Ru.parser.yy.parseError=Ru.parser.parseError}}]);
|