import {
  get_tklst,
  init_mdsjson,
  mayLaunchGdcPlotFromRunpp,
  parse
} from "./chunk-IW57W7EQ.js";
import {
  bulkembed,
  bulkui,
  loadstudycohort
} from "./chunk-ZTYNN6G5.js";
import {
  childCorsMessage
} from "./chunk-PRZWSBMA.js";
import {
  findgenemodel_bysymbol
} from "./chunk-LTOBEUM2.js";
import {
  urlmap_default
} from "./chunk-WKNI3HRQ.js";
import {
  block_init_default
} from "./chunk-67DBIM6H.js";
import {
  newpane,
  renderSandboxFormDiv,
  sayerror,
  tkt
} from "./chunk-SA7APTJR.js";
import {
  string2pos
} from "./chunk-HJ6L54YS.js";
import {
  Menu,
  observeElem
} from "./chunk-HYOEWQ5P.js";
import {
  clearServerDataCache,
  dofetch,
  dofetch2,
  dofetch3,
  setAuth
} from "./chunk-7EMWHCVW.js";
import {
  applyOverrides,
  mclass
} from "./chunk-4UWS5Y3N.js";
import {
  selectAll_default,
  select_default
} from "./chunk-I6Y4O3RR.js";

// src/style-normalize-scoped.css
var styles = new CSSStyleSheet();
styles.replaceSync(`
/**
 * Render the \`main\` element consistently in IE.
 */

.sja_root_holder main, .sja_menu_div main, .sja_pane main {
  display: block;
}

/**
 * Correct the font size and margin on \`h1\` elements within \`section\` and
 * \`article\` contexts in Chrome, Firefox, and Safari.
 */

.sja_root_holder h1, .sja_menu_div h1, .sja_pane h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

/* Grouping content
   ========================================================================== */

/**
 * 1. Add the correct box sizing in Firefox.
 * 2. Show the overflow in Edge and IE.
 */

.sja_root_holder hr, .sja_menu_div hr, .sja_pane hr {
  box-sizing: content-box; /* 1 */
  height: 0; /* 1 */
  overflow: visible; /* 2 */
}

/**
 * 1. Correct the inheritance and scaling of font size in all browsers.
 * 2. Correct the odd \`em\` font sizing in all browsers.
 */

.sja_root_holder pre, .sja_menu_div pre, .sja_pane pre {
  font-family: monospace, monospace; /* 1 */
  font-size: 1em; /* 2 */
}

/* Text-level semantics
   ========================================================================== */

/**
 * Remove the gray background on active links in IE 10.
 */

.sja_root_holder a, .sja_menu_div a, .sja_pane a {
  background-color: transparent;
}

/**
 * 1. Remove the bottom border in Chrome 57-
 * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
 */

.sja_root_holder abbr[title], .sja_menu_div abbr[title], .sja_pane abbr[title] {
  border-bottom: none; /* 1 */
  text-decoration: underline; /* 2 */
  text-decoration: underline dotted; /* 2 */
}

/**
 * Add the correct font weight in Chrome, Edge, and Safari.
 */

.sja_root_holder b, .sja_menu_div b, .sja_pane b,
.sja_root_holder strong, .sja_menu_div strong, .sja_pane strong {
  font-weight: bolder;
}

/**
 * 1. Correct the inheritance and scaling of font size in all browsers.
 * 2. Correct the odd \`em\` font sizing in all browsers.
 */

.sja_root_holder code, .sja_menu_div code, .sja_pane code,
.sja_root_holder kbd, .sja_menu_div kbd, .sja_pane kbd,
.sja_root_holder samp, .sja_menu_div samp, .sja_pane samp {
  font-family: monospace, monospace; /* 1 */
  font-size: 1em; /* 2 */
}

/**
 * Add the correct font size in all browsers.
 */

.sja_root_holder small, .sja_menu_div small, .sja_pane small {
  font-size: 80%;
}

/**
 * Prevent \`sub\` and \`sup\` elements from affecting the line height in
 * all browsers.
 */

.sja_root_holder sub, .sja_menu_div sub, .sja_pane sub,
.sja_root_holder sup, .sja_menu_div sup, .sja_pane sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

.sja_root_holder sub, .sja_menu_div sub, .sja_pane sub {
  bottom: -0.25em;
}

.sja_root_holder sup, .sja_menu_div sup, .sja_pane sup {
  top: -0.5em;
}

/* Embedded content
   ========================================================================== */

/**
 * Remove the border on images inside links in IE 10.
 */

.sja_root_holder img, .sja_menu_div img, .sja_pane img {
  border-style: none;
}

/* Forms
   ========================================================================== */

/**
 * 1. Change the font styles in all browsers.
 * 2. Remove the margin in Firefox and Safari.
 */

.sja_root_holder button, .sja_menu_div button, .sja_pane button,
.sja_root_holder input, .sja_menu_div input, .sja_pane input,
.sja_root_holder optgroup, .sja_menu_div optgroup, .sja_pane optgroup,
.sja_root_holder select, .sja_menu_div select, .sja_pane select,
.sja_root_holder textarea, .sja_menu_div textarea, .sja_pane textarea {
  font-family: inherit; /* 1 */
  font-size: 100%; /* 1 */
  line-height: 1.15; /* 1 */
  margin: 0; /* 2 */
}

/**
 * Show the overflow in IE.
 * 1. Show the overflow in Edge.
 */

.sja_root_holder button, .sja_menu_div button, .sja_pane button,
.sja_root_holder input  /* 1 */, .sja_menu_div input  /* 1 */, .sja_pane input  /* 1 */ {
  overflow: visible;
}

/**
 * Remove the inheritance of text transform in Edge, Firefox, and IE.
 * 1. Remove the inheritance of text transform in Firefox.
 */

.sja_root_holder button, .sja_menu_div button, .sja_pane button,
.sja_root_holder select  /* 1 */, .sja_menu_div select  /* 1 */, .sja_pane select  /* 1 */ {
  text-transform: none;
}

/**
 * Correct the inability to style clickable types in iOS and Safari.
 */

.sja_root_holder button, .sja_menu_div button, .sja_pane button,
.sja_root_holder [type="button"], .sja_menu_div [type="button"], .sja_pane [type="button"],
.sja_root_holder [type="reset"], .sja_menu_div [type="reset"], .sja_pane [type="reset"],
.sja_root_holder [type="submit"], .sja_menu_div [type="submit"], .sja_pane [type="submit"] {
  -webkit-appearance: button;
}

/**
 * Remove the inner border and padding in Firefox.
 */

.sja_root_holder button::-moz-focus-inner, .sja_menu_div button::-moz-focus-inner, .sja_pane button::-moz-focus-inner,
.sja_root_holder [type="button"]::-moz-focus-inner, .sja_menu_div [type="button"]::-moz-focus-inner, .sja_pane [type="button"]::-moz-focus-inner,
.sja_root_holder [type="reset"]::-moz-focus-inner, .sja_menu_div [type="reset"]::-moz-focus-inner, .sja_pane [type="reset"]::-moz-focus-inner,
.sja_root_holder [type="submit"]::-moz-focus-inner, .sja_menu_div [type="submit"]::-moz-focus-inner, .sja_pane [type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

/**
 * Restore the focus styles unset by the previous rule.
 */

.sja_root_holder button:-moz-focusring, .sja_menu_div button:-moz-focusring, .sja_pane button:-moz-focusring,
.sja_root_holder [type="button"]:-moz-focusring, .sja_menu_div [type="button"]:-moz-focusring, .sja_pane [type="button"]:-moz-focusring,
.sja_root_holder [type="reset"]:-moz-focusring, .sja_menu_div [type="reset"]:-moz-focusring, .sja_pane [type="reset"]:-moz-focusring,
.sja_root_holder [type="submit"]:-moz-focusring, .sja_menu_div [type="submit"]:-moz-focusring, .sja_pane [type="submit"]:-moz-focusring {
  outline: 1px dotted ButtonText;
}

/**
 * Correct the padding in Firefox.
 */

.sja_root_holder fieldset, .sja_menu_div fieldset, .sja_pane fieldset {
  padding: 0.35em 0.75em 0.625em;
}

/**
 * 1. Correct the text wrapping in Edge and IE.
 * 2. Correct the color inheritance from \`fieldset\` elements in IE.
 * 3. Remove the padding so developers are not caught out when they zero out
 *    \`fieldset\` elements in all browsers.
 */

.sja_root_holder legend, .sja_menu_div legend, .sja_pane legend {
  box-sizing: border-box; /* 1 */
  color: inherit; /* 2 */
  display: table; /* 1 */
  max-width: 100%; /* 1 */
  padding: 0; /* 3 */
  white-space: normal; /* 1 */
}

/**
 * Add the correct vertical alignment in Chrome, Firefox, and Opera.
 */

.sja_root_holder progress, .sja_menu_div progress, .sja_pane progress {
  vertical-align: baseline;
}

/**
 * Remove the default vertical scrollbar in IE 10+.
 */

.sja_root_holder textarea, .sja_menu_div textarea, .sja_pane textarea {
  overflow: auto;
}

/**
 * 1. Add the correct box sizing in IE 10.
 * 2. Remove the padding in IE 10.
 */

.sja_root_holder [type="checkbox"], .sja_menu_div [type="checkbox"], .sja_pane [type="checkbox"],
.sja_root_holder [type="radio"], .sja_menu_div [type="radio"], .sja_pane [type="radio"] {
  box-sizing: border-box; /* 1 */
  padding: 0; /* 2 */
}

/**
 * Correct the cursor style of increment and decrement buttons in Chrome.
 */

.sja_root_holder [type="number"]::-webkit-inner-spin-button, .sja_menu_div [type="number"]::-webkit-inner-spin-button, .sja_pane [type="number"]::-webkit-inner-spin-button,
.sja_root_holder [type="number"]::-webkit-outer-spin-button, .sja_menu_div [type="number"]::-webkit-outer-spin-button, .sja_pane [type="number"]::-webkit-outer-spin-button {
  height: auto;
}

/**
 * 1. Correct the odd appearance in Chrome and Safari.
 * 2. Correct the outline style in Safari.
 */

.sja_root_holder [type="search"], .sja_menu_div [type="search"], .sja_pane [type="search"] {
  -webkit-appearance: textfield; /* 1 */
  outline-offset: -2px; /* 2 */
}

/**
 * Remove the inner padding in Chrome and Safari on macOS.
 */

.sja_root_holder [type="search"]::-webkit-search-decoration, .sja_menu_div [type="search"]::-webkit-search-decoration, .sja_pane [type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

/**
 * 1. Correct the inability to style clickable types in iOS and Safari.
 * 2. Change font properties to \`inherit\` in Safari.
 */

.sja_root_holder ::-webkit-file-upload-button, .sja_menu_div ::-webkit-file-upload-button, .sja_pane ::-webkit-file-upload-button {
  -webkit-appearance: button; /* 1 */
  font: inherit; /* 2 */
}

/* Interactive
   ========================================================================== */

/*
 * Add the correct display in Edge, IE 10+, and Firefox.
 */

.sja_root_holder details, .sja_menu_div details, .sja_pane details {
  display: block;
}

/*
 * Add the correct display in all browsers.
 */

.sja_root_holder summary, .sja_menu_div summary, .sja_pane summary {
  display: list-item;
}

/* Misc
   ========================================================================== */

/**
 * Add the correct display in IE 10+.
 */

.sja_root_holder template, .sja_menu_div template, .sja_pane template {
  display: none;
}

/**
 * Add the correct display in IE 10.
 */

.sja_root_holder [hidden], .sja_menu_div [hidden], .sja_pane [hidden] {
  display: none;
}`);
document.adoptedStyleSheets.push(styles);

// ../node_modules/highlight.js/styles/github.css
var styles2 = new CSSStyleSheet();
styles2.replaceSync(`pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
  Theme: GitHub
  Description: Light theme as seen on github.com
  Author: github.com
  Maintainer: @Hirse
  Updated: 2021-05-15

  Outdated base version: https://github.com/primer/github-syntax-light
  Current colors taken from GitHub's CSS
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}`);
document.adoptedStyleSheets.push(styles2);

// src/style.css
var styles3 = new CSSStyleSheet();
styles3.replaceSync(`/*
    see client/generateScopedCss.js on how to generate style-normalize-*.css

    also see a TODO comment in client/src/app.js, of dynamically importing
    style-normalize-unscoped.css only if it's known to not conflict in
    the embedder portal
*/
/* directly import these in src/app.js so that they will be processed as CSSStyleSheet
@import './style-normalize-scoped.css';
@import 'highlight.js/styles/github.css';
*/
/*
html {
    height:100%;
}
body {
    min-height:100%;
}
table {
    font-size:1em;
    border-spacing:1px;
    border-collapse:separate;
}
*/

/*
    !!! NOTE !!!
    FireFox does not support the @scope (selector) syntax
    that can enclose all affected rules inside a nested block,
    so for now, will need to prepend the .sja_root_holder scope for each selector
*/

/***************************************
CSS properties that are not covered 
by normalize.css are covered here

!!! make sure to scope to sja_root_holder
****************************************/

.sja_root_holder h2 {
    margin-block-start: 0.83em;
    margin-block-end: 0.83em;
}


/***************************************
    tag-based styles

  prevent embedder styles from overriding
  the styles within pp-controlled divs
****************************************/


/* use default browser styles within pp-controlled divs */

/* using the !important flag:
- this flag is used to override conflicting styles
- this flag will override both embedder styling and inline styling
- it is not necessary to use this flag to prevent embedder styles from overriding pp styles, because specifying styles within pp-specific classes will usually prevent this issue
- the only time when it is necessary to use this flag is when (1) the conflicting styling also has an !important flag or (2) the conflicting styling is also specified in this same file
*/


.sja_root_holder {
    all: initial;  /* block inheritance for all properties */
    font-family: Arial, sans-serif;
    /*background-color: #fff;*/
}

.sja_menu_div,
.sja_pane {
    all: initial; /* block inheritance for all properties */
}

.sja_menu_div {
  font-family: Arial;
}

.sja_root_holder table,
.sja_menu_div table,
.sja_pane table {
    border-collapse: separate;
    border-spacing: 2px;
}

.sja_root_holder svg {
    display: inline-block;
}
/*
    override the thicker button border
    that results when a button's 
    border-radius: 0 which seems to override
    all associated styles of 
    -webkit-appearance: button;
*/

.sja_root_holder button,
.sja_menu_div button,
.sja_pane button {
    padding: 2px 3px;
    border-width: 1px;
    border-style: solid;
    border-radius: 3px;
    box-shadow: inset 0 0 0 99999px rgba(255, 255, 255, 0.3);
    color: black;
    background-color: buttonface;
    border-color: buttonborder;
}

.sja_root_holder button:disabled,
.sja_menu_div button:disabled,
.sja_pane button:disabled {
    background-color: rgba(239, 239, 239, 0.3);
    color: rgba(16, 16, 16, 0.3);
    border-color: rgba(118, 118, 118, 0.3);
}

.sja_root_holder button:hover,
.sja_menu_div button:hover,
.sja_pane button:hover {
    box-shadow: none;
}

.sja_root_holder label,
.sja_menu_div label,
.sja_pane label {
    margin-bottom: 0;
}

.sja_root_holder a,
.sja_menu_div a,
.sja_pane a,
.linkText {
    color: rgb(0, 0, 238);
    cursor: pointer;
    text-decoration: underline;
}

.sja_root_holder input,
.sja_menu_div input,
.sja_pane input {
    padding: 1px 3px;
    margin:  2px 5px;
    border:  1px solid #ccc;
}

.sja_root_holder select,
.sja_menu_div select,
.sja_pane select {
    padding: 1px 3px;
    padding-right: 30px; /* padding between text and arrow */
    background-size: auto;
    background-position: right;
    border: 1px solid #ccc;
}

.sja_root_holder textarea,
.sja_menu_div textarea,
.sja_pane textarea {
    padding: 2px;
    border: 1px solid #ccc;
}

.sja_root_holder input[type="search"].tree_search {
    -webkit-appearance: searchfield;
}

.sja_root_holder ul {
    display: block;
    list-style-type: disc;
    margin-block-start: 1em;
    margin-block-end: 1em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    padding-inline-start: 40px;
}

.sja_root_holder ul ul {
    list-style-type: circle;
}

.sja_root_holder li {
    display: list-item;
    text-align: -webkit-match-parent;
}

/*************************
    class-specific styles
*************************/

.sja_errorbar {
    position: relative;
    padding: 5px 50px 5px 10px;
    background-color: rgba(200, 0, 0, .1);
    color: rgba(190, 0, 0, .5);
    border: solid 1px rgba(200, 0, 0, .2);
    /*border-width: 1px 0px;*/
}

.sja_infobar {
    position: relative;
    padding: 5px 50px 5px 10px;
    background-color: rgba(0, 100, 200, .1);
    color: rgba(0, 80, 180, .8);
    border: solid 1px rgba(0, 100, 200, .25);
    border-radius: 5px;
}



.sja_inset_a {
    background-color: #ebedeb;
    box-shadow: inset 0px 0px 14px 0px #858585;
    padding: 5px 10px;
}

.sja_menu,
.sja_menu_persist,
.sja_tooltip {
    position: absolute;
    background-color: white;
    font-family: Arial;
    z-index: 1000;
}

/* /client/src/app.js start */
.sja_menuoption {
    color: black;
    padding: 5px 10px;
    cursor: default;
    background-color: #f2f2f2;
    margin: 1px;
    border-radius: 5px;
}

.sja_menuoption_not_interactive {
    padding: 5px 10px;
    cursor: default;
    margin: 1px;
}

.sja_sharp_border {
    border-radius: 0px;
}
.sja_menuoption:hover {
    background-color: #e6e6e6
}

.sja_menuoption:active {
    color: #cc0000;
    background-color: #FCE2E1;
}
/* /client/src/app.js end */

.sja_filter_tag_btn {
    display: inline-block;
    color: black;
    padding: 5px 8px;
    background-color: #cfe2f3;
    cursor: default;
}

/* .sja_filter_tag_btn:hover { opacity: 0.8; cursor:default} */

.sja_filter_tag_btn:active {
    color: #cc0000;
    opacity: 0.6;
}

.ts_pill:hover,
.tvs_pill:hover {
    opacity: 0.8;
    cursor: default
}

.sjpp_apply_btn {
    background-color: #d0e0e3;
    border-radius: 13px !important; 
    padding: 7px 15px !important;
    border: 0px !important;
}


.sjpp_delete_btn,
.remove_btn {
    background-color: #f4cccc;
}

.ts_summary_btn {
    background-color: #d9d2e9;
}


/* mostly for table tr */

.sja_clb {
    padding: 5px 10px;
    cursor: default;
}

.sja_clb:hover {
    background: #ffff99;
}

.sja_clb:active {
    background: #ffcc99;
}

.sja_clb_selected {
    padding: 5px 10px;
    cursor: default;
    background: #FAF0C8;
    border-bottom: solid 2px #E3CA64;
}

.sja_clb_selected:hover {
    background: #FCE68B
}

.sja_clb_selected:active {
    background: #ffcc99
}


/* table tr, gray highlight */

.sja_clb_gray {
    padding: 5px 10px;
    cursor: default;
}

.sja_clb_gray:hover {
    background-color: #f1f1f1;
}

.sja_clb_gray:active {
    background-color: #ffffcc;
}

.sja_hideable_legend {
    cursor: default;
}

.sja_hideable_legend:hover {
    background: #ffff99;
}

.sja_legend_more_btn {
    padding: 3px;
    text-align: center;
    font-size: 0.7em;
    opacity: 0.5;
    cursor: default;
}

.sja_legend_more_btn:hover {
    text-decoration: underline;
}


/* text only */

.sja_clbtext2 {
    cursor: default;
    text-decoration: none;
}

.sja_clbtext2:hover {
    text-decoration: underline;
}

.sja_clbtext2:active {
    fill: #CC0000;
    color: #CC0000;
}

.sja_clbtext {
    cursor: default;
    color: black;
    fill: black;
    border-bottom: solid 1px transparent;
}

.sja_clbtext:hover {
    color: #631318;
    fill: #631318;
    border-color: black;
}

.sja_clbtext:active {
    color: #CC0000;
    border-color: #cc0000;
    fill: #cc0000;
}

.sja_clbtextbold {
    cursor: default;
    color: black;
    fill: black;
    font-weight: normal;
}

.sja_clbtextbold:hover {
    color: #631318;
    fill: #631318;
    font-weight: bold;
}

.sja_clbtextbold:active {
    color: #CC0000;
    fill: #cc0000;
    font-weight: bold;
}

.sja_opaque6 {
    opacity: .6;
    cursor: default;
}

.sja_opaque6:hover {
    opacity: .9;
}

.sja_opaque8 {
    opacity: .8;
    cursor: default;
}

.sja_opaque8:hover {
    opacity: 1;
}

.sja_simpletable tr td {
    border-bottom: solid 1px #ededed;
}

.sja_mcdot {
    cursor: default;
    border-radius: 8px;
    padding: 1px 2px;
    margin-right: 1px;
    color: white;
    font-size: .8em;
}

.sja_variantpagesnv {
    cursor: default;
    display: inline-block;
    border-radius: 3px;
    padding: 3px 10px;
    margin-right: 2px;
    color: white;
    background-color: #0099FF;
    opacity: .6;
}

.sja_variantpagesnv:hover {
    opacity: 1;
}

.sja_variantpagesnv:active {
    background-color: #3366FF;
}

.sja_selectsample {
    cursor: default;
    display: inline-block;
    border-radius: 2px;
    border: solid 1px #545454;
    padding: 3px 10px;
    margin-right: 2px;
    color: #545454;
    background-color: white;
    font-size: .8em;
}

.sja_selectsample:hover {
    background-color: #f1f1f1;
}

.sja_selectsample:active {
    background-color: #F2E1E3;
}

.sja_pane {
    position: absolute;
    /*border:solid 1px #ccc;
    */
    box-shadow: 0px 2px 4px 1px #999;
    background-color: white;
}

.sja_pane>:first-child {
    padding-right: 10px;
    cursor: move;
    background-color: #f0f0f0;
}

.sja_pane>:nth-child(2) {
    padding: 0px 10px 10px 10px;
    font-family: Arial;
}

.sja_cursor_hmove {
    cursor: ew-resize;
}

.sja_svgtext {
    cursor: default;
    fill-opacity: .8
}

.sja_svgtext2 {
    cursor: default;
    fill: black;
}

.sja_svgtext2:hover {
    fill: #B30000
}

.sja_clb5 {
    /* tree button */
    cursor: default;
    display: inline-block;
    border: solid 1px #006600;
    color: #006600;
    background-color: white;
    margin-left: 6px;
    padding: 0px 4px;
    font-size: 80%;
}

.sja_clb5:hover {
    background-color: #006600;
    color: white;
}

.sja_clb5:active {
    background-color: #009900;
}

.sja_clb2 {
    color: black;
    font-family: Courier;
    display: inline-block;
    padding: 1px 5px;
    cursor: default;
}

.sja_clb2:hover {
    background-color: #ffff99;
}

.sja_clb2:active {
    background-color: #ccff99;
}

.sja_clbb {
    /* highlight border */
    border: solid 1px transparent;
    cursor: default;
}

.sja_clbb:hover {
    border-color: #ccc;
}

.sja_clbbox {
    cursor: default;
    padding: 2px 5px;
    color: white;
    font-size: .7em;
    font-weight: normal;
}

.sja_clbbox:hover {
    font-weight: bold;
}

.sja_tr {
    cursor: default;
    background-color: #f1f1f1;
}

.sja_tr:hover {
    background-color: white;
}

.sja_tr:active {
    background-color: #ffffcc;
}

.sja_tr2 {
    cursor: default;
}

.sja_tr2:hover {
    background-color: #ffffcc;
}

.sja_tr2:active {
    background-color: #ffff00;
}

.sja_aa_disclabel {
    cursor: default;
}

.sja_aa_discnum {
    cursor: default;
    text-rendering: geometricPrecision;
}

.sja_aa_skkick:hover {
    stroke: #858585;
}

.sja_aa_disckick:hover {
    stroke-opacity: 1;
}

.sja_menuoption_y {
    display: inline-block;
    color: black;
    padding: 2px 4px;
    cursor: default;
    background-color: #E6E5C5;
    margin: 2px;
}

.sja_menuoption_y:hover {
    background-color: #DEDCA9
}

.sja_menuoption_y:active {
    background-color: #FFFF99
}

.sja_menuoption_r {
    display: inline-block;
    color: black;
    padding: 2px 4px;
    cursor: default;
    background-color: #EDDDDE;
    margin: 2px;
}

.sja_menuoption_r:hover {
    background-color: #E8CFD1
}

.sja_menuoption_r:active {
    background-color: #FCD9DD
}

.sja_error2 {
    display: inline-block;
    padding: 5px 50px 5px 10px;
    margin: 10px 20px;
    background-color: rgba(200, 0, 0, .5);
    color: white;
    border-radius: 6px;
}

.sja_paint {
    position: relative;
}

.sja_paint>:first-child {}

.sja_paint>:nth-child(2) {
    position: absolute;
    padding: 3px 6px;
    cursor: default;
    top: 10px;
    right: 30px;
    font-size: 80%;
}

.sja_tree_ul {
    list-style-type: none;
    padding-left: 25px;
    line-height: 1.4;
}

.sja_input {
    display: inline-block;
    padding: 2px 6px;
}

.sja_bulkcell {
    display: inline-block;
    width: 3px;
    height: 9px;
    margin: 1px 1px 0px 0px;
}

.sja_tag {
    display: inline-block;
    margin-left: 10px;
    padding: 1px 3px;
    background-color: #858585;
    color: white;
    font-size: 80%;
}

.sja_bgbox {
    cursor: default;
    fill: yellow;
    fill-opacity: 0;
}

.sja_bgbox:hover {
    fill-opacity: .2;
}

.sja_diseasehm_search_item {
    display: inline-block;
    margin: 3px;
    padding: 2px;
}

.sja_pulse {
    animation: pulse .5s alternate infinite;
}

@keyframes pulse {
    from {
        opacity: .2;
    }
    to {
        opacity: 1;
    }
}

.sja_hm-edittool-table td {
    padding: 0 2px;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
}

.sja_hm-edittool-table td:hover {
    opacity: 1;
    font-weight: 600;
}

.sja_tinylogo_head {
    display: inline-block;
    background-color: #858585;
    color: white;
    font-size: .6em;
    padding: 1px 3px;
}

.sja_tinylogo_body {
    display: inline-block;
    margin-left: 10px;
    background-color: #ededed;
    font-size: .9em;
    color: black;
    padding: 1px 5px;
}

.sja_handle_green {
    display: inline-block;
    font-size: .9em;
    padding: 3px 6px;
    background-color: #f0f7f1;
    color: #146E17;
    cursor: default;
}

.sja_handle_green:hover {
    background-color: #D5F0D8;
}

.sja_handle_green:active {
    background-color: #BAD1BC;
    color: black;
}

.sja_handle_red {
    display: inline-block;
    font-size: .9em;
    padding: 3px 6px;
    background-color: #F5EBEC;
    color: #991F1F;
    cursor: default;
}

.sja_handle_red:hover {
    background-color: #F2D8DB;
}

.sja_handle_red:active {
    background-color: #E3B1B7;
    color: black;
}

.sja_btn {
    -webkit-appearance: button;
    -moz-appearance: button;
    appearance: button;
    text-decoration: none;
    color: initial;
}

.sja_button {
    display: inline-block;
    background: white;
    padding: 3px 5px;
    border: solid 1px black;
    opacity: .8;
    cursor: default;
}

.sja_button:hover {
    opacity: 1;
}

.sja_button_open {
    display: inline-block;
    background: #ddd;
    padding: 3px 5px;
    border: solid 1px black;
    opacity: .8;
    cursor: default;
}

.sja_button_open:hover {
    opacity: 1;
}

.sja_button_fold {
    display: inline-block;
    background: #aaa;
    color: white;
    padding: 3px 5px;
    border: solid 1px black;
    opacity: .8;
    cursor: default;
}

.sja_button_fold:hover {
    opacity: 1;
}

.sja-termdb-config-row-label {
    padding: 5px;
    text-align: left;
    vertical-align: middle;
}

.sjpp-controls-table {
  margin-bottom: 10px;
}

.sjpp-controls-table > tr:hover {
  /*font-weight: 600;*/
  text-shadow:0px 0px 0.5px black;
  background-color: rgba(239, 236, 149, 0.389);
}

.sja_edit_btn {
    display: inline-block;
    color: black;
    background-color: #f2f2f2;
    border-radius: 5px;
    border: solid 1px #aaa;
    padding: 5px 10px;
    cursor: default;
    margin: 1px;
    font-size: 0.8em;
    margin-left: 20px;
}

.sja_edit_btn:hover {
    background-color: #e6e6e6
}

.sja_edit_btn:active {
    color: #cc0000;
    background-color: #FCE2E1;
}

/* App Drawer style */

.sjpp-appdrawer-cols {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-weight: 500;
    font-size: 17px;
    text-align: left;
    color: #324870;
    margin: 10px 10px 0px 10px;
}

.sjpp-track, .sjpp-track li {
    display: grid !important;
    grid-template-columns: 2fr 4fr 40px;
    grid-template-areas: 'image header' 'image blurb';
    gap: 5px;
}

.sjpp-app-drawer-card,
.sjpp-track {
    background-color: white;
    max-width: 400px;
    /* min-width: 320px; */
    border-radius: 5px;
    padding: 0px;
    align-items: center;
    justify-items: left;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    -webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.sjpp-app-drawer-card::after,
.sjpp-track::after {
    content: "";
    border-radius: 8px;
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    -webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.sjpp-app-drawer-card:hover,
.sjpp-track:hover {
    -webkit-transform: scale(1, 1);
    transform: scale(1, 1);
}

.sjpp-app-drawer-card:hover::after,
.sjpp-track:hover::after {
    opacity: 1;
}

.sjpp-track-image {
    grid-area: image;
    width: 75px;
    height: 75px;
    align-self: start;
    justify-self: start;
}

.sjpp-track-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px 0px 0px 5px;
}

.sjpp-app-drawer-card-ribbon{
    grid-area: image;
    overflow: hidden;
    width: 100%;
    height: 100%;
}
.sjpp-app-drawer-card-ribbon::before,
.sjpp-app-drawer-card-ribbon::after {
  position: relative;
  z-index: -1;
  content: '';
  display: block;
  border-top-color: transparent;
  border-left-color: transparent;
}
.sjpp-app-drawer-card-ribbon span {
  position: relative;
  display: block;
  width: 100%;
  padding: 1px 0;
  border-color: transparent transparent transparent darkgray;
  box-shadow: 0 2px 7.5px rgba(0, 0, 0, 0.3);
  opacity: 1;
  font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
  transform: rotate(-45deg);
}

.sjpp-app-drawer-card-ribbon::before {
    top: 0;
    right: 0;
}
.sjpp-app-drawer-card-ribbon::after {
    bottom: 0;
    left: 0;
}

.sjpp-track-h {
    grid-area: header;
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    margin-left: 5px;
    padding: 0px;
}

.sjpp-track-blurb {
    grid-area: blurb;
    font-size: 13px;
    font-weight: 300;
    margin-left: 5px;
    justify-content: center;
    font-style: oblique;
    color: #403f3f;
}

/* client/src/block.js start */
.sjpp-active-tiny-button {
	display: inline-block;
	background-color: #1C5E86;
	font-size: .8em;
	color: white;
	padding: 1px 5px;
	margin-right: 5px;
	border-radius: 4px;
}

.sjpp-plus-button
{
    display: inline-block;
    margin: 1px;
    border: solid 1px #545454;
    font-size: .9em;
    cursor: default;
    padding: 2px 5px;
}

.sjpp-dshandleholder
{
    display: inline-block;
    margin: 1px;
    border: solid 1px #545454;
    font-size: .9em;
    cursor: default;
}

.sjpp-dslabel
{
    display: inline-block;
    color: black;
    padding: 2px 4px;

}
/* client/src/block.js end */


/* client/src/app.js start */
.sjpp-input-div-gene-pos
{
    display: inline-block;
    padding-right: 5px;
}

.sjpp-input-gene-pos
{
    border: solid 1px #545454;
    padding: 6px 10px;
    border-radius: 5px;
}

.sjpp-genome-select-div
{
    display: inline-block;
    padding-left: 5px;
}

.sjpp-genome-select
{
    border-radius: 5px;
    margin: 1px 20px 1px 10px;
}

.sjpp-output-sandbox-title
{
    border-radius:4px; 
    color:white; 
    background-color: #969696; 
    padding: 1px 5px; 
    display:inline-block; 
    font-size:0.8em; 
    margin-left:4px;
}
/* client/src/app.js end */

/* client/dom/sandbox.ts start */
.sjpp-output-sandbox-header
{
    display: inline-block;
    margin: 5px 10px;
    padding-right: 8px;
    margin-bottom: 0px;
    /* box-shadow:2px 0px 2px #f2f2f2; */
    border-radius: 5px 5px 0 0;
    /* background-color: #f2f2f2; */
    z-index: 99;
}

.sjpp-output-sandbox-content
{
    margin: 5px 10px;
    margin-top: 0px;
    padding-right: 8px;
    display: inline-block;
    /* box-shadow: 2px 2px 10px #f2f2f2; */
    border: solid 1px #ccc;
    border-top: solid 1px white;
    border-radius: 0  0 5px 5px;
}

.sjpp-output-sandbox-collapse-btn,
.sjpp-output-sandbox-expand-btn,
.sjpp-output-sandbox-close-bt
{
    /* display: inline-block; */
    /* margin: 0px; */
    /* border-right: solid 2px white; */
    font-size: 16px;
    cursor: default;
}

.sjpp-output-sandbox-close-bt {
    border-radius: 5px 0 0 0;
}

/* 
Separated padding for sandbox buttons to fix close button's
right, white border not extending to total height of
sandbox header
*/
.sjpp-output-sandbox-collapse-btn,
.sjpp-output-sandbox-expand-btn {
    padding: 4px 10px;
}

.sjpp-output-sandbox-close-bt {
    padding: 8px 10px;
}
/* client/dom/sandbox.ts end */


.sjpp_row_wrapper:hover {
    background: #fcfcca !important; 
}
/*.sjpp_row_wrapper:nth-child(odd) {background: rgb(237, 237, 237)}*/

.sjpp_table_header {
    font-size: 1em;
    text-align: left;
    position: sticky;
    top: 0;
    opacity: 0.7;
    font-weight: normal;
}

.sjpp_table_item {
    padding: 3px 5px;
    font-size: 1em;
    text-align: left;
}

.sjpp_show_scrollbar{
	/* set to "auto" to avoid showing a gray track as non-functional scrollbar when contents don't scroll at all, since scrollbar track is now gray and no longer white */
    overflow-y: auto;
    overflow-x: auto;
}

.sjpp_show_scrollbar::-webkit-scrollbar{
    background-color: #f1f1f1; /* use non-white track color so the presence of scrollbar is apparent (gdc requirement) */
    border-radius: 7px;
    width: 14px;
}

/* This will handle the thumb (scrolling part) */
.sjpp_show_scrollbar::-webkit-scrollbar-thumb{
    background-color: #858585;
    border-radius: 7px;
    border: 1px solid white;
}

.sjpp_show_scrollbar::-webkit-scrollbar-thumb:vertical{
    height: 14px!important;
    width: 14px;
}

.sjpp-matrix-series-group-label-g text,
.sjpp-matrix-series-label-g text,
.sjpp-matrix-term-group-label-g text,
.sjpp-matrix-term-label-g text,
.sjpp-matrix-label text {
    -webkit-user-select:  none;
    -moz-user-select: none;
    -ms-user-select: none;
    -user-select: none;
}

.sjpp-nav
{
    position: sticky;
    background-color: white;
    width: 100%;
    z-index: 10;
    top: 0px;
    left: 0px;
    padding: 0px 0px 15px 0px;
}

.add_term_btn {
    border-radius: 6px;
}

#sjpp-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color:rgba(255, 255, 255, 0.8);
}

.sjpp-spinner {
    position: absolute;
    left: calc(50% - 30px);
    top: 30%;
    height: 60px;
    width: 60px;
    margin: 0px auto;
    -webkit-animation: rotation .6s infinite linear;
    -moz-animation: rotation .6s infinite linear;
    -o-animation: rotation .6s infinite linear;
    animation: rotation .6s infinite linear;
    border-left: 6px solid rgba(0, 174, 239, .15);
    border-right: 6px solid rgba(0, 174, 239, .15);
    border-bottom: 6px solid rgba(0, 174, 239, .15);
    border-top: 6px solid rgba(0, 174, 239, .8);
    border-radius: 100%;
}

.sjpp-spinner-small {
    position: absolute;
    left: calc(50% - 15px);
    top: calc(50% - 15px);
    height: 30px;
    width: 30px;
    margin: 0px auto;
    -webkit-animation: rotation .6s infinite linear;
    -moz-animation: rotation .6s infinite linear;
    -o-animation: rotation .6s infinite linear;
    animation: rotation .6s infinite linear;
    border-left: 3px solid rgba(0, 174, 239, .15);
    border-right: 3px solid rgba(0, 174, 239, .15);
    border-bottom: 3px solid rgba(0, 174, 239, .15);
    border-top: 3px solid rgba(0, 174, 239, .8);
    border-radius: 100%;
}

@-webkit-keyframes rotation {
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(359deg);}
 }
 @-moz-keyframes rotation {
    from {-moz-transform: rotate(0deg);}
    to {-moz-transform: rotate(359deg);}
 }
 @-o-keyframes rotation {
    from {-o-transform: rotate(0deg);}
    to {-o-transform: rotate(359deg);}
 }
 @keyframes rotation {
    from {transform: rotate(0deg);}
    to {transform: rotate(359deg);}
 }


 .sja_root_holder [aria-label], .sja_menu_div [aria-label], .sja_pane [aria-label] {
    position: relative;
    cursor: default;
  }

  .sja_root_holder [aria-label]:after, .sja_menu_div [aria-label]:after, .sja_pane [aria-label]:after {
    content: attr(aria-label);
    position: absolute;
    left: 1em;
    top: 1.75em; /* put it on the top */
    /*bottom: 50%;*/
    background-color: white;
    color: #000;
    font-size: 15px;
    padding: 5px;
    opacity: 0;
    z-index: 10000;
    max-width: 350px;
    white-space: wrap;
    pointer-events: none;
    box-shadow: 0px 2px 4px 1px #999;
    text-align: left;
}

  .sja_root_holder [aria-label]:hover:after, .sja_menu_div [aria-label]:hover:after, .sja_pane [aria-label]:hover:after {
    /* uncomment for fading out effect
    animation-name: fadeOut;
    animation-duration: 10s;
    */
    opacity: 1;
    width: max-content;
  }

  /* uncomment for fading out effect
  @keyframes fadeOut {
    0% {
      opacity: 1;
      width: max-content;
    
    }

    100% {
        opacity: 0;
        width: max-content;

    }
  }*/
`);
document.adoptedStyleSheets.push(styles3);

// src/style-zoomify-scoped.css
var styles4 = new CSSStyleSheet();
styles4.replaceSync(`.sja_root_holder .map, .sja_menu_div .map, .sja_pane .map {
  width: 100%;
  height: 400px;
}

.sja_root_holder .map .ol-custom-overviewmap, .sja_menu_div .map .ol-custom-overviewmap, .sja_pane .map .ol-custom-overviewmap,
.sja_root_holder .map .ol-custom-overviewmap.ol-uncollapsible, .sja_menu_div .map .ol-custom-overviewmap.ol-uncollapsible, .sja_pane .map .ol-custom-overviewmap.ol-uncollapsible {
  bottom: auto;
  left: auto;
  right: 6pt;
  top: 6pt;
}

.sja_root_holder .ol-full-screen, .sja_menu_div .ol-full-screen, .sja_pane .ol-full-screen {
  position: absolute;
  right: auto;
  left: 6pt;
  top: 70pt;
}`);
document.adoptedStyleSheets.push(styles4);

// src/app.js
var headtip;
function runproteinpaint(arg) {
  if (document.body === null || arg.holder === null) {
    const e = `Call runproteinpaint() only after arg.holder is ready`;
    alert(e);
    console.error(e);
  }
  if (arg.styles) {
    if (typeof arg.styles != "string") throw "arg.styles{} not string";
    const styles5 = new CSSStyleSheet();
    styles5.replaceSync(arg.styles);
    document.adoptedStyleSheets.push(styles5);
  }
  if (!headtip) {
    headtip = new Menu({ padding: "0px", offsetX: 0, offsetY: 0 });
    headtip.d.style("z-index", 5555);
  }
  const app = {
    error0(m) {
      sayerror(app.holder0, m);
    },
    /*
    server emitted state, if true, will trigger globals e.g. window.bb
    it needs to be set before launching any apps
    */
    debugmode: false,
    // event callbacks for dynamically-loaded renderer instances
    callbacks: arg.callbacks || { sjcharts: {} },
    // object to store instances as created by dynamically loaded apps/renderers
    // the default is to have a unique tracker per Proteinpaint app instance
    instanceTracker: arg.instanceTracker || { sjcharts: {} }
  };
  setHostUrl(arg, app);
  if (!app.instanceTracker.sjcharts) {
    app.instanceTracker.sjcharts = {};
  }
  if (!app.callbacks.sjcharts) {
    app.callbacks.sjcharts = {};
  }
  if (arg.clear) {
    selectAll_default(".sja_pane").remove();
    return;
  }
  app.holder = select_default(arg.holder || document.body).append("div").attr("class", "sja_root_holder").attr("data-ppclientversion", `2.191.4`).style("font-size", "1em").style("color", "black").on("click", (e) => {
    e.stopPropagation();
    if (e.target.tagName == "BUTTON") e.preventDefault();
  });
  observeElem(app.holder.node());
  app.sandbox_header = arg.sandbox_header || void 0;
  if (arg.jwt) {
    sessionStorage.setItem("jwt", arg.jwt);
  }
  sessionStorage.setItem("suppressErrors", JSON.stringify(arg.suppressErrors));
  if (arg.variantPageCall_snv) {
    app.variantPageCall_snv = arg.variantPageCall_snv;
  }
  if (arg.samplecart) {
    app.samplecart = arg.samplecart;
  }
  if (arg.base_zindex) {
    newpane({ setzindex: arg.base_zindex });
  }
  const serverData = arg.serverData || // allow server data caching by app,
  // may generalize later
  arg.termdb && arg.termdb.serverData;
  const response = dofetch3("genomes", {}, { serverData });
  return response.then(async (data) => {
    if (data.error) throw { message: "Cannot get genomes: " + data.error };
    if (!data.genomes) throw { message: "no genome data!?" };
    if (data.debugmode) app.debugmode = true;
    if (data.base_zindex) {
      newpane({ setzindex: data.base_zindex });
    }
    if (data.features) {
      sessionStorage.setItem("optionalFeatures", JSON.stringify(data.features));
    }
    app.genomes = data.genomes;
    app.cardsPath = data.cardsPath;
    app.pkgver = data.pkgver;
    app.launchDate = data.launchdate;
    await setAuth({ dsAuth: data.dsAuth, holder: app.holder });
    if (data.commonOverrides || arg.commonOverrides) {
      const commonOverrides = Object.assign(data.commonOverrides || {}, arg.commonOverrides || {});
      applyOverrides(commonOverrides);
      sessionStorage.setItem("commonOverrides", JSON.stringify(commonOverrides));
    }
    if (data.targetPortal && data.targetPortal == "gdc") await import("./style.gdc-55MDBS67.js");
    for (const genomename in app.genomes) {
      const err = initgenome(app.genomes[genomename]);
      if (err) {
        throw { message: "Error with " + genomename + " genome: " + err };
      }
    }
    if (!arg.noheader && !arg.mass && !arg.massSessionId && !arg.massSessionFile && !window.location.search.includes("noheader") && !window.location.search.includes("mass-session-id") && !window.location.search.includes("mass-session-file") && !window.location.search.includes("mass-session-url") && !window.location.search.includes("massnative") && !window.location.search.includes("mass")) {
      const _ = await import("./AppHeader-PXLGVCVS.js");
      const appHeader = new _.AppHeader({
        headtip,
        app,
        data,
        jwt: arg.jwt
      });
      await appHeader.makeheader();
    }
    app.holder0 = app.holder.append("div").style("margin", "10px");
    const subapp = await parseEmbedThenUrl(arg, app);
    const appInstance = subapp || app;
    if (app.debugmode && data.features.sse && window.location.pathname != "/puppet.html") {
      import("./notify-2ROOBENL.js").catch((e) => console.warn(`debugmode: server-sent notifications setup failed`, e)).then(({ setRefreshCallback }) => {
        setRefreshCallback(() => {
          if (subapp?.destroy) subapp.destroy();
          select_default(arg.holder ? arg.holder : document.body).selectAll("*").remove();
          sseRefreshCallback(arg, appInstance);
        });
      });
    }
    if (!arg.origSubApp && subapp) arg.origSubApp = subapp;
    return appInstance;
  }).catch((err) => {
    if (!app.holder.text()?.includes(err.message || err)) app.holder.text(err.message || err);
    if (err.stack) console.log(err.stack);
  });
}
var boundApps = /* @__PURE__ */ new WeakMap();
function bindProteinPaint({ rootElem, initArgs, updateArgs, isStale, hasChangedUsername }) {
  const app = boundApps.get(rootElem);
  if (hasChangedUsername) clearServerDataCache();
  if (app) {
    if (!updateArgs) return app;
    if (typeof app.then != "function") {
      if (!isStale()) app.update(updateArgs);
      return app;
    } else {
      if (app.initTimeout) clearTimeout(app.initTimeout);
      app.initTimeout = setTimeout(() => {
        delete app.initTimeout;
        app.then(() => {
          if (!isStale()) app.update(updateArgs);
        });
      }, 20);
      return app;
    }
  } else {
    const pp_holder = rootElem.querySelector(".sja_root_holder");
    if (pp_holder) pp_holder.remove();
    if (!initArgs.opts) initArgs.opts = {};
    if (!initArgs.opts.app) initArgs.opts.app = {};
    if (!Object.keys(initArgs.opts.app).includes("doNotAwaitInitRender")) initArgs.opts.app.doNotAwaitInitArgs = true;
    const arg = Object.assign(
      initArgs,
      updateArgs || {},
      // may reapply previously rendered state from an unbound stale instance
      {
        state: Object.assign(rootElem._ppAppState || {}, initArgs.state || {})
      }
    );
    delete rootElem._ppAppState;
    const newAppInstance = runproteinpaint(arg).then((pp) => {
      boundApps.set(rootElem, pp);
      return pp;
    });
    boundApps.set(rootElem, newAppInstance);
    return newAppInstance;
  }
}
async function sseRefreshCallback(arg, subapp) {
  if (subapp?.destroy) subapp.destroy();
  select_default(arg.holder ? arg.holder : document.body).selectAll("*").remove();
  const app = boundApps.has(arg.holder) && boundApps.get(arg.holder);
  if (app) {
    if (subapp && app != subapp) return;
    arg.holder._ppAppState = structuredClone(app.getState?.());
    boundApps.delete(arg.holder);
  } else {
    if (!arg.pphost)
      arg.pphost = arg.host ? window.location.protocol + "//" + arg.host.split("://")[1]?.split("/")[0] : window.location.origin;
    if (subapp.getState) arg.state = structuredClone(subapp.getState());
    const subapp1 = await import(
      // embedder portal bundler should ignore this PP-only hot-module-replacement
      /*webpackIgnore: true*/
      `${arg.pphost}/bin/dist/app.js?_=${Date.now()}`
    ).then((_) => _.runproteinpaint(arg)).catch(console.log);
    if (arg.origSubApp && subapp1 && !Object.isFrozen(arg.origSubApp)) {
      arg.origSubApp.update = (arg2) => subapp1.update(arg2);
    } else if (!Object.isFrozen(arg.subApp)) {
      subapp.update = (arg2) => subapp1.update(arg2);
    }
  }
}
runproteinpaint.getStatus = async function getStatus(outputAs = "") {
  return await fetch("/healthcheck").then((res) => res.json()).then((res) => {
    const status = {
      clientVersion: document.querySelector(".sja_root_holder")?.dataset.ppclientversion,
      versionInfo: res.versionInfo
    };
    if (outputAs == "log") console.info(status);
    else if (outputAs == "json") return JSON.stringify(status);
    else return status;
  }).catch(console.error);
};
var ppsrc = document && document.currentScript && document.currentScript.src || "";
function setHostUrl(arg, app) {
  if (arg.host) {
    app.hostURL = arg.host;
  } else if (window.location.hostname == "localhost") {
    const urlp = urlmap_default();
    if (urlp.has("hosturl")) app.hostURL = urlp.get("hosturl");
    else if (window.testHost) {
      app.hostURL = window.testHost;
    } else {
      const hostname = urlp.get("hostname");
      const hostport = urlp.get("hostport");
      const prot = window.location.protocol + "//";
      if (hostname && hostport) app.hostURL = prot + hostname + ":" + hostport;
      else if (hostname) app.hostURL = prot + hostname;
      else if (hostport) app.hostURL = prot + window.location.hostname + ":" + hostport;
    }
  }
  if (!app.hostURL) {
    if (ppsrc.includes("://")) {
      app.hostURL = ppsrc.split("://")[0] + "://" + ppsrc.split("://")[1].split("/")[0];
    } else {
      app.hostURL = "";
    }
  }
  if (app.hostURL.endsWith("/")) app.hostURL = app.hostURL.slice(0, -1);
  sessionStorage.setItem("hostURL", app.hostURL);
}
async function parseEmbedThenUrl(arg, app) {
  if (arg.genome && app.selectgenome) {
    for (let i = 0; i < app.selectgenome.node().childNodes.length; i++) {
      if (app.selectgenome.node().childNodes[i].value == arg.genome) {
        app.selectgenome.property("selectedIndex", i);
        break;
      }
    }
  }
  if (arg.mclassOverride) {
    if (!arg.mclassOverride.className) arg.mclassOverride.className = "Class";
    for (const k in arg.mclassOverride.classes) {
      const c = mclass[k];
      if (c) {
        Object.assign(c, arg.mclassOverride.classes[k]);
      }
    }
  }
  if (arg.singlecell) {
    launch_singlecell(arg.singlecell, app);
    return app;
  }
  if (arg.fimo) {
    launch_fimo(arg.fimo, app);
    return app;
  }
  if (arg.mdssurvivalplot) {
    if (arg.genome) arg.mdssurvivalplot.genome = arg.genome;
    launchmdssurvivalplot(arg.mdssurvivalplot, app);
    return app;
  }
  if (arg.mdssamplescatterplot) {
    if (arg.genome) arg.mdssamplescatterplot.genome = arg.genome;
    launchmdssamplescatterplot(arg.mdssamplescatterplot, app);
    return app;
  }
  if (arg.samplematrix) {
    arg.samplematrix.jwt = arg.jwt;
    launchsamplematrix(arg.samplematrix, app);
    return app;
  }
  if (arg.hic) {
    arg.hic.jwt = arg.jwt;
    launchhic(arg.hic, app);
    return app;
  }
  if (arg.block) {
    return launchblock(arg, app);
  }
  if (arg.study) {
    loadstudycohort(
      app.genomes,
      arg.study,
      app.holder0,
      app.hostURL,
      arg.jwt,
      false,
      // no show
      app
    );
    return app;
  }
  if (arg.studyview) {
    const obj = arg.studyview;
    obj.hostURL = arg.host;
    const gn = obj.genome || arg.genome;
    obj.genome = app.genomes[gn];
    obj.hostURL = app.hostURL;
    obj.jwt = arg.jwt;
    obj.holder = app.holder0;
    bulkembed(obj);
    return app;
  }
  if (await may_launchGeneView(arg, app)) {
    return app;
  }
  if (arg.fusioneditor) {
    launchfusioneditor(arg, app);
    return app;
  }
  if (arg.genefusion) {
    launch_genefusion(arg, app);
    return app;
  }
  if (arg.mavolcanoplot) {
    launchmavb(arg, app);
    return app;
  }
  if (arg.twodmaf) {
    launch2dmaf(arg, app);
    return app;
  }
  if (arg.junctionbymatrix) {
    launchJunctionbyMatrix(arg, app);
    return;
  }
  if (arg.selectGenomeWithTklst) {
    await launchSelectGenomeWithTklst(arg, app);
    return;
  }
  if (arg.disco) {
    return await launchDisco(arg, app);
  }
  if (arg.wsiViewer) {
    return await launchWsiViewer(arg, app);
  }
  if (arg.parseurl && location.search.length) {
    try {
      return await parse({
        app,
        genomes: app.genomes,
        hostURL: app.hostURL,
        variantPageCall_snv: app.variantPageCall_snv,
        samplecart: app.samplecart,
        holder: app.holder,
        selectgenome: app.selectgenome,
        genome_browser_btn: app.genome_browser_btn,
        debugmode: app.debugmode,
        state: arg.state
      });
    } catch (e) {
      app.error0(e);
      console.error(e.stack || e);
    }
  }
  if (arg.project) {
    let holder = void 0;
    if (arg.project.uionly) holder = app.holder0;
    bulkui(0, 0, app.genomes, app.hostURL, holder, app.sandbox_header);
  }
  if (arg.termdb) {
    await launchtermdb(arg.termdb, app);
  }
  if (arg.maftimeline) {
    launchmaftimeline(arg, app);
  }
  {
    const _ = await mayLaunchGdcPlotFromRunpp(arg, app);
    if (_) return _;
  }
  if (arg.mass) {
    const subapp = await launchmass(arg, app);
    return subapp;
  }
  if (arg.tkui) {
    launch_tkUIs(arg, app);
  }
  if (arg.massSessionId) {
    const res = await dofetch3(`/massSession?id=${arg.massSessionId}`);
    if (res.error) throw res.error;
    const opts = {
      debug: app.debugmode,
      holder: app.holder0,
      state: res.state,
      genome: app.genomes[res.state.vocab.genome],
      massSessionDuration: res.massSessionDuration,
      getDatasetAccessToken: arg.getDatasetAccessToken,
      addLoginCallback: arg.addLoginCallback
    };
    const _ = await import("./app-FJT5VXMF.js");
    _.appInit(opts);
    return;
  }
  if (arg.massSessionFile || arg.massSessionURL) {
    let state;
    if (arg.massSessionFile) {
      const file = arg.massSessionFile;
      const jsonFile = await dofetch3(`/textfile`, {
        method: "POST",
        body: JSON.stringify({ file })
      });
      if (jsonFile.error) throw jsonFile.error;
      state = JSON.parse(jsonFile.text);
    } else {
      const url = arg.massSessionURL;
      const jsonURL = await dofetch3(`/urltextfile`, {
        method: "POST",
        body: JSON.stringify({ url })
      });
      if (jsonURL.error) throw jsonURL.error;
      state = JSON.parse(jsonURL.text);
    }
    const opts = {
      debug: app.debugmode,
      holder: app.holder0,
      state,
      genome: app.genomes[state.vocab.genome]
    };
    const _ = await import("./app-FJT5VXMF.js");
    _.appInit(opts);
    return;
  }
}
async function may_launchGeneView(arg, app) {
  if (arg.p) {
    arg.gene = arg.p;
    delete arg.p;
  }
  if (arg.gene2canonicalisoform) {
    if (!arg.genome) throw ".genome missing for gene2canonicalisoform";
    const data = await dofetch2(
      "gene2canonicalisoform?genome=" + arg.genome + "&gene=" + arg.gene2canonicalisoform
    );
    if (data.error) throw data.error;
    if (!data.isoform) throw "no canonical isoform for given gene accession";
    arg.gene = data.isoform;
  }
  if (arg.mds3_ssm2canonicalisoform) {
    if (!arg.genome) throw ".genome missing";
    if (!arg.mds3_ssm2canonicalisoform.ssm_id) throw ".ssm_id missing from mds3_ssm2canonicalisoform";
    if (!arg.mds3_ssm2canonicalisoform.dslabel) throw ".dslabel missing from mds3_ssm2canonicalisoform";
    const data = await dofetch2(
      "mds3?genome=" + arg.genome + "&dslabel=" + arg.mds3_ssm2canonicalisoform.dslabel + "&ssm2canonicalisoform=1&ssm_id=" + arg.mds3_ssm2canonicalisoform.ssm_id
    );
    if (data.error) throw data.error;
    if (!data.isoform) throw "no isoform found for given ssm_id";
    arg.gene = data.isoform;
    if (arg.tracks) {
      const tk = arg.tracks.find((i) => i.dslabel == arg.mds3_ssm2canonicalisoform.dslabel);
      if (tk) {
        tk.hlssmid = arg.mds3_ssm2canonicalisoform.ssm_id;
      }
    }
  }
  if (arg.gene) {
    await launchgeneview(arg, app);
    return true;
  }
  return false;
}
async function launchmdssamplescatterplot(arg, app) {
  if (!arg.genome) {
    app.error0("missing genome for mdssamplescatterplot");
    return;
  }
  const genome = app.genomes[arg.genome];
  if (!genome) {
    app.error0("invalid genome for mdssamplescatterplot");
    return;
  }
  arg.genome = genome;
  if (arg.dataset) {
    arg.mds = genome.datasets[arg.dataset];
    if (!arg.mds) {
      app.error0("invalid dataset for mdssamplescatterplot");
      return;
    }
    arg.dslabel = arg.dataset;
    delete arg.dataset;
    if (arg.mds.mdsIsUninitiated) {
      const d = await dofetch3(`getDataset?genome=${arg.genome.name}&dsname=${arg.dslabel}`);
      if (d.error) throw d.error;
      if (!d.ds) throw "ds missing";
      Object.assign(arg.mds, d.ds);
      delete arg.mds.mdsIsUninitiated;
    }
  } else if (arg.analysisdata) {
  } else if (arg.analysisdata_file) {
    try {
      const data = await dofetch("textfile", { file: arg.analysisdata_file });
      if (data.error) throw tmp.error;
      else if (data.text) arg.analysisdata = JSON.parse(data.text);
    } catch (e) {
      app.error0(e);
      return;
    }
  } else {
    app.error0("neither .dataset or .analysisdata is given");
    return;
  }
  import("./mds.samplescatterplot-Y5V73GOY.js").then((_) => {
    _.init(arg, app.holder0, app.debugmode);
  });
}
function launchmdssurvivalplot(arg, app) {
  if (!arg.genome) {
    app.error0("missing genome for mdssurvivalplot");
    return;
  }
  const genome = app.genomes[arg.genome];
  if (!genome) {
    app.error0("invalid genome for mdssurvivalplot");
    return;
  }
  arg.genome = genome;
  if (!arg.dataset) {
    app.error0("missing dataset for mdssurvivalplot");
    return;
  }
  arg.mds = genome.datasets[arg.dataset];
  if (!arg.mds) {
    app.error0("invalid dataset for mdssurvivalplot");
    return;
  }
  delete arg.dataset;
  if (arg.plotlist) {
    for (const p of arg.plotlist) {
      p.renderplot = 1;
    }
  }
  import("./mds.survivalplot-CZBRMHYN.js").then((_) => {
    _.init(arg, app.holder0, app.debugmode);
  });
}
function launch_fimo(arg, app) {
  if (!arg.genome) {
    app.error0("missing genome for fimo");
    return;
  }
  const genome = app.genomes[arg.genome];
  if (!genome) {
    app.error0("invalid genome for fimo");
    return;
  }
  arg.genome = genome;
  arg.div = app.holder0;
  import("./mds.fimo-ZJSEPLD7.js").then((_) => {
    _.init(arg);
  });
}
function launchhic(hic, app) {
  if (!hic.genome) {
    app.error0("missing genome for hic");
    return;
  }
  hic.genome = app.genomes[hic.genome];
  if (!hic.genome) {
    app.error0("invalid genome for hic");
    return;
  }
  if (!hic.file) {
    app.error0("missing file for hic");
    return;
  }
  hic.hostURL = app.hostURL;
  hic.holder = app.holder0;
  import("./HicApp-BBD2YOMT.js").then(async (_) => {
    await _.hicInit(hic, app.debugmode);
  });
}
function launchsamplematrix(cfg, app) {
  if (!cfg.genome) {
    app.error0("missing genome for launching samplematrix");
    return;
  }
  cfg.genome = app.genomes[cfg.genome];
  if (!cfg.genome) {
    app.error0("invalid genome for samplematrix");
    return;
  }
  cfg.hostURL = app.hostURL;
  cfg.holder = app.holder0;
  cfg.debugmode = app.debugmode;
  import("./samplematrix-NYDAH74I.js").then((_) => {
    new _.Samplematrix(cfg);
  });
}
async function launchgeneview(arg, app) {
  if (!arg.genome) {
    app.error0("Cannot embed: must specify reference genome");
    return;
  }
  if (arg.tracks) {
    for (const t of arg.tracks) {
      if (t.type == "mds3" && t.dslabel) continue;
      t.iscustom = true;
    }
  }
  if (arg.tkjsonfile) {
    if (!arg.tracks) arg.tracks = [];
    const urlp = /* @__PURE__ */ new Map([["tkjsonfile", arg.tkjsonfile]]);
    const lst = await get_tklst(urlp, genomeobj);
    for (const i of lst) {
      arg.tracks.push(i);
    }
  }
  const pa = {
    jwt: arg.jwt,
    hostURL: app.hostURL,
    query: arg.gene,
    genome: app.genomes[arg.genome],
    holder: app.holder0,
    variantPageCall_snv: app.variantPageCall_snv,
    samplecart: app.samplecart,
    debugmode: app.debugmode,
    datasetqueries: arg.datasetqueries,
    mset: arg.mset,
    tklst: arg.tracks,
    gmmode: arg.gmmode,
    geneDomains: arg.geneDomains,
    mclassOverride: arg.mclassOverride,
    hide_dsHandles: arg.hide_dsHandles,
    onloadalltk_always: arg.onloadalltk_always
  };
  let ds = null;
  if (arg.dataset) {
    pa.dataset = arg.dataset.split(",");
    pa.legacyDsFilter = arg.legacyDsFilter;
    if (arg.hidedatasetexpression) {
      pa.hidedatasetexpression = true;
    }
  }
  if (arg.hidegenecontrol) {
    pa.hidegenecontrol = true;
  }
  if (arg.hidegenelegend) {
    pa.hidegenelegend = true;
  }
  let hlaa = null;
  if (arg.hlaachange) {
    hlaa = /* @__PURE__ */ new Map();
    if (Array.isArray(arg.hlaachange)) {
      for (const s of arg.hlaachange) {
        if (s.name) {
          hlaa.set(s.name, s);
        }
      }
    } else {
      for (const s of arg.hlaachange.split(",")) {
        hlaa.set(s, false);
      }
    }
    if (hlaa.size) {
      pa.hlaachange = hlaa;
    }
  }
  if (arg.hlvariants) {
    pa.hlvariants = arg.hlvariants;
  }
  await block_init_default(pa);
}
async function launchblock(arg, app) {
  if (!arg.genome) {
    app.error0("Cannot embed: must specify reference genome");
    return;
  }
  const genomeobj2 = app.genomes[arg.genome];
  if (!genomeobj2) {
    app.error0("Invalid genome: " + arg.genome);
    return;
  }
  if (arg.study) {
    loadstudycohort(
      app.genomes,
      arg.study,
      app.holder0,
      app.hostURL,
      arg.jwt,
      true,
      // no show
      app
    );
  }
  if (arg.tracks) {
    for (const t of arg.tracks) {
      if (t.type == tkt.mds3 && t.dslabel) continue;
      if (t.mdsjsonfile || t.mdsjsonurl) {
        try {
          const tks = await init_mdsjson(t.mdsjsonfile, t.mdsjsonurl);
          arg.tracks = arg.tracks.filter((tk) => tk != t);
          arg.tracks.push(...tks);
        } catch (e) {
          sayerror(app.holder0, e);
        }
      }
      t.iscustom = true;
    }
  }
  if (arg.tkjsonfile) {
    if (!arg.tracks) arg.tracks = [];
    const urlp = /* @__PURE__ */ new Map([["tkjsonfile", arg.tkjsonfile]]);
    const lst = await get_tklst(urlp, genomeobj2);
    for (const i of lst) {
      arg.tracks.push(i);
    }
  }
  const blockinitarg = {
    genome: genomeobj2,
    hostURL: app.hostURL,
    jwt: arg.jwt,
    holder: app.holder0,
    nativetracks: arg.nativetracks,
    tklst: arg.tracks,
    debugmode: app.debugmode,
    legendimg: arg.legendimg,
    onloadalltk_always: arg.onloadalltk_always
  };
  if (arg.width) {
    const v = Number.parseInt(arg.width);
    if (Number.isNaN(v)) return app.error0("browser width must be integer");
    blockinitarg.width = v;
  }
  if (arg.subpanels) {
    if (!Array.isArray(arg.subpanels)) return app.error0("subpanels is not array");
    const lst = [];
    for (const r of arg.subpanels) {
      if (!r.chr) {
        app.error0("missing chr in one subpanel");
        continue;
      }
      if (!r.start || !r.stop) {
        app.error0("missing start or stop in one subpanel");
        continue;
      }
      if (!r.width) {
        r.width = 400;
      }
      if (!r.leftpad) {
        r.leftpad = 5;
      }
      lst.push(r);
    }
    if (lst.length) {
      blockinitarg.subpanels = lst;
    }
  }
  if (arg.nobox) {
    blockinitarg.nobox = true;
  } else {
    blockinitarg.dogtag = arg.dogtag || arg.genome;
  }
  if (arg.chr && Number.isInteger(arg.start)) {
    blockinitarg.chr = arg.chr;
    blockinitarg.start = arg.start;
    blockinitarg.stop = Number.isInteger(arg.stop) ? arg.stop : arg.start + 1;
  } else if (arg.position) {
    const pos = string2pos(arg.position, genomeobj2);
    if (pos) {
      blockinitarg.chr = pos.chr;
      blockinitarg.start = pos.start;
      blockinitarg.stop = pos.stop;
    }
  } else if (arg.positionbygene) {
    try {
      const gmlst = await findgenemodel_bysymbol(arg.genome, arg.positionbygene);
      if (gmlst && gmlst[0]) {
        const gm = gmlst[0];
        blockinitarg.chr = gm.chr;
        blockinitarg.start = gm.start;
        blockinitarg.stop = gm.stop;
      }
    } catch (e) {
      app.error0(e);
    }
  }
  if (!blockinitarg.chr) {
    blockinitarg.chr = genomeobj2.defaultcoord.chr;
    blockinitarg.start = genomeobj2.defaultcoord.start;
    blockinitarg.stop = genomeobj2.defaultcoord.stop;
  }
  if (arg.datasetqueries) {
    blockinitarg.datasetqueries = arg.datasetqueries;
  }
  if (arg.hlregions) {
    const lst = [];
    for (const region of arg.hlregions) {
      const pos = string2pos(region, genomeobj2, true);
      if (pos) lst.push(pos);
    }
    if (lst.length) blockinitarg.hlregions = lst;
  }
  const h = urlmap_default();
  if (h) {
    if (h.has("position")) {
      const pos = string2pos(h.get("position"), genomeobj2);
      if (pos) {
        blockinitarg.chr = pos.chr;
        blockinitarg.start = pos.start;
        blockinitarg.stop = pos.stop;
      }
    }
    if (h.has("hlregion")) {
      const lst = [];
      for (const tmp2 of h.get("hlregion").split(",")) {
        const pos = string2pos(tmp2, genomeobj2, true);
        if (pos) {
          lst.push(pos);
        }
      }
      if (lst.length) {
        blockinitarg.hlregions = lst;
      }
    }
    if (h.has("bedgraphdotfile")) {
      if (!blockinitarg.tklst) blockinitarg.tklst = [];
      const lst = h.get("bedgraphdotfile").split(",");
      for (let i = 0; i < lst.length; i += 2) {
        if (lst[i] && lst[i + 1]) {
          blockinitarg.tklst.push({
            type: tkt.bedgraphdot,
            name: lst[i],
            file: lst[i + 1]
          });
        }
      }
    }
  }
  return import("./block-TTN2IQAH.js").then((b) => {
    app.block = new b.Block(blockinitarg);
    return app;
  });
}
function launchfusioneditor(arg, app) {
  if (arg.fusioneditor.uionly) {
    const [inputdiv, gselect, filediv, saydiv, visualdiv] = renderSandboxFormDiv(app.holder0, app.genomes);
    import("./svmr-O4GJJUT2.js").then((p) => {
      p.svmrui([null, inputdiv, gselect, filediv, saydiv, visualdiv], app.genomes, app.hostURL, arg.jwt);
    });
    return;
  }
  const genomeobj2 = app.genomes[arg.genome];
  if (!genomeobj2) {
    app.error0("Invalid genome: " + arg.genome);
    return;
  }
  import("./svmr-O4GJJUT2.js").then((p) => {
    p.svmrparseinput(arg.fusioneditor, app.error0, genomeobj2, app.holder0, app.hostURL, arg.jwt);
  });
}
async function launchSelectGenomeWithTklst(arg, app) {
  const _ = await import("./selectGenomeWithTklst-OSB7B6L3.js");
  await _.init(arg, app.holder0, app.genomes);
}
function launchmavb(arg, app) {
  if (arg.mavolcanoplot.uionly) {
    import("./mavb-SQDA3B2B.js").then((p) => {
      p.mavbui(app.genomes, app.hostURL, arg.jwt, app.holder0, app.sandbox_header);
    });
    return;
  }
  const genomeobj2 = app.genomes[arg.genome];
  if (!genomeobj2) {
    app.error0("Invalid genome: " + arg.genome);
    return;
  }
  arg.mavolcanoplot.hostURL = app.hostURL;
  arg.mavolcanoplot.genome = genomeobj2;
  import("./mavb-SQDA3B2B.js").then((p) => {
    p.mavbparseinput(arg.mavolcanoplot, app.error0, app.holder0, arg.jwt);
  });
}
function launch2dmaf(arg, app) {
  if (arg.twodmaf.uionly) {
    import("./2dmaf-Z3D2M3FB.js").then((p) => {
      p.d2mafui(app.genomes, app.holder0);
    });
    return;
  }
  const genomeobj2 = app.genomes[arg.genome];
  if (!genomeobj2) {
    app.error0("Invalid genome: " + arg.genome);
    return;
  }
  arg.twodmaf.hostURL = app.hostURL;
  arg.twodmaf.genome = genomeobj2;
  import("./2dmaf-Z3D2M3FB.js").then((d2maf) => {
    d2maf.d2mafparseinput(arg.twodmaf, app.holder0);
  });
}
function launchmaftimeline(arg, app) {
  if (arg.maftimeline.uionly) {
    import("./maftimeline-NLZLMHT2.js").then((p) => {
      p.default(app.genomes, app.holder0, app.sandbox_header);
    });
  }
}
function launchJunctionbyMatrix(arg, app) {
  if (arg.junctionbymatrix.uionly) {
    import("./block.tk.junction.textmatrixui-4RIH3EZI.js").then((p) => {
      p.default(app.genomes, app.hostURL, arg.jwt, app.holder0);
    });
  }
}
async function launch_singlecell(arg, app) {
  try {
    const genome = app.genomes[arg.genome];
    if (!genome) throw "Invalid genome: " + arg.genome;
    arg.genome = genome;
    const _ = await import("./singlecell-RO3BL5OO.js");
    await _.init(arg, app.holder0);
  } catch (e) {
    app.error0("Error launching single cell viewer: " + e);
    if (e.stack) console.log(e.stack);
  }
}
async function launch_tkUIs(arg, app) {
  if (arg.tkui == "bigwig") {
    const p = await import("./block.tk.bigwig.ui-OSRCPTQC.js");
    p.bigwigUI(app.genomes, app.holder);
  }
  if (arg.tkui == "databrowser") {
    const p = await import("./databrowser.ui-WGD7D3XV.js");
    p.init_databrowserUI(app.holder, app.debugmode);
  }
  if (arg.tkui == "genefusion") {
    const p = await import("./genefusion.ui-ASICJNII.js");
    p.init_geneFusionUI(app.holder, app.genomes, app.debugmode);
  }
  if (arg.tkui == "disco") {
    const p = await import("./Disco.UI-IWVSK3RN.js");
    p.init_discoplotUI(app.holder, app.genomes, app.debugmode);
  }
}
async function launchtermdb(opts, app) {
  if (!opts.holder) opts.holder = app.holder0;
  import("./app-AIIN4WDE.js").then((_) => {
    _.appInit(opts);
  });
}
async function launch_genefusion(arg, app) {
  try {
    const genome = app.genomes[arg.genome];
    if (!genome) throw "Invalid genome: " + arg.genome;
    const fusionParse = await import("./fusion.parse-ARORGJ5J.js");
    const m = await fusionParse.parseFusion({
      line: arg.genefusion.text,
      genome,
      positionType: arg.genefusion.positionType
    });
    await getGm(m.pairlst[0].a, genome);
    await getGm(m.pairlst[0].b, genome);
    const _ = await import("./svgraph-QBDF2SLB.js");
    _.default({
      pairlst: m.pairlst,
      genome,
      holder: app.holder
    });
  } catch (e) {
    app.error0(e);
  }
}
async function getGm(p, genome) {
  const d = await dofetch3("genelookup", {
    body: { genome: genome.name, input: p.isoform, deep: 1 }
  });
  if (d.error) throw d.error;
  if (!Array.isArray(d.gmlst)) throw "gmlst not array";
  const u = d.gmlst.find((i) => i.isoform == p.isoform);
  if (!u) throw "no match to isoform";
  p.chr = u.chr;
  p.name = u.name;
  p.gm = { isoform: u.isoform };
}
async function launchmass(arg, app) {
  const opts = arg.mass;
  if ("debugmode" in app) opts.debug = app.debugmode;
  if (!opts.holder) opts.holder = app.holder0;
  if (opts.state) {
    if (opts.state.genome) {
      opts.genome = app.genomes[opts.state.genome];
    } else if (opts.state?.vocab?.genome) {
      opts.genome = app.genomes[opts.state.vocab.genome];
    }
  }
  opts.getDatasetAccessToken = arg.getDatasetAccessToken;
  opts.addLoginCallback = arg.addLoginCallback;
  opts.pkgver = app.pkgver;
  childCorsMessage(opts);
  const _ = await import("./app-FJT5VXMF.js");
  return await _.appInit(opts);
}
function initgenome(g) {
  g.tkset = [];
  g.isoformcache = /* @__PURE__ */ new Map();
  g.junctionframecache = /* @__PURE__ */ new Map();
  g.isoformmatch = (n2, chr, pos) => {
    if (!n2) return null;
    const n = n2.toUpperCase();
    if (!g.isoformcache.has(n)) return null;
    const lst = g.isoformcache.get(n);
    if (lst.length == 1) return lst[0];
    if (!chr) {
      console.log("no chr provided for matching with " + n);
      return lst[0];
    }
    let gm = null;
    for (const m of lst) {
      if (m.chr.toUpperCase() == chr.toUpperCase() && m.start <= pos && m.stop >= pos) {
        gm = m;
      }
    }
    if (gm) return gm;
    for (const m of lst) {
      if (m.chr.toUpperCase() == chr.toUpperCase()) return m;
    }
    return null;
  };
  g.chrlookup = {};
  for (const nn in g.majorchr) {
    g.chrlookup[nn.toUpperCase()] = { name: nn, len: g.majorchr[nn], major: true };
  }
  if (g.minorchr) {
    for (const nn in g.minorchr) {
      g.chrlookup[nn.toUpperCase()] = { name: nn, len: g.minorchr[nn] };
    }
  }
  if (!g.tracks) {
    g.tracks = [];
  }
  for (const t of g.tracks) {
    t.tkid = Math.random().toString();
  }
  for (const dsname in g.datasets) {
    const ds = g.datasets[dsname];
    if (ds.isMds) {
    } else if (ds.isMds3) {
      if (!ds.label) return "ds.label missing";
    }
  }
  return null;
}
async function launchDisco(arg, app) {
  if (!arg.genome) throw '"genome" parameter missing';
  const genomeObj = app.genomes[arg.genome];
  if (!genomeObj) throw "unknown genome";
  if (arg.disco.sample_id) {
    const vocabApi = (await import("./vocabulary-D3W44IWE.js")).vocabInit({
      state: { genome: genomeObj.name, dslabel: arg.disco.dslabel }
    });
    const termdbConfig = await vocabApi.getTermdbConfig();
    const overrides = { Disco: arg.disco?.settings || {} };
    await (await import("./plot.disco-OUE4RFHL.js")).default(termdbConfig, arg.disco.dslabel, { sample_id: arg.disco.sample_id }, app.holder, genomeObj, overrides);
    return;
  } else {
    const _ = await import("./launch.adhoc-NOISOX5E.js");
    return await _.launch(arg.disco, genomeObj, app.holder0);
  }
}
async function launchWsiViewer(arg, app) {
  if (!arg.genome) throw '"genome" parameter missing';
  const genomeObj = app.genomes[arg.genome];
  if (!genomeObj) throw "unknown genome";
  const wsiViewer = await import("./plot.wsi-2MU5BDG3.js");
  const urlParams = new URLSearchParams(window.location.search);
  const sampleId = urlParams.get("sample_id");
  if (!sampleId) {
    throw "sample-id parameter missing";
  }
  wsiViewer.default(arg.dslabel, app.holder, genomeObj, sampleId);
}

export {
  runproteinpaint,
  bindProteinPaint
};
//# sourceMappingURL=chunk-74ZU4BT6.js.map
