@sjcrh/proteinpaint-client 2.77.0 → 2.78.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 (237) hide show
  1. package/dist/{2dmaf-acb8cfdd.js → 2dmaf-7dddba15.js} +1 -1
  2. package/dist/{AppHeader-315dbd3a.js → AppHeader-67cea623.js} +1 -1
  3. package/dist/{ColorScale-4b4ea8a2.js → ColorScale-7a36cc17.js} +1 -1
  4. package/dist/{DEanalysis-28ddd620.js → DEanalysis-417e1f88.js} +1 -1
  5. package/dist/{Disco-3c427131.js → Disco-30abd4cb.js} +1 -1
  6. package/dist/{Disco.UI-b071cf7a.js → Disco.UI-ea58ee03.js} +1 -1
  7. package/dist/{DragControls-7961799c.js → DragControls-a5072cfd.js} +1 -1
  8. package/dist/{DziViewer-aa5b5706.js → DziViewer-af3c5a76.js} +1 -1
  9. package/dist/FilterRxComp-cb149666.js +1 -0
  10. package/dist/FilterStateless-bdd1416d.js +1 -0
  11. package/dist/{HicApp-674a148d.js → HicApp-fe8682af.js} +1 -1
  12. package/dist/{OrbitControls-58ca2292.js → OrbitControls-0d20d46b.js} +1 -1
  13. package/dist/{WSIViewer-afe97e2e.js → WSIViewer-64e55fb8.js} +1 -1
  14. package/dist/{adSandbox-791d704e.js → adSandbox-5753745b.js} +1 -1
  15. package/dist/app-488d9fd6.js +1 -0
  16. package/dist/{app-bd9f016b.js → app-5aa892cb.js} +1 -1
  17. package/dist/app-d9433820.js +1 -0
  18. package/dist/app.js +1 -1
  19. package/dist/bam-4e0df8b6.js +1 -0
  20. package/dist/{barchart-e3dcfc5f.js → barchart-687ae584.js} +1 -1
  21. package/dist/{barchart.events-cecb7bf5.js → barchart.events-9e2c1acf.js} +1 -1
  22. package/dist/{bars.renderer-58e38632.js → bars.renderer-95f7250f.js} +1 -1
  23. package/dist/{block-944afb9f.js → block-2f22e7fd.js} +1 -1
  24. package/dist/block.lazyload-143ae987.js +1 -0
  25. package/dist/{block.legend-3dbc41a8.js → block.legend-aa831169.js} +1 -1
  26. package/dist/{block.mds-b3967ce5.js → block.mds-64d95cf9.js} +1 -1
  27. package/dist/{block.mds.cnv-6de3115e.js → block.mds.cnv-2520897d.js} +1 -1
  28. package/dist/{block.mds.expressionrank-553613e8.js → block.mds.expressionrank-582ed7bc.js} +1 -1
  29. package/dist/{block.mds.expressionstat-2c396bb9.js → block.mds.expressionstat-483c9bc9.js} +1 -1
  30. package/dist/{block.mds.geneboxplot-552fe571.js → block.mds.geneboxplot-c1276cba.js} +1 -1
  31. package/dist/{block.mds.junction-1e25c13d.js → block.mds.junction-4a132819.js} +1 -1
  32. package/dist/{block.mds.svcnv-462d762d.js → block.mds.svcnv-a532eca7.js} +1 -1
  33. package/dist/{block.mds.svcnv.share-766e4b22.js → block.mds.svcnv.share-6575b7cf.js} +1 -1
  34. package/dist/{block.mds2-6e04432d.js → block.mds2-9ce41a23.js} +1 -1
  35. package/dist/{block.svg-40b47da8.js → block.svg-adb13c76.js} +1 -1
  36. package/dist/{block.tk.aicheck-cc42cbaf.js → block.tk.aicheck-ef6b634b.js} +1 -1
  37. package/dist/{block.tk.ase-da848c5f.js → block.tk.ase-1b119031.js} +1 -1
  38. package/dist/{block.tk.bam-8053c97e.js → block.tk.bam-2aa824aa.js} +1 -1
  39. package/dist/{block.tk.bedgraphdot-79cb0faf.js → block.tk.bedgraphdot-983fe4b3.js} +1 -1
  40. package/dist/{block.tk.bigwig.ui-a8decec7.js → block.tk.bigwig.ui-fb6401ee.js} +1 -1
  41. package/dist/{block.tk.hicstraw-3d1e9d41.js → block.tk.hicstraw-c6732591.js} +1 -1
  42. package/dist/{block.tk.junction-81eae755.js → block.tk.junction-429b654c.js} +1 -1
  43. package/dist/{block.tk.junction.textmatrixui-4c45b69a.js → block.tk.junction.textmatrixui-15bd752c.js} +1 -1
  44. package/dist/{block.tk.ld-997fca31.js → block.tk.ld-fba14536.js} +1 -1
  45. package/dist/{block.tk.menu-d3e7ccbb.js → block.tk.menu-1299ae5e.js} +1 -1
  46. package/dist/{block.tk.pgv-ae1d1f59.js → block.tk.pgv-c946527f.js} +1 -1
  47. package/dist/{boxplot-fed0a86b.js → boxplot-dbf30a19.js} +1 -1
  48. package/dist/{brainImaging-b455fd0c.js → brainImaging-b2865ba3.js} +1 -1
  49. package/dist/{brush-06989a5e.js → brush-1a123226.js} +1 -1
  50. package/dist/{categorical-82722704.js → categorical-f67752ed.js} +1 -1
  51. package/dist/{condition-f68cc8d1.js → condition-dcc70001.js} +1 -1
  52. package/dist/{controls-1d99916a.js → controls-f4648f7f.js} +1 -1
  53. package/dist/controls.btns-26bb6ef1.js +1 -0
  54. package/dist/{controls.config-00ce9f0b.js → controls.config-9870bdea.js} +1 -1
  55. package/dist/{cuminc-879690b0.js → cuminc-2273cdd3.js} +1 -1
  56. package/dist/{customdata.inputui-c563c695.js → customdata.inputui-fb1b24dc.js} +1 -1
  57. package/dist/{dataDownload-087ac205.js → dataDownload-b94871d0.js} +1 -1
  58. package/dist/{databrowser.ui-9f98f6b3.js → databrowser.ui-8ace51c3.js} +1 -1
  59. package/dist/{density-e0aff1d0.js → density-e023c28f.js} +1 -1
  60. package/dist/{dictionary-fe0ea1d6.js → dictionary-321e19f9.js} +1 -1
  61. package/dist/{drag-e11d6644.js → drag-1b98e43e.js} +1 -1
  62. package/dist/{e2pca-b3250d5c.js → e2pca-00e78fdc.js} +1 -1
  63. package/dist/{ep-9ca01df0.js → ep-b0d6177c.js} +1 -1
  64. package/dist/{facet-397afad5.js → facet-26292a3d.js} +1 -1
  65. package/dist/{filter-b3d3964e.js → filter-67d51c09.js} +1 -1
  66. package/dist/{fusion.parse-e5312047.js → fusion.parse-7e3a6071.js} +1 -1
  67. package/dist/{geneExpClustering-4383ff2c.js → geneExpClustering-a2cf1bb9.js} +1 -1
  68. package/dist/{geneExpression-52678025.js → geneExpression-d1d5a7ca.js} +1 -1
  69. package/dist/{geneExpression-cfb86b5d.js → geneExpression-dc10af2c.js} +1 -1
  70. package/dist/{geneExpression-2422f66b.js → geneExpression-e4a5a2cd.js} +1 -1
  71. package/dist/{geneORA-81220ec0.js → geneORA-248baba7.js} +1 -1
  72. package/dist/{geneVariant-18f9591a.js → geneVariant-447d6af9.js} +1 -1
  73. package/dist/{geneVariant-4d22b146.js → geneVariant-7366f3d1.js} +1 -1
  74. package/dist/{genefusion.ui-e38778dd.js → genefusion.ui-e219424a.js} +1 -1
  75. package/dist/{genesearch-0587c713.js → genesearch-d8780180.js} +1 -1
  76. package/dist/{geneset-604d0529.js → geneset-1f67d4c9.js} +1 -1
  77. package/dist/genomeBrowser-52c639b4.js +1 -0
  78. package/dist/{genomeBrowser.controls-204f007e.js → genomeBrowser.controls-3a7a1c94.js} +1 -1
  79. package/dist/{groupsetting-53dfd5e5.js → groupsetting-697a1503.js} +1 -1
  80. package/dist/{gsea-a1b04406.js → gsea-d3286c53.js} +1 -1
  81. package/dist/hierCluster-00268175.js +1 -0
  82. package/dist/{html.legend-6807e9ad.js → html.legend-0abd27ff.js} +1 -1
  83. package/dist/{imagePlot-f96cdc61.js → imagePlot-f6398b6e.js} +1 -1
  84. package/dist/{lasso-845446b8.js → lasso-48317f42.js} +1 -1
  85. package/dist/launch.adhoc-98dc0421.js +1 -0
  86. package/dist/{leftlabel.sample-3a6037c2.js → leftlabel.sample-591bc38d.js} +1 -1
  87. package/dist/legacyDataset-354f1a29.js +1 -0
  88. package/dist/{log-0ea548ec.js → log-1001ca83.js} +1 -1
  89. package/dist/{lollipop-75e11e9a.js → lollipop-40c4c5cb.js} +1 -1
  90. package/dist/{maf-e4af10d7.js → maf-10526648.js} +1 -1
  91. package/dist/{maftimeline-cc2e866c.js → maftimeline-a77349ad.js} +1 -1
  92. package/dist/matrix-1190d4b3.js +1 -0
  93. package/dist/matrix-bc0ccf83.js +1 -0
  94. package/dist/{mavb-b2dd74f6.js → mavb-0d28dd97.js} +1 -1
  95. package/dist/{mds.fimo-f19840cd.js → mds.fimo-929b9e65.js} +1 -1
  96. package/dist/{mds.samplescatterplot-254f1de6.js → mds.samplescatterplot-5a4ee6b6.js} +1 -1
  97. package/dist/{mds.survivalplot-f440db10.js → mds.survivalplot-b04947ee.js} +1 -1
  98. package/dist/metaboliteIntensity-f407ad0c.js +1 -0
  99. package/dist/niceNumLabels-621ef5c3.js +1 -0
  100. package/dist/{nodrag-f6c0801c.js → nodrag-b2866dd8.js} +1 -1
  101. package/dist/{notify-da3afe99.js → notify-91f0bc5d.js} +1 -1
  102. package/dist/{numeric-1d0318e8.js → numeric-eb1d29b3.js} +1 -1
  103. package/dist/{numeric.binary-88bf9e0d.js → numeric.binary-da92d665.js} +1 -1
  104. package/dist/numeric.continuous-92d1dea8.js +1 -0
  105. package/dist/numeric.discrete-cd8f09b1.js +1 -0
  106. package/dist/{numeric.spline-b3968b77.js → numeric.spline-9a9987b6.js} +1 -1
  107. package/dist/{numeric.toggle-ab8b79be.js → numeric.toggle-8f68f077.js} +1 -1
  108. package/dist/{oncomatrix-5f4326a8.js → oncomatrix-c29e6de9.js} +1 -1
  109. package/dist/{parseData-62083461.js → parseData-3bf0ef9f.js} +1 -1
  110. package/dist/{plot.2dvaf-eccd8ef3.js → plot.2dvaf-9e59c7d1.js} +1 -1
  111. package/dist/plot.app-fc3608a9.js +1 -0
  112. package/dist/plot.barplot-122296f7.js +1 -0
  113. package/dist/{plot.boxplot-0c538ebe.js → plot.boxplot-99c5aac5.js} +1 -1
  114. package/dist/{plot.brainImaging-ee3a0272.js → plot.brainImaging-a7bb79d6.js} +1 -1
  115. package/dist/{plot.disco-c9249cbd.js → plot.disco-ccdf741c.js} +1 -1
  116. package/dist/{plot.dzi-dfd72ddf.js → plot.dzi-aafdf56b.js} +1 -1
  117. package/dist/plot.ssgq-146075f5.js +1 -0
  118. package/dist/{plot.vaf2cov-4081decd.js → plot.vaf2cov-41e13dd9.js} +1 -1
  119. package/dist/{plot.wsi-f6325d95.js → plot.wsi-2327ad63.js} +1 -1
  120. package/dist/{profileBarchart-f4da0483.js → profileBarchart-46616916.js} +1 -1
  121. package/dist/profileHome-121aaddb.js +1 -0
  122. package/dist/profilePlot-a2591a28.js +1 -0
  123. package/dist/{profilePolar-996784ad.js → profilePolar-006a56b1.js} +1 -1
  124. package/dist/{profileRadar-79299186.js → profileRadar-3320d932.js} +1 -1
  125. package/dist/{profileRadarFacility-00e31213.js → profileRadarFacility-7a9cea80.js} +1 -1
  126. package/dist/{profileSummary-df75e6ff.js → profileSummary-7a747b4e.js} +1 -1
  127. package/dist/recover-edcdde38.js +1 -0
  128. package/dist/{regression.inputs-e647b716.js → regression.inputs-d5d44e49.js} +1 -1
  129. package/dist/{regression.inputs.values.table-b283619d.js → regression.inputs.values.table-daf7bcda.js} +1 -1
  130. package/dist/regression.results-31a8884d.js +1 -0
  131. package/dist/{renderPvalueTable-0ed37e90.js → renderPvalueTable-05c29ccf.js} +1 -1
  132. package/dist/sampleScatter-f6c04130.js +1 -0
  133. package/dist/{sampleScatter.rendererThree-aa51e3c8.js → sampleScatter.rendererThree-448689c6.js} +2 -2
  134. package/dist/{sampleView-e4819da2.js → sampleView-0931e571.js} +1 -1
  135. package/dist/{samplelst-9d9ff205.js → samplelst-27115b0e.js} +1 -1
  136. package/dist/{samplematrix-3556e5c0.js → samplematrix-2bb2480b.js} +1 -1
  137. package/dist/{scatter-ff17f653.js → scatter-a8d7c2a0.js} +1 -1
  138. package/dist/select2Terms-480025f5.js +1 -0
  139. package/dist/{selectGenomeWithTklst-84f4ff79.js → selectGenomeWithTklst-71344af2.js} +1 -1
  140. package/dist/{singleCellCellType-a2ce9bfa.js → singleCellCellType-b4061c59.js} +1 -1
  141. package/dist/{singleCellGeneExpression-a2b45c7a.js → singleCellGeneExpression-547149f2.js} +1 -1
  142. package/dist/singleCellPlot-2f5ad46a.js +1 -0
  143. package/dist/{singlecell-a5b8a39b.js → singlecell-1c3bee25.js} +1 -1
  144. package/dist/{singlecell-63cb06d8.js → singlecell-281a74a6.js} +1 -1
  145. package/dist/snp-32b8cbd8.js +1 -0
  146. package/dist/{snp-6e312b4c.js → snp-6bbefa83.js} +1 -1
  147. package/dist/snplocus-84450f3d.js +1 -0
  148. package/dist/{spliceevent.a53ss.diagram-aa2df5d7.js → spliceevent.a53ss.diagram-c04f46f1.js} +1 -1
  149. package/dist/{spliceevent.exonskip.diagram-0b792984.js → spliceevent.exonskip.diagram-a514c12e.js} +1 -1
  150. package/dist/spliceevent.exonskip.getdefault-a9a45dfc.js +1 -0
  151. package/dist/{spliceevent.noeventdiagram-e6e29a6e.js → spliceevent.noeventdiagram-b1be922c.js} +1 -1
  152. package/dist/{spliceevent.phrase-5f65a5f4.js → spliceevent.phrase-57659f7c.js} +1 -1
  153. package/dist/{stattable-775a5af5.js → stattable-7fa50fd2.js} +1 -1
  154. package/dist/{style.gdc-519a42d8.js → style.gdc-6b6a2e0c.js} +1 -1
  155. package/dist/{summary-5866c75f.js → summary-54587ccf.js} +1 -1
  156. package/dist/{sunburst-f928bfd2.js → sunburst-c24faf27.js} +1 -1
  157. package/dist/{survival-405514f6.js → survival-21e6637b.js} +1 -1
  158. package/dist/survival-538cddc2.js +1 -0
  159. package/dist/{svg.download-cd895635.js → svg.download-0dd56dfd.js} +1 -1
  160. package/dist/{svg.legend-812ea603.js → svg.legend-21629769.js} +1 -1
  161. package/dist/{svgraph-037fd7b6.js → svgraph-76e34d5e.js} +1 -1
  162. package/dist/{svmr-3bd143c3.js → svmr-89b80ea2.js} +1 -1
  163. package/dist/table-10183501.js +1 -0
  164. package/dist/{table-e013d8fc.js → table-bb97b5c9.js} +1 -1
  165. package/dist/{termInfo-e16f90f2.js → termInfo-4d954045.js} +1 -1
  166. package/dist/termdb.bins-06fd21c1.js +1 -0
  167. package/dist/termsetting-c12f1c69.js +1 -0
  168. package/dist/{tk-25ae65c4.js → tk-b96367f7.js} +1 -1
  169. package/dist/{toggleButtons-2144daab.js → toggleButtons-bb9aca2f.js} +1 -1
  170. package/dist/{tp.ui-38bc5890.js → tp.ui-f01b186b.js} +1 -1
  171. package/dist/tvs.density-064e5767.js +1 -0
  172. package/dist/{tvs.geneVariant-f99fe353.js → tvs.geneVariant-3fac6bed.js} +1 -1
  173. package/dist/{tvs.numeric-d9108473.js → tvs.numeric-86aacc82.js} +1 -1
  174. package/dist/{tvs.samplelst-3b8ee998.js → tvs.samplelst-1b00d7b6.js} +1 -1
  175. package/dist/{uiUtils-57f4b1ba.js → uiUtils-5aad7e13.js} +1 -1
  176. package/dist/{variantBrowser-56ebc7e1.js → variantBrowser-2c465d02.js} +1 -1
  177. package/dist/{vcf-e43b533a.js → vcf-55bf2c83.js} +1 -1
  178. package/dist/{violin-1352dab2.js → violin-edbe9a63.js} +1 -1
  179. package/dist/violin.interactivity-57637244.js +1 -0
  180. package/dist/{violin.renderer-4273257d.js → violin.renderer-4cab7448.js} +1 -1
  181. package/dist/{violinRenderer-7f46e468.js → violinRenderer-24abe5fd.js} +1 -1
  182. package/dist/{viridis-87a8b605.js → viridis-8a8f3e12.js} +1 -1
  183. package/dist/{y-cac91178.js → y-6fe1bb7b.js} +1 -1
  184. package/dist/{zoom-001c2f01.js → zoom-6a36fb2b.js} +1 -1
  185. package/package.json +6 -5
  186. package/dist/FilterRxComp-e8de560c.js +0 -1
  187. package/dist/FilterStateless-75514d37.js +0 -1
  188. package/dist/app-3d14cbe4.js +0 -1
  189. package/dist/app-8b5b982a.js +0 -1
  190. package/dist/bam-fa90bae8.js +0 -1
  191. package/dist/block.lazyload-4c4e81ff.js +0 -1
  192. package/dist/controls.btns-237b3154.js +0 -1
  193. package/dist/genomeBrowser-9f0e8a60.js +0 -1
  194. package/dist/hierCluster-edaaacc5.js +0 -1
  195. package/dist/hierCluster.config-a84f69a3.js +0 -1
  196. package/dist/hierCluster.interactivity-dd917fd3.js +0 -1
  197. package/dist/hierCluster.renderers-4d33e96a.js +0 -1
  198. package/dist/launch.adhoc-cb00917b.js +0 -1
  199. package/dist/legacyDataset-c9bab1e6.js +0 -1
  200. package/dist/matrix-8b3341c4.js +0 -1
  201. package/dist/matrix.cells-4dd055e7.js +0 -1
  202. package/dist/matrix.cluster-7ab94fb5.js +0 -1
  203. package/dist/matrix.config-b3b56456.js +0 -1
  204. package/dist/matrix.controls-6e0e9692.js +0 -1
  205. package/dist/matrix.data-baabaf57.js +0 -1
  206. package/dist/matrix.dom-cb1f4872.js +0 -1
  207. package/dist/matrix.groups-9990aade.js +0 -1
  208. package/dist/matrix.interactivity-3f3cf44d.js +0 -1
  209. package/dist/matrix.layout-50bc2ea5.js +0 -1
  210. package/dist/matrix.legend-024e2d50.js +0 -1
  211. package/dist/matrix.renderers-1aed44e5.js +0 -1
  212. package/dist/matrix.serieses-dc18fcc2.js +0 -1
  213. package/dist/matrix.sort-89b98e83.js +0 -1
  214. package/dist/matrix.sorterUi-0ad98ef0.js +0 -1
  215. package/dist/metaboliteIntensity-4d905d93.js +0 -1
  216. package/dist/niceNumLabels-ef07b7ad.js +0 -1
  217. package/dist/numeric.continuous-d27197cf.js +0 -1
  218. package/dist/numeric.discrete-b826f33b.js +0 -1
  219. package/dist/plot.app-4dc30ebc.js +0 -1
  220. package/dist/plot.barplot-331715f6.js +0 -1
  221. package/dist/plot.ssgq-b5f68395.js +0 -1
  222. package/dist/profileHome-11b7d146.js +0 -1
  223. package/dist/profilePlot-5dd1fe71.js +0 -1
  224. package/dist/recover-4888c2a9.js +0 -1
  225. package/dist/regression.results-f61b4a25.js +0 -1
  226. package/dist/sampleScatter-b96546e9.js +0 -1
  227. package/dist/select2Terms-eb437c2a.js +0 -1
  228. package/dist/singleCellPlot-e7e57b0f.js +0 -1
  229. package/dist/snp-41aa88d1.js +0 -1
  230. package/dist/snplocus-0653ba82.js +0 -1
  231. package/dist/spliceevent.exonskip.getdefault-af1943e3.js +0 -1
  232. package/dist/survival-10dd3d28.js +0 -1
  233. package/dist/table-be2a9975.js +0 -1
  234. package/dist/termdb.bins-a60aaa77.js +0 -1
  235. package/dist/termsetting-7467350f.js +0 -1
  236. package/dist/tvs.density-060d3006.js +0 -1
  237. package/dist/violin.interactivity-2502dcd8.js +0 -1
@@ -1 +0,0 @@
1
- import{i as t,d as e,M as s,a as r,z as i,A as o,B as a,h as n,C as l,D as p,r as c,m as d,E as m,F as u}from"./app-3d14cbe4.js";import{T as h,N as f,g}from"./termsetting-7467350f.js";import{F as b,g as j,a as y,f as v}from"./FilterRxComp-e8de560c.js";import{f as x}from"./FilterStateless-75514d37.js";import{appInit as w}from"./app-bd9f016b.js";import{r as C}from"./table-be2a9975.js";import{_ as T}from"./tslib.es6-c3c2d88f.js";import{a as k}from"./genesearch-0587c713.js";import{m as S}from"./checkbox-96437f4d.js";import{r as _}from"./rehydrateFilter-12d118cb.js";class I extends b{constructor(t){super(t);this.api={main:this.main.bind(this),getNormalRoot:()=>j(this.rawFilter),getPromise:t=>this.promises[t]};if(t.debug)this.api.Inner=this}async main(t,e={}){this.dom.controlsTip.hide();this.dom.treeTip.hide();const s="activeCohort"in e?e.activeCohort:this.activeCohort;const r=y(t,"filterUiRoot");if(r)delete r.tag;t.lst.push({tag:"filterUiRoot",type:"tvslst",join:"",lst:[]});t.join=t.lst.length>1?"and":"";const i=JSON.stringify(t);if(this.rawCopy==i&&JSON.stringify(this.activeCohort)==JSON.stringify(s))return;await super.main(i,e)}refresh(t){this.dom.controlsTip.hide();this.dom.treeTip.hide();const e=JSON.parse(JSON.stringify(this.rawFilter));const s=v(e,this.filter.$id);if(!s||this.rawFilter.$id===this.filter.$id){this.opts.callback(e)}else{const r=s.lst.findIndex((t=>t.$id==this.filter.$id));s.lst[r]=t;this.opts.callback(e)}const r=e.lst.findIndex((e=>e.$id===t.$id));e.lst.splice(r,1);this.main(e)}}const A=t(I);function P(t){if(!t.div||!t.text||!t.callback)throw new Error("Missing required parameters");return t.div.append("button").property("disabled",t.disabled||false).style("border","none").style("border-radius","20px").style("padding","10px 15px").text(t.text).on("click",(()=>{t.callback()}))}function D(t,s){const r=s.selectAll().data(t,(t=>t.value)).enter().append("div").style("margin","5px");const i=r.append("label").on("mousedown",(t=>{t.stopPropagation()}));const o=i.append("input").attr("type","radio").attr("name",(t=>t.label)).attr("value",(t=>t.value)).property("checked",(t=>t.checked)).on("input",(function(t,r){return T(this,void 0,void 0,(function*(){t.stopPropagation();o.property("disabled",true);o.property("checked",false);s.selectAll(".contentDiv").style("display","none");const i=e(this.parentNode).append("div").classed("contentDiv",true).style("padding-left","25px").style("display","block");yield r.callback(i);e(this).property("checked",true);o.property("disabled",false)}))}));o.filter((t=>t.checked)).property("checked",true);i.append("span").html((t=>"&nbsp;"+t.label));i.append("span").style("display","block").style("padding-left","25px").style("font-size","0.75em").html((t=>t.sublabel||""))}class B{constructor(t){this.params2Add=[];this.tip=t.tip;this.params=t.params;this.callback=t.callback;this.addOptionalParams=t.addOptionalParams;this.tip.d.style("padding","15px");this.render();for(const t of this.params2Add)this.addOptionalParams(t)}render(){for(const t of this.params){const e=this.addParameter(t.param,this.tip.d.append("div"));t.input=e}const t=P({div:this.tip.d.append("div").style("padding","20px").style("display","inline-block"),text:"Calculate genes",callback:()=>T(this,void 0,void 0,(function*(){t.property("disabled",true).text("Loading...");yield this.callback();this.tip.hide()}))})}addParameter(t,e){var s;let r;if(t.type=="boolean"){if((s=t===null||t===void 0?void 0:t.options)===null||s===void 0?void 0:s.length){const s=e.append("div").style("margin","10px 0px").on("mousedown",(t=>{t.stopPropagation()}));r=s.append("input").attr("type","checkbox").attr("id",t.id);this.addLabels(s,"label",t);const i=e.append("div").style("padding-left","20px");for(const e of t.options){const t=this.addParameter(e,i.append("div"));this.params2Add.push({param:e,input:t})}if(t.value){r.property("checked",t.value);i.style("display","block")}else i.style("display","none");r.on("change",(()=>{i.style("display",r.property("checked")?"block":"none")}))}else{r=e.append("input").style("padding","2px").attr("type","checkbox").attr("id",t.id);if(t.value)r.property("checked",t.value);this.addLabels(e,"label",t)}}else if(t.type=="string"&&t.value){r=S({holder:e,id:t.id,checked:true,labeltext:t.label,callback:()=>{}})}else if(t.type=="number"){r=e.append("input").attr("type","number").style("width","50px").style("padding","5px").attr("id",t.id);if(t.value)r.attr("value",t.value);this.addLabels(e,"span",t)}else if(t.type=="radio"){const s=t.options.find((t=>t.checked));if(!s)t.options[0].checked=true;r=e.append("div").attr("id",t.id);r.append("p").style("font-size","0.8em").style("opacity",.75).text(t.label);D(t.options,r)}return r}addLabels(t,e,s){if(!s.sublabel)t.append(e).html(s.label).attr("for",s.id);else{const r=t.append("div").style("display","inline-block").style("vertical-align","middle");r.append(e).style("display","block").style("padding-top","3px").html(s.label).attr("for",s.id);r.append("span").style("display","block").style("font-size","0.75em").html(s.sublabel)}}}class G{constructor(t){var e,r,i;this.holder=t.holder;this.genome=t.genome;this.callback=t.callback;this.vocabApi=t.vocabApi;this.customInputs=t.customInputs;this.geneList=structuredClone(t.geneList||[]);this.tip2=new s({padding:"0px",parent_menu:t.holder.node(),test:"test"});this.minNumGenes=t.minNumGenes||0;if("mode"in t)this.mode=t.mode;if("titleText"in t)this.titleText=t.titleText;this.origLst=structuredClone(this.geneList);this.origNames=JSON.stringify(this.geneList.map((t=>t.gene)).sort());this.holder.selectAll("*").remove();const o=this.holder.append("div").style("padding","5px");if(this.titleText){o.append("div").style("margin-bottom","10px").html(this.titleText)}const a=o.append("div");const n=a.append("label");n.append("span").html("Search");const l=n.append("div").style("display","inline-flex").style("align-items","center").style("margin","8px 0px -5px 0px");const p=a.append("div").style("display","inline-flex").style("align-items","center").style("float","right").style("gap","5px");const c=this.addGene.bind(this);this.geneSearch=k({tip:this.tip2,genome:this.genome,row:l,searchOnly:"gene",callback:c,hideHelp:true,focusOff:true});this.menuList=[];this.api={dom:{holder:o,textControlDiv:p.append("div"),clearBtn:P({div:p,text:"Clear",disabled:!((e=this.geneList)===null||e===void 0?void 0:e.length),callback:()=>{this.geneList=[];this.renderGenes()}}),restoreBtn:((r=this.geneList)===null||r===void 0?void 0:r.length)?P({div:p,disabled:true,text:"Restore",callback:()=>{this.geneList=this.origLst;this.renderGenes()}}):null,geneHoldingDiv:this.renderGeneHoldingDiv(o),statLegendDiv:o.append("div"),submitBtn:P({div:o.append("div").style("margin-top","10px"),text:"Submit",disabled:!((i=this.geneList)===null||i===void 0?void 0:i.length),callback:()=>{this.callback({geneList:this.geneList})}})},topMutatedGenesParams:[],topVariablyExpressedGenesParams:[],statColor2label:new Map,destroy(){t.holder.remove()}};this.getParams();this.createMenuList();this.renderTextControls(this.api.dom.textControlDiv);this.renderGenes()}getParams(){var t,e,s,i;if(this.mode==h.GENE_VARIANT&&((e=(t=this.vocabApi.termdbConfig)===null||t===void 0?void 0:t.queries)===null||e===void 0?void 0:e.topMutatedGenes)){if(this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topMutatedGenes.arguments)this.api.topMutatedGenesParams.push({param:t})}}if(this.mode==h.GENE_EXPRESSION&&((i=(s=this.vocabApi.termdbConfig)===null||s===void 0?void 0:s.queries)===null||i===void 0?void 0:i.topVariablyExpressedGenes)){if(this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){for(const t of this.vocabApi.termdbConfig.queries.topVariablyExpressedGenes.arguments){if(t.type=="radio"){if(!t.options||t.options.length==0)throw"Radio button must have options";for(const e of t.options){if(e.type=="tree"){e.callback=s=>T(this,void 0,void 0,(function*(){const r=yield import("./app-bd9f016b.js");const i=s.append("div");yield r.appInit({holder:i,state:{dslabel:e.value,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:r=>{s.append("div").classed("ts_pill sja_filter_tag_btn sja_tree_click_term termlabel",true).style("margin","5px").text(`${r.id}`);t.value={type:e.value,geneList:r._geneset.map((t=>t.symbol))};i.selectAll("*").remove()}}})}))}if(e.type=="text"){e.callback=s=>T(this,void 0,void 0,(function*(){s.append("span").style("display","block").style("font-size","0.8em").style("opacity",.75).text("Enter genes separated by spaces or commas");s.append("textarea").style("display","block").on("keyup",r.debounce((function(){const s=this.value.split(/[\s,]+/).map((t=>t.trim())).filter((t=>t!==""));t.value={type:e.value,geneList:s}})),500)}))}if(e.type=="boolean"){e.callback=()=>{t.value={type:e.value,geneList:null}}}}}this.api.topVariablyExpressedGenesParams.push({param:t})}}}}baseGeneMenuArgs(t){t=this.removeDuplicates(t);return{tip:this.tip2,params:t,addOptionalParams:({param:e,input:s})=>{t.push({param:e,input:s})}}}removeDuplicates(t){var e;for(const s of t){if((e=s.param)===null||e===void 0?void 0:e.options){s.param.options.forEach((e=>{if(!e.id)return;const s=t.findIndex((t=>t.param.id==e.id));if(s!=-1)t.splice(s,1)}))}}return t}createMenuList(){var t,e,s,r;if(((t=this.api)===null||t===void 0?void 0:t.topMutatedGenesParams.length)>0){this.menuList.push({label:"Top mutated genes",callback:t=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={filter0:this.vocabApi.state.termfilter.filter0};for(const{param:e,input:s}of this.api.topMutatedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopMutatedGenes(t);this.geneList=[];this.geneList.push(...e.genes);this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topMutatedGenesParams),{callback:e});new B(s)}))})}if(((e=this.api)===null||e===void 0?void 0:e.topVariablyExpressedGenesParams.length)>0){this.menuList.push({label:"Top variably expressed genes",callback:t=>{this.api.topVariablyExpressedGenesParams.filter((t=>{var e;return t.param.type=="radio"&&((e=t.param)===null||e===void 0?void 0:e.options)})).forEach((t=>{if(typeof t.param.options[0].value==="string"){t.param.value={type:t.param.options[0].value,value:null}}else{console.error(`Unexpected radio button value type: ${typeof t.param.options[0].value}`)}}));this.tip2.clear().showunder(t.target);const e=()=>T(this,void 0,void 0,(function*(){const t={genome:this.vocabApi.state.vocab.genome,dslabel:this.vocabApi.state.vocab.dslabel};if(this.vocabApi.state.termfilter){if(this.vocabApi.state.termfilter.filter)t.filter=this.vocabApi.state.termfilter.filter;if(this.vocabApi.state.termfilter.filter0)t.filter0=this.vocabApi.state.termfilter.filter0}for(const{param:e,input:s}of this.api.topVariablyExpressedGenesParams){const r=s.attr("id");t[r]=this.getInputValue({param:e,input:s})}const e=yield this.vocabApi.getTopVariablyExpressedGenes(t);this.geneList=[];if(e.genes){for(const t of e.genes)this.geneList.push({gene:t})}this.renderGenes()}));const s=Object.assign(this.baseGeneMenuArgs(this.api.topVariablyExpressedGenesParams),{callback:e});new B(s)}})}if((r=(s=this.genome)===null||s===void 0?void 0:s.termdbs)===null||r===void 0?void 0:r.msigdb){for(const t in this.genome.termdbs){const e=this.genome.termdbs[t];this.menuList.push({label:`${e.label} gene set`,callback:()=>T(this,void 0,void 0,(function*(){this.tip2.clear().showunder(this.api.dom.textControlDiv.node());const e=yield import("./app-bd9f016b.js");e.appInit({holder:this.tip2.d,state:{dslabel:t,genome:this.genome.name,nav:{header_mode:"search_only"}},tree:{click_term:t=>{this.geneList=[];const e=t._geneset;if(e){for(const t of e)this.geneList.push({gene:t.symbol});this.renderGenes()}this.tip2.hide();this.api.dom.submitBtn.node().focus()}}})}))})}}if(this.customInputs){for(const t of this.customInputs){this.menuList.push({label:t.label,callback:()=>{t.showInput({callback:({geneList:t})=>{this.geneList=t;this.renderGenes()}})},tagName:"button"})}}}renderTextControls(t){for(const e of this.menuList){if(e.tagName=="button")P({div:t,text:e.label,callback:e.callback});else t.append("a").style("text-decoration","underline").style("padding","0px 10px").style("color","black").html(`${e.label} &#9660;`).on("click",(t=>T(this,void 0,void 0,(function*(){yield e.callback(t)}))))}}getInputValue({param:t,input:e}){if(t.type=="radio")return t.value;const s=e.node().value;if(e.attr("type")=="number")return Number(s);if(e.attr("type")=="checkbox"){if(t.type=="string")return e.node().checked?t.value:"";if(t.type=="boolean")return e.node().checked?1:0}}renderGeneHoldingDiv(t){return t.append("div").append("div").style("display","flex").style("flex-wrap","wrap").style("gap","5px").style("min-height","20px").style("border","solid 1px #aaa").style("margin","15px 0px").style("padding","6px 2px").style("min-height","30px")}renderStatLegend(){if(!this.api.statColor2label||this.api.statColor2label.size==0){this.api.dom.statLegendDiv.style("display","none");return}this.api.dom.statLegendDiv.style("display","block").selectAll("*").remove();for(const[t,e]of this.api.statColor2label){this.api.dom.statLegendDiv.append("div").style("display","inline-block").style("width","12px").style("height","12px").style("background-color",t);this.api.dom.statLegendDiv.append("span").html(` ${e} &nbsp;&nbsp;`)}return this.api.dom.statLegendDiv}addGene(){const t=this.geneSearch.geneSymbol;for(const e of this.geneList){if(e.gene==t){window.alert(`The gene ${t} has already been added`);return}}if(t)this.geneList.push({gene:t});this.renderGenes()}renderGenes(){var t,s,r,i;const o=this.geneList.some((t=>t.mutationStat));if(!o)this.geneList.sort(((t,e)=>{if(t.gene<e.gene)return-1;if(t.gene>e.gene)return 1;return 0}));this.api.dom.geneHoldingDiv.selectAll("*").remove();const a=this.renderGene.bind(this);const n=this.deleteGene.bind(this);this.api.dom.geneHoldingDiv.selectAll("div").data(this.geneList||[]).enter().append("div").attr("aria-label","Click to delete").attr("class","sja_menuoption").attr("tabindex",0).style("position","relative").style("display","inline-block").style("padding","5px 16px 5px 9px").style("margin-left","5px").each((function(t){const s=e(this).style("border-radius","5px");a(s,t);s.on("click",(()=>n(t)))})).on("mouseover",(function(t){const s=e(t.target);s.append("div").style("margin-left","4px").classed("sjpp_deletebt",true).style("display","inline-block").style("position","absolute").style("right","0px").style("top","0px").style("transform","scale(0.6)").style("pointer-events","none").html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-x-lg" viewBox="0 0 16 16">\n <path stroke='#f00' d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>\n </svg>`)})).on("mouseout",(function(t){e(t.target).select(".sjpp_deletebt").remove()})).on("focus",(t=>{t.target.dispatchEvent(new PointerEvent("mouseover"))})).on("blur",(t=>{t.target.dispatchEvent(new PointerEvent("mouseout"))})).on("keyup",(t=>{if(t.key=="Enter")t.target.click()}));this.renderStatLegend();this.api.dom.clearBtn.property("disabled",!((t=this.geneList)===null||t===void 0?void 0:t.length));const l=this.origNames!==JSON.stringify(this.geneList.map((t=>t.gene)).sort());(s=this.api.dom.restoreBtn)===null||s===void 0?void 0:s.property("disabled",!l);this.api.dom.submitBtn.property("disabled",!l||((r=this.geneList)===null||r===void 0?void 0:r.length)<this.minNumGenes||!((i=this.geneList)===null||i===void 0?void 0:i.length));if(l)this.api.dom.submitBtn.node().focus()}renderGene(t,e){if(e.mutationStat){t.html(`${e.gene}&nbsp;&nbsp;`);for(const s of e.mutationStat){let e;let r="black";if("class"in s){if(!i[s.class])throw"invalid stat class";e=i[s.class].color;this.api.statColor2label.set(e,i[s.class].label)}else if("dt"in s){if(!o[s["dt"]])throw"invalid stat dt";e=o[s["dt"]];r="white";this.api.statColor2label.set(e,a[s["dt"]])}else{throw"stat missing dt/class"}t.insert("span").style("font-size",".7em").style("background-color",e).style("padding","1px 2px").style("color",r).text(s.count)}}else{t.insert("div").style("display","inline-block").html(e.gene)}}deleteGene(t){const e=this.geneList.findIndex((e=>e.gene===t.gene));if(e!=-1){this.geneList.splice(e,1);this.renderGenes()}}}function L(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-28ddd620.js");case"../plots/Disco.js":return import("./Disco-3c427131.js");case"../plots/DziViewer.js":return import("./DziViewer-aa5b5706.js");case"../plots/WSIViewer.js":return import("./WSIViewer-afe97e2e.js");case"../plots/barchart.data.js":return import("./FilterRxComp-e8de560c.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-cecb7bf5.js");case"../plots/barchart.js":return import("./barchart-e3dcfc5f.js");case"../plots/bars.renderer.js":return import("./bars.renderer-58e38632.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-fed0a86b.js");case"../plots/brainImaging.js":return import("./brainImaging-b455fd0c.js");case"../plots/controls.btns.js":return import("./controls.btns-237b3154.js");case"../plots/controls.config.js":return import("./controls.config-00ce9f0b.js");case"../plots/controls.js":return import("./controls-1d99916a.js");case"../plots/cuminc.js":return import("./cuminc-879690b0.js");case"../plots/dataDownload.js":return import("./dataDownload-087ac205.js");case"../plots/dictionary.js":return import("./dictionary-fe0ea1d6.js");case"../plots/facet.js":return import("./facet-397afad5.js");case"../plots/geneExpression.js":return import("./geneExpression-52678025.js");case"../plots/geneORA.js":return import("./geneORA-81220ec0.js");case"../plots/geneset.js":return import("./geneset-604d0529.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-204f007e.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-9f0e8a60.js");case"../plots/gsea.js":return import("./gsea-a1b04406.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-a84f69a3.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-dd917fd3.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-edaaacc5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-4d33e96a.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-f96cdc61.js");case"../plots/matrix.cells.js":return import("./matrix.cells-4dd055e7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-7ab94fb5.js");case"../plots/matrix.config.js":return import("./matrix.config-b3b56456.js");case"../plots/matrix.controls.js":return import("./matrix.controls-6e0e9692.js");case"../plots/matrix.data.js":return import("./matrix.data-baabaf57.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-cb1f4872.js");case"../plots/matrix.groups.js":return import("./matrix.groups-9990aade.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-3f3cf44d.js");case"../plots/matrix.js":return import("./matrix-8b3341c4.js");case"../plots/matrix.layout.js":return import("./matrix.layout-50bc2ea5.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-024e2d50.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-1aed44e5.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-dc18fcc2.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-89b98e83.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-0ad98ef0.js");case"../plots/plot.app.js":return import("./plot.app-4dc30ebc.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-ee3a0272.js");case"../plots/plot.disco.js":return import("./plot.disco-c9249cbd.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-b5f68395.js");case"../plots/profileBarchart.js":return import("./profileBarchart-f4da0483.js");case"../plots/profilePlot.js":return import("./profilePlot-5dd1fe71.js");case"../plots/profilePolar.js":return import("./profilePolar-996784ad.js");case"../plots/profileRadar.js":return import("./profileRadar-79299186.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-00e31213.js");case"../plots/profileSummary.js":return import("./profileSummary-df75e6ff.js");case"../plots/regression.inputs.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-b283619d.js");case"../plots/regression.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-f61b4a25.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-aa51e3c8.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-e4819da2.js");case"../plots/scatter.js":return import("./scatter-ff17f653.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e7e57b0f.js");case"../plots/stattable.js":return import("./stattable-775a5af5.js");case"../plots/summary.js":return import("./summary-5866c75f.js");case"../plots/survival.js":return import("./survival-405514f6.js");case"../plots/table.js":return import("./table-e013d8fc.js");case"../plots/variantBrowser.js":return import("./variantBrowser-56ebc7e1.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-2502dcd8.js");case"../plots/violin.js":return import("./violin-1352dab2.js");case"../plots/violin.renderer.js":return import("./violin.renderer-4273257d.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class E{constructor(t={}){this.type="charts";q(this)}async init(t){this.dom={holder:this.opts.holder,tip:new s({padding:"0px"})};this.makeButtons(t)}getState(t){const e=N(t);const s=JSON.parse(JSON.stringify(t.termdbConfig?.supportedChartTypes||{}));const r={vocab:t.vocab,activeCohort:t.activeCohort,termfilter:t.termfilter,supportedChartTypes:s[e]||["summary"],termdbConfig:t.termdbConfig};if(t?.termfilter?.filter){r.filter=j(t.termfilter.filter)}if(!r.supportedChartTypes.includes("dictionary")&&!r.termdbConfig.hiddenChartTypes?.includes("dictionary")){if(r.vocab.dslabel=="ProfileFull"||r.vocab.dslabel=="ProfileAbbrev")r.supportedChartTypes.push(...t.termdbConfig.allowedChartTypes);r.supportedChartTypes.push("dictionary");r.supportedChartTypes.push("facet")}return r}main(){this.dom.btns.style("display",(t=>this.state.supportedChartTypes.includes(t.chartType)?"":"none"))}}const R=n(E);function N(t){if(t?.termdbConfig?.selectCohort?.values){if(!Number.isInteger(t.activeCohort))throw"appState.activeCohort is not integer array index";const e=t.termdbConfig.selectCohort.values[t.activeCohort];if(!e)throw"appState.activeCohort array index out of bound";return[...e.keys].sort().join(",")}return""}function M(t,e){const s=[{label:"Data Dictionary",clickTo:t.prepPlot,chartType:"dictionary",config:{chartType:"dictionary"}},{label:"Sample View",clickTo:t.prepPlot,chartType:"sampleView",config:{chartType:"sampleView"}},{label:"Summary Plots",chartType:"summary",clickTo:t.showTree_select1term,usecase:{target:"summary",detail:"term"}},{label:"Scatter Plot",chartType:"sampleScatter",clickTo:t.loadChartSpecificMenu},{label:"Cumulative Incidence",chartType:"cuminc",clickTo:t.showTree_select1term,usecase:{target:"cuminc",detail:"term"}},{label:"Survival",chartType:"survival",clickTo:t.showTree_select1term,usecase:{target:"survival",detail:"term"}},{label:"Regression Analysis",chartType:"regression",clickTo:t.loadChartSpecificMenu},{label:"Sample Matrix",chartType:"matrix",clickTo:t.loadChartSpecificMenu},{label:"Genome Browser",chartType:"genomeBrowser",clickTo:t.loadChartSpecificMenu},{label:"Differential Expression",chartType:"DEanalysis",clickTo:t.loadChartSpecificMenu},{label:"Data Download",clickTo:t.prepPlot,chartType:"dataDownload",config:{chartType:"dataDownload",terms:[]}},{label:"Facet Table",clickTo:t.loadChartSpecificMenu,chartType:"facet",config:{chartType:"facet"}},{label:"Brain Imaging",clickTo:t.loadChartSpecificMenu,chartType:"brainImaging",config:{chartType:"brainImaging"}},{label:"Single Cell Plot",clickTo:t.loadChartSpecificMenu,chartType:"singleCellPlot",config:{chartType:"singleCellPlot"}},{label:"Gene Expression",chartType:"geneExpression",clickTo:t.showGenesetEditUI,usecase:{target:"geneExpression"}},{label:"Metabolite Intensity",chartType:"metaboliteIntensity",clickTo:t.showTree_selectlst,usecase:{target:"metaboliteIntensity",detail:"term"},updateActionBySelectedTerms:(t,e)=>{const s=e.map((t=>({term:structuredClone(t),q:{mode:f.continuous}})));if(s.length==1){t.config.chartType="summary";t.config.term=s[0];return}if(s.length==2){t.config.chartType="summary";t.config.term=s[0];t.config.term2=s[1];return}t.config.chartType="hierCluster";t.config.dataType=h.METABOLITE_INTENSITY;t.config.termgroups=[{name:"Metabolite Intensity Cluster",lst:s,type:"hierCluster"}]}}];if(e.vocab.dslabel=="ProfileFull"||e.vocab.dslabel=="ProfileAbbrev"){const r=O(t,e);s.unshift(...r)}for(const t in e?.termdbConfig.renamedChartTypes||[]){const r=s.find((e=>e.chartType===t));if(r){r.label=e.termdbConfig.renamedChartTypes[t]}}return s}function O(t,e){const s=[{label:"Profile Polar",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profilePolar",header:"Polar Graph",logged:true}}),chartType:"profilePolar"},{label:"Profile Barchart",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileBarchart",header:"Barchart Graph",logged:true}}),chartType:"profileBarchart"},{label:"Radar 1-Score-based(Site)",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadarFacility",plot:"plot1",header:"Radar 1-Score-based(Site)",logged:true}}),chartType:"profileRadarFacility"},{label:"Radar 2-Impressions",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot1",header:"Radar 2-Impressions",logged:true}}),chartType:"profileRadar"}];if(e.vocab.dslabel=="ProfileFull"){s.push({label:"Radar 3-Score-based(SC & POC)s",clickTo:()=>t.app.dispatch({type:"plot_create",config:{chartType:"profileRadar",plot:"plot2",header:"Radar 3-Score-based(SC & POC)",logged:true}}),chartType:"profileRadar"})}return s}function q(t){t.makeButtons=function(e){const s=M(t,e);t.dom.btns=t.dom.holder.selectAll("button").data(s).enter().append("button").style("margin","10px").style("padding","10px 15px").style("border-radius","20px").style("border-color","#ededed").html((t=>t.label)).on("click",(function(e,s){t.dom.tip.clear().showunder(this);s.clickTo(s)}))};t.showTree_select1term=async e=>{if(e.usecase.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};if(e.parentId)s.parentId=e.parentId;const r=await import("./app-bd9f016b.js");r.appInit({vocabApi:t.app.vocabApi,holder:t.dom.tip.d.append("div"),state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{click_term:r=>{const i=r.term?r:{term:r};s.config[e.usecase.detail]=i;t.dom.tip.hide();t.app.dispatch(s)}}})};t.showGenesetEditUI=async e=>{const s=[];const r=t.app;const i=t.dom.tip;const o=t.dom.tip.d;o.selectAll("*").remove();const a=o.append("div").style("padding","5px");const n=a.append("label");n.append("span").text("Create ");let l;const p=n.append("input").style("margin","2px 5px").style("width","210px").attr("placeholder","Group Name").on("input",(()=>{l=p.property("value")}));const c={index:0,name:l,label:l,lst:[],status:"new"};new G({holder:o.append("div"),genome:r.opts.genome,geneList:s,mode:"geneExpression",vocabApi:r.vocabApi,callback:async({geneList:t,groupName:e})=>{if(!c)throw`missing selectedGroup`;i.hide();const s={name:e||l,lst:[],type:"hierCluster"};const a=s.lst.filter((t=>t.term.type!="geneVariant"));const n=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));if(n.length==1){const t=n[0];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t}});return}if(n.length==2){const t=n[0];const e=n[1];r.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e}});return}s.lst=[...a,...n];if(!s.lst.length)tg.splice(c.index,1);o.selectAll("*").remove();r.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION}})}})};t.showTree_selectlst=async e=>{t.dom.tip.clear();if(e.usecase?.label){t.dom.tip.d.append("div").style("margin","3px 5px").style("padding","3px 5px").style("font-weight",600).html(e.usecase.label)}const s={type:"plot_create",id:F(),config:{chartType:e.chartType}};const r=await import("./app-bd9f016b.js");t.dom.submenu=t.dom.tip.d.append("div");r.appInit({holder:t.dom.submenu,vocabApi:t.app.vocabApi,state:{activeCohort:t.state.activeCohort,nav:{header_mode:"search_only"},tree:{usecase:e.usecase}},tree:{submit_lst:r=>{const i=e.processSelection?e.processSelection(r):r;s.config[e.usecase.detail]=i;if(e.updateActionBySelectedTerms)e.updateActionBySelectedTerms(s,r);t.dom.tip.hide();t.app.dispatch(s)}}})};t.loadChartSpecificMenu=async e=>{t.dom.tip.clear();const s=await L(`../plots/${e.chartType}.js`);s.makeChartBtnMenu(t.dom.tip.d,t)};t.prepPlot=function(e){const s={type:"plot_prep",config:e.config,id:F()};t.app.dispatch(s)}}const V="_CHART_AUTOID_";let $=Date.now();function F(){return V+$++}const H=l(5);class U{constructor(t={}){this.type="groups";this.selectedGroupsIdx=new Set}async init(){this.dom={holder:this.opts.holder.append("div").style("margin","10px")};W(this);this.tip=new s({padding:"0px"})}getState(t){const e=N(t);const s={termfilter:t.termfilter,groups:Y(t),termdbConfig:t.termdbConfig,customTerms:t.customTerms,supportedChartTypes:t.termdbConfig.supportedChartTypes[e],matrixplots:t.termdbConfig.matrixplots};return s}async main(){await X(this)}getMassFilter(){if(!this.state.termfilter.filter||this.state.termfilter.filter.lst.length==0){return{type:"tvslst",in:true,join:"",lst:[]}}const t=j(structuredClone(this.state.termfilter.filter));return t}async groups2samplelst(t){const e=[];const s=new Set,r=[];for(const i of t){const t=await this.app.vocabApi.getFilteredSampleList(i.filter);const o=[];for(const i of t){const t={sampleId:i.id};if("name"in i){t.sample=i.name}if(!s.has(i.id))o.push(t);else{for(const t of e){const e=t.items.findIndex((t=>t.sampleId===i.id));if(e!==-1)r.push(...t.items.splice(e,1))}}s.add(t.sampleId)}if(o.length)e.push({name:i.name,items:o,color:i.color})}if(r.length){const t=confirm('Overlap detected: 1 or more samples belong to >1 groups. A new group will be created for these "overlap" samples.');if(!t)return;e.push({name:"Group overlap",items:r})}const i=e.length==1?e[0].name:"Sample groups";const o=lt(e,i,this.app.vocabApi);if(t.length==1){const t=await this.app.vocabApi.getCohortSampleCount(this.activeCohortName);const e=parseInt(t,10);const s=Object.values(o.term.values).find((t=>t.key.startsWith("Not in")));s.othersGroupSampleNum=e-s.list.length}for(const t of o.q.groups){o.term.values[t.name].list=t.values;o.term.values[t.name].inuse=t.inuse}return o}updateLaunchButton(){this.dom.newTermSpan.style("display","none");this.dom.noGroupSelected.style("display","none");if(this.state.groups.length==0)return;if(this.state.groups.length==1){this.dom.newTermSpan.style("display","");this.dom.launchButton.text(`Create variable using "${this.state.groups[0].name}"`);this.dom.newTermNameInput.property("value",this.state.groups[0].name+" vs others");return}const t=[...this.selectedGroupsIdx];if(t.length==0){this.dom.noGroupSelected.style("display","");return}this.dom.newTermSpan.style("display","");if(t.length==1){this.dom.launchButton.text(`Create variable using "${this.state.groups[t[0]]?.name}"`);this.dom.newTermNameInput.property("value",this.state.groups[t[0]].name+" vs others");return}this.dom.launchButton.text(`Create variable using ${t.length} groups`);this.dom.newTermNameInput.property("value",t.map((t=>this.state.groups[t].name)).join(" vs "))}displayCustomTerms(){this.dom.customTermDiv.selectAll("*").remove();if(this.state.customTerms.length==0){this.dom.customTermDiv.append("div").text("No custom variables. Use above controls to create new ones. Custom variables are added to dictionary.").style("font-size",".8em");return}this.dom.customTermDiv.append("div").style("margin-bottom","10px").style("font-size",".8em").text("Following custom variables are available in all charts where variables are used. Click one to delete.");for(const{name:t,tw:e}of this.state.customTerms){const s=this.dom.customTermDiv.append("div");s.text(t).attr("class","sja_filter_tag_btn").style("padding","3px 6px").style("border-radius","6px").style("margin-right","5px").on("click",(s=>{const r=()=>this.app.vocabApi.deleteCustomTerm(t);this.showGroupsMenu(s,e,r)}))}}newId(){this.lastId=g();return this.lastId}showGroupsMenu(t,e,s){const r=structuredClone(e);this.tip.clear();const i=this.tip.d.append("div");const o=this?.lastId;const a=i.append("div");const n=p({holder:a});for(const[t,s]of Object.entries(e.term.values)){const t=s.color?`<span style="display:inline-block; width:12px; height:12px; background-color:${s.color}" ></span>`:`<span style="display:inline-block; width:11px; height:11px; background-color:${"#fff"}; border: 0.1px solid black" ></span>`;const[e,r]=n.addRow();e.html(`${t} ${s.label}:`);r.html(`${s.othersGroupSampleNum||s.list.length} samples`)}i.append("div");it(this.tip,i,r,this.app,o,this.state,(()=>this.newId));if(this.state.supportedChartTypes.includes("DEanalysis")&&r.q.groups.length==2)J(i,this,this.state,r);if(this.state.supportedChartTypes.includes("survival"))st("survival",i,"Compare survival",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("geneExpression"))rt("geneExpression",i,"Gene expression",this.tip,r,o,this,true);if(this.state.supportedChartTypes.includes("cuminc"))st("cuminc",i,"Compare cumulative incidence",this.tip,r,o,this,true);const l=i.append("div").attr("class","sja_menuoption sja_sharp_border").html("Summarize");l.insert("div").html("›").style("float","right");l.on("click",(async t=>{et(l,(t=>{Z(t,r,this.app,o,(()=>this.newId))}),this.app,this.tip)}));i.append("div").attr("class","sja_menuoption sja_sharp_border").text("Delete variable").on("click",(t=>{s();this.tip.hide()}));if(this.state.termdbConfig.scatterplots)for(const t of this.state.termdbConfig.scatterplots){if(t.colorTW)i.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Open ${t.name}`).on("click",(()=>{let e={chartType:"sampleScatter",name:t.name};if(t.sampleCategory)e.sampleCategory={tw:structuredClone(t.sampleCategory.tw),order:t.sampleCategory.order,defaultValue:t.sampleCategory.defaultValue};if(t.sampleType)e.sampleType=t.sampleType;e.colorTW=structuredClone(r);if(t.settings)e.settings=structuredClone(t.settings);this.app.dispatch({type:"plot_create",config:e});this.tip.hide()}))}this.tip.showunder(t.target)}}const z=n(U);function J(t,e,s,r,i){t.append("div").attr("class","sja_menuoption sja_sharp_border").text("Differential expression").on("click",(t=>{const i=[];for(const t of r.q.groups){if(t.values&&t.values.length>0){i.push(t)}else{throw"group does not contain samples for DE analysis"}}const o={chartType:"DEanalysis",state:s,samplelst:{groups:i}};e.tip.hide();e.app.dispatch({type:"plot_create",config:o})}))}function W(t){t.dom.filterTableDiv=t.dom.holder.append("div").style("margin-bottom","10px");const e=t.dom.holder.append("div");t.dom.addNewGroupBtnHolder=e.append("span").style("margin-right","20px");t.dom.newTermSpan=e.append("span");t.dom.newTermSpan.append("span").style("padding-left","15px").text("Add variable:");t.dom.newTermNameInput=t.dom.newTermSpan.append("input").attr("type","text");t.dom.launchButton=t.dom.newTermSpan.append("span").attr("class","sja_menuoption").on("click",(()=>Q(t)));t.dom.noGroupSelected=e.append("span").text("No groups selected").style("opacity",.5);t.dom.customTermDiv=t.dom.holder.append("div").style("margin","20px").style("border-left","solid 1px black").style("padding","10px");t.dom.holder.on("click",(t=>{if(tt)tt.hide()}))}async function X(t){if(!t.filterPrompt)t.filterPrompt=await A({holder:t.dom.addNewGroupBtnHolder,vocabApi:t.app.vocabApi,emptyLabel:"Add group",termdbConfig:t.state.termdbConfig,callback:e=>{ot(t.app,e,t.state.groups)},debug:t.opts.debug});t.filterPrompt.main(t.getMassFilter());const e=structuredClone(t.state.groups);if(!e.length){t.updateLaunchButton();t.dom.filterTableDiv.style("display","none");t.displayCustomTerms();return}t.dom.filterTableDiv.style("display","").selectAll("*").remove();const s={div:t.dom.filterTableDiv,columns:[{label:"NAME",editCallback:async(e,s)=>{const r=s.value;const i=t.state.groups.findIndex((t=>t.name==r));if(i!=-1){alert(`Group named ${r} already exists`);X(t)}else await t.app.dispatch({type:"rename_group",index:e,newName:s.value})}},{label:"COLOR",editCallback:async(e,s)=>{await t.app.dispatch({type:"change_color_group",index:e,newColor:s.color})}},{label:"#SAMPLE"},{label:"FILTER"}],columnButtons:[{text:"Delete",callback:(s,r)=>{const i=e[r];t.app.vocabApi.deleteGroup(i.name)}}],rows:[]};for(const r of e){s.rows.push([{value:r.name},{color:r.color},{value:"n="+await t.app.vocabApi.getFilteredSampleCount(r.filter)},{}])}t.selectedGroupsIdx.clear();if(e.length==1){t.selectedGroupsIdx.add(0)}else{s.noButtonCallback=(e,s)=>{if(s.checked)t.selectedGroupsIdx.add(e);else t.selectedGroupsIdx.delete(e);t.updateLaunchButton()};s.selectedRows=[];for(let r=0;r<e.length;r++){s.selectedRows.push(r);t.selectedGroupsIdx.add(r)}}C(s);for(const[r,i]of s.rows.entries()){const s=e[r];x({holder:i[3].__td,vocabApi:t.app.vocabApi,termdbConfig:t.state.termdbConfig,callback:r=>{if(!r||r.lst.length==0){const t=e.findIndex((t=>t.name==s.name));e.splice(t,1)}else{s.filter=r}t.app.dispatch({type:"app_refresh",state:{groups:e}})}}).main(s.filter)}t.updateLaunchButton();t.displayCustomTerms()}async function Q(t){const e=[];for(const s of t.selectedGroupsIdx){const r=t.state.groups[s];if(r)e.push(r)}if(e.length==0)throw"No groups, should not happen";const s=t.dom.newTermNameInput.property("value");const r=await t.groups2samplelst(e);if(!r)return;r.term.name=s;t.app.vocabApi.addCustomTerm({name:s,tw:r});t.dom.newTermSpan.style("display","none")}function Y(t){if(!t.termfilter?.filter||t.termfilter.filter.lst.length==0){return t.groups}const e=[];for(const s of t.groups){const r=j(structuredClone(t.termfilter.filter));const i=y(s.filter,"filterUiRoot");if(!i){e.push(s);continue}r.lst.push(i);r.join=r.lst.length>1?"and":"";const o={name:s.name,filter:r,color:s.color};e.push(o)}return e}async function K(t,e,s,r,i,o){let a={chartType:t,term:e,term2:s};if(i)a.insertBefore=i;if(o)a.id=o();await r.dispatch({type:"plot_create",config:a})}async function Z(t,e,s,r,i){const o=t.term?t:{term:t};let a={chartType:"summary",childType:"barchart",term:o,term2:e};if(r)a.insertBefore=r;if(i)a.id=i();await s.dispatch({type:"plot_create",config:a})}let tt;async function et(t,e,r,i,o={tree:{usecase:{target:"default",detail:"term"}}},a=true,n=true,l=[]){if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();if(n)tt.showunderoffset(t.node());else tt.showunder(t.node());w({holder:tt.d,vocabApi:r.vocabApi,state:o,tree:{disable_terms:l,click_term:t=>{e(t);tt.hide();if(a)i.hide()}}})}function st(t,e,s,r,i,o,a,n=false){const l=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${s}&nbsp;&nbsp;›`).on("click",(e=>{const s={tree:{usecase:{target:t,detail:"term"}}};if(t=="survival")s.nav={header_mode:"hide_search"};et(l,(e=>{K(t,e,i,a.app,o,n?()=>a.newId:null)}),a.app,r,s)}))}function rt(t,e,r,i,o,a,n,l=false){const p=e.append("div").attr("class","sja_menuoption sja_sharp_border").html(`${r}&nbsp;&nbsp;›`).on("click",(()=>{if(!tt)tt=new s({padding:0,offsetX:162,offsetY:-34,parent_menu:i.d.node()});tt.clear();tt.showunderoffset(p.node());new G({holder:tt.d,genome:n.app.opts.genome,geneList:[],vocabApi:n.app.vocabApi,callback:async({geneList:t,groupName:e})=>{i.hide();const s={name:e,lst:[],type:"hierCluster"};const r=s.lst.filter((t=>t.term.type!="geneExpression"));const a=await Promise.all(t.map((async t=>{const e={gene:t.symbol||t.gene,name:t.symbol||t.gene,type:"geneExpression"};let r=s.lst.find((e=>e.term.name==t.symbol||e.term.name==t.gene));if(!r){r={term:e,q:{}}}return r})));tt.d.selectAll("*").remove();if(a.length==1){const t=a[0];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:o}});return}if(a.length==2){const t=a[0];const e=a[1];n.app.dispatch({type:"plot_create",config:{chartType:"summary",term:t,term2:e,colorTW:o}});return}s.lst=[...r,...a];n.app.dispatch({type:"plot_create",config:{chartType:"hierCluster",termgroups:[s],dataType:h.GENE_EXPRESSION,divideBy:o,settings:{hierCluster:{yDendrogramHeight:0,clusterSamples:false}}}})}})}))}function it(t,e,s,r,i,o,a){if(o.matrixplots){for(const n of o.matrixplots){e.append("div").attr("class","sja_menuoption sja_sharp_border").text(n.name).on("click",(async()=>{const e=await r.vocabApi.getMatrixByName(n.name);e.divideBy=s;e.insertBefore=i;e.settings.matrix.colw=0;if(a)e.id=a();r.dispatch({type:"plot_create",config:e});t.hide()}))}}}function ot(t,e,s){s=JSON.parse(JSON.stringify(s));let r="New group";let i=0;while(1){const t=r+(i==0?"":" "+i);if(!s.find((e=>e.name==t)))break;i++}r=r+(i==0?"":" "+i);const o={name:r,filter:e,color:c(H(s.length)).formatHex()};s.push(o);t.dispatch({type:"app_refresh",state:{groups:s}})}function at(t){let e=0;let s=true;for(const r in t.term.values){const i=t.q.groups[e].values;t.term.values[r].list=i;if(i[0]&&"sample"in i[0])s=false;e++}const r={type:"tvslst",in:true,join:"",lst:[{type:"tvs",tvs:{term:t.term},noEdit:s}]};return r}function nt(t){const e={name:"",index:0,items:[{sampleId:t}]};const s=lt([e],"",false);const r=at(s);return r}function lt(t,e="groups",s=true){const r={};const i=[];let o;for(const e of t){o=n(e);const t={name:e.name,in:true,values:o};i.push(t);r[e.name]={key:e.name,label:e.name,color:e.color,list:o}}if(t.length==1&&s){const e="Not in "+t[0].name;r[e]={key:e,label:e,color:"#aaa",list:o};i.push({name:e,in:false,values:o})}const a={isAtomic:true,term:{name:e,type:"samplelst",values:r},q:{groups:i}};return a;function n(t){const e=[];for(const s of t.items){const t={sampleId:s.sampleId};if("sample"in s){t.sample=s.sample}e.push(t)}return e}}function pt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-28ddd620.js");case"../plots/Disco.js":return import("./Disco-3c427131.js");case"../plots/DziViewer.js":return import("./DziViewer-aa5b5706.js");case"../plots/WSIViewer.js":return import("./WSIViewer-afe97e2e.js");case"../plots/barchart.data.js":return import("./FilterRxComp-e8de560c.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-cecb7bf5.js");case"../plots/barchart.js":return import("./barchart-e3dcfc5f.js");case"../plots/bars.renderer.js":return import("./bars.renderer-58e38632.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-fed0a86b.js");case"../plots/brainImaging.js":return import("./brainImaging-b455fd0c.js");case"../plots/controls.btns.js":return import("./controls.btns-237b3154.js");case"../plots/controls.config.js":return import("./controls.config-00ce9f0b.js");case"../plots/controls.js":return import("./controls-1d99916a.js");case"../plots/cuminc.js":return import("./cuminc-879690b0.js");case"../plots/dataDownload.js":return import("./dataDownload-087ac205.js");case"../plots/dictionary.js":return import("./dictionary-fe0ea1d6.js");case"../plots/facet.js":return import("./facet-397afad5.js");case"../plots/geneExpression.js":return import("./geneExpression-52678025.js");case"../plots/geneORA.js":return import("./geneORA-81220ec0.js");case"../plots/geneset.js":return import("./geneset-604d0529.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-204f007e.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-9f0e8a60.js");case"../plots/gsea.js":return import("./gsea-a1b04406.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-a84f69a3.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-dd917fd3.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-edaaacc5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-4d33e96a.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-f96cdc61.js");case"../plots/matrix.cells.js":return import("./matrix.cells-4dd055e7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-7ab94fb5.js");case"../plots/matrix.config.js":return import("./matrix.config-b3b56456.js");case"../plots/matrix.controls.js":return import("./matrix.controls-6e0e9692.js");case"../plots/matrix.data.js":return import("./matrix.data-baabaf57.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-cb1f4872.js");case"../plots/matrix.groups.js":return import("./matrix.groups-9990aade.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-3f3cf44d.js");case"../plots/matrix.js":return import("./matrix-8b3341c4.js");case"../plots/matrix.layout.js":return import("./matrix.layout-50bc2ea5.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-024e2d50.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-1aed44e5.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-dc18fcc2.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-89b98e83.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-0ad98ef0.js");case"../plots/plot.app.js":return import("./plot.app-4dc30ebc.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-ee3a0272.js");case"../plots/plot.disco.js":return import("./plot.disco-c9249cbd.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-b5f68395.js");case"../plots/profileBarchart.js":return import("./profileBarchart-f4da0483.js");case"../plots/profilePlot.js":return import("./profilePlot-5dd1fe71.js");case"../plots/profilePolar.js":return import("./profilePolar-996784ad.js");case"../plots/profileRadar.js":return import("./profileRadar-79299186.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-00e31213.js");case"../plots/profileSummary.js":return import("./profileSummary-df75e6ff.js");case"../plots/regression.inputs.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-b283619d.js");case"../plots/regression.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-f61b4a25.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-aa51e3c8.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-e4819da2.js");case"../plots/scatter.js":return import("./scatter-ff17f653.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e7e57b0f.js");case"../plots/stattable.js":return import("./stattable-775a5af5.js");case"../plots/summary.js":return import("./summary-5866c75f.js");case"../plots/survival.js":return import("./survival-405514f6.js");case"../plots/table.js":return import("./table-e013d8fc.js");case"../plots/variantBrowser.js":return import("./variantBrowser-56ebc7e1.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-2502dcd8.js");case"../plots/violin.js":return import("./violin-1352dab2.js");case"../plots/violin.renderer.js":return import("./violin.renderer-4273257d.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function ct(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-28ddd620.js");case"../plots/Disco.js":return import("./Disco-3c427131.js");case"../plots/DziViewer.js":return import("./DziViewer-aa5b5706.js");case"../plots/WSIViewer.js":return import("./WSIViewer-afe97e2e.js");case"../plots/barchart.data.js":return import("./FilterRxComp-e8de560c.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-cecb7bf5.js");case"../plots/barchart.js":return import("./barchart-e3dcfc5f.js");case"../plots/bars.renderer.js":return import("./bars.renderer-58e38632.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-fed0a86b.js");case"../plots/brainImaging.js":return import("./brainImaging-b455fd0c.js");case"../plots/controls.btns.js":return import("./controls.btns-237b3154.js");case"../plots/controls.config.js":return import("./controls.config-00ce9f0b.js");case"../plots/controls.js":return import("./controls-1d99916a.js");case"../plots/cuminc.js":return import("./cuminc-879690b0.js");case"../plots/dataDownload.js":return import("./dataDownload-087ac205.js");case"../plots/dictionary.js":return import("./dictionary-fe0ea1d6.js");case"../plots/facet.js":return import("./facet-397afad5.js");case"../plots/geneExpression.js":return import("./geneExpression-52678025.js");case"../plots/geneORA.js":return import("./geneORA-81220ec0.js");case"../plots/geneset.js":return import("./geneset-604d0529.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-204f007e.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-9f0e8a60.js");case"../plots/gsea.js":return import("./gsea-a1b04406.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-a84f69a3.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-dd917fd3.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-edaaacc5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-4d33e96a.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-f96cdc61.js");case"../plots/matrix.cells.js":return import("./matrix.cells-4dd055e7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-7ab94fb5.js");case"../plots/matrix.config.js":return import("./matrix.config-b3b56456.js");case"../plots/matrix.controls.js":return import("./matrix.controls-6e0e9692.js");case"../plots/matrix.data.js":return import("./matrix.data-baabaf57.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-cb1f4872.js");case"../plots/matrix.groups.js":return import("./matrix.groups-9990aade.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-3f3cf44d.js");case"../plots/matrix.js":return import("./matrix-8b3341c4.js");case"../plots/matrix.layout.js":return import("./matrix.layout-50bc2ea5.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-024e2d50.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-1aed44e5.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-dc18fcc2.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-89b98e83.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-0ad98ef0.js");case"../plots/plot.app.js":return import("./plot.app-4dc30ebc.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-ee3a0272.js");case"../plots/plot.disco.js":return import("./plot.disco-c9249cbd.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-b5f68395.js");case"../plots/profileBarchart.js":return import("./profileBarchart-f4da0483.js");case"../plots/profilePlot.js":return import("./profilePlot-5dd1fe71.js");case"../plots/profilePolar.js":return import("./profilePolar-996784ad.js");case"../plots/profileRadar.js":return import("./profileRadar-79299186.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-00e31213.js");case"../plots/profileSummary.js":return import("./profileSummary-df75e6ff.js");case"../plots/regression.inputs.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-b283619d.js");case"../plots/regression.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-f61b4a25.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-aa51e3c8.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-e4819da2.js");case"../plots/scatter.js":return import("./scatter-ff17f653.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e7e57b0f.js");case"../plots/stattable.js":return import("./stattable-775a5af5.js");case"../plots/summary.js":return import("./summary-5866c75f.js");case"../plots/survival.js":return import("./survival-405514f6.js");case"../plots/table.js":return import("./table-e013d8fc.js");case"../plots/variantBrowser.js":return import("./variantBrowser-56ebc7e1.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-2502dcd8.js");case"../plots/violin.js":return import("./violin-1352dab2.js");case"../plots/violin.renderer.js":return import("./violin.renderer-4273257d.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}function dt(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-28ddd620.js");case"../plots/Disco.js":return import("./Disco-3c427131.js");case"../plots/DziViewer.js":return import("./DziViewer-aa5b5706.js");case"../plots/WSIViewer.js":return import("./WSIViewer-afe97e2e.js");case"../plots/barchart.data.js":return import("./FilterRxComp-e8de560c.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-cecb7bf5.js");case"../plots/barchart.js":return import("./barchart-e3dcfc5f.js");case"../plots/bars.renderer.js":return import("./bars.renderer-58e38632.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-fed0a86b.js");case"../plots/brainImaging.js":return import("./brainImaging-b455fd0c.js");case"../plots/controls.btns.js":return import("./controls.btns-237b3154.js");case"../plots/controls.config.js":return import("./controls.config-00ce9f0b.js");case"../plots/controls.js":return import("./controls-1d99916a.js");case"../plots/cuminc.js":return import("./cuminc-879690b0.js");case"../plots/dataDownload.js":return import("./dataDownload-087ac205.js");case"../plots/dictionary.js":return import("./dictionary-fe0ea1d6.js");case"../plots/facet.js":return import("./facet-397afad5.js");case"../plots/geneExpression.js":return import("./geneExpression-52678025.js");case"../plots/geneORA.js":return import("./geneORA-81220ec0.js");case"../plots/geneset.js":return import("./geneset-604d0529.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-204f007e.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-9f0e8a60.js");case"../plots/gsea.js":return import("./gsea-a1b04406.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-a84f69a3.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-dd917fd3.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-edaaacc5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-4d33e96a.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-f96cdc61.js");case"../plots/matrix.cells.js":return import("./matrix.cells-4dd055e7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-7ab94fb5.js");case"../plots/matrix.config.js":return import("./matrix.config-b3b56456.js");case"../plots/matrix.controls.js":return import("./matrix.controls-6e0e9692.js");case"../plots/matrix.data.js":return import("./matrix.data-baabaf57.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-cb1f4872.js");case"../plots/matrix.groups.js":return import("./matrix.groups-9990aade.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-3f3cf44d.js");case"../plots/matrix.js":return import("./matrix-8b3341c4.js");case"../plots/matrix.layout.js":return import("./matrix.layout-50bc2ea5.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-024e2d50.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-1aed44e5.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-dc18fcc2.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-89b98e83.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-0ad98ef0.js");case"../plots/plot.app.js":return import("./plot.app-4dc30ebc.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-ee3a0272.js");case"../plots/plot.disco.js":return import("./plot.disco-c9249cbd.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-b5f68395.js");case"../plots/profileBarchart.js":return import("./profileBarchart-f4da0483.js");case"../plots/profilePlot.js":return import("./profilePlot-5dd1fe71.js");case"../plots/profilePolar.js":return import("./profilePolar-996784ad.js");case"../plots/profileRadar.js":return import("./profileRadar-79299186.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-00e31213.js");case"../plots/profileSummary.js":return import("./profileSummary-df75e6ff.js");case"../plots/regression.inputs.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-b283619d.js");case"../plots/regression.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-f61b4a25.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.a}));case"../plots/sampleScatter.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.b}));case"../plots/sampleScatter.renderer.js":return import("./sampleScatter-b96546e9.js").then((function(t){return t.s}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-aa51e3c8.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-e4819da2.js");case"../plots/scatter.js":return import("./scatter-ff17f653.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e7e57b0f.js");case"../plots/stattable.js":return import("./stattable-775a5af5.js");case"../plots/summary.js":return import("./summary-5866c75f.js");case"../plots/survival.js":return import("./survival-405514f6.js");case"../plots/table.js":return import("./table-e013d8fc.js");case"../plots/variantBrowser.js":return import("./variantBrowser-56ebc7e1.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-2502dcd8.js");case"../plots/violin.js":return import("./violin-1352dab2.js");case"../plots/violin.renderer.js":return import("./violin.renderer-4273257d.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}const mt="_MASS_AUTOID_"+Math.random().toString().slice(-6);let ut=(+new Date).toString().slice(-8);function ht(){return mt+"_"+ut++}const ft=new Set(["with_tabs","hidden","search_only","hide_search","only_buttons","with_cohortHtmlSelect"]);const gt={nav:{header_mode:"with_tabs",activeTab:0},activeCohort:0,search:{isVisible:true},plots:[],termfilter:{filter:{type:"tvslst",in:true,join:"",lst:[]}},reuse:{customTermQ:{byId:{},byName:{}}},groups:[],customTerms:[],autoSave:true};class bt{constructor(t){this.type="store";this.defaultState=gt;this.prevGeneratedId=0}validateOpts(t){const e=t.state;if(e.vocab.dslabel){if(!e.vocab.genome)throw".state[.vocab].genome missing"}else{if(!Array.isArray(e.vocab.terms))throw"vocab.terms must be an array of objects"}}validateState(){if(!ft.has(this.state.nav.header_mode))throw"invalid state.nav.header_mode"}async init(){try{this.state.termdbConfig=await this.app.vocabApi.getTermdbConfig();await this.setTermfilter();await this.rehydrateGroups();await this.app.vocabApi.main({termfilter:JSON.parse(JSON.stringify(this.state.termfilter)),termdbConfig:this.state.termdbConfig});const t=[];for(const[e,s]of this.state.plots.entries()){let r;try{const t=await dt(`../plots/${s.chartType}.js`);r=await t.getPlotConfig(s,this.app)}catch(t){this.app.printError(t);console.error(`getPlotConfig() failed: ${t}`)}if(!r){t.push(e);continue}this.state.plots[e]=r;if(!("id"in r))r.id=`_AUTOID_${ut++}_${e}`;if(r.mayAdjustConfig)r.mayAdjustConfig(r)}if(t.length){for(const e of t){this.state.plots.splice(e,1)}}}catch(t){throw t}}setId(t){t.$id=this.prevGeneratedId++;if(t.$lst){for(const e of t.$lst){this.setId(e)}}}async setTermfilter(){let t=y(this.state.termfilter.filter,"filterUiRoot");if(!t){this.state.termfilter.filter.tag="filterUiRoot";t=this.state.termfilter.filter}await Promise.all(_(this.state.termfilter.filter,this.app.vocabApi));if(!this.state.termdbConfig.selectCohort){this.state.activeCohort=-1;if(this.state.activeTab===0)this.state.activeTab=1;if(this.state.nav.header_mode==="with_cohortHtmlSelect"){console.warn(`no termdbConfig.selectCohort to use for nav.header_mode = 'with_cohortHtmlSelect'`);this.state.nav.header_mode="search_only"}}else{let e=y(this.state.termfilter.filter,"cohortFilter");if(!e){e={tag:"cohortFilter",type:"tvs",tvs:{term:JSON.parse(JSON.stringify(this.state.termdbConfig.selectCohort.term)),values:this.state.activeCohort==-1?[]:this.state.termdbConfig.selectCohort.values[this.state.activeCohort].keys.map((t=>({key:t,label:t})))}};this.state.termfilter.filter={type:"tvslst",in:true,join:"and",lst:[e,t]}}else{const t=(t,e)=>t<e?-1:1;e.tvs.values.sort(((t,e)=>t.key<e.key?-1:1));const s=JSON.stringify(e.tvs.values.map((t=>t.key)).sort(t));const r=this.state.termdbConfig.selectCohort.values.findIndex((e=>s==JSON.stringify(e.keys.sort(t))));if(this.state.activeCohort!==-1&&this.state.activeCohort!==0&&r!==this.state.activeCohort){console.log("Warning: cohortFilter will override the state.activeCohort due to mismatch")}this.state.activeCohort=r}}}async rehydrateGroups(){const t=[];for(const e of this.state.groups){t.push(..._(e.filter,this.app.vocabApi))}await Promise.all(t)}}bt.prototype.actions={app_refresh(t={}){this.state=this.copyMerge(this.toJson(this.state),t.state||{});const e=new Set;if(t.subactions){for(const s of t.subactions){this.actions[s.type].call(this,s);if(s.type.startsWith("plot_"))e.add(s.id)}}for(const s in this.state.plots){if(s.mayAdjustConfig&&!e.has(s.id)){s.mayAdjustConfig(s,t.config)}}},tab_set(t){this.state.nav.activeTab=t.activeTab},cohort_set(t){this.state.activeCohort=t.activeCohort;const e=this.state.termdbConfig.selectCohort.values[t.activeCohort];const s=y(this.state.termfilter.filter,"cohortFilter");if(!s)throw`No item tagged with 'cohortFilter'`;s.tvs.values=e.keys.map((t=>({key:t,label:t})))},async plot_prep(t){const e={id:"id"in t?t.id:ht()};if(!t.config)throw".config{} missing for plot_prep";if(t.config.chartType&&Object.keys(t.config).length==1){const e=await ct(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);t.config=Object.assign(s,t.config)}Object.assign(e,t.config);this.state.plots.push(e)},async plot_create(t){const e=await pt(`../plots/${t.config.chartType}.js`);const s=await e.getPlotConfig(t.config,this.app);if(!("id"in t))t.id=ht();s.id=t.id;if(s.mayAdjustConfig){s.mayAdjustConfig(s,t.config)}this.state.plots.push(s)},plot_edit(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit()`;this.copyMerge(e,t.config,t.opts?t.opts:{});if(e.mayAdjustConfig){e.mayAdjustConfig(e,t.config)}if(t.config&&"cutoff"in t.config){e.cutoff=t.config.cutoff}else{delete e.cutoff}},plot_delete(t){const e=this.state.plots.findIndex((e=>e.id===t.id));if(e!==-1)this.state.plots.splice(e,1)},plot_nestedEdits(t){const e=this.state.plots.find((e=>e.id===t.id));if(!e)throw`missing plot id='${t.id}' in store.plot_edit_nested`;for(const s of t.edits){const t=s.nestedKeys.pop();const r=s.nestedKeys.reduce(((t,e)=>t[e]),e);r[t]=s.value}},async plot_splice(t){for(const e of t.subactions){await this.actions[e.type].call(this,e)}},filter_replace(t){if("filter0"in t){this.state.termfilter.filter0=t.filter0;return}const e=t.filter?t.filter:{type:"tvslst",join:"",in:1,lst:[]};if(!t.filter.tag){this.state.termfilter.filter=e}else{const s=y(this.state.termfilter.filter,t.filter.tag);if(!s)throw`cannot replace missing filter with tag '${t.filter.tag}'`;const r=v(this.state.termfilter.filter,s.$id);if(r==s){this.state.termfilter.filter=e}else{const t=r.lst.indexOf(s);r.lst[t]=e}}},cache_termq({termId:t,q:e}){if(!t)throw`missing termId for caching custom term.q`;if(!e?.reuseId)throw`missing or empty tw.q.reuseId as cache identifier for term='${t}'`;const s=this.state.reuse.customTermQ.byId;if(!s[t])s[t]={};s[t][e.reuseId]=e;for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t?.q?.reuseId===e.reuseId)t.q=e}}},uncache_termq({term:t,q:e}){if(!t.id)throw`missing term.id for uncaching custom term.q`;if(!e.reuseId)throw`missing qname as uncache identifier for term.id='${t.id}'`;const s=this.state.reuse.customTermQ.byId[t.id];if(!s)throw`missing term.q cache for term.id='${t.id}`;if(!(e.reuseId in s))console.warn(`q.reuseId='${e.cacheid}' not cached for term.id='${t.id}'`);else{delete s[e.reuseId];for(const t of this.state.plots){if(!(t.chartType in yt))continue;const s=yt[t.chartType](t);for(const t of s){if(t.q.reuseId===e.reuseId){delete t.q.reuseId;delete t.q.name}}}}},add_customTerm(t){this.state.customTerms.push(t.obj)},delete_customTerm({name:t}){const e=this.state.customTerms.findIndex((e=>e.name==t));if(e!=-1)this.state.customTerms.splice(e,1)},add_group(t){if(this.state.nav.header_mode!="hidden"){const e=t.obj;const s=`Group ${this.state.groups.length+1}`;const r=lt([e]);const i={name:s,filter:at(r),plotId:e.plotId};this.state.groups.push(i);this.state.nav.activeTab=1}else if("plotId"in t.obj){const e=this.state.plots.find((e=>e.id==t.obj.plotId));if(e.groups){t.obj.index=e.groups.length;t.obj.name=`Group ${e.groups.length+1}`;e.groups.push(t.obj)}}},rename_group(t){const e=t.index;const s=t.newName;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].name=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].name=s}}}},change_color_group(t){const e=t.index;const s=t.newColor;if(this.state.nav.header_mode!="hidden"){this.state.groups[e].color=s}else{for(const t of this.state.plots){if(t?.groups){t.groups[e].color=s}}}},delete_group({name:t}){if(this.state.nav.header_mode!="hidden"){const e=this.state.groups.findIndex((e=>e.name==t));if(e!=-1)this.state.groups.splice(e,1)}else{for(const e of this.state.plots){if(e?.groups){const s=e.groups.findIndex((e=>e.name==t));if(s!=-1)e.groups.splice(s,1)}}}}};const jt=t=>[t.term0,t.term,t.term2].filter((t=>!!t));const yt={summary:jt,survival:jt,cuminc:jt,regression:t=>[t.outcome,...t.independent].filter((t=>!!t)),matrix:t=>t.termgroups.reduce(((t,e)=>{t.push(...e.lst);return t}),[])};const vt=d(bt);class xt{constructor(t={}){this.type="recover";this.initialHolderDisplay=t.holder.style("display");this.dom={holder:t.holder,btnDiv:t.holder.append("div").style("position","sticky").style("top","12px").style("right","20px").style("margin",t.margin?t.margin:"10px").style("text-align","right")};this.hasStatePreMain=true;this.reactsTo=t.reactsTo||(()=>true);this.getState=t.getState||(t=>t);this.debouncedTrack=()=>{this.trackPending=true;this.trackState();this.render()};this.wait="wait"in t?t.wait:800;this.maxHistoryLen=t.maxHistoryLen||10}preApiFreeze(t){t.replaceLastState=t=>{if(this.isRecovering)return;this.state=this.getState(t);if(!this.trackPending)this.history[this.currIndex]=this.state}}init(){this.app.register(this.api);this.currIndex=-1;this.history=[];this.isActive=!isNaN(this.maxHistoryLen)&&+this.maxHistoryLen>0;if(this.isActive){Ct(this);this.initUi()}this.eventTypes=["postInit","postRender"]}async main(){if(!this.isActive)return;if(this.opts.hide?.(this.state)){this.dom.holder.style("display","none");return}this.dom.holder.style("display",this.initialHolderDisplay||"");if(!this.timedTrack){this.trackState();this.trackPending=true;this.timedTrack=setTimeout((()=>{}),this.wait);return}clearTimeout(this.timedTrack);this.trackPending=true;this.timedTrack=setTimeout(this.debouncedTrack,this.wait)}trackState(){if(this.isRecovering){this.isRecovering=false;return}if(this.state._scope_=="none")return;this.isRecovering=false;const t=this.opts.adjustTrackedState?this.opts.adjustTrackedState(this.state):this.state;if(!t){console.error("no state to track");return}if(!Object.isFrozen(t))m(t);if(this.currIndex==-1)this.origState=t;if(this.currIndex<this.history.length-1){this.history.splice(this.currIndex,this.history.length-(this.currIndex+1))}if(u(t,this.history[this.history.length-1]))return;this.history.push(t);this.currIndex+=1;if(this.history.length>this.maxHistoryLen){this.history.splice(1,1);this.currIndex+=-1}this.trackPending=false}goto(t){if(t<0&&this.currIndex+t>-1)this.currIndex+=t;else if(t>0&&this.currIndex+t<this.history.length)this.currIndex+=t;else return;this.isRecovering=true;const e=this.history[this.currIndex];this.render();if(this.opts.plot_id){const t=structuredClone(e);this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:t.config,_scope_:t._scope_})}else{this.app.dispatch({type:"app_refresh",state:e})}}reset(){this.currIndex=0;this.isRecovering=true;const t=this.origState;if(this.opts.plot_id){const e=t.plots.find((t=>t.id===this.opts.plot_id));this.app.dispatch({type:"plot_edit",id:this.opts.plot_id,config:structuredClone(e)})}else this.app.dispatch({type:"app_refresh",state:t})}}const wt=n(xt);function Ct(t){t.initUi=function(){t.dom.undoBtn=t.dom.btnDiv.append("button").attr("aria-label","undo the previous action").property("disabled",true).style("margin","0 0 0 4px").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.undoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-counterclockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(-1)));t.dom.redoBtn=t.dom.btnDiv.append("button").attr("aria-label","redo a subsequent action").property("disabled",true).style("margin",t.opts.resetHtml?"0":"0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.redoHtml||`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#000" class="bi bi-arrow-clockwise" viewBox="0 0 16 16" style='vertical-align: middle'>\n\t\t\t <path stroke='#000' stroke-width='0.25' fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/>\n\t\t\t <path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>\n\t\t\t</svg>`).on("click",(()=>t.goto(1)));if(t.opts.resetHtml)t.dom.resetBtn=t.dom.btnDiv.append("button").attr("aria-label","Restore the initial rendered state").property("disabled",true).style("margin","0 4px 0 0").style("border","1px solid #ccc").style("vertical-align","middle").html(t.opts.resetHtml).on("click",(()=>t.reset()))};t.render=function(){if(t.dom.undoBtn)t.dom.undoBtn.property("disabled",t.currIndex<1||t.history.length===1);if(t.dom.redoBtn)t.dom.redoBtn.property("disabled",t.history.length<2||t.currIndex>=t.history.length-1);if(t.dom.resetBtn)t.dom.resetBtn.property("disabled",t.currIndex===0)}}export{G,lt as a,at as b,R as c,ot as d,it as e,st as f,z as g,et as h,N as i,Y as j,nt as k,Z as o,wt as r,vt as s};
@@ -1 +0,0 @@
1
- import{bL as e,y as t,I as n,f as s}from"./app-3d14cbe4.js";import{a as r}from"./axisstyle-fac7f76b.js";import{C as o}from"./ColorScale-4b4ea8a2.js";import{a as i}from"./axis-747c801e.js";import{l as a}from"./log-0ea548ec.js";function p({bp:e,g:t,color:n,scale:s,rowheight:r,labpad:o}){if(e.label){t.append("text").attr("font-family","Arial").attr("text-anchor","end").attr("dominant-baseline","central").attr("fill",n).attr("x",-o).attr("y",r/2).attr("font-size",Math.min(15,r)).text(e.label)}if(e.w1!=undefined){const o=s(e.w1);const i=s(e.w2);const a=s(e.p25);const p=s(e.p50);const l=s(e.p75);e.hline=t.append("line").attr("stroke",n).attr("shape-rendering","crispEdges").attr("x1",o).attr("x2",i).attr("y1",r/2).attr("y2",r/2);e.linew1=t.append("line").attr("stroke",n).attr("shape-rendering","crispEdges").attr("x1",o).attr("x2",o).attr("y1",0).attr("y2",r);e.linew2=t.append("line").attr("stroke",n).attr("shape-rendering","crispEdges").attr("x1",i).attr("x2",i).attr("y1",0).attr("y2",r);e.box=t.append("rect").attr("fill","white").attr("stroke",n).attr("shape-rendering","crispEdges").attr("x",a).attr("y",0).attr("width",l-a).attr("height",r);e.linep50=t.append("line").attr("stroke",n).attr("shape-rendering","crispEdges").attr("x1",p).attr("x2",p).attr("y1",0).attr("y2",r)}for(const o of e.out){t.append("circle").attr("stroke",n).attr("fill","white").attr("fill-opacity",0).attr("cx",s(o.value)).attr("cy",r/2).attr("r",r/3)}}function l(e,t,n,s){const r=[];if(Array.isArray(e)){for(const o of e){if(o.namekey=="regulomedb"){if(typeof t.chr=="string"&&t.pos!==undefined&&Number.isInteger(t.pos)){const e=`${t.chr}%3A${t.pos}-${t.pos+1}`;r.push(`<a href="${o.base}regions=${e}&genome=${s=="hg38"?"GRCh38":s}" target="_blank">${o.linkText}</a>`)}continue}c(o,t,n,r)}}else{c(e,t,n,r)}return r}function c(e,t,n,s){const r=t[e.namekey];if(r==undefined)return;const o=e.base+r;if(e.shownSeparately){s.push(`<a href="${o}" target="_blank">${e.linkText||r}</a>`);return}n.html(`<a href="${o}" target="_blank">${n.html()}</a>`)}const d="NA";const f="#126e08";const m=f;class u{constructor(e){this.opts=e;this.app=e.app;this.parent=e.parent;this.type="regression";g(this);const t=this.opts.holder;t.append("div").style("margin-top","10px").style("padding-top","20px").style("font-size","1.2em").style("opacity",.3).html("Results");this.dom={holder:t,err_div:t.append("div"),snplocusBlockDiv:t.append("div"),oneSetResultDiv:t.append("div").style("margin","10px")}}async main(){try{this.parent.inputs.dom.submitBtn.text("Running...");this.config=this.parent.config;this.state=this.parent.state;if(!this.state.formIsComplete||this.parent.inputs.hasError||this.config.hasUnsubmittedEdits&&!this.hasUnsubmittedEdits_nullify_singleuse){this.dom.holder.style("display","none");return}delete this.hasUnsubmittedEdits_nullify_singleuse;if(this.snplocusBlock){this.snplocusBlock.cloakOn()}const e=await this.app.vocabApi.getRegressionData(this.getDataRequestOpts());if(e.error)throw e.error;this.dom.err_div.style("display","none");this.dom.oneSetResultDiv.selectAll("*").remove();this.dom.holder.style("display","block");await this.displayResult(e);const t=this.dom.holder.node().getBoundingClientRect().top+window.scrollY;const n=document.querySelector(".sjpp-nav").getBoundingClientRect().height;window.scroll({behavior:"smooth",top:t-n})}catch(e){this.hasError=true;this.dom.holder.style("display","block");this.dom.err_div.style("display","block");t(this.dom.err_div,"Error: "+(e.error||e));this.parent.inputs.dom.submitBtn.property("disabled",true);console.error(e)}}getDataRequestOpts(){const e=this.config;const t={regressionType:e.regressionType,outcome:e.outcome,independent:e.independent};t.filter=this.parent.filter;return t}getIndependentInput(e){for(const t of this.parent.inputs.independent.inputLst){if(!t.term)continue;if(t.term.term.id==e||t.term.term.name==e)return t;if(t.term.term&&t.term.term.snps){for(const n of t.term.term.snps){if(n.snpid==e){const s={id:e,q:{geneticModel:t.term.q.geneticModel},term:{id:e,name:e},effectAllele:t.term.q.snp2effAle[e]};if(t.term.q.snp2refGrp){s.refGrp=t.term.q.snp2refGrp[e]}if(n.mlst){const r=n.mlst.find((n=>n.alt==t.term.q.snp2effAle[e]));if(r){s.term.name=r.mname}else{s.term.name=n.mlst[0].mname}}return{term:s}}}}}return{term:{id:e,q:{},term:{name:e}}}}}function g(e){e.displayResult=async t=>{const n=e.parent.inputs.independent.inputLst.find((e=>e.term&&e.term.term.type=="snplocus"));if(n){if(!e.snplocusBlock){e.dom.snplocusBlockDiv.append("div").style("margin-top","30px").style("opacity",.3).text("Click on a variant within the browser to view its regression results");e.snplocusBlock=await b(e,n,t.resultLst)}else{await v(e,n,t.resultLst)}return}delete e.snplocusBlock;e.dom.snplocusBlockDiv.selectAll("*").remove();if(!t.resultLst[0]||!t.resultLst[0].data)throw"result is not [ {data:{}} ]";e.displayResult_oneset(t.resultLst[0].data)};e.displayResult_oneset=t=>{e.dom.oneSetResultDiv.selectAll("*").remove();e.dom.LDresultDiv=e.dom.oneSetResultDiv.append("div");e.mayshow_warn(t);if(t.sampleSize)e.newDiv("Sample size:",t.sampleSize);if(t.eventCnt)e.newDiv("Number of events:",t.eventCnt);e.mayshow_headerRow(t);e.mayshow_splinePlots(t);e.mayshow_residuals(t);e.mayshow_coefficients(t);e.mayshow_totalSnpEffect(t);e.mayshow_type3(t);e.mayshow_tests(t);e.mayshow_other(t);e.mayshow_fisher(t);e.mayshow_wilcoxon(t);e.mayshow_cuminc(t)};e.newDiv=(t,n,s)=>{const r=e.dom.oneSetResultDiv.append("div").style("margin","20px 0px 10px 0px").attr("name",t);const o=r.append("div");o.append("span").style("text-decoration","underline").text(t);if(n){o.append("span").html(n).style("margin-left","5px")}return s?o:r.append("div").style("margin-left","20px")};e.mayshow_warn=t=>{if(!t.warnings)return;const n=e.newDiv("Warnings");const s=new Set(t.warnings);for(const e of s){n.append("p").style("margin","5px").text(e)}};e.mayshow_headerRow=t=>{if(!t.headerRow)return;const n=t.headerRow.k;const s=t.headerRow.v;const r=e.parent.inputs.independent.inputLst.find((e=>e.term&&e.term.term.type=="snplocus"));if(r){const t=r.term.term.snps.find((e=>e.snpid==s.snpid));const o=t.mlst[0];o.chr=t.chr;const i=e.newDiv(n,null,true);const a=i.append("span").text(`${o.chr}:${o.pos+1} ${o.ref&&o.alt?o.ref+">"+o.alt:""}`).style("margin-left","5px");const p=e.app.vocabApi.termdbConfig.urlTemplates?.ssm||e.app.vocabApi.termdbConfig.queries?.snvindel?.ssmUrl;if(p){const t=l(p,o,a,e.parent.genomeObj.name);if(t?.length){i.append("span").style("margin-left","10px").html(t.join(" "))}}let c;const d=`Genotypes: ${s.gtcounts.join(", ")}`;if(s.monomorphic){c=[d]}else{const e=`Effect allele: ${s.effAle}`;const t=`Allele frequency: ${s.af}`;c=[e,t,d]}i.append("span").html(`&nbsp;&#65372;&nbsp;${c.join("&nbsp;&#65372;&nbsp;")}`)}else{e.newDiv(n,s)}};e.mayshow_splinePlots=t=>{if(!t.splinePlots)return;const n=e.newDiv("Cubic spline plots");for(const e of t.splinePlots){n.append("img").attr("src",e.src).style("width",e.size.width).style("height",e.size.height)}};e.mayshow_residuals=t=>{if(!t.residuals)return;const n=e.newDiv(t.residuals.label);const s=n.append("table").style("border-spacing","8px").attr("name","sjpp-residuals-table");const r=s.append("tr").style("opacity",.4);const o=s.append("tr");for(let e=0;e<t.residuals.header.length;e++){r.append("td").text(t.residuals.header[e]);o.append("td").text(t.residuals.rows[e])}};e.mayshow_cuminc=async t=>{if(!t.cuminc)return;const n=e.newDiv("Cumulative incidence test:");const s=await import("./cuminc-879690b0.js");const r=new s.Cuminc({holder:n,config:{term:e.config.outcome,term2:{term:{name:"Variant",values:{1:{key:1,label:"Has minor allele"},2:{key:2,label:"No minor allele"}}}}}});if(t.cuminc.ci_data){r.main(t.cuminc.ci_data)}else{n.append("div").style("margin","20px").text(t.cuminc.msg)}};e.mayshow_wilcoxon=t=>{if(!t.wilcoxon)return;const s=e.newDiv("Wilcoxon rank sum test:","p-value = "+t.wilcoxon.pvalue);if(t.wilcoxon.boxplots){const o=t.wilcoxon.boxplots;const a=20,l=400,c=160,d=40,f=20,u=10;const g=n().domain([o.minv,o.maxv]).range([0,l]);const h=s.append("svg").style("margin-top","10px").attr("width",c+f+l+10).attr("height",u*3+a*2+d);const y=h.append("g").attr("transform",`translate(${c+f},${u})`);p({g:y.append("g"),bp:o.hasEff,scale:g,rowheight:a,color:m,labpad:f});p({g:y.append("g").attr("transform",`translate(0,${a+u})`),bp:o.noEff,scale:g,rowheight:a,color:m,labpad:f});{const t=y.append("g").attr("transform",`translate(0,${a*2+u*2})`);const n=i().scale(g);r({axis:t.call(n),color:m,showline:true});t.append("text").text(e.config.outcome.term.name).attr("font-size",15).attr("x",l/2).attr("y",d-5).attr("text-anchor","middle").attr("fill",m)}}};e.mayshow_fisher=t=>{if(!t.fisher)return;const n=e.newDiv(t.fisher.isChi?"Chi-square test:":"Fisher's exact test:","p-value = "+t.fisher.pvalue);const s=n.append("table").style("margin","20px").style("border-spacing","5px").style("border-collapse","separate");for(const e of t.fisher.rows){const t=s.append("tr");for(const n of e){t.append("td").text(n)}}};e.mayshow_coefficients=t=>{if(!t.coefficients)return;const n=e.newDiv(t.coefficients.label);const s=n.append("table").style("border-spacing","0px").attr("data-testid","sjpp_regression_resultCoefficientTable");const r=e.config.regressionType=="cox"&&e.app.vocabApi.termdbConfig.neuroOncRegression;{const e=s.append("tr").style("opacity",.4);t.coefficients.header.forEach(((t,n)=>{if(r&&(n==2||n==3))return;e.append("td").text(t).style("padding","8px");if(n===1)e.append("td")}))}if(e.config.regressionType!="cox"){const e=s.append("tr").style("background","#eee");t.coefficients.intercept.forEach(((t,n)=>{e.append("td").text(t).style("padding","8px");if(n===1)e.append("td")}))}const o=e.getForestPlotter(t.coefficients.terms,t.coefficients.interactions,r);let i=e.config.regressionType=="cox"?1:0;for(const n in t.coefficients.terms){const a=t.coefficients.terms[n];const p=e.getIndependentInput(n).term;let l=s.append("tr").style("background",i++%2?"#eee":"none");const c=l.append("td").style("padding","8px");y(p,c);if(a.fields){const e=a.fields;{const e=l.append("td").style("padding","8px");N(e,p)}if(r){e.shift();e.shift()}o(l.append("td"),e);for(const t of e){l.append("td").text(t).style("padding","8px")}}else if(a.categories){const t=[];const d=e.getIndependentInput(n);if(d.orderedLabels){for(const e of d.orderedLabels){if(a.categories[e])t.push(e)}}for(const e in a.categories){if(!t.includes(e))t.push(e)}c.attr("rowspan",t.length).style("vertical-align","top");let f=true;for(const e of t){if(!f){l=s.append("tr").style("background",i++%2?"#eee":"none")}const t=a.categories[e];const n=l.append("td").style("padding","8px");N(n,p,e);if(r){const[e,s]=t.shift().split("/");const[r,o]=t.shift().split("/");if(f){const t=c.select(".sjpcb-regression-results-refGrp");t.append("div").html(`n = ${e}<br>events = ${r}`)}n.append("div").style("font-size",".8em").html(`n = ${s}<br>events = ${o}`)}o(l.append("td"),t);for(const e of t){l.append("td").text(e).style("padding","8px")}f=false}}else{l.append("td").text("ERROR: no .fields[] or .categories{}")}}for(const n of t.coefficients.interactions){const t=s.append("tr").style("background",i++%2?"#eee":"none");const r=e.getIndependentInput(n.term1).term;const a=e.getIndependentInput(n.term2).term;{const e=t.append("td").style("padding","8px");h(e.append("div"),r?r.term.name+" : ":n.term1+" : ");h(e.append("div"),a?a.term.name:n.term2)}{const e=t.append("td").style("padding","8px");N(e.append("div"),r,n.category1);N(e.append("div"),a,n.category2)}o(t.append("td"),n.lst);for(const e of n.lst){t.append("td").text(e).style("padding","8px")}}const a=s.append("tr");a.append("td");a.append("td");o(a.append("td"));for(const e of t.coefficients.header)a.append("td")};e.mayshow_totalSnpEffect=t=>{if(!t.totalSnpEffect)return;const n=e.newDiv(t.totalSnpEffect.label);const s=n.append("table").style("border-spacing","0px");{const e=s.append("tr").style("opacity",.4);for(const n of t.totalSnpEffect.header){e.append("td").text(n).style("padding","8px")}}const r=s.append("tr").style("background","#eee");for(const e of t.totalSnpEffect.lst){r.append("td").text(e).style("padding","8px")}const o=e.getIndependentInput(t.totalSnpEffect.snp).term;const i=t.totalSnpEffect.interactions.map((t=>({t1:e.getIndependentInput(t.term1).term,t2:e.getIndependentInput(t.term2).term})));const a=`Total: total effect of removing the snp (${o.term.name}) and its interactions (${i.map((e=>e.t1.term.name+" : "+e.t2.term.name)).join(" ; ")}) from the model`;n.append("div").style("margin","20px 0px 20px 10px").style("font-size",".8em").style("text-align","left").style("color","#999").text(a)};e.mayshow_type3=t=>{if(!t.type3||e.parent.app.vocabApi.termdbConfig.neuroOncRegression)return;const n=e.newDiv(t.type3.label);const s=n.append("table").style("border-spacing","0px");{const e=s.append("tr").style("opacity",.4);for(const n of t.type3.header){e.append("td").text(n).style("padding","8px")}}if(e.config.regressionType!="cox"){const e=s.append("tr").style("background","#eee");for(const n of t.type3.intercept){e.append("td").text(n).style("padding","8px")}}let r=e.config.regressionType=="cox"?1:0;for(const n in t.type3.terms){const o=t.type3.terms[n];const i=e.getIndependentInput(n).term;let a=s.append("tr").style("background",r++%2?"#eee":"none");const p=a.append("td").style("padding","8px");h(p,i.term.name);for(const e of o){a.append("td").text(e).style("padding","8px")}}for(const n of t.type3.interactions){const t=s.append("tr").style("background",r++%2?"#eee":"none");const o=e.getIndependentInput(n.term1).term;const i=e.getIndependentInput(n.term2).term;const a=t.append("td").style("padding","8px");h(a.append("div"),o.term.name+" : ");h(a.append("div"),i.term.name);for(const e of n.lst){t.append("td").text(e).style("padding","8px")}}};e.mayshow_tests=t=>{if(!t.tests||e.parent.app.vocabApi.termdbConfig.neuroOncRegression)return;const n=e.newDiv(t.tests.label);const s=n.append("table").style("border-spacing","0px");const r=s.append("tr").style("opacity",.4);for(const e of t.tests.header){r.append("td").text(e).style("padding","8px")}let o=0;for(const e of t.tests.rows){const t=s.append("tr").style("background",o++%2?"none":"#eee");for(const n of e){t.append("td").text(n).style("padding","8px")}}};e.mayshow_other=t=>{if(!t.other)return;const n=e.newDiv(t.other.label);const s=n.append("table").style("border-spacing","8px");for(let e=0;e<t.other.header.length;e++){const n=s.append("tr");n.append("td").style("opacity",.4).text(t.other.header[e]);n.append("td").text(t.other.rows[e])}};e.getForestPlotter=(t,s,o)=>{let p,l,c,d,m,u,g;if(e.config.regressionType=="linear"){p=0;l=1;c=2;d="Beta value";m=0;u=null;g=null}else if(e.config.regressionType=="logistic"){p=0;l=1;c=2;d="Odds ratio";m=1;u=.1;g=10}else if(e.config.regressionType=="cox"){p=0;l=1;c=2;d="Hazard ratio";m=1;u=.1;g=10}else{throw"unknown regressionType"}const h=[];for(const e in t){const n=t[e];if(n.fields){k(n.fields)}else{for(const e in n.categories){k(n.categories[e])}}}for(const e of s){k(e.lst)}if(h.length==0){return()=>{}}h.sort(((e,t)=>e-t));if(u==null){u=h[0];g=h[h.length-1]}const y=150;const x=20;const b=10,v=10;const w=_(h);return(t,n)=>{if(!w){return}const s=t.append("svg").attr("width",y+b+v).attr("height",x);const o=s.append("g").attr("transform","translate("+b+",0)");if(!n){const t=e.config.regressionType=="logistic"?".1r":undefined;const n=i().ticks(4,t).scale(w);r({axis:o.call(n),color:f,showline:true});const a=12;o.append("text").attr("fill",f).text(d).attr("x",y/2).attr("y",x+a);s.attr("height",x+a);return}{const e=w(m);o.append("line").attr("x1",e).attr("y1",0).attr("x2",e).attr("y2",x).attr("stroke","#ccc")}const a=Number(n[p]),h=Number(n[l]),k=Number(n[c]);if(Number.isNaN(a)){return}o.append("circle").attr("cx",w(Math.min(Math.max(a,u),g))).attr("cy",x/2).attr("r",3).attr("fill",f);if(Number.isNaN(h)||Number.isNaN(k)){return}o.append("line").attr("x1",w(Math.min(Math.max(h,u),g))).attr("y1",x/2).attr("x2",w(Math.min(Math.max(k,u),g))).attr("y2",x/2).attr("stroke",f)};function k(e){const t=o?e.slice(2):e;const n=Number(t[p]);if(!Number.isNaN(n))h.push(n);const s=Number(t[l]),r=Number(t[c]);if(!Number.isNaN(s)&&!Number.isNaN(r)){h.push(s);h.push(r)}}function _(t){if(e.config.regressionType=="logistic"){let e=0;while(t[e]<=0){e++}if(e>=t.length||t[e]<=0){return}const n=t[e];const s=t[t.length-1];return a().domain([Math.max(n,u),Math.min(s,g)]).range([0,y]).nice()}if(e.config.regressionType=="linear"||e.config.regressionType=="cox"){return n().domain([Math.max(t[0],u),Math.min(t[t.length-1],g)]).range([0,y])}throw"unknown type"}}}function h(e,t){if(t.length<40){e.text(t)}else{e.text(t.substring(0,35)+" ...").attr("aria-label",t)}}function y(e,t){h(t,e.term.name||tid);if(e.q.mode!="spline"&&"refGrp"in e&&e.refGrp!=d){const n=t.append("div").style("margin-top","2px").style("font-size",".8em");n.append("div").style("display","inline-block").style("vertical-align","top").style("padding","1px 5px").style("border","1px solid #aaa").style("border-radius","10px").style("font-size",".7em").text("REF");n.append("div").attr("class","sjpcb-regression-results-refGrp").style("display","inline-block").style("vertical-align","top").style("margin-left","3px").text(e.term.values&&e.term.values[e.refGrp]?e.term.values[e.refGrp].label:e.refGrp)}if(e.effectAllele){t.append("div").style("font-size",".8em").style("opacity",.6).html('<span style="padding:1px 5px;border:1px solid #aaa;border-radius:10px;font-size:.7em">EFFECT ALLELE</span> '+e.effectAllele+"</span>")}}function x(e,t){const n=[];for(const s of e.term.snps){const r={chr:s.chr,pos:s.pos,ssm_id:s.snpid};n.push(r);const o=e.q.snp2effAle[s.snpid];const i=s.mlst.find((e=>e.alt==o));if(i){Object.assign(r,i)}else{Object.assign(r,s.mlst[0])}r.regressionPvalue="NA";r.mlpv=0;const a=t.find((e=>e.id==s.snpid));if(!a){r.regressionResult={data:{err:["No result for this variant at "+s.snpid]}};continue}r.regressionResult=a;const p=a.data;if(!p)throw".data{} missing";if(p.type3){const e=A(p,s.snpid);if(e==undefined);else{r.regressionPvalue=e;r.mlpv=-Math.log10(e)}if(!p.coefficients||!p.coefficients.terms)throw".data.coefficients.terms{} missing";const t=p.coefficients.terms[s.snpid];if(!t)throw"snp missing from data.coefficients.terms{}";if(Array.isArray(t.fields)){r.regressionEstimate=t.fields[0]}else if(t.categories){const e=[];for(const n in t.categories){e.push(n+":"+t.categories[n][0])}r.regressionEstimate=" "+e.join(" ")}else{throw"unknown way to get snp estimates from coefficients table"}}else if(p.fisher){r.regressionPvalue=p.fisher.pvalue;r.mlpv=-Math.log10(p.fisher.pvalue);r.shapeTriangle=true}else if(p.wilcoxon){r.regressionPvalue=p.wilcoxon.pvalue;r.mlpv=-Math.log10(p.wilcoxon.pvalue);r.shapeTriangle=true}else if(p.cuminc){r.regressionPvalue=p.cuminc.pvalue;r.mlpv=-Math.log10(p.cuminc.pvalue);r.shapeTriangle=true}else{r.shapeCircle=true}}return n}async function b(e,t,n){const r={holder:e.dom.snplocusBlockDiv,genome:e.parent.genomeObj,chr:t.term.q.chr,start:t.term.q.start,stop:t.term.q.stop,nobox:true,tklst:[],onCoordinateChange:async n=>{for(const t of e.snplocusBlock.tklst){if(t.type=="mds3")delete t.skewer.hlssmid}const{chr:s,start:r,stop:o}=n[0];const i={term:{id:t.term.term.id,type:"snplocus"},q:JSON.parse(JSON.stringify(t.term.q))};i.q.chr=s;i.q.start=r;i.q.stop=o;const a=await import("./snplocus-0653ba82.js");await a.fillTW(i,e.app.vocabApi);e.hasUnsubmittedEdits_nullify_singleuse=true;t.pill.runCallback(i)}};r.tklst.push({type:"mds3",name:"Variants",skewerModes:[{type:"numeric",byAttribute:"mlpv",label:"-log10 p-value",inuse:true,tooltipPrintValue:t=>D(t,e.config.regressionType)}],custom_variants:x(t.term,n),variantShapeName:{dot:"common variants analyzed by model-fitting",triangle:"rare variants analyzed by "+(e.config.regressionType=="linear"?"Wilcoxon rank sum test":e.config.regressionType=="logistic"?"Fisher's exact test":"Cumulative incidence test"),circle:"monomorphic variants skipped"},click_snvindel:async n=>{e.displayResult_oneset(n.regressionResult.data);await R(n,t,e);const s=e.dom.oneSetResultDiv.node().getBoundingClientRect().top+window.scrollY;const r=document.querySelector(".sjpp-nav").getBoundingClientRect().height;window.scroll({behavior:"smooth",top:s-r})}});s(e.parent.genomeObj,r.tklst);const o=await import("./block-944afb9f.js").then((function(e){return e.c}));return new o.Block(r)}async function v(e,t,n){const s=e.snplocusBlock.tklst.find((e=>e.type=="mds3"));s.custom_variants=x(t.term,n);const r=e.snplocusBlock.rglst[0];if(r.chr==t.term.q.chr&&r.start==t.term.q.start&&r.stop==t.term.q.stop){s.load()}else{await e.snplocusBlock.jump_1basedcoordinate(t.term.q)}e.snplocusBlock.cloakOff()}const w="#2E6594",k="#ff0000",_=e(w,k);async function R(e,t,n){if(!t.term.q.restrictAncestry){return}const s=n.snplocusBlock.tklst.find((e=>e.type=="mds3"));if(!s||!s.skewer||!s.skewer.nmg)return;for(const e of s.custom_variants)delete e.regressionR2;const r=n.dom.LDresultDiv.append("span").text("Loading LD data...");try{const o=await n.app.vocabApi.getLDdata(t.term.q.restrictAncestry.name,e);if(o.error)throw o.error;if(o.nodata||!o.lst||o.lst.length==0){r.text("No LD data");s.skewer.nmg.selectAll(".sja_aa_disk_fill").attr("fill",(e=>e.shapeCircle?"none":s.color4disc(e)));return}s.skewer.nmg.selectAll(".sja_aa_disk_fill").attr("fill",(t=>{if(t.pos==e.pos&&t.ref==e.ref&&t.alt==e.alt){return k}for(const e of o.lst){if(e.pos==t.pos&&e.alleles==t.ref+"."+t.alt){t.regressionR2=e.r2;return _(e.r2)}}return _(0)}));r.html(t.term.q.restrictAncestry.name+" LD r<sup>2</sup>");E(n.dom.LDresultDiv,_)}catch(e){r.text("Error: "+(e.message||e))}}function E(e,t){const n=e.append("span").style("margin-left","10px");const s=[];for(let e=0;e<=1;e+=.1){s.push(t(e))}const r=20;const i=15;const a=10;const p=150;const l=new o({holder:n,data:[0,1],topTicks:true,width:a*2+p,height:r+i,barheight:i,barwidth:p,fontSize:12,startColor:s[0],midColor:s[s.length-1],endColor:s[s.length-1],position:`${a},${r}`,tickSize:6});l.render()}function D(e,t){const n=[{k:"p-value",v:e.regressionPvalue}];if(e.regressionResult.AFstr){n.push({k:"AF",v:e.regressionResult.AFstr})}if(e.regressionEstimate){if(t=="linear")n.push({k:"beta",v:e.regressionEstimate});else if(t=="logistic")n.push({k:"odds ratio",v:e.regressionEstimate});else if(t=="cox")n.push({k:"hazard ratio",v:e.regressionEstimate});else throw"unknown regression type"}if(e.regressionR2){n.push({k:"LD r2",v:e.regressionR2})}return n}function A(e,t){let n;if(e.totalSnpEffect){n=e.totalSnpEffect.lst[e.totalSnpEffect.lst.length-1]}else{if(!e.type3.terms)throw".data{type3:{terms}} missing";if(!e.type3.terms[t])throw t+" missing in type3.terms{}";if(!Array.isArray(e.type3.terms[t]))throw`type3.terms[${snp.snpid}] not array`;n=e.type3.terms[t][e.type3.terms[t].length-1]}const s=Number(n);if(Number.isFinite(s)){return s}return undefined}function N(e,t,n){if(n){e.text(t&&t.term.values&&t.term.values[n]?t.term.values[n].label:n);return}e.style("opacity",.3);if("geneticModel"in t.q){const n=t.q.geneticModel;e.text(n==0?"(additive)":n==1?"(dominant)":"(recessive)");return}if(t.q.mode){e.text("("+t.q.mode+")");return}}var q=Object.freeze({__proto__:null,RegressionResults:u,showLDlegend:E});export{u as R,l as m,q as r,E as s};
@@ -1 +0,0 @@
1
- import{h as t,M as e,a as s,d as o,y as a,J as i,b as n,K as r,I as l,r as c,L as p,N as d,O as h,B as m,z as f,n as u,P as g,Q as y}from"./app-3d14cbe4.js";import{c as b,f as v}from"./termsetting-7467350f.js";import{controlsInit as x}from"./controls-1d99916a.js";import{d as S}from"./zoom-001c2f01.js";import{d as w}from"./lasso-845446b8.js";import{c as C,g as j,r as T,a as k,b as D,d as _,e as A,f as O,h as W,o as L,i as M,j as $}from"./recover-4888c2a9.js";import{t as z,s as I}from"./shapes-21ebfec4.js";import{r as N}from"./table-be2a9975.js";import{a as G,b as R,c as q}from"./FilterRxComp-e8de560c.js";import{searchSampleInput as V}from"./sampleView-e4819da2.js";import{s as E}from"./select2Terms-eb437c2a.js";import{d as F}from"./svg.download-cd895635.js";import{s as P}from"./sampleScatter.rendererThree-aa51e3c8.js";import{a as U,b as B,c as H}from"./axis-747c801e.js";import{l as K}from"./line-264f8f9e.js";class Y{constructor(t){this.type="search";X(this);Q(this)}async init(t){this.dom={holder:this.opts.holder,holderNode:this.opts.holder.node(),tip:new e({padding:"5px"})};this.initUI()}reactsTo(t){return t.type.startsWith("search")||t.type.startsWith("cohort")}getState(t){return{cohortStr:t.activeCohort==-1||!t.termdbConfig.selectCohort?"":t.termdbConfig.selectCohort.values[t.activeCohort].keys.slice().sort().join(","),search:t.search,nav:t.nav}}async main(){this.dom.holder.style("display",this.state.search.isVisible&&this.state.nav.header_mode!="only_buttons"?"inline-block":"none")}async doSearch(t){if(!t){this.clear({hide:true});this.bus.emit("postSearch",[]);return}const e=await this.app.vocabApi.findTerm(t,this.state.cohortStr,this.opts.usecase,this.opts.targetType);if(!e.lst||e.lst.length==0){this.noResult()}else{this.showTerms(e)}this.bus.emit("postSearch",e)}}const J=t(Y);function X(t){t.initUI=()=>{t.dom.holder.style("display",t.search&&t.search.isVisible==false?"none":"inline-block");t.dom.input=t.dom.holder.style("text-align","center").append("input").attr("type","search").attr("class","tree_search").attr("placeholder","Search").style("width","180px").style("display","block").on("input",s.debounce(t.onInput,300));t.dom.resultDiv=t.dom.tip.d.style("border-left",t.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("padding-left","5px")};t.noResult=()=>{t.clear();t.dom.resultDiv.append("div").text("No match").style("padding","3px 3px 3px 0px").style("opacity",.5)};t.showTerms=e=>{if(t.opts.disable_terms)e.lst.forEach((e=>{if(e.disabled)t.opts.disable_terms.push(e)}));t.clear({hide:!e.lst.length});if(e.lst.length){t.dom.resultDiv.append("table").selectAll().data(e.lst).enter().append("tr").each(t.showTerm)}};t.showTerm=function(e){const s=o(this);const a=s.append("td").text(e.name);if(e.type){a.style("cursor","pointer").attr("class","sja_menuoption").on("click",(()=>{t.app.dispatch({type:"plot_create",config:{chartType:e.type=="survival"?"survival":"summary",term:{term:e}}});t.clear({hide:true})}))}else{a.style("padding","5px 10px").style("opacity",.5)}s.append("td").text((e.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};t.clear=(e={})=>{t.dom.tip.clear();if(e.hide)t.dom.tip.hide();else t.dom.tip.showunder(t.dom.holderNode)}}function Q(t){t.onInput=async()=>{const e=t.dom.input.property("value");try{await t.doSearch(e)}catch(e){t.clear();a(t.dom.resultDiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}}}function Z(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-28ddd620.js");case"../plots/Disco.js":return import("./Disco-3c427131.js");case"../plots/DziViewer.js":return import("./DziViewer-aa5b5706.js");case"../plots/WSIViewer.js":return import("./WSIViewer-afe97e2e.js");case"../plots/barchart.data.js":return import("./FilterRxComp-e8de560c.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-cecb7bf5.js");case"../plots/barchart.js":return import("./barchart-e3dcfc5f.js");case"../plots/bars.renderer.js":return import("./bars.renderer-58e38632.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-fed0a86b.js");case"../plots/brainImaging.js":return import("./brainImaging-b455fd0c.js");case"../plots/controls.btns.js":return import("./controls.btns-237b3154.js");case"../plots/controls.config.js":return import("./controls.config-00ce9f0b.js");case"../plots/controls.js":return import("./controls-1d99916a.js");case"../plots/cuminc.js":return import("./cuminc-879690b0.js");case"../plots/dataDownload.js":return import("./dataDownload-087ac205.js");case"../plots/dictionary.js":return import("./dictionary-fe0ea1d6.js");case"../plots/facet.js":return import("./facet-397afad5.js");case"../plots/geneExpression.js":return import("./geneExpression-52678025.js");case"../plots/geneORA.js":return import("./geneORA-81220ec0.js");case"../plots/geneset.js":return import("./geneset-604d0529.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-204f007e.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-9f0e8a60.js");case"../plots/gsea.js":return import("./gsea-a1b04406.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-a84f69a3.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-dd917fd3.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-edaaacc5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-4d33e96a.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-f96cdc61.js");case"../plots/matrix.cells.js":return import("./matrix.cells-4dd055e7.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-7ab94fb5.js");case"../plots/matrix.config.js":return import("./matrix.config-b3b56456.js");case"../plots/matrix.controls.js":return import("./matrix.controls-6e0e9692.js");case"../plots/matrix.data.js":return import("./matrix.data-baabaf57.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-cb1f4872.js");case"../plots/matrix.groups.js":return import("./matrix.groups-9990aade.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-3f3cf44d.js");case"../plots/matrix.js":return import("./matrix-8b3341c4.js");case"../plots/matrix.layout.js":return import("./matrix.layout-50bc2ea5.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-024e2d50.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-1aed44e5.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-dc18fcc2.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-89b98e83.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-0ad98ef0.js");case"../plots/plot.app.js":return import("./plot.app-4dc30ebc.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-ee3a0272.js");case"../plots/plot.disco.js":return import("./plot.disco-c9249cbd.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-b5f68395.js");case"../plots/profileBarchart.js":return import("./profileBarchart-f4da0483.js");case"../plots/profilePlot.js":return import("./profilePlot-5dd1fe71.js");case"../plots/profilePolar.js":return import("./profilePolar-996784ad.js");case"../plots/profileRadar.js":return import("./profileRadar-79299186.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-00e31213.js");case"../plots/profileSummary.js":return import("./profileSummary-df75e6ff.js");case"../plots/regression.inputs.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-b283619d.js");case"../plots/regression.js":return import("./regression.inputs-e647b716.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-f61b4a25.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return Promise.resolve().then((function(){return Nt}));case"../plots/sampleScatter.js":return Promise.resolve().then((function(){return Jt}));case"../plots/sampleScatter.renderer.js":return Promise.resolve().then((function(){return $t}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-aa51e3c8.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-e4819da2.js");case"../plots/scatter.js":return import("./scatter-ff17f653.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-e7e57b0f.js");case"../plots/stattable.js":return import("./stattable-775a5af5.js");case"../plots/summary.js":return import("./summary-5866c75f.js");case"../plots/survival.js":return import("./survival-405514f6.js");case"../plots/table.js":return import("./table-e013d8fc.js");case"../plots/variantBrowser.js":return import("./variantBrowser-56ebc7e1.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-2502dcd8.js");case"../plots/violin.js":return import("./violin-1352dab2.js");case"../plots/violin.renderer.js":return import("./violin.renderer-4273257d.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class tt{constructor(){this.type="sessionBtn";this.route="termdb";this.embedderOrigin=window.location.origin;this.hostURL=sessionStorage.getItem("hostURL")||this.embedderOrigin}async init(t){const s=new e({padding:"0px"});this.dom={button:this.opts.button,tip:s};this.dom.button.on("click",(()=>{this.dom.tip.clear();this.showMenu()}));this.dslabel=t.vocab.dslabel;this.savedSessions=JSON.parse(localStorage.getItem("savedMassSessions")||`{}`);this.requiredAuth=t.termdbConfig?.requiredAuth?.find((t=>t.route==this.route&&t.type=="jwt"))}async showMenu(){this.dom.tip.clear().d.style("padding",0);const t=[{label:`Open`,title:"Recover a saved session",callback:this.open},{label:`Save`,title:"Save the current view",callback:this.save},{label:`Share`,title:"Create a URL link to share this view",callback:this.getSessionUrl}];if(!this.serverCachedSessions)await this.setServerCachedSessions();if(Object.keys(this.savedSessions).length||Object.keys(this.serverCachedSessions).length){t.push({label:`Delete`,title:"Delete a saved session",callback:this.delete})}this.dom.tip.clear().d.selectAll(".sja_menuoption sja_sharp_border").data(t).enter().append("div").attr("class","sja_menuoption sja_sharp_border").attr("aria-label",(t=>t.title)).html((t=>t.label)).on("click",((t,e)=>{this.dom.tip.clear().d.style("padding","10px");this.showBackBtn();e.callback.call(this)}));this.dom.tip.showunder(this.dom.button.node())}async open(){const t=`sjpp-session-open-radio-`+Math.random().toString().slice(-6);this.dom.tip.d.append("div").style("display","none").style("padding","3px 9px").html(`\n\t\t\t<b>Open in</b>\n\t\t\t<label>\n\t\t\t\t<input type='radio' name='${t}' value='new' style='margin-right: 0; vertical-align: bottom'/>\n\t\t\t\t<span>a new tab</span>\n\t\t\t</label>\n\t\t\t<label style='margin-left: 5px'>\n\t\t\t\t<input type='radio' name='${t}' value='current' checked=checked style='margin-right: 0; vertical-align: bottom'/>\n\t\t\t\t<span>current tab</span>\n\t\t\t</label>\n\t\t`);const e=await this.listSessions({trClickHandler:async(e,s)=>{const{loc:o,id:a}=s;if(!a)return;if(o.includes("browser")){this.sessionName=a;const e=this.savedSessions[a];await et(e,this.app);const s=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(s=="current"){this.app.dispatch({type:"app_refresh",state:e})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${a}&src=browser`)}else{if(e.embedder)i({state:e});else{const{protocol:t,host:s,search:o,origin:a,href:n}=window.location;const r={protocol:t,host:s,search:o,origin:a,href:n};i({state:Object.assign({embedder:r},e)})}}this.dom.tip.hide()}else if(o=="server"){const e=this.app.vocabApi.mayGetAuthHeaders(this.route);const s={id:a,route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const o=await n(`/massSession?`,{headers:e,body:s});if(!o.state)throw o.error||"unable to get the cached session from the server";await et(o.state,this.app);this.savedSessions[a]=o.state;const r=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(r=="current"){this.app.dispatch({type:"app_refresh",state:o.state})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${a}&src=cred&dslabel=${this.dslabel}&route=${this.route}`)}else{i(o)}this.dom.tip.hide()}}});e.headtr.select("th").html("Open from");const s=e.tbody.insert("tr","tr");s.append("td").style("text-align","center").style("padding","3px 9px").html("Local file");const o=s.append("td").style("text-align","left").append("label");o.append("span").style("padding","3px 9px").style("text-decoration","underline").style("cursor","pointer").html("Choose File");o.append("input").attr("type","file").attr("placeholder","file name").style("opacity",0).style("width","0.1px").style("height","0.1px").style("position","absolute").on("change",(async()=>{const e=event.target.files.item(0);const s=await e.text();let o=e.name;if(this.savedSessions[o]){o=prompt(`Leave as-is to overwrite a session with the same name, or enter a different session name.`,o)}this.sessionName=o;const a=JSON.parse(s);await et(a,this.app);this.savedSessions[o]=a;localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));const n=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(n=="current"){this.app.dispatch({type:"app_refresh",state:a})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${o}&src=browser`)}else{if(a.embedder)i({state:a});else{const{protocol:t,host:e,search:s,origin:o,href:n}=window.location;const r={protocol:t,host:e,search:s,origin:o,href:n};i({state:Object.assign({embedder:r},a)})}}this.dom.tip.hide()}))}async listSessions(t={}){const e=this.dom.tip.d.append("table").attr("class","sjpp-controls-table");const s=e.append("thead").append("tr");s.selectAll("th").data(["Cache Location","Session ID"]).enter().append("th").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").html((t=>t));const o=Object.keys(this.savedSessions).map((t=>({loc:"browser",id:t})));if(!this.serverCachedSessions)await this.setServerCachedSessions();o.push(...this.serverCachedSessions.map((t=>({loc:"server",id:t}))));const a=e.append("tbody");const i=a.selectAll("tr").data(o).enter().append("tr").on("click",t.trClickHandler||null);i.selectAll("td").data((t=>[t,t])).enter().append("td").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").style("cursor","pointer").html(((t,e)=>e===0?t.loc:t.id));if(!this.serverCachedSessions.length&&this.requiredAuth&&!this.app.vocabApi.hasVerifiedToken()){e.append("tbody").append("tr").selectAll("td").data(["server","requires sign-in"]).enter().append("td").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").html((t=>t))}return{table:e,headtr:s,tbody:a,trs:i}}async setServerCachedSessions(){const t=this.app.getState();this.requiredAuth=t.termdbConfig?.requiredAuth?.find((t=>t.route==this.route&&t.type=="jwt"));if(!this.requiredAuth){this.serverCachedSessions=[];return}const e=this.app.vocabApi.mayGetAuthHeaders(this.route);const s={route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const o=await n("/sessionIds",{headers:e,body:s});this.serverCachedSessions=o.sessionIds||[]}async save(t){const e=this.dom.tip.d;const s=e.append("div");s.append("span").html("Save as");const o=Object.keys(this.savedSessions);if(!this.serverCachedSessions)await this.setServerCachedSessions();o.push(...this.serverCachedSessions.filter((t=>!o.includes(t))));const a=this.sessionName||"unnamed-session";const i=s.append("input").attr("type","text").attr("placeholder",a).style("width","220px").on("input",(()=>{n.selectAll("*").remove();const t=i.property("value");const e=o.filter((e=>e===t));const s=o.filter((e=>e.startsWith(t)));const a=o.filter((e=>e.includes(t)&&e!==t&&!s.includes(e)));n.selectAll("div").data([...e,...s,...a]).enter().append("div").attr("class","sja_menuoption").html((t=>t)).on("click",((t,e)=>{i.property("value",e);n.selectAll("*").remove()}))}));const n=e.append("div");const r=e.append("div");r.append("span").html("Save to&nbsp;");r.append("button").style("min-width","80px").html("Browser").attr("title",`Save the session in your current browser's cache. The session can be easily recovered, but not shared among your other devices`).on("click",(()=>{this.sessionName=i.property("value")||a;this.savedSessions[this.sessionName]=this.app.getState();localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));this.confirmAction(`Cached '<b>${this.sessionName}</b>' in browser`)}));r.append("button").style("min-width","80px").html("File").attr("title",`Save the session into a local file. The session can be easily recoved using the 'Open from local file' option.`).on("click",(()=>{const t=i.property("value")||a;this.savedSessions[t]=this.app.getState();this.download(t);this.confirmAction(`Downloaded '<b>${t}</b>'`)}));if(this.requiredAuth){const t=this.app.vocabApi.hasVerifiedToken()?"":"Requires sign-in. ";r.append("button").style("min-width","80px").html("Server").attr("title",`${t}Save the session into a remote server. The session can be easily shared across your different devices and recovered using the 'Open from server' option.`).property("disabled",!this.app.vocabApi.hasVerifiedToken()).on("click",(async()=>{if(!this.app.vocabApi.hasVerifiedToken()){alert("Requires sign-in");return}const t=i.property("value")||a;this.savedSessions[t]=this.app.getState();const e=await this.getSessionUrl(t);if(e.id!=t)throw`error saving ${t}`;this.confirmAction(`Saved '<b>${t}</b>' on the server`)}))}}download(t=""){const e=t||this.sessionName;const s=e?.endsWith(".txt")?"":".txt";const o=`${e}${s}`;z(o,JSON.stringify(this.savedSessions[e]))}async getSessionUrl(t=""){const e=this.app.vocabApi.mayGetAuthHeaders("termdb");const s=structuredClone(this.app.getState());const{protocol:o,host:a,search:r,origin:l,href:c}=window.location;s.embedder={protocol:o,host:a,search:r,origin:l,href:c};if(t){s.__sessionFor__={route:this.route,filename:t,dslabel:this.dslabel,embedder:window.location.hostname}}const p=await n("/massSession",{headers:e,method:"POST",body:JSON.stringify(s)});if(t){return p}else{const t=`${this.hostURL}/?mass-session-id=${p.id}&noheader=1`;this.dom.tip.showunder(this.dom.button.node());const e=this.dom.tip.d.append("div").style("margin","10px");e.append("div").style("margin-bottom","12px").html(`Click the link to recover this session. Bookmark or share this link.`);const o=e.append("a").attr("href",t).attr("target","_blank").html(p.id);if(this.hostURL!=window.location.origin){o.on("click",(t=>{t.preventDefault();i({state:s},window.location.origin);return false}))}e.append("div").html(`\n\t\t\t\t\t<br>\n\t\t\t\t\t<div style="max-width: 400px; font-size: 1em; opacity:.6">\n\t\t\t\t\t<span>NOTES</span>\n\t\t\t\t\t<ul>\n\t\t\t\t\t<li>A recovered session may hide data or views to users that are not authorized to access the saved datasets or features.</li>\n\t\t\t\t\t<li>This session will be saved for ${this.opts.massSessionDuration} days.</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t</div>`);setTimeout((()=>{this.dom.button.property("disabled",false)}),1e3)}}async delete(){const t=await this.listSessions({trClickHandler:function(s){const a=this.lastChild.querySelector("input");const i=s.target==a?a.checked:!a.checked;o(this).style("text-decoration",i?"line-through":"");if(s.target!=a)a.checked=i;const n=t.table.node().querySelectorAll("input:checked");e.property("disabled",n.length?false:true)}});t.headtr.append("th").html("Delete");t.trs.each((function(t){o(this).append("td").style("text-align","center").append("input").attr("type","checkbox").attr("value",t.id)}));const e=this.dom.tip.d.append("div").style("text-align","center").append("button").html("Delete selected sessions").property("disabled",true).on("click",(async()=>{const e=t.table.node().querySelectorAll("input");const s=[];for(const t of e){if(o(t).property("checked")){const e=t.parentNode.parentNode.__data__;if(e.loc=="browser"){delete this.savedSessions[t.value]}else if(e.loc=="server"){delete this.serverCachedSessions[t.value];s.push(t.value)}else throw`unknown cache location=${e.loc}`}}localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));try{const t=this.app.vocabApi.mayGetAuthHeaders("termdb");const e={ids:s,route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const o=n(`/massSession?`,{method:"DELETE",headers:t,body:e})}catch(t){throw t}this.dom.tip.hide()}))}showBackBtn(){this.dom.tip.d.append("div").attr("class","sja_clbtext2").style("margin-bottom","10px").style("cursor","pointer").html(`&lt; Session Menu`).on("click",(()=>this.showMenu()))}confirmAction(t){this.dom.tip.clear().d.append("div").html(t).transition().delay(3e3).duration(1e3).style("opacity",0);setTimeout((()=>{this.dom.tip.hide()}),3500)}}async function et(t,e){if(t.plots){const s=[];for(const o of t.plots){s.push((async()=>{const t=await Z(`../plots/${o.chartType}.js`);return await t.getPlotConfig(o,e)})())}try{await Promise.all(s)}catch(t){console.log(t);e.printError(t)}}}const st=t(tt);class ot{constructor(t){this.type="about";this.app=t.app;this.holder=t.holder;this.features=t.features}init(){this.holder.append("div").style("padding","10px").html(this.features.html)}main(){const t=this.app.Inner.components.nav.Inner.tabs.findIndex((t=>t.subheader=="about"));const e=this.app.Inner.state.nav.activeTab==t;this.holder.style("display",e?"":"none")}}const at=t(ot);let it=0;const nt="_MASS_AUTOID_"+Math.random().toString().slice(-6);let rt=(+new Date).toString().slice(-8);const lt=new e({padding:"0px",offsetX:0,offsetY:0});lt.d.style("z-index",5555);const ct={top:"CHARTS",mid:"NONE",btm:"",subheader:"charts"};const pt={top:"GROUPS",mid:"NONE",btm:"",subheader:"groups"};const dt={top:"FILTER",mid:"NONE",btm:"",subheader:"filter"};function ht(){return nt+"_"+rt++}class mt{constructor(t){this.type="nav";this.instanceNum=it++;this.activeTab=0;this.activeCohort=0;this.searching=false;this.samplecounts={};this.massSessionDuration=t.massSessionDuration;this.sessionDaysLeft=t.app.opts.sessionDaysLeft||null;this.sessionId=t.app.opts.sessionId||null;gt(this);ut(this)}async init(t){try{this.cohortFilter=G(t.termfilter.filter,"cohortFilter");this.initUI(t);this.initCohort(t);this.components=await r({search:J({app:this.app,holder:this.dom.searchDiv,usecase:{target:"summary",detail:"term"},targetType:"Dictionary Variables"}),filter:R({app:this.app,vocabApi:this.app.vocabApi,holder:this.dom.subheader.filter.append("div"),hideLabel:this.opts.header_mode==="with_tabs",emptyLabel:"+Add new filter",callback:t=>{this.app.dispatch({type:"filter_replace",filter:t})}}),charts:C({app:this.app,holder:this.dom.subheader.charts,vocab:this.opts.vocab}),groups:j({app:this.app,holder:this.dom.subheader.groups,vocab:this.opts.vocab}),recover:T({app:this.app,holder:this.dom.recoverDiv,getState:t=>t,reactsTo:t=>t.type!="plot_edit",maxHistoryLen:5}),sessionBtn:st({app:this.app,button:this.dom.saveBtn,massSessionDuration:this.opts.massSessionDuration,sessionDaysLeft:this.app.opts.sessionDaysLeft||null}),about:t.termdbConfig.about?at({app:this.app,holder:this.dom.subheader.about,features:t.termdbConfig.about}):[]});this.mayShowMessage_sessionDaysLeft()}catch(t){throw t}}reactsTo(t){if(t.type.includes("cache_termq"))return true;if(t.type.startsWith("filter"))return true;if(t.type.startsWith("cohort"))return true;if(t.type.startsWith("tab"))return true;if(t.type=="plot_create")return true;if(t.type=="plot_delete")return true;if(t.type=="app_refresh")return true;if(t.type.endsWith("_customTerm"))return true;if(t.type.endsWith("_group"))return true}getState(t){return{searching:this.searching,nav:t.nav,activeCohort:t.activeCohort,termdbConfig:t.termdbConfig,filter:t.termfilter.filter,plots:t.plots,groups:t.groups}}async main(){if(this.state.termdbConfig.selectCohort&&this.state.termdbConfig.about){console.error("Cohort(s) and an About tab are defined. Only one can be used.");return}this.dom.tabDiv.style("display",this.state.nav.header_mode==="with_tabs"?"inline-block":"none");this.dom.tip.hide();this.activeTab=this.state.nav.activeTab;this.prevCohort=this.activeCohort;this.activeCohort=+this.state.activeCohort;this.filterUiRoot=G(this.state.filter,"filterUiRoot");this.cohortFilter=G(this.state.filter,"cohortFilter");if(this.cohortNames){this.activeCohortName=this.cohortNames[this.activeCohort];if(this.activeCohort!==-1)this.activeCohortLabel=this.state.termdbConfig.selectCohort.values[this.activeCohort].shortLabel}this.filterJSON=JSON.stringify(this.state.filter);this.cohortsData=await this.app.vocabApi.getCohortsData();if(this.state.termdbConfig.about)this.about=this.state.termdbConfig.about;if(this.state.nav.header_mode==="with_tabs"){if(!(this.activeCohortName in this.samplecounts)){const t=await this.app.vocabApi.getCohortSampleCount(this.activeCohortName);this.samplecounts[this.activeCohortName]=t}if(!(this.filterJSON in this.samplecounts)){if(!this.filterUiRoot||!this.filterUiRoot.lst.length){this.samplecounts[this.filterJSON]=this.samplecounts[this.activeCohortName]}else{const t=await this.app.vocabApi.getFilteredSampleCount(this.filterJSON);this.samplecounts[this.filterJSON]=t}}}this.updateUI()}}const ft=t(mt);function ut(t){t.initUI=s=>{const o=t.opts.holder.append("div").style("white-space","nowrap");let a=o.append("div").style("display","inline-block").style("float","right").style("font-size","1.1em").style("margin-top","50px").text(s.termdbConfig?.title?.text||"");const i=o.append("div").style("display","none").style("vertical-align","bottom");const n=o.append("div").style("vertical-align","top").style("margin","10px").style("display","inline-block");t.opts.holder.attr("class","sjpp-nav");t.dom={holder:t.opts.holder,header:o,tabDiv:i,controlsDiv:n,searchDiv:n.append("div").style("margin","10px"),sessionDiv:n.append("div").style("display","inline-block"),recoverDiv:n.append("div").style("display","inline-block"),helpDiv:n.append("div").style("display","none"),sessionElapsedMessageDiv:n.append("div").style("display","none"),subheaderDiv:t.opts.holder.append("div").style("display","block").style("padding-top","5px").style("border-bottom","1px solid #000"),messageDiv:t.opts.holder.append("div").style("margin","30px").style("display","none"),titleDiv:a,tip:new e({padding:"5px"})};if(s.nav.header_mode=="only_buttons"){t.dom.tabDiv.style("display","none");t.dom.recoverDiv.style("display","none");a.style("margin-top","95px").style("font-size","0.9em");if(s.termdbConfig.title?.link)a.on("click",(()=>window.open(s.termdbConfig.title.link,"_blank"))).on("mouseover",(()=>a.style("cursor","pointer")))}if(t.opts.header_mode==="with_cohortHtmlSelect"){t.dom.cohortStandaloneDiv=o.append("div").style("display","inline-block").style("margin","10px").style("vertical-align","top");t.dom.cohortStandaloneDiv.append("label").html("Cohort: ");t.dom.cohortSelect=t.dom.cohortStandaloneDiv.append("select").on("change",(function(){t.app.dispatch({type:"cohort_set",activeCohort:+this.value})}));t.dom.cohortSelect.selectAll("option").data(s.termdbConfig.selectCohort.values).enter().append("option").attr("value",((t,e)=>e)).property("selected",((t,e)=>e===s.activeCohort)).html((t=>t.shortLabel))}t.dom.subheader=Object.freeze({search:t.dom.subheaderDiv.append("div").style("display","none"),groups:t.dom.subheaderDiv.append("div").style("display","none"),charts:t.dom.subheaderDiv.append("div").style("display","none"),filter:t.dom.subheaderDiv.append("div").style("display","none"),cart:t.dom.subheaderDiv.append("div").style("display","none").html("<br/>Cart feature under construction - work in progress<br/>&nbsp;<br/>"),about:t.dom.subheaderDiv.append("div").style("display","none").attr("data-testid","sjpp-mass-about")});t.tabs=[ct,pt,dt];if(s.termdbConfig.hideGroupsTab)t.tabs.splice(1,1);if(s.termdbConfig?.selectCohort||s.termdbConfig?.about){const e=s.termdbConfig?.about?.tab||{};const o=s.termdbConfig.selectCohort?"COHORT":e.topLabel||"";const a=e.midLabel||(e?"ABOUT":"");const i=e.btmLabel||"";const n={top:o.toUpperCase(),mid:a.toUpperCase(),btm:i,subheader:"about"};const r=s.termdbConfig?.selectCohort?0:e.order||0;t.tabs.splice(r,0,n)}const r=t.dom.tabDiv.append("table").style("border-collapse","collapse");r.selectAll("tr").data(["top","mid","btm"]).enter().append("tr").style("font-size",((t,e)=>e==1?"20px":"12px")).selectAll("td").data(((e,s)=>t.tabs.map(((t,o)=>({rowNum:s,key:e,colNum:o,label:t[e],subheader:t.subheader}))))).enter().append("td").style("display","none").style("width","100px").style("padding",(t=>t.rowNum===0?"12px 12px 3px 12px":"3px 12px")).style("text-align","center").style("border-left","1px solid #ccc").style("border-right","1px solid #ccc").style("color","#aaa").style("cursor","pointer").html((t=>t.label)).on("click",((e,s)=>{t.setTab(e,s)}));t.dom.trs=r.selectAll("tr");t.dom.tds=r.selectAll("td");t.subheaderKeys=t.tabs.map((t=>t.subheader));t.dom.saveBtn=t.dom.sessionDiv.append("button").style("margin","10px").text("Session ▼");if(t.sessionDaysLeft!=null){t.dom.fileBtn=t.dom.sessionDiv.append("button").style("margin","10px").text("Export Session").on("click",(e=>{t.getSessionFile(e)}))}const l=s.termdbConfig.helpPages;if(l){t.dom.helpBtn=t.dom.helpDiv.style("display","inline-block").append("button").style("margin","10px").html("Help &#9660;").on("click",(t=>{const e=t.target.getBoundingClientRect();const s=lt.clear().show(e.left-0,e.top+e.height+5).d.append("div");for(const t of l){s.append("div").style("margin","15px").append("a").attr("href",t.url).attr("target","_blank").text(t.label)}}))}};t.mayShowMessage_sessionDaysLeft=()=>{if(!Number.isFinite(t.sessionDaysLeft)){return}t.dom.sessionElapsedMessageDiv.style("display","block");t.dom.remainingDaysMessage=t.dom.sessionElapsedMessageDiv.append("div").style("display","block").style("opacity","0.65").html(`<u>${t.sessionDaysLeft} days</u> left until this session is removed. Click the "Save Session" button to create a new one.`)};t.updateUI=async(e=false)=>{if(!t.dom.subheaderDiv)return;if(t.activeTab&&t.state.termdbConfig.selectCohort&&t.activeCohort==-1){t.dom.subheaderDiv.style("display","none");t.dom.messageDiv.selectAll("text").remove();t.dom.messageDiv.style("display","").text('No cohort selected. Please select a cohort in the "COHORT" tab.')}else{let s="block";if(e){s=t.dom.subheaderDiv.style("display")=="none"?"block":"none"}if(t.dom.subheaderDiv)t.dom.subheaderDiv.style("display",s);if(t.dom.messageDiv)t.dom.messageDiv.style("display","none")}const s=t.state.termdbConfig.selectCohort;t.dom.searchDiv.style("display",s&&t.activeCohort==-1||t.state.nav.header_mode=="only_buttons"?"none":"inline-block");t.dom.header.style("border-bottom",t.state.nav.header_mode==="with_tabs"?"1px solid #000":"");t.dom.tds.style("display","").style("color",(e=>e.colNum==t.activeTab?"#000":"#aaa")).style("background-color",(e=>e.colNum==t.activeTab&&t.dom.subheaderDiv.style("display")!="none"?"#ececec":"transparent")).html((function(e,s){if(e.key=="top")return this.innerHTML;if(e.subheader=="groups"){if(e.key=="mid")return t.state.groups.length||"NONE";return""}if(e.subheader==="charts"){const s=t.state.plots.length;if(e.key=="mid")return!s?"NONE":s;else return""}else if(e.subheader==="about"){if(t.activeCohortName&&t.activeCohortName in t.samplecounts){const s={top:this.innerHTML,mid:t.activeCohortLabel,btm:t.samplecounts[t.activeCohortName]};return s[e.key]||""}else if(t.about){const s={top:t.about?.tab?.topLabel?t.about.tab.topLabel.toUpperCase():this.innerHTML,mid:t.about?.tab?.midLabel?t.about.tab.midLabel.toUpperCase():"ABOUT",btm:t.about?.tab?.btmLabel||this.innerHTML};return s[e.key]||""}else{return e.key==="mid"?"NONE":this.innerHTML}}else if(e.subheader==="filter"){const s=t.filterUiRoot?t.filterUiRoot:{lst:[]};if(s.lst.length===0){return e.key==="mid"?"NONE":t.samplecounts["undefined"]?`${t.samplecounts["undefined"]}`:""}else{const o=t.samplecounts[t.filterJSON]!=undefined?""+t.samplecounts[t.filterJSON]:"";return e.key==="mid"?s.lst.length:o}}else{return e.key==="mid"?this.innerHTML:"&nbsp;"}}));for(const e in t.dom.subheader){t.dom.subheader[e].style("display",t.tabs[t.activeTab].subheader===e?"block":"none")}t.renderCohortsTable();if(t.opts.header_mode==="with_cohort_select"){t.dom.cohortSelect.selectAll("option").property("value",appState.activeCohort)}};t.renderCohortsTable=()=>{if(!t.dom.cohortTable)return;t.dom.cohortTable.selectAll("*").remove();const e=[{label:"Feature"}];const s=[];const o=t.cohortsData;if("error"in o)throw o.error;for(const t of o.features)s.push([{value:t.name}]);for(const t of o.cohorts){e.push({label:t.cohort?`${t.name} (${t.cohort})`:t.name});for(const[e,a]of o.features.entries()){const i=o.cfeatures.find((e=>e.idfeature===a.idfeature&&e.cohort===t.cohort));if(i)s[e].push({value:i.value})}}N({rows:s,columns:e,div:t.dom.cohortTable,showLines:false,maxHeight:"60vh"});t.dom.cohortTable.select("table").style("border-collapse","collapse");t.dom.cohortTable.selectAll(`tbody > tr > td`).style("background-color","transparent");const a=t.state.termdbConfig.selectCohort;const i=a.values[t.activeCohort].keys;let n=`tbody > tr > td:nth-child(${t.activeCohort+2})`;const r=i.length>1;if(r){n="";for(const t of i){const e=o.cohorts.map((t=>t.cohort)).indexOf(t);if(n!=="")n+=",";n+=`tbody > tr > td:nth-child(${e+2})`}}const l=t.dom.cohortTable.selectAll(n);l.style("background-color","yellow");t.dom.cohortInputs.property("checked",((e,s)=>s===t.activeCohort))};t.initCohort=async e=>{const s=e.termdbConfig.selectCohort;if(!s)return;t.dom.tds.filter((t=>t.colNum===0)).style("display","");t.cohortNames=s.values.map((t=>t.keys.slice().sort().join(",")));if(s.title){t.dom.cohortTitle=t.dom.subheader.about.append("h2").style("margin-left","10px").text(s.title)}if(s.description){t.dom.cohortDescription=t.dom.subheader.about.append("div").style("margin-left","10px").html(s.description)}if(s.prompt){t.dom.cohortPrompt=t.dom.subheader.about.append("div").style("margin-left","10px").style("padding-top","30px").style("padding-bottom","10px").style("font-weight","bold").text(s.prompt)}t.dom.cohortOpts=t.dom.subheader.about.append("div").style("margin-bottom","30px").style("margin-left","10px");t.dom.cohortOpts.append("table").selectAll("tr").data(s.values).enter().append("tr").each((function(e,s){const a=o(this);const i=a.append("td");const n="sja-termdb-cohort-"+t.instanceNum;const r=n+"-"+s;i.append("input").attr("type","radio").attr("name",n).attr("id",r).attr("value",s).property("checked",s===t.activeCohort).style("margin-right","5px").style("margin-left","0px").on("click",(()=>{t.app.dispatch({type:"cohort_set",activeCohort:s})}));i.append("label").attr("for",r).attr("colspan",2).style("cursor","pointer").html((t=>t.label));a.selectAll("td").style("max-width","600px").style("padding-bottom","10px").style("padding-right","20px").style("vertical-align","top")}));t.dom.cohortInputs=t.dom.cohortOpts.selectAll("input");t.dom.cohortTable=t.dom.subheader.about.append("div");if(s.asterisk){t.dom.cohortAsterisk=t.dom.subheader.about.append("div").style("margin-left","10px").style("padding-top","20px").style("padding-bottom","20px").style("font-size","small").text(s.asterisk)}}}function gt(t){t.setTab=async(e,s)=>{if(s.colNum===t.activeTab&&!t.searching){t.prevCohort=t.activeCohort;await t.updateUI(true);if(t.bus)t.bus.emit("postRender");return}t.activeTab=s.colNum;t.searching=false;t.app.dispatch({type:"tab_set",activeTab:t.activeTab});const o=t.subheaderKeys.indexOf("charts");if(t.activeTab==o&&t.activeCohort!=-1&&!t.state.plots.length){t.app.dispatch({type:"plot_create",id:ht(),config:{chartType:"dictionary"}})}};t.getSessionFile=async e=>{const s=await n(`/massSession?id=${t.sessionId}`);const o=document.createElement("a");const a="data:application/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(s.state));o.setAttribute("href",a);o.download=`${t.sessionId}.json`;o.click();o.remove()}}function yt(t,e){return bt(t)||vt(t,e)||xt()}function bt(t){if(Array.isArray(t))return t}function vt(t,e){var s=[];var o=true;var a=false;var i=undefined;try{for(var n=t[Symbol.iterator](),r;!(o=(r=n.next()).done);o=true){s.push(r.value);if(e&&s.length===e)break}}catch(t){a=true;i=t}finally{try{if(!o&&n["return"]!=null)n["return"]()}finally{if(a)throw i}}return s}function xt(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function St(t,e,s,o){t=t.filter((function(t,o){var a=e(t,o),i=s(t,o);return a!=null&&isFinite(a)&&i!=null&&isFinite(i)}));if(o){t.sort((function(t,s){return e(t)-e(s)}))}var a=t.length,i=new Float64Array(a),n=new Float64Array(a);var r=0,l=0,c,p,d;for(var h=0;h<a;){d=t[h];i[h]=c=+e(d,h,t);n[h]=p=+s(d,h,t);++h;r+=(c-r)/h;l+=(p-l)/h}for(var m=0;m<a;++m){i[m]-=r;n[m]-=l}return[i,n,r,l]}function wt(t,e,s,o){var a=0;for(var i=0,n=t.length;i<n;i++){var r=t[i],l=+e(r,i,t),c=+s(r,i,t);if(l!=null&&isFinite(l)&&c!=null&&isFinite(c)){o(l,c,a++)}}}function Ct(t,e,s,o,a){var i=0,n=0;wt(t,e,s,(function(t,e){var s=e-a(t),r=e-o;i+=s*s;n+=r*r}));return 1-i/n}function jt(t){return Math.atan2(t[1][1]-t[0][1],t[1][0]-t[0][0])*180/Math.PI}function Tt(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}function kt(t,e,s){var o=Math.log(e-t)*Math.LOG10E+1|0;var a=1*Math.pow(10,-o/2-1),i=1e4;var n=[l(t),l(e)],r=0;while(c(n)&&r<i){}return n;function l(t){return[t,s(t)]}function c(t){r++;var e=t.length;var s=false;for(var o=0;o<e-1;o++){var i=t[o],n=t[o+1],c=Tt([i,n]),p=l(c[0]),d=jt([i,c]),h=jt([i,p]),m=Math.abs(d-h);if(m>a){t.splice(o+1,0,p);s=true}}return s}}function Dt(t,e,s,o){var a=o-t*t,i=Math.abs(a)<1e-24?0:(s-t*e)/a,n=e-i*t;return[n,i]}function _t(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s;function o(o){var a=0,i=0,n=0,r=0,l=0,c=s?+s[0]:Infinity,p=s?+s[1]:-Infinity;wt(o,t,e,(function(t,e){++a;i+=(t-i)/a;n+=(e-n)/a;r+=(t*e-r)/a;l+=(t*t-l)/a;if(!s){if(t<c)c=t;if(t>p)p=t}}));var d=Dt(i,n,r,l),h=yt(d,2),m=h[0],f=h[1],u=function t(e){return f*e+m},g=[[c,u(c)],[p,u(p)]];g.a=f;g.b=m;g.predict=u;g.rSquared=Ct(o,t,e,n,u);return g}o.domain=function(t){return arguments.length?(s=t,o):s};o.x=function(e){return arguments.length?(t=e,o):t};o.y=function(t){return arguments.length?(e=t,o):e};return o}function At(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s;function o(o){var a=St(o,t,e),i=yt(a,4),n=i[0],r=i[1],l=i[2],c=i[3],p=n.length;var d=0,h=0,m=0,f=0,u=0,g,y,b,v;for(g=0;g<p;){y=n[g];b=r[g++];v=y*y;d+=(v-d)/g;h+=(v*y-h)/g;m+=(v*v-m)/g;f+=(y*b-f)/g;u+=(v*b-u)/g}var x=0,S=0,w=s?+s[0]:Infinity,C=s?+s[1]:-Infinity;wt(o,t,e,(function(t,e){S++;x+=(e-x)/S;if(!s){if(t<w)w=t;if(t>C)C=t}}));var j=m-d*d,T=d*j-h*h,k=(u*d-f*h)/T,D=(f*j-u*h)/T,_=-k*d,A=function t(e){e=e-l;return k*e*e+D*e+_+c};var O=kt(w,C,A);O.a=k;O.b=D-2*k*l;O.c=_-D*l+k*l*l+c;O.predict=A;O.rSquared=Ct(o,t,e,x,A);return O}o.domain=function(t){return arguments.length?(s=t,o):s};o.x=function(e){return arguments.length?(t=e,o):t};o.y=function(t){return arguments.length?(e=t,o):e};return o}function Ot(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s=3,o;function a(a){if(s===1){var i=_t().x(t).y(e).domain(o)(a);i.coefficients=[i.b,i.a];delete i.a;delete i.b;return i}if(s===2){var n=At().x(t).y(e).domain(o)(a);n.coefficients=[n.c,n.b,n.a];delete n.a;delete n.b;delete n.c;return n}var r=St(a,t,e),l=yt(r,4),c=l[0],p=l[1],d=l[2],h=l[3],m=c.length,f=[],u=[],g=s+1;var y=0,b=0,v=o?+o[0]:Infinity,x=o?+o[1]:-Infinity;wt(a,t,e,(function(t,e){++b;y+=(e-y)/b;if(!o){if(t<v)v=t;if(t>x)x=t}}));var S,w,C,j,T;for(S=0;S<g;++S){for(C=0,j=0;C<m;++C){j+=Math.pow(c[C],S)*p[C]}f.push(j);T=new Float64Array(g);for(w=0;w<g;++w){for(C=0,j=0;C<m;++C){j+=Math.pow(c[C],S+w)}T[w]=j}u.push(T)}u.push(f);var k=Lt(u),D=function t(e){e-=d;var s=h+k[0]+k[1]*e+k[2]*e*e;for(S=3;S<g;++S){s+=k[S]*Math.pow(e,S)}return s},_=kt(v,x,D);_.coefficients=Wt(g,k,-d,h);_.predict=D;_.rSquared=Ct(a,t,e,y,D);return _}a.domain=function(t){return arguments.length?(o=t,a):o};a.x=function(e){return arguments.length?(t=e,a):t};a.y=function(t){return arguments.length?(e=t,a):e};a.order=function(t){return arguments.length?(s=t,a):s};return a}function Wt(t,e,s,o){var a=Array(t);var i,n,r,l;for(i=0;i<t;++i){a[i]=0}for(i=t-1;i>=0;--i){r=e[i];l=1;a[i]+=r;for(n=1;n<=i;++n){l*=(i+1-n)/n;a[i-n]+=r*Math.pow(s,n)*l}}a[0]+=o;return a}function Lt(t){var e=t.length-1,s=[];var o,a,i,n,r;for(o=0;o<e;++o){n=o;for(a=o+1;a<e;++a){if(Math.abs(t[o][a])>Math.abs(t[o][n])){n=a}}for(i=o;i<e+1;++i){r=t[i][o];t[i][o]=t[i][n];t[i][n]=r}for(a=o+1;a<e;++a){for(i=e;i>=o;i--){t[i][a]-=t[i][o]*t[o][a]/t[o][o]}}}for(a=e-1;a>=0;--a){r=0;for(i=a+1;i<e;++i){r+=t[i][a]*s[i]}s[a]=(t[e][a]-r)/t[a][a]}return s}function Mt(t){P(t);t.render=function(){const e=t.mainDiv.selectAll(":scope > div").data(t.charts,(t=>t?.id));e.exit().remove();e.each(t.renderChart);e.enter().append("div").style("vertical-align","top").each(t.renderChart)};t.renderChart=function(e){e.chartDiv=o(this);const a=t.settings;e.chartDiv.style("opacity",0).style("display","inline-block");e.chartDiv.on("mouseover",(s=>{if(!t.onClick)t.showTooltip(s,e)}));e.chartDiv.on("click",(s=>t.showTooltip(s,e)));e.svg=e.chartDiv.select("svg").empty()?e.chartDiv.append("svg"):e.chartDiv.select("svg");s(e,a);e.chartDiv.transition().duration(a.duration).style("opacity",1)};t.initAxes=function(e){if(e.data.samples.length==0)return;e.xAxisScale=l().domain([e.xMin,e.xMax]).range([t.axisOffset.x,t.settings.svgw+t.axisOffset.x]);e.axisBottom=U(e.xAxisScale);e.yAxisScale=l().domain([e.yMax,e.yMin]).range([t.axisOffset.y,t.settings.svgh+t.axisOffset.y]);e.zAxisScale=l().domain([e.zMin,e.zMax]).range([0,t.settings.svgd]);e.xScaleMin=e.xAxisScale(e.xMin);e.xScaleMax=e.xAxisScale(e.xMax);e.yScaleMin=e.xAxisScale(e.yMin);e.yScaleMax=e.yAxisScale(e.yMax);e.zScaleMin=e.xAxisScale(e.zMin);e.zScaleMax=e.zAxisScale(e.zMax);e.axisLeft=B(e.yAxisScale);const s=t.config.settings.sampleScatter.defaultColor;if(!t.config.startColor)t.config.startColor=t.config.stopColor={};if(!t.config.startColor[e.id]){t.config.startColor[e.id]=c(s).brighter().brighter().toString()}if(!t.config.stopColor[e.id]){t.config.stopColor[e.id]=c(s).darker().toString()}if(t.config.colorTW?.q.mode==="continuous"){const[s,o]=e.cohortSamples.filter((e=>!t.config.colorTW.term.values||!(e.category in t.config.colorTW.term.values))).reduce(((t,e)=>[e.category<t[0]?e.category:t[0],e.category>t[1]?e.category:t[1]]),[e.cohortSamples[0].category,e.cohortSamples[0].category]);e.colorGenerator=l().domain([s,o]).range([t.config.startColor[e.id],t.config.stopColor[e.id]])}};function s(e,s){const o=e.svg;let n=Math.min(20*40/e.colorLegend.size,25);if(n<12)n=12;let r=e.colorLegend.size*n;if(e.colorLegend.get("Ref")?.sampleCount>0)r+=60;const l=t.config.scaleDotTW?200:100;t.legendHeight=Math.max(r,e.shapeLegend.size*30)+l;const c=t.charts.length==1?s.svgw+800:s.svgw+(t.config.shapeTW?600:350);o.transition().duration(s.duration).attr("width",c).attr("height",Math.max(s.svgh+100,t.legendHeight));a(e);if(t.is3D)t.render3DSerie(e);else if(t.is2DLarge)t.render2DSerieLarge(e);else{i(e,s.duration);t.renderLegend(e,n)}}function a(e){const s=e.svg;let o,a,i;if(s.select(".sjpcb-scatter-mainG").size()==0){e.mainG=s.append("g").attr("class","sjpcb-scatter-mainG");o=s.append("g").attr("class","sjpcb-scatter-axis");a=s.append("g").attr("class","sjpcb-scatter-labelsG");e.xAxis=o.append("g").attr("class","sjpcb-scatter-x-axis");e.yAxis=o.append("g").attr("class","sjpcb-scatter-y-axis").attr("transform",`translate(${t.axisOffset.x}, 0)`);e.mainG.append("rect").attr("class","zoom").attr("x",t.axisOffset.x).attr("y",t.axisOffset.y-t.settings.size).attr("width",t.settings.svgw).attr("height",t.settings.svgh).attr("fill","white");e.serie=e.mainG.append("g").attr("class","sjpcb-scatter-series");e.regressionG=e.mainG.append("g").attr("class","sjpcb-scatter-lowess");const n=`${Date.now()}`;const r=`sjpp_clip_${n}`;t.defs=s.append("defs");i=t.defs.append("clipPath").attr("id",r).append("rect");const l=t.defs.append("linearGradient").attr("id",`linear-gradient-${e.id}`).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");t.startGradient[e.id]=l.append("stop").attr("offset","0%").attr("stop-color",t.config.startColor[e.id]);t.stopGradient[e.id]=l.append("stop").attr("offset","100%").attr("stop-color",t.config.stopColor[e.id]);e.mainG.attr("clip-path",`url(#${r})`);e.legendG=s.append("g").attr("class","sjpcb-scatter-legend")}else{e.mainG=s.select(".sjpcb-scatter-mainG");e.serie=e.mainG.select(".sjpcb-scatter-series");e.regressionG=e.mainG.select(".sjpcb-scatter-lowess");o=s.select(".sjpcb-scatter-axis");a=s.select(".sjpcb-scatter-labelsG");e.xAxis=o.select(".sjpcb-scatter-x-axis");e.yAxis=o.select(".sjpcb-scatter-y-axis");e.legendG=s.select(".sjpcb-scatter-legend");i=s.select(`defs > clipPath > rect`)}e.xAxis.attr("transform",`translate(0, ${t.settings.svgh+t.axisOffset.y})`);e.legendG.attr("transform",`translate(${t.settings.svgw+t.axisOffset.x+50}, 20)`);if(e.axisBottom){e.xAxis.call(e.axisBottom);e.yAxis.call(e.axisLeft)}const n=Math.sqrt(t.settings.size);if(t.settings.showAxes&&!(t.is2DLarge||t.is3D)){i.attr("x",t.axisOffset.x).attr("y",0).attr("width",t.settings.svgw+2*n).attr("height",t.settings.svgh+t.axisOffset.y);o.style("opacity",1);if(t.config.term){let s=t.config.term.term.name;if(!t.config.colorTW&&!t.config.shapeTW&&!t.config.term0)s=`${s}, n=${e.cohortSamples.length}`;a.selectAll("*").remove();a.append("text").attr("transform",`translate(${t.axisOffset.x+t.settings.svgw/2}, ${t.settings.svgh+t.axisOffset.y+40})`).attr("text-anchor","middle").text(s);if(t.config.term0&&!t.config.colorTW&&!t.config.shapeTW){const s=`${e.id}, n=${e.cohortSamples.length}`;a.append("text").attr("transform",`translate(${t.axisOffset.x+t.settings.svgw/2}, ${t.settings.svgh+t.axisOffset.y+65})`).attr("text-anchor","middle").text(s)}a.append("text").attr("transform",`translate(${t.axisOffset.x-50}, ${t.settings.svgh/2+t.axisOffset.y}) rotate(-90)`).attr("text-anchor","middle").text(t.config.term2.term.name)}}else{o.style("opacity",0);i.attr("x",t.axisOffset.x-n).attr("y",0).attr("width",t.settings.svgw+2*n).attr("height",t.settings.svgh+t.axisOffset.y+n)}}function i(e,s){if(t.canvas)t.canvas.remove();const o=e.serie;const a=e.data;const i=o.selectAll('path[name="serie"]').data(a.samples);i.exit().remove();i.transition().duration(s).attr("name","serie").attr("transform",(s=>t.transform(e,s))).attr("d",(s=>t.getShape(e,s))).attr("fill",(s=>t.getColor(s,e))).attr("stroke",(s=>t.getColor(s,e))).attr("stroke-width",(e=>t.getStrokeWidth(e))).style("fill-opacity",(e=>t.getOpacity(e)));i.enter().append("path").attr("name","serie").attr("transform",(s=>t.transform(e,s))).attr("d",(s=>t.getShape(e,s))).attr("fill",(s=>t.getColor(s,e))).attr("stroke",(s=>t.getColor(s,e))).attr("stroke-width",(e=>t.getStrokeWidth(e))).style("fill-opacity",(e=>t.getOpacity(e))).transition().duration(s);t.mayRenderRegression()}t.getStrokeWidth=function(e){const s=t.getOpacity(e);if(s<=.2)return 0;if(s==1.2)return 2;return 1};t.processData=async function(){for(const e of t.charts){t.initAxes(e);const s=t.config.settings.sampleScatter.regression;if(!s||s=="None")continue;let o;const a=[];await e.cohortSamples.forEach((t=>{const s=e.xAxisScale(t.x);const o=e.yAxisScale(t.y);a.push({x:s,y:o})}));let i;if(s=="Polynomial"){o=Ot().x((t=>t.x)).y((t=>t.y)).order(3);i=o(a)}else if(s=="Lowess"){const e=[],s=[];for(const t of a){e.push(t.x);s.push(t.y)}i=await t.app.vocabApi.getLowessCurve({coords:{X:e,Y:s}})}else{throw`unsupported regression type='${s}'`}e.regressionCurve=i}};t.mayRenderRegression=async function(){for(const e of t.charts){e.regressionG?.selectAll("*").remove();if(e.regressionCurve){const t=K().x((t=>t[0])).y((t=>t[1]));const s=e.regressionG.append("path");s.attr("d",t(e.regressionCurve)).attr("stroke","blue").attr("fill","none").style("stroke-width","2")}}};t.getColor=function(e,s){if(t.config.colorTW?.q.mode=="continuous"&&"sampleId"in e){const t=s.colorGenerator(e.category);return t}if(e.category=="Default")return t.config.settings.sampleScatter.defaultColor;const o=s.colorLegend.get(e.category);return o.color};t.getOpacity=function(e){if("sampleId"in e){if(t.filterSampleStr){if(!e.sample?.toLowerCase().includes(t.filterSampleStr.toLowerCase()))return.2;else return 1.2}const s=e.hidden?.["category"]||e.hidden?.["shape"]?0:t.settings.opacity;return s}const s=t.settings.showRef?t.settings.opacity:0;return s};t.getShape=function(t,e,s=1){const o=t.shapeLegend.get(e.shape).shape%qt.length;return qt[o]};t.transform=function(e,s,o=1){const a=e.xAxisScale(s.x);const i=e.yAxisScale(s.y);const n=!("sampleId"in s);let r;if(!t.config.scaleDotTW||n){r="sampleId"in s?t.settings.size:t.settings.refSize}else{const o=t.settings.maxShapeSize-t.settings.minShapeSize;if(t.settings.scaleDotOrder=="Ascending")r=t.settings.minShapeSize+(s.scale-e.scaleMin)/(e.scaleMax-e.scaleMin)*o;else r=t.settings.maxShapeSize-(s.scale-e.scaleMin)/(e.scaleMax-e.scaleMin)*o}const l=`translate(${a},${i}) scale(${t.zoom*r*o/3})`;return l};t.lassoReset=e=>{const s=e.chartDiv.select(".sjpcb-scatter-mainG");if(e.lasso)e.lasso.items(s.select(".sjpcb-scatter-series").selectAll('path[name="serie"]')).targetArea(s).on("start",o).on("draw",a).on("end",i);function o(s){if(t.lassoOn){e.lasso.items().attr("transform",(s=>t.transform(e,s,1/2))).style("fill-opacity",(e=>t.getOpacity(e)!=0?.5:0)).classed("not_possible",true).classed("selected",false)}}function a(s){if(t.lassoOn){e.lasso.possibleItems().attr("transform",(s=>t.transform(e,s,1.2))).style("fill-opacity",(e=>t.getOpacity(e))).classed("not_possible",false).classed("possible",true);e.lasso.notPossibleItems().attr("transform",(s=>t.transform(e,s,1/2))).style("fill-opacity",(e=>t.getOpacity(e)!=0?.5:0)).classed("not_possible",true).classed("possible",false)}}function i(s){if(t.lassoOn){e.lasso.items().classed("not_possible",false).classed("possible",false);e.lasso.selectedItems().attr("transform",(s=>t.transform(e,s,1.3)));e.lasso.items().style("fill-opacity",(e=>t.getOpacity(e)));t.selectedItems=[];for(const s of e.lasso.selectedItems()){const e=s.__data__;if("sampleId"in e&&!(e.hidden["category"]||e.hidden["shape"]))t.selectedItems.push(s)}e.lasso.notSelectedItems().attr("transform",(s=>t.transform(e,s)));n(s.sourceEvent)}}function n(e){const s=t.selectedItems.map((t=>t.__data__));t.dom.tip.clear().hide();if(t.selectedItems.length==0)return;t.dom.tip.show(e.clientX,e.clientY);const o=t.dom.tip.d.append("div");o.append("div").attr("class","sja_menuoption sja_sharp_border").text(`List ${t.selectedItems.length} samples`).on("click",(e=>{t.dom.tip.hide();t.showTable({name:"Group "+(t.config.groups.length+1),items:s},e.clientX,e.clientY,true)}));o.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to a group").on("click",(async()=>{const e={name:"Group",items:s};const o=k([e]);const a=D(o);_(t.app,a,t.state.groups)}));o.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to a group and filter").on("click",(()=>{const e={name:"Group",items:s};const o=k([e]);const a=D(o);_(t.app,a,t.state.groups);t.addToFilter(o)}));if("sample"in s[0])o.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show samples").on("click",(async e=>{const o=[];for(const t of s)o.push({sampleId:t.sampleId,sampleName:t.sample});t.app.dispatch({type:"plot_create",id:ht(),config:{chartType:"sampleView",samples:o}});t.dom.tip.hide()}))}if(t.lassoOn){s.on(".zoom",null);s.on("mousedown.drag",null);s.call(e.lasso)}};t.addGroup=async function(e){e.plotId=t.id;await t.app.vocabApi.addGroup(e);t.dom.tip.hide()};t.setTools=function(){if(!t.charts[0])return;const e=t.config.settings.controls.isOpen;const s=t.dom.toolsDiv.style("background-color","white");s.selectAll("*").remove();let o="block";if(e)o="inline-block";const a=s.insert("div").style("display",o).style("margin","20px").attr("name","sjpp-reset-btn");p["restart"](a,{handler:g,title:"Reset plot to defaults"});const i=s.insert("div").style("display",o).style("margin","20px").attr("name","sjpp-zoom-in-btn");p["zoomIn"](i,{handler:f,title:"Zoom in"});const n=s.insert("div").style("display",o).style("margin","20px").attr("name","sjpp-zoom-out-btn");p["zoomOut"](n,{handler:u,title:"Zoom out"});const r=s.insert("div").style("display",o).style("margin","20px");const l=s.insert("div").style("display",o).style("margin","20px");if(!(t.is2DLarge||t.is3D)){p["search"](r,{handler:e=>t.searchSample(e),title:"Search samples"});p["lasso"](l,{handler:y,enabled:t.lassoOn,title:"Select a group of samples"})}t.dom.groupDiv=s.insert("div").style("display",o).style("margin","20px");const c=t.charts[0].mainG;const h=S().scaleExtent([.5,t.config.scaleDotTW?4:10]).on("zoom",m).filter((t=>{if(t.type==="wheel")return t.ctrlKey;return true}));if(t.config.scaleDotTW&&t.zoom>4)g();c.call(h);for(const e of t.charts){e.lasso=w();t.lassoReset(e)}t.updateGroupsButton();t.settings;function m(e){for(const s of t.charts){const o=e.transform.rescaleX(s.xAxisScale);const a=e.transform.rescaleY(s.yAxisScale);s.xAxis.call(s.axisBottom.scale(o));s.yAxis.call(s.axisLeft.scale(a));s.serie.attr("transform",e.transform);t.zoom=e.transform.scale(1).k;const i=s.serie.selectAll('path[name="serie"');i.attr("transform",(e=>t.transform(s,e,1)));if(t.lassoOn)s.lasso.selectedItems().attr("transform",(e=>t.transform(s,e,1.2)));if(t.config.scaleDotTW)t.drawScaleDotLegend(s)}}function f(){for(const e of t.charts)if(t.is2DLarge)t.zoom=t.zoom+.25;else h.scaleBy(e.mainG.transition().duration(750),1.5)}function u(){for(const e of t.charts)if(t.is2DLarge)t.zoom=t.zoom-.25;else h.scaleBy(e.mainG.transition().duration(750),.5)}function g(){for(const e of t.charts)if(t.is2DLarge)t.zoom=1;else e.mainG.transition().duration(750).call(h.transform,d);t.render()}function y(){t.lassoOn=!t.lassoOn;for(const e of t.charts){if(t.lassoOn){e.mainG.on(".zoom",null);e.mainG.call(e.lasso)}else{e.mainG.on("mousedown.drag",null);e.lasso.items().classed("not_possible",false);e.lasso.items().classed("possible",false);e.lasso.items().attr("r",t.settings.size).style("fill-opacity",(e=>t.getOpacity(e)));e.mainG.call(h);t.selectedItems=null}}l.select("*").remove();p["lasso"](l,{handler:y,enabled:t.lassoOn})}};t.updateGroupsButton=function(){t.dom.groupDiv.selectAll("*").remove();t.dom.tip.hide();if(t.config.groups.length==0)return;t.dom.groupDiv.append("button").style("border","none").style("background","transparent").style("padding",0).append("div").style("font-size","1.1em").html(`&#931${t.config.groups.length+1};`).on("click",(e=>{if(t.config.groups.length==1)t.showGroupMenu(e,t.config.groups[0]);else t.showGroupsMenu(e)}))};t.renderLegend=function(e,s){const o=e.legendG;o.selectAll("*").remove();let a=0;let i=25;if(!t.config.colorTW&&!t.config.shapeTW&&!t.config.colorColumn){if(t.config.scaleDotTW){e.scaleG=o.append("g").attr("transform",`translate(${a+45},${t.legendHeight-150})`);t.drawScaleDotLegend(e)}return}let n;let r=Math.min(.8,20/e.colorLegend.size);if(r<.5)r=.5;const p=o.style("font-size",`${r}em`);let d=t.config.term0?`${e.id}, n=${e.cohortSamples.length}`:`${e.cohortSamples.length} ${t.config.sampleType?t.config.sampleType+"s":"samples"}`;if(t.filterSampleStr)d+=`, search = ${t.filterSampleStr}`;p.append("text").attr("x",0).attr("y",i).text(d).style("font-weight","bold");i+=s+10;if(t.config.colorTW||t.config.colorColumn){n=`${h(t.config.colorTW?.term?.name||t.config.colorColumn.name,t.config.shapeTW==undefined)}`;const r=e.colorLegend.get("Ref");if(t.config.colorTW?.term?.type=="geneVariant"&&t.config.colorTW?.q.type=="values")i=t.renderGeneVariantLegend(e,a,i,o,t.config.colorTW,"category",e.colorLegend);else{p.append("text").attr("id","legendTitle").attr("x",a).attr("y",i).text(n).style("font-weight","bold");i+=s;if(t.config.colorTW?.q?.mode==="continuous"){const o=150;const[a,n]=e.colorGenerator.domain();const r=l().domain([a,n]).range([0,o]);const c=(n-a)/4;const d=[a,a+c,a+2*c,a+3*c,n];const h=H(r).tickValues(d);p.append("g").attr("transform",`translate(0, 100)`).call(h);e.startRect=p.append("rect").attr("x",-25).attr("y",100).attr("width",20).attr("height",20).style("fill",t.config.startColor[e.id]).on("click",(s=>t.editColor(e,"startColor",e.startRect)));e.stopRect=p.append("rect").attr("x",o+5).attr("y",100).attr("width",20).attr("height",20).style("fill",t.config.stopColor[e.id]).on("click",(s=>t.editColor(e,"stopColor",e.stopRect)));p.append("rect").attr("x",0).attr("y",100).attr("width",o).attr("height",20).style("fill",`url(#linear-gradient-${e.id})`);i+=s}else{for(const[n,r]of e.colorLegend){if(n=="Ref")continue;const l=n;const c=t.config.colorTW?.q.hiddenValues?n in t.config.colorTW.q.hiddenValues:false;const[d,h]=m(p,r,l,a,i,c);if(!t.config.colorColumn){d.on("click",(s=>t.onLegendClick(e,o,"colorTW",n,s,r)));h.on("click",(s=>t.onLegendClick(e,o,"colorTW",n,s,r)))}i+=s}}}if(r?.sampleCount>0){i=i+s;const n=o.append("g");n.append("text").attr("x",a).attr("y",i).text("Reference").style("font-weight","bold");i=i+s;const l=o.append("g");l.append("path").attr("transform",(t=>`translate(${a-2}, ${i-5}) scale(0.5)`)).style("fill",r.color).attr("d",qt[0]).style("stroke",c(r.color).darker());l.on("click",(s=>t.onLegendClick(e,o,"colorTW","Ref",s,r)));const p=o.append("g").append("text").attr("x",a+10).attr("y",i).text(`n=${r.sampleCount}`).style("text-decoration",!t.settings.showRef?"line-through":"none").attr("alignment-baseline","middle");p.on("click",(s=>t.onLegendClick(e,o,"colorTW","Ref",s,r)))}}if(t.config.scaleDotTW){e.scaleG=o.append("g").attr("transform",`translate(${a},${t.legendHeight-100})`);t.drawScaleDotLegend(e)}if(t.config.shapeTW){a=!t.config.colorTW?0:300;i=60;n=`${h(t.config.shapeTW.term.name)}`;if(t.config.shapeTW.term.type=="geneVariant"&&t.config.shapeTW.q.type=="values")t.renderGeneVariantLegend(e,a,i,o,t.config.shapeTW,"shape",e.shapeLegend);else{const r=o.append("g");r.append("text").attr("x",a).attr("y",i).text(n).style("font-weight","bold");i+=s;const l="gray";for(const[n,p]of e.shapeLegend){if(n=="Ref")continue;const d=p.shape%qt.length;const h=qt[d];const m=n;const f=p.sampleCount;const u=t.config.shapeTW.q.hiddenValues?n in t.config.shapeTW.q.hiddenValues:false;const g=r.append("g");g.append("path").attr("transform",(t=>`translate(${a}, ${i-5}) scale(0.5)`)).style("fill",l).attr("d",h).style("stroke",c(l).darker());g.append("text").attr("x",a+10).attr("y",i).text(`${m}, n=${f}`).style("text-decoration",u?"line-through":"none").attr("alignment-baseline","middle");i+=s;g.on("click",(s=>t.onLegendClick(e,o,"shapeTW",n,s,p)))}}}function h(t,e=false){if(t.length>25&&!e)t=t.slice(0,25)+"...";return t}function m(s,a,i,n,r,l=false){Math.min(5*40/e.colorLegend.size,5);const p=s.append("g");p.append("path").attr("d",qt[0]).attr("transform",`translate(${n-2}, ${r-5}) scale(0.5)`).style("fill",a.color).style("stroke",c(a.color).darker());if(!t.config.colorColumn)p.on("click",(s=>t.onLegendClick(e,o,"colorTW",key,s,a)));const d=s.append("g");d.append("text").attr("name","sjpp-scatter-legend-label").attr("x",n+10).attr("y",r).text(`${i}, n=${a.sampleCount}`).style("text-decoration",l?"line-through":"none").attr("alignment-baseline","middle");return[p,d]}};t.drawScaleDotLegend=function(s){const a=s.scaleG;a.selectAll("*").remove();const i=70;const n=t.settings.minShapeSize/3;const r=t.settings.maxShapeSize/3;const l=t.settings.scaleDotOrder;const c=l=="Ascending";const p=a.append("g");p.append("text").text(t.config.scaleDotTW.term.name).style("font-weight","bold");const d=b(s.scaleMin).toString();const h=b(s.scaleMax).toString();const m=30;const f=40;const u=16;const g=u*n;const y=u*r;const v=g/2;const x=y/2;const S=a.append("g").attr("transform",`translate(${m},${f})`);const w=30;S.append("path").attr("d",qt[0]).style("fill","#aaa").style("stroke","#aaa").attr("transform",`translate(${c?-v:-x}, ${c?-v:-x}) scale(${c?n:r})`);const C=a.append("g").attr("transform",`translate(${i+m},${f})`);C.append("path").attr("d",qt[0]).style("fill","#aaa").style("stroke","#aaa").attr("transform",`translate(${c?-x:-v}, ${c?-x:-v}) scale(${c?r:n})`);S.append("text").attr("x",c?-v-w:-x-w).attr("y",5).style("font-size",".8em").attr("text-anchor","start").text(d);C.append("text").attr("x",c?y+5:g+5).attr("y",5).style("font-size",".8em").text(h);S.append("line").attr("x1",0).attr("y1",c?v:x).attr("x2",i).attr("y2",c?x:v).style("stroke","#aaa");S.append("line").attr("x1",0).attr("y1",c?-v:-x).attr("x2",i).attr("y2",c?-x:-v).style("stroke","#aaa");a.append("rect").attr("width",110*t.zoom).attr("height",50).attr("fill","transparent").on("click",(s=>{const a=new e({padding:"3px"});const i=a.d;i.append("label").text("Min:");const n=i.append("input").attr("type","number").attr("min","1").attr("max","100").style("width","50px").attr("value",t.settings.minShapeSize).on("change",(()=>{let e=parseFloat(n.node().value);if(e<Gt){e=Gt;n.node().value=Gt}t.config.settings.sampleScatter.minShapeSize=e;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}));i.append("label").text("Max:");const r=i.append("input").attr("type","number").attr("min","1").attr("max","1000").style("width","50px").attr("value",t.settings.maxShapeSize).on("change",(()=>{let e=parseFloat(r.node().value);if(e>Rt){e=Rt;r.node().value=Rt}t.config.settings.sampleScatter.maxShapeSize=e;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}));const c=a.d.append("div");c.append("label").text("Order: ");const p=["Ascending","Descending"];c.selectAll("input").data(p).enter().append("div").style("display","inline-block").each(d);function d(e){const s=o(this);const a=s.append("input").attr("type","radio").attr("id",e).attr("value",e).property("checked",(t=>t==l));s.append("label").text(e).attr("for",e);a.on("change",(e=>{t.config.settings.sampleScatter.scaleDotOrder=e.target.value;c.selectAll("input").nodes().find((t=>t.value!=e.target.value)).checked=false;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}))}a.showunder(s.target)}))};t.editColor=function(s,o,a){const i=t.config[o][s.id];const n=new e({padding:"3px"});const r=n.clear().d.append("Label").text("Color:").append("input").attr("type","color").attr("value",c(i).formatHex()).on("change",(()=>{const e=r.node().value;t.changeGradientColor(s,o,a,e);n.hide()}));n.showunder(a.node(),false)};t.changeGradientColor=function(e,s,o,a){const i=c(a).formatHex();t.config[s][e.id]=i;o.style("fill",i);e.colorGenerator=l().range([t.config.startColor[e.id],t.config.stopColor[e.id]]);t.startGradient[e.id].attr("stop-color",t.config.startColor[e.id]);t.stopGradient[e.id].attr("stop-color",t.config.stopColor[e.id]);t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})};t.renderGeneVariantLegend=function(e,s,o,a,i,n,r){const l=125;const p=i.term.name.length>25?i.term.name.slice(0,25)+"...":i.term.name;let d=p;const f=a.append("g").style("font-size","0.9em");f.append("text").attr("id","legendTitle").attr("x",s).attr("y",o).text(d).style("font-weight","bold");s+=l;const u=e.cohortSamples[0]["cat_info"][n];for(const[p,d]of u.entries()){o+=25;const p=d.dt;const u=h[d.origin]?.label;const g=u?`${u[0]} ${m[p]}`:m[p];f.append("text").attr("x",s-l).attr("y",o).text(u?`${u} ${m[p]}`:m[p]).style("font-weight","bold");o+=25;for(const[p,d]of r){if(p=="Ref")continue;if(!p.includes(g))continue;const r=p.split(", ")[0];const h=f.append("g");if(n=="shape"){const t=d.shape%qt.length;h.append("path").attr("transform",(t=>`translate(${s-l-2}, ${o-8}) scale(0.5)`)).style("fill","gray").attr("d",qt[t]).style("stroke",c("gray").darker())}else{h.append("path").attr("d",qt[0]).attr("transform",`translate(${-2}, ${o-8}) scale(0.5)`).style("fill",d.color).style("stroke",c(d.color).darker());h.on("click",(s=>t.onLegendClick(e,a,"colorTW",p,s,d)))}const m=i.q.hiddenValues?p in i.q.hiddenValues:false;f.append("g").append("text").attr("x",s-l+10).attr("y",o).attr("name","sjpp-scatter-legend-label").style("text-decoration",m?"line-through":"none").text(r+(p.includes(g)?`, n=${d.sampleCount}`:"")).on("click",(s=>t.onLegendClick(e,f,n=="shape"?"shapeTW":"colorTW",p,s,d)));o+=25}}return o}}var $t=Object.freeze({__proto__:null,setRenderers:Mt});function zt(t){t.showTooltip=function(e,s){const o=e.type=="click";t.onClick=o;if(o)t.searchMenu?.hide();if(!(e.target.tagName=="path"&&e.target.getAttribute("name")=="serie")){if(t.onClick&&o){t.onClick=false;t.dom.tooltip.hide();return}if(!o){t.dom.tooltip.hide()}return}const a=e.target.__data__;const i="sample"in a;let n=10;n=n/t.zoom;const r=s.data.samples.filter((e=>{const o=It(e.x,e.y,a.x,a.y,s);if(!("sampleId"in e)&&(!t.settings.showRef||t.settings.refSize==0))return false;return t.getOpacity(e)>0&&o<n}));r.sort(((e,s)=>{if(!("sampleId"in e))return 1;if(t.config.term){if(e.x<s.x)return-1;if(e.x>s.x)return 1;if(e.y<s.y)return-1;return 1}if(t.config.colorTW){if(t.config.colorTW.term.type=="categorical"){if(e.category.includes(f.WT.label)||e.category.includes(f.Blank.label))return 1}else{if(e.category<s.category)return-1;else if(e.category>s.category)return 1}}if(e.shape.includes(f.WT.label)||e.shape.includes(f.Blank.label))return 1;return-1}));if(r.length==0)return;const l=[];const p=t.config.term?true:false;const d=t=>`${t.x.toPrecision(2)},${t.y.toPrecision(2)}`;for(const t of r){const e=d(t);let s=l.find((t=>t.id==e));if(!s){s={id:e,parentId:null,samples:[t],level:1,category:null,children:[]};l.push(s);if(p){const o=j("x",t);const a={id:o,parentId:e,samples:[t],level:2,category:"X",children:[],value:o};l.push(a);s.children.push(a);const i=j("y",t);const n={id:`${i}${o}`,parent:a,parentId:o,samples:[t],level:3,category:"Y",children:[],value:i};a.children.push(n);l.push(n);s.xnode=a;s.ynode=n}}else{s.samples.push(t);if(p){s.xnode.samples.push(t);s.ynode.samples.push(t)}}}let h=p?4:2;let m=p?["y","x",""]:[""];if(t.config.colorTW)C("category",t.config.colorTW);if(t.config.shapeTW)C("shape",t.config.shapeTW,t.config.colorTW);if(t.config.scaleDotTW)C("scale",t.config.scaleDotTW,t.config.shapeTW);t.dom.tooltip.clear();const u=t.dom.tooltip.d.style("padding","5px");const g=t.state.termdbConfig.queries?.singleSampleGenomeQuantification;const y=t.state.termdbConfig.queries?.singleSampleMutation;if(r.length>1)u.append("div").style("color","#aaa").style("padding","3px").style("font-weight","bold").html(`${r.length} Samples`);const b=u.append("div").style("max-height","400px").style("overflow","scroll");if(r.length>3)b.attr("class","sjpp_show_scrollbar");const v=b.append("table").style("width","100%");const x=l.filter((t=>p?t.level==1:t.level==2));if(p)for(const t of x){if(r.length>1)v.append("tr").append("td").attr("colspan",3).style("border-top","1px solid #aaa");for(const e of t.children){w(e)}}else for(const t of x){if(r.length>1)v.append("tr").append("td").attr("colspan",3).style("border-top","1px solid #aaa");w(t)}t.dom.tooltip.show(e.clientX,e.clientY,true,false);function S(e){const s=e=="category"?t.config.colorTW:e=="shape"?t.config.shapeTW:e=="scale"?t.config.scaleDotTW:e=="X"&&t.config.term?t.config.term:e=="Y"&&t.config.term2?t.config.term2:null;return s}function w(e){const a=S(e.category);e.added=true;let n;const l=e.samples[0];if(l.category!="Ref"){let n=v.append("tr");const p=a!=null&&(a==t.config.colorTW||a==t.config.shapeTW);let d=a?a.term.name:e.category;if(r.length>1&&!i)d=d+` (${e.samples.length})`;n.append("td").style("color","#aaa").text(d);const h=n.append("td");if(p){const i=a==t.config.colorTW?t.getColor(l,s):t.config.colorTW?"gray":t.settings.defaultColor;const r=a==t.config.colorTW?s.shapeLegend.get("Ref").shape%qt.length:s.shapeLegend.get(l.shape).shape%qt.length;const p=qt[r];let m="black";const u=c("white").toString();if(a?.term.type=="geneVariant"&&a.q.type=="values"){for(const t in f){const s=f[t];if(e.value.includes(s.label)){if(c(s.color).toString()!=u)m=s.color;break}}if(o){n.append("td").append("button").text("Lollipop").on("click",(async e=>{await t.openLollipop(d);t.dom.tip.hide()}))}}let g=e.value.toString().length;const y=g*9+60;const b=h.append("svg").attr("width",y).attr("height","25px");const v=b.append("g").attr("transform","translate(10, 14)");v.append("path").attr("d",p).attr("fill",i).attr("stroke","#aaa").attr("transform","translate(0, -2) scale(0.5)");const x=v.append("text").attr("x",12).attr("y",6).attr("font-size","0.9em");x.append("tspan").text(e.value).attr("fill",m)}else h.style("padding","2px").text(`${e.value}`)}for(const t of e.children)if(!t.added)w(t);if(e.children.length==0&&i){for(const s of e.samples){if("info"in s)for(const[t,e]of Object.entries(s.info)){n=v.append("tr");n.append("td").style("color","#aaa").text(t);n.append("td").text(e)}n=v.append("tr");n.append("td").style("color","#aaa").text("Sample");n.append("td").style("padding","2px").text(s.sample);if("sampleId"in s&&o){n.append("td").append("button").text("Sample view").on("click",(e=>t.openSampleView(s)));if(y)n.append("td").append("button").text("Disco").on("click",(async e=>t.openDiscoPlot(s)));if(g)n.append("td").append("button").text("Met Array").on("click",(async e=>t.openMetArray(s)))}}}}function C(t,e,s){for(const o of r){const a=j(t,o,e);let i="";for(const t of m)i+=j(t,o,s);const n=a+i;let r=l.find((t=>t.id==n&&t.parentId==i));let c=l.find((t=>t.id==i));if(!r){r={id:n,parentId:i,samples:[],level:h,category:t,children:[],value:a};l.push(r)}r.samples.push(o);if(c)c.children.push(r)}h++;m.unshift(t)}function j(t,e,s){if(t=="")return"";let o=e[t];if(s?.term.type=="geneVariant"&&s.q.type=="values"){const s=o.split(", ")[0];for(const a in f){const i=f[a];if(s==i.label){const s=e.cat_info[t].find((t=>t.class==i.key)).mname;if(s)o=`${s} ${o}`}}}if(typeof o=="number"&&o%1!=0)o=o.toPrecision(2);return o}};t.openSampleView=function(e){t.dom.tooltip.hide();t.onClick=false;t.app.dispatch({type:"plot_create",id:ht(),config:{chartType:"sampleView",sample:{sampleId:e.sampleId,sampleName:e.sample}}});t.dom.tip.hide()};t.openMetArray=async function(e){t.dom.tooltip.hide();t.onClick=false;e.sample_id=e.sample;for(const s in t.state.termdbConfig.queries.singleSampleGenomeQuantification){const o=u(t.opts.plotDiv);o.header.text(e.sample_id);const a=await import("./plot.ssgq-b5f68395.js");await a.plotSingleSampleGenomeQuantification(t.state.termdbConfig,t.state.vocab.dslabel,s,e,o.body.append("div").style("margin","20px"),t.app.opts.genome)}t.dom.tip.hide()};t.openDiscoPlot=async function(e){t.dom.tooltip.hide();t.onClick=false;e.sample_id=e.sample;const s=u(t.opts.plotDiv);s.header.text(e.sample_id);const o=await import("./plot.disco-c9249cbd.js");o.default(t.state.termdbConfig,t.state.vocab.dslabel,e,s.body,t.app.opts.genome)};t.openLollipop=async function(e){t.dom.tooltip.hide();t.onClick=false;const s=u(t.opts.plotDiv||select(t.opts.holder.node().parentNode));s.header.text(e);const o={holder:s.body.append("div").style("margin","20px"),genome:t.app.opts.genome,nobox:true,query:e,tklst:[{type:"mds3",dslabel:t.app.opts.state.vocab.dslabel,filter0:t.state.termfilter.filter0,filterObj:structuredClone(t.state.termfilter.filter)}]};const a=await import("./app-3d14cbe4.js").then((function(t){return t.c3}));await a.default(o)};t.onLegendClick=function(s,o,a,i,n,r){const l=t.config[a];const p=l.q.hiddenValues?i in l.q.hiddenValues:false;const d=new e({padding:"0px"});const h=d.d.append("div");h.append("div").attr("class","sja_menuoption sja_sharp_border").text(p?"Show":"Hide").on("click",(()=>{t.hideCategory(o,l,i,!p);d.hide();const e={};e[a]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:e})}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show only").on("click",(()=>{const e=a=="colorTW"?s.colorLegend:s.shapeLegend;for(const s of e.keys())t.hideCategory(o,l,s,l.term.type=="geneVariant"&&l.q.type=="values"?!s.startsWith(i):s!=i);d.hide();const n={};n[a]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:n})}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{d.hide();const e=a=="colorTW"?s.colorLegend:s.shapeLegend;for(const s of e.keys())t.hideCategory(o,l,s,false);const i={};i[a]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:i})}));if(r.color){const e=c(r.color).formatHex();const s=h.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",e).on("change",(()=>{t.changeColor(i,s.node().value);d.hide()}))}d.showunder(n.target)};t.hideCategory=function(e,s,o,a){if(o=="Ref"){t.settings.showRef=!a;t.app.dispatch({type:"plot_edit",id:t.id,config:{settings:{sampleScatter:t.settings}}})}if(!s.q.hiddenValues)s.q.hiddenValues={};const i=!(s.term.type=="geneVariant"&&s.q.type=="values")&&s.term.values[o]?s.term.values[o]:{key:o,label:o};const n=e.selectAll(`text[name="sjpp-scatter-legend-label"]`).nodes();const r=n.find((t=>o.startsWith(t.innerHTML)))?.parentElement;if(r)r.style["text-decoration"]=a?"line-through":"none";if(!a)delete s.q.hiddenValues[o];else s.q.hiddenValues[o]=i};t.changeColor=async function(e,s){const o=t.config.colorTW;if(!(o.term.type=="geneVariant"&&o.q.type=="values")&&o.term.values[e])o.term.values[e].color=s;else{if(!o.term.values)o.term.values={};o.term.values[e]={key:e,label:e,color:s}}await t.app.dispatch({type:"plot_edit",id:t.id,config:{colorTW:o}})};t.searchSample=async function(s){if(!this.searchMenu){this.searchMenu=new e({padding:"3px"});this.samplesData=await this.app.vocabApi.getSamplesByName({filter:t.state.termfilter.filter});const s=t=>{};V(this.searchMenu.d,this.samplesData,s,(e=>t.filterSamples(e)))}this.searchMenu.show(s.clientX,s.clientY,false)};t.filterSamples=function(e){this.filterSampleStr=e;t.render()};t.getCategoryInfo=function(t,e){if(!(e in t))return"";return t[e]};t.addToFilter=function(e){const s=G(t.state.termfilter.filter,"filterUiRoot");const o=q([s,D(e)]);o.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:o})};t.showTable=function(e,s,o,a){let i=[];const n=[];const r=e.items[0];if("sample"in r)n.push(f("Sample","label"));if(t.config.colorTW)n.push(f(t.config.colorTW.term.name,"label"));if(t.config.shapeTW)n.push(f(t.config.shapeTW.term.name,"label"));let l=false;for(const s of e.items){const e=[];if("sample"in s)e.push(f(s.sample));if(t.config.colorTW)e.push(f(t.getCategoryInfo(s,"category")));if(t.config.shapeTW)e.push(f(t.getCategoryInfo(s,"shape")));if("info"in s){l=true;const t=[];for(const[e,o]of Object.entries(s.info))t.push(`${e}: ${o}`);e.push(f(t.join(", ")))}i.push(e)}if(l)n.push(f("Info","label"));t.dom.tip.clear();const c=t.dom.tip.d.append("div").style("padding","5px");const p=c.append("div").style("margin-top","5px");const d=p.append("div").html("&nbsp;"+e.name).style("font-size","0.9rem").on("click",(()=>{const s=d.select("input").empty();if(!s)return;d.html("");const o=d.append("input").attr("value",e.name).on("change",(async()=>{const s=o.node().value;if(s)t.renameGroup(e,s);else o.node().value=e.name;d.html("&nbsp;"+e.name)}));o.node().focus();o.node().select()}));const h=c.append("div");const m=[];if(a){const e={text:"Add to a group",callback:e=>{const s=[];for(const o of e)s.push(t.selectedItems[o].__data__);const o={name:`Group ${t.config.groups.length+1}`,items:s,index:t.config.groups.length};const a=D(k([o]));_(t.app,a,t.state.groups)}};m.push(e)}else{const i={text:"Delete samples",callback:i=>{e.items=e.items.filter(((t,e,s)=>!(e in i)));t.showTable(e,s,o,a)}};m.push(i)}N({rows:i,columns:n,div:h,showLines:true,maxWidth:n.length*"15"+"vw",maxHeight:"35vh",buttons:m,selectAll:true});t.dom.tip.show(s,o,false,false);function f(t,e="value"){let s={};s[e]=t;return s}};t.showGroupMenu=function(e,s){t.dom.tip.clear();t.dom.tip.show(e.clientX,e.clientY,false,true);const o=t.dom.tip.d.append("div");const a=t.config.name?t.config.name:"Summary scatter";const i=k([s],a+" groups");const n=o.append("div").attr("name","sjpp-group-input-div").html("&nbsp;"+s.name).style("font-size","0.9rem").on("click",(()=>{const e=n.select("input").empty();if(!e)return;n.html("");const o=n.append("input").attr("value",s.name).on("change",(async()=>{const e=o.node().value;if(e)t.renameGroup(s,e);else o.node().value=s.name;n.html("&nbsp;"+s.name)}));o.node().focus();o.node().select()}));o.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Edit ${s.items.length} samples`).on("click",(o=>{t.dom.tip.hide();t.showTable(s,e.clientX,e.clientY,false)}));t.addCommonMenuItems(o,i);o.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Delete group`).on("click",(async e=>{await t.app.vocabApi.deleteGroup(s.name);t.dom.tip.hide()}));o.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to filter").on("click",(()=>{t.addToFilter(i);t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:t.config.groups}})}));o.append("div").attr("class","sja_menuoption sja_sharp_border").text(s.showOnly?"Show All":"Show Only").on("click",(()=>{s.showOnly=!s.showOnly;t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:t.config.groups}})}))};t.renameGroup=async function(e,s){const o=t.config.groups.findIndex((t=>t.name==s));if(o!=-1)alert(`Group named ${s} already exists`);else await t.app.dispatch({type:"rename_group",index:e.index,newName:s})};t.addCommonMenuItems=function(e,s){A(t.dom.tip,e,s,t.app,t.id,t.state);if(t.state.supportedChartTypes.includes("survival"))O("survival",e,"Compare survival",t.dom.tip,s,t.id,this);if(t.state.supportedChartTypes.includes("cuminc"))O("cuminc",e,"Compare cumulative incidence",t.dom.tip,s,t.id,this);const o=e.append("div").attr("class","sja_menuoption sja_sharp_border").html("Summarize");o.insert("div").html("›").style("float","right");o.on("click",(async e=>{W(o,(e=>{L(e,s,t.app,t.id)}),t.app,t.dom.tip)}))};t.showGroupsMenu=function(e){t.dom.tip.clear();t.dom.tip.show(e.clientX,e.clientY,false,true);const s=t.dom.tip.d.append("div");const o=t.config.name?t.config.name:"Summary scatter";const a=k(t.config.groups,o+" groups");let i=s.append("div");for(const[o,a]of t.config.groups.entries()){i=s.append("div").attr("class","sja_menuoption sja_sharp_border");i.insert("div").style("display","inline-block").text(` ${a.name}: ${a.items.length} `);i.append("div").style("display","inline-block").style("float","right").html("&nbsp;&nbsp;›");i.on("click",(s=>{t.dom.tip.clear().hide();t.showGroupMenu(e,a)}))}t.addCommonMenuItems(s,a);i=s.append("div").attr("class","sja_menuoption sja_sharp_border").text("Delete groups").on("click",(async e=>{for(const e of t.config.groups)await t.app.vocabApi.deleteGroup(e.name);t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:[]}})}))}}function It(t,e,s,o,a){const i=a.xAxisScale(s)-a.xAxisScale(t);const n=a.yAxisScale(o)-a.yAxisScale(e);const r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));return r}var Nt=Object.freeze({__proto__:null,setInteractivity:zt});const Gt=.2;const Rt=4;const qt=I;class Vt{constructor(){this.type="sampleScatter";this.lassoOn=false;this.zoom=1;this.startGradient={};this.stopGradient={}}async init(t){const s=this.opts.holder.insert("div").style("display","inline-block");const a=s.insert("div").style("display","inline-block").attr("class","pp-termdb-plot-controls");this.mainDiv=this.opts.holder.insert("div").style("display","inline-block").style("vertical-align","top");const i=80;this.axisOffset={x:i,y:30};this.dom={header:this.opts.header,loadingDiv:this.opts.holder.append("div").style("position","absolute").style("left","45%").style("top","60%"),tip:new e({padding:"0px"}),tooltip:new e({padding:"2px",offsetX:10,offsetY:0}),controlsHolder:a,toolsDiv:s.insert("div")};this.settings={};if(this.dom.header)this.dom.header.html("Scatter Plot");zt(this);Mt(this);document.addEventListener("scroll",(t=>this?.dom?.tooltip?.hide()));o(".sjpp-output-sandbox-content").on("scroll",(t=>this.dom.tooltip.hide()))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}const s=M(t);return{config:e,termfilter:t.termfilter,supportedChartTypes:t.termdbConfig.supportedChartTypes[s],matrixplots:t.termdbConfig.matrixplots,vocab:t.vocab,termdbConfig:t.termdbConfig,groups:$(t)}}getDataRequestOpts(){const t=this.config;const e=[];if(t.term)e.push(t.term);if(t.term2)e.push(t.term2);const s={name:t.name,colorTW:t.colorTW,filter:this.getFilter(),coordTWs:e};if(this.state.termfilter.filter0)s.filter0=this.state.termfilter.filter0;if(t.colorColumn)s.colorColumn=t.colorColumn;if(t.shapeTW)s.shapeTW=t.shapeTW;if(t.scaleDotTW){if(!t.scaleDotTW.q)t.scaleDotTW.q={};t.scaleDotTW.q.mode="continuous";s.scaleDotTW=t.scaleDotTW}if(t.term0)s.divideByTW=t.term0;return s}async main(){this.config=structuredClone(this.state.config);if(this.config.settings.sampleScatter.regression!=="None"&&this.config.term0){if(this.charts)for(const t of this.charts)t.chartDiv.selectAll("*").remove();this.dom.loadingDiv.style("display","block").html("Processing data...")}if(this.dom.header)this.dom.header.html(this.config.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">SCATTER PLOT</span>`);g(this.settings,this.config.settings.sampleScatter);const t=this.getDataRequestOpts();if(t.coordTWs.length==1)return;const e=await this.app.vocabApi.getScatterData(t);if(e.error)throw e.error;this.charts=[];let s=0;for(const[t,o]of Object.entries(e)){if(!Array.isArray(o.samples))throw"data.samples[] not array";if(o.isLast)this.createChart(t,o,s);else this.createChart(t,o,0)}this.initRanges();this.is3D=this.config.term&&this.config.term0?.q.mode=="continuous";if(!this.config.colorColumn)await this.setControls();await this.processData();this.render();this.dom.loadingDiv.style("display","none");if(!this.is3D)this.setTools();this.dom.tip.hide()}createChart(t,e,s){const o=e.samples.filter((t=>"sampleId"in t));if(o.length>1e4)this.is2DLarge=true;const a=new Map(e.colorLegend);const i=new Map(e.shapeLegend);this.charts.splice(s,0,{id:t,data:e,cohortSamples:o,colorLegend:a,shapeLegend:i})}initRanges(){if(this.charts.length>1){const t=[];for(const e of this.charts)t.push(...e.data.samples);const e=t[0];const[s,o,a,i,n,r,l,c]=t.reduce(((t,e)=>[e.x<t[0]?e.x:t[0],e.x>t[1]?e.x:t[1],e.y<t[2]?e.y:t[2],e.y>t[3]?e.y:t[3],e.z<t[4]?e.z:t[4],e.z>t[5]?e.z:t[5],"scale"in e?e.scale<t[6]?e.scale:t[6]:Number.POSITIVE_INFINITY,"scale"in e?e.scale>t[7]?e.scale:t[7]:Number.NEGATIVE_INFINITY]),[e.x,e.x,e.y,e.y,e.z,e.z,e.scale,e.scale]);for(const t of this.charts){t.xMin=s;t.xMax=o;t.yMin=a;t.yMax=i;t.zMin=n;t.zMax=r;t.scaleMin=l;t.scaleMax=c}}else for(const t of this.charts){if(t.data.samples.length==0)return;const e=t.data.samples[0];const[s,o,a,i,n,r,l,c]=t.data.samples.reduce(((t,e)=>[e.x<t[0]?e.x:t[0],e.x>t[1]?e.x:t[1],e.y<t[2]?e.y:t[2],e.y>t[3]?e.y:t[3],e.z<t[4]?e.z:t[4],e.z>t[5]?e.z:t[5],"scale"in e?e.scale<t[6]?e.scale:t[6]:Number.POSITIVE_INFINITY,"scale"in e?e.scale>t[7]?e.scale:t[7]:Number.NEGATIVE_INFINITY]),[e.x,e.x,e.y,e.y,e.z,e.z,e.scale,e.scale]);t.xMin=s;t.xMax=o;t.yMin=a;t.yMax=i;t.zMin=n;t.zMax=r;t.scaleMin=l;t.scaleMax=c}}async setControls(){this.dom.controlsHolder.selectAll("*").remove();const t=this.charts[0]?.data.samples.find((t=>!("sampleId"in t)))||false;const e={type:"term",configKey:"scaleDotTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"Scale sample by term value",label:"Scale by",vocabApi:this.app.vocabApi,numericEditMenuVersion:["continuous"]};const s={type:"term",configKey:"shapeTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"shapeTW"},title:"Categories to assign a shape",label:"Shape",vocabApi:this.app.vocabApi};const o={label:"Sample size",type:"number",chartType:"sampleScatter",settingsKey:"size",title:"Sample size, represents the factor used to scale the sample",min:0};const a=(Rt-Gt)/10;const i={label:"Min size",type:"number",chartType:"sampleScatter",settingsKey:"minShapeSize",title:"Minimum sample size",min:Gt,max:Rt,step:a};const n={label:"Max size",type:"number",chartType:"sampleScatter",settingsKey:"maxShapeSize",title:"Maximum sample size",min:Gt,max:Rt,step:a};const r={label:"Scale order",type:"radio",chartType:"sampleScatter",settingsKey:"scaleDotOrder",options:[{label:"Ascending",value:"Ascending"},{label:"Descending",value:"Descending"}]};const l={label:"Reference size",type:"number",chartType:"sampleScatter",settingsKey:"refSize",title:"It represents the area of the reference symbol in square pixels",min:0};const c={boxLabel:"Visible",label:"Show axes",type:"checkbox",chartType:"sampleScatter",settingsKey:"showAxes",title:`Option to show/hide plot axes`};const p=[{type:"term",configKey:"colorTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"colorTW"},title:"Categories to color the samples",label:"Color",vocabApi:this.app.vocabApi,numericEditMenuVersion:["continuous","discrete"]},{label:"Opacity",type:"number",chartType:"sampleScatter",settingsKey:"opacity",title:"It represents the opacity of the elements",min:0,max:1,step:.1},{label:"Chart width",type:"number",chartType:"sampleScatter",settingsKey:"svgw"},{label:"Chart height",type:"number",chartType:"sampleScatter",settingsKey:"svgh"}];if(this.config.sampleCategory){const t=Object.values(this.config.sampleCategory.tw.term.values).map((t=>({label:t.label||t.key,value:t.key})));if(this.config.sampleCategory.order)t.sort(((t,e)=>{const s=this.config.sampleCategory.order.indexOf(t.value);const o=this.config.sampleCategory.order.indexOf(e.value);if(s<o)return-1;return 1}));if(!this.settings.sampleCategory)this.settings.sampleCategory=this.config.sampleCategory.defaultValue||"";t.push({label:"All",value:""});const e={label:"Sample type",type:"dropdown",chartType:"sampleScatter",settingsKey:"sampleCategory",options:t};p.push(e)}if(!this.is2DLarge){p.unshift({type:"term",configKey:"term0",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"term0"},title:"Categories to divide by",label:this.config.term0?.q?.mode=="continuous"?"Z":"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.app.hasWebGL?.()?["discrete","continuous"]:["discrete"],processInput:t=>{if(t?.term.type=="integer"||t?.term.type=="float")t.q={mode:"continuous"}}})}else{p.push({label:"Sample size",type:"number",chartType:"sampleScatter",settingsKey:"threeSize",title:"Sample size",min:0,max:1,step:.001}),p.push({label:"Field of Vision",type:"number",chartType:"sampleScatter",settingsKey:"threeFOV",title:"Field of Vision",min:50,max:90,step:1})}if(this.config.term){p.unshift(...[{type:"term",configKey:"term",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"X coordinate to plot the samples",label:"X",vocabApi:this.app.vocabApi,menuOptions:"!remove",numericEditMenuVersion:["continuous"]},{type:"term",configKey:"term2",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"Y coordinate to plot the samples",label:"Y",vocabApi:this.app.vocabApi,menuOptions:"!remove",numericEditMenuVersion:["continuous"]}]);if(!this.is3D){p.splice(4,0,s);p.splice(5,0,e);if(this.config.scaleDotTW){p.splice(6,0,i);p.splice(7,0,n);p.splice(8,0,r);if(t)p.splice(9,0,l)}else{p.splice(6,0,o);if(t)p.splice(7,0,l)}p.push({label:"Show regression",type:"dropdown",chartType:"sampleScatter",settingsKey:"regression",options:[{label:"None",value:"None"},{label:"Lowess",value:"Lowess"},{label:"Polynomial",value:"Polynomial"}]})}else{p.push({label:"Chart depth",type:"number",chartType:"sampleScatter",settingsKey:"svgd"});p.push({label:"Field of vision",title:"Camera field of view, in degrees",type:"number",chartType:"sampleScatter",settingsKey:"fov"})}p.push(c);p.push({label:"Default color",type:"color",chartType:"sampleScatter",settingsKey:"defaultColor"})}else if(!this.is2DLarge){p.splice(2,0,s);p.splice(3,0,e);if(this.config.scaleDotTW){p.splice(4,0,i);p.splice(5,0,n);p.splice(6,0,r);if(t)p.splice(7,0,l)}else{p.splice(4,0,o);if(t)p.splice(5,0,l)}p.push(c)}this.components={controls:await x({app:this.app,id:this.id,holder:this.dom.controlsHolder,inputs:p})};this.components.controls.on("downloadClick.scatter",(()=>{if(this.is2DLarge||this.is3D){const t=this.canvas.toDataURL("image/png");Ft(t)}else for(const t of this.charts)F(t.svg,"scatter.svg",this.opts.holder.node())}))}getFilter(){const t={type:"tvslst",in:true,join:"and",lst:[]};const e="sampleCategory"in this.settings?this.settings.sampleCategory:this.config.sampleCategory?.defaultValue;if(e){const s=this.config.sampleCategory.tw;t.lst.push({type:"tvs",tvs:{term:s.term,values:[{key:e}]}})}const s=[this.state.termfilter.filter,t];if(this.config.filter)s.push(this.config.filter);const o=q(s);return o}}function Et(t,e,s=null){let o={chartType:"sampleScatter",name:e.name,filter:s};if(e.sampleCategory)o.sampleCategory={tw:structuredClone(e.sampleCategory.tw),order:e.sampleCategory.order,defaultValue:e.sampleCategory.defaultValue};if(e.sampleType)o.sampleType=e.sampleType;if(e.colorTW)o.colorTW=structuredClone(e.colorTW);else if(e.colorColumn)o.colorColumn=structuredClone(e.colorColumn);if("shapeTW"in e)o.shapeTW=structuredClone(e.shapeTW);if(e.settings)o.settings=structuredClone(e.settings);t.dispatch({type:"plot_create",config:o})}function Ft(t){const e=document.createElement("a");e.setAttribute("download","image");document.body.appendChild(e);e.click();e.remove();e.href=t;e.click();e.remove()}async function Pt(t,e){try{if(t.colorTW)await v(t.colorTW,e.vocabApi);if(t.shapeTW)await v(t.shapeTW,e.vocabApi);if(t.term)await v(t.term,e.vocabApi);if(t.term2)await v(t.term2,e.vocabApi);if(t.term0)await v(t.term0,e.vocabApi);if(t.scaleDotTW)await v(t.scaleDotTW,e.vocabApi);if(t.sampleCategory)await v(t.sampleCategory.tw,e.vocabApi);let s=Kt();if(t.settings)g(s,t.settings);if(!t.term&&!t.term2)s.showAxes=false;const o={groups:[],settings:{controls:{isOpen:false},sampleScatter:s},startColor:{},stopColor:{}};const a=g(o,t);if(a.term0?.q?.mode=="continuous"&&!e.hasWebGL())throw"Can not load Z/Divide by term in continuous mode as WebGL is not supported";return a}catch(t){console.log(t);throw`${t} [sampleScatter getPlotConfig()]`}}const Ut=t(Vt);const Bt=Ut;function Ht(t,e){const s=t.append("div");if(e.state.termdbConfig.scatterplots)for(const t of e.state.termdbConfig.scatterplots){s.append("div").attr("class","sja_menuoption sja_sharp_border").text(t.name).on("click",(()=>{Et(e.app,t);e.dom.tip.hide()}))}s.append("div");if(!e.state.termdbConfig.hiddenChartTypes?.includes("dynamicScatter")){const t=(t,s)=>{e.app.dispatch({type:"plot_create",config:{chartType:"sampleScatter",term:{term:t,q:{mode:"continuous"}},term2:{term:s,q:{mode:"continuous"}},name:`${t.name} vs ${s.name}`}})};E(e.dom.tip,e.app,"sampleScatter","numeric",t)}}function Kt(){return{size:1,minShapeSize:.5,maxShapeSize:4,scaleDotOrder:"Ascending",refSize:.8,svgw:500,svgh:500,svgd:500,axisTitleFontSize:16,showAxes:true,showRef:true,opacity:.8,defaultColor:y,regression:"None",fov:50,threeSize:.002,threeFOV:70}}async function Yt(t,e,s){const o={holder:t,state:{vocab:e.vocab,plots:[{chartType:"sampleScatter",subfolder:"plots",name:s.name,colorTW:s.colorTW,sampleType:s.sampleType,sampleCategory:{tw:structuredClone(s.sampleCategory.tw),order:s.sampleCategory.order,defaultValue:s.sampleCategory.defaultValue}}]}};const a=await import("./plot.app-4dc30ebc.js");await a.appInit(o)}var Jt=Object.freeze({__proto__:null,minShapeSize:Gt,maxShapeSize:Rt,shapes:qt,openScatterPlot:Et,downloadImage:Ft,getPlotConfig:Pt,scatterInit:Ut,componentInit:Bt,makeChartBtnMenu:Ht,getDefaultScatterSettings:Kt,renderScatter:Yt});export{Nt as a,Jt as b,Kt as g,ft as n,$t as s};
@@ -1 +0,0 @@
1
- import{h as t}from"./recover-4888c2a9.js";import{M as e}from"./app-3d14cbe4.js";function s(s,n,p,a,d){const i=new e({padding:"5px"});const l=s.d.append("div").style("padding","5px");l.append("div").html("Select variables to plot").style("font-size","0.9rem");let o,c;const r=l.append("div").style("padding-top","5px").html("&nbsp;X&nbsp;&nbsp;");const b=r.append("div").attr("class","sja_filter_tag_btn add_term_btn").text("+").on("click",(t=>{v(b,(t=>o=t),a)}));const f=l.append("div").html("&nbsp;Y&nbsp;&nbsp;");const m=f.append("div").attr("class","sja_filter_tag_btn add_term_btn").text("+").on("click",(t=>{v(m,(t=>c=t),a)}));const u=l.append("div").style("float","right").style("padding","5px").insert("button").text("Submit").property("disabled",true).on("click",(()=>{d(o,c);s.hide()}));function v(e,a,d){const l={tree:{usecase:{detail:d,target:p}}};const r=[];if(o)r.push(o);if(c)r.push(c);t(e,(t=>{a(t);i.hide();e.selectAll("*").remove();e.text(t.name);if(o!=null&&c!=null)u.property("disabled",false)}),n,s,l,false,false,r)}}export{s};