@sjcrh/proteinpaint-client 2.74.2 → 2.76.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.
- package/dist/{2dmaf-b2d78c57.js → 2dmaf-74b99126.js} +1 -1
- package/dist/AppHeader-cecb39c2.js +1 -0
- package/dist/{ColorScale-9c76aef3.js → ColorScale-21cab8d2.js} +1 -1
- package/dist/DEanalysis-95bad59a.js +1 -0
- package/dist/Disco-a6e921a0.js +1 -0
- package/dist/Disco.UI-9ad999ed.js +1 -0
- package/dist/{DragControls-586f72db.js → DragControls-e3b6a937.js} +1 -1
- package/dist/{DziViewer-6311327c.js → DziViewer-354a790d.js} +1 -1
- package/dist/FilterRxComp-701a1480.js +1 -0
- package/dist/{FilterStateless-046081c2.js → FilterStateless-54c0b763.js} +1 -1
- package/dist/{HicApp-40e44cba.js → HicApp-d5a946bf.js} +1 -1
- package/dist/{OrbitControls-0cda1772.js → OrbitControls-694652cd.js} +1 -1
- package/dist/WSIViewer-dc7f8eb0.js +1 -0
- package/dist/adSandbox-f438e388.js +1 -0
- package/dist/app-3320ab6f.js +1 -0
- package/dist/app-649f8357.js +1 -0
- package/dist/app-b369b169.js +1 -0
- package/dist/app.js +1 -1
- package/dist/bam-431875ef.js +1 -0
- package/dist/barchart-8277ed43.js +1 -0
- package/dist/barchart.events-da29c90d.js +1 -0
- package/dist/{bars.renderer-5f7a4174.js → bars.renderer-dcfdd59b.js} +1 -1
- package/dist/block-6aedd569.js +1 -0
- package/dist/block.lazyload-87b12654.js +1 -0
- package/dist/block.legend-d3f61ef7.js +1 -0
- package/dist/{block.mds-effc078d.js → block.mds-3ad17dfa.js} +1 -1
- package/dist/{block.mds.cnv-ec861a26.js → block.mds.cnv-857ba868.js} +1 -1
- package/dist/{block.mds.expressionrank-a2ad7c80.js → block.mds.expressionrank-7e3b208c.js} +1 -1
- package/dist/{block.mds.expressionstat-31dc5595.js → block.mds.expressionstat-f2d31c86.js} +1 -1
- package/dist/{block.mds.geneboxplot-3ca857ce.js → block.mds.geneboxplot-f0fbaf12.js} +1 -1
- package/dist/{block.mds.junction-debba938.js → block.mds.junction-7f87f48f.js} +1 -1
- package/dist/{block.mds.svcnv-8dc5abdf.js → block.mds.svcnv-ac035c12.js} +1 -1
- package/dist/{block.mds.svcnv.share-81e62600.js → block.mds.svcnv.share-886d9479.js} +1 -1
- package/dist/block.mds2-7852c1ee.js +1 -0
- package/dist/{block.svg-9121e8e7.js → block.svg-9b916fa6.js} +1 -1
- package/dist/{block.tk.aicheck-c1b478e9.js → block.tk.aicheck-6770e333.js} +1 -1
- package/dist/{block.tk.ase-0f6ded48.js → block.tk.ase-ee807e59.js} +1 -1
- package/dist/{block.tk.bam-7cd06aee.js → block.tk.bam-00fba6e8.js} +1 -1
- package/dist/{block.tk.bedgraphdot-3ef8b94e.js → block.tk.bedgraphdot-7fda78e9.js} +1 -1
- package/dist/{block.tk.bigwig.ui-d1248810.js → block.tk.bigwig.ui-cc1a42f3.js} +1 -1
- package/dist/{block.tk.hicstraw-ee731e55.js → block.tk.hicstraw-526470e3.js} +1 -1
- package/dist/{block.tk.junction-4d8cab4d.js → block.tk.junction-b43a4cda.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-a6430b27.js → block.tk.junction.textmatrixui-a60ed78a.js} +1 -1
- package/dist/{block.tk.ld-8429a18b.js → block.tk.ld-d15bde41.js} +1 -1
- package/dist/{block.tk.menu-3f31f958.js → block.tk.menu-3aeb93c6.js} +1 -1
- package/dist/{block.tk.pgv-07e46705.js → block.tk.pgv-9af2bd64.js} +1 -1
- package/dist/boxplot-e17a17b7.js +1 -0
- package/dist/brainImaging-bf2ceee9.js +1 -0
- package/dist/{brush-c386fe3d.js → brush-aa175142.js} +1 -1
- package/dist/categorical-a52014a1.js +1 -0
- package/dist/condition-c646e357.js +1 -0
- package/dist/controls-287e6efa.js +1 -0
- package/dist/{controls.btns-1cb2bfab.js → controls.btns-79b805dd.js} +1 -1
- package/dist/controls.config-28d6d6a8.js +1 -0
- package/dist/cuminc-9e275854.js +1 -0
- package/dist/{customdata.inputui-cbd712ea.js → customdata.inputui-dc49d94b.js} +1 -1
- package/dist/dataDownload-3a3d4f33.js +1 -0
- package/dist/databrowser.ui-d8d3f8fd.js +1 -0
- package/dist/{density-19266ebf.js → density-a82a8b1c.js} +1 -1
- package/dist/dictionary-c5a19d90.js +1 -0
- package/dist/{drag-0b968811.js → drag-7b30ba17.js} +1 -1
- package/dist/{e2pca-b8752945.js → e2pca-82765817.js} +1 -1
- package/dist/{ep-a86b185a.js → ep-d017ec2f.js} +1 -1
- package/dist/facet-a9b44ef3.js +1 -0
- package/dist/{fusion.parse-244b2b97.js → fusion.parse-d40d0b9d.js} +1 -1
- package/dist/geneExpClustering-34c3f518.js +1 -0
- package/dist/geneExpression-0d1b7244.js +1 -0
- package/dist/{geneExpression-e0430f2e.js → geneExpression-589f485b.js} +1 -1
- package/dist/{geneExpression-387205bf.js → geneExpression-7d14983f.js} +1 -1
- package/dist/geneORA-903a780f.js +1 -0
- package/dist/{geneVariant-7de021b6.js → geneVariant-89601b34.js} +1 -1
- package/dist/geneVariant-92c4e870.js +1 -0
- package/dist/{genefusion.ui-a331de19.js → genefusion.ui-7e22e811.js} +1 -1
- package/dist/{genesearch-ea59f5d4.js → genesearch-a4e19f0d.js} +1 -1
- package/dist/geneset-108a39d2.js +1 -0
- package/dist/genomeBrowser-12f86a36.js +1 -0
- package/dist/genomeBrowser.controls-d5067811.js +1 -0
- package/dist/{groupsetting-20ffef77.js → groupsetting-b4416a96.js} +1 -1
- package/dist/gsea-543dab25.js +1 -0
- package/dist/hierCluster-26e14090.js +1 -0
- package/dist/hierCluster.config-98e82dff.js +1 -0
- package/dist/{hierCluster.interactivity-9b433033.js → hierCluster.interactivity-e56f6542.js} +1 -1
- package/dist/hierCluster.renderers-74a64cf5.js +1 -0
- package/dist/{html.legend-abb5452e.js → html.legend-a3f4ebfe.js} +1 -1
- package/dist/imagePlot-b9eae4ae.js +1 -0
- package/dist/{lasso-55cf4057.js → lasso-f767f634.js} +1 -1
- package/dist/launch.adhoc-abca6af3.js +1 -0
- package/dist/leftlabel.sample-24c2388d.js +1 -0
- package/dist/legacyDataset-e0e201ab.js +1 -0
- package/dist/{log-cf45fcf2.js → log-99af3443.js} +1 -1
- package/dist/{lollipop-c5b6e615.js → lollipop-806f8fa4.js} +1 -1
- package/dist/{maf-7535f1f9.js → maf-b06579e4.js} +1 -1
- package/dist/{maftimeline-1292ab62.js → maftimeline-4840a380.js} +1 -1
- package/dist/matrix-00bb50ff.js +1 -0
- package/dist/matrix.cells-914dd0c6.js +1 -0
- package/dist/{matrix.cluster-168bc96b.js → matrix.cluster-783ceab0.js} +1 -1
- package/dist/matrix.config-6ce74dfe.js +1 -0
- package/dist/matrix.controls-7b2a6f95.js +1 -0
- package/dist/{matrix.data-b1d0febe.js → matrix.data-dac4f1b7.js} +1 -1
- package/dist/{matrix.dom-00defa30.js → matrix.dom-4e10bbe9.js} +1 -1
- package/dist/matrix.groups-b9fca14a.js +1 -0
- package/dist/matrix.interactivity-84169b43.js +1 -0
- package/dist/{matrix.layout-c2345231.js → matrix.layout-dd5a44fd.js} +1 -1
- package/dist/matrix.legend-ac6d45e6.js +1 -0
- package/dist/matrix.renderers-78010275.js +1 -0
- package/dist/matrix.serieses-9b4fd744.js +1 -0
- package/dist/matrix.sort-014d798d.js +1 -0
- package/dist/{matrix.sorterUi-a741ba2e.js → matrix.sorterUi-9bf7e6f9.js} +1 -1
- package/dist/{mavb-92136d17.js → mavb-c6be46fc.js} +1 -1
- package/dist/{mds.fimo-c03115b4.js → mds.fimo-bff6a1ed.js} +1 -1
- package/dist/mds.samplescatterplot-9a02b9fb.js +1 -0
- package/dist/{mds.survivalplot-366db380.js → mds.survivalplot-055549f4.js} +1 -1
- package/dist/{metaboliteIntensity-ddb6e480.js → metaboliteIntensity-fac92f8b.js} +1 -1
- package/dist/niceNumLabels-238aabce.js +1 -0
- package/dist/{nodrag-2c046d31.js → nodrag-16ad4b03.js} +1 -1
- package/dist/{notify-44ebc0df.js → notify-224cccbd.js} +1 -1
- package/dist/{numeric-918d4686.js → numeric-b0b17185.js} +1 -1
- package/dist/numeric.binary-1f9e93f2.js +1 -0
- package/dist/numeric.continuous-ebcd0567.js +1 -0
- package/dist/numeric.discrete-7b97044a.js +1 -0
- package/dist/numeric.spline-1be88f3d.js +1 -0
- package/dist/numeric.toggle-7fa2a770.js +1 -0
- package/dist/oncomatrix-351af2a0.js +1 -0
- package/dist/{parseData-e66308cd.js → parseData-21fe9822.js} +1 -1
- package/dist/partjson.esm-b3f1fc21.js +1 -0
- package/dist/{plot.2dvaf-73dbfbd1.js → plot.2dvaf-18a35e4b.js} +1 -1
- package/dist/plot.app-30c4b8e5.js +1 -0
- package/dist/plot.barplot-7c4865a2.js +1 -0
- package/dist/{plot.boxplot-641da058.js → plot.boxplot-fe3046c6.js} +1 -1
- package/dist/plot.brainImaging-2ceb6023.js +1 -0
- package/dist/plot.disco-6011f87f.js +1 -0
- package/dist/{plot.dzi-41ea26e5.js → plot.dzi-6728a7c8.js} +1 -1
- package/dist/plot.ssgq-5581dc56.js +1 -0
- package/dist/{plot.vaf2cov-80e58833.js → plot.vaf2cov-b2284c64.js} +1 -1
- package/dist/{plot.wsi-51cc48ef.js → plot.wsi-9a9d4034.js} +1 -1
- package/dist/profileBarchart-0476f1f8.js +1 -0
- package/dist/profileHome-32eb9b50.js +1 -0
- package/dist/profilePlot-c7e099e8.js +1 -0
- package/dist/profilePolar-6b981e63.js +1 -0
- package/dist/profileRadar-bca1cc03.js +1 -0
- package/dist/profileRadarFacility-bbb1ecd8.js +1 -0
- package/dist/profileSummary-b114204f.js +1 -0
- package/dist/recover-49e09de0.js +1 -0
- package/dist/regression.inputs-a761f40d.js +1 -0
- package/dist/regression.inputs.values.table-5929d25a.js +1 -0
- package/dist/regression.results-69bc42d0.js +1 -0
- package/dist/{renderPvalueTable-895a72c2.js → renderPvalueTable-dc5d15f2.js} +1 -1
- package/dist/sampleScatter-2d0ed680.js +1 -0
- package/dist/{sampleScatter.rendererThree-5e686004.js → sampleScatter.rendererThree-0b12ac61.js} +2 -2
- package/dist/sampleView-484ab133.js +1 -0
- package/dist/samplelst-689796e6.js +1 -0
- package/dist/{samplematrix-2a1d7d82.js → samplematrix-2b137a05.js} +1 -1
- package/dist/scatter-205e013f.js +1 -0
- package/dist/{select2Terms-b4fffc50.js → select2Terms-b21e184a.js} +1 -1
- package/dist/{selectGenomeWithTklst-acf7e568.js → selectGenomeWithTklst-466995b4.js} +1 -1
- package/dist/singleCellCellType-5db730bb.js +1 -0
- package/dist/{singleCellGeneExpression-6de17162.js → singleCellGeneExpression-7147a2d0.js} +1 -1
- package/dist/singleCellPlot-73b2738f.js +1 -0
- package/dist/{singlecell-f76c856a.js → singlecell-24409b72.js} +1 -1
- package/dist/singlecell-bca774ed.js +1 -0
- package/dist/{snp-9590a1b4.js → snp-37d06246.js} +1 -1
- package/dist/snp-a8388ce4.js +1 -0
- package/dist/snplocus-7a1ea8c9.js +1 -0
- package/dist/{snplst-007a1926.js → snplst-6865d7c7.js} +1 -1
- package/dist/{spliceevent.a53ss.diagram-63dfef69.js → spliceevent.a53ss.diagram-e2eab72b.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-76fa9af8.js → spliceevent.exonskip.diagram-4d5df3a1.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-a94aad6e.js +1 -0
- package/dist/{spliceevent.noeventdiagram-64a099e0.js → spliceevent.noeventdiagram-ea97b0fb.js} +1 -1
- package/dist/{spliceevent.phrase-770c8cac.js → spliceevent.phrase-c5832470.js} +1 -1
- package/dist/{stattable-f1189f0f.js → stattable-7c5ecc2f.js} +1 -1
- package/dist/{style.gdc-89cfdb0f.js → style.gdc-131f3c77.js} +1 -1
- package/dist/summary-5ec455d3.js +1 -0
- package/dist/{sunburst-d5379952.js → sunburst-533902a7.js} +1 -1
- package/dist/survival-92250664.js +1 -0
- package/dist/survival-e16e068f.js +1 -0
- package/dist/{svg.download-86850940.js → svg.download-35926549.js} +1 -1
- package/dist/{svg.legend-a94b0697.js → svg.legend-8d490df2.js} +1 -1
- package/dist/{svgraph-c57b9ae3.js → svgraph-6fac8cbc.js} +1 -1
- package/dist/{svmr-cf6f1b27.js → svmr-d07ff695.js} +1 -1
- package/dist/table-29d5a973.js +1 -0
- package/dist/table-ad744310.js +1 -0
- package/dist/termInfo-bf99a37e.js +1 -0
- package/dist/{termdb.bins-9faa5170.js → termdb.bins-8b656cc3.js} +1 -1
- package/dist/termsetting-33ea66f1.js +1 -0
- package/dist/tk-071a7550.js +1 -0
- package/dist/{toggleButtons-002aeda1.js → toggleButtons-dbdbad01.js} +1 -1
- package/dist/tp.ui-9c2e9fc5.js +1 -0
- package/dist/tslib.es6-c3c2d88f.js +1 -0
- package/dist/tvs.density-f6128793.js +1 -0
- package/dist/{tvs.geneVariant-3a65ad94.js → tvs.geneVariant-ca4bdbb1.js} +1 -1
- package/dist/tvs.numeric-0260a825.js +1 -0
- package/dist/{tvs.samplelst-1eeb586b.js → tvs.samplelst-cb71b3bf.js} +1 -1
- package/dist/{uiUtils-1336bad7.js → uiUtils-f1bd2bcc.js} +1 -1
- package/dist/{variantBrowser-f0c812c1.js → variantBrowser-7c540224.js} +1 -1
- package/dist/{vcf-c4a23924.js → vcf-5cc55588.js} +1 -1
- package/dist/violin-2ba509eb.js +1 -0
- package/dist/violin.interactivity-4da6d7a9.js +1 -0
- package/dist/{violin.renderer-dafd89fa.js → violin.renderer-ce024265.js} +1 -1
- package/dist/{violinRenderer-8215f40d.js → violinRenderer-f7c96a60.js} +1 -1
- package/dist/{viridis-ffd14c4d.js → viridis-01ab20c5.js} +1 -1
- package/dist/{y-dd197cc9.js → y-67939f83.js} +1 -1
- package/dist/{zoom-9c63e74c.js → zoom-25dce8b9.js} +1 -1
- package/package.json +6 -4
- package/dist/AppHeader-a2a7e518.js +0 -1
- package/dist/DEanalysis-a6b50e49.js +0 -1
- package/dist/Disco-1c71b7dd.js +0 -1
- package/dist/Disco.UI-4c16ee50.js +0 -1
- package/dist/FilterRxComp-242f4615.js +0 -1
- package/dist/WSIViewer-d90032d7.js +0 -1
- package/dist/adSandbox-3528c372.js +0 -1
- package/dist/app-07dee349.js +0 -1
- package/dist/app-a8c4854a.js +0 -1
- package/dist/app-ade9c62a.js +0 -1
- package/dist/bam-92483a98.js +0 -1
- package/dist/barchart-3e69d094.js +0 -1
- package/dist/barchart.events-9b11d97e.js +0 -1
- package/dist/block-dcb130fb.js +0 -1
- package/dist/block.lazyload-9f031cac.js +0 -1
- package/dist/block.legend-b2987cd9.js +0 -1
- package/dist/block.mds2-de6e0986.js +0 -1
- package/dist/boxplot-1178fffc.js +0 -1
- package/dist/brainImaging-98ed7aa2.js +0 -1
- package/dist/categorical-26528ce8.js +0 -1
- package/dist/condition-b0d74550.js +0 -1
- package/dist/controls-0bacec22.js +0 -1
- package/dist/controls.config-0ccc9d79.js +0 -1
- package/dist/controls.divide-a9fe9466.js +0 -1
- package/dist/controls.overlay-fe20d41d.js +0 -1
- package/dist/controls.term1-faa2efcf.js +0 -1
- package/dist/cuminc-7e2cac2d.js +0 -1
- package/dist/dataDownload-ade8d840.js +0 -1
- package/dist/databrowser.ui-716f0519.js +0 -1
- package/dist/dictionary-3f83ce63.js +0 -1
- package/dist/facet-6850cfed.js +0 -1
- package/dist/geneExpClustering-7fd3c87e.js +0 -1
- package/dist/geneExpression-6462537d.js +0 -1
- package/dist/geneORA-7eb818c4.js +0 -1
- package/dist/geneVariant-b58e924a.js +0 -1
- package/dist/geneset-9f69ad3f.js +0 -1
- package/dist/genomeBrowser-1b2b83f7.js +0 -1
- package/dist/genomeBrowser.controls-cd8ddeb1.js +0 -1
- package/dist/gsea-36376589.js +0 -1
- package/dist/hierCluster-f1e30c19.js +0 -1
- package/dist/hierCluster.config-da3510b1.js +0 -1
- package/dist/hierCluster.renderers-610d8860.js +0 -1
- package/dist/imagePlot-7089bdff.js +0 -1
- package/dist/launch.adhoc-d229fd55.js +0 -1
- package/dist/leftlabel.sample-a919168c.js +0 -1
- package/dist/legacyDataset-1cbcb67d.js +0 -1
- package/dist/matrix-0614794d.js +0 -1
- package/dist/matrix.cells-819d4991.js +0 -1
- package/dist/matrix.config-c54ca273.js +0 -1
- package/dist/matrix.controls-5eca7822.js +0 -1
- package/dist/matrix.groups-4660dd70.js +0 -1
- package/dist/matrix.interactivity-23d83183.js +0 -1
- package/dist/matrix.legend-2e647224.js +0 -1
- package/dist/matrix.renderers-43445f4f.js +0 -1
- package/dist/matrix.serieses-972fbe5d.js +0 -1
- package/dist/matrix.sort-80d9b788.js +0 -1
- package/dist/mds.samplescatterplot-1623e6d0.js +0 -1
- package/dist/niceNumLabels-6cfc1508.js +0 -1
- package/dist/numeric.binary-80467e8b.js +0 -1
- package/dist/numeric.continuous-69a62a15.js +0 -1
- package/dist/numeric.discrete-86181905.js +0 -1
- package/dist/numeric.spline-1b07fd13.js +0 -1
- package/dist/numeric.toggle-37c4bee8.js +0 -1
- package/dist/oncomatrix-475271da.js +0 -1
- package/dist/plot.app-aa916e0e.js +0 -1
- package/dist/plot.barplot-8b440a2b.js +0 -1
- package/dist/plot.brainImaging-2f796b0c.js +0 -1
- package/dist/plot.disco-43e18d2f.js +0 -1
- package/dist/plot.ssgq-e49cb70b.js +0 -1
- package/dist/profileBarchart-91463ab6.js +0 -1
- package/dist/profileHome-d37a6821.js +0 -1
- package/dist/profilePlot-9ca577cb.js +0 -1
- package/dist/profilePolar-19c7da5b.js +0 -1
- package/dist/profileRadar-8bf094e3.js +0 -1
- package/dist/profileRadarFacility-f9fd8971.js +0 -1
- package/dist/profileSummary-93999c14.js +0 -1
- package/dist/recover-36ada47f.js +0 -1
- package/dist/regression.inputs-cb57ece6.js +0 -1
- package/dist/regression.inputs.values.table-908bb37a.js +0 -1
- package/dist/regression.results-c186a8dc.js +0 -1
- package/dist/roundValue-b0d0517c.js +0 -1
- package/dist/sampleScatter-9d5b3630.js +0 -1
- package/dist/sampleView-2d895023.js +0 -1
- package/dist/samplelst-9f8343ff.js +0 -1
- package/dist/scatter-b4992f64.js +0 -1
- package/dist/singleCellCellType-84a0c2cf.js +0 -1
- package/dist/singleCellPlot-2f2b8619.js +0 -1
- package/dist/singlecell-90567dde.js +0 -1
- package/dist/snp-79ec95ba.js +0 -1
- package/dist/snplocus-cb629be1.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-31d2950c.js +0 -1
- package/dist/summary-b77bef3c.js +0 -1
- package/dist/survival-61ab375a.js +0 -1
- package/dist/survival-80a0ade9.js +0 -1
- package/dist/table-79e3e776.js +0 -1
- package/dist/table-eee91e14.js +0 -1
- package/dist/termInfo-f851b415.js +0 -1
- package/dist/tk-75566002.js +0 -1
- package/dist/tp.ui-02911b56.js +0 -1
- package/dist/tslib.es6-1f85f553.js +0 -1
- package/dist/tvs.density-026fca97.js +0 -1
- package/dist/tvs.numeric-3f3d9919.js +0 -1
- package/dist/violin-1515c3e6.js +0 -1
- package/dist/violin.interactivity-8e2f480d.js +0 -1
package/dist/Disco-1c71b7dd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-1f85f553.js";import{M as e,D as s,ak as n,at as i,as as o,ap as a,aq as r,z as l,I as c,d as h,P as d,h as p,K as u}from"./app-a8c4854a.js";import{d as g}from"./arc-3d6751aa.js";import{p as m,c as f}from"./constant-426a1483.js";import{s as v}from"./svg.legend-a94b0697.js";import{a as A,l as x}from"./line-264f8f9e.js";import{t as M}from"./math-2fb199c6.js";import{topBarInit as R}from"./controls.btns-1cb2bfab.js";import{configUiInit as b}from"./controls.config-0ccc9d79.js";import"./controls.overlay-fe20d41d.js";import"./roundValue-b0d0517c.js";import"path";import"./FilterRxComp-242f4615.js";import"./table-79e3e776.js";import"./termdb.bins-9faa5170.js";import"./controls.term1-faa2efcf.js";import"./controls.divide-a9fe9466.js";var C=Math.abs;var y=Math.cos;var w=Math.sin;var I=Math.PI;var L=I/2;var D=1e-12;var T=Array.prototype.slice;function P(t){return function(){return t}}function O(t){return t.source}function N(t){return t.target}function E(t){return t.radius}function V(t){return t.startAngle}function S(t){return t.endAngle}function z(){return 0}function B(t){var e=O,s=N,n=E,i=E,o=V,a=S,r=z,l=null;function c(){var c,h=e.apply(this,arguments),d=s.apply(this,arguments),p=r.apply(this,arguments)/2,u=T.call(arguments),g=+n.apply(this,(u[0]=h,u)),f=o.apply(this,u)-L,v=a.apply(this,u)-L,A=+i.apply(this,(u[0]=d,u)),x=o.apply(this,u)-L,M=a.apply(this,u)-L;if(!l)l=c=m();if(p>D){if(C(v-f)>p*2+D)v>f?(f+=p,v-=p):(f-=p,v+=p);else f=v=(f+v)/2;if(C(M-x)>p*2+D)M>x?(x+=p,M-=p):(x-=p,M+=p);else x=M=(x+M)/2}l.moveTo(g*y(f),g*w(f));l.arc(0,0,g,f,v);if(f!==x||v!==M){if(t){var R=+t.apply(this,arguments),b=A-R,I=(x+M)/2;l.quadraticCurveTo(0,0,b*y(x),b*w(x));l.lineTo(A*y(I),A*w(I));l.lineTo(b*y(M),b*w(M))}else{l.quadraticCurveTo(0,0,A*y(x),A*w(x));l.arc(0,0,A,x,M)}}l.quadraticCurveTo(0,0,g*y(f),g*w(f));l.closePath();if(c)return l=null,c+""||null}if(t)c.headRadius=function(e){return arguments.length?(t=typeof e==="function"?e:P(+e),c):t};c.radius=function(t){return arguments.length?(n=i=typeof t==="function"?t:P(+t),c):n};c.sourceRadius=function(t){return arguments.length?(n=typeof t==="function"?t:P(+t),c):n};c.targetRadius=function(t){return arguments.length?(i=typeof t==="function"?t:P(+t),c):i};c.startAngle=function(t){return arguments.length?(o=typeof t==="function"?t:P(+t),c):o};c.endAngle=function(t){return arguments.length?(a=typeof t==="function"?t:P(+t),c):a};c.padAngle=function(t){return arguments.length?(r=typeof t==="function"?t:P(+t),c):r};c.source=function(t){return arguments.length?(e=t,c):e};c.target=function(t){return arguments.length?(s=t,c):s};c.context=function(t){return arguments.length?(l=t==null?null:t,c):l};return c}function G(){return B()}function $(t,e){return e<t?-1:e>t?1:e>=t?0:NaN}function k(t){return t}function W(){var t=k,e=$,s=null,n=f(0),i=f(M),o=f(0);function a(a){var r,l=(a=A(a)).length,c,h,d=0,p=new Array(l),u=new Array(l),g=+n.apply(this,arguments),m=Math.min(M,Math.max(-M,i.apply(this,arguments)-g)),f,v=Math.min(Math.abs(m)/l,o.apply(this,arguments)),x=v*(m<0?-1:1),R;for(r=0;r<l;++r){if((R=u[p[r]=r]=+t(a[r],r,a))>0){d+=R}}if(e!=null)p.sort((function(t,s){return e(u[t],u[s])}));else if(s!=null)p.sort((function(t,e){return s(a[t],a[e])}));for(r=0,h=d?(m-l*x)/d:0;r<l;++r,g=f){c=p[r],R=u[c],f=g+(R>0?R*h:0)+x,u[c]={data:a[c],index:r,value:R,startAngle:g,endAngle:f,padAngle:v}}return u}a.value=function(e){return arguments.length?(t=typeof e==="function"?e:f(+e),a):t};a.sortValues=function(t){return arguments.length?(e=t,s=null,a):e};a.sort=function(t){return arguments.length?(s=t,e=null,a):s};a.startAngle=function(t){return arguments.length?(n=typeof t==="function"?t:f(+t),a):n};a.endAngle=function(t){return arguments.length?(i=typeof t==="function"?t:f(+t),a):i};a.padAngle=function(t){return arguments.length?(o=typeof t==="function"?t:f(+t),a):o};return a}class F{constructor(t,e,s){this.radius=t;this.width=e;this.color=s}render(t){const e=g();const s={startAngle:0,endAngle:Math.PI*2,innerRadius:this.radius,outerRadius:this.radius+this.width,color:this.color,text:"No label"};const n=[];n.push(s);const i=t.append("g");i.selectAll("path").data(n).enter().append("path").attr("d",(t=>e(t))).attr("fill",(t=>t.color))}}class j{static create(){const t=new e({padding:5});t.d.style("border","1px solid #FFF").style("position","absolute").style("z-index",1001);return t}}var _;(function(t){t["Intrachromosomal"]="#1B9E77";t["Interchromosomal"]="#6A3D9A"})(_||(_={}));class H{static getColor(t,e){if(t!=e){return _.Interchromosomal.valueOf()}else{return _.Intrachromosomal.valueOf()}}}class U{render(t,e){let n=0;if(e.length>0){n=e[0].target.radius;const s=new F(n,2,"#6464641A");s.render(t)}const i=G().radius(n);const o=t.selectAll(".chord").data(e);const a=j.create();o.enter().append("path").attr("class","chord").attr("d",i).attr("fill",(t=>H.getColor(t.source.positionInChromosome.chromosome,t.target.positionInChromosome.chromosome))).on("mouseover",((t,e)=>{const n=s({holder:a.d});this.createTooltip(n,e);a.show(t.x,t.y)})).on("mouseout",(()=>{a.clear();a.hide()}))}createTooltip(t,e){{const[e,s]=t.addRow();e.text("Data type");s.append("span").style("margin-left","5px").text("Fusion transcript")}{const s=e.source.positionInChromosome;const n=e.target.positionInChromosome;const[i,o]=t.addRow();i.text("Position");o.append("span").style("margin-left","5px").text(` ${e.source.gene?e.source.gene:""} ${s.chromosome}:${s.position} ${e.source.strand=="+"?"forward":"reverse"} > `+` ${e.target.gene?e.target.gene:""} ${n.chromosome}:${n.position} ${e.target.strand=="+"?"forward":"reverse"} `)}}}class q{constructor(t,e){this.renders=t;this.legendRenderer=e;this.fusionRenderer=new U}render(t,e){const s=t.append("div").style("display","inline-block").style("font-family","Arial");const n=s.append("svg").attr("id","sjpp_disco_plot").attr("data-testid","sjpp_disco_plot").attr("width",e.width).attr("height",e.height+e.legendHeight);const i=n.append("g").attr("class","mainG").attr("transform",`translate(${e.settings.rings.labelLinesInnerRadius+e.settings.rings.labelsToLinesDistance+100},${e.height/2})`);for(const[t,s]of this.renders){const n=e.getElements(t);const o=e.getCollisions(t);s.render(i,n,o)}this.fusionRenderer.render(i,e.fusions);this.legendRenderer.render(i,e.legend,-1*(e.settings.rings.labelLinesInnerRadius+e.settings.rings.labelsToLinesDistance+50),e.width,e.height/2)}}class X{constructor(e){this.discoApp=e;this.downloadClickListener=t=>{const e=this.discoApp.state.settings.downloadImgName||"disco.plot";const s=document.createElement("a");document.body.appendChild(s);s.addEventListener("click",(()=>{const n=new XMLSerializer;const i=new Blob([n.serializeToString(t)],{type:"image/svg+xml"});s.download=e+".svg";s.href=URL.createObjectURL(i);document.body.removeChild(s)}),false);s.click()};this.geneClickListener=(e,s)=>t(this,void 0,void 0,(function*(){const{filter:t,filter0:n}=this.discoApp.app.getState().termfilter;const i={holder:this.discoApp.app.opts.holder,genome:this.discoApp.app.opts.state.args.genome,nobox:true,query:e,tklst:[{type:"mds3",dslabel:this.discoApp.app.opts.state.dslabel,hlaachange:s.join(","),filter0:n,filterObj:t}]};const o=yield import("./app-a8c4854a.js").then((function(t){return t.c3}));yield o.default(i)}))}}class K{constructor(t,e,s){this.chromosomes=[];this.chromosomesOrder=[];this.keysArray=[];this.totalSizeArray=[];this.chrSizesArray=[];const n=s||e;this.settings=t;this.chromosomesOrder=[];let i=0;this.totalPadAngle=Object.keys(n).length*this.settings.padAngle;this.totalChromosomesAngle=2*Math.PI-this.totalPadAngle;for(const t in n){const e=t.slice(0,3)==="chr"?t.slice(3):t;this.chromosomesOrder.push(t);this.keysArray.push(e);this.totalSizeArray.push(i);this.chrSizesArray.push(n[t]);i+=n[t]}this.totalSize=i;let o=0;for(let t=0;t<this.keysArray.length;t++){const e=this.totalChromosomesAngle*(this.chrSizesArray[t]/i);const s=t==0?this.settings.padAngle/2:o+this.settings.padAngle;const n=t==0?this.settings.padAngle/2+e:o+this.settings.padAngle+e;const a={start:this.totalSizeArray[t],size:this.chrSizesArray[t],factor:1,startAngle:s,endAngle:n,angle:(s+n)/2,innerRadius:this.settings.chromosomeInnerRadius,outerRadius:this.settings.chromosomeInnerRadius+this.settings.chromosomeWidth,color:"#AAA",text:this.keysArray[t]};this.chromosomes.push(a);if(a.endAngle!=null){o=a.endAngle}}}}class J{constructor(t,e){this.sampleName=t;this.prioritizedGenes=e}map(t){return{dt:t.dt,mname:t.mname,mClass:t.class,gene:t.gene,chr:t.chr,ref:t.ref,alt:t.alt,position:t.pos?t.pos:t.position,poschr:t.poschr,posbins:t.posbins,poslabel:t.poslabel,sampleName:this.sampleName,ssm_id:t.ssm_id,start:t.start,stop:t.stop,value:t.value,segmean:t.segmean,isPrioritized:this.prioritizedGenes.some((e=>e==t.gene)),chrA:t.chrA,chrB:t.chrB,geneA:t.geneA,geneB:t.geneB,posA:t.posA,posB:t.posB,strandA:t.strandA,strandB:t.strandB}}}class Q{map(t,e){return this.calculatePercentileForPositivesAndNegatives(t,e)}calculatePercentileForPositivesAndNegatives(t,e){const s=t.filter((t=>t>0));const n=t.filter((t=>t<0)).map((t=>-1*t));let i=NaN;let o=NaN;if(s.length>0){i=this.calculatePercentile(s,e)}if(n.length>0){o=-1*this.calculatePercentile(n,e)}return{positive:i,negative:o}}calculatePercentile(t,e){if(t.length===0){throw new Error("Array must contain at least one element.")}const s=t.sort(((t,e)=>t-e));const n=e/100*(s.length-1);const i=Math.floor(n);const o=Math.ceil(n);const a=n-i;if(i===o){return s[i]}return s[i]+a*(s[o]-s[i])}}class Y{constructor(t,e,s,l=[]){this.labelData=[];this.nonExonicSnvData=[];this.nonExonicInnerRadius=0;this.snvRingDataMap=new Map;this.snvInnerRadius=0;this.snvData=[];this.bpx=0;this.onePxArcAngle=0;this.filteredSnvData=[];this.lohData=[];this.lohInnerRadius=0;this.cnvData=[];this.cnvInnerRadius=0;this.fusionData=[];this.fusionRadius=0;this.hasPrioritizedGenes=false;this.cnvLossMaxValue=0;this.cnvGainMaxValue=0;this.percentilePositive=0;this.percentileNegative=0;this.cnvMaxPercentileAbs=0;this.lohMaxValue=undefined;this.lohMinValue=undefined;this.snvFilter=t=>t.dt==n;this.fusionFilter=t=>t.dt==i||t.dt==o;this.cnvFilter=t=>t.dt==a;this.lohFilter=t=>t.dt==r;this.compareData=(t,e)=>{const s=this.reference.chromosomesOrder.indexOf(t.chr)-this.reference.chromosomesOrder.indexOf(e.chr);if(s!=0){return s}const n=t.pos?t.pos:t.start;const i=e.pos?e.pos:e.start;return n-i};this.settings=t;this.reference=e;this.sample=s;this.lastInnerRadious=this.settings.rings.chromosomeInnerRadius;this.gainCapped=this.settings.Disco.cnvCapping;this.lossCapped=-1*this.settings.Disco.cnvCapping;this.nonExonicFilter=e=>{if(l.length>0&&this.settings.Disco.prioritizeGeneLabelsByGeneSets){return l.includes(e.gene)&&t.rings.nonExonicFilterValues.includes(yt.snvClassLayer[e.mClass])}else{return t.rings.nonExonicFilterValues.includes(yt.snvClassLayer[e.mClass])}};this.snvRingFilter=e=>{if(l.length>0&&this.settings.Disco.prioritizeGeneLabelsByGeneSets){return l.includes(e.gene)&&t.rings.snvRingFilters.includes(yt.snvClassLayer[e.mClass])}else{return t.rings.snvRingFilters.includes(yt.snvClassLayer[e.mClass])}};this.dataObjectMapper=new J(s,l)}map(t){const e=[];t.forEach((t=>{const s=this.reference.chromosomesOrder.indexOf(t.chr);const l=this.reference.chromosomesOrder.indexOf(t.chrA);const c=this.reference.chromosomesOrder.indexOf(t.chrB);if(t.dt==n){if(s!=-1&&this.snvData.length<this.settings.snv.maxMutationCount){this.addData(t,e)}}else if(t.dt==i||t.dt==o){if(l!=-1&&c!=-1){this.addData(t,e)}}else if([a,r].includes(Number(t.dt))){this.addData(t,e)}else{throw Error("Unknown mutation type!")}}));const s=e.sort(this.compareData);if(this.settings.rings.nonExonicRingEnabled){s.forEach((t=>{this.filterNonExonicSnvData(t)}))}if(this.nonExonicSnvData.length>0){this.nonExonicInnerRadius=this.lastInnerRadious-this.settings.rings.nonExonicRingWidth;this.lastInnerRadious=this.nonExonicInnerRadius}s.forEach((t=>{this.filterSnvs(t)}));s.forEach((t=>{this.filterLohs(t)}));if(this.lohData.length>0){this.lohInnerRadius=this.lastInnerRadious-this.settings.rings.lohRingWidth;this.lastInnerRadious=this.lohInnerRadius}s.forEach((t=>{this.filterCnvs(t)}));if(this.cnvData.length>0){this.cnvInnerRadius=this.lastInnerRadious-this.settings.rings.cnvRingWidth;this.lastInnerRadious=this.cnvInnerRadius;this.cappedCnvMaxAbsValue=Math.min(this.settings.Disco.cnvCapping,Math.max(Math.abs(Y.capMaxValue(this.cnvLossMaxValue,this.gainCapped,this.lossCapped)),Math.abs(Y.capMaxValue(this.cnvGainMaxValue,this.gainCapped,this.lossCapped))));const t=(new Q).map(this.cnvData.map((t=>t.value)),this.settings.Disco.cnvPercentile);this.percentilePositive=Y.capMaxValue(t.positive,this.gainCapped,this.lossCapped);this.percentileNegative=Y.capMaxValue(t.negative,this.gainCapped,this.lossCapped);this.cnvMaxPercentileAbs=Math.min(this.settings.Disco.cnvCapping,Math.max(this.percentilePositive,Math.abs(this.percentileNegative)))}s.forEach((t=>{this.filterFusion(t)}));if(this.fusionData.length>0){this.fusionRadius=this.lastInnerRadious}const l={labelData:this.labelData,nonExonicSnvData:this.nonExonicSnvData,nonExonicInnerRadius:this.nonExonicInnerRadius,snvRingDataMap:this.snvRingDataMap,snvInnerRadius:this.snvInnerRadius,snvData:this.snvData,bpx:this.bpx,onePxArcAngle:this.onePxArcAngle,filteredSnvData:this.filteredSnvData,lohData:this.lohData,lohInnerRadius:this.lohInnerRadius,cnvData:this.cnvData,cnvInnerRadius:this.cnvInnerRadius,fusionData:this.fusionData,fusionRadius:this.fusionRadius,hasPrioritizedGenes:this.hasPrioritizedGenes,cnvGainMaxValue:this.cnvGainMaxValue,cnvLossMaxValue:this.cnvLossMaxValue,cappedCnvMaxAbsValue:this.cappedCnvMaxAbsValue,percentilePositive:this.percentilePositive,percentileNegative:this.percentileNegative,cnvMaxPercentileAbs:this.cnvMaxPercentileAbs,lohMaxValue:this.lohMaxValue,lohMinValue:this.lohMinValue};return l}addData(t,e){const s=this.dataObjectMapper.map(t);if(s.isPrioritized){this.hasPrioritizedGenes=true}e.push(s)}filterNonExonicSnvData(t){if(this.snvFilter(t)){if(this.settings.rings.nonExonicRingEnabled&&this.nonExonicFilter(t)){this.nonExonicSnvData.push(t)}}}filterSnvs(t){if(this.snvFilter(t)){this.snvData.push(t);if(this.snvRingFilter(t)){if(this.snvInnerRadius==0){this.snvInnerRadius=this.lastInnerRadious-this.settings.rings.snvRingWidth;this.lastInnerRadious=this.snvInnerRadius;this.bpx=Math.floor(this.reference.totalSize/(this.reference.totalChromosomesAngle*this.snvInnerRadius));this.onePxArcAngle=1/this.snvInnerRadius}this.filteredSnvData.push(t);this.labelData.push(t);const e=this.calculateArcAngle(t);let s=this.snvRingDataMap.get(e);if(!s){s=new Array}s.push(t);this.snvRingDataMap.set(e,s)}}}filterFusion(t){if(this.fusionFilter(t)){t.isPrioritized=true;this.fusionData.push(t);this.labelData.push(t)}}filterLohs(t){if(this.lohFilter(t)){if(this.lohMaxValue==undefined||this.lohMaxValue<t.value){this.lohMaxValue=t.segmean}if(this.lohMinValue==undefined||this.lohMinValue>t.value){this.lohMinValue=t.segmean}this.lohData.push(t)}}filterCnvs(t){if(this.cnvFilter(t)){if(this.cnvGainMaxValue==undefined||this.cnvGainMaxValue<t.value){this.cnvGainMaxValue=t.value}if(this.cnvLossMaxValue==undefined||this.cnvLossMaxValue>t.value){this.cnvLossMaxValue=t.value}this.cnvData.push(t)}}calculateArcAngle(t){const e=this.reference.chromosomes[this.reference.chromosomesOrder.findIndex((e=>t.chr==e))];const s=Math.floor(t.position/this.bpx);return e.startAngle+s*this.onePxArcAngle}static capMaxValue(t,e,s){if(t&&Math.sign(t)==1){return t>e?e:t}if(Math.sign(t)==-1){return t<s?s:t}return 0}static capMinValue(t,e=1){if(Math.sign(t)==1){return t>e?t:e}if(Math.sign(t)==-1){return t<-1*e?t:-1*e}return 1}}class Z{constructor(t,e,s,n,i,o,a,r,l){this.snvTitle=t;this.cnvTitle=e;this.lohTitle=s;this.fusionTitle=n;this.snvClassMap=i;this.cnvClassMap=o;this.cnvRenderingType=a;this.lohLegend=l;this.fusionLegend=r}legendCount(){return(this.snvClassMap.size>0?1:0)+(this.cnvClassMap.size>0?1:0)+(this.lohLegend?1:0)+(this.fusionLegend?1:0)}}class tt{constructor(t,e,s,n,i){this.source=t;this.target=e;this.genes=s;this.count=n;this.endpts=i}}class et{constructor(t,e,s,n,i,o,a,r){this.startAngle=t;this.endAngle=e;this.radius=s;this.gene=n;this.value=i;this.genes=o;this.positionInChromosome=a;this.strand=r}}class st{constructor(t,e,s){this.radius=t;this.sampleName=e;this.reference=s}map(t){const e=[];t.forEach((t=>{const s=new Set;s.add(t.geneA);s.add(t.geneB);const n=new et(this.calculateStartAngle(t.chrA,t.posA),this.calculateEndAngle(t.chrA,t.posA),this.radius,t.geneA,t.value,s,{chromosome:t.chrA,position:t.posA},t.strandA);const i=new et(this.calculateStartAngle(t.chrB,t.posB),this.calculateEndAngle(t.chrB,t.posB),this.radius,t.geneB,t.value,s,{chromosome:t.chrB,position:t.posB},t.strandB);const o=new tt(n,i,"genes",-1,"Endpoints");e.push(o)}));return e}calculateStartAngle(t,e){const s=this.reference.chromosomesOrder.indexOf(t);const n=this.reference.chromosomes[s];return n.startAngle+(n.endAngle-n.startAngle)*(Number(e)/n.size)-.01}calculateEndAngle(t,e){const s=this.reference.chromosomesOrder.indexOf(t);const n=this.reference.chromosomes[s];return.01+n.startAngle+(n.endAngle-n.startAngle)*(Number(e)/n.size)}}class nt{static provide(t){const e=Math.min(Math.max(t,0),1);const s=Math.round(e*255);return`rgb(${s}, ${s}, ${s})`}}class it{constructor(t,e){this.minValue=t;this.maxValue=e;this.colorStartValue=nt.provide(t);this.colorEndValue=nt.provide(e)}}var ot;(function(t){t[t["CHROMOSOME"]=0]="CHROMOSOME";t[t["LABEL"]=1]="LABEL";t[t["NONEXONICSNV"]=2]="NONEXONICSNV";t[t["SNV"]=3]="SNV";t[t["CNV"]=4]="CNV";t[t["LOH"]=5]="LOH";t[t["FUSION"]=6]="FUSION"})(ot||(ot={}));class at{constructor(t,e,s,n,i,o,a){this.settings=t;this.rings=e;this.legend=s;this.fusions=n;this.genesetName=o;this.width=1.2*(this.settings.horizontalPadding+this.settings.rings.labelLinesInnerRadius+this.settings.rings.labelsToLinesDistance);this.height=2*(this.settings.rings.labelLinesInnerRadius+this.settings.rings.labelsToLinesDistance+this.settings.verticalPadding);this.legendHeight=this.calculateLegendHeight(s);this.snvDataLength=i.snvData.length;this.filteredSnvDataLength=i.filteredSnvData.length;this.snvDataLengthAll=a;this.cnvMaxValue=i.cnvGainMaxValue;this.cnvMinValue=i.cnvLossMaxValue;this.cappedCnvMaxAbsValue=i.cappedCnvMaxAbsValue;this.negativePercentile80=i.percentileNegative;this.positivePercentile80=i.percentilePositive}getElements(t){switch(t){case ot.CHROMOSOME:return this.rings.chromosomesRing?this.rings.chromosomesRing.elements:[];case ot.LABEL:return this.rings.labelsRing.elementsToDisplay;case ot.NONEXONICSNV:return this.rings.nonExonicArcRing?this.rings.nonExonicArcRing.elements:[];case ot.SNV:return this.rings.snvArcRing?this.rings.snvArcRing.elements:[];case ot.CNV:return this.rings.cnvArcRing?this.rings.cnvArcRing.elements:[];case ot.LOH:return this.rings.lohArcRing?this.rings.lohArcRing.elements:[];default:throw new Error(`ringType ${t} not defined`)}}getCollisions(t){if(t==ot.LABEL){return this.rings.labelsRing.collisions}else{return undefined}}calculateLegendHeight(t){const e=this.settings.legend.rowHeight;return e*t.legendCount()}}class rt{constructor(t,e,s){this.innerRadius=t;this.outerRadius=t+e;this.width=e;this.elements=s}}class lt{constructor(){const t={};for(const e in l){t[l[e].label]=l[e];t[e]=l[e]}this.mlabel=t}static getInstance(){if(!lt.instance){lt.instance=new lt}return lt.instance}}class ct{constructor(t,e,s){this.snvType=t;this.color=e;this.count=s}}class ht{constructor(t,e,s,n){this.snvClassMap=new Map;this.svnInnerRadius=t;this.svnWidth=e;this.sampleName=s;this.reference=n;this.bpx=Math.floor(this.reference.totalSize/(this.reference.totalChromosomesAngle*t));this.onePxArcAngle=1/t}map(t){const e=[];for(const s of t.keys()){const n=t.get(s);if(n){const t=n.length;for(let i=0;i<n.length;i++){const o=n[i];const a=this.snvClassMap.get(o.mClass);if(a){this.snvClassMap.set(o.mClass,this.createSnvLegend(o.mClass,++a.count))}else{this.snvClassMap.set(o.mClass,this.createSnvLegend(o.mClass,1))}const r=s;const l=s+this.onePxArcAngle;const c=lt.getInstance().mlabel?lt.getInstance().mlabel[o.mClass]:undefined;const h={startAngle:r,endAngle:l,innerRadius:this.svnInnerRadius+i*this.svnWidth/t,outerRadius:this.svnInnerRadius+(i+1)*this.svnWidth/t,color:c.color,text:o.gene,dataClass:c.label,mname:o.mname,chr:o.chr,pos:o.position,sampleName:[o.sampleName]};e.push(h)}}}return e}createSnvLegend(t,e){const s=lt.getInstance().mlabel[t];return new ct(s.label,s.color,e)}}class dt{constructor(t,e,s,n){this.text=t;this.cnvType=e;this.color=s;this.value=n}}var pt;(function(t){t[t["Loss"]=0]="Loss";t[t["Gain"]=1]="Gain";t[t["Cap"]=2]="Cap"})(pt||(pt={}));var ut;(function(t){t["heatmap"]="heatmap";t["bar"]="bar"})(ut||(ut={}));class gt{static getColor(t,e,s=0){const n=e.cnv;const i=e.Disco.cnvRenderingType==ut.heatmap?e.Disco.cnvCapping:s;const o=e.Disco.cnvRenderingType==ut.heatmap?-1*e.Disco.cnvCapping:-1*s;if(t<o){return n.cappedLossColor}else if(t>=o&&t<=0){return n.lossColor}else if(t>0&&t<=i){return n.ampColor}else{return n.cappedAmpColor}}}class mt{constructor(t,e,s,n,i,o=0,a=0,r=0,l=0,c="",h){this.cnvClassMap=new Map;this.cnvInnerRadius=t;this.cnvWidth=e;this.settings=s;this.sampleName=n;this.reference=i;this.cnvMaxValue=o;this.cnvMinValue=a;this.cnvMaxAbsValue=r;this.cnvAbsPercentile=l;this.cnvUnit=c;this.cnvRenderingType=h;this.gainCapped=Math.min(l,this.settings.Disco.cnvCapping);this.lossCapped=-1*Math.min(l,this.settings.Disco.cnvCapping);this.lossOnly=o<=0;this.gainOnly=a>=0;this.onePxArcAngle=1/this.cnvInnerRadius;const d=new dt("Max",o>0?pt.Gain:pt.Loss,this.getColor(o),o);const p=new dt("Min",a>0?pt.Gain:pt.Loss,this.getColor(a),a);const u=new dt("Capping",pt.Loss,this.getColor(a>0?a:o),this.settings.Disco.cnvCapping);this.cnvClassMap.set(pt.Gain,d);this.cnvClassMap.set(pt.Loss,p);this.cnvClassMap.set(pt.Cap,u)}map(t){const e=[];t.forEach((t=>{let s=this.calculateStartAngle(t);let n=this.calculateEndAngle(t);if(n-s<this.onePxArcAngle){const t=this.onePxArcAngle-(n-s);s=s-t/2;n=s+t/2}const i=this.calculateInnerRadius(t);const o=this.calculateOuterRadius(t);const a=this.getColor(t.value);const r={startAngle:s,endAngle:n,innerRadius:i,outerRadius:o,color:a,text:t.gene,chr:t.chr,start:t.start,stop:t.stop,value:t.value,unit:this.cnvUnit,sampleName:[this.sampleName]};e.push(r)}));return e}calculateStartAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return s.startAngle+(s.endAngle-s.startAngle)*(Number(t.start)/s.size)}calculateEndAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return s.startAngle+(s.endAngle-s.startAngle)*(Number(t.stop)/s.size)}getColor(t){return gt.getColor(t,this.settings,this.cnvAbsPercentile)}calculateInnerRadius(t){if(this.cnvRenderingType==ut.heatmap){return this.cnvInnerRadius}if(this.gainOnly){return this.cnvInnerRadius}if(this.lossOnly){const e=this.cnvInnerRadius+this.cnvWidth;return e+Y.capMinValue(this.cnvWidth*Y.capMaxValue(t.value,this.gainCapped,this.lossCapped)/this.cnvAbsPercentile)}const e=this.cnvInnerRadius+this.cnvWidth/2;if(Math.sign(t.value)==1){return e}if(Math.sign(t.value)==-1){return e+Y.capMinValue(Y.capMaxValue(t.value,this.gainCapped,this.lossCapped)/this.cnvAbsPercentile*(this.cnvWidth/2))}return 1}calculateOuterRadius(t){const e=this.cnvInnerRadius+this.cnvWidth;if(this.cnvRenderingType==ut.heatmap){return e}if(this.gainOnly){return this.cnvInnerRadius+Y.capMinValue(this.cnvWidth*Y.capMaxValue(t.value,this.gainCapped,this.lossCapped)/this.cnvAbsPercentile)}if(this.lossOnly){return e}const s=this.cnvInnerRadius+this.cnvWidth/2;if(Math.sign(t.value)==1){return s+Y.capMinValue(Y.capMaxValue(t.value,this.gainCapped,this.lossCapped)/this.cnvMaxAbsValue*(this.cnvWidth/2))}if(Math.sign(t.value)==-1){return s}return 1}}class ft{constructor(t,e){this.points=new Array;this.points=t;this.color=e}}class vt{static createLabel(t,e,s,n,i,o,a,r,l,c,h=false,d,p,u){const g=(t+e)/2;const m=g-Math.PI/2;const f=`rotate(${g*180/Math.PI-90}) translate(${n})${g>Math.PI?"rotate(180)":""}`;const v=g>Math.PI?"end":"";const A=s;const x=n-d;const M=[];const R={x:A*Math.cos(m),y:A*Math.sin(m)};const b={x:x*Math.cos(m),y:x*Math.sin(m)};M.push(R);M.push(b);const C=new ft(M,a);const y={startAngle:t,endAngle:e,innerRadius:s,outerRadius:n,angle:g,value:i,text:o,color:a,transform:f,textAnchor:v,ccAngle:m,line:C,isPrioritized:h,start:c,stop:c,chr:l,mutationsTooltip:p?[p]:undefined,fusionTooltip:u?[u]:undefined};return y}static createMovedLabel(t,e){const s=t.startAngle+e;const n=t.endAngle+e;const i=(s+n)/2;const o=i-Math.PI/2;const a=t.innerRadius;const r=t.outerRadius-2;const l=(r-a)/3;const c=Math.cos(t.ccAngle);const h=Math.sin(t.ccAngle);const d=Math.cos(t.ccAngle+e);const p=Math.sin(t.ccAngle+e);const u=[];const g={x:a*c,y:a*h};const m={x:(a+l)*c,y:(a+l)*h};const f={x:(a+2*l)*d,y:(a+2*l)*p};const v={x:(a+3*l)*d,y:(a+3*l)*p};u.push(g);u.push(m);u.push(f);u.push(v);const A=new ft(u,t.color);const x="rotate("+(i*180/Math.PI-90)+")"+"translate("+t.outerRadius+")"+(i>Math.PI?"rotate(180)":"");const M=i>Math.PI?"end":"";const R=t.mutationsTooltip?t.mutationsTooltip[0].color:t.fusionTooltip?t.fusionTooltip[0].color:undefined;const b={startAngle:s,endAngle:n,innerRadius:t.innerRadius,outerRadius:t.outerRadius,angle:i,value:t.value,text:t.text,transform:x,textAnchor:M,ccAngle:o,color:R,line:A,isPrioritized:t.isPrioritized,start:t.start,stop:t.stop,chr:t.chr,mutationsTooltip:t.mutationsTooltip,fusionTooltip:t.fusionTooltip};return b}}class At{constructor(t,e,s,n=0){this.labelMap=new Map;this.settings=t;this.sampleName=e;this.reference=s;this.cnvMaxPercentileAbs=n}map(t,e=[]){const s=this.settings.rings.labelLinesInnerRadius;const o=s+this.settings.rings.labelsToLinesDistance;t.forEach((t=>{if(t.dt==n){const e=this.calculateStartAngle(t.chr,t.position);const n=this.calculateEndAngle(t.chr,t.position);const i=lt.getInstance().mlabel?lt.getInstance().mlabel[t.mClass]:undefined;this.addLabelOrMutation(t,t.gene,t.mname,e,n,s,o,i.color,i.label)}if(t.dt==i){const e=H.getColor(t.chrA,t.chrB);if(t.geneA){const n=this.calculateStartAngle(t.chrA,t.posA);const i=this.calculateEndAngle(t.chrA,t.posA);this.addLabelOrFusion(t,t.geneA,t.posA,n,i,s,o,e)}if(t.geneB&&t.geneA!=t.geneB){const n=this.calculateStartAngle(t.chrB,t.posB);const i=this.calculateEndAngle(t.chrB,t.posB);this.addLabelOrFusion(t,t.geneB,t.posB,n,i,s,o,e)}}}));const a=Array.from(this.labelMap.values());a.forEach((t=>{e.forEach((e=>{if(t.stop>=e.start&&e.stop>=t.start&&t.chr==e.chr){const s={value:e.value,color:gt.getColor(e.value,this.settings,this.cnvMaxPercentileAbs),chr:e.chr,start:e.start,stop:e.stop};if(t.cnvTooltip){t.cnvTooltip.push(s)}else{t.cnvTooltip=[];t.cnvTooltip.push(s)}}}))}));return Array.from(this.labelMap.values())}addLabelOrMutation(t,e,s,n,i,o,a,r,l){const c=this.labelMap.get(e);const h={mname:s,color:r,dataClass:l,chr:t.chr,position:t.position};if(!c){this.labelMap.set(e,vt.createLabel(n,i,o,a,t.value,e,r,l,t.chr,t.position,t.isPrioritized,this.settings.rings.labelsToLinesGap,h))}else{if(c.mutationsTooltip){c.start=Math.min(c.start,t.position);c.stop=Math.max(c.stop,t.position);c.mutationsTooltip.push(h)}else{c.mutationsTooltip=[];c.start=Math.min(c.start,t.position);c.stop=Math.max(c.stop,t.position);c.mutationsTooltip.push(h)}}}addLabelOrFusion(t,e,s,n,i,o,a,r){const l=this.labelMap.get(e);const c={color:r,chrA:t.chrA,chrB:t.chrB,posA:t.posA,posB:t.posB,geneA:t.geneA,geneB:t.geneB,strandA:t.strandA,strandB:t.strandB};if(!l){this.labelMap.set(e,vt.createLabel(n,i,o,a,t.value,e,r,"Fusion transcript",t.chr,t.position,t.isPrioritized,this.settings.rings.labelsToLinesGap,undefined,c))}else{if(l.fusionTooltip){l.start=Math.min(l.start,s);l.stop=Math.max(l.stop,s);l.fusionTooltip.push(c)}else{l.fusionTooltip=[];l.start=Math.min(l.start,s);l.stop=Math.max(l.stop,s);l.fusionTooltip.push(c)}}}calculateStartAngle(t,e){const s=this.reference.chromosomesOrder.findIndex((e=>e==t));const n=this.reference.chromosomes[s];return n.startAngle+(n.endAngle-n.startAngle)*(Number(e)/n.size)}calculateEndAngle(t,e){const s=this.reference.chromosomesOrder.findIndex((e=>e==t));const n=this.reference.chromosomes[s];return n.startAngle+(n.endAngle-n.startAngle)*(Number(e)/n.size)}}class xt extends rt{constructor(t,e,s){super(t.rings.labelLinesInnerRadius,t.rings.labelsToLinesDistance,e.sort(((t,e)=>t.startAngle<e.startAngle?-1:t.startAngle>e.startAngle?1:0)));this.elementsToDisplay=[];this.settings=t;this.hasPrioritizedGenes=s;const n=2*Math.PI*(t.rings.labelLinesInnerRadius+t.rings.labelsToLinesDistance);this.overlapAngle=this.settings.label.overlapAngleFactor*this.settings.label.fontSize/n;this.calculateCollisions()}calculateCollisions(){this.collisions=[];let t=[];t=this.elements.filter((t=>t.isPrioritized));if(this.settings.label.prioritizeGeneLabelsByGeneSets){this.elementsToDisplay=this.getLabelsWithPrioritizedGenes(t)}else if(this.hasPrioritizedGenes){const t=this.elements.filter((t=>t.isPrioritized));const e=this.getLabelsWithPrioritizedGenes(t);const s=this.elements.filter((t=>!t.isPrioritized));const n=[...s,...e].sort(((t,e)=>t.startAngle-e.startAngle));this.elementsToDisplay=this.getAllLabels(n)}else{this.elementsToDisplay=this.getLabelsWithPrioritizedGenes(this.elements)}}getLabelsWithPrioritizedGenes(t){const e=[];let s={endAngle:0};t.forEach(((t,n)=>{if(n==0){e.push(t);s=t}else{const n=s.endAngle-t.startAngle+this.overlapAngle;if(n>0&&n<this.settings.label.maxDeltaAngle){const i=vt.createMovedLabel(t,n);e===null||e===void 0?void 0:e.push(i);s=i}if(n<=0){e.push(t);s=t}}}));return e}getAllLabels(t){var e;const s=[];let n={endAngle:0};const i=t.length;let o=-1;for(let a=0;a<t.length;a++){const r=t[a];if(r.isPrioritized){s.push(r);o=a;n=r;continue}if(a==0){if(i>1){if(this.isElementOverlappingNextCancerGene(t,o,r,0)){continue}s.push(r);n=r}continue}const l=n.endAngle-r.startAngle+this.overlapAngle;if(l>0&&l<this.settings.label.maxDeltaAngle){if(a==length-1){s.push(r);continue}if(this.isElementOverlappingNextCancerGene(t,o,r,l)){continue}const i=vt.createMovedLabel(r,l);(e=this.collisions)===null||e===void 0?void 0:e.push(i);s.push(r);n=i}if(l<=0){if(this.isElementOverlappingNextCancerGene(t,o,r,0)){continue}s.push(r);n=r}}return s}isElementOverlappingNextCancerGene(t,e,s,n){const i=this.getNextLabelWithCancerGene(t,e);if(i){const t=s.endAngle+n-i.startAngle+this.overlapAngle;if(t>0){return true}}return false}getNextLabelWithCancerGene(t,e){return t.find(((t,s)=>t.isPrioritized&&s>e))}}class Mt{constructor(t,e,s,n){this.nonExonicInnerRadius=t;this.nonExonicWidht=e;this.sampleName=s;this.reference=n;this.onePxArcAngle=1/t}map(t){const e=this.nonExonicInnerRadius;const s=e+this.nonExonicWidht;const n=[];t.forEach((t=>{const i=lt.getInstance().mlabel?lt.getInstance().mlabel[t.mClass]:undefined;const o=this.calculateStartAngle(t);const a=this.calculateEndAngle(t);const r={startAngle:o,endAngle:a,innerRadius:e,outerRadius:s,color:i.color,text:t.gene,dataClass:i.label,mname:t.mname,chr:t.chr,pos:t.position,sampleName:[t.sampleName]};n.push(r)}));return n}calculateStartAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return s.startAngle+(s.endAngle-s.startAngle)*(Number(t.position)/s.size)-this.onePxArcAngle}calculateEndAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return this.onePxArcAngle+s.startAngle+(s.endAngle-s.startAngle)*(Number(t.position)/s.size)}}class Rt{constructor(t,e,s,n){this.lohInnerRadius=t;this.lohWidth=e;this.sampleName=s;this.reference=n}map(t){const e=[];t.forEach((t=>{const s=this.calculateStartAngle(t);const n=this.calculateEndAngle(t);const i=this.lohInnerRadius;const o=i+this.lohWidth;const a=nt.provide(t.segmean);const r={startAngle:s,endAngle:n,innerRadius:i,outerRadius:o,color:a,text:t.gene,chr:t.chr,start:t.start,stop:t.stop,value:t.segmean};e.push(r)}));return e}calculateStartAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return s.startAngle+(s.endAngle-s.startAngle)*(Number(t.start)/s.size)}calculateEndAngle(t){const e=this.reference.chromosomesOrder.indexOf(t.chr);const s=this.reference.chromosomes[e];return s.startAngle+(s.endAngle-s.startAngle)*(Number(t.stop)/s.size)}}class bt{constructor(t,e,s,n,i,o){this.labelsRing=t;this.chromosomesRing=e;this.nonExonicArcRing=s;this.snvArcRing=n;this.cnvArcRing=i;this.lohArcRing=o}}class Ct{constructor(t,e,s,n,i){this.nonExonicArcRing=undefined;this.settings=t;this.dataMapper=e;this.reference=s;this.sampleName=n;this.genesetName=i}map(t){const e=this.dataMapper.map(t);const s=new At(this.settings,this.sampleName,this.reference,e.cnvMaxPercentileAbs);const i=s.map(e.labelData,e.cnvData);const o=new xt(this.settings,i,e.hasPrioritizedGenes);const a=new rt(this.settings.rings.chromosomeInnerRadius,this.settings.rings.chromosomeWidth,this.reference.chromosomes);const r=new Mt(e.nonExonicInnerRadius,this.settings.rings.nonExonicRingWidth,this.sampleName,this.reference);const l=r.map(e.nonExonicSnvData);if(l.length>0){this.nonExonicArcRing=new rt(e.nonExonicInnerRadius,this.settings.rings.nonExonicRingWidth,l)}this.snvArcsMapper=new ht(e.snvInnerRadius,this.settings.rings.snvRingWidth,this.sampleName,this.reference);const c=this.snvArcsMapper.map(e.snvRingDataMap);if(c.length>0){this.snvArcRing=new rt(e.snvInnerRadius,this.settings.rings.snvRingWidth,c)}const h=new Rt(e.lohInnerRadius,this.settings.rings.lohRingWidth,this.sampleName,this.reference);const d=h.map(e.lohData);if(d.length>0){this.lohArcRing=new rt(e.lohInnerRadius,this.settings.rings.lohRingWidth,d)}this.cnvArcsMapper=new mt(e.cnvInnerRadius,this.settings.rings.cnvRingWidth,this.settings,this.sampleName,this.reference,e.percentilePositive,e.percentileNegative,e.cappedCnvMaxAbsValue,e.cnvMaxPercentileAbs,this.settings.cnv.unit,this.settings.Disco.cnvRenderingType);const p=this.cnvArcsMapper.map(e.cnvData);if(p.length>0){this.cnvArcRing=new rt(e.cnvInnerRadius,this.settings.rings.cnvRingWidth,p)}const u=new st(e.fusionRadius,this.sampleName,this.reference);const g=u.map(e.fusionData);let m;if(this.settings.legend.lohLegendEnabled&&e.lohMinValue&&e.lohMaxValue){m=new it(e.lohMinValue,e.lohMaxValue)}const f=new Z(this.settings.legend.snvTitle,this.settings.legend.cnvTitle,this.settings.legend.lohTitle,this.settings.legend.fusionTitle,this.snvArcsMapper?this.snvArcsMapper.snvClassMap:new Map,this.cnvArcsMapper?this.cnvArcsMapper.cnvClassMap:new Map,this.settings.Disco.cnvRenderingType,g.length>0,m);const v=new bt(o,a,this.nonExonicArcRing,this.snvArcRing,this.cnvArcRing,this.lohArcRing);return new at(this.settings,v,f,g,e,this.genesetName,t.filter((t=>t.dt==n)).length)}}class yt{constructor(t){this.settings=t}map(t){var e,s;const n=t.args.chromosomes;const i=t.args.genome.majorchr;const o=t.args.sampleName;const a=t.args.genome;const r=((e=a===null||a===void 0?void 0:a.geneset)===null||e===void 0?void 0:e[0])?a.geneset[0].lst:[];const l=((s=a===null||a===void 0?void 0:a.geneset)===null||s===void 0?void 0:s[0])?a.geneset[0].name:"";const c=t.args.data;const h=new K(this.settings,i,n);const d=new Y(this.settings,h,o,r);return new Ct(this.settings,d,h,o,l).map(c)}}yt.snvClassLayer={M:"exonic",E:"exonic",F:"exonic",N:"exonic",S:"exonic",D:"exonic",I:"exonic",P:"exonic",L:"exonic",Utr3:"exonic",Utr5:"exonic",ProteinAltering:"exonic",mnv:"non-exonic",ITD:"non-exonic",insertion:"non-exonic",deletion:"non-exonic",Intron:"non-exonic",X:"non-exonic",noncoding:"non-exonic"};class wt{constructor(t){this.cappedCnvMaxAbsValue=t}map(t){const e=[];let s=0;if(t.snvClassMap){this.mapSnv(t,e,s++)}if(t.cnvRenderingType==ut.heatmap){this.mapCnvHeatmap(t,e,s++)}else if(t.cnvRenderingType==ut.bar){if(t.cnvClassMap){this.mapCnvBar(t,e,s++)}}if(t.lohLegend){this.mapLoh(t,e,s++)}if(t.fusionLegend){this.mapFusion(t,e,s++)}return e}mapSnv(t,e,s){const n=[];let i=0;for(const[e,s]of t.snvClassMap){n.push({termid:t.snvTitle,key:e,text:`${s.snvType} (${s.count})`,color:s.color,order:i++,border:"1px solid #ccc"})}e.push({name:t.snvTitle,order:s,items:n})}mapCnvBar(t,e,s){if(!t.cnvClassMap)return;const n=t.cnvClassMap.get(pt.Gain);const i=t.cnvClassMap.get(pt.Loss);const o=t.cnvClassMap.get(pt.Cap);if(n&&i&&o){let a=0;const r=[];if(n.value>0){r.push({termid:t.cnvTitle,key:pt.Gain,text:`Max: ${n.value}`,color:n.color,order:a++,border:"1px solid #ccc"})}if(i.value<0){r.push({termid:t.cnvTitle,key:pt.Loss,text:`Min: ${i.value}`,color:i.color,order:a++,border:"1px solid #ccc"})}r.push({termid:t.cnvTitle,key:pt.Cap,text:`Capping: ${o.value}`,color:o.color,order:a++,border:"1px solid #ccc"});e.push({name:t.cnvTitle,order:s,items:r})}}mapCnvHeatmap(t,e,s){if(!t.cnvClassMap)return;const n=t.cnvClassMap.get(pt.Gain);const i=t.cnvClassMap.get(pt.Loss);const o=t.cnvClassMap.get(pt.Cap);if(n&&i&&o){let a=0;const r=[];if(n.value>0){r.push({termid:t.cnvTitle,key:pt.Gain,text:"Copy number gain",width:100,domain:[0,1],minLabel:0,maxLabel:n.value,order:a++,isLegendItem:true,dt:4,scale:c([0,1],["white",n.color])})}if(i.value<0){r.push({termid:t.cnvTitle,key:pt.Loss,text:"Copy number loss",width:100,domain:[0,1],minLabel:0,maxLabel:i.value,order:a++,isLegendItem:true,dt:4,scale:c([0,1],["white",i.color])})}r.push({termid:t.cnvTitle,key:pt.Cap,text:`Capping: ${o.value}`,color:o.color,order:a++,border:"1px solid #ccc"});e.push({name:t.cnvTitle,order:s,items:r})}}mapLoh(t,e,s){if(!t.lohLegend)return;const n=[];n.push({termid:t.lohTitle,key:"min",text:"min",color:t.lohLegend.colorStartValue,order:0,border:"1px solid #ccc"});n.push({termid:t.lohTitle,key:"max",text:"max",color:t.lohLegend.colorEndValue,order:1,border:"1px solid #ccc"});e.push({name:t.lohTitle,order:s,items:n})}mapFusion(t,e,s){const n=[];n.push({termid:t.fusionTitle,key:_.Interchromosomal,text:"Interchromosomal",color:_.Interchromosomal.valueOf(),order:0,border:"1px solid #ccc"});n.push({termid:t.fusionTitle,key:_.Intrachromosomal,text:"Intrachromosomal",color:_.Intrachromosomal.valueOf(),order:1,border:"1px solid #ccc"});e.push({name:t.fusionTitle,order:s,items:n})}}class It{constructor(t=0,e){this.fontSize=e;this.legendJSONMapper=new wt(t)}render(t,e,s,n,i){const o=v({holder:t.append("g").attr("data-testid","sjpp_disco_plot_legend"),rectFillFxn:t=>t.color,iconStroke:"#aaa"});const a={xOffset:s};const r=this.legendJSONMapper.map(e);o(r,{settings:Object.assign({},{svgw:n,svgh:i,dimensions:a,fontsize:this.fontSize})})}}class Lt{constructor(t,e,s){this.padAngle=t;this.innerRadius=e;this.outerRadius=s}render(t,e){const s=W().padAngle(this.padAngle).value((t=>t.size)).sort(null);const n=s(e);const i=g().innerRadius(this.innerRadius).outerRadius(this.outerRadius);const o=t.append("g").attr("data-testid","sjpp_chromosomes_arc_group");o.selectAll("path").data(n).enter().append("path").attr("d",i).attr("fill","black");o.selectAll("text").data(n).enter().append("text").attr("transform",(t=>`translate(${i.centroid(t)}) rotate(${t.data.angle*180/Math.PI-90})${t.data.angle>Math.PI?"rotate(180)":""}`)).attr("dy","0.35em").attr("text-anchor","middle").text((t=>t.data.text)).style("fill","white")}}class Dt{constructor(t,e){this.animationDuration=t;this.geneClickListener=e}render(t,e,n){const i=t.append("g");const o=x().x((t=>t.x)).y((t=>t.y));const a=j.create();i.selectAll(".group").data(e).enter().append("g").attr("class","group").each(((t,e,n)=>{const i=h(n[e]);i.append("text").attr("class","chord-text").attr("dy",".35em").attr("transform",t.transform).style("text-anchor",t.textAnchor).style("font-size","12px").style("fill",t.color).style("cursor","pointer").text(t.text).on("click",(()=>{if(t.mutationsTooltip){this.geneClickListener(t.text,t.mutationsTooltip.map((t=>t.mname)))}})).on("mouseover",(e=>{const n=s({holder:a.d});this.createTooltip(n,t);a.show(e.x,e.y)})).on("mouseout",(()=>{a.clear();a.hide()}));i.append("path").attr("class","chord-tick").datum(t.line.points).style("stroke",t.color).style("fill","none").attr("d",o)}));i.selectAll(".group").each(((t,e,s)=>{const i=n?n.find((e=>e.text===t.text)):undefined;if(i){const t=h(s[e]);t.selectAll(".chord-text").datum(i).transition().duration(this.animationDuration).attr("transform",i.transform).style("text-anchor",i.textAnchor);t.selectAll(".chord-tick").datum(i.line.points).transition().duration(this.animationDuration).style("fill","none").attr("d",o)}}))}createTooltip(t,e){if(e.mutationsTooltip){const[s,n]=t.addRow();s.text("Gene");n.append("span").style("margin-left","5px").text(e.text);e.mutationsTooltip.forEach((e=>{{const[s,n]=t.addRow();s.text("Consequence");n.append("span").text(e.mname);n.append("span").style("margin-left","5px").style("color",e.color).text(e.dataClass)}{const[s,n]=t.addRow();s.text("Mutation");n.append("span").text(`${e.chr}:${e.position}`)}}))}if(e.fusionTooltip){const[s,n]=t.addRow();s.text("Data type");n.append("span").text("Fusion transcript");e.fusionTooltip.forEach((e=>{const[s,n]=t.addRow();s.text("Break points");n.append("span").text(` ${e.geneA?e.geneA:""} ${e.chrA}:${e.posA} \n\t\t\t\t\t\t${e.strandA=="+"?"forward":"reverse"} > `+`${e.geneB?e.geneB:""} ${e.chrB}:${e.posB} ${e.strandB=="+"?"forward":"reverse"} `)}))}if(e.cnvTooltip){e.cnvTooltip.forEach((e=>{const[s,n]=t.addRow();s.text("CNV");n.append("span").style("color",e.color).text(e.value).append("span").style("margin-left","5px").text(`${e.chr}:${e.start}-${e.stop}`)}))}}}function Tt(t={}){const e={downloadImgName:"disco.plot",Disco:{cnvCapping:5,isOpen:false,prioritizeGeneLabelsByGeneSets:false,showPrioritizeGeneLabelsByGeneSets:false,cnvRenderingType:ut.heatmap,cnvPercentile:80},rings:{nonExonicRingWidth:20,snvRingWidth:20,lohRingWidth:20,cnvRingWidth:30,snvRingFilters:["exonic"],chromosomeInnerRadius:190,chromosomeWidth:20,labelLinesInnerRadius:210,labelsToLinesDistance:30,labelsToLinesGap:2,nonExonicRingEnabled:true,nonExonicFilterValues:["non-exonic"]},verticalPadding:70,horizontalPadding:500,layerScaler:1,padAngle:.002,label:{fontSize:12,maxDeltaAngle:.05,animationDuration:1e3,overlapAngleFactor:5},cnv:{capping:5,ampColor:"#D6683C",lossColor:"#67a9cf",cappedAmpColor:"#8B0000",cappedLossColor:"#00008B",unit:"Unit"},snv:{maxMutationCount:1e4},legend:{snvTitle:"SNV",cnvTitle:"CNV",lohTitle:"LOH",fusionTitle:"SV",lohLegendEnabled:true,fontSize:12,rowHeight:48},menu:{padding:5}};return d(e,t)}class Pt{constructor(t){this.geneClickListener=t}render(t,e){const i=g();const o=t.append("g");const a=j.create();o.selectAll("path").data(e).enter().append("path").attr("d",(t=>i(t))).attr("fill",(t=>t.color)).on("mouseover",((t,e)=>{const i=s({holder:a.d});const o=structuredClone(e);o.dt=n;o.class=e.dataClass;o.gene=o.text;{const[t,e]=i.addRow();t.text("Consequence");e.append("span").text(o.mname);e.append("span").style("margin-left","5px").style("color",o.color).style("font-size",".8em").text(o.dataClass)}{const[t,e]=i.addRow();t.text(o.ref&&o.alt?"Mutation":"Position");e.append("span").text(`${o.chr}:${o.pos+1} ${o.ref&&o.alt?o.ref+">"+o.alt:""}`)}if(o.gene){const[t,e]=i.addRow();t.text("Gene");e.text(o.gene)}if(o.occurrence>1){const[t,e]=i.addRow();t.text("Occurrence");e.text(o.occurrence)}a.show(t.x,t.y)})).on("mouseout",(()=>{a.clear();a.hide()})).on("click",((t,e)=>{this.geneClickListener(e.text,[e.mname])}))}}class Ot{constructor(t,e){this.svnWidth=t;this.geneClickListener=e}render(t,e){if(e.length>0){const s=e[0].innerRadius;const n=new F(s,this.svnWidth,"#6464641A");n.render(t)}const i=g();const o=t.append("g");const a=j.create();o.selectAll("path").data(e).enter().append("path").attr("d",(t=>i(t))).attr("fill",(t=>t.color)).on("mouseover",((t,e)=>{const i=s({holder:a.d});const o=structuredClone(e);o.dt=n;o.class=e.dataClass;o.gene=o.text;{const[t,e]=i.addRow();t.text("Consequence");e.append("span").text(o.mname);e.append("span").style("margin-left","5px").style("color",o.color).style("font-size",".8em").text(o.dataClass)}{const[t,e]=i.addRow();t.text(o.ref&&o.alt?"Mutation":"Position");e.append("span").text(`${o.chr}:${o.pos+1} ${o.ref&&o.alt?o.ref+">"+o.alt:""}`)}if(o.gene){const[t,e]=i.addRow();t.text("Gene");e.text(o.gene)}if(o.occurrence>1){const[t,e]=i.addRow();t.text("Occurrence");e.text(o.occurrence)}a.show(t.x,t.y)})).on("mouseout",(()=>{a.clear();a.hide()})).on("click",((t,e)=>{this.geneClickListener(e.text,[e.mname])}))}}class Nt{render(t,e){const n=g();const i=t.append("g");const o=j.create();i.selectAll("path").data(e).enter().append("path").attr("d",(t=>n(t))).attr("fill",(t=>t.color)).on("mouseover",((t,e)=>{const n=s({holder:o.d});const i=structuredClone(e);i.dt=r;i.gene=i.text;{const[t,e]=n.addRow();t.text("Data type");e.append("span").style("margin-left","5px").text("Loss of Heterozygosity")}const[a,l]=n.addRow();a.text("Position");l.append("span").text(`${e.chr}:${e.start}-${e.stop}`);o.show(t.x,t.y)})).on("mouseout",(()=>{o.clear();o.hide()}))}}class Et{render(t,e){const n=g();const i=t.append("g");const o=j.create();i.selectAll("path").data(e).enter().append("path").attr("d",(t=>n(t))).attr("fill",(t=>t.color)).on("mouseover",((t,e)=>{const n=structuredClone(e);n.dt=a;n.samples=[{sample_id:e.sampleName}];n.gene=n.text;const i=s({holder:o.d});{const[t,e]=i.addRow();t.text("Copy number change");e.html(`<span style="background:${n.color}"> </span> ${n.value}`)}{const[t,e]=i.addRow();t.text("Position");e.text(n.chr+":"+n.start+"-"+n.stop)}{const[t,e]=i.addRow();t.text("Unit");e.text(n.value)}o.show(t.x,t.y)})).on("mouseout",(()=>{o.clear();o.hide()}))}}class Vt{constructor(t=0,e=0){this.positivePercentile80=t;this.negativePercentile80=e}render(t,e){const n=g();const i=t.append("g");const o=j.create();i.selectAll("path").data(e).enter().append("path").attr("d",(t=>n(t))).attr("fill",(t=>c([this.negativePercentile80,0,this.positivePercentile80],[t.color,"white",t.color]).clamp(true)(t.value))).on("mouseover",((t,e)=>{const n=s({holder:o.d});const i=structuredClone(e);i.dt=a;i.samples=[{sample_id:e.sampleName}];i.gene=i.text;{const[t,e]=n.addRow();t.text("Copy number change");e.html(`<span style="background:${i.color}"> </span> ${i.value}`)}{const[t,e]=n.addRow();t.text("Position");e.text(i.chr+":"+i.start+"-"+i.stop)}{const[t,e]=n.addRow();t.text("Unit");e.text(i.value)}o.show(t.x,t.y)})).on("mouseout",(()=>{o.clear();o.hide()}))}}class St{constructor(t){this.recreateViewModel=false;this.type="Disco";this.opts=t;this.isOpen=false;this.discoInteractions=new X(this)}init(){return t(this,void 0,void 0,(function*(){const t=this.app.getState();const e=t.plots.find((t=>t.id===this.id)).settings;this.stateViewModelMapper=new yt(e);this.viewModel=this.stateViewModelMapper.map(t);const s=this.opts.holder;const n=s.append("div").style("display","inline-block").style("vertical-align","top");const i=n.append("div");const o=n.append("div");const a=this.getConfigInputsOptions(this.viewModel);this.features=yield u({topbar:R({app:this.app,id:this.id,downloadHandler:()=>this.discoInteractions.downloadClickListener(s.select('svg[id="sjpp_disco_plot"]').node()),callback:()=>this.toggleVisibility(this.isOpen),isOpen:()=>this.isOpen,holder:i}),config:b({app:this.app,id:this.id,holder:o,isOpen:()=>this.isOpen,inputs:a})})}))}getConfigInputsOptions(t){const e=[];if(t.settings.Disco.showPrioritizeGeneLabelsByGeneSets){const s=[{boxLabel:t.genesetName,label:`Filter mutations`,type:"checkbox",chartType:"Disco",settingsKey:"prioritizeGeneLabelsByGeneSets",title:`Only show mutations for ${t.genesetName} genes`}];e.push(...s)}const s=[{label:"CNV capping",type:"number",chartType:"Disco",settingsKey:"cnvCapping",title:"Cnv capping",min:0},{boxLabel:"",label:"CNV rendering type",type:"radio",chartType:"Disco",settingsKey:"cnvRenderingType",title:"CNV rendering type",options:[{label:"Heatmap",value:ut.heatmap},{label:"Bar",value:ut.bar}]},{label:"CNV percentile",type:"number",chartType:"Disco",settingsKey:"cnvPercentile",title:"Cnv percentile",min:1,max:100}];e.push(...s);return e}main(){return t(this,void 0,void 0,(function*(){const t=this.state.settings;this.isOpen=t.Disco.isOpen;if(this.recreateViewModel){this.stateViewModelMapper=new yt(t);this.viewModel=this.stateViewModelMapper.map(this.app.getState())}this.recreateViewModel=true;if(this.viewModel){const e=this.opts.holder;e.select('div[id="sjpp_disco_plot_holder_div"]').remove();const s=e.append("div").attr("id","sjpp_disco_plot_holder_div").style("display","inline-block");const n=this.app.getState();for(const t in this.features){this.features[t].update({state:this.state,appState:n})}const i=new It(this.viewModel.cappedCnvMaxAbsValue,t.label.fontSize);const o=new q(this.getRingRenderers(t,this.viewModel,this.discoInteractions.geneClickListener),i);o.render(s,this.viewModel)}}))}getState(t){return t.plots.find((t=>t.id===this.id))}getRingRenderers(t,e,s){const n=new Lt(t.padAngle,t.rings.chromosomeInnerRadius,t.rings.chromosomeInnerRadius+t.rings.chromosomeWidth);const i=new Dt(t.label.animationDuration,s);const o=new Pt(s);const a=new Ot(t.rings.snvRingWidth,s);const r=t.Disco.cnvRenderingType===ut.heatmap?new Vt(e.positivePercentile80,e.negativePercentile80):new Et;const l=new Nt;const c=new Map;c.set(ot.CHROMOSOME,n);c.set(ot.LABEL,i);c.set(ot.NONEXONICSNV,o);c.set(ot.SNV,a);c.set(ot.CNV,r);c.set(ot.LOH,l);return c}toggleVisibility(t){this.app.dispatch({type:"plot_edit",id:this.opts.id,config:{settings:{Disco:{isOpen:!t}}}})}}const zt=p(St);const Bt=zt;function Gt(e){return t(this,void 0,void 0,(function*(){return{chartType:"Disco",subfolder:"disco",extension:"ts",settings:Tt(e.overrides)}}))}export{Bt as componentInit,zt as discoInit,Gt as getPlotConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-1f85f553.js";import{m as e,a as l,b as n,c as i,f as a,e as o}from"./uiUtils-1336bad7.js";import{T as s}from"./toggleButtons-002aeda1.js";import{y as p,aT as d}from"./app-a8c4854a.js";import{launch as c}from"./launch.adhoc-d229fd55.js";import"./plot.app-aa916e0e.js";import"./recover-36ada47f.js";import"./roundValue-b0d0517c.js";import"path";import"./FilterRxComp-242f4615.js";import"./table-79e3e776.js";import"./termdb.bins-9faa5170.js";import"./FilterStateless-046081c2.js";import"./app-ade9c62a.js";import"./termInfo-f851b415.js";import"./genesearch-ea59f5d4.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";function r(t,n,i){const a=t.append("div").style("margin","20px 20px 20px 40px").style("font-family","'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif").style("place-items","center left").style("overflow","hidden").classed("sjpp-app-ui",true).classed("sjpp-disco-ui",true);const o={data:[]};e(a,"Select Genome").style("font-size","1.15em").style("padding","10px 0px").style("color","#003366");m(a,n,o);e(a,"Provide Data").style("font-size","1.15em").style("padding","10px 0px 5px 0px").style("color","#003366");a.append("div").style("opacity",.75).style("padding","10px 10px 15px 20px").style("width","65vw").style("line-height","1.5em").html('<p>The plot accepts multiple data types. Input fields for each data type are available in the tabs below. Upload a file or paste data in at least one data type tab and click "Create Disco Plot". <a href="https://proteinpaint.stjude.org/ppdemo/hg38/disco/discoDemoData.tar.gz" target="Demo data">Download example files</a></p>');const s=a.append("div").style("margin-left","2vw");y(s,o);const p=a.append("div").style("display","flex").style("align-items","center").style("padding","15px 0px");v(p,o,n,a,t);l(p,o,".disco_input");if(i)window["doms"]=o;return o}function m(t,e,l){const i=t.append("div").style("margin-left","40px");const a=n(i,e).style("border","1px solid rgb(138, 177, 212)");l.genome=a.node()}function y(e,l){const n=[{label:"SNV Indel",active:true,callback:(e,n)=>t(this,void 0,void 0,(function*(){n.key="snv";const t=`<ol>\n\t\t\t\t\t<li>chr</li>\n\t\t\t\t\t<li>position</li>\n\t\t\t\t\t<li>gene</li>\n\t\t\t\t\t<li>aachange</li>\n\t\t\t\t\t<li>class</li></ol>\n\t\t\t\t\t<p>Example:</p>\n<pre style="margin-left: 10px;">\nchr1\t226252135\tH3F3A\tK28M\tM\nchr2\t98765432\tTestGene\tTestMutation\tF\n</pre>`;f(n,l,t)}))},{label:"SV",active:false,callback:(e,n)=>t(this,void 0,void 0,(function*(){n.key="sv";const t=`<ol>\n\t\t\t\t\t<li>chrA</li>\n\t\t\t\t\t<li>posA</li>\n\t\t\t\t\t<li>geneA (optional)</li>\n\t\t\t\t\t<li>chrB</li>\n\t\t\t\t\t<li>posB</li>\n\t\t\t\t\t<li>geneB (optional)</li>\n\t\t\t\t</ol>\n\t\t\t\t<p>Example (with genes):</p>\n<pre style="margin-left: 10px;">\nchr6\t3067605\tMDC1\tchr12\t61521661\tKMT2D\n</pre>\n\t\t\t\t<p>Example (without genes):</p>\n<pre style="margin-left: 10px;">\nchr6\t3067605\tchr12\t61521661\n</pre>`;f(n,l,t)}))},{label:"CNV",active:false,callback:(e,n)=>t(this,void 0,void 0,(function*(){n.key="cnv";const t=`<ol>\n\t\t\t\t<li>chr</li>\n\t\t\t\t<li>start</li>\n\t\t\t\t<li>stop</li>\n\t\t\t\t<li>value</li>\n\t\t\t\t</ol>\n\t\t\t\t<p>Example:</p>\n<pre style="margin-left: 10px;">\nchr1\t1\t100000000\t0.5\nchr1\t100000000\t200000000\t-0.5\n</pre>`;f(n,l,t)}))}];new s({holder:e,tabs:n,tabsPosition:"vertical",linePosition:"right"}).main()}function f(t,e,l){t.contentHolder.style("border","none").style("display","block").style("padding-left","30px");x(t,e);t.contentHolder.append("div").style("padding","15px 0px 0px 10px").style("opacity",.75).text(`Provide ${t.label} data in tab delimited format with the following columns:`).append("span").html(l);delete t.callback}function x(e,l){const n=95;const i=[{label:"Select File",active:true,width:n,callback:(n,i)=>t(this,void 0,void 0,(function*(){const t=e.key;i.contentHolder.style("border","none").style("display","block");d(i.contentHolder);i.contentHolder.append("div").style("padding","0px 0px 5px 15px").style("opacity",.65).text(`Select a local file`);u(i,l,t);delete i.callback}))},{label:"Paste Data",active:false,width:n,callback:(n,i)=>t(this,void 0,void 0,(function*(){const t=e.key;i.contentHolder.style("border","none").style("display","block");d(i.contentHolder);h(i,l,t);delete i.callback}))}];new s({holder:e.contentHolder,tabs:i}).main()}function u(t,e,l){const n=t.contentHolder.append("div").style("display","inline-block");const i=a(n).classed("disco_input",true);i.on("change",(t=>{const n=t.target.files[0];const i=new FileReader;i.onload=t=>{e.data[l+"Text"]=t.target.result};i.readAsText(n,"utf8")}))}function h(e,l,n){const i=e.contentHolder.append("div").style("display","block");const a=o({div:i,cols:50}).style("border","1px solid rgb(138, 177, 212)").style("margin","0px 0px 0px 20px").classed("disco_input",true).on("keyup",(()=>t(this,void 0,void 0,(function*(){l.data[n+"Text"]=a.property("value").trim()}))))}function v(t,e,l,n,a){const o=i({div:t,text:"Create Disco Plot"});const s=t.append("div");o.style("margin-right","10px").style("font-size","16px").classed("sjpp-ui-submitBtn",true).attr("type","submit").on("click",(()=>{if(!e.data||e.data==undefined){const t=s.append("div").style("display","inline-block").style("max-width","20vw");p(t,"Please provide data");setTimeout((()=>t.remove()),2e3)}else{const t=l[e.genome.options[e.genome.selectedIndex].text];n.remove();c(e.data,t,a);b(a,l)}}))}function b(t,e){t.append("button").html("« Back").on("click",(()=>{t.selectAll("*").remove();r(t,e,false)}))}export{r as init_discoplotUI};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{M as e,d as s,i,G as r,b as n,t as o,H as a,I as l,h as c}from"./app-a8c4854a.js";import{r as d}from"./table-79e3e776.js";import{i as p,a as f,b as h,T as m,r as u}from"./roundValue-b0d0517c.js";import{c as y}from"./termdb.bins-9faa5170.js";function g(t){switch(t){case"./tvs.categorical.js":return import("./tvs.categorical-b9b37c70.js");case"./tvs.condition.js":return import("./tvs.condition-cbe198d7.js");case"./tvs.density.js":return import("./tvs.density-026fca97.js");case"./tvs.geneVariant.js":return import("./tvs.geneVariant-3a65ad94.js");case"./tvs.numeric.js":return import("./tvs.numeric-3f3d9919.js");case"./tvs.samplelst.js":return import("./tvs.samplelst-1eeb586b.js");case"./tvs.survival.js":return import("./tvs.survival-df35b85b.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class b{constructor(t){this.opts=this.validateOpts(t);this.dom={holder:t.holder,tip:new e({padding:"5px"})};this.durations={exit:0};_(this);this.categoryData={};this.handlerByType={};this.api={main:this.main.bind(this),showMenu:this.showMenu}}validateOpts(t){if(!t.holder)throw".holder missing";if(!t.vocabApi)throw".vocabApi missing";if(typeof t.callback!="function")throw".callback() is not a function";return t}async main(t={}){this.tvs=t.tvs;this.filter=t.filter;await this.setHandler();await this.updateUI()}async setHandler(){if(!this.tvs||!this.tvs.term)return;const t=this.tvs.term;const e=p(t)?"numeric":f(t)?"categorical":t.type;if(!this.handlerByType[e]){try{const t=await g(`./tvs.${e}.js`);this.handlerByType[e]=t.handler}catch(t){throw`error with handler='./tvs.${e}.js': ${t}`}}this.handler=this.handlerByType[e]}}const v=i(b);function _(t){t.updateUI=function(){const e=t.dom.holder;const s=e.selectAll(".tvs_pill").data([t.tvs],(t=>t?.term.id));s.exit().each(t.exitPill);s.each(t.updatePill);s.enter().append("div").attr("class","tvs_pill").style("white-space","nowrap").style("display","inline-block").transition().duration(200).each(t.enterPill)};t.enterPill=async function(){const e=s(this).style("font-size",".9em");e.append("div").attr("class","term_name_btn sja_filter_tag_btn").style("display","inline-block").style("border-radius","6px 0 0 6px").style("padding","6px 6px 3px 6px").html(t.handler.term_name_gen).style("text-transform","uppercase");e.append("div").attr("class","negate_btn").style("cursor","default").style("padding","6px 6px 3px 6px").style("background",t.tvs.isnot?"#f4cccc":"#a2c4c9").html(t.handler.getNegateText?.(t)||(t.tvs.isnot&&t.tvs.term.type!=="geneVariant"?"NOT":"IS"));t.updatePill.call(this)};t.showMenu=e=>{const s=e?e:t.dom.tip;if(t.tvs.term.type!=="geneVariant"){j(s,t.tvs,t)}t.handler.fillMenu(t,s,t.tvs)};t.updatePill=async function(){const e=s(this);const i=e.datum();const r=t.tvs.values&&t.tvs.values.length||t.tvs.ranges&&t.tvs.ranges.length||t.tvs.term.type=="samplelst";e.select(".term_name_btn").html(t.handler.term_name_gen);e.select(".negate_btn").style("display",r?"inline-block":"none").style("background",t.tvs.isnot?"#f4cccc":"#a2c4c9").html(t.handler.getNegateText?.(t)||(i.isnot&&i.term.type!=="geneVariant"?"NOT":"IS"));const n=t.handler.get_pill_label(i);if(!("grade_type"in n))n.grade_type="";const o=e.selectAll(".value_btn").data(n?[n]:[],(t=>t.txt+t.grade_type));o.exit().each(t.removeValueBtn);o.enter().append("div").attr("class","value_btn sja_filter_tag_btn").style("display",r?"inline-block":"none").style("padding","6px 6px 3px 6px").style("border-radius","0 6px 6px 0").style("font-style","italic").html((t=>t.txt)).append("div").attr("class","grade_type_btn").style("display","inline-block").style("margin","0 5px").style("font-size",".6em").style("text-transform","uppercase").html((t=>t.grade_type)).style("opacity",0).transition().duration(200).style("opacity",1)};t.exitPill=async function(e){s(this).style("opacity",1).transition().duration(t.durations.exit).style("opacity",0).remove()};t.makeValueTable=function(e,s,i,r){if(i?.length==0)return e;const n=e.append("div").style("font-size","0.8rem");const o=n.append("div");const a=Math.max(...i.map((t=>t.samplecount)),0);i.forEach((t=>t.bar_width_frac=Number((1-(a-t.samplecount)/a).toFixed(4))));const l=100;const c=[];const p=[];for(const[t,e]of i.entries()){let i=e.label||e.key;if(e.samplecount)i+=" (n="+e.samplecount+")";const r=l*e.bar_width_frac;const n=`<div style='margin:1px 10px;width:${r}px;height:15px;background-color:#ddd'>`;c.push([{value:i},{html:n}]);let o=false;if(s.term.type=="categorical"||s.term.type=="survival")o=s.values.find((t=>t.key===e.key));else if(s.term.type=="float"||s.term.type=="integer")o=s.ranges.find((t=>String(t.value)===e.value.toString()));else if(s.term.type=="condition")o=s.values.find((t=>String(t.key)===String(e.key)));if(o)p.push(t)}const f=[{label:"tvs"},{label:"bar"}];const h={text:"APPLY",class:"sjpp_apply_btn sja_filter_tag_btn",callback:t=>{if(r)r(t)}};t.tableApi=d({rows:c,columns:f,div:o,maxWidth:"40vw",maxHeight:"40vh",buttons:[h],showHeader:false,striped:false,showLines:false,selectedRows:p,selectedRowStyle:{"text-decoration":s.isnot?"line-through":""}});return o};t.removeValueBtn=function(e,i){const r=s(this.parentNode);const n=r.datum();const o=t.handler.getSelectRemovePos(i,n);s(r.selectAll(".value_select")._groups[0][o]).remove();s(r.selectAll(".or_btn")._groups[0][i]).remove();s(this).style("opacity",1).transition().duration(t.durations.exit).style("opacity",0).remove()}}async function w(t){const e=new b(t);e.tvs={term:t.term};e.filter=t.filter;await e.setHandler();if(e.handler.setTvsDefaults)e.handler.setTvsDefaults(e.tvs);e.handler.fillMenu(e,t.holder,e.tvs)}function j(t,e,s){const i=t.selectAll("label").data([{label:"Exclude",value:"false",checked:e.isnot!==undefined?e.isnot:false}]).enter().append("label").style("margin","0 5px");const r=i.append("input").attr("type","checkbox").attr("name","sja_filter_isnot_input").attr("value",(t=>t.value)).property("checked",(t=>t.checked)).style("vertical-align","top").style("margin-right","3px").on("change",(()=>{e.isnot=r.node().checked;if(s.tableApi){s.tableApi.update({selectedRowStyle:{"text-decoration":e.isnot?"line-through":""}})}}));i.append("span").style("margin-right","5px").style("vertical-align","top").html((t=>t.label))}function T(t,e){if(t.type==="tvs"&&t.tvs.term.id===e)return t;if(t.type!=="tvslst")return;for(const s of t.lst){const t=T(s,e);if(t)return t}}function N(t,e){if(t.$id===e)return t;if(t.type!=="tvslst")return;for(const s of t.lst){const t=N(s,e);if(t)return t}}function S(t,e){if(t.$id===e)return t;if(!t.lst)return;for(const s of t.lst){if(s.$id===e)return t;else if(s.type=="tvslst"){const t=S(s,e);if(t)return t}}}function x(t,e){if(t.tag===e)return t;if(t.type!=="tvslst")return;for(const s of t.lst){const t=x(s,e);if(t)return t}}function k(t=[],e="",s=null){const i={type:"tvslst",in:true,join:e,lst:t};if(s!==null&&i.$id!==undefined)i.$id=s;return i}function A(t){if(!t)return k([]);const e=JSON.parse(JSON.stringify(t));const s=O(e);return s.type=="tvslst"?s:k([s])}function O(t){delete t.$id;delete t.tag;if(t.type!="tvslst")return t;const e=t.lst.filter((t=>t.type!=="tvslst"||t.lst.length>0)).map((t=>t.type!=="tvslst"||t.lst.length>1?t:t.lst[0]));e.forEach(I);if(!e.length){return k([],"",t.$id)}else if(e.length==1){if(e[0].type==="tvslst"){return O(e[0])}else{return I(e[0])}}else{t.lst=[];for(const s of e){if(s.type==="tvslst"){const e=O(s);if(e.type!=="tvslst"||e.join!=t.join||e.in!=t.in){t.lst.push(e)}else if(e.lst.length){t.lst.push(...e.lst)}}else{t.lst.push(s)}}return t}}function I(t,e=null){delete t.$id;if(typeof e=="function")e(t);if(t.type=="tvslst"){for(const s of t.lst){I(s,e)}}return t}function C(t){if(!t||t.length==0)return;let e=JSON.parse(JSON.stringify(t[0]));if(t.length==1)return e;if(e.lst.length<2){if(e.join!=="")throw'filter.join must be an empty string "" when filter.lst.length < 2';e.join="and"}else if(e.join=="or"){e={type:"tvslst",join:"and",in:true,lst:[e]}}else if(e.join!="and"){throw'filter.join must be either "and" or "or" when .lst length > 1'}for(let s=1;s<t.length;s++){const i=JSON.parse(JSON.stringify(t[s]));if(i.join=="or")e.lst.push(i);else e.lst.push(...i.lst)}if(e.lst.length==1&&e.lst[0].type=="tvs"){e.join=""}return e}let D=0;function R(t){t.initUI=async function(){if(t.opts.newBtn){t.opts.newBtn.on("click.filter",t.displayTreeNew)}else{t.dom.newBtn=t.dom.holder.append("div").attr("class","sja_new_filter_btn sja_menuoption").html(t.opts.emptyLabel).style("display","inline-block").on("click",t.displayTreeNew)}t.dom.filterContainer=t.dom.holder.append("div").attr("class","sja_filter_container");t.dom.holder.selectAll(".sja_filter_add_transformer").data(t.opts.joinWith).enter().append("div").attr("class","sja_filter_add_transformer").style("display",(e=>t.filter&&t.filter.join!=e?"inline-block":"none")).style("margin-left","10px").style("padding","5px").style("border-radius","5px").style("cursor","pointer").html((t=>"+"+t.toUpperCase())).on("click",t.displayTreeNew);t.dom.table=t.dom.controlsTip.clear().d.append("table").style("border-collapse","collapse");const e=[{action:"edit",html:["","Edit","›"],handler:t.editTerm},{action:"join",html:["✚","","›"],handler:t.displayTreeMenu},{action:"switch",html:["","Switch to",""],handler:t.switchJoin},{action:"negate",html:["","Negate",""],handler:t.negateClause},{action:"remove",html:["✖","Remove",""],handler:t.removeTransform}];if(t.opts.vocab){e.splice(1,0,{action:"replace",html:["","Replace","›"],handler:t.displayTreeMenu})}t.dom.table.selectAll("tr").data(e).enter().append("tr").attr("class","sja_menuoption").on("click",t.handleMenuOptionClick).selectAll("td").data((t=>t.html)).enter().append("td").style("padding","5px").style("border-top","solid 1px white").style("color",((t,e)=>t=="✖"?"#a00":e===0?"#0a0":"#111")).style("opacity",((t,e)=>e===0?.8:1)).html((t=>t));t.dom.treeHead=t.dom.treeTip.d.append("div").attr("class","sja_tree_tip_head").style("padding","3px");t.dom.termSrcDiv=t.dom.treeTip.d.append("div").attr("class","sja_term_src_body");t.dom.treeHeadTitle=t.dom.treeHead.append("div");s("body").on("mousedown.sja_filter_"+D++,(e=>{if(["sja_filter_join_label","sja_filter_clause_negate","sja_filter_paren_open","sja_filter_paren_close"].includes(e.target.className))return;t.dom.filterContainer?.selectAll(".sja_filter_grp").style("background-color","transparent");t.removeBlankPill();this.dom.holder?.selectAll(".sja_filter_add_transformer").style("display",this.getAddTransformerBtnDisplay)}))};t.updateUI=async function(e,s){e.datum(s).style("display",!s.lst||!s.lst.length?"none":"inline-block");const i=e.selectAll(":scope > .sja_filter_grp").style("background-color","transparent").data([s],t.getId);i.exit().each(t.removeGrp);i.each(t.updateGrp);i.enter().append("div").attr("class","sja_filter_grp").style("margin","5px").each(t.addGrp);t.updatePromise(0)};t.addGrp=function(e,i){const r=this.parentNode.__data__;s(this).style("display","inline-block");s(this).append("div").attr("class","sja_filter_clause_negate").style("display",r.in?"none":"inline-block").style("color","rgb(102,0,0)").style("font-weight",500).style("cursor","pointer").html("NOT").on("click",t.displayControlsMenu);s(this).append("div").attr("class","sja_filter_paren_open").html("(").style("display","none").style("padding","0 5px").style("font-weight",500).style("font-size","24px").style("cursor","pointer").on("click",t.displayControlsMenu);const n=e.type=="tvslst"?e.lst:[e];const o=s(this).selectAll(":scope > .sja_filter_item").data(n,t.getId);o.enter().append("div").attr("class","sja_filter_item").each(t.addItem);if(t.opts.joinWith.length==1){t.dom.last_join_div=s(this).append("div").attr("class","sja_filter_last_join").style("display","inline");t.dom.last_join_label=t.dom.last_join_div.append("div").datum({action:"join",html:["✚","","›"],handler:t.displayTreeMenu}).attr("class","sja_filter_last_join_label").style("padding","0 5px").style("display",r.lst.length?"inline":"none").style("font-weight",500).style("cursor","pointer").html("+"+t.opts.joinWith[0].toUpperCase()).on("click",t.showLastJoinBlank);s("body").on("mousedown.sja_filter_last_join",(()=>{t.dom.last_join_label.style("display","inline")}))}s(this).append("div").attr("class","sja_filter_paren_close").style("padding","0 5px").html(")").style("display","none").style("font-weight",500).style("font-size","24px").style("cursor","pointer").on("click",t.displayControlsMenu);s(this).selectAll(":scope > .sja_filter_paren_open, :scope > .sja_filter_paren_close").style("display",t.opts.joinWith.length<2||n.length<2?"none":!r.in||n.length>1&&r.tag!="filterUiRoot"?"inline-block":"none")};t.updateGrp=function(e,i){const r=this.parentNode.__data__;s(this).select(":scope > .sja_filter_clause_negate").style("display",r.in?"none":"inline-block");const n=e.type=="tvslst"?e.lst:[e];s(this).selectAll(":scope > .sja_filter_paren_open, :scope > .sja_filter_paren_close").style("display",t.opts.joinWith.length<2||n.length<2?"none":!r.in||n.length>1&&r.tag!="filterUiRoot"?"inline-block":"none");const o=s(this).selectAll(":scope > .sja_filter_item").data(n,t.getId);o.exit().each(t.removeItem);o.each(t.updateItem);o.enter().insert("div",":scope > .sja_filter_paren_close").attr("class","sja_filter_item").each(t.addItem);s(this).selectAll(":scope > .sja_filter_item").sort(((t,e)=>n.indexOf(t)-n.indexOf(e)));if(t.dom.last_join_label){t.dom.last_join_div.datum(r);this.insertBefore(t.dom.last_join_div.node(),s(this).select(":scope > .sja_filter_paren_close").node());t.dom.last_join_label.style("display","inline")}};t.removeGrp=function(e){t.numExpectedItems+=1;if(e.type=="tvslst"){for(const s of e.lst){if(s.lst)t.removeGrp(s);else{delete t.pills[s.$id]}}}else{delete t.pills[e.$id]}if(this instanceof Node){s(this).selectAll("*").on("click",null);s(this).on("click",null).remove()}t.updatePromise()};t.addItem=async function(e,i){const r=this.parentNode.__data__;if(e.type=="tvslst"){t.updateUI(s(this),e);t.addJoinLabel(this,r,e);return}t.numExpectedItems+=1;const n=s(this).style("display","inline-block").style("position","relative").style("white-space","nowrap").append("div").attr("class","sja_pill_wrapper").style("display","inline-block").style("margin",t.opts.joinWith.length>1?"":"2px").on("click",e.renderAs==="htmlSelect"?null:t.displayControlsMenu);t.addJoinLabel(this,r,e);if(e.renderAs=="htmlSelect"){const s=V(t,e);const i=n.append("select").on("change",(function(){const i=JSON.parse(JSON.stringify(t.filter));const n=N(i,r.$id);const o=r.lst.indexOf(e);if(o==-1)return;const a=+this.value;const l=JSON.parse(JSON.stringify(e));const c="keys"in s[a]?s[a].keys:[s[a].key];l.tvs.values=c.map((t=>({key:t,label:t})));n.lst[o]=l;t.refresh(i)}));const o=E(t,e);i.selectAll("option").data(s).enter().append("option").property("value",((t,e)=>e)).property("selected",((t,e)=>e==o)).html((t=>t.shortLabel?t.shortLabel:t.label?t.label:t.key))}else{const s=await v({vocabApi:t.vocabApi,holder:n,debug:t.opts.debug,getCategoriesArguments:t.opts.getCategoriesArguments,callback:s=>{const i=JSON.parse(JSON.stringify(t.filter));const n=N(i,r.$id);const o=r.lst.indexOf(e);if(o==-1)return;const a=n.lst.findIndex((t=>t.$id==e.$id));if(a==-1)n.lst[o]={$id:e.$id,type:"tvs",tvs:s};else n.lst[a].tvs=s;t.refresh(i)}});t.pills[e.$id]=s;await s.main({tvs:e.tvs,filter:t.getFilterExcludingPill(e.$id)})}t.updatePromise()};t.updateItem=async function(e,i){const r=this.parentNode.__data__;s(this).select(":scope > .sja_filter_join_label").style("display",t.opts.joinWith.length>1&&r.lst.indexOf(e)<r.lst.length-1?"inline-block":"none").style("margin",t.opts.joinWith.length>1?"":"2px").html(r.join=="and"?"AND":"OR");if(e.type=="tvslst"){t.updateUI(s(this),e)}else if(e.renderAs==="htmlSelect"){t.numExpectedItems+=1;s(this).select("select").property("value",""+E(t,e))}else{if(!t.pills[e.$id])return;t.numExpectedItems+=1;await t.pills[e.$id].main({tvs:e.tvs,filter:t.getFilterExcludingPill(e.$id)})}t.updatePromise()};t.removeItem=function(e){delete t.pills[e.$id];s(this).on("click",null).remove()};t.addJoinLabel=function(e,i,r){const n=i.lst.findIndex((t=>t.$id===r.$id));s(e).append("div").attr("class","sja_filter_join_label").style("display",t.opts.joinWith.length>1&&i.lst.length>1&&r&&n!=-1&&n<i.lst.length-1?"inline-block":"none").style("width","50px").style("padding","5px").style("border","none").style("border-radius","5px").style("text-align","center").style("cursor","pointer").html(i.lst.length<2?"":i.join=="and"?"AND":"OR").on("click",t.displayControlsMenu)};t.updateJoinLabel=function(e){const i=this.parentNode.parentNode.parentNode.__data__;const r=i.lst.findIndex((t=>t.$id===e.$id));s(this).style("display",t.opts.joinWith.length>1&&i.lst.length>1&&e&&r!=-1&&r<i.lst.length-1?"inline-block":"none")};t.getAddTransformerBtnDisplay=function(e){if(t.opts.joinWith.length<2){return"none"}else if(t.filter&&t.filter.lst.find((t=>t.tag==="cohortFilter"))){return t.filter.lst.length==1&&e=="and"?"inline-block":"none"}else{return t.filter&&t.filter.lst.length>0&&(t.filter.join!==e||!t.filter.in)?"inline-block":"none"}}}function V(t,e){return e.selectOptionsFrom=="selectCohort"?t.opts.termdbConfig.selectCohort.values:Array.isArray(e.tvs.term.values)?e.tvs.term.values:Object.values(e.tvs.term.values)}function E(t,e){const s=V(t,e);const i=JSON.stringify(e.tvs.values.map((t=>t.key)).sort());const r=s.findIndex((t=>t.keys?i===JSON.stringify(t.keys.sort()):t.key===i));return r}const M="#fff";function $(t){t.displayControlsMenu=function(e){e.stopPropagation();if(!t.activeData)return;const s=this.parentNode.__data__;const i=S(t.filter,s.$id);t.activeData={item:s,filter:i,elem:this};t.removeBlankPill();t.resetGrpHighlights(this,i);if(s.noEdit)t.dom.table.selectAll("tr").filter((t=>t.action=="edit")).style("display","none");t.dom.controlsTip.showunder(this)};t.resetGrpHighlights=function(e,s){const i=e.className;const r=i.includes("join")||i.includes("negate")||i.includes("paren");const n=t.dom.controlsTip.d.selectAll("tr").style("background-color","");n.filter((t=>t.action=="edit"||t.action=="replace")).style("display",r?"none":"table-row");n.filter((t=>t.action=="remove")).style("display",i.includes("_join_")&&s.lst.find((t=>t.tag=="cohortFilter"))?"none":"table-row");n.filter((t=>t.action=="join")).style("display",t.opts.joinWith.length<2||s.$id==t.filter.$id&&s.lst.length==1||i.includes("negate")||i.includes("paren")?"none":"table-row").select("td:nth-child(2)").html(r?s.join.toUpperCase():s.join=="and"?"OR":"AND");n.filter((t=>t.action=="switch")).style("display",t.opts.joinWith.length<2||s.$id==t.filter.$id&&s.lst.length==1||!i.includes("_join_")?"none":"table-row").select("td:nth-child(2)").html((t=>s.join=="and"?"Switch to OR":"Switch to AND"));t.dom.filterContainer.selectAll(".sja_filter_grp").style("background-color","transparent");if(r){if(i.includes("join"))e.parentNode.parentNode.style.backgroundColor="#ee5";else e.parentNode.style.backgroundColor="#ee5"}};t.handleMenuOptionClick=async function(e,s){e.stopPropagation();if(s==t.activeData.menuOpt)return;t.activeData.menuOpt=s;if(t.activeData.elem.className.includes("join")&&s.action!=="join"&&s.action!="switch"){t.activeData.item=t.activeData.filter;t.activeData.filter=S(t.filter,t.activeData.item)}t.resetBlankPill(s.action);t.dom.controlsTip.d.selectAll("tr").style("background-color","");await s.handler(this,s)};t.resetBlankPill=function(e){t.removeBlankPill();t.dom.filterContainer.selectAll(".sja_filter_grp").style("background-color","transparent");if(e!="join")return;const i=t.dom.last_join_div?t.dom.last_join_div.node():t.activeData.elem.className.includes("join_label")?t.activeData.elem.parentNode.parentNode:t.activeData.item.type=="tvs"||t.activeData.filter===t.filter?t.activeData.elem:t.activeData.elem.parentNode.parentNode;const r=t.opts.joinWith.length===1?t.opts.joinWith[0].toUpperCase():t.activeData.elem.className.includes("join_label")?t.activeData.filter.join.toUpperCase():t.activeData.btn&&typeof t.activeData.btn.__data__==="string"?t.activeData.btn.__data__.toUpperCase():t.activeData.item.type=="tvslst"?t.activeData.filter.join.toUpperCase():t.activeData.filter.join=="or"?"AND":"OR";if(t.activeData.item.type=="tvs"&&!t.activeData.elem.className.includes("join_label")){s(i).insert("div","div").attr("class","sja_filter_paren_open").style("display",t.opts.joinWith.length>1?"inline-block":"none").style("padding","0 5px").style("font-weight",500).style("font-size","24px").style("cursor","pointer").html("(")}const n=s(i).insert("div",":scope > .sja_filter_paren_close").attr("class","sja_filter_blank_pill").style("display","inline-block").style("height","20px").style("overflow","visible");n.append("div").style("display","inline-block").style("width","50px").style("text-align","center").html(r);n.append("div").style("position","relative").style("top","-7px").style("display","inline-block").style("width","80px").style("height","22px").style("margin-right","5px").style("border","3px dashed #b8d3ea").style("vertical-align","top").style("background-color","#ee5");if(t.activeData.item.type=="tvs"&&!t.activeData.elem.className.includes("join_label")){s(i).append("div").attr("class","sja_filter_paren_close").style("display",t.opts.joinWith.length>1?"inline-block":"none").style("padding","0 5px").style("font-weight",500).style("font-size","24px").style("cursor","pointer").html(")")}if(i==t.dom.filterContainer.node()){t.dom.filterContainer.selectAll(":scope > .sja_filter_grp > .sja_filter_paren_open, :scope > .sja_filter_grp > .sja_filter_paren_close").style("display",t.opts.joinWith.length>1&&t.filter.lst.length>1?"inline-block":"none")}};t.removeBlankPill=function(){t.dom.holder?.selectAll(".sja_filter_blank_pill, .sja_pill_wrapper > .sja_filter_paren_open, .sja_pill_wrapper > .sja_filter_paren_close").remove();if(t.filter.in&&t.filter.lst.filter((t=>t.type==="tvslst")).length<1){t.dom.filterContainer?.selectAll(":scope > .sja_filter_grp > .sja_filter_paren_open, :scope > .sja_filter_grp > .sja_filter_paren_close").style("display","none")}};t.displayTreeNew=async function(e,s){e.stopPropagation();if(t.opts.newBtn&&this.className!=="sja_filter_add_transformer"&&t.filter.lst.length)return;t.dom.filterContainer.selectAll(".sja_filter_grp").style("background-color","transparent");if(t.filter.lst.length>0){t.activeData={item:t.filter,filter:t.filter,elem:t.dom.filterContainer.node(),btn:this}}if(t.filter.lst.length)t.resetBlankPill("join");const i=t.dom.filterContainer.select(".sja_filter_blank_pill").node();if(i){t.dom.holder.selectAll(".sja_filter_add_transformer").style("display","none");t.dom.treeTip.clear().showunder(i)}else{t.dom.treeTip.clear().showunder(this)}const r=t.activeData?t.getAdjustedRoot(t.activeData.filter.$id,s):JSON.parse(t.rawCopy);const n=await import("./app-ade9c62a.js");n.appInit({vocabApi:t.vocabApi,holder:t.dom.termSrcDiv,getCategoriesArguments:t.opts.getCategoriesArguments,state:{activeCohort:t.activeCohort,termfilter:{filter:r},tree:{usecase:{target:"filter"}}},tree:{disable_terms:t.activeData&&t.activeData.filter&&t.activeData.filter.lst&&s=="and"?t.activeData.filter.lst.filter((t=>t.type==="tvs"&&t.tvs.term.type!=="condition")).map((t=>t.tvs.term.id)):[],click_term2select_tvs(e){t.editFilterRoot(s,[{type:"tvs",tvs:e}])}}})};t.editFilterRoot=(e,s)=>{const i=JSON.parse(JSON.stringify(t.filter));if(!i.lst.length){if(s.length>1)i.join="and";i.lst.push(...s);t.refresh(i)}else if(e!="or"&&e!="and"){throw"unhandled new term(s): invalid appender join value"}else{if(!i.join)i.join=e;if(i.join==e&&i.in){if(s.length<2||i.join=="and"){i.lst.push(...s)}else{i.push({type:"tvslst",in:true,join:"and",lst:s})}t.refresh(i)}else if(e=="and"||s.length<2){delete i.tag;t.refresh({tag:"filterUiRoot",type:"tvslst",in:true,join:e,lst:[i,...s]})}else{delete i.tag;t.refresh({tag:"filterUiRoot",type:"tvslst",in:true,join:"or",lst:[i,{type:"tvslst",in:true,join:"and",lst:s}]})}}};t.displayTreeMenu=async function(e,i){s(e).style("background-color",M);t.dom.holder.selectAll(".sja_filter_add_transformer").style("display","none");const r=t.dom.filterContainer.select(".sja_filter_blank_pill").node();if(r){t.dom.controlsTip.hide();t.dom.treeTip.clear().showunder(r)}else if(e.lastChild instanceof HTMLElement){t.dom.treeTip.clear().showunderoffset(e.lastChild)}else{t.dom.treeTip.clear().showunder(e)}const n=t.activeData.filter;const o=await import("./app-ade9c62a.js");o.appInit({vocabApi:t.vocabApi,holder:t.dom.termSrcDiv,getCategoriesArguments:t.opts.getCategoriesArguments,state:{activeCohort:t.activeCohort,header_mode:"search_only",termfilter:{filter:t.getAdjustedRoot(n.$id,n.join)},tree:{usecase:{target:"filter"}}},tree:{disable_terms:n&&n.lst&&n.join=="and"?n.lst.filter((t=>t.type==="tvs"&&t.tvs.term.type!=="condition")).map((t=>t.tvs.term.id)):!t.activeData.item?[]:t.activeData.item.type=="tvs"?[t.activeData.item.tvs.term.id]:t.activeData.item.lst?t.activeData.item.lst.filter((t=>t.type=="tvs")).map((t=>t.tvs.term.id)):[],click_term2select_tvs:i.action=="replace"?t.replaceTerm:!n.join||!n.lst.length||t.activeData.elem&&t.activeData.elem.className.includes("join")?t.appendTerm:t.subnestFilter}})};t.editTerm=function(e){s(e.parentNode).selectAll("tr").style("background-color",t.highlightEditRow);const i=t.dom.termSrcDiv;const r=t.activeData.item;t.dom.treeTip.clear();t.pills[r.$id].showMenu(i);t.dom.treeTip.showunderoffset(e.lastChild)};t.highlightEditRow=function(t){return t.action=="edit"?M:""};t.handleNotLabelClick=function(e,s){t.activeData={item:this.__data__};t.negateClause()};t.negateClause=function(){const e=JSON.parse(JSON.stringify(t.filter));const s=N(e,t.activeData.item.$id);if(s.type=="tvslst")s.in=!s.in;else if(s.type=="tvs"&&s.tvs?.term?.type=="geneVariant"){const t=s.tvs.values.filter((t=>t.mclassExcludeLst.length>0))[0];const e=t.mclassLst;t.mclassLst=t.mclassExcludeLst;t.mclassExcludeLst=e;s.tvs.isnot=!s.tvs.isnot}else s.tvs.isnot=!s.tvs.isnot;t.refresh(e)};t.replaceTerm=e=>{const s=Array.isArray(e)?e:[{type:"tvs",tvs:e}];const i=JSON.parse(JSON.stringify(t.filter));const r=N(i,t.activeData.filter.$id);const n=r.lst.findIndex((e=>e.$id===t.activeData.item.$id));if(s.length<2||r.join=="and"){r.lst.splice(n,1,...s)}else{r.lst[n]={in:!e.isnot,type:"tvslst",join:"and",lst:s}}t.refresh(i)};t.appendTerm=e=>{const s=Array.isArray(e)?e:[{type:"tvs",tvs:e}];const i=JSON.parse(JSON.stringify(t.filter));const r=N(i,t.activeData.filter.$id);if(s.length<2||r.join=="and"){r.lst.push(...s);if(r.join==""&&t.opts.joinWith.length===1)r.join=t.opts.joinWith[0]}else{r.lst.push({in:true,type:"tvslst",join:"and",lst:s})}t.refresh(i)};t.subnestFilter=e=>{let s;if(Array.isArray(e)){s=e}else{s=[{type:"tvs",tvs:e}]}const i=t.activeData.item;const r=t.activeData.filter;const n=JSON.parse(JSON.stringify(t.filter));const o=N(n,r.$id);const a=o.lst.findIndex((t=>t.$id===i.$id));o.lst[a]={in:true,type:"tvslst",join:r.join=="or"?"and":"or",lst:[i,...s]};t.refresh(n)};t.removeTransform=function(e,s){const i=s.action||typeof s!=="object"?t.activeData.item:N(t.filter,s.$id);const r=S(t.filter,i.$id);if(i==r){t.refresh(k([],"",i.$id));return}const n=r.lst.findIndex((t=>t.$id===i.$id));if(n==-1)return;const o=JSON.parse(JSON.stringify(t.filter));const a=N(o,r.$id);a.lst.splice(n,1);if(a.lst.length===1){const e=S(o,a.$id);if(a.lst[0].type=="tvslst"){if(e==o){a.lst[0].tag="filterUiRoot";t.refresh(a.lst[0])}else{const s=e.lst.findIndex((t=>t.$id==a.$id));if(a.lst[0].join==e.join){e.lst.splice(s,1,...a.lst[0].lst);t.refresh(o)}else{e.lst[s]=a.lst[0];t.refresh(o)}}}else{a.join="";const s=e.lst.findIndex((t=>t.$id===a.$id));e.lst[s]=a.lst[0];if(!a.in){e.lst[s].tvs.isnot=!e.lst[s].tvs.isnot;if(e==o)e.in=true}t.refresh(o)}}else{t.refresh(o)}};t.showLastJoinBlank=function(e,s){e.stopPropagation();const i=t.dom.last_join_div.node();t.dom.last_join_label.style("display","none");const r=this.parentNode.__data__;t.activeData={item:r,filter:r,elem:i};t.resetBlankPill(s.action);t.displayTreeMenu(i,s)};t.switchJoin=function(e,s){const i=JSON.parse(JSON.stringify(t.filter));const r=N(i,t.activeData.filter.$id);if(r.join<2)return;r.join=r.join=="and"?"or":"and";t.refresh(i)}}function q(t,e={}){if(t.find((t=>!Number.isFinite(t))))throw"non-numeric values found";let s;const i=new Set(t);if(i.size===1){const t=[...i][0];s={type:"custom-bin",lst:[{stop:t,stopinclusive:false,startunbounded:true,label:"<"+t},{start:t,stop:t,startinclusive:true,stopinclusive:true,label:"="+t},{start:t,startinclusive:false,stopunbounded:true,label:">"+t}]}}else{t.sort(((t,e)=>t-e));const e=t.length;const i=t[0];const r=t[e-1];const n=(r-i)/8;let o=Math.round(e*.05)-1;if(o<0)o=0;const a=t[o];const l=Math.max(i+n,a);let[c,d,p,f]=P(n,l,r,i);s={type:"regular-bin",startinclusive:true,bin_size:c,first_bin:{stop:d}};if(p)s.last_bin={start:p};if(f)s.rounding=f}if("format"in e){if(e.format==="string"){return JSON.stringify(s)}else{throw"options are not in the correct format"}}else{return s}}function P(t,e,s,i){let r,n,o,a;const l=Math.floor(Math.log10(t));if(t>=.1&&t<=2){r=Math.round(t/(1*10**l))*(1*10**l);n=Math.round(e/(1*10**l))*(1*10**l)}else{r=Math.round(t/(5*10**l))*(5*10**l);n=Math.round(e/(5*10**l))*(5*10**l);if(r===0)r=1*10**l;if(n===0)n=1*10**l;if(r===5*10**l&&n===1*10**l)n=5*10**l}if(n<i)n=n*2;const c=n+r*7;if(s>c){o=n+r*6}if(t<1){const t=Math.abs(l);r=Number(r.toFixed(t));n=Number(n.toFixed(t));if(o)o=Number(o.toFixed(t));a="."+t+"f"}if(Object.is(n,-0))n=0;return[r,n,o,a]}class F{constructor(t){this.app=t.app;this.opts=t;this.state=t.state;this.vocab=t.state.vocab;this.currAnnoData={samples:{},refs:{byTermId:{}},lastTerms:[],lastFilter:{}};this.missingCatValsByTermId={};const e=localStorage.getItem("jwtByDsRoute")||`{}`;this.jwtByDsRoute=JSON.parse(e);const s=this.vocab?.dslabel||this.state?.dslabel;this.jwtByRoute=this.jwtByDsRoute[s]||{}}async main(t=null){if(t)Object.assign(this.state,t);else this.state=structuredClone(this.app?.getState?.()||this.opts.state);if(this.state.vocab)this.vocab=this.state.vocab;const e=this.state.dslabel||this.state.vocab.dslabel;this.verifiedToken=!this.state.termdbConfig?.requiredAuth?.length||r(e,"termdb");if(e)await this.maySetVerifiedToken(e)}async maySetVerifiedToken(t){if(this.verifiedToken===true)return this.verifiedToken;let e=this.opts.getDatasetAccessToken?.();if(!e)e=this.jwtByRoute["termdb"];if(this.verifedToken&&e===this.verifiedToken)return this.verifiedToken;try{const s=this.state.termdbConfig?.requiredAuth.find((t=>t.route=="termdb"));if(!s){this.verifiedToken=true;return}if(s.type==="jwt"){if(!e){delete this.verifiedToken;return}const i={[s.headerKey]:e};const r="termdb";if(!i.authorization&&this.jwtByRoute[r])i.authorization=`Bearer ${btoa(this.jwtByRoute[r])}`;const o=await n("/jwt-status",{method:"POST",headers:i,body:{dslabel:t,route:r,embedder:location.hostname}});this.verifiedToken=o.status==="ok"&&e;if(o.error){this.tokenVerificationPayload=o;throw o.error}else{this.sessionId=s.headerKey&&o[s.headerKey]||o["x-sjppds-sessionid"]||o["x-ds-access-token"];delete this.tokenVerificationMessage;delete this.tokenVerificationPayload;if(o.jwt){if(!this.jwtByDsRoute[t]){this.jwtByDsRoute[t]={};this.jwtByRoute=this.jwtByDsRoute[t]}this.jwtByDsRoute[t][o.route]=o.jwt;localStorage.setItem("jwtByDsRoute",JSON.stringify(this.jwtByDsRoute))}}}else{throw`unsupported requiredAuth='${s.type}'`}}catch(t){this.tokenVerificationMessage=t.message||t.reason||t;if(typeof t=="object")console.log(t)}}hasVerifiedToken(){return this.verifiedToken&&true}mayGetAuthHeaders(t=""){const e=this.state.termdbConfig?.requiredAuth;if(!e)return{};if(!this.verifiedToken){this.tokenVerificationMessage=`requires login for this data`;return}const s={};if(e.headerKey)s[e.headerKey]=this.verifiedToken;if(this.sessionId)s["x-sjppds-sessionid"]=this.sessionId;if(t&&this.jwtByRoute[t]){const e=this.jwtByRoute[t];s.authorization=`Bearer ${btoa(e)}`}return s}async trackDsAction({action:t,details:e}){const s={"x-sjppds-sessionid":this.sessionId};const i=this.jwtByRoute.termdb;if(i)s.authorization="Bearer "+btoa(i);await n("/authorizedActions",{method:"POST",credentials:"include",headers:s,body:Object.assign({dslabel:this.vocab.dslabel,action:t,details:e,"x-sjppds-sessionid":this.sessionId})})}getTwMinCopy(t){if(!t)return;const e={term:{},q:t.q};if(t.$id)e.$id=t.$id;if(t.term){if(h(t.term.type)){if(t.term.id)e.term.id=t.term.id;if(t.term.name)e.term.name=t.term.name;if(t.term.type)e.term.type=t.term.type;if(t.term.values)e.term.values=t.term.values;if(t.term.groupsetting)e.term.groupsetting=t.term.groupsetting}else{e.term=structuredClone(t.term);if(t.term.type=="geneVariant"){delete e.term.groupsetting}}}return e}cacheTermQ(t,e){if(!e.reuseId)throw`missing term q.reuseId for term.id='${t.id}'`;this.app.dispatch({type:"cache_termq",termId:t.id,q:e})}async uncacheTermQ(t,e){await this.app.dispatch({type:"uncache_termq",term:t,q:e})}getCustomTermQLst(t){if(t.id){const e=this.state.reuse.customTermQ.byId[t.id]||{};const s=Object.values(e).map((t=>JSON.parse(JSON.stringify(t))));for(let t=s.length+1;t<1e3;t++){const e=`Setting #${t}`;if(!s.find((t=>t.reuseId===e))){s.nextReuseId=e;break}}if(!s.nextReuseId){s.nextReuseId=btoa((+new Date).toString()).slice(10,-3)}return s}else return[]}async addCustomTerm(t){await this.app.dispatch({type:"add_customTerm",obj:t})}async deleteCustomTerm(t){await this.app.dispatch({type:"delete_customTerm",name:t})}async getCustomTerms(){if(!Array.isArray(this.state.customTerms))return[];return this.state.customTerms.map((t=>t.tw))}async addGroup(t){await this.app.dispatch({type:"add_group",obj:t})}async deleteGroup(t){await this.app.dispatch({type:"delete_group",name:t})}async getGroups(){if(!Array.isArray(this.state.groups))return[];return this.state.groups}}const L=new Set(["categorical","integer","float","condition","survival","snplst","snplocus","geneVariant","samplelst","geneExpression",m.METABOLITE_INTENSITY,m.SINGLECELL_GENE_EXPRESSION,m.SINGLECELL_CELLTYPE,m.SNP]);function J(t,e,s,i){const r=e||{};if(typeof i?.usecase?.[use.target]=="function"){return i.usecase[use.target](t,use)}const n=new Set;const o=t.child_types||[];switch(r.target){case"barchart":case"summary":if(r.detail=="term0"&&t.type=="geneVariant"){return n}if(r.detail=="term2"&&t.type=="geneVariant"&&r.term1type=="geneVariant"){return n}if(t.type&&t.type!=="survival")n.add("plot");if(B(o))n.add("branch");return n;case"matrix":if(t.type)n.add("plot");if(!t.isleaf)n.add("branch");return n;case"table":if(r.detail=="term")n.add("plot");if(o.length>1)n.add("branch");return n;case"sampleScatter":if(r.detail=="numeric"){if(p(t)){n.add("plot")}if(G(o))n.add("branch")}else{if(L.has(t.type))n.add("plot");if(!t.isleaf)n.add("branch")}return n;case"profile":if(!t.isleaf){n.add("branch");const e=t.id.split("__").length;if(e>2){n.add("plot")}}return n;case"boxplot":if(t.type=="float"||t.type=="integer")n.add("plot");if(r.detail==="term2"&&G(o))n.add("branch");return n;case"cuminc":if(r.detail=="term"){if(t.type=="condition")n.add("plot");if(o.includes("condition"))n.add("branch");return n}if(r.detail==="term2"){if(t.type&&t.type!="survival")n.add("plot");if(B(o))n.add("branch");return n}if(r.detail=="term0"){n.add("plot");return n}case"survival":if(r.detail=="term"){if(t.type=="survival")n.add("plot");if(o.includes("survival"))n.add("branch");return n}if(r.detail==="term2"){if(t.type!="survival"){if(t.type)n.add("plot");if(B(o))n.add("branch")}return n}if(r.detail=="term0"){if(t.type)n.add("plot");if(B(o))n.add("branch");return n}if(t.isleaf)n.add("plot");else n.add("branch");return n;case"regression":if(r.detail=="outcome"){if(r.regressionType=="linear"){if(t.type=="float"||t.type=="integer")n.add("plot");if(G(o))n.add("branch");return n}if(r.regressionType=="logistic"){if(t.type&&t.type!="survival")n.add("plot");if(B(o))n.add("branch");return n}else if(r.regressionType=="cox"){if(t.type=="condition"||t.type=="survival")n.add("plot");if(o.includes("condition")||o.includes("survival"))n.add("branch");return n}}if(r.detail=="independent"){if(t.type=="float"||t.type=="integer"||t.type=="categorical"||t.type=="samplelst")n.add("plot");if(U(o,["categorical","float","integer"]))n.add("branch");return n}case"filter":const e=s?.excludedTermtypeByTarget?.filter;if(e){if(L.has(t.type)&&!e.includes(t.type))n.add("plot");if(o.find((t=>!e.includes(t))))n.add("branch");return n}default:if(L.has(t.type))n.add("plot");if(!t.isleaf)n.add("branch");return n}}function B(t){if(!t.length)return false;return t.length>1||t[0]!="survival"}function G(t){return t.includes("float")||t.includes("integer")}function U(t,e){for(const s of e){if(t.includes(s))return true}}class W extends F{async getTermdbConfig(){const t=await n("termdb/config",{body:{genome:this.vocab.genome,dslabel:this.vocab.dslabel,embedder:window.location.hostname}});if(t.error)throw t.error;this.termdbConfig=t.termdbConfig||{};return this.termdbConfig}async getTermChildren(t,e){let s;const i={genome:this.vocab.genome,dslabel:this.vocab.dslabel};if(e){i.cohortValues=e.slice().sort().join(",")}if(this.state.treeFilter){i.treeFilter=this.state.treeFilter}if(t.__tree_isroot){i.default_rootterm=1;s=await n("termdb/rootterm",{body:i},this.opts.fetchOpts)}else{i.get_children=1;i.tid=t.id;s=await n("termdb/termchildren",{body:i},this.opts.fetchOpts)}if(s.error)throw s.error;for(const t of s.lst){if(t.type=="integer"||t.type=="float"){if(t.bins.rounding)t.bins.default.rounding=t.bins.rounding;if(t.bins.label_offset&&!t.bins.default.label_offset)t.bins.default.label_offset=t.bins.label_offset}}return s}async getNestedChartSeriesData(t){const[e,s]=this.getTdbDataUrl(t);const i=this.mayGetAuthHeaders("termdb");const r=await n(e,{headers:i,body:s},this.opts.fetchOpts);if(r.error)throw r.error;if(r.charts){for(const e of r.charts){this.mayFillInMissingCatValues(t.term0,e.chartId,e.total);for(const s of e.serieses){this.mayFillInMissingCatValues(t.term,s.seriesId,s.total);for(const e of s.data){this.mayFillInMissingCatValues(t.term2,e.dataId,e.total)}}}}return r}mayFillInMissingCatValues(t,e,s){if(!e)return;if(!(t?.id in this.missingCatValsByTermId))return;const i=this.missingCatValsByTermId[t.id];if(!(e in i.values)){i.values[e]={key:e,label:e};i.samplecount[e]={samplecount:0,key:e,label:e}}i.samplecount[e].samplecount+=s}getTdbDataUrl(t){const e={genome:this.vocab.genome,dslabel:this.vocab.dslabel,embedder:window.location.hostname};if(t.chartType=="cuminc")e.getcuminc=1;if(t.chartType=="survival")e.getsurvival=1;for(const s of["term0","term","term2"]){const i=this.getTwMinCopy(t[s]);if(!i)continue;const r=s=="term"?"term1":s;e[r+"_$id"]=i.$id;if("id"in i.term&&(!i.term?.type||h(i.term.type))){e[r+"_id"]=i.term.id}else{e[r]=i.term}if(!i.q)throw"plot."+s+".q{} missing: "+i.term.id;e[r+"_q"]=i.q}if(t.filter){const s=A(t.filter);if(s.lst.length){e.filter=s}}if(t.filter0)e.filter0=t.filter0;if("grade"in t)e.grade=t.grade;if("minSampleSize"in t)e.minSampleSize=t.minSampleSize;if(t.term2){const s={term1:t.term.q.hiddenValues?Object.keys(t.term.q.hiddenValues).map((e=>t.term.term.values?.[e]?.label||e)):[],term2:t.term2.q.hiddenValues?Object.keys(t.term2.q.hiddenValues).map((e=>t.term2.term.values?.[e]?.label||e)):[]};e.hiddenValues=s}if(t.get)e.get=t.get;return[t.chartType?"termdb":"termdb-barsql",e]}syncTermData(t,e,s={}){if(!e||!e.refs)return;for(const[i,r]of["term0","term","term2"].entries()){const n=t[r];const o=!s[r]||s[r].term?.id===n?.term?.id;if(n=="genotype")continue;if(!n){if(r=="term")throw`missing plot.term{}`;continue}if(e.refs.bins){n.bins=e.refs.bins[i];if(e.refs.q&&e.refs.q[i]){if(!n.q)n.q={};const t=e.refs.q[i];if(t!==n.q||!o){if(t.type!=n.q.type||t.mode!=n.q.mode){for(const t in n.q){if(t!="hiddenValues"||!o)delete n.q[t]}}Object.assign(n.q,t)}}}if(!n.q)n.q={}}}async getRegressionData(t){if(!h(t.outcome.term.type))throw"outcome must be dictionary term";const e=this.getTwMinCopy(t.outcome);e.id=e.term.id;e.q=JSON.parse(JSON.stringify(t.outcome.q));e.type=e.term.type;if(!e.q.mode&&t.regressionType=="linear")e.q.mode="continuous";const s=["mode","scale"];e.refGrp=e.q.mode=="continuous"?"NA":t.outcome.refGrp;if(e.q.mode=="continuous"){for(const t in e.q){if(!s.includes(t))delete e.q[t]}}const i={getregression:1,genome:this.vocab.genome,dslabel:this.vocab.dslabel,regressionType:t.regressionType,outcome:e,independent:t.independent.map((t=>{const e=this.getTwMinCopy(t);e.refGrp=t.refGrp;e.interactions=t.interactions;const i=JSON.parse(JSON.stringify(e.q));delete i.values;delete i.totalCount;if(e.q.mode=="continuous"){for(const t in i){if(!s.includes(t))delete i[t]}}return{id:e.term.id,q:i,term:e.term,type:e.term.type,refGrp:e.q.mode=="continuous"?"NA":e.refGrp,interactions:e.interactions||[],values:e.term.values}}))};const r=A(t.filter);if(r.lst.length)i.filter=r;const o=await n("termdb",{body:i},this.opts.fetchOpts);if(o.error)throw o.error;return o}async findTerm(t,e="",s=null,i=""){const r={genome:this.vocab.genome,dslabel:this.vocab.dslabel,findterm:encodeURIComponent(t),cohortStr:e};if(s)r.usecase=s;if(this.state.treeFilter)r.treeFilter=this.state.treeFilter;if(i)r.targetType=i;const o=await n("termdb",{body:r});if(o.error)throw o.error;const a=t.toUpperCase();const l={equals:[],startsWith:[],startsWord:[],includes:[]};for(const t of o.lst){const e=t.name.toUpperCase();if(e===a)l.equals.push(t);else if(e.startsWith(a))l.startsWith.push(t);else if(e.includes(" "+a))l.startsWord.push(t);else l.includes.push(t)}o.lst=[...l.equals,...l.startsWith,...l.startsWord,...l.includes];return o}async getTermInfo(t){if(!t)throw".getTermInfo: Missing term id";const e=["genome="+this.vocab.genome+"&dslabel="+this.vocab.dslabel+"&getterminfo=1&tid="+t];const s=await n("/termdb?"+e.join("&"),{},this.opts.fetchOpts);if(s.error)throw s.error;return s}async getCohortSampleCount(t){const e={genome:this.vocab.genome,dslabel:this.vocab.dslabel,cohort:t};const s=await n("termdb/cohort/summary",{body:e},this.opts.fetchOpts);if(!s)throw"missing data";if(s.error)throw s.error;return s[0]?.samplecount||s.count||0}async getFilteredSampleCount(t,e){const s={genome:this.vocab.genome,dslabel:this.vocab.dslabel,getsamplecount:e||"count",filter:typeof t=="string"?t:A(t)};const i=await n("termdb",{body:s},this.opts.fetchOpts);if(!i)throw`missing data`;if(i.error)throw i.error;if(e){if(!Array.isArray(i))throw"data is not array";return i}return i[0]?.samplecount||i.count||0}async getViolinPlotData(t,e={}){const s=this.mayGetAuthHeaders("termdb");t.tw=this.getTwMinCopy(t.tw);if(t.divideTw)t.divideTw=this.getTwMinCopy(t.divideTw);const i=Object.assign({genome:this.vocab.genome,dslabel:this.vocab.dslabel,embedder:window.location.hostname,devicePixelRatio:window.devicePixelRatio,isKDE:"isKDE"in t?t.isKDE:true,ticks:t.ticks,datasymbol:t.datasymbol||"rug",orientation:t.orientation||"horizontal",radius:t.radius||3,svgw:t.svgw||200,unit:t.unit||"abs"},t,e);if(i.filter)i.filter=A(i.filter);const r=await n("termdb/violin",{headers:s,body:i});return r}async getPercentile(t,e,s){if(e.find((t=>!Number.isInteger(t))))throw"non-integer percentiles found";if(Math.max(...e)>99||Math.min(...e)<1)throw"percentiles must be between 1-99";const i={getpercentile:e,tid:t,genome:this.vocab.genome,dslabel:this.vocab.dslabel};if(s){i.filter=A(s)}return await n("termdb/getpercentile",{body:i})}async getDescrStats(t,e,s){const i={tw:t,genome:this.vocab.genome,dslabel:this.vocab.dslabel};if(s)i.logScale=true;if(e){if(e.filter)i.filter=A(e.filter);if(e.filter0)i.filter0=e.filter0}return await n("/termdb/descrstats",{body:i})}async getTerms(t,e=null,s=null){if(!t)throw"getTerms: ids missing";if(!Array.isArray(t))throw`invalid ids`;const i=e||this.state.vocab?.dslabel;const r=s||this.state.vocab?.genome;if(!i)throw"getTerms: dslabel missing";if(!r)throw"getTerms: genome missing";const o={genome:r,dslabel:i,ids:t,embedder:window.location.hostname};const a=await n(`termdb/termsbyids`,{body:o});if(a.error)throw"getTerm: "+a.error;for(const t in a.terms){const e=a.terms[t];if(e.type=="categorical"&&!e.values)this.missingCatValsByTermId[e.id]=e}return a.terms}async getterm(t,e=null,s=null){if(!t)throw"getterm: termid missing";const i=await this.getTerms([t],e,s);const r=i[t];if(!r)throw"no term found for "+t;return r}graphable(t){if(!t)throw"graphable: term is missing";return J(t).has("plot")}async getCategories(t,e,s={}){const i=this.mayGetAuthHeaders();if(t.type=="snplst"||t.type=="snplocus"){const t=Object.assign({validateSnps:1,sumSamples:1,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel},s);if(e){t.filter=A(e)}return await n("/termdb",{headers:i,body:t})}if(t.category2samplecount){const e=[];for(const s in t.category2samplecount){e.push({key:s,label:t?.values?.[s]?.label||s,samplecount:t.category2samplecount[s]})}return{lst:e}}const r={term:t,q:s.term1_q||{}};delete s.term1_q;const a={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,tw:this.getTwMinCopy(r),...s};if(e){a.filter=A(e)}try{const t=await n("termdb/categories",{headers:i,body:a});if(t.error)o(t.error);return t}catch(t){window.alert(t.message||t)}}async getNumericUncomputableCategories(t,e){const s={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,tid:t.id};if(e){s.filter=A(e)}try{const t=await n("/termdb/numericcategories",{body:s});if(t.error)throw t.error;return t}catch(t){window.alert(t.message||t)}}async validateSnps(t){const e=["validateSnps=1","genome="+this.state.vocab.genome,"dslabel="+this.state.vocab.dslabel];if(t.text){e.push("snptext="+encodeURIComponent(t.text))}else if(t.chr){e.push("chr="+t.chr);e.push("start="+t.start);e.push("stop="+t.stop);if(t.variant_filter)e.push("variant_filter="+encodeURIComponent(JSON.stringify(t.variant_filter)))}return await n("/termdb?"+e.join("&"))}async get_variantFilter(){return await n("termdb",{body:{getvariantfilter:1,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel}})}async getSamplesPerFilter(t){return await n("termdb",{body:{for:"getSamplesPerFilter",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,filters:t.filters}})}async getAnnotatedSampleData(t,e={}){const s=this.mayGetAuthHeaders("termdb");if(!s)return;const i=A(t.filter);const r={};const o={byTermId:e.byTermId||{},bySampleId:e.bySampleId||{}};const a=[];const l=new Set;const c=t.isHierCluster?null:t.terms.filter((t=>t.term.type==="geneVariant")).map((t=>t.term.chr?`${t.term.chr}:${t.term.start}-${t.term.stop}`:t.term.name)).sort();const d=t.terms.slice();let p=0;if(t.loadingDiv)t.loadingDiv.html("Updating data ...");while(true){const e=z(d,t.termsPerRequest||1);if(e.length==0)break;const f={headers:s,credentials:"include",body:{for:"matrix",genome:this.vocab.genome,dslabel:this.vocab.dslabel,terms:e.map(this.getTwMinCopy),filter:i,embedder:window.location.hostname}};if(t.signal)f.signal=t.signal;if(t.filter0)f.body.filter0=t.filter0;if(t.isHierCluster)f.body.isHierCluster=true;if(this.vocab.dslabel=="GDC"&&e.find((t=>t.term.id&&(!t.term?.type||h(t.term.type))))&&c?.length){f.body.currentGeneNames=c}a.push(n("termdb",f,{cacheAs:"decoded"}).then((s=>{if(s.error)throw s.error;if(!s.refs.bySampleId)s.refs.bySampleId={};for(const t of e){for(const e in s.samples){const i=s.samples[e];if(!Object.keys(i).filter((t=>t!="sample")).length)continue;l.add(e);if(!(e in r)){if(!s.refs.bySampleId[e])s.refs.bySampleId[e]={};if(typeof s.refs.bySampleId[e]=="string")s.refs.bySampleId[e]={label:s.refs.bySampleId[e]};const t=s.refs.bySampleId[e];if(!t.label)t.label=e;const i={sample:e,_ref_:t};r[e]=i}if(t.$id in i)r[e][t.$id]=i[t.$id]}for(const t in s.refs.bySampleId){o.bySampleId[t]=s.refs.bySampleId[t]}o.byTermId[t.$id]=t;if(t.$id in s.refs.byTermId){o.byTermId[t.$id]=Object.assign({},o.byTermId[t.$id],s.refs.byTermId[t.$id])}}p++;if(t.loadingDiv)t.loadingDiv.html(`Updating data (${p}/${a.length}) ...`)})))}try{if(t.loadingDiv)t.loadingDiv.html(`Updating data (0/${a.length})`);await Promise.all(a);if(t.loadingDiv)t.loadingDiv.html("")}catch(t){if(typeof t=="string"){t.toLowerCase();if(t.includes("token")||t.includes("jwt")||t.includes("login")||t.includes("sign")||t.includes("auth")||t.includes("credential")){this.tokenVerificationMessage=t}}throw t}try{if(t.loadingDiv)t.loadingDiv.html(`Processing data ...`);const e=t.terms.filter((t=>h(t.term.type))).map((t=>t.$id));const s=[];if(!e.length){s.push(...Object.values(r))}else{for(const t in r){const i=r[t];for(const t in i){if(e.includes(t)){s.push(i);break}}}if(!s.length&&this.termdbConfig?.matrix?.settings?.displayDictRowWithNoValues){s.push(...Object.values(r))}}const i=new RegExp(t.sampleNameFilter||".*");const n={lst:s.filter((t=>l.has(t.sample)&&i.test(t.sample))),refs:o};n.samples=n.lst.reduce(((t,e)=>{t[e.sample]=e;return t}),{});for(const e of t.terms){H(e,n.lst,this.termdbConfig)}return n}catch(t){throw t}}async getTermTypes(t){const e={body:{for:"termTypes",genome:this.vocab.genome,dslabel:this.vocab.dslabel,ids:JSON.stringify(t)}};const s=await n("termdb",e,this.opts.fetchOpts);if(s.error)throw s.error;return s}async getLDdata(t,e){const s={getLDdata:1,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,ldtkname:t,m:{chr:e.chr,pos:e.pos,ref:e.ref,alt:e.alt}};return await n("termdb",{body:s})}async getScatterData(t){const e=this.mayGetAuthHeaders("termdb");const s={for:"scatter",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,plotName:t.name,coordTWs:t.coordTWs.map((t=>this.getTwMinCopy(t))),filter:A(t.filter),filter0:t.filter0,embedder:window.location.hostname};if(t.colorColumn)s.colorColumn=t.colorColumn;if(t.colorTW)s.colorTW=this.getTwMinCopy(t.colorTW);if(t.shapeTW)s.shapeTW=this.getTwMinCopy(t.shapeTW);if(t.divideByTW)s.divideByTW=this.getTwMinCopy(t.divideByTW);if(t.scaleDotTW)s.scaleDotTW=this.getTwMinCopy(t.scaleDotTW);return await n("termdb",{headers:e,body:s})}async getDefaultBins(t){const e=this.mayGetAuthHeaders("termdb");const s={for:"getDefaultBins",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,tw:t.tw,embedder:window.location.hostname};const i=this.opts?.state?.termfilter;if(i){if(i.filter)s.filter=A(i.filter);if(i.filter0)s.filter0=i.filter0}return await n("termdb",{headers:e,body:s})}async setTermBins({term:t,q:e}){const s=await this.getDefaultBins({tw:{term:t,q:e}});if("error"in s)throw s.error;t.bins=s;if(e.mode=="discrete"&&!e.type){const s=e.mode;for(const t in e){if(t!="isAtomic")delete e[t]}Object.assign(e,t.bins.default);e.mode=s}}async getSingleSampleData(t){const e=this.mayGetAuthHeaders("termdb");const s={for:"singleSampleData",sampleId:t.sampleId,term_ids:t.term_ids,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,embedder:window.location.hostname};const i=await n("termdb",{headers:e,body:s});const r={};if("error"in i)return i;for(const t of i){const e=JSON.parse(t.jsondata);r[t.term_id]={value:t.value,term:e}}return r}async getAllSamples(){const t=this.mayGetAuthHeaders("termdb");const e={for:"getAllSamples",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,embedder:window.location.hostname};const s=await n("termdb",{headers:t,body:e});return s}async getSamplesByName(t){const e=this.mayGetAuthHeaders("termb");const s={for:"getSamplesByName",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,embedder:window.location.hostname};if(t?.filter)s.filter=t.filter;const i=await n("termdb",{headers:e,body:s});return i}async getProfileFacilities(){const t=this.mayGetAuthHeaders("termb");const e={for:"getProfileFacilities",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,embedder:window.location.hostname};const s=await n("termdb",{headers:t,body:e});const i=[];for(const t of s)i.push(t.name);return i}async getLowessCurve(t){const e=this.mayGetAuthHeaders("termb");const s={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel,getLowessCurve:1,coords:t.coords};return await n("termdb",{headers:e,body:s})}async getCohortsData(t){const e={genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel};return await n("termdb/cohorts",{body:e})}async getMds3queryDetails(){return await n("termdb",{body:{for:"mds3queryDetails",genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel}})}async getMatrixByName(t){return await n("termdb",{body:{for:"matrix",getPlotDataByName:t,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel}})}async getTopMutatedGenes(t){return await n("gdc/topMutatedGenes",{method:"GET",body:t})}async getTopVariablyExpressedGenes(t){return await n("termdb/topVariablyExpressedGenes",{method:"GET",body:t})}async getTopTermsByType(t){t.genome=this.state.vocab.genome;t.dslabel=this.state.vocab.dslabel;return await n("termdb/getTopTermsByType",{method:"GET",body:t})}async getSampleImages(t){const e={};e.genome=this.state.vocab.genome;e.dslabel=this.state.vocab.dslabel;e.sampleId=t;return await n("termdb/getSampleImages",{method:"GET",body:e})}async convertSampleId(t,e){const s=new Map;const i=[];for(const r of t){const t={};i.push(t);for(const i of e){if(!("to"in i))i.to=i.from;if(!i.convert){t[i.to]=r[i.from];continue}if(!s.has(i))s.set(i,{});const e=s.get(i);const n=r[i.from];if(!e[n])e[n]=[];e[n].push({obj:t,sample:r})}}const r=[];for(const[t,e]of s){const s=Object.keys(e);r.push(await n("termdb",{body:{for:"convertSampleId",inputs:s,genome:this.state.vocab.genome,dslabel:this.state.vocab.dslabel}}).then((i=>{for(const r of s){for(const{sample:s,obj:n}of e[r]){n[t.to]=i.mapping[r]}}})))}await Promise.all(r);return i}}function H(t,e,s){if(t.term.type!="categorical"){return}if(!("$id"in t)){return}const i={};const r={};for(const s of e){if(!s[t.$id])continue;const e=s[t.$id].key;i[e]=1+(i[e]||0);r[e]={key:e,label:e}}t.term.category2samplecount=i;if(s.alwaysRefillCategoricalTermValues||!t.term.values||Object.keys(t.term.values).length==0){t.term.values=r}}function z(t,e){const s=[];let i=0,r=t.length;while(i<r){i++;const r=t.shift();if(s.find((t=>t.term.type===r.term.type&&(("id"in t.term||"id"in r.term)&&t.term.id===r.term.id||t.term.name===r.term.name)))){t.push(r)}else{s.push(r)}if(s.length>=e)break}return s}class K{constructor(t){this.Pj=t,this.opts=["@delimit","@errmode"],this.contexts=["@branch","@parent","@root","@self","@values","@key"],this.filters=["@split()","@before()","@join()","@ignore()"],this.post=["@after()","@dist()","@end()"],this.terms=[...this.opts,...this.contexts,...this.filters,...this.post]}setFxn(t,e,s,i){this[t]?s[t]=this[t](i,e,s):e.errors.push(["key","UNRECOGNIZED-RESERVED-"+t])}trueFxn(){return!0}notDefined(t){return void 0===t}}K.prototype["@split"]=function(t){const e=t.slice(1,-2),s=this.Pj.opts["="][e];if(!s)throw`missing @split() function ${e}`;this.Pj.split=s},K.prototype["@before"]=function(t,e){const s=t.slice(1,-2),i=this.Pj.opts["="][s];return i||(e.errors.push(["val","MISSING-"+e.term+"-FXN",s]),this.trueFxn)},K.prototype["@after"]=K.prototype["@before"],K.prototype["@done"]=K.prototype["@before"],K.prototype["@join"]=function(t,e,s){return(s,i)=>{let r=!0;for(const n in t){const o=t[n].slice(1,-2),a=this.Pj.opts["="][o];if(a){const t=a(s,i,n);t?this.Pj.joins.set(n,t):r=!1}else e.errors.push(["val","MISSING-@join-FXN",o])}return r}},K.prototype["@dist"]=function(t,e){const s=Array.isArray(t)?t:[t],i={};for(const t of s)i[t]=this.Pj.converter.subs["@"](this.Pj,t);return t=>{t["@dist"]=s=>{for(const r in i){const n=(0,i[r])(null,t);n?Array.isArray(n)?n.includes(s)||n.push(s):t.errors.push([e,"NON-ARRAY-DIST-TARGET",r]):t.errors.push([e,"MISSING-DIST-TARGET",r])}}}},K.prototype["@ignore"]=function(t,e,s){if(!t["@ignore()"])return e;const i=Array.isArray(t["@ignore()"])||"string"==typeof t["@ignore()"]||"object"!=typeof t["@ignore()"],r=i?{"@":t["@ignore()"]}:t["@ignore()"],n={};for(const t in r){const e=r[t];if(Array.isArray(e))n[t]=t=>e.includes(t);else if("string"==typeof e&&"="==e[0]){const i=this.Pj.opts["="][e.slice(1,-2)];i?n[t]=i:(s.errors.push(["val","MISSING-@ignore()-FXN",e]),n[t]=this.notDefined)}else s.errors.push(["val","UNSUPPORTED-@ignore()-VALUE",e]),n[t]=this.notDefined}return i?n:Object.assign({},e,n)};class Y{constructor(t){this.Pj=t,this.allowedKeyTypes=new Set(["string","number"])}getFxn(t,e){const[s,i]=this.Pj.converter.default(this.Pj,t,e,t.term);if(s)return this[i.conv](s,t)}getAllowedKeys(t,e,s,i){if(!Array.isArray(t))return i.errors.push(["key","NON-ARRAY-KEYS",e]),[];const r=[];for(const n of t)s.ignore(n)||(this.allowedKeyTypes.has(typeof n)?r.push(n):i.errors.push([s,"INVALID-RESULT-KEY",e]));return r}}Y.prototype[""]=function(t,e){return(s,i)=>this.getAllowedKeys([t(s,i)],s,e,i)},Y.prototype["()"]=Y.prototype[""],Y.prototype["[]"]=function(t,e){return(s,i)=>this.getAllowedKeys(t(s,i),s,e,i)},Y.prototype["(]"]=Y.prototype["[]"];class X{constructor(t){this.Pj=t}getFxn(t,e){return this[this.getValType(t.templateVal)+"Filler"](t,e,t.templateVal)}getValType(t){return"string"==typeof t?"str":Array.isArray(t)?"arr":t&&"object"==typeof t?"obj":"default"}strFiller(t,e,s,i){const[r,n]=this.Pj.converter.default(this.Pj,t,e,s);if(!r)return;const o=(i||n.aggr)+","+n.conv;return o in this?this[o](r,t):void 0}arrFiller(t,e,s){const i=this.getValType(s[0]);return"str"==i?this.strFiller(t,e,s[0],"[]"):"arr"==i?this["[[,]]"](s[0],t):"obj"==i?this["[{}]"](s[0],t):this.defaultFiller(t,e,s)}objFiller(t,e,s){return this.Pj.parseTemplate(s,t.inheritedIgnore,t.lineage),(t,e,i)=>{this.Pj.setResultContext("{}",e,i),this.Pj.processRow(t,s,i[e])}}defaultFiller(t,e,s){const i=JSON.stringify(s);return(t,e,s)=>{s[e]=JSON.parse(i)}}getArrSeed(t){const e=t.templateVal&&t.templateVal.length>1?t.templateVal[1]:1;if("set"==e)return(t,e,s)=>{e in t?Array.isArray(t[e])&&(t[e]=new Set(t[e])):t[e]=new Set,t[e].add(s)};if(0==e)return(t,e,s)=>{e in t||(t[e]=[]),t[e].push(s)};if(this.isNumeric(e)){const t=new Map;return(s,i,r)=>{i in s||(s[i]=[]),t.has(s[i])||t.set(s[i],new Map);const n=t.get(s[i]);n.has(r)||n.set(r,0);const o=n.get(r);o<e&&(s[i].push(r),n.set(r,o+1))}}}isNumeric(t){return!isNaN(parseFloat(t))&&isFinite(t)&&""!==t}}X.prototype[","]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);e.ignore(o,i,s)||(r[i]=o)}},X.prototype[",()"]=X.prototype[","],X.prototype[",[]"]=X.prototype[","],X.prototype[",(]"]=X.prototype[","],X.prototype["[],"]=function(t,e){const s=this.getArrSeed(e);if(s)return(i,r,n,o)=>{const a=t(i,o);e.ignore(a,r,i,o)||s(n,r,a)};e.errors.push(["val","INVALID-[]-OPTION"])},X.prototype["[],()"]=X.prototype["[],"],X.prototype["[],[]"]=function(t,e){const s=this.getArrSeed(e);return(i,r,n,o)=>{const a=t(i,o);if(Array.isArray(a))for(const t of a)e.ignore(t,r,i,o)||s(n,r,t);else o.errors.push([e,"NON-ARRAY-VALS",i])}},X.prototype["[],(]"]=X.prototype["[],[]"],X.prototype["[{}]"]=function(t,e){this.Pj.parseTemplate(t,e.inheritedIgnore,e.lineage);const s=e.templateVal&&e.templateVal.length>1?e.templateVal[1]:"";if(!s)return(e,s,i)=>{this.Pj.setResultContext("[]",s,i);const r=this.Pj.setResultContext("{}",i[s].length,i[s]);this.Pj.processRow(e,t,r)};if("string"==typeof s){const[i,r]=this.Pj.converter.default(this.Pj,Object.assign({},{templateVal:s}),e.inheritedIgnore,s);return r.aggr||r.skip||r.timing?void e.errors.push(["val","INVALID-[{}]-OPTION-TOKEN"]):(r,n,o,a)=>{const l=this.Pj.setResultContext("[]",n,o,!0),c=this.Pj.contexts.get(l).tracker,d=i(r,a),p="]"==s.slice(-1)?d:[d];if(Array.isArray(p))for(const e of p)if(c.has(e))this.Pj.processRow(r,t,c.get(e));else{const s=this.Pj.setResultContext("{}",l.length,l,!1,e,r,t);s&&(c.set(e,s),this.Pj.processRow(r,t,s))}else a.errors.push([e,"NON-ARRAY-VALS",r])}}e.errors.push(["val","INVALID-[{}]-OPTION"])},X.prototype["[[,]]"]=function(t,e){const s=[];for(const i of t){const t=Object.assign({},e,{templateVal:i});s.push(this.getFxn(t,e.inheritedIgnore))}return"map"!=(e.templateVal[1]?e.templateVal[1]:"")?(t,e,i)=>{e in i||(i[e]=[]);const r=[];for(const e in s)s[+e](t,+e,r);i[e].push(r)}:(t,e,i)=>{e in i?i[e]instanceof Map||(i[e]=new Map(i[e])):i[e]=new Map;const r=[];s[0](t,0,r),i[e].has(r[0])&&(r[1]=i[e].get(r[0])),s[1](t,1,r),i[e].set(r[0],r[1])}},X.prototype["+,"]=function(t,e){return(s,i,r,n)=>{i in r||(r[i]=0);const o=t(s,n);e.ignore(o,i,s,n)||(this.isNumeric(o)?r[i]+=+o:n.errors.push([e,"NON-NUMERIC-INCREMENT",s]))}},X.prototype["+,()"]=X.prototype["+,"],X.prototype["+,[]"]=function(t,e){return(s,i,r,n)=>{i in r||(r[i]=0);const o=t(s,n);if(Array.isArray(o))for(const t of o)e.ignore(t,i,s,n)||(this.isNumeric(t)?r[i]+=+t:n.errors.push([e,"NON-NUMERIC-INCREMENT",s]));else e.errors.push(["val","NON-ARRAY-VALS",s])}},X.prototype["+,(]"]=X.prototype["+,[]"],X.prototype["-,"]=function(t,e){return(s,i,r,n)=>{i in r||(r[i]=0);const o=t(s,n);e.ignore(o,i,s,n)||(this.isNumeric(o)?r[i]+=-o:n.errors.push([e,"NON-NUMERIC-DECREMENT",s]))}},X.prototype["-,()"]=X.prototype["-,"],X.prototype["-,[]"]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);if(Array.isArray(o)){i in r||(r[i]=0);for(const t of o)e.ignore(t,i,s,n)||(r[i]+=-t)}else e.errors.push(["val","NON-ARRAY-VALS",s])}},X.prototype["-,(]"]=X.prototype["-,[]"],X.prototype["<,"]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);if(e.ignore(o,i,s,n))return;const a=+o;this.isNumeric(a)?i in r?r[i]<a&&(r[i]=a):r[i]=a:n.errors.push([e,"NON-NUMERIC-THAN",s])}},X.prototype["<,()"]=X.prototype["<,"],X.prototype["<,[]"]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);if(Array.isArray(o))for(const t of o){if(e.ignore(t,i,s,n))return;if(!this.isNumeric(t))return void n.errors.push([e,"NON-NUMERIC-THAN",s]);const o=+t;i in r?r[i]<o&&(r[i]=o):r[i]=o}else e.errors.push(["val","NON-ARRAY-VALS",s])}},X.prototype["<,(]"]=X.prototype["<,[]"],X.prototype[">,"]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);e.ignore(o,i,s,n)||(this.isNumeric(o)?i in r?r[i]>o&&(r[i]=o):r[i]=o:n.errors.push([e,"NON-NUMERIC-THAN",s]))}},X.prototype[">,()"]=X.prototype[">,"],X.prototype[">,[]"]=function(t,e){return(s,i,r,n)=>{const o=t(s,n);if(Array.isArray(o))for(const t of o){if(e.ignore(t,i,s,n))return;if(!this.isNumeric(t))return void n.errors.push([e,"NON-NUMERIC-THAN",s]);const o=+t;i in r?r[i]>o&&(r[i]=o):r[i]=o}else e.errors.push(["val","NON-ARRAY-VALS",s])}},X.prototype[">,(]"]=X.prototype[">,[]"];class Q{constructor(t){this.Pj=t,this.allErrSet=new Set,this.allErrObj=Object.create(null),this.mode={input:"{}",result:"{}-",root:"",console:"{}"},this.modeKeys=["input","result","root","console"],this.setMode()}setMode(t={}){Array.isArray(t)?this.modeKeys.forEach(((e,s)=>this.mode[e]=t[s])):"object"==typeof t&&this.modeKeys.forEach((e=>{e in t&&(this.mode[e]=t[e])}))}clear(t={}){this.allErrSet.clear(),this.allErrObj=Object.create(null),this.setMode(t)}markErrors(t,e){if(!e)return;const s="[]"==this.mode.result.slice(0,2)?[]:{};for(const i in e.filler.inputs){const r=e.filler.inputs[i];for(const e of r.errors){const[i,n,o]=e;"key"==i?(this.track(s,e,r.lineage.join(this.Pj.delimit)),this.mode.input&&(t["{{ "+n+" }} "+r.term]=r.templateVal)):"val"==i&&(Array.isArray(r.templateVal)?(this.track(s,e,r.templateVal[0]),this.mode.input&&(t[r.term]=["{{ "+n+" }} ",...r.templateVal])):"string"==typeof r.templateVal?(this.track(s,e,r.templateVal),this.mode.input&&(t[r.term]="{{ "+n+" }} "+r.templateVal)):(this.track(s,e,r.templateVal),this.mode.input&&(t[r.term]="{{ "+n+" }} ")))}}if(e.errors.length){const i={};t["@errors"]=i;for(const t of e.errors){const[e,r,n]=t;if(this.track(s,t,e.term),!this.mode.input)continue;const o="{{ "+r+" }} "+e.term;o in i||(i[o]=0),i[o]+=1}}if(e.filler.errors.length)for(const t of e.filler.errors)this.track(s,t,t[2],!1);Object.keys(s).length&&this.mode.result&&(t["@errors"]=s)}track(t,e,s,i=!0){this.allErrSet.add(e),this.trackAsObj(this.allErrObj,e,s),i&&"-"==this.mode.result.slice(-1)||(Array.isArray(t)?t.push(e):this.trackAsObj(t,e,s))}trackAsObj(t,e,s){const[i,r,n]=e;r in t||(t[r]=Object.create(null)),s in t[r]||(t[r][s]=n?[]:0),n?t[r][s].includes(n)||t[r][s].push(n):t[r][s]+=1}log(){const t=[...this.allErrSet];if(t.length){if(this.mode.root){const e=this.mode.root;this.Pj.tree["@errorsAll"]="[]"==e?t:this.allErrObj}if(this.mode.console){const e=this.mode.console.slice(0,2);console.log("[]"==e?t:this.allErrObj)}}}}function Z(t,e){const s=t.skipSymbols.includes(e[0])?e[0]:"",i=e.slice(s.length,s.length+3),r=t.timeSymbols.includes(i)?i:"",n=s.length+r.length,o=e[n],a=e.slice(-2),l=t.aggrSymbols.includes(o)&&o!=e?o:"",c=t.convSymbols.includes(a)&&a!=e?a:"",d=l&&c?e.slice(n+1,-2):l?e.slice(n+1):c?e.slice(n,-2):s||r?e.slice(n):e,p=t.subsSymbols.includes(d[0])?d[0]:"",f=l+p+c,h=p?d.slice(1):d;return[d,f,{skip:s,time:r,aggr:l,subs:p,stem:h,conv:c,subterm:d},t.steps.indexOf(r)]}const tt={"#":function(t,e,s){t.commentedTerms.has(s)||t.commentedTerms.set(s,[]),t.commentedTerms.get(s).push(e)},"*":function(t,e,s){t.focusTemplate[s.term.slice(1)]=s.templateVal},"":function(t,e,s){return t.valFiller.isNumeric(e)?()=>+e:()=>e},$:function(t,e,s){if("$"==e||e=="$"+t.delimit)return t=>t;if(e.includes(t.delimit)){const s=e.slice(1).split(t.delimit);""==s[0]&&s.shift();const i=(t,e)=>t?t[e]:void 0;return t=>s.reduce(i,t)}{const t=e.slice(1);return e=>e[t]}},"=":function(t,e,s){const i=e.slice(1).split(t.delimit).reduce(((t,e)=>t&&e in t?t[e]:void 0),t.opts["="]);if(i)return t=>i;s.errors.push(["val","MISSING-EXTERNAL-SUBS"])},"@":function(t,e,s){if(!t.reserved.opts.includes(e)){if("@"==e||e=="@"+t.delimit)return(t,e)=>e.self;if(e.includes(t.delimit)){const i=e.split(t.delimit),r=(i,r)=>{if("@"==r[0]&&r.length>1&&!t.reserved.contexts.includes(r))return s.errors.push(["val","UNRECOGNIZED-CONTEXT-"+e,s.lineage.join(".")+"."+r]),[null,null];const[n,o]=i;return n&&r?"@"==r?[o.self,o]:"@values"==r?[Object.values(n),o]:"@"==r[0]?[o[r.slice(1)],t.contexts.get(o[r.slice(1)])]:[n[r],t.contexts.get(n[r])]:[null,null]};return(t,e)=>i.reduce(r,[e.self,e])[0]}if(t.reserved.contexts.includes(e)){const t=e.slice(1);return(e,s)=>s[t]}s.errors.push(["val","UNRECOGNIZED-CONTEXT-"+e])}},"&":function(t,e,s){const i=e.slice(1).split(t.delimit),r=i.shift();if(i.length){if(1==i.length){const e=i[0];return()=>{const s=t.joins.get(r);return s?s[e]:null}}{const e=(t,e)=>t?t[e]:null;t.joins.get(r);return s=>i.reduce(e,t.joins.get(r))}}return()=>t.joins.get(r)}},et={"":function(t,e,s){return t},"()":function(t,e,s){if("="==s.subs){const i=t();return"function"!=typeof i?void e.errors.push(["val","NOT-A-FUNCTION",s.subs+s.term+s.conv]):i}return(s,i)=>{const r=t(s,i);if("function"==typeof r)return r(s,i);e.errors.push(["val","NOT-A-FUNCTION",s])}}};et["[]"]=et[""],et["(]"]=et["()"];var st=Object.freeze({__proto__:null,default:function(t,e,s,i){const[r,n,o]=Z(t,i);if(t.reserved.opts.includes(r))return[];const a=r+o.conv;if(e.ignore=a in s?s[a]:s["@"],o.skip&&"~"!=o.skip)return tt[o.skip](t,r,e),[];if(o.subs in tt){const s=tt[o.subs](t,r,e);return s?[et[o.conv](s,e,o),o]:[]}return e.errors.push(["val","UNSUPPORTED-SYMBOL-"+o.subs]),[]},parseTerm:Z,subs:tt,conv:et});class it{constructor(t={}){this.defaultOpts={template:{},seed:"{}","=":{}},this.opts=Object.assign(this.defaultOpts,t),this.delimit=".",this.subsSymbols=["$","=","@","&"],this.convSymbols=["()","[]","(]"],this.aggrSymbols=["+","-","<",">"],this.timePost=["_0:","_1:","_2:","_3:","_4:","_5:","_6:","_7:","_8:","_9:"],this.timeSymbols=[":__","_:_","__:",...this.timePost],this.skipSymbols=["#","*","~"],this.steps=[":__","","_:_"],this.errors=new Q(this),this.reserved=new K(this),this.keyFiller=new Y(this),this.valFiller=new X(this),this.commentedTerms=new Map,this.joins=new Map,this.fillers=new Map,this.contexts=new Map,this.temps=new Map,this.refresh()}refresh(t={}){this.times={start:+new Date},Object.assign(this.opts,t),"string"!=typeof this.opts.template&&(this.opts.template=JSON.stringify(this.opts.template));const e=JSON.parse(this.opts.template);this.errors.clear(e["@errmode"]),e["@delimit"]&&(this.delimit=e["@delimit"]),this.commentedTerms.clear(),this.joins.clear(),this.fillers.clear(),this.contexts.clear(),this.temps.clear(),delete this.tree,this.tree=this.setResultContext(this.opts.seed),this.focusTemplate=Object.create(null),this.parseTemplate(e,{"@":this.reserved.notDefined}),this.times.parse=+new Date-this.times.start,Object.keys(this.focusTemplate).length?(this.parseTemplate(this.focusTemplate,{"@":this.reserved.notDefined}),this.template=this.focusTemplate):this.template=e,this.postLoopTerms=Object.create(null),this.done=[],this.opts.data&&this.add(this.opts.data,!1),this.errors.log(this.fillers)}setResultContext(t,e=null,s=null,i=!1,r,n=null,o=null){const a=null!==e&&e in s?s[e]:JSON.parse(t);if(this.contexts.has(a))return a;const l={branch:e,parent:s,context:this.contexts.get(s),self:a,root:this.tree?this.tree:a,joins:this.joins,errors:[],key:r};if(i&&(l.tracker=new Map),n&&o){const t=this.fillers.get(o);if(!t["@before"](n,l))return;if(t["@join"]&&!t["@join"](n,l))return}return this.contexts.set(a,l),null!==e&&(s[e]=a),a}parseTemplate(t,e,s=[]){const i=Object.create(null);i.inputs=Object.create(null),i["@before"]=this.reserved.trueFxn,i["@after"]=this.reserved.trueFxn,i.postTerms={},i.errors=[];const r=this.reserved["@ignore"](t,e,i);i["@ignore"]=r,this.fillers.set(t,i);const n=this.steps.map((t=>[]));for(const e in t){const[o,a,l,c]=Z(this,e),d=t[e],p=i.inputs[e]={term:e,subterm:o,symbols:a,keyTokens:l,templateVal:d,lineage:[...s,e],inheritedIgnore:r,errors:[]};"@()"==a?this.reserved.setFxn(o,p,i,d):(p.keyFxn=this.keyFiller.getFxn(p,r),p.keyFxn&&(p.valFxn=this.valFiller.getFxn(p,r),"__:"==l.time||this.timePost.includes(l.time)?(i.postTerms[l.time]||(i.postTerms[l.time]=[]),i.postTerms[l.time].includes(e)||i.postTerms[l.time].push(e)):n[c].push(e)))}i.steps=n.filter((t=>t.length))}add(t,e=!0){this.times.start||(this.times.start=+new Date),e&&this.errors.clear(),this.joins.clear();for(const e of t)if(this.split)for(const t of this.split(e))this.processRow(t,this.template,this.tree),this.joins.clear();else this.processRow(e,this.template,this.tree),this.joins.clear();this.processResult(this.tree);for(const t of this.timePost)if(this.postLoopTerms[t])for(const e of this.postLoopTerms[t])this.postLoop(e.self,e,t);for(const t of this.done)t.done(t.self,t);for(const[t,e]of this.temps)for(const s of e)delete t[s];this.times.total=+new Date-this.times.start,delete this.times.start,e&&this.errors.log()}processRow(t,e,s){const i=this.contexts.get(s),r=this.fillers.get(e);if(i.filler=r,r["@before"](t,i)&&(!r["@join"]||r["@join"](t,i))){for(const e of r.steps)for(const n of e){const e=r.inputs[n];if(e.keyFxn&&e.valFxn){const r=e.keyFxn(t,i);for(const n of r)e.valFxn(t,n,s,i),"~"==e.keyTokens.skip&&(this.temps.has(s)||this.temps.set(s,new Set),this.temps.get(s).add(n))}}r["@after"](t,i),r["@dist"]&&r["@dist"](i),r["@done"]&&!this.done.includes(i)&&(i.done=r["@done"],this.done.push(i));for(const t in r.postTerms)this.postLoopTerms[t]||(this.postLoopTerms[t]=[]),this.postLoopTerms[t].includes(i)||this.postLoopTerms[t].push(i);return!0}}postLoop(t,e,s="__:"){if(e&&e.filler&&e.filler.postTerms[s])for(const i of e.filler.postTerms[s]){const s=e.filler.inputs[i];if(s.keyFxn&&s.valFxn){const i=s.keyFxn(null,e);for(const r of i)s.valFxn(null,r,t,e)}}}processResult(t){const e=this.contexts.get(t);this.postLoop(t,e,"__:");for(const e in t){const s=t[e];if(s)if(Array.isArray(s)||s instanceof Set||s instanceof Map)for(const t of s)"object"==typeof t&&this.processResult(t);else if("object"==typeof s){const t=this.contexts.get(s);t&&t["@dist"]&&t["@dist"](s),this.processResult(s)}}e&&e.filler&&this.errors.markErrors(t,e)}copyResult(t,e={}){if(arguments.length&&void 0===t)return;const s=arguments.length?t:this.tree;for(const t in s){const i=s[t];if(i instanceof Set||i instanceof Map)e[t]=[...i];else if(Array.isArray(i)){e[t]=[];for(const s of i)if(Array.isArray(s)){const i=[];e[t].push(i),this.copyResult(s,i)}else if(s&&"object"==typeof s){const i=Object.create(null);e[t].push(i),this.copyResult(s,i)}else e[t]=JSON.parse(JSON.stringify(i))}else i&&"object"==typeof i?(e[t]=Object.create(null),this.copyResult(i,e[t])):e[t]=JSON.parse(JSON.stringify(i))}return e}}it.prototype.converter=st;function rt(t,e,s){const i=!e?[]:e.type=="tvslst"?e.lst:[e];let r=0;for(const n of i){if(n.type=="tvslst"){if(rt(t,n)){r++}}else{const e=n.tvs;let i;if(e.term.type=="geneVariant"){i=s.map((e=>t[e])).filter((t=>t))}else if(e.term.type=="integer"||e.term.type=="float"||e.term.type==m.GENE_EXPRESSION||e.term.type==m.METABOLITE_INTENSITY){i=t[e.term.id]||t[e.term.$id]?.key}else if(e.term.type=="survival"){i=t[e.term.$id]?.key}else{i=t[e.term.id]||t[e.term.$id]?.value}let o;if(e.term.type=="categorical"){if(i===undefined){if(e.isnot)o=!o;if(o)r++;continue}const t=e.valueset?e.valueset:new Set(e.values.map((t=>t.key)));o=t.has(i)}else if(e.term.type=="integer"||e.term.type=="float"||e.term.type==m.GENE_EXPRESSION||e.term.type==m.METABOLITE_INTENSITY){if(i===undefined){if(e.isnot)o=!o;if(o)r++;continue}for(const t of e.ranges){if("value"in t){o=i===t.value;if(o)break}else if(i==t.name){o=true;break}else{if(e.term.values){const t=e.term.values[i.toString()];if(t&&t.uncomputable){continue}}let s,r;if(t.startunbounded){s=true}else if("start"in t){if(t.startinclusive){s=i>=t.start}else{s=i>t.start}}if(t.stopunbounded){r=true}else if("stop"in t){if(t.stopinclusive){r=i<=t.stop}else{r=i<t.stop}}o=s&&r}if(o)break}}else if(e.term.type=="condition"){const t=getPrecomputedKey(e);const s=i&&i[t];if(s){o=Array.isArray(s)?e.values.find((t=>s.includes(t.key))):e.values.find((t=>t.key==s))}}else if(e.term.type=="survival"){if(i===undefined){if(e.isnot)o=!o;if(o)r++;continue}const t=e.valueset?e.valueset:new Set(e.values.map((t=>t.key)));o=t.has(i)}else if(e.term.type=="geneVariant"&&e.legendFilterType=="geneVariant_hard"){const t=e.values[0];o=i.find((e=>{for(const s of e.values){if(s.dt==t.dt&&(!s.origin||s.origin==t.origin)&&t.mclasslst.includes(s.class))return true}}))&&true}else if(e.term.type==m.SINGLECELL_GENE_EXPRESSION);else{throw"unknown term type"}if(e.isnot){o=!o}if(o)r++}if(e.join=="or"&&r)return true}if(r==i.length)return true}function nt(t,e){const s=JSON.parse(JSON.stringify(t));if(!s.term1)s.term1=s.term?s.term:{};if(!s.term1_q)s.term1_q={};if(!s.term0)s.term0={};if(!s.term0_q)s.term0_q={};if(!s.term2)s.term2={};if(!s.term2_q)s.term2_q={};if(!s.filter)s.filter={type:"tvslst",join:"",lst:[]};const i=at(s,e);return i.tree.results}const ot=JSON.stringify({"@before()":"=prep()","@join()":{idVal:"=idVal()"},results:{"_2:maxAcrossCharts":"=maxAcrossCharts()",charts:[{chartId:"@key",total:"+1","_1:maxSeriesTotal":"=maxSeriesTotal()","@done()":"=filterEmptySeries()",serieses:[{total:"+1",seriesId:"@key",max:"<&idVal.dataVal","~values":["&idVal.dataVal",0],"~sum":"+&idVal.dataVal","__:boxplot":"=boxplot()","~samples":["$sample","set"],data:[{dataId:"@key",total:"+1"},"&idVal.dataId[]"]},"&idVal.seriesId[]"]},"&idVal.chartId[]"],"~sum":"+&idVal.seriesVal","~values":["&idVal.seriesVal",0],"__:boxplot":"=boxplot()",refs:{cols:["&idVal.seriesId[]"],colgrps:["-"],rows:["&idVal.dataId[]"],rowgrps:["-"],col2name:{"&idVal.seriesId[]":{name:"@branch",grp:"-"}},row2name:{"&idVal.dataId[]":{name:"@branch",grp:"-"}},"__:useColOrder":"=useColOrder()","__:useRowOrder":"=useRowOrder()","__:bins":"=bins()","@done()":"=sortColsRows()"},"@done()":"=sortCharts()"}});function at(t,e){const s={categorical:lt,integer:ct,float:ct,undefined:dt};return new it({data:e,seed:`{"values": []}`,template:ot,"=":{idVal(i,r){const[n,o]=s[t.term0.type](i.data,t.term0,t.term0_q,e);const[a,l]=s[t.term1.type](i.data,t.term1,t.term1_q,e);const[c,d]=s[t.term2.type](i.data,t.term2,t.term2_q,e);return{chartId:n,chartVal:o,seriesId:a,seriesVal:l,dataId:c,dataVal:d}},prep(e){return rt(e.data,t.filter)},maxSeriesTotal(t,e){let s=0;for(const t of e.self.serieses){if(t&&t.total>s){s=t.total}}return s},maxAcrossCharts(t,e){let s=0;for(const t of e.self.charts){if(t.maxSeriesTotal>s){s=t.maxSeriesTotal}}return s},boxplot(t,e){if(!e.self.values||!e.self.values.length)return;const s=e.self.values.filter((t=>t!==null&&!isNaN(t)));if(!s.length)return;s.sort(((t,e)=>t-e));const i=pt(s.map((t=>({value:+t}))));i.mean=e.self.sum/s.length;let r=0;for(const t of s){r+=Math.pow(t-i.mean,2)}i.sd=Math.sqrt(r/(s.length-1));if(isNaN(i.sd))i.sd=null;return i},numSamples(t,e){return e.self.samples.size},filterEmptySeries(t){const e=t.serieses.filter((t=>t.total));t.serieses.splice(0,t.serieses.length,...e)},sortColsRows(e){if(t.term1_q.orderedLabels){const s=t.term1_q.orderedLabels;e.cols.sort(((t,e)=>s.indexOf(t)-s.indexOf(e)))}if(t.term2.orderedLabels){const s=t.term2_q.orderedLabels;e.rows.sort(((t,e)=>s.indexOf(t)-s.indexOf(e)))}},sortCharts(t){},useColOrder(){return t.term1_q.orderedLabels&&t.term1_q.orderedLabels.length>0},useRowOrder(){return t.term2_q.orderedLabels&&t.term2_q.orderedLabels.length>0},bins(){return[t.term0_q,t.term1_q,t.term2_q].map((t=>t.computed_bins))},q(){}}})}function lt(t,e){const s="id"in e?t[e.id]:"-";const i="id"in e&&a(t[e.id])?+t[e.id]:0;return[[s],i]}function ct(t,e,s,i){if(!("id"in e)||!(e.id in t))return[[],undefined];if(!s.computed_bins){const t={};i.map((s=>{if(!a(s.data[e.id]))return;const i=+s.data[e.id];if(!("min"in t)||t.min>i)t.min=i;if(!("max"in t)||t.max<i)t.max=i}));s.computed_bins=y(s,(e=>t));s.orderedLabels=s.computed_bins.map((t=>t.label))}const r=t[e.id];if(e.values&&r in e.values&&e.values[r].uncomputable){return[[e.values[r].label],undefined]}if(a(t[e.id])){const t=[];for(const e of s.computed_bins){if(e.startunbounded){if(r<e.stop){t.push(e.label)}else if(e.stopinclusive&&r===e.stop){t.push(e.label)}}else if(e.stopunbounded){if(r>e.start){t.push(e.label)}else if(e.stopinclusive&&r===e.start){t.push(e.label)}}else if((r>e.start||r===e.start&&e.startinclusive)&&(r<e.stop||r===e.stop&&e.stopinclusive)){t.push(e.label)}if(t.length)break}return[t,r]}return[[],undefined]}function dt(){return[["-"],undefined]}function pt(t){const e=t.length;if(e<5){return{out:t}}const s=t[Math.floor(e/2)].value;const i=t[Math.floor(e/4)].value;const r=t[Math.floor(e*3/4)].value;const n=t[Math.floor(e*.05)].value;const o=t[Math.floor(e*.95)].value;t[Math.floor(e*.01)].value;const a=r-i;let l,c;if(a==0){l=0;c=0}else{const s=t.findIndex((t=>t.value>i-a*1.5));l=t[s==-1?0:s].value;const n=t.findIndex((t=>t.value>r+a*1.5));c=t[n==-1?e-1:Math.max(0,n-1)].value}const d=t.filter((t=>t.value<i-a*1.5||t.value>r+a*1.5));return{w1:l,w2:c,p05:n,p25:i,p50:s,p75:r,p95:o,iqr:a,out:d}}function ft(t,e){if(!e||!e.length){return{lst:Object.keys(t.term.values).map((e=>({key:e,label:t.term.values[e].label,value:e})))}}const s=new it({data:e,template:JSON.stringify({"@before()":"=prep()","@join()":{idVal:"=idVal()"},results:{"&idVal.id":{samplecount:"+1",":__key":"&idVal.id",":__label":"&idVal.id",":__value":"&idVal.id"}}}),"=":{prep(e){return rt(e.data,t.filter)},idVal(e,s){const[i,r]=lt(e.data,t.term);return{id:i[0],value:r}}}});return{lst:Object.values(s.tree.results)}}var ht=Object.freeze({__proto__:null,getBarchartData:nt,getCategoryData:ft});function mt(t,e){t.sort(((t,e)=>t-e));const s=Math.abs(e/100*t.length-1);const i=Number.isInteger(s)?(t[s]+t[s+1])/2:t[Math.ceil(s)];return i}class ut extends F{constructor(t){super(t);this.datarows=[];if(t.state.vocab.sampleannotation){const e=t.state.vocab.sampleannotation;Object.keys(e).forEach((t=>this.datarows.push({sample:t,data:e[t]})))}}getTermdbConfig(){return{selectCohort:this.vocab.selectCohort,supportedChartTypes:[]}}getTermChildren(t,e){const s=(e||[]).slice().sort().join(",");const i=t.__tree_isroot?null:t.id;return{lst:this.vocab.terms.filter((t=>t.parent_id===i&&(!s.length||s===t.cohortValues.slice().sort.join(","))))}}async getNestedChartSeriesData(t){const e={term1:t.term?t.term.term:{},term1_q:t.term?t.term.q:undefined,term0:t.term0?t.term0.term:undefined,term0_q:t.term0?t.term0.q:undefined,term2:t.term2?t.term2.term:undefined,term2_q:t.term2?t.term2.q:undefined,filter:this.state.termfilter&&this.state.termfilter.filter};return nt(e,this.datarows)}syncTermData(t,e,s={}){if(!e||!e.refs)return;for(const[s,i]of["term0","term","term2"].entries()){const r=t[i];if(r=="genotype")return;if(!r){if(i=="term")throw`missing plot.term{}`;return}if(e.refs.bins){r.bins=e.refs.bins[s];if(e.refs.q&&e.refs.q[s]){if(!r.q)r.q={};const t=e.refs.q[s];if(t!==r.q){for(const t in r.q)delete r.q[t];Object.assign(r.q,t)}}}if(!r.q)r.q={}}}async findTerm(t,e,s=null){return{lst:this.vocab.terms.filter((s=>s.name.includes(t)&&(!e||e===s.cohortValues.slice().sort.join(","))))}}async getTermInfo(e){const s=this.vocab.find((t=>t.id===e));if(!s)return undefined;return{terminfo:t.info}}async getCohortSampleCount(t){if(!t)return;const e=this.vocab.find((t=>t.id===id));if(!e||!e.cohortValues.includes(t))return;if(!e.samplecount)e.samplecount={};if(!(t in e.samplecount)){e.samplecount[t]=Object.keys(this.vocab.sampleannotation).length}return{samplecount:e.samplecount[t]}}async getCohortsData(t){return null}async getFilteredSampleCount(t){return"TBD"}async getDensityPlotData(t,e,s){if(!this.datarows||!this.datarows.length){const e=this.vocab.terms.find((e=>e.id===t));e.range&&e.range;return{minvalue:e.range&&e.range.start,maxvalue:e.range&&e.range.stop}}const i=[];const r=new Set;let n,o,c=0;let d={};for(const t of this.datarows){if(d[t.sample])continue;const e=t.s||t.data;if(e&&rt(e,s)){d[t.sample]=this.vocab.sampleannotation[t.sample]}}for(const e in d){if(!(t in this.vocab.sampleannotation[e]))continue;const s=this.vocab.sampleannotation[e][t];if(a(s)){const t=+s;c+=1;if(n===undefined||t<n)n=t;if(o===undefined||t>o)o=t;i.push(t);r.add(t)}}const p=this.vocab.terms.find((e=>e.id==t));const f=40;const h=p.type=="integer"&&o-n<f?o-n:p.type=="float"&&r.size<f?r:f;const m=l().domain([n,o]).range([e.plot_size.xpad,e.plot_size.width-e.plot_size.xpad]);const u=yt(m.ticks(h))(i);return{density:u,densitymax:u.reduce(((t,e,s)=>s===0||e[1]>t?e[1]:t),0),minvalue:n,maxvalue:o,samplecount:c}}async getPercentile(t,e,s){if(e.find((t=>!Number.isInteger(t))))throw"non-integer percentiles found";if(Math.max(...e)>99||Math.min(...e)<1)throw"percentiles must be between 1-99";const i=[];const r=[];const n={};for(const t of this.datarows){if(n[t.sample])continue;const e=t.s||t.data;if(e&&rt(e,s)){n[t.sample]=this.vocab.sampleannotation[t.sample]}}for(const e in n){if(!(t in this.vocab.sampleannotation[e]))continue;const s=Number(this.vocab.sampleannotation[e][t]);if(!Number.isFinite(s))throw"non-numeric value";r.push(s)}r.sort(((t,e)=>t-e));for(const t of e){const e=Math.abs(t/100*r.length-1);const s=Number.isInteger(e)?(r[e]+r[e+1])/2:r[Math.ceil(e)];i.push(s)}return{values:i}}async getDescrStats(t,e,s){const i=[];const r={};for(const t of this.datarows){if(r[t.sample])continue;const s=t.s||t.data;if(s&&rt(s,e)){r[t.sample]=this.vocab.sampleannotation[t.sample]}}for(const e in r){if(!(t in this.vocab.sampleannotation[e]))continue;const s=Number(this.vocab.sampleannotation[e][t]);if(!Number.isFinite(s))throw"non-numeric value";i.push(s)}i.sort(((t,e)=>t-e));const n=i.length;const o=i.reduce(((t,e)=>t+e),0);const a=o/n;const l=mt(i,25);const c=mt(i,50);const d=mt(i,75);const p=i.map((t=>(t-a)**2)).reduce(((t,e)=>t+e),0);const f=p/(i.length-1);const h=Math.sqrt(f);const m=Math.min(...i);const y=Math.max(...i);return{values:[{id:"total",label:"n",value:n},{id:"min",label:"Minimum",value:u(m,2)},{id:"p25",label:"1st quartile",value:u(l,2)},{id:"median",label:"Median",value:u(c,2)},{id:"mean",label:"Mean",value:u(a,2)},{id:"p75",label:"3rd quartile",value:u(d,2)},{id:"max",label:"Maximum",value:u(y,2)},{id:"sd",label:"Standard deviation",value:u(h,2)}]}}async getTerms(t,e=null,s=null){if(!t)throw"getTerms: ids missing";if(!Array.isArray(t))throw`invalid ids`;const i={};for(const e of t){const t=this.vocab.terms.find((t=>t.id===e));if(t)i[e]=t}return i}async getterm(t){if(!t)throw"getterm: termid missing";return this.vocab.terms.find((e=>e.id==t))}async getCategories(t,e,s=null){const i={term:t,filter:e};const r=ft(i,this.datarows);return r}getNumericUncomputableCategories(t,e){throw"to be implemented!! getNumericUncomputableCategories"}graphable(t){if(!t)throw"graphable: term is missing";return J(t).has("plot")}q_to_param(t){const e=JSON.parse(JSON.stringify(t));delete e.hiddenValues;return encodeURIComponent(JSON.stringify(e))}}function yt(t){return e=>{const s=[];for(let e=0;e<t.length;e++)s.push([t[e],0]);for(const i of e){for(let e=1;e<t.length;e++){if(i<=t[e]){s[e-1][1]++;break}}}return s}}function gt(t){if(t.vocab&&!t.state){t.state={vocab:t.vocab}}if(!t.state)throw"missing opts.state";if(!t.state.vocab){t.state.vocab=t.vocab?t.vocab:{}}const e=t.state.vocab;if(t.state.genome){e.genome=t.state.genome;delete t.state.genome}if(t.state.dslabel){e.dslabel=t.state.dslabel;delete t.state.dslabel}if(e.dslabel){return new W(t)}else if(e.terms){return new ut(t)}}function bt(t){const e=JSON.parse(JSON.stringify(t));delete e.hiddenValues;return encodeURIComponent(JSON.stringify(e))}function vt({samples:t,sample_attributes:e}){const s={__root:{id:"root",name:"root",__tree_isroot:true}};const i={};for(const r of t){const t=r.sample;if(!i[t])i[t]={};Object.assign(i[t],r.s);for(const t in r.s){if(!s[t]){const i=e[t]&&e[t].label?e[t].label:t;s[t]={id:t,name:i,parent_id:null,type:e[t].type=="float"?"float":e[t].type=="integer"?"integer":"categorical",values:{},isleaf:true}}const i=s[t];if(!("id"in i))i.id=t;if(!("parent_id"in i))i.parent_id=null;if(!("values"in i))i.values={};if(!("isleaf"in i))i.isleaf=true;if(!i.computableVals&&(i.type=="float"||i.type=="integer")){i.computableVals=[]}const n=r.s[t];if(i.type=="categorical"){i.groupsetting={disabled:true};if(!(n in i.values)){i.values[n]={key:n,label:n}}}else if(i.type=="integer"||i.type=="float"){if(n==="Not Available"&&!(n in i.values)){i.values[n]={label:n,uncomputable:true}}if(!(n in i.values)){if(!a(r.s[t]))throw`non-numeric term value='${n}' for term='${t}'`;r.s[t]=Number(r.s[t]);const e=r.s[t];i.computableVals.push(e)}}else if(i.type=="condition");else if(i.type==m.SINGLECELL_GENE_EXPRESSION);else{throw"Term type not supported:"+i.type}}}for(const t in s){const e=s[t];if((e.type=="integer"||e.type=="float")&&!e.bins){e.bins={default:q(e.computableVals)};delete e.computableVals}}return{sampleannotation:i,terms:Object.values(s)}}var _t=Object.freeze({__proto__:null,vocabInit:gt,q_to_param:bt,getVocabFromSamplesArray:vt});const wt={joinWith:["and","or"]};class jt{constructor(t){this.opts=this.validateOpts(t);this.dom={holder:t.holder,controlsTip:new e({padding:"0px",parent_menu:this.opts.holder.node()&&this.opts.holder.node().closest(".sja_menu_div")}),treeTip:new e({padding:"5px",offsetX:20,offsetY:-34,clearSelector:".sja_term_src_body"})};this.durations={exit:500};this.lastId=0;this.categoryData={};this.pills={};$(this);R(this);this.initUI();this.filter={type:"tvslst",tag:"filterUiRoot",join:"and",in:true,lst:[]};this.promises={}}validateOpts(t){const e=Object.assign({},wt,t);if(!e.holder)throw".holder missing";if(e.vocabApi){this.vocabApi=e.vocabApi}else{if(!e.vocab)throw".vocab missing";if(e.vocab.dslabel){if(!e.vocab.genome)throw"vocab.genome missing"}else{if(!e.vocab.terms)throw"vocab.terms missing"}}if(typeof e.callback!="function")throw".callback() is not a function";if(e.getVisibleRoot&&typeof e.getVisibleRoot!="function")throw".getVisibleRoot() must be a function if set as an option";if(!e.emptyLabel)e.emptyLabel="+NEW";return e}async main(t,e={}){this.promises.postRender=new Promise(((t,e)=>{this.mainResolve=t;this.mainReject=e}));this.numProcessedItems=0;this.numExpectedItems=0;this.opts=Object.assign({},this.opts,e);this.activeCohort=this.opts.activeCohort;this.rawCopy=t;this.rawFilter=JSON.parse(this.rawCopy);this.validateFilter(this.rawFilter);this.filter=x(this.rawFilter,"filterUiRoot");if(!this.filter){this.filter=this.rawFilter;this.filter.tag="filterUiRoot"}await this.resetActiveData(this.filter);this.removeBlankPill();this.dom.newBtn.style("display",this.opts.newBtn?"":this.filter.lst.length==0?"inline-block":"none");this.dom.holder.selectAll(".sja_filter_add_transformer").style("display",this.getAddTransformerBtnDisplay);this.setVocabApi();this.updateUI(this.dom.filterContainer,this.filter);return this.promises.postRender}validateFilter(t){if(!("$id"in t))t.$id=this.lastId++;else if(this.lastId<=t.$id)this.lastId=t.$id+1;if(!("type"in t))throw"missing filter.type";if(t.type!="tvs"&&t.type!="tvslst")throw"invalid filter.type";if(t.type!="tvslst")return;if(!Array.isArray(t.lst))throw"invalid or missing filter.lst[]";if(t.lst.length>1){if(t.join!="and"&&t.join!="or")throw"invalid filter.join value for lst.length > 1"}else if(t.join!==""){throw"filter.join must be an empty string when lst.length < 2"}if(!t.lst.length)t.in=true;for(const[e,s]of t.lst.entries()){this.validateFilter(s)}}resetActiveData(t){if(this.dom.controlsTip.d.style("display")=="none"){this.activeData={item:{},filter:{}}}else{this.activeData={item:N(t,this.activeData.item.$id),filter:N(t,this.activeData.filter.$id),menuOpt:this.activeData.menuOpt}}}refresh(t){this.dom.controlsTip.hide();this.dom.treeTip.hide();const e=JSON.parse(JSON.stringify(this.rawFilter));delete e.tag;t.tag="filterUiRoot";const s=S(e,this.filter.$id);if(!s||this.rawFilter.$id===this.filter.$id){this.api.main(t);this.opts.callback(t)}else{const i=s.lst.findIndex((t=>t.$id==this.filter.$id));s.lst[i]=t;this.api.main(e);this.opts.callback(t)}}getId(t){return t.$id}getFilterExcludingPill(t){const e=JSON.parse(JSON.stringify(this.rawFilter));const s=S(e,t);const i=s.lst.findIndex((e=>e.$id===t));if(i==-1)return null;s.lst.splice(i,1);return A(e)}getAdjustedRoot(t,e){const s=JSON.parse(JSON.stringify(this.rawFilter));if(e=="and")return s;const i=x(s,"cohortFilter");const r=S(s,t);if(!r){return{type:"tvslst",in:true,join:"and",lst:i?[i]:[]}}const n=r.lst.findIndex((t=>t.$id===r.$id));if(n==-1)return{type:"tvslst",in:true,join:"and",lst:i?[i]:[]};r.lst.splice(n,1);if(i&&!r.lst.find((t=>t===i))){return A({type:"tvslst",join:"and",lst:[i,r]})}return A(r)}setVocabApi(){if(!this.vocabApi){const t={getState:()=>{const t=JSON.parse(this.rawCopy);const e=x(t,"cohortFilter");if(e&&this.opts.termdbConfig){e.tvs.values=this.activeCohort==-1||this.activeCohort===undefined?[]:this.opts.termdbConfig.selectCohort.values[this.activeCohort].keys.map((t=>({key:t,label:t})))}return{vocab:this.opts.vocab,termfilter:{filter:t},tree:{plots:{}}}}};const e=t.getState();const s=e.vocab||{genome:e.genome,dslabel:e.dslabel};if(!this.vocabApi){this.vocabApi=gt({app:t,state:{vocab:s}})}}this.vocabApi.main()}updatePromise=function(t=1){if(!this.mainResolve)return;this.numProcessedItems+=t;if(this.numExpectedItems==this.numProcessedItems){this.mainResolve();if(this.bus)this.bus.emit("postRender");delete this.mainResolve}}}class Tt extends jt{constructor(t){super(t);this.type="filter";this.initHolder()}async preApiFreeze(t){t.main=this.main.bind(this);t.getNormalRoot=()=>A(this.rawFilter)}getState(t){return{termfilter:t.termfilter,activeCohort:t.activeCohort}}async main(t=null){this.dom.controlsTip.hide();this.dom.treeTip.hide();const e=this.state&&this.state.termfilter;if(!e){this.dom.holder.style("display","none");return}this.dom.holder.style("display","inline-block");const s=JSON.stringify(t||e.filter);super.main(s,{activeCohort:this.state.activeCohort})}initHolder(){const t=this.dom.holder.attr("class","filter_div").style("position","relative").style("width","fit-content").style("margin","10px").style("margin-top","5px").style("display","table").style("border",this.opts.hideLabel?"none":"solid 1px #ddd");if(this.opts.hideLabel){this.dom.filterDiv=t.style("display","inline-block").style("padding","5px 10px")}else{t.append("span").text("Filter").style("padding","0 10px");this.dom.filterDiv=t.append("div").style("display","inline-block").style("padding","5px 10px")}}}const Nt=c(Tt);export{jt as F,x as a,Nt as b,C as c,T as d,vt as e,S as f,A as g,it as h,J as i,rt as j,ht as k,_t as l,w as s,gt as v};
|