@datagrok/helm 2.13.7 → 3.0.0

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.
Files changed (349) hide show
  1. package/CREDITS.md +164 -0
  2. package/dist/489.js +2 -0
  3. package/dist/489.js.map +1 -0
  4. package/dist/package-test.js +1 -1
  5. package/dist/package-test.js.map +1 -1
  6. package/dist/package.js +1 -1
  7. package/dist/package.js.map +1 -1
  8. package/files/samples/helm-showcase.csv +56 -0
  9. package/package.json +6 -10
  10. package/src/helm-helper.ts +61 -413
  11. package/src/package-api.ts +14 -11
  12. package/src/package-test.ts +0 -2
  13. package/src/package-utils.ts +8 -298
  14. package/src/package.g.ts +2 -8
  15. package/src/package.ts +11 -31
  16. package/src/tests/helm-activity-cliffs.ts +2 -2
  17. package/src/tests/helm-input-tests.ts +83 -0
  18. package/src/tests/parse-helm-tests.ts +7 -57
  19. package/src/tests/properties-widget-tests.ts +21 -11
  20. package/src/utils/helm-grid-cell-renderer.ts +141 -151
  21. package/src/utils/index.ts +3 -7
  22. package/src/widgets/helm-input.ts +42 -12
  23. package/src/widgets/properties-widget.ts +18 -11
  24. package/test-console-output-1.log +103 -706
  25. package/test-record-1.mp4 +0 -0
  26. package/webpack.config.js +1 -12
  27. package/dist/455.js +0 -2
  28. package/dist/455.js.map +0 -1
  29. package/dist/package-dojo.js +0 -2
  30. package/dist/package-dojo.js.map +0 -1
  31. package/helm/JSDraw/Pistoia.HELM-uncompressed.js +0 -9694
  32. package/helm/JSDraw/ReadMe.txt +0 -8
  33. package/helm/JSDraw/Scilligence.JSDraw2.Lite-uncompressed.js +0 -31126
  34. package/helm/dojo/package.ts +0 -41
  35. package/helm/dojo/types.ts +0 -12
  36. package/src/helm-web-editor.ts +0 -68
  37. package/src/tests/get-monomer-tests.ts +0 -214
  38. package/src/tests/helm-service-tests.ts +0 -98
  39. package/src/types/dojo.ts +0 -3
  40. package/src/types/index.ts +0 -5
  41. package/src/utils/get-monomer.ts +0 -90
  42. package/src/utils/helm-service.ts +0 -166
  43. package/vendor/dojo-1.10.10/dijit/BackgroundIframe.js +0 -63
  44. package/vendor/dojo-1.10.10/dijit/BackgroundIframe.js.uncompressed.js +0 -116
  45. package/vendor/dojo-1.10.10/dijit/Destroyable.js +0 -35
  46. package/vendor/dojo-1.10.10/dijit/Destroyable.js.uncompressed.js +0 -83
  47. package/vendor/dojo-1.10.10/dijit/Tooltip.js +0 -240
  48. package/vendor/dojo-1.10.10/dijit/Tooltip.js.uncompressed.js +0 -612
  49. package/vendor/dojo-1.10.10/dijit/Viewport.js +0 -44
  50. package/vendor/dojo-1.10.10/dijit/Viewport.js.uncompressed.js +0 -87
  51. package/vendor/dojo-1.10.10/dijit/WidgetSet.js +0 -76
  52. package/vendor/dojo-1.10.10/dijit/WidgetSet.js.uncompressed.js +0 -247
  53. package/vendor/dojo-1.10.10/dijit/_AttachMixin.js +0 -94
  54. package/vendor/dojo-1.10.10/dijit/_AttachMixin.js.uncompressed.js +0 -238
  55. package/vendor/dojo-1.10.10/dijit/_Contained.js +0 -17
  56. package/vendor/dojo-1.10.10/dijit/_Contained.js.uncompressed.js +0 -56
  57. package/vendor/dojo-1.10.10/dijit/_Container.js +0 -47
  58. package/vendor/dojo-1.10.10/dijit/_Container.js.uncompressed.js +0 -108
  59. package/vendor/dojo-1.10.10/dijit/_CssStateMixin.js +0 -198
  60. package/vendor/dojo-1.10.10/dijit/_CssStateMixin.js.uncompressed.js +0 -372
  61. package/vendor/dojo-1.10.10/dijit/_FocusMixin.js +0 -11
  62. package/vendor/dojo-1.10.10/dijit/_FocusMixin.js.uncompressed.js +0 -66
  63. package/vendor/dojo-1.10.10/dijit/_HasDropDown.js +0 -188
  64. package/vendor/dojo-1.10.10/dijit/_HasDropDown.js.uncompressed.js +0 -472
  65. package/vendor/dojo-1.10.10/dijit/_OnDijitClickMixin.js +0 -8
  66. package/vendor/dojo-1.10.10/dijit/_OnDijitClickMixin.js.uncompressed.js +0 -31
  67. package/vendor/dojo-1.10.10/dijit/_TemplatedMixin.js +0 -90
  68. package/vendor/dojo-1.10.10/dijit/_TemplatedMixin.js.uncompressed.js +0 -205
  69. package/vendor/dojo-1.10.10/dijit/_Widget.js +0 -66
  70. package/vendor/dojo-1.10.10/dijit/_Widget.js.uncompressed.js +0 -352
  71. package/vendor/dojo-1.10.10/dijit/_WidgetBase.js +0 -353
  72. package/vendor/dojo-1.10.10/dijit/_WidgetBase.js.uncompressed.js +0 -1200
  73. package/vendor/dojo-1.10.10/dijit/_base/focus.js +0 -68
  74. package/vendor/dojo-1.10.10/dijit/_base/focus.js.uncompressed.js +0 -207
  75. package/vendor/dojo-1.10.10/dijit/_base/manager.js +0 -10
  76. package/vendor/dojo-1.10.10/dijit/_base/manager.js.uncompressed.js +0 -35
  77. package/vendor/dojo-1.10.10/dijit/_base/place.js +0 -52
  78. package/vendor/dojo-1.10.10/dijit/_base/place.js.uncompressed.js +0 -131
  79. package/vendor/dojo-1.10.10/dijit/_base/popup.js +0 -23
  80. package/vendor/dojo-1.10.10/dijit/_base/popup.js.uncompressed.js +0 -58
  81. package/vendor/dojo-1.10.10/dijit/_base/scroll.js +0 -6
  82. package/vendor/dojo-1.10.10/dijit/_base/scroll.js.uncompressed.js +0 -22
  83. package/vendor/dojo-1.10.10/dijit/_base/sniff.js +0 -3
  84. package/vendor/dojo-1.10.10/dijit/_base/sniff.js.uncompressed.js +0 -12
  85. package/vendor/dojo-1.10.10/dijit/_base/typematic.js +0 -3
  86. package/vendor/dojo-1.10.10/dijit/_base/typematic.js.uncompressed.js +0 -10
  87. package/vendor/dojo-1.10.10/dijit/_base/wai.js +0 -32
  88. package/vendor/dojo-1.10.10/dijit/_base/wai.js.uncompressed.js +0 -109
  89. package/vendor/dojo-1.10.10/dijit/_base/window.js +0 -6
  90. package/vendor/dojo-1.10.10/dijit/_base/window.js.uncompressed.js +0 -18
  91. package/vendor/dojo-1.10.10/dijit/_base.js +0 -4
  92. package/vendor/dojo-1.10.10/dijit/_base.js.uncompressed.js +0 -27
  93. package/vendor/dojo-1.10.10/dijit/a11y.js +0 -109
  94. package/vendor/dojo-1.10.10/dijit/a11y.js.uncompressed.js +0 -191
  95. package/vendor/dojo-1.10.10/dijit/a11yclick.js +0 -66
  96. package/vendor/dojo-1.10.10/dijit/a11yclick.js.uncompressed.js +0 -139
  97. package/vendor/dojo-1.10.10/dijit/focus.js +0 -188
  98. package/vendor/dojo-1.10.10/dijit/focus.js.uncompressed.js +0 -371
  99. package/vendor/dojo-1.10.10/dijit/form/Button.js +0 -49
  100. package/vendor/dojo-1.10.10/dijit/form/Button.js.uncompressed.js +0 -130
  101. package/vendor/dojo-1.10.10/dijit/form/ComboBox.js +0 -4
  102. package/vendor/dojo-1.10.10/dijit/form/ComboBox.js.uncompressed.js +0 -27
  103. package/vendor/dojo-1.10.10/dijit/form/ComboButton.js +0 -21
  104. package/vendor/dojo-1.10.10/dijit/form/ComboButton.js.uncompressed.js +0 -86
  105. package/vendor/dojo-1.10.10/dijit/form/DropDownButton.js +0 -38
  106. package/vendor/dojo-1.10.10/dijit/form/DropDownButton.js.uncompressed.js +0 -102
  107. package/vendor/dojo-1.10.10/dijit/form/ToggleButton.js +0 -7
  108. package/vendor/dojo-1.10.10/dijit/form/ToggleButton.js.uncompressed.js +0 -26
  109. package/vendor/dojo-1.10.10/dijit/form/_ButtonMixin.js +0 -50
  110. package/vendor/dojo-1.10.10/dijit/form/_ButtonMixin.js.uncompressed.js +0 -116
  111. package/vendor/dojo-1.10.10/dijit/form/_FormValueMixin.js +0 -26
  112. package/vendor/dojo-1.10.10/dijit/form/_FormValueMixin.js.uncompressed.js +0 -81
  113. package/vendor/dojo-1.10.10/dijit/form/_FormValueWidget.js +0 -24
  114. package/vendor/dojo-1.10.10/dijit/form/_FormValueWidget.js.uncompressed.js +0 -51
  115. package/vendor/dojo-1.10.10/dijit/form/_FormWidget.js +0 -22
  116. package/vendor/dojo-1.10.10/dijit/form/_FormWidget.js.uncompressed.js +0 -67
  117. package/vendor/dojo-1.10.10/dijit/form/_FormWidgetMixin.js +0 -111
  118. package/vendor/dojo-1.10.10/dijit/form/_FormWidgetMixin.js.uncompressed.js +0 -254
  119. package/vendor/dojo-1.10.10/dijit/form/_ToggleButtonMixin.js +0 -32
  120. package/vendor/dojo-1.10.10/dijit/form/_ToggleButtonMixin.js.uncompressed.js +0 -69
  121. package/vendor/dojo-1.10.10/dijit/hccss.js +0 -9
  122. package/vendor/dojo-1.10.10/dijit/hccss.js.uncompressed.js +0 -21
  123. package/vendor/dojo-1.10.10/dijit/layout/AccordionContainer.js +0 -215
  124. package/vendor/dojo-1.10.10/dijit/layout/AccordionContainer.js.uncompressed.js +0 -550
  125. package/vendor/dojo-1.10.10/dijit/layout/AccordionPane.js +0 -7
  126. package/vendor/dojo-1.10.10/dijit/layout/AccordionPane.js.uncompressed.js +0 -25
  127. package/vendor/dojo-1.10.10/dijit/layout/ContentPane.js +0 -235
  128. package/vendor/dojo-1.10.10/dijit/layout/ContentPane.js.uncompressed.js +0 -653
  129. package/vendor/dojo-1.10.10/dijit/layout/StackContainer.js +0 -171
  130. package/vendor/dojo-1.10.10/dijit/layout/StackContainer.js.uncompressed.js +0 -411
  131. package/vendor/dojo-1.10.10/dijit/layout/StackController.js +0 -194
  132. package/vendor/dojo-1.10.10/dijit/layout/StackController.js.uncompressed.js +0 -410
  133. package/vendor/dojo-1.10.10/dijit/layout/_ContentPaneResizeMixin.js +0 -99
  134. package/vendor/dojo-1.10.10/dijit/layout/_ContentPaneResizeMixin.js.uncompressed.js +0 -236
  135. package/vendor/dojo-1.10.10/dijit/layout/_LayoutWidget.js +0 -47
  136. package/vendor/dojo-1.10.10/dijit/layout/_LayoutWidget.js.uncompressed.js +0 -190
  137. package/vendor/dojo-1.10.10/dijit/layout/utils.js +0 -77
  138. package/vendor/dojo-1.10.10/dijit/layout/utils.js.uncompressed.js +0 -151
  139. package/vendor/dojo-1.10.10/dijit/main.js +0 -4
  140. package/vendor/dojo-1.10.10/dijit/main.js.uncompressed.js +0 -16
  141. package/vendor/dojo-1.10.10/dijit/nls/dijit-all_en-us.js +0 -2
  142. package/vendor/dojo-1.10.10/dijit/nls/dijit-all_en-us.js.uncompressed.js +0 -21
  143. package/vendor/dojo-1.10.10/dijit/nls/loading.js +0 -2
  144. package/vendor/dojo-1.10.10/dijit/nls/loading.js.uncompressed.js +0 -47
  145. package/vendor/dojo-1.10.10/dijit/place.js +0 -142
  146. package/vendor/dojo-1.10.10/dijit/place.js.uncompressed.js +0 -407
  147. package/vendor/dojo-1.10.10/dijit/popup.js +0 -162
  148. package/vendor/dojo-1.10.10/dijit/popup.js.uncompressed.js +0 -441
  149. package/vendor/dojo-1.10.10/dijit/registry.js +0 -79
  150. package/vendor/dojo-1.10.10/dijit/registry.js.uncompressed.js +0 -159
  151. package/vendor/dojo-1.10.10/dijit/selection.js +0 -364
  152. package/vendor/dojo-1.10.10/dijit/selection.js.uncompressed.js +0 -525
  153. package/vendor/dojo-1.10.10/dijit/typematic.js +0 -96
  154. package/vendor/dojo-1.10.10/dijit/typematic.js.uncompressed.js +0 -211
  155. package/vendor/dojo-1.10.10/dojo/NodeList-manipulate.js +0 -195
  156. package/vendor/dojo-1.10.10/dojo/NodeList-manipulate.js.uncompressed.js +0 -761
  157. package/vendor/dojo-1.10.10/dojo/Stateful.js +0 -90
  158. package/vendor/dojo-1.10.10/dojo/Stateful.js.uncompressed.js +0 -218
  159. package/vendor/dojo-1.10.10/dojo/_base/url.js +0 -87
  160. package/vendor/dojo-1.10.10/dojo/_base/url.js.uncompressed.js +0 -109
  161. package/vendor/dojo-1.10.10/dojo/cache.js +0 -9
  162. package/vendor/dojo-1.10.10/dojo/cache.js.uncompressed.js +0 -7
  163. package/vendor/dojo-1.10.10/dojo/colors.js +0 -74
  164. package/vendor/dojo-1.10.10/dojo/colors.js.uncompressed.js +0 -232
  165. package/vendor/dojo-1.10.10/dojo/cookie.js +0 -48
  166. package/vendor/dojo-1.10.10/dojo/cookie.js.uncompressed.js +0 -98
  167. package/vendor/dojo-1.10.10/dojo/date/stamp.js +0 -82
  168. package/vendor/dojo-1.10.10/dojo/date/stamp.js.uncompressed.js +0 -144
  169. package/vendor/dojo-1.10.10/dojo/dojo.js +0 -7
  170. package/vendor/dojo-1.10.10/dojo/dojo.js.uncompressed.js +0 -18680
  171. package/vendor/dojo-1.10.10/dojo/fx/Toggler.js +0 -27
  172. package/vendor/dojo-1.10.10/dojo/fx/Toggler.js.uncompressed.js +0 -101
  173. package/vendor/dojo-1.10.10/dojo/fx/easing.js +0 -165
  174. package/vendor/dojo-1.10.10/dojo/fx/easing.js.uncompressed.js +0 -276
  175. package/vendor/dojo-1.10.10/dojo/fx.js +0 -271
  176. package/vendor/dojo-1.10.10/dojo/fx.js.uncompressed.js +0 -443
  177. package/vendor/dojo-1.10.10/dojo/hccss.js +0 -26
  178. package/vendor/dojo-1.10.10/dojo/hccss.js.uncompressed.js +0 -52
  179. package/vendor/dojo-1.10.10/dojo/html.js +0 -161
  180. package/vendor/dojo-1.10.10/dojo/html.js.uncompressed.js +0 -370
  181. package/vendor/dojo-1.10.10/dojo/io/iframe.js +0 -71
  182. package/vendor/dojo-1.10.10/dojo/io/iframe.js.uncompressed.js +0 -190
  183. package/vendor/dojo-1.10.10/dojo/io/script.js +0 -112
  184. package/vendor/dojo-1.10.10/dojo/io/script.js.uncompressed.js +0 -280
  185. package/vendor/dojo-1.10.10/dojo/parser.js +0 -437
  186. package/vendor/dojo-1.10.10/dojo/parser.js.uncompressed.js +0 -915
  187. package/vendor/dojo-1.10.10/dojo/promise/all.js +0 -59
  188. package/vendor/dojo-1.10.10/dojo/promise/all.js.uncompressed.js +0 -77
  189. package/vendor/dojo-1.10.10/dojo/regexp.js +0 -32
  190. package/vendor/dojo-1.10.10/dojo/regexp.js.uncompressed.js +0 -70
  191. package/vendor/dojo-1.10.10/dojo/request/iframe.js +0 -291
  192. package/vendor/dojo-1.10.10/dojo/request/iframe.js.uncompressed.js +0 -438
  193. package/vendor/dojo-1.10.10/dojo/request/script.js +0 -129
  194. package/vendor/dojo-1.10.10/dojo/request/script.js.uncompressed.js +0 -237
  195. package/vendor/dojo-1.10.10/dojo/require.js +0 -11
  196. package/vendor/dojo-1.10.10/dojo/require.js.uncompressed.js +0 -7
  197. package/vendor/dojo-1.10.10/dojo/resources/blank.gif +0 -0
  198. package/vendor/dojo-1.10.10/dojo/string.js +0 -67
  199. package/vendor/dojo-1.10.10/dojo/string.js.uncompressed.js +0 -181
  200. package/vendor/dojo-1.10.10/dojo/touch.js +0 -191
  201. package/vendor/dojo-1.10.10/dojo/touch.js.uncompressed.js +0 -468
  202. package/vendor/dojo-1.10.10/dojo/uacss.js +0 -36
  203. package/vendor/dojo-1.10.10/dojo/uacss.js.uncompressed.js +0 -85
  204. package/vendor/dojo-1.10.10/dojo/window.js +0 -141
  205. package/vendor/dojo-1.10.10/dojo/window.js.uncompressed.js +0 -241
  206. package/vendor/dojo-1.10.10/dojox/charting/Chart.js +0 -626
  207. package/vendor/dojo-1.10.10/dojox/charting/Chart.js.uncompressed.js +0 -1220
  208. package/vendor/dojo-1.10.10/dojox/charting/Chart2D.js +0 -5
  209. package/vendor/dojo-1.10.10/dojox/charting/Chart2D.js.uncompressed.js +0 -16
  210. package/vendor/dojo-1.10.10/dojox/charting/Element.js +0 -247
  211. package/vendor/dojo-1.10.10/dojox/charting/Element.js.uncompressed.js +0 -402
  212. package/vendor/dojo-1.10.10/dojox/charting/Series.js +0 -24
  213. package/vendor/dojo-1.10.10/dojox/charting/Series.js.uncompressed.js +0 -58
  214. package/vendor/dojo-1.10.10/dojox/charting/SimpleTheme.js +0 -191
  215. package/vendor/dojo-1.10.10/dojox/charting/SimpleTheme.js.uncompressed.js +0 -577
  216. package/vendor/dojo-1.10.10/dojox/charting/Theme.js +0 -42
  217. package/vendor/dojo-1.10.10/dojox/charting/Theme.js.uncompressed.js +0 -120
  218. package/vendor/dojo-1.10.10/dojox/charting/action2d/Base.js +0 -11
  219. package/vendor/dojo-1.10.10/dojox/charting/action2d/Base.js.uncompressed.js +0 -36
  220. package/vendor/dojo-1.10.10/dojox/charting/action2d/Highlight.js +0 -77
  221. package/vendor/dojo-1.10.10/dojox/charting/action2d/Highlight.js.uncompressed.js +0 -144
  222. package/vendor/dojo-1.10.10/dojox/charting/action2d/Magnify.js +0 -58
  223. package/vendor/dojo-1.10.10/dojox/charting/action2d/Magnify.js.uncompressed.js +0 -123
  224. package/vendor/dojo-1.10.10/dojox/charting/action2d/MoveSlice.js +0 -54
  225. package/vendor/dojo-1.10.10/dojox/charting/action2d/MoveSlice.js.uncompressed.js +0 -124
  226. package/vendor/dojo-1.10.10/dojox/charting/action2d/PlotAction.js +0 -28
  227. package/vendor/dojo-1.10.10/dojox/charting/action2d/PlotAction.js.uncompressed.js +0 -74
  228. package/vendor/dojo-1.10.10/dojox/charting/action2d/Tooltip.js +0 -116
  229. package/vendor/dojo-1.10.10/dojox/charting/action2d/Tooltip.js.uncompressed.js +0 -178
  230. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Base.js +0 -24
  231. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Base.js.uncompressed.js +0 -83
  232. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Default.js +0 -557
  233. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Default.js.uncompressed.js +0 -980
  234. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Invisible.js +0 -65
  235. package/vendor/dojo-1.10.10/dojox/charting/axis2d/Invisible.js.uncompressed.js +0 -224
  236. package/vendor/dojo-1.10.10/dojox/charting/axis2d/common.js +0 -91
  237. package/vendor/dojo-1.10.10/dojox/charting/axis2d/common.js.uncompressed.js +0 -164
  238. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Areas.js +0 -7
  239. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Areas.js.uncompressed.js +0 -14
  240. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Bars.js +0 -168
  241. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Bars.js.uncompressed.js +0 -311
  242. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Base.js +0 -61
  243. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Base.js.uncompressed.js +0 -161
  244. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Bubble.js +0 -141
  245. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Bubble.js.uncompressed.js +0 -242
  246. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Candlesticks.js +0 -126
  247. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Candlesticks.js.uncompressed.js +0 -243
  248. package/vendor/dojo-1.10.10/dojox/charting/plot2d/CartesianBase.js +0 -108
  249. package/vendor/dojo-1.10.10/dojox/charting/plot2d/CartesianBase.js.uncompressed.js +0 -290
  250. package/vendor/dojo-1.10.10/dojox/charting/plot2d/ClusteredBars.js +0 -13
  251. package/vendor/dojo-1.10.10/dojox/charting/plot2d/ClusteredBars.js.uncompressed.js +0 -14
  252. package/vendor/dojo-1.10.10/dojox/charting/plot2d/ClusteredColumns.js +0 -13
  253. package/vendor/dojo-1.10.10/dojox/charting/plot2d/ClusteredColumns.js.uncompressed.js +0 -14
  254. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Columns.js +0 -153
  255. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Columns.js.uncompressed.js +0 -249
  256. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Default.js +0 -253
  257. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Default.js.uncompressed.js +0 -472
  258. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Grid.js +0 -182
  259. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Grid.js.uncompressed.js +0 -356
  260. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Lines.js +0 -6
  261. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Lines.js.uncompressed.js +0 -12
  262. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Markers.js +0 -6
  263. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Markers.js.uncompressed.js +0 -12
  264. package/vendor/dojo-1.10.10/dojox/charting/plot2d/MarkersOnly.js +0 -7
  265. package/vendor/dojo-1.10.10/dojox/charting/plot2d/MarkersOnly.js.uncompressed.js +0 -13
  266. package/vendor/dojo-1.10.10/dojox/charting/plot2d/OHLC.js +0 -110
  267. package/vendor/dojo-1.10.10/dojox/charting/plot2d/OHLC.js.uncompressed.js +0 -208
  268. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Pie.js +0 -303
  269. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Pie.js.uncompressed.js +0 -547
  270. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Scatter.js +0 -134
  271. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Scatter.js.uncompressed.js +0 -207
  272. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Spider.js +0 -299
  273. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Spider.js.uncompressed.js +0 -537
  274. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Stacked.js +0 -24
  275. package/vendor/dojo-1.10.10/dojox/charting/plot2d/Stacked.js.uncompressed.js +0 -44
  276. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedAreas.js +0 -7
  277. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedAreas.js.uncompressed.js +0 -14
  278. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedBars.js +0 -22
  279. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedBars.js.uncompressed.js +0 -33
  280. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedColumns.js +0 -20
  281. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedColumns.js.uncompressed.js +0 -31
  282. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedLines.js +0 -6
  283. package/vendor/dojo-1.10.10/dojox/charting/plot2d/StackedLines.js.uncompressed.js +0 -12
  284. package/vendor/dojo-1.10.10/dojox/charting/plot2d/_PlotEvents.js +0 -68
  285. package/vendor/dojo-1.10.10/dojox/charting/plot2d/_PlotEvents.js.uncompressed.js +0 -120
  286. package/vendor/dojo-1.10.10/dojox/charting/plot2d/common.js +0 -209
  287. package/vendor/dojo-1.10.10/dojox/charting/plot2d/common.js.uncompressed.js +0 -214
  288. package/vendor/dojo-1.10.10/dojox/charting/plot2d/commonStacked.js +0 -76
  289. package/vendor/dojo-1.10.10/dojox/charting/plot2d/commonStacked.js.uncompressed.js +0 -77
  290. package/vendor/dojo-1.10.10/dojox/charting/scaler/common.js +0 -59
  291. package/vendor/dojo-1.10.10/dojox/charting/scaler/common.js.uncompressed.js +0 -70
  292. package/vendor/dojo-1.10.10/dojox/charting/scaler/linear.js +0 -220
  293. package/vendor/dojo-1.10.10/dojox/charting/scaler/linear.js.uncompressed.js +0 -262
  294. package/vendor/dojo-1.10.10/dojox/charting/scaler/primitive.js +0 -23
  295. package/vendor/dojo-1.10.10/dojox/charting/scaler/primitive.js.uncompressed.js +0 -36
  296. package/vendor/dojo-1.10.10/dojox/charting/themes/Claro.js +0 -39
  297. package/vendor/dojo-1.10.10/dojox/charting/themes/Claro.js.uncompressed.js +0 -106
  298. package/vendor/dojo-1.10.10/dojox/charting/themes/Wetland.js +0 -5
  299. package/vendor/dojo-1.10.10/dojox/charting/themes/Wetland.js.uncompressed.js +0 -12
  300. package/vendor/dojo-1.10.10/dojox/charting/themes/common.js +0 -4
  301. package/vendor/dojo-1.10.10/dojox/charting/themes/common.js.uncompressed.js +0 -3
  302. package/vendor/dojo-1.10.10/dojox/charting/widget/Legend.js +0 -102
  303. package/vendor/dojo-1.10.10/dojox/charting/widget/Legend.js.uncompressed.js +0 -165
  304. package/vendor/dojo-1.10.10/dojox/color/Palette.js +0 -163
  305. package/vendor/dojo-1.10.10/dojox/color/Palette.js.uncompressed.js +0 -460
  306. package/vendor/dojo-1.10.10/dojox/color/_base.js +0 -174
  307. package/vendor/dojo-1.10.10/dojox/color/_base.js.uncompressed.js +0 -196
  308. package/vendor/dojo-1.10.10/dojox/gfx/_base.js +0 -253
  309. package/vendor/dojo-1.10.10/dojox/gfx/_base.js.uncompressed.js +0 -1024
  310. package/vendor/dojo-1.10.10/dojox/gfx/fx.js +0 -297
  311. package/vendor/dojo-1.10.10/dojox/gfx/fx.js.uncompressed.js +0 -350
  312. package/vendor/dojo-1.10.10/dojox/gfx/gradutils.js +0 -63
  313. package/vendor/dojo-1.10.10/dojox/gfx/gradutils.js.uncompressed.js +0 -91
  314. package/vendor/dojo-1.10.10/dojox/gfx/matrix.js +0 -170
  315. package/vendor/dojo-1.10.10/dojox/gfx/matrix.js.uncompressed.js +0 -501
  316. package/vendor/dojo-1.10.10/dojox/gfx/path.js +0 -319
  317. package/vendor/dojo-1.10.10/dojox/gfx/path.js.uncompressed.js +0 -478
  318. package/vendor/dojo-1.10.10/dojox/gfx/shape.js +0 -459
  319. package/vendor/dojo-1.10.10/dojox/gfx/shape.js.uncompressed.js +0 -1091
  320. package/vendor/dojo-1.10.10/dojox/gfx/svg.js +0 -662
  321. package/vendor/dojo-1.10.10/dojox/gfx/svg.js.uncompressed.js +0 -1023
  322. package/vendor/dojo-1.10.10/dojox/gfx/utils.js +0 -199
  323. package/vendor/dojo-1.10.10/dojox/gfx/utils.js.uncompressed.js +0 -322
  324. package/vendor/dojo-1.10.10/dojox/gfx.js +0 -2
  325. package/vendor/dojo-1.10.10/dojox/gfx.js.uncompressed.js +0 -1136
  326. package/vendor/dojo-1.10.10/dojox/lang/functional/array.js +0 -151
  327. package/vendor/dojo-1.10.10/dojox/lang/functional/array.js.uncompressed.js +0 -169
  328. package/vendor/dojo-1.10.10/dojox/lang/functional/fold.js +0 -93
  329. package/vendor/dojo-1.10.10/dojox/lang/functional/fold.js.uncompressed.js +0 -125
  330. package/vendor/dojo-1.10.10/dojox/lang/functional/lambda.js +0 -81
  331. package/vendor/dojo-1.10.10/dojox/lang/functional/lambda.js.uncompressed.js +0 -132
  332. package/vendor/dojo-1.10.10/dojox/lang/functional/object.js +0 -54
  333. package/vendor/dojo-1.10.10/dojox/lang/functional/object.js.uncompressed.js +0 -78
  334. package/vendor/dojo-1.10.10/dojox/lang/functional/reversed.js +0 -61
  335. package/vendor/dojo-1.10.10/dojox/lang/functional/reversed.js.uncompressed.js +0 -77
  336. package/vendor/dojo-1.10.10/dojox/lang/functional/scan.js +0 -87
  337. package/vendor/dojo-1.10.10/dojox/lang/functional/scan.js.uncompressed.js +0 -107
  338. package/vendor/dojo-1.10.10/dojox/lang/functional.js +0 -4
  339. package/vendor/dojo-1.10.10/dojox/lang/functional.js.uncompressed.js +0 -3
  340. package/vendor/dojo-1.10.10/dojox/lang/utils.js +0 -86
  341. package/vendor/dojo-1.10.10/dojox/lang/utils.js.uncompressed.js +0 -121
  342. package/vendor/dojo-1.10.10/dojox/main.js +0 -4
  343. package/vendor/dojo-1.10.10/dojox/main.js.uncompressed.js +0 -14
  344. package/vendor/dojo-1.10.10/dojox/storage/LocalStorageProvider.js +0 -112
  345. package/vendor/dojo-1.10.10/dojox/storage/LocalStorageProvider.js.uncompressed.js +0 -208
  346. package/vendor/dojo-1.10.10/dojox/storage/Provider.js +0 -62
  347. package/vendor/dojo-1.10.10/dojox/storage/Provider.js.uncompressed.js +0 -344
  348. package/vendor/dojo-1.10.10/dojox/storage/manager.js +0 -110
  349. package/vendor/dojo-1.10.10/dojox/storage/manager.js.uncompressed.js +0 -263
package/CREDITS.md ADDED
@@ -0,0 +1,164 @@
1
+ # Helm — Third-Party Libraries
2
+
3
+ The `@datagrok/helm` package is distributed under the MIT license that covers
4
+ the rest of the `public/` repository (see [`../../LICENSE.md`](../../LICENSE.md)).
5
+ It incorporates the open-source components listed below; this file reproduces
6
+ the attribution and notices required by their respective licenses.
7
+
8
+ All runtime dependencies bundled into the published artifact are under
9
+ permissive licenses (MIT, ISC, BSD-3-Clause / Academic Free License v2.1).
10
+ No copyleft (GPL/LGPL/MPL) component is bundled into the published Helm
11
+ plugin artifact.
12
+
13
+ The Pistoia HELM Web Editor and Scilligence JSDraw2 sources, which were
14
+ historically vendored under `helm/JSDraw/`, are now consumed via
15
+ `@datagrok-libraries/helm-web-editor` (an internal Datagrok library covered by
16
+ the repo-wide MIT umbrella). Their original upstream licenses are reproduced
17
+ below for completeness because the vendored copies remain in the repository.
18
+
19
+ ---
20
+
21
+ ## 1. Bundled in the published artifact (`dist/`)
22
+
23
+ ### Dojo Toolkit (1.10.10)
24
+
25
+ The full Dojo Toolkit (`dojo`, `dijit`, `dojox`) is vendored under
26
+ `vendor/dojo-1.10.10/` and webpack-bundled into a separate `package-dojo.js`
27
+ chunk via `require.context()`. Required by JSDraw2 / HELM Web Editor.
28
+
29
+ - Upstream: https://dojotoolkit.org/ — https://github.com/dojo/dojo
30
+ - License: **BSD-3-Clause** OR **Academic Free License v2.1** (dual-licensed,
31
+ at the user's choice — Datagrok elects the BSD-3-Clause terms)
32
+
33
+ ```
34
+ Dojo is available under *either* the terms of the BSD 3-Clause "New" License
35
+ *or* the Academic Free License version 2.1. As a recipient of Dojo, you may
36
+ choose which license to receive this code under.
37
+
38
+ Copyright (c) 2005-2015, The Dojo Foundation
39
+ All rights reserved.
40
+
41
+ Redistribution and use in source and binary forms, with or without
42
+ modification, are permitted provided that the following conditions are met:
43
+
44
+ * Redistributions of source code must retain the above copyright notice,
45
+ this list of conditions and the following disclaimer.
46
+ * Redistributions in binary form must reproduce the above copyright notice,
47
+ this list of conditions and the following disclaimer in the documentation
48
+ and/or other materials provided with the distribution.
49
+ * Neither the name of the Dojo Foundation nor the names of its contributors
50
+ may be used to endorse or promote products derived from this software
51
+ without specific prior written permission.
52
+
53
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
54
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
56
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
57
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
60
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
61
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63
+ ```
64
+
65
+ **Modification note.** `core/client/d4`-style monkey patches are applied to
66
+ Dojo at runtime (not in the vendored source) — see
67
+ `HelmPackage.initHELMWebEditor()` in `src/package-utils.ts`, which patches
68
+ `dojox.gfx.svg.Text.prototype.getTextWidth` to prevent an infinite loop. The
69
+ vendored Dojo files themselves are byte-identical to the upstream 1.10.10
70
+ release.
71
+
72
+ ### Scilligence JSDraw2 Lite & Pistoia HELM Web Editor (vendored copy under `helm/JSDraw/`)
73
+
74
+ Historically vendored uncompressed sources of the JSDraw2 Lite molecule
75
+ sketcher (Scilligence) and the Pistoia HELM Web Editor. The active code path
76
+ loads `@datagrok-libraries/helm-web-editor` (the internal Datagrok library)
77
+ rather than these files; they are kept in the repository as a reference and
78
+ fallback. If a build configuration ever bundles them again, the following
79
+ notice applies.
80
+
81
+ - Upstream (JSDraw2 Lite): https://github.com/scilligence/JSDraw.Lite
82
+ - Upstream (HELM Web Editor): https://github.com/PistoiaHELM/HELMWebEditor
83
+ - License: **MIT** (both projects)
84
+
85
+ ```
86
+ The MIT License (MIT)
87
+
88
+ Copyright (c) Scilligence Corporation (JSDraw2 Lite) and the Pistoia Alliance
89
+ (HELM Web Editor)
90
+
91
+ Permission is hereby granted, free of charge, to any person obtaining a copy
92
+ of this software and associated documentation files (the "Software"), to deal
93
+ in the Software without restriction, including without limitation the rights
94
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95
+ copies of the Software, and to permit persons to whom the Software is
96
+ furnished to do so, subject to the following conditions:
97
+
98
+ The above copyright notice and this permission notice shall be included in all
99
+ copies or substantial portions of the Software.
100
+
101
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107
+ SOFTWARE.
108
+ ```
109
+
110
+ ### lru-cache (10.4.x)
111
+
112
+ LRU cache used to cap the rendered-monomer / off-screen-editor caches in the
113
+ HELM cell renderer.
114
+
115
+ - Upstream: https://github.com/isaacs/node-lru-cache
116
+ - License: **ISC**
117
+
118
+ ```
119
+ The ISC License
120
+
121
+ Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors
122
+
123
+ Permission to use, copy, modify, and/or distribute this software for any
124
+ purpose with or without fee is hereby granted, provided that the above
125
+ copyright notice and this permission notice appear in all copies.
126
+
127
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
128
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
129
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
130
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
131
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
132
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
133
+ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 2. Linked at runtime via the Datagrok platform (webpack externals)
139
+
140
+ These libraries are not bundled into Helm's `dist/` — they are provided once
141
+ by the platform host and shared across all packages.
142
+
143
+ | Component | Version | License | Upstream |
144
+ |-----------------|---------|--------------|--------------------------------------------|
145
+ | OpenChemLib JS | 7.x | BSD-3-Clause | https://github.com/cheminfo/openchemlib-js |
146
+ | RxJS | 6.x | Apache-2.0 | https://github.com/ReactiveX/rxjs |
147
+ | cash-dom | 8.x | MIT | https://github.com/fabiospampinato/cash |
148
+ | Day.js | 1.x | MIT | https://github.com/iamkun/dayjs |
149
+ | wu.js | 2.x | MIT | https://github.com/fitzgen/wu.js |
150
+
151
+ ---
152
+
153
+ ## 3. Development-only dependencies
154
+
155
+ Tools used during the build/test cycle (not in the runtime tree, not bundled):
156
+ the `datagrok-tools` CLI transitively pulls in `puppeteer-screen-recorder`,
157
+ which references `@ffmpeg-installer/ffmpeg` (LGPL-2.1) and
158
+ `@ffmpeg-installer/win32-x64` (GPLv3). These binaries are **not** redistributed
159
+ as part of the published Helm plugin and impose no obligation on users of the
160
+ plugin.
161
+
162
+ The peer/devDependencies on other Datagrok plugins (`@datagrok/bio`,
163
+ `@datagrok/chem`) are MIT — covered by the repo-wide `LICENSE.md`. Each of
164
+ those plugins maintains its own `CREDITS.md` for its own third-party content.
package/dist/489.js ADDED
@@ -0,0 +1,2 @@
1
+ var helm;(()=>{"use strict";"object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,new Set;const t="object"==typeof process&&process?process:{};let e=globalThis.AbortController,i=globalThis.AbortSignal;if(void 0===e){i=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},e=class{constructor(){l()}signal=new i;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let r="1"!==t.env?.LRU_CACHE_IGNORE_AC_WARNING;const l=()=>{r&&(r=!1,((e,i,r,l)=>{"function"==typeof t.emitWarning?t.emitWarning(e,i,r,l):console.error(`[${r}] ${i}: ${e}`)})("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",l))}}Symbol("type"),Symbol.iterator,Symbol.toStringTag;Error;new Map([[123,"lbrace"],[125,"rbrace"],[40,"lparen"],[41,"rparen"],[93,"rbracket"],[124,"pipe"],[46,"dot"],[44,"comma"],[43,"plus"],[58,"colon"],[45,"dash"],[36,"dollar"],[62,"gt"],[63,"question"],[42,"asterisk"],[95,"underscore"],[39,"apos"]]);new Map;var r="HELM_AA",l="HELM_SUGAR",s="HELM_BASE",o="HELM_LINKER",n="HELM_CHEM",a="HELM_BLOB",h="HELM_NUCLEOTIDE",d={PEPTIDE:"PEPTIDE",RNA:"RNA",CHEM:"CHEM",BLOB:"BLOB",G:"G"};var u=class{constructor(){this._listeners=new Set,this._completed=!1}subscribe(t){return this._completed?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}next(t){if(!this._completed)for(let e of[...this._listeners])e(t)}complete(){this._completed=!0,this._listeners.clear()}get observerCount(){return this._listeners.size}};function c(t){return{line:"#202020",text:"#000000",background:t}}function p(t){return{line:"#e0e0e0",text:"#ffffff",background:k(t,.25)}}function _(t){let e=/^#([0-9a-fA-F]{6})$/.exec(t),i=/^#([0-9a-fA-F]{3})$/.exec(t);if(null!==e){let t=e[1];return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}if(null!==i){let t=i[1];return[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)]}return null}function b(t){return t.toString(16).padStart(2,"0")}function f(t,e,i){return`#${b(t)}${b(e)}${b(i)}`}function m(t,e,i){let r=t/255,l=e/255,s=i/255,o=Math.max(r,l,s),n=Math.min(r,l,s),a=(o+n)/2;if(o===n)return[0,0,a];let h,d=o-n;return h=o===r?60*((l-s)/d+(l<s?6:0)):o===l?60*((s-r)/d+2):60*((r-l)/d+4),[h,a>.5?d/(2-o-n):d/(o+n),a]}function g(t,e,i){let r=i;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function v(t,e,i){if(0===e){let t=Math.round(255*i);return[t,t,t]}let r=i<.5?i*(1+e):i+e-i*e,l=2*i-r,s=t/360;return[Math.round(255*g(l,r,s+1/3)),Math.round(255*g(l,r,s)),Math.round(255*g(l,r,s-1/3))]}function y(t,e=.3,i=.1){let r=_(t);if(null===r)return t;let[l,s,o]=m(r[0],r[1],r[2]),n=Math.max(0,Math.min(1,s*(1-e))),a=Math.max(0,Math.min(.95,o+i*(1-o))),[h,d,u]=v(l,n,a);return f(h,d,u)}function w(t){let e=_(t);if(null===e)return 0;let i=t=>{let e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)};return.2126*i(e[0])+.7152*i(e[1])+.0722*i(e[2])}function A(t){let e=_(t);if(null===e)return"#1f2937";let[i,r,l]=m(e[0],e[1],e[2]);if(l>.85||r<.15&&l>.7)return"#1f2937";let s=Math.max(.08,l-.3);return function(t){let e=(t.h%360+360)%360,i=Math.max(0,Math.min(1,t.s)),r=Math.max(0,Math.min(1,t.l)),[l,s,o]=v(e,i,r);return f(l,s,o)}({h:i,s:Math.min(1,r+.1),l:s})}function S(t){let e=function(t){let e=_(t);return null===e?null:{r:e[0]/255,g:e[1]/255,b:e[2]/255}}(t);if(null===e)return"#1f2937";let i=t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),r=.2126*i(e.r)+.7152*i(e.g)+.0722*i(e.b);return 1.05/(r+.05)>(r+.05)/.05?"#ffffff":"#1f2937"}function k(t,e){let i=_(t);if(null===i)return t;let r=1-e;return f(Math.max(0,Math.min(255,Math.round(i[0]*r))),Math.max(0,Math.min(255,Math.round(i[1]*r))),Math.max(0,Math.min(255,Math.round(i[2]*r))))}var C={A:c("#A0A0FF"),G:c("#FF7070"),T:c("#A0FFA0"),C:c("#FF8C4B"),U:c("#FF8080")},T={R:c("#7a85c1"),r:c("#7a85c1")},E={P:c("#9aa5e1"),p:c("#9aa5e1")},N={A:c("#C8C8C8"),R:c("#145AFF"),N:c("#00DCDC"),D:c("#E60A0A"),C:c("#E6E600"),E:c("#00DCDC"),Q:c("#E60A0A"),G:c("#EBEBEB"),H:c("#8282D2"),I:c("#0F820F"),L:c("#0F820F"),K:c("#145AFF"),M:c("#E6E600"),F:c("#3232AA"),P:c("#DC9682"),S:c("#FA9600"),T:c("#FA9600"),W:c("#B45AB4"),Y:c("#3232AA"),V:c("#0F820F")},M={R:c("#eeeeee")},x={B:c("#999999"),G:c("#e2e2e2")},B={P:c("#9aa5e1")},L={name:"light",fallback:{line:"#202020",text:"#000000",background:"#eeeeee"},errorTriple:{line:"#cc0000",text:"#000000",background:"#FFFF00"},palette:{[s]:C,[l]:T,[o]:E,[r]:N,[n]:M,[a]:x,[h]:B}};function I(t){let e={};for(let[i,r]of Object.entries(t))e[i]=p(r.background);return e}var P={name:"dark",fallback:{line:"#e0e0e0",text:"#ffffff",background:k("#eeeeee",.5)},errorTriple:{line:"#ff5050",text:"#ffffff",background:k("#FFFF00",.4)},palette:{[s]:I(C),[l]:I(T),[o]:I(E),[r]:I(N),[n]:I(M),[a]:I(x),[h]:I(B)}};function $(t,e,i=L){if(null===t)return{...i.errorTriple};let r=t.meta?.colors;if(void 0!==r){let t="light"===i.name?r.light:"dark"===i.name?r.dark:void 0;if(void 0!==t)return{...t,line:A(t.background)};if(void 0!==r.default)return{...r.default,line:A(r.default.background)}}let l=t.naturalAnalog;if(void 0!==l&&""!==l){let t=i.palette[e];if(void 0!==t){let e=t[l];if(void 0!==e)return{...e,line:A(e.background),text:S(e.background)}}}return{...i.fallback,line:A(i.fallback.background),text:S(i.fallback.background)}}function F(t){switch(t.polymerType){case d.PEPTIDE:return r;case d.CHEM:return n;case d.BLOB:return a;case d.RNA:if("Branch"===t.monomerType)return s;if("Backbone"===t.monomerType){let e=t.naturalAnalog;return"P"===e||"p"===e?o:l}return null;default:return null}}new Set(["PEPTIDE","RNA","CHEM","BLOB"]),new Set(["Backbone","Branch","Terminal","Undefined"]);new Set(["?","*","_","X","N"]);Math.PI;function R(t,e){let i=Math.min(t.x,e.x),r=Math.min(t.y,e.y);return{x:i,y:r,width:Math.max(t.x+t.width,e.x+e.width)-i,height:Math.max(t.y+t.height,e.y+e.height)-r}}function O(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function D(t){if(0===t.length)return"";let e=t[0],i=`M ${O(e.x)} ${O(e.y)}`;for(let e=1;e<t.length;e++){let r=t[e];i+=` L ${O(r.x)} ${O(r.y)}`}return i+=` L ${O(e.x)} ${O(e.y)} Z`,i}function H(t,e,i,r){let l=[],s=360/e;for(let o=0;o<e;o++){let e=(r+o*s)*Math.PI/180;l.push({x:t.x+i*Math.cos(e),y:t.y+i*Math.sin(e)})}return l}function V(t,e,i,r){let l=Math.abs(e)/2,s=Math.abs(i)/2,o=Math.max(0,Math.min(r,l,s)),n=t.x-l,a=t.y-s,h=n+2*l,d=a+2*s,u=`M ${O(n+o)} ${O(a)}`;return u+=` L ${O(h-o)} ${O(a)}`,u+=` A ${O(o)} ${O(o)} 0 0 1 ${O(h)} ${O(a+o)}`,u+=` L ${O(h)} ${O(d-o)}`,u+=` A ${O(o)} ${O(o)} 0 0 1 ${O(h-o)} ${O(d)}`,u+=` L ${O(n+o)} ${O(d)}`,u+=` A ${O(o)} ${O(o)} 0 0 1 ${O(n)} ${O(d-o)}`,u+=` L ${O(n)} ${O(a+o)}`,u+=` A ${O(o)} ${O(o)} 0 0 1 ${O(n+o)} ${O(a)}`,u+=" Z",u}function G(t,e,i){let r=Math.abs(e),l=Math.abs(i);return`M ${O(t.x-r)} ${O(t.y)} A ${O(r)} ${O(l)} 0 1 0 ${O(t.x+r)} ${O(t.y)} A ${O(r)} ${O(l)} 0 1 0 ${O(t.x-r)} ${O(t.y)} Z`}function K(t,e,i,r){switch(t){case"hexagon":{let t=i*Math.sqrt(3)/2,r=i;return{x:e.x-t,y:e.y-r,width:2*t,height:2*r}}case"diamond":return{x:e.x-i,y:e.y-i,width:2*i,height:2*i};case"pentagon":{let t=Math.cos(18*Math.PI/180)*i,r=-i,l=Math.sin(54*Math.PI/180)*i;return{x:e.x-t,y:e.y+r,width:2*t,height:l-r}}case"rounded-rect":case"blob":{let t=r??i,l=Math.abs(i)/2,s=Math.abs(t)/2;return{x:e.x-l,y:e.y-s,width:2*l,height:2*s}}case"ellipse":{let t=Math.abs(i),l=Math.abs(r??i);return{x:e.x-t,y:e.y-l,width:2*t,height:2*l}}case"circle":{let t=Math.abs(i);return{x:e.x-t,y:e.y-t,width:2*t,height:2*t}}}}var z='"Helvetica Neue", Helvetica, Arial, sans-serif';function U(t){return{aa:{size:.72*t,strokeWidth:5},sugar:{size:1.39*t,strokeWidth:5,cornerRadius:.3*t},base:{size:.88*t,strokeWidth:5},linker:{size:.63*t,strokeWidth:5},chem:{size:1.49*t,strokeWidth:5,cornerRadius:.5*t},blob:{size:1.64*t,strokeWidth:5,cornerRadius:.8*t},nucleotide:{size:.98*t,strokeWidth:5}}}var q={name:"light",background:"#ffffff",defaultStroke:"#202020",defaultFill:"#ffffff",selectionColor:"#FFC107",highlightColor:"#A4E2DC",errorColor:"#cc0000",fontSize:14,fontFamily:z,bondLength:28,textColor:"#000000",idColor:"#00aa00",annotationColor:"#FFA500",tagDotColor:"#dd2222",hbondColor:"#888888",nonCanonicalHbondColor:"#cc8800",crossPolymerBondColor:"#1f5fcd",colorTheme:L,palette:{softenCanvas:!1},shapes:U(14)};U(14);function j(t,e){switch(e){case r:return t.shapes.aa;case l:return t.shapes.sugar;case s:return t.shapes.base;case o:return t.shapes.linker;case n:return t.shapes.chem;case a:return t.shapes.blob;case h:return t.shapes.nucleotide}}function W(t){switch(t){case r:return"hexagon";case l:return"rounded-rect";case s:return"diamond";case o:return"circle";case n:return"rounded-rect";case a:return"blob";case h:return"pentagon"}}function Y(t,e,i=0){let r=j(e,t.biotype);if("*"===t.symbol)return function(t,e){return G(t,e,e)}(t.p,r.size+i);switch(W(t.biotype)){case"hexagon":{let e=0===i?0:i/Math.cos(Math.PI/6);return function(t,e,i=-30){return D(H(t,6,e,i))}(t.p,r.size+e)}case"diamond":{let e=0===i?0:i/Math.cos(Math.PI/4);return function(t,e){return D([{x:t.x,y:t.y-e},{x:t.x+e,y:t.y},{x:t.x,y:t.y+e},{x:t.x-e,y:t.y}])}(t.p,r.size+e)}case"pentagon":{let e=0===i?0:i/Math.cos(Math.PI/5);return function(t,e,i=-90){return D(H(t,5,e,i))}(t.p,r.size+e)}case"rounded-rect":return V(t.p,r.size+2*i,r.size+2*i,(r.cornerRadius??0)+i);case"blob":return function(t,e,i,r){return V(t,e,i,r)}(t.p,r.size+2*i,r.size+2*i,(r.cornerRadius??0)+i);case"circle":return G(t.p,r.size+i,r.size+i)}}function X(t,e){let i,r=j(e,t.biotype),l="*"===t.symbol?"circle":W(t.biotype);switch(l){case"hexagon":case"diamond":case"pentagon":case"circle":i=K(l,t.p,r.size);break;case"rounded-rect":case"blob":i=K(l,t.p,r.size,r.size)}let s=r.strokeWidth/2;return{x:i.x-s,y:i.y-s,width:i.width+2*s,height:i.height+2*s}}function Z(t,e){return j(e,t.biotype)}var J=/[&"'<>]/;function Q(t){return J.test(t)?t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):t}function tt(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function et(t,e,i){let r=`<${t}`;if(void 0!==e)for(let t in e){let i=e[t];if(void 0!==i&&!1!==i){if(!0===i){r+=` ${t}`;continue}r+="number"==typeof i?` ${t}="${tt(i)}"`:` ${t}="${Q(i)}"`}}return void 0===i?`${r}/>`:"string"==typeof i?`${r}>${i}</${t}>`:`${r}>${i.join("")}</${t}>`}function it(t,e,i){if(0===i.size)return et("g",{class:"hw-layer hw-highlights"},"");let r=[];for(let l of t.atoms){if(!i.has(l.id))continue;let t=Y(l,e,(Z(l,e).strokeWidth+3)/2);r.push(et("path",{d:t,class:"hw-highlight",fill:"none",stroke:e.highlightColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":l.symbol,"data-ring-atom-id":l.id,"data-testid":`highlight-ring-${l.id}`}))}return et("g",{class:"hw-layer hw-highlights"},r.join(""))}function rt(t,e,i){if(0===i.size)return et("g",{class:"hw-layer hw-selections"},"");let r=[];for(let l of t.atoms){if(!i.has(l.id))continue;let t=Y(l,e,(Z(l,e).strokeWidth+3)/2);r.push(et("path",{d:t,class:"hw-selection",fill:"none",stroke:e.selectionColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":l.symbol,"data-ring-atom-id":l.id,"data-testid":`selection-ring-${l.id}`}))}return et("g",{class:"hw-layer hw-selections"},r.join(""))}new WeakMap;var lt=class{constructor(t,e){this.atoms=t,this.bonds=e,this.isEmpty=0===t.size&&0===e.size,Object.freeze(this)}};new lt(new Set,new Set);function st(t){let e=t.ownerDocument;if(null!=e)return e;let i=globalThis;if(void 0!==i.document)return i.document;throw new Error("EditorView: no Document available (host.ownerDocument is null).")}function ot(t,e,i,r){let l=t.createElement(e);if(void 0!==i)for(let t of Object.keys(i)){let e=i[t];!1===e||void 0===e||l.setAttribute(t,!0===e?"":String(e))}if(void 0!==r)for(let e of r)"string"==typeof e?l.appendChild(t.createTextNode(e)):l.appendChild(e);return l}function nt(t,e,i=220,r=140){if(null==t||""===e)return null;try{let l=t.get_mol(e);if(null===l)return null;let s=l.get_svg(i,r);return l.delete(),s}catch{return null}}function at(t,e,i){let r="data-testid";for(let i=0;i<t.body.children.length;i++){let l=t.body.children[i];if(void 0!==l&&l.getAttribute(r)===e)return l}let l=ot(t,"div",{class:i,[r]:e});return l.style.display="none",t.body.appendChild(l),l}function ht(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(e.appendChild(ot(t,"div",{class:"hw-tooltip__symbol"},[i.symbol])),void 0!==i.name&&""!==i.name&&i.name!==i.symbol&&e.appendChild(ot(t,"div",{class:"hw-tooltip__name"},[i.name])),void 0!==i.rdkitSvg&&null!==i.rdkitSvg&&""!==i.rdkitSvg){let r={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(r["data-testid"]=i.rdkitTestid);let l=ot(t,"div",r);l.innerHTML=i.rdkitSvg,e.appendChild(l)}void 0!==i.hint&&""!==i.hint&&e.appendChild(ot(t,"div",{class:"hw-tooltip__hint"},[i.hint]))}function dt(t,e,i){let r=t.style;r.display="block",r.left=`${e+12}px`,r.top=`${i+12}px`}function ut(t){null!==t&&(t.style.display="none")}function ct(t){let e=t.body;if(null!=e)for(let t=0;t<e.children.length;t++){let i=e.children[t];if(void 0===i)continue;let r=void 0===i.getAttribute?null:i.getAttribute("data-testid");null!=r&&r.endsWith("-tooltip")&&ut(i)}}var pt=class t{constructor(t,e,i){this._baseTransform="",this._viewport={scale:1,offset:{x:0,y:0}},this._pinnedBbox=null,this._tooltip=null,this._bondTooltip=null,this._rdkitSvgCache=new Map,this._unsubs=[],this._destroyed=!1,this.host=t,this._editor=e,this._doc=i?.documentImpl??st(t),this._width=i?.width??400,this._height=i?.height??200,function(t){let e=st(t);if(null!==e.querySelector("style[data-hw-editor-view-styles]"))return;let i=e.createElement("style");i.setAttribute("data-hw-editor-view-styles",""),i.textContent=".hw-editor-view{position:relative;display:block;overflow:hidden;outline:none;}.hw-editor-view svg{display:block;user-select:none;}.hw-editor-view.hw-view-only{cursor:default;}";let r=e.head??e.documentElement;null!==r&&r.appendChild(i)}(t);let r=this._doc.createElement("div");r.setAttribute("class","hw-editor-view"),t.appendChild(r),this._tooltip=at(this._doc,"atom-tooltip","hw-atom-tooltip"),this._bondTooltip=at(this._doc,"bond-tooltip","hw-bond-tooltip"),this._svgRoot=this._renderFresh(),this._unsubs.push(e.on("mol:changed",t=>{this._hideTooltip(),this._hideBondTooltip(),("setHelm"===t.reason||"cleanLayout"===t.reason||"initial"===t.reason)&&(this._pinnedBbox=null),this._renderFresh()})),this._unsubs.push(e.on("selection:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("highlight:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("theme:change",()=>{this._renderFresh()})),this._unsubs.push(e.on("view:resize",t=>{this._applyResize(t.width,t.height)})),this._unsubs.push(e.on("view:viewport-change",t=>{this._viewport=t.viewport,this._applyViewport(t.viewport)})),this._unsubs.push(e.on("view:fit-to-content",()=>{this._pinnedBbox=null,this._renderFresh()})),this._unsubs.push(e.on("monomer:hover",t=>{this._showTooltip(t.atom,t.clientX,t.clientY)})),this._unsubs.push(e.on("monomer:hover-end",()=>{this._hideTooltip()})),this._unsubs.push(e.on("bond:hover",t=>{this._showBondTooltip(t.bond,t.clientX,t.clientY)})),this._unsubs.push(e.on("bond:hover-end",()=>{this._hideBondTooltip()})),this._unsubs.push(e.on("bond:preview",t=>{this._paintBondPreview(t.start.p,t.cursor,null!==t.candidate)})),this._unsubs.push(e.on("bond:preview-end",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("bond:cancel",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("selection:rectangle-start",t=>{this._paintSelectionRect(t.origin,t.origin)})),this._unsubs.push(e.on("selection:rectangle-update",t=>{this._paintSelectionRectFromRect(t.rect)})),this._unsubs.push(e.on("selection:rectangle-end",()=>{this._clearSelectionRect()}))}get svgRoot(){return this._svgRoot}get width(){return this._width}get height(){return this._height}resize(t,e){this._destroyed||(this._width=t,this._height=e,this._renderFresh())}redraw(){this._destroyed||this._renderFresh()}destroy(){if(this._destroyed)return;this._destroyed=!0;for(let t of this._unsubs)t();this._unsubs.length=0;let t=this.host.querySelector(".hw-editor-view");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t),ut(this._tooltip),ut(this._bondTooltip),this._tooltip=null,this._bondTooltip=null}_renderFresh(){let t=this._editor.getService(),e=this._currentTheme(),i=this._editor.getMol();null===this._pinnedBbox&&(this._pinnedBbox=function(t,e=q){if(0===t.atoms.length)return{x:0,y:0,width:0,height:0};let i=X(t.atoms[0],e);for(let r=1;r<t.atoms.length;r++)i=R(i,X(t.atoms[r],e));return i}(i,e));let r=t.renderMol(i,{width:this._width,height:this._height,theme:e,fixedModelBbox:this._pinnedBbox});this._svgRoot=function(t,e){let i=st(t),r=t.querySelector(".hw-editor-view");if(null===r)throw new Error("EditorView.replaceSvg: missing .hw-editor-view wrapper.");let l=i.createElement("div");l.innerHTML=e;let s=l.querySelector("svg");if(null===s)throw new Error("EditorView.replaceSvg: rendered output contained no <svg>.");for(;null!==r.firstChild;)r.removeChild(r.firstChild);return r.appendChild(s),s}(this.host,r);let l=this._svgRoot.querySelector(".hw-content");return this._baseTransform=null!==l?l.getAttribute("transform")??"":"",this._svgRoot.setAttribute("data-testid","editor-svg"),this._applyOverlaysToCurrent(),(1!==this._viewport.scale||0!==this._viewport.offset.x||0!==this._viewport.offset.y)&&this._applyViewport(this._viewport),this._svgRoot}_refreshOverlays(t){this._applyOverlaysToCurrent()}_applyOverlaysToCurrent(){let t=this._editor.getMol(),e=this._editor.getSelection(),i=function(t,e={}){let i=e.theme??q,r=e.selectedAtomIds??new Set;return{highlightLayer:it(t,i,e.highlightedAtomIds??new Set),selectionLayer:rt(t,i,r)}}(t,{theme:this._currentTheme(),selectedAtomIds:e.atoms,highlightedAtomIds:this._editorHighlights()});this._spliceLayer("hw-highlights",i.highlightLayer),this._spliceLayer("hw-selections",i.selectionLayer)}_spliceLayer(t,e){let i=this._svgRoot.querySelector(`.${t}`);if(null===i||null===i.parentNode)return;let r=this._doc.createElementNS("http://www.w3.org/2000/svg","svg");r.innerHTML=e;let l=r.querySelector(`.${t}`);null!==l&&i.parentNode.replaceChild(l,i)}_editorHighlights(){let t=this._editor;return"function"==typeof t._currentHighlights?t._currentHighlights():new Set}_currentTheme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyResize(t,e){this._width=t,this._height=e,this._pinnedBbox=null,this._renderFresh()}_applyViewport(t){let e=this._svgRoot.querySelector(".hw-content");if(null===e)return;let i=`translate(${t.offset.x} ${t.offset.y}) scale(${t.scale})`,r=""===this._baseTransform?i:`${i} ${this._baseTransform}`;e.setAttribute("transform",r)}_showTooltip(t,e,i){let r=this._tooltip;if(null===r)return;let l=""===t.symbol?"?":t.symbol,s=t.monomer?.name??"",o=t.bio.positionInChain,n=""===t.bio.chainId?"?":t.bio.chainId,a=""!==s&&s!==l?`${s} @ ${n}:${o}`:`${l} @ ${n}:${o}`,h=this._renderRdkitTooltipSvg(t);ht(this._doc,r,{symbol:l,name:a,rdkitSvg:h,rdkitTestid:"atom-tooltip-rdkit-svg"});let d=""!==s&&s!==l?`${l} — ${s} @ ${n}:${o}`:`${l} @ ${n}:${o}`,u=this._doc.createElement("div");u.setAttribute("class","hw-atom-tooltip__text"),u.style.display="none",u.appendChild(this._doc.createTextNode(d)),r.appendChild(u),dt(r,e,i)}_renderRdkitTooltipSvg(e){let i=this._editor.getService().options.rdkitModule;if(null==i)return null;let r=e.monomer;if(null===r)return null;let l=r.smiles;if(void 0===l||""===l)return null;let s=`${r.polymerType}:${r.symbol}`;if(this._rdkitSvgCache.has(s))return this._rdkitSvgCache.get(s)??null;let o=nt(i,l,220,140);if(this._rdkitSvgCache.size>=t._RDKIT_CACHE_LIMIT){let t=this._rdkitSvgCache.keys().next().value;void 0!==t&&this._rdkitSvgCache.delete(t)}return this._rdkitSvgCache.set(s,o),o}_hideTooltip(){ut(this._tooltip)}_showBondTooltip(t,e,i){let r=this._bondTooltip;if(null===r)return;let l=_t(t.r1),s=_t(t.r2),o=`${t.a1.symbol}@${t.a1.bio.chainId}:${t.a1.bio.positionInChain}`,n=`${t.a2.symbol}@${t.a2.bio.chainId}:${t.a2.bio.positionInChain}`;ht(this._doc,r,{symbol:`${l}-${s} (${t.kind})`,name:`${o} ↔ ${n}`}),dt(r,e,i)}_hideBondTooltip(){ut(this._bondTooltip)}_paintBondPreview(t,e,i){let r=this._svgRoot.querySelector(".hw-content");if(null===r)return;let l=r.querySelector(".hw-bond-preview");null===l&&(l=this._doc.createElementNS("http://www.w3.org/2000/svg","line"),l.setAttribute("class","hw-bond-preview"),l.setAttribute("data-testid","bond-preview"),l.setAttribute("stroke-dasharray","6 4"),l.setAttribute("stroke-width","2"),l.setAttribute("fill","none"),l.setAttribute("pointer-events","none"),r.appendChild(l)),l.setAttribute("x1",String(t.x)),l.setAttribute("y1",String(t.y)),l.setAttribute("x2",String(e.x)),l.setAttribute("y2",String(e.y)),l.setAttribute("stroke",i?"#1f5fcd":"#999999")}_clearBondPreview(){let t=this._svgRoot.querySelector(".hw-bond-preview");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}_paintSelectionRect(t,e){let i=Math.min(t.x,e.x),r=Math.min(t.y,e.y),l=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);this._paintSelectionRectAt(i,r,l,s)}_paintSelectionRectFromRect(t){this._paintSelectionRectAt(t.x,t.y,t.width,t.height)}_paintSelectionRectAt(t,e,i,r){let l=this._svgRoot.querySelector(".hw-content");if(null===l)return;let s=l.querySelector(".hw-selection-rect");null===s&&(s=this._doc.createElementNS("http://www.w3.org/2000/svg","rect"),s.setAttribute("class","hw-selection-rect"),s.setAttribute("data-testid","selection-rect"),s.setAttribute("fill","rgba(31, 95, 205, 0.08)"),s.setAttribute("stroke","#1f5fcd"),s.setAttribute("stroke-width","1"),s.setAttribute("stroke-dasharray","4 3"),s.setAttribute("pointer-events","none"),l.appendChild(s)),s.setAttribute("x",String(t)),s.setAttribute("y",String(e)),s.setAttribute("width",String(i)),s.setAttribute("height",String(r))}_clearSelectionRect(){let t=this._svgRoot.querySelector(".hw-selection-rect");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}};pt._RDKIT_CACHE_LIMIT=256;function _t(t){switch(t.kind){case"numeric":return`R${t.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair";case"positional":return`${t.position}pos:R${t.r}`}}var bt=class t{constructor(t,e){this._onClose=null,this._primaryAction=null,this._host=t,this._doc=e.documentImpl??st(t);let i=this._doc,r={class:"hw-modal-backdrop",role:"presentation"};void 0!==e.testId&&(r["data-testid"]=`dialog-${e.testId}`);let l=ot(i,"div",r),s={class:"hw-modal",role:"dialog","aria-modal":"true","aria-label":e.title};void 0!==e.testId&&(s["data-testid"]=`dialog-${e.testId}-frame`);let o=ot(i,"div",s),n=ot(i,"div",{class:"hw-modal__header"},[e.title]),a=ot(i,"div",{class:"hw-modal__body"});o.appendChild(n),o.appendChild(a),l.appendChild(o);let h=t=>{t.stopPropagation()};for(let t of["mousedown","mousemove","mouseup","mouseover","mouseenter","mouseleave","wheel","contextmenu","dblclick","keydown","keyup","keypress"])l.addEventListener(t,h);o.addEventListener("keydown",t=>{let e=t;if("Enter"!==e.key||"TEXTAREA"===e.target?.tagName)return;let i=this._primaryAction;null!==i&&(e.preventDefault?.(),e.stopImmediatePropagation?.(),i())}),l.addEventListener("click",t=>{t.target!==l?t.stopPropagation():this.close()}),this.root=l,this.body=a}static anyOpen(){return t._openStack.length>0}static closeTopmost(){let e=t._openStack[t._openStack.length-1];return void 0!==e&&(e.close(),!0)}open(e){this._onClose=e??null,null===this.root.parentNode&&this._host.appendChild(this.root),t._openStack.includes(this)||t._openStack.push(this),ct(this._doc)}close(){let e=t._openStack.indexOf(this);e>=0&&t._openStack.splice(e,1),null!==this.root.parentNode&&this.root.parentNode.removeChild(this.root);let i=this._onClose;this._onClose=null,null!==i&&i()}setPrimaryAction(t){this._primaryAction=t}get isOpen(){return null!==this.root.parentNode}};bt._openStack=[];Object.freeze(new Set);function ft(t){return t.startsWith("[")&&t.endsWith("]")||1===t.length&&/^[A-Za-z]$/.test(t)?t:`[${t}]`}function mt(t,e,i){return`${ft(t)}(${ft(e)})${ft(i)}`}var gt="http://www.w3.org/2000/svg",vt={sugar:l,base:s,linker:o},yt={sugar:["r","R"],base:["A"],linker:["p","P"]},wt={x:70,y:60},At={x:140,y:60},St={x:70,y:130},kt=class t{constructor(t,e,i){this.onValueSet=new u,this.onPickModeChange=new u,this._slots=new Map,this._favStar=null,this._pickMode=null,this._destroyed=!1,this._builderRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??st(t),this._hooks=i?.paletteHooks??null,this._favHooks=i?.favoriteHooks??null,this.element=ot(this._doc,"div",{class:"hw-rna-builder","data-testid":"rna-builder"});let r=ot(this._doc,"div",{class:"hw-rna-builder__header"});if(r.appendChild(ot(this._doc,"div",{class:"hw-rna-builder__title"},["RNA builder"])),null!==this._favHooks){let t=ot(this._doc,"span",{class:"hw-rna-builder__fav hw-rna-builder__fav--disabled",role:"button",tabindex:"0","data-testid":"rna-builder-fav-star",title:"Favorite this triplet","aria-pressed":"false","aria-disabled":"true"},["☆"]),e=t=>{t.stopPropagation();let e=this.getSelection();""===e.preview||null===this._favHooks||this._favHooks.toggleFavoriteTriplet(e.sugar,e.base,e.linker)};t.addEventListener("click",e),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&e(t)}),this._favStar=t,r.appendChild(t)}this.element.appendChild(r),this._hintEl=ot(this._doc,"div",{class:"hw-rna-builder__hint","data-testid":"rna-builder-hint",hidden:!0}),this.element.appendChild(this._hintEl);let l=this._buildSvg();this.element.appendChild(l),this._preview=ot(this._doc,"div",{class:"hw-rna-builder__preview","data-testid":"rna-builder-preview"}),this.element.appendChild(this._preview),this._addBtn=ot(this._doc,"button",{class:"hw-rna-builder__add",type:"button","data-testid":"rna-builder-add-btn"},["Add triplet"]),this._addBtn.addEventListener("click",()=>this._onAddClicked()),this.element.appendChild(this._addBtn),t.appendChild(this.element);let s=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),o=e.on("theme:change",()=>{this._destroyed||this._repaintSlotColors()});this._libUnsub=()=>{try{s()}catch{}try{o()}catch{}},this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}refresh(){this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}getSelection(){let t=this._slots.get("sugar")?.value??"",e=this._slots.get("base")?.value??"",i=this._slots.get("linker")?.value??"";return{sugar:t,base:e,linker:i,preview:""!==t&&""!==e&&""!==i?mt(t,e,i):""}}setField(t,e){let i=this._slots.get(t);void 0!==i&&(i.value=e,this._setLabelText(i.labelEl,e),this._repaintSlot(i),this._updatePreview(),this.onValueSet.next({field:t,symbol:e}))}startPickMode(t){this._pickMode!==t?(null!==this._pickMode&&this._setSlotPressed(this._pickMode,!1),this._pickMode=t,this._setSlotPressed(t,!0),this._setHintActive(t),this.onPickModeChange.next({field:t}),null!==this._hooks&&this._hooks.beginBiotypeFilter(vt[t],e=>{this.setField(t,e),this._exitPickMode()},()=>{this._exitPickMode()})):this.cancelPickMode()}cancelPickMode(){null!==this._pickMode&&(null!==this._hooks&&this._hooks.endBiotypeFilter(),this._exitPickMode())}getPickMode(){return this._pickMode}triggerAdd(){this._onAddClicked()}destroy(){this._destroyed||(this._destroyed=!0,null!==this._pickMode&&null!==this._hooks&&this._hooks.endBiotypeFilter(),this._libUnsub(),this.onValueSet.complete(),this.onPickModeChange.complete(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}_buildSvg(){let t=this._doc.createElementNS(gt,"svg");t.setAttribute("class","hw-rna-builder__triplet"),t.setAttribute("viewBox","0 0 200 180"),t.setAttribute("data-testid","rna-builder-triplet-svg"),t.setAttribute("role","group"),t.setAttribute("aria-label","Triplet preview");let e=this._doc.createElementNS(gt,"line");e.setAttribute("class","hw-rna-builder__bond"),e.setAttribute("x1",String(wt.x+18)),e.setAttribute("y1",String(wt.y)),e.setAttribute("x2",String(At.x-18)),e.setAttribute("y2",String(At.y)),t.appendChild(e);let i=this._doc.createElementNS(gt,"line");i.setAttribute("class","hw-rna-builder__bond"),i.setAttribute("x1",String(wt.x)),i.setAttribute("y1",String(wt.y+18)),i.setAttribute("x2",String(St.x)),i.setAttribute("y2",String(St.y-22)),t.appendChild(i);let r=this._doc.createElementNS(gt,"rect");r.setAttribute("class","hw-rna-builder__slot-shape"),r.setAttribute("x",String(-18)),r.setAttribute("y",String(-18)),r.setAttribute("width",String(36)),r.setAttribute("height",String(36)),r.setAttribute("rx","8"),r.setAttribute("ry","8");let l=this._buildSlot("sugar","Pick sugar (backbone)",wt,r),s=this._doc.createElementNS(gt,"circle");s.setAttribute("class","hw-rna-builder__slot-shape"),s.setAttribute("cx","0"),s.setAttribute("cy","0"),s.setAttribute("r",String(18));let o=this._buildSlot("linker","Pick linker",At,s),n=this._doc.createElementNS(gt,"path");n.setAttribute("class","hw-rna-builder__slot-shape"),n.setAttribute("d","M -22 0 L 0 -22 L 22 0 L 0 22 Z");let a=this._buildSlot("base","Pick base",St,n);return t.appendChild(o.groupEl),t.appendChild(l.groupEl),t.appendChild(a.groupEl),this._slots.set("sugar",l),this._slots.set("linker",o),this._slots.set("base",a),t}_buildSlot(t,e,i,r){let l=this._doc.createElementNS(gt,"g");l.setAttribute("class","hw-rna-builder__slot"),l.setAttribute("data-slot",t),l.setAttribute("data-testid",`rna-builder-slot-${t}`),l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.setAttribute("aria-label",e),l.setAttribute("aria-pressed","false"),l.setAttribute("transform",`translate(${i.x} ${i.y})`),l.appendChild(r);let s=this._doc.createElementNS(gt,"text");s.setAttribute("class","hw-rna-builder__slot-label"),s.setAttribute("data-testid",`rna-builder-${t}-value`),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("text-anchor","middle"),s.setAttribute("dominant-baseline","central"),l.appendChild(s);let o=e=>{e.stopPropagation(),this.startPickMode(t)};return l.addEventListener("click",o),l.addEventListener("keydown",t=>{let e=t;("Enter"===e.key||" "===e.key)&&o(t)}),l.addEventListener("mouseenter",e=>this._showSlotTooltip(t,e)),l.addEventListener("mouseleave",()=>this._hideSlotTooltip()),l.addEventListener("focus",()=>this._showSlotTooltip(t,null)),l.addEventListener("blur",()=>this._hideSlotTooltip()),{id:t,biotype:vt[t],groupEl:l,shapeEl:r,labelEl:s,value:""}}_setLabelText(t,e){let i=[];for(let e=t.firstChild;null!==e;e=e.nextSibling)"title"===e.nodeName||"TITLE"===e.nodeName||i.push(e);for(let e of i)t.removeChild(e);let r=function(t){let e=t.length;return e<=2?16:e<=4?11:e<=7?8:e<=10?6:5}(e);t.setAttribute("font-size",String(r)),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","central");let l=e.length>10?`${e.slice(0,9)}…`:e;t.appendChild(this._doc.createTextNode(l));let s=t.parentNode;if(null!==s){let t=null;for(let e=s.firstChild;null!==e;e=e.nextSibling)if("title"===e.nodeName||"TITLE"===e.nodeName){t=e;break}for(null===t&&(t=this._doc.createElementNS(gt,"title"),s.insertBefore(t,s.firstChild));null!==t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._doc.createTextNode(e))}}_repaintSlotColors(){for(let t of this._slots.values())this._repaintSlot(t)}_repaintSlot(t){let e=this._editor.getService().monomerLib,i=this._theme(),r=""===t.value?null:function(t,e,i){return t.getMonomerSet(e).get(i)??null}(e,t.biotype,t.value),l=$(r,t.biotype,i.colorTheme);t.shapeEl.style.fill=l.background,t.shapeEl.style.stroke=l.line,t.labelEl.style.fill=l.text}_populateDefaults(){let t=this._editor.getService().monomerLib;for(let[e,i]of this._slots.entries()){let r=Tt(t,i.biotype),l=Et(r,yt[e]),s=""!==i.value&&r.some(t=>t.symbol===i.value)?i.value:l??r[0]?.symbol??"";i.value=s,this._setLabelText(i.labelEl,s)}}_updatePreview(){let t=this.getSelection();for(;null!==this._preview.firstChild;)this._preview.removeChild(this._preview.firstChild);this._preview.appendChild(this._doc.createTextNode(""===t.preview?"-":t.preview)),this._updateFavStar(t)}_updateFavStar(t){if(null===this._favStar||null===this._favHooks)return;let e=""!==t.preview,i=e&&this._favHooks.isFavoriteTriplet(t.sugar,t.base,t.linker);for(;null!==this._favStar.firstChild;)this._favStar.removeChild(this._favStar.firstChild);this._favStar.appendChild(this._doc.createTextNode(i?"★":"☆")),this._favStar.setAttribute("aria-pressed",i?"true":"false"),e?this._favStar.removeAttribute("aria-disabled"):this._favStar.setAttribute("aria-disabled","true");let r="hw-rna-builder__fav"+(i?" hw-rna-builder__fav--active":"")+(e?"":" hw-rna-builder__fav--disabled");this._favStar.setAttribute("class",r)}_onAddClicked(){let t=this.getSelection();""!==t.preview&&this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)}_exitPickMode(){if(null===this._pickMode)return;let t=this._pickMode;this._setSlotPressed(t,!1),this._pickMode=null,this._setHintActive(null),this.onPickModeChange.next({field:null})}_setHintActive(t){let e=this._hintEl;for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(null===t)return void e.setAttribute("hidden","");e.removeAttribute("hidden");let i="sugar"===t?"sugar":"base"===t?"base":"linker";e.appendChild(this._doc.createTextNode(`Pick ${i} from palette`))}_setSlotPressed(t,e){let i=this._slots.get(t);if(void 0===i)return;i.groupEl.setAttribute("aria-pressed",e?"true":"false");let r=(i.groupEl.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-rna-builder__slot--active"!==t).join(" ");i.groupEl.setAttribute("class",e?`${r} hw-rna-builder__slot--active`:r)}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_builderRdkitSvgFor(e){if(null===e)return null;let i=e.smiles;if(void 0===i||""===i)return null;let r=this._rdkit();if(null===r)return null;let l=`${e.polymerType}:${e.symbol}`;if(this._builderRdkitCache.has(l))return this._builderRdkitCache.get(l)??null;let s=nt(r,i,220,140);if(this._builderRdkitCache.size>=t._BUILDER_RDKIT_CACHE_LIMIT){let t=this._builderRdkitCache.keys().next().value;void 0!==t&&this._builderRdkitCache.delete(t)}return this._builderRdkitCache.set(l,s),s}_slotHint(t){switch(t){case"sugar":return"Click to choose a different sugar";case"base":return"Click to choose a different base";case"linker":return"Click to choose a different linker"}}_slotTitle(t,e){let i=""===e?"?":e;switch(t){case"sugar":return`Sugar: ${i}`;case"base":return`Base: ${i}`;case"linker":return`Linker: ${i}`}}_showSlotTooltip(t,e){let i=this._slots.get(t);if(void 0===i)return;let r=this._editor.getService().monomerLib.getMonomerSet(i.biotype),l=""===i.value?null:r.get(i.value)??null,s=at(this._doc,"builder-tooltip","hw-builder-tooltip");ht(this._doc,s,{symbol:this._slotTitle(t,i.value),name:l?.name??"",rdkitSvg:this._builderRdkitSvgFor(l),rdkitTestid:"builder-tooltip-rdkit-svg",hint:this._slotHint(t)});let o=e;if(null!==o&&"number"==typeof o.clientX&&"number"==typeof o.clientY)dt(s,o.clientX,o.clientY);else{let t=i.groupEl,e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null;null!==e?dt(s,e.left+e.width/2,e.top+e.height/2):dt(s,0,0)}}_hideSlotTooltip(){ut(this._doc.body.querySelector('[data-testid="builder-tooltip"]'))}};kt._BUILDER_RDKIT_CACHE_LIMIT=256;var Ct=kt;function Tt(t,e){let i=t.getMonomerSet(e),r=[];for(let t of i.values())r.push(t);return r.sort((t,e)=>t.symbol.localeCompare(e.symbol)),r}function Et(t,e){let i=new Set;for(let e of t)i.add(e.symbol);for(let t of e)if(i.has(t))return t;return null}var Nt="Favorites",Mt={[Nt]:"★ Favorites",[d.PEPTIDE]:"Peptides",[d.RNA]:"RNA",[d.CHEM]:"CHEM",[d.BLOB]:"BLOB",G:"G"},xt=[Nt,d.PEPTIDE,d.RNA,d.CHEM,d.BLOB,"G"],Bt="hwe:palette:favorites",Lt="hwe:palette:active-tab";function It(t){return`${t.sugar}|${t.base}|${t.linker}`}var Pt=class t{constructor(t,e,i){this.favoritesChanged=new u,this._nextAddUnsub=()=>{},this._favorites=new Set,this._favoriteTriplets=[],this._pendingRnaSelection=null,this._visibleTabs=[Nt],this._activeTab=Nt,this._searchInput=null,this._filter="",this._destroyed=!1,this._rnaBuilder=null,this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,this._pickEscapeListener=null,this._pickOutsideClickListener=null,this._paletteRdkitCache=new Map,this._editor=e,this._doc=i?.documentImpl??st(t),this._opts={documentImpl:this._doc,groupByNaturalAnalog:i?.groupByNaturalAnalog??!0,allowFavorites:i?.allowFavorites??!0},this._loadFavorites(),this._activeTab=this._resolveInitialTab(i?.initialTab),this.element=ot(this._doc,"div",{class:"hw-palette","data-testid":"palette"}),t.appendChild(this.element),this._render(),this._libUnsub=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),this._themeUnsub=e.on("theme:change",()=>{this._destroyed||this.refresh()}),this._nextAddUnsub=e.on("option:change",t=>{this._destroyed||"nextAdd"===t.key&&this._updatePrimedClasses()})}refresh(){this._render()}setFilter(t){this._filter=t.trim().toLowerCase(),null!==this._searchInput&&this._searchInput.value!==t&&(this._searchInput.value=t),this._applyFilter()}setActiveTab(t){this._visibleTabs.includes(t)&&(this._activeTab=t,this._persistActiveTab(),this._applyActiveTabClasses(),this._applyFilter())}getActiveTab(){return this._activeTab}getFavorites(){let t=this._editor.getService().monomerLib,e=[];for(let i of this._favorites)null!==this._findMonomer(t,i)&&e.push(i);return e}setFavorite(t,e){e!==this._favorites.has(t)&&(e?this._favorites.add(t):this._favorites.delete(t),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}clearFavorites(){0===this._favorites.size&&0===this._favoriteTriplets.length||(this._favorites.clear(),this._favoriteTriplets.length=0,this._saveFavorites(),this._render(),this._emitFavoritesChanged())}getFavoriteTriplets(){return this._favoriteTriplets.map(t=>({...t}))}isFavoriteTriplet(t,e,i){let r=It({sugar:t,base:e,linker:i});return this._favoriteTriplets.some(t=>It(t)===r)}setFavoriteTriplet(t,e,i,r){let l=It({sugar:t,base:e,linker:i}),s=this._favoriteTriplets.findIndex(t=>It(t)===l);r!==s>=0&&(r?this._favoriteTriplets.push({sugar:t,base:e,linker:i}):this._favoriteTriplets.splice(s,1),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}_hidePaletteTooltips(){let t=this._doc.body;ut(t.querySelector('[data-testid="palette-tooltip"]')),ut(t.querySelector('[data-testid="palette-triplet-tooltip"]'))}_emitFavoritesChanged(){this.favoritesChanged.next({favorites:this.getFavorites(),triplets:this.getFavoriteTriplets()})}destroy(){this._destroyed||(this._destroyed=!0,null!==this._rnaBuilder&&(this._rnaBuilder.destroy(),this._rnaBuilder=null),this._libUnsub(),this._themeUnsub(),this._nextAddUnsub(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}getRnaBuilder(){return this._rnaBuilder}hasActiveBiotypeFilter(){return null!==this._activeBiotypeFilter}getActiveBiotypeFilter(){return this._activeBiotypeFilter}cancelBiotypeFilter(){if(null===this._activeBiotypeFilter)return;let t=this._pickCanceller;this._teardownPickMode(),t?.()}_buildPaletteFilterHooks(){return{beginBiotypeFilter:(t,e,i)=>{null!==this._activeBiotypeFilter&&this._teardownPickMode(),this._activeBiotypeFilter=t,this._pickResolver=e,this._pickCanceller=i,this._applyFilter();let r=t=>{"Escape"===t.key&&this.cancelBiotypeFilter()};this._pickEscapeListener=r,this._doc.defaultView?.addEventListener("keydown",r);let l=t=>{if(null===this._activeBiotypeFilter)return;let e=t.target;if(null==e)return;let i=this._activeBiotypeFilter,r=e;for(;null!==r;){let t=void 0===r.getAttribute?null:r.getAttribute("class");if(null!==t){let e=t.split(/\s+/);if(e.includes("hw-palette__tile")){if((r.getAttribute("data-biotype")??"")===i)return;break}if(e.includes("hw-rna-builder__slot")){if(this._isInsideOwnPalette(r))return;break}}r=r.parentElement}this.cancelBiotypeFilter()};this._pickOutsideClickListener=l,this._doc.addEventListener("mousedown",l,!0)},endBiotypeFilter:()=>this._teardownPickMode()}}_scrollActivePaneToTop(){let t=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`);if(null===t)return;let e=t;try{if("function"==typeof e.scrollTo)return void e.scrollTo({top:0,behavior:"smooth"})}catch{}"number"==typeof e.scrollTop&&(e.scrollTop=0)}_isInsideOwnPalette(t){let e=t;for(;null!==e;){if(e===this.element)return!0;e=e.parentElement}return!1}_teardownPickMode(){null!==this._activeBiotypeFilter&&(this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,null!==this._pickEscapeListener&&(this._doc.defaultView?.removeEventListener("keydown",this._pickEscapeListener),this._pickEscapeListener=null),null!==this._pickOutsideClickListener&&(this._doc.removeEventListener("mousedown",this._pickOutsideClickListener,!0),this._pickOutsideClickListener=null),this._applyFilter())}_render(){for(null!==this._rnaBuilder&&(this._pendingRnaSelection=this._rnaBuilder.getSelection(),this._rnaBuilder.destroy(),this._rnaBuilder=null);null!==this.element.firstChild;)this.element.removeChild(this.element.firstChild);let t=this._doc.createElement("input");t.setAttribute("type","search"),t.setAttribute("class","hw-palette__search"),t.setAttribute("placeholder","Search monomers..."),t.setAttribute("data-testid","palette-search"),""!==this._filter&&(t.value=this._filter),t.addEventListener("input",()=>this.setFilter(t.value)),this._searchInput=t,this.element.appendChild(t),this._visibleTabs=this._computeVisibleTabs(),this._visibleTabs.includes(this._activeTab)||(this._activeTab=Nt);let e=ot(this._doc,"div",{class:"hw-palette__tabs",role:"tablist","data-testid":"palette-tabs"});for(let t of this._visibleTabs){let i=t===this._activeTab,r=ot(this._doc,"button",{class:"hw-palette__tab",type:"button",role:"tab","aria-controls":`hw-palette-pane-${t}`,"aria-selected":i?"true":"false","data-testid":`palette-tab-${t}`,"data-tab":t,title:Mt[t]},[Mt[t]]);r.addEventListener("click",()=>this.setActiveTab(t)),e.appendChild(r)}this.element.appendChild(e);let i=ot(this._doc,"div",{class:"hw-palette__panes"}),r=this._theme(),l=this._editor.getService().monomerLib;for(let t of this._visibleTabs){let e=t===this._activeTab,s=ot(this._doc,"div",{class:"hw-palette__pane",id:`hw-palette-pane-${t}`,role:"tabpanel","data-testid":`palette-pane-${t}`,"data-tab":t,hidden:!e});t===Nt?this._buildFavoritesPane(s,l,r):this._buildPolymerPane(s,t,l,r),i.appendChild(s)}this.element.appendChild(i),this._applyFilter()}_computeVisibleTabs(){let t=this._editor.getService().monomerLib,e=new Set;for(let i of t.getPolymerTypes())e.add(i);let i=[];i.push(Nt);for(let t of xt)t!==Nt&&e.has(t)&&i.push(t);return i}_buildFavoritesPane(t,e,i){let r=this._resolveFavoriteMonomers(e),l=this._favoriteTriplets;if(0===r.length&&0===l.length){let e=ot(this._doc,"div",{class:"hw-palette__placeholder","data-testid":"palette-favorites-empty"},["No favorites yet — click the ☆ on any tile to add one."]);return void t.appendChild(e)}for(let[e,i]of this._groupByPolymerAndType(r))t.appendChild(this._renderGroup(e,i));l.length>0&&t.appendChild(this._renderTripletGroup("RNA · Triplets",l,e))}_groupByPolymerAndType(t){let e=new Map;for(let i of t){let t=i.polymerType,r=i.monomerType??"Undefined",l=`${t}|${r}`,s=e.get(l);void 0===s&&(s={pt:t,mt:r,list:[]},e.set(l,s)),s.list.push(i)}let i=t=>{let e=xt.indexOf(t);return e<0?99:e},r={Backbone:0,Branch:1,Terminal:2,Undefined:3};return Array.from(e.values()).sort((t,e)=>i(t.pt)-i(e.pt)||(r[t.mt]??9)-(r[e.mt]??9)||t.mt.localeCompare(e.mt)).map(t=>[`${this._polymerLabel(t.pt)} · ${t.mt}`,t.list])}_polymerLabel(t){return Mt[t]??t}_renderTripletGroup(t,e,i){let r=ot(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),l=ot(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),s=ot(this._doc,"div",{class:"hw-triplet-chips","data-testid":"palette-triplet-favorites"});for(let t of e)s.appendChild(this._renderTripletChip(t,i));return r.appendChild(l),r.appendChild(s),r}_renderTripletChip(t,e){let i=mt(t.sugar,t.base,t.linker),r=e.getMonomerSet(s).get(t.base)??null,l=$(r,s,this._theme().colorTheme),o=this.isFavoriteTriplet(t.sugar,t.base,t.linker),n=void 0!==r?.name&&""!==r.name?`${i} — ${r.name}`:i,{root:a}=function(t,e){let i=!1!==e.showStar,r=ot(t,"span",{class:"hw-triplet-chip__star"},[e.favorite?"★":"☆"]),l=ot(t,"span",{class:"hw-triplet-chip__label"},[e.label]),s=["hw-triplet-chip"];e.favorite&&s.push("hw-triplet-chip--favorite");let o=i?[r,l]:[l];return{root:ot(t,"div",{class:s.join(" "),role:"button",tabindex:"0","aria-label":e.title,"data-sugar":e.sugar,"data-base":e.base,"data-linker":e.linker,"data-triplet":e.label,"data-testid":`palette-triplet-${e.label}`,title:e.title,style:`background:${e.background};color:${e.textColor};`},o),star:r}}(this._doc,{sugar:t.sugar,base:t.base,linker:t.linker,label:i,title:n,background:y(l.background),textColor:l.text,favorite:o,showStar:this._opts.allowFavorites});return this._wireTripletChip(a,t),a}_wireTripletChip(t,e){t.addEventListener("mouseenter",t=>{let i=t,r=at(this._doc,"palette-triplet-tooltip","hw-palette-tooltip hw-triplet-tooltip");(function(t,e,i){for(;null!==e.firstChild;)e.removeChild(e.firstChild);e.appendChild(ot(t,"div",{class:"hw-tooltip__symbol"},[i.title]));let r=ot(t,"div",{class:"hw-tooltip__triplet"});for(let e of i.parts){let l=ot(t,"div",{class:"hw-tooltip__triplet-part"});if(l.appendChild(ot(t,"div",{class:"hw-tooltip__triplet-role"},[`${e.role}: ${e.symbol}`])),void 0!==e.name&&""!==e.name&&e.name!==e.symbol&&l.appendChild(ot(t,"div",{class:"hw-tooltip__name"},[e.name])),void 0!==e.rdkitSvg&&null!==e.rdkitSvg&&""!==e.rdkitSvg){let r={class:"hw-tooltip__rdkit"};void 0!==i.rdkitTestid&&(r["data-testid"]=i.rdkitTestid);let s=ot(t,"div",r);s.innerHTML=e.rdkitSvg,l.appendChild(s)}r.appendChild(l)}e.appendChild(r),void 0!==i.hint&&""!==i.hint&&e.appendChild(ot(t,"div",{class:"hw-tooltip__hint"},[i.hint]))})(this._doc,r,{title:mt(e.sugar,e.base,e.linker),parts:this._tripletTooltipParts(e),hint:"Click to add this triplet",rdkitTestid:"palette-triplet-tooltip-rdkit-svg"}),dt(r,"number"==typeof i.clientX?i.clientX:0,"number"==typeof i.clientY?i.clientY:0)}),t.addEventListener("mouseleave",()=>{ut(this._doc.body.querySelector('[data-testid="palette-triplet-tooltip"]'))}),t.addEventListener("click",t=>{let i=t.target;if(this._opts.allowFavorites&&!0===i?.classList?.contains("hw-triplet-chip__star"))return this.setFavoriteTriplet(e.sugar,e.base,e.linker,!this.isFavoriteTriplet(e.sugar,e.base,e.linker)),void t.stopPropagation();this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)}),t.addEventListener("keydown",t=>{let i=t;("Enter"===i.key||" "===i.key)&&this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)})}_buildRnaDefaultChips(e){let i=this._pickSymbol(e.getMonomerSet(l),["r","R"]),r=this._pickSymbol(e.getMonomerSet(o),["p","P"]),n=e.getMonomerSet(s);if(null===i||null===r)return null;let a=t._DEFAULT_TRIPLET_BASES.filter(t=>n.has(t));if(0===a.length)return null;let h=ot(this._doc,"div",{class:"hw-triplet-chips hw-triplet-chips--defaults","data-testid":"rna-default-triplets"});for(let t of a)h.appendChild(this._renderTripletChip({sugar:i,base:t,linker:r},e));return h}_tripletTooltipParts(t){let e=this._editor.getService().monomerLib,i=(t,i,r)=>{let l=e.getMonomerSet(i).get(r)??null;return{role:t,symbol:r,...void 0!==l?.name?{name:l.name}:{},rdkitSvg:null===l?null:this._paletteRdkitSvg(l)}};return[i("Sugar",l,t.sugar),i("Base",s,t.base),i("Linker",o,t.linker)]}_pickSymbol(t,e){for(let i of e)if(t.has(i))return i;let i=t.keys().next();return!0===i.done?null:i.value}_restoreRnaSelection(){let t=this._pendingRnaSelection;if(this._pendingRnaSelection=null,null===t||null===this._rnaBuilder)return;let e=this._editor.getService().monomerLib;""!==t.sugar&&e.getMonomerSet(l).has(t.sugar)&&this._rnaBuilder.setField("sugar",t.sugar),""!==t.base&&e.getMonomerSet(s).has(t.base)&&this._rnaBuilder.setField("base",t.base),""!==t.linker&&e.getMonomerSet(o).has(t.linker)&&this._rnaBuilder.setField("linker",t.linker)}_resolveFavoriteMonomers(t){let e=[];for(let i of this._favorites){let r=this._findMonomer(t,i);null!==r&&e.push(r)}return e}_findMonomer(t,e){for(let i of t.getPolymerTypes()){let r=t.getMonomer(i,e);if(null!==r)return r}return null}_buildPolymerPane(t,e,i,r){let l=e,s=this._monomersForPolymer(l,i);if(0===s.length)return;if(l===d.RNA){this._rnaBuilder=new Ct(t,this._editor,{documentImpl:this._doc,paletteHooks:this._buildPaletteFilterHooks(),favoriteHooks:this._opts.allowFavorites?{isFavoriteTriplet:(t,e,i)=>this.isFavoriteTriplet(t,e,i),toggleFavoriteTriplet:(t,e,i)=>this.setFavoriteTriplet(t,e,i,!this.isFavoriteTriplet(t,e,i))}:null}),this._restoreRnaSelection();let e=this._buildRnaDefaultChips(i);null!==e&&t.appendChild(e);let r=this._groupRna(s);for(let[e,i]of r)0!==i.length&&t.appendChild(this._renderGroup(e,i));return}if(l===d.PEPTIDE&&this._opts.groupByNaturalAnalog){let e=this._groupByAnalog(s);for(let[i,r]of e){let e=""===i?"Other":i;t.appendChild(this._renderGroup(e,r))}return}let o=ot(this._doc,"div",{class:"hw-palette__group-tiles"}),n=this._editor.getNextAddSymbol(),a=this._sortByColor(s);for(let t of a){let e=this._biotype(t,l);o.appendChild(this._renderTile(t,e,n))}t.appendChild(o)}_renderGroup(t,e){let i=ot(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),r=ot(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),l=ot(this._doc,"div",{class:"hw-palette__group-tiles"}),s=this._editor.getNextAddSymbol(),o=this._sortByColor(e);for(let t of o){let e=this._biotype(t,t.polymerType);l.appendChild(this._renderTile(t,e,s))}return i.appendChild(r),i.appendChild(l),i}_sortByColor(t){let e=this._theme(),i=t.map((t,i)=>{let r=function(t){let e=_(t);if(null===e)return{h:0,s:0,l:0};let[i,r,l]=m(e[0],e[1],e[2]);return{h:i,s:r,l}}($(t,this._biotype(t,t.polymerType),e.colorTheme).background),l=0===r.s?1:0;return{m:t,idx:i,h:r.h,s:r.s,l:r.l,isGrey:l}});return i.sort((t,e)=>t.isGrey!==e.isGrey?t.isGrey-e.isGrey:t.h!==e.h?t.h-e.h:t.s!==e.s?t.s-e.s:t.l!==e.l?t.l-e.l:t.idx-e.idx),i.map(t=>t.m)}_monomersForPolymer(t,e){let i=e.getMonomerSymbolsByType(t),r=[];for(let l of i){let i=e.getMonomer(t,l);null!==i&&r.push(i)}return r.sort((t,e)=>t.symbol.localeCompare(e.symbol)),r}_groupByAnalog(t){let e=new Map;for(let i of t){let t=i.naturalAnalog??"",r=e.get(t);void 0===r&&(r=[],e.set(t,r)),r.push(i)}let i=[],r=Array.from(e.keys()).sort((t,e)=>""===t&&""!==e?1:""===e&&""!==t?-1:t.localeCompare(e));for(let t of r)i.push([t,e.get(t)]);return new Map(i)}_groupRna(t){let e=[],i=[],r=[],n=[];for(let a of t){let t=F(a);t===l?e.push(a):t===s?i.push(a):t===o?r.push(a):n.push(a)}let a=new Map;return a.set("Backbones",e),a.set("Bases",i),a.set("Linkers",r),n.length>0&&a.set("Other",n),a}_renderTile(t,e,i){let r=this._favorites.has(t.symbol),l=null!==i&&i.symbol===t.symbol&&i.biotype===e,{root:s,star:o}=function(t,e){let i=$(e.monomer,e.biotype,e.theme.colorTheme),r=y(i.background),l=i.text,s=function(t,e){let i=w(t),r=w(e);return(Math.max(i,r)+.05)/(Math.min(i,r)+.05)}(l,r)<5,o=e.monomer.symbol,n=function(t){return t<=3?14:t<=6?11:t<=9?9:8}(o.length),a=`font-size:${n}px;${o.length>=10?"line-height:1.1;letter-spacing:-0.02em;":""}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80px;display:inline-block;`,h=ot(t,"span",{class:"hw-palette__star"},[e.favorite?"★":"☆"]),d=ot(t,"span",{class:"hw-palette__label",style:a},[o]),u=["hw-palette__tile"];e.primed&&u.push("hw-palette__tile--primed"),e.favorite&&u.push("hw-palette__tile--favorite"),s&&u.push("hw-palette__tile--low-contrast");let c=void 0!==e.monomer.name?`${o} — ${e.monomer.name}`:o,p=`background:${r};color:${l};width:100%;min-width:48px;padding:4px 6px;height:40px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;`;return{root:ot(t,"div",{class:u.join(" "),draggable:"true",role:"button","aria-pressed":e.primed?"true":"false","aria-label":c,"data-symbol":o,"data-biotype":e.biotype,"data-bg":r,"data-raw-bg":i.background,"data-testid":`palette-tile-${o}`,title:c,style:p},[h,d]),star:h}}(this._doc,{monomer:t,biotype:e,theme:this._theme(),favorite:r,primed:l});return this._wireTile(s,o,t,e),s}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_paletteRdkitSvg(e){let i=e.smiles;if(void 0===i||""===i)return null;let r=this._rdkit();if(null===r)return null;let l=`${e.polymerType}:${e.symbol}`;if(this._paletteRdkitCache.has(l))return this._paletteRdkitCache.get(l)??null;let s=nt(r,i,220,140);if(this._paletteRdkitCache.size>=t._PALETTE_RDKIT_CACHE_LIMIT){let t=this._paletteRdkitCache.keys().next().value;void 0!==t&&this._paletteRdkitCache.delete(t)}return this._paletteRdkitCache.set(l,s),s}_wireTile(t,e,i,r){t.addEventListener("mouseenter",t=>{let e=t,r=at(this._doc,"palette-tooltip","hw-palette-tooltip");ht(this._doc,r,{symbol:i.symbol,name:i.name??"",rdkitSvg:this._paletteRdkitSvg(i),rdkitTestid:"palette-tooltip-rdkit-svg"}),dt(r,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),t.addEventListener("mouseleave",()=>{ut(this._doc.body.querySelector('[data-testid="palette-tooltip"]'))}),t.addEventListener("click",t=>{let e=t.target;if(this._opts.allowFavorites&&void 0!==e&&!0===e?.classList?.contains("hw-palette__star"))return this.setFavorite(i.symbol,!this._favorites.has(i.symbol)),void t.stopPropagation();if(null!==this._activeBiotypeFilter&&this._activeBiotypeFilter===r){let e=this._pickResolver;return this._teardownPickMode(),e?.(i.symbol),this._scrollActivePaneToTop(),void t.stopPropagation()}let l=this._editor.getSelection();if(l.atoms.size>0){let e=this._editor.getMol(),s=[];for(let t of l.atoms){let i=e.atoms.find(e=>e.id===t);void 0!==i&&s.push(i)}return s.length>0&&s.every(t=>t.biotype===r)?(this._editor.replaceMonomers(s,i.symbol),void t.stopPropagation()):(this._editor.fire("editor:status",{message:`Cannot bulk-replace ${s.length} selected atom(s) with ${i.symbol}: selection contains incompatible biotypes for ${r}.`,severity:"warn",durationMs:3e3}),void t.stopPropagation())}let s=this._editor.getNextAddSymbol();if(null!==s&&s.symbol===i.symbol&&s.biotype===r)return this._editor.setNextAddSymbol(null),void this._updatePrimedClasses();this._editor.setNextAddSymbol(i.symbol,r),this._updatePrimedClasses()}),t.addEventListener("dragstart",t=>{let e=t.dataTransfer;if(null!=e)try{e.setData("application/x-hwe-monomer",JSON.stringify({symbol:i.symbol,biotype:r})),e.effectAllowed="copy"}catch{}ut(this._doc.body.querySelector('[data-testid="palette-tooltip"]')),this._editor.startPaletteDrag(i.symbol,r)})}_biotype(t,e){let i=F(t);if(null!==i)return i;switch(e){case d.PEPTIDE:return r;case d.RNA:return l;case d.CHEM:return n;case d.BLOB:return a;default:return n}}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyFilter(){let t=this._filter,e=this._activeBiotypeFilter,i=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`),r=(i??this.element).querySelectorAll(".hw-palette__tile");for(let i=0;i<r.length;i++){let l=r[i],s=(l.getAttribute("data-symbol")??"").toLowerCase(),o=(l.getAttribute("title")??"").toLowerCase(),n=l.getAttribute("data-biotype")??"",a=(""===t||s.indexOf(t)>=0||o.indexOf(t)>=0)&&(null===e||n===e);l.style.display=a?"":"none"}let l=(i??this.element).querySelectorAll(".hw-triplet-chip");for(let i=0;i<l.length;i++){let r=l[i],s=[r.getAttribute("data-triplet")??"",r.getAttribute("data-sugar")??"",r.getAttribute("data-base")??"",r.getAttribute("data-linker")??""].join(" ").toLowerCase(),o=(""===t||s.indexOf(t)>=0)&&null===e;r.style.display=o?"":"none"}let s=(i??this.element).querySelectorAll(".hw-palette__group");for(let t=0;t<s.length;t++){let e=s[t],i=e.querySelectorAll(".hw-palette__tile, .hw-triplet-chip"),r=!1;for(let t=0;t<i.length;t++)if("none"!==i[t].style.display){r=!0;break}r?(e.removeAttribute("hidden"),e.removeAttribute("data-section-empty")):(e.setAttribute("hidden",""),e.setAttribute("data-section-empty","true"))}}_updatePrimedClasses(){let t=this._editor.getNextAddSymbol(),e=this.element.querySelectorAll(".hw-palette__tile");for(let i=0;i<e.length;i++){let r=e[i],l=r.getAttribute("data-symbol")??"",s=r.getAttribute("data-biotype")??"",o=null!==t&&t.symbol===l&&t.biotype===s,n=(r.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-palette__tile--primed"!==t).join(" ");r.setAttribute("class",o?`${n} hw-palette__tile--primed`:n),r.setAttribute("aria-pressed",o?"true":"false")}}_applyActiveTabClasses(){let t=this.element.querySelectorAll(".hw-palette__tab");for(let e=0;e<t.length;e++){let i=t[e],r=i.getAttribute("data-tab")??"";i.setAttribute("aria-selected",r===this._activeTab?"true":"false")}let e=this.element.querySelectorAll(".hw-palette__pane");for(let t=0;t<e.length;t++){let i=e[t];(i.getAttribute("data-tab")??"")===this._activeTab?i.removeAttribute("hidden"):i.setAttribute("hidden","")}}_localStorage(){if(!this._opts.allowFavorites)return null;let t=this._doc.defaultView;if(null==t)return null;try{return t.localStorage??null}catch{return null}}_resolveInitialTab(t){if(void 0!==t&&xt.includes(t))return t;let e=this._localStorage();if(null!==e)try{let t=e.getItem(Lt);if(null!==t&&xt.includes(t))return t}catch{}return Nt}_persistActiveTab(){let t=this._localStorage();if(null!==t)try{t.setItem(Lt,this._activeTab)}catch{}}_loadFavorites(){let t=this._localStorage();if(null!==t){try{let e=t.getItem(Bt);if(null!==e&&""!==e){let t=JSON.parse(e),i=this._extractSymbols(t);for(let t of i)this._favorites.add(t);for(let e of this._extractTriplets(t))this._favoriteTriplets.push(e);return}}catch{}try{let e=t.getItem("hwe.palette.favorites");if(null===e||""===e)return;let i=JSON.parse(e);if(Array.isArray(i)){for(let t of i){if("string"!=typeof t)continue;let e=t.indexOf("|"),i=e>=0?t.slice(e+1):t;""!==i&&this._favorites.add(i)}this._saveFavorites()}}catch{}}}_extractSymbols(t){if(Array.isArray(t)){let e=[];for(let i of t)"string"==typeof i&&e.push(i);return e}if(null!==t&&"object"==typeof t){let e=t;if(Array.isArray(e.symbols)){let t=[];for(let i of e.symbols)"string"==typeof i&&t.push(i);return t}}return[]}_extractTriplets(t){if(null===t||"object"!=typeof t)return[];let e=t;if(!Array.isArray(e.triplets))return[];let i=[];for(let t of e.triplets){if(null===t||"object"!=typeof t)continue;let e=t;"string"==typeof e.sugar&&"string"==typeof e.base&&"string"==typeof e.linker&&i.push({sugar:e.sugar,base:e.base,linker:e.linker})}return i}_saveFavorites(){let t=this._localStorage();if(null!==t)try{let e={symbols:Array.from(this._favorites)};this._favoriteTriplets.length>0&&(e.triplets=this._favoriteTriplets.map(t=>({...t}))),t.setItem(Bt,JSON.stringify(e))}catch{}}};Pt._DEFAULT_TRIPLET_BASES=["A","C","G","U","T"],Pt._PALETTE_RDKIT_CACHE_LIMIT=256;new Set([d.PEPTIDE,d.RNA,d.CHEM,d.BLOB]),new Set(["Backbone","Branch","Terminal","Undefined"]);var $t,Ft;!function(t){t[t.default=0]="default",t[t.continuous=1]="continuous"}($t||($t={})),function(t){t.Sequence="sequence",t.Helm="notation",t.Properties="properties",t.StructureView="structureview"}(Ft||(Ft={}));const Rt={V2K_RGP_SHIFT:8,V2K_RGP_LINE:"M RGP",V2K_A_LINE:"A ",V3K_COUNTS_SHIFT:14,V3K_IDX_SHIFT:7,V3K_HEADER_FIRST_LINE:"\nDatagrok macromolecule handler\n\n",V3K_HEADER_SECOND_LINE:" 0 0 0 0 0 0 999 V3000\n",V3K_BEGIN_CTAB_BLOCK:"M V30 BEGIN CTAB\n",V3K_END_CTAB_BLOCK:"M V30 END CTAB\n",V3K_BEGIN_COUNTS_LINE:"M V30 COUNTS ",V3K_COUNTS_LINE_ENDING:" 0 0 0\n",V3K_BEGIN_ATOM_BLOCK:"M V30 BEGIN ATOM\n",V3K_END_ATOM_BLOCK:"M V30 END ATOM\n",V3K_BEGIN_BOND_BLOCK:"M V30 BEGIN BOND\n",V3K_END_BOND_BLOCK:"M V30 END BOND\n",V3K_BOND_CONFIG:" CFG=",V3K_BEGIN_DATA_LINE:"M V30 ",V3K_END:"M END",PRECISION_FACTOR:1e4,DEOXYRIBOSE:{polymerType:d.RNA,symbol:"d"},RIBOSE:{polymerType:d.RNA,symbol:"r"},PHOSPHATE:{polymerType:d.RNA,symbol:"p"},OXYGEN:"O",HYDROGEN:"H"};function Ot(t,e){return t[e.polymerType]?.[e.symbol]}var Dt;!function(t){t[t.SUGAR=0]="SUGAR",t[t.BASE=1]="BASE",t[t.PHOSPHATE=2]="PHOSPHATE",t[t.TERMINAL_5P=3]="TERMINAL_5P",t[t.TERMINAL_3P=4]="TERMINAL_3P"}(Dt||(Dt={}));class Ht extends Map{constructor(t){super(t)}}class Vt{constructor(t,e){this.molfile=t,this.monomers=e}static createEmpty(){return new Vt("",new Ht(null))}}const Gt=d;var Kt,zt,Ut;new RegExp("[rd]\\((\\w)\\)p?","g");class qt{constructor(t,e,i){this.name=t,this.alphabet=e,this.cutoff=i}}!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(Kt||(Kt={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(zt||(zt={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(Ut||(Ut={}));const jt=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}};function Wt(t){let e;switch(t){case s:case l:case o:case h:case"nucleotide":e=d.RNA;break;case r:e=d.PEPTIDE;break;case n:e=d.CHEM;break;case a:e=d.BLOB;break;default:e=d.PEPTIDE,console.warn(`Unexpected HelmType '${t}'`)}return e}function Yt(t,e,i,r,l){if(0===t.length)return Vt.createEmpty();const s=r===Gt.RNA&&!!l&&l.length===t.length,{atomCount:o,bondCount:n,needsCapping:a}=function(t,e,i,r,l,s){let o=0,n=0,a=0,h=!0,d=null,u=null;for(let i=0;i<t.length;++i){const r=t[i];if(""!==r.symbol){if("*"==r.symbol)throw new Error("Gap canonical symbol is '', not '*");d=Ot(e,{symbol:r.symbol,polymerType:Wt(r.biotype)}),o+=d.atoms.x.length,n+=d.bonds.bondTypes.length,a++,l&&i%3==2&&(u=d)}}if(r===Gt.PEPTIDE)o+=1,n+=a,a>0&&((d?.meta?.rNodes?.length??0)<2||d?.terminalR2Atom?.toLowerCase()===Rt.HYDROGEN.toLowerCase())&&(h=!1,o-=1,n-=1);else if(l)n+=a,s&&s.length>0&&s[s.length-1]===Dt.TERMINAL_3P?(h=!1,n-=1):o+=1;else{const r=i===zt.DNA?Ot(e,Rt.DEOXYRIBOSE):Ot(e,Rt.RIBOSE),l=Ot(e,Rt.PHOSPHATE);o+=(t.length-1)*l.atoms.x.length,o+=t.length*r.atoms.x.length,o+=1,n+=(t.length-1)*l.bonds.bondTypes.length,n+=t.length*r.bonds.bondTypes.length,n-=1,n+=3*t.length}return{atomCount:o,bondCount:n,needsCapping:h}}(t,e,i,r,s,l),h=new Array(o),d=new Array(n);let u,c=null,p=null;r===Gt.PEPTIDE?u=Xt:(u=Jt,s||(c=i===zt.DNA?Ot(e,Rt.DEOXYRIBOSE):Ot(e,Rt.RIBOSE),p=Ot(e,Rt.PHOSPHATE)));const _={i:0,nodeShift:0,bondShift:0,backbonePositionShift:new Array(2).fill(0),branchPositionShift:new Array(2).fill(0),backboneAttachNode:0,branchAttachNode:0,flipFactor:1},b={sugar:c,phosphate:p,seqLength:s?Math.ceil(t.length/3):t.length,atomCount:o,bondCount:n},f=new Ht,m=[];let g,v=0;if(s)!function(t,e,i,r,l,s,o,n,a,h){for(let o=0;o<t.length;++o){const d=t[o];if(""===d.symbol)continue;const u=e[o],c=Ot(i,{symbol:d.symbol,polymerType:Wt(d.biotype)}),p=s.nodeShift,_=s.bondShift;s.i=o,u===Dt.BASE?Qt(c,r,l,s):Zt(c,r,l,s),c.stereoAtoms?.forEach(t=>a.push(t+v)),h(c.atoms.x.length);const b=[];for(let t=p;t<s.nodeShift;++t)b.push(t);const f=[];for(let t=_;t<s.bondShift;++t)f.push(t);n.set(o,{biotype:d.biotype,symbol:d.symbol,atoms:b,bonds:f})}}(t,l,e,h,d,_,0,f,m,t=>{v+=t});else for(_.i=0;_.i<b.seqLength;++_.i){const i=t[_.i];if(""===i.symbol)continue;const r=Ot(e,{symbol:i.symbol,polymerType:Wt(i.biotype)});g=r.terminalR2Atom;const l=_.nodeShift,s=_.bondShift;u(r,h,d,_,b),r.stereoAtoms?.forEach(t=>m.push(t+v)),v+=r.atoms.x.length;const o=_.nodeShift-l,n=new Array(o);for(let t=0;t<o;++t)n[t]=l+t;const a=_.bondShift-s,c=new Array(a);for(let t=0;t<a;++t)c[t]=s+t;f.set(_.i,{biotype:i.biotype,symbol:i.symbol,atoms:n,bonds:c})}a&&function(t,e,i,r,l=Rt.OXYGEN){const s=i.nodeShift+1;t[r.atomCount]=Rt.V3K_BEGIN_DATA_LINE+s+" "+(l??Rt.OXYGEN)+" "+ee(i.backbonePositionShift[0])+" "+i.flipFactor*ee(i.backbonePositionShift[1])+" 0.000000 0\n";const o=i.backboneAttachNode,n=s;e[r.bondCount]=Rt.V3K_BEGIN_DATA_LINE+i.bondShift+" 1 "+o+" "+n+"\n"}(h,d,_,b,g??Rt.OXYGEN);const y=Rt.V3K_BEGIN_COUNTS_LINE+o+" "+n+Rt.V3K_COUNTS_LINE_ENDING;let w="";return w+=Rt.V3K_HEADER_FIRST_LINE,w+=Rt.V3K_HEADER_SECOND_LINE,w+=Rt.V3K_BEGIN_CTAB_BLOCK,w+=y,w+=Rt.V3K_BEGIN_ATOM_BLOCK,w+=h.join(""),w+=Rt.V3K_END_ATOM_BLOCK,w+=Rt.V3K_BEGIN_BOND_BLOCK,w+=d.join(""),w+=Rt.V3K_END_BOND_BLOCK,m.length>0&&(w+=function(t){const e=[];let i=`M V30 MDLV30/STEABS ATOMS=(${t.length}`;for(let r=0;r<t.length;r++){const l=`${i} ${t[r]}`;l.length>76?(e.push(`${i} -\n`),i=`M V30 ${t[r]}`):i=l,r===t.length-1&&e.push(`${i})\n`)}return`M V30 BEGIN COLLECTION\n${e.join("")}M V30 END COLLECTION\n`}(m)),w+=Rt.V3K_END_CTAB_BLOCK,w+=Rt.V3K_END,{molfile:w,monomers:f}}function Xt(t,e,i,r){r.flipFactor=(-1)**(r.i%2),Zt(t,e,i,r)}function Zt(t,e,i,r){!function(t,e,i){for(let r=0;r<t.atoms.atomTypes.length;++r){const l=i.nodeShift+r+1;e[i.nodeShift+r]=Rt.V3K_BEGIN_DATA_LINE+l+" "+t.atoms.atomTypes[r]+" "+ee(i.backbonePositionShift[0]+t.atoms.x[r])+" "+ee(i.backbonePositionShift[1]+i.flipFactor*t.atoms.y[r])+" "+t.atoms.kwargs[r]}}(t,e,r),te(t,i,r),function(t,e,i){if(0!==i.backboneAttachNode){const r=i.bondShift,l=i.backboneAttachNode,s=t.meta.terminalNodes[0]+i.nodeShift;e[i.bondShift-1]=Rt.V3K_BEGIN_DATA_LINE+r+" 1 "+l+" "+s+"\n"}}(t,i,r),null!==t.meta.branchShift&&t.meta.terminalNodes.length>2&&function(t,e){e.branchAttachNode=e.nodeShift+t.meta.terminalNodes[2];for(let i=0;i<2;++i)e.branchPositionShift[i]=e.backbonePositionShift[i]+t.meta.branchShift[i]}(t,r),function(t,e){e.backboneAttachNode=e.nodeShift+t.meta.terminalNodes[1],e.bondShift+=t.bonds.atomPairs.length+1,e.nodeShift+=t.atoms.atomTypes.length,e.backbonePositionShift[0]+=t.meta.backboneShift?.[0]??0,e.backbonePositionShift[1]+=e.flipFactor*(t.meta.backboneShift?.[1]??0)}(t,r)}function Jt(t,e,i,r,l){if(0===r.i)Zt(l.sugar,e,i,r);else for(const t of[l.phosphate,l.sugar])Zt(t,e,i,r);Qt(t,e,i,r)}function Qt(t,e,i,r){!function(t,e,i){for(let r=0;r<t.atoms.atomTypes.length;++r){const l=i.nodeShift+r+1;e[i.nodeShift+r]=Rt.V3K_BEGIN_DATA_LINE+l+" "+t.atoms.atomTypes[r]+" "+ee(i.branchPositionShift[0]+t.atoms.x[r])+" "+ee(i.branchPositionShift[1]+i.flipFactor*t.atoms.y[r])+" "+t.atoms.kwargs[r]}}(t,e,r),te(t,i,r),function(t,e,i){const r=i.bondShift,l=i.branchAttachNode,s=t.meta.terminalNodes[0]+i.nodeShift;e[r-1]=Rt.V3K_BEGIN_DATA_LINE+r+" 1 "+l+" "+s+"\n"}(t,i,r);const l=r.bondShift,s=r.branchAttachNode,o=t.meta.terminalNodes[0]+r.nodeShift;i[l-1]=Rt.V3K_BEGIN_DATA_LINE+l+" 1 "+s+" "+o+"\n",r.bondShift+=t.bonds.atomPairs.length+1,r.nodeShift+=t.atoms.atomTypes.length}function te(t,e,i){for(let r=0;r<t.bonds.atomPairs.length;++r){const l=i.bondShift+r+1,s=t.bonds.atomPairs[r][0]+i.nodeShift,o=t.bonds.atomPairs[r][1]+i.nodeShift;let n="";if(t.bonds.bondConfiguration.has(r)){let e=t.bonds.bondConfiguration.get(r);i.flipFactor<0&&(e=1===e?3:1),n=" CFG="+e}const a=t.bonds.kwargs.has(r)?" "+t.bonds.kwargs.get(r):"";e[i.bondShift+r]=Rt.V3K_BEGIN_DATA_LINE+l+" "+t.bonds.bondTypes[r]+" "+s+" "+o+n+a+"\n"}}function ee(t){return Math.round(Rt.PRECISION_FACTOR*t)/Rt.PRECISION_FACTOR}new qt(zt.PT,jt.fasta.peptide,.5),new qt(zt.DNA,jt.fasta.dna,.55),new qt(zt.RNA,jt.fasta.rna,.55),Kt.FASTA,Kt.SEPARATOR,Kt.HELM,Kt.BILN,onmessage=t=>{const{seqList:e,rolesList:i,monomersDict:r,alphabet:l,polymerType:s,start:o,end:n}=t.data,a=new Array(n-o),h=new Array(0);for(let t=o;t<n;++t)try{const n=e[t],h=i?i[t]:void 0;a[t-o]=Yt(n,r,l,s,h)}catch(e){const i=`Cannot get molfile of row #${t}: ${e instanceof Error?e.message:e.toString()}.`;h.push(i)}postMessage({molfiles:a,warnings:h})},helm={}})();
2
+ //# sourceMappingURL=489.js.map