From 3be6e9c04ba59dcf33a53437828788e2db384510 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Fri, 25 Sep 2026 10:38:05 +0100 Subject: [PATCH 01/38] Claude suggestions for pulling VCFs from zarr datasets --- malariagen_data/anoph/to_vcf_cnv.py | 401 +++++++++++++++++++++++++++ malariagen_data/anopheles.py | 2 + tests/anoph/test_vcf_exporter_cnv.py | 234 ++++++++++++++++ 3 files changed, 637 insertions(+) create mode 100644 malariagen_data/anoph/to_vcf_cnv.py create mode 100644 tests/anoph/test_vcf_exporter_cnv.py diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py new file mode 100644 index 000000000..fbc16f520 --- /dev/null +++ b/malariagen_data/anoph/to_vcf_cnv.py @@ -0,0 +1,401 @@ +import gzip +import os +from datetime import date +from typing import List, Optional, Sequence + +import numpy as np +from numpydoc_decorator import doc # type: ignore + +from .cnv_data import AnophelesCnvData +from . import base_params +from . import cnv_params +from . import plink_params +from . import vcf_params + + +def _decode(value) -> str: + return value.decode() if hasattr(value, "decode") else str(value) + + +def _write_vcf_header( + f, + *, + contigs: Sequence[str], + sample_ids: Sequence[str], + info_lines: Sequence[str], + format_lines: Sequence[str], + alt_lines: Sequence[str] = (), +) -> None: + f.write("##fileformat=VCFv4.3\n") + f.write(f"##fileDate={date.today().strftime('%Y%m%d')}\n") + f.write("##source=malariagen_data\n") + for contig in contigs: + f.write(f"##contig=\n") + for line in alt_lines: + f.write(line + "\n") + for line in info_lines: + f.write(line + "\n") + for line in format_lines: + f.write(line + "\n") + header_cols = [ + "#CHROM", + "POS", + "ID", + "REF", + "ALT", + "QUAL", + "FILTER", + "INFO", + "FORMAT", + ] + f.write("\t".join(header_cols + list(sample_ids)) + "\n") + + +class CnvVcfExporter( + AnophelesCnvData, +): + """ + Export CNV calls to VCF. + + N.B., unlike SNP calls, CNV calls are not fully standardised in VCF. + Here each CNV region or call is written as a single symbolic `` + ALT allele (REF is written as "N", per the VCF specification for + imprecise/symbolic variants), with the relevant per-sample data + encoded in FORMAT fields. This is a draft representation intended + to give IGV something sensible to render, and to remove the + dependency on separately-hosted CNV VCF files; it is not intended + to be a fully general-purpose CNV VCF writer. + """ + + def __init__( + self, + **kwargs, + ): + # N.B., this class is designed to work cooperatively, and + # so it's important that any remaining parameters are passed + # to the superclass constructor. + super().__init__(**kwargs) + + @doc( + summary=""" + Export CNV HMM copy number calls to Variant Call Format (VCF). + """, + extended_summary=""" + This function writes genome-wide CNV HMM calls to a VCF file. + Each CNV region is written as a symbolic `` allele, with + the estimated copy number for each sample stored in the `CN` + FORMAT field. Data is written in chunks to avoid loading the + entire array into memory. Supports optional gzip compression + when the output path ends with `.gz`. + """, + returns=""" + Path to the VCF output file. + """, + ) + def cnv_hmm_to_vcf( + self, + output_path: vcf_params.vcf_output_path, + region: base_params.regions, + sample_sets: Optional[base_params.sample_sets] = None, + sample_query: Optional[base_params.sample_query] = None, + sample_query_options: Optional[base_params.sample_query_options] = None, + max_coverage_variance: cnv_params.max_coverage_variance = cnv_params.max_coverage_variance_default, + inline_array: base_params.inline_array = base_params.inline_array_default, + chunks: base_params.chunks = base_params.native_chunks, + overwrite: plink_params.overwrite = False, + ) -> str: + if os.path.exists(output_path) and not overwrite: + return output_path + + ds = self.cnv_hmm( + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + sample_query_options=sample_query_options, + max_coverage_variance=max_coverage_variance, + inline_array=inline_array, + chunks=chunks, + ) + + sample_ids = ds["sample_id"].values + contigs = ds.attrs.get("contigs", self.contigs) + compress = output_path.endswith(".gz") + opener = gzip.open if compress else open + + with opener(output_path, "wt") as f: + _write_vcf_header( + f, + contigs=contigs, + sample_ids=sample_ids, + alt_lines=[ + '##ALT=', + ], + info_lines=[ + '##INFO=', + ], + format_lines=[ + '##FORMAT=', + ], + ) + + pos_data = ds["variant_position"].data + end_data = ds["variant_end"].data + contig_data = ds["variant_contig"].data + cn_data = ds["call_CN"].data + + chunk_sizes = pos_data.chunks[0] + offsets = np.cumsum((0,) + chunk_sizes) + + with self._spinner(f"Write VCF ({ds.sizes['variants']} CNV HMM regions)"): + for ci in range(len(chunk_sizes)): + start = offsets[ci] + stop = offsets[ci + 1] + pos_chunk = pos_data[start:stop].compute() + end_chunk = end_data[start:stop].compute() + contig_chunk = contig_data[start:stop].compute() + cn_chunk = cn_data[start:stop].compute() + + lines: List[str] = [] + for j in range(pos_chunk.shape[0]): + chrom = contigs[contig_chunk[j]] + pos = str(pos_chunk[j]) + end = int(end_chunk[j]) + info = f"END={end}" + sample_fields = ( + "." if v < 0 else str(int(v)) for v in cn_chunk[j] + ) + lines.append( + f"{chrom}\t{pos}\t.\tN\t\t.\t.\t{info}\tCN\t" + + "\t".join(sample_fields) + + "\n" + ) + f.write("".join(lines)) + + return output_path + + @doc( + summary=""" + Export CNV coverage calls to Variant Call Format (VCF). + """, + extended_summary=""" + This function writes CNV coverage calls (discrete CNV alleles + called from read coverage) to a VCF file. Each CNV allele is + written as a symbolic `` allele, with the presence/absence + call for each sample stored in the `GT` FORMAT field (as a + haploid call: "1" if the CNV allele was called, "0" if not, + "." if missing). Data is written in chunks to avoid loading + the entire array into memory. Supports optional gzip + compression when the output path ends with `.gz`. + """, + returns=""" + Path to the VCF output file. + """, + ) + def cnv_coverage_calls_to_vcf( + self, + output_path: vcf_params.vcf_output_path, + region: base_params.regions, + sample_set: base_params.sample_set, + analysis: cnv_params.coverage_calls_analysis, + inline_array: base_params.inline_array = base_params.inline_array_default, + chunks: base_params.chunks = base_params.native_chunks, + overwrite: plink_params.overwrite = False, + ) -> str: + if os.path.exists(output_path) and not overwrite: + return output_path + + ds = self.cnv_coverage_calls( + region=region, + sample_set=sample_set, + analysis=analysis, + inline_array=inline_array, + chunks=chunks, + ) + + sample_ids = ds["sample_id"].values + contigs = ds.attrs.get("contigs", self.contigs) + compress = output_path.endswith(".gz") + opener = gzip.open if compress else open + + with opener(output_path, "wt") as f: + _write_vcf_header( + f, + contigs=contigs, + sample_ids=sample_ids, + alt_lines=[ + '##ALT=', + ], + info_lines=[ + '##INFO=', + '##INFO=', + '##INFO=', + ], + format_lines=[ + '##FORMAT=', + ], + ) + + pos_data = ds["variant_position"].data + end_data = ds["variant_end"].data + contig_data = ds["variant_contig"].data + id_data = ds["variant_id"].data + cipos_data = ds["variant_CIPOS"].data + ciend_data = ds["variant_CIEND"].data + filter_data = ds["variant_filter_pass"].data + gt_data = ds["call_genotype"].data + + chunk_sizes = pos_data.chunks[0] + offsets = np.cumsum((0,) + chunk_sizes) + + with self._spinner( + f"Write VCF ({ds.sizes['variants']} CNV coverage calls)" + ): + for ci in range(len(chunk_sizes)): + start = offsets[ci] + stop = offsets[ci + 1] + pos_chunk = pos_data[start:stop].compute() + end_chunk = end_data[start:stop].compute() + contig_chunk = contig_data[start:stop].compute() + id_chunk = id_data[start:stop].compute() + cipos_chunk = cipos_data[start:stop].compute() + ciend_chunk = ciend_data[start:stop].compute() + filter_chunk = filter_data[start:stop].compute() + gt_chunk = gt_data[start:stop].compute() + + lines: List[str] = [] + for j in range(pos_chunk.shape[0]): + chrom = contigs[contig_chunk[j]] + pos = str(pos_chunk[j]) + variant_id = _decode(id_chunk[j]) + end = int(end_chunk[j]) + filt = "PASS" if filter_chunk[j] else "." + info = ( + f"END={end};CIPOS={int(cipos_chunk[j])}" + f";CIEND={int(ciend_chunk[j])}" + ) + sample_fields = ( + "." if v < 0 else str(int(v)) for v in gt_chunk[j] + ) + lines.append( + f"{chrom}\t{pos}\t{variant_id}\tN\t\t.\t{filt}\t{info}\tGT\t" + + "\t".join(sample_fields) + + "\n" + ) + f.write("".join(lines)) + + return output_path + + @doc( + summary=""" + Export CNV discordant read calls to Variant Call Format (VCF). + """, + extended_summary=""" + This function writes CNV discordant read calls (CNV alleles + supported by discordant/paired-end read evidence) to a VCF + file. Each CNV allele is written as a symbolic `` allele, + with the call for each sample stored in the `GT` FORMAT field + (as a haploid call: "1" if the CNV allele was called, "0" if + not, "." if missing). Data is written in chunks to avoid + loading the entire array into memory. Supports optional gzip + compression when the output path ends with `.gz`. + """, + returns=""" + Path to the VCF output file. + """, + ) + def cnv_discordant_read_calls_to_vcf( + self, + output_path: vcf_params.vcf_output_path, + contigs: base_params.contigs, + sample_sets: Optional[base_params.sample_sets] = None, + sample_query: Optional[base_params.sample_query] = None, + sample_query_options: Optional[base_params.sample_query_options] = None, + inline_array: base_params.inline_array = base_params.inline_array_default, + chunks: base_params.chunks = base_params.native_chunks, + overwrite: plink_params.overwrite = False, + ) -> str: + if os.path.exists(output_path) and not overwrite: + return output_path + + ds = self.cnv_discordant_read_calls( + contigs=contigs, + sample_sets=sample_sets, + sample_query=sample_query, + sample_query_options=sample_query_options, + inline_array=inline_array, + chunks=chunks, + ) + + sample_ids = ds["sample_id"].values + all_contigs = ds.attrs.get("contigs", self.contigs) + compress = output_path.endswith(".gz") + opener = gzip.open if compress else open + + with opener(output_path, "wt") as f: + _write_vcf_header( + f, + contigs=all_contigs, + sample_ids=sample_ids, + alt_lines=[ + '##ALT=', + ], + info_lines=[ + '##INFO=', + '##INFO=', + '##INFO=', + '##INFO=', + ], + format_lines=[ + '##FORMAT=', + ], + ) + + pos_data = ds["variant_position"].data + end_data = ds["variant_end"].data + contig_data = ds["variant_contig"].data + id_data = ds["variant_id"].data + region_data = ds["variant_Region"].data + sbm_data = ds["variant_StartBreakpointMethod"].data + ebm_data = ds["variant_EndBreakpointMethod"].data + gt_data = ds["call_genotype"].data + + chunk_sizes = pos_data.chunks[0] + offsets = np.cumsum((0,) + chunk_sizes) + + with self._spinner( + f"Write VCF ({ds.sizes['variants']} CNV discordant read calls)" + ): + for ci in range(len(chunk_sizes)): + start = offsets[ci] + stop = offsets[ci + 1] + pos_chunk = pos_data[start:stop].compute() + end_chunk = end_data[start:stop].compute() + contig_chunk = contig_data[start:stop].compute() + id_chunk = id_data[start:stop].compute() + region_chunk = region_data[start:stop].compute() + sbm_chunk = sbm_data[start:stop].compute() + ebm_chunk = ebm_data[start:stop].compute() + gt_chunk = gt_data[start:stop].compute() + + lines: List[str] = [] + for j in range(pos_chunk.shape[0]): + chrom = all_contigs[contig_chunk[j]] + pos = str(pos_chunk[j]) + variant_id = _decode(id_chunk[j]) + end = int(end_chunk[j]) + region_val = _decode(region_chunk[j]) + info = ( + f"END={end};REGION={region_val}" + f";SBM={int(sbm_chunk[j])};EBM={int(ebm_chunk[j])}" + ) + sample_fields = ( + "." if v < 0 else str(int(v)) for v in gt_chunk[j] + ) + lines.append( + f"{chrom}\t{pos}\t{variant_id}\tN\t\t.\t.\t{info}\tGT\t" + + "\t".join(sample_fields) + + "\n" + ) + f.write("".join(lines)) + + return output_path diff --git a/malariagen_data/anopheles.py b/malariagen_data/anopheles.py index 8342dbb88..b775dad1e 100644 --- a/malariagen_data/anopheles.py +++ b/malariagen_data/anopheles.py @@ -37,6 +37,7 @@ from .anoph.to_plink import PlinkConverter from .anoph.ld import AnophelesLdAnalysis from .anoph.to_vcf import SnpVcfExporter +from .anoph.to_vcf_cnv import CnvVcfExporter from .anoph.g123 import AnophelesG123Analysis from .anoph.fst import AnophelesFstAnalysis from .anoph.h12 import AnophelesH12Analysis @@ -93,6 +94,7 @@ class AnophelesDataResource( PlinkConverter, AnophelesLdAnalysis, SnpVcfExporter, + CnvVcfExporter, AnophelesIgv, AnophelesKaryotypeAnalysis, AnophelesAimData, diff --git a/tests/anoph/test_vcf_exporter_cnv.py b/tests/anoph/test_vcf_exporter_cnv.py new file mode 100644 index 000000000..e111ce70b --- /dev/null +++ b/tests/anoph/test_vcf_exporter_cnv.py @@ -0,0 +1,234 @@ +import gzip +import os +import random + +import pytest +from pytest_cases import parametrize_with_cases + +from malariagen_data import af1 as _af1 +from malariagen_data import ag3 as _ag3 + +from malariagen_data.anoph.to_vcf_cnv import CnvVcfExporter + + +@pytest.fixture +def ag3_sim_api(ag3_sim_fixture): + return CnvVcfExporter( + url=ag3_sim_fixture.url, + public_url=ag3_sim_fixture.url, + config_path=_ag3.CONFIG_PATH, + major_version_number=_ag3.MAJOR_VERSION_NUMBER, + major_version_path=_ag3.MAJOR_VERSION_PATH, + pre=True, + aim_metadata_dtype={ + "aim_species_fraction_arab": "float64", + "aim_species_fraction_colu": "float64", + "aim_species_fraction_colu_no2l": "float64", + "aim_species_gambcolu_arabiensis": object, + "aim_species_gambiae_coluzzii": object, + "aim_species": object, + }, + gff_gene_type="gene", + gff_gene_name_attribute="Name", + gff_default_attributes=("ID", "Parent", "Name", "description"), + results_cache=ag3_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="gamb_colu", + discordant_read_calls_analysis=ag3_sim_fixture.config[ + "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" + ], + ) + + +@pytest.fixture +def af1_sim_api(af1_sim_fixture): + return CnvVcfExporter( + url=af1_sim_fixture.url, + public_url=af1_sim_fixture.url, + config_path=_af1.CONFIG_PATH, + major_version_number=_af1.MAJOR_VERSION_NUMBER, + major_version_path=_af1.MAJOR_VERSION_PATH, + pre=False, + gff_gene_type="protein_coding_gene", + gff_gene_name_attribute="Note", + gff_default_attributes=("ID", "Parent", "Note", "description"), + results_cache=af1_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="funestus", + discordant_read_calls_analysis=None, + ) + + +def case_ag3_sim(ag3_sim_fixture, ag3_sim_api): + return ag3_sim_fixture, ag3_sim_api + + +def case_af1_sim(af1_sim_fixture, af1_sim_api): + return af1_sim_fixture, af1_sim_api + + +def _check_basic_vcf_structure(output_path, expected_n_variants, expected_sample_ids): + assert os.path.exists(output_path) + + opener = gzip.open if output_path.endswith(".gz") else open + with opener(output_path, "rt") as f: + lines = f.readlines() + + header_lines = [line for line in lines if line.startswith("##")] + column_line = [line for line in lines if line.startswith("#CHROM")] + data_lines = [line for line in lines if not line.startswith("#")] + + assert header_lines[0].strip() == "##fileformat=VCFv4.3" + assert len(column_line) == 1 + + col_fields = column_line[0].strip().split("\t") + vcf_samples = col_fields[9:] + assert list(vcf_samples) == list(expected_sample_ids) + + assert len(data_lines) == expected_n_variants + + for line in data_lines: + fields = line.rstrip("\n").split("\t") + assert len(fields) == 9 + len(expected_sample_ids) + ref, alt = fields[3], fields[4] + assert ref == "N" + assert alt == "" + + return data_lines + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_to_vcf(fixture, api: CnvVcfExporter, tmp_path): + region = random.choice(api.contigs) + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) + + ds = api.cnv_hmm(region=region, sample_sets=sample_sets, max_coverage_variance=None) + n_variants = ds.sizes["variants"] + sample_ids = ds["sample_id"].values + + output_path = str(tmp_path / "test_cnv_hmm.vcf") + api.cnv_hmm_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + max_coverage_variance=None, + ) + + data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) + + # Check positions match. + vcf_positions = sorted([int(line.split("\t")[1]) for line in data_lines]) + ds_positions = sorted(ds["variant_position"].values.tolist()) + assert vcf_positions == ds_positions + + # Check FORMAT is CN. + for line in data_lines: + fields = line.rstrip("\n").split("\t") + assert fields[8] == "CN" + assert fields[7].startswith("END=") + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_coverage_calls_to_vcf(fixture, api: CnvVcfExporter, tmp_path): + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_set = random.choice(all_sample_sets) + analysis = random.choice(api.coverage_calls_analysis_ids) + region = random.choice(api.contigs) + + ds = api.cnv_coverage_calls(region=region, sample_set=sample_set, analysis=analysis) + n_variants = ds.sizes["variants"] + sample_ids = ds["sample_id"].values + + output_path = str(tmp_path / "test_cnv_coverage_calls.vcf") + api.cnv_coverage_calls_to_vcf( + output_path=output_path, + region=region, + sample_set=sample_set, + analysis=analysis, + ) + + data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) + + ds_ids = [ + v.decode() if hasattr(v, "decode") else str(v) for v in ds["variant_id"].values + ] + vcf_ids = [line.split("\t")[2] for line in data_lines] + assert sorted(vcf_ids) == sorted(ds_ids) + + for line in data_lines: + fields = line.rstrip("\n").split("\t") + assert fields[8] == "GT" + assert fields[6] in ("PASS", ".") + assert "CIPOS=" in fields[7] + assert "CIEND=" in fields[7] + for sample_val in fields[9:]: + assert sample_val in ("0", "1", ".") + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_discordant_read_calls_to_vcf(fixture, api: CnvVcfExporter, tmp_path): + contig = random.choice(api.contigs) + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) + + ds = api.cnv_discordant_read_calls(contigs=contig, sample_sets=sample_sets) + n_variants = ds.sizes["variants"] + sample_ids = ds["sample_id"].values + + output_path = str(tmp_path / "test_cnv_discordant.vcf") + api.cnv_discordant_read_calls_to_vcf( + output_path=output_path, + contigs=contig, + sample_sets=sample_sets, + ) + + data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) + + for line in data_lines: + fields = line.rstrip("\n").split("\t") + assert fields[8] == "GT" + assert "REGION=" in fields[7] + assert "SBM=" in fields[7] + assert "EBM=" in fields[7] + for sample_val in fields[9:]: + assert sample_val in ("0", "1", ".") + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_to_vcf_overwrite(fixture, api: CnvVcfExporter, tmp_path): + region = api.contigs[0] + output_path = str(tmp_path / "test_cnv_hmm.vcf") + + api.cnv_hmm_to_vcf( + output_path=output_path, region=region, max_coverage_variance=None + ) + mtime_first = os.path.getmtime(output_path) + + # Without overwrite, should return early. + api.cnv_hmm_to_vcf( + output_path=output_path, region=region, max_coverage_variance=None + ) + assert os.path.getmtime(output_path) == mtime_first + + # With overwrite, file should be rewritten. + api.cnv_hmm_to_vcf( + output_path=output_path, + region=region, + max_coverage_variance=None, + overwrite=True, + ) + assert os.path.exists(output_path) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_to_vcf_gzip(fixture, api: CnvVcfExporter, tmp_path): + region = api.contigs[0] + output_path = str(tmp_path / "test_cnv_hmm.vcf.gz") + + api.cnv_hmm_to_vcf( + output_path=output_path, region=region, max_coverage_variance=None + ) + assert os.path.exists(output_path) + + with gzip.open(output_path, "rt") as f: + first_line = f.readline() + assert first_line.strip() == "##fileformat=VCFv4.3" From 73f547f7364570f7fb9c35fa8f636f23234e72e4 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 12:53:19 +0100 Subject: [PATCH 02/38] claude suggestions for BAM-replacement, not really possible for data in zarr datasets --- malariagen_data/anoph/igv.py | 212 ++++++++++++++++++- malariagen_data/anoph/to_coverage.py | 293 +++++++++++++++++++++++++++ malariagen_data/anopheles.py | 2 + tests/anoph/conftest.py | 38 ++-- 4 files changed, 530 insertions(+), 15 deletions(-) create mode 100644 malariagen_data/anoph/to_coverage.py diff --git a/malariagen_data/anoph/igv.py b/malariagen_data/anoph/igv.py index 59680640b..19c59ca48 100644 --- a/malariagen_data/anoph/igv.py +++ b/malariagen_data/anoph/igv.py @@ -1,3 +1,4 @@ +import os from typing import List, Optional import igv_notebook # type: ignore @@ -77,11 +78,97 @@ def _igv_site_filters_tracks( tracks.append(track_config) return tracks + def _igv_local_coverage_track( + self, + *, + region: Region, + sample: str, + visibility_window: int, + source: str = "cnv_hmm", + field: str = "NormCov", + output_path: Optional[str] = None, + ): + # Build a coverage track computed locally from the Zarr arrays + # rather than loaded from an externally-hosted file. This is not + # a substitute for an alignments track (there are no individual + # reads), but gives a fallback source of coverage information + # for a sample when the BAM file is not available. Two sources + # are supported: "cnv_hmm" gives windowed coverage genome-wide; + # "snp_calls" gives per-base read depth, but only at called SNP + # sites. + # + # N.B., this method is only usable when this class is combined + # (via cooperative multiple inheritance) with CoverageExporter, + # as is the case for the top-level Ag3/Af1 data resource classes. + # Methods are accessed via getattr rather than a direct import to + # avoid adding CoverageExporter as a base class of AnophelesIgv, + # which would conflict with the method resolution order of the + # combined data resource classes. + extra_kwargs: dict + if source == "cnv_hmm": + to_bedgraph = getattr(self, "cnv_hmm_coverage_to_bedgraph", None) + extra_kwargs = dict(field=field) + track_name = f"Coverage ({field}, local) - {sample}" + path_suffix = field + elif source == "snp_calls": + to_bedgraph = getattr(self, "snp_calls_coverage_to_bedgraph", None) + extra_kwargs = dict() + track_name = f"SNP read depth (local) - {sample}" + path_suffix = "AD" + else: + raise ValueError( + f"Unknown coverage source: {source!r}. " + "Valid sources are 'cnv_hmm', 'snp_calls'." + ) + + if to_bedgraph is None: + raise NotImplementedError( + "Local coverage tracks require this API object to also " + "provide CNV and SNP data (see CoverageExporter)." + ) + + if output_path is None: + if self._results_cache is None: + raise ValueError( + "Cannot create a local coverage track without knowing " + "where to write it. Either pass `coverage_track_path`, " + "or configure `results_cache` when creating this API " + "object." + ) + safe_region = ( + str(region).replace(":", "_").replace(",", "").replace("-", "_") + ) + cache_dir = self._results_cache / "igv_coverage" + os.makedirs(cache_dir, exist_ok=True) + output_path = str( + cache_dir / f"{sample}_{safe_region}_{source}_{path_suffix}.bedgraph" + ) + + to_bedgraph( + output_path=output_path, + region=region, + sample=sample, + **extra_kwargs, + ) + + return { + "name": track_name, + "url": output_path, + "format": "bedgraph", + "type": "wig", + "visibilityWindow": visibility_window, # bp + "height": 50, + "color": "#5e3c99", + } + def _igv_view_alignments_tracks( self, region: Region, sample: str, visibility_window: int = 20_000, + local_coverage_fallback: bool = False, + coverage_source: str = "cnv_hmm", + coverage_track_path: Optional[str] = None, ): # Look up sample set for sample. try: @@ -121,7 +208,10 @@ def _igv_view_alignments_tracks( } ) - # Add alignments track. + # Add alignments track. N.B., this depends on the BAM file being + # hosted at `bam_url` and remaining reachable; if that URL stops + # working (e.g. following migration of raw data to ENA/EVA) this + # track will fail to load in the browser. tracks.append( { "name": "Alignments", @@ -134,6 +224,21 @@ def _igv_view_alignments_tracks( } ) + # Optionally also add a coverage track computed locally from CNV + # HMM or SNP calls data, as a fallback source of coverage + # information that does not depend on the alignments BAM file + # remaining available. + if local_coverage_fallback: + tracks.append( + self._igv_local_coverage_track( + region=region, + sample=sample, + visibility_window=visibility_window, + source=coverage_source, + output_path=coverage_track_path, + ) + ) + return tracks @_check_types @@ -183,6 +288,28 @@ def igv( visible. """, init="If True, call igv_notebook.init().", + local_coverage_fallback=""" + If True, also add a coverage track computed locally from + CNV HMM or SNP calls data. Unlike the alignments track, + this does not depend on the BAM file remaining available + at its hosted URL, so it provides a fallback source of + coverage information if that URL stops working. It is + not a substitute for the alignments track, since it + contains only summarised coverage values, not individual + reads. + """, + coverage_source=""" + Which data to compute the local coverage track from, if + `local_coverage_fallback` is True. "cnv_hmm" gives + windowed coverage genome-wide; "snp_calls" gives + per-base read depth, but only at called SNP sites. + """, + coverage_track_path=""" + Path to write the local coverage track file to, if + `local_coverage_fallback` is True. If not provided, + defaults to a location under `results_cache` (which must + therefore be configured). + """, ), ) def view_alignments( @@ -191,6 +318,9 @@ def view_alignments( sample: str, visibility_window: int = 20_000, init: bool = True, + local_coverage_fallback: bool = False, + coverage_source: str = "cnv_hmm", + coverage_track_path: Optional[str] = None, ): # Parse region. region_prepped: Region = _parse_single_region(self, region) @@ -201,6 +331,86 @@ def view_alignments( region=region_prepped, sample=sample, visibility_window=visibility_window, + local_coverage_fallback=local_coverage_fallback, + coverage_source=coverage_source, + coverage_track_path=coverage_track_path, + ) + + # Create IGV browser. + self.igv(region=region_prepped, tracks=tracks, init=init) + + @_check_types + @doc( + summary=""" + Launch IGV and view sequence read coverage from the given + sample, computed locally from CNV HMM or SNP calls data. + """, + extended_summary=""" + Unlike `view_alignments()`, this does not depend on an + externally-hosted BAM file, or on the WGS data catalog: + coverage is derived directly from data already available in + the Zarr arrays. It shows only summarised coverage depth, + not individual aligned reads, so it is a fallback source of + information about read coverage rather than a substitute for + viewing alignments. + """, + parameters=dict( + sample="Sample identifier.", + source=""" + Which data to compute the coverage track from. + "cnv_hmm" gives windowed coverage genome-wide; + "snp_calls" gives per-base read depth, but only at + called SNP sites. + """, + field=""" + Which coverage field to display, if `source` is + "cnv_hmm". "NormCov" is coverage normalised against a set + of reference windows; "RawCov" is unnormalised read + counts per window. Ignored if `source` is "snp_calls". + """, + visibility_window=""" + Zoom level in base pairs at which SNP data will become + visible. + """, + init="If True, call igv_notebook.init().", + output_path=""" + Path to write the local coverage track file to. If not + provided, defaults to a location under `results_cache` + (which must therefore be configured). + """, + ), + ) + def view_coverage( + self, + region: base_params.region, + sample: str, + source: str = "cnv_hmm", + field: str = "NormCov", + visibility_window: int = 20_000, + init: bool = True, + output_path: Optional[str] = None, + ): + # Parse region. + region_prepped: Region = _parse_single_region(self, region) + del region + + # Set up site filters tracks, consistent with view_alignments(). + tracks = self._igv_site_filters_tracks( + contig=region_prepped.contig, + visibility_window=visibility_window, + ) + + # Add the locally-computed coverage track. N.B., this does not + # touch the WGS data catalog or any externally-hosted files. + tracks.append( + self._igv_local_coverage_track( + region=region_prepped, + sample=sample, + visibility_window=visibility_window, + source=source, + field=field, + output_path=output_path, + ) ) # Create IGV browser. diff --git a/malariagen_data/anoph/to_coverage.py b/malariagen_data/anoph/to_coverage.py new file mode 100644 index 000000000..dc5d1c234 --- /dev/null +++ b/malariagen_data/anoph/to_coverage.py @@ -0,0 +1,293 @@ +import gzip +import os +from typing import List, Optional + +import numpy as np +from numpydoc_decorator import doc # type: ignore + +from .cnv_data import AnophelesCnvData +from .snp_data import AnophelesSnpData +from . import base_params +from . import cnv_params +from . import plink_params + +_VALID_CNV_COVERAGE_FIELDS = {"NormCov", "RawCov"} + + +def _bedgraph_opener(output_path: str): + compress = output_path.endswith(".gz") + return gzip.open if compress else open + + +class CoverageExporter( + AnophelesCnvData, + AnophelesSnpData, +): + """ + Export per-sample read coverage to bedGraph, derived either from + CNV HMM data (windowed coverage, genome-wide) or from SNP calls + (per-site read depth, only at called SNP positions). + + N.B., this does not reconstruct read alignments. It cannot + substitute for a BAM file, because the underlying Zarr arrays only + ever store windowed or per-site summary values (and copy number + calls derived from them) rather than individual reads. What this + class provides is a coverage-depth track that can be loaded into + IGV alongside (or instead of) an alignments track, as a fallback + for when the raw BAM file for a sample is not available, e.g. + because it is hosted externally and that host has become + unreachable. + """ + + def __init__( + self, + **kwargs, + ): + # N.B., this class is designed to work cooperatively, and + # so it's important that any remaining parameters are passed + # to the superclass constructor. + super().__init__(**kwargs) + + def _lookup_sample_set(self, sample: str) -> str: + try: + sample_rec = self.sample_metadata().set_index("sample_id").loc[sample] + except KeyError as e: + raise ValueError( + f"No data found for sample {sample!r}. This sample might be " + "unavailable or irrelevant with respect to settings." + ) from e + return sample_rec["sample_set"] + + @doc( + summary=""" + Export per-sample CNV HMM coverage to bedGraph format. + """, + extended_summary=""" + This function writes windowed read coverage for a single + sample, derived from CNV HMM data, to a bedGraph file. This + is not a substitute for a BAM file of aligned reads: it + contains only per-window summary coverage values (as stored + in the Zarr arrays), not individual reads. It is intended as + a fallback coverage track for IGV, for use when the aligned + reads (BAM) for a sample are not available, e.g. because the + file is hosted externally and unreachable. Coverage is + available genome-wide (in fixed-size windows), regardless of + whether any SNPs were called nearby. Data is written in + chunks to avoid loading the entire array into memory. + Supports optional gzip compression when the output path ends + with `.gz`. + """, + parameters=dict( + output_path=""" + Path to write the bedGraph output file. Use a `.gz` + extension to enable gzip compression. + """, + sample="Sample identifier.", + field=""" + Which coverage field to export. "NormCov" is coverage + normalised against a set of reference windows (comparable + between samples); "RawCov" is unnormalised read counts + per window. + """, + ), + returns=""" + Path to the bedGraph output file. + """, + ) + def cnv_hmm_coverage_to_bedgraph( + self, + output_path: str, + region: base_params.regions, + sample: str, + field: str = "NormCov", + max_coverage_variance: cnv_params.max_coverage_variance = None, + inline_array: base_params.inline_array = base_params.inline_array_default, + chunks: base_params.chunks = base_params.native_chunks, + overwrite: plink_params.overwrite = False, + ) -> str: + if field not in _VALID_CNV_COVERAGE_FIELDS: + raise ValueError( + f"Unknown coverage field: {field!r}. " + f"Valid fields are: {sorted(_VALID_CNV_COVERAGE_FIELDS)}" + ) + + if os.path.exists(output_path) and not overwrite: + return output_path + + # Look up which sample set this sample belongs to, so we only + # need to open the CNV HMM data for that one sample set. + sample_set = self._lookup_sample_set(sample) + + ds = self.cnv_hmm( + region=region, + sample_sets=sample_set, + sample_query=f"sample_id == {sample!r}", + max_coverage_variance=max_coverage_variance, + inline_array=inline_array, + chunks=chunks, + ) + + if ds.sizes["samples"] == 0: + raise ValueError( + f"No CNV HMM data available for sample {sample!r}, this may be " + "because it was excluded by max_coverage_variance." + ) + + contigs = ds.attrs.get("contigs", self.contigs) + opener = _bedgraph_opener(output_path) + + with opener(output_path, "wt") as f: + f.write( + f'track type=bedGraph name="{sample} {field}" ' + f'description="CNV HMM {field} for {sample}"\n' + ) + + pos_data = ds["variant_position"].data + end_data = ds["variant_end"].data + contig_data = ds["variant_contig"].data + cov_data = ds[f"call_{field}"].data + + chunk_sizes = pos_data.chunks[0] + offsets = np.cumsum((0,) + chunk_sizes) + + with self._spinner( + f"Write bedGraph ({ds.sizes['variants']} coverage windows)" + ): + for ci in range(len(chunk_sizes)): + start = offsets[ci] + stop = offsets[ci + 1] + pos_chunk = pos_data[start:stop].compute() + end_chunk = end_data[start:stop].compute() + contig_chunk = contig_data[start:stop].compute() + # Select the single requested sample's coverage + # column from the already-materialised chunk, rather + # than indexing the dask/zarr array before compute, + # which can trigger a less efficient (and, for + # arrays with unwritten/fill-value chunks, buggy) + # orthogonal-selection code path. + cov_chunk = cov_data[start:stop].compute()[:, 0] + + lines: List[str] = [] + for j in range(pos_chunk.shape[0]): + v = cov_chunk[j] + if v < 0: + # Masked/missing value, skip rather than + # write a misleading zero. + continue + chrom = contigs[contig_chunk[j]] + # bedGraph coordinates are 0-based, half-open; + # variant_position is 1-based inclusive. + bed_start = int(pos_chunk[j]) - 1 + bed_end = int(end_chunk[j]) + lines.append(f"{chrom}\t{bed_start}\t{bed_end}\t{v}\n") + f.write("".join(lines)) + + return output_path + + @doc( + summary=""" + Export per-sample SNP read depth to bedGraph format. + """, + extended_summary=""" + This function writes read depth at called SNP sites for a + single sample, derived from the allele depth (`AD`) field of + SNP calls, to a bedGraph file. Unlike + `cnv_hmm_coverage_to_bedgraph()`, this only has a value at + positions where a SNP was called, not genome-wide, but gives + higher-resolution, per-base depth in those locations rather + than a windowed summary. This is not a substitute for a BAM + file of aligned reads. It is intended as a fallback coverage + track for IGV, for use when the aligned reads (BAM) for a + sample are not available, e.g. because the file is hosted + externally and unreachable. Data is written in chunks to + avoid loading the entire array into memory. Supports + optional gzip compression when the output path ends with + `.gz`. + """, + parameters=dict( + output_path=""" + Path to write the bedGraph output file. Use a `.gz` + extension to enable gzip compression. + """, + sample="Sample identifier.", + ), + returns=""" + Path to the bedGraph output file. + """, + ) + def snp_calls_coverage_to_bedgraph( + self, + output_path: str, + region: base_params.regions, + sample: str, + site_mask: Optional[base_params.site_mask] = None, + inline_array: base_params.inline_array = base_params.inline_array_default, + chunks: base_params.chunks = base_params.native_chunks, + overwrite: plink_params.overwrite = False, + ) -> str: + if os.path.exists(output_path) and not overwrite: + return output_path + + # Look up which sample set this sample belongs to, so we only + # need to open the SNP calls data for that one sample set. + sample_set = self._lookup_sample_set(sample) + + ds = self.snp_calls( + region=region, + sample_sets=sample_set, + sample_query=f"sample_id == {sample!r}", + site_mask=site_mask, + inline_array=inline_array, + chunks=chunks, + ) + + if ds.sizes["samples"] == 0: + raise ValueError(f"No SNP calls data available for sample {sample!r}.") + + contigs = ds.attrs.get("contigs", self.contigs) + opener = _bedgraph_opener(output_path) + + with opener(output_path, "wt") as f: + f.write( + f'track type=bedGraph name="{sample} SNP depth" ' + f'description="SNP read depth (sum of AD) for {sample}"\n' + ) + + pos_data = ds["variant_position"].data + contig_data = ds["variant_contig"].data + ad_data = ds["call_AD"].data + + chunk_sizes = pos_data.chunks[0] + offsets = np.cumsum((0,) + chunk_sizes) + + with self._spinner(f"Write bedGraph ({ds.sizes['variants']} SNP sites)"): + for ci in range(len(chunk_sizes)): + start = offsets[ci] + stop = offsets[ci + 1] + pos_chunk = pos_data[start:stop].compute() + contig_chunk = contig_data[start:stop].compute() + # Select the single requested sample's allele depth + # values from the already-materialised chunk, rather + # than indexing the dask/zarr array before compute + # (see the equivalent comment in + # cnv_hmm_coverage_to_bedgraph). + ad_chunk = ad_data[start:stop].compute()[:, 0, :] + + lines: List[str] = [] + for j in range(pos_chunk.shape[0]): + ad_row = ad_chunk[j] + if np.all(ad_row < 0): + # No call for this sample at this site, skip + # rather than write a misleading zero. + continue + depth = int(np.clip(ad_row, 0, None).sum()) + chrom = contigs[contig_chunk[j]] + # bedGraph coordinates are 0-based, half-open; + # variant_position is 1-based, and each SNP is a + # single base position. + bed_start = int(pos_chunk[j]) - 1 + bed_end = int(pos_chunk[j]) + lines.append(f"{chrom}\t{bed_start}\t{bed_end}\t{depth}\n") + f.write("".join(lines)) + + return output_path diff --git a/malariagen_data/anopheles.py b/malariagen_data/anopheles.py index b775dad1e..6d0cf6940 100644 --- a/malariagen_data/anopheles.py +++ b/malariagen_data/anopheles.py @@ -38,6 +38,7 @@ from .anoph.ld import AnophelesLdAnalysis from .anoph.to_vcf import SnpVcfExporter from .anoph.to_vcf_cnv import CnvVcfExporter +from .anoph.to_coverage import CoverageExporter from .anoph.g123 import AnophelesG123Analysis from .anoph.fst import AnophelesFstAnalysis from .anoph.h12 import AnophelesH12Analysis @@ -95,6 +96,7 @@ class AnophelesDataResource( AnophelesLdAnalysis, SnpVcfExporter, CnvVcfExporter, + CoverageExporter, AnophelesIgv, AnophelesKaryotypeAnalysis, AnophelesAimData, diff --git a/tests/anoph/conftest.py b/tests/anoph/conftest.py index f94768ad3..d3cfd0174 100644 --- a/tests/anoph/conftest.py +++ b/tests/anoph/conftest.py @@ -444,20 +444,30 @@ def simulate_snp_genotypes( gt_chunks = (contig_n_sites // 5, n_samples // 3, None) calldata.create_dataset(name="GT", data=gt, chunks=gt_chunks) - # Create other arrays - these are never actually used currently - # so we'll create some empty arrays to avoid delaying the tests. - calldata.create_dataset( - name="GQ", shape=(contig_n_sites, n_samples), dtype="i1", fill_value=-1 - ) - calldata.create_dataset( - name="MQ", shape=(contig_n_sites, n_samples), dtype="f4", fill_value=-1 - ) - calldata.create_dataset( - name="AD", - shape=(contig_n_sites, n_samples, 4), - dtype="i2", - fill_value=-1, - ) + # Simulate GQ, MQ and AD arrays with real (if arbitrary) values, + # reusing the missing call mask from GT above, rather than + # leaving them as constant fill-value arrays. A fill-value-only + # zarr array has no chunks actually written to the underlying + # store, and SafeStore (see malariagen_data/util.py) deliberately + # raises rather than silently substituting the fill value for an + # unwritten chunk, so code that fully computes these fields + # (e.g. VCF/coverage export) would otherwise hit a spurious + # FileNotFoundError against this fixture despite there being + # nothing wrong with the real data. + loc_missing_2d = loc_missing.reshape(contig_n_sites, n_samples) + + gq = rng.integers(low=0, high=100, size=(contig_n_sites, n_samples), dtype="i1") + gq[loc_missing_2d] = -1 + calldata.create_dataset(name="GQ", data=gq) + + mq = rng.uniform(low=20, high=60, size=(contig_n_sites, n_samples)).astype("f4") + calldata.create_dataset(name="MQ", data=mq) + + ad = rng.integers( + low=0, high=50, size=(contig_n_sites, n_samples, 4), dtype="i2" + ) + ad[loc_missing_2d] = -1 + calldata.create_dataset(name="AD", data=ad) zarr.consolidate_metadata(zarr_path) From b2651bc2bcd58cf4117ee26f140d49d4b98bf40e Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 16:21:08 +0100 Subject: [PATCH 03/38] don't allow None for sample_sets or sample_query in to_vcf --- malariagen_data/anoph/to_vcf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 4a942fbb2..623539aba 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -51,8 +51,10 @@ def snp_calls_to_vcf( self, output_path: vcf_params.vcf_output_path, region: base_params.regions, - sample_sets: Optional[base_params.sample_sets] = None, - sample_query: Optional[base_params.sample_query] = None, + sample_sets: Optional[base_params.sample_sets], + sample_query: Optional[ + base_params.sample_query + ], # must be of form f"sample_id == '{sample_id}'" sample_query_options: Optional[base_params.sample_query_options] = None, sample_indices: Optional[base_params.sample_indices] = None, site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, From 837260ded751e1364d7c615511d865d1ba21b361 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 16:39:16 +0100 Subject: [PATCH 04/38] remove optional from sample_Sets and sample_query --- malariagen_data/anoph/to_vcf.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 623539aba..2d18c2840 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -51,10 +51,8 @@ def snp_calls_to_vcf( self, output_path: vcf_params.vcf_output_path, region: base_params.regions, - sample_sets: Optional[base_params.sample_sets], - sample_query: Optional[ - base_params.sample_query - ], # must be of form f"sample_id == '{sample_id}'" + sample_sets: base_params.sample_sets, + sample_query: base_params.sample_query, # must be of form f"sample_id == '{sample_id}'" sample_query_options: Optional[base_params.sample_query_options] = None, sample_indices: Optional[base_params.sample_indices] = None, site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, From 8d0d336836640da7653f702c94409968531bcfe9 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 17:12:26 +0100 Subject: [PATCH 05/38] claude fixes for tests making sample_sets and sample_Wuery non-optional --- tests/anoph/test_vcf_exporter.py | 85 ++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 4 deletions(-) diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 7635f536f..b78969329 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -64,16 +64,29 @@ def case_af1_sim(af1_sim_fixture, af1_sim_api): return af1_sim_fixture, af1_sim_api +def _pick_single_sample_query(api: SnpVcfExporter, sample_sets): + """Pick one sample from the given sample sets and build a + `sample_query` that scopes a VCF export down to just that sample, + which is the only supported usage of `snp_calls_to_vcf()` (it is + used to generate a single-sample VCF for IGV).""" + df_samples = api.sample_metadata(sample_sets=sample_sets) + sample_id = str(df_samples["sample_id"].iloc[0]) + sample_query = f"sample_id == '{sample_id}'" + return sample_id, sample_query + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): region = random.choice(api.contigs) all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) site_mask = random.choice((None,) + api.site_mask_ids) + sample_id, sample_query = _pick_single_sample_query(api, sample_sets) data_params = dict( region=region, sample_sets=sample_sets, + sample_query=sample_query, site_mask=site_mask, ) @@ -81,6 +94,12 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): n_variants = ds.sizes["variants"] sample_ids = ds["sample_id"].values + # snp_calls_to_vcf() only supports exporting a single sample at a + # time (its only current use case is generating a per-sample VCF + # for IGV), so sample_query must narrow the dataset down to one + # sample. + assert list(sample_ids) == [sample_id] + output_path = str(tmp_path / "test.vcf") api.snp_calls_to_vcf(output_path=output_path, **data_params) @@ -119,29 +138,77 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): ), f"byte-string repr in REF/ALT: REF={ref!r} ALT={alt!r}" +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_requires_sample_sets_and_query( + fixture, api: SnpVcfExporter, tmp_path +): + # sample_sets and sample_query are required: a VCF without an + # explicit cohort/sample basis for the calls it contains is not + # meaningful. + region = api.contigs[0] + output_path = str(tmp_path / "test_missing_args.vcf") + + with pytest.raises(TypeError): + api.snp_calls_to_vcf(output_path=output_path, region=region) # type: ignore[call-arg] + + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + with pytest.raises(TypeError): + api.snp_calls_to_vcf( # type: ignore[call-arg] + output_path=output_path, region=region, sample_sets=sample_sets + ) + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_overwrite(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) output_path = str(tmp_path / "test.vcf") - api.snp_calls_to_vcf(output_path=output_path, region=region) + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) mtime_first = os.path.getmtime(output_path) # Without overwrite, should return early. - api.snp_calls_to_vcf(output_path=output_path, region=region) + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) assert os.path.getmtime(output_path) == mtime_first # With overwrite, file should be rewritten. - api.snp_calls_to_vcf(output_path=output_path, region=region, overwrite=True) + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + overwrite=True, + ) assert os.path.exists(output_path) @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_gzip(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) output_path = str(tmp_path / "test.vcf.gz") - api.snp_calls_to_vcf(output_path=output_path, region=region) + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) assert os.path.exists(output_path) # Verify it's valid gzip. @@ -153,12 +220,17 @@ def test_vcf_exporter_gzip(fixture, api: SnpVcfExporter, tmp_path): @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) # Test with additional FORMAT fields. output_path = str(tmp_path / "test_fields.vcf") api.snp_calls_to_vcf( output_path=output_path, region=region, + sample_sets=sample_sets, + sample_query=sample_query, fields=("GT", "GQ"), ) @@ -186,11 +258,16 @@ def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) output_path = str(tmp_path / "test_no_gt.vcf") with pytest.raises(ValueError, match="GT must be included"): api.snp_calls_to_vcf( output_path=output_path, region=region, + sample_sets=sample_sets, + sample_query=sample_query, fields=("GQ",), ) From a302a13be73513301bddaec77c72dad50ef6c515 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 17:20:53 +0100 Subject: [PATCH 06/38] updated doctring re sample_sets and sample_query --- malariagen_data/anoph/to_vcf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 2d18c2840..12a4cc79b 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -42,6 +42,15 @@ def __init__( in chunks to avoid loading the entire genotype matrix into memory. Supports optional gzip compression when the output path ends with `.gz`. + + Sample query must be in a format that can be used against the + sample_metadata() dataframe. Sample set must be specified and + the query should return at least one sample for that sample set + As the current use case for this funcitonality, it is strongly + recommended that sample_query is in the format + f"sample_id == '\{sample_id\}'" - thus specifying a single + sample. + """, returns=""" Path to the VCF output file. @@ -52,7 +61,7 @@ def snp_calls_to_vcf( output_path: vcf_params.vcf_output_path, region: base_params.regions, sample_sets: base_params.sample_sets, - sample_query: base_params.sample_query, # must be of form f"sample_id == '{sample_id}'" + sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, sample_indices: Optional[base_params.sample_indices] = None, site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, From bc181eab13d5f64bb42cac2e2af3673b8f246ddd Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 17:26:36 +0100 Subject: [PATCH 07/38] claude draft input validation --- malariagen_data/anoph/to_vcf.py | 62 +++++++++++++++++++++++++ tests/anoph/test_vcf_exporter.py | 80 ++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 12a4cc79b..74f3ae91b 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -1,5 +1,6 @@ import gzip import os +import re from datetime import date from typing import Optional @@ -20,6 +21,47 @@ "MQ": '##FORMAT=', } +# snp_calls_to_vcf() only supports exporting a single sample at a time +# (its current use case is generating a per-sample VCF for IGV), so +# sample_query must be of the form "sample_id == ''". +_SINGLE_SAMPLE_QUERY_PATTERN = re.compile( + r"""^\s*sample_id\s*==\s*(['"])[^'"]+\1\s*$""" +) + + +def _validate_single_sample_selection( + *, + sample_sets: base_params.sample_sets, + sample_query: base_params.sample_query, +) -> None: + """ + Validate that `sample_sets` and `sample_query` are provided and + together specify a single sample, which is the only usage that + `snp_calls_to_vcf()` currently supports. A VCF file is only + meaningful with respect to an explicit sample basis for its calls, + so both parameters are required; and because the only current use + case is generating a per-sample VCF for IGV, `sample_query` is + required to select exactly one sample. + """ + if not sample_sets: + raise ValueError( + "sample_sets must be provided and non-empty: a VCF must be " + "generated against an explicit set of samples." + ) + if not sample_query or not sample_query.strip(): + raise ValueError( + "sample_query must be provided and non-empty, and must " + "select a single sample (see snp_calls_to_vcf() docs)." + ) + if not _SINGLE_SAMPLE_QUERY_PATTERN.match(sample_query): + raise ValueError( + f"sample_query {sample_query!r} does not select a single " + "sample. snp_calls_to_vcf() only supports exporting a " + "single sample at a time (its current use case is " + "generating a per-sample VCF for IGV); sample_query must be " + "of the form \"sample_id == ''\"." + ) + class SnpVcfExporter( AnophelesSnpData, @@ -73,6 +115,9 @@ def snp_calls_to_vcf( base_params._validate_sample_selection_params( sample_query=sample_query, sample_indices=sample_indices ) + _validate_single_sample_selection( + sample_sets=sample_sets, sample_query=sample_query + ) # Validate fields parameter. fields = tuple(fields) @@ -99,6 +144,23 @@ def snp_calls_to_vcf( chunks=chunks, ) + # sample_query is validated above to be of the single-sample + # form "sample_id == ''", but that only checks the + # shape of the query string. Confirm it actually resolved to + # exactly one sample within the given sample_sets — zero would + # mean the sample_id wasn't found (e.g. a typo, or the sample is + # not part of the given sample_sets); more than one should not + # be possible with an equality query on a unique identifier, but + # is checked defensively rather than silently written out as a + # multi-sample VCF. + n_samples_selected = ds.sizes["samples"] + if n_samples_selected != 1: + raise ValueError( + f"sample_query {sample_query!r} selected " + f"{n_samples_selected} samples from sample_sets " + f"{sample_sets!r}, expected exactly 1." + ) + sample_ids = ds["sample_id"].values contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index b78969329..7ea33a846 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -159,6 +159,86 @@ def test_vcf_exporter_requires_sample_sets_and_query( ) +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_empty_sample_sets(fixture, api: SnpVcfExporter, tmp_path): + region = api.contigs[0] + output_path = str(tmp_path / "test_empty_sample_sets.vcf") + + with pytest.raises(ValueError, match="sample_sets must be provided"): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=[], + sample_query="sample_id == 'anything'", + ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_empty_sample_query(fixture, api: SnpVcfExporter, tmp_path): + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + output_path = str(tmp_path / "test_empty_sample_query.vcf") + + with pytest.raises(ValueError, match="sample_query must be provided"): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query="", + ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_multi_sample_query_rejected( + fixture, api: SnpVcfExporter, tmp_path +): + # sample_query must select a single sample via equality on + # sample_id; a query that could match more than one sample (even a + # syntactically simple one like a country filter) is rejected + # up front, before touching any data. + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + output_path = str(tmp_path / "test_multi_sample_query.vcf") + + for bad_query in [ + "country == 'Uganda'", + "sample_id in ['AB0085-C', 'AB0086-C']", + "sample_id != 'AB0085-C'", + ]: + with pytest.raises(ValueError, match="does not select a single sample"): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=bad_query, + ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_sample_query_matches_zero_samples( + fixture, api: SnpVcfExporter, tmp_path +): + # A query in the right shape but for a sample_id that isn't part of + # the given sample_sets should still be rejected, not silently + # produce a zero-sample VCF. In practice snp_calls() itself already + # raises for a query matching no samples, before our own post-hoc + # sample-count check ever runs; either way this must not succeed. + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + output_path = str(tmp_path / "test_zero_sample_query.vcf") + + with pytest.raises(ValueError): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query="sample_id == 'not_a_real_sample_id'", + ) + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_overwrite(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] From 317c2b0326c339eec25f74c1c4ad8a9a11412219 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 28 Sep 2026 17:29:53 +0100 Subject: [PATCH 08/38] updated docstring to specify only one sample can be used- can revisit later if usage expands beyond IGV --- malariagen_data/anoph/to_vcf.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 74f3ae91b..e1c80a2a2 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -85,14 +85,14 @@ def __init__( memory. Supports optional gzip compression when the output path ends with `.gz`. - Sample query must be in a format that can be used against the - sample_metadata() dataframe. Sample set must be specified and - the query should return at least one sample for that sample set - As the current use case for this funcitonality, it is strongly - recommended that sample_query is in the format - f"sample_id == '\{sample_id\}'" - thus specifying a single - sample. - + `sample_sets` and `sample_query` are both required: a VCF is + only meaningful with respect to an explicit sample basis for + its calls. The current use case for this functionality is + generating a single-sample VCF for IGV, so `sample_query` is + required to select exactly one sample, and must be of the + form `"sample_id == ''"`. Any other query (e.g. + selecting samples by cohort, or more than one sample_id) is + rejected. """, returns=""" Path to the VCF output file. From cf3e6b6e8fc0cc6da9c4e66531df51ba2b705c47 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 09:49:19 +0100 Subject: [PATCH 09/38] claude suggested changes to batch call rather than separate for each chunk --- malariagen_data/anoph/to_vcf.py | 65 ++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index e1c80a2a2..98d3580d9 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -4,6 +4,7 @@ from datetime import date from typing import Optional +import dask import numpy as np from numpydoc_decorator import doc # type: ignore @@ -223,33 +224,63 @@ def snp_calls_to_vcf( chunk_sizes = gt_data.chunks[0] offsets = np.cumsum((0,) + chunk_sizes) + # Which optional fields were requested, so we know what to + # fetch (and where to put the results) for each chunk below. + optional_names = [] + optional_arrays = [] + if gq_data is not None: + optional_names.append("GQ") + optional_arrays.append(gq_data) + if ad_data is not None: + optional_names.append("AD") + optional_arrays.append(ad_data) + if mq_data is not None: + optional_names.append("MQ") + optional_arrays.append(mq_data) + # Write records in chunks. with self._spinner(f"Write VCF ({ds.sizes['variants']} variants)"): for ci in range(len(chunk_sizes)): start = offsets[ci] stop = offsets[ci + 1] - gt_chunk = gt_data[start:stop].compute() - pos_chunk = pos_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - allele_chunk = allele_data[start:stop].compute() - # Compute optional field chunks, handling missing data. + # Fetch the required arrays for this chunk in a + # single batched call, rather than one .compute() + # call per array. Each separate .compute() call is + # its own blocking round trip to the underlying + # store (e.g. GCS); batching lets dask fetch all of + # them concurrently instead of one at a time, which + # matters a lot for a remote store and can be the + # difference between a fast export and one that + # takes hours longer than it needs to. + gt_chunk, pos_chunk, contig_chunk, allele_chunk = dask.compute( + gt_data[start:stop], + pos_data[start:stop], + contig_data[start:stop], + allele_data[start:stop], + ) + + # Fetch any requested optional fields for this chunk, + # again as a single batched call. If any of them + # fail to load, fall back to "." for all requested + # optional fields in this chunk (rather than only + # the one that failed) — these arrays live in the + # same region of the same store, so a failure + # affecting one is likely to affect the others too, + # and batching the fallback is the price of batching + # the fetch. gq_chunk = None ad_chunk = None mq_chunk = None - if gq_data is not None: - try: - gq_chunk = gq_data[start:stop].compute() - except (FileNotFoundError, KeyError): - pass - if ad_data is not None: - try: - ad_chunk = ad_data[start:stop].compute() - except (FileNotFoundError, KeyError): - pass - if mq_data is not None: + if optional_arrays: try: - mq_chunk = mq_data[start:stop].compute() + computed = dask.compute( + *(arr[start:stop] for arr in optional_arrays) + ) + optional_chunks = dict(zip(optional_names, computed)) + gq_chunk = optional_chunks.get("GQ") + ad_chunk = optional_chunks.get("AD") + mq_chunk = optional_chunks.get("MQ") except (FileNotFoundError, KeyError): pass From 50d620e2bf1d04852227b5aa199f69dc446e71d9 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 10:50:58 +0100 Subject: [PATCH 10/38] removed the numpy array that is edited through a loop- i.e. not a vectorised implementation, noticed in diff igv.ipynb had changed due to me running it previously, restored to original state and added nbstripout to pre-commit hooks to prevent this happening in future --- .pre-commit-config.yaml | 12 + malariagen_data/anoph/to_vcf.py | 44 +- notebooks/igv.ipynb | 3764 +------------------------------ 3 files changed, 65 insertions(+), 3755 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34d8c53c1..cb9d17692 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,3 +16,15 @@ repos: - "--fix" # Run the formatter. - id: ruff-format + - repo: https://github.com/kynan/nbstripout + rev: 0.9.1 + hooks: + # Strip outputs, execution counts and volatile metadata (kernel + # display name, language version — these change depending on + # which local environment a notebook was last run under, not on + # any real edit) from notebooks before they're committed, so + # `git diff` only shows real cell-source changes. + - id: nbstripout + args: + - "--extra-keys" + - "metadata.kernelspec.display_name metadata.language_info.version" diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 98d3580d9..132386520 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -145,15 +145,10 @@ def snp_calls_to_vcf( chunks=chunks, ) - # sample_query is validated above to be of the single-sample - # form "sample_id == ''", but that only checks the - # shape of the query string. Confirm it actually resolved to - # exactly one sample within the given sample_sets — zero would - # mean the sample_id wasn't found (e.g. a typo, or the sample is - # not part of the given sample_sets); more than one should not - # be possible with an equality query on a unique identifier, but - # is checked defensively rather than silently written out as a - # multi-sample VCF. + # Confirm inputs actually resolved to exactly + # one sample within the given sample_sets + # checked defensively rather than silently written + # out as a multi-sample VCF. n_samples_selected = ds.sizes["samples"] if n_samples_selected != 1: raise ValueError( @@ -249,10 +244,7 @@ def snp_calls_to_vcf( # call per array. Each separate .compute() call is # its own blocking round trip to the underlying # store (e.g. GCS); batching lets dask fetch all of - # them concurrently instead of one at a time, which - # matters a lot for a remote store and can be the - # difference between a fast export and one that - # takes hours longer than it needs to. + # them concurrently instead of one at a time gt_chunk, pos_chunk, contig_chunk, allele_chunk = dask.compute( gt_data[start:stop], pos_data[start:stop], @@ -260,15 +252,12 @@ def snp_calls_to_vcf( allele_data[start:stop], ) - # Fetch any requested optional fields for this chunk, - # again as a single batched call. If any of them - # fail to load, fall back to "." for all requested - # optional fields in this chunk (rather than only - # the one that failed) — these arrays live in the - # same region of the same store, so a failure + # Fetch requested optional fields for this chunk + # as a single batched call. If any of them fail + # to load, fall back to "." for all requested + # optional fields in this chunk — these arrays live + # in the same region of the same store, so a failure # affecting one is likely to affect the others too, - # and batching the fallback is the price of batching - # the fetch. gq_chunk = None ad_chunk = None mq_chunk = None @@ -336,7 +325,16 @@ def snp_calls_to_vcf( f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\t.\t{format_str}\t" ) - sample_fields = np.empty(n_samples, dtype=object) + # N.B., a plain Python list here, not a NumPy + # array: this loop builds a handful of short + # strings per variant via ordinary Python string + # concatenation, not a numeric/vectorized + # operation, so a `np.empty(..., dtype=object)` + # array bought nothing but the overhead of a + # NumPy allocation on every single variant row + # (up to ~150 million times for a whole-genome + # export). + sample_fields = [] # Use pre-formatted GT strings and add other fields for k in range(n_samples): @@ -367,7 +365,7 @@ def snp_calls_to_vcf( parts.append("." if v < 0 else str(v)) else: parts.append(".") - sample_fields[k] = ":".join(parts) + sample_fields.append(":".join(parts)) # Build and buffer the line line = fixed_cols + "\t".join(sample_fields) + "\n" diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index dea51f0bb..104f217f0 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -2,8 +2,8 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, - "id": "07b16c04", + "execution_count": null, + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -12,420 +12,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "1c7ecf7a", + "execution_count": null, + "id": "1", "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "'use strict';\n", - "(function(root) {\n", - " function now() {\n", - " return new Date();\n", - " }\n", - "\n", - " const force = true;\n", - "\n", - " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n", - " root._bokeh_onload_callbacks = [];\n", - " root._bokeh_is_loading = undefined;\n", - " }\n", - "\n", - "const JS_MIME_TYPE = 'application/javascript';\n", - " const HTML_MIME_TYPE = 'text/html';\n", - " const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", - " const CLASS_NAME = 'output_bokeh rendered_html';\n", - "\n", - " /**\n", - " * Render data to the DOM node\n", - " */\n", - " function render(props, node) {\n", - " const script = document.createElement(\"script\");\n", - " node.appendChild(script);\n", - " }\n", - "\n", - " /**\n", - " * Handle when an output is cleared or removed\n", - " */\n", - " function handleClearOutput(event, handle) {\n", - " function drop(id) {\n", - " const view = Bokeh.index.get_by_id(id)\n", - " if (view != null) {\n", - " view.model.document.clear()\n", - " Bokeh.index.delete(view)\n", - " }\n", - " }\n", - "\n", - " const cell = handle.cell;\n", - "\n", - " const id = cell.output_area._bokeh_element_id;\n", - " const server_id = cell.output_area._bokeh_server_id;\n", - "\n", - " // Clean up Bokeh references\n", - " if (id != null) {\n", - " drop(id)\n", - " }\n", - "\n", - " if (server_id !== undefined) {\n", - " // Clean up Bokeh references\n", - " const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", - " cell.notebook.kernel.execute(cmd_clean, {\n", - " iopub: {\n", - " output: function(msg) {\n", - " const id = msg.content.text.trim()\n", - " drop(id)\n", - " }\n", - " }\n", - " });\n", - " // Destroy server and session\n", - " const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", - " cell.notebook.kernel.execute(cmd_destroy);\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Handle when a new output is added\n", - " */\n", - " function handleAddOutput(event, handle) {\n", - " const output_area = handle.output_area;\n", - " const output = handle.output;\n", - "\n", - " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", - " if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n", - " return\n", - " }\n", - "\n", - " const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", - "\n", - " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", - " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", - " // store reference to embed id on output_area\n", - " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", - " }\n", - " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", - " const bk_div = document.createElement(\"div\");\n", - " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", - " const script_attrs = bk_div.children[0].attributes;\n", - " for (let i = 0; i < script_attrs.length; i++) {\n", - " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", - " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n", - " }\n", - " // store reference to server id on output_area\n", - " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", - " }\n", - " }\n", - "\n", - " function register_renderer(events, OutputArea) {\n", - "\n", - " function append_mime(data, metadata, element) {\n", - " // create a DOM node to render to\n", - " const toinsert = this.create_output_subarea(\n", - " metadata,\n", - " CLASS_NAME,\n", - " EXEC_MIME_TYPE\n", - " );\n", - " this.keyboard_manager.register_events(toinsert);\n", - " // Render to node\n", - " const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", - " render(props, toinsert[toinsert.length - 1]);\n", - " element.append(toinsert);\n", - " return toinsert\n", - " }\n", - "\n", - " /* Handle when an output is cleared or removed */\n", - " events.on('clear_output.CodeCell', handleClearOutput);\n", - " events.on('delete.Cell', handleClearOutput);\n", - "\n", - " /* Handle when a new output is added */\n", - " events.on('output_added.OutputArea', handleAddOutput);\n", - "\n", - " /**\n", - " * Register the mime type and append_mime function with output_area\n", - " */\n", - " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", - " /* Is output safe? */\n", - " safe: true,\n", - " /* Index of renderer in `output_area.display_order` */\n", - " index: 0\n", - " });\n", - " }\n", - "\n", - " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", - " if (root.Jupyter !== undefined) {\n", - " const events = require('base/js/events');\n", - " const OutputArea = require('notebook/js/outputarea').OutputArea;\n", - "\n", - " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", - " register_renderer(events, OutputArea);\n", - " }\n", - " }\n", - " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", - " root._bokeh_timeout = Date.now() + 5000;\n", - " root._bokeh_failed_load = false;\n", - " }\n", - "\n", - " const NB_LOAD_WARNING = {'data': {'text/html':\n", - " \"
\\n\"+\n", - " \"

\\n\"+\n", - " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", - " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", - " \"

\\n\"+\n", - " \"
    \\n\"+\n", - " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", - " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", - " \"
\\n\"+\n", - " \"\\n\"+\n", - " \"from bokeh.resources import INLINE\\n\"+\n", - " \"output_notebook(resources=INLINE)\\n\"+\n", - " \"\\n\"+\n", - " \"
\"}};\n", - "\n", - " function display_loaded(error = null) {\n", - " const el = document.getElementById(null);\n", - " if (el != null) {\n", - " const html = (() => {\n", - " if (typeof root.Bokeh === \"undefined\") {\n", - " if (error == null) {\n", - " return \"BokehJS is loading ...\";\n", - " } else {\n", - " return \"BokehJS failed to load.\";\n", - " }\n", - " } else {\n", - " const prefix = `BokehJS ${root.Bokeh.version}`;\n", - " if (error == null) {\n", - " return `${prefix} successfully loaded.`;\n", - " } else {\n", - " return `${prefix} encountered errors while loading and may not function as expected.`;\n", - " }\n", - " }\n", - " })();\n", - " el.innerHTML = html;\n", - "\n", - " if (error != null) {\n", - " const wrapper = document.createElement(\"div\");\n", - " wrapper.style.overflow = \"auto\";\n", - " wrapper.style.height = \"5em\";\n", - " wrapper.style.resize = \"vertical\";\n", - " const content = document.createElement(\"div\");\n", - " content.style.fontFamily = \"monospace\";\n", - " content.style.whiteSpace = \"pre-wrap\";\n", - " content.style.backgroundColor = \"rgb(255, 221, 221)\";\n", - " content.textContent = error.stack ?? error.toString();\n", - " wrapper.append(content);\n", - " el.append(wrapper);\n", - " }\n", - " } else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(() => display_loaded(error), 100);\n", - " }\n", - " }\n", - "\n", - " function run_callbacks() {\n", - " try {\n", - " root._bokeh_onload_callbacks.forEach(function(callback) {\n", - " if (callback != null)\n", - " callback();\n", - " });\n", - " } finally {\n", - " delete root._bokeh_onload_callbacks\n", - " }\n", - " console.debug(\"Bokeh: all callbacks have finished\");\n", - " }\n", - "\n", - " function load_libs(css_urls, js_urls, callback) {\n", - " if (css_urls == null) css_urls = [];\n", - " if (js_urls == null) js_urls = [];\n", - "\n", - " root._bokeh_onload_callbacks.push(callback);\n", - " if (root._bokeh_is_loading > 0) {\n", - " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", - " return null;\n", - " }\n", - " if (js_urls == null || js_urls.length === 0) {\n", - " run_callbacks();\n", - " return null;\n", - " }\n", - " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", - " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", - "\n", - " function on_load() {\n", - " root._bokeh_is_loading--;\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", - " run_callbacks()\n", - " }\n", - " }\n", - "\n", - " function on_error(url) {\n", - " console.error(\"failed to load \" + url);\n", - " }\n", - "\n", - " for (let i = 0; i < css_urls.length; i++) {\n", - " const url = css_urls[i];\n", - " const element = document.createElement(\"link\");\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.rel = \"stylesheet\";\n", - " element.type = \"text/css\";\n", - " element.href = url;\n", - " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " for (let i = 0; i < js_urls.length; i++) {\n", - " const url = js_urls[i];\n", - " const element = document.createElement('script');\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.async = false;\n", - " element.src = url;\n", - " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", - " document.head.appendChild(element);\n", - " }\n", - " };\n", - "\n", - " function inject_raw_css(css) {\n", - " const element = document.createElement(\"style\");\n", - " element.appendChild(document.createTextNode(css));\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.1.min.js\"];\n", - " const css_urls = [];\n", - "\n", - " const inline_js = [ function(Bokeh) {\n", - " Bokeh.set_log_level(\"info\");\n", - " },\n", - "function(Bokeh) {\n", - " }\n", - " ];\n", - "\n", - " function run_inline_js() {\n", - " if (root.Bokeh !== undefined || force === true) {\n", - " try {\n", - " for (let i = 0; i < inline_js.length; i++) {\n", - " inline_js[i].call(root, root.Bokeh);\n", - " }\n", - "\n", - " } catch (error) {throw error;\n", - " }} else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(run_inline_js, 100);\n", - " } else if (!root._bokeh_failed_load) {\n", - " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", - " root._bokeh_failed_load = true;\n", - " } else if (force !== true) {\n", - " const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n", - " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", - " }\n", - " }\n", - "\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", - " run_inline_js();\n", - " } else {\n", - " load_libs(css_urls, js_urls, function() {\n", - " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", - " run_inline_js();\n", - " });\n", - " }\n", - "}(window));" - ], - "application/vnd.bokehjs_load.v0+json": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"
    \\n\"+\n \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n \"
  • use INLINE resources instead, as so:
  • \\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
MalariaGEN Ag3 API client
\n", - " Please note that data are subject to terms of use,\n", - " for more information see \n", - " the MalariaGEN website or contact support@malariagen.net.\n", - " See also the Ag3 API docs.\n", - "
\n", - " Storage URL\n", - " gs://vo_agam_release_master_us_central1/
\n", - " Data releases available\n", - " 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14
\n", - " Results cache\n", - " None
\n", - " Cohorts analysis\n", - " 20250131
\n", - " AIM analysis\n", - " 20220528
\n", - " Site filters analysis\n", - " dt_20200416
\n", - " Software version\n", - " malariagen_data 0.0.0
\n", - " Client location\n", - " England, United Kingdom
\n", - " " - ], - "text/plain": [ - "\n", - "Storage URL : gs://vo_agam_release_master_us_central1/\n", - "Data releases available : 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14\n", - "Results cache : None\n", - "Cohorts analysis : 20250131\n", - "AIM analysis : 20220528\n", - "Site filters analysis : dt_20200416\n", - "Software version : malariagen_data 0.0.0\n", - "Client location : England, United Kingdom\n", - "---\n", - "Please note that data are subject to terms of use,\n", - "for more information see https://www.malariagen.net/data\n", - "or contact support@malariagen.net. For API documentation see \n", - "https://malariagen.github.io/malariagen-data-python/v0.0.0/Ag3.html" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ag3 = malariagen_data.Ag3()\n", "ag3" @@ -433,1459 +23,20 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "921aa6e4", + "execution_count": null, + "id": "2", "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "window.igv=function(){\"use strict\";function e(e){return t(\"div\",e)}function t(e,t){const i=document.createElement(e);return t&&(t.class&&i.classList.add(t.class),t.id&&(i.id=t.id),t.style&&function(e,t){for(let i of Object.keys(t))e.style[i]=t[i]}(i,t.style)),i}function i(e){const t=getComputedStyle(e);\"none\"!==t.display&&(e._initialDisplay=t.display),e.style.display=\"none\"}function n(e){if(\"none\"===getComputedStyle(e).display){const t=e._initialDisplay||\"block\";e.style.display=t}}function r(e){if(e.type.startsWith(\"touch\")){const t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.pageX,y:e.pageY}}function s(){return(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}let o=(e,{clientX:t,clientY:i})=>{const{left:n,top:r,width:s,height:o}=e.getBoundingClientRect(),a=t-n,c=i-r;return{x:a,y:c,xNormalized:a/s,yNormalized:c/o,width:s,height:o}};function a(e,t){const{clientX:i,clientY:n}=e;return o(t,{clientX:i,clientY:n})}class c{constructor(){this.elem=t(\"div\",{class:\"igv-ui-panel-column\"})}add(t){if(t instanceof Node)this.elem.append(t);else if(\"object\"==typeof t)this.elem.append(t.elem);else{const i=e();i.innerHTML=t,this.elem.append(i),this.html=i}}}function l(e,t){return h(e,t)}function h(e,t){t=t||\"currentColor\";let i=d[e];i||(console.error(`No icon named: ${e}`),i=d.question);const n=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");n.setAttributeNS(null,\"viewBox\",\"0 0 \"+i[0]+\" \"+i[1]);const r=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");return r.setAttributeNS(null,\"fill\",t),r.setAttributeNS(null,\"d\",i[4]),n.appendChild(r),n}const d={check:[512,512,[],\"f00c\",\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"],cog:[512,512,[],\"f013\",\"M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z\"],exclamation:[192,512,[],\"f12a\",\"M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z\"],\"exclamation-circle\":[512,512,[],\"f06a\",\"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],\"exclamation-triangle\":[576,512,[],\"f071\",\"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],minus:[448,512,[],\"f068\",\"M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z\"],\"minus-circle\":[512,512,[],\"f056\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z\"],\"minus-square\":[448,512,[],\"f146\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z\"],plus:[448,512,[],\"f067\",\"M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z\"],\"plus-circle\":[512,512,[],\"f055\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],\"plus-square\":[448,512,[],\"f0fe\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],question:[384,512,[],\"f128\",\"M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z\"],save:[448,512,[],\"f0c7\",\"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z\"],search:[512,512,[],\"f002\",\"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z\"],share:[512,512,[],\"f064\",\"M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z\"],spinner:[512,512,[],\"f110\",\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"],square:[448,512,[],\"f0c8\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z\"],\"square-full\":[512,512,[],\"f45c\",\"M512 512H0V0h512v512z\"],times:[384,512,[],\"f00d\",\"M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z\"],\"times-circle\":[512,512,[],\"f057\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z\"],wrench:[512,512,[],\"f0ad\",\"M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z\"]};function u(e,t){var i=document.createElement(\"div\");e.appendChild(i),i.appendChild(l(\"times\")),i.addEventListener(\"click\",(function(e){e.preventDefault(),e.stopPropagation(),t()}))}let f;function p(e,t,i){t.addEventListener(\"mousedown\",function(e){e.stopPropagation(),e.preventDefault();const t=g.bind(this),n=m.bind(this),r=getComputedStyle(this),s=this.getBoundingClientRect();f={constraint:i,dragFunction:t,dragEndFunction:n,screenX:e.screenX,screenY:e.screenY,minDy:-s.top,minDx:-s.left,top:parseInt(r.top.replace(\"px\",\"\")),left:parseInt(r.left.replace(\"px\",\"\"))},document.addEventListener(\"mousemove\",t),document.addEventListener(\"mouseup\",n),document.addEventListener(\"mouseleave\",n),document.addEventListener(\"mouseexit\",n)}.bind(e))}function g(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=Math.max(f.minDx,e.screenX-f.screenX),i=Math.max(f.minDy,e.screenY-f.screenY),n=f.left+t,r=f.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function m(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=f.dragFunction,i=f.dragEndFunction;document.removeEventListener(\"mousemove\",t),document.removeEventListener(\"mouseup\",i),document.removeEventListener(\"mouseleave\",i),document.removeEventListener(\"mouseexit\",i),f=void 0}class w{constructor({parent:t,label:n,content:r,okHandler:s,cancelHandler:o}){this.parent=t;const a=()=>{i(this.elem),\"function\"==typeof o&&o(this)};this.elem=e(),this.elem.classList.add(\"igv-ui-generic-dialog-container\",\"igv-ui-center-fixed\");const c=e({class:\"igv-ui-generic-dialog-header\"});if(this.elem.appendChild(c),u(c,a),n){const t=e({class:\"igv-ui-dialog-one-liner\"});this.elem.appendChild(t),t.innerHTML=n}r.elem.style.margin=\"16px\",this.elem.appendChild(r.elem),this.content=r;const l=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.elem.appendChild(l),this.ok=e(),l.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),l.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",this.callback=void 0,this.ok.addEventListener(\"click\",(e=>{i(this.elem),\"function\"==typeof s?s(this):this.callback&&\"function\"==typeof this.callback&&this.callback(this)})),this.cancel.addEventListener(\"click\",a),p(this.elem,c),this.elem.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation()}))}present(e,t){if(e.label&&this.label&&(this.label.textContent=e.label),e.html){this.content.html.innerHTML=e.html}if(e.text){this.content.html.innerText=e.text}e.value&&this.input&&(this.input.value=e.value),e.callback&&(this.callback=e.callback),n(this.elem)}clampLocation(e,t){let i=this.elem.getBoundingClientRect(),n=this.parent.getBoundingClientRect();const r=Math.min(Math.max(t,n.y),n.y+n.height-i.height),s=Math.min(Math.max(e,n.x),n.x+n.width-i.width);this.elem.style.left=s+\"px\",this.elem.style.top=r+\"px\"}}\n", - "/*!\n", - " * jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\n", - " * https://jquery.com/\n", - " *\n", - " * Includes Sizzle.js\n", - " * https://sizzlejs.com/\n", - " *\n", - " * Copyright JS Foundation and other contributors\n", - " * Released under the MIT license\n", - " * https://jquery.org/license\n", - " *\n", - " * Date: 2018-01-20T17:24Z\n", - " */var b=[],F=window.document,v=Object.getPrototypeOf,y=b.slice,A=b.concat,C=b.push,_=b.indexOf,x={},k=x.toString,I=x.hasOwnProperty,S=I.toString,E=S.call(Object),N={},B=function(e){return\"function\"==typeof e&&\"number\"!=typeof e.nodeType},M=function(e){return null!=e&&e===e.window},R={type:!0,src:!0,noModule:!0};function D(e,t,i){var n,r=(t=t||F).createElement(\"script\");if(r.text=e,i)for(n in R)i[n]&&(r[n]=i[n]);t.head.appendChild(r).parentNode.removeChild(r)}function T(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?x[k.call(e)]||\"object\":typeof e}var L=\"3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\",z=function(e,t){return new z.fn.init(e,t)},H=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;function P(e){var t=!!e&&\"length\"in e&&e.length,i=T(e);return!B(e)&&!M(e)&&(\"array\"===i||0===t||\"number\"==typeof t&&t>0&&t-1 in e)}z.fn=z.prototype={jquery:L,constructor:z,length:0,toArray:function(){return y.call(this)},get:function(e){return null==e?y.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=z.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return z.each(this,e)},map:function(e){return this.pushStack(z.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(y.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i+~]|\"+L+\")\"+L+\"*\"),V=new RegExp(\"=\"+L+\"*([^\\\\]'\\\"]*?)\"+L+\"*\\\\]\",\"g\"),j=new RegExp(P),W=new RegExp(\"^\"+z+\"$\"),G={ID:new RegExp(\"^#(\"+z+\")\"),CLASS:new RegExp(\"^\\\\.(\"+z+\")\"),TAG:new RegExp(\"^(\"+z+\"|[*])\"),ATTR:new RegExp(\"^\"+H),PSEUDO:new RegExp(\"^\"+P),CHILD:new RegExp(\"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\"+L+\"*(even|odd|(([+-]|)(\\\\d*)n|)\"+L+\"*(?:([+-]|)\"+L+\"*(\\\\d+)|))\"+L+\"*\\\\)|)\",\"i\"),bool:new RegExp(\"^(?:\"+T+\")$\",\"i\"),needsContext:new RegExp(\"^\"+L+\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\"+L+\"*((?:-\\\\d)?\\\\d*)\"+L+\"*\\\\)|)(?=[^-]|$)\",\"i\")},$=/^(?:input|select|textarea|button)$/i,K=/^h\\d$/i,Y=/^[^{]+\\{\\s*\\[native \\w/,X=/^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,Z=/[+~]/,J=new RegExp(\"\\\\\\\\([\\\\da-f]{1,6}\"+L+\"?|(\"+L+\")|.)\",\"ig\"),ee=function(e,t,i){var n=\"0x\"+t-65536;return n!=n||i?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},te=/([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\0-\\x1f\\x7f-\\uFFFF\\w-]/g,ie=function(e,t){return t?\"\\0\"===e?\"�\":e.slice(0,-1)+\"\\\\\"+e.charCodeAt(e.length-1).toString(16)+\" \":\"\\\\\"+e},ne=function(){u()},re=we((function(e){return!0===e.disabled&&(\"form\"in e||\"label\"in e)}),{dir:\"parentNode\",next:\"legend\"});try{M.apply(E=R.call(y.childNodes),y.childNodes),E[y.childNodes.length].nodeType}catch(e){M={apply:E.length?function(e,t){B.apply(e,R.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function se(e,t,n,r){var s,a,l,h,d,p,w,b=t&&t.ownerDocument,A=t?t.nodeType:9;if(n=n||[],\"string\"!=typeof e||!e||1!==A&&9!==A&&11!==A)return n;if(!r&&((t?t.ownerDocument||t:y)!==f&&u(t),t=t||f,g)){if(11!==A&&(d=X.exec(e)))if(s=d[1]){if(9===A){if(!(l=t.getElementById(s)))return n;if(l.id===s)return n.push(l),n}else if(b&&(l=b.getElementById(s))&&F(t,l)&&l.id===s)return n.push(l),n}else{if(d[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=d[3])&&i.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(i.qsa&&!k[e+\" \"]&&(!m||!m.test(e))){if(1!==A)b=t,w=e;else if(\"object\"!==t.nodeName.toLowerCase()){for((h=t.getAttribute(\"id\"))?h=h.replace(te,ie):t.setAttribute(\"id\",h=v),a=(p=o(e)).length;a--;)p[a]=\"#\"+h+\" \"+me(p[a]);w=p.join(\",\"),b=Z.test(e)&&pe(t.parentNode)||t}if(w)try{return M.apply(n,b.querySelectorAll(w)),n}catch(e){}finally{h===v&&t.removeAttribute(\"id\")}}}return c(e.replace(U,\"$1\"),t,n,r)}function oe(){var e=[];return function t(i,r){return e.push(i+\" \")>n.cacheLength&&delete t[e.shift()],t[i+\" \"]=r}}function ae(e){return e[v]=!0,e}function ce(e){var t=f.createElement(\"fieldset\");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function he(e){return function(t){return\"input\"===t.nodeName.toLowerCase()&&t.type===e}}function de(e){return function(t){var i=t.nodeName.toLowerCase();return(\"input\"===i||\"button\"===i)&&t.type===e}}function ue(e){return function(t){return\"form\"in t?t.parentNode&&!1===t.disabled?\"label\"in t?\"label\"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:\"label\"in t&&t.disabled===e}}function fe(e){return ae((function(t){return t=+t,ae((function(i,n){for(var r,s=e([],i.length,t),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=se.support={},s=se.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&\"HTML\"!==t.nodeName},u=se.setDocument=function(e){var t,r,o=e?e.ownerDocument||e:y;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),y!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener(\"unload\",ne,!1):r.attachEvent&&r.attachEvent(\"onunload\",ne)),i.attributes=ce((function(e){return e.className=\"i\",!e.getAttribute(\"className\")})),i.getElementsByTagName=ce((function(e){return e.appendChild(f.createComment(\"\")),!e.getElementsByTagName(\"*\").length})),i.getElementsByClassName=Y.test(f.getElementsByClassName),i.getById=ce((function(e){return p.appendChild(e).id=v,!f.getElementsByName||!f.getElementsByName(v).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){return e.getAttribute(\"id\")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode(\"id\");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,r,s=t.getElementById(e);if(s){if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s];for(r=t.getElementsByName(e),n=0;s=r[n++];)if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],r=0,s=t.getElementsByTagName(e);if(\"*\"===e){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},w=[],m=[],(i.qsa=Y.test(f.querySelectorAll))&&(ce((function(e){p.appendChild(e).innerHTML=\"\",e.querySelectorAll(\"[msallowcapture^='']\").length&&m.push(\"[*^$]=\"+L+\"*(?:''|\\\"\\\")\"),e.querySelectorAll(\"[selected]\").length||m.push(\"\\\\[\"+L+\"*(?:value|\"+T+\")\"),e.querySelectorAll(\"[id~=\"+v+\"-]\").length||m.push(\"~=\"),e.querySelectorAll(\":checked\").length||m.push(\":checked\"),e.querySelectorAll(\"a#\"+v+\"+*\").length||m.push(\".#.+[+~]\")})),ce((function(e){e.innerHTML=\"\";var t=f.createElement(\"input\");t.setAttribute(\"type\",\"hidden\"),e.appendChild(t).setAttribute(\"name\",\"D\"),e.querySelectorAll(\"[name=d]\").length&&m.push(\"name\"+L+\"*[*^$|!~]?=\"),2!==e.querySelectorAll(\":enabled\").length&&m.push(\":enabled\",\":disabled\"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(\":disabled\").length&&m.push(\":enabled\",\":disabled\"),e.querySelectorAll(\"*,:x\"),m.push(\",.*:\")}))),(i.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ce((function(e){i.disconnectedMatch=b.call(e,\"*\"),b.call(e,\"[s!='']:x\"),w.push(\"!=\",P)})),m=m.length&&new RegExp(m.join(\"|\")),w=w.length&&new RegExp(w.join(\"|\")),t=Y.test(p.compareDocumentPosition),F=t||Y.test(p.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},I=t?function(e,t){if(e===t)return d=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e===f||e.ownerDocument===y&&F(y,e)?-1:t===f||t.ownerDocument===y&&F(y,t)?1:h?D(h,e)-D(h,t):0:4&n?-1:1)}:function(e,t){if(e===t)return d=!0,0;var i,n=0,r=e.parentNode,s=t.parentNode,o=[e],a=[t];if(!r||!s)return e===f?-1:t===f?1:r?-1:s?1:h?D(h,e)-D(h,t):0;if(r===s)return le(e,t);for(i=e;i=i.parentNode;)o.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?le(o[n],a[n]):o[n]===y?-1:a[n]===y?1:0},f):f},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&u(e),t=t.replace(V,\"='$1']\"),i.matchesSelector&&g&&!k[t+\" \"]&&(!w||!w.test(t))&&(!m||!m.test(t)))try{var n=b.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return se(t,f,null,[e]).length>0},se.contains=function(e,t){return(e.ownerDocument||e)!==f&&u(e),F(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!==f&&u(e);var r=n.attrHandle[t.toLowerCase()],s=r&&S.call(n.attrHandle,t.toLowerCase())?r(e,t,!g):void 0;return void 0!==s?s:i.attributes||!g?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},se.escape=function(e){return(e+\"\").replace(te,ie)},se.error=function(e){throw new Error(\"Syntax error, unrecognized expression: \"+e)},se.uniqueSort=function(e){var t,n=[],r=0,s=0;if(d=!i.detectDuplicates,h=!i.sortStable&&e.slice(0),e.sort(I),d){for(;t=e[s++];)t===e[s]&&(r=n.push(s));for(;r--;)e.splice(n[r],1)}return h=null,e},r=se.getText=function(e){var t,i=\"\",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if(\"string\"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=r(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n++];)i+=r(t);return i},n=se.selectors={cacheLength:50,createPseudo:ae,match:G,attrHandle:{},find:{},relative:{\">\":{dir:\"parentNode\",first:!0},\" \":{dir:\"parentNode\"},\"+\":{dir:\"previousSibling\",first:!0},\"~\":{dir:\"previousSibling\"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(J,ee),e[3]=(e[3]||e[4]||e[5]||\"\").replace(J,ee),\"~=\"===e[2]&&(e[3]=\" \"+e[3]+\" \"),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),\"nth\"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(\"even\"===e[3]||\"odd\"===e[3])),e[5]=+(e[7]+e[8]||\"odd\"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||\"\":i&&j.test(i)&&(t=o(i,!0))&&(t=i.indexOf(\")\",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(J,ee).toLowerCase();return\"*\"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=_[e+\" \"];return t||(t=new RegExp(\"(^|\"+L+\")\"+e+\"(\"+L+\"|$)\"))&&_(e,(function(e){return t.test(\"string\"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute(\"class\")||\"\")}))},ATTR:function(e,t,i){return function(n){var r=se.attr(n,e);return null==r?\"!=\"===t:!t||(r+=\"\",\"=\"===t?r===i:\"!=\"===t?r!==i:\"^=\"===t?i&&0===r.indexOf(i):\"*=\"===t?i&&r.indexOf(i)>-1:\"$=\"===t?i&&r.slice(-i.length)===i:\"~=\"===t?(\" \"+r.replace(O,\" \")+\" \").indexOf(i)>-1:\"|=\"===t&&(r===i||r.slice(0,i.length+1)===i+\"-\"))}},CHILD:function(e,t,i,n,r){var s=\"nth\"!==e.slice(0,3),o=\"last\"!==e.slice(-4),a=\"of-type\"===t;return 1===n&&0===r?function(e){return!!e.parentNode}:function(t,i,c){var l,h,d,u,f,p,g=s!==o?\"nextSibling\":\"previousSibling\",m=t.parentNode,w=a&&t.nodeName.toLowerCase(),b=!c&&!a,F=!1;if(m){if(s){for(;g;){for(u=t;u=u[g];)if(a?u.nodeName.toLowerCase()===w:1===u.nodeType)return!1;p=g=\"only\"===e&&!p&&\"nextSibling\"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&b){for(F=(f=(l=(h=(d=(u=m)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1])&&l[2],u=f&&m.childNodes[f];u=++f&&u&&u[g]||(F=f=0)||p.pop();)if(1===u.nodeType&&++F&&u===t){h[e]=[A,f,F];break}}else if(b&&(F=f=(l=(h=(d=(u=t)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1]),!1===F)for(;(u=++f&&u&&u[g]||(F=f=0)||p.pop())&&((a?u.nodeName.toLowerCase()!==w:1!==u.nodeType)||!++F||(b&&((h=(d=u[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]=[A,F]),u!==t)););return(F-=r)===n||F%n==0&&F/n>=0}}},PSEUDO:function(e,t){var i,r=n.pseudos[e]||n.setFilters[e.toLowerCase()]||se.error(\"unsupported pseudo: \"+e);return r[v]?r(t):r.length>1?(i=[e,e,\"\",t],n.setFilters.hasOwnProperty(e.toLowerCase())?ae((function(e,i){for(var n,s=r(e,t),o=s.length;o--;)e[n=D(e,s[o])]=!(i[n]=s[o])})):function(e){return r(e,0,i)}):r}},pseudos:{not:ae((function(e){var t=[],i=[],n=a(e.replace(U,\"$1\"));return n[v]?ae((function(e,t,i,r){for(var s,o=n(e,null,r,[]),a=e.length;a--;)(s=o[a])&&(e[a]=!(t[a]=s))})):function(e,r,s){return t[0]=e,n(t,null,s,i),t[0]=null,!i.pop()}})),has:ae((function(e){return function(t){return se(e,t).length>0}})),contains:ae((function(e){return e=e.replace(J,ee),function(t){return(t.textContent||t.innerText||r(t)).indexOf(e)>-1}})),lang:ae((function(e){return W.test(e||\"\")||se.error(\"unsupported lang: \"+e),e=e.replace(J,ee).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute(\"xml:lang\")||t.getAttribute(\"lang\"))return(i=i.toLowerCase())===e||0===i.indexOf(e+\"-\")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ue(!1),disabled:ue(!0),checked:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&!!e.checked||\"option\"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return $.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&\"button\"===e.type||\"button\"===t},text:function(e){var t;return\"input\"===e.nodeName.toLowerCase()&&\"text\"===e.type&&(null==(t=e.getAttribute(\"type\"))||\"text\"===t.toLowerCase())},first:fe((function(){return[0]})),last:fe((function(e,t){return[t-1]})),eq:fe((function(e,t,i){return[i<0?i+t:i]})),even:fe((function(e,t){for(var i=0;i=0;)e.push(n);return e})),gt:fe((function(e,t,i){for(var n=i<0?i+t:i;++n1?function(t,i,n){for(var r=e.length;r--;)if(!e[r](t,i,n))return!1;return!0}:e[0]}function Fe(e,t,i,n,r){for(var s,o=[],a=0,c=e.length,l=null!=t;a-1&&(s[l]=!(o[l]=d))}}else w=Fe(w===o?w.splice(p,w.length):w),r?r(null,o,w,c):M.apply(o,w)}))}function ye(e){for(var t,i,r,s=e.length,o=n.relative[e[0].type],a=o||n.relative[\" \"],c=o?1:0,h=we((function(e){return e===t}),a,!0),d=we((function(e){return D(t,e)>-1}),a,!0),u=[function(e,i,n){var r=!o&&(n||i!==l)||((t=i).nodeType?h(e,i,n):d(e,i,n));return t=null,r}];c1&&be(u),c>1&&me(e.slice(0,c-1).concat({value:\" \"===e[c-2].type?\"*\":\"\"})).replace(U,\"$1\"),i,c0,r=e.length>0,s=function(s,o,a,c,h){var d,p,m,w=0,b=\"0\",F=s&&[],v=[],y=l,C=s||r&&n.find.TAG(\"*\",h),_=A+=null==y?1:Math.random()||.1,x=C.length;for(h&&(l=o===f||o||h);b!==x&&null!=(d=C[b]);b++){if(r&&d){for(p=0,o||d.ownerDocument===f||(u(d),a=!g);m=e[p++];)if(m(d,o||f,a)){c.push(d);break}h&&(A=_)}i&&((d=!m&&d)&&w--,s&&F.push(d))}if(w+=b,i&&b!==w){for(p=0;m=t[p++];)m(F,v,o,a);if(s){if(w>0)for(;b--;)F[b]||v[b]||(v[b]=N.call(c));v=Fe(v)}M.apply(c,v),h&&!s&&v.length>0&&w+t.length>1&&se.uniqueSort(c)}return h&&(A=_,l=y),F};return i?ae(s):s}(s,r)),a.selector=e}return a},c=se.select=function(e,t,i,r){var s,c,l,h,d,u=\"function\"==typeof e&&e,f=!r&&o(e=u.selector||e);if(i=i||[],1===f.length){if((c=f[0]=f[0].slice(0)).length>2&&\"ID\"===(l=c[0]).type&&9===t.nodeType&&g&&n.relative[c[1].type]){if(!(t=(n.find.ID(l.matches[0].replace(J,ee),t)||[])[0]))return i;u&&(t=t.parentNode),e=e.slice(c.shift().value.length)}for(s=G.needsContext.test(e)?0:c.length;s--&&(l=c[s],!n.relative[h=l.type]);)if((d=n.find[h])&&(r=d(l.matches[0].replace(J,ee),Z.test(c[0].type)&&pe(t.parentNode)||t))){if(c.splice(s,1),!(e=r.length&&me(c)))return M.apply(i,r),i;break}}return(u||a(e,f))(r,t,!g,i,!t||Z.test(e)&&pe(t.parentNode)||t),i},i.sortStable=v.split(\"\").sort(I).join(\"\")===v,i.detectDuplicates=!!d,u(),se}(window);z.find=O,z.expr=O.selectors,z.expr[\":\"]=z.expr.pseudos,z.uniqueSort=z.unique=O.uniqueSort,z.text=O.getText,z.isXMLDoc=O.isXML,z.contains=O.contains,z.escapeSelector=O.escape;var U=function(e,t,i){for(var n=[],r=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&z(e).is(i))break;n.push(e)}return n},q=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},Q=z.expr.match.needsContext;function V(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var j=/^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i;function W(e,t,i){return B(t)?z.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?z.grep(e,(function(e){return e===t!==i})):\"string\"!=typeof t?z.grep(e,(function(e){return _.call(t,e)>-1!==i})):z.filter(t,e,i)}z.filter=function(e,t,i){var n=t[0];return i&&(e=\":not(\"+e+\")\"),1===t.length&&1===n.nodeType?z.find.matchesSelector(n,e)?[n]:[]:z.find.matches(e,z.grep(t,(function(e){return 1===e.nodeType})))},z.fn.extend({find:function(e){var t,i,n=this.length,r=this;if(\"string\"!=typeof e)return this.pushStack(z(e).filter((function(){for(t=0;t1?z.uniqueSort(i):i},filter:function(e){return this.pushStack(W(this,e||[],!1))},not:function(e){return this.pushStack(W(this,e||[],!0))},is:function(e){return!!W(this,\"string\"==typeof e&&Q.test(e)?z(e):e||[],!1).length}});var G,$=/^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/;(z.fn.init=function(e,t,i){var n,r;if(!e)return this;if(i=i||G,\"string\"==typeof e){if(!(n=\"<\"===e[0]&&\">\"===e[e.length-1]&&e.length>=3?[null,e,null]:$.exec(e))||!n[1]&&t)return!t||t.jquery?(t||i).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof z?t[0]:t,z.merge(this,z.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:F,!0)),j.test(n[1])&&z.isPlainObject(t))for(n in t)B(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return(r=F.getElementById(n[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):B(e)?void 0!==i.ready?i.ready(e):e(z):z.makeArray(e,this)}).prototype=z.fn,G=z(F);var K=/^(?:parents|prev(?:Until|All))/,Y={children:!0,contents:!0,next:!0,prev:!0};function X(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}z.fn.extend({has:function(e){var t=z(e,this),i=t.length;return this.filter((function(){for(var e=0;e-1:1===i.nodeType&&z.find.matchesSelector(i,e))){s.push(i);break}return this.pushStack(s.length>1?z.uniqueSort(s):s)},index:function(e){return e?\"string\"==typeof e?_.call(z(e),this[0]):_.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(z.uniqueSort(z.merge(this.get(),z(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),z.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return U(e,\"parentNode\")},parentsUntil:function(e,t,i){return U(e,\"parentNode\",i)},next:function(e){return X(e,\"nextSibling\")},prev:function(e){return X(e,\"previousSibling\")},nextAll:function(e){return U(e,\"nextSibling\")},prevAll:function(e){return U(e,\"previousSibling\")},nextUntil:function(e,t,i){return U(e,\"nextSibling\",i)},prevUntil:function(e,t,i){return U(e,\"previousSibling\",i)},siblings:function(e){return q((e.parentNode||{}).firstChild,e)},children:function(e){return q(e.firstChild)},contents:function(e){return V(e,\"iframe\")?e.contentDocument:(V(e,\"template\")&&(e=e.content||e),z.merge([],e.childNodes))}},(function(e,t){z.fn[e]=function(i,n){var r=z.map(this,t,i);return\"Until\"!==e.slice(-5)&&(n=i),n&&\"string\"==typeof n&&(r=z.filter(n,r)),this.length>1&&(Y[e]||z.uniqueSort(r),K.test(e)&&r.reverse()),this.pushStack(r)}}));var Z=/[^\\x20\\t\\r\\n\\f]+/g;function J(e){return e}function ee(e){throw e}function te(e,t,i,n){var r;try{e&&B(r=e.promise)?r.call(e).done(t).fail(i):e&&B(r=e.then)?r.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}z.Callbacks=function(e){e=\"string\"==typeof e?function(e){var t={};return z.each(e.match(Z)||[],(function(e,i){t[i]=!0})),t}(e):z.extend({},e);var t,i,n,r,s=[],o=[],a=-1,c=function(){for(r=r||e.once,n=t=!0;o.length;a=-1)for(i=o.shift();++a-1;)s.splice(i,1),i<=a&&a--})),this},has:function(e){return e?z.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i=\"\",this},disabled:function(){return!s},lock:function(){return r=o=[],i||t||(s=i=\"\"),this},locked:function(){return!!r},fireWith:function(e,i){return r||(i=[e,(i=i||[]).slice?i.slice():i],o.push(i),t||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!n}};return l},z.extend({Deferred:function(e){var t=[[\"notify\",\"progress\",z.Callbacks(\"memory\"),z.Callbacks(\"memory\"),2],[\"resolve\",\"done\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),0,\"resolved\"],[\"reject\",\"fail\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),1,\"rejected\"]],i=\"pending\",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return z.Deferred((function(i){z.each(t,(function(t,n){var s=B(e[n[4]])&&e[n[4]];r[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&B(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+\"With\"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,n){var r=0;function s(e,t,i,n){return function(){var o=this,a=arguments,c=function(){var c,l;if(!(e=r&&(i!==ee&&(o=void 0,a=[n]),t.rejectWith(o,a))}};e?l():(z.Deferred.getStackHook&&(l.stackTrace=z.Deferred.getStackHook()),window.setTimeout(l))}}return z.Deferred((function(r){t[0][3].add(s(0,r,B(n)?n:J,r.notifyWith)),t[1][3].add(s(0,r,B(e)?e:J)),t[2][3].add(s(0,r,B(i)?i:ee))})).promise()},promise:function(e){return null!=e?z.extend(e,n):n}},r={};return z.each(t,(function(e,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+\"With\"](this===r?void 0:this,arguments),this},r[s[0]+\"With\"]=o.fireWith})),n.promise(r),e&&e.call(r,r),r},when:function(e){var t=arguments.length,i=t,n=Array(i),r=y.call(arguments),s=z.Deferred(),o=function(e){return function(i){n[e]=this,r[e]=arguments.length>1?y.call(arguments):i,--t||s.resolveWith(n,r)}};if(t<=1&&(te(e,s.done(o(i)).resolve,s.reject,!t),\"pending\"===s.state()||B(r[i]&&r[i].then)))return s.then();for(;i--;)te(r[i],o(i),s.reject);return s.promise()}});var ie=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;z.Deferred.exceptionHook=function(e,t){window.console&&window.console.warn&&e&&ie.test(e.name)&&window.console.warn(\"jQuery.Deferred exception: \"+e.message,e.stack,t)},z.readyException=function(e){window.setTimeout((function(){throw e}))};var ne=z.Deferred();function re(){F.removeEventListener(\"DOMContentLoaded\",re),window.removeEventListener(\"load\",re),z.ready()}z.fn.ready=function(e){return ne.then(e).catch((function(e){z.readyException(e)})),this},z.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--z.readyWait:z.isReady)||(z.isReady=!0,!0!==e&&--z.readyWait>0||ne.resolveWith(F,[z]))}}),z.ready.then=ne.then,\"complete\"===F.readyState||\"loading\"!==F.readyState&&!F.documentElement.doScroll?window.setTimeout(z.ready):(F.addEventListener(\"DOMContentLoaded\",re),window.addEventListener(\"load\",re));var se=function(e,t,i,n,r,s,o){var a=0,c=e.length,l=null==i;if(\"object\"===T(i))for(a in r=!0,i)se(e,t,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,B(n)||(o=!0),l&&(o?(t.call(e,n),t=null):(l=t,t=function(e,t,i){return l.call(z(e),i)})),t))for(;a1,null,!0)},removeData:function(e){return this.each((function(){fe.remove(this,e)}))}}),z.extend({queue:function(e,t,i){var n;if(e)return t=(t||\"fx\")+\"queue\",n=ue.get(e,t),i&&(!n||Array.isArray(i)?n=ue.access(e,t,z.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||\"fx\";var i=z.queue(e,t),n=i.length,r=i.shift(),s=z._queueHooks(e,t);\"inprogress\"===r&&(r=i.shift(),n--),r&&(\"fx\"===t&&i.unshift(\"inprogress\"),delete s.stop,r.call(e,(function(){z.dequeue(e,t)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(e,t){var i=t+\"queueHooks\";return ue.get(e,i)||ue.access(e,i,{empty:z.Callbacks(\"once memory\").add((function(){ue.remove(e,[t+\"queue\",i])}))})}}),z.fn.extend({queue:function(e,t){var i=2;return\"string\"!=typeof e&&(t=e,e=\"fx\",i--),arguments.length\\x20\\t\\r\\n\\f]+)/i,Ie=/^$|^module$|\\/(?:java|ecma)script/i,Se={option:[1,\"\"],thead:[1,\"\",\"
\"],col:[2,\"\",\"
\"],tr:[2,\"\",\"
\"],td:[3,\"\",\"
\"],_default:[0,\"\",\"\"]};function Ee(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||\"*\"):void 0!==e.querySelectorAll?e.querySelectorAll(t||\"*\"):[],void 0===t||t&&V(e,t)?z.merge([e],i):i}function Ne(e,t){for(var i=0,n=e.length;i-1)r&&r.push(s);else if(l=z.contains(s.ownerDocument,s),o=Ee(d.appendChild(s),\"script\"),l&&Ne(o),i)for(h=0;s=o[h++];)Ie.test(s.type||\"\")&&i.push(s);return d}!function(){var e=F.createDocumentFragment().appendChild(F.createElement(\"div\")),t=F.createElement(\"input\");t.setAttribute(\"type\",\"radio\"),t.setAttribute(\"checked\",\"checked\"),t.setAttribute(\"name\",\"t\"),e.appendChild(t),N.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML=\"\",N.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var Re=F.documentElement,De=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Le=/^([^.]*)(?:\\.(.+)|)/;function ze(){return!0}function He(){return!1}function Pe(){try{return F.activeElement}catch(e){}}function Oe(e,t,i,n,r,s){var o,a;if(\"object\"==typeof t){for(a in\"string\"!=typeof i&&(n=n||i,i=void 0),t)Oe(e,a,i,n,t[a],s);return e}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&(\"string\"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=He;else if(!r)return e;return 1===s&&(o=r,r=function(e){return z().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=z.guid++)),e.each((function(){z.event.add(this,t,r,n,i)}))}z.event={global:{},add:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.get(e);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&z.find.matchesSelector(Re,r),i.guid||(i.guid=z.guid++),(c=m.events)||(c=m.events={}),(o=m.handle)||(o=m.handle=function(t){return void 0!==z&&z.event.triggered!==t.type?z.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f&&(d=z.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,d=z.event.special[f]||{},h=z.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&z.expr.match.needsContext.test(r),namespace:p.join(\".\")},s),(u=c[f])||((u=c[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,n,p,o)||e.addEventListener&&e.addEventListener(f,o)),d.add&&(d.add.call(e,h),h.handler.guid||(h.handler.guid=i.guid)),r?u.splice(u.delegateCount++,0,h):u.push(h),z.event.global[f]=!0)},remove:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.hasData(e)&&ue.get(e);if(m&&(c=m.events)){for(l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)if(f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f){for(d=z.event.special[f]||{},u=c[f=(n?d.delegateType:d.bindType)||f]||[],a=a[2]&&new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"),o=s=u.length;s--;)h=u[s],!r&&g!==h.origType||i&&i.guid!==h.guid||a&&!a.test(h.namespace)||n&&n!==h.selector&&(\"**\"!==n||!h.selector)||(u.splice(s,1),h.selector&&u.delegateCount--,d.remove&&d.remove.call(e,h));o&&!u.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||z.removeEvent(e,f,m.handle),delete c[f])}else for(f in c)z.event.remove(e,f+t[l],i,n,!0);z.isEmptyObject(c)&&ue.remove(e,\"handle events\")}},dispatch:function(e){var t,i,n,r,s,o,a=z.event.fix(e),c=new Array(arguments.length),l=(ue.get(this,\"events\")||{})[a.type]||[],h=z.event.special[a.type]||{};for(c[0]=a,t=1;t=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&(\"click\"!==e.type||!0!==l.disabled)){for(s=[],o={},i=0;i-1:z.find(r,this,null,[l]).length),o[r]&&s.push(n);s.length&&a.push({elem:l,handlers:s})}return l=this,c\\x20\\t\\r\\n\\f]*)[^>]*)\\/>/gi,qe=/\\s*$/g;function je(e,t){return V(e,\"table\")&&V(11!==t.nodeType?t:t.firstChild,\"tr\")&&z(e).children(\"tbody\")[0]||e}function We(e){return e.type=(null!==e.getAttribute(\"type\"))+\"/\"+e.type,e}function Ge(e){return\"true/\"===(e.type||\"\").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute(\"type\"),e}function $e(e,t){var i,n,r,s,o,a,c,l;if(1===t.nodeType){if(ue.hasData(e)&&(s=ue.access(e),o=ue.set(t,s),l=s.events))for(r in delete o.handle,o.events={},l)for(i=0,n=l[r].length;i1&&\"string\"==typeof f&&!N.checkClone&&Qe.test(f))return e.each((function(r){var s=e.eq(r);p&&(t[0]=f.call(this,r,s.html())),Ye(s,t,i,n)}));if(d&&(s=(r=Me(t,e[0].ownerDocument,!1,e,n)).firstChild,1===r.childNodes.length&&(r=s),s||n)){for(a=(o=z.map(Ee(r,\"script\"),We)).length;h\")},clone:function(e,t,i){var n,r,s,o,a=e.cloneNode(!0),c=z.contains(e.ownerDocument,e);if(!(N.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||z.isXMLDoc(e)))for(o=Ee(a),n=0,r=(s=Ee(e)).length;n0&&Ne(o,!c&&Ee(e,\"script\")),a},cleanData:function(e){for(var t,i,n,r=z.event.special,s=0;void 0!==(i=e[s]);s++)if(he(i)){if(t=i[ue.expando]){if(t.events)for(n in t.events)r[n]?z.event.remove(i,n):z.removeEvent(i,n,t.handle);i[ue.expando]=void 0}i[fe.expando]&&(i[fe.expando]=void 0)}}}),z.fn.extend({detach:function(e){return Xe(this,e,!0)},remove:function(e){return Xe(this,e)},text:function(e){return se(this,(function(e){return void 0===e?z.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ye(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)}))},prepend:function(){return Ye(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(z.cleanData(Ee(e,!1)),e.textContent=\"\");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return z.clone(this,e,t)}))},html:function(e){return se(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if(\"string\"==typeof e&&!qe.test(e)&&!Se[(ke.exec(e)||[\"\",\"\"])[1].toLowerCase()]){e=z.htmlPrefilter(e);try{for(;i=0&&(c+=Math.max(0,Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-s-c-a-.5))),c}function pt(e,t,i){var n=Je(e),r=tt(e,t,n),s=\"border-box\"===z.css(e,\"boxSizing\",!1,n),o=s;if(Ze.test(r)){if(!i)return r;r=\"auto\"}return o=o&&(N.boxSizingReliable()||r===e.style[t]),(\"auto\"===r||!parseFloat(r)&&\"inline\"===z.css(e,\"display\",!1,n))&&(r=e[\"offset\"+t[0].toUpperCase()+t.slice(1)],o=!0),(r=parseFloat(r)||0)+ft(e,t,i||(s?\"border\":\"content\"),o,n,r)+\"px\"}z.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=tt(e,\"opacity\");return\"\"===i?\"1\":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,s,o,a=le(t),c=ot.test(t),l=e.style;if(c||(t=dt(a)),o=z.cssHooks[t]||z.cssHooks[a],void 0===i)return o&&\"get\"in o&&void 0!==(r=o.get(e,!1,n))?r:l[t];\"string\"===(s=typeof i)&&(r=be.exec(i))&&r[1]&&(i=function(e,t,i,n){var r,s,o=20,a=n?function(){return n.cur()}:function(){return z.css(e,t,\"\")},c=a(),l=i&&i[3]||(z.cssNumber[t]?\"\":\"px\"),h=(z.cssNumber[t]||\"px\"!==l&&+c)&&be.exec(z.css(e,t));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;o--;)z.style(e,t,h+l),(1-s)*(1-(s=a()/c||.5))<=0&&(o=0),h/=s;h*=2,z.style(e,t,h+l),i=i||[]}return i&&(h=+h||+c||0,r=i[1]?h+(i[1]+1)*i[2]:+i[2],n&&(n.unit=l,n.start=h,n.end=r)),r}(e,t,r),s=\"number\"),null!=i&&i==i&&(\"number\"===s&&(i+=r&&r[3]||(z.cssNumber[a]?\"\":\"px\")),N.clearCloneStyle||\"\"!==i||0!==t.indexOf(\"background\")||(l[t]=\"inherit\"),o&&\"set\"in o&&void 0===(i=o.set(e,i,n))||(c?l.setProperty(t,i):l[t]=i))}},css:function(e,t,i,n){var r,s,o,a=le(t);return ot.test(t)||(t=dt(a)),(o=z.cssHooks[t]||z.cssHooks[a])&&\"get\"in o&&(r=o.get(e,!0,i)),void 0===r&&(r=tt(e,t,n)),\"normal\"===r&&t in ct&&(r=ct[t]),\"\"===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),z.each([\"height\",\"width\"],(function(e,t){z.cssHooks[t]={get:function(e,i,n){if(i)return!st.test(z.css(e,\"display\"))||e.getClientRects().length&&e.getBoundingClientRect().width?pt(e,t,n):ye(e,at,(function(){return pt(e,t,n)}))},set:function(e,i,n){var r,s=Je(e),o=\"border-box\"===z.css(e,\"boxSizing\",!1,s),a=n&&ft(e,t,n,o,s);return o&&N.scrollboxSize()===s.position&&(a-=Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-parseFloat(s[t])-ft(e,t,\"border\",!1,s)-.5)),a&&(r=be.exec(i))&&\"px\"!==(r[3]||\"px\")&&(e.style[t]=i,i=z.css(e,t)),ut(0,i,a)}}})),z.cssHooks.marginLeft=it(N.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(tt(e,\"marginLeft\"))||e.getBoundingClientRect().left-ye(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+\"px\"})),z.each({margin:\"\",padding:\"\",border:\"Width\"},(function(e,t){z.cssHooks[e+t]={expand:function(i){for(var n=0,r={},s=\"string\"==typeof i?i.split(\" \"):[i];n<4;n++)r[e+Fe[n]+t]=s[n]||s[n-2]||s[0];return r}},\"margin\"!==e&&(z.cssHooks[e+t].set=ut)})),z.fn.extend({css:function(e,t){return se(this,(function(e,t,i){var n,r,s={},o=0;if(Array.isArray(t)){for(n=Je(e),r=t.length;o1)}}),z.fn.delay=function(e,t){return e=z.fx&&z.fx.speeds[e]||e,t=t||\"fx\",this.queue(t,(function(t,i){var n=window.setTimeout(t,e);i.stop=function(){window.clearTimeout(n)}}))},nt=F.createElement(\"input\"),rt=F.createElement(\"select\").appendChild(F.createElement(\"option\")),nt.type=\"checkbox\",N.checkOn=\"\"!==nt.value,N.optSelected=rt.selected,(nt=F.createElement(\"input\")).value=\"t\",nt.type=\"radio\",N.radioValue=\"t\"===nt.value;var gt,mt=z.expr.attrHandle;z.fn.extend({attr:function(e,t){return se(this,z.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){z.removeAttr(this,e)}))}}),z.extend({attr:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===e.getAttribute?z.prop(e,t,i):(1===s&&z.isXMLDoc(e)||(r=z.attrHooks[t.toLowerCase()]||(z.expr.match.bool.test(t)?gt:void 0)),void 0!==i?null===i?void z.removeAttr(e,t):r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:(e.setAttribute(t,i+\"\"),i):r&&\"get\"in r&&null!==(n=r.get(e,t))?n:null==(n=z.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!N.radioValue&&\"radio\"===t&&V(e,\"input\")){var i=e.value;return e.setAttribute(\"type\",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,r=t&&t.match(Z);if(r&&1===e.nodeType)for(;i=r[n++];)e.removeAttribute(i)}}),gt={set:function(e,t,i){return!1===t?z.removeAttr(e,i):e.setAttribute(i,i),i}},z.each(z.expr.match.bool.source.match(/\\w+/g),(function(e,t){var i=mt[t]||z.find.attr;mt[t]=function(e,t,n){var r,s,o=t.toLowerCase();return n||(s=mt[o],mt[o]=r,r=null!=i(e,t,n)?o:null,mt[o]=s),r}}));var wt=/^(?:input|select|textarea|button)$/i,bt=/^(?:a|area)$/i;function Ft(e){return(e.match(Z)||[]).join(\" \")}function vt(e){return e.getAttribute&&e.getAttribute(\"class\")||\"\"}function yt(e){return Array.isArray(e)?e:\"string\"==typeof e&&e.match(Z)||[]}z.fn.extend({prop:function(e,t){return se(this,z.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[z.propFix[e]||e]}))}}),z.extend({prop:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&z.isXMLDoc(e)||(t=z.propFix[t]||t,r=z.propHooks[t]),void 0!==i?r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:e[t]=i:r&&\"get\"in r&&null!==(n=r.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=z.find.attr(e,\"tabindex\");return t?parseInt(t,10):wt.test(e.nodeName)||bt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:\"htmlFor\",class:\"className\"}}),N.optSelected||(z.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),z.each([\"tabIndex\",\"readOnly\",\"maxLength\",\"cellSpacing\",\"cellPadding\",\"rowSpan\",\"colSpan\",\"useMap\",\"frameBorder\",\"contentEditable\"],(function(){z.propFix[this.toLowerCase()]=this})),z.fn.extend({addClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).addClass(e.call(this,t,vt(this)))}));if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)n.indexOf(\" \"+s+\" \")<0&&(n+=s+\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},removeClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).removeClass(e.call(this,t,vt(this)))}));if(!arguments.length)return this.attr(\"class\",\"\");if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)for(;n.indexOf(\" \"+s+\" \")>-1;)n=n.replace(\" \"+s+\" \",\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},toggleClass:function(e,t){var i=typeof e,n=\"string\"===i||Array.isArray(e);return\"boolean\"==typeof t&&n?t?this.addClass(e):this.removeClass(e):B(e)?this.each((function(i){z(this).toggleClass(e.call(this,i,vt(this),t),t)})):this.each((function(){var t,r,s,o;if(n)for(r=0,s=z(this),o=yt(e);t=o[r++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&\"boolean\"!==i||((t=vt(this))&&ue.set(this,\"__className__\",t),this.setAttribute&&this.setAttribute(\"class\",t||!1===e?\"\":ue.get(this,\"__className__\")||\"\"))}))},hasClass:function(e){var t,i,n=0;for(t=\" \"+e+\" \";i=this[n++];)if(1===i.nodeType&&(\" \"+Ft(vt(i))+\" \").indexOf(t)>-1)return!0;return!1}});var At=/\\r/g;z.fn.extend({val:function(e){var t,i,n,r=this[0];return arguments.length?(n=B(e),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?e.call(this,i,z(this).val()):e)?r=\"\":\"number\"==typeof r?r+=\"\":Array.isArray(r)&&(r=z.map(r,(function(e){return null==e?\"\":e+\"\"}))),(t=z.valHooks[this.type]||z.valHooks[this.nodeName.toLowerCase()])&&\"set\"in t&&void 0!==t.set(this,r,\"value\")||(this.value=r))}))):r?(t=z.valHooks[r.type]||z.valHooks[r.nodeName.toLowerCase()])&&\"get\"in t&&void 0!==(i=t.get(r,\"value\"))?i:\"string\"==typeof(i=r.value)?i.replace(At,\"\"):null==i?\"\":i:void 0}}),z.extend({valHooks:{option:{get:function(e){var t=z.find.attr(e,\"value\");return null!=t?t:Ft(z.text(e))}},select:{get:function(e){var t,i,n,r=e.options,s=e.selectedIndex,o=\"select-one\"===e.type,a=o?null:[],c=o?s+1:r.length;for(n=s<0?c:o?s:0;n-1)&&(i=!0);return i||(e.selectedIndex=-1),s}}}}),z.each([\"radio\",\"checkbox\"],(function(){z.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=z.inArray(z(e).val(),t)>-1}},N.checkOn||(z.valHooks[this].get=function(e){return null===e.getAttribute(\"value\")?\"on\":e.value})})),N.focusin=\"onfocusin\"in window;var Ct=/^(?:focusinfocus|focusoutblur)$/,_t=function(e){e.stopPropagation()};z.extend(z.event,{trigger:function(e,t,i,n){var r,s,o,a,c,l,h,d,u=[i||F],f=I.call(e,\"type\")?e.type:e,p=I.call(e,\"namespace\")?e.namespace.split(\".\"):[];if(s=d=o=i=i||F,3!==i.nodeType&&8!==i.nodeType&&!Ct.test(f+z.event.triggered)&&(f.indexOf(\".\")>-1&&(p=f.split(\".\"),f=p.shift(),p.sort()),c=f.indexOf(\":\")<0&&\"on\"+f,(e=e[z.expando]?e:new z.Event(f,\"object\"==typeof e&&e)).isTrigger=n?2:3,e.namespace=p.join(\".\"),e.rnamespace=e.namespace?new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:z.makeArray(t,[e]),h=z.event.special[f]||{},n||!h.trigger||!1!==h.trigger.apply(i,t))){if(!n&&!h.noBubble&&!M(i)){for(a=h.delegateType||f,Ct.test(a+f)||(s=s.parentNode);s;s=s.parentNode)u.push(s),o=s;o===(i.ownerDocument||F)&&u.push(o.defaultView||o.parentWindow||window)}for(r=0;(s=u[r++])&&!e.isPropagationStopped();)d=s,e.type=r>1?a:h.bindType||f,(l=(ue.get(s,\"events\")||{})[e.type]&&ue.get(s,\"handle\"))&&l.apply(s,t),(l=c&&s[c])&&l.apply&&he(s)&&(e.result=l.apply(s,t),!1===e.result&&e.preventDefault());return e.type=f,n||e.isDefaultPrevented()||h._default&&!1!==h._default.apply(u.pop(),t)||!he(i)||c&&B(i[f])&&!M(i)&&((o=i[c])&&(i[c]=null),z.event.triggered=f,e.isPropagationStopped()&&d.addEventListener(f,_t),i[f](),e.isPropagationStopped()&&d.removeEventListener(f,_t),z.event.triggered=void 0,o&&(i[c]=o)),e.result}},simulate:function(e,t,i){var n=z.extend(new z.Event,i,{type:e,isSimulated:!0});z.event.trigger(n,null,t)}}),z.fn.extend({trigger:function(e,t){return this.each((function(){z.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return z.event.trigger(e,t,i,!0)}}),N.focusin||z.each({focus:\"focusin\",blur:\"focusout\"},(function(e,t){var i=function(e){z.event.simulate(t,e.target,z.event.fix(e))};z.event.special[t]={setup:function(){var n=this.ownerDocument||this,r=ue.access(n,t);r||n.addEventListener(e,i,!0),ue.access(n,t,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=ue.access(n,t)-1;r?ue.access(n,t,r):(n.removeEventListener(e,i,!0),ue.remove(n,t))}}}));var xt,kt=/\\[\\]$/,It=/\\r?\\n/g,St=/^(?:submit|button|image|reset|file)$/i,Et=/^(?:input|select|textarea|keygen)/i;function Nt(e,t,i,n){var r;if(Array.isArray(t))z.each(t,(function(t,r){i||kt.test(e)?n(e,r):Nt(e+\"[\"+(\"object\"==typeof r&&null!=r?t:\"\")+\"]\",r,i,n)}));else if(i||\"object\"!==T(t))n(e,t);else for(r in t)Nt(e+\"[\"+r+\"]\",t[r],i,n)}z.param=function(e,t){var i,n=[],r=function(e,t){var i=B(t)?t():t;n[n.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(null==i?\"\":i)};if(Array.isArray(e)||e.jquery&&!z.isPlainObject(e))z.each(e,(function(){r(this.name,this.value)}));else for(i in e)Nt(i,e[i],t,r);return n.join(\"&\")},z.fn.extend({serialize:function(){return z.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=z.prop(this,\"elements\");return e?z.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!z(this).is(\":disabled\")&&Et.test(this.nodeName)&&!St.test(e)&&(this.checked||!xe.test(e))})).map((function(e,t){var i=z(this).val();return null==i?null:Array.isArray(i)?z.map(i,(function(e){return{name:t.name,value:e.replace(It,\"\\r\\n\")}})):{name:t.name,value:i.replace(It,\"\\r\\n\")}})).get()}}),z.fn.extend({wrapAll:function(e){var t;return this[0]&&(B(e)&&(e=e.call(this[0])),t=z(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return B(e)?this.each((function(t){z(this).wrapInner(e.call(this,t))})):this.each((function(){var t=z(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=B(e);return this.each((function(i){z(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not(\"body\").each((function(){z(this).replaceWith(this.childNodes)})),this}}),z.expr.pseudos.hidden=function(e){return!z.expr.pseudos.visible(e)},z.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},N.createHTMLDocument=((xt=F.implementation.createHTMLDocument(\"\").body).innerHTML=\"
\",2===xt.childNodes.length),z.parseHTML=function(e,t,i){return\"string\"!=typeof e?[]:(\"boolean\"==typeof t&&(i=t,t=!1),t||(N.createHTMLDocument?((n=(t=F.implementation.createHTMLDocument(\"\")).createElement(\"base\")).href=F.location.href,t.head.appendChild(n)):t=F),s=!i&&[],(r=j.exec(e))?[t.createElement(r[1])]:(r=Me([e],t,s),s&&s.length&&z(s).remove(),z.merge([],r.childNodes)));var n,r,s},z.offset={setOffset:function(e,t,i){var n,r,s,o,a,c,l=z.css(e,\"position\"),h=z(e),d={};\"static\"===l&&(e.style.position=\"relative\"),a=h.offset(),s=z.css(e,\"top\"),c=z.css(e,\"left\"),(\"absolute\"===l||\"fixed\"===l)&&(s+c).indexOf(\"auto\")>-1?(o=(n=h.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(c)||0),B(t)&&(t=t.call(e,i,z.extend({},a))),null!=t.top&&(d.top=t.top-a.top+o),null!=t.left&&(d.left=t.left-a.left+r),\"using\"in t?t.using.call(e,d):h.css(d)}},z.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){z.offset.setOffset(this,e,t)}));var t,i,n=this[0];return n?n.getClientRects().length?(t=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,i,n=this[0],r={top:0,left:0};if(\"fixed\"===z.css(n,\"position\"))t=n.getBoundingClientRect();else{for(t=this.offset(),i=n.ownerDocument,e=n.offsetParent||i.documentElement;e&&(e===i.body||e===i.documentElement)&&\"static\"===z.css(e,\"position\");)e=e.parentNode;e&&e!==n&&1===e.nodeType&&((r=z(e).offset()).top+=z.css(e,\"borderTopWidth\",!0),r.left+=z.css(e,\"borderLeftWidth\",!0))}return{top:t.top-r.top-z.css(n,\"marginTop\",!0),left:t.left-r.left-z.css(n,\"marginLeft\",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&\"static\"===z.css(e,\"position\");)e=e.offsetParent;return e||Re}))}}),z.each({scrollLeft:\"pageXOffset\",scrollTop:\"pageYOffset\"},(function(e,t){var i=\"pageYOffset\"===t;z.fn[e]=function(n){return se(this,(function(e,n,r){var s;if(M(e)?s=e:9===e.nodeType&&(s=e.defaultView),void 0===r)return s?s[t]:e[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):e[n]=r}),e,n,arguments.length)}})),z.each([\"top\",\"left\"],(function(e,t){z.cssHooks[t]=it(N.pixelPosition,(function(e,i){if(i)return i=tt(e,t),Ze.test(i)?z(e).position()[t]+\"px\":i}))})),z.each({Height:\"height\",Width:\"width\"},(function(e,t){z.each({padding:\"inner\"+e,content:t,\"\":\"outer\"+e},(function(i,n){z.fn[n]=function(r,s){var o=arguments.length&&(i||\"boolean\"!=typeof r),a=i||(!0===r||!0===s?\"margin\":\"border\");return se(this,(function(t,i,r){var s;return M(t)?0===n.indexOf(\"outer\")?t[\"inner\"+e]:t.document.documentElement[\"client\"+e]:9===t.nodeType?(s=t.documentElement,Math.max(t.body[\"scroll\"+e],s[\"scroll\"+e],t.body[\"offset\"+e],s[\"offset\"+e],s[\"client\"+e])):void 0===r?z.css(t,i,a):z.style(t,i,r,a)}),t,o?r:void 0,o)}}))})),z.each(\"blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu\".split(\" \"),(function(e,t){z.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)}})),z.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),z.fn.extend({bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,\"**\"):this.off(t,e||\"**\",i)}}),z.proxy=function(e,t){var i,n,r;if(\"string\"==typeof t&&(i=e[t],t=e,e=i),B(e))return n=y.call(arguments,2),r=function(){return e.apply(t||this,n.concat(y.call(arguments)))},r.guid=e.guid=e.guid||z.guid++,r},z.holdReady=function(e){e?z.readyWait++:z.ready(!0)},z.isArray=Array.isArray,z.parseJSON=JSON.parse,z.nodeName=V,z.isFunction=B,z.isWindow=M,z.camelCase=le,z.type=T,z.now=Date.now,z.isNumeric=function(e){var t=z.type(e);return(\"number\"===t||\"string\"===t)&&!isNaN(e-parseFloat(e))};const Bt=z;function Mt(e){return\"string\"==typeof e||e instanceof String}function Rt(e){var t=String(e).split(/[.,]/);return t[0].split(\"\").reverse().reduce((function(e,t,i){return i%3==0?e+\",\"+t:e+t})).split(\"\").reverse().join(\"\")+(t[1]?\".\"+t[1]:\"\")}const Dt=function(e){return e.split(/\\n|\\r\\n|\\r/g)};function Tt(e,t){var i,n,r=[],s=e.length,o=0,a=!1;if(s>0)for(r[o]=e.charAt(0),i=1;i0?e.charAt(0).toUpperCase()+e.slice(1):e}function zt(e){if(void 0!==e.name)return e.name;if(Mt(e)){let t=e.lastIndexOf(\"/\"),i=t<0?e:e.substr(t+1);return t=i.indexOf(\"?\"),t>0&&(i=i.substr(0,t)),i}throw Error(\"Expected File or string, got \"+typeof e)}function Ht(e){return!!e&&(\"function\"!=typeof e&&(e instanceof File||e.hasOwnProperty(\"name\")&&\"function\"==typeof e.slice&&\"function\"==typeof e.arrayBuffer))}function Pt(e,t){const i=document.createElement(\"a\");i.setAttribute(\"href\",t),i.setAttribute(\"download\",e),i.style.display=\"none\",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Ot(e){for(var t=Ut,i=t.parser.loose.exec(e),n={},r=14;r--;)n[t.key[r]]=i[r]||\"\";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,i,r){i&&(n[t.q.name][i]=r)})),n}\"object\"==typeof process&&\"undefined\"==typeof window&&(global.atob=function(e){return Buffer.from(e,\"base64\").toString(\"binary\")});const Ut={strictMode:!1,key:[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"],q:{name:\"queryKey\",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/}};function qt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Qt=256,Vt=286,jt=30,Wt=15,Gt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),$t=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Yt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xt=new Array(576);qt(Xt);const Zt=new Array(60);qt(Zt);const Jt=new Array(512);qt(Jt);const ei=new Array(256);qt(ei);const ti=new Array(29);qt(ti);const ii=new Array(jt);function ni(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let ri,si,oi;function ai(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}qt(ii);const ci=e=>e<256?Jt[e]:Jt[256+(e>>>7)],li=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},hi=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{hi(e,i[2*t],i[2*t+1])},ui=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},fi=(e,t,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=Wt;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ui(n[t]++,t))}},pi=e=>{let t;for(t=0;t{e.bi_valid>8?li(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},mi=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let n,r,s,o,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?di(e,r,t):(s=ei[r],di(e,s+Qt+1,t),o=Gt[s],0!==o&&(r-=ti[s],hi(e,r,o)),n--,s=ci(n),di(e,s,i),o=$t[s],0!==o&&(n-=ii[s],hi(e,n,o)))}while(a{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)wi(e,i,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wi(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*c]=i[2*o]+i[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=c,e.heap[1]=c++,wi(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let l,h,d,u,f,p,g=0;for(u=0;u<=Wt;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)h=e.heap[l],u=i[2*i[2*h+1]+1]+1,u>c&&(u=c,g++),i[2*h+1]=u,h>n||(e.bl_count[u]++,f=0,h>=a&&(f=o[h-a]),p=i[2*h],e.opt_len+=p*(u+f),s&&(e.static_len+=p*(r[2*h+1]+f)));if(0!==g){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(u=c;0!==u;u--)for(h=e.bl_count[u];0!==h;)d=e.heap[--l],d>n||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),h--)}})(e,t),fi(i,l,e.bl_count)},vi=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a{hi(e,0+(n?1:0),3),gi(e),li(e,i),li(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var _i=e=>{Ai||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(ti[n]=i,e=0;e<1<>=7;n{let r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(vi(e,e.dyn_ltree,e.l_desc.max_code),vi(e,e.dyn_dtree,e.d_desc.max_code),Fi(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Yt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Ci(e,t,i,n):4===e.strategy||s===r?(hi(e,2+(n?1:0),3),bi(e,Xt,Zt)):(hi(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(hi(e,t-257,5),hi(e,i-1,5),hi(e,n-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ei[i]+Qt+1)]++,e.dyn_dtree[2*ci(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{hi(e,2,3),di(e,256,Xt),(e=>{16===e.bi_valid?(li(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ii=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Si=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ei=(e,t,i,n)=>{const r=Si,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Ni={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},Bi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mi,_tr_stored_block:Ri,_tr_flush_block:Di,_tr_tally:Ti,_tr_align:Li}=ki,{Z_NO_FLUSH:zi,Z_PARTIAL_FLUSH:Hi,Z_FULL_FLUSH:Pi,Z_FINISH:Oi,Z_BLOCK:Ui,Z_OK:qi,Z_STREAM_END:Qi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:ji,Z_BUF_ERROR:Wi,Z_DEFAULT_COMPRESSION:Gi,Z_FILTERED:$i,Z_HUFFMAN_ONLY:Ki,Z_RLE:Yi,Z_FIXED:Xi,Z_DEFAULT_STRATEGY:Zi,Z_UNKNOWN:Ji,Z_DEFLATED:en}=Bi,tn=258,nn=262,rn=42,sn=113,on=666,an=(e,t)=>(e.msg=Ni[t],t),cn=e=>2*e-(e>4?9:0),ln=e=>{let t=e.length;for(;--t>=0;)e[t]=0},hn=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let dn=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},fn=(e,t)=>{Di(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,un(e.strm)},pn=(e,t)=>{e.pending_buf[e.pending++]=t},gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},mn=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=Ii(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Ei(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},wn=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-nn?e.strstart-(e.w_size-nn):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+tn;let f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,l[i+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},bn=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nn)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),hn(e),n+=t),0===e.strm.avail_in)break;if(i=mn(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=dn(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=dn(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,n,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,un(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(mn(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(mn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=s||(n||t===Oi)&&t!==zi&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=t===Oi&&0===e.strm.avail_in&&i===n?1:0,Ri(e,e.block_start,i,o),e.block_start+=i,un(e.strm)),o?3:1)},vn=(e,t)=>{let i,n;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nn&&(e.match_length=wn(e,i)),e.match_length>=3)if(n=Ti(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=dn(e,e.ins_h,e.window[e.strstart+1]);else n=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let i,n,r;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=Ti(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Ti(e,0,e.window[e.strstart-1]),n&&fn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ti(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2};function An(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const Cn=[new An(0,0,0,0,Fn),new An(4,4,8,4,vn),new An(4,5,16,8,vn),new An(4,6,32,32,vn),new An(4,4,16,16,yn),new An(8,16,32,32,yn),new An(8,16,128,128,yn),new An(8,32,128,256,yn),new An(32,128,258,1024,yn),new An(32,258,258,4096,yn)];function _n(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ln(this.dyn_ltree),ln(this.dyn_dtree),ln(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ln(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ln(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const xn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==sn&&t.status!==on?1:0},kn=e=>{if(xn(e))return an(e,Vi);e.total_in=e.total_out=0,e.data_type=Ji;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?rn:sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mi(t),qi},In=e=>{const t=kn(e);var i;return t===qi&&((i=e.state).window_size=2*i.w_size,ln(i.head),i.max_lazy_match=Cn[i.level].max_lazy,i.good_match=Cn[i.level].good_length,i.nice_match=Cn[i.level].nice_length,i.max_chain_length=Cn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Sn=(e,t,i,n,r,s)=>{if(!e)return Vi;let o=1;if(t===Gi&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==en||n<8||n>15||t<0||t>9||s<0||s>Xi||8===n&&1!==o)return an(e,Vi);8===n&&(n=9);const a=new _n;return e.state=a,a.strm=e,a.status=rn,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<{let i=t.length;if(xn(e))return Vi;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==rn||n.lookahead)return Vi;if(1===r&&(e.adler=Ii(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(ln(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,bn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=dn(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,bn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,n.wrap=r,qi},Nn={deflateInit:(e,t)=>Sn(e,t,en,15,8,Zi),deflateInit2:Sn,deflateReset:In,deflateResetKeep:kn,deflateSetHeader:(e,t)=>xn(e)||2!==e.state.wrap?Vi:(e.state.gzhead=t,qi),deflate:(e,t)=>{if(xn(e)||t>Ui||t<0)return e?an(e,Vi):Vi;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===on&&t!==Oi)return an(e,0===e.avail_out?Wi:Vi);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(un(e),0===e.avail_out)return i.last_flush=-1,qi}else if(0===e.avail_in&&cn(t)<=cn(n)&&t!==Oi)return an(e,Wi);if(i.status===on&&0!==e.avail_in)return an(e,Wi);if(i.status===rn&&0===i.wrap&&(i.status=sn),i.status===rn){let t=en+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=Ki||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,gn(i,t),0!==i.strstart&&(gn(i,e.adler>>>16),gn(i,65535&e.adler)),e.adler=1,i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(57===i.status)if(e.adler=0,pn(i,31),pn(i,139),pn(i,8),i.gzhead)pn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),pn(i,255&i.gzhead.time),pn(i,i.gzhead.time>>8&255),pn(i,i.gzhead.time>>16&255),pn(i,i.gzhead.time>>24&255),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(pn(i,255&i.gzhead.extra.length),pn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ei(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,3),i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,un(e),0!==i.pending)return i.last_flush=-1,qi;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(un(e),0!==i.pending))return i.last_flush=-1,qi;pn(i,255&e.adler),pn(i,e.adler>>8&255),e.adler=0}if(i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(0!==e.avail_in||0!==i.lookahead||t!==zi&&i.status!==on){let n=0===i.level?Fn(i,t):i.strategy===Ki?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(bn(e),0===e.lookahead)){if(t===zi)return 1;break}if(e.match_length=0,i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Yi?((e,t)=>{let i,n,r,s;const o=e.window;for(;;){if(e.lookahead<=tn){if(bn(e),e.lookahead<=tn&&t===zi)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=e.strstart+tn;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ti(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):Cn[i.level].func(i,t);if(3!==n&&4!==n||(i.status=on),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),qi;if(2===n&&(t===Hi?Li(i):t!==Ui&&(Ri(i,0,0,!1),t===Pi&&(ln(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),un(e),0===e.avail_out))return i.last_flush=-1,qi}return t!==Oi?qi:i.wrap<=0?Qi:(2===i.wrap?(pn(i,255&e.adler),pn(i,e.adler>>8&255),pn(i,e.adler>>16&255),pn(i,e.adler>>24&255),pn(i,255&e.total_in),pn(i,e.total_in>>8&255),pn(i,e.total_in>>16&255),pn(i,e.total_in>>24&255)):(gn(i,e.adler>>>16),gn(i,65535&e.adler)),un(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?qi:Qi)},deflateEnd:e=>{if(xn(e))return Vi;const t=e.state.status;return e.state=null,t===sn?an(e,ji):qi},deflateSetDictionary:En,deflateInfo:\"pako deflate (from Nodeca project)\"};const Bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Bn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:CA>=248?5:CA>=240?4:CA>=224?3:CA>=192?2:1;Dn[254]=Dn[254]=1;var Tn={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Rn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Dn[e[i]]>t?i:t}};var Ln=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0};const zn=Object.prototype.toString,{Z_NO_FLUSH:Hn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:On,Z_FINISH:Un,Z_OK:qn,Z_STREAM_END:Qn,Z_DEFAULT_COMPRESSION:Vn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Wn}=Bi;function Gn(e){this.options=Mn.assign({level:Vn,method:Wn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Nn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==qn)throw new Error(Ni[i]);if(t.header&&Nn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=\"string\"==typeof t.dictionary?Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===zn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Nn.deflateSetDictionary(this.strm,e),i!==qn)throw new Error(Ni[i]);this._dict_set=!0}}function $n(e,t){const i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Ni[i.err];return i.result}Gn.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Un:Hn,\"string\"==typeof e?i.input=Tn.string2buf(e):\"[object ArrayBuffer]\"===zn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Pn||s===On)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Nn.deflate(i,s),r===Qn)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Nn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===qn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn=function(e,t){return(t=t||{}).raw=!0,$n(e,t)},Yn=function(e,t){return(t=t||{}).gzip=!0,$n(e,t)},Xn={Deflate:Gn,deflate:$n,deflateRaw:Kn,gzip:Yn,constants:Bi};const Zn=16209;var Jn=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=16191;break e}e.msg=\"invalid literal/length code\",k.mode=Zn;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=Zn;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null;const k=new Uint16Array(16),I=new Uint16Array(16);let S,E,N,B=null;for(g=0;g<=er;g++)k[g]=0;for(m=0;m=1&&0===k[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(I[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){S=g-y,o[m]+1=p?(E=B[o[m]-p],N=x[o[m]-p]):(E=96,N=0),l=1<>y)+h]=S<<24|E<<16|N}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--k[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0};const{Z_FINISH:or,Z_BLOCK:ar,Z_TREES:cr,Z_OK:lr,Z_STREAM_END:hr,Z_NEED_DICT:dr,Z_STREAM_ERROR:ur,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr,Z_BUF_ERROR:gr,Z_DEFLATED:mr}=Bi,wr=16180,br=16190,Fr=16191,vr=16192,yr=16194,Ar=16199,Cr=16200,_r=16206,xr=16209,kr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ir(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Sr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Er=e=>{if(Sr(e))return ur;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=wr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,lr},Nr=e=>{if(Sr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Er(e)},Br=(e,t)=>{let i;if(Sr(e))return ur;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Nr(e))},Mr=(e,t)=>{if(!e)return ur;const i=new Ir;e.state=i,i.strm=e,i.window=null,i.mode=wr;const n=Br(e,t);return n!==lr&&(e.state=null),n};let Rr,Dr,Tr=!0;const Lr=e=>{if(Tr){Rr=new Int32Array(512),Dr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(sr(1,e.lens,0,288,Rr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sr(2,e.lens,0,32,Dr,0,e.work,{bits:5}),Tr=!1}e.lencode=Rr,e.lenbits=9,e.distcode=Dr,e.distbits=5},zr=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Sr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;i=e.state,i.mode===Fr&&(i.mode=vr),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=lr;e:for(;;)switch(i.mode){case wr:if(0===i.wrap){i.mode=vr;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0),l=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=xr;break}if((15&l)!==mr){e.msg=\"unknown compression method\",i.mode=xr;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits&&(i.wbits=A),A>15||A>i.wbits){e.msg=\"invalid window size\",i.mode=xr;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Ei(i.check,x,4,0)),l=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&4&i.wrap&&(i.check=Ei(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Fr;break;case 16189:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=_r;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=16193;break;case 1:if(Lr(i),i.mode=Ar,t===cr){l>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg=\"invalid block type\",i.mode=xr}l>>>=2,h-=2;break;case 16193:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=xr;break}if(i.length=65535&l,l=0,h=0,i.mode=yr,t===cr)break e;case yr:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Fr;break;case 16196:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=xr;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=sr(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=xr;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=xr;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=xr;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===xr)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=xr;break}if(i.lenbits=9,k={bits:i.lenbits},C=sr(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=xr;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=sr(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=xr;break}if(i.mode=Ar,t===cr)break e;case Ar:i.mode=Cr;case Cr:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Jn(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Fr&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=Fr;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=xr;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=xr;break}i.offset=b,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=xr;break}i.mode=16204;case 16204:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=xr;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=Cr);break;case 16205:if(0===c)break e;r[o++]=i.length,c--,i.mode=Cr;break;case _r:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<Mr(e,15),inflateInit2:Mr,inflate:Hr,inflateEnd:e=>{if(Sr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,lr},inflateGetHeader:(e,t)=>{if(Sr(e))return ur;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,lr):ur},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return Sr(e)?ur:(n=e.state,0!==n.wrap&&n.mode!==br?ur:n.mode===br&&(r=1,r=Ii(r,t,i,0),r!==n.check)?fr:(s=zr(e,t,i,i),s?(n.mode=16210,pr):(n.havedict=1,lr)))},inflateInfo:\"pako inflate (from Nodeca project)\"};var Or=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1};const Ur=Object.prototype.toString,{Z_NO_FLUSH:qr,Z_FINISH:Qr,Z_OK:Vr,Z_STREAM_END:jr,Z_NEED_DICT:Wr,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:$r,Z_MEM_ERROR:Kr}=Bi;function Yr(e){this.options=Mn.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Pr.inflateInit2(this.strm,t.windowBits);if(i!==Vr)throw new Error(Ni[i]);if(this.header=new Or,Pr.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Ur.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Pr.inflateSetDictionary(this.strm,t.dictionary),i!==Vr)))throw new Error(Ni[i])}function Xr(e,t){const i=new Yr(t);if(i.push(e),i.err)throw i.msg||Ni[i.err];return i.result}Yr.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Qr:qr,\"[object ArrayBuffer]\"===Ur.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Pr.inflate(i,o),s===Wr&&r&&(s=Pr.inflateSetDictionary(i,r),s===Vr?s=Pr.inflate(i,o):s===$r&&(s=Wr));i.avail_in>0&&s===jr&&i.state.wrap>0&&0!==e[i.next_in];)Pr.inflateReset(i),s=Pr.inflate(i,o);switch(s){case Gr:case $r:case Wr:case Kr:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===jr))if(\"string\"===this.options.to){let e=Tn.utf8border(i.output,i.next_out),t=i.next_out-e,r=Tn.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Vr||0!==a){if(s===jr)return s=Pr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Yr.prototype.onData=function(e){this.chunks.push(e)},Yr.prototype.onEnd=function(e){e===Vr&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zr=function(e,t){return(t=t||{}).raw=!0,Xr(e,t)},Jr={Inflate:Yr,inflate:Xr,inflateRaw:Zr,ungzip:Xr,constants:Bi};const{Deflate:es,deflate:ts,deflateRaw:is,gzip:ns}=Xn,{Inflate:rs,inflate:ss,inflateRaw:os,ungzip:as}=Jr;var cs=is,ls=ss,hs=os,ds=as;const us=4;function fs(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 31===t[0]&&139===t[1]}function ps(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 0!==(t[3]&us)&&66===t[12]&&67===t[13]?gs(t.buffer):ds(t)}function gs(e,t){const i=[];let n=0,r=0;for(t=t||e.byteLength-18;n100?Fs(new Uint8Array(e.buffer,e.byteOffset+t,r),i,n):function(e,t,i,n,r){for(let s=0;s=0){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t0?ds(e):e,i}return decodeURIComponent(r)}const ys={lerp:(e,t,i)=>(1-i)*e+i*t,mean:function(e){var t,i=0,n=0;for(t=0;t0?i/n:0},meanAndStdev:function(e){var t,i,n=0,r=0,s=0;for(i=0;i0?{mean:n/s,stdev:Math.sqrt(r-n*n/s)}:{mean:0,stdev:0}},median:function(e){var t=e.length;return e.sort(),t%2==0?(e[t/2-1]+e[t/2])/2:e[(t-1)/2]},percentile:function(e,t){if(0!==e.length){var i=Math.floor(e.length*((100-t)/100));return 0===i?(e.sort((function(e,t){return t-e})),e[i]):function(e,t){var i,n=new As;for(i=0;in.content[0])&&(n.content.length===t&&n.pop(),n.push(r))}return n.content[0]}(e,i)}},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},log2:function(e){return Math.log(e)/Math.LN2}};function As(){this.content=[]}function Cs(e,t){return Math.random()*(t-e)+e}As.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},remove:function(e){for(var t=this.content.length,i=0;i0;){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=t,this.content[e]=r,e=n}},sinkDown:function(e){for(var t=this.content.length,i=this.content[e],n=i;;){var r=2*(e+1),s=r-1,o=null;if(s{let e=[];for(let t=1;t>=.5;t-=.1)for(let i=0;i<1;i+=1/28){const n=\"rgb(\"+_s.hsvToRgb(i,1,t).join(\",\")+\")\";e.push(n)}return e.pop(),e.push(_s.rgbColor(16,16,16)),e},rgbToHex:function(e){return(e=e.match(/^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i))&&4===e.length?\"#\"+(\"0\"+parseInt(e[1],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[2],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[3],10).toString(16)).slice(-2):\"\"},hexToRgb:function(e){var t=/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(e);if(null!==t)return\"rgb(\"+parseInt(t[1],16)+\",\"+parseInt(t[2],16)+\",\"+parseInt(t[3],16)+\")\"},hsvToRgb:function(e,t,i){var n,r,s,o=Math.floor(6*e),a=6*e-o,c=i*(1-t),l=i*(1-a*t),h=i*(1-(1-a)*t);switch(o%6){case 0:n=i,r=h,s=c;break;case 1:n=l,r=i,s=c;break;case 2:n=c,r=i,s=h;break;case 3:n=c,r=l,s=i;break;case 4:n=h,r=c,s=i;break;case 5:n=i,r=c,s=l}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(e,t,i){var n,r,s;if(0===t)n=r=s=i;else{var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=_s.hue2rgb(a,o,e+1/3),r=_s.hue2rgb(a,o,e),s=_s.hue2rgb(a,o,e-1/3)}return[255*n,255*r,255*s]},hue2rgb:(e,t,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e),rgbaColor:function(e,t,i,n){return\"rgba(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\",\"+(n=ys.clamp(n,0,1))+\")\"},rgbColor:function(e,t,i){return\"rgb(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\")\"},greyScale:function(e){var t=ys.clamp(e,0,255);return\"rgb(\"+t+\",\"+t+\",\"+t+\")\"},randomGrey:function(e,t){e=ys.clamp(e,0,255),t=ys.clamp(t,0,255);var i=Math.round(Cs(e,t)).toString(10);return\"rgb(\"+i+\",\"+i+\",\"+i+\")\"},randomRGB:function(e,t){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgb(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\")\"},randomRGBConstantAlpha:function(e,t,i){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgba(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+i+\")\"},addAlpha:function(e,t){if(\"0\"===e||\".\"===e)e=\"rgb(0,0,0)\";else{const t=this.colorNameToHex(e);t&&(e=t)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);if(e.startsWith(\"rgba\")){const i=e.lastIndexOf(\",\");return e.substring(0,i+1)+t.toString()+\")\"}return i&&(e=_s.hexToRgb(e)),e.startsWith(\"rgb\")?e.replace(\"rgb\",\"rgba\").replace(\")\",\", \"+t+\")\"):(console.log(e+\" is not an rgb style string\"),e)},rgbComponents:function(e){if(\"0\"===e||\".\"===e)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e))e=_s.hexToRgb(e);else if(!e.startsWith(\"rgb\")){const t=this.colorNameToHex(e);e=this.hexToRgb(t)}if(e.startsWith(\"rgb(\"))return e.substring(4,e.length-1).split(\",\").map((e=>Number.parseInt(e.trim())));if(e.startsWith(\"rgba(\"))return e.substring(5,e.length-1).split(\",\").map(((e,t)=>(e=e.trim(),3===t?Number.parseFloat(e):Number.parseInt(e))));throw Error(\"Unrecognized color string: color\")},getCompositeColor:function(e,t,i){return\"rgb(\"+Math.floor(i*t[0]+(1-i)*e[0])+\",\"+Math.floor(i*t[1]+(1-i)*e[1])+\",\"+Math.floor(i*t[2]+(1-i)*e[2])+\")\"},createColorString:function(e){const t=this.createColorStringSafe(e);return t||e},createColorStringSafe:function(e){if((e=function(e){return void 0===e||((e.startsWith(\"'\")||e.startsWith('\"'))&&(e=e.substring(1)),(e.endsWith(\"'\")||e.endsWith('\"'))&&(e=e.substring(0,e.length-1))),e}(e)).startsWith(\"rgb(\")&&e.endsWith(\")\"))return e;if(e.startsWith(\"#\")&&e.length<8)return e;const t=this.colorNameToHex(e);if(t)return t;const i=e.split(\",\");return 3===i.length&&xs(i[0])&&xs(i[1])&&xs(i[2])?`rgb(${e})`:void 0},darkenLighten:function(e,t){let i,n=this.colorNameToHex(e);i=n?_s.hexToRgb(n):e.startsWith(\"rgb(\")?e:_s.hexToRgb(e);const r=i.replace(\")\",\"\").substring(4).split(\",\"),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+t)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+t)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+t));return\"rgb(\"+s.toString()+\",\"+o.toString()+\",\"+a.toString()+\")\"},colorNameToHex:function(e){return{aliceblue:\"#f0f8ff\",antiquewhite:\"#faebd7\",aqua:\"#00ffff\",aquamarine:\"#7fffd4\",azure:\"#f0ffff\",beige:\"#f5f5dc\",bisque:\"#ffe4c4\",black:\"#000000\",blanchedalmond:\"#ffebcd\",blue:\"#0000ff\",blueviolet:\"#8a2be2\",brown:\"#a52a2a\",burlywood:\"#deb887\",cadetblue:\"#5f9ea0\",chartreuse:\"#7fff00\",chocolate:\"#d2691e\",coral:\"#ff7f50\",cornflowerblue:\"#6495ed\",cornsilk:\"#fff8dc\",crimson:\"#dc143c\",cyan:\"#00ffff\",darkblue:\"#00008b\",darkcyan:\"#008b8b\",darkgoldenrod:\"#b8860b\",darkgray:\"#a9a9a9\",darkgreen:\"#006400\",darkkhaki:\"#bdb76b\",darkmagenta:\"#8b008b\",darkolivegreen:\"#556b2f\",darkorange:\"#ff8c00\",darkorchid:\"#9932cc\",darkred:\"#8b0000\",darksalmon:\"#e9967a\",darkseagreen:\"#8fbc8f\",darkslateblue:\"#483d8b\",darkslategray:\"#2f4f4f\",darkturquoise:\"#00ced1\",darkviolet:\"#9400d3\",deeppink:\"#ff1493\",deepskyblue:\"#00bfff\",dimgray:\"#696969\",dodgerblue:\"#1e90ff\",firebrick:\"#b22222\",floralwhite:\"#fffaf0\",forestgreen:\"#228b22\",fuchsia:\"#ff00ff\",gainsboro:\"#dcdcdc\",ghostwhite:\"#f8f8ff\",gold:\"#ffd700\",goldenrod:\"#daa520\",gray:\"#808080\",green:\"#008000\",greenyellow:\"#adff2f\",honeydew:\"#f0fff0\",hotpink:\"#ff69b4\",\"indianred \":\"#cd5c5c\",\"indigo \":\"#4b0082\",ivory:\"#fffff0\",khaki:\"#f0e68c\",lavender:\"#e6e6fa\",lavenderblush:\"#fff0f5\",lawngreen:\"#7cfc00\",lemonchiffon:\"#fffacd\",lightblue:\"#add8e6\",lightcoral:\"#f08080\",lightcyan:\"#e0ffff\",lightgoldenrodyellow:\"#fafad2\",lightgrey:\"#d3d3d3\",lightgreen:\"#90ee90\",lightpink:\"#ffb6c1\",lightsalmon:\"#ffa07a\",lightseagreen:\"#20b2aa\",lightskyblue:\"#87cefa\",lightslategray:\"#778899\",lightsteelblue:\"#b0c4de\",lightyellow:\"#ffffe0\",lime:\"#00ff00\",limegreen:\"#32cd32\",linen:\"#faf0e6\",magenta:\"#ff00ff\",maroon:\"#800000\",mediumaquamarine:\"#66cdaa\",mediumblue:\"#0000cd\",mediumorchid:\"#ba55d3\",mediumpurple:\"#9370d8\",mediumseagreen:\"#3cb371\",mediumslateblue:\"#7b68ee\",mediumspringgreen:\"#00fa9a\",mediumturquoise:\"#48d1cc\",mediumvioletred:\"#c71585\",midnightblue:\"#191970\",mintcream:\"#f5fffa\",mistyrose:\"#ffe4e1\",moccasin:\"#ffe4b5\",navajowhite:\"#ffdead\",navy:\"#000080\",oldlace:\"#fdf5e6\",olive:\"#808000\",olivedrab:\"#6b8e23\",orange:\"#ffa500\",orangered:\"#ff4500\",orchid:\"#da70d6\",palegoldenrod:\"#eee8aa\",palegreen:\"#98fb98\",paleturquoise:\"#afeeee\",palevioletred:\"#d87093\",papayawhip:\"#ffefd5\",peachpuff:\"#ffdab9\",peru:\"#cd853f\",pink:\"#ffc0cb\",plum:\"#dda0dd\",powderblue:\"#b0e0e6\",purple:\"#800080\",red:\"#ff0000\",rosybrown:\"#bc8f8f\",royalblue:\"#4169e1\",saddlebrown:\"#8b4513\",salmon:\"#fa8072\",sandybrown:\"#f4a460\",seagreen:\"#2e8b57\",seashell:\"#fff5ee\",sienna:\"#a0522d\",silver:\"#c0c0c0\",skyblue:\"#87ceeb\",slateblue:\"#6a5acd\",slategray:\"#708090\",snow:\"#fffafa\",springgreen:\"#00ff7f\",steelblue:\"#4682b4\",tan:\"#d2b48c\",teal:\"#008080\",thistle:\"#d8bfd8\",tomato:\"#ff6347\",turquoise:\"#40e0d0\",violet:\"#ee82ee\",wheat:\"#f5deb3\",white:\"#ffffff\",whitesmoke:\"#f5f5f5\",yellow:\"#ffff00\",yellowgreen:\"#9acd32\",darkgrey:\"#a9a9a9\",darkslategrey:\"#2f4f4f\",dimgrey:\"#696969\",grey:\"#808080\",lightgray:\"#d3d3d3\",lightslategrey:\"#778899\",slategrey:\"#708090\"}[e]}};function xs(e){const t=Number.parseInt(e);return!Number.isNaN(t)&&t>=0&&t<=255}const ks=\"googleapis\";class Is{constructor(){this.oauthTokens={}}setToken(e,t){t=t||ks,this.oauthTokens[t]=e}getToken(e){let t;e=e||ks;for(let i of Object.keys(this.oauthTokens)){if(Ss(i).test(e)){t=this.oauthTokens[i];break}}return t}removeToken(e){e=e||ks;for(let t of Object.keys(this.oauthTokens)){Ss(t).test(e)&&(this.oauthTokens[t]=void 0)}}}function Ss(e){return new RegExp(\"^\"+e.split(/\\*+/).map(Es).join(\".*\")+\"$\")}function Es(e){return e.replace(/[|\\\\{}()[\\]^$+*?.]/g,\"\\\\$&\")}function Ns(e){return e.includes(\"googleapis\")&&!e.includes(\"urlshortener\")||Bs(e)||Ms(e)}function Bs(e){return e.startsWith(\"gs://\")||e.startsWith(\"https://www.googleapis.com/storage\")||e.startsWith(\"https://storage.cloud.google.com\")||e.startsWith(\"https://storage.googleapis.com\")}function Ms(e){return e.indexOf(\"drive.google.com\")>=0||e.indexOf(\"www.googleapis.com/drive\")>0}function Rs(e){let{bucket:t,object:i}=function(e){let t,i;if(e.startsWith(\"gs://\")){const n=e.indexOf(\"/\",5);if(n>=0){t=e.substring(5,n);const r=e.indexOf(\"?\");i=r<0?e.substring(n+1):e.substring(n+1,r)}}else if(e.startsWith(\"https://storage.googleapis.com\")||e.startsWith(\"https://storage.cloud.google.com\")){const n=e.indexOf(\"/v1/b/\",8);if(n>0){const r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}else{const n=e.indexOf(\"/\",8),r=e.indexOf(\"/\",n+1),s=e.indexOf(\"?\",r);r>0&&(t=e.substring(n+1,r),i=s<0?e.substring(r+1):e.substring(r+1,s))}}else if(e.startsWith(\"https://www.googleapis.com/storage/v1/b\")){const n=e.indexOf(\"/v1/b/\",8),r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}if(t&&i)return{bucket:t,object:i};throw Error(`Unrecognized Google Storage URI: ${e}`)}(e);i=function(e){let t=\"\";return e.split(\"\").forEach((function(e){Ds.has(e)?t+=Ds.get(e):t+=e})),t}(i);const n=e.indexOf(\"?\");return`https://storage.googleapis.com/storage/v1/b/${t}/o/${i}${n>0?e.substring(n)+\"&alt=media\":\"?alt=media\"}`}const Ds=new Map;function Ts(){return window.google&&window.google.igv}async function Ls(e){if(!Ts())throw Error(\"Google oAuth has not been initialized\");if(google.igv.tokenResponse&&Date.now(){try{t.callback=e=>{void 0!==e.error&&n(e),google.igv.tokenResponse=e,google.igv.tokenExpiresAt=Date.now()+1e3*e.expires_in,i(e.access_token)},t.requestAccessToken({scope:e})}catch(e){console.log(e)}}))}}function zs(){return google.igv.apiKey}function Hs(e){var t=Ps(e);return t?\"https://www.googleapis.com/drive/v3/files/\"+t+\"?alt=media&supportsTeamDrives=true\":e}function Ps(e){if(e.includes(\"/open?id=\")){const t=e.indexOf(\"/open?id=\")+9,i=e.indexOf(\"&\");if(t>0&&i>t)return e.substring(t,i);if(t>0)return e.substring(t)}else{if(e.includes(\"/file/d/\")){const t=e.indexOf(\"/file/d/\")+8,i=e.lastIndexOf(\"/\");return e.substring(t,i)}if(e.startsWith(\"https://www.googleapis.com/drive\")){let t=e.indexOf(\"/files/\");const i=e.indexOf(\"?\");if(t>0)return t+=7,i>0?e.substring(t,i):e.substring(t)}}throw Error(\"Unknown Google Drive url format: \"+e)}Ds.set(\"!\",\"%21\"),Ds.set(\"#\",\"%23\"),Ds.set(\"$\",\"%24\"),Ds.set(\"%\",\"%25\"),Ds.set(\"&\",\"%26\"),Ds.set(\"'\",\"%27\"),Ds.set(\"(\",\"%28\"),Ds.set(\")\",\"%29\"),Ds.set(\"*\",\"%2A\"),Ds.set(\"+\",\"%2B\"),Ds.set(\",\",\"%2C\"),Ds.set(\"/\",\"%2F\"),Ds.set(\":\",\"%3A\"),Ds.set(\";\",\"%3B\"),Ds.set(\"=\",\"%3D\"),Ds.set(\"?\",\"%3F\"),Ds.set(\"@\",\"%40\"),Ds.set(\"[\",\"%5B\"),Ds.set(\"]\",\"%5D\"),Ds.set(\" \",\"%20\");class Os{constructor(e){this.requestsPerSecond=e.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(e,t){var i=this;return new Promise((function(t,n){i.queued.push({resolve:t,reject:n,asyncFunction:e}),i.dequeue()}))}addAll(e,t){var i=e.map(function(e){return this.add(e,t)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var e=new Date,t=1e3/this.requestsPerSecond+1,i=e-this.lastStartTime;i>=t?this._execute():setTimeout(function(){this.dequeue()}.bind(this),t-i)}}async _execute(){this.lastStartTime=new Date;var e=this.queued.shift();const t=e.asyncFunction;try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}}}function Us(){if(Ts()){return Ts()&&google.igv.tokenResponse&&Date.now()0)for(var o=0;othis._loadURL(e,t))):this._loadURL(e,t)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async _loadURL(e,t){const i=this,n=e;e=function(e){return e.startsWith(\"https://www.dropbox.com\")?e.replace(\"//www.dropbox.com\",\"//dl.dropboxusercontent.com\"):e.startsWith(\"https://drive.google.com\")?Hs(e):e.includes(\"//www.broadinstitute.org/igvdata\")?e.replace(\"//www.broadinstitute.org/igvdata\",\"//data.broadinstitute.org/igvdata\"):e.includes(\"//igvdata.broadinstitute.org\")?e.replace(\"//igvdata.broadinstitute.org\",\"//s3.amazonaws.com/igv.broadinstitute.org\"):e.includes(\"//igv.genepattern.org\")?e.replace(\"//igv.genepattern.org\",\"//igv-genepattern-org.s3.amazonaws.com\"):e.startsWith(\"ftp://ftp.ncbi.nlm.nih.gov/geo\")?e.replace(\"ftp://\",\"https://\"):e}(e);let r=(t=t||{}).oauthToken||this.getOauthToken(e);return r&&(r=await(\"function\"==typeof r?r():r)),new Promise((function(s,o){Ns(e)&&!function(e){return e.indexOf(\"X-Goog-Signature\")>-1}(e)&&(Bs(e)&&(e=Rs(e)),Ms(e=function(e){let t=Qs.apiKey;t||\"undefined\"==typeof gapi||(t=gapi.apiKey);if(void 0!==t&&!e.includes(\"key=\")){const i=e.includes(\"?\")?\"&\":\"?\";e=e+i+\"key=\"+t}return e}(e))&&function(e){if(e.includes(\"supportsTeamDrive\"))return e;{const t=e.includes(\"?\")?\"&\":\"?\";e=e+t+\"supportsTeamDrive=true\"}}(e),r||(r=Us()));const a=t.headers||{};r&&function(e,t){t&&(e[\"Cache-Control\"]=\"no-cache\",e.Authorization=\"Bearer \"+t)}(a,r);const c=t.range,l=new XMLHttpRequest,h=t.sendData||t.body,d=t.method||(h?\"POST\":\"GET\"),u=t.responseType,f=t.contentType,p=t.mimeType;if(l.open(d,e),t.timeout&&(l.timeout=t.timeout),c){let e=\"\";c.size&&(e=c.start+c.size-1),l.setRequestHeader(\"Range\",\"bytes=\"+c.start+\"-\"+e)}if(f&&l.setRequestHeader(\"Content-Type\",f),p&&l.overrideMimeType(p),u&&(l.responseType=u),a)for(let e of Object.keys(a)){const t=a[e];l.setRequestHeader(e,t)}!0===t.withCredentials&&(l.withCredentials=!0),l.onload=async function(n){if(0===l.status||l.status>=200&&l.status<=300)if(\"HEAD\"===t.method){const e=t.requestedHeaders||[\"content-length\"],i={};for(let t of e)i[t]=l.getResponseHeader(t);s(i)}else c&&206!==l.status&&0!==c.start?(l.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${e}. This can have severe performance impacts.`),s(l.response.slice(c.start,c.start+c.size))):s(l.response);else 416===l.status?g(Error(\"416 Unsatisfiable Range\")):!Ts()||404!==l.status&&401!==l.status&&403!==l.status||!Ns(e)||t.retries?403===l.status?g(\"Access forbidden: \"+e):g(l.status):m()},l.onerror=function(i){Ns(e)&&!t.retries?m():g(\"Error accessing resource: \"+e+\" Status: \"+l.status)},l.ontimeout=function(e){g(\"Timed out\")},l.onabort=function(e){console.log(\"Aborted\"),o(e)};try{l.send(h)}catch(i){Ns(e)&&!t.retries?m():g(i)}function g(e){if(!o)throw e;o(e)}async function m(){try{const e=await async function(e){if(Ts()){const t=function(e){return Ms(e)?\"https://www.googleapis.com/auth/drive.file\":Bs(e)?\"https://www.googleapis.com/auth/devstorage.read_only\":\"https://www.googleapis.com/auth/userinfo.profile\"}(e);return await Ls(t)}throw Error(\"Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.\")}(n);t.retries=1,t.oauthToken=e;const r=await i.load(n,t);s(r)}catch(e){if(e.error){const t=e.error.startsWith(\"popup_blocked\")?\"Google login popup blocked by browser.\":e.error;alert(t)}else g(e)}}}))}async _loadFileSlice(e,t){let i=t&&t.range?e.slice(t.range.start,t.range.start+t.range.size):e;const n=await i.arrayBuffer();return\"arraybuffer\"===t.responseType?n:qs(n)}async _loadStringFromFile(e,t){const i=t.range?e.slice(t.range.start,t.range.start+t.range.size):e;return qs(await i.arrayBuffer())}async _loadStringFromUrl(e,t){(t=t||{}).responseType=\"arraybuffer\";return qs(await this.load(e,t))}setOauthToken(e,t){this.oauth.setToken(e,t)}getOauthToken(e){const t=Ns(e)?void 0:Ot(e).host;let i=this.oauth.getToken(t);if(i)return i;if(void 0===t){const e=Us();if(e&&e.expires_at>Date.now())return e.access_token}}async getContentLength(e,t){(t=t||{}).method=\"HEAD\",t.requestedHeaders=[\"content-length\"];const i=(await this._loadURL(e,t))[\"content-length\"];return i?Number.parseInt(i):0}};var Vs={color:1};Vs.parent=Vs,Vs.left=Vs,Vs.right=Vs;class js{constructor(){this.root=Vs}insert(e,t,i){var n=new Xs(new Ys(e,t,i));for(this.treeInsert(n),n.color=2;n!==this.root&&2===n.parent.color;)if(n.parent===n.parent.parent.left){let e=n.parent.parent.right;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,Gs.call(this,n)),n.parent.color=1,n.parent.parent.color=2,$s.call(this,n.parent.parent))}else{let e=n.parent.parent.left;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,$s.call(this,n)),n.parent.color=1,n.parent.parent.color=2,Gs.call(this,n.parent.parent))}this.root.color=1}findOverlapping(e,t){var i=new Ys(e,t,0);if(this.root===Vs)return[];var n=Ws.call(this,i,this.root,[]);return n.length>1&&n.sort((function(e,t){return e.low-t.low})),n}logIntervals(){!function e(t,i){for(var n=\"\",r=0;r=e.low&&Ws.call(this,e,t.left,i),t.right!==Vs&&t.right.min<=e.high&&Ws.call(this,e,t.right,i),i}function Gs(e){var t=e.right;e.right=t.left,t.left!==Vs&&(t.left.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,Ks.call(this,e)}function $s(e){var t=e.left;e.left=t.right,t.right!==Vs&&(t.right.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t,Ks.call(this,e)}function Ks(e){for(;e!==Vs;){var t=e.left.max>e.right.max?e.left.max:e.right.max,i=e.interval.high;e.max=t>i?t:i;var n=e.left.mine.low?1:this.highe.high?1:0}overlaps(e){return this.low<=e.high&&e.low<=this.high}}function Xs(e){this.parent=Vs,this.left=Vs,this.right=Vs,this.interval=e,this.color=2}class Zs{constructor(e,t,i){e=e||[],this.treeMap=this.buildTreeMap(e,t),this.range=i,this.count=e.length}containsRange(e){return void 0===this.range||this.range.contains(e.chr,e.start,e.end)}findFeatures(e){const t=[];for(let i of Object.values(this.allFeatures))for(let n of i)e(n)&&t.push(n);return t}queryFeatures(e,t,i){const n=this.treeMap[e];if(!n)return[];const r=n.findOverlapping(t,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[e];if(s){for(let e of r){const r=e.value;for(let e=r.start;ei)break;r.end>=t&&n.push(r)}}n.sort((function(e,t){return e.start-t.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(e,t){const i={},n=[];if(this.allFeatures={},e){for(let i of e){let e=i.chr;t&&(e=t.getChromosomeName(e));let r=this.allFeatures[e];r||(n.push(e),r=[],this.allFeatures[e]=r),r.push(i)}for(let e of n){const t=this.allFeatures[e];t.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1})),i[e]=Js(t)}}return i}}function Js(e){const t=new js,i=e.length,n=Math.max(10,Math.round(i/10));for(let r=0;rt.start?1:-1}));for(let r=0;ri)break;s.end>t&&e.push(s)}})),e.sort((function(e,t){return e.start-t.start})),e)}return[]};function io(e){if(3===(e=e.replace(/^#/,\"\")).length&&(e=e.split(\"\").map((e=>e+e)).join(\"\")),6!==e.length)throw new Error(\"Invalid HEX color.\");let t=parseInt(e,16);return`rgb(${t>>16&255}, ${t>>8&255}, ${255&t})`}const no={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}};function ro(e){const{r:t,g:i,b:n}=no[e];return`rgb(${t},${i},${n})`}const so={Set1:[\"rgb(228,26,28)\",\"rgb(55,126,184)\",\"rgb(77,175,74)\",\"rgb(166,86,40)\",\"rgb(152,78,163)\",\"rgb(255,127,0)\",\"rgb(247,129,191)\",\"rgb(153,153,153)\",\"rgb(255,255,51)\"],Dark2:[\"rgb(27,158,119)\",\"rgb(217,95,2)\",\"rgb(117,112,179)\",\"rgb(231,41,138)\",\"rgb(102,166,30)\",\"rgb(230,171,2)\",\"rgb(166,118,29)\",\"rgb(102,102,102)\"],Set2:[\"rgb(102, 194,165)\",\"rgb(252,141,98)\",\"rgb(141,160,203)\",\"rgb(231,138,195)\",\"rgb(166,216,84)\",\"rgb(255,217,47)\",\"rgb(229,196,148)\",\"rgb(179,179,179)\"],Set3:[\"rgb(141,211,199)\",\"rgb(255,255,179)\",\"rgb(190,186,218)\",\"rgb(251,128,114)\",\"rgb(128,177,211)\",\"rgb(253,180,98)\",\"rgb(179,222,105)\",\"rgb(252,205,229)\",\"rgb(217,217,217)\",\"rgb(188,128,189)\",\"rgb(204,235,197)\",\"rgb(255,237,111)\"],Pastel1:[\"rgb(251,180,174)\",\"rgb(179,205,227)\",\"rgb(204,235,197)\",\"rgb(222,203,228)\",\"rgb(254,217,166)\",\"rgb(255,255,204)\",\"rgb(229,216,189)\",\"rgb(253,218,236)\"],Pastel2:[\"rgb(173,226,207)\",\"rgb(253,205,172)\",\"rgb(203,213,232)\",\"rgb(244,202,228)\",\"rgb(230,245,201)\",\"rgb(255,242,174)\",\"rgb(243,225,206)\"],Accent:[\"rgb(127,201,127)\",\"rgb(190,174,212)\",\"rgb(253,192,134)\",\"rgb(255,255,153)\",\"rgb(56,108,176)\",\"rgb(240,2,127)\",\"rgb(191,91,23)\"]};class oo{constructor(e){this.colors=so[e],Array.isArray(this.colors)||(this.colors=[]),this.colorTable=new Map,this.nextIdx=0,this.colorGenerator=new co}getColor(e){return this.colorTable.has(e)||(this.nextIdxparseInt(e)))}}co.prototype.hsvToRgb=function(e,t,i){var n=Math.floor(6*e),r=6*e-n,s=i*(1-t),o=i*(1-r*t),a=i*(1-(1-r)*t),c=255,l=255,h=255;switch(n){case 0:c=i,l=a,h=s;break;case 1:c=o,l=i,h=s;break;case 2:c=s,l=i,h=a;break;case 3:c=s,l=o,h=i;break;case 4:c=a,l=s,h=i;break;case 5:c=i,l=s,h=o}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},co.prototype.padHex=function(e){return e.length>this.hexwidth?e:new Array(this.hexwidth-e.length+1).join(\"0\")+e},co.prototype.get=function(e,t){this.hue+=this.goldenRatio,this.hue%=1,\"number\"!=typeof e&&(e=.5),\"number\"!=typeof t&&(t=.95);var i=this.hsvToRgb(this.hue,e,t);return\"#\"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new co;function fo(e,t,i){if(i<.005)return e;if(i>.995)return t;{let n,r,s,o,a,c;i<.5?(i/=.5,[n,r,s]=uo(e),[o,a,c]=uo(ro(\"snow\"))):(i=(i-.5)/.5,[n,r,s]=uo(ro(\"snow\")),[o,a,c]=uo(t));const[l,h,d]=[Math.floor(ys.lerp(n,o,i)),Math.floor(ys.lerp(r,a,i)),Math.floor(ys.lerp(s,c,i))];return function(e,t,i){return`rgb(${e=ys.clamp(e,0,255)}, ${t=ys.clamp(t,0,255)}, ${i=ys.clamp(i,0,255)})`}(l,h,d)}}const po=new Set([\"bedtype\",\"alignment\",\"annotation\",\"variant\",\"wig\",\"interact\",\"shoebox\"]),go=new Set([\"alignment\",\"annotation\",\"variant\",\"eqtl\",\"qtl\",\"snp\",\"shoebox\",\"wig\"]),mo=new Set([\"sequence\",\"ruler\",\"ideogram\"]),wo={};class bo{constructor(e){this.browser=e,this.initialize()}initialize(){const e=new c;e.add(\"...\");const t={parent:this.browser.root,content:e};this.dialog=new w(t),this.browser.root.appendChild(this.dialog.elem),i(this.dialog.elem)}trackMenuItemList(e){const t=[];return\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{const e=parseInt(this.browser.inputDialog.value,10);if(void 0!==e){const t=[];this.trackView.track.selected?t.push(...this.trackView.browser.getSelectedTrackViews().map((({track:e})=>e))):t.push(this);for(const i of t)i.trackView.autoHeight=!1,void 0!==i.minHeight&&i.minHeight>e&&(i.minHeight=e),void 0!==i.maxHeight&&i.maxHeight1&&new Set(t).has(e)}(e)?t.push(...this.multiSelectMenuItems(e)):(\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?\"untitled\":e.trim(),this.name=e},i={label:\"Track Name\",value:Ao(this)||\"unnamed\",callback:t};this.browser.inputDialog.present(i,e)}return e.text(\"Set track name\"),{object:e,click:t}}()),t.push(...this.defaultMenuItems(e))),!1!==e.track.removable&&(t.push(\"
\"),t.push(function(e){const t=e.track.selected?\"Remove tracks\":\"Remove track\",i=Bt(\"
\");function n(e){this.trackView.browser._removeTrack(this)}return i.text(t),{object:i,click:n,menuItemType:\"removeTrack\"}}(e))),t}defaultMenuItems(e){const t=[];return Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),e.track.menuItemList&&t.push(...e.track.menuItemList()),function(e){const t=e.track;return t&&t.config&&void 0!==t.config.visibilityWindow||t&&go.has(t.type)}(e)&&(t.push(\"
\"),t.push(function(e){const t=Bt(\"
\");function i(t){const i=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?-1:e.trim(),this.visibilityWindow=Number.parseInt(e),this.config.visibilityWindow=Number.parseInt(e),this.trackView.updateViews()},n={label:\"wig\"===e?\"Visibility window (bp). Enter 0 for whole chromosome, -1 for whole genome.\":\"Visibility window (bp). Enter 0 for whole chromosome.\",value:this.visibilityWindow,callback:i};this.browser.inputDialog.present(n,t)}return t.text(\"Set visibility window\"),{object:t,click:i}}(e.track.type))),t}multiSelectMenuItems(e){const t=[],i=e.browser.getSelectedTrackViews();var n;return!0===(n=i.map((({track:e})=>e.type)),1===[...new Set(n)].length)?(t.push(...this.defaultMenuItems(e)),\"wig\"===e.track.type&&(t.push(\"
\"),t.push(function(){const e=Bt(\"
\");function t(e){const t=so.Dark2,i=Math.floor(Math.random()*t.length),n=`auto-scale-group-${s()}`;wo[n]=t[i];const r=this.browser.getSelectedTrackViews();for(const{track:e}of r)e.autoscaleGroup=n;this.browser.updateViews()}return e.text(\"Group autoscale\"),{object:e,doAllMultiSelectedTracks:!0,click:t}}()))):Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),t}}function Fo({trackView:e,label:t,option:i}){const n=Bt(\"
\");return n.text(t),{object:n,click:()=>e.presentColorPicker(i)}}function vo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.color=void 0,e.repaintViews()}}}function yo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.altColor=void 0,e.repaintViews()}}}function Ao(e){return e.name}function Co(e){return void 0===e.type||po.has(e.type)}class _o{constructor(e,t){this.browser=e,this.$container=Bt(\"
\",{class:\"igv-generic-dialog-container\"}),t.append(this.$container),this.$container.offset({left:0,top:0});const i=Bt(\"
\",{class:\"igv-generic-dialog-header\"});this.$container.append(i),u(i[0],(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$minimum);const n=Bt(\"
\");n.text(\"Minimum\"),this.$minimum.append(n),this.$minimum_input=Bt(\"\"),this.$minimum.append(this.$minimum_input),this.$maximum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$maximum);const r=Bt(\"
\");r.text(\"Maximum\"),this.$maximum.append(r),this.$maximum_input=Bt(\"\"),this.$maximum.append(this.$maximum_input);const s=Bt(\"
\",{class:\"igv-generic-dialog-ok-cancel\"});this.$container.append(s),this.$ok=Bt(\"
\"),s.append(this.$ok),this.$ok.text(\"OK\"),this.$cancel=Bt(\"
\"),s.append(this.$cancel),this.$cancel.text(\"Cancel\"),this.$cancel.on(\"click\",(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),p(this.$container.get(0),i.get(0)),this.$container.hide()}configure(e){let t;if(Array.isArray(e)){t={min:Number.MAX_SAFE_INTEGER,max:-Number.MAX_SAFE_INTEGER};for(const i of e)i.track.dataRange&&(t.min=Math.min(i.track.dataRange.min,t.min),t.max=Math.max(i.track.dataRange.max,t.max))}else t=e.track.dataRange;t&&(this.$minimum_input.val(t.min),this.$maximum_input.val(t.max)),this.$minimum_input.unbind(),this.$minimum_input.on(\"keyup\",(t=>{13===t.keyCode&&this.processResults(e),t.stopImmediatePropagation()})),this.$maximum_input.unbind(),this.$maximum_input.on(\"keyup\",(t=>{13===t.keyCode&&(t.stopImmediatePropagation(),this.processResults(e))})),this.$ok.unbind(),this.$ok.on(\"click\",(t=>{this.processResults(e)}))}processResults(e){if(\"\"!==this.$minimum_input.val()&&\"\"!==this.$maximum_input.val()){const t=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());if(isNaN(t)||isNaN(i))this.browser.alert.present(new Error(\"Must input numeric values\"),void 0);else{const n=Array.isArray(e)?e:[e];for(const e of n)e.track.setDataRange({min:t,max:i})}this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\")}this.$container.offset({left:0,top:0}),this.$container.hide()}present(e){const t=e.offset().top,i=Bt(\"body\").scrollTop();this.$container.offset({left:e.width()-this.$container.width(),top:t+i}),this.$container.show()}}const xo={configureHighDPICanvas:function(e,t,i){const n=window.devicePixelRatio;e.canvas.style.width=`${t}px`,e.canvas.width=Math.floor(n*t),e.canvas.style.height=`${i}px`,e.canvas.height=Math.floor(n*i),e.scale(n,n)},setProperties:function(e,t){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];e[i]=n}},strokeLine:function(e,t,i,n,r,s){t=Math.floor(t)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(e.save(),xo.setProperties(e,s)),e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke(),s&&e.restore()},fillRect:function(e,t,i,n,r,s){s&&(e.save(),xo.setProperties(e,s)),e.fillRect(t,i,n,r),s&&e.restore()},fillPolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.fill(),n&&e.restore()},strokePolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.stroke(),n&&e.restore()},fillText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.fillText(t,0,0)}else e.fillText(t,i,n);(r||s)&&e.restore()},strokeText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.strokeText(t,0,0)}else e.strokeText(t,i,n);(r||s)&&e.restore()},strokeCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.stroke(),r&&e.restore()},fillCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.fill(),r&&e.restore()},drawArrowhead:function(e,t,i,n,r){e.save(),n||(n=5),r&&(e.lineWidth=r),e.beginPath(),e.moveTo(t,i-n/2),e.lineTo(t,i+n/2),e.lineTo(t+n,i),e.lineTo(t,i-n/2),e.closePath(),e.fill(),e.restore()},dashedLine:function(e,t,i,n,r,s,o={}){void 0===s&&(s=2),e.setLineDash([s,s]),xo.strokeLine(e,t,i,n,r,o),e.setLineDash([])},roundRect:function(e,t,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),e.beginPath(),e.moveTo(t+s,i),e.lineTo(t+n-s,i),e.quadraticCurveTo(t+n,i,t+n,i+s),e.lineTo(t+n,i+r-s),e.quadraticCurveTo(t+n,i+r,t+n-s,i+r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t,i+r,t,i+r-s),e.lineTo(t,i+s),e.quadraticCurveTo(t,i,t+s,i),e.closePath(),a&&e.stroke(),o&&e.fill()},polygon:function(e,t,i,n,r){void 0===r&&(r=!0),e.beginPath();var s=t.length;e.moveTo(t[0],i[0]);for(var o=1;o{for(let t=0;t{e.translate(t,0),e.scale(-1,1),e.translate(-t,0)}};function ko(e,t,i){var n,r=t.length;for(e.beginPath(),e.moveTo(t[0],i[0]),n=1;n1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:Oo;So&&So(e,null);let n=t.length;for(;n--;){let r=t[n];if(\"string\"==typeof r){const e=i(r);e!==r&&(Eo(t)||(t[n]=e),r=e)}e[r]=!0}return e}function Zo(e){for(let t=0;t/gm),pa=Ro(/\\${[\\w\\W]*}/gm),ga=Ro(/^data-[\\-\\w.\\u00B7-\\uFFFF]/),ma=Ro(/^aria-[\\-\\w]+$/),wa=Ro(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i),ba=Ro(/^(?:\\w+script|data):/i),Fa=Ro(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g),va=Ro(/^html$/i),ya=Ro(/^[a-z][.\\w]*(-[.\\w]+)+$/i);var Aa=Object.freeze({__proto__:null,MUSTACHE_EXPR:ua,ERB_EXPR:fa,TMPLIT_EXPR:pa,DATA_ATTR:ga,ARIA_ATTR:ma,IS_ALLOWED_URI:wa,IS_SCRIPT_OR_DATA:ba,ATTR_WHITESPACE:Fa,DOCTYPE_NAME:va,CUSTOM_ELEMENT:ya});const Ca=1,_a=3,xa=7,ka=8,Ia=9,Sa=function(){return\"undefined\"==typeof window?null:window};var Ea=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Sa();const i=t=>e(t);if(i.version=\"3.1.6\",i.removed=[],!t||!t.document||t.document.nodeType!==Ia)return i.isSupported=!1,i;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:h,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:p}=t,g=l.prototype,m=ea(g,\"cloneNode\"),w=ea(g,\"remove\"),b=ea(g,\"nextSibling\"),F=ea(g,\"childNodes\"),v=ea(g,\"parentNode\");if(\"function\"==typeof a){const e=n.createElement(\"template\");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,A=\"\";const{implementation:C,createNodeIterator:_,createDocumentFragment:x,getElementsByTagName:k}=n,{importNode:I}=r;let S={};i.isSupported=\"function\"==typeof Io&&\"function\"==typeof v&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:E,ERB_EXPR:N,TMPLIT_EXPR:B,DATA_ATTR:M,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:D,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:L}=Aa;let{IS_ALLOWED_URI:z}=Aa,H=null;const P=Xo({},[...ta,...ia,...na,...sa,...aa]);let O=null;const U=Xo({},[...ca,...la,...ha,...da]);let q=Object.seal(Do(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,V=null,j=!0,W=!0,G=!1,$=!0,K=!1,Y=!0,X=!1,Z=!1,J=!1,ee=!1,te=!1,ie=!1,ne=!0,re=!1,se=!0,oe=!1,ae={},ce=null;const le=Xo({},[\"annotation-xml\",\"audio\",\"colgroup\",\"desc\",\"foreignobject\",\"head\",\"iframe\",\"math\",\"mi\",\"mn\",\"mo\",\"ms\",\"mtext\",\"noembed\",\"noframes\",\"noscript\",\"plaintext\",\"script\",\"style\",\"svg\",\"template\",\"thead\",\"title\",\"video\",\"xmp\"]);let he=null;const de=Xo({},[\"audio\",\"video\",\"img\",\"source\",\"image\",\"track\"]);let ue=null;const fe=Xo({},[\"alt\",\"class\",\"for\",\"id\",\"label\",\"name\",\"pattern\",\"placeholder\",\"role\",\"summary\",\"title\",\"value\",\"style\",\"xmlns\"]),pe=\"http://www.w3.org/1998/Math/MathML\",ge=\"http://www.w3.org/2000/svg\",me=\"http://www.w3.org/1999/xhtml\";let we=me,be=!1,Fe=null;const ve=Xo({},[pe,ge,me],Uo);let ye=null;const Ae=[\"application/xhtml+xml\",\"text/html\"];let Ce=null,_e=null;const xe=n.createElement(\"form\"),ke=function(e){return e instanceof RegExp||e instanceof Function},Ie=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!_e||_e!==e){if(e&&\"object\"==typeof e||(e={}),e=Jo(e),ye=-1===Ae.indexOf(e.PARSER_MEDIA_TYPE)?\"text/html\":e.PARSER_MEDIA_TYPE,Ce=\"application/xhtml+xml\"===ye?Uo:Oo,H=Wo(e,\"ALLOWED_TAGS\")?Xo({},e.ALLOWED_TAGS,Ce):P,O=Wo(e,\"ALLOWED_ATTR\")?Xo({},e.ALLOWED_ATTR,Ce):U,Fe=Wo(e,\"ALLOWED_NAMESPACES\")?Xo({},e.ALLOWED_NAMESPACES,Uo):ve,ue=Wo(e,\"ADD_URI_SAFE_ATTR\")?Xo(Jo(fe),e.ADD_URI_SAFE_ATTR,Ce):fe,he=Wo(e,\"ADD_DATA_URI_TAGS\")?Xo(Jo(de),e.ADD_DATA_URI_TAGS,Ce):de,ce=Wo(e,\"FORBID_CONTENTS\")?Xo({},e.FORBID_CONTENTS,Ce):le,Q=Wo(e,\"FORBID_TAGS\")?Xo({},e.FORBID_TAGS,Ce):{},V=Wo(e,\"FORBID_ATTR\")?Xo({},e.FORBID_ATTR,Ce):{},ae=!!Wo(e,\"USE_PROFILES\")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,W=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,K=e.SAFE_FOR_TEMPLATES||!1,Y=!1!==e.SAFE_FOR_XML,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,se=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,z=e.ALLOWED_URI_REGEXP||wa,we=e.NAMESPACE||me,q=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&\"boolean\"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(q.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),K&&(W=!1),te&&(ee=!0),ae&&(H=Xo({},aa),O=[],!0===ae.html&&(Xo(H,ta),Xo(O,ca)),!0===ae.svg&&(Xo(H,ia),Xo(O,la),Xo(O,da)),!0===ae.svgFilters&&(Xo(H,na),Xo(O,la),Xo(O,da)),!0===ae.mathMl&&(Xo(H,sa),Xo(O,ha),Xo(O,da))),e.ADD_TAGS&&(H===P&&(H=Jo(H)),Xo(H,e.ADD_TAGS,Ce)),e.ADD_ATTR&&(O===U&&(O=Jo(O)),Xo(O,e.ADD_ATTR,Ce)),e.ADD_URI_SAFE_ATTR&&Xo(ue,e.ADD_URI_SAFE_ATTR,Ce),e.FORBID_CONTENTS&&(ce===le&&(ce=Jo(ce)),Xo(ce,e.FORBID_CONTENTS,Ce)),se&&(H[\"#text\"]=!0),X&&Xo(H,[\"html\",\"head\",\"body\"]),H.table&&(Xo(H,[\"tbody\"]),delete Q.tbody),e.TRUSTED_TYPES_POLICY){if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');y=e.TRUSTED_TYPES_POLICY,A=y.createHTML(\"\")}else void 0===y&&(y=function(e,t){if(\"object\"!=typeof e||\"function\"!=typeof e.createPolicy)return null;let i=null;const n=\"data-tt-policy-suffix\";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r=\"dompurify\"+(i?\"#\"+i:\"\");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn(\"TrustedTypes policy \"+r+\" could not be created.\"),null}}(p,s)),null!==y&&\"string\"==typeof A&&(A=y.createHTML(\"\"));Mo&&Mo(e),_e=e}},Se=Xo({},[\"mi\",\"mo\",\"mn\",\"ms\",\"mtext\"]),Ee=Xo({},[\"foreignobject\",\"annotation-xml\"]),Ne=Xo({},[\"title\",\"style\",\"font\",\"a\",\"script\"]),Be=Xo({},[...ia,...na,...ra]),Me=Xo({},[...sa,...oa]),Re=function(e){Po(i.removed,{element:e});try{v(e).removeChild(e)}catch(t){w(e)}},De=function(e,t){try{Po(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Po(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),\"is\"===e&&!O[e])if(ee||te)try{Re(t)}catch(e){}else try{t.setAttribute(e,\"\")}catch(e){}},Te=function(e){let t=null,i=null;if(J)e=\"\"+e;else{const t=qo(e,/^[\\r\\n\\t ]+/);i=t&&t[0]}\"application/xhtml+xml\"===ye&&we===me&&(e=''+e+\"\");const r=y?y.createHTML(e):e;if(we===me)try{t=(new f).parseFromString(r,ye)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(we,\"template\",null);try{t.documentElement.innerHTML=be?A:r}catch(e){}}const s=t.body||t.documentElement;return e&&i&&s.insertBefore(n.createTextNode(i),s.childNodes[0]||null),we===me?k.call(t,X?\"html\":\"body\")[0]:X?t.documentElement:s},Le=function(e){return _.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},ze=function(e){return e instanceof u&&(\"string\"!=typeof e.nodeName||\"string\"!=typeof e.textContent||\"function\"!=typeof e.removeChild||!(e.attributes instanceof d)||\"function\"!=typeof e.removeAttribute||\"function\"!=typeof e.setAttribute||\"string\"!=typeof e.namespaceURI||\"function\"!=typeof e.insertBefore||\"function\"!=typeof e.hasChildNodes)},He=function(e){return\"function\"==typeof c&&e instanceof c},Pe=function(e,t,n){S[e]&&zo(S[e],(e=>{e.call(i,t,n,_e)}))},Oe=function(e){let t=null;if(Pe(\"beforeSanitizeElements\",e,null),ze(e))return Re(e),!0;const n=Ce(e.nodeName);if(Pe(\"uponSanitizeElement\",e,{tagName:n,allowedTags:H}),e.hasChildNodes()&&!He(e.firstElementChild)&&Go(/<[/\\w]/g,e.innerHTML)&&Go(/<[/\\w]/g,e.textContent))return Re(e),!0;if(e.nodeType===xa)return Re(e),!0;if(Y&&e.nodeType===ka&&Go(/<[/\\w]/g,e.data))return Re(e),!0;if(!H[n]||Q[n]){if(!Q[n]&&qe(n)){if(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,n))return!1;if(q.tagNameCheck instanceof Function&&q.tagNameCheck(n))return!1}if(se&&!ce[n]){const t=v(e)||e.parentNode,i=F(e)||e.childNodes;if(i&&t){for(let n=i.length-1;n>=0;--n){const r=m(i[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,b(e))}}}return Re(e),!0}return e instanceof l&&!function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:we,tagName:\"template\"});const i=Oo(e.tagName),n=Oo(t.tagName);return!!Fe[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?\"svg\"===i:t.namespaceURI===pe?\"svg\"===i&&(\"annotation-xml\"===n||Se[n]):Boolean(Be[i]):e.namespaceURI===pe?t.namespaceURI===me?\"math\"===i:t.namespaceURI===ge?\"math\"===i&&Ee[n]:Boolean(Me[i]):e.namespaceURI===me?!(t.namespaceURI===ge&&!Ee[n])&&!(t.namespaceURI===pe&&!Se[n])&&!Me[i]&&(Ne[i]||!Be[i]):!(\"application/xhtml+xml\"!==ye||!Fe[e.namespaceURI]))}(e)?(Re(e),!0):\"noscript\"!==n&&\"noembed\"!==n&&\"noframes\"!==n||!Go(/<\\/no(script|embed|frames)/i,e.innerHTML)?(K&&e.nodeType===_a&&(t=e.textContent,zo([E,N,B],(e=>{t=Qo(t,e,\" \")})),e.textContent!==t&&(Po(i.removed,{element:e.cloneNode()}),e.textContent=t)),Pe(\"afterSanitizeElements\",e,null),!1):(Re(e),!0)},Ue=function(e,t,i){if(ne&&(\"id\"===t||\"name\"===t)&&(i in n||i in xe))return!1;if(W&&!V[t]&&Go(M,t));else if(j&&Go(R,t));else if(!O[t]||V[t]){if(!(qe(e)&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,e)||q.tagNameCheck instanceof Function&&q.tagNameCheck(e))&&(q.attributeNameCheck instanceof RegExp&&Go(q.attributeNameCheck,t)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(t))||\"is\"===t&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,i)||q.tagNameCheck instanceof Function&&q.tagNameCheck(i))))return!1}else if(ue[t]);else if(Go(z,Qo(i,T,\"\")));else if(\"src\"!==t&&\"xlink:href\"!==t&&\"href\"!==t||\"script\"===e||0!==Vo(i,\"data:\")||!he[e]){if(G&&!Go(D,Qo(i,T,\"\")));else if(i)return!1}else;return!0},qe=function(e){return\"annotation-xml\"!==e&&qo(e,L)},Qe=function(e){Pe(\"beforeSanitizeAttributes\",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:\"\",attrValue:\"\",keepAttr:!0,allowedAttributes:O};let r=t.length;for(;r--;){const s=t[r],{name:o,namespaceURI:a,value:c}=s,l=Ce(o);let h=\"value\"===o?c:jo(c);if(n.attrName=l,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Pe(\"uponSanitizeAttribute\",e,n),h=n.attrValue,Y&&Go(/((--!?|])>)|<\\/(style|title)/i,h)){De(o,e);continue}if(n.forceKeepAttr)continue;if(De(o,e),!n.keepAttr)continue;if(!$&&Go(/\\/>/i,h)){De(o,e);continue}K&&zo([E,N,B],(e=>{h=Qo(h,e,\" \")}));const d=Ce(e.nodeName);if(Ue(d,l,h)){if(!re||\"id\"!==l&&\"name\"!==l||(De(o,e),h=\"user-content-\"+h),y&&\"object\"==typeof p&&\"function\"==typeof p.getAttributeType)if(a);else switch(p.getAttributeType(d,l)){case\"TrustedHTML\":h=y.createHTML(h);break;case\"TrustedScriptURL\":h=y.createScriptURL(h)}try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),ze(e)?Re(e):Ho(i.removed)}catch(e){}}}Pe(\"afterSanitizeAttributes\",e,null)},Ve=function e(t){let i=null;const n=Le(t);for(Pe(\"beforeSanitizeShadowDOM\",t,null);i=n.nextNode();)Pe(\"uponSanitizeShadowNode\",i,null),Oe(i)||(i.content instanceof o&&e(i.content),Qe(i));Pe(\"afterSanitizeShadowDOM\",t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,a=null,l=null;if(be=!e,be&&(e=\"\\x3c!--\\x3e\"),\"string\"!=typeof e&&!He(e)){if(\"function\"!=typeof e.toString)throw $o(\"toString is not a function\");if(\"string\"!=typeof(e=e.toString()))throw $o(\"dirty is not a string, aborting\")}if(!i.isSupported)return e;if(Z||Ie(t),i.removed=[],\"string\"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Ce(e.nodeName);if(!H[t]||Q[t])throw $o(\"root node is forbidden and cannot be sanitized in-place\")}}else if(e instanceof c)n=Te(\"\\x3c!----\\x3e\"),s=n.ownerDocument.importNode(e,!0),s.nodeType===Ca&&\"BODY\"===s.nodeName||\"HTML\"===s.nodeName?n=s:n.appendChild(s);else{if(!ee&&!K&&!X&&-1===e.indexOf(\"<\"))return y&&ie?y.createHTML(e):e;if(n=Te(e),!n)return ee?null:ie?A:\"\"}n&&J&&Re(n.firstChild);const h=Le(oe?e:n);for(;a=h.nextNode();)Oe(a)||(a.content instanceof o&&Ve(a.content),Qe(a));if(oe)return e;if(ee){if(te)for(l=x.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(O.shadowroot||O.shadowrootmode)&&(l=I.call(r,l,!0)),l}let d=X?n.outerHTML:n.innerHTML;return X&&H[\"!doctype\"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Go(va,n.ownerDocument.doctype.name)&&(d=\"\\n\"+d),K&&zo([E,N,B],(e=>{d=Qo(d,e,\" \")})),y&&ie?y.createHTML(d):d},i.setConfig=function(){Ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},i.clearConfig=function(){_e=null,Z=!1},i.isValidAttribute=function(e,t,i){_e||Ie({});const n=Ce(e),r=Ce(t);return Ue(n,r,i)},i.addHook=function(e,t){\"function\"==typeof t&&(S[e]=S[e]||[],Po(S[e],t))},i.removeHook=function(e){if(S[e])return Ho(S[e])},i.removeHooks=function(e){S[e]&&(S[e]=[])},i.removeAllHooks=function(){S={}},i}();class Na{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container),this._input=document.createElement(\"input\"),this.input_container.appendChild(this._input);const r=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(r),this.ok=e(),r.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),r.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"keyup\",(e=>{\"Enter\"===e.code&&(\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)),e.stopImmediatePropagation()})),this.ok.addEventListener(\"click\",(()=>{\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)}));const s=()=>{this._input.value=\"\",i(this.container)};this.cancel.addEventListener(\"click\",s),u(n,s),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._input.value=e.value,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ba={licorice:\"#000000\",lead:\"#1e1e1e\",tungsten:\"#3a3a3a\",iron:\"#545453\",steel:\"#6e6e6e\",tin:\"#878687\",nickel:\"#888787\",aluminum:\"#a09fa0\",magnesium:\"#b8b8b8\",silver:\"#d0d0d0\",mercury:\"#e8e8e8\",snow:\"#ffffff\",cayenne:\"#891100\",mocha:\"#894800\",aspargus:\"#888501\",fern:\"#458401\",clover:\"#028401\",moss:\"#018448\",teal:\"#008688\",ocean:\"#004a88\",midnight:\"#001888\",eggplant:\"#491a88\",plum:\"#891e88\",maroon:\"#891648\",maraschino:\"#ff2101\",tangerine:\"#ff8802\",lemon:\"#fffa03\",lime:\"#83f902\",spring:\"#05f802\",seam_foam:\"#03f987\",turquoise:\"#00fdff\",aqua:\"#008cff\",blueberry:\"#002eff\",grape:\"#8931ff\",magenta:\"#ff39ff\",strawberry:\"#ff2987\",salmon:\"#ff726e\",cantaloupe:\"#ffce6e\",banana:\"#fffb6d\",honeydew:\"#cefa6e\",flora:\"#68f96e\",spindrift:\"#68fbd0\",ice:\"#68fdff\",sky:\"#6acfff\",orchid:\"#6e76ff\",lavender:\"#d278ff\",bubblegum:\"#ff7aff\",carnation:\"#ff7fd3\"};class Ma{constructor({parent:t,top:n,left:r,width:s,height:o,border:a,closeHandler:c}){let l=e({class:\"igv-ui-generic-container\"});t.appendChild(l),i(l),this.container=l,void 0!==n&&(this.container.style.top=`${n}px`),void 0!==r&&(this.container.style.left=`${r}px`),void 0!==s&&(this.container.style.width=`${s}px`),void 0!==o&&(this.container.style.height=`${o}px`),a&&(this.container.style.border=a);const h=e();this.container.appendChild(h),u(h,(e=>{i(this.container),\"function\"==typeof c&&c(e)})),p(this.container,h)}show(){n(this.container)}hide(){i(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Ra extends Ma{constructor({parent:e,width:t}){super({parent:e,width:t,border:\"1px solid gray\"})}configure(e,t){this.colorHandlers=t,this.setActiveColorHandler(\"color\"),this.createSwatches(e)}setActiveColorHandler(e){this.activeColorHandler=this.colorHandlers[e]}createSwatches(t){this.container.querySelectorAll(\".igv-ui-color-swatch\").forEach((e=>e.remove()));const i=Object.values(Ba);for(let t of i){const i=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(i),this.decorateSwatch(i,t)}if(t)for(let i of t){const t=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(t),this.decorateSwatch(t,i)}}decorateSwatch(e,t){e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(()=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(()=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),this.activeColorHandler(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),this.activeColorHandler(t)}))}}const Da={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};class Ta{constructor(t,n){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},n),this.container=e({class:\"igv-ui-alert-dialog-container\"}),t.appendChild(this.container),this.container.setAttribute(\"tabIndex\",\"-1\");const r=e();this.container.appendChild(r),this.errorHeadline=e(),r.appendChild(this.errorHeadline),this.errorHeadline.textContent=\"\";let s=e({class:\"igv-ui-alert-dialog-body\"});this.container.appendChild(s),this.body=e({class:\"igv-ui-alert-dialog-body-copy\"}),s.appendChild(this.body);let o=e();this.container.appendChild(o),this.ok=e(),o.appendChild(this.ok),this.ok.textContent=\"OK\";const a=()=>{\"function\"==typeof this.callback&&(this.callback(\"OK\"),this.callback=void 0),this.body.innerHTML=\"\",i(this.container)};this.ok.addEventListener(\"click\",(e=>{e.stopPropagation(),a()})),this.container.addEventListener(\"keypress\",(e=>{e.stopPropagation(),\"Enter\"===e.key&&a()})),p(this.container,r),i(this.container)}present(e,t){this.errorHeadline.textContent=e.message?\"ERROR\":\"\";let i=e.message||e;Da.hasOwnProperty(i)&&(i=Da[i]);const r=Ea.sanitize(i);this.body.innerHTML=r,this.callback=t,n(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class La{constructor(e){this.dialog=new Ta(e)}present(e,t){this.dialog.present(e,t)}}function za(e){if(e)switch(e.toLowerCase()){case\"bw\":case\"bigwig\":case\"wig\":case\"bedgraph\":case\"tdf\":return\"wig\";case\"vcf\":return\"variant\";case\"seg\":return\"seg\";case\"mut\":case\"maf\":return\"mut\";case\"bam\":case\"cram\":return\"alignment\";case\"hiccups\":case\"bedpe\":case\"bedpe-loop\":case\"biginteract\":return\"interact\";case\"bp\":return\"arc\";case\"gwas\":return\"gwas\";case\"bed\":case\"bigbed\":case\"bb\":case\"biggenepred\":case\"bignarrowpeak\":return\"bedtype\";case\"fasta\":return\"sequence\";case\"pytor\":return\"cnvpytor\";case\"qtl\":return\"qtl\";default:return\"annotation\"}}function Ha(e){e.featureType&&(e.type=e.type||e.featureType,e.featureType=void 0),\"junctions\"===e.type?e.type=\"junction\":\"bed\"===e.type?(e.type=\"annotation\",e.format=e.format||\"bed\"):\"annotations\"===e.type?e.type=\"annotation\":\"alignments\"===e.type?e.type=\"alignment\":\"bam\"===e.type?(e.type=\"alignment\",e.format=\"bam\"):\"vcf\"===e.type?(e.type=\"variant\",e.format=\"vcf\"):\"t2d\"===e.type?e.type=\"gwas\":\"FusionJuncSpan\"!==e.type||e.format?\"aed\"===e.type&&(e.type=\"annotation\",e.format=e.format||\"aed\"):e.format=\"fusionjuncspan\"}var Pa=Object.freeze({__proto__:null,inferTrackType:za,translateDeprecatedTypes:Ha});function Oa(e){const t=new Set([\"boolean\",\"number\",\"string\",\"symbol\"]),i=typeof e;return void 0!==e&&(t.has(i)||e.substring||e.toFixed)}function Ua(e,t){var i={oauthToken:e.oauthToken,headers:e.headers,withCredentials:e.withCredentials,filename:e.filename};return Object.assign(i,t)}const qa=function(e){var t,i;if(e&&e.length>0){t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of e)Number.isNaN(n.value)||(t=Math.min(t,n.value),i=Math.max(i,n.value));i>0&&(t=Math.min(0,t)),i<0&&(i=0)}else t=0,i=100;return{min:t,max:i}},Qa=function(e,t,i){let n=t.start,r=t.end;if(void 0===r)n-=i/2,r=n+i,r>e?(r=e,n=r-i):n<0&&(n=0,r=i);else if(r-ne?(r=e,n=r-i):(n=t-i/2,r=n+i)}t.start=Math.ceil(n),t.end=Math.floor(r)},Va=function(e){return\"number\"==typeof e?e-e==0:\"string\"==typeof e&&\"\"!==e.trim()&&Number.isFinite(+e)};async function ja(e){if(Mt(e)&&e.startsWith(\"https://drive.google.com\")){if(void 0===zs())throw Error(\"Google drive is referenced, but API key is not defined. An API key is required for Google Drive access\");const t=await async function(e){let t=\"https://www.googleapis.com/drive/v3/files/\"+Ps(e)+\"?supportsTeamDrives=true\";const i=zs();i&&(t+=\"&key=\"+i);const n=await fetch(t);let r=await n.json();if(r.error&&404===r.error.code){let e=\"https://www.googleapis.com/auth/drive.readonly\";const i=await Ls(e);if(!i)throw Error(r.error);{const e=await fetch(t,{headers:{Authorization:`Bearer ${i}`}});if(r=await e.json(),r.error)throw Error(r.error)}}return r}(e);return t.originalFileName||t.name}return zt(e)}function Wa(e){var t,i;return e>1e7?(t=\" mb\",i=e/1e6,Math.floor(i).toString()+t):e>1e4?(t=\" kb\",i=e/1e3,Rt(Math.floor(i))+t):Rt(e)+\" bp\"}function Ga(e){return Mt(e)&&e.startsWith(\"data:\")}function $a(t,i){const n=e({class:i});t.appendChild(n)}function Ka(e,t){t.parentNode.insertBefore(e,t)}function Ya(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function Xa(){return\"https:\"===window.location.protocol||\"localhost\"===window.location.hostname}class Za extends Ma{constructor({parent:e,top:t,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:e,top:t,left:i,width:n,height:r,border:\"1px solid gray\"}),Ja(this.container,o,s)}}const Ja=(t,i,n)=>{const r=Object.values(Ba);for(let n of r){const r=e({class:\"igv-ui-color-swatch\"});t.appendChild(r),ec(r,n,i)}if(n)for(let r of n){const n=e({class:\"igv-ui-color-swatch\"});t.appendChild(n),ec(n,r,i)}},ec=(e,t,i)=>{e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(i=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(t=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),i(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),i(t)}))};class tc{constructor(t,i,n,r){this.parent=t,this.popover=e({class:\"igv-ui-popover\"}),t.appendChild(this.popover),this.popoverHeader=e(),this.popover.appendChild(this.popoverHeader);const s=e();this.popoverHeader.appendChild(s),n&&(s.textContent=n);const o=e();this.popoverHeader.appendChild(o),o.appendChild(l(\"times\")),o.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault(),r?r():this.dismiss()})),!0===i&&p(this.popover,this.popoverHeader,{minX:0,minY:0}),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\"}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";const t=this.popover.parentNode,{x:i,y:n,width:r}=a(e,t);this.popover.style.top=`${n}px`;const{width:s}=this.popover.getBoundingClientRect(),o=i+s,c=o-r;this.popover.style.left=`${o>r?i-c:i}px`,this.popoverContent.style.maxWidth=`${Math.min(s,r)}px`}presentContentWithEvent(e,t){this.popover.style.display=\"block\",this.popoverContent.innerHTML=t,ic(e,this.popover,this.popoverContent)}presentMenu(e,t){if(0===t.length)return;this.popover.style.display=\"block\";const i=nc(t,this.popover);for(let e of i)this.popoverContent.appendChild(e.object);ic(e,this.popover,this.popoverContent)}dismiss(){this.popover.style.display=\"none\"}hide(){this.popover.style.display=\"none\",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const e=Object.keys(this);for(let t of e)this[t]=void 0}}function ic(e,t,i){const{x:n,y:r,width:s}=a(e,t.parentNode);t.style.top=`${r}px`;const{width:o}=t.getBoundingClientRect(),c=n+o,l=c-s;t.style.left=`${c>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}function nc(t,n){const r=t.map((function(t,r){let s;if(\"string\"==typeof t)s=e(),s.innerHTML=t;else if(\"Node\"==typeof t)s=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)s=function(t,i){const n=e({class:\"igv-ui-trackgear-popover-check-container\"}),r=h(\"check\",!0===i?\"#444\":\"transparent\");r.style.borderColor=\"gray\",r.style.borderWidth=\"1px\",r.style.borderStyle=\"solid\",n.appendChild(r);let s=e();return s.textContent=t,n.appendChild(s),n}(\"Show all bases\",t.value);else if(\"color\"===t.type){const o=new Za({parent:n.parentElement,width:364,colorHandler:e=>t.click(e)});s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);const a=e=>{o.show(),i(n),e.preventDefault(),e.stopPropagation()};s.addEventListener(\"click\",a),s.addEventListener(\"touchend\",a),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function c(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}s.addEventListener(\"click\",c),s.addEventListener(\"touchend\",c),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{object:s,init:t.init}}));return r}const rc=[[\"A\",\"T\"],[\"G\",\"C\"],[\"Y\",\"R\"],[\"W\",\"S\"],[\"K\",\"M\"],[\"D\",\"H\"],[\"B\",\"V\"]],sc=new Map;for(let _A of rc){const xA=_A[0],kA=_A[1];sc.set(xA,kA),sc.set(kA,xA),sc.set(xA.toLowerCase(),kA.toLowerCase()),sc.set(kA.toLowerCase(),xA.toLowerCase())}function oc(e){return sc.has(e)?sc.get(e):e}function ac(e){let t=\"\";for(let i of e)t+=sc.has(i)?sc.get(i):i;return t}function cc(e){let t=\"\",i=e.length;for(;i-- >0;){const n=e[i];t+=sc.has(n)?sc.get(n):n}return t}class lc{constructor(e,t,i,n){this.name=e,this.order=t,this.bpLength=i,this.altNames=n}getAltName(e){return this.altNames&&this.altNames.has(e)?this.altNames.get(e):this.name}}class hc{constructor(e,t,i,n){this.chr=e,this.start=t,this.end=i,this.features=n}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}containsRange(e){return this.chr===e.chr&&this.start<=e.start&&this.end>=e.end}get locusString(){return`${this.chr}:${this.start+1}-${this.end}`}}class dc extends hc{constructor(e,t,i,n){super(e,t,i,n)}getSequence(e,t){if(ethis.end)return null;const i=e-this.start,n=t-e;return this.features?this.features.substring(i,i+n):null}hasSequence(e,t){return e>=this.start&&t<=this.end}}const uc=Dt,fc=new Set([\"fastaURL\",\"indexURL\",\"cytobandURL\",\"indexed\"]);class pc{#e;chromosomes=new Map;sequences=new Map;constructor(e){this.fastaURL=e.fastaURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!fc.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.loadAll()}getSequenceRecord(e){return this.chromosomes.get(e)}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getSequence(e,t,i){if(0===this.sequences.size&&await this.loadAll(),!this.sequences.has(e))return;let n=this.sequences.get(e).find((e=>e.contains(t,i)));if(!n&&(n=this.sequences.get(e).find((e=>e.overlaps(t,i))),!n))return;t-=n.offset,i-=n.offset;let r=\"\";if(t<0)for(let e=t;e\")){a&&a.seq&&c.call(this,a,o++);const e=r.substr(1).split(/\\s+/),t=e[0].split(\":\");if(a.chr=t[0],a.seq=\"\",a.offset=0,t.length>1&&t[1].indexOf(\"-\")>0){const i=t[1].split(\"-\");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),e.length>1&&e[1].startsWith(\"@len=\"))try{a.length=parseInt(e[1].trim().substring(5))}catch(e){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&c.call(this,a,o)}function c(e,i){const n=e.length||e.offset+e.seq.length;if(t.has(e.chr)){const t=this.chromosomes.get(e.chr);t.bpLength=Math.max(t.bpLength,n)}else this.sequences.set(e.chr,[]),this.chromosomes.set(e.chr,new lc(e.chr,i,n)),t.add(e.chr);this.sequences.get(e.chr).push(new gc(e.offset,e.seq))}}getSequenceInterval(e,t,i){const n=this.sequences.get(e);if(n)for(let r of n){const n=r.sequence,s=r.offset,o=s+n.length;if(s<=t&&o>=i)return new dc(e,s,o,n)}}}class gc{constructor(e,t){this.offset=e,this.sequence=t}contains(e,t){return this.offset<=e&&this.end>=t}overlaps(e,t){return this.offsete}get end(){return this.offset+this.sequence.length}}const mc=Dt,wc=new Set([\"fastaURL\",\"indexURL\",\"compressedIndexURL\",\"cytobandURL\",\"indexed\"]);class bc{#e;chromosomes=new Map;constructor(e){this.file=e.fastaURL,this.indexFile=e.indexURL,this.compressedIndexFile=e.compressedIndexURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!wc.has(i)&&(t[i]=e[i]);this.config=t}getSequenceRecord(e){return this.chromosomes.get(e)}async init(){return this.getIndex()}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getIndex(){if(this.index)return this.index;{const e=await Qs.load(this.indexFile,Ua(this.config)),t=mc(e),i=t.length;let n=0,r=0;for(this.index={};nthis.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let t=0;te){c=!0;break}t=t)break}const l=i[i.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]0&&(w=Math.min(s-r,a-u),b+=m.substr(F,w),F+=w+l);F1){const e=Number.parseInt(t[1]),n=new lc(t[0],i++,e);this.chromosomes.set(t[0],n)}}}}class yc{constructor(e,t=!0){this.littleEndian=t,this.position=0,this.view=e,this.length=e.byteLength}dumpBytes(e=100){const t=this.position,i=[];for(let t=0;t<=e;t++)i.push(this.getByte());console.log(i.join(\" \")),this.setPosition(t)}setPosition(e){this.position=e}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position=0;i--)t=256*t+e[i];else for(let i=0;i0&&(t+=String.fromCharCode(e))}return t}getFloat(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e}getDouble(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e}skip(e){return this.position+=e,this.position}getVPointer(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Ac(i,t)}}class Ac{constructor(e,t){this.block=e,this.offset=t}isLessThan(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset}isEqualTo(e){return this.block===e.block&&this.offset===e.offset}print(){return this.block+\":\"+this.offset}}class Cc{static magic=2026540177;littleEndian=!0;nodeCache=new Map;static async loadBpTree(e,t,i){return new Cc(e,t,i).init()}constructor(e,t,i){this.path=e,this.config=t,this.startOffset=i}async init(){const e=await this.#t(this.startOffset,32);let t=e.getInt();if(t!==Cc.magic&&(e.setPosition(0),this.littleEndian=!this.littleEndian,e.littleEndian=this.littleEndian,t=e.getInt(),t!==Cc.magic))throw Error(`Bad magic number ${t}`);const i=e.getInt(),n=e.getInt(),r=e.getInt(),s=e.getLong(),o=e.getLong(),a=this.startOffset+32;return this.header={magic:t,blockSize:i,keySize:n,valSize:r,itemCount:s,reserved:o,nodeOffset:a},this}async search(e){this.header||await this.init();const{keySize:t,valSize:i}=this.header;if(16!==i&&8!==i)throw Error(`Unexpected valSize ${i}`);const n=async e=>{if(this.nodeCache.has(e))return this.nodeCache.get(e);{let n=await this.#t(e,4);const r=n.getByte();n.getByte();const s=n.getUShort(),o=[];if(1===r){const r=s*(t+i);n=await this.#t(e+4,r);for(let e=0;e{const i=await n(t);if(1!==i.type){let t=i.items[0].offset;for(let n=1;n>6&3]+_c[IA>>4&3]+_c[IA>>2&3]+_c[3&IA]);const kc=xc.map((e=>e.toLowerCase()));class Ic{littleEndian;metaIndex=new Map;constructor(e){this.url=e.twoBitURL||e.fastaURL,this.config=e,e.twoBitBptURL&&(this.bptURL=e.twoBitBptURL)}async init(){if(this.bptURL)this.index=await Cc.loadBpTree(this.bptURL,this.config,0);else{const e=await this._readIndex();this.index={search:async t=>e.has(t)?{offset:e.get(t)}:void 0}}}async readSequence(e,t,i){this.index||await this.init();const n=await this.getSequenceRecord(e);if(!n)return null;if(t<0)throw new TypeError(\"regionStart cannot be less than 0\");(void 0===i||i>n.dnaSize)&&(i=n.dnaSize);const r=this._getOverlappingBlocks(t,i,n.nBlocks),s=this._getOverlappingBlocks(t,i,n.maskBlocks),o=Math.floor(t/4),a=n.packedPos+o,c=Math.floor(i/4)-o+1,l=await Qs.loadArrayBuffer(this.url,{range:{start:a,size:c}}),h=new Uint8Array(l);let d=\"\";for(let e=t;ee;if(r[0]&&e>=r[0].start&&et)break;r.endn.contains(e,t,i)));if(n||(n=await this.#o(e,t,i),this.#a(n),this.#r.push(n)),n){const e=t-n.start,r=i-t;return n.features?n.features.substring(e,e+r):null}}#a(e){this.#r=this.#r.filter((t=>!e.contains(t))),this.#r.length===this.#s&&this.#r.shift(),this.browser&&this.browser.referenceFrameList.length<100&&(this.#r=this.#r.filter((e=>void 0!==this.browser.referenceFrameList.find((t=>t.overlaps(e))))))}getSequenceInterval(e,t,i){return this.#r.find((n=>n.contains(e,t,i)))}async#o(e,t,i){let n=t,r=i;if(i-t{s.features=await this.sequenceReader.readSequence(e,n,r),t(s)}));return this.#n=[s,t],t}}async init(){return this.sequenceReader.init()}get chromosomeNames(){return this.sequenceReader.chromosomeNames}getFirstChromosomeName(){return\"function\"==typeof this.sequenceReader.getFirstChromosomeName?this.sequenceReader.getFirstChromosomeName():void 0}#c(e){this.browser.referenceFrameList}}async function Nc(e,t){let i;return\"chromsizes\"===e.format?i=new vc(e.fastaURL||e.url):\"2bit\"===e.format||e.twoBitURL?i=new Ec(new Ic(e),t):Ga(e.fastaURL)||!e.indexURL?i=new pc(e):\"gbk\"===e.format||e.gbkURL||(i=new Ec(new bc(e),t)),await i.init(),i}const Bc={A:\"rgb( 0, 200, 0)\",C:\"rgb( 0,0,200)\",T:\"rgb(255,0,0)\",G:\"rgb(209,113, 5)\",N:\"rgb(80,80,80)\"};function Mc(e,t){if(e.length<6)return void console.log(\"Skipping line: \"+e.join(\" \"));var i={chr1:e[0],start1:Number.parseInt(e[1]),end1:Number.parseInt(e[2]),chr2:e[3],start2:Number.parseInt(e[4]),end2:Number.parseInt(e[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;t&&void 0===t.hiccups&&(t.hiccups=!!t.columnNames&&Dc(t.columnNames));const n=t&&t.hiccups,r=n?6:10;if(n||(e.length>6&&\".\"!==e[6]&&(i.name=e[6]),e.length>7&&\".\"!==e[7]&&(i.score=Number(e[7])),e.length>8&&\".\"!==e[8]&&(i.strand1=e[8]),e.length>9&&\".\"!==e[9]&&(i.strand2=e[9])),t){const n=t.colorColumn;n&&nr&&t.columnNames&&t.columnNames.length===e.length&&(i.extras=e.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function Rc(e,t){if(!(e.length<8))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),color:_s.createColorString(e[6]),value:Number(e[7])}}function Dc(e){return e&&(e.includes(\"fdrDonut\")||e.includes(\"fdr_donut\"))}function Tc(e,t){if(!(e.length<6))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),chr1:e[8],start1:Number.parseInt(e[9]),end1:Number.parseInt(e[10]),chr2:e[13],start2:Number.parseInt(e[14]),end2:Number.parseInt(e[15]),name:e[3],score:Number(e[4]),value:Number(e[5]),color:\".\"===e[7]?void 0:\"0\"===e[7]?\"rgb(0,0,0)\":e[7]};console.log(\"Skipping line: \"+e.join(\" \"))}class Lc{constructor(e){this.message=e}}const zc=new Map([[\"%09\",\"\\t\"],[\"%0A\",\"\\n\"],[\"%0D\",\"\\r\"],[\"%25\",\"%\"],[\"%3B\",\";\"],[\"%3D\",\"=\"],[\"%26\",\"&\"],[\"%2C\",\",\"]]);function Hc(e){if(!e.includes(\"%\"))return e;let t=\"\";for(let i=0;i0&&e2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3});let a=3;try{if(e.length>3&&a++0&&e[3].indexOf(\"=\")>0){const i=Pc(e[3],\"=\");o.attributes={};for(let e of i)o.attributes[e[0]]=e[1],null!=t.nameField&&e[0]===t.nameField&&(o.name=e[1])}o.name||(o.name=\".\"===e[3]?\"\":e[3])}if(e.length>4&&a++5&&a++6&&a++7&&a++8&&a++11&&a++1e3)return o;const i=e[10].replace(/,$/,\"\").split(\",\"),n=e[11].replace(/,$/,\"\").split(\",\");if(i.length!==n.length||t!==i.length)return o;const s=[];for(let e=0;e0&&(Yc(s,o.cdStart,o.cdEnd),o.exons=s)}if(t){let i=t.thicknessColumn,n=t.colorColumn;n&&n14&&(i.signal=Number(e[12]),i.pValue=Number(e[13]),i.qValue=Number(e[14])),i}function Qc(e,t){const i=Uc(e,t,9);if(i){const t=[\"Coverage\",\"% Showing Methylation\",\"N-mod\",\"N-canonical\",\"N-other mod\",\"N-delete\",\"N-fail\",\"N-dff\",\"N-nocall\"];for(let n=9;ni?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}function Xc(e,t){var i,n,r,s,o,a,c;if(!(e.length<9))return i=e[0],n=parseInt(e[1]),r=parseInt(e[2]),o=e[3],a=Number(e[4]),s=e[5].trim(),c=Number(e[6]),0===a&&(a=c),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:c,pValue:Number(e[7]),qValue:Number(e[8])}}function Zc(e,t){const i=Xc(e);return e.length>9&&(i.peak=Number(e[9])),i}function Jc(e,t){if(e.length<=3)return;const i={chr:e[0],start:parseInt(e[1]),end:parseInt(e[2]),value:Number(e[3])};if(t){let n=t.colorColumn;n&&n2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3}),a=[];for(let t=3;t\"),this.name&&t.push({name:\"Name\",value:this.name}),t.push({name:\"Type\",value:this.type}),t.push({name:\"Source\",value:this.source}),void 0!==this.score&&t.push({name:\"Score\",value:this.score}),t.push({name:\"Phase\",value:this.phase}),this.attributeString){const e=Pc(this.attributeString,this.delim);for(let[i,n]of e)void 0!==n&&n.length>0&&!ml.has(i.toLowerCase())&&t.push({name:i+\":\",value:n})}return t.push({name:\"Location\",value:`${this.chr}:${Rt(this.start+1)}-${Rt(this.end)}`}),t}getAttributeValue(e){if(this.hasOwnProperty(e))return this[e];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(e))return this._attributeCache.get(e);{const t=Pc(this.attributeString,this.delim);let i;for(let[n,r]of t)if(n===e){i=r;break}return this._attributeCache.set(e,i),i}}}class bl extends wl{constructor(e){super(e),this.exons=[],this.parts=[]}addExon(e){this.exons.push(e),this.start=Math.min(this.start,e.start),this.end=Math.max(this.end,e.end)}addPart(e){this.parts.push(e)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(e,t){return e.start-t.start}));let e=this.parts[0].start,t=this.parts[0].end;for(let i=1;i=t&&i.start<=e)return i}addCDS(e){let t;const i=this.exons;for(let n of i)if(n.start<=e.start&&n.end>=e.end){t=n;break}t?(t.cdStart=t.cdStart?Math.min(e.start,t.cdStart):e.start,t.cdEnd=t.cdEnd?Math.max(e.end,t.cdEnd):e.end,t.readingFrame=e.readingFrame):console.error(\"No exon found spanning \"+e.start+\"-\"+e.end),this.cdStart=this.cdStart?Math.min(e.start,this.cdStart):e.start,this.cdEnd=this.cdEnd?Math.max(e.end,this.cdEnd):e.end}addUTR(e){let t;const i=this.exons;for(let n=0;n=e.end){t=i[n];break}t?e.start===t.start&&e.end===t.end?t.utr=!0:(e.endt.start&&(t.cdEnd=e.start)):console.error(\"No exon found spanning \"+cds.start+\"-\"+cds.end)}finish(){this.assembleParts();var e=this.cdStart,t=this.cdEnd;this.exons.sort((function(e,t){return e.start-t.start})),e&&this.exons.forEach((function(i){(i.endt)&&(i.utr=!0)}))}popupData(e){const t=super.popupData(e);for(let i of this.exons)if(!i.pseudo&&e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}for(let i of this.parts)if(e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}return t}}function Fl(e,t){const i=t.format;if(e.length<9)return;const n=\"gff3\"===i?\"=\":\" \";return new wl({source:Hc(e[1]),type:e[2],chr:e[0],start:parseInt(e[3])-1,end:parseInt(e[4]),score:\".\"===e[5]?void 0:Number(e[5]),strand:e[6],phase:\".\"===e[7]?\".\":parseInt(e[7]),attributeString:e[8],delim:n})}function vl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):\"ID\"===e?i.id=t:\"Parent\"===e&&(i.parent=t)}return i}function yl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);let r,s;switch(i.type){case\"gene\":r=\"gene_id\";break;case\"transcript\":r=\"transcript_id\",s=\"gene_id\";break;default:s=\"transcript_id\"}for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):e===r?i.id=t:e===s&&(i.parent=t)}return i}function Al(e,t){if(!(e.length<7)){var i=e[0],n=e[1],r=parseInt(e[2]),s=parseInt(e[3]),o=parseInt(e[4]),a=parseInt(e[5]),c=e[6],l={chr:i,name:n,junction_left:r,junction_right:s,num_junction_reads:o,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=r,d=s;if(a>0)for(var u=c.split(\",\"),f=0;fd&&(d=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=d,l}}function Cl(e,t){if(e.length<7)return null;const i={chr:e[0],start:parseInt(e[1])-1,end:parseInt(e[2]),\"Strongest SNP-risk allele\":e[3],\"Disease/Phenotype\":e[4],\"P-value\":e[5],\"Odds ratio or beta\":e[6]};return e.length>6&&(i.PUBMEDID=`${e[7]}`),i}function _l(e,t){const i=t.customFormat;if(e.lengthvoid 0===n||!n.has(e.type))),\"gff3\"===this.format){const t=this.combineFeaturesById(e);i=this.combineFeaturesByType(t)}else i=this.combineFeaturesByType(e);return this.numberExons(i,t),this.nameFeatures(i),i}combineFeaturesById(e){const t=new Map,i=[];for(let n of e)if(gl(n.type)||pl(n.type)||!n.id)i.push(n);else{let e=t.get(n.chr);e||(e=new Map,t.set(n.chr,e));let i=e.get(n.id);i?i.push(n):e.set(n.id,[n])}for(let e of t.values())for(let t of e.values())if(t.length>1){const e=t[0];e.exons=[];for(let i of t)e.start=Math.min(e.start,i.start),e.end=Math.max(e.end,i.end),e.exons.push({start:i.start,end:i.end});i.push(e)}else i.push(t[0]);return i}combineFeaturesByType(e){const t=e.filter((e=>\"gene\"===e.type||e.type.endsWith(\"_gene\"))),i=Object.create(null);for(let e of t)i[e.id]=e;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;e=e.filter((e=>void 0===o||!o.has(e.type)));for(let t of e)if(pl(t.type)){const e=t.id;if(void 0!==e){const o=new bl(t);n[e]=o,r.push(o),s.add(t);const a=i[t.parent];a&&(o.geneObject=a,s.add(a))}}for(let t of e)if(gl(t.type)){const e=l(t);if(e)for(let i of e){let o=n[i];if(!o&&\"gtf\"===this.format){const e=Object.assign({},t);e.type=\"transcript\",o=new bl(e),n[i]=o,r.push(o)}if(void 0!==o){if(a=t.type,ll.has(a))if(e.length>1){const e=new wl(t);o.addExon(e)}else o.addExon(t);else o.addPart(t);s.add(t)}}}var a;r.forEach((function(e){\"function\"==typeof e.finish&&e.finish()}));const c=e.filter((e=>!s.has(e)));for(let e of c)r.push(e);return r;function l(e){return e.parent&&\"\"!==e.parent.trim()?e.parent.trim().split(\",\"):null}}numberExons(e,t){for(let i of e)if(i.exons&&(!t||i.end<=t.end&&i.start>t.start))for(let e=0;e1&&(t=e)}else{this.setDecoder(n.format);const e=i.split(this.delimiter||\"\\t\");try{const i=Object.assign({columnNames:t},n);if(this.decode(e,i))break;e.length>1&&(t=e)}catch(i){e.length>1&&(t=e)}}}if(t){n.columnNames=t;for(let e=0;e0&&console.error(`Error parsing line '${s}': ${c.message}`)):c&&t.push(c)}return i===Mc&&function(e){if(0==e.length)return;const t=e[0];if(void 0===t.score&&void 0!==t.name){for(let t of e)if(!Va(t.name)&&\".\"!==t.name)return;for(let t of e)t.score=Number(t.name),delete t.name}const i=e.filter((e=>e.chr1!==e.chr2));for(let t of i){const i=Object.assign({},t);i.dup=!0,e.push(i),t.chr=t.chr1,t.start=t.start1,t.end=t.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(t),\"gtf\"!==this.config.format&&\"gff3\"!==this.config.format&&\"gff\"!==this.config.format||!1===this.config.assembleGFF?t:new Il(this.config).combineFeatures(t)}setDecoder(e){switch(e){case\"broadpeak\":case\"regionpeak\":case\"peaks\":this.decode=Xc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"narrowpeak\":this.decode=Zc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedgraph\":this.decode=Jc,this.delimiter=/\\s+/;break;case\"wig\":this.decode=el,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gff3\":case\"gff\":this.decode=vl,this.delimiter=\"\\t\";break;case\"gtf\":this.decode=yl,this.delimiter=\"\\t\";break;case\"fusionjuncspan\":this.decode=Al,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gtexgwas\":this.skipRows=1,this.decode=Cl,this.delimiter=\"\\t\";break;case\"refflat\":this.decode=Gc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepred\":this.decode=jc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepredext\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"ensgene\":this.decode=jc,this.header.shift=1,this.delimiter=this.config.delimiter||/\\s+/;break;case\"refgene\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/,this.header.shift=1;break;case\"bed\":this.decode=Uc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gappedpeak\":this.decode=qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedmethyl\":this.decode=Qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedpe\":case\"hiccups\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-domain\":this.decode=Rc,this.headerLine=!0,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-loop\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\",this.header={colorColumn:7};break;case\"interact\":this.decode=Tc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"snp\":this.decode=tl,this.delimiter=\"\\t\";break;case\"rmsk\":this.decode=Vc,this.delimiter=\"\\t\";break;case\"gcnv\":this.decode=xl,this.delimiter=\"\\t\";break;case\"shoebox\":this.decode=il,this.delimiter=\"\\t\";break;default:const t=function(e){return Sl&&Sl[e]?function(e){const t=e.fields,i=[\"chr\",\"start\",\"end\"];for(let n=0;n4?parseInt(t[4].split(\"=\")[1],10):1,index:0}}function Rl(e){const t=e.split(/\\s+/);return{format:\"variableStep\",chrom:t[1].split(\"=\")[1],span:t.length>2?parseInt(t[2].split(\"=\")[1],10):1}}function Dl(t,i){const n=e({class:\"igv-menu-popup-check-container\"}),r=e();n.appendChild(r);const s=l(\"check\",!0===i?\"#444\":\"transparent\");r.appendChild(s);const o=e();return o.innerText=t,n.appendChild(o),n}function Tl(e,t){t=t||Number.MAX_SAFE_INTEGER;const i=[];e.sort((function(e,t){return e.start-t.start})),i.push(-1e3);for(let n of e){let e=0;const r=Math.min(i.length,t);for(e=0;e=i[e]){n.row=e,i[e]=n.end;break}n.row=e,i[e]=n.end}}async function Ll(e,t,i){const n=e=>{const i=Object.assign({},e);return i.chr=\"all\",i.start=t.getGenomeCoordinate(e.chr,e.start),i.end=t.getGenomeCoordinate(e.chr,e.end),i._f=e,i.exons&&delete i.exons,i},r=new Set(t.wgChromosomeNames),s=[];let o=0;for(let a of t.wgChromosomeNames){if(Array.isArray(e)){const i={};for(let n of e){const e=t.getChromosomeName(n.chr);i.hasOwnProperty(e)||(i[e]=[]),i[e].push(n)}e=i}const c=e[a];if(c){const e=i||1e4;for(let i of c){let a=t.getChromosomeName(i.chr);if(r.has(a))if(s.length0&&!i.startsWith(\"rgb(\")&&!i.startsWith(\"rgba(\")?`rgb(${i})`:i);var i;e.name||e.label?this.name=e.name||e.label:Ht(e.url)?this.name=e.url.name:Mt(e.url)&&!e.url.startsWith(\"data:\")&&(this.name=zt(e.url)),this.url=e.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=e.order,this.autoscaleGroup=e.autoscaleGroup,this.removable=void 0===e.removable||e.removable,this.minHeight=e.minHeight||Math.min(25,this.height),this.maxHeight=e.maxHeight||Math.max(1e3,this.height),e.onclick&&(this.onclick=e.onclick,e.onclick=void 0),e.description&&(\"function\"==typeof e.description?this.description=e.description:this.description=()=>e.description),e.hoverTextFields?this.hoverText=Pl.bind(this):\"function\"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(e){this._name=e,this.trackView&&this.trackView.setTrackLabelName(e)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}repaintViews(){this.trackView&&this.trackView.repaintViews()}getState(){const e={},t=Object.keys(this.config).filter((e=>{return!(void 0===(t=this.config[e])||\"function\"==typeof t||t instanceof Promise);var t}));for(const i of t)i.startsWith(\"_\")||(e[i]=this.config[i]);for(let t of Object.keys(e)){if(t.startsWith(\"_\"))continue;const i=this[t];void 0===i||!Oa(i)&&\"boolean\"!=typeof i&&\"metadata\"!==t||(e[t]=i)}const i=Object.assign({},Hl.defaults);if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))i[e]=this.constructor.defaults[e];for(let t of Object.keys(i))void 0!==this[t]&&i[t]!==this[t]&&(e[t]=this[t]);return!this.autoscale&&this.dataRange&&(e.min=this.dataRange.min,e.max=this.dataRange.max),this.autoscaleGroup&&(e.autoscaleGroup=this.autoscaleGroup),e}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(e){if(this.disposed)return;const t={};let i;for(let n of Object.keys(e))switch(n.toLowerCase()){case\"usescore\":t.useScore=1===e[n]||\"1\"===e[n]||\"on\"===e[n]||!0===e[n];break;case\"visibility\":switch(e[n]){case\"2\":case\"3\":case\"pack\":case\"full\":t.displayMode=\"EXPANDED\";break;case\"4\":case\"squish\":t.displayMode=\"SQUISHED\";break;case\"1\":case\"dense\":t.displayMode=\"COLLAPSED\"}break;case\"color\":case\"altcolor\":t[n]=e[n].startsWith(\"rgb(\")?e[n]:\"rgb(\"+e[n]+\")\";break;case\"featurevisiblitywindow\":case\"visibilitywindow\":t.visibilityWindow=Number.parseInt(e[n]);break;case\"maxheightpixels\":i=e[n].split(\":\"),3===i.length&&(t.minHeight=Number.parseInt(i[2]),t.height=Number.parseInt(i[1]),t.maxHeight=Number.parseInt(i[0]));break;case\"viewlimits\":if(!this.config.autoscale){i=e[n].split(\":\");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),Number.isNaN(r)||Number.isNaN(s)?console.warn(`Unexpected viewLimits value in track line: ${e.viewLimits}`):(t.autoscale=!1,t.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r)}case\"name\":t[n]=e[n];break;case\"url\":t.infoURL=e[n];break;case\"type\":const r=e[n];Ol.has(r)?t[n]=Ol.get(r):t[n]=r;break;case\"graphtype\":t.graphType=e[n];break;default:t[n]=e[n]}for(let e of Object.keys(t))if(!this.config.hasOwnProperty(e)||\"name\"===e&&this.config._derivedName){let i=t[e];if(\"true\"===i&&(i=!0),\"false\"===i&&(i=!1),this[e]=i,\"height\"===e&&this.trackView)try{const e=Number.parseInt(i);this.trackView.setTrackHeight(e)}catch(e){console.error(e)}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!Array.isArray(t)||0===t.length)return[];const i=e.genomicLocation,n=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2;return to(t,i-n,i+n)}extractPopupData(e,t){const i=new Set([\"row\",\"color\",\"chr\",\"start\",\"end\",\"cdStart\",\"cdEnd\",\"strand\",\"alpha\"]),n=[];let r,s;for(let t in e)if(e.hasOwnProperty(t)&&!i.has(t)&&Oa(e[t])){let i=e[t];n.push({name:Lt(t),value:i}),\"alleles\"===t?r=e[t]:\"alleleFreqs\"===t&&(s=e[t])}if(r&&s){r.endsWith(\",\")&&(r=r.substr(0,r.length-1)),s.endsWith(\",\")&&(s=s.substr(0,s.length-1));let i=r.split(\",\"),o=s.split(\",\");if(o.length>1){let r=[];for(let e=0;e=0;i--){let o=r[i].a;if(1===o.length){t||(t=this.getGenomeId());const i=Hl.getCravatLink(e.chr,e.start+1,s,o,t);console.log(i),i&&(n.push(\"
\"),n.push({html:i}),n.push(\"
\"))}}}}if(e.attributes)for(let t of Object.keys(e.attributes))n.push({name:t,value:e.attributes[t]});let o=`${e.chr}:${Rt(e.start+1)}-${Rt(e.end)}`;return e.strand&&(o+=` (${e.strand})`),n.push({name:\"Location\",value:o}),n}description(){const e=(e,t)=>`
${e}: ${t}
`;let t='
';if(this.url?Ht(this.url)?t+=e(\"Filename\",this.url.name):t+=e(\"URL\",this.url):t=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata)){t+=e(i,this.config.metadata[i])}for(let i of Object.keys(this.config)){if(i.startsWith(\"_\"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&Oa(n)&&(t+=e(i,n))}}}return t+=\"
\",t}getColorForFeature(e){return\"function\"==typeof this.color?this.color(feature):this.color}numericDataMenuItems(){const e=[];e.push(\"
\");let t=Bt(\"
\");if(t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),void 0!==this.logScale){function i(){this.logScale=!this.logScale,this.trackView.repaintViews()}t=Bt(Dl(\"Log scale\",this.logScale)),e.push({object:t,click:i})}return t=Bt(Dl(\"Autoscale\",this.autoscale)),e.push({object:t,click:function(){this.autoscaleGroup=void 0,this.autoscale=!this.autoscale,this.browser.updateViews()}}),e}setDataRange({min:e,max:t}){this.dataRange={min:e,max:t},this.autoscale=!1,this.autoscaleGroup=void 0,this.trackView.repaintViews()}async nextFeatureAfter(e,t,i){let n=this.trackView.viewports[0].cachedFeatures;if(n&&Array.isArray(n)&&n.length>0){if(this.browser.genome.getChromosomeName(n[0].chr)===e){const e=function(e,t,i=!0){const n=e=>(e.start+e.end)/2,r=i?(e,t)=>e.start-t.start+e.end-t.end:(e,t)=>t.start-e.start+t.end-e.end,s=Array.from(e);s.sort(r);let o=0,a=s.length;for(;o=t?o=e+1:a=e}return s[o]}(n,t,i);if(e)return e}}if(\"function\"==typeof this.featureSource.nextFeature)return this.featureSource.nextFeature(e,t,i,this.visibilityWindow)}dispose(){this.disposed=!0;for(let e of Object.keys(this))this[e]=void 0}static getCravatLink(e,t,i,n,r){if(\"hg38\"===r||\"GRCh38\"===r){return`Cravat ${i}->${n}`}}static localFileInspection(e){const t=Object.assign({},e),i={url:\"file\",indexURL:\"indexFile\"};for(const e of[\"url\",\"indexURL\"])t[e]&&t[e]instanceof File&&(t[i[e]]=t[e].name,delete t[e]);return t}}function Pl(e){if(!this.hoverTextFields)return;const t=this.clickedFeatures(e);if(t&&t.length>0){let e=\"\";for(let i=0;i0&&(e+=\"\\n\"),e=\"\";for(let t of this.hoverTextFields)e.length>0&&(e+=\"\\n\"),n.hasOwnProperty(t)?e+=n[t]:\"function\"==typeof n.getAttribute&&(e+=n.getAttribute(t))}return e}}const Ol=new Map([[\"wiggle_0\",\"wig\"],[\"bed\",\"bed\"],[\"bigBed\",\"bigBed\"],[\"bigWig\",\"bigWig\"]]);class Ul{constructor(e){switch(this.type=e||\"seg\",this.type){case\"mut\":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case\"maf\":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(e){let t;for(;void 0!==(t=await e.nextLine());)if(!t.startsWith(\"#\")){const e=t.split(\"\\t\");this.header={headings:e};break}return this.header}async parseFeatures(e){const t=[];let i;this.header||(this.header=await this.parseHeader(e)),\"seg\"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await e.nextLine());){const e=r.split(\"\\t\"),s=\"seg\"===this.type?Number(e[this.dataColumn]):e[this.dataColumn];if(e.length>this.dataColumn){const r=new ql({sample:e[this.sampleColumn],chr:e[this.chrColumn],start:parseInt(e[this.startColumn])-1,end:parseInt(e[this.endColumn]),value:s,valueColumnName:n});if(i){const t=this.extractExtraColumns(e);r.setAttributes({names:i,values:t})}t.push(r)}}return t}extractExtraColumns(e){const t=[];for(let i=0;i=0)return this.attributeValues[t]}}popupData(e,t){const i=new Set([\"chr\",\"start\",\"end\",\"sample\",\"value\",\"row\",\"color\",\"sampleKey\",\"uniqueSampleKey\",\"sampleId\",\"chromosome\",\"uniquePatientKey\"]),n=this.chr+\":\"+Rt(this.start+1)+\"-\"+Rt(this.end),r=[{name:\"Sample\",value:this.sample},{name:\"Location\",value:n},{name:this.valueColumnName?Lt(this.valueColumnName):\"Value\",value:this.value}];if(\"mut\"===e&&\"hg38\"===t){const e=this.extractCravatLink(t);e&&(r.push(\"
\"),r.push({html:e}),r.push(\"
\"))}if(this.attributeNames&&this.attributeNames.length>0)for(let e=0;e0)for(let n=0;n\"===t||\"<*>\"===t||\".\"===t)return\"NONVARIANT\";{const e=t.split(\",\").map((function(e){return 1===i&&1===e.length?\"SNP\":\"\"===e?\"NONVARIANT\":e.length>i&&$l(e)?\"INSERTION\":e.lengthe.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let t of i)if(this.alleles.push(t),\"SV\"!==this.type&&$l(t)){let i=t.length,n=e.length;const r=Math.min(i,n);let s=0;for(;s0&&n>0;){const r=s+i-1,o=s+n-1;if(t.charCodeAt(r)!==e.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(t.charCodeAt(r)!==e.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos),this.start===this.end&&(this.start-=.5,this.end+=.5)}}popupData(e,t){const i=`${Rt(this.pos)}`,n=this.start===this.end?`${Rt(this.start)} | ${Rt(this.start+1)}`:`${Rt(this.start+1)}-${Rt(this.end)}`,r=[{name:\"Chr\",value:this.chr},{name:\"Pos\",value:i},{name:\"Loc\",value:n},{name:\"ID\",value:this.names?this.names:\"\"},{name:\"Ref\",value:this.referenceBases},{name:\"Alt\",value:this.alternateBases.replace(\"<\",\"<\")},{name:\"Qual\",value:this.quality},{name:\"Filter\",value:this.filter}];if(this.type&&r.push({name:\"Type\",value:this.type}),\"SNP\"===this.type){let e=this.referenceBases;if(1===e.length){let i=this.alternateBases.split(\",\");for(let n of i)if(1===n.length){let i=Hl.getCravatLink(this.chr,this.pos,e,n,t);i&&(r.push(\"
\"),r.push({html:i}))}}}const s=Object.keys(this.info);if(this.info&&s.length>0){r.push({html:'
'});for(let e of s)r.push({name:e,value:Kl(decodeURIComponent(this.info[e]))})}return r}getInfo(e){return this.info?this.info[e]:void 0}isRefBlock(){return\"NONVARIANT\"===this.type}isFiltered(){return!(\".\"===this.filter||\"PASS\"===this.filter)}alleleFreq(){return this.info?this.info.AF:void 0}}class jl{constructor(e){this.mate=e,this.chr=e.info.CHR2,this.pos=Number.parseInt(e.info.END),this.start=this.pos-1,this.end=this.pos}get info(){return this.mate.info}get names(){return this.mate.names}get referenceBases(){return this.mate.referenceBases}get alternateBases(){return this.mate.alternateBases}get quality(){return this.mate.quality}get filter(){return this.mate.filter}get calls(){return this.mate.calls}getAttributeValue(e){return this.mate.getAttributeValue(e)}getInfo(e){this.mate.getInfo(e)}isFiltered(){return this.mate.isFiltered()}alleleFreq(){return this.mate.alleleFreq()}popupData(e,t){const i=[];return i.push(\"SV Breakpoint\"),i.push({name:\"Chr\",value:this.chr}),i.push({name:\"Pos\",value:`${Rt(this.pos)}`}),i.push({html:'
'}),i.push(\"SV\"),i.push(...this.mate.popupData(e,t)),i}}class Wl{constructor({formatFields:e,sample:t,token:i}){this.info={},this.sample=t;const n=i.split(\":\");for(let t=0;t\");for(let e of r)i.push({name:e,value:decodeURIComponent(this.info[e])});return i}}const Gl=new Set([\"A\",\"C\",\"T\",\"G\"].map((e=>e.charCodeAt(0))));function $l(e){for(let t=0;t\");if(!(t>2&&o>0)){console.log(\"Malformed VCF header line: \"+n);continue}const a=n.substring(2,t-1);i[a]||(i[a]={});const c=Tt(n.substring(t+1,o-1),\",\");for(let t of c){var r=t.split(\"=\");r.length>1&&(\"ID\"===r[0]?e=r[1]:s[r[0]]=r[1])}e&&(i[a][e]=s)}else if(n.startsWith(\"##contig\")&&t){const e=n.indexOf(\"\",e));const s=n.substring(e+4,r),o=t.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith(\"#CHROM\")){const e=n.split(\"\\t\");if(e.length>8){i.sampleNameMap=new Map;for(let t=9;t9){const r=Xl(e[8].split(\":\"));n.calls=[];for(let t=9;t{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))0||0==i.length||i.indexOf(\"x\")>0)continue;const s=e[this.chrCol],o=r(e[this.valueCol]),a=parseInt(i)-1,c=a+1;t.push(new eh({chr:s,start:a,end:c,value:o,line:n,columns:this.columns}))}}return t}static isGWAS(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class eh{constructor({chr:e,start:t,end:i,value:n,line:r,columns:s}){this.chr=e,this.start=t,this.end=i,this.value=n,this.line=r,this.columns=s}popupData(){const e=this.line.split(/\\t/);return this.columns.map((function(t,i){return{name:t,value:e[i]}}))}getAttribute(e){const t=this.line.split(/\\t/);for(let i=0;i0?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split(\"=\",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();t[e]=i}}return t}function ah(e){let t={},i=e.split(/\\s+/);if(2===i.length){i[1].split(\";\").forEach((function(e){let i=e.split(\"=\");\"color\"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:\"thickness\"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function ch(e,t){var i,n,r=e.columns;this.aed=e,this.allColumns=t,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=\".\",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let e=0;e0)for(let e=0;ee.maxv.isGreaterThan(t))));const i=[];let n;for(let t of e)n&&dh(n,t)?t.maxv.isGreaterThan(n.maxv)&&(n.maxv=t.maxv):(i.push(t),n=t);return i}function dh(e,t){const i=t.minv.block-e.maxv.block;return t.maxv.block-e.minv.block<5e6&&i<65e3}ch.prototype.popupData=function(){for(var e=[],t=this.aed,i=0;i=28){t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt();const e=t.getInt(),i=t.position+e;let r=0;for(;t.positions)t.getInt(),t.getVPointer(),t.getVPointer(),t.getLong(),t.getLong();else{i[e]=[];const n=t.getInt();for(let s=0;sr&&(r=s.block),i[e].push([n,s]))}}}o>0&&(this.indices[e]={binIndex:i,loffset:n})}this.lastBlockPosition=r}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=this.reg2bins(t,i);if(0==e.length)return[];const r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let i of t){const t=i[0],n=i[1];r.push({minv:t,maxv:n,bin:e})}}let s=e[this.depth][0];do{if(n.binIndex[s])break;s>1+(this.getParentBin(s)<<3)?s--:s=this.getParentBin(s)}while(0!=s);return hh(r,n.loffset[s])}return[]}getParentBin(e){return 0==e?0:e-1>>3}reg2bins(e,t){(e-=1)<1&&(e=1),t>2**34&&(t=2**34),t-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(e>>r),o=n+(t>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class fh{constructor(){}async parse(e,t){const i=[];let n=Number.MAX_SAFE_INTEGER,r=0;const s=new yc(new DataView(e)),o=s.getInt(),a={};if(!(21578050===o||t&&21578324===o))throw new Error(indexURL+\" is not a \"+(t?\"tabix\":\"bai\")+\" file\");{const e=s.getInt();if(t){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let t=0;tr&&(r=o.block),e[t].push([i,o]))}}}const c=s.getInt();for(let e=0;e0&&(i[t]={binIndex:e,linearIndex:o})}this.firstBlockPosition=n,this.lastBlockPosition=r,this.indices=i,this.sequenceIndexMap=a,this.tabix=t}}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=function(e,t){const i=[];t>=1<<29&&(t=1<<29);return--t,i.push([0,0]),i.push([1+(e>>26),1+(t>>26)]),i.push([9+(e>>23),9+(t>>23)]),i.push([73+(e>>20),73+(t>>20)]),i.push([585+(e>>17),585+(t>>17)]),i.push([4681+(e>>14),4681+(t>>14)]),i}(t,i),r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let e of t){const t=e[0],i=e[1];r.push({minv:t,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(t>>14,s-1),c=Math.min(i>>14,s-1);for(let e=a;e<=c;e++){const t=n.linearIndex[e];if(t){o=t;break}}return hh(r,o)}return[]}}class ph{constructor(){this.tribble=!0}async parse(e){let t=0;this.chrIndex={},this.lastBlockPosition=[];const i=new yc(new DataView(e));!function(e){e.getInt(),e.getInt();const t=e.getInt();if(e.getString(),e.getLong(),e.getLong(),e.getString(),e.getInt(),t>=3){let t=e.getInt();for(;t-- >0;)e.getString(),e.getString()}}(i);let n=i.getInt();for(;n-- >0;){let e=i.getString();const n=i.getInt(),r=i.getInt(),s=i.getInt();i.getInt(),i.getInt();let o=i.getLong();const a=[];for(let e=0;et&&(t=e)}this.chrIndex[e]={chr:e,blocks:a,longestFeature:s,binWidth:n}}this.lastBlockPosition=t}get sequenceNames(){return Object.keys(this.chrIndex)}chunksForRange(e,t,i){const n=this.chrIndex[e];if(n){const e=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(t-r,0),a=Math.floor(o/s);if(a>=e.length)return[];{const t=Math.min(Math.floor((i-1)/s),e.length-1),n=e[a].min,r=e[t].max;if(0===r-n)return[];return[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function gh(e,t){let i=await Qs.loadArrayBuffer(e,Ua(t)),n=new DataView(i);if(31===n.getUint8(0)&&139===n.getUint8(1)){i=gs(i).buffer,n=new DataView(i)}switch(n.getInt32(0,!0)){case 21578050:return async function(e){const t=new fh;return await t.parse(e,!1),t}(i);case 21578324:return async function(e){const t=new fh;return await t.parse(e,!0),t}(i);case 21582659:return async function(e){const t=new uh;return t.parse(e),t}(i);case 1480870228:return async function(e){const t=new ph;return t.parse(e),t}(i);case 38359875:throw Error(\"CSI version 2 is not supported.\");default:throw Error(`Unrecognized index type: ${e}`)}}function mh(e){return\"string\"==typeof e||e instanceof String?new wh(e):new bh(e)}class wh{constructor(e){this.data=e,this.ptr=0}nextLine(){var e=this.ptr,t=this.data.indexOf(\"\\n\",e),i=this.data;if(t>0)return this.ptr=t+1,t>e&&\"\\r\"===i.charAt(t-1)?i.substring(e,t-1):i.substring(e,t);var n=i.length;return this.ptr=n,e>=n?void 0:i.substring(e)}}class bh{constructor(e){this.data=e,this.length=this.data.length,this.ptr=0}nextLine(){if(this.ptr>=this.data.length)return;let e=this.ptr;const t=this.data;let i=\"\",n=!1;for(;e0)for(var a=0;a{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])};class yh{constructor(e){this.config=e,this.cacheBlocks=0!=e.cacheBlocks,this.cache=void 0}async getData(e,t){const i=e.block,n=t.block,r=0===t.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const e of s)o+=e.byteLength;const a=new Uint8Array(o);let c=0;for(const e of s)a.set(e,c),c+=e.byteLength;return a}async getInflatedBlocks(e,t,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=e&&(n.endBlock>=t||i&&n.nextEndBlock===t)){const i=e-n.startBlock,r=t-n.startBlock;return Ch(n.buffer,i,r)}{let r;if(!n||n.startBlock>t||n.endBlock=n.endBlock)o=n.buffer;else{const i=Math.max(0,e-n.startBlock);let r;if(t>=n.endBlock)r=n.buffer.byteLength;else{const e=Ah(n.buffer);for(let i=0;in.endBlock){const e=await this.loadBLockData(n.endBlock,t,{skipStart:!0,skipEnd:i});s.push(e)}r=function(e){if(1===e.length)return e[0];let t=0;for(const i of e)t+=i.byteLength;const i=new Uint8Array(t);let n=0;for(const t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(s)}let s=t;if(i){const e=Ah(r);t=e[e.length-1]}return this.cache={startBlock:e,endBlock:t,nextEndBlock:s,buffer:r},Ch(r)}}return Ch(await this.loadBLockData(e,t,{skipEnd:i}))}async loadBLockData(e,t,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!(i&&i.skipEnd)){const e=Ua(n,{range:{start:t,size:26}}),i=await Qs.loadArrayBuffer(n.url,e);s=vh(i)}if(r){const t=Ua(n,{range:{start:e,size:26}}),i=await Qs.loadArrayBuffer(n.url,t);e+=vh(i)}const o=Ua(n,{range:{start:e,size:t+s-e}});return Qs.loadArrayBuffer(n.url,o)}}function Ah(e){const t=e.byteLength;let i=0;const n=[0];for(;i{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))<_h)return Number.MIN_VALUE}return Number(e)};for(;void 0!==(n=e.nextLine());){const e=n.split(this.delimiter);if(e.length===this.columns.length){const i=e[this.posColumn];if(i.indexOf(\";\")>0||0==i.length||i.indexOf(\"x\")>0)continue;const n=e[this.chrColumn],s=r(e[this.pValueColumn]),o=parseInt(i)-1,a=o+1,c=e[this.snpColumn],l=e[this.phenotypeColumn],h=new kh({chr:n,start:o,end:a,pValue:s,snp:c,phenotype:l},this.columns,e);t.push(h)}}return t}static isQTL(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"],[\"rsid\",\"variant\",\"snp\"],[\"phenotype\",\"gene\",\"gene_id\",\"molecular_trait_id\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class kh{constructor({chr:e,start:t,end:i,pValue:n,snp:r,phenotype:s},o,a){this.chr=e,this.start=t,this.end=i,this.pValue=n,this.snp=r,this.phenotype=s,this.headers=o,this.tokens=a}popupData(){const e=[];for(let t=0;te.blocks)).map((e=>e.max)).reduce(((e,t)=>Math.min(e,t)),Number.MAX_SAFE_INTEGER),n=Ua(this.config,{bgz:e.tabix,range:{start:0,size:i}});t=mh(await Qs.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(t),this.header}if(\"service\"!==this.config.sourceType){let e;if(this.config._filecontents)e=this.config._filecontents,delete this.config._filecontents;else{const t=Ua(this.config);e=await Qs.loadByteArray(this.config.url,t)}e.length<5e8&&(e=(new TextDecoder).decode(e));let t=mh(e);this.header=await this.parser.parseHeader(t),t=mh(e),this.features=await this.parser.parseFeatures(t),this.sequenceNames=new Set;for(let e of this.features)this.sequenceNames.add(e.chr);return this.header}if(this.config.seqnamesURL){const e=Ua(this.config,{}),t=await Qs.loadString(this.config.seqnamesURL,e);t&&(this.sequenceNames=new Set(t.split(\",\").map((e=>e.trim())).filter((e=>e))))}if(this.config.headerURL){const e=Ua(this.config,{}),t=mh(await Qs.loadString(this.config.headerURL,e));return this.header=await this.parser.parseHeader(t),this.header}}getParser(e){switch(e.format){case\"vcf\":return new Yl(e);case\"seg\":return new Ul(\"seg\");case\"mut\":return new Ul(\"mut\");case\"maf\":return new Ul(\"maf\");case\"gwas\":return new Jl(e);case\"qtl\":return new xh(e);case\"aed\":return new nh(e);default:return new El(e)}}async loadFeaturesNoIndex(){if(this.features){const e=this.features;return delete this.features,e}{const e=Ua(this.config),t=await Qs.loadByteArray(this.config.url,e);if(!this.header){const e=mh(t);this.header=await this.parser.parseHeader(e)}const i=mh(t),n=[];return await this._parse(n,i),n}}async loadFeaturesWithIndex(e,t,i){const n=this.config;this.parser;const r=this.index.tabix,s=r?this.index.sequenceIndexMap[e]:e;if(void 0===s)return[];const o=this.index.chunksForRange(s,t,i);if(o&&0!==o.length){const s=[];for(let a of o){let o;if(r)o=await this._blockLoader.getData(a.minv,a.maxv);else{const e=Ua(n,{range:{start:a.minv.block,size:a.maxv.block-a.minv.block+1}});o=await Qs.loadString(n.url,e)}const c=mh(a.minv.offset?o.slice(a.minv.offset):o);await this._parse(s,c,e,i,t)}return s}return[]}async loadFeaturesFromService(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);const r=Ua(this.config),s=mh(await Qs.loadString(n,r)),o=[];return await this._parse(o,s),o}async _parse(e,t,i,n,r){let s=await this.parser.parseFeatures(t);if(s.sort((function(e,t){return e.chr===t.chr?e.start-t.start:e.chr.localeCompare(t.chr)})),void 0===i)for(let t of s)e.push(t);else{let t=!1;for(let o=0;on){e.push(a);break}a.end>=r&&a.start<=n&&(t||(t=!0,o>0&&e.push(s[o-1])),e.push(a))}}}}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return gh(this.config.indexURL,this.config)}async loadFeaturesFromDataURI(){if(this.features){const e=this.features;return delete this.features,e}{const e=vs(this.dataURI);let t=mh(e);this.header=await this.parser.parseHeader(t),this.header instanceof String&&this.header.startsWith(\"##gff-version 3\")&&(this.format=\"gff3\"),t=mh(e);const i=[];return await this._parse(i,t),i}}}const Sh=Mt;class Eh{constructor(e){this.config=e}async readFeatures(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&(\"function\"==typeof this.config.body?s.body=this.config.body({chr:e,start:t,end:i}):s.body=this.config.body.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i));const o=await Qs.load(n,s);if(o&&(r=\"function\"==typeof this.config.parser?this.config.parser(o):Sh(o)?JSON.parse(o):o),this.config.mappings){let e=Object.keys(this.config.mappings);for(let t of r)for(let i of e)t[i]=t[this.config.mappings[i]]}return r}}const Nh=function(e,t){this.config=e,this.genome=t,this.expandQueryInterval=!1};Nh.prototype.readFeatures=function(e,t,i){const n=Math.max(0,Math.floor(t));let r=Math.ceil(i);if(this.genome){const t=this.genome.getChromosome(e);t&&r>t.bpLength&&(r=t.bpLength)}const s=this.config.url+\"?db=\"+this.config.db+\"&table=\"+this.config.tableName+\"&chr=\"+e+\"&start=\"+n+\"&end=\"+r;return Qs.loadJson(s,this.config).then((function(e){return e?(e.forEach((function(e){e.hasOwnProperty(\"exonStarts\")&&e.hasOwnProperty(\"exonEnds\")&&e.hasOwnProperty(\"exonCount\")&&e.hasOwnProperty(\"cdsStart\")&&e.hasOwnProperty(\"cdsEnd\")&&function(e){var t,i,n,r,s,o;t=e.exonCount,i=e.exonStarts.split(\",\"),n=e.exonEnds.split(\",\"),r=[];for(var a=0;ao||e.cdsEnd=s&&e.cdsStart<=o&&(c.cdStart=e.cdsStart),e.cdsEnd>=s&&e.cdsEnd<=o&&(c.cdEnd=e.cdsEnd),r.push(c)}e.exons=r}(e)})),e):null}))};class Bh{featureCaches=[];gtexChrs=new Set([\"chr1\",\"chr10\",\"chr11\",\"chr12\",\"chr13\",\"chr14\",\"chr15\",\"chr16\",\"chr17\",\"chr18\",\"chr19\",\"chr2\",\"chr20\",\"chr21\",\"chr22\",\"chr3\",\"chr4\",\"chr5\",\"chr6\",\"chr7\",\"chr8\",\"chr9\",\"chrM\",\"chrX\",\"chrY\"]);constructor(e){this.config=e,this.url=e.url,this.tissueId=e.tissueSiteDetailId,this.datasetId=e.datasetId||\"gtex_v8\"}async readFeatures(e,t,i){const n=e.startsWith(\"chr\")?e:\"MT\"===e?\"chrM\":\"chr\"+e;if(!this.gtexChrs.has(n))return[];const r=Math.floor(t),s=Math.ceil(i),o=this.datasetId,a=this.url+\"?chromosome=\"+n+\"&start=\"+r+\"&end=\"+s+\"&tissueSiteDetailId=\"+this.tissueId+\"&datasetId=\"+o,c=await Qs.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?c.singleTissueEqtl.map((e=>new Mh(e))):[]}}class Mh{constructor(e){this.chr=e.chromosome,this.start=e.pos-1,this.end=this.start+1,this.snp=e.snpId,this.phenotype=e.geneSymbol,this.pValue=e.pValue,this.json=e}popupData(){return Object.keys(this.json).map((e=>({name:e,value:this.json[e]})))}}class Rh{constructor(e,t){if(this.config=e,this.genome=t,!e.format)throw Error('Format is required, and must be either \"bam\" or \"cram\"');if(this.format=e.format.toUpperCase(),\"BAM\"!==this.format&&\"VCF\"!==this.format)throw Error(`htsget format ${e.format} is not supported`)}async readHeaderData(){const e=`${Dh(this.config)}?class=header&format=${this.format}`,t=await Qs.loadJson(e,Ua(this.config));return await this.loadUrls(t.htsget.urls)}async readData(e,t,i){const n=`${Dh(this.config)}?format=${this.format}&referenceName=${e}&start=${Math.floor(t)}&end=${Math.ceil(i)}`,r=await Qs.loadJson(n,Ua(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(e){const t=[];for(let i of e)if(i.url.startsWith(\"data:\"))t.push(Promise.resolve(Th(i.url)));else{const e=Ua(this.config||{});i.headers&&(e.headers=Object.assign(e.headers||{},i.headers)),t.push(Qs.loadArrayBuffer(i.url,e))}return function(e){let t=0;for(let i of e)t+=i.byteLength;let i=0;const n=new Uint8Array(t);for(let t of e){const e=new Uint8Array(t);n.set(e,i),i+=e.length}return n}(await Promise.all(t))}static async inferFormat(e){try{const t=Dh(e),i=`${t}${t.includes(\"?\")?\"&\":\"?\"}class=header`,n=await Qs.loadJson(i,Ua(e));if(n.htsget){const t=n.htsget.format;if(\"BAM\"!==t&&\"VCF\"!==t)throw Error(`htsget format ${t} is not supported`);e.format=t.toLowerCase(),e.sourceType=\"htsget\",e.name||(e.name=await ja(e.url))}}catch(e){}}}function Dh(e){if(e.url&&e.endpoint&&e.id)return e.url+e.endpoint+e.id;if(e.endpoint&&e.id)return e.endpoint+e.id;if(e.url)return e.url.startsWith(\"htsget://\")?e.url.replace(\"htsget://\",\"https://\"):e.url;throw Error(\"Must specify either 'url', or 'endpoint' and 'id\")}function Th(e){const t=e.split(\",\"),i=t[0].split(\":\")[1];let n=t[1];n=i.indexOf(\"base64\")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>t[e])).filter((e=>this.sequenceNames.has(e)));n.length>0&&(i=n[0]),this.chrAliasTable.set(e,i)}else this.chrAliasTable.set(e,void 0)}return this.chrAliasTable.get(e)}}class Hh{constructor(e){this.genome=e}async nextFeature(e,t,i,n){let r=this.genome.chromosomeNames||[e],s=r.indexOf(e);if(s<0)return;const o=Math.min(1e4,n||1e4);let a=i?t:Math.max(t-o,0);for(;s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=i?a+o:Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=2){let e=t.getInt();for(this.windowFunctions=[];e-- >0;)this.windowFunctions.push(t.getString())}this.trackType=t.getString(),this.trackLine=t.getString();let i=t.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(t.getString());this.genomeID=t.getString(),this.flags=t.getInt(),this.compressed=!!(1&this.flags),e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:this.indexPos,size:this.indexSize}})),t=new yc(new DataView(e)),this.datasetIndex={};let n=t.getInt();for(;n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.datasetIndex[e]={position:i,size:n}}for(this.groupIndex={},n=t.getInt();n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.groupIndex[e]={position:i,size:n}}return this}async readDataset(e,t,i){const n=e+\"_\"+t+\"_\"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?\"\":\"/\"+t,s=\"all\"===e.toLowerCase()||void 0===i?\"0\":i.toString();let o;o=\"raw\"===t?\"/\"+e+\"/raw\":\"/\"+e+\"/z\"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const c=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new yc(new DataView(c));let h=l.getInt();const d={};for(;h-- >0;)d[l.getString()]=l.getString();const u=l.getString(),f=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:o,attributes:d,dataType:u,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const e=this.genome,t=this.groupCache[\"/\"];if(t)return t;{const t=await this.readGroup(\"/\"),i=t.chromosomes,n=t.maxZoom;n&&(this.maxZoom=Number(n));const r=t.totalCount;r&&(t.totalCount=Number(r));const s={};return i&&i.split(\",\").forEach((function(t){const i=e.getChromosomeName(t);s[i]=t})),this.chrAliasTable=s,this.groupCache[\"/\"]=t,t}}async readGroup(e){const t=this.groupCache[e];if(t)return t;{await this.readHeader();const t=this.groupIndex[e];if(void 0===t)return;const i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:t.position,size:t.size}}));if(!i)return;const n=new yc(new DataView(i)),r={name:e};let s=n.getInt();for(;s-- >0;){const e=n.getString(),t=n.getString();r[e]=t}return this.groupCache[e]=r,r}}async readTiles(e,t){if(e.sort((function(e,t){return e.position-t.position})),0===(e=e.filter((function(e){return e.size>0}))).length)return[];const i=[];for(let n of e){const e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:n.position,size:n.size}}));let r;try{r=this.compressed?ls(e).buffer:e}catch(e){console.error(e);continue}const s=new yc(new DataView(r)),o=s.getString();let a;switch(o){case\"fixedStep\":a=Oh(s,t);break;case\"variableStep\":a=Uh(s,t);break;case\"bed\":case\"bedWithName\":a=qh(s,t,o);break;default:throw\"Unknown tile type: \"+o}i.push(a)}return i}async readTile(e,t){let i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e.position,size:e.size}}));if(this.compressed){i=ls(i).buffer}const n=new yc(new DataView(i)),r=n.getString();switch(r){case\"fixedStep\":return Oh(n,t);case\"variableStep\":return Uh(n,t);case\"bed\":case\"bedWithName\":return qh(n,t,r);default:throw\"Unknown tile type: \"+r}}}function Oh(e,t){const i=e.getInt(),n=e.getInt(),r=e.getFloat(),s=[];let o=t;for(;o-- >0;){let t=i;const n=[];for(;t-- >0;)n.push(e.getFloat());s.push(n)}return{type:\"fixedStep\",start:n,span:r,data:s,nTracks:t,nPositions:i}}function Uh(e,t){const i=e.getInt(),n=e.getFloat(),r=e.getInt(),s=[];let o=r;for(;o-- >0;)s.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){o=r;const t=[];for(;o-- >0;)t.push(e.getFloat());a.push(t)}return{type:\"variableStep\",tileStart:i,span:n,start:s,data:a,nTracks:t,nPositions:r}}function qh(e,t,i){const n=e.getInt();let r=n;const s=[];for(;r-- >0;)s.push(e.getInt());r=n;const o=[];for(;r-- >0;)o.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){let t=n;const i=[];for(;t-- >0;)i.push(e.getFloat());a.push(i)}if(\"bedWithName\"===i){r=n;const t=[];for(;r-- >0;)t.push(e.getString())}return{type:i,start:s,end:o,data:a,nTracks:t,nPositions:n}}class Qh extends Hh{#h={};searchable=!1;constructor(e,t){super(t),this.genome=t,this.reader=new Ph(e,t),this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r=\"mean\"}){return\"all\"===e.toLowerCase()?this.getWGValues(r,n):this._getFeatures(e,t,i,n,r)}async _getFeatures(e,t,i,n,r){const s=new hc(e,t,i),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const e=this.rootGroup.totalCount;e&&(this.normalizationFactor=1e6/e)}s.bpPerPixel=n;const a=function(e,t,i){var n=i.getChromosome(e).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*t)))/Gh)}(e,n,o);let c=this.reader.chrAliasTable[e],l=this.reader.maxZoom;void 0===c&&(c=e),void 0===l&&(l=-1);const h=a>l?\"raw\":r,d=await this.reader.readDataset(c,h,a);if(null==d)return[];const u=d.tileWidth,f=Math.floor(t/u),p=Math.floor(i/u),g=await this.reader.readTiles(d.tiles.slice(f,p+1),1),m=[];for(let r of g)switch(r.type){case\"bed\":Vh(r,e,t,i,n,m);break;case\"variableStep\":jh(r,e,t,i,n,m);break;case\"fixedStep\":Wh(r,e,t,i,n,m);break;default:throw\"Unknown tile type: \"+r.type}return m.sort((function(e,t){return e.start-t.start})),m}get supportsWholeGenome(){return!0}get windowFunctions(){return this.reader.windowFunctions}async getWGValues(e,t){const i=this.#h[e];if(i&&i.bpPerPixel>.8*t&&i.bpPerPixel<1.2*t)return i.values;{const i=[],n=this.genome;if(this.genome.wgChromosomeNames)for(let r of n.wgChromosomeNames){const s=n.getChromosome(r).bpLength;t=s/1e3;const o=await this._getFeatures(r,0,s,t,e);if(o)for(let e of o){const t=Object.assign({},e);t.chr=\"all\",t.start=n.getGenomeCoordinate(e.chr,e.start),t.end=n.getGenomeCoordinate(e.chr,e.end),t._f=e,i.push(t)}}return this.#h[e]={values:i,bpPerPixel:t},i}}}function Vh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.end,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function jh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.span,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function Wh(e,t,i,n,r,s){const o=e.nPositions;let a=e.start;const c=e.span,l=e.data[0];for(let e=0;en)break;r>=i&&(Number.isNaN(l[e])||s.push({chr:t,start:a,end:r,value:l[e]})),a=r}}var Gh=Math.log(2);class $h{constructor(e,t,i,n){this.header=e,this.nameToId=t,this.idToName=i,this.sumLengths=n}static parseTree(e,t,i=!1){{const n=e.getInt(),r=e.getInt(),s=e.getInt(),o=e.getInt(),a=e.getLong(),c=e.getLong(),l={magic:n,blockSize:r,keySize:s,valSize:o,itemCount:a,reserved:c},h=new Map,d=[];let u=0;const f=n=>{n>=0&&(e.position=n);const r=e.getByte();e.getByte();const a=e.getUShort();if(1===r)for(let t=0;t{const a=await this.readNode(o);for(let o of a.items)Yh(o,e,t,i,n)&&(1===a.type?r.push(o):await s(o.childOffset))};return await s(this.header.rootNodeOffset),r}async readNode(e){const t=e;if(this.nodeCache.has(t))return this.nodeCache.get(t);let i=await this.#t(e,4);const n=i.getByte(),r=1===n;i.getByte();const s=i.getUShort();let o=s*(r?32:24);i=await this.#t(e+4,o);const a=[];for(let e=0;ee.startChrom||n===e.startChrom&&r>=e.startBase)&&(t!!e)),s=[];for(let e of r){const t=e.split(\" \")[0];if(t.startsWith(i)&&s.push(e),t.slice(0,i.length)>i)break}if(0!==s.length){const e=new Map;for(let t of s){const[i,...n]=t.split(\" \");e.set(i,n.map((e=>e.split(\",\")[0])))}return e}}async getIndex(e){return this.index||(this.index=await this._readIndex()),this.index}async _readIndex(e){return(await Qs.loadString(this.ixxFile)).split(\"\\n\").filter((e=>!!e)).map((e=>{const t=e.length-10,i=e.slice(0,t),n=e.slice(t);return[i,Number.parseInt(n,16)]}))}async _getBuffer(e,t){let i=0,n=65536;const r=await this.getIndex(t);for(let t=0;t0?ls(r):r,a.call(this,new DataView(d.buffer),c,t,l,n,h,this.chromTree.idToName,s,this.littleEndian)}return h.sort((function(e,t){return e.start-t.start})),h}return[]}async#d(e){if(this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.chromTree.nameToId.get(e);if(void 0===t&&this.genome){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>this.chromTree.nameToId.has(e)));e.length>0&&(n=e[0],t=this.chromTree.nameToId.get(e[0]))}this.chrAliasTable.set(e,n)}return t}get searchable(){return\"bigbed\"===this.type}async search(e){if(this.header||await this.loadHeader(),!this.header||!this.header.extraIndexCount)return;const t=await this._searchForRegions(e);if(t){const i=await this._loadFeaturesForRange(t.offset,t.length);if(i){const t=i.filter((t=>{for(let i of Object.keys(t)){const n=t[i];if(Mt(n)&&n.toLowerCase()===e.toLowerCase())return!0}return!1}));return t.length>0?t.reduce(((e,t)=>e.end-e.start>t.end-t.start?e:t),i[0]):void 0}}}async _searchForRegions(e){const t=await this.#u();if(t){if(this._trix){const t=e.toLowerCase(),i=await this._trix.search(t);i&&i.has(t)&&(e=i.get(t)[0])}for(let i of t){const t=await i.search(e);if(t)return t}}}async#u(){if(void 0===this._searchTrees&&this.header.extraIndexOffsets&&this.header.extraIndexOffsets.length>0){this._searchTrees=[];for(let e of this.header.extraIndexOffsets){const t=await Cc.loadBpTree(this.path,this.config,e);this._searchTrees.push(t)}}return this._searchTrees}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let e,t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;const i=new yc(new DataView(t),this.littleEndian);let n=i.getUInt();if(2291137574===n)this.type=\"bigwig\";else if(2273964779===n)this.type=\"bigbed\";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let e=i.getUInt();654085990===e?this.type=\"bigwig\":3958540679===e&&(this.type=\"bigbed\")}e={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:e.totalSummaryOffset>0?e.totalSummaryOffset-r+40:Math.min(e.fullDataOffset,e.chromTreeOffset)-r};t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:s}));const o=new yc(new DataView(t),this.littleEndian),a=e.nZoomLevels;this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let e=1;e<=a;e++){const t=a-e,i=new Jh(t,o);this.firstZoomDataOffset=Math.min(i.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[t]=i}if(e.autoSqlOffset>0){o.position=e.autoSqlOffset-r;const t=o.getString();t&&(this.autoSql=function(e){let t;const i=[];let n=!1;const r=e.trim().split(/\\s*[\\r\\n]+\\s*/g);for(let e of r)if(e=e.trim(),e.length>0){if(e.startsWith(\"#\"))continue;if(e.startsWith(\"table\"))t=e.split(/\\s+/)[1].trim();else if(e.startsWith(\"(\"))n=!0;else if(e.startsWith(\")\"));else if(n){const t=e.indexOf(\";\");if(t>0){const n=e.substr(0,t).split(/\\s+/),r=e.substr(t+1).replace(/\"/g,\"\").trim();i.push({type:n[0],name:n[1],description:r})}}}return{table:t,fields:i}}(t))}e.totalSummaryOffset>0&&(o.position=e.totalSummaryOffset-r,this.totalSummary=new ed(o));const c=Math.min(2e5,Math.max(1e4,e.fullDataOffset-e.chromTreeOffset));if(this.chromTree=await this.#f(e.chromTreeOffset,c),this.chrNames=new Set(this.chromTree.idToName),\"bigbed\"===this.type){const t=await this.#p(e.fullDataOffset);this.featureDensity=t/this.chromTree.sumLengths}return this.header=e,e.extensionOffset>0&&await this.loadExtendedHeader(e.extensionOffset),this.header}}async#p(e){const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:4}}));return new yc(new DataView(t),this.littleEndian).getInt()}async#f(e,t){let i=t;const n=async()=>{const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:i}})),n=new yc(new DataView(t),this.littleEndian);return $h.parseTree(n,e,this.genome)};let r;for(;i<1e6;)try{return await n()}catch(e){r=e,i*=2}throw r}async loadExtendedHeader(e){let t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:64}})),i=new yc(new DataView(t),this.littleEndian);i.getUShort();const n=i.getUShort(),r=i.getLong();if(0===n)return;let s=56*n;t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:r,size:s}})),i=new yc(new DataView(t),this.littleEndian);const o=[],a=[],c=[];for(let e=0;e0?ls(n):n,s=[];return nd.call(this).call(this,new DataView(r.buffer),0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,s,this.chromTree.idToName),s}}class Jh{constructor(e,t){this.index=e,this.reductionLevel=t.getInt(),this.reserved=t.getInt(),this.dataOffset=t.getLong(),this.indexOffset=t.getLong()}}class ed{constructor(e){e?(this.basesCovered=e.getLong(),this.minVal=e.getDouble(),this.maxVal=e.getDouble(),this.sumData=e.getDouble(),this.sumSquares=e.getDouble(),td.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function td(){let e=this.basesCovered;if(e>0){this.mean=this.sumData/e,this.stddev=Math.sqrt(this.sumSquares/(e-1));let t=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:t,max:i}}}function id(e,t,i,n,r,s,o,a,c){const l=new yc(e,c),h=l.getInt(),d=l.getInt();let u=d,f=l.getInt();const p=l.getInt(),g=l.getInt(),m=l.getByte();l.getByte();let w=l.getUShort();if(h>=t&&h<=n){let e=0;for(;w-- >0;){let a;switch(m){case 1:u=l.getInt(),f=l.getInt(),a=l.getFloat();break;case 2:u=l.getInt(),a=l.getFloat(),f=u+g;break;case 3:a=l.getFloat(),u=d+e*p,f=u+g,e++}if(!(hn||h===n&&u>=r)break;if(Number.isFinite(a)){const e=o[h];s.push({chr:e,start:u,end:f,value:a})}}}}}function nd(){const e=function(e,t,i,n){if(\"biginteract\"===n||i&&(\"chromatinInteract\"===i.table||\"interact\"===i.table))return function(e,t){return e.chr1=t[5],e.start1=Number.parseInt(t[6]),e.end1=Number.parseInt(t[7]),e.chr2=t[10],e.start2=Number.parseInt(t[11]),e.end2=Number.parseInt(t[12]),e.name=t[0],e.score=Number(t[1]),e.value=Number(t[2]),e.color=\".\"===t[4]?void 0:\"0\"===t[4]?\"rgb(0,0,0)\":t[4],e};{const n=e-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&\".\"!==s[5]&&\"0\"!==s[5]&&\"-1\"!==s[5]){const e=_s.createColorString(s[5]);r.color=e.startsWith(\"rgb\")?e:void 0}if(n>8){const e=parseInt(s[6]),t=s[7].split(\",\"),i=s[8].split(\",\"),n=[];for(let s=0;si?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=e;n=13;){const t=h.getInt(),c=a[t],l=h.getInt(),d=h.getInt(),u=h.getString();if(!(tr||t===r&&l>=s)break;if(d>0){const t={chr:c,start:l,end:d};o.push(t);const i=u.split(\"\\t\");e(t,i)}}}}}function rd(e,t,i,n,r,s,o,a,c){const l=new yc(e,c);for(;l.remLength()>=32;){const e=l.getInt(),c=l.getInt(),h=l.getInt(),d=l.getInt(),u=l.getFloat(),f=l.getFloat(),p=l.getFloat();let g;switch(l.getFloat(),a){case\"min\":g=u;break;case\"max\":g=f;break;default:g=0===d?0:p/d}if(!(en||e===n&&c>=r)break;if(Number.isFinite(g)){const t=o[e];s.push({chr:t,start:c,end:h,value:g})}}}}class sd{constructor(e){this.data=e}loadArrayBuffer(e,t){const i=t.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(e,t){const i=Math.min(this.data.byteLength-e.start,e.size);return t?new Uint8Array(this.data,e.start,i):new DataView(this.data,e.start,i)}}class od extends Hh{queryable=!0;#h={};windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];constructor(e,t){super(t),this.reader=new Zh(e,t),this.genome=t,this.format=e.format||\"bigwig\"}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r}){await this.reader.loadHeader();const s=\"bigwig\"===this.reader.type;let o;return o=\"all\"===e.toLowerCase()?s?await this.getWGValues(r,n):[]:await this.reader.readFeatures(e,t,e,i,n,r),s||Tl(o),o}async getHeader(){return this.reader.loadHeader()}async defaultVisibilityWindow(){return\"bigwig\"===this.reader.type?-1:this.reader.featureDensity?Math.floor(1e4/this.reader.featureDensity):-1}async getWGValues(e,t){const i=this.genome,n=this.#h[e];if(n&&n.bpPerPixel>.8*t&&n.bpPerPixel<1.2*t)return n.values;{const n=await this.reader.readWGFeatures(t,e);let r=[];for(let e of n){const t=e.chr,n=i.getCumulativeOffset(t);if(void 0===n)continue;const s=Object.assign({},e);s.chr=\"all\",s.start=n+e.start,s.end=n+e.end,s._f=e,r.push(s)}return r.sort(((e,t)=>e.start-t.start)),this.#h[e]={values:r,bpPerPixel:t},r}}supportsWholeGenome(){return\"bigwig\"===this.reader.type}async trackType(){return this.reader.getTrackType()}get searchable(){return this.reader.searchable}async search(e){return this.reader.search(e)}}const ad=.01;function cd(e,t,i,n){if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"}),n&&xo.fillRect(e,t-4-2,0,4,i,{fillStyle:n});const r=void 0!==this.flipAxis&&this.flipAxis,s=.95*t-8-5,o=.95*t-5,a={font:\"normal 10px Arial\",textAlign:\"right\",fillStyle:\"black\",strokeStyle:\"black\"};xo.strokeLine(e,s,ad*i,o,ad*i,a),xo.fillText(e,l(r?this.dataRange.min:this.dataRange.max),s+4,ad*i+12,a);const c=.99*i;function l(e){return 0===e?\"0\":Math.abs(e)>=10?e.toFixed():Math.abs(e)>=1?e.toFixed(1):Math.abs(e)>=.1?e.toFixed(2):e.toExponential(1)}xo.strokeLine(e,s,c,o,c,a),xo.fillText(e,l(r?this.dataRange.max:this.dataRange.min),s+4,c-4,a),xo.strokeLine(e,o,ad*i,o,c,a)}class ld extends Hl{static defaults={height:50,flipAxis:!1,logScale:!1,windowFunction:\"mean\",graphType:\"bar\",normalize:void 0,scaleFactor:void 0,overflowColor:\"rgb(255, 32, 255)\",baselineColor:\"lightGray\",summarize:!0,visibilityWindow:void 0};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"wig\",this.featureType=\"numeric\",this.resolutionAware=!0,this.paintAxis=cd;const t=e.format?e.format.toLowerCase():e.format;e.featureSource?(this.featureSource=e.featureSource,delete e.featureSource):this.featureSource=\"bigwig\"===t?new od(e,this.browser.genome):\"tdf\"===t?new Qh(e,this.browser.genome):Ad(e,this.browser.genome),void 0===e.max||!0===e.autoscale?this.autoscale=!0:this.dataRange={min:e.min||0,max:e.max}}async postInit(){const e=await this.getHeader();this.disposed||e&&this.setTrackProperties(e)}supportsWholeGenome(){return void 0===this.visibilityWindow||this.visibilityWindow<0}async getFeatures(e,t,i,n){const r=this.windowFunction,s=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:r});if(this.normalize&&this.featureSource.normalizationFactor){const e=this.featureSource.normalizationFactor;for(let t of s)t.value*=e}if(this.scaleFactor){const e=this.scaleFactor;for(let t of s)t.value*=e}return!this.summarize||\"mean\"!==r&&\"min\"!==r&&\"max\"!==r?s:hd(s,t,n,r)}menuItemList(){const e=[];if(void 0!==this.flipAxis){function t(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}e.push(\"
\"),e.push({label:\"Flip y-axis\",click:t})}return this.featureSource.windowFunctions&&e.push(...this.wigSummarizationItems()),e.push(...this.numericDataMenuItems()),e}wigSummarizationItems(){const e=this.featureSource.windowFunctions,t=[];t.push(\"
\"),t.push(\"
Windowing function
\");for(const i of e){const n=Bt(Dl(i,this.windowFunction===i));function r(){this.windowFunction=i,this.trackView.updateViews()}t.push({object:n,click:r})}return t}async getHeader(){return\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(e,t,i,n){const r=!0===n?e<0?-Math.log10(Math.abs(e)+1):Math.log10(Math.abs(e)+1):e;return i/((!0===n?Math.log10(Math.abs(t)+1):t)-r)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return n=n<0?-Math.log10(Math.abs(n)+1):Math.log10(Math.abs(n)+1),i=i<0?-Math.log10(Math.abs(i)+1):Math.log10(Math.abs(i)+1),e=e<0?-Math.log10(Math.abs(e)+1):Math.log10(e+1),(this.flipAxis?e-n:i-e)*t}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight-1,a=r+s*n+1,c=this.getScaleFactor(this.dataRange.min,this.dataRange.max,o,this.logScale),l=e=>this.logScale?this.computeYPixelValueInLogScale(e,c):this.computeYPixelValue(e,c);if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,c=-1;const h=l(0);for(let d of t){if(d.enda)break;const t=(d.start-r)/n;if(isNaN(t))continue;let u=l(d.value);const f=(d.end-r)/n-t,p=e.alpha?_s.addAlpha(this.getColorForFeature(d),e.alpha):this.getColorForFeature(d);if(\"line\"===this.graphType)void 0!==s&&xo.strokeLine(i,c,s,t,u,{fillStyle:p,strokeStyle:p}),xo.strokeLine(i,t,u,t+f,u,{fillStyle:p,strokeStyle:p});else if(\"points\"===this.graphType){const e=this.config.pointSize||3,n=t+f/2;xo.fillCircle(i,n,u,e/2,{fillStyle:p,strokeStyle:p}),d.value>this.dataRange.max?xo.fillCircle(i,n,e/2,e/2,3,{fillStyle:this.overflowColor}):d.valuethis.dataRange.max?xo.fillRect(i,t,0,f,3,{fillStyle:this.overflowColor}):d.value0){const i=e.genomicLocation,n=[];t.sort((function(e,t){return Math.abs((e.start+e.end)/2-i)-Math.abs((t.start+t.end)/2-i)}));const r=t.length>10?t.slice(0,10):t;r.sort((function(e,t){return e.start-t.start}));for(let e of r)if(e){n.length>0&&n.push(\"
\");let t=e.end-e.start==1?Rt(Math.floor(e.start)+1):Rt(Math.floor(e.start)+1)+\"-\"+Rt(Math.floor(e.end));n.push({name:\"Position:\",value:t}),n.push({name:\"Value:     \",value:Rt(e.value.toFixed(4))})}return r.length...\"),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(e){let t=e.value<0&&this.altColor?this.altColor:this.color||\"rgb(150, 150, 150)\";return\"function\"==typeof t?t(e.value):t}dispose(){this.trackView=void 0}}function hd(e,t,i,n=\"mean\"){if(i<=1||!e||0===e.length)return e;const r=e[0].chr,s=i,o=[],a=e=>{const i=t+e.bin*s,a=i+s;let c;switch(n){case\"mean\":c=e.sumData/e.count;break;case\"max\":c=e.max;break;case\"min\":c=e.min;break;default:throw Error(`Unknown window function: ${n}`)}const l=`${n} of ${e.count} values`;o.push({chr:r,start:i,end:a,value:c,description:l})};let c;for(let i of e){let e=Math.floor((i.start-t)/s);const n=Math.floor((i.end-t)/s);if(c&&e===c.bin&&(c.add(i),e++),!c||n>c.bin){if(c&&a(c),n>e){const e=t+n*s;o.push({chr:r,start:i.start,end:e,value:i.value})}c=new dd(n,i)}}c&&a(c);const l=[];let h=o[0];for(let e of o)h.value===e.value&&e.start<=h.end?h.end=e.end:(l.push(h),h=e);return l.push(h),l}class dd{constructor(e,t){this.bin=e,this.sumData=t.value,this.count=1,this.min=t.value,this.max=t.value}add(e){this.sumData+=e.value,this.max=Math.max(e.value,this.max),this.min=Math.min(e.value,this.min),this.count++}get mean(){return this.sumData/this.count}}class ud extends Hh{constructor(e,t){super(t),this.config=e||{},this.genome=t,this.sourceType=void 0===e.sourceType?\"file\":e.sourceType,this.maxWGCount=e.maxWGCount||1e4,this.windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];const i=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"tdf\"]);if(this.queryable=e.indexURL||!0===e.queryable,e.reader)this.reader=e.reader,this.queryable=!1!==e.queryable;else{if(\"ga4gh\"===e.sourceType)throw Error(\"Unsupported source type 'ga4gh'\");\"eqtl\"!==e.type&&\"qtl\"!==e.type||\"gtex-ws\"!==e.sourceType?\"htsget\"===e.sourceType?(this.reader=new Lh(e,t),this.queryable=!0):\"ucscservice\"===e.sourceType?(this.reader=new Nh(e.source),this.queryable=!0):\"custom\"===e.sourceType?(this.reader=new Eh(e.source),this.queryable=!1!==e.source.queryable):\"service\"===e.sourceType?(this.reader=new Ih(e,t),this.queryable=!0):(this.reader=new Ih(e,t),void 0!==e.queryable?this.queryable=e.queryable:(i.has(e.format)||this.reader.indexed)&&(this.queryable=!0)):(this.reader=new Bh(e),this.queryable=!0)}this.searchable=!1!==e.searchable}async defaultVisibilityWindow(){if(this.reader&&\"function\"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const e=await this.getHeader();return e?e.type:void 0}async getHeader(){if(!this.header)if(this.reader&&\"function\"==typeof this.reader.readHeader){const e=await this.reader.readHeader();e?(this.header=e,e.format&&(this.config.format=e.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r,windowFunction:s}){const o=\"all\"===e.toLowerCase();if(t=t||0,i=i||Number.MAX_SAFE_INTEGER,(o&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new hc(e,t,i)))&&await this.loadFeatures(e,t,i,r),o){if(!this.wgFeatures)if(this.supportsWholeGenome())if(\"wig\"===this.config.type){const e=await Ll(this.featureCache.getAllFeatures(),this.genome,1e6);this.wgFeatures=hd(e,0,n,s)}else this.wgFeatures=await Ll(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount);else this.wgFeatures=[];return this.wgFeatures}return this.featureCache.queryFeatures(e,t,i)}async findFeatures(e){return this.featureCache?this.featureCache.findFeatures(e):[]}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]:this.featureCache.getAllFeatures()}async loadFeatures(e,t,i,n){await this.getHeader();const r=this.reader;let s=t,o=i,a=e;if(!this.chrAliasManager&&this.reader&&this.reader.sequenceNames&&(this.chrAliasManager=new zh(this.reader.sequenceNames,this.genome)),this.chrAliasManager&&(a=await this.chrAliasManager.getAliasName(e)),(!n||n<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(a):void 0;s=0,o=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,i)}else if(n>i-t&&!1!==this.config.expandQuery){let e=Math.min(4.1*(i-t),n);this.config.minQuerySize&&et.end-t.start)continue;this.featureMap.set(i.toUpperCase(),t)}}}search(e){if(this.featureMap)return this.featureMap.get(e.toUpperCase())}}class pd{constructor({chr:e,locus:t,accession:i,aliases:n,features:r,sequence:s}){this.chr=e,this.locus=t,this.accession=i,this.aliases=n,this.features=r,this.sequence=s,this.bpLength=s.length}toJSON(){return{gbkURL:this.url}}getSequenceRecord(e){return{chr:this.chr,bpLength:this.bpLength}}get chromosomeNames(){return[this.chr]}getFirstChromosomeName(){return this.chr}get id(){return this.accession}get name(){return this.locus}get initialLocus(){return this.chr}get description(){return this.locus}get infoURL(){return this.url}showWholeGenomeView(){return!1}getHomeChromosomeName(){return this.chr}getChromosomeName(e){return e}getChromosomeDisplayName(e){return this.chr}getChromosome(e){if(e===this.chr)return{name:this.chr,bpLength:this.bpLength}}async loadChromosome(e){return this.getChromosome(e)}async getAliasRecord(e){}getCytobands(e){return[]}getChromosomes(){return[this.getChromosome(this.chr)]}get wgChromosomeNames(){}getGenomeCoordinate(e,t){if(e===this.chr)return t}getChromosomeCoordinate(e){return{chr:this.chr,position:e}}getCumulativeOffset(e){return 0}getGenomeLength(){return this.bpLength}async getSequence(e,t,i){return e===this.chr?this.sequence.substring(t,i):void 0}getSequenceInterval(e,t,i){return e===this.chr?new dc(this.chr,0,this.sequence.length,this.sequence):void 0}}const gd=/\\s+/,md=new Map;async function wd(e){let t=md.get(e);if(!t){t=function(e){if(!e)return null;const t=mh(e);let i=t.nextLine();const n=i.split(/\\s+/);if(\"LOCUS\"!==n[0].toUpperCase())throw Error(\"Expected `LOCUS` line. Found: \"+i);const r=n[1].trim();let s,o;do{if(i=t.nextLine(),i.startsWith(\"ACCESSION\")){const e=i.split(gd);if(e.length<2)throw Error(\"Genbank file missing ACCESSION number.\");s=e[1].trim()}else if(i.startsWith(\"ALIASES\")){const e=i.split(gd);e.length>1&&(o=e[1].split(\",\"))}}while(i&&!i.startsWith(\"FEATURES\"));const a=s||r,c=function(e,t){const i=[];let n,r,s,o=0;for(;;)if(r=t.nextLine(),\"\"!==r){if(!r||r.startsWith(\"ORIGIN\"))break;if(r.length<6)o<10&&console(\"Unexpected line in genbank file (skipping): \"+r),o++;else if(\" \"!==r.charAt(5)){let t=r.substring(5,21).trim();s={chr:e,type:t,attributes:{},getAttributeValue:function(e){return this.attributes[e]}},n=r.substring(21),\"source\"!==t.toLowerCase()&&i.push(s)}else{let t=r.substring(21).trim();if(t.length>0)if(47===t.charCodeAt(0)){if(47===n.charCodeAt(0)){let e=n.split(\"=\",2);if(e.length>1){let t=e[0].length>1?e[0].substring(1):\"\",i=Fd(e[1]);s.attributes[t]=i}}else{const t=n.includes(\"complement\")?\"-\":\"+\";s.strand=t;let i=n.replace(\"join\",\"\").replace(\"order\",\"\").replace(\"complement\",\"\").replace(\"(\",\"\").replace(\")\",\"\");if(i.includes(\"..\")){i=i.replace(\"<\",\"\").replace(\">\",\"\");const n=bd(i,e,t),r=n[0];s.start=r.start;const o=n[n.length-1];s.end=o.end,n.length>1&&(s.exons=n)}else s.start=parseInt(i)-1,s.end=s.start+1}n=t}else n+=t}}return i}(a,t),l=function(e){let t,i=\"\";for(;(t=e.nextLine())&&!t.startsWith(\"//\");){t=t.trim();const e=t.split(/\\s+/);for(let t=1;t1&&(o=parseInt(n[1])),r.push({chr:t,start:s,end:o,strand:i})}return r.sort((function(e,t){return e.start-t.start})),r}function Fd(e){return e.startsWith('\"')&&e.endsWith('\"')&&(e=e.substring(1,e.length-2)),e}class vd extends Hh{constructor(e,t){super(t),this.config=e,this.searchable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){if(!this.featureSource){const e=await wd(this.config.url);this.featureSource=new fd({genome:this.config.genome,features:e.features,searchableFields:[\"gene\",\"db_xref\",\"locus_tag\",\"transcript_id\"]})}return this.featureSource.getFeatures({chr:e,start:t,end:i})}supportsWholeGenome(){return!1}search(e){return this.featureSource.search(e)}}const yd=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\"]);function Ad(e,t){const i=e.format?e.format.toLowerCase():void 0;return e.features?new fd(e,t):yd.has(i)?new od(e,t):\"tdf\"===i?new Qh(e,t):\"gbk\"===i?new vd(e,t):new ud(e,t)}function Cd(e){return(3-e.readingFrame)%3}function _d(e){return e.cdStart||e.start}function xd(e){return e.cdEnd||e.end}const kd=.25;function Id(e,t,i){let n=(e.start-t)/i,r=(e.end-t)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Sd(e,t,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(e);let o,a;r.fillStyle=n,r.strokeStyle=n,\"SQUISHED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*e.row):\"EXPANDED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*e.row):(o=this.featureHeight,a=this.margin);const c=s.pixelWidth,l=a+o/2,h=o/2,d=l-h/2,u=e.exons?e.exons.length:0,f=Id(e,t,i),p=this.arrowSpacing,g=\"+\"===e.strand?1:\"-\"===e.strand?-1:0;if(0===u){const e=Math.max(0,f.px),t=Math.min(c,f.px1),i=t-e;if(r.fillRect(e,a,i,o),0!==g){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let i=e+p/2;ic)break;if(f.utr)r.fillRect(w,d,F,h);else{if(f.cdStart&&(m=Math.round((f.cdStart-t)/i),r.fillRect(w,d,m-w,h),F-=m-w,w=m),f.cdEnd&&(m=Math.round((f.cdEnd-t)/i),r.fillRect(m,d,b-m,h),F-=b-m,b=m),F=Math.max(F,1),r.fillRect(w,a,F,o),void 0!==f.readingFrame&&s.bpPerPixel0&&void 0!==e.exons[u-1].readingFrame?e.exons[u-1]:void 0,n=up+5&&0!==g&&s.bpPerPixel>kd){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let e=w+p/2;e{const f=Math.round((i-s)/o),p=Math.round((n-s)/o)-f;let g;if(void 0===r){if(l.hasSequence(i,n)){const e=l.getSequence(i,n);if(e&&3===e.length){const i=\"+\"===t?e:ac(e.split(\"\").reverse().join(\"\"));g=Gd[i]}}}else g=r;e.fillStyle=\"M\"===r||\"M\"===g&&0===u?\"#83f902\":\"STOP\"===g?\"#ff2101\":h[d],e.fillRect(f,a,p,c),g&&(e.save(),((t,i,n,r,s)=>{\"STOP\"===s&&(s=\"*\");const o=e.measureText(s).width;xo.fillText(e,s,n+(i-o)/2,r-4,{fillStyle:\"#ffffff\"})})(0,p,f,a+c,g),e.restore());const m=n-i;return m>0&&m<3?{start:i,end:n}:void 0},u=Cd(n);let f,p,g,m,w,b=_d(n),F=xd(n),v=1;if(\"+\"===t){for(u>0&&(b+=u),v=1,w=0,f=b;f0||g){const e=u>0?Bd.call(this,t,u,b-u,b,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;i&&d(t,b-u,b,i.aminoAcidLetter,0,void 0),n&&d(t,g.start,g.end,n.aminoAcidLetter,m,void 0)}}}else{for(u>0&&(F-=u),v=1,w=0,w=0,p=F;p>b;w++,p-=3)m=v%2,f=Math.max(b,p-3),g=d(t,f,p,void 0,v%2,w),++v;if(u>0||g){const e=u>0?Bd.call(this,t,u,F,F+u,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;n&&d(t,F,F+u,n.aminoAcidLetter,0,void 0),i&&d(t,g.start,g.end,i.aminoAcidLetter,m,void 0)}}}e.restore()}function Nd(e,t,i,n,r,s,o){try{e.save();let s=t.name;if(void 0===s&&t.gene&&(s=t.gene.name),void 0===s&&(s=t.id||t.ID),!s||\".\"===s)return;let a=o.pixelXOffset||0;const c=Math.max(i,-a);let l,h=(c+Math.min(n,-a+o.viewportWidth))/2;\"COLLAPSED\"===this.displayMode&&\"SLANT\"===this.labelDisplayMode&&(l={rotate:{angle:45}});const d=function(e,t){return t?e+20:e+25}(r,l);let u=this.getColorForFeature(t),f=this.browser.qtlSelections.hasPhenotype(t.name);const p={textAlign:\"SLANT\"===this.labelDisplayMode?void 0:\"center\",fillStyle:u,strokeStyle:u},g=e.measureText(s),m=h-g.width/2,w=h+g.width/2,b=o.rowLastLabelX[t.row]||-Number.MAX_SAFE_INTEGER;(o.labelAllFeatures||m>b||f)&&(o.rowLastLabelX[t.row]=w,\"y\"===o.axis?(e.save(),xo.labelTransformWithContext(e,h),xo.fillText(e,s,h,d,p,l),e.restore()):(e.clearRect(h-g.width/2-1,d-g.actualBoundingBoxAscent-1,g.width+2,g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+2),xo.fillText(e,s,h,d,p,l)))}finally{e.restore()}}function Bd(e,t,i,n,r,s,o,a,c){let l,h,d=\"\",u=\"\",f=\"\";const p={left:void 0,rite:void 0};if(\"+\"===e){if(t){if(u=c.getSequence(i,n),!u)return;if([l,h]=[xd(s)-(3-t),xd(s)],d=c.getSequence(l,h),!d)return;f=d+u,p.left={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(d=c.getSequence(r.start,r.end),!d)return;const e=Cd(a),t=_d(a);if(u=c.getSequence(t,t+e),!u)return;f=d+u,p.rite={triplet:f,aminoAcidLetter:Gd[f]}}}else{if(t){if(d=c.getSequence(i,n),void 0===d)return;if([l,h]=[_d(a),_d(a)+(3-t)],u=c.getSequence(l,h),void 0===u)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.rite={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(u=c.getSequence(r.start,r.end),void 0===u)return;const e=Cd(s),t=xd(s);if(d=c.getSequence(t-e,t),void 0===d)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.left={triplet:f,aminoAcidLetter:Gd[f]}}}return p}const Md=new Set([\"nonsense\",\"missense\",\"stop-loss\",\"frameshift\",\"cds-indel\"]),Rd=new Set([\"coding-synon\"]),Dd=new Set([\"splice-3\",\"splice-5\"]),Td=new Set([\"untranslated-5\",\"untranslated-3\"]);function Ld(e,t,i,n,r){var s,o,a,c,l,h,d=Id(e,t,i),u=this.margin,f=this.snpColors.length;switch(s=\"squished\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case\"function\":c=e.func,h=c.split(\",\"),l=h.map((function(e){return Md.has(e)||Dd.has(e)?f-1:Rd.has(e)?f-2:Td.has(e)?f-3:0})),o=l.reduce((function(e,t){return Math.max(e,t)}));break;case\"class\":o=\"deletion\"===(a=e.class)?f-1:\"mnp\"===a?f-2:\"microsatellite\"===a||\"named\"===a?f-3:0}r.fillStyle=this.snpColors[o],r.fillRect(d.px,u,d.pw,s)}function zd(e,t,i,n,r){const s=\"EXPANDED\"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;\"COLLAPSED\"!==this.displayMode&&void 0!==e.row&&(o+=e.row*s);const a=o+.5*s,c=a-.5*s,l=a+.5*s,h=Math.round((e.junction_left-t)/i),d=Math.round((e.junction_right-t)/i);r.beginPath(),r.moveTo(h,a),r.bezierCurveTo(h,c,d,c,d,a),r.lineWidth=1+Math.log(e.num_junction_reads)/Math.log(2),r.strokeStyle=\"blue\",r.stroke();const u=e.spanning_frag_coords;for(let e=0;et&&(t=i.row);return this.margin+(t+1)*(\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,bpEnd:s,pixelWidth:o,pixelHeight:a,referenceFrame:c}=e;if(nr&&i.end!isNaN(e)))));let h=[];const d=[];for(let o of t){if(o.ends)break;\"COLLAPSED\"===this.displayMode&&this.browser.qtlSelections.hasPhenotype(o.name)&&d.push(o);const t=\"COLLAPSED\"===this.displayMode?0:o.row;e.drawLabel=e.labelAllFeatures||l>10;const c=Math.ceil((o.end-r)/n),u=h[t];if(!u||c>u){this.render.call(this,o,r,n,a,i,e);const s=Math.floor((o.start-r)/n);u&&s-u<=0&&(i.globalAlpha=.5,xo.strokeLine(i,s,0,s,a,{strokeStyle:\"rgb(255, 255, 255)\"}),i.globalAlpha=1),h[t]=c}}for(let t of d)e.drawLabel=!0,this.render.call(this,t,r,n,a,i,e)}else console.log(\"No feature list\")}clickedFeatures(e){const t=e.y-this.margin,i=super.clickedFeatures(e);let n;switch(this.displayMode){case\"SQUISHED\":n=Math.floor(t/this.squishedRowHeight);break;case\"EXPANDED\":n=Math.floor(t/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(e){return void 0===n||void 0===e.row||n===e.row}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=e._f||e,r=\"function\"==typeof t.popupData?t.popupData(i):this.extractPopupData(t);if(r){n.length>0&&n.push(\"

\");const s=this.infoURL||this.config.infoURL;for(let t of r)if(n.push(t),s&&t.name&&\"name\"===t.name.toLowerCase()&&t.value&&Mt(t.value)&&!t.value.startsWith(\"<\")){const i=s.replace(\"$$\",e.name);t.value=`${t.value}`}const o=\"gff\"===this.config.format||\"gff3\"===this.config.format||\"gtf\"===this.config.format;if(t.exons&&t.exons.length>1)for(let e=0;e=r.start&&i<=r.end){const i=o?r.number:\"-\"===t.strand?t.exons.length-e:e+1;i&&(n.push(\"
\"),n.push({name:\"Exon Number\",value:i}));break}}}}return n}menuItemList(){const e=[];if(this.render===Ld){e.push(\"
\");for(const i of[\"function\",\"class\"]){const n=Bt(Dl(`Color by ${i}`,i===this.colorBy));function r(){this.colorBy=i,this.trackView.repaintViews()}e.push({object:n,click:r})}}e.push(\"
\");const t={COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"};for(const s of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){const o=Bt(Dl(t[s],s===this.displayMode));function a(){this.displayMode=s,this.config.displayMode=s,this.trackView.checkContentHeight(),this.trackView.repaintViews()}e.push({object:o,click:a})}return e}contextMenuItemList(e){const t=this.clickedFeatures(e);if(void 0===t||0===t.length)return;t.length>1&&t.sort(((e,t)=>t.end-t.start-(e.end-e.start)));const i=t[0];if(i.end-i.start<=1e6){const e=[{label:\"View feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&void 0!==navigator.clipboard&&e.push({label:\"Copy feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.push(\"
\"),e}}description(){if(Ld===this.render){let e=\"\"+this.name+\"
\";return e+=\"Color By Function:
\",e+='Red: Coding-Non-Synonymous, Splice Site
',e+='Green: Coding-Synonymous
',e+='Blue: Untranslated
',e+='Black: Intron, Locus, Unknown

',e+=\"Color By Class:
\",e+='Red: Deletion
',e+='Green: MNP
',e+='Blue: Microsatellite, Named
',e+='Black: Indel, Insertion, SNP',e+=\"\",e}return super.description()}getColorForFeature(e){const t=e._f||e;let i;if(e.name&&this.browser.qtlSelections.hasPhenotype(e.name))i=this.browser.qtlSelections.colorForGene(e.name);else if(this.altColor&&\"-\"===t.strand)i=\"function\"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)i=\"function\"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const e=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];i=this.colorTable.getColor(e)}else t.color&&(i=t.color);if(i||(i=\"rgb(0, 0, 150)\"),t.alpha&&1!==t.alpha)i=_s.addAlpha(i,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const e=function(e,t,i){const n=(t-e)/9,r=Math.floor((i-e)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,t.score);t.alpha=e,i=_s.addAlpha(i,e)}return i}dispose(){this.trackView=void 0}}class Pd{constructor(t){if(this.config=t,this.browser=t.browser,this.columnFormat=t.columnFormat,this.tableRowSelectionList=[],this.tableDOM=e({class:\"igv-roi-table\"}),t.width){let[e]=t.width.split(\"px\");e=parseInt(e,10),this.tableDOM.style.width=`${Math.min(e,1600)}px`}t.parent.appendChild(this.tableDOM),this.headerDOM=t,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=t.gotoButtonHandler}set headerDOM({browser:t,parent:i,headerTitle:n,dismissHandler:r}){const s=e();this.tableDOM.appendChild(s);const o=e();s.appendChild(o),o.innerHTML=n;const a=e();s.appendChild(a),a.appendChild(l(\"times\")),this.boundDismissHandler=function(e){e.stopPropagation(),r()}.bind(this),a.addEventListener(\"click\",this.boundDismissHandler);const{y:c}=t.root.getBoundingClientRect(),{y:h}=i.getBoundingClientRect(),d=-(h-c);p(this.tableDOM,s,{minX:0,minY:d}),this.tableDOM.style.display=\"none\",this._headerDOM=s}set tableColumnTitles(t){const i=e({class:\"igv-roi-table-column-titles\"});t.appendChild(i);for(const{label:t,width:n}of this.columnFormat){const r=e();i.appendChild(r),r.style.width=n,r.innerText=t}this._tableColumnTitlesDOM=i}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(t){const i=e({class:\"igv-roi-table-row-container\"});t.appendChild(i),this._tableRowContainerDOM=i}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(t){const i=e();this.tableDOM.appendChild(i);const n=e({class:\"igv-roi-table-button\"});i.appendChild(n),n.id=\"igv-roi-table-view-button\",n.textContent=\"Go To\",n.style.pointerEvents=\"none\",this._footerDOM=i,this.gotoButton=n,this.boundGotoButtonHandler=t.bind(this),this.gotoButton.addEventListener(\"click\",this.boundGotoButtonHandler)}tableRowDOMHelper(e){e.addEventListener(\"mousedown\",(t=>{t.stopPropagation(),e.classList.toggle(\"igv-roi-table-row-selected\"),e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\"),this.setTableRowSelectionState(e.classList.contains(\"igv-roi-table-row-selected\"))})),e.addEventListener(\"mouseover\",(t=>{e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\")})),e.addEventListener(\"mouseout\",(t=>{e.classList.remove(\"igv-roi-table-row-hover\")}))}clearTable(){const e=this.tableRowContainer.querySelectorAll(\".igv-roi-table-row\");for(let t of e)t.remove()}setTableRowSelectionState(e){e?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?\"auto\":\"none\"}present(){this.tableDOM.style.left=\"0px\";const{y:e}=this.browser.root.getBoundingClientRect(),{y:t}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=e-t+\"px\",this.tableDOM.style.display=\"flex\"}dismiss(){this.tableDOM.style.display=\"none\"}isVisible(){return\"none\"!==this.tableDOM.style.display}dispose(){this.tableDOM.innerHTML=\"\",this.tableDOM.remove();for(const e of Object.keys(this))this[e]=void 0;document.removeEventListener(\"click\",this.boundDismissHandler)}}class Od extends Pd{constructor(e){super(Object.assign({width:\"1024px\"},e)),this.descriptionDOM=e}set descriptionDOM(t){if(t.description){let i;i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.innerHTML=\"BLAT result for query sequence:\",i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.style.maxHeight=\"128px\",i.innerHTML=t.description,i=e({class:\"igv-roi-table-goto-explainer\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.innerHTML=\"Select one or more rows and click Go To to view the regions\"}}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),n=t.map((e=>isFinite(e)?Rt(e):e));for(let t=0;te.remove())),e.length>0)for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}static getColumnFormatConfiguration(){return[{label:\"chr\",width:\"7%\"},{label:\"start\",width:\"12%\"},{label:\"end\",width:\"12%\"},{label:\"strand\",width:\"5%\"},{label:\"score\",width:\"5%\"},{label:\"match\",width:\"5%\"},{label:\"mis-match\",width:\"7%\"},{label:\"rep. match\",width:\"7%\"},{label:\"N's\",width:\"3%\"},{label:\"Q gap count\",width:\"9%\"},{label:\"Q gap bases\",width:\"9%\"},{label:\"T gap count\",width:\"9%\"},{label:\"T gap bases\",width:\"9%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(const e of t){const t=[];e.querySelectorAll(\"div\").forEach((e=>t.push(e.innerText)));const[n,r,s]=t;i.push(`${n}:${r}-${s}`)}for(const e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),this.browser.search(i.join(\" \"))}}const Ud=\"https://igv.org/services/blatUCSC.php\";async function qd({url:e,userSeq:t,db:i}){if(e=e||Ud,!i)throw Error(\"Blat database is not defined\");const n=await async function(e=\"\",t,i){const n=new URLSearchParams;n.append(\"userSeq\",t),n.append(\"db\",i);const r=await fetch(e,{method:\"post\",body:n});return r.json()}(e,t,i);n.fields;return n.blat.map($c)}const Qd=25e3;class Vd extends Hd{constructor(e,t){super(e,t),this.name||(this.name=\"Blat Results\"),this.sequence=e.sequence,this.table=void 0,e.features&&(this._features=e.features,this.featureSource=new fd({features:e.features},this.browser.genome),delete e.features)}async postInit(){if(!this.featureSource){const e=this.browser.genome.id,t=this.browser.config.blatServerURL,i=await qd({url:t,userSeq:this.sequence,db:e});this._features=i,this.featureSource=new fd({features:i},this.browser.genome)}}openTableView(){if(void 0===this.table){const e=this._features.map((e=>[e.chr,e.start+1,e.end,e.strand,e.score,e.matches,e.misMatches,e.repMatches,e.nCount,e.qNumInsert,e.qBaseInsert,e.tNumInsert,e.tBaseInsert])),t={browser:this.browser,parent:this.browser.columnContainer,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:Od.getColumnFormatConfiguration(),gotoButtonHandler:Od.gotoButtonHandler};this.table=new Od(t),this.table.renderTable(e)}this.table.present()}menuItemList(){const e=super.menuItemList();return e.push(\"
\"),e.push({label:\"Open table view\",click:function(){this.openTableView()}}),e}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function jd({sequence:e,browser:t,name:i,title:n}){if(e.length>Qd)t.alert.present(`Sequence size exceeds maximum allowed length (${e.length} > 25000)`);else try{const r=t.genome.id,s=t.config.blatServerURL||\"https://igv.org/services/blatUCSC.php\",o={type:\"blat\",name:i||\"blat results\",title:n||\"blat results\",sequence:e,altColor:\"rgb(176, 176, 236)\",color:\"rgb(236, 176, 176)\",searchable:!1,features:await qd({url:s,userSeq:e,db:r})};(await t.loadTrack(o)).openTableView()}catch(e){t.alert.present(`Error performing blat search: ${e}`)}}const Wd=Number.MIN_SAFE_INTEGER,Gd={TTT:\"F\",TTC:\"F\",TTA:\"L\",TTG:\"L\",CTT:\"L\",CTC:\"L\",CTA:\"L\",CTG:\"L\",ATT:\"I\",ATC:\"I\",ATA:\"I\",ATG:\"M\",GTT:\"V\",GTC:\"V\",GTA:\"V\",GTG:\"V\",TCT:\"S\",TCC:\"S\",TCA:\"S\",TCG:\"S\",CCT:\"P\",CCC:\"P\",CCA:\"P\",CCG:\"P\",ACT:\"T\",ACC:\"T\",ACA:\"T\",ACG:\"T\",GCT:\"A\",GCC:\"A\",GCA:\"A\",GCG:\"A\",TAT:\"Y\",TAC:\"Y\",TAA:\"STOP\",TAG:\"STOP\",CAT:\"H\",CAC:\"H\",CAA:\"Q\",CAG:\"Q\",AAT:\"N\",AAC:\"N\",AAA:\"K\",AAG:\"K\",GAT:\"D\",GAC:\"D\",GAA:\"E\",GAG:\"E\",TGT:\"C\",TGC:\"C\",TGA:\"STOP\",TGG:\"W\",CGT:\"R\",CGC:\"R\",CGA:\"R\",CGG:\"R\",AGT:\"S\",AGC:\"S\",AGA:\"R\",AGG:\"R\",GGT:\"G\",GGC:\"G\",GGA:\"G\",GGG:\"G\"},$d={},Kd=[\"A\",\"G\",\"C\",\"T\",\"Y\",\"R\",\"W\",\"S\",\"K\",\"M\",\"D\",\"V\",\"H\",\"B\",\"N\",\"X\"],Yd=[\"T\",\"C\",\"G\",\"A\",\"R\",\"Y\",\"W\",\"S\",\"M\",\"K\",\"H\",\"B\",\"D\",\"V\",\"N\",\"X\"];for(let NA=0;NA{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?\"Close Translation\":\"Three-frame Translate\",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let e of this.trackView.viewports)e.setContentHeight(Xd);this.trackView.setTrackHeight(Xd)}else{for(let e of this.trackView.viewports)e.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(e){const t=e.viewport;if(t.referenceFrame.bpPerPixel<=1){const e=t.getWidth()*t.referenceFrame.bpPerPixel,i=t.referenceFrame.chr,n=Math.floor(t.referenceFrame.start),r=Math.ceil(n+e),s=[{label:this.reversed?\"View visible sequence (reversed)...\":\"View visible sequence...\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&s.push({label:\"Copy visible sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),s.push({label:\"BLAT read sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);if(e){this.reversed&&(e=cc(e));const t=`blat: ${i}:${n+1}-${r}`,s=`blat: ${i}:${n+1}-${r}`;jd({sequence:e,browser:this.browser,name:t,title:s})}}}),s.push(\"
\"),s}}translateSequence(e){const t=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;e.length-n>=3;){let r=e.slice(n,n+3);this.reversed&&(r=r.split(\"\").reverse().join(\"\"));const s=Gd[r.toUpperCase()]||\"\";t[i].push({codons:r,aminoA:s}),n+=3}}return t}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new Jd(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome}async getFeatures(e,t,i,n){if(t=Math.floor(t),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:t,sequence:await n.getSequence(e,t,i)}}}draw(e){const t=e.context;if(e.features){let i=e.features.sequence;if(!i)return;this.reversed&&(i=i.split(\"\").map((function(e){return $d[e]})).join(\"\"));const n=e.features.bpStart,r=1+e.bpStart+e.pixelWidth*e.bpPerPixel;for(let s=Math.floor(e.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r.1)xo.fillRect(t,n,5,o,10,{fillStyle:c});else{const i=n+.5*(o-t.measureText(a).width);\"y\"===e.axis?(t.save(),xo.labelTransformWithContext(t,i),xo.strokeText(t,a,i,15,{strokeStyle:c}),t.restore()):xo.strokeText(t,a,i,15,{strokeStyle:c})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;ie.pixelWidth)break;let f=c.aminoA;c.aminoA.indexOf(\"STOP\")>-1?(a=\"rgb(255, 0, 0)\",f=\"STOP\"):\"M\"===c.aminoA&&(a=\"rgb(0, 153, 0)\",f=\"START\"),xo.fillRect(t,h,r,d-h,25,{fillStyle:a}),e.bpPerPixel<=.1&&xo.strokeText(t,f,u-t.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(e){return this.height=this.frameTranslate?Xd:25,this.height}fillColor(e){return this.color?this.color:\"dna\"===this.sequenceType?this.browser.nucleotideColors[e]||\"gray\":\"rgb(0, 0, 150)\"}getState(){const e={type:\"sequence\"};return this.order!==Wd&&(e.order=this.order),this.reversed&&(e.revealed=!0),e}}class Jd{constructor(e,t){this.config=e,this.genome=t}async init(){this.fasta=await Nc(this.config),this.chrNameMap=new Map;for(let e of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(e),e)}async getSequence(e,t,i){const n=this.chrNameMap.has(e)?this.chrNameMap.get(e):e;return this.fasta.getSequence(n,t,i)}}class eu{constructor(e,t,i,n){this.guid=s(),this.trackView=e,this.referenceFrame=i,this.browser=e.browser,this.$viewport=Bt('
'),t.appendChild(this.$viewport.get(0)),e.track.height&&(this.$viewport.get(0).style.height=`${e.track.height}px`),e.track instanceof Zd&&(this.alert=new Ta(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(e){this.messageDiv||(this.messageDiv=document.createElement(\"div\"),this.messageDiv.className=\"igv-viewport-message\",this.$viewport.append(Bt(this.messageDiv))),this.messageDiv.textContent=e,this.messageDiv.style.display=\"inline-block\"}hideMessage(e){this.messageDiv&&(this.messageDiv.style.display=\"none\")}setTrackLabel(e){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(e){this.contentTop=e,this.$viewport.height()}async loadFeatures(){}clearCache(){}repaint(){}draw(e,t,i){console.log(\"Viewport - draw(drawConfiguration, features, roiFeatures)\")}checkContentHeight(e){let t=this.trackView.track;if(e=e||this.cachedFeatures,\"FILL\"===t.displayMode)this.setContentHeight(this.$viewport.height());else if(\"function\"==typeof t.computePixelHeight&&e&&e.length>0){let i=t.computePixelHeight(e);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(e){this.contentHeight=e}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(e){this.$viewport.width(e)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(e,t){console.log(\"Viewport - containsPosition(chr, position)\")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.$viewport.get(0).remove();for(let e of Object.keys(this))this[e]=void 0}}\n", - "/*!!\n", - " * Canvas 2 Svg v1.0.19\n", - " * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.\n", - " *\n", - " * Licensed under the MIT license:\n", - " * http://www.opensource.org/licenses/mit-license.php\n", - " *\n", - " * Author:\n", - " * Kerry Liu\n", - " *\n", - " * Copyright (c) 2014 Gliffy Inc.\n", - " */function tu(e,t){var i,n=Object.keys(t);for(i=0;i0){\"path\"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:t,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement(\"g\");t.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute(\"transform\");n?n+=\" \":n=\"\",n+=e,this.__currentElement.setAttribute(\"transform\",n)}addTrackGroupWithTranslationAndClipRect(e,t,i,n,r,s){const o=e+\"_clip_rect\";let a=this.__createElement(\"clipPath\",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement(\"rect\",{x:\"0\",y:s.toString(),width:n.toString(),height:r.toString()}));let c=this.__createElement(\"g\");this.__rootGroup.appendChild(c),c.setAttribute(\"transform\",tu(\"translate({x},{y})\",{x:t,y:i})),c.setAttribute(\"id\",e+\"_group\"),c.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:o})),this.__currentElement=c}scale(e,t){void 0===t&&(t=e),this.__addTransform(tu(\"scale({x},{y})\",{x:e,y:t}))}rotate(e){var t=180*e/Math.PI;this.__addTransform(tu(\"rotate({angle},{cx},{cy})\",{angle:t,cx:0,cy:0}))}translate(e,t){this.__addTransform(tu(\"translate({x},{y})\",{x:e,y:t}))}transform(e,t,i,n,r,s){this.__addTransform(tu(\"matrix({a},{b},{c},{d},{e},{f})\",{a:e,b:t,c:i,d:n,e:r,f:s}))}beginPath(){var e;this.__currentDefaultPath=\"\",this.__currentPosition={},e=this.__createElement(\"path\",{},!0),this.__closestGroupOrSvg().appendChild(e),this.__currentElement=e}__applyCurrentDefaultPath(){var e=this.__currentElement;\"path\"===e.nodeName?e.setAttribute(\"d\",this.__currentDefaultPath):console.error(\"Attempted to apply path command to node\",e.nodeName)}__addPathCommand(e){this.__currentDefaultPath+=\" \",this.__currentDefaultPath+=e}moveTo(e,t){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:e,y:t},this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand(\"Z\")}lineTo(e,t){this.__currentPosition={x:e,y:t},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf(\"M\")>-1?this.__addPathCommand(tu(\"L {x} {y}\",{x:e,y:t})):this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}bezierCurveTo(e,t,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(tu(\"C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}\",{cp1x:e,cp1y:t,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(e,t,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(tu(\"Q {cpx} {cpy} {x} {y}\",{cpx:e,cpy:t,x:i,y:n}))}arcTo(e,t,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error(\"IndexSizeError: The radius provided (\"+r+\") is negative.\");if(s===e&&o===t||e===i&&t===n||0===r)this.lineTo(e,t);else{var a=ru([s-e,o-t]),c=ru([i-e,n-t]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),d=ru([a[0]+c[0],a[1]+c[1]]),u=r/Math.sin(h/2),f=e+u*d[0],p=t+u*d[1],g=[-a[1],a[0]],m=[c[1],-c[0]],w=function(e){var t=e[0];return e[1]>=0?Math.acos(t):-Math.acos(t)},b=w(g),F=w(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,b,F)}else this.lineTo(e,t)}}}stroke(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"fill stroke markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"stroke\")}fill(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"stroke fill markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"fill\")}rect(e,t,i,n){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(e,t),this.lineTo(e+i,t),this.lineTo(e+i,t+n),this.lineTo(e,t+n),this.lineTo(e,t),this.closePath()}fillRect(e,t,i,n){n<0&&(t+=n,n=-n),i<0&&(e+=i,i=-i);var r,s,o,a={x:e,y:t,width:i,height:n};(!this.viewbox||(r=this.viewbox,s=a,r.xs.x&&r.ys.y))&&(o=this.__createElement(\"rect\",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement(\"fill\"))}strokeRect(e,t,i,n){var r;r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement(\"stroke\")}strokeEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"stroke\")}fillEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"fill\")}__ellipse(e,t,i,n,r,s,o,a,c){const l={cx:e,cy:t,rx:i,ry:n},h=this.__createElement(\"ellipse\",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var e=this.__closestGroupOrSvg().getAttribute(\"transform\"),t=this.__root.childNodes[1],i=t.childNodes,n=i.length-1;n>=0;n--)i[n]&&t.removeChild(i[n]);this.__currentElement=t,this.__groupStack=[],e&&this.__addTransform(e)}clearRect(e,t,i,n){if(0!==e||0!==t||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n,fill:\"#FFFFFF\"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(e,t,i,n){var r=this.__createElement(\"linearGradient\",{id:iu(this.__ids),x1:e+\"px\",x2:i+\"px\",y1:t+\"px\",y2:n+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(r),new au(r,this)}createRadialGradient(e,t,i,n,r,s){var o=this.__createElement(\"radialGradient\",{id:iu(this.__ids),cx:n+\"px\",cy:r+\"px\",r:s+\"px\",fx:e+\"px\",fy:t+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(o),new au(o,this)}__parseFont(){var e=/^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))(?:\\s*\\/\\s*(normal|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])))?\\s*([-,\\'\\\"\\sa-z0-9]+?)\\s*$/i.exec(this.font),t={style:e[1]||\"normal\",size:e[4]||\"10px\",family:e[6]||\"sans-serif\",weight:e[3]||\"normal\",decoration:e[2]||\"normal\",href:null};return\"underline\"===this.__fontUnderline&&(t.decoration=\"underline\"),this.__fontHref&&(t.href=this.__fontHref),t}__wrapTextLink(e,t){if(e.href){var i=this.__createElement(\"a\");return i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",e.href),i.appendChild(t),i}return t}__applyText(e,t,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement(\"text\",{\"font-family\":o.family,\"font-size\":o.size,\"font-style\":o.style,\"font-weight\":o.weight,\"text-decoration\":o.decoration,x:t,y:i,\"text-anchor\":(r=this.textAlign,s={left:\"start\",right:\"end\",center:\"middle\",start:\"start\",end:\"end\"},s[r]||s.start),\"dominant-baseline\":nu(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(e)),this.__currentElement=c,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,c))}fillText(e,t,i){this.__applyText(e,t,i,\"fill\")}strokeText(e,t,i){this.__applyText(e,t,i,\"stroke\")}measureText(e){return this.__ctx.font=this.font,this.__ctx.measureText(e)}arc(e,t,i,n,r,s){if(n!==r){(n%=2*Math.PI)===(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=e+i*Math.cos(r),a=t+i*Math.sin(r),c=e+i*Math.cos(n),l=t+i*Math.sin(n),h=s?0:1,d=0,u=r-n;u<0&&(u+=2*Math.PI),d=s?u>Math.PI?0:1:u>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(tu(\"A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}\",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:d,sweepFlag:h,endX:o,endY:a})),this.__currentPosition={x:o,y:a}}}clip(){var e=this.__closestGroupOrSvg(),t=this.__createElement(\"clipPath\"),i=iu(this.__ids),n=this.__createElement(\"g\");this.__applyCurrentDefaultPath(),e.removeChild(this.__currentElement),t.setAttribute(\"id\",i),t.appendChild(this.__currentElement),this.__defs.appendChild(t),e.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:i})),e.appendChild(n),this.__currentElement=n}drawImage(){var e,t,i,n,r,s,o,a,c,l,h,d,u,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)e=f[1],t=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)e=f[1],t=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error(\"Invalid number of arguments passed to drawImage: \"+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],e=f[5],t=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var w=\"translate(\"+e+\", \"+t+\")\";if(p instanceof lu){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)u=c.childNodes[0].getAttribute(\"id\"),this.__ids[u]=u,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,F=l.getAttribute(\"transform\");b=F?F+\" \"+w:w,l.setAttribute(\"transform\",b),o.appendChild(l)}}}else\"CANVAS\"!==p.nodeName&&\"IMG\"!==p.nodeName||((h=this.__createElement(\"image\")).setAttribute(\"width\",i),h.setAttribute(\"height\",n),h.setAttribute(\"preserveAspectRatio\",\"none\"),(g||m||r!==p.width||s!==p.height)&&((d=this.__document.createElement(\"canvas\")).width=i,d.height=n,d.getContext(\"2d\").drawImage(p,g,m,r,s,0,0,i,n),p=d),h.setAttribute(\"transform\",w),h.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===p.nodeName?p.toDataURL():p.getAttribute(\"src\")),o.appendChild(h))}createPattern(e,t){let i,n=this.__document.__createElement(\"pattern\"),r=iu(this.__ids);return n.setAttribute(\"id\",r),n.setAttribute(\"width\",e.width),n.setAttribute(\"height\",e.height),\"CANVAS\"===e.nodeName||\"IMG\"===e.nodeName?(i=this.__createElement(\"image\"),i.setAttribute(\"width\",e.width),i.setAttribute(\"height\",e.height),i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===e.nodeName?e.toDataURL():e.getAttribute(\"src\")),n.appendChild(i),this.__defs.appendChild(n)):e instanceof lu&&(n.appendChild(e.__root.childNodes[1]),this.__defs.appendChild(n)),new cu(n,this)}setLineDash(e){e&&e.length>0?this.lineDash=e.join(\",\"):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}function hu(e){if(e.startsWith(\"GCF\")||e.startsWith(\"GCA\")&&e.length>=13){return\"https://hgdownload.soe.ucsc.edu/hubs/\"+e.substring(0,3)+\"/\"+e.substring(4,7)+\"/\"+e.substring(7,10)+\"/\"+e.substring(10,13)+\"/\"+e+\"/hub.txt\"}}class du{static supportedTypes=new Set([\"bigBed\",\"bigWig\",\"bigGenePred\",\"vcfTabix\"]);static filterTracks=new Set([\"cytoBandIdeo\",\"assembly\",\"gap\",\"gapOverlap\",\"allGaps\",\"cpgIslandExtUnmasked\",\"windowMasker\"]);static async loadHub(e){const t=e.lastIndexOf(\"/\"),i=e.substring(0,t+1),n=await pu(e);let r;if(\"genome\"===n[1].type){const e=n[1];if(e.hasProperty(\"groups\")){const t=i+e.getProperty(\"groups\");r=await pu(t)}if(e.hasProperty(\"chromSizes\")){const t=i+e.getProperty(\"chromSizes\"),n=await async function(e){try{const t=(await fetch(e,{method:\"HEAD\"})).headers;return t.has(\"content-length\")?t.get(\"content-length\"):null}catch(e){return null}}(t);null!==n&&Number.parseInt(n)<1e6&&e.setProperty(\"chromSizesURL\",t)}}return new du(e,n,r)}constructor(e,t,i){this.url=e;const n=e.lastIndexOf(\"/\");if(this.baseURL=e.substring(0,n+1),\"hub\"!==t[0].type)throw Error(\"Unexpected hub.txt file -- does the first line start with 'hub'?\");if(this.hubStanza=t[0],\"on\"!==this.hubStanza.getProperty(\"useOneFile\"))throw Error(\"Only 'useOneFile' hubs are currently supported\");if(t.length<2)throw Error(\"Expected at least 2 stanzas, hub and genome\");if(\"genome\"!==t[1].type)throw Error(`Unexpected hub file -- expected \"genome\" stanza but found \"${t[1].type}\"`);this.genomeStanza=t[1],this.trackStanzas=[];for(let e=2;e0?e.substring(0,t):e}}this.genomeStanza.hasProperty(\"blat\")&&(r.blat=this.baseURL+this.genomeStanza.getProperty(\"blat\")),this.genomeStanza.hasProperty(\"chromAliasBb\")&&(r.chromAliasBbURL=this.baseURL+this.genomeStanza.getProperty(\"chromAliasBb\")),this.genomeStanza.hasProperty(\"chromAlias\")&&(r.aliasURL=this.baseURL+this.genomeStanza.getProperty(\"chromAlias\")),this.genomeStanza.hasProperty(\"twoBitBptURL\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptURL\")),this.genomeStanza.hasProperty(\"twoBitBptUrl\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptUrl\")),e.includeChromSizes&&this.genomeStanza.hasProperty(\"chromSizes\")&&(r.chromSizesURL=this.baseURL+this.genomeStanza.getProperty(\"chromSizes\")),this.hubStanza.hasProperty(\"longLabel\")?r.description=this.hubStanza.getProperty(\"longLabel\").replace(\"/\",\"\\n\"):(r.description=r.id,this.genomeStanza.hasProperty(\"description\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"description\")}`),this.genomeStanza.hasProperty(\"organism\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"organism\")}`),this.genomeStanza.hasProperty(\"scientificName\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"scientificName\")}`),this.genomeStanza.hasProperty(\"htmlPath\")&&(r.infoURL=this.baseURL+this.genomeStanza.getProperty(\"htmlPath\")));const s=this.trackStanzas.filter((e=>\"cytoBandIdeo\"===e.name&&e.hasProperty(\"bigDataUrl\")));s.length>0&&(r.cytobandBbURL=this.baseURL+s[0].getProperty(\"bigDataUrl\"));return r.tracks=this.#g((e=>!du.filterTracks.has(e.name)&&\"hide\"!==e.getProperty(\"visibility\"))),r}getGroupedTrackConfigurations(){const e=new Map;for(let t of this.#g()){if(\"cytoBandIdeo\"===t.name)continue;const i=t.group||\"other\";e.has(i)?e.get(i).push(t):e.set(i,[t])}const t=this.groupStanzas?new Map(this.groupStanzas.map((e=>[e.getProperty(\"name\"),e]))):new Map;return Array.from(e.keys()).map((i=>({label:t.has(i)?t.get(i).getProperty(\"label\"):i,tracks:e.get(i)})))}#g(e){return this.trackStanzas.filter((t=>du.supportedTypes.has(t.format)&&t.hasProperty(\"bigDataUrl\")&&(!e||e(t)))).map((e=>this.#m(e)))}#m(e){const t=e.format,i={id:e.getProperty(\"track\"),name:e.getProperty(\"shortLabel\"),format:t,url:this.baseURL+e.getProperty(\"bigDataUrl\"),displayMode:e.displayMode};if(\"vcfTabix\"===t&&(i.indexURL=i.url+\".tbi\"),e.hasProperty(\"longLabel\")&&e.hasProperty(\"html\")?(i.description&&(i.description+=\"
\"),i.description=`${e.getProperty(\"longLabel\")}`):e.hasProperty(\"longLabel\")&&(i.description=e.getProperty(\"longLabel\")),e.hasProperty(\"autoScale\")&&(i.autoscale=\"on\"===e.getProperty(\"autoScale\").toLowerCase()),e.hasProperty(\"maxHeightPixels\")){const t=e.getProperty(\"maxHeightPixels\").split(\":\");i.maxHeight=Number.parseInt(t[0]),i.height=Number.parseInt(t[1]),i.minHeight=Number.parseInt(t[2])}if(e.hasProperty(\"color\")){const t=e.getProperty(\"color\");i.color=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"altColor\")){const t=e.getProperty(\"altColor\");i.altColor=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"viewLimits\")){const t=e.getProperty(\"viewLimits\").split(\":\");let n,r;t.length>1&&(n=Number.parseInt(t[0]),r=Number.parseInt(t[1])),Number.isNaN(r)||Number.isNaN(n)?console.warn(`Unexpected viewLimits value in track line: ${properties.viewLimits}`):(i.min=n,i.max=r)}if(e.hasProperty(\"itemRgb\"),\"hide\"===e.getProperty(\"visibility\")&&(i.visible=!1),e.hasProperty(\"url\")&&(i.infoURL=e.getProperty(\"url\")),e.hasProperty(\"searchIndex\")&&(i.searchIndex=e.getProperty(\"searchIndex\")),e.hasProperty(\"searchTrix\")&&(i.trixURL=this.baseURL+e.getProperty(\"searchTrix\")),e.hasProperty(\"group\")&&(i.group=e.getProperty(\"group\"),this.groupPriorityMap&&this.groupPriorityMap.has(i.group))){const e=this.groupPriorityMap.get(i.group)+1;i.order=e,this.groupPriorityMap.set(i.group,e)}return i}}function uu(e){const t=e.indexOf(\" \");return t>0?e.substring(0,t):e}class fu{properties=new Map;constructor(e,t){this.type=e,this.name=t}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.has(e)?this.properties.get(e):this.parent?this.parent.getProperty(e):void 0}hasProperty(e){return!!this.properties.has(e)||!!this.parent&&this.parent.hasProperty(e)}get format(){const e=this.getProperty(\"type\");if(e)return uu(e)}get displayMode(){let e=this.getProperty(\"visibility\");if(!e)return\"COLLAPSED\";switch(e=e.toLowerCase(),e){case\"dense\":default:return\"COLLAPSED\";case\"pack\":return\"EXPANDED\";case\"squish\":return\"SQUISHED\"}}}async function pu(e){const t=await fetch(e),i=(await t.text()).split(/\\n|\\r\\n|\\r/g),n=[];let r,s=!0;for(let e of i){const t=gu(e),i=e.indexOf(\" \",t);if(i<0)s=!0;else{const o=e.substring(t,i).trim();if(o.startsWith(\"#\"))continue;const a=e.substring(i+1).trim();if(s){const e=new fu(o,a);n.push(e),r=e,s=!1}r.setProperty(o,a)}}return function(e){const t=new Map;for(let i of e)t.set(i.name,i);for(let i of e)if(i.properties.has(\"parent\")){const e=uu(i.properties.get(\"parent\"));i.parent=t.get(e)}return e}(n)}function gu(e){let t=0;for(t=0;t=13)try{const e=hu(i);t=(await du.loadHub(e)).getGenomeConfig()}catch(e){console.error(e)}t||e.present(new Error(`Unknown genome id: ${i}`),void 0)}return t}return t}};let wu,bu,Fu=0,vu=0,yu=[];class Au extends eu{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.$spinner=Bt(\"
\",{class:\"igv-loading-spinner-container\"}),this.$viewport.append(this.$spinner),this.$spinner.append(Bt(\"
\"));const e=this.trackView.track;\"sequence\"!==e.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),\"sequence\"!==e.id&&(this.$trackLabel=Bt('
'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(e.name||\"\"),!1===this.browser.doShowTrackLabels&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(e){super.setContentHeight(e),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(e){this.$trackLabel.empty(),this.$trackLabel.html(e);const t=this.$trackLabel.text();this.$trackLabel.attr(\"title\",t)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&\"sequence\"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return Bt(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if(\"all\"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const e=this.trackView.track.visibilityWindow;return void 0!==e&&e>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>e}return!0})()){if(this.canvas&&(Bt(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const e=this.trackView.minHeight||0;this.setContentHeight(e)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const e=this.referenceFrame;this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===e.bpPerPixel&&(this.canvas._data.pixelShift=Math.round((this.canvas._data.bpStart-e.start)/e.bpPerPixel),this.canvas.style.left=this.canvas._data.pixelShift+\"px\")}genomicRange(){return{start:this.referenceFrame.start,end:this.referenceFrame.start+this.referenceFrame.bpPerPixel*this.$viewport.width()}}setTop(e){if(super.setTop(e),this.canvas){const t=this.$viewport.height(),i=e+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n0)for(let n of i.roiSets){const i=await n.getFeatures(t,s,o,e.bpPerPixel);r.push({track:n,features:i})}const a=i&&i.resolutionAware,c=this.windowFunction;return this.featureCache=new Cu(t,s,o,e.bpPerPixel,n,r,a,c),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(e){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage(\"Error loading track data\"),this.browser.alert.present(e),console.error(e))}finally{this.loading=!1,this.stopSpinner()}}}get track(){return this.trackView.track}get windowFunction(){return this.track?this.track.windowFunction:void 0}repaintDimensions(){const e=mu.isWholeGenomeView(this.referenceFrame.chr),t=e?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(e?0:this.$viewport.width()*i),bpEnd:e?Number.MAX_SAFE_INTEGER:this.referenceFrame.start+2*this.$viewport.width()*i+1,pixelWidth:t}}repaint(){if(void 0===this.featureCache)return;const{features:e,roiFeatures:t}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=t?Math.max(o,s):o,c=Math.min(a,3*s);if(0===r||0===c)return void(this.canvas&&Bt(this.canvas).remove());const l=Math.max(0,-this.contentTop-Math.floor(c/3)),h=this.referenceFrame.bpPerPixel,d=Math.round((i-this.referenceFrame.start)/h),u=(this.contentTop||0)+l,f=document.createElement(\"canvas\");f.style.position=\"relative\",f.style.display=\"block\",f.style.width=r+\"px\",f.style.height=c+\"px\",f.style.left=d+\"px\",f.style.top=u+\"px\";const p=\"FILL\"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*c;const g=f.getContext(\"2d\");g.scale(p,p),g.translate(0,-l);const m={context:g,pixelXOffset:d,pixelWidth:r,pixelHeight:c,pixelTop:l,bpStart:i,bpEnd:n,bpPerPixel:h,pixelShift:d,windowFunction:this.windowFunction,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,e,t),this.canvas&&Bt(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(Bt(f))}refresh(){if(!this.canvas||!this.featureCache)return;const e=this.canvas._data;e.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:t,roiFeatures:i}=this.featureCache;this.draw(e,t,i)}draw(e,t,i){if(t&&(e.features=t,this.trackView.track.draw(e)),i&&i.length>0)for(let t of i)e.features=t.features,t.track.draw(e)}containsPosition(e,t){return this.referenceFrame.chr===e&&t>=this.referenceFrame.start&&t<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const e=this.canvas._data,t=e?e.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-Bt(this.canvas).position().left*i,o=(-this.contentTop-t)*i,a=this.canvas.getContext(\"2d\").getImageData(s,o,n,r),c=document.createElement(\"canvas\"),l=c.getContext(\"2d\");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);Pt((this.$trackLabel.text()?this.$trackLabel.text():\"image\")+\".png\",c.toDataURL(\"image/png\"))}saveSVG(){let{width:e,height:t}=this.browser.columnContainer.getBoundingClientRect();const i=new lu({width:e,height:8e3,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),n={deltaX:32,deltaY:32};this.renderSVGContext(i,n,!1),i.setHeight(t);const r=(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\"),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),a=i.getSerializedSvg(!0),c=URL.createObjectURL(new Blob([a],{type:\"application/octet-stream\"}));Pt(`${`${r}_referenceFrame_${o}_guid_${s()}`}.svg`,c)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){if(!(this.$zoomInNotice&&this.$zoomInNotice.is(\":visible\"))){const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,a=t,c=i+this.contentTop,l=-this.contentTop;e.saveWithTranslationAndClipRect(o,a,c,n,r,l);const{start:h,bpPerPixel:d}=this.referenceFrame,u=Math.round((h-this.referenceFrame.start)/d),f={context:e,viewport:this,referenceFrame:this.referenceFrame,top:l,pixelTop:l,pixelWidth:n,pixelHeight:r,pixelXOffset:u,pixelShift:u,bpStart:h,bpEnd:h+n*d,bpPerPixel:d,viewportWidth:n,selection:this.selection},p=this.featureCache?this.featureCache.features:void 0,g=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(f,p,g),e.restore()}if(n&&this.$trackLabel&&this.browser.doShowTrackLabels){const{x:n,y:r,width:s,height:o}=((e,t)=>{const{x:i,y:n,width:r,height:s}=e.getBoundingClientRect(),{x:o,y:a,width:c,height:l}=t.getBoundingClientRect();return{x:o-i,y:a-n,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(e,t+n,i+r,s,o)}}renderTrackLabelSVG(e,t,i,n,r){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_track_label_guid_${s()}`;e.saveWithTranslationAndClipRect(o,t,i,n,r,0),e.fillStyle=\"white\",e.fillRect(0,0,n,r),e.font=\"12px Arial\",e.fillStyle=\"rgb(68, 68, 68)\";const{width:a}=e.measureText(this.$trackLabel.text()),c=.25*(n-a),l=.7*(r-12);e.fillText(this.$trackLabel.text(),c,r-l),e.strokeStyle=\"rgb(68, 68, 68)\",e.strokeRect(0,0,n,r),e.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(e,t,i,n,r){if(this.featureCache&&this.featureCache.containsRange(t,i,n,r,this.windowFunction))return this.featureCache.features;if(\"function\"==typeof e.getFeatures){const s=await e.getFeatures(t,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const e=this.canvas._data;return!e||this.referenceFrame.starte.bpEnd||this.referenceFrame.chr!==e.referenceFrame.chr||this.referenceFrame.bpPerPixel!=e.bpPerPixel||this.windowFunction!=e.windowFunction}needsReload(){if(!this.featureCache)return!0;const{chr:e,bpPerPixel:t}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(e,i,n,t,this.windowFunction)}createZoomInNotice(e){const t=Bt(\"
\",{class:\"igv-zoom-in-notice-container\"});e.append(t);const i=Bt(\"
\");return t.append(i),i.text(\"Zoom in to see features\"),t.hide(),t}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const e=this.$viewport.get(0);this.addViewportContextMenuHandler(e);const t=e=>{this.enableClick=!0,this.browser.mouseDownOnViewport(e,this),r(e)};e.addEventListener(\"mousedown\",t),e.addEventListener(\"touchstart\",t);const i=e=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};e.addEventListener(\"mouseup\",i),e.addEventListener(\"touchend\",i),\"function\"==typeof this.trackView.track.hoverText&&e.addEventListener(\"mousemove\",(e=>{if(0===e.buttons&&Date.now()-vu>100){vu=Date.now();const t=this.createClickState(e);if(t){const e=this.trackView.track.hoverText(t);e?this.$viewport[0].setAttribute(\"title\",e):this.$viewport[0].removeAttribute(\"title\")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&\"sequence\"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(e){e.addEventListener(\"contextmenu\",(e=>{if(this.browser.dragObject)return!1;const t=this.createClickState(e);if(void 0===t)return!1;e.preventDefault();let i=[];if(\"function\"==typeof this.trackView.track.contextMenuItemList){const e=this.trackView.track.contextMenuItemList(t);e&&(i=e)}i.length>0&&i.push({label:Bt(\"
\")}),i.push({label:\"Save Image (PNG)\",click:()=>this.savePNG()}),i.push({label:\"Save Image (SVG)\",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(e,i)}))}addViewportClickHandler(e){e.addEventListener(\"click\",(e=>{if(this.enableClick&&this.canvas){if(3===e.which||e.ctrlKey)return;if(this.browser.dragObject||this.browser.isScrolling)return;e.preventDefault();const t=a(e,this.$viewport.get(0)).x,i=a(e,this.canvas).x,n=this.referenceFrame;Math.floor(n.start+n.toBP(i));const r=Date.now();if(r-Fue));e[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=t,i=e.join(\" \")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,e,this.referenceFrame)}else\"function\"==typeof this.trackView.track.popupData&&(wu=setTimeout((()=>{const t=this.getPopupContent(e);if(t)if(!1===e.shiftKey){if(bu&&bu.dispose(),yu.length>0){for(const e of yu)e.dispose();yu.length=0}bu=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{bu.dispose()})),bu.presentContentWithEvent(e,t)}else{let i=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{const e=yu.indexOf(i);yu.splice(e,1),i.dispose()}));yu.push(i),i.presentContentWithEvent(e,t)}window.clearTimeout(wu),wu=void 0}),this.browser.constants.doubleClickDelay));Fu=r}}))}addTrackLabelClickHandler(e){e.addEventListener(\"click\",(e=>{e.stopPropagation();const{track:t}=this.trackView;let i;\"function\"==typeof t.description?i=t.description():t.description&&(i=`
${t.description}
`),i&&(void 0===this.popover&&(this.popover=new tc(this.browser.columnContainer,!0,t.name||\"\",void 0)),this.popover.presentContentWithEvent(e,i))}))}createClickState(e){if(!this.canvas)return;const t=this.referenceFrame,i=a(e,this.$viewport.get(0)),n=a(e,this.canvas),r=t.start+t.toBP(i.x);return{event:e,viewport:this,referenceFrame:t,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(e){const t=this.createClickState(e);if(void 0===t)return;let i=this.trackView.track;const n=i.popupData(t),r=this.browser.fireEvent(\"trackclick\",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((e=>{if(e.name){const t=`${e.name}   ${e.value}`;return`
${t}
`}return\"
\"===e?e:e.html?e.html:`
${e}
`})).join(\"\")):\"string\"==typeof r&&(s=r),s}dispose(){this.popover&&this.popover.dispose(),super.dispose()}}class Cu{constructor(e,t,i,n,r,s,o,a){this.chr=e,this.bpStart=t,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o,this.windowFunction=a}containsRange(e,t,i,n,r){if(r&&r!==this.windowFunction)return!1;const s=this.multiresolution?this.bpPerPixel/n:1;return t>=this.bpStart&&i<=this.bpEnd&&e===this.chr&&s>.5&&s<2}overlapsRange(e,t,i){return this.chr===e&&i>=this.bpStart&&t<=this.bpEnd}}const _u=function(e,t){const{r:i,g:n,b:r}=no[e];return`rgba(${i},${n},${r},${t})`}(\"nickel\",2/16),xu=_u;class ku{constructor(e,t){if(this.url=e.url,e.name&&(this.name=e.name),this.isUserDefined=e.isUserDefined,e.featureSource)this.featureSource=e.featureSource;else if(e.features)this.featureSource=new Su(e.features,t);else{if(!e.format)throw Error(\"ROI configuration must define either features or file format\");this.featureSource=Ad(e,t)}!0===this.isUserDefined?(this.color=e.color||xu,this.headerColor=\"rgba(155,185,129)\"):(this.color=e.color||_u,this.headerColor=\"rgb(190,190,190)\"),this.isVisible=void 0===e.isVisible||e.isVisible}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}async getAllFeatures(){return\"function\"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(e){this.featureSource.addFeature(e)}removeFeature(e){this.featureSource.removeFeature(e)}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined,isVisible:this.isVisible};{const e=this.featureSource.getAllFeatures(),t=[];for(let i of Object.keys(e))for(let n of e[i])t.push(n);return{name:this.name,color:this.color,features:t,isUserDefined:this.isUserDefined,isVisible:this.isVisible}}}dispose(){for(let e of Object.keys(this))this[e]=void 0}}function Iu(e,t,i,n){let r=Math.round((e-i)/n);let s=Math.round((t-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class Su{constructor(e,t){this.featureMap={},this.genome=t;for(let i of e){const e=t?t.getChromosomeName(i.chr):i.chr;let n=this.featureMap[e];n||(n=[],this.featureMap[e]=n),n.push(i)}for(let e of Object.keys(this.featureMap))this.featureMap[e].sort(((e,t)=>e.start-t.start))}async getFeatures({chr:e,start:t,end:i}){if(\"all\"===e.toLowerCase())return Ll(this.featureMap,this.genome);{const n=this.featureMap[e];return n?n.filter((e=>e.end>t&&e.starte.start-t.start))}removeFeature({chr:e,start:t,end:i}){if(this.featureMap[e]){const n=`${e}-${t}-${i}`;this.featureMap[e]=this.featureMap[e].filter((e=>n!==`${e.chr}-${e.start}-${e.end}`)),0===this.featureMap[e].length&&delete this.featureMap[e]}}}class Eu{constructor(t,i,n,r){this.rulerViewport=t,this.rulerSweeper=e({class:\"igv-ruler-sweeper\"}),i.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(mu.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on(\"locuschange\",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off(\"locuschange\",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let e,t,i,n,r,s;this.boundContentMouseDownHandler=function(s){e=!0,t=!0;const{x:o}=a(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display=\"block\",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?xu:\"rgba(68, 134, 247, 0.25)\",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener(\"mousedown\",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let c;if(e&&t){const{x:e}=a(o,this.rulerViewport.contentDiv);c=Math.max(Math.min(e,this.rulerViewport.contentDiv.clientWidth),0),s=c-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;if(!0===e&&!0===t&&(e=t=void 0,this.rulerSweeper.style.display=\"none\",r>1)){s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))};!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(Qa(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(e,t,i){e.start=Math.round(t.start),e.end=Math.round(t.end),e.bpPerPixel=(e.end-e.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener(\"mousedown\",this.boundContentMouseDownHandler),document.removeEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),document.removeEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}function Nu(e){if(Bu[e])return Bu[e];if(Bu[\"chr\"+e]){const t=Bu[\"chr\"+e];return Bu[e]=t,t}{const t=_s.randomRGB(0,255);return Bu[e]=t,t}}const Bu={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0)\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};let Mu,Ru;class Du extends Au{constructor(e,t,i,n){super(e,t,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let e;this.$multiLocusCloseButton=Bt(\"
\",{class:\"igv-multi-locus-close-button\"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(l(\"times-circle\")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=Bt(\"
\",{class:\"igv-multi-locus-ruler-label\"}),this.$viewport.append(this.$rulerLabel),e=document.createElement(\"div\"),this.$rulerLabel.append(Bt(e)),this.$rulerLabel.get(0).addEventListener(\"click\",(async e=>{e.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=Bt(\"
\",{class:\"igv-ruler-tooltip\"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=Bt(\"
\"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new Eu(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(mu.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(e){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=Nu(this.referenceFrame.chr);const t=this.$rulerLabel.get(0).querySelector(\"div\"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();t.innerHTML=`${this.referenceFrame.getMultiLocusLabel(e)}`;const{width:n}=t.getBoundingClientRect();n/i>.5&&(t.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(e)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(e){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===e){const e=this.browser.referenceFrameList.indexOf(this.referenceFrame),t=`click${this.namespace}`;this.$viewport.on(t,(t=>{const{x:i}=a(t,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let t=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));t[e]=s,r=t.join(\" \")}this.browser.search(r)})),this.$viewport.get(0).style.cursor=\"pointer\"}else this.$viewport.get(0).style.cursor=\"default\"}mouseMove(e){if(!0===this.browser.doShowCursorGuide){void 0===Ru?(Ru=this,this.$tooltip.show()):Ru.guid!==this.guid?(Ru.$tooltip&&Ru.$tooltip.hide(),this.$tooltip.show(),Ru=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:t}=a(e,this.$viewport.get(0)),{start:i,end:n,bpPerPixel:r}=this.referenceFrame,s=Math.round(.5+i+Math.max(0,t)*r);this.$tooltipContent.text(Rt(s));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:c}=this.$viewport.get(0).getBoundingClientRect();return this.$tooltip.css({left:`${ys.clamp(t,0,c-o)}px`}),clearTimeout(Mu),Mu=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4),{start:i,bp:s,end:n}}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class Tu extends Au{featureCache=new Lu;constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.canvas=document.createElement(\"canvas\"),this.canvas.className=\"igv-ideogram-canvas\",this.$viewport.append(Bt(this.canvas)),this.ideogram_ctx=this.canvas.getContext(\"2d\"),this.addMouseHandlers()}async getFeatures(e,t,i,n){return this.featureCache.containsRange(e)?this.featureCache.get(e):this.loadFeatures()}async loadFeatures(){const e=this.referenceFrame.chr,t=await this.referenceFrame.genome.getCytobands(e);return this.featureCache.set(e,t),t}repaint(){if(void 0===this.featureCache)return;const{width:e,height:t}=this.$viewport[0].getBoundingClientRect();xo.configureHighDPICanvas(this.ideogram_ctx,e,t);const i=this.referenceFrame.chr,n=this.featureCache.get(i),r={context:this.ideogram_ctx,pixelWidth:e,pixelHeight:t,referenceFrame:this.referenceFrame,features:n};this.trackView.track.draw(r)}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(e){this.boundClickHandler=function(e){const{xNormalized:t,width:i}=a(e,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=t;s-r/2<0&&(s=r/2);s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),c=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=c,this.referenceFrame.bpPerPixel=(c-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),e.addEventListener(\"click\",this.boundClickHandler)}setWidth(e){this.$viewport.width(e)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){const{width:r,height:o}=this.$viewport.get(0).getBoundingClientRect(),a=`ideogram_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,c=t,l=i+this.contentTop,h=-this.contentTop;e.saveWithTranslationAndClipRect(a,c,l,r,o,h),this.trackView.track.draw({context:e,pixelWidth:r,pixelHeight:o,referenceFrame:this.referenceFrame,features:this.featureCache.get(this.referenceFrame.chr)}),e.restore()}startSpinner(){}stopSpinner(){}}class Lu{features=new Map;containsRange(e){return this.features.has(e)}set(e,t){this.features.set(e,t)}get(e){return this.features.get(e)}}function zu(e,t,i,n){if(\"ruler\"===e.track.type)return new Du(e,t,i,n);if(\"ideogram\"===e.track.id)return new Tu(e,t,i,n);{const r=new Au(e,t,i,n);return i.viewport=r,r}}const Hu=[\"rgb(255, 0, 0)\",\"rgb(0, 255, 0)\",\"rgb(0, 0, 255)\",\"rgb(255, 0, 255)\",\"rgb(0, 255, 255)\",\"rgb(128, 0, 128)\",\"rgb(255, 165, 0)\",\"rgb(255, 105, 180)\",\"rgb(255, 127, 80)\",\"rgb(220, 20, 60)\",\"rgb(255, 99, 71)\",\"rgb(173, 216, 230)\",\"rgb(144, 238, 144)\",\"rgb(224, 255, 255)\",\"rgb(250, 250, 210)\",\"rgb(152, 251, 152)\",\"rgb(70, 130, 180)\",\"rgb(102, 205, 170)\"].map((e=>{const[t,i,n]=e.split(\",\"),[r,s]=t.split(\"(\"),[o,a]=n.split(\")\");return[s,i,o]})),Pu=ro(\"magnesium\"),Ou=[\"#sampleTable\",\"#sampleMapping\",\"#colors\"];class Uu{static emptySpaceReplacement=\"|\";sampleDictionary={};attributeNames=[];sampleMappingDictionary={};colorDictionary={};attributeRangeLUT={};constructor(e){e.tracks.some((e=>\"function\"==typeof e.getSamples)).length>0&&e.sampleInfoControl.setButtonVisibility(!0),this.initialize()}initialize(){this.sampleInfoFiles=[],this.attributeNames=[],this.sampleDictionary={},this.sampleMappingDictionary={},this.colorDictionary={},this.attributeRangeLUT={},this.initialized=!1}get attributeCount(){return this.attributeNames?this.attributeNames.length:0}isInitialized(){return this.initialized}hasAttributes(){return this.attributeCount>0}getAttributes(e){const t=0===Object.keys(this.sampleMappingDictionary)?e:this.sampleMappingDictionary[e]||e;return this.sampleDictionary[t]}async loadSampleInfoFile(e){try{const t=await Qs.loadString(e);this.#w(t),this.sampleInfoFiles.push(e)}catch(e){console.error(e.message)}}#w(e){const t=function(e){const t={},i=e.split(/\\r?\\n|\\r/).map((e=>e.trim())).filter((e=>\"\"!==e));let n;Ou.includes(i[0])||(n=\"#sampleTable\",t[n]=[]);for(const e of i)Ou.includes(e)?(n=e,t[n]=[]):n&&!1===e.startsWith(\"#\")&&t[n].push(e);return t}(e);for(const[e,i]of Object.entries(t))switch(e){case\"#sampleTable\":this.#b(i);break;case\"#sampleMapping\":this.#F(i);break;case\"#colors\":this.#v(i)}this.initialized=!0}getAttributeColor(e,t){let i;if(\"-\"===t)i=ro(\"snow\");else if(\"string\"==typeof t&&this.colorDictionary[t])i=this.colorDictionary[t]();else if(this.colorDictionary[e])i=this.colorDictionary[e](t);else if(\"string\"==typeof t)i=\"NA\"===t?Pu:function(e){let t=0;for(let i=0;i>8*e&255;i.push(n)}return`rgb(${i.join(\", \")})`}(t);else{const[n,r]=this.attributeRangeLUT[e],s=.2,o=Math.max((t-n)/(r-n),s),[a,c,l]=Hu[Object.keys(this.attributeRangeLUT).indexOf(e)];i=`rgba(${a},${c},${l},${o})`}return i}getSortedSampleKeysByAttribute(e,t,i){i=i||1;const n=e.filter((e=>\"number\"==typeof this.getAttributes(e)[t])),r=e.filter((e=>\"string\"==typeof this.getAttributes(e)[t])),s=(e,n)=>{const r=this.getAttributes(e)[t],s=this.getAttributes(n)[t];return\"string\"==typeof r&&\"string\"==typeof s?i*r.localeCompare(s):\"number\"==typeof r&&\"number\"==typeof s?i*(r-s):void 0};return n.sort(s),r.sort(s),-1===i?[...n,...r]:[...r,...n]}toJSON(){const e=[];for(const t of this.sampleInfoFiles){const i={url:t},n=Hl.localFileInspection(i);e.push(n)}return e}#b(e){const t=e.shift().split(\"\\t\").filter((e=>e.length>0));t.shift();const i=t.map((e=>e.split(\" \").join(Uu.emptySpaceReplacement))),n=e.filter((e=>e.length>0));let r;for(const e of n){const t=e.split(\"\\t\"),n=t.shift();void 0===r&&(r={}),r[n]={};for(let e=0;e\"number\"==typeof e,r=e=>\"string\"==typeof e;for(const e of Object.keys(i)){const t=i[e],s=new Set(t),o=Array.from(s);if(!0===o.some(r)&&!0===o.some(n)?i[e]=o.filter((e=>!r(e))):i[e]=o,!i[e].some(r)){const t=i[e].slice();i[e]=[Math.min(...t),Math.max(...t)]}}return i}(i,r);qu(this.attributeRangeLUT,s);const o=new Set(this.attributeNames);for(const e of i)o.has(e)||this.attributeNames.push(e);qu(this.sampleDictionary,r)}#F(e){for(const t of e){const[e,i]=t.split(\"\\t\");this.sampleMappingDictionary[e]=i}}#v(e){const t=(e,t,i)=>{let n;switch(t){case 0:n=e.split(\" \").join(Uu.emptySpaceReplacement);break;case 1:n=e.includes(\":\")?e.split(\":\").map((e=>parseFloat(e))):e;break;case 2:case 3:n=`rgb(${e})`}return n},i=e.map((e=>e.split(\"\\t\").map(t))),n=i.filter((e=>3===e.length&&!e.includes(\"*\"))).filter((([e,t,i])=>!Array.isArray(t))),r={};for(const e of n){const[t,i,n]=e;void 0===r[t]&&(r[t]={}),r[t][i.toUpperCase()]=n}for(const[e,t]of Object.entries(r)){const i=Object.assign({},t);this.colorDictionary[e]=e=>{const t=e.toUpperCase();return i[t]||ro(\"snow\")}}const s=i.filter((e=>Array.isArray(e[1])));for(const e of s){const[t,i]=e[1],n=e[0];if(3===e.length){const[r,s,o]=uo(e[2]);this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return lo(r,s,o,(e-t)/(i-t))}}else if(4===e.length){const[t,i]=e[1],[n,r,s,o]=e;this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return fo(s,o,(e-t)/(i-t))}}}const o=i.filter((e=>3===e.length&&e.includes(\"*\")));for(const e of o)if(\"*\"===e[1]){const[t,i,n]=e;this.colorDictionary[t]=e=>{if(\"NA\"===e)return Pu;{const[i,r]=this.attributeRangeLUT[t],s=(e-i)/(r-i),[o,a,c]=uo(n);return lo(o,a,c,s)}}}else if(\"*\"===e[0]){const[t,i,n]=e;this.colorDictionary[i]=()=>n}}}function qu(e,t){for(const[i,n]of Object.entries(t))i in e&&e[i]===n||(e[i]=n)}function Qu(e){const t=Object.assign({},e);for(const[e,i]of Object.entries(t))\"string\"!=typeof i||isNaN(i)||(t[e]=Number(i));return t}const Vu=16,ju=Rt;class Wu{constructor(e){this.browser=e,this.height=40,this.name=\"\",this.id=\"ruler\",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type=\"ruler\"}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){mu.isWholeGenomeView(t.chr)?this.drawWholeGenome({context:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n}){e.save(),xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"});for(let t of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(t),s=this.browser.genome.getChromosome(t).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(e,o,0,a,i,t)}e.restore()}doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:r}){e.clearRect(0,0,i,n);const s=function(e,t){if(e<10)return new Gu(1,\"bp\",1);const i=Math.floor(Math.log10(e));let n=\"bp\",r=1;i>9?(n=\"gb\",r=1e9):i>6?(n=\"mb\",r=1e6):i>3&&(n=\"kb\",r=1e3);const s=Math.pow(10,i-1),o=e/s,a=75,c=Math.pow(10,i-1),l=Math.pow(10,i)/2;return new Gu(o0&&u+c<=d&&(xo.fillText(e,i,n,this.height-8),d=0),l>0&&xo.strokeLine(e,l,this.height-6,l,this.height-2),h=Math.floor((1+o)*s.majorTick);let f=l+(Math.round(t.toPixels(h-1-r+.5))-l)/2;f>0&&xo.strokeLine(e,f,this.height-6,f,this.height-2),++o,d+=a}while(le.measureText(o).width&&xo.fillText(e,o,t+n/2,i+r/2,{fillStyle:_s.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Gu{constructor(e,t,i){this.majorTick=e,this.minorTick=e/10,this.majorUnit=t,this.unitMultiplier=i}description(e){console.log((e||\"\")+\" tick \"+ju(this.majorTick)+\" label width \"+ju(this.labelWidthBP)+\" multiplier \"+this.unitMultiplier)}}class $u{constructor(t,i,n){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),this.viewport.style.height=`${t.track.height}px`,null===this.viewport.previousElementSibling&&(this.viewport.style.zIndex=16,this.viewport.style.overflow=\"visible\"),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.ctx.font=\"10px verdana\",this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(n),this.addMouseHandlers()}resizeCanvas(){const e=window.devicePixelRatio,t=this.browser.getSampleInfoViewportWidth();let i;if(this.browser.trackViews.length>1&&null===this.viewport.previousElementSibling){const[e,t]=[this.browser.ideogramTrackView.track,this.browser.rulerTrackView.track];i=e.height+t.height}else i=this.viewport.clientHeight;if(this.canvas.width!==t*e||this.canvas.height!==i*e){const n=this.canvas;n.width=t*e,n.height=i*e,n.style.width=`${t}px`,n.style.height=`${i}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(e,e),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}}setTop(e){\"function\"==typeof this.trackView.track.getSamples&&(this.contentTop=e,this.repaint())}setWidth(e){this.viewport.innerWidth=e,this.resizeCanvas()}setHeight(e){const t=this.browser.getSampleInfoViewportWidth();this.viewport.style.width=`${t}px`,this.viewport.style.height=`${e}px`;const i=window.devicePixelRatio;this.canvas.width=t*i,this.canvas.height=e*i,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(i,i),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}async repaint(){if(this.resizeCanvas(),\"function\"==typeof this.trackView.track.getSamples){const e=this.trackView.track.getSamples();e.names&&e.names.length>0&&this.draw({context:this.ctx,samples:e})}else null===this.viewport.previousElementSibling&&(this.browser.rulerTrackView&&this.browser.rulerTrackView.setTrackHeight(!0===this.browser.sampleInfoControl.showSampleInfo?this.calculateSampleInfoColumnHeight():40,!0),this.renderSampleInfoColumns(this.ctx))}calculateSampleInfoColumnHeight(){const e=this.browser.sampleInfo.attributeNames.map((e=>this.ctx.measureText(e).width));return 4+Math.min(Math.max(...e),128)}draw({context:e,samples:t}){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=ro(\"snow\"),e.fillRect(0,0,e.canvas.width,e.canvas.height),t&&t.names.length>0){const i=this.browser.sampleInfo.attributeNames,n=this.viewport.getBoundingClientRect().height;let r=1;const s=t.height;r=s-2*r<=1?0:1;let o=this.contentTop+t.yOffset;this.hitList={};for(const a of t.names){if(o>n)break;if(o+s>0){const t=this.browser.sampleInfo.getAttributes(a);if(t){const n=Object.entries(t);for(const t of n){const[n,a]=t;e.fillStyle=this.browser.sampleInfo.getAttributeColor(n,a);const c=8+i.indexOf(n)*Vu,l=o+r,h=s-2*r;e.fillRect(c,l,15,h);const d=`${Math.floor(c)}#${Math.floor(l)}#16#${Math.ceil(h)}`;this.hitList[d]=`${n}#${a}`}}}o+=s}}}renderSampleInfoColumns(e){const t=(e,t,i,n,r,s)=>{e.save(),e.font=\"10px verdana\",e.translate(i+r/2,n+s),e.rotate(-Math.PI/2),e.textAlign=\"left\",e.fillStyle=ro(\"lead\"),e.fillText(t,2,2),e.restore()},i=this.browser.sampleInfo.attributeNames;this.hitList={};for(let n=0;n{const{marginTop:n}=window.getComputedStyle(i),{x:r,y:s}=a(e,this.browser.columnContainer.querySelector(\".igv-sample-info-column\"));return{x:Math.floor(r),y:Math.floor(s-parseInt(n,10))}},n=this.browser.columnContainer.querySelector(\".igv-sample-info-column\"),{x:r,y:s}=i(n,this.viewport);n.setAttribute(\"title\",\"\");for(const[e,i]of t){const[t,o,a,c]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(rt+a||so+c)){n.setAttribute(\"title\",`${i}`);break}}}else{const{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){const[e,t]=r.split(\"#\");this.viewport.setAttribute(\"title\",`${e.split(Uu.emptySpaceReplacement).join(\" \")}: ${\"-\"===t?\"\":t}`);break}}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}show(){this.viewport.style.display=\"block\"}hide(){this.viewport.style.display=\"none\"}}class Ku{constructor(t,i,n,r){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.track.height}px`),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.trackScrollDelta=0,this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(r),this.addMouseHandlers()}checkCanvas(){const e=this.browser.sampleNameViewportWidth||0;this.ctx.canvas.width=e*window.devicePixelRatio,this.ctx.canvas.style.width=`${e}px`,this.ctx.canvas.height=this.viewport.clientHeight*window.devicePixelRatio,this.ctx.canvas.style.height=`${this.viewport.clientHeight}px`,this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio)}setTop(e){if(\"function\"==typeof this.trackView.track.getSamples){this.contentTop=e;const t=this.trackView.track.getSamples();this.repaint(t)}}setWidth(e){this.viewport.innerWidth=e,this.checkCanvas()}async repaint(e){if(e.names.length>0&&!0===this.browser.showSampleNames&&(this.checkCanvas(),this.draw({context:this.ctx,samples:e}),void 0===this.browser.sampleNameViewportWidth)){const t=e.names.map((e=>this.ctx.measureText(e).width));this.browser.sampleNameViewportWidth=Math.min(200,4+Math.ceil(Math.max(...t))),this.browser.layoutChange()}}draw({context:e,samples:t}){if(xo.fillRect(e,0,0,e.canvas.width,t.height,{fillStyle:ro(\"snow\")}),t&&t.names.length>0){const i=this.viewport.getBoundingClientRect().height,n=t.height,r=n-2<=1?0:1;let s=this.contentTop+t.yOffset;this.hitList={};for(const o of t.names){if(s>i)break;if(s+n>0){const t=n-2*r;Yu(e,o,0+2,s+r,e.canvas.width,t)}s+=n}}}renderSVGContext(e,{deltaX:t,deltaY:i}){if(\"function\"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:o,height:a}=this.viewport.getBoundingClientRect(),c=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_sample_names_guid_${s()}`;e.saveWithTranslationAndClipRect(c,t,i+r,o,a,-r),this.draw({context:e,samples:n}),e.restore()}}addMouseHandlers(){this.boundClickHandler=function(e){e.preventDefault();const t={label:\"Name Panel Width\",value:this.browser.sampleNameViewportWidth,callback:e=>{this.browser.sampleNameViewportWidth=parseInt(e),this.browser.layoutChange()}};this.browser.inputDialog.present(t,e)}.bind(this),this.viewport.addEventListener(\"contextmenu\",this.boundClickHandler),this.boundMouseMoveHandler=function(e){if(this.hitList){const t=Object.entries(this.hitList),{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){this.viewport.setAttribute(\"title\",`${r}`);break}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"contextmenu\",this.boundClickHandler),this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function Yu(e,t,i,n,r,s){const o=Math.min(s,10);e.font=`${o}px sans-serif`,e.textAlign=\"start\",e.fillStyle=ro(\"lead\");const a=i,c=e.measureText(t),l=n+s/2+(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent)/2;e.fillText(t,a,l)}class Xu{constructor(t){this.popover=e({class:\"igv-menu-popup\"}),t.appendChild(this.popover),this.parent=t;const i=e({class:\"igv-menu-popup-header\"});this.popover.appendChild(i),u(i,(()=>this.popover.style.display=\"none\")),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),p(this.popover,i),i.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault()})),this.popover.style.display=\"none\"}presentMenuList(e,t){if(Zu(this.parent),t.length>0){this.popoverContent.innerHTML=\"\";const i=this.parseMenuList(e,t);for(let e of i){e.init&&e.init();let t=e.object;0===i.indexOf(e)&&t.removeClass(\"igv-track-menu-border-top\"),t.hasClass(\"igv-track-menu-border-top\")||t.hasClass(\"igv-menu-popup-check-container\")||t.is(\"div\")&&t.addClass(\"igv-menu-popup-shim\"),this.popoverContent.appendChild(t.get(0))}this.popover.style.display=\"flex\";const{width:n}=this.popover.getBoundingClientRect();this.popover.style.left=-n+\"px\",this.popover.style.top=\"0px\"}}parseMenuList(e,t){return t.map(((t,i)=>{let n;if(t.name?(n=Bt(\"
\"),n.text(t.name)):t.object?n=t.object:\"string\"==typeof t.label?(n=Bt(\"
\"),n.html(t.label)):\"string\"==typeof t&&(n=t.startsWith(\"<\")?Bt(t):Bt(\"
\"+t+\"
\")),0===i&&n.addClass(\"igv-track-menu-border-top\"),t.click||t.dialog){const i=i=>{if(i.preventDefault(),i.stopPropagation(),t.click)if(e.track.selected){const n=e.browser.getSelectedTrackViews();if(!0===t.doAllMultiSelectedTracks)t.click.call(e.track,i);else if(\"removeTrack\"===t.menuItemType){const r=()=>{e.browser.overlayTrackButton.setVisibility(!1);for(const{track:e}of n)t.click.call(e,i)},s={html:`Are you sure you want to delete ${n.length} tracks?`,callback:r};e.browser.menuUtils.dialog.present(s,i)}else for(const{track:e}of n)t.click.call(e,i)}else t.click.call(e.track,i);else t.dialog&&t.dialog.call(e.track,i);this.popover.style.display=\"none\"};n.on(\"click\",i),n.on(\"touchend\",(e=>i(e))),n.on(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}return{object:n,init:t.init||void 0}}))}presentTrackContextMenu(t,n){this.popoverContent.innerHTML=\"\";const r=function(t,n){return t.map((t=>{let r;if(\"string\"==typeof t&&\"
\"===t)r=document.createElement(\"hr\");else if(\"string\"==typeof t)r=e({class:\"context-menu\"}),r.innerHTML=t;else if(\"Node\"==typeof t)r=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)r=Dl(\"Show all bases\",t.value);else if(\"color\"===t.type){const s=new Ra(n.parentElement);s.configure({color:\"grey\"}),r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);const o=e=>{s.show(),i(n),e.preventDefault(),e.stopPropagation()};r.addEventListener(\"click\",o),r.addEventListener(\"touchend\",o),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function a(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}r.addEventListener(\"click\",a),r.addEventListener(\"touchend\",a),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{el:r,init:t.init}}))}(n,this.popover);for(let{el:e}of r)this.popoverContent.appendChild(e);!function(e,t){t.style.display=\"flex\";const{x:i,y:n}=a(e,t.parentNode),{width:r}=t.getBoundingClientRect(),s=i+r,{width:o}=t.parentNode.getBoundingClientRect();t.style.left=`${s>o?i-(s-o):i}px`,t.style.top=`${n}px`}(t,this.popover)}hide(){this.popover.style.display=\"none\"}dispose(){this.popoverContent.innerHTML=\"\",this.popover.innerHTML=\"\",Object.keys(this).forEach((function(e){this[e]=void 0}))}}const Zu=e=>{const t=e.querySelectorAll(\".igv-menu-popup\");for(const e of t)e.style.display=\"none\"};class Ju{constructor(t,i,n,r,s,o,a){this.browser=i,this.button=e({class:\"igv-navbar-text-button\"}),t.appendChild(this.button),Array.isArray(n)?(this.textContent=n[0],this.title=n[1]):this.textContent=this.title=n,this.buttonLabel=r,this.imageDictionary={image:`url(\"data:image/svg+xml,${encodeURIComponent(s)}\")`,imageHover:`url(\"data:image/svg+xml,${encodeURIComponent(o)}\")`},this.responsiveKey=\"text\",this.configureButton(this.textContent,this.title),this.setState(a),i.on(\"navbar-resize\",(e=>{this.navbarResizeHandler(e)}))}navbarResizeHandler(e){const t=\"igv-navbar-icon-button\"===e?\"image\":\"text\";t!==this.responsiveKey&&(this.responsiveKey=t,this.configureButton(this.textContent,this.title),this.setState(void 0))}configureButton(e,t){this.groupElement=void 0,this.button.title=t,this.button.innerHTML=\"\",this.button.style.backgroundImage=\"none\",this.button.classList.remove(\"igv-navbar-icon-button\"),this.button.classList.remove(\"igv-navbar-text-button\"),\"text\"===this.responsiveKey?this.configureTextButton(e):this.configureIconButton()}configureTextButton(e){console.log(`text ${this.title}`),this.button.classList.add(\"igv-navbar-text-button\");const t=document.createElement(\"div\");t.innerHTML=this.buttonLabel;const i=t.firstChild;this.button.appendChild(i),this.groupElement=i.querySelector(\"#igv-navbar-button-group\");i.querySelector(\"#igv-navbar-button-label\").textContent=e}configureIconButton(){console.log(`icon ${this.title}`),this.button.classList.add(\"igv-navbar-icon-button\")}setState(e){void 0!==e&&(this.doHover=e),\"text\"===this.responsiveKey?this.setTextButtonState(this.doHover):this.setIconButtonState(this.doHover)}setTextButtonState(e){this.groupElement.classList.remove(...this.groupElement.classList);const t=!0===e?\"igv-navbar-text-button-svg-hover\":\"igv-navbar-text-button-svg-inactive\";this.groupElement.classList.add(t)}setIconButtonState(e){this.button.style.backgroundImage=!0===e?this.imageDictionary.imageHover:this.imageDictionary.image}show(){this.button.style.display=\"flex\"}hide(){this.button.style.display=\"none\"}setVisibility(e){!0===e?this.show():this.hide()}}const ef='\\n \\n \\n \\n \\n \\n \\n \\n \\n';class tf extends Hl{static defaults={autoscale:void 0,alpha:.5,height:50};constructor(e,t,i){super(e,t),this.type=\"merged\",this.paintAxis=cd,this.graphType=e.graphType,this.tracks=i||[]}async postInit(){if(this.config.tracks){for(let e of this.config.tracks){const t=await this.browser.createTrack(e);t?this.tracks.push(t):console.warn(\"Could not create track \"+e),\"function\"==typeof t.postInit&&await t.postInit()}this.config.tracks.every((e=>void 0!==e.autoscale||void 0!==e.max))||(this.config.autoscale=void 0===this.config.max)}for(let e of this.tracks)e.isMergedTrack=!0;if(this.config.autoscale?this.autoscale=this.config.autoscale:void 0!==this.config.max&&this.setDataRange({min:this.config.min||0,max:this.config.max}),void 0!==this.config.flipAxis)for(let e of this.tracks)e.flipAxis=this.config.flipAxis;if(void 0!==this.config.logScale)for(let e of this.tracks)e.logScale=this.config.logScale;this.resolutionAware=this.tracks.some((e=>e.resolutionAware))}set flipAxis(e){this.config.flipAxis=e;for(let t of rf(this.tracks))t.flipAxis=e}get flipAxis(){return rf(this.tracks).every((e=>e.flipAxis))}set logScale(e){this.config.logScale=e;for(let t of rf(this.tracks))t.logScale=e}get logScale(){return rf(this.tracks).every((e=>e.logScale))}get height(){return this._height}set height(e){if(this.config.height=e,this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}set autoscale(e){if(this._autoscale=e,!1===e&&this.tracks)for(let e of this.tracks)e.autoscale=!1}get autoscale(){return this._autoscale}set autoscaleGroup(e){if(this.tracks)for(let t of this.tracks)t.autoscaleGroup=e}get autoscaleGroup(){if(this.tracks&&this.tracks.length>0){const e=this.tracks[0].autoscaleGroup;return this.tracks.some((t=>e!==t.autoscaleGroup))?void 0:e}}setDataRange({min:e,max:t}){this.autoscale=!1;for(const i of rf(this.tracks))i.dataRange={min:e,max:t},i.autoscale=!1,i.autoscaleGroup=!1}set dataRange({min:e,max:t}){for(const i of rf(this.tracks))i.dataRange={min:e,max:t}}get dataRange(){if(this.tracks){const e=rf(this.tracks);if(e.length>0){const t=e[0].dataRange;if(e.every((e=>e.dataRange&&e.dataRange.min===t.min&&e.dataRange.max===t.max)))return t}}}menuItemList(){const e=[];return rf(this.tracks).length>0&&(void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e.push(...this.numericDataMenuItems())),e.push(\"
\"),e.push(this.overlayTrackAlphaAdjustmentMenuItem()),e.push(this.trackSeparationMenuItem()),e}async getFeatures(e,t,i,n){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n))),s=await Promise.all(r);if(s.every((e=>0===e.length)))return new nf([],[]);{const e=this.tracks.map((e=>e.name));return new nf(s,e)}}draw(e){const t=e.features;for(let i=0,n=this.tracks.length;i0&&i.push(\"
\"),i.push(`
${t[r].trackName}
`),t[r].features.length>0){n=!1;const s=this.tracks[r].popupData(e,t[r].features);i.push(...s)}else i.push(\"Missing or 0 value(s)\");return!0===n?[]:i}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!t.featureArrays||!Array.isArray(t.featureArrays)||0===t.featureArrays.length)return[];const i=e.genomicLocation,n=[],r=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2,s=i-r,o=i+r;for(let e=0;ee.supportsWholeGenome))}getState(){const e=super.getState(),t=[];for(let e of this.tracks)t.push(e.getState());return e.tracks=t,e}updateScales(e){let t;if(this.autoscale){t=!0;let i=[];for(let t of e){if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,r=n+e.toBP(t.getWidth()),s=t.featureCache.features;this.autoscale&&(i.push({value:s.getMax(n,r)}),i.push({value:s.getMin(n,r)}))}const e=qa(i);for(const t of rf(this.tracks))t.dataRange=e}}else{let i=-1;for(let n of this.tracks)if(++i,n.autoscale){t=!0;let r=[];for(let t of e)if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,s=n+e.toBP(t.getWidth()),o=t.featureCache.features.featureArrays[i];if(o)for(let e of o)if(!(e.ends)break;r.push(e)}}n.dataRange=qa(r)}}return t}overlayTrackAlphaAdjustmentMenuItem(){const t=e();return t.innerText=\"Set transparency\",{object:Bt(t),dialog:function(e){const t={label:\"Transparency\",value:this.alpha,min:0,max:1,scaleFactor:1e3,callback:e=>{this.alpha=Math.max(.001,e),this.repaintViews()}};this.browser.sliderDialog.present(t,e)}}}trackSeparationMenuItem(){const e=Bt(\"
\");return e.text(\"Separate tracks\"),{object:e,click:function(e){const t=this.autoscale,i=this.name,n=this.tracks,r=this.browser,s=this.order;r.removeTrack(this);for(let e of n)e.order=s,t&&(e.autoscaleGroup=i),e.isMergedTrack=!1,r.addTrack(e.config,e);r.updateViews()}}}}class nf{constructor(e,t){this.featureArrays=e,this.trackNames=t}getMax(e,t){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(!(void 0===r.value||Number.isNaN(r.value)||r.endt)break;i=Math.max(i,r.value)}return i!==-Number.MAX_VALUE?i:100}getMin(e,t){let i=0;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.endt)break;i=Math.min(i,r.value)}return i}}const rf=e=>e?e.filter((e=>void 0!==e.dataRange||void 0!==e.autoscale||void 0!==e.autoscaleGroup)):[];class sf extends Ju{constructor(e,t){super(e,t,\"Overlay Tracks\",ef,'\\n Overlay Tracks\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n Overlay Tracks Hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>this.setState(!1)));this.boundMouseClickHandler=(()=>{this.setVisibility(!1),of.call(this)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(!0)}}function of(e){if(!0===af(this.browser)){const e=this.browser.getSelectedTrackViews().map((({track:e})=>e));for(const t of e)t.selected=!1;const t=[];for(let i of e)\"merged\"===i.type?t.push(...i.tracks):t.push(i);const i={name:\"Overlay\",type:\"merged\",autoscale:!1,alpha:.5,height:Math.max(...e.map((({height:e})=>e))),order:Math.min(...e.map((({order:e})=>e)))},n=new tf(i,this.browser,t);for(const t of e){const e=this.browser.trackViews.indexOf(t.trackView);this.browser.trackViews.splice(e,1),t.trackView.dispose()}this.browser.addTrack(i,n),n.trackView.updateViews()}}function af(e){const t=e.getSelectedTrackViews();if(t&&t.length>1){const e=new Set([\"wig\",\"merged\"]);return t.filter((({track:t})=>e.has(t.type))).length>1}return!1}const cf=new Set([\"sequence\",\"ruler\",\"ideogram\"]),lf=new Set([\"ruler\",\"sequence\",\"ideogram\"]);class hf{constructor(e,t,i){this.namespace=`trackview-${s()}`,this.browser=e,this.track=i,i.trackView=this,this.addDOMToColumnContainer(e,t,e.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(e,t,i){this.axis=this.createAxis(e,this.track),this.createViewports(e,t,i),this.sampleInfoViewport=new $u(this,e.columnContainer.querySelector(\".igv-sample-info-column\"),e.getSampleInfoViewportWidth()),this.sampleNameViewport=new Ku(this,e.columnContainer.querySelector(\".igv-sample-name-column\"),void 0,e.getSampleNameViewportWidth()),this.createTrackScrollbar(e),this.createTrackDragHandle(e),this.createTrackGearPopup(e)}createViewports(e,t,i){this.viewports=[];const n=e.calculateViewportWidth(i.length),r=t.querySelectorAll(\".igv-column\");for(let e=0;e{e.preventDefault(),e.stopPropagation(),this.track.selected=e.target.checked,this.setDragHandleSelectionState(e.target.checked),this.browser.overlayTrackButton.setVisibility(af(this.browser))})),this.enableTrackSelection(!1)}return n}resizeAxisCanvas(e,t){this.axis.style.width=`${e}px`,this.axis.style.height=`${t}px`,\"function\"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${e}px`,this.axisCanvas.style.height=`${t}px`)}renderSVGContext(e,{deltaX:t,deltaY:i}){!function(e,t,i,n,r){if(\"function\"==typeof t.paintAxis){const{y:o,width:a,height:c}=i.getBoundingClientRect(),l=`${(t.name||t.id).replace(/\\W/g,\"\")}_axis_guid_${s()}`;e.saveWithTranslationAndClipRect(l,n,o+r,a,c,0),t.paintAxis(e,a,c),e.restore()}}(e,this.track,this.axisCanvas,t,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:n+t,deltaY:r+i};for(let t of this.viewports){t.renderSVGContext(e,o);const{width:i}=t.$viewport.get(0).getBoundingClientRect();o.deltaX+=i}if(!0===this.browser.sampleInfo.isInitialized()&&!0===this.browser.sampleInfoControl.showSampleInfo){this.sampleInfoViewport.renderSVGContext(e,o);const{width:t}=this.sampleInfoViewport.viewport.getBoundingClientRect();o.deltaX+=t}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(e,o)}presentColorPicker(e){if(!1===lf.has(this.track.type)){const t=[],i=this.track.color||this.track.defaultColor;Mt(i)&&t.push(i),this.track.altColor&&Mt(this.track.altColor)&&t.push(this.track.altColor);let n=t.map((e=>e.startsWith(\"#\")?e:e.startsWith(\"rgb(\")?_s.rgbToHex(e):_s.colorNameToHex(e))),r={color:e=>{this.track.color=io(e),this.repaintViews()},altColor:e=>{this.track.altColor=io(e),this.repaintViews()}};const s=this.browser.getSelectedTrackViews();s.length>0&&new Set(s).has(this)?(r={color:e=>{for(let t of s)t.track.color=e,t.repaintViews()}},this.browser.genericColorPicker.configure(n,r)):this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(e),this.browser.genericColorPicker.show()}}setTrackHeight(e,t){t||(this.track.minHeight&&(e=Math.max(this.track.minHeight,e)),this.track.maxHeight&&(e=Math.min(this.track.maxHeight,e))),this.track.height=e,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),\"function\"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:t}of this.viewports)t.height(e);if(this.sampleInfoViewport.setHeight(e),this.sampleNameViewport.viewport.style.height=`${e}px`,\"function\"!=typeof this.track.computePixelHeight)for(let t of this.viewports)t.setContentHeight(e);this.repaintViews(),this.updateScrollbar(),this.dragHandle.style.height=`${e}px`,this.gearContainer.style.height=`${e}px`}updateScrollbar(){const e=this.viewports[0].$viewport.height();if(this.outerScroll.style.height=`${e}px`,!1===cf.has(this.track.type)){const t=this.maxViewportContentHeight(),i=Math.round(e/t*e);t>e?(this.innerScroll.style.display=\"block\",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display=\"none\"}}moveScroller(e){const t=Bt(this.innerScroll).position().top+e,i=Math.min(Math.max(0,t),this.outerScroll.clientHeight-this.innerScroll.clientHeight);Bt(this.innerScroll).css(\"top\",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let e of this.viewports)e.setTop(r);this.sampleInfoViewport.setTop(r),this.sampleNameViewport.trackScrollDelta=e,this.sampleNameViewport.setTop(r)}isLoading(){for(let e of this.viewports)if(e.isLoading())return!0}repaintViews(){for(let e of this.viewports)e.isVisible()&&e.repaint();\"function\"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSampleInfo(),this.repaintSamples()}repaintSampleInfo(){this.sampleInfoViewport.repaint()}repaintSamples(){if(\"function\"==typeof this.track.getSamples){const e=this.track.getSamples();e.names&&e.names.length>0&&this.sampleNameViewport.repaint(e)}}setTrackLabelName(e){this.viewports.forEach((t=>t.setTrackLabel(e)))}resize(e){for(let t of this.viewports)t.setWidth(e)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const e=this.viewports.filter((e=>e.isVisible()));if(e.forEach((e=>e.shift())),this.browser.dragObject)return;const t=e.filter((e=>e.needsRepaint())).filter((e=>e.checkZoomIn())),i=e.filter((e=>e.checkZoomIn())).filter((e=>e.needsReload()));for(let e of i)await e.loadFeatures();if(this.disposed)return;if(this.track&&\"function\"==typeof this.track.variantRowCount&&i.length>0){let e=0;for(let t of this.viewports)t.featureCache&&t.featureCache.features&&(e=Math.max(e,t.featureCache.features.reduce(((e,t)=>Math.max(e,t.row||0)),0)));if(this.track.nVariantRows!==e+1){this.track.variantRowCount(e+1);for(let e of this.viewports)e.checkContentHeight()}}let n;if(\"merged\"===this.track.type)n=this.track.updateScales(e);else if(this.track.autoscale){let t=[];for(let i of e){const e=i.referenceFrame,n=e.start,r=n+e.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(n,r);if(t.push({value:e}),\"function\"==typeof i.featureCache.features.getMin){const e=i.featureCache.features.getMin(n,r);t.push({value:e})}}else{const e=to(i.featureCache.features,n,r);for(let i of e)t.push(i)}}\"function\"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(t):this.track.dataRange=qa(t)}const r=this.track.autoscale||this.track.autoscaleGroup||\"ruler\"===this.track.type||n||this.track.groupBy;for(let i of e)t.includes(i)?i.repaint():r&&i.refresh();this.adjustTrackHeight(),this.repaintSampleInfo(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let e of this.viewports)e.clearCache()}updateRulerViewportLabels(){const e=this.browser.calculateViewportWidth(this.viewports.length);for(let t of this.viewports)\"ruler\"===this.track.type&&(this.viewports.length>1?t.presentLocusLabel(e):t.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let e=[];const t=this.viewports.filter((e=>e.isVisible()));for(let i of t){const t=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+t.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(r,o);e.push({value:t})}else{const t=\"function\"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):to(i.featureCache.features,r,o);e=e.concat(t)}}return e}checkContentHeight(){for(let e of this.viewports)e.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var e=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(e,!1):this.track.paintAxis&&this.paintAxis(),!1===cf.has(this.track.type)){const t=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-e);if(t{if(!t.isVisible())return!1;if(t.checkZoomIn()){const i=t.referenceFrame,n=t.referenceFrame.chr,r=i.start,s=r+i.toBP(Bt(t.contentDiv).width()),o=i.bpPerPixel;return e||!t.tile||t.tile.invalidate||!t.tile.containsRange(n,r,s,o)}return!1}))}createTrackScrollbar(t){const i=e();if(t.columnContainer.querySelector(\".igv-scrollbar-column\").appendChild(i),i.style.height=`${this.track.height}px`,this.outerScroll=i,!1===cf.has(this.track.type)){const n=e();i.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){\"sequence\"!==this.track.type&&!0===mo.has(this.track.type)?this.dragHandle=e({class:\"igv-track-drag-shim\"}):(this.dragHandle=e({class:\"igv-track-drag-handle\"}),this.dragHandle.classList.add(\"igv-track-drag-handle-color\")),t.columnContainer.querySelector(\".igv-track-drag-column\").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){if(this.gearContainer=e(),t.columnContainer.querySelector(\".igv-gear-menu-column\").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu);else{function i(e){if(e.preventDefault(),e.stopPropagation(),\"none\"===this.trackGearPopup.popover.style.display){for(const e of t.trackViews.filter((e=>e!==this&&void 0!==e.trackGearPopup)))e.trackGearPopup.popover.style.display=\"none\";this.trackGearPopup.presentMenuList(this,t.menuUtils.trackMenuItemList(this))}else this.trackGearPopup.popover.style.display=\"none\"}this.gear=e(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(l(\"cog\")),this.trackGearPopup=new Xu(this.gear),this.boundTrackGearClickHandler=i.bind(this),this.gear.addEventListener(\"click\",this.boundTrackGearClickHandler)}}addTrackScrollMouseHandlers(e){this.boundTrackScrollMouseDownHandler=function(t){t.stopPropagation();const{y:i}=r(t);Bt(this.innerScroll).data(\"yDown\",i.toString()),this.boundColumnContainerMouseMoveHandler=function(e){e.stopPropagation();const{y:t}=r(e);this.moveScroller(t-parseInt(Bt(this.innerScroll).data(\"yDown\"))),Bt(this.innerScroll).data(\"yDown\",t.toString())}.bind(this),e.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(t){e.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),e.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),e.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===cf.has(this.track.type)&&(this.innerScroll.removeEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.browser.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.browser.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.browser.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseMoveHandler))}addTrackDragMouseHandlers(e){if(\"sequence\"===this.track.type||!1===mo.has(this.track.type)){let t;function i(i){i.preventDefault(),t=i.target,!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.add(\"igv-track-drag-handle-hover-color\")),e.startTrackDrag(this)}function n(i){e.endTrackDrag(),t&&i.target!==t&&!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-color\")),t=void 0}function r(i){i.preventDefault(),void 0===t&&!1===this.track.selected&&(i.target.classList.remove(\"igv-track-drag-handle-color\"),i.target.classList.add(\"igv-track-drag-handle-hover-color\")),e.updateTrackDrag(this)}function s(e){e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))}this.boundTrackDragMouseDownHandler=i.bind(this),this.dragHandle.addEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=n.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=r.bind(this),this.dragHandle.addEventListener(\"mouseenter\",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener(\"mouseout\",(e=>{e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){\"ideogram\"===this.track.type||\"ruler\"===this.track.type||(this.dragHandle.removeEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),document.removeEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener(\"mouseup\",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler))}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener(\"click\",this.boundTrackGearClickHandler)}removeDOMFromColumnContainer(){this.axis.remove(),this.removeViewportsFromColumnContainer(),this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}removeViewportsFromColumnContainer(){for(let e of this.viewports)e.$viewport.remove()}dispose(){this.axis.remove();for(let e of this.viewports)e.dispose();this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),\"function\"==typeof this.track.dispose&&this.track.dispose();for(let e of Object.keys(this))this[e]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if(\"function\"==typeof this.track.paintAxis){const{width:e,height:t}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*t,this.axisCanvas.width=i*e;const n=this.axisCanvas.getContext(\"2d\");if(n.scale(i,i),this.track.autoscaleGroup){if(void 0===wo[this.track.autoscaleGroup]){const e=so.Dark2,t=Math.floor(Math.random()*so.Dark2.length);wo[this.track.autoscaleGroup]=e[t]}const i=_s.addAlpha(wo[this.track.autoscaleGroup],.75);this.track.paintAxis(n,e,t,i)}else this.track.paintAxis(n,e,t,void 0)}}maxViewportContentHeight(){return Math.max(...this.viewports.map((e=>e.getContentHeight())))}enableTrackSelection(e){const t=this.trackSelectionContainer;if(t&&!mo.has(this.track.type))if(!1!==e)t.style.display=\"grid\";else{this.track.selected=!1;t.querySelector(\"[name=track-select]\").checked=this.track.selected,this.dragHandle&&this.setDragHandleSelectionState(!1),t.style.display=\"none\"}}setDragHandleSelectionState(e){const t=this.dragHandle;e?(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-selected-color\")):(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.remove(\"igv-track-drag-handle-selected-color\"),t.classList.add(\"igv-track-drag-handle-color\"))}}function df(e){this.thresholds=e.thresholds,this.colors=e.colors}function uf(e){this.scale=e,this.lowColor=\"rgb(\"+e.lowR+\",\"+e.lowG+\",\"+e.lowB+\")\",this.highColor=\"rgb(\"+e.highR+\",\"+e.highG+\",\"+e.highB+\")\",this.diff=e.high-e.low}df.prototype.getColor=function(e){for(let t of this.thresholds)if(e=i.high?this.highColor:(t=(e-i.low)/this.diff,\"rgb(\"+Math.floor(i.lowR+t*(i.highR-i.lowR))+\",\"+Math.floor(i.lowG+t*(i.highG-i.lowG))+\",\"+Math.floor(i.lowB+t*(i.highB-i.lowB))+\")\")};class ff{constructor(e){this.color=e}getColor(){return this.color}}const pf={threshold:2e3,r:0,g:0,b:255};class gf{constructor(e){e=e||pf,this.threshold=e.threshold,this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[],this.nbins=2e3,this.binsize=this.threshold/this.nbins}setThreshold(e){this.threshold=e,this.cache=[],this.binsize=this.threshold/this.nbins}getThreshold(){return this.threshold}setColorComponents(e){this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[]}getColorComponents(){return{r:this.r,g:this.g,b:this.b}}equals(e){return JSON.stringify(this)===JSON.stringify(e)}getColor(e){const t=Math.floor(Math.min(this.threshold,e)/this.binsize);if(void 0===this.cache[t]){const i=(ys.clamp(e,0,this.threshold)-0)/(this.threshold-0);this.cache[t]=`rgba(${this.r},${this.g},${this.b}, ${i})`}return this.cache[t]}stringify(){return this.threshold+\",\"+this.r+\",\"+this.g+\",\"+this.b}static parse(e){var t,i;return e.startsWith(\"R:\")?(t=e.substring(2).split(\":\"),(i=new RatioColorScale(Number.parseFloat(t[0]))).positiveScale=n(t[1]),i.negativeScale=n(t[2]),i):n(e);function n(e){var t,i;return t={threshold:(i=e.split(\",\"))[0],r:i[1],g:i[2],b:i[3]},new gf(t)}}}class mf{constructor(e){this.config=e,this.url=e.path||e.url}async read(e,t){const i={start:e,size:t};return Qs.loadArrayBuffer(this.url,{range:i})}}class wf{constructor(e){this.file=e}async read(e,t){const i=this.file;return void 0!==e?i.slice(e,e+t).arrayBuffer():i.arrayBuffer()}}class bf{constructor(e,t){this.file=e,this.rateLimiter=t}async read(e,t){const i=this.file,n=this.rateLimiter;return new Promise((function(r,s){n.limiter((async function(i){try{const n=await i.read(e,t);r(n)}catch(e){s(e)}}))(i)}))}}class Ff{constructor(e){this.file=e.file,this.size=e.size||64e3,this.position=0,this.bufferStart=0,this.bufferLength=0,this.buffer=void 0}async read(e,t){const i=e,n=e+t,r=this.bufferStart,s=this.bufferStart+this.bufferLength;if(t>this.size)return this.buffer=void 0,this.bufferStart=0,this.bufferLength=0,this.file.read(e,t);if(i>=r&&n<=s){const e=i-r,n=e+t;return this.buffer.slice(e,n)}if(ir){const n=r-i,s=await this.file.read(e,n),o=t-n;if(o>0){const e=this.buffer.slice(0,o);return vf(s,e)}return s}if(!(is))return this.buffer=await this.file.read(e,this.size),this.bufferStart=e,this.bufferLength=this.buffer.byteLength,this.buffer.slice(0,t);{const e=s-i,n=this.bufferLength-e,r=this.buffer.slice(n,this.bufferLength),o=t-e;if(!(o>0))return r;try{this.buffer=await this.file.read(s,this.size),this.bufferStart=s,this.bufferLength=this.buffer.byteLength;const e=this.buffer.slice(0,o);return vf(r,e)}catch(e){if(e.code&&416===e.code)return r;throw e}}}}var vf=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer};const yf=function(e,t){this.littleEndian=void 0===t||t,this.position=0,this.view=e,this.length=e.byteLength};function Af(e,t){this.block=e,this.offset=t}yf.prototype.available=function(){return this.length-this.position},yf.prototype.remLength=function(){return this.length-this.position},yf.prototype.hasNext=function(){return this.position=0;i--)t=256*t+e[i];else for(i=0;i0&&(n+=String.fromCharCode(i));return n},yf.prototype.getFixedLengthTrimmedString=function(e){var t,i,n=\"\";for(t=0;t32&&(n+=String.fromCharCode(i));return n},yf.prototype.getFloat=function(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e},yf.prototype.getDouble=function(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e},yf.prototype.skip=function(e){return this.position+=e,this.position},yf.prototype.getVPointer=function(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Af(i,t)},Af.prototype.isLessThan=function(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset},Af.prototype.print=function(){return this.block+\":\"+this.offset};class Cf{constructor(e,t){this.chr1=e,this.chr2=t}getKey(){return this.chr1.name+\"_\"+this.chr2.name+\"_\"+this.zoom.unit+\"_\"+this.zoom.binSize}getBlockNumbers(e,t,i){if(e.chr==this.chr2&&t.chr===this.chr1){const i=e;e=t,t=i}const n=this.chr1===this.chr2,r=this.zoom.binSize,s=this.blockBinCount,o=this.blockColumnCount;return i<9||!n?function(){const i=e.start/r,a=e.end/r,c=t.start/r,l=t.end/r,h=Math.floor(i/s),d=Math.floor((a-1)/s),u=Math.floor(c/s),f=Math.floor((l-1)/s),p=[];for(let e=u;e<=f;e++)for(let t=h;t<=d;t++){let i;i=n&&e0;){const e=t.getInt(),i=t.getLong(),n=t.getInt();this.blockIndex[e]={filePosition:i,size:n}}}getBlockIndexEntry(e){return this.blockIndex[e]}}class xf{constructor(e,t,i){this.chr1=e,this.chr2=t,this.bpZoomData=[],this.fragZoomData=[];for(let e of i)\"BP\"===e.zoom.unit?this.bpZoomData.push(e):this.fragZoomData.push(e)}findZoomForResolution(e,t){const i=\"FRAG\"===t?this.fragZoomData:this.bpZoomData;for(let t=1;tt){const i=e;e=t,t=i}return`${e}_${t}`}static parseMatrix(e,t){const i=new yf(new DataView(e)),n=i.getInt(),r=i.getInt(),s=t[n],o=t[r];let a=i.getInt();const c=[];for(;a-- >0;){const e=Cf.parseMatrixZoomData(s,o,i);c.push(e)}return new xf(n,r,c)}}class kf{constructor(e,t,i){this.bin1=e,this.bin2=t,this.counts=i}getKey(){return this.bin1+\"_\"+this.bin2}}class If{constructor(e=10){this.max=e,this.map=new Map}get(e){let t=this.map.get(e);return t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size===this.max&&this.map.delete(this.first()),this.map.set(e,t)}has(e){return this.map.has(e)}clear(){this.map.clear()}first(){return this.map.keys().next().value}}class Sf{constructor(e,t,i,n){this.file=e,this.filePosition=t,this.nValues=i,this.dataType=n,this.cache=void 0}async getValues(e,t){if(!this.cache||ethis.cache.end){const i=Math.max(0,e-1e3),n=Math.min(this.nValues,t+1e3),r=this.filePosition+i*this.dataType,s=n-i,o=s*this.dataType,a=await this.file.read(r,o);if(!a)return;const c=new yf(new DataView(a)),l=[];for(let e=0;e=0||t.indexOf(\"www.googleapis.com/drive\")>0?this.file=new bf(i,Bf):this.file=i}}var t}async init(){this.initialized||(await this.readHeaderAndFooter(),this.initialized=!0)}async getVersion(){if(void 0===this.version){const e=await this.file.read(0,128);if(!e)return;const t=new yf(new DataView(e));return this.magic=t.getString(),this.version=t.getInt(),this.version}return this.version}async getMetaData(){return await this.init(),this.meta}async readHeaderAndFooter(){let e=await this.file.read(0,16);if(!e||0===e.byteLength)throw Error(\"File content is empty\");let t=new yf(new DataView(e));if(this.magic=t.getString(),this.version=t.getInt(),this.version<5)throw Error(\"Unsupported hic version: \"+this.version);this.footerPosition=t.getLong(),await this.readFooter();const i=Object.values(this.masterIndex).reduce(((e,t)=>Math.min(e,t.start)),Number.MAX_VALUE)-16;e=await this.file.read(16,i),t=new yf(new DataView(e)),this.genomeId=t.getString(),this.version>=9&&(this.normVectorIndexPosition=t.getLong(),this.normVectorIndexSize=t.getLong()),this.attributes={};let n=t.getInt();for(;n-- >0;)this.attributes[t.getString()]=t.getString();this.chromosomes=[],this.chromosomeIndexMap={};let r=t.getInt(),s=0;for(;r-- >0;){const e={index:s,name:t.getString(),size:this.version<9?t.getInt():t.getLong()};\"all\"===e.name.toLowerCase()&&(this.wholeGenomeChromosome=e,this.wholeGenomeResolution=Math.round(2*e.size)),this.chromosomes.push(e),this.chromosomeIndexMap[e.name]=e.index,s++}this.bpResolutions=[];let o=t.getInt();for(;o-- >0;)this.bpResolutions.push(t.getInt());if(this.loadFragData){this.fragResolutions=[];let e=t.getInt();if(e>0)for(;e-- >0;)this.fragResolutions.push(t.getInt())}this.chrAliasTable={};for(let e of Object.keys(this.chromosomeIndexMap))e.startsWith(\"chr\")?this.chrAliasTable[e.substr(3)]=e:\"MT\"===e?this.chrAliasTable.chrM=e:this.chrAliasTable[\"chr\"+e]=e;this.meta={version:this.version,genome:this.genomeId,chromosomes:this.chromosomes,resolutions:this.bpResolutions}}async readFooter(){const e=this.version<9?8:12;let t=await this.file.read(this.footerPosition,e);if(!t)return null;let i=new yf(new DataView(t));const n=this.version<9?i.getInt():i.getLong();let r=i.getInt();const s=196*r;for(t=await this.file.read(this.footerPosition+e,Math.min(s,n)),i=new yf(new DataView(t)),this.masterIndex={};r-- >0;){const e=i.getString(),t=i.getLong(),n=i.getInt();this.masterIndex[e]={start:t,size:n}}if(this.expectedValueVectors={},this.version>5){const e=this.version<9?4:8;this.normExpectedValueVectorsPosition=this.footerPosition+e+n}return this}async printIndexStats(){let e,t=0,i=0;await await this.init();for(let n of Object.keys(this.masterIndex)){const r=this.masterIndex[n];t+=r.size,r.size>i&&(i=r.size,e=n)}console.log(`${i} ${e} ${this.config.url}`)}async getMatrix(e,t){const i=xf.getKey(e,t);if(this.matrixCache.has(i))return this.matrixCache.get(i);{const n=await this.readMatrix(e,t);return this.matrixCache.set(i,n),n}}async readMatrix(e,t){if(await this.init(),e>t){const i=e;e=t,t=i}const i=xf.getKey(e,t),n=this.masterIndex[i];if(!n)return;const r=await this.file.read(n.start,n.size);return r?xf.parseMatrix(r,this.chromosomes):void 0}async getContactRecords(e,t,i,n,r,s=!1){await this.init();const o=this.chromosomeIndexMap[this.getFileChrName(t.chr)],a=this.chromosomeIndexMap[this.getFileChrName(i.chr)];if(o>a||o===a&&t.start>=i.end){const e=t;t=i,i=e}const c=await this.getBlocks(t,i,n,r);if(!c||0===c.length)return[];const l=[],h=t.start/r,d=t.end/r,u=i.start/r,f=i.end/r,p=Math.floor(h),g=Math.ceil(d),m=Math.floor(u),w=Math.ceil(f);for(let o of c)if(o){let a,c,b=e&&\"NONE\"!==e;const F=this.getFileChrName(t.chr),v=this.getFileChrName(i.chr);if(b){const t=await this.getNormalizationVector(e,F,n,r),i=F===v?t:await this.getNormalizationVector(e,v,n,r);t&&i?(a=await t.getValues(p,g),c=await i.getValues(m,w)):b=!1}for(let e of o.records)if(s||e.bin1>=h&&e.bin1=u&&e.bin210&&(this.percentile95=Lf(o.records,95))}return l}async getBlocks(e,t,i,n){const r=(e,t)=>`${t.getKey()}_${e}`;await this.init();const s=this.getFileChrName(e.chr),o=this.getFileChrName(t.chr),a=this.chromosomeIndexMap[s],c=this.chromosomeIndexMap[o];if(void 0===a)return console.log(\"No chromosome named: \"+e.chr),[];if(void 0===c)return console.log(\"No chromosome named: \"+t.chr),[];const l=await this.getMatrix(a,c);if(!l)return console.log(\"No matrix for \"+e.chr+\"-\"+t.chr),[];const h=l.getZoomData(n,i);if(!h){let i=`No data avalailble for resolution: ${n} for map ${e.chr}-${t.chr}`;throw new Error(i)}const d=h.getBlockNumbers(e,t,this.version),u=[],f=[];for(let e of d){const t=r(e,h);this.blockCache.has(n,t)?u.push(this.blockCache.get(n,t)):f.push(e)}const p=f.map((e=>this.readBlock(e,h))),g=await Promise.all(p);for(let e of g)e&&this.blockCache.set(n,r(e.blockNumber,h),e);return u.concat(g)}async readBlock(e,t){const i=await t.blockIndex.getBlockIndexEntry(e);if(i){let n=await this.file.read(i.filePosition,i.size);if(!n)return;n=new ls(new Uint8Array(n)).buffer;const r=new yf(new DataView(n)),s=r.getInt(),o=[];if(this.version<7)for(let e=0;e0;)this.parseNormVectorEntry(i);return this.normVectorIndex}async readNormExpectedValuesAndNormVectorIndex(){if(await this.init(),void 0===this.normExpectedValueVectorsPosition)return;const e=await this.skipExpectedValues(this.normExpectedValueVectorsPosition);let t=4,i=await this.file.read(e,4);if(0===i.byteLength)return;const n=new yf(new DataView(i)).getInt(),r={start:e+t,size:30*n};i=await this.file.read(r.start,r.size),this.normalizedExpectedValueVectors={},this.normVectorIndex={},await async function i(n,r){const s=new yf(new DataView(r));for(;n-- >0;){if(s.available()<100){n++,t+=s.position;const r=Math.max(1e3,30*n),o={start:e+t,size:r},a=await this.file.read(o.start,o.size);return i.call(this,n,a)}this.parseNormVectorEntry(s)}t+=s.position}.call(this,n,i),this.config.nvi=e.toString()+\",\"+t}async skipExpectedValues(e){const t=this.version,i=new Ff({file:this.file,size:256e3}),n={start:e,size:4},r=await i.read(n.start,n.size),s=new yf(new DataView(r)).getInt();return 0===s?e+4:async function e(n,r){let s={start:n,size:500},o=0,a=n,c=await i.read(s.start,s.size),l=new yf(new DataView(c));l.getString(),l.getString(),l.getInt();const h=t<9?l.getInt():l.getLong();o+=l.position+h*(t<9?8:4),s={start:n+o,size:4},c=await i.read(s.start,s.size),l=new yf(new DataView(c));const d=l.getInt();return o+=4+d*(4+(t<9?8:4)),r--,0===r?a+o:e(a+o,r)}(e+4,s)}getZoomIndexForBinSize(e,t){let i;if(\"BP\"===(t=t||\"BP\"))i=this.bpResolutions;else{if(\"FRAG\"!==t)throw new Error(\"Invalid unit: \"+t);i=this.fragResolutions}for(let t=0;te.counts));i.sort((function(e,t){return e-t}));return i[Math.floor(t/100*e.length)]}class zf{constructor(e,t){this.config=e,this.genome=t,this.hicFile=e._hicFile?e._hicFile:new Mf(e),e._hicFile=void 0}async getHeader(){return await this.hicFile.init(),this.hicFile}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){this.hicFile.initialized||await this.hicFile.init();const s=this.hicFile.bpResolutions,o=s[s.length-1];return(await this.hicFile.getContactRecords(void 0,{chr:e,start:t,end:i},{chr:\"celltype\",start:0,end:1e8},\"BP\",o)).map((t=>{const i=t.bin1*o;return{chr:e,start:i,end:i+o,value:t.counts,sample:t.bin2.toString()}}))}supportsWholeGenome(){return!1}}function Hf(e,t){const i=new Set(e.attributeNames),n=t[0];if(void 0===e.getAttributes(n))return!1;{const t=Object.keys(e.getAttributes(n));for(const e of t)if(!1===i.has(e))return!1}return!0}class Pf extends Hl{#y=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),this.type=e.type||\"seg\",\"maf\"===this.type&&(this.type=\"mut\"),this.isLog=e.isLog,this.displayMode=e.displayMode||\"EXPANDED\",this.height=e.height||300,this.maxHeight=e.maxHeight||500,this.squishedRowHeight=e.sampleSquishHeight||e.squishedRowHeight||2,this.expandedRowHeight=e.sampleExpandHeight||e.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,this.sampleKeys=[],e.samples){for(let t of e.samples)this.sampleKeys.push(t);this.explicitSamples=!0}if(e.color)this.color=e.color;else if(e.colorTable)this.colorTable=new ao(e.colorTable);else switch(this.type){case\"mut\":this.colorTable=new ao(qf);break;case\"shoebox\":e.colorScale&&(this.sbColorScale=gf.parse(e.colorScale));break;default:this.posColorScale=new uf(e.posColorScale||Of),this.negColorScale=new uf(e.negColorScale||Uf)}const t=Object.assign({},this.config);t.maxWGCount=t.maxWGCount||Number.MAX_SAFE_INTEGER,\"shoebox\"===this.type?(this.featureSource=new zf(t,this.browser.genome),this.height=e.height||500,this.maxHeight=e.maxHeight||800,this.isLog=!1,this.squishedRowHeight=e.squishedRowHeight||1,this.displayMode=e.displayMode||\"SQUISHED\",this.visibilityWindow=void 0===e.visibilityWindow?1e6:e.visibilityWindow):this.featureSource=Ad(t,this.browser.genome),this.initialSort=e.sort}async postInit(){\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const e=[];if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const n of this.browser.sampleInfo.attributeNames){if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[n]}))){const r=Bt(\"
\");function s(){const e=this.#y.get(n)||1;this.sortByAttribute(n,e),this.#y.set(n,-1*e),this.config.sort={option:\"ATTRIBUTE\",attribute:n,direction:1===e?\"ASC\":\"DESC\"}}r.html(`  ${n.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:r,click:s})}}}const t={SQUISHED:\"Squish\",EXPANDED:\"Expand\",FILL:\"Fill\"};if(\"shoebox\"===this.type&&this.sbColorScale){function o(e){this.browser.inputDialog.present({label:\"Color Scale Threshold\",value:this.sbColorScale.threshold,callback:()=>{const e=Number(this.browser.inputDialog.value,10);e&&(this.sbColorScale.setThreshold(e),this.trackView.repaintViews())}},e)}e.push(\"
\"),e.push({object:Bt(\"
Set color scale threshold
\"),dialog:o})}e.push(\"
\"),e.push(\"DisplayMode:\");const i=\"seg\"===this.type||\"shoebox\"===this.type?[\"SQUISHED\",\"EXPANDED\",\"FILL\"]:[\"SQUISHED\",\"EXPANDED\"];for(let a of i){const c=Dl(t[a],a===this.displayMode);e.push({object:Bt(c),click:function(){this.displayMode=a,this.config.displayMode=a,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return e}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.sampleHeight,yOffset:0}}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:t,end:i});if(this.updateSampleKeys(n),this.initialSort){const e=this.initialSort;if(void 0===e.option||\"VALUE\"===e.option.toUpperCase())this.sortByValue(e,n);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"DESC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return n}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){if(this.checkForLog(r),\"shoebox\"===this.type&&!this.sbColorScale){const e=this.featureSource.hicFile.percentile95||2e3;this.sbColorScale=new gf({threshold:e,r:0,g:0,b:255})}const a={};let c;switch(this.sampleKeys.forEach((function(e,t){a[e]=t})),this.displayMode){case\"FILL\":this.sampleHeight=n/this.sampleKeys.length,c=0;break;case\"SQUISHED\":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let e of r)e.pixelRect=void 0;const h=t+n,d=o+i*s+1,u=s;this.sampleYStart=void 0;for(let i of r){if(i.endd)continue;const n=i.sampleKey||i.sample;i.row=a[n];const r=i.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=r);if(r+lh)continue;const s=Math.max(i.start,o);let f=Math.round((s-o)/u);const p=Math.min(i.end,d),g=Math.round((p-o)/u);let m,w,b=Math.max(1,g-f);if(this.color?m=\"function\"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),\"mut\"===this.type)w=l-2*c,b<3&&(b=3,f-=1);else if(\"shoebox\"===this.type){m=this.sbColorScale.getColor(i.value);let e=l;if(l<.25){const t=.1+2*Math.abs(t.value);e=Math.min(1,t*l)}w=e-2*c}else{let e=i.value;this.isLog||(e=ys.log2(e/2)),m=e<-.1?this.negColorScale.getColor(e):e>.1?this.posColorScale.getColor(e):\"white\";let t=l;if(l<.25){const i=.1+2*Math.abs(e);t=Math.min(1,i*l)}w=t-2*c}i.pixelRect={x:f,y:r,w:b,h:w},e.fillStyle=m,e.fillRect(f,r,b,w)}}}checkForLog(e){if(void 0===this.isLog){this.isLog=!1;for(let t of e)if(t.value<0)return void(this.isLog=!0)}}computePixelHeight(e){if(!e)return 0;const t=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(e),this.sampleKeys.length*t}async sortByValue(e,t){const i=e.chr;let n,r;if(e.position?(n=e.position-1,r=n+1):(n=e.start,r=e.end),t||(t=await this.featureSource.getFeatures({chr:i,start:n,end:r})),!t)return;this.updateSampleKeys(t);const s={},o=\"ASC\"===e.direction?1:-1,a=()=>{const e=r-n+1;for(let i of t){if(i.endr)break;const t=Math.max(n,i.start),o=(Math.min(r,i.end)-t)/e,a=i.sampleKey||i.sample,c=s[a]||0;s[a]=c+o*i.value}this.sampleKeys.sort((function(e,t){let i=s[e],n=s[t];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))},c=()=>{for(let e of t){if(e.endr)break;const t=e.sampleKey||e.sample;(!s.hasOwnProperty(t)||e.value.localeCompare(s[t])>0)&&(s[t]=e.value)}this.sampleKeys.sort((function(e,t){let i=s[e]||\"\",n=s[t]||\"\";return o*i.localeCompare(n)}))};\"mut\"===this.type?c():a(),this.trackView.repaintViews()}sortByAttribute(e,t){this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(e){const t=e.genomicLocation,i=t=>{const i=e.viewport.cachedFeatures;this.sortByValue(t,i)},n=e.referenceFrame.toBP(2.5);return[\"DESC\",\"ASC\"].map((r=>{const s=\"DESC\"===r?\"descending\":\"ascending\";return{label:\"seg\"===this.type||\"shoebox\"===this.type?`Sort by value (${s})`:`Sort by type (${s})`,click:()=>{const s={option:\"VALUE\",direction:r,chr:e.referenceFrame.chr,start:Math.floor(t-n),end:Math.floor(t+n)};i(s),this.config.sort=s}}}))}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(e){if(this.explicitSamples)return;const t=new Set(this.sampleKeys);for(let i of e){const e=i.sampleKey||i.sample;t.has(e)||(this.sampleKeys.push(e),t.add(e))}}}const Of={low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0},Uf={low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255},qf={indel:\"rgb(0,200,0)\",\"targeted region\":\"rgb(236,155,43)\",truncating:\"rgb(\\t150,0,0)\",\"non-coding transcript\":\"rgb(0,0,150)\",synonymous:\"rgb(109,165,95)\",silent:\"rgb(109,135,80)\",missense_mutation:\"rgb(72,130,187)\",missense:\"rgb(72,130,187)\",\"splice site\":\"rgb(143,83,155)\",splice_region:\"rgb(143,83,155)\",nonsense:\"rgb(216, 57,81)\",nonsense_mutation:\"rgb(216, 57,81)\",frame_shift_del:\"rgb(226,135,65)\",frame_shift_ins:\"rgb(226,135,65)\",in_frame_del:\"rgb(247,235,94)\",in_frame_ins:\"rgb(247,235,94)\",\"*other*\":\"rgb(159,91,50)\"};class Qf{constructor(e){this.paired=!0,this.firstAlignment=e,this.chr=e.chr,this.readName=e.readName,e.startt.start?this.connectingEnd=e.start:this.connectingStart=e.start+e.lengthOnRef,this.start=Math.min(t.start,e.start),this.end=Math.max(t.start+t.lengthOnRef,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(t.scStart,e.scStart);const i=Math.max(t.scStart+t.scLengthOnRef,e.scStart+e.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}alignmentContaining(e,t){return this.firstAlignment.containsLocation(e,t)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(e,t)?this.secondAlignment:void 0}popupData(e){let t=this.firstAlignment.popupData(e);return this.secondAlignment&&(t.push(\"-------------------------------\"),t=t.concat(this.secondAlignment.popupData(e))),t}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}get firstOfPairStrand(){return this.firstAlignment.firstOfPairStrand}get pairOrientation(){return this.firstAlignment.pairOrientation}hasTag(e){return this.firstAlignment.hasTag(e)||this.secondAlignment&&this.secondAlignment.hasTag(e)}getGroupValue({option:e,tag:t}){switch(e){case\"strand\":return this.isNegativeStrand()?\"-\":\"+\";case\"FIRST_IN_PAIR_STRAND\":return this.isPaired()?this.isFirstOfPair()?this.isNegativeStrand()?\"-\":\"+\":this.isSecondOfPair()?this.isNegativeStrand()?\"+\":\"-\":void 0:void 0;case\"START\":return this.start;case\"INSERT_SIZE\":return this.fragmentLength;case\"MATE_CHR\":return this.mate?this.mate.chr:void 0;case\"MQ\":return this.mq;case\"ALIGNED_READ_LENGTH\":return this.lengthOnRef;case\"TAG\":return this.tags()[t];case\"PHASE\":return this.tags().HP;case\"READ_ORDER\":return this.isPaired()&&this.isFirstOfPair()?\"FIRST\":this.isPaired()&&this.isSecondOfPair()?\"SECOND\":\"\";default:return}}}class Vf{static instances=new Map;static getKey(e,t,i){const n=\"\"+e+t+i;return Vf.instances.has(n)||Vf.instances.set(n,new Vf(e,t,i)),Vf.instances.get(n)}constructor(e,t,i){this.base=e,this.strand=t,this.modification=i,this.canonicalBase=\"+\"===this.strand?this.base:oc(this.base)}getCanonicalBase(){}toString(){return\"\"+this.base+this.strand+this.modification}static compare(e,t){const i=e.modification,n=t.modification;return i===n?e.strand.charAt(0)-t.strand.charAt(0):jf.has(i)&jf.has(n)?jf.get(i)-jf.get(n):jf.has(i)?1:jf.has(n)?-1:i>n?1:-1}}const jf=new Map([\"NONE_C\",\"NONE_T\",\"NONE_G\",\"NONE_A\",\"m\",\"h\",\"f\",\"c\",\"C\",\"g\",\"e\",\"b\",\"T\",\"U\",\"a\",\"A\",\"o\",\"G\",\"n\",\"N\"].map(((e,t)=>[e,t])));class Wf{constructor(e,t,i,n){this.base=e,this.modification=i,this.strand=t,this.likelihoods=n,this.canonicalBase=\"+\"==this.strand?this.base:oc(this.base),this.key=Vf.getKey(e,t,i)}containsPosition(e){return this.likelihoods.has(e)}is5mC(){return this.modification.equals(\"m\")&&(\"C\"===this.base&&\"+\"===this.strand||\"G\"===this.base&&\"-\"===this.strand)}fullName(){return Gf.get(this.modification)||this.modification}}const Gf=new Map;Gf.set(\"m\",\"5mC\"),Gf.set(\"h\",\"5hmC\"),Gf.set(\"f\",\"5fC\"),Gf.set(\"c\",\"5caC\"),Gf.set(\"g\",\"5hmU\"),Gf.set(\"e\",\"5fU\"),Gf.set(\"b\",\"5caU\"),Gf.set(\"a\",\"6mA\"),Gf.set(\"o\",\"8xoG\"),Gf.set(\"n\",\"Xao\"),Gf.set(\"C\",\"Unknown C\"),Gf.set(\"T\",\"Unknown T\"),Gf.set(\"A\",\"Unknown A\"),Gf.set(\"G\",\"Unknown G\"),Gf.set(\"N\",\"Unknown\");const $f=new Map([[\"m\",\"5mC\"],[\"h\",\"5hmC\"],[\"f\",\"5fC\"],[\"c\",\"5caC\"],[\"g\",\"5hmU\"],[\"e\",\"5fU\"],[\"b\",\"5caU\"],[\"a\",\"6mA\"],[\"o\",\"8xoG\"],[\"n\",\"Xao\"],[\"C\",\"Unknown C\"],[\"T\",\"Unknown T\"],[\"A\",\"Unknown A\"],[\"G\",\"Unknown G\"],[\"N\",\"Unknown\"]]);function Kf(e){return $f.has(e)?$f.get(e):\"Uknown\"}function Yf(e){if(!e)return!1;const t=e.length;if(0==t)return!1;for(let i=0;i\"9\")return!1}return!0}function Xf(e){return e<0?e+256:e}class Zf{allModifications=new Set;simplexModifications=new Set;maxLikelihoods=new Map;nomodLikelihoods=new Map;lastThreshold;incrementCounts(e){if(!e.blocks)return;const t=e.getBaseModificationSets();if(t)for(let i of e.blocks)if(\"S\"!==i.type)for(let e=0;eo&&(s=e.canonicalBase,o=c,n=t)}}if(0!=s){const t=i.start+e,r=Vf.getKey(s,\"+\",\"NONE_\"+s);this.allModifications.add(r);const c=(e,t,i,n)=>{let r=n.get(i);r||(r=new Map,n.set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push(t)};c(t,o,n,this.maxLikelihoods),a>o?c(t,a,r,this.nomodLikelihoods):c(t,o,n,this.nomodLikelihoods)}}}getCount(e,t,i,n){this.lastThreshold=i;const r=255*i,s=n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t);if(!s)return 0;const o=s.get(e);if(o){let e=0;for(let t of o){Xf(t)>=r&&e++}return e}return 0}getLikelihoodSum(e,t,i,n){this.lastThreshold=i;const r=255*i,s=(n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t)).get(e);if(s){let e=0;for(let t of s){const i=Xf(t);i>=r&&(e+=i)}return e}return 0}popupData(e,t){const i=[];i.push(\"Modifications with likelihood > \"+100*this.lastThreshold+\"%\");for(let n of this.maxLikelihoods.keys()){if(this.maxLikelihoods.get(n).has(e)){let r=\"basemod2\"===t;const s=this.getCount(e,n,this.lastThreshold,r);if(s>0){const t=this.getLikelihoodSum(e,n,this.lastThreshold,r)/s*.3921568,o=Kf(n.modification);i.push(o+\" (\"+n.base+n.strand+\"): \"+s+\" @ average likelihood \"+Math.round(t)+\"%\")}}}return i}computeSimplex(){const e=new Set(Array.from(this.allModifications).filter((e=>\"-\"===e.strand)).map((e=>e.modification)));for(let t of this.allModifications)\"+\"!==t.strand||e.has(t.modification)||(this.simplexModifications.add(t.modification),this.simplexModifications.add(\"NONE_\"+t.getCanonicalBase()))}}class Jf{constructor(){this.alignments=[],this.score=void 0}findAlignment(e,t=!1){const i=(e,i)=>i>=e.start&&i=s.start&&e0?h-=e:0===h&&(h=1)}return h}(s,r,e);case\"strand\":return s.strand?1:-1;case\"START\":return s.start;case\"TAG\":return s.tags()[i];case\"READ_NAME\":return s.readName;case\"INSERT_SIZE\":return-Math.abs(s.fragmentLength);case\"GAP_SIZE\":return-s.gapSizeAt(e);case\"MATE_CHR\":return s.mate?s.mate.chr:Number.MAX_VALUE;case\"MQ\":return void 0===s.mq?Number.MAX_VALUE:-s.mq;case\"ALIGNED_READ_LENGTH\":return-s.lengthOnRef;default:return Number.MAX_VALUE}}}var ep={fr:{F1R2:\"LR\",F2R1:\"LR\",F1F2:\"LL\",F2F1:\"LL\",R1R2:\"RR\",R2R1:\"RR\",R1F2:\"RL\",R2F1:\"RL\"},rf:{R1F2:\"LR\",R2F1:\"LR\",R1R2:\"LL\",R2R1:\"LL\",F1F2:\"RR\",F2F1:\"RR\",F1R2:\"RL\",F2R1:\"RL\"},ff:{F2F1:\"LR\",R1R2:\"LR\",F2R1:\"LL\",R1F2:\"LL\",R2F1:\"RR\",F1R2:\"RR\",R2R1:\"RL\",F1F2:\"RL\"}};class tp{#A=[];baseModificationKeys=new Set;constructor(e,t,i,{samplingWindowSize:n,samplingDepth:r,alleleFreqThreshold:s,colorBy:o}){this.alleleFreqThreshold=void 0===s?.2:s,this.samplingWindowSize=n||100,this.samplingDepth=r||1e3,this.chr=e,this.start=Math.floor(t),this.end=Math.ceil(i),this.length=i-t,this.coverageMap=new np(e,t,i,this.alleleFreqThreshold),this.downsampledIntervals=[],o&&o.startsWith(\"basemod\")&&(this.baseModCounts=new Zf),this.alignments=[],this.pairsCache=new Map,this.downsampledReads=new Set,this.currentBucket=new ip(this.start,this.start+this.samplingWindowSize,this),this.hasPairs=!1}pack({viewAsPairs:e,showSoftClips:t,expectedPairOrientation:i,groupBy:n,displayMode:r}){let s=this.allAlignments();s=e?function(e){const t=new Map,i=e.map((e=>{if(ap(e)){let i=t.get(e.readName);return i?(i.setSecondAlignment(e),t.delete(e.readName),i):(i=new Qf(e),t.set(e.readName,i),i)}return e}));return i}(s):function(e){return e.flatMap((e=>e instanceof Qf?[e.firstAlignment,e.secondAlignment].filter(Boolean):[e]))}(s),this.packAlignmentRows(s,t,i,n,r),this.alignments&&delete this.alignments}packAlignmentRows(e,t,i,n,r){this.#A=[];const s=(e,i)=>{e.sort((function(e,i){return t?e.scStart-i.scStart:e.start-i.start}));const n=new op(i);let r,s=0,o=0;const a=new Set,c=()=>{r=new Jf,n.push(r),s=0,o=0,a.clear()};for(c();e.length>0;)if(o>=0&&o(t?e.scStart:e.start)>s),o)}else e=e.filter((e=>!a.has(e))),c();return n},o=(e,t)=>{e.sort((function(e,t){return e.start-t.start}));const i=new op(t),{start:n,end:r}=this.viewport.genomicRange();for(let t of e)if(t.endr)this.#A.push(t);else{const e=new Jf;e.alignments.push(t),i.push(e)}return i};if(!e||0===e.length)return new Map;{const t=new Map;if(n)for(let r of e){const e=lp(r,n,i)||\"\";t.has(e)||t.set(e,[]),t.get(e).push(r)}else t.set(\"\",e);const a=new Map,c=Array.from(t.keys()).sort(function(e,t){switch(e){case\"pairOrientation\":return function(e){const t=[\"LL\",\"RR\",\"RL\",\"LR\",\"\"];return(e,i)=>t.indexOf(e)-t.indexOf(i)}();case\"strand\":case\"firstOfPairStrand\":return up;default:return e&&e.startsWith(\"base:\")?dp:fp}}(n));for(let e of c){const i=t.get(e),n=\"FULL\"===r?o(i,e):s(i,e);a.set(e,n)}this.packedGroups=a}}push(e){this.hasPairs=this.hasPairs||e.isPaired(),this.coverageMap.incCounts(e);const t=e.getBaseModificationSets();if(t)for(let e of t)this.baseModificationKeys.add(e.key);this.baseModCounts&&this.baseModCounts.incrementCounts(e),this.downsampledReads.has(e.readName)?this.currentBucket.downsampledCount++:(e.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new ip(e.start,e.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(e))}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.hasAlignments=this.alignments.length>0,this.alignments.sort((function(e,t){return e.start-t.start})),this.baseModCounts&&this.baseModCounts.computeSimplex(),delete this.currentBucket,delete this.pairsCache,delete this.downsampledReads}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new sp(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount))}allAlignments(){if(this.alignments)return this.alignments;if(this.packedGroups){const e=Array.from(this.packedGroups.values()).flatMap((e=>e.rows.flatMap((e=>e.alignments))));if(this.#A&&this.#A.length>0)for(let t of this.#A)e.push(t);return e}return[]}getMax(e,t){return this.coverageMap.getMax(e,t)}sortRows(e){if(this.packedGroups)for(let t of this.packedGroups.values())t.sortRows(e,this)}}class ip{constructor(e,t,{samplingDepth:i,downsampledReads:n,pairsCache:r}){this.start=e,this.end=t,this.alignments=[],this.downsampledCount=0,this.samplingDepth=i,this.downsampledReads=n,this.pairsCache=r,this.hasPairs=!1}addAlignment(e){this.hasPairs=this.hasPairs||e.isPaired();const t=this.hasPairs?Math.ceil(this.samplingDepth/2):this.samplingDepth;if(ap(e)){const t=this.pairsCache.get(e.readName);if(t)return t.setSecondAlignment(e),void this.pairsCache.delete(e.readName)}if(this.alignments.lengtht)break;const s=this.coverage[r];n>=e&&s&&(i=Math.max(i,s.total))}return i}incCounts(e){var t=this;if(void 0===e.blocks?i(e):e.blocks.forEach((function(e){i(e)})),e.gaps)for(let i of e.gaps)if(\"D\"===i.type){const e=i.start-t.bpStart;for(let n=e;n=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.posA;case\"C\":case\"c\":return n.posC;case\"T\":case\"t\":return n.posT;case\"G\":case\"g\":return n.posG;case\"N\":case\"n\":return n.posN;default:return 0}}getNegCount(e,t){const i=e-this.bpStart;if(i<0||i>=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.negA;case\"C\":case\"c\":return n.negC;case\"T\":case\"t\":return n.negT;case\"G\":case\"g\":return n.negG;case\"N\":case\"n\":return n.negN;default:return 0}}getCount(e,t){return this.getPosCount(e,t)+this.getNegCount(e,t)}getTotalCount(e){const t=e-this.bpStart;return t>=0&&t=t}}class sp{constructor(e,t,i){this.start=e,this.end=t,this.counts=i}popupData(e){return[{name:\"start\",value:Math.floor(this.start+1)},{name:\"end\",value:this.end},{name:\"# downsampled:\",value:this.counts}]}}class op{pixelTop=0;pixelBottom=0;rows=[];constructor(e){this.name=this.name}push(e){this.rows.push(e)}get length(){return this.rows.length}sortRows(e,t){const i=[],n=[];for(let t of this.rows){void 0!==t.findAlignment(e.position,e.sortAsPairs)?i.push(t):n.push(t)}i.sort(((i,n)=>{const r=e.direction,s=i.getSortValue(e,t),o=n.getSortValue(e,t);if(void 0===o&&void 0!==o)return 1;if(void 0!==s&&void 0===o)return-1;const a=s>o?1:s>1);t(e[i])?r=i:n=i}return r}function lp(e,t,i){let n,r,s;if(t.startsWith(\"tag:\"))n=t.substring(4),t=\"tag\";else if(t.startsWith(\"base:\")){const e=t.split(\":\");3===e.length&&(t=\"base\",r=e[1],s=Number.parseInt(e[2].replaceAll(\",\",\"\"))-1)}switch(t){case\"strand\":return e.strand?\"+\":\"-\";case\"firstOfPairStrand\":const t=e.firstOfPairStrand;return void 0===t?\"\":t?\"+\":\"-\";case\"mateChr\":return e.mate&&e.isMateMapped()?e.mate.chr:\"\";case\"pairOrientation\":return ep[i][e.pairOrientation]||\"\";case\"chimeric\":return e.tags().SA?\"chimeric\":\"\";case\"supplementary\":return e.isSupplementary?\"supplementary\":\"\";case\"readOrder\":return e.isPaired()&&e.isFirstOfPair()?\"first\":e.isPaired()&&e.isSecondOfPair()?\"second\":\"\";case\"phase\":return e.tags().HP||\"\";case\"tag\":return e.tags()[n]||\"\";case\"base\":if(e.chr===r&&e.start<=s&&e.end>s){const t=e.readBaseAt(s);return t||\"GAP\"}return\"\";default:return}}const hp=new Map([[\"A\",1],[\"T\",2],[\"C\",3],[\"G\",4],[\"N\",5],[\"GAP\",5],[\"\",7]]);function dp(e,t){return hp.has(e)&&hp.has(t)?hp.get(e)-hp.get(t):e.localeCompare(t,void 0,{sensitivity:\"base\"})}function up(e,t){return e===t?0:e&&t?-e.localeCompare(t):e?1:-1}function fp(e,t){if(e||t){if(e){if(t){if(e===t)return 0;if(Va(e)&&(Va(t),1))return Number.parseFloat(e)-Number.parseFloat(t);{let i=e.toString(),n=t.toString();return i.localeCompare(n,void 0,{sensitivity:\"base\"})}}return-1}return 1}return 0}class pp{constructor(e){const t=e.split(\",\");this.chr=t[0],this.start=parseInt(t[1]),this.strand=t[2].charAt(0),this.mapQ=parseInt(t[4]),this.numMismatches=parseInt(t[5]),this.lenOnRef=function(e){let t=0,i=\"\";for(let n=0;n47&&r<58)i+=e.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:t+=parseInt(i.toString())}i=\"\"}}return t}(t[3])}printString(){return this.chr+\":\"+Rt(this.start)+\"-\"+Rt(this.start+this.lenOnRef)+\" (\"+this.strand+\") = \"+Rt(this.lenOnRef)+\"bp @MAPQ: \"+this.mapQ+\" NM: \"+this.numMismatches}}function gp(e){return e.split(\";\").filter((e=>e.length>0)).map((e=>new pp(e)))}const mp={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class wp{constructor(){this.hidden=!1}isMapped(){return!(4&this.flags)}isPaired(){return!!(1&this.flags)}isProperPair(){return!!(2&this.flags)}isFirstOfPair(){return!!(64&this.flags)}isSecondOfPair(){return!!(128&this.flags)}isSecondary(){return!!(256&this.flags)}isSupplementary(){return!!(2048&this.flags)}isFailsVendorQualityCheck(){return!!(512&this.flags)}isDuplicate(){return!!(1024&this.flags)}isMateMapped(){return!(8&this.flags)}isNegativeStrand(){return!!(16&this.flags)}isMateNegativeStrand(){return!!(32&this.flags)}hasTag(e){const t=this.tagDict||function(e){let t=0;const i=e.length,n={};for(;t=i&&e<=i+n}popupData(e){const t=[];if(e=Math.floor(e),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(e===i||e===i-1)return t.push({name:\"Insertion\",value:n.substr(r.seqOffset,r.len)}),t.push({name:\"Location\",value:i}),t}}t.push({name:\"Read Name\",value:this.readName}),t.push(\"
\"),t.push({name:\"Alignment Start\",value:Rt(1+this.start),borderTop:!0}),t.push({name:\"Read Strand\",value:!0===this.strand?\"(+)\":\"(-)\",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const e=25;n=`${n.substring(0,e-2)} ... ${n.substring(n.length-e+2)}`}t.push({name:\"Cigar\",value:n}),t.push({name:\"Mapping Quality\",value:this.mq}),t.push({name:\"Secondary\",value:a(this.isSecondary())}),t.push({name:\"Supplementary\",value:a(this.isSupplementary())}),t.push({name:\"Duplicate\",value:a(this.isDuplicate())}),t.push({name:\"Failed QC\",value:a(this.isFailsVendorQualityCheck())}),this.isPaired()&&(t.push(\"
\"),t.push({name:\"First in Pair\",value:!this.isSecondOfPair(),borderTop:!0}),t.push({name:\"Mate is Mapped\",value:a(this.isMateMapped())}),this.pairOrientation&&t.push({name:\"Pair Orientation\",value:this.pairOrientation}),this.isMateMapped()&&(t.push({name:\"Mate Chromosome\",value:this.mate.chr}),t.push({name:\"Mate Start\",value:this.mate.position+1}),t.push({name:\"Mate Strand\",value:!0===this.mate.strand?\"(+)\":\"(-)\"}),t.push({name:\"Insert Size\",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty(\"SA\")){t.push(\"
\"),t.push({name:\"Supplementary Alignments\",value:\"\"});const e=gp(r.SA);if(e){t.push(\"
    \");for(let i of e)t.push(`
  • ${i.printString()}
  • `);t.push(\"
\")}}const s=new Set([\"SA\",\"MD\"]);t.push(\"
\");for(let e in r)s.has(e)||t.push({name:e,value:r[e]});t.push({name:\"Hidden Tags\",value:\"SA, MD\"}),t.push(\"
\"),t.push({name:\"Genomic Location: \",value:Rt(1+e)}),t.push({name:\"Read Base:\",value:this.readBaseAt(e)}),t.push({name:\"Base Quality:\",value:this.readBaseQualityAt(e)});const o=this.getBaseModificationSets();if(o){const i=this.positionToReadIndex(e);if(void 0!==i){let e=!1;for(let n of o)if(n.containsPosition(i)){e||(t.push(\"
\"),t.push(\"Base modifications:\"),e=!0);const r=Math.round(100/255*Xf(n.likelihoods.get(i)));t.push(`${n.fullName()} @ likelihood = ${r}%`)}}}return t;function a(e){return e?\"Yes\":\"No\"}}readBaseAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.seq)return\"*\";{const i=t.seqIndexAt(e);return this.seq[i]}}}readBaseQualityAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.qual)return 30;{const i=t.seqIndexAt(e);return i>=0&&this.qual&&i=t.start&&e1)if(Yf(e))h.push(e);else for(let t=0;t=n.start&&t>1)+n;a+4=t)return!1;if(\"B\"!==String.fromCharCode(e[a+2])||\"I\"!==String.fromCharCode(e[a+3]))return!1;var l=Dp(e,a+4),h=a+8;if(h+4*l>t)return!1;var d=\"\",u=0;s.length=0,a=h;for(var f=0;f>4,m=Ep[15&p];\"M\"!==m&&\"EQ\"!==m&&\"X\"!==m&&\"D\"!==m&&\"N\"!==m&&\"=\"!==m||(u+=g),d=d+g+m,s.push({len:g,ltr:m})}return r.cigar=d,r.lengthOnRef=u,!0},decodeBamRecords:function(e,t,i,n,r,s,o,a){for(;te.length)return;if(p<0){t=u;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p>8,b=255&m,F=Dp(e,t+16),v=(4294901760&F)>>16,y=65535&F,A=Dp(e,t+20),C=Dp(e,t+24),_=Dp(e,t+28),x=Dp(e,t+32);let k=[];for(let i=0;i>4,h=Ep[15&c];\"M\"!==h&&\"EQ\"!==h&&\"X\"!==h&&\"D\"!==h&&\"N\"!==h&&\"=\"!==h||(I+=l),S=S+l+h,E+=4,B={len:l,ltr:h},N.push(B)}if(f.chr=n[p],f.start=g,f.flags=v,f.strand=!(16&v),f.readName=k,f.cigar=S,f.lengthOnRef=I,f.fragmentLength=x,f.mq=w,Mp.bam_tag2cigar(e,u,E,A,f,N),f.end=f.start+f.lengthOnRef,f.end>1;for(let t=0;t>4]),M.push(Sp[15&d])}M=M.slice(0,A).join(\"\"),E+=R;const D=[];for(let t=0;t=0&&(f.mate={chr:n[C],position:_,strand:!(32&v)}),f.seq=M,f.qual=D;const T=new Uint8Array(e.buffer.slice(E,u));f.tagDict=zp(T),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Rp(f,N),i.push(f)),t=u}},decodeSamRecords:function(e,t,i,n,r,s){var o,a,c,l,h,d,u,f,p,g;for(l=(o=Dt(e)).length,!1,a=0;ar)break;if(f=0,(g=Tp(p.cigar)).forEach((function(e){var t=e.len,i=e.ltr;\"M\"!==i&&\"EQ\"!==i&&\"X\"!==i&&\"D\"!==i&&\"N\"!==i&&\"=\"!==i||(f+=t)})),p.lengthOnRef=f,!(p.start+fBp&&(console.log(\"Warning: attempt to set sampling depth > maximum value of \"+Bp),e.samplingDepth=Bp)},setPairOrientation:function(e){if(e.isMapped()&&e.mate&&e.isMateMapped()&&e.mate.chr===e.chr){var t=e.strand?\"F\":\"R\",i=e.mate,n=i.strand?\"F\":\"R\",r=\" \",s=\" \";e.isFirstOfPair()?(r=\"1\",s=\"2\"):e.isSecondOfPair()&&(r=\"2\",s=\"1\");var o=[],a=e.fragmentLength,c=e.end-e.start;if(0===a)a=(e.start0?(o[0]=t,o[1]=r,o[2]=n,o[3]=s):(o[2]=t,o[3]=r,o[0]=n,o[1]=s),e.pairOrientation=o.join(\"\")}}};function Rp(e,t){const i=[];let n,r,s=0,o=e.start;e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef;for(let a of t){let t;switch(a.ltr){case\"H\":case\"P\":break;case\"S\":t=o,e.scLengthOnRef+=a.len,0===i.length&&(e.scStart-=a.len,t-=a.len),i.push(new xp({start:t,seqOffset:s,len:a.len,type:\"S\"})),s+=a.len;break;case\"N\":case\"D\":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case\"I\":void 0===n&&(n=[]),n.push(new xp({start:o,len:a.len,seqOffset:s,type:\"I\"})),s+=a.len;break;case\"M\":case\"EQ\":case\"=\":case\"X\":i.push(new xp({start:o,seqOffset:s,len:a.len,type:\"M\"})),s+=a.len,o+=a.len;break;default:console.log(\"Error processing cigar element: \"+a.len+a.ltr)}}e.blocks=i,e.insertions=n,e.gaps=r}function Dp(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Tp(e){var t,i,n,r,s,o,a,c,l;for(t=[],i=[],s=null,r=e.length,n=0;n=48&&l<=57?i.push(o):(a=o,c=Number.parseInt(i.join(\"\")),i=[],null!==s&&s.ltr===a?s.len+=c:(s={len:c,ltr:a},t.push(s)));return t}function Lp(e){var t={};return e.forEach((function(e){var i=e.split(\":\");t[i[0]]=i[2]})),t}function zp(e){let t=0;const i=e.length,n={},r=new DataView(e.buffer);for(;t=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>t.has(e)));e.length>0&&(n=e[0])}return this.chrAliasTable.set(e,n),n}return e}}class Pp{chrAliasTable=new Map;constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.baiPath=e.indexURL,Mp.setReaderDefaults(this,e),this._blockLoader=new yh(e)}async readAlignments(e,t,i){const n=await this.#x(e),r=new tp(e,t,i,this.config);if(void 0===n)return r;{const e=(await this.getIndex()).chunksForRange(n,t,i);if(!e||0===e.length)return r;for(let s of e){const e=await this._blockLoader.getData(s.minv,s.maxv);if(Mp.decodeBamRecords(e,s.minv.offset,r,this.header.chrNames,n,t,i,this.filter))break}return r.finish(),r}}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async getHeader(){if(!this.header){const e=this.genome,t=await this.getIndex();let i;if(t.firstBlockPosition){const e=Ua(this.config,{range:{start:t.firstBlockPosition,size:26}}),n=ms(await Qs.loadArrayBuffer(this.bamPath,e));i=t.firstBlockPosition+n}else i=64e3;const n=Ua(this.config,{range:{start:0,size:i}});this.header=await Mp.readHeader(this.bamPath,n,e)}return this.header}async getIndex(){return this.index||(this.index=await gh(this.baiPath,this.config)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const e=await this.getHeader();return this.chrToIndex=e.chrToIndex,this.indexToChr=e.chrNames,this.chrNames=new Set(e.chrNames),this.chrToIndex}}}class Op{constructor(e,t){this.config=e,this.genome=t;const i={};e.sources.sequences.forEach((function(n){const r=t?t.getChromosomeName(n):n;i[r]=function(e,t,i){const n={url:e.sources.url.replace(\"$CHR\",i)};e.sources.indexURL&&(n.indexURL=e.sources.indexURL.replace(\"$CHR\",i));const r=Object.assign(e,n);return new Pp(r,t)}(e,t,n)})),this.bamReaders=i,Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.bamReaders.hasOwnProperty(e)){let n=this.bamReaders[e];return await n.readAlignments(e,t,i)}return new tp(e,t,i,this.config)}}const Up=function(e,t){this.config=e,this.genome=t,Mp.setReaderDefaults(this,e)};function qp(){const e=this,t=this.genome;if(this.header)return Promise.resolve(this.header);{const i=this.config.url+\"?file=\"+this.config.alignmentFile+\"&options=-b,-H\",n=Ua(this.config);return Mp.readHeader(i,n,t).then((function(t){return e.header=t,t}))}}Up.prototype.readAlignments=function(e,t,i){var n=this;return qp.call(n).then((function(r){var s,o;return s=r.chrAliasTable.hasOwnProperty(e)?r.chrAliasTable[e]:e,o=n.config.url+\"?reference=\"+n.config.referenceFile+\"&file=\"+n.config.alignmentFile+\"®ion=\"+s+\":\"+t+\"-\"+i,Qs.loadString(o,Ua(n.config)).then((function(o){var a;return r.chrToIndex[s],a=new tp(e,t,i,n.config),Mp.decodeSamRecords(o,a,s,t,i,n.filter),a}))}))};class Qp extends Rh{constructor(e,t){super(e,t),Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(!this.header){const e=gs((await this.readHeaderData()).buffer);this.header=Mp.decodeBamHeader(e,this.genome),this.chrAliasTable=new Map;for(let e of this.header.chrNames)this.chrAliasTable.set(e,this.genome.getChromosomeName(e))}let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=gs((await this.readData(n,t,i)).buffer);this.header=Mp.decodeBamHeader(r,this.genome);const s=this.header.chrToIndex[e],o=new tp(e,t,i,this.config);return Mp.decodeBamRecords(r,this.header.size,o,this.header.chrNames,s,t,i,this.filter),o.finish(),o}}\n", - "/*! For license information please see cram-bundle.js.LICENSE.txt */for(var Vp=(()=>{var e={4923:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(8712),s=i(5931),o=i(9747);function a(e,t){const[i,n,r,s,o,a]=t,c=i;e[c]||(e[c]=[]),e[c].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}t.default=class{constructor(e){this.filehandle=(0,s.open)(e.url,e.path,e.filehandle)}parseIndex(){return n(this,void 0,void 0,(function*(){const e={},t=31===(i=yield this.filehandle.readFile())[0]&&139===i[1]?(0,r.unzip)(i):i;var i;if(t.length>4&&21578050===t.readUInt32LE(0))throw new o.CramMalformedError(\"invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support\");let n=[],s=\"\";for(const i of t)if(i>=48&&i<=57||!s&&45===i)s+=String.fromCharCode(i);else if(9===i)n.push(Number.parseInt(s,10)),s=\"\";else if(10===i)n.push(Number.parseInt(s,10)),s=\"\",a(e,n),n=[];else if(13!==i&&32!==i)throw new o.CramMalformedError(\"invalid .crai index file\");return s&&n.push(Number.parseInt(s,10)),6===n.length&&a(e,n),Object.entries(e).forEach((([t,i])=>{const n=i;e[t]=n.sort(((e,t)=>e.start-t.start||e.span-t.span))})),e}))}getIndex(){return this.parseIndexP||(this.parseIndexP=this.parseIndex().catch((e=>{throw this.parseIndexP=void 0,e}))),this.parseIndexP}hasDataForReferenceSequence(e){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[e]}))}getEntriesForRange(e,t,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[e];if(!n)return[];const r=e=>{const n=e.start,r=e.start+e.span;return n>i?-1:r<=t?1:0},s=[];for(const e of n)0===r(e)&&s.push(e);return s}))}}},9508:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=class{constructor(e,t){this.parameters=e,this.dataType=t}}},368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(e,t,i,n){return(0,o.getBits)(t.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}t.default=a},8635:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(9508)),s=i(400);class o extends r.default{constructor(e,t,i){super(e,t),this.instantiateCodec=i}decode(e,t,i,n){const r=this._getLengthCodec().decode(e,t,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a{(0,s.tinyMemoize)(o,e)}))},4839:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(e,t){const i=e.content,{stopByte:n}=this.parameters,r=t.bytePosition;let s=t.bytePosition;for(;i[s]!==n&&s=e.content.length)throw new a.CramBufferOverrunError(\"attempted to read beyond end of block. this file seems truncated.\");return e.content[t.bytePosition++]}}t.default=c},8185:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(e,t,i,n){let r=1;for(;0===(0,o.getBits)(t.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(t.content,n.coreBlock,r-1)|1<{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramBufferOverrunError=void 0,t.getBits=function(e,t,n){let r=0;if(t.bytePosition+(7-t.bitPosition+n)/8>e.length)throw new i(\"read error during decoding. the file seems to be truncated.\");for(let i=n;i;i--)r<<=1,r|=e[t.bytePosition]>>t.bitPosition&1,t.bitPosition-=1,t.bitPosition<0&&(t.bytePosition+=1),t.bitPosition&=7;return r};class i extends Error{}t.CramBufferOverrunError=i},4341:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),this.codes={},this.codeBook={},this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],![\"byte\",\"int\"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let e=new Array(this.parameters.numCodes);for(let t=0;te.bitLength-t.bitLength||e.symbol-t.symbol)),this.codeBook={},e.forEach((e=>{this.codeBook[e.bitLength]||(this.codeBook[e.bitLength]=[]),this.codeBook[e.bitLength].push(e.symbol)}))}buildCodes(){this.codes={};let e=0,t=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=Number.parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};t+=1;const o=s-e;if(t<<=o,n.bitCode=t,e+=o,function(e){let t=e-(e>>1)&1431655765;return t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}(t)>s)throw new r.CramMalformedError(\"Symbol out of range\");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((e,t)=>e.bitLength-t.bitLength||e.bitCode-t.bitCode)),this.sortedValuesByBitCode=this.sortedCodes.map((e=>e.value)),this.sortedBitCodes=this.sortedCodes.map((e=>e.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((e=>e.bitLength));const e=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(e+1).fill(-1);for(let e=0;e-1&&this.sortedBitLengthsByBitCode[i]===t)return this.sortedValuesByBitCode[i];for(let i=e;this.sortedCodes[i+1].bitLength===t&&i{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:\"MIDNSHP:XB\",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},7219:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(6524),r=i(9747),s={BF:\"int\",CF:\"int\",RI:\"int\",RL:\"int\",AP:\"int\",RG:\"int\",MF:\"int\",NS:\"int\",NP:\"int\",TS:\"int\",NF:\"int\",TC:\"byte\",TN:\"int\",FN:\"int\",FC:\"byte\",FP:\"int\",BS:\"byte\",IN:\"byteArray\",SC:\"byteArray\",DL:\"int\",BA:\"byte\",BB:\"byteArray\",RS:\"int\",PD:\"int\",HC:\"int\",MQ:\"int\",RN:\"byteArray\",QS:\"byte\",QQ:\"byteArray\",TL:\"int\"};t.default=class{constructor(e){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(e){const t=new Array(5);for(let e=0;e<5;e+=1)t[e]=new Array(4);return t[0][e[0]>>6&3]=\"C\",t[0][e[0]>>4&3]=\"G\",t[0][e[0]>>2&3]=\"T\",t[0][3&e[0]]=\"N\",t[1][e[1]>>6&3]=\"A\",t[1][e[1]>>4&3]=\"G\",t[1][e[1]>>2&3]=\"T\",t[1][3&e[1]]=\"N\",t[2][e[2]>>6&3]=\"A\",t[2][e[2]>>4&3]=\"C\",t[2][e[2]>>2&3]=\"T\",t[2][3&e[2]]=\"N\",t[3][e[3]>>6&3]=\"A\",t[3][e[3]>>4&3]=\"C\",t[3][e[3]>>2&3]=\"G\",t[3][3&e[3]]=\"N\",t[4][e[4]>>6&3]=\"A\",t[4][e[4]>>4&3]=\"C\",t[4][e[4]>>2&3]=\"G\",t[4][3&e[4]]=\"T\",t}(e.preservation.SM),this.dataSeriesEncoding=e.dataSeriesEncoding,this.tagEncoding=e.tagEncoding}getCodecForTag(e){const t=this.tagCodecCache[e];if(t)return t;{const t=this.tagEncoding[e];if(!t)throw new Error(\"Error, no tag encoding\");const i=(0,n.instantiateCodec)(t,\"byteArray\");return this.tagCodecCache[e]=i,i}}getTagNames(e){return this.tagIdsDictionary[e]}getCodecForDataSeries(e){let t=this.dataSeriesCodecCache[e];if(void 0===t){const i=this.dataSeriesEncoding[e];if(i){const o=s[e];if(!o)throw new r.CramMalformedError(`data series name ${e} not defined in file compression header`);t=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[e]=t}}return t}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.endsWith(\"Cache\")||(e[t]=this[t])})),e}}},78:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=i(9747),a=i(400),c=r(i(6771)),l=r(i(7219)),h=i(3165);class d{constructor(e,t){this.file=e,this.filePosition=t}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(!(null==e?void 0:e.numRecords))return null;const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),n=yield this.getFirstBlock();if(void 0===n)return;if(\"COMPRESSION_HEADER\"!==n.contentType)throw new o.CramMalformedError(`invalid content type ${n.contentType} in compression header block`);const r=(0,a.parseItem)(n.content,i.cramCompressionHeader.parser,0,n.contentPosition);return Object.assign(Object.assign({},n),{parsedContent:r})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(e)return this.file.readBlock(e._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const e=yield this.getCompressionHeaderBlock();if(e)return new l.default(e.parsedContent)}))}getSlice(e,t){return new c.default(this,e,t)}_readContainerHeader(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),{cramContainerHeader1:n,cramContainerHeader2:r}=i,{size:o}=yield this.file.stat();if(e>=o)return void console.warn(`pos:${e}>=fileSize:${o} in cram container`);const c=s.Buffer.allocUnsafe(n.maxLength);yield this.file.read(c,0,n.maxLength,e);const l=(0,a.parseItem)(c,n.parser),d=(0,a.itf8Size)(l.numLandmarks);if(e+l.length>=o)return void console.warn(`container at ${e} is beyond fileSize:${o}, skipping`);const u=s.Buffer.allocUnsafe(r.maxLength(l.numLandmarks));yield this.file.read(u,0,r.maxLength(l.numLandmarks),e+l._size-d);const f=(0,a.parseItem)(u,r.parser);return this.file.validateChecksums&&void 0!==f.crc32&&(yield this.file.checkCrc32(e,l._size+f._size-d-4,f.crc32,`container header beginning at position ${e}`)),Object.assign(l,f,{_size:l._size+f._size-d,_endPosition:l._size+f._size-d+e})}))}}t.default=d,\"getHeader getCompressionHeaderBlock getCompressionScheme\".split(\" \").forEach((e=>{(0,a.tinyMemoize)(d,e)}))},6794:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=r(i(928)),a=r(i(7392)),c=r(i(6960)),l=r(i(235)),h=i(1307),d=i(9747),u=i(8712),f=r(i(9989)),p=i(3165),g=r(i(78)),m=i(5931),w=i(400),b=i(5417);class F{constructor(e){var t;if(this.file=(0,m.open)(e.url,e.path,e.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=e.seqFetch,this.options={checkSequenceMD5:e.checkSequenceMD5,cacheSize:null!==(t=e.cacheSize)&&void 0!==t?t:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const e=new Uint32Array([287454020]),t=new Uint8Array(e.buffer);return 68===t[0]?0:17===t[0]?1:2}()>0)throw new Error(\"Detected big-endian machine, may be unable to run\")}read(e,t,i,n){return this.file.read(e,t,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const{maxLength:e,parser:t}=(0,p.cramFileDefinition)(),i=s.Buffer.allocUnsafe(e);yield this.file.read(i,0,e,0);const n=t(i).value;if(2!==n.majorVersion&&3!==n.majorVersion)throw new d.CramUnimplementedError(`CRAM version ${n.majorVersion} not supported`);return n}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.getContainerById(0);if(!e)throw new d.CramMalformedError(\"file contains no containers\");const t=yield e.getFirstBlock();if(void 0===t)return(0,b.parseHeaderText)(\"\");const i=t.content,n=i.readInt32LE(0),r=i.toString(\"utf8\",4,4+n);return this.header=r,(0,b.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getContainerById(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t);let n=i.cramFileDefinition.maxLength;const{size:r}=yield this.file.stat(),{cramContainerHeader1:s}=i;let o;for(let t=0;t<=e;t++){if(n+s.maxLength+8>=r)return;o=this.getContainerAtPosition(n);const i=yield o.getHeader();if(!i)throw new d.CramMalformedError(`container ${e} not found in file`);if(0===t){n=i._endPosition;for(let e=0;e=r)return;const o=s.Buffer.allocUnsafe(n.maxLength);return yield this.file.read(o,0,n.maxLength,e),(0,w.parseItem)(o,n.parser,0,e)}))}_parseSection(e,t){return n(this,arguments,void 0,(function*(e,t,i=e.maxLength,n){let r;if(n)r=n;else{const{size:e}=yield this.file.stat();if(t+i>=e)return;r=s.Buffer.allocUnsafe(i),yield this.file.read(r,0,i,t)}const o=(0,w.parseItem)(r,e.parser,0,t);if(o._size!==i)throw new d.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${o._size}`);return o}))}_uncompress(e,t,i){return n(this,void 0,void 0,(function*(){if(\"gzip\"===e)(0,u.unzip)(t).copy(i);else if(\"bzip2\"===e){const e=l.default.array(t);let n,r=l.default.header(e),o=0;do{n=l.default.decompress(e,r),-1!==n&&(s.Buffer.from(n).copy(i,o),o+=n.length,r-=n.length)}while(-1!==n)}else if(\"lzma\"===e){const e=new Response(new h.XzReadableStream((n=t,new ReadableStream({start(e){e.enqueue(n),e.close()}}))));s.Buffer.from(yield e.arrayBuffer()).copy(i)}else if(\"rans\"===e)(0,f.default)(t,i);else if(\"rans4x16\"===e)c.default.r4x16_uncompress(t,i);else if(\"arith\"===e)c.default.arith_uncompress(t,i);else if(\"fqzcomp\"===e)c.default.fqzcomp_uncompress(t,i);else{if(\"tok3\"!==e)throw new d.CramUnimplementedError(`${e} decompression not yet implemented`);c.default.tok3_uncompress(t,i)}var n}))}readBlock(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t),n=yield this.readBlockHeader(e);if(void 0===n)return;const r=n._endPosition,o=s.Buffer.allocUnsafe(n.uncompressedSize),a=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:o});if(\"raw\"!==n.compressionMethod){const e=s.Buffer.allocUnsafe(n.compressedSize);yield this.read(e,0,n.compressedSize,r),yield this._uncompress(n.compressionMethod,e,o)}else yield this.read(o,0,n.uncompressedSize,r);if(t>=3){const t=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===t)return;a.crc32=t.crc32,this.validateChecksums&&(yield this.checkCrc32(e,n._size+n.compressedSize,t.crc32,\"block data\")),a._endPosition=t._endPosition,a._size=a.compressedSize+i.cramBlockCrc32.maxLength}else a._endPosition=r+a.compressedSize,a._size=a.compressedSize;return a}))}}t.default=F,\"getDefinition getSectionParsers getSamHeader\".split(\" \").forEach((e=>{(0,w.tinyMemoize)(F,e)}))},7390:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=t.CramRecord=void 0;var r=i(8401);Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return n(r).default}});var s=i(6794);Object.defineProperty(t,\"default\",{enumerable:!0,get:function(){return n(s).default}})},8401:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.MateFlagsDecoder=t.CramFlagsDecoder=t.BamFlagsDecoder=t.MateFlags=t.CramFlags=t.BamFlags=void 0;const r=n(i(7295)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(e){const t={};for(const[i,n]of e)t[`is${n}`]=e=>!!(e&i),t[`set${n}`]=e=>e|i;return t}t.BamFlags=[[1,\"Paired\"],[2,\"ProperlyPaired\"],[4,\"SegmentUnmapped\"],[8,\"MateUnmapped\"],[16,\"ReverseComplemented\"],[32,\"MateReverseComplemented\"],[64,\"Read1\"],[128,\"Read2\"],[256,\"Secondary\"],[512,\"FailedQc\"],[1024,\"Duplicate\"],[2048,\"Supplementary\"]],t.CramFlags=[[1,\"PreservingQualityScores\"],[2,\"Detached\"],[4,\"WithMateDownstream\"],[8,\"DecodeSequenceAsStar\"]],t.MateFlags=[[1,\"OnNegativeStrand\"],[2,\"Unmapped\"]],t.BamFlagsDecoder=o(t.BamFlags),t.CramFlagsDecoder=o(t.CramFlags),t.MateFlagsDecoder=o(t.MateFlags),t.default=class{constructor({flags:e,cramFlags:t,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:c,mateToUse:l,readGroupId:h,readName:d,sequenceId:u,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=e,this.cramFlags=t,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=h,this.readName=d,this.sequenceId=u,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,c&&(this.readFeatures=c),l&&(this.mate={flags:l.mateFlags,readName:l.mateReadName,sequenceId:l.mateSequenceId,alignmentStart:l.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const e=function(e,t){if(!e.lengthOnRef&&!e.readLength)return null;if(e.isUnknownBases())return null;const i=e.alignmentStart-t.start;if(!e.readFeatures)return t.seq.slice(i,i+(e.lengthOnRef||0)).toUpperCase();let n=\"\",r=i,s=0;for(;n.lengththis.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=e,r[1]=i,r[2]=t,r[3]=n):(r[2]=e,r[3]=i,r[0]=t,r[1]=n),r.join(\"\")}return null}addReferenceSequence(e,t){this.readFeatures&&this.readFeatures.forEach((i=>{\"X\"===i.code&&function(e,t,i,n){const r=n.refPos-t.start,o=t.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const c=i.substitutionMatrix[a][n.data];c&&(n.sub=c)}(0,e,t,i)})),!this.readBases&&e.start<=this.alignmentStart&&e.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=e)}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.startsWith(\"_\")||(e[t]=this[t])})),e.readBases=this.getReadBases(),e}}},3165:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.cramFileDefinition=r,t.cramBlockHeader=s,t.cramBlockCrc32=o,t.cramTagDictionary=c,t.cramPreservationMap=l,t.isMappedSliceHeader=function(e){return\"number\"==typeof e.refSeqId},t.getSectionParsers=function(e){return{cramFileDefinition:r(),cramBlockHeader:s(),cramBlockCrc32:o(),cramDataSeriesEncodingMap:p(),cramTagEncodingMap:g(),cramCompressionHeader:{parser:(e,t)=>{const{value:i,offset:n}=l().parser(e,t);t=n;const{value:r,offset:s}=p().parser(e,t);t=s;const{value:o,offset:a}=g().parser(e,t);return t=a,{value:{dataSeriesEncoding:h(r),preservation:h(i),tagEncoding:h(o)},offset:t}}},cramEncoding:{parser:(e,t)=>f(e,t)},cramUnmappedSliceHeader:d(e),cramMappedSliceHeader:u(e),cramContainerHeader1:m(e),cramContainerHeader2:w(e)}};const n=i(400);function r(){return{parser:(e,t=0)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length);let r=0;const s=e.subarray(r,r+4).toString();r+=4;const o=n.getUint8(r);r+=1;const a=n.getUint8(r);r+=1;const c=i.subarray(r,r+20).toString().replaceAll(\"\\0\",\"\");return r+=20,{value:{magic:s,majorVersion:o,minorVersion:a,fileId:c},offset:r}},maxLength:26}}function s(){return{parser:(e,t=0)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length);let s=0;const o=r.getUint8(s),a=[\"raw\",\"gzip\",\"bzip2\",\"lzma\",\"rans\",\"rans4x16\",\"arith\",\"fqzcomp\",\"tok3\"][o];if(!a)throw new Error(`compression method number ${o} not implemented`);s+=1;const c=r.getUint8(s),l=[\"FILE_HEADER\",\"COMPRESSION_HEADER\",\"MAPPED_SLICE_HEADER\",\"UNMAPPED_SLICE_HEADER\",\"EXTERNAL_DATA\",\"CORE_DATA\"][c];if(!l)throw new Error(`invalid block content type id ${c}`);s+=1;const[h,d]=(0,n.parseItf8)(e,s);s+=d;const[u,f]=(0,n.parseItf8)(e,s);s+=f;const[p,g]=(0,n.parseItf8)(e,s);return s+=g,{offset:s,value:{uncompressedSize:p,compressedSize:u,contentId:h,contentType:l,compressionMethod:a}}},maxLength:17}}function o(){return{parser:(e,t)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length).getUint32(t,!0);return{offset:t+=4,value:{crc32:n}}},maxLength:4}}function a(e,t,i){const n=e.toString(\"utf8\",t,i),r=[];for(let e=0;e{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const s=e.subarray(t,t+i);t+=i;const o=[];let c=0,l=0;for(;lc&&o.push(a(s,c,l)),{value:{size:i,ents:o},offset:t}}}}function l(){return{parser:(e,t)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,l]=(0,n.parseItf8)(e,t);t+=l;const h=[];for(let i=0;i{const[r,s]=(0,n.parseItf8)(t,i);i+=s;let o=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,o=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,o=e}else console.warn(\"recordCounter=0\");const[a,c]=(0,n.parseItf8)(t,i);i+=c;const[l,h]=(0,n.parseItf8)(t,i);i+=h;const d=[];for(let e=0;e=2&&(u=[...t.subarray(i,i+16)],i+=16),{value:{recordCounter:o,md5:u,contentIds:d,numContentIds:l,numBlocks:a,numRecords:r},offset:i}},maxLength:e=>40+5*e}}function u(e){return{parser:(t,i)=>{const[r,s]=(0,n.parseItf8)(t,i);i+=s;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;let u=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,u=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,u=e}else console.warn(\"majorVersion is <2, recordCounter set to 0\");const[f,p]=(0,n.parseItf8)(t,i);i+=p;const[g,m]=(0,n.parseItf8)(t,i);i+=m;const w=[];for(let e=0;e=2&&(v=[...t.subarray(i,i+16)],i+=16),{value:{md5:v,numBlocks:f,numRecords:h,numContentIds:g,refSeqSpan:c,refSeqId:r,refSeqStart:o,recordCounter:u,refBaseBlockId:b,contentIds:w},offset:i}},maxLength:e=>60+5*e}}function f(e,t){const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,c]=(0,n.parseItf8)(e,t);t+=c;const l={};if(0===s);else if(1===s){const[i,r]=(0,n.parseItf8)(e,t);l.blockContentId=i,t+=r}else if(2===s){const[i,r]=(0,n.parseItf8)(e,t);l.offset=i,t+=r;const[s,o]=(0,n.parseItf8)(e,t);l.M=s,t+=o}else if(3===s){const i=(0,n.parseItf8)(e,t),r=i[0];t+=i[1];const s=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(255&i),{value:o,offset:c}=f(e,t);t=c,a.push({key:s,value:o})}return{value:{mapSize:i,ents:a,mapCount:s},offset:t}}}}function m(e){return{maxLength:52,parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length).getInt32(i,!0);i+=4;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;const[u,f]=(0,n.parseItf8)(t,i);i+=f;let p,g=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);g=e,i+=r}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);g=e,i+=r}else console.warn(\"setting recordCounter=0\");if(e>1){const[e,r]=(0,n.parseLtf8)(t,i);p=e,i+=r}const[m,w]=(0,n.parseItf8)(t,i);i+=w;const[b,F]=(0,n.parseItf8)(t,i);return{value:{length:s,refSeqId:o,refSeqStart:c,alignmentSpan:h,numBlocks:m,numLandmarks:b,numBases:p,recordCounter:g,numRecords:u},offset:i+=F}}}}function w(e){return{parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length),[o,a]=(0,n.parseItf8)(t,i);i+=a;const c=[];for(let e=0;e=3&&(l=s.getUint32(i,!0),i+=4),{value:Object.assign(Object.assign({},void 0===l?{}:{crc32:l}),{numLandmarks:o,landmarks:c}),offset:i}},maxLength:e=>5+5*e+4}}},6484:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,c,l,h,d,u,f){let p=t(\"BF\");const g=t(\"CF\");if(!(0,s.isMappedSliceHeader)(c.parsedContent))throw new Error(\"slice header not mapped\");const m=u>1&&-2===c.parsedContent.refSeqId?t(\"RI\"):c.parsedContent.refSeqId,w=t(\"RL\");let b=t(\"AP\");i.APdelta&&(b+=d.lastAlignmentStart),d.lastAlignmentStart=b;const F=t(\"RG\");let v,y,A,C;if(i.readNamesIncluded&&(v=o(t(\"RN\"))),r.CramFlagsDecoder.isDetached(g)){const e=t(\"MF\");let n;i.readNamesIncluded||(n=o(t(\"RN\")),v=n);const s=t(\"NS\"),a=t(\"NP\");(e||s>-1)&&(y={mateFlags:e,mateSequenceId:s,mateAlignmentStart:a,mateReadName:n}),A=t(\"TS\"),r.MateFlagsDecoder.isUnmapped(e)&&(p=r.BamFlagsDecoder.setMateUnmapped(p)),r.MateFlagsDecoder.isOnNegativeStrand(e)&&(p=r.BamFlagsDecoder.setMateReverseComplemented(p))}else r.CramFlagsDecoder.isWithMateDownstream(g)&&(C=t(\"NF\")+f+1);const _=t(\"TL\");if(_<0)throw new n.CramMalformedError(\"invalid TL index\");const x={},k=i.getTagNames(_),I=k.length;for(let t=0;t1?\"SC\":\"IN\"],X:[\"number\",\"BS\"],D:[\"number\",\"DL\"],I:[\"string\",\"IN\"],i:[\"character\",\"BA\"],b:[\"string\",\"BB\"],q:[\"numArray\",\"QQ\"],Q:[\"number\",\"QS\"],H:[\"number\",\"HC\"],P:[\"number\",\"PD\"],N:[\"number\",\"RS\"]}[t];if(!h)throw new n.CramMalformedError(`invalid read feature code \"${t}\"`);let d=l(h);const u={B:[\"number\",\"QS\"]}[t];u&&(d=[d,l(u)]),o+=r;const f=o;a+=r;const p=a;\"D\"===t||\"N\"===t?a+=d:\"I\"===t||\"S\"===t?a-=d.length:\"i\"===t&&(a-=1),c[e]={code:t,pos:f,refPos:p,data:d}}return c}(b,e,t,0,u)),E=w,S)for(const{code:e,data:t}of S)\"D\"===e||\"N\"===e?E+=t:\"I\"===e||\"S\"===e?E-=t.length:\"i\"===e&&(E-=1);if(Number.isNaN(E)&&(console.warn(`${v||`${m}:${b}`} record has invalid read features`),E=w),N=t(\"MQ\"),r.CramFlagsDecoder.isPreservingQualityScores(g)){B=new Array(w);for(let e=0;e=0){const r=e[i.mateRecordNumber];if(!r)throw new s.CramMalformedError(\"intra-slice mate record not found, this file seems malformed\");n.push(...t(r))}return n}(i),r=n.map((e=>e.alignmentStart)),o=n.map((e=>e.alignmentStart+e.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((e=>{if(void 0!==e.templateLength)throw new s.CramMalformedError(\"mate pair group has some members that have template lengths already, this file seems malformed\");e.templateLength=a}))}(e,0,i):function(e,t){const i=Math.min(e.alignmentStart,t.alignmentStart),n=Math.max(e.alignmentStart+e.readLength-1,t.alignmentStart+t.readLength-1)-i+1;e.templateLength=n,t.templateLength=n}(i,n)),i.mateRecordNumber=void 0}class f{constructor(e,t,i){this.container=e,this.containerPosition=t,this.sliceSize=i,this.file=e.file}getHeader(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.file.getDefinition(),t=(0,h.getSectionParsers)(e),i=yield this.container.getHeader();if(!i)throw new Error(\"no container header detected\");const n=yield this.file.readBlock(i._endPosition+this.containerPosition);if(void 0===n)throw new Error(\"block header undefined\");if(\"MAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramMappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}if(\"UNMAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramUnmappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${n.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();let t=e._endPosition;const i=new Array(e.parsedContent.numBlocks);for(let e=0;e{\"EXTERNAL_DATA\"===e.contentType&&(t[e.contentId]=e)})),t}))}getBlockByContentId(e){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[e]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const e=(yield this.getHeader()).parsedContent;if(!(0,h.isMappedSliceHeader)(e))throw new Error(\"slice header not mapped\");if(e.refSeqId<0)return;const t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error(\"compression scheme undefined\");if(e.refBaseBlockId>=0){const t=yield this.getBlockByContentId(e.refBaseBlockId);if(!t)throw new s.CramMalformedError(\"embedded reference specified, but reference block does not exist\");return{seq:t.data.toString(\"utf8\"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}if(t.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error(\"reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence\");const t=yield this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);if(t.length!==e.refSeqSpan)throw new s.CramArgumentError(\"seqFetch callback returned a reference sequence of the wrong length\");return{seq:t,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){var e,t;const{majorVersion:i}=yield this.file.getDefinition(),n=yield this.container.getCompressionScheme();if(void 0===n)throw new Error(\"compression scheme undefined\");const r=yield this.getHeader(),a=yield this._getBlocksContentIdIndex();if(i>1&&this.file.options.checkSequenceMD5&&(0,h.isMappedSliceHeader)(r.parsedContent)&&r.parsedContent.refSeqId>=0&&\"0000000000000000\"!==(null===(e=r.parsedContent.md5)||void 0===e?void 0:e.join(\"\"))){const e=yield this.getReferenceRegion();if(e){const{seq:i,start:n,end:a}=e,c=(0,o.sequenceMD5)(i),l=null===(t=r.parsedContent.md5)||void 0===t?void 0:t.map((e=>(e<16?\"0\":\"\")+e.toString(16))).join(\"\");if(c!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${r.parsedContent.refSeqId} pos ${n}..${a}. recorded MD5: ${l}, calculated MD5: ${c}`)}}const f=yield this.getCoreDataBlock(),p={lastAlignmentStart:(0,h.isMappedSliceHeader)(r.parsedContent)?r.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(e){let t=this.map.get(e);return void 0===t&&(t={bitPosition:7,bytePosition:0},this.map.set(e,t)),t}}},g=e=>{const t=n.getCodecForDataSeries(e);if(!t)throw new s.CramMalformedError(`no codec defined for ${e} data series`);return t.decode(this,f,a,p)},m=new Array(r.parsedContent.numRecords);for(let t=0;t=0&&u(m,e,m[e],m[t])}return m}))}getRecords(e){return n(this,void 0,void 0,(function*(){const t=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(t.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(t.toString(),i));const r=(yield i).filter(e);if(r.length&&this.file.fetchReferenceSequenceCallback){const e=yield this.getHeader();if((0,h.isMappedSliceHeader)(e.parsedContent)&&(e.parsedContent.refSeqId>=0||-2===e.parsedContent.refSeqId)){const t=e.parsedContent.refSeqId>=0?e.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error(\"compression scheme undefined\");const s={};for(const e of r){const i=void 0!==t?t:e.sequenceId;let n=s[i];n||(n={id:i,start:e.alignmentStart,end:Number.NEGATIVE_INFINITY,seq:null},s[i]=n);const r=e.alignmentStart+(e.lengthOnRef||e.readLength)-1;r>n.end&&(n.end=r),e.alignmentStartn(this,void 0,void 0,(function*(){-1!==e.id&&e.start<=e.end&&this.file.fetchReferenceSequenceCallback&&(e.seq=yield this.file.fetchReferenceSequenceCallback(e.id,e.start,e.end))})))));for(const e of r){const n=s[void 0!==t?t:e.sequenceId];if(null==n?void 0:n.seq){const t=n.seq;e.addReferenceSequence(Object.assign(Object.assign({},n),{seq:t}),i)}}}}return r}))}}t.default=f,\"getHeader getBlocks _getBlocksContentIdIndex\".split(\" \").forEach((e=>{(0,o.tinyMemoize)(f,e)}))},400:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.itf8Size=function(e){return-128&e?-16384&e?-2097152&e?-268435456&e?5:4:3:2:1},t.parseItf8=function(e,t){let i=t;const n=e[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|e[i+1]),i+=2):n<224?(r=2097151&(n<<16|e[i+1]<<8|e[i+2]),i+=3):n<240?(r=268435455&(n<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4):(r=(15&n)<<28|e[i+1]<<20|e[i+2]<<12|e[i+3]<<4|15&e[i+4],i+=5),i>e.length)throw new o.CramBufferOverrunError(\"Attempted to read beyond end of buffer; this file seems truncated.\");return[r,i-t]},t.parseLtf8=function(e,t){let i=t;const n=e[i];let r;if(n<128)r=n,i+=1;else if(n<192)r=16383&(e[i]<<8|e[i+1]),i+=2;else if(n<224)r=2097151&(e[i]<<16|e[i+1]<<8|e[i+2]),r=(63&n)<<16|e.readUInt16LE(i+1),i+=3;else if(n<240)r=268435455&(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4;else if(n<248)r=(15&e[i])*Math.pow(2,32)+(e[i+1]<<24)|e[i+2]<<16|e[i+3]<<8|e[i+4],i+=5;else if(n<252)r=((7&e[i])<<8|e[i+1])*Math.pow(2,32)+(e[i+2]<<24)|e[i+3]<<16|e[i+4]<<8|e[i+5],i+=6;else if(n<254)r=((3&e[i])<<16|e[i+1]<<8|e[i+2])*Math.pow(2,32)+(e[i+3]<<24)|e[i+4]<<16|e[i+5]<<8|e[i+6],i+=7;else if(n<255){if(r=s.default.fromBytesBE(e.slice(i+1,i+8)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=8}else{if(r=s.default.fromBytesBE(e.slice(i+1,i+9)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=9}return[r,i-t]},t.parseItem=function(e,t,i=0,n=0){const{offset:r,value:s}=t(e,i);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},t.tinyMemoize=function(e,t){const i=e.prototype[t],n=`_memo_${t}`;e.prototype[t]=function(){if(!(n in this)){const e=i.call(this);this[n]=e,Promise.resolve(e).catch((()=>{delete this[n]}))}return this[n]}},t.sequenceMD5=function(e){return(0,r.default)(e.toUpperCase().replaceAll(/[^\\u0021-\\u007e]/g,\"\"))};const r=n(i(3503)),s=n(i(8570)),o=i(612)},9747:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramArgumentError=t.CramSizeLimitError=t.CramMalformedError=t.CramUnimplementedError=t.CramError=void 0;class i extends Error{}t.CramError=i;class n extends Error{}t.CramUnimplementedError=n,t.CramMalformedError=class extends i{},t.CramSizeLimitError=class extends i{},t.CramArgumentError=class extends i{}},7806:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.IndexedCramFile=t.CraiIndex=t.CramRecord=t.CramFile=void 0;var r=i(7390);Object.defineProperty(t,\"CramFile\",{enumerable:!0,get:function(){return n(r).default}}),Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return r.CramRecord}});var s=i(4923);Object.defineProperty(t,\"CraiIndex\",{enumerable:!0,get:function(){return n(s).default}});var o=i(6014);Object.defineProperty(t,\"IndexedCramFile\",{enumerable:!0,get:function(){return n(o).default}})},6014:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(9747),o=r(i(7390));t.default=class{constructor(e){var t;if(this.cram=null!==(t=e.cram)&&void 0!==t?t:new o.default({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof o.default))throw new Error(\"invalid arguments: no cramfile\");this.index=e.index}getRecordsForRange(e,t,i){return n(this,arguments,void 0,(function*(e,t,i,n={}){if(n.viewAsPairs=n.viewAsPairs||!1,n.pairAcrossChr=n.pairAcrossChr||!1,n.maxInsertSize=n.maxInsertSize||2e5,\"string\"==typeof e)throw new s.CramUnimplementedError(\"string sequence names not yet supported\");const r=e,o=yield this.index.getEntriesForRange(r,t,i),a=n=>n.sequenceId===e&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=t,c=yield Promise.all(o.map((e=>this.getRecordsInSlice(e,a))));let l=Array.prototype.concat(...c);if(n.viewAsPairs){const e={},t={};for(const i of l){const n=i.readName;if(void 0===n)throw new Error(\"readName undefined\");const r=i.uniqueId;e[n]||(e[n]=0),e[n]+=1,t[r]=1}const i={};Object.entries(e).forEach((([e,t])=>{1===t&&(i[e]=!0)}));const s=[];for(const e of l){const t=e.readName;if(void 0===t)throw new Error(\"readName undefined\");if(i[t]&&e.mate&&(e.mate.sequenceId===r||n.pairAcrossChr)&&Math.abs(e.alignmentStart-e.mate.alignmentStart)e.toString().localeCompare(t.toString()))).filter(((e,t,i)=>!t||e.toString()!==i[t-1].toString()));const c=[];for(const e of a){let n=this.cram.featureCache.get(e.toString());n||(n=this.getRecordsInSlice(e,(()=>!0)),this.cram.featureCache.set(e.toString(),n));const r=n.then((e=>{const n=[];for(const r of e){if(void 0===r.readName)throw new Error(\"readName undefined\");i[r.readName]&&!t[r.uniqueId]&&n.push(r)}return n}));c.push(r)}const h=yield Promise.all(c);if(h.length){const e=h.reduce(((e,t)=>e.concat(t)));l=l.concat(e)}}return l}))}getRecordsInSlice({containerStart:e,sliceStart:t,sliceBytes:i},n){return this.cram.getContainerAtPosition(e).getSlice(t,i).getRecords(n)}hasDataForReferenceSequence(e){return this.index.hasDataForReferenceSequence(e)}}},5931:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RemoteFile=t.LocalFile=void 0,t.open=function(e,t,i){if(i)return i;if(e)return new n.RemoteFile(e);if(t)return new n.LocalFile(t);throw new Error(\"no url, path, or filehandle provided, cannot open\")};const n=i(1113);var r=i(1113);Object.defineProperty(t,\"LocalFile\",{enumerable:!0,get:function(){return r.LocalFile}}),Object.defineProperty(t,\"RemoteFile\",{enumerable:!0,get:function(){return r.RemoteFile}})},6476:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RANS_BYTE_L=t.TOTFREQ=t.TF_SHIFT=void 0,t.TF_SHIFT=12,t.TOTFREQ=4096,t.RANS_BYTE_L=1<<23},997:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,n){let a=e.getInt(),c=e.getInt(),l=e.getInt(),h=e.getInt();const d=n.remaining(),u=-4&d;for(let r=0;r>2;let u=0,f=d,p=2*d,g=3*d,m=0,w=0,b=0,F=0;for(;u{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(9747),r=i(6476);class s{constructor(){this.F=void 0,this.C=void 0}}function o(e,t,i,n){return i*(e>>n)+(e&(1<>s)+(e&(1<=128&&(t.fc[c].F&=-129,t.fc[c].F=(127&t.fc[c].F)<<8|255&e.get()),t.fc[c].C=r,o.default.symbolInit(i[c],t.fc[c].C,t.fc[c].F),t.R||(t.R=new Array(s.TOTFREQ)),t.R.fill(c,r,r+t.fc[c].F),r+=t.fc[c].F,0===n&&c+1===(255&e.getByteAt(e.position()))?(c=255&e.get(),n=255&e.get()):0!==n?(n-=1,c+=1):c=255&e.get()}while(0!==c);a(r=128&&(t[r].fc[h].F&=-129,t[r].fc[h].F=(127&t[r].fc[h].F)<<8|255&e.get()),t[r].fc[h].C=l,0===t[r].fc[h].F&&(t[r].fc[h].F=s.TOTFREQ),null==i[r][h]&&(i[r][h]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][h],t[r].fc[h].C,t[r].fc[h].F),null==t[r].R&&(t[r].R=new Array(s.TOTFREQ)),t[r].R.fill(h,l,l+t[r].fc[h].F),l+=t[r].fc[h].F,a(l<=s.TOTFREQ),0===c&&h+1===(255&e.getByteAt(e.position()))?(h=255&e.get(),c=255&e.get()):0!==c?(c-=1,h+=1):h=255&e.get()}while(0!==h);0===n&&r+1===(255&e.getByteAt(e.position()))?(r=255&e.get(),n=255&e.get()):0!==n?(n-=1,r+=1):r=255&e.get()}while(0!==r)};const r=i(9747),s=i(6476),o=n(i(488));function a(e){if(!e)throw new r.CramMalformedError(\"assertion failed\")}},9989:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i=0){if(0===e.length)return t.fill(0),t;const n=new d(e,i),u=n.get();if(0!==u&&1!==u)throw new s.CramMalformedError(`Invalid rANS order ${u}`);if(n.getInt()!==n.remaining()-h)throw new s.CramMalformedError(\"Incorrect input length.\");const f=n.getInt(),p=new d(t||r.Buffer.allocUnsafe(f));if(p.length{Object.defineProperty(t,\"__esModule\",{value:!0}),t.parseHeaderText=function(e){const t=e.split(/\\r?\\n/),i=[];for(const e of t){const[t,...n]=e.split(/\\t/);t&&i.push({tag:t.slice(1),data:n.map((e=>{const t=e.indexOf(\":\");return-1!==t?{tag:e.slice(0,t),value:e.slice(t+1)}:{tag:e,value:\"\"}}))})}return i}},8712:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.unzip=function(e){return r.Buffer.from((0,n.inflate)(e))};const n=i(1668),r=i(8287)},635:(e,t,i)=>{var n=i(8287).Buffer;const r=i(4646),s=i(8706),o=i(9614),a=i(235),c=128;e.exports=class{decode(e){return this.stream=new s(e),this.decodeStream(this.stream)}decodeStream(e,t=0){var i=this.stream.ReadByte();16&i||(t=this.stream.ReadUint7());var n,r=t,s=1&i;if(8&i)return this.decodeStripe(this.stream,t);if(i&c&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&c&&(o=this.decodePack(o,n,t)),o}encode(e,t){if(this.stream=new s(\"\",0,1.1*e.length+100),this.stream.WriteByte(t),16&t||this.stream.WriteUint7(e.length),8&t)return n.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,e,t>>8)]);var i,r=1&t,o=e.length;return t&c&&([i,e,o]=this.encodePack(e)),t&c&&this.stream.WriteStream(i),64&t?r?this.encodeRLE1(e,o,this.stream):this.encodeRLE0(e,o,this.stream):r?this.encode1(e,o,this.stream):this.encode0(e,o,this.stream)}decode0(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);var a=new o(s),c=new r(e);c.RangeStartDecode(e);for(var l=0;l=3?3:h;for(c[d].ModelEncode(i,l,u),h-=u,d=256;3==u;)u=h>=3?3:h,c[d].ModelEncode(i,l,u),d=257,h-=u}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);for(var a=new Array(s),c=0;c=3?3:d;for(c[u].ModelEncode(i,l,f),d-=f,u=256;3==f;)f=d>=3?3:d,c[u].ModelEncode(i,l,f),u=257,d-=f}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(e){this.nsym=e.ReadByte();for(var t=new Array(this.nsym),i=0;i>=1}}else if(this.nsym<=4)for(s=0,o=0;s>=2;else{if(!(this.nsym<=16))return e;for(s=0,o=0;s>=4}return r}packMeta(e){for(var t=new s(\"\",0,1024),i=new Array(256),n=0;no),n[o]=new Array(r[o]);for(var a=0,c=0;co),a[o]=this.decodeStream(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o{e.exports=class{constructor(e){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(e){for(var t=0;t<5;t++)this.code=(this.code<<8)+e.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(e){return this.range=Math.floor(this.range/e),Math.floor(this.code/this.range)}RangeDecode(e,t,i,n){for(this.code-=t*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+e.ReadByte()}RangeShiftLow(e){if(this.low<4278190080|this.carry){for(e.WriteByte(this.cache+this.carry);this.FFnum;)e.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(e,t,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=t*this.range,this.low>>>=0,this.range*=i,this.low{e.exports=class{constructor(e=256){this.total_freq=e,this.max_sym=e-1,this.S=new Array,this.F=new Array;for(var t=0;t<=this.max_sym;t++)this.S[t]=t,this.F[t]=1}ModelDecode(e,t){for(var i=t.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];t.RangeDecode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var e=0;e<=this.max_sym;e++)this.F[e]-=Math.floor(this.F[e]/2),this.total_freq+=this.F[e]}ModelEncode(e,t,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(t.RangeEncode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},6038:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(9614),o=i(4646);function a(e,t,i){for(var n=0,r=0,s=-1,o=new Array(1024);r>4,t.qshift=15&i,i=e.ReadByte(),t.qloc=i>>4,t.sloc=15&i,i=e.ReadByte(),t.ploc=i>>4,t.dloc=15&i,t.qmap=new Array(256),16&t.pflags)for(var n=0;n0&&128&t.pflags)a(e,t.qtab,256);else for(n=0;n<256;n++)t.qtab[n]=n;return t.ptab=new Array(1024),32&t.pflags&&a(e,t.ptab,1024),t.dtab=new Array(256),64&t.pflags&&a(e,t.dtab,256),t}function h(e,t,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(e,t):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(e,t);a|=n.len[1].ModelDecode(e,t)<<8,a|=n.len[2].ModelDecode(e,t)<<16,a|=n.len[3].ModelDecode(e,t)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(e,t)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(e,t)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function d(e,t,i){for(var n=0,r=0,s=new Array(2*i),o=0;n1?i.nparam-1:0,s=new Array(256);if(2&i)r=e.ReadByte(),a(e,s,256);else{for(var o=0;o0&&(t.sel=new s(e.max_sel+1)),t}(r),p=new o(e);p.RangeStartDecode(e);for(var g=new n.allocUnsafe(i),m={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},w=0;w0&&f.dup.ModelDecode(e,p)){for(var b=0;b4),qshift:d,qloc:7,pbits:7,pshift:t[0]>128?1:0,ploc:0,dbits:d>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:c,nsym:a,do_qmap:u,do_dedup:0,fixed_len:1==t.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:d<=4?1:0,do_qtab:0,qbits:8+(d>4)-(0==o),sbits:1,sloc:15-(d<=4),do_stab:1,do_sel:1}]}(e,t,i,n),p=function(e,t,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],c=0;c1?1:0)|(t[0].do_stab?2:0);if(e.WriteByte(l),1&l&&e.WriteByte(t.length),2&l){var h=1<0&&h--,e.WriteByte(h),d(e,o,256)}for(var u=0;u0){for(c=0;c<256;c++)n[u][c]=c;t[u].do_qtab&&d(e,n[u],256)}if(t[u].pbits>0){for(c=0;c<1024;c++)r[u][c]=Math.min((1<>t[u].pshift);d(e,r[u],1024)}if(t[u].dbits>0){for(c=0;c<256;c++)a[c]>(1<>t[u].dshift)];d(e,s[u],256)}}return e}(p,f,n,a,c,l,h);return function(e,t,i,n,r,a,c,l,h,d){var u=1<0&&u--;for(var f=t.length,p=0,g=0;g0&&F.ModelEncode(e,v,A);var C=d[A],_=i[Math.min(i.length-1,y++)];r[C].fixed_len?r[C].fixed_len>0&&(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255),r[C].fixed_len=-1):(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255)),r[C].do_dedup&&process.exit(1),g=_;var x=0,k=r[C].context,I=0,S=0}var E=t[w++],N=a[C][E];m[k].ModelEncode(e,v,N),I=(I<0&&(k+=l[C][Math.min(g,1023)]<0&&(k+=h[C][Math.min(x,255)]<{var n=i(8287).Buffer,r=i(5460),s=i(8223),o=i(635),a=i(6038),c=i(5997);e.exports={r4x8_uncompress:function(e,t){r.decode(e).copy(t,0,0)},r4x16_uncompress:function(e,t){s.decode(e).copy(t,0,0)},arith_uncompress:function(e,t){o.decode(e).copy(t,0,0)},fqzcomp_uncompress:function(e,t){var i=new Array;a.decode(e,i).copy(t,0,0)},tok3_uncompress:function(e,t){var i=c.decode(e,0,\"\\0\");n.from(i,\"binary\").copy(t,0,0)}}},8706:(e,t,i)=>{var n=i(8287).Buffer;e.exports=class{constructor(e,t=0,i=0){0!=i?(this.buf=n.allocUnsafe(i),this.length=i):(this.buf=e,this.length=e.length),this.pos=t}EOF(){return this.pos>=this.length}ReadData(e){var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}ReadByte(){const e=this.buf[this.pos];return this.pos++,e}ReadChar(){const e=this.buf[this.pos];return this.pos++,String.fromCharCode(e)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const e=this.buf.readInt32LE(this.pos);return this.pos+=4,e}ReadString(){var e=\"\";do{var t=this.buf[this.pos++];t&&(e+=String.fromCharCode(t))}while(t);return e}ReadUint7(){var e=0;do{var t=this.ReadByte();e=e<<7|127&t}while(128&t);return e}ReadITF8(){var e=this.buf[this.pos];return this.pos++,e>=240?(e=(15&e)<<28,e+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):e>=224?(e=(15&e)<<24,e+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(0|this.buf[this.pos+2]),this.pos+=3):e>=192?(e=(31&e)<<16,e+=(this.buf[this.pos+0]<<8)+(0|this.buf[this.pos+1]),this.pos+=2):e>=128&&(e=(63&e)<<8,e+=this.buf[this.pos],this.pos++),e}WriteByte(e){this.buf[this.pos++]=e}WriteChar(e){this.buf[this.pos++]=e.charCodeAt(0)}WriteString(e){for(var t=0;t>8&255)}WriteUint32(e){this.buf.writeInt32LE(e,this.pos),this.pos+=4}WriteUint7(e){var t=0,i=e;do{t+=7,i>>=7}while(i>0);do{t-=7,this.WriteByte((e>>t&127)+((t>0)<<7))}while(t>0)}WriteITF8(e){e<0&&(e=1+e),e<=127?this.buf[this.pos++]=e:e<=16383?(this.buf[this.pos++]=128|Math.floor(e/256),this.buf[this.pos++]=255&e):e<131071?(this.buf[this.pos++]=192|Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):e<268435455?(this.buf[this.pos++]=224|Math.floor(e/16777216),this.buf[this.pos++]=255&Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):(this.buf[this.pos++]=240|Math.floor(e/268435456),this.buf[this.pos++]=255&Math.floor(e/1048576),this.buf[this.pos++]=255&Math.floor(e/4096),this.buf[this.pos++]=255&Math.floor(e/4),this.buf[this.pos++]=15&e)}WriteByteNeg(e){this.buf[--this.pos]=e}}},5460:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e){return 4095&e}function o(e,t){for(var i=0;t>=e[i+1];)i++;return i}function a(e){for(var t=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=e[i+1];)i++;t[n]=i}return t}function c(e,t,i){return i*(e>>12)+(4095&e)-t}function l(e,t){for(;t<1<<23;)t=(t<<8)+e.ReadByte();return t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<23>>n<<8)*i;e>=r;)t.WriteByteNeg(255&e),e>>=8;return e}(e,t,n,r),(Math.floor(e/n)<0?(o--,r++):(r=e.ReadByte())==s+1&&(o=e.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}function f(e){for(var t=0,i=0;i<256;i++)t+=e[i];const n=4096;var r=n/t;do{var s=0,o=0,a=0;for(t=0,i=0;i<256;i++)0!=e[i]&&(s2?e[o]-=t-n:t!=n&&(r*=.99,a=1)}while(a)}function p(e,t){for(var i=0,n=0;n<256;n++)if(t[n]){if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteITF8(t[n])}e.WriteByte(0)}e.exports={decode:function(e){var t=new r(e),i=t.ReadByte(),h=(t.ReadUint32(),t.ReadUint32());return 0==i?function(e,t){var i=new Array(256),r=new Array(256);u(e,i,r);for(var o=a(r),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var f=new n.allocUnsafe(t);for(d=0;d0?(a--,s++):(s=e.ReadByte())==o+1&&(a=e.ReadByte()),o=s}while(0!=s)}(e,i,r);for(var h=new Array(256),d=0;d<256;d++)h[d]=a(r[d]);for(var f=new Array(4),p=new Array(4),g=0;g<4;g++)f[g]=e.ReadUint32(),p[g]=0;var m=new n.allocUnsafe(t),w=Math.floor(t/4);for(d=0;d=0;a--)c[a%4]=d(c[a%4],u,o[e[a]],s[e[a]],12);for(a=3;a>=0;a--)h(c[a],u);var g=i.pos;return i.buf.writeInt32LE(g-9+(u.length-u.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}(e):function(e){const t=e.length;var i=new r(\"\",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var s=new Array(256),o=new Array(256),a=new Array(256),c=0;c<256;c++)o[c]=new Array(256),a[c]=new Array(256);for(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3}(e,o,s),function(e,t){for(var i=0;i<256;i++)t[i]&&f(e[i])}(o,s),function(e,t,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(e.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,e.WriteByte(n)}p(e,t[r])}e.WriteByte(0)}(i,o,s),c=0;c<256;c++)if(s[c]){a[c][0]=0;for(var l=1;l<256;l++)a[c][l]=a[c][l-1]+o[c][l-1]}var u=new Array(4),g=new Array(4);for(l=0;l<4;l++)u[l]=1<<23,g[l]=0;var m=new r(\"\",t,t),w=Math.floor(t/4),b=new Array(4),F=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*w-2,F[l]=e[b[l]+1];for(F[3]=e[t-1],c=t-2;c>4*w-2;c--)u[3]=d(u[3],m,a[e[c]][F[3]],o[e[c]][F[3]],12),F[3]=e[c];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=e[b[l]];u[l]=d(u[l],m,a[v][F[l]],o[v][F[l]],12),F[l]=v,b[l]--}for(l=3;l>=0;l--)u[l]=d(u[l],m,a[0][F[l]],o[0][F[l]],12);for(c=3;c>=0;c--)h(u[c],m);var y=i.pos;return i.buf.writeInt32LE(y-9+(m.length-m.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e)}}},8223:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e,t){return e&(1<=e[i+1];)i++;return i}function a(e,t){for(var i=1<=e[r+1];)r++;n[s]=r}return n}function c(e,t,i,n){return i*(e>>n)+(e&(1<>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<31-n)*i;e>=r;)t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e),e>>=16;return e}(e,t,n,r),(Math.floor(e/n)<o),n[o]=new Array(s[o]);for(var a=0,c=0;co),a[o]=f(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o>4,h=e;if(1&f){var d=e.ReadUint7(),u=e.ReadUint7(),f=new r(e.ReadData(u));h=new r(m(f,d))}var p=new Array(256),w=new Array(256);!function(e,t,i,n){for(var r=0;r<256;r++){t[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)t[r][s]=0}var o=g(e);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(t[r][s]=e.ReadUint7(),0==t[r][s]&&(a=e.ReadByte())));for(b(t[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+t[r][s]}}(h,p,w,i);for(var F=new Array(256),v=0;v<256;v++)F[v]=a(w[v],i);for(var y=new Array(4),A=new Array(4),C=0;C<4;C++)y[C]=e.ReadUint32(),A[C]=0;var _=new n.allocUnsafe(t),x=Math.floor(t/4);for(v=0;v>=1}else if(i<=4)for(a=0;a>=2;else if(i<=16)for(a=0;a>=4;return s}(x,v,y,F)),x}function p(e,t){var i=new r(\"\",0,10);i.WriteByte(t);var s=1&t,o=8&t,a=32&t,c=64&t,l=128&t,f=t>>8;if(16&t||i.WriteUint7(e.length),o)return n.concat([i.buf.slice(0,i.pos),u(0,e,f)]);var p=new n.alloc(0);l&&([p,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;for(i=0;i0&&(s[i]=o++);if(!(o>16)){if(o<=1)var a=new n.allocUnsafe(0);else if(o<=2){a=new n.allocUnsafe(Math.ceil(e.length/8));var c=-1;for(i=0;i0&&(t[i]=c++,l.WriteByte(i));return l.WriteUint7(a.length),[l.buf.slice(0,l.pos),a]}}(e));var g=new n.alloc(0);if(c&&([g,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var s=-1;for(i=0;i0&&o++;for(o||(o=1,t[0]=1),(h=new r(\"\",0,o+1+e.length)).WriteByte(o),i=0;i<256;i++)t[i]>0&&h.WriteByte(i);var a=new n.allocUnsafe(e.length),c=0;for(i=0;i0){s=e[i];for(var l=0;i+l+1>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3})(e,o,s),function(e,t){for(var i=0;i<256;i++)if(t[i]){var n=Math.ceil(Math.log2(t[i]));n>12&&(n=12),w(e[i],n)}}(o,s);var l=new r(\"\",0,198156);!function(e,t,i){F(e,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(e.WriteUint7(t[n][s]),!t[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=t[n][o])break;r++}e.WriteByte(r)}}(l,o,s);var u=v(l.buf.slice(0,l.pos));for(u.length4*y-2;c--)p[3]=d(p[3],m,a[e[c]][C[3]],o[e[c]][C[3]],12),C[3]=e[c];for(;A[0]>=0;)for(f=3;f>=0;f--){var _=e[A[f]];p[f]=d(p[f],m,a[_][C[f]],o[_][C[f]],12),C[f]=_,A[f]--}for(f=3;f>=0;f--)p[f]=d(p[f],m,a[0][C[f]],o[0][C[f]],12);for(c=3;c>=0;c--)h(p[c],m);return n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e);return n.concat([i.buf.slice(0,i.pos),p,g,m])}function g(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var n=0,r=e.ReadByte(),s=r;do{t[r]=1,n>0?(n--,r++):(r=e.ReadByte())==s+1&&(n=e.ReadByte()),s=r}while(0!=r);return t}function m(e,t){var i=new Array(256),r=new Array(256);!function(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=g(e);for(n=0;n<256;n++)r[n]>0&&(t[n]=e.ReadUint7());for(b(t,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}(e,i,r);for(var o=a(r,12),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var u=new n.allocUnsafe(t);for(d=0;d2?e[a]-=i-r:i!=r&&(s=r/i,c=1)}while(c)}function b(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];if(0!=i&&i!=1<0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteByte(0)}function v(e){const t=e.length;var i=new r(\"\",0,780),s=new Array(256);!function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i12&&(o=12),w(s,o),function(e,t){F(e,t);for(var i=0;i<256;i++)t[i]&&e.WriteUint7(t[i])}(i,s),w(s,12);var a=new Array(256);a[0]=0;for(var c=1;c<256;c++)a[c]=a[c-1]+s[c-1];var l=new Array(4);for(c=0;c<4;c++)l[c]=32768;var u=new r(\"\",1.05*t+100|0,1.05*t+100|0);for(c=t-1;c>=0;c--)l[c%4]=d(l[c%4],u,a[e[c]],s[e[c]],12);for(c=3;c>=0;c--)h(l[c],u);return n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}e.exports={decode:function(e){return f(new r(e),0)},encode:p}},5997:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(8223);var o=new(i(635));function a(e,t){for(var i=e+\"\";i.length0&&5==t[o][0].type)&&t[o][i])switch(e[0].WriteByte(t[o][i].type),t[o][i].type){case 6:e[6].WriteUint32(t[o][i].val);break;case 5:e[5].WriteUint32(t[o][i].val);break;case 1:e[1].WriteString(t[o][i].val);break;case 2:e[2].WriteChar(t[o][i].val);break;case 7:e[7].WriteUint32(t[o][i].val);break;case 3:e[3].WriteUint32(t[o][i].val),e[4].WriteByte(t[o][i].val.length);break;case 8:case 9:e[t[o][i].type].WriteByte(t[o][i].val)}}function h(e,t,i,n){for(var r=0;r<=12;r++)if(!(e[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),e[r]=e[r].buf.slice(0,e[r].pos);var s=d(e[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function d(e,t){var i,n=1<<30,r=[0,1,64,65,128,129,201];for(var a in r){var c=r[a];if(!(1&c&&e.length<100||8&c&&e.length%4!=0)){try{var l=t?o.encode(e,c):s.encode(e,c)}catch(e){l=0}l&&n>l.length&&(n=l.length,i=l)}}return i}function u(e,t,i,n,r){var s=0,o=r-1;e[r]=new Array(256),t[n]?e[r][0]={type:5,val:r-t[n]}:e[r][0]={type:6,val:0==r?0:1},t[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),c=0;c=0&&e[o][l])if(e[o][l].str==a[c])h=10,d=\"\";else if(7==e[o][l].type||8==e[o][l].type){var u=d-e[o][l].str;i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=8,d=u)}else 3!=e[o][l].type&&9!=e[o][l].type||e[o][l].str.length!=d.length||(u=d-e[o][l].str,i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=9,d=u));e[r][l]={str:a[c],val:d,type:h},s{t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),o=s[0],c=s[1],l=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,c)),h=0,d=c>0?o-4:o;for(i=0;i>16&255,l[h++]=t>>8&255,l[h++]=255&t;return 2===c&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,l[h++]=255&t),1===c&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,l=n-r;al?l:a+o));return 1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+\"==\")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+\"=\")),s.join(\"\")};for(var i=[],n=[],r=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function c(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},8287:(e,t,i)=>{const n=i(7526),r=i(251),s=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return d(e)}return l(e,t,i)}function l(e,t,i){if(\"string\"==typeof e)return function(e,t){if(\"string\"==typeof t&&\"\"!==t||(t=\"utf8\"),!c.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|g(e,t);let n=a(i);const r=n.write(e,t);return r!==i&&(n=n.slice(0,r)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,i);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?\"number\"!=typeof e.length||Y(e.length)?a(0):u(e):\"Buffer\"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function h(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function d(e){return h(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),i=a(t);for(let n=0;n=o)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o.toString(16)+\" bytes\");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return W(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return G(e).length;default:if(r)return n?-1:W(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function m(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return N(this,t,i);case\"utf8\":case\"utf-8\":return k(this,t,i);case\"ascii\":return S(this,t,i);case\"latin1\":case\"binary\":return E(this,t,i);case\"base64\":return x(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return B(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function w(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function b(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Y(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:F(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):F(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function F(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function x(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function k(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!c.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;ti&&(e+=\" ... \"),\"\"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,i,n,r){if(K(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),l=this.slice(n,r),h=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return v(this,e,t,i);case\"utf8\":case\"utf-8\":return y(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return A(this,e,t,i);case\"base64\":return C(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return _(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function S(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function R(e,t,i,n,r,s){if(!c.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function D(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function T(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function L(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function z(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,4),r.write(e,t,i,n,23,4),i+4}function H(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,8),r.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||M(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return D(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return T(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return D(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return T(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(e,t,i){return z(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return z(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return H(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return H(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(!c.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function q(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new P.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Q(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||V(t,e.length-(i+1))}(n,r,s)}function Q(e,t){if(\"number\"!=typeof e)throw new P.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function V(e,t,i){if(Math.floor(e)!==e)throw Q(e,i),new P.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}O(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),O(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),O(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=U(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=U(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function W(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(e){return n.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(j,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function $(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}const X=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Z(e){return\"undefined\"==typeof BigInt?J:e}function J(){throw new Error(\"BigInt not supported\")}},235:e=>{var t={array:function(e){var t=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-t;r>=o?(s<<=o,s|=n[o]&e[i++],t=0,r-=o):(s<<=r,s|=(e[i]&n[r]<<8-r-t)>>8-r-t,t+=r,r=0)}return s}},simple:function(e){var i,n,r=t.header(e),s=[],o=0;do{-1!=(n=t.decompress(e,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a9)throw\"Not a BZIP archive\";return t},decompress:function(e,t,i){for(var n=9e5,r=\"\",s=0;s<6;s++)r+=e(8).toString(16);if(\"177245385090\"==r)return-1;if(\"314159265359\"!=r)throw\"eek not valid bzip data\";if(e(32),e(1))throw\"unsupported obsolete version\";var o=e(24);if(o>n)throw\"Initial position larger than buffer size\";var a=e(16),c=new Uint8Array(256),l=0;for(s=0;s<16;s++)if(a&1<<15-s){var h=e(16);for(g=0;g<16;g++)h&1<<15-g&&(c[l++]=16*s+g)}var d=e(3);if(d<2||d>6)throw\"another error\";var u=e(15);if(0==u)throw\"meh\";var f=[];for(s=0;s=d)throw\"whoops another error\";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var w=l+2,b=[];for(g=0;g20)throw\"I gave up a while ago on writing error messages\";if(!e(1))break;e(1)?a--:a++}A[s]=a}for(F=v=A[0],s=1;sv?v=A[s]:A[s]=u)throw\"meow i'm a kitty, that's an error\";_=(y=b[p[E++]]).base.subarray(1),x=y.limit.subarray(1)}for(g=e(s=y.minLen);;){if(s>y.maxLen)throw\"rawr i'm a dinosaur\";if(g<=x[s])break;s++,g=g<<1|e(1)}if((g-=_[s])<0||g>=258)throw\"moo i'm a cow\";var M=y.permute[g];if(0!=M&&1!=M){if(I){if(I=0,S+a>=n)throw\"Boom.\";for(N[m=c[f[0]]]+=a;a--;)B[S++]=m}if(M>l)break;if(S>=n)throw\"I can't think of anything. Error\";m=f[s=M-1],f.splice(s,1),f.splice(0,0,m),N[m=c[m]]++,B[S++]=m}else I||(I=1,a=0),a+=0==M?I:2*I,I<<=1}if(o<0||o>=S)throw\"I'm a monkey and I'm throwing something at someone, namely you\";for(g=0,s=0;s<256;s++)h=g+N[s],N[s]=g,g=h;for(s=0;s>=8,T=-1);var L,z,H,P=new Uint8Array(n),O=0;for(i||(i=1/0);S;){for(S--,z=D,D=255&(R=B[R]),R>>=8,3==T++?(L=D,H=z,D=-1):(L=1,H=D);L--;)if(P[O++]=H,! --i)return P;D!=z&&(T=0)}return P.subarray(0,O)}};e.exports=t},2151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],i=0;i{var t,i;t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",i={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&i.rotl(e,8)|4278255360&i.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],i=0,n=0;i>>5]|=e[i]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],i=0;i<32*e.length;i+=8)t.push(e[i>>>5]>>>24-i%32&255);return t},bytesToHex:function(e){for(var t=[],i=0;i>>4).toString(16)),t.push((15&e[i]).toString(16));return t.join(\"\")},hexToBytes:function(e){for(var t=[],i=0;i>>6*(3-s)&63)):i.push(\"=\");return i.join(\"\")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,\"\");for(var i=[],n=0,r=0;n>>6-2*r);return i}},e.exports=i},1113:(e,t,i)=>{i.r(t),i.d(t,{BlobFile:()=>l,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>h,open:()=>d});var n=i(3617),r=i.n(n),s=i(8287);function o(e){return(\"object\"==typeof e&&null!==e&&\"message\"in e?e.message:`${e}`).replace(/\\.$/,\"\")}class a{async getBufferFromResponse(e){const t=await e.arrayBuffer();return s.Buffer.from(t)}constructor(e,t={}){this.baseOverrides={},this.url=e;const i=t.fetch||globalThis.fetch.bind(globalThis);if(!i)throw new TypeError(\"no fetch function supplied, and none found in global environment\");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=i}async fetch(e,t){let i;try{i=await this.fetchImplementation(e,t)}catch(n){if(!`${n}`.includes(\"Failed to fetch\"))throw new Error(`${o(n)} fetching ${e}`,{cause:n});console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`);try{i=await this.fetchImplementation(e,{...t,cache:\"reload\"})}catch(t){throw new Error(`${o(t)} fetching ${e}`,{cause:t})}}return i}async read(e,t=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const c=await this.fetch(this.url,{...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:o});if(!c.ok)throw new Error(`HTTP ${c.status} fetching ${this.url}`);if(200===c.status&&0===n||206===c.status){const n=await this.getBufferFromResponse(c),r=n.copy(e,t,0,Math.min(i,n.length)),s=c.headers.get(\"content-range\"),o=/\\/(\\d+)$/.exec(s||\"\");return(null==o?void 0:o[1])&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:e}}if(200===c.status)throw new Error(`${this.url} fetch returned status 200, expected 206`);throw new Error(`HTTP ${c.status} fetching ${this.url}`)}async readFile(e={}){let t,i;\"string\"==typeof e?(t=e,i={}):(t=e.encoding,i=e,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o=await this.fetch(this.url,{headers:n,method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:r,...this.baseOverrides,...s});if(200!==o.status)throw new Error(`HTTP ${o.status} fetching ${this.url}`);if(\"utf8\"===t)return o.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(o)}async stat(){if(!this._stat){const e=s.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function c(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"!=typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsArrayBuffer(e)}))}class l{constructor(e){this.blob=e,this.size=e.size}async read(e,t=0,i,n=0){if(!i)return{bytesRead:0,buffer:e};const r=n,o=r+i,a=await c(this.blob.slice(r,o)),l=s.Buffer.from(a);return{bytesRead:l.copy(e,t),buffer:l}}async readFile(e){const t=\"string\"==typeof e?e:null==e?void 0:e.encoding;if(\"utf8\"===t)return function(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"==typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsText(e)}))}(this.blob);if(t)throw new Error(`unsupported encoding: ${t}`);const i=await c(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function h(e,t={}){return new a(e,t)}function d(e,t,i,n={}){if(void 0!==i)return i;if(void 0!==e)return h(e,n);if(void 0!==t)return new(r())(t,n);throw new Error(\"no url, path, or filehandle provided, cannot open\")}},251:(e,t)=>{t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}},8570:e=>{e.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,\"__isLong__\",{value:!0}),i.isLong=n;var r={},s={};function o(e,t){var i,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(i=c(e,(0|e)<0?-1:0,!0),o&&(s[e]=i),i):(o=-128<=(e|=0)&&e<128)&&(n=r[e])?n:(i=c(e,e<0?-1:0,!1),o&&(r[e]=i),i)}function a(e,t){if(isNaN(e))return t?w:m;if(t){if(e<0)return w;if(e>=f)return A}else{if(e<=-p)return C;if(e+1>=p)return y}return e<0?a(-e,t).neg():c(e%u|0,e/u|0,t)}function c(e,t,n){return new i(e,t,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=c;var l=Math.pow;function h(e,t,i){if(0===e.length)throw Error(\"empty string\");if(\"NaN\"===e||\"Infinity\"===e||\"+Infinity\"===e||\"-Infinity\"===e)return m;if(\"number\"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||360)throw Error(\"interior hyphen\");if(0===n)return h(e.substring(1),t,i).neg();for(var r=a(l(i,8)),s=m,o=0;o>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=c).isZero())return h+o;for(;h.length<6;)h=\"0\"+h;o=\"\"+h+o}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(C)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.ne=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.le=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.ge=_.greaterThanOrEqual,_.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(b)},_.neg=_.negate,_.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,a=65535&e.high,l=e.low>>>16,h=0,u=0,f=0,p=0;return f+=(p+=s+(65535&e.low))>>>16,u+=(f+=r+l)>>>16,h+=(u+=i+a)>>>16,h+=t+o,c((f&=65535)<<16|(p&=65535),(h&=65535)<<16|(u&=65535),this.unsigned)},_.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return m;if(n(e)||(e=d(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(C))return e.isOdd()?C:m;if(e.eq(C))return this.isOdd()?C:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return a(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,l=e.high>>>16,h=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,w=0,b=0,F=0;return b+=(F+=o*f)>>>16,w+=(b+=s*f)>>>16,b&=65535,w+=(b+=o*u)>>>16,p+=(w+=r*f)>>>16,w&=65535,p+=(w+=s*u)>>>16,w&=65535,p+=(w+=o*h)>>>16,p+=i*f+r*u+s*h+o*l,c((b&=65535)<<16|(F&=65535),(p&=65535)<<16|(w&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error(\"division by zero\");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return w;if(e.gt(this.shru(1)))return F;s=w}else{if(this.eq(C))return e.eq(b)||e.eq(v)?C:e.eq(C)?b:(i=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?b:v:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(C))return this.unsigned?w:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=m}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),h=o<=48?1:l(2,o-48),u=a(i),f=u.mul(e);f.isNegative()||f.gt(r);)f=(u=a(i-=h,this.unsigned)).mul(e);u.isZero()&&(u=b),s=s.add(u),r=r.sub(f)}return s},_.div=_.divide,_.modulo=function(e){return n(e)||(e=d(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.rem=_.modulo,_.not=function(){return c(~this.low,~this.high,this.unsigned)},_.and=function(e){return n(e)||(e=d(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return n(e)||(e=d(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return n(e)||(e=d(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low<>>32-e,this.unsigned):c(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?c(this.low>>>e|t<<32-e,t>>>e,this.unsigned):c(32===e?t:t>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.shr_u=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},_.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},3503:(e,t,i)=>{var n,r,s,o,a;n=i(3939),r=i(2151).utf8,s=i(652),o=i(2151).bin,(a=function(e,t){e.constructor==String?e=t&&\"binary\"===t.encoding?o.stringToBytes(e):r.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var i=n.bytesToWords(e),c=8*e.length,l=1732584193,h=-271733879,d=-1732584194,u=271733878,f=0;f>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[c>>>5]|=128<>>9<<4)]=c;var p=a._ff,g=a._gg,m=a._hh,w=a._ii;for(f=0;f>>0,h=h+F>>>0,d=d+v>>>0,u=u+y>>>0}return n.endian([l,h,d,u])})._ff=function(e,t,i,n,r,s,o){var a=e+(t&i|~t&n)+(r>>>0)+o;return(a<>>32-s)+t},a._gg=function(e,t,i,n,r,s,o){var a=e+(t&n|i&~n)+(r>>>0)+o;return(a<>>32-s)+t},a._hh=function(e,t,i,n,r,s,o){var a=e+(t^i^n)+(r>>>0)+o;return(a<>>32-s)+t},a._ii=function(e,t,i,n,r,s,o){var a=e+(i^(t|~n))+(r>>>0)+o;return(a<>>32-s)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error(\"Illegal argument \"+e);var i=n.wordsToBytes(a(e,t));return t&&t.asBytes?i:t&&t.asString?o.bytesToString(i):n.bytesToHex(i)}},652:e=>{function t(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return\"function\"==typeof e.readFloatLE&&\"function\"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},1668:(e,t,i)=>{var n={};(0,i(9805).assign)(n,i(3303),i(7083),i(9681)),e.exports=n},3303:(e,t,i)=>{var n=i(8411),r=i(9805),s=i(1996),o=i(4674),a=i(4442),c=Object.prototype.toString,l=0,h=-1,d=0,u=8;function f(e){if(!(this instanceof f))return new f(e);this.options=r.assign({level:h,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==l)throw new Error(o[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p=\"string\"==typeof t.dictionary?s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=n.deflateSetDictionary(this.strm,p))!==l)throw new Error(o[i]);this._dict_set=!0}}function p(e,t){var i=new f(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}f.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,\"string\"==typeof e?a.input=s.string2buf(e):\"[object ArrayBuffer]\"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&i!==l)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||(\"string\"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===l):2!==o||(this.onEnd(l),a.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===l&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},7083:(e,t,i)=>{var n=i(1447),r=i(9805),s=i(1996),o=i(9681),a=i(4674),c=i(4442),l=i(7414),h=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new l,n.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===h.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[i])}function u(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(e,t){var i,a,c,l,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,\"string\"==typeof e?u.input=s.binstring2buf(e):\"[object ArrayBuffer]\"===h.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new r.Buf8(f),u.next_out=0,u.avail_out=f),(i=n.inflate(u,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==o.Z_STREAM_END&&(0!==u.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||(\"string\"===this.options.to?(c=s.utf8border(u.output,u.next_out),l=u.next_out-c,d=s.buf2string(u.output,c),u.next_out=l,u.avail_out=f-l,l&&r.arraySet(u.output,u.output,c,l,0),this.onData(d)):this.onData(r.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=d,t.inflate=u,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.ungzip=u},9805:(e,t)=>{var i=\"undefined\"!=typeof Uint8Array&&\"undefined\"!=typeof Uint16Array&&\"undefined\"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,n,r){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),r);else for(var s=0;s{var n=i(9805),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var i=\"\",o=0;o>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},t.buf2binstring=function(e){return c(e,e.length)},t.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i4)l[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?l[n++]=65533:r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|1023&r)}return c(l,n)},t.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},3269:e=>{e.exports=function(e,t,i,n){for(var r=65535&e,s=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16}},9681:e=>{e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:e=>{var t=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();e.exports=function(e,i,n,r){var s=t,o=r+n;e^=-1;for(var a=r;a>>8^s[255&(e^i[a])];return~e}},8411:(e,t,i)=>{var n,r=i(9805),s=i(3665),o=i(3269),a=i(4823),c=i(4674),l=0,h=0,d=-2,u=2,f=8,p=286,g=30,m=19,w=2*p+1,b=15,F=3,v=258,y=v+F+1,A=42,C=103,_=113,x=666;function k(e,t){return e.msg=c[t],t}function I(e){return(e<<1)-(e>4?9:0)}function S(e){for(var t=e.length;--t>=0;)e[t]=0}function E(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function N(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,E(e.strm)}function B(e,t){e.pending_buf[e.pending++]=t}function M(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function R(e,t,i,n){var s=e.avail_in;return s>n&&(s=n),0===s?0:(e.avail_in-=s,r.arraySet(t,e.input,e.next_in,s,i),1===e.state.wrap?e.adler=o(e.adler,t,s,i):2===e.state.wrap&&(e.adler=a(e.adler,t,s,i)),e.next_in+=s,e.total_in+=s,s)}function D(e,t){var i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-y?e.strstart-(e.w_size-y):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+v,f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead}function T(e){var t,i,n,s,o,a=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-y)){r.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=i=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--i);t=i=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--i);s+=a}if(0===e.strm.avail_in)break;if(i=R(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=F)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<=F)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-F,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<15&&(a=2,n-=16),s<1||s>9||i!==f||n<8||n>15||t<0||t>9||o<0||o>4)return k(e,d);8===n&&(n=9);var c=new P;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=n,c.w_size=1<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(T(e),0===e.lookahead&&t===l)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-y&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),1)})),new H(4,4,8,4,L),new H(4,5,16,8,L),new H(4,6,32,32,L),new H(4,4,16,16,z),new H(8,16,32,32,z),new H(8,16,128,128,z),new H(8,32,128,256,z),new H(32,128,258,1024,z),new H(32,258,258,4096,z)],t.deflateInit=function(e,t){return q(e,t,f,15,8,0)},t.deflateInit2=q,t.deflateReset=U,t.deflateResetKeep=O,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?d:(e.state.gzhead=t,h):d},t.deflate=function(e,t){var i,r,o,c;if(!e||!e.state||t>5||t<0)return e?k(e,d):d;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===x&&4!==t)return k(e,0===e.avail_out?-5:d);if(r.strm=e,i=r.last_flush,r.last_flush=t,r.status===A)if(2===r.wrap)e.adler=0,B(r,31),B(r,139),B(r,8),r.gzhead?(B(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),B(r,255&r.gzhead.time),B(r,r.gzhead.time>>8&255),B(r,r.gzhead.time>>16&255),B(r,r.gzhead.time>>24&255),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(B(r,255&r.gzhead.extra.length),B(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(B(r,0),B(r,0),B(r,0),B(r,0),B(r,0),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,3),r.status=_);else{var u=f+(r.w_bits-8<<4)<<8;u|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(u|=32),u+=31-u%31,r.status=_,M(r,u),0!==r.strstart&&(M(r,e.adler>>>16),M(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending!==r.pending_buf_size));)B(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.status=C)}else r.status=C;if(r.status===C&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&E(e),r.pending+2<=r.pending_buf_size&&(B(r,255&e.adler),B(r,e.adler>>8&255),e.adler=0,r.status=_)):r.status=_),0!==r.pending){if(E(e),0===e.avail_out)return r.last_flush=-1,h}else if(0===e.avail_in&&I(t)<=I(i)&&4!==t)return k(e,-5);if(r.status===x&&0!==e.avail_in)return k(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==l&&r.status!==x){var p=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(T(e),0===e.lookahead)){if(t===l)return 1;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,n,r,o,a=e.window;;){if(e.lookahead<=v){if(T(e),e.lookahead<=v&&t===l)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&e.strstart>0&&(n=a[r=e.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=e.strstart+v;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=s._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):n[r.level].func(r,t);if(3!==p&&4!==p||(r.status=x),1===p||3===p)return 0===e.avail_out&&(r.last_flush=-1),h;if(2===p&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(S(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),E(e),0===e.avail_out))return r.last_flush=-1,h}return 4!==t?h:r.wrap<=0?1:(2===r.wrap?(B(r,255&e.adler),B(r,e.adler>>8&255),B(r,e.adler>>16&255),B(r,e.adler>>24&255),B(r,255&e.total_in),B(r,e.total_in>>8&255),B(r,e.total_in>>16&255),B(r,e.total_in>>24&255)):(M(r,e.adler>>>16),M(r,65535&e.adler)),E(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?h:1)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==A&&69!==t&&73!==t&&91!==t&&t!==C&&t!==_&&t!==x?k(e,d):(e.state=null,t===_?k(e,-3):h):d},t.deflateSetDictionary=function(e,t){var i,n,s,a,c,l,u,f,p=t.length;if(!e||!e.state)return d;if(2===(a=(i=e.state).wrap)||1===a&&i.status!==A||i.lookahead)return d;for(1===a&&(e.adler=o(e.adler,t,p,0)),i.wrap=0,p>=i.w_size&&(0===a&&(S(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new r.Buf8(i.w_size),r.arraySet(f,t,p-i.w_size,i.w_size,0),t=f,p=i.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,T(i);i.lookahead>=F;){n=i.strstart,s=i.lookahead-(F-1);do{i.ins_h=(i.ins_h<{e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}},7293:e=>{e.exports=function(e,t){var i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x,k;i=e.state,n=e.next_in,x=e.input,r=n+(e.avail_in-5),s=e.next_out,k=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,w=(1<>>=v=F>>>24,p-=v,0==(v=F>>>16&255))k[s++]=65535&F;else{if(!(16&v)){if(64&v){if(32&v){i.mode=12;break e}e.msg=\"invalid literal/length code\",i.mode=30;break e}F=g[(65535&F)+(f&(1<>>=v,p-=v),p<15&&(f+=x[n++]<>>=v=F>>>24,p-=v,16&(v=F>>>16&255)){if(A=65535&F,p<(v&=15)&&(f+=x[n++]<c){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(f>>>=v,p-=v,A>(v=s-o)){if((v=A-v)>h&&i.sane){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(C=0,_=u,0===d){if(C+=l-v,v2;)k[s++]=_[C++],k[s++]=_[C++],k[s++]=_[C++],y-=3;y&&(k[s++]=_[C++],y>1&&(k[s++]=_[C++]))}else{C=s-A;do{k[s++]=k[C++],k[s++]=k[C++],k[s++]=k[C++],y-=3}while(y>2);y&&(k[s++]=k[C++],y>1&&(k[s++]=k[C++]))}break}if(64&v){e.msg=\"invalid distance code\",i.mode=30;break e}F=m[(65535&F)+(f&(1<>3,f&=(1<<(p-=y<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n{var n=i(9805),r=i(3269),s=i(4823),o=i(7293),a=i(1998),c=0,l=-2,h=1,d=12,u=30,f=852,p=592;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(f),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,c):l}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,w(e)):l}function F(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,b(e))):l}function v(e,t){var i,n;return e?(n=new m,e.state=n,n.window=null,(i=F(e,t))!==c&&(e.state=null),i):l}var y,A,C=!0;function _(e){if(C){var t;for(y=new n.Buf32(512),A=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,y,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,A,0,e.work,{bits:5}),C=!1}e.lencode=y,e.lenbits=9,e.distcode=A,e.distbits=5}function x(e,t,i,r){var s,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(n.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,t,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,t,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=s(i.check,O,2,0),v=0,y=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg=\"incorrect header check\",i.mode=u;break}if(8!=(15&v)){e.msg=\"unknown compression method\",i.mode=u;break}if(y-=4,T=8+(15&(v>>>=4)),0===i.wbits)i.wbits=T;else if(T>i.wbits){e.msg=\"invalid window size\",i.mode=u;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=3;case 3:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>8&255,O[2]=v>>>16&255,O[3]=v>>>24&255,i.check=s(i.check,O,4,0)),v=0,y=0,i.mode=4;case 4:for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>8),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=5;case 5:if(1024&i.flags){for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((k=i.length)>b&&(k=b),k&&(i.head&&(T=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,f,m,k,T)),512&i.flags&&(i.check=s(i.check,f,k,m)),b-=k,m+=k,i.length-=k),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===b)break e;k=0;do{T=f[m+k++],i.head&&T&&i.length<65536&&(i.head.name+=String.fromCharCode(T))}while(T&&k>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=d;break;case 10:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>=7&y,y-=7&y,i.mode=27;break}for(;y<3;){if(0===b)break e;b--,v+=f[m++]<>>=1)){case 0:i.mode=14;break;case 1:if(_(i),i.mode=20,6===t){v>>>=2,y-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=u}v>>>=2,y-=2;break;case 14:for(v>>>=7&y,y-=7&y;y<32;){if(0===b)break e;b--,v+=f[m++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=u;break}if(i.length=65535&v,v=0,y=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(k=i.length){if(k>b&&(k=b),k>F&&(k=F),0===k)break e;n.arraySet(p,f,m,k,w),b-=k,m+=k,F-=k,w+=k,i.length-=k;break}i.mode=d;break;case 17:for(;y<14;){if(0===b)break e;b--,v+=f[m++]<>>=5,y-=5,i.ndist=1+(31&v),v>>>=5,y-=5,i.ncode=4+(15&v),v>>>=4,y-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=u;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,y-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,z={bits:i.lenbits},L=a(0,i.lens,0,19,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid code lengths set\",i.mode=u;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=E,y-=E,i.lens[i.have++]=B;else{if(16===B){for(H=E+2;y>>=E,y-=E,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=u;break}T=i.lens[i.have-1],k=3+(3&v),v>>>=2,y-=2}else if(17===B){for(H=E+3;y>>=E)),v>>>=3,y-=3}else{for(H=E+7;y>>=E)),v>>>=7,y-=7}if(i.have+k>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=u;break}for(;k--;)i.lens[i.have++]=T}}if(i.mode===u)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=u;break}if(i.lenbits=9,z={bits:i.lenbits},L=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid literal/lengths set\",i.mode=u;break}if(i.distbits=6,i.distcode=i.distdyn,z={bits:i.distbits},L=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,z),i.distbits=z.bits,L){e.msg=\"invalid distances set\",i.mode=u;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(b>=6&&F>=258){e.next_out=w,e.avail_out=F,e.next_in=m,e.avail_in=b,i.hold=v,i.bits=y,o(e,C),w=e.next_out,p=e.output,F=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,v=i.hold,y=i.bits,i.mode===d&&(i.back=-1);break}for(i.back=0;N=(P=i.lencode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,i.length=B,0===N){i.mode=26;break}if(32&N){i.back=-1,i.mode=d;break}if(64&N){e.msg=\"invalid literal/length code\",i.mode=u;break}i.extra=15&N,i.mode=22;case 22:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;N=(P=i.distcode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,64&N){e.msg=\"invalid distance code\",i.mode=u;break}i.offset=B,i.extra=15&N,i.mode=24;case 24:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=u;break}i.mode=25;case 25:if(0===F)break e;if(k=C-F,i.offset>k){if((k=i.offset-k)>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=u;break}k>i.wnext?(k-=i.wnext,I=i.wsize-k):I=i.wnext-k,k>i.length&&(k=i.length),S=i.window}else S=p,I=w-i.offset,k=i.length;k>F&&(k=F),F-=k,i.length-=k;do{p[w++]=S[I++]}while(--k);0===i.length&&(i.mode=21);break;case 26:if(0===F)break e;p[w++]=i.length,F--,i.mode=21;break;case 27:if(i.wrap){for(;y<32;){if(0===b)break e;b--,v|=f[m++]<{var n=i(9805),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,i,c,l,h,d,u){var f,p,g,m,w,b,F,v,y,A=u.bits,C=0,_=0,x=0,k=0,I=0,S=0,E=0,N=0,B=0,M=0,R=null,D=0,T=new n.Buf16(16),L=new n.Buf16(16),z=null,H=0;for(C=0;C<=15;C++)T[C]=0;for(_=0;_=1&&0===T[k];k--);if(I>k&&(I=k),0===k)return l[h++]=20971520,l[h++]=20971520,u.bits=1,0;for(x=1;x0&&(0===e||1!==k))return-1;for(L[1]=0,C=1;C<15;C++)L[C+1]=L[C]+T[C];for(_=0;_852||2===e&&B>592)return 1;for(;;){F=C-E,d[_]b?(v=z[H+d[_]],y=R[D+d[_]]):(v=96,y=0),f=1<>E)+(p-=f)]=F<<24|v<<16|y}while(0!==p);for(f=1<>=1;if(0!==f?(M&=f-1,M+=f):M=0,_++,0==--T[C]){if(C===k)break;C=t[i+d[_]]}if(C>I&&(M&m)!==g){for(0===E&&(E=I),w+=x,N=1<<(S=C-E);S+E852||2===e&&B>592)return 1;l[g=M&m]=I<<24|S<<16|w-h}}return 0!==M&&(l[w+M]=C-E<<24|64<<16),u.bits=I,0}},4674:e=>{e.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},3665:(e,t,i)=>{var n=i(9805);function r(e){for(var t=e.length;--t>=0;)e[t]=0}var s=15,o=16,a=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);r(d);var u=new Array(60);r(u);var f=new Array(512);r(f);var p=new Array(256);r(p);var g=new Array(29);r(g);var m,w,b,F=new Array(30);function v(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}function y(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?f[e]:f[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function _(e,t,i){e.bi_valid>o-i?(e.bi_buf|=t<>o-e.bi_valid,e.bi_valid+=i-o):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1}function I(e,t,i){var n,r,o=new Array(s+1),a=0;for(n=1;n<=s;n++)o[n]=a=a+i[n-1]<<1;for(r=0;r<=t;r++){var c=e[2*r+1];0!==c&&(e[2*r]=k(o[c]++,c))}}function S(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function E(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function N(e,t,i,n){var r=2*t,s=2*i;return e[r]>1;i>=1;i--)B(e,o,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],B(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,o[2*r]=o[2*i]+o[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,o[2*i+1]=o[2*n+1]=r,e.heap[1]=r++,B(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,o,a,c,l=t.dyn_tree,h=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(o=0;o<=s;o++)e.bl_count[o]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(o=l[2*l[2*(n=e.heap[i])+1]+1]+1)>g&&(o=g,m++),l[2*n+1]=o,n>h||(e.bl_count[o]++,a=0,n>=p&&(a=f[n-p]),c=l[2*n],e.opt_len+=c*(o+a),u&&(e.static_len+=c*(d[2*n+1]+a)));if(0!==m){do{for(o=g-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[g]--,m-=2}while(m>0);for(o=g;0!==o;o--)for(n=e.bl_count[o];0!==n;)(r=e.heap[--i])>h||(l[2*r+1]!==o&&(e.opt_len+=(o-l[2*r+1])*l[2*r],l[2*r+1]=o),n--)}}(e,t),I(o,h,e.bl_count)}function D(e,t,i){var n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a>=7;n<30;n++)for(F[n]=r<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),o=function(e){var t;for(D(e,e.dyn_ltree,e.l_desc.max_code),D(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?z(e,t,i,n):4===e.strategy||s===r?(_(e,2+(n?1:0),3),M(e,d,u)):(_(e,4+(n?1:0),3),function(e,t,i,n){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,n-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(p[i]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){_(e,2,3),x(e,256,d),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},4442:e=>{e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},7392:e=>{class t{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError(\"`maxSize` must be a number greater than 0\");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}e.exports=t},1307:function(e,t,i){var n;n=e=>(()=>{var t=[,e=>{e.exports=\"data:application/wasm;base64,AGFzbQEAAAABOApgAX8Bf2ABfwBgAABgA39/fwF/YAABf2ACf38AYAN/f34BfmACf38Bf2AEf39/fwF/YAN/f38AAyEgAAABAgMDAwMEAQUAAgMCBgcIBwUDAAMHAQcABwcBAwkFAwEAAgYIAX8BQfCgBAsHTgUGbWVtb3J5AgAOY3JlYXRlX2NvbnRleHQACA9kZXN0cm95X2NvbnRleHQACQxzdXBwbHlfaW5wdXQACg9nZXRfbmV4dF9vdXRwdXQACwqNYCDfAgEFf0EAIQECQCAAQQdqIgJBEEkNAEEBIQEgAkEDdiIDQQJGDQBBAiEBIAJBIEkNAEEDIQEgA0EERg0AQQQhASACQTBJDQBBBSEBIANBBkYNAEEGIQEgAkHIAEkNAEEHIQEgAkHYAEkNAEEIIQEgAkGIAUkNAEEJIQEgAkGIAkkNACAAEIGAgIAAIgBBCGpBACAAGw8LAkACQCABQQJ0QcCIgIAAaiIEKAIAIgANAEEAIQACQAJAQQAoAuSIgIAAIgJFDQBBACACKAIANgLkiICAAAwBC0EAEIGAgIAAIgJFDQILIAJBgIB8cSIAIAJBCHZB/wFxIgJyIAE6AAAgAkEIdCAAckGAAmohAEEAIQJBACABQQJ0QYCIgIAAaigCACIDayEFIAMhAQNAIAAgBWoiACACNgIAIAAhAiABIANqIgFBgQJJDQALIAQgADYCAAsgBCAAKAIANgIACyAAC+4HAQd/AkACQAJAAkACQEEALQC0iICAAEUNAEEAQQA6ALSIgIAAQQAoArCIgIAAIgFFDQFBsIiAgAAhAgNAAkACQCABQQhqIgMgASgCBCIEaiIFQQh2Qf8BcSIGDQAgASECDAELAkADQCAFQYCAfHEgBmotAABB/gFHDQFBsIiAgAAhBgNAIAYiBygCACIGIAVHDQALIAcgBSgCADYCACABIAQgBSgCBGpBCGoiBDYCBCAHIAIgAiAFRhshAiADIARqIgVBCHZB/wFxIgYNAAsLIAIoAgAhAgsgAigCACIBDQALC0EAKAKwiICAACIFRQ0AIABBhwJqQYB+cSEDQX8hAkGwiICAACEEQQAhAUGwiICAACEGA0AgBiEHAkAgBSIGKAIEIgUgAEkNACAFIAJPDQAgBSECIAchBCAGIQEgBUEIaiADRw0AIAchBCAFIQIgBiEBDAQLIAYoAgAiBQ0ACyABDQIMAQtBsIiAgAAhBAs/AEEQdCEBIABBiAJqIQdBACEDAkACQEEAKAK4iICAACICRQ0AQQAhBSABIQYMAQtBACABQfCghIAAQf//A2pBgIB8cSIGayICNgK4iICAACACIQULAkAgByAFTQ0AIAcgBWsiByACQQF2IgIgAiAHSRtB//8DaiIHQRB2QABBf0YNAkEAQQAoAriIgIAAIAdBgIB8cSIDajYCuIiAgAALIAZFDQEgBkH/AToAASAGQQAoArCIgIAANgKAAiAGQYQCaiADIAVqQYCAfHFB+H1qIgI2AgAgBkGAAmohAQsgAUGAgHxxIgYgAUEIdkH/AXFyQf8BOgAAIAQgASgCADYCAAJAIAIgAGtBgH5xIgUNACABDwsgASEDAkAgBiABQQhqIgQgAmoiByAFQX9zakGAgHxxRg0AIARB//8DcSEFAkAgAEH3/QNLDQAgBiAEQQh2Qf8BcWpB/gE6AAAgAUEAKAKwiICAADYCACABQYCABCAFayIFNgIEQQAgATYCsIiAgAAQg4CAgAAgBkGEggRqIAIgBWtB+H1qIgU2AgAgBkGBgARqQf8BOgAAIAZBgIIEaiEDIAUgAGtBgH5xIQUMAQsgAiAFaiAAIAVqQX9qQYCAfHFrQYCAfGohBSABIQMLIAMgAygCBCAFazYCBCAFQfgBaiEGIAcgBWtBCHZB/wFxIQUCQANAIAYiB0GAfmohBiAFIgQNAUEBIQUgB0H4AUcNAAsLAkAgB0H4AUYNACACIAFqIAZrQYCAfHEiBSAEakH+AToAACAFIARBCHRqIgVBACgCsIiAgAA2AgAgBSAGNgIEQQAgBTYCsIiAgAAQg4CAgAALIAMPC0EAC3wBAn8CQCAARQ0AAkAgAEGAgHxxIABBCHZB/wFxciIBLQAAIgJB/wFHDQAgAEF4aiIAQQAoArCIgIAANgIAQQAgADYCsIiAgAAgAUH+AToAAEEAQQE6ALSIgIAADwsgACACQQJ0QcCIgIAAaiICKAIANgIAIAIgADYCAAsLawECfwJAQQAoArCIgIAAIgAoAgRB/wFLDQAgAEGAgHxxIgEgAEEIdkH/AXEiAHJBCToAAEEAQQAoArCIgIAAKAIANgKwiICAACABIABBCHRyIgBBACgC5IiAgAA2AgBBACAANgLkiICAAAsLTgECfwJAIAAgAUYNACACRQ0AA0ACQCAALQAAIgMgAS0AACIERg0AQQFBfyADIARLGw8LIAFBAWohASAAQQFqIQAgAkF/aiICDQALC0EAC3gBAX8CQAJAIAAgAU8NACACRQ0BIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ADAILCyAAIAFNDQAgAkUNACABQX9qIQEgAEF/aiEDA0AgAyACaiABIAJqLQAAOgAAIAJBf2oiAg0ACwsgAAssAQF/AkAgAkUNACAAIQMDQCADIAE6AAAgA0EBaiEDIAJBf2oiAg0ACwsgAAuCAQEBfwJAAkAgAEEDcQ0AIAEgAnJBA3ENACACQQRJDQEgAkECdiECIAAhAwNAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIAJBf2oiAg0ADAILCyACRQ0AIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ACwsgAAuIAQECfwJAQQAtAOiIgIAADQBBAEEBOgDoiICAABCMgICAABCOgICAAAtBoIAIEICAgIAAIgBBgIAENgIAQQJBgICAIBCXgICAACEBIABBFGpCgICAgICAwAA3AgAgAEEQaiAAQaCABGo2AgAgAEEIakIANwMAIAAgAEEgajYCBCAAIAE2AhwgAAsVACAAKAIcEJiAgIAAIAAQgoCAgAALFgAgAEEMaiABNgIAIABBCGpBADYCAAsbACAAKAIcIABBBGogAEEMaigCAEUQloCAgAALVAEDf0EAIQADQEEIIQEgACECA0BBACACQQFxa0GghuLtfnEgAkEBdnMhAiABQX9qIgENAAsgAEECdEHwiICAAGogAjYCACAAQQFqIgBBgAJHDQALC0oAIAJBf3MhAgJAIAFFDQADQCACQf8BcSAALQAAc0ECdEHwiICAAGooAgAgAkEIdnMhAiAAQQFqIQAgAUF/aiIBDQALCyACQX9zC10DAX4BfwF+QgAhAANAQQghASAAIQIDQEIAIAJCAYN9QsKenLzd8pW2SYMgAkIBiIUhAiABQX9qIgENAAsgAKdBA3RB8JCAgABqIAI3AwAgAEIBfCIAQoACUg0ACwtLACACQn+FIQICQCABRQ0AA0AgAkL/AYMgADEAAIWnQQN0QfCQgIAAaikDACACQgiIhSECIABBAWohACABQX9qIgENAAsLIAJCf4UL1RACDH8CfgJAAkAgACgCJEUNACAAKAIAIQIMAQtBACECIABBADoAKCAAQgA3AwAgAEIANwMYIABByABqQQBB5AAQhoCAgAAaIABBrAFqQQw2AgALIAAgASgCBCIDNgIQIABBsAFqIQQgAEHgAGohBSAAQcgAaiEGIABBtgFqIQcgAEGoAWohCCABKAIQIQkCQAJAAkACQANAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAIOCgECAAQFBgcICQoPCyABKAIAIQogACgCqAEhAiAAKAKsASELIAEoAgQhDCABKAIIIQ0MAgsgCCAAKAKoASIMakEIaiABKAIAIAEoAgQiAmogASgCCCACayICIAAoAqwBIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0RIABBATYCAAJAIARBqIiAgABBBhCEgICAAEUNAEEFIQwMEgsgB0ECQQAQjYCAgAAgACgAuAFHDRBBBiEMIActAAANESAAIAAtALcBIgI2AiAgAkEESw0RQQEgAnRBE3FFDRELIAEoAgQiDCABKAIIIg1GDQ4CQCABKAIAIgogDGotAAAiCw0AIAAgDDYCECABIAxBAWo2AgRBBiECDAwLQQAhAiAAQQA2AqgBIABBAjYCACAAIAtBAnRBBGoiCzYCrAEgACALNgJACyAIIAJqQQhqIAogDGogDSAMayIMIAsgAmsiAiAMIAJJGyICEIeAgIAAGiABIAIgASgCBGo2AgRBACEMIABBACAAKAKoASACaiICIAIgACgCrAEiC0YbNgKoASACIAtHDQ8gACACQXxqIgI2AqwBQQchDCAEIAJBABCNgICAACAAIAAoAqwBIgtqQbABaigAAEcNDyAAQQI2AqgBIAAtALEBIgJBP3ENDAJAAkAgAkHAAHFFDQAgACAEIAggCxCRgICAAEEBRw0RIAAgACkDCDcDMCAALQCxASECDAELIABCfzcDMAtCfyEOAkAgAkEYdEEYdUF/Sg0AIAAgBCAIIAAoAqwBEJGAgIAAQQFHDRAgACkDCCEOCyAAIA43AzggACgCrAEiDSAAKAKoASICa0ECSQ0PIAAgAkEBaiIKNgKoASAIIAJqQQhqLQAAQSFHDQwgACACQQJqIgs2AqgBIAggCmpBCGotAABBAUcNDCANIAtGDQ8gACACQQNqNgKoASAAKAKwCSAIIAtqQQhqLQAAEJyAgIAAIgwNDyAAKAKoASIMIAAoAqwBIgIgDCACSxshDQJAA0AgDSAMRg0BIAggDEEBaiICNgIAIAQgDGohCyACIQwgCy0AAA0ODAALCyAGQgA3AwAgAEEANgKoASAAQQM2AgAgBkEIakIANwMACyAAIAEoAgQ2AhAgACABKAIQNgIUIAAoArAJIAEQmYCAgAAhDCAAIAApA0ggASgCBCAAKAIQa618Ig43A0ggACAAKQNQIAEoAhAgACgCFCICayILrXwiDzcDUCAOIAApAzBWDQ0gDyAAKQM4Vg0NAkACQAJAAkAgACgCIEF/ag4EAAMDAQMLIAEoAgwgAmogCyAAKAIYEI2AgIAArSEODAELIAEoAgwgAmogCyAAKQMYEI+AgIAAIQ4LIAAgDjcDGAsgDEEBRw0OAkAgACkDMCIOQn9RDQAgDiAGKQMAUg0OCwJAIAApAzgiDkJ/UQ0AQQchDCAOIAApA1BSDQ8LIAAgACkDSCAANQJAfCAAKQNgfCIPNwNgQgQhDgJAAkACQCAAKAIgQX9qDgQBAgIAAgtCCCEOCyAFIA4gD3w3AwALIAAgACkDaCAAKQNQfDcDaCAAIAVBGCAAKAJwEI2AgIAANgJwIABBBDYCACAAIAApA1hCAXw3A1gLAkAgBikDACIOQgODUA0AIA5CAXwhDiABKAIEIQwgASgCCCELA0AgCyAMRg0NIAEgDEEBaiICNgIEIAEoAgAgDGotAAANDiAGIA43AwAgDkIDgyEPIA5CAXwhDiACIQwgD0IAUg0ACwsgAEEFNgIAC0EBIQIgACgCIEF/ag4EBgcHBQcLIAAgARCSgICAACIMQQFHDQsgAEEHNgIAC0EAIAAoAhBrIQggAEGAAWopAwAhDiABKAIEIQwCQANAIA4gCCAMaq18QgODUA0BAkAgDCABKAIIRw0AIAAgARCTgICAAAwLCyABIAxBAWoiAjYCBCABKAIAIAxqIQsgAiEMIAstAAANCwwACwsgACABEJOAgIAAQQchDCAFIABBkAFqQRgQhICAgAANCiAAQQg2AgALIAAgAUEgEJSAgIAAIgxBAUcNCSAAQQk2AgBBDCELIABBDDYCrAEMAQsgACgCrAEhCwsgAEGoAWogACgCqAEiDGpBCGogASgCACABKAIEIgJqIAEoAgggAmsiAiALIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0HIAAQlYCAgAAhDAwHC0EBIQIgACABQcAAEJSAgIAAIgxBAUcNBgwBC0EBIQIgACABQSAQlICAgAAiDEEBRw0FCyAAIAI2AgAMAAsLQQYhDAwCC0EAIQwMAQtBByEMCwJAAkAgACgCJA0AAkACQCAMDgIAAwELQQdBCCABKAIEIAEoAghGGyEMCyABIAk2AhAgASADNgIEIAwPCwJAIAwNACADIAEoAgRHDQAgCSABKAIQRw0AIAAtACghASAAQQE6ACggAUEDdA8LIABBADoAKAsgDAuaAQEDfwJAIAAoAgQiBA0AIABCADcDCAsgAigCACEFA0ACQCAFIANJDQBBAA8LIAEgBWotAAAhBiACIAVBAWoiBTYCACAAIAZB/wBxrSAErYYgACkDCIQ3AwgCQAJAIAZBgAFxDQACQCAGDQBBByEGIAQNAgsgAEEANgIEQQEPC0EHIQYgACAEQQdqIgQ2AgQgBEE/Rw0BCwsgBguhAgIDfwF+IABBkAFqIQIgAUEEaiEDA0ACQCAAIAEoAgAgAyABKAIIEJGAgIAAIgRBAUYNACAAQYABaiIDIAMpAwAgASgCBCAAKAIQIgNrIgKtfDcDACAAIAMgASgCAGogAiAAKAIYEI2AgIAArTcDGCAEDwsCQAJAAkACQAJAIAAoAngOAwACAQMLIAAgACkDCCIFNwOIAQJAIAUgACkDWFENAEEHDwsgAEEBNgJ4DAMLIAAgACkDmAEgACkDCHw3A5gBIAAgAkEYIAAoAqABEI2AgIAANgKgASAAQQE2AnggACAAKQOIAUJ/fCIFNwOIAQwCCyAAQQI2AnggACAAKQOQASAAKQMIfDcDkAELIAApA4gBIQULIAVCAFINAAtBAQtAAQJ/IABBgAFqIgIgAikDACABKAIEIAAoAhAiAmsiA618NwMAIAAgAiABKAIAaiADIAAoAhgQjYCAgACtNwMYC3wBBH8gASgCBCEDIAEoAgghBANAAkAgBCADRw0AQQAPCyABIANBAWoiBTYCBAJAIAEoAgAgA2otAAAgACkDGCAAKAIEIgOtiKdB/wFxRg0AQQcPCyAAIANBCGoiBjYCBCAFIQMgBiACSQ0ACyAAQQA2AgQgAEIANwMYQQELbwEBf0EHIQECQCAAQboBai8AAEHZtAFHDQAgAEG0AWpBBkEAEI2AgIAAIABBsAFqKAAARw0AIABBgAFqKQMAQgKIIAA1ALQBUg0AIABBuAFqLQAADQBBAUEHIAAoAiAgAEG5AWotAABGGyEBCyABC7QCAQR/AkACQCAAKAIkRQ0AIAAoAgAhAwwBC0EAIQMgAEEAOgAoIABCADcDACAAQgA3AxggAEHIAGpBAEHkABCGgICAABogAEGsAWpBDDYCAEEBIQILIABByABqIQQCQAJAA0ACQCADQQpHDQAgASgCBCIDIAEoAggiBUYNAiABKAIAIQYCQANAIAYgA2otAAANASABIANBAWoiAzYCBCAAIAAoAgRBAWpBA3E2AgQgBSADRg0EDAALCwJAIAAoAgRFDQBBBw8LIAAoAiRFDQAgAEEAOgAoIABCADcDACAAQgA3AxggBEEAQeQAEIaAgIAAGiAAQQw2AqwBCyAAIAEQkICAgAAiA0EBRw0CQQohAyAAQQo2AgAMAAsLAkAgAg0AQQAPC0EHQQEgACgCBBshAwsgAwt1AQF/AkBBuAkQgICAgAAiAkUNACACIAA2AiQgAiAAIAEQm4CAgAAiADYCsAkCQCAARQ0AIAJBADoAKCACQgA3AwAgAkIANwMYIAJByABqQQBB5AAQhoCAgAAaIAJBrAFqQQw2AgAgAg8LIAIQgoCAgAALQQALHgACQCAARQ0AIAAoArAJEJ2AgIAAIAAQgoCAgAALC4ARAQx/IABB6N0BaiECIABB1ABqIQMgAEEcaiIEQQhqIQUCQAJAA0AgACgCQCEGAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgASgCBCIHIAEoAggiCEkNACAGQQdGDQEMEgsgBg4JAQIDBAUGBwAJDwsgACgCTCEGDAcLQQEhCSABIAdBAWo2AgQgASgCACAHai0AACIHRQ0IAkACQCAHQd8BSw0AIAdBAUcNAQsgAEGAAjsBUAJAIAAoAjwNACAAIAEoAgwgASgCECIGajYCGCAAIAEoAhQgBms2AiwLIARCADcCACAFQgA3AgAMCwsgAC0AUEUNCgwOCyABIAdBAWo2AgQgASgCACAHai0AACEHIABBAjYCQCAAIAdBCHQgACgCSGo2AkgMDAsgASAHQQFqNgIEIAEoAgAgB2otAAAhByAAQQM2AkAgACAHIAAoAkhqQQFqNgJIDAsLIAEgB0EBajYCBCABKAIAIAdqLQAAIQcgAEEENgJAIAAgB0EIdDYCTAwKCyABIAdBAWo2AgQgASgCACAHai0AACEHIAAgACgCRDYCQCAAIAcgACgCTGpBAWo2AkwMCQsgASAHQQFqNgIEQQchCSABKAIAIAdqLQAAIgdB4AFLDQNBACEGAkACQCAHQS1PDQBBACEIDAELIAdBU2oiByAHQf8BcUEtbiIIQS1sayEHIAhBAWohCAsgAEF/IAh0QX9zNgJ0AkAgB0H/AXFBCUkNACAHQXdqIgcgB0H/AXFBCW4iBkEJbGshByAGQQFqIQYLIAAgBjYCcCAAIAdB/wFxIgc2AmwgBiAHakEESw0DIANCADcCACADQQhqQgA3AgAgA0EQakEANgIAIABBfyAGdEF/czYCcEH4ACEHA0AgACAHakGACDsBACAHQQJqIgdB5N0BRw0ACyAAQQY2AkAgAEEFNgIIIABC/////w83AgALIAAoAkwiCUEFSQ0IAkAgACgCCCIHRQ0AIAdBf2ohBiABKAIEIQcgASgCCCEKA0AgCiAHRg0LIAEgB0EBaiIINgIEIAEoAgAgB2otAAAhByAAIAY2AgggACAHIAAoAgRBCHRyNgIEIAghByAGQX9qIgZBf0cNAAsLIABBBzYCQCAAIAlBe2oiBjYCTAsgACAAKAIgIgcgASgCFCABKAIQayIIIAAoAkgiCiAIIApJGyIIaiAAKAIsIgogCiAHayAISxs2AiggASgCCCIJIAEoAgQiCGshBwJAAkACQCAAKALk3QEiCg0AIAYNAUEAIQYLIABB5N0BaiILIApqQQRqIAEoAgAgCGogByAGIAprIgZBKiAKayIIIAggBksbIgYgBiAHSxsiBxCHgICAABoCQAJAIAcgACgC5N0BIghqIgYgACgCTEcNACALIAhqIAdqQQRqQQBBPyAGaxCGgICAABogACgC5N0BIAdqIQYMAQsCQCAGQRRLDQAgACAGNgLk3QEgASABKAIEIAdqNgIEDAMLIAZBa2ohBgsgAEEANgIQIAAgAjYCDCAAIAY2AhRBByEJIAAQmoCAgABFDQMgACgCECIIIAAoAuTdASIKIAdqSw0DIAAgACgCTCAIayIGNgJMAkAgCiAITQ0AIAAgCiAIayIHNgLk3QEgAiALIAhqQQRqIAcQhYCAgAAaDAILIABBADYC5N0BIAEgASgCBCAIIApraiIINgIEIAEoAggiCSAIayEHCwJAIAdBFUkNACAAIAg2AhAgACABKAIANgIMIAAgCUFraiAIIAZqIAcgBkEVakkbNgIUQQchCSAAEJqAgIAARQ0DIAAoAkwiByAAKAIQIgggASgCBGsiBkkNAyABIAg2AgQgACAHIAZrIgY2AkwgASgCCCAIayIHQRRLDQELIAIgASgCACAIaiAGIAcgByAGSxsiBxCHgICAABogACAHNgLk3QEgASABKAIEIAdqNgIECyAAKAIgIgYgACgCHCIIayEHAkAgACgCPEUNAAJAIAYgACgCLEcNACAAQQA2AiALIAEoAgwgASgCEGogACgCGCAIaiAHEIeAgIAAGiAAKAIgIQYLIAAgBjYCHCABIAEoAhAgB2oiBjYCECAAIAAoAkggB2siBzYCSAJAIAcNAEEHIQkgACgCTA0CIAAoAmgNAiAAKAIEDQIgAEEANgJADAULQQAhCSAGIAEoAhRGDQEgASgCBCABKAIIRw0GIAAoAuTdASAAKAJMTw0GDAELIAAoAkwiCkUNAUEAIQkgCCAHTQ0AA0AgASgCFCIGIAEoAhAiC00NASAAIAogCiAAKAIsIAAoAiAiDGsiDSAIIAdrIgggBiALayIGIAggBkkbIgYgBiANSxsiBiAGIApLGyIGazYCTCAMIAAoAhhqIAEoAgAgB2ogBhCFgICAABogACAAKAIgIAZqIgc2AiACQCAAKAIkIAdPDQAgACAHNgIkCwJAIAAoAjxFDQACQCAHIAAoAixHDQAgAEEANgIgCyABKAIMIAEoAhBqIAEoAgAgASgCBGogBhCFgICAABogACgCICEHCyAAIAc2AhwgASABKAIQIAZqNgIQIAEgASgCBCAGaiIHNgIEIAAoAkwiCkUNAiABKAIIIgggB0sNAAsLIAkPCyAAQQA2AkAMAwsgB0EYdEEYdUF/Sg0BIABBATYCQCAAIAdBEHRBgID8AHE2AkgCQCAHQcABSQ0AIABBBTYCRCAAQQA6AFEMAwsgAC0AUQ0DIABBBjYCRCAHQaABSQ0CIANCADcCACADQRBqQQA2AgAgA0EIakIANwIAQfgAIQcDQCAAIAdqQYAIOwEAIAdBAmoiB0Hk3QFHDQALCyAAQQU2AgggAEL/////DzcCAAwBCyAHQQJLDQEgAEKDgICAgAE3AkAMAAsLQQcPC0EAC/8XARJ/IABBGGohAQJAIABBIGooAgAiAiAAQShqKAIAIgNPDQAgAEHoAGoiBCgCAEUNACABIAQgACgCVBCegICAABogACgCKCEDIAAoAiAhAgsCQCACIANPDQAgAEHcDWohBSAAQegAaiEGIABB4BVqIQcgAEHUAGohCANAIAAoAhAiCSAAKAIUSw0BIAAgACgCZCIKQQV0aiAAKAJ0IAJxIgtBAXRqIgxB+ABqIQ0CQAJAIAAoAgAiBEGAgIAISQ0AIAAoAgQhDgwBCyAAIARBCHQiBDYCACAAIAlBAWoiAzYCECAAIAAoAgRBCHQgACgCDCAJai0AAHIiDjYCBCADIQkLAkACQCAOIARBC3YgDS8BACIPbCIDTw0AIAAgAzYCACANIA9BgBAgD2tBBXZqOwEAIAJBf2ohBAJAIAINACAAKAIsIARqIQQLAkACQCAAKAIkIg8NAEEAIQQMAQsgACgCGCAEai0AACEECyAAKAJwIAJxIAAoAmwiDXQgBEEIIA1rdmohDAJAAkAgCkEGSw0AQQEhBANAIAAgDEGADGxqIARBAXQiBGpB5B1qIQ0CQAJAIANB////B00NACADIQoMAQsgACADQQh0Igo2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiAKQQt2IA0vAQAiD2wiA0kNACAAIA4gA2siDjYCBCAAIAogA2siAzYCACANIA8gD0EFdms7AQAgBEEBciEEDAELIAAgAzYCACANIA9BgBAgD2tBBXZqOwEACyAEQYACSQ0ADAILCyACIAAoAlQiDUF/c2ohBAJAIAIgDUsNACAAKAIsIARqIQQLAkACQCAPDQBBACEQDAELIAAoAhggBGotAAAhEAtBASEEQYACIQ0DQCAAIAxBgAxsaiAQQQF0IhAgDXEiESANaiAEakEBdGpB5B1qIQ8CQAJAIANB////B00NACADIQsMAQsgACADQQh0Igs2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiALQQt2IA8vAQAiCmwiA08iEg0AIAAgAzYCACAKQYAQIAprQQV2aiEKDAELIAAgDiADayIONgIEIAAgCyADayIDNgIAIAogCkEFdmshCkEAIQ0LIA8gCjsBACANIBFzIQ0gBEEBdCASciIEQYACSQ0ACwsgACACQQFqNgIgIAAoAhggAmogBDoAAAJAIAAoAiQgACgCICICTw0AIAAgAjYCJAtBACEDAkAgACgCZCIEQQRJDQACQCAEQQlLDQAgBEF9aiEDDAELIARBemohAwsgACADNgJkDAELIAAgDiADayIONgIEIAAgBCADayIDNgIAIA0gDyAPQQV2azsBACAAIApBAXRqIg9B+ANqIQQCQAJAIANB////B00NACAJIQoMAQsgACADQQh0IgM2AgAgACAJQQFqIgo2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQLAkACQCAOIANBC3YgBC8BACINbCIJSQ0AIAAgDiAJayIONgIEIAAgAyAJayIDNgIAIAQgDSANQQV2azsBACAPQZAEaiENAkACQCADQf///wdNDQAgCiEQDAELIAAgA0EIdCIDNgIAIAAgCkEBaiIQNgIQIAAgDkEIdCAAKAIMIApqLQAAciIONgIECwJAAkAgDiADQQt2IA0vAQAiCWwiBE8NACANIAlBgBAgCWtBBXZqOwEAIAxB2ARqIQMCQCAEQf///wdLDQAgACAEQQh0IgQ2AgAgACAQQQFqNgIQIAAgDkEIdCAAKAIMIBBqLQAAciIONgIECwJAIA4gBEELdiADLwEAIg1sIglJDQAgACAOIAlrNgIEIAAgBCAJazYCACADIA0gDUEFdms7AQAMAgsgAyANQYAQIA1rQQV2ajsBACAAIAk2AgAgAEEBNgJoIABBCUELIAAoAmRBB0kbNgJkDAMLIAAgDiAEayIONgIEIA0gCSAJQQV2azsBACAPQagEaiENAkACQCADIARrIgNB////B00NACAQIQoMAQsgACADQQh0IgM2AgAgACAQQQFqIgo2AhAgACAOQQh0IAAoAgwgEGotAAByIg42AgQLAkACQCAOIANBC3YgDS8BACIEbCIJTw0AIAAgCTYCACANIARBgBAgBGtBBXZqOwEAIAAoAlghAwwBCyAAIA4gCWsiDjYCBCANIAQgBEEFdms7AQAgD0HABGohBAJAIAMgCWsiA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgCkEBajYCECAAIA5BCHQgACgCDCAKai0AAHIiDjYCBAsCQAJAIA4gA0ELdiAELwEAIg1sIglPDQAgACAJNgIAIAQgDUGAECANa0EFdmo7AQAgACgCXCEDDAELIAAgDiAJazYCBCAAIAMgCWs2AgAgACgCYCEDIAAgACgCXDYCYCAEIA0gDUEFdms7AQALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAzYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAHIAsQn4CAgAAMAQsgBCANQYAQIA1rQQV2ajsBACAAIAk2AgAgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIAUgCxCfgICAACAAKAJoIgNBfmpBAyADQQZJGyEKIAAoAgAhA0EBIQ4DQCAAIApBB3RqIA5BAXQiDmpB2AdqIQ0CQAJAIANBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgRBAWo2AhAgACAAKAIEQQh0IAQgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgDS8BACIJbCIPSQ0AIAAgBCAPayIENgIEIAAgAyAPayIDNgIAIA0gCSAJQQV2azsBACAOQQFyIQ4MAQsgACAPNgIAIA0gCUGAECAJa0EFdmo7AQAgDyEDCyAOQcAASQ0ACwJAIA5BQGoiCUEDSw0AIAAgCTYCVAwBCyAAIA5BAXFBAnIiDTYCVCAJQQF2IQ8CQCAJQQ1LDQAgACANIA9Bf2oiDHQiCzYCVEEBIQ0gCCALQQF0akGEC2ohEEE/IA5rIRFBACEPA0AgECARIA1qQQF0aiEOAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA4vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACAOIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDUEBdEEBciENDAELIAAgAzYCACAOIAlBgBAgCWtBBXZqOwEAIA1BAXQhDQsgDCAPQQFqIg9HDQAMAgsLIA9Be2ohDgNAAkAgA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgACgCECIJQQFqNgIQIARBCHQgCSAAKAIMai0AAHIhBAsgACADQQF2IgM2AgAgACAEIANrIgRBH3UiCSANQQF0akEBaiINNgJUIAAgCSADcSAEaiIENgIEIA5Bf2oiDg0ACyAAIA1BBHQiCzYCVEEAIQ9BASEOA0AgACAOQQF0Ig5qQbwNaiENAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA0vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACANIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDkEBciEODAELIAAgAzYCACANIAlBgBAgCWtBBXZqOwEACyAPQQFqIg9BBEcNAAsLAkAgASAGIAAoAlQQnoCAgAANAEEADwsgACgCICECCyACIAAoAihJDQALC0EBIQMCQCAAKAIAIgRB////B0sNACAAIARBCHQ2AgBBASEDIAAgACgCECIEQQFqNgIQIAAgACgCBEEIdCAEIAAoAgxqLQAAcjYCBAsgAwtwAQF/AkBBqN4BEICAgIAAIgJFDQAgAkE0aiABNgIAIAJBPGogADYCAAJAAkACQCAAQX9qDgIAAQILIAIgARCAgICAACIANgIYIAANASACEIKAgIAADAILIAJBADYCGCACQThqQQA2AgALIAIPC0EAC9IBAQJ/QQYhAgJAIAFBJ0sNACAAQTBqIAFBAXFBAnIgAUEBdkELanQiATYCAAJAAkAgAEE8aigCACIDRQ0AQQQhAiABIABBNGooAgBLDQIgAEEsaiABNgIAIANBAkcNACAAQThqIgMoAgAgAU8NACAAIAE2AjggACgCGBCCgICAACAAIAAoAjAQgICAgAAiATYCGCABDQBBAyECDAELQQAhAiAAQQA2AkAgAEHQAGpBAToAACAAQegAakEANgIAIABB5N0BaiEDCyADQQA2AgALIAILIwACQCAAQTxqKAIARQ0AIAAoAhgQgoCAgAALIAAQgoCAgAAL9QEBBH9BACEDAkAgACgCDCACTQ0AIAAoAhggAk0NACABIAEoAgAiBCAAKAIQIAAoAggiBWsiBiAEIAYgBEkbIgRrNgIAIAUgAkF/c2ohAQJAIAUgAksNACAAKAIUIAFqIQELIAAoAgAiAiABai0AACEGQQEhAyAAIAVBAWo2AgggAiAFaiAGOgAAAkAgBEF/aiICRQ0AA0AgACgCACIFQQAgAUEBaiIBIAEgACgCFEYbIgFqLQAAIQQgACAAKAIIIgZBAWo2AgggBSAGaiAEOgAAIAJBf2oiAg0ACwsgACgCDCAAKAIIIgFPDQAgACABNgIMCyADC8gEAQd/AkACQCAAKAIAIgNBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAAKAIEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgAS8BACIGbCIFTw0AIAEgBkGAECAGa0EFdmo7AQAgASACQQR0akEEaiEHQQghCEECIQkMAQsgACAEIAVrIgQ2AgQgASAGIAZBBXZrOwEAAkAgAyAFayIDQf///wdLDQAgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkAgBCADQQt2IAEvAQIiBmwiBU8NACABIAZBgBAgBmtBBXZqOwECIAEgAkEEdGpBhAJqIQdBCCEIQQohCQwBCyAAIAQgBWsiBDYCBCABIAYgBkEFdms7AQIgAUGEBGohByADIAVrIQVBgAIhCEESIQkLIABB6ABqIAk2AgBBASEBA0AgByABQQF0IgFqIQMCQAJAIAVB////B00NACAFIQIMAQsgACAFQQh0IgI2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIAJBC3YgAy8BACIGbCIFSQ0AIAAgBCAFayIENgIEIAAgAiAFayIFNgIAIAMgBiAGQQV2azsBACABQQFyIQEMAQsgACAFNgIAIAMgBkGAECAGa0EFdmo7AQALIAEgCEkNAAsgAEHoAGogASAIayAJajYCAAsLNQEAQYAICy4IAAAAEAAAABgAAAAgAAAAKAAAADAAAABAAAAAUAAAAIAAAAAAAQAA/Td6WFoA\"},t=>{t.exports=e}],i={};function n(e){var r=i[e];if(void 0!==r)return r.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{XzReadableStream:()=>s});var e=n(1);const t=globalThis.ReadableStream||n(2).ReadableStream;class i{constructor(e){this.exports=e.exports,this.memory=this.exports.memory,this.ptr=this.exports.create_context(),this._refresh(),this.bufSize=this.mem32[0],this.inStart=this.mem32[1]-this.ptr,this.inEnd=this.inStart+this.bufSize,this.outStart=this.mem32[4]-this.ptr}supplyInput(e){this._refresh(),this.mem8.subarray(this.inStart,this.inEnd).set(e,0),this.exports.supply_input(this.ptr,e.byteLength),this._refresh()}getNextOutput(){const e=this.exports.get_next_output(this.ptr);if(this._refresh(),0!==e&&1!==e)throw new Error(`get_next_output failed with error code ${e}`);return{outChunk:this.mem8.slice(this.outStart,this.outStart+this.mem32[5]),finished:1===e}}needsMoreInput(){return this.mem32[2]===this.mem32[3]}outputBufferIsFull(){return this.mem32[5]===this.bufSize}resetOutputBuffer(){this.outPos=this.mem32[5]=0}dispose(){this.exports.destroy_context(this.ptr),this.exports=null}_refresh(){this.memory.buffer!==this.mem8?.buffer&&(this.mem8=new Uint8Array(this.memory.buffer,this.ptr),this.mem32=new Uint32Array(this.memory.buffer,this.ptr))}}class s extends t{static _moduleInstancePromise;static _moduleInstance;static async _getModuleInstance(){const t=e.replace(\"data:application/wasm;base64,\",\"\"),i=Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer,n=await WebAssembly.instantiate(i,{});s._moduleInstance=n.instance}constructor(e){let t,n=null;const r=e.getReader();super({async start(e){s._moduleInstance||await(s._moduleInstancePromise||(s._moduleInstancePromise=s._getModuleInstance())),t=new i(s._moduleInstance)},async pull(e){if(t.needsMoreInput()){if(null===n||0===n.byteLength){const{done:e,value:t}=await r.read();e||(n=t)}const e=Math.min(t.bufSize,n.byteLength);t.supplyInput(n.subarray(0,e)),n=n.subarray(e)}const i=t.getNextOutput();e.enqueue(i.outChunk),t.resetOutputBuffer(),i.finished&&(t.dispose(),e.close())},cancel:()=>(t.dispose(),r.cancel())})}}})(),r})(),e.exports=n(i(772))},3617:()=>{},772:()=>{},928:(e,t,i)=>{const n=i(2886).default;e.exports=n,e.exports.default=n},1308:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0});let i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];\"undefined\"!=typeof Int32Array&&(i=new Int32Array(i)),t.default=(e,t)=>{let n=0===t?0:~t;for(let t=0;t>>8;return~n}},2886:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(1308)),s=n(i(7327));t.default=(0,s.default)(\"crc-32\",r.default)},4422:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(8287);t.default=(e,t)=>n.Buffer.from(e,t)},7327:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(4422));t.default=function(e,t){const i=(e,i)=>t((0,r.default)(e),i)>>>0;return i.signed=(e,i)=>t((0,r.default)(e),i),i.unsigned=i,i.model=e,i}}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}return i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i(7806)})(),jp=[],Wp=[],Gp=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,$p=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Kp=0;Kp<64;++Kp)jp[Kp]=$p[Kp],Wp[$p.charCodeAt(Kp)]=Kp;function Yp(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function Xp(e,t,i){for(var n,r,s=[],o=t;o>18&63]+jp[r>>12&63]+jp[r>>6&63]+jp[63&r]);return s.join(\"\")}Wp[\"-\".charCodeAt(0)]=62,Wp[\"_\".charCodeAt(0)]=63;var Zp={byteLength:function(e){var t=Yp(e),i=t[0],n=t[1];return 3*(i+n)/4-n},toByteArray:function(e){var t,i,n=Yp(e),r=n[0],s=n[1],o=new Gp(function(e,t,i){return 3*(t+i)/4-i}(0,r,s)),a=0,c=s>0?r-4:r;for(i=0;i>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===s&&(t=Wp[e.charCodeAt(i)]<<2|Wp[e.charCodeAt(i+1)]>>4,o[a++]=255&t),1===s&&(t=Wp[e.charCodeAt(i)]<<10|Wp[e.charCodeAt(i+1)]<<4|Wp[e.charCodeAt(i+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o},fromByteArray:function(e){for(var t,i=e.length,n=i%3,r=[],s=16383,o=0,a=i-n;oa?a:o+s));return 1===n?(t=e[i-1],r.push(jp[t>>2]+jp[t<<4&63]+\"==\")):2===n&&(t=(e[i-2]<<8)+e[i-1],r.push(jp[t>>10]+jp[t>>4&63]+jp[t<<2&63]+\"=\")),r.join(\"\")}};\n", - "/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Jp={read:function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},write:function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}};\n", - "/*!\n", - " * The buffer module from node.js, for the browser.\n", - " *\n", - " * @author Feross Aboukhadijeh \n", - " * @license MIT\n", - " */const eg=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null,tg=2147483647;function ig(e){if(e>tg)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,ng.prototype),t}function ng(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return og(e)}return rg(e,t,i)}function rg(e,t,i){if(\"string\"==typeof e)return function(e,t){\"string\"==typeof t&&\"\"!==t||(t=\"utf8\");if(!ng.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|hg(e,t);let n=ig(i);const r=n.write(e,t);r!==i&&(n=n.slice(0,r));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Vg(e,Uint8Array)){const t=new Uint8Array(e);return cg(t.buffer,t.byteOffset,t.byteLength)}return ag(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(Vg(e,ArrayBuffer)||e&&Vg(e.buffer,ArrayBuffer))return cg(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(Vg(e,SharedArrayBuffer)||e&&Vg(e.buffer,SharedArrayBuffer)))return cg(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return ng.from(n,t,i);const r=function(e){if(ng.isBuffer(e)){const t=0|lg(e.length),i=ig(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return\"number\"!=typeof e.length||jg(e.length)?ig(0):ag(e);if(\"Buffer\"===e.type&&Array.isArray(e.data))return ag(e.data)}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return ng.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function sg(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function og(e){return sg(e),ig(e<0?0:0|lg(e))}function ag(e){const t=e.length<0?0:0|lg(e.length),i=ig(t);for(let n=0;n=tg)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+tg.toString(16)+\" bytes\");return 0|e}function hg(e,t){if(ng.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Vg(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return Ug(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return qg(e).length;default:if(r)return n?-1:Ug(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function dg(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return xg(this,t,i);case\"utf8\":case\"utf-8\":return yg(this,t,i);case\"ascii\":return Cg(this,t,i);case\"latin1\":case\"binary\":return _g(this,t,i);case\"base64\":return vg(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return kg(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function ug(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function fg(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),jg(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=ng.from(t,n)),ng.isBuffer(t))return 0===t.length?-1:pg(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):pg(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function pg(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function vg(e,t,i){return 0===t&&i===e.length?Zp.fromByteArray(e):Zp.fromByteArray(e.slice(t,i))}function yg(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=Ag)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(ng.isBuffer(t)||(t=ng.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!ng.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},ng.byteLength=hg,ng.prototype._isBuffer=!0,ng.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;tt&&(e+=\" ... \"),\"\"},eg&&(ng.prototype[eg]=ng.prototype.inspect),ng.prototype.compare=function(e,t,i,n,r){if(Vg(e,Uint8Array)&&(e=ng.from(e,e.offset,e.byteLength)),!ng.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),c=this.slice(n,r),l=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return gg(this,e,t,i);case\"utf8\":case\"utf-8\":return mg(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return wg(this,e,t,i);case\"base64\":return bg(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return Fg(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},ng.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const Ag=4096;function Cg(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function Sg(e,t,i,n,r,s){if(!ng.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function Eg(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function Ng(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function Bg(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function Mg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,4),Jp.write(e,t,i,n,23,4),i+4}function Rg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,8),Jp.write(e,t,i,n,52,8),i+8}ng.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},ng.prototype.readUint8=ng.prototype.readUInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),this[e]},ng.prototype.readUint16LE=ng.prototype.readUInt16LE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]|this[e+1]<<8},ng.prototype.readUint16BE=ng.prototype.readUInt16BE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]<<8|this[e+1]},ng.prototype.readUint32LE=ng.prototype.readUInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ng.prototype.readUint32BE=ng.prototype.readUInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ng.prototype.readBigUInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},ng.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||Ig(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},ng.prototype.readInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ng.prototype.readInt16LE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt16BE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ng.prototype.readInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ng.prototype.readBigInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!0,23,4)},ng.prototype.readFloatBE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!1,23,4)},ng.prototype.readDoubleLE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!0,52,8)},ng.prototype.readDoubleBE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!1,52,8)},ng.prototype.writeUintLE=ng.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},ng.prototype.writeUint8=ng.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,255,0),this[t]=255&e,t+1},ng.prototype.writeUint16LE=ng.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeUint16BE=ng.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeUint32LE=ng.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},ng.prototype.writeUint32BE=ng.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigUInt64LE=Gg((function(e,t=0){return Eg(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeBigUInt64BE=Gg((function(e,t=0){return Ng(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},ng.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},ng.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},ng.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigInt64LE=Gg((function(e,t=0){return Eg(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeBigInt64BE=Gg((function(e,t=0){return Ng(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeFloatLE=function(e,t,i){return Mg(this,e,t,!0,i)},ng.prototype.writeFloatBE=function(e,t,i){return Mg(this,e,t,!1,i)},ng.prototype.writeDoubleLE=function(e,t,i){return Rg(this,e,t,!0,i)},ng.prototype.writeDoubleBE=function(e,t,i){return Rg(this,e,t,!1,i)},ng.prototype.copy=function(e,t,i,n){if(!ng.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function zg(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new Dg.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Hg(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||Pg(t,e.length-(i+1))}(n,r,s)}function Hg(e,t){if(\"number\"!=typeof e)throw new Dg.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function Pg(e,t,i){if(Math.floor(e)!==e)throw Hg(e,i),new Dg.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new Dg.ERR_BUFFER_OUT_OF_BOUNDS;throw new Dg.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}Tg(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),Tg(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),Tg(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=Lg(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=Lg(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const Og=/[^+/0-9A-Za-z-_]/g;function Ug(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function qg(e){return Zp.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(Og,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function Qg(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Vg(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function jg(e){return e!=e}const Wg=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Gg(e){return\"undefined\"==typeof BigInt?$g:e}function $g(){throw new Error(\"BigInt not supported\")}class Kg{constructor(e,t){this.position=0,this.url=e,this.config=t,Ht(e)||!1===t.cacheFetches?this.useCache=!1:(this.useCache=!0,this.cache=new Yg({fetch:(e,t)=>this._fetch(e,t),fetchSize:t.fetchSize||1e4}))}async _fetch(e,t){const i={start:e,size:t};this._stat={size:void 0};const n=await Qs.loadArrayBuffer(this.url,Ua(this.config,{range:i}));return ng.from(n)}async read(e,t=0,i=1/0,n=0){if(this.useCache)await this.cache.get(e,t,n,i);else{(await this._fetch(n,i)).copy(e,t)}return{bytesRead:i,buffer:e}}async readFile(){const e=await Qs.loadArrayBuffer(this.url,Ua(this.config));return ng.from(e)}async stat(){if(!this._stat){const e=ng.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class Yg{constructor({fetch:e,fetchSize:t=3e4}){this.fetch=e,this.position=0,this.buffer=ng.allocUnsafe(0),this.fetchSize=t}async get(e,t,i,n){if(e.length=this.position&&i+n<=this.position+this.buffer.length);else{const e=Math.max(n,this.fetchSize);this.buffer=await this.fetch(i,e),this.position=i}const r=t,s=i-this.position,o=s+n;this.buffer.copy(e,r,s,o)}}class Xg{chrAliasTable=new Map;constructor(e,t,i){this.config=e,this.browser=i,this.genome=t,this.cramFile=new Vp.CramFile({filehandle:e.fileHandle?e.fileHandle:new Kg(e.url,e),seqFetch:e.seqFetch||async function(e,t,i){const n=this.genome,r=await this.getHeader(),s=n.getChromosomeName(r.indexToChr[e]);return this.genome.getSequence(s,t-1,i)}.bind(this),checkSequenceMD5:void 0===e.checkSequenceMD5||e.checkSequenceMD5});const n=e.indexFileHandle?e.indexFileHandle:new Kg(e.indexURL,e);this.indexedCramFile=new Vp.IndexedCramFile({cram:this.cramFile,index:new Vp.CraiIndex({filehandle:n}),fetchSizeLimit:e.fetchSizeLimit||1e9}),Mp.setReaderDefaults(this,e)}async getHeader(){if(!this.header){const e=await this.cramFile.getSamHeader(),t={},i=[],n=[];for(let r of e)if(\"SQ\"===r.tag){for(let e of r.data)if(\"SN\"===e.tag){const n=e.value;t[n]=i.length,i.push(n);break}}else\"RG\"===r.tag&&n.push(r.data);this.header={indexToChr:i,chrToIndex:t,chrNames:Object.keys(t),readGroups:n}}return this.header}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async readAlignments(e,t,i){const n=await this.getHeader(),r=await this.#x(e),s=new tp(e,t,i,this.config);if(void 0===r)return s;try{const e=await this.indexedCramFile.getRecordsForRange(r,t,i);for(let a of e){const e=a.sequenceId,c=a.alignmentStart,l=c+a.lengthOnRef;if(e<0)continue;if(e>r||c>i)return;if(e=0&&(t=\"Sequence mismatch. Is this the correct genome for the loaded CRAM?\"),this.browser.alert.present(new Error(t)),e}function o(e,t){const i=new wp;if(i.chr=t[e.sequenceId],i.start=e.alignmentStart-1,i.lengthOnRef=e.lengthOnRef,i.flags=e.flags,i.strand=!(16&e.flags),i.fragmentLength=e.templateLength||e.templateSize,i.mq=e.mappingQuality,i.end=e.alignmentStart+e.lengthOnRef,i.readGroupId=e.readGroupId,e.mate&&void 0!==e.mate.sequenceId){const n=void 0!==e.mate.flags?!(1&e.mate.flags):!(32&e.flags);i.mate={chr:t[e.mate.sequenceId],position:e.mate.alignmentStart,strand:n}}return i.seq=e.getReadBases(),i.qual=e.qualityScores,i.tagDict=e.tags,i.readName=e.readName,function(e,t){const i=[];let n,r,s=0,o=\"\";if(t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef,e.readFeatures)for(let a of e.readFeatures){const e=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(e){case\"S\":case\"I\":case\"i\":case\"N\":case\"D\":if(l>s){const e=l-s;i.push(new xp({start:h-e,seqOffset:s,len:e,type:\"M\"})),s+=e,o+=e+\"M\"}if(\"S\"===e){let n=h;t.scLengthOnRef+=c.length,0===l&&(t.scStart-=c.length,n-=c.length);const r=c.length;i.push(new xp({start:n,seqOffset:s,len:r,type:\"S\"})),s+=r,o+=r+e}else if(\"I\"===e||\"i\"===e){void 0===n&&(n=[]);const t=\"i\"===e?1:c.length;n.push(new xp({start:h,len:t,seqOffset:s,type:\"I\"})),s+=t,o+=t+e}else\"D\"!==e&&\"N\"!==e||(r||(r=[]),r.push({start:h,len:c,type:e}),o+=c+e);break;case\"H\":case\"P\":o+=c+e}}const a=e.readLength-s;a>0&&(i.push(new xp({start:e.alignmentStart+e.lengthOnRef-a-1,seqOffset:s,len:a,type:\"M\"})),o+=a+\"M\");t.blocks=i,t.insertions=n,t.gaps=r,t.cigar=o}(e,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Mp.setPairOrientation(i),i}}}const Zg=2291137574,Jg=2273964779,em=[84,68,70,52],tm=new Uint8Array([66,65,77,1]),im=[67,82,65,77],nm=[31,139],rm=4,sm=new Set([\"narrowpeak\",\"broadpeak\",\"regionpeak\",\"peaks\",\"bedgraph\",\"wig\",\"gff3\",\"gff\",\"gtf\",\"fusionjuncspan\",\"refflat\",\"seg\",\"aed\",\"bed\",\"bedMethyl\",\"vcf\",\"bb\",\"bigbed\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"bw\",\"bigwig\",\"bam\",\"tdf\",\"refgene\",\"genepred\",\"genepredext\",\"bedpe\",\"bp\",\"snp\",\"rmsk\",\"cram\",\"gwas\",\"maf\",\"mut\",\"hiccups\",\"fasta\",\"fa\",\"fna\",\"pytor\",\"hic\",\"qtl\"]);function om(e,t){const i=Math.min(e.length,t.length);if(0==i)return!1;for(let n=0;n=this.start&&e.end<=this.end}overlaps(e){return e.chr===this.chr&&!(e.endthis.end)}extend(e){e.chr===this.chr&&(this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}getLocusString(){if(\"all\"===this.chr)return\"all\";{const e=Rt(Math.floor(this.start)+1),t=Rt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}static fromLocusString(e){if(\"all\"===e)return new lm({chr:\"all\"});const t=e.split(\":\"),i=t[0],n=t[1].split(\"-\"),r=Number.parseInt(n[0].replace(/,/g,\"\"))-1,s=Number.parseInt(n[1].replace(/,/g,\"\"));return new lm({chr:i,start:r,end:s})}}\n", - "/*!\n", - " * vanilla-picker v2.12.1\n", - " * https://vanilla-picker.js.org\n", - " *\n", - " * Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)\n", - " * Released under the ISC license.\n", - " */var hm=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},dm=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1;return(t>0?e.toFixed(t).replace(/0+$/,\"\").replace(/\\.$/,\"\"):e.toString())||\"0\"}var gm=function(){function e(t,i,n,r){hm(this,e);var s=this;if(void 0===t);else if(Array.isArray(t))this.rgba=t;else if(void 0===n){var o=t&&\"\"+t;o&&function(t){if(t.startsWith(\"hsl\")){var i=t.match(/([\\-\\d\\.e]+)/g).map(Number),n=um(i,4),r=n[0],o=n[1],a=n[2],c=n[3];void 0===c&&(c=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,c]}else if(t.startsWith(\"rgb\")){var l=t.match(/([\\-\\d\\.e]+)/g).map(Number),h=um(l,4),d=h[0],u=h[1],f=h[2],p=h[3];void 0===p&&(p=1),s.rgba=[d,u,f,p]}else t.startsWith(\"#\")?s.rgba=e.hexToRgb(t):s.rgba=e.nameToRgb(t)||e.hexToRgb(t)}(o.toLowerCase())}else this.rgba=[t,i,n,void 0===r?1:r]}return dm(e,[{key:\"printRGB\",value:function(e){var t=(e?this.rgba:this.rgba.slice(0,3)).map((function(e,t){return pm(e,3===t?3:0)}));return e?\"rgba(\"+t+\")\":\"rgb(\"+t+\")\"}},{key:\"printHSL\",value:function(e){var t=[360,100,100,1],i=[\"\",\"%\",\"%\",\"\"],n=(e?this.hsla:this.hsla.slice(0,3)).map((function(e,n){return pm(e*t[n],3===n?3:1)+i[n]}));return e?\"hsla(\"+n+\")\":\"hsl(\"+n+\")\"}},{key:\"printHex\",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:\"rgba\",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error(\"No color is set\");return this._rgba=e.hslToRgb(this._hsla)},set:function(e){3===e.length&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:\"rgbString\",get:function(){return this.printRGB()}},{key:\"rgbaString\",get:function(){return this.printRGB(!0)}},{key:\"hsla\",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error(\"No color is set\");return this._hsla=e.rgbToHsl(this._rgba)},set:function(e){3===e.length&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:\"hslString\",get:function(){return this.printHSL()}},{key:\"hslaString\",get:function(){return this.printHSL(!0)}},{key:\"hex\",get:function(){var e=this.rgba.map((function(e,t){return t<3?e.toString(16):Math.round(255*e).toString(16)}));return\"#\"+e.map((function(e){return e.padStart(2,\"0\")})).join(\"\")},set:function(t){this.rgba=e.hexToRgb(t)}}],[{key:\"hexToRgb\",value:function(e){var t=(e.startsWith(\"#\")?e.slice(1):e).replace(/^(\\w{3})$/,\"$1F\").replace(/^(\\w)(\\w)(\\w)(\\w)$/,\"$1$1$2$2$3$3$4$4\").replace(/^(\\w{6})$/,\"$1FF\");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error(\"Unknown hex color; \"+e);var i=t.match(/^(\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)$/).slice(1).map((function(e){return parseInt(e,16)}));return i[3]=i[3]/255,i}},{key:\"nameToRgb\",value:function(t){var i=t.toLowerCase().replace(\"at\",\"T\").replace(/[aeiouyldf]/g,\"\").replace(\"ght\",\"L\").replace(\"rk\",\"D\").slice(-5,4),n=fm[i];return void 0===n?n:e.hexToRgb(n.replace(/\\-/g,\"00\").padStart(6,\"f\"))}},{key:\"rgbToHsl\",value:function(e){var t=um(e,4),i=t[0],n=t[1],r=t[2],s=t[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),c=void 0,l=void 0,h=(o+a)/2;if(o===a)c=l=0;else{var d=o-a;switch(l=h>.5?d/(2-o-a):d/(o+a),o){case i:c=(n-r)/d+(n1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e},h=r<.5?r*(1+n):r+n-r*n,d=2*r-h;o=l(d,h,i+1/3),a=l(d,h,i),c=l(d,h,i-1/3)}var u=[255*o,255*a,255*c].map(Math.round);return u[3]=s,u}}]),e}(),mm=function(){function e(){hm(this,e),this._events=[]}return dm(e,[{key:\"add\",value:function(e,t,i){e.addEventListener(t,i,!1),this._events.push({target:e,type:t,handler:i})}},{key:\"remove\",value:function(t,i,n){this._events=this._events.filter((function(r){var s=!0;return t&&t!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&e._doRemove(r.target,r.type,r.handler),!s}))}},{key:\"destroy\",value:function(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)})),this._events=[]}}],[{key:\"_doRemove\",value:function(e,t,i){e.removeEventListener(t,i,!1)}}]),e}();function wm(e,t,i){var n=!1;function r(e,t,i){return Math.max(t,Math.min(e,i))}function s(e,s,o){if(o&&(n=!0),n){e.preventDefault();var a=t.getBoundingClientRect(),c=a.width,l=a.height,h=s.clientX,d=s.clientY,u=r(h-a.left,0,c),f=r(d-a.top,0,l);i(u/c,f/l)}}function o(e,t){1===(void 0===e.buttons?e.which:e.buttons)?s(e,e,t):n=!1}function a(e,t){1===e.touches.length?s(e,e.touches[0],t):n=!1}e.add(t,\"mousedown\",(function(e){o(e,!0)})),e.add(t,\"touchstart\",(function(e){a(e,!0)})),e.add(window,\"mousemove\",o),e.add(t,\"touchmove\",a),e.add(window,\"mouseup\",(function(e){n=!1})),e.add(t,\"touchend\",(function(e){n=!1})),e.add(t,\"touchcancel\",(function(e){n=!1}))}var bm=\"keydown\",Fm=\"mousedown\",vm=\"focusin\";function ym(e,t){return(t||document).querySelector(e)}function Am(e){e.preventDefault(),e.stopPropagation()}function Cm(e,t,i,n,r){e.add(t,bm,(function(e){i.indexOf(e.key)>=0&&(r&&Am(e),n(e))}))}var _m=function(){function e(t){hm(this,e),this.settings={popup:\"right\",layout:\"default\",alpha:!0,editor:!0,editorFormat:\"hex\",cancelButton:!1,defaultColor:\"#0cf\"},this._events=new mm,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(t)}return dm(e,[{key:\"setOptions\",value:function(e){var t=this;if(e){var i=this.settings;if(e instanceof HTMLElement)i.parent=e;else{i.parent&&e.parent&&i.parent!==e.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(e,t,i){for(var n in e)i&&i.indexOf(n)>=0||(t[n]=e[n])}(e,i),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var n=e.color||e.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(e){return t.openHandler(e)};this._events.add(r,\"click\",s),Cm(this._events,r,[\" \",\"Spacebar\",\"Enter\"],s),this._popupInited=!0}else e.parent&&!i.popup&&this.show()}}},{key:\"openHandler\",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents=\"none\";var t=e&&e.type===bm?this._domEdit:this.domElement;setTimeout((function(){return t.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:\"closeHandler\",value:function(e){var t=e&&e.type,i=!1;if(e)if(t===Fm||t===vm){var n=(this.__containedEvent||0)+100;e.timeStamp>n&&(i=!0)}else Am(e),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents=\"\",t!==Fm&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:\"movePopup\",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:\"setColor\",value:function(e,t){this._setColor(e,{silent:t})}},{key:\"_setColor\",value:function(e,t){if(\"string\"==typeof e&&(e=e.trim()),e){t=t||{};var i=void 0;try{i=new gm(e)}catch(e){if(t.failSilently)return;throw e}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,t)}}},{key:\"setColour\",value:function(e,t){this.setColor(e,t)}},{key:\"show\",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var e=this._toggleDOM(!0);return this._setPosition(),e}var t=function(e){var t=document.createElement(\"div\");return t.innerHTML=e,t.firstElementChild}(this.settings.template||'
');return this.domElement=t,this._domH=ym(\".picker_hue\",t),this._domSL=ym(\".picker_sl\",t),this._domA=ym(\".picker_alpha\",t),this._domEdit=ym(\".picker_editor input\",t),this._domSample=ym(\".picker_sample\",t),this._domOkay=ym(\".picker_done button\",t),this._domCancel=ym(\".picker_cancel button\",t),t.classList.add(\"layout_\"+this.settings.layout),this.settings.alpha||t.classList.add(\"no_alpha\"),this.settings.editor||t.classList.add(\"no_editor\"),this.settings.cancelButton||t.classList.add(\"no_cancel\"),this._ifPopup((function(){return t.classList.add(\"popup\")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:\"hide\",value:function(){return this._toggleDOM(!1)}},{key:\"destroy\",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:\"_bindEvents\",value:function(){var e=this,t=this,i=this.domElement,n=this._events;function r(e,t,i){n.add(e,t,i)}r(i,\"click\",(function(e){return e.preventDefault()})),wm(n,this._domH,(function(e,i){return t._setHSLA(e)})),wm(n,this._domSL,(function(e,i){return t._setHSLA(null,e,1-i)})),this.settings.alpha&&wm(n,this._domA,(function(e,i){return t._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,\"input\",(function(e){t._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,\"focus\",(function(e){var t=this;t.selectionStart===t.selectionEnd&&t.select()})),this._ifPopup((function(){var t=function(t){return e.closeHandler(t)};r(window,Fm,t),r(window,vm,t),Cm(n,i,[\"Esc\",\"Escape\"],t);var s=function(t){e.__containedEvent=t.timeStamp};r(i,Fm,s),r(i,vm,s),r(e._domCancel,\"click\",t)}));var o=function(t){e._ifPopup((function(){return e.closeHandler(t)})),e.onDone&&e.onDone(e.colour)};r(this._domOkay,\"click\",o),Cm(n,i,[\"Enter\"],o)}},{key:\"_setPosition\",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup((function(i){\"static\"===getComputedStyle(e).position&&(e.style.position=\"relative\");var n=!0===i?\"popup_right\":\"popup_\"+i;[\"popup_top\",\"popup_bottom\",\"popup_left\",\"popup_right\"].forEach((function(e){e===n?t.classList.add(e):t.classList.remove(e)})),t.classList.add(n)}))}},{key:\"_setHSLA\",value:function(e,t,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[e,t,i,n].forEach((function(e,t){(e||0===e)&&(o[t]=e)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:\"_updateUI\",value:function(e){if(this.domElement){e=e||{};var t=this.colour,i=t.hsla,n=\"hsl(\"+360*i[0]+\", 100%, 50%)\",r=t.hslString,s=t.hslaString,o=this._domH,a=this._domSL,c=this._domA,l=ym(\".picker_selector\",o),h=ym(\".picker_selector\",a),d=ym(\".picker_selector\",c);b(0,l,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,b(0,h,i[1]),F(0,h,1-i[2]),a.style.color=r,F(0,d,1-i[3]);var u=r,f=u.replace(\"hsl\",\"hsla\").replace(\")\",\", 0)\"),p=\"linear-gradient(\"+[u,f]+\")\";if(this._domA.style.background=p+\", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em\",!e.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,w=void 0;switch(g){case\"rgb\":w=t.printRGB(m);break;case\"hsl\":w=t.printHSL(m);break;default:w=t.printHex(m)}this._domEdit.value=w}this._domSample.style.color=s}function b(e,t,i){t.style.left=100*i+\"%\"}function F(e,t,i){t.style.top=100*i+\"%\"}}},{key:\"_ifPopup\",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:\"_toggleDOM\",value:function(e){var t=this.domElement;if(!t)return!1;var i=e?\"\":\"none\",n=t.style.display!==i;return n&&(t.style.display=i),n}}]),e}(),xm=document.createElement(\"style\");function km(e){if(Im[e])return Im[e];if(Im[\"chr\"+e]){const t=Im[\"chr\"+e];return Im[e]=t,t}{const r=(t=Math.round(255*Math.random()).toString(10),i=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),\"rgb(\"+t+\",\"+i+\",\"+n+\")\");return Im[e]=r,r}var t,i,n}xm.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:\"\";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:\"\";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:\"\";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(xm),_m.StyleElement=xm;const Im={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};class Sm{constructor(e){this.tracks=[],this.chordSets=[]}addChordSet(e){this.chordSets=this.chordSets.filter((t=>t.name!==e.name)),this.chordSets.push(e);let t=this.tracks.find((t=>e.trackName===t.name));t&&(t.chordSets=t.chordSets.filter((t=>t.name!==e.name)),t.chordSets.push(e)),t||(t=new Em(e),this.tracks.push(t))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(e){return this.tracks.find((t=>e===t.name))}getChordSet(e){return this.chordSets.find((t=>e===t.name))}}class Em{constructor(e){this.name=e.trackName,this.color=e.trackColor,this.visible=!0,this.chordSets=[e],this.id=(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const e=[];for(let t of this.chordSets)for(let i of t.chords)e.push(i);return e}}const Nm=Math.exp(5);class Bm{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(e,t){if(t=t||{},this.config=t,Bm.isInstalled()){this.parent=e,this.groupByTrack=!0===t.groupByTrack,this.chordManager=new Sm(t);const i=document.createElement(\"div\");i.className=\"igv-circview-container\",e.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement(\"div\");n.className=\"igv-circview-circular-genome-view\",i.appendChild(n),this.container=n,t.assembly&&this.setAssembly(t.assembly),this.width=t.width||500,this.height=t.height||500,this.setSize(this.width,this.height)}else console.error(\"JBrowse circular view is not installed\")}createControls(e){const t=document.createElement(\"div\");t.className=\"igv-circview-toolbar\",e.appendChild(t),this.toolbar=t;const i=document.createElement(\"div\");i.className=\"igv-circview-track-panel\",e.appendChild(i),this.controlPanel=i,this.controlPanel.style.display=\"none\";const n=document.createElement(\"div\");n.className=\"igv-circview-toolbar-button-container\",this.toolbar.appendChild(n),this.showControlsButton=document.createElement(\"div\"),this.showControlsButton.className=\"igv-circview-button\",n.appendChild(this.showControlsButton),this.showControlsButton.innerText=\"none\"===this.controlPanel.style.display?\"Show Controls\":\"Hide Controls\",this.showControlsButton.addEventListener(\"click\",(e=>{this.controlPanel.querySelectorAll(\"div\").length>0&&(\"none\"===this.controlPanel.style.display?(this.controlPanel.style.display=\"flex\",e.target.innerText=\"Hide Controls\"):(this.controlPanel.style.display=\"none\",e.target.innerText=\"Show Controls\"))}));let r=document.createElement(\"div\");r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Clear All\",r.addEventListener(\"click\",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement(\"div\"),r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Close\",r.addEventListener(\"click\",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML=\"\",this.controlPanel.appendChild(this.createGroupByCB());const e=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let t of e)this.addToControlPanel(t)}createGroupByCB(){const e=document.createElement(\"input\");e.type=\"checkbox\",e.id=\"groupByCB\",e.style.width=\"1.4em\",e.style.height=\"1.4em\",e.checked=this.groupByTrack,e.onclick=e=>{this.groupByTrack=e.target.checked,this.resetControlPanel(),this.render()};const t=document.createElement(\"label\");t.for=\"groupByCB\",t.innerText=\"Group by track\",t.style.color=\"black\",t.style.paddingLeft=\"10px\";const i=document.createElement(\"div\");return i.style.width=\"100%\",i.style.paddingTop=\"5px\",i.style.paddingBottom=\"5px\",i.style.background=\"rgb(216, 230, 234)\",i.appendChild(e),i.appendChild(t),i}addToControlPanel(e){const t=document.createElement(\"div\");this.controlPanel.appendChild(t);const i=document.createElement(\"div\");i.className=\"igv-circview-button\",t.appendChild(i),i.innerText=!0===e.visible?\"Hide\":\"Show\",i.addEventListener(\"click\",(t=>{!0===e.visible?(this.hideChordSet(e.name),t.target.innerText=\"Show\"):(this.showChordSet(e.name),t.target.innerText=\"Hide\")}));const n=document.createElement(\"input\"),r=e=>200*Math.log(e*Nm),s=document.createElement(\"div\");s.className=\"igv-circview-button\",s.innerHTML=\"    \",t.appendChild(s),s.style.backgroundColor=Mm(e.color,1);const o={parent:s,popup:\"right\",editorFormat:\"rgb\",color:e.color,onChange:({rgbaString:t})=>{s.style.backgroundColor=Mm(t,1),this.setColor(e.name,t),n.value=r(Rm(e.color))}},a=new _m(o);n.setAttribute(\"title\",\"Adjust transparency of arcs\"),n.type=\"range\",n.style.width=\"100px\",n.style.marginRight=\"10px\",n.setAttribute(\"class\",\"range\"),n.setAttribute(\"min\",\"0\"),n.setAttribute(\"max\",\"1000\"),n.value=r(Rm(e.color)),n.oninput=()=>{const t=(i=n.value,Math.exp(i/200)/Nm);var i;this.setColor(e.name,Mm(e.color,t)),a.setColor(e.color)},t.appendChild(n);const c=document.createElement(\"div\");c.style.color=\"black\",t.appendChild(c),c.innerText=c.title=e.name}setAssembly(e){const t=this.genomeId||Lm();if(this.genomeId===t)return;this.chordManager.clearChords(),this.genomeId=t,this.chrNames=new Set(e.chromosomes.map((e=>Dm(e.name))));const i=[],n=[];for(let t of e.chromosomes){const e=Dm(t.name);n.push(t.color||km(e)),i.push({refName:e,uniqueId:e,start:0,end:t.bpLength})}this.assembly={name:e.name,sequence:{trackId:t,type:\"ReferenceSequenceTrack\",adapter:{type:\"FromConfigSequenceAdapter\",features:i}},refNameColors:n},this.render()}addChords(e,t={}){const i=t.name||t.track||\"*\",n=i.split(\" \")[0].replaceAll(\"%20\",\" \"),r={name:i.replaceAll(\"%20\",\" \"),trackName:n,chords:e,color:t.color||\"black\",trackColor:t.trackColor||t.color||\"black\",visible:!0,id:t.id||Lm()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(e,t){if(t=t||e,this.width=e,this.height=t,this.viewState){const i=this.viewState.session.view;i.setWidth(e),i.setHeight(t),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display=\"block\"}hide(){this.parent.style.display=\"none\"}get visible(){return\"none\"!==this.parent.style.display}set visible(e){this.parent.style.display=e?\"block\":\"none\"}hideChordSet(e){let t=this.getChordSet(e);t?(t.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(e){let t=this.getChordSet(e);t?(t.visible=!0,this.render()):console.warn(`No track with name: ${e}`)}deleteTrack(e){let t=this.tracks.findIndex((t=>e===t.name));t>=0&&this.tracks.splice(t,1),this.render()}getChordSet(e){return this.groupByTrack?this.chordManager.getTrack(e):this.chordManager.getChordSet(e)}setColor(e,t){const i=this.getChordSet(e);if(i){i.color=t;const e=i.id;for(let i of this.viewState.config.tracks)if(e===i.trackId){i.displays[0].renderer.strokeColor.set(t);break}}}render(){const{createViewState:e,JBrowseCircularGenomeView:t}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((e=>e.visible)),n=[],r=[];for(let e of i)n.push({trackId:e.id,name:e.name,assemblyNames:[\"forIGV\"],type:\"VariantTrack\",adapter:{type:\"FromConfigAdapter\",features:e.chords}}),r.push(e.color);this.viewState=e({assembly:this.assembly,tracks:n});for(let e=0;e div {\\n margin: 4px;\\n}\\n\\n.igv-circview-track-panel {\\n z-index: 1024;\\n position: absolute;\\n top: 33px;\\n left: 0;\\n width: 100%;\\n height: fit-content;\\n border-bottom-style: solid;\\n border-bottom-color: dimgray;\\n border-bottom-width: thin;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n.igv-circview-track-panel > div {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-circview-track-panel > div > div {\\n margin: 4px;\\n}\\n\\n.igv-circview-swatch-button {\\n cursor: pointer;\\n padding: 5px;\\n width: 8px;\\n height: 8px;\\n border: 1px solid #8d8b8b;\\n border-radius: 16px;\\n}\\n\\n.igv-circview-button {\\n cursor: pointer;\\n padding: 5px;\\n color: #444;\\n vertical-align: middle;\\n text-align: center;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n border: 1px solid #8d8b8b;\\n border-radius: 4px;\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\\n}\\n\\n.igv-circview-button:hover {\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n.igv-circview-button:active {\\n color: #007bff;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n/*# sourceMappingURL=circular-view.css.map */\\n',document.head.insertBefore(e,document.head.childNodes[document.head.childNodes.length-1])}()}const zm=e=>e.startsWith(\"chr\")?e.substring(3):e;function Hm(e){const t=[],i=[];if(e.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n);i.push(Nu(r.name)),t.push({name:r.name,bpLength:r.bpLength})}return t}function Pm(e,t,i,n){const r=t.color||\"rgb(0,0,255)\",s=_s.addAlpha(\"all\"===i.chr?r:Nu(i.chr),n),o=_s.addAlpha(r,n),a=t.name.replaceAll(\" \",\"%20\"),c=\"all\"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;t.browser.circularView.addChords(e,{track:c,color:s,trackColor:o}),t.browser.circularViewVisible||(t.browser.circularViewVisible=!0)}class Om{constructor(e,{minTLENPercentile:t,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===t?.1:t,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(e)}compute(e){for(let n of e)if(n.isProperPair()){var t=Math.abs(n.fragmentLength);this.sumF+=t,this.sumF2+=t*t,this.isizes.push(t);var i=n.pairOrientation;if(\"string\"==typeof i&&4===i.length)switch(\"\"+i.charAt(0)+i.charAt(2)){case\"FF\":case\"RR\":this.ffCount++;break;case\"FR\":this.frCount++;break;case\"RF\":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation=\"ff\":this.frCount/this.totalCount>.9?this.orienation=\"fr\":this.rfCount/this.totalCount>.9&&(this.orienation=\"rf\"),this.minTLEN=0===this.lp?0:Um(this.isizes,this.lp),this.maxTLEN=Um(this.isizes,this.up)}}function Um(e,t){if(0!==e.length){var i=Math.floor(e.length*(t/100));return e.sort((function(e,t){return e-t})),e[i]}}const qm=\"rgb(255,0,255)\",Qm=\"rgb(0,0,255)\",Vm=\"rgb(132, 178, 158)\",jm=new Map;jm.set(\"m\",\"rgb(255,0,0)\"),jm.set(\"h\",qm),jm.set(\"o\",\"rgb(111, 78, 129)\"),jm.set(\"f\",\"rgb(246, 200, 95)\"),jm.set(\"c\",\"rgb(157, 216, 102)\"),jm.set(\"g\",\"rgb(255, 160, 86)\"),jm.set(\"e\",\"rgb(141, 221, 208)\"),jm.set(\"b\",\"rgb(202, 71, 47)\"),jm.set(\"h\",qm),jm.set(\"a\",\"rgb(51,0,111)\"),jm.set(\"NONE_A\",Qm),jm.set(\"NONE_C\",Qm),jm.set(\"NONE_T\",Qm),jm.set(\"NONE_G\",Qm),jm.set(\"NONE_N\",Qm);const Wm=new Map;function Gm(e,t,i){let n=function(e,t){return jm.has(e)?jm.get(e):Vm}(e),r=Xf(t);if(r>255)return n;const s=e+r+i;if(r<0&&(r=0),!Wm.has(s)){const e=\"basemod2\"===i?Math.max(20,Math.min(255,r*r/50-4*r+200+20)):Math.max(20,Math.min(255,.006127*r*r)),[t,o,a]=_s.rgbComponents(n);Wm.set(s,`rgba(${t},${o},${a},${e/255})`)}return Wm.get(s)}class $m{constructor(e){this.alignmentTrack=e}updateContext(e){this.context=e}drawModifications(e,t,i,n,r,s){const{ctx:o,pixelEnd:a,bpStart:c,bpPerPixel:l}=n,h=e.getBaseModificationSets();if(h){let n;const d=r.split(\":\");2==d.length&&(r=d[0],n=d[1]);for(let d of e.blocks){if(\"S\"===d.type)continue;const e=t,u=i;let f=Math.max(1,1/l);for(let t=d.seqOffset;ta)break;if(i+f<0)continue;let p,g=-1,m=255,w=0;for(let e of h)if((!n||e.modification===n)&&e.containsPosition(t)){const i=Xf(e.likelihoods.get(t));m-=i,(!p||i>g)&&(p=e.modification,w=e.canonicalBase,g=i)}if(p){const t=255*s;let n;m>g&&\"basemod2\"===r&&m>=t?n=Gm(\"NONE_\"+w,m,r):g>=t&&(n=Gm(p,g,r)),o.fillStyle=n,f<3&&(f=3,i--),o.fillRect(i,e,f,Math.max(1,u-2))}}}}}}const Km=new Set([\"firstOfPairStrand\"]);class Ym extends Hl{static defaults={viewAsPairs:!1,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,colorBy:void 0,groupBy:void 0,displayMode:\"EXPANDED\",alignmentRowHeight:14,squishedRowHeight:3,negStrandColor:\"rgba(150, 150, 230, 0.75)\",posStrandColor:\"rgba(230, 150, 150, 0.75)\",baseModPosStrandColor:\"rgb(195, 195, 195)\",baseModNegStrandColor:\"rgb(195, 210, 195)\",insertionColor:\"rgb(138, 94, 161)\",insertionTextColor:\"white\",showInsertionText:!1,deletionColor:\"black\",deletionTextColor:\"black\",showDeletionText:!1,skippedColor:\"rgb(150, 170, 170)\",pairConnectorColor:void 0,smallTLENColor:\"rgb(0, 0, 150)\",largeTLENColor:\"rgb(200, 0, 0)\",expectedPairOrientation:\"fr\",rlColor:\"rgb(0, 150, 0)\",rrColor:\"rgb(20, 50, 200)\",llColor:\"rgb(0, 150, 150)\",bamColorTag:\"YC\",hideSmallIndels:!1,indelSizeThreshold:1,highlightColor:void 0,minTLEN:void 0,maxTLEN:void 0,tagColorPallete:\"Set1\"};_colorTables=new Map;_baseModifications=new Set;constructor(e,t){super(e,t),(e.colorTable||e.tagColorTable)&&(this.colorTable=new ao(e.tagColorTable)),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.pairOrienation&&(this.expectedPairOrientation=e.pairOrientation),e.smallFragmentLengthColor&&(this.smallTLENColor=e.smallFragmentLengthColor),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.minFragmentLength&&(this.minTLEN=e.minFragmentLength),e.maxFragmentLength&&(this.maxTLEN=e.maxFragmentLength),e.displayMode&&(this.displayMode=e.displayMode.toUpperCase()),e.colorBy&&e.colorByTag&&(this.colorBy=e.colorBy+\":\"+e.colorByTag),this.featureSource=this.parent.featureSource,this.top=0===e.coverageTrackHeight?0:e.coverageTrackHeight+5,this.pairColors={RL:this.rlColor,RR:this.rrColor,LL:this.llColor},e.highlightedReads&&this.setHighlightedReads(e.highlightedReads),this.hasPairs=!1,this.hasSupplemental=!1,this._groupByTags=[],this._groupByPositions=[],e.groupBy&&(this.groupBy=e.groupBy,e.groupBy.startsWith(\"base:\")&&this._groupByPositions.push(e.groupBy.substring(5)),e.groupBy.startsWith(\"tag:\")&&this._groupByTags.push(e.groupBy.substring(4))),this._locusChange=Zm.bind(this),this.browser.on(\"locuschange\",this._locusChange)}init(e){this.parent=e.parent,delete e.parent,super.init(e)}dispose(){this.browser.off(\"locuschage\",this._locusChange)}get baseModRenderer(){return this._baseModRenderer||(this._baseModRenderer=new $m(this)),this._baseModRenderer}get baseModificationThreshold(){return this.parent.baseModificationThreshold}setTop(e,t){this.top=0===e.height||!1===t?0:5+e.height}setHighlightedReads(e,t){if(!Array.isArray(e)||!e.every((e=>\"string\"==typeof e)))throw new Error(\"AlignmentTrack.setHighlightedReads() only accept array of strings\");t&&(this.highlightColor=t),this.highlightedReads=new Set(e)}computePixelHeight(e){if(e.packedGroups){let t=e.hasDownsampledIntervals()?15:0;const i=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;for(let n of e.packedGroups.values())t+=i*n.length+10;return t+5}return 0}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=r+s*n+1,a=this.showSoftClips,c=this.showAllBases,l=this.browser.nucleotideColors;i.save();for(let e of t.baseModificationKeys)this._baseModifications.add(e.modification);let h=t.sequence;h&&(h=h.toUpperCase());let d=0;this.colorBy||(this.colorBy=this.hasPairs?\"unexpectedPair\":\"none\");let u=e.pixelTop;this.top&&i.translate(0,this.top);const f=u+e.pixelHeight;t.hasDownsampledIntervals()?(d=15,t.downsampledIntervals.forEach((function(e){var t=(e.start-r)/n,s=(e.end-r)/n;s-t>5&&(t+=1,s-=1),xo.fillRect(i,t,2,s-t,8,{fillStyle:\"black\"})}))):d=0,this.alignmentsYOffset=d;const p=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight,g=t.packedGroups;if(g){let t=d;for(let n of g.keys()){const a=g.get(n),c=a.rows,l=c.length;a.pixelTop=t;for(let e=0;ef)break;if(t+no)break;!0!==e.hidden&&(e instanceof Qf?(m.call(this,e,t,n),w.call(this,e.firstAlignment,t,n),e.secondAlignment&&w.call(this,e.secondAlignment,t,n)):w.call(this,e,t,n))}t+=p}}if(a.pixelBottom=t,this.groupBy&&n){i.save(),i.font=\"400 12px sans-serif\";const r=i.measureText(n),o=r.width+10,c=-e.pixelShift+e.viewportWidth-o-10,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+10,h=Math.min(a.pixelTop+l-1,a.pixelBottom);i.textAlign=\"center\",i.fillStyle=\"white\",i.strokeStyle=\"lightGray\",xo.roundRect(i,c,h-r.actualBoundingBoxAscent-5,o,l,2,1,1),i.fillStyle=\"black\",i.fillText(n,c+o/2,h),xo.dashedLine(i,0,t,s,t),i.restore(),t+=10}}}function m(e,t,s){var a=this.getConnectorColor(e.firstAlignment),c=(e.connectingStart-r)/n,l=(e.connectingEnd-r)/n,h=t+s/2;e.connectingEndo||(e.mq<=0&&(a=_s.addAlpha(a,.15)),xo.setProperties(i,{fillStyle:a,strokeStyle:a}),xo.strokeLine(i,c,h,l,h))}function w(e,d,u){if(e.start+e.lengthOnRefo)return;const f=a?e.blocks:e.blocks.filter((e=>\"S\"!==e.type));let g=this.getAlignmentColor(e);const m=g;e.mq<=0&&(g=_s.addAlpha(g,.15)),xo.setProperties(i,{fillStyle:g,strokeStyle:m});const w=[];for(let e=0;eo))break}if(e.gaps){const t=d+u/2;for(let s of e.gaps){const e=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-e,c=s.len.toString(),l=6*c.length,h=e+a/2,u=\"D\"===s.type?this.deletionColor:this.skippedColor;if(xo.strokeLine(i,e,t,o,t,{strokeStyle:u,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=l+8){const e=h-l/2;xo.fillRect(i,e-1,d-1,l+2,12,{fillStyle:\"white\"}),xo.fillText(i,c,e,d+10,{font:\"normal 10px monospace\",fillStyle:this.deletionTextColor})}}}if(e.insertions&&this.showInsertions){let t=-1;for(let s of e.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.starto)break;const e=s.start-r,a=s.len.toString(),c=2+6*a.length,l=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,h=Math.max(Math.min(c,l),2),f=e/n-h/2;if(f-t>2){const e={fillStyle:this.insertionColor};xo.fillRect(i,f-2,d,h+4,2,e),xo.fillRect(i,f,d+2,h,u-4,e),xo.fillRect(i,f-2,d+u-2,h+4,2,e),this.showInsertionText&&s.len>1&&l>c&&xo.fillText(i,a,f+1,d+10,{font:\"normal 10px monospace\",fillStyle:this.insertionTextColor}),t=f}}}for(let{bbox:e,baseColor:t,readChar:r}of w){if(n<=.1&&e.height>=8){const n=Math.min(10,e.height);i.font=n+\"px sans-serif\";const s=e.x+e.width/2;xo.strokeText(i,r,s-i.measureText(r).width/2,n-1+e.y,{strokeStyle:t})}else xo.fillRect(i,e.x,e.y,e.width,e.height,{fillStyle:t})}if(this.colorBy&&this.colorBy.startsWith(\"basemod\")){const t={ctx:i,bpPerPixel:n,bpStart:r,bpEnd:o,pixelEnd:s};this.baseModRenderer.drawModifications(e,d,u,t,this.colorBy,this.baseModificationThreshold)}function b(o,a){const w=[],b=o.start-t.start,F=(o.start-r)/n,v=(o.start+o.len-r)/n,y=Math.max(1,v-F),A=100/n,C=Math.min(p/2,A/6),_=\"S\"===o.type,x=e.mq<=0||this.selectedReadName===e.readName||_||this.highlightedReads&&this.highlightedReads.has(e.readName);let k=m;this.selectedReadName===e.readName?k=\"red\":_?k=\"rgb(50,50,50)\":this.highlightedReads&&this.highlightedReads.has(e.readName)&&(k=this.highlightColor||\"#00ff00\");const I=!0===e.strand&&a===f.length-1,S=!1===e.strand&&0===a;if(I|S){let e,t;I?(e=[F,v,v+C,v,F,F],t=[d,d,d+u/2,d+u,d+u,d]):S&&(e=[v,F,F-C,F,v,v],t=[d,d,d+u/2,d+u,d+u,d]),xo.fillPolygon(i,e,t,{fillStyle:g}),x&&xo.strokePolygon(i,e,t,{strokeStyle:k})}else xo.fillRect(i,F,d,y,u,{fillStyle:g}),x&&(i.save(),i.strokeStyle=k,i.strokeRect(F,d,y,u),i.restore());if(_||c||this.showMismatches&&h&&e.seq&&\"*\"!==e.seq){const t=e.seq?e.seq.toUpperCase():void 0,i=e.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let e=0,p=o.len;es)break;let g=t?t.charAt(a+e):\"\";const m=b+e>=0?h.charAt(b+e):\"\";if(\"=\"===g&&(g=m),\"X\"===g||m!==g||_||c){let t=l[g]||\"rgb(0,0,0)\";if(!_&&void 0!==i&&i.length>a+e){t=Xm(i[a+e],t)}w.push({bbox:{x:p,y:d,width:f,height:u},baseColor:t,readChar:g})}}}return w}}i.restore()}popupData(e){const t=this.getClickedObject(e);return t?t.popupData(e.genomicLocation):void 0}menuItemList(){let e=[];e.push(\"
\");const t=Bt('
');t.text(\"Color by:\"),e.push({name:void 0,object:t,click:void 0,init:void 0});const i=[];i.push({key:\"none\",label:\"none\"}),i.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(i.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),i.push({key:\"pairOrientation\",label:\"pair orientation\"}),i.push({key:\"tlen\",label:\"insert size (TLEN)\"}),i.push({key:\"unexpectedPair\",label:\"pair orientation & insert size (TLEN)\"})),i.push({key:\"tag\",label:\"tag\"});for(let t of i){const i=void 0===this.colorBy&&\"none\"===t.key||this.colorBy===t.key;e.push(this.colorByCB(t,i))}const n=this._baseModifications.size;if(n>0){e.push('
');let t=1===n?\"base modification\":\"base modification (all)\";if(e.push(this.basemodColorByCB({key:\"basemod\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod:\"+t,label:`base modification (${Kf(t)})`}));if(e.push('
'),t=1===n?\"base modification 2-color\":\"base modification 2-color (all)\",e.push(this.basemodColorByCB({key:\"basemod2\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod2:\"+t,label:`base modification 2-color (${Kf(t)})`}))}e.push(\"
\");const r=Bt('
');r.text(\"Group by:\"),e.push({name:void 0,object:r,click:void 0,init:void 0});const s=[];s.push({key:\"none\",label:\"none\"}),s.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(s.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),s.push({key:\"pairOrientation\",label:\"pair orientation\"}),s.push({key:\"mateChr\",label:\"chromosome of mate\"})),s.push({key:\"chimeric\",label:\"chimeric\"}),s.push({key:\"supplementary\",label:\"supplementary flag\"}),s.push({key:\"readOrder\",label:\"read order\"});for(let e of this._groupByTags)s.push({key:`tag:${e}`,label:`tag:${e}`});for(let e of this._groupByPositions)s.push({key:`base:${e}`,label:`base:${e}`});s.push({key:\"tag\",label:\"tag...\"});for(let t of s){const i=void 0===this.groupBy&&\"none\"===t.key||this.groupBy===t.key;e.push(this.groupByCB(t,i))}e.push(\"
\"),e.push({object:Bt(Dl(\"Show all bases\",this.showAllBases)),click:function(){this.alignmentTrack.showAllBases=!this.alignmentTrack.showAllBases,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show mismatches\",this.showMismatches)),click:function(){this.alignmentTrack.showMismatches=!this.alignmentTrack.showMismatches,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show insertions\",this.showInsertions)),click:function(){this.alignmentTrack.showInsertions=!this.alignmentTrack.showInsertions,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show soft clips\",this.showSoftClips)),click:function(){this.alignmentTrack.showSoftClips=!this.alignmentTrack.showSoftClips;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.repaintViews()}}),this.hasPairs&&(e.push(\"
\"),e.push({object:Bt(Dl(\"View as pairs\",this.viewAsPairs)),click:function(){const e=!this.alignmentTrack.viewAsPairs;if(e&&this.groupBy&&!Km.has(this.groupBy))return void this.browser.alert.present(`'View as Pairs' is incompatible with 'Group By ${this.groupBy}'`);this.alignmentTrack.viewAsPairs=e;const t=this.getCachedAlignmentContainers();for(let e of t)e.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(e.push(\"
\"),this.hasPairs&&e.push({label:\"Add discordant pairs to circular view\",click:function(){for(let e of this.trackView.viewports)this.addPairedChordsForViewport(e)}}),this.hasSupplemental&&e.push({label:\"Add split reads to circular view\",click:function(){for(let e of this.trackView.viewports)this.addSplitChordsForViewport(e)}})),e.push(\"
\");const o=Bt('
');o.text(\"Display mode:\"),e.push({name:void 0,object:o,click:void 0,init:void 0});for(let t of[\"EXPANDED\",\"SQUISHED\",\"FULL\"])e.push({object:Bt(Dl(t.toLowerCase(),this.displayMode===t)),click:function(){this.alignmentTrack.setDisplayMode(t)}});return e}setDisplayMode(e){const t=\"FULL\"===this.displayMode||\"FULL\"===e;if(this.displayMode=e,t){const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this)}this.trackView.checkContentHeight(),this.trackView.repaintViews()}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"tag\"!==e.key){function n(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){const t=this.alignmentTrack.colorBy.startsWith(\"tag:\")?this.alignmentTrack.colorBy.substring(4):\"\";this.browser.inputDialog.present({label:\"Tag Name\",value:t,callback:e=>{const t=this.alignmentTrack;e?(t.colorBy=\"tag:\"+e,t.colorTable||(t.colorTable=new oo(\"Set1\"))):t.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}basemodColorByCB(e){const t=this.colorBy===e.key;return{name:void 0,object:Bt(Dl(e.label,t)),click:function(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()},init:void 0}}groupByCB(e,t){return{name:void 0,object:Bt(Dl(e.label,t)),dialog:function(t){const i=()=>this.alignmentTrack.repackAlignments();if(\"tag\"===e.key){let e=\"\";this.alignmentTrack.groupBy&&this.alignmentTrack.groupBy.startsWith(\"tag:\")&&(e=this.alignmentTrack.groupBy.substring(4)),this.browser.inputDialog.present({label:\"Tag Name\",value:e,callback:e=>{e&&(this.alignmentTrack.groupBy=\"tag:\"+e,this.alignmentTrack._groupByTags.push(e),i())}},t)}else\"none\"===e.key?this.alignmentTrack.groupBy=void 0:this.alignmentTrack.groupBy=e.key,i()},init:void 0}}repackAlignments(){const e=this.getCachedAlignmentContainers();for(let t of e)\"function\"==typeof t.pack&&t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}contextMenuItemList(e){const t=e.viewport,i=[],n=i=>{const n=this.sortObject,r=!n||n.position!==Math.floor(e.genomicLocation)||!n.direction,s={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:i,direction:r,sortAsPairs:t.trackView.track.viewAsPairs};this.sortObject=s,t.cachedFeatures.sortRows(s),t.repaint()};i.push(\"Sort by...\"),i.push({label:\"  base\",click:()=>n(\"BASE\")}),i.push({label:\"  read strand\",click:()=>n(\"strand\")}),i.push({label:\"  start location\",click:()=>n(\"START\")}),i.push({label:\"  insert size\",click:()=>n(\"INSERT_SIZE\")}),i.push({label:\"  gap size\",click:()=>n(\"GAP_SIZE\")}),i.push({label:\"  chromosome of mate\",click:()=>n(\"MATE_CHR\")}),i.push({label:\"  mapping quality\",click:()=>n(\"MQ\")}),i.push({label:\"  read name\",click:()=>n(\"READ_NAME\")}),i.push({label:\"  aligned read length\",click:()=>n(\"ALIGNED_READ_LENGTH\")}),i.push({label:\"  tag\",click:()=>{const i=this.sortObject,n=!i||i.position!==Math.floor(e.genomicLocation)||!i.direction,r={label:\"Tag Name\",value:this.sortByTag?this.sortByTag:\"\",callback:i=>{if(i){const r={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:\"TAG\",tag:i,direction:n};this.sortByTag=i,this.sortObject=r,t.cachedFeatures.sortRows(r),t.repaint()}}};this.browser.inputDialog.present(r,e.event)}}),i.push(\"
\");const r=`${t.referenceFrame.chr}:${Rt(Math.floor(e.genomicLocation)+1)}`;i.push({label:`Group by base @${r}`,click:()=>{this._groupByPositions.push(r),this.groupBy=`base:${r}`;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),i.push(\"
\");const s=this.getClickedObject(e);if(s){const t=this.showSoftClips,n=\"function\"==typeof s.alignmentContaining?s.alignmentContaining(e.genomicLocation,t):s;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:\"View mate in split screen\",click:()=>{if(n.mate){const t=e.viewport.referenceFrame,i=this.browser.genome.getChromosome(n.mate.chr);if(i){this.selectedReadName=n.readName;const r=t.bpPerPixel*e.viewport.getWidth(),s=n.mate.position-r/2,o=n.mate.position+r/2;this.browser.addMultiLocusPanel(i.name,s,o,t)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:\"View read sequence\",click:()=>{const e=n.seq;e&&\"*\"!==e?this.browser.alert.present(e):this.browser.alert.present(\"Read sequence: *\")}}),Xa()&&i.push({label:\"Copy read sequence\",click:async()=>{const e=n.seq;try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}});const t=n.seq;if(t&&\"*\"!==t){t.length{const e=n.isNegativeStrand()?cc(t):t,i=`${n.readName} - blat`,r=`${this.name} - ${i}`;jd({sequence:e,browser:this.browser,name:i,title:r})}});const e=n.softClippedBlocks();e.left&&e.left.len>20&&e.left.len{const i=t.substr(e.left.seqOffset,e.left.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat left clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}}),e.right&&e.right.len>20&&e.right.len{const i=t.substr(e.right.seqOffset,e.right.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat right clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}})}i.push(\"
\")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:\"Add discordant pairs to circular view\",click:()=>{this.addPairedChordsForViewport(t)}}),this.hasSupplemental&&i.push({label:\"Add split reads to circular view\",click:()=>{this.addSplitChordsForViewport(t)}}),i.push(\"
\")),i}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t)return;const i=e.y-this.top,n=e.genomicLocation;if(t.packedGroups){let e=Number.MAX_VALUE;for(let r of t.packedGroups.values())if(e=Math.min(e,r.pixelTop),i>r.pixelTop&&i<=r.pixelBottom){const e=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let t=Math.floor((i-r.pixelTop)/e);if(t>=0&&te.containsLocation(n,this.showSoftClips)));if(e.length>0)return e[0]}}}if(i=n)return e}getConnectorColor(e){if(this.pairConnectorColor)return this.pairConnectorColor;let t=this.colorBy;switch(t&&t.startsWith(\"tag:\")&&(t.substring(4),t=\"tag\"),t){case\"strand\":case\"firstOfPairStrand\":case\"pairOrientation\":case\"tag\":return this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(200, 200, 200)\";default:return this.getAlignmentColor(e)}}getAlignmentColor(e){let t;t=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(185, 185, 185)\";let i,n=this.colorBy;switch(n&&n.startsWith(\"tag:\")&&(i=n.substring(4),n=\"tag\"),n){case\"basemod\":case\"basemod2\":t=e.strand?this.baseModPosStrandColor:this.baseModNegStrandColor;break;case\"strand\":t=e.strand?this.posStrandColor:this.negStrandColor;break;case\"firstOfPairStrand\":const r=e.firstOfPairStrand;void 0!==r&&(t=r?this.posStrandColor:this.negStrandColor);break;case\"unexpectedPair\":case\"pairOrientation\":if(e.pairOrientation){const i=ep[this.expectedPairOrientation];if(i){const n=this.pairColors[i[e.pairOrientation]];if(n){t=n;break}}}if(\"pairOrientation\"===n)break;case\"tlen\":case\"fragmentLength\":e.mate&&e.isMateMapped()&&(e.mate.chr!==e.chr?t=Nu(e.mate.chr):this.minTemplateLength&&Math.abs(e.fragmentLength)this.maxTemplateLength&&(t=this.largeTLENColor));break;case\"tag\":const s=e.tags()[i];void 0!==s&&(this.bamColorTag===i&&(t=_s.createColorStringSafe(s)),this.colorTable||(this.colorTable=new oo(this.tagColorPallete)),t=this.colorTable.getColor(s))}return t}get nucleotideColors(){return this.browser.nucleotideColors}get minTemplateLength(){return void 0!==this.minTLEN?this.minTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.minTLEN:0}get maxTemplateLength(){return void 0!==this.maxTLEN?this.maxTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.maxTLEN:1e3}getState(){const e=super.getState();return this.highlightedReads&&(e.highlightedReads=Array.from(this.highlightedReads)),e}get name(){return this.parent.name}set name(e){this.parent.name=e}get color(){return this.parent.color}set color(e){this.parent.color=e}get trackView(){return this.parent.trackView}get getCachedAlignmentContainers(){return this.parent.getCachedAlignmentContainers}get sortObject(){return this.parent.sortObject}set sortObject(e){this.parent.sortObject=e}addPairedChordsForViewport(e){return this.parent.addPairedChordsForViewport(e)}addSplitChordsForViewport(e){return this.parent.addSplitChordsForViewport(e)}}function Xm(e,t){let i;return i=e<5?.1:Math.max(.1,Math.min(1,.1+.9*(e-5)/15)),i=Math.round(10*i)/10,i<1&&(t=_s.addAlpha(t,i)),t}function Zm(){\"FULL\"!==this.displayMode||this.browser.isTrackPanning()||this.repackAlignments()}function Jm(e,t,i,n,r,s,o,a,c){const l=o.baseModCounts,h=o.coverageMap;if(l){let o;const d=a.split(\":\");2==d.length&&(a=d[0],o=d[1]);const u=Array.from(l.allModifications);u.sort(Vf.compare);const f=h.getTotalCount(s);if(!u.filter((e=>o?o===e.modification:!e.modification.startsWith(\"NONE_\"))).find((e=>l.getCount(s,e,0,!1)>0)))return;for(let d of u){if(d.modification.startsWith(\"NONE_\")&&\"basemod2\"!==a)continue;if(o&&o!==d.modification&&!d.modification.startsWith(\"NONE_\"))continue;const u=d.base,p=oc(u),g=h.getCount(s,u)+h.getCount(s,p),m=l.simplexModifications.has(d.modification)?h.getPosCount(s,u)+h.getNegCount(s,p):g;if(0==m)continue;const w=\"basemod2\"===a,b=l.getCount(s,d,c,w);if(0==b)continue;const F=g/f*(b/m),v=Math.round(F*r),y=l.getLikelihoodSum(s,d,c,w)/b,A=i-v,C=Gm(d.modification,y,a);e.fillStyle=C,e.fillRect(t,A,n,v),i=A}}}class ew{constructor(e,t){this.featureType=\"numeric\",this.parent=t,this.featureSource=t.featureSource,this.paintAxis=cd,this.top=0,this.autoscale=e.autoscale||void 0===e.max,e.coverageColor&&(this.color=e.coverageColor),this.autoscale||(this.dataRange={min:e.min||0,max:e.max})}get height(){return this.parent.coverageTrackHeight}draw(e){const t=e.pixelTop;e.pixelHeight;const i=this.parent.browser.nucleotideColors;if(t>this.height)return;const n=e.context,r=e.features,s=r.coverageMap;let o;s.refSeq&&(o=s.refSeq.toUpperCase());const a=e.bpPerPixel,c=e.bpStart,l=c+e.pixelWidth*a+1;let h;h=this.color?this.color:this.parent.color&&\"function\"!=typeof this.parent.color?_s.darkenLighten(this.parent.color,-35):\"rgb(150, 150, 150)\",xo.setProperties(n,{fillStyle:h,strokeStyle:h});const d=Math.max(1,1/a);for(let e=0,t=s.coverage.length;el)break;const i=s.coverage[e];if(!i)continue;const r=i.total/this.dataRange.max*this.height,o=this.height-r,h=(t-c)/a;xo.fillRect(n,h,o,d,r)}if(o)for(let e=0,t=s.coverage.length;el)break;const h=s.coverage[e];if(!h)continue;const u=h.total/this.dataRange.max*this.height;let f=this.height-u;const p=Math.floor((t-c)/a),g=o[e];if(this.parent.colorBy&&this.parent.colorBy.startsWith(\"basemod\"))Jm(n,p,this.height,d,u,t,r,this.parent.colorBy,this.parent.baseModificationThreshold);else if(h.isMismatch(g)){xo.setProperties(n,{fillStyle:i[g]}),xo.fillRect(n,p,f,d,u);let e=0;for(let t of[\"A\",\"C\",\"T\",\"G\"]){const r=(h[\"pos\"+t]+h[\"neg\"+t])/this.dataRange.max*this.height;f=this.height-r-e,e+=r,xo.setProperties(n,{fillStyle:i[t]}),xo.fillRect(n,p,f,d,r)}}}}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t||0===t.length)return;const i=Math.floor(e.genomicLocation),n=t.coverageMap,r=Math.floor(i-n.bpStart),s=n.coverage[r];return s?{coverage:s,baseModCounts:t.baseModCounts,hoverText:()=>n.coverage[r].hoverText()}:void 0}popupData(e){const t=[],{coverage:i,baseModCounts:n}=this.getClickedObject(e);if(i){const r=Math.floor(e.genomicLocation),s=e.viewport.referenceFrame;t.push(s.chr+\":\"+Rt(1+r)),t.push({name:\"Total Count\",value:i.total});let o=i.posA+i.negA;o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posA+\"+, \"+i.negA+\"- )\"),t.push({name:\"A\",value:o}),o=i.posC+i.negC,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posC+\"+, \"+i.negC+\"- )\"),t.push({name:\"C\",value:o}),o=i.posG+i.negG,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posG+\"+, \"+i.negG+\"- )\"),t.push({name:\"G\",value:o}),o=i.posT+i.negT,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posT+\"+, \"+i.negT+\"- )\"),t.push({name:\"T\",value:o}),o=i.posN+i.negN,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posN+\"+, \"+i.negN+\"- )\"),t.push({name:\"N\",value:o}),t.push(\"
\"),t.push({name:\"DEL\",value:i.del.toString()}),t.push({name:\"INS\",value:i.ins.toString()}),n&&(t.push(\"
\"),t.push(...n.popupData(r,this.parent.colorBy)))}return t}}class tw extends Hl{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,height:300,coverageTrackHeight:50,baseModificationThreshold:0};constructor(e,t){super(e,t)}init(e){this.type=\"alignment\",this.featureSource=new cm(e,this.browser);const t=Object.assign({parent:this},e);this.coverageTrack=new ew(t,this);const i=Object.assign({parent:this},e);this.alignmentTrack=new Ym(i,this.browser),super.init(e),this.showAlignments||(this._height=this.coverageTrackHeight),e.sort&&(Array.isArray(e.sort)?this.assignSort(e.sort[0]):this.assignSort(e.sort))}dispose(){this.alignmentTrack.dispose()}setHighlightedReads(e,t){this.alignmentTrack.setHighlightedReads(e,t),this.updateViews()}get expectedPairOrientation(){return this.alignmentTrack.expectedPairOrientation}get viewAsPairs(){return this.alignmentTrack.viewAsPairs}get colorBy(){return this.alignmentTrack.colorBy}set height(e){this._height=e,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?e-this.coverageTrackHeight:e)}get height(){return this._height}sort(e){e=this.assignSort(e);for(let t of this.trackView.viewports)if(t.containsPosition(e.chr,e.position)){const i=t.cachedFeatures;i&&(i.sortRows(e),t.repaint())}}assignSort(e){if(e.locus){const t=function(e){const t=e.split(\":\"),i=t[1].split(\"-\"),n={chr:t[0],start:Number.parseInt(i[0].replace(/,/g,\"\"))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,\"\")):n.end=n.start+1,n}(e.locus);e.chr=t.chr,e.position=t.start}else e.position--;return e.direction=\"ASC\"===e.direction||!0===e.direction,e.chr=this.browser.genome.getChromosomeName(e.chr),this.sortObject=e,this.sortObject}async getFeatures(e,t,i,n,r){const s=await this.featureSource.getAlignments(e,t,i);if(s.viewport=r,s.hasPairs&&!this._pairedEndStats&&!this.config.maxFragmentLength){const e=new Om(s.allAlignments(),this.config);e.totalCount>99&&(this._pairedEndStats=e)}s.pack(this.alignmentTrack);const o=this.sortObject;return o&&o.chr===e&&o.position>=t&&o.position<=i&&s.sortRows(o),this.alignmentTrack.hasPairs=this.alignmentTrack.hasPairs||s.hasPairs,s}computePixelHeight(e){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(e):0)}draw(e){xo.fillRect(e.context,0,e.pixelTop,e.pixelWidth,e.pixelHeight,{fillStyle:\"rgb(255, 255, 255)\"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display=\"block\",this.coverageTrack.draw(e)):this.trackView.axisCanvas.style.display=\"none\",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(e))}paintAxis(e,t,i){this.coverageTrack.paintAxis(e,t,this.coverageTrackHeight)}contextMenuItemList(e){return this.alignmentTrack.contextMenuItemList(e)}popupData(e){return!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y{if(!this.autoHeight){const e=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(e)}};return e.push(\"
\"),e.push({object:Bt(Dl(\"Show Coverage\",this.showCoverage)),click:function(){this.showCoverage=!this.showCoverage,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show Alignments\",this.showAlignments)),click:function(){this.showAlignments=!this.showAlignments,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e}getState(){const e=super.getState();return this.sortObject&&(e.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?\"ASC\":\"DESC\"}),Object.assign(e,this.alignmentTrack.getState()),e}getCachedAlignmentContainers(){return this.trackView.viewports.map((e=>e.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(e){this.coverageTrack.dataRange=e}get logScale(){return this.coverageTrack.logScale}set logScale(e){this.coverageTrack.logScale=e}get autoscale(){return this.coverageTrack.autoscale}set autoscale(e){this.coverageTrack.autoscale=e}addPairedChordsForViewport(e){const t=this.maxTemplateLength,i=[],n=e.referenceFrame;for(let r of e.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>t&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>t)&&i.push(r));Pm((e=>{const t=[];for(let i of e)if(i.paired)i.firstAlignment&&i.secondAlignment&&t.push({uniqueId:i.readName,refName:zm(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:zm(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const e=i.mate;e&&e.chr&&e.position&&t.push({uniqueId:i.readName,refName:zm(i.chr),start:i.start,end:i.end,mate:{refName:zm(e.chr),start:e.position-1,end:e.position}})}return t})(i),this,n,.02)}addSplitChordsForViewport(e){const t=[],i=e.referenceFrame;for(let n of e.cachedFeatures.allAlignments()){const e=n.hasTag(\"SA\");n.end>=i.start&&n.start<=i.end&&e&&t.push(n)}Pm((e=>{const t=e=>{const t=gp(e.tags().SA);let n=0;for(let r of t)r.start!==e.start&&i.push({uniqueId:`${e.readName}_${n++}`,refName:zm(e.chr),start:e.start,end:e.end,mate:{refName:zm(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of e)i.paired?(t(i.firstAlignment),i.secondAlignment&&t(i.secondAlignment)):t(i);return i})(t),this,i,.02)}}class iw extends Hl{static defaults={height:250,theta:Math.PI/4,arcOrientation:\"UP\",showBlocks:!0,blockHeight:3,thickness:1,color:\"rgb(180,25,137)\",alpha:.02,logScale:!0};constructor(e,t){super(e,t)}init(e){super.init(e),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(e){if(!e.arcType)return\"nested\";switch(e.arcType){case\"chiapet\":return\"inView\";case\"chiapetoutbound\":return\"partialInView\";default:return e.arcType}}(e),this.painter={flipAxis:\"DOWN\"===this.arcOrientation,dataRange:this.dataRange,paintAxis:cd},e.valueColumn?(this.valueColumn=e.valueColumn,this.hasValue=!0):e.useScore&&(this.hasValue=!0,this.valueColumn=\"score\"),e.max?(this.dataRange={min:e.min||0,max:e.max},this.autoscale=!1):this.autoscale=!0,e.featureSource?(this.featureSource=e.featureSource,delete e._featureSource):(this.featureSource=Ad(e,this.browser.genome),this.featureSource.getWGFeatures=aw)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(e){\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?this.drawProportional(e):this.drawNested(e)}drawNested(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.viewportWidth,s=e.bpPerPixel,o=e.bpStart,a=s;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const c=e.features;if(c){(function(){let e=0;for(let t of c){let n=(t.start-o)/a,r=(t.end-o)/a;n>=0&&r<=i&&(e=Math.max(e,r-n))}let t=Math.min(r,e)/2;if(e>0){let e=(n-10)/t;this.theta=function(e){let t,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(t=0;te);t++);let r=0===t?0:i[t-1],s=ti)continue;let f=u-d;f<3&&(f=3,d--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,w=d+p;let b,F,v;if(s?(b=this.height+m,F=Math.PI+Math.PI/2-this.theta,v=Math.PI+Math.PI/2+this.theta):(b=-m,F=Math.PI/2-this.theta,v=Math.PI/2+this.theta),this.showBlocks&&\"all\"!==e.chr){const i=(e.start1-o)/a,n=(e.end1-o)/a,r=(e.start2-o)/a,c=(e.end2-o)/a,l=s?-this.blockHeight:this.blockHeight;t.fillRect(i,h,n-i,l),t.fillRect(r,h,c-r,l)}n&&!this.config.useScore&&f>r&&(n=ow(n,this.alpha)),t.strokeStyle=n,t.fillStyle=n,t.beginPath(),t.arc(w,b,g,F,v,!1),t.stroke(),e.drawState={xc:w,yc:b,r:g}}else{let r=Math.round((e.start-o)/a),c=Math.round((e.end-o)/a);if(c<0||r>i)continue;let l=c-r;l<3&&(l=3,r--);const h=e.chr===e.chr1?e.chr2:e.chr1;t.strokeStyle=n,t.fillStyle=ow(Nu(h),.5),s?(t.fillRect(r,this.height/2,l,this.height/2),t.fillText(h,r+l/2,this.height/2-5),e.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(t.fillRect(r,0,l,this.height/2),t.fillText(h,r+l/2,this.height/2+13),e.drawState={x:r,y:0,w:l,h:this.height/2})}}}var l}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}drawProportional(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.bpPerPixel,s=e.bpStart,o=r,a=e.referenceFrame.start,c=e.referenceFrame.end,l=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const h=e.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,e.pixelHeight-1,this.logScale),d=l?e.pixelHeight:0;for(let e of h){e.drawState=void 0;const n=this.valueColumn?e[this.valueColumn]:e.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(e.chr1===e.chr2||\"all\"===e.chr){const{m1:i,m2:r}=nw(e,this.browser.genome);let u=Math.round((i-s)/o),f=Math.round((r-s)/o)-u;if(f<3&&(f=3,u--),nthis.dataRange.max)continue;if(\"proportional\"!==this.arcType){const e=\"partialInView\"===this.arcType,t=i>=a&&r<=c;let n=!1,s=!1;if(!t&&e&&(n=a<=i&&i<=c,n||(s=a<=r&&r<=c)),!(t||n||s))continue}const p=f/2,g=u+f/2;e.drawState={xc:g,yc:d,radiusX:p,radiusY:h};const m=l,w=e.color||this.color;if(t.strokeStyle=w,t.lineWidth=e.thickness||this.thickness||1,!0===t.isSVG?t.strokeEllipse(g,d,p,h,0,0,Math.PI,m):(t.beginPath(),t.ellipse(g,d,p,h,0,0,Math.PI,m),t.stroke()),this.alpha&&(t.fillStyle=ow(w,this.alpha),!0===t.isSVG?t.fillEllipse(g,d,p,h,0,0,Math.PI,m):t.fill()),this.showBlocks&&\"all\"!==e.chr){t.fillStyle=w;const i=(e.start1-s)/o,n=(e.end1-s)/o,r=(e.start2-s)/o,a=(e.end2-s)/o,c=l?-this.blockHeight:this.blockHeight;t.fillRect(i,d,n-i,c),t.fillRect(r,d,a-r,c)}}else{let r=Math.round((e.start-s)/o),a=Math.round((e.end-s)/o);if(a<0||r>i||nthis.dataRange.max)continue;const c=Math.min(h,this.height-13);let d=a-r;d<3&&(d=3,r--);const u=e.chr===e.chr1?e.chr2:e.chr1;if(t.font=\"8px sans-serif\",t.textAlign=\"center\",t.fillStyle=ow(Nu(u),.5),l){const i=this.height-c;t.fillRect(r,i,d,c),t.fillText(u,r+d/2,i-5),e.drawState={x:r,y:i,w:d,h:c}}else t.fillRect(r,0,d,c),t.fillText(u,r+d/2,c+13),e.drawState={x:r,y:0,w:d,h:c}}}}}clearAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"})}paintAxis(e,t,i){const n={min:0,max:this.dataRange.max};\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?(this.painter.flipAxis=\"DOWN\"===this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(e,t,i)):this.clearAxis(e,t,i)}menuItemList(){let e=[];if(this.hasValue){e.push(\"
\");const t={nested:\"Nested\",proportional:\"Proportional - All\",inView:\"Proportional - Both Ends in View\",partialInView:\"Proportional - One End in View\"};e.push(\"Arc Type\");for(let i of[\"nested\",\"proportional\",\"inView\",\"partialInView\"])e.push({object:Bt(Dl(t[i],i===this.arcType)),click:function(){this.arcType=i,this.trackView.repaintViews()}})}return e.push(\"
\"),e.push({name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}),e.push({name:this.showBlocks?\"Hide Blocks\":\"Show Blocks\",click:function(){this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),\"proportional\"!==this.arcType&&\"inView\"!==this.arcType&&\"partialInView\"!==this.arcType||(e=e.concat(this.numericDataMenuItems())),this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add interactions to circular view\",click:function(){for(let e of this.trackView.viewports)this.addChordsForViewport(e.referenceFrame)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:\"Add interactions to circular view\",click:()=>{const e=t.referenceFrame;this.addChordsForViewport(e)}}),i.push(\"
\"),i}}addChordsForViewport(e){let t;if(\"all\"===e.chr)t=Object.values(this.featureSource.getAllFeatures()).flat();else{t=this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end).filter((e=>e.drawState))}if(0===t.length)return;Pm(t.map((e=>{const t=e._f||e;return{uniqueId:`${t.chr1}:${t.start1}-${t.end1}_${t.chr2}:${t.start2}-${t.end2}`,refName:zm(t.chr1),start:t.start1,end:t.end1,mate:{refName:zm(t.chr2),start:t.start2,end:t.end2}}})),this,e,.5)}doAutoscale(e){let t=0;if(e)for(let i of e){const e=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(e)||(t=Math.max(t,e))}return{min:0,max:t}}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){const t=e._||e;if(i.push({name:\"Region 1\",value:rw(t.chr1,t.start1,t.end1,t.strand1)}),i.push({name:\"Region 2\",value:rw(t.chr2,t.start2,t.end2,t.strand2)}),t.name&&i.push({name:\"Name\",value:t.name}),void 0!==t.value&&i.push({name:\"Value\",value:t.value}),void 0!==t.score&&i.push({name:\"Score\",value:t.score}),t.extras&&this.header&&this.header.columnNames){const e=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r=t-a&&e.canvasX<=t+s+a&&e.canvasY>=n&&e.canvasY<=n+o){const n=-Math.abs(e.canvasX-(t+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((e,t)=>e.score-t.score)),i.map((e=>e.feature))}}function nw(e,t){let i=(e.start1+e.end1)/2,n=(e.start2+e.end2)/2;if(\"all\"===e.chr&&(i=t.getGenomeCoordinate(e.chr1,i),n=t.getGenomeCoordinate(e.chr2,n)),i>n){const e=i;i=n,n=e}return{m1:i,m2:n}}function rw(e,t,i,n){return n&&\".\"!==n?`${e}:${Rt(t+1)}-${Rt(i)} (${n})`:`${e}:${Rt(t+1)}-${Rt(i)}`}const sw=new Map;function ow(e,t){const i=`${e}_${t}`;let n=sw.get(i);return n||(n=_s.addAlpha(e,t),sw.set(i,n)),n}function aw(e){const t=e=>{const t=Object.assign({},e);return t.chr=\"all\",t.start=i.getGenomeCoordinate(e.chr1,e.start1),t.end=i.getGenomeCoordinate(e.chr2,e.end2),t},i=this.genome;let n,r=0;for(let t of i.wgChromosomeNames){let i=e[t];if(i)for(let e of i)e.dup||(r++,e.score&&(!n||e.score>n.score)&&(n=e))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),c=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let l,h=[],d=[];for(let e=0;e=400){const e=Error(r.statusText);throw e.code=s,e}return r.arrayBuffer()}}class hw{constructor(e){this.file=e.file,this.fetchSize=e.fetchSize||16e3,this.maxSize=e.maxSize||1e6,this.buffers=[]}async read(e,t){let i=this.buffers.filter((i=>i.overlaps(e,e+t)));for(let n of i)if(n.contains(e,e+t))return n.slice(e,e+t);if(0===i.length){let i=Math.max(t,this.fetchSize);this.buffers.sort(((e,t)=>e.start-t.start));const n=function(e,t,i){let n=i-1,r=e.length;for(;1+n>1);t(e[i])?r=i:n=i}return r}(this.buffers,(t=>t.start>e),0);ne.start-t.start));const n=[];let r=e;for(let e of i){if(rr){const e=r,t=s-e,i=await this.file.read(e,t),o=new dw(e,i);n.push(o)}const o=n[0].start,a=function(e){const t=e.reduce(((e,t)=>e+t.byteLength),0),i=new Uint8Array(t);let n=0;for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(n.map((e=>e.buffer))),c=new dw(o,a),l=new Set(i);return this.buffers=this.buffers.filter((e=>!l.has(e))),this.addBuffer(c),c.slice(e,e+t)}}addBuffer(e){const t=this.buffers.reduce(((e,t)=>e+t.size),0)+e.size;if(t>this.maxSize){const e=t-this.maxSize;this.buffers.sort(((e,t)=>e.creationTime-t.creationTime));let i,n=0;for(i=0;ie));i++);this.buffers=ithis.buffer.byteLength)throw Error(\"buffer bounds error\");return this.buffer.slice(e-this.start,t-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(e,t){return e>=this.start&&t<=this.end}overlaps(e,t){return e>this.start&&ethis.start&&t(((e,t,i)=>{t in e?fw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,\"symbol\"!=typeof t?t+\"\":t,i),i);async function gw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=await Aw.unpack_from_async(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function mw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=Aw.unpack_from(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function ww(e){e||e()}function bw(e){var t=\"<\"+Array.from(e.values()).join(\"\");return Aw.calcsize(t)}function Fw(e,t=8){return Math.ceil(e/t)*t}var vw={u:\"Uint\",i:\"Int\",f:\"Float\"};function yw(e){var t,i,n=Aw._is_big_endian(e);if(/S/.test(e))t=\"getString\",i=0|((e.match(/S(\\d*)/)||[])[1]||1);else{let[n,r,s]=e.match(/[<>=!@]?(i|u|f)(\\d*)/);i=parseInt(s||4,10),t=\"get\"+vw[r]+(8*i).toFixed()}return[t,n,i]}var Aw=new class{constructor(){this.big_endian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}(),this.getters={s:\"getUint8\",b:\"getInt8\",B:\"getUint8\",h:\"getInt16\",H:\"getUint16\",i:\"getInt32\",I:\"getUint32\",l:\"getInt32\",L:\"getUint32\",q:\"getInt64\",Q:\"getUint64\",f:\"getFloat32\",d:\"getFloat64\"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let e=Object.keys(this.byte_lengths).join(\"\");this.fmt_size_regex=\"(\\\\d*)([\"+e+\"])\"}calcsize(e){for(var t,i=0,n=new RegExp(this.fmt_size_regex,\"g\");null!==(t=n.exec(e));){let e=parseInt(t[1]||1,10),n=t[2];i+=e*this.byte_lengths[n]}return i}_is_big_endian(e){return!/^)/.test(e)||this.big_endian)}async unpack_from_async(e,t,i){i=Number.parseInt(i||0);const n=this.calcsize(e),r=await t.slice(i,i+n);let s=0;for(var o,a=new Cw(r),c=[],l=this._is_big_endian(e),h=new RegExp(this.fmt_size_regex,\"g\");null!==(o=h.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if(\"s\"==t)c.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;de+(t<<8*i)),0);return o}var kw=class{constructor(e,t){this.buf=e,this.offset=t,this.dtype=this.determine_dtype()}async determine_dtype(){let e=await gw(Iw,this.buf,this.offset);this.offset+=Sw;let t=15&e.get(\"class_and_version\");if(t==Ew)return this._determine_dtype_fixed_point(e);if(t==Nw)return this._determine_dtype_floating_point(e);if(t==Bw)throw\"Time datatype class not supported.\";if(t==Mw)return this._determine_dtype_string(e);if(t==Rw)throw\"Bitfield datatype class not supported.\";if(t==Dw)return{datatype_class:Dw,size:e.get(\"size\")};if(t==Tw)return this._determine_dtype_compound(e);if(t==Lw)return[\"REFERENCE\",e.get(\"size\")];if(t==zw)return this.determine_dtype();if(t==Pw)throw\"Array datatype class not supported.\";if(t==Hw){let t=this._determine_dtype_vlen(e);if(\"VLEN_SEQUENCE\"==t[0]){t=[\"VLEN_SEQUENCE\",this.determine_dtype()]}return t}throw\"Invalid datatype class \"+t}_determine_dtype_fixed_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;var n;return i=(8&e.get(\"class_bit_field_0\"))>0?\"i\":\"u\",n=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=4,n+i+t.toFixed()}_determine_dtype_floating_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;return i=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=12,i+\"f\"+t.toFixed()}_determine_dtype_string(e){return\"S\"+e.get(\"size\").toFixed()}_determine_dtype_vlen(e){return 1!=(1&e.get(\"class_bit_field_0\"))?[\"VLEN_SEQUENCE\",0,0]:[\"VLEN_STRING\",e.get(\"class_bit_field_0\")>>4,1&e.get(\"class_bit_field_1\")]}_determine_dtype_compound(e){throw\"Compound type not yet implemented!\"}},Iw=new Map([[\"class_and_version\",\"B\"],[\"class_bit_field_0\",\"B\"],[\"class_bit_field_1\",\"B\"],[\"class_bit_field_2\",\"B\"],[\"size\",\"I\"]]),Sw=bw(Iw);bw(new Map([[\"offset\",\"I\"],[\"dimensionality\",\"B\"],[\"reserved_0\",\"B\"],[\"reserved_1\",\"B\"],[\"reserved_2\",\"B\"],[\"permutation\",\"I\"],[\"reserved_3\",\"I\"],[\"dim_size_1\",\"I\"],[\"dim_size_2\",\"I\"],[\"dim_size_3\",\"I\"],[\"dim_size_4\",\"I\"]]));var Ew=0,Nw=1,Bw=2,Mw=3,Rw=4,Dw=5,Tw=6,Lw=7,zw=8,Hw=9,Pw=10;function Ow(e){let t=e.length;for(;--t>=0;)e[t]=0}Ow(new Array(576)),Ow(new Array(60)),Ow(new Array(512)),Ow(new Array(256)),Ow(new Array(29)),Ow(new Array(30));var Uw=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16},qw=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})()),Qw=(e,t,i,n)=>{const r=qw,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Vw={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},jw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Ww=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gw={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Ww(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:RA>=248?5:RA>=240?4:RA>=224?3:RA>=192?2:1;Kw[254]=Kw[254]=1;var Yw={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&$w)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Kw[e[i]]>t?i:t}};var Xw=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Zw=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=12;break e}e.msg=\"invalid literal/length code\",k.mode=30;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=30;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null,k=0;const I=new Uint16Array(16),S=new Uint16Array(16);let E,N,B,M=null,R=0;for(g=0;g<=Jw;g++)I[g]=0;for(m=0;m=1&&0===I[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(S[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){E=g-y,o[m]p?(N=M[R+o[m]],B=x[k+o[m]]):(N=96,B=0),l=1<>y)+h]=E<<24|N<<16|B}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--I[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0},{Z_FINISH:sb,Z_BLOCK:ob,Z_TREES:ab,Z_OK:cb,Z_STREAM_END:lb,Z_NEED_DICT:hb,Z_STREAM_ERROR:db,Z_DATA_ERROR:ub,Z_MEM_ERROR:fb,Z_BUF_ERROR:pb,Z_DEFLATED:gb}=jw,mb=12,wb=30,bb=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Fb(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var vb,yb,Ab=e=>{if(!e||!e.state)return db;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,cb},Cb=e=>{if(!e||!e.state)return db;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ab(e)},_b=(e,t)=>{let i;if(!e||!e.state)return db;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?db:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Cb(e))},xb=(e,t)=>{if(!e)return db;const i=new Fb;e.state=i,i.window=null;const n=_b(e,t);return n!==cb&&(e.state=null),n},kb=!0,Ib=e=>{if(kb){vb=new Int32Array(512),yb=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rb(1,e.lens,0,288,vb,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rb(2,e.lens,0,32,yb,0,e.work,{bits:5}),kb=!1}e.lencode=vb,e.lenbits=9,e.distcode=yb,e.distbits=5},Sb=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return db;i=e.state,i.mode===mb&&(i.mode=13),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=cb;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=wb;break}if((15&l)!==gb){e.msg=\"unknown compression method\",i.mode=wb;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg=\"invalid window size\",i.mode=wb;break}i.dmax=1<>8&1),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Qw(i.check,x,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&(i.check=Qw(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mb;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=14;break;case 1:if(Ib(i),i.mode=20,t===ab){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=wb}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=wb;break}if(i.length=65535&l,l=0,h=0,i.mode=15,t===ab)break e;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=mb;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=wb;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=rb(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=wb;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=wb;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=wb;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===wb)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=wb;break}if(i.lenbits=9,k={bits:i.lenbits},C=rb(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=wb;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=rb(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=wb;break}if(i.mode=20,t===ab)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Zw(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===mb&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=mb;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=wb;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=wb;break}i.offset=b,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=wb;break}i.mode=25;case 25:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=wb;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<xb(e,15),inflateInit2:xb,inflate:Eb,inflateEnd:e=>{if(!e||!e.state)return db;let t=e.state;return t.window&&(t.window=null),e.state=null,cb},inflateGetHeader:(e,t)=>{if(!e||!e.state)return db;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,cb):db},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?db:11===n.mode&&(r=1,r=Uw(r,t,i,0),r!==n.check)?ub:(s=Sb(e,t,i,i),s?(n.mode=31,fb):(n.havedict=1,cb))):db},inflateInfo:\"pako inflate (from Nodeca project)\"};var Bb=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1},Mb=Object.prototype.toString,{Z_NO_FLUSH:Rb,Z_FINISH:Db,Z_OK:Tb,Z_STREAM_END:Lb,Z_NEED_DICT:zb,Z_STREAM_ERROR:Hb,Z_DATA_ERROR:Pb,Z_MEM_ERROR:Ob}=jw;function Ub(e){this.options=Gw.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Xw,this.strm.avail_out=0;let i=Nb.inflateInit2(this.strm,t.windowBits);if(i!==Tb)throw new Error(Vw[i]);if(this.header=new Bb,Nb.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Yw.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Mb.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Nb.inflateSetDictionary(this.strm,t.dictionary),i!==Tb)))throw new Error(Vw[i])}function qb(e,t){const i=new Ub(t);if(i.push(e),i.err)throw i.msg||Vw[i.err];return i.result}Ub.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Db:Rb,\"[object ArrayBuffer]\"===Mb.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Nb.inflate(i,o),s===zb&&r&&(s=Nb.inflateSetDictionary(i,r),s===Tb?s=Nb.inflate(i,o):s===Pb&&(s=zb));i.avail_in>0&&s===Lb&&i.state.wrap>0&&0!==e[i.next_in];)Nb.inflateReset(i),s=Nb.inflate(i,o);switch(s){case Hb:case Pb:case zb:case Ob:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===Lb))if(\"string\"===this.options.to){let e=Yw.utf8border(i.output,i.next_out),t=i.next_out-e,r=Yw.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Tb||0!==a){if(s===Lb)return s=Nb.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ub.prototype.onData=function(e){this.chunks.push(e)},Ub.prototype.onEnd=function(e){e===Tb&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Gw.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qb=function(e,t){return(t=t||{}).raw=!0,qb(e,t)},Vb={Inflate:Ub,inflate:qb,inflateRaw:Qb,ungzip:qb,constants:jw},{Inflate:jb,inflate:Wb,inflateRaw:Gb,ungzip:$b}=Vb,Kb=Wb,Yb=$b;var Xb=new Map([[1,function(e,t){let i=new Uint8Array(e);return Kb(i).buffer}],[2,function(e,t){let i=e.byteLength,n=new Uint8Array(i),r=Math.floor(i/t),s=new DataView(e);for(var o=0;oHH\",e,i);if(c%=65535,r!=(a%=65535)||s!=c)throw'ValueError(\"fletcher32 checksum invalid\")'}(e),e.slice(0,-4)}]]),Zb=class{constructor(e,t){this.fh=e,this.offset=t,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let e=this.depth;for(;e>0;){for(var t of this.all_nodes.get(e))for(var i of t.get(\"addresses\"))this._add_node(await this._read_node(i,e-1));e--}}async _read_root_node(){let e=await this._read_node(this.offset,null);this._add_node(e),this.depth=e.get(\"node_level\")}_add_node(e){let t=e.get(\"node_level\");this.all_nodes.has(t)?this.all_nodes.get(t).push(e):this.all_nodes.set(t,[e])}async _read_node(e,t){let i=await this._read_node_header(e,t);return i.set(\"keys\",[]),i.set(\"addresses\",[]),i}async _read_node_header(e){throw\"NotImplementedError: must define _read_node_header in implementation class\"}},Jb=class extends Zb{constructor(){super(...arguments),pw(this,\"B_LINK_NODE\",new Map([[\"signature\",\"4s\"],[\"node_type\",\"B\"],[\"node_level\",\"B\"],[\"entries_used\",\"H\"],[\"left_sibling\",\"Q\"],[\"right_sibling\",\"Q\"]]))}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);if(null!=t&&i.get(\"node_level\")!=t)throw\"node level does not match\";return i}},eF=class extends Jb{constructor(e,t){super(e,t),pw(this,\"NODE_TYPE\",0),this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=bw(this.B_LINK_NODE);let n=[],r=[],s=i.get(\"entries_used\");for(var o=0;o=0&&F[A]>=e[A];A--)F[A]=0,b[A]=w[A],A>0&&(F[A-1]+=1,b[A-1]+=1);if(b.slice(0,-1).every((function(e,i){return e=0;o--){if(t&1<0?r*=n:r=n}}return s}_nrecords_max(e,t,i){return Math.floor((e-10-i)/(t+i))}_required_bytes(e){return Math.ceil(_w(e)/8)}_int_format(e){return[\"0&&(h=(await Aw.unpack_from_async(a,this.fh,i))[0],i+=r),c.push([n,l,h])}}return s.set(\"keys\",a),s.set(\"addresses\",c),s}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);return i.set(\"node_level\",t),i}*iter_records(){for(let e of this.all_nodes.values())for(let t of e)for(let e of t.get(\"keys\"))yield e}_parse_record(e){throw\"NotImplementedError\"}},nF=class extends iF{constructor(){super(...arguments),pw(this,\"NODE_TYPE\",5)}async _parse_record(e,t,i){let n=(await Aw.unpack_from_async(\"0)throw\"Filter info size not supported on FractalHeap\";if(t.get(\"btree_address_huge_objects\")!=dF)throw\"Huge objects not implemented in FractalHeap\";t.set(\"btree_address_huge_objects\",null),t.get(\"root_block_address\")==dF&&t.set(\"root_block_address\",null);let i=t.get(\"log2_maximum_heap_size\"),n=this._min_size_nbits(i),r=new Map([[\"signature\",\"4s\"],[\"version\",\"B\"],[\"heap_header_adddress\",\"Q\"],[\"block_offset\",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=bw(r),2&~t.get(\"flags\")||r.set(\"checksum\",\"I\"),this.direct_block_header=r,this.direct_block_header_size=bw(r);let s=t.get(\"maximum_direct_block_size\");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,t.get(\"max_managed_object_size\"));this._managed_object_length_size=this._min_size_integer(o);let a=t.get(\"starting_block_size\"),c=t.get(\"table_width\");if(!(a>0))throw\"Starting block size == 0 not implemented\";let l=Number(Math.floor(Math.log2(s)));ww(1n<0)for await(let e of this._iter_indirect_block(this.fh,f,p))u.push(e);else{let e=await this._read_direct_block(this.fh,f,a);u.push(e)}let g=u.reduce(((e,t)=>e+t.byteLength),0),m=new Uint8Array(g),w=0;u.forEach((e=>{m.set(new Uint8Array(e),w),w+=e.byteLength})),this.managed=m.buffer}async _read_direct_block(e,t,i){let n=await e.slice(t,t+i);return ww(\"FHDB\"==mw(this.direct_block_header,n).get(\"signature\")),n}get_data(e){let t=Aw.unpack_from(\">4&3,n=1;if(0==i){ww(0==t>>6);let i=this._managed_object_offset_size,r=xw(i,e,n);n+=i,i=this._managed_object_length_size;let s=xw(i,e,n);return this.managed.slice(r,r+s)}throw 1==i?\"tiny objectID not supported in FractalHeap\":2==i?\"huge objectID not supported in FractalHeap\":\"unknown objectID type in FractalHeap\"}_min_size_integer(e){return this._min_size_nbits(_w(e))}_min_size_nbits(e){return Math.ceil(e/8)}async*_iter_indirect_block(e,t,i){let n=await gw(this.indirect_block_header,e,t);t+=this.indirect_block_header_size,ww(\"FHIB\"==n.get(\"signature\"));let r=n.get(\"block_offset\").reduce(((e,t,i)=>e+(t<<8*i)),0);n.set(\"block_offset\",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;ithis._chunks))}get shape(){let e=this.find_msg_type(ZF)[0].get(\"offset_to_message\");return async function(e,t){let i=(await Aw.unpack_from_async(\"255&&(s=(await Aw.unpack_from_async(\"0;e.set(\"optional\",a);let c,l=(await Aw.unpack_from_async(\"0&&(c=(await Aw.unpack_from_async(`${s}s`,i,t))[0],t+=s),e.set(\"name\",c);let h=await Aw.unpack_from_async(`<${l}i`,i,t);t+=4*l,e.set(\"client_data_values\",h),r.push(e)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(e){return this.msgs.filter((function(t){return t.get(\"type\")==e}))}async get_attributes(){let e={},t=this.find_msg_type(sv);for(let i of t){let t=i.get(\"offset_to_message\"),[n,r]=await this.unpack_attribute(t);e[n]=r}return e}async get_fillvalue(){var e,t=this.find_msg_type(tv)[0].get(\"offset_to_message\");let i=(await Aw.unpack_from_async(\"=r&&([s,r]=a[++c],l=0);let t=await gw(PF,e,s+l),i=s+l+OF;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[u,f]=await Aw.unpack_from_async(\"=o-qF){let e=c[++l];if(null==e)break;[r,o]=e,h=0}let t=await gw(UF,e,r+h),i=r+h+qF+n;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[d,u]=await Aw.unpack_from_async(\"0,c=(4&n)>0;(8&n)>0?(r=(await Aw.unpack_from_async(\"0&&(t+=8);let r=(2&n)>0?jF:VF,s=await gw(r,e,t),o=new Map;for(let[e,t]of s.entries())o.set(e,t==IF?null:t);return o}get is_dataset(){return this.find_msg_type(ZF).length>0}async get_data(){let e=this.find_msg_type(nv)[0].get(\"offset_to_message\");var[t,i,n,r]=await this._get_data_message_properties(e);if(0==n)throw\"Compact storage of DataObject not implemented\";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(e):void 0}async _get_data_message_properties(e){let t,i,n,[r,s,o]=await Aw.unpack_from_async(\"=1&&r<=4),[r,t,i,n]}async _get_contiguous_data(e){let[t]=await Aw.unpack_from_async(\"=!@\\|]?(i|u|f|S)(\\d*)/.test(n)){let[e,i,s]=yw(n),a=new Array(r);const c=await this.fh.slice(t,t+s*r);let l=new Cw(c);for(var o=0;o=1&&t<=3);var a=\"<\"+(i-1).toFixed()+\"I\",c=await Aw.unpack_from_async(a,this.fh,s);this._chunks=c,this._chunk_dims=i,this._chunk_address=o}}}};var IF=Aw.unpack_from(\"this.get(e)))}length(){return this.keys.length}_dereference(e){if(!e)throw\"cannot deference null reference\";let t=this.file._get_object_by_address(e);if(null==t)throw\"reference not found in file\";return t}async get(e){if(\"number\"==typeof e)return this._dereference(e);var t=dv(e);if(\"/\"==t)return this.file;if(\".\"==t)return this;if(/^\\//.test(t))return this.file.get(t.slice(1));if(\"\"!=function(e){let t=\"/\",i=e.lastIndexOf(t)+1,n=e.slice(0,i),r=new RegExp(\"^\"+t+\"+$\"),s=new RegExp(t+\"$\");n&&!r.test(n)&&(n=n.replace(s,\"\"));return n}(t))var[i,n]=t.split(/\\/(.*)/);else var i=t,n=\".\";if(!(i in this._links))throw i+\" not found in group\";var r=dv(this.name+\"/\"+i);let s=this._links[i];if(\"string\"==typeof s)try{return this.get(s)}catch(e){return null}var o=new kF(this.file._fh,s);if(await o.ready,o.is_dataset){if(\".\"!=n)throw r+\" is a dataset, not a group\";return new hv(r,o,this)}var a=new cv(r,this);return await a.init(o),a.get(n)}visit(e){return this.visititems(((t,i)=>e(t)))}visititems(e){var t=this.name.length;/\\/$/.test(this.name)||(t+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=e(n.name.slice(t),n);if(null!=r)return r;n instanceof cv&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},lv=class extends cv{constructor(e,t,i){super(\"/\",null),this.ready=this.init(e,t,i)}async init(e,t,i){var n=new sF(e,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new kF(e,r);if(await s.ready,this.parent=this,this.file=this,this.name=\"/\",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=e,this.filename=t||\"\",this.mode=\"r\",this.userblock_size=0,i&&i.index)this.index=i.index;else{let t;if(i&&i.indexOffset)t=i.indexOffset;else{const e=await this.attrs;if(e.hasOwnProperty(\"_index_offset\"))t=e._index_offset;else{const e=this.indexName||\"_index\",i=await s.find_link(e);i&&(t=i[1])}}if(t)try{const i=new kF(e,t);await i.ready;const n=await i.get_data(),r=Yb(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(e){console.error(`Error loading index by offset ${e}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(e){return this._dataobjects.offset==e?this:this.visititems((e=>{e._dataobjects.offset}))}},hv=class extends Array{constructor(e,t,i){super(),this.parent=i,this.file=i.file,this.name=e,this._dataobjects=t,this._attrs=null,this._astype=null}get value(){var e=this._dataobjects.get_data();return null==this._astype?this.getValue(e):e.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(e,t){const i=e.length,n=t.reduce(((e,t)=>e*t),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=e;const s=t.slice(1).reverse();for(let e of s){const t=[],{length:i}=r;let n=0;for(;n{let t=e.indexOf(\"\\0\");return t>=0?e.substring(0,t):e})):e}};function dv(e){return e.replace(/\\/(\\/)+/g,\"/\")}async function uv(e){var t;e.url&&(\"function\"==typeof(t=e.url).slice&&\"function\"==typeof t.arrayBuffer)&&(e.file=e.url,e.url=void 0);const i=void 0!==e.url;let n=e.reader?e.reader:function(e){if(e.url)return new lw(e);if(e.path)return new NodeLocalFile(e);if(e.file)return new uw(e.file);throw Error(\"One of 'url', 'path (node only)', or 'file (browser only)' must be specified\")}(e);const r=e.fetchSize||2e3,s=e.maxSize||2e5;i&&(n=new hw({file:n,fetchSize:r,maxSize:s}));const o=new fv(n),a=await async function(e){let t;if(e.indexReader)t=e.indexReader;else{if(e.index)return e.index;e.indexURL?t=new lw({url:e.indexURL}):e.indexPath?t=new NodeLocalFile({path:e.indexPath}):e.indexFile&&(t=new uw({file:e.indexFile}))}if(t){const e=await t.read(),i=(new TextDecoder).decode(e);return JSON.parse(i)}return}(e),c=e.indexOffset,l=function(e){if(e.url)return pv(e.url);if(e.path)return pv(e.path);if(e.file)return e.file.name}(e),h=new lv(o,l,{index:a,indexOffset:c});return await h.ready,h}class fv{constructor(e){this.fileReader=e}async slice(e,t){return this.fileReader.read(e,t-e)}}function pv(e){const t=e.lastIndexOf(\"/\");return t>0?e.substring(t+1):e}class gv{constructor(e,t){this.chrom=e,this.signal_bin_size=t;this.signals={raw_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}`,gc_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}_GC`,gc_partition:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_merge`,baf:`snp_likelihood_${this.chrom}_${this.signal_bin_size}_mask`,baf_i1:`snp_i1_${this.chrom}_${this.signal_bin_size}_mask`,Mosaic_segments:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_segments_2d`,Mosaic_calls:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_call_2d`}}}class mv{constructor(e,t=1e5){this.h5_file=e,this.bin_size=t,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await uv({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(e=this.bin_size){let t=await this.fetch();this.h5_obj=t,this.pytor_keys=t.keys;let i=new wv(this.pytor_keys),n=i.get_rd_bins(),r=i.get_snp_bins();this.available_bins=[...new Set(n,r)],this.available_bins.includes(e)||(e=this.available_bins.at(-1));const s=await t.get(\"rd_chromosomes\");await s.dtype;let o=await s.value,a=await this.rd_stat(e);var c=[],l=[],h=[],d=[],u=[],f=[];for(let t of o){let i=new gv(t,e);var p=i.signals.raw_RD;let n=await this.get_chr_signal(t,e,p,a);c=c.concat(n);var g=i.signals.gc_RD;let r=await this.get_chr_signal(t,e,g,a);l=l.concat(r);let s=i.signals.gc_partition,o=await this.get_chr_signal(t,e,s,a);h=h.concat(o);let m=await this.rd_call_combined(t,e,a,i);d=d.concat(m);let w=i.signals.baf_i1,b=await this.get_baf_signals_v2(t,e,w);u=u.concat(b[0]),f=f.concat(b[1])}this.callers=[],0!=d.length&&this.callers.push(\"ReadDepth\"),0!=d.length&&this.callers.push(\"2D\");var m={},w={RD_Raw:c,RD_Raw_gc_coor:l,ReadDepth:h,\"2D\":d,BAF1:u,BAF2:f};return m[e]=w,m}decode_segments(e){let t=[],i=[];for(let n of e)4294967295==n?(t.push(i),i=[]):i.push(n);return t}async rd_call_combined(e,t,i,n){let r,s=[],o=n.signals.Mosaic_segments;if(this.pytor_keys.includes(o)){const e=await this.h5_obj.get(o);let t=await e.value;r=this.decode_segments(t)}let a=n.signals.Mosaic_calls;if(this.pytor_keys.includes(a)){const n=await this.h5_obj.get(a);let o=await n.to_array();r.forEach(((n,r)=>{n.forEach(((n,a)=>{s.push({chr:e,start:n*t,end:(n+1)*t,value:o[0][r]/i[4]*2})}))}))}return s}async rd_stat(e){let t,i=`rd_stat_${e}_auto`;if(this.pytor_keys.includes(i)){const e=await this.h5_obj.get(i);t=await e.value}return t}async get_chr_signal(e,t,i,n){let r=[];if(this.pytor_keys.includes(i)){const s=await this.h5_obj.get(i);(await s.value).forEach(((i,s)=>{r.push({chr:e,start:s*t,end:(s+1)*t,value:i/n[4]*2})}))}return r}async get_baf_signals(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{let a=Math.max(...i);const c=i.indexOf(a);let l=Math.max(c/200,1-c/200);r.push({chr:e,start:o*t,end:(o+1)*t,value:n*l}),.5!=l&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(1-l)})}))}return[r,s]}async get_baf_signals_v2(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{isNaN(i)||(r.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5-i)}),.5!=i&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5+i)}))}))}return[r,s]}}class wv{constructor(e){this.signals=e}get_rd_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^his_rd_p_(.*)_(\\d+)$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}get_snp_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^snp_likelihood_(.*)_(\\d+)_mask$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}}function bv(e){let t=function(e){if(e.length<4)return e;let t,i,n,r,s,o;return t=e.slice().sort(((e,t)=>e-t)),t.length/4%1==0?(i=.5*(t[t.length/4]+t[t.length/4+1]),n=.5*(t[t.length*(3/4)]+t[t.length*(3/4)+1])):(i=t[Math.floor(t.length/4+1)],n=t[Math.ceil(t.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,t.filter((e=>e>=o&&e<=s))}(e);const i=t.length,n=t.reduce(((e,t)=>e+t))/i,r=Math.sqrt(t.map((e=>Math.pow(e-n,2))).reduce(((e,t)=>e+t))/i);return[n,r]}var Fv={range_function:function(e,t,i){return Array(Math.ceil((t-e)/i)).fill(e).map(((e,t)=>e+t*i))},getDistParams:bv,linspace:function(e,t,i){if(void 0===i&&(i=Math.max(Math.round(t-e)+1,1)),i<2)return 1===i?[e]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*t+(i-r)*e)/i;return n},GetFit:class{constructor(e){this.allBins=e}getValues(){return Object.values(this.allBins).reduce(((e,t)=>e.concat(t.filter((e=>e.binScore>0)).map((e=>e.binScore)))),[])}getMean(e){return e.reduce((function(e,t){return e+t}))/e.length}fit_data(){return bv(this.getValues())}histogram(e,t){const i=t[1]-t[0],n=[];e.forEach(((e,r)=>{t.forEach(((t,r)=>{if(n[t]||(n[t]={count:0}),t<=e&&e{r.push(e.count)})),r}}};function vv(e,t){return isNaN(e)||isNaN(t)||t<=0?NaN:0===e?.5:.5+.5*(yv(.5*t,.5,1)-yv(.5*t,.5,t/(t+e*e)))*Math.sign(e)}function yv(e,t,i){if(0==i)return 0;if(1==i)return 1;{let n=xv(e+t)-xv(e)-xv(t)+e*Math.log(i)+t*Math.log(1-i);return i<(e+1)/(e+t+2)?Math.exp(n)*Av(e,t,i)/e:1-Math.exp(n)*Av(t,e,1-i)/t}}function Av(e,t,i,n=1e3){let r=1,s=1,o=1,a=e+t,c=e+1,l=e-1,h=1-a*i/c;for(let d=0;d<=n;d++){let n=parseFloat(d+1),u=n+n,f=n*(t-n)*i/((l+u)*(e+u)),p=r+f*s,g=h+f*o;f=-(e+n)*(a+n)*i/((c+u)*(e+u));let m=g+f*h,w=r;if(s=p/m,o=g/m,r=(p+f*r)/m,h=1,Math.abs(r-w)<3e-7*Math.abs(r))return r}}function Cv(e){if(0==e||1==e)return 1;return e*Cv(e-1)}function _v(e){let t;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==e)t=1e99;else if(e%1==0)t=Cv(e-1);else{for(let t=0;tt?e:t}))}function Sv(e,t,i,n){return t*Math.exp(-1*(e-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function Ev(e,t,i,n){return Math.exp(-1*(e-i)**2/(t**2+n**2))}function Nv(e,t){let i;try{i=e.reduce(((e,i,n)=>e+Math.min(i,t[n])))}catch{return console.log(\"Failed to find likelihood overlap: \",e,t),0}return i}function Bv(e,t,i,n){return 0==t&&0==n?{nl:.5*(e+i),ne:0}:{nl:(e*n*n+i*t*t)/(t*t+n*n),ne:Math.sqrt(t*t*n*n/(t*t+n*n))}}function Mv(e,t){let i=parseInt(t*(e.length-1)),n=t*(e.length-1)-i;return iMath.floor(t/2)&&(n=t-1-n);const r=(t/2-n)/(t+1),s=Math.floor((t/2+n)/2),o=t-1-s;let a=e.slice(s,o+1).reduce(((e,t)=>e+t),0)/e.reduce(((e,t)=>e+t),0);return n===Math.floor(t/2)&&(a=1),{mean:r,p:a}}var Dv=class{constructor(e,t){this.wigFeatures=e,this.binSize=t}get_fit(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data();return{globalMean:t,globalStd:i}}async call_2d(e=null,t=null,i=\"both\",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let c=null==e?.05*this.binSize/3e9:e,l=null==t?parseInt(this.binSize/1e4):t,h=[],d=[],u=[],f=[],p=[],g=[];for(const[e,t]of Object.entries(this.wigFeatures)){let e=[],i=[],s=[];t.forEach(((t,n)=>{t.hets_count>4&&t.dp_count>l&&(e.push([n]),i.push(t.binScore),s.push(t.likelihood_score),delete t.likelihood_score)}));let o=[];for(let e=1;eMath.sqrt(Math.sqrt(e)**2+this.globalStd**2+Math.pow(a[t]/2,2)))),m=[];for(let t=0;t0;){m=m.filter((e=>\"number\"==typeof e));let t=Iv(m);if(isNaN(t)&&console.log(\"NaN value\",m),te*s[o+1][t])),r=n.reduce(((e,t)=>e+t))}catch{console.log(s),console.log(\"max_overlap:\",t,o,m.length),console.log(\"likelihood: \",o,s[o],s[o+1]),console.log(\"nlh: \",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(e){return e/r})),e[o].push(...e[o+1]),i.splice(o+1,1),g.splice(o+1,1),e.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o0){let e=Ev(i[o-1],g[o-1],i[o],g[o])*Nv(s[o-1],s[o]);m[o-1]=e}}let w=-1;for(;;){m=[];for(let t=0;te*s[r+1][t])),a=n.reduce(((e,t)=>e+t));s[r]=n.map((function(e){return e/a})),e[r].push(...e[r+1]),e[r]=e[r].sort(((e,t)=>e-t)),i.splice(o,1),g.splice(o,1),e.splice(o,1),s.splice(o,1),o>=e.length&&(r+=1,o=r+1)}else o+=1,o>=e.length&&(r+=1,o=r+1)}if(w==e.length)break;w=e.length}e.forEach(((e,n)=>{let o=Rv(s[n]);e.length>1&&(e.forEach(((e,s)=>{d.push(t[e]),o.mean<=r&&h.push(t[e]),t[e].segment_score=i[n]})),u.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let w=Fv.linspace(o,1,m),b={},F={};for(let e=10;e>-1;e--)for(let t=0;t1-t+t*e/2)),a=e/2;e>0?(n=.5-t/(t+s),r=w.map(((e,i)=>.5-(1-e+e*t)/(2-2*e+(t+s)*e)))):(n=0,r=w.map(((e,t)=>0*e)));for(let i=0;i{if(!isNaN(r[t])){let n=Sv(e*this.globalMean,1,u[i],f[i])*Mv(p[i],.5+r[t]);l+=n,n>h&&(h=n,d=w[t])}})),i in b?b[i].push([e,t,s,l/w.length,d]):b[i]=[e,t,s,l/w.length,d]}for(let e=0;ee[3]-t[3]));else if(b[e].sort(((e,t)=>e[3]-t[3])),\"both\"==i&&(F[e].sort(((e,t)=>e[3]-t[3])),F[e][0][3]>b[e][0][3])){let t=b[e].filter((t=>t[0]!=F[e][0][0]&&t[1]<=F[e][0][1]));b[e]=[F[e][0]].push(...t)}for(let e=0;e{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}formatDataStructure_BAF(e,t=-1){const i=[],n=[];for(const[r,s]of Object.entries(this.wigFeatures))s.forEach((r=>{var s={...r},o={...r};let a=r[e];.5!=a&&(o.value=t*(1-a),n.push(o)),s.value=t*a,i.push(s)}));return[i,n]}};const Tv=2871e6;function Lv(e){for(var t=1,i=1,n=1*e,r=1;r<50;r++)t*=r,n+=(i*=-1)*Math.pow(e,2*r+1)/(t*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function zv(e,t,i,n,r){var s=new Ov(i.slice(n,r));return 0==s.std&&(s.std=t>0?t*s.mean/e:1),Uv(e,s.mean,s.std,r-n)/(r-n)}function Hv(e,t,i,n,r){var s=new Ov(i.slice(n,r));if(s.means&!l&c0&&(h=zv(e,t,i,n-1,r)),r-n>2)var d=zv(e,t,i,n+1,r),u=zv(e,t,i,n,r-1);if(re+t))/e.length,this.std=Math.sqrt(e.reduce(((e,t)=>(t-this.mean)**2))/e.length)}}function Uv(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-kv.TdistributionCDF(Math.abs(r),n-1)}function qv(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-kv.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var Qv=class{constructor(e,t,i){this.rd=e,this.mean=t,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(e){var t=[];return e.forEach(((e,i)=>{var n=0;n=e>this.mean/4?this.mean/(this.std**2*e):4/this.std**2,t.push(n)})),t}meanShiftCaller(e,t=3){var i={};return Object.entries(this.rd).forEach((([e,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let e=0;e{var o=r.map(((e,t)=>!e)),a=[];Object.entries(n).forEach((([e,t])=>{a.push(t.binScore)}));var c=[0],l=0;for(let e=0;e0&&(c.push(c[c.length-1]+l-1),l=0):l+=1;c.shift();for(let i=0;i=a.length||Math.abs(t-i)>=a.length)){var u=(i-t)*Math.exp(-.5*(i-t)**2/e**2)*Math.exp(-.5*(a[t]-a[i])**2*h[t]);d[t]+=u}for(var f=new Array,p=0;p=0&&f.push(p);f.push(d.length-1),f=f.concat(c).sort(((e,t)=>e-t)),f=Array.from(new Set(f));var g=0;for(p=0;pe+t))/m.length;a.fill(w,g,f[p]+1),g=f[p]+1}}p=0;for(var b=0;p.01&&f.push(p+1)}f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1);for(p=1;p1))continue;v[0]=f[p-2];var y=[f[p],f[p]];if(!(p.01/Tv*bin_size*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>.01/Tv*bin_size*(A+_))continue}if(Uv(this.mean,x.mean,x.std,x.data.length)>.05)continue;let e=a.slice(F[0],F[1]);var B=new Ov(e);r.fill(!0,F[0],F[1]),s.fill(B.mean,F[0],F[1])}})),i[e]=s})),i}call_mean_shift(e=3){for(var t=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n{var s=t.map(((e,t)=>!e)),o=[];s.forEach(((e,t)=>{e&&o.push(this.rd[t])}));for(var a=[0],c=0,l=0;l0&&(a.push(a[a.length-1]+c-1),c=0):c+=1;a.shift();for(var h=0;h=o.length||Math.abs(l-f)>=o.length)){var p=(f-l)*Math.exp(-.5*(f-l)**2/n**2)*Math.exp(-.5*(o[l]-o[f])**2*d[l]);u[l]+=p}var g=new Array;for(l=0;l=0&&g.push(l);g.push(u.length-1),g=g.concat(a).sort(((e,t)=>e-t)),g=Array.from(new Set(g));var m=0;for(l=0;le+t))/w.length;o.fill(b,m,g[l]+1),m=g[l]+1}}for(l=0,f=0;l.01&&g.push(l+1)}g.unshift(0),g.push(i.length),t=new Array(this.rd.length).fill(!1);for(l=1;l1){v[0]=g[l-2];var y=[g[l],g[l]];if(l3.483106931382794e-9*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>3.483106931382794e-9*(A+_))continue}if(!(Uv(this.mean,x.mean,x.std,x.data.length)>.05)){var B=new Ov(this.rd.slice(F[0],F[1]));t.fill(!0,F[0],F[1]),i.fill(B.mean,F[0],F[1])}}}}}})),i}cnv_calling(e=1e5){var t=.25*this.mean,i=this.mean-t,n=this.mean+t,r=2971e6,s=this.meanShiftCaller(e),o={},a=[];return Object.entries(s).forEach((([c,l])=>{for(var h=!1;!h;){h=!0;var d=new Array(1).fill(0);for(let e=0;e.01&&d.push(e+1)}d.push(l.length);for(let e=0;e0&&(f=Math.abs(l[d[e]]-l[d[e-1]])),e{m.push(t.binScore)}));for(var w,b=new Array(l.length).fill(\"\"),F=0,v=.05*e/r;FA+1){var C=Pv(this.mean,this.std,m,A,_,v);if(C){var _=C;b.fill(\"D\",A,_)}}for(A=F;Fn;)F+=1;(_=F)>A+1&&(C=Pv(this.mean,this.std,m,A,_,v))&&(_=C,b.fill(\"A\",A,_)),F==y&&(F+=1)}for(F=0;FA+1&&(Hv(this.mean,this.std,m,A,_)<1682935038707506e-26&&b.fill([\"d\"]*(_-A),A,_),F-=1),F+=1}(F=0)=b.length););if(F>A){var k=new Ov(x.slice(A,F));x.fill(k.mean,A,F)}F=0;e--){var i;let n=this.allVariants[e];this.allVariants.splice(e,1);let r=n.chr;i=Math.max(Math.floor(n.start/this.rowBinSize),0),t[r]||(t[r]=[]),t[r][i]||(t[r][i]={chr:r,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const s=Object.values(n.calls);if(1!==s.length)throw Error(`Unexpected number of genotypes: ${s.length}. CNVPytor expects 1 and only 1 genotype`);const o=s[0],a=o.info.DP;a&&(t[r][i].dp_sum_score+=Number.parseInt(a),t[r][i].dp_count++);let c=o.info.AD.split(\",\"),l=o.genotype;if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){t[r][i].hets_count++;let e=parseInt(c[0]),n=parseInt(c[1]);t[r][i].hets.push({ref:e,alt:n})}}this.chromosomes=Object.keys(t);var n,r=this.adjust_bin_size(t);if(\"ReadDepth\"==e){n=new Wv(r,this.binSize).ReadDepth_caller();var s=this.formatDataStructure_BAF(r,\"max_likelihood\")}else if(\"2D\"==e){let e=new Dv(r,this.binSize),t=await e.call_2d();n=[t.binScore,[],t.segment_score];s=e.formatDataStructure_BAF(\"max_likelihood\",-1)}return[n,s]}formatDataStructure(e,t,i=1){const n=[];for(const[s,o]of Object.entries(e))for(let e of o){var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}return n}format_BAF_likelihood(e){const t=[];for(const[n,r]of Object.entries(e))for(let e of r){var i={...e};.5!=e.value&&(i.value=1-e.value,t.push(i))}return t}get_max_min_score(e){if(e.likelihood_score.length>0){const t=Math.max(...e.likelihood_score),i=e.likelihood_score.indexOf(t);e.value=Math.max(i/100,1-i/100),e.min_score=Math.min(i/100,1-i/100)}else e.score=0;return e}async getAllbins(){const e=await this.computeDepthFeatures();return new Fv.GetFit(e).fit_data(),e}formatDataStructure_BAF(e,t,i=-1){const n=[],r=[];for(const[a,c]of Object.entries(e))for(let e of c){var s={...e},o={...e};let a=e[t];.5!=a&&(o.value=i*(1-a),r.push(o)),s.value=i*a,n.push(s)}return[n,r]}adjust_bin_size(e){var t={};for(let r of this.chromosomes){t[r]||(t[r]=[]);for(let s=0;sjv(o.ref,o.alt,e)));else{var n=0;t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>{var a=t[r][s].likelihood_score[i]*jv(o.ref,o.alt,e);return n+=a,a})),t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>t[r][s].likelihood_score[i]/n))}t[r][s].binScore=100*parseInt(t[r][s].dp_sum_score/t[r][s].dp_count);const a=this.get_max_min_score(t[r][s]);t[r][s].max_likelihood=a.value}}return t}}function jv(e,t,i,n=!0){return Math.pow(i,e)*Math.pow(1-i,t)+Math.pow(i,t)*Math.pow(1-i,e)}class Wv{constructor(e,t){this.wigFeatures=e,this.binSize=t}ReadDepth_caller(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data(),n=new Qv(this.wigFeatures,t,i),r=n.meanShiftCaller(this.binSize),s=n.cnv_calling();return Object.entries(this.wigFeatures).forEach((([e,t])=>{t.forEach(((t,i)=>{t.partition_level=parseInt(r[e][i]),t.partition_call=parseInt(s[0][e][i])}))})),[this.formatDataStructure(\"binScore\",t),this.formatDataStructure(\"partition_level\",t),this.formatDataStructure(\"partition_call\",t),s[1]]}formatDataStructure(e,t=1){const i=[];for(const[r,s]of Object.entries(this.wigFeatures))for(let r of s){var n={...r};1!=t&&(n.value=r[e]/t*2),i.push(n)}return i}}class Gv extends Hl{static DEFAULT_TRACK_HEIGHT=250;constructor(e,t){super(e,t)}init(e){this.featureType=\"numeric\",this.type=\"cnvpytor\",e.max||(this.defaultScale=!0,this.autoscale=!1),e.height||(e.height=Gv.DEFAULT_TRACK_HEIGHT),this.type=\"cnvpytor\",this.graphType=e.graphType||\"points\",this.bin_size=e.bin_size||1e5,this.signal_name=e.signal_name||\"rd_snp\",this.cnv_caller=e.cnv_caller||\"2D\",this.colors=e.colors||[\"gray\",\"black\",\"green\",\"blue\"],super.init(e)}get supportsWholeGenome(){return!0}get_signals(){let e=[];return\"rd_snp\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller,\"BAF1\",\"BAF2\"]:\"rd\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller]:\"snp\"==this.signal_name?e=[\"BAF1\",\"BAF2\"]:\"cnh\"==this.signal_name&&(e=[this.cnv_caller]),e}get_signal_colors(){return[{singal_name:\"RD_Raw\",color:this.colors[0]},{singal_name:\"RD_Raw_gc_coor\",color:this.colors[1]},{singal_name:\"ReadDepth\",color:this.colors[2]},{singal_name:\"2D\",color:this.colors[2]},{singal_name:\"BAF1\",color:this.colors[3]},{singal_name:\"BAF2\",color:this.colors[3]}]}async postInit(){if(\"vcf\"==this.config.format){let e;this.featureSource?e=Object.values(this.featureSource.getAllFeatures()).flat():(this.featureSource=this.featureSource||Ad(this.config,this.browser.genome),this.header=await this.getHeader(),e=this.featureSource.reader.features);const t=new Vv(e,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},\"2D\"==this.cnv_caller?(r=await t.read_rd_baf(\"2D\"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size][\"2D\"]=i[2],this.available_callers=[\"2D\"]):(r=await t.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=[\"ReadDepth\"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new mv(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const e=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let t in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:\"wig\"};t.features=n,t.name=i,t.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(t);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+t),\"function\"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(e)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if(\"function\"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleKeys=this.callSets?this.callSets.map((e=>e.sample)):[],this.sampleNames=this.sampleKeys}return this.header}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat(this.numericDataMenuItems()),e.push(\"
\"),e.push(\"Bin Sizes\");for(let t of this.available_bins){const i=Dl(t,t===this.bin_size);e.push({object:Bt(i),click:async function(){this.bin_size=t,this.trackView.startSpinner(),await this.recreate_tracks(t),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"Signal Type\");let t={rd_snp:\"RD and BAF Likelihood\",rd:\"RD Signal\",snp:\"BAF Likelihood\"};for(let i in t){const n=Dl(t[i],i===this.signal_name);e.push({object:Bt(n),click:async function(){this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"CNV caller\");for(let t of this.available_callers){const i=Dl(t,t===this.cnv_caller);e.push({object:Bt(i),click:async function(){this.cnv_caller=t,this.trackView.startSpinner(),await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}if(this.variantState){e.push(\"
\");for(let t of this.available_callers)e.push({label:\"Convert to variant track\",click:()=>{this.convertToVariant()}})}return e}async recreate_tracks(e){this.tracks=[];const t=[];e in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(e)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:\"wig\"};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+e),\"function\"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}async getFeatures(e,t,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n)));return Promise.all(r)}}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features;if(!t)return;if(this.defaultScale&&(\"rd_snp\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||5}:\"rd\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||5}:\"snp\"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(e,t){let i=0,n=-Number.MAX_VALUE;for(let e of t)for(let t of e)void 0===t.value||Number.isNaN(t.value)||(i=Math.min(i,t.value),n=Math.max(n,t.value));return{min:i,max:n}}(e.referenceFrame.chr,t)),this.tracks)for(let i=0,n=this.tracks.length;ithis.logScale?this.computeYPixelValueInLogScale(e,i):this.computeYPixelValue(e,i);if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=n(t.y),r={strokeStyle:t.color,strokeWidth:1};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,r):xo.strokeLine(e.context,0,i,e.pixelWidth,i,r)}let r=n(2);xo.dashedLine(e.context,0,r,e.pixelWidth,r,5,{strokeStyle:\"lightgray\",strokeWidth:.5})}paintAxis(e,t,i){var n,r,s,o,a,c,l,h={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let d=void 0!==this.flipAxis&&this.flipAxis;function u(e){return e<0?Math.abs(e):0===e?\"0\":Math.abs(e)>=10||e%1==0?e.toFixed():Math.abs(e)>=1?e.toFixed(1):e.toFixed(2)}xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"}),n=(l=.95*t)-8,a={x:r=l,y:s=o=.01*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.min:this.dataRange.max),n+4,s+12,h),c={x:r,y:s=o=.99*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.max:this.dataRange.min),n+4,s-4,h),xo.strokeLine(e,a.x,a.y,c.x,c.y,h);const f=this.getScaleFactor(this.dataRange.min,this.dataRange.max,i,this.logScale),p=e=>this.logScale?this.computeYPixelValueInLogScale(e,f):this.computeYPixelValue(e,f),g=Math.ceil((this.dataRange.max-this.dataRange.min)/10);for(let t=Math.ceil(this.dataRange.min+1);t0&&t.push(\"
\"),t.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(e,i[n]);t.push(...r)}return t}}async convertToVariant(){this.variantState&&(Object.setPrototypeOf(this,Yv.prototype),this.init(this.variantState),await this.postInit(),this.trackView.clearCachedFeatures(),this.variantState.trackHeight&&this.trackView.setTrackHeight(this.variantState.trackHeight),this.trackView.checkContentHeight(),this.trackView.updateViews(),delete this.variantState)}}const $v=Mt,Kv=10;class Yv extends Hl{static defaults={displayMode:\"EXPANDED\",sortDirection:\"ASC\",showGenotypes:!0,expandedVariantHeight:10,squishedVariantHeight:2,squishedCallHeight:1,expandedCallHeight:10,expandedVGap:2,squishedVGap:1,expandedGroupGap:10,squishedGroupGap:5,featureHeight:14,noGenotypeColor:\"rgb(200,180,180)\",noCallColor:\"rgb(225, 225, 225)\",nonRefColor:\"rgb(200, 200, 215)\",mixedColor:\"rgb(200, 220, 200)\",homrefColor:\"rgb(200, 200, 200)\",homvarColor:\"rgb(17,248,254)\",hetvarColor:\"rgb(34,12,253)\",refColor:\"rgb(0,0,220)\",altColor:\"rgb(255,0,0)\",visibilityWindow:void 0,labelDisplayMode:void 0,type:\"variant\"};_sortDirections=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),e.variantHeight&&(this.expandedVariantHeight=e.variantHeight),this.featureSource=Ad(e,this.browser.genome),this.colorTables=new Map,e.colorTable){const t=e.colorBy||\"*\";this.colorTables.set(t,new ao(e.colorTable))}if(this.strokecolor=e.strokecolor,this._context_hook=e.context_hook,e.color&&(this.colorBy=void 0),this.nVariantRows=1,e.samples)for(let t of e.samples)this.sampleKeys=e.samples;e.sort&&(this.initialSort=e.sort),this._colorByItems=new Map([[\"none\",\"None\"]])}async postInit(){if(this.header=await this.getHeader(),this.header.INFO){const e=new Set(Object.keys(this.header.INFO));this.config.colorBy?this.colorBy=this.config.colorBy:!this.config.color&&e.has(\"AF\")&&(this.colorBy=\"AF\"),e.has(\"AF\")&&this._colorByItems.set(\"AF\",\"Allele frequency\"),e.has(\"VT\")&&this._colorByItems.set(\"VT\",\"Variant Type\"),e.has(\"SVTYPE\")&&this._colorByItems.set(\"SVTYPE\",\"SV Type\")}if(this.config.colorBy&&!this._colorByItems.has(this.config.colorBy)&&this._colorByItems.set(this.config.colorBy,this.config.colorBy),!this.disposed){if(this.header&&!this.sampleKeys&&(this.sampleKeys=this.header.sampleNameMap?Array.from(this.header.sampleNameMap.keys()):[]),void 0===this.visibilityWindow&&!1!==this.config.indexed){const e=Ht(this.config.url)?this.config.url.name:this.config.url;$v(e)&&e.toLowerCase().includes(\"gnomad\")?this.visibilityWindow=1e3:\"function\"==typeof this.featureSource.defaultVisibilityWindow?this.visibilityWindow=await this.featureSource.defaultVisibilityWindow():this.visibilityWindow=1e6}return this}}get supportsWholeGenome(){return!this.config.indexURL||!0===this.config.supportsWholeGenome}get color(){return this._color||\"rgb(0,0,150)\"}set color(e){this._color=e,e&&(this.colorBy=void 0)}async getHeader(){return this.header||\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getSampleCount(){return this.sampleKeys?this.sampleKeys.length:0}async getFeatures(e,t,i,n){void 0===this.header&&(this.header=await this.getHeader());const r=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow});if(this.initialSort){const e=this.initialSort;if(void 0===e.option||\"GENOTYPE\"===e.option.toUpperCase())this.sortSamplesByGenotype(e,r);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"ASC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return r}hasSamples(){return this.getSampleCount()>0}getSamples(){const e=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=t*((\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight)+e),r=Kv+t*(i+e);return{names:this.sampleKeys,yOffset:r,height:n}}computePixelHeight(e){if(!e||0===e.length)return Kv;const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,n=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=!1===this.showGenotypes?0:this.getSampleCount()*t;return Kv+t*(n+i)+i+(s+1)*(r+i)}variantRowCount(e){this.nVariantRows=e}draw({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){xo.fillRect(e,0,s,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const a=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,c=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,l=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=Kv+c*(l+a);let h=this.sampleColumns;const d=this.hasSamples();if(h&&d&&!1!==this.showGenotypes&&xo.strokeLine(e,0,this.variantBandHeight,t,this.variantBandHeight,{strokeStyle:\"rgb(224,224,224) \"}),o){const i=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+t*n+1;for(let t of o){if(t.enda)break;const o=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=Kv+(\"COLLAPSED\"===this.displayMode?0:t.row*(o+s)),l=o;let h=(t.start-r)/n,u=(t.end-r)/n,f=Math.max(1,u-h);f<3?(f=3,h-=1):f>5&&(h+=1,f-=2);const p=t._f||t;let g;try{g=p.alleleFreq()}catch(e){console.log(e)}if(\"AF\"===this.colorBy&&g){const t=Math.min(1,g)*l,i=l-t;e.fillStyle=p.isFiltered()?this.refColorFiltered:this.refColor,e.fillRect(h,c,f,i),e.fillStyle=p.isFiltered()?this.altColorFiltered:this.altColor,e.fillRect(h,c+i,f,t)}else e.fillStyle=this.getColorForFeature(p),e.fillRect(h,c,f,l);let m=this.getVariantStrokecolor(p);if(m&&(e.strokeStyle=m,e.strokeRect(h,c,f,l)),this.callContextHook(p,e,h,c,f,l),d&&!1!==this.showGenotypes){const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=t*(i+s);let n=0;for(let t of this.sampleKeys){const r=this.header.sampleNameMap.get(t),o=p.calls[r];if(o){const t=\"COLLAPSED\"===this.displayMode?0:p.row,r=this.sampleYOffset+n*this.sampleHeight+t*(i+s);let a=!0,c=!0,l=!1;if(o.genotype)for(let e of o.genotype){if(\".\"===e){l=!0;break}0!==e&&(c=!1),0===e&&(a=!1)}o.genotype?e.fillStyle=l?this.noCallColor:c?this.homrefColor:a?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,r,f,i)}n++}}}}else console.log(\"No feature list\")}get refColorFiltered(){return this._refColorFiltered||(this._refColorFiltered=_s.addAlpha(this.refColor,.2)),this._refColorFiltered}get altColorFiltered(){return this._altColorFiltered||(this._altColorFiltered=_s.addAlpha(this.altColor,.2)),this._altColorFiltered}getColorForFeature(e){const t=e._f||e;let i;if(this.colorBy&&\"none\"!==this.colorBy){const e=t.getAttributeValue(this.colorBy);i=void 0!==e?this.getVariantColorTable(this.colorBy).getColor(e):\"gray\"}else i=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"NONVARIANT\"===t.type?this.nonRefColor:\"MIXED\"===t.type?this.mixedColor:this.color;return t.isFiltered()&&(i=_s.addAlpha(i,.2)),i}getVariantStrokecolor(e){const t=e._f||e;let i;return i=this.strokecolor?\"function\"==typeof this.strokecolor?this.strokecolor(t):this.strokecolor:void 0,i}callContextHook(e,t,i,n,r,s){if(this._context_hook&&\"function\"==typeof this._context_hook){const o=e._f||e;t.save(),this._context_hook(o,t,i,n,r,s),t.restore()}}clickedFeatures(e){let t=super.clickedFeatures(e);const i=\"EXPANDED\"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+(\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=e.y;if(r<=this.variantBandHeight){const e=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-Kv)/(e+i));\"COLLAPSED\"!==this.displayMode&&(t=t.filter((e=>e.row===n)))}else if(this.sampleKeys){const e=r-this.variantBandHeight,i=Math.floor(e/this.sampleHeight);if(i>=0&&ie.row===r)),o=this.sampleKeys[i],a=this.header.sampleNameMap.get(o);t=s.map((e=>{const t=e.calls[a];return t.genotypeString=function(e,t){if(e.genotype){let i=\"\";if(\".\"===t.alternateBases)i=\"No Call\";else{const n=t.alternateBases.split(\",\");for(let r of e.genotype)if(i.length>0&&(i+=\" | \"),\".\"===r)i+=\".\";else if(0===r)i+=t.referenceBases;else{i+=n[r-1].replace(\"<\",\"<\")}}return i}}(t,e),t}))}}return t}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=this.browser.genome.id;let r=[];for(let e of t){const t=e._f||e;if(r.length>0&&r.push({html:'
'}),\"function\"==typeof t.popupData){const e=t.popupData(i,n);Array.prototype.push.apply(r,e)}}return r}menuItemList(){const e=[];if(this.header.INFO&&this.header.INFO){const t=this._colorByItems;e.push(\"
\");const i=Bt('
');i.text(\"Color by:\"),e.push({name:void 0,object:i,click:void 0,init:void 0});for(let n of t.keys()){const r=this.colorBy===n;e.push(this.colorByCB({key:n,label:t.get(n)},r))}e.push(this.colorByCB({key:\"info\",label:\"Info field...\"}))}if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const s of this.browser.sampleInfo.attributeNames)if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[s]}))){const o=Bt(\"
\");function a(){const e=this._sortDirections.get(s)||1;this.sortByAttribute(s,e),this.config.sort={option:\"ATTRIBUTE\",attribute:s,direction:e>0?\"ASC\":\"DESC\"},this._sortDirections.set(s,-1*e)}o.html(`  ${s.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:o,click:a})}}e.push(\"
\"),this.getSampleCount()>0&&(e.push({object:Bt('
')}),e.push({object:Bt(Dl(\"Show Genotypes\",this.showGenotypes)),click:function(){this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.browser.sampleNameControl.performClickWithState(this.browser,this.showGenotypes),this.browser.sampleInfoControl.performClickWithState(this.browser,this.showGenotypes)}})),e.push({object:Bt('
')});for(let c of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){e.push({object:Bt(Dl({COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"}[c],c===this.displayMode)),click:function(){this.displayMode=c,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add SVs to circular view\",click:function(){for(let e of this.trackView.viewports)this.sendChordsForViewport(e)}})),this.canCovertToPytor()&&(e.push(\"
\"),e.push({label:\"Convert to CNVpytor track\",click:function(){this.convertToPytor()}})),e}contextMenuItemList(e){const t=[];if(this.hasSamples()&&this.showGenotypes){const i=e.viewport.referenceFrame,n=e.genomicLocation,r=i.toBP(2.5),s=this._sortDirections.get(\"genotype\")||1;this._sortDirections.set(\"genotype\",-1*s),t.push({label:\"Sort by genotype\",click:t=>{const i={direction:s,option:\"genotype\",chr:e.viewport.referenceFrame.chr,start:Math.floor(n-r),end:Math.ceil(n+r)},o=e.viewport.cachedFeatures;this.sortSamplesByGenotype(i,o),this.config.sort=i}}),t.push(\"
\")}if(this.browser.circularView){const i=e.viewport;t.push({label:\"Add SVs to Circular View\",click:()=>{this.sendChordsForViewport(i)}}),t.push(\"
\")}return t}async sortSamplesByGenotype({chr:e,position:t,start:i,end:n,direction:r},s){if(void 0===i&&(i=t-1),void 0===n&&(n=t),s||(s=await this.featureSource.getFeatures({chr:e,start:i,end:n})),!s)return;const o=new Map,a=\"ASC\"===r?1:-1;for(let e of s)if(!(e.endn)break;for(let t of e.calls){const e=t.sample,i=t.zygosityScore();o.set(e,o.has(e)?o.get(e)+i:i)}}this.sampleKeys.sort((function(e,t){let i=o.get(e)||0,n=o.get(t)||0;return a*(i-n)})),this.trackView.repaintViews()}sortByAttribute(e,t){this.config.sort={option:\"ATTRIBUTE\",attribute:e,direction:1===t?\"ASC\":\"DESC\"},this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}sendChordsForViewport(e){const t=e.referenceFrame;let i;if(\"all\"===t.chr){const e=this.featureSource.getAllFeatures(),t=Object.keys(e).map((t=>e[t]));i=[].concat(...t)}else i=this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end);Pm(i.filter((e=>{const t=e._f||e;return t.info&&t.info.CHR2&&t.info.END&&(t.info.CHR2!==t.chr||Math.abs(Number.parseInt(t.info.END)-t.pos)>1e6)})).map((e=>{const t=e._f||e,i=Number.parseInt(t.info.END),n=i-100,r=i+100;return{uniqueId:`${t.chr}:${t.start}-${t.end}_${t.info.CHR2}:${t.info.END}`,refName:zm(t.chr),start:t.start,end:t.end,mate:{refName:zm(t.info.CHR2),start:n,end:r}}})),this,t,.5)}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"info\"!==e.key){function n(){const t=\"none\"===e.key?void 0:e.key;this.colorBy=t,this.config.colorBy=t,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){this.browser.inputDialog.present({label:\"Info field\",value:\"\",callback:e=>{e?(this.colorBy=e,this._colorByItems.set(e,e)):this.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}getState(){const e=super.getState();return this.color&&\"function\"!=typeof this.color&&(e.color=this.color),e}getVariantColorTable(e){if(this.colorTables.has(e))return this.colorTables.get(e);if(this.colorTables.has(\"*\"))return this.colorTables.get(\"*\");{let t;if(\"SVTYPE\"===e)t=Xv;else t=new oo(\"Set1\");return this.colorTables.set(e,t),t}}paintAxis(){}canCovertToPytor(){return!this.config.indexURL&&(!!this.header&&(1===Object.keys(this.sampleKeys).length&&this.header.FORMAT&&this.header.FORMAT.AD&&this.header.FORMAT.DP))}async convertToPytor(){this.variantState={...this.config,...this.getState()},this.variantState.trackHeight=this.height,this.trackView.startSpinner(),setTimeout((async()=>{try{const e=Object.assign({},this.config);Object.setPrototypeOf(this,Gv.prototype),this.init(e),await this.postInit(),this.trackView.clearCachedFeatures(),this.trackView.setTrackHeight(this.config.height||Gv.DEFAULT_TRACK_HEIGHT),this.trackView.checkContentHeight(),this.trackView.updateViews()}finally{this.trackView.stopSpinner()}}),100)}}const Xv=new ao({DEL:\"#ff2101\",INS:\"#001888\",DUP:\"#028401\",INV:\"#008688\",CNV:\"#8931ff\",BND:\"#891100\",\"*\":\"#002eff\"}),Zv={timeout:5e3,type:\"plain\",url:\"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$\",coords:0};async function Jv(e,t){const i=e.searchConfig||Zv;let n;t=t.toUpperCase();const r=e.tracks.filter((e=>e.searchable));for(let e of r){const i=await e.search(t);if(i)return i}if(e.config&&!1!==e.config.search)try{return n=await async function(e,t,i){let n=i.url.replace(\"$FEATURE$\",t.toUpperCase());n.indexOf(\"$GENOME$\")>-1&&(n=n.replace(\"$GENOME$\",e.genome.id?e.genome.id:\"hg19\"));const r=i.timeout?{timeout:i.timeout}:void 0,s=await Qs.loadString(n,r);return function(e,t,i){let n;n=\"plain\"===i.type?function(e,t){const i=[],n=Dt(t);for(let t of n){const n=t.split(\"\\t\");if(n.length>=3){const t=n[1].split(\":\"),r=t[1].split(\"-\");i.push({chromosome:e.genome.getChromosomeName(t[0].trim()),start:parseInt(r[0].replace(/,/g,\"\")),end:parseInt(r[1].replace(/,/g,\"\")),name:n[0].toUpperCase()})}}return i}(e,t):JSON.parse(t);i.resultsField&&(n=n[i.resultsField]);if(n&&0!==n.length){const e=i.chromosomeField||\"chromosome\",t=i.startField||\"start\",r=i.endField||\"end\",s=i.coords||1;let o;o=Array.isArray(n)?n[0]:n,o.hasOwnProperty(e)&&o.hasOwnProperty(t)||console.error(\"Search service results must include chromosome and start fields: \"+o);const a=o[e];let c=o[t]-s,l=o[r];void 0===l&&(l=c+1);const h={chr:a,start:c,end:l};if(!o.type||o.type,i.geneField&&i.snpField){const e=o[i.geneField]||o[i.snpField];e&&(h.name=e.toUpperCase())}return h}return}(e,s,i)}(e,t,i),n}catch(e){console.log(\"Search service not available \"+e)}}function ey(e,t=!1){const i=e.split(\"\\t\");if(i.length>2)try{const e=i[0],t=parseInt(i[1].replace(/,/g,\"\"),10)-1,n=parseInt(i[2].replace(/,/g,\"\"),10);if(!isNaN(t)&&!isNaN(n))return{chr:e,start:t,end:n}}catch(e){}const n=e.split(\":\"),r={chr:n[0]};if(n.length>1){let e,i=n[1].split(\"-\");if(i.length>2){if(!n[1].startsWith(\"-\"))return;{const e=n[1].indexOf(\"-\",1);if(e>0){i=[n[1].substring(0,e),n[1].substring(e+1)]}}}if(e=i[0].replace(/,/g,\"\"),isNaN(e))return;if(r.start=parseInt(e,10)-1,r.end=r.start+1,1===i.length&&(r.start-=20,r.end+=20),2===i.length){if(e=i[1].replace(/,/g,\"\"),isNaN(e))return;if(r.end=parseInt(e,10),r.start<0&&!t){const e=-extent.start;r.start+=e,r.end+=e}}}return r}class ty extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"qtl\",this.name=e.name;const t=e.minLogP||e.min,i=e.maxLogP||e.max;this.dataRange={min:void 0!==t?t:3.5,max:i||25},this.autoscale=!i||e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||2,this.height=e.height||100,this.disableButtons=e.disableButtons,this.featureSource=Ad(e,this.browser.genome)}paintAxis(e,t,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*t,a=s-5,c=s,l=i-(o-this.dataRange.min)/n;xo.strokeLine(e,a,l,c,l,r),l>8&&xo.fillText(e,o,a-1,l+2,r)}r.textAlign=\"center\",xo.fillText(e,\"-log10(pvalue)\",t/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(e,t,i){const n=this.visibilityWindow;return await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const{context:t,referenceFrame:i,pixelWidth:n,pixelHeight:r}=e;this.background&&xo.fillRect(t,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(t,0,r-1,n,r-1,{strokeStyle:this.divider}),i.feature&&i.feature.match(/RS[0-9]+/);const s=i=>{const s=i?2*this.dotSize:this.dotSize,o=e.bpStart,a=(this.dataRange.max-this.dataRange.min)/r;for(let d of e.features){const u=(d.start-o+.5)/e.bpPerPixel;if(u<0)continue;if(u>n)break;const f=d.phenotype;let p;if(this.browser.qtlSelections.qtl?(l=this.browser.qtlSelections.qtl,h=d,p=l.chr===h.chr&&l.start===h.start&&l.pValue===h.pValue):p=this.browser.qtlSelections.snps.size>0?this.browser.qtlSelections.hasSnp(d.snp)&&this.browser.qtlSelections.hasPhenotype(f):this.browser.qtlSelections.hasPhenotype(f),!i||p){var c=-Math.log(d.pValue)/Math.LN10;if(c>=this.dataRange.min){let e;c>this.dataRange.max?(c=this.dataRange.max,e=!0):e=!1;const n=Math.max(0+s,r-Math.round((c-this.dataRange.min)/a));let o;d.px=u,d.py=n,d.radius=s,i&&p?(o=this.browser.qtlSelections.colorForGene(f),xo.setProperties(t,{fillStyle:o,strokeStyle:\"black\"})):(o=e?\"rgb(150, 150, 150)\":\"rgb(180, 180, 180)\",xo.setProperties(t,{fillStyle:o,strokeStyle:o})),xo.fillCircle(t,u,n,s),xo.strokeCircle(t,u,n,s)}}}var l,h};s(!1),s(!0)}popupData(e,t){if(void 0===t&&(t=e.viewport.cachedFeatures),!t||0===t.length)return[];const i=this.name,n=[];for(let r of this._clickedFeatures(e,t))n.length>0&&n.push(\"
\"),\"function\"==typeof r.popupData?n.push(...r.popupData(e)):n.push({name:\"snp id\",value:r.snp},{name:\"gene id\",value:r.gencodeId},{name:\"gene name\",value:r.geneSymbol},{name:\"p value\",value:r.pValue},{name:\"tissue\",value:i});return n}_clickedFeatures(e,t){const i=(e,t)=>Math.sqrt((e.px-t.canvasX)*(e.px-t.canvasX)+(e.py-t.canvasY)*(e.py-t.canvasY)),n=t.filter((t=>i(t,e)<6));if(n.length>1){n.sort(((t,n)=>i(t,e)-i(n,e)));const t=i(n[0],e);return n.filter((n=>i(n,e)<=t))}return n}contextMenuItemList(e){const t=[],i=e.viewport.cachedFeatures;if(i){const n=this._clickedFeatures(e,i);n.length>0&&(t.push({label:\"Highlight associated features\",click:async()=>{this.browser.qtlSelections.clear();for(let e of n)this.browser.qtlSelections.qtl=e,this.browser.qtlSelections.addPhenotype(e.phenotype);this.browser.repaintViews()}}),t.push(\"
\"))}return t}menuItemList(){const e=[];return e.push(...this.numericDataMenuItems()),e.push(\"
\"),e.push({label:\"Search for...\",dialog:function(e){this.browser.inputDialog.present({label:\"Search for snp or phenotype\",value:\"\",callback:async e=>{if(e){e=e.trim().toUpperCase();const t=t=>((t.phenotype&&t.phenotype.toUpperCase())===e||t.snp&&t.snp.toUpperCase()===e)&&-Math.log(t.pValue)/Math.LN10>this.dataRange.min;let i,n,r,s=await this.featureSource.findFeatures(t);if(0==s.length){await this.browser.search(e)&&(s=await this.featureSource.findFeatures(t))}if(s.length>0){this.browser.qtlSelections.clear();const t=new Set;i=s[0].chr,n=s[0].start,r=s[0].end;for(let o of s)o.snp&&o.snp.toUpperCase()===e&&this.browser.qtlSelections.addSnp(o.snp),this.browser.qtlSelections.addPhenotype(o.phenotype),t.add(o.phenotype),o.chr===i&&(n=Math.min(n,o.start),r=Math.max(r,o.end));const o=this.browser.genome.getChromosomeName(i);for(let e of t){const t=await Jv(this.browser,e);t&&o===this.browser.genome.getChromosomeName(t.chr)&&(n=Math.min(n,t.start),r=Math.max(r,t.end))}const a=Math.floor(.1*(r-n));n=Math.max(0,n-a),r+=a,await this.browser.search(`${i}:${n}-${r}`)}}}},e)}}),e}doAutoscale(e){let t=this.config.max||25;if(e.length>0){const i=e.map((e=>-Math.log(e.pValue)/Math.LN10));i.sort(((e,t)=>e-t));t=i[Math.floor(i.length*(this.autoscalePercentile/100))]}return this.dataRange.max=Math.max(t,10),this.dataRange}}const iy={X:\"rgb(204, 153, 0)\",Y:\"rgb(153, 204, 0)\",Un:\"darkGray)\",1:\"rgb(80, 80, 255)\",2:\"rgb(206, 61, 50)\",\"2a\":\"rgb(210, 65, 55)\",\"2b\":\"rgb(215, 70, 60)\",3:\"rgb(116, 155, 88)\",4:\"rgb(240, 230, 133)\",5:\"rgb(70, 105, 131)\",6:\"rgb(186, 99, 56)\",7:\"rgb(93, 177, 221)\",8:\"rgb(128, 34, 104)\",9:\"rgb(107, 215, 107)\",10:\"rgb(213, 149, 167)\",11:\"rgb(146, 72, 34)\",12:\"rgb(131, 123, 141)\",13:\"rgb(199, 81, 39)\",14:\"rgb(213, 143, 92)\",15:\"rgb(122, 101, 165)\",16:\"rgb(228, 175, 105)\",17:\"rgb(59, 27, 83)\",18:\"rgb(205, 222, 183)\",19:\"rgb(97, 42, 121)\",20:\"rgb(174, 31, 99)\",21:\"rgb(231, 199, 111)\",22:\"rgb(90, 101, 94)\",23:\"rgb(204, 153, 0)\",24:\"rgb(153, 204, 0)\",25:\"rgb(51, 204, 0)\",26:\"rgb(0, 204, 51)\",27:\"rgb(0, 204, 153)\",28:\"rgb(0, 153, 204)\",29:\"rgb(10, 71, 255)\",30:\"rgb(71, 117, 255)\",31:\"rgb(255, 194, 10)\",32:\"rgb(255, 209, 71)\",33:\"rgb(153, 0, 51)\",34:\"rgb(153, 26, 0)\",35:\"rgb(153, 102, 0)\",36:\"rgb(128, 153, 0)\",37:\"rgb(51, 153, 0)\",38:\"rgb(0, 153, 26)\",39:\"rgb(0, 153, 102)\",40:\"rgb(0, 128, 153)\",41:\"rgb(0, 51, 153)\",42:\"rgb(26, 0, 153)\",43:\"rgb(102, 0, 153)\",44:\"rgb(153, 0, 128)\",45:\"rgb(214, 0, 71)\",46:\"rgb(255, 20, 99)\",47:\"rgb(0, 214, 143)\",48:\"rgb(20, 255, 177)\"};for(let DA of Object.keys(iy)){iy[\"chr\"+DA]=iy[DA]}for(let TA=1;TA<=48;TA++){if(10===TA)continue;const LA=ny(TA);iy[LA]=iy[TA.toString()]}function ny(e){if(!+e)return!1;for(var t=String(+e).split(\"\"),i=[\"\",\"C\",\"CC\",\"CCC\",\"CD\",\"D\",\"DC\",\"DCC\",\"DCCC\",\"CM\",\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\",\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"],n=\"\",r=3;r--;)n=(i[+t.pop()+10*r]||\"\")+n;return Array(+t.join(\"\")+1).join(\"M\")+n}class ry extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.useChrColors=void 0===e.useChrColors||e.useChrColors,this.trait=e.trait,this.posteriorProbability=e.posteriorProbability,this.valueProperty=\"bed\"===e.format?\"score\":\"value\",this.height=e.height||100,this.autoscale=e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||3,this.popoverWindow=void 0===e.popoverWindow?1e8:e.popoverWindow,this.useChrColors?this.colorScale=new ao(e.colorTable||iy):e.color?this.colorScale=new ff(e.color):this.colorScale=new df(e.colorScale||{thresholds:[5e-8,5e-4,.5],colors:[\"rgb(255,50,50)\",\"rgb(251,100,100)\",\"rgb(251,170,170)\",\"rgb(227,238,249)\"]}),this.featureSource=Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.features,i=e.context,n=e.pixelWidth,r=e.pixelHeight;if(this.background&&xo.fillRect(i,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),t){const s=e.bpPerPixel,o=e.bpStart,a=o+n*s+1;for(let e of t){const t=e.start;if(ta)break;let n;if(this.posteriorProbability)n=e[this.valueProperty];else{const t=e[this.valueProperty];if(!t)continue;n=-Math.log10(t)}const c=this.useChrColors?e._f?e._f.chr:e.chr:n,l=this.colorScale.getColor(c),h=(this.dataRange.max-this.dataRange.min)/r,d=Math.round((t-o)/s),u=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/h));l&&xo.setProperties(i,{fillStyle:l,strokeStyle:\"black\"}),xo.fillCircle(i,d,u,this.dotSize),e.px=d,e.py=u}}}paintAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});var n={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const t=.1;for(let s=this.dataRange.min;s0&&i.push(\"
\"),5==r){i.push(\"...\");break}if(s=s._f||s,\"function\"==typeof s.popupData)i=i.concat(s.popupData());else{const e=s[this.valueProperty],t=s.chr,r=Rt(s.start+1);i.push({name:\"chromosome\",value:t}),i.push({name:\"position\",value:r}),i.push({name:\"name\",value:s.name}),n.posteriorProbability?i.push({name:\"posterior probability\",value:e}):i.push({name:\"pValue\",value:e})}r++}}}return i}menuItemList(){return this.numericDataMenuItems()}doAutoscale(e){if(e.length>0){const t=this.valueProperty,i=this.posteriorProbability,n=e.map((function(e){const n=e[t];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=qa(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class sy extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.autoscale=e.autoscale||void 0===e.max,this.dataRange={min:e.min||0,max:e.max},this.windowFunction=e.windowFunction||\"mean\",this.paintAxis=cd,this.graphType=e.graphType||\"bar\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=Ad(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if(\"function\"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleKeys=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty(\"clickToHighlight\")){let e=this.header.clickToHighlight;this.config.clickToHighlight=e,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty(\"highlight\")){this.config.highlightSamples={};let e=this.header.highlight;Array.isArray(e)||(e=[e]);for(let t of e){const e=t.split(\";\");2===e.length&&(this.config.highlightSamples[e[0]]=e[1])}}}}menuItemList(){return this.numericDataMenuItems()}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let e=1;et&&(r=e-1),void 0===s&&n[e].start>i){s=e+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=e,a=e=>(this.dataRange.max-e)/(this.dataRange.max-this.dataRange.min)*o,c=function(e){let t=Math.floor((e-r)/n);return isNaN(t)&&console.warn(\"isNaN(x). feature start \"+Rt(e)+\" bp start \"+Rt(r)),t};if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const e=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},l=[],h=[];this.clickDetectorCache={};for(let d of t){const t=c(d.start),u=c(d.end),f=s>=0?c(s):t;if(!isNaN(t)&&!isNaN(u)){this.clickDetectorCache[t]=[],this.clickDetectorCache[u]=[];for(let s=0;s=1){const s=o[c],h=a(s),d=e&&e[c];d?l.push([f,h,t,g,d]):r&&c in this.config.samplesClickedToHighlight?l.push([f,h,t,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,f,h,t,g,{strokeStyle:\"#D9D9D9\"}),n&&!(c in e)||this.clickDetectorCache[t].push([f,h,t,g,c,d||\"gray\"])}if(u-t>=1){const s=e&&e[c];s?h.push([t,g,u,g,s]):r&&c in this.config.samplesClickedToHighlight?h.push([t,g,u,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,t,g,u,g,{strokeStyle:\"gray\"}),n&&!(c in e)||this.clickDetectorCache[u].push([t,g,u,g,c,s||\"gray\"])}o[c]=p}s=d.end}}for(let e of l)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:1.3});for(let e of h)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:2})}(e=>{if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=a(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):xo.strokeLine(e.context,0,i,e.pixelWidth,i,n)}})(e)}doAutoscale(e){let t,i;return e.length>0?(t=Number.MAX_VALUE,i=-Number.MAX_VALUE,e.forEach((function(e){t=Math.min(t,...e.values),i=Math.max(i,...e.values)})),t-=.01,i+=.01):(t=0,i=100),{min:t,max:i}}clickedFeatures(e){const t=e.canvasX,i=e.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=t)break;if(n){let e=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(ts)return[];const a=n[1],c=n[3];if(iMath.max(a,c)+10)continue;const l=oy(t,i,r,a,s,c);l0?c/l:0}class ay extends Hl{static defaults={height:300,theta:Math.PI/2,arcOrientation:\"UP\"};constructor(e,t){super(e,t),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",\"bp\"===e.format?this.featureSource=new ly(e,t.genome):this.featureSource=new ud(e,t.genome)}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.context,i=Math.PI/2,n=e.pixelWidth,r=e.pixelHeight;e.viewportWidth;const s=e.bpPerPixel,o=e.bpStart,a=s,c=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,n,r,{fillStyle:\"rgb(255, 255, 255)\"});const l=e.features;if(l){cy(l,1);for(let e of l)if(e.startLeft){let n=Math.round((e.startLeft-o)/a),r=Math.round((e.startRight-o)/a),s=Math.round((e.endLeft-o)/a),l=Math.round((e.endRight-o)/a);t.fillStyle=e.color,t.strokeStyle=e.color,t.beginPath();let h=(n+l)/2,d=(l-n)/2,u=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);c?(t.arc(h,u,d,f,p),t.lineTo(s,u)):(u=0,t.arc(h,u,d,p,f),t.lineTo(l,u));const g=(r+s)/2,m=(s-r)/2,w=u;c?(t.arc(g,w,m,p,f,!0),t.lineTo(n,w)):(t.arc(g,w,m,f,p,!0),t.lineTo(s,w)),t.stroke(),t.fill(),e.drawState={x1:h,y1:u,r1:d,x2:g,y2:w,r2:m,sa:f,ea:p}}else{let n=Math.round((e.start-o)/a),r=Math.round((e.end-o)/a);t.strokeStyle=e.color,t.beginPath();let s=(n+r)/2,l=(r-n)/2,h=this.height,d=Math.PI+(Math.PI/2-i),u=2*Math.PI-(Math.PI/2-i);c?t.arc(s,h,l,d,u):(h=0,t.arc(s,h,l,u,d)),t.stroke(),e.drawState={x1:s,y1:h,r1:l,sa:d,ea:u}}}}clickedFeatures(e){const t=super.clickedFeatures(e),i=[];cy(t,-1);for(let n of t){const t=n.drawState,r=e.canvasX-t.x1,s=e.canvasY-t.y1,o=Math.sqrt(r*r+s*s),a=t.r1+3;let c,l;if(void 0===t.x2)c=o,l=t.r1-3;else{const i=e.canvasX-t.x2,n=e.canvasY-t.y2;c=Math.sqrt(i*i+n*n),l=t.r2-3}if(ol){i.push(n);break}}return i}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0)return this.extractPopupData(t[0],this.getGenomeId())}menuItemList(){return[{name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}]}}function cy(e,t){e.sort((function(e,i){const n=void 0===e.score?-Number.MAX_VALUE:e.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===t?1:t)*(n-r)}))}class ly{constructor(e,t){this.config=e,this.genome=t}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,t,i);{const n=Ua(this.config),r=await Qs.loadByteArray(this.config.url,n);return this.featureCache=new Zs(function(e){if(!e)return null;const t=mh(e);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=t.nextLine());){const e=i.split(\"\\t\");if(n&&i.startsWith(\"color:\")){const t=\"rgb(\"+e[1]+\",\"+e[2]+\",\"+e[3]+\")\";r.push(t),e.length>4&&s.push(e[4])}else{n=!1;const t=e[0],i=Number.parseInt(e[1])-1,c=Number.parseInt(e[2])-1,l=Number.parseInt(e[3]),h=Number.parseInt(e[4]);var a=Number.parseInt(e[5]);const d=r[a];let u;u=i<=h?{chr:t,startLeft:Math.min(i,c),startRight:Math.max(i,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:d,score:a}:{chr:t,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(i,c),endRight:Math.max(i,c),color:d,score:a},u.start=u.startLeft,u.end=u.endRight,s.length>a&&(u.description=s[a]),o.push(u)}}return o}(r),s),this.featureCache.queryFeatures(e,t,i)}}}class hy{constructor(e){this.browser=e,this.type=\"ideogram\",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,features:r}){const s=t.chr,o=t.genome.getChromosome(s);if(void 0===o||i<=0||n<=0||\"all\"===s.toLowerCase())return;!function({ctx:e,chr:t,referenceFrame:i,genome:n,width:r,height:s,stainColors:o,features:a}){const c=1,l=.5*c,h=0;if(void 0===n)return;xo.fillRect(e,0,0,r,s,{fillStyle:_s.greyScale(255)});const d=a;if(d){const t=h+s/2,i=[],n=[];if(0===d.length)return;const a=r/d[d.length-1].end;e.beginPath(),xo.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1),e.clip();for(let r=0;r0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),o.bpLength=l),a{uy.getColor(e)}));class fy extends Hl{static defaults={margin:10,colorByNumReadsThreshold:5,height:100};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=e.type||\"junctions\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){return this.height}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.isMergedTrack||xo.fillRect(i,0,e.pixelTop,s,o,{fillStyle:\"rgb(255, 255, 255)\"}),t){const s={};s.referenceFrame=e.viewport.referenceFrame,s.referenceFrameStart=s.referenceFrame.start,s.referenceFrameEnd=s.referenceFrameStart+s.referenceFrame.toBP(e.viewport.getWidth()),s.featureZoomOutTracker={};for(let e of t)if(!(e.enda)break;this.renderJunction(e,r,n,o,i,s)}}else console.log(\"No feature list\")}renderJunction(e,t,i,n,r,s){e.isVisible=!1;const o=Math.round((e.start-t)/i),a=Math.round((e.end-t)/i),c=(o+a)/2;if(a-o<=3){if(c in s.featureZoomOutTracker)return;s.featureZoomOutTracker[c]=!0}if(this.config.hideAnnotatedJunctions&&\"true\"===e.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&\"false\"===e.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(e.attributes.motif))return;if(this.config.hideStrand===e.strand)return;if(this.config.minJunctionEndsVisible){let t=0;if(e.start>=s.referenceFrameStart&&e.start<=s.referenceFrameEnd&&(t+=1),e.end>=s.referenceFrameStart&&e.end<=s.referenceFrameEnd&&(t+=1),t0&&h/d>this.config.maxFractionMultiMappedReads)return;if(e.attributes.maximum_spliced_alignment_overhang&&parseInt(e.attributes.maximum_spliced_alignment_overhang)this.config.maxSamplesWithThisJunction)return;if(e.attributes.num_samples_total&&(e.attributes.percent_samples_with_this_junction=100*u/Number(e.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(e.attributes.percent_samples_with_this_junctionthis.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,p=n,g=f+.5*p;let m=f;const w=f+p-10,b=(o+c)/2,F=(c+a)/2;let v,y,A=1;e.attributes.line_width?A=Number(e.attributes.line_width):(void 0===this.config.thicknessBasedOn||\"numUniqueReads\"===this.config.thicknessBasedOn?A=l:\"numReads\"===this.config.thicknessBasedOn?A=d:\"numSamplesWithThisJunction\"===this.config.thicknessBasedOn&&void 0!==u&&(A=u),A=1+Math.log(A+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||\"random\"===this.config.bounceHeightBasedOn?v=(e.start+e.end)%7:\"distance\"===this.config.bounceHeightBasedOn?v=6*(e.end-e.start)/(s.referenceFrameEnd-s.referenceFrameStart):\"thickness\"===this.config.bounceHeightBasedOn&&(v=2*A),m+=p*Math.max(7-v,0)/10,y=e.attributes.color?e.attributes.color:void 0===this.config.colorBy||\"numUniqueReads\"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"numReads\"===this.config.colorBy?d>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"isAnnotatedJunction\"===this.config.colorBy?\"true\"===e.attributes.annotated_junction?\"#b0b0ec\":\"orange\":\"strand\"===this.config.colorBy?\"+\"===e.strand?\"#b0b0ec\":\"#ecb0b0\":\"motif\"===this.config.colorBy?uy.getColor(e.attributes.motif):\"#AAAAAA\";let C=\"\";e.attributes.label?C=e.attributes.label.replace(/_/g,\" \"):void 0===this.config.labelWith||\"uniqueReadCount\"===this.config.labelWith?C=l:\"totalReadCount\"===this.config.labelWith?C=d:\"numSamplesWithThisJunction\"===this.config.labelWith?void 0!==u&&(C=u):\"percentSamplesWithThisJunction\"===this.config.labelWith?void 0!==e.attributes.percent_samples_with_this_junction&&(C=e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%\"):\"motif\"===this.config.labelWith&&void 0!==e.attributes.motif&&(C+=e.attributes.motif),\"uniqueReadCount\"===this.config.labelWithInParen?C+=\" (\"+l+\")\":\"totalReadCount\"===this.config.labelWithInParen?C+=\" (\"+d+\")\":\"multiMappedReadCount\"===this.config.labelWithInParen?h>0&&(C+=\" (+\"+h+\")\"):\"numSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==u&&(C+=\" (\"+u+\")\"):\"percentSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==e.attributes.percent_samples_with_this_junction&&(C+=\" (\"+e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%)\"):\"motif\"===this.config.labelWithInParen&&void 0!==e.attributes.motif&&(C+=` ${e.attributes.motif}`),e.isVisible=!0,r.beginPath(),r.moveTo(o,w),r.bezierCurveTo(b,m,F,m,a,w),r.lineWidth=A,r.strokeStyle=y,r.stroke();const _=(e,t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-n/2,i-n),e.lineTo(t+n/2,i-n),e.lineTo(t,i),e.closePath(),e.fill()};if(e.attributes.left_shape||e.attributes.right_shape){r.fillStyle=y;const t=r.lineWidth>2?10:7;e.attributes.left_shape&&_(r,o,w,t),e.attributes.right_shape&&_(r,a,w,t)}r.fillText(C,c-r.measureText(C).width/2,(7*m+g)/8)}clickedFeatures(e){return super.clickedFeatures(e).filter((function(e){return e.isVisible&&e.attributes}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=\"function\"==typeof e.popupData?e.popupData(i):this.extractPopupData(e._f||e,this.getGenomeId());t&&(n.length>0&&n.push(\"

\"),Array.prototype.push.apply(n,t))}return n}dispose(){this.trackView=void 0}}const py={min:0,max:3e3,color:\"rgb(0,0,255)\"};class gy{constructor(e){e=e||py,this.max=e.max,this.min=e.min||0,this.cache=[],this.nbins=1e3,this.binsize=(this.max-this.min)/this.nbins,this.updateColor(e.color||\"rgb(0,0,255)\")}updateColor(e){const t=e.substring(4).replace(\")\",\"\").split(\",\");3===t.length&&(this.r=Number.parseInt(t[0].trim()),this.g=Number.parseInt(t[1].trim()),this.b=Number.parseInt(t[2].trim())),this.cache=[]}setMinMax(e,t){this.min=e,this.max=t,this.cache=[],this.binsize=(this.max-this.min)/this.nbins}getColor(e){if(e\");let t=Bt(\"
\");return t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),e}setDataRange({min:e,max:t}){this.dataRange.min=e,this.dataRange.max=t,this.colorScale.min=e,this.colorScale.max=t,this.trackView.repaintViews()}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.rowHeight,yOffset:0}}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){const a=this.rowHeight,c=t+n,l=o+i*s+1,h=a;for(let i of r){if(i.endl)continue;const n=Math.round((i.start-o)/s),r=Math.round((i.end-o)/s),d=Math.max(1,r-n);let u=0;for(let r=i.values.length-1;r>=0;r--){const s=i.values[r],o=u*a;if(o+ac)continue;const l=this.colorScale.getColor(s);e.fillStyle=l,e.fillRect(n,o,d,h),u++}}}}computePixelHeight(e){return e&&0!==e.length?e[0].values.length*this.rowHeight:0}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}get supportsWholeGenome(){return!1}getState(){const e=super.getState();return e.colorScale=this.colorScale.toJson(),e}}const wy=new Map([[\"ideogram\",(e,t)=>new hy(e,t)],[\"sequence\",(e,t)=>new Zd(e,t)],[\"feature\",(e,t)=>new Hd(e,t)],[\"seg\",(e,t)=>new Pf(e,t)],[\"mut\",(e,t)=>new Pf(e,t)],[\"maf\",(e,t)=>new Pf(e,t)],[\"shoebox\",(e,t)=>new my(e,t)],[\"wig\",(e,t)=>new ld(e,t)],[\"merged\",(e,t)=>new tf(e,t)],[\"alignment\",(e,t)=>new tw(e,t)],[\"interaction\",(e,t)=>new iw(e,t)],[\"interact\",(e,t)=>new iw(e,t)],[\"variant\",(e,t)=>new Yv(e,t)],[\"qtl\",(e,t)=>new ty(e,t)],[\"eqtl\",(e,t)=>new ty(e,t)],[\"gwas\",(e,t)=>new ry(e,t)],[\"arc\",(e,t)=>new ay(e,t)],[\"gcnv\",(e,t)=>new sy(e,t)],[\"junction\",(e,t)=>new fy(e,t)],[\"blat\",(e,t)=>new Vd(e,t)],[\"cnvpytor\",(e,t)=>new Gv(e,t)]]);class by{constructor(e,t){const i=(new DOMParser).parseFromString(e,\"text/xml\");this.processRootNode(i,t);const n=i.getElementsByTagName(\"Resource\"),r=i.getElementsByTagName(\"Track\"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(e,t){var i={url:e.getAttribute(\"path\"),indexURL:e.getAttribute(\"index\"),order:t};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(e){const t=e.getElementsByTagName(\"Track\");if(t&&t.length>0){const i={type:\"merged\",tracks:[]};Fy(e,i),o.push(i),Array.from(t).forEach((function(e){e.processed=!0;const t=e.getAttribute(\"id\"),n=a.get(t);n&&(i.tracks.push(n),Fy(e,n),n.autoscale=!1,i.height=n.height)}))}else if(!e.processed){const t=e.getAttribute(\"id\"),i=a.get(t);i&&(o.push(i),Fy(e,i))}}))}processRootNode(e,t){const i=e.getElementsByTagName(\"Session\");!i||i.length;const n=i.item(0),r=n.getAttribute(\"genome\"),s=n.getAttribute(\"locus\"),o=n.getAttribute(\"ucscID\");t&&t.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Fy(e,t){t.name=e.getAttribute(\"name\");const i=e.getAttribute(\"color\");i&&(t.color=\"rgb(\"+i+\")\");const n=e.getAttribute(\"altColor\");i&&(t.altColor=\"rgb(\"+n+\")\");const r=e.getAttribute(\"height\");r&&(t.height=parseInt(r));const s=e.getAttribute(\"autoScale\");s&&(t.autoscale=\"true\"===s);const o=e.getAttribute(\"autoscaleGroup\");o&&(t.autoscaleGroup=o);const a=e.getAttribute(\"windowFunction\");a&&(t.windowFunction=a);const c=e.getAttribute(\"visibilityWindow\")||e.getAttribute(\"featureVisibilityWindow\");c&&(t.visibilityWindow=c);const l=e.getAttribute(\"indexed\");l&&(t.indexed=\"true\"===l);const h=e.getAttribute(\"normalize\");h&&(t.normalize=\"true\"===h);const d=e.getElementsByTagName(\"DataRange\");if(d.length>0){const e=d.item(0);t.min=Number(e.getAttribute(\"minimum\")),t.max=Number(e.getAttribute(\"maximum\")),t.logScale=\"LOG\"===e.getAttribute(\"type\")}}class vy{constructor(e,t,i,n,r){this.genome=e,this.chr=t,this.start=i,this.end=n,this.bpPerPixel=r,this.id=s()}get center(){return(this.start+this.end)/2}get locusSearchString(){return`${this.chr}:${this.start+1}-${this.end}`}extend(e){const t=Math.min(e.start,this.start),i=Math.max(e.end,this.end),n=(i-t)/(this.end-this.start);this.start=t,this.end=i,this.bpPerPixel*=n}calculateEnd(e){return this.start+this.bpPerPixel*e}calculateCenter(e){return this.start+this.bpPerPixel*e/2}calculateBPP(e,t){return(e-this.start)/t}set(e){this.chr=e.chr,this.start=e.start,this.bpPerPixel=e.bpPerPixel}toPixels(e){return e/this.bpPerPixel}toBP(e){return this.bpPerPixel*e}shift(e){this.start+=e,this.end+=e}shiftPixels(e,t,i){const n=this.start,r=e*this.bpPerPixel;return this.start+=r,i&&this.clampStart(t),this.end=this.start+t*this.bpPerPixel,n!==this.start}clampStart(e){const t=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(t,this.start),e){const{bpLength:t}=this.genome.getChromosome(this.chr),i=t-e*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(e,t,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,s=this.start,o=this.bpPerPixel,a=this.getChromosome().bpLength,c=t<1?e.minimumBases()/i:a/i;this.bpPerPixel=t<1?Math.max(this.bpPerPixel*t,c):Math.min(this.bpPerPixel*t,c);const l=this.bpPerPixel*i;this.start=r-.5*l,this.clampStart(i),this.end=this.start+l;(s!==this.start||o!==this.bpPerPixel)&&await e.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(e){const t=\" \",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*e);return`${t}${this.chr}${t}${Wa(n-i)}${t}`}getMultiLocusLabelLocusOnly(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e);return`${t}${i}:${n}-${r}${t}`}getMultiLocusLabel(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e),s=Math.floor(this.start)+1;return`${t}${i}:${n}-${r}${t}${t}(${Wa(Math.round(this.start+this.bpPerPixel*e)-s)})${t}`}getPresentationLocusComponents(e){if(\"all\"===this.chr)return{chr:this.chr};{const t=Rt(Math.floor(this.start)+1),i=Rt(Math.round(this.start+this.bpPerPixel*e));return{chr:this.chr,start:t,end:i}}}getLocusString(){if(\"all\"===this.chr)return\"all\";return`${this.genome.getChromosomeDisplayName(this.chr)}:${Rt(Math.floor(this.start)+1)}-${Rt(Math.round(this.end))}`}description(e){console.log(` ${e||\"\"} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Rt(Math.round(this.start))} end ${Rt(Math.round(this.end))} `)}overlaps(e){return this.chr===e.chr&&this.end>=e.start&&e.end>=this.start}}function yy(){return\"3.0.9\"}const Ay=\"Maximum sequence count exceeded\";class Cy{constructor(t,i){this.container=e({class:\"igv-chromosome-select-widget-container\"}),i.appendChild(this.container),this.select=document.createElement(\"select\"),this.select.setAttribute(\"name\",\"chromosome-select-widget\"),this.container.appendChild(this.select),this.select.addEventListener(\"change\",(()=>{this.select.blur(),\"\"!==this.select.value&&Ay!==this.select.value&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes,this.genome=t.genome}show(){this.container.style.display=\"flex\"}hide(){this.container.style.display=\"none\"}setValue(e){this.select.value=this.genome.getChromosomeDisplayName(e)}update(e){this.genome=e;const t=e.wgChromosomeNames.map((t=>e.getChromosomeDisplayName(t)))||[];if(this.showAllChromosomes&&e.chromosomeNames.length>1){const i=new Set(t);let n=0;for(let r of e.chromosomeNames){if(1e3==++n){t.push(Ay);break}i.has(r)||(r=e.getChromosomeDisplayName(r),t.push(r))}}this.select.innerHTML=\"\",e.showWholeGenomeView()&&t.unshift(\"all\");for(let i of t){const t=document.createElement(\"option\");t.setAttribute(\"value\",i),t.innerText=e.getChromosomeDisplayName(i),this.select.appendChild(t)}}}class _y{constructor(t,i){this.container=e({class:\"igv-windowsize-panel-container\"}),t.appendChild(this.container),i.on(\"locuschange\",(e=>{this.updatePanel(e)})),this.browser=i}show(){this.container.style.display=\"block\"}hide(){this.container.style.display=\"none\"}updatePanel(e){const t=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===e.length?Wa(Math.round(t*e[0].bpPerPixel)):\"\"}}class xy extends Ju{constructor(e,t,i,n){super(e,t,\"Select Tracks\",ef,'\\n multi select\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n multi select hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.navbar=i,this.enableMultiTrackSelection=!1,this.button.addEventListener(\"mouseenter\",(e=>{!1===n&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(e=>{!1===n&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{this.setMultiTrackSelection(!this.enableMultiTrackSelection)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler)}setMultiTrackSelection(e){this.enableMultiTrackSelection=e,this.setState(this.enableMultiTrackSelection),!1===this.enableMultiTrackSelection&&this.navbar.overlayTrackButton.setVisibility(!1);for(const t of this.browser.trackViews)t.enableTrackSelection(e)}}class ky{constructor(t,i){this.browser=i,this.columnContainer=t,this.horizontalGuide=e({class:\"igv-cursor-guide-horizontal\"}),t.appendChild(this.horizontalGuide),this.verticalGuide=e({class:\"igv-cursor-guide-vertical\"}),t.appendChild(this.verticalGuide),this.addMouseHandler(i),this.setVisibility(i.config.showCursorGuide)}addMouseHandler(e){this.boundMouseMoveHandler=function(t){t.target.tagName;const{x:i,y:n}=a(t,this.columnContainer);if(this.horizontalGuide.style.top=`${n}px`,\"CANVAS\"===t.target.tagName){const n=function(e,t){for(;e.parentElement;){if(e.parentElement.classList.contains(t))return e.parentElement;e=e.parentElement}return}(t.target,\"igv-viewport\");if(n&&e.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const r=e.root.querySelectorAll(\".igv-column\");let s;const o=n.parentElement;for(let e=0;e\\n cursor\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n cursor hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.doShowCursorGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCursorGuide&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCursorGuide&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCursorGuide=!t.doShowCursorGuide,t.setCursorGuideVisibility(t.doShowCursorGuide),this.setState(t.doShowCursorGuide)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCursorTrackingGuideButton)}}class Sy extends Ju{constructor(e,t){super(e,t,\"Center Line\",ef,'\\n centerline\\n \\n \\n \\n \\n \\n \\n','\\n centerline hover\\n \\n \\n \\n \\n \\n \\n',t.config.showCenterGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCenterLine&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCenterLine&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCenterLine=!t.doShowCenterLine,t.setCenterLineVisibility(t.doShowCenterLine),this.setState(t.doShowCenterLine)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCenterGuideButton)}}class Ey extends Ju{constructor(e,t){super(e,t,\"Track Labels\",ef,'\\n track labels\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n track labels hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showTrackLabels),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowTrackLabels&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowTrackLabels&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowTrackLabels=!t.doShowTrackLabels,t.setTrackLabelVisibility(t.doShowTrackLabels),this.setState(t.doShowTrackLabels)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showTrackLabelButton)}}class Ny extends Ju{constructor(e,t){super(e,t,[\"ROI\",\"Regions of Interest Table\"],ef,'\\n roi\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n','\\n roi hover\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowROITable&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowROITable&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>this.buttonHandler(!t.doShowROITable))),this.setVisibility(!1)}buttonHandler(e){this.setState(e),this.browser.setROITableVisibility(e)}}class By extends Ju{constructor(e,t){super(e,t,\"Sample Info\",ef,'\\n sample info\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample info hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.showSampleInfo=!1,this.button.addEventListener(\"mouseenter\",(()=>{!1===this.showSampleInfo&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===this.showSampleInfo&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)}))}performClickWithState(e,t){this.showSampleInfo=void 0===t?!this.showSampleInfo:t;e.columnContainer.querySelector(\".igv-sample-info-column\").style.display=!1===this.showSampleInfo?\"none\":\"flex\",this.setState(this.showSampleInfo),e.layoutChange()}setButtonVisibility(e){this.showSampleInfo=e,this.setState(this.showSampleInfo),!0===this.showSampleInfo?this.show():this.hide()}}class My extends Ju{constructor(e,t){super(e,t,\"Sample Names\",'\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names hover\\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showSampleNames),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.showSampleNames&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.showSampleNames&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)})),!0===t.config.showSampleNameButton?this.show():this.hide()}performClickWithState(e,t){e.showSampleNames=void 0===t?!e.showSampleNames:t;e.columnContainer.querySelector(\".igv-sample-name-column\").style.display=!1===e.showSampleNames?\"none\":\"flex\",this.setState(e.showSampleNames),e.layoutChange()}}class Ry{constructor(t,i){this.parent=t,this.popover=e({class:\"igv-ui-dropdown\"}),t.appendChild(this.popover),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\",this.shim=i}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";let{x:t,y:i}=a(e,this.parent);this.popover.style.left=`${t+this.shim.left}px`,this.popover.style.top=`${i+this.shim.top}px`}_present(e){this.popover.style.display=\"block\";let{x:t,y:i,width:n}=a(e,this.parent);t+=this.shim.left,i+=this.shim.top,this.popover.style.top=`${i}px`;const{width:r}=this.popover.getBoundingClientRect(),s=t+r,o=s-n;this.popover.style.left=`${s>n?t-o:t}px`}dismiss(){this.popover.style.display=\"none\"}}class Dy extends Ju{constructor(e,t){super(e,t,\"Save Image\",ef,'\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>{for(const e of this.button.querySelectorAll(\"div\"))if(\"block\"===e.style.display)return;this.setState(!1)})),this.dropdown=new Ry(this.button.parentNode,{top:24,left:-88});const i=[{label:\"Save as SVG\",click:e=>{this.browser.saveSVGtoFile(\"igvjs.svg\"),this.dropdown.dismiss()}},{label:\"Save as PNG\",click:e=>{this.browser.savePNGtoFile(\"igvjs.png\"),this.dropdown.dismiss()}}];this.dropdown.configure(i),this.button.addEventListener(\"click\",(e=>{let t;if(e.target===this.button)t=!0;else if(e.target.closest(\"svg\")){e.target.closest(\"div\")===this.button&&(t=!0)}!0===t&&(\"none\"===this.dropdown.popover.style.display?this.dropdown.present(e):this.dropdown.dismiss())})),this.setVisibility(t.config.showSVGButton)}navbarResizeHandler(e){this.dropdown.dismiss(),super.navbarResizeHandler(e)}}const Ty=function(t,i,n){const r=e({class:\"igv-navbar-button\"});t.append(r),r.textContent=n.label,r.addEventListener(\"click\",(()=>n.callback(i)))};let Ly=23,zy=0;class Hy{constructor(t,i,n){this.browser=i,this.zoomContainer=e({class:\"igv-zoom-widget\"}),n.appendChild(this.zoomContainer),this.zoomOutButton=e(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(l(\"minus-circle\")),this.zoomOutButton.addEventListener(\"click\",(()=>{i.zoomOut()}));const r=e();this.zoomContainer.appendChild(r),this.slider=document.createElement(\"input\"),this.slider.type=\"range\",this.slider.min=\"0\",this.slider.max=`${Ly}`,r.appendChild(this.slider),this.slider.addEventListener(\"change\",(e=>{e.preventDefault(),e.stopPropagation();const t=i.referenceFrameList[0],{bpLength:n}=t.genome.getChromosome(t.chr),{end:r,start:s}=t,o=r-s,a=n/Math.pow(2,e.target.valueAsNumber);i.zoomWithScaleFactor(a/o)})),this.zoomInButton=e(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(l(\"plus-circle\")),this.zoomInButton.addEventListener(\"click\",(()=>{i.zoomIn()})),i.on(\"locuschange\",(e=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(e))}))}update(e){if(this.slider){const t=e[0],{bpLength:i}=t.genome.getChromosome(t.chr),{start:n,end:r}=t;Ly=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${Ly}`;const s=i/(r-n);zy=Math.log2(s),this.slider.value=`${Math.round(zy)}`}}enable(){this.slider&&(this.slider.disabled=!1)}disable(){this.slider&&(this.slider.disabled=!0)}hide(){this.zoomContainer.style.display=\"none\"}show(){this.zoomContainer.style.display=\"block\"}hideSlider(){this.slider&&(this.slider.style.display=\"none\")}showSlider(){this.slider&&(this.slider.style.display=\"block\")}}class Py{constructor(t,i){this.browser=i,this.config=t,this.currentClass=\"igv-navbar-text-button\";const n=Bt(\"
\",{class:\"igv-navbar\"});this.$navigation=n;const r=Bt(\"
\",{class:\"igv-navbar-left-container\"});n.append(r),this.navbarLeftContainer=r.get(0);const s=Bt(\"
\",{class:\"igv-logo\"});r.append(s);const o=Bt('IGV; ');o.css(\"width\",\"34px\"),o.css(\"height\",\"32px\"),s.append(o),this.$current_genome=Bt(\"
\",{class:\"igv-current-genome\"}),r.append(this.$current_genome),this.$current_genome.text(\"\");const a=Bt(\"
\",{class:\"igv-navbar-genomic-location\"});r.append(a),this.chromosomeSelectWidget=new Cy(i,a.get(0)),!1!==t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const c=Bt(\"
\",{class:\"igv-locus-size-group\"});a.append(c);const h=Bt(\"
\",{class:\"igv-search-container\"});c.append(h),this.$searchInput=Bt(\"\",{class:\"igv-search-input\",type:\"text\",placeholder:\"Locus Search\"}),h.append(this.$searchInput),this.$searchInput[0].addEventListener(\"keyup\",(e=>{e.stopImmediatePropagation()})),this.$searchInput.change((()=>i.doSearch(this.$searchInput.val())));const d=e({class:\"igv-search-icon-container\"});h.append(Bt(d)),d.appendChild(l(\"search\")),d.addEventListener(\"click\",(()=>i.doSearch(this.$searchInput.val()))),this.windowSizePanel=new _y(c.get(0),i);const u=Bt(\"
\",{class:\"igv-navbar-right-container\"});n.append(u),this.navbarRightContainer=u.get(0);const f=Bt('
');u.append(f);const p=f.get(0);this.toggle_button_container=p,this.overlayTrackButton=new sf(p,i),this.overlayTrackButton.setVisibility(!1);const g=!1!==t.showMultiSelectButton;if(this.multiTrackSelectButton=new xy(p,i,this,g),this.cursorGuideButton=new Iy(p,i),this.centerLineButton=new Sy(p,i),this.trackLabelControl=new Ey(p,i),this.roiTableControl=new Ny(p,i),this.sampleInfoControl=new By(p,i),this.sampleNameControl=new My(p,i),!0===t.showSVGButton&&(this.saveImageControl=new Dy(p,i)),t.customButtons)for(let e of t.customButtons)new Ty(p,i,e);this.zoomWidget=new Hy(t,i,u.get(0)),!1===t.showNavigation&&this.$navigation.hide()}navbarDidResize(){const e=this.$navigation.width(),t=this.currentNavbarButtonClass();\"igv-navbar-text-button\"===t&&(this.textButtonContainerWidth=this.navbarRightContainer.getBoundingClientRect().width);const i=this.browser,n=i.isMultiLocusWholeGenomeView()||i.referenceFrameList&&mu.isWholeGenomeView(i.referenceFrameList[0].chr);n?this.windowSizePanel.hide():this.windowSizePanel.show();const{x:r,width:s}=this.navbarLeftContainer.getBoundingClientRect(),o=r+s,{x:a}=this.navbarRightContainer.getBoundingClientRect();let c;if(\"igv-navbar-text-button\"===t&&a-o<8)c=\"igv-navbar-icon-button\";else if(this.textButtonContainerWidth&&\"igv-navbar-icon-button\"===t){e-o-this.textButtonContainerWidth>8&&(c=\"igv-navbar-text-button\")}let l;c&&t!==c&&(this.currentClass=c,this.browser.fireEvent(\"navbar-resize\",[c])),l=n?\"igv-zoom-widget-hidden\":e>860?\"igv-zoom-widget\":\"igv-zoom-widget-900\",Bt(this.zoomWidget.zoomContainer).removeClass(),Bt(this.zoomWidget.zoomContainer).addClass(l)}setCenterLineButtonVisibility(e){e?this.centerLineButton.setVisibility(!e):this.centerLineButton.setVisibility(this.config.showCenterGuideButton)}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}updateGenome(e){let t=e.id&&e.id.length<20?e.id:`${e.id.substring(0,8)}...${e.id.substring(e.id.length-8)}`;this.$current_genome.text(t),this.$current_genome.attr(\"title\",e.description);!1!==this.config.showChromosomeWidget&&!1!==e.showChromosomeWidget&&e.chromosomeNames&&e.chromosomeNames.length>1?(this.chromosomeSelectWidget.update(e),this.chromosomeSelectWidget.show()):this.chromosomeSelectWidget.hide()}updateLocus(e,t){this.$searchInput&&this.$searchInput.val(e),this.chromosomeSelectWidget&&(this.chromosomeSelectWidget.select.value=t)}currentNavbarButtonClass(){return this.currentClass}setEnableTrackSelection(e){this.multiTrackSelectButton.setMultiTrackSelection(e)}getEnableTrackSelection(){return this.multiTrackSelectButton.enableMultiTrackSelection}hide(){this.$navigation.hide()}show(){this.$navigation.show()}}const Oy=(e,t)=>{const i=0===e?t.nextElementSibling:t.previousElementSibling;t.remove(),i.remove()},Uy=t=>{const i=e({class:\"igv-column-shim\"});Ya(i,t);const n=e({class:\"igv-column\"});return Ya(n,i),n},qy=(t,i)=>{for(let n=0;n1&&n>0){Ka(e({class:\"igv-column-shim\"}),r)}}};class Qy{constructor(t,i,n){this.browser=t,this.referenceFrame=i,this.column=n,this.container=e({class:\"igv-center-line\"}),n.appendChild(this.container),t.doShowCenterLine?this.show():this.hide()}repaint(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const e=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${e}px`,this.container.classList.remove(\"igv-center-line-thin\"),this.container.classList.add(\"igv-center-line-wide\")}else this.container.style.width=\"1px\",this.container.classList.remove(\"igv-center-line-wide\"),this.container.classList.add(\"igv-center-line-thin\")}}show(){this.isVisible=!0,this.container.style.display=\"block\",this.repaint()}hide(){this.isVisible=!1,this.container.style.display=\"none\"}resize(){this.repaint()}}const Vy=function(t,i){this.button=e({class:\"igv-navbar-button\"}),t.appendChild(this.button),this.button.textContent=\"circular view\",this.button.addEventListener(\"click\",(()=>{i.circularViewVisible=!i.circularViewVisible})),this.browser=i,this.setVisibility(i.config.showCircularViewButton),this.setState(i.circularViewVisible)};Vy.prototype.setVisibility=function(e){!0===e?this.show():this.hide()},Vy.prototype.setState=function(e){!0===e?this.button.classList.add(\"igv-navbar-button-clicked\"):this.button.classList.remove(\"igv-navbar-button-clicked\")},Vy.prototype.show=function(){this.button.style.display=\"block\",this.setState(this.browser.circularViewVisible)},Vy.prototype.hide=function(){this.button.style.display=\"none\"};class jy{constructor(t,i){this.browser=t,this.container=e({class:\"igv-roi-menu\"}),i.appendChild(this.container);const n=e();this.container.appendChild(n),u(n,(()=>this.container.style.display=\"none\")),this.body=e(),this.container.appendChild(this.body),this.container.style.display=\"none\"}async present(e,t,i,n,r,s){const o=this.menuItems(e,t,i,n,r,s);this.browser.menuPopup.presentTrackContextMenu(i,o)}menuItems(e,t,i,n,r,s){const o=e.name?[`${e.name}
`]:[];return\"name\"in t&&o.push(`ROI Set: ${t.name}`),o.length>0&&o.push(\"
\"),t.isUserDefined&&o.push({label:\"Set description ...\",click:()=>{const t={label:\"Description\",value:e.name||\"\",callback:()=>{const t=this.browser.inputDialog.value||\"\";e.name=t.trim(),this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(t,i)}}),Xa()&&e.end-e.start<1e6&&o.push({label:\"Copy reference sequence\",click:async()=>{this.container.style.display=\"none\";let t=await this.browser.genome.getSequence(e.chr,e.start,e.end);t||(t=\"Unknown sequence\");try{await navigator.clipboard.writeText(t)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.end-e.start<=25e3&&o.push({label:\"BLAT reference sequence\",click:async()=>{this.container.style.display=\"none\";const{chr:t,start:i,end:n}=e;let r=await this.browser.genome.getSequence(t,i,n);if(r){const e=`blat: ${t}:${i+1}-${n}`,s=`blat: ${t}:${i+1}-${n}`;jd({sequence:r,browser:this.browser,name:e,title:s})}}}),t.isUserDefined&&o.push(\"
\",{label:\"Delete\",click:async()=>{t.removeFeature(e);const i=await t.getAllFeatures();0===Object.keys(i).length&&n.deleteUserDefinedROISet(),n.deleteRegionWithKey(s.dataset.region,r),n.repaintTable()}}),o}dispose(){this.container.innerHTML=\"\"}}class Wy extends Pd{constructor(e){const t={browser:e,parent:e.columnContainer,headerTitle:\"Regions of Interest\",dismissHandler:()=>e.roiTableControl.buttonHandler(!1),gotoButtonHandler:Wy.gotoButtonHandler};t.columnFormat=Wy.getColumnFormatConfiguration(!0),super(Object.assign({width:\"640px\"},t))}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),{setName:n,feature:r}=t;i.dataset.region=Xy(r.chr,r.start,r.end);let s=[r.chr,Rt(r.start),Rt(r.end),r.name||\"\",n];4===this.columnFormat.length&&(s=s.slice(0,4));for(let t=0;te.remove())),e.length>0){const t=e.sort(((e,t)=>e.feature.chr.localeCompare(t.feature.chr)||e.feature.start-t.feature.start||e.feature.end-t.feature.end));for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}}set footerDOM(t){super.footerDOM=t,this.gotoButton.textContent=\"Go to selected region(s)\";const i=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(i),i.id=\"igv-roi-hide-show-button\",i.textContent=\"Copy Sequence\",i.title=\"One region only of max size 1 mb\",this.copySequenceButton=i,Gy(this.copySequenceButton,!1),this.boundCopySequenceButtonHandler=async function(e){e.preventDefault(),e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\");if(t.length>0){const e=[];for(let i of t){const{locus:t}=Jy(i.dataset.region);e.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");if(this.setTableRowSelectionState(!1),e.length>0){const{chr:t,start:i,end:n}=ey(e[0],this.browser.isSoftclipped()),r=await this.browser.genome.getSequence(t,i,n);await navigator.clipboard.writeText(r)}}}.bind(this),this.copySequenceButton.addEventListener(\"click\",this.boundCopySequenceButtonHandler);const n=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(n),n.id=\"igv-roi-hide-show-button\",n.textContent=\"Hide all ROIs\",this.toggleROIButton=n,this.boundToggleDisplayButtonHandler=function(e){e.preventDefault(),e.stopPropagation(),this.browser.roiManager.toggleROIs()}.bind(this),this.toggleROIButton.addEventListener(\"click\",this.boundToggleDisplayButtonHandler)}setROIVisibility(e){const t=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let i=0;i0&&t.length<2){const{locus:e}=Jy(t[0].dataset.region),{chr:i,start:n,end:r}=ey(e,this.browser.isSoftclipped());Gy(this.copySequenceButton,r-n<1e6)}else Gy(this.copySequenceButton,!1)}dispose(){document.removeEventListener(\"click\",this.boundGotoButtonHandler),document.removeEventListener(\"click\",this.boundCopySequenceButtonHandler),document.removeEventListener(\"click\",this.boundToggleDisplayButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(e){return!0===e?[{label:\"Chr\",width:\"20%\"},{label:\"Start\",width:\"15%\"},{label:\"End\",width:\"15%\"},{label:\"Description\",width:\"30%\"},{label:\"ROI Set\",width:\"20%\"}]:[{label:\"Chr\",width:\"25%\"},{label:\"Start\",width:\"20%\"},{label:\"End\",width:\"20%\"},{label:\"Description\",width:\"35%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(let e of t){const{locus:t}=Jy(e.dataset.region);i.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(\" \"))}}function Gy(e,t){e.style.pointerEvents=t?\"auto\":\"none\",e.style.color=ro(t?\"licorice\":\"silver\"),e.style.borderColor=ro(t?\"licorice\":\"silver\")}function $y(e,t){const i=window.getComputedStyle(e).backgroundColor.match(/[\\d.]+/g);3===i.length&&i.push(1),i[3]=t,e.style.backgroundColor=`rgba(${i.join(\", \")})`}class Ky{constructor(e){this.browser=e,this.roiMenu=new jy(e,e.columnContainer),this.roiTable=new Wy(e,e.columnContainer),this.top=0,this.roiSets=[],this.boundLocusChangeHandler=Yy.bind(this),e.on(\"locuschange\",this.boundLocusChangeHandler);this.observer=new MutationObserver((()=>{const t=e.findTracks((e=>new Set([\"ideogram\",\"ruler\"]).has(e.type))),[i,n]=t.map((e=>e.trackView.viewports[0].$viewport.get(0))).map((e=>function(e){const t=window.getComputedStyle(e),i=parseInt(t.marginTop),n=parseInt(t.marginBottom),{top:r,bottom:s,height:o}=e.getBoundingClientRect();return{top:Math.floor(r)-i,bottom:Math.floor(s)+n,height:Math.floor(o)+i+n}}(e))),r=i?i.height:0,s=n?n.height:0,o=e.columnContainer.querySelectorAll(\".igv-roi-region\");if(o)for(const e of o)e.style.marginTop=`${r+s+-.5}px`})),this.observer.observe(e.columnContainer,{attributes:!0,childList:!0,subtree:!0})}async reset(){this.roiSets.length>0&&this.browser.roiTableControl.setVisibility(!0);const e=this.roiSets.map((e=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})));e.length>0&&await Promise.all(e);const t=await this.getTableRecords();if(this.roiTable.renderTable(t),this.roiSets.length>0){const e=this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e)}}async loadROI(e,t){const i=Array.isArray(e)?e:[e];for(let e of i)!e.name&&e.url&&(e.name=await ja(e.url)),e.url&&!e.format&&(e.format=await am(e)),this.roiSets.push(new ku(e,t));await this.reset()}clearROIs(){this.roiTable.clearTable();const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();for(let e of this.roiSets)e.dispose();this.roiSets=[]}async getTableRecords(){const e=[];for(let t of this.roiSets){const i=t.name||\"\",n=await t.getAllFeatures();for(let t of Object.keys(n))for(let r of n[t])e.push({setName:i,feature:r})}return e}presentTable(){this.roiTable.present()}async repaintTable(){const e=await this.getTableRecords();this.roiTable.renderTable(e)}dismissTable(){this.roiTable.dismiss()}roiTableIsVisible(){return this.roiTable.isVisible()}async updateUserDefinedROISet(e){let t=await this.getUserDefinedROISet();void 0===t&&(t=this.initializeUserDefinedROISet()),t.addFeature(e),this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(e){this.browser.roiTableControl.setVisibility(e)}toggleROIs(){const e=!this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e);for(const t of this.roiSets)t.isVisible=e}async renderAllROISets(){for(let e of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})}async renderROISet({browser:e,pixelTop:t,roiSet:i}){const n=e.columnContainer.querySelectorAll(\".igv-column\");for(let r=0;ra)&&e.remove()}const h=await i.getFeatures(s,o,a);if(h)for(let l of h){const h=Xy(s,l.start,l.end),{x:d,width:u}=Iu(Math.max(o,l.start),Math.min(a,l.end),o,c),f=n[r].querySelector(Zy(h));if(f)f.style.left=`${d}px`,f.style.width=`${u}px`;else{const s=this.createRegionElement(e.columnContainer,t,d,u,i,h,l);n[r].appendChild(s)}}}}createRegionElement(t,i,n,r,s,o,c){const l=e({class:\"igv-roi-region\"});l.style.top=`${i}px`,l.style.left=`${n}px`,l.style.width=`${r}px`,l.style.backgroundColor=s.color,l.dataset.color=s.color,l.dataset.region=o;const h=e();return l.appendChild(h),h.style.backgroundColor=s.headerColor,h.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation(),a(e,t),this.roiMenu.present(c,s,e,this,t,l)})),l}renderSVGContext(e,t,{deltaX:i,deltaY:n}){for(const r of e.querySelectorAll(\".igv-roi-region\")){const{x:e,y:s,width:o,height:a}=r.getBoundingClientRect();t.fillStyle=r.style.backgroundColor,t.fillRect(e-i,s+n,o,a);const c=r.querySelector(\"div\"),{x:l,y:h,width:d,height:u}=c.getBoundingClientRect();t.fillStyle=c.style.backgroundColor,t.fillRect(l-i,h+n,d,u)}}getUserDefinedROISet(){return this.roiSets.find((e=>!0===e.isUserDefined))}deleteUserDefinedROISet(){this.roiSets=this.roiSets.filter((e=>!0!==e.isUserDefined))}initializeUserDefinedROISet(){const e=new ku({name:\"user defined\",isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(e),e}async deleteRegionWithKey(e,t){t.querySelectorAll(Zy(e)).forEach((e=>e.remove()));0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}toJSON(){return this.roiSets.map((e=>e.toJSON()))}dispose(){this.browser.off(\"locuschange\",this.boundLocusChangeHandler);const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let e of this.roiSets)e.dispose();for(let e of Object.keys(this))this[e]=void 0}}function Yy(){this.renderAllROISets()}function Xy(e,t,i){return`${e}-${t}-${i}`}function Zy(e){return`[data-region=\"${e}\"]`}function Jy(e){let t=e.split(\"-\"),i=parseInt(t.pop()),n=parseInt(t.pop()),r=t.join(\"-\");return{chr:r,start:n,end:i,locus:`${r}:${n}-${i}`,bedRecord:`${r}\\t${n}\\t${i}`}}class eA{constructor(e,t){this.name=e.name,this.featureSource=e.featureSource||Ad(e,t),this.color=e.color||_u}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}draw(e){const{context:t,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=e;if(!a)return;const c=n+o*i+1;for(let{start:e,end:o}of a){if(oc)break;const{x:a,width:l}=Iu(e,o,n,i);xo.fillRect(t,a,r,l,s,{fillStyle:this.color})}}}class tA{aliasRecordCache=new Map;constructor(e,t,i){(t=t||{}).url=e,this.reader=new Zh(t,i)}async preload(e){await this.reader.preload();for(let t of e)await this.search(t)}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async search(e){if(!this.aliasRecordCache.has(e)){const t=await this.reader.search(e);if(t)for(let e of Object.keys(t))\"start\"!==e&&\"end\"!==e&&this.aliasRecordCache.set(t[e],t)}return this.aliasRecordCache.get(e)}async getChromosomeNames(){return await this.reader.loadHeader(),Array.from(this.reader.chrNames)}}class iA{aliasRecordCache=new Map;constructor(e,t,i){this.aliasURL=e,this.config=t,this.genome=i}async preload(){return this.loadAliases()}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async loadAliases(){const e=await Qs.loadString(this.aliasURL,Ua(this.config)),t=Dt(e),i=t[0];i.startsWith(\"#\")&&(this.headings=i.substring(1).split(\"\\t\").map((e=>e.trim())),this.altNameSets=this.headings.slice(1));const n=this.genome.chromosomeNames?new Set(this.genome.chromosomeNames):new Set;for(let e of t)if(!e.startsWith(\"#\")&&e.length>0){const t=e.split(\"\\t\");let i=t.find((e=>n.has(e)));i||(i=t[0]);const r={chr:i};for(let e=0;enew nA(e.start,e.end,e.name,e.gieStain)))}}class sA{cytobands=new Map;constructor(e,t){this.url=e,this.config=t}async getCytobands(e){return 0===this.cytobands.size&&await this.#I(),this.cytobands.get(e)}async#I(){let e,t;if(Ga(this.url)){const t=vs(this.url);e=\"\";const i=t.length;for(let n=0;n0){const e=e.substring(0,t);r[\"ncbi-gi\"]=e}}else{if(e.startsWith(\"hg\")||e.startsWith(\"GRCh\")||\"1kg_ref\"===e||\"b37\"===e)switch(n){case\"23\":r.ucsc=\"chrX\",t=!0;break;case\"24\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"23\",t=!0;break;case\"chrY\":r.ncbi=\"24\",t=!0}else if(e.startsWith(\"mm\")||e.startsWith(\"GRCm\")||e.startsWith(\"rheMac\"))switch(n){case\"21\":r.ucsc=\"chrX\",t=!0;break;case\"22\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"21\",t=!0;break;case\"chrY\":r.ncbi=\"22\",t=!0}if(t)continue;\"chrM\"===n?r.ncbi=\"MT\":\"MT\"===n?r.ucsc=\"chrM\":n.toLowerCase().startsWith(\"chr\")?r.ncbi=n.substring(3):Number.isInteger(Number(n))&&(r.ucsc=\"chr\"+n)}}for(let e of i){for(let t of Object.values(e))this.aliasRecordCache.set(t,e);this.aliasRecordCache.set(e.chr.toLowerCase(),e),this.aliasRecordCache.set(e.chr.toUpperCase(),e)}}}search(e){return this.aliasRecordCache.get(e)}static getNCBIName(e){const t=e.split(\"\\\\|\");return t[t.length-1]}}class aA{#S;static async createGenome(e,t){const i=new aA(e,t);return await i.init(),i}constructor(e,t){this.config=e,this.browser=t,this.id=e.id||function(e){return void 0!==e.id?e.id:e.fastaURL&&Mt(e.fastaURL)&&!e.fastaURL.startsWith(\"data:\")?e.fastaURL:e.fastaURL&&e.fastaURL.name?e.fastaURL.name:\"\"}(e),this.name=e.name,this.nameSet=e.nameSet}async init(){const e=this.config;if(this.sequence=await Nc(e,this.browser),e.chromSizesURL?this.chromosomes=await async function(e){const t=new Map;let i;if(Ga(e)){let t=vs(e);i=\"\";for(let e of t)i+=String.fromCharCode(e)}else i=await Qs.load(e,{});const n=Fc(i);let r=0;for(let e of n){const i=e.split(\"\\t\");if(i.length>1){const e=Number.parseInt(i[1]);t.set(i[0],new lc(i[0],r++,e))}}return t}(e.chromSizesURL):this.chromosomes=this.sequence.chromosomes||new Map,this.chromosomes.size>0&&(this.chromosomeNames=Array.from(this.chromosomes.keys())),e.chromAliasBbURL?(this.chromAlias=new tA(e.chromAliasBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.chromAlias.getChromosomeNames())):e.aliasURL?this.chromAlias=new iA(e.aliasURL,Object.assign({},e),this):this.chromosomeNames&&(this.chromAlias=new oA(this.id,this.chromosomeNames)),e.cytobandBbURL)this.cytobandSource=new rA(e.cytobandBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames());else if(e.cytobandURL&&(this.cytobandSource=new sA(e.cytobandURL,Object.assign({},e)),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames()),0===this.chromosomes.size)){const e=await this.cytobandSource.getChromosomes();for(let t of e)this.chromosomes.set(e.name,e)}if(!1!==e.wholeGenomeView&&this.chromosomes.size>0&&(e.chromosomeOrder?Array.isArray(e.chromosomeOrder)?this.#S=e.chromosomeOrder:this.#S=e.chromosomeOrder.split(\",\").map((e=>e.trim())):this.#S=function(e){const t=[];let i,n=1;for(let r of e.values()){if(i){if(r.bpLength1,this.wholeGenomeView){const e=this.#S.reduce(((e,t)=>e+this.chromosomes.get(t).bpLength),0);this.chromosomes.set(\"all\",new lc(\"all\",0,e))}}get description(){return this.config.description||`${this.id}\\n${this.name}`}get infoURL(){return this.config.infoURL}showWholeGenomeView(){return this.wholeGenomeView}toJSON(){return Object.assign({},this.config,{tracks:void 0})}get initialLocus(){return this.config.locus?this.config.locus:this.getHomeChromosomeName()}getHomeChromosomeName(){return this.showWholeGenomeView()&&this.chromosomes.has(\"all\")?\"all\":this.chromosomeNames[0]}getChromosomeName(e){return this.chromAlias?this.chromAlias.getChromosomeName(e,this.chromosomes.keys()):e}getChromosomeDisplayName(e){return this.nameSet&&this.chromAlias&&this.chromAlias.getChromosomeAlias(e,this.nameSet)||e}getChromosome(e){return this.chromAlias&&(e=this.chromAlias.getChromosomeName(e)),this.chromosomes.get(e)}async loadChromosome(e){if(this.chromAlias){const t=await this.chromAlias.search(e);t&&(e=t.chr)}if(!this.chromosomes.has(e)){let t;const i=await this.sequence.getSequenceRecord(e);i&&(t=new lc(e,0,i.bpLength)),this.chromosomes.set(e,t)}return this.chromosomes.get(e)}async getAliasRecord(e){if(this.chromAlias)return this.chromAlias.search(e)}async getCytobands(e){if(this.cytobandSource){const t=this.getChromosomeName(e);return await this.cytobandSource.getCytobands(t)}}getChromosomes(){return this.chromosomes}get wgChromosomeNames(){return this.#S?this.#S.slice():void 0}get showChromosomeWidget(){return this.config.showChromosomeWidget}getGenomeCoordinate(e,t){var i=this.getCumulativeOffset(e);if(void 0!==i)return i+t}getChromosomeCoordinate(e){let t;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.#S){const r=this.cumulativeOffsets[n];if(r>e){return{chr:t,position:e-i}}t=n,i=r}return{chr:this.#S[this.#S.length-1],position:0}}getCumulativeOffset(e){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let e={},t=0;for(let i of this.#S){e[i]=Math.floor(t);t+=this.getChromosome(i).bpLength}return e}.call(this));const t=this.getChromosomeName(e);return this.cumulativeOffsets[t]}getGenomeLength(){if(!this.bpLength){let e=0;for(let t of this.#S){e+=this.chromosomes.get(t).bpLength}this.bpLength=e}return this.bpLength}async getSequence(e,t,i){return e=this.getChromosomeName(e),this.sequence.getSequence(e,t,i)}getSequenceInterval(e,t,i){return\"function\"==typeof this.sequence.getSequenceInterval?this.sequence.getSequenceInterval(e,t,i):void 0}}class cA{constructor(){this.clear()}clear(){this.phenotypeColors=new Map,this.snps=new Set,this.qtl=null}isEmpty(){return 0===this.phenotypeColors.size&&0===this.snps.size&&null===this.qtl}addSnp(e){e=e.toUpperCase(),this.snps.add(e)}addPhenotype(e){e=e.toUpperCase();const t=this.phenotypeColors.size;if(!this.phenotypeColors.has(e.toUpperCase())){const i=t0&&(e.phenotypes=Array.from(this.phenotypeColors.keys())),this.snps.size>0&&(e.snps=Array.from(this.snps)),this.qtl&&(e.qtl=this.qtl),e}static fromJSON(e){const t=new cA;if(e.phenotypes)for(let i of e.phenotypes)t.addPhenotype(i);if(e.snps)for(let i of e.snps)t.addSnp(i);return e.qtl&&(t.qtl=e.qtl),t}}const lA=[];lA.push(\"rgb(228,26,28)\"),lA.push(\"rgb(55,126,184)\"),lA.push(\"rgb(77,175,74)\"),lA.push(\"rgb(166,86,40)\"),lA.push(\"rgb(152,78,163)\"),lA.push(\"rgb(255,127,0)\"),lA.push(\"rgb(247,129,191)\"),lA.push(\"rgb(255,255,51)\"),lA.push(\"rgb(102,194,165)\"),lA.push(\"rgb(252,141,98)\"),lA.push(\"rgb(141, 160, 203)\"),lA.push(\"rgb(231, 138, 195)\"),lA.push(\"rgb(166, 216, 84)\"),lA.push(\"rgb(255, 217, 47)\"),lA.push(\"rgb(229, 196, 148)\"),lA.push(\"rgb( 141, 211, 199)\"),lA.push(\"rgb(255, 255, 179)\"),lA.push(\"rgb(190, 186, 218)\"),lA.push(\"rgb(251, 128, 114)\"),lA.push(\"rgb(128, 177, 211)\"),lA.push(\"rgb(253, 180, 98)\"),lA.push(\"rgb(179, 222, 105)\"),lA.push(\"rgb(252, 205, 229)\"),lA.push(\"rgb(188, 128, 189)\"),lA.push(\"rgb(204, 235, 197)\"),lA.push(\"rgb(255, 237, 111)\");class hA{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container);let r='';this._input=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._input),r='',this._output=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._output);const s=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(s),this.ok=e(),s.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),s.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"input\",(()=>{const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this._output.value=`${e.toFixed(2)}`}),!1),this.ok.addEventListener(\"click\",(()=>{if(\"function\"==typeof this.callback){const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this.callback=void 0}this._input.value=void 0,i(this.container)}));const o=()=>{this._input.value=void 0,i(this.container)};this.cancel.addEventListener(\"click\",o),u(n,o),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._scaleFactor=e.scaleFactor;const[i,r,s]=[e.min,e.max,e.value].map((e=>Math.floor(this._scaleFactor*e).toString()));this._input.min=i,this._input.max=r,this._input.value=s;const o=parseFloat(s)/this._scaleFactor;this._output.value=`${o.toFixed(2)}`,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}class dA{qtlSelections=new cA;constructor(t,i){this.config=t,this.guid=s(),this.namespace=\".browser_\"+this.guid,this.parent=i;let n=i.shadowRoot;if(!n){n=i.attachShadow({mode:\"open\"});const e=new CSSStyleSheet;e.replaceSync('.igv-ui-dropdown {\\n cursor: default;\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div {\\n overflow-y: auto;\\n overflow-x: hidden;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div {\\n padding: 4px;\\n width: 100%;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: 1px;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div:last-child {\\n border-bottom-color: transparent;\\n border-bottom-width: 0;\\n}\\n.igv-ui-dropdown > div > div:hover {\\n cursor: pointer;\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n\\n.igv-ui-popover {\\n cursor: default;\\n position: absolute;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n background-color: white;\\n}\\n.igv-ui-popover > div:first-child {\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-width: 0;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-popover > div:first-child > div:first-child {\\n margin-left: 4px;\\n}\\n.igv-ui-popover > div:first-child > div:last-child {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-popover > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-popover > div:last-child {\\n user-select: text;\\n overflow-y: auto;\\n overflow-x: hidden;\\n max-height: 400px;\\n max-width: 800px;\\n background-color: white;\\n border-bottom-width: 0;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-ui-popover > div:last-child > div {\\n margin-left: 4px;\\n margin-right: 4px;\\n min-width: 220px;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n.igv-ui-popover > div:last-child > div > span {\\n font-weight: bolder;\\n}\\n.igv-ui-popover > div:last-child hr {\\n width: 100%;\\n}\\n\\n.igv-ui-alert-dialog-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n top: 50%;\\n left: 50%;\\n width: 400px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n outline: none;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 15px;\\n font-weight: 400;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:first-child {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\\n padding-left: 8px;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\\n -webkit-user-select: text;\\n -moz-user-select: text;\\n -ms-user-select: text;\\n user-select: text;\\n color: #373737;\\n width: 100%;\\n height: calc(100% - 24px - 64px);\\n overflow-y: scroll;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\\n margin: 16px;\\n width: auto;\\n height: auto;\\n overflow-wrap: break-word;\\n word-break: break-word;\\n background-color: white;\\n border: unset;\\n}\\n.igv-ui-alert-dialog-container > div:last-child {\\n width: 100%;\\n margin-bottom: 10px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div {\\n margin: unset;\\n width: 40px;\\n height: 30px;\\n line-height: 30px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n border-color: #2B81AF;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div:hover {\\n cursor: pointer;\\n border-color: #25597f;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-color-swatch {\\n position: relative;\\n box-sizing: content-box;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: wrap;\\n justify-content: center;\\n align-items: center;\\n width: 32px;\\n height: 32px;\\n border-style: solid;\\n border-width: 2px;\\n border-color: white;\\n border-radius: 4px;\\n}\\n\\n.igv-ui-color-swatch:hover {\\n border-color: dimgray;\\n}\\n\\n.igv-ui-colorpicker-menu-close-button {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 32px;\\n margin-top: 4px;\\n margin-bottom: 4px;\\n padding-right: 8px;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa {\\n display: block;\\n margin-left: 4px;\\n margin-right: 4px;\\n color: #5f5f5f;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\\n.igv-ui-colorpicker-menu-close-button i.fa:active {\\n cursor: pointer;\\n color: #0f0f0f;\\n}\\n\\n.igv-ui-generic-dialog-container {\\n box-sizing: content-box;\\n position: fixed;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: fit-content;\\n padding-bottom: 16px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input > div {\\n width: fit-content;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input[type=range] {\\n width: 70%;\\n -webkit-appearance: none;\\n background: linear-gradient(90deg, white, black);\\n outline: none;\\n margin: 0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input output {\\n display: block;\\n height: 100%;\\n width: 20%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n padding-top: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div {\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n\\n.igv-ui-generic-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-container > div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-ui-generic-container > div:first-child > div {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-ui-dialog {\\n z-index: 2048;\\n position: fixed;\\n width: fit-content;\\n height: fit-content;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n background-color: white;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-dialog .igv-ui-dialog-one-liner {\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n font-weight: bold;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\\n width: 100%;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\\n margin: 16px;\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\\n background-color: #5ea4e0;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\\n background-color: #c4c4c4;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\\n z-index: 2048;\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-panel-column {\\n display: flex;\\n flex-direction: column;\\n}\\n\\n.igv-ui-panel-row {\\n display: flex;\\n flex-direction: row;\\n}\\n\\n.igv-ui-textbox {\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-table {\\n background-color: white;\\n}\\n\\n.igv-ui-table thead {\\n position: sticky;\\n top: 0;\\n}\\n\\n.igv-ui-table th {\\n text-align: left;\\n}\\n\\n.igv-ui-table td {\\n padding-right: 20px;\\n}\\n\\n.igv-ui-table tr:hover {\\n background-color: lightblue;\\n}\\n\\n.igv-ui-center-fixed {\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.igv-navbar {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n box-sizing: border-box;\\n width: 100%;\\n color: #444;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n line-height: 32px;\\n padding-left: 8px;\\n padding-right: 8px;\\n margin-top: 2px;\\n margin-bottom: 6px;\\n height: 32px;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: #f3f3f3;\\n}\\n.igv-navbar .igv-navbar-left-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 32px;\\n line-height: 32px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-logo {\\n width: 34px;\\n height: 32px;\\n margin-right: 8px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\\n height: 32px;\\n margin-left: 4px;\\n margin-right: 4px;\\n user-select: none;\\n line-height: 32px;\\n vertical-align: middle;\\n text-align: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n height: 100%;\\n width: 125px;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\\n display: block;\\n cursor: pointer;\\n width: 100px;\\n height: 75%;\\n outline: none;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n margin-left: 8px;\\n height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 240px;\\n height: 22px;\\n line-height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\\n cursor: text;\\n width: 85%;\\n height: 22px;\\n line-height: 22px;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n text-align: left;\\n padding-left: 8px;\\n margin-right: 8px;\\n outline: none;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: white;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\\n cursor: pointer;\\n height: 16px;\\n width: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\\n margin-left: 4px;\\n user-select: none;\\n}\\n.igv-navbar .igv-navbar-right-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\\n position: relative;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-hidden {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\\n color: #737373;\\n font-size: 18px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\\n display: block;\\n height: fit-content;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\\n display: block;\\n width: 125px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\\n color: #737373;\\n font-size: 18px;\\n height: 32px;\\n line-height: 32px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\\n display: none;\\n}\\n\\n.igv-navbar-button {\\n display: block;\\n box-sizing: unset;\\n padding-left: 6px;\\n padding-right: 6px;\\n height: 18px;\\n text-transform: capitalize;\\n user-select: none;\\n line-height: 18px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 11px;\\n font-weight: 200;\\n color: #737373;\\n background-color: #f3f3f3;\\n border-color: #737373;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 6px;\\n}\\n\\n.igv-navbar-button:hover {\\n cursor: pointer;\\n}\\n\\n.igv-navbar-button-clicked {\\n color: white;\\n background-color: #737373;\\n}\\n\\n.igv-navbar-icon-button {\\n cursor: pointer;\\n position: relative;\\n width: 24px;\\n height: 24px;\\n margin-left: 4px;\\n margin-right: 4px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:first-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: -18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:last-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n.igv-navbar-text-button {\\n cursor: pointer;\\n position: relative;\\n margin-left: 2px;\\n margin-right: 2px;\\n border: none;\\n display: flex;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar-text-button > div:nth-child(2) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 0;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-text-button > div:nth-child(3) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 42px;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n#igv-text-button-label {\\n text-anchor: middle;\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-inactive rect {\\n stroke: #737373;\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-inactive text {\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-inactive tspan {\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-hover text {\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-hover tspan {\\n dominant-baseline: middle;\\n}\\n\\n#igv-save-svg-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-svg-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-svg-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-svg-group:hover text {\\n fill: white;\\n}\\n\\n#igv-save-png-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-png-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-png-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-png-group:hover text {\\n fill: white;\\n}\\n\\n.igv-zoom-in-notice-container {\\n z-index: 256;\\n position: absolute;\\n top: 8px;\\n left: 50%;\\n transform: translate(-50%, 0%);\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n background-color: white;\\n}\\n.igv-zoom-in-notice-container > div {\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-top: 2px;\\n padding-bottom: 2px;\\n width: 100%;\\n height: 100%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: #3f3f3f;\\n}\\n\\n.igv-zoom-in-notice {\\n position: absolute;\\n top: 10px;\\n left: 50%;\\n}\\n.igv-zoom-in-notice div {\\n position: relative;\\n left: -50%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #3f3f3f;\\n background-color: rgba(255, 255, 255, 0.51);\\n z-index: 64;\\n}\\n\\n.igv-container-spinner {\\n position: absolute;\\n top: 90%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n z-index: 1024;\\n width: 24px;\\n height: 24px;\\n pointer-events: none;\\n color: #737373;\\n}\\n\\n.igv-multi-locus-close-button {\\n position: absolute;\\n top: 2px;\\n right: 0;\\n padding-left: 2px;\\n padding-right: 2px;\\n width: 12px;\\n height: 12px;\\n color: #666666;\\n background-color: white;\\n z-index: 1000;\\n}\\n.igv-multi-locus-close-button > svg {\\n vertical-align: top;\\n}\\n\\n.igv-multi-locus-close-button:hover {\\n cursor: pointer;\\n color: #434343;\\n}\\n\\n.igv-multi-locus-ruler-label {\\n z-index: 64;\\n position: absolute;\\n top: 2px;\\n left: 0;\\n width: 100%;\\n height: 12px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label > div {\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n color: rgb(16, 16, 16);\\n background-color: white;\\n}\\n.igv-multi-locus-ruler-label > div {\\n cursor: pointer;\\n}\\n\\n.igv-multi-locus-ruler-label-square-dot {\\n z-index: 64;\\n position: absolute;\\n left: 50%;\\n top: 5%;\\n transform: translate(-50%, 0%);\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\\n width: 14px;\\n height: 14px;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\\n margin-left: 16px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: rgb(16, 16, 16);\\n}\\n\\n.igv-ruler-sweeper {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 26px;\\n bottom: 0;\\n left: 0;\\n width: 0;\\n z-index: 99999;\\n background-color: rgba(68, 134, 247, 0.25);\\n}\\n\\n.igv-ruler-tooltip {\\n pointer-events: none;\\n z-index: 128;\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 1px;\\n height: 32px;\\n background-color: transparent;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ruler-tooltip > div {\\n pointer-events: none;\\n width: 128px;\\n height: auto;\\n padding: 1px;\\n color: #373737;\\n font-size: 10px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n background-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-color: #373737;\\n}\\n\\n.igv-track-label {\\n position: absolute;\\n left: 8px;\\n top: 8px;\\n width: auto;\\n height: auto;\\n max-width: 50%;\\n padding-left: 4px;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n text-align: center;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-color: #444;\\n border-radius: 2px;\\n border-style: solid;\\n border-width: thin;\\n background-color: white;\\n z-index: 128;\\n cursor: pointer;\\n}\\n\\n.igv-track-label:hover,\\n.igv-track-label:focus,\\n.igv-track-label:active {\\n background-color: #e8e8e8;\\n}\\n\\n.igv-track-label-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-top: 4px;\\n}\\n\\n.igv-center-line {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n transform: translateX(-50%);\\n z-index: 8;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-left-style: dashed;\\n border-left-width: thin;\\n border-right-style: dashed;\\n border-right-width: thin;\\n}\\n\\n.igv-center-line-wide {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(127, 127, 127, 0.51);\\n}\\n\\n.igv-center-line-thin {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(0, 0, 0, 0);\\n}\\n\\n.igv-cursor-guide-horizontal {\\n display: none;\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n left: 0;\\n right: 0;\\n top: 50%;\\n height: 1px;\\n z-index: 32;\\n margin-left: 50px;\\n margin-right: 54px;\\n border-top-style: dotted;\\n border-top-width: thin;\\n border-top-color: rgba(127, 127, 127, 0.76);\\n}\\n\\n.igv-cursor-guide-vertical {\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n width: 1px;\\n z-index: 32;\\n border-left-style: dotted;\\n border-left-width: thin;\\n border-left-color: rgba(127, 127, 127, 0.76);\\n display: none;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-generic-dialog-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\\n width: 30%;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-generic-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-container div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-generic-container div:first-child i {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-menu-popup {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: max-content;\\n max-width: 400px;\\n z-index: 512;\\n cursor: pointer;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background: white;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-end;\\n text-align: left;\\n}\\n.igv-menu-popup > div:not(:first-child) {\\n width: 100%;\\n}\\n.igv-menu-popup > div:not(:first-child) > div {\\n background: white;\\n}\\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\\n padding-left: 4px;\\n padding-right: 4px;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:last-child {\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:hover {\\n background: #efefef;\\n}\\n\\n.igv-menu-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-bottom: 1px;\\n padding-top: 1px;\\n}\\n\\n.igv-menu-popup-header {\\n position: relative;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-menu-popup-header div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-menu-popup-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n.igv-menu-popup-check-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 20px;\\n margin-right: 4px;\\n background-color: transparent;\\n}\\n.igv-menu-popup-check-container div {\\n padding-top: 2px;\\n padding-left: 8px;\\n}\\n.igv-menu-popup-check-container div:first-child {\\n position: relative;\\n width: 12px;\\n height: 12px;\\n}\\n.igv-menu-popup-check-container div:first-child svg {\\n position: absolute;\\n width: 12px;\\n height: 12px;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-loading-spinner-container {\\n z-index: 1024;\\n position: absolute;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 32px;\\n height: 32px;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-loading-spinner-container > div {\\n box-sizing: border-box;\\n width: 100%;\\n height: 100%;\\n border-radius: 50%;\\n border: 4px solid rgba(128, 128, 128, 0.5);\\n border-top-color: rgb(255, 255, 255);\\n animation: spin 1s ease-in-out infinite;\\n -webkit-animation: spin 1s ease-in-out infinite;\\n}\\n\\n@keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n@-webkit-keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n.igv-roi-menu {\\n position: absolute;\\n z-index: 512;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background-color: white;\\n width: 192px;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-menu > div:first-child {\\n height: 24px;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-roi-menu > div:first-child > div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-roi-menu > div:first-child > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-menu > div:last-child {\\n background-color: white;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: 0;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n text-align: start;\\n vertical-align: middle;\\n}\\n.igv-roi-menu > div:last-child > div {\\n height: 24px;\\n padding-left: 4px;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n border-bottom-color: #7f7f7f;\\n}\\n.igv-roi-menu > div:last-child > div:not(:first-child):hover {\\n cursor: pointer;\\n background-color: rgba(127, 127, 127, 0.1);\\n}\\n.igv-roi-menu > div:last-child div:first-child {\\n font-style: italic;\\n text-align: center;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n}\\n.igv-roi-menu > div:last-child > div:last-child {\\n border-bottom-width: 0;\\n border-bottom-color: transparent;\\n}\\n\\n.igv-roi-placeholder {\\n font-style: normal;\\n color: rgba(75, 75, 75, 0.6);\\n}\\n\\n.igv-roi-table {\\n position: absolute;\\n z-index: 1024;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n resize: both;\\n overflow: hidden;\\n width: min-content;\\n max-width: 1600px;\\n border-color: #7f7f7f;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n font-weight: 400;\\n background-color: white;\\n cursor: default;\\n}\\n.igv-roi-table > div {\\n height: 24px;\\n font-size: 14px;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n}\\n.igv-roi-table > div:first-child {\\n border-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-top-width: 0;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-roi-table > div:first-child > div:first-child {\\n text-align: center;\\n white-space: nowrap;\\n text-overflow: ellipsis;\\n overflow: hidden;\\n margin-left: 4px;\\n margin-right: 4px;\\n width: calc(100% - 4px - 12px);\\n}\\n.igv-roi-table > div:first-child > div:last-child {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7f7f7f;\\n}\\n.igv-roi-table > div:first-child > div:last-child > svg {\\n display: block;\\n}\\n.igv-roi-table > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-table > .igv-roi-table-description {\\n padding: 4px;\\n margin-left: 4px;\\n word-break: break-all;\\n overflow-y: auto;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-goto-explainer {\\n margin-top: 5px;\\n margin-left: 4px;\\n color: #7F7F7F;\\n font-style: italic;\\n height: 24px;\\n border-top: solid lightgray;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n padding-right: 16px;\\n background-color: white;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: #7f7f7f;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n overflow: auto;\\n height: 360px;\\n flex: 1 1 auto;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: transparent;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n.igv-roi-table > div:last-child {\\n min-height: 32px;\\n height: 32px;\\n line-height: 32px;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: transparent;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-width: 0;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n\\n.igv-roi-table-row-selected {\\n background-color: rgba(0, 0, 0, 0.125);\\n}\\n\\n.igv-roi-table-button {\\n cursor: pointer;\\n height: 20px;\\n user-select: none;\\n line-height: 20px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 13px;\\n font-weight: 400;\\n color: black;\\n padding-left: 6px;\\n padding-right: 6px;\\n background-color: rgb(239, 239, 239);\\n border-color: black;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 3px;\\n}\\n\\n.igv-roi-table-button:hover {\\n font-weight: 400;\\n background-color: rgba(0, 0, 0, 0.13);\\n}\\n\\n.igv-roi-region {\\n z-index: 64;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n pointer-events: none;\\n overflow: visible;\\n margin-top: 66px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-region > div {\\n position: relative;\\n width: 100%;\\n height: 8px;\\n pointer-events: auto;\\n}\\n\\n.igv-roi-menu-row {\\n height: 24px;\\n padding-left: 8px;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n background-color: white;\\n}\\n\\n.igv-roi-menu-row-edit-description {\\n width: -webkit-fill-available;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n background-color: white;\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-bottom: 4px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-menu-row-edit-description > label {\\n margin-left: 2px;\\n margin-bottom: 0;\\n display: block;\\n width: -webkit-fill-available;\\n}\\n.igv-roi-menu-row-edit-description > input {\\n display: block;\\n margin-left: 2px;\\n margin-right: 2px;\\n margin-bottom: 1px;\\n width: -webkit-fill-available;\\n}\\n\\n.igv-container {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n padding-top: 4px;\\n user-select: none;\\n -webkit-user-select: none;\\n -ms-user-select: none;\\n min-height: 160px;\\n}\\n\\n.igv-viewport {\\n position: relative;\\n margin-top: 5px;\\n line-height: 1;\\n overflow-x: hidden;\\n overflow-y: hidden;\\n}\\n\\n.igv-viewport-content {\\n position: relative;\\n width: 100%;\\n}\\n.igv-viewport-content > canvas {\\n position: relative;\\n display: block;\\n}\\n\\n.igv-column-container {\\n position: relative;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n width: 100%;\\n}\\n\\n.igv-column-shim {\\n width: 1px;\\n margin-left: 2px;\\n margin-right: 2px;\\n background-color: #545453;\\n}\\n\\n.igv-axis-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 50px;\\n}\\n.igv-axis-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n}\\n.igv-axis-column > div > div {\\n z-index: 512;\\n position: absolute;\\n top: 8px;\\n left: 8px;\\n width: fit-content;\\n height: fit-content;\\n background-color: transparent;\\n display: grid;\\n align-items: start;\\n justify-items: center;\\n}\\n.igv-axis-column > div > div > input {\\n display: block;\\n margin: unset;\\n cursor: pointer;\\n}\\n\\n.igv-column {\\n position: relative;\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-info-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-name-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-scrollbar-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div > div {\\n cursor: pointer;\\n position: absolute;\\n top: 0;\\n left: 2px;\\n width: 8px;\\n border-width: 1px;\\n border-style: solid;\\n border-color: #c4c4c4;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-scrollbar-column > div > div:hover {\\n background-color: #c4c4c4;\\n}\\n\\n.igv-track-drag-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 12px;\\n background-color: white;\\n}\\n.igv-track-drag-column > .igv-track-drag-handle {\\n z-index: 512;\\n position: relative;\\n cursor: pointer;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n border-top-right-radius: 6px;\\n border-bottom-right-radius: 6px;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-color {\\n background-color: #c4c4c4;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-hover-color {\\n background-color: #787878;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-selected-color {\\n background-color: #0963fa;\\n}\\n.igv-track-drag-column > .igv-track-drag-shim {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n}\\n\\n.igv-gear-menu-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 28px;\\n}\\n.igv-gear-menu-column > div {\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n margin-top: 5px;\\n width: 100%;\\n background: white;\\n}\\n.igv-gear-menu-column > div > div {\\n position: relative;\\n margin-top: 4px;\\n width: 16px;\\n height: 16px;\\n color: #7F7F7F;\\n}\\n.igv-gear-menu-column > div > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n/*# sourceMappingURL=igv.css.map */\\n'),n.adoptedStyleSheets=[e]}if(this.root=e({class:\"igv-container\"}),n.appendChild(this.root),this.spinner=e({class:\"igv-loading-spinner-container\"}),this.root.appendChild(this.spinner),this.spinner.appendChild(e()),this.spinner.style.width=\"64px\",this.spinner.style.height=\"64px\",this.stopSpinner(),this.alert=new La(this.root),this.columnContainer=e({class:\"igv-column-container\"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Xu(this.columnContainer),this.menuUtils=new bo(this),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:\"rgb(0,0,150)\",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},t.listeners)for(let e of Object.keys(t.listeners))this.on(e,t.listeners[e]);this.on(\"trackremoved\",(()=>{0===this.findTracks((e=>\"function\"==typeof e.getSamples)).length&&(this.sampleInfoControl.setButtonVisibility(!1),this.sampleNameViewportWidth=void 0,this.showSampleNames=!1,this.sampleNameControl.setState(this.showSampleNames),this.sampleNameControl.hide(),this.layoutChange())})),this.on(\"didchangecolumnlayout\",(()=>{if(yu.length>0){const e=yu.length;for(let t=0;t1}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let e of this.referenceFrameList)if(\"all\"===e.chr.toLowerCase())return!0;return!1}currentLoci(){const e=e=>`${e.chr}:${e.start+1}-${e.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?\"\":1===this.referenceFrameList.length?e(this.referenceFrameList[0]):this.referenceFrameList.map((t=>e(t)))}toSVG(){const{x:e,y:t,width:i,height:n}=this.columnContainer.getBoundingClientRect(),r=new lu({width:i,height:n,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:i,height:n}}),s={deltaX:0,deltaY:-t};for(let e of this.trackViews)e.renderSVGContext(r,s);return s.deltaX=e,this.roiManager.renderSVGContext(this.columnContainer,r,s),r.getSerializedSvg(!0)}saveSVGtoFile(e,t){let i=this.toSVG();if(t){const e=document.createElement(\"svg\");e.innerHTML=i,t.append(e),t.appendChild(e)}const n=e||\"igvjs.svg\",r=URL.createObjectURL(new Blob([i],{type:\"application/octet-stream\"}));Pt(n,r),URL.revokeObjectURL(r)}savePNGtoFile(e){const t=this.toSVG(),i=new Blob([t],{type:\"image/svg+xml\"}),n=URL.createObjectURL(i),r=document.createElement(\"img\");r.addEventListener(\"load\",(()=>{const t=this.columnContainer.getBoundingClientRect(),i=window.devicePixelRatio,s=t.width*i,o=t.height*i,a=document.createElement(\"canvas\");a.width=s,a.height=o;const c=a.getContext(\"2d\");c.scale(i,i),c.drawImage(r,0,0);const l=a.toDataURL(\"image/png\");Pt(e=e||\"igvjs.png\",l),URL.revokeObjectURL(n)})),r.src=n}async loadSession(e){let t;return this.sampleInfo.initialize(),this.roiSets=[],t=e.url||e.file?await dA.loadSessionFile(e):e,this.loadSessionObject(t)}static async loadSessionFile(e){const t=e.url||e.file;let i;if(e.url&&Mt(e.url)&&(e.url.startsWith(\"blob:\")||e.url.startsWith(\"data:\"))){const t=dA.uncompressSession(e.url);i=JSON.parse(t)}else{let n=e.filename;if(n||(n=e.url?await ja(e.url):e.file.name),n.endsWith(\".xml\")){const e=mu.KNOWN_GENOMES,n=await Qs.loadString(t);i=new by(n,e)}else if(n.endsWith(\"hub.txt\")){i={reference:(await du.loadHub(t,e)).getGenomeConfig()}}else{if(!n.endsWith(\".json\"))throw Error(\"Unrecognized session file format:\"+n);i=await Qs.loadJson(t)}}return bA(i)}async loadSessionObject(e){this.cleanHouseForSession(),this.config=e,e.browsers&&(e=await async function(e){const t=e.browsers[0],i={},n=new Mf({url:t.url});await n.readHeaderAndFooter(),i.sampleNameViewportWidth=20,i.genome=\"hg38\";const r=t.state.split(\",\"),s=n.bpResolutions[Number.parseInt(r[2])],o=Number.parseInt(r[0]),a=Math.floor(Number.parseFloat(r[3])*s),c=a+Math.floor(1700*s);return i.locus=`${n.chromosomes[o].name}:${a}-${c}`,i.tracks=(t.tracks||[]).filter((e=>!(\"refgene\"===e.format||\"cellType\"===e.name))),i.tracks.push({type:\"shoebox\",url:t.url,name:t.name,colorScale:t.colorScale,_hicFile:n}),i}(e)),this.navbar.sampleInfoControl.setButtonVisibility(!1),this.showSampleNames=e.showSampleNames||!1,this.navbar.sampleNameControl.setState(!0===this.showSampleNames),e.sampleNameViewportWidth&&(this.sampleNameViewportWidth=e.sampleNameViewportWidth),$a(this.columnContainer,\"igv-axis-column\"),$a(this.columnContainer,\"igv-sample-info-column\"),$a(this.columnContainer,\"igv-sample-name-column\"),$a(this.columnContainer,\"igv-scrollbar-column\"),$a(this.columnContainer,\"igv-track-drag-column\"),$a(this.columnContainer,\"igv-gear-menu-column\");const t=e.reference||e.genome;if(!t)return void console.warn(\"No genome or reference object specified\");const i=Mt(t)?await mu.expandReference(this.alert,t):t;if(await this.loadReference(i,i.locus||e.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==e.showIdeogram){const e=new hy(this);e.id=\"ideogram\";const t=new hf(this,this.columnContainer,e);this.trackViews.push(t)}if(!1!==e.showRuler){const e=new hf(this,this.columnContainer,new Wu(this));this.trackViews.push(e)}e.qtlSelections&&(this.qtlSelections=cA.fromJSON(e.qtlSelections)),this.roiManager.clearROIs(),e.roi?this.roiManager.loadROI(e.roi):await this.roiManager.reset();const n=[];if(e.sampleinfo)for(const t of e.sampleinfo)t.file?n.push(t.file):this.loadSampleInfo(t);const r=i.tracks||[],s=e.tracks?r.concat(e.tracks):r;0===s.filter((e=>\"sequence\"===e.type&&!e.url&&!e.fastaURL)).length&&s.push({type:\"sequence\",order:Wd,removable:!1});const o=s.filter((e=>void 0!==e.file)).map((({file:e})=>e)),a=s.filter((e=>void 0!==e.indexFile)).map((({indexFile:e})=>e));a.length>0&&o.push(...a),n.length>0&&o.push(...n),o.length>0&&alert(`Local files cannot be loaded automatically.\\nThis session contains references to these local files:\\n${o.map((e=>` ${e}`)).join(\"\\n\")}`);const c=s.filter((e=>void 0===e.file));let l=1;for(let e of c)void 0===e.order&&(e.order=l++);await this.loadTrackList(c);for(let e of this.trackViews.filter((e=>\"ruler\"===e.track.type||\"ideogram\"===e.track.type)))await e.updateViews();return this.trackViews.some((e=>e.track.selected))&&this.navbar.setEnableTrackSelection(!0),this.updateUIWithReferenceFrameList(),this.updateLocusSearchWidget(),s}cleanHouseForSession(){for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-info-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column\").forEach((e=>e.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}async loadReference(e,t){let i;this.removeAllTracks(),this.roiManager.clearROIs(),this.navbar.setEnableTrackSelection(!1),i=e.gbkURL?await wd(e.gbkURL):await aA.createGenome(e,this);const n=void 0===this.genome||this.genome.id!==i.id;this.genome=i,this.navbar.updateGenome(i);let r=t||i.initialLocus;Array.isArray(r)&&(r=r.join(\" \"));if(!await this.search(r,!0))throw new Error(`Cannot set initial locus ${r}`);if(n){let t;if(e.hubURL){t=(await du.loadHub(e.hubURL)).getGroupedTrackConfigurations()}this.fireEvent(\"genomechange\",[{genome:i,trackConfigurations:t}]),this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)})}}async loadGenome(e){let t;e.genarkAccession&&(e.url=hu(e.genarkAccession)),e.url&&(Mt(e.url)&&e.url.endsWith(\"/hub.txt\")?(e.hubURL=e.url,delete e.url):\"gbk\"===function(e){let t;if(e instanceof File)t=e.name;else{if(\"string\"!=typeof e)throw new Error(\"Input must be a File object or a URL string\");t=e}const i=t.split(\".\").pop();return i.split(\"?\")[0]}(e.url)&&(e.gbkURL=e.url,delete e.url));if(e.hubURL||e.url&&Mt(e.url)&&e.url.endsWith(\"/hub.txt\")){t=(await du.loadHub(e.hubURL||e.url,e)).getGenomeConfig()}else t=Mt(e)||!(e.url||e.fastaURL||e.twoBitURL||e.gbkURL)?await mu.expandReference(this.alert,e):e;let i;await this.loadReference(t),i=t.gbkURL||\"gbk\"===t.format?[{name:\"Annotations\",format:\"gbk\",url:t.gbkURL}]:t.tracks||[];return 0===i.filter((e=>\"sequence\"===e.type)).length&&i.push({type:\"sequence\",order:Wd}),await this.loadTrackList(i),await this.updateViews(),this.genome}async loadTrackHub(e){const t=bA((await du.loadHub(e.url,e)).getGenomeConfig());return this.loadGenome(t)}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(e[0].chr),this.navbar.navbarDidResize(),mA(this.trackViews,this.doShowTrackLabels),this.doShowCenterLine&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.centerLineButton.boundMouseClickHandler(),this.doShowCursorGuide&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.cursorGuideButton.boundMouseClickHandler(),this.setCenterLineAndCenterLineButtonVisibility(mu.isWholeGenomeView(e[0].chr))}setCenterLineAndCenterLineButtonVisibility(e){e?this.navbar.centerLineButton.setVisibility(!1):this.navbar.centerLineButton.setVisibility(this.config.showCenterGuideButton);for(let t of this.centerLineList)e?this.setCenterLineVisibility(!e):this.setCenterLineVisibility(this.doShowCenterLine)}setTrackLabelVisibility(e){mA(this.trackViews,e)}setROITableVisibility(e){!0===e?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)!0===e?(t.show(),t.repaint()):t.hide()}async loadTrackList(e){let t=0;for(let i of e)void 0===i.order&&(i.order=t++);const i=[];for(let t of e)i.push(this._loadTrack(t));const n=await Promise.all(i);return this.trackViews.filter((function(e){return e.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadTrack(e){e.sync=!1!==e.sync;const t=this._loadTrack(e);return t&&e.autoscaleGroup&&(await t,this.updateViews()),t}async _loadTrack(e){Mt(e)&&(e=JSON.parse(e));try{if(e.hidden){const t=Ad(e,this.genome);return void await t.getFeatures({chr:\"1\",start:0,end:Number.MAX_SAFE_INTEGER})}const t=await this.createTrack(e);if(\"sampleinfo\"===e.type)return void this.layoutChange();if(void 0===t)return;return this.addTrack(e,t)}catch(t){let i=t.message||t.error||t.toString();const n={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};n.hasOwnProperty(i)&&(i=n[i]),i=`${i} : ${Ht(e.url)?e.url.name:e.url}`;const r=new Error(i);throw console.error(r),r}}async addTrack(e,t){void 0===t.order&&(t.order=this.trackViews.length);const i=new hf(this,this.columnContainer,t);if(this.trackViews.push(i),mA(this.trackViews,this.doShowTrackLabels),\"function\"==typeof t.postInit)try{i.startSpinner(),await t.postInit()}finally{i.stopSpinner()}return t.autoscaleGroup||(e.sync?await i.updateViews():i.updateViews()),\"function\"==typeof t.hasSamples&&t.hasSamples()&&(this.sampleInfo.hasAttributes()&&this.sampleInfoControl.setButtonVisibility(!0),!1!==this.config.showSampleNameButton&&this.sampleNameControl.show()),this.reorderTracks(),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),t.trackView.enableTrackSelection(this.navbar.getEnableTrackSelection()),t}async loadROI(e){return this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=this.roiManager.getUserDefinedROISet();if(void 0===e)return[];const t=await e.getAllFeatures(),i=[];for(let e of Object.values(t))i.push(...e);return i}return[]}getRulerTrackView(){const e=this.trackViews.filter((({track:e})=>\"ruler\"===e.id));return e.length>0?e[0]:void 0}async createTrack(e){let t=await async function(e){return\"function\"==typeof e?e():e}\n", - "/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(e.url||e.fastaURL);if(Mt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format=\"fasta\";else if(e.sourceType)\"htsget\"===e.sourceType&&await Rh.inferFormat(e);else{const t=await am(e);t&&(e.format=t)}e.type&&Ha(e);let i=e.type?e.type.toLowerCase():void 0;if(!i){if(!e.format)throw Error(`Unrecognized track: ${JSON.stringify(e)}`);if(\"hic\"===e.format){const t=new Mf(e);if(await t.readHeaderAndFooter(),!t.chromosomeIndexMap.celltype)throw Error(\"'.hic' files not supported\");i=\"shoebox\",e._hicFile=t}else if(i=za(e.format),\"bedtype\"===i){const t=Ad(e,this.genome);e._featureSource=t;const n=await t.trackType();i=n||\"annotation\"}e.type=i}if(this.trackDefaults&&i){const t=this.trackDefaults[i];if(t)for(let i in t)t.hasOwnProperty(i)&&void 0===e[i]&&(e[i]=t[i])}const n=function(e,t,i){let n;switch(e){case\"annotation\":case\"genes\":case\"fusionjuncspan\":case\"snp\":n=\"feature\";break;case\"seg\":case\"maf\":case\"mut\":n=\"seg\";break;case\"junctions\":case\"splicejunctions\":n=\"junction\";break;default:n=e}return wy.has(n)?wy.get(n)(t,i):void 0}(i,e,this);if(void 0!==n)return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map((e=>new eA(e,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0)}reorderTracks(){this.trackViews.sort((function(e,t){const i=e=>\"ideogram\"===e.track.id?1:\"ruler\"===e.track.id?2:3,n=i(e),r=i(t);if(n===r){return(e.track.order||0)-(t.track.order||0)}return n-r}));for(let{axis:e,viewports:t,sampleInfoViewport:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){e.remove();for(let{$viewport:e}of t)e.detach();i.viewport.remove(),n.viewport.remove(),r.remove(),s.remove(),o.remove()}const e=this.columnContainer.querySelectorAll(\".igv-column\");for(let{axis:t,viewports:i,sampleInfoViewport:n,sampleNameViewport:r,outerScroll:s,dragHandle:o,gearContainer:a}of this.trackViews){this.columnContainer.querySelector(\".igv-axis-column\").appendChild(t);for(let t=0;te.track&&e.track.name)).map((e=>e.track.name))}getSelectedTrackViews(){return this.trackViews.filter((e=>!0===e.track.selected))}removeTrackByName(e){const t=this.trackViews.slice();for(let i of t)e===i.track.name&&this.removeTrack(i.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent(\"trackremoved\",[e]),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=this.trackViews;this.trackViews=[];for(let t of e)\"ruler\"!==t.track.id&&\"ideogram\"!==t.track.id?(this.fireEvent(\"trackremoved\",[t.track]),t.dispose()):this.trackViews.push(t)}get ideogramTrackView(){return this.trackViews[0]}get rulerTrackView(){return this.trackViews[1]}findTracks(e,t){let i=\"function\"==typeof e?t=>e(t.track):i=>t===i.track[e];return this.trackViews.filter(i).map((e=>e.track))}get tracks(){return this.trackViews.map((e=>e.track)).filter((e=>void 0!==e))}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach((function(t){t.setTrackHeight(e)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((e=>e.bpPerPixel<0))){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel=(t.end-t.start)/e}this.referenceFrameList&&this.navbar.navbarDidResize(),uA.call(this),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(let e of this.referenceFrameList)e.bpPerPixel<=10&&await this.genome.getSequence(e.chr,e.start,e.start+1);for(let e of this.centerLineList)e.repaint();if(this.dragObject)for(let t of e)await t.updateViews();else{const t={},i=[];for(const n of e)if(n.track.autoscaleGroup){const e=n.track.autoscaleGroup;t[e]||(t[e]=[]),t[e].push(n)}else i.push(n);if(Object.entries(t).length>0)for(const[e,i]of Object.entries(t)){const e=await Promise.all(i.map((e=>e.getInViewFeatures()))),t=qa(e.flat());for(const e of i)e.track.dataRange=Object.assign({},t),e.track.autoscale=!1;await Promise.all(i.map((e=>e.updateViews())))}await Promise.all(i.map((e=>e.updateViews())))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of e)i.end=i.start+i.bpPerPixel*t;const i=1===e.length?this.referenceFrameList[0].chr:\"\",n=this.referenceFrameList.map((e=>e.getLocusString())).join(\" \");this.navbar.updateLocus(n,i),this.fireEvent(\"locuschange\",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleInfoViewportWidth()+this.getSampleNameViewportWidth()+14+12+28,t-=5*(e-1),Math.floor(t/e)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=s;const o=(i-t)/r,a=new vy(this.genome,e,t,i,o),c=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],d=Uy(h.get(0).parentElement);if(this.fireEvent(\"didchangecolumnlayout\"),l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.push(t)}}else{this.referenceFrameList.splice(l,0,a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.splice(l,0,t)}}this.centerLineList=this.createCenterLineList(this.columnContainer),uA.call(this),await this.updateViews(!0)}createCenterLineList(e){const t=e.querySelectorAll(\".igv-center-line\");for(let e=0;e{i===t||e.remove()})),this.columnContainer.querySelectorAll(\".igv-column-shim\").forEach((e=>e.remove()));for(let e of this.trackViews){const i=e.viewports[t];e.viewports.filter(((e,i)=>i!==t)).forEach((e=>e.dispose())),e.viewports=[i]}const i=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/i,this.referenceFrameList=[e],this.trackViews.forEach((({viewports:e})=>e.forEach((e=>e.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=e;for(let{viewports:e}of this.trackViews)for(let i of e)i.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,i){await this.search(e+\":\"+t+\"-\"+i)}async doSearch(e,t){const i=await this.search(e,t);return i||this.alert.present(new Error(`Unrecognized locus: ${e} `)),i}async search(e,t){const i=await async function(e,t){if(void 0===t||\"\"===t.trim())return;const i=t.split(\" \");let n=[];const r=async t=>{if(\"all\"===t.trim().toLowerCase()||\"*\"===t)return e.genome.wholeGenomeView?{chr:\"all\",start:0,end:e.genome.getChromosome(\"all\").bpLength}:void 0;let i,n;if(t.includes(\":\")&&(i=ey(t,e.isSoftclipped()),i&&(n=await e.genome.loadChromosome(i.chr))),!n){i=void 0;const r=await Jv(e,t);r&&(i={chr:r.chr,start:r.start,end:r.end,name:(r.name||t).toUpperCase()}),i||(n=await e.genome.loadChromosome(t),n&&(i={chr:n.name}))}return i&&(n=n||await e.genome.loadChromosome(i.chr),i.chr=n.name,void 0===i.start&&void 0===i.end&&(i.start=0,i.end=n.bpLength)),i};for(let e of i){const t=await r(e);t&&n.push(t)}if(0===n.length){const e=await r(t.replaceAll(\" \",\"+\"));e&&n.push(e)}return 0===n.length?void 0:n}(this,e);if(i&&i.length>0){this.referenceFrameList=function(e,t,i,n,r,s){return e.map((e=>{const o=Object.assign({},e);if(i&&o.name&&(o.start=Math.max(0,o.start-i),o.end+=i),!s){const e=t.getChromosome(o.chr);Qa(e.bpLength,o,n)}return new vy(t,o.chr,o.start,o.end,(o.end-o.start)/r)}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let e of this.trackViews)e.removeViewportsFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-column-shim, .igv-column\").forEach((e=>e.remove())),qy(this.columnContainer.querySelector(\".igv-sample-info-column\"),this.referenceFrameList.length),this.fireEvent(\"didchangecolumnlayout\");for(let e of this.trackViews)e.createViewports(this,this.columnContainer,this.referenceFrameList);return this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}return!1}async loadSampleInfo(e){await this.sampleInfo.loadSampleInfoFile(e.url);for(const{sampleInfoViewport:e}of this.trackViews)e.setWidth(this.getSampleInfoColumnWidth());this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0&&(this.sampleInfoControl.performClickWithState(this,!0),this.sampleInfoControl.setButtonVisibility(!0));for(const{sampleInfoViewport:e}of this.trackViews)e.repaint()}getSampleInfoColumnWidth(){if(this.sampleInfo.attributeCount){const e=this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0,t=this.sampleInfo.hasAttributes(),i=this.sampleInfoControl.showSampleInfo;return e&&t&&i?this.sampleInfo.attributeCount*Vu+8:0}return 0}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(e)if(t){const i=this.eventHandlers[e];if(i&&0!==i.length){const n=i.indexOf(t);-1!==n&&this.eventHandlers[e].splice(n,1)}else console.warn(\"No handlers to remove for event: \"+e)}else this.eventHandlers[e]=[];else this.eventHandlers={}}fireEvent(e,t,i){const n=this.eventHandlers[e];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(e){return e.apply(r,t)}))[0]}dispose(){this.removeEventHandlers();for(let e of this.trackViews)e.dispose();this.roiManager&&this.roiManager.dispose()}toJSON(){const e={version:\"3.0.9\"};if(void 0!==this.showSampleNames&&(e.showSampleNames=this.showSampleNames),this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[];let i=this.trackViews[0];for(let{referenceFrame:e}of i.viewports){const i=e.getLocusString();t.push(i)}e.locus=1===t.length?t[0]:t,e.roi=this.roiManager.toJSON(),this.qtlSelections.isEmpty()||(e.qtlSelections=this.qtlSelections.toJSON());const n=[],r=[];for(const{track:e}of this.trackViews)try{let t;\"function\"==typeof e.getState?t=Hl.localFileInspection(e.getState()):e.config&&(t=Hl.localFileInspection(e.config)),t&&(t.browser&&delete t.browser,t.order=e.order,n.push(t))}catch(t){const i=`Track: ${e.name}: ${t}`;console.error(i),r.push(i)}if(r.length>0){let e=1,t=\"Errors encountered saving session:
\";for(let i of r)t+=` (${e++}) ${i.toString()}
`;throw Error(t)}e.tracks=n;const s=[];for(const e of n)for(const t of Object.keys(e))\"file\"!==t&&\"indexFile\"!==t||s.push(e[t]);const o=[];if(this.sampleInfo.sampleInfoFiles.length>0){const t=this.sampleInfo.toJSON();t.length>0&&(e.sampleinfo=t);for(const e of this.sampleInfo.sampleInfoFiles){const t=Hl.localFileInspection({url:e});t.file&&o.push(t.file)}o.length>0&&s.push(...o)}return s.length>0&&alert(`This session includes reference(s) to local file(s):\\n${s.map((e=>` ${e}`)).join(\"\\n\")}\\nLocal files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){return function(e){const t=new Uint8Array(e.length);for(var i=0;i0?e.substring(0,t):e)+\"?sessionURL=blob:\"+this.compressedSession()}mouseDownOnViewport(e,t){var i;i=r(e),this.vpMouseDown={viewport:t,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent(\"trackdragend\",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((e=>!0===e.track.showSoftClips))}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,i=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),r=this.trackViews;r[i]=t,r[n]=e;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i0;e--){const t=r[e].track;if(!(t.order>=a))break;t.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=t.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=uA.bind(this),window.addEventListener(\"resize\",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener(\"resize\",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=pA.bind(this),this.root.addEventListener(\"mouseup\",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener(\"mouseup\",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=pA.bind(this),this.root.addEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=fA.bind(this),this.boundColumnContainerTouchMoveHandler=fA.bind(this),this.boundColumnContainerMouseLeaveHandler=pA.bind(this),this.boundColumnContainerMouseUpHandler=pA.bind(this),this.boundColumnContainerTouchEndHandler=pA.bind(this),this.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=gA.bind(this),document.addEventListener(\"keyup\",this.keyUpHandler)}removeKeyboardHandler(){console.log(\"Remove handler\"),document.addEventListener(\"keyup\",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf(\"/gzip;base64\")>0){t=vs(e);let i=\"\";for(let e of t)i+=String.fromCharCode(e);return i}return function(e){e=e.replace(/\\./g,\"+\").replace(/_/g,\"/\").replace(/-/g,\"=\");const t=atob(e),i=[];for(let e=0;e{const r=e.data,s=r.mate;function o(e){e.chr=i.genome.getChromosomeName(e.refName);let t=!1;for(let n of i.referenceFrameList){const i=lm.fromLocusString(n.getLocusString());if(i.contains(e)){t=!0;break}if(i.overlaps(e)){n.extend(e),t=!0;break}}if(!t){const t=2e3,n=(e.start+e.end)/2;i.addMultiLocusPanel(e.chr,n-t,n+t)}}o(r),o(s)}})),this.circularViewControl=new Vy(this.navbar.toggle_button_container,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get sampleInfoControl(){return this.navbar.sampleInfoControl}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}get sampleNameControl(){return this.navbar.sampleNameControl}}async function uA(){if(!this.referenceFrameList)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList){const i=this.referenceFrameList.indexOf(t),{chr:n,genome:r}=t,{bpLength:s}=r.getChromosome(t.chr),o=t.toBP(e);mu.isWholeGenomeView(n)||o>s?t.bpPerPixel=s/e:t.end=t.start+t.toBP(e);for(let{viewports:t}of this.trackViews)t[i].setWidth(e)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function fA(e){e.preventDefault();const{x:t,y:i}=r(e);if(this.vpMouseDown){const{viewport:e,referenceFrame:n}=this.vpMouseDown,r=Math.abs(t-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(t-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:e,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const t=e.$viewport.height(),i=e.trackView.maxViewportContentHeight();this.vpMouseDown.r=t/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-t;n.shiftPixels(r,e.$viewport.width(),i)&&this.updateViews(),this.fireEvent(\"trackdrag\")}if(this.isScrolling){const t=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);e.trackView.moveScroller(t)}this.vpMouseDown.lastMouseX=t,this.vpMouseDown.lastMouseY=i}}function pA(e){this.cancelTrackPan(),this.endTrackDrag()}async function gA(e){if(this.referenceFrameList&&!(this.referenceFrameList.length>1)&&(\"KeyF\"===e.code||\"KeyB\"===e.code)){const t=this.getSelectedTrackViews();if(t.length>0){const i=t[0].track;if(\"function\"==typeof i.nextFeatureAfter){const t=this.referenceFrameList[0],n=t.viewport?t.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),r=\"all\"===t.chr.toLowerCase(),s=i.visibilityWindow;if(r||s&&s>0&&t.bpPerPixel*n>s)return;const o=\"KeyF\"===e.code,a=t.chr,c=t.center,l=await i.nextFeatureAfter(a,c,o);if(l){const i=await this.genome.getChromosomeName(l.chr);if(a===i){const i=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,r=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,i-r/2),t.end=i+r/2,t.bpPerPixel=(t.end-t.start)/n}else t.shift(i-c);this.updateViews()}else{t.chr=i;const r=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,i=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,r-i/2),t.end=t.start+i,t.bpPerPixel=(t.end-t.start)/n}else t.start=r-n*t.bpPerPixel/2,t.end=t.start+n*t.bpPerPixel;this.updateViews()}}}}}}function mA(e,t){for(let{viewports:i}of e)for(let e of i)e.$trackLabel&&(0===i.indexOf(e)&&!0===t?e.$trackLabel.show():e.$trackLabel.hide())}let wA=[];function bA(e){return void 0===e.minimumBases&&(e.minimumBases=40),void 0===e.showIdeogram&&(e.showIdeogram=!0),void 0===e.showCircularView&&(e.showCircularView=!1),void 0===e.showCircularViewButton&&(e.showCircularViewButton=!1),void 0===e.showTrackLabelButton&&(e.showTrackLabelButton=!0),void 0===e.showTrackLabels&&(e.showTrackLabels=!0),void 0===e.showCursorTrackingGuideButton&&(e.showCursorTrackingGuideButton=!0),void 0===e.showCursorGuide&&(e.showCursorGuide=e.showCursorTrackingGuide||!1),void 0===e.showCenterGuideButton&&(e.showCenterGuideButton=!0),void 0===e.showCenterGuide&&(e.showCenterGuide=!1),void 0===e.showSampleNames&&(e.showSampleNames=!1),void 0===e.showSVGButton&&(e.showSVGButton=!0),void 0===e.showControls&&(e.showControls=!0),void 0===e.showNavigation&&(e.showNavigation=!0),void 0===e.showRuler&&(e.showRuler=!0),void 0===e.flanking&&(e.flanking=1e3),void 0===e.pairsSupported&&(e.pairsSupported=!0),e.tracks||(e.tracks=[]),e}const FA=Qs.setApiKey;const vA=Qs.oauth;var yA={TrackUtils:Pa,IGVGraphics:xo,MenuUtils:bo,DataRangeDialog:_o,createTrack:async function(e,t){return await dA.prototype.createTrack.call(t,e)},createBrowser:async function(e,t){void 0===t&&(t={}),mu.KNOWN_GENOMES||await mu.initializeGenomes(t),bA(t),t.queryParametersSupported&&function(e){var t,i,n,r,s,o,a,c,l;let h,d,u;if(a=window.location.href,s={},t=a.indexOf(\"?\"),i=a.lastIndexOf(\"#\"),t>=0)for(i<0&&(i=a.length),n=t+1;nt&&(i.indexURL=d[t]),u&&u.length>t&&(i.name=u[t]),e.tracks.push(i)}}}(t),t.apiKey&&Qs.setApiKey(t.apiKey),t.oauthToken&&Qs.setOauthToken(t.oauthToken),t.clientId&&!Ts()&&await async function(e){if(!google.accounts.oauth2.initTokenClient)throw new Error(\"Google accounts token client not loaded (https://accounts.google.com/gsi/client)\");if(Ts())throw new Error(\"Google client is already initialized\");const t={client_id:e.client_id||e.clientId,scope:e.scope||\"https://www.googleapis.com/auth/userinfo.profile\",state:e.state||\"igv\",error:e=>{throw new Error(e.type)},hint:e.hint,hosted_domain:e.hosted_domain},i=google.accounts.oauth2.initTokenClient(t);google.igv={tokenClient:i,apiKey:e.apiKey}}({client_id:t.clientId,apiKey:t.apiKey,scope:\"https://www.googleapis.com/auth/userinfo.profile\"});const i=new dA(t,e);wA.push(i),i.startSpinner();const n=t.sessionURL||t.session||t.hubURL;return n?await i.loadSession({url:n}):await i.loadSessionObject(t),i.stopSpinner(),i.navbar.navbarDidResize(),i},removeBrowser:function(e){e.dispose(),e.root.remove(),wA=wA.filter((t=>t!==e))},removeAllBrowsers:function(){for(let e of wA)e.dispose(),e.root.remove();wA=[]},visibilityChange:async function(){for(let e of wA)await e.visibilityChange()},setGoogleOauthToken:function(e){return Qs.setOauthToken(e)},setOauthToken:function(e,t){return Qs.setOauthToken(e,t)},oauth:vA,version:yy,setApiKey:FA,TrackBase:Hl,registerTrackClass:function(e,t){wy.set(e,((e,i)=>new t(e,i)))},registerTrackCreatorFunction:function(e,t){wy.set(e,t)},registerFileFormats:function(e,t){Sl[e]={fields:t}},loadSessionFile:dA.loadSessionFile};return yA}();\n", - "//# sourceMappingURL=igv.iife.js.map\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Global handler for igv.js messages. Messages have the form\n", - " * {\n", - " * command -- the command to execute\n", - " * id -- the id of the igv.js browser, if applicable\n", - " * data -- any data needed for the command\n", - " * }\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope, with the execption of the global handler\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " let svgComm\n", - " if (isNotebook) {\n", - " svgComm = Jupyter.notebook.kernel.comm_manager.new_comm('svg', {})\n", - " }\n", - "\n", - " async function toSVG(displayID, locus, svg) {\n", - " //console.log(isNotebook + \" \" + locus)\n", - " if (isNotebook) {\n", - " svgComm.send({\n", - " \"display_id\": displayID,\n", - " \"locus\": locus,\n", - " \"svg\": svg\n", - " })\n", - " }\n", - " }\n", - "\n", - " console.log(\"Installing IGVMessageHandler\")\n", - "\n", - " function convertUrlsAndPaths(session) {\n", - " if (session.reference) {\n", - " for (let pre of [\"fasta\", \"index\", \"cytoband\", \"cytobandBb\", \"compressedIndex\", \"alias\", \"aliasBb\",\n", - " \"twoBit\", \"twoBitBpt\", \"chromAliasBb\", \"chromSizes\", \"trix\"]) {\n", - " convert(session.reference, pre)\n", - " }\n", - " if (session.reference.tracks) {\n", - " for (let t of session.reference.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " if (session.tracks) {\n", - " for (let t of session.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Return true if the sessionJson object contains only absolute URLs to resources\n", - " */\n", - " function safeToWeblink(sessionJson) {\n", - " const unsafe = (url) => typeof url.startsWith != 'function' || !url.startsWith(\"http\")\n", - " if (sessionJson.reference) {\n", - " if (unsafe(sessionJson.reference.fastaURL)) return false\n", - " }\n", - " if (sessionJson.tracks) {\n", - " const urls = sessionJson.tracks.filter(t => t.url).map(t => t.url)\n", - " if (urls.some(unsafe)) return false\n", - " }\n", - " return true\n", - " }\n", - "\n", - " class MessageHandler {\n", - "\n", - " constructor() {\n", - " this.browserCache = new Map()\n", - " this.messageQueue = new Queue()\n", - " }\n", - "\n", - " on(msg) {\n", - " this.messageQueue.enqueue(msg)\n", - " this.processQueue()\n", - " }\n", - "\n", - " async processQueue() {\n", - "\n", - " const convertTrackData = (data) => {\n", - " convert(data)\n", - " convert(data, \"index\")\n", - " if (!data.indexURL) {\n", - " data.indexed = false\n", - " }\n", - " }\n", - "\n", - " if (!this.processing) {\n", - " this.processing = true\n", - " while (!this.messageQueue.isEmpty()) {\n", - " const msg = this.messageQueue.dequeue()\n", - " const command = msg.command\n", - " const browserID = msg.id\n", - " const data = msg.data\n", - " const browser = this.browserCache.get(browserID)\n", - " try {\n", - " switch (command) {\n", - " case \"createBrowser\":\n", - "\n", - " // custom button bar\n", - " const button_container = document.getElementById(`${browserID}_buttons`) // <= created from python\n", - " const customButtonDiv = document.createElement('div')\n", - " customButtonDiv.style = `background: #f3f3f3;padding: 5px;border-color: #bfbfbf;border-style: solid;border-width: thin;border-radius: 3px;`\n", - " button_container.appendChild(customButtonDiv)\n", - "\n", - " data.sync = true\n", - " convertUrlsAndPaths(data)\n", - "\n", - " const container = document.getElementById(`${browserID}_igvcontainer`) // <= created from python\n", - " const newBrowser = await igv.createBrowser(container, data)\n", - " this.browserCache.set(browserID, newBrowser)\n", - "\n", - " // Add igv-notebook button bar\n", - " const toJsonButton = document.createElement('button')\n", - " toJsonButton.innerText = \"Save Session\"\n", - " toJsonButton.style = \"margin-right:5px\"\n", - " toJsonButton.addEventListener('click', (evt) => {\n", - " let fn\n", - " if (isNotebook) {\n", - " fn = prompt(\"Filename:\", \"session.json\")\n", - " } else {\n", - " fn = \"session.json\"\n", - " }\n", - " if (fn) {\n", - " const json = newBrowser.toJSON()\n", - " const jsonString = JSON.stringify(json, null, '\\t')\n", - " download(fn, jsonString)\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(toJsonButton)\n", - "\n", - " const webLinkNode = document.createElement('a')\n", - " webLinkNode.target = \"igvWeb\"\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.style.display = \"none\"\n", - "\n", - " const shareButton = document.createElement('button')\n", - " shareButton.innerText = \"Show IGV-Web Link\"\n", - " shareButton.style = \"margin-right:5px\"\n", - " shareButton.addEventListener('click', async (evt) => {\n", - "\n", - " if (safeToWeblink(newBrowser.toJSON())) {\n", - " const sessionURL = `https://igv.org/app?sessionURL=blob:${newBrowser.compressedSession()}`\n", - " const shortURL = await shortenURL(sessionURL)\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.setAttribute(\"href\", shortURL)\n", - " webLinkNode.style.display = \"inline-block\"\n", - " shareButton.innerText = \"Update IGV-Web Link\"\n", - " } else {\n", - " webLinkNode.innerText = \"Cannot link -- non URL resources used\"\n", - " webLinkNode.style.display = \"inline-block\"\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(shareButton)\n", - " customButtonDiv.appendChild(webLinkNode)\n", - "\n", - " if (isNotebook) {\n", - " const toSVGButton = document.createElement('button')\n", - " toSVGButton.innerText = \"To SVG\"\n", - " toSVGButton.style = \"float:right\"\n", - " toSVGButton.addEventListener('click', (evt) => {\n", - " const locus = newBrowser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " const svg = newBrowser.toSVG()\n", - " toSVG(browserID, locus, svg)\n", - " })\n", - " customButtonDiv.appendChild(toSVGButton)\n", - " }\n", - "\n", - " break\n", - "\n", - " case \"loadSession\":\n", - " convertUrlsAndPaths(data)\n", - " browser.loadSessionObject(data)\n", - " break\n", - "\n", - " case \"loadTrack\":\n", - " convertTrackData(data)\n", - " await browser.loadTrack(data)\n", - " break\n", - "\n", - " case \"loadROI\":\n", - " if (Array.isArray(data)) {\n", - " data.map(convertTrackData)\n", - " } else {\n", - " convertTrackData(data)\n", - " }\n", - " await browser.loadROI(data)\n", - " break\n", - "\n", - " case \"clearROIs\":\n", - " await browser.clearROIs()\n", - " break\n", - "\n", - " case \"search\":\n", - " browser.search(data)\n", - " break\n", - "\n", - " case \"zoomIn\":\n", - " browser.zoomIn()\n", - " break\n", - "\n", - " case \"zoomOut\":\n", - " browser.zoomOut()\n", - " break\n", - "\n", - " case \"remove\":\n", - " this.browserCache.delete(browserID)\n", - " document.getElementById(browserID).parentNode.removeChild(container)\n", - " break\n", - "\n", - " case \"toSVG\":\n", - " const displayId = data\n", - " const svg = browser.toSVG()\n", - " const locus = browser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " toSVG(displayId, locus, svg)\n", - " break\n", - "\n", - " default:\n", - " console.error(\"Unrecognized method: \" + msg.command)\n", - " }\n", - " } catch (e) {\n", - " console.error(e)\n", - " }\n", - " }\n", - " this.processing = false\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Potentially convert a path to a local File-like object.\n", - " * @param path\n", - " * @returns {*}\n", - " */\n", - " function createNotebookFile(path) {\n", - " if (!path ||\n", - " path.startsWith(\"https://\") || path.startsWith(\"http://\") || path.startsWith(\"gs://\") || path.startsWith(\"data:\")) {\n", - " return path\n", - " } else {\n", - " // Try to create a notebook file. If no notebook file implementation is available for the kernel in\n", - " // use (e.g. Jupyter Lab) treat as a URL.\n", - " const nbFile = igv.createNotebookLocalFile({path})\n", - " if (nbFile != null) {\n", - " return nbFile\n", - " } else {\n", - " // Try to treat as relative URL. This may or may not work\n", - " return convertURL(path)\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Convert relative URLs to absolute. Primarily for Jupyter Lab, not generally needed for Jupyter Notebook\n", - " * @param url\n", - " * @returns {*}\n", - " */\n", - " function convertURL(url) {\n", - "\n", - " const pageURL = window.location.href\n", - "\n", - " if (!url ||\n", - " url.startsWith(\"https://\") ||\n", - " url.startsWith(\"http://\") ||\n", - " url.startsWith(\"gs://\") ||\n", - " url.startsWith(\"data:\")) {\n", - " return url\n", - " } else if (isColab) {\n", - " // Interpret relative url as a path.\n", - " igv.createNotebookLocalFile({path: url})\n", - " } else if (isNotebook) {\n", - " // Jupyter Notebook\n", - " //\n", - " // Examples\n", - " // https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/notebooks/examples/BamFiles-Jupyter.ipynb\n", - " // => https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/files/examples/data/gstt1_sample.bam\",\n", - "\n", - " const baseURL = document.querySelector('body').getAttribute('data-base-url')\n", - " const notebookPath = document.querySelector('body').getAttribute('data-notebook-path')\n", - " const notebookName = document.querySelector('body').getAttribute('data-notebook-name')\n", - " const notebookDir = notebookPath.slice(0, -1 * notebookName.length)\n", - "\n", - " //`${location.origin}${base_path}files/${nb_dir}${url}`\n", - " if (url.startsWith(\"/\")) {\n", - " url = `files${url}`\n", - " return encodeURI(`${location.origin}${baseURL}${url}`)\n", - " } else {\n", - " // URL is relative to notebook\n", - " return encodeURI(`${location.origin}${baseURL}files/${notebookDir}${url}`)\n", - " }\n", - " } else if (pageURL.includes(\"/lab\")) {\n", - "\n", - " console.log(\"Jupyter lab\")\n", - " // Jupyter Lab\n", - "\n", - " // Examples\n", - " // http://localhost:8888/lab/workspaces/auto-N/tree/examples/BamFiles.ipynb\n", - " // => http://localhost:8888/files/examples/data/gstt1_sample.bam\n", - " //\n", - " // https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/lab/tree/examples/BamFiles.ipynb\n", - " // => https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/files/examples/data/gstt1_sample.bam\n", - "\n", - " const baseIndex = pageURL.indexOf(\"/lab\")\n", - " const baseURL = pageURL.substring(0, baseIndex)\n", - "\n", - " if (url.startsWith(\"/\")) {\n", - " return encodeURI(`${baseURL}/files${url}`)\n", - " } else if (pageURL.includes(\"/tree/\")) {\n", - " // Interpret URL as relative to notebook location. This is not reliable, '/tree/' is not always in the page URL\n", - " const treeIndex = pageURL.indexOf(\"/tree/\") + 6\n", - " const lastSlashIndex = pageURL.lastIndexOf(\"/\")\n", - " const notebookDir = pageURL.substring(treeIndex, lastSlashIndex)\n", - " return encodeURI(`${baseURL}/files/${notebookDir}/${url}`)\n", - " } else {\n", - " // We don't know how to determine the notebook path\n", - " console.warn(\"Page url missing '/tree/'. Can't determine notebook path.\")\n", - " return encodeURI(`${baseURL}/files/${url}`)\n", - " }\n", - " } else {\n", - " // We should never get here,\n", - " return encodeURI(url)\n", - " }\n", - " }\n", - "\n", - "\n", - " function convert(config, prefix) {\n", - " const urlProp = prefix ? prefix + \"URL\" : \"url\"\n", - " const pathProp = prefix ? prefix + \"Path\" : \"path\"\n", - " if (config[pathProp]) {\n", - " config[urlProp] = createNotebookFile(config[pathProp])\n", - " } else if (config[urlProp]) {\n", - " config[urlProp] = convertURL(config[urlProp])\n", - " }\n", - " }\n", - "\n", - "\n", - " class Queue {\n", - " constructor() {\n", - " this.elements = []\n", - " }\n", - "\n", - " enqueue(e) {\n", - " this.elements.push(e)\n", - " }\n", - "\n", - " dequeue() {\n", - " return this.elements.shift()\n", - " }\n", - "\n", - " isEmpty() {\n", - " return this.elements.length == 0\n", - " }\n", - "\n", - " peek() {\n", - " return !this.isEmpty() ? this.elements[0] : undefined\n", - " }\n", - "\n", - " length() {\n", - " return this.elements.length\n", - " }\n", - " }\n", - "\n", - " window.igv.MessageHandler = new MessageHandler()\n", - "\n", - " function download(filename, text) {\n", - "\n", - " const data = URL.createObjectURL(new Blob([text], {type: \"application/octet-stream\"}))\n", - " const element = document.createElement('a')\n", - " element.setAttribute('href', data)\n", - " element.setAttribute('download', filename)\n", - " element.style.display = 'none'\n", - " document.body.appendChild(element)\n", - " element.click()\n", - " document.body.removeChild(element)\n", - " }\n", - "\n", - " async function shortenURL(url) {\n", - " const endpoint = \"https://2et6uxfezb.execute-api.us-east-1.amazonaws.com/dev/tinyurl/\"\n", - " const enc = encodeURIComponent(url)\n", - " const response = await fetch(`${endpoint}${enc}`)\n", - " if (response.ok) {\n", - " return response.text()\n", - " } else {\n", - " throw new Error(response.statusText)\n", - " }\n", - " }\n", - "\n", - " console.log(\"igv.MessageHandler installed\")\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Mock objects to emulate the browser \"File\" class for use with Jupyter and Colab notebooks. These objects delegate\n", - " * actual file reading to python.\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " igv.createNotebookLocalFile = function (options) {\n", - " if (isColab) {\n", - " return new ColabLocalFile(options)\n", - " } else if (isNotebook) {\n", - " return new JupyterLocalFile(options)\n", - " } else {\n", - " return undefined; //TODO -- throw error?\n", - " }\n", - " }\n", - "\n", - "\n", - " // Start up a Comm object if in a Jupyter Notebook environment (i.e. not Colab or JupyterLab).\n", - " let comm\n", - " const pendingRequests = new Map()\n", - " if (isNotebook) {\n", - " console.log('registering comm')\n", - " comm = Jupyter.notebook.kernel.comm_manager.new_comm('file_request', {})\n", - " // Register a handler\n", - " comm.on_msg(function (msg) {\n", - " const id = msg.content.data.id\n", - " const data = msg.content.data.data\n", - " pendingRequests.set(id, data)\n", - " })\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Jupyter notebooks. File reading is delegated to python via Comms messaging.\n", - " * Polling is used to synchronize the async message passing.\n", - " *\n", - " * NOTE: This will not work for JupyterLab\n", - " */\n", - " class JupyterLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'JupyterLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new JupyterLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as binary data.\n", - " *\n", - " * @returns {Promise<*>}\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const id = uniqueID()\n", - " const path = this.path\n", - " const promise = new Promise((resolve, reject) => {\n", - " let count = 0\n", - "\n", - " function poll() {\n", - "\n", - " if (count > 100) {\n", - " console.error(`error reading ${path}: timed out`)\n", - " reject(`error reading ${path}: timed out`)\n", - " }\n", - "\n", - " count++\n", - " if (pendingRequests.has(id)) {\n", - " const data = pendingRequests.get(id)\n", - " const dataString = atob(data)\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " pendingRequests.delete(id)\n", - " resolve(bytes.buffer)\n", - " } else {\n", - " setTimeout(poll, 100)\n", - " }\n", - " }\n", - "\n", - " poll()\n", - " })\n", - "\n", - " const msg = (this.start === undefined) ?\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer'} :\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer', 'start': this.start, 'end': this.end}\n", - "\n", - " comm.send(msg)\n", - "\n", - " return promise\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Colab environments.\n", - " */\n", - " class ColabLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'ColabLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new ColabLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as\n", - " * binary data.\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const args = (this.start === undefined) ?\n", - " [this.path] :\n", - " [this.path, this.start.toString(), this.end.toString()]\n", - "\n", - " const result = await google.colab.kernel.invokeFunction(\n", - " 'ReadFile', // The callback name.\n", - " args, // The arguments.\n", - " {}) // kwargs\n", - " const data = result.data[\"text/plain\"]\n", - " const dataString = atob(data.substring(2, data.length - 1))\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " return bytes.buffer\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " let counter = 0\n", - "\n", - " function uniqueID() {\n", - " return `${Math.random()}-${counter++}`\n", - " }\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "window.igv.MessageHandler.on({\"id\": \"jb_4232033\", \"command\": \"createBrowser\", \"data\": {\"reference\": {\"id\": \"AgamP4\", \"name\": \"Anopheles gambiae (PEST)\", \"fastaURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa.fai\", \"tracks\": [{\"name\": \"Genes\", \"type\": \"annotation\", \"format\": \"gff3\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_BASEFEATURES_AgamP4.12.gff3.gz\", \"indexed\": false}]}, \"locus\": \"2L:2,422,600-2,422,700\", \"id\": \"jb_4232033\"}})" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ag3.igv(region=\"2L:2,422,600-2,422,700\")" ] }, { "cell_type": "code", - "execution_count": 4, - "id": "72d27502", + "execution_count": null, + "id": "3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " \r" - ] - }, - { - "data": { - "application/javascript": [ - "window.igv=function(){\"use strict\";function e(e){return t(\"div\",e)}function t(e,t){const i=document.createElement(e);return t&&(t.class&&i.classList.add(t.class),t.id&&(i.id=t.id),t.style&&function(e,t){for(let i of Object.keys(t))e.style[i]=t[i]}(i,t.style)),i}function i(e){const t=getComputedStyle(e);\"none\"!==t.display&&(e._initialDisplay=t.display),e.style.display=\"none\"}function n(e){if(\"none\"===getComputedStyle(e).display){const t=e._initialDisplay||\"block\";e.style.display=t}}function r(e){if(e.type.startsWith(\"touch\")){const t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.pageX,y:e.pageY}}function s(){return(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}let o=(e,{clientX:t,clientY:i})=>{const{left:n,top:r,width:s,height:o}=e.getBoundingClientRect(),a=t-n,c=i-r;return{x:a,y:c,xNormalized:a/s,yNormalized:c/o,width:s,height:o}};function a(e,t){const{clientX:i,clientY:n}=e;return o(t,{clientX:i,clientY:n})}class c{constructor(){this.elem=t(\"div\",{class:\"igv-ui-panel-column\"})}add(t){if(t instanceof Node)this.elem.append(t);else if(\"object\"==typeof t)this.elem.append(t.elem);else{const i=e();i.innerHTML=t,this.elem.append(i),this.html=i}}}function l(e,t){return h(e,t)}function h(e,t){t=t||\"currentColor\";let i=d[e];i||(console.error(`No icon named: ${e}`),i=d.question);const n=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");n.setAttributeNS(null,\"viewBox\",\"0 0 \"+i[0]+\" \"+i[1]);const r=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");return r.setAttributeNS(null,\"fill\",t),r.setAttributeNS(null,\"d\",i[4]),n.appendChild(r),n}const d={check:[512,512,[],\"f00c\",\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"],cog:[512,512,[],\"f013\",\"M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z\"],exclamation:[192,512,[],\"f12a\",\"M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z\"],\"exclamation-circle\":[512,512,[],\"f06a\",\"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],\"exclamation-triangle\":[576,512,[],\"f071\",\"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],minus:[448,512,[],\"f068\",\"M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z\"],\"minus-circle\":[512,512,[],\"f056\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z\"],\"minus-square\":[448,512,[],\"f146\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z\"],plus:[448,512,[],\"f067\",\"M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z\"],\"plus-circle\":[512,512,[],\"f055\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],\"plus-square\":[448,512,[],\"f0fe\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],question:[384,512,[],\"f128\",\"M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z\"],save:[448,512,[],\"f0c7\",\"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z\"],search:[512,512,[],\"f002\",\"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z\"],share:[512,512,[],\"f064\",\"M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z\"],spinner:[512,512,[],\"f110\",\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"],square:[448,512,[],\"f0c8\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z\"],\"square-full\":[512,512,[],\"f45c\",\"M512 512H0V0h512v512z\"],times:[384,512,[],\"f00d\",\"M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z\"],\"times-circle\":[512,512,[],\"f057\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z\"],wrench:[512,512,[],\"f0ad\",\"M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z\"]};function u(e,t){var i=document.createElement(\"div\");e.appendChild(i),i.appendChild(l(\"times\")),i.addEventListener(\"click\",(function(e){e.preventDefault(),e.stopPropagation(),t()}))}let f;function p(e,t,i){t.addEventListener(\"mousedown\",function(e){e.stopPropagation(),e.preventDefault();const t=g.bind(this),n=m.bind(this),r=getComputedStyle(this),s=this.getBoundingClientRect();f={constraint:i,dragFunction:t,dragEndFunction:n,screenX:e.screenX,screenY:e.screenY,minDy:-s.top,minDx:-s.left,top:parseInt(r.top.replace(\"px\",\"\")),left:parseInt(r.left.replace(\"px\",\"\"))},document.addEventListener(\"mousemove\",t),document.addEventListener(\"mouseup\",n),document.addEventListener(\"mouseleave\",n),document.addEventListener(\"mouseexit\",n)}.bind(e))}function g(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=Math.max(f.minDx,e.screenX-f.screenX),i=Math.max(f.minDy,e.screenY-f.screenY),n=f.left+t,r=f.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function m(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=f.dragFunction,i=f.dragEndFunction;document.removeEventListener(\"mousemove\",t),document.removeEventListener(\"mouseup\",i),document.removeEventListener(\"mouseleave\",i),document.removeEventListener(\"mouseexit\",i),f=void 0}class w{constructor({parent:t,label:n,content:r,okHandler:s,cancelHandler:o}){this.parent=t;const a=()=>{i(this.elem),\"function\"==typeof o&&o(this)};this.elem=e(),this.elem.classList.add(\"igv-ui-generic-dialog-container\",\"igv-ui-center-fixed\");const c=e({class:\"igv-ui-generic-dialog-header\"});if(this.elem.appendChild(c),u(c,a),n){const t=e({class:\"igv-ui-dialog-one-liner\"});this.elem.appendChild(t),t.innerHTML=n}r.elem.style.margin=\"16px\",this.elem.appendChild(r.elem),this.content=r;const l=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.elem.appendChild(l),this.ok=e(),l.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),l.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",this.callback=void 0,this.ok.addEventListener(\"click\",(e=>{i(this.elem),\"function\"==typeof s?s(this):this.callback&&\"function\"==typeof this.callback&&this.callback(this)})),this.cancel.addEventListener(\"click\",a),p(this.elem,c),this.elem.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation()}))}present(e,t){if(e.label&&this.label&&(this.label.textContent=e.label),e.html){this.content.html.innerHTML=e.html}if(e.text){this.content.html.innerText=e.text}e.value&&this.input&&(this.input.value=e.value),e.callback&&(this.callback=e.callback),n(this.elem)}clampLocation(e,t){let i=this.elem.getBoundingClientRect(),n=this.parent.getBoundingClientRect();const r=Math.min(Math.max(t,n.y),n.y+n.height-i.height),s=Math.min(Math.max(e,n.x),n.x+n.width-i.width);this.elem.style.left=s+\"px\",this.elem.style.top=r+\"px\"}}\n", - "/*!\n", - " * jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\n", - " * https://jquery.com/\n", - " *\n", - " * Includes Sizzle.js\n", - " * https://sizzlejs.com/\n", - " *\n", - " * Copyright JS Foundation and other contributors\n", - " * Released under the MIT license\n", - " * https://jquery.org/license\n", - " *\n", - " * Date: 2018-01-20T17:24Z\n", - " */var b=[],F=window.document,v=Object.getPrototypeOf,y=b.slice,A=b.concat,C=b.push,_=b.indexOf,x={},k=x.toString,I=x.hasOwnProperty,S=I.toString,E=S.call(Object),N={},B=function(e){return\"function\"==typeof e&&\"number\"!=typeof e.nodeType},M=function(e){return null!=e&&e===e.window},R={type:!0,src:!0,noModule:!0};function D(e,t,i){var n,r=(t=t||F).createElement(\"script\");if(r.text=e,i)for(n in R)i[n]&&(r[n]=i[n]);t.head.appendChild(r).parentNode.removeChild(r)}function T(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?x[k.call(e)]||\"object\":typeof e}var L=\"3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\",z=function(e,t){return new z.fn.init(e,t)},H=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;function P(e){var t=!!e&&\"length\"in e&&e.length,i=T(e);return!B(e)&&!M(e)&&(\"array\"===i||0===t||\"number\"==typeof t&&t>0&&t-1 in e)}z.fn=z.prototype={jquery:L,constructor:z,length:0,toArray:function(){return y.call(this)},get:function(e){return null==e?y.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=z.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return z.each(this,e)},map:function(e){return this.pushStack(z.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(y.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i+~]|\"+L+\")\"+L+\"*\"),V=new RegExp(\"=\"+L+\"*([^\\\\]'\\\"]*?)\"+L+\"*\\\\]\",\"g\"),j=new RegExp(P),W=new RegExp(\"^\"+z+\"$\"),G={ID:new RegExp(\"^#(\"+z+\")\"),CLASS:new RegExp(\"^\\\\.(\"+z+\")\"),TAG:new RegExp(\"^(\"+z+\"|[*])\"),ATTR:new RegExp(\"^\"+H),PSEUDO:new RegExp(\"^\"+P),CHILD:new RegExp(\"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\"+L+\"*(even|odd|(([+-]|)(\\\\d*)n|)\"+L+\"*(?:([+-]|)\"+L+\"*(\\\\d+)|))\"+L+\"*\\\\)|)\",\"i\"),bool:new RegExp(\"^(?:\"+T+\")$\",\"i\"),needsContext:new RegExp(\"^\"+L+\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\"+L+\"*((?:-\\\\d)?\\\\d*)\"+L+\"*\\\\)|)(?=[^-]|$)\",\"i\")},$=/^(?:input|select|textarea|button)$/i,K=/^h\\d$/i,Y=/^[^{]+\\{\\s*\\[native \\w/,X=/^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,Z=/[+~]/,J=new RegExp(\"\\\\\\\\([\\\\da-f]{1,6}\"+L+\"?|(\"+L+\")|.)\",\"ig\"),ee=function(e,t,i){var n=\"0x\"+t-65536;return n!=n||i?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},te=/([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\0-\\x1f\\x7f-\\uFFFF\\w-]/g,ie=function(e,t){return t?\"\\0\"===e?\"�\":e.slice(0,-1)+\"\\\\\"+e.charCodeAt(e.length-1).toString(16)+\" \":\"\\\\\"+e},ne=function(){u()},re=we((function(e){return!0===e.disabled&&(\"form\"in e||\"label\"in e)}),{dir:\"parentNode\",next:\"legend\"});try{M.apply(E=R.call(y.childNodes),y.childNodes),E[y.childNodes.length].nodeType}catch(e){M={apply:E.length?function(e,t){B.apply(e,R.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function se(e,t,n,r){var s,a,l,h,d,p,w,b=t&&t.ownerDocument,A=t?t.nodeType:9;if(n=n||[],\"string\"!=typeof e||!e||1!==A&&9!==A&&11!==A)return n;if(!r&&((t?t.ownerDocument||t:y)!==f&&u(t),t=t||f,g)){if(11!==A&&(d=X.exec(e)))if(s=d[1]){if(9===A){if(!(l=t.getElementById(s)))return n;if(l.id===s)return n.push(l),n}else if(b&&(l=b.getElementById(s))&&F(t,l)&&l.id===s)return n.push(l),n}else{if(d[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=d[3])&&i.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(i.qsa&&!k[e+\" \"]&&(!m||!m.test(e))){if(1!==A)b=t,w=e;else if(\"object\"!==t.nodeName.toLowerCase()){for((h=t.getAttribute(\"id\"))?h=h.replace(te,ie):t.setAttribute(\"id\",h=v),a=(p=o(e)).length;a--;)p[a]=\"#\"+h+\" \"+me(p[a]);w=p.join(\",\"),b=Z.test(e)&&pe(t.parentNode)||t}if(w)try{return M.apply(n,b.querySelectorAll(w)),n}catch(e){}finally{h===v&&t.removeAttribute(\"id\")}}}return c(e.replace(U,\"$1\"),t,n,r)}function oe(){var e=[];return function t(i,r){return e.push(i+\" \")>n.cacheLength&&delete t[e.shift()],t[i+\" \"]=r}}function ae(e){return e[v]=!0,e}function ce(e){var t=f.createElement(\"fieldset\");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function he(e){return function(t){return\"input\"===t.nodeName.toLowerCase()&&t.type===e}}function de(e){return function(t){var i=t.nodeName.toLowerCase();return(\"input\"===i||\"button\"===i)&&t.type===e}}function ue(e){return function(t){return\"form\"in t?t.parentNode&&!1===t.disabled?\"label\"in t?\"label\"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:\"label\"in t&&t.disabled===e}}function fe(e){return ae((function(t){return t=+t,ae((function(i,n){for(var r,s=e([],i.length,t),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=se.support={},s=se.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&\"HTML\"!==t.nodeName},u=se.setDocument=function(e){var t,r,o=e?e.ownerDocument||e:y;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),y!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener(\"unload\",ne,!1):r.attachEvent&&r.attachEvent(\"onunload\",ne)),i.attributes=ce((function(e){return e.className=\"i\",!e.getAttribute(\"className\")})),i.getElementsByTagName=ce((function(e){return e.appendChild(f.createComment(\"\")),!e.getElementsByTagName(\"*\").length})),i.getElementsByClassName=Y.test(f.getElementsByClassName),i.getById=ce((function(e){return p.appendChild(e).id=v,!f.getElementsByName||!f.getElementsByName(v).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){return e.getAttribute(\"id\")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode(\"id\");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,r,s=t.getElementById(e);if(s){if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s];for(r=t.getElementsByName(e),n=0;s=r[n++];)if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],r=0,s=t.getElementsByTagName(e);if(\"*\"===e){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},w=[],m=[],(i.qsa=Y.test(f.querySelectorAll))&&(ce((function(e){p.appendChild(e).innerHTML=\"\",e.querySelectorAll(\"[msallowcapture^='']\").length&&m.push(\"[*^$]=\"+L+\"*(?:''|\\\"\\\")\"),e.querySelectorAll(\"[selected]\").length||m.push(\"\\\\[\"+L+\"*(?:value|\"+T+\")\"),e.querySelectorAll(\"[id~=\"+v+\"-]\").length||m.push(\"~=\"),e.querySelectorAll(\":checked\").length||m.push(\":checked\"),e.querySelectorAll(\"a#\"+v+\"+*\").length||m.push(\".#.+[+~]\")})),ce((function(e){e.innerHTML=\"\";var t=f.createElement(\"input\");t.setAttribute(\"type\",\"hidden\"),e.appendChild(t).setAttribute(\"name\",\"D\"),e.querySelectorAll(\"[name=d]\").length&&m.push(\"name\"+L+\"*[*^$|!~]?=\"),2!==e.querySelectorAll(\":enabled\").length&&m.push(\":enabled\",\":disabled\"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(\":disabled\").length&&m.push(\":enabled\",\":disabled\"),e.querySelectorAll(\"*,:x\"),m.push(\",.*:\")}))),(i.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ce((function(e){i.disconnectedMatch=b.call(e,\"*\"),b.call(e,\"[s!='']:x\"),w.push(\"!=\",P)})),m=m.length&&new RegExp(m.join(\"|\")),w=w.length&&new RegExp(w.join(\"|\")),t=Y.test(p.compareDocumentPosition),F=t||Y.test(p.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},I=t?function(e,t){if(e===t)return d=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e===f||e.ownerDocument===y&&F(y,e)?-1:t===f||t.ownerDocument===y&&F(y,t)?1:h?D(h,e)-D(h,t):0:4&n?-1:1)}:function(e,t){if(e===t)return d=!0,0;var i,n=0,r=e.parentNode,s=t.parentNode,o=[e],a=[t];if(!r||!s)return e===f?-1:t===f?1:r?-1:s?1:h?D(h,e)-D(h,t):0;if(r===s)return le(e,t);for(i=e;i=i.parentNode;)o.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?le(o[n],a[n]):o[n]===y?-1:a[n]===y?1:0},f):f},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&u(e),t=t.replace(V,\"='$1']\"),i.matchesSelector&&g&&!k[t+\" \"]&&(!w||!w.test(t))&&(!m||!m.test(t)))try{var n=b.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return se(t,f,null,[e]).length>0},se.contains=function(e,t){return(e.ownerDocument||e)!==f&&u(e),F(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!==f&&u(e);var r=n.attrHandle[t.toLowerCase()],s=r&&S.call(n.attrHandle,t.toLowerCase())?r(e,t,!g):void 0;return void 0!==s?s:i.attributes||!g?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},se.escape=function(e){return(e+\"\").replace(te,ie)},se.error=function(e){throw new Error(\"Syntax error, unrecognized expression: \"+e)},se.uniqueSort=function(e){var t,n=[],r=0,s=0;if(d=!i.detectDuplicates,h=!i.sortStable&&e.slice(0),e.sort(I),d){for(;t=e[s++];)t===e[s]&&(r=n.push(s));for(;r--;)e.splice(n[r],1)}return h=null,e},r=se.getText=function(e){var t,i=\"\",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if(\"string\"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=r(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n++];)i+=r(t);return i},n=se.selectors={cacheLength:50,createPseudo:ae,match:G,attrHandle:{},find:{},relative:{\">\":{dir:\"parentNode\",first:!0},\" \":{dir:\"parentNode\"},\"+\":{dir:\"previousSibling\",first:!0},\"~\":{dir:\"previousSibling\"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(J,ee),e[3]=(e[3]||e[4]||e[5]||\"\").replace(J,ee),\"~=\"===e[2]&&(e[3]=\" \"+e[3]+\" \"),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),\"nth\"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(\"even\"===e[3]||\"odd\"===e[3])),e[5]=+(e[7]+e[8]||\"odd\"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||\"\":i&&j.test(i)&&(t=o(i,!0))&&(t=i.indexOf(\")\",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(J,ee).toLowerCase();return\"*\"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=_[e+\" \"];return t||(t=new RegExp(\"(^|\"+L+\")\"+e+\"(\"+L+\"|$)\"))&&_(e,(function(e){return t.test(\"string\"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute(\"class\")||\"\")}))},ATTR:function(e,t,i){return function(n){var r=se.attr(n,e);return null==r?\"!=\"===t:!t||(r+=\"\",\"=\"===t?r===i:\"!=\"===t?r!==i:\"^=\"===t?i&&0===r.indexOf(i):\"*=\"===t?i&&r.indexOf(i)>-1:\"$=\"===t?i&&r.slice(-i.length)===i:\"~=\"===t?(\" \"+r.replace(O,\" \")+\" \").indexOf(i)>-1:\"|=\"===t&&(r===i||r.slice(0,i.length+1)===i+\"-\"))}},CHILD:function(e,t,i,n,r){var s=\"nth\"!==e.slice(0,3),o=\"last\"!==e.slice(-4),a=\"of-type\"===t;return 1===n&&0===r?function(e){return!!e.parentNode}:function(t,i,c){var l,h,d,u,f,p,g=s!==o?\"nextSibling\":\"previousSibling\",m=t.parentNode,w=a&&t.nodeName.toLowerCase(),b=!c&&!a,F=!1;if(m){if(s){for(;g;){for(u=t;u=u[g];)if(a?u.nodeName.toLowerCase()===w:1===u.nodeType)return!1;p=g=\"only\"===e&&!p&&\"nextSibling\"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&b){for(F=(f=(l=(h=(d=(u=m)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1])&&l[2],u=f&&m.childNodes[f];u=++f&&u&&u[g]||(F=f=0)||p.pop();)if(1===u.nodeType&&++F&&u===t){h[e]=[A,f,F];break}}else if(b&&(F=f=(l=(h=(d=(u=t)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1]),!1===F)for(;(u=++f&&u&&u[g]||(F=f=0)||p.pop())&&((a?u.nodeName.toLowerCase()!==w:1!==u.nodeType)||!++F||(b&&((h=(d=u[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]=[A,F]),u!==t)););return(F-=r)===n||F%n==0&&F/n>=0}}},PSEUDO:function(e,t){var i,r=n.pseudos[e]||n.setFilters[e.toLowerCase()]||se.error(\"unsupported pseudo: \"+e);return r[v]?r(t):r.length>1?(i=[e,e,\"\",t],n.setFilters.hasOwnProperty(e.toLowerCase())?ae((function(e,i){for(var n,s=r(e,t),o=s.length;o--;)e[n=D(e,s[o])]=!(i[n]=s[o])})):function(e){return r(e,0,i)}):r}},pseudos:{not:ae((function(e){var t=[],i=[],n=a(e.replace(U,\"$1\"));return n[v]?ae((function(e,t,i,r){for(var s,o=n(e,null,r,[]),a=e.length;a--;)(s=o[a])&&(e[a]=!(t[a]=s))})):function(e,r,s){return t[0]=e,n(t,null,s,i),t[0]=null,!i.pop()}})),has:ae((function(e){return function(t){return se(e,t).length>0}})),contains:ae((function(e){return e=e.replace(J,ee),function(t){return(t.textContent||t.innerText||r(t)).indexOf(e)>-1}})),lang:ae((function(e){return W.test(e||\"\")||se.error(\"unsupported lang: \"+e),e=e.replace(J,ee).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute(\"xml:lang\")||t.getAttribute(\"lang\"))return(i=i.toLowerCase())===e||0===i.indexOf(e+\"-\")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ue(!1),disabled:ue(!0),checked:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&!!e.checked||\"option\"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return $.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&\"button\"===e.type||\"button\"===t},text:function(e){var t;return\"input\"===e.nodeName.toLowerCase()&&\"text\"===e.type&&(null==(t=e.getAttribute(\"type\"))||\"text\"===t.toLowerCase())},first:fe((function(){return[0]})),last:fe((function(e,t){return[t-1]})),eq:fe((function(e,t,i){return[i<0?i+t:i]})),even:fe((function(e,t){for(var i=0;i=0;)e.push(n);return e})),gt:fe((function(e,t,i){for(var n=i<0?i+t:i;++n1?function(t,i,n){for(var r=e.length;r--;)if(!e[r](t,i,n))return!1;return!0}:e[0]}function Fe(e,t,i,n,r){for(var s,o=[],a=0,c=e.length,l=null!=t;a-1&&(s[l]=!(o[l]=d))}}else w=Fe(w===o?w.splice(p,w.length):w),r?r(null,o,w,c):M.apply(o,w)}))}function ye(e){for(var t,i,r,s=e.length,o=n.relative[e[0].type],a=o||n.relative[\" \"],c=o?1:0,h=we((function(e){return e===t}),a,!0),d=we((function(e){return D(t,e)>-1}),a,!0),u=[function(e,i,n){var r=!o&&(n||i!==l)||((t=i).nodeType?h(e,i,n):d(e,i,n));return t=null,r}];c1&&be(u),c>1&&me(e.slice(0,c-1).concat({value:\" \"===e[c-2].type?\"*\":\"\"})).replace(U,\"$1\"),i,c0,r=e.length>0,s=function(s,o,a,c,h){var d,p,m,w=0,b=\"0\",F=s&&[],v=[],y=l,C=s||r&&n.find.TAG(\"*\",h),_=A+=null==y?1:Math.random()||.1,x=C.length;for(h&&(l=o===f||o||h);b!==x&&null!=(d=C[b]);b++){if(r&&d){for(p=0,o||d.ownerDocument===f||(u(d),a=!g);m=e[p++];)if(m(d,o||f,a)){c.push(d);break}h&&(A=_)}i&&((d=!m&&d)&&w--,s&&F.push(d))}if(w+=b,i&&b!==w){for(p=0;m=t[p++];)m(F,v,o,a);if(s){if(w>0)for(;b--;)F[b]||v[b]||(v[b]=N.call(c));v=Fe(v)}M.apply(c,v),h&&!s&&v.length>0&&w+t.length>1&&se.uniqueSort(c)}return h&&(A=_,l=y),F};return i?ae(s):s}(s,r)),a.selector=e}return a},c=se.select=function(e,t,i,r){var s,c,l,h,d,u=\"function\"==typeof e&&e,f=!r&&o(e=u.selector||e);if(i=i||[],1===f.length){if((c=f[0]=f[0].slice(0)).length>2&&\"ID\"===(l=c[0]).type&&9===t.nodeType&&g&&n.relative[c[1].type]){if(!(t=(n.find.ID(l.matches[0].replace(J,ee),t)||[])[0]))return i;u&&(t=t.parentNode),e=e.slice(c.shift().value.length)}for(s=G.needsContext.test(e)?0:c.length;s--&&(l=c[s],!n.relative[h=l.type]);)if((d=n.find[h])&&(r=d(l.matches[0].replace(J,ee),Z.test(c[0].type)&&pe(t.parentNode)||t))){if(c.splice(s,1),!(e=r.length&&me(c)))return M.apply(i,r),i;break}}return(u||a(e,f))(r,t,!g,i,!t||Z.test(e)&&pe(t.parentNode)||t),i},i.sortStable=v.split(\"\").sort(I).join(\"\")===v,i.detectDuplicates=!!d,u(),se}(window);z.find=O,z.expr=O.selectors,z.expr[\":\"]=z.expr.pseudos,z.uniqueSort=z.unique=O.uniqueSort,z.text=O.getText,z.isXMLDoc=O.isXML,z.contains=O.contains,z.escapeSelector=O.escape;var U=function(e,t,i){for(var n=[],r=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&z(e).is(i))break;n.push(e)}return n},q=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},Q=z.expr.match.needsContext;function V(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var j=/^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i;function W(e,t,i){return B(t)?z.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?z.grep(e,(function(e){return e===t!==i})):\"string\"!=typeof t?z.grep(e,(function(e){return _.call(t,e)>-1!==i})):z.filter(t,e,i)}z.filter=function(e,t,i){var n=t[0];return i&&(e=\":not(\"+e+\")\"),1===t.length&&1===n.nodeType?z.find.matchesSelector(n,e)?[n]:[]:z.find.matches(e,z.grep(t,(function(e){return 1===e.nodeType})))},z.fn.extend({find:function(e){var t,i,n=this.length,r=this;if(\"string\"!=typeof e)return this.pushStack(z(e).filter((function(){for(t=0;t1?z.uniqueSort(i):i},filter:function(e){return this.pushStack(W(this,e||[],!1))},not:function(e){return this.pushStack(W(this,e||[],!0))},is:function(e){return!!W(this,\"string\"==typeof e&&Q.test(e)?z(e):e||[],!1).length}});var G,$=/^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/;(z.fn.init=function(e,t,i){var n,r;if(!e)return this;if(i=i||G,\"string\"==typeof e){if(!(n=\"<\"===e[0]&&\">\"===e[e.length-1]&&e.length>=3?[null,e,null]:$.exec(e))||!n[1]&&t)return!t||t.jquery?(t||i).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof z?t[0]:t,z.merge(this,z.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:F,!0)),j.test(n[1])&&z.isPlainObject(t))for(n in t)B(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return(r=F.getElementById(n[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):B(e)?void 0!==i.ready?i.ready(e):e(z):z.makeArray(e,this)}).prototype=z.fn,G=z(F);var K=/^(?:parents|prev(?:Until|All))/,Y={children:!0,contents:!0,next:!0,prev:!0};function X(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}z.fn.extend({has:function(e){var t=z(e,this),i=t.length;return this.filter((function(){for(var e=0;e-1:1===i.nodeType&&z.find.matchesSelector(i,e))){s.push(i);break}return this.pushStack(s.length>1?z.uniqueSort(s):s)},index:function(e){return e?\"string\"==typeof e?_.call(z(e),this[0]):_.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(z.uniqueSort(z.merge(this.get(),z(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),z.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return U(e,\"parentNode\")},parentsUntil:function(e,t,i){return U(e,\"parentNode\",i)},next:function(e){return X(e,\"nextSibling\")},prev:function(e){return X(e,\"previousSibling\")},nextAll:function(e){return U(e,\"nextSibling\")},prevAll:function(e){return U(e,\"previousSibling\")},nextUntil:function(e,t,i){return U(e,\"nextSibling\",i)},prevUntil:function(e,t,i){return U(e,\"previousSibling\",i)},siblings:function(e){return q((e.parentNode||{}).firstChild,e)},children:function(e){return q(e.firstChild)},contents:function(e){return V(e,\"iframe\")?e.contentDocument:(V(e,\"template\")&&(e=e.content||e),z.merge([],e.childNodes))}},(function(e,t){z.fn[e]=function(i,n){var r=z.map(this,t,i);return\"Until\"!==e.slice(-5)&&(n=i),n&&\"string\"==typeof n&&(r=z.filter(n,r)),this.length>1&&(Y[e]||z.uniqueSort(r),K.test(e)&&r.reverse()),this.pushStack(r)}}));var Z=/[^\\x20\\t\\r\\n\\f]+/g;function J(e){return e}function ee(e){throw e}function te(e,t,i,n){var r;try{e&&B(r=e.promise)?r.call(e).done(t).fail(i):e&&B(r=e.then)?r.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}z.Callbacks=function(e){e=\"string\"==typeof e?function(e){var t={};return z.each(e.match(Z)||[],(function(e,i){t[i]=!0})),t}(e):z.extend({},e);var t,i,n,r,s=[],o=[],a=-1,c=function(){for(r=r||e.once,n=t=!0;o.length;a=-1)for(i=o.shift();++a-1;)s.splice(i,1),i<=a&&a--})),this},has:function(e){return e?z.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i=\"\",this},disabled:function(){return!s},lock:function(){return r=o=[],i||t||(s=i=\"\"),this},locked:function(){return!!r},fireWith:function(e,i){return r||(i=[e,(i=i||[]).slice?i.slice():i],o.push(i),t||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!n}};return l},z.extend({Deferred:function(e){var t=[[\"notify\",\"progress\",z.Callbacks(\"memory\"),z.Callbacks(\"memory\"),2],[\"resolve\",\"done\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),0,\"resolved\"],[\"reject\",\"fail\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),1,\"rejected\"]],i=\"pending\",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return z.Deferred((function(i){z.each(t,(function(t,n){var s=B(e[n[4]])&&e[n[4]];r[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&B(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+\"With\"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,n){var r=0;function s(e,t,i,n){return function(){var o=this,a=arguments,c=function(){var c,l;if(!(e=r&&(i!==ee&&(o=void 0,a=[n]),t.rejectWith(o,a))}};e?l():(z.Deferred.getStackHook&&(l.stackTrace=z.Deferred.getStackHook()),window.setTimeout(l))}}return z.Deferred((function(r){t[0][3].add(s(0,r,B(n)?n:J,r.notifyWith)),t[1][3].add(s(0,r,B(e)?e:J)),t[2][3].add(s(0,r,B(i)?i:ee))})).promise()},promise:function(e){return null!=e?z.extend(e,n):n}},r={};return z.each(t,(function(e,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+\"With\"](this===r?void 0:this,arguments),this},r[s[0]+\"With\"]=o.fireWith})),n.promise(r),e&&e.call(r,r),r},when:function(e){var t=arguments.length,i=t,n=Array(i),r=y.call(arguments),s=z.Deferred(),o=function(e){return function(i){n[e]=this,r[e]=arguments.length>1?y.call(arguments):i,--t||s.resolveWith(n,r)}};if(t<=1&&(te(e,s.done(o(i)).resolve,s.reject,!t),\"pending\"===s.state()||B(r[i]&&r[i].then)))return s.then();for(;i--;)te(r[i],o(i),s.reject);return s.promise()}});var ie=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;z.Deferred.exceptionHook=function(e,t){window.console&&window.console.warn&&e&&ie.test(e.name)&&window.console.warn(\"jQuery.Deferred exception: \"+e.message,e.stack,t)},z.readyException=function(e){window.setTimeout((function(){throw e}))};var ne=z.Deferred();function re(){F.removeEventListener(\"DOMContentLoaded\",re),window.removeEventListener(\"load\",re),z.ready()}z.fn.ready=function(e){return ne.then(e).catch((function(e){z.readyException(e)})),this},z.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--z.readyWait:z.isReady)||(z.isReady=!0,!0!==e&&--z.readyWait>0||ne.resolveWith(F,[z]))}}),z.ready.then=ne.then,\"complete\"===F.readyState||\"loading\"!==F.readyState&&!F.documentElement.doScroll?window.setTimeout(z.ready):(F.addEventListener(\"DOMContentLoaded\",re),window.addEventListener(\"load\",re));var se=function(e,t,i,n,r,s,o){var a=0,c=e.length,l=null==i;if(\"object\"===T(i))for(a in r=!0,i)se(e,t,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,B(n)||(o=!0),l&&(o?(t.call(e,n),t=null):(l=t,t=function(e,t,i){return l.call(z(e),i)})),t))for(;a1,null,!0)},removeData:function(e){return this.each((function(){fe.remove(this,e)}))}}),z.extend({queue:function(e,t,i){var n;if(e)return t=(t||\"fx\")+\"queue\",n=ue.get(e,t),i&&(!n||Array.isArray(i)?n=ue.access(e,t,z.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||\"fx\";var i=z.queue(e,t),n=i.length,r=i.shift(),s=z._queueHooks(e,t);\"inprogress\"===r&&(r=i.shift(),n--),r&&(\"fx\"===t&&i.unshift(\"inprogress\"),delete s.stop,r.call(e,(function(){z.dequeue(e,t)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(e,t){var i=t+\"queueHooks\";return ue.get(e,i)||ue.access(e,i,{empty:z.Callbacks(\"once memory\").add((function(){ue.remove(e,[t+\"queue\",i])}))})}}),z.fn.extend({queue:function(e,t){var i=2;return\"string\"!=typeof e&&(t=e,e=\"fx\",i--),arguments.length\\x20\\t\\r\\n\\f]+)/i,Ie=/^$|^module$|\\/(?:java|ecma)script/i,Se={option:[1,\"\"],thead:[1,\"\",\"
\"],col:[2,\"\",\"
\"],tr:[2,\"\",\"
\"],td:[3,\"\",\"
\"],_default:[0,\"\",\"\"]};function Ee(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||\"*\"):void 0!==e.querySelectorAll?e.querySelectorAll(t||\"*\"):[],void 0===t||t&&V(e,t)?z.merge([e],i):i}function Ne(e,t){for(var i=0,n=e.length;i-1)r&&r.push(s);else if(l=z.contains(s.ownerDocument,s),o=Ee(d.appendChild(s),\"script\"),l&&Ne(o),i)for(h=0;s=o[h++];)Ie.test(s.type||\"\")&&i.push(s);return d}!function(){var e=F.createDocumentFragment().appendChild(F.createElement(\"div\")),t=F.createElement(\"input\");t.setAttribute(\"type\",\"radio\"),t.setAttribute(\"checked\",\"checked\"),t.setAttribute(\"name\",\"t\"),e.appendChild(t),N.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML=\"\",N.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var Re=F.documentElement,De=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Le=/^([^.]*)(?:\\.(.+)|)/;function ze(){return!0}function He(){return!1}function Pe(){try{return F.activeElement}catch(e){}}function Oe(e,t,i,n,r,s){var o,a;if(\"object\"==typeof t){for(a in\"string\"!=typeof i&&(n=n||i,i=void 0),t)Oe(e,a,i,n,t[a],s);return e}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&(\"string\"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=He;else if(!r)return e;return 1===s&&(o=r,r=function(e){return z().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=z.guid++)),e.each((function(){z.event.add(this,t,r,n,i)}))}z.event={global:{},add:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.get(e);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&z.find.matchesSelector(Re,r),i.guid||(i.guid=z.guid++),(c=m.events)||(c=m.events={}),(o=m.handle)||(o=m.handle=function(t){return void 0!==z&&z.event.triggered!==t.type?z.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f&&(d=z.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,d=z.event.special[f]||{},h=z.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&z.expr.match.needsContext.test(r),namespace:p.join(\".\")},s),(u=c[f])||((u=c[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,n,p,o)||e.addEventListener&&e.addEventListener(f,o)),d.add&&(d.add.call(e,h),h.handler.guid||(h.handler.guid=i.guid)),r?u.splice(u.delegateCount++,0,h):u.push(h),z.event.global[f]=!0)},remove:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.hasData(e)&&ue.get(e);if(m&&(c=m.events)){for(l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)if(f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f){for(d=z.event.special[f]||{},u=c[f=(n?d.delegateType:d.bindType)||f]||[],a=a[2]&&new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"),o=s=u.length;s--;)h=u[s],!r&&g!==h.origType||i&&i.guid!==h.guid||a&&!a.test(h.namespace)||n&&n!==h.selector&&(\"**\"!==n||!h.selector)||(u.splice(s,1),h.selector&&u.delegateCount--,d.remove&&d.remove.call(e,h));o&&!u.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||z.removeEvent(e,f,m.handle),delete c[f])}else for(f in c)z.event.remove(e,f+t[l],i,n,!0);z.isEmptyObject(c)&&ue.remove(e,\"handle events\")}},dispatch:function(e){var t,i,n,r,s,o,a=z.event.fix(e),c=new Array(arguments.length),l=(ue.get(this,\"events\")||{})[a.type]||[],h=z.event.special[a.type]||{};for(c[0]=a,t=1;t=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&(\"click\"!==e.type||!0!==l.disabled)){for(s=[],o={},i=0;i-1:z.find(r,this,null,[l]).length),o[r]&&s.push(n);s.length&&a.push({elem:l,handlers:s})}return l=this,c\\x20\\t\\r\\n\\f]*)[^>]*)\\/>/gi,qe=/\\s*$/g;function je(e,t){return V(e,\"table\")&&V(11!==t.nodeType?t:t.firstChild,\"tr\")&&z(e).children(\"tbody\")[0]||e}function We(e){return e.type=(null!==e.getAttribute(\"type\"))+\"/\"+e.type,e}function Ge(e){return\"true/\"===(e.type||\"\").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute(\"type\"),e}function $e(e,t){var i,n,r,s,o,a,c,l;if(1===t.nodeType){if(ue.hasData(e)&&(s=ue.access(e),o=ue.set(t,s),l=s.events))for(r in delete o.handle,o.events={},l)for(i=0,n=l[r].length;i1&&\"string\"==typeof f&&!N.checkClone&&Qe.test(f))return e.each((function(r){var s=e.eq(r);p&&(t[0]=f.call(this,r,s.html())),Ye(s,t,i,n)}));if(d&&(s=(r=Me(t,e[0].ownerDocument,!1,e,n)).firstChild,1===r.childNodes.length&&(r=s),s||n)){for(a=(o=z.map(Ee(r,\"script\"),We)).length;h\")},clone:function(e,t,i){var n,r,s,o,a=e.cloneNode(!0),c=z.contains(e.ownerDocument,e);if(!(N.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||z.isXMLDoc(e)))for(o=Ee(a),n=0,r=(s=Ee(e)).length;n0&&Ne(o,!c&&Ee(e,\"script\")),a},cleanData:function(e){for(var t,i,n,r=z.event.special,s=0;void 0!==(i=e[s]);s++)if(he(i)){if(t=i[ue.expando]){if(t.events)for(n in t.events)r[n]?z.event.remove(i,n):z.removeEvent(i,n,t.handle);i[ue.expando]=void 0}i[fe.expando]&&(i[fe.expando]=void 0)}}}),z.fn.extend({detach:function(e){return Xe(this,e,!0)},remove:function(e){return Xe(this,e)},text:function(e){return se(this,(function(e){return void 0===e?z.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ye(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)}))},prepend:function(){return Ye(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(z.cleanData(Ee(e,!1)),e.textContent=\"\");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return z.clone(this,e,t)}))},html:function(e){return se(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if(\"string\"==typeof e&&!qe.test(e)&&!Se[(ke.exec(e)||[\"\",\"\"])[1].toLowerCase()]){e=z.htmlPrefilter(e);try{for(;i=0&&(c+=Math.max(0,Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-s-c-a-.5))),c}function pt(e,t,i){var n=Je(e),r=tt(e,t,n),s=\"border-box\"===z.css(e,\"boxSizing\",!1,n),o=s;if(Ze.test(r)){if(!i)return r;r=\"auto\"}return o=o&&(N.boxSizingReliable()||r===e.style[t]),(\"auto\"===r||!parseFloat(r)&&\"inline\"===z.css(e,\"display\",!1,n))&&(r=e[\"offset\"+t[0].toUpperCase()+t.slice(1)],o=!0),(r=parseFloat(r)||0)+ft(e,t,i||(s?\"border\":\"content\"),o,n,r)+\"px\"}z.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=tt(e,\"opacity\");return\"\"===i?\"1\":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,s,o,a=le(t),c=ot.test(t),l=e.style;if(c||(t=dt(a)),o=z.cssHooks[t]||z.cssHooks[a],void 0===i)return o&&\"get\"in o&&void 0!==(r=o.get(e,!1,n))?r:l[t];\"string\"===(s=typeof i)&&(r=be.exec(i))&&r[1]&&(i=function(e,t,i,n){var r,s,o=20,a=n?function(){return n.cur()}:function(){return z.css(e,t,\"\")},c=a(),l=i&&i[3]||(z.cssNumber[t]?\"\":\"px\"),h=(z.cssNumber[t]||\"px\"!==l&&+c)&&be.exec(z.css(e,t));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;o--;)z.style(e,t,h+l),(1-s)*(1-(s=a()/c||.5))<=0&&(o=0),h/=s;h*=2,z.style(e,t,h+l),i=i||[]}return i&&(h=+h||+c||0,r=i[1]?h+(i[1]+1)*i[2]:+i[2],n&&(n.unit=l,n.start=h,n.end=r)),r}(e,t,r),s=\"number\"),null!=i&&i==i&&(\"number\"===s&&(i+=r&&r[3]||(z.cssNumber[a]?\"\":\"px\")),N.clearCloneStyle||\"\"!==i||0!==t.indexOf(\"background\")||(l[t]=\"inherit\"),o&&\"set\"in o&&void 0===(i=o.set(e,i,n))||(c?l.setProperty(t,i):l[t]=i))}},css:function(e,t,i,n){var r,s,o,a=le(t);return ot.test(t)||(t=dt(a)),(o=z.cssHooks[t]||z.cssHooks[a])&&\"get\"in o&&(r=o.get(e,!0,i)),void 0===r&&(r=tt(e,t,n)),\"normal\"===r&&t in ct&&(r=ct[t]),\"\"===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),z.each([\"height\",\"width\"],(function(e,t){z.cssHooks[t]={get:function(e,i,n){if(i)return!st.test(z.css(e,\"display\"))||e.getClientRects().length&&e.getBoundingClientRect().width?pt(e,t,n):ye(e,at,(function(){return pt(e,t,n)}))},set:function(e,i,n){var r,s=Je(e),o=\"border-box\"===z.css(e,\"boxSizing\",!1,s),a=n&&ft(e,t,n,o,s);return o&&N.scrollboxSize()===s.position&&(a-=Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-parseFloat(s[t])-ft(e,t,\"border\",!1,s)-.5)),a&&(r=be.exec(i))&&\"px\"!==(r[3]||\"px\")&&(e.style[t]=i,i=z.css(e,t)),ut(0,i,a)}}})),z.cssHooks.marginLeft=it(N.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(tt(e,\"marginLeft\"))||e.getBoundingClientRect().left-ye(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+\"px\"})),z.each({margin:\"\",padding:\"\",border:\"Width\"},(function(e,t){z.cssHooks[e+t]={expand:function(i){for(var n=0,r={},s=\"string\"==typeof i?i.split(\" \"):[i];n<4;n++)r[e+Fe[n]+t]=s[n]||s[n-2]||s[0];return r}},\"margin\"!==e&&(z.cssHooks[e+t].set=ut)})),z.fn.extend({css:function(e,t){return se(this,(function(e,t,i){var n,r,s={},o=0;if(Array.isArray(t)){for(n=Je(e),r=t.length;o1)}}),z.fn.delay=function(e,t){return e=z.fx&&z.fx.speeds[e]||e,t=t||\"fx\",this.queue(t,(function(t,i){var n=window.setTimeout(t,e);i.stop=function(){window.clearTimeout(n)}}))},nt=F.createElement(\"input\"),rt=F.createElement(\"select\").appendChild(F.createElement(\"option\")),nt.type=\"checkbox\",N.checkOn=\"\"!==nt.value,N.optSelected=rt.selected,(nt=F.createElement(\"input\")).value=\"t\",nt.type=\"radio\",N.radioValue=\"t\"===nt.value;var gt,mt=z.expr.attrHandle;z.fn.extend({attr:function(e,t){return se(this,z.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){z.removeAttr(this,e)}))}}),z.extend({attr:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===e.getAttribute?z.prop(e,t,i):(1===s&&z.isXMLDoc(e)||(r=z.attrHooks[t.toLowerCase()]||(z.expr.match.bool.test(t)?gt:void 0)),void 0!==i?null===i?void z.removeAttr(e,t):r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:(e.setAttribute(t,i+\"\"),i):r&&\"get\"in r&&null!==(n=r.get(e,t))?n:null==(n=z.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!N.radioValue&&\"radio\"===t&&V(e,\"input\")){var i=e.value;return e.setAttribute(\"type\",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,r=t&&t.match(Z);if(r&&1===e.nodeType)for(;i=r[n++];)e.removeAttribute(i)}}),gt={set:function(e,t,i){return!1===t?z.removeAttr(e,i):e.setAttribute(i,i),i}},z.each(z.expr.match.bool.source.match(/\\w+/g),(function(e,t){var i=mt[t]||z.find.attr;mt[t]=function(e,t,n){var r,s,o=t.toLowerCase();return n||(s=mt[o],mt[o]=r,r=null!=i(e,t,n)?o:null,mt[o]=s),r}}));var wt=/^(?:input|select|textarea|button)$/i,bt=/^(?:a|area)$/i;function Ft(e){return(e.match(Z)||[]).join(\" \")}function vt(e){return e.getAttribute&&e.getAttribute(\"class\")||\"\"}function yt(e){return Array.isArray(e)?e:\"string\"==typeof e&&e.match(Z)||[]}z.fn.extend({prop:function(e,t){return se(this,z.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[z.propFix[e]||e]}))}}),z.extend({prop:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&z.isXMLDoc(e)||(t=z.propFix[t]||t,r=z.propHooks[t]),void 0!==i?r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:e[t]=i:r&&\"get\"in r&&null!==(n=r.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=z.find.attr(e,\"tabindex\");return t?parseInt(t,10):wt.test(e.nodeName)||bt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:\"htmlFor\",class:\"className\"}}),N.optSelected||(z.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),z.each([\"tabIndex\",\"readOnly\",\"maxLength\",\"cellSpacing\",\"cellPadding\",\"rowSpan\",\"colSpan\",\"useMap\",\"frameBorder\",\"contentEditable\"],(function(){z.propFix[this.toLowerCase()]=this})),z.fn.extend({addClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).addClass(e.call(this,t,vt(this)))}));if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)n.indexOf(\" \"+s+\" \")<0&&(n+=s+\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},removeClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).removeClass(e.call(this,t,vt(this)))}));if(!arguments.length)return this.attr(\"class\",\"\");if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)for(;n.indexOf(\" \"+s+\" \")>-1;)n=n.replace(\" \"+s+\" \",\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},toggleClass:function(e,t){var i=typeof e,n=\"string\"===i||Array.isArray(e);return\"boolean\"==typeof t&&n?t?this.addClass(e):this.removeClass(e):B(e)?this.each((function(i){z(this).toggleClass(e.call(this,i,vt(this),t),t)})):this.each((function(){var t,r,s,o;if(n)for(r=0,s=z(this),o=yt(e);t=o[r++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&\"boolean\"!==i||((t=vt(this))&&ue.set(this,\"__className__\",t),this.setAttribute&&this.setAttribute(\"class\",t||!1===e?\"\":ue.get(this,\"__className__\")||\"\"))}))},hasClass:function(e){var t,i,n=0;for(t=\" \"+e+\" \";i=this[n++];)if(1===i.nodeType&&(\" \"+Ft(vt(i))+\" \").indexOf(t)>-1)return!0;return!1}});var At=/\\r/g;z.fn.extend({val:function(e){var t,i,n,r=this[0];return arguments.length?(n=B(e),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?e.call(this,i,z(this).val()):e)?r=\"\":\"number\"==typeof r?r+=\"\":Array.isArray(r)&&(r=z.map(r,(function(e){return null==e?\"\":e+\"\"}))),(t=z.valHooks[this.type]||z.valHooks[this.nodeName.toLowerCase()])&&\"set\"in t&&void 0!==t.set(this,r,\"value\")||(this.value=r))}))):r?(t=z.valHooks[r.type]||z.valHooks[r.nodeName.toLowerCase()])&&\"get\"in t&&void 0!==(i=t.get(r,\"value\"))?i:\"string\"==typeof(i=r.value)?i.replace(At,\"\"):null==i?\"\":i:void 0}}),z.extend({valHooks:{option:{get:function(e){var t=z.find.attr(e,\"value\");return null!=t?t:Ft(z.text(e))}},select:{get:function(e){var t,i,n,r=e.options,s=e.selectedIndex,o=\"select-one\"===e.type,a=o?null:[],c=o?s+1:r.length;for(n=s<0?c:o?s:0;n-1)&&(i=!0);return i||(e.selectedIndex=-1),s}}}}),z.each([\"radio\",\"checkbox\"],(function(){z.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=z.inArray(z(e).val(),t)>-1}},N.checkOn||(z.valHooks[this].get=function(e){return null===e.getAttribute(\"value\")?\"on\":e.value})})),N.focusin=\"onfocusin\"in window;var Ct=/^(?:focusinfocus|focusoutblur)$/,_t=function(e){e.stopPropagation()};z.extend(z.event,{trigger:function(e,t,i,n){var r,s,o,a,c,l,h,d,u=[i||F],f=I.call(e,\"type\")?e.type:e,p=I.call(e,\"namespace\")?e.namespace.split(\".\"):[];if(s=d=o=i=i||F,3!==i.nodeType&&8!==i.nodeType&&!Ct.test(f+z.event.triggered)&&(f.indexOf(\".\")>-1&&(p=f.split(\".\"),f=p.shift(),p.sort()),c=f.indexOf(\":\")<0&&\"on\"+f,(e=e[z.expando]?e:new z.Event(f,\"object\"==typeof e&&e)).isTrigger=n?2:3,e.namespace=p.join(\".\"),e.rnamespace=e.namespace?new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:z.makeArray(t,[e]),h=z.event.special[f]||{},n||!h.trigger||!1!==h.trigger.apply(i,t))){if(!n&&!h.noBubble&&!M(i)){for(a=h.delegateType||f,Ct.test(a+f)||(s=s.parentNode);s;s=s.parentNode)u.push(s),o=s;o===(i.ownerDocument||F)&&u.push(o.defaultView||o.parentWindow||window)}for(r=0;(s=u[r++])&&!e.isPropagationStopped();)d=s,e.type=r>1?a:h.bindType||f,(l=(ue.get(s,\"events\")||{})[e.type]&&ue.get(s,\"handle\"))&&l.apply(s,t),(l=c&&s[c])&&l.apply&&he(s)&&(e.result=l.apply(s,t),!1===e.result&&e.preventDefault());return e.type=f,n||e.isDefaultPrevented()||h._default&&!1!==h._default.apply(u.pop(),t)||!he(i)||c&&B(i[f])&&!M(i)&&((o=i[c])&&(i[c]=null),z.event.triggered=f,e.isPropagationStopped()&&d.addEventListener(f,_t),i[f](),e.isPropagationStopped()&&d.removeEventListener(f,_t),z.event.triggered=void 0,o&&(i[c]=o)),e.result}},simulate:function(e,t,i){var n=z.extend(new z.Event,i,{type:e,isSimulated:!0});z.event.trigger(n,null,t)}}),z.fn.extend({trigger:function(e,t){return this.each((function(){z.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return z.event.trigger(e,t,i,!0)}}),N.focusin||z.each({focus:\"focusin\",blur:\"focusout\"},(function(e,t){var i=function(e){z.event.simulate(t,e.target,z.event.fix(e))};z.event.special[t]={setup:function(){var n=this.ownerDocument||this,r=ue.access(n,t);r||n.addEventListener(e,i,!0),ue.access(n,t,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=ue.access(n,t)-1;r?ue.access(n,t,r):(n.removeEventListener(e,i,!0),ue.remove(n,t))}}}));var xt,kt=/\\[\\]$/,It=/\\r?\\n/g,St=/^(?:submit|button|image|reset|file)$/i,Et=/^(?:input|select|textarea|keygen)/i;function Nt(e,t,i,n){var r;if(Array.isArray(t))z.each(t,(function(t,r){i||kt.test(e)?n(e,r):Nt(e+\"[\"+(\"object\"==typeof r&&null!=r?t:\"\")+\"]\",r,i,n)}));else if(i||\"object\"!==T(t))n(e,t);else for(r in t)Nt(e+\"[\"+r+\"]\",t[r],i,n)}z.param=function(e,t){var i,n=[],r=function(e,t){var i=B(t)?t():t;n[n.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(null==i?\"\":i)};if(Array.isArray(e)||e.jquery&&!z.isPlainObject(e))z.each(e,(function(){r(this.name,this.value)}));else for(i in e)Nt(i,e[i],t,r);return n.join(\"&\")},z.fn.extend({serialize:function(){return z.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=z.prop(this,\"elements\");return e?z.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!z(this).is(\":disabled\")&&Et.test(this.nodeName)&&!St.test(e)&&(this.checked||!xe.test(e))})).map((function(e,t){var i=z(this).val();return null==i?null:Array.isArray(i)?z.map(i,(function(e){return{name:t.name,value:e.replace(It,\"\\r\\n\")}})):{name:t.name,value:i.replace(It,\"\\r\\n\")}})).get()}}),z.fn.extend({wrapAll:function(e){var t;return this[0]&&(B(e)&&(e=e.call(this[0])),t=z(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return B(e)?this.each((function(t){z(this).wrapInner(e.call(this,t))})):this.each((function(){var t=z(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=B(e);return this.each((function(i){z(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not(\"body\").each((function(){z(this).replaceWith(this.childNodes)})),this}}),z.expr.pseudos.hidden=function(e){return!z.expr.pseudos.visible(e)},z.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},N.createHTMLDocument=((xt=F.implementation.createHTMLDocument(\"\").body).innerHTML=\"
\",2===xt.childNodes.length),z.parseHTML=function(e,t,i){return\"string\"!=typeof e?[]:(\"boolean\"==typeof t&&(i=t,t=!1),t||(N.createHTMLDocument?((n=(t=F.implementation.createHTMLDocument(\"\")).createElement(\"base\")).href=F.location.href,t.head.appendChild(n)):t=F),s=!i&&[],(r=j.exec(e))?[t.createElement(r[1])]:(r=Me([e],t,s),s&&s.length&&z(s).remove(),z.merge([],r.childNodes)));var n,r,s},z.offset={setOffset:function(e,t,i){var n,r,s,o,a,c,l=z.css(e,\"position\"),h=z(e),d={};\"static\"===l&&(e.style.position=\"relative\"),a=h.offset(),s=z.css(e,\"top\"),c=z.css(e,\"left\"),(\"absolute\"===l||\"fixed\"===l)&&(s+c).indexOf(\"auto\")>-1?(o=(n=h.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(c)||0),B(t)&&(t=t.call(e,i,z.extend({},a))),null!=t.top&&(d.top=t.top-a.top+o),null!=t.left&&(d.left=t.left-a.left+r),\"using\"in t?t.using.call(e,d):h.css(d)}},z.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){z.offset.setOffset(this,e,t)}));var t,i,n=this[0];return n?n.getClientRects().length?(t=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,i,n=this[0],r={top:0,left:0};if(\"fixed\"===z.css(n,\"position\"))t=n.getBoundingClientRect();else{for(t=this.offset(),i=n.ownerDocument,e=n.offsetParent||i.documentElement;e&&(e===i.body||e===i.documentElement)&&\"static\"===z.css(e,\"position\");)e=e.parentNode;e&&e!==n&&1===e.nodeType&&((r=z(e).offset()).top+=z.css(e,\"borderTopWidth\",!0),r.left+=z.css(e,\"borderLeftWidth\",!0))}return{top:t.top-r.top-z.css(n,\"marginTop\",!0),left:t.left-r.left-z.css(n,\"marginLeft\",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&\"static\"===z.css(e,\"position\");)e=e.offsetParent;return e||Re}))}}),z.each({scrollLeft:\"pageXOffset\",scrollTop:\"pageYOffset\"},(function(e,t){var i=\"pageYOffset\"===t;z.fn[e]=function(n){return se(this,(function(e,n,r){var s;if(M(e)?s=e:9===e.nodeType&&(s=e.defaultView),void 0===r)return s?s[t]:e[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):e[n]=r}),e,n,arguments.length)}})),z.each([\"top\",\"left\"],(function(e,t){z.cssHooks[t]=it(N.pixelPosition,(function(e,i){if(i)return i=tt(e,t),Ze.test(i)?z(e).position()[t]+\"px\":i}))})),z.each({Height:\"height\",Width:\"width\"},(function(e,t){z.each({padding:\"inner\"+e,content:t,\"\":\"outer\"+e},(function(i,n){z.fn[n]=function(r,s){var o=arguments.length&&(i||\"boolean\"!=typeof r),a=i||(!0===r||!0===s?\"margin\":\"border\");return se(this,(function(t,i,r){var s;return M(t)?0===n.indexOf(\"outer\")?t[\"inner\"+e]:t.document.documentElement[\"client\"+e]:9===t.nodeType?(s=t.documentElement,Math.max(t.body[\"scroll\"+e],s[\"scroll\"+e],t.body[\"offset\"+e],s[\"offset\"+e],s[\"client\"+e])):void 0===r?z.css(t,i,a):z.style(t,i,r,a)}),t,o?r:void 0,o)}}))})),z.each(\"blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu\".split(\" \"),(function(e,t){z.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)}})),z.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),z.fn.extend({bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,\"**\"):this.off(t,e||\"**\",i)}}),z.proxy=function(e,t){var i,n,r;if(\"string\"==typeof t&&(i=e[t],t=e,e=i),B(e))return n=y.call(arguments,2),r=function(){return e.apply(t||this,n.concat(y.call(arguments)))},r.guid=e.guid=e.guid||z.guid++,r},z.holdReady=function(e){e?z.readyWait++:z.ready(!0)},z.isArray=Array.isArray,z.parseJSON=JSON.parse,z.nodeName=V,z.isFunction=B,z.isWindow=M,z.camelCase=le,z.type=T,z.now=Date.now,z.isNumeric=function(e){var t=z.type(e);return(\"number\"===t||\"string\"===t)&&!isNaN(e-parseFloat(e))};const Bt=z;function Mt(e){return\"string\"==typeof e||e instanceof String}function Rt(e){var t=String(e).split(/[.,]/);return t[0].split(\"\").reverse().reduce((function(e,t,i){return i%3==0?e+\",\"+t:e+t})).split(\"\").reverse().join(\"\")+(t[1]?\".\"+t[1]:\"\")}const Dt=function(e){return e.split(/\\n|\\r\\n|\\r/g)};function Tt(e,t){var i,n,r=[],s=e.length,o=0,a=!1;if(s>0)for(r[o]=e.charAt(0),i=1;i0?e.charAt(0).toUpperCase()+e.slice(1):e}function zt(e){if(void 0!==e.name)return e.name;if(Mt(e)){let t=e.lastIndexOf(\"/\"),i=t<0?e:e.substr(t+1);return t=i.indexOf(\"?\"),t>0&&(i=i.substr(0,t)),i}throw Error(\"Expected File or string, got \"+typeof e)}function Ht(e){return!!e&&(\"function\"!=typeof e&&(e instanceof File||e.hasOwnProperty(\"name\")&&\"function\"==typeof e.slice&&\"function\"==typeof e.arrayBuffer))}function Pt(e,t){const i=document.createElement(\"a\");i.setAttribute(\"href\",t),i.setAttribute(\"download\",e),i.style.display=\"none\",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Ot(e){for(var t=Ut,i=t.parser.loose.exec(e),n={},r=14;r--;)n[t.key[r]]=i[r]||\"\";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,i,r){i&&(n[t.q.name][i]=r)})),n}\"object\"==typeof process&&\"undefined\"==typeof window&&(global.atob=function(e){return Buffer.from(e,\"base64\").toString(\"binary\")});const Ut={strictMode:!1,key:[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"],q:{name:\"queryKey\",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/}};function qt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Qt=256,Vt=286,jt=30,Wt=15,Gt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),$t=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Yt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xt=new Array(576);qt(Xt);const Zt=new Array(60);qt(Zt);const Jt=new Array(512);qt(Jt);const ei=new Array(256);qt(ei);const ti=new Array(29);qt(ti);const ii=new Array(jt);function ni(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let ri,si,oi;function ai(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}qt(ii);const ci=e=>e<256?Jt[e]:Jt[256+(e>>>7)],li=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},hi=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{hi(e,i[2*t],i[2*t+1])},ui=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},fi=(e,t,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=Wt;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ui(n[t]++,t))}},pi=e=>{let t;for(t=0;t{e.bi_valid>8?li(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},mi=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let n,r,s,o,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?di(e,r,t):(s=ei[r],di(e,s+Qt+1,t),o=Gt[s],0!==o&&(r-=ti[s],hi(e,r,o)),n--,s=ci(n),di(e,s,i),o=$t[s],0!==o&&(n-=ii[s],hi(e,n,o)))}while(a{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)wi(e,i,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wi(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*c]=i[2*o]+i[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=c,e.heap[1]=c++,wi(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let l,h,d,u,f,p,g=0;for(u=0;u<=Wt;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)h=e.heap[l],u=i[2*i[2*h+1]+1]+1,u>c&&(u=c,g++),i[2*h+1]=u,h>n||(e.bl_count[u]++,f=0,h>=a&&(f=o[h-a]),p=i[2*h],e.opt_len+=p*(u+f),s&&(e.static_len+=p*(r[2*h+1]+f)));if(0!==g){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(u=c;0!==u;u--)for(h=e.bl_count[u];0!==h;)d=e.heap[--l],d>n||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),h--)}})(e,t),fi(i,l,e.bl_count)},vi=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a{hi(e,0+(n?1:0),3),gi(e),li(e,i),li(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var _i=e=>{Ai||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(ti[n]=i,e=0;e<1<>=7;n{let r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(vi(e,e.dyn_ltree,e.l_desc.max_code),vi(e,e.dyn_dtree,e.d_desc.max_code),Fi(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Yt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Ci(e,t,i,n):4===e.strategy||s===r?(hi(e,2+(n?1:0),3),bi(e,Xt,Zt)):(hi(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(hi(e,t-257,5),hi(e,i-1,5),hi(e,n-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ei[i]+Qt+1)]++,e.dyn_dtree[2*ci(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{hi(e,2,3),di(e,256,Xt),(e=>{16===e.bi_valid?(li(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ii=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Si=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ei=(e,t,i,n)=>{const r=Si,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Ni={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},Bi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mi,_tr_stored_block:Ri,_tr_flush_block:Di,_tr_tally:Ti,_tr_align:Li}=ki,{Z_NO_FLUSH:zi,Z_PARTIAL_FLUSH:Hi,Z_FULL_FLUSH:Pi,Z_FINISH:Oi,Z_BLOCK:Ui,Z_OK:qi,Z_STREAM_END:Qi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:ji,Z_BUF_ERROR:Wi,Z_DEFAULT_COMPRESSION:Gi,Z_FILTERED:$i,Z_HUFFMAN_ONLY:Ki,Z_RLE:Yi,Z_FIXED:Xi,Z_DEFAULT_STRATEGY:Zi,Z_UNKNOWN:Ji,Z_DEFLATED:en}=Bi,tn=258,nn=262,rn=42,sn=113,on=666,an=(e,t)=>(e.msg=Ni[t],t),cn=e=>2*e-(e>4?9:0),ln=e=>{let t=e.length;for(;--t>=0;)e[t]=0},hn=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let dn=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},fn=(e,t)=>{Di(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,un(e.strm)},pn=(e,t)=>{e.pending_buf[e.pending++]=t},gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},mn=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=Ii(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Ei(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},wn=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-nn?e.strstart-(e.w_size-nn):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+tn;let f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,l[i+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},bn=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nn)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),hn(e),n+=t),0===e.strm.avail_in)break;if(i=mn(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=dn(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=dn(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,n,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,un(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(mn(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(mn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=s||(n||t===Oi)&&t!==zi&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=t===Oi&&0===e.strm.avail_in&&i===n?1:0,Ri(e,e.block_start,i,o),e.block_start+=i,un(e.strm)),o?3:1)},vn=(e,t)=>{let i,n;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nn&&(e.match_length=wn(e,i)),e.match_length>=3)if(n=Ti(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=dn(e,e.ins_h,e.window[e.strstart+1]);else n=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let i,n,r;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=Ti(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Ti(e,0,e.window[e.strstart-1]),n&&fn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ti(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2};function An(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const Cn=[new An(0,0,0,0,Fn),new An(4,4,8,4,vn),new An(4,5,16,8,vn),new An(4,6,32,32,vn),new An(4,4,16,16,yn),new An(8,16,32,32,yn),new An(8,16,128,128,yn),new An(8,32,128,256,yn),new An(32,128,258,1024,yn),new An(32,258,258,4096,yn)];function _n(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ln(this.dyn_ltree),ln(this.dyn_dtree),ln(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ln(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ln(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const xn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==sn&&t.status!==on?1:0},kn=e=>{if(xn(e))return an(e,Vi);e.total_in=e.total_out=0,e.data_type=Ji;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?rn:sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mi(t),qi},In=e=>{const t=kn(e);var i;return t===qi&&((i=e.state).window_size=2*i.w_size,ln(i.head),i.max_lazy_match=Cn[i.level].max_lazy,i.good_match=Cn[i.level].good_length,i.nice_match=Cn[i.level].nice_length,i.max_chain_length=Cn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Sn=(e,t,i,n,r,s)=>{if(!e)return Vi;let o=1;if(t===Gi&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==en||n<8||n>15||t<0||t>9||s<0||s>Xi||8===n&&1!==o)return an(e,Vi);8===n&&(n=9);const a=new _n;return e.state=a,a.strm=e,a.status=rn,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<{let i=t.length;if(xn(e))return Vi;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==rn||n.lookahead)return Vi;if(1===r&&(e.adler=Ii(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(ln(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,bn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=dn(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,bn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,n.wrap=r,qi},Nn={deflateInit:(e,t)=>Sn(e,t,en,15,8,Zi),deflateInit2:Sn,deflateReset:In,deflateResetKeep:kn,deflateSetHeader:(e,t)=>xn(e)||2!==e.state.wrap?Vi:(e.state.gzhead=t,qi),deflate:(e,t)=>{if(xn(e)||t>Ui||t<0)return e?an(e,Vi):Vi;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===on&&t!==Oi)return an(e,0===e.avail_out?Wi:Vi);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(un(e),0===e.avail_out)return i.last_flush=-1,qi}else if(0===e.avail_in&&cn(t)<=cn(n)&&t!==Oi)return an(e,Wi);if(i.status===on&&0!==e.avail_in)return an(e,Wi);if(i.status===rn&&0===i.wrap&&(i.status=sn),i.status===rn){let t=en+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=Ki||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,gn(i,t),0!==i.strstart&&(gn(i,e.adler>>>16),gn(i,65535&e.adler)),e.adler=1,i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(57===i.status)if(e.adler=0,pn(i,31),pn(i,139),pn(i,8),i.gzhead)pn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),pn(i,255&i.gzhead.time),pn(i,i.gzhead.time>>8&255),pn(i,i.gzhead.time>>16&255),pn(i,i.gzhead.time>>24&255),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(pn(i,255&i.gzhead.extra.length),pn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ei(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,3),i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,un(e),0!==i.pending)return i.last_flush=-1,qi;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(un(e),0!==i.pending))return i.last_flush=-1,qi;pn(i,255&e.adler),pn(i,e.adler>>8&255),e.adler=0}if(i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(0!==e.avail_in||0!==i.lookahead||t!==zi&&i.status!==on){let n=0===i.level?Fn(i,t):i.strategy===Ki?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(bn(e),0===e.lookahead)){if(t===zi)return 1;break}if(e.match_length=0,i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Yi?((e,t)=>{let i,n,r,s;const o=e.window;for(;;){if(e.lookahead<=tn){if(bn(e),e.lookahead<=tn&&t===zi)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=e.strstart+tn;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ti(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):Cn[i.level].func(i,t);if(3!==n&&4!==n||(i.status=on),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),qi;if(2===n&&(t===Hi?Li(i):t!==Ui&&(Ri(i,0,0,!1),t===Pi&&(ln(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),un(e),0===e.avail_out))return i.last_flush=-1,qi}return t!==Oi?qi:i.wrap<=0?Qi:(2===i.wrap?(pn(i,255&e.adler),pn(i,e.adler>>8&255),pn(i,e.adler>>16&255),pn(i,e.adler>>24&255),pn(i,255&e.total_in),pn(i,e.total_in>>8&255),pn(i,e.total_in>>16&255),pn(i,e.total_in>>24&255)):(gn(i,e.adler>>>16),gn(i,65535&e.adler)),un(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?qi:Qi)},deflateEnd:e=>{if(xn(e))return Vi;const t=e.state.status;return e.state=null,t===sn?an(e,ji):qi},deflateSetDictionary:En,deflateInfo:\"pako deflate (from Nodeca project)\"};const Bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Bn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:CA>=248?5:CA>=240?4:CA>=224?3:CA>=192?2:1;Dn[254]=Dn[254]=1;var Tn={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Rn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Dn[e[i]]>t?i:t}};var Ln=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0};const zn=Object.prototype.toString,{Z_NO_FLUSH:Hn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:On,Z_FINISH:Un,Z_OK:qn,Z_STREAM_END:Qn,Z_DEFAULT_COMPRESSION:Vn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Wn}=Bi;function Gn(e){this.options=Mn.assign({level:Vn,method:Wn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Nn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==qn)throw new Error(Ni[i]);if(t.header&&Nn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=\"string\"==typeof t.dictionary?Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===zn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Nn.deflateSetDictionary(this.strm,e),i!==qn)throw new Error(Ni[i]);this._dict_set=!0}}function $n(e,t){const i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Ni[i.err];return i.result}Gn.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Un:Hn,\"string\"==typeof e?i.input=Tn.string2buf(e):\"[object ArrayBuffer]\"===zn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Pn||s===On)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Nn.deflate(i,s),r===Qn)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Nn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===qn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn=function(e,t){return(t=t||{}).raw=!0,$n(e,t)},Yn=function(e,t){return(t=t||{}).gzip=!0,$n(e,t)},Xn={Deflate:Gn,deflate:$n,deflateRaw:Kn,gzip:Yn,constants:Bi};const Zn=16209;var Jn=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=16191;break e}e.msg=\"invalid literal/length code\",k.mode=Zn;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=Zn;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null;const k=new Uint16Array(16),I=new Uint16Array(16);let S,E,N,B=null;for(g=0;g<=er;g++)k[g]=0;for(m=0;m=1&&0===k[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(I[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){S=g-y,o[m]+1=p?(E=B[o[m]-p],N=x[o[m]-p]):(E=96,N=0),l=1<>y)+h]=S<<24|E<<16|N}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--k[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0};const{Z_FINISH:or,Z_BLOCK:ar,Z_TREES:cr,Z_OK:lr,Z_STREAM_END:hr,Z_NEED_DICT:dr,Z_STREAM_ERROR:ur,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr,Z_BUF_ERROR:gr,Z_DEFLATED:mr}=Bi,wr=16180,br=16190,Fr=16191,vr=16192,yr=16194,Ar=16199,Cr=16200,_r=16206,xr=16209,kr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ir(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Sr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Er=e=>{if(Sr(e))return ur;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=wr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,lr},Nr=e=>{if(Sr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Er(e)},Br=(e,t)=>{let i;if(Sr(e))return ur;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Nr(e))},Mr=(e,t)=>{if(!e)return ur;const i=new Ir;e.state=i,i.strm=e,i.window=null,i.mode=wr;const n=Br(e,t);return n!==lr&&(e.state=null),n};let Rr,Dr,Tr=!0;const Lr=e=>{if(Tr){Rr=new Int32Array(512),Dr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(sr(1,e.lens,0,288,Rr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sr(2,e.lens,0,32,Dr,0,e.work,{bits:5}),Tr=!1}e.lencode=Rr,e.lenbits=9,e.distcode=Dr,e.distbits=5},zr=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Sr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;i=e.state,i.mode===Fr&&(i.mode=vr),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=lr;e:for(;;)switch(i.mode){case wr:if(0===i.wrap){i.mode=vr;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0),l=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=xr;break}if((15&l)!==mr){e.msg=\"unknown compression method\",i.mode=xr;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits&&(i.wbits=A),A>15||A>i.wbits){e.msg=\"invalid window size\",i.mode=xr;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Ei(i.check,x,4,0)),l=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&4&i.wrap&&(i.check=Ei(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Fr;break;case 16189:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=_r;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=16193;break;case 1:if(Lr(i),i.mode=Ar,t===cr){l>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg=\"invalid block type\",i.mode=xr}l>>>=2,h-=2;break;case 16193:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=xr;break}if(i.length=65535&l,l=0,h=0,i.mode=yr,t===cr)break e;case yr:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Fr;break;case 16196:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=xr;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=sr(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=xr;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=xr;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=xr;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===xr)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=xr;break}if(i.lenbits=9,k={bits:i.lenbits},C=sr(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=xr;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=sr(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=xr;break}if(i.mode=Ar,t===cr)break e;case Ar:i.mode=Cr;case Cr:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Jn(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Fr&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=Fr;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=xr;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=xr;break}i.offset=b,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=xr;break}i.mode=16204;case 16204:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=xr;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=Cr);break;case 16205:if(0===c)break e;r[o++]=i.length,c--,i.mode=Cr;break;case _r:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<Mr(e,15),inflateInit2:Mr,inflate:Hr,inflateEnd:e=>{if(Sr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,lr},inflateGetHeader:(e,t)=>{if(Sr(e))return ur;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,lr):ur},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return Sr(e)?ur:(n=e.state,0!==n.wrap&&n.mode!==br?ur:n.mode===br&&(r=1,r=Ii(r,t,i,0),r!==n.check)?fr:(s=zr(e,t,i,i),s?(n.mode=16210,pr):(n.havedict=1,lr)))},inflateInfo:\"pako inflate (from Nodeca project)\"};var Or=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1};const Ur=Object.prototype.toString,{Z_NO_FLUSH:qr,Z_FINISH:Qr,Z_OK:Vr,Z_STREAM_END:jr,Z_NEED_DICT:Wr,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:$r,Z_MEM_ERROR:Kr}=Bi;function Yr(e){this.options=Mn.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Pr.inflateInit2(this.strm,t.windowBits);if(i!==Vr)throw new Error(Ni[i]);if(this.header=new Or,Pr.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Ur.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Pr.inflateSetDictionary(this.strm,t.dictionary),i!==Vr)))throw new Error(Ni[i])}function Xr(e,t){const i=new Yr(t);if(i.push(e),i.err)throw i.msg||Ni[i.err];return i.result}Yr.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Qr:qr,\"[object ArrayBuffer]\"===Ur.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Pr.inflate(i,o),s===Wr&&r&&(s=Pr.inflateSetDictionary(i,r),s===Vr?s=Pr.inflate(i,o):s===$r&&(s=Wr));i.avail_in>0&&s===jr&&i.state.wrap>0&&0!==e[i.next_in];)Pr.inflateReset(i),s=Pr.inflate(i,o);switch(s){case Gr:case $r:case Wr:case Kr:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===jr))if(\"string\"===this.options.to){let e=Tn.utf8border(i.output,i.next_out),t=i.next_out-e,r=Tn.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Vr||0!==a){if(s===jr)return s=Pr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Yr.prototype.onData=function(e){this.chunks.push(e)},Yr.prototype.onEnd=function(e){e===Vr&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zr=function(e,t){return(t=t||{}).raw=!0,Xr(e,t)},Jr={Inflate:Yr,inflate:Xr,inflateRaw:Zr,ungzip:Xr,constants:Bi};const{Deflate:es,deflate:ts,deflateRaw:is,gzip:ns}=Xn,{Inflate:rs,inflate:ss,inflateRaw:os,ungzip:as}=Jr;var cs=is,ls=ss,hs=os,ds=as;const us=4;function fs(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 31===t[0]&&139===t[1]}function ps(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 0!==(t[3]&us)&&66===t[12]&&67===t[13]?gs(t.buffer):ds(t)}function gs(e,t){const i=[];let n=0,r=0;for(t=t||e.byteLength-18;n100?Fs(new Uint8Array(e.buffer,e.byteOffset+t,r),i,n):function(e,t,i,n,r){for(let s=0;s=0){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t0?ds(e):e,i}return decodeURIComponent(r)}const ys={lerp:(e,t,i)=>(1-i)*e+i*t,mean:function(e){var t,i=0,n=0;for(t=0;t0?i/n:0},meanAndStdev:function(e){var t,i,n=0,r=0,s=0;for(i=0;i0?{mean:n/s,stdev:Math.sqrt(r-n*n/s)}:{mean:0,stdev:0}},median:function(e){var t=e.length;return e.sort(),t%2==0?(e[t/2-1]+e[t/2])/2:e[(t-1)/2]},percentile:function(e,t){if(0!==e.length){var i=Math.floor(e.length*((100-t)/100));return 0===i?(e.sort((function(e,t){return t-e})),e[i]):function(e,t){var i,n=new As;for(i=0;in.content[0])&&(n.content.length===t&&n.pop(),n.push(r))}return n.content[0]}(e,i)}},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},log2:function(e){return Math.log(e)/Math.LN2}};function As(){this.content=[]}function Cs(e,t){return Math.random()*(t-e)+e}As.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},remove:function(e){for(var t=this.content.length,i=0;i0;){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=t,this.content[e]=r,e=n}},sinkDown:function(e){for(var t=this.content.length,i=this.content[e],n=i;;){var r=2*(e+1),s=r-1,o=null;if(s{let e=[];for(let t=1;t>=.5;t-=.1)for(let i=0;i<1;i+=1/28){const n=\"rgb(\"+_s.hsvToRgb(i,1,t).join(\",\")+\")\";e.push(n)}return e.pop(),e.push(_s.rgbColor(16,16,16)),e},rgbToHex:function(e){return(e=e.match(/^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i))&&4===e.length?\"#\"+(\"0\"+parseInt(e[1],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[2],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[3],10).toString(16)).slice(-2):\"\"},hexToRgb:function(e){var t=/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(e);if(null!==t)return\"rgb(\"+parseInt(t[1],16)+\",\"+parseInt(t[2],16)+\",\"+parseInt(t[3],16)+\")\"},hsvToRgb:function(e,t,i){var n,r,s,o=Math.floor(6*e),a=6*e-o,c=i*(1-t),l=i*(1-a*t),h=i*(1-(1-a)*t);switch(o%6){case 0:n=i,r=h,s=c;break;case 1:n=l,r=i,s=c;break;case 2:n=c,r=i,s=h;break;case 3:n=c,r=l,s=i;break;case 4:n=h,r=c,s=i;break;case 5:n=i,r=c,s=l}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(e,t,i){var n,r,s;if(0===t)n=r=s=i;else{var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=_s.hue2rgb(a,o,e+1/3),r=_s.hue2rgb(a,o,e),s=_s.hue2rgb(a,o,e-1/3)}return[255*n,255*r,255*s]},hue2rgb:(e,t,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e),rgbaColor:function(e,t,i,n){return\"rgba(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\",\"+(n=ys.clamp(n,0,1))+\")\"},rgbColor:function(e,t,i){return\"rgb(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\")\"},greyScale:function(e){var t=ys.clamp(e,0,255);return\"rgb(\"+t+\",\"+t+\",\"+t+\")\"},randomGrey:function(e,t){e=ys.clamp(e,0,255),t=ys.clamp(t,0,255);var i=Math.round(Cs(e,t)).toString(10);return\"rgb(\"+i+\",\"+i+\",\"+i+\")\"},randomRGB:function(e,t){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgb(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\")\"},randomRGBConstantAlpha:function(e,t,i){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgba(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+i+\")\"},addAlpha:function(e,t){if(\"0\"===e||\".\"===e)e=\"rgb(0,0,0)\";else{const t=this.colorNameToHex(e);t&&(e=t)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);if(e.startsWith(\"rgba\")){const i=e.lastIndexOf(\",\");return e.substring(0,i+1)+t.toString()+\")\"}return i&&(e=_s.hexToRgb(e)),e.startsWith(\"rgb\")?e.replace(\"rgb\",\"rgba\").replace(\")\",\", \"+t+\")\"):(console.log(e+\" is not an rgb style string\"),e)},rgbComponents:function(e){if(\"0\"===e||\".\"===e)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e))e=_s.hexToRgb(e);else if(!e.startsWith(\"rgb\")){const t=this.colorNameToHex(e);e=this.hexToRgb(t)}if(e.startsWith(\"rgb(\"))return e.substring(4,e.length-1).split(\",\").map((e=>Number.parseInt(e.trim())));if(e.startsWith(\"rgba(\"))return e.substring(5,e.length-1).split(\",\").map(((e,t)=>(e=e.trim(),3===t?Number.parseFloat(e):Number.parseInt(e))));throw Error(\"Unrecognized color string: color\")},getCompositeColor:function(e,t,i){return\"rgb(\"+Math.floor(i*t[0]+(1-i)*e[0])+\",\"+Math.floor(i*t[1]+(1-i)*e[1])+\",\"+Math.floor(i*t[2]+(1-i)*e[2])+\")\"},createColorString:function(e){const t=this.createColorStringSafe(e);return t||e},createColorStringSafe:function(e){if((e=function(e){return void 0===e||((e.startsWith(\"'\")||e.startsWith('\"'))&&(e=e.substring(1)),(e.endsWith(\"'\")||e.endsWith('\"'))&&(e=e.substring(0,e.length-1))),e}(e)).startsWith(\"rgb(\")&&e.endsWith(\")\"))return e;if(e.startsWith(\"#\")&&e.length<8)return e;const t=this.colorNameToHex(e);if(t)return t;const i=e.split(\",\");return 3===i.length&&xs(i[0])&&xs(i[1])&&xs(i[2])?`rgb(${e})`:void 0},darkenLighten:function(e,t){let i,n=this.colorNameToHex(e);i=n?_s.hexToRgb(n):e.startsWith(\"rgb(\")?e:_s.hexToRgb(e);const r=i.replace(\")\",\"\").substring(4).split(\",\"),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+t)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+t)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+t));return\"rgb(\"+s.toString()+\",\"+o.toString()+\",\"+a.toString()+\")\"},colorNameToHex:function(e){return{aliceblue:\"#f0f8ff\",antiquewhite:\"#faebd7\",aqua:\"#00ffff\",aquamarine:\"#7fffd4\",azure:\"#f0ffff\",beige:\"#f5f5dc\",bisque:\"#ffe4c4\",black:\"#000000\",blanchedalmond:\"#ffebcd\",blue:\"#0000ff\",blueviolet:\"#8a2be2\",brown:\"#a52a2a\",burlywood:\"#deb887\",cadetblue:\"#5f9ea0\",chartreuse:\"#7fff00\",chocolate:\"#d2691e\",coral:\"#ff7f50\",cornflowerblue:\"#6495ed\",cornsilk:\"#fff8dc\",crimson:\"#dc143c\",cyan:\"#00ffff\",darkblue:\"#00008b\",darkcyan:\"#008b8b\",darkgoldenrod:\"#b8860b\",darkgray:\"#a9a9a9\",darkgreen:\"#006400\",darkkhaki:\"#bdb76b\",darkmagenta:\"#8b008b\",darkolivegreen:\"#556b2f\",darkorange:\"#ff8c00\",darkorchid:\"#9932cc\",darkred:\"#8b0000\",darksalmon:\"#e9967a\",darkseagreen:\"#8fbc8f\",darkslateblue:\"#483d8b\",darkslategray:\"#2f4f4f\",darkturquoise:\"#00ced1\",darkviolet:\"#9400d3\",deeppink:\"#ff1493\",deepskyblue:\"#00bfff\",dimgray:\"#696969\",dodgerblue:\"#1e90ff\",firebrick:\"#b22222\",floralwhite:\"#fffaf0\",forestgreen:\"#228b22\",fuchsia:\"#ff00ff\",gainsboro:\"#dcdcdc\",ghostwhite:\"#f8f8ff\",gold:\"#ffd700\",goldenrod:\"#daa520\",gray:\"#808080\",green:\"#008000\",greenyellow:\"#adff2f\",honeydew:\"#f0fff0\",hotpink:\"#ff69b4\",\"indianred \":\"#cd5c5c\",\"indigo \":\"#4b0082\",ivory:\"#fffff0\",khaki:\"#f0e68c\",lavender:\"#e6e6fa\",lavenderblush:\"#fff0f5\",lawngreen:\"#7cfc00\",lemonchiffon:\"#fffacd\",lightblue:\"#add8e6\",lightcoral:\"#f08080\",lightcyan:\"#e0ffff\",lightgoldenrodyellow:\"#fafad2\",lightgrey:\"#d3d3d3\",lightgreen:\"#90ee90\",lightpink:\"#ffb6c1\",lightsalmon:\"#ffa07a\",lightseagreen:\"#20b2aa\",lightskyblue:\"#87cefa\",lightslategray:\"#778899\",lightsteelblue:\"#b0c4de\",lightyellow:\"#ffffe0\",lime:\"#00ff00\",limegreen:\"#32cd32\",linen:\"#faf0e6\",magenta:\"#ff00ff\",maroon:\"#800000\",mediumaquamarine:\"#66cdaa\",mediumblue:\"#0000cd\",mediumorchid:\"#ba55d3\",mediumpurple:\"#9370d8\",mediumseagreen:\"#3cb371\",mediumslateblue:\"#7b68ee\",mediumspringgreen:\"#00fa9a\",mediumturquoise:\"#48d1cc\",mediumvioletred:\"#c71585\",midnightblue:\"#191970\",mintcream:\"#f5fffa\",mistyrose:\"#ffe4e1\",moccasin:\"#ffe4b5\",navajowhite:\"#ffdead\",navy:\"#000080\",oldlace:\"#fdf5e6\",olive:\"#808000\",olivedrab:\"#6b8e23\",orange:\"#ffa500\",orangered:\"#ff4500\",orchid:\"#da70d6\",palegoldenrod:\"#eee8aa\",palegreen:\"#98fb98\",paleturquoise:\"#afeeee\",palevioletred:\"#d87093\",papayawhip:\"#ffefd5\",peachpuff:\"#ffdab9\",peru:\"#cd853f\",pink:\"#ffc0cb\",plum:\"#dda0dd\",powderblue:\"#b0e0e6\",purple:\"#800080\",red:\"#ff0000\",rosybrown:\"#bc8f8f\",royalblue:\"#4169e1\",saddlebrown:\"#8b4513\",salmon:\"#fa8072\",sandybrown:\"#f4a460\",seagreen:\"#2e8b57\",seashell:\"#fff5ee\",sienna:\"#a0522d\",silver:\"#c0c0c0\",skyblue:\"#87ceeb\",slateblue:\"#6a5acd\",slategray:\"#708090\",snow:\"#fffafa\",springgreen:\"#00ff7f\",steelblue:\"#4682b4\",tan:\"#d2b48c\",teal:\"#008080\",thistle:\"#d8bfd8\",tomato:\"#ff6347\",turquoise:\"#40e0d0\",violet:\"#ee82ee\",wheat:\"#f5deb3\",white:\"#ffffff\",whitesmoke:\"#f5f5f5\",yellow:\"#ffff00\",yellowgreen:\"#9acd32\",darkgrey:\"#a9a9a9\",darkslategrey:\"#2f4f4f\",dimgrey:\"#696969\",grey:\"#808080\",lightgray:\"#d3d3d3\",lightslategrey:\"#778899\",slategrey:\"#708090\"}[e]}};function xs(e){const t=Number.parseInt(e);return!Number.isNaN(t)&&t>=0&&t<=255}const ks=\"googleapis\";class Is{constructor(){this.oauthTokens={}}setToken(e,t){t=t||ks,this.oauthTokens[t]=e}getToken(e){let t;e=e||ks;for(let i of Object.keys(this.oauthTokens)){if(Ss(i).test(e)){t=this.oauthTokens[i];break}}return t}removeToken(e){e=e||ks;for(let t of Object.keys(this.oauthTokens)){Ss(t).test(e)&&(this.oauthTokens[t]=void 0)}}}function Ss(e){return new RegExp(\"^\"+e.split(/\\*+/).map(Es).join(\".*\")+\"$\")}function Es(e){return e.replace(/[|\\\\{}()[\\]^$+*?.]/g,\"\\\\$&\")}function Ns(e){return e.includes(\"googleapis\")&&!e.includes(\"urlshortener\")||Bs(e)||Ms(e)}function Bs(e){return e.startsWith(\"gs://\")||e.startsWith(\"https://www.googleapis.com/storage\")||e.startsWith(\"https://storage.cloud.google.com\")||e.startsWith(\"https://storage.googleapis.com\")}function Ms(e){return e.indexOf(\"drive.google.com\")>=0||e.indexOf(\"www.googleapis.com/drive\")>0}function Rs(e){let{bucket:t,object:i}=function(e){let t,i;if(e.startsWith(\"gs://\")){const n=e.indexOf(\"/\",5);if(n>=0){t=e.substring(5,n);const r=e.indexOf(\"?\");i=r<0?e.substring(n+1):e.substring(n+1,r)}}else if(e.startsWith(\"https://storage.googleapis.com\")||e.startsWith(\"https://storage.cloud.google.com\")){const n=e.indexOf(\"/v1/b/\",8);if(n>0){const r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}else{const n=e.indexOf(\"/\",8),r=e.indexOf(\"/\",n+1),s=e.indexOf(\"?\",r);r>0&&(t=e.substring(n+1,r),i=s<0?e.substring(r+1):e.substring(r+1,s))}}else if(e.startsWith(\"https://www.googleapis.com/storage/v1/b\")){const n=e.indexOf(\"/v1/b/\",8),r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}if(t&&i)return{bucket:t,object:i};throw Error(`Unrecognized Google Storage URI: ${e}`)}(e);i=function(e){let t=\"\";return e.split(\"\").forEach((function(e){Ds.has(e)?t+=Ds.get(e):t+=e})),t}(i);const n=e.indexOf(\"?\");return`https://storage.googleapis.com/storage/v1/b/${t}/o/${i}${n>0?e.substring(n)+\"&alt=media\":\"?alt=media\"}`}const Ds=new Map;function Ts(){return window.google&&window.google.igv}async function Ls(e){if(!Ts())throw Error(\"Google oAuth has not been initialized\");if(google.igv.tokenResponse&&Date.now(){try{t.callback=e=>{void 0!==e.error&&n(e),google.igv.tokenResponse=e,google.igv.tokenExpiresAt=Date.now()+1e3*e.expires_in,i(e.access_token)},t.requestAccessToken({scope:e})}catch(e){console.log(e)}}))}}function zs(){return google.igv.apiKey}function Hs(e){var t=Ps(e);return t?\"https://www.googleapis.com/drive/v3/files/\"+t+\"?alt=media&supportsTeamDrives=true\":e}function Ps(e){if(e.includes(\"/open?id=\")){const t=e.indexOf(\"/open?id=\")+9,i=e.indexOf(\"&\");if(t>0&&i>t)return e.substring(t,i);if(t>0)return e.substring(t)}else{if(e.includes(\"/file/d/\")){const t=e.indexOf(\"/file/d/\")+8,i=e.lastIndexOf(\"/\");return e.substring(t,i)}if(e.startsWith(\"https://www.googleapis.com/drive\")){let t=e.indexOf(\"/files/\");const i=e.indexOf(\"?\");if(t>0)return t+=7,i>0?e.substring(t,i):e.substring(t)}}throw Error(\"Unknown Google Drive url format: \"+e)}Ds.set(\"!\",\"%21\"),Ds.set(\"#\",\"%23\"),Ds.set(\"$\",\"%24\"),Ds.set(\"%\",\"%25\"),Ds.set(\"&\",\"%26\"),Ds.set(\"'\",\"%27\"),Ds.set(\"(\",\"%28\"),Ds.set(\")\",\"%29\"),Ds.set(\"*\",\"%2A\"),Ds.set(\"+\",\"%2B\"),Ds.set(\",\",\"%2C\"),Ds.set(\"/\",\"%2F\"),Ds.set(\":\",\"%3A\"),Ds.set(\";\",\"%3B\"),Ds.set(\"=\",\"%3D\"),Ds.set(\"?\",\"%3F\"),Ds.set(\"@\",\"%40\"),Ds.set(\"[\",\"%5B\"),Ds.set(\"]\",\"%5D\"),Ds.set(\" \",\"%20\");class Os{constructor(e){this.requestsPerSecond=e.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(e,t){var i=this;return new Promise((function(t,n){i.queued.push({resolve:t,reject:n,asyncFunction:e}),i.dequeue()}))}addAll(e,t){var i=e.map(function(e){return this.add(e,t)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var e=new Date,t=1e3/this.requestsPerSecond+1,i=e-this.lastStartTime;i>=t?this._execute():setTimeout(function(){this.dequeue()}.bind(this),t-i)}}async _execute(){this.lastStartTime=new Date;var e=this.queued.shift();const t=e.asyncFunction;try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}}}function Us(){if(Ts()){return Ts()&&google.igv.tokenResponse&&Date.now()0)for(var o=0;othis._loadURL(e,t))):this._loadURL(e,t)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async _loadURL(e,t){const i=this,n=e;e=function(e){return e.startsWith(\"https://www.dropbox.com\")?e.replace(\"//www.dropbox.com\",\"//dl.dropboxusercontent.com\"):e.startsWith(\"https://drive.google.com\")?Hs(e):e.includes(\"//www.broadinstitute.org/igvdata\")?e.replace(\"//www.broadinstitute.org/igvdata\",\"//data.broadinstitute.org/igvdata\"):e.includes(\"//igvdata.broadinstitute.org\")?e.replace(\"//igvdata.broadinstitute.org\",\"//s3.amazonaws.com/igv.broadinstitute.org\"):e.includes(\"//igv.genepattern.org\")?e.replace(\"//igv.genepattern.org\",\"//igv-genepattern-org.s3.amazonaws.com\"):e.startsWith(\"ftp://ftp.ncbi.nlm.nih.gov/geo\")?e.replace(\"ftp://\",\"https://\"):e}(e);let r=(t=t||{}).oauthToken||this.getOauthToken(e);return r&&(r=await(\"function\"==typeof r?r():r)),new Promise((function(s,o){Ns(e)&&!function(e){return e.indexOf(\"X-Goog-Signature\")>-1}(e)&&(Bs(e)&&(e=Rs(e)),Ms(e=function(e){let t=Qs.apiKey;t||\"undefined\"==typeof gapi||(t=gapi.apiKey);if(void 0!==t&&!e.includes(\"key=\")){const i=e.includes(\"?\")?\"&\":\"?\";e=e+i+\"key=\"+t}return e}(e))&&function(e){if(e.includes(\"supportsTeamDrive\"))return e;{const t=e.includes(\"?\")?\"&\":\"?\";e=e+t+\"supportsTeamDrive=true\"}}(e),r||(r=Us()));const a=t.headers||{};r&&function(e,t){t&&(e[\"Cache-Control\"]=\"no-cache\",e.Authorization=\"Bearer \"+t)}(a,r);const c=t.range,l=new XMLHttpRequest,h=t.sendData||t.body,d=t.method||(h?\"POST\":\"GET\"),u=t.responseType,f=t.contentType,p=t.mimeType;if(l.open(d,e),t.timeout&&(l.timeout=t.timeout),c){let e=\"\";c.size&&(e=c.start+c.size-1),l.setRequestHeader(\"Range\",\"bytes=\"+c.start+\"-\"+e)}if(f&&l.setRequestHeader(\"Content-Type\",f),p&&l.overrideMimeType(p),u&&(l.responseType=u),a)for(let e of Object.keys(a)){const t=a[e];l.setRequestHeader(e,t)}!0===t.withCredentials&&(l.withCredentials=!0),l.onload=async function(n){if(0===l.status||l.status>=200&&l.status<=300)if(\"HEAD\"===t.method){const e=t.requestedHeaders||[\"content-length\"],i={};for(let t of e)i[t]=l.getResponseHeader(t);s(i)}else c&&206!==l.status&&0!==c.start?(l.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${e}. This can have severe performance impacts.`),s(l.response.slice(c.start,c.start+c.size))):s(l.response);else 416===l.status?g(Error(\"416 Unsatisfiable Range\")):!Ts()||404!==l.status&&401!==l.status&&403!==l.status||!Ns(e)||t.retries?403===l.status?g(\"Access forbidden: \"+e):g(l.status):m()},l.onerror=function(i){Ns(e)&&!t.retries?m():g(\"Error accessing resource: \"+e+\" Status: \"+l.status)},l.ontimeout=function(e){g(\"Timed out\")},l.onabort=function(e){console.log(\"Aborted\"),o(e)};try{l.send(h)}catch(i){Ns(e)&&!t.retries?m():g(i)}function g(e){if(!o)throw e;o(e)}async function m(){try{const e=await async function(e){if(Ts()){const t=function(e){return Ms(e)?\"https://www.googleapis.com/auth/drive.file\":Bs(e)?\"https://www.googleapis.com/auth/devstorage.read_only\":\"https://www.googleapis.com/auth/userinfo.profile\"}(e);return await Ls(t)}throw Error(\"Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.\")}(n);t.retries=1,t.oauthToken=e;const r=await i.load(n,t);s(r)}catch(e){if(e.error){const t=e.error.startsWith(\"popup_blocked\")?\"Google login popup blocked by browser.\":e.error;alert(t)}else g(e)}}}))}async _loadFileSlice(e,t){let i=t&&t.range?e.slice(t.range.start,t.range.start+t.range.size):e;const n=await i.arrayBuffer();return\"arraybuffer\"===t.responseType?n:qs(n)}async _loadStringFromFile(e,t){const i=t.range?e.slice(t.range.start,t.range.start+t.range.size):e;return qs(await i.arrayBuffer())}async _loadStringFromUrl(e,t){(t=t||{}).responseType=\"arraybuffer\";return qs(await this.load(e,t))}setOauthToken(e,t){this.oauth.setToken(e,t)}getOauthToken(e){const t=Ns(e)?void 0:Ot(e).host;let i=this.oauth.getToken(t);if(i)return i;if(void 0===t){const e=Us();if(e&&e.expires_at>Date.now())return e.access_token}}async getContentLength(e,t){(t=t||{}).method=\"HEAD\",t.requestedHeaders=[\"content-length\"];const i=(await this._loadURL(e,t))[\"content-length\"];return i?Number.parseInt(i):0}};var Vs={color:1};Vs.parent=Vs,Vs.left=Vs,Vs.right=Vs;class js{constructor(){this.root=Vs}insert(e,t,i){var n=new Xs(new Ys(e,t,i));for(this.treeInsert(n),n.color=2;n!==this.root&&2===n.parent.color;)if(n.parent===n.parent.parent.left){let e=n.parent.parent.right;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,Gs.call(this,n)),n.parent.color=1,n.parent.parent.color=2,$s.call(this,n.parent.parent))}else{let e=n.parent.parent.left;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,$s.call(this,n)),n.parent.color=1,n.parent.parent.color=2,Gs.call(this,n.parent.parent))}this.root.color=1}findOverlapping(e,t){var i=new Ys(e,t,0);if(this.root===Vs)return[];var n=Ws.call(this,i,this.root,[]);return n.length>1&&n.sort((function(e,t){return e.low-t.low})),n}logIntervals(){!function e(t,i){for(var n=\"\",r=0;r=e.low&&Ws.call(this,e,t.left,i),t.right!==Vs&&t.right.min<=e.high&&Ws.call(this,e,t.right,i),i}function Gs(e){var t=e.right;e.right=t.left,t.left!==Vs&&(t.left.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,Ks.call(this,e)}function $s(e){var t=e.left;e.left=t.right,t.right!==Vs&&(t.right.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t,Ks.call(this,e)}function Ks(e){for(;e!==Vs;){var t=e.left.max>e.right.max?e.left.max:e.right.max,i=e.interval.high;e.max=t>i?t:i;var n=e.left.mine.low?1:this.highe.high?1:0}overlaps(e){return this.low<=e.high&&e.low<=this.high}}function Xs(e){this.parent=Vs,this.left=Vs,this.right=Vs,this.interval=e,this.color=2}class Zs{constructor(e,t,i){e=e||[],this.treeMap=this.buildTreeMap(e,t),this.range=i,this.count=e.length}containsRange(e){return void 0===this.range||this.range.contains(e.chr,e.start,e.end)}findFeatures(e){const t=[];for(let i of Object.values(this.allFeatures))for(let n of i)e(n)&&t.push(n);return t}queryFeatures(e,t,i){const n=this.treeMap[e];if(!n)return[];const r=n.findOverlapping(t,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[e];if(s){for(let e of r){const r=e.value;for(let e=r.start;ei)break;r.end>=t&&n.push(r)}}n.sort((function(e,t){return e.start-t.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(e,t){const i={},n=[];if(this.allFeatures={},e){for(let i of e){let e=i.chr;t&&(e=t.getChromosomeName(e));let r=this.allFeatures[e];r||(n.push(e),r=[],this.allFeatures[e]=r),r.push(i)}for(let e of n){const t=this.allFeatures[e];t.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1})),i[e]=Js(t)}}return i}}function Js(e){const t=new js,i=e.length,n=Math.max(10,Math.round(i/10));for(let r=0;rt.start?1:-1}));for(let r=0;ri)break;s.end>t&&e.push(s)}})),e.sort((function(e,t){return e.start-t.start})),e)}return[]};function io(e){if(3===(e=e.replace(/^#/,\"\")).length&&(e=e.split(\"\").map((e=>e+e)).join(\"\")),6!==e.length)throw new Error(\"Invalid HEX color.\");let t=parseInt(e,16);return`rgb(${t>>16&255}, ${t>>8&255}, ${255&t})`}const no={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}};function ro(e){const{r:t,g:i,b:n}=no[e];return`rgb(${t},${i},${n})`}const so={Set1:[\"rgb(228,26,28)\",\"rgb(55,126,184)\",\"rgb(77,175,74)\",\"rgb(166,86,40)\",\"rgb(152,78,163)\",\"rgb(255,127,0)\",\"rgb(247,129,191)\",\"rgb(153,153,153)\",\"rgb(255,255,51)\"],Dark2:[\"rgb(27,158,119)\",\"rgb(217,95,2)\",\"rgb(117,112,179)\",\"rgb(231,41,138)\",\"rgb(102,166,30)\",\"rgb(230,171,2)\",\"rgb(166,118,29)\",\"rgb(102,102,102)\"],Set2:[\"rgb(102, 194,165)\",\"rgb(252,141,98)\",\"rgb(141,160,203)\",\"rgb(231,138,195)\",\"rgb(166,216,84)\",\"rgb(255,217,47)\",\"rgb(229,196,148)\",\"rgb(179,179,179)\"],Set3:[\"rgb(141,211,199)\",\"rgb(255,255,179)\",\"rgb(190,186,218)\",\"rgb(251,128,114)\",\"rgb(128,177,211)\",\"rgb(253,180,98)\",\"rgb(179,222,105)\",\"rgb(252,205,229)\",\"rgb(217,217,217)\",\"rgb(188,128,189)\",\"rgb(204,235,197)\",\"rgb(255,237,111)\"],Pastel1:[\"rgb(251,180,174)\",\"rgb(179,205,227)\",\"rgb(204,235,197)\",\"rgb(222,203,228)\",\"rgb(254,217,166)\",\"rgb(255,255,204)\",\"rgb(229,216,189)\",\"rgb(253,218,236)\"],Pastel2:[\"rgb(173,226,207)\",\"rgb(253,205,172)\",\"rgb(203,213,232)\",\"rgb(244,202,228)\",\"rgb(230,245,201)\",\"rgb(255,242,174)\",\"rgb(243,225,206)\"],Accent:[\"rgb(127,201,127)\",\"rgb(190,174,212)\",\"rgb(253,192,134)\",\"rgb(255,255,153)\",\"rgb(56,108,176)\",\"rgb(240,2,127)\",\"rgb(191,91,23)\"]};class oo{constructor(e){this.colors=so[e],Array.isArray(this.colors)||(this.colors=[]),this.colorTable=new Map,this.nextIdx=0,this.colorGenerator=new co}getColor(e){return this.colorTable.has(e)||(this.nextIdxparseInt(e)))}}co.prototype.hsvToRgb=function(e,t,i){var n=Math.floor(6*e),r=6*e-n,s=i*(1-t),o=i*(1-r*t),a=i*(1-(1-r)*t),c=255,l=255,h=255;switch(n){case 0:c=i,l=a,h=s;break;case 1:c=o,l=i,h=s;break;case 2:c=s,l=i,h=a;break;case 3:c=s,l=o,h=i;break;case 4:c=a,l=s,h=i;break;case 5:c=i,l=s,h=o}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},co.prototype.padHex=function(e){return e.length>this.hexwidth?e:new Array(this.hexwidth-e.length+1).join(\"0\")+e},co.prototype.get=function(e,t){this.hue+=this.goldenRatio,this.hue%=1,\"number\"!=typeof e&&(e=.5),\"number\"!=typeof t&&(t=.95);var i=this.hsvToRgb(this.hue,e,t);return\"#\"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new co;function fo(e,t,i){if(i<.005)return e;if(i>.995)return t;{let n,r,s,o,a,c;i<.5?(i/=.5,[n,r,s]=uo(e),[o,a,c]=uo(ro(\"snow\"))):(i=(i-.5)/.5,[n,r,s]=uo(ro(\"snow\")),[o,a,c]=uo(t));const[l,h,d]=[Math.floor(ys.lerp(n,o,i)),Math.floor(ys.lerp(r,a,i)),Math.floor(ys.lerp(s,c,i))];return function(e,t,i){return`rgb(${e=ys.clamp(e,0,255)}, ${t=ys.clamp(t,0,255)}, ${i=ys.clamp(i,0,255)})`}(l,h,d)}}const po=new Set([\"bedtype\",\"alignment\",\"annotation\",\"variant\",\"wig\",\"interact\",\"shoebox\"]),go=new Set([\"alignment\",\"annotation\",\"variant\",\"eqtl\",\"qtl\",\"snp\",\"shoebox\",\"wig\"]),mo=new Set([\"sequence\",\"ruler\",\"ideogram\"]),wo={};class bo{constructor(e){this.browser=e,this.initialize()}initialize(){const e=new c;e.add(\"...\");const t={parent:this.browser.root,content:e};this.dialog=new w(t),this.browser.root.appendChild(this.dialog.elem),i(this.dialog.elem)}trackMenuItemList(e){const t=[];return\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{const e=parseInt(this.browser.inputDialog.value,10);if(void 0!==e){const t=[];this.trackView.track.selected?t.push(...this.trackView.browser.getSelectedTrackViews().map((({track:e})=>e))):t.push(this);for(const i of t)i.trackView.autoHeight=!1,void 0!==i.minHeight&&i.minHeight>e&&(i.minHeight=e),void 0!==i.maxHeight&&i.maxHeight1&&new Set(t).has(e)}(e)?t.push(...this.multiSelectMenuItems(e)):(\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?\"untitled\":e.trim(),this.name=e},i={label:\"Track Name\",value:Ao(this)||\"unnamed\",callback:t};this.browser.inputDialog.present(i,e)}return e.text(\"Set track name\"),{object:e,click:t}}()),t.push(...this.defaultMenuItems(e))),!1!==e.track.removable&&(t.push(\"
\"),t.push(function(e){const t=e.track.selected?\"Remove tracks\":\"Remove track\",i=Bt(\"
\");function n(e){this.trackView.browser._removeTrack(this)}return i.text(t),{object:i,click:n,menuItemType:\"removeTrack\"}}(e))),t}defaultMenuItems(e){const t=[];return Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),e.track.menuItemList&&t.push(...e.track.menuItemList()),function(e){const t=e.track;return t&&t.config&&void 0!==t.config.visibilityWindow||t&&go.has(t.type)}(e)&&(t.push(\"
\"),t.push(function(e){const t=Bt(\"
\");function i(t){const i=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?-1:e.trim(),this.visibilityWindow=Number.parseInt(e),this.config.visibilityWindow=Number.parseInt(e),this.trackView.updateViews()},n={label:\"wig\"===e?\"Visibility window (bp). Enter 0 for whole chromosome, -1 for whole genome.\":\"Visibility window (bp). Enter 0 for whole chromosome.\",value:this.visibilityWindow,callback:i};this.browser.inputDialog.present(n,t)}return t.text(\"Set visibility window\"),{object:t,click:i}}(e.track.type))),t}multiSelectMenuItems(e){const t=[],i=e.browser.getSelectedTrackViews();var n;return!0===(n=i.map((({track:e})=>e.type)),1===[...new Set(n)].length)?(t.push(...this.defaultMenuItems(e)),\"wig\"===e.track.type&&(t.push(\"
\"),t.push(function(){const e=Bt(\"
\");function t(e){const t=so.Dark2,i=Math.floor(Math.random()*t.length),n=`auto-scale-group-${s()}`;wo[n]=t[i];const r=this.browser.getSelectedTrackViews();for(const{track:e}of r)e.autoscaleGroup=n;this.browser.updateViews()}return e.text(\"Group autoscale\"),{object:e,doAllMultiSelectedTracks:!0,click:t}}()))):Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),t}}function Fo({trackView:e,label:t,option:i}){const n=Bt(\"
\");return n.text(t),{object:n,click:()=>e.presentColorPicker(i)}}function vo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.color=void 0,e.repaintViews()}}}function yo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.altColor=void 0,e.repaintViews()}}}function Ao(e){return e.name}function Co(e){return void 0===e.type||po.has(e.type)}class _o{constructor(e,t){this.browser=e,this.$container=Bt(\"
\",{class:\"igv-generic-dialog-container\"}),t.append(this.$container),this.$container.offset({left:0,top:0});const i=Bt(\"
\",{class:\"igv-generic-dialog-header\"});this.$container.append(i),u(i[0],(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$minimum);const n=Bt(\"
\");n.text(\"Minimum\"),this.$minimum.append(n),this.$minimum_input=Bt(\"\"),this.$minimum.append(this.$minimum_input),this.$maximum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$maximum);const r=Bt(\"
\");r.text(\"Maximum\"),this.$maximum.append(r),this.$maximum_input=Bt(\"\"),this.$maximum.append(this.$maximum_input);const s=Bt(\"
\",{class:\"igv-generic-dialog-ok-cancel\"});this.$container.append(s),this.$ok=Bt(\"
\"),s.append(this.$ok),this.$ok.text(\"OK\"),this.$cancel=Bt(\"
\"),s.append(this.$cancel),this.$cancel.text(\"Cancel\"),this.$cancel.on(\"click\",(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),p(this.$container.get(0),i.get(0)),this.$container.hide()}configure(e){let t;if(Array.isArray(e)){t={min:Number.MAX_SAFE_INTEGER,max:-Number.MAX_SAFE_INTEGER};for(const i of e)i.track.dataRange&&(t.min=Math.min(i.track.dataRange.min,t.min),t.max=Math.max(i.track.dataRange.max,t.max))}else t=e.track.dataRange;t&&(this.$minimum_input.val(t.min),this.$maximum_input.val(t.max)),this.$minimum_input.unbind(),this.$minimum_input.on(\"keyup\",(t=>{13===t.keyCode&&this.processResults(e),t.stopImmediatePropagation()})),this.$maximum_input.unbind(),this.$maximum_input.on(\"keyup\",(t=>{13===t.keyCode&&(t.stopImmediatePropagation(),this.processResults(e))})),this.$ok.unbind(),this.$ok.on(\"click\",(t=>{this.processResults(e)}))}processResults(e){if(\"\"!==this.$minimum_input.val()&&\"\"!==this.$maximum_input.val()){const t=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());if(isNaN(t)||isNaN(i))this.browser.alert.present(new Error(\"Must input numeric values\"),void 0);else{const n=Array.isArray(e)?e:[e];for(const e of n)e.track.setDataRange({min:t,max:i})}this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\")}this.$container.offset({left:0,top:0}),this.$container.hide()}present(e){const t=e.offset().top,i=Bt(\"body\").scrollTop();this.$container.offset({left:e.width()-this.$container.width(),top:t+i}),this.$container.show()}}const xo={configureHighDPICanvas:function(e,t,i){const n=window.devicePixelRatio;e.canvas.style.width=`${t}px`,e.canvas.width=Math.floor(n*t),e.canvas.style.height=`${i}px`,e.canvas.height=Math.floor(n*i),e.scale(n,n)},setProperties:function(e,t){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];e[i]=n}},strokeLine:function(e,t,i,n,r,s){t=Math.floor(t)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(e.save(),xo.setProperties(e,s)),e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke(),s&&e.restore()},fillRect:function(e,t,i,n,r,s){s&&(e.save(),xo.setProperties(e,s)),e.fillRect(t,i,n,r),s&&e.restore()},fillPolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.fill(),n&&e.restore()},strokePolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.stroke(),n&&e.restore()},fillText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.fillText(t,0,0)}else e.fillText(t,i,n);(r||s)&&e.restore()},strokeText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.strokeText(t,0,0)}else e.strokeText(t,i,n);(r||s)&&e.restore()},strokeCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.stroke(),r&&e.restore()},fillCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.fill(),r&&e.restore()},drawArrowhead:function(e,t,i,n,r){e.save(),n||(n=5),r&&(e.lineWidth=r),e.beginPath(),e.moveTo(t,i-n/2),e.lineTo(t,i+n/2),e.lineTo(t+n,i),e.lineTo(t,i-n/2),e.closePath(),e.fill(),e.restore()},dashedLine:function(e,t,i,n,r,s,o={}){void 0===s&&(s=2),e.setLineDash([s,s]),xo.strokeLine(e,t,i,n,r,o),e.setLineDash([])},roundRect:function(e,t,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),e.beginPath(),e.moveTo(t+s,i),e.lineTo(t+n-s,i),e.quadraticCurveTo(t+n,i,t+n,i+s),e.lineTo(t+n,i+r-s),e.quadraticCurveTo(t+n,i+r,t+n-s,i+r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t,i+r,t,i+r-s),e.lineTo(t,i+s),e.quadraticCurveTo(t,i,t+s,i),e.closePath(),a&&e.stroke(),o&&e.fill()},polygon:function(e,t,i,n,r){void 0===r&&(r=!0),e.beginPath();var s=t.length;e.moveTo(t[0],i[0]);for(var o=1;o{for(let t=0;t{e.translate(t,0),e.scale(-1,1),e.translate(-t,0)}};function ko(e,t,i){var n,r=t.length;for(e.beginPath(),e.moveTo(t[0],i[0]),n=1;n1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:Oo;So&&So(e,null);let n=t.length;for(;n--;){let r=t[n];if(\"string\"==typeof r){const e=i(r);e!==r&&(Eo(t)||(t[n]=e),r=e)}e[r]=!0}return e}function Zo(e){for(let t=0;t/gm),pa=Ro(/\\${[\\w\\W]*}/gm),ga=Ro(/^data-[\\-\\w.\\u00B7-\\uFFFF]/),ma=Ro(/^aria-[\\-\\w]+$/),wa=Ro(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i),ba=Ro(/^(?:\\w+script|data):/i),Fa=Ro(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g),va=Ro(/^html$/i),ya=Ro(/^[a-z][.\\w]*(-[.\\w]+)+$/i);var Aa=Object.freeze({__proto__:null,MUSTACHE_EXPR:ua,ERB_EXPR:fa,TMPLIT_EXPR:pa,DATA_ATTR:ga,ARIA_ATTR:ma,IS_ALLOWED_URI:wa,IS_SCRIPT_OR_DATA:ba,ATTR_WHITESPACE:Fa,DOCTYPE_NAME:va,CUSTOM_ELEMENT:ya});const Ca=1,_a=3,xa=7,ka=8,Ia=9,Sa=function(){return\"undefined\"==typeof window?null:window};var Ea=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Sa();const i=t=>e(t);if(i.version=\"3.1.6\",i.removed=[],!t||!t.document||t.document.nodeType!==Ia)return i.isSupported=!1,i;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:h,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:p}=t,g=l.prototype,m=ea(g,\"cloneNode\"),w=ea(g,\"remove\"),b=ea(g,\"nextSibling\"),F=ea(g,\"childNodes\"),v=ea(g,\"parentNode\");if(\"function\"==typeof a){const e=n.createElement(\"template\");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,A=\"\";const{implementation:C,createNodeIterator:_,createDocumentFragment:x,getElementsByTagName:k}=n,{importNode:I}=r;let S={};i.isSupported=\"function\"==typeof Io&&\"function\"==typeof v&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:E,ERB_EXPR:N,TMPLIT_EXPR:B,DATA_ATTR:M,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:D,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:L}=Aa;let{IS_ALLOWED_URI:z}=Aa,H=null;const P=Xo({},[...ta,...ia,...na,...sa,...aa]);let O=null;const U=Xo({},[...ca,...la,...ha,...da]);let q=Object.seal(Do(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,V=null,j=!0,W=!0,G=!1,$=!0,K=!1,Y=!0,X=!1,Z=!1,J=!1,ee=!1,te=!1,ie=!1,ne=!0,re=!1,se=!0,oe=!1,ae={},ce=null;const le=Xo({},[\"annotation-xml\",\"audio\",\"colgroup\",\"desc\",\"foreignobject\",\"head\",\"iframe\",\"math\",\"mi\",\"mn\",\"mo\",\"ms\",\"mtext\",\"noembed\",\"noframes\",\"noscript\",\"plaintext\",\"script\",\"style\",\"svg\",\"template\",\"thead\",\"title\",\"video\",\"xmp\"]);let he=null;const de=Xo({},[\"audio\",\"video\",\"img\",\"source\",\"image\",\"track\"]);let ue=null;const fe=Xo({},[\"alt\",\"class\",\"for\",\"id\",\"label\",\"name\",\"pattern\",\"placeholder\",\"role\",\"summary\",\"title\",\"value\",\"style\",\"xmlns\"]),pe=\"http://www.w3.org/1998/Math/MathML\",ge=\"http://www.w3.org/2000/svg\",me=\"http://www.w3.org/1999/xhtml\";let we=me,be=!1,Fe=null;const ve=Xo({},[pe,ge,me],Uo);let ye=null;const Ae=[\"application/xhtml+xml\",\"text/html\"];let Ce=null,_e=null;const xe=n.createElement(\"form\"),ke=function(e){return e instanceof RegExp||e instanceof Function},Ie=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!_e||_e!==e){if(e&&\"object\"==typeof e||(e={}),e=Jo(e),ye=-1===Ae.indexOf(e.PARSER_MEDIA_TYPE)?\"text/html\":e.PARSER_MEDIA_TYPE,Ce=\"application/xhtml+xml\"===ye?Uo:Oo,H=Wo(e,\"ALLOWED_TAGS\")?Xo({},e.ALLOWED_TAGS,Ce):P,O=Wo(e,\"ALLOWED_ATTR\")?Xo({},e.ALLOWED_ATTR,Ce):U,Fe=Wo(e,\"ALLOWED_NAMESPACES\")?Xo({},e.ALLOWED_NAMESPACES,Uo):ve,ue=Wo(e,\"ADD_URI_SAFE_ATTR\")?Xo(Jo(fe),e.ADD_URI_SAFE_ATTR,Ce):fe,he=Wo(e,\"ADD_DATA_URI_TAGS\")?Xo(Jo(de),e.ADD_DATA_URI_TAGS,Ce):de,ce=Wo(e,\"FORBID_CONTENTS\")?Xo({},e.FORBID_CONTENTS,Ce):le,Q=Wo(e,\"FORBID_TAGS\")?Xo({},e.FORBID_TAGS,Ce):{},V=Wo(e,\"FORBID_ATTR\")?Xo({},e.FORBID_ATTR,Ce):{},ae=!!Wo(e,\"USE_PROFILES\")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,W=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,K=e.SAFE_FOR_TEMPLATES||!1,Y=!1!==e.SAFE_FOR_XML,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,se=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,z=e.ALLOWED_URI_REGEXP||wa,we=e.NAMESPACE||me,q=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&\"boolean\"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(q.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),K&&(W=!1),te&&(ee=!0),ae&&(H=Xo({},aa),O=[],!0===ae.html&&(Xo(H,ta),Xo(O,ca)),!0===ae.svg&&(Xo(H,ia),Xo(O,la),Xo(O,da)),!0===ae.svgFilters&&(Xo(H,na),Xo(O,la),Xo(O,da)),!0===ae.mathMl&&(Xo(H,sa),Xo(O,ha),Xo(O,da))),e.ADD_TAGS&&(H===P&&(H=Jo(H)),Xo(H,e.ADD_TAGS,Ce)),e.ADD_ATTR&&(O===U&&(O=Jo(O)),Xo(O,e.ADD_ATTR,Ce)),e.ADD_URI_SAFE_ATTR&&Xo(ue,e.ADD_URI_SAFE_ATTR,Ce),e.FORBID_CONTENTS&&(ce===le&&(ce=Jo(ce)),Xo(ce,e.FORBID_CONTENTS,Ce)),se&&(H[\"#text\"]=!0),X&&Xo(H,[\"html\",\"head\",\"body\"]),H.table&&(Xo(H,[\"tbody\"]),delete Q.tbody),e.TRUSTED_TYPES_POLICY){if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');y=e.TRUSTED_TYPES_POLICY,A=y.createHTML(\"\")}else void 0===y&&(y=function(e,t){if(\"object\"!=typeof e||\"function\"!=typeof e.createPolicy)return null;let i=null;const n=\"data-tt-policy-suffix\";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r=\"dompurify\"+(i?\"#\"+i:\"\");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn(\"TrustedTypes policy \"+r+\" could not be created.\"),null}}(p,s)),null!==y&&\"string\"==typeof A&&(A=y.createHTML(\"\"));Mo&&Mo(e),_e=e}},Se=Xo({},[\"mi\",\"mo\",\"mn\",\"ms\",\"mtext\"]),Ee=Xo({},[\"foreignobject\",\"annotation-xml\"]),Ne=Xo({},[\"title\",\"style\",\"font\",\"a\",\"script\"]),Be=Xo({},[...ia,...na,...ra]),Me=Xo({},[...sa,...oa]),Re=function(e){Po(i.removed,{element:e});try{v(e).removeChild(e)}catch(t){w(e)}},De=function(e,t){try{Po(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Po(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),\"is\"===e&&!O[e])if(ee||te)try{Re(t)}catch(e){}else try{t.setAttribute(e,\"\")}catch(e){}},Te=function(e){let t=null,i=null;if(J)e=\"\"+e;else{const t=qo(e,/^[\\r\\n\\t ]+/);i=t&&t[0]}\"application/xhtml+xml\"===ye&&we===me&&(e=''+e+\"\");const r=y?y.createHTML(e):e;if(we===me)try{t=(new f).parseFromString(r,ye)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(we,\"template\",null);try{t.documentElement.innerHTML=be?A:r}catch(e){}}const s=t.body||t.documentElement;return e&&i&&s.insertBefore(n.createTextNode(i),s.childNodes[0]||null),we===me?k.call(t,X?\"html\":\"body\")[0]:X?t.documentElement:s},Le=function(e){return _.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},ze=function(e){return e instanceof u&&(\"string\"!=typeof e.nodeName||\"string\"!=typeof e.textContent||\"function\"!=typeof e.removeChild||!(e.attributes instanceof d)||\"function\"!=typeof e.removeAttribute||\"function\"!=typeof e.setAttribute||\"string\"!=typeof e.namespaceURI||\"function\"!=typeof e.insertBefore||\"function\"!=typeof e.hasChildNodes)},He=function(e){return\"function\"==typeof c&&e instanceof c},Pe=function(e,t,n){S[e]&&zo(S[e],(e=>{e.call(i,t,n,_e)}))},Oe=function(e){let t=null;if(Pe(\"beforeSanitizeElements\",e,null),ze(e))return Re(e),!0;const n=Ce(e.nodeName);if(Pe(\"uponSanitizeElement\",e,{tagName:n,allowedTags:H}),e.hasChildNodes()&&!He(e.firstElementChild)&&Go(/<[/\\w]/g,e.innerHTML)&&Go(/<[/\\w]/g,e.textContent))return Re(e),!0;if(e.nodeType===xa)return Re(e),!0;if(Y&&e.nodeType===ka&&Go(/<[/\\w]/g,e.data))return Re(e),!0;if(!H[n]||Q[n]){if(!Q[n]&&qe(n)){if(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,n))return!1;if(q.tagNameCheck instanceof Function&&q.tagNameCheck(n))return!1}if(se&&!ce[n]){const t=v(e)||e.parentNode,i=F(e)||e.childNodes;if(i&&t){for(let n=i.length-1;n>=0;--n){const r=m(i[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,b(e))}}}return Re(e),!0}return e instanceof l&&!function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:we,tagName:\"template\"});const i=Oo(e.tagName),n=Oo(t.tagName);return!!Fe[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?\"svg\"===i:t.namespaceURI===pe?\"svg\"===i&&(\"annotation-xml\"===n||Se[n]):Boolean(Be[i]):e.namespaceURI===pe?t.namespaceURI===me?\"math\"===i:t.namespaceURI===ge?\"math\"===i&&Ee[n]:Boolean(Me[i]):e.namespaceURI===me?!(t.namespaceURI===ge&&!Ee[n])&&!(t.namespaceURI===pe&&!Se[n])&&!Me[i]&&(Ne[i]||!Be[i]):!(\"application/xhtml+xml\"!==ye||!Fe[e.namespaceURI]))}(e)?(Re(e),!0):\"noscript\"!==n&&\"noembed\"!==n&&\"noframes\"!==n||!Go(/<\\/no(script|embed|frames)/i,e.innerHTML)?(K&&e.nodeType===_a&&(t=e.textContent,zo([E,N,B],(e=>{t=Qo(t,e,\" \")})),e.textContent!==t&&(Po(i.removed,{element:e.cloneNode()}),e.textContent=t)),Pe(\"afterSanitizeElements\",e,null),!1):(Re(e),!0)},Ue=function(e,t,i){if(ne&&(\"id\"===t||\"name\"===t)&&(i in n||i in xe))return!1;if(W&&!V[t]&&Go(M,t));else if(j&&Go(R,t));else if(!O[t]||V[t]){if(!(qe(e)&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,e)||q.tagNameCheck instanceof Function&&q.tagNameCheck(e))&&(q.attributeNameCheck instanceof RegExp&&Go(q.attributeNameCheck,t)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(t))||\"is\"===t&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,i)||q.tagNameCheck instanceof Function&&q.tagNameCheck(i))))return!1}else if(ue[t]);else if(Go(z,Qo(i,T,\"\")));else if(\"src\"!==t&&\"xlink:href\"!==t&&\"href\"!==t||\"script\"===e||0!==Vo(i,\"data:\")||!he[e]){if(G&&!Go(D,Qo(i,T,\"\")));else if(i)return!1}else;return!0},qe=function(e){return\"annotation-xml\"!==e&&qo(e,L)},Qe=function(e){Pe(\"beforeSanitizeAttributes\",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:\"\",attrValue:\"\",keepAttr:!0,allowedAttributes:O};let r=t.length;for(;r--;){const s=t[r],{name:o,namespaceURI:a,value:c}=s,l=Ce(o);let h=\"value\"===o?c:jo(c);if(n.attrName=l,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Pe(\"uponSanitizeAttribute\",e,n),h=n.attrValue,Y&&Go(/((--!?|])>)|<\\/(style|title)/i,h)){De(o,e);continue}if(n.forceKeepAttr)continue;if(De(o,e),!n.keepAttr)continue;if(!$&&Go(/\\/>/i,h)){De(o,e);continue}K&&zo([E,N,B],(e=>{h=Qo(h,e,\" \")}));const d=Ce(e.nodeName);if(Ue(d,l,h)){if(!re||\"id\"!==l&&\"name\"!==l||(De(o,e),h=\"user-content-\"+h),y&&\"object\"==typeof p&&\"function\"==typeof p.getAttributeType)if(a);else switch(p.getAttributeType(d,l)){case\"TrustedHTML\":h=y.createHTML(h);break;case\"TrustedScriptURL\":h=y.createScriptURL(h)}try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),ze(e)?Re(e):Ho(i.removed)}catch(e){}}}Pe(\"afterSanitizeAttributes\",e,null)},Ve=function e(t){let i=null;const n=Le(t);for(Pe(\"beforeSanitizeShadowDOM\",t,null);i=n.nextNode();)Pe(\"uponSanitizeShadowNode\",i,null),Oe(i)||(i.content instanceof o&&e(i.content),Qe(i));Pe(\"afterSanitizeShadowDOM\",t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,a=null,l=null;if(be=!e,be&&(e=\"\\x3c!--\\x3e\"),\"string\"!=typeof e&&!He(e)){if(\"function\"!=typeof e.toString)throw $o(\"toString is not a function\");if(\"string\"!=typeof(e=e.toString()))throw $o(\"dirty is not a string, aborting\")}if(!i.isSupported)return e;if(Z||Ie(t),i.removed=[],\"string\"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Ce(e.nodeName);if(!H[t]||Q[t])throw $o(\"root node is forbidden and cannot be sanitized in-place\")}}else if(e instanceof c)n=Te(\"\\x3c!----\\x3e\"),s=n.ownerDocument.importNode(e,!0),s.nodeType===Ca&&\"BODY\"===s.nodeName||\"HTML\"===s.nodeName?n=s:n.appendChild(s);else{if(!ee&&!K&&!X&&-1===e.indexOf(\"<\"))return y&&ie?y.createHTML(e):e;if(n=Te(e),!n)return ee?null:ie?A:\"\"}n&&J&&Re(n.firstChild);const h=Le(oe?e:n);for(;a=h.nextNode();)Oe(a)||(a.content instanceof o&&Ve(a.content),Qe(a));if(oe)return e;if(ee){if(te)for(l=x.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(O.shadowroot||O.shadowrootmode)&&(l=I.call(r,l,!0)),l}let d=X?n.outerHTML:n.innerHTML;return X&&H[\"!doctype\"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Go(va,n.ownerDocument.doctype.name)&&(d=\"\\n\"+d),K&&zo([E,N,B],(e=>{d=Qo(d,e,\" \")})),y&&ie?y.createHTML(d):d},i.setConfig=function(){Ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},i.clearConfig=function(){_e=null,Z=!1},i.isValidAttribute=function(e,t,i){_e||Ie({});const n=Ce(e),r=Ce(t);return Ue(n,r,i)},i.addHook=function(e,t){\"function\"==typeof t&&(S[e]=S[e]||[],Po(S[e],t))},i.removeHook=function(e){if(S[e])return Ho(S[e])},i.removeHooks=function(e){S[e]&&(S[e]=[])},i.removeAllHooks=function(){S={}},i}();class Na{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container),this._input=document.createElement(\"input\"),this.input_container.appendChild(this._input);const r=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(r),this.ok=e(),r.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),r.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"keyup\",(e=>{\"Enter\"===e.code&&(\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)),e.stopImmediatePropagation()})),this.ok.addEventListener(\"click\",(()=>{\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)}));const s=()=>{this._input.value=\"\",i(this.container)};this.cancel.addEventListener(\"click\",s),u(n,s),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._input.value=e.value,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ba={licorice:\"#000000\",lead:\"#1e1e1e\",tungsten:\"#3a3a3a\",iron:\"#545453\",steel:\"#6e6e6e\",tin:\"#878687\",nickel:\"#888787\",aluminum:\"#a09fa0\",magnesium:\"#b8b8b8\",silver:\"#d0d0d0\",mercury:\"#e8e8e8\",snow:\"#ffffff\",cayenne:\"#891100\",mocha:\"#894800\",aspargus:\"#888501\",fern:\"#458401\",clover:\"#028401\",moss:\"#018448\",teal:\"#008688\",ocean:\"#004a88\",midnight:\"#001888\",eggplant:\"#491a88\",plum:\"#891e88\",maroon:\"#891648\",maraschino:\"#ff2101\",tangerine:\"#ff8802\",lemon:\"#fffa03\",lime:\"#83f902\",spring:\"#05f802\",seam_foam:\"#03f987\",turquoise:\"#00fdff\",aqua:\"#008cff\",blueberry:\"#002eff\",grape:\"#8931ff\",magenta:\"#ff39ff\",strawberry:\"#ff2987\",salmon:\"#ff726e\",cantaloupe:\"#ffce6e\",banana:\"#fffb6d\",honeydew:\"#cefa6e\",flora:\"#68f96e\",spindrift:\"#68fbd0\",ice:\"#68fdff\",sky:\"#6acfff\",orchid:\"#6e76ff\",lavender:\"#d278ff\",bubblegum:\"#ff7aff\",carnation:\"#ff7fd3\"};class Ma{constructor({parent:t,top:n,left:r,width:s,height:o,border:a,closeHandler:c}){let l=e({class:\"igv-ui-generic-container\"});t.appendChild(l),i(l),this.container=l,void 0!==n&&(this.container.style.top=`${n}px`),void 0!==r&&(this.container.style.left=`${r}px`),void 0!==s&&(this.container.style.width=`${s}px`),void 0!==o&&(this.container.style.height=`${o}px`),a&&(this.container.style.border=a);const h=e();this.container.appendChild(h),u(h,(e=>{i(this.container),\"function\"==typeof c&&c(e)})),p(this.container,h)}show(){n(this.container)}hide(){i(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Ra extends Ma{constructor({parent:e,width:t}){super({parent:e,width:t,border:\"1px solid gray\"})}configure(e,t){this.colorHandlers=t,this.setActiveColorHandler(\"color\"),this.createSwatches(e)}setActiveColorHandler(e){this.activeColorHandler=this.colorHandlers[e]}createSwatches(t){this.container.querySelectorAll(\".igv-ui-color-swatch\").forEach((e=>e.remove()));const i=Object.values(Ba);for(let t of i){const i=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(i),this.decorateSwatch(i,t)}if(t)for(let i of t){const t=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(t),this.decorateSwatch(t,i)}}decorateSwatch(e,t){e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(()=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(()=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),this.activeColorHandler(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),this.activeColorHandler(t)}))}}const Da={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};class Ta{constructor(t,n){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},n),this.container=e({class:\"igv-ui-alert-dialog-container\"}),t.appendChild(this.container),this.container.setAttribute(\"tabIndex\",\"-1\");const r=e();this.container.appendChild(r),this.errorHeadline=e(),r.appendChild(this.errorHeadline),this.errorHeadline.textContent=\"\";let s=e({class:\"igv-ui-alert-dialog-body\"});this.container.appendChild(s),this.body=e({class:\"igv-ui-alert-dialog-body-copy\"}),s.appendChild(this.body);let o=e();this.container.appendChild(o),this.ok=e(),o.appendChild(this.ok),this.ok.textContent=\"OK\";const a=()=>{\"function\"==typeof this.callback&&(this.callback(\"OK\"),this.callback=void 0),this.body.innerHTML=\"\",i(this.container)};this.ok.addEventListener(\"click\",(e=>{e.stopPropagation(),a()})),this.container.addEventListener(\"keypress\",(e=>{e.stopPropagation(),\"Enter\"===e.key&&a()})),p(this.container,r),i(this.container)}present(e,t){this.errorHeadline.textContent=e.message?\"ERROR\":\"\";let i=e.message||e;Da.hasOwnProperty(i)&&(i=Da[i]);const r=Ea.sanitize(i);this.body.innerHTML=r,this.callback=t,n(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class La{constructor(e){this.dialog=new Ta(e)}present(e,t){this.dialog.present(e,t)}}function za(e){if(e)switch(e.toLowerCase()){case\"bw\":case\"bigwig\":case\"wig\":case\"bedgraph\":case\"tdf\":return\"wig\";case\"vcf\":return\"variant\";case\"seg\":return\"seg\";case\"mut\":case\"maf\":return\"mut\";case\"bam\":case\"cram\":return\"alignment\";case\"hiccups\":case\"bedpe\":case\"bedpe-loop\":case\"biginteract\":return\"interact\";case\"bp\":return\"arc\";case\"gwas\":return\"gwas\";case\"bed\":case\"bigbed\":case\"bb\":case\"biggenepred\":case\"bignarrowpeak\":return\"bedtype\";case\"fasta\":return\"sequence\";case\"pytor\":return\"cnvpytor\";case\"qtl\":return\"qtl\";default:return\"annotation\"}}function Ha(e){e.featureType&&(e.type=e.type||e.featureType,e.featureType=void 0),\"junctions\"===e.type?e.type=\"junction\":\"bed\"===e.type?(e.type=\"annotation\",e.format=e.format||\"bed\"):\"annotations\"===e.type?e.type=\"annotation\":\"alignments\"===e.type?e.type=\"alignment\":\"bam\"===e.type?(e.type=\"alignment\",e.format=\"bam\"):\"vcf\"===e.type?(e.type=\"variant\",e.format=\"vcf\"):\"t2d\"===e.type?e.type=\"gwas\":\"FusionJuncSpan\"!==e.type||e.format?\"aed\"===e.type&&(e.type=\"annotation\",e.format=e.format||\"aed\"):e.format=\"fusionjuncspan\"}var Pa=Object.freeze({__proto__:null,inferTrackType:za,translateDeprecatedTypes:Ha});function Oa(e){const t=new Set([\"boolean\",\"number\",\"string\",\"symbol\"]),i=typeof e;return void 0!==e&&(t.has(i)||e.substring||e.toFixed)}function Ua(e,t){var i={oauthToken:e.oauthToken,headers:e.headers,withCredentials:e.withCredentials,filename:e.filename};return Object.assign(i,t)}const qa=function(e){var t,i;if(e&&e.length>0){t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of e)Number.isNaN(n.value)||(t=Math.min(t,n.value),i=Math.max(i,n.value));i>0&&(t=Math.min(0,t)),i<0&&(i=0)}else t=0,i=100;return{min:t,max:i}},Qa=function(e,t,i){let n=t.start,r=t.end;if(void 0===r)n-=i/2,r=n+i,r>e?(r=e,n=r-i):n<0&&(n=0,r=i);else if(r-ne?(r=e,n=r-i):(n=t-i/2,r=n+i)}t.start=Math.ceil(n),t.end=Math.floor(r)},Va=function(e){return\"number\"==typeof e?e-e==0:\"string\"==typeof e&&\"\"!==e.trim()&&Number.isFinite(+e)};async function ja(e){if(Mt(e)&&e.startsWith(\"https://drive.google.com\")){if(void 0===zs())throw Error(\"Google drive is referenced, but API key is not defined. An API key is required for Google Drive access\");const t=await async function(e){let t=\"https://www.googleapis.com/drive/v3/files/\"+Ps(e)+\"?supportsTeamDrives=true\";const i=zs();i&&(t+=\"&key=\"+i);const n=await fetch(t);let r=await n.json();if(r.error&&404===r.error.code){let e=\"https://www.googleapis.com/auth/drive.readonly\";const i=await Ls(e);if(!i)throw Error(r.error);{const e=await fetch(t,{headers:{Authorization:`Bearer ${i}`}});if(r=await e.json(),r.error)throw Error(r.error)}}return r}(e);return t.originalFileName||t.name}return zt(e)}function Wa(e){var t,i;return e>1e7?(t=\" mb\",i=e/1e6,Math.floor(i).toString()+t):e>1e4?(t=\" kb\",i=e/1e3,Rt(Math.floor(i))+t):Rt(e)+\" bp\"}function Ga(e){return Mt(e)&&e.startsWith(\"data:\")}function $a(t,i){const n=e({class:i});t.appendChild(n)}function Ka(e,t){t.parentNode.insertBefore(e,t)}function Ya(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function Xa(){return\"https:\"===window.location.protocol||\"localhost\"===window.location.hostname}class Za extends Ma{constructor({parent:e,top:t,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:e,top:t,left:i,width:n,height:r,border:\"1px solid gray\"}),Ja(this.container,o,s)}}const Ja=(t,i,n)=>{const r=Object.values(Ba);for(let n of r){const r=e({class:\"igv-ui-color-swatch\"});t.appendChild(r),ec(r,n,i)}if(n)for(let r of n){const n=e({class:\"igv-ui-color-swatch\"});t.appendChild(n),ec(n,r,i)}},ec=(e,t,i)=>{e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(i=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(t=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),i(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),i(t)}))};class tc{constructor(t,i,n,r){this.parent=t,this.popover=e({class:\"igv-ui-popover\"}),t.appendChild(this.popover),this.popoverHeader=e(),this.popover.appendChild(this.popoverHeader);const s=e();this.popoverHeader.appendChild(s),n&&(s.textContent=n);const o=e();this.popoverHeader.appendChild(o),o.appendChild(l(\"times\")),o.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault(),r?r():this.dismiss()})),!0===i&&p(this.popover,this.popoverHeader,{minX:0,minY:0}),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\"}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";const t=this.popover.parentNode,{x:i,y:n,width:r}=a(e,t);this.popover.style.top=`${n}px`;const{width:s}=this.popover.getBoundingClientRect(),o=i+s,c=o-r;this.popover.style.left=`${o>r?i-c:i}px`,this.popoverContent.style.maxWidth=`${Math.min(s,r)}px`}presentContentWithEvent(e,t){this.popover.style.display=\"block\",this.popoverContent.innerHTML=t,ic(e,this.popover,this.popoverContent)}presentMenu(e,t){if(0===t.length)return;this.popover.style.display=\"block\";const i=nc(t,this.popover);for(let e of i)this.popoverContent.appendChild(e.object);ic(e,this.popover,this.popoverContent)}dismiss(){this.popover.style.display=\"none\"}hide(){this.popover.style.display=\"none\",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const e=Object.keys(this);for(let t of e)this[t]=void 0}}function ic(e,t,i){const{x:n,y:r,width:s}=a(e,t.parentNode);t.style.top=`${r}px`;const{width:o}=t.getBoundingClientRect(),c=n+o,l=c-s;t.style.left=`${c>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}function nc(t,n){const r=t.map((function(t,r){let s;if(\"string\"==typeof t)s=e(),s.innerHTML=t;else if(\"Node\"==typeof t)s=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)s=function(t,i){const n=e({class:\"igv-ui-trackgear-popover-check-container\"}),r=h(\"check\",!0===i?\"#444\":\"transparent\");r.style.borderColor=\"gray\",r.style.borderWidth=\"1px\",r.style.borderStyle=\"solid\",n.appendChild(r);let s=e();return s.textContent=t,n.appendChild(s),n}(\"Show all bases\",t.value);else if(\"color\"===t.type){const o=new Za({parent:n.parentElement,width:364,colorHandler:e=>t.click(e)});s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);const a=e=>{o.show(),i(n),e.preventDefault(),e.stopPropagation()};s.addEventListener(\"click\",a),s.addEventListener(\"touchend\",a),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function c(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}s.addEventListener(\"click\",c),s.addEventListener(\"touchend\",c),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{object:s,init:t.init}}));return r}const rc=[[\"A\",\"T\"],[\"G\",\"C\"],[\"Y\",\"R\"],[\"W\",\"S\"],[\"K\",\"M\"],[\"D\",\"H\"],[\"B\",\"V\"]],sc=new Map;for(let _A of rc){const xA=_A[0],kA=_A[1];sc.set(xA,kA),sc.set(kA,xA),sc.set(xA.toLowerCase(),kA.toLowerCase()),sc.set(kA.toLowerCase(),xA.toLowerCase())}function oc(e){return sc.has(e)?sc.get(e):e}function ac(e){let t=\"\";for(let i of e)t+=sc.has(i)?sc.get(i):i;return t}function cc(e){let t=\"\",i=e.length;for(;i-- >0;){const n=e[i];t+=sc.has(n)?sc.get(n):n}return t}class lc{constructor(e,t,i,n){this.name=e,this.order=t,this.bpLength=i,this.altNames=n}getAltName(e){return this.altNames&&this.altNames.has(e)?this.altNames.get(e):this.name}}class hc{constructor(e,t,i,n){this.chr=e,this.start=t,this.end=i,this.features=n}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}containsRange(e){return this.chr===e.chr&&this.start<=e.start&&this.end>=e.end}get locusString(){return`${this.chr}:${this.start+1}-${this.end}`}}class dc extends hc{constructor(e,t,i,n){super(e,t,i,n)}getSequence(e,t){if(ethis.end)return null;const i=e-this.start,n=t-e;return this.features?this.features.substring(i,i+n):null}hasSequence(e,t){return e>=this.start&&t<=this.end}}const uc=Dt,fc=new Set([\"fastaURL\",\"indexURL\",\"cytobandURL\",\"indexed\"]);class pc{#e;chromosomes=new Map;sequences=new Map;constructor(e){this.fastaURL=e.fastaURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!fc.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.loadAll()}getSequenceRecord(e){return this.chromosomes.get(e)}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getSequence(e,t,i){if(0===this.sequences.size&&await this.loadAll(),!this.sequences.has(e))return;let n=this.sequences.get(e).find((e=>e.contains(t,i)));if(!n&&(n=this.sequences.get(e).find((e=>e.overlaps(t,i))),!n))return;t-=n.offset,i-=n.offset;let r=\"\";if(t<0)for(let e=t;e\")){a&&a.seq&&c.call(this,a,o++);const e=r.substr(1).split(/\\s+/),t=e[0].split(\":\");if(a.chr=t[0],a.seq=\"\",a.offset=0,t.length>1&&t[1].indexOf(\"-\")>0){const i=t[1].split(\"-\");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),e.length>1&&e[1].startsWith(\"@len=\"))try{a.length=parseInt(e[1].trim().substring(5))}catch(e){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&c.call(this,a,o)}function c(e,i){const n=e.length||e.offset+e.seq.length;if(t.has(e.chr)){const t=this.chromosomes.get(e.chr);t.bpLength=Math.max(t.bpLength,n)}else this.sequences.set(e.chr,[]),this.chromosomes.set(e.chr,new lc(e.chr,i,n)),t.add(e.chr);this.sequences.get(e.chr).push(new gc(e.offset,e.seq))}}getSequenceInterval(e,t,i){const n=this.sequences.get(e);if(n)for(let r of n){const n=r.sequence,s=r.offset,o=s+n.length;if(s<=t&&o>=i)return new dc(e,s,o,n)}}}class gc{constructor(e,t){this.offset=e,this.sequence=t}contains(e,t){return this.offset<=e&&this.end>=t}overlaps(e,t){return this.offsete}get end(){return this.offset+this.sequence.length}}const mc=Dt,wc=new Set([\"fastaURL\",\"indexURL\",\"compressedIndexURL\",\"cytobandURL\",\"indexed\"]);class bc{#e;chromosomes=new Map;constructor(e){this.file=e.fastaURL,this.indexFile=e.indexURL,this.compressedIndexFile=e.compressedIndexURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!wc.has(i)&&(t[i]=e[i]);this.config=t}getSequenceRecord(e){return this.chromosomes.get(e)}async init(){return this.getIndex()}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getIndex(){if(this.index)return this.index;{const e=await Qs.load(this.indexFile,Ua(this.config)),t=mc(e),i=t.length;let n=0,r=0;for(this.index={};nthis.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let t=0;te){c=!0;break}t=t)break}const l=i[i.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]0&&(w=Math.min(s-r,a-u),b+=m.substr(F,w),F+=w+l);F1){const e=Number.parseInt(t[1]),n=new lc(t[0],i++,e);this.chromosomes.set(t[0],n)}}}}class yc{constructor(e,t=!0){this.littleEndian=t,this.position=0,this.view=e,this.length=e.byteLength}dumpBytes(e=100){const t=this.position,i=[];for(let t=0;t<=e;t++)i.push(this.getByte());console.log(i.join(\" \")),this.setPosition(t)}setPosition(e){this.position=e}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position=0;i--)t=256*t+e[i];else for(let i=0;i0&&(t+=String.fromCharCode(e))}return t}getFloat(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e}getDouble(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e}skip(e){return this.position+=e,this.position}getVPointer(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Ac(i,t)}}class Ac{constructor(e,t){this.block=e,this.offset=t}isLessThan(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset}isEqualTo(e){return this.block===e.block&&this.offset===e.offset}print(){return this.block+\":\"+this.offset}}class Cc{static magic=2026540177;littleEndian=!0;nodeCache=new Map;static async loadBpTree(e,t,i){return new Cc(e,t,i).init()}constructor(e,t,i){this.path=e,this.config=t,this.startOffset=i}async init(){const e=await this.#t(this.startOffset,32);let t=e.getInt();if(t!==Cc.magic&&(e.setPosition(0),this.littleEndian=!this.littleEndian,e.littleEndian=this.littleEndian,t=e.getInt(),t!==Cc.magic))throw Error(`Bad magic number ${t}`);const i=e.getInt(),n=e.getInt(),r=e.getInt(),s=e.getLong(),o=e.getLong(),a=this.startOffset+32;return this.header={magic:t,blockSize:i,keySize:n,valSize:r,itemCount:s,reserved:o,nodeOffset:a},this}async search(e){this.header||await this.init();const{keySize:t,valSize:i}=this.header;if(16!==i&&8!==i)throw Error(`Unexpected valSize ${i}`);const n=async e=>{if(this.nodeCache.has(e))return this.nodeCache.get(e);{let n=await this.#t(e,4);const r=n.getByte();n.getByte();const s=n.getUShort(),o=[];if(1===r){const r=s*(t+i);n=await this.#t(e+4,r);for(let e=0;e{const i=await n(t);if(1!==i.type){let t=i.items[0].offset;for(let n=1;n>6&3]+_c[IA>>4&3]+_c[IA>>2&3]+_c[3&IA]);const kc=xc.map((e=>e.toLowerCase()));class Ic{littleEndian;metaIndex=new Map;constructor(e){this.url=e.twoBitURL||e.fastaURL,this.config=e,e.twoBitBptURL&&(this.bptURL=e.twoBitBptURL)}async init(){if(this.bptURL)this.index=await Cc.loadBpTree(this.bptURL,this.config,0);else{const e=await this._readIndex();this.index={search:async t=>e.has(t)?{offset:e.get(t)}:void 0}}}async readSequence(e,t,i){this.index||await this.init();const n=await this.getSequenceRecord(e);if(!n)return null;if(t<0)throw new TypeError(\"regionStart cannot be less than 0\");(void 0===i||i>n.dnaSize)&&(i=n.dnaSize);const r=this._getOverlappingBlocks(t,i,n.nBlocks),s=this._getOverlappingBlocks(t,i,n.maskBlocks),o=Math.floor(t/4),a=n.packedPos+o,c=Math.floor(i/4)-o+1,l=await Qs.loadArrayBuffer(this.url,{range:{start:a,size:c}}),h=new Uint8Array(l);let d=\"\";for(let e=t;ee;if(r[0]&&e>=r[0].start&&et)break;r.endn.contains(e,t,i)));if(n||(n=await this.#o(e,t,i),this.#a(n),this.#r.push(n)),n){const e=t-n.start,r=i-t;return n.features?n.features.substring(e,e+r):null}}#a(e){this.#r=this.#r.filter((t=>!e.contains(t))),this.#r.length===this.#s&&this.#r.shift(),this.browser&&this.browser.referenceFrameList.length<100&&(this.#r=this.#r.filter((e=>void 0!==this.browser.referenceFrameList.find((t=>t.overlaps(e))))))}getSequenceInterval(e,t,i){return this.#r.find((n=>n.contains(e,t,i)))}async#o(e,t,i){let n=t,r=i;if(i-t{s.features=await this.sequenceReader.readSequence(e,n,r),t(s)}));return this.#n=[s,t],t}}async init(){return this.sequenceReader.init()}get chromosomeNames(){return this.sequenceReader.chromosomeNames}getFirstChromosomeName(){return\"function\"==typeof this.sequenceReader.getFirstChromosomeName?this.sequenceReader.getFirstChromosomeName():void 0}#c(e){this.browser.referenceFrameList}}async function Nc(e,t){let i;return\"chromsizes\"===e.format?i=new vc(e.fastaURL||e.url):\"2bit\"===e.format||e.twoBitURL?i=new Ec(new Ic(e),t):Ga(e.fastaURL)||!e.indexURL?i=new pc(e):\"gbk\"===e.format||e.gbkURL||(i=new Ec(new bc(e),t)),await i.init(),i}const Bc={A:\"rgb( 0, 200, 0)\",C:\"rgb( 0,0,200)\",T:\"rgb(255,0,0)\",G:\"rgb(209,113, 5)\",N:\"rgb(80,80,80)\"};function Mc(e,t){if(e.length<6)return void console.log(\"Skipping line: \"+e.join(\" \"));var i={chr1:e[0],start1:Number.parseInt(e[1]),end1:Number.parseInt(e[2]),chr2:e[3],start2:Number.parseInt(e[4]),end2:Number.parseInt(e[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;t&&void 0===t.hiccups&&(t.hiccups=!!t.columnNames&&Dc(t.columnNames));const n=t&&t.hiccups,r=n?6:10;if(n||(e.length>6&&\".\"!==e[6]&&(i.name=e[6]),e.length>7&&\".\"!==e[7]&&(i.score=Number(e[7])),e.length>8&&\".\"!==e[8]&&(i.strand1=e[8]),e.length>9&&\".\"!==e[9]&&(i.strand2=e[9])),t){const n=t.colorColumn;n&&nr&&t.columnNames&&t.columnNames.length===e.length&&(i.extras=e.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function Rc(e,t){if(!(e.length<8))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),color:_s.createColorString(e[6]),value:Number(e[7])}}function Dc(e){return e&&(e.includes(\"fdrDonut\")||e.includes(\"fdr_donut\"))}function Tc(e,t){if(!(e.length<6))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),chr1:e[8],start1:Number.parseInt(e[9]),end1:Number.parseInt(e[10]),chr2:e[13],start2:Number.parseInt(e[14]),end2:Number.parseInt(e[15]),name:e[3],score:Number(e[4]),value:Number(e[5]),color:\".\"===e[7]?void 0:\"0\"===e[7]?\"rgb(0,0,0)\":e[7]};console.log(\"Skipping line: \"+e.join(\" \"))}class Lc{constructor(e){this.message=e}}const zc=new Map([[\"%09\",\"\\t\"],[\"%0A\",\"\\n\"],[\"%0D\",\"\\r\"],[\"%25\",\"%\"],[\"%3B\",\";\"],[\"%3D\",\"=\"],[\"%26\",\"&\"],[\"%2C\",\",\"]]);function Hc(e){if(!e.includes(\"%\"))return e;let t=\"\";for(let i=0;i0&&e2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3});let a=3;try{if(e.length>3&&a++0&&e[3].indexOf(\"=\")>0){const i=Pc(e[3],\"=\");o.attributes={};for(let e of i)o.attributes[e[0]]=e[1],null!=t.nameField&&e[0]===t.nameField&&(o.name=e[1])}o.name||(o.name=\".\"===e[3]?\"\":e[3])}if(e.length>4&&a++5&&a++6&&a++7&&a++8&&a++11&&a++1e3)return o;const i=e[10].replace(/,$/,\"\").split(\",\"),n=e[11].replace(/,$/,\"\").split(\",\");if(i.length!==n.length||t!==i.length)return o;const s=[];for(let e=0;e0&&(Yc(s,o.cdStart,o.cdEnd),o.exons=s)}if(t){let i=t.thicknessColumn,n=t.colorColumn;n&&n14&&(i.signal=Number(e[12]),i.pValue=Number(e[13]),i.qValue=Number(e[14])),i}function Qc(e,t){const i=Uc(e,t,9);if(i){const t=[\"Coverage\",\"% Showing Methylation\",\"N-mod\",\"N-canonical\",\"N-other mod\",\"N-delete\",\"N-fail\",\"N-dff\",\"N-nocall\"];for(let n=9;ni?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}function Xc(e,t){var i,n,r,s,o,a,c;if(!(e.length<9))return i=e[0],n=parseInt(e[1]),r=parseInt(e[2]),o=e[3],a=Number(e[4]),s=e[5].trim(),c=Number(e[6]),0===a&&(a=c),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:c,pValue:Number(e[7]),qValue:Number(e[8])}}function Zc(e,t){const i=Xc(e);return e.length>9&&(i.peak=Number(e[9])),i}function Jc(e,t){if(e.length<=3)return;const i={chr:e[0],start:parseInt(e[1]),end:parseInt(e[2]),value:Number(e[3])};if(t){let n=t.colorColumn;n&&n2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3}),a=[];for(let t=3;t\"),this.name&&t.push({name:\"Name\",value:this.name}),t.push({name:\"Type\",value:this.type}),t.push({name:\"Source\",value:this.source}),void 0!==this.score&&t.push({name:\"Score\",value:this.score}),t.push({name:\"Phase\",value:this.phase}),this.attributeString){const e=Pc(this.attributeString,this.delim);for(let[i,n]of e)void 0!==n&&n.length>0&&!ml.has(i.toLowerCase())&&t.push({name:i+\":\",value:n})}return t.push({name:\"Location\",value:`${this.chr}:${Rt(this.start+1)}-${Rt(this.end)}`}),t}getAttributeValue(e){if(this.hasOwnProperty(e))return this[e];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(e))return this._attributeCache.get(e);{const t=Pc(this.attributeString,this.delim);let i;for(let[n,r]of t)if(n===e){i=r;break}return this._attributeCache.set(e,i),i}}}class bl extends wl{constructor(e){super(e),this.exons=[],this.parts=[]}addExon(e){this.exons.push(e),this.start=Math.min(this.start,e.start),this.end=Math.max(this.end,e.end)}addPart(e){this.parts.push(e)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(e,t){return e.start-t.start}));let e=this.parts[0].start,t=this.parts[0].end;for(let i=1;i=t&&i.start<=e)return i}addCDS(e){let t;const i=this.exons;for(let n of i)if(n.start<=e.start&&n.end>=e.end){t=n;break}t?(t.cdStart=t.cdStart?Math.min(e.start,t.cdStart):e.start,t.cdEnd=t.cdEnd?Math.max(e.end,t.cdEnd):e.end,t.readingFrame=e.readingFrame):console.error(\"No exon found spanning \"+e.start+\"-\"+e.end),this.cdStart=this.cdStart?Math.min(e.start,this.cdStart):e.start,this.cdEnd=this.cdEnd?Math.max(e.end,this.cdEnd):e.end}addUTR(e){let t;const i=this.exons;for(let n=0;n=e.end){t=i[n];break}t?e.start===t.start&&e.end===t.end?t.utr=!0:(e.endt.start&&(t.cdEnd=e.start)):console.error(\"No exon found spanning \"+cds.start+\"-\"+cds.end)}finish(){this.assembleParts();var e=this.cdStart,t=this.cdEnd;this.exons.sort((function(e,t){return e.start-t.start})),e&&this.exons.forEach((function(i){(i.endt)&&(i.utr=!0)}))}popupData(e){const t=super.popupData(e);for(let i of this.exons)if(!i.pseudo&&e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}for(let i of this.parts)if(e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}return t}}function Fl(e,t){const i=t.format;if(e.length<9)return;const n=\"gff3\"===i?\"=\":\" \";return new wl({source:Hc(e[1]),type:e[2],chr:e[0],start:parseInt(e[3])-1,end:parseInt(e[4]),score:\".\"===e[5]?void 0:Number(e[5]),strand:e[6],phase:\".\"===e[7]?\".\":parseInt(e[7]),attributeString:e[8],delim:n})}function vl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):\"ID\"===e?i.id=t:\"Parent\"===e&&(i.parent=t)}return i}function yl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);let r,s;switch(i.type){case\"gene\":r=\"gene_id\";break;case\"transcript\":r=\"transcript_id\",s=\"gene_id\";break;default:s=\"transcript_id\"}for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):e===r?i.id=t:e===s&&(i.parent=t)}return i}function Al(e,t){if(!(e.length<7)){var i=e[0],n=e[1],r=parseInt(e[2]),s=parseInt(e[3]),o=parseInt(e[4]),a=parseInt(e[5]),c=e[6],l={chr:i,name:n,junction_left:r,junction_right:s,num_junction_reads:o,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=r,d=s;if(a>0)for(var u=c.split(\",\"),f=0;fd&&(d=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=d,l}}function Cl(e,t){if(e.length<7)return null;const i={chr:e[0],start:parseInt(e[1])-1,end:parseInt(e[2]),\"Strongest SNP-risk allele\":e[3],\"Disease/Phenotype\":e[4],\"P-value\":e[5],\"Odds ratio or beta\":e[6]};return e.length>6&&(i.PUBMEDID=`${e[7]}`),i}function _l(e,t){const i=t.customFormat;if(e.lengthvoid 0===n||!n.has(e.type))),\"gff3\"===this.format){const t=this.combineFeaturesById(e);i=this.combineFeaturesByType(t)}else i=this.combineFeaturesByType(e);return this.numberExons(i,t),this.nameFeatures(i),i}combineFeaturesById(e){const t=new Map,i=[];for(let n of e)if(gl(n.type)||pl(n.type)||!n.id)i.push(n);else{let e=t.get(n.chr);e||(e=new Map,t.set(n.chr,e));let i=e.get(n.id);i?i.push(n):e.set(n.id,[n])}for(let e of t.values())for(let t of e.values())if(t.length>1){const e=t[0];e.exons=[];for(let i of t)e.start=Math.min(e.start,i.start),e.end=Math.max(e.end,i.end),e.exons.push({start:i.start,end:i.end});i.push(e)}else i.push(t[0]);return i}combineFeaturesByType(e){const t=e.filter((e=>\"gene\"===e.type||e.type.endsWith(\"_gene\"))),i=Object.create(null);for(let e of t)i[e.id]=e;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;e=e.filter((e=>void 0===o||!o.has(e.type)));for(let t of e)if(pl(t.type)){const e=t.id;if(void 0!==e){const o=new bl(t);n[e]=o,r.push(o),s.add(t);const a=i[t.parent];a&&(o.geneObject=a,s.add(a))}}for(let t of e)if(gl(t.type)){const e=l(t);if(e)for(let i of e){let o=n[i];if(!o&&\"gtf\"===this.format){const e=Object.assign({},t);e.type=\"transcript\",o=new bl(e),n[i]=o,r.push(o)}if(void 0!==o){if(a=t.type,ll.has(a))if(e.length>1){const e=new wl(t);o.addExon(e)}else o.addExon(t);else o.addPart(t);s.add(t)}}}var a;r.forEach((function(e){\"function\"==typeof e.finish&&e.finish()}));const c=e.filter((e=>!s.has(e)));for(let e of c)r.push(e);return r;function l(e){return e.parent&&\"\"!==e.parent.trim()?e.parent.trim().split(\",\"):null}}numberExons(e,t){for(let i of e)if(i.exons&&(!t||i.end<=t.end&&i.start>t.start))for(let e=0;e1&&(t=e)}else{this.setDecoder(n.format);const e=i.split(this.delimiter||\"\\t\");try{const i=Object.assign({columnNames:t},n);if(this.decode(e,i))break;e.length>1&&(t=e)}catch(i){e.length>1&&(t=e)}}}if(t){n.columnNames=t;for(let e=0;e0&&console.error(`Error parsing line '${s}': ${c.message}`)):c&&t.push(c)}return i===Mc&&function(e){if(0==e.length)return;const t=e[0];if(void 0===t.score&&void 0!==t.name){for(let t of e)if(!Va(t.name)&&\".\"!==t.name)return;for(let t of e)t.score=Number(t.name),delete t.name}const i=e.filter((e=>e.chr1!==e.chr2));for(let t of i){const i=Object.assign({},t);i.dup=!0,e.push(i),t.chr=t.chr1,t.start=t.start1,t.end=t.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(t),\"gtf\"!==this.config.format&&\"gff3\"!==this.config.format&&\"gff\"!==this.config.format||!1===this.config.assembleGFF?t:new Il(this.config).combineFeatures(t)}setDecoder(e){switch(e){case\"broadpeak\":case\"regionpeak\":case\"peaks\":this.decode=Xc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"narrowpeak\":this.decode=Zc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedgraph\":this.decode=Jc,this.delimiter=/\\s+/;break;case\"wig\":this.decode=el,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gff3\":case\"gff\":this.decode=vl,this.delimiter=\"\\t\";break;case\"gtf\":this.decode=yl,this.delimiter=\"\\t\";break;case\"fusionjuncspan\":this.decode=Al,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gtexgwas\":this.skipRows=1,this.decode=Cl,this.delimiter=\"\\t\";break;case\"refflat\":this.decode=Gc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepred\":this.decode=jc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepredext\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"ensgene\":this.decode=jc,this.header.shift=1,this.delimiter=this.config.delimiter||/\\s+/;break;case\"refgene\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/,this.header.shift=1;break;case\"bed\":this.decode=Uc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gappedpeak\":this.decode=qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedmethyl\":this.decode=Qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedpe\":case\"hiccups\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-domain\":this.decode=Rc,this.headerLine=!0,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-loop\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\",this.header={colorColumn:7};break;case\"interact\":this.decode=Tc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"snp\":this.decode=tl,this.delimiter=\"\\t\";break;case\"rmsk\":this.decode=Vc,this.delimiter=\"\\t\";break;case\"gcnv\":this.decode=xl,this.delimiter=\"\\t\";break;case\"shoebox\":this.decode=il,this.delimiter=\"\\t\";break;default:const t=function(e){return Sl&&Sl[e]?function(e){const t=e.fields,i=[\"chr\",\"start\",\"end\"];for(let n=0;n4?parseInt(t[4].split(\"=\")[1],10):1,index:0}}function Rl(e){const t=e.split(/\\s+/);return{format:\"variableStep\",chrom:t[1].split(\"=\")[1],span:t.length>2?parseInt(t[2].split(\"=\")[1],10):1}}function Dl(t,i){const n=e({class:\"igv-menu-popup-check-container\"}),r=e();n.appendChild(r);const s=l(\"check\",!0===i?\"#444\":\"transparent\");r.appendChild(s);const o=e();return o.innerText=t,n.appendChild(o),n}function Tl(e,t){t=t||Number.MAX_SAFE_INTEGER;const i=[];e.sort((function(e,t){return e.start-t.start})),i.push(-1e3);for(let n of e){let e=0;const r=Math.min(i.length,t);for(e=0;e=i[e]){n.row=e,i[e]=n.end;break}n.row=e,i[e]=n.end}}async function Ll(e,t,i){const n=e=>{const i=Object.assign({},e);return i.chr=\"all\",i.start=t.getGenomeCoordinate(e.chr,e.start),i.end=t.getGenomeCoordinate(e.chr,e.end),i._f=e,i.exons&&delete i.exons,i},r=new Set(t.wgChromosomeNames),s=[];let o=0;for(let a of t.wgChromosomeNames){if(Array.isArray(e)){const i={};for(let n of e){const e=t.getChromosomeName(n.chr);i.hasOwnProperty(e)||(i[e]=[]),i[e].push(n)}e=i}const c=e[a];if(c){const e=i||1e4;for(let i of c){let a=t.getChromosomeName(i.chr);if(r.has(a))if(s.length0&&!i.startsWith(\"rgb(\")&&!i.startsWith(\"rgba(\")?`rgb(${i})`:i);var i;e.name||e.label?this.name=e.name||e.label:Ht(e.url)?this.name=e.url.name:Mt(e.url)&&!e.url.startsWith(\"data:\")&&(this.name=zt(e.url)),this.url=e.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=e.order,this.autoscaleGroup=e.autoscaleGroup,this.removable=void 0===e.removable||e.removable,this.minHeight=e.minHeight||Math.min(25,this.height),this.maxHeight=e.maxHeight||Math.max(1e3,this.height),e.onclick&&(this.onclick=e.onclick,e.onclick=void 0),e.description&&(\"function\"==typeof e.description?this.description=e.description:this.description=()=>e.description),e.hoverTextFields?this.hoverText=Pl.bind(this):\"function\"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(e){this._name=e,this.trackView&&this.trackView.setTrackLabelName(e)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}repaintViews(){this.trackView&&this.trackView.repaintViews()}getState(){const e={},t=Object.keys(this.config).filter((e=>{return!(void 0===(t=this.config[e])||\"function\"==typeof t||t instanceof Promise);var t}));for(const i of t)i.startsWith(\"_\")||(e[i]=this.config[i]);for(let t of Object.keys(e)){if(t.startsWith(\"_\"))continue;const i=this[t];void 0===i||!Oa(i)&&\"boolean\"!=typeof i&&\"metadata\"!==t||(e[t]=i)}const i=Object.assign({},Hl.defaults);if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))i[e]=this.constructor.defaults[e];for(let t of Object.keys(i))void 0!==this[t]&&i[t]!==this[t]&&(e[t]=this[t]);return!this.autoscale&&this.dataRange&&(e.min=this.dataRange.min,e.max=this.dataRange.max),this.autoscaleGroup&&(e.autoscaleGroup=this.autoscaleGroup),e}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(e){if(this.disposed)return;const t={};let i;for(let n of Object.keys(e))switch(n.toLowerCase()){case\"usescore\":t.useScore=1===e[n]||\"1\"===e[n]||\"on\"===e[n]||!0===e[n];break;case\"visibility\":switch(e[n]){case\"2\":case\"3\":case\"pack\":case\"full\":t.displayMode=\"EXPANDED\";break;case\"4\":case\"squish\":t.displayMode=\"SQUISHED\";break;case\"1\":case\"dense\":t.displayMode=\"COLLAPSED\"}break;case\"color\":case\"altcolor\":t[n]=e[n].startsWith(\"rgb(\")?e[n]:\"rgb(\"+e[n]+\")\";break;case\"featurevisiblitywindow\":case\"visibilitywindow\":t.visibilityWindow=Number.parseInt(e[n]);break;case\"maxheightpixels\":i=e[n].split(\":\"),3===i.length&&(t.minHeight=Number.parseInt(i[2]),t.height=Number.parseInt(i[1]),t.maxHeight=Number.parseInt(i[0]));break;case\"viewlimits\":if(!this.config.autoscale){i=e[n].split(\":\");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),Number.isNaN(r)||Number.isNaN(s)?console.warn(`Unexpected viewLimits value in track line: ${e.viewLimits}`):(t.autoscale=!1,t.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r)}case\"name\":t[n]=e[n];break;case\"url\":t.infoURL=e[n];break;case\"type\":const r=e[n];Ol.has(r)?t[n]=Ol.get(r):t[n]=r;break;case\"graphtype\":t.graphType=e[n];break;default:t[n]=e[n]}for(let e of Object.keys(t))if(!this.config.hasOwnProperty(e)||\"name\"===e&&this.config._derivedName){let i=t[e];if(\"true\"===i&&(i=!0),\"false\"===i&&(i=!1),this[e]=i,\"height\"===e&&this.trackView)try{const e=Number.parseInt(i);this.trackView.setTrackHeight(e)}catch(e){console.error(e)}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!Array.isArray(t)||0===t.length)return[];const i=e.genomicLocation,n=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2;return to(t,i-n,i+n)}extractPopupData(e,t){const i=new Set([\"row\",\"color\",\"chr\",\"start\",\"end\",\"cdStart\",\"cdEnd\",\"strand\",\"alpha\"]),n=[];let r,s;for(let t in e)if(e.hasOwnProperty(t)&&!i.has(t)&&Oa(e[t])){let i=e[t];n.push({name:Lt(t),value:i}),\"alleles\"===t?r=e[t]:\"alleleFreqs\"===t&&(s=e[t])}if(r&&s){r.endsWith(\",\")&&(r=r.substr(0,r.length-1)),s.endsWith(\",\")&&(s=s.substr(0,s.length-1));let i=r.split(\",\"),o=s.split(\",\");if(o.length>1){let r=[];for(let e=0;e=0;i--){let o=r[i].a;if(1===o.length){t||(t=this.getGenomeId());const i=Hl.getCravatLink(e.chr,e.start+1,s,o,t);console.log(i),i&&(n.push(\"
\"),n.push({html:i}),n.push(\"
\"))}}}}if(e.attributes)for(let t of Object.keys(e.attributes))n.push({name:t,value:e.attributes[t]});let o=`${e.chr}:${Rt(e.start+1)}-${Rt(e.end)}`;return e.strand&&(o+=` (${e.strand})`),n.push({name:\"Location\",value:o}),n}description(){const e=(e,t)=>`
${e}: ${t}
`;let t='
';if(this.url?Ht(this.url)?t+=e(\"Filename\",this.url.name):t+=e(\"URL\",this.url):t=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata)){t+=e(i,this.config.metadata[i])}for(let i of Object.keys(this.config)){if(i.startsWith(\"_\"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&Oa(n)&&(t+=e(i,n))}}}return t+=\"
\",t}getColorForFeature(e){return\"function\"==typeof this.color?this.color(feature):this.color}numericDataMenuItems(){const e=[];e.push(\"
\");let t=Bt(\"
\");if(t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),void 0!==this.logScale){function i(){this.logScale=!this.logScale,this.trackView.repaintViews()}t=Bt(Dl(\"Log scale\",this.logScale)),e.push({object:t,click:i})}return t=Bt(Dl(\"Autoscale\",this.autoscale)),e.push({object:t,click:function(){this.autoscaleGroup=void 0,this.autoscale=!this.autoscale,this.browser.updateViews()}}),e}setDataRange({min:e,max:t}){this.dataRange={min:e,max:t},this.autoscale=!1,this.autoscaleGroup=void 0,this.trackView.repaintViews()}async nextFeatureAfter(e,t,i){let n=this.trackView.viewports[0].cachedFeatures;if(n&&Array.isArray(n)&&n.length>0){if(this.browser.genome.getChromosomeName(n[0].chr)===e){const e=function(e,t,i=!0){const n=e=>(e.start+e.end)/2,r=i?(e,t)=>e.start-t.start+e.end-t.end:(e,t)=>t.start-e.start+t.end-e.end,s=Array.from(e);s.sort(r);let o=0,a=s.length;for(;o=t?o=e+1:a=e}return s[o]}(n,t,i);if(e)return e}}if(\"function\"==typeof this.featureSource.nextFeature)return this.featureSource.nextFeature(e,t,i,this.visibilityWindow)}dispose(){this.disposed=!0;for(let e of Object.keys(this))this[e]=void 0}static getCravatLink(e,t,i,n,r){if(\"hg38\"===r||\"GRCh38\"===r){return`Cravat ${i}->${n}`}}static localFileInspection(e){const t=Object.assign({},e),i={url:\"file\",indexURL:\"indexFile\"};for(const e of[\"url\",\"indexURL\"])t[e]&&t[e]instanceof File&&(t[i[e]]=t[e].name,delete t[e]);return t}}function Pl(e){if(!this.hoverTextFields)return;const t=this.clickedFeatures(e);if(t&&t.length>0){let e=\"\";for(let i=0;i0&&(e+=\"\\n\"),e=\"\";for(let t of this.hoverTextFields)e.length>0&&(e+=\"\\n\"),n.hasOwnProperty(t)?e+=n[t]:\"function\"==typeof n.getAttribute&&(e+=n.getAttribute(t))}return e}}const Ol=new Map([[\"wiggle_0\",\"wig\"],[\"bed\",\"bed\"],[\"bigBed\",\"bigBed\"],[\"bigWig\",\"bigWig\"]]);class Ul{constructor(e){switch(this.type=e||\"seg\",this.type){case\"mut\":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case\"maf\":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(e){let t;for(;void 0!==(t=await e.nextLine());)if(!t.startsWith(\"#\")){const e=t.split(\"\\t\");this.header={headings:e};break}return this.header}async parseFeatures(e){const t=[];let i;this.header||(this.header=await this.parseHeader(e)),\"seg\"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await e.nextLine());){const e=r.split(\"\\t\"),s=\"seg\"===this.type?Number(e[this.dataColumn]):e[this.dataColumn];if(e.length>this.dataColumn){const r=new ql({sample:e[this.sampleColumn],chr:e[this.chrColumn],start:parseInt(e[this.startColumn])-1,end:parseInt(e[this.endColumn]),value:s,valueColumnName:n});if(i){const t=this.extractExtraColumns(e);r.setAttributes({names:i,values:t})}t.push(r)}}return t}extractExtraColumns(e){const t=[];for(let i=0;i=0)return this.attributeValues[t]}}popupData(e,t){const i=new Set([\"chr\",\"start\",\"end\",\"sample\",\"value\",\"row\",\"color\",\"sampleKey\",\"uniqueSampleKey\",\"sampleId\",\"chromosome\",\"uniquePatientKey\"]),n=this.chr+\":\"+Rt(this.start+1)+\"-\"+Rt(this.end),r=[{name:\"Sample\",value:this.sample},{name:\"Location\",value:n},{name:this.valueColumnName?Lt(this.valueColumnName):\"Value\",value:this.value}];if(\"mut\"===e&&\"hg38\"===t){const e=this.extractCravatLink(t);e&&(r.push(\"
\"),r.push({html:e}),r.push(\"
\"))}if(this.attributeNames&&this.attributeNames.length>0)for(let e=0;e0)for(let n=0;n\"===t||\"<*>\"===t||\".\"===t)return\"NONVARIANT\";{const e=t.split(\",\").map((function(e){return 1===i&&1===e.length?\"SNP\":\"\"===e?\"NONVARIANT\":e.length>i&&$l(e)?\"INSERTION\":e.lengthe.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let t of i)if(this.alleles.push(t),\"SV\"!==this.type&&$l(t)){let i=t.length,n=e.length;const r=Math.min(i,n);let s=0;for(;s0&&n>0;){const r=s+i-1,o=s+n-1;if(t.charCodeAt(r)!==e.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(t.charCodeAt(r)!==e.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos),this.start===this.end&&(this.start-=.5,this.end+=.5)}}popupData(e,t){const i=`${Rt(this.pos)}`,n=this.start===this.end?`${Rt(this.start)} | ${Rt(this.start+1)}`:`${Rt(this.start+1)}-${Rt(this.end)}`,r=[{name:\"Chr\",value:this.chr},{name:\"Pos\",value:i},{name:\"Loc\",value:n},{name:\"ID\",value:this.names?this.names:\"\"},{name:\"Ref\",value:this.referenceBases},{name:\"Alt\",value:this.alternateBases.replace(\"<\",\"<\")},{name:\"Qual\",value:this.quality},{name:\"Filter\",value:this.filter}];if(this.type&&r.push({name:\"Type\",value:this.type}),\"SNP\"===this.type){let e=this.referenceBases;if(1===e.length){let i=this.alternateBases.split(\",\");for(let n of i)if(1===n.length){let i=Hl.getCravatLink(this.chr,this.pos,e,n,t);i&&(r.push(\"
\"),r.push({html:i}))}}}const s=Object.keys(this.info);if(this.info&&s.length>0){r.push({html:'
'});for(let e of s)r.push({name:e,value:Kl(decodeURIComponent(this.info[e]))})}return r}getInfo(e){return this.info?this.info[e]:void 0}isRefBlock(){return\"NONVARIANT\"===this.type}isFiltered(){return!(\".\"===this.filter||\"PASS\"===this.filter)}alleleFreq(){return this.info?this.info.AF:void 0}}class jl{constructor(e){this.mate=e,this.chr=e.info.CHR2,this.pos=Number.parseInt(e.info.END),this.start=this.pos-1,this.end=this.pos}get info(){return this.mate.info}get names(){return this.mate.names}get referenceBases(){return this.mate.referenceBases}get alternateBases(){return this.mate.alternateBases}get quality(){return this.mate.quality}get filter(){return this.mate.filter}get calls(){return this.mate.calls}getAttributeValue(e){return this.mate.getAttributeValue(e)}getInfo(e){this.mate.getInfo(e)}isFiltered(){return this.mate.isFiltered()}alleleFreq(){return this.mate.alleleFreq()}popupData(e,t){const i=[];return i.push(\"SV Breakpoint\"),i.push({name:\"Chr\",value:this.chr}),i.push({name:\"Pos\",value:`${Rt(this.pos)}`}),i.push({html:'
'}),i.push(\"SV\"),i.push(...this.mate.popupData(e,t)),i}}class Wl{constructor({formatFields:e,sample:t,token:i}){this.info={},this.sample=t;const n=i.split(\":\");for(let t=0;t\");for(let e of r)i.push({name:e,value:decodeURIComponent(this.info[e])});return i}}const Gl=new Set([\"A\",\"C\",\"T\",\"G\"].map((e=>e.charCodeAt(0))));function $l(e){for(let t=0;t\");if(!(t>2&&o>0)){console.log(\"Malformed VCF header line: \"+n);continue}const a=n.substring(2,t-1);i[a]||(i[a]={});const c=Tt(n.substring(t+1,o-1),\",\");for(let t of c){var r=t.split(\"=\");r.length>1&&(\"ID\"===r[0]?e=r[1]:s[r[0]]=r[1])}e&&(i[a][e]=s)}else if(n.startsWith(\"##contig\")&&t){const e=n.indexOf(\"\",e));const s=n.substring(e+4,r),o=t.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith(\"#CHROM\")){const e=n.split(\"\\t\");if(e.length>8){i.sampleNameMap=new Map;for(let t=9;t9){const r=Xl(e[8].split(\":\"));n.calls=[];for(let t=9;t{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))0||0==i.length||i.indexOf(\"x\")>0)continue;const s=e[this.chrCol],o=r(e[this.valueCol]),a=parseInt(i)-1,c=a+1;t.push(new eh({chr:s,start:a,end:c,value:o,line:n,columns:this.columns}))}}return t}static isGWAS(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class eh{constructor({chr:e,start:t,end:i,value:n,line:r,columns:s}){this.chr=e,this.start=t,this.end=i,this.value=n,this.line=r,this.columns=s}popupData(){const e=this.line.split(/\\t/);return this.columns.map((function(t,i){return{name:t,value:e[i]}}))}getAttribute(e){const t=this.line.split(/\\t/);for(let i=0;i0?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split(\"=\",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();t[e]=i}}return t}function ah(e){let t={},i=e.split(/\\s+/);if(2===i.length){i[1].split(\";\").forEach((function(e){let i=e.split(\"=\");\"color\"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:\"thickness\"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function ch(e,t){var i,n,r=e.columns;this.aed=e,this.allColumns=t,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=\".\",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let e=0;e0)for(let e=0;ee.maxv.isGreaterThan(t))));const i=[];let n;for(let t of e)n&&dh(n,t)?t.maxv.isGreaterThan(n.maxv)&&(n.maxv=t.maxv):(i.push(t),n=t);return i}function dh(e,t){const i=t.minv.block-e.maxv.block;return t.maxv.block-e.minv.block<5e6&&i<65e3}ch.prototype.popupData=function(){for(var e=[],t=this.aed,i=0;i=28){t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt();const e=t.getInt(),i=t.position+e;let r=0;for(;t.positions)t.getInt(),t.getVPointer(),t.getVPointer(),t.getLong(),t.getLong();else{i[e]=[];const n=t.getInt();for(let s=0;sr&&(r=s.block),i[e].push([n,s]))}}}o>0&&(this.indices[e]={binIndex:i,loffset:n})}this.lastBlockPosition=r}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=this.reg2bins(t,i);if(0==e.length)return[];const r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let i of t){const t=i[0],n=i[1];r.push({minv:t,maxv:n,bin:e})}}let s=e[this.depth][0];do{if(n.binIndex[s])break;s>1+(this.getParentBin(s)<<3)?s--:s=this.getParentBin(s)}while(0!=s);return hh(r,n.loffset[s])}return[]}getParentBin(e){return 0==e?0:e-1>>3}reg2bins(e,t){(e-=1)<1&&(e=1),t>2**34&&(t=2**34),t-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(e>>r),o=n+(t>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class fh{constructor(){}async parse(e,t){const i=[];let n=Number.MAX_SAFE_INTEGER,r=0;const s=new yc(new DataView(e)),o=s.getInt(),a={};if(!(21578050===o||t&&21578324===o))throw new Error(indexURL+\" is not a \"+(t?\"tabix\":\"bai\")+\" file\");{const e=s.getInt();if(t){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let t=0;tr&&(r=o.block),e[t].push([i,o]))}}}const c=s.getInt();for(let e=0;e0&&(i[t]={binIndex:e,linearIndex:o})}this.firstBlockPosition=n,this.lastBlockPosition=r,this.indices=i,this.sequenceIndexMap=a,this.tabix=t}}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=function(e,t){const i=[];t>=1<<29&&(t=1<<29);return--t,i.push([0,0]),i.push([1+(e>>26),1+(t>>26)]),i.push([9+(e>>23),9+(t>>23)]),i.push([73+(e>>20),73+(t>>20)]),i.push([585+(e>>17),585+(t>>17)]),i.push([4681+(e>>14),4681+(t>>14)]),i}(t,i),r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let e of t){const t=e[0],i=e[1];r.push({minv:t,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(t>>14,s-1),c=Math.min(i>>14,s-1);for(let e=a;e<=c;e++){const t=n.linearIndex[e];if(t){o=t;break}}return hh(r,o)}return[]}}class ph{constructor(){this.tribble=!0}async parse(e){let t=0;this.chrIndex={},this.lastBlockPosition=[];const i=new yc(new DataView(e));!function(e){e.getInt(),e.getInt();const t=e.getInt();if(e.getString(),e.getLong(),e.getLong(),e.getString(),e.getInt(),t>=3){let t=e.getInt();for(;t-- >0;)e.getString(),e.getString()}}(i);let n=i.getInt();for(;n-- >0;){let e=i.getString();const n=i.getInt(),r=i.getInt(),s=i.getInt();i.getInt(),i.getInt();let o=i.getLong();const a=[];for(let e=0;et&&(t=e)}this.chrIndex[e]={chr:e,blocks:a,longestFeature:s,binWidth:n}}this.lastBlockPosition=t}get sequenceNames(){return Object.keys(this.chrIndex)}chunksForRange(e,t,i){const n=this.chrIndex[e];if(n){const e=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(t-r,0),a=Math.floor(o/s);if(a>=e.length)return[];{const t=Math.min(Math.floor((i-1)/s),e.length-1),n=e[a].min,r=e[t].max;if(0===r-n)return[];return[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function gh(e,t){let i=await Qs.loadArrayBuffer(e,Ua(t)),n=new DataView(i);if(31===n.getUint8(0)&&139===n.getUint8(1)){i=gs(i).buffer,n=new DataView(i)}switch(n.getInt32(0,!0)){case 21578050:return async function(e){const t=new fh;return await t.parse(e,!1),t}(i);case 21578324:return async function(e){const t=new fh;return await t.parse(e,!0),t}(i);case 21582659:return async function(e){const t=new uh;return t.parse(e),t}(i);case 1480870228:return async function(e){const t=new ph;return t.parse(e),t}(i);case 38359875:throw Error(\"CSI version 2 is not supported.\");default:throw Error(`Unrecognized index type: ${e}`)}}function mh(e){return\"string\"==typeof e||e instanceof String?new wh(e):new bh(e)}class wh{constructor(e){this.data=e,this.ptr=0}nextLine(){var e=this.ptr,t=this.data.indexOf(\"\\n\",e),i=this.data;if(t>0)return this.ptr=t+1,t>e&&\"\\r\"===i.charAt(t-1)?i.substring(e,t-1):i.substring(e,t);var n=i.length;return this.ptr=n,e>=n?void 0:i.substring(e)}}class bh{constructor(e){this.data=e,this.length=this.data.length,this.ptr=0}nextLine(){if(this.ptr>=this.data.length)return;let e=this.ptr;const t=this.data;let i=\"\",n=!1;for(;e0)for(var a=0;a{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])};class yh{constructor(e){this.config=e,this.cacheBlocks=0!=e.cacheBlocks,this.cache=void 0}async getData(e,t){const i=e.block,n=t.block,r=0===t.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const e of s)o+=e.byteLength;const a=new Uint8Array(o);let c=0;for(const e of s)a.set(e,c),c+=e.byteLength;return a}async getInflatedBlocks(e,t,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=e&&(n.endBlock>=t||i&&n.nextEndBlock===t)){const i=e-n.startBlock,r=t-n.startBlock;return Ch(n.buffer,i,r)}{let r;if(!n||n.startBlock>t||n.endBlock=n.endBlock)o=n.buffer;else{const i=Math.max(0,e-n.startBlock);let r;if(t>=n.endBlock)r=n.buffer.byteLength;else{const e=Ah(n.buffer);for(let i=0;in.endBlock){const e=await this.loadBLockData(n.endBlock,t,{skipStart:!0,skipEnd:i});s.push(e)}r=function(e){if(1===e.length)return e[0];let t=0;for(const i of e)t+=i.byteLength;const i=new Uint8Array(t);let n=0;for(const t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(s)}let s=t;if(i){const e=Ah(r);t=e[e.length-1]}return this.cache={startBlock:e,endBlock:t,nextEndBlock:s,buffer:r},Ch(r)}}return Ch(await this.loadBLockData(e,t,{skipEnd:i}))}async loadBLockData(e,t,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!(i&&i.skipEnd)){const e=Ua(n,{range:{start:t,size:26}}),i=await Qs.loadArrayBuffer(n.url,e);s=vh(i)}if(r){const t=Ua(n,{range:{start:e,size:26}}),i=await Qs.loadArrayBuffer(n.url,t);e+=vh(i)}const o=Ua(n,{range:{start:e,size:t+s-e}});return Qs.loadArrayBuffer(n.url,o)}}function Ah(e){const t=e.byteLength;let i=0;const n=[0];for(;i{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))<_h)return Number.MIN_VALUE}return Number(e)};for(;void 0!==(n=e.nextLine());){const e=n.split(this.delimiter);if(e.length===this.columns.length){const i=e[this.posColumn];if(i.indexOf(\";\")>0||0==i.length||i.indexOf(\"x\")>0)continue;const n=e[this.chrColumn],s=r(e[this.pValueColumn]),o=parseInt(i)-1,a=o+1,c=e[this.snpColumn],l=e[this.phenotypeColumn],h=new kh({chr:n,start:o,end:a,pValue:s,snp:c,phenotype:l},this.columns,e);t.push(h)}}return t}static isQTL(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"],[\"rsid\",\"variant\",\"snp\"],[\"phenotype\",\"gene\",\"gene_id\",\"molecular_trait_id\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class kh{constructor({chr:e,start:t,end:i,pValue:n,snp:r,phenotype:s},o,a){this.chr=e,this.start=t,this.end=i,this.pValue=n,this.snp=r,this.phenotype=s,this.headers=o,this.tokens=a}popupData(){const e=[];for(let t=0;te.blocks)).map((e=>e.max)).reduce(((e,t)=>Math.min(e,t)),Number.MAX_SAFE_INTEGER),n=Ua(this.config,{bgz:e.tabix,range:{start:0,size:i}});t=mh(await Qs.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(t),this.header}if(\"service\"!==this.config.sourceType){let e;if(this.config._filecontents)e=this.config._filecontents,delete this.config._filecontents;else{const t=Ua(this.config);e=await Qs.loadByteArray(this.config.url,t)}e.length<5e8&&(e=(new TextDecoder).decode(e));let t=mh(e);this.header=await this.parser.parseHeader(t),t=mh(e),this.features=await this.parser.parseFeatures(t),this.sequenceNames=new Set;for(let e of this.features)this.sequenceNames.add(e.chr);return this.header}if(this.config.seqnamesURL){const e=Ua(this.config,{}),t=await Qs.loadString(this.config.seqnamesURL,e);t&&(this.sequenceNames=new Set(t.split(\",\").map((e=>e.trim())).filter((e=>e))))}if(this.config.headerURL){const e=Ua(this.config,{}),t=mh(await Qs.loadString(this.config.headerURL,e));return this.header=await this.parser.parseHeader(t),this.header}}getParser(e){switch(e.format){case\"vcf\":return new Yl(e);case\"seg\":return new Ul(\"seg\");case\"mut\":return new Ul(\"mut\");case\"maf\":return new Ul(\"maf\");case\"gwas\":return new Jl(e);case\"qtl\":return new xh(e);case\"aed\":return new nh(e);default:return new El(e)}}async loadFeaturesNoIndex(){if(this.features){const e=this.features;return delete this.features,e}{const e=Ua(this.config),t=await Qs.loadByteArray(this.config.url,e);if(!this.header){const e=mh(t);this.header=await this.parser.parseHeader(e)}const i=mh(t),n=[];return await this._parse(n,i),n}}async loadFeaturesWithIndex(e,t,i){const n=this.config;this.parser;const r=this.index.tabix,s=r?this.index.sequenceIndexMap[e]:e;if(void 0===s)return[];const o=this.index.chunksForRange(s,t,i);if(o&&0!==o.length){const s=[];for(let a of o){let o;if(r)o=await this._blockLoader.getData(a.minv,a.maxv);else{const e=Ua(n,{range:{start:a.minv.block,size:a.maxv.block-a.minv.block+1}});o=await Qs.loadString(n.url,e)}const c=mh(a.minv.offset?o.slice(a.minv.offset):o);await this._parse(s,c,e,i,t)}return s}return[]}async loadFeaturesFromService(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);const r=Ua(this.config),s=mh(await Qs.loadString(n,r)),o=[];return await this._parse(o,s),o}async _parse(e,t,i,n,r){let s=await this.parser.parseFeatures(t);if(s.sort((function(e,t){return e.chr===t.chr?e.start-t.start:e.chr.localeCompare(t.chr)})),void 0===i)for(let t of s)e.push(t);else{let t=!1;for(let o=0;on){e.push(a);break}a.end>=r&&a.start<=n&&(t||(t=!0,o>0&&e.push(s[o-1])),e.push(a))}}}}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return gh(this.config.indexURL,this.config)}async loadFeaturesFromDataURI(){if(this.features){const e=this.features;return delete this.features,e}{const e=vs(this.dataURI);let t=mh(e);this.header=await this.parser.parseHeader(t),this.header instanceof String&&this.header.startsWith(\"##gff-version 3\")&&(this.format=\"gff3\"),t=mh(e);const i=[];return await this._parse(i,t),i}}}const Sh=Mt;class Eh{constructor(e){this.config=e}async readFeatures(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&(\"function\"==typeof this.config.body?s.body=this.config.body({chr:e,start:t,end:i}):s.body=this.config.body.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i));const o=await Qs.load(n,s);if(o&&(r=\"function\"==typeof this.config.parser?this.config.parser(o):Sh(o)?JSON.parse(o):o),this.config.mappings){let e=Object.keys(this.config.mappings);for(let t of r)for(let i of e)t[i]=t[this.config.mappings[i]]}return r}}const Nh=function(e,t){this.config=e,this.genome=t,this.expandQueryInterval=!1};Nh.prototype.readFeatures=function(e,t,i){const n=Math.max(0,Math.floor(t));let r=Math.ceil(i);if(this.genome){const t=this.genome.getChromosome(e);t&&r>t.bpLength&&(r=t.bpLength)}const s=this.config.url+\"?db=\"+this.config.db+\"&table=\"+this.config.tableName+\"&chr=\"+e+\"&start=\"+n+\"&end=\"+r;return Qs.loadJson(s,this.config).then((function(e){return e?(e.forEach((function(e){e.hasOwnProperty(\"exonStarts\")&&e.hasOwnProperty(\"exonEnds\")&&e.hasOwnProperty(\"exonCount\")&&e.hasOwnProperty(\"cdsStart\")&&e.hasOwnProperty(\"cdsEnd\")&&function(e){var t,i,n,r,s,o;t=e.exonCount,i=e.exonStarts.split(\",\"),n=e.exonEnds.split(\",\"),r=[];for(var a=0;ao||e.cdsEnd=s&&e.cdsStart<=o&&(c.cdStart=e.cdsStart),e.cdsEnd>=s&&e.cdsEnd<=o&&(c.cdEnd=e.cdsEnd),r.push(c)}e.exons=r}(e)})),e):null}))};class Bh{featureCaches=[];gtexChrs=new Set([\"chr1\",\"chr10\",\"chr11\",\"chr12\",\"chr13\",\"chr14\",\"chr15\",\"chr16\",\"chr17\",\"chr18\",\"chr19\",\"chr2\",\"chr20\",\"chr21\",\"chr22\",\"chr3\",\"chr4\",\"chr5\",\"chr6\",\"chr7\",\"chr8\",\"chr9\",\"chrM\",\"chrX\",\"chrY\"]);constructor(e){this.config=e,this.url=e.url,this.tissueId=e.tissueSiteDetailId,this.datasetId=e.datasetId||\"gtex_v8\"}async readFeatures(e,t,i){const n=e.startsWith(\"chr\")?e:\"MT\"===e?\"chrM\":\"chr\"+e;if(!this.gtexChrs.has(n))return[];const r=Math.floor(t),s=Math.ceil(i),o=this.datasetId,a=this.url+\"?chromosome=\"+n+\"&start=\"+r+\"&end=\"+s+\"&tissueSiteDetailId=\"+this.tissueId+\"&datasetId=\"+o,c=await Qs.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?c.singleTissueEqtl.map((e=>new Mh(e))):[]}}class Mh{constructor(e){this.chr=e.chromosome,this.start=e.pos-1,this.end=this.start+1,this.snp=e.snpId,this.phenotype=e.geneSymbol,this.pValue=e.pValue,this.json=e}popupData(){return Object.keys(this.json).map((e=>({name:e,value:this.json[e]})))}}class Rh{constructor(e,t){if(this.config=e,this.genome=t,!e.format)throw Error('Format is required, and must be either \"bam\" or \"cram\"');if(this.format=e.format.toUpperCase(),\"BAM\"!==this.format&&\"VCF\"!==this.format)throw Error(`htsget format ${e.format} is not supported`)}async readHeaderData(){const e=`${Dh(this.config)}?class=header&format=${this.format}`,t=await Qs.loadJson(e,Ua(this.config));return await this.loadUrls(t.htsget.urls)}async readData(e,t,i){const n=`${Dh(this.config)}?format=${this.format}&referenceName=${e}&start=${Math.floor(t)}&end=${Math.ceil(i)}`,r=await Qs.loadJson(n,Ua(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(e){const t=[];for(let i of e)if(i.url.startsWith(\"data:\"))t.push(Promise.resolve(Th(i.url)));else{const e=Ua(this.config||{});i.headers&&(e.headers=Object.assign(e.headers||{},i.headers)),t.push(Qs.loadArrayBuffer(i.url,e))}return function(e){let t=0;for(let i of e)t+=i.byteLength;let i=0;const n=new Uint8Array(t);for(let t of e){const e=new Uint8Array(t);n.set(e,i),i+=e.length}return n}(await Promise.all(t))}static async inferFormat(e){try{const t=Dh(e),i=`${t}${t.includes(\"?\")?\"&\":\"?\"}class=header`,n=await Qs.loadJson(i,Ua(e));if(n.htsget){const t=n.htsget.format;if(\"BAM\"!==t&&\"VCF\"!==t)throw Error(`htsget format ${t} is not supported`);e.format=t.toLowerCase(),e.sourceType=\"htsget\",e.name||(e.name=await ja(e.url))}}catch(e){}}}function Dh(e){if(e.url&&e.endpoint&&e.id)return e.url+e.endpoint+e.id;if(e.endpoint&&e.id)return e.endpoint+e.id;if(e.url)return e.url.startsWith(\"htsget://\")?e.url.replace(\"htsget://\",\"https://\"):e.url;throw Error(\"Must specify either 'url', or 'endpoint' and 'id\")}function Th(e){const t=e.split(\",\"),i=t[0].split(\":\")[1];let n=t[1];n=i.indexOf(\"base64\")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>t[e])).filter((e=>this.sequenceNames.has(e)));n.length>0&&(i=n[0]),this.chrAliasTable.set(e,i)}else this.chrAliasTable.set(e,void 0)}return this.chrAliasTable.get(e)}}class Hh{constructor(e){this.genome=e}async nextFeature(e,t,i,n){let r=this.genome.chromosomeNames||[e],s=r.indexOf(e);if(s<0)return;const o=Math.min(1e4,n||1e4);let a=i?t:Math.max(t-o,0);for(;s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=i?a+o:Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=2){let e=t.getInt();for(this.windowFunctions=[];e-- >0;)this.windowFunctions.push(t.getString())}this.trackType=t.getString(),this.trackLine=t.getString();let i=t.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(t.getString());this.genomeID=t.getString(),this.flags=t.getInt(),this.compressed=!!(1&this.flags),e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:this.indexPos,size:this.indexSize}})),t=new yc(new DataView(e)),this.datasetIndex={};let n=t.getInt();for(;n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.datasetIndex[e]={position:i,size:n}}for(this.groupIndex={},n=t.getInt();n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.groupIndex[e]={position:i,size:n}}return this}async readDataset(e,t,i){const n=e+\"_\"+t+\"_\"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?\"\":\"/\"+t,s=\"all\"===e.toLowerCase()||void 0===i?\"0\":i.toString();let o;o=\"raw\"===t?\"/\"+e+\"/raw\":\"/\"+e+\"/z\"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const c=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new yc(new DataView(c));let h=l.getInt();const d={};for(;h-- >0;)d[l.getString()]=l.getString();const u=l.getString(),f=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:o,attributes:d,dataType:u,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const e=this.genome,t=this.groupCache[\"/\"];if(t)return t;{const t=await this.readGroup(\"/\"),i=t.chromosomes,n=t.maxZoom;n&&(this.maxZoom=Number(n));const r=t.totalCount;r&&(t.totalCount=Number(r));const s={};return i&&i.split(\",\").forEach((function(t){const i=e.getChromosomeName(t);s[i]=t})),this.chrAliasTable=s,this.groupCache[\"/\"]=t,t}}async readGroup(e){const t=this.groupCache[e];if(t)return t;{await this.readHeader();const t=this.groupIndex[e];if(void 0===t)return;const i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:t.position,size:t.size}}));if(!i)return;const n=new yc(new DataView(i)),r={name:e};let s=n.getInt();for(;s-- >0;){const e=n.getString(),t=n.getString();r[e]=t}return this.groupCache[e]=r,r}}async readTiles(e,t){if(e.sort((function(e,t){return e.position-t.position})),0===(e=e.filter((function(e){return e.size>0}))).length)return[];const i=[];for(let n of e){const e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:n.position,size:n.size}}));let r;try{r=this.compressed?ls(e).buffer:e}catch(e){console.error(e);continue}const s=new yc(new DataView(r)),o=s.getString();let a;switch(o){case\"fixedStep\":a=Oh(s,t);break;case\"variableStep\":a=Uh(s,t);break;case\"bed\":case\"bedWithName\":a=qh(s,t,o);break;default:throw\"Unknown tile type: \"+o}i.push(a)}return i}async readTile(e,t){let i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e.position,size:e.size}}));if(this.compressed){i=ls(i).buffer}const n=new yc(new DataView(i)),r=n.getString();switch(r){case\"fixedStep\":return Oh(n,t);case\"variableStep\":return Uh(n,t);case\"bed\":case\"bedWithName\":return qh(n,t,r);default:throw\"Unknown tile type: \"+r}}}function Oh(e,t){const i=e.getInt(),n=e.getInt(),r=e.getFloat(),s=[];let o=t;for(;o-- >0;){let t=i;const n=[];for(;t-- >0;)n.push(e.getFloat());s.push(n)}return{type:\"fixedStep\",start:n,span:r,data:s,nTracks:t,nPositions:i}}function Uh(e,t){const i=e.getInt(),n=e.getFloat(),r=e.getInt(),s=[];let o=r;for(;o-- >0;)s.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){o=r;const t=[];for(;o-- >0;)t.push(e.getFloat());a.push(t)}return{type:\"variableStep\",tileStart:i,span:n,start:s,data:a,nTracks:t,nPositions:r}}function qh(e,t,i){const n=e.getInt();let r=n;const s=[];for(;r-- >0;)s.push(e.getInt());r=n;const o=[];for(;r-- >0;)o.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){let t=n;const i=[];for(;t-- >0;)i.push(e.getFloat());a.push(i)}if(\"bedWithName\"===i){r=n;const t=[];for(;r-- >0;)t.push(e.getString())}return{type:i,start:s,end:o,data:a,nTracks:t,nPositions:n}}class Qh extends Hh{#h={};searchable=!1;constructor(e,t){super(t),this.genome=t,this.reader=new Ph(e,t),this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r=\"mean\"}){return\"all\"===e.toLowerCase()?this.getWGValues(r,n):this._getFeatures(e,t,i,n,r)}async _getFeatures(e,t,i,n,r){const s=new hc(e,t,i),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const e=this.rootGroup.totalCount;e&&(this.normalizationFactor=1e6/e)}s.bpPerPixel=n;const a=function(e,t,i){var n=i.getChromosome(e).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*t)))/Gh)}(e,n,o);let c=this.reader.chrAliasTable[e],l=this.reader.maxZoom;void 0===c&&(c=e),void 0===l&&(l=-1);const h=a>l?\"raw\":r,d=await this.reader.readDataset(c,h,a);if(null==d)return[];const u=d.tileWidth,f=Math.floor(t/u),p=Math.floor(i/u),g=await this.reader.readTiles(d.tiles.slice(f,p+1),1),m=[];for(let r of g)switch(r.type){case\"bed\":Vh(r,e,t,i,n,m);break;case\"variableStep\":jh(r,e,t,i,n,m);break;case\"fixedStep\":Wh(r,e,t,i,n,m);break;default:throw\"Unknown tile type: \"+r.type}return m.sort((function(e,t){return e.start-t.start})),m}get supportsWholeGenome(){return!0}get windowFunctions(){return this.reader.windowFunctions}async getWGValues(e,t){const i=this.#h[e];if(i&&i.bpPerPixel>.8*t&&i.bpPerPixel<1.2*t)return i.values;{const i=[],n=this.genome;if(this.genome.wgChromosomeNames)for(let r of n.wgChromosomeNames){const s=n.getChromosome(r).bpLength;t=s/1e3;const o=await this._getFeatures(r,0,s,t,e);if(o)for(let e of o){const t=Object.assign({},e);t.chr=\"all\",t.start=n.getGenomeCoordinate(e.chr,e.start),t.end=n.getGenomeCoordinate(e.chr,e.end),t._f=e,i.push(t)}}return this.#h[e]={values:i,bpPerPixel:t},i}}}function Vh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.end,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function jh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.span,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function Wh(e,t,i,n,r,s){const o=e.nPositions;let a=e.start;const c=e.span,l=e.data[0];for(let e=0;en)break;r>=i&&(Number.isNaN(l[e])||s.push({chr:t,start:a,end:r,value:l[e]})),a=r}}var Gh=Math.log(2);class $h{constructor(e,t,i,n){this.header=e,this.nameToId=t,this.idToName=i,this.sumLengths=n}static parseTree(e,t,i=!1){{const n=e.getInt(),r=e.getInt(),s=e.getInt(),o=e.getInt(),a=e.getLong(),c=e.getLong(),l={magic:n,blockSize:r,keySize:s,valSize:o,itemCount:a,reserved:c},h=new Map,d=[];let u=0;const f=n=>{n>=0&&(e.position=n);const r=e.getByte();e.getByte();const a=e.getUShort();if(1===r)for(let t=0;t{const a=await this.readNode(o);for(let o of a.items)Yh(o,e,t,i,n)&&(1===a.type?r.push(o):await s(o.childOffset))};return await s(this.header.rootNodeOffset),r}async readNode(e){const t=e;if(this.nodeCache.has(t))return this.nodeCache.get(t);let i=await this.#t(e,4);const n=i.getByte(),r=1===n;i.getByte();const s=i.getUShort();let o=s*(r?32:24);i=await this.#t(e+4,o);const a=[];for(let e=0;ee.startChrom||n===e.startChrom&&r>=e.startBase)&&(t!!e)),s=[];for(let e of r){const t=e.split(\" \")[0];if(t.startsWith(i)&&s.push(e),t.slice(0,i.length)>i)break}if(0!==s.length){const e=new Map;for(let t of s){const[i,...n]=t.split(\" \");e.set(i,n.map((e=>e.split(\",\")[0])))}return e}}async getIndex(e){return this.index||(this.index=await this._readIndex()),this.index}async _readIndex(e){return(await Qs.loadString(this.ixxFile)).split(\"\\n\").filter((e=>!!e)).map((e=>{const t=e.length-10,i=e.slice(0,t),n=e.slice(t);return[i,Number.parseInt(n,16)]}))}async _getBuffer(e,t){let i=0,n=65536;const r=await this.getIndex(t);for(let t=0;t0?ls(r):r,a.call(this,new DataView(d.buffer),c,t,l,n,h,this.chromTree.idToName,s,this.littleEndian)}return h.sort((function(e,t){return e.start-t.start})),h}return[]}async#d(e){if(this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.chromTree.nameToId.get(e);if(void 0===t&&this.genome){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>this.chromTree.nameToId.has(e)));e.length>0&&(n=e[0],t=this.chromTree.nameToId.get(e[0]))}this.chrAliasTable.set(e,n)}return t}get searchable(){return\"bigbed\"===this.type}async search(e){if(this.header||await this.loadHeader(),!this.header||!this.header.extraIndexCount)return;const t=await this._searchForRegions(e);if(t){const i=await this._loadFeaturesForRange(t.offset,t.length);if(i){const t=i.filter((t=>{for(let i of Object.keys(t)){const n=t[i];if(Mt(n)&&n.toLowerCase()===e.toLowerCase())return!0}return!1}));return t.length>0?t.reduce(((e,t)=>e.end-e.start>t.end-t.start?e:t),i[0]):void 0}}}async _searchForRegions(e){const t=await this.#u();if(t){if(this._trix){const t=e.toLowerCase(),i=await this._trix.search(t);i&&i.has(t)&&(e=i.get(t)[0])}for(let i of t){const t=await i.search(e);if(t)return t}}}async#u(){if(void 0===this._searchTrees&&this.header.extraIndexOffsets&&this.header.extraIndexOffsets.length>0){this._searchTrees=[];for(let e of this.header.extraIndexOffsets){const t=await Cc.loadBpTree(this.path,this.config,e);this._searchTrees.push(t)}}return this._searchTrees}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let e,t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;const i=new yc(new DataView(t),this.littleEndian);let n=i.getUInt();if(2291137574===n)this.type=\"bigwig\";else if(2273964779===n)this.type=\"bigbed\";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let e=i.getUInt();654085990===e?this.type=\"bigwig\":3958540679===e&&(this.type=\"bigbed\")}e={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:e.totalSummaryOffset>0?e.totalSummaryOffset-r+40:Math.min(e.fullDataOffset,e.chromTreeOffset)-r};t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:s}));const o=new yc(new DataView(t),this.littleEndian),a=e.nZoomLevels;this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let e=1;e<=a;e++){const t=a-e,i=new Jh(t,o);this.firstZoomDataOffset=Math.min(i.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[t]=i}if(e.autoSqlOffset>0){o.position=e.autoSqlOffset-r;const t=o.getString();t&&(this.autoSql=function(e){let t;const i=[];let n=!1;const r=e.trim().split(/\\s*[\\r\\n]+\\s*/g);for(let e of r)if(e=e.trim(),e.length>0){if(e.startsWith(\"#\"))continue;if(e.startsWith(\"table\"))t=e.split(/\\s+/)[1].trim();else if(e.startsWith(\"(\"))n=!0;else if(e.startsWith(\")\"));else if(n){const t=e.indexOf(\";\");if(t>0){const n=e.substr(0,t).split(/\\s+/),r=e.substr(t+1).replace(/\"/g,\"\").trim();i.push({type:n[0],name:n[1],description:r})}}}return{table:t,fields:i}}(t))}e.totalSummaryOffset>0&&(o.position=e.totalSummaryOffset-r,this.totalSummary=new ed(o));const c=Math.min(2e5,Math.max(1e4,e.fullDataOffset-e.chromTreeOffset));if(this.chromTree=await this.#f(e.chromTreeOffset,c),this.chrNames=new Set(this.chromTree.idToName),\"bigbed\"===this.type){const t=await this.#p(e.fullDataOffset);this.featureDensity=t/this.chromTree.sumLengths}return this.header=e,e.extensionOffset>0&&await this.loadExtendedHeader(e.extensionOffset),this.header}}async#p(e){const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:4}}));return new yc(new DataView(t),this.littleEndian).getInt()}async#f(e,t){let i=t;const n=async()=>{const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:i}})),n=new yc(new DataView(t),this.littleEndian);return $h.parseTree(n,e,this.genome)};let r;for(;i<1e6;)try{return await n()}catch(e){r=e,i*=2}throw r}async loadExtendedHeader(e){let t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:64}})),i=new yc(new DataView(t),this.littleEndian);i.getUShort();const n=i.getUShort(),r=i.getLong();if(0===n)return;let s=56*n;t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:r,size:s}})),i=new yc(new DataView(t),this.littleEndian);const o=[],a=[],c=[];for(let e=0;e0?ls(n):n,s=[];return nd.call(this).call(this,new DataView(r.buffer),0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,s,this.chromTree.idToName),s}}class Jh{constructor(e,t){this.index=e,this.reductionLevel=t.getInt(),this.reserved=t.getInt(),this.dataOffset=t.getLong(),this.indexOffset=t.getLong()}}class ed{constructor(e){e?(this.basesCovered=e.getLong(),this.minVal=e.getDouble(),this.maxVal=e.getDouble(),this.sumData=e.getDouble(),this.sumSquares=e.getDouble(),td.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function td(){let e=this.basesCovered;if(e>0){this.mean=this.sumData/e,this.stddev=Math.sqrt(this.sumSquares/(e-1));let t=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:t,max:i}}}function id(e,t,i,n,r,s,o,a,c){const l=new yc(e,c),h=l.getInt(),d=l.getInt();let u=d,f=l.getInt();const p=l.getInt(),g=l.getInt(),m=l.getByte();l.getByte();let w=l.getUShort();if(h>=t&&h<=n){let e=0;for(;w-- >0;){let a;switch(m){case 1:u=l.getInt(),f=l.getInt(),a=l.getFloat();break;case 2:u=l.getInt(),a=l.getFloat(),f=u+g;break;case 3:a=l.getFloat(),u=d+e*p,f=u+g,e++}if(!(hn||h===n&&u>=r)break;if(Number.isFinite(a)){const e=o[h];s.push({chr:e,start:u,end:f,value:a})}}}}}function nd(){const e=function(e,t,i,n){if(\"biginteract\"===n||i&&(\"chromatinInteract\"===i.table||\"interact\"===i.table))return function(e,t){return e.chr1=t[5],e.start1=Number.parseInt(t[6]),e.end1=Number.parseInt(t[7]),e.chr2=t[10],e.start2=Number.parseInt(t[11]),e.end2=Number.parseInt(t[12]),e.name=t[0],e.score=Number(t[1]),e.value=Number(t[2]),e.color=\".\"===t[4]?void 0:\"0\"===t[4]?\"rgb(0,0,0)\":t[4],e};{const n=e-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&\".\"!==s[5]&&\"0\"!==s[5]&&\"-1\"!==s[5]){const e=_s.createColorString(s[5]);r.color=e.startsWith(\"rgb\")?e:void 0}if(n>8){const e=parseInt(s[6]),t=s[7].split(\",\"),i=s[8].split(\",\"),n=[];for(let s=0;si?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=e;n=13;){const t=h.getInt(),c=a[t],l=h.getInt(),d=h.getInt(),u=h.getString();if(!(tr||t===r&&l>=s)break;if(d>0){const t={chr:c,start:l,end:d};o.push(t);const i=u.split(\"\\t\");e(t,i)}}}}}function rd(e,t,i,n,r,s,o,a,c){const l=new yc(e,c);for(;l.remLength()>=32;){const e=l.getInt(),c=l.getInt(),h=l.getInt(),d=l.getInt(),u=l.getFloat(),f=l.getFloat(),p=l.getFloat();let g;switch(l.getFloat(),a){case\"min\":g=u;break;case\"max\":g=f;break;default:g=0===d?0:p/d}if(!(en||e===n&&c>=r)break;if(Number.isFinite(g)){const t=o[e];s.push({chr:t,start:c,end:h,value:g})}}}}class sd{constructor(e){this.data=e}loadArrayBuffer(e,t){const i=t.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(e,t){const i=Math.min(this.data.byteLength-e.start,e.size);return t?new Uint8Array(this.data,e.start,i):new DataView(this.data,e.start,i)}}class od extends Hh{queryable=!0;#h={};windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];constructor(e,t){super(t),this.reader=new Zh(e,t),this.genome=t,this.format=e.format||\"bigwig\"}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r}){await this.reader.loadHeader();const s=\"bigwig\"===this.reader.type;let o;return o=\"all\"===e.toLowerCase()?s?await this.getWGValues(r,n):[]:await this.reader.readFeatures(e,t,e,i,n,r),s||Tl(o),o}async getHeader(){return this.reader.loadHeader()}async defaultVisibilityWindow(){return\"bigwig\"===this.reader.type?-1:this.reader.featureDensity?Math.floor(1e4/this.reader.featureDensity):-1}async getWGValues(e,t){const i=this.genome,n=this.#h[e];if(n&&n.bpPerPixel>.8*t&&n.bpPerPixel<1.2*t)return n.values;{const n=await this.reader.readWGFeatures(t,e);let r=[];for(let e of n){const t=e.chr,n=i.getCumulativeOffset(t);if(void 0===n)continue;const s=Object.assign({},e);s.chr=\"all\",s.start=n+e.start,s.end=n+e.end,s._f=e,r.push(s)}return r.sort(((e,t)=>e.start-t.start)),this.#h[e]={values:r,bpPerPixel:t},r}}supportsWholeGenome(){return\"bigwig\"===this.reader.type}async trackType(){return this.reader.getTrackType()}get searchable(){return this.reader.searchable}async search(e){return this.reader.search(e)}}const ad=.01;function cd(e,t,i,n){if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"}),n&&xo.fillRect(e,t-4-2,0,4,i,{fillStyle:n});const r=void 0!==this.flipAxis&&this.flipAxis,s=.95*t-8-5,o=.95*t-5,a={font:\"normal 10px Arial\",textAlign:\"right\",fillStyle:\"black\",strokeStyle:\"black\"};xo.strokeLine(e,s,ad*i,o,ad*i,a),xo.fillText(e,l(r?this.dataRange.min:this.dataRange.max),s+4,ad*i+12,a);const c=.99*i;function l(e){return 0===e?\"0\":Math.abs(e)>=10?e.toFixed():Math.abs(e)>=1?e.toFixed(1):Math.abs(e)>=.1?e.toFixed(2):e.toExponential(1)}xo.strokeLine(e,s,c,o,c,a),xo.fillText(e,l(r?this.dataRange.max:this.dataRange.min),s+4,c-4,a),xo.strokeLine(e,o,ad*i,o,c,a)}class ld extends Hl{static defaults={height:50,flipAxis:!1,logScale:!1,windowFunction:\"mean\",graphType:\"bar\",normalize:void 0,scaleFactor:void 0,overflowColor:\"rgb(255, 32, 255)\",baselineColor:\"lightGray\",summarize:!0,visibilityWindow:void 0};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"wig\",this.featureType=\"numeric\",this.resolutionAware=!0,this.paintAxis=cd;const t=e.format?e.format.toLowerCase():e.format;e.featureSource?(this.featureSource=e.featureSource,delete e.featureSource):this.featureSource=\"bigwig\"===t?new od(e,this.browser.genome):\"tdf\"===t?new Qh(e,this.browser.genome):Ad(e,this.browser.genome),void 0===e.max||!0===e.autoscale?this.autoscale=!0:this.dataRange={min:e.min||0,max:e.max}}async postInit(){const e=await this.getHeader();this.disposed||e&&this.setTrackProperties(e)}supportsWholeGenome(){return void 0===this.visibilityWindow||this.visibilityWindow<0}async getFeatures(e,t,i,n){const r=this.windowFunction,s=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:r});if(this.normalize&&this.featureSource.normalizationFactor){const e=this.featureSource.normalizationFactor;for(let t of s)t.value*=e}if(this.scaleFactor){const e=this.scaleFactor;for(let t of s)t.value*=e}return!this.summarize||\"mean\"!==r&&\"min\"!==r&&\"max\"!==r?s:hd(s,t,n,r)}menuItemList(){const e=[];if(void 0!==this.flipAxis){function t(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}e.push(\"
\"),e.push({label:\"Flip y-axis\",click:t})}return this.featureSource.windowFunctions&&e.push(...this.wigSummarizationItems()),e.push(...this.numericDataMenuItems()),e}wigSummarizationItems(){const e=this.featureSource.windowFunctions,t=[];t.push(\"
\"),t.push(\"
Windowing function
\");for(const i of e){const n=Bt(Dl(i,this.windowFunction===i));function r(){this.windowFunction=i,this.trackView.updateViews()}t.push({object:n,click:r})}return t}async getHeader(){return\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(e,t,i,n){const r=!0===n?e<0?-Math.log10(Math.abs(e)+1):Math.log10(Math.abs(e)+1):e;return i/((!0===n?Math.log10(Math.abs(t)+1):t)-r)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return n=n<0?-Math.log10(Math.abs(n)+1):Math.log10(Math.abs(n)+1),i=i<0?-Math.log10(Math.abs(i)+1):Math.log10(Math.abs(i)+1),e=e<0?-Math.log10(Math.abs(e)+1):Math.log10(e+1),(this.flipAxis?e-n:i-e)*t}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight-1,a=r+s*n+1,c=this.getScaleFactor(this.dataRange.min,this.dataRange.max,o,this.logScale),l=e=>this.logScale?this.computeYPixelValueInLogScale(e,c):this.computeYPixelValue(e,c);if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,c=-1;const h=l(0);for(let d of t){if(d.enda)break;const t=(d.start-r)/n;if(isNaN(t))continue;let u=l(d.value);const f=(d.end-r)/n-t,p=e.alpha?_s.addAlpha(this.getColorForFeature(d),e.alpha):this.getColorForFeature(d);if(\"line\"===this.graphType)void 0!==s&&xo.strokeLine(i,c,s,t,u,{fillStyle:p,strokeStyle:p}),xo.strokeLine(i,t,u,t+f,u,{fillStyle:p,strokeStyle:p});else if(\"points\"===this.graphType){const e=this.config.pointSize||3,n=t+f/2;xo.fillCircle(i,n,u,e/2,{fillStyle:p,strokeStyle:p}),d.value>this.dataRange.max?xo.fillCircle(i,n,e/2,e/2,3,{fillStyle:this.overflowColor}):d.valuethis.dataRange.max?xo.fillRect(i,t,0,f,3,{fillStyle:this.overflowColor}):d.value0){const i=e.genomicLocation,n=[];t.sort((function(e,t){return Math.abs((e.start+e.end)/2-i)-Math.abs((t.start+t.end)/2-i)}));const r=t.length>10?t.slice(0,10):t;r.sort((function(e,t){return e.start-t.start}));for(let e of r)if(e){n.length>0&&n.push(\"
\");let t=e.end-e.start==1?Rt(Math.floor(e.start)+1):Rt(Math.floor(e.start)+1)+\"-\"+Rt(Math.floor(e.end));n.push({name:\"Position:\",value:t}),n.push({name:\"Value:     \",value:Rt(e.value.toFixed(4))})}return r.length...\"),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(e){let t=e.value<0&&this.altColor?this.altColor:this.color||\"rgb(150, 150, 150)\";return\"function\"==typeof t?t(e.value):t}dispose(){this.trackView=void 0}}function hd(e,t,i,n=\"mean\"){if(i<=1||!e||0===e.length)return e;const r=e[0].chr,s=i,o=[],a=e=>{const i=t+e.bin*s,a=i+s;let c;switch(n){case\"mean\":c=e.sumData/e.count;break;case\"max\":c=e.max;break;case\"min\":c=e.min;break;default:throw Error(`Unknown window function: ${n}`)}const l=`${n} of ${e.count} values`;o.push({chr:r,start:i,end:a,value:c,description:l})};let c;for(let i of e){let e=Math.floor((i.start-t)/s);const n=Math.floor((i.end-t)/s);if(c&&e===c.bin&&(c.add(i),e++),!c||n>c.bin){if(c&&a(c),n>e){const e=t+n*s;o.push({chr:r,start:i.start,end:e,value:i.value})}c=new dd(n,i)}}c&&a(c);const l=[];let h=o[0];for(let e of o)h.value===e.value&&e.start<=h.end?h.end=e.end:(l.push(h),h=e);return l.push(h),l}class dd{constructor(e,t){this.bin=e,this.sumData=t.value,this.count=1,this.min=t.value,this.max=t.value}add(e){this.sumData+=e.value,this.max=Math.max(e.value,this.max),this.min=Math.min(e.value,this.min),this.count++}get mean(){return this.sumData/this.count}}class ud extends Hh{constructor(e,t){super(t),this.config=e||{},this.genome=t,this.sourceType=void 0===e.sourceType?\"file\":e.sourceType,this.maxWGCount=e.maxWGCount||1e4,this.windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];const i=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"tdf\"]);if(this.queryable=e.indexURL||!0===e.queryable,e.reader)this.reader=e.reader,this.queryable=!1!==e.queryable;else{if(\"ga4gh\"===e.sourceType)throw Error(\"Unsupported source type 'ga4gh'\");\"eqtl\"!==e.type&&\"qtl\"!==e.type||\"gtex-ws\"!==e.sourceType?\"htsget\"===e.sourceType?(this.reader=new Lh(e,t),this.queryable=!0):\"ucscservice\"===e.sourceType?(this.reader=new Nh(e.source),this.queryable=!0):\"custom\"===e.sourceType?(this.reader=new Eh(e.source),this.queryable=!1!==e.source.queryable):\"service\"===e.sourceType?(this.reader=new Ih(e,t),this.queryable=!0):(this.reader=new Ih(e,t),void 0!==e.queryable?this.queryable=e.queryable:(i.has(e.format)||this.reader.indexed)&&(this.queryable=!0)):(this.reader=new Bh(e),this.queryable=!0)}this.searchable=!1!==e.searchable}async defaultVisibilityWindow(){if(this.reader&&\"function\"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const e=await this.getHeader();return e?e.type:void 0}async getHeader(){if(!this.header)if(this.reader&&\"function\"==typeof this.reader.readHeader){const e=await this.reader.readHeader();e?(this.header=e,e.format&&(this.config.format=e.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r,windowFunction:s}){const o=\"all\"===e.toLowerCase();if(t=t||0,i=i||Number.MAX_SAFE_INTEGER,(o&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new hc(e,t,i)))&&await this.loadFeatures(e,t,i,r),o){if(!this.wgFeatures)if(this.supportsWholeGenome())if(\"wig\"===this.config.type){const e=await Ll(this.featureCache.getAllFeatures(),this.genome,1e6);this.wgFeatures=hd(e,0,n,s)}else this.wgFeatures=await Ll(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount);else this.wgFeatures=[];return this.wgFeatures}return this.featureCache.queryFeatures(e,t,i)}async findFeatures(e){return this.featureCache?this.featureCache.findFeatures(e):[]}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]:this.featureCache.getAllFeatures()}async loadFeatures(e,t,i,n){await this.getHeader();const r=this.reader;let s=t,o=i,a=e;if(!this.chrAliasManager&&this.reader&&this.reader.sequenceNames&&(this.chrAliasManager=new zh(this.reader.sequenceNames,this.genome)),this.chrAliasManager&&(a=await this.chrAliasManager.getAliasName(e)),(!n||n<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(a):void 0;s=0,o=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,i)}else if(n>i-t&&!1!==this.config.expandQuery){let e=Math.min(4.1*(i-t),n);this.config.minQuerySize&&et.end-t.start)continue;this.featureMap.set(i.toUpperCase(),t)}}}search(e){if(this.featureMap)return this.featureMap.get(e.toUpperCase())}}class pd{constructor({chr:e,locus:t,accession:i,aliases:n,features:r,sequence:s}){this.chr=e,this.locus=t,this.accession=i,this.aliases=n,this.features=r,this.sequence=s,this.bpLength=s.length}toJSON(){return{gbkURL:this.url}}getSequenceRecord(e){return{chr:this.chr,bpLength:this.bpLength}}get chromosomeNames(){return[this.chr]}getFirstChromosomeName(){return this.chr}get id(){return this.accession}get name(){return this.locus}get initialLocus(){return this.chr}get description(){return this.locus}get infoURL(){return this.url}showWholeGenomeView(){return!1}getHomeChromosomeName(){return this.chr}getChromosomeName(e){return e}getChromosomeDisplayName(e){return this.chr}getChromosome(e){if(e===this.chr)return{name:this.chr,bpLength:this.bpLength}}async loadChromosome(e){return this.getChromosome(e)}async getAliasRecord(e){}getCytobands(e){return[]}getChromosomes(){return[this.getChromosome(this.chr)]}get wgChromosomeNames(){}getGenomeCoordinate(e,t){if(e===this.chr)return t}getChromosomeCoordinate(e){return{chr:this.chr,position:e}}getCumulativeOffset(e){return 0}getGenomeLength(){return this.bpLength}async getSequence(e,t,i){return e===this.chr?this.sequence.substring(t,i):void 0}getSequenceInterval(e,t,i){return e===this.chr?new dc(this.chr,0,this.sequence.length,this.sequence):void 0}}const gd=/\\s+/,md=new Map;async function wd(e){let t=md.get(e);if(!t){t=function(e){if(!e)return null;const t=mh(e);let i=t.nextLine();const n=i.split(/\\s+/);if(\"LOCUS\"!==n[0].toUpperCase())throw Error(\"Expected `LOCUS` line. Found: \"+i);const r=n[1].trim();let s,o;do{if(i=t.nextLine(),i.startsWith(\"ACCESSION\")){const e=i.split(gd);if(e.length<2)throw Error(\"Genbank file missing ACCESSION number.\");s=e[1].trim()}else if(i.startsWith(\"ALIASES\")){const e=i.split(gd);e.length>1&&(o=e[1].split(\",\"))}}while(i&&!i.startsWith(\"FEATURES\"));const a=s||r,c=function(e,t){const i=[];let n,r,s,o=0;for(;;)if(r=t.nextLine(),\"\"!==r){if(!r||r.startsWith(\"ORIGIN\"))break;if(r.length<6)o<10&&console(\"Unexpected line in genbank file (skipping): \"+r),o++;else if(\" \"!==r.charAt(5)){let t=r.substring(5,21).trim();s={chr:e,type:t,attributes:{},getAttributeValue:function(e){return this.attributes[e]}},n=r.substring(21),\"source\"!==t.toLowerCase()&&i.push(s)}else{let t=r.substring(21).trim();if(t.length>0)if(47===t.charCodeAt(0)){if(47===n.charCodeAt(0)){let e=n.split(\"=\",2);if(e.length>1){let t=e[0].length>1?e[0].substring(1):\"\",i=Fd(e[1]);s.attributes[t]=i}}else{const t=n.includes(\"complement\")?\"-\":\"+\";s.strand=t;let i=n.replace(\"join\",\"\").replace(\"order\",\"\").replace(\"complement\",\"\").replace(\"(\",\"\").replace(\")\",\"\");if(i.includes(\"..\")){i=i.replace(\"<\",\"\").replace(\">\",\"\");const n=bd(i,e,t),r=n[0];s.start=r.start;const o=n[n.length-1];s.end=o.end,n.length>1&&(s.exons=n)}else s.start=parseInt(i)-1,s.end=s.start+1}n=t}else n+=t}}return i}(a,t),l=function(e){let t,i=\"\";for(;(t=e.nextLine())&&!t.startsWith(\"//\");){t=t.trim();const e=t.split(/\\s+/);for(let t=1;t1&&(o=parseInt(n[1])),r.push({chr:t,start:s,end:o,strand:i})}return r.sort((function(e,t){return e.start-t.start})),r}function Fd(e){return e.startsWith('\"')&&e.endsWith('\"')&&(e=e.substring(1,e.length-2)),e}class vd extends Hh{constructor(e,t){super(t),this.config=e,this.searchable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){if(!this.featureSource){const e=await wd(this.config.url);this.featureSource=new fd({genome:this.config.genome,features:e.features,searchableFields:[\"gene\",\"db_xref\",\"locus_tag\",\"transcript_id\"]})}return this.featureSource.getFeatures({chr:e,start:t,end:i})}supportsWholeGenome(){return!1}search(e){return this.featureSource.search(e)}}const yd=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\"]);function Ad(e,t){const i=e.format?e.format.toLowerCase():void 0;return e.features?new fd(e,t):yd.has(i)?new od(e,t):\"tdf\"===i?new Qh(e,t):\"gbk\"===i?new vd(e,t):new ud(e,t)}function Cd(e){return(3-e.readingFrame)%3}function _d(e){return e.cdStart||e.start}function xd(e){return e.cdEnd||e.end}const kd=.25;function Id(e,t,i){let n=(e.start-t)/i,r=(e.end-t)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Sd(e,t,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(e);let o,a;r.fillStyle=n,r.strokeStyle=n,\"SQUISHED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*e.row):\"EXPANDED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*e.row):(o=this.featureHeight,a=this.margin);const c=s.pixelWidth,l=a+o/2,h=o/2,d=l-h/2,u=e.exons?e.exons.length:0,f=Id(e,t,i),p=this.arrowSpacing,g=\"+\"===e.strand?1:\"-\"===e.strand?-1:0;if(0===u){const e=Math.max(0,f.px),t=Math.min(c,f.px1),i=t-e;if(r.fillRect(e,a,i,o),0!==g){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let i=e+p/2;ic)break;if(f.utr)r.fillRect(w,d,F,h);else{if(f.cdStart&&(m=Math.round((f.cdStart-t)/i),r.fillRect(w,d,m-w,h),F-=m-w,w=m),f.cdEnd&&(m=Math.round((f.cdEnd-t)/i),r.fillRect(m,d,b-m,h),F-=b-m,b=m),F=Math.max(F,1),r.fillRect(w,a,F,o),void 0!==f.readingFrame&&s.bpPerPixel0&&void 0!==e.exons[u-1].readingFrame?e.exons[u-1]:void 0,n=up+5&&0!==g&&s.bpPerPixel>kd){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let e=w+p/2;e{const f=Math.round((i-s)/o),p=Math.round((n-s)/o)-f;let g;if(void 0===r){if(l.hasSequence(i,n)){const e=l.getSequence(i,n);if(e&&3===e.length){const i=\"+\"===t?e:ac(e.split(\"\").reverse().join(\"\"));g=Gd[i]}}}else g=r;e.fillStyle=\"M\"===r||\"M\"===g&&0===u?\"#83f902\":\"STOP\"===g?\"#ff2101\":h[d],e.fillRect(f,a,p,c),g&&(e.save(),((t,i,n,r,s)=>{\"STOP\"===s&&(s=\"*\");const o=e.measureText(s).width;xo.fillText(e,s,n+(i-o)/2,r-4,{fillStyle:\"#ffffff\"})})(0,p,f,a+c,g),e.restore());const m=n-i;return m>0&&m<3?{start:i,end:n}:void 0},u=Cd(n);let f,p,g,m,w,b=_d(n),F=xd(n),v=1;if(\"+\"===t){for(u>0&&(b+=u),v=1,w=0,f=b;f0||g){const e=u>0?Bd.call(this,t,u,b-u,b,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;i&&d(t,b-u,b,i.aminoAcidLetter,0,void 0),n&&d(t,g.start,g.end,n.aminoAcidLetter,m,void 0)}}}else{for(u>0&&(F-=u),v=1,w=0,w=0,p=F;p>b;w++,p-=3)m=v%2,f=Math.max(b,p-3),g=d(t,f,p,void 0,v%2,w),++v;if(u>0||g){const e=u>0?Bd.call(this,t,u,F,F+u,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;n&&d(t,F,F+u,n.aminoAcidLetter,0,void 0),i&&d(t,g.start,g.end,i.aminoAcidLetter,m,void 0)}}}e.restore()}function Nd(e,t,i,n,r,s,o){try{e.save();let s=t.name;if(void 0===s&&t.gene&&(s=t.gene.name),void 0===s&&(s=t.id||t.ID),!s||\".\"===s)return;let a=o.pixelXOffset||0;const c=Math.max(i,-a);let l,h=(c+Math.min(n,-a+o.viewportWidth))/2;\"COLLAPSED\"===this.displayMode&&\"SLANT\"===this.labelDisplayMode&&(l={rotate:{angle:45}});const d=function(e,t){return t?e+20:e+25}(r,l);let u=this.getColorForFeature(t),f=this.browser.qtlSelections.hasPhenotype(t.name);const p={textAlign:\"SLANT\"===this.labelDisplayMode?void 0:\"center\",fillStyle:u,strokeStyle:u},g=e.measureText(s),m=h-g.width/2,w=h+g.width/2,b=o.rowLastLabelX[t.row]||-Number.MAX_SAFE_INTEGER;(o.labelAllFeatures||m>b||f)&&(o.rowLastLabelX[t.row]=w,\"y\"===o.axis?(e.save(),xo.labelTransformWithContext(e,h),xo.fillText(e,s,h,d,p,l),e.restore()):(e.clearRect(h-g.width/2-1,d-g.actualBoundingBoxAscent-1,g.width+2,g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+2),xo.fillText(e,s,h,d,p,l)))}finally{e.restore()}}function Bd(e,t,i,n,r,s,o,a,c){let l,h,d=\"\",u=\"\",f=\"\";const p={left:void 0,rite:void 0};if(\"+\"===e){if(t){if(u=c.getSequence(i,n),!u)return;if([l,h]=[xd(s)-(3-t),xd(s)],d=c.getSequence(l,h),!d)return;f=d+u,p.left={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(d=c.getSequence(r.start,r.end),!d)return;const e=Cd(a),t=_d(a);if(u=c.getSequence(t,t+e),!u)return;f=d+u,p.rite={triplet:f,aminoAcidLetter:Gd[f]}}}else{if(t){if(d=c.getSequence(i,n),void 0===d)return;if([l,h]=[_d(a),_d(a)+(3-t)],u=c.getSequence(l,h),void 0===u)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.rite={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(u=c.getSequence(r.start,r.end),void 0===u)return;const e=Cd(s),t=xd(s);if(d=c.getSequence(t-e,t),void 0===d)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.left={triplet:f,aminoAcidLetter:Gd[f]}}}return p}const Md=new Set([\"nonsense\",\"missense\",\"stop-loss\",\"frameshift\",\"cds-indel\"]),Rd=new Set([\"coding-synon\"]),Dd=new Set([\"splice-3\",\"splice-5\"]),Td=new Set([\"untranslated-5\",\"untranslated-3\"]);function Ld(e,t,i,n,r){var s,o,a,c,l,h,d=Id(e,t,i),u=this.margin,f=this.snpColors.length;switch(s=\"squished\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case\"function\":c=e.func,h=c.split(\",\"),l=h.map((function(e){return Md.has(e)||Dd.has(e)?f-1:Rd.has(e)?f-2:Td.has(e)?f-3:0})),o=l.reduce((function(e,t){return Math.max(e,t)}));break;case\"class\":o=\"deletion\"===(a=e.class)?f-1:\"mnp\"===a?f-2:\"microsatellite\"===a||\"named\"===a?f-3:0}r.fillStyle=this.snpColors[o],r.fillRect(d.px,u,d.pw,s)}function zd(e,t,i,n,r){const s=\"EXPANDED\"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;\"COLLAPSED\"!==this.displayMode&&void 0!==e.row&&(o+=e.row*s);const a=o+.5*s,c=a-.5*s,l=a+.5*s,h=Math.round((e.junction_left-t)/i),d=Math.round((e.junction_right-t)/i);r.beginPath(),r.moveTo(h,a),r.bezierCurveTo(h,c,d,c,d,a),r.lineWidth=1+Math.log(e.num_junction_reads)/Math.log(2),r.strokeStyle=\"blue\",r.stroke();const u=e.spanning_frag_coords;for(let e=0;et&&(t=i.row);return this.margin+(t+1)*(\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,bpEnd:s,pixelWidth:o,pixelHeight:a,referenceFrame:c}=e;if(nr&&i.end!isNaN(e)))));let h=[];const d=[];for(let o of t){if(o.ends)break;\"COLLAPSED\"===this.displayMode&&this.browser.qtlSelections.hasPhenotype(o.name)&&d.push(o);const t=\"COLLAPSED\"===this.displayMode?0:o.row;e.drawLabel=e.labelAllFeatures||l>10;const c=Math.ceil((o.end-r)/n),u=h[t];if(!u||c>u){this.render.call(this,o,r,n,a,i,e);const s=Math.floor((o.start-r)/n);u&&s-u<=0&&(i.globalAlpha=.5,xo.strokeLine(i,s,0,s,a,{strokeStyle:\"rgb(255, 255, 255)\"}),i.globalAlpha=1),h[t]=c}}for(let t of d)e.drawLabel=!0,this.render.call(this,t,r,n,a,i,e)}else console.log(\"No feature list\")}clickedFeatures(e){const t=e.y-this.margin,i=super.clickedFeatures(e);let n;switch(this.displayMode){case\"SQUISHED\":n=Math.floor(t/this.squishedRowHeight);break;case\"EXPANDED\":n=Math.floor(t/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(e){return void 0===n||void 0===e.row||n===e.row}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=e._f||e,r=\"function\"==typeof t.popupData?t.popupData(i):this.extractPopupData(t);if(r){n.length>0&&n.push(\"

\");const s=this.infoURL||this.config.infoURL;for(let t of r)if(n.push(t),s&&t.name&&\"name\"===t.name.toLowerCase()&&t.value&&Mt(t.value)&&!t.value.startsWith(\"<\")){const i=s.replace(\"$$\",e.name);t.value=`${t.value}`}const o=\"gff\"===this.config.format||\"gff3\"===this.config.format||\"gtf\"===this.config.format;if(t.exons&&t.exons.length>1)for(let e=0;e=r.start&&i<=r.end){const i=o?r.number:\"-\"===t.strand?t.exons.length-e:e+1;i&&(n.push(\"
\"),n.push({name:\"Exon Number\",value:i}));break}}}}return n}menuItemList(){const e=[];if(this.render===Ld){e.push(\"
\");for(const i of[\"function\",\"class\"]){const n=Bt(Dl(`Color by ${i}`,i===this.colorBy));function r(){this.colorBy=i,this.trackView.repaintViews()}e.push({object:n,click:r})}}e.push(\"
\");const t={COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"};for(const s of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){const o=Bt(Dl(t[s],s===this.displayMode));function a(){this.displayMode=s,this.config.displayMode=s,this.trackView.checkContentHeight(),this.trackView.repaintViews()}e.push({object:o,click:a})}return e}contextMenuItemList(e){const t=this.clickedFeatures(e);if(void 0===t||0===t.length)return;t.length>1&&t.sort(((e,t)=>t.end-t.start-(e.end-e.start)));const i=t[0];if(i.end-i.start<=1e6){const e=[{label:\"View feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&void 0!==navigator.clipboard&&e.push({label:\"Copy feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.push(\"
\"),e}}description(){if(Ld===this.render){let e=\"\"+this.name+\"
\";return e+=\"Color By Function:
\",e+='Red: Coding-Non-Synonymous, Splice Site
',e+='Green: Coding-Synonymous
',e+='Blue: Untranslated
',e+='Black: Intron, Locus, Unknown

',e+=\"Color By Class:
\",e+='Red: Deletion
',e+='Green: MNP
',e+='Blue: Microsatellite, Named
',e+='Black: Indel, Insertion, SNP',e+=\"\",e}return super.description()}getColorForFeature(e){const t=e._f||e;let i;if(e.name&&this.browser.qtlSelections.hasPhenotype(e.name))i=this.browser.qtlSelections.colorForGene(e.name);else if(this.altColor&&\"-\"===t.strand)i=\"function\"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)i=\"function\"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const e=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];i=this.colorTable.getColor(e)}else t.color&&(i=t.color);if(i||(i=\"rgb(0, 0, 150)\"),t.alpha&&1!==t.alpha)i=_s.addAlpha(i,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const e=function(e,t,i){const n=(t-e)/9,r=Math.floor((i-e)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,t.score);t.alpha=e,i=_s.addAlpha(i,e)}return i}dispose(){this.trackView=void 0}}class Pd{constructor(t){if(this.config=t,this.browser=t.browser,this.columnFormat=t.columnFormat,this.tableRowSelectionList=[],this.tableDOM=e({class:\"igv-roi-table\"}),t.width){let[e]=t.width.split(\"px\");e=parseInt(e,10),this.tableDOM.style.width=`${Math.min(e,1600)}px`}t.parent.appendChild(this.tableDOM),this.headerDOM=t,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=t.gotoButtonHandler}set headerDOM({browser:t,parent:i,headerTitle:n,dismissHandler:r}){const s=e();this.tableDOM.appendChild(s);const o=e();s.appendChild(o),o.innerHTML=n;const a=e();s.appendChild(a),a.appendChild(l(\"times\")),this.boundDismissHandler=function(e){e.stopPropagation(),r()}.bind(this),a.addEventListener(\"click\",this.boundDismissHandler);const{y:c}=t.root.getBoundingClientRect(),{y:h}=i.getBoundingClientRect(),d=-(h-c);p(this.tableDOM,s,{minX:0,minY:d}),this.tableDOM.style.display=\"none\",this._headerDOM=s}set tableColumnTitles(t){const i=e({class:\"igv-roi-table-column-titles\"});t.appendChild(i);for(const{label:t,width:n}of this.columnFormat){const r=e();i.appendChild(r),r.style.width=n,r.innerText=t}this._tableColumnTitlesDOM=i}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(t){const i=e({class:\"igv-roi-table-row-container\"});t.appendChild(i),this._tableRowContainerDOM=i}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(t){const i=e();this.tableDOM.appendChild(i);const n=e({class:\"igv-roi-table-button\"});i.appendChild(n),n.id=\"igv-roi-table-view-button\",n.textContent=\"Go To\",n.style.pointerEvents=\"none\",this._footerDOM=i,this.gotoButton=n,this.boundGotoButtonHandler=t.bind(this),this.gotoButton.addEventListener(\"click\",this.boundGotoButtonHandler)}tableRowDOMHelper(e){e.addEventListener(\"mousedown\",(t=>{t.stopPropagation(),e.classList.toggle(\"igv-roi-table-row-selected\"),e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\"),this.setTableRowSelectionState(e.classList.contains(\"igv-roi-table-row-selected\"))})),e.addEventListener(\"mouseover\",(t=>{e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\")})),e.addEventListener(\"mouseout\",(t=>{e.classList.remove(\"igv-roi-table-row-hover\")}))}clearTable(){const e=this.tableRowContainer.querySelectorAll(\".igv-roi-table-row\");for(let t of e)t.remove()}setTableRowSelectionState(e){e?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?\"auto\":\"none\"}present(){this.tableDOM.style.left=\"0px\";const{y:e}=this.browser.root.getBoundingClientRect(),{y:t}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=e-t+\"px\",this.tableDOM.style.display=\"flex\"}dismiss(){this.tableDOM.style.display=\"none\"}isVisible(){return\"none\"!==this.tableDOM.style.display}dispose(){this.tableDOM.innerHTML=\"\",this.tableDOM.remove();for(const e of Object.keys(this))this[e]=void 0;document.removeEventListener(\"click\",this.boundDismissHandler)}}class Od extends Pd{constructor(e){super(Object.assign({width:\"1024px\"},e)),this.descriptionDOM=e}set descriptionDOM(t){if(t.description){let i;i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.innerHTML=\"BLAT result for query sequence:\",i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.style.maxHeight=\"128px\",i.innerHTML=t.description,i=e({class:\"igv-roi-table-goto-explainer\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.innerHTML=\"Select one or more rows and click Go To to view the regions\"}}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),n=t.map((e=>isFinite(e)?Rt(e):e));for(let t=0;te.remove())),e.length>0)for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}static getColumnFormatConfiguration(){return[{label:\"chr\",width:\"7%\"},{label:\"start\",width:\"12%\"},{label:\"end\",width:\"12%\"},{label:\"strand\",width:\"5%\"},{label:\"score\",width:\"5%\"},{label:\"match\",width:\"5%\"},{label:\"mis-match\",width:\"7%\"},{label:\"rep. match\",width:\"7%\"},{label:\"N's\",width:\"3%\"},{label:\"Q gap count\",width:\"9%\"},{label:\"Q gap bases\",width:\"9%\"},{label:\"T gap count\",width:\"9%\"},{label:\"T gap bases\",width:\"9%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(const e of t){const t=[];e.querySelectorAll(\"div\").forEach((e=>t.push(e.innerText)));const[n,r,s]=t;i.push(`${n}:${r}-${s}`)}for(const e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),this.browser.search(i.join(\" \"))}}const Ud=\"https://igv.org/services/blatUCSC.php\";async function qd({url:e,userSeq:t,db:i}){if(e=e||Ud,!i)throw Error(\"Blat database is not defined\");const n=await async function(e=\"\",t,i){const n=new URLSearchParams;n.append(\"userSeq\",t),n.append(\"db\",i);const r=await fetch(e,{method:\"post\",body:n});return r.json()}(e,t,i);n.fields;return n.blat.map($c)}const Qd=25e3;class Vd extends Hd{constructor(e,t){super(e,t),this.name||(this.name=\"Blat Results\"),this.sequence=e.sequence,this.table=void 0,e.features&&(this._features=e.features,this.featureSource=new fd({features:e.features},this.browser.genome),delete e.features)}async postInit(){if(!this.featureSource){const e=this.browser.genome.id,t=this.browser.config.blatServerURL,i=await qd({url:t,userSeq:this.sequence,db:e});this._features=i,this.featureSource=new fd({features:i},this.browser.genome)}}openTableView(){if(void 0===this.table){const e=this._features.map((e=>[e.chr,e.start+1,e.end,e.strand,e.score,e.matches,e.misMatches,e.repMatches,e.nCount,e.qNumInsert,e.qBaseInsert,e.tNumInsert,e.tBaseInsert])),t={browser:this.browser,parent:this.browser.columnContainer,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:Od.getColumnFormatConfiguration(),gotoButtonHandler:Od.gotoButtonHandler};this.table=new Od(t),this.table.renderTable(e)}this.table.present()}menuItemList(){const e=super.menuItemList();return e.push(\"
\"),e.push({label:\"Open table view\",click:function(){this.openTableView()}}),e}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function jd({sequence:e,browser:t,name:i,title:n}){if(e.length>Qd)t.alert.present(`Sequence size exceeds maximum allowed length (${e.length} > 25000)`);else try{const r=t.genome.id,s=t.config.blatServerURL||\"https://igv.org/services/blatUCSC.php\",o={type:\"blat\",name:i||\"blat results\",title:n||\"blat results\",sequence:e,altColor:\"rgb(176, 176, 236)\",color:\"rgb(236, 176, 176)\",searchable:!1,features:await qd({url:s,userSeq:e,db:r})};(await t.loadTrack(o)).openTableView()}catch(e){t.alert.present(`Error performing blat search: ${e}`)}}const Wd=Number.MIN_SAFE_INTEGER,Gd={TTT:\"F\",TTC:\"F\",TTA:\"L\",TTG:\"L\",CTT:\"L\",CTC:\"L\",CTA:\"L\",CTG:\"L\",ATT:\"I\",ATC:\"I\",ATA:\"I\",ATG:\"M\",GTT:\"V\",GTC:\"V\",GTA:\"V\",GTG:\"V\",TCT:\"S\",TCC:\"S\",TCA:\"S\",TCG:\"S\",CCT:\"P\",CCC:\"P\",CCA:\"P\",CCG:\"P\",ACT:\"T\",ACC:\"T\",ACA:\"T\",ACG:\"T\",GCT:\"A\",GCC:\"A\",GCA:\"A\",GCG:\"A\",TAT:\"Y\",TAC:\"Y\",TAA:\"STOP\",TAG:\"STOP\",CAT:\"H\",CAC:\"H\",CAA:\"Q\",CAG:\"Q\",AAT:\"N\",AAC:\"N\",AAA:\"K\",AAG:\"K\",GAT:\"D\",GAC:\"D\",GAA:\"E\",GAG:\"E\",TGT:\"C\",TGC:\"C\",TGA:\"STOP\",TGG:\"W\",CGT:\"R\",CGC:\"R\",CGA:\"R\",CGG:\"R\",AGT:\"S\",AGC:\"S\",AGA:\"R\",AGG:\"R\",GGT:\"G\",GGC:\"G\",GGA:\"G\",GGG:\"G\"},$d={},Kd=[\"A\",\"G\",\"C\",\"T\",\"Y\",\"R\",\"W\",\"S\",\"K\",\"M\",\"D\",\"V\",\"H\",\"B\",\"N\",\"X\"],Yd=[\"T\",\"C\",\"G\",\"A\",\"R\",\"Y\",\"W\",\"S\",\"M\",\"K\",\"H\",\"B\",\"D\",\"V\",\"N\",\"X\"];for(let NA=0;NA{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?\"Close Translation\":\"Three-frame Translate\",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let e of this.trackView.viewports)e.setContentHeight(Xd);this.trackView.setTrackHeight(Xd)}else{for(let e of this.trackView.viewports)e.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(e){const t=e.viewport;if(t.referenceFrame.bpPerPixel<=1){const e=t.getWidth()*t.referenceFrame.bpPerPixel,i=t.referenceFrame.chr,n=Math.floor(t.referenceFrame.start),r=Math.ceil(n+e),s=[{label:this.reversed?\"View visible sequence (reversed)...\":\"View visible sequence...\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&s.push({label:\"Copy visible sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),s.push({label:\"BLAT read sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);if(e){this.reversed&&(e=cc(e));const t=`blat: ${i}:${n+1}-${r}`,s=`blat: ${i}:${n+1}-${r}`;jd({sequence:e,browser:this.browser,name:t,title:s})}}}),s.push(\"
\"),s}}translateSequence(e){const t=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;e.length-n>=3;){let r=e.slice(n,n+3);this.reversed&&(r=r.split(\"\").reverse().join(\"\"));const s=Gd[r.toUpperCase()]||\"\";t[i].push({codons:r,aminoA:s}),n+=3}}return t}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new Jd(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome}async getFeatures(e,t,i,n){if(t=Math.floor(t),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:t,sequence:await n.getSequence(e,t,i)}}}draw(e){const t=e.context;if(e.features){let i=e.features.sequence;if(!i)return;this.reversed&&(i=i.split(\"\").map((function(e){return $d[e]})).join(\"\"));const n=e.features.bpStart,r=1+e.bpStart+e.pixelWidth*e.bpPerPixel;for(let s=Math.floor(e.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r.1)xo.fillRect(t,n,5,o,10,{fillStyle:c});else{const i=n+.5*(o-t.measureText(a).width);\"y\"===e.axis?(t.save(),xo.labelTransformWithContext(t,i),xo.strokeText(t,a,i,15,{strokeStyle:c}),t.restore()):xo.strokeText(t,a,i,15,{strokeStyle:c})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;ie.pixelWidth)break;let f=c.aminoA;c.aminoA.indexOf(\"STOP\")>-1?(a=\"rgb(255, 0, 0)\",f=\"STOP\"):\"M\"===c.aminoA&&(a=\"rgb(0, 153, 0)\",f=\"START\"),xo.fillRect(t,h,r,d-h,25,{fillStyle:a}),e.bpPerPixel<=.1&&xo.strokeText(t,f,u-t.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(e){return this.height=this.frameTranslate?Xd:25,this.height}fillColor(e){return this.color?this.color:\"dna\"===this.sequenceType?this.browser.nucleotideColors[e]||\"gray\":\"rgb(0, 0, 150)\"}getState(){const e={type:\"sequence\"};return this.order!==Wd&&(e.order=this.order),this.reversed&&(e.revealed=!0),e}}class Jd{constructor(e,t){this.config=e,this.genome=t}async init(){this.fasta=await Nc(this.config),this.chrNameMap=new Map;for(let e of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(e),e)}async getSequence(e,t,i){const n=this.chrNameMap.has(e)?this.chrNameMap.get(e):e;return this.fasta.getSequence(n,t,i)}}class eu{constructor(e,t,i,n){this.guid=s(),this.trackView=e,this.referenceFrame=i,this.browser=e.browser,this.$viewport=Bt('
'),t.appendChild(this.$viewport.get(0)),e.track.height&&(this.$viewport.get(0).style.height=`${e.track.height}px`),e.track instanceof Zd&&(this.alert=new Ta(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(e){this.messageDiv||(this.messageDiv=document.createElement(\"div\"),this.messageDiv.className=\"igv-viewport-message\",this.$viewport.append(Bt(this.messageDiv))),this.messageDiv.textContent=e,this.messageDiv.style.display=\"inline-block\"}hideMessage(e){this.messageDiv&&(this.messageDiv.style.display=\"none\")}setTrackLabel(e){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(e){this.contentTop=e,this.$viewport.height()}async loadFeatures(){}clearCache(){}repaint(){}draw(e,t,i){console.log(\"Viewport - draw(drawConfiguration, features, roiFeatures)\")}checkContentHeight(e){let t=this.trackView.track;if(e=e||this.cachedFeatures,\"FILL\"===t.displayMode)this.setContentHeight(this.$viewport.height());else if(\"function\"==typeof t.computePixelHeight&&e&&e.length>0){let i=t.computePixelHeight(e);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(e){this.contentHeight=e}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(e){this.$viewport.width(e)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(e,t){console.log(\"Viewport - containsPosition(chr, position)\")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.$viewport.get(0).remove();for(let e of Object.keys(this))this[e]=void 0}}\n", - "/*!!\n", - " * Canvas 2 Svg v1.0.19\n", - " * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.\n", - " *\n", - " * Licensed under the MIT license:\n", - " * http://www.opensource.org/licenses/mit-license.php\n", - " *\n", - " * Author:\n", - " * Kerry Liu\n", - " *\n", - " * Copyright (c) 2014 Gliffy Inc.\n", - " */function tu(e,t){var i,n=Object.keys(t);for(i=0;i0){\"path\"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:t,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement(\"g\");t.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute(\"transform\");n?n+=\" \":n=\"\",n+=e,this.__currentElement.setAttribute(\"transform\",n)}addTrackGroupWithTranslationAndClipRect(e,t,i,n,r,s){const o=e+\"_clip_rect\";let a=this.__createElement(\"clipPath\",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement(\"rect\",{x:\"0\",y:s.toString(),width:n.toString(),height:r.toString()}));let c=this.__createElement(\"g\");this.__rootGroup.appendChild(c),c.setAttribute(\"transform\",tu(\"translate({x},{y})\",{x:t,y:i})),c.setAttribute(\"id\",e+\"_group\"),c.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:o})),this.__currentElement=c}scale(e,t){void 0===t&&(t=e),this.__addTransform(tu(\"scale({x},{y})\",{x:e,y:t}))}rotate(e){var t=180*e/Math.PI;this.__addTransform(tu(\"rotate({angle},{cx},{cy})\",{angle:t,cx:0,cy:0}))}translate(e,t){this.__addTransform(tu(\"translate({x},{y})\",{x:e,y:t}))}transform(e,t,i,n,r,s){this.__addTransform(tu(\"matrix({a},{b},{c},{d},{e},{f})\",{a:e,b:t,c:i,d:n,e:r,f:s}))}beginPath(){var e;this.__currentDefaultPath=\"\",this.__currentPosition={},e=this.__createElement(\"path\",{},!0),this.__closestGroupOrSvg().appendChild(e),this.__currentElement=e}__applyCurrentDefaultPath(){var e=this.__currentElement;\"path\"===e.nodeName?e.setAttribute(\"d\",this.__currentDefaultPath):console.error(\"Attempted to apply path command to node\",e.nodeName)}__addPathCommand(e){this.__currentDefaultPath+=\" \",this.__currentDefaultPath+=e}moveTo(e,t){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:e,y:t},this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand(\"Z\")}lineTo(e,t){this.__currentPosition={x:e,y:t},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf(\"M\")>-1?this.__addPathCommand(tu(\"L {x} {y}\",{x:e,y:t})):this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}bezierCurveTo(e,t,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(tu(\"C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}\",{cp1x:e,cp1y:t,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(e,t,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(tu(\"Q {cpx} {cpy} {x} {y}\",{cpx:e,cpy:t,x:i,y:n}))}arcTo(e,t,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error(\"IndexSizeError: The radius provided (\"+r+\") is negative.\");if(s===e&&o===t||e===i&&t===n||0===r)this.lineTo(e,t);else{var a=ru([s-e,o-t]),c=ru([i-e,n-t]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),d=ru([a[0]+c[0],a[1]+c[1]]),u=r/Math.sin(h/2),f=e+u*d[0],p=t+u*d[1],g=[-a[1],a[0]],m=[c[1],-c[0]],w=function(e){var t=e[0];return e[1]>=0?Math.acos(t):-Math.acos(t)},b=w(g),F=w(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,b,F)}else this.lineTo(e,t)}}}stroke(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"fill stroke markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"stroke\")}fill(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"stroke fill markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"fill\")}rect(e,t,i,n){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(e,t),this.lineTo(e+i,t),this.lineTo(e+i,t+n),this.lineTo(e,t+n),this.lineTo(e,t),this.closePath()}fillRect(e,t,i,n){n<0&&(t+=n,n=-n),i<0&&(e+=i,i=-i);var r,s,o,a={x:e,y:t,width:i,height:n};(!this.viewbox||(r=this.viewbox,s=a,r.xs.x&&r.ys.y))&&(o=this.__createElement(\"rect\",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement(\"fill\"))}strokeRect(e,t,i,n){var r;r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement(\"stroke\")}strokeEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"stroke\")}fillEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"fill\")}__ellipse(e,t,i,n,r,s,o,a,c){const l={cx:e,cy:t,rx:i,ry:n},h=this.__createElement(\"ellipse\",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var e=this.__closestGroupOrSvg().getAttribute(\"transform\"),t=this.__root.childNodes[1],i=t.childNodes,n=i.length-1;n>=0;n--)i[n]&&t.removeChild(i[n]);this.__currentElement=t,this.__groupStack=[],e&&this.__addTransform(e)}clearRect(e,t,i,n){if(0!==e||0!==t||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n,fill:\"#FFFFFF\"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(e,t,i,n){var r=this.__createElement(\"linearGradient\",{id:iu(this.__ids),x1:e+\"px\",x2:i+\"px\",y1:t+\"px\",y2:n+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(r),new au(r,this)}createRadialGradient(e,t,i,n,r,s){var o=this.__createElement(\"radialGradient\",{id:iu(this.__ids),cx:n+\"px\",cy:r+\"px\",r:s+\"px\",fx:e+\"px\",fy:t+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(o),new au(o,this)}__parseFont(){var e=/^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))(?:\\s*\\/\\s*(normal|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])))?\\s*([-,\\'\\\"\\sa-z0-9]+?)\\s*$/i.exec(this.font),t={style:e[1]||\"normal\",size:e[4]||\"10px\",family:e[6]||\"sans-serif\",weight:e[3]||\"normal\",decoration:e[2]||\"normal\",href:null};return\"underline\"===this.__fontUnderline&&(t.decoration=\"underline\"),this.__fontHref&&(t.href=this.__fontHref),t}__wrapTextLink(e,t){if(e.href){var i=this.__createElement(\"a\");return i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",e.href),i.appendChild(t),i}return t}__applyText(e,t,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement(\"text\",{\"font-family\":o.family,\"font-size\":o.size,\"font-style\":o.style,\"font-weight\":o.weight,\"text-decoration\":o.decoration,x:t,y:i,\"text-anchor\":(r=this.textAlign,s={left:\"start\",right:\"end\",center:\"middle\",start:\"start\",end:\"end\"},s[r]||s.start),\"dominant-baseline\":nu(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(e)),this.__currentElement=c,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,c))}fillText(e,t,i){this.__applyText(e,t,i,\"fill\")}strokeText(e,t,i){this.__applyText(e,t,i,\"stroke\")}measureText(e){return this.__ctx.font=this.font,this.__ctx.measureText(e)}arc(e,t,i,n,r,s){if(n!==r){(n%=2*Math.PI)===(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=e+i*Math.cos(r),a=t+i*Math.sin(r),c=e+i*Math.cos(n),l=t+i*Math.sin(n),h=s?0:1,d=0,u=r-n;u<0&&(u+=2*Math.PI),d=s?u>Math.PI?0:1:u>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(tu(\"A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}\",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:d,sweepFlag:h,endX:o,endY:a})),this.__currentPosition={x:o,y:a}}}clip(){var e=this.__closestGroupOrSvg(),t=this.__createElement(\"clipPath\"),i=iu(this.__ids),n=this.__createElement(\"g\");this.__applyCurrentDefaultPath(),e.removeChild(this.__currentElement),t.setAttribute(\"id\",i),t.appendChild(this.__currentElement),this.__defs.appendChild(t),e.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:i})),e.appendChild(n),this.__currentElement=n}drawImage(){var e,t,i,n,r,s,o,a,c,l,h,d,u,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)e=f[1],t=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)e=f[1],t=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error(\"Invalid number of arguments passed to drawImage: \"+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],e=f[5],t=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var w=\"translate(\"+e+\", \"+t+\")\";if(p instanceof lu){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)u=c.childNodes[0].getAttribute(\"id\"),this.__ids[u]=u,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,F=l.getAttribute(\"transform\");b=F?F+\" \"+w:w,l.setAttribute(\"transform\",b),o.appendChild(l)}}}else\"CANVAS\"!==p.nodeName&&\"IMG\"!==p.nodeName||((h=this.__createElement(\"image\")).setAttribute(\"width\",i),h.setAttribute(\"height\",n),h.setAttribute(\"preserveAspectRatio\",\"none\"),(g||m||r!==p.width||s!==p.height)&&((d=this.__document.createElement(\"canvas\")).width=i,d.height=n,d.getContext(\"2d\").drawImage(p,g,m,r,s,0,0,i,n),p=d),h.setAttribute(\"transform\",w),h.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===p.nodeName?p.toDataURL():p.getAttribute(\"src\")),o.appendChild(h))}createPattern(e,t){let i,n=this.__document.__createElement(\"pattern\"),r=iu(this.__ids);return n.setAttribute(\"id\",r),n.setAttribute(\"width\",e.width),n.setAttribute(\"height\",e.height),\"CANVAS\"===e.nodeName||\"IMG\"===e.nodeName?(i=this.__createElement(\"image\"),i.setAttribute(\"width\",e.width),i.setAttribute(\"height\",e.height),i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===e.nodeName?e.toDataURL():e.getAttribute(\"src\")),n.appendChild(i),this.__defs.appendChild(n)):e instanceof lu&&(n.appendChild(e.__root.childNodes[1]),this.__defs.appendChild(n)),new cu(n,this)}setLineDash(e){e&&e.length>0?this.lineDash=e.join(\",\"):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}function hu(e){if(e.startsWith(\"GCF\")||e.startsWith(\"GCA\")&&e.length>=13){return\"https://hgdownload.soe.ucsc.edu/hubs/\"+e.substring(0,3)+\"/\"+e.substring(4,7)+\"/\"+e.substring(7,10)+\"/\"+e.substring(10,13)+\"/\"+e+\"/hub.txt\"}}class du{static supportedTypes=new Set([\"bigBed\",\"bigWig\",\"bigGenePred\",\"vcfTabix\"]);static filterTracks=new Set([\"cytoBandIdeo\",\"assembly\",\"gap\",\"gapOverlap\",\"allGaps\",\"cpgIslandExtUnmasked\",\"windowMasker\"]);static async loadHub(e){const t=e.lastIndexOf(\"/\"),i=e.substring(0,t+1),n=await pu(e);let r;if(\"genome\"===n[1].type){const e=n[1];if(e.hasProperty(\"groups\")){const t=i+e.getProperty(\"groups\");r=await pu(t)}if(e.hasProperty(\"chromSizes\")){const t=i+e.getProperty(\"chromSizes\"),n=await async function(e){try{const t=(await fetch(e,{method:\"HEAD\"})).headers;return t.has(\"content-length\")?t.get(\"content-length\"):null}catch(e){return null}}(t);null!==n&&Number.parseInt(n)<1e6&&e.setProperty(\"chromSizesURL\",t)}}return new du(e,n,r)}constructor(e,t,i){this.url=e;const n=e.lastIndexOf(\"/\");if(this.baseURL=e.substring(0,n+1),\"hub\"!==t[0].type)throw Error(\"Unexpected hub.txt file -- does the first line start with 'hub'?\");if(this.hubStanza=t[0],\"on\"!==this.hubStanza.getProperty(\"useOneFile\"))throw Error(\"Only 'useOneFile' hubs are currently supported\");if(t.length<2)throw Error(\"Expected at least 2 stanzas, hub and genome\");if(\"genome\"!==t[1].type)throw Error(`Unexpected hub file -- expected \"genome\" stanza but found \"${t[1].type}\"`);this.genomeStanza=t[1],this.trackStanzas=[];for(let e=2;e0?e.substring(0,t):e}}this.genomeStanza.hasProperty(\"blat\")&&(r.blat=this.baseURL+this.genomeStanza.getProperty(\"blat\")),this.genomeStanza.hasProperty(\"chromAliasBb\")&&(r.chromAliasBbURL=this.baseURL+this.genomeStanza.getProperty(\"chromAliasBb\")),this.genomeStanza.hasProperty(\"chromAlias\")&&(r.aliasURL=this.baseURL+this.genomeStanza.getProperty(\"chromAlias\")),this.genomeStanza.hasProperty(\"twoBitBptURL\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptURL\")),this.genomeStanza.hasProperty(\"twoBitBptUrl\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptUrl\")),e.includeChromSizes&&this.genomeStanza.hasProperty(\"chromSizes\")&&(r.chromSizesURL=this.baseURL+this.genomeStanza.getProperty(\"chromSizes\")),this.hubStanza.hasProperty(\"longLabel\")?r.description=this.hubStanza.getProperty(\"longLabel\").replace(\"/\",\"\\n\"):(r.description=r.id,this.genomeStanza.hasProperty(\"description\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"description\")}`),this.genomeStanza.hasProperty(\"organism\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"organism\")}`),this.genomeStanza.hasProperty(\"scientificName\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"scientificName\")}`),this.genomeStanza.hasProperty(\"htmlPath\")&&(r.infoURL=this.baseURL+this.genomeStanza.getProperty(\"htmlPath\")));const s=this.trackStanzas.filter((e=>\"cytoBandIdeo\"===e.name&&e.hasProperty(\"bigDataUrl\")));s.length>0&&(r.cytobandBbURL=this.baseURL+s[0].getProperty(\"bigDataUrl\"));return r.tracks=this.#g((e=>!du.filterTracks.has(e.name)&&\"hide\"!==e.getProperty(\"visibility\"))),r}getGroupedTrackConfigurations(){const e=new Map;for(let t of this.#g()){if(\"cytoBandIdeo\"===t.name)continue;const i=t.group||\"other\";e.has(i)?e.get(i).push(t):e.set(i,[t])}const t=this.groupStanzas?new Map(this.groupStanzas.map((e=>[e.getProperty(\"name\"),e]))):new Map;return Array.from(e.keys()).map((i=>({label:t.has(i)?t.get(i).getProperty(\"label\"):i,tracks:e.get(i)})))}#g(e){return this.trackStanzas.filter((t=>du.supportedTypes.has(t.format)&&t.hasProperty(\"bigDataUrl\")&&(!e||e(t)))).map((e=>this.#m(e)))}#m(e){const t=e.format,i={id:e.getProperty(\"track\"),name:e.getProperty(\"shortLabel\"),format:t,url:this.baseURL+e.getProperty(\"bigDataUrl\"),displayMode:e.displayMode};if(\"vcfTabix\"===t&&(i.indexURL=i.url+\".tbi\"),e.hasProperty(\"longLabel\")&&e.hasProperty(\"html\")?(i.description&&(i.description+=\"
\"),i.description=`${e.getProperty(\"longLabel\")}`):e.hasProperty(\"longLabel\")&&(i.description=e.getProperty(\"longLabel\")),e.hasProperty(\"autoScale\")&&(i.autoscale=\"on\"===e.getProperty(\"autoScale\").toLowerCase()),e.hasProperty(\"maxHeightPixels\")){const t=e.getProperty(\"maxHeightPixels\").split(\":\");i.maxHeight=Number.parseInt(t[0]),i.height=Number.parseInt(t[1]),i.minHeight=Number.parseInt(t[2])}if(e.hasProperty(\"color\")){const t=e.getProperty(\"color\");i.color=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"altColor\")){const t=e.getProperty(\"altColor\");i.altColor=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"viewLimits\")){const t=e.getProperty(\"viewLimits\").split(\":\");let n,r;t.length>1&&(n=Number.parseInt(t[0]),r=Number.parseInt(t[1])),Number.isNaN(r)||Number.isNaN(n)?console.warn(`Unexpected viewLimits value in track line: ${properties.viewLimits}`):(i.min=n,i.max=r)}if(e.hasProperty(\"itemRgb\"),\"hide\"===e.getProperty(\"visibility\")&&(i.visible=!1),e.hasProperty(\"url\")&&(i.infoURL=e.getProperty(\"url\")),e.hasProperty(\"searchIndex\")&&(i.searchIndex=e.getProperty(\"searchIndex\")),e.hasProperty(\"searchTrix\")&&(i.trixURL=this.baseURL+e.getProperty(\"searchTrix\")),e.hasProperty(\"group\")&&(i.group=e.getProperty(\"group\"),this.groupPriorityMap&&this.groupPriorityMap.has(i.group))){const e=this.groupPriorityMap.get(i.group)+1;i.order=e,this.groupPriorityMap.set(i.group,e)}return i}}function uu(e){const t=e.indexOf(\" \");return t>0?e.substring(0,t):e}class fu{properties=new Map;constructor(e,t){this.type=e,this.name=t}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.has(e)?this.properties.get(e):this.parent?this.parent.getProperty(e):void 0}hasProperty(e){return!!this.properties.has(e)||!!this.parent&&this.parent.hasProperty(e)}get format(){const e=this.getProperty(\"type\");if(e)return uu(e)}get displayMode(){let e=this.getProperty(\"visibility\");if(!e)return\"COLLAPSED\";switch(e=e.toLowerCase(),e){case\"dense\":default:return\"COLLAPSED\";case\"pack\":return\"EXPANDED\";case\"squish\":return\"SQUISHED\"}}}async function pu(e){const t=await fetch(e),i=(await t.text()).split(/\\n|\\r\\n|\\r/g),n=[];let r,s=!0;for(let e of i){const t=gu(e),i=e.indexOf(\" \",t);if(i<0)s=!0;else{const o=e.substring(t,i).trim();if(o.startsWith(\"#\"))continue;const a=e.substring(i+1).trim();if(s){const e=new fu(o,a);n.push(e),r=e,s=!1}r.setProperty(o,a)}}return function(e){const t=new Map;for(let i of e)t.set(i.name,i);for(let i of e)if(i.properties.has(\"parent\")){const e=uu(i.properties.get(\"parent\"));i.parent=t.get(e)}return e}(n)}function gu(e){let t=0;for(t=0;t=13)try{const e=hu(i);t=(await du.loadHub(e)).getGenomeConfig()}catch(e){console.error(e)}t||e.present(new Error(`Unknown genome id: ${i}`),void 0)}return t}return t}};let wu,bu,Fu=0,vu=0,yu=[];class Au extends eu{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.$spinner=Bt(\"
\",{class:\"igv-loading-spinner-container\"}),this.$viewport.append(this.$spinner),this.$spinner.append(Bt(\"
\"));const e=this.trackView.track;\"sequence\"!==e.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),\"sequence\"!==e.id&&(this.$trackLabel=Bt('
'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(e.name||\"\"),!1===this.browser.doShowTrackLabels&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(e){super.setContentHeight(e),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(e){this.$trackLabel.empty(),this.$trackLabel.html(e);const t=this.$trackLabel.text();this.$trackLabel.attr(\"title\",t)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&\"sequence\"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return Bt(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if(\"all\"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const e=this.trackView.track.visibilityWindow;return void 0!==e&&e>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>e}return!0})()){if(this.canvas&&(Bt(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const e=this.trackView.minHeight||0;this.setContentHeight(e)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const e=this.referenceFrame;this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===e.bpPerPixel&&(this.canvas._data.pixelShift=Math.round((this.canvas._data.bpStart-e.start)/e.bpPerPixel),this.canvas.style.left=this.canvas._data.pixelShift+\"px\")}genomicRange(){return{start:this.referenceFrame.start,end:this.referenceFrame.start+this.referenceFrame.bpPerPixel*this.$viewport.width()}}setTop(e){if(super.setTop(e),this.canvas){const t=this.$viewport.height(),i=e+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n0)for(let n of i.roiSets){const i=await n.getFeatures(t,s,o,e.bpPerPixel);r.push({track:n,features:i})}const a=i&&i.resolutionAware,c=this.windowFunction;return this.featureCache=new Cu(t,s,o,e.bpPerPixel,n,r,a,c),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(e){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage(\"Error loading track data\"),this.browser.alert.present(e),console.error(e))}finally{this.loading=!1,this.stopSpinner()}}}get track(){return this.trackView.track}get windowFunction(){return this.track?this.track.windowFunction:void 0}repaintDimensions(){const e=mu.isWholeGenomeView(this.referenceFrame.chr),t=e?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(e?0:this.$viewport.width()*i),bpEnd:e?Number.MAX_SAFE_INTEGER:this.referenceFrame.start+2*this.$viewport.width()*i+1,pixelWidth:t}}repaint(){if(void 0===this.featureCache)return;const{features:e,roiFeatures:t}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=t?Math.max(o,s):o,c=Math.min(a,3*s);if(0===r||0===c)return void(this.canvas&&Bt(this.canvas).remove());const l=Math.max(0,-this.contentTop-Math.floor(c/3)),h=this.referenceFrame.bpPerPixel,d=Math.round((i-this.referenceFrame.start)/h),u=(this.contentTop||0)+l,f=document.createElement(\"canvas\");f.style.position=\"relative\",f.style.display=\"block\",f.style.width=r+\"px\",f.style.height=c+\"px\",f.style.left=d+\"px\",f.style.top=u+\"px\";const p=\"FILL\"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*c;const g=f.getContext(\"2d\");g.scale(p,p),g.translate(0,-l);const m={context:g,pixelXOffset:d,pixelWidth:r,pixelHeight:c,pixelTop:l,bpStart:i,bpEnd:n,bpPerPixel:h,pixelShift:d,windowFunction:this.windowFunction,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,e,t),this.canvas&&Bt(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(Bt(f))}refresh(){if(!this.canvas||!this.featureCache)return;const e=this.canvas._data;e.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:t,roiFeatures:i}=this.featureCache;this.draw(e,t,i)}draw(e,t,i){if(t&&(e.features=t,this.trackView.track.draw(e)),i&&i.length>0)for(let t of i)e.features=t.features,t.track.draw(e)}containsPosition(e,t){return this.referenceFrame.chr===e&&t>=this.referenceFrame.start&&t<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const e=this.canvas._data,t=e?e.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-Bt(this.canvas).position().left*i,o=(-this.contentTop-t)*i,a=this.canvas.getContext(\"2d\").getImageData(s,o,n,r),c=document.createElement(\"canvas\"),l=c.getContext(\"2d\");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);Pt((this.$trackLabel.text()?this.$trackLabel.text():\"image\")+\".png\",c.toDataURL(\"image/png\"))}saveSVG(){let{width:e,height:t}=this.browser.columnContainer.getBoundingClientRect();const i=new lu({width:e,height:8e3,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),n={deltaX:32,deltaY:32};this.renderSVGContext(i,n,!1),i.setHeight(t);const r=(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\"),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),a=i.getSerializedSvg(!0),c=URL.createObjectURL(new Blob([a],{type:\"application/octet-stream\"}));Pt(`${`${r}_referenceFrame_${o}_guid_${s()}`}.svg`,c)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){if(!(this.$zoomInNotice&&this.$zoomInNotice.is(\":visible\"))){const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,a=t,c=i+this.contentTop,l=-this.contentTop;e.saveWithTranslationAndClipRect(o,a,c,n,r,l);const{start:h,bpPerPixel:d}=this.referenceFrame,u=Math.round((h-this.referenceFrame.start)/d),f={context:e,viewport:this,referenceFrame:this.referenceFrame,top:l,pixelTop:l,pixelWidth:n,pixelHeight:r,pixelXOffset:u,pixelShift:u,bpStart:h,bpEnd:h+n*d,bpPerPixel:d,viewportWidth:n,selection:this.selection},p=this.featureCache?this.featureCache.features:void 0,g=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(f,p,g),e.restore()}if(n&&this.$trackLabel&&this.browser.doShowTrackLabels){const{x:n,y:r,width:s,height:o}=((e,t)=>{const{x:i,y:n,width:r,height:s}=e.getBoundingClientRect(),{x:o,y:a,width:c,height:l}=t.getBoundingClientRect();return{x:o-i,y:a-n,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(e,t+n,i+r,s,o)}}renderTrackLabelSVG(e,t,i,n,r){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_track_label_guid_${s()}`;e.saveWithTranslationAndClipRect(o,t,i,n,r,0),e.fillStyle=\"white\",e.fillRect(0,0,n,r),e.font=\"12px Arial\",e.fillStyle=\"rgb(68, 68, 68)\";const{width:a}=e.measureText(this.$trackLabel.text()),c=.25*(n-a),l=.7*(r-12);e.fillText(this.$trackLabel.text(),c,r-l),e.strokeStyle=\"rgb(68, 68, 68)\",e.strokeRect(0,0,n,r),e.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(e,t,i,n,r){if(this.featureCache&&this.featureCache.containsRange(t,i,n,r,this.windowFunction))return this.featureCache.features;if(\"function\"==typeof e.getFeatures){const s=await e.getFeatures(t,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const e=this.canvas._data;return!e||this.referenceFrame.starte.bpEnd||this.referenceFrame.chr!==e.referenceFrame.chr||this.referenceFrame.bpPerPixel!=e.bpPerPixel||this.windowFunction!=e.windowFunction}needsReload(){if(!this.featureCache)return!0;const{chr:e,bpPerPixel:t}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(e,i,n,t,this.windowFunction)}createZoomInNotice(e){const t=Bt(\"
\",{class:\"igv-zoom-in-notice-container\"});e.append(t);const i=Bt(\"
\");return t.append(i),i.text(\"Zoom in to see features\"),t.hide(),t}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const e=this.$viewport.get(0);this.addViewportContextMenuHandler(e);const t=e=>{this.enableClick=!0,this.browser.mouseDownOnViewport(e,this),r(e)};e.addEventListener(\"mousedown\",t),e.addEventListener(\"touchstart\",t);const i=e=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};e.addEventListener(\"mouseup\",i),e.addEventListener(\"touchend\",i),\"function\"==typeof this.trackView.track.hoverText&&e.addEventListener(\"mousemove\",(e=>{if(0===e.buttons&&Date.now()-vu>100){vu=Date.now();const t=this.createClickState(e);if(t){const e=this.trackView.track.hoverText(t);e?this.$viewport[0].setAttribute(\"title\",e):this.$viewport[0].removeAttribute(\"title\")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&\"sequence\"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(e){e.addEventListener(\"contextmenu\",(e=>{if(this.browser.dragObject)return!1;const t=this.createClickState(e);if(void 0===t)return!1;e.preventDefault();let i=[];if(\"function\"==typeof this.trackView.track.contextMenuItemList){const e=this.trackView.track.contextMenuItemList(t);e&&(i=e)}i.length>0&&i.push({label:Bt(\"
\")}),i.push({label:\"Save Image (PNG)\",click:()=>this.savePNG()}),i.push({label:\"Save Image (SVG)\",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(e,i)}))}addViewportClickHandler(e){e.addEventListener(\"click\",(e=>{if(this.enableClick&&this.canvas){if(3===e.which||e.ctrlKey)return;if(this.browser.dragObject||this.browser.isScrolling)return;e.preventDefault();const t=a(e,this.$viewport.get(0)).x,i=a(e,this.canvas).x,n=this.referenceFrame;Math.floor(n.start+n.toBP(i));const r=Date.now();if(r-Fue));e[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=t,i=e.join(\" \")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,e,this.referenceFrame)}else\"function\"==typeof this.trackView.track.popupData&&(wu=setTimeout((()=>{const t=this.getPopupContent(e);if(t)if(!1===e.shiftKey){if(bu&&bu.dispose(),yu.length>0){for(const e of yu)e.dispose();yu.length=0}bu=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{bu.dispose()})),bu.presentContentWithEvent(e,t)}else{let i=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{const e=yu.indexOf(i);yu.splice(e,1),i.dispose()}));yu.push(i),i.presentContentWithEvent(e,t)}window.clearTimeout(wu),wu=void 0}),this.browser.constants.doubleClickDelay));Fu=r}}))}addTrackLabelClickHandler(e){e.addEventListener(\"click\",(e=>{e.stopPropagation();const{track:t}=this.trackView;let i;\"function\"==typeof t.description?i=t.description():t.description&&(i=`
${t.description}
`),i&&(void 0===this.popover&&(this.popover=new tc(this.browser.columnContainer,!0,t.name||\"\",void 0)),this.popover.presentContentWithEvent(e,i))}))}createClickState(e){if(!this.canvas)return;const t=this.referenceFrame,i=a(e,this.$viewport.get(0)),n=a(e,this.canvas),r=t.start+t.toBP(i.x);return{event:e,viewport:this,referenceFrame:t,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(e){const t=this.createClickState(e);if(void 0===t)return;let i=this.trackView.track;const n=i.popupData(t),r=this.browser.fireEvent(\"trackclick\",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((e=>{if(e.name){const t=`${e.name}   ${e.value}`;return`
${t}
`}return\"
\"===e?e:e.html?e.html:`
${e}
`})).join(\"\")):\"string\"==typeof r&&(s=r),s}dispose(){this.popover&&this.popover.dispose(),super.dispose()}}class Cu{constructor(e,t,i,n,r,s,o,a){this.chr=e,this.bpStart=t,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o,this.windowFunction=a}containsRange(e,t,i,n,r){if(r&&r!==this.windowFunction)return!1;const s=this.multiresolution?this.bpPerPixel/n:1;return t>=this.bpStart&&i<=this.bpEnd&&e===this.chr&&s>.5&&s<2}overlapsRange(e,t,i){return this.chr===e&&i>=this.bpStart&&t<=this.bpEnd}}const _u=function(e,t){const{r:i,g:n,b:r}=no[e];return`rgba(${i},${n},${r},${t})`}(\"nickel\",2/16),xu=_u;class ku{constructor(e,t){if(this.url=e.url,e.name&&(this.name=e.name),this.isUserDefined=e.isUserDefined,e.featureSource)this.featureSource=e.featureSource;else if(e.features)this.featureSource=new Su(e.features,t);else{if(!e.format)throw Error(\"ROI configuration must define either features or file format\");this.featureSource=Ad(e,t)}!0===this.isUserDefined?(this.color=e.color||xu,this.headerColor=\"rgba(155,185,129)\"):(this.color=e.color||_u,this.headerColor=\"rgb(190,190,190)\"),this.isVisible=void 0===e.isVisible||e.isVisible}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}async getAllFeatures(){return\"function\"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(e){this.featureSource.addFeature(e)}removeFeature(e){this.featureSource.removeFeature(e)}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined,isVisible:this.isVisible};{const e=this.featureSource.getAllFeatures(),t=[];for(let i of Object.keys(e))for(let n of e[i])t.push(n);return{name:this.name,color:this.color,features:t,isUserDefined:this.isUserDefined,isVisible:this.isVisible}}}dispose(){for(let e of Object.keys(this))this[e]=void 0}}function Iu(e,t,i,n){let r=Math.round((e-i)/n);let s=Math.round((t-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class Su{constructor(e,t){this.featureMap={},this.genome=t;for(let i of e){const e=t?t.getChromosomeName(i.chr):i.chr;let n=this.featureMap[e];n||(n=[],this.featureMap[e]=n),n.push(i)}for(let e of Object.keys(this.featureMap))this.featureMap[e].sort(((e,t)=>e.start-t.start))}async getFeatures({chr:e,start:t,end:i}){if(\"all\"===e.toLowerCase())return Ll(this.featureMap,this.genome);{const n=this.featureMap[e];return n?n.filter((e=>e.end>t&&e.starte.start-t.start))}removeFeature({chr:e,start:t,end:i}){if(this.featureMap[e]){const n=`${e}-${t}-${i}`;this.featureMap[e]=this.featureMap[e].filter((e=>n!==`${e.chr}-${e.start}-${e.end}`)),0===this.featureMap[e].length&&delete this.featureMap[e]}}}class Eu{constructor(t,i,n,r){this.rulerViewport=t,this.rulerSweeper=e({class:\"igv-ruler-sweeper\"}),i.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(mu.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on(\"locuschange\",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off(\"locuschange\",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let e,t,i,n,r,s;this.boundContentMouseDownHandler=function(s){e=!0,t=!0;const{x:o}=a(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display=\"block\",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?xu:\"rgba(68, 134, 247, 0.25)\",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener(\"mousedown\",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let c;if(e&&t){const{x:e}=a(o,this.rulerViewport.contentDiv);c=Math.max(Math.min(e,this.rulerViewport.contentDiv.clientWidth),0),s=c-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;if(!0===e&&!0===t&&(e=t=void 0,this.rulerSweeper.style.display=\"none\",r>1)){s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))};!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(Qa(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(e,t,i){e.start=Math.round(t.start),e.end=Math.round(t.end),e.bpPerPixel=(e.end-e.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener(\"mousedown\",this.boundContentMouseDownHandler),document.removeEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),document.removeEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}function Nu(e){if(Bu[e])return Bu[e];if(Bu[\"chr\"+e]){const t=Bu[\"chr\"+e];return Bu[e]=t,t}{const t=_s.randomRGB(0,255);return Bu[e]=t,t}}const Bu={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0)\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};let Mu,Ru;class Du extends Au{constructor(e,t,i,n){super(e,t,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let e;this.$multiLocusCloseButton=Bt(\"
\",{class:\"igv-multi-locus-close-button\"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(l(\"times-circle\")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=Bt(\"
\",{class:\"igv-multi-locus-ruler-label\"}),this.$viewport.append(this.$rulerLabel),e=document.createElement(\"div\"),this.$rulerLabel.append(Bt(e)),this.$rulerLabel.get(0).addEventListener(\"click\",(async e=>{e.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=Bt(\"
\",{class:\"igv-ruler-tooltip\"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=Bt(\"
\"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new Eu(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(mu.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(e){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=Nu(this.referenceFrame.chr);const t=this.$rulerLabel.get(0).querySelector(\"div\"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();t.innerHTML=`${this.referenceFrame.getMultiLocusLabel(e)}`;const{width:n}=t.getBoundingClientRect();n/i>.5&&(t.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(e)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(e){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===e){const e=this.browser.referenceFrameList.indexOf(this.referenceFrame),t=`click${this.namespace}`;this.$viewport.on(t,(t=>{const{x:i}=a(t,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let t=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));t[e]=s,r=t.join(\" \")}this.browser.search(r)})),this.$viewport.get(0).style.cursor=\"pointer\"}else this.$viewport.get(0).style.cursor=\"default\"}mouseMove(e){if(!0===this.browser.doShowCursorGuide){void 0===Ru?(Ru=this,this.$tooltip.show()):Ru.guid!==this.guid?(Ru.$tooltip&&Ru.$tooltip.hide(),this.$tooltip.show(),Ru=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:t}=a(e,this.$viewport.get(0)),{start:i,end:n,bpPerPixel:r}=this.referenceFrame,s=Math.round(.5+i+Math.max(0,t)*r);this.$tooltipContent.text(Rt(s));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:c}=this.$viewport.get(0).getBoundingClientRect();return this.$tooltip.css({left:`${ys.clamp(t,0,c-o)}px`}),clearTimeout(Mu),Mu=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4),{start:i,bp:s,end:n}}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class Tu extends Au{featureCache=new Lu;constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.canvas=document.createElement(\"canvas\"),this.canvas.className=\"igv-ideogram-canvas\",this.$viewport.append(Bt(this.canvas)),this.ideogram_ctx=this.canvas.getContext(\"2d\"),this.addMouseHandlers()}async getFeatures(e,t,i,n){return this.featureCache.containsRange(e)?this.featureCache.get(e):this.loadFeatures()}async loadFeatures(){const e=this.referenceFrame.chr,t=await this.referenceFrame.genome.getCytobands(e);return this.featureCache.set(e,t),t}repaint(){if(void 0===this.featureCache)return;const{width:e,height:t}=this.$viewport[0].getBoundingClientRect();xo.configureHighDPICanvas(this.ideogram_ctx,e,t);const i=this.referenceFrame.chr,n=this.featureCache.get(i),r={context:this.ideogram_ctx,pixelWidth:e,pixelHeight:t,referenceFrame:this.referenceFrame,features:n};this.trackView.track.draw(r)}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(e){this.boundClickHandler=function(e){const{xNormalized:t,width:i}=a(e,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=t;s-r/2<0&&(s=r/2);s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),c=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=c,this.referenceFrame.bpPerPixel=(c-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),e.addEventListener(\"click\",this.boundClickHandler)}setWidth(e){this.$viewport.width(e)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){const{width:r,height:o}=this.$viewport.get(0).getBoundingClientRect(),a=`ideogram_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,c=t,l=i+this.contentTop,h=-this.contentTop;e.saveWithTranslationAndClipRect(a,c,l,r,o,h),this.trackView.track.draw({context:e,pixelWidth:r,pixelHeight:o,referenceFrame:this.referenceFrame,features:this.featureCache.get(this.referenceFrame.chr)}),e.restore()}startSpinner(){}stopSpinner(){}}class Lu{features=new Map;containsRange(e){return this.features.has(e)}set(e,t){this.features.set(e,t)}get(e){return this.features.get(e)}}function zu(e,t,i,n){if(\"ruler\"===e.track.type)return new Du(e,t,i,n);if(\"ideogram\"===e.track.id)return new Tu(e,t,i,n);{const r=new Au(e,t,i,n);return i.viewport=r,r}}const Hu=[\"rgb(255, 0, 0)\",\"rgb(0, 255, 0)\",\"rgb(0, 0, 255)\",\"rgb(255, 0, 255)\",\"rgb(0, 255, 255)\",\"rgb(128, 0, 128)\",\"rgb(255, 165, 0)\",\"rgb(255, 105, 180)\",\"rgb(255, 127, 80)\",\"rgb(220, 20, 60)\",\"rgb(255, 99, 71)\",\"rgb(173, 216, 230)\",\"rgb(144, 238, 144)\",\"rgb(224, 255, 255)\",\"rgb(250, 250, 210)\",\"rgb(152, 251, 152)\",\"rgb(70, 130, 180)\",\"rgb(102, 205, 170)\"].map((e=>{const[t,i,n]=e.split(\",\"),[r,s]=t.split(\"(\"),[o,a]=n.split(\")\");return[s,i,o]})),Pu=ro(\"magnesium\"),Ou=[\"#sampleTable\",\"#sampleMapping\",\"#colors\"];class Uu{static emptySpaceReplacement=\"|\";sampleDictionary={};attributeNames=[];sampleMappingDictionary={};colorDictionary={};attributeRangeLUT={};constructor(e){e.tracks.some((e=>\"function\"==typeof e.getSamples)).length>0&&e.sampleInfoControl.setButtonVisibility(!0),this.initialize()}initialize(){this.sampleInfoFiles=[],this.attributeNames=[],this.sampleDictionary={},this.sampleMappingDictionary={},this.colorDictionary={},this.attributeRangeLUT={},this.initialized=!1}get attributeCount(){return this.attributeNames?this.attributeNames.length:0}isInitialized(){return this.initialized}hasAttributes(){return this.attributeCount>0}getAttributes(e){const t=0===Object.keys(this.sampleMappingDictionary)?e:this.sampleMappingDictionary[e]||e;return this.sampleDictionary[t]}async loadSampleInfoFile(e){try{const t=await Qs.loadString(e);this.#w(t),this.sampleInfoFiles.push(e)}catch(e){console.error(e.message)}}#w(e){const t=function(e){const t={},i=e.split(/\\r?\\n|\\r/).map((e=>e.trim())).filter((e=>\"\"!==e));let n;Ou.includes(i[0])||(n=\"#sampleTable\",t[n]=[]);for(const e of i)Ou.includes(e)?(n=e,t[n]=[]):n&&!1===e.startsWith(\"#\")&&t[n].push(e);return t}(e);for(const[e,i]of Object.entries(t))switch(e){case\"#sampleTable\":this.#b(i);break;case\"#sampleMapping\":this.#F(i);break;case\"#colors\":this.#v(i)}this.initialized=!0}getAttributeColor(e,t){let i;if(\"-\"===t)i=ro(\"snow\");else if(\"string\"==typeof t&&this.colorDictionary[t])i=this.colorDictionary[t]();else if(this.colorDictionary[e])i=this.colorDictionary[e](t);else if(\"string\"==typeof t)i=\"NA\"===t?Pu:function(e){let t=0;for(let i=0;i>8*e&255;i.push(n)}return`rgb(${i.join(\", \")})`}(t);else{const[n,r]=this.attributeRangeLUT[e],s=.2,o=Math.max((t-n)/(r-n),s),[a,c,l]=Hu[Object.keys(this.attributeRangeLUT).indexOf(e)];i=`rgba(${a},${c},${l},${o})`}return i}getSortedSampleKeysByAttribute(e,t,i){i=i||1;const n=e.filter((e=>\"number\"==typeof this.getAttributes(e)[t])),r=e.filter((e=>\"string\"==typeof this.getAttributes(e)[t])),s=(e,n)=>{const r=this.getAttributes(e)[t],s=this.getAttributes(n)[t];return\"string\"==typeof r&&\"string\"==typeof s?i*r.localeCompare(s):\"number\"==typeof r&&\"number\"==typeof s?i*(r-s):void 0};return n.sort(s),r.sort(s),-1===i?[...n,...r]:[...r,...n]}toJSON(){const e=[];for(const t of this.sampleInfoFiles){const i={url:t},n=Hl.localFileInspection(i);e.push(n)}return e}#b(e){const t=e.shift().split(\"\\t\").filter((e=>e.length>0));t.shift();const i=t.map((e=>e.split(\" \").join(Uu.emptySpaceReplacement))),n=e.filter((e=>e.length>0));let r;for(const e of n){const t=e.split(\"\\t\"),n=t.shift();void 0===r&&(r={}),r[n]={};for(let e=0;e\"number\"==typeof e,r=e=>\"string\"==typeof e;for(const e of Object.keys(i)){const t=i[e],s=new Set(t),o=Array.from(s);if(!0===o.some(r)&&!0===o.some(n)?i[e]=o.filter((e=>!r(e))):i[e]=o,!i[e].some(r)){const t=i[e].slice();i[e]=[Math.min(...t),Math.max(...t)]}}return i}(i,r);qu(this.attributeRangeLUT,s);const o=new Set(this.attributeNames);for(const e of i)o.has(e)||this.attributeNames.push(e);qu(this.sampleDictionary,r)}#F(e){for(const t of e){const[e,i]=t.split(\"\\t\");this.sampleMappingDictionary[e]=i}}#v(e){const t=(e,t,i)=>{let n;switch(t){case 0:n=e.split(\" \").join(Uu.emptySpaceReplacement);break;case 1:n=e.includes(\":\")?e.split(\":\").map((e=>parseFloat(e))):e;break;case 2:case 3:n=`rgb(${e})`}return n},i=e.map((e=>e.split(\"\\t\").map(t))),n=i.filter((e=>3===e.length&&!e.includes(\"*\"))).filter((([e,t,i])=>!Array.isArray(t))),r={};for(const e of n){const[t,i,n]=e;void 0===r[t]&&(r[t]={}),r[t][i.toUpperCase()]=n}for(const[e,t]of Object.entries(r)){const i=Object.assign({},t);this.colorDictionary[e]=e=>{const t=e.toUpperCase();return i[t]||ro(\"snow\")}}const s=i.filter((e=>Array.isArray(e[1])));for(const e of s){const[t,i]=e[1],n=e[0];if(3===e.length){const[r,s,o]=uo(e[2]);this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return lo(r,s,o,(e-t)/(i-t))}}else if(4===e.length){const[t,i]=e[1],[n,r,s,o]=e;this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return fo(s,o,(e-t)/(i-t))}}}const o=i.filter((e=>3===e.length&&e.includes(\"*\")));for(const e of o)if(\"*\"===e[1]){const[t,i,n]=e;this.colorDictionary[t]=e=>{if(\"NA\"===e)return Pu;{const[i,r]=this.attributeRangeLUT[t],s=(e-i)/(r-i),[o,a,c]=uo(n);return lo(o,a,c,s)}}}else if(\"*\"===e[0]){const[t,i,n]=e;this.colorDictionary[i]=()=>n}}}function qu(e,t){for(const[i,n]of Object.entries(t))i in e&&e[i]===n||(e[i]=n)}function Qu(e){const t=Object.assign({},e);for(const[e,i]of Object.entries(t))\"string\"!=typeof i||isNaN(i)||(t[e]=Number(i));return t}const Vu=16,ju=Rt;class Wu{constructor(e){this.browser=e,this.height=40,this.name=\"\",this.id=\"ruler\",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type=\"ruler\"}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){mu.isWholeGenomeView(t.chr)?this.drawWholeGenome({context:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n}){e.save(),xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"});for(let t of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(t),s=this.browser.genome.getChromosome(t).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(e,o,0,a,i,t)}e.restore()}doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:r}){e.clearRect(0,0,i,n);const s=function(e,t){if(e<10)return new Gu(1,\"bp\",1);const i=Math.floor(Math.log10(e));let n=\"bp\",r=1;i>9?(n=\"gb\",r=1e9):i>6?(n=\"mb\",r=1e6):i>3&&(n=\"kb\",r=1e3);const s=Math.pow(10,i-1),o=e/s,a=75,c=Math.pow(10,i-1),l=Math.pow(10,i)/2;return new Gu(o0&&u+c<=d&&(xo.fillText(e,i,n,this.height-8),d=0),l>0&&xo.strokeLine(e,l,this.height-6,l,this.height-2),h=Math.floor((1+o)*s.majorTick);let f=l+(Math.round(t.toPixels(h-1-r+.5))-l)/2;f>0&&xo.strokeLine(e,f,this.height-6,f,this.height-2),++o,d+=a}while(le.measureText(o).width&&xo.fillText(e,o,t+n/2,i+r/2,{fillStyle:_s.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Gu{constructor(e,t,i){this.majorTick=e,this.minorTick=e/10,this.majorUnit=t,this.unitMultiplier=i}description(e){console.log((e||\"\")+\" tick \"+ju(this.majorTick)+\" label width \"+ju(this.labelWidthBP)+\" multiplier \"+this.unitMultiplier)}}class $u{constructor(t,i,n){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),this.viewport.style.height=`${t.track.height}px`,null===this.viewport.previousElementSibling&&(this.viewport.style.zIndex=16,this.viewport.style.overflow=\"visible\"),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.ctx.font=\"10px verdana\",this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(n),this.addMouseHandlers()}resizeCanvas(){const e=window.devicePixelRatio,t=this.browser.getSampleInfoViewportWidth();let i;if(this.browser.trackViews.length>1&&null===this.viewport.previousElementSibling){const[e,t]=[this.browser.ideogramTrackView.track,this.browser.rulerTrackView.track];i=e.height+t.height}else i=this.viewport.clientHeight;if(this.canvas.width!==t*e||this.canvas.height!==i*e){const n=this.canvas;n.width=t*e,n.height=i*e,n.style.width=`${t}px`,n.style.height=`${i}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(e,e),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}}setTop(e){\"function\"==typeof this.trackView.track.getSamples&&(this.contentTop=e,this.repaint())}setWidth(e){this.viewport.innerWidth=e,this.resizeCanvas()}setHeight(e){const t=this.browser.getSampleInfoViewportWidth();this.viewport.style.width=`${t}px`,this.viewport.style.height=`${e}px`;const i=window.devicePixelRatio;this.canvas.width=t*i,this.canvas.height=e*i,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(i,i),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}async repaint(){if(this.resizeCanvas(),\"function\"==typeof this.trackView.track.getSamples){const e=this.trackView.track.getSamples();e.names&&e.names.length>0&&this.draw({context:this.ctx,samples:e})}else null===this.viewport.previousElementSibling&&(this.browser.rulerTrackView&&this.browser.rulerTrackView.setTrackHeight(!0===this.browser.sampleInfoControl.showSampleInfo?this.calculateSampleInfoColumnHeight():40,!0),this.renderSampleInfoColumns(this.ctx))}calculateSampleInfoColumnHeight(){const e=this.browser.sampleInfo.attributeNames.map((e=>this.ctx.measureText(e).width));return 4+Math.min(Math.max(...e),128)}draw({context:e,samples:t}){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=ro(\"snow\"),e.fillRect(0,0,e.canvas.width,e.canvas.height),t&&t.names.length>0){const i=this.browser.sampleInfo.attributeNames,n=this.viewport.getBoundingClientRect().height;let r=1;const s=t.height;r=s-2*r<=1?0:1;let o=this.contentTop+t.yOffset;this.hitList={};for(const a of t.names){if(o>n)break;if(o+s>0){const t=this.browser.sampleInfo.getAttributes(a);if(t){const n=Object.entries(t);for(const t of n){const[n,a]=t;e.fillStyle=this.browser.sampleInfo.getAttributeColor(n,a);const c=8+i.indexOf(n)*Vu,l=o+r,h=s-2*r;e.fillRect(c,l,15,h);const d=`${Math.floor(c)}#${Math.floor(l)}#16#${Math.ceil(h)}`;this.hitList[d]=`${n}#${a}`}}}o+=s}}}renderSampleInfoColumns(e){const t=(e,t,i,n,r,s)=>{e.save(),e.font=\"10px verdana\",e.translate(i+r/2,n+s),e.rotate(-Math.PI/2),e.textAlign=\"left\",e.fillStyle=ro(\"lead\"),e.fillText(t,2,2),e.restore()},i=this.browser.sampleInfo.attributeNames;this.hitList={};for(let n=0;n{const{marginTop:n}=window.getComputedStyle(i),{x:r,y:s}=a(e,this.browser.columnContainer.querySelector(\".igv-sample-info-column\"));return{x:Math.floor(r),y:Math.floor(s-parseInt(n,10))}},n=this.browser.columnContainer.querySelector(\".igv-sample-info-column\"),{x:r,y:s}=i(n,this.viewport);n.setAttribute(\"title\",\"\");for(const[e,i]of t){const[t,o,a,c]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(rt+a||so+c)){n.setAttribute(\"title\",`${i}`);break}}}else{const{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){const[e,t]=r.split(\"#\");this.viewport.setAttribute(\"title\",`${e.split(Uu.emptySpaceReplacement).join(\" \")}: ${\"-\"===t?\"\":t}`);break}}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}show(){this.viewport.style.display=\"block\"}hide(){this.viewport.style.display=\"none\"}}class Ku{constructor(t,i,n,r){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.track.height}px`),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.trackScrollDelta=0,this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(r),this.addMouseHandlers()}checkCanvas(){const e=this.browser.sampleNameViewportWidth||0;this.ctx.canvas.width=e*window.devicePixelRatio,this.ctx.canvas.style.width=`${e}px`,this.ctx.canvas.height=this.viewport.clientHeight*window.devicePixelRatio,this.ctx.canvas.style.height=`${this.viewport.clientHeight}px`,this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio)}setTop(e){if(\"function\"==typeof this.trackView.track.getSamples){this.contentTop=e;const t=this.trackView.track.getSamples();this.repaint(t)}}setWidth(e){this.viewport.innerWidth=e,this.checkCanvas()}async repaint(e){if(e.names.length>0&&!0===this.browser.showSampleNames&&(this.checkCanvas(),this.draw({context:this.ctx,samples:e}),void 0===this.browser.sampleNameViewportWidth)){const t=e.names.map((e=>this.ctx.measureText(e).width));this.browser.sampleNameViewportWidth=Math.min(200,4+Math.ceil(Math.max(...t))),this.browser.layoutChange()}}draw({context:e,samples:t}){if(xo.fillRect(e,0,0,e.canvas.width,t.height,{fillStyle:ro(\"snow\")}),t&&t.names.length>0){const i=this.viewport.getBoundingClientRect().height,n=t.height,r=n-2<=1?0:1;let s=this.contentTop+t.yOffset;this.hitList={};for(const o of t.names){if(s>i)break;if(s+n>0){const t=n-2*r;Yu(e,o,0+2,s+r,e.canvas.width,t)}s+=n}}}renderSVGContext(e,{deltaX:t,deltaY:i}){if(\"function\"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:o,height:a}=this.viewport.getBoundingClientRect(),c=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_sample_names_guid_${s()}`;e.saveWithTranslationAndClipRect(c,t,i+r,o,a,-r),this.draw({context:e,samples:n}),e.restore()}}addMouseHandlers(){this.boundClickHandler=function(e){e.preventDefault();const t={label:\"Name Panel Width\",value:this.browser.sampleNameViewportWidth,callback:e=>{this.browser.sampleNameViewportWidth=parseInt(e),this.browser.layoutChange()}};this.browser.inputDialog.present(t,e)}.bind(this),this.viewport.addEventListener(\"contextmenu\",this.boundClickHandler),this.boundMouseMoveHandler=function(e){if(this.hitList){const t=Object.entries(this.hitList),{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){this.viewport.setAttribute(\"title\",`${r}`);break}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"contextmenu\",this.boundClickHandler),this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function Yu(e,t,i,n,r,s){const o=Math.min(s,10);e.font=`${o}px sans-serif`,e.textAlign=\"start\",e.fillStyle=ro(\"lead\");const a=i,c=e.measureText(t),l=n+s/2+(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent)/2;e.fillText(t,a,l)}class Xu{constructor(t){this.popover=e({class:\"igv-menu-popup\"}),t.appendChild(this.popover),this.parent=t;const i=e({class:\"igv-menu-popup-header\"});this.popover.appendChild(i),u(i,(()=>this.popover.style.display=\"none\")),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),p(this.popover,i),i.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault()})),this.popover.style.display=\"none\"}presentMenuList(e,t){if(Zu(this.parent),t.length>0){this.popoverContent.innerHTML=\"\";const i=this.parseMenuList(e,t);for(let e of i){e.init&&e.init();let t=e.object;0===i.indexOf(e)&&t.removeClass(\"igv-track-menu-border-top\"),t.hasClass(\"igv-track-menu-border-top\")||t.hasClass(\"igv-menu-popup-check-container\")||t.is(\"div\")&&t.addClass(\"igv-menu-popup-shim\"),this.popoverContent.appendChild(t.get(0))}this.popover.style.display=\"flex\";const{width:n}=this.popover.getBoundingClientRect();this.popover.style.left=-n+\"px\",this.popover.style.top=\"0px\"}}parseMenuList(e,t){return t.map(((t,i)=>{let n;if(t.name?(n=Bt(\"
\"),n.text(t.name)):t.object?n=t.object:\"string\"==typeof t.label?(n=Bt(\"
\"),n.html(t.label)):\"string\"==typeof t&&(n=t.startsWith(\"<\")?Bt(t):Bt(\"
\"+t+\"
\")),0===i&&n.addClass(\"igv-track-menu-border-top\"),t.click||t.dialog){const i=i=>{if(i.preventDefault(),i.stopPropagation(),t.click)if(e.track.selected){const n=e.browser.getSelectedTrackViews();if(!0===t.doAllMultiSelectedTracks)t.click.call(e.track,i);else if(\"removeTrack\"===t.menuItemType){const r=()=>{e.browser.overlayTrackButton.setVisibility(!1);for(const{track:e}of n)t.click.call(e,i)},s={html:`Are you sure you want to delete ${n.length} tracks?`,callback:r};e.browser.menuUtils.dialog.present(s,i)}else for(const{track:e}of n)t.click.call(e,i)}else t.click.call(e.track,i);else t.dialog&&t.dialog.call(e.track,i);this.popover.style.display=\"none\"};n.on(\"click\",i),n.on(\"touchend\",(e=>i(e))),n.on(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}return{object:n,init:t.init||void 0}}))}presentTrackContextMenu(t,n){this.popoverContent.innerHTML=\"\";const r=function(t,n){return t.map((t=>{let r;if(\"string\"==typeof t&&\"
\"===t)r=document.createElement(\"hr\");else if(\"string\"==typeof t)r=e({class:\"context-menu\"}),r.innerHTML=t;else if(\"Node\"==typeof t)r=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)r=Dl(\"Show all bases\",t.value);else if(\"color\"===t.type){const s=new Ra(n.parentElement);s.configure({color:\"grey\"}),r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);const o=e=>{s.show(),i(n),e.preventDefault(),e.stopPropagation()};r.addEventListener(\"click\",o),r.addEventListener(\"touchend\",o),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function a(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}r.addEventListener(\"click\",a),r.addEventListener(\"touchend\",a),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{el:r,init:t.init}}))}(n,this.popover);for(let{el:e}of r)this.popoverContent.appendChild(e);!function(e,t){t.style.display=\"flex\";const{x:i,y:n}=a(e,t.parentNode),{width:r}=t.getBoundingClientRect(),s=i+r,{width:o}=t.parentNode.getBoundingClientRect();t.style.left=`${s>o?i-(s-o):i}px`,t.style.top=`${n}px`}(t,this.popover)}hide(){this.popover.style.display=\"none\"}dispose(){this.popoverContent.innerHTML=\"\",this.popover.innerHTML=\"\",Object.keys(this).forEach((function(e){this[e]=void 0}))}}const Zu=e=>{const t=e.querySelectorAll(\".igv-menu-popup\");for(const e of t)e.style.display=\"none\"};class Ju{constructor(t,i,n,r,s,o,a){this.browser=i,this.button=e({class:\"igv-navbar-text-button\"}),t.appendChild(this.button),Array.isArray(n)?(this.textContent=n[0],this.title=n[1]):this.textContent=this.title=n,this.buttonLabel=r,this.imageDictionary={image:`url(\"data:image/svg+xml,${encodeURIComponent(s)}\")`,imageHover:`url(\"data:image/svg+xml,${encodeURIComponent(o)}\")`},this.responsiveKey=\"text\",this.configureButton(this.textContent,this.title),this.setState(a),i.on(\"navbar-resize\",(e=>{this.navbarResizeHandler(e)}))}navbarResizeHandler(e){const t=\"igv-navbar-icon-button\"===e?\"image\":\"text\";t!==this.responsiveKey&&(this.responsiveKey=t,this.configureButton(this.textContent,this.title),this.setState(void 0))}configureButton(e,t){this.groupElement=void 0,this.button.title=t,this.button.innerHTML=\"\",this.button.style.backgroundImage=\"none\",this.button.classList.remove(\"igv-navbar-icon-button\"),this.button.classList.remove(\"igv-navbar-text-button\"),\"text\"===this.responsiveKey?this.configureTextButton(e):this.configureIconButton()}configureTextButton(e){console.log(`text ${this.title}`),this.button.classList.add(\"igv-navbar-text-button\");const t=document.createElement(\"div\");t.innerHTML=this.buttonLabel;const i=t.firstChild;this.button.appendChild(i),this.groupElement=i.querySelector(\"#igv-navbar-button-group\");i.querySelector(\"#igv-navbar-button-label\").textContent=e}configureIconButton(){console.log(`icon ${this.title}`),this.button.classList.add(\"igv-navbar-icon-button\")}setState(e){void 0!==e&&(this.doHover=e),\"text\"===this.responsiveKey?this.setTextButtonState(this.doHover):this.setIconButtonState(this.doHover)}setTextButtonState(e){this.groupElement.classList.remove(...this.groupElement.classList);const t=!0===e?\"igv-navbar-text-button-svg-hover\":\"igv-navbar-text-button-svg-inactive\";this.groupElement.classList.add(t)}setIconButtonState(e){this.button.style.backgroundImage=!0===e?this.imageDictionary.imageHover:this.imageDictionary.image}show(){this.button.style.display=\"flex\"}hide(){this.button.style.display=\"none\"}setVisibility(e){!0===e?this.show():this.hide()}}const ef='\\n \\n \\n \\n \\n \\n \\n \\n \\n';class tf extends Hl{static defaults={autoscale:void 0,alpha:.5,height:50};constructor(e,t,i){super(e,t),this.type=\"merged\",this.paintAxis=cd,this.graphType=e.graphType,this.tracks=i||[]}async postInit(){if(this.config.tracks){for(let e of this.config.tracks){const t=await this.browser.createTrack(e);t?this.tracks.push(t):console.warn(\"Could not create track \"+e),\"function\"==typeof t.postInit&&await t.postInit()}this.config.tracks.every((e=>void 0!==e.autoscale||void 0!==e.max))||(this.config.autoscale=void 0===this.config.max)}for(let e of this.tracks)e.isMergedTrack=!0;if(this.config.autoscale?this.autoscale=this.config.autoscale:void 0!==this.config.max&&this.setDataRange({min:this.config.min||0,max:this.config.max}),void 0!==this.config.flipAxis)for(let e of this.tracks)e.flipAxis=this.config.flipAxis;if(void 0!==this.config.logScale)for(let e of this.tracks)e.logScale=this.config.logScale;this.resolutionAware=this.tracks.some((e=>e.resolutionAware))}set flipAxis(e){this.config.flipAxis=e;for(let t of rf(this.tracks))t.flipAxis=e}get flipAxis(){return rf(this.tracks).every((e=>e.flipAxis))}set logScale(e){this.config.logScale=e;for(let t of rf(this.tracks))t.logScale=e}get logScale(){return rf(this.tracks).every((e=>e.logScale))}get height(){return this._height}set height(e){if(this.config.height=e,this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}set autoscale(e){if(this._autoscale=e,!1===e&&this.tracks)for(let e of this.tracks)e.autoscale=!1}get autoscale(){return this._autoscale}set autoscaleGroup(e){if(this.tracks)for(let t of this.tracks)t.autoscaleGroup=e}get autoscaleGroup(){if(this.tracks&&this.tracks.length>0){const e=this.tracks[0].autoscaleGroup;return this.tracks.some((t=>e!==t.autoscaleGroup))?void 0:e}}setDataRange({min:e,max:t}){this.autoscale=!1;for(const i of rf(this.tracks))i.dataRange={min:e,max:t},i.autoscale=!1,i.autoscaleGroup=!1}set dataRange({min:e,max:t}){for(const i of rf(this.tracks))i.dataRange={min:e,max:t}}get dataRange(){if(this.tracks){const e=rf(this.tracks);if(e.length>0){const t=e[0].dataRange;if(e.every((e=>e.dataRange&&e.dataRange.min===t.min&&e.dataRange.max===t.max)))return t}}}menuItemList(){const e=[];return rf(this.tracks).length>0&&(void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e.push(...this.numericDataMenuItems())),e.push(\"
\"),e.push(this.overlayTrackAlphaAdjustmentMenuItem()),e.push(this.trackSeparationMenuItem()),e}async getFeatures(e,t,i,n){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n))),s=await Promise.all(r);if(s.every((e=>0===e.length)))return new nf([],[]);{const e=this.tracks.map((e=>e.name));return new nf(s,e)}}draw(e){const t=e.features;for(let i=0,n=this.tracks.length;i0&&i.push(\"
\"),i.push(`
${t[r].trackName}
`),t[r].features.length>0){n=!1;const s=this.tracks[r].popupData(e,t[r].features);i.push(...s)}else i.push(\"Missing or 0 value(s)\");return!0===n?[]:i}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!t.featureArrays||!Array.isArray(t.featureArrays)||0===t.featureArrays.length)return[];const i=e.genomicLocation,n=[],r=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2,s=i-r,o=i+r;for(let e=0;ee.supportsWholeGenome))}getState(){const e=super.getState(),t=[];for(let e of this.tracks)t.push(e.getState());return e.tracks=t,e}updateScales(e){let t;if(this.autoscale){t=!0;let i=[];for(let t of e){if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,r=n+e.toBP(t.getWidth()),s=t.featureCache.features;this.autoscale&&(i.push({value:s.getMax(n,r)}),i.push({value:s.getMin(n,r)}))}const e=qa(i);for(const t of rf(this.tracks))t.dataRange=e}}else{let i=-1;for(let n of this.tracks)if(++i,n.autoscale){t=!0;let r=[];for(let t of e)if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,s=n+e.toBP(t.getWidth()),o=t.featureCache.features.featureArrays[i];if(o)for(let e of o)if(!(e.ends)break;r.push(e)}}n.dataRange=qa(r)}}return t}overlayTrackAlphaAdjustmentMenuItem(){const t=e();return t.innerText=\"Set transparency\",{object:Bt(t),dialog:function(e){const t={label:\"Transparency\",value:this.alpha,min:0,max:1,scaleFactor:1e3,callback:e=>{this.alpha=Math.max(.001,e),this.repaintViews()}};this.browser.sliderDialog.present(t,e)}}}trackSeparationMenuItem(){const e=Bt(\"
\");return e.text(\"Separate tracks\"),{object:e,click:function(e){const t=this.autoscale,i=this.name,n=this.tracks,r=this.browser,s=this.order;r.removeTrack(this);for(let e of n)e.order=s,t&&(e.autoscaleGroup=i),e.isMergedTrack=!1,r.addTrack(e.config,e);r.updateViews()}}}}class nf{constructor(e,t){this.featureArrays=e,this.trackNames=t}getMax(e,t){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(!(void 0===r.value||Number.isNaN(r.value)||r.endt)break;i=Math.max(i,r.value)}return i!==-Number.MAX_VALUE?i:100}getMin(e,t){let i=0;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.endt)break;i=Math.min(i,r.value)}return i}}const rf=e=>e?e.filter((e=>void 0!==e.dataRange||void 0!==e.autoscale||void 0!==e.autoscaleGroup)):[];class sf extends Ju{constructor(e,t){super(e,t,\"Overlay Tracks\",ef,'\\n Overlay Tracks\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n Overlay Tracks Hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>this.setState(!1)));this.boundMouseClickHandler=(()=>{this.setVisibility(!1),of.call(this)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(!0)}}function of(e){if(!0===af(this.browser)){const e=this.browser.getSelectedTrackViews().map((({track:e})=>e));for(const t of e)t.selected=!1;const t=[];for(let i of e)\"merged\"===i.type?t.push(...i.tracks):t.push(i);const i={name:\"Overlay\",type:\"merged\",autoscale:!1,alpha:.5,height:Math.max(...e.map((({height:e})=>e))),order:Math.min(...e.map((({order:e})=>e)))},n=new tf(i,this.browser,t);for(const t of e){const e=this.browser.trackViews.indexOf(t.trackView);this.browser.trackViews.splice(e,1),t.trackView.dispose()}this.browser.addTrack(i,n),n.trackView.updateViews()}}function af(e){const t=e.getSelectedTrackViews();if(t&&t.length>1){const e=new Set([\"wig\",\"merged\"]);return t.filter((({track:t})=>e.has(t.type))).length>1}return!1}const cf=new Set([\"sequence\",\"ruler\",\"ideogram\"]),lf=new Set([\"ruler\",\"sequence\",\"ideogram\"]);class hf{constructor(e,t,i){this.namespace=`trackview-${s()}`,this.browser=e,this.track=i,i.trackView=this,this.addDOMToColumnContainer(e,t,e.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(e,t,i){this.axis=this.createAxis(e,this.track),this.createViewports(e,t,i),this.sampleInfoViewport=new $u(this,e.columnContainer.querySelector(\".igv-sample-info-column\"),e.getSampleInfoViewportWidth()),this.sampleNameViewport=new Ku(this,e.columnContainer.querySelector(\".igv-sample-name-column\"),void 0,e.getSampleNameViewportWidth()),this.createTrackScrollbar(e),this.createTrackDragHandle(e),this.createTrackGearPopup(e)}createViewports(e,t,i){this.viewports=[];const n=e.calculateViewportWidth(i.length),r=t.querySelectorAll(\".igv-column\");for(let e=0;e{e.preventDefault(),e.stopPropagation(),this.track.selected=e.target.checked,this.setDragHandleSelectionState(e.target.checked),this.browser.overlayTrackButton.setVisibility(af(this.browser))})),this.enableTrackSelection(!1)}return n}resizeAxisCanvas(e,t){this.axis.style.width=`${e}px`,this.axis.style.height=`${t}px`,\"function\"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${e}px`,this.axisCanvas.style.height=`${t}px`)}renderSVGContext(e,{deltaX:t,deltaY:i}){!function(e,t,i,n,r){if(\"function\"==typeof t.paintAxis){const{y:o,width:a,height:c}=i.getBoundingClientRect(),l=`${(t.name||t.id).replace(/\\W/g,\"\")}_axis_guid_${s()}`;e.saveWithTranslationAndClipRect(l,n,o+r,a,c,0),t.paintAxis(e,a,c),e.restore()}}(e,this.track,this.axisCanvas,t,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:n+t,deltaY:r+i};for(let t of this.viewports){t.renderSVGContext(e,o);const{width:i}=t.$viewport.get(0).getBoundingClientRect();o.deltaX+=i}if(!0===this.browser.sampleInfo.isInitialized()&&!0===this.browser.sampleInfoControl.showSampleInfo){this.sampleInfoViewport.renderSVGContext(e,o);const{width:t}=this.sampleInfoViewport.viewport.getBoundingClientRect();o.deltaX+=t}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(e,o)}presentColorPicker(e){if(!1===lf.has(this.track.type)){const t=[],i=this.track.color||this.track.defaultColor;Mt(i)&&t.push(i),this.track.altColor&&Mt(this.track.altColor)&&t.push(this.track.altColor);let n=t.map((e=>e.startsWith(\"#\")?e:e.startsWith(\"rgb(\")?_s.rgbToHex(e):_s.colorNameToHex(e))),r={color:e=>{this.track.color=io(e),this.repaintViews()},altColor:e=>{this.track.altColor=io(e),this.repaintViews()}};const s=this.browser.getSelectedTrackViews();s.length>0&&new Set(s).has(this)?(r={color:e=>{for(let t of s)t.track.color=e,t.repaintViews()}},this.browser.genericColorPicker.configure(n,r)):this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(e),this.browser.genericColorPicker.show()}}setTrackHeight(e,t){t||(this.track.minHeight&&(e=Math.max(this.track.minHeight,e)),this.track.maxHeight&&(e=Math.min(this.track.maxHeight,e))),this.track.height=e,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),\"function\"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:t}of this.viewports)t.height(e);if(this.sampleInfoViewport.setHeight(e),this.sampleNameViewport.viewport.style.height=`${e}px`,\"function\"!=typeof this.track.computePixelHeight)for(let t of this.viewports)t.setContentHeight(e);this.repaintViews(),this.updateScrollbar(),this.dragHandle.style.height=`${e}px`,this.gearContainer.style.height=`${e}px`}updateScrollbar(){const e=this.viewports[0].$viewport.height();if(this.outerScroll.style.height=`${e}px`,!1===cf.has(this.track.type)){const t=this.maxViewportContentHeight(),i=Math.round(e/t*e);t>e?(this.innerScroll.style.display=\"block\",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display=\"none\"}}moveScroller(e){const t=Bt(this.innerScroll).position().top+e,i=Math.min(Math.max(0,t),this.outerScroll.clientHeight-this.innerScroll.clientHeight);Bt(this.innerScroll).css(\"top\",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let e of this.viewports)e.setTop(r);this.sampleInfoViewport.setTop(r),this.sampleNameViewport.trackScrollDelta=e,this.sampleNameViewport.setTop(r)}isLoading(){for(let e of this.viewports)if(e.isLoading())return!0}repaintViews(){for(let e of this.viewports)e.isVisible()&&e.repaint();\"function\"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSampleInfo(),this.repaintSamples()}repaintSampleInfo(){this.sampleInfoViewport.repaint()}repaintSamples(){if(\"function\"==typeof this.track.getSamples){const e=this.track.getSamples();e.names&&e.names.length>0&&this.sampleNameViewport.repaint(e)}}setTrackLabelName(e){this.viewports.forEach((t=>t.setTrackLabel(e)))}resize(e){for(let t of this.viewports)t.setWidth(e)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const e=this.viewports.filter((e=>e.isVisible()));if(e.forEach((e=>e.shift())),this.browser.dragObject)return;const t=e.filter((e=>e.needsRepaint())).filter((e=>e.checkZoomIn())),i=e.filter((e=>e.checkZoomIn())).filter((e=>e.needsReload()));for(let e of i)await e.loadFeatures();if(this.disposed)return;if(this.track&&\"function\"==typeof this.track.variantRowCount&&i.length>0){let e=0;for(let t of this.viewports)t.featureCache&&t.featureCache.features&&(e=Math.max(e,t.featureCache.features.reduce(((e,t)=>Math.max(e,t.row||0)),0)));if(this.track.nVariantRows!==e+1){this.track.variantRowCount(e+1);for(let e of this.viewports)e.checkContentHeight()}}let n;if(\"merged\"===this.track.type)n=this.track.updateScales(e);else if(this.track.autoscale){let t=[];for(let i of e){const e=i.referenceFrame,n=e.start,r=n+e.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(n,r);if(t.push({value:e}),\"function\"==typeof i.featureCache.features.getMin){const e=i.featureCache.features.getMin(n,r);t.push({value:e})}}else{const e=to(i.featureCache.features,n,r);for(let i of e)t.push(i)}}\"function\"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(t):this.track.dataRange=qa(t)}const r=this.track.autoscale||this.track.autoscaleGroup||\"ruler\"===this.track.type||n||this.track.groupBy;for(let i of e)t.includes(i)?i.repaint():r&&i.refresh();this.adjustTrackHeight(),this.repaintSampleInfo(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let e of this.viewports)e.clearCache()}updateRulerViewportLabels(){const e=this.browser.calculateViewportWidth(this.viewports.length);for(let t of this.viewports)\"ruler\"===this.track.type&&(this.viewports.length>1?t.presentLocusLabel(e):t.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let e=[];const t=this.viewports.filter((e=>e.isVisible()));for(let i of t){const t=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+t.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(r,o);e.push({value:t})}else{const t=\"function\"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):to(i.featureCache.features,r,o);e=e.concat(t)}}return e}checkContentHeight(){for(let e of this.viewports)e.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var e=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(e,!1):this.track.paintAxis&&this.paintAxis(),!1===cf.has(this.track.type)){const t=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-e);if(t{if(!t.isVisible())return!1;if(t.checkZoomIn()){const i=t.referenceFrame,n=t.referenceFrame.chr,r=i.start,s=r+i.toBP(Bt(t.contentDiv).width()),o=i.bpPerPixel;return e||!t.tile||t.tile.invalidate||!t.tile.containsRange(n,r,s,o)}return!1}))}createTrackScrollbar(t){const i=e();if(t.columnContainer.querySelector(\".igv-scrollbar-column\").appendChild(i),i.style.height=`${this.track.height}px`,this.outerScroll=i,!1===cf.has(this.track.type)){const n=e();i.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){\"sequence\"!==this.track.type&&!0===mo.has(this.track.type)?this.dragHandle=e({class:\"igv-track-drag-shim\"}):(this.dragHandle=e({class:\"igv-track-drag-handle\"}),this.dragHandle.classList.add(\"igv-track-drag-handle-color\")),t.columnContainer.querySelector(\".igv-track-drag-column\").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){if(this.gearContainer=e(),t.columnContainer.querySelector(\".igv-gear-menu-column\").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu);else{function i(e){if(e.preventDefault(),e.stopPropagation(),\"none\"===this.trackGearPopup.popover.style.display){for(const e of t.trackViews.filter((e=>e!==this&&void 0!==e.trackGearPopup)))e.trackGearPopup.popover.style.display=\"none\";this.trackGearPopup.presentMenuList(this,t.menuUtils.trackMenuItemList(this))}else this.trackGearPopup.popover.style.display=\"none\"}this.gear=e(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(l(\"cog\")),this.trackGearPopup=new Xu(this.gear),this.boundTrackGearClickHandler=i.bind(this),this.gear.addEventListener(\"click\",this.boundTrackGearClickHandler)}}addTrackScrollMouseHandlers(e){this.boundTrackScrollMouseDownHandler=function(t){t.stopPropagation();const{y:i}=r(t);Bt(this.innerScroll).data(\"yDown\",i.toString()),this.boundColumnContainerMouseMoveHandler=function(e){e.stopPropagation();const{y:t}=r(e);this.moveScroller(t-parseInt(Bt(this.innerScroll).data(\"yDown\"))),Bt(this.innerScroll).data(\"yDown\",t.toString())}.bind(this),e.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(t){e.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),e.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),e.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===cf.has(this.track.type)&&(this.innerScroll.removeEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.browser.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.browser.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.browser.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseMoveHandler))}addTrackDragMouseHandlers(e){if(\"sequence\"===this.track.type||!1===mo.has(this.track.type)){let t;function i(i){i.preventDefault(),t=i.target,!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.add(\"igv-track-drag-handle-hover-color\")),e.startTrackDrag(this)}function n(i){e.endTrackDrag(),t&&i.target!==t&&!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-color\")),t=void 0}function r(i){i.preventDefault(),void 0===t&&!1===this.track.selected&&(i.target.classList.remove(\"igv-track-drag-handle-color\"),i.target.classList.add(\"igv-track-drag-handle-hover-color\")),e.updateTrackDrag(this)}function s(e){e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))}this.boundTrackDragMouseDownHandler=i.bind(this),this.dragHandle.addEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=n.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=r.bind(this),this.dragHandle.addEventListener(\"mouseenter\",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener(\"mouseout\",(e=>{e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){\"ideogram\"===this.track.type||\"ruler\"===this.track.type||(this.dragHandle.removeEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),document.removeEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener(\"mouseup\",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler))}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener(\"click\",this.boundTrackGearClickHandler)}removeDOMFromColumnContainer(){this.axis.remove(),this.removeViewportsFromColumnContainer(),this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}removeViewportsFromColumnContainer(){for(let e of this.viewports)e.$viewport.remove()}dispose(){this.axis.remove();for(let e of this.viewports)e.dispose();this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),\"function\"==typeof this.track.dispose&&this.track.dispose();for(let e of Object.keys(this))this[e]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if(\"function\"==typeof this.track.paintAxis){const{width:e,height:t}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*t,this.axisCanvas.width=i*e;const n=this.axisCanvas.getContext(\"2d\");if(n.scale(i,i),this.track.autoscaleGroup){if(void 0===wo[this.track.autoscaleGroup]){const e=so.Dark2,t=Math.floor(Math.random()*so.Dark2.length);wo[this.track.autoscaleGroup]=e[t]}const i=_s.addAlpha(wo[this.track.autoscaleGroup],.75);this.track.paintAxis(n,e,t,i)}else this.track.paintAxis(n,e,t,void 0)}}maxViewportContentHeight(){return Math.max(...this.viewports.map((e=>e.getContentHeight())))}enableTrackSelection(e){const t=this.trackSelectionContainer;if(t&&!mo.has(this.track.type))if(!1!==e)t.style.display=\"grid\";else{this.track.selected=!1;t.querySelector(\"[name=track-select]\").checked=this.track.selected,this.dragHandle&&this.setDragHandleSelectionState(!1),t.style.display=\"none\"}}setDragHandleSelectionState(e){const t=this.dragHandle;e?(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-selected-color\")):(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.remove(\"igv-track-drag-handle-selected-color\"),t.classList.add(\"igv-track-drag-handle-color\"))}}function df(e){this.thresholds=e.thresholds,this.colors=e.colors}function uf(e){this.scale=e,this.lowColor=\"rgb(\"+e.lowR+\",\"+e.lowG+\",\"+e.lowB+\")\",this.highColor=\"rgb(\"+e.highR+\",\"+e.highG+\",\"+e.highB+\")\",this.diff=e.high-e.low}df.prototype.getColor=function(e){for(let t of this.thresholds)if(e=i.high?this.highColor:(t=(e-i.low)/this.diff,\"rgb(\"+Math.floor(i.lowR+t*(i.highR-i.lowR))+\",\"+Math.floor(i.lowG+t*(i.highG-i.lowG))+\",\"+Math.floor(i.lowB+t*(i.highB-i.lowB))+\")\")};class ff{constructor(e){this.color=e}getColor(){return this.color}}const pf={threshold:2e3,r:0,g:0,b:255};class gf{constructor(e){e=e||pf,this.threshold=e.threshold,this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[],this.nbins=2e3,this.binsize=this.threshold/this.nbins}setThreshold(e){this.threshold=e,this.cache=[],this.binsize=this.threshold/this.nbins}getThreshold(){return this.threshold}setColorComponents(e){this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[]}getColorComponents(){return{r:this.r,g:this.g,b:this.b}}equals(e){return JSON.stringify(this)===JSON.stringify(e)}getColor(e){const t=Math.floor(Math.min(this.threshold,e)/this.binsize);if(void 0===this.cache[t]){const i=(ys.clamp(e,0,this.threshold)-0)/(this.threshold-0);this.cache[t]=`rgba(${this.r},${this.g},${this.b}, ${i})`}return this.cache[t]}stringify(){return this.threshold+\",\"+this.r+\",\"+this.g+\",\"+this.b}static parse(e){var t,i;return e.startsWith(\"R:\")?(t=e.substring(2).split(\":\"),(i=new RatioColorScale(Number.parseFloat(t[0]))).positiveScale=n(t[1]),i.negativeScale=n(t[2]),i):n(e);function n(e){var t,i;return t={threshold:(i=e.split(\",\"))[0],r:i[1],g:i[2],b:i[3]},new gf(t)}}}class mf{constructor(e){this.config=e,this.url=e.path||e.url}async read(e,t){const i={start:e,size:t};return Qs.loadArrayBuffer(this.url,{range:i})}}class wf{constructor(e){this.file=e}async read(e,t){const i=this.file;return void 0!==e?i.slice(e,e+t).arrayBuffer():i.arrayBuffer()}}class bf{constructor(e,t){this.file=e,this.rateLimiter=t}async read(e,t){const i=this.file,n=this.rateLimiter;return new Promise((function(r,s){n.limiter((async function(i){try{const n=await i.read(e,t);r(n)}catch(e){s(e)}}))(i)}))}}class Ff{constructor(e){this.file=e.file,this.size=e.size||64e3,this.position=0,this.bufferStart=0,this.bufferLength=0,this.buffer=void 0}async read(e,t){const i=e,n=e+t,r=this.bufferStart,s=this.bufferStart+this.bufferLength;if(t>this.size)return this.buffer=void 0,this.bufferStart=0,this.bufferLength=0,this.file.read(e,t);if(i>=r&&n<=s){const e=i-r,n=e+t;return this.buffer.slice(e,n)}if(ir){const n=r-i,s=await this.file.read(e,n),o=t-n;if(o>0){const e=this.buffer.slice(0,o);return vf(s,e)}return s}if(!(is))return this.buffer=await this.file.read(e,this.size),this.bufferStart=e,this.bufferLength=this.buffer.byteLength,this.buffer.slice(0,t);{const e=s-i,n=this.bufferLength-e,r=this.buffer.slice(n,this.bufferLength),o=t-e;if(!(o>0))return r;try{this.buffer=await this.file.read(s,this.size),this.bufferStart=s,this.bufferLength=this.buffer.byteLength;const e=this.buffer.slice(0,o);return vf(r,e)}catch(e){if(e.code&&416===e.code)return r;throw e}}}}var vf=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer};const yf=function(e,t){this.littleEndian=void 0===t||t,this.position=0,this.view=e,this.length=e.byteLength};function Af(e,t){this.block=e,this.offset=t}yf.prototype.available=function(){return this.length-this.position},yf.prototype.remLength=function(){return this.length-this.position},yf.prototype.hasNext=function(){return this.position=0;i--)t=256*t+e[i];else for(i=0;i0&&(n+=String.fromCharCode(i));return n},yf.prototype.getFixedLengthTrimmedString=function(e){var t,i,n=\"\";for(t=0;t32&&(n+=String.fromCharCode(i));return n},yf.prototype.getFloat=function(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e},yf.prototype.getDouble=function(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e},yf.prototype.skip=function(e){return this.position+=e,this.position},yf.prototype.getVPointer=function(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Af(i,t)},Af.prototype.isLessThan=function(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset},Af.prototype.print=function(){return this.block+\":\"+this.offset};class Cf{constructor(e,t){this.chr1=e,this.chr2=t}getKey(){return this.chr1.name+\"_\"+this.chr2.name+\"_\"+this.zoom.unit+\"_\"+this.zoom.binSize}getBlockNumbers(e,t,i){if(e.chr==this.chr2&&t.chr===this.chr1){const i=e;e=t,t=i}const n=this.chr1===this.chr2,r=this.zoom.binSize,s=this.blockBinCount,o=this.blockColumnCount;return i<9||!n?function(){const i=e.start/r,a=e.end/r,c=t.start/r,l=t.end/r,h=Math.floor(i/s),d=Math.floor((a-1)/s),u=Math.floor(c/s),f=Math.floor((l-1)/s),p=[];for(let e=u;e<=f;e++)for(let t=h;t<=d;t++){let i;i=n&&e0;){const e=t.getInt(),i=t.getLong(),n=t.getInt();this.blockIndex[e]={filePosition:i,size:n}}}getBlockIndexEntry(e){return this.blockIndex[e]}}class xf{constructor(e,t,i){this.chr1=e,this.chr2=t,this.bpZoomData=[],this.fragZoomData=[];for(let e of i)\"BP\"===e.zoom.unit?this.bpZoomData.push(e):this.fragZoomData.push(e)}findZoomForResolution(e,t){const i=\"FRAG\"===t?this.fragZoomData:this.bpZoomData;for(let t=1;tt){const i=e;e=t,t=i}return`${e}_${t}`}static parseMatrix(e,t){const i=new yf(new DataView(e)),n=i.getInt(),r=i.getInt(),s=t[n],o=t[r];let a=i.getInt();const c=[];for(;a-- >0;){const e=Cf.parseMatrixZoomData(s,o,i);c.push(e)}return new xf(n,r,c)}}class kf{constructor(e,t,i){this.bin1=e,this.bin2=t,this.counts=i}getKey(){return this.bin1+\"_\"+this.bin2}}class If{constructor(e=10){this.max=e,this.map=new Map}get(e){let t=this.map.get(e);return t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size===this.max&&this.map.delete(this.first()),this.map.set(e,t)}has(e){return this.map.has(e)}clear(){this.map.clear()}first(){return this.map.keys().next().value}}class Sf{constructor(e,t,i,n){this.file=e,this.filePosition=t,this.nValues=i,this.dataType=n,this.cache=void 0}async getValues(e,t){if(!this.cache||ethis.cache.end){const i=Math.max(0,e-1e3),n=Math.min(this.nValues,t+1e3),r=this.filePosition+i*this.dataType,s=n-i,o=s*this.dataType,a=await this.file.read(r,o);if(!a)return;const c=new yf(new DataView(a)),l=[];for(let e=0;e=0||t.indexOf(\"www.googleapis.com/drive\")>0?this.file=new bf(i,Bf):this.file=i}}var t}async init(){this.initialized||(await this.readHeaderAndFooter(),this.initialized=!0)}async getVersion(){if(void 0===this.version){const e=await this.file.read(0,128);if(!e)return;const t=new yf(new DataView(e));return this.magic=t.getString(),this.version=t.getInt(),this.version}return this.version}async getMetaData(){return await this.init(),this.meta}async readHeaderAndFooter(){let e=await this.file.read(0,16);if(!e||0===e.byteLength)throw Error(\"File content is empty\");let t=new yf(new DataView(e));if(this.magic=t.getString(),this.version=t.getInt(),this.version<5)throw Error(\"Unsupported hic version: \"+this.version);this.footerPosition=t.getLong(),await this.readFooter();const i=Object.values(this.masterIndex).reduce(((e,t)=>Math.min(e,t.start)),Number.MAX_VALUE)-16;e=await this.file.read(16,i),t=new yf(new DataView(e)),this.genomeId=t.getString(),this.version>=9&&(this.normVectorIndexPosition=t.getLong(),this.normVectorIndexSize=t.getLong()),this.attributes={};let n=t.getInt();for(;n-- >0;)this.attributes[t.getString()]=t.getString();this.chromosomes=[],this.chromosomeIndexMap={};let r=t.getInt(),s=0;for(;r-- >0;){const e={index:s,name:t.getString(),size:this.version<9?t.getInt():t.getLong()};\"all\"===e.name.toLowerCase()&&(this.wholeGenomeChromosome=e,this.wholeGenomeResolution=Math.round(2*e.size)),this.chromosomes.push(e),this.chromosomeIndexMap[e.name]=e.index,s++}this.bpResolutions=[];let o=t.getInt();for(;o-- >0;)this.bpResolutions.push(t.getInt());if(this.loadFragData){this.fragResolutions=[];let e=t.getInt();if(e>0)for(;e-- >0;)this.fragResolutions.push(t.getInt())}this.chrAliasTable={};for(let e of Object.keys(this.chromosomeIndexMap))e.startsWith(\"chr\")?this.chrAliasTable[e.substr(3)]=e:\"MT\"===e?this.chrAliasTable.chrM=e:this.chrAliasTable[\"chr\"+e]=e;this.meta={version:this.version,genome:this.genomeId,chromosomes:this.chromosomes,resolutions:this.bpResolutions}}async readFooter(){const e=this.version<9?8:12;let t=await this.file.read(this.footerPosition,e);if(!t)return null;let i=new yf(new DataView(t));const n=this.version<9?i.getInt():i.getLong();let r=i.getInt();const s=196*r;for(t=await this.file.read(this.footerPosition+e,Math.min(s,n)),i=new yf(new DataView(t)),this.masterIndex={};r-- >0;){const e=i.getString(),t=i.getLong(),n=i.getInt();this.masterIndex[e]={start:t,size:n}}if(this.expectedValueVectors={},this.version>5){const e=this.version<9?4:8;this.normExpectedValueVectorsPosition=this.footerPosition+e+n}return this}async printIndexStats(){let e,t=0,i=0;await await this.init();for(let n of Object.keys(this.masterIndex)){const r=this.masterIndex[n];t+=r.size,r.size>i&&(i=r.size,e=n)}console.log(`${i} ${e} ${this.config.url}`)}async getMatrix(e,t){const i=xf.getKey(e,t);if(this.matrixCache.has(i))return this.matrixCache.get(i);{const n=await this.readMatrix(e,t);return this.matrixCache.set(i,n),n}}async readMatrix(e,t){if(await this.init(),e>t){const i=e;e=t,t=i}const i=xf.getKey(e,t),n=this.masterIndex[i];if(!n)return;const r=await this.file.read(n.start,n.size);return r?xf.parseMatrix(r,this.chromosomes):void 0}async getContactRecords(e,t,i,n,r,s=!1){await this.init();const o=this.chromosomeIndexMap[this.getFileChrName(t.chr)],a=this.chromosomeIndexMap[this.getFileChrName(i.chr)];if(o>a||o===a&&t.start>=i.end){const e=t;t=i,i=e}const c=await this.getBlocks(t,i,n,r);if(!c||0===c.length)return[];const l=[],h=t.start/r,d=t.end/r,u=i.start/r,f=i.end/r,p=Math.floor(h),g=Math.ceil(d),m=Math.floor(u),w=Math.ceil(f);for(let o of c)if(o){let a,c,b=e&&\"NONE\"!==e;const F=this.getFileChrName(t.chr),v=this.getFileChrName(i.chr);if(b){const t=await this.getNormalizationVector(e,F,n,r),i=F===v?t:await this.getNormalizationVector(e,v,n,r);t&&i?(a=await t.getValues(p,g),c=await i.getValues(m,w)):b=!1}for(let e of o.records)if(s||e.bin1>=h&&e.bin1=u&&e.bin210&&(this.percentile95=Lf(o.records,95))}return l}async getBlocks(e,t,i,n){const r=(e,t)=>`${t.getKey()}_${e}`;await this.init();const s=this.getFileChrName(e.chr),o=this.getFileChrName(t.chr),a=this.chromosomeIndexMap[s],c=this.chromosomeIndexMap[o];if(void 0===a)return console.log(\"No chromosome named: \"+e.chr),[];if(void 0===c)return console.log(\"No chromosome named: \"+t.chr),[];const l=await this.getMatrix(a,c);if(!l)return console.log(\"No matrix for \"+e.chr+\"-\"+t.chr),[];const h=l.getZoomData(n,i);if(!h){let i=`No data avalailble for resolution: ${n} for map ${e.chr}-${t.chr}`;throw new Error(i)}const d=h.getBlockNumbers(e,t,this.version),u=[],f=[];for(let e of d){const t=r(e,h);this.blockCache.has(n,t)?u.push(this.blockCache.get(n,t)):f.push(e)}const p=f.map((e=>this.readBlock(e,h))),g=await Promise.all(p);for(let e of g)e&&this.blockCache.set(n,r(e.blockNumber,h),e);return u.concat(g)}async readBlock(e,t){const i=await t.blockIndex.getBlockIndexEntry(e);if(i){let n=await this.file.read(i.filePosition,i.size);if(!n)return;n=new ls(new Uint8Array(n)).buffer;const r=new yf(new DataView(n)),s=r.getInt(),o=[];if(this.version<7)for(let e=0;e0;)this.parseNormVectorEntry(i);return this.normVectorIndex}async readNormExpectedValuesAndNormVectorIndex(){if(await this.init(),void 0===this.normExpectedValueVectorsPosition)return;const e=await this.skipExpectedValues(this.normExpectedValueVectorsPosition);let t=4,i=await this.file.read(e,4);if(0===i.byteLength)return;const n=new yf(new DataView(i)).getInt(),r={start:e+t,size:30*n};i=await this.file.read(r.start,r.size),this.normalizedExpectedValueVectors={},this.normVectorIndex={},await async function i(n,r){const s=new yf(new DataView(r));for(;n-- >0;){if(s.available()<100){n++,t+=s.position;const r=Math.max(1e3,30*n),o={start:e+t,size:r},a=await this.file.read(o.start,o.size);return i.call(this,n,a)}this.parseNormVectorEntry(s)}t+=s.position}.call(this,n,i),this.config.nvi=e.toString()+\",\"+t}async skipExpectedValues(e){const t=this.version,i=new Ff({file:this.file,size:256e3}),n={start:e,size:4},r=await i.read(n.start,n.size),s=new yf(new DataView(r)).getInt();return 0===s?e+4:async function e(n,r){let s={start:n,size:500},o=0,a=n,c=await i.read(s.start,s.size),l=new yf(new DataView(c));l.getString(),l.getString(),l.getInt();const h=t<9?l.getInt():l.getLong();o+=l.position+h*(t<9?8:4),s={start:n+o,size:4},c=await i.read(s.start,s.size),l=new yf(new DataView(c));const d=l.getInt();return o+=4+d*(4+(t<9?8:4)),r--,0===r?a+o:e(a+o,r)}(e+4,s)}getZoomIndexForBinSize(e,t){let i;if(\"BP\"===(t=t||\"BP\"))i=this.bpResolutions;else{if(\"FRAG\"!==t)throw new Error(\"Invalid unit: \"+t);i=this.fragResolutions}for(let t=0;te.counts));i.sort((function(e,t){return e-t}));return i[Math.floor(t/100*e.length)]}class zf{constructor(e,t){this.config=e,this.genome=t,this.hicFile=e._hicFile?e._hicFile:new Mf(e),e._hicFile=void 0}async getHeader(){return await this.hicFile.init(),this.hicFile}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){this.hicFile.initialized||await this.hicFile.init();const s=this.hicFile.bpResolutions,o=s[s.length-1];return(await this.hicFile.getContactRecords(void 0,{chr:e,start:t,end:i},{chr:\"celltype\",start:0,end:1e8},\"BP\",o)).map((t=>{const i=t.bin1*o;return{chr:e,start:i,end:i+o,value:t.counts,sample:t.bin2.toString()}}))}supportsWholeGenome(){return!1}}function Hf(e,t){const i=new Set(e.attributeNames),n=t[0];if(void 0===e.getAttributes(n))return!1;{const t=Object.keys(e.getAttributes(n));for(const e of t)if(!1===i.has(e))return!1}return!0}class Pf extends Hl{#y=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),this.type=e.type||\"seg\",\"maf\"===this.type&&(this.type=\"mut\"),this.isLog=e.isLog,this.displayMode=e.displayMode||\"EXPANDED\",this.height=e.height||300,this.maxHeight=e.maxHeight||500,this.squishedRowHeight=e.sampleSquishHeight||e.squishedRowHeight||2,this.expandedRowHeight=e.sampleExpandHeight||e.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,this.sampleKeys=[],e.samples){for(let t of e.samples)this.sampleKeys.push(t);this.explicitSamples=!0}if(e.color)this.color=e.color;else if(e.colorTable)this.colorTable=new ao(e.colorTable);else switch(this.type){case\"mut\":this.colorTable=new ao(qf);break;case\"shoebox\":e.colorScale&&(this.sbColorScale=gf.parse(e.colorScale));break;default:this.posColorScale=new uf(e.posColorScale||Of),this.negColorScale=new uf(e.negColorScale||Uf)}const t=Object.assign({},this.config);t.maxWGCount=t.maxWGCount||Number.MAX_SAFE_INTEGER,\"shoebox\"===this.type?(this.featureSource=new zf(t,this.browser.genome),this.height=e.height||500,this.maxHeight=e.maxHeight||800,this.isLog=!1,this.squishedRowHeight=e.squishedRowHeight||1,this.displayMode=e.displayMode||\"SQUISHED\",this.visibilityWindow=void 0===e.visibilityWindow?1e6:e.visibilityWindow):this.featureSource=Ad(t,this.browser.genome),this.initialSort=e.sort}async postInit(){\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const e=[];if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const n of this.browser.sampleInfo.attributeNames){if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[n]}))){const r=Bt(\"
\");function s(){const e=this.#y.get(n)||1;this.sortByAttribute(n,e),this.#y.set(n,-1*e),this.config.sort={option:\"ATTRIBUTE\",attribute:n,direction:1===e?\"ASC\":\"DESC\"}}r.html(`  ${n.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:r,click:s})}}}const t={SQUISHED:\"Squish\",EXPANDED:\"Expand\",FILL:\"Fill\"};if(\"shoebox\"===this.type&&this.sbColorScale){function o(e){this.browser.inputDialog.present({label:\"Color Scale Threshold\",value:this.sbColorScale.threshold,callback:()=>{const e=Number(this.browser.inputDialog.value,10);e&&(this.sbColorScale.setThreshold(e),this.trackView.repaintViews())}},e)}e.push(\"
\"),e.push({object:Bt(\"
Set color scale threshold
\"),dialog:o})}e.push(\"
\"),e.push(\"DisplayMode:\");const i=\"seg\"===this.type||\"shoebox\"===this.type?[\"SQUISHED\",\"EXPANDED\",\"FILL\"]:[\"SQUISHED\",\"EXPANDED\"];for(let a of i){const c=Dl(t[a],a===this.displayMode);e.push({object:Bt(c),click:function(){this.displayMode=a,this.config.displayMode=a,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return e}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.sampleHeight,yOffset:0}}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:t,end:i});if(this.updateSampleKeys(n),this.initialSort){const e=this.initialSort;if(void 0===e.option||\"VALUE\"===e.option.toUpperCase())this.sortByValue(e,n);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"DESC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return n}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){if(this.checkForLog(r),\"shoebox\"===this.type&&!this.sbColorScale){const e=this.featureSource.hicFile.percentile95||2e3;this.sbColorScale=new gf({threshold:e,r:0,g:0,b:255})}const a={};let c;switch(this.sampleKeys.forEach((function(e,t){a[e]=t})),this.displayMode){case\"FILL\":this.sampleHeight=n/this.sampleKeys.length,c=0;break;case\"SQUISHED\":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let e of r)e.pixelRect=void 0;const h=t+n,d=o+i*s+1,u=s;this.sampleYStart=void 0;for(let i of r){if(i.endd)continue;const n=i.sampleKey||i.sample;i.row=a[n];const r=i.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=r);if(r+lh)continue;const s=Math.max(i.start,o);let f=Math.round((s-o)/u);const p=Math.min(i.end,d),g=Math.round((p-o)/u);let m,w,b=Math.max(1,g-f);if(this.color?m=\"function\"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),\"mut\"===this.type)w=l-2*c,b<3&&(b=3,f-=1);else if(\"shoebox\"===this.type){m=this.sbColorScale.getColor(i.value);let e=l;if(l<.25){const t=.1+2*Math.abs(t.value);e=Math.min(1,t*l)}w=e-2*c}else{let e=i.value;this.isLog||(e=ys.log2(e/2)),m=e<-.1?this.negColorScale.getColor(e):e>.1?this.posColorScale.getColor(e):\"white\";let t=l;if(l<.25){const i=.1+2*Math.abs(e);t=Math.min(1,i*l)}w=t-2*c}i.pixelRect={x:f,y:r,w:b,h:w},e.fillStyle=m,e.fillRect(f,r,b,w)}}}checkForLog(e){if(void 0===this.isLog){this.isLog=!1;for(let t of e)if(t.value<0)return void(this.isLog=!0)}}computePixelHeight(e){if(!e)return 0;const t=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(e),this.sampleKeys.length*t}async sortByValue(e,t){const i=e.chr;let n,r;if(e.position?(n=e.position-1,r=n+1):(n=e.start,r=e.end),t||(t=await this.featureSource.getFeatures({chr:i,start:n,end:r})),!t)return;this.updateSampleKeys(t);const s={},o=\"ASC\"===e.direction?1:-1,a=()=>{const e=r-n+1;for(let i of t){if(i.endr)break;const t=Math.max(n,i.start),o=(Math.min(r,i.end)-t)/e,a=i.sampleKey||i.sample,c=s[a]||0;s[a]=c+o*i.value}this.sampleKeys.sort((function(e,t){let i=s[e],n=s[t];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))},c=()=>{for(let e of t){if(e.endr)break;const t=e.sampleKey||e.sample;(!s.hasOwnProperty(t)||e.value.localeCompare(s[t])>0)&&(s[t]=e.value)}this.sampleKeys.sort((function(e,t){let i=s[e]||\"\",n=s[t]||\"\";return o*i.localeCompare(n)}))};\"mut\"===this.type?c():a(),this.trackView.repaintViews()}sortByAttribute(e,t){this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(e){const t=e.genomicLocation,i=t=>{const i=e.viewport.cachedFeatures;this.sortByValue(t,i)},n=e.referenceFrame.toBP(2.5);return[\"DESC\",\"ASC\"].map((r=>{const s=\"DESC\"===r?\"descending\":\"ascending\";return{label:\"seg\"===this.type||\"shoebox\"===this.type?`Sort by value (${s})`:`Sort by type (${s})`,click:()=>{const s={option:\"VALUE\",direction:r,chr:e.referenceFrame.chr,start:Math.floor(t-n),end:Math.floor(t+n)};i(s),this.config.sort=s}}}))}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(e){if(this.explicitSamples)return;const t=new Set(this.sampleKeys);for(let i of e){const e=i.sampleKey||i.sample;t.has(e)||(this.sampleKeys.push(e),t.add(e))}}}const Of={low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0},Uf={low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255},qf={indel:\"rgb(0,200,0)\",\"targeted region\":\"rgb(236,155,43)\",truncating:\"rgb(\\t150,0,0)\",\"non-coding transcript\":\"rgb(0,0,150)\",synonymous:\"rgb(109,165,95)\",silent:\"rgb(109,135,80)\",missense_mutation:\"rgb(72,130,187)\",missense:\"rgb(72,130,187)\",\"splice site\":\"rgb(143,83,155)\",splice_region:\"rgb(143,83,155)\",nonsense:\"rgb(216, 57,81)\",nonsense_mutation:\"rgb(216, 57,81)\",frame_shift_del:\"rgb(226,135,65)\",frame_shift_ins:\"rgb(226,135,65)\",in_frame_del:\"rgb(247,235,94)\",in_frame_ins:\"rgb(247,235,94)\",\"*other*\":\"rgb(159,91,50)\"};class Qf{constructor(e){this.paired=!0,this.firstAlignment=e,this.chr=e.chr,this.readName=e.readName,e.startt.start?this.connectingEnd=e.start:this.connectingStart=e.start+e.lengthOnRef,this.start=Math.min(t.start,e.start),this.end=Math.max(t.start+t.lengthOnRef,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(t.scStart,e.scStart);const i=Math.max(t.scStart+t.scLengthOnRef,e.scStart+e.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}alignmentContaining(e,t){return this.firstAlignment.containsLocation(e,t)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(e,t)?this.secondAlignment:void 0}popupData(e){let t=this.firstAlignment.popupData(e);return this.secondAlignment&&(t.push(\"-------------------------------\"),t=t.concat(this.secondAlignment.popupData(e))),t}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}get firstOfPairStrand(){return this.firstAlignment.firstOfPairStrand}get pairOrientation(){return this.firstAlignment.pairOrientation}hasTag(e){return this.firstAlignment.hasTag(e)||this.secondAlignment&&this.secondAlignment.hasTag(e)}getGroupValue({option:e,tag:t}){switch(e){case\"strand\":return this.isNegativeStrand()?\"-\":\"+\";case\"FIRST_IN_PAIR_STRAND\":return this.isPaired()?this.isFirstOfPair()?this.isNegativeStrand()?\"-\":\"+\":this.isSecondOfPair()?this.isNegativeStrand()?\"+\":\"-\":void 0:void 0;case\"START\":return this.start;case\"INSERT_SIZE\":return this.fragmentLength;case\"MATE_CHR\":return this.mate?this.mate.chr:void 0;case\"MQ\":return this.mq;case\"ALIGNED_READ_LENGTH\":return this.lengthOnRef;case\"TAG\":return this.tags()[t];case\"PHASE\":return this.tags().HP;case\"READ_ORDER\":return this.isPaired()&&this.isFirstOfPair()?\"FIRST\":this.isPaired()&&this.isSecondOfPair()?\"SECOND\":\"\";default:return}}}class Vf{static instances=new Map;static getKey(e,t,i){const n=\"\"+e+t+i;return Vf.instances.has(n)||Vf.instances.set(n,new Vf(e,t,i)),Vf.instances.get(n)}constructor(e,t,i){this.base=e,this.strand=t,this.modification=i,this.canonicalBase=\"+\"===this.strand?this.base:oc(this.base)}getCanonicalBase(){}toString(){return\"\"+this.base+this.strand+this.modification}static compare(e,t){const i=e.modification,n=t.modification;return i===n?e.strand.charAt(0)-t.strand.charAt(0):jf.has(i)&jf.has(n)?jf.get(i)-jf.get(n):jf.has(i)?1:jf.has(n)?-1:i>n?1:-1}}const jf=new Map([\"NONE_C\",\"NONE_T\",\"NONE_G\",\"NONE_A\",\"m\",\"h\",\"f\",\"c\",\"C\",\"g\",\"e\",\"b\",\"T\",\"U\",\"a\",\"A\",\"o\",\"G\",\"n\",\"N\"].map(((e,t)=>[e,t])));class Wf{constructor(e,t,i,n){this.base=e,this.modification=i,this.strand=t,this.likelihoods=n,this.canonicalBase=\"+\"==this.strand?this.base:oc(this.base),this.key=Vf.getKey(e,t,i)}containsPosition(e){return this.likelihoods.has(e)}is5mC(){return this.modification.equals(\"m\")&&(\"C\"===this.base&&\"+\"===this.strand||\"G\"===this.base&&\"-\"===this.strand)}fullName(){return Gf.get(this.modification)||this.modification}}const Gf=new Map;Gf.set(\"m\",\"5mC\"),Gf.set(\"h\",\"5hmC\"),Gf.set(\"f\",\"5fC\"),Gf.set(\"c\",\"5caC\"),Gf.set(\"g\",\"5hmU\"),Gf.set(\"e\",\"5fU\"),Gf.set(\"b\",\"5caU\"),Gf.set(\"a\",\"6mA\"),Gf.set(\"o\",\"8xoG\"),Gf.set(\"n\",\"Xao\"),Gf.set(\"C\",\"Unknown C\"),Gf.set(\"T\",\"Unknown T\"),Gf.set(\"A\",\"Unknown A\"),Gf.set(\"G\",\"Unknown G\"),Gf.set(\"N\",\"Unknown\");const $f=new Map([[\"m\",\"5mC\"],[\"h\",\"5hmC\"],[\"f\",\"5fC\"],[\"c\",\"5caC\"],[\"g\",\"5hmU\"],[\"e\",\"5fU\"],[\"b\",\"5caU\"],[\"a\",\"6mA\"],[\"o\",\"8xoG\"],[\"n\",\"Xao\"],[\"C\",\"Unknown C\"],[\"T\",\"Unknown T\"],[\"A\",\"Unknown A\"],[\"G\",\"Unknown G\"],[\"N\",\"Unknown\"]]);function Kf(e){return $f.has(e)?$f.get(e):\"Uknown\"}function Yf(e){if(!e)return!1;const t=e.length;if(0==t)return!1;for(let i=0;i\"9\")return!1}return!0}function Xf(e){return e<0?e+256:e}class Zf{allModifications=new Set;simplexModifications=new Set;maxLikelihoods=new Map;nomodLikelihoods=new Map;lastThreshold;incrementCounts(e){if(!e.blocks)return;const t=e.getBaseModificationSets();if(t)for(let i of e.blocks)if(\"S\"!==i.type)for(let e=0;eo&&(s=e.canonicalBase,o=c,n=t)}}if(0!=s){const t=i.start+e,r=Vf.getKey(s,\"+\",\"NONE_\"+s);this.allModifications.add(r);const c=(e,t,i,n)=>{let r=n.get(i);r||(r=new Map,n.set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push(t)};c(t,o,n,this.maxLikelihoods),a>o?c(t,a,r,this.nomodLikelihoods):c(t,o,n,this.nomodLikelihoods)}}}getCount(e,t,i,n){this.lastThreshold=i;const r=255*i,s=n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t);if(!s)return 0;const o=s.get(e);if(o){let e=0;for(let t of o){Xf(t)>=r&&e++}return e}return 0}getLikelihoodSum(e,t,i,n){this.lastThreshold=i;const r=255*i,s=(n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t)).get(e);if(s){let e=0;for(let t of s){const i=Xf(t);i>=r&&(e+=i)}return e}return 0}popupData(e,t){const i=[];i.push(\"Modifications with likelihood > \"+100*this.lastThreshold+\"%\");for(let n of this.maxLikelihoods.keys()){if(this.maxLikelihoods.get(n).has(e)){let r=\"basemod2\"===t;const s=this.getCount(e,n,this.lastThreshold,r);if(s>0){const t=this.getLikelihoodSum(e,n,this.lastThreshold,r)/s*.3921568,o=Kf(n.modification);i.push(o+\" (\"+n.base+n.strand+\"): \"+s+\" @ average likelihood \"+Math.round(t)+\"%\")}}}return i}computeSimplex(){const e=new Set(Array.from(this.allModifications).filter((e=>\"-\"===e.strand)).map((e=>e.modification)));for(let t of this.allModifications)\"+\"!==t.strand||e.has(t.modification)||(this.simplexModifications.add(t.modification),this.simplexModifications.add(\"NONE_\"+t.getCanonicalBase()))}}class Jf{constructor(){this.alignments=[],this.score=void 0}findAlignment(e,t=!1){const i=(e,i)=>i>=e.start&&i=s.start&&e0?h-=e:0===h&&(h=1)}return h}(s,r,e);case\"strand\":return s.strand?1:-1;case\"START\":return s.start;case\"TAG\":return s.tags()[i];case\"READ_NAME\":return s.readName;case\"INSERT_SIZE\":return-Math.abs(s.fragmentLength);case\"GAP_SIZE\":return-s.gapSizeAt(e);case\"MATE_CHR\":return s.mate?s.mate.chr:Number.MAX_VALUE;case\"MQ\":return void 0===s.mq?Number.MAX_VALUE:-s.mq;case\"ALIGNED_READ_LENGTH\":return-s.lengthOnRef;default:return Number.MAX_VALUE}}}var ep={fr:{F1R2:\"LR\",F2R1:\"LR\",F1F2:\"LL\",F2F1:\"LL\",R1R2:\"RR\",R2R1:\"RR\",R1F2:\"RL\",R2F1:\"RL\"},rf:{R1F2:\"LR\",R2F1:\"LR\",R1R2:\"LL\",R2R1:\"LL\",F1F2:\"RR\",F2F1:\"RR\",F1R2:\"RL\",F2R1:\"RL\"},ff:{F2F1:\"LR\",R1R2:\"LR\",F2R1:\"LL\",R1F2:\"LL\",R2F1:\"RR\",F1R2:\"RR\",R2R1:\"RL\",F1F2:\"RL\"}};class tp{#A=[];baseModificationKeys=new Set;constructor(e,t,i,{samplingWindowSize:n,samplingDepth:r,alleleFreqThreshold:s,colorBy:o}){this.alleleFreqThreshold=void 0===s?.2:s,this.samplingWindowSize=n||100,this.samplingDepth=r||1e3,this.chr=e,this.start=Math.floor(t),this.end=Math.ceil(i),this.length=i-t,this.coverageMap=new np(e,t,i,this.alleleFreqThreshold),this.downsampledIntervals=[],o&&o.startsWith(\"basemod\")&&(this.baseModCounts=new Zf),this.alignments=[],this.pairsCache=new Map,this.downsampledReads=new Set,this.currentBucket=new ip(this.start,this.start+this.samplingWindowSize,this),this.hasPairs=!1}pack({viewAsPairs:e,showSoftClips:t,expectedPairOrientation:i,groupBy:n,displayMode:r}){let s=this.allAlignments();s=e?function(e){const t=new Map,i=e.map((e=>{if(ap(e)){let i=t.get(e.readName);return i?(i.setSecondAlignment(e),t.delete(e.readName),i):(i=new Qf(e),t.set(e.readName,i),i)}return e}));return i}(s):function(e){return e.flatMap((e=>e instanceof Qf?[e.firstAlignment,e.secondAlignment].filter(Boolean):[e]))}(s),this.packAlignmentRows(s,t,i,n,r),this.alignments&&delete this.alignments}packAlignmentRows(e,t,i,n,r){this.#A=[];const s=(e,i)=>{e.sort((function(e,i){return t?e.scStart-i.scStart:e.start-i.start}));const n=new op(i);let r,s=0,o=0;const a=new Set,c=()=>{r=new Jf,n.push(r),s=0,o=0,a.clear()};for(c();e.length>0;)if(o>=0&&o(t?e.scStart:e.start)>s),o)}else e=e.filter((e=>!a.has(e))),c();return n},o=(e,t)=>{e.sort((function(e,t){return e.start-t.start}));const i=new op(t),{start:n,end:r}=this.viewport.genomicRange();for(let t of e)if(t.endr)this.#A.push(t);else{const e=new Jf;e.alignments.push(t),i.push(e)}return i};if(!e||0===e.length)return new Map;{const t=new Map;if(n)for(let r of e){const e=lp(r,n,i)||\"\";t.has(e)||t.set(e,[]),t.get(e).push(r)}else t.set(\"\",e);const a=new Map,c=Array.from(t.keys()).sort(function(e,t){switch(e){case\"pairOrientation\":return function(e){const t=[\"LL\",\"RR\",\"RL\",\"LR\",\"\"];return(e,i)=>t.indexOf(e)-t.indexOf(i)}();case\"strand\":case\"firstOfPairStrand\":return up;default:return e&&e.startsWith(\"base:\")?dp:fp}}(n));for(let e of c){const i=t.get(e),n=\"FULL\"===r?o(i,e):s(i,e);a.set(e,n)}this.packedGroups=a}}push(e){this.hasPairs=this.hasPairs||e.isPaired(),this.coverageMap.incCounts(e);const t=e.getBaseModificationSets();if(t)for(let e of t)this.baseModificationKeys.add(e.key);this.baseModCounts&&this.baseModCounts.incrementCounts(e),this.downsampledReads.has(e.readName)?this.currentBucket.downsampledCount++:(e.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new ip(e.start,e.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(e))}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.hasAlignments=this.alignments.length>0,this.alignments.sort((function(e,t){return e.start-t.start})),this.baseModCounts&&this.baseModCounts.computeSimplex(),delete this.currentBucket,delete this.pairsCache,delete this.downsampledReads}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new sp(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount))}allAlignments(){if(this.alignments)return this.alignments;if(this.packedGroups){const e=Array.from(this.packedGroups.values()).flatMap((e=>e.rows.flatMap((e=>e.alignments))));if(this.#A&&this.#A.length>0)for(let t of this.#A)e.push(t);return e}return[]}getMax(e,t){return this.coverageMap.getMax(e,t)}sortRows(e){if(this.packedGroups)for(let t of this.packedGroups.values())t.sortRows(e,this)}}class ip{constructor(e,t,{samplingDepth:i,downsampledReads:n,pairsCache:r}){this.start=e,this.end=t,this.alignments=[],this.downsampledCount=0,this.samplingDepth=i,this.downsampledReads=n,this.pairsCache=r,this.hasPairs=!1}addAlignment(e){this.hasPairs=this.hasPairs||e.isPaired();const t=this.hasPairs?Math.ceil(this.samplingDepth/2):this.samplingDepth;if(ap(e)){const t=this.pairsCache.get(e.readName);if(t)return t.setSecondAlignment(e),void this.pairsCache.delete(e.readName)}if(this.alignments.lengtht)break;const s=this.coverage[r];n>=e&&s&&(i=Math.max(i,s.total))}return i}incCounts(e){var t=this;if(void 0===e.blocks?i(e):e.blocks.forEach((function(e){i(e)})),e.gaps)for(let i of e.gaps)if(\"D\"===i.type){const e=i.start-t.bpStart;for(let n=e;n=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.posA;case\"C\":case\"c\":return n.posC;case\"T\":case\"t\":return n.posT;case\"G\":case\"g\":return n.posG;case\"N\":case\"n\":return n.posN;default:return 0}}getNegCount(e,t){const i=e-this.bpStart;if(i<0||i>=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.negA;case\"C\":case\"c\":return n.negC;case\"T\":case\"t\":return n.negT;case\"G\":case\"g\":return n.negG;case\"N\":case\"n\":return n.negN;default:return 0}}getCount(e,t){return this.getPosCount(e,t)+this.getNegCount(e,t)}getTotalCount(e){const t=e-this.bpStart;return t>=0&&t=t}}class sp{constructor(e,t,i){this.start=e,this.end=t,this.counts=i}popupData(e){return[{name:\"start\",value:Math.floor(this.start+1)},{name:\"end\",value:this.end},{name:\"# downsampled:\",value:this.counts}]}}class op{pixelTop=0;pixelBottom=0;rows=[];constructor(e){this.name=this.name}push(e){this.rows.push(e)}get length(){return this.rows.length}sortRows(e,t){const i=[],n=[];for(let t of this.rows){void 0!==t.findAlignment(e.position,e.sortAsPairs)?i.push(t):n.push(t)}i.sort(((i,n)=>{const r=e.direction,s=i.getSortValue(e,t),o=n.getSortValue(e,t);if(void 0===o&&void 0!==o)return 1;if(void 0!==s&&void 0===o)return-1;const a=s>o?1:s>1);t(e[i])?r=i:n=i}return r}function lp(e,t,i){let n,r,s;if(t.startsWith(\"tag:\"))n=t.substring(4),t=\"tag\";else if(t.startsWith(\"base:\")){const e=t.split(\":\");3===e.length&&(t=\"base\",r=e[1],s=Number.parseInt(e[2].replaceAll(\",\",\"\"))-1)}switch(t){case\"strand\":return e.strand?\"+\":\"-\";case\"firstOfPairStrand\":const t=e.firstOfPairStrand;return void 0===t?\"\":t?\"+\":\"-\";case\"mateChr\":return e.mate&&e.isMateMapped()?e.mate.chr:\"\";case\"pairOrientation\":return ep[i][e.pairOrientation]||\"\";case\"chimeric\":return e.tags().SA?\"chimeric\":\"\";case\"supplementary\":return e.isSupplementary?\"supplementary\":\"\";case\"readOrder\":return e.isPaired()&&e.isFirstOfPair()?\"first\":e.isPaired()&&e.isSecondOfPair()?\"second\":\"\";case\"phase\":return e.tags().HP||\"\";case\"tag\":return e.tags()[n]||\"\";case\"base\":if(e.chr===r&&e.start<=s&&e.end>s){const t=e.readBaseAt(s);return t||\"GAP\"}return\"\";default:return}}const hp=new Map([[\"A\",1],[\"T\",2],[\"C\",3],[\"G\",4],[\"N\",5],[\"GAP\",5],[\"\",7]]);function dp(e,t){return hp.has(e)&&hp.has(t)?hp.get(e)-hp.get(t):e.localeCompare(t,void 0,{sensitivity:\"base\"})}function up(e,t){return e===t?0:e&&t?-e.localeCompare(t):e?1:-1}function fp(e,t){if(e||t){if(e){if(t){if(e===t)return 0;if(Va(e)&&(Va(t),1))return Number.parseFloat(e)-Number.parseFloat(t);{let i=e.toString(),n=t.toString();return i.localeCompare(n,void 0,{sensitivity:\"base\"})}}return-1}return 1}return 0}class pp{constructor(e){const t=e.split(\",\");this.chr=t[0],this.start=parseInt(t[1]),this.strand=t[2].charAt(0),this.mapQ=parseInt(t[4]),this.numMismatches=parseInt(t[5]),this.lenOnRef=function(e){let t=0,i=\"\";for(let n=0;n47&&r<58)i+=e.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:t+=parseInt(i.toString())}i=\"\"}}return t}(t[3])}printString(){return this.chr+\":\"+Rt(this.start)+\"-\"+Rt(this.start+this.lenOnRef)+\" (\"+this.strand+\") = \"+Rt(this.lenOnRef)+\"bp @MAPQ: \"+this.mapQ+\" NM: \"+this.numMismatches}}function gp(e){return e.split(\";\").filter((e=>e.length>0)).map((e=>new pp(e)))}const mp={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class wp{constructor(){this.hidden=!1}isMapped(){return!(4&this.flags)}isPaired(){return!!(1&this.flags)}isProperPair(){return!!(2&this.flags)}isFirstOfPair(){return!!(64&this.flags)}isSecondOfPair(){return!!(128&this.flags)}isSecondary(){return!!(256&this.flags)}isSupplementary(){return!!(2048&this.flags)}isFailsVendorQualityCheck(){return!!(512&this.flags)}isDuplicate(){return!!(1024&this.flags)}isMateMapped(){return!(8&this.flags)}isNegativeStrand(){return!!(16&this.flags)}isMateNegativeStrand(){return!!(32&this.flags)}hasTag(e){const t=this.tagDict||function(e){let t=0;const i=e.length,n={};for(;t=i&&e<=i+n}popupData(e){const t=[];if(e=Math.floor(e),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(e===i||e===i-1)return t.push({name:\"Insertion\",value:n.substr(r.seqOffset,r.len)}),t.push({name:\"Location\",value:i}),t}}t.push({name:\"Read Name\",value:this.readName}),t.push(\"
\"),t.push({name:\"Alignment Start\",value:Rt(1+this.start),borderTop:!0}),t.push({name:\"Read Strand\",value:!0===this.strand?\"(+)\":\"(-)\",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const e=25;n=`${n.substring(0,e-2)} ... ${n.substring(n.length-e+2)}`}t.push({name:\"Cigar\",value:n}),t.push({name:\"Mapping Quality\",value:this.mq}),t.push({name:\"Secondary\",value:a(this.isSecondary())}),t.push({name:\"Supplementary\",value:a(this.isSupplementary())}),t.push({name:\"Duplicate\",value:a(this.isDuplicate())}),t.push({name:\"Failed QC\",value:a(this.isFailsVendorQualityCheck())}),this.isPaired()&&(t.push(\"
\"),t.push({name:\"First in Pair\",value:!this.isSecondOfPair(),borderTop:!0}),t.push({name:\"Mate is Mapped\",value:a(this.isMateMapped())}),this.pairOrientation&&t.push({name:\"Pair Orientation\",value:this.pairOrientation}),this.isMateMapped()&&(t.push({name:\"Mate Chromosome\",value:this.mate.chr}),t.push({name:\"Mate Start\",value:this.mate.position+1}),t.push({name:\"Mate Strand\",value:!0===this.mate.strand?\"(+)\":\"(-)\"}),t.push({name:\"Insert Size\",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty(\"SA\")){t.push(\"
\"),t.push({name:\"Supplementary Alignments\",value:\"\"});const e=gp(r.SA);if(e){t.push(\"
    \");for(let i of e)t.push(`
  • ${i.printString()}
  • `);t.push(\"
\")}}const s=new Set([\"SA\",\"MD\"]);t.push(\"
\");for(let e in r)s.has(e)||t.push({name:e,value:r[e]});t.push({name:\"Hidden Tags\",value:\"SA, MD\"}),t.push(\"
\"),t.push({name:\"Genomic Location: \",value:Rt(1+e)}),t.push({name:\"Read Base:\",value:this.readBaseAt(e)}),t.push({name:\"Base Quality:\",value:this.readBaseQualityAt(e)});const o=this.getBaseModificationSets();if(o){const i=this.positionToReadIndex(e);if(void 0!==i){let e=!1;for(let n of o)if(n.containsPosition(i)){e||(t.push(\"
\"),t.push(\"Base modifications:\"),e=!0);const r=Math.round(100/255*Xf(n.likelihoods.get(i)));t.push(`${n.fullName()} @ likelihood = ${r}%`)}}}return t;function a(e){return e?\"Yes\":\"No\"}}readBaseAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.seq)return\"*\";{const i=t.seqIndexAt(e);return this.seq[i]}}}readBaseQualityAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.qual)return 30;{const i=t.seqIndexAt(e);return i>=0&&this.qual&&i=t.start&&e1)if(Yf(e))h.push(e);else for(let t=0;t=n.start&&t>1)+n;a+4=t)return!1;if(\"B\"!==String.fromCharCode(e[a+2])||\"I\"!==String.fromCharCode(e[a+3]))return!1;var l=Dp(e,a+4),h=a+8;if(h+4*l>t)return!1;var d=\"\",u=0;s.length=0,a=h;for(var f=0;f>4,m=Ep[15&p];\"M\"!==m&&\"EQ\"!==m&&\"X\"!==m&&\"D\"!==m&&\"N\"!==m&&\"=\"!==m||(u+=g),d=d+g+m,s.push({len:g,ltr:m})}return r.cigar=d,r.lengthOnRef=u,!0},decodeBamRecords:function(e,t,i,n,r,s,o,a){for(;te.length)return;if(p<0){t=u;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p>8,b=255&m,F=Dp(e,t+16),v=(4294901760&F)>>16,y=65535&F,A=Dp(e,t+20),C=Dp(e,t+24),_=Dp(e,t+28),x=Dp(e,t+32);let k=[];for(let i=0;i>4,h=Ep[15&c];\"M\"!==h&&\"EQ\"!==h&&\"X\"!==h&&\"D\"!==h&&\"N\"!==h&&\"=\"!==h||(I+=l),S=S+l+h,E+=4,B={len:l,ltr:h},N.push(B)}if(f.chr=n[p],f.start=g,f.flags=v,f.strand=!(16&v),f.readName=k,f.cigar=S,f.lengthOnRef=I,f.fragmentLength=x,f.mq=w,Mp.bam_tag2cigar(e,u,E,A,f,N),f.end=f.start+f.lengthOnRef,f.end>1;for(let t=0;t>4]),M.push(Sp[15&d])}M=M.slice(0,A).join(\"\"),E+=R;const D=[];for(let t=0;t=0&&(f.mate={chr:n[C],position:_,strand:!(32&v)}),f.seq=M,f.qual=D;const T=new Uint8Array(e.buffer.slice(E,u));f.tagDict=zp(T),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Rp(f,N),i.push(f)),t=u}},decodeSamRecords:function(e,t,i,n,r,s){var o,a,c,l,h,d,u,f,p,g;for(l=(o=Dt(e)).length,!1,a=0;ar)break;if(f=0,(g=Tp(p.cigar)).forEach((function(e){var t=e.len,i=e.ltr;\"M\"!==i&&\"EQ\"!==i&&\"X\"!==i&&\"D\"!==i&&\"N\"!==i&&\"=\"!==i||(f+=t)})),p.lengthOnRef=f,!(p.start+fBp&&(console.log(\"Warning: attempt to set sampling depth > maximum value of \"+Bp),e.samplingDepth=Bp)},setPairOrientation:function(e){if(e.isMapped()&&e.mate&&e.isMateMapped()&&e.mate.chr===e.chr){var t=e.strand?\"F\":\"R\",i=e.mate,n=i.strand?\"F\":\"R\",r=\" \",s=\" \";e.isFirstOfPair()?(r=\"1\",s=\"2\"):e.isSecondOfPair()&&(r=\"2\",s=\"1\");var o=[],a=e.fragmentLength,c=e.end-e.start;if(0===a)a=(e.start0?(o[0]=t,o[1]=r,o[2]=n,o[3]=s):(o[2]=t,o[3]=r,o[0]=n,o[1]=s),e.pairOrientation=o.join(\"\")}}};function Rp(e,t){const i=[];let n,r,s=0,o=e.start;e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef;for(let a of t){let t;switch(a.ltr){case\"H\":case\"P\":break;case\"S\":t=o,e.scLengthOnRef+=a.len,0===i.length&&(e.scStart-=a.len,t-=a.len),i.push(new xp({start:t,seqOffset:s,len:a.len,type:\"S\"})),s+=a.len;break;case\"N\":case\"D\":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case\"I\":void 0===n&&(n=[]),n.push(new xp({start:o,len:a.len,seqOffset:s,type:\"I\"})),s+=a.len;break;case\"M\":case\"EQ\":case\"=\":case\"X\":i.push(new xp({start:o,seqOffset:s,len:a.len,type:\"M\"})),s+=a.len,o+=a.len;break;default:console.log(\"Error processing cigar element: \"+a.len+a.ltr)}}e.blocks=i,e.insertions=n,e.gaps=r}function Dp(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Tp(e){var t,i,n,r,s,o,a,c,l;for(t=[],i=[],s=null,r=e.length,n=0;n=48&&l<=57?i.push(o):(a=o,c=Number.parseInt(i.join(\"\")),i=[],null!==s&&s.ltr===a?s.len+=c:(s={len:c,ltr:a},t.push(s)));return t}function Lp(e){var t={};return e.forEach((function(e){var i=e.split(\":\");t[i[0]]=i[2]})),t}function zp(e){let t=0;const i=e.length,n={},r=new DataView(e.buffer);for(;t=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>t.has(e)));e.length>0&&(n=e[0])}return this.chrAliasTable.set(e,n),n}return e}}class Pp{chrAliasTable=new Map;constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.baiPath=e.indexURL,Mp.setReaderDefaults(this,e),this._blockLoader=new yh(e)}async readAlignments(e,t,i){const n=await this.#x(e),r=new tp(e,t,i,this.config);if(void 0===n)return r;{const e=(await this.getIndex()).chunksForRange(n,t,i);if(!e||0===e.length)return r;for(let s of e){const e=await this._blockLoader.getData(s.minv,s.maxv);if(Mp.decodeBamRecords(e,s.minv.offset,r,this.header.chrNames,n,t,i,this.filter))break}return r.finish(),r}}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async getHeader(){if(!this.header){const e=this.genome,t=await this.getIndex();let i;if(t.firstBlockPosition){const e=Ua(this.config,{range:{start:t.firstBlockPosition,size:26}}),n=ms(await Qs.loadArrayBuffer(this.bamPath,e));i=t.firstBlockPosition+n}else i=64e3;const n=Ua(this.config,{range:{start:0,size:i}});this.header=await Mp.readHeader(this.bamPath,n,e)}return this.header}async getIndex(){return this.index||(this.index=await gh(this.baiPath,this.config)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const e=await this.getHeader();return this.chrToIndex=e.chrToIndex,this.indexToChr=e.chrNames,this.chrNames=new Set(e.chrNames),this.chrToIndex}}}class Op{constructor(e,t){this.config=e,this.genome=t;const i={};e.sources.sequences.forEach((function(n){const r=t?t.getChromosomeName(n):n;i[r]=function(e,t,i){const n={url:e.sources.url.replace(\"$CHR\",i)};e.sources.indexURL&&(n.indexURL=e.sources.indexURL.replace(\"$CHR\",i));const r=Object.assign(e,n);return new Pp(r,t)}(e,t,n)})),this.bamReaders=i,Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.bamReaders.hasOwnProperty(e)){let n=this.bamReaders[e];return await n.readAlignments(e,t,i)}return new tp(e,t,i,this.config)}}const Up=function(e,t){this.config=e,this.genome=t,Mp.setReaderDefaults(this,e)};function qp(){const e=this,t=this.genome;if(this.header)return Promise.resolve(this.header);{const i=this.config.url+\"?file=\"+this.config.alignmentFile+\"&options=-b,-H\",n=Ua(this.config);return Mp.readHeader(i,n,t).then((function(t){return e.header=t,t}))}}Up.prototype.readAlignments=function(e,t,i){var n=this;return qp.call(n).then((function(r){var s,o;return s=r.chrAliasTable.hasOwnProperty(e)?r.chrAliasTable[e]:e,o=n.config.url+\"?reference=\"+n.config.referenceFile+\"&file=\"+n.config.alignmentFile+\"®ion=\"+s+\":\"+t+\"-\"+i,Qs.loadString(o,Ua(n.config)).then((function(o){var a;return r.chrToIndex[s],a=new tp(e,t,i,n.config),Mp.decodeSamRecords(o,a,s,t,i,n.filter),a}))}))};class Qp extends Rh{constructor(e,t){super(e,t),Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(!this.header){const e=gs((await this.readHeaderData()).buffer);this.header=Mp.decodeBamHeader(e,this.genome),this.chrAliasTable=new Map;for(let e of this.header.chrNames)this.chrAliasTable.set(e,this.genome.getChromosomeName(e))}let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=gs((await this.readData(n,t,i)).buffer);this.header=Mp.decodeBamHeader(r,this.genome);const s=this.header.chrToIndex[e],o=new tp(e,t,i,this.config);return Mp.decodeBamRecords(r,this.header.size,o,this.header.chrNames,s,t,i,this.filter),o.finish(),o}}\n", - "/*! For license information please see cram-bundle.js.LICENSE.txt */for(var Vp=(()=>{var e={4923:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(8712),s=i(5931),o=i(9747);function a(e,t){const[i,n,r,s,o,a]=t,c=i;e[c]||(e[c]=[]),e[c].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}t.default=class{constructor(e){this.filehandle=(0,s.open)(e.url,e.path,e.filehandle)}parseIndex(){return n(this,void 0,void 0,(function*(){const e={},t=31===(i=yield this.filehandle.readFile())[0]&&139===i[1]?(0,r.unzip)(i):i;var i;if(t.length>4&&21578050===t.readUInt32LE(0))throw new o.CramMalformedError(\"invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support\");let n=[],s=\"\";for(const i of t)if(i>=48&&i<=57||!s&&45===i)s+=String.fromCharCode(i);else if(9===i)n.push(Number.parseInt(s,10)),s=\"\";else if(10===i)n.push(Number.parseInt(s,10)),s=\"\",a(e,n),n=[];else if(13!==i&&32!==i)throw new o.CramMalformedError(\"invalid .crai index file\");return s&&n.push(Number.parseInt(s,10)),6===n.length&&a(e,n),Object.entries(e).forEach((([t,i])=>{const n=i;e[t]=n.sort(((e,t)=>e.start-t.start||e.span-t.span))})),e}))}getIndex(){return this.parseIndexP||(this.parseIndexP=this.parseIndex().catch((e=>{throw this.parseIndexP=void 0,e}))),this.parseIndexP}hasDataForReferenceSequence(e){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[e]}))}getEntriesForRange(e,t,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[e];if(!n)return[];const r=e=>{const n=e.start,r=e.start+e.span;return n>i?-1:r<=t?1:0},s=[];for(const e of n)0===r(e)&&s.push(e);return s}))}}},9508:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=class{constructor(e,t){this.parameters=e,this.dataType=t}}},368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(e,t,i,n){return(0,o.getBits)(t.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}t.default=a},8635:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(9508)),s=i(400);class o extends r.default{constructor(e,t,i){super(e,t),this.instantiateCodec=i}decode(e,t,i,n){const r=this._getLengthCodec().decode(e,t,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a{(0,s.tinyMemoize)(o,e)}))},4839:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(e,t){const i=e.content,{stopByte:n}=this.parameters,r=t.bytePosition;let s=t.bytePosition;for(;i[s]!==n&&s=e.content.length)throw new a.CramBufferOverrunError(\"attempted to read beyond end of block. this file seems truncated.\");return e.content[t.bytePosition++]}}t.default=c},8185:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(e,t,i,n){let r=1;for(;0===(0,o.getBits)(t.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(t.content,n.coreBlock,r-1)|1<{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramBufferOverrunError=void 0,t.getBits=function(e,t,n){let r=0;if(t.bytePosition+(7-t.bitPosition+n)/8>e.length)throw new i(\"read error during decoding. the file seems to be truncated.\");for(let i=n;i;i--)r<<=1,r|=e[t.bytePosition]>>t.bitPosition&1,t.bitPosition-=1,t.bitPosition<0&&(t.bytePosition+=1),t.bitPosition&=7;return r};class i extends Error{}t.CramBufferOverrunError=i},4341:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),this.codes={},this.codeBook={},this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],![\"byte\",\"int\"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let e=new Array(this.parameters.numCodes);for(let t=0;te.bitLength-t.bitLength||e.symbol-t.symbol)),this.codeBook={},e.forEach((e=>{this.codeBook[e.bitLength]||(this.codeBook[e.bitLength]=[]),this.codeBook[e.bitLength].push(e.symbol)}))}buildCodes(){this.codes={};let e=0,t=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=Number.parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};t+=1;const o=s-e;if(t<<=o,n.bitCode=t,e+=o,function(e){let t=e-(e>>1)&1431655765;return t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}(t)>s)throw new r.CramMalformedError(\"Symbol out of range\");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((e,t)=>e.bitLength-t.bitLength||e.bitCode-t.bitCode)),this.sortedValuesByBitCode=this.sortedCodes.map((e=>e.value)),this.sortedBitCodes=this.sortedCodes.map((e=>e.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((e=>e.bitLength));const e=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(e+1).fill(-1);for(let e=0;e-1&&this.sortedBitLengthsByBitCode[i]===t)return this.sortedValuesByBitCode[i];for(let i=e;this.sortedCodes[i+1].bitLength===t&&i{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:\"MIDNSHP:XB\",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},7219:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(6524),r=i(9747),s={BF:\"int\",CF:\"int\",RI:\"int\",RL:\"int\",AP:\"int\",RG:\"int\",MF:\"int\",NS:\"int\",NP:\"int\",TS:\"int\",NF:\"int\",TC:\"byte\",TN:\"int\",FN:\"int\",FC:\"byte\",FP:\"int\",BS:\"byte\",IN:\"byteArray\",SC:\"byteArray\",DL:\"int\",BA:\"byte\",BB:\"byteArray\",RS:\"int\",PD:\"int\",HC:\"int\",MQ:\"int\",RN:\"byteArray\",QS:\"byte\",QQ:\"byteArray\",TL:\"int\"};t.default=class{constructor(e){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(e){const t=new Array(5);for(let e=0;e<5;e+=1)t[e]=new Array(4);return t[0][e[0]>>6&3]=\"C\",t[0][e[0]>>4&3]=\"G\",t[0][e[0]>>2&3]=\"T\",t[0][3&e[0]]=\"N\",t[1][e[1]>>6&3]=\"A\",t[1][e[1]>>4&3]=\"G\",t[1][e[1]>>2&3]=\"T\",t[1][3&e[1]]=\"N\",t[2][e[2]>>6&3]=\"A\",t[2][e[2]>>4&3]=\"C\",t[2][e[2]>>2&3]=\"T\",t[2][3&e[2]]=\"N\",t[3][e[3]>>6&3]=\"A\",t[3][e[3]>>4&3]=\"C\",t[3][e[3]>>2&3]=\"G\",t[3][3&e[3]]=\"N\",t[4][e[4]>>6&3]=\"A\",t[4][e[4]>>4&3]=\"C\",t[4][e[4]>>2&3]=\"G\",t[4][3&e[4]]=\"T\",t}(e.preservation.SM),this.dataSeriesEncoding=e.dataSeriesEncoding,this.tagEncoding=e.tagEncoding}getCodecForTag(e){const t=this.tagCodecCache[e];if(t)return t;{const t=this.tagEncoding[e];if(!t)throw new Error(\"Error, no tag encoding\");const i=(0,n.instantiateCodec)(t,\"byteArray\");return this.tagCodecCache[e]=i,i}}getTagNames(e){return this.tagIdsDictionary[e]}getCodecForDataSeries(e){let t=this.dataSeriesCodecCache[e];if(void 0===t){const i=this.dataSeriesEncoding[e];if(i){const o=s[e];if(!o)throw new r.CramMalformedError(`data series name ${e} not defined in file compression header`);t=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[e]=t}}return t}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.endsWith(\"Cache\")||(e[t]=this[t])})),e}}},78:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=i(9747),a=i(400),c=r(i(6771)),l=r(i(7219)),h=i(3165);class d{constructor(e,t){this.file=e,this.filePosition=t}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(!(null==e?void 0:e.numRecords))return null;const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),n=yield this.getFirstBlock();if(void 0===n)return;if(\"COMPRESSION_HEADER\"!==n.contentType)throw new o.CramMalformedError(`invalid content type ${n.contentType} in compression header block`);const r=(0,a.parseItem)(n.content,i.cramCompressionHeader.parser,0,n.contentPosition);return Object.assign(Object.assign({},n),{parsedContent:r})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(e)return this.file.readBlock(e._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const e=yield this.getCompressionHeaderBlock();if(e)return new l.default(e.parsedContent)}))}getSlice(e,t){return new c.default(this,e,t)}_readContainerHeader(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),{cramContainerHeader1:n,cramContainerHeader2:r}=i,{size:o}=yield this.file.stat();if(e>=o)return void console.warn(`pos:${e}>=fileSize:${o} in cram container`);const c=s.Buffer.allocUnsafe(n.maxLength);yield this.file.read(c,0,n.maxLength,e);const l=(0,a.parseItem)(c,n.parser),d=(0,a.itf8Size)(l.numLandmarks);if(e+l.length>=o)return void console.warn(`container at ${e} is beyond fileSize:${o}, skipping`);const u=s.Buffer.allocUnsafe(r.maxLength(l.numLandmarks));yield this.file.read(u,0,r.maxLength(l.numLandmarks),e+l._size-d);const f=(0,a.parseItem)(u,r.parser);return this.file.validateChecksums&&void 0!==f.crc32&&(yield this.file.checkCrc32(e,l._size+f._size-d-4,f.crc32,`container header beginning at position ${e}`)),Object.assign(l,f,{_size:l._size+f._size-d,_endPosition:l._size+f._size-d+e})}))}}t.default=d,\"getHeader getCompressionHeaderBlock getCompressionScheme\".split(\" \").forEach((e=>{(0,a.tinyMemoize)(d,e)}))},6794:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=r(i(928)),a=r(i(7392)),c=r(i(6960)),l=r(i(235)),h=i(1307),d=i(9747),u=i(8712),f=r(i(9989)),p=i(3165),g=r(i(78)),m=i(5931),w=i(400),b=i(5417);class F{constructor(e){var t;if(this.file=(0,m.open)(e.url,e.path,e.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=e.seqFetch,this.options={checkSequenceMD5:e.checkSequenceMD5,cacheSize:null!==(t=e.cacheSize)&&void 0!==t?t:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const e=new Uint32Array([287454020]),t=new Uint8Array(e.buffer);return 68===t[0]?0:17===t[0]?1:2}()>0)throw new Error(\"Detected big-endian machine, may be unable to run\")}read(e,t,i,n){return this.file.read(e,t,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const{maxLength:e,parser:t}=(0,p.cramFileDefinition)(),i=s.Buffer.allocUnsafe(e);yield this.file.read(i,0,e,0);const n=t(i).value;if(2!==n.majorVersion&&3!==n.majorVersion)throw new d.CramUnimplementedError(`CRAM version ${n.majorVersion} not supported`);return n}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.getContainerById(0);if(!e)throw new d.CramMalformedError(\"file contains no containers\");const t=yield e.getFirstBlock();if(void 0===t)return(0,b.parseHeaderText)(\"\");const i=t.content,n=i.readInt32LE(0),r=i.toString(\"utf8\",4,4+n);return this.header=r,(0,b.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getContainerById(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t);let n=i.cramFileDefinition.maxLength;const{size:r}=yield this.file.stat(),{cramContainerHeader1:s}=i;let o;for(let t=0;t<=e;t++){if(n+s.maxLength+8>=r)return;o=this.getContainerAtPosition(n);const i=yield o.getHeader();if(!i)throw new d.CramMalformedError(`container ${e} not found in file`);if(0===t){n=i._endPosition;for(let e=0;e=r)return;const o=s.Buffer.allocUnsafe(n.maxLength);return yield this.file.read(o,0,n.maxLength,e),(0,w.parseItem)(o,n.parser,0,e)}))}_parseSection(e,t){return n(this,arguments,void 0,(function*(e,t,i=e.maxLength,n){let r;if(n)r=n;else{const{size:e}=yield this.file.stat();if(t+i>=e)return;r=s.Buffer.allocUnsafe(i),yield this.file.read(r,0,i,t)}const o=(0,w.parseItem)(r,e.parser,0,t);if(o._size!==i)throw new d.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${o._size}`);return o}))}_uncompress(e,t,i){return n(this,void 0,void 0,(function*(){if(\"gzip\"===e)(0,u.unzip)(t).copy(i);else if(\"bzip2\"===e){const e=l.default.array(t);let n,r=l.default.header(e),o=0;do{n=l.default.decompress(e,r),-1!==n&&(s.Buffer.from(n).copy(i,o),o+=n.length,r-=n.length)}while(-1!==n)}else if(\"lzma\"===e){const e=new Response(new h.XzReadableStream((n=t,new ReadableStream({start(e){e.enqueue(n),e.close()}}))));s.Buffer.from(yield e.arrayBuffer()).copy(i)}else if(\"rans\"===e)(0,f.default)(t,i);else if(\"rans4x16\"===e)c.default.r4x16_uncompress(t,i);else if(\"arith\"===e)c.default.arith_uncompress(t,i);else if(\"fqzcomp\"===e)c.default.fqzcomp_uncompress(t,i);else{if(\"tok3\"!==e)throw new d.CramUnimplementedError(`${e} decompression not yet implemented`);c.default.tok3_uncompress(t,i)}var n}))}readBlock(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t),n=yield this.readBlockHeader(e);if(void 0===n)return;const r=n._endPosition,o=s.Buffer.allocUnsafe(n.uncompressedSize),a=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:o});if(\"raw\"!==n.compressionMethod){const e=s.Buffer.allocUnsafe(n.compressedSize);yield this.read(e,0,n.compressedSize,r),yield this._uncompress(n.compressionMethod,e,o)}else yield this.read(o,0,n.uncompressedSize,r);if(t>=3){const t=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===t)return;a.crc32=t.crc32,this.validateChecksums&&(yield this.checkCrc32(e,n._size+n.compressedSize,t.crc32,\"block data\")),a._endPosition=t._endPosition,a._size=a.compressedSize+i.cramBlockCrc32.maxLength}else a._endPosition=r+a.compressedSize,a._size=a.compressedSize;return a}))}}t.default=F,\"getDefinition getSectionParsers getSamHeader\".split(\" \").forEach((e=>{(0,w.tinyMemoize)(F,e)}))},7390:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=t.CramRecord=void 0;var r=i(8401);Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return n(r).default}});var s=i(6794);Object.defineProperty(t,\"default\",{enumerable:!0,get:function(){return n(s).default}})},8401:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.MateFlagsDecoder=t.CramFlagsDecoder=t.BamFlagsDecoder=t.MateFlags=t.CramFlags=t.BamFlags=void 0;const r=n(i(7295)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(e){const t={};for(const[i,n]of e)t[`is${n}`]=e=>!!(e&i),t[`set${n}`]=e=>e|i;return t}t.BamFlags=[[1,\"Paired\"],[2,\"ProperlyPaired\"],[4,\"SegmentUnmapped\"],[8,\"MateUnmapped\"],[16,\"ReverseComplemented\"],[32,\"MateReverseComplemented\"],[64,\"Read1\"],[128,\"Read2\"],[256,\"Secondary\"],[512,\"FailedQc\"],[1024,\"Duplicate\"],[2048,\"Supplementary\"]],t.CramFlags=[[1,\"PreservingQualityScores\"],[2,\"Detached\"],[4,\"WithMateDownstream\"],[8,\"DecodeSequenceAsStar\"]],t.MateFlags=[[1,\"OnNegativeStrand\"],[2,\"Unmapped\"]],t.BamFlagsDecoder=o(t.BamFlags),t.CramFlagsDecoder=o(t.CramFlags),t.MateFlagsDecoder=o(t.MateFlags),t.default=class{constructor({flags:e,cramFlags:t,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:c,mateToUse:l,readGroupId:h,readName:d,sequenceId:u,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=e,this.cramFlags=t,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=h,this.readName=d,this.sequenceId=u,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,c&&(this.readFeatures=c),l&&(this.mate={flags:l.mateFlags,readName:l.mateReadName,sequenceId:l.mateSequenceId,alignmentStart:l.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const e=function(e,t){if(!e.lengthOnRef&&!e.readLength)return null;if(e.isUnknownBases())return null;const i=e.alignmentStart-t.start;if(!e.readFeatures)return t.seq.slice(i,i+(e.lengthOnRef||0)).toUpperCase();let n=\"\",r=i,s=0;for(;n.lengththis.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=e,r[1]=i,r[2]=t,r[3]=n):(r[2]=e,r[3]=i,r[0]=t,r[1]=n),r.join(\"\")}return null}addReferenceSequence(e,t){this.readFeatures&&this.readFeatures.forEach((i=>{\"X\"===i.code&&function(e,t,i,n){const r=n.refPos-t.start,o=t.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const c=i.substitutionMatrix[a][n.data];c&&(n.sub=c)}(0,e,t,i)})),!this.readBases&&e.start<=this.alignmentStart&&e.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=e)}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.startsWith(\"_\")||(e[t]=this[t])})),e.readBases=this.getReadBases(),e}}},3165:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.cramFileDefinition=r,t.cramBlockHeader=s,t.cramBlockCrc32=o,t.cramTagDictionary=c,t.cramPreservationMap=l,t.isMappedSliceHeader=function(e){return\"number\"==typeof e.refSeqId},t.getSectionParsers=function(e){return{cramFileDefinition:r(),cramBlockHeader:s(),cramBlockCrc32:o(),cramDataSeriesEncodingMap:p(),cramTagEncodingMap:g(),cramCompressionHeader:{parser:(e,t)=>{const{value:i,offset:n}=l().parser(e,t);t=n;const{value:r,offset:s}=p().parser(e,t);t=s;const{value:o,offset:a}=g().parser(e,t);return t=a,{value:{dataSeriesEncoding:h(r),preservation:h(i),tagEncoding:h(o)},offset:t}}},cramEncoding:{parser:(e,t)=>f(e,t)},cramUnmappedSliceHeader:d(e),cramMappedSliceHeader:u(e),cramContainerHeader1:m(e),cramContainerHeader2:w(e)}};const n=i(400);function r(){return{parser:(e,t=0)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length);let r=0;const s=e.subarray(r,r+4).toString();r+=4;const o=n.getUint8(r);r+=1;const a=n.getUint8(r);r+=1;const c=i.subarray(r,r+20).toString().replaceAll(\"\\0\",\"\");return r+=20,{value:{magic:s,majorVersion:o,minorVersion:a,fileId:c},offset:r}},maxLength:26}}function s(){return{parser:(e,t=0)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length);let s=0;const o=r.getUint8(s),a=[\"raw\",\"gzip\",\"bzip2\",\"lzma\",\"rans\",\"rans4x16\",\"arith\",\"fqzcomp\",\"tok3\"][o];if(!a)throw new Error(`compression method number ${o} not implemented`);s+=1;const c=r.getUint8(s),l=[\"FILE_HEADER\",\"COMPRESSION_HEADER\",\"MAPPED_SLICE_HEADER\",\"UNMAPPED_SLICE_HEADER\",\"EXTERNAL_DATA\",\"CORE_DATA\"][c];if(!l)throw new Error(`invalid block content type id ${c}`);s+=1;const[h,d]=(0,n.parseItf8)(e,s);s+=d;const[u,f]=(0,n.parseItf8)(e,s);s+=f;const[p,g]=(0,n.parseItf8)(e,s);return s+=g,{offset:s,value:{uncompressedSize:p,compressedSize:u,contentId:h,contentType:l,compressionMethod:a}}},maxLength:17}}function o(){return{parser:(e,t)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length).getUint32(t,!0);return{offset:t+=4,value:{crc32:n}}},maxLength:4}}function a(e,t,i){const n=e.toString(\"utf8\",t,i),r=[];for(let e=0;e{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const s=e.subarray(t,t+i);t+=i;const o=[];let c=0,l=0;for(;lc&&o.push(a(s,c,l)),{value:{size:i,ents:o},offset:t}}}}function l(){return{parser:(e,t)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,l]=(0,n.parseItf8)(e,t);t+=l;const h=[];for(let i=0;i{const[r,s]=(0,n.parseItf8)(t,i);i+=s;let o=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,o=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,o=e}else console.warn(\"recordCounter=0\");const[a,c]=(0,n.parseItf8)(t,i);i+=c;const[l,h]=(0,n.parseItf8)(t,i);i+=h;const d=[];for(let e=0;e=2&&(u=[...t.subarray(i,i+16)],i+=16),{value:{recordCounter:o,md5:u,contentIds:d,numContentIds:l,numBlocks:a,numRecords:r},offset:i}},maxLength:e=>40+5*e}}function u(e){return{parser:(t,i)=>{const[r,s]=(0,n.parseItf8)(t,i);i+=s;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;let u=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,u=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,u=e}else console.warn(\"majorVersion is <2, recordCounter set to 0\");const[f,p]=(0,n.parseItf8)(t,i);i+=p;const[g,m]=(0,n.parseItf8)(t,i);i+=m;const w=[];for(let e=0;e=2&&(v=[...t.subarray(i,i+16)],i+=16),{value:{md5:v,numBlocks:f,numRecords:h,numContentIds:g,refSeqSpan:c,refSeqId:r,refSeqStart:o,recordCounter:u,refBaseBlockId:b,contentIds:w},offset:i}},maxLength:e=>60+5*e}}function f(e,t){const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,c]=(0,n.parseItf8)(e,t);t+=c;const l={};if(0===s);else if(1===s){const[i,r]=(0,n.parseItf8)(e,t);l.blockContentId=i,t+=r}else if(2===s){const[i,r]=(0,n.parseItf8)(e,t);l.offset=i,t+=r;const[s,o]=(0,n.parseItf8)(e,t);l.M=s,t+=o}else if(3===s){const i=(0,n.parseItf8)(e,t),r=i[0];t+=i[1];const s=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(255&i),{value:o,offset:c}=f(e,t);t=c,a.push({key:s,value:o})}return{value:{mapSize:i,ents:a,mapCount:s},offset:t}}}}function m(e){return{maxLength:52,parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length).getInt32(i,!0);i+=4;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;const[u,f]=(0,n.parseItf8)(t,i);i+=f;let p,g=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);g=e,i+=r}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);g=e,i+=r}else console.warn(\"setting recordCounter=0\");if(e>1){const[e,r]=(0,n.parseLtf8)(t,i);p=e,i+=r}const[m,w]=(0,n.parseItf8)(t,i);i+=w;const[b,F]=(0,n.parseItf8)(t,i);return{value:{length:s,refSeqId:o,refSeqStart:c,alignmentSpan:h,numBlocks:m,numLandmarks:b,numBases:p,recordCounter:g,numRecords:u},offset:i+=F}}}}function w(e){return{parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length),[o,a]=(0,n.parseItf8)(t,i);i+=a;const c=[];for(let e=0;e=3&&(l=s.getUint32(i,!0),i+=4),{value:Object.assign(Object.assign({},void 0===l?{}:{crc32:l}),{numLandmarks:o,landmarks:c}),offset:i}},maxLength:e=>5+5*e+4}}},6484:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,c,l,h,d,u,f){let p=t(\"BF\");const g=t(\"CF\");if(!(0,s.isMappedSliceHeader)(c.parsedContent))throw new Error(\"slice header not mapped\");const m=u>1&&-2===c.parsedContent.refSeqId?t(\"RI\"):c.parsedContent.refSeqId,w=t(\"RL\");let b=t(\"AP\");i.APdelta&&(b+=d.lastAlignmentStart),d.lastAlignmentStart=b;const F=t(\"RG\");let v,y,A,C;if(i.readNamesIncluded&&(v=o(t(\"RN\"))),r.CramFlagsDecoder.isDetached(g)){const e=t(\"MF\");let n;i.readNamesIncluded||(n=o(t(\"RN\")),v=n);const s=t(\"NS\"),a=t(\"NP\");(e||s>-1)&&(y={mateFlags:e,mateSequenceId:s,mateAlignmentStart:a,mateReadName:n}),A=t(\"TS\"),r.MateFlagsDecoder.isUnmapped(e)&&(p=r.BamFlagsDecoder.setMateUnmapped(p)),r.MateFlagsDecoder.isOnNegativeStrand(e)&&(p=r.BamFlagsDecoder.setMateReverseComplemented(p))}else r.CramFlagsDecoder.isWithMateDownstream(g)&&(C=t(\"NF\")+f+1);const _=t(\"TL\");if(_<0)throw new n.CramMalformedError(\"invalid TL index\");const x={},k=i.getTagNames(_),I=k.length;for(let t=0;t1?\"SC\":\"IN\"],X:[\"number\",\"BS\"],D:[\"number\",\"DL\"],I:[\"string\",\"IN\"],i:[\"character\",\"BA\"],b:[\"string\",\"BB\"],q:[\"numArray\",\"QQ\"],Q:[\"number\",\"QS\"],H:[\"number\",\"HC\"],P:[\"number\",\"PD\"],N:[\"number\",\"RS\"]}[t];if(!h)throw new n.CramMalformedError(`invalid read feature code \"${t}\"`);let d=l(h);const u={B:[\"number\",\"QS\"]}[t];u&&(d=[d,l(u)]),o+=r;const f=o;a+=r;const p=a;\"D\"===t||\"N\"===t?a+=d:\"I\"===t||\"S\"===t?a-=d.length:\"i\"===t&&(a-=1),c[e]={code:t,pos:f,refPos:p,data:d}}return c}(b,e,t,0,u)),E=w,S)for(const{code:e,data:t}of S)\"D\"===e||\"N\"===e?E+=t:\"I\"===e||\"S\"===e?E-=t.length:\"i\"===e&&(E-=1);if(Number.isNaN(E)&&(console.warn(`${v||`${m}:${b}`} record has invalid read features`),E=w),N=t(\"MQ\"),r.CramFlagsDecoder.isPreservingQualityScores(g)){B=new Array(w);for(let e=0;e=0){const r=e[i.mateRecordNumber];if(!r)throw new s.CramMalformedError(\"intra-slice mate record not found, this file seems malformed\");n.push(...t(r))}return n}(i),r=n.map((e=>e.alignmentStart)),o=n.map((e=>e.alignmentStart+e.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((e=>{if(void 0!==e.templateLength)throw new s.CramMalformedError(\"mate pair group has some members that have template lengths already, this file seems malformed\");e.templateLength=a}))}(e,0,i):function(e,t){const i=Math.min(e.alignmentStart,t.alignmentStart),n=Math.max(e.alignmentStart+e.readLength-1,t.alignmentStart+t.readLength-1)-i+1;e.templateLength=n,t.templateLength=n}(i,n)),i.mateRecordNumber=void 0}class f{constructor(e,t,i){this.container=e,this.containerPosition=t,this.sliceSize=i,this.file=e.file}getHeader(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.file.getDefinition(),t=(0,h.getSectionParsers)(e),i=yield this.container.getHeader();if(!i)throw new Error(\"no container header detected\");const n=yield this.file.readBlock(i._endPosition+this.containerPosition);if(void 0===n)throw new Error(\"block header undefined\");if(\"MAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramMappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}if(\"UNMAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramUnmappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${n.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();let t=e._endPosition;const i=new Array(e.parsedContent.numBlocks);for(let e=0;e{\"EXTERNAL_DATA\"===e.contentType&&(t[e.contentId]=e)})),t}))}getBlockByContentId(e){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[e]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const e=(yield this.getHeader()).parsedContent;if(!(0,h.isMappedSliceHeader)(e))throw new Error(\"slice header not mapped\");if(e.refSeqId<0)return;const t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error(\"compression scheme undefined\");if(e.refBaseBlockId>=0){const t=yield this.getBlockByContentId(e.refBaseBlockId);if(!t)throw new s.CramMalformedError(\"embedded reference specified, but reference block does not exist\");return{seq:t.data.toString(\"utf8\"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}if(t.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error(\"reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence\");const t=yield this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);if(t.length!==e.refSeqSpan)throw new s.CramArgumentError(\"seqFetch callback returned a reference sequence of the wrong length\");return{seq:t,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){var e,t;const{majorVersion:i}=yield this.file.getDefinition(),n=yield this.container.getCompressionScheme();if(void 0===n)throw new Error(\"compression scheme undefined\");const r=yield this.getHeader(),a=yield this._getBlocksContentIdIndex();if(i>1&&this.file.options.checkSequenceMD5&&(0,h.isMappedSliceHeader)(r.parsedContent)&&r.parsedContent.refSeqId>=0&&\"0000000000000000\"!==(null===(e=r.parsedContent.md5)||void 0===e?void 0:e.join(\"\"))){const e=yield this.getReferenceRegion();if(e){const{seq:i,start:n,end:a}=e,c=(0,o.sequenceMD5)(i),l=null===(t=r.parsedContent.md5)||void 0===t?void 0:t.map((e=>(e<16?\"0\":\"\")+e.toString(16))).join(\"\");if(c!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${r.parsedContent.refSeqId} pos ${n}..${a}. recorded MD5: ${l}, calculated MD5: ${c}`)}}const f=yield this.getCoreDataBlock(),p={lastAlignmentStart:(0,h.isMappedSliceHeader)(r.parsedContent)?r.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(e){let t=this.map.get(e);return void 0===t&&(t={bitPosition:7,bytePosition:0},this.map.set(e,t)),t}}},g=e=>{const t=n.getCodecForDataSeries(e);if(!t)throw new s.CramMalformedError(`no codec defined for ${e} data series`);return t.decode(this,f,a,p)},m=new Array(r.parsedContent.numRecords);for(let t=0;t=0&&u(m,e,m[e],m[t])}return m}))}getRecords(e){return n(this,void 0,void 0,(function*(){const t=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(t.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(t.toString(),i));const r=(yield i).filter(e);if(r.length&&this.file.fetchReferenceSequenceCallback){const e=yield this.getHeader();if((0,h.isMappedSliceHeader)(e.parsedContent)&&(e.parsedContent.refSeqId>=0||-2===e.parsedContent.refSeqId)){const t=e.parsedContent.refSeqId>=0?e.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error(\"compression scheme undefined\");const s={};for(const e of r){const i=void 0!==t?t:e.sequenceId;let n=s[i];n||(n={id:i,start:e.alignmentStart,end:Number.NEGATIVE_INFINITY,seq:null},s[i]=n);const r=e.alignmentStart+(e.lengthOnRef||e.readLength)-1;r>n.end&&(n.end=r),e.alignmentStartn(this,void 0,void 0,(function*(){-1!==e.id&&e.start<=e.end&&this.file.fetchReferenceSequenceCallback&&(e.seq=yield this.file.fetchReferenceSequenceCallback(e.id,e.start,e.end))})))));for(const e of r){const n=s[void 0!==t?t:e.sequenceId];if(null==n?void 0:n.seq){const t=n.seq;e.addReferenceSequence(Object.assign(Object.assign({},n),{seq:t}),i)}}}}return r}))}}t.default=f,\"getHeader getBlocks _getBlocksContentIdIndex\".split(\" \").forEach((e=>{(0,o.tinyMemoize)(f,e)}))},400:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.itf8Size=function(e){return-128&e?-16384&e?-2097152&e?-268435456&e?5:4:3:2:1},t.parseItf8=function(e,t){let i=t;const n=e[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|e[i+1]),i+=2):n<224?(r=2097151&(n<<16|e[i+1]<<8|e[i+2]),i+=3):n<240?(r=268435455&(n<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4):(r=(15&n)<<28|e[i+1]<<20|e[i+2]<<12|e[i+3]<<4|15&e[i+4],i+=5),i>e.length)throw new o.CramBufferOverrunError(\"Attempted to read beyond end of buffer; this file seems truncated.\");return[r,i-t]},t.parseLtf8=function(e,t){let i=t;const n=e[i];let r;if(n<128)r=n,i+=1;else if(n<192)r=16383&(e[i]<<8|e[i+1]),i+=2;else if(n<224)r=2097151&(e[i]<<16|e[i+1]<<8|e[i+2]),r=(63&n)<<16|e.readUInt16LE(i+1),i+=3;else if(n<240)r=268435455&(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4;else if(n<248)r=(15&e[i])*Math.pow(2,32)+(e[i+1]<<24)|e[i+2]<<16|e[i+3]<<8|e[i+4],i+=5;else if(n<252)r=((7&e[i])<<8|e[i+1])*Math.pow(2,32)+(e[i+2]<<24)|e[i+3]<<16|e[i+4]<<8|e[i+5],i+=6;else if(n<254)r=((3&e[i])<<16|e[i+1]<<8|e[i+2])*Math.pow(2,32)+(e[i+3]<<24)|e[i+4]<<16|e[i+5]<<8|e[i+6],i+=7;else if(n<255){if(r=s.default.fromBytesBE(e.slice(i+1,i+8)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=8}else{if(r=s.default.fromBytesBE(e.slice(i+1,i+9)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=9}return[r,i-t]},t.parseItem=function(e,t,i=0,n=0){const{offset:r,value:s}=t(e,i);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},t.tinyMemoize=function(e,t){const i=e.prototype[t],n=`_memo_${t}`;e.prototype[t]=function(){if(!(n in this)){const e=i.call(this);this[n]=e,Promise.resolve(e).catch((()=>{delete this[n]}))}return this[n]}},t.sequenceMD5=function(e){return(0,r.default)(e.toUpperCase().replaceAll(/[^\\u0021-\\u007e]/g,\"\"))};const r=n(i(3503)),s=n(i(8570)),o=i(612)},9747:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramArgumentError=t.CramSizeLimitError=t.CramMalformedError=t.CramUnimplementedError=t.CramError=void 0;class i extends Error{}t.CramError=i;class n extends Error{}t.CramUnimplementedError=n,t.CramMalformedError=class extends i{},t.CramSizeLimitError=class extends i{},t.CramArgumentError=class extends i{}},7806:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.IndexedCramFile=t.CraiIndex=t.CramRecord=t.CramFile=void 0;var r=i(7390);Object.defineProperty(t,\"CramFile\",{enumerable:!0,get:function(){return n(r).default}}),Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return r.CramRecord}});var s=i(4923);Object.defineProperty(t,\"CraiIndex\",{enumerable:!0,get:function(){return n(s).default}});var o=i(6014);Object.defineProperty(t,\"IndexedCramFile\",{enumerable:!0,get:function(){return n(o).default}})},6014:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(9747),o=r(i(7390));t.default=class{constructor(e){var t;if(this.cram=null!==(t=e.cram)&&void 0!==t?t:new o.default({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof o.default))throw new Error(\"invalid arguments: no cramfile\");this.index=e.index}getRecordsForRange(e,t,i){return n(this,arguments,void 0,(function*(e,t,i,n={}){if(n.viewAsPairs=n.viewAsPairs||!1,n.pairAcrossChr=n.pairAcrossChr||!1,n.maxInsertSize=n.maxInsertSize||2e5,\"string\"==typeof e)throw new s.CramUnimplementedError(\"string sequence names not yet supported\");const r=e,o=yield this.index.getEntriesForRange(r,t,i),a=n=>n.sequenceId===e&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=t,c=yield Promise.all(o.map((e=>this.getRecordsInSlice(e,a))));let l=Array.prototype.concat(...c);if(n.viewAsPairs){const e={},t={};for(const i of l){const n=i.readName;if(void 0===n)throw new Error(\"readName undefined\");const r=i.uniqueId;e[n]||(e[n]=0),e[n]+=1,t[r]=1}const i={};Object.entries(e).forEach((([e,t])=>{1===t&&(i[e]=!0)}));const s=[];for(const e of l){const t=e.readName;if(void 0===t)throw new Error(\"readName undefined\");if(i[t]&&e.mate&&(e.mate.sequenceId===r||n.pairAcrossChr)&&Math.abs(e.alignmentStart-e.mate.alignmentStart)e.toString().localeCompare(t.toString()))).filter(((e,t,i)=>!t||e.toString()!==i[t-1].toString()));const c=[];for(const e of a){let n=this.cram.featureCache.get(e.toString());n||(n=this.getRecordsInSlice(e,(()=>!0)),this.cram.featureCache.set(e.toString(),n));const r=n.then((e=>{const n=[];for(const r of e){if(void 0===r.readName)throw new Error(\"readName undefined\");i[r.readName]&&!t[r.uniqueId]&&n.push(r)}return n}));c.push(r)}const h=yield Promise.all(c);if(h.length){const e=h.reduce(((e,t)=>e.concat(t)));l=l.concat(e)}}return l}))}getRecordsInSlice({containerStart:e,sliceStart:t,sliceBytes:i},n){return this.cram.getContainerAtPosition(e).getSlice(t,i).getRecords(n)}hasDataForReferenceSequence(e){return this.index.hasDataForReferenceSequence(e)}}},5931:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RemoteFile=t.LocalFile=void 0,t.open=function(e,t,i){if(i)return i;if(e)return new n.RemoteFile(e);if(t)return new n.LocalFile(t);throw new Error(\"no url, path, or filehandle provided, cannot open\")};const n=i(1113);var r=i(1113);Object.defineProperty(t,\"LocalFile\",{enumerable:!0,get:function(){return r.LocalFile}}),Object.defineProperty(t,\"RemoteFile\",{enumerable:!0,get:function(){return r.RemoteFile}})},6476:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RANS_BYTE_L=t.TOTFREQ=t.TF_SHIFT=void 0,t.TF_SHIFT=12,t.TOTFREQ=4096,t.RANS_BYTE_L=1<<23},997:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,n){let a=e.getInt(),c=e.getInt(),l=e.getInt(),h=e.getInt();const d=n.remaining(),u=-4&d;for(let r=0;r>2;let u=0,f=d,p=2*d,g=3*d,m=0,w=0,b=0,F=0;for(;u{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(9747),r=i(6476);class s{constructor(){this.F=void 0,this.C=void 0}}function o(e,t,i,n){return i*(e>>n)+(e&(1<>s)+(e&(1<=128&&(t.fc[c].F&=-129,t.fc[c].F=(127&t.fc[c].F)<<8|255&e.get()),t.fc[c].C=r,o.default.symbolInit(i[c],t.fc[c].C,t.fc[c].F),t.R||(t.R=new Array(s.TOTFREQ)),t.R.fill(c,r,r+t.fc[c].F),r+=t.fc[c].F,0===n&&c+1===(255&e.getByteAt(e.position()))?(c=255&e.get(),n=255&e.get()):0!==n?(n-=1,c+=1):c=255&e.get()}while(0!==c);a(r=128&&(t[r].fc[h].F&=-129,t[r].fc[h].F=(127&t[r].fc[h].F)<<8|255&e.get()),t[r].fc[h].C=l,0===t[r].fc[h].F&&(t[r].fc[h].F=s.TOTFREQ),null==i[r][h]&&(i[r][h]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][h],t[r].fc[h].C,t[r].fc[h].F),null==t[r].R&&(t[r].R=new Array(s.TOTFREQ)),t[r].R.fill(h,l,l+t[r].fc[h].F),l+=t[r].fc[h].F,a(l<=s.TOTFREQ),0===c&&h+1===(255&e.getByteAt(e.position()))?(h=255&e.get(),c=255&e.get()):0!==c?(c-=1,h+=1):h=255&e.get()}while(0!==h);0===n&&r+1===(255&e.getByteAt(e.position()))?(r=255&e.get(),n=255&e.get()):0!==n?(n-=1,r+=1):r=255&e.get()}while(0!==r)};const r=i(9747),s=i(6476),o=n(i(488));function a(e){if(!e)throw new r.CramMalformedError(\"assertion failed\")}},9989:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i=0){if(0===e.length)return t.fill(0),t;const n=new d(e,i),u=n.get();if(0!==u&&1!==u)throw new s.CramMalformedError(`Invalid rANS order ${u}`);if(n.getInt()!==n.remaining()-h)throw new s.CramMalformedError(\"Incorrect input length.\");const f=n.getInt(),p=new d(t||r.Buffer.allocUnsafe(f));if(p.length{Object.defineProperty(t,\"__esModule\",{value:!0}),t.parseHeaderText=function(e){const t=e.split(/\\r?\\n/),i=[];for(const e of t){const[t,...n]=e.split(/\\t/);t&&i.push({tag:t.slice(1),data:n.map((e=>{const t=e.indexOf(\":\");return-1!==t?{tag:e.slice(0,t),value:e.slice(t+1)}:{tag:e,value:\"\"}}))})}return i}},8712:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.unzip=function(e){return r.Buffer.from((0,n.inflate)(e))};const n=i(1668),r=i(8287)},635:(e,t,i)=>{var n=i(8287).Buffer;const r=i(4646),s=i(8706),o=i(9614),a=i(235),c=128;e.exports=class{decode(e){return this.stream=new s(e),this.decodeStream(this.stream)}decodeStream(e,t=0){var i=this.stream.ReadByte();16&i||(t=this.stream.ReadUint7());var n,r=t,s=1&i;if(8&i)return this.decodeStripe(this.stream,t);if(i&c&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&c&&(o=this.decodePack(o,n,t)),o}encode(e,t){if(this.stream=new s(\"\",0,1.1*e.length+100),this.stream.WriteByte(t),16&t||this.stream.WriteUint7(e.length),8&t)return n.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,e,t>>8)]);var i,r=1&t,o=e.length;return t&c&&([i,e,o]=this.encodePack(e)),t&c&&this.stream.WriteStream(i),64&t?r?this.encodeRLE1(e,o,this.stream):this.encodeRLE0(e,o,this.stream):r?this.encode1(e,o,this.stream):this.encode0(e,o,this.stream)}decode0(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);var a=new o(s),c=new r(e);c.RangeStartDecode(e);for(var l=0;l=3?3:h;for(c[d].ModelEncode(i,l,u),h-=u,d=256;3==u;)u=h>=3?3:h,c[d].ModelEncode(i,l,u),d=257,h-=u}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);for(var a=new Array(s),c=0;c=3?3:d;for(c[u].ModelEncode(i,l,f),d-=f,u=256;3==f;)f=d>=3?3:d,c[u].ModelEncode(i,l,f),u=257,d-=f}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(e){this.nsym=e.ReadByte();for(var t=new Array(this.nsym),i=0;i>=1}}else if(this.nsym<=4)for(s=0,o=0;s>=2;else{if(!(this.nsym<=16))return e;for(s=0,o=0;s>=4}return r}packMeta(e){for(var t=new s(\"\",0,1024),i=new Array(256),n=0;no),n[o]=new Array(r[o]);for(var a=0,c=0;co),a[o]=this.decodeStream(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o{e.exports=class{constructor(e){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(e){for(var t=0;t<5;t++)this.code=(this.code<<8)+e.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(e){return this.range=Math.floor(this.range/e),Math.floor(this.code/this.range)}RangeDecode(e,t,i,n){for(this.code-=t*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+e.ReadByte()}RangeShiftLow(e){if(this.low<4278190080|this.carry){for(e.WriteByte(this.cache+this.carry);this.FFnum;)e.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(e,t,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=t*this.range,this.low>>>=0,this.range*=i,this.low{e.exports=class{constructor(e=256){this.total_freq=e,this.max_sym=e-1,this.S=new Array,this.F=new Array;for(var t=0;t<=this.max_sym;t++)this.S[t]=t,this.F[t]=1}ModelDecode(e,t){for(var i=t.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];t.RangeDecode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var e=0;e<=this.max_sym;e++)this.F[e]-=Math.floor(this.F[e]/2),this.total_freq+=this.F[e]}ModelEncode(e,t,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(t.RangeEncode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},6038:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(9614),o=i(4646);function a(e,t,i){for(var n=0,r=0,s=-1,o=new Array(1024);r>4,t.qshift=15&i,i=e.ReadByte(),t.qloc=i>>4,t.sloc=15&i,i=e.ReadByte(),t.ploc=i>>4,t.dloc=15&i,t.qmap=new Array(256),16&t.pflags)for(var n=0;n0&&128&t.pflags)a(e,t.qtab,256);else for(n=0;n<256;n++)t.qtab[n]=n;return t.ptab=new Array(1024),32&t.pflags&&a(e,t.ptab,1024),t.dtab=new Array(256),64&t.pflags&&a(e,t.dtab,256),t}function h(e,t,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(e,t):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(e,t);a|=n.len[1].ModelDecode(e,t)<<8,a|=n.len[2].ModelDecode(e,t)<<16,a|=n.len[3].ModelDecode(e,t)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(e,t)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(e,t)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function d(e,t,i){for(var n=0,r=0,s=new Array(2*i),o=0;n1?i.nparam-1:0,s=new Array(256);if(2&i)r=e.ReadByte(),a(e,s,256);else{for(var o=0;o0&&(t.sel=new s(e.max_sel+1)),t}(r),p=new o(e);p.RangeStartDecode(e);for(var g=new n.allocUnsafe(i),m={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},w=0;w0&&f.dup.ModelDecode(e,p)){for(var b=0;b4),qshift:d,qloc:7,pbits:7,pshift:t[0]>128?1:0,ploc:0,dbits:d>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:c,nsym:a,do_qmap:u,do_dedup:0,fixed_len:1==t.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:d<=4?1:0,do_qtab:0,qbits:8+(d>4)-(0==o),sbits:1,sloc:15-(d<=4),do_stab:1,do_sel:1}]}(e,t,i,n),p=function(e,t,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],c=0;c1?1:0)|(t[0].do_stab?2:0);if(e.WriteByte(l),1&l&&e.WriteByte(t.length),2&l){var h=1<0&&h--,e.WriteByte(h),d(e,o,256)}for(var u=0;u0){for(c=0;c<256;c++)n[u][c]=c;t[u].do_qtab&&d(e,n[u],256)}if(t[u].pbits>0){for(c=0;c<1024;c++)r[u][c]=Math.min((1<>t[u].pshift);d(e,r[u],1024)}if(t[u].dbits>0){for(c=0;c<256;c++)a[c]>(1<>t[u].dshift)];d(e,s[u],256)}}return e}(p,f,n,a,c,l,h);return function(e,t,i,n,r,a,c,l,h,d){var u=1<0&&u--;for(var f=t.length,p=0,g=0;g0&&F.ModelEncode(e,v,A);var C=d[A],_=i[Math.min(i.length-1,y++)];r[C].fixed_len?r[C].fixed_len>0&&(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255),r[C].fixed_len=-1):(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255)),r[C].do_dedup&&process.exit(1),g=_;var x=0,k=r[C].context,I=0,S=0}var E=t[w++],N=a[C][E];m[k].ModelEncode(e,v,N),I=(I<0&&(k+=l[C][Math.min(g,1023)]<0&&(k+=h[C][Math.min(x,255)]<{var n=i(8287).Buffer,r=i(5460),s=i(8223),o=i(635),a=i(6038),c=i(5997);e.exports={r4x8_uncompress:function(e,t){r.decode(e).copy(t,0,0)},r4x16_uncompress:function(e,t){s.decode(e).copy(t,0,0)},arith_uncompress:function(e,t){o.decode(e).copy(t,0,0)},fqzcomp_uncompress:function(e,t){var i=new Array;a.decode(e,i).copy(t,0,0)},tok3_uncompress:function(e,t){var i=c.decode(e,0,\"\\0\");n.from(i,\"binary\").copy(t,0,0)}}},8706:(e,t,i)=>{var n=i(8287).Buffer;e.exports=class{constructor(e,t=0,i=0){0!=i?(this.buf=n.allocUnsafe(i),this.length=i):(this.buf=e,this.length=e.length),this.pos=t}EOF(){return this.pos>=this.length}ReadData(e){var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}ReadByte(){const e=this.buf[this.pos];return this.pos++,e}ReadChar(){const e=this.buf[this.pos];return this.pos++,String.fromCharCode(e)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const e=this.buf.readInt32LE(this.pos);return this.pos+=4,e}ReadString(){var e=\"\";do{var t=this.buf[this.pos++];t&&(e+=String.fromCharCode(t))}while(t);return e}ReadUint7(){var e=0;do{var t=this.ReadByte();e=e<<7|127&t}while(128&t);return e}ReadITF8(){var e=this.buf[this.pos];return this.pos++,e>=240?(e=(15&e)<<28,e+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):e>=224?(e=(15&e)<<24,e+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(0|this.buf[this.pos+2]),this.pos+=3):e>=192?(e=(31&e)<<16,e+=(this.buf[this.pos+0]<<8)+(0|this.buf[this.pos+1]),this.pos+=2):e>=128&&(e=(63&e)<<8,e+=this.buf[this.pos],this.pos++),e}WriteByte(e){this.buf[this.pos++]=e}WriteChar(e){this.buf[this.pos++]=e.charCodeAt(0)}WriteString(e){for(var t=0;t>8&255)}WriteUint32(e){this.buf.writeInt32LE(e,this.pos),this.pos+=4}WriteUint7(e){var t=0,i=e;do{t+=7,i>>=7}while(i>0);do{t-=7,this.WriteByte((e>>t&127)+((t>0)<<7))}while(t>0)}WriteITF8(e){e<0&&(e=1+e),e<=127?this.buf[this.pos++]=e:e<=16383?(this.buf[this.pos++]=128|Math.floor(e/256),this.buf[this.pos++]=255&e):e<131071?(this.buf[this.pos++]=192|Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):e<268435455?(this.buf[this.pos++]=224|Math.floor(e/16777216),this.buf[this.pos++]=255&Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):(this.buf[this.pos++]=240|Math.floor(e/268435456),this.buf[this.pos++]=255&Math.floor(e/1048576),this.buf[this.pos++]=255&Math.floor(e/4096),this.buf[this.pos++]=255&Math.floor(e/4),this.buf[this.pos++]=15&e)}WriteByteNeg(e){this.buf[--this.pos]=e}}},5460:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e){return 4095&e}function o(e,t){for(var i=0;t>=e[i+1];)i++;return i}function a(e){for(var t=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=e[i+1];)i++;t[n]=i}return t}function c(e,t,i){return i*(e>>12)+(4095&e)-t}function l(e,t){for(;t<1<<23;)t=(t<<8)+e.ReadByte();return t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<23>>n<<8)*i;e>=r;)t.WriteByteNeg(255&e),e>>=8;return e}(e,t,n,r),(Math.floor(e/n)<0?(o--,r++):(r=e.ReadByte())==s+1&&(o=e.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}function f(e){for(var t=0,i=0;i<256;i++)t+=e[i];const n=4096;var r=n/t;do{var s=0,o=0,a=0;for(t=0,i=0;i<256;i++)0!=e[i]&&(s2?e[o]-=t-n:t!=n&&(r*=.99,a=1)}while(a)}function p(e,t){for(var i=0,n=0;n<256;n++)if(t[n]){if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteITF8(t[n])}e.WriteByte(0)}e.exports={decode:function(e){var t=new r(e),i=t.ReadByte(),h=(t.ReadUint32(),t.ReadUint32());return 0==i?function(e,t){var i=new Array(256),r=new Array(256);u(e,i,r);for(var o=a(r),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var f=new n.allocUnsafe(t);for(d=0;d0?(a--,s++):(s=e.ReadByte())==o+1&&(a=e.ReadByte()),o=s}while(0!=s)}(e,i,r);for(var h=new Array(256),d=0;d<256;d++)h[d]=a(r[d]);for(var f=new Array(4),p=new Array(4),g=0;g<4;g++)f[g]=e.ReadUint32(),p[g]=0;var m=new n.allocUnsafe(t),w=Math.floor(t/4);for(d=0;d=0;a--)c[a%4]=d(c[a%4],u,o[e[a]],s[e[a]],12);for(a=3;a>=0;a--)h(c[a],u);var g=i.pos;return i.buf.writeInt32LE(g-9+(u.length-u.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}(e):function(e){const t=e.length;var i=new r(\"\",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var s=new Array(256),o=new Array(256),a=new Array(256),c=0;c<256;c++)o[c]=new Array(256),a[c]=new Array(256);for(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3}(e,o,s),function(e,t){for(var i=0;i<256;i++)t[i]&&f(e[i])}(o,s),function(e,t,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(e.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,e.WriteByte(n)}p(e,t[r])}e.WriteByte(0)}(i,o,s),c=0;c<256;c++)if(s[c]){a[c][0]=0;for(var l=1;l<256;l++)a[c][l]=a[c][l-1]+o[c][l-1]}var u=new Array(4),g=new Array(4);for(l=0;l<4;l++)u[l]=1<<23,g[l]=0;var m=new r(\"\",t,t),w=Math.floor(t/4),b=new Array(4),F=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*w-2,F[l]=e[b[l]+1];for(F[3]=e[t-1],c=t-2;c>4*w-2;c--)u[3]=d(u[3],m,a[e[c]][F[3]],o[e[c]][F[3]],12),F[3]=e[c];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=e[b[l]];u[l]=d(u[l],m,a[v][F[l]],o[v][F[l]],12),F[l]=v,b[l]--}for(l=3;l>=0;l--)u[l]=d(u[l],m,a[0][F[l]],o[0][F[l]],12);for(c=3;c>=0;c--)h(u[c],m);var y=i.pos;return i.buf.writeInt32LE(y-9+(m.length-m.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e)}}},8223:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e,t){return e&(1<=e[i+1];)i++;return i}function a(e,t){for(var i=1<=e[r+1];)r++;n[s]=r}return n}function c(e,t,i,n){return i*(e>>n)+(e&(1<>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<31-n)*i;e>=r;)t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e),e>>=16;return e}(e,t,n,r),(Math.floor(e/n)<o),n[o]=new Array(s[o]);for(var a=0,c=0;co),a[o]=f(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o>4,h=e;if(1&f){var d=e.ReadUint7(),u=e.ReadUint7(),f=new r(e.ReadData(u));h=new r(m(f,d))}var p=new Array(256),w=new Array(256);!function(e,t,i,n){for(var r=0;r<256;r++){t[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)t[r][s]=0}var o=g(e);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(t[r][s]=e.ReadUint7(),0==t[r][s]&&(a=e.ReadByte())));for(b(t[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+t[r][s]}}(h,p,w,i);for(var F=new Array(256),v=0;v<256;v++)F[v]=a(w[v],i);for(var y=new Array(4),A=new Array(4),C=0;C<4;C++)y[C]=e.ReadUint32(),A[C]=0;var _=new n.allocUnsafe(t),x=Math.floor(t/4);for(v=0;v>=1}else if(i<=4)for(a=0;a>=2;else if(i<=16)for(a=0;a>=4;return s}(x,v,y,F)),x}function p(e,t){var i=new r(\"\",0,10);i.WriteByte(t);var s=1&t,o=8&t,a=32&t,c=64&t,l=128&t,f=t>>8;if(16&t||i.WriteUint7(e.length),o)return n.concat([i.buf.slice(0,i.pos),u(0,e,f)]);var p=new n.alloc(0);l&&([p,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;for(i=0;i0&&(s[i]=o++);if(!(o>16)){if(o<=1)var a=new n.allocUnsafe(0);else if(o<=2){a=new n.allocUnsafe(Math.ceil(e.length/8));var c=-1;for(i=0;i0&&(t[i]=c++,l.WriteByte(i));return l.WriteUint7(a.length),[l.buf.slice(0,l.pos),a]}}(e));var g=new n.alloc(0);if(c&&([g,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var s=-1;for(i=0;i0&&o++;for(o||(o=1,t[0]=1),(h=new r(\"\",0,o+1+e.length)).WriteByte(o),i=0;i<256;i++)t[i]>0&&h.WriteByte(i);var a=new n.allocUnsafe(e.length),c=0;for(i=0;i0){s=e[i];for(var l=0;i+l+1>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3})(e,o,s),function(e,t){for(var i=0;i<256;i++)if(t[i]){var n=Math.ceil(Math.log2(t[i]));n>12&&(n=12),w(e[i],n)}}(o,s);var l=new r(\"\",0,198156);!function(e,t,i){F(e,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(e.WriteUint7(t[n][s]),!t[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=t[n][o])break;r++}e.WriteByte(r)}}(l,o,s);var u=v(l.buf.slice(0,l.pos));for(u.length4*y-2;c--)p[3]=d(p[3],m,a[e[c]][C[3]],o[e[c]][C[3]],12),C[3]=e[c];for(;A[0]>=0;)for(f=3;f>=0;f--){var _=e[A[f]];p[f]=d(p[f],m,a[_][C[f]],o[_][C[f]],12),C[f]=_,A[f]--}for(f=3;f>=0;f--)p[f]=d(p[f],m,a[0][C[f]],o[0][C[f]],12);for(c=3;c>=0;c--)h(p[c],m);return n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e);return n.concat([i.buf.slice(0,i.pos),p,g,m])}function g(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var n=0,r=e.ReadByte(),s=r;do{t[r]=1,n>0?(n--,r++):(r=e.ReadByte())==s+1&&(n=e.ReadByte()),s=r}while(0!=r);return t}function m(e,t){var i=new Array(256),r=new Array(256);!function(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=g(e);for(n=0;n<256;n++)r[n]>0&&(t[n]=e.ReadUint7());for(b(t,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}(e,i,r);for(var o=a(r,12),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var u=new n.allocUnsafe(t);for(d=0;d2?e[a]-=i-r:i!=r&&(s=r/i,c=1)}while(c)}function b(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];if(0!=i&&i!=1<0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteByte(0)}function v(e){const t=e.length;var i=new r(\"\",0,780),s=new Array(256);!function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i12&&(o=12),w(s,o),function(e,t){F(e,t);for(var i=0;i<256;i++)t[i]&&e.WriteUint7(t[i])}(i,s),w(s,12);var a=new Array(256);a[0]=0;for(var c=1;c<256;c++)a[c]=a[c-1]+s[c-1];var l=new Array(4);for(c=0;c<4;c++)l[c]=32768;var u=new r(\"\",1.05*t+100|0,1.05*t+100|0);for(c=t-1;c>=0;c--)l[c%4]=d(l[c%4],u,a[e[c]],s[e[c]],12);for(c=3;c>=0;c--)h(l[c],u);return n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}e.exports={decode:function(e){return f(new r(e),0)},encode:p}},5997:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(8223);var o=new(i(635));function a(e,t){for(var i=e+\"\";i.length0&&5==t[o][0].type)&&t[o][i])switch(e[0].WriteByte(t[o][i].type),t[o][i].type){case 6:e[6].WriteUint32(t[o][i].val);break;case 5:e[5].WriteUint32(t[o][i].val);break;case 1:e[1].WriteString(t[o][i].val);break;case 2:e[2].WriteChar(t[o][i].val);break;case 7:e[7].WriteUint32(t[o][i].val);break;case 3:e[3].WriteUint32(t[o][i].val),e[4].WriteByte(t[o][i].val.length);break;case 8:case 9:e[t[o][i].type].WriteByte(t[o][i].val)}}function h(e,t,i,n){for(var r=0;r<=12;r++)if(!(e[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),e[r]=e[r].buf.slice(0,e[r].pos);var s=d(e[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function d(e,t){var i,n=1<<30,r=[0,1,64,65,128,129,201];for(var a in r){var c=r[a];if(!(1&c&&e.length<100||8&c&&e.length%4!=0)){try{var l=t?o.encode(e,c):s.encode(e,c)}catch(e){l=0}l&&n>l.length&&(n=l.length,i=l)}}return i}function u(e,t,i,n,r){var s=0,o=r-1;e[r]=new Array(256),t[n]?e[r][0]={type:5,val:r-t[n]}:e[r][0]={type:6,val:0==r?0:1},t[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),c=0;c=0&&e[o][l])if(e[o][l].str==a[c])h=10,d=\"\";else if(7==e[o][l].type||8==e[o][l].type){var u=d-e[o][l].str;i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=8,d=u)}else 3!=e[o][l].type&&9!=e[o][l].type||e[o][l].str.length!=d.length||(u=d-e[o][l].str,i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=9,d=u));e[r][l]={str:a[c],val:d,type:h},s{t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),o=s[0],c=s[1],l=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,c)),h=0,d=c>0?o-4:o;for(i=0;i>16&255,l[h++]=t>>8&255,l[h++]=255&t;return 2===c&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,l[h++]=255&t),1===c&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,l=n-r;al?l:a+o));return 1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+\"==\")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+\"=\")),s.join(\"\")};for(var i=[],n=[],r=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function c(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},8287:(e,t,i)=>{const n=i(7526),r=i(251),s=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return d(e)}return l(e,t,i)}function l(e,t,i){if(\"string\"==typeof e)return function(e,t){if(\"string\"==typeof t&&\"\"!==t||(t=\"utf8\"),!c.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|g(e,t);let n=a(i);const r=n.write(e,t);return r!==i&&(n=n.slice(0,r)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,i);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?\"number\"!=typeof e.length||Y(e.length)?a(0):u(e):\"Buffer\"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function h(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function d(e){return h(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),i=a(t);for(let n=0;n=o)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o.toString(16)+\" bytes\");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return W(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return G(e).length;default:if(r)return n?-1:W(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function m(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return N(this,t,i);case\"utf8\":case\"utf-8\":return k(this,t,i);case\"ascii\":return S(this,t,i);case\"latin1\":case\"binary\":return E(this,t,i);case\"base64\":return x(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return B(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function w(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function b(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Y(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:F(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):F(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function F(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function x(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function k(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!c.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;ti&&(e+=\" ... \"),\"\"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,i,n,r){if(K(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),l=this.slice(n,r),h=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return v(this,e,t,i);case\"utf8\":case\"utf-8\":return y(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return A(this,e,t,i);case\"base64\":return C(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return _(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function S(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function R(e,t,i,n,r,s){if(!c.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function D(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function T(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function L(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function z(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,4),r.write(e,t,i,n,23,4),i+4}function H(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,8),r.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||M(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return D(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return T(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return D(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return T(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(e,t,i){return z(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return z(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return H(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return H(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(!c.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function q(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new P.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Q(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||V(t,e.length-(i+1))}(n,r,s)}function Q(e,t){if(\"number\"!=typeof e)throw new P.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function V(e,t,i){if(Math.floor(e)!==e)throw Q(e,i),new P.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}O(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),O(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),O(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=U(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=U(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function W(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(e){return n.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(j,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function $(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}const X=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Z(e){return\"undefined\"==typeof BigInt?J:e}function J(){throw new Error(\"BigInt not supported\")}},235:e=>{var t={array:function(e){var t=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-t;r>=o?(s<<=o,s|=n[o]&e[i++],t=0,r-=o):(s<<=r,s|=(e[i]&n[r]<<8-r-t)>>8-r-t,t+=r,r=0)}return s}},simple:function(e){var i,n,r=t.header(e),s=[],o=0;do{-1!=(n=t.decompress(e,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a9)throw\"Not a BZIP archive\";return t},decompress:function(e,t,i){for(var n=9e5,r=\"\",s=0;s<6;s++)r+=e(8).toString(16);if(\"177245385090\"==r)return-1;if(\"314159265359\"!=r)throw\"eek not valid bzip data\";if(e(32),e(1))throw\"unsupported obsolete version\";var o=e(24);if(o>n)throw\"Initial position larger than buffer size\";var a=e(16),c=new Uint8Array(256),l=0;for(s=0;s<16;s++)if(a&1<<15-s){var h=e(16);for(g=0;g<16;g++)h&1<<15-g&&(c[l++]=16*s+g)}var d=e(3);if(d<2||d>6)throw\"another error\";var u=e(15);if(0==u)throw\"meh\";var f=[];for(s=0;s=d)throw\"whoops another error\";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var w=l+2,b=[];for(g=0;g20)throw\"I gave up a while ago on writing error messages\";if(!e(1))break;e(1)?a--:a++}A[s]=a}for(F=v=A[0],s=1;sv?v=A[s]:A[s]=u)throw\"meow i'm a kitty, that's an error\";_=(y=b[p[E++]]).base.subarray(1),x=y.limit.subarray(1)}for(g=e(s=y.minLen);;){if(s>y.maxLen)throw\"rawr i'm a dinosaur\";if(g<=x[s])break;s++,g=g<<1|e(1)}if((g-=_[s])<0||g>=258)throw\"moo i'm a cow\";var M=y.permute[g];if(0!=M&&1!=M){if(I){if(I=0,S+a>=n)throw\"Boom.\";for(N[m=c[f[0]]]+=a;a--;)B[S++]=m}if(M>l)break;if(S>=n)throw\"I can't think of anything. Error\";m=f[s=M-1],f.splice(s,1),f.splice(0,0,m),N[m=c[m]]++,B[S++]=m}else I||(I=1,a=0),a+=0==M?I:2*I,I<<=1}if(o<0||o>=S)throw\"I'm a monkey and I'm throwing something at someone, namely you\";for(g=0,s=0;s<256;s++)h=g+N[s],N[s]=g,g=h;for(s=0;s>=8,T=-1);var L,z,H,P=new Uint8Array(n),O=0;for(i||(i=1/0);S;){for(S--,z=D,D=255&(R=B[R]),R>>=8,3==T++?(L=D,H=z,D=-1):(L=1,H=D);L--;)if(P[O++]=H,! --i)return P;D!=z&&(T=0)}return P.subarray(0,O)}};e.exports=t},2151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],i=0;i{var t,i;t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",i={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&i.rotl(e,8)|4278255360&i.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],i=0,n=0;i>>5]|=e[i]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],i=0;i<32*e.length;i+=8)t.push(e[i>>>5]>>>24-i%32&255);return t},bytesToHex:function(e){for(var t=[],i=0;i>>4).toString(16)),t.push((15&e[i]).toString(16));return t.join(\"\")},hexToBytes:function(e){for(var t=[],i=0;i>>6*(3-s)&63)):i.push(\"=\");return i.join(\"\")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,\"\");for(var i=[],n=0,r=0;n>>6-2*r);return i}},e.exports=i},1113:(e,t,i)=>{i.r(t),i.d(t,{BlobFile:()=>l,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>h,open:()=>d});var n=i(3617),r=i.n(n),s=i(8287);function o(e){return(\"object\"==typeof e&&null!==e&&\"message\"in e?e.message:`${e}`).replace(/\\.$/,\"\")}class a{async getBufferFromResponse(e){const t=await e.arrayBuffer();return s.Buffer.from(t)}constructor(e,t={}){this.baseOverrides={},this.url=e;const i=t.fetch||globalThis.fetch.bind(globalThis);if(!i)throw new TypeError(\"no fetch function supplied, and none found in global environment\");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=i}async fetch(e,t){let i;try{i=await this.fetchImplementation(e,t)}catch(n){if(!`${n}`.includes(\"Failed to fetch\"))throw new Error(`${o(n)} fetching ${e}`,{cause:n});console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`);try{i=await this.fetchImplementation(e,{...t,cache:\"reload\"})}catch(t){throw new Error(`${o(t)} fetching ${e}`,{cause:t})}}return i}async read(e,t=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const c=await this.fetch(this.url,{...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:o});if(!c.ok)throw new Error(`HTTP ${c.status} fetching ${this.url}`);if(200===c.status&&0===n||206===c.status){const n=await this.getBufferFromResponse(c),r=n.copy(e,t,0,Math.min(i,n.length)),s=c.headers.get(\"content-range\"),o=/\\/(\\d+)$/.exec(s||\"\");return(null==o?void 0:o[1])&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:e}}if(200===c.status)throw new Error(`${this.url} fetch returned status 200, expected 206`);throw new Error(`HTTP ${c.status} fetching ${this.url}`)}async readFile(e={}){let t,i;\"string\"==typeof e?(t=e,i={}):(t=e.encoding,i=e,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o=await this.fetch(this.url,{headers:n,method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:r,...this.baseOverrides,...s});if(200!==o.status)throw new Error(`HTTP ${o.status} fetching ${this.url}`);if(\"utf8\"===t)return o.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(o)}async stat(){if(!this._stat){const e=s.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function c(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"!=typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsArrayBuffer(e)}))}class l{constructor(e){this.blob=e,this.size=e.size}async read(e,t=0,i,n=0){if(!i)return{bytesRead:0,buffer:e};const r=n,o=r+i,a=await c(this.blob.slice(r,o)),l=s.Buffer.from(a);return{bytesRead:l.copy(e,t),buffer:l}}async readFile(e){const t=\"string\"==typeof e?e:null==e?void 0:e.encoding;if(\"utf8\"===t)return function(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"==typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsText(e)}))}(this.blob);if(t)throw new Error(`unsupported encoding: ${t}`);const i=await c(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function h(e,t={}){return new a(e,t)}function d(e,t,i,n={}){if(void 0!==i)return i;if(void 0!==e)return h(e,n);if(void 0!==t)return new(r())(t,n);throw new Error(\"no url, path, or filehandle provided, cannot open\")}},251:(e,t)=>{t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}},8570:e=>{e.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,\"__isLong__\",{value:!0}),i.isLong=n;var r={},s={};function o(e,t){var i,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(i=c(e,(0|e)<0?-1:0,!0),o&&(s[e]=i),i):(o=-128<=(e|=0)&&e<128)&&(n=r[e])?n:(i=c(e,e<0?-1:0,!1),o&&(r[e]=i),i)}function a(e,t){if(isNaN(e))return t?w:m;if(t){if(e<0)return w;if(e>=f)return A}else{if(e<=-p)return C;if(e+1>=p)return y}return e<0?a(-e,t).neg():c(e%u|0,e/u|0,t)}function c(e,t,n){return new i(e,t,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=c;var l=Math.pow;function h(e,t,i){if(0===e.length)throw Error(\"empty string\");if(\"NaN\"===e||\"Infinity\"===e||\"+Infinity\"===e||\"-Infinity\"===e)return m;if(\"number\"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||360)throw Error(\"interior hyphen\");if(0===n)return h(e.substring(1),t,i).neg();for(var r=a(l(i,8)),s=m,o=0;o>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=c).isZero())return h+o;for(;h.length<6;)h=\"0\"+h;o=\"\"+h+o}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(C)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.ne=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.le=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.ge=_.greaterThanOrEqual,_.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(b)},_.neg=_.negate,_.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,a=65535&e.high,l=e.low>>>16,h=0,u=0,f=0,p=0;return f+=(p+=s+(65535&e.low))>>>16,u+=(f+=r+l)>>>16,h+=(u+=i+a)>>>16,h+=t+o,c((f&=65535)<<16|(p&=65535),(h&=65535)<<16|(u&=65535),this.unsigned)},_.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return m;if(n(e)||(e=d(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(C))return e.isOdd()?C:m;if(e.eq(C))return this.isOdd()?C:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return a(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,l=e.high>>>16,h=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,w=0,b=0,F=0;return b+=(F+=o*f)>>>16,w+=(b+=s*f)>>>16,b&=65535,w+=(b+=o*u)>>>16,p+=(w+=r*f)>>>16,w&=65535,p+=(w+=s*u)>>>16,w&=65535,p+=(w+=o*h)>>>16,p+=i*f+r*u+s*h+o*l,c((b&=65535)<<16|(F&=65535),(p&=65535)<<16|(w&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error(\"division by zero\");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return w;if(e.gt(this.shru(1)))return F;s=w}else{if(this.eq(C))return e.eq(b)||e.eq(v)?C:e.eq(C)?b:(i=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?b:v:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(C))return this.unsigned?w:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=m}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),h=o<=48?1:l(2,o-48),u=a(i),f=u.mul(e);f.isNegative()||f.gt(r);)f=(u=a(i-=h,this.unsigned)).mul(e);u.isZero()&&(u=b),s=s.add(u),r=r.sub(f)}return s},_.div=_.divide,_.modulo=function(e){return n(e)||(e=d(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.rem=_.modulo,_.not=function(){return c(~this.low,~this.high,this.unsigned)},_.and=function(e){return n(e)||(e=d(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return n(e)||(e=d(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return n(e)||(e=d(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low<>>32-e,this.unsigned):c(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?c(this.low>>>e|t<<32-e,t>>>e,this.unsigned):c(32===e?t:t>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.shr_u=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},_.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},3503:(e,t,i)=>{var n,r,s,o,a;n=i(3939),r=i(2151).utf8,s=i(652),o=i(2151).bin,(a=function(e,t){e.constructor==String?e=t&&\"binary\"===t.encoding?o.stringToBytes(e):r.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var i=n.bytesToWords(e),c=8*e.length,l=1732584193,h=-271733879,d=-1732584194,u=271733878,f=0;f>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[c>>>5]|=128<>>9<<4)]=c;var p=a._ff,g=a._gg,m=a._hh,w=a._ii;for(f=0;f>>0,h=h+F>>>0,d=d+v>>>0,u=u+y>>>0}return n.endian([l,h,d,u])})._ff=function(e,t,i,n,r,s,o){var a=e+(t&i|~t&n)+(r>>>0)+o;return(a<>>32-s)+t},a._gg=function(e,t,i,n,r,s,o){var a=e+(t&n|i&~n)+(r>>>0)+o;return(a<>>32-s)+t},a._hh=function(e,t,i,n,r,s,o){var a=e+(t^i^n)+(r>>>0)+o;return(a<>>32-s)+t},a._ii=function(e,t,i,n,r,s,o){var a=e+(i^(t|~n))+(r>>>0)+o;return(a<>>32-s)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error(\"Illegal argument \"+e);var i=n.wordsToBytes(a(e,t));return t&&t.asBytes?i:t&&t.asString?o.bytesToString(i):n.bytesToHex(i)}},652:e=>{function t(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return\"function\"==typeof e.readFloatLE&&\"function\"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},1668:(e,t,i)=>{var n={};(0,i(9805).assign)(n,i(3303),i(7083),i(9681)),e.exports=n},3303:(e,t,i)=>{var n=i(8411),r=i(9805),s=i(1996),o=i(4674),a=i(4442),c=Object.prototype.toString,l=0,h=-1,d=0,u=8;function f(e){if(!(this instanceof f))return new f(e);this.options=r.assign({level:h,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==l)throw new Error(o[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p=\"string\"==typeof t.dictionary?s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=n.deflateSetDictionary(this.strm,p))!==l)throw new Error(o[i]);this._dict_set=!0}}function p(e,t){var i=new f(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}f.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,\"string\"==typeof e?a.input=s.string2buf(e):\"[object ArrayBuffer]\"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&i!==l)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||(\"string\"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===l):2!==o||(this.onEnd(l),a.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===l&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},7083:(e,t,i)=>{var n=i(1447),r=i(9805),s=i(1996),o=i(9681),a=i(4674),c=i(4442),l=i(7414),h=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new l,n.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===h.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[i])}function u(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(e,t){var i,a,c,l,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,\"string\"==typeof e?u.input=s.binstring2buf(e):\"[object ArrayBuffer]\"===h.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new r.Buf8(f),u.next_out=0,u.avail_out=f),(i=n.inflate(u,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==o.Z_STREAM_END&&(0!==u.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||(\"string\"===this.options.to?(c=s.utf8border(u.output,u.next_out),l=u.next_out-c,d=s.buf2string(u.output,c),u.next_out=l,u.avail_out=f-l,l&&r.arraySet(u.output,u.output,c,l,0),this.onData(d)):this.onData(r.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=d,t.inflate=u,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.ungzip=u},9805:(e,t)=>{var i=\"undefined\"!=typeof Uint8Array&&\"undefined\"!=typeof Uint16Array&&\"undefined\"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,n,r){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),r);else for(var s=0;s{var n=i(9805),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var i=\"\",o=0;o>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},t.buf2binstring=function(e){return c(e,e.length)},t.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i4)l[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?l[n++]=65533:r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|1023&r)}return c(l,n)},t.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},3269:e=>{e.exports=function(e,t,i,n){for(var r=65535&e,s=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16}},9681:e=>{e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:e=>{var t=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();e.exports=function(e,i,n,r){var s=t,o=r+n;e^=-1;for(var a=r;a>>8^s[255&(e^i[a])];return~e}},8411:(e,t,i)=>{var n,r=i(9805),s=i(3665),o=i(3269),a=i(4823),c=i(4674),l=0,h=0,d=-2,u=2,f=8,p=286,g=30,m=19,w=2*p+1,b=15,F=3,v=258,y=v+F+1,A=42,C=103,_=113,x=666;function k(e,t){return e.msg=c[t],t}function I(e){return(e<<1)-(e>4?9:0)}function S(e){for(var t=e.length;--t>=0;)e[t]=0}function E(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function N(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,E(e.strm)}function B(e,t){e.pending_buf[e.pending++]=t}function M(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function R(e,t,i,n){var s=e.avail_in;return s>n&&(s=n),0===s?0:(e.avail_in-=s,r.arraySet(t,e.input,e.next_in,s,i),1===e.state.wrap?e.adler=o(e.adler,t,s,i):2===e.state.wrap&&(e.adler=a(e.adler,t,s,i)),e.next_in+=s,e.total_in+=s,s)}function D(e,t){var i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-y?e.strstart-(e.w_size-y):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+v,f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead}function T(e){var t,i,n,s,o,a=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-y)){r.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=i=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--i);t=i=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--i);s+=a}if(0===e.strm.avail_in)break;if(i=R(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=F)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<=F)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-F,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<15&&(a=2,n-=16),s<1||s>9||i!==f||n<8||n>15||t<0||t>9||o<0||o>4)return k(e,d);8===n&&(n=9);var c=new P;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=n,c.w_size=1<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(T(e),0===e.lookahead&&t===l)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-y&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),1)})),new H(4,4,8,4,L),new H(4,5,16,8,L),new H(4,6,32,32,L),new H(4,4,16,16,z),new H(8,16,32,32,z),new H(8,16,128,128,z),new H(8,32,128,256,z),new H(32,128,258,1024,z),new H(32,258,258,4096,z)],t.deflateInit=function(e,t){return q(e,t,f,15,8,0)},t.deflateInit2=q,t.deflateReset=U,t.deflateResetKeep=O,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?d:(e.state.gzhead=t,h):d},t.deflate=function(e,t){var i,r,o,c;if(!e||!e.state||t>5||t<0)return e?k(e,d):d;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===x&&4!==t)return k(e,0===e.avail_out?-5:d);if(r.strm=e,i=r.last_flush,r.last_flush=t,r.status===A)if(2===r.wrap)e.adler=0,B(r,31),B(r,139),B(r,8),r.gzhead?(B(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),B(r,255&r.gzhead.time),B(r,r.gzhead.time>>8&255),B(r,r.gzhead.time>>16&255),B(r,r.gzhead.time>>24&255),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(B(r,255&r.gzhead.extra.length),B(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(B(r,0),B(r,0),B(r,0),B(r,0),B(r,0),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,3),r.status=_);else{var u=f+(r.w_bits-8<<4)<<8;u|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(u|=32),u+=31-u%31,r.status=_,M(r,u),0!==r.strstart&&(M(r,e.adler>>>16),M(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending!==r.pending_buf_size));)B(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.status=C)}else r.status=C;if(r.status===C&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&E(e),r.pending+2<=r.pending_buf_size&&(B(r,255&e.adler),B(r,e.adler>>8&255),e.adler=0,r.status=_)):r.status=_),0!==r.pending){if(E(e),0===e.avail_out)return r.last_flush=-1,h}else if(0===e.avail_in&&I(t)<=I(i)&&4!==t)return k(e,-5);if(r.status===x&&0!==e.avail_in)return k(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==l&&r.status!==x){var p=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(T(e),0===e.lookahead)){if(t===l)return 1;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,n,r,o,a=e.window;;){if(e.lookahead<=v){if(T(e),e.lookahead<=v&&t===l)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&e.strstart>0&&(n=a[r=e.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=e.strstart+v;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=s._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):n[r.level].func(r,t);if(3!==p&&4!==p||(r.status=x),1===p||3===p)return 0===e.avail_out&&(r.last_flush=-1),h;if(2===p&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(S(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),E(e),0===e.avail_out))return r.last_flush=-1,h}return 4!==t?h:r.wrap<=0?1:(2===r.wrap?(B(r,255&e.adler),B(r,e.adler>>8&255),B(r,e.adler>>16&255),B(r,e.adler>>24&255),B(r,255&e.total_in),B(r,e.total_in>>8&255),B(r,e.total_in>>16&255),B(r,e.total_in>>24&255)):(M(r,e.adler>>>16),M(r,65535&e.adler)),E(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?h:1)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==A&&69!==t&&73!==t&&91!==t&&t!==C&&t!==_&&t!==x?k(e,d):(e.state=null,t===_?k(e,-3):h):d},t.deflateSetDictionary=function(e,t){var i,n,s,a,c,l,u,f,p=t.length;if(!e||!e.state)return d;if(2===(a=(i=e.state).wrap)||1===a&&i.status!==A||i.lookahead)return d;for(1===a&&(e.adler=o(e.adler,t,p,0)),i.wrap=0,p>=i.w_size&&(0===a&&(S(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new r.Buf8(i.w_size),r.arraySet(f,t,p-i.w_size,i.w_size,0),t=f,p=i.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,T(i);i.lookahead>=F;){n=i.strstart,s=i.lookahead-(F-1);do{i.ins_h=(i.ins_h<{e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}},7293:e=>{e.exports=function(e,t){var i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x,k;i=e.state,n=e.next_in,x=e.input,r=n+(e.avail_in-5),s=e.next_out,k=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,w=(1<>>=v=F>>>24,p-=v,0==(v=F>>>16&255))k[s++]=65535&F;else{if(!(16&v)){if(64&v){if(32&v){i.mode=12;break e}e.msg=\"invalid literal/length code\",i.mode=30;break e}F=g[(65535&F)+(f&(1<>>=v,p-=v),p<15&&(f+=x[n++]<>>=v=F>>>24,p-=v,16&(v=F>>>16&255)){if(A=65535&F,p<(v&=15)&&(f+=x[n++]<c){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(f>>>=v,p-=v,A>(v=s-o)){if((v=A-v)>h&&i.sane){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(C=0,_=u,0===d){if(C+=l-v,v2;)k[s++]=_[C++],k[s++]=_[C++],k[s++]=_[C++],y-=3;y&&(k[s++]=_[C++],y>1&&(k[s++]=_[C++]))}else{C=s-A;do{k[s++]=k[C++],k[s++]=k[C++],k[s++]=k[C++],y-=3}while(y>2);y&&(k[s++]=k[C++],y>1&&(k[s++]=k[C++]))}break}if(64&v){e.msg=\"invalid distance code\",i.mode=30;break e}F=m[(65535&F)+(f&(1<>3,f&=(1<<(p-=y<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n{var n=i(9805),r=i(3269),s=i(4823),o=i(7293),a=i(1998),c=0,l=-2,h=1,d=12,u=30,f=852,p=592;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(f),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,c):l}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,w(e)):l}function F(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,b(e))):l}function v(e,t){var i,n;return e?(n=new m,e.state=n,n.window=null,(i=F(e,t))!==c&&(e.state=null),i):l}var y,A,C=!0;function _(e){if(C){var t;for(y=new n.Buf32(512),A=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,y,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,A,0,e.work,{bits:5}),C=!1}e.lencode=y,e.lenbits=9,e.distcode=A,e.distbits=5}function x(e,t,i,r){var s,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(n.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,t,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,t,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=s(i.check,O,2,0),v=0,y=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg=\"incorrect header check\",i.mode=u;break}if(8!=(15&v)){e.msg=\"unknown compression method\",i.mode=u;break}if(y-=4,T=8+(15&(v>>>=4)),0===i.wbits)i.wbits=T;else if(T>i.wbits){e.msg=\"invalid window size\",i.mode=u;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=3;case 3:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>8&255,O[2]=v>>>16&255,O[3]=v>>>24&255,i.check=s(i.check,O,4,0)),v=0,y=0,i.mode=4;case 4:for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>8),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=5;case 5:if(1024&i.flags){for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((k=i.length)>b&&(k=b),k&&(i.head&&(T=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,f,m,k,T)),512&i.flags&&(i.check=s(i.check,f,k,m)),b-=k,m+=k,i.length-=k),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===b)break e;k=0;do{T=f[m+k++],i.head&&T&&i.length<65536&&(i.head.name+=String.fromCharCode(T))}while(T&&k>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=d;break;case 10:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>=7&y,y-=7&y,i.mode=27;break}for(;y<3;){if(0===b)break e;b--,v+=f[m++]<>>=1)){case 0:i.mode=14;break;case 1:if(_(i),i.mode=20,6===t){v>>>=2,y-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=u}v>>>=2,y-=2;break;case 14:for(v>>>=7&y,y-=7&y;y<32;){if(0===b)break e;b--,v+=f[m++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=u;break}if(i.length=65535&v,v=0,y=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(k=i.length){if(k>b&&(k=b),k>F&&(k=F),0===k)break e;n.arraySet(p,f,m,k,w),b-=k,m+=k,F-=k,w+=k,i.length-=k;break}i.mode=d;break;case 17:for(;y<14;){if(0===b)break e;b--,v+=f[m++]<>>=5,y-=5,i.ndist=1+(31&v),v>>>=5,y-=5,i.ncode=4+(15&v),v>>>=4,y-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=u;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,y-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,z={bits:i.lenbits},L=a(0,i.lens,0,19,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid code lengths set\",i.mode=u;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=E,y-=E,i.lens[i.have++]=B;else{if(16===B){for(H=E+2;y>>=E,y-=E,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=u;break}T=i.lens[i.have-1],k=3+(3&v),v>>>=2,y-=2}else if(17===B){for(H=E+3;y>>=E)),v>>>=3,y-=3}else{for(H=E+7;y>>=E)),v>>>=7,y-=7}if(i.have+k>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=u;break}for(;k--;)i.lens[i.have++]=T}}if(i.mode===u)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=u;break}if(i.lenbits=9,z={bits:i.lenbits},L=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid literal/lengths set\",i.mode=u;break}if(i.distbits=6,i.distcode=i.distdyn,z={bits:i.distbits},L=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,z),i.distbits=z.bits,L){e.msg=\"invalid distances set\",i.mode=u;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(b>=6&&F>=258){e.next_out=w,e.avail_out=F,e.next_in=m,e.avail_in=b,i.hold=v,i.bits=y,o(e,C),w=e.next_out,p=e.output,F=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,v=i.hold,y=i.bits,i.mode===d&&(i.back=-1);break}for(i.back=0;N=(P=i.lencode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,i.length=B,0===N){i.mode=26;break}if(32&N){i.back=-1,i.mode=d;break}if(64&N){e.msg=\"invalid literal/length code\",i.mode=u;break}i.extra=15&N,i.mode=22;case 22:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;N=(P=i.distcode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,64&N){e.msg=\"invalid distance code\",i.mode=u;break}i.offset=B,i.extra=15&N,i.mode=24;case 24:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=u;break}i.mode=25;case 25:if(0===F)break e;if(k=C-F,i.offset>k){if((k=i.offset-k)>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=u;break}k>i.wnext?(k-=i.wnext,I=i.wsize-k):I=i.wnext-k,k>i.length&&(k=i.length),S=i.window}else S=p,I=w-i.offset,k=i.length;k>F&&(k=F),F-=k,i.length-=k;do{p[w++]=S[I++]}while(--k);0===i.length&&(i.mode=21);break;case 26:if(0===F)break e;p[w++]=i.length,F--,i.mode=21;break;case 27:if(i.wrap){for(;y<32;){if(0===b)break e;b--,v|=f[m++]<{var n=i(9805),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,i,c,l,h,d,u){var f,p,g,m,w,b,F,v,y,A=u.bits,C=0,_=0,x=0,k=0,I=0,S=0,E=0,N=0,B=0,M=0,R=null,D=0,T=new n.Buf16(16),L=new n.Buf16(16),z=null,H=0;for(C=0;C<=15;C++)T[C]=0;for(_=0;_=1&&0===T[k];k--);if(I>k&&(I=k),0===k)return l[h++]=20971520,l[h++]=20971520,u.bits=1,0;for(x=1;x0&&(0===e||1!==k))return-1;for(L[1]=0,C=1;C<15;C++)L[C+1]=L[C]+T[C];for(_=0;_852||2===e&&B>592)return 1;for(;;){F=C-E,d[_]b?(v=z[H+d[_]],y=R[D+d[_]]):(v=96,y=0),f=1<>E)+(p-=f)]=F<<24|v<<16|y}while(0!==p);for(f=1<>=1;if(0!==f?(M&=f-1,M+=f):M=0,_++,0==--T[C]){if(C===k)break;C=t[i+d[_]]}if(C>I&&(M&m)!==g){for(0===E&&(E=I),w+=x,N=1<<(S=C-E);S+E852||2===e&&B>592)return 1;l[g=M&m]=I<<24|S<<16|w-h}}return 0!==M&&(l[w+M]=C-E<<24|64<<16),u.bits=I,0}},4674:e=>{e.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},3665:(e,t,i)=>{var n=i(9805);function r(e){for(var t=e.length;--t>=0;)e[t]=0}var s=15,o=16,a=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);r(d);var u=new Array(60);r(u);var f=new Array(512);r(f);var p=new Array(256);r(p);var g=new Array(29);r(g);var m,w,b,F=new Array(30);function v(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}function y(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?f[e]:f[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function _(e,t,i){e.bi_valid>o-i?(e.bi_buf|=t<>o-e.bi_valid,e.bi_valid+=i-o):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1}function I(e,t,i){var n,r,o=new Array(s+1),a=0;for(n=1;n<=s;n++)o[n]=a=a+i[n-1]<<1;for(r=0;r<=t;r++){var c=e[2*r+1];0!==c&&(e[2*r]=k(o[c]++,c))}}function S(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function E(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function N(e,t,i,n){var r=2*t,s=2*i;return e[r]>1;i>=1;i--)B(e,o,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],B(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,o[2*r]=o[2*i]+o[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,o[2*i+1]=o[2*n+1]=r,e.heap[1]=r++,B(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,o,a,c,l=t.dyn_tree,h=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(o=0;o<=s;o++)e.bl_count[o]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(o=l[2*l[2*(n=e.heap[i])+1]+1]+1)>g&&(o=g,m++),l[2*n+1]=o,n>h||(e.bl_count[o]++,a=0,n>=p&&(a=f[n-p]),c=l[2*n],e.opt_len+=c*(o+a),u&&(e.static_len+=c*(d[2*n+1]+a)));if(0!==m){do{for(o=g-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[g]--,m-=2}while(m>0);for(o=g;0!==o;o--)for(n=e.bl_count[o];0!==n;)(r=e.heap[--i])>h||(l[2*r+1]!==o&&(e.opt_len+=(o-l[2*r+1])*l[2*r],l[2*r+1]=o),n--)}}(e,t),I(o,h,e.bl_count)}function D(e,t,i){var n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a>=7;n<30;n++)for(F[n]=r<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),o=function(e){var t;for(D(e,e.dyn_ltree,e.l_desc.max_code),D(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?z(e,t,i,n):4===e.strategy||s===r?(_(e,2+(n?1:0),3),M(e,d,u)):(_(e,4+(n?1:0),3),function(e,t,i,n){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,n-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(p[i]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){_(e,2,3),x(e,256,d),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},4442:e=>{e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},7392:e=>{class t{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError(\"`maxSize` must be a number greater than 0\");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}e.exports=t},1307:function(e,t,i){var n;n=e=>(()=>{var t=[,e=>{e.exports=\"data:application/wasm;base64,AGFzbQEAAAABOApgAX8Bf2ABfwBgAABgA39/fwF/YAABf2ACf38AYAN/f34BfmACf38Bf2AEf39/fwF/YAN/f38AAyEgAAABAgMDAwMEAQUAAgMCBgcIBwUDAAMHAQcABwcBAwkFAwEAAgYIAX8BQfCgBAsHTgUGbWVtb3J5AgAOY3JlYXRlX2NvbnRleHQACA9kZXN0cm95X2NvbnRleHQACQxzdXBwbHlfaW5wdXQACg9nZXRfbmV4dF9vdXRwdXQACwqNYCDfAgEFf0EAIQECQCAAQQdqIgJBEEkNAEEBIQEgAkEDdiIDQQJGDQBBAiEBIAJBIEkNAEEDIQEgA0EERg0AQQQhASACQTBJDQBBBSEBIANBBkYNAEEGIQEgAkHIAEkNAEEHIQEgAkHYAEkNAEEIIQEgAkGIAUkNAEEJIQEgAkGIAkkNACAAEIGAgIAAIgBBCGpBACAAGw8LAkACQCABQQJ0QcCIgIAAaiIEKAIAIgANAEEAIQACQAJAQQAoAuSIgIAAIgJFDQBBACACKAIANgLkiICAAAwBC0EAEIGAgIAAIgJFDQILIAJBgIB8cSIAIAJBCHZB/wFxIgJyIAE6AAAgAkEIdCAAckGAAmohAEEAIQJBACABQQJ0QYCIgIAAaigCACIDayEFIAMhAQNAIAAgBWoiACACNgIAIAAhAiABIANqIgFBgQJJDQALIAQgADYCAAsgBCAAKAIANgIACyAAC+4HAQd/AkACQAJAAkACQEEALQC0iICAAEUNAEEAQQA6ALSIgIAAQQAoArCIgIAAIgFFDQFBsIiAgAAhAgNAAkACQCABQQhqIgMgASgCBCIEaiIFQQh2Qf8BcSIGDQAgASECDAELAkADQCAFQYCAfHEgBmotAABB/gFHDQFBsIiAgAAhBgNAIAYiBygCACIGIAVHDQALIAcgBSgCADYCACABIAQgBSgCBGpBCGoiBDYCBCAHIAIgAiAFRhshAiADIARqIgVBCHZB/wFxIgYNAAsLIAIoAgAhAgsgAigCACIBDQALC0EAKAKwiICAACIFRQ0AIABBhwJqQYB+cSEDQX8hAkGwiICAACEEQQAhAUGwiICAACEGA0AgBiEHAkAgBSIGKAIEIgUgAEkNACAFIAJPDQAgBSECIAchBCAGIQEgBUEIaiADRw0AIAchBCAFIQIgBiEBDAQLIAYoAgAiBQ0ACyABDQIMAQtBsIiAgAAhBAs/AEEQdCEBIABBiAJqIQdBACEDAkACQEEAKAK4iICAACICRQ0AQQAhBSABIQYMAQtBACABQfCghIAAQf//A2pBgIB8cSIGayICNgK4iICAACACIQULAkAgByAFTQ0AIAcgBWsiByACQQF2IgIgAiAHSRtB//8DaiIHQRB2QABBf0YNAkEAQQAoAriIgIAAIAdBgIB8cSIDajYCuIiAgAALIAZFDQEgBkH/AToAASAGQQAoArCIgIAANgKAAiAGQYQCaiADIAVqQYCAfHFB+H1qIgI2AgAgBkGAAmohAQsgAUGAgHxxIgYgAUEIdkH/AXFyQf8BOgAAIAQgASgCADYCAAJAIAIgAGtBgH5xIgUNACABDwsgASEDAkAgBiABQQhqIgQgAmoiByAFQX9zakGAgHxxRg0AIARB//8DcSEFAkAgAEH3/QNLDQAgBiAEQQh2Qf8BcWpB/gE6AAAgAUEAKAKwiICAADYCACABQYCABCAFayIFNgIEQQAgATYCsIiAgAAQg4CAgAAgBkGEggRqIAIgBWtB+H1qIgU2AgAgBkGBgARqQf8BOgAAIAZBgIIEaiEDIAUgAGtBgH5xIQUMAQsgAiAFaiAAIAVqQX9qQYCAfHFrQYCAfGohBSABIQMLIAMgAygCBCAFazYCBCAFQfgBaiEGIAcgBWtBCHZB/wFxIQUCQANAIAYiB0GAfmohBiAFIgQNAUEBIQUgB0H4AUcNAAsLAkAgB0H4AUYNACACIAFqIAZrQYCAfHEiBSAEakH+AToAACAFIARBCHRqIgVBACgCsIiAgAA2AgAgBSAGNgIEQQAgBTYCsIiAgAAQg4CAgAALIAMPC0EAC3wBAn8CQCAARQ0AAkAgAEGAgHxxIABBCHZB/wFxciIBLQAAIgJB/wFHDQAgAEF4aiIAQQAoArCIgIAANgIAQQAgADYCsIiAgAAgAUH+AToAAEEAQQE6ALSIgIAADwsgACACQQJ0QcCIgIAAaiICKAIANgIAIAIgADYCAAsLawECfwJAQQAoArCIgIAAIgAoAgRB/wFLDQAgAEGAgHxxIgEgAEEIdkH/AXEiAHJBCToAAEEAQQAoArCIgIAAKAIANgKwiICAACABIABBCHRyIgBBACgC5IiAgAA2AgBBACAANgLkiICAAAsLTgECfwJAIAAgAUYNACACRQ0AA0ACQCAALQAAIgMgAS0AACIERg0AQQFBfyADIARLGw8LIAFBAWohASAAQQFqIQAgAkF/aiICDQALC0EAC3gBAX8CQAJAIAAgAU8NACACRQ0BIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ADAILCyAAIAFNDQAgAkUNACABQX9qIQEgAEF/aiEDA0AgAyACaiABIAJqLQAAOgAAIAJBf2oiAg0ACwsgAAssAQF/AkAgAkUNACAAIQMDQCADIAE6AAAgA0EBaiEDIAJBf2oiAg0ACwsgAAuCAQEBfwJAAkAgAEEDcQ0AIAEgAnJBA3ENACACQQRJDQEgAkECdiECIAAhAwNAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIAJBf2oiAg0ADAILCyACRQ0AIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ACwsgAAuIAQECfwJAQQAtAOiIgIAADQBBAEEBOgDoiICAABCMgICAABCOgICAAAtBoIAIEICAgIAAIgBBgIAENgIAQQJBgICAIBCXgICAACEBIABBFGpCgICAgICAwAA3AgAgAEEQaiAAQaCABGo2AgAgAEEIakIANwMAIAAgAEEgajYCBCAAIAE2AhwgAAsVACAAKAIcEJiAgIAAIAAQgoCAgAALFgAgAEEMaiABNgIAIABBCGpBADYCAAsbACAAKAIcIABBBGogAEEMaigCAEUQloCAgAALVAEDf0EAIQADQEEIIQEgACECA0BBACACQQFxa0GghuLtfnEgAkEBdnMhAiABQX9qIgENAAsgAEECdEHwiICAAGogAjYCACAAQQFqIgBBgAJHDQALC0oAIAJBf3MhAgJAIAFFDQADQCACQf8BcSAALQAAc0ECdEHwiICAAGooAgAgAkEIdnMhAiAAQQFqIQAgAUF/aiIBDQALCyACQX9zC10DAX4BfwF+QgAhAANAQQghASAAIQIDQEIAIAJCAYN9QsKenLzd8pW2SYMgAkIBiIUhAiABQX9qIgENAAsgAKdBA3RB8JCAgABqIAI3AwAgAEIBfCIAQoACUg0ACwtLACACQn+FIQICQCABRQ0AA0AgAkL/AYMgADEAAIWnQQN0QfCQgIAAaikDACACQgiIhSECIABBAWohACABQX9qIgENAAsLIAJCf4UL1RACDH8CfgJAAkAgACgCJEUNACAAKAIAIQIMAQtBACECIABBADoAKCAAQgA3AwAgAEIANwMYIABByABqQQBB5AAQhoCAgAAaIABBrAFqQQw2AgALIAAgASgCBCIDNgIQIABBsAFqIQQgAEHgAGohBSAAQcgAaiEGIABBtgFqIQcgAEGoAWohCCABKAIQIQkCQAJAAkACQANAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAIOCgECAAQFBgcICQoPCyABKAIAIQogACgCqAEhAiAAKAKsASELIAEoAgQhDCABKAIIIQ0MAgsgCCAAKAKoASIMakEIaiABKAIAIAEoAgQiAmogASgCCCACayICIAAoAqwBIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0RIABBATYCAAJAIARBqIiAgABBBhCEgICAAEUNAEEFIQwMEgsgB0ECQQAQjYCAgAAgACgAuAFHDRBBBiEMIActAAANESAAIAAtALcBIgI2AiAgAkEESw0RQQEgAnRBE3FFDRELIAEoAgQiDCABKAIIIg1GDQ4CQCABKAIAIgogDGotAAAiCw0AIAAgDDYCECABIAxBAWo2AgRBBiECDAwLQQAhAiAAQQA2AqgBIABBAjYCACAAIAtBAnRBBGoiCzYCrAEgACALNgJACyAIIAJqQQhqIAogDGogDSAMayIMIAsgAmsiAiAMIAJJGyICEIeAgIAAGiABIAIgASgCBGo2AgRBACEMIABBACAAKAKoASACaiICIAIgACgCrAEiC0YbNgKoASACIAtHDQ8gACACQXxqIgI2AqwBQQchDCAEIAJBABCNgICAACAAIAAoAqwBIgtqQbABaigAAEcNDyAAQQI2AqgBIAAtALEBIgJBP3ENDAJAAkAgAkHAAHFFDQAgACAEIAggCxCRgICAAEEBRw0RIAAgACkDCDcDMCAALQCxASECDAELIABCfzcDMAtCfyEOAkAgAkEYdEEYdUF/Sg0AIAAgBCAIIAAoAqwBEJGAgIAAQQFHDRAgACkDCCEOCyAAIA43AzggACgCrAEiDSAAKAKoASICa0ECSQ0PIAAgAkEBaiIKNgKoASAIIAJqQQhqLQAAQSFHDQwgACACQQJqIgs2AqgBIAggCmpBCGotAABBAUcNDCANIAtGDQ8gACACQQNqNgKoASAAKAKwCSAIIAtqQQhqLQAAEJyAgIAAIgwNDyAAKAKoASIMIAAoAqwBIgIgDCACSxshDQJAA0AgDSAMRg0BIAggDEEBaiICNgIAIAQgDGohCyACIQwgCy0AAA0ODAALCyAGQgA3AwAgAEEANgKoASAAQQM2AgAgBkEIakIANwMACyAAIAEoAgQ2AhAgACABKAIQNgIUIAAoArAJIAEQmYCAgAAhDCAAIAApA0ggASgCBCAAKAIQa618Ig43A0ggACAAKQNQIAEoAhAgACgCFCICayILrXwiDzcDUCAOIAApAzBWDQ0gDyAAKQM4Vg0NAkACQAJAAkAgACgCIEF/ag4EAAMDAQMLIAEoAgwgAmogCyAAKAIYEI2AgIAArSEODAELIAEoAgwgAmogCyAAKQMYEI+AgIAAIQ4LIAAgDjcDGAsgDEEBRw0OAkAgACkDMCIOQn9RDQAgDiAGKQMAUg0OCwJAIAApAzgiDkJ/UQ0AQQchDCAOIAApA1BSDQ8LIAAgACkDSCAANQJAfCAAKQNgfCIPNwNgQgQhDgJAAkACQCAAKAIgQX9qDgQBAgIAAgtCCCEOCyAFIA4gD3w3AwALIAAgACkDaCAAKQNQfDcDaCAAIAVBGCAAKAJwEI2AgIAANgJwIABBBDYCACAAIAApA1hCAXw3A1gLAkAgBikDACIOQgODUA0AIA5CAXwhDiABKAIEIQwgASgCCCELA0AgCyAMRg0NIAEgDEEBaiICNgIEIAEoAgAgDGotAAANDiAGIA43AwAgDkIDgyEPIA5CAXwhDiACIQwgD0IAUg0ACwsgAEEFNgIAC0EBIQIgACgCIEF/ag4EBgcHBQcLIAAgARCSgICAACIMQQFHDQsgAEEHNgIAC0EAIAAoAhBrIQggAEGAAWopAwAhDiABKAIEIQwCQANAIA4gCCAMaq18QgODUA0BAkAgDCABKAIIRw0AIAAgARCTgICAAAwLCyABIAxBAWoiAjYCBCABKAIAIAxqIQsgAiEMIAstAAANCwwACwsgACABEJOAgIAAQQchDCAFIABBkAFqQRgQhICAgAANCiAAQQg2AgALIAAgAUEgEJSAgIAAIgxBAUcNCSAAQQk2AgBBDCELIABBDDYCrAEMAQsgACgCrAEhCwsgAEGoAWogACgCqAEiDGpBCGogASgCACABKAIEIgJqIAEoAgggAmsiAiALIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0HIAAQlYCAgAAhDAwHC0EBIQIgACABQcAAEJSAgIAAIgxBAUcNBgwBC0EBIQIgACABQSAQlICAgAAiDEEBRw0FCyAAIAI2AgAMAAsLQQYhDAwCC0EAIQwMAQtBByEMCwJAAkAgACgCJA0AAkACQCAMDgIAAwELQQdBCCABKAIEIAEoAghGGyEMCyABIAk2AhAgASADNgIEIAwPCwJAIAwNACADIAEoAgRHDQAgCSABKAIQRw0AIAAtACghASAAQQE6ACggAUEDdA8LIABBADoAKAsgDAuaAQEDfwJAIAAoAgQiBA0AIABCADcDCAsgAigCACEFA0ACQCAFIANJDQBBAA8LIAEgBWotAAAhBiACIAVBAWoiBTYCACAAIAZB/wBxrSAErYYgACkDCIQ3AwgCQAJAIAZBgAFxDQACQCAGDQBBByEGIAQNAgsgAEEANgIEQQEPC0EHIQYgACAEQQdqIgQ2AgQgBEE/Rw0BCwsgBguhAgIDfwF+IABBkAFqIQIgAUEEaiEDA0ACQCAAIAEoAgAgAyABKAIIEJGAgIAAIgRBAUYNACAAQYABaiIDIAMpAwAgASgCBCAAKAIQIgNrIgKtfDcDACAAIAMgASgCAGogAiAAKAIYEI2AgIAArTcDGCAEDwsCQAJAAkACQAJAIAAoAngOAwACAQMLIAAgACkDCCIFNwOIAQJAIAUgACkDWFENAEEHDwsgAEEBNgJ4DAMLIAAgACkDmAEgACkDCHw3A5gBIAAgAkEYIAAoAqABEI2AgIAANgKgASAAQQE2AnggACAAKQOIAUJ/fCIFNwOIAQwCCyAAQQI2AnggACAAKQOQASAAKQMIfDcDkAELIAApA4gBIQULIAVCAFINAAtBAQtAAQJ/IABBgAFqIgIgAikDACABKAIEIAAoAhAiAmsiA618NwMAIAAgAiABKAIAaiADIAAoAhgQjYCAgACtNwMYC3wBBH8gASgCBCEDIAEoAgghBANAAkAgBCADRw0AQQAPCyABIANBAWoiBTYCBAJAIAEoAgAgA2otAAAgACkDGCAAKAIEIgOtiKdB/wFxRg0AQQcPCyAAIANBCGoiBjYCBCAFIQMgBiACSQ0ACyAAQQA2AgQgAEIANwMYQQELbwEBf0EHIQECQCAAQboBai8AAEHZtAFHDQAgAEG0AWpBBkEAEI2AgIAAIABBsAFqKAAARw0AIABBgAFqKQMAQgKIIAA1ALQBUg0AIABBuAFqLQAADQBBAUEHIAAoAiAgAEG5AWotAABGGyEBCyABC7QCAQR/AkACQCAAKAIkRQ0AIAAoAgAhAwwBC0EAIQMgAEEAOgAoIABCADcDACAAQgA3AxggAEHIAGpBAEHkABCGgICAABogAEGsAWpBDDYCAEEBIQILIABByABqIQQCQAJAA0ACQCADQQpHDQAgASgCBCIDIAEoAggiBUYNAiABKAIAIQYCQANAIAYgA2otAAANASABIANBAWoiAzYCBCAAIAAoAgRBAWpBA3E2AgQgBSADRg0EDAALCwJAIAAoAgRFDQBBBw8LIAAoAiRFDQAgAEEAOgAoIABCADcDACAAQgA3AxggBEEAQeQAEIaAgIAAGiAAQQw2AqwBCyAAIAEQkICAgAAiA0EBRw0CQQohAyAAQQo2AgAMAAsLAkAgAg0AQQAPC0EHQQEgACgCBBshAwsgAwt1AQF/AkBBuAkQgICAgAAiAkUNACACIAA2AiQgAiAAIAEQm4CAgAAiADYCsAkCQCAARQ0AIAJBADoAKCACQgA3AwAgAkIANwMYIAJByABqQQBB5AAQhoCAgAAaIAJBrAFqQQw2AgAgAg8LIAIQgoCAgAALQQALHgACQCAARQ0AIAAoArAJEJ2AgIAAIAAQgoCAgAALC4ARAQx/IABB6N0BaiECIABB1ABqIQMgAEEcaiIEQQhqIQUCQAJAA0AgACgCQCEGAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgASgCBCIHIAEoAggiCEkNACAGQQdGDQEMEgsgBg4JAQIDBAUGBwAJDwsgACgCTCEGDAcLQQEhCSABIAdBAWo2AgQgASgCACAHai0AACIHRQ0IAkACQCAHQd8BSw0AIAdBAUcNAQsgAEGAAjsBUAJAIAAoAjwNACAAIAEoAgwgASgCECIGajYCGCAAIAEoAhQgBms2AiwLIARCADcCACAFQgA3AgAMCwsgAC0AUEUNCgwOCyABIAdBAWo2AgQgASgCACAHai0AACEHIABBAjYCQCAAIAdBCHQgACgCSGo2AkgMDAsgASAHQQFqNgIEIAEoAgAgB2otAAAhByAAQQM2AkAgACAHIAAoAkhqQQFqNgJIDAsLIAEgB0EBajYCBCABKAIAIAdqLQAAIQcgAEEENgJAIAAgB0EIdDYCTAwKCyABIAdBAWo2AgQgASgCACAHai0AACEHIAAgACgCRDYCQCAAIAcgACgCTGpBAWo2AkwMCQsgASAHQQFqNgIEQQchCSABKAIAIAdqLQAAIgdB4AFLDQNBACEGAkACQCAHQS1PDQBBACEIDAELIAdBU2oiByAHQf8BcUEtbiIIQS1sayEHIAhBAWohCAsgAEF/IAh0QX9zNgJ0AkAgB0H/AXFBCUkNACAHQXdqIgcgB0H/AXFBCW4iBkEJbGshByAGQQFqIQYLIAAgBjYCcCAAIAdB/wFxIgc2AmwgBiAHakEESw0DIANCADcCACADQQhqQgA3AgAgA0EQakEANgIAIABBfyAGdEF/czYCcEH4ACEHA0AgACAHakGACDsBACAHQQJqIgdB5N0BRw0ACyAAQQY2AkAgAEEFNgIIIABC/////w83AgALIAAoAkwiCUEFSQ0IAkAgACgCCCIHRQ0AIAdBf2ohBiABKAIEIQcgASgCCCEKA0AgCiAHRg0LIAEgB0EBaiIINgIEIAEoAgAgB2otAAAhByAAIAY2AgggACAHIAAoAgRBCHRyNgIEIAghByAGQX9qIgZBf0cNAAsLIABBBzYCQCAAIAlBe2oiBjYCTAsgACAAKAIgIgcgASgCFCABKAIQayIIIAAoAkgiCiAIIApJGyIIaiAAKAIsIgogCiAHayAISxs2AiggASgCCCIJIAEoAgQiCGshBwJAAkACQCAAKALk3QEiCg0AIAYNAUEAIQYLIABB5N0BaiILIApqQQRqIAEoAgAgCGogByAGIAprIgZBKiAKayIIIAggBksbIgYgBiAHSxsiBxCHgICAABoCQAJAIAcgACgC5N0BIghqIgYgACgCTEcNACALIAhqIAdqQQRqQQBBPyAGaxCGgICAABogACgC5N0BIAdqIQYMAQsCQCAGQRRLDQAgACAGNgLk3QEgASABKAIEIAdqNgIEDAMLIAZBa2ohBgsgAEEANgIQIAAgAjYCDCAAIAY2AhRBByEJIAAQmoCAgABFDQMgACgCECIIIAAoAuTdASIKIAdqSw0DIAAgACgCTCAIayIGNgJMAkAgCiAITQ0AIAAgCiAIayIHNgLk3QEgAiALIAhqQQRqIAcQhYCAgAAaDAILIABBADYC5N0BIAEgASgCBCAIIApraiIINgIEIAEoAggiCSAIayEHCwJAIAdBFUkNACAAIAg2AhAgACABKAIANgIMIAAgCUFraiAIIAZqIAcgBkEVakkbNgIUQQchCSAAEJqAgIAARQ0DIAAoAkwiByAAKAIQIgggASgCBGsiBkkNAyABIAg2AgQgACAHIAZrIgY2AkwgASgCCCAIayIHQRRLDQELIAIgASgCACAIaiAGIAcgByAGSxsiBxCHgICAABogACAHNgLk3QEgASABKAIEIAdqNgIECyAAKAIgIgYgACgCHCIIayEHAkAgACgCPEUNAAJAIAYgACgCLEcNACAAQQA2AiALIAEoAgwgASgCEGogACgCGCAIaiAHEIeAgIAAGiAAKAIgIQYLIAAgBjYCHCABIAEoAhAgB2oiBjYCECAAIAAoAkggB2siBzYCSAJAIAcNAEEHIQkgACgCTA0CIAAoAmgNAiAAKAIEDQIgAEEANgJADAULQQAhCSAGIAEoAhRGDQEgASgCBCABKAIIRw0GIAAoAuTdASAAKAJMTw0GDAELIAAoAkwiCkUNAUEAIQkgCCAHTQ0AA0AgASgCFCIGIAEoAhAiC00NASAAIAogCiAAKAIsIAAoAiAiDGsiDSAIIAdrIgggBiALayIGIAggBkkbIgYgBiANSxsiBiAGIApLGyIGazYCTCAMIAAoAhhqIAEoAgAgB2ogBhCFgICAABogACAAKAIgIAZqIgc2AiACQCAAKAIkIAdPDQAgACAHNgIkCwJAIAAoAjxFDQACQCAHIAAoAixHDQAgAEEANgIgCyABKAIMIAEoAhBqIAEoAgAgASgCBGogBhCFgICAABogACgCICEHCyAAIAc2AhwgASABKAIQIAZqNgIQIAEgASgCBCAGaiIHNgIEIAAoAkwiCkUNAiABKAIIIgggB0sNAAsLIAkPCyAAQQA2AkAMAwsgB0EYdEEYdUF/Sg0BIABBATYCQCAAIAdBEHRBgID8AHE2AkgCQCAHQcABSQ0AIABBBTYCRCAAQQA6AFEMAwsgAC0AUQ0DIABBBjYCRCAHQaABSQ0CIANCADcCACADQRBqQQA2AgAgA0EIakIANwIAQfgAIQcDQCAAIAdqQYAIOwEAIAdBAmoiB0Hk3QFHDQALCyAAQQU2AgggAEL/////DzcCAAwBCyAHQQJLDQEgAEKDgICAgAE3AkAMAAsLQQcPC0EAC/8XARJ/IABBGGohAQJAIABBIGooAgAiAiAAQShqKAIAIgNPDQAgAEHoAGoiBCgCAEUNACABIAQgACgCVBCegICAABogACgCKCEDIAAoAiAhAgsCQCACIANPDQAgAEHcDWohBSAAQegAaiEGIABB4BVqIQcgAEHUAGohCANAIAAoAhAiCSAAKAIUSw0BIAAgACgCZCIKQQV0aiAAKAJ0IAJxIgtBAXRqIgxB+ABqIQ0CQAJAIAAoAgAiBEGAgIAISQ0AIAAoAgQhDgwBCyAAIARBCHQiBDYCACAAIAlBAWoiAzYCECAAIAAoAgRBCHQgACgCDCAJai0AAHIiDjYCBCADIQkLAkACQCAOIARBC3YgDS8BACIPbCIDTw0AIAAgAzYCACANIA9BgBAgD2tBBXZqOwEAIAJBf2ohBAJAIAINACAAKAIsIARqIQQLAkACQCAAKAIkIg8NAEEAIQQMAQsgACgCGCAEai0AACEECyAAKAJwIAJxIAAoAmwiDXQgBEEIIA1rdmohDAJAAkAgCkEGSw0AQQEhBANAIAAgDEGADGxqIARBAXQiBGpB5B1qIQ0CQAJAIANB////B00NACADIQoMAQsgACADQQh0Igo2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiAKQQt2IA0vAQAiD2wiA0kNACAAIA4gA2siDjYCBCAAIAogA2siAzYCACANIA8gD0EFdms7AQAgBEEBciEEDAELIAAgAzYCACANIA9BgBAgD2tBBXZqOwEACyAEQYACSQ0ADAILCyACIAAoAlQiDUF/c2ohBAJAIAIgDUsNACAAKAIsIARqIQQLAkACQCAPDQBBACEQDAELIAAoAhggBGotAAAhEAtBASEEQYACIQ0DQCAAIAxBgAxsaiAQQQF0IhAgDXEiESANaiAEakEBdGpB5B1qIQ8CQAJAIANB////B00NACADIQsMAQsgACADQQh0Igs2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiALQQt2IA8vAQAiCmwiA08iEg0AIAAgAzYCACAKQYAQIAprQQV2aiEKDAELIAAgDiADayIONgIEIAAgCyADayIDNgIAIAogCkEFdmshCkEAIQ0LIA8gCjsBACANIBFzIQ0gBEEBdCASciIEQYACSQ0ACwsgACACQQFqNgIgIAAoAhggAmogBDoAAAJAIAAoAiQgACgCICICTw0AIAAgAjYCJAtBACEDAkAgACgCZCIEQQRJDQACQCAEQQlLDQAgBEF9aiEDDAELIARBemohAwsgACADNgJkDAELIAAgDiADayIONgIEIAAgBCADayIDNgIAIA0gDyAPQQV2azsBACAAIApBAXRqIg9B+ANqIQQCQAJAIANB////B00NACAJIQoMAQsgACADQQh0IgM2AgAgACAJQQFqIgo2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQLAkACQCAOIANBC3YgBC8BACINbCIJSQ0AIAAgDiAJayIONgIEIAAgAyAJayIDNgIAIAQgDSANQQV2azsBACAPQZAEaiENAkACQCADQf///wdNDQAgCiEQDAELIAAgA0EIdCIDNgIAIAAgCkEBaiIQNgIQIAAgDkEIdCAAKAIMIApqLQAAciIONgIECwJAAkAgDiADQQt2IA0vAQAiCWwiBE8NACANIAlBgBAgCWtBBXZqOwEAIAxB2ARqIQMCQCAEQf///wdLDQAgACAEQQh0IgQ2AgAgACAQQQFqNgIQIAAgDkEIdCAAKAIMIBBqLQAAciIONgIECwJAIA4gBEELdiADLwEAIg1sIglJDQAgACAOIAlrNgIEIAAgBCAJazYCACADIA0gDUEFdms7AQAMAgsgAyANQYAQIA1rQQV2ajsBACAAIAk2AgAgAEEBNgJoIABBCUELIAAoAmRBB0kbNgJkDAMLIAAgDiAEayIONgIEIA0gCSAJQQV2azsBACAPQagEaiENAkACQCADIARrIgNB////B00NACAQIQoMAQsgACADQQh0IgM2AgAgACAQQQFqIgo2AhAgACAOQQh0IAAoAgwgEGotAAByIg42AgQLAkACQCAOIANBC3YgDS8BACIEbCIJTw0AIAAgCTYCACANIARBgBAgBGtBBXZqOwEAIAAoAlghAwwBCyAAIA4gCWsiDjYCBCANIAQgBEEFdms7AQAgD0HABGohBAJAIAMgCWsiA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgCkEBajYCECAAIA5BCHQgACgCDCAKai0AAHIiDjYCBAsCQAJAIA4gA0ELdiAELwEAIg1sIglPDQAgACAJNgIAIAQgDUGAECANa0EFdmo7AQAgACgCXCEDDAELIAAgDiAJazYCBCAAIAMgCWs2AgAgACgCYCEDIAAgACgCXDYCYCAEIA0gDUEFdms7AQALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAzYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAHIAsQn4CAgAAMAQsgBCANQYAQIA1rQQV2ajsBACAAIAk2AgAgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIAUgCxCfgICAACAAKAJoIgNBfmpBAyADQQZJGyEKIAAoAgAhA0EBIQ4DQCAAIApBB3RqIA5BAXQiDmpB2AdqIQ0CQAJAIANBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgRBAWo2AhAgACAAKAIEQQh0IAQgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgDS8BACIJbCIPSQ0AIAAgBCAPayIENgIEIAAgAyAPayIDNgIAIA0gCSAJQQV2azsBACAOQQFyIQ4MAQsgACAPNgIAIA0gCUGAECAJa0EFdmo7AQAgDyEDCyAOQcAASQ0ACwJAIA5BQGoiCUEDSw0AIAAgCTYCVAwBCyAAIA5BAXFBAnIiDTYCVCAJQQF2IQ8CQCAJQQ1LDQAgACANIA9Bf2oiDHQiCzYCVEEBIQ0gCCALQQF0akGEC2ohEEE/IA5rIRFBACEPA0AgECARIA1qQQF0aiEOAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA4vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACAOIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDUEBdEEBciENDAELIAAgAzYCACAOIAlBgBAgCWtBBXZqOwEAIA1BAXQhDQsgDCAPQQFqIg9HDQAMAgsLIA9Be2ohDgNAAkAgA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgACgCECIJQQFqNgIQIARBCHQgCSAAKAIMai0AAHIhBAsgACADQQF2IgM2AgAgACAEIANrIgRBH3UiCSANQQF0akEBaiINNgJUIAAgCSADcSAEaiIENgIEIA5Bf2oiDg0ACyAAIA1BBHQiCzYCVEEAIQ9BASEOA0AgACAOQQF0Ig5qQbwNaiENAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA0vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACANIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDkEBciEODAELIAAgAzYCACANIAlBgBAgCWtBBXZqOwEACyAPQQFqIg9BBEcNAAsLAkAgASAGIAAoAlQQnoCAgAANAEEADwsgACgCICECCyACIAAoAihJDQALC0EBIQMCQCAAKAIAIgRB////B0sNACAAIARBCHQ2AgBBASEDIAAgACgCECIEQQFqNgIQIAAgACgCBEEIdCAEIAAoAgxqLQAAcjYCBAsgAwtwAQF/AkBBqN4BEICAgIAAIgJFDQAgAkE0aiABNgIAIAJBPGogADYCAAJAAkACQCAAQX9qDgIAAQILIAIgARCAgICAACIANgIYIAANASACEIKAgIAADAILIAJBADYCGCACQThqQQA2AgALIAIPC0EAC9IBAQJ/QQYhAgJAIAFBJ0sNACAAQTBqIAFBAXFBAnIgAUEBdkELanQiATYCAAJAAkAgAEE8aigCACIDRQ0AQQQhAiABIABBNGooAgBLDQIgAEEsaiABNgIAIANBAkcNACAAQThqIgMoAgAgAU8NACAAIAE2AjggACgCGBCCgICAACAAIAAoAjAQgICAgAAiATYCGCABDQBBAyECDAELQQAhAiAAQQA2AkAgAEHQAGpBAToAACAAQegAakEANgIAIABB5N0BaiEDCyADQQA2AgALIAILIwACQCAAQTxqKAIARQ0AIAAoAhgQgoCAgAALIAAQgoCAgAAL9QEBBH9BACEDAkAgACgCDCACTQ0AIAAoAhggAk0NACABIAEoAgAiBCAAKAIQIAAoAggiBWsiBiAEIAYgBEkbIgRrNgIAIAUgAkF/c2ohAQJAIAUgAksNACAAKAIUIAFqIQELIAAoAgAiAiABai0AACEGQQEhAyAAIAVBAWo2AgggAiAFaiAGOgAAAkAgBEF/aiICRQ0AA0AgACgCACIFQQAgAUEBaiIBIAEgACgCFEYbIgFqLQAAIQQgACAAKAIIIgZBAWo2AgggBSAGaiAEOgAAIAJBf2oiAg0ACwsgACgCDCAAKAIIIgFPDQAgACABNgIMCyADC8gEAQd/AkACQCAAKAIAIgNBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAAKAIEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgAS8BACIGbCIFTw0AIAEgBkGAECAGa0EFdmo7AQAgASACQQR0akEEaiEHQQghCEECIQkMAQsgACAEIAVrIgQ2AgQgASAGIAZBBXZrOwEAAkAgAyAFayIDQf///wdLDQAgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkAgBCADQQt2IAEvAQIiBmwiBU8NACABIAZBgBAgBmtBBXZqOwECIAEgAkEEdGpBhAJqIQdBCCEIQQohCQwBCyAAIAQgBWsiBDYCBCABIAYgBkEFdms7AQIgAUGEBGohByADIAVrIQVBgAIhCEESIQkLIABB6ABqIAk2AgBBASEBA0AgByABQQF0IgFqIQMCQAJAIAVB////B00NACAFIQIMAQsgACAFQQh0IgI2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIAJBC3YgAy8BACIGbCIFSQ0AIAAgBCAFayIENgIEIAAgAiAFayIFNgIAIAMgBiAGQQV2azsBACABQQFyIQEMAQsgACAFNgIAIAMgBkGAECAGa0EFdmo7AQALIAEgCEkNAAsgAEHoAGogASAIayAJajYCAAsLNQEAQYAICy4IAAAAEAAAABgAAAAgAAAAKAAAADAAAABAAAAAUAAAAIAAAAAAAQAA/Td6WFoA\"},t=>{t.exports=e}],i={};function n(e){var r=i[e];if(void 0!==r)return r.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{XzReadableStream:()=>s});var e=n(1);const t=globalThis.ReadableStream||n(2).ReadableStream;class i{constructor(e){this.exports=e.exports,this.memory=this.exports.memory,this.ptr=this.exports.create_context(),this._refresh(),this.bufSize=this.mem32[0],this.inStart=this.mem32[1]-this.ptr,this.inEnd=this.inStart+this.bufSize,this.outStart=this.mem32[4]-this.ptr}supplyInput(e){this._refresh(),this.mem8.subarray(this.inStart,this.inEnd).set(e,0),this.exports.supply_input(this.ptr,e.byteLength),this._refresh()}getNextOutput(){const e=this.exports.get_next_output(this.ptr);if(this._refresh(),0!==e&&1!==e)throw new Error(`get_next_output failed with error code ${e}`);return{outChunk:this.mem8.slice(this.outStart,this.outStart+this.mem32[5]),finished:1===e}}needsMoreInput(){return this.mem32[2]===this.mem32[3]}outputBufferIsFull(){return this.mem32[5]===this.bufSize}resetOutputBuffer(){this.outPos=this.mem32[5]=0}dispose(){this.exports.destroy_context(this.ptr),this.exports=null}_refresh(){this.memory.buffer!==this.mem8?.buffer&&(this.mem8=new Uint8Array(this.memory.buffer,this.ptr),this.mem32=new Uint32Array(this.memory.buffer,this.ptr))}}class s extends t{static _moduleInstancePromise;static _moduleInstance;static async _getModuleInstance(){const t=e.replace(\"data:application/wasm;base64,\",\"\"),i=Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer,n=await WebAssembly.instantiate(i,{});s._moduleInstance=n.instance}constructor(e){let t,n=null;const r=e.getReader();super({async start(e){s._moduleInstance||await(s._moduleInstancePromise||(s._moduleInstancePromise=s._getModuleInstance())),t=new i(s._moduleInstance)},async pull(e){if(t.needsMoreInput()){if(null===n||0===n.byteLength){const{done:e,value:t}=await r.read();e||(n=t)}const e=Math.min(t.bufSize,n.byteLength);t.supplyInput(n.subarray(0,e)),n=n.subarray(e)}const i=t.getNextOutput();e.enqueue(i.outChunk),t.resetOutputBuffer(),i.finished&&(t.dispose(),e.close())},cancel:()=>(t.dispose(),r.cancel())})}}})(),r})(),e.exports=n(i(772))},3617:()=>{},772:()=>{},928:(e,t,i)=>{const n=i(2886).default;e.exports=n,e.exports.default=n},1308:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0});let i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];\"undefined\"!=typeof Int32Array&&(i=new Int32Array(i)),t.default=(e,t)=>{let n=0===t?0:~t;for(let t=0;t>>8;return~n}},2886:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(1308)),s=n(i(7327));t.default=(0,s.default)(\"crc-32\",r.default)},4422:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(8287);t.default=(e,t)=>n.Buffer.from(e,t)},7327:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(4422));t.default=function(e,t){const i=(e,i)=>t((0,r.default)(e),i)>>>0;return i.signed=(e,i)=>t((0,r.default)(e),i),i.unsigned=i,i.model=e,i}}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}return i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i(7806)})(),jp=[],Wp=[],Gp=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,$p=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Kp=0;Kp<64;++Kp)jp[Kp]=$p[Kp],Wp[$p.charCodeAt(Kp)]=Kp;function Yp(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function Xp(e,t,i){for(var n,r,s=[],o=t;o>18&63]+jp[r>>12&63]+jp[r>>6&63]+jp[63&r]);return s.join(\"\")}Wp[\"-\".charCodeAt(0)]=62,Wp[\"_\".charCodeAt(0)]=63;var Zp={byteLength:function(e){var t=Yp(e),i=t[0],n=t[1];return 3*(i+n)/4-n},toByteArray:function(e){var t,i,n=Yp(e),r=n[0],s=n[1],o=new Gp(function(e,t,i){return 3*(t+i)/4-i}(0,r,s)),a=0,c=s>0?r-4:r;for(i=0;i>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===s&&(t=Wp[e.charCodeAt(i)]<<2|Wp[e.charCodeAt(i+1)]>>4,o[a++]=255&t),1===s&&(t=Wp[e.charCodeAt(i)]<<10|Wp[e.charCodeAt(i+1)]<<4|Wp[e.charCodeAt(i+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o},fromByteArray:function(e){for(var t,i=e.length,n=i%3,r=[],s=16383,o=0,a=i-n;oa?a:o+s));return 1===n?(t=e[i-1],r.push(jp[t>>2]+jp[t<<4&63]+\"==\")):2===n&&(t=(e[i-2]<<8)+e[i-1],r.push(jp[t>>10]+jp[t>>4&63]+jp[t<<2&63]+\"=\")),r.join(\"\")}};\n", - "/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Jp={read:function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},write:function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}};\n", - "/*!\n", - " * The buffer module from node.js, for the browser.\n", - " *\n", - " * @author Feross Aboukhadijeh \n", - " * @license MIT\n", - " */const eg=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null,tg=2147483647;function ig(e){if(e>tg)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,ng.prototype),t}function ng(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return og(e)}return rg(e,t,i)}function rg(e,t,i){if(\"string\"==typeof e)return function(e,t){\"string\"==typeof t&&\"\"!==t||(t=\"utf8\");if(!ng.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|hg(e,t);let n=ig(i);const r=n.write(e,t);r!==i&&(n=n.slice(0,r));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Vg(e,Uint8Array)){const t=new Uint8Array(e);return cg(t.buffer,t.byteOffset,t.byteLength)}return ag(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(Vg(e,ArrayBuffer)||e&&Vg(e.buffer,ArrayBuffer))return cg(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(Vg(e,SharedArrayBuffer)||e&&Vg(e.buffer,SharedArrayBuffer)))return cg(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return ng.from(n,t,i);const r=function(e){if(ng.isBuffer(e)){const t=0|lg(e.length),i=ig(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return\"number\"!=typeof e.length||jg(e.length)?ig(0):ag(e);if(\"Buffer\"===e.type&&Array.isArray(e.data))return ag(e.data)}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return ng.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function sg(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function og(e){return sg(e),ig(e<0?0:0|lg(e))}function ag(e){const t=e.length<0?0:0|lg(e.length),i=ig(t);for(let n=0;n=tg)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+tg.toString(16)+\" bytes\");return 0|e}function hg(e,t){if(ng.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Vg(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return Ug(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return qg(e).length;default:if(r)return n?-1:Ug(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function dg(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return xg(this,t,i);case\"utf8\":case\"utf-8\":return yg(this,t,i);case\"ascii\":return Cg(this,t,i);case\"latin1\":case\"binary\":return _g(this,t,i);case\"base64\":return vg(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return kg(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function ug(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function fg(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),jg(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=ng.from(t,n)),ng.isBuffer(t))return 0===t.length?-1:pg(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):pg(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function pg(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function vg(e,t,i){return 0===t&&i===e.length?Zp.fromByteArray(e):Zp.fromByteArray(e.slice(t,i))}function yg(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=Ag)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(ng.isBuffer(t)||(t=ng.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!ng.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},ng.byteLength=hg,ng.prototype._isBuffer=!0,ng.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;tt&&(e+=\" ... \"),\"\"},eg&&(ng.prototype[eg]=ng.prototype.inspect),ng.prototype.compare=function(e,t,i,n,r){if(Vg(e,Uint8Array)&&(e=ng.from(e,e.offset,e.byteLength)),!ng.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),c=this.slice(n,r),l=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return gg(this,e,t,i);case\"utf8\":case\"utf-8\":return mg(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return wg(this,e,t,i);case\"base64\":return bg(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return Fg(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},ng.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const Ag=4096;function Cg(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function Sg(e,t,i,n,r,s){if(!ng.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function Eg(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function Ng(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function Bg(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function Mg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,4),Jp.write(e,t,i,n,23,4),i+4}function Rg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,8),Jp.write(e,t,i,n,52,8),i+8}ng.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},ng.prototype.readUint8=ng.prototype.readUInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),this[e]},ng.prototype.readUint16LE=ng.prototype.readUInt16LE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]|this[e+1]<<8},ng.prototype.readUint16BE=ng.prototype.readUInt16BE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]<<8|this[e+1]},ng.prototype.readUint32LE=ng.prototype.readUInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ng.prototype.readUint32BE=ng.prototype.readUInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ng.prototype.readBigUInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},ng.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||Ig(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},ng.prototype.readInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ng.prototype.readInt16LE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt16BE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ng.prototype.readInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ng.prototype.readBigInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!0,23,4)},ng.prototype.readFloatBE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!1,23,4)},ng.prototype.readDoubleLE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!0,52,8)},ng.prototype.readDoubleBE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!1,52,8)},ng.prototype.writeUintLE=ng.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},ng.prototype.writeUint8=ng.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,255,0),this[t]=255&e,t+1},ng.prototype.writeUint16LE=ng.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeUint16BE=ng.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeUint32LE=ng.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},ng.prototype.writeUint32BE=ng.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigUInt64LE=Gg((function(e,t=0){return Eg(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeBigUInt64BE=Gg((function(e,t=0){return Ng(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},ng.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},ng.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},ng.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigInt64LE=Gg((function(e,t=0){return Eg(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeBigInt64BE=Gg((function(e,t=0){return Ng(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeFloatLE=function(e,t,i){return Mg(this,e,t,!0,i)},ng.prototype.writeFloatBE=function(e,t,i){return Mg(this,e,t,!1,i)},ng.prototype.writeDoubleLE=function(e,t,i){return Rg(this,e,t,!0,i)},ng.prototype.writeDoubleBE=function(e,t,i){return Rg(this,e,t,!1,i)},ng.prototype.copy=function(e,t,i,n){if(!ng.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function zg(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new Dg.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Hg(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||Pg(t,e.length-(i+1))}(n,r,s)}function Hg(e,t){if(\"number\"!=typeof e)throw new Dg.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function Pg(e,t,i){if(Math.floor(e)!==e)throw Hg(e,i),new Dg.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new Dg.ERR_BUFFER_OUT_OF_BOUNDS;throw new Dg.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}Tg(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),Tg(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),Tg(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=Lg(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=Lg(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const Og=/[^+/0-9A-Za-z-_]/g;function Ug(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function qg(e){return Zp.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(Og,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function Qg(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Vg(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function jg(e){return e!=e}const Wg=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Gg(e){return\"undefined\"==typeof BigInt?$g:e}function $g(){throw new Error(\"BigInt not supported\")}class Kg{constructor(e,t){this.position=0,this.url=e,this.config=t,Ht(e)||!1===t.cacheFetches?this.useCache=!1:(this.useCache=!0,this.cache=new Yg({fetch:(e,t)=>this._fetch(e,t),fetchSize:t.fetchSize||1e4}))}async _fetch(e,t){const i={start:e,size:t};this._stat={size:void 0};const n=await Qs.loadArrayBuffer(this.url,Ua(this.config,{range:i}));return ng.from(n)}async read(e,t=0,i=1/0,n=0){if(this.useCache)await this.cache.get(e,t,n,i);else{(await this._fetch(n,i)).copy(e,t)}return{bytesRead:i,buffer:e}}async readFile(){const e=await Qs.loadArrayBuffer(this.url,Ua(this.config));return ng.from(e)}async stat(){if(!this._stat){const e=ng.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class Yg{constructor({fetch:e,fetchSize:t=3e4}){this.fetch=e,this.position=0,this.buffer=ng.allocUnsafe(0),this.fetchSize=t}async get(e,t,i,n){if(e.length=this.position&&i+n<=this.position+this.buffer.length);else{const e=Math.max(n,this.fetchSize);this.buffer=await this.fetch(i,e),this.position=i}const r=t,s=i-this.position,o=s+n;this.buffer.copy(e,r,s,o)}}class Xg{chrAliasTable=new Map;constructor(e,t,i){this.config=e,this.browser=i,this.genome=t,this.cramFile=new Vp.CramFile({filehandle:e.fileHandle?e.fileHandle:new Kg(e.url,e),seqFetch:e.seqFetch||async function(e,t,i){const n=this.genome,r=await this.getHeader(),s=n.getChromosomeName(r.indexToChr[e]);return this.genome.getSequence(s,t-1,i)}.bind(this),checkSequenceMD5:void 0===e.checkSequenceMD5||e.checkSequenceMD5});const n=e.indexFileHandle?e.indexFileHandle:new Kg(e.indexURL,e);this.indexedCramFile=new Vp.IndexedCramFile({cram:this.cramFile,index:new Vp.CraiIndex({filehandle:n}),fetchSizeLimit:e.fetchSizeLimit||1e9}),Mp.setReaderDefaults(this,e)}async getHeader(){if(!this.header){const e=await this.cramFile.getSamHeader(),t={},i=[],n=[];for(let r of e)if(\"SQ\"===r.tag){for(let e of r.data)if(\"SN\"===e.tag){const n=e.value;t[n]=i.length,i.push(n);break}}else\"RG\"===r.tag&&n.push(r.data);this.header={indexToChr:i,chrToIndex:t,chrNames:Object.keys(t),readGroups:n}}return this.header}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async readAlignments(e,t,i){const n=await this.getHeader(),r=await this.#x(e),s=new tp(e,t,i,this.config);if(void 0===r)return s;try{const e=await this.indexedCramFile.getRecordsForRange(r,t,i);for(let a of e){const e=a.sequenceId,c=a.alignmentStart,l=c+a.lengthOnRef;if(e<0)continue;if(e>r||c>i)return;if(e=0&&(t=\"Sequence mismatch. Is this the correct genome for the loaded CRAM?\"),this.browser.alert.present(new Error(t)),e}function o(e,t){const i=new wp;if(i.chr=t[e.sequenceId],i.start=e.alignmentStart-1,i.lengthOnRef=e.lengthOnRef,i.flags=e.flags,i.strand=!(16&e.flags),i.fragmentLength=e.templateLength||e.templateSize,i.mq=e.mappingQuality,i.end=e.alignmentStart+e.lengthOnRef,i.readGroupId=e.readGroupId,e.mate&&void 0!==e.mate.sequenceId){const n=void 0!==e.mate.flags?!(1&e.mate.flags):!(32&e.flags);i.mate={chr:t[e.mate.sequenceId],position:e.mate.alignmentStart,strand:n}}return i.seq=e.getReadBases(),i.qual=e.qualityScores,i.tagDict=e.tags,i.readName=e.readName,function(e,t){const i=[];let n,r,s=0,o=\"\";if(t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef,e.readFeatures)for(let a of e.readFeatures){const e=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(e){case\"S\":case\"I\":case\"i\":case\"N\":case\"D\":if(l>s){const e=l-s;i.push(new xp({start:h-e,seqOffset:s,len:e,type:\"M\"})),s+=e,o+=e+\"M\"}if(\"S\"===e){let n=h;t.scLengthOnRef+=c.length,0===l&&(t.scStart-=c.length,n-=c.length);const r=c.length;i.push(new xp({start:n,seqOffset:s,len:r,type:\"S\"})),s+=r,o+=r+e}else if(\"I\"===e||\"i\"===e){void 0===n&&(n=[]);const t=\"i\"===e?1:c.length;n.push(new xp({start:h,len:t,seqOffset:s,type:\"I\"})),s+=t,o+=t+e}else\"D\"!==e&&\"N\"!==e||(r||(r=[]),r.push({start:h,len:c,type:e}),o+=c+e);break;case\"H\":case\"P\":o+=c+e}}const a=e.readLength-s;a>0&&(i.push(new xp({start:e.alignmentStart+e.lengthOnRef-a-1,seqOffset:s,len:a,type:\"M\"})),o+=a+\"M\");t.blocks=i,t.insertions=n,t.gaps=r,t.cigar=o}(e,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Mp.setPairOrientation(i),i}}}const Zg=2291137574,Jg=2273964779,em=[84,68,70,52],tm=new Uint8Array([66,65,77,1]),im=[67,82,65,77],nm=[31,139],rm=4,sm=new Set([\"narrowpeak\",\"broadpeak\",\"regionpeak\",\"peaks\",\"bedgraph\",\"wig\",\"gff3\",\"gff\",\"gtf\",\"fusionjuncspan\",\"refflat\",\"seg\",\"aed\",\"bed\",\"bedMethyl\",\"vcf\",\"bb\",\"bigbed\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"bw\",\"bigwig\",\"bam\",\"tdf\",\"refgene\",\"genepred\",\"genepredext\",\"bedpe\",\"bp\",\"snp\",\"rmsk\",\"cram\",\"gwas\",\"maf\",\"mut\",\"hiccups\",\"fasta\",\"fa\",\"fna\",\"pytor\",\"hic\",\"qtl\"]);function om(e,t){const i=Math.min(e.length,t.length);if(0==i)return!1;for(let n=0;n=this.start&&e.end<=this.end}overlaps(e){return e.chr===this.chr&&!(e.endthis.end)}extend(e){e.chr===this.chr&&(this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}getLocusString(){if(\"all\"===this.chr)return\"all\";{const e=Rt(Math.floor(this.start)+1),t=Rt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}static fromLocusString(e){if(\"all\"===e)return new lm({chr:\"all\"});const t=e.split(\":\"),i=t[0],n=t[1].split(\"-\"),r=Number.parseInt(n[0].replace(/,/g,\"\"))-1,s=Number.parseInt(n[1].replace(/,/g,\"\"));return new lm({chr:i,start:r,end:s})}}\n", - "/*!\n", - " * vanilla-picker v2.12.1\n", - " * https://vanilla-picker.js.org\n", - " *\n", - " * Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)\n", - " * Released under the ISC license.\n", - " */var hm=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},dm=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1;return(t>0?e.toFixed(t).replace(/0+$/,\"\").replace(/\\.$/,\"\"):e.toString())||\"0\"}var gm=function(){function e(t,i,n,r){hm(this,e);var s=this;if(void 0===t);else if(Array.isArray(t))this.rgba=t;else if(void 0===n){var o=t&&\"\"+t;o&&function(t){if(t.startsWith(\"hsl\")){var i=t.match(/([\\-\\d\\.e]+)/g).map(Number),n=um(i,4),r=n[0],o=n[1],a=n[2],c=n[3];void 0===c&&(c=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,c]}else if(t.startsWith(\"rgb\")){var l=t.match(/([\\-\\d\\.e]+)/g).map(Number),h=um(l,4),d=h[0],u=h[1],f=h[2],p=h[3];void 0===p&&(p=1),s.rgba=[d,u,f,p]}else t.startsWith(\"#\")?s.rgba=e.hexToRgb(t):s.rgba=e.nameToRgb(t)||e.hexToRgb(t)}(o.toLowerCase())}else this.rgba=[t,i,n,void 0===r?1:r]}return dm(e,[{key:\"printRGB\",value:function(e){var t=(e?this.rgba:this.rgba.slice(0,3)).map((function(e,t){return pm(e,3===t?3:0)}));return e?\"rgba(\"+t+\")\":\"rgb(\"+t+\")\"}},{key:\"printHSL\",value:function(e){var t=[360,100,100,1],i=[\"\",\"%\",\"%\",\"\"],n=(e?this.hsla:this.hsla.slice(0,3)).map((function(e,n){return pm(e*t[n],3===n?3:1)+i[n]}));return e?\"hsla(\"+n+\")\":\"hsl(\"+n+\")\"}},{key:\"printHex\",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:\"rgba\",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error(\"No color is set\");return this._rgba=e.hslToRgb(this._hsla)},set:function(e){3===e.length&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:\"rgbString\",get:function(){return this.printRGB()}},{key:\"rgbaString\",get:function(){return this.printRGB(!0)}},{key:\"hsla\",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error(\"No color is set\");return this._hsla=e.rgbToHsl(this._rgba)},set:function(e){3===e.length&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:\"hslString\",get:function(){return this.printHSL()}},{key:\"hslaString\",get:function(){return this.printHSL(!0)}},{key:\"hex\",get:function(){var e=this.rgba.map((function(e,t){return t<3?e.toString(16):Math.round(255*e).toString(16)}));return\"#\"+e.map((function(e){return e.padStart(2,\"0\")})).join(\"\")},set:function(t){this.rgba=e.hexToRgb(t)}}],[{key:\"hexToRgb\",value:function(e){var t=(e.startsWith(\"#\")?e.slice(1):e).replace(/^(\\w{3})$/,\"$1F\").replace(/^(\\w)(\\w)(\\w)(\\w)$/,\"$1$1$2$2$3$3$4$4\").replace(/^(\\w{6})$/,\"$1FF\");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error(\"Unknown hex color; \"+e);var i=t.match(/^(\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)$/).slice(1).map((function(e){return parseInt(e,16)}));return i[3]=i[3]/255,i}},{key:\"nameToRgb\",value:function(t){var i=t.toLowerCase().replace(\"at\",\"T\").replace(/[aeiouyldf]/g,\"\").replace(\"ght\",\"L\").replace(\"rk\",\"D\").slice(-5,4),n=fm[i];return void 0===n?n:e.hexToRgb(n.replace(/\\-/g,\"00\").padStart(6,\"f\"))}},{key:\"rgbToHsl\",value:function(e){var t=um(e,4),i=t[0],n=t[1],r=t[2],s=t[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),c=void 0,l=void 0,h=(o+a)/2;if(o===a)c=l=0;else{var d=o-a;switch(l=h>.5?d/(2-o-a):d/(o+a),o){case i:c=(n-r)/d+(n1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e},h=r<.5?r*(1+n):r+n-r*n,d=2*r-h;o=l(d,h,i+1/3),a=l(d,h,i),c=l(d,h,i-1/3)}var u=[255*o,255*a,255*c].map(Math.round);return u[3]=s,u}}]),e}(),mm=function(){function e(){hm(this,e),this._events=[]}return dm(e,[{key:\"add\",value:function(e,t,i){e.addEventListener(t,i,!1),this._events.push({target:e,type:t,handler:i})}},{key:\"remove\",value:function(t,i,n){this._events=this._events.filter((function(r){var s=!0;return t&&t!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&e._doRemove(r.target,r.type,r.handler),!s}))}},{key:\"destroy\",value:function(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)})),this._events=[]}}],[{key:\"_doRemove\",value:function(e,t,i){e.removeEventListener(t,i,!1)}}]),e}();function wm(e,t,i){var n=!1;function r(e,t,i){return Math.max(t,Math.min(e,i))}function s(e,s,o){if(o&&(n=!0),n){e.preventDefault();var a=t.getBoundingClientRect(),c=a.width,l=a.height,h=s.clientX,d=s.clientY,u=r(h-a.left,0,c),f=r(d-a.top,0,l);i(u/c,f/l)}}function o(e,t){1===(void 0===e.buttons?e.which:e.buttons)?s(e,e,t):n=!1}function a(e,t){1===e.touches.length?s(e,e.touches[0],t):n=!1}e.add(t,\"mousedown\",(function(e){o(e,!0)})),e.add(t,\"touchstart\",(function(e){a(e,!0)})),e.add(window,\"mousemove\",o),e.add(t,\"touchmove\",a),e.add(window,\"mouseup\",(function(e){n=!1})),e.add(t,\"touchend\",(function(e){n=!1})),e.add(t,\"touchcancel\",(function(e){n=!1}))}var bm=\"keydown\",Fm=\"mousedown\",vm=\"focusin\";function ym(e,t){return(t||document).querySelector(e)}function Am(e){e.preventDefault(),e.stopPropagation()}function Cm(e,t,i,n,r){e.add(t,bm,(function(e){i.indexOf(e.key)>=0&&(r&&Am(e),n(e))}))}var _m=function(){function e(t){hm(this,e),this.settings={popup:\"right\",layout:\"default\",alpha:!0,editor:!0,editorFormat:\"hex\",cancelButton:!1,defaultColor:\"#0cf\"},this._events=new mm,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(t)}return dm(e,[{key:\"setOptions\",value:function(e){var t=this;if(e){var i=this.settings;if(e instanceof HTMLElement)i.parent=e;else{i.parent&&e.parent&&i.parent!==e.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(e,t,i){for(var n in e)i&&i.indexOf(n)>=0||(t[n]=e[n])}(e,i),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var n=e.color||e.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(e){return t.openHandler(e)};this._events.add(r,\"click\",s),Cm(this._events,r,[\" \",\"Spacebar\",\"Enter\"],s),this._popupInited=!0}else e.parent&&!i.popup&&this.show()}}},{key:\"openHandler\",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents=\"none\";var t=e&&e.type===bm?this._domEdit:this.domElement;setTimeout((function(){return t.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:\"closeHandler\",value:function(e){var t=e&&e.type,i=!1;if(e)if(t===Fm||t===vm){var n=(this.__containedEvent||0)+100;e.timeStamp>n&&(i=!0)}else Am(e),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents=\"\",t!==Fm&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:\"movePopup\",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:\"setColor\",value:function(e,t){this._setColor(e,{silent:t})}},{key:\"_setColor\",value:function(e,t){if(\"string\"==typeof e&&(e=e.trim()),e){t=t||{};var i=void 0;try{i=new gm(e)}catch(e){if(t.failSilently)return;throw e}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,t)}}},{key:\"setColour\",value:function(e,t){this.setColor(e,t)}},{key:\"show\",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var e=this._toggleDOM(!0);return this._setPosition(),e}var t=function(e){var t=document.createElement(\"div\");return t.innerHTML=e,t.firstElementChild}(this.settings.template||'
');return this.domElement=t,this._domH=ym(\".picker_hue\",t),this._domSL=ym(\".picker_sl\",t),this._domA=ym(\".picker_alpha\",t),this._domEdit=ym(\".picker_editor input\",t),this._domSample=ym(\".picker_sample\",t),this._domOkay=ym(\".picker_done button\",t),this._domCancel=ym(\".picker_cancel button\",t),t.classList.add(\"layout_\"+this.settings.layout),this.settings.alpha||t.classList.add(\"no_alpha\"),this.settings.editor||t.classList.add(\"no_editor\"),this.settings.cancelButton||t.classList.add(\"no_cancel\"),this._ifPopup((function(){return t.classList.add(\"popup\")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:\"hide\",value:function(){return this._toggleDOM(!1)}},{key:\"destroy\",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:\"_bindEvents\",value:function(){var e=this,t=this,i=this.domElement,n=this._events;function r(e,t,i){n.add(e,t,i)}r(i,\"click\",(function(e){return e.preventDefault()})),wm(n,this._domH,(function(e,i){return t._setHSLA(e)})),wm(n,this._domSL,(function(e,i){return t._setHSLA(null,e,1-i)})),this.settings.alpha&&wm(n,this._domA,(function(e,i){return t._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,\"input\",(function(e){t._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,\"focus\",(function(e){var t=this;t.selectionStart===t.selectionEnd&&t.select()})),this._ifPopup((function(){var t=function(t){return e.closeHandler(t)};r(window,Fm,t),r(window,vm,t),Cm(n,i,[\"Esc\",\"Escape\"],t);var s=function(t){e.__containedEvent=t.timeStamp};r(i,Fm,s),r(i,vm,s),r(e._domCancel,\"click\",t)}));var o=function(t){e._ifPopup((function(){return e.closeHandler(t)})),e.onDone&&e.onDone(e.colour)};r(this._domOkay,\"click\",o),Cm(n,i,[\"Enter\"],o)}},{key:\"_setPosition\",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup((function(i){\"static\"===getComputedStyle(e).position&&(e.style.position=\"relative\");var n=!0===i?\"popup_right\":\"popup_\"+i;[\"popup_top\",\"popup_bottom\",\"popup_left\",\"popup_right\"].forEach((function(e){e===n?t.classList.add(e):t.classList.remove(e)})),t.classList.add(n)}))}},{key:\"_setHSLA\",value:function(e,t,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[e,t,i,n].forEach((function(e,t){(e||0===e)&&(o[t]=e)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:\"_updateUI\",value:function(e){if(this.domElement){e=e||{};var t=this.colour,i=t.hsla,n=\"hsl(\"+360*i[0]+\", 100%, 50%)\",r=t.hslString,s=t.hslaString,o=this._domH,a=this._domSL,c=this._domA,l=ym(\".picker_selector\",o),h=ym(\".picker_selector\",a),d=ym(\".picker_selector\",c);b(0,l,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,b(0,h,i[1]),F(0,h,1-i[2]),a.style.color=r,F(0,d,1-i[3]);var u=r,f=u.replace(\"hsl\",\"hsla\").replace(\")\",\", 0)\"),p=\"linear-gradient(\"+[u,f]+\")\";if(this._domA.style.background=p+\", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em\",!e.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,w=void 0;switch(g){case\"rgb\":w=t.printRGB(m);break;case\"hsl\":w=t.printHSL(m);break;default:w=t.printHex(m)}this._domEdit.value=w}this._domSample.style.color=s}function b(e,t,i){t.style.left=100*i+\"%\"}function F(e,t,i){t.style.top=100*i+\"%\"}}},{key:\"_ifPopup\",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:\"_toggleDOM\",value:function(e){var t=this.domElement;if(!t)return!1;var i=e?\"\":\"none\",n=t.style.display!==i;return n&&(t.style.display=i),n}}]),e}(),xm=document.createElement(\"style\");function km(e){if(Im[e])return Im[e];if(Im[\"chr\"+e]){const t=Im[\"chr\"+e];return Im[e]=t,t}{const r=(t=Math.round(255*Math.random()).toString(10),i=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),\"rgb(\"+t+\",\"+i+\",\"+n+\")\");return Im[e]=r,r}var t,i,n}xm.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:\"\";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:\"\";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:\"\";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(xm),_m.StyleElement=xm;const Im={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};class Sm{constructor(e){this.tracks=[],this.chordSets=[]}addChordSet(e){this.chordSets=this.chordSets.filter((t=>t.name!==e.name)),this.chordSets.push(e);let t=this.tracks.find((t=>e.trackName===t.name));t&&(t.chordSets=t.chordSets.filter((t=>t.name!==e.name)),t.chordSets.push(e)),t||(t=new Em(e),this.tracks.push(t))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(e){return this.tracks.find((t=>e===t.name))}getChordSet(e){return this.chordSets.find((t=>e===t.name))}}class Em{constructor(e){this.name=e.trackName,this.color=e.trackColor,this.visible=!0,this.chordSets=[e],this.id=(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const e=[];for(let t of this.chordSets)for(let i of t.chords)e.push(i);return e}}const Nm=Math.exp(5);class Bm{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(e,t){if(t=t||{},this.config=t,Bm.isInstalled()){this.parent=e,this.groupByTrack=!0===t.groupByTrack,this.chordManager=new Sm(t);const i=document.createElement(\"div\");i.className=\"igv-circview-container\",e.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement(\"div\");n.className=\"igv-circview-circular-genome-view\",i.appendChild(n),this.container=n,t.assembly&&this.setAssembly(t.assembly),this.width=t.width||500,this.height=t.height||500,this.setSize(this.width,this.height)}else console.error(\"JBrowse circular view is not installed\")}createControls(e){const t=document.createElement(\"div\");t.className=\"igv-circview-toolbar\",e.appendChild(t),this.toolbar=t;const i=document.createElement(\"div\");i.className=\"igv-circview-track-panel\",e.appendChild(i),this.controlPanel=i,this.controlPanel.style.display=\"none\";const n=document.createElement(\"div\");n.className=\"igv-circview-toolbar-button-container\",this.toolbar.appendChild(n),this.showControlsButton=document.createElement(\"div\"),this.showControlsButton.className=\"igv-circview-button\",n.appendChild(this.showControlsButton),this.showControlsButton.innerText=\"none\"===this.controlPanel.style.display?\"Show Controls\":\"Hide Controls\",this.showControlsButton.addEventListener(\"click\",(e=>{this.controlPanel.querySelectorAll(\"div\").length>0&&(\"none\"===this.controlPanel.style.display?(this.controlPanel.style.display=\"flex\",e.target.innerText=\"Hide Controls\"):(this.controlPanel.style.display=\"none\",e.target.innerText=\"Show Controls\"))}));let r=document.createElement(\"div\");r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Clear All\",r.addEventListener(\"click\",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement(\"div\"),r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Close\",r.addEventListener(\"click\",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML=\"\",this.controlPanel.appendChild(this.createGroupByCB());const e=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let t of e)this.addToControlPanel(t)}createGroupByCB(){const e=document.createElement(\"input\");e.type=\"checkbox\",e.id=\"groupByCB\",e.style.width=\"1.4em\",e.style.height=\"1.4em\",e.checked=this.groupByTrack,e.onclick=e=>{this.groupByTrack=e.target.checked,this.resetControlPanel(),this.render()};const t=document.createElement(\"label\");t.for=\"groupByCB\",t.innerText=\"Group by track\",t.style.color=\"black\",t.style.paddingLeft=\"10px\";const i=document.createElement(\"div\");return i.style.width=\"100%\",i.style.paddingTop=\"5px\",i.style.paddingBottom=\"5px\",i.style.background=\"rgb(216, 230, 234)\",i.appendChild(e),i.appendChild(t),i}addToControlPanel(e){const t=document.createElement(\"div\");this.controlPanel.appendChild(t);const i=document.createElement(\"div\");i.className=\"igv-circview-button\",t.appendChild(i),i.innerText=!0===e.visible?\"Hide\":\"Show\",i.addEventListener(\"click\",(t=>{!0===e.visible?(this.hideChordSet(e.name),t.target.innerText=\"Show\"):(this.showChordSet(e.name),t.target.innerText=\"Hide\")}));const n=document.createElement(\"input\"),r=e=>200*Math.log(e*Nm),s=document.createElement(\"div\");s.className=\"igv-circview-button\",s.innerHTML=\"    \",t.appendChild(s),s.style.backgroundColor=Mm(e.color,1);const o={parent:s,popup:\"right\",editorFormat:\"rgb\",color:e.color,onChange:({rgbaString:t})=>{s.style.backgroundColor=Mm(t,1),this.setColor(e.name,t),n.value=r(Rm(e.color))}},a=new _m(o);n.setAttribute(\"title\",\"Adjust transparency of arcs\"),n.type=\"range\",n.style.width=\"100px\",n.style.marginRight=\"10px\",n.setAttribute(\"class\",\"range\"),n.setAttribute(\"min\",\"0\"),n.setAttribute(\"max\",\"1000\"),n.value=r(Rm(e.color)),n.oninput=()=>{const t=(i=n.value,Math.exp(i/200)/Nm);var i;this.setColor(e.name,Mm(e.color,t)),a.setColor(e.color)},t.appendChild(n);const c=document.createElement(\"div\");c.style.color=\"black\",t.appendChild(c),c.innerText=c.title=e.name}setAssembly(e){const t=this.genomeId||Lm();if(this.genomeId===t)return;this.chordManager.clearChords(),this.genomeId=t,this.chrNames=new Set(e.chromosomes.map((e=>Dm(e.name))));const i=[],n=[];for(let t of e.chromosomes){const e=Dm(t.name);n.push(t.color||km(e)),i.push({refName:e,uniqueId:e,start:0,end:t.bpLength})}this.assembly={name:e.name,sequence:{trackId:t,type:\"ReferenceSequenceTrack\",adapter:{type:\"FromConfigSequenceAdapter\",features:i}},refNameColors:n},this.render()}addChords(e,t={}){const i=t.name||t.track||\"*\",n=i.split(\" \")[0].replaceAll(\"%20\",\" \"),r={name:i.replaceAll(\"%20\",\" \"),trackName:n,chords:e,color:t.color||\"black\",trackColor:t.trackColor||t.color||\"black\",visible:!0,id:t.id||Lm()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(e,t){if(t=t||e,this.width=e,this.height=t,this.viewState){const i=this.viewState.session.view;i.setWidth(e),i.setHeight(t),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display=\"block\"}hide(){this.parent.style.display=\"none\"}get visible(){return\"none\"!==this.parent.style.display}set visible(e){this.parent.style.display=e?\"block\":\"none\"}hideChordSet(e){let t=this.getChordSet(e);t?(t.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(e){let t=this.getChordSet(e);t?(t.visible=!0,this.render()):console.warn(`No track with name: ${e}`)}deleteTrack(e){let t=this.tracks.findIndex((t=>e===t.name));t>=0&&this.tracks.splice(t,1),this.render()}getChordSet(e){return this.groupByTrack?this.chordManager.getTrack(e):this.chordManager.getChordSet(e)}setColor(e,t){const i=this.getChordSet(e);if(i){i.color=t;const e=i.id;for(let i of this.viewState.config.tracks)if(e===i.trackId){i.displays[0].renderer.strokeColor.set(t);break}}}render(){const{createViewState:e,JBrowseCircularGenomeView:t}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((e=>e.visible)),n=[],r=[];for(let e of i)n.push({trackId:e.id,name:e.name,assemblyNames:[\"forIGV\"],type:\"VariantTrack\",adapter:{type:\"FromConfigAdapter\",features:e.chords}}),r.push(e.color);this.viewState=e({assembly:this.assembly,tracks:n});for(let e=0;e div {\\n margin: 4px;\\n}\\n\\n.igv-circview-track-panel {\\n z-index: 1024;\\n position: absolute;\\n top: 33px;\\n left: 0;\\n width: 100%;\\n height: fit-content;\\n border-bottom-style: solid;\\n border-bottom-color: dimgray;\\n border-bottom-width: thin;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n.igv-circview-track-panel > div {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-circview-track-panel > div > div {\\n margin: 4px;\\n}\\n\\n.igv-circview-swatch-button {\\n cursor: pointer;\\n padding: 5px;\\n width: 8px;\\n height: 8px;\\n border: 1px solid #8d8b8b;\\n border-radius: 16px;\\n}\\n\\n.igv-circview-button {\\n cursor: pointer;\\n padding: 5px;\\n color: #444;\\n vertical-align: middle;\\n text-align: center;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n border: 1px solid #8d8b8b;\\n border-radius: 4px;\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\\n}\\n\\n.igv-circview-button:hover {\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n.igv-circview-button:active {\\n color: #007bff;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n/*# sourceMappingURL=circular-view.css.map */\\n',document.head.insertBefore(e,document.head.childNodes[document.head.childNodes.length-1])}()}const zm=e=>e.startsWith(\"chr\")?e.substring(3):e;function Hm(e){const t=[],i=[];if(e.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n);i.push(Nu(r.name)),t.push({name:r.name,bpLength:r.bpLength})}return t}function Pm(e,t,i,n){const r=t.color||\"rgb(0,0,255)\",s=_s.addAlpha(\"all\"===i.chr?r:Nu(i.chr),n),o=_s.addAlpha(r,n),a=t.name.replaceAll(\" \",\"%20\"),c=\"all\"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;t.browser.circularView.addChords(e,{track:c,color:s,trackColor:o}),t.browser.circularViewVisible||(t.browser.circularViewVisible=!0)}class Om{constructor(e,{minTLENPercentile:t,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===t?.1:t,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(e)}compute(e){for(let n of e)if(n.isProperPair()){var t=Math.abs(n.fragmentLength);this.sumF+=t,this.sumF2+=t*t,this.isizes.push(t);var i=n.pairOrientation;if(\"string\"==typeof i&&4===i.length)switch(\"\"+i.charAt(0)+i.charAt(2)){case\"FF\":case\"RR\":this.ffCount++;break;case\"FR\":this.frCount++;break;case\"RF\":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation=\"ff\":this.frCount/this.totalCount>.9?this.orienation=\"fr\":this.rfCount/this.totalCount>.9&&(this.orienation=\"rf\"),this.minTLEN=0===this.lp?0:Um(this.isizes,this.lp),this.maxTLEN=Um(this.isizes,this.up)}}function Um(e,t){if(0!==e.length){var i=Math.floor(e.length*(t/100));return e.sort((function(e,t){return e-t})),e[i]}}const qm=\"rgb(255,0,255)\",Qm=\"rgb(0,0,255)\",Vm=\"rgb(132, 178, 158)\",jm=new Map;jm.set(\"m\",\"rgb(255,0,0)\"),jm.set(\"h\",qm),jm.set(\"o\",\"rgb(111, 78, 129)\"),jm.set(\"f\",\"rgb(246, 200, 95)\"),jm.set(\"c\",\"rgb(157, 216, 102)\"),jm.set(\"g\",\"rgb(255, 160, 86)\"),jm.set(\"e\",\"rgb(141, 221, 208)\"),jm.set(\"b\",\"rgb(202, 71, 47)\"),jm.set(\"h\",qm),jm.set(\"a\",\"rgb(51,0,111)\"),jm.set(\"NONE_A\",Qm),jm.set(\"NONE_C\",Qm),jm.set(\"NONE_T\",Qm),jm.set(\"NONE_G\",Qm),jm.set(\"NONE_N\",Qm);const Wm=new Map;function Gm(e,t,i){let n=function(e,t){return jm.has(e)?jm.get(e):Vm}(e),r=Xf(t);if(r>255)return n;const s=e+r+i;if(r<0&&(r=0),!Wm.has(s)){const e=\"basemod2\"===i?Math.max(20,Math.min(255,r*r/50-4*r+200+20)):Math.max(20,Math.min(255,.006127*r*r)),[t,o,a]=_s.rgbComponents(n);Wm.set(s,`rgba(${t},${o},${a},${e/255})`)}return Wm.get(s)}class $m{constructor(e){this.alignmentTrack=e}updateContext(e){this.context=e}drawModifications(e,t,i,n,r,s){const{ctx:o,pixelEnd:a,bpStart:c,bpPerPixel:l}=n,h=e.getBaseModificationSets();if(h){let n;const d=r.split(\":\");2==d.length&&(r=d[0],n=d[1]);for(let d of e.blocks){if(\"S\"===d.type)continue;const e=t,u=i;let f=Math.max(1,1/l);for(let t=d.seqOffset;ta)break;if(i+f<0)continue;let p,g=-1,m=255,w=0;for(let e of h)if((!n||e.modification===n)&&e.containsPosition(t)){const i=Xf(e.likelihoods.get(t));m-=i,(!p||i>g)&&(p=e.modification,w=e.canonicalBase,g=i)}if(p){const t=255*s;let n;m>g&&\"basemod2\"===r&&m>=t?n=Gm(\"NONE_\"+w,m,r):g>=t&&(n=Gm(p,g,r)),o.fillStyle=n,f<3&&(f=3,i--),o.fillRect(i,e,f,Math.max(1,u-2))}}}}}}const Km=new Set([\"firstOfPairStrand\"]);class Ym extends Hl{static defaults={viewAsPairs:!1,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,colorBy:void 0,groupBy:void 0,displayMode:\"EXPANDED\",alignmentRowHeight:14,squishedRowHeight:3,negStrandColor:\"rgba(150, 150, 230, 0.75)\",posStrandColor:\"rgba(230, 150, 150, 0.75)\",baseModPosStrandColor:\"rgb(195, 195, 195)\",baseModNegStrandColor:\"rgb(195, 210, 195)\",insertionColor:\"rgb(138, 94, 161)\",insertionTextColor:\"white\",showInsertionText:!1,deletionColor:\"black\",deletionTextColor:\"black\",showDeletionText:!1,skippedColor:\"rgb(150, 170, 170)\",pairConnectorColor:void 0,smallTLENColor:\"rgb(0, 0, 150)\",largeTLENColor:\"rgb(200, 0, 0)\",expectedPairOrientation:\"fr\",rlColor:\"rgb(0, 150, 0)\",rrColor:\"rgb(20, 50, 200)\",llColor:\"rgb(0, 150, 150)\",bamColorTag:\"YC\",hideSmallIndels:!1,indelSizeThreshold:1,highlightColor:void 0,minTLEN:void 0,maxTLEN:void 0,tagColorPallete:\"Set1\"};_colorTables=new Map;_baseModifications=new Set;constructor(e,t){super(e,t),(e.colorTable||e.tagColorTable)&&(this.colorTable=new ao(e.tagColorTable)),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.pairOrienation&&(this.expectedPairOrientation=e.pairOrientation),e.smallFragmentLengthColor&&(this.smallTLENColor=e.smallFragmentLengthColor),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.minFragmentLength&&(this.minTLEN=e.minFragmentLength),e.maxFragmentLength&&(this.maxTLEN=e.maxFragmentLength),e.displayMode&&(this.displayMode=e.displayMode.toUpperCase()),e.colorBy&&e.colorByTag&&(this.colorBy=e.colorBy+\":\"+e.colorByTag),this.featureSource=this.parent.featureSource,this.top=0===e.coverageTrackHeight?0:e.coverageTrackHeight+5,this.pairColors={RL:this.rlColor,RR:this.rrColor,LL:this.llColor},e.highlightedReads&&this.setHighlightedReads(e.highlightedReads),this.hasPairs=!1,this.hasSupplemental=!1,this._groupByTags=[],this._groupByPositions=[],e.groupBy&&(this.groupBy=e.groupBy,e.groupBy.startsWith(\"base:\")&&this._groupByPositions.push(e.groupBy.substring(5)),e.groupBy.startsWith(\"tag:\")&&this._groupByTags.push(e.groupBy.substring(4))),this._locusChange=Zm.bind(this),this.browser.on(\"locuschange\",this._locusChange)}init(e){this.parent=e.parent,delete e.parent,super.init(e)}dispose(){this.browser.off(\"locuschage\",this._locusChange)}get baseModRenderer(){return this._baseModRenderer||(this._baseModRenderer=new $m(this)),this._baseModRenderer}get baseModificationThreshold(){return this.parent.baseModificationThreshold}setTop(e,t){this.top=0===e.height||!1===t?0:5+e.height}setHighlightedReads(e,t){if(!Array.isArray(e)||!e.every((e=>\"string\"==typeof e)))throw new Error(\"AlignmentTrack.setHighlightedReads() only accept array of strings\");t&&(this.highlightColor=t),this.highlightedReads=new Set(e)}computePixelHeight(e){if(e.packedGroups){let t=e.hasDownsampledIntervals()?15:0;const i=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;for(let n of e.packedGroups.values())t+=i*n.length+10;return t+5}return 0}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=r+s*n+1,a=this.showSoftClips,c=this.showAllBases,l=this.browser.nucleotideColors;i.save();for(let e of t.baseModificationKeys)this._baseModifications.add(e.modification);let h=t.sequence;h&&(h=h.toUpperCase());let d=0;this.colorBy||(this.colorBy=this.hasPairs?\"unexpectedPair\":\"none\");let u=e.pixelTop;this.top&&i.translate(0,this.top);const f=u+e.pixelHeight;t.hasDownsampledIntervals()?(d=15,t.downsampledIntervals.forEach((function(e){var t=(e.start-r)/n,s=(e.end-r)/n;s-t>5&&(t+=1,s-=1),xo.fillRect(i,t,2,s-t,8,{fillStyle:\"black\"})}))):d=0,this.alignmentsYOffset=d;const p=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight,g=t.packedGroups;if(g){let t=d;for(let n of g.keys()){const a=g.get(n),c=a.rows,l=c.length;a.pixelTop=t;for(let e=0;ef)break;if(t+no)break;!0!==e.hidden&&(e instanceof Qf?(m.call(this,e,t,n),w.call(this,e.firstAlignment,t,n),e.secondAlignment&&w.call(this,e.secondAlignment,t,n)):w.call(this,e,t,n))}t+=p}}if(a.pixelBottom=t,this.groupBy&&n){i.save(),i.font=\"400 12px sans-serif\";const r=i.measureText(n),o=r.width+10,c=-e.pixelShift+e.viewportWidth-o-10,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+10,h=Math.min(a.pixelTop+l-1,a.pixelBottom);i.textAlign=\"center\",i.fillStyle=\"white\",i.strokeStyle=\"lightGray\",xo.roundRect(i,c,h-r.actualBoundingBoxAscent-5,o,l,2,1,1),i.fillStyle=\"black\",i.fillText(n,c+o/2,h),xo.dashedLine(i,0,t,s,t),i.restore(),t+=10}}}function m(e,t,s){var a=this.getConnectorColor(e.firstAlignment),c=(e.connectingStart-r)/n,l=(e.connectingEnd-r)/n,h=t+s/2;e.connectingEndo||(e.mq<=0&&(a=_s.addAlpha(a,.15)),xo.setProperties(i,{fillStyle:a,strokeStyle:a}),xo.strokeLine(i,c,h,l,h))}function w(e,d,u){if(e.start+e.lengthOnRefo)return;const f=a?e.blocks:e.blocks.filter((e=>\"S\"!==e.type));let g=this.getAlignmentColor(e);const m=g;e.mq<=0&&(g=_s.addAlpha(g,.15)),xo.setProperties(i,{fillStyle:g,strokeStyle:m});const w=[];for(let e=0;eo))break}if(e.gaps){const t=d+u/2;for(let s of e.gaps){const e=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-e,c=s.len.toString(),l=6*c.length,h=e+a/2,u=\"D\"===s.type?this.deletionColor:this.skippedColor;if(xo.strokeLine(i,e,t,o,t,{strokeStyle:u,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=l+8){const e=h-l/2;xo.fillRect(i,e-1,d-1,l+2,12,{fillStyle:\"white\"}),xo.fillText(i,c,e,d+10,{font:\"normal 10px monospace\",fillStyle:this.deletionTextColor})}}}if(e.insertions&&this.showInsertions){let t=-1;for(let s of e.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.starto)break;const e=s.start-r,a=s.len.toString(),c=2+6*a.length,l=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,h=Math.max(Math.min(c,l),2),f=e/n-h/2;if(f-t>2){const e={fillStyle:this.insertionColor};xo.fillRect(i,f-2,d,h+4,2,e),xo.fillRect(i,f,d+2,h,u-4,e),xo.fillRect(i,f-2,d+u-2,h+4,2,e),this.showInsertionText&&s.len>1&&l>c&&xo.fillText(i,a,f+1,d+10,{font:\"normal 10px monospace\",fillStyle:this.insertionTextColor}),t=f}}}for(let{bbox:e,baseColor:t,readChar:r}of w){if(n<=.1&&e.height>=8){const n=Math.min(10,e.height);i.font=n+\"px sans-serif\";const s=e.x+e.width/2;xo.strokeText(i,r,s-i.measureText(r).width/2,n-1+e.y,{strokeStyle:t})}else xo.fillRect(i,e.x,e.y,e.width,e.height,{fillStyle:t})}if(this.colorBy&&this.colorBy.startsWith(\"basemod\")){const t={ctx:i,bpPerPixel:n,bpStart:r,bpEnd:o,pixelEnd:s};this.baseModRenderer.drawModifications(e,d,u,t,this.colorBy,this.baseModificationThreshold)}function b(o,a){const w=[],b=o.start-t.start,F=(o.start-r)/n,v=(o.start+o.len-r)/n,y=Math.max(1,v-F),A=100/n,C=Math.min(p/2,A/6),_=\"S\"===o.type,x=e.mq<=0||this.selectedReadName===e.readName||_||this.highlightedReads&&this.highlightedReads.has(e.readName);let k=m;this.selectedReadName===e.readName?k=\"red\":_?k=\"rgb(50,50,50)\":this.highlightedReads&&this.highlightedReads.has(e.readName)&&(k=this.highlightColor||\"#00ff00\");const I=!0===e.strand&&a===f.length-1,S=!1===e.strand&&0===a;if(I|S){let e,t;I?(e=[F,v,v+C,v,F,F],t=[d,d,d+u/2,d+u,d+u,d]):S&&(e=[v,F,F-C,F,v,v],t=[d,d,d+u/2,d+u,d+u,d]),xo.fillPolygon(i,e,t,{fillStyle:g}),x&&xo.strokePolygon(i,e,t,{strokeStyle:k})}else xo.fillRect(i,F,d,y,u,{fillStyle:g}),x&&(i.save(),i.strokeStyle=k,i.strokeRect(F,d,y,u),i.restore());if(_||c||this.showMismatches&&h&&e.seq&&\"*\"!==e.seq){const t=e.seq?e.seq.toUpperCase():void 0,i=e.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let e=0,p=o.len;es)break;let g=t?t.charAt(a+e):\"\";const m=b+e>=0?h.charAt(b+e):\"\";if(\"=\"===g&&(g=m),\"X\"===g||m!==g||_||c){let t=l[g]||\"rgb(0,0,0)\";if(!_&&void 0!==i&&i.length>a+e){t=Xm(i[a+e],t)}w.push({bbox:{x:p,y:d,width:f,height:u},baseColor:t,readChar:g})}}}return w}}i.restore()}popupData(e){const t=this.getClickedObject(e);return t?t.popupData(e.genomicLocation):void 0}menuItemList(){let e=[];e.push(\"
\");const t=Bt('
');t.text(\"Color by:\"),e.push({name:void 0,object:t,click:void 0,init:void 0});const i=[];i.push({key:\"none\",label:\"none\"}),i.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(i.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),i.push({key:\"pairOrientation\",label:\"pair orientation\"}),i.push({key:\"tlen\",label:\"insert size (TLEN)\"}),i.push({key:\"unexpectedPair\",label:\"pair orientation & insert size (TLEN)\"})),i.push({key:\"tag\",label:\"tag\"});for(let t of i){const i=void 0===this.colorBy&&\"none\"===t.key||this.colorBy===t.key;e.push(this.colorByCB(t,i))}const n=this._baseModifications.size;if(n>0){e.push('
');let t=1===n?\"base modification\":\"base modification (all)\";if(e.push(this.basemodColorByCB({key:\"basemod\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod:\"+t,label:`base modification (${Kf(t)})`}));if(e.push('
'),t=1===n?\"base modification 2-color\":\"base modification 2-color (all)\",e.push(this.basemodColorByCB({key:\"basemod2\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod2:\"+t,label:`base modification 2-color (${Kf(t)})`}))}e.push(\"
\");const r=Bt('
');r.text(\"Group by:\"),e.push({name:void 0,object:r,click:void 0,init:void 0});const s=[];s.push({key:\"none\",label:\"none\"}),s.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(s.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),s.push({key:\"pairOrientation\",label:\"pair orientation\"}),s.push({key:\"mateChr\",label:\"chromosome of mate\"})),s.push({key:\"chimeric\",label:\"chimeric\"}),s.push({key:\"supplementary\",label:\"supplementary flag\"}),s.push({key:\"readOrder\",label:\"read order\"});for(let e of this._groupByTags)s.push({key:`tag:${e}`,label:`tag:${e}`});for(let e of this._groupByPositions)s.push({key:`base:${e}`,label:`base:${e}`});s.push({key:\"tag\",label:\"tag...\"});for(let t of s){const i=void 0===this.groupBy&&\"none\"===t.key||this.groupBy===t.key;e.push(this.groupByCB(t,i))}e.push(\"
\"),e.push({object:Bt(Dl(\"Show all bases\",this.showAllBases)),click:function(){this.alignmentTrack.showAllBases=!this.alignmentTrack.showAllBases,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show mismatches\",this.showMismatches)),click:function(){this.alignmentTrack.showMismatches=!this.alignmentTrack.showMismatches,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show insertions\",this.showInsertions)),click:function(){this.alignmentTrack.showInsertions=!this.alignmentTrack.showInsertions,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show soft clips\",this.showSoftClips)),click:function(){this.alignmentTrack.showSoftClips=!this.alignmentTrack.showSoftClips;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.repaintViews()}}),this.hasPairs&&(e.push(\"
\"),e.push({object:Bt(Dl(\"View as pairs\",this.viewAsPairs)),click:function(){const e=!this.alignmentTrack.viewAsPairs;if(e&&this.groupBy&&!Km.has(this.groupBy))return void this.browser.alert.present(`'View as Pairs' is incompatible with 'Group By ${this.groupBy}'`);this.alignmentTrack.viewAsPairs=e;const t=this.getCachedAlignmentContainers();for(let e of t)e.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(e.push(\"
\"),this.hasPairs&&e.push({label:\"Add discordant pairs to circular view\",click:function(){for(let e of this.trackView.viewports)this.addPairedChordsForViewport(e)}}),this.hasSupplemental&&e.push({label:\"Add split reads to circular view\",click:function(){for(let e of this.trackView.viewports)this.addSplitChordsForViewport(e)}})),e.push(\"
\");const o=Bt('
');o.text(\"Display mode:\"),e.push({name:void 0,object:o,click:void 0,init:void 0});for(let t of[\"EXPANDED\",\"SQUISHED\",\"FULL\"])e.push({object:Bt(Dl(t.toLowerCase(),this.displayMode===t)),click:function(){this.alignmentTrack.setDisplayMode(t)}});return e}setDisplayMode(e){const t=\"FULL\"===this.displayMode||\"FULL\"===e;if(this.displayMode=e,t){const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this)}this.trackView.checkContentHeight(),this.trackView.repaintViews()}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"tag\"!==e.key){function n(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){const t=this.alignmentTrack.colorBy.startsWith(\"tag:\")?this.alignmentTrack.colorBy.substring(4):\"\";this.browser.inputDialog.present({label:\"Tag Name\",value:t,callback:e=>{const t=this.alignmentTrack;e?(t.colorBy=\"tag:\"+e,t.colorTable||(t.colorTable=new oo(\"Set1\"))):t.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}basemodColorByCB(e){const t=this.colorBy===e.key;return{name:void 0,object:Bt(Dl(e.label,t)),click:function(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()},init:void 0}}groupByCB(e,t){return{name:void 0,object:Bt(Dl(e.label,t)),dialog:function(t){const i=()=>this.alignmentTrack.repackAlignments();if(\"tag\"===e.key){let e=\"\";this.alignmentTrack.groupBy&&this.alignmentTrack.groupBy.startsWith(\"tag:\")&&(e=this.alignmentTrack.groupBy.substring(4)),this.browser.inputDialog.present({label:\"Tag Name\",value:e,callback:e=>{e&&(this.alignmentTrack.groupBy=\"tag:\"+e,this.alignmentTrack._groupByTags.push(e),i())}},t)}else\"none\"===e.key?this.alignmentTrack.groupBy=void 0:this.alignmentTrack.groupBy=e.key,i()},init:void 0}}repackAlignments(){const e=this.getCachedAlignmentContainers();for(let t of e)\"function\"==typeof t.pack&&t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}contextMenuItemList(e){const t=e.viewport,i=[],n=i=>{const n=this.sortObject,r=!n||n.position!==Math.floor(e.genomicLocation)||!n.direction,s={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:i,direction:r,sortAsPairs:t.trackView.track.viewAsPairs};this.sortObject=s,t.cachedFeatures.sortRows(s),t.repaint()};i.push(\"Sort by...\"),i.push({label:\"  base\",click:()=>n(\"BASE\")}),i.push({label:\"  read strand\",click:()=>n(\"strand\")}),i.push({label:\"  start location\",click:()=>n(\"START\")}),i.push({label:\"  insert size\",click:()=>n(\"INSERT_SIZE\")}),i.push({label:\"  gap size\",click:()=>n(\"GAP_SIZE\")}),i.push({label:\"  chromosome of mate\",click:()=>n(\"MATE_CHR\")}),i.push({label:\"  mapping quality\",click:()=>n(\"MQ\")}),i.push({label:\"  read name\",click:()=>n(\"READ_NAME\")}),i.push({label:\"  aligned read length\",click:()=>n(\"ALIGNED_READ_LENGTH\")}),i.push({label:\"  tag\",click:()=>{const i=this.sortObject,n=!i||i.position!==Math.floor(e.genomicLocation)||!i.direction,r={label:\"Tag Name\",value:this.sortByTag?this.sortByTag:\"\",callback:i=>{if(i){const r={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:\"TAG\",tag:i,direction:n};this.sortByTag=i,this.sortObject=r,t.cachedFeatures.sortRows(r),t.repaint()}}};this.browser.inputDialog.present(r,e.event)}}),i.push(\"
\");const r=`${t.referenceFrame.chr}:${Rt(Math.floor(e.genomicLocation)+1)}`;i.push({label:`Group by base @${r}`,click:()=>{this._groupByPositions.push(r),this.groupBy=`base:${r}`;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),i.push(\"
\");const s=this.getClickedObject(e);if(s){const t=this.showSoftClips,n=\"function\"==typeof s.alignmentContaining?s.alignmentContaining(e.genomicLocation,t):s;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:\"View mate in split screen\",click:()=>{if(n.mate){const t=e.viewport.referenceFrame,i=this.browser.genome.getChromosome(n.mate.chr);if(i){this.selectedReadName=n.readName;const r=t.bpPerPixel*e.viewport.getWidth(),s=n.mate.position-r/2,o=n.mate.position+r/2;this.browser.addMultiLocusPanel(i.name,s,o,t)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:\"View read sequence\",click:()=>{const e=n.seq;e&&\"*\"!==e?this.browser.alert.present(e):this.browser.alert.present(\"Read sequence: *\")}}),Xa()&&i.push({label:\"Copy read sequence\",click:async()=>{const e=n.seq;try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}});const t=n.seq;if(t&&\"*\"!==t){t.length{const e=n.isNegativeStrand()?cc(t):t,i=`${n.readName} - blat`,r=`${this.name} - ${i}`;jd({sequence:e,browser:this.browser,name:i,title:r})}});const e=n.softClippedBlocks();e.left&&e.left.len>20&&e.left.len{const i=t.substr(e.left.seqOffset,e.left.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat left clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}}),e.right&&e.right.len>20&&e.right.len{const i=t.substr(e.right.seqOffset,e.right.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat right clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}})}i.push(\"
\")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:\"Add discordant pairs to circular view\",click:()=>{this.addPairedChordsForViewport(t)}}),this.hasSupplemental&&i.push({label:\"Add split reads to circular view\",click:()=>{this.addSplitChordsForViewport(t)}}),i.push(\"
\")),i}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t)return;const i=e.y-this.top,n=e.genomicLocation;if(t.packedGroups){let e=Number.MAX_VALUE;for(let r of t.packedGroups.values())if(e=Math.min(e,r.pixelTop),i>r.pixelTop&&i<=r.pixelBottom){const e=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let t=Math.floor((i-r.pixelTop)/e);if(t>=0&&te.containsLocation(n,this.showSoftClips)));if(e.length>0)return e[0]}}}if(i=n)return e}getConnectorColor(e){if(this.pairConnectorColor)return this.pairConnectorColor;let t=this.colorBy;switch(t&&t.startsWith(\"tag:\")&&(t.substring(4),t=\"tag\"),t){case\"strand\":case\"firstOfPairStrand\":case\"pairOrientation\":case\"tag\":return this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(200, 200, 200)\";default:return this.getAlignmentColor(e)}}getAlignmentColor(e){let t;t=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(185, 185, 185)\";let i,n=this.colorBy;switch(n&&n.startsWith(\"tag:\")&&(i=n.substring(4),n=\"tag\"),n){case\"basemod\":case\"basemod2\":t=e.strand?this.baseModPosStrandColor:this.baseModNegStrandColor;break;case\"strand\":t=e.strand?this.posStrandColor:this.negStrandColor;break;case\"firstOfPairStrand\":const r=e.firstOfPairStrand;void 0!==r&&(t=r?this.posStrandColor:this.negStrandColor);break;case\"unexpectedPair\":case\"pairOrientation\":if(e.pairOrientation){const i=ep[this.expectedPairOrientation];if(i){const n=this.pairColors[i[e.pairOrientation]];if(n){t=n;break}}}if(\"pairOrientation\"===n)break;case\"tlen\":case\"fragmentLength\":e.mate&&e.isMateMapped()&&(e.mate.chr!==e.chr?t=Nu(e.mate.chr):this.minTemplateLength&&Math.abs(e.fragmentLength)this.maxTemplateLength&&(t=this.largeTLENColor));break;case\"tag\":const s=e.tags()[i];void 0!==s&&(this.bamColorTag===i&&(t=_s.createColorStringSafe(s)),this.colorTable||(this.colorTable=new oo(this.tagColorPallete)),t=this.colorTable.getColor(s))}return t}get nucleotideColors(){return this.browser.nucleotideColors}get minTemplateLength(){return void 0!==this.minTLEN?this.minTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.minTLEN:0}get maxTemplateLength(){return void 0!==this.maxTLEN?this.maxTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.maxTLEN:1e3}getState(){const e=super.getState();return this.highlightedReads&&(e.highlightedReads=Array.from(this.highlightedReads)),e}get name(){return this.parent.name}set name(e){this.parent.name=e}get color(){return this.parent.color}set color(e){this.parent.color=e}get trackView(){return this.parent.trackView}get getCachedAlignmentContainers(){return this.parent.getCachedAlignmentContainers}get sortObject(){return this.parent.sortObject}set sortObject(e){this.parent.sortObject=e}addPairedChordsForViewport(e){return this.parent.addPairedChordsForViewport(e)}addSplitChordsForViewport(e){return this.parent.addSplitChordsForViewport(e)}}function Xm(e,t){let i;return i=e<5?.1:Math.max(.1,Math.min(1,.1+.9*(e-5)/15)),i=Math.round(10*i)/10,i<1&&(t=_s.addAlpha(t,i)),t}function Zm(){\"FULL\"!==this.displayMode||this.browser.isTrackPanning()||this.repackAlignments()}function Jm(e,t,i,n,r,s,o,a,c){const l=o.baseModCounts,h=o.coverageMap;if(l){let o;const d=a.split(\":\");2==d.length&&(a=d[0],o=d[1]);const u=Array.from(l.allModifications);u.sort(Vf.compare);const f=h.getTotalCount(s);if(!u.filter((e=>o?o===e.modification:!e.modification.startsWith(\"NONE_\"))).find((e=>l.getCount(s,e,0,!1)>0)))return;for(let d of u){if(d.modification.startsWith(\"NONE_\")&&\"basemod2\"!==a)continue;if(o&&o!==d.modification&&!d.modification.startsWith(\"NONE_\"))continue;const u=d.base,p=oc(u),g=h.getCount(s,u)+h.getCount(s,p),m=l.simplexModifications.has(d.modification)?h.getPosCount(s,u)+h.getNegCount(s,p):g;if(0==m)continue;const w=\"basemod2\"===a,b=l.getCount(s,d,c,w);if(0==b)continue;const F=g/f*(b/m),v=Math.round(F*r),y=l.getLikelihoodSum(s,d,c,w)/b,A=i-v,C=Gm(d.modification,y,a);e.fillStyle=C,e.fillRect(t,A,n,v),i=A}}}class ew{constructor(e,t){this.featureType=\"numeric\",this.parent=t,this.featureSource=t.featureSource,this.paintAxis=cd,this.top=0,this.autoscale=e.autoscale||void 0===e.max,e.coverageColor&&(this.color=e.coverageColor),this.autoscale||(this.dataRange={min:e.min||0,max:e.max})}get height(){return this.parent.coverageTrackHeight}draw(e){const t=e.pixelTop;e.pixelHeight;const i=this.parent.browser.nucleotideColors;if(t>this.height)return;const n=e.context,r=e.features,s=r.coverageMap;let o;s.refSeq&&(o=s.refSeq.toUpperCase());const a=e.bpPerPixel,c=e.bpStart,l=c+e.pixelWidth*a+1;let h;h=this.color?this.color:this.parent.color&&\"function\"!=typeof this.parent.color?_s.darkenLighten(this.parent.color,-35):\"rgb(150, 150, 150)\",xo.setProperties(n,{fillStyle:h,strokeStyle:h});const d=Math.max(1,1/a);for(let e=0,t=s.coverage.length;el)break;const i=s.coverage[e];if(!i)continue;const r=i.total/this.dataRange.max*this.height,o=this.height-r,h=(t-c)/a;xo.fillRect(n,h,o,d,r)}if(o)for(let e=0,t=s.coverage.length;el)break;const h=s.coverage[e];if(!h)continue;const u=h.total/this.dataRange.max*this.height;let f=this.height-u;const p=Math.floor((t-c)/a),g=o[e];if(this.parent.colorBy&&this.parent.colorBy.startsWith(\"basemod\"))Jm(n,p,this.height,d,u,t,r,this.parent.colorBy,this.parent.baseModificationThreshold);else if(h.isMismatch(g)){xo.setProperties(n,{fillStyle:i[g]}),xo.fillRect(n,p,f,d,u);let e=0;for(let t of[\"A\",\"C\",\"T\",\"G\"]){const r=(h[\"pos\"+t]+h[\"neg\"+t])/this.dataRange.max*this.height;f=this.height-r-e,e+=r,xo.setProperties(n,{fillStyle:i[t]}),xo.fillRect(n,p,f,d,r)}}}}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t||0===t.length)return;const i=Math.floor(e.genomicLocation),n=t.coverageMap,r=Math.floor(i-n.bpStart),s=n.coverage[r];return s?{coverage:s,baseModCounts:t.baseModCounts,hoverText:()=>n.coverage[r].hoverText()}:void 0}popupData(e){const t=[],{coverage:i,baseModCounts:n}=this.getClickedObject(e);if(i){const r=Math.floor(e.genomicLocation),s=e.viewport.referenceFrame;t.push(s.chr+\":\"+Rt(1+r)),t.push({name:\"Total Count\",value:i.total});let o=i.posA+i.negA;o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posA+\"+, \"+i.negA+\"- )\"),t.push({name:\"A\",value:o}),o=i.posC+i.negC,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posC+\"+, \"+i.negC+\"- )\"),t.push({name:\"C\",value:o}),o=i.posG+i.negG,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posG+\"+, \"+i.negG+\"- )\"),t.push({name:\"G\",value:o}),o=i.posT+i.negT,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posT+\"+, \"+i.negT+\"- )\"),t.push({name:\"T\",value:o}),o=i.posN+i.negN,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posN+\"+, \"+i.negN+\"- )\"),t.push({name:\"N\",value:o}),t.push(\"
\"),t.push({name:\"DEL\",value:i.del.toString()}),t.push({name:\"INS\",value:i.ins.toString()}),n&&(t.push(\"
\"),t.push(...n.popupData(r,this.parent.colorBy)))}return t}}class tw extends Hl{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,height:300,coverageTrackHeight:50,baseModificationThreshold:0};constructor(e,t){super(e,t)}init(e){this.type=\"alignment\",this.featureSource=new cm(e,this.browser);const t=Object.assign({parent:this},e);this.coverageTrack=new ew(t,this);const i=Object.assign({parent:this},e);this.alignmentTrack=new Ym(i,this.browser),super.init(e),this.showAlignments||(this._height=this.coverageTrackHeight),e.sort&&(Array.isArray(e.sort)?this.assignSort(e.sort[0]):this.assignSort(e.sort))}dispose(){this.alignmentTrack.dispose()}setHighlightedReads(e,t){this.alignmentTrack.setHighlightedReads(e,t),this.updateViews()}get expectedPairOrientation(){return this.alignmentTrack.expectedPairOrientation}get viewAsPairs(){return this.alignmentTrack.viewAsPairs}get colorBy(){return this.alignmentTrack.colorBy}set height(e){this._height=e,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?e-this.coverageTrackHeight:e)}get height(){return this._height}sort(e){e=this.assignSort(e);for(let t of this.trackView.viewports)if(t.containsPosition(e.chr,e.position)){const i=t.cachedFeatures;i&&(i.sortRows(e),t.repaint())}}assignSort(e){if(e.locus){const t=function(e){const t=e.split(\":\"),i=t[1].split(\"-\"),n={chr:t[0],start:Number.parseInt(i[0].replace(/,/g,\"\"))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,\"\")):n.end=n.start+1,n}(e.locus);e.chr=t.chr,e.position=t.start}else e.position--;return e.direction=\"ASC\"===e.direction||!0===e.direction,e.chr=this.browser.genome.getChromosomeName(e.chr),this.sortObject=e,this.sortObject}async getFeatures(e,t,i,n,r){const s=await this.featureSource.getAlignments(e,t,i);if(s.viewport=r,s.hasPairs&&!this._pairedEndStats&&!this.config.maxFragmentLength){const e=new Om(s.allAlignments(),this.config);e.totalCount>99&&(this._pairedEndStats=e)}s.pack(this.alignmentTrack);const o=this.sortObject;return o&&o.chr===e&&o.position>=t&&o.position<=i&&s.sortRows(o),this.alignmentTrack.hasPairs=this.alignmentTrack.hasPairs||s.hasPairs,s}computePixelHeight(e){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(e):0)}draw(e){xo.fillRect(e.context,0,e.pixelTop,e.pixelWidth,e.pixelHeight,{fillStyle:\"rgb(255, 255, 255)\"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display=\"block\",this.coverageTrack.draw(e)):this.trackView.axisCanvas.style.display=\"none\",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(e))}paintAxis(e,t,i){this.coverageTrack.paintAxis(e,t,this.coverageTrackHeight)}contextMenuItemList(e){return this.alignmentTrack.contextMenuItemList(e)}popupData(e){return!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y{if(!this.autoHeight){const e=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(e)}};return e.push(\"
\"),e.push({object:Bt(Dl(\"Show Coverage\",this.showCoverage)),click:function(){this.showCoverage=!this.showCoverage,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show Alignments\",this.showAlignments)),click:function(){this.showAlignments=!this.showAlignments,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e}getState(){const e=super.getState();return this.sortObject&&(e.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?\"ASC\":\"DESC\"}),Object.assign(e,this.alignmentTrack.getState()),e}getCachedAlignmentContainers(){return this.trackView.viewports.map((e=>e.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(e){this.coverageTrack.dataRange=e}get logScale(){return this.coverageTrack.logScale}set logScale(e){this.coverageTrack.logScale=e}get autoscale(){return this.coverageTrack.autoscale}set autoscale(e){this.coverageTrack.autoscale=e}addPairedChordsForViewport(e){const t=this.maxTemplateLength,i=[],n=e.referenceFrame;for(let r of e.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>t&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>t)&&i.push(r));Pm((e=>{const t=[];for(let i of e)if(i.paired)i.firstAlignment&&i.secondAlignment&&t.push({uniqueId:i.readName,refName:zm(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:zm(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const e=i.mate;e&&e.chr&&e.position&&t.push({uniqueId:i.readName,refName:zm(i.chr),start:i.start,end:i.end,mate:{refName:zm(e.chr),start:e.position-1,end:e.position}})}return t})(i),this,n,.02)}addSplitChordsForViewport(e){const t=[],i=e.referenceFrame;for(let n of e.cachedFeatures.allAlignments()){const e=n.hasTag(\"SA\");n.end>=i.start&&n.start<=i.end&&e&&t.push(n)}Pm((e=>{const t=e=>{const t=gp(e.tags().SA);let n=0;for(let r of t)r.start!==e.start&&i.push({uniqueId:`${e.readName}_${n++}`,refName:zm(e.chr),start:e.start,end:e.end,mate:{refName:zm(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of e)i.paired?(t(i.firstAlignment),i.secondAlignment&&t(i.secondAlignment)):t(i);return i})(t),this,i,.02)}}class iw extends Hl{static defaults={height:250,theta:Math.PI/4,arcOrientation:\"UP\",showBlocks:!0,blockHeight:3,thickness:1,color:\"rgb(180,25,137)\",alpha:.02,logScale:!0};constructor(e,t){super(e,t)}init(e){super.init(e),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(e){if(!e.arcType)return\"nested\";switch(e.arcType){case\"chiapet\":return\"inView\";case\"chiapetoutbound\":return\"partialInView\";default:return e.arcType}}(e),this.painter={flipAxis:\"DOWN\"===this.arcOrientation,dataRange:this.dataRange,paintAxis:cd},e.valueColumn?(this.valueColumn=e.valueColumn,this.hasValue=!0):e.useScore&&(this.hasValue=!0,this.valueColumn=\"score\"),e.max?(this.dataRange={min:e.min||0,max:e.max},this.autoscale=!1):this.autoscale=!0,e.featureSource?(this.featureSource=e.featureSource,delete e._featureSource):(this.featureSource=Ad(e,this.browser.genome),this.featureSource.getWGFeatures=aw)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(e){\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?this.drawProportional(e):this.drawNested(e)}drawNested(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.viewportWidth,s=e.bpPerPixel,o=e.bpStart,a=s;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const c=e.features;if(c){(function(){let e=0;for(let t of c){let n=(t.start-o)/a,r=(t.end-o)/a;n>=0&&r<=i&&(e=Math.max(e,r-n))}let t=Math.min(r,e)/2;if(e>0){let e=(n-10)/t;this.theta=function(e){let t,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(t=0;te);t++);let r=0===t?0:i[t-1],s=ti)continue;let f=u-d;f<3&&(f=3,d--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,w=d+p;let b,F,v;if(s?(b=this.height+m,F=Math.PI+Math.PI/2-this.theta,v=Math.PI+Math.PI/2+this.theta):(b=-m,F=Math.PI/2-this.theta,v=Math.PI/2+this.theta),this.showBlocks&&\"all\"!==e.chr){const i=(e.start1-o)/a,n=(e.end1-o)/a,r=(e.start2-o)/a,c=(e.end2-o)/a,l=s?-this.blockHeight:this.blockHeight;t.fillRect(i,h,n-i,l),t.fillRect(r,h,c-r,l)}n&&!this.config.useScore&&f>r&&(n=ow(n,this.alpha)),t.strokeStyle=n,t.fillStyle=n,t.beginPath(),t.arc(w,b,g,F,v,!1),t.stroke(),e.drawState={xc:w,yc:b,r:g}}else{let r=Math.round((e.start-o)/a),c=Math.round((e.end-o)/a);if(c<0||r>i)continue;let l=c-r;l<3&&(l=3,r--);const h=e.chr===e.chr1?e.chr2:e.chr1;t.strokeStyle=n,t.fillStyle=ow(Nu(h),.5),s?(t.fillRect(r,this.height/2,l,this.height/2),t.fillText(h,r+l/2,this.height/2-5),e.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(t.fillRect(r,0,l,this.height/2),t.fillText(h,r+l/2,this.height/2+13),e.drawState={x:r,y:0,w:l,h:this.height/2})}}}var l}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}drawProportional(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.bpPerPixel,s=e.bpStart,o=r,a=e.referenceFrame.start,c=e.referenceFrame.end,l=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const h=e.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,e.pixelHeight-1,this.logScale),d=l?e.pixelHeight:0;for(let e of h){e.drawState=void 0;const n=this.valueColumn?e[this.valueColumn]:e.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(e.chr1===e.chr2||\"all\"===e.chr){const{m1:i,m2:r}=nw(e,this.browser.genome);let u=Math.round((i-s)/o),f=Math.round((r-s)/o)-u;if(f<3&&(f=3,u--),nthis.dataRange.max)continue;if(\"proportional\"!==this.arcType){const e=\"partialInView\"===this.arcType,t=i>=a&&r<=c;let n=!1,s=!1;if(!t&&e&&(n=a<=i&&i<=c,n||(s=a<=r&&r<=c)),!(t||n||s))continue}const p=f/2,g=u+f/2;e.drawState={xc:g,yc:d,radiusX:p,radiusY:h};const m=l,w=e.color||this.color;if(t.strokeStyle=w,t.lineWidth=e.thickness||this.thickness||1,!0===t.isSVG?t.strokeEllipse(g,d,p,h,0,0,Math.PI,m):(t.beginPath(),t.ellipse(g,d,p,h,0,0,Math.PI,m),t.stroke()),this.alpha&&(t.fillStyle=ow(w,this.alpha),!0===t.isSVG?t.fillEllipse(g,d,p,h,0,0,Math.PI,m):t.fill()),this.showBlocks&&\"all\"!==e.chr){t.fillStyle=w;const i=(e.start1-s)/o,n=(e.end1-s)/o,r=(e.start2-s)/o,a=(e.end2-s)/o,c=l?-this.blockHeight:this.blockHeight;t.fillRect(i,d,n-i,c),t.fillRect(r,d,a-r,c)}}else{let r=Math.round((e.start-s)/o),a=Math.round((e.end-s)/o);if(a<0||r>i||nthis.dataRange.max)continue;const c=Math.min(h,this.height-13);let d=a-r;d<3&&(d=3,r--);const u=e.chr===e.chr1?e.chr2:e.chr1;if(t.font=\"8px sans-serif\",t.textAlign=\"center\",t.fillStyle=ow(Nu(u),.5),l){const i=this.height-c;t.fillRect(r,i,d,c),t.fillText(u,r+d/2,i-5),e.drawState={x:r,y:i,w:d,h:c}}else t.fillRect(r,0,d,c),t.fillText(u,r+d/2,c+13),e.drawState={x:r,y:0,w:d,h:c}}}}}clearAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"})}paintAxis(e,t,i){const n={min:0,max:this.dataRange.max};\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?(this.painter.flipAxis=\"DOWN\"===this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(e,t,i)):this.clearAxis(e,t,i)}menuItemList(){let e=[];if(this.hasValue){e.push(\"
\");const t={nested:\"Nested\",proportional:\"Proportional - All\",inView:\"Proportional - Both Ends in View\",partialInView:\"Proportional - One End in View\"};e.push(\"Arc Type\");for(let i of[\"nested\",\"proportional\",\"inView\",\"partialInView\"])e.push({object:Bt(Dl(t[i],i===this.arcType)),click:function(){this.arcType=i,this.trackView.repaintViews()}})}return e.push(\"
\"),e.push({name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}),e.push({name:this.showBlocks?\"Hide Blocks\":\"Show Blocks\",click:function(){this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),\"proportional\"!==this.arcType&&\"inView\"!==this.arcType&&\"partialInView\"!==this.arcType||(e=e.concat(this.numericDataMenuItems())),this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add interactions to circular view\",click:function(){for(let e of this.trackView.viewports)this.addChordsForViewport(e.referenceFrame)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:\"Add interactions to circular view\",click:()=>{const e=t.referenceFrame;this.addChordsForViewport(e)}}),i.push(\"
\"),i}}addChordsForViewport(e){let t;if(\"all\"===e.chr)t=Object.values(this.featureSource.getAllFeatures()).flat();else{t=this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end).filter((e=>e.drawState))}if(0===t.length)return;Pm(t.map((e=>{const t=e._f||e;return{uniqueId:`${t.chr1}:${t.start1}-${t.end1}_${t.chr2}:${t.start2}-${t.end2}`,refName:zm(t.chr1),start:t.start1,end:t.end1,mate:{refName:zm(t.chr2),start:t.start2,end:t.end2}}})),this,e,.5)}doAutoscale(e){let t=0;if(e)for(let i of e){const e=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(e)||(t=Math.max(t,e))}return{min:0,max:t}}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){const t=e._||e;if(i.push({name:\"Region 1\",value:rw(t.chr1,t.start1,t.end1,t.strand1)}),i.push({name:\"Region 2\",value:rw(t.chr2,t.start2,t.end2,t.strand2)}),t.name&&i.push({name:\"Name\",value:t.name}),void 0!==t.value&&i.push({name:\"Value\",value:t.value}),void 0!==t.score&&i.push({name:\"Score\",value:t.score}),t.extras&&this.header&&this.header.columnNames){const e=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r=t-a&&e.canvasX<=t+s+a&&e.canvasY>=n&&e.canvasY<=n+o){const n=-Math.abs(e.canvasX-(t+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((e,t)=>e.score-t.score)),i.map((e=>e.feature))}}function nw(e,t){let i=(e.start1+e.end1)/2,n=(e.start2+e.end2)/2;if(\"all\"===e.chr&&(i=t.getGenomeCoordinate(e.chr1,i),n=t.getGenomeCoordinate(e.chr2,n)),i>n){const e=i;i=n,n=e}return{m1:i,m2:n}}function rw(e,t,i,n){return n&&\".\"!==n?`${e}:${Rt(t+1)}-${Rt(i)} (${n})`:`${e}:${Rt(t+1)}-${Rt(i)}`}const sw=new Map;function ow(e,t){const i=`${e}_${t}`;let n=sw.get(i);return n||(n=_s.addAlpha(e,t),sw.set(i,n)),n}function aw(e){const t=e=>{const t=Object.assign({},e);return t.chr=\"all\",t.start=i.getGenomeCoordinate(e.chr1,e.start1),t.end=i.getGenomeCoordinate(e.chr2,e.end2),t},i=this.genome;let n,r=0;for(let t of i.wgChromosomeNames){let i=e[t];if(i)for(let e of i)e.dup||(r++,e.score&&(!n||e.score>n.score)&&(n=e))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),c=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let l,h=[],d=[];for(let e=0;e=400){const e=Error(r.statusText);throw e.code=s,e}return r.arrayBuffer()}}class hw{constructor(e){this.file=e.file,this.fetchSize=e.fetchSize||16e3,this.maxSize=e.maxSize||1e6,this.buffers=[]}async read(e,t){let i=this.buffers.filter((i=>i.overlaps(e,e+t)));for(let n of i)if(n.contains(e,e+t))return n.slice(e,e+t);if(0===i.length){let i=Math.max(t,this.fetchSize);this.buffers.sort(((e,t)=>e.start-t.start));const n=function(e,t,i){let n=i-1,r=e.length;for(;1+n>1);t(e[i])?r=i:n=i}return r}(this.buffers,(t=>t.start>e),0);ne.start-t.start));const n=[];let r=e;for(let e of i){if(rr){const e=r,t=s-e,i=await this.file.read(e,t),o=new dw(e,i);n.push(o)}const o=n[0].start,a=function(e){const t=e.reduce(((e,t)=>e+t.byteLength),0),i=new Uint8Array(t);let n=0;for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(n.map((e=>e.buffer))),c=new dw(o,a),l=new Set(i);return this.buffers=this.buffers.filter((e=>!l.has(e))),this.addBuffer(c),c.slice(e,e+t)}}addBuffer(e){const t=this.buffers.reduce(((e,t)=>e+t.size),0)+e.size;if(t>this.maxSize){const e=t-this.maxSize;this.buffers.sort(((e,t)=>e.creationTime-t.creationTime));let i,n=0;for(i=0;ie));i++);this.buffers=ithis.buffer.byteLength)throw Error(\"buffer bounds error\");return this.buffer.slice(e-this.start,t-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(e,t){return e>=this.start&&t<=this.end}overlaps(e,t){return e>this.start&&ethis.start&&t(((e,t,i)=>{t in e?fw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,\"symbol\"!=typeof t?t+\"\":t,i),i);async function gw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=await Aw.unpack_from_async(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function mw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=Aw.unpack_from(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function ww(e){e||e()}function bw(e){var t=\"<\"+Array.from(e.values()).join(\"\");return Aw.calcsize(t)}function Fw(e,t=8){return Math.ceil(e/t)*t}var vw={u:\"Uint\",i:\"Int\",f:\"Float\"};function yw(e){var t,i,n=Aw._is_big_endian(e);if(/S/.test(e))t=\"getString\",i=0|((e.match(/S(\\d*)/)||[])[1]||1);else{let[n,r,s]=e.match(/[<>=!@]?(i|u|f)(\\d*)/);i=parseInt(s||4,10),t=\"get\"+vw[r]+(8*i).toFixed()}return[t,n,i]}var Aw=new class{constructor(){this.big_endian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}(),this.getters={s:\"getUint8\",b:\"getInt8\",B:\"getUint8\",h:\"getInt16\",H:\"getUint16\",i:\"getInt32\",I:\"getUint32\",l:\"getInt32\",L:\"getUint32\",q:\"getInt64\",Q:\"getUint64\",f:\"getFloat32\",d:\"getFloat64\"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let e=Object.keys(this.byte_lengths).join(\"\");this.fmt_size_regex=\"(\\\\d*)([\"+e+\"])\"}calcsize(e){for(var t,i=0,n=new RegExp(this.fmt_size_regex,\"g\");null!==(t=n.exec(e));){let e=parseInt(t[1]||1,10),n=t[2];i+=e*this.byte_lengths[n]}return i}_is_big_endian(e){return!/^)/.test(e)||this.big_endian)}async unpack_from_async(e,t,i){i=Number.parseInt(i||0);const n=this.calcsize(e),r=await t.slice(i,i+n);let s=0;for(var o,a=new Cw(r),c=[],l=this._is_big_endian(e),h=new RegExp(this.fmt_size_regex,\"g\");null!==(o=h.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if(\"s\"==t)c.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;de+(t<<8*i)),0);return o}var kw=class{constructor(e,t){this.buf=e,this.offset=t,this.dtype=this.determine_dtype()}async determine_dtype(){let e=await gw(Iw,this.buf,this.offset);this.offset+=Sw;let t=15&e.get(\"class_and_version\");if(t==Ew)return this._determine_dtype_fixed_point(e);if(t==Nw)return this._determine_dtype_floating_point(e);if(t==Bw)throw\"Time datatype class not supported.\";if(t==Mw)return this._determine_dtype_string(e);if(t==Rw)throw\"Bitfield datatype class not supported.\";if(t==Dw)return{datatype_class:Dw,size:e.get(\"size\")};if(t==Tw)return this._determine_dtype_compound(e);if(t==Lw)return[\"REFERENCE\",e.get(\"size\")];if(t==zw)return this.determine_dtype();if(t==Pw)throw\"Array datatype class not supported.\";if(t==Hw){let t=this._determine_dtype_vlen(e);if(\"VLEN_SEQUENCE\"==t[0]){t=[\"VLEN_SEQUENCE\",this.determine_dtype()]}return t}throw\"Invalid datatype class \"+t}_determine_dtype_fixed_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;var n;return i=(8&e.get(\"class_bit_field_0\"))>0?\"i\":\"u\",n=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=4,n+i+t.toFixed()}_determine_dtype_floating_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;return i=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=12,i+\"f\"+t.toFixed()}_determine_dtype_string(e){return\"S\"+e.get(\"size\").toFixed()}_determine_dtype_vlen(e){return 1!=(1&e.get(\"class_bit_field_0\"))?[\"VLEN_SEQUENCE\",0,0]:[\"VLEN_STRING\",e.get(\"class_bit_field_0\")>>4,1&e.get(\"class_bit_field_1\")]}_determine_dtype_compound(e){throw\"Compound type not yet implemented!\"}},Iw=new Map([[\"class_and_version\",\"B\"],[\"class_bit_field_0\",\"B\"],[\"class_bit_field_1\",\"B\"],[\"class_bit_field_2\",\"B\"],[\"size\",\"I\"]]),Sw=bw(Iw);bw(new Map([[\"offset\",\"I\"],[\"dimensionality\",\"B\"],[\"reserved_0\",\"B\"],[\"reserved_1\",\"B\"],[\"reserved_2\",\"B\"],[\"permutation\",\"I\"],[\"reserved_3\",\"I\"],[\"dim_size_1\",\"I\"],[\"dim_size_2\",\"I\"],[\"dim_size_3\",\"I\"],[\"dim_size_4\",\"I\"]]));var Ew=0,Nw=1,Bw=2,Mw=3,Rw=4,Dw=5,Tw=6,Lw=7,zw=8,Hw=9,Pw=10;function Ow(e){let t=e.length;for(;--t>=0;)e[t]=0}Ow(new Array(576)),Ow(new Array(60)),Ow(new Array(512)),Ow(new Array(256)),Ow(new Array(29)),Ow(new Array(30));var Uw=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16},qw=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})()),Qw=(e,t,i,n)=>{const r=qw,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Vw={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},jw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Ww=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gw={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Ww(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:RA>=248?5:RA>=240?4:RA>=224?3:RA>=192?2:1;Kw[254]=Kw[254]=1;var Yw={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&$w)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Kw[e[i]]>t?i:t}};var Xw=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Zw=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=12;break e}e.msg=\"invalid literal/length code\",k.mode=30;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=30;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null,k=0;const I=new Uint16Array(16),S=new Uint16Array(16);let E,N,B,M=null,R=0;for(g=0;g<=Jw;g++)I[g]=0;for(m=0;m=1&&0===I[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(S[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){E=g-y,o[m]p?(N=M[R+o[m]],B=x[k+o[m]]):(N=96,B=0),l=1<>y)+h]=E<<24|N<<16|B}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--I[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0},{Z_FINISH:sb,Z_BLOCK:ob,Z_TREES:ab,Z_OK:cb,Z_STREAM_END:lb,Z_NEED_DICT:hb,Z_STREAM_ERROR:db,Z_DATA_ERROR:ub,Z_MEM_ERROR:fb,Z_BUF_ERROR:pb,Z_DEFLATED:gb}=jw,mb=12,wb=30,bb=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Fb(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var vb,yb,Ab=e=>{if(!e||!e.state)return db;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,cb},Cb=e=>{if(!e||!e.state)return db;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ab(e)},_b=(e,t)=>{let i;if(!e||!e.state)return db;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?db:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Cb(e))},xb=(e,t)=>{if(!e)return db;const i=new Fb;e.state=i,i.window=null;const n=_b(e,t);return n!==cb&&(e.state=null),n},kb=!0,Ib=e=>{if(kb){vb=new Int32Array(512),yb=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rb(1,e.lens,0,288,vb,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rb(2,e.lens,0,32,yb,0,e.work,{bits:5}),kb=!1}e.lencode=vb,e.lenbits=9,e.distcode=yb,e.distbits=5},Sb=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return db;i=e.state,i.mode===mb&&(i.mode=13),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=cb;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=wb;break}if((15&l)!==gb){e.msg=\"unknown compression method\",i.mode=wb;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg=\"invalid window size\",i.mode=wb;break}i.dmax=1<>8&1),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Qw(i.check,x,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&(i.check=Qw(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mb;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=14;break;case 1:if(Ib(i),i.mode=20,t===ab){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=wb}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=wb;break}if(i.length=65535&l,l=0,h=0,i.mode=15,t===ab)break e;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=mb;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=wb;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=rb(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=wb;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=wb;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=wb;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===wb)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=wb;break}if(i.lenbits=9,k={bits:i.lenbits},C=rb(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=wb;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=rb(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=wb;break}if(i.mode=20,t===ab)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Zw(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===mb&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=mb;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=wb;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=wb;break}i.offset=b,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=wb;break}i.mode=25;case 25:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=wb;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<xb(e,15),inflateInit2:xb,inflate:Eb,inflateEnd:e=>{if(!e||!e.state)return db;let t=e.state;return t.window&&(t.window=null),e.state=null,cb},inflateGetHeader:(e,t)=>{if(!e||!e.state)return db;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,cb):db},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?db:11===n.mode&&(r=1,r=Uw(r,t,i,0),r!==n.check)?ub:(s=Sb(e,t,i,i),s?(n.mode=31,fb):(n.havedict=1,cb))):db},inflateInfo:\"pako inflate (from Nodeca project)\"};var Bb=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1},Mb=Object.prototype.toString,{Z_NO_FLUSH:Rb,Z_FINISH:Db,Z_OK:Tb,Z_STREAM_END:Lb,Z_NEED_DICT:zb,Z_STREAM_ERROR:Hb,Z_DATA_ERROR:Pb,Z_MEM_ERROR:Ob}=jw;function Ub(e){this.options=Gw.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Xw,this.strm.avail_out=0;let i=Nb.inflateInit2(this.strm,t.windowBits);if(i!==Tb)throw new Error(Vw[i]);if(this.header=new Bb,Nb.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Yw.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Mb.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Nb.inflateSetDictionary(this.strm,t.dictionary),i!==Tb)))throw new Error(Vw[i])}function qb(e,t){const i=new Ub(t);if(i.push(e),i.err)throw i.msg||Vw[i.err];return i.result}Ub.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Db:Rb,\"[object ArrayBuffer]\"===Mb.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Nb.inflate(i,o),s===zb&&r&&(s=Nb.inflateSetDictionary(i,r),s===Tb?s=Nb.inflate(i,o):s===Pb&&(s=zb));i.avail_in>0&&s===Lb&&i.state.wrap>0&&0!==e[i.next_in];)Nb.inflateReset(i),s=Nb.inflate(i,o);switch(s){case Hb:case Pb:case zb:case Ob:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===Lb))if(\"string\"===this.options.to){let e=Yw.utf8border(i.output,i.next_out),t=i.next_out-e,r=Yw.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Tb||0!==a){if(s===Lb)return s=Nb.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ub.prototype.onData=function(e){this.chunks.push(e)},Ub.prototype.onEnd=function(e){e===Tb&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Gw.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qb=function(e,t){return(t=t||{}).raw=!0,qb(e,t)},Vb={Inflate:Ub,inflate:qb,inflateRaw:Qb,ungzip:qb,constants:jw},{Inflate:jb,inflate:Wb,inflateRaw:Gb,ungzip:$b}=Vb,Kb=Wb,Yb=$b;var Xb=new Map([[1,function(e,t){let i=new Uint8Array(e);return Kb(i).buffer}],[2,function(e,t){let i=e.byteLength,n=new Uint8Array(i),r=Math.floor(i/t),s=new DataView(e);for(var o=0;oHH\",e,i);if(c%=65535,r!=(a%=65535)||s!=c)throw'ValueError(\"fletcher32 checksum invalid\")'}(e),e.slice(0,-4)}]]),Zb=class{constructor(e,t){this.fh=e,this.offset=t,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let e=this.depth;for(;e>0;){for(var t of this.all_nodes.get(e))for(var i of t.get(\"addresses\"))this._add_node(await this._read_node(i,e-1));e--}}async _read_root_node(){let e=await this._read_node(this.offset,null);this._add_node(e),this.depth=e.get(\"node_level\")}_add_node(e){let t=e.get(\"node_level\");this.all_nodes.has(t)?this.all_nodes.get(t).push(e):this.all_nodes.set(t,[e])}async _read_node(e,t){let i=await this._read_node_header(e,t);return i.set(\"keys\",[]),i.set(\"addresses\",[]),i}async _read_node_header(e){throw\"NotImplementedError: must define _read_node_header in implementation class\"}},Jb=class extends Zb{constructor(){super(...arguments),pw(this,\"B_LINK_NODE\",new Map([[\"signature\",\"4s\"],[\"node_type\",\"B\"],[\"node_level\",\"B\"],[\"entries_used\",\"H\"],[\"left_sibling\",\"Q\"],[\"right_sibling\",\"Q\"]]))}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);if(null!=t&&i.get(\"node_level\")!=t)throw\"node level does not match\";return i}},eF=class extends Jb{constructor(e,t){super(e,t),pw(this,\"NODE_TYPE\",0),this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=bw(this.B_LINK_NODE);let n=[],r=[],s=i.get(\"entries_used\");for(var o=0;o=0&&F[A]>=e[A];A--)F[A]=0,b[A]=w[A],A>0&&(F[A-1]+=1,b[A-1]+=1);if(b.slice(0,-1).every((function(e,i){return e=0;o--){if(t&1<0?r*=n:r=n}}return s}_nrecords_max(e,t,i){return Math.floor((e-10-i)/(t+i))}_required_bytes(e){return Math.ceil(_w(e)/8)}_int_format(e){return[\"0&&(h=(await Aw.unpack_from_async(a,this.fh,i))[0],i+=r),c.push([n,l,h])}}return s.set(\"keys\",a),s.set(\"addresses\",c),s}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);return i.set(\"node_level\",t),i}*iter_records(){for(let e of this.all_nodes.values())for(let t of e)for(let e of t.get(\"keys\"))yield e}_parse_record(e){throw\"NotImplementedError\"}},nF=class extends iF{constructor(){super(...arguments),pw(this,\"NODE_TYPE\",5)}async _parse_record(e,t,i){let n=(await Aw.unpack_from_async(\"0)throw\"Filter info size not supported on FractalHeap\";if(t.get(\"btree_address_huge_objects\")!=dF)throw\"Huge objects not implemented in FractalHeap\";t.set(\"btree_address_huge_objects\",null),t.get(\"root_block_address\")==dF&&t.set(\"root_block_address\",null);let i=t.get(\"log2_maximum_heap_size\"),n=this._min_size_nbits(i),r=new Map([[\"signature\",\"4s\"],[\"version\",\"B\"],[\"heap_header_adddress\",\"Q\"],[\"block_offset\",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=bw(r),2&~t.get(\"flags\")||r.set(\"checksum\",\"I\"),this.direct_block_header=r,this.direct_block_header_size=bw(r);let s=t.get(\"maximum_direct_block_size\");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,t.get(\"max_managed_object_size\"));this._managed_object_length_size=this._min_size_integer(o);let a=t.get(\"starting_block_size\"),c=t.get(\"table_width\");if(!(a>0))throw\"Starting block size == 0 not implemented\";let l=Number(Math.floor(Math.log2(s)));ww(1n<0)for await(let e of this._iter_indirect_block(this.fh,f,p))u.push(e);else{let e=await this._read_direct_block(this.fh,f,a);u.push(e)}let g=u.reduce(((e,t)=>e+t.byteLength),0),m=new Uint8Array(g),w=0;u.forEach((e=>{m.set(new Uint8Array(e),w),w+=e.byteLength})),this.managed=m.buffer}async _read_direct_block(e,t,i){let n=await e.slice(t,t+i);return ww(\"FHDB\"==mw(this.direct_block_header,n).get(\"signature\")),n}get_data(e){let t=Aw.unpack_from(\">4&3,n=1;if(0==i){ww(0==t>>6);let i=this._managed_object_offset_size,r=xw(i,e,n);n+=i,i=this._managed_object_length_size;let s=xw(i,e,n);return this.managed.slice(r,r+s)}throw 1==i?\"tiny objectID not supported in FractalHeap\":2==i?\"huge objectID not supported in FractalHeap\":\"unknown objectID type in FractalHeap\"}_min_size_integer(e){return this._min_size_nbits(_w(e))}_min_size_nbits(e){return Math.ceil(e/8)}async*_iter_indirect_block(e,t,i){let n=await gw(this.indirect_block_header,e,t);t+=this.indirect_block_header_size,ww(\"FHIB\"==n.get(\"signature\"));let r=n.get(\"block_offset\").reduce(((e,t,i)=>e+(t<<8*i)),0);n.set(\"block_offset\",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;ithis._chunks))}get shape(){let e=this.find_msg_type(ZF)[0].get(\"offset_to_message\");return async function(e,t){let i=(await Aw.unpack_from_async(\"255&&(s=(await Aw.unpack_from_async(\"0;e.set(\"optional\",a);let c,l=(await Aw.unpack_from_async(\"0&&(c=(await Aw.unpack_from_async(`${s}s`,i,t))[0],t+=s),e.set(\"name\",c);let h=await Aw.unpack_from_async(`<${l}i`,i,t);t+=4*l,e.set(\"client_data_values\",h),r.push(e)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(e){return this.msgs.filter((function(t){return t.get(\"type\")==e}))}async get_attributes(){let e={},t=this.find_msg_type(sv);for(let i of t){let t=i.get(\"offset_to_message\"),[n,r]=await this.unpack_attribute(t);e[n]=r}return e}async get_fillvalue(){var e,t=this.find_msg_type(tv)[0].get(\"offset_to_message\");let i=(await Aw.unpack_from_async(\"=r&&([s,r]=a[++c],l=0);let t=await gw(PF,e,s+l),i=s+l+OF;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[u,f]=await Aw.unpack_from_async(\"=o-qF){let e=c[++l];if(null==e)break;[r,o]=e,h=0}let t=await gw(UF,e,r+h),i=r+h+qF+n;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[d,u]=await Aw.unpack_from_async(\"0,c=(4&n)>0;(8&n)>0?(r=(await Aw.unpack_from_async(\"0&&(t+=8);let r=(2&n)>0?jF:VF,s=await gw(r,e,t),o=new Map;for(let[e,t]of s.entries())o.set(e,t==IF?null:t);return o}get is_dataset(){return this.find_msg_type(ZF).length>0}async get_data(){let e=this.find_msg_type(nv)[0].get(\"offset_to_message\");var[t,i,n,r]=await this._get_data_message_properties(e);if(0==n)throw\"Compact storage of DataObject not implemented\";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(e):void 0}async _get_data_message_properties(e){let t,i,n,[r,s,o]=await Aw.unpack_from_async(\"=1&&r<=4),[r,t,i,n]}async _get_contiguous_data(e){let[t]=await Aw.unpack_from_async(\"=!@\\|]?(i|u|f|S)(\\d*)/.test(n)){let[e,i,s]=yw(n),a=new Array(r);const c=await this.fh.slice(t,t+s*r);let l=new Cw(c);for(var o=0;o=1&&t<=3);var a=\"<\"+(i-1).toFixed()+\"I\",c=await Aw.unpack_from_async(a,this.fh,s);this._chunks=c,this._chunk_dims=i,this._chunk_address=o}}}};var IF=Aw.unpack_from(\"this.get(e)))}length(){return this.keys.length}_dereference(e){if(!e)throw\"cannot deference null reference\";let t=this.file._get_object_by_address(e);if(null==t)throw\"reference not found in file\";return t}async get(e){if(\"number\"==typeof e)return this._dereference(e);var t=dv(e);if(\"/\"==t)return this.file;if(\".\"==t)return this;if(/^\\//.test(t))return this.file.get(t.slice(1));if(\"\"!=function(e){let t=\"/\",i=e.lastIndexOf(t)+1,n=e.slice(0,i),r=new RegExp(\"^\"+t+\"+$\"),s=new RegExp(t+\"$\");n&&!r.test(n)&&(n=n.replace(s,\"\"));return n}(t))var[i,n]=t.split(/\\/(.*)/);else var i=t,n=\".\";if(!(i in this._links))throw i+\" not found in group\";var r=dv(this.name+\"/\"+i);let s=this._links[i];if(\"string\"==typeof s)try{return this.get(s)}catch(e){return null}var o=new kF(this.file._fh,s);if(await o.ready,o.is_dataset){if(\".\"!=n)throw r+\" is a dataset, not a group\";return new hv(r,o,this)}var a=new cv(r,this);return await a.init(o),a.get(n)}visit(e){return this.visititems(((t,i)=>e(t)))}visititems(e){var t=this.name.length;/\\/$/.test(this.name)||(t+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=e(n.name.slice(t),n);if(null!=r)return r;n instanceof cv&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},lv=class extends cv{constructor(e,t,i){super(\"/\",null),this.ready=this.init(e,t,i)}async init(e,t,i){var n=new sF(e,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new kF(e,r);if(await s.ready,this.parent=this,this.file=this,this.name=\"/\",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=e,this.filename=t||\"\",this.mode=\"r\",this.userblock_size=0,i&&i.index)this.index=i.index;else{let t;if(i&&i.indexOffset)t=i.indexOffset;else{const e=await this.attrs;if(e.hasOwnProperty(\"_index_offset\"))t=e._index_offset;else{const e=this.indexName||\"_index\",i=await s.find_link(e);i&&(t=i[1])}}if(t)try{const i=new kF(e,t);await i.ready;const n=await i.get_data(),r=Yb(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(e){console.error(`Error loading index by offset ${e}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(e){return this._dataobjects.offset==e?this:this.visititems((e=>{e._dataobjects.offset}))}},hv=class extends Array{constructor(e,t,i){super(),this.parent=i,this.file=i.file,this.name=e,this._dataobjects=t,this._attrs=null,this._astype=null}get value(){var e=this._dataobjects.get_data();return null==this._astype?this.getValue(e):e.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(e,t){const i=e.length,n=t.reduce(((e,t)=>e*t),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=e;const s=t.slice(1).reverse();for(let e of s){const t=[],{length:i}=r;let n=0;for(;n{let t=e.indexOf(\"\\0\");return t>=0?e.substring(0,t):e})):e}};function dv(e){return e.replace(/\\/(\\/)+/g,\"/\")}async function uv(e){var t;e.url&&(\"function\"==typeof(t=e.url).slice&&\"function\"==typeof t.arrayBuffer)&&(e.file=e.url,e.url=void 0);const i=void 0!==e.url;let n=e.reader?e.reader:function(e){if(e.url)return new lw(e);if(e.path)return new NodeLocalFile(e);if(e.file)return new uw(e.file);throw Error(\"One of 'url', 'path (node only)', or 'file (browser only)' must be specified\")}(e);const r=e.fetchSize||2e3,s=e.maxSize||2e5;i&&(n=new hw({file:n,fetchSize:r,maxSize:s}));const o=new fv(n),a=await async function(e){let t;if(e.indexReader)t=e.indexReader;else{if(e.index)return e.index;e.indexURL?t=new lw({url:e.indexURL}):e.indexPath?t=new NodeLocalFile({path:e.indexPath}):e.indexFile&&(t=new uw({file:e.indexFile}))}if(t){const e=await t.read(),i=(new TextDecoder).decode(e);return JSON.parse(i)}return}(e),c=e.indexOffset,l=function(e){if(e.url)return pv(e.url);if(e.path)return pv(e.path);if(e.file)return e.file.name}(e),h=new lv(o,l,{index:a,indexOffset:c});return await h.ready,h}class fv{constructor(e){this.fileReader=e}async slice(e,t){return this.fileReader.read(e,t-e)}}function pv(e){const t=e.lastIndexOf(\"/\");return t>0?e.substring(t+1):e}class gv{constructor(e,t){this.chrom=e,this.signal_bin_size=t;this.signals={raw_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}`,gc_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}_GC`,gc_partition:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_merge`,baf:`snp_likelihood_${this.chrom}_${this.signal_bin_size}_mask`,baf_i1:`snp_i1_${this.chrom}_${this.signal_bin_size}_mask`,Mosaic_segments:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_segments_2d`,Mosaic_calls:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_call_2d`}}}class mv{constructor(e,t=1e5){this.h5_file=e,this.bin_size=t,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await uv({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(e=this.bin_size){let t=await this.fetch();this.h5_obj=t,this.pytor_keys=t.keys;let i=new wv(this.pytor_keys),n=i.get_rd_bins(),r=i.get_snp_bins();this.available_bins=[...new Set(n,r)],this.available_bins.includes(e)||(e=this.available_bins.at(-1));const s=await t.get(\"rd_chromosomes\");await s.dtype;let o=await s.value,a=await this.rd_stat(e);var c=[],l=[],h=[],d=[],u=[],f=[];for(let t of o){let i=new gv(t,e);var p=i.signals.raw_RD;let n=await this.get_chr_signal(t,e,p,a);c=c.concat(n);var g=i.signals.gc_RD;let r=await this.get_chr_signal(t,e,g,a);l=l.concat(r);let s=i.signals.gc_partition,o=await this.get_chr_signal(t,e,s,a);h=h.concat(o);let m=await this.rd_call_combined(t,e,a,i);d=d.concat(m);let w=i.signals.baf_i1,b=await this.get_baf_signals_v2(t,e,w);u=u.concat(b[0]),f=f.concat(b[1])}this.callers=[],0!=d.length&&this.callers.push(\"ReadDepth\"),0!=d.length&&this.callers.push(\"2D\");var m={},w={RD_Raw:c,RD_Raw_gc_coor:l,ReadDepth:h,\"2D\":d,BAF1:u,BAF2:f};return m[e]=w,m}decode_segments(e){let t=[],i=[];for(let n of e)4294967295==n?(t.push(i),i=[]):i.push(n);return t}async rd_call_combined(e,t,i,n){let r,s=[],o=n.signals.Mosaic_segments;if(this.pytor_keys.includes(o)){const e=await this.h5_obj.get(o);let t=await e.value;r=this.decode_segments(t)}let a=n.signals.Mosaic_calls;if(this.pytor_keys.includes(a)){const n=await this.h5_obj.get(a);let o=await n.to_array();r.forEach(((n,r)=>{n.forEach(((n,a)=>{s.push({chr:e,start:n*t,end:(n+1)*t,value:o[0][r]/i[4]*2})}))}))}return s}async rd_stat(e){let t,i=`rd_stat_${e}_auto`;if(this.pytor_keys.includes(i)){const e=await this.h5_obj.get(i);t=await e.value}return t}async get_chr_signal(e,t,i,n){let r=[];if(this.pytor_keys.includes(i)){const s=await this.h5_obj.get(i);(await s.value).forEach(((i,s)=>{r.push({chr:e,start:s*t,end:(s+1)*t,value:i/n[4]*2})}))}return r}async get_baf_signals(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{let a=Math.max(...i);const c=i.indexOf(a);let l=Math.max(c/200,1-c/200);r.push({chr:e,start:o*t,end:(o+1)*t,value:n*l}),.5!=l&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(1-l)})}))}return[r,s]}async get_baf_signals_v2(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{isNaN(i)||(r.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5-i)}),.5!=i&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5+i)}))}))}return[r,s]}}class wv{constructor(e){this.signals=e}get_rd_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^his_rd_p_(.*)_(\\d+)$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}get_snp_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^snp_likelihood_(.*)_(\\d+)_mask$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}}function bv(e){let t=function(e){if(e.length<4)return e;let t,i,n,r,s,o;return t=e.slice().sort(((e,t)=>e-t)),t.length/4%1==0?(i=.5*(t[t.length/4]+t[t.length/4+1]),n=.5*(t[t.length*(3/4)]+t[t.length*(3/4)+1])):(i=t[Math.floor(t.length/4+1)],n=t[Math.ceil(t.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,t.filter((e=>e>=o&&e<=s))}(e);const i=t.length,n=t.reduce(((e,t)=>e+t))/i,r=Math.sqrt(t.map((e=>Math.pow(e-n,2))).reduce(((e,t)=>e+t))/i);return[n,r]}var Fv={range_function:function(e,t,i){return Array(Math.ceil((t-e)/i)).fill(e).map(((e,t)=>e+t*i))},getDistParams:bv,linspace:function(e,t,i){if(void 0===i&&(i=Math.max(Math.round(t-e)+1,1)),i<2)return 1===i?[e]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*t+(i-r)*e)/i;return n},GetFit:class{constructor(e){this.allBins=e}getValues(){return Object.values(this.allBins).reduce(((e,t)=>e.concat(t.filter((e=>e.binScore>0)).map((e=>e.binScore)))),[])}getMean(e){return e.reduce((function(e,t){return e+t}))/e.length}fit_data(){return bv(this.getValues())}histogram(e,t){const i=t[1]-t[0],n=[];e.forEach(((e,r)=>{t.forEach(((t,r)=>{if(n[t]||(n[t]={count:0}),t<=e&&e{r.push(e.count)})),r}}};function vv(e,t){return isNaN(e)||isNaN(t)||t<=0?NaN:0===e?.5:.5+.5*(yv(.5*t,.5,1)-yv(.5*t,.5,t/(t+e*e)))*Math.sign(e)}function yv(e,t,i){if(0==i)return 0;if(1==i)return 1;{let n=xv(e+t)-xv(e)-xv(t)+e*Math.log(i)+t*Math.log(1-i);return i<(e+1)/(e+t+2)?Math.exp(n)*Av(e,t,i)/e:1-Math.exp(n)*Av(t,e,1-i)/t}}function Av(e,t,i,n=1e3){let r=1,s=1,o=1,a=e+t,c=e+1,l=e-1,h=1-a*i/c;for(let d=0;d<=n;d++){let n=parseFloat(d+1),u=n+n,f=n*(t-n)*i/((l+u)*(e+u)),p=r+f*s,g=h+f*o;f=-(e+n)*(a+n)*i/((c+u)*(e+u));let m=g+f*h,w=r;if(s=p/m,o=g/m,r=(p+f*r)/m,h=1,Math.abs(r-w)<3e-7*Math.abs(r))return r}}function Cv(e){if(0==e||1==e)return 1;return e*Cv(e-1)}function _v(e){let t;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==e)t=1e99;else if(e%1==0)t=Cv(e-1);else{for(let t=0;tt?e:t}))}function Sv(e,t,i,n){return t*Math.exp(-1*(e-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function Ev(e,t,i,n){return Math.exp(-1*(e-i)**2/(t**2+n**2))}function Nv(e,t){let i;try{i=e.reduce(((e,i,n)=>e+Math.min(i,t[n])))}catch{return console.log(\"Failed to find likelihood overlap: \",e,t),0}return i}function Bv(e,t,i,n){return 0==t&&0==n?{nl:.5*(e+i),ne:0}:{nl:(e*n*n+i*t*t)/(t*t+n*n),ne:Math.sqrt(t*t*n*n/(t*t+n*n))}}function Mv(e,t){let i=parseInt(t*(e.length-1)),n=t*(e.length-1)-i;return iMath.floor(t/2)&&(n=t-1-n);const r=(t/2-n)/(t+1),s=Math.floor((t/2+n)/2),o=t-1-s;let a=e.slice(s,o+1).reduce(((e,t)=>e+t),0)/e.reduce(((e,t)=>e+t),0);return n===Math.floor(t/2)&&(a=1),{mean:r,p:a}}var Dv=class{constructor(e,t){this.wigFeatures=e,this.binSize=t}get_fit(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data();return{globalMean:t,globalStd:i}}async call_2d(e=null,t=null,i=\"both\",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let c=null==e?.05*this.binSize/3e9:e,l=null==t?parseInt(this.binSize/1e4):t,h=[],d=[],u=[],f=[],p=[],g=[];for(const[e,t]of Object.entries(this.wigFeatures)){let e=[],i=[],s=[];t.forEach(((t,n)=>{t.hets_count>4&&t.dp_count>l&&(e.push([n]),i.push(t.binScore),s.push(t.likelihood_score),delete t.likelihood_score)}));let o=[];for(let e=1;eMath.sqrt(Math.sqrt(e)**2+this.globalStd**2+Math.pow(a[t]/2,2)))),m=[];for(let t=0;t0;){m=m.filter((e=>\"number\"==typeof e));let t=Iv(m);if(isNaN(t)&&console.log(\"NaN value\",m),te*s[o+1][t])),r=n.reduce(((e,t)=>e+t))}catch{console.log(s),console.log(\"max_overlap:\",t,o,m.length),console.log(\"likelihood: \",o,s[o],s[o+1]),console.log(\"nlh: \",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(e){return e/r})),e[o].push(...e[o+1]),i.splice(o+1,1),g.splice(o+1,1),e.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o0){let e=Ev(i[o-1],g[o-1],i[o],g[o])*Nv(s[o-1],s[o]);m[o-1]=e}}let w=-1;for(;;){m=[];for(let t=0;te*s[r+1][t])),a=n.reduce(((e,t)=>e+t));s[r]=n.map((function(e){return e/a})),e[r].push(...e[r+1]),e[r]=e[r].sort(((e,t)=>e-t)),i.splice(o,1),g.splice(o,1),e.splice(o,1),s.splice(o,1),o>=e.length&&(r+=1,o=r+1)}else o+=1,o>=e.length&&(r+=1,o=r+1)}if(w==e.length)break;w=e.length}e.forEach(((e,n)=>{let o=Rv(s[n]);e.length>1&&(e.forEach(((e,s)=>{d.push(t[e]),o.mean<=r&&h.push(t[e]),t[e].segment_score=i[n]})),u.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let w=Fv.linspace(o,1,m),b={},F={};for(let e=10;e>-1;e--)for(let t=0;t1-t+t*e/2)),a=e/2;e>0?(n=.5-t/(t+s),r=w.map(((e,i)=>.5-(1-e+e*t)/(2-2*e+(t+s)*e)))):(n=0,r=w.map(((e,t)=>0*e)));for(let i=0;i{if(!isNaN(r[t])){let n=Sv(e*this.globalMean,1,u[i],f[i])*Mv(p[i],.5+r[t]);l+=n,n>h&&(h=n,d=w[t])}})),i in b?b[i].push([e,t,s,l/w.length,d]):b[i]=[e,t,s,l/w.length,d]}for(let e=0;ee[3]-t[3]));else if(b[e].sort(((e,t)=>e[3]-t[3])),\"both\"==i&&(F[e].sort(((e,t)=>e[3]-t[3])),F[e][0][3]>b[e][0][3])){let t=b[e].filter((t=>t[0]!=F[e][0][0]&&t[1]<=F[e][0][1]));b[e]=[F[e][0]].push(...t)}for(let e=0;e{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}formatDataStructure_BAF(e,t=-1){const i=[],n=[];for(const[r,s]of Object.entries(this.wigFeatures))s.forEach((r=>{var s={...r},o={...r};let a=r[e];.5!=a&&(o.value=t*(1-a),n.push(o)),s.value=t*a,i.push(s)}));return[i,n]}};const Tv=2871e6;function Lv(e){for(var t=1,i=1,n=1*e,r=1;r<50;r++)t*=r,n+=(i*=-1)*Math.pow(e,2*r+1)/(t*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function zv(e,t,i,n,r){var s=new Ov(i.slice(n,r));return 0==s.std&&(s.std=t>0?t*s.mean/e:1),Uv(e,s.mean,s.std,r-n)/(r-n)}function Hv(e,t,i,n,r){var s=new Ov(i.slice(n,r));if(s.means&!l&c0&&(h=zv(e,t,i,n-1,r)),r-n>2)var d=zv(e,t,i,n+1,r),u=zv(e,t,i,n,r-1);if(re+t))/e.length,this.std=Math.sqrt(e.reduce(((e,t)=>(t-this.mean)**2))/e.length)}}function Uv(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-kv.TdistributionCDF(Math.abs(r),n-1)}function qv(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-kv.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var Qv=class{constructor(e,t,i){this.rd=e,this.mean=t,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(e){var t=[];return e.forEach(((e,i)=>{var n=0;n=e>this.mean/4?this.mean/(this.std**2*e):4/this.std**2,t.push(n)})),t}meanShiftCaller(e,t=3){var i={};return Object.entries(this.rd).forEach((([e,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let e=0;e{var o=r.map(((e,t)=>!e)),a=[];Object.entries(n).forEach((([e,t])=>{a.push(t.binScore)}));var c=[0],l=0;for(let e=0;e0&&(c.push(c[c.length-1]+l-1),l=0):l+=1;c.shift();for(let i=0;i=a.length||Math.abs(t-i)>=a.length)){var u=(i-t)*Math.exp(-.5*(i-t)**2/e**2)*Math.exp(-.5*(a[t]-a[i])**2*h[t]);d[t]+=u}for(var f=new Array,p=0;p=0&&f.push(p);f.push(d.length-1),f=f.concat(c).sort(((e,t)=>e-t)),f=Array.from(new Set(f));var g=0;for(p=0;pe+t))/m.length;a.fill(w,g,f[p]+1),g=f[p]+1}}p=0;for(var b=0;p.01&&f.push(p+1)}f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1);for(p=1;p1))continue;v[0]=f[p-2];var y=[f[p],f[p]];if(!(p.01/Tv*bin_size*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>.01/Tv*bin_size*(A+_))continue}if(Uv(this.mean,x.mean,x.std,x.data.length)>.05)continue;let e=a.slice(F[0],F[1]);var B=new Ov(e);r.fill(!0,F[0],F[1]),s.fill(B.mean,F[0],F[1])}})),i[e]=s})),i}call_mean_shift(e=3){for(var t=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n{var s=t.map(((e,t)=>!e)),o=[];s.forEach(((e,t)=>{e&&o.push(this.rd[t])}));for(var a=[0],c=0,l=0;l0&&(a.push(a[a.length-1]+c-1),c=0):c+=1;a.shift();for(var h=0;h=o.length||Math.abs(l-f)>=o.length)){var p=(f-l)*Math.exp(-.5*(f-l)**2/n**2)*Math.exp(-.5*(o[l]-o[f])**2*d[l]);u[l]+=p}var g=new Array;for(l=0;l=0&&g.push(l);g.push(u.length-1),g=g.concat(a).sort(((e,t)=>e-t)),g=Array.from(new Set(g));var m=0;for(l=0;le+t))/w.length;o.fill(b,m,g[l]+1),m=g[l]+1}}for(l=0,f=0;l.01&&g.push(l+1)}g.unshift(0),g.push(i.length),t=new Array(this.rd.length).fill(!1);for(l=1;l1){v[0]=g[l-2];var y=[g[l],g[l]];if(l3.483106931382794e-9*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>3.483106931382794e-9*(A+_))continue}if(!(Uv(this.mean,x.mean,x.std,x.data.length)>.05)){var B=new Ov(this.rd.slice(F[0],F[1]));t.fill(!0,F[0],F[1]),i.fill(B.mean,F[0],F[1])}}}}}})),i}cnv_calling(e=1e5){var t=.25*this.mean,i=this.mean-t,n=this.mean+t,r=2971e6,s=this.meanShiftCaller(e),o={},a=[];return Object.entries(s).forEach((([c,l])=>{for(var h=!1;!h;){h=!0;var d=new Array(1).fill(0);for(let e=0;e.01&&d.push(e+1)}d.push(l.length);for(let e=0;e0&&(f=Math.abs(l[d[e]]-l[d[e-1]])),e{m.push(t.binScore)}));for(var w,b=new Array(l.length).fill(\"\"),F=0,v=.05*e/r;FA+1){var C=Pv(this.mean,this.std,m,A,_,v);if(C){var _=C;b.fill(\"D\",A,_)}}for(A=F;Fn;)F+=1;(_=F)>A+1&&(C=Pv(this.mean,this.std,m,A,_,v))&&(_=C,b.fill(\"A\",A,_)),F==y&&(F+=1)}for(F=0;FA+1&&(Hv(this.mean,this.std,m,A,_)<1682935038707506e-26&&b.fill([\"d\"]*(_-A),A,_),F-=1),F+=1}(F=0)=b.length););if(F>A){var k=new Ov(x.slice(A,F));x.fill(k.mean,A,F)}F=0;e--){var i;let n=this.allVariants[e];this.allVariants.splice(e,1);let r=n.chr;i=Math.max(Math.floor(n.start/this.rowBinSize),0),t[r]||(t[r]=[]),t[r][i]||(t[r][i]={chr:r,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const s=Object.values(n.calls);if(1!==s.length)throw Error(`Unexpected number of genotypes: ${s.length}. CNVPytor expects 1 and only 1 genotype`);const o=s[0],a=o.info.DP;a&&(t[r][i].dp_sum_score+=Number.parseInt(a),t[r][i].dp_count++);let c=o.info.AD.split(\",\"),l=o.genotype;if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){t[r][i].hets_count++;let e=parseInt(c[0]),n=parseInt(c[1]);t[r][i].hets.push({ref:e,alt:n})}}this.chromosomes=Object.keys(t);var n,r=this.adjust_bin_size(t);if(\"ReadDepth\"==e){n=new Wv(r,this.binSize).ReadDepth_caller();var s=this.formatDataStructure_BAF(r,\"max_likelihood\")}else if(\"2D\"==e){let e=new Dv(r,this.binSize),t=await e.call_2d();n=[t.binScore,[],t.segment_score];s=e.formatDataStructure_BAF(\"max_likelihood\",-1)}return[n,s]}formatDataStructure(e,t,i=1){const n=[];for(const[s,o]of Object.entries(e))for(let e of o){var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}return n}format_BAF_likelihood(e){const t=[];for(const[n,r]of Object.entries(e))for(let e of r){var i={...e};.5!=e.value&&(i.value=1-e.value,t.push(i))}return t}get_max_min_score(e){if(e.likelihood_score.length>0){const t=Math.max(...e.likelihood_score),i=e.likelihood_score.indexOf(t);e.value=Math.max(i/100,1-i/100),e.min_score=Math.min(i/100,1-i/100)}else e.score=0;return e}async getAllbins(){const e=await this.computeDepthFeatures();return new Fv.GetFit(e).fit_data(),e}formatDataStructure_BAF(e,t,i=-1){const n=[],r=[];for(const[a,c]of Object.entries(e))for(let e of c){var s={...e},o={...e};let a=e[t];.5!=a&&(o.value=i*(1-a),r.push(o)),s.value=i*a,n.push(s)}return[n,r]}adjust_bin_size(e){var t={};for(let r of this.chromosomes){t[r]||(t[r]=[]);for(let s=0;sjv(o.ref,o.alt,e)));else{var n=0;t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>{var a=t[r][s].likelihood_score[i]*jv(o.ref,o.alt,e);return n+=a,a})),t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>t[r][s].likelihood_score[i]/n))}t[r][s].binScore=100*parseInt(t[r][s].dp_sum_score/t[r][s].dp_count);const a=this.get_max_min_score(t[r][s]);t[r][s].max_likelihood=a.value}}return t}}function jv(e,t,i,n=!0){return Math.pow(i,e)*Math.pow(1-i,t)+Math.pow(i,t)*Math.pow(1-i,e)}class Wv{constructor(e,t){this.wigFeatures=e,this.binSize=t}ReadDepth_caller(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data(),n=new Qv(this.wigFeatures,t,i),r=n.meanShiftCaller(this.binSize),s=n.cnv_calling();return Object.entries(this.wigFeatures).forEach((([e,t])=>{t.forEach(((t,i)=>{t.partition_level=parseInt(r[e][i]),t.partition_call=parseInt(s[0][e][i])}))})),[this.formatDataStructure(\"binScore\",t),this.formatDataStructure(\"partition_level\",t),this.formatDataStructure(\"partition_call\",t),s[1]]}formatDataStructure(e,t=1){const i=[];for(const[r,s]of Object.entries(this.wigFeatures))for(let r of s){var n={...r};1!=t&&(n.value=r[e]/t*2),i.push(n)}return i}}class Gv extends Hl{static DEFAULT_TRACK_HEIGHT=250;constructor(e,t){super(e,t)}init(e){this.featureType=\"numeric\",this.type=\"cnvpytor\",e.max||(this.defaultScale=!0,this.autoscale=!1),e.height||(e.height=Gv.DEFAULT_TRACK_HEIGHT),this.type=\"cnvpytor\",this.graphType=e.graphType||\"points\",this.bin_size=e.bin_size||1e5,this.signal_name=e.signal_name||\"rd_snp\",this.cnv_caller=e.cnv_caller||\"2D\",this.colors=e.colors||[\"gray\",\"black\",\"green\",\"blue\"],super.init(e)}get supportsWholeGenome(){return!0}get_signals(){let e=[];return\"rd_snp\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller,\"BAF1\",\"BAF2\"]:\"rd\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller]:\"snp\"==this.signal_name?e=[\"BAF1\",\"BAF2\"]:\"cnh\"==this.signal_name&&(e=[this.cnv_caller]),e}get_signal_colors(){return[{singal_name:\"RD_Raw\",color:this.colors[0]},{singal_name:\"RD_Raw_gc_coor\",color:this.colors[1]},{singal_name:\"ReadDepth\",color:this.colors[2]},{singal_name:\"2D\",color:this.colors[2]},{singal_name:\"BAF1\",color:this.colors[3]},{singal_name:\"BAF2\",color:this.colors[3]}]}async postInit(){if(\"vcf\"==this.config.format){let e;this.featureSource?e=Object.values(this.featureSource.getAllFeatures()).flat():(this.featureSource=this.featureSource||Ad(this.config,this.browser.genome),this.header=await this.getHeader(),e=this.featureSource.reader.features);const t=new Vv(e,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},\"2D\"==this.cnv_caller?(r=await t.read_rd_baf(\"2D\"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size][\"2D\"]=i[2],this.available_callers=[\"2D\"]):(r=await t.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=[\"ReadDepth\"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new mv(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const e=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let t in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:\"wig\"};t.features=n,t.name=i,t.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(t);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+t),\"function\"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(e)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if(\"function\"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleKeys=this.callSets?this.callSets.map((e=>e.sample)):[],this.sampleNames=this.sampleKeys}return this.header}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat(this.numericDataMenuItems()),e.push(\"
\"),e.push(\"Bin Sizes\");for(let t of this.available_bins){const i=Dl(t,t===this.bin_size);e.push({object:Bt(i),click:async function(){this.bin_size=t,this.trackView.startSpinner(),await this.recreate_tracks(t),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"Signal Type\");let t={rd_snp:\"RD and BAF Likelihood\",rd:\"RD Signal\",snp:\"BAF Likelihood\"};for(let i in t){const n=Dl(t[i],i===this.signal_name);e.push({object:Bt(n),click:async function(){this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"CNV caller\");for(let t of this.available_callers){const i=Dl(t,t===this.cnv_caller);e.push({object:Bt(i),click:async function(){this.cnv_caller=t,this.trackView.startSpinner(),await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}if(this.variantState){e.push(\"
\");for(let t of this.available_callers)e.push({label:\"Convert to variant track\",click:()=>{this.convertToVariant()}})}return e}async recreate_tracks(e){this.tracks=[];const t=[];e in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(e)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:\"wig\"};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+e),\"function\"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}async getFeatures(e,t,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n)));return Promise.all(r)}}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features;if(!t)return;if(this.defaultScale&&(\"rd_snp\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||5}:\"rd\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||5}:\"snp\"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(e,t){let i=0,n=-Number.MAX_VALUE;for(let e of t)for(let t of e)void 0===t.value||Number.isNaN(t.value)||(i=Math.min(i,t.value),n=Math.max(n,t.value));return{min:i,max:n}}(e.referenceFrame.chr,t)),this.tracks)for(let i=0,n=this.tracks.length;ithis.logScale?this.computeYPixelValueInLogScale(e,i):this.computeYPixelValue(e,i);if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=n(t.y),r={strokeStyle:t.color,strokeWidth:1};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,r):xo.strokeLine(e.context,0,i,e.pixelWidth,i,r)}let r=n(2);xo.dashedLine(e.context,0,r,e.pixelWidth,r,5,{strokeStyle:\"lightgray\",strokeWidth:.5})}paintAxis(e,t,i){var n,r,s,o,a,c,l,h={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let d=void 0!==this.flipAxis&&this.flipAxis;function u(e){return e<0?Math.abs(e):0===e?\"0\":Math.abs(e)>=10||e%1==0?e.toFixed():Math.abs(e)>=1?e.toFixed(1):e.toFixed(2)}xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"}),n=(l=.95*t)-8,a={x:r=l,y:s=o=.01*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.min:this.dataRange.max),n+4,s+12,h),c={x:r,y:s=o=.99*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.max:this.dataRange.min),n+4,s-4,h),xo.strokeLine(e,a.x,a.y,c.x,c.y,h);const f=this.getScaleFactor(this.dataRange.min,this.dataRange.max,i,this.logScale),p=e=>this.logScale?this.computeYPixelValueInLogScale(e,f):this.computeYPixelValue(e,f),g=Math.ceil((this.dataRange.max-this.dataRange.min)/10);for(let t=Math.ceil(this.dataRange.min+1);t0&&t.push(\"
\"),t.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(e,i[n]);t.push(...r)}return t}}async convertToVariant(){this.variantState&&(Object.setPrototypeOf(this,Yv.prototype),this.init(this.variantState),await this.postInit(),this.trackView.clearCachedFeatures(),this.variantState.trackHeight&&this.trackView.setTrackHeight(this.variantState.trackHeight),this.trackView.checkContentHeight(),this.trackView.updateViews(),delete this.variantState)}}const $v=Mt,Kv=10;class Yv extends Hl{static defaults={displayMode:\"EXPANDED\",sortDirection:\"ASC\",showGenotypes:!0,expandedVariantHeight:10,squishedVariantHeight:2,squishedCallHeight:1,expandedCallHeight:10,expandedVGap:2,squishedVGap:1,expandedGroupGap:10,squishedGroupGap:5,featureHeight:14,noGenotypeColor:\"rgb(200,180,180)\",noCallColor:\"rgb(225, 225, 225)\",nonRefColor:\"rgb(200, 200, 215)\",mixedColor:\"rgb(200, 220, 200)\",homrefColor:\"rgb(200, 200, 200)\",homvarColor:\"rgb(17,248,254)\",hetvarColor:\"rgb(34,12,253)\",refColor:\"rgb(0,0,220)\",altColor:\"rgb(255,0,0)\",visibilityWindow:void 0,labelDisplayMode:void 0,type:\"variant\"};_sortDirections=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),e.variantHeight&&(this.expandedVariantHeight=e.variantHeight),this.featureSource=Ad(e,this.browser.genome),this.colorTables=new Map,e.colorTable){const t=e.colorBy||\"*\";this.colorTables.set(t,new ao(e.colorTable))}if(this.strokecolor=e.strokecolor,this._context_hook=e.context_hook,e.color&&(this.colorBy=void 0),this.nVariantRows=1,e.samples)for(let t of e.samples)this.sampleKeys=e.samples;e.sort&&(this.initialSort=e.sort),this._colorByItems=new Map([[\"none\",\"None\"]])}async postInit(){if(this.header=await this.getHeader(),this.header.INFO){const e=new Set(Object.keys(this.header.INFO));this.config.colorBy?this.colorBy=this.config.colorBy:!this.config.color&&e.has(\"AF\")&&(this.colorBy=\"AF\"),e.has(\"AF\")&&this._colorByItems.set(\"AF\",\"Allele frequency\"),e.has(\"VT\")&&this._colorByItems.set(\"VT\",\"Variant Type\"),e.has(\"SVTYPE\")&&this._colorByItems.set(\"SVTYPE\",\"SV Type\")}if(this.config.colorBy&&!this._colorByItems.has(this.config.colorBy)&&this._colorByItems.set(this.config.colorBy,this.config.colorBy),!this.disposed){if(this.header&&!this.sampleKeys&&(this.sampleKeys=this.header.sampleNameMap?Array.from(this.header.sampleNameMap.keys()):[]),void 0===this.visibilityWindow&&!1!==this.config.indexed){const e=Ht(this.config.url)?this.config.url.name:this.config.url;$v(e)&&e.toLowerCase().includes(\"gnomad\")?this.visibilityWindow=1e3:\"function\"==typeof this.featureSource.defaultVisibilityWindow?this.visibilityWindow=await this.featureSource.defaultVisibilityWindow():this.visibilityWindow=1e6}return this}}get supportsWholeGenome(){return!this.config.indexURL||!0===this.config.supportsWholeGenome}get color(){return this._color||\"rgb(0,0,150)\"}set color(e){this._color=e,e&&(this.colorBy=void 0)}async getHeader(){return this.header||\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getSampleCount(){return this.sampleKeys?this.sampleKeys.length:0}async getFeatures(e,t,i,n){void 0===this.header&&(this.header=await this.getHeader());const r=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow});if(this.initialSort){const e=this.initialSort;if(void 0===e.option||\"GENOTYPE\"===e.option.toUpperCase())this.sortSamplesByGenotype(e,r);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"ASC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return r}hasSamples(){return this.getSampleCount()>0}getSamples(){const e=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=t*((\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight)+e),r=Kv+t*(i+e);return{names:this.sampleKeys,yOffset:r,height:n}}computePixelHeight(e){if(!e||0===e.length)return Kv;const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,n=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=!1===this.showGenotypes?0:this.getSampleCount()*t;return Kv+t*(n+i)+i+(s+1)*(r+i)}variantRowCount(e){this.nVariantRows=e}draw({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){xo.fillRect(e,0,s,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const a=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,c=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,l=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=Kv+c*(l+a);let h=this.sampleColumns;const d=this.hasSamples();if(h&&d&&!1!==this.showGenotypes&&xo.strokeLine(e,0,this.variantBandHeight,t,this.variantBandHeight,{strokeStyle:\"rgb(224,224,224) \"}),o){const i=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+t*n+1;for(let t of o){if(t.enda)break;const o=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=Kv+(\"COLLAPSED\"===this.displayMode?0:t.row*(o+s)),l=o;let h=(t.start-r)/n,u=(t.end-r)/n,f=Math.max(1,u-h);f<3?(f=3,h-=1):f>5&&(h+=1,f-=2);const p=t._f||t;let g;try{g=p.alleleFreq()}catch(e){console.log(e)}if(\"AF\"===this.colorBy&&g){const t=Math.min(1,g)*l,i=l-t;e.fillStyle=p.isFiltered()?this.refColorFiltered:this.refColor,e.fillRect(h,c,f,i),e.fillStyle=p.isFiltered()?this.altColorFiltered:this.altColor,e.fillRect(h,c+i,f,t)}else e.fillStyle=this.getColorForFeature(p),e.fillRect(h,c,f,l);let m=this.getVariantStrokecolor(p);if(m&&(e.strokeStyle=m,e.strokeRect(h,c,f,l)),this.callContextHook(p,e,h,c,f,l),d&&!1!==this.showGenotypes){const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=t*(i+s);let n=0;for(let t of this.sampleKeys){const r=this.header.sampleNameMap.get(t),o=p.calls[r];if(o){const t=\"COLLAPSED\"===this.displayMode?0:p.row,r=this.sampleYOffset+n*this.sampleHeight+t*(i+s);let a=!0,c=!0,l=!1;if(o.genotype)for(let e of o.genotype){if(\".\"===e){l=!0;break}0!==e&&(c=!1),0===e&&(a=!1)}o.genotype?e.fillStyle=l?this.noCallColor:c?this.homrefColor:a?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,r,f,i)}n++}}}}else console.log(\"No feature list\")}get refColorFiltered(){return this._refColorFiltered||(this._refColorFiltered=_s.addAlpha(this.refColor,.2)),this._refColorFiltered}get altColorFiltered(){return this._altColorFiltered||(this._altColorFiltered=_s.addAlpha(this.altColor,.2)),this._altColorFiltered}getColorForFeature(e){const t=e._f||e;let i;if(this.colorBy&&\"none\"!==this.colorBy){const e=t.getAttributeValue(this.colorBy);i=void 0!==e?this.getVariantColorTable(this.colorBy).getColor(e):\"gray\"}else i=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"NONVARIANT\"===t.type?this.nonRefColor:\"MIXED\"===t.type?this.mixedColor:this.color;return t.isFiltered()&&(i=_s.addAlpha(i,.2)),i}getVariantStrokecolor(e){const t=e._f||e;let i;return i=this.strokecolor?\"function\"==typeof this.strokecolor?this.strokecolor(t):this.strokecolor:void 0,i}callContextHook(e,t,i,n,r,s){if(this._context_hook&&\"function\"==typeof this._context_hook){const o=e._f||e;t.save(),this._context_hook(o,t,i,n,r,s),t.restore()}}clickedFeatures(e){let t=super.clickedFeatures(e);const i=\"EXPANDED\"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+(\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=e.y;if(r<=this.variantBandHeight){const e=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-Kv)/(e+i));\"COLLAPSED\"!==this.displayMode&&(t=t.filter((e=>e.row===n)))}else if(this.sampleKeys){const e=r-this.variantBandHeight,i=Math.floor(e/this.sampleHeight);if(i>=0&&ie.row===r)),o=this.sampleKeys[i],a=this.header.sampleNameMap.get(o);t=s.map((e=>{const t=e.calls[a];return t.genotypeString=function(e,t){if(e.genotype){let i=\"\";if(\".\"===t.alternateBases)i=\"No Call\";else{const n=t.alternateBases.split(\",\");for(let r of e.genotype)if(i.length>0&&(i+=\" | \"),\".\"===r)i+=\".\";else if(0===r)i+=t.referenceBases;else{i+=n[r-1].replace(\"<\",\"<\")}}return i}}(t,e),t}))}}return t}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=this.browser.genome.id;let r=[];for(let e of t){const t=e._f||e;if(r.length>0&&r.push({html:'
'}),\"function\"==typeof t.popupData){const e=t.popupData(i,n);Array.prototype.push.apply(r,e)}}return r}menuItemList(){const e=[];if(this.header.INFO&&this.header.INFO){const t=this._colorByItems;e.push(\"
\");const i=Bt('
');i.text(\"Color by:\"),e.push({name:void 0,object:i,click:void 0,init:void 0});for(let n of t.keys()){const r=this.colorBy===n;e.push(this.colorByCB({key:n,label:t.get(n)},r))}e.push(this.colorByCB({key:\"info\",label:\"Info field...\"}))}if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const s of this.browser.sampleInfo.attributeNames)if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[s]}))){const o=Bt(\"
\");function a(){const e=this._sortDirections.get(s)||1;this.sortByAttribute(s,e),this.config.sort={option:\"ATTRIBUTE\",attribute:s,direction:e>0?\"ASC\":\"DESC\"},this._sortDirections.set(s,-1*e)}o.html(`  ${s.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:o,click:a})}}e.push(\"
\"),this.getSampleCount()>0&&(e.push({object:Bt('
')}),e.push({object:Bt(Dl(\"Show Genotypes\",this.showGenotypes)),click:function(){this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.browser.sampleNameControl.performClickWithState(this.browser,this.showGenotypes),this.browser.sampleInfoControl.performClickWithState(this.browser,this.showGenotypes)}})),e.push({object:Bt('
')});for(let c of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){e.push({object:Bt(Dl({COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"}[c],c===this.displayMode)),click:function(){this.displayMode=c,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add SVs to circular view\",click:function(){for(let e of this.trackView.viewports)this.sendChordsForViewport(e)}})),this.canCovertToPytor()&&(e.push(\"
\"),e.push({label:\"Convert to CNVpytor track\",click:function(){this.convertToPytor()}})),e}contextMenuItemList(e){const t=[];if(this.hasSamples()&&this.showGenotypes){const i=e.viewport.referenceFrame,n=e.genomicLocation,r=i.toBP(2.5),s=this._sortDirections.get(\"genotype\")||1;this._sortDirections.set(\"genotype\",-1*s),t.push({label:\"Sort by genotype\",click:t=>{const i={direction:s,option:\"genotype\",chr:e.viewport.referenceFrame.chr,start:Math.floor(n-r),end:Math.ceil(n+r)},o=e.viewport.cachedFeatures;this.sortSamplesByGenotype(i,o),this.config.sort=i}}),t.push(\"
\")}if(this.browser.circularView){const i=e.viewport;t.push({label:\"Add SVs to Circular View\",click:()=>{this.sendChordsForViewport(i)}}),t.push(\"
\")}return t}async sortSamplesByGenotype({chr:e,position:t,start:i,end:n,direction:r},s){if(void 0===i&&(i=t-1),void 0===n&&(n=t),s||(s=await this.featureSource.getFeatures({chr:e,start:i,end:n})),!s)return;const o=new Map,a=\"ASC\"===r?1:-1;for(let e of s)if(!(e.endn)break;for(let t of e.calls){const e=t.sample,i=t.zygosityScore();o.set(e,o.has(e)?o.get(e)+i:i)}}this.sampleKeys.sort((function(e,t){let i=o.get(e)||0,n=o.get(t)||0;return a*(i-n)})),this.trackView.repaintViews()}sortByAttribute(e,t){this.config.sort={option:\"ATTRIBUTE\",attribute:e,direction:1===t?\"ASC\":\"DESC\"},this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}sendChordsForViewport(e){const t=e.referenceFrame;let i;if(\"all\"===t.chr){const e=this.featureSource.getAllFeatures(),t=Object.keys(e).map((t=>e[t]));i=[].concat(...t)}else i=this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end);Pm(i.filter((e=>{const t=e._f||e;return t.info&&t.info.CHR2&&t.info.END&&(t.info.CHR2!==t.chr||Math.abs(Number.parseInt(t.info.END)-t.pos)>1e6)})).map((e=>{const t=e._f||e,i=Number.parseInt(t.info.END),n=i-100,r=i+100;return{uniqueId:`${t.chr}:${t.start}-${t.end}_${t.info.CHR2}:${t.info.END}`,refName:zm(t.chr),start:t.start,end:t.end,mate:{refName:zm(t.info.CHR2),start:n,end:r}}})),this,t,.5)}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"info\"!==e.key){function n(){const t=\"none\"===e.key?void 0:e.key;this.colorBy=t,this.config.colorBy=t,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){this.browser.inputDialog.present({label:\"Info field\",value:\"\",callback:e=>{e?(this.colorBy=e,this._colorByItems.set(e,e)):this.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}getState(){const e=super.getState();return this.color&&\"function\"!=typeof this.color&&(e.color=this.color),e}getVariantColorTable(e){if(this.colorTables.has(e))return this.colorTables.get(e);if(this.colorTables.has(\"*\"))return this.colorTables.get(\"*\");{let t;if(\"SVTYPE\"===e)t=Xv;else t=new oo(\"Set1\");return this.colorTables.set(e,t),t}}paintAxis(){}canCovertToPytor(){return!this.config.indexURL&&(!!this.header&&(1===Object.keys(this.sampleKeys).length&&this.header.FORMAT&&this.header.FORMAT.AD&&this.header.FORMAT.DP))}async convertToPytor(){this.variantState={...this.config,...this.getState()},this.variantState.trackHeight=this.height,this.trackView.startSpinner(),setTimeout((async()=>{try{const e=Object.assign({},this.config);Object.setPrototypeOf(this,Gv.prototype),this.init(e),await this.postInit(),this.trackView.clearCachedFeatures(),this.trackView.setTrackHeight(this.config.height||Gv.DEFAULT_TRACK_HEIGHT),this.trackView.checkContentHeight(),this.trackView.updateViews()}finally{this.trackView.stopSpinner()}}),100)}}const Xv=new ao({DEL:\"#ff2101\",INS:\"#001888\",DUP:\"#028401\",INV:\"#008688\",CNV:\"#8931ff\",BND:\"#891100\",\"*\":\"#002eff\"}),Zv={timeout:5e3,type:\"plain\",url:\"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$\",coords:0};async function Jv(e,t){const i=e.searchConfig||Zv;let n;t=t.toUpperCase();const r=e.tracks.filter((e=>e.searchable));for(let e of r){const i=await e.search(t);if(i)return i}if(e.config&&!1!==e.config.search)try{return n=await async function(e,t,i){let n=i.url.replace(\"$FEATURE$\",t.toUpperCase());n.indexOf(\"$GENOME$\")>-1&&(n=n.replace(\"$GENOME$\",e.genome.id?e.genome.id:\"hg19\"));const r=i.timeout?{timeout:i.timeout}:void 0,s=await Qs.loadString(n,r);return function(e,t,i){let n;n=\"plain\"===i.type?function(e,t){const i=[],n=Dt(t);for(let t of n){const n=t.split(\"\\t\");if(n.length>=3){const t=n[1].split(\":\"),r=t[1].split(\"-\");i.push({chromosome:e.genome.getChromosomeName(t[0].trim()),start:parseInt(r[0].replace(/,/g,\"\")),end:parseInt(r[1].replace(/,/g,\"\")),name:n[0].toUpperCase()})}}return i}(e,t):JSON.parse(t);i.resultsField&&(n=n[i.resultsField]);if(n&&0!==n.length){const e=i.chromosomeField||\"chromosome\",t=i.startField||\"start\",r=i.endField||\"end\",s=i.coords||1;let o;o=Array.isArray(n)?n[0]:n,o.hasOwnProperty(e)&&o.hasOwnProperty(t)||console.error(\"Search service results must include chromosome and start fields: \"+o);const a=o[e];let c=o[t]-s,l=o[r];void 0===l&&(l=c+1);const h={chr:a,start:c,end:l};if(!o.type||o.type,i.geneField&&i.snpField){const e=o[i.geneField]||o[i.snpField];e&&(h.name=e.toUpperCase())}return h}return}(e,s,i)}(e,t,i),n}catch(e){console.log(\"Search service not available \"+e)}}function ey(e,t=!1){const i=e.split(\"\\t\");if(i.length>2)try{const e=i[0],t=parseInt(i[1].replace(/,/g,\"\"),10)-1,n=parseInt(i[2].replace(/,/g,\"\"),10);if(!isNaN(t)&&!isNaN(n))return{chr:e,start:t,end:n}}catch(e){}const n=e.split(\":\"),r={chr:n[0]};if(n.length>1){let e,i=n[1].split(\"-\");if(i.length>2){if(!n[1].startsWith(\"-\"))return;{const e=n[1].indexOf(\"-\",1);if(e>0){i=[n[1].substring(0,e),n[1].substring(e+1)]}}}if(e=i[0].replace(/,/g,\"\"),isNaN(e))return;if(r.start=parseInt(e,10)-1,r.end=r.start+1,1===i.length&&(r.start-=20,r.end+=20),2===i.length){if(e=i[1].replace(/,/g,\"\"),isNaN(e))return;if(r.end=parseInt(e,10),r.start<0&&!t){const e=-extent.start;r.start+=e,r.end+=e}}}return r}class ty extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"qtl\",this.name=e.name;const t=e.minLogP||e.min,i=e.maxLogP||e.max;this.dataRange={min:void 0!==t?t:3.5,max:i||25},this.autoscale=!i||e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||2,this.height=e.height||100,this.disableButtons=e.disableButtons,this.featureSource=Ad(e,this.browser.genome)}paintAxis(e,t,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*t,a=s-5,c=s,l=i-(o-this.dataRange.min)/n;xo.strokeLine(e,a,l,c,l,r),l>8&&xo.fillText(e,o,a-1,l+2,r)}r.textAlign=\"center\",xo.fillText(e,\"-log10(pvalue)\",t/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(e,t,i){const n=this.visibilityWindow;return await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const{context:t,referenceFrame:i,pixelWidth:n,pixelHeight:r}=e;this.background&&xo.fillRect(t,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(t,0,r-1,n,r-1,{strokeStyle:this.divider}),i.feature&&i.feature.match(/RS[0-9]+/);const s=i=>{const s=i?2*this.dotSize:this.dotSize,o=e.bpStart,a=(this.dataRange.max-this.dataRange.min)/r;for(let d of e.features){const u=(d.start-o+.5)/e.bpPerPixel;if(u<0)continue;if(u>n)break;const f=d.phenotype;let p;if(this.browser.qtlSelections.qtl?(l=this.browser.qtlSelections.qtl,h=d,p=l.chr===h.chr&&l.start===h.start&&l.pValue===h.pValue):p=this.browser.qtlSelections.snps.size>0?this.browser.qtlSelections.hasSnp(d.snp)&&this.browser.qtlSelections.hasPhenotype(f):this.browser.qtlSelections.hasPhenotype(f),!i||p){var c=-Math.log(d.pValue)/Math.LN10;if(c>=this.dataRange.min){let e;c>this.dataRange.max?(c=this.dataRange.max,e=!0):e=!1;const n=Math.max(0+s,r-Math.round((c-this.dataRange.min)/a));let o;d.px=u,d.py=n,d.radius=s,i&&p?(o=this.browser.qtlSelections.colorForGene(f),xo.setProperties(t,{fillStyle:o,strokeStyle:\"black\"})):(o=e?\"rgb(150, 150, 150)\":\"rgb(180, 180, 180)\",xo.setProperties(t,{fillStyle:o,strokeStyle:o})),xo.fillCircle(t,u,n,s),xo.strokeCircle(t,u,n,s)}}}var l,h};s(!1),s(!0)}popupData(e,t){if(void 0===t&&(t=e.viewport.cachedFeatures),!t||0===t.length)return[];const i=this.name,n=[];for(let r of this._clickedFeatures(e,t))n.length>0&&n.push(\"
\"),\"function\"==typeof r.popupData?n.push(...r.popupData(e)):n.push({name:\"snp id\",value:r.snp},{name:\"gene id\",value:r.gencodeId},{name:\"gene name\",value:r.geneSymbol},{name:\"p value\",value:r.pValue},{name:\"tissue\",value:i});return n}_clickedFeatures(e,t){const i=(e,t)=>Math.sqrt((e.px-t.canvasX)*(e.px-t.canvasX)+(e.py-t.canvasY)*(e.py-t.canvasY)),n=t.filter((t=>i(t,e)<6));if(n.length>1){n.sort(((t,n)=>i(t,e)-i(n,e)));const t=i(n[0],e);return n.filter((n=>i(n,e)<=t))}return n}contextMenuItemList(e){const t=[],i=e.viewport.cachedFeatures;if(i){const n=this._clickedFeatures(e,i);n.length>0&&(t.push({label:\"Highlight associated features\",click:async()=>{this.browser.qtlSelections.clear();for(let e of n)this.browser.qtlSelections.qtl=e,this.browser.qtlSelections.addPhenotype(e.phenotype);this.browser.repaintViews()}}),t.push(\"
\"))}return t}menuItemList(){const e=[];return e.push(...this.numericDataMenuItems()),e.push(\"
\"),e.push({label:\"Search for...\",dialog:function(e){this.browser.inputDialog.present({label:\"Search for snp or phenotype\",value:\"\",callback:async e=>{if(e){e=e.trim().toUpperCase();const t=t=>((t.phenotype&&t.phenotype.toUpperCase())===e||t.snp&&t.snp.toUpperCase()===e)&&-Math.log(t.pValue)/Math.LN10>this.dataRange.min;let i,n,r,s=await this.featureSource.findFeatures(t);if(0==s.length){await this.browser.search(e)&&(s=await this.featureSource.findFeatures(t))}if(s.length>0){this.browser.qtlSelections.clear();const t=new Set;i=s[0].chr,n=s[0].start,r=s[0].end;for(let o of s)o.snp&&o.snp.toUpperCase()===e&&this.browser.qtlSelections.addSnp(o.snp),this.browser.qtlSelections.addPhenotype(o.phenotype),t.add(o.phenotype),o.chr===i&&(n=Math.min(n,o.start),r=Math.max(r,o.end));const o=this.browser.genome.getChromosomeName(i);for(let e of t){const t=await Jv(this.browser,e);t&&o===this.browser.genome.getChromosomeName(t.chr)&&(n=Math.min(n,t.start),r=Math.max(r,t.end))}const a=Math.floor(.1*(r-n));n=Math.max(0,n-a),r+=a,await this.browser.search(`${i}:${n}-${r}`)}}}},e)}}),e}doAutoscale(e){let t=this.config.max||25;if(e.length>0){const i=e.map((e=>-Math.log(e.pValue)/Math.LN10));i.sort(((e,t)=>e-t));t=i[Math.floor(i.length*(this.autoscalePercentile/100))]}return this.dataRange.max=Math.max(t,10),this.dataRange}}const iy={X:\"rgb(204, 153, 0)\",Y:\"rgb(153, 204, 0)\",Un:\"darkGray)\",1:\"rgb(80, 80, 255)\",2:\"rgb(206, 61, 50)\",\"2a\":\"rgb(210, 65, 55)\",\"2b\":\"rgb(215, 70, 60)\",3:\"rgb(116, 155, 88)\",4:\"rgb(240, 230, 133)\",5:\"rgb(70, 105, 131)\",6:\"rgb(186, 99, 56)\",7:\"rgb(93, 177, 221)\",8:\"rgb(128, 34, 104)\",9:\"rgb(107, 215, 107)\",10:\"rgb(213, 149, 167)\",11:\"rgb(146, 72, 34)\",12:\"rgb(131, 123, 141)\",13:\"rgb(199, 81, 39)\",14:\"rgb(213, 143, 92)\",15:\"rgb(122, 101, 165)\",16:\"rgb(228, 175, 105)\",17:\"rgb(59, 27, 83)\",18:\"rgb(205, 222, 183)\",19:\"rgb(97, 42, 121)\",20:\"rgb(174, 31, 99)\",21:\"rgb(231, 199, 111)\",22:\"rgb(90, 101, 94)\",23:\"rgb(204, 153, 0)\",24:\"rgb(153, 204, 0)\",25:\"rgb(51, 204, 0)\",26:\"rgb(0, 204, 51)\",27:\"rgb(0, 204, 153)\",28:\"rgb(0, 153, 204)\",29:\"rgb(10, 71, 255)\",30:\"rgb(71, 117, 255)\",31:\"rgb(255, 194, 10)\",32:\"rgb(255, 209, 71)\",33:\"rgb(153, 0, 51)\",34:\"rgb(153, 26, 0)\",35:\"rgb(153, 102, 0)\",36:\"rgb(128, 153, 0)\",37:\"rgb(51, 153, 0)\",38:\"rgb(0, 153, 26)\",39:\"rgb(0, 153, 102)\",40:\"rgb(0, 128, 153)\",41:\"rgb(0, 51, 153)\",42:\"rgb(26, 0, 153)\",43:\"rgb(102, 0, 153)\",44:\"rgb(153, 0, 128)\",45:\"rgb(214, 0, 71)\",46:\"rgb(255, 20, 99)\",47:\"rgb(0, 214, 143)\",48:\"rgb(20, 255, 177)\"};for(let DA of Object.keys(iy)){iy[\"chr\"+DA]=iy[DA]}for(let TA=1;TA<=48;TA++){if(10===TA)continue;const LA=ny(TA);iy[LA]=iy[TA.toString()]}function ny(e){if(!+e)return!1;for(var t=String(+e).split(\"\"),i=[\"\",\"C\",\"CC\",\"CCC\",\"CD\",\"D\",\"DC\",\"DCC\",\"DCCC\",\"CM\",\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\",\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"],n=\"\",r=3;r--;)n=(i[+t.pop()+10*r]||\"\")+n;return Array(+t.join(\"\")+1).join(\"M\")+n}class ry extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.useChrColors=void 0===e.useChrColors||e.useChrColors,this.trait=e.trait,this.posteriorProbability=e.posteriorProbability,this.valueProperty=\"bed\"===e.format?\"score\":\"value\",this.height=e.height||100,this.autoscale=e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||3,this.popoverWindow=void 0===e.popoverWindow?1e8:e.popoverWindow,this.useChrColors?this.colorScale=new ao(e.colorTable||iy):e.color?this.colorScale=new ff(e.color):this.colorScale=new df(e.colorScale||{thresholds:[5e-8,5e-4,.5],colors:[\"rgb(255,50,50)\",\"rgb(251,100,100)\",\"rgb(251,170,170)\",\"rgb(227,238,249)\"]}),this.featureSource=Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.features,i=e.context,n=e.pixelWidth,r=e.pixelHeight;if(this.background&&xo.fillRect(i,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),t){const s=e.bpPerPixel,o=e.bpStart,a=o+n*s+1;for(let e of t){const t=e.start;if(ta)break;let n;if(this.posteriorProbability)n=e[this.valueProperty];else{const t=e[this.valueProperty];if(!t)continue;n=-Math.log10(t)}const c=this.useChrColors?e._f?e._f.chr:e.chr:n,l=this.colorScale.getColor(c),h=(this.dataRange.max-this.dataRange.min)/r,d=Math.round((t-o)/s),u=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/h));l&&xo.setProperties(i,{fillStyle:l,strokeStyle:\"black\"}),xo.fillCircle(i,d,u,this.dotSize),e.px=d,e.py=u}}}paintAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});var n={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const t=.1;for(let s=this.dataRange.min;s0&&i.push(\"
\"),5==r){i.push(\"...\");break}if(s=s._f||s,\"function\"==typeof s.popupData)i=i.concat(s.popupData());else{const e=s[this.valueProperty],t=s.chr,r=Rt(s.start+1);i.push({name:\"chromosome\",value:t}),i.push({name:\"position\",value:r}),i.push({name:\"name\",value:s.name}),n.posteriorProbability?i.push({name:\"posterior probability\",value:e}):i.push({name:\"pValue\",value:e})}r++}}}return i}menuItemList(){return this.numericDataMenuItems()}doAutoscale(e){if(e.length>0){const t=this.valueProperty,i=this.posteriorProbability,n=e.map((function(e){const n=e[t];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=qa(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class sy extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.autoscale=e.autoscale||void 0===e.max,this.dataRange={min:e.min||0,max:e.max},this.windowFunction=e.windowFunction||\"mean\",this.paintAxis=cd,this.graphType=e.graphType||\"bar\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=Ad(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if(\"function\"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleKeys=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty(\"clickToHighlight\")){let e=this.header.clickToHighlight;this.config.clickToHighlight=e,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty(\"highlight\")){this.config.highlightSamples={};let e=this.header.highlight;Array.isArray(e)||(e=[e]);for(let t of e){const e=t.split(\";\");2===e.length&&(this.config.highlightSamples[e[0]]=e[1])}}}}menuItemList(){return this.numericDataMenuItems()}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let e=1;et&&(r=e-1),void 0===s&&n[e].start>i){s=e+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=e,a=e=>(this.dataRange.max-e)/(this.dataRange.max-this.dataRange.min)*o,c=function(e){let t=Math.floor((e-r)/n);return isNaN(t)&&console.warn(\"isNaN(x). feature start \"+Rt(e)+\" bp start \"+Rt(r)),t};if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const e=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},l=[],h=[];this.clickDetectorCache={};for(let d of t){const t=c(d.start),u=c(d.end),f=s>=0?c(s):t;if(!isNaN(t)&&!isNaN(u)){this.clickDetectorCache[t]=[],this.clickDetectorCache[u]=[];for(let s=0;s=1){const s=o[c],h=a(s),d=e&&e[c];d?l.push([f,h,t,g,d]):r&&c in this.config.samplesClickedToHighlight?l.push([f,h,t,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,f,h,t,g,{strokeStyle:\"#D9D9D9\"}),n&&!(c in e)||this.clickDetectorCache[t].push([f,h,t,g,c,d||\"gray\"])}if(u-t>=1){const s=e&&e[c];s?h.push([t,g,u,g,s]):r&&c in this.config.samplesClickedToHighlight?h.push([t,g,u,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,t,g,u,g,{strokeStyle:\"gray\"}),n&&!(c in e)||this.clickDetectorCache[u].push([t,g,u,g,c,s||\"gray\"])}o[c]=p}s=d.end}}for(let e of l)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:1.3});for(let e of h)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:2})}(e=>{if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=a(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):xo.strokeLine(e.context,0,i,e.pixelWidth,i,n)}})(e)}doAutoscale(e){let t,i;return e.length>0?(t=Number.MAX_VALUE,i=-Number.MAX_VALUE,e.forEach((function(e){t=Math.min(t,...e.values),i=Math.max(i,...e.values)})),t-=.01,i+=.01):(t=0,i=100),{min:t,max:i}}clickedFeatures(e){const t=e.canvasX,i=e.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=t)break;if(n){let e=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(ts)return[];const a=n[1],c=n[3];if(iMath.max(a,c)+10)continue;const l=oy(t,i,r,a,s,c);l0?c/l:0}class ay extends Hl{static defaults={height:300,theta:Math.PI/2,arcOrientation:\"UP\"};constructor(e,t){super(e,t),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",\"bp\"===e.format?this.featureSource=new ly(e,t.genome):this.featureSource=new ud(e,t.genome)}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.context,i=Math.PI/2,n=e.pixelWidth,r=e.pixelHeight;e.viewportWidth;const s=e.bpPerPixel,o=e.bpStart,a=s,c=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,n,r,{fillStyle:\"rgb(255, 255, 255)\"});const l=e.features;if(l){cy(l,1);for(let e of l)if(e.startLeft){let n=Math.round((e.startLeft-o)/a),r=Math.round((e.startRight-o)/a),s=Math.round((e.endLeft-o)/a),l=Math.round((e.endRight-o)/a);t.fillStyle=e.color,t.strokeStyle=e.color,t.beginPath();let h=(n+l)/2,d=(l-n)/2,u=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);c?(t.arc(h,u,d,f,p),t.lineTo(s,u)):(u=0,t.arc(h,u,d,p,f),t.lineTo(l,u));const g=(r+s)/2,m=(s-r)/2,w=u;c?(t.arc(g,w,m,p,f,!0),t.lineTo(n,w)):(t.arc(g,w,m,f,p,!0),t.lineTo(s,w)),t.stroke(),t.fill(),e.drawState={x1:h,y1:u,r1:d,x2:g,y2:w,r2:m,sa:f,ea:p}}else{let n=Math.round((e.start-o)/a),r=Math.round((e.end-o)/a);t.strokeStyle=e.color,t.beginPath();let s=(n+r)/2,l=(r-n)/2,h=this.height,d=Math.PI+(Math.PI/2-i),u=2*Math.PI-(Math.PI/2-i);c?t.arc(s,h,l,d,u):(h=0,t.arc(s,h,l,u,d)),t.stroke(),e.drawState={x1:s,y1:h,r1:l,sa:d,ea:u}}}}clickedFeatures(e){const t=super.clickedFeatures(e),i=[];cy(t,-1);for(let n of t){const t=n.drawState,r=e.canvasX-t.x1,s=e.canvasY-t.y1,o=Math.sqrt(r*r+s*s),a=t.r1+3;let c,l;if(void 0===t.x2)c=o,l=t.r1-3;else{const i=e.canvasX-t.x2,n=e.canvasY-t.y2;c=Math.sqrt(i*i+n*n),l=t.r2-3}if(ol){i.push(n);break}}return i}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0)return this.extractPopupData(t[0],this.getGenomeId())}menuItemList(){return[{name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}]}}function cy(e,t){e.sort((function(e,i){const n=void 0===e.score?-Number.MAX_VALUE:e.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===t?1:t)*(n-r)}))}class ly{constructor(e,t){this.config=e,this.genome=t}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,t,i);{const n=Ua(this.config),r=await Qs.loadByteArray(this.config.url,n);return this.featureCache=new Zs(function(e){if(!e)return null;const t=mh(e);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=t.nextLine());){const e=i.split(\"\\t\");if(n&&i.startsWith(\"color:\")){const t=\"rgb(\"+e[1]+\",\"+e[2]+\",\"+e[3]+\")\";r.push(t),e.length>4&&s.push(e[4])}else{n=!1;const t=e[0],i=Number.parseInt(e[1])-1,c=Number.parseInt(e[2])-1,l=Number.parseInt(e[3]),h=Number.parseInt(e[4]);var a=Number.parseInt(e[5]);const d=r[a];let u;u=i<=h?{chr:t,startLeft:Math.min(i,c),startRight:Math.max(i,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:d,score:a}:{chr:t,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(i,c),endRight:Math.max(i,c),color:d,score:a},u.start=u.startLeft,u.end=u.endRight,s.length>a&&(u.description=s[a]),o.push(u)}}return o}(r),s),this.featureCache.queryFeatures(e,t,i)}}}class hy{constructor(e){this.browser=e,this.type=\"ideogram\",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,features:r}){const s=t.chr,o=t.genome.getChromosome(s);if(void 0===o||i<=0||n<=0||\"all\"===s.toLowerCase())return;!function({ctx:e,chr:t,referenceFrame:i,genome:n,width:r,height:s,stainColors:o,features:a}){const c=1,l=.5*c,h=0;if(void 0===n)return;xo.fillRect(e,0,0,r,s,{fillStyle:_s.greyScale(255)});const d=a;if(d){const t=h+s/2,i=[],n=[];if(0===d.length)return;const a=r/d[d.length-1].end;e.beginPath(),xo.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1),e.clip();for(let r=0;r0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),o.bpLength=l),a{uy.getColor(e)}));class fy extends Hl{static defaults={margin:10,colorByNumReadsThreshold:5,height:100};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=e.type||\"junctions\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){return this.height}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.isMergedTrack||xo.fillRect(i,0,e.pixelTop,s,o,{fillStyle:\"rgb(255, 255, 255)\"}),t){const s={};s.referenceFrame=e.viewport.referenceFrame,s.referenceFrameStart=s.referenceFrame.start,s.referenceFrameEnd=s.referenceFrameStart+s.referenceFrame.toBP(e.viewport.getWidth()),s.featureZoomOutTracker={};for(let e of t)if(!(e.enda)break;this.renderJunction(e,r,n,o,i,s)}}else console.log(\"No feature list\")}renderJunction(e,t,i,n,r,s){e.isVisible=!1;const o=Math.round((e.start-t)/i),a=Math.round((e.end-t)/i),c=(o+a)/2;if(a-o<=3){if(c in s.featureZoomOutTracker)return;s.featureZoomOutTracker[c]=!0}if(this.config.hideAnnotatedJunctions&&\"true\"===e.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&\"false\"===e.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(e.attributes.motif))return;if(this.config.hideStrand===e.strand)return;if(this.config.minJunctionEndsVisible){let t=0;if(e.start>=s.referenceFrameStart&&e.start<=s.referenceFrameEnd&&(t+=1),e.end>=s.referenceFrameStart&&e.end<=s.referenceFrameEnd&&(t+=1),t0&&h/d>this.config.maxFractionMultiMappedReads)return;if(e.attributes.maximum_spliced_alignment_overhang&&parseInt(e.attributes.maximum_spliced_alignment_overhang)this.config.maxSamplesWithThisJunction)return;if(e.attributes.num_samples_total&&(e.attributes.percent_samples_with_this_junction=100*u/Number(e.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(e.attributes.percent_samples_with_this_junctionthis.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,p=n,g=f+.5*p;let m=f;const w=f+p-10,b=(o+c)/2,F=(c+a)/2;let v,y,A=1;e.attributes.line_width?A=Number(e.attributes.line_width):(void 0===this.config.thicknessBasedOn||\"numUniqueReads\"===this.config.thicknessBasedOn?A=l:\"numReads\"===this.config.thicknessBasedOn?A=d:\"numSamplesWithThisJunction\"===this.config.thicknessBasedOn&&void 0!==u&&(A=u),A=1+Math.log(A+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||\"random\"===this.config.bounceHeightBasedOn?v=(e.start+e.end)%7:\"distance\"===this.config.bounceHeightBasedOn?v=6*(e.end-e.start)/(s.referenceFrameEnd-s.referenceFrameStart):\"thickness\"===this.config.bounceHeightBasedOn&&(v=2*A),m+=p*Math.max(7-v,0)/10,y=e.attributes.color?e.attributes.color:void 0===this.config.colorBy||\"numUniqueReads\"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"numReads\"===this.config.colorBy?d>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"isAnnotatedJunction\"===this.config.colorBy?\"true\"===e.attributes.annotated_junction?\"#b0b0ec\":\"orange\":\"strand\"===this.config.colorBy?\"+\"===e.strand?\"#b0b0ec\":\"#ecb0b0\":\"motif\"===this.config.colorBy?uy.getColor(e.attributes.motif):\"#AAAAAA\";let C=\"\";e.attributes.label?C=e.attributes.label.replace(/_/g,\" \"):void 0===this.config.labelWith||\"uniqueReadCount\"===this.config.labelWith?C=l:\"totalReadCount\"===this.config.labelWith?C=d:\"numSamplesWithThisJunction\"===this.config.labelWith?void 0!==u&&(C=u):\"percentSamplesWithThisJunction\"===this.config.labelWith?void 0!==e.attributes.percent_samples_with_this_junction&&(C=e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%\"):\"motif\"===this.config.labelWith&&void 0!==e.attributes.motif&&(C+=e.attributes.motif),\"uniqueReadCount\"===this.config.labelWithInParen?C+=\" (\"+l+\")\":\"totalReadCount\"===this.config.labelWithInParen?C+=\" (\"+d+\")\":\"multiMappedReadCount\"===this.config.labelWithInParen?h>0&&(C+=\" (+\"+h+\")\"):\"numSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==u&&(C+=\" (\"+u+\")\"):\"percentSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==e.attributes.percent_samples_with_this_junction&&(C+=\" (\"+e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%)\"):\"motif\"===this.config.labelWithInParen&&void 0!==e.attributes.motif&&(C+=` ${e.attributes.motif}`),e.isVisible=!0,r.beginPath(),r.moveTo(o,w),r.bezierCurveTo(b,m,F,m,a,w),r.lineWidth=A,r.strokeStyle=y,r.stroke();const _=(e,t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-n/2,i-n),e.lineTo(t+n/2,i-n),e.lineTo(t,i),e.closePath(),e.fill()};if(e.attributes.left_shape||e.attributes.right_shape){r.fillStyle=y;const t=r.lineWidth>2?10:7;e.attributes.left_shape&&_(r,o,w,t),e.attributes.right_shape&&_(r,a,w,t)}r.fillText(C,c-r.measureText(C).width/2,(7*m+g)/8)}clickedFeatures(e){return super.clickedFeatures(e).filter((function(e){return e.isVisible&&e.attributes}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=\"function\"==typeof e.popupData?e.popupData(i):this.extractPopupData(e._f||e,this.getGenomeId());t&&(n.length>0&&n.push(\"

\"),Array.prototype.push.apply(n,t))}return n}dispose(){this.trackView=void 0}}const py={min:0,max:3e3,color:\"rgb(0,0,255)\"};class gy{constructor(e){e=e||py,this.max=e.max,this.min=e.min||0,this.cache=[],this.nbins=1e3,this.binsize=(this.max-this.min)/this.nbins,this.updateColor(e.color||\"rgb(0,0,255)\")}updateColor(e){const t=e.substring(4).replace(\")\",\"\").split(\",\");3===t.length&&(this.r=Number.parseInt(t[0].trim()),this.g=Number.parseInt(t[1].trim()),this.b=Number.parseInt(t[2].trim())),this.cache=[]}setMinMax(e,t){this.min=e,this.max=t,this.cache=[],this.binsize=(this.max-this.min)/this.nbins}getColor(e){if(e\");let t=Bt(\"
\");return t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),e}setDataRange({min:e,max:t}){this.dataRange.min=e,this.dataRange.max=t,this.colorScale.min=e,this.colorScale.max=t,this.trackView.repaintViews()}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.rowHeight,yOffset:0}}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){const a=this.rowHeight,c=t+n,l=o+i*s+1,h=a;for(let i of r){if(i.endl)continue;const n=Math.round((i.start-o)/s),r=Math.round((i.end-o)/s),d=Math.max(1,r-n);let u=0;for(let r=i.values.length-1;r>=0;r--){const s=i.values[r],o=u*a;if(o+ac)continue;const l=this.colorScale.getColor(s);e.fillStyle=l,e.fillRect(n,o,d,h),u++}}}}computePixelHeight(e){return e&&0!==e.length?e[0].values.length*this.rowHeight:0}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}get supportsWholeGenome(){return!1}getState(){const e=super.getState();return e.colorScale=this.colorScale.toJson(),e}}const wy=new Map([[\"ideogram\",(e,t)=>new hy(e,t)],[\"sequence\",(e,t)=>new Zd(e,t)],[\"feature\",(e,t)=>new Hd(e,t)],[\"seg\",(e,t)=>new Pf(e,t)],[\"mut\",(e,t)=>new Pf(e,t)],[\"maf\",(e,t)=>new Pf(e,t)],[\"shoebox\",(e,t)=>new my(e,t)],[\"wig\",(e,t)=>new ld(e,t)],[\"merged\",(e,t)=>new tf(e,t)],[\"alignment\",(e,t)=>new tw(e,t)],[\"interaction\",(e,t)=>new iw(e,t)],[\"interact\",(e,t)=>new iw(e,t)],[\"variant\",(e,t)=>new Yv(e,t)],[\"qtl\",(e,t)=>new ty(e,t)],[\"eqtl\",(e,t)=>new ty(e,t)],[\"gwas\",(e,t)=>new ry(e,t)],[\"arc\",(e,t)=>new ay(e,t)],[\"gcnv\",(e,t)=>new sy(e,t)],[\"junction\",(e,t)=>new fy(e,t)],[\"blat\",(e,t)=>new Vd(e,t)],[\"cnvpytor\",(e,t)=>new Gv(e,t)]]);class by{constructor(e,t){const i=(new DOMParser).parseFromString(e,\"text/xml\");this.processRootNode(i,t);const n=i.getElementsByTagName(\"Resource\"),r=i.getElementsByTagName(\"Track\"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(e,t){var i={url:e.getAttribute(\"path\"),indexURL:e.getAttribute(\"index\"),order:t};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(e){const t=e.getElementsByTagName(\"Track\");if(t&&t.length>0){const i={type:\"merged\",tracks:[]};Fy(e,i),o.push(i),Array.from(t).forEach((function(e){e.processed=!0;const t=e.getAttribute(\"id\"),n=a.get(t);n&&(i.tracks.push(n),Fy(e,n),n.autoscale=!1,i.height=n.height)}))}else if(!e.processed){const t=e.getAttribute(\"id\"),i=a.get(t);i&&(o.push(i),Fy(e,i))}}))}processRootNode(e,t){const i=e.getElementsByTagName(\"Session\");!i||i.length;const n=i.item(0),r=n.getAttribute(\"genome\"),s=n.getAttribute(\"locus\"),o=n.getAttribute(\"ucscID\");t&&t.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Fy(e,t){t.name=e.getAttribute(\"name\");const i=e.getAttribute(\"color\");i&&(t.color=\"rgb(\"+i+\")\");const n=e.getAttribute(\"altColor\");i&&(t.altColor=\"rgb(\"+n+\")\");const r=e.getAttribute(\"height\");r&&(t.height=parseInt(r));const s=e.getAttribute(\"autoScale\");s&&(t.autoscale=\"true\"===s);const o=e.getAttribute(\"autoscaleGroup\");o&&(t.autoscaleGroup=o);const a=e.getAttribute(\"windowFunction\");a&&(t.windowFunction=a);const c=e.getAttribute(\"visibilityWindow\")||e.getAttribute(\"featureVisibilityWindow\");c&&(t.visibilityWindow=c);const l=e.getAttribute(\"indexed\");l&&(t.indexed=\"true\"===l);const h=e.getAttribute(\"normalize\");h&&(t.normalize=\"true\"===h);const d=e.getElementsByTagName(\"DataRange\");if(d.length>0){const e=d.item(0);t.min=Number(e.getAttribute(\"minimum\")),t.max=Number(e.getAttribute(\"maximum\")),t.logScale=\"LOG\"===e.getAttribute(\"type\")}}class vy{constructor(e,t,i,n,r){this.genome=e,this.chr=t,this.start=i,this.end=n,this.bpPerPixel=r,this.id=s()}get center(){return(this.start+this.end)/2}get locusSearchString(){return`${this.chr}:${this.start+1}-${this.end}`}extend(e){const t=Math.min(e.start,this.start),i=Math.max(e.end,this.end),n=(i-t)/(this.end-this.start);this.start=t,this.end=i,this.bpPerPixel*=n}calculateEnd(e){return this.start+this.bpPerPixel*e}calculateCenter(e){return this.start+this.bpPerPixel*e/2}calculateBPP(e,t){return(e-this.start)/t}set(e){this.chr=e.chr,this.start=e.start,this.bpPerPixel=e.bpPerPixel}toPixels(e){return e/this.bpPerPixel}toBP(e){return this.bpPerPixel*e}shift(e){this.start+=e,this.end+=e}shiftPixels(e,t,i){const n=this.start,r=e*this.bpPerPixel;return this.start+=r,i&&this.clampStart(t),this.end=this.start+t*this.bpPerPixel,n!==this.start}clampStart(e){const t=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(t,this.start),e){const{bpLength:t}=this.genome.getChromosome(this.chr),i=t-e*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(e,t,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,s=this.start,o=this.bpPerPixel,a=this.getChromosome().bpLength,c=t<1?e.minimumBases()/i:a/i;this.bpPerPixel=t<1?Math.max(this.bpPerPixel*t,c):Math.min(this.bpPerPixel*t,c);const l=this.bpPerPixel*i;this.start=r-.5*l,this.clampStart(i),this.end=this.start+l;(s!==this.start||o!==this.bpPerPixel)&&await e.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(e){const t=\" \",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*e);return`${t}${this.chr}${t}${Wa(n-i)}${t}`}getMultiLocusLabelLocusOnly(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e);return`${t}${i}:${n}-${r}${t}`}getMultiLocusLabel(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e),s=Math.floor(this.start)+1;return`${t}${i}:${n}-${r}${t}${t}(${Wa(Math.round(this.start+this.bpPerPixel*e)-s)})${t}`}getPresentationLocusComponents(e){if(\"all\"===this.chr)return{chr:this.chr};{const t=Rt(Math.floor(this.start)+1),i=Rt(Math.round(this.start+this.bpPerPixel*e));return{chr:this.chr,start:t,end:i}}}getLocusString(){if(\"all\"===this.chr)return\"all\";return`${this.genome.getChromosomeDisplayName(this.chr)}:${Rt(Math.floor(this.start)+1)}-${Rt(Math.round(this.end))}`}description(e){console.log(` ${e||\"\"} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Rt(Math.round(this.start))} end ${Rt(Math.round(this.end))} `)}overlaps(e){return this.chr===e.chr&&this.end>=e.start&&e.end>=this.start}}function yy(){return\"3.0.9\"}const Ay=\"Maximum sequence count exceeded\";class Cy{constructor(t,i){this.container=e({class:\"igv-chromosome-select-widget-container\"}),i.appendChild(this.container),this.select=document.createElement(\"select\"),this.select.setAttribute(\"name\",\"chromosome-select-widget\"),this.container.appendChild(this.select),this.select.addEventListener(\"change\",(()=>{this.select.blur(),\"\"!==this.select.value&&Ay!==this.select.value&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes,this.genome=t.genome}show(){this.container.style.display=\"flex\"}hide(){this.container.style.display=\"none\"}setValue(e){this.select.value=this.genome.getChromosomeDisplayName(e)}update(e){this.genome=e;const t=e.wgChromosomeNames.map((t=>e.getChromosomeDisplayName(t)))||[];if(this.showAllChromosomes&&e.chromosomeNames.length>1){const i=new Set(t);let n=0;for(let r of e.chromosomeNames){if(1e3==++n){t.push(Ay);break}i.has(r)||(r=e.getChromosomeDisplayName(r),t.push(r))}}this.select.innerHTML=\"\",e.showWholeGenomeView()&&t.unshift(\"all\");for(let i of t){const t=document.createElement(\"option\");t.setAttribute(\"value\",i),t.innerText=e.getChromosomeDisplayName(i),this.select.appendChild(t)}}}class _y{constructor(t,i){this.container=e({class:\"igv-windowsize-panel-container\"}),t.appendChild(this.container),i.on(\"locuschange\",(e=>{this.updatePanel(e)})),this.browser=i}show(){this.container.style.display=\"block\"}hide(){this.container.style.display=\"none\"}updatePanel(e){const t=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===e.length?Wa(Math.round(t*e[0].bpPerPixel)):\"\"}}class xy extends Ju{constructor(e,t,i,n){super(e,t,\"Select Tracks\",ef,'\\n multi select\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n multi select hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.navbar=i,this.enableMultiTrackSelection=!1,this.button.addEventListener(\"mouseenter\",(e=>{!1===n&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(e=>{!1===n&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{this.setMultiTrackSelection(!this.enableMultiTrackSelection)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler)}setMultiTrackSelection(e){this.enableMultiTrackSelection=e,this.setState(this.enableMultiTrackSelection),!1===this.enableMultiTrackSelection&&this.navbar.overlayTrackButton.setVisibility(!1);for(const t of this.browser.trackViews)t.enableTrackSelection(e)}}class ky{constructor(t,i){this.browser=i,this.columnContainer=t,this.horizontalGuide=e({class:\"igv-cursor-guide-horizontal\"}),t.appendChild(this.horizontalGuide),this.verticalGuide=e({class:\"igv-cursor-guide-vertical\"}),t.appendChild(this.verticalGuide),this.addMouseHandler(i),this.setVisibility(i.config.showCursorGuide)}addMouseHandler(e){this.boundMouseMoveHandler=function(t){t.target.tagName;const{x:i,y:n}=a(t,this.columnContainer);if(this.horizontalGuide.style.top=`${n}px`,\"CANVAS\"===t.target.tagName){const n=function(e,t){for(;e.parentElement;){if(e.parentElement.classList.contains(t))return e.parentElement;e=e.parentElement}return}(t.target,\"igv-viewport\");if(n&&e.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const r=e.root.querySelectorAll(\".igv-column\");let s;const o=n.parentElement;for(let e=0;e\\n cursor\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n cursor hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.doShowCursorGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCursorGuide&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCursorGuide&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCursorGuide=!t.doShowCursorGuide,t.setCursorGuideVisibility(t.doShowCursorGuide),this.setState(t.doShowCursorGuide)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCursorTrackingGuideButton)}}class Sy extends Ju{constructor(e,t){super(e,t,\"Center Line\",ef,'\\n centerline\\n \\n \\n \\n \\n \\n \\n','\\n centerline hover\\n \\n \\n \\n \\n \\n \\n',t.config.showCenterGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCenterLine&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCenterLine&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCenterLine=!t.doShowCenterLine,t.setCenterLineVisibility(t.doShowCenterLine),this.setState(t.doShowCenterLine)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCenterGuideButton)}}class Ey extends Ju{constructor(e,t){super(e,t,\"Track Labels\",ef,'\\n track labels\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n track labels hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showTrackLabels),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowTrackLabels&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowTrackLabels&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowTrackLabels=!t.doShowTrackLabels,t.setTrackLabelVisibility(t.doShowTrackLabels),this.setState(t.doShowTrackLabels)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showTrackLabelButton)}}class Ny extends Ju{constructor(e,t){super(e,t,[\"ROI\",\"Regions of Interest Table\"],ef,'\\n roi\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n','\\n roi hover\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowROITable&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowROITable&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>this.buttonHandler(!t.doShowROITable))),this.setVisibility(!1)}buttonHandler(e){this.setState(e),this.browser.setROITableVisibility(e)}}class By extends Ju{constructor(e,t){super(e,t,\"Sample Info\",ef,'\\n sample info\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample info hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.showSampleInfo=!1,this.button.addEventListener(\"mouseenter\",(()=>{!1===this.showSampleInfo&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===this.showSampleInfo&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)}))}performClickWithState(e,t){this.showSampleInfo=void 0===t?!this.showSampleInfo:t;e.columnContainer.querySelector(\".igv-sample-info-column\").style.display=!1===this.showSampleInfo?\"none\":\"flex\",this.setState(this.showSampleInfo),e.layoutChange()}setButtonVisibility(e){this.showSampleInfo=e,this.setState(this.showSampleInfo),!0===this.showSampleInfo?this.show():this.hide()}}class My extends Ju{constructor(e,t){super(e,t,\"Sample Names\",'\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names hover\\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showSampleNames),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.showSampleNames&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.showSampleNames&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)})),!0===t.config.showSampleNameButton?this.show():this.hide()}performClickWithState(e,t){e.showSampleNames=void 0===t?!e.showSampleNames:t;e.columnContainer.querySelector(\".igv-sample-name-column\").style.display=!1===e.showSampleNames?\"none\":\"flex\",this.setState(e.showSampleNames),e.layoutChange()}}class Ry{constructor(t,i){this.parent=t,this.popover=e({class:\"igv-ui-dropdown\"}),t.appendChild(this.popover),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\",this.shim=i}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";let{x:t,y:i}=a(e,this.parent);this.popover.style.left=`${t+this.shim.left}px`,this.popover.style.top=`${i+this.shim.top}px`}_present(e){this.popover.style.display=\"block\";let{x:t,y:i,width:n}=a(e,this.parent);t+=this.shim.left,i+=this.shim.top,this.popover.style.top=`${i}px`;const{width:r}=this.popover.getBoundingClientRect(),s=t+r,o=s-n;this.popover.style.left=`${s>n?t-o:t}px`}dismiss(){this.popover.style.display=\"none\"}}class Dy extends Ju{constructor(e,t){super(e,t,\"Save Image\",ef,'\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>{for(const e of this.button.querySelectorAll(\"div\"))if(\"block\"===e.style.display)return;this.setState(!1)})),this.dropdown=new Ry(this.button.parentNode,{top:24,left:-88});const i=[{label:\"Save as SVG\",click:e=>{this.browser.saveSVGtoFile(\"igvjs.svg\"),this.dropdown.dismiss()}},{label:\"Save as PNG\",click:e=>{this.browser.savePNGtoFile(\"igvjs.png\"),this.dropdown.dismiss()}}];this.dropdown.configure(i),this.button.addEventListener(\"click\",(e=>{let t;if(e.target===this.button)t=!0;else if(e.target.closest(\"svg\")){e.target.closest(\"div\")===this.button&&(t=!0)}!0===t&&(\"none\"===this.dropdown.popover.style.display?this.dropdown.present(e):this.dropdown.dismiss())})),this.setVisibility(t.config.showSVGButton)}navbarResizeHandler(e){this.dropdown.dismiss(),super.navbarResizeHandler(e)}}const Ty=function(t,i,n){const r=e({class:\"igv-navbar-button\"});t.append(r),r.textContent=n.label,r.addEventListener(\"click\",(()=>n.callback(i)))};let Ly=23,zy=0;class Hy{constructor(t,i,n){this.browser=i,this.zoomContainer=e({class:\"igv-zoom-widget\"}),n.appendChild(this.zoomContainer),this.zoomOutButton=e(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(l(\"minus-circle\")),this.zoomOutButton.addEventListener(\"click\",(()=>{i.zoomOut()}));const r=e();this.zoomContainer.appendChild(r),this.slider=document.createElement(\"input\"),this.slider.type=\"range\",this.slider.min=\"0\",this.slider.max=`${Ly}`,r.appendChild(this.slider),this.slider.addEventListener(\"change\",(e=>{e.preventDefault(),e.stopPropagation();const t=i.referenceFrameList[0],{bpLength:n}=t.genome.getChromosome(t.chr),{end:r,start:s}=t,o=r-s,a=n/Math.pow(2,e.target.valueAsNumber);i.zoomWithScaleFactor(a/o)})),this.zoomInButton=e(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(l(\"plus-circle\")),this.zoomInButton.addEventListener(\"click\",(()=>{i.zoomIn()})),i.on(\"locuschange\",(e=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(e))}))}update(e){if(this.slider){const t=e[0],{bpLength:i}=t.genome.getChromosome(t.chr),{start:n,end:r}=t;Ly=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${Ly}`;const s=i/(r-n);zy=Math.log2(s),this.slider.value=`${Math.round(zy)}`}}enable(){this.slider&&(this.slider.disabled=!1)}disable(){this.slider&&(this.slider.disabled=!0)}hide(){this.zoomContainer.style.display=\"none\"}show(){this.zoomContainer.style.display=\"block\"}hideSlider(){this.slider&&(this.slider.style.display=\"none\")}showSlider(){this.slider&&(this.slider.style.display=\"block\")}}class Py{constructor(t,i){this.browser=i,this.config=t,this.currentClass=\"igv-navbar-text-button\";const n=Bt(\"
\",{class:\"igv-navbar\"});this.$navigation=n;const r=Bt(\"
\",{class:\"igv-navbar-left-container\"});n.append(r),this.navbarLeftContainer=r.get(0);const s=Bt(\"
\",{class:\"igv-logo\"});r.append(s);const o=Bt('IGV; ');o.css(\"width\",\"34px\"),o.css(\"height\",\"32px\"),s.append(o),this.$current_genome=Bt(\"
\",{class:\"igv-current-genome\"}),r.append(this.$current_genome),this.$current_genome.text(\"\");const a=Bt(\"
\",{class:\"igv-navbar-genomic-location\"});r.append(a),this.chromosomeSelectWidget=new Cy(i,a.get(0)),!1!==t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const c=Bt(\"
\",{class:\"igv-locus-size-group\"});a.append(c);const h=Bt(\"
\",{class:\"igv-search-container\"});c.append(h),this.$searchInput=Bt(\"\",{class:\"igv-search-input\",type:\"text\",placeholder:\"Locus Search\"}),h.append(this.$searchInput),this.$searchInput[0].addEventListener(\"keyup\",(e=>{e.stopImmediatePropagation()})),this.$searchInput.change((()=>i.doSearch(this.$searchInput.val())));const d=e({class:\"igv-search-icon-container\"});h.append(Bt(d)),d.appendChild(l(\"search\")),d.addEventListener(\"click\",(()=>i.doSearch(this.$searchInput.val()))),this.windowSizePanel=new _y(c.get(0),i);const u=Bt(\"
\",{class:\"igv-navbar-right-container\"});n.append(u),this.navbarRightContainer=u.get(0);const f=Bt('
');u.append(f);const p=f.get(0);this.toggle_button_container=p,this.overlayTrackButton=new sf(p,i),this.overlayTrackButton.setVisibility(!1);const g=!1!==t.showMultiSelectButton;if(this.multiTrackSelectButton=new xy(p,i,this,g),this.cursorGuideButton=new Iy(p,i),this.centerLineButton=new Sy(p,i),this.trackLabelControl=new Ey(p,i),this.roiTableControl=new Ny(p,i),this.sampleInfoControl=new By(p,i),this.sampleNameControl=new My(p,i),!0===t.showSVGButton&&(this.saveImageControl=new Dy(p,i)),t.customButtons)for(let e of t.customButtons)new Ty(p,i,e);this.zoomWidget=new Hy(t,i,u.get(0)),!1===t.showNavigation&&this.$navigation.hide()}navbarDidResize(){const e=this.$navigation.width(),t=this.currentNavbarButtonClass();\"igv-navbar-text-button\"===t&&(this.textButtonContainerWidth=this.navbarRightContainer.getBoundingClientRect().width);const i=this.browser,n=i.isMultiLocusWholeGenomeView()||i.referenceFrameList&&mu.isWholeGenomeView(i.referenceFrameList[0].chr);n?this.windowSizePanel.hide():this.windowSizePanel.show();const{x:r,width:s}=this.navbarLeftContainer.getBoundingClientRect(),o=r+s,{x:a}=this.navbarRightContainer.getBoundingClientRect();let c;if(\"igv-navbar-text-button\"===t&&a-o<8)c=\"igv-navbar-icon-button\";else if(this.textButtonContainerWidth&&\"igv-navbar-icon-button\"===t){e-o-this.textButtonContainerWidth>8&&(c=\"igv-navbar-text-button\")}let l;c&&t!==c&&(this.currentClass=c,this.browser.fireEvent(\"navbar-resize\",[c])),l=n?\"igv-zoom-widget-hidden\":e>860?\"igv-zoom-widget\":\"igv-zoom-widget-900\",Bt(this.zoomWidget.zoomContainer).removeClass(),Bt(this.zoomWidget.zoomContainer).addClass(l)}setCenterLineButtonVisibility(e){e?this.centerLineButton.setVisibility(!e):this.centerLineButton.setVisibility(this.config.showCenterGuideButton)}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}updateGenome(e){let t=e.id&&e.id.length<20?e.id:`${e.id.substring(0,8)}...${e.id.substring(e.id.length-8)}`;this.$current_genome.text(t),this.$current_genome.attr(\"title\",e.description);!1!==this.config.showChromosomeWidget&&!1!==e.showChromosomeWidget&&e.chromosomeNames&&e.chromosomeNames.length>1?(this.chromosomeSelectWidget.update(e),this.chromosomeSelectWidget.show()):this.chromosomeSelectWidget.hide()}updateLocus(e,t){this.$searchInput&&this.$searchInput.val(e),this.chromosomeSelectWidget&&(this.chromosomeSelectWidget.select.value=t)}currentNavbarButtonClass(){return this.currentClass}setEnableTrackSelection(e){this.multiTrackSelectButton.setMultiTrackSelection(e)}getEnableTrackSelection(){return this.multiTrackSelectButton.enableMultiTrackSelection}hide(){this.$navigation.hide()}show(){this.$navigation.show()}}const Oy=(e,t)=>{const i=0===e?t.nextElementSibling:t.previousElementSibling;t.remove(),i.remove()},Uy=t=>{const i=e({class:\"igv-column-shim\"});Ya(i,t);const n=e({class:\"igv-column\"});return Ya(n,i),n},qy=(t,i)=>{for(let n=0;n1&&n>0){Ka(e({class:\"igv-column-shim\"}),r)}}};class Qy{constructor(t,i,n){this.browser=t,this.referenceFrame=i,this.column=n,this.container=e({class:\"igv-center-line\"}),n.appendChild(this.container),t.doShowCenterLine?this.show():this.hide()}repaint(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const e=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${e}px`,this.container.classList.remove(\"igv-center-line-thin\"),this.container.classList.add(\"igv-center-line-wide\")}else this.container.style.width=\"1px\",this.container.classList.remove(\"igv-center-line-wide\"),this.container.classList.add(\"igv-center-line-thin\")}}show(){this.isVisible=!0,this.container.style.display=\"block\",this.repaint()}hide(){this.isVisible=!1,this.container.style.display=\"none\"}resize(){this.repaint()}}const Vy=function(t,i){this.button=e({class:\"igv-navbar-button\"}),t.appendChild(this.button),this.button.textContent=\"circular view\",this.button.addEventListener(\"click\",(()=>{i.circularViewVisible=!i.circularViewVisible})),this.browser=i,this.setVisibility(i.config.showCircularViewButton),this.setState(i.circularViewVisible)};Vy.prototype.setVisibility=function(e){!0===e?this.show():this.hide()},Vy.prototype.setState=function(e){!0===e?this.button.classList.add(\"igv-navbar-button-clicked\"):this.button.classList.remove(\"igv-navbar-button-clicked\")},Vy.prototype.show=function(){this.button.style.display=\"block\",this.setState(this.browser.circularViewVisible)},Vy.prototype.hide=function(){this.button.style.display=\"none\"};class jy{constructor(t,i){this.browser=t,this.container=e({class:\"igv-roi-menu\"}),i.appendChild(this.container);const n=e();this.container.appendChild(n),u(n,(()=>this.container.style.display=\"none\")),this.body=e(),this.container.appendChild(this.body),this.container.style.display=\"none\"}async present(e,t,i,n,r,s){const o=this.menuItems(e,t,i,n,r,s);this.browser.menuPopup.presentTrackContextMenu(i,o)}menuItems(e,t,i,n,r,s){const o=e.name?[`${e.name}
`]:[];return\"name\"in t&&o.push(`ROI Set: ${t.name}`),o.length>0&&o.push(\"
\"),t.isUserDefined&&o.push({label:\"Set description ...\",click:()=>{const t={label:\"Description\",value:e.name||\"\",callback:()=>{const t=this.browser.inputDialog.value||\"\";e.name=t.trim(),this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(t,i)}}),Xa()&&e.end-e.start<1e6&&o.push({label:\"Copy reference sequence\",click:async()=>{this.container.style.display=\"none\";let t=await this.browser.genome.getSequence(e.chr,e.start,e.end);t||(t=\"Unknown sequence\");try{await navigator.clipboard.writeText(t)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.end-e.start<=25e3&&o.push({label:\"BLAT reference sequence\",click:async()=>{this.container.style.display=\"none\";const{chr:t,start:i,end:n}=e;let r=await this.browser.genome.getSequence(t,i,n);if(r){const e=`blat: ${t}:${i+1}-${n}`,s=`blat: ${t}:${i+1}-${n}`;jd({sequence:r,browser:this.browser,name:e,title:s})}}}),t.isUserDefined&&o.push(\"
\",{label:\"Delete\",click:async()=>{t.removeFeature(e);const i=await t.getAllFeatures();0===Object.keys(i).length&&n.deleteUserDefinedROISet(),n.deleteRegionWithKey(s.dataset.region,r),n.repaintTable()}}),o}dispose(){this.container.innerHTML=\"\"}}class Wy extends Pd{constructor(e){const t={browser:e,parent:e.columnContainer,headerTitle:\"Regions of Interest\",dismissHandler:()=>e.roiTableControl.buttonHandler(!1),gotoButtonHandler:Wy.gotoButtonHandler};t.columnFormat=Wy.getColumnFormatConfiguration(!0),super(Object.assign({width:\"640px\"},t))}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),{setName:n,feature:r}=t;i.dataset.region=Xy(r.chr,r.start,r.end);let s=[r.chr,Rt(r.start),Rt(r.end),r.name||\"\",n];4===this.columnFormat.length&&(s=s.slice(0,4));for(let t=0;te.remove())),e.length>0){const t=e.sort(((e,t)=>e.feature.chr.localeCompare(t.feature.chr)||e.feature.start-t.feature.start||e.feature.end-t.feature.end));for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}}set footerDOM(t){super.footerDOM=t,this.gotoButton.textContent=\"Go to selected region(s)\";const i=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(i),i.id=\"igv-roi-hide-show-button\",i.textContent=\"Copy Sequence\",i.title=\"One region only of max size 1 mb\",this.copySequenceButton=i,Gy(this.copySequenceButton,!1),this.boundCopySequenceButtonHandler=async function(e){e.preventDefault(),e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\");if(t.length>0){const e=[];for(let i of t){const{locus:t}=Jy(i.dataset.region);e.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");if(this.setTableRowSelectionState(!1),e.length>0){const{chr:t,start:i,end:n}=ey(e[0],this.browser.isSoftclipped()),r=await this.browser.genome.getSequence(t,i,n);await navigator.clipboard.writeText(r)}}}.bind(this),this.copySequenceButton.addEventListener(\"click\",this.boundCopySequenceButtonHandler);const n=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(n),n.id=\"igv-roi-hide-show-button\",n.textContent=\"Hide all ROIs\",this.toggleROIButton=n,this.boundToggleDisplayButtonHandler=function(e){e.preventDefault(),e.stopPropagation(),this.browser.roiManager.toggleROIs()}.bind(this),this.toggleROIButton.addEventListener(\"click\",this.boundToggleDisplayButtonHandler)}setROIVisibility(e){const t=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let i=0;i0&&t.length<2){const{locus:e}=Jy(t[0].dataset.region),{chr:i,start:n,end:r}=ey(e,this.browser.isSoftclipped());Gy(this.copySequenceButton,r-n<1e6)}else Gy(this.copySequenceButton,!1)}dispose(){document.removeEventListener(\"click\",this.boundGotoButtonHandler),document.removeEventListener(\"click\",this.boundCopySequenceButtonHandler),document.removeEventListener(\"click\",this.boundToggleDisplayButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(e){return!0===e?[{label:\"Chr\",width:\"20%\"},{label:\"Start\",width:\"15%\"},{label:\"End\",width:\"15%\"},{label:\"Description\",width:\"30%\"},{label:\"ROI Set\",width:\"20%\"}]:[{label:\"Chr\",width:\"25%\"},{label:\"Start\",width:\"20%\"},{label:\"End\",width:\"20%\"},{label:\"Description\",width:\"35%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(let e of t){const{locus:t}=Jy(e.dataset.region);i.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(\" \"))}}function Gy(e,t){e.style.pointerEvents=t?\"auto\":\"none\",e.style.color=ro(t?\"licorice\":\"silver\"),e.style.borderColor=ro(t?\"licorice\":\"silver\")}function $y(e,t){const i=window.getComputedStyle(e).backgroundColor.match(/[\\d.]+/g);3===i.length&&i.push(1),i[3]=t,e.style.backgroundColor=`rgba(${i.join(\", \")})`}class Ky{constructor(e){this.browser=e,this.roiMenu=new jy(e,e.columnContainer),this.roiTable=new Wy(e,e.columnContainer),this.top=0,this.roiSets=[],this.boundLocusChangeHandler=Yy.bind(this),e.on(\"locuschange\",this.boundLocusChangeHandler);this.observer=new MutationObserver((()=>{const t=e.findTracks((e=>new Set([\"ideogram\",\"ruler\"]).has(e.type))),[i,n]=t.map((e=>e.trackView.viewports[0].$viewport.get(0))).map((e=>function(e){const t=window.getComputedStyle(e),i=parseInt(t.marginTop),n=parseInt(t.marginBottom),{top:r,bottom:s,height:o}=e.getBoundingClientRect();return{top:Math.floor(r)-i,bottom:Math.floor(s)+n,height:Math.floor(o)+i+n}}(e))),r=i?i.height:0,s=n?n.height:0,o=e.columnContainer.querySelectorAll(\".igv-roi-region\");if(o)for(const e of o)e.style.marginTop=`${r+s+-.5}px`})),this.observer.observe(e.columnContainer,{attributes:!0,childList:!0,subtree:!0})}async reset(){this.roiSets.length>0&&this.browser.roiTableControl.setVisibility(!0);const e=this.roiSets.map((e=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})));e.length>0&&await Promise.all(e);const t=await this.getTableRecords();if(this.roiTable.renderTable(t),this.roiSets.length>0){const e=this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e)}}async loadROI(e,t){const i=Array.isArray(e)?e:[e];for(let e of i)!e.name&&e.url&&(e.name=await ja(e.url)),e.url&&!e.format&&(e.format=await am(e)),this.roiSets.push(new ku(e,t));await this.reset()}clearROIs(){this.roiTable.clearTable();const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();for(let e of this.roiSets)e.dispose();this.roiSets=[]}async getTableRecords(){const e=[];for(let t of this.roiSets){const i=t.name||\"\",n=await t.getAllFeatures();for(let t of Object.keys(n))for(let r of n[t])e.push({setName:i,feature:r})}return e}presentTable(){this.roiTable.present()}async repaintTable(){const e=await this.getTableRecords();this.roiTable.renderTable(e)}dismissTable(){this.roiTable.dismiss()}roiTableIsVisible(){return this.roiTable.isVisible()}async updateUserDefinedROISet(e){let t=await this.getUserDefinedROISet();void 0===t&&(t=this.initializeUserDefinedROISet()),t.addFeature(e),this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(e){this.browser.roiTableControl.setVisibility(e)}toggleROIs(){const e=!this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e);for(const t of this.roiSets)t.isVisible=e}async renderAllROISets(){for(let e of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})}async renderROISet({browser:e,pixelTop:t,roiSet:i}){const n=e.columnContainer.querySelectorAll(\".igv-column\");for(let r=0;ra)&&e.remove()}const h=await i.getFeatures(s,o,a);if(h)for(let l of h){const h=Xy(s,l.start,l.end),{x:d,width:u}=Iu(Math.max(o,l.start),Math.min(a,l.end),o,c),f=n[r].querySelector(Zy(h));if(f)f.style.left=`${d}px`,f.style.width=`${u}px`;else{const s=this.createRegionElement(e.columnContainer,t,d,u,i,h,l);n[r].appendChild(s)}}}}createRegionElement(t,i,n,r,s,o,c){const l=e({class:\"igv-roi-region\"});l.style.top=`${i}px`,l.style.left=`${n}px`,l.style.width=`${r}px`,l.style.backgroundColor=s.color,l.dataset.color=s.color,l.dataset.region=o;const h=e();return l.appendChild(h),h.style.backgroundColor=s.headerColor,h.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation(),a(e,t),this.roiMenu.present(c,s,e,this,t,l)})),l}renderSVGContext(e,t,{deltaX:i,deltaY:n}){for(const r of e.querySelectorAll(\".igv-roi-region\")){const{x:e,y:s,width:o,height:a}=r.getBoundingClientRect();t.fillStyle=r.style.backgroundColor,t.fillRect(e-i,s+n,o,a);const c=r.querySelector(\"div\"),{x:l,y:h,width:d,height:u}=c.getBoundingClientRect();t.fillStyle=c.style.backgroundColor,t.fillRect(l-i,h+n,d,u)}}getUserDefinedROISet(){return this.roiSets.find((e=>!0===e.isUserDefined))}deleteUserDefinedROISet(){this.roiSets=this.roiSets.filter((e=>!0!==e.isUserDefined))}initializeUserDefinedROISet(){const e=new ku({name:\"user defined\",isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(e),e}async deleteRegionWithKey(e,t){t.querySelectorAll(Zy(e)).forEach((e=>e.remove()));0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}toJSON(){return this.roiSets.map((e=>e.toJSON()))}dispose(){this.browser.off(\"locuschange\",this.boundLocusChangeHandler);const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let e of this.roiSets)e.dispose();for(let e of Object.keys(this))this[e]=void 0}}function Yy(){this.renderAllROISets()}function Xy(e,t,i){return`${e}-${t}-${i}`}function Zy(e){return`[data-region=\"${e}\"]`}function Jy(e){let t=e.split(\"-\"),i=parseInt(t.pop()),n=parseInt(t.pop()),r=t.join(\"-\");return{chr:r,start:n,end:i,locus:`${r}:${n}-${i}`,bedRecord:`${r}\\t${n}\\t${i}`}}class eA{constructor(e,t){this.name=e.name,this.featureSource=e.featureSource||Ad(e,t),this.color=e.color||_u}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}draw(e){const{context:t,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=e;if(!a)return;const c=n+o*i+1;for(let{start:e,end:o}of a){if(oc)break;const{x:a,width:l}=Iu(e,o,n,i);xo.fillRect(t,a,r,l,s,{fillStyle:this.color})}}}class tA{aliasRecordCache=new Map;constructor(e,t,i){(t=t||{}).url=e,this.reader=new Zh(t,i)}async preload(e){await this.reader.preload();for(let t of e)await this.search(t)}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async search(e){if(!this.aliasRecordCache.has(e)){const t=await this.reader.search(e);if(t)for(let e of Object.keys(t))\"start\"!==e&&\"end\"!==e&&this.aliasRecordCache.set(t[e],t)}return this.aliasRecordCache.get(e)}async getChromosomeNames(){return await this.reader.loadHeader(),Array.from(this.reader.chrNames)}}class iA{aliasRecordCache=new Map;constructor(e,t,i){this.aliasURL=e,this.config=t,this.genome=i}async preload(){return this.loadAliases()}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async loadAliases(){const e=await Qs.loadString(this.aliasURL,Ua(this.config)),t=Dt(e),i=t[0];i.startsWith(\"#\")&&(this.headings=i.substring(1).split(\"\\t\").map((e=>e.trim())),this.altNameSets=this.headings.slice(1));const n=this.genome.chromosomeNames?new Set(this.genome.chromosomeNames):new Set;for(let e of t)if(!e.startsWith(\"#\")&&e.length>0){const t=e.split(\"\\t\");let i=t.find((e=>n.has(e)));i||(i=t[0]);const r={chr:i};for(let e=0;enew nA(e.start,e.end,e.name,e.gieStain)))}}class sA{cytobands=new Map;constructor(e,t){this.url=e,this.config=t}async getCytobands(e){return 0===this.cytobands.size&&await this.#I(),this.cytobands.get(e)}async#I(){let e,t;if(Ga(this.url)){const t=vs(this.url);e=\"\";const i=t.length;for(let n=0;n0){const e=e.substring(0,t);r[\"ncbi-gi\"]=e}}else{if(e.startsWith(\"hg\")||e.startsWith(\"GRCh\")||\"1kg_ref\"===e||\"b37\"===e)switch(n){case\"23\":r.ucsc=\"chrX\",t=!0;break;case\"24\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"23\",t=!0;break;case\"chrY\":r.ncbi=\"24\",t=!0}else if(e.startsWith(\"mm\")||e.startsWith(\"GRCm\")||e.startsWith(\"rheMac\"))switch(n){case\"21\":r.ucsc=\"chrX\",t=!0;break;case\"22\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"21\",t=!0;break;case\"chrY\":r.ncbi=\"22\",t=!0}if(t)continue;\"chrM\"===n?r.ncbi=\"MT\":\"MT\"===n?r.ucsc=\"chrM\":n.toLowerCase().startsWith(\"chr\")?r.ncbi=n.substring(3):Number.isInteger(Number(n))&&(r.ucsc=\"chr\"+n)}}for(let e of i){for(let t of Object.values(e))this.aliasRecordCache.set(t,e);this.aliasRecordCache.set(e.chr.toLowerCase(),e),this.aliasRecordCache.set(e.chr.toUpperCase(),e)}}}search(e){return this.aliasRecordCache.get(e)}static getNCBIName(e){const t=e.split(\"\\\\|\");return t[t.length-1]}}class aA{#S;static async createGenome(e,t){const i=new aA(e,t);return await i.init(),i}constructor(e,t){this.config=e,this.browser=t,this.id=e.id||function(e){return void 0!==e.id?e.id:e.fastaURL&&Mt(e.fastaURL)&&!e.fastaURL.startsWith(\"data:\")?e.fastaURL:e.fastaURL&&e.fastaURL.name?e.fastaURL.name:\"\"}(e),this.name=e.name,this.nameSet=e.nameSet}async init(){const e=this.config;if(this.sequence=await Nc(e,this.browser),e.chromSizesURL?this.chromosomes=await async function(e){const t=new Map;let i;if(Ga(e)){let t=vs(e);i=\"\";for(let e of t)i+=String.fromCharCode(e)}else i=await Qs.load(e,{});const n=Fc(i);let r=0;for(let e of n){const i=e.split(\"\\t\");if(i.length>1){const e=Number.parseInt(i[1]);t.set(i[0],new lc(i[0],r++,e))}}return t}(e.chromSizesURL):this.chromosomes=this.sequence.chromosomes||new Map,this.chromosomes.size>0&&(this.chromosomeNames=Array.from(this.chromosomes.keys())),e.chromAliasBbURL?(this.chromAlias=new tA(e.chromAliasBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.chromAlias.getChromosomeNames())):e.aliasURL?this.chromAlias=new iA(e.aliasURL,Object.assign({},e),this):this.chromosomeNames&&(this.chromAlias=new oA(this.id,this.chromosomeNames)),e.cytobandBbURL)this.cytobandSource=new rA(e.cytobandBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames());else if(e.cytobandURL&&(this.cytobandSource=new sA(e.cytobandURL,Object.assign({},e)),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames()),0===this.chromosomes.size)){const e=await this.cytobandSource.getChromosomes();for(let t of e)this.chromosomes.set(e.name,e)}if(!1!==e.wholeGenomeView&&this.chromosomes.size>0&&(e.chromosomeOrder?Array.isArray(e.chromosomeOrder)?this.#S=e.chromosomeOrder:this.#S=e.chromosomeOrder.split(\",\").map((e=>e.trim())):this.#S=function(e){const t=[];let i,n=1;for(let r of e.values()){if(i){if(r.bpLength1,this.wholeGenomeView){const e=this.#S.reduce(((e,t)=>e+this.chromosomes.get(t).bpLength),0);this.chromosomes.set(\"all\",new lc(\"all\",0,e))}}get description(){return this.config.description||`${this.id}\\n${this.name}`}get infoURL(){return this.config.infoURL}showWholeGenomeView(){return this.wholeGenomeView}toJSON(){return Object.assign({},this.config,{tracks:void 0})}get initialLocus(){return this.config.locus?this.config.locus:this.getHomeChromosomeName()}getHomeChromosomeName(){return this.showWholeGenomeView()&&this.chromosomes.has(\"all\")?\"all\":this.chromosomeNames[0]}getChromosomeName(e){return this.chromAlias?this.chromAlias.getChromosomeName(e,this.chromosomes.keys()):e}getChromosomeDisplayName(e){return this.nameSet&&this.chromAlias&&this.chromAlias.getChromosomeAlias(e,this.nameSet)||e}getChromosome(e){return this.chromAlias&&(e=this.chromAlias.getChromosomeName(e)),this.chromosomes.get(e)}async loadChromosome(e){if(this.chromAlias){const t=await this.chromAlias.search(e);t&&(e=t.chr)}if(!this.chromosomes.has(e)){let t;const i=await this.sequence.getSequenceRecord(e);i&&(t=new lc(e,0,i.bpLength)),this.chromosomes.set(e,t)}return this.chromosomes.get(e)}async getAliasRecord(e){if(this.chromAlias)return this.chromAlias.search(e)}async getCytobands(e){if(this.cytobandSource){const t=this.getChromosomeName(e);return await this.cytobandSource.getCytobands(t)}}getChromosomes(){return this.chromosomes}get wgChromosomeNames(){return this.#S?this.#S.slice():void 0}get showChromosomeWidget(){return this.config.showChromosomeWidget}getGenomeCoordinate(e,t){var i=this.getCumulativeOffset(e);if(void 0!==i)return i+t}getChromosomeCoordinate(e){let t;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.#S){const r=this.cumulativeOffsets[n];if(r>e){return{chr:t,position:e-i}}t=n,i=r}return{chr:this.#S[this.#S.length-1],position:0}}getCumulativeOffset(e){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let e={},t=0;for(let i of this.#S){e[i]=Math.floor(t);t+=this.getChromosome(i).bpLength}return e}.call(this));const t=this.getChromosomeName(e);return this.cumulativeOffsets[t]}getGenomeLength(){if(!this.bpLength){let e=0;for(let t of this.#S){e+=this.chromosomes.get(t).bpLength}this.bpLength=e}return this.bpLength}async getSequence(e,t,i){return e=this.getChromosomeName(e),this.sequence.getSequence(e,t,i)}getSequenceInterval(e,t,i){return\"function\"==typeof this.sequence.getSequenceInterval?this.sequence.getSequenceInterval(e,t,i):void 0}}class cA{constructor(){this.clear()}clear(){this.phenotypeColors=new Map,this.snps=new Set,this.qtl=null}isEmpty(){return 0===this.phenotypeColors.size&&0===this.snps.size&&null===this.qtl}addSnp(e){e=e.toUpperCase(),this.snps.add(e)}addPhenotype(e){e=e.toUpperCase();const t=this.phenotypeColors.size;if(!this.phenotypeColors.has(e.toUpperCase())){const i=t0&&(e.phenotypes=Array.from(this.phenotypeColors.keys())),this.snps.size>0&&(e.snps=Array.from(this.snps)),this.qtl&&(e.qtl=this.qtl),e}static fromJSON(e){const t=new cA;if(e.phenotypes)for(let i of e.phenotypes)t.addPhenotype(i);if(e.snps)for(let i of e.snps)t.addSnp(i);return e.qtl&&(t.qtl=e.qtl),t}}const lA=[];lA.push(\"rgb(228,26,28)\"),lA.push(\"rgb(55,126,184)\"),lA.push(\"rgb(77,175,74)\"),lA.push(\"rgb(166,86,40)\"),lA.push(\"rgb(152,78,163)\"),lA.push(\"rgb(255,127,0)\"),lA.push(\"rgb(247,129,191)\"),lA.push(\"rgb(255,255,51)\"),lA.push(\"rgb(102,194,165)\"),lA.push(\"rgb(252,141,98)\"),lA.push(\"rgb(141, 160, 203)\"),lA.push(\"rgb(231, 138, 195)\"),lA.push(\"rgb(166, 216, 84)\"),lA.push(\"rgb(255, 217, 47)\"),lA.push(\"rgb(229, 196, 148)\"),lA.push(\"rgb( 141, 211, 199)\"),lA.push(\"rgb(255, 255, 179)\"),lA.push(\"rgb(190, 186, 218)\"),lA.push(\"rgb(251, 128, 114)\"),lA.push(\"rgb(128, 177, 211)\"),lA.push(\"rgb(253, 180, 98)\"),lA.push(\"rgb(179, 222, 105)\"),lA.push(\"rgb(252, 205, 229)\"),lA.push(\"rgb(188, 128, 189)\"),lA.push(\"rgb(204, 235, 197)\"),lA.push(\"rgb(255, 237, 111)\");class hA{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container);let r='';this._input=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._input),r='',this._output=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._output);const s=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(s),this.ok=e(),s.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),s.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"input\",(()=>{const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this._output.value=`${e.toFixed(2)}`}),!1),this.ok.addEventListener(\"click\",(()=>{if(\"function\"==typeof this.callback){const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this.callback=void 0}this._input.value=void 0,i(this.container)}));const o=()=>{this._input.value=void 0,i(this.container)};this.cancel.addEventListener(\"click\",o),u(n,o),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._scaleFactor=e.scaleFactor;const[i,r,s]=[e.min,e.max,e.value].map((e=>Math.floor(this._scaleFactor*e).toString()));this._input.min=i,this._input.max=r,this._input.value=s;const o=parseFloat(s)/this._scaleFactor;this._output.value=`${o.toFixed(2)}`,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}class dA{qtlSelections=new cA;constructor(t,i){this.config=t,this.guid=s(),this.namespace=\".browser_\"+this.guid,this.parent=i;let n=i.shadowRoot;if(!n){n=i.attachShadow({mode:\"open\"});const e=new CSSStyleSheet;e.replaceSync('.igv-ui-dropdown {\\n cursor: default;\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div {\\n overflow-y: auto;\\n overflow-x: hidden;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div {\\n padding: 4px;\\n width: 100%;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: 1px;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div:last-child {\\n border-bottom-color: transparent;\\n border-bottom-width: 0;\\n}\\n.igv-ui-dropdown > div > div:hover {\\n cursor: pointer;\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n\\n.igv-ui-popover {\\n cursor: default;\\n position: absolute;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n background-color: white;\\n}\\n.igv-ui-popover > div:first-child {\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-width: 0;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-popover > div:first-child > div:first-child {\\n margin-left: 4px;\\n}\\n.igv-ui-popover > div:first-child > div:last-child {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-popover > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-popover > div:last-child {\\n user-select: text;\\n overflow-y: auto;\\n overflow-x: hidden;\\n max-height: 400px;\\n max-width: 800px;\\n background-color: white;\\n border-bottom-width: 0;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-ui-popover > div:last-child > div {\\n margin-left: 4px;\\n margin-right: 4px;\\n min-width: 220px;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n.igv-ui-popover > div:last-child > div > span {\\n font-weight: bolder;\\n}\\n.igv-ui-popover > div:last-child hr {\\n width: 100%;\\n}\\n\\n.igv-ui-alert-dialog-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n top: 50%;\\n left: 50%;\\n width: 400px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n outline: none;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 15px;\\n font-weight: 400;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:first-child {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\\n padding-left: 8px;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\\n -webkit-user-select: text;\\n -moz-user-select: text;\\n -ms-user-select: text;\\n user-select: text;\\n color: #373737;\\n width: 100%;\\n height: calc(100% - 24px - 64px);\\n overflow-y: scroll;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\\n margin: 16px;\\n width: auto;\\n height: auto;\\n overflow-wrap: break-word;\\n word-break: break-word;\\n background-color: white;\\n border: unset;\\n}\\n.igv-ui-alert-dialog-container > div:last-child {\\n width: 100%;\\n margin-bottom: 10px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div {\\n margin: unset;\\n width: 40px;\\n height: 30px;\\n line-height: 30px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n border-color: #2B81AF;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div:hover {\\n cursor: pointer;\\n border-color: #25597f;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-color-swatch {\\n position: relative;\\n box-sizing: content-box;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: wrap;\\n justify-content: center;\\n align-items: center;\\n width: 32px;\\n height: 32px;\\n border-style: solid;\\n border-width: 2px;\\n border-color: white;\\n border-radius: 4px;\\n}\\n\\n.igv-ui-color-swatch:hover {\\n border-color: dimgray;\\n}\\n\\n.igv-ui-colorpicker-menu-close-button {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 32px;\\n margin-top: 4px;\\n margin-bottom: 4px;\\n padding-right: 8px;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa {\\n display: block;\\n margin-left: 4px;\\n margin-right: 4px;\\n color: #5f5f5f;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\\n.igv-ui-colorpicker-menu-close-button i.fa:active {\\n cursor: pointer;\\n color: #0f0f0f;\\n}\\n\\n.igv-ui-generic-dialog-container {\\n box-sizing: content-box;\\n position: fixed;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: fit-content;\\n padding-bottom: 16px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input > div {\\n width: fit-content;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input[type=range] {\\n width: 70%;\\n -webkit-appearance: none;\\n background: linear-gradient(90deg, white, black);\\n outline: none;\\n margin: 0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input output {\\n display: block;\\n height: 100%;\\n width: 20%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n padding-top: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div {\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n\\n.igv-ui-generic-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-container > div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-ui-generic-container > div:first-child > div {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-ui-dialog {\\n z-index: 2048;\\n position: fixed;\\n width: fit-content;\\n height: fit-content;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n background-color: white;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-dialog .igv-ui-dialog-one-liner {\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n font-weight: bold;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\\n width: 100%;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\\n margin: 16px;\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\\n background-color: #5ea4e0;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\\n background-color: #c4c4c4;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\\n z-index: 2048;\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-panel-column {\\n display: flex;\\n flex-direction: column;\\n}\\n\\n.igv-ui-panel-row {\\n display: flex;\\n flex-direction: row;\\n}\\n\\n.igv-ui-textbox {\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-table {\\n background-color: white;\\n}\\n\\n.igv-ui-table thead {\\n position: sticky;\\n top: 0;\\n}\\n\\n.igv-ui-table th {\\n text-align: left;\\n}\\n\\n.igv-ui-table td {\\n padding-right: 20px;\\n}\\n\\n.igv-ui-table tr:hover {\\n background-color: lightblue;\\n}\\n\\n.igv-ui-center-fixed {\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.igv-navbar {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n box-sizing: border-box;\\n width: 100%;\\n color: #444;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n line-height: 32px;\\n padding-left: 8px;\\n padding-right: 8px;\\n margin-top: 2px;\\n margin-bottom: 6px;\\n height: 32px;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: #f3f3f3;\\n}\\n.igv-navbar .igv-navbar-left-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 32px;\\n line-height: 32px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-logo {\\n width: 34px;\\n height: 32px;\\n margin-right: 8px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\\n height: 32px;\\n margin-left: 4px;\\n margin-right: 4px;\\n user-select: none;\\n line-height: 32px;\\n vertical-align: middle;\\n text-align: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n height: 100%;\\n width: 125px;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\\n display: block;\\n cursor: pointer;\\n width: 100px;\\n height: 75%;\\n outline: none;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n margin-left: 8px;\\n height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 240px;\\n height: 22px;\\n line-height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\\n cursor: text;\\n width: 85%;\\n height: 22px;\\n line-height: 22px;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n text-align: left;\\n padding-left: 8px;\\n margin-right: 8px;\\n outline: none;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: white;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\\n cursor: pointer;\\n height: 16px;\\n width: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\\n margin-left: 4px;\\n user-select: none;\\n}\\n.igv-navbar .igv-navbar-right-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\\n position: relative;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-hidden {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\\n color: #737373;\\n font-size: 18px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\\n display: block;\\n height: fit-content;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\\n display: block;\\n width: 125px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\\n color: #737373;\\n font-size: 18px;\\n height: 32px;\\n line-height: 32px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\\n display: none;\\n}\\n\\n.igv-navbar-button {\\n display: block;\\n box-sizing: unset;\\n padding-left: 6px;\\n padding-right: 6px;\\n height: 18px;\\n text-transform: capitalize;\\n user-select: none;\\n line-height: 18px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 11px;\\n font-weight: 200;\\n color: #737373;\\n background-color: #f3f3f3;\\n border-color: #737373;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 6px;\\n}\\n\\n.igv-navbar-button:hover {\\n cursor: pointer;\\n}\\n\\n.igv-navbar-button-clicked {\\n color: white;\\n background-color: #737373;\\n}\\n\\n.igv-navbar-icon-button {\\n cursor: pointer;\\n position: relative;\\n width: 24px;\\n height: 24px;\\n margin-left: 4px;\\n margin-right: 4px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:first-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: -18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:last-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n.igv-navbar-text-button {\\n cursor: pointer;\\n position: relative;\\n margin-left: 2px;\\n margin-right: 2px;\\n border: none;\\n display: flex;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar-text-button > div:nth-child(2) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 0;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-text-button > div:nth-child(3) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 42px;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n#igv-text-button-label {\\n text-anchor: middle;\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-inactive rect {\\n stroke: #737373;\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-inactive text {\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-inactive tspan {\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-hover text {\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-hover tspan {\\n dominant-baseline: middle;\\n}\\n\\n#igv-save-svg-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-svg-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-svg-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-svg-group:hover text {\\n fill: white;\\n}\\n\\n#igv-save-png-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-png-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-png-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-png-group:hover text {\\n fill: white;\\n}\\n\\n.igv-zoom-in-notice-container {\\n z-index: 256;\\n position: absolute;\\n top: 8px;\\n left: 50%;\\n transform: translate(-50%, 0%);\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n background-color: white;\\n}\\n.igv-zoom-in-notice-container > div {\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-top: 2px;\\n padding-bottom: 2px;\\n width: 100%;\\n height: 100%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: #3f3f3f;\\n}\\n\\n.igv-zoom-in-notice {\\n position: absolute;\\n top: 10px;\\n left: 50%;\\n}\\n.igv-zoom-in-notice div {\\n position: relative;\\n left: -50%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #3f3f3f;\\n background-color: rgba(255, 255, 255, 0.51);\\n z-index: 64;\\n}\\n\\n.igv-container-spinner {\\n position: absolute;\\n top: 90%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n z-index: 1024;\\n width: 24px;\\n height: 24px;\\n pointer-events: none;\\n color: #737373;\\n}\\n\\n.igv-multi-locus-close-button {\\n position: absolute;\\n top: 2px;\\n right: 0;\\n padding-left: 2px;\\n padding-right: 2px;\\n width: 12px;\\n height: 12px;\\n color: #666666;\\n background-color: white;\\n z-index: 1000;\\n}\\n.igv-multi-locus-close-button > svg {\\n vertical-align: top;\\n}\\n\\n.igv-multi-locus-close-button:hover {\\n cursor: pointer;\\n color: #434343;\\n}\\n\\n.igv-multi-locus-ruler-label {\\n z-index: 64;\\n position: absolute;\\n top: 2px;\\n left: 0;\\n width: 100%;\\n height: 12px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label > div {\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n color: rgb(16, 16, 16);\\n background-color: white;\\n}\\n.igv-multi-locus-ruler-label > div {\\n cursor: pointer;\\n}\\n\\n.igv-multi-locus-ruler-label-square-dot {\\n z-index: 64;\\n position: absolute;\\n left: 50%;\\n top: 5%;\\n transform: translate(-50%, 0%);\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\\n width: 14px;\\n height: 14px;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\\n margin-left: 16px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: rgb(16, 16, 16);\\n}\\n\\n.igv-ruler-sweeper {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 26px;\\n bottom: 0;\\n left: 0;\\n width: 0;\\n z-index: 99999;\\n background-color: rgba(68, 134, 247, 0.25);\\n}\\n\\n.igv-ruler-tooltip {\\n pointer-events: none;\\n z-index: 128;\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 1px;\\n height: 32px;\\n background-color: transparent;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ruler-tooltip > div {\\n pointer-events: none;\\n width: 128px;\\n height: auto;\\n padding: 1px;\\n color: #373737;\\n font-size: 10px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n background-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-color: #373737;\\n}\\n\\n.igv-track-label {\\n position: absolute;\\n left: 8px;\\n top: 8px;\\n width: auto;\\n height: auto;\\n max-width: 50%;\\n padding-left: 4px;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n text-align: center;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-color: #444;\\n border-radius: 2px;\\n border-style: solid;\\n border-width: thin;\\n background-color: white;\\n z-index: 128;\\n cursor: pointer;\\n}\\n\\n.igv-track-label:hover,\\n.igv-track-label:focus,\\n.igv-track-label:active {\\n background-color: #e8e8e8;\\n}\\n\\n.igv-track-label-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-top: 4px;\\n}\\n\\n.igv-center-line {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n transform: translateX(-50%);\\n z-index: 8;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-left-style: dashed;\\n border-left-width: thin;\\n border-right-style: dashed;\\n border-right-width: thin;\\n}\\n\\n.igv-center-line-wide {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(127, 127, 127, 0.51);\\n}\\n\\n.igv-center-line-thin {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(0, 0, 0, 0);\\n}\\n\\n.igv-cursor-guide-horizontal {\\n display: none;\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n left: 0;\\n right: 0;\\n top: 50%;\\n height: 1px;\\n z-index: 32;\\n margin-left: 50px;\\n margin-right: 54px;\\n border-top-style: dotted;\\n border-top-width: thin;\\n border-top-color: rgba(127, 127, 127, 0.76);\\n}\\n\\n.igv-cursor-guide-vertical {\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n width: 1px;\\n z-index: 32;\\n border-left-style: dotted;\\n border-left-width: thin;\\n border-left-color: rgba(127, 127, 127, 0.76);\\n display: none;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-generic-dialog-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\\n width: 30%;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-generic-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-container div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-generic-container div:first-child i {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-menu-popup {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: max-content;\\n max-width: 400px;\\n z-index: 512;\\n cursor: pointer;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background: white;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-end;\\n text-align: left;\\n}\\n.igv-menu-popup > div:not(:first-child) {\\n width: 100%;\\n}\\n.igv-menu-popup > div:not(:first-child) > div {\\n background: white;\\n}\\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\\n padding-left: 4px;\\n padding-right: 4px;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:last-child {\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:hover {\\n background: #efefef;\\n}\\n\\n.igv-menu-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-bottom: 1px;\\n padding-top: 1px;\\n}\\n\\n.igv-menu-popup-header {\\n position: relative;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-menu-popup-header div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-menu-popup-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n.igv-menu-popup-check-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 20px;\\n margin-right: 4px;\\n background-color: transparent;\\n}\\n.igv-menu-popup-check-container div {\\n padding-top: 2px;\\n padding-left: 8px;\\n}\\n.igv-menu-popup-check-container div:first-child {\\n position: relative;\\n width: 12px;\\n height: 12px;\\n}\\n.igv-menu-popup-check-container div:first-child svg {\\n position: absolute;\\n width: 12px;\\n height: 12px;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-loading-spinner-container {\\n z-index: 1024;\\n position: absolute;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 32px;\\n height: 32px;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-loading-spinner-container > div {\\n box-sizing: border-box;\\n width: 100%;\\n height: 100%;\\n border-radius: 50%;\\n border: 4px solid rgba(128, 128, 128, 0.5);\\n border-top-color: rgb(255, 255, 255);\\n animation: spin 1s ease-in-out infinite;\\n -webkit-animation: spin 1s ease-in-out infinite;\\n}\\n\\n@keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n@-webkit-keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n.igv-roi-menu {\\n position: absolute;\\n z-index: 512;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background-color: white;\\n width: 192px;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-menu > div:first-child {\\n height: 24px;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-roi-menu > div:first-child > div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-roi-menu > div:first-child > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-menu > div:last-child {\\n background-color: white;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: 0;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n text-align: start;\\n vertical-align: middle;\\n}\\n.igv-roi-menu > div:last-child > div {\\n height: 24px;\\n padding-left: 4px;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n border-bottom-color: #7f7f7f;\\n}\\n.igv-roi-menu > div:last-child > div:not(:first-child):hover {\\n cursor: pointer;\\n background-color: rgba(127, 127, 127, 0.1);\\n}\\n.igv-roi-menu > div:last-child div:first-child {\\n font-style: italic;\\n text-align: center;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n}\\n.igv-roi-menu > div:last-child > div:last-child {\\n border-bottom-width: 0;\\n border-bottom-color: transparent;\\n}\\n\\n.igv-roi-placeholder {\\n font-style: normal;\\n color: rgba(75, 75, 75, 0.6);\\n}\\n\\n.igv-roi-table {\\n position: absolute;\\n z-index: 1024;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n resize: both;\\n overflow: hidden;\\n width: min-content;\\n max-width: 1600px;\\n border-color: #7f7f7f;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n font-weight: 400;\\n background-color: white;\\n cursor: default;\\n}\\n.igv-roi-table > div {\\n height: 24px;\\n font-size: 14px;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n}\\n.igv-roi-table > div:first-child {\\n border-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-top-width: 0;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-roi-table > div:first-child > div:first-child {\\n text-align: center;\\n white-space: nowrap;\\n text-overflow: ellipsis;\\n overflow: hidden;\\n margin-left: 4px;\\n margin-right: 4px;\\n width: calc(100% - 4px - 12px);\\n}\\n.igv-roi-table > div:first-child > div:last-child {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7f7f7f;\\n}\\n.igv-roi-table > div:first-child > div:last-child > svg {\\n display: block;\\n}\\n.igv-roi-table > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-table > .igv-roi-table-description {\\n padding: 4px;\\n margin-left: 4px;\\n word-break: break-all;\\n overflow-y: auto;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-goto-explainer {\\n margin-top: 5px;\\n margin-left: 4px;\\n color: #7F7F7F;\\n font-style: italic;\\n height: 24px;\\n border-top: solid lightgray;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n padding-right: 16px;\\n background-color: white;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: #7f7f7f;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n overflow: auto;\\n height: 360px;\\n flex: 1 1 auto;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: transparent;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n.igv-roi-table > div:last-child {\\n min-height: 32px;\\n height: 32px;\\n line-height: 32px;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: transparent;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-width: 0;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n\\n.igv-roi-table-row-selected {\\n background-color: rgba(0, 0, 0, 0.125);\\n}\\n\\n.igv-roi-table-button {\\n cursor: pointer;\\n height: 20px;\\n user-select: none;\\n line-height: 20px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 13px;\\n font-weight: 400;\\n color: black;\\n padding-left: 6px;\\n padding-right: 6px;\\n background-color: rgb(239, 239, 239);\\n border-color: black;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 3px;\\n}\\n\\n.igv-roi-table-button:hover {\\n font-weight: 400;\\n background-color: rgba(0, 0, 0, 0.13);\\n}\\n\\n.igv-roi-region {\\n z-index: 64;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n pointer-events: none;\\n overflow: visible;\\n margin-top: 66px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-region > div {\\n position: relative;\\n width: 100%;\\n height: 8px;\\n pointer-events: auto;\\n}\\n\\n.igv-roi-menu-row {\\n height: 24px;\\n padding-left: 8px;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n background-color: white;\\n}\\n\\n.igv-roi-menu-row-edit-description {\\n width: -webkit-fill-available;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n background-color: white;\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-bottom: 4px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-menu-row-edit-description > label {\\n margin-left: 2px;\\n margin-bottom: 0;\\n display: block;\\n width: -webkit-fill-available;\\n}\\n.igv-roi-menu-row-edit-description > input {\\n display: block;\\n margin-left: 2px;\\n margin-right: 2px;\\n margin-bottom: 1px;\\n width: -webkit-fill-available;\\n}\\n\\n.igv-container {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n padding-top: 4px;\\n user-select: none;\\n -webkit-user-select: none;\\n -ms-user-select: none;\\n min-height: 160px;\\n}\\n\\n.igv-viewport {\\n position: relative;\\n margin-top: 5px;\\n line-height: 1;\\n overflow-x: hidden;\\n overflow-y: hidden;\\n}\\n\\n.igv-viewport-content {\\n position: relative;\\n width: 100%;\\n}\\n.igv-viewport-content > canvas {\\n position: relative;\\n display: block;\\n}\\n\\n.igv-column-container {\\n position: relative;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n width: 100%;\\n}\\n\\n.igv-column-shim {\\n width: 1px;\\n margin-left: 2px;\\n margin-right: 2px;\\n background-color: #545453;\\n}\\n\\n.igv-axis-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 50px;\\n}\\n.igv-axis-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n}\\n.igv-axis-column > div > div {\\n z-index: 512;\\n position: absolute;\\n top: 8px;\\n left: 8px;\\n width: fit-content;\\n height: fit-content;\\n background-color: transparent;\\n display: grid;\\n align-items: start;\\n justify-items: center;\\n}\\n.igv-axis-column > div > div > input {\\n display: block;\\n margin: unset;\\n cursor: pointer;\\n}\\n\\n.igv-column {\\n position: relative;\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-info-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-name-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-scrollbar-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div > div {\\n cursor: pointer;\\n position: absolute;\\n top: 0;\\n left: 2px;\\n width: 8px;\\n border-width: 1px;\\n border-style: solid;\\n border-color: #c4c4c4;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-scrollbar-column > div > div:hover {\\n background-color: #c4c4c4;\\n}\\n\\n.igv-track-drag-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 12px;\\n background-color: white;\\n}\\n.igv-track-drag-column > .igv-track-drag-handle {\\n z-index: 512;\\n position: relative;\\n cursor: pointer;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n border-top-right-radius: 6px;\\n border-bottom-right-radius: 6px;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-color {\\n background-color: #c4c4c4;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-hover-color {\\n background-color: #787878;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-selected-color {\\n background-color: #0963fa;\\n}\\n.igv-track-drag-column > .igv-track-drag-shim {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n}\\n\\n.igv-gear-menu-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 28px;\\n}\\n.igv-gear-menu-column > div {\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n margin-top: 5px;\\n width: 100%;\\n background: white;\\n}\\n.igv-gear-menu-column > div > div {\\n position: relative;\\n margin-top: 4px;\\n width: 16px;\\n height: 16px;\\n color: #7F7F7F;\\n}\\n.igv-gear-menu-column > div > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n/*# sourceMappingURL=igv.css.map */\\n'),n.adoptedStyleSheets=[e]}if(this.root=e({class:\"igv-container\"}),n.appendChild(this.root),this.spinner=e({class:\"igv-loading-spinner-container\"}),this.root.appendChild(this.spinner),this.spinner.appendChild(e()),this.spinner.style.width=\"64px\",this.spinner.style.height=\"64px\",this.stopSpinner(),this.alert=new La(this.root),this.columnContainer=e({class:\"igv-column-container\"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Xu(this.columnContainer),this.menuUtils=new bo(this),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:\"rgb(0,0,150)\",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},t.listeners)for(let e of Object.keys(t.listeners))this.on(e,t.listeners[e]);this.on(\"trackremoved\",(()=>{0===this.findTracks((e=>\"function\"==typeof e.getSamples)).length&&(this.sampleInfoControl.setButtonVisibility(!1),this.sampleNameViewportWidth=void 0,this.showSampleNames=!1,this.sampleNameControl.setState(this.showSampleNames),this.sampleNameControl.hide(),this.layoutChange())})),this.on(\"didchangecolumnlayout\",(()=>{if(yu.length>0){const e=yu.length;for(let t=0;t1}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let e of this.referenceFrameList)if(\"all\"===e.chr.toLowerCase())return!0;return!1}currentLoci(){const e=e=>`${e.chr}:${e.start+1}-${e.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?\"\":1===this.referenceFrameList.length?e(this.referenceFrameList[0]):this.referenceFrameList.map((t=>e(t)))}toSVG(){const{x:e,y:t,width:i,height:n}=this.columnContainer.getBoundingClientRect(),r=new lu({width:i,height:n,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:i,height:n}}),s={deltaX:0,deltaY:-t};for(let e of this.trackViews)e.renderSVGContext(r,s);return s.deltaX=e,this.roiManager.renderSVGContext(this.columnContainer,r,s),r.getSerializedSvg(!0)}saveSVGtoFile(e,t){let i=this.toSVG();if(t){const e=document.createElement(\"svg\");e.innerHTML=i,t.append(e),t.appendChild(e)}const n=e||\"igvjs.svg\",r=URL.createObjectURL(new Blob([i],{type:\"application/octet-stream\"}));Pt(n,r),URL.revokeObjectURL(r)}savePNGtoFile(e){const t=this.toSVG(),i=new Blob([t],{type:\"image/svg+xml\"}),n=URL.createObjectURL(i),r=document.createElement(\"img\");r.addEventListener(\"load\",(()=>{const t=this.columnContainer.getBoundingClientRect(),i=window.devicePixelRatio,s=t.width*i,o=t.height*i,a=document.createElement(\"canvas\");a.width=s,a.height=o;const c=a.getContext(\"2d\");c.scale(i,i),c.drawImage(r,0,0);const l=a.toDataURL(\"image/png\");Pt(e=e||\"igvjs.png\",l),URL.revokeObjectURL(n)})),r.src=n}async loadSession(e){let t;return this.sampleInfo.initialize(),this.roiSets=[],t=e.url||e.file?await dA.loadSessionFile(e):e,this.loadSessionObject(t)}static async loadSessionFile(e){const t=e.url||e.file;let i;if(e.url&&Mt(e.url)&&(e.url.startsWith(\"blob:\")||e.url.startsWith(\"data:\"))){const t=dA.uncompressSession(e.url);i=JSON.parse(t)}else{let n=e.filename;if(n||(n=e.url?await ja(e.url):e.file.name),n.endsWith(\".xml\")){const e=mu.KNOWN_GENOMES,n=await Qs.loadString(t);i=new by(n,e)}else if(n.endsWith(\"hub.txt\")){i={reference:(await du.loadHub(t,e)).getGenomeConfig()}}else{if(!n.endsWith(\".json\"))throw Error(\"Unrecognized session file format:\"+n);i=await Qs.loadJson(t)}}return bA(i)}async loadSessionObject(e){this.cleanHouseForSession(),this.config=e,e.browsers&&(e=await async function(e){const t=e.browsers[0],i={},n=new Mf({url:t.url});await n.readHeaderAndFooter(),i.sampleNameViewportWidth=20,i.genome=\"hg38\";const r=t.state.split(\",\"),s=n.bpResolutions[Number.parseInt(r[2])],o=Number.parseInt(r[0]),a=Math.floor(Number.parseFloat(r[3])*s),c=a+Math.floor(1700*s);return i.locus=`${n.chromosomes[o].name}:${a}-${c}`,i.tracks=(t.tracks||[]).filter((e=>!(\"refgene\"===e.format||\"cellType\"===e.name))),i.tracks.push({type:\"shoebox\",url:t.url,name:t.name,colorScale:t.colorScale,_hicFile:n}),i}(e)),this.navbar.sampleInfoControl.setButtonVisibility(!1),this.showSampleNames=e.showSampleNames||!1,this.navbar.sampleNameControl.setState(!0===this.showSampleNames),e.sampleNameViewportWidth&&(this.sampleNameViewportWidth=e.sampleNameViewportWidth),$a(this.columnContainer,\"igv-axis-column\"),$a(this.columnContainer,\"igv-sample-info-column\"),$a(this.columnContainer,\"igv-sample-name-column\"),$a(this.columnContainer,\"igv-scrollbar-column\"),$a(this.columnContainer,\"igv-track-drag-column\"),$a(this.columnContainer,\"igv-gear-menu-column\");const t=e.reference||e.genome;if(!t)return void console.warn(\"No genome or reference object specified\");const i=Mt(t)?await mu.expandReference(this.alert,t):t;if(await this.loadReference(i,i.locus||e.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==e.showIdeogram){const e=new hy(this);e.id=\"ideogram\";const t=new hf(this,this.columnContainer,e);this.trackViews.push(t)}if(!1!==e.showRuler){const e=new hf(this,this.columnContainer,new Wu(this));this.trackViews.push(e)}e.qtlSelections&&(this.qtlSelections=cA.fromJSON(e.qtlSelections)),this.roiManager.clearROIs(),e.roi?this.roiManager.loadROI(e.roi):await this.roiManager.reset();const n=[];if(e.sampleinfo)for(const t of e.sampleinfo)t.file?n.push(t.file):this.loadSampleInfo(t);const r=i.tracks||[],s=e.tracks?r.concat(e.tracks):r;0===s.filter((e=>\"sequence\"===e.type&&!e.url&&!e.fastaURL)).length&&s.push({type:\"sequence\",order:Wd,removable:!1});const o=s.filter((e=>void 0!==e.file)).map((({file:e})=>e)),a=s.filter((e=>void 0!==e.indexFile)).map((({indexFile:e})=>e));a.length>0&&o.push(...a),n.length>0&&o.push(...n),o.length>0&&alert(`Local files cannot be loaded automatically.\\nThis session contains references to these local files:\\n${o.map((e=>` ${e}`)).join(\"\\n\")}`);const c=s.filter((e=>void 0===e.file));let l=1;for(let e of c)void 0===e.order&&(e.order=l++);await this.loadTrackList(c);for(let e of this.trackViews.filter((e=>\"ruler\"===e.track.type||\"ideogram\"===e.track.type)))await e.updateViews();return this.trackViews.some((e=>e.track.selected))&&this.navbar.setEnableTrackSelection(!0),this.updateUIWithReferenceFrameList(),this.updateLocusSearchWidget(),s}cleanHouseForSession(){for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-info-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column\").forEach((e=>e.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}async loadReference(e,t){let i;this.removeAllTracks(),this.roiManager.clearROIs(),this.navbar.setEnableTrackSelection(!1),i=e.gbkURL?await wd(e.gbkURL):await aA.createGenome(e,this);const n=void 0===this.genome||this.genome.id!==i.id;this.genome=i,this.navbar.updateGenome(i);let r=t||i.initialLocus;Array.isArray(r)&&(r=r.join(\" \"));if(!await this.search(r,!0))throw new Error(`Cannot set initial locus ${r}`);if(n){let t;if(e.hubURL){t=(await du.loadHub(e.hubURL)).getGroupedTrackConfigurations()}this.fireEvent(\"genomechange\",[{genome:i,trackConfigurations:t}]),this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)})}}async loadGenome(e){let t;e.genarkAccession&&(e.url=hu(e.genarkAccession)),e.url&&(Mt(e.url)&&e.url.endsWith(\"/hub.txt\")?(e.hubURL=e.url,delete e.url):\"gbk\"===function(e){let t;if(e instanceof File)t=e.name;else{if(\"string\"!=typeof e)throw new Error(\"Input must be a File object or a URL string\");t=e}const i=t.split(\".\").pop();return i.split(\"?\")[0]}(e.url)&&(e.gbkURL=e.url,delete e.url));if(e.hubURL||e.url&&Mt(e.url)&&e.url.endsWith(\"/hub.txt\")){t=(await du.loadHub(e.hubURL||e.url,e)).getGenomeConfig()}else t=Mt(e)||!(e.url||e.fastaURL||e.twoBitURL||e.gbkURL)?await mu.expandReference(this.alert,e):e;let i;await this.loadReference(t),i=t.gbkURL||\"gbk\"===t.format?[{name:\"Annotations\",format:\"gbk\",url:t.gbkURL}]:t.tracks||[];return 0===i.filter((e=>\"sequence\"===e.type)).length&&i.push({type:\"sequence\",order:Wd}),await this.loadTrackList(i),await this.updateViews(),this.genome}async loadTrackHub(e){const t=bA((await du.loadHub(e.url,e)).getGenomeConfig());return this.loadGenome(t)}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(e[0].chr),this.navbar.navbarDidResize(),mA(this.trackViews,this.doShowTrackLabels),this.doShowCenterLine&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.centerLineButton.boundMouseClickHandler(),this.doShowCursorGuide&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.cursorGuideButton.boundMouseClickHandler(),this.setCenterLineAndCenterLineButtonVisibility(mu.isWholeGenomeView(e[0].chr))}setCenterLineAndCenterLineButtonVisibility(e){e?this.navbar.centerLineButton.setVisibility(!1):this.navbar.centerLineButton.setVisibility(this.config.showCenterGuideButton);for(let t of this.centerLineList)e?this.setCenterLineVisibility(!e):this.setCenterLineVisibility(this.doShowCenterLine)}setTrackLabelVisibility(e){mA(this.trackViews,e)}setROITableVisibility(e){!0===e?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)!0===e?(t.show(),t.repaint()):t.hide()}async loadTrackList(e){let t=0;for(let i of e)void 0===i.order&&(i.order=t++);const i=[];for(let t of e)i.push(this._loadTrack(t));const n=await Promise.all(i);return this.trackViews.filter((function(e){return e.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadTrack(e){e.sync=!1!==e.sync;const t=this._loadTrack(e);return t&&e.autoscaleGroup&&(await t,this.updateViews()),t}async _loadTrack(e){Mt(e)&&(e=JSON.parse(e));try{if(e.hidden){const t=Ad(e,this.genome);return void await t.getFeatures({chr:\"1\",start:0,end:Number.MAX_SAFE_INTEGER})}const t=await this.createTrack(e);if(\"sampleinfo\"===e.type)return void this.layoutChange();if(void 0===t)return;return this.addTrack(e,t)}catch(t){let i=t.message||t.error||t.toString();const n={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};n.hasOwnProperty(i)&&(i=n[i]),i=`${i} : ${Ht(e.url)?e.url.name:e.url}`;const r=new Error(i);throw console.error(r),r}}async addTrack(e,t){void 0===t.order&&(t.order=this.trackViews.length);const i=new hf(this,this.columnContainer,t);if(this.trackViews.push(i),mA(this.trackViews,this.doShowTrackLabels),\"function\"==typeof t.postInit)try{i.startSpinner(),await t.postInit()}finally{i.stopSpinner()}return t.autoscaleGroup||(e.sync?await i.updateViews():i.updateViews()),\"function\"==typeof t.hasSamples&&t.hasSamples()&&(this.sampleInfo.hasAttributes()&&this.sampleInfoControl.setButtonVisibility(!0),!1!==this.config.showSampleNameButton&&this.sampleNameControl.show()),this.reorderTracks(),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),t.trackView.enableTrackSelection(this.navbar.getEnableTrackSelection()),t}async loadROI(e){return this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=this.roiManager.getUserDefinedROISet();if(void 0===e)return[];const t=await e.getAllFeatures(),i=[];for(let e of Object.values(t))i.push(...e);return i}return[]}getRulerTrackView(){const e=this.trackViews.filter((({track:e})=>\"ruler\"===e.id));return e.length>0?e[0]:void 0}async createTrack(e){let t=await async function(e){return\"function\"==typeof e?e():e}\n", - "/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(e.url||e.fastaURL);if(Mt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format=\"fasta\";else if(e.sourceType)\"htsget\"===e.sourceType&&await Rh.inferFormat(e);else{const t=await am(e);t&&(e.format=t)}e.type&&Ha(e);let i=e.type?e.type.toLowerCase():void 0;if(!i){if(!e.format)throw Error(`Unrecognized track: ${JSON.stringify(e)}`);if(\"hic\"===e.format){const t=new Mf(e);if(await t.readHeaderAndFooter(),!t.chromosomeIndexMap.celltype)throw Error(\"'.hic' files not supported\");i=\"shoebox\",e._hicFile=t}else if(i=za(e.format),\"bedtype\"===i){const t=Ad(e,this.genome);e._featureSource=t;const n=await t.trackType();i=n||\"annotation\"}e.type=i}if(this.trackDefaults&&i){const t=this.trackDefaults[i];if(t)for(let i in t)t.hasOwnProperty(i)&&void 0===e[i]&&(e[i]=t[i])}const n=function(e,t,i){let n;switch(e){case\"annotation\":case\"genes\":case\"fusionjuncspan\":case\"snp\":n=\"feature\";break;case\"seg\":case\"maf\":case\"mut\":n=\"seg\";break;case\"junctions\":case\"splicejunctions\":n=\"junction\";break;default:n=e}return wy.has(n)?wy.get(n)(t,i):void 0}(i,e,this);if(void 0!==n)return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map((e=>new eA(e,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0)}reorderTracks(){this.trackViews.sort((function(e,t){const i=e=>\"ideogram\"===e.track.id?1:\"ruler\"===e.track.id?2:3,n=i(e),r=i(t);if(n===r){return(e.track.order||0)-(t.track.order||0)}return n-r}));for(let{axis:e,viewports:t,sampleInfoViewport:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){e.remove();for(let{$viewport:e}of t)e.detach();i.viewport.remove(),n.viewport.remove(),r.remove(),s.remove(),o.remove()}const e=this.columnContainer.querySelectorAll(\".igv-column\");for(let{axis:t,viewports:i,sampleInfoViewport:n,sampleNameViewport:r,outerScroll:s,dragHandle:o,gearContainer:a}of this.trackViews){this.columnContainer.querySelector(\".igv-axis-column\").appendChild(t);for(let t=0;te.track&&e.track.name)).map((e=>e.track.name))}getSelectedTrackViews(){return this.trackViews.filter((e=>!0===e.track.selected))}removeTrackByName(e){const t=this.trackViews.slice();for(let i of t)e===i.track.name&&this.removeTrack(i.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent(\"trackremoved\",[e]),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=this.trackViews;this.trackViews=[];for(let t of e)\"ruler\"!==t.track.id&&\"ideogram\"!==t.track.id?(this.fireEvent(\"trackremoved\",[t.track]),t.dispose()):this.trackViews.push(t)}get ideogramTrackView(){return this.trackViews[0]}get rulerTrackView(){return this.trackViews[1]}findTracks(e,t){let i=\"function\"==typeof e?t=>e(t.track):i=>t===i.track[e];return this.trackViews.filter(i).map((e=>e.track))}get tracks(){return this.trackViews.map((e=>e.track)).filter((e=>void 0!==e))}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach((function(t){t.setTrackHeight(e)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((e=>e.bpPerPixel<0))){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel=(t.end-t.start)/e}this.referenceFrameList&&this.navbar.navbarDidResize(),uA.call(this),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(let e of this.referenceFrameList)e.bpPerPixel<=10&&await this.genome.getSequence(e.chr,e.start,e.start+1);for(let e of this.centerLineList)e.repaint();if(this.dragObject)for(let t of e)await t.updateViews();else{const t={},i=[];for(const n of e)if(n.track.autoscaleGroup){const e=n.track.autoscaleGroup;t[e]||(t[e]=[]),t[e].push(n)}else i.push(n);if(Object.entries(t).length>0)for(const[e,i]of Object.entries(t)){const e=await Promise.all(i.map((e=>e.getInViewFeatures()))),t=qa(e.flat());for(const e of i)e.track.dataRange=Object.assign({},t),e.track.autoscale=!1;await Promise.all(i.map((e=>e.updateViews())))}await Promise.all(i.map((e=>e.updateViews())))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of e)i.end=i.start+i.bpPerPixel*t;const i=1===e.length?this.referenceFrameList[0].chr:\"\",n=this.referenceFrameList.map((e=>e.getLocusString())).join(\" \");this.navbar.updateLocus(n,i),this.fireEvent(\"locuschange\",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleInfoViewportWidth()+this.getSampleNameViewportWidth()+14+12+28,t-=5*(e-1),Math.floor(t/e)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=s;const o=(i-t)/r,a=new vy(this.genome,e,t,i,o),c=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],d=Uy(h.get(0).parentElement);if(this.fireEvent(\"didchangecolumnlayout\"),l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.push(t)}}else{this.referenceFrameList.splice(l,0,a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.splice(l,0,t)}}this.centerLineList=this.createCenterLineList(this.columnContainer),uA.call(this),await this.updateViews(!0)}createCenterLineList(e){const t=e.querySelectorAll(\".igv-center-line\");for(let e=0;e{i===t||e.remove()})),this.columnContainer.querySelectorAll(\".igv-column-shim\").forEach((e=>e.remove()));for(let e of this.trackViews){const i=e.viewports[t];e.viewports.filter(((e,i)=>i!==t)).forEach((e=>e.dispose())),e.viewports=[i]}const i=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/i,this.referenceFrameList=[e],this.trackViews.forEach((({viewports:e})=>e.forEach((e=>e.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=e;for(let{viewports:e}of this.trackViews)for(let i of e)i.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,i){await this.search(e+\":\"+t+\"-\"+i)}async doSearch(e,t){const i=await this.search(e,t);return i||this.alert.present(new Error(`Unrecognized locus: ${e} `)),i}async search(e,t){const i=await async function(e,t){if(void 0===t||\"\"===t.trim())return;const i=t.split(\" \");let n=[];const r=async t=>{if(\"all\"===t.trim().toLowerCase()||\"*\"===t)return e.genome.wholeGenomeView?{chr:\"all\",start:0,end:e.genome.getChromosome(\"all\").bpLength}:void 0;let i,n;if(t.includes(\":\")&&(i=ey(t,e.isSoftclipped()),i&&(n=await e.genome.loadChromosome(i.chr))),!n){i=void 0;const r=await Jv(e,t);r&&(i={chr:r.chr,start:r.start,end:r.end,name:(r.name||t).toUpperCase()}),i||(n=await e.genome.loadChromosome(t),n&&(i={chr:n.name}))}return i&&(n=n||await e.genome.loadChromosome(i.chr),i.chr=n.name,void 0===i.start&&void 0===i.end&&(i.start=0,i.end=n.bpLength)),i};for(let e of i){const t=await r(e);t&&n.push(t)}if(0===n.length){const e=await r(t.replaceAll(\" \",\"+\"));e&&n.push(e)}return 0===n.length?void 0:n}(this,e);if(i&&i.length>0){this.referenceFrameList=function(e,t,i,n,r,s){return e.map((e=>{const o=Object.assign({},e);if(i&&o.name&&(o.start=Math.max(0,o.start-i),o.end+=i),!s){const e=t.getChromosome(o.chr);Qa(e.bpLength,o,n)}return new vy(t,o.chr,o.start,o.end,(o.end-o.start)/r)}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let e of this.trackViews)e.removeViewportsFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-column-shim, .igv-column\").forEach((e=>e.remove())),qy(this.columnContainer.querySelector(\".igv-sample-info-column\"),this.referenceFrameList.length),this.fireEvent(\"didchangecolumnlayout\");for(let e of this.trackViews)e.createViewports(this,this.columnContainer,this.referenceFrameList);return this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}return!1}async loadSampleInfo(e){await this.sampleInfo.loadSampleInfoFile(e.url);for(const{sampleInfoViewport:e}of this.trackViews)e.setWidth(this.getSampleInfoColumnWidth());this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0&&(this.sampleInfoControl.performClickWithState(this,!0),this.sampleInfoControl.setButtonVisibility(!0));for(const{sampleInfoViewport:e}of this.trackViews)e.repaint()}getSampleInfoColumnWidth(){if(this.sampleInfo.attributeCount){const e=this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0,t=this.sampleInfo.hasAttributes(),i=this.sampleInfoControl.showSampleInfo;return e&&t&&i?this.sampleInfo.attributeCount*Vu+8:0}return 0}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(e)if(t){const i=this.eventHandlers[e];if(i&&0!==i.length){const n=i.indexOf(t);-1!==n&&this.eventHandlers[e].splice(n,1)}else console.warn(\"No handlers to remove for event: \"+e)}else this.eventHandlers[e]=[];else this.eventHandlers={}}fireEvent(e,t,i){const n=this.eventHandlers[e];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(e){return e.apply(r,t)}))[0]}dispose(){this.removeEventHandlers();for(let e of this.trackViews)e.dispose();this.roiManager&&this.roiManager.dispose()}toJSON(){const e={version:\"3.0.9\"};if(void 0!==this.showSampleNames&&(e.showSampleNames=this.showSampleNames),this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[];let i=this.trackViews[0];for(let{referenceFrame:e}of i.viewports){const i=e.getLocusString();t.push(i)}e.locus=1===t.length?t[0]:t,e.roi=this.roiManager.toJSON(),this.qtlSelections.isEmpty()||(e.qtlSelections=this.qtlSelections.toJSON());const n=[],r=[];for(const{track:e}of this.trackViews)try{let t;\"function\"==typeof e.getState?t=Hl.localFileInspection(e.getState()):e.config&&(t=Hl.localFileInspection(e.config)),t&&(t.browser&&delete t.browser,t.order=e.order,n.push(t))}catch(t){const i=`Track: ${e.name}: ${t}`;console.error(i),r.push(i)}if(r.length>0){let e=1,t=\"Errors encountered saving session:
\";for(let i of r)t+=` (${e++}) ${i.toString()}
`;throw Error(t)}e.tracks=n;const s=[];for(const e of n)for(const t of Object.keys(e))\"file\"!==t&&\"indexFile\"!==t||s.push(e[t]);const o=[];if(this.sampleInfo.sampleInfoFiles.length>0){const t=this.sampleInfo.toJSON();t.length>0&&(e.sampleinfo=t);for(const e of this.sampleInfo.sampleInfoFiles){const t=Hl.localFileInspection({url:e});t.file&&o.push(t.file)}o.length>0&&s.push(...o)}return s.length>0&&alert(`This session includes reference(s) to local file(s):\\n${s.map((e=>` ${e}`)).join(\"\\n\")}\\nLocal files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){return function(e){const t=new Uint8Array(e.length);for(var i=0;i0?e.substring(0,t):e)+\"?sessionURL=blob:\"+this.compressedSession()}mouseDownOnViewport(e,t){var i;i=r(e),this.vpMouseDown={viewport:t,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent(\"trackdragend\",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((e=>!0===e.track.showSoftClips))}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,i=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),r=this.trackViews;r[i]=t,r[n]=e;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i0;e--){const t=r[e].track;if(!(t.order>=a))break;t.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=t.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=uA.bind(this),window.addEventListener(\"resize\",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener(\"resize\",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=pA.bind(this),this.root.addEventListener(\"mouseup\",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener(\"mouseup\",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=pA.bind(this),this.root.addEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=fA.bind(this),this.boundColumnContainerTouchMoveHandler=fA.bind(this),this.boundColumnContainerMouseLeaveHandler=pA.bind(this),this.boundColumnContainerMouseUpHandler=pA.bind(this),this.boundColumnContainerTouchEndHandler=pA.bind(this),this.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=gA.bind(this),document.addEventListener(\"keyup\",this.keyUpHandler)}removeKeyboardHandler(){console.log(\"Remove handler\"),document.addEventListener(\"keyup\",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf(\"/gzip;base64\")>0){t=vs(e);let i=\"\";for(let e of t)i+=String.fromCharCode(e);return i}return function(e){e=e.replace(/\\./g,\"+\").replace(/_/g,\"/\").replace(/-/g,\"=\");const t=atob(e),i=[];for(let e=0;e{const r=e.data,s=r.mate;function o(e){e.chr=i.genome.getChromosomeName(e.refName);let t=!1;for(let n of i.referenceFrameList){const i=lm.fromLocusString(n.getLocusString());if(i.contains(e)){t=!0;break}if(i.overlaps(e)){n.extend(e),t=!0;break}}if(!t){const t=2e3,n=(e.start+e.end)/2;i.addMultiLocusPanel(e.chr,n-t,n+t)}}o(r),o(s)}})),this.circularViewControl=new Vy(this.navbar.toggle_button_container,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get sampleInfoControl(){return this.navbar.sampleInfoControl}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}get sampleNameControl(){return this.navbar.sampleNameControl}}async function uA(){if(!this.referenceFrameList)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList){const i=this.referenceFrameList.indexOf(t),{chr:n,genome:r}=t,{bpLength:s}=r.getChromosome(t.chr),o=t.toBP(e);mu.isWholeGenomeView(n)||o>s?t.bpPerPixel=s/e:t.end=t.start+t.toBP(e);for(let{viewports:t}of this.trackViews)t[i].setWidth(e)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function fA(e){e.preventDefault();const{x:t,y:i}=r(e);if(this.vpMouseDown){const{viewport:e,referenceFrame:n}=this.vpMouseDown,r=Math.abs(t-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(t-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:e,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const t=e.$viewport.height(),i=e.trackView.maxViewportContentHeight();this.vpMouseDown.r=t/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-t;n.shiftPixels(r,e.$viewport.width(),i)&&this.updateViews(),this.fireEvent(\"trackdrag\")}if(this.isScrolling){const t=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);e.trackView.moveScroller(t)}this.vpMouseDown.lastMouseX=t,this.vpMouseDown.lastMouseY=i}}function pA(e){this.cancelTrackPan(),this.endTrackDrag()}async function gA(e){if(this.referenceFrameList&&!(this.referenceFrameList.length>1)&&(\"KeyF\"===e.code||\"KeyB\"===e.code)){const t=this.getSelectedTrackViews();if(t.length>0){const i=t[0].track;if(\"function\"==typeof i.nextFeatureAfter){const t=this.referenceFrameList[0],n=t.viewport?t.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),r=\"all\"===t.chr.toLowerCase(),s=i.visibilityWindow;if(r||s&&s>0&&t.bpPerPixel*n>s)return;const o=\"KeyF\"===e.code,a=t.chr,c=t.center,l=await i.nextFeatureAfter(a,c,o);if(l){const i=await this.genome.getChromosomeName(l.chr);if(a===i){const i=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,r=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,i-r/2),t.end=i+r/2,t.bpPerPixel=(t.end-t.start)/n}else t.shift(i-c);this.updateViews()}else{t.chr=i;const r=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,i=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,r-i/2),t.end=t.start+i,t.bpPerPixel=(t.end-t.start)/n}else t.start=r-n*t.bpPerPixel/2,t.end=t.start+n*t.bpPerPixel;this.updateViews()}}}}}}function mA(e,t){for(let{viewports:i}of e)for(let e of i)e.$trackLabel&&(0===i.indexOf(e)&&!0===t?e.$trackLabel.show():e.$trackLabel.hide())}let wA=[];function bA(e){return void 0===e.minimumBases&&(e.minimumBases=40),void 0===e.showIdeogram&&(e.showIdeogram=!0),void 0===e.showCircularView&&(e.showCircularView=!1),void 0===e.showCircularViewButton&&(e.showCircularViewButton=!1),void 0===e.showTrackLabelButton&&(e.showTrackLabelButton=!0),void 0===e.showTrackLabels&&(e.showTrackLabels=!0),void 0===e.showCursorTrackingGuideButton&&(e.showCursorTrackingGuideButton=!0),void 0===e.showCursorGuide&&(e.showCursorGuide=e.showCursorTrackingGuide||!1),void 0===e.showCenterGuideButton&&(e.showCenterGuideButton=!0),void 0===e.showCenterGuide&&(e.showCenterGuide=!1),void 0===e.showSampleNames&&(e.showSampleNames=!1),void 0===e.showSVGButton&&(e.showSVGButton=!0),void 0===e.showControls&&(e.showControls=!0),void 0===e.showNavigation&&(e.showNavigation=!0),void 0===e.showRuler&&(e.showRuler=!0),void 0===e.flanking&&(e.flanking=1e3),void 0===e.pairsSupported&&(e.pairsSupported=!0),e.tracks||(e.tracks=[]),e}const FA=Qs.setApiKey;const vA=Qs.oauth;var yA={TrackUtils:Pa,IGVGraphics:xo,MenuUtils:bo,DataRangeDialog:_o,createTrack:async function(e,t){return await dA.prototype.createTrack.call(t,e)},createBrowser:async function(e,t){void 0===t&&(t={}),mu.KNOWN_GENOMES||await mu.initializeGenomes(t),bA(t),t.queryParametersSupported&&function(e){var t,i,n,r,s,o,a,c,l;let h,d,u;if(a=window.location.href,s={},t=a.indexOf(\"?\"),i=a.lastIndexOf(\"#\"),t>=0)for(i<0&&(i=a.length),n=t+1;nt&&(i.indexURL=d[t]),u&&u.length>t&&(i.name=u[t]),e.tracks.push(i)}}}(t),t.apiKey&&Qs.setApiKey(t.apiKey),t.oauthToken&&Qs.setOauthToken(t.oauthToken),t.clientId&&!Ts()&&await async function(e){if(!google.accounts.oauth2.initTokenClient)throw new Error(\"Google accounts token client not loaded (https://accounts.google.com/gsi/client)\");if(Ts())throw new Error(\"Google client is already initialized\");const t={client_id:e.client_id||e.clientId,scope:e.scope||\"https://www.googleapis.com/auth/userinfo.profile\",state:e.state||\"igv\",error:e=>{throw new Error(e.type)},hint:e.hint,hosted_domain:e.hosted_domain},i=google.accounts.oauth2.initTokenClient(t);google.igv={tokenClient:i,apiKey:e.apiKey}}({client_id:t.clientId,apiKey:t.apiKey,scope:\"https://www.googleapis.com/auth/userinfo.profile\"});const i=new dA(t,e);wA.push(i),i.startSpinner();const n=t.sessionURL||t.session||t.hubURL;return n?await i.loadSession({url:n}):await i.loadSessionObject(t),i.stopSpinner(),i.navbar.navbarDidResize(),i},removeBrowser:function(e){e.dispose(),e.root.remove(),wA=wA.filter((t=>t!==e))},removeAllBrowsers:function(){for(let e of wA)e.dispose(),e.root.remove();wA=[]},visibilityChange:async function(){for(let e of wA)await e.visibilityChange()},setGoogleOauthToken:function(e){return Qs.setOauthToken(e)},setOauthToken:function(e,t){return Qs.setOauthToken(e,t)},oauth:vA,version:yy,setApiKey:FA,TrackBase:Hl,registerTrackClass:function(e,t){wy.set(e,((e,i)=>new t(e,i)))},registerTrackCreatorFunction:function(e,t){wy.set(e,t)},registerFileFormats:function(e,t){Sl[e]={fields:t}},loadSessionFile:dA.loadSessionFile};return yA}();\n", - "//# sourceMappingURL=igv.iife.js.map\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Global handler for igv.js messages. Messages have the form\n", - " * {\n", - " * command -- the command to execute\n", - " * id -- the id of the igv.js browser, if applicable\n", - " * data -- any data needed for the command\n", - " * }\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope, with the execption of the global handler\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " let svgComm\n", - " if (isNotebook) {\n", - " svgComm = Jupyter.notebook.kernel.comm_manager.new_comm('svg', {})\n", - " }\n", - "\n", - " async function toSVG(displayID, locus, svg) {\n", - " //console.log(isNotebook + \" \" + locus)\n", - " if (isNotebook) {\n", - " svgComm.send({\n", - " \"display_id\": displayID,\n", - " \"locus\": locus,\n", - " \"svg\": svg\n", - " })\n", - " }\n", - " }\n", - "\n", - " console.log(\"Installing IGVMessageHandler\")\n", - "\n", - " function convertUrlsAndPaths(session) {\n", - " if (session.reference) {\n", - " for (let pre of [\"fasta\", \"index\", \"cytoband\", \"cytobandBb\", \"compressedIndex\", \"alias\", \"aliasBb\",\n", - " \"twoBit\", \"twoBitBpt\", \"chromAliasBb\", \"chromSizes\", \"trix\"]) {\n", - " convert(session.reference, pre)\n", - " }\n", - " if (session.reference.tracks) {\n", - " for (let t of session.reference.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " if (session.tracks) {\n", - " for (let t of session.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Return true if the sessionJson object contains only absolute URLs to resources\n", - " */\n", - " function safeToWeblink(sessionJson) {\n", - " const unsafe = (url) => typeof url.startsWith != 'function' || !url.startsWith(\"http\")\n", - " if (sessionJson.reference) {\n", - " if (unsafe(sessionJson.reference.fastaURL)) return false\n", - " }\n", - " if (sessionJson.tracks) {\n", - " const urls = sessionJson.tracks.filter(t => t.url).map(t => t.url)\n", - " if (urls.some(unsafe)) return false\n", - " }\n", - " return true\n", - " }\n", - "\n", - " class MessageHandler {\n", - "\n", - " constructor() {\n", - " this.browserCache = new Map()\n", - " this.messageQueue = new Queue()\n", - " }\n", - "\n", - " on(msg) {\n", - " this.messageQueue.enqueue(msg)\n", - " this.processQueue()\n", - " }\n", - "\n", - " async processQueue() {\n", - "\n", - " const convertTrackData = (data) => {\n", - " convert(data)\n", - " convert(data, \"index\")\n", - " if (!data.indexURL) {\n", - " data.indexed = false\n", - " }\n", - " }\n", - "\n", - " if (!this.processing) {\n", - " this.processing = true\n", - " while (!this.messageQueue.isEmpty()) {\n", - " const msg = this.messageQueue.dequeue()\n", - " const command = msg.command\n", - " const browserID = msg.id\n", - " const data = msg.data\n", - " const browser = this.browserCache.get(browserID)\n", - " try {\n", - " switch (command) {\n", - " case \"createBrowser\":\n", - "\n", - " // custom button bar\n", - " const button_container = document.getElementById(`${browserID}_buttons`) // <= created from python\n", - " const customButtonDiv = document.createElement('div')\n", - " customButtonDiv.style = `background: #f3f3f3;padding: 5px;border-color: #bfbfbf;border-style: solid;border-width: thin;border-radius: 3px;`\n", - " button_container.appendChild(customButtonDiv)\n", - "\n", - " data.sync = true\n", - " convertUrlsAndPaths(data)\n", - "\n", - " const container = document.getElementById(`${browserID}_igvcontainer`) // <= created from python\n", - " const newBrowser = await igv.createBrowser(container, data)\n", - " this.browserCache.set(browserID, newBrowser)\n", - "\n", - " // Add igv-notebook button bar\n", - " const toJsonButton = document.createElement('button')\n", - " toJsonButton.innerText = \"Save Session\"\n", - " toJsonButton.style = \"margin-right:5px\"\n", - " toJsonButton.addEventListener('click', (evt) => {\n", - " let fn\n", - " if (isNotebook) {\n", - " fn = prompt(\"Filename:\", \"session.json\")\n", - " } else {\n", - " fn = \"session.json\"\n", - " }\n", - " if (fn) {\n", - " const json = newBrowser.toJSON()\n", - " const jsonString = JSON.stringify(json, null, '\\t')\n", - " download(fn, jsonString)\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(toJsonButton)\n", - "\n", - " const webLinkNode = document.createElement('a')\n", - " webLinkNode.target = \"igvWeb\"\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.style.display = \"none\"\n", - "\n", - " const shareButton = document.createElement('button')\n", - " shareButton.innerText = \"Show IGV-Web Link\"\n", - " shareButton.style = \"margin-right:5px\"\n", - " shareButton.addEventListener('click', async (evt) => {\n", - "\n", - " if (safeToWeblink(newBrowser.toJSON())) {\n", - " const sessionURL = `https://igv.org/app?sessionURL=blob:${newBrowser.compressedSession()}`\n", - " const shortURL = await shortenURL(sessionURL)\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.setAttribute(\"href\", shortURL)\n", - " webLinkNode.style.display = \"inline-block\"\n", - " shareButton.innerText = \"Update IGV-Web Link\"\n", - " } else {\n", - " webLinkNode.innerText = \"Cannot link -- non URL resources used\"\n", - " webLinkNode.style.display = \"inline-block\"\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(shareButton)\n", - " customButtonDiv.appendChild(webLinkNode)\n", - "\n", - " if (isNotebook) {\n", - " const toSVGButton = document.createElement('button')\n", - " toSVGButton.innerText = \"To SVG\"\n", - " toSVGButton.style = \"float:right\"\n", - " toSVGButton.addEventListener('click', (evt) => {\n", - " const locus = newBrowser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " const svg = newBrowser.toSVG()\n", - " toSVG(browserID, locus, svg)\n", - " })\n", - " customButtonDiv.appendChild(toSVGButton)\n", - " }\n", - "\n", - " break\n", - "\n", - " case \"loadSession\":\n", - " convertUrlsAndPaths(data)\n", - " browser.loadSessionObject(data)\n", - " break\n", - "\n", - " case \"loadTrack\":\n", - " convertTrackData(data)\n", - " await browser.loadTrack(data)\n", - " break\n", - "\n", - " case \"loadROI\":\n", - " if (Array.isArray(data)) {\n", - " data.map(convertTrackData)\n", - " } else {\n", - " convertTrackData(data)\n", - " }\n", - " await browser.loadROI(data)\n", - " break\n", - "\n", - " case \"clearROIs\":\n", - " await browser.clearROIs()\n", - " break\n", - "\n", - " case \"search\":\n", - " browser.search(data)\n", - " break\n", - "\n", - " case \"zoomIn\":\n", - " browser.zoomIn()\n", - " break\n", - "\n", - " case \"zoomOut\":\n", - " browser.zoomOut()\n", - " break\n", - "\n", - " case \"remove\":\n", - " this.browserCache.delete(browserID)\n", - " document.getElementById(browserID).parentNode.removeChild(container)\n", - " break\n", - "\n", - " case \"toSVG\":\n", - " const displayId = data\n", - " const svg = browser.toSVG()\n", - " const locus = browser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " toSVG(displayId, locus, svg)\n", - " break\n", - "\n", - " default:\n", - " console.error(\"Unrecognized method: \" + msg.command)\n", - " }\n", - " } catch (e) {\n", - " console.error(e)\n", - " }\n", - " }\n", - " this.processing = false\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Potentially convert a path to a local File-like object.\n", - " * @param path\n", - " * @returns {*}\n", - " */\n", - " function createNotebookFile(path) {\n", - " if (!path ||\n", - " path.startsWith(\"https://\") || path.startsWith(\"http://\") || path.startsWith(\"gs://\") || path.startsWith(\"data:\")) {\n", - " return path\n", - " } else {\n", - " // Try to create a notebook file. If no notebook file implementation is available for the kernel in\n", - " // use (e.g. Jupyter Lab) treat as a URL.\n", - " const nbFile = igv.createNotebookLocalFile({path})\n", - " if (nbFile != null) {\n", - " return nbFile\n", - " } else {\n", - " // Try to treat as relative URL. This may or may not work\n", - " return convertURL(path)\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Convert relative URLs to absolute. Primarily for Jupyter Lab, not generally needed for Jupyter Notebook\n", - " * @param url\n", - " * @returns {*}\n", - " */\n", - " function convertURL(url) {\n", - "\n", - " const pageURL = window.location.href\n", - "\n", - " if (!url ||\n", - " url.startsWith(\"https://\") ||\n", - " url.startsWith(\"http://\") ||\n", - " url.startsWith(\"gs://\") ||\n", - " url.startsWith(\"data:\")) {\n", - " return url\n", - " } else if (isColab) {\n", - " // Interpret relative url as a path.\n", - " igv.createNotebookLocalFile({path: url})\n", - " } else if (isNotebook) {\n", - " // Jupyter Notebook\n", - " //\n", - " // Examples\n", - " // https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/notebooks/examples/BamFiles-Jupyter.ipynb\n", - " // => https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/files/examples/data/gstt1_sample.bam\",\n", - "\n", - " const baseURL = document.querySelector('body').getAttribute('data-base-url')\n", - " const notebookPath = document.querySelector('body').getAttribute('data-notebook-path')\n", - " const notebookName = document.querySelector('body').getAttribute('data-notebook-name')\n", - " const notebookDir = notebookPath.slice(0, -1 * notebookName.length)\n", - "\n", - " //`${location.origin}${base_path}files/${nb_dir}${url}`\n", - " if (url.startsWith(\"/\")) {\n", - " url = `files${url}`\n", - " return encodeURI(`${location.origin}${baseURL}${url}`)\n", - " } else {\n", - " // URL is relative to notebook\n", - " return encodeURI(`${location.origin}${baseURL}files/${notebookDir}${url}`)\n", - " }\n", - " } else if (pageURL.includes(\"/lab\")) {\n", - "\n", - " console.log(\"Jupyter lab\")\n", - " // Jupyter Lab\n", - "\n", - " // Examples\n", - " // http://localhost:8888/lab/workspaces/auto-N/tree/examples/BamFiles.ipynb\n", - " // => http://localhost:8888/files/examples/data/gstt1_sample.bam\n", - " //\n", - " // https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/lab/tree/examples/BamFiles.ipynb\n", - " // => https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/files/examples/data/gstt1_sample.bam\n", - "\n", - " const baseIndex = pageURL.indexOf(\"/lab\")\n", - " const baseURL = pageURL.substring(0, baseIndex)\n", - "\n", - " if (url.startsWith(\"/\")) {\n", - " return encodeURI(`${baseURL}/files${url}`)\n", - " } else if (pageURL.includes(\"/tree/\")) {\n", - " // Interpret URL as relative to notebook location. This is not reliable, '/tree/' is not always in the page URL\n", - " const treeIndex = pageURL.indexOf(\"/tree/\") + 6\n", - " const lastSlashIndex = pageURL.lastIndexOf(\"/\")\n", - " const notebookDir = pageURL.substring(treeIndex, lastSlashIndex)\n", - " return encodeURI(`${baseURL}/files/${notebookDir}/${url}`)\n", - " } else {\n", - " // We don't know how to determine the notebook path\n", - " console.warn(\"Page url missing '/tree/'. Can't determine notebook path.\")\n", - " return encodeURI(`${baseURL}/files/${url}`)\n", - " }\n", - " } else {\n", - " // We should never get here,\n", - " return encodeURI(url)\n", - " }\n", - " }\n", - "\n", - "\n", - " function convert(config, prefix) {\n", - " const urlProp = prefix ? prefix + \"URL\" : \"url\"\n", - " const pathProp = prefix ? prefix + \"Path\" : \"path\"\n", - " if (config[pathProp]) {\n", - " config[urlProp] = createNotebookFile(config[pathProp])\n", - " } else if (config[urlProp]) {\n", - " config[urlProp] = convertURL(config[urlProp])\n", - " }\n", - " }\n", - "\n", - "\n", - " class Queue {\n", - " constructor() {\n", - " this.elements = []\n", - " }\n", - "\n", - " enqueue(e) {\n", - " this.elements.push(e)\n", - " }\n", - "\n", - " dequeue() {\n", - " return this.elements.shift()\n", - " }\n", - "\n", - " isEmpty() {\n", - " return this.elements.length == 0\n", - " }\n", - "\n", - " peek() {\n", - " return !this.isEmpty() ? this.elements[0] : undefined\n", - " }\n", - "\n", - " length() {\n", - " return this.elements.length\n", - " }\n", - " }\n", - "\n", - " window.igv.MessageHandler = new MessageHandler()\n", - "\n", - " function download(filename, text) {\n", - "\n", - " const data = URL.createObjectURL(new Blob([text], {type: \"application/octet-stream\"}))\n", - " const element = document.createElement('a')\n", - " element.setAttribute('href', data)\n", - " element.setAttribute('download', filename)\n", - " element.style.display = 'none'\n", - " document.body.appendChild(element)\n", - " element.click()\n", - " document.body.removeChild(element)\n", - " }\n", - "\n", - " async function shortenURL(url) {\n", - " const endpoint = \"https://2et6uxfezb.execute-api.us-east-1.amazonaws.com/dev/tinyurl/\"\n", - " const enc = encodeURIComponent(url)\n", - " const response = await fetch(`${endpoint}${enc}`)\n", - " if (response.ok) {\n", - " return response.text()\n", - " } else {\n", - " throw new Error(response.statusText)\n", - " }\n", - " }\n", - "\n", - " console.log(\"igv.MessageHandler installed\")\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Mock objects to emulate the browser \"File\" class for use with Jupyter and Colab notebooks. These objects delegate\n", - " * actual file reading to python.\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " igv.createNotebookLocalFile = function (options) {\n", - " if (isColab) {\n", - " return new ColabLocalFile(options)\n", - " } else if (isNotebook) {\n", - " return new JupyterLocalFile(options)\n", - " } else {\n", - " return undefined; //TODO -- throw error?\n", - " }\n", - " }\n", - "\n", - "\n", - " // Start up a Comm object if in a Jupyter Notebook environment (i.e. not Colab or JupyterLab).\n", - " let comm\n", - " const pendingRequests = new Map()\n", - " if (isNotebook) {\n", - " console.log('registering comm')\n", - " comm = Jupyter.notebook.kernel.comm_manager.new_comm('file_request', {})\n", - " // Register a handler\n", - " comm.on_msg(function (msg) {\n", - " const id = msg.content.data.id\n", - " const data = msg.content.data.data\n", - " pendingRequests.set(id, data)\n", - " })\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Jupyter notebooks. File reading is delegated to python via Comms messaging.\n", - " * Polling is used to synchronize the async message passing.\n", - " *\n", - " * NOTE: This will not work for JupyterLab\n", - " */\n", - " class JupyterLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'JupyterLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new JupyterLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as binary data.\n", - " *\n", - " * @returns {Promise<*>}\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const id = uniqueID()\n", - " const path = this.path\n", - " const promise = new Promise((resolve, reject) => {\n", - " let count = 0\n", - "\n", - " function poll() {\n", - "\n", - " if (count > 100) {\n", - " console.error(`error reading ${path}: timed out`)\n", - " reject(`error reading ${path}: timed out`)\n", - " }\n", - "\n", - " count++\n", - " if (pendingRequests.has(id)) {\n", - " const data = pendingRequests.get(id)\n", - " const dataString = atob(data)\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " pendingRequests.delete(id)\n", - " resolve(bytes.buffer)\n", - " } else {\n", - " setTimeout(poll, 100)\n", - " }\n", - " }\n", - "\n", - " poll()\n", - " })\n", - "\n", - " const msg = (this.start === undefined) ?\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer'} :\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer', 'start': this.start, 'end': this.end}\n", - "\n", - " comm.send(msg)\n", - "\n", - " return promise\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Colab environments.\n", - " */\n", - " class ColabLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'ColabLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new ColabLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as\n", - " * binary data.\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const args = (this.start === undefined) ?\n", - " [this.path] :\n", - " [this.path, this.start.toString(), this.end.toString()]\n", - "\n", - " const result = await google.colab.kernel.invokeFunction(\n", - " 'ReadFile', // The callback name.\n", - " args, // The arguments.\n", - " {}) // kwargs\n", - " const data = result.data[\"text/plain\"]\n", - " const dataString = atob(data.substring(2, data.length - 1))\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " return bytes.buffer\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " let counter = 0\n", - "\n", - " function uniqueID() {\n", - " return `${Math.random()}-${counter++}`\n", - " }\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "window.igv.MessageHandler.on({\"id\": \"jb_423544\", \"command\": \"createBrowser\", \"data\": {\"reference\": {\"id\": \"AgamP4\", \"name\": \"Anopheles gambiae (PEST)\", \"fastaURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa.fai\", \"tracks\": [{\"name\": \"Genes\", \"type\": \"annotation\", \"format\": \"gff3\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_BASEFEATURES_AgamP4.12.gff3.gz\", \"indexed\": false}]}, \"locus\": \"2L:2,422,600-2,422,700\", \"tracks\": [{\"name\": \"Filters - gamb_colu_arab\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu_arab/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu_arab/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"Filters - gamb_colu\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"Filters - arab\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/arab/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/arab/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"SNPs\", \"url\": \"https://vo_agam_output.cog.sanger.ac.uk/AR0002-C.vcf.gz\", \"indexURL\": \"https://vo_agam_output.cog.sanger.ac.uk/AR0002-C.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 50}, {\"name\": \"Alignments\", \"url\": \"https://vo_agam_output.cog.sanger.ac.uk/AR0002-C.bam\", \"indexURL\": \"https://vo_agam_output.cog.sanger.ac.uk/AR0002-C.bam.bai\", \"format\": \"bam\", \"type\": \"alignment\", \"visibilityWindow\": 20000, \"height\": 500}], \"id\": \"jb_423544\"}})" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "ag3.view_alignments(sample=\"AR0002-C\", region=\"2L:2,422,600-2,422,700\")" ] @@ -1893,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6ff2c51", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -1903,7 +54,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3e64cfeb", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -1912,728 +63,10 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "08571777", + "execution_count": null, + "id": "6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " \r" - ] - }, - { - "data": { - "application/javascript": [ - "window.igv=function(){\"use strict\";function e(e){return t(\"div\",e)}function t(e,t){const i=document.createElement(e);return t&&(t.class&&i.classList.add(t.class),t.id&&(i.id=t.id),t.style&&function(e,t){for(let i of Object.keys(t))e.style[i]=t[i]}(i,t.style)),i}function i(e){const t=getComputedStyle(e);\"none\"!==t.display&&(e._initialDisplay=t.display),e.style.display=\"none\"}function n(e){if(\"none\"===getComputedStyle(e).display){const t=e._initialDisplay||\"block\";e.style.display=t}}function r(e){if(e.type.startsWith(\"touch\")){const t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.pageX,y:e.pageY}}function s(){return(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}let o=(e,{clientX:t,clientY:i})=>{const{left:n,top:r,width:s,height:o}=e.getBoundingClientRect(),a=t-n,c=i-r;return{x:a,y:c,xNormalized:a/s,yNormalized:c/o,width:s,height:o}};function a(e,t){const{clientX:i,clientY:n}=e;return o(t,{clientX:i,clientY:n})}class c{constructor(){this.elem=t(\"div\",{class:\"igv-ui-panel-column\"})}add(t){if(t instanceof Node)this.elem.append(t);else if(\"object\"==typeof t)this.elem.append(t.elem);else{const i=e();i.innerHTML=t,this.elem.append(i),this.html=i}}}function l(e,t){return h(e,t)}function h(e,t){t=t||\"currentColor\";let i=d[e];i||(console.error(`No icon named: ${e}`),i=d.question);const n=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");n.setAttributeNS(null,\"viewBox\",\"0 0 \"+i[0]+\" \"+i[1]);const r=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");return r.setAttributeNS(null,\"fill\",t),r.setAttributeNS(null,\"d\",i[4]),n.appendChild(r),n}const d={check:[512,512,[],\"f00c\",\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"],cog:[512,512,[],\"f013\",\"M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z\"],exclamation:[192,512,[],\"f12a\",\"M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z\"],\"exclamation-circle\":[512,512,[],\"f06a\",\"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],\"exclamation-triangle\":[576,512,[],\"f071\",\"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],minus:[448,512,[],\"f068\",\"M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z\"],\"minus-circle\":[512,512,[],\"f056\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z\"],\"minus-square\":[448,512,[],\"f146\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z\"],plus:[448,512,[],\"f067\",\"M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z\"],\"plus-circle\":[512,512,[],\"f055\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],\"plus-square\":[448,512,[],\"f0fe\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],question:[384,512,[],\"f128\",\"M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z\"],save:[448,512,[],\"f0c7\",\"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z\"],search:[512,512,[],\"f002\",\"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z\"],share:[512,512,[],\"f064\",\"M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z\"],spinner:[512,512,[],\"f110\",\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"],square:[448,512,[],\"f0c8\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z\"],\"square-full\":[512,512,[],\"f45c\",\"M512 512H0V0h512v512z\"],times:[384,512,[],\"f00d\",\"M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z\"],\"times-circle\":[512,512,[],\"f057\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z\"],wrench:[512,512,[],\"f0ad\",\"M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z\"]};function u(e,t){var i=document.createElement(\"div\");e.appendChild(i),i.appendChild(l(\"times\")),i.addEventListener(\"click\",(function(e){e.preventDefault(),e.stopPropagation(),t()}))}let f;function p(e,t,i){t.addEventListener(\"mousedown\",function(e){e.stopPropagation(),e.preventDefault();const t=g.bind(this),n=m.bind(this),r=getComputedStyle(this),s=this.getBoundingClientRect();f={constraint:i,dragFunction:t,dragEndFunction:n,screenX:e.screenX,screenY:e.screenY,minDy:-s.top,minDx:-s.left,top:parseInt(r.top.replace(\"px\",\"\")),left:parseInt(r.left.replace(\"px\",\"\"))},document.addEventListener(\"mousemove\",t),document.addEventListener(\"mouseup\",n),document.addEventListener(\"mouseleave\",n),document.addEventListener(\"mouseexit\",n)}.bind(e))}function g(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=Math.max(f.minDx,e.screenX-f.screenX),i=Math.max(f.minDy,e.screenY-f.screenY),n=f.left+t,r=f.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function m(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=f.dragFunction,i=f.dragEndFunction;document.removeEventListener(\"mousemove\",t),document.removeEventListener(\"mouseup\",i),document.removeEventListener(\"mouseleave\",i),document.removeEventListener(\"mouseexit\",i),f=void 0}class w{constructor({parent:t,label:n,content:r,okHandler:s,cancelHandler:o}){this.parent=t;const a=()=>{i(this.elem),\"function\"==typeof o&&o(this)};this.elem=e(),this.elem.classList.add(\"igv-ui-generic-dialog-container\",\"igv-ui-center-fixed\");const c=e({class:\"igv-ui-generic-dialog-header\"});if(this.elem.appendChild(c),u(c,a),n){const t=e({class:\"igv-ui-dialog-one-liner\"});this.elem.appendChild(t),t.innerHTML=n}r.elem.style.margin=\"16px\",this.elem.appendChild(r.elem),this.content=r;const l=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.elem.appendChild(l),this.ok=e(),l.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),l.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",this.callback=void 0,this.ok.addEventListener(\"click\",(e=>{i(this.elem),\"function\"==typeof s?s(this):this.callback&&\"function\"==typeof this.callback&&this.callback(this)})),this.cancel.addEventListener(\"click\",a),p(this.elem,c),this.elem.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation()}))}present(e,t){if(e.label&&this.label&&(this.label.textContent=e.label),e.html){this.content.html.innerHTML=e.html}if(e.text){this.content.html.innerText=e.text}e.value&&this.input&&(this.input.value=e.value),e.callback&&(this.callback=e.callback),n(this.elem)}clampLocation(e,t){let i=this.elem.getBoundingClientRect(),n=this.parent.getBoundingClientRect();const r=Math.min(Math.max(t,n.y),n.y+n.height-i.height),s=Math.min(Math.max(e,n.x),n.x+n.width-i.width);this.elem.style.left=s+\"px\",this.elem.style.top=r+\"px\"}}\n", - "/*!\n", - " * jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\n", - " * https://jquery.com/\n", - " *\n", - " * Includes Sizzle.js\n", - " * https://sizzlejs.com/\n", - " *\n", - " * Copyright JS Foundation and other contributors\n", - " * Released under the MIT license\n", - " * https://jquery.org/license\n", - " *\n", - " * Date: 2018-01-20T17:24Z\n", - " */var b=[],F=window.document,v=Object.getPrototypeOf,y=b.slice,A=b.concat,C=b.push,_=b.indexOf,x={},k=x.toString,I=x.hasOwnProperty,S=I.toString,E=S.call(Object),N={},B=function(e){return\"function\"==typeof e&&\"number\"!=typeof e.nodeType},M=function(e){return null!=e&&e===e.window},R={type:!0,src:!0,noModule:!0};function D(e,t,i){var n,r=(t=t||F).createElement(\"script\");if(r.text=e,i)for(n in R)i[n]&&(r[n]=i[n]);t.head.appendChild(r).parentNode.removeChild(r)}function T(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?x[k.call(e)]||\"object\":typeof e}var L=\"3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\",z=function(e,t){return new z.fn.init(e,t)},H=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;function P(e){var t=!!e&&\"length\"in e&&e.length,i=T(e);return!B(e)&&!M(e)&&(\"array\"===i||0===t||\"number\"==typeof t&&t>0&&t-1 in e)}z.fn=z.prototype={jquery:L,constructor:z,length:0,toArray:function(){return y.call(this)},get:function(e){return null==e?y.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=z.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return z.each(this,e)},map:function(e){return this.pushStack(z.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(y.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i+~]|\"+L+\")\"+L+\"*\"),V=new RegExp(\"=\"+L+\"*([^\\\\]'\\\"]*?)\"+L+\"*\\\\]\",\"g\"),j=new RegExp(P),W=new RegExp(\"^\"+z+\"$\"),G={ID:new RegExp(\"^#(\"+z+\")\"),CLASS:new RegExp(\"^\\\\.(\"+z+\")\"),TAG:new RegExp(\"^(\"+z+\"|[*])\"),ATTR:new RegExp(\"^\"+H),PSEUDO:new RegExp(\"^\"+P),CHILD:new RegExp(\"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\"+L+\"*(even|odd|(([+-]|)(\\\\d*)n|)\"+L+\"*(?:([+-]|)\"+L+\"*(\\\\d+)|))\"+L+\"*\\\\)|)\",\"i\"),bool:new RegExp(\"^(?:\"+T+\")$\",\"i\"),needsContext:new RegExp(\"^\"+L+\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\"+L+\"*((?:-\\\\d)?\\\\d*)\"+L+\"*\\\\)|)(?=[^-]|$)\",\"i\")},$=/^(?:input|select|textarea|button)$/i,K=/^h\\d$/i,Y=/^[^{]+\\{\\s*\\[native \\w/,X=/^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,Z=/[+~]/,J=new RegExp(\"\\\\\\\\([\\\\da-f]{1,6}\"+L+\"?|(\"+L+\")|.)\",\"ig\"),ee=function(e,t,i){var n=\"0x\"+t-65536;return n!=n||i?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},te=/([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\0-\\x1f\\x7f-\\uFFFF\\w-]/g,ie=function(e,t){return t?\"\\0\"===e?\"�\":e.slice(0,-1)+\"\\\\\"+e.charCodeAt(e.length-1).toString(16)+\" \":\"\\\\\"+e},ne=function(){u()},re=we((function(e){return!0===e.disabled&&(\"form\"in e||\"label\"in e)}),{dir:\"parentNode\",next:\"legend\"});try{M.apply(E=R.call(y.childNodes),y.childNodes),E[y.childNodes.length].nodeType}catch(e){M={apply:E.length?function(e,t){B.apply(e,R.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function se(e,t,n,r){var s,a,l,h,d,p,w,b=t&&t.ownerDocument,A=t?t.nodeType:9;if(n=n||[],\"string\"!=typeof e||!e||1!==A&&9!==A&&11!==A)return n;if(!r&&((t?t.ownerDocument||t:y)!==f&&u(t),t=t||f,g)){if(11!==A&&(d=X.exec(e)))if(s=d[1]){if(9===A){if(!(l=t.getElementById(s)))return n;if(l.id===s)return n.push(l),n}else if(b&&(l=b.getElementById(s))&&F(t,l)&&l.id===s)return n.push(l),n}else{if(d[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=d[3])&&i.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(i.qsa&&!k[e+\" \"]&&(!m||!m.test(e))){if(1!==A)b=t,w=e;else if(\"object\"!==t.nodeName.toLowerCase()){for((h=t.getAttribute(\"id\"))?h=h.replace(te,ie):t.setAttribute(\"id\",h=v),a=(p=o(e)).length;a--;)p[a]=\"#\"+h+\" \"+me(p[a]);w=p.join(\",\"),b=Z.test(e)&&pe(t.parentNode)||t}if(w)try{return M.apply(n,b.querySelectorAll(w)),n}catch(e){}finally{h===v&&t.removeAttribute(\"id\")}}}return c(e.replace(U,\"$1\"),t,n,r)}function oe(){var e=[];return function t(i,r){return e.push(i+\" \")>n.cacheLength&&delete t[e.shift()],t[i+\" \"]=r}}function ae(e){return e[v]=!0,e}function ce(e){var t=f.createElement(\"fieldset\");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function he(e){return function(t){return\"input\"===t.nodeName.toLowerCase()&&t.type===e}}function de(e){return function(t){var i=t.nodeName.toLowerCase();return(\"input\"===i||\"button\"===i)&&t.type===e}}function ue(e){return function(t){return\"form\"in t?t.parentNode&&!1===t.disabled?\"label\"in t?\"label\"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:\"label\"in t&&t.disabled===e}}function fe(e){return ae((function(t){return t=+t,ae((function(i,n){for(var r,s=e([],i.length,t),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=se.support={},s=se.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&\"HTML\"!==t.nodeName},u=se.setDocument=function(e){var t,r,o=e?e.ownerDocument||e:y;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),y!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener(\"unload\",ne,!1):r.attachEvent&&r.attachEvent(\"onunload\",ne)),i.attributes=ce((function(e){return e.className=\"i\",!e.getAttribute(\"className\")})),i.getElementsByTagName=ce((function(e){return e.appendChild(f.createComment(\"\")),!e.getElementsByTagName(\"*\").length})),i.getElementsByClassName=Y.test(f.getElementsByClassName),i.getById=ce((function(e){return p.appendChild(e).id=v,!f.getElementsByName||!f.getElementsByName(v).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){return e.getAttribute(\"id\")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode(\"id\");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,r,s=t.getElementById(e);if(s){if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s];for(r=t.getElementsByName(e),n=0;s=r[n++];)if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],r=0,s=t.getElementsByTagName(e);if(\"*\"===e){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},w=[],m=[],(i.qsa=Y.test(f.querySelectorAll))&&(ce((function(e){p.appendChild(e).innerHTML=\"\",e.querySelectorAll(\"[msallowcapture^='']\").length&&m.push(\"[*^$]=\"+L+\"*(?:''|\\\"\\\")\"),e.querySelectorAll(\"[selected]\").length||m.push(\"\\\\[\"+L+\"*(?:value|\"+T+\")\"),e.querySelectorAll(\"[id~=\"+v+\"-]\").length||m.push(\"~=\"),e.querySelectorAll(\":checked\").length||m.push(\":checked\"),e.querySelectorAll(\"a#\"+v+\"+*\").length||m.push(\".#.+[+~]\")})),ce((function(e){e.innerHTML=\"\";var t=f.createElement(\"input\");t.setAttribute(\"type\",\"hidden\"),e.appendChild(t).setAttribute(\"name\",\"D\"),e.querySelectorAll(\"[name=d]\").length&&m.push(\"name\"+L+\"*[*^$|!~]?=\"),2!==e.querySelectorAll(\":enabled\").length&&m.push(\":enabled\",\":disabled\"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(\":disabled\").length&&m.push(\":enabled\",\":disabled\"),e.querySelectorAll(\"*,:x\"),m.push(\",.*:\")}))),(i.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ce((function(e){i.disconnectedMatch=b.call(e,\"*\"),b.call(e,\"[s!='']:x\"),w.push(\"!=\",P)})),m=m.length&&new RegExp(m.join(\"|\")),w=w.length&&new RegExp(w.join(\"|\")),t=Y.test(p.compareDocumentPosition),F=t||Y.test(p.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},I=t?function(e,t){if(e===t)return d=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e===f||e.ownerDocument===y&&F(y,e)?-1:t===f||t.ownerDocument===y&&F(y,t)?1:h?D(h,e)-D(h,t):0:4&n?-1:1)}:function(e,t){if(e===t)return d=!0,0;var i,n=0,r=e.parentNode,s=t.parentNode,o=[e],a=[t];if(!r||!s)return e===f?-1:t===f?1:r?-1:s?1:h?D(h,e)-D(h,t):0;if(r===s)return le(e,t);for(i=e;i=i.parentNode;)o.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?le(o[n],a[n]):o[n]===y?-1:a[n]===y?1:0},f):f},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&u(e),t=t.replace(V,\"='$1']\"),i.matchesSelector&&g&&!k[t+\" \"]&&(!w||!w.test(t))&&(!m||!m.test(t)))try{var n=b.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return se(t,f,null,[e]).length>0},se.contains=function(e,t){return(e.ownerDocument||e)!==f&&u(e),F(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!==f&&u(e);var r=n.attrHandle[t.toLowerCase()],s=r&&S.call(n.attrHandle,t.toLowerCase())?r(e,t,!g):void 0;return void 0!==s?s:i.attributes||!g?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},se.escape=function(e){return(e+\"\").replace(te,ie)},se.error=function(e){throw new Error(\"Syntax error, unrecognized expression: \"+e)},se.uniqueSort=function(e){var t,n=[],r=0,s=0;if(d=!i.detectDuplicates,h=!i.sortStable&&e.slice(0),e.sort(I),d){for(;t=e[s++];)t===e[s]&&(r=n.push(s));for(;r--;)e.splice(n[r],1)}return h=null,e},r=se.getText=function(e){var t,i=\"\",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if(\"string\"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=r(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n++];)i+=r(t);return i},n=se.selectors={cacheLength:50,createPseudo:ae,match:G,attrHandle:{},find:{},relative:{\">\":{dir:\"parentNode\",first:!0},\" \":{dir:\"parentNode\"},\"+\":{dir:\"previousSibling\",first:!0},\"~\":{dir:\"previousSibling\"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(J,ee),e[3]=(e[3]||e[4]||e[5]||\"\").replace(J,ee),\"~=\"===e[2]&&(e[3]=\" \"+e[3]+\" \"),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),\"nth\"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(\"even\"===e[3]||\"odd\"===e[3])),e[5]=+(e[7]+e[8]||\"odd\"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||\"\":i&&j.test(i)&&(t=o(i,!0))&&(t=i.indexOf(\")\",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(J,ee).toLowerCase();return\"*\"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=_[e+\" \"];return t||(t=new RegExp(\"(^|\"+L+\")\"+e+\"(\"+L+\"|$)\"))&&_(e,(function(e){return t.test(\"string\"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute(\"class\")||\"\")}))},ATTR:function(e,t,i){return function(n){var r=se.attr(n,e);return null==r?\"!=\"===t:!t||(r+=\"\",\"=\"===t?r===i:\"!=\"===t?r!==i:\"^=\"===t?i&&0===r.indexOf(i):\"*=\"===t?i&&r.indexOf(i)>-1:\"$=\"===t?i&&r.slice(-i.length)===i:\"~=\"===t?(\" \"+r.replace(O,\" \")+\" \").indexOf(i)>-1:\"|=\"===t&&(r===i||r.slice(0,i.length+1)===i+\"-\"))}},CHILD:function(e,t,i,n,r){var s=\"nth\"!==e.slice(0,3),o=\"last\"!==e.slice(-4),a=\"of-type\"===t;return 1===n&&0===r?function(e){return!!e.parentNode}:function(t,i,c){var l,h,d,u,f,p,g=s!==o?\"nextSibling\":\"previousSibling\",m=t.parentNode,w=a&&t.nodeName.toLowerCase(),b=!c&&!a,F=!1;if(m){if(s){for(;g;){for(u=t;u=u[g];)if(a?u.nodeName.toLowerCase()===w:1===u.nodeType)return!1;p=g=\"only\"===e&&!p&&\"nextSibling\"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&b){for(F=(f=(l=(h=(d=(u=m)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1])&&l[2],u=f&&m.childNodes[f];u=++f&&u&&u[g]||(F=f=0)||p.pop();)if(1===u.nodeType&&++F&&u===t){h[e]=[A,f,F];break}}else if(b&&(F=f=(l=(h=(d=(u=t)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1]),!1===F)for(;(u=++f&&u&&u[g]||(F=f=0)||p.pop())&&((a?u.nodeName.toLowerCase()!==w:1!==u.nodeType)||!++F||(b&&((h=(d=u[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]=[A,F]),u!==t)););return(F-=r)===n||F%n==0&&F/n>=0}}},PSEUDO:function(e,t){var i,r=n.pseudos[e]||n.setFilters[e.toLowerCase()]||se.error(\"unsupported pseudo: \"+e);return r[v]?r(t):r.length>1?(i=[e,e,\"\",t],n.setFilters.hasOwnProperty(e.toLowerCase())?ae((function(e,i){for(var n,s=r(e,t),o=s.length;o--;)e[n=D(e,s[o])]=!(i[n]=s[o])})):function(e){return r(e,0,i)}):r}},pseudos:{not:ae((function(e){var t=[],i=[],n=a(e.replace(U,\"$1\"));return n[v]?ae((function(e,t,i,r){for(var s,o=n(e,null,r,[]),a=e.length;a--;)(s=o[a])&&(e[a]=!(t[a]=s))})):function(e,r,s){return t[0]=e,n(t,null,s,i),t[0]=null,!i.pop()}})),has:ae((function(e){return function(t){return se(e,t).length>0}})),contains:ae((function(e){return e=e.replace(J,ee),function(t){return(t.textContent||t.innerText||r(t)).indexOf(e)>-1}})),lang:ae((function(e){return W.test(e||\"\")||se.error(\"unsupported lang: \"+e),e=e.replace(J,ee).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute(\"xml:lang\")||t.getAttribute(\"lang\"))return(i=i.toLowerCase())===e||0===i.indexOf(e+\"-\")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ue(!1),disabled:ue(!0),checked:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&!!e.checked||\"option\"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return $.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&\"button\"===e.type||\"button\"===t},text:function(e){var t;return\"input\"===e.nodeName.toLowerCase()&&\"text\"===e.type&&(null==(t=e.getAttribute(\"type\"))||\"text\"===t.toLowerCase())},first:fe((function(){return[0]})),last:fe((function(e,t){return[t-1]})),eq:fe((function(e,t,i){return[i<0?i+t:i]})),even:fe((function(e,t){for(var i=0;i=0;)e.push(n);return e})),gt:fe((function(e,t,i){for(var n=i<0?i+t:i;++n1?function(t,i,n){for(var r=e.length;r--;)if(!e[r](t,i,n))return!1;return!0}:e[0]}function Fe(e,t,i,n,r){for(var s,o=[],a=0,c=e.length,l=null!=t;a-1&&(s[l]=!(o[l]=d))}}else w=Fe(w===o?w.splice(p,w.length):w),r?r(null,o,w,c):M.apply(o,w)}))}function ye(e){for(var t,i,r,s=e.length,o=n.relative[e[0].type],a=o||n.relative[\" \"],c=o?1:0,h=we((function(e){return e===t}),a,!0),d=we((function(e){return D(t,e)>-1}),a,!0),u=[function(e,i,n){var r=!o&&(n||i!==l)||((t=i).nodeType?h(e,i,n):d(e,i,n));return t=null,r}];c1&&be(u),c>1&&me(e.slice(0,c-1).concat({value:\" \"===e[c-2].type?\"*\":\"\"})).replace(U,\"$1\"),i,c0,r=e.length>0,s=function(s,o,a,c,h){var d,p,m,w=0,b=\"0\",F=s&&[],v=[],y=l,C=s||r&&n.find.TAG(\"*\",h),_=A+=null==y?1:Math.random()||.1,x=C.length;for(h&&(l=o===f||o||h);b!==x&&null!=(d=C[b]);b++){if(r&&d){for(p=0,o||d.ownerDocument===f||(u(d),a=!g);m=e[p++];)if(m(d,o||f,a)){c.push(d);break}h&&(A=_)}i&&((d=!m&&d)&&w--,s&&F.push(d))}if(w+=b,i&&b!==w){for(p=0;m=t[p++];)m(F,v,o,a);if(s){if(w>0)for(;b--;)F[b]||v[b]||(v[b]=N.call(c));v=Fe(v)}M.apply(c,v),h&&!s&&v.length>0&&w+t.length>1&&se.uniqueSort(c)}return h&&(A=_,l=y),F};return i?ae(s):s}(s,r)),a.selector=e}return a},c=se.select=function(e,t,i,r){var s,c,l,h,d,u=\"function\"==typeof e&&e,f=!r&&o(e=u.selector||e);if(i=i||[],1===f.length){if((c=f[0]=f[0].slice(0)).length>2&&\"ID\"===(l=c[0]).type&&9===t.nodeType&&g&&n.relative[c[1].type]){if(!(t=(n.find.ID(l.matches[0].replace(J,ee),t)||[])[0]))return i;u&&(t=t.parentNode),e=e.slice(c.shift().value.length)}for(s=G.needsContext.test(e)?0:c.length;s--&&(l=c[s],!n.relative[h=l.type]);)if((d=n.find[h])&&(r=d(l.matches[0].replace(J,ee),Z.test(c[0].type)&&pe(t.parentNode)||t))){if(c.splice(s,1),!(e=r.length&&me(c)))return M.apply(i,r),i;break}}return(u||a(e,f))(r,t,!g,i,!t||Z.test(e)&&pe(t.parentNode)||t),i},i.sortStable=v.split(\"\").sort(I).join(\"\")===v,i.detectDuplicates=!!d,u(),se}(window);z.find=O,z.expr=O.selectors,z.expr[\":\"]=z.expr.pseudos,z.uniqueSort=z.unique=O.uniqueSort,z.text=O.getText,z.isXMLDoc=O.isXML,z.contains=O.contains,z.escapeSelector=O.escape;var U=function(e,t,i){for(var n=[],r=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&z(e).is(i))break;n.push(e)}return n},q=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},Q=z.expr.match.needsContext;function V(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var j=/^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i;function W(e,t,i){return B(t)?z.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?z.grep(e,(function(e){return e===t!==i})):\"string\"!=typeof t?z.grep(e,(function(e){return _.call(t,e)>-1!==i})):z.filter(t,e,i)}z.filter=function(e,t,i){var n=t[0];return i&&(e=\":not(\"+e+\")\"),1===t.length&&1===n.nodeType?z.find.matchesSelector(n,e)?[n]:[]:z.find.matches(e,z.grep(t,(function(e){return 1===e.nodeType})))},z.fn.extend({find:function(e){var t,i,n=this.length,r=this;if(\"string\"!=typeof e)return this.pushStack(z(e).filter((function(){for(t=0;t1?z.uniqueSort(i):i},filter:function(e){return this.pushStack(W(this,e||[],!1))},not:function(e){return this.pushStack(W(this,e||[],!0))},is:function(e){return!!W(this,\"string\"==typeof e&&Q.test(e)?z(e):e||[],!1).length}});var G,$=/^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/;(z.fn.init=function(e,t,i){var n,r;if(!e)return this;if(i=i||G,\"string\"==typeof e){if(!(n=\"<\"===e[0]&&\">\"===e[e.length-1]&&e.length>=3?[null,e,null]:$.exec(e))||!n[1]&&t)return!t||t.jquery?(t||i).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof z?t[0]:t,z.merge(this,z.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:F,!0)),j.test(n[1])&&z.isPlainObject(t))for(n in t)B(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return(r=F.getElementById(n[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):B(e)?void 0!==i.ready?i.ready(e):e(z):z.makeArray(e,this)}).prototype=z.fn,G=z(F);var K=/^(?:parents|prev(?:Until|All))/,Y={children:!0,contents:!0,next:!0,prev:!0};function X(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}z.fn.extend({has:function(e){var t=z(e,this),i=t.length;return this.filter((function(){for(var e=0;e-1:1===i.nodeType&&z.find.matchesSelector(i,e))){s.push(i);break}return this.pushStack(s.length>1?z.uniqueSort(s):s)},index:function(e){return e?\"string\"==typeof e?_.call(z(e),this[0]):_.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(z.uniqueSort(z.merge(this.get(),z(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),z.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return U(e,\"parentNode\")},parentsUntil:function(e,t,i){return U(e,\"parentNode\",i)},next:function(e){return X(e,\"nextSibling\")},prev:function(e){return X(e,\"previousSibling\")},nextAll:function(e){return U(e,\"nextSibling\")},prevAll:function(e){return U(e,\"previousSibling\")},nextUntil:function(e,t,i){return U(e,\"nextSibling\",i)},prevUntil:function(e,t,i){return U(e,\"previousSibling\",i)},siblings:function(e){return q((e.parentNode||{}).firstChild,e)},children:function(e){return q(e.firstChild)},contents:function(e){return V(e,\"iframe\")?e.contentDocument:(V(e,\"template\")&&(e=e.content||e),z.merge([],e.childNodes))}},(function(e,t){z.fn[e]=function(i,n){var r=z.map(this,t,i);return\"Until\"!==e.slice(-5)&&(n=i),n&&\"string\"==typeof n&&(r=z.filter(n,r)),this.length>1&&(Y[e]||z.uniqueSort(r),K.test(e)&&r.reverse()),this.pushStack(r)}}));var Z=/[^\\x20\\t\\r\\n\\f]+/g;function J(e){return e}function ee(e){throw e}function te(e,t,i,n){var r;try{e&&B(r=e.promise)?r.call(e).done(t).fail(i):e&&B(r=e.then)?r.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}z.Callbacks=function(e){e=\"string\"==typeof e?function(e){var t={};return z.each(e.match(Z)||[],(function(e,i){t[i]=!0})),t}(e):z.extend({},e);var t,i,n,r,s=[],o=[],a=-1,c=function(){for(r=r||e.once,n=t=!0;o.length;a=-1)for(i=o.shift();++a-1;)s.splice(i,1),i<=a&&a--})),this},has:function(e){return e?z.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i=\"\",this},disabled:function(){return!s},lock:function(){return r=o=[],i||t||(s=i=\"\"),this},locked:function(){return!!r},fireWith:function(e,i){return r||(i=[e,(i=i||[]).slice?i.slice():i],o.push(i),t||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!n}};return l},z.extend({Deferred:function(e){var t=[[\"notify\",\"progress\",z.Callbacks(\"memory\"),z.Callbacks(\"memory\"),2],[\"resolve\",\"done\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),0,\"resolved\"],[\"reject\",\"fail\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),1,\"rejected\"]],i=\"pending\",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return z.Deferred((function(i){z.each(t,(function(t,n){var s=B(e[n[4]])&&e[n[4]];r[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&B(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+\"With\"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,n){var r=0;function s(e,t,i,n){return function(){var o=this,a=arguments,c=function(){var c,l;if(!(e=r&&(i!==ee&&(o=void 0,a=[n]),t.rejectWith(o,a))}};e?l():(z.Deferred.getStackHook&&(l.stackTrace=z.Deferred.getStackHook()),window.setTimeout(l))}}return z.Deferred((function(r){t[0][3].add(s(0,r,B(n)?n:J,r.notifyWith)),t[1][3].add(s(0,r,B(e)?e:J)),t[2][3].add(s(0,r,B(i)?i:ee))})).promise()},promise:function(e){return null!=e?z.extend(e,n):n}},r={};return z.each(t,(function(e,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+\"With\"](this===r?void 0:this,arguments),this},r[s[0]+\"With\"]=o.fireWith})),n.promise(r),e&&e.call(r,r),r},when:function(e){var t=arguments.length,i=t,n=Array(i),r=y.call(arguments),s=z.Deferred(),o=function(e){return function(i){n[e]=this,r[e]=arguments.length>1?y.call(arguments):i,--t||s.resolveWith(n,r)}};if(t<=1&&(te(e,s.done(o(i)).resolve,s.reject,!t),\"pending\"===s.state()||B(r[i]&&r[i].then)))return s.then();for(;i--;)te(r[i],o(i),s.reject);return s.promise()}});var ie=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;z.Deferred.exceptionHook=function(e,t){window.console&&window.console.warn&&e&&ie.test(e.name)&&window.console.warn(\"jQuery.Deferred exception: \"+e.message,e.stack,t)},z.readyException=function(e){window.setTimeout((function(){throw e}))};var ne=z.Deferred();function re(){F.removeEventListener(\"DOMContentLoaded\",re),window.removeEventListener(\"load\",re),z.ready()}z.fn.ready=function(e){return ne.then(e).catch((function(e){z.readyException(e)})),this},z.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--z.readyWait:z.isReady)||(z.isReady=!0,!0!==e&&--z.readyWait>0||ne.resolveWith(F,[z]))}}),z.ready.then=ne.then,\"complete\"===F.readyState||\"loading\"!==F.readyState&&!F.documentElement.doScroll?window.setTimeout(z.ready):(F.addEventListener(\"DOMContentLoaded\",re),window.addEventListener(\"load\",re));var se=function(e,t,i,n,r,s,o){var a=0,c=e.length,l=null==i;if(\"object\"===T(i))for(a in r=!0,i)se(e,t,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,B(n)||(o=!0),l&&(o?(t.call(e,n),t=null):(l=t,t=function(e,t,i){return l.call(z(e),i)})),t))for(;a1,null,!0)},removeData:function(e){return this.each((function(){fe.remove(this,e)}))}}),z.extend({queue:function(e,t,i){var n;if(e)return t=(t||\"fx\")+\"queue\",n=ue.get(e,t),i&&(!n||Array.isArray(i)?n=ue.access(e,t,z.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||\"fx\";var i=z.queue(e,t),n=i.length,r=i.shift(),s=z._queueHooks(e,t);\"inprogress\"===r&&(r=i.shift(),n--),r&&(\"fx\"===t&&i.unshift(\"inprogress\"),delete s.stop,r.call(e,(function(){z.dequeue(e,t)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(e,t){var i=t+\"queueHooks\";return ue.get(e,i)||ue.access(e,i,{empty:z.Callbacks(\"once memory\").add((function(){ue.remove(e,[t+\"queue\",i])}))})}}),z.fn.extend({queue:function(e,t){var i=2;return\"string\"!=typeof e&&(t=e,e=\"fx\",i--),arguments.length\\x20\\t\\r\\n\\f]+)/i,Ie=/^$|^module$|\\/(?:java|ecma)script/i,Se={option:[1,\"\"],thead:[1,\"\",\"
\"],col:[2,\"\",\"
\"],tr:[2,\"\",\"
\"],td:[3,\"\",\"
\"],_default:[0,\"\",\"\"]};function Ee(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||\"*\"):void 0!==e.querySelectorAll?e.querySelectorAll(t||\"*\"):[],void 0===t||t&&V(e,t)?z.merge([e],i):i}function Ne(e,t){for(var i=0,n=e.length;i-1)r&&r.push(s);else if(l=z.contains(s.ownerDocument,s),o=Ee(d.appendChild(s),\"script\"),l&&Ne(o),i)for(h=0;s=o[h++];)Ie.test(s.type||\"\")&&i.push(s);return d}!function(){var e=F.createDocumentFragment().appendChild(F.createElement(\"div\")),t=F.createElement(\"input\");t.setAttribute(\"type\",\"radio\"),t.setAttribute(\"checked\",\"checked\"),t.setAttribute(\"name\",\"t\"),e.appendChild(t),N.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML=\"\",N.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var Re=F.documentElement,De=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Le=/^([^.]*)(?:\\.(.+)|)/;function ze(){return!0}function He(){return!1}function Pe(){try{return F.activeElement}catch(e){}}function Oe(e,t,i,n,r,s){var o,a;if(\"object\"==typeof t){for(a in\"string\"!=typeof i&&(n=n||i,i=void 0),t)Oe(e,a,i,n,t[a],s);return e}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&(\"string\"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=He;else if(!r)return e;return 1===s&&(o=r,r=function(e){return z().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=z.guid++)),e.each((function(){z.event.add(this,t,r,n,i)}))}z.event={global:{},add:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.get(e);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&z.find.matchesSelector(Re,r),i.guid||(i.guid=z.guid++),(c=m.events)||(c=m.events={}),(o=m.handle)||(o=m.handle=function(t){return void 0!==z&&z.event.triggered!==t.type?z.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f&&(d=z.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,d=z.event.special[f]||{},h=z.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&z.expr.match.needsContext.test(r),namespace:p.join(\".\")},s),(u=c[f])||((u=c[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,n,p,o)||e.addEventListener&&e.addEventListener(f,o)),d.add&&(d.add.call(e,h),h.handler.guid||(h.handler.guid=i.guid)),r?u.splice(u.delegateCount++,0,h):u.push(h),z.event.global[f]=!0)},remove:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.hasData(e)&&ue.get(e);if(m&&(c=m.events)){for(l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)if(f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f){for(d=z.event.special[f]||{},u=c[f=(n?d.delegateType:d.bindType)||f]||[],a=a[2]&&new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"),o=s=u.length;s--;)h=u[s],!r&&g!==h.origType||i&&i.guid!==h.guid||a&&!a.test(h.namespace)||n&&n!==h.selector&&(\"**\"!==n||!h.selector)||(u.splice(s,1),h.selector&&u.delegateCount--,d.remove&&d.remove.call(e,h));o&&!u.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||z.removeEvent(e,f,m.handle),delete c[f])}else for(f in c)z.event.remove(e,f+t[l],i,n,!0);z.isEmptyObject(c)&&ue.remove(e,\"handle events\")}},dispatch:function(e){var t,i,n,r,s,o,a=z.event.fix(e),c=new Array(arguments.length),l=(ue.get(this,\"events\")||{})[a.type]||[],h=z.event.special[a.type]||{};for(c[0]=a,t=1;t=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&(\"click\"!==e.type||!0!==l.disabled)){for(s=[],o={},i=0;i-1:z.find(r,this,null,[l]).length),o[r]&&s.push(n);s.length&&a.push({elem:l,handlers:s})}return l=this,c\\x20\\t\\r\\n\\f]*)[^>]*)\\/>/gi,qe=/\\s*$/g;function je(e,t){return V(e,\"table\")&&V(11!==t.nodeType?t:t.firstChild,\"tr\")&&z(e).children(\"tbody\")[0]||e}function We(e){return e.type=(null!==e.getAttribute(\"type\"))+\"/\"+e.type,e}function Ge(e){return\"true/\"===(e.type||\"\").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute(\"type\"),e}function $e(e,t){var i,n,r,s,o,a,c,l;if(1===t.nodeType){if(ue.hasData(e)&&(s=ue.access(e),o=ue.set(t,s),l=s.events))for(r in delete o.handle,o.events={},l)for(i=0,n=l[r].length;i1&&\"string\"==typeof f&&!N.checkClone&&Qe.test(f))return e.each((function(r){var s=e.eq(r);p&&(t[0]=f.call(this,r,s.html())),Ye(s,t,i,n)}));if(d&&(s=(r=Me(t,e[0].ownerDocument,!1,e,n)).firstChild,1===r.childNodes.length&&(r=s),s||n)){for(a=(o=z.map(Ee(r,\"script\"),We)).length;h\")},clone:function(e,t,i){var n,r,s,o,a=e.cloneNode(!0),c=z.contains(e.ownerDocument,e);if(!(N.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||z.isXMLDoc(e)))for(o=Ee(a),n=0,r=(s=Ee(e)).length;n0&&Ne(o,!c&&Ee(e,\"script\")),a},cleanData:function(e){for(var t,i,n,r=z.event.special,s=0;void 0!==(i=e[s]);s++)if(he(i)){if(t=i[ue.expando]){if(t.events)for(n in t.events)r[n]?z.event.remove(i,n):z.removeEvent(i,n,t.handle);i[ue.expando]=void 0}i[fe.expando]&&(i[fe.expando]=void 0)}}}),z.fn.extend({detach:function(e){return Xe(this,e,!0)},remove:function(e){return Xe(this,e)},text:function(e){return se(this,(function(e){return void 0===e?z.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ye(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)}))},prepend:function(){return Ye(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(z.cleanData(Ee(e,!1)),e.textContent=\"\");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return z.clone(this,e,t)}))},html:function(e){return se(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if(\"string\"==typeof e&&!qe.test(e)&&!Se[(ke.exec(e)||[\"\",\"\"])[1].toLowerCase()]){e=z.htmlPrefilter(e);try{for(;i=0&&(c+=Math.max(0,Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-s-c-a-.5))),c}function pt(e,t,i){var n=Je(e),r=tt(e,t,n),s=\"border-box\"===z.css(e,\"boxSizing\",!1,n),o=s;if(Ze.test(r)){if(!i)return r;r=\"auto\"}return o=o&&(N.boxSizingReliable()||r===e.style[t]),(\"auto\"===r||!parseFloat(r)&&\"inline\"===z.css(e,\"display\",!1,n))&&(r=e[\"offset\"+t[0].toUpperCase()+t.slice(1)],o=!0),(r=parseFloat(r)||0)+ft(e,t,i||(s?\"border\":\"content\"),o,n,r)+\"px\"}z.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=tt(e,\"opacity\");return\"\"===i?\"1\":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,s,o,a=le(t),c=ot.test(t),l=e.style;if(c||(t=dt(a)),o=z.cssHooks[t]||z.cssHooks[a],void 0===i)return o&&\"get\"in o&&void 0!==(r=o.get(e,!1,n))?r:l[t];\"string\"===(s=typeof i)&&(r=be.exec(i))&&r[1]&&(i=function(e,t,i,n){var r,s,o=20,a=n?function(){return n.cur()}:function(){return z.css(e,t,\"\")},c=a(),l=i&&i[3]||(z.cssNumber[t]?\"\":\"px\"),h=(z.cssNumber[t]||\"px\"!==l&&+c)&&be.exec(z.css(e,t));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;o--;)z.style(e,t,h+l),(1-s)*(1-(s=a()/c||.5))<=0&&(o=0),h/=s;h*=2,z.style(e,t,h+l),i=i||[]}return i&&(h=+h||+c||0,r=i[1]?h+(i[1]+1)*i[2]:+i[2],n&&(n.unit=l,n.start=h,n.end=r)),r}(e,t,r),s=\"number\"),null!=i&&i==i&&(\"number\"===s&&(i+=r&&r[3]||(z.cssNumber[a]?\"\":\"px\")),N.clearCloneStyle||\"\"!==i||0!==t.indexOf(\"background\")||(l[t]=\"inherit\"),o&&\"set\"in o&&void 0===(i=o.set(e,i,n))||(c?l.setProperty(t,i):l[t]=i))}},css:function(e,t,i,n){var r,s,o,a=le(t);return ot.test(t)||(t=dt(a)),(o=z.cssHooks[t]||z.cssHooks[a])&&\"get\"in o&&(r=o.get(e,!0,i)),void 0===r&&(r=tt(e,t,n)),\"normal\"===r&&t in ct&&(r=ct[t]),\"\"===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),z.each([\"height\",\"width\"],(function(e,t){z.cssHooks[t]={get:function(e,i,n){if(i)return!st.test(z.css(e,\"display\"))||e.getClientRects().length&&e.getBoundingClientRect().width?pt(e,t,n):ye(e,at,(function(){return pt(e,t,n)}))},set:function(e,i,n){var r,s=Je(e),o=\"border-box\"===z.css(e,\"boxSizing\",!1,s),a=n&&ft(e,t,n,o,s);return o&&N.scrollboxSize()===s.position&&(a-=Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-parseFloat(s[t])-ft(e,t,\"border\",!1,s)-.5)),a&&(r=be.exec(i))&&\"px\"!==(r[3]||\"px\")&&(e.style[t]=i,i=z.css(e,t)),ut(0,i,a)}}})),z.cssHooks.marginLeft=it(N.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(tt(e,\"marginLeft\"))||e.getBoundingClientRect().left-ye(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+\"px\"})),z.each({margin:\"\",padding:\"\",border:\"Width\"},(function(e,t){z.cssHooks[e+t]={expand:function(i){for(var n=0,r={},s=\"string\"==typeof i?i.split(\" \"):[i];n<4;n++)r[e+Fe[n]+t]=s[n]||s[n-2]||s[0];return r}},\"margin\"!==e&&(z.cssHooks[e+t].set=ut)})),z.fn.extend({css:function(e,t){return se(this,(function(e,t,i){var n,r,s={},o=0;if(Array.isArray(t)){for(n=Je(e),r=t.length;o1)}}),z.fn.delay=function(e,t){return e=z.fx&&z.fx.speeds[e]||e,t=t||\"fx\",this.queue(t,(function(t,i){var n=window.setTimeout(t,e);i.stop=function(){window.clearTimeout(n)}}))},nt=F.createElement(\"input\"),rt=F.createElement(\"select\").appendChild(F.createElement(\"option\")),nt.type=\"checkbox\",N.checkOn=\"\"!==nt.value,N.optSelected=rt.selected,(nt=F.createElement(\"input\")).value=\"t\",nt.type=\"radio\",N.radioValue=\"t\"===nt.value;var gt,mt=z.expr.attrHandle;z.fn.extend({attr:function(e,t){return se(this,z.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){z.removeAttr(this,e)}))}}),z.extend({attr:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===e.getAttribute?z.prop(e,t,i):(1===s&&z.isXMLDoc(e)||(r=z.attrHooks[t.toLowerCase()]||(z.expr.match.bool.test(t)?gt:void 0)),void 0!==i?null===i?void z.removeAttr(e,t):r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:(e.setAttribute(t,i+\"\"),i):r&&\"get\"in r&&null!==(n=r.get(e,t))?n:null==(n=z.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!N.radioValue&&\"radio\"===t&&V(e,\"input\")){var i=e.value;return e.setAttribute(\"type\",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,r=t&&t.match(Z);if(r&&1===e.nodeType)for(;i=r[n++];)e.removeAttribute(i)}}),gt={set:function(e,t,i){return!1===t?z.removeAttr(e,i):e.setAttribute(i,i),i}},z.each(z.expr.match.bool.source.match(/\\w+/g),(function(e,t){var i=mt[t]||z.find.attr;mt[t]=function(e,t,n){var r,s,o=t.toLowerCase();return n||(s=mt[o],mt[o]=r,r=null!=i(e,t,n)?o:null,mt[o]=s),r}}));var wt=/^(?:input|select|textarea|button)$/i,bt=/^(?:a|area)$/i;function Ft(e){return(e.match(Z)||[]).join(\" \")}function vt(e){return e.getAttribute&&e.getAttribute(\"class\")||\"\"}function yt(e){return Array.isArray(e)?e:\"string\"==typeof e&&e.match(Z)||[]}z.fn.extend({prop:function(e,t){return se(this,z.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[z.propFix[e]||e]}))}}),z.extend({prop:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&z.isXMLDoc(e)||(t=z.propFix[t]||t,r=z.propHooks[t]),void 0!==i?r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:e[t]=i:r&&\"get\"in r&&null!==(n=r.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=z.find.attr(e,\"tabindex\");return t?parseInt(t,10):wt.test(e.nodeName)||bt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:\"htmlFor\",class:\"className\"}}),N.optSelected||(z.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),z.each([\"tabIndex\",\"readOnly\",\"maxLength\",\"cellSpacing\",\"cellPadding\",\"rowSpan\",\"colSpan\",\"useMap\",\"frameBorder\",\"contentEditable\"],(function(){z.propFix[this.toLowerCase()]=this})),z.fn.extend({addClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).addClass(e.call(this,t,vt(this)))}));if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)n.indexOf(\" \"+s+\" \")<0&&(n+=s+\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},removeClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).removeClass(e.call(this,t,vt(this)))}));if(!arguments.length)return this.attr(\"class\",\"\");if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)for(;n.indexOf(\" \"+s+\" \")>-1;)n=n.replace(\" \"+s+\" \",\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},toggleClass:function(e,t){var i=typeof e,n=\"string\"===i||Array.isArray(e);return\"boolean\"==typeof t&&n?t?this.addClass(e):this.removeClass(e):B(e)?this.each((function(i){z(this).toggleClass(e.call(this,i,vt(this),t),t)})):this.each((function(){var t,r,s,o;if(n)for(r=0,s=z(this),o=yt(e);t=o[r++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&\"boolean\"!==i||((t=vt(this))&&ue.set(this,\"__className__\",t),this.setAttribute&&this.setAttribute(\"class\",t||!1===e?\"\":ue.get(this,\"__className__\")||\"\"))}))},hasClass:function(e){var t,i,n=0;for(t=\" \"+e+\" \";i=this[n++];)if(1===i.nodeType&&(\" \"+Ft(vt(i))+\" \").indexOf(t)>-1)return!0;return!1}});var At=/\\r/g;z.fn.extend({val:function(e){var t,i,n,r=this[0];return arguments.length?(n=B(e),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?e.call(this,i,z(this).val()):e)?r=\"\":\"number\"==typeof r?r+=\"\":Array.isArray(r)&&(r=z.map(r,(function(e){return null==e?\"\":e+\"\"}))),(t=z.valHooks[this.type]||z.valHooks[this.nodeName.toLowerCase()])&&\"set\"in t&&void 0!==t.set(this,r,\"value\")||(this.value=r))}))):r?(t=z.valHooks[r.type]||z.valHooks[r.nodeName.toLowerCase()])&&\"get\"in t&&void 0!==(i=t.get(r,\"value\"))?i:\"string\"==typeof(i=r.value)?i.replace(At,\"\"):null==i?\"\":i:void 0}}),z.extend({valHooks:{option:{get:function(e){var t=z.find.attr(e,\"value\");return null!=t?t:Ft(z.text(e))}},select:{get:function(e){var t,i,n,r=e.options,s=e.selectedIndex,o=\"select-one\"===e.type,a=o?null:[],c=o?s+1:r.length;for(n=s<0?c:o?s:0;n-1)&&(i=!0);return i||(e.selectedIndex=-1),s}}}}),z.each([\"radio\",\"checkbox\"],(function(){z.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=z.inArray(z(e).val(),t)>-1}},N.checkOn||(z.valHooks[this].get=function(e){return null===e.getAttribute(\"value\")?\"on\":e.value})})),N.focusin=\"onfocusin\"in window;var Ct=/^(?:focusinfocus|focusoutblur)$/,_t=function(e){e.stopPropagation()};z.extend(z.event,{trigger:function(e,t,i,n){var r,s,o,a,c,l,h,d,u=[i||F],f=I.call(e,\"type\")?e.type:e,p=I.call(e,\"namespace\")?e.namespace.split(\".\"):[];if(s=d=o=i=i||F,3!==i.nodeType&&8!==i.nodeType&&!Ct.test(f+z.event.triggered)&&(f.indexOf(\".\")>-1&&(p=f.split(\".\"),f=p.shift(),p.sort()),c=f.indexOf(\":\")<0&&\"on\"+f,(e=e[z.expando]?e:new z.Event(f,\"object\"==typeof e&&e)).isTrigger=n?2:3,e.namespace=p.join(\".\"),e.rnamespace=e.namespace?new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:z.makeArray(t,[e]),h=z.event.special[f]||{},n||!h.trigger||!1!==h.trigger.apply(i,t))){if(!n&&!h.noBubble&&!M(i)){for(a=h.delegateType||f,Ct.test(a+f)||(s=s.parentNode);s;s=s.parentNode)u.push(s),o=s;o===(i.ownerDocument||F)&&u.push(o.defaultView||o.parentWindow||window)}for(r=0;(s=u[r++])&&!e.isPropagationStopped();)d=s,e.type=r>1?a:h.bindType||f,(l=(ue.get(s,\"events\")||{})[e.type]&&ue.get(s,\"handle\"))&&l.apply(s,t),(l=c&&s[c])&&l.apply&&he(s)&&(e.result=l.apply(s,t),!1===e.result&&e.preventDefault());return e.type=f,n||e.isDefaultPrevented()||h._default&&!1!==h._default.apply(u.pop(),t)||!he(i)||c&&B(i[f])&&!M(i)&&((o=i[c])&&(i[c]=null),z.event.triggered=f,e.isPropagationStopped()&&d.addEventListener(f,_t),i[f](),e.isPropagationStopped()&&d.removeEventListener(f,_t),z.event.triggered=void 0,o&&(i[c]=o)),e.result}},simulate:function(e,t,i){var n=z.extend(new z.Event,i,{type:e,isSimulated:!0});z.event.trigger(n,null,t)}}),z.fn.extend({trigger:function(e,t){return this.each((function(){z.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return z.event.trigger(e,t,i,!0)}}),N.focusin||z.each({focus:\"focusin\",blur:\"focusout\"},(function(e,t){var i=function(e){z.event.simulate(t,e.target,z.event.fix(e))};z.event.special[t]={setup:function(){var n=this.ownerDocument||this,r=ue.access(n,t);r||n.addEventListener(e,i,!0),ue.access(n,t,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=ue.access(n,t)-1;r?ue.access(n,t,r):(n.removeEventListener(e,i,!0),ue.remove(n,t))}}}));var xt,kt=/\\[\\]$/,It=/\\r?\\n/g,St=/^(?:submit|button|image|reset|file)$/i,Et=/^(?:input|select|textarea|keygen)/i;function Nt(e,t,i,n){var r;if(Array.isArray(t))z.each(t,(function(t,r){i||kt.test(e)?n(e,r):Nt(e+\"[\"+(\"object\"==typeof r&&null!=r?t:\"\")+\"]\",r,i,n)}));else if(i||\"object\"!==T(t))n(e,t);else for(r in t)Nt(e+\"[\"+r+\"]\",t[r],i,n)}z.param=function(e,t){var i,n=[],r=function(e,t){var i=B(t)?t():t;n[n.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(null==i?\"\":i)};if(Array.isArray(e)||e.jquery&&!z.isPlainObject(e))z.each(e,(function(){r(this.name,this.value)}));else for(i in e)Nt(i,e[i],t,r);return n.join(\"&\")},z.fn.extend({serialize:function(){return z.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=z.prop(this,\"elements\");return e?z.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!z(this).is(\":disabled\")&&Et.test(this.nodeName)&&!St.test(e)&&(this.checked||!xe.test(e))})).map((function(e,t){var i=z(this).val();return null==i?null:Array.isArray(i)?z.map(i,(function(e){return{name:t.name,value:e.replace(It,\"\\r\\n\")}})):{name:t.name,value:i.replace(It,\"\\r\\n\")}})).get()}}),z.fn.extend({wrapAll:function(e){var t;return this[0]&&(B(e)&&(e=e.call(this[0])),t=z(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return B(e)?this.each((function(t){z(this).wrapInner(e.call(this,t))})):this.each((function(){var t=z(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=B(e);return this.each((function(i){z(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not(\"body\").each((function(){z(this).replaceWith(this.childNodes)})),this}}),z.expr.pseudos.hidden=function(e){return!z.expr.pseudos.visible(e)},z.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},N.createHTMLDocument=((xt=F.implementation.createHTMLDocument(\"\").body).innerHTML=\"
\",2===xt.childNodes.length),z.parseHTML=function(e,t,i){return\"string\"!=typeof e?[]:(\"boolean\"==typeof t&&(i=t,t=!1),t||(N.createHTMLDocument?((n=(t=F.implementation.createHTMLDocument(\"\")).createElement(\"base\")).href=F.location.href,t.head.appendChild(n)):t=F),s=!i&&[],(r=j.exec(e))?[t.createElement(r[1])]:(r=Me([e],t,s),s&&s.length&&z(s).remove(),z.merge([],r.childNodes)));var n,r,s},z.offset={setOffset:function(e,t,i){var n,r,s,o,a,c,l=z.css(e,\"position\"),h=z(e),d={};\"static\"===l&&(e.style.position=\"relative\"),a=h.offset(),s=z.css(e,\"top\"),c=z.css(e,\"left\"),(\"absolute\"===l||\"fixed\"===l)&&(s+c).indexOf(\"auto\")>-1?(o=(n=h.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(c)||0),B(t)&&(t=t.call(e,i,z.extend({},a))),null!=t.top&&(d.top=t.top-a.top+o),null!=t.left&&(d.left=t.left-a.left+r),\"using\"in t?t.using.call(e,d):h.css(d)}},z.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){z.offset.setOffset(this,e,t)}));var t,i,n=this[0];return n?n.getClientRects().length?(t=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,i,n=this[0],r={top:0,left:0};if(\"fixed\"===z.css(n,\"position\"))t=n.getBoundingClientRect();else{for(t=this.offset(),i=n.ownerDocument,e=n.offsetParent||i.documentElement;e&&(e===i.body||e===i.documentElement)&&\"static\"===z.css(e,\"position\");)e=e.parentNode;e&&e!==n&&1===e.nodeType&&((r=z(e).offset()).top+=z.css(e,\"borderTopWidth\",!0),r.left+=z.css(e,\"borderLeftWidth\",!0))}return{top:t.top-r.top-z.css(n,\"marginTop\",!0),left:t.left-r.left-z.css(n,\"marginLeft\",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&\"static\"===z.css(e,\"position\");)e=e.offsetParent;return e||Re}))}}),z.each({scrollLeft:\"pageXOffset\",scrollTop:\"pageYOffset\"},(function(e,t){var i=\"pageYOffset\"===t;z.fn[e]=function(n){return se(this,(function(e,n,r){var s;if(M(e)?s=e:9===e.nodeType&&(s=e.defaultView),void 0===r)return s?s[t]:e[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):e[n]=r}),e,n,arguments.length)}})),z.each([\"top\",\"left\"],(function(e,t){z.cssHooks[t]=it(N.pixelPosition,(function(e,i){if(i)return i=tt(e,t),Ze.test(i)?z(e).position()[t]+\"px\":i}))})),z.each({Height:\"height\",Width:\"width\"},(function(e,t){z.each({padding:\"inner\"+e,content:t,\"\":\"outer\"+e},(function(i,n){z.fn[n]=function(r,s){var o=arguments.length&&(i||\"boolean\"!=typeof r),a=i||(!0===r||!0===s?\"margin\":\"border\");return se(this,(function(t,i,r){var s;return M(t)?0===n.indexOf(\"outer\")?t[\"inner\"+e]:t.document.documentElement[\"client\"+e]:9===t.nodeType?(s=t.documentElement,Math.max(t.body[\"scroll\"+e],s[\"scroll\"+e],t.body[\"offset\"+e],s[\"offset\"+e],s[\"client\"+e])):void 0===r?z.css(t,i,a):z.style(t,i,r,a)}),t,o?r:void 0,o)}}))})),z.each(\"blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu\".split(\" \"),(function(e,t){z.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)}})),z.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),z.fn.extend({bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,\"**\"):this.off(t,e||\"**\",i)}}),z.proxy=function(e,t){var i,n,r;if(\"string\"==typeof t&&(i=e[t],t=e,e=i),B(e))return n=y.call(arguments,2),r=function(){return e.apply(t||this,n.concat(y.call(arguments)))},r.guid=e.guid=e.guid||z.guid++,r},z.holdReady=function(e){e?z.readyWait++:z.ready(!0)},z.isArray=Array.isArray,z.parseJSON=JSON.parse,z.nodeName=V,z.isFunction=B,z.isWindow=M,z.camelCase=le,z.type=T,z.now=Date.now,z.isNumeric=function(e){var t=z.type(e);return(\"number\"===t||\"string\"===t)&&!isNaN(e-parseFloat(e))};const Bt=z;function Mt(e){return\"string\"==typeof e||e instanceof String}function Rt(e){var t=String(e).split(/[.,]/);return t[0].split(\"\").reverse().reduce((function(e,t,i){return i%3==0?e+\",\"+t:e+t})).split(\"\").reverse().join(\"\")+(t[1]?\".\"+t[1]:\"\")}const Dt=function(e){return e.split(/\\n|\\r\\n|\\r/g)};function Tt(e,t){var i,n,r=[],s=e.length,o=0,a=!1;if(s>0)for(r[o]=e.charAt(0),i=1;i0?e.charAt(0).toUpperCase()+e.slice(1):e}function zt(e){if(void 0!==e.name)return e.name;if(Mt(e)){let t=e.lastIndexOf(\"/\"),i=t<0?e:e.substr(t+1);return t=i.indexOf(\"?\"),t>0&&(i=i.substr(0,t)),i}throw Error(\"Expected File or string, got \"+typeof e)}function Ht(e){return!!e&&(\"function\"!=typeof e&&(e instanceof File||e.hasOwnProperty(\"name\")&&\"function\"==typeof e.slice&&\"function\"==typeof e.arrayBuffer))}function Pt(e,t){const i=document.createElement(\"a\");i.setAttribute(\"href\",t),i.setAttribute(\"download\",e),i.style.display=\"none\",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Ot(e){for(var t=Ut,i=t.parser.loose.exec(e),n={},r=14;r--;)n[t.key[r]]=i[r]||\"\";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,i,r){i&&(n[t.q.name][i]=r)})),n}\"object\"==typeof process&&\"undefined\"==typeof window&&(global.atob=function(e){return Buffer.from(e,\"base64\").toString(\"binary\")});const Ut={strictMode:!1,key:[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"],q:{name:\"queryKey\",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/}};function qt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Qt=256,Vt=286,jt=30,Wt=15,Gt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),$t=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Yt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xt=new Array(576);qt(Xt);const Zt=new Array(60);qt(Zt);const Jt=new Array(512);qt(Jt);const ei=new Array(256);qt(ei);const ti=new Array(29);qt(ti);const ii=new Array(jt);function ni(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let ri,si,oi;function ai(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}qt(ii);const ci=e=>e<256?Jt[e]:Jt[256+(e>>>7)],li=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},hi=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{hi(e,i[2*t],i[2*t+1])},ui=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},fi=(e,t,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=Wt;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ui(n[t]++,t))}},pi=e=>{let t;for(t=0;t{e.bi_valid>8?li(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},mi=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let n,r,s,o,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?di(e,r,t):(s=ei[r],di(e,s+Qt+1,t),o=Gt[s],0!==o&&(r-=ti[s],hi(e,r,o)),n--,s=ci(n),di(e,s,i),o=$t[s],0!==o&&(n-=ii[s],hi(e,n,o)))}while(a{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)wi(e,i,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wi(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*c]=i[2*o]+i[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=c,e.heap[1]=c++,wi(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let l,h,d,u,f,p,g=0;for(u=0;u<=Wt;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)h=e.heap[l],u=i[2*i[2*h+1]+1]+1,u>c&&(u=c,g++),i[2*h+1]=u,h>n||(e.bl_count[u]++,f=0,h>=a&&(f=o[h-a]),p=i[2*h],e.opt_len+=p*(u+f),s&&(e.static_len+=p*(r[2*h+1]+f)));if(0!==g){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(u=c;0!==u;u--)for(h=e.bl_count[u];0!==h;)d=e.heap[--l],d>n||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),h--)}})(e,t),fi(i,l,e.bl_count)},vi=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a{hi(e,0+(n?1:0),3),gi(e),li(e,i),li(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var _i=e=>{Ai||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(ti[n]=i,e=0;e<1<>=7;n{let r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(vi(e,e.dyn_ltree,e.l_desc.max_code),vi(e,e.dyn_dtree,e.d_desc.max_code),Fi(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Yt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Ci(e,t,i,n):4===e.strategy||s===r?(hi(e,2+(n?1:0),3),bi(e,Xt,Zt)):(hi(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(hi(e,t-257,5),hi(e,i-1,5),hi(e,n-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ei[i]+Qt+1)]++,e.dyn_dtree[2*ci(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{hi(e,2,3),di(e,256,Xt),(e=>{16===e.bi_valid?(li(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ii=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Si=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ei=(e,t,i,n)=>{const r=Si,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Ni={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},Bi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mi,_tr_stored_block:Ri,_tr_flush_block:Di,_tr_tally:Ti,_tr_align:Li}=ki,{Z_NO_FLUSH:zi,Z_PARTIAL_FLUSH:Hi,Z_FULL_FLUSH:Pi,Z_FINISH:Oi,Z_BLOCK:Ui,Z_OK:qi,Z_STREAM_END:Qi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:ji,Z_BUF_ERROR:Wi,Z_DEFAULT_COMPRESSION:Gi,Z_FILTERED:$i,Z_HUFFMAN_ONLY:Ki,Z_RLE:Yi,Z_FIXED:Xi,Z_DEFAULT_STRATEGY:Zi,Z_UNKNOWN:Ji,Z_DEFLATED:en}=Bi,tn=258,nn=262,rn=42,sn=113,on=666,an=(e,t)=>(e.msg=Ni[t],t),cn=e=>2*e-(e>4?9:0),ln=e=>{let t=e.length;for(;--t>=0;)e[t]=0},hn=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let dn=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},fn=(e,t)=>{Di(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,un(e.strm)},pn=(e,t)=>{e.pending_buf[e.pending++]=t},gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},mn=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=Ii(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Ei(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},wn=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-nn?e.strstart-(e.w_size-nn):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+tn;let f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,l[i+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},bn=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nn)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),hn(e),n+=t),0===e.strm.avail_in)break;if(i=mn(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=dn(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=dn(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,n,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,un(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(mn(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(mn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=s||(n||t===Oi)&&t!==zi&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=t===Oi&&0===e.strm.avail_in&&i===n?1:0,Ri(e,e.block_start,i,o),e.block_start+=i,un(e.strm)),o?3:1)},vn=(e,t)=>{let i,n;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nn&&(e.match_length=wn(e,i)),e.match_length>=3)if(n=Ti(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=dn(e,e.ins_h,e.window[e.strstart+1]);else n=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let i,n,r;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=Ti(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Ti(e,0,e.window[e.strstart-1]),n&&fn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ti(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2};function An(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const Cn=[new An(0,0,0,0,Fn),new An(4,4,8,4,vn),new An(4,5,16,8,vn),new An(4,6,32,32,vn),new An(4,4,16,16,yn),new An(8,16,32,32,yn),new An(8,16,128,128,yn),new An(8,32,128,256,yn),new An(32,128,258,1024,yn),new An(32,258,258,4096,yn)];function _n(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ln(this.dyn_ltree),ln(this.dyn_dtree),ln(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ln(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ln(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const xn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==sn&&t.status!==on?1:0},kn=e=>{if(xn(e))return an(e,Vi);e.total_in=e.total_out=0,e.data_type=Ji;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?rn:sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mi(t),qi},In=e=>{const t=kn(e);var i;return t===qi&&((i=e.state).window_size=2*i.w_size,ln(i.head),i.max_lazy_match=Cn[i.level].max_lazy,i.good_match=Cn[i.level].good_length,i.nice_match=Cn[i.level].nice_length,i.max_chain_length=Cn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Sn=(e,t,i,n,r,s)=>{if(!e)return Vi;let o=1;if(t===Gi&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==en||n<8||n>15||t<0||t>9||s<0||s>Xi||8===n&&1!==o)return an(e,Vi);8===n&&(n=9);const a=new _n;return e.state=a,a.strm=e,a.status=rn,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<{let i=t.length;if(xn(e))return Vi;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==rn||n.lookahead)return Vi;if(1===r&&(e.adler=Ii(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(ln(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,bn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=dn(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,bn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,n.wrap=r,qi},Nn={deflateInit:(e,t)=>Sn(e,t,en,15,8,Zi),deflateInit2:Sn,deflateReset:In,deflateResetKeep:kn,deflateSetHeader:(e,t)=>xn(e)||2!==e.state.wrap?Vi:(e.state.gzhead=t,qi),deflate:(e,t)=>{if(xn(e)||t>Ui||t<0)return e?an(e,Vi):Vi;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===on&&t!==Oi)return an(e,0===e.avail_out?Wi:Vi);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(un(e),0===e.avail_out)return i.last_flush=-1,qi}else if(0===e.avail_in&&cn(t)<=cn(n)&&t!==Oi)return an(e,Wi);if(i.status===on&&0!==e.avail_in)return an(e,Wi);if(i.status===rn&&0===i.wrap&&(i.status=sn),i.status===rn){let t=en+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=Ki||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,gn(i,t),0!==i.strstart&&(gn(i,e.adler>>>16),gn(i,65535&e.adler)),e.adler=1,i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(57===i.status)if(e.adler=0,pn(i,31),pn(i,139),pn(i,8),i.gzhead)pn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),pn(i,255&i.gzhead.time),pn(i,i.gzhead.time>>8&255),pn(i,i.gzhead.time>>16&255),pn(i,i.gzhead.time>>24&255),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(pn(i,255&i.gzhead.extra.length),pn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ei(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,3),i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,un(e),0!==i.pending)return i.last_flush=-1,qi;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(un(e),0!==i.pending))return i.last_flush=-1,qi;pn(i,255&e.adler),pn(i,e.adler>>8&255),e.adler=0}if(i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(0!==e.avail_in||0!==i.lookahead||t!==zi&&i.status!==on){let n=0===i.level?Fn(i,t):i.strategy===Ki?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(bn(e),0===e.lookahead)){if(t===zi)return 1;break}if(e.match_length=0,i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Yi?((e,t)=>{let i,n,r,s;const o=e.window;for(;;){if(e.lookahead<=tn){if(bn(e),e.lookahead<=tn&&t===zi)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=e.strstart+tn;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ti(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):Cn[i.level].func(i,t);if(3!==n&&4!==n||(i.status=on),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),qi;if(2===n&&(t===Hi?Li(i):t!==Ui&&(Ri(i,0,0,!1),t===Pi&&(ln(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),un(e),0===e.avail_out))return i.last_flush=-1,qi}return t!==Oi?qi:i.wrap<=0?Qi:(2===i.wrap?(pn(i,255&e.adler),pn(i,e.adler>>8&255),pn(i,e.adler>>16&255),pn(i,e.adler>>24&255),pn(i,255&e.total_in),pn(i,e.total_in>>8&255),pn(i,e.total_in>>16&255),pn(i,e.total_in>>24&255)):(gn(i,e.adler>>>16),gn(i,65535&e.adler)),un(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?qi:Qi)},deflateEnd:e=>{if(xn(e))return Vi;const t=e.state.status;return e.state=null,t===sn?an(e,ji):qi},deflateSetDictionary:En,deflateInfo:\"pako deflate (from Nodeca project)\"};const Bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Bn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:CA>=248?5:CA>=240?4:CA>=224?3:CA>=192?2:1;Dn[254]=Dn[254]=1;var Tn={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Rn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Dn[e[i]]>t?i:t}};var Ln=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0};const zn=Object.prototype.toString,{Z_NO_FLUSH:Hn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:On,Z_FINISH:Un,Z_OK:qn,Z_STREAM_END:Qn,Z_DEFAULT_COMPRESSION:Vn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Wn}=Bi;function Gn(e){this.options=Mn.assign({level:Vn,method:Wn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Nn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==qn)throw new Error(Ni[i]);if(t.header&&Nn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=\"string\"==typeof t.dictionary?Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===zn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Nn.deflateSetDictionary(this.strm,e),i!==qn)throw new Error(Ni[i]);this._dict_set=!0}}function $n(e,t){const i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Ni[i.err];return i.result}Gn.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Un:Hn,\"string\"==typeof e?i.input=Tn.string2buf(e):\"[object ArrayBuffer]\"===zn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Pn||s===On)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Nn.deflate(i,s),r===Qn)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Nn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===qn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn=function(e,t){return(t=t||{}).raw=!0,$n(e,t)},Yn=function(e,t){return(t=t||{}).gzip=!0,$n(e,t)},Xn={Deflate:Gn,deflate:$n,deflateRaw:Kn,gzip:Yn,constants:Bi};const Zn=16209;var Jn=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=16191;break e}e.msg=\"invalid literal/length code\",k.mode=Zn;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=Zn;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null;const k=new Uint16Array(16),I=new Uint16Array(16);let S,E,N,B=null;for(g=0;g<=er;g++)k[g]=0;for(m=0;m=1&&0===k[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(I[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){S=g-y,o[m]+1=p?(E=B[o[m]-p],N=x[o[m]-p]):(E=96,N=0),l=1<>y)+h]=S<<24|E<<16|N}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--k[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0};const{Z_FINISH:or,Z_BLOCK:ar,Z_TREES:cr,Z_OK:lr,Z_STREAM_END:hr,Z_NEED_DICT:dr,Z_STREAM_ERROR:ur,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr,Z_BUF_ERROR:gr,Z_DEFLATED:mr}=Bi,wr=16180,br=16190,Fr=16191,vr=16192,yr=16194,Ar=16199,Cr=16200,_r=16206,xr=16209,kr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ir(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Sr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Er=e=>{if(Sr(e))return ur;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=wr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,lr},Nr=e=>{if(Sr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Er(e)},Br=(e,t)=>{let i;if(Sr(e))return ur;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Nr(e))},Mr=(e,t)=>{if(!e)return ur;const i=new Ir;e.state=i,i.strm=e,i.window=null,i.mode=wr;const n=Br(e,t);return n!==lr&&(e.state=null),n};let Rr,Dr,Tr=!0;const Lr=e=>{if(Tr){Rr=new Int32Array(512),Dr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(sr(1,e.lens,0,288,Rr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sr(2,e.lens,0,32,Dr,0,e.work,{bits:5}),Tr=!1}e.lencode=Rr,e.lenbits=9,e.distcode=Dr,e.distbits=5},zr=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Sr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;i=e.state,i.mode===Fr&&(i.mode=vr),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=lr;e:for(;;)switch(i.mode){case wr:if(0===i.wrap){i.mode=vr;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0),l=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=xr;break}if((15&l)!==mr){e.msg=\"unknown compression method\",i.mode=xr;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits&&(i.wbits=A),A>15||A>i.wbits){e.msg=\"invalid window size\",i.mode=xr;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Ei(i.check,x,4,0)),l=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&4&i.wrap&&(i.check=Ei(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Fr;break;case 16189:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=_r;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=16193;break;case 1:if(Lr(i),i.mode=Ar,t===cr){l>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg=\"invalid block type\",i.mode=xr}l>>>=2,h-=2;break;case 16193:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=xr;break}if(i.length=65535&l,l=0,h=0,i.mode=yr,t===cr)break e;case yr:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Fr;break;case 16196:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=xr;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=sr(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=xr;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=xr;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=xr;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===xr)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=xr;break}if(i.lenbits=9,k={bits:i.lenbits},C=sr(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=xr;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=sr(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=xr;break}if(i.mode=Ar,t===cr)break e;case Ar:i.mode=Cr;case Cr:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Jn(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Fr&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=Fr;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=xr;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=xr;break}i.offset=b,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=xr;break}i.mode=16204;case 16204:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=xr;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=Cr);break;case 16205:if(0===c)break e;r[o++]=i.length,c--,i.mode=Cr;break;case _r:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<Mr(e,15),inflateInit2:Mr,inflate:Hr,inflateEnd:e=>{if(Sr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,lr},inflateGetHeader:(e,t)=>{if(Sr(e))return ur;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,lr):ur},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return Sr(e)?ur:(n=e.state,0!==n.wrap&&n.mode!==br?ur:n.mode===br&&(r=1,r=Ii(r,t,i,0),r!==n.check)?fr:(s=zr(e,t,i,i),s?(n.mode=16210,pr):(n.havedict=1,lr)))},inflateInfo:\"pako inflate (from Nodeca project)\"};var Or=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1};const Ur=Object.prototype.toString,{Z_NO_FLUSH:qr,Z_FINISH:Qr,Z_OK:Vr,Z_STREAM_END:jr,Z_NEED_DICT:Wr,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:$r,Z_MEM_ERROR:Kr}=Bi;function Yr(e){this.options=Mn.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Pr.inflateInit2(this.strm,t.windowBits);if(i!==Vr)throw new Error(Ni[i]);if(this.header=new Or,Pr.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Ur.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Pr.inflateSetDictionary(this.strm,t.dictionary),i!==Vr)))throw new Error(Ni[i])}function Xr(e,t){const i=new Yr(t);if(i.push(e),i.err)throw i.msg||Ni[i.err];return i.result}Yr.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Qr:qr,\"[object ArrayBuffer]\"===Ur.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Pr.inflate(i,o),s===Wr&&r&&(s=Pr.inflateSetDictionary(i,r),s===Vr?s=Pr.inflate(i,o):s===$r&&(s=Wr));i.avail_in>0&&s===jr&&i.state.wrap>0&&0!==e[i.next_in];)Pr.inflateReset(i),s=Pr.inflate(i,o);switch(s){case Gr:case $r:case Wr:case Kr:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===jr))if(\"string\"===this.options.to){let e=Tn.utf8border(i.output,i.next_out),t=i.next_out-e,r=Tn.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Vr||0!==a){if(s===jr)return s=Pr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Yr.prototype.onData=function(e){this.chunks.push(e)},Yr.prototype.onEnd=function(e){e===Vr&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zr=function(e,t){return(t=t||{}).raw=!0,Xr(e,t)},Jr={Inflate:Yr,inflate:Xr,inflateRaw:Zr,ungzip:Xr,constants:Bi};const{Deflate:es,deflate:ts,deflateRaw:is,gzip:ns}=Xn,{Inflate:rs,inflate:ss,inflateRaw:os,ungzip:as}=Jr;var cs=is,ls=ss,hs=os,ds=as;const us=4;function fs(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 31===t[0]&&139===t[1]}function ps(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 0!==(t[3]&us)&&66===t[12]&&67===t[13]?gs(t.buffer):ds(t)}function gs(e,t){const i=[];let n=0,r=0;for(t=t||e.byteLength-18;n100?Fs(new Uint8Array(e.buffer,e.byteOffset+t,r),i,n):function(e,t,i,n,r){for(let s=0;s=0){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t0?ds(e):e,i}return decodeURIComponent(r)}const ys={lerp:(e,t,i)=>(1-i)*e+i*t,mean:function(e){var t,i=0,n=0;for(t=0;t0?i/n:0},meanAndStdev:function(e){var t,i,n=0,r=0,s=0;for(i=0;i0?{mean:n/s,stdev:Math.sqrt(r-n*n/s)}:{mean:0,stdev:0}},median:function(e){var t=e.length;return e.sort(),t%2==0?(e[t/2-1]+e[t/2])/2:e[(t-1)/2]},percentile:function(e,t){if(0!==e.length){var i=Math.floor(e.length*((100-t)/100));return 0===i?(e.sort((function(e,t){return t-e})),e[i]):function(e,t){var i,n=new As;for(i=0;in.content[0])&&(n.content.length===t&&n.pop(),n.push(r))}return n.content[0]}(e,i)}},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},log2:function(e){return Math.log(e)/Math.LN2}};function As(){this.content=[]}function Cs(e,t){return Math.random()*(t-e)+e}As.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},remove:function(e){for(var t=this.content.length,i=0;i0;){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=t,this.content[e]=r,e=n}},sinkDown:function(e){for(var t=this.content.length,i=this.content[e],n=i;;){var r=2*(e+1),s=r-1,o=null;if(s{let e=[];for(let t=1;t>=.5;t-=.1)for(let i=0;i<1;i+=1/28){const n=\"rgb(\"+_s.hsvToRgb(i,1,t).join(\",\")+\")\";e.push(n)}return e.pop(),e.push(_s.rgbColor(16,16,16)),e},rgbToHex:function(e){return(e=e.match(/^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i))&&4===e.length?\"#\"+(\"0\"+parseInt(e[1],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[2],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[3],10).toString(16)).slice(-2):\"\"},hexToRgb:function(e){var t=/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(e);if(null!==t)return\"rgb(\"+parseInt(t[1],16)+\",\"+parseInt(t[2],16)+\",\"+parseInt(t[3],16)+\")\"},hsvToRgb:function(e,t,i){var n,r,s,o=Math.floor(6*e),a=6*e-o,c=i*(1-t),l=i*(1-a*t),h=i*(1-(1-a)*t);switch(o%6){case 0:n=i,r=h,s=c;break;case 1:n=l,r=i,s=c;break;case 2:n=c,r=i,s=h;break;case 3:n=c,r=l,s=i;break;case 4:n=h,r=c,s=i;break;case 5:n=i,r=c,s=l}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(e,t,i){var n,r,s;if(0===t)n=r=s=i;else{var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=_s.hue2rgb(a,o,e+1/3),r=_s.hue2rgb(a,o,e),s=_s.hue2rgb(a,o,e-1/3)}return[255*n,255*r,255*s]},hue2rgb:(e,t,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e),rgbaColor:function(e,t,i,n){return\"rgba(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\",\"+(n=ys.clamp(n,0,1))+\")\"},rgbColor:function(e,t,i){return\"rgb(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\")\"},greyScale:function(e){var t=ys.clamp(e,0,255);return\"rgb(\"+t+\",\"+t+\",\"+t+\")\"},randomGrey:function(e,t){e=ys.clamp(e,0,255),t=ys.clamp(t,0,255);var i=Math.round(Cs(e,t)).toString(10);return\"rgb(\"+i+\",\"+i+\",\"+i+\")\"},randomRGB:function(e,t){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgb(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\")\"},randomRGBConstantAlpha:function(e,t,i){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgba(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+i+\")\"},addAlpha:function(e,t){if(\"0\"===e||\".\"===e)e=\"rgb(0,0,0)\";else{const t=this.colorNameToHex(e);t&&(e=t)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);if(e.startsWith(\"rgba\")){const i=e.lastIndexOf(\",\");return e.substring(0,i+1)+t.toString()+\")\"}return i&&(e=_s.hexToRgb(e)),e.startsWith(\"rgb\")?e.replace(\"rgb\",\"rgba\").replace(\")\",\", \"+t+\")\"):(console.log(e+\" is not an rgb style string\"),e)},rgbComponents:function(e){if(\"0\"===e||\".\"===e)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e))e=_s.hexToRgb(e);else if(!e.startsWith(\"rgb\")){const t=this.colorNameToHex(e);e=this.hexToRgb(t)}if(e.startsWith(\"rgb(\"))return e.substring(4,e.length-1).split(\",\").map((e=>Number.parseInt(e.trim())));if(e.startsWith(\"rgba(\"))return e.substring(5,e.length-1).split(\",\").map(((e,t)=>(e=e.trim(),3===t?Number.parseFloat(e):Number.parseInt(e))));throw Error(\"Unrecognized color string: color\")},getCompositeColor:function(e,t,i){return\"rgb(\"+Math.floor(i*t[0]+(1-i)*e[0])+\",\"+Math.floor(i*t[1]+(1-i)*e[1])+\",\"+Math.floor(i*t[2]+(1-i)*e[2])+\")\"},createColorString:function(e){const t=this.createColorStringSafe(e);return t||e},createColorStringSafe:function(e){if((e=function(e){return void 0===e||((e.startsWith(\"'\")||e.startsWith('\"'))&&(e=e.substring(1)),(e.endsWith(\"'\")||e.endsWith('\"'))&&(e=e.substring(0,e.length-1))),e}(e)).startsWith(\"rgb(\")&&e.endsWith(\")\"))return e;if(e.startsWith(\"#\")&&e.length<8)return e;const t=this.colorNameToHex(e);if(t)return t;const i=e.split(\",\");return 3===i.length&&xs(i[0])&&xs(i[1])&&xs(i[2])?`rgb(${e})`:void 0},darkenLighten:function(e,t){let i,n=this.colorNameToHex(e);i=n?_s.hexToRgb(n):e.startsWith(\"rgb(\")?e:_s.hexToRgb(e);const r=i.replace(\")\",\"\").substring(4).split(\",\"),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+t)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+t)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+t));return\"rgb(\"+s.toString()+\",\"+o.toString()+\",\"+a.toString()+\")\"},colorNameToHex:function(e){return{aliceblue:\"#f0f8ff\",antiquewhite:\"#faebd7\",aqua:\"#00ffff\",aquamarine:\"#7fffd4\",azure:\"#f0ffff\",beige:\"#f5f5dc\",bisque:\"#ffe4c4\",black:\"#000000\",blanchedalmond:\"#ffebcd\",blue:\"#0000ff\",blueviolet:\"#8a2be2\",brown:\"#a52a2a\",burlywood:\"#deb887\",cadetblue:\"#5f9ea0\",chartreuse:\"#7fff00\",chocolate:\"#d2691e\",coral:\"#ff7f50\",cornflowerblue:\"#6495ed\",cornsilk:\"#fff8dc\",crimson:\"#dc143c\",cyan:\"#00ffff\",darkblue:\"#00008b\",darkcyan:\"#008b8b\",darkgoldenrod:\"#b8860b\",darkgray:\"#a9a9a9\",darkgreen:\"#006400\",darkkhaki:\"#bdb76b\",darkmagenta:\"#8b008b\",darkolivegreen:\"#556b2f\",darkorange:\"#ff8c00\",darkorchid:\"#9932cc\",darkred:\"#8b0000\",darksalmon:\"#e9967a\",darkseagreen:\"#8fbc8f\",darkslateblue:\"#483d8b\",darkslategray:\"#2f4f4f\",darkturquoise:\"#00ced1\",darkviolet:\"#9400d3\",deeppink:\"#ff1493\",deepskyblue:\"#00bfff\",dimgray:\"#696969\",dodgerblue:\"#1e90ff\",firebrick:\"#b22222\",floralwhite:\"#fffaf0\",forestgreen:\"#228b22\",fuchsia:\"#ff00ff\",gainsboro:\"#dcdcdc\",ghostwhite:\"#f8f8ff\",gold:\"#ffd700\",goldenrod:\"#daa520\",gray:\"#808080\",green:\"#008000\",greenyellow:\"#adff2f\",honeydew:\"#f0fff0\",hotpink:\"#ff69b4\",\"indianred \":\"#cd5c5c\",\"indigo \":\"#4b0082\",ivory:\"#fffff0\",khaki:\"#f0e68c\",lavender:\"#e6e6fa\",lavenderblush:\"#fff0f5\",lawngreen:\"#7cfc00\",lemonchiffon:\"#fffacd\",lightblue:\"#add8e6\",lightcoral:\"#f08080\",lightcyan:\"#e0ffff\",lightgoldenrodyellow:\"#fafad2\",lightgrey:\"#d3d3d3\",lightgreen:\"#90ee90\",lightpink:\"#ffb6c1\",lightsalmon:\"#ffa07a\",lightseagreen:\"#20b2aa\",lightskyblue:\"#87cefa\",lightslategray:\"#778899\",lightsteelblue:\"#b0c4de\",lightyellow:\"#ffffe0\",lime:\"#00ff00\",limegreen:\"#32cd32\",linen:\"#faf0e6\",magenta:\"#ff00ff\",maroon:\"#800000\",mediumaquamarine:\"#66cdaa\",mediumblue:\"#0000cd\",mediumorchid:\"#ba55d3\",mediumpurple:\"#9370d8\",mediumseagreen:\"#3cb371\",mediumslateblue:\"#7b68ee\",mediumspringgreen:\"#00fa9a\",mediumturquoise:\"#48d1cc\",mediumvioletred:\"#c71585\",midnightblue:\"#191970\",mintcream:\"#f5fffa\",mistyrose:\"#ffe4e1\",moccasin:\"#ffe4b5\",navajowhite:\"#ffdead\",navy:\"#000080\",oldlace:\"#fdf5e6\",olive:\"#808000\",olivedrab:\"#6b8e23\",orange:\"#ffa500\",orangered:\"#ff4500\",orchid:\"#da70d6\",palegoldenrod:\"#eee8aa\",palegreen:\"#98fb98\",paleturquoise:\"#afeeee\",palevioletred:\"#d87093\",papayawhip:\"#ffefd5\",peachpuff:\"#ffdab9\",peru:\"#cd853f\",pink:\"#ffc0cb\",plum:\"#dda0dd\",powderblue:\"#b0e0e6\",purple:\"#800080\",red:\"#ff0000\",rosybrown:\"#bc8f8f\",royalblue:\"#4169e1\",saddlebrown:\"#8b4513\",salmon:\"#fa8072\",sandybrown:\"#f4a460\",seagreen:\"#2e8b57\",seashell:\"#fff5ee\",sienna:\"#a0522d\",silver:\"#c0c0c0\",skyblue:\"#87ceeb\",slateblue:\"#6a5acd\",slategray:\"#708090\",snow:\"#fffafa\",springgreen:\"#00ff7f\",steelblue:\"#4682b4\",tan:\"#d2b48c\",teal:\"#008080\",thistle:\"#d8bfd8\",tomato:\"#ff6347\",turquoise:\"#40e0d0\",violet:\"#ee82ee\",wheat:\"#f5deb3\",white:\"#ffffff\",whitesmoke:\"#f5f5f5\",yellow:\"#ffff00\",yellowgreen:\"#9acd32\",darkgrey:\"#a9a9a9\",darkslategrey:\"#2f4f4f\",dimgrey:\"#696969\",grey:\"#808080\",lightgray:\"#d3d3d3\",lightslategrey:\"#778899\",slategrey:\"#708090\"}[e]}};function xs(e){const t=Number.parseInt(e);return!Number.isNaN(t)&&t>=0&&t<=255}const ks=\"googleapis\";class Is{constructor(){this.oauthTokens={}}setToken(e,t){t=t||ks,this.oauthTokens[t]=e}getToken(e){let t;e=e||ks;for(let i of Object.keys(this.oauthTokens)){if(Ss(i).test(e)){t=this.oauthTokens[i];break}}return t}removeToken(e){e=e||ks;for(let t of Object.keys(this.oauthTokens)){Ss(t).test(e)&&(this.oauthTokens[t]=void 0)}}}function Ss(e){return new RegExp(\"^\"+e.split(/\\*+/).map(Es).join(\".*\")+\"$\")}function Es(e){return e.replace(/[|\\\\{}()[\\]^$+*?.]/g,\"\\\\$&\")}function Ns(e){return e.includes(\"googleapis\")&&!e.includes(\"urlshortener\")||Bs(e)||Ms(e)}function Bs(e){return e.startsWith(\"gs://\")||e.startsWith(\"https://www.googleapis.com/storage\")||e.startsWith(\"https://storage.cloud.google.com\")||e.startsWith(\"https://storage.googleapis.com\")}function Ms(e){return e.indexOf(\"drive.google.com\")>=0||e.indexOf(\"www.googleapis.com/drive\")>0}function Rs(e){let{bucket:t,object:i}=function(e){let t,i;if(e.startsWith(\"gs://\")){const n=e.indexOf(\"/\",5);if(n>=0){t=e.substring(5,n);const r=e.indexOf(\"?\");i=r<0?e.substring(n+1):e.substring(n+1,r)}}else if(e.startsWith(\"https://storage.googleapis.com\")||e.startsWith(\"https://storage.cloud.google.com\")){const n=e.indexOf(\"/v1/b/\",8);if(n>0){const r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}else{const n=e.indexOf(\"/\",8),r=e.indexOf(\"/\",n+1),s=e.indexOf(\"?\",r);r>0&&(t=e.substring(n+1,r),i=s<0?e.substring(r+1):e.substring(r+1,s))}}else if(e.startsWith(\"https://www.googleapis.com/storage/v1/b\")){const n=e.indexOf(\"/v1/b/\",8),r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}if(t&&i)return{bucket:t,object:i};throw Error(`Unrecognized Google Storage URI: ${e}`)}(e);i=function(e){let t=\"\";return e.split(\"\").forEach((function(e){Ds.has(e)?t+=Ds.get(e):t+=e})),t}(i);const n=e.indexOf(\"?\");return`https://storage.googleapis.com/storage/v1/b/${t}/o/${i}${n>0?e.substring(n)+\"&alt=media\":\"?alt=media\"}`}const Ds=new Map;function Ts(){return window.google&&window.google.igv}async function Ls(e){if(!Ts())throw Error(\"Google oAuth has not been initialized\");if(google.igv.tokenResponse&&Date.now(){try{t.callback=e=>{void 0!==e.error&&n(e),google.igv.tokenResponse=e,google.igv.tokenExpiresAt=Date.now()+1e3*e.expires_in,i(e.access_token)},t.requestAccessToken({scope:e})}catch(e){console.log(e)}}))}}function zs(){return google.igv.apiKey}function Hs(e){var t=Ps(e);return t?\"https://www.googleapis.com/drive/v3/files/\"+t+\"?alt=media&supportsTeamDrives=true\":e}function Ps(e){if(e.includes(\"/open?id=\")){const t=e.indexOf(\"/open?id=\")+9,i=e.indexOf(\"&\");if(t>0&&i>t)return e.substring(t,i);if(t>0)return e.substring(t)}else{if(e.includes(\"/file/d/\")){const t=e.indexOf(\"/file/d/\")+8,i=e.lastIndexOf(\"/\");return e.substring(t,i)}if(e.startsWith(\"https://www.googleapis.com/drive\")){let t=e.indexOf(\"/files/\");const i=e.indexOf(\"?\");if(t>0)return t+=7,i>0?e.substring(t,i):e.substring(t)}}throw Error(\"Unknown Google Drive url format: \"+e)}Ds.set(\"!\",\"%21\"),Ds.set(\"#\",\"%23\"),Ds.set(\"$\",\"%24\"),Ds.set(\"%\",\"%25\"),Ds.set(\"&\",\"%26\"),Ds.set(\"'\",\"%27\"),Ds.set(\"(\",\"%28\"),Ds.set(\")\",\"%29\"),Ds.set(\"*\",\"%2A\"),Ds.set(\"+\",\"%2B\"),Ds.set(\",\",\"%2C\"),Ds.set(\"/\",\"%2F\"),Ds.set(\":\",\"%3A\"),Ds.set(\";\",\"%3B\"),Ds.set(\"=\",\"%3D\"),Ds.set(\"?\",\"%3F\"),Ds.set(\"@\",\"%40\"),Ds.set(\"[\",\"%5B\"),Ds.set(\"]\",\"%5D\"),Ds.set(\" \",\"%20\");class Os{constructor(e){this.requestsPerSecond=e.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(e,t){var i=this;return new Promise((function(t,n){i.queued.push({resolve:t,reject:n,asyncFunction:e}),i.dequeue()}))}addAll(e,t){var i=e.map(function(e){return this.add(e,t)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var e=new Date,t=1e3/this.requestsPerSecond+1,i=e-this.lastStartTime;i>=t?this._execute():setTimeout(function(){this.dequeue()}.bind(this),t-i)}}async _execute(){this.lastStartTime=new Date;var e=this.queued.shift();const t=e.asyncFunction;try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}}}function Us(){if(Ts()){return Ts()&&google.igv.tokenResponse&&Date.now()0)for(var o=0;othis._loadURL(e,t))):this._loadURL(e,t)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async _loadURL(e,t){const i=this,n=e;e=function(e){return e.startsWith(\"https://www.dropbox.com\")?e.replace(\"//www.dropbox.com\",\"//dl.dropboxusercontent.com\"):e.startsWith(\"https://drive.google.com\")?Hs(e):e.includes(\"//www.broadinstitute.org/igvdata\")?e.replace(\"//www.broadinstitute.org/igvdata\",\"//data.broadinstitute.org/igvdata\"):e.includes(\"//igvdata.broadinstitute.org\")?e.replace(\"//igvdata.broadinstitute.org\",\"//s3.amazonaws.com/igv.broadinstitute.org\"):e.includes(\"//igv.genepattern.org\")?e.replace(\"//igv.genepattern.org\",\"//igv-genepattern-org.s3.amazonaws.com\"):e.startsWith(\"ftp://ftp.ncbi.nlm.nih.gov/geo\")?e.replace(\"ftp://\",\"https://\"):e}(e);let r=(t=t||{}).oauthToken||this.getOauthToken(e);return r&&(r=await(\"function\"==typeof r?r():r)),new Promise((function(s,o){Ns(e)&&!function(e){return e.indexOf(\"X-Goog-Signature\")>-1}(e)&&(Bs(e)&&(e=Rs(e)),Ms(e=function(e){let t=Qs.apiKey;t||\"undefined\"==typeof gapi||(t=gapi.apiKey);if(void 0!==t&&!e.includes(\"key=\")){const i=e.includes(\"?\")?\"&\":\"?\";e=e+i+\"key=\"+t}return e}(e))&&function(e){if(e.includes(\"supportsTeamDrive\"))return e;{const t=e.includes(\"?\")?\"&\":\"?\";e=e+t+\"supportsTeamDrive=true\"}}(e),r||(r=Us()));const a=t.headers||{};r&&function(e,t){t&&(e[\"Cache-Control\"]=\"no-cache\",e.Authorization=\"Bearer \"+t)}(a,r);const c=t.range,l=new XMLHttpRequest,h=t.sendData||t.body,d=t.method||(h?\"POST\":\"GET\"),u=t.responseType,f=t.contentType,p=t.mimeType;if(l.open(d,e),t.timeout&&(l.timeout=t.timeout),c){let e=\"\";c.size&&(e=c.start+c.size-1),l.setRequestHeader(\"Range\",\"bytes=\"+c.start+\"-\"+e)}if(f&&l.setRequestHeader(\"Content-Type\",f),p&&l.overrideMimeType(p),u&&(l.responseType=u),a)for(let e of Object.keys(a)){const t=a[e];l.setRequestHeader(e,t)}!0===t.withCredentials&&(l.withCredentials=!0),l.onload=async function(n){if(0===l.status||l.status>=200&&l.status<=300)if(\"HEAD\"===t.method){const e=t.requestedHeaders||[\"content-length\"],i={};for(let t of e)i[t]=l.getResponseHeader(t);s(i)}else c&&206!==l.status&&0!==c.start?(l.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${e}. This can have severe performance impacts.`),s(l.response.slice(c.start,c.start+c.size))):s(l.response);else 416===l.status?g(Error(\"416 Unsatisfiable Range\")):!Ts()||404!==l.status&&401!==l.status&&403!==l.status||!Ns(e)||t.retries?403===l.status?g(\"Access forbidden: \"+e):g(l.status):m()},l.onerror=function(i){Ns(e)&&!t.retries?m():g(\"Error accessing resource: \"+e+\" Status: \"+l.status)},l.ontimeout=function(e){g(\"Timed out\")},l.onabort=function(e){console.log(\"Aborted\"),o(e)};try{l.send(h)}catch(i){Ns(e)&&!t.retries?m():g(i)}function g(e){if(!o)throw e;o(e)}async function m(){try{const e=await async function(e){if(Ts()){const t=function(e){return Ms(e)?\"https://www.googleapis.com/auth/drive.file\":Bs(e)?\"https://www.googleapis.com/auth/devstorage.read_only\":\"https://www.googleapis.com/auth/userinfo.profile\"}(e);return await Ls(t)}throw Error(\"Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.\")}(n);t.retries=1,t.oauthToken=e;const r=await i.load(n,t);s(r)}catch(e){if(e.error){const t=e.error.startsWith(\"popup_blocked\")?\"Google login popup blocked by browser.\":e.error;alert(t)}else g(e)}}}))}async _loadFileSlice(e,t){let i=t&&t.range?e.slice(t.range.start,t.range.start+t.range.size):e;const n=await i.arrayBuffer();return\"arraybuffer\"===t.responseType?n:qs(n)}async _loadStringFromFile(e,t){const i=t.range?e.slice(t.range.start,t.range.start+t.range.size):e;return qs(await i.arrayBuffer())}async _loadStringFromUrl(e,t){(t=t||{}).responseType=\"arraybuffer\";return qs(await this.load(e,t))}setOauthToken(e,t){this.oauth.setToken(e,t)}getOauthToken(e){const t=Ns(e)?void 0:Ot(e).host;let i=this.oauth.getToken(t);if(i)return i;if(void 0===t){const e=Us();if(e&&e.expires_at>Date.now())return e.access_token}}async getContentLength(e,t){(t=t||{}).method=\"HEAD\",t.requestedHeaders=[\"content-length\"];const i=(await this._loadURL(e,t))[\"content-length\"];return i?Number.parseInt(i):0}};var Vs={color:1};Vs.parent=Vs,Vs.left=Vs,Vs.right=Vs;class js{constructor(){this.root=Vs}insert(e,t,i){var n=new Xs(new Ys(e,t,i));for(this.treeInsert(n),n.color=2;n!==this.root&&2===n.parent.color;)if(n.parent===n.parent.parent.left){let e=n.parent.parent.right;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,Gs.call(this,n)),n.parent.color=1,n.parent.parent.color=2,$s.call(this,n.parent.parent))}else{let e=n.parent.parent.left;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,$s.call(this,n)),n.parent.color=1,n.parent.parent.color=2,Gs.call(this,n.parent.parent))}this.root.color=1}findOverlapping(e,t){var i=new Ys(e,t,0);if(this.root===Vs)return[];var n=Ws.call(this,i,this.root,[]);return n.length>1&&n.sort((function(e,t){return e.low-t.low})),n}logIntervals(){!function e(t,i){for(var n=\"\",r=0;r=e.low&&Ws.call(this,e,t.left,i),t.right!==Vs&&t.right.min<=e.high&&Ws.call(this,e,t.right,i),i}function Gs(e){var t=e.right;e.right=t.left,t.left!==Vs&&(t.left.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,Ks.call(this,e)}function $s(e){var t=e.left;e.left=t.right,t.right!==Vs&&(t.right.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t,Ks.call(this,e)}function Ks(e){for(;e!==Vs;){var t=e.left.max>e.right.max?e.left.max:e.right.max,i=e.interval.high;e.max=t>i?t:i;var n=e.left.mine.low?1:this.highe.high?1:0}overlaps(e){return this.low<=e.high&&e.low<=this.high}}function Xs(e){this.parent=Vs,this.left=Vs,this.right=Vs,this.interval=e,this.color=2}class Zs{constructor(e,t,i){e=e||[],this.treeMap=this.buildTreeMap(e,t),this.range=i,this.count=e.length}containsRange(e){return void 0===this.range||this.range.contains(e.chr,e.start,e.end)}findFeatures(e){const t=[];for(let i of Object.values(this.allFeatures))for(let n of i)e(n)&&t.push(n);return t}queryFeatures(e,t,i){const n=this.treeMap[e];if(!n)return[];const r=n.findOverlapping(t,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[e];if(s){for(let e of r){const r=e.value;for(let e=r.start;ei)break;r.end>=t&&n.push(r)}}n.sort((function(e,t){return e.start-t.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(e,t){const i={},n=[];if(this.allFeatures={},e){for(let i of e){let e=i.chr;t&&(e=t.getChromosomeName(e));let r=this.allFeatures[e];r||(n.push(e),r=[],this.allFeatures[e]=r),r.push(i)}for(let e of n){const t=this.allFeatures[e];t.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1})),i[e]=Js(t)}}return i}}function Js(e){const t=new js,i=e.length,n=Math.max(10,Math.round(i/10));for(let r=0;rt.start?1:-1}));for(let r=0;ri)break;s.end>t&&e.push(s)}})),e.sort((function(e,t){return e.start-t.start})),e)}return[]};function io(e){if(3===(e=e.replace(/^#/,\"\")).length&&(e=e.split(\"\").map((e=>e+e)).join(\"\")),6!==e.length)throw new Error(\"Invalid HEX color.\");let t=parseInt(e,16);return`rgb(${t>>16&255}, ${t>>8&255}, ${255&t})`}const no={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}};function ro(e){const{r:t,g:i,b:n}=no[e];return`rgb(${t},${i},${n})`}const so={Set1:[\"rgb(228,26,28)\",\"rgb(55,126,184)\",\"rgb(77,175,74)\",\"rgb(166,86,40)\",\"rgb(152,78,163)\",\"rgb(255,127,0)\",\"rgb(247,129,191)\",\"rgb(153,153,153)\",\"rgb(255,255,51)\"],Dark2:[\"rgb(27,158,119)\",\"rgb(217,95,2)\",\"rgb(117,112,179)\",\"rgb(231,41,138)\",\"rgb(102,166,30)\",\"rgb(230,171,2)\",\"rgb(166,118,29)\",\"rgb(102,102,102)\"],Set2:[\"rgb(102, 194,165)\",\"rgb(252,141,98)\",\"rgb(141,160,203)\",\"rgb(231,138,195)\",\"rgb(166,216,84)\",\"rgb(255,217,47)\",\"rgb(229,196,148)\",\"rgb(179,179,179)\"],Set3:[\"rgb(141,211,199)\",\"rgb(255,255,179)\",\"rgb(190,186,218)\",\"rgb(251,128,114)\",\"rgb(128,177,211)\",\"rgb(253,180,98)\",\"rgb(179,222,105)\",\"rgb(252,205,229)\",\"rgb(217,217,217)\",\"rgb(188,128,189)\",\"rgb(204,235,197)\",\"rgb(255,237,111)\"],Pastel1:[\"rgb(251,180,174)\",\"rgb(179,205,227)\",\"rgb(204,235,197)\",\"rgb(222,203,228)\",\"rgb(254,217,166)\",\"rgb(255,255,204)\",\"rgb(229,216,189)\",\"rgb(253,218,236)\"],Pastel2:[\"rgb(173,226,207)\",\"rgb(253,205,172)\",\"rgb(203,213,232)\",\"rgb(244,202,228)\",\"rgb(230,245,201)\",\"rgb(255,242,174)\",\"rgb(243,225,206)\"],Accent:[\"rgb(127,201,127)\",\"rgb(190,174,212)\",\"rgb(253,192,134)\",\"rgb(255,255,153)\",\"rgb(56,108,176)\",\"rgb(240,2,127)\",\"rgb(191,91,23)\"]};class oo{constructor(e){this.colors=so[e],Array.isArray(this.colors)||(this.colors=[]),this.colorTable=new Map,this.nextIdx=0,this.colorGenerator=new co}getColor(e){return this.colorTable.has(e)||(this.nextIdxparseInt(e)))}}co.prototype.hsvToRgb=function(e,t,i){var n=Math.floor(6*e),r=6*e-n,s=i*(1-t),o=i*(1-r*t),a=i*(1-(1-r)*t),c=255,l=255,h=255;switch(n){case 0:c=i,l=a,h=s;break;case 1:c=o,l=i,h=s;break;case 2:c=s,l=i,h=a;break;case 3:c=s,l=o,h=i;break;case 4:c=a,l=s,h=i;break;case 5:c=i,l=s,h=o}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},co.prototype.padHex=function(e){return e.length>this.hexwidth?e:new Array(this.hexwidth-e.length+1).join(\"0\")+e},co.prototype.get=function(e,t){this.hue+=this.goldenRatio,this.hue%=1,\"number\"!=typeof e&&(e=.5),\"number\"!=typeof t&&(t=.95);var i=this.hsvToRgb(this.hue,e,t);return\"#\"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new co;function fo(e,t,i){if(i<.005)return e;if(i>.995)return t;{let n,r,s,o,a,c;i<.5?(i/=.5,[n,r,s]=uo(e),[o,a,c]=uo(ro(\"snow\"))):(i=(i-.5)/.5,[n,r,s]=uo(ro(\"snow\")),[o,a,c]=uo(t));const[l,h,d]=[Math.floor(ys.lerp(n,o,i)),Math.floor(ys.lerp(r,a,i)),Math.floor(ys.lerp(s,c,i))];return function(e,t,i){return`rgb(${e=ys.clamp(e,0,255)}, ${t=ys.clamp(t,0,255)}, ${i=ys.clamp(i,0,255)})`}(l,h,d)}}const po=new Set([\"bedtype\",\"alignment\",\"annotation\",\"variant\",\"wig\",\"interact\",\"shoebox\"]),go=new Set([\"alignment\",\"annotation\",\"variant\",\"eqtl\",\"qtl\",\"snp\",\"shoebox\",\"wig\"]),mo=new Set([\"sequence\",\"ruler\",\"ideogram\"]),wo={};class bo{constructor(e){this.browser=e,this.initialize()}initialize(){const e=new c;e.add(\"...\");const t={parent:this.browser.root,content:e};this.dialog=new w(t),this.browser.root.appendChild(this.dialog.elem),i(this.dialog.elem)}trackMenuItemList(e){const t=[];return\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{const e=parseInt(this.browser.inputDialog.value,10);if(void 0!==e){const t=[];this.trackView.track.selected?t.push(...this.trackView.browser.getSelectedTrackViews().map((({track:e})=>e))):t.push(this);for(const i of t)i.trackView.autoHeight=!1,void 0!==i.minHeight&&i.minHeight>e&&(i.minHeight=e),void 0!==i.maxHeight&&i.maxHeight1&&new Set(t).has(e)}(e)?t.push(...this.multiSelectMenuItems(e)):(\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?\"untitled\":e.trim(),this.name=e},i={label:\"Track Name\",value:Ao(this)||\"unnamed\",callback:t};this.browser.inputDialog.present(i,e)}return e.text(\"Set track name\"),{object:e,click:t}}()),t.push(...this.defaultMenuItems(e))),!1!==e.track.removable&&(t.push(\"
\"),t.push(function(e){const t=e.track.selected?\"Remove tracks\":\"Remove track\",i=Bt(\"
\");function n(e){this.trackView.browser._removeTrack(this)}return i.text(t),{object:i,click:n,menuItemType:\"removeTrack\"}}(e))),t}defaultMenuItems(e){const t=[];return Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),e.track.menuItemList&&t.push(...e.track.menuItemList()),function(e){const t=e.track;return t&&t.config&&void 0!==t.config.visibilityWindow||t&&go.has(t.type)}(e)&&(t.push(\"
\"),t.push(function(e){const t=Bt(\"
\");function i(t){const i=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?-1:e.trim(),this.visibilityWindow=Number.parseInt(e),this.config.visibilityWindow=Number.parseInt(e),this.trackView.updateViews()},n={label:\"wig\"===e?\"Visibility window (bp). Enter 0 for whole chromosome, -1 for whole genome.\":\"Visibility window (bp). Enter 0 for whole chromosome.\",value:this.visibilityWindow,callback:i};this.browser.inputDialog.present(n,t)}return t.text(\"Set visibility window\"),{object:t,click:i}}(e.track.type))),t}multiSelectMenuItems(e){const t=[],i=e.browser.getSelectedTrackViews();var n;return!0===(n=i.map((({track:e})=>e.type)),1===[...new Set(n)].length)?(t.push(...this.defaultMenuItems(e)),\"wig\"===e.track.type&&(t.push(\"
\"),t.push(function(){const e=Bt(\"
\");function t(e){const t=so.Dark2,i=Math.floor(Math.random()*t.length),n=`auto-scale-group-${s()}`;wo[n]=t[i];const r=this.browser.getSelectedTrackViews();for(const{track:e}of r)e.autoscaleGroup=n;this.browser.updateViews()}return e.text(\"Group autoscale\"),{object:e,doAllMultiSelectedTracks:!0,click:t}}()))):Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),t}}function Fo({trackView:e,label:t,option:i}){const n=Bt(\"
\");return n.text(t),{object:n,click:()=>e.presentColorPicker(i)}}function vo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.color=void 0,e.repaintViews()}}}function yo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.altColor=void 0,e.repaintViews()}}}function Ao(e){return e.name}function Co(e){return void 0===e.type||po.has(e.type)}class _o{constructor(e,t){this.browser=e,this.$container=Bt(\"
\",{class:\"igv-generic-dialog-container\"}),t.append(this.$container),this.$container.offset({left:0,top:0});const i=Bt(\"
\",{class:\"igv-generic-dialog-header\"});this.$container.append(i),u(i[0],(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$minimum);const n=Bt(\"
\");n.text(\"Minimum\"),this.$minimum.append(n),this.$minimum_input=Bt(\"\"),this.$minimum.append(this.$minimum_input),this.$maximum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$maximum);const r=Bt(\"
\");r.text(\"Maximum\"),this.$maximum.append(r),this.$maximum_input=Bt(\"\"),this.$maximum.append(this.$maximum_input);const s=Bt(\"
\",{class:\"igv-generic-dialog-ok-cancel\"});this.$container.append(s),this.$ok=Bt(\"
\"),s.append(this.$ok),this.$ok.text(\"OK\"),this.$cancel=Bt(\"
\"),s.append(this.$cancel),this.$cancel.text(\"Cancel\"),this.$cancel.on(\"click\",(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),p(this.$container.get(0),i.get(0)),this.$container.hide()}configure(e){let t;if(Array.isArray(e)){t={min:Number.MAX_SAFE_INTEGER,max:-Number.MAX_SAFE_INTEGER};for(const i of e)i.track.dataRange&&(t.min=Math.min(i.track.dataRange.min,t.min),t.max=Math.max(i.track.dataRange.max,t.max))}else t=e.track.dataRange;t&&(this.$minimum_input.val(t.min),this.$maximum_input.val(t.max)),this.$minimum_input.unbind(),this.$minimum_input.on(\"keyup\",(t=>{13===t.keyCode&&this.processResults(e),t.stopImmediatePropagation()})),this.$maximum_input.unbind(),this.$maximum_input.on(\"keyup\",(t=>{13===t.keyCode&&(t.stopImmediatePropagation(),this.processResults(e))})),this.$ok.unbind(),this.$ok.on(\"click\",(t=>{this.processResults(e)}))}processResults(e){if(\"\"!==this.$minimum_input.val()&&\"\"!==this.$maximum_input.val()){const t=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());if(isNaN(t)||isNaN(i))this.browser.alert.present(new Error(\"Must input numeric values\"),void 0);else{const n=Array.isArray(e)?e:[e];for(const e of n)e.track.setDataRange({min:t,max:i})}this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\")}this.$container.offset({left:0,top:0}),this.$container.hide()}present(e){const t=e.offset().top,i=Bt(\"body\").scrollTop();this.$container.offset({left:e.width()-this.$container.width(),top:t+i}),this.$container.show()}}const xo={configureHighDPICanvas:function(e,t,i){const n=window.devicePixelRatio;e.canvas.style.width=`${t}px`,e.canvas.width=Math.floor(n*t),e.canvas.style.height=`${i}px`,e.canvas.height=Math.floor(n*i),e.scale(n,n)},setProperties:function(e,t){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];e[i]=n}},strokeLine:function(e,t,i,n,r,s){t=Math.floor(t)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(e.save(),xo.setProperties(e,s)),e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke(),s&&e.restore()},fillRect:function(e,t,i,n,r,s){s&&(e.save(),xo.setProperties(e,s)),e.fillRect(t,i,n,r),s&&e.restore()},fillPolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.fill(),n&&e.restore()},strokePolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.stroke(),n&&e.restore()},fillText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.fillText(t,0,0)}else e.fillText(t,i,n);(r||s)&&e.restore()},strokeText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.strokeText(t,0,0)}else e.strokeText(t,i,n);(r||s)&&e.restore()},strokeCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.stroke(),r&&e.restore()},fillCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.fill(),r&&e.restore()},drawArrowhead:function(e,t,i,n,r){e.save(),n||(n=5),r&&(e.lineWidth=r),e.beginPath(),e.moveTo(t,i-n/2),e.lineTo(t,i+n/2),e.lineTo(t+n,i),e.lineTo(t,i-n/2),e.closePath(),e.fill(),e.restore()},dashedLine:function(e,t,i,n,r,s,o={}){void 0===s&&(s=2),e.setLineDash([s,s]),xo.strokeLine(e,t,i,n,r,o),e.setLineDash([])},roundRect:function(e,t,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),e.beginPath(),e.moveTo(t+s,i),e.lineTo(t+n-s,i),e.quadraticCurveTo(t+n,i,t+n,i+s),e.lineTo(t+n,i+r-s),e.quadraticCurveTo(t+n,i+r,t+n-s,i+r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t,i+r,t,i+r-s),e.lineTo(t,i+s),e.quadraticCurveTo(t,i,t+s,i),e.closePath(),a&&e.stroke(),o&&e.fill()},polygon:function(e,t,i,n,r){void 0===r&&(r=!0),e.beginPath();var s=t.length;e.moveTo(t[0],i[0]);for(var o=1;o{for(let t=0;t{e.translate(t,0),e.scale(-1,1),e.translate(-t,0)}};function ko(e,t,i){var n,r=t.length;for(e.beginPath(),e.moveTo(t[0],i[0]),n=1;n1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:Oo;So&&So(e,null);let n=t.length;for(;n--;){let r=t[n];if(\"string\"==typeof r){const e=i(r);e!==r&&(Eo(t)||(t[n]=e),r=e)}e[r]=!0}return e}function Zo(e){for(let t=0;t/gm),pa=Ro(/\\${[\\w\\W]*}/gm),ga=Ro(/^data-[\\-\\w.\\u00B7-\\uFFFF]/),ma=Ro(/^aria-[\\-\\w]+$/),wa=Ro(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i),ba=Ro(/^(?:\\w+script|data):/i),Fa=Ro(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g),va=Ro(/^html$/i),ya=Ro(/^[a-z][.\\w]*(-[.\\w]+)+$/i);var Aa=Object.freeze({__proto__:null,MUSTACHE_EXPR:ua,ERB_EXPR:fa,TMPLIT_EXPR:pa,DATA_ATTR:ga,ARIA_ATTR:ma,IS_ALLOWED_URI:wa,IS_SCRIPT_OR_DATA:ba,ATTR_WHITESPACE:Fa,DOCTYPE_NAME:va,CUSTOM_ELEMENT:ya});const Ca=1,_a=3,xa=7,ka=8,Ia=9,Sa=function(){return\"undefined\"==typeof window?null:window};var Ea=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Sa();const i=t=>e(t);if(i.version=\"3.1.6\",i.removed=[],!t||!t.document||t.document.nodeType!==Ia)return i.isSupported=!1,i;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:h,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:p}=t,g=l.prototype,m=ea(g,\"cloneNode\"),w=ea(g,\"remove\"),b=ea(g,\"nextSibling\"),F=ea(g,\"childNodes\"),v=ea(g,\"parentNode\");if(\"function\"==typeof a){const e=n.createElement(\"template\");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,A=\"\";const{implementation:C,createNodeIterator:_,createDocumentFragment:x,getElementsByTagName:k}=n,{importNode:I}=r;let S={};i.isSupported=\"function\"==typeof Io&&\"function\"==typeof v&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:E,ERB_EXPR:N,TMPLIT_EXPR:B,DATA_ATTR:M,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:D,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:L}=Aa;let{IS_ALLOWED_URI:z}=Aa,H=null;const P=Xo({},[...ta,...ia,...na,...sa,...aa]);let O=null;const U=Xo({},[...ca,...la,...ha,...da]);let q=Object.seal(Do(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,V=null,j=!0,W=!0,G=!1,$=!0,K=!1,Y=!0,X=!1,Z=!1,J=!1,ee=!1,te=!1,ie=!1,ne=!0,re=!1,se=!0,oe=!1,ae={},ce=null;const le=Xo({},[\"annotation-xml\",\"audio\",\"colgroup\",\"desc\",\"foreignobject\",\"head\",\"iframe\",\"math\",\"mi\",\"mn\",\"mo\",\"ms\",\"mtext\",\"noembed\",\"noframes\",\"noscript\",\"plaintext\",\"script\",\"style\",\"svg\",\"template\",\"thead\",\"title\",\"video\",\"xmp\"]);let he=null;const de=Xo({},[\"audio\",\"video\",\"img\",\"source\",\"image\",\"track\"]);let ue=null;const fe=Xo({},[\"alt\",\"class\",\"for\",\"id\",\"label\",\"name\",\"pattern\",\"placeholder\",\"role\",\"summary\",\"title\",\"value\",\"style\",\"xmlns\"]),pe=\"http://www.w3.org/1998/Math/MathML\",ge=\"http://www.w3.org/2000/svg\",me=\"http://www.w3.org/1999/xhtml\";let we=me,be=!1,Fe=null;const ve=Xo({},[pe,ge,me],Uo);let ye=null;const Ae=[\"application/xhtml+xml\",\"text/html\"];let Ce=null,_e=null;const xe=n.createElement(\"form\"),ke=function(e){return e instanceof RegExp||e instanceof Function},Ie=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!_e||_e!==e){if(e&&\"object\"==typeof e||(e={}),e=Jo(e),ye=-1===Ae.indexOf(e.PARSER_MEDIA_TYPE)?\"text/html\":e.PARSER_MEDIA_TYPE,Ce=\"application/xhtml+xml\"===ye?Uo:Oo,H=Wo(e,\"ALLOWED_TAGS\")?Xo({},e.ALLOWED_TAGS,Ce):P,O=Wo(e,\"ALLOWED_ATTR\")?Xo({},e.ALLOWED_ATTR,Ce):U,Fe=Wo(e,\"ALLOWED_NAMESPACES\")?Xo({},e.ALLOWED_NAMESPACES,Uo):ve,ue=Wo(e,\"ADD_URI_SAFE_ATTR\")?Xo(Jo(fe),e.ADD_URI_SAFE_ATTR,Ce):fe,he=Wo(e,\"ADD_DATA_URI_TAGS\")?Xo(Jo(de),e.ADD_DATA_URI_TAGS,Ce):de,ce=Wo(e,\"FORBID_CONTENTS\")?Xo({},e.FORBID_CONTENTS,Ce):le,Q=Wo(e,\"FORBID_TAGS\")?Xo({},e.FORBID_TAGS,Ce):{},V=Wo(e,\"FORBID_ATTR\")?Xo({},e.FORBID_ATTR,Ce):{},ae=!!Wo(e,\"USE_PROFILES\")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,W=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,K=e.SAFE_FOR_TEMPLATES||!1,Y=!1!==e.SAFE_FOR_XML,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,se=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,z=e.ALLOWED_URI_REGEXP||wa,we=e.NAMESPACE||me,q=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&\"boolean\"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(q.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),K&&(W=!1),te&&(ee=!0),ae&&(H=Xo({},aa),O=[],!0===ae.html&&(Xo(H,ta),Xo(O,ca)),!0===ae.svg&&(Xo(H,ia),Xo(O,la),Xo(O,da)),!0===ae.svgFilters&&(Xo(H,na),Xo(O,la),Xo(O,da)),!0===ae.mathMl&&(Xo(H,sa),Xo(O,ha),Xo(O,da))),e.ADD_TAGS&&(H===P&&(H=Jo(H)),Xo(H,e.ADD_TAGS,Ce)),e.ADD_ATTR&&(O===U&&(O=Jo(O)),Xo(O,e.ADD_ATTR,Ce)),e.ADD_URI_SAFE_ATTR&&Xo(ue,e.ADD_URI_SAFE_ATTR,Ce),e.FORBID_CONTENTS&&(ce===le&&(ce=Jo(ce)),Xo(ce,e.FORBID_CONTENTS,Ce)),se&&(H[\"#text\"]=!0),X&&Xo(H,[\"html\",\"head\",\"body\"]),H.table&&(Xo(H,[\"tbody\"]),delete Q.tbody),e.TRUSTED_TYPES_POLICY){if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');y=e.TRUSTED_TYPES_POLICY,A=y.createHTML(\"\")}else void 0===y&&(y=function(e,t){if(\"object\"!=typeof e||\"function\"!=typeof e.createPolicy)return null;let i=null;const n=\"data-tt-policy-suffix\";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r=\"dompurify\"+(i?\"#\"+i:\"\");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn(\"TrustedTypes policy \"+r+\" could not be created.\"),null}}(p,s)),null!==y&&\"string\"==typeof A&&(A=y.createHTML(\"\"));Mo&&Mo(e),_e=e}},Se=Xo({},[\"mi\",\"mo\",\"mn\",\"ms\",\"mtext\"]),Ee=Xo({},[\"foreignobject\",\"annotation-xml\"]),Ne=Xo({},[\"title\",\"style\",\"font\",\"a\",\"script\"]),Be=Xo({},[...ia,...na,...ra]),Me=Xo({},[...sa,...oa]),Re=function(e){Po(i.removed,{element:e});try{v(e).removeChild(e)}catch(t){w(e)}},De=function(e,t){try{Po(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Po(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),\"is\"===e&&!O[e])if(ee||te)try{Re(t)}catch(e){}else try{t.setAttribute(e,\"\")}catch(e){}},Te=function(e){let t=null,i=null;if(J)e=\"\"+e;else{const t=qo(e,/^[\\r\\n\\t ]+/);i=t&&t[0]}\"application/xhtml+xml\"===ye&&we===me&&(e=''+e+\"\");const r=y?y.createHTML(e):e;if(we===me)try{t=(new f).parseFromString(r,ye)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(we,\"template\",null);try{t.documentElement.innerHTML=be?A:r}catch(e){}}const s=t.body||t.documentElement;return e&&i&&s.insertBefore(n.createTextNode(i),s.childNodes[0]||null),we===me?k.call(t,X?\"html\":\"body\")[0]:X?t.documentElement:s},Le=function(e){return _.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},ze=function(e){return e instanceof u&&(\"string\"!=typeof e.nodeName||\"string\"!=typeof e.textContent||\"function\"!=typeof e.removeChild||!(e.attributes instanceof d)||\"function\"!=typeof e.removeAttribute||\"function\"!=typeof e.setAttribute||\"string\"!=typeof e.namespaceURI||\"function\"!=typeof e.insertBefore||\"function\"!=typeof e.hasChildNodes)},He=function(e){return\"function\"==typeof c&&e instanceof c},Pe=function(e,t,n){S[e]&&zo(S[e],(e=>{e.call(i,t,n,_e)}))},Oe=function(e){let t=null;if(Pe(\"beforeSanitizeElements\",e,null),ze(e))return Re(e),!0;const n=Ce(e.nodeName);if(Pe(\"uponSanitizeElement\",e,{tagName:n,allowedTags:H}),e.hasChildNodes()&&!He(e.firstElementChild)&&Go(/<[/\\w]/g,e.innerHTML)&&Go(/<[/\\w]/g,e.textContent))return Re(e),!0;if(e.nodeType===xa)return Re(e),!0;if(Y&&e.nodeType===ka&&Go(/<[/\\w]/g,e.data))return Re(e),!0;if(!H[n]||Q[n]){if(!Q[n]&&qe(n)){if(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,n))return!1;if(q.tagNameCheck instanceof Function&&q.tagNameCheck(n))return!1}if(se&&!ce[n]){const t=v(e)||e.parentNode,i=F(e)||e.childNodes;if(i&&t){for(let n=i.length-1;n>=0;--n){const r=m(i[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,b(e))}}}return Re(e),!0}return e instanceof l&&!function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:we,tagName:\"template\"});const i=Oo(e.tagName),n=Oo(t.tagName);return!!Fe[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?\"svg\"===i:t.namespaceURI===pe?\"svg\"===i&&(\"annotation-xml\"===n||Se[n]):Boolean(Be[i]):e.namespaceURI===pe?t.namespaceURI===me?\"math\"===i:t.namespaceURI===ge?\"math\"===i&&Ee[n]:Boolean(Me[i]):e.namespaceURI===me?!(t.namespaceURI===ge&&!Ee[n])&&!(t.namespaceURI===pe&&!Se[n])&&!Me[i]&&(Ne[i]||!Be[i]):!(\"application/xhtml+xml\"!==ye||!Fe[e.namespaceURI]))}(e)?(Re(e),!0):\"noscript\"!==n&&\"noembed\"!==n&&\"noframes\"!==n||!Go(/<\\/no(script|embed|frames)/i,e.innerHTML)?(K&&e.nodeType===_a&&(t=e.textContent,zo([E,N,B],(e=>{t=Qo(t,e,\" \")})),e.textContent!==t&&(Po(i.removed,{element:e.cloneNode()}),e.textContent=t)),Pe(\"afterSanitizeElements\",e,null),!1):(Re(e),!0)},Ue=function(e,t,i){if(ne&&(\"id\"===t||\"name\"===t)&&(i in n||i in xe))return!1;if(W&&!V[t]&&Go(M,t));else if(j&&Go(R,t));else if(!O[t]||V[t]){if(!(qe(e)&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,e)||q.tagNameCheck instanceof Function&&q.tagNameCheck(e))&&(q.attributeNameCheck instanceof RegExp&&Go(q.attributeNameCheck,t)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(t))||\"is\"===t&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,i)||q.tagNameCheck instanceof Function&&q.tagNameCheck(i))))return!1}else if(ue[t]);else if(Go(z,Qo(i,T,\"\")));else if(\"src\"!==t&&\"xlink:href\"!==t&&\"href\"!==t||\"script\"===e||0!==Vo(i,\"data:\")||!he[e]){if(G&&!Go(D,Qo(i,T,\"\")));else if(i)return!1}else;return!0},qe=function(e){return\"annotation-xml\"!==e&&qo(e,L)},Qe=function(e){Pe(\"beforeSanitizeAttributes\",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:\"\",attrValue:\"\",keepAttr:!0,allowedAttributes:O};let r=t.length;for(;r--;){const s=t[r],{name:o,namespaceURI:a,value:c}=s,l=Ce(o);let h=\"value\"===o?c:jo(c);if(n.attrName=l,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Pe(\"uponSanitizeAttribute\",e,n),h=n.attrValue,Y&&Go(/((--!?|])>)|<\\/(style|title)/i,h)){De(o,e);continue}if(n.forceKeepAttr)continue;if(De(o,e),!n.keepAttr)continue;if(!$&&Go(/\\/>/i,h)){De(o,e);continue}K&&zo([E,N,B],(e=>{h=Qo(h,e,\" \")}));const d=Ce(e.nodeName);if(Ue(d,l,h)){if(!re||\"id\"!==l&&\"name\"!==l||(De(o,e),h=\"user-content-\"+h),y&&\"object\"==typeof p&&\"function\"==typeof p.getAttributeType)if(a);else switch(p.getAttributeType(d,l)){case\"TrustedHTML\":h=y.createHTML(h);break;case\"TrustedScriptURL\":h=y.createScriptURL(h)}try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),ze(e)?Re(e):Ho(i.removed)}catch(e){}}}Pe(\"afterSanitizeAttributes\",e,null)},Ve=function e(t){let i=null;const n=Le(t);for(Pe(\"beforeSanitizeShadowDOM\",t,null);i=n.nextNode();)Pe(\"uponSanitizeShadowNode\",i,null),Oe(i)||(i.content instanceof o&&e(i.content),Qe(i));Pe(\"afterSanitizeShadowDOM\",t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,a=null,l=null;if(be=!e,be&&(e=\"\\x3c!--\\x3e\"),\"string\"!=typeof e&&!He(e)){if(\"function\"!=typeof e.toString)throw $o(\"toString is not a function\");if(\"string\"!=typeof(e=e.toString()))throw $o(\"dirty is not a string, aborting\")}if(!i.isSupported)return e;if(Z||Ie(t),i.removed=[],\"string\"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Ce(e.nodeName);if(!H[t]||Q[t])throw $o(\"root node is forbidden and cannot be sanitized in-place\")}}else if(e instanceof c)n=Te(\"\\x3c!----\\x3e\"),s=n.ownerDocument.importNode(e,!0),s.nodeType===Ca&&\"BODY\"===s.nodeName||\"HTML\"===s.nodeName?n=s:n.appendChild(s);else{if(!ee&&!K&&!X&&-1===e.indexOf(\"<\"))return y&&ie?y.createHTML(e):e;if(n=Te(e),!n)return ee?null:ie?A:\"\"}n&&J&&Re(n.firstChild);const h=Le(oe?e:n);for(;a=h.nextNode();)Oe(a)||(a.content instanceof o&&Ve(a.content),Qe(a));if(oe)return e;if(ee){if(te)for(l=x.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(O.shadowroot||O.shadowrootmode)&&(l=I.call(r,l,!0)),l}let d=X?n.outerHTML:n.innerHTML;return X&&H[\"!doctype\"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Go(va,n.ownerDocument.doctype.name)&&(d=\"\\n\"+d),K&&zo([E,N,B],(e=>{d=Qo(d,e,\" \")})),y&&ie?y.createHTML(d):d},i.setConfig=function(){Ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},i.clearConfig=function(){_e=null,Z=!1},i.isValidAttribute=function(e,t,i){_e||Ie({});const n=Ce(e),r=Ce(t);return Ue(n,r,i)},i.addHook=function(e,t){\"function\"==typeof t&&(S[e]=S[e]||[],Po(S[e],t))},i.removeHook=function(e){if(S[e])return Ho(S[e])},i.removeHooks=function(e){S[e]&&(S[e]=[])},i.removeAllHooks=function(){S={}},i}();class Na{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container),this._input=document.createElement(\"input\"),this.input_container.appendChild(this._input);const r=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(r),this.ok=e(),r.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),r.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"keyup\",(e=>{\"Enter\"===e.code&&(\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)),e.stopImmediatePropagation()})),this.ok.addEventListener(\"click\",(()=>{\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)}));const s=()=>{this._input.value=\"\",i(this.container)};this.cancel.addEventListener(\"click\",s),u(n,s),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._input.value=e.value,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ba={licorice:\"#000000\",lead:\"#1e1e1e\",tungsten:\"#3a3a3a\",iron:\"#545453\",steel:\"#6e6e6e\",tin:\"#878687\",nickel:\"#888787\",aluminum:\"#a09fa0\",magnesium:\"#b8b8b8\",silver:\"#d0d0d0\",mercury:\"#e8e8e8\",snow:\"#ffffff\",cayenne:\"#891100\",mocha:\"#894800\",aspargus:\"#888501\",fern:\"#458401\",clover:\"#028401\",moss:\"#018448\",teal:\"#008688\",ocean:\"#004a88\",midnight:\"#001888\",eggplant:\"#491a88\",plum:\"#891e88\",maroon:\"#891648\",maraschino:\"#ff2101\",tangerine:\"#ff8802\",lemon:\"#fffa03\",lime:\"#83f902\",spring:\"#05f802\",seam_foam:\"#03f987\",turquoise:\"#00fdff\",aqua:\"#008cff\",blueberry:\"#002eff\",grape:\"#8931ff\",magenta:\"#ff39ff\",strawberry:\"#ff2987\",salmon:\"#ff726e\",cantaloupe:\"#ffce6e\",banana:\"#fffb6d\",honeydew:\"#cefa6e\",flora:\"#68f96e\",spindrift:\"#68fbd0\",ice:\"#68fdff\",sky:\"#6acfff\",orchid:\"#6e76ff\",lavender:\"#d278ff\",bubblegum:\"#ff7aff\",carnation:\"#ff7fd3\"};class Ma{constructor({parent:t,top:n,left:r,width:s,height:o,border:a,closeHandler:c}){let l=e({class:\"igv-ui-generic-container\"});t.appendChild(l),i(l),this.container=l,void 0!==n&&(this.container.style.top=`${n}px`),void 0!==r&&(this.container.style.left=`${r}px`),void 0!==s&&(this.container.style.width=`${s}px`),void 0!==o&&(this.container.style.height=`${o}px`),a&&(this.container.style.border=a);const h=e();this.container.appendChild(h),u(h,(e=>{i(this.container),\"function\"==typeof c&&c(e)})),p(this.container,h)}show(){n(this.container)}hide(){i(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Ra extends Ma{constructor({parent:e,width:t}){super({parent:e,width:t,border:\"1px solid gray\"})}configure(e,t){this.colorHandlers=t,this.setActiveColorHandler(\"color\"),this.createSwatches(e)}setActiveColorHandler(e){this.activeColorHandler=this.colorHandlers[e]}createSwatches(t){this.container.querySelectorAll(\".igv-ui-color-swatch\").forEach((e=>e.remove()));const i=Object.values(Ba);for(let t of i){const i=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(i),this.decorateSwatch(i,t)}if(t)for(let i of t){const t=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(t),this.decorateSwatch(t,i)}}decorateSwatch(e,t){e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(()=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(()=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),this.activeColorHandler(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),this.activeColorHandler(t)}))}}const Da={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};class Ta{constructor(t,n){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},n),this.container=e({class:\"igv-ui-alert-dialog-container\"}),t.appendChild(this.container),this.container.setAttribute(\"tabIndex\",\"-1\");const r=e();this.container.appendChild(r),this.errorHeadline=e(),r.appendChild(this.errorHeadline),this.errorHeadline.textContent=\"\";let s=e({class:\"igv-ui-alert-dialog-body\"});this.container.appendChild(s),this.body=e({class:\"igv-ui-alert-dialog-body-copy\"}),s.appendChild(this.body);let o=e();this.container.appendChild(o),this.ok=e(),o.appendChild(this.ok),this.ok.textContent=\"OK\";const a=()=>{\"function\"==typeof this.callback&&(this.callback(\"OK\"),this.callback=void 0),this.body.innerHTML=\"\",i(this.container)};this.ok.addEventListener(\"click\",(e=>{e.stopPropagation(),a()})),this.container.addEventListener(\"keypress\",(e=>{e.stopPropagation(),\"Enter\"===e.key&&a()})),p(this.container,r),i(this.container)}present(e,t){this.errorHeadline.textContent=e.message?\"ERROR\":\"\";let i=e.message||e;Da.hasOwnProperty(i)&&(i=Da[i]);const r=Ea.sanitize(i);this.body.innerHTML=r,this.callback=t,n(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class La{constructor(e){this.dialog=new Ta(e)}present(e,t){this.dialog.present(e,t)}}function za(e){if(e)switch(e.toLowerCase()){case\"bw\":case\"bigwig\":case\"wig\":case\"bedgraph\":case\"tdf\":return\"wig\";case\"vcf\":return\"variant\";case\"seg\":return\"seg\";case\"mut\":case\"maf\":return\"mut\";case\"bam\":case\"cram\":return\"alignment\";case\"hiccups\":case\"bedpe\":case\"bedpe-loop\":case\"biginteract\":return\"interact\";case\"bp\":return\"arc\";case\"gwas\":return\"gwas\";case\"bed\":case\"bigbed\":case\"bb\":case\"biggenepred\":case\"bignarrowpeak\":return\"bedtype\";case\"fasta\":return\"sequence\";case\"pytor\":return\"cnvpytor\";case\"qtl\":return\"qtl\";default:return\"annotation\"}}function Ha(e){e.featureType&&(e.type=e.type||e.featureType,e.featureType=void 0),\"junctions\"===e.type?e.type=\"junction\":\"bed\"===e.type?(e.type=\"annotation\",e.format=e.format||\"bed\"):\"annotations\"===e.type?e.type=\"annotation\":\"alignments\"===e.type?e.type=\"alignment\":\"bam\"===e.type?(e.type=\"alignment\",e.format=\"bam\"):\"vcf\"===e.type?(e.type=\"variant\",e.format=\"vcf\"):\"t2d\"===e.type?e.type=\"gwas\":\"FusionJuncSpan\"!==e.type||e.format?\"aed\"===e.type&&(e.type=\"annotation\",e.format=e.format||\"aed\"):e.format=\"fusionjuncspan\"}var Pa=Object.freeze({__proto__:null,inferTrackType:za,translateDeprecatedTypes:Ha});function Oa(e){const t=new Set([\"boolean\",\"number\",\"string\",\"symbol\"]),i=typeof e;return void 0!==e&&(t.has(i)||e.substring||e.toFixed)}function Ua(e,t){var i={oauthToken:e.oauthToken,headers:e.headers,withCredentials:e.withCredentials,filename:e.filename};return Object.assign(i,t)}const qa=function(e){var t,i;if(e&&e.length>0){t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of e)Number.isNaN(n.value)||(t=Math.min(t,n.value),i=Math.max(i,n.value));i>0&&(t=Math.min(0,t)),i<0&&(i=0)}else t=0,i=100;return{min:t,max:i}},Qa=function(e,t,i){let n=t.start,r=t.end;if(void 0===r)n-=i/2,r=n+i,r>e?(r=e,n=r-i):n<0&&(n=0,r=i);else if(r-ne?(r=e,n=r-i):(n=t-i/2,r=n+i)}t.start=Math.ceil(n),t.end=Math.floor(r)},Va=function(e){return\"number\"==typeof e?e-e==0:\"string\"==typeof e&&\"\"!==e.trim()&&Number.isFinite(+e)};async function ja(e){if(Mt(e)&&e.startsWith(\"https://drive.google.com\")){if(void 0===zs())throw Error(\"Google drive is referenced, but API key is not defined. An API key is required for Google Drive access\");const t=await async function(e){let t=\"https://www.googleapis.com/drive/v3/files/\"+Ps(e)+\"?supportsTeamDrives=true\";const i=zs();i&&(t+=\"&key=\"+i);const n=await fetch(t);let r=await n.json();if(r.error&&404===r.error.code){let e=\"https://www.googleapis.com/auth/drive.readonly\";const i=await Ls(e);if(!i)throw Error(r.error);{const e=await fetch(t,{headers:{Authorization:`Bearer ${i}`}});if(r=await e.json(),r.error)throw Error(r.error)}}return r}(e);return t.originalFileName||t.name}return zt(e)}function Wa(e){var t,i;return e>1e7?(t=\" mb\",i=e/1e6,Math.floor(i).toString()+t):e>1e4?(t=\" kb\",i=e/1e3,Rt(Math.floor(i))+t):Rt(e)+\" bp\"}function Ga(e){return Mt(e)&&e.startsWith(\"data:\")}function $a(t,i){const n=e({class:i});t.appendChild(n)}function Ka(e,t){t.parentNode.insertBefore(e,t)}function Ya(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function Xa(){return\"https:\"===window.location.protocol||\"localhost\"===window.location.hostname}class Za extends Ma{constructor({parent:e,top:t,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:e,top:t,left:i,width:n,height:r,border:\"1px solid gray\"}),Ja(this.container,o,s)}}const Ja=(t,i,n)=>{const r=Object.values(Ba);for(let n of r){const r=e({class:\"igv-ui-color-swatch\"});t.appendChild(r),ec(r,n,i)}if(n)for(let r of n){const n=e({class:\"igv-ui-color-swatch\"});t.appendChild(n),ec(n,r,i)}},ec=(e,t,i)=>{e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(i=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(t=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),i(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),i(t)}))};class tc{constructor(t,i,n,r){this.parent=t,this.popover=e({class:\"igv-ui-popover\"}),t.appendChild(this.popover),this.popoverHeader=e(),this.popover.appendChild(this.popoverHeader);const s=e();this.popoverHeader.appendChild(s),n&&(s.textContent=n);const o=e();this.popoverHeader.appendChild(o),o.appendChild(l(\"times\")),o.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault(),r?r():this.dismiss()})),!0===i&&p(this.popover,this.popoverHeader,{minX:0,minY:0}),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\"}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";const t=this.popover.parentNode,{x:i,y:n,width:r}=a(e,t);this.popover.style.top=`${n}px`;const{width:s}=this.popover.getBoundingClientRect(),o=i+s,c=o-r;this.popover.style.left=`${o>r?i-c:i}px`,this.popoverContent.style.maxWidth=`${Math.min(s,r)}px`}presentContentWithEvent(e,t){this.popover.style.display=\"block\",this.popoverContent.innerHTML=t,ic(e,this.popover,this.popoverContent)}presentMenu(e,t){if(0===t.length)return;this.popover.style.display=\"block\";const i=nc(t,this.popover);for(let e of i)this.popoverContent.appendChild(e.object);ic(e,this.popover,this.popoverContent)}dismiss(){this.popover.style.display=\"none\"}hide(){this.popover.style.display=\"none\",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const e=Object.keys(this);for(let t of e)this[t]=void 0}}function ic(e,t,i){const{x:n,y:r,width:s}=a(e,t.parentNode);t.style.top=`${r}px`;const{width:o}=t.getBoundingClientRect(),c=n+o,l=c-s;t.style.left=`${c>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}function nc(t,n){const r=t.map((function(t,r){let s;if(\"string\"==typeof t)s=e(),s.innerHTML=t;else if(\"Node\"==typeof t)s=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)s=function(t,i){const n=e({class:\"igv-ui-trackgear-popover-check-container\"}),r=h(\"check\",!0===i?\"#444\":\"transparent\");r.style.borderColor=\"gray\",r.style.borderWidth=\"1px\",r.style.borderStyle=\"solid\",n.appendChild(r);let s=e();return s.textContent=t,n.appendChild(s),n}(\"Show all bases\",t.value);else if(\"color\"===t.type){const o=new Za({parent:n.parentElement,width:364,colorHandler:e=>t.click(e)});s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);const a=e=>{o.show(),i(n),e.preventDefault(),e.stopPropagation()};s.addEventListener(\"click\",a),s.addEventListener(\"touchend\",a),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function c(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}s.addEventListener(\"click\",c),s.addEventListener(\"touchend\",c),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{object:s,init:t.init}}));return r}const rc=[[\"A\",\"T\"],[\"G\",\"C\"],[\"Y\",\"R\"],[\"W\",\"S\"],[\"K\",\"M\"],[\"D\",\"H\"],[\"B\",\"V\"]],sc=new Map;for(let _A of rc){const xA=_A[0],kA=_A[1];sc.set(xA,kA),sc.set(kA,xA),sc.set(xA.toLowerCase(),kA.toLowerCase()),sc.set(kA.toLowerCase(),xA.toLowerCase())}function oc(e){return sc.has(e)?sc.get(e):e}function ac(e){let t=\"\";for(let i of e)t+=sc.has(i)?sc.get(i):i;return t}function cc(e){let t=\"\",i=e.length;for(;i-- >0;){const n=e[i];t+=sc.has(n)?sc.get(n):n}return t}class lc{constructor(e,t,i,n){this.name=e,this.order=t,this.bpLength=i,this.altNames=n}getAltName(e){return this.altNames&&this.altNames.has(e)?this.altNames.get(e):this.name}}class hc{constructor(e,t,i,n){this.chr=e,this.start=t,this.end=i,this.features=n}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}containsRange(e){return this.chr===e.chr&&this.start<=e.start&&this.end>=e.end}get locusString(){return`${this.chr}:${this.start+1}-${this.end}`}}class dc extends hc{constructor(e,t,i,n){super(e,t,i,n)}getSequence(e,t){if(ethis.end)return null;const i=e-this.start,n=t-e;return this.features?this.features.substring(i,i+n):null}hasSequence(e,t){return e>=this.start&&t<=this.end}}const uc=Dt,fc=new Set([\"fastaURL\",\"indexURL\",\"cytobandURL\",\"indexed\"]);class pc{#e;chromosomes=new Map;sequences=new Map;constructor(e){this.fastaURL=e.fastaURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!fc.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.loadAll()}getSequenceRecord(e){return this.chromosomes.get(e)}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getSequence(e,t,i){if(0===this.sequences.size&&await this.loadAll(),!this.sequences.has(e))return;let n=this.sequences.get(e).find((e=>e.contains(t,i)));if(!n&&(n=this.sequences.get(e).find((e=>e.overlaps(t,i))),!n))return;t-=n.offset,i-=n.offset;let r=\"\";if(t<0)for(let e=t;e\")){a&&a.seq&&c.call(this,a,o++);const e=r.substr(1).split(/\\s+/),t=e[0].split(\":\");if(a.chr=t[0],a.seq=\"\",a.offset=0,t.length>1&&t[1].indexOf(\"-\")>0){const i=t[1].split(\"-\");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),e.length>1&&e[1].startsWith(\"@len=\"))try{a.length=parseInt(e[1].trim().substring(5))}catch(e){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&c.call(this,a,o)}function c(e,i){const n=e.length||e.offset+e.seq.length;if(t.has(e.chr)){const t=this.chromosomes.get(e.chr);t.bpLength=Math.max(t.bpLength,n)}else this.sequences.set(e.chr,[]),this.chromosomes.set(e.chr,new lc(e.chr,i,n)),t.add(e.chr);this.sequences.get(e.chr).push(new gc(e.offset,e.seq))}}getSequenceInterval(e,t,i){const n=this.sequences.get(e);if(n)for(let r of n){const n=r.sequence,s=r.offset,o=s+n.length;if(s<=t&&o>=i)return new dc(e,s,o,n)}}}class gc{constructor(e,t){this.offset=e,this.sequence=t}contains(e,t){return this.offset<=e&&this.end>=t}overlaps(e,t){return this.offsete}get end(){return this.offset+this.sequence.length}}const mc=Dt,wc=new Set([\"fastaURL\",\"indexURL\",\"compressedIndexURL\",\"cytobandURL\",\"indexed\"]);class bc{#e;chromosomes=new Map;constructor(e){this.file=e.fastaURL,this.indexFile=e.indexURL,this.compressedIndexFile=e.compressedIndexURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!wc.has(i)&&(t[i]=e[i]);this.config=t}getSequenceRecord(e){return this.chromosomes.get(e)}async init(){return this.getIndex()}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getIndex(){if(this.index)return this.index;{const e=await Qs.load(this.indexFile,Ua(this.config)),t=mc(e),i=t.length;let n=0,r=0;for(this.index={};nthis.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let t=0;te){c=!0;break}t=t)break}const l=i[i.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]0&&(w=Math.min(s-r,a-u),b+=m.substr(F,w),F+=w+l);F1){const e=Number.parseInt(t[1]),n=new lc(t[0],i++,e);this.chromosomes.set(t[0],n)}}}}class yc{constructor(e,t=!0){this.littleEndian=t,this.position=0,this.view=e,this.length=e.byteLength}dumpBytes(e=100){const t=this.position,i=[];for(let t=0;t<=e;t++)i.push(this.getByte());console.log(i.join(\" \")),this.setPosition(t)}setPosition(e){this.position=e}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position=0;i--)t=256*t+e[i];else for(let i=0;i0&&(t+=String.fromCharCode(e))}return t}getFloat(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e}getDouble(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e}skip(e){return this.position+=e,this.position}getVPointer(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Ac(i,t)}}class Ac{constructor(e,t){this.block=e,this.offset=t}isLessThan(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset}isEqualTo(e){return this.block===e.block&&this.offset===e.offset}print(){return this.block+\":\"+this.offset}}class Cc{static magic=2026540177;littleEndian=!0;nodeCache=new Map;static async loadBpTree(e,t,i){return new Cc(e,t,i).init()}constructor(e,t,i){this.path=e,this.config=t,this.startOffset=i}async init(){const e=await this.#t(this.startOffset,32);let t=e.getInt();if(t!==Cc.magic&&(e.setPosition(0),this.littleEndian=!this.littleEndian,e.littleEndian=this.littleEndian,t=e.getInt(),t!==Cc.magic))throw Error(`Bad magic number ${t}`);const i=e.getInt(),n=e.getInt(),r=e.getInt(),s=e.getLong(),o=e.getLong(),a=this.startOffset+32;return this.header={magic:t,blockSize:i,keySize:n,valSize:r,itemCount:s,reserved:o,nodeOffset:a},this}async search(e){this.header||await this.init();const{keySize:t,valSize:i}=this.header;if(16!==i&&8!==i)throw Error(`Unexpected valSize ${i}`);const n=async e=>{if(this.nodeCache.has(e))return this.nodeCache.get(e);{let n=await this.#t(e,4);const r=n.getByte();n.getByte();const s=n.getUShort(),o=[];if(1===r){const r=s*(t+i);n=await this.#t(e+4,r);for(let e=0;e{const i=await n(t);if(1!==i.type){let t=i.items[0].offset;for(let n=1;n>6&3]+_c[IA>>4&3]+_c[IA>>2&3]+_c[3&IA]);const kc=xc.map((e=>e.toLowerCase()));class Ic{littleEndian;metaIndex=new Map;constructor(e){this.url=e.twoBitURL||e.fastaURL,this.config=e,e.twoBitBptURL&&(this.bptURL=e.twoBitBptURL)}async init(){if(this.bptURL)this.index=await Cc.loadBpTree(this.bptURL,this.config,0);else{const e=await this._readIndex();this.index={search:async t=>e.has(t)?{offset:e.get(t)}:void 0}}}async readSequence(e,t,i){this.index||await this.init();const n=await this.getSequenceRecord(e);if(!n)return null;if(t<0)throw new TypeError(\"regionStart cannot be less than 0\");(void 0===i||i>n.dnaSize)&&(i=n.dnaSize);const r=this._getOverlappingBlocks(t,i,n.nBlocks),s=this._getOverlappingBlocks(t,i,n.maskBlocks),o=Math.floor(t/4),a=n.packedPos+o,c=Math.floor(i/4)-o+1,l=await Qs.loadArrayBuffer(this.url,{range:{start:a,size:c}}),h=new Uint8Array(l);let d=\"\";for(let e=t;ee;if(r[0]&&e>=r[0].start&&et)break;r.endn.contains(e,t,i)));if(n||(n=await this.#o(e,t,i),this.#a(n),this.#r.push(n)),n){const e=t-n.start,r=i-t;return n.features?n.features.substring(e,e+r):null}}#a(e){this.#r=this.#r.filter((t=>!e.contains(t))),this.#r.length===this.#s&&this.#r.shift(),this.browser&&this.browser.referenceFrameList.length<100&&(this.#r=this.#r.filter((e=>void 0!==this.browser.referenceFrameList.find((t=>t.overlaps(e))))))}getSequenceInterval(e,t,i){return this.#r.find((n=>n.contains(e,t,i)))}async#o(e,t,i){let n=t,r=i;if(i-t{s.features=await this.sequenceReader.readSequence(e,n,r),t(s)}));return this.#n=[s,t],t}}async init(){return this.sequenceReader.init()}get chromosomeNames(){return this.sequenceReader.chromosomeNames}getFirstChromosomeName(){return\"function\"==typeof this.sequenceReader.getFirstChromosomeName?this.sequenceReader.getFirstChromosomeName():void 0}#c(e){this.browser.referenceFrameList}}async function Nc(e,t){let i;return\"chromsizes\"===e.format?i=new vc(e.fastaURL||e.url):\"2bit\"===e.format||e.twoBitURL?i=new Ec(new Ic(e),t):Ga(e.fastaURL)||!e.indexURL?i=new pc(e):\"gbk\"===e.format||e.gbkURL||(i=new Ec(new bc(e),t)),await i.init(),i}const Bc={A:\"rgb( 0, 200, 0)\",C:\"rgb( 0,0,200)\",T:\"rgb(255,0,0)\",G:\"rgb(209,113, 5)\",N:\"rgb(80,80,80)\"};function Mc(e,t){if(e.length<6)return void console.log(\"Skipping line: \"+e.join(\" \"));var i={chr1:e[0],start1:Number.parseInt(e[1]),end1:Number.parseInt(e[2]),chr2:e[3],start2:Number.parseInt(e[4]),end2:Number.parseInt(e[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;t&&void 0===t.hiccups&&(t.hiccups=!!t.columnNames&&Dc(t.columnNames));const n=t&&t.hiccups,r=n?6:10;if(n||(e.length>6&&\".\"!==e[6]&&(i.name=e[6]),e.length>7&&\".\"!==e[7]&&(i.score=Number(e[7])),e.length>8&&\".\"!==e[8]&&(i.strand1=e[8]),e.length>9&&\".\"!==e[9]&&(i.strand2=e[9])),t){const n=t.colorColumn;n&&nr&&t.columnNames&&t.columnNames.length===e.length&&(i.extras=e.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function Rc(e,t){if(!(e.length<8))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),color:_s.createColorString(e[6]),value:Number(e[7])}}function Dc(e){return e&&(e.includes(\"fdrDonut\")||e.includes(\"fdr_donut\"))}function Tc(e,t){if(!(e.length<6))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),chr1:e[8],start1:Number.parseInt(e[9]),end1:Number.parseInt(e[10]),chr2:e[13],start2:Number.parseInt(e[14]),end2:Number.parseInt(e[15]),name:e[3],score:Number(e[4]),value:Number(e[5]),color:\".\"===e[7]?void 0:\"0\"===e[7]?\"rgb(0,0,0)\":e[7]};console.log(\"Skipping line: \"+e.join(\" \"))}class Lc{constructor(e){this.message=e}}const zc=new Map([[\"%09\",\"\\t\"],[\"%0A\",\"\\n\"],[\"%0D\",\"\\r\"],[\"%25\",\"%\"],[\"%3B\",\";\"],[\"%3D\",\"=\"],[\"%26\",\"&\"],[\"%2C\",\",\"]]);function Hc(e){if(!e.includes(\"%\"))return e;let t=\"\";for(let i=0;i0&&e2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3});let a=3;try{if(e.length>3&&a++0&&e[3].indexOf(\"=\")>0){const i=Pc(e[3],\"=\");o.attributes={};for(let e of i)o.attributes[e[0]]=e[1],null!=t.nameField&&e[0]===t.nameField&&(o.name=e[1])}o.name||(o.name=\".\"===e[3]?\"\":e[3])}if(e.length>4&&a++5&&a++6&&a++7&&a++8&&a++11&&a++1e3)return o;const i=e[10].replace(/,$/,\"\").split(\",\"),n=e[11].replace(/,$/,\"\").split(\",\");if(i.length!==n.length||t!==i.length)return o;const s=[];for(let e=0;e0&&(Yc(s,o.cdStart,o.cdEnd),o.exons=s)}if(t){let i=t.thicknessColumn,n=t.colorColumn;n&&n14&&(i.signal=Number(e[12]),i.pValue=Number(e[13]),i.qValue=Number(e[14])),i}function Qc(e,t){const i=Uc(e,t,9);if(i){const t=[\"Coverage\",\"% Showing Methylation\",\"N-mod\",\"N-canonical\",\"N-other mod\",\"N-delete\",\"N-fail\",\"N-dff\",\"N-nocall\"];for(let n=9;ni?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}function Xc(e,t){var i,n,r,s,o,a,c;if(!(e.length<9))return i=e[0],n=parseInt(e[1]),r=parseInt(e[2]),o=e[3],a=Number(e[4]),s=e[5].trim(),c=Number(e[6]),0===a&&(a=c),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:c,pValue:Number(e[7]),qValue:Number(e[8])}}function Zc(e,t){const i=Xc(e);return e.length>9&&(i.peak=Number(e[9])),i}function Jc(e,t){if(e.length<=3)return;const i={chr:e[0],start:parseInt(e[1]),end:parseInt(e[2]),value:Number(e[3])};if(t){let n=t.colorColumn;n&&n2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3}),a=[];for(let t=3;t\"),this.name&&t.push({name:\"Name\",value:this.name}),t.push({name:\"Type\",value:this.type}),t.push({name:\"Source\",value:this.source}),void 0!==this.score&&t.push({name:\"Score\",value:this.score}),t.push({name:\"Phase\",value:this.phase}),this.attributeString){const e=Pc(this.attributeString,this.delim);for(let[i,n]of e)void 0!==n&&n.length>0&&!ml.has(i.toLowerCase())&&t.push({name:i+\":\",value:n})}return t.push({name:\"Location\",value:`${this.chr}:${Rt(this.start+1)}-${Rt(this.end)}`}),t}getAttributeValue(e){if(this.hasOwnProperty(e))return this[e];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(e))return this._attributeCache.get(e);{const t=Pc(this.attributeString,this.delim);let i;for(let[n,r]of t)if(n===e){i=r;break}return this._attributeCache.set(e,i),i}}}class bl extends wl{constructor(e){super(e),this.exons=[],this.parts=[]}addExon(e){this.exons.push(e),this.start=Math.min(this.start,e.start),this.end=Math.max(this.end,e.end)}addPart(e){this.parts.push(e)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(e,t){return e.start-t.start}));let e=this.parts[0].start,t=this.parts[0].end;for(let i=1;i=t&&i.start<=e)return i}addCDS(e){let t;const i=this.exons;for(let n of i)if(n.start<=e.start&&n.end>=e.end){t=n;break}t?(t.cdStart=t.cdStart?Math.min(e.start,t.cdStart):e.start,t.cdEnd=t.cdEnd?Math.max(e.end,t.cdEnd):e.end,t.readingFrame=e.readingFrame):console.error(\"No exon found spanning \"+e.start+\"-\"+e.end),this.cdStart=this.cdStart?Math.min(e.start,this.cdStart):e.start,this.cdEnd=this.cdEnd?Math.max(e.end,this.cdEnd):e.end}addUTR(e){let t;const i=this.exons;for(let n=0;n=e.end){t=i[n];break}t?e.start===t.start&&e.end===t.end?t.utr=!0:(e.endt.start&&(t.cdEnd=e.start)):console.error(\"No exon found spanning \"+cds.start+\"-\"+cds.end)}finish(){this.assembleParts();var e=this.cdStart,t=this.cdEnd;this.exons.sort((function(e,t){return e.start-t.start})),e&&this.exons.forEach((function(i){(i.endt)&&(i.utr=!0)}))}popupData(e){const t=super.popupData(e);for(let i of this.exons)if(!i.pseudo&&e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}for(let i of this.parts)if(e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}return t}}function Fl(e,t){const i=t.format;if(e.length<9)return;const n=\"gff3\"===i?\"=\":\" \";return new wl({source:Hc(e[1]),type:e[2],chr:e[0],start:parseInt(e[3])-1,end:parseInt(e[4]),score:\".\"===e[5]?void 0:Number(e[5]),strand:e[6],phase:\".\"===e[7]?\".\":parseInt(e[7]),attributeString:e[8],delim:n})}function vl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):\"ID\"===e?i.id=t:\"Parent\"===e&&(i.parent=t)}return i}function yl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);let r,s;switch(i.type){case\"gene\":r=\"gene_id\";break;case\"transcript\":r=\"transcript_id\",s=\"gene_id\";break;default:s=\"transcript_id\"}for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):e===r?i.id=t:e===s&&(i.parent=t)}return i}function Al(e,t){if(!(e.length<7)){var i=e[0],n=e[1],r=parseInt(e[2]),s=parseInt(e[3]),o=parseInt(e[4]),a=parseInt(e[5]),c=e[6],l={chr:i,name:n,junction_left:r,junction_right:s,num_junction_reads:o,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=r,d=s;if(a>0)for(var u=c.split(\",\"),f=0;fd&&(d=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=d,l}}function Cl(e,t){if(e.length<7)return null;const i={chr:e[0],start:parseInt(e[1])-1,end:parseInt(e[2]),\"Strongest SNP-risk allele\":e[3],\"Disease/Phenotype\":e[4],\"P-value\":e[5],\"Odds ratio or beta\":e[6]};return e.length>6&&(i.PUBMEDID=`${e[7]}`),i}function _l(e,t){const i=t.customFormat;if(e.lengthvoid 0===n||!n.has(e.type))),\"gff3\"===this.format){const t=this.combineFeaturesById(e);i=this.combineFeaturesByType(t)}else i=this.combineFeaturesByType(e);return this.numberExons(i,t),this.nameFeatures(i),i}combineFeaturesById(e){const t=new Map,i=[];for(let n of e)if(gl(n.type)||pl(n.type)||!n.id)i.push(n);else{let e=t.get(n.chr);e||(e=new Map,t.set(n.chr,e));let i=e.get(n.id);i?i.push(n):e.set(n.id,[n])}for(let e of t.values())for(let t of e.values())if(t.length>1){const e=t[0];e.exons=[];for(let i of t)e.start=Math.min(e.start,i.start),e.end=Math.max(e.end,i.end),e.exons.push({start:i.start,end:i.end});i.push(e)}else i.push(t[0]);return i}combineFeaturesByType(e){const t=e.filter((e=>\"gene\"===e.type||e.type.endsWith(\"_gene\"))),i=Object.create(null);for(let e of t)i[e.id]=e;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;e=e.filter((e=>void 0===o||!o.has(e.type)));for(let t of e)if(pl(t.type)){const e=t.id;if(void 0!==e){const o=new bl(t);n[e]=o,r.push(o),s.add(t);const a=i[t.parent];a&&(o.geneObject=a,s.add(a))}}for(let t of e)if(gl(t.type)){const e=l(t);if(e)for(let i of e){let o=n[i];if(!o&&\"gtf\"===this.format){const e=Object.assign({},t);e.type=\"transcript\",o=new bl(e),n[i]=o,r.push(o)}if(void 0!==o){if(a=t.type,ll.has(a))if(e.length>1){const e=new wl(t);o.addExon(e)}else o.addExon(t);else o.addPart(t);s.add(t)}}}var a;r.forEach((function(e){\"function\"==typeof e.finish&&e.finish()}));const c=e.filter((e=>!s.has(e)));for(let e of c)r.push(e);return r;function l(e){return e.parent&&\"\"!==e.parent.trim()?e.parent.trim().split(\",\"):null}}numberExons(e,t){for(let i of e)if(i.exons&&(!t||i.end<=t.end&&i.start>t.start))for(let e=0;e1&&(t=e)}else{this.setDecoder(n.format);const e=i.split(this.delimiter||\"\\t\");try{const i=Object.assign({columnNames:t},n);if(this.decode(e,i))break;e.length>1&&(t=e)}catch(i){e.length>1&&(t=e)}}}if(t){n.columnNames=t;for(let e=0;e0&&console.error(`Error parsing line '${s}': ${c.message}`)):c&&t.push(c)}return i===Mc&&function(e){if(0==e.length)return;const t=e[0];if(void 0===t.score&&void 0!==t.name){for(let t of e)if(!Va(t.name)&&\".\"!==t.name)return;for(let t of e)t.score=Number(t.name),delete t.name}const i=e.filter((e=>e.chr1!==e.chr2));for(let t of i){const i=Object.assign({},t);i.dup=!0,e.push(i),t.chr=t.chr1,t.start=t.start1,t.end=t.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(t),\"gtf\"!==this.config.format&&\"gff3\"!==this.config.format&&\"gff\"!==this.config.format||!1===this.config.assembleGFF?t:new Il(this.config).combineFeatures(t)}setDecoder(e){switch(e){case\"broadpeak\":case\"regionpeak\":case\"peaks\":this.decode=Xc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"narrowpeak\":this.decode=Zc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedgraph\":this.decode=Jc,this.delimiter=/\\s+/;break;case\"wig\":this.decode=el,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gff3\":case\"gff\":this.decode=vl,this.delimiter=\"\\t\";break;case\"gtf\":this.decode=yl,this.delimiter=\"\\t\";break;case\"fusionjuncspan\":this.decode=Al,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gtexgwas\":this.skipRows=1,this.decode=Cl,this.delimiter=\"\\t\";break;case\"refflat\":this.decode=Gc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepred\":this.decode=jc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepredext\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"ensgene\":this.decode=jc,this.header.shift=1,this.delimiter=this.config.delimiter||/\\s+/;break;case\"refgene\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/,this.header.shift=1;break;case\"bed\":this.decode=Uc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gappedpeak\":this.decode=qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedmethyl\":this.decode=Qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedpe\":case\"hiccups\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-domain\":this.decode=Rc,this.headerLine=!0,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-loop\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\",this.header={colorColumn:7};break;case\"interact\":this.decode=Tc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"snp\":this.decode=tl,this.delimiter=\"\\t\";break;case\"rmsk\":this.decode=Vc,this.delimiter=\"\\t\";break;case\"gcnv\":this.decode=xl,this.delimiter=\"\\t\";break;case\"shoebox\":this.decode=il,this.delimiter=\"\\t\";break;default:const t=function(e){return Sl&&Sl[e]?function(e){const t=e.fields,i=[\"chr\",\"start\",\"end\"];for(let n=0;n4?parseInt(t[4].split(\"=\")[1],10):1,index:0}}function Rl(e){const t=e.split(/\\s+/);return{format:\"variableStep\",chrom:t[1].split(\"=\")[1],span:t.length>2?parseInt(t[2].split(\"=\")[1],10):1}}function Dl(t,i){const n=e({class:\"igv-menu-popup-check-container\"}),r=e();n.appendChild(r);const s=l(\"check\",!0===i?\"#444\":\"transparent\");r.appendChild(s);const o=e();return o.innerText=t,n.appendChild(o),n}function Tl(e,t){t=t||Number.MAX_SAFE_INTEGER;const i=[];e.sort((function(e,t){return e.start-t.start})),i.push(-1e3);for(let n of e){let e=0;const r=Math.min(i.length,t);for(e=0;e=i[e]){n.row=e,i[e]=n.end;break}n.row=e,i[e]=n.end}}async function Ll(e,t,i){const n=e=>{const i=Object.assign({},e);return i.chr=\"all\",i.start=t.getGenomeCoordinate(e.chr,e.start),i.end=t.getGenomeCoordinate(e.chr,e.end),i._f=e,i.exons&&delete i.exons,i},r=new Set(t.wgChromosomeNames),s=[];let o=0;for(let a of t.wgChromosomeNames){if(Array.isArray(e)){const i={};for(let n of e){const e=t.getChromosomeName(n.chr);i.hasOwnProperty(e)||(i[e]=[]),i[e].push(n)}e=i}const c=e[a];if(c){const e=i||1e4;for(let i of c){let a=t.getChromosomeName(i.chr);if(r.has(a))if(s.length0&&!i.startsWith(\"rgb(\")&&!i.startsWith(\"rgba(\")?`rgb(${i})`:i);var i;e.name||e.label?this.name=e.name||e.label:Ht(e.url)?this.name=e.url.name:Mt(e.url)&&!e.url.startsWith(\"data:\")&&(this.name=zt(e.url)),this.url=e.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=e.order,this.autoscaleGroup=e.autoscaleGroup,this.removable=void 0===e.removable||e.removable,this.minHeight=e.minHeight||Math.min(25,this.height),this.maxHeight=e.maxHeight||Math.max(1e3,this.height),e.onclick&&(this.onclick=e.onclick,e.onclick=void 0),e.description&&(\"function\"==typeof e.description?this.description=e.description:this.description=()=>e.description),e.hoverTextFields?this.hoverText=Pl.bind(this):\"function\"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(e){this._name=e,this.trackView&&this.trackView.setTrackLabelName(e)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}repaintViews(){this.trackView&&this.trackView.repaintViews()}getState(){const e={},t=Object.keys(this.config).filter((e=>{return!(void 0===(t=this.config[e])||\"function\"==typeof t||t instanceof Promise);var t}));for(const i of t)i.startsWith(\"_\")||(e[i]=this.config[i]);for(let t of Object.keys(e)){if(t.startsWith(\"_\"))continue;const i=this[t];void 0===i||!Oa(i)&&\"boolean\"!=typeof i&&\"metadata\"!==t||(e[t]=i)}const i=Object.assign({},Hl.defaults);if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))i[e]=this.constructor.defaults[e];for(let t of Object.keys(i))void 0!==this[t]&&i[t]!==this[t]&&(e[t]=this[t]);return!this.autoscale&&this.dataRange&&(e.min=this.dataRange.min,e.max=this.dataRange.max),this.autoscaleGroup&&(e.autoscaleGroup=this.autoscaleGroup),e}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(e){if(this.disposed)return;const t={};let i;for(let n of Object.keys(e))switch(n.toLowerCase()){case\"usescore\":t.useScore=1===e[n]||\"1\"===e[n]||\"on\"===e[n]||!0===e[n];break;case\"visibility\":switch(e[n]){case\"2\":case\"3\":case\"pack\":case\"full\":t.displayMode=\"EXPANDED\";break;case\"4\":case\"squish\":t.displayMode=\"SQUISHED\";break;case\"1\":case\"dense\":t.displayMode=\"COLLAPSED\"}break;case\"color\":case\"altcolor\":t[n]=e[n].startsWith(\"rgb(\")?e[n]:\"rgb(\"+e[n]+\")\";break;case\"featurevisiblitywindow\":case\"visibilitywindow\":t.visibilityWindow=Number.parseInt(e[n]);break;case\"maxheightpixels\":i=e[n].split(\":\"),3===i.length&&(t.minHeight=Number.parseInt(i[2]),t.height=Number.parseInt(i[1]),t.maxHeight=Number.parseInt(i[0]));break;case\"viewlimits\":if(!this.config.autoscale){i=e[n].split(\":\");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),Number.isNaN(r)||Number.isNaN(s)?console.warn(`Unexpected viewLimits value in track line: ${e.viewLimits}`):(t.autoscale=!1,t.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r)}case\"name\":t[n]=e[n];break;case\"url\":t.infoURL=e[n];break;case\"type\":const r=e[n];Ol.has(r)?t[n]=Ol.get(r):t[n]=r;break;case\"graphtype\":t.graphType=e[n];break;default:t[n]=e[n]}for(let e of Object.keys(t))if(!this.config.hasOwnProperty(e)||\"name\"===e&&this.config._derivedName){let i=t[e];if(\"true\"===i&&(i=!0),\"false\"===i&&(i=!1),this[e]=i,\"height\"===e&&this.trackView)try{const e=Number.parseInt(i);this.trackView.setTrackHeight(e)}catch(e){console.error(e)}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!Array.isArray(t)||0===t.length)return[];const i=e.genomicLocation,n=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2;return to(t,i-n,i+n)}extractPopupData(e,t){const i=new Set([\"row\",\"color\",\"chr\",\"start\",\"end\",\"cdStart\",\"cdEnd\",\"strand\",\"alpha\"]),n=[];let r,s;for(let t in e)if(e.hasOwnProperty(t)&&!i.has(t)&&Oa(e[t])){let i=e[t];n.push({name:Lt(t),value:i}),\"alleles\"===t?r=e[t]:\"alleleFreqs\"===t&&(s=e[t])}if(r&&s){r.endsWith(\",\")&&(r=r.substr(0,r.length-1)),s.endsWith(\",\")&&(s=s.substr(0,s.length-1));let i=r.split(\",\"),o=s.split(\",\");if(o.length>1){let r=[];for(let e=0;e=0;i--){let o=r[i].a;if(1===o.length){t||(t=this.getGenomeId());const i=Hl.getCravatLink(e.chr,e.start+1,s,o,t);console.log(i),i&&(n.push(\"
\"),n.push({html:i}),n.push(\"
\"))}}}}if(e.attributes)for(let t of Object.keys(e.attributes))n.push({name:t,value:e.attributes[t]});let o=`${e.chr}:${Rt(e.start+1)}-${Rt(e.end)}`;return e.strand&&(o+=` (${e.strand})`),n.push({name:\"Location\",value:o}),n}description(){const e=(e,t)=>`
${e}: ${t}
`;let t='
';if(this.url?Ht(this.url)?t+=e(\"Filename\",this.url.name):t+=e(\"URL\",this.url):t=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata)){t+=e(i,this.config.metadata[i])}for(let i of Object.keys(this.config)){if(i.startsWith(\"_\"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&Oa(n)&&(t+=e(i,n))}}}return t+=\"
\",t}getColorForFeature(e){return\"function\"==typeof this.color?this.color(feature):this.color}numericDataMenuItems(){const e=[];e.push(\"
\");let t=Bt(\"
\");if(t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),void 0!==this.logScale){function i(){this.logScale=!this.logScale,this.trackView.repaintViews()}t=Bt(Dl(\"Log scale\",this.logScale)),e.push({object:t,click:i})}return t=Bt(Dl(\"Autoscale\",this.autoscale)),e.push({object:t,click:function(){this.autoscaleGroup=void 0,this.autoscale=!this.autoscale,this.browser.updateViews()}}),e}setDataRange({min:e,max:t}){this.dataRange={min:e,max:t},this.autoscale=!1,this.autoscaleGroup=void 0,this.trackView.repaintViews()}async nextFeatureAfter(e,t,i){let n=this.trackView.viewports[0].cachedFeatures;if(n&&Array.isArray(n)&&n.length>0){if(this.browser.genome.getChromosomeName(n[0].chr)===e){const e=function(e,t,i=!0){const n=e=>(e.start+e.end)/2,r=i?(e,t)=>e.start-t.start+e.end-t.end:(e,t)=>t.start-e.start+t.end-e.end,s=Array.from(e);s.sort(r);let o=0,a=s.length;for(;o=t?o=e+1:a=e}return s[o]}(n,t,i);if(e)return e}}if(\"function\"==typeof this.featureSource.nextFeature)return this.featureSource.nextFeature(e,t,i,this.visibilityWindow)}dispose(){this.disposed=!0;for(let e of Object.keys(this))this[e]=void 0}static getCravatLink(e,t,i,n,r){if(\"hg38\"===r||\"GRCh38\"===r){return`Cravat ${i}->${n}`}}static localFileInspection(e){const t=Object.assign({},e),i={url:\"file\",indexURL:\"indexFile\"};for(const e of[\"url\",\"indexURL\"])t[e]&&t[e]instanceof File&&(t[i[e]]=t[e].name,delete t[e]);return t}}function Pl(e){if(!this.hoverTextFields)return;const t=this.clickedFeatures(e);if(t&&t.length>0){let e=\"\";for(let i=0;i0&&(e+=\"\\n\"),e=\"\";for(let t of this.hoverTextFields)e.length>0&&(e+=\"\\n\"),n.hasOwnProperty(t)?e+=n[t]:\"function\"==typeof n.getAttribute&&(e+=n.getAttribute(t))}return e}}const Ol=new Map([[\"wiggle_0\",\"wig\"],[\"bed\",\"bed\"],[\"bigBed\",\"bigBed\"],[\"bigWig\",\"bigWig\"]]);class Ul{constructor(e){switch(this.type=e||\"seg\",this.type){case\"mut\":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case\"maf\":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(e){let t;for(;void 0!==(t=await e.nextLine());)if(!t.startsWith(\"#\")){const e=t.split(\"\\t\");this.header={headings:e};break}return this.header}async parseFeatures(e){const t=[];let i;this.header||(this.header=await this.parseHeader(e)),\"seg\"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await e.nextLine());){const e=r.split(\"\\t\"),s=\"seg\"===this.type?Number(e[this.dataColumn]):e[this.dataColumn];if(e.length>this.dataColumn){const r=new ql({sample:e[this.sampleColumn],chr:e[this.chrColumn],start:parseInt(e[this.startColumn])-1,end:parseInt(e[this.endColumn]),value:s,valueColumnName:n});if(i){const t=this.extractExtraColumns(e);r.setAttributes({names:i,values:t})}t.push(r)}}return t}extractExtraColumns(e){const t=[];for(let i=0;i=0)return this.attributeValues[t]}}popupData(e,t){const i=new Set([\"chr\",\"start\",\"end\",\"sample\",\"value\",\"row\",\"color\",\"sampleKey\",\"uniqueSampleKey\",\"sampleId\",\"chromosome\",\"uniquePatientKey\"]),n=this.chr+\":\"+Rt(this.start+1)+\"-\"+Rt(this.end),r=[{name:\"Sample\",value:this.sample},{name:\"Location\",value:n},{name:this.valueColumnName?Lt(this.valueColumnName):\"Value\",value:this.value}];if(\"mut\"===e&&\"hg38\"===t){const e=this.extractCravatLink(t);e&&(r.push(\"
\"),r.push({html:e}),r.push(\"
\"))}if(this.attributeNames&&this.attributeNames.length>0)for(let e=0;e0)for(let n=0;n\"===t||\"<*>\"===t||\".\"===t)return\"NONVARIANT\";{const e=t.split(\",\").map((function(e){return 1===i&&1===e.length?\"SNP\":\"\"===e?\"NONVARIANT\":e.length>i&&$l(e)?\"INSERTION\":e.lengthe.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let t of i)if(this.alleles.push(t),\"SV\"!==this.type&&$l(t)){let i=t.length,n=e.length;const r=Math.min(i,n);let s=0;for(;s0&&n>0;){const r=s+i-1,o=s+n-1;if(t.charCodeAt(r)!==e.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(t.charCodeAt(r)!==e.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos),this.start===this.end&&(this.start-=.5,this.end+=.5)}}popupData(e,t){const i=`${Rt(this.pos)}`,n=this.start===this.end?`${Rt(this.start)} | ${Rt(this.start+1)}`:`${Rt(this.start+1)}-${Rt(this.end)}`,r=[{name:\"Chr\",value:this.chr},{name:\"Pos\",value:i},{name:\"Loc\",value:n},{name:\"ID\",value:this.names?this.names:\"\"},{name:\"Ref\",value:this.referenceBases},{name:\"Alt\",value:this.alternateBases.replace(\"<\",\"<\")},{name:\"Qual\",value:this.quality},{name:\"Filter\",value:this.filter}];if(this.type&&r.push({name:\"Type\",value:this.type}),\"SNP\"===this.type){let e=this.referenceBases;if(1===e.length){let i=this.alternateBases.split(\",\");for(let n of i)if(1===n.length){let i=Hl.getCravatLink(this.chr,this.pos,e,n,t);i&&(r.push(\"
\"),r.push({html:i}))}}}const s=Object.keys(this.info);if(this.info&&s.length>0){r.push({html:'
'});for(let e of s)r.push({name:e,value:Kl(decodeURIComponent(this.info[e]))})}return r}getInfo(e){return this.info?this.info[e]:void 0}isRefBlock(){return\"NONVARIANT\"===this.type}isFiltered(){return!(\".\"===this.filter||\"PASS\"===this.filter)}alleleFreq(){return this.info?this.info.AF:void 0}}class jl{constructor(e){this.mate=e,this.chr=e.info.CHR2,this.pos=Number.parseInt(e.info.END),this.start=this.pos-1,this.end=this.pos}get info(){return this.mate.info}get names(){return this.mate.names}get referenceBases(){return this.mate.referenceBases}get alternateBases(){return this.mate.alternateBases}get quality(){return this.mate.quality}get filter(){return this.mate.filter}get calls(){return this.mate.calls}getAttributeValue(e){return this.mate.getAttributeValue(e)}getInfo(e){this.mate.getInfo(e)}isFiltered(){return this.mate.isFiltered()}alleleFreq(){return this.mate.alleleFreq()}popupData(e,t){const i=[];return i.push(\"SV Breakpoint\"),i.push({name:\"Chr\",value:this.chr}),i.push({name:\"Pos\",value:`${Rt(this.pos)}`}),i.push({html:'
'}),i.push(\"SV\"),i.push(...this.mate.popupData(e,t)),i}}class Wl{constructor({formatFields:e,sample:t,token:i}){this.info={},this.sample=t;const n=i.split(\":\");for(let t=0;t\");for(let e of r)i.push({name:e,value:decodeURIComponent(this.info[e])});return i}}const Gl=new Set([\"A\",\"C\",\"T\",\"G\"].map((e=>e.charCodeAt(0))));function $l(e){for(let t=0;t\");if(!(t>2&&o>0)){console.log(\"Malformed VCF header line: \"+n);continue}const a=n.substring(2,t-1);i[a]||(i[a]={});const c=Tt(n.substring(t+1,o-1),\",\");for(let t of c){var r=t.split(\"=\");r.length>1&&(\"ID\"===r[0]?e=r[1]:s[r[0]]=r[1])}e&&(i[a][e]=s)}else if(n.startsWith(\"##contig\")&&t){const e=n.indexOf(\"\",e));const s=n.substring(e+4,r),o=t.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith(\"#CHROM\")){const e=n.split(\"\\t\");if(e.length>8){i.sampleNameMap=new Map;for(let t=9;t9){const r=Xl(e[8].split(\":\"));n.calls=[];for(let t=9;t{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))0||0==i.length||i.indexOf(\"x\")>0)continue;const s=e[this.chrCol],o=r(e[this.valueCol]),a=parseInt(i)-1,c=a+1;t.push(new eh({chr:s,start:a,end:c,value:o,line:n,columns:this.columns}))}}return t}static isGWAS(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class eh{constructor({chr:e,start:t,end:i,value:n,line:r,columns:s}){this.chr=e,this.start=t,this.end=i,this.value=n,this.line=r,this.columns=s}popupData(){const e=this.line.split(/\\t/);return this.columns.map((function(t,i){return{name:t,value:e[i]}}))}getAttribute(e){const t=this.line.split(/\\t/);for(let i=0;i0?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split(\"=\",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();t[e]=i}}return t}function ah(e){let t={},i=e.split(/\\s+/);if(2===i.length){i[1].split(\";\").forEach((function(e){let i=e.split(\"=\");\"color\"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:\"thickness\"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function ch(e,t){var i,n,r=e.columns;this.aed=e,this.allColumns=t,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=\".\",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let e=0;e0)for(let e=0;ee.maxv.isGreaterThan(t))));const i=[];let n;for(let t of e)n&&dh(n,t)?t.maxv.isGreaterThan(n.maxv)&&(n.maxv=t.maxv):(i.push(t),n=t);return i}function dh(e,t){const i=t.minv.block-e.maxv.block;return t.maxv.block-e.minv.block<5e6&&i<65e3}ch.prototype.popupData=function(){for(var e=[],t=this.aed,i=0;i=28){t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt();const e=t.getInt(),i=t.position+e;let r=0;for(;t.positions)t.getInt(),t.getVPointer(),t.getVPointer(),t.getLong(),t.getLong();else{i[e]=[];const n=t.getInt();for(let s=0;sr&&(r=s.block),i[e].push([n,s]))}}}o>0&&(this.indices[e]={binIndex:i,loffset:n})}this.lastBlockPosition=r}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=this.reg2bins(t,i);if(0==e.length)return[];const r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let i of t){const t=i[0],n=i[1];r.push({minv:t,maxv:n,bin:e})}}let s=e[this.depth][0];do{if(n.binIndex[s])break;s>1+(this.getParentBin(s)<<3)?s--:s=this.getParentBin(s)}while(0!=s);return hh(r,n.loffset[s])}return[]}getParentBin(e){return 0==e?0:e-1>>3}reg2bins(e,t){(e-=1)<1&&(e=1),t>2**34&&(t=2**34),t-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(e>>r),o=n+(t>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class fh{constructor(){}async parse(e,t){const i=[];let n=Number.MAX_SAFE_INTEGER,r=0;const s=new yc(new DataView(e)),o=s.getInt(),a={};if(!(21578050===o||t&&21578324===o))throw new Error(indexURL+\" is not a \"+(t?\"tabix\":\"bai\")+\" file\");{const e=s.getInt();if(t){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let t=0;tr&&(r=o.block),e[t].push([i,o]))}}}const c=s.getInt();for(let e=0;e0&&(i[t]={binIndex:e,linearIndex:o})}this.firstBlockPosition=n,this.lastBlockPosition=r,this.indices=i,this.sequenceIndexMap=a,this.tabix=t}}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=function(e,t){const i=[];t>=1<<29&&(t=1<<29);return--t,i.push([0,0]),i.push([1+(e>>26),1+(t>>26)]),i.push([9+(e>>23),9+(t>>23)]),i.push([73+(e>>20),73+(t>>20)]),i.push([585+(e>>17),585+(t>>17)]),i.push([4681+(e>>14),4681+(t>>14)]),i}(t,i),r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let e of t){const t=e[0],i=e[1];r.push({minv:t,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(t>>14,s-1),c=Math.min(i>>14,s-1);for(let e=a;e<=c;e++){const t=n.linearIndex[e];if(t){o=t;break}}return hh(r,o)}return[]}}class ph{constructor(){this.tribble=!0}async parse(e){let t=0;this.chrIndex={},this.lastBlockPosition=[];const i=new yc(new DataView(e));!function(e){e.getInt(),e.getInt();const t=e.getInt();if(e.getString(),e.getLong(),e.getLong(),e.getString(),e.getInt(),t>=3){let t=e.getInt();for(;t-- >0;)e.getString(),e.getString()}}(i);let n=i.getInt();for(;n-- >0;){let e=i.getString();const n=i.getInt(),r=i.getInt(),s=i.getInt();i.getInt(),i.getInt();let o=i.getLong();const a=[];for(let e=0;et&&(t=e)}this.chrIndex[e]={chr:e,blocks:a,longestFeature:s,binWidth:n}}this.lastBlockPosition=t}get sequenceNames(){return Object.keys(this.chrIndex)}chunksForRange(e,t,i){const n=this.chrIndex[e];if(n){const e=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(t-r,0),a=Math.floor(o/s);if(a>=e.length)return[];{const t=Math.min(Math.floor((i-1)/s),e.length-1),n=e[a].min,r=e[t].max;if(0===r-n)return[];return[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function gh(e,t){let i=await Qs.loadArrayBuffer(e,Ua(t)),n=new DataView(i);if(31===n.getUint8(0)&&139===n.getUint8(1)){i=gs(i).buffer,n=new DataView(i)}switch(n.getInt32(0,!0)){case 21578050:return async function(e){const t=new fh;return await t.parse(e,!1),t}(i);case 21578324:return async function(e){const t=new fh;return await t.parse(e,!0),t}(i);case 21582659:return async function(e){const t=new uh;return t.parse(e),t}(i);case 1480870228:return async function(e){const t=new ph;return t.parse(e),t}(i);case 38359875:throw Error(\"CSI version 2 is not supported.\");default:throw Error(`Unrecognized index type: ${e}`)}}function mh(e){return\"string\"==typeof e||e instanceof String?new wh(e):new bh(e)}class wh{constructor(e){this.data=e,this.ptr=0}nextLine(){var e=this.ptr,t=this.data.indexOf(\"\\n\",e),i=this.data;if(t>0)return this.ptr=t+1,t>e&&\"\\r\"===i.charAt(t-1)?i.substring(e,t-1):i.substring(e,t);var n=i.length;return this.ptr=n,e>=n?void 0:i.substring(e)}}class bh{constructor(e){this.data=e,this.length=this.data.length,this.ptr=0}nextLine(){if(this.ptr>=this.data.length)return;let e=this.ptr;const t=this.data;let i=\"\",n=!1;for(;e0)for(var a=0;a{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])};class yh{constructor(e){this.config=e,this.cacheBlocks=0!=e.cacheBlocks,this.cache=void 0}async getData(e,t){const i=e.block,n=t.block,r=0===t.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const e of s)o+=e.byteLength;const a=new Uint8Array(o);let c=0;for(const e of s)a.set(e,c),c+=e.byteLength;return a}async getInflatedBlocks(e,t,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=e&&(n.endBlock>=t||i&&n.nextEndBlock===t)){const i=e-n.startBlock,r=t-n.startBlock;return Ch(n.buffer,i,r)}{let r;if(!n||n.startBlock>t||n.endBlock=n.endBlock)o=n.buffer;else{const i=Math.max(0,e-n.startBlock);let r;if(t>=n.endBlock)r=n.buffer.byteLength;else{const e=Ah(n.buffer);for(let i=0;in.endBlock){const e=await this.loadBLockData(n.endBlock,t,{skipStart:!0,skipEnd:i});s.push(e)}r=function(e){if(1===e.length)return e[0];let t=0;for(const i of e)t+=i.byteLength;const i=new Uint8Array(t);let n=0;for(const t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(s)}let s=t;if(i){const e=Ah(r);t=e[e.length-1]}return this.cache={startBlock:e,endBlock:t,nextEndBlock:s,buffer:r},Ch(r)}}return Ch(await this.loadBLockData(e,t,{skipEnd:i}))}async loadBLockData(e,t,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!(i&&i.skipEnd)){const e=Ua(n,{range:{start:t,size:26}}),i=await Qs.loadArrayBuffer(n.url,e);s=vh(i)}if(r){const t=Ua(n,{range:{start:e,size:26}}),i=await Qs.loadArrayBuffer(n.url,t);e+=vh(i)}const o=Ua(n,{range:{start:e,size:t+s-e}});return Qs.loadArrayBuffer(n.url,o)}}function Ah(e){const t=e.byteLength;let i=0;const n=[0];for(;i{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))<_h)return Number.MIN_VALUE}return Number(e)};for(;void 0!==(n=e.nextLine());){const e=n.split(this.delimiter);if(e.length===this.columns.length){const i=e[this.posColumn];if(i.indexOf(\";\")>0||0==i.length||i.indexOf(\"x\")>0)continue;const n=e[this.chrColumn],s=r(e[this.pValueColumn]),o=parseInt(i)-1,a=o+1,c=e[this.snpColumn],l=e[this.phenotypeColumn],h=new kh({chr:n,start:o,end:a,pValue:s,snp:c,phenotype:l},this.columns,e);t.push(h)}}return t}static isQTL(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"],[\"rsid\",\"variant\",\"snp\"],[\"phenotype\",\"gene\",\"gene_id\",\"molecular_trait_id\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class kh{constructor({chr:e,start:t,end:i,pValue:n,snp:r,phenotype:s},o,a){this.chr=e,this.start=t,this.end=i,this.pValue=n,this.snp=r,this.phenotype=s,this.headers=o,this.tokens=a}popupData(){const e=[];for(let t=0;te.blocks)).map((e=>e.max)).reduce(((e,t)=>Math.min(e,t)),Number.MAX_SAFE_INTEGER),n=Ua(this.config,{bgz:e.tabix,range:{start:0,size:i}});t=mh(await Qs.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(t),this.header}if(\"service\"!==this.config.sourceType){let e;if(this.config._filecontents)e=this.config._filecontents,delete this.config._filecontents;else{const t=Ua(this.config);e=await Qs.loadByteArray(this.config.url,t)}e.length<5e8&&(e=(new TextDecoder).decode(e));let t=mh(e);this.header=await this.parser.parseHeader(t),t=mh(e),this.features=await this.parser.parseFeatures(t),this.sequenceNames=new Set;for(let e of this.features)this.sequenceNames.add(e.chr);return this.header}if(this.config.seqnamesURL){const e=Ua(this.config,{}),t=await Qs.loadString(this.config.seqnamesURL,e);t&&(this.sequenceNames=new Set(t.split(\",\").map((e=>e.trim())).filter((e=>e))))}if(this.config.headerURL){const e=Ua(this.config,{}),t=mh(await Qs.loadString(this.config.headerURL,e));return this.header=await this.parser.parseHeader(t),this.header}}getParser(e){switch(e.format){case\"vcf\":return new Yl(e);case\"seg\":return new Ul(\"seg\");case\"mut\":return new Ul(\"mut\");case\"maf\":return new Ul(\"maf\");case\"gwas\":return new Jl(e);case\"qtl\":return new xh(e);case\"aed\":return new nh(e);default:return new El(e)}}async loadFeaturesNoIndex(){if(this.features){const e=this.features;return delete this.features,e}{const e=Ua(this.config),t=await Qs.loadByteArray(this.config.url,e);if(!this.header){const e=mh(t);this.header=await this.parser.parseHeader(e)}const i=mh(t),n=[];return await this._parse(n,i),n}}async loadFeaturesWithIndex(e,t,i){const n=this.config;this.parser;const r=this.index.tabix,s=r?this.index.sequenceIndexMap[e]:e;if(void 0===s)return[];const o=this.index.chunksForRange(s,t,i);if(o&&0!==o.length){const s=[];for(let a of o){let o;if(r)o=await this._blockLoader.getData(a.minv,a.maxv);else{const e=Ua(n,{range:{start:a.minv.block,size:a.maxv.block-a.minv.block+1}});o=await Qs.loadString(n.url,e)}const c=mh(a.minv.offset?o.slice(a.minv.offset):o);await this._parse(s,c,e,i,t)}return s}return[]}async loadFeaturesFromService(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);const r=Ua(this.config),s=mh(await Qs.loadString(n,r)),o=[];return await this._parse(o,s),o}async _parse(e,t,i,n,r){let s=await this.parser.parseFeatures(t);if(s.sort((function(e,t){return e.chr===t.chr?e.start-t.start:e.chr.localeCompare(t.chr)})),void 0===i)for(let t of s)e.push(t);else{let t=!1;for(let o=0;on){e.push(a);break}a.end>=r&&a.start<=n&&(t||(t=!0,o>0&&e.push(s[o-1])),e.push(a))}}}}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return gh(this.config.indexURL,this.config)}async loadFeaturesFromDataURI(){if(this.features){const e=this.features;return delete this.features,e}{const e=vs(this.dataURI);let t=mh(e);this.header=await this.parser.parseHeader(t),this.header instanceof String&&this.header.startsWith(\"##gff-version 3\")&&(this.format=\"gff3\"),t=mh(e);const i=[];return await this._parse(i,t),i}}}const Sh=Mt;class Eh{constructor(e){this.config=e}async readFeatures(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&(\"function\"==typeof this.config.body?s.body=this.config.body({chr:e,start:t,end:i}):s.body=this.config.body.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i));const o=await Qs.load(n,s);if(o&&(r=\"function\"==typeof this.config.parser?this.config.parser(o):Sh(o)?JSON.parse(o):o),this.config.mappings){let e=Object.keys(this.config.mappings);for(let t of r)for(let i of e)t[i]=t[this.config.mappings[i]]}return r}}const Nh=function(e,t){this.config=e,this.genome=t,this.expandQueryInterval=!1};Nh.prototype.readFeatures=function(e,t,i){const n=Math.max(0,Math.floor(t));let r=Math.ceil(i);if(this.genome){const t=this.genome.getChromosome(e);t&&r>t.bpLength&&(r=t.bpLength)}const s=this.config.url+\"?db=\"+this.config.db+\"&table=\"+this.config.tableName+\"&chr=\"+e+\"&start=\"+n+\"&end=\"+r;return Qs.loadJson(s,this.config).then((function(e){return e?(e.forEach((function(e){e.hasOwnProperty(\"exonStarts\")&&e.hasOwnProperty(\"exonEnds\")&&e.hasOwnProperty(\"exonCount\")&&e.hasOwnProperty(\"cdsStart\")&&e.hasOwnProperty(\"cdsEnd\")&&function(e){var t,i,n,r,s,o;t=e.exonCount,i=e.exonStarts.split(\",\"),n=e.exonEnds.split(\",\"),r=[];for(var a=0;ao||e.cdsEnd=s&&e.cdsStart<=o&&(c.cdStart=e.cdsStart),e.cdsEnd>=s&&e.cdsEnd<=o&&(c.cdEnd=e.cdsEnd),r.push(c)}e.exons=r}(e)})),e):null}))};class Bh{featureCaches=[];gtexChrs=new Set([\"chr1\",\"chr10\",\"chr11\",\"chr12\",\"chr13\",\"chr14\",\"chr15\",\"chr16\",\"chr17\",\"chr18\",\"chr19\",\"chr2\",\"chr20\",\"chr21\",\"chr22\",\"chr3\",\"chr4\",\"chr5\",\"chr6\",\"chr7\",\"chr8\",\"chr9\",\"chrM\",\"chrX\",\"chrY\"]);constructor(e){this.config=e,this.url=e.url,this.tissueId=e.tissueSiteDetailId,this.datasetId=e.datasetId||\"gtex_v8\"}async readFeatures(e,t,i){const n=e.startsWith(\"chr\")?e:\"MT\"===e?\"chrM\":\"chr\"+e;if(!this.gtexChrs.has(n))return[];const r=Math.floor(t),s=Math.ceil(i),o=this.datasetId,a=this.url+\"?chromosome=\"+n+\"&start=\"+r+\"&end=\"+s+\"&tissueSiteDetailId=\"+this.tissueId+\"&datasetId=\"+o,c=await Qs.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?c.singleTissueEqtl.map((e=>new Mh(e))):[]}}class Mh{constructor(e){this.chr=e.chromosome,this.start=e.pos-1,this.end=this.start+1,this.snp=e.snpId,this.phenotype=e.geneSymbol,this.pValue=e.pValue,this.json=e}popupData(){return Object.keys(this.json).map((e=>({name:e,value:this.json[e]})))}}class Rh{constructor(e,t){if(this.config=e,this.genome=t,!e.format)throw Error('Format is required, and must be either \"bam\" or \"cram\"');if(this.format=e.format.toUpperCase(),\"BAM\"!==this.format&&\"VCF\"!==this.format)throw Error(`htsget format ${e.format} is not supported`)}async readHeaderData(){const e=`${Dh(this.config)}?class=header&format=${this.format}`,t=await Qs.loadJson(e,Ua(this.config));return await this.loadUrls(t.htsget.urls)}async readData(e,t,i){const n=`${Dh(this.config)}?format=${this.format}&referenceName=${e}&start=${Math.floor(t)}&end=${Math.ceil(i)}`,r=await Qs.loadJson(n,Ua(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(e){const t=[];for(let i of e)if(i.url.startsWith(\"data:\"))t.push(Promise.resolve(Th(i.url)));else{const e=Ua(this.config||{});i.headers&&(e.headers=Object.assign(e.headers||{},i.headers)),t.push(Qs.loadArrayBuffer(i.url,e))}return function(e){let t=0;for(let i of e)t+=i.byteLength;let i=0;const n=new Uint8Array(t);for(let t of e){const e=new Uint8Array(t);n.set(e,i),i+=e.length}return n}(await Promise.all(t))}static async inferFormat(e){try{const t=Dh(e),i=`${t}${t.includes(\"?\")?\"&\":\"?\"}class=header`,n=await Qs.loadJson(i,Ua(e));if(n.htsget){const t=n.htsget.format;if(\"BAM\"!==t&&\"VCF\"!==t)throw Error(`htsget format ${t} is not supported`);e.format=t.toLowerCase(),e.sourceType=\"htsget\",e.name||(e.name=await ja(e.url))}}catch(e){}}}function Dh(e){if(e.url&&e.endpoint&&e.id)return e.url+e.endpoint+e.id;if(e.endpoint&&e.id)return e.endpoint+e.id;if(e.url)return e.url.startsWith(\"htsget://\")?e.url.replace(\"htsget://\",\"https://\"):e.url;throw Error(\"Must specify either 'url', or 'endpoint' and 'id\")}function Th(e){const t=e.split(\",\"),i=t[0].split(\":\")[1];let n=t[1];n=i.indexOf(\"base64\")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>t[e])).filter((e=>this.sequenceNames.has(e)));n.length>0&&(i=n[0]),this.chrAliasTable.set(e,i)}else this.chrAliasTable.set(e,void 0)}return this.chrAliasTable.get(e)}}class Hh{constructor(e){this.genome=e}async nextFeature(e,t,i,n){let r=this.genome.chromosomeNames||[e],s=r.indexOf(e);if(s<0)return;const o=Math.min(1e4,n||1e4);let a=i?t:Math.max(t-o,0);for(;s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=i?a+o:Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=2){let e=t.getInt();for(this.windowFunctions=[];e-- >0;)this.windowFunctions.push(t.getString())}this.trackType=t.getString(),this.trackLine=t.getString();let i=t.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(t.getString());this.genomeID=t.getString(),this.flags=t.getInt(),this.compressed=!!(1&this.flags),e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:this.indexPos,size:this.indexSize}})),t=new yc(new DataView(e)),this.datasetIndex={};let n=t.getInt();for(;n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.datasetIndex[e]={position:i,size:n}}for(this.groupIndex={},n=t.getInt();n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.groupIndex[e]={position:i,size:n}}return this}async readDataset(e,t,i){const n=e+\"_\"+t+\"_\"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?\"\":\"/\"+t,s=\"all\"===e.toLowerCase()||void 0===i?\"0\":i.toString();let o;o=\"raw\"===t?\"/\"+e+\"/raw\":\"/\"+e+\"/z\"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const c=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new yc(new DataView(c));let h=l.getInt();const d={};for(;h-- >0;)d[l.getString()]=l.getString();const u=l.getString(),f=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:o,attributes:d,dataType:u,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const e=this.genome,t=this.groupCache[\"/\"];if(t)return t;{const t=await this.readGroup(\"/\"),i=t.chromosomes,n=t.maxZoom;n&&(this.maxZoom=Number(n));const r=t.totalCount;r&&(t.totalCount=Number(r));const s={};return i&&i.split(\",\").forEach((function(t){const i=e.getChromosomeName(t);s[i]=t})),this.chrAliasTable=s,this.groupCache[\"/\"]=t,t}}async readGroup(e){const t=this.groupCache[e];if(t)return t;{await this.readHeader();const t=this.groupIndex[e];if(void 0===t)return;const i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:t.position,size:t.size}}));if(!i)return;const n=new yc(new DataView(i)),r={name:e};let s=n.getInt();for(;s-- >0;){const e=n.getString(),t=n.getString();r[e]=t}return this.groupCache[e]=r,r}}async readTiles(e,t){if(e.sort((function(e,t){return e.position-t.position})),0===(e=e.filter((function(e){return e.size>0}))).length)return[];const i=[];for(let n of e){const e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:n.position,size:n.size}}));let r;try{r=this.compressed?ls(e).buffer:e}catch(e){console.error(e);continue}const s=new yc(new DataView(r)),o=s.getString();let a;switch(o){case\"fixedStep\":a=Oh(s,t);break;case\"variableStep\":a=Uh(s,t);break;case\"bed\":case\"bedWithName\":a=qh(s,t,o);break;default:throw\"Unknown tile type: \"+o}i.push(a)}return i}async readTile(e,t){let i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e.position,size:e.size}}));if(this.compressed){i=ls(i).buffer}const n=new yc(new DataView(i)),r=n.getString();switch(r){case\"fixedStep\":return Oh(n,t);case\"variableStep\":return Uh(n,t);case\"bed\":case\"bedWithName\":return qh(n,t,r);default:throw\"Unknown tile type: \"+r}}}function Oh(e,t){const i=e.getInt(),n=e.getInt(),r=e.getFloat(),s=[];let o=t;for(;o-- >0;){let t=i;const n=[];for(;t-- >0;)n.push(e.getFloat());s.push(n)}return{type:\"fixedStep\",start:n,span:r,data:s,nTracks:t,nPositions:i}}function Uh(e,t){const i=e.getInt(),n=e.getFloat(),r=e.getInt(),s=[];let o=r;for(;o-- >0;)s.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){o=r;const t=[];for(;o-- >0;)t.push(e.getFloat());a.push(t)}return{type:\"variableStep\",tileStart:i,span:n,start:s,data:a,nTracks:t,nPositions:r}}function qh(e,t,i){const n=e.getInt();let r=n;const s=[];for(;r-- >0;)s.push(e.getInt());r=n;const o=[];for(;r-- >0;)o.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){let t=n;const i=[];for(;t-- >0;)i.push(e.getFloat());a.push(i)}if(\"bedWithName\"===i){r=n;const t=[];for(;r-- >0;)t.push(e.getString())}return{type:i,start:s,end:o,data:a,nTracks:t,nPositions:n}}class Qh extends Hh{#h={};searchable=!1;constructor(e,t){super(t),this.genome=t,this.reader=new Ph(e,t),this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r=\"mean\"}){return\"all\"===e.toLowerCase()?this.getWGValues(r,n):this._getFeatures(e,t,i,n,r)}async _getFeatures(e,t,i,n,r){const s=new hc(e,t,i),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const e=this.rootGroup.totalCount;e&&(this.normalizationFactor=1e6/e)}s.bpPerPixel=n;const a=function(e,t,i){var n=i.getChromosome(e).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*t)))/Gh)}(e,n,o);let c=this.reader.chrAliasTable[e],l=this.reader.maxZoom;void 0===c&&(c=e),void 0===l&&(l=-1);const h=a>l?\"raw\":r,d=await this.reader.readDataset(c,h,a);if(null==d)return[];const u=d.tileWidth,f=Math.floor(t/u),p=Math.floor(i/u),g=await this.reader.readTiles(d.tiles.slice(f,p+1),1),m=[];for(let r of g)switch(r.type){case\"bed\":Vh(r,e,t,i,n,m);break;case\"variableStep\":jh(r,e,t,i,n,m);break;case\"fixedStep\":Wh(r,e,t,i,n,m);break;default:throw\"Unknown tile type: \"+r.type}return m.sort((function(e,t){return e.start-t.start})),m}get supportsWholeGenome(){return!0}get windowFunctions(){return this.reader.windowFunctions}async getWGValues(e,t){const i=this.#h[e];if(i&&i.bpPerPixel>.8*t&&i.bpPerPixel<1.2*t)return i.values;{const i=[],n=this.genome;if(this.genome.wgChromosomeNames)for(let r of n.wgChromosomeNames){const s=n.getChromosome(r).bpLength;t=s/1e3;const o=await this._getFeatures(r,0,s,t,e);if(o)for(let e of o){const t=Object.assign({},e);t.chr=\"all\",t.start=n.getGenomeCoordinate(e.chr,e.start),t.end=n.getGenomeCoordinate(e.chr,e.end),t._f=e,i.push(t)}}return this.#h[e]={values:i,bpPerPixel:t},i}}}function Vh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.end,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function jh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.span,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function Wh(e,t,i,n,r,s){const o=e.nPositions;let a=e.start;const c=e.span,l=e.data[0];for(let e=0;en)break;r>=i&&(Number.isNaN(l[e])||s.push({chr:t,start:a,end:r,value:l[e]})),a=r}}var Gh=Math.log(2);class $h{constructor(e,t,i,n){this.header=e,this.nameToId=t,this.idToName=i,this.sumLengths=n}static parseTree(e,t,i=!1){{const n=e.getInt(),r=e.getInt(),s=e.getInt(),o=e.getInt(),a=e.getLong(),c=e.getLong(),l={magic:n,blockSize:r,keySize:s,valSize:o,itemCount:a,reserved:c},h=new Map,d=[];let u=0;const f=n=>{n>=0&&(e.position=n);const r=e.getByte();e.getByte();const a=e.getUShort();if(1===r)for(let t=0;t{const a=await this.readNode(o);for(let o of a.items)Yh(o,e,t,i,n)&&(1===a.type?r.push(o):await s(o.childOffset))};return await s(this.header.rootNodeOffset),r}async readNode(e){const t=e;if(this.nodeCache.has(t))return this.nodeCache.get(t);let i=await this.#t(e,4);const n=i.getByte(),r=1===n;i.getByte();const s=i.getUShort();let o=s*(r?32:24);i=await this.#t(e+4,o);const a=[];for(let e=0;ee.startChrom||n===e.startChrom&&r>=e.startBase)&&(t!!e)),s=[];for(let e of r){const t=e.split(\" \")[0];if(t.startsWith(i)&&s.push(e),t.slice(0,i.length)>i)break}if(0!==s.length){const e=new Map;for(let t of s){const[i,...n]=t.split(\" \");e.set(i,n.map((e=>e.split(\",\")[0])))}return e}}async getIndex(e){return this.index||(this.index=await this._readIndex()),this.index}async _readIndex(e){return(await Qs.loadString(this.ixxFile)).split(\"\\n\").filter((e=>!!e)).map((e=>{const t=e.length-10,i=e.slice(0,t),n=e.slice(t);return[i,Number.parseInt(n,16)]}))}async _getBuffer(e,t){let i=0,n=65536;const r=await this.getIndex(t);for(let t=0;t0?ls(r):r,a.call(this,new DataView(d.buffer),c,t,l,n,h,this.chromTree.idToName,s,this.littleEndian)}return h.sort((function(e,t){return e.start-t.start})),h}return[]}async#d(e){if(this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.chromTree.nameToId.get(e);if(void 0===t&&this.genome){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>this.chromTree.nameToId.has(e)));e.length>0&&(n=e[0],t=this.chromTree.nameToId.get(e[0]))}this.chrAliasTable.set(e,n)}return t}get searchable(){return\"bigbed\"===this.type}async search(e){if(this.header||await this.loadHeader(),!this.header||!this.header.extraIndexCount)return;const t=await this._searchForRegions(e);if(t){const i=await this._loadFeaturesForRange(t.offset,t.length);if(i){const t=i.filter((t=>{for(let i of Object.keys(t)){const n=t[i];if(Mt(n)&&n.toLowerCase()===e.toLowerCase())return!0}return!1}));return t.length>0?t.reduce(((e,t)=>e.end-e.start>t.end-t.start?e:t),i[0]):void 0}}}async _searchForRegions(e){const t=await this.#u();if(t){if(this._trix){const t=e.toLowerCase(),i=await this._trix.search(t);i&&i.has(t)&&(e=i.get(t)[0])}for(let i of t){const t=await i.search(e);if(t)return t}}}async#u(){if(void 0===this._searchTrees&&this.header.extraIndexOffsets&&this.header.extraIndexOffsets.length>0){this._searchTrees=[];for(let e of this.header.extraIndexOffsets){const t=await Cc.loadBpTree(this.path,this.config,e);this._searchTrees.push(t)}}return this._searchTrees}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let e,t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;const i=new yc(new DataView(t),this.littleEndian);let n=i.getUInt();if(2291137574===n)this.type=\"bigwig\";else if(2273964779===n)this.type=\"bigbed\";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let e=i.getUInt();654085990===e?this.type=\"bigwig\":3958540679===e&&(this.type=\"bigbed\")}e={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:e.totalSummaryOffset>0?e.totalSummaryOffset-r+40:Math.min(e.fullDataOffset,e.chromTreeOffset)-r};t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:s}));const o=new yc(new DataView(t),this.littleEndian),a=e.nZoomLevels;this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let e=1;e<=a;e++){const t=a-e,i=new Jh(t,o);this.firstZoomDataOffset=Math.min(i.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[t]=i}if(e.autoSqlOffset>0){o.position=e.autoSqlOffset-r;const t=o.getString();t&&(this.autoSql=function(e){let t;const i=[];let n=!1;const r=e.trim().split(/\\s*[\\r\\n]+\\s*/g);for(let e of r)if(e=e.trim(),e.length>0){if(e.startsWith(\"#\"))continue;if(e.startsWith(\"table\"))t=e.split(/\\s+/)[1].trim();else if(e.startsWith(\"(\"))n=!0;else if(e.startsWith(\")\"));else if(n){const t=e.indexOf(\";\");if(t>0){const n=e.substr(0,t).split(/\\s+/),r=e.substr(t+1).replace(/\"/g,\"\").trim();i.push({type:n[0],name:n[1],description:r})}}}return{table:t,fields:i}}(t))}e.totalSummaryOffset>0&&(o.position=e.totalSummaryOffset-r,this.totalSummary=new ed(o));const c=Math.min(2e5,Math.max(1e4,e.fullDataOffset-e.chromTreeOffset));if(this.chromTree=await this.#f(e.chromTreeOffset,c),this.chrNames=new Set(this.chromTree.idToName),\"bigbed\"===this.type){const t=await this.#p(e.fullDataOffset);this.featureDensity=t/this.chromTree.sumLengths}return this.header=e,e.extensionOffset>0&&await this.loadExtendedHeader(e.extensionOffset),this.header}}async#p(e){const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:4}}));return new yc(new DataView(t),this.littleEndian).getInt()}async#f(e,t){let i=t;const n=async()=>{const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:i}})),n=new yc(new DataView(t),this.littleEndian);return $h.parseTree(n,e,this.genome)};let r;for(;i<1e6;)try{return await n()}catch(e){r=e,i*=2}throw r}async loadExtendedHeader(e){let t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:64}})),i=new yc(new DataView(t),this.littleEndian);i.getUShort();const n=i.getUShort(),r=i.getLong();if(0===n)return;let s=56*n;t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:r,size:s}})),i=new yc(new DataView(t),this.littleEndian);const o=[],a=[],c=[];for(let e=0;e0?ls(n):n,s=[];return nd.call(this).call(this,new DataView(r.buffer),0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,s,this.chromTree.idToName),s}}class Jh{constructor(e,t){this.index=e,this.reductionLevel=t.getInt(),this.reserved=t.getInt(),this.dataOffset=t.getLong(),this.indexOffset=t.getLong()}}class ed{constructor(e){e?(this.basesCovered=e.getLong(),this.minVal=e.getDouble(),this.maxVal=e.getDouble(),this.sumData=e.getDouble(),this.sumSquares=e.getDouble(),td.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function td(){let e=this.basesCovered;if(e>0){this.mean=this.sumData/e,this.stddev=Math.sqrt(this.sumSquares/(e-1));let t=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:t,max:i}}}function id(e,t,i,n,r,s,o,a,c){const l=new yc(e,c),h=l.getInt(),d=l.getInt();let u=d,f=l.getInt();const p=l.getInt(),g=l.getInt(),m=l.getByte();l.getByte();let w=l.getUShort();if(h>=t&&h<=n){let e=0;for(;w-- >0;){let a;switch(m){case 1:u=l.getInt(),f=l.getInt(),a=l.getFloat();break;case 2:u=l.getInt(),a=l.getFloat(),f=u+g;break;case 3:a=l.getFloat(),u=d+e*p,f=u+g,e++}if(!(hn||h===n&&u>=r)break;if(Number.isFinite(a)){const e=o[h];s.push({chr:e,start:u,end:f,value:a})}}}}}function nd(){const e=function(e,t,i,n){if(\"biginteract\"===n||i&&(\"chromatinInteract\"===i.table||\"interact\"===i.table))return function(e,t){return e.chr1=t[5],e.start1=Number.parseInt(t[6]),e.end1=Number.parseInt(t[7]),e.chr2=t[10],e.start2=Number.parseInt(t[11]),e.end2=Number.parseInt(t[12]),e.name=t[0],e.score=Number(t[1]),e.value=Number(t[2]),e.color=\".\"===t[4]?void 0:\"0\"===t[4]?\"rgb(0,0,0)\":t[4],e};{const n=e-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&\".\"!==s[5]&&\"0\"!==s[5]&&\"-1\"!==s[5]){const e=_s.createColorString(s[5]);r.color=e.startsWith(\"rgb\")?e:void 0}if(n>8){const e=parseInt(s[6]),t=s[7].split(\",\"),i=s[8].split(\",\"),n=[];for(let s=0;si?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=e;n=13;){const t=h.getInt(),c=a[t],l=h.getInt(),d=h.getInt(),u=h.getString();if(!(tr||t===r&&l>=s)break;if(d>0){const t={chr:c,start:l,end:d};o.push(t);const i=u.split(\"\\t\");e(t,i)}}}}}function rd(e,t,i,n,r,s,o,a,c){const l=new yc(e,c);for(;l.remLength()>=32;){const e=l.getInt(),c=l.getInt(),h=l.getInt(),d=l.getInt(),u=l.getFloat(),f=l.getFloat(),p=l.getFloat();let g;switch(l.getFloat(),a){case\"min\":g=u;break;case\"max\":g=f;break;default:g=0===d?0:p/d}if(!(en||e===n&&c>=r)break;if(Number.isFinite(g)){const t=o[e];s.push({chr:t,start:c,end:h,value:g})}}}}class sd{constructor(e){this.data=e}loadArrayBuffer(e,t){const i=t.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(e,t){const i=Math.min(this.data.byteLength-e.start,e.size);return t?new Uint8Array(this.data,e.start,i):new DataView(this.data,e.start,i)}}class od extends Hh{queryable=!0;#h={};windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];constructor(e,t){super(t),this.reader=new Zh(e,t),this.genome=t,this.format=e.format||\"bigwig\"}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r}){await this.reader.loadHeader();const s=\"bigwig\"===this.reader.type;let o;return o=\"all\"===e.toLowerCase()?s?await this.getWGValues(r,n):[]:await this.reader.readFeatures(e,t,e,i,n,r),s||Tl(o),o}async getHeader(){return this.reader.loadHeader()}async defaultVisibilityWindow(){return\"bigwig\"===this.reader.type?-1:this.reader.featureDensity?Math.floor(1e4/this.reader.featureDensity):-1}async getWGValues(e,t){const i=this.genome,n=this.#h[e];if(n&&n.bpPerPixel>.8*t&&n.bpPerPixel<1.2*t)return n.values;{const n=await this.reader.readWGFeatures(t,e);let r=[];for(let e of n){const t=e.chr,n=i.getCumulativeOffset(t);if(void 0===n)continue;const s=Object.assign({},e);s.chr=\"all\",s.start=n+e.start,s.end=n+e.end,s._f=e,r.push(s)}return r.sort(((e,t)=>e.start-t.start)),this.#h[e]={values:r,bpPerPixel:t},r}}supportsWholeGenome(){return\"bigwig\"===this.reader.type}async trackType(){return this.reader.getTrackType()}get searchable(){return this.reader.searchable}async search(e){return this.reader.search(e)}}const ad=.01;function cd(e,t,i,n){if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"}),n&&xo.fillRect(e,t-4-2,0,4,i,{fillStyle:n});const r=void 0!==this.flipAxis&&this.flipAxis,s=.95*t-8-5,o=.95*t-5,a={font:\"normal 10px Arial\",textAlign:\"right\",fillStyle:\"black\",strokeStyle:\"black\"};xo.strokeLine(e,s,ad*i,o,ad*i,a),xo.fillText(e,l(r?this.dataRange.min:this.dataRange.max),s+4,ad*i+12,a);const c=.99*i;function l(e){return 0===e?\"0\":Math.abs(e)>=10?e.toFixed():Math.abs(e)>=1?e.toFixed(1):Math.abs(e)>=.1?e.toFixed(2):e.toExponential(1)}xo.strokeLine(e,s,c,o,c,a),xo.fillText(e,l(r?this.dataRange.max:this.dataRange.min),s+4,c-4,a),xo.strokeLine(e,o,ad*i,o,c,a)}class ld extends Hl{static defaults={height:50,flipAxis:!1,logScale:!1,windowFunction:\"mean\",graphType:\"bar\",normalize:void 0,scaleFactor:void 0,overflowColor:\"rgb(255, 32, 255)\",baselineColor:\"lightGray\",summarize:!0,visibilityWindow:void 0};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"wig\",this.featureType=\"numeric\",this.resolutionAware=!0,this.paintAxis=cd;const t=e.format?e.format.toLowerCase():e.format;e.featureSource?(this.featureSource=e.featureSource,delete e.featureSource):this.featureSource=\"bigwig\"===t?new od(e,this.browser.genome):\"tdf\"===t?new Qh(e,this.browser.genome):Ad(e,this.browser.genome),void 0===e.max||!0===e.autoscale?this.autoscale=!0:this.dataRange={min:e.min||0,max:e.max}}async postInit(){const e=await this.getHeader();this.disposed||e&&this.setTrackProperties(e)}supportsWholeGenome(){return void 0===this.visibilityWindow||this.visibilityWindow<0}async getFeatures(e,t,i,n){const r=this.windowFunction,s=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:r});if(this.normalize&&this.featureSource.normalizationFactor){const e=this.featureSource.normalizationFactor;for(let t of s)t.value*=e}if(this.scaleFactor){const e=this.scaleFactor;for(let t of s)t.value*=e}return!this.summarize||\"mean\"!==r&&\"min\"!==r&&\"max\"!==r?s:hd(s,t,n,r)}menuItemList(){const e=[];if(void 0!==this.flipAxis){function t(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}e.push(\"
\"),e.push({label:\"Flip y-axis\",click:t})}return this.featureSource.windowFunctions&&e.push(...this.wigSummarizationItems()),e.push(...this.numericDataMenuItems()),e}wigSummarizationItems(){const e=this.featureSource.windowFunctions,t=[];t.push(\"
\"),t.push(\"
Windowing function
\");for(const i of e){const n=Bt(Dl(i,this.windowFunction===i));function r(){this.windowFunction=i,this.trackView.updateViews()}t.push({object:n,click:r})}return t}async getHeader(){return\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(e,t,i,n){const r=!0===n?e<0?-Math.log10(Math.abs(e)+1):Math.log10(Math.abs(e)+1):e;return i/((!0===n?Math.log10(Math.abs(t)+1):t)-r)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return n=n<0?-Math.log10(Math.abs(n)+1):Math.log10(Math.abs(n)+1),i=i<0?-Math.log10(Math.abs(i)+1):Math.log10(Math.abs(i)+1),e=e<0?-Math.log10(Math.abs(e)+1):Math.log10(e+1),(this.flipAxis?e-n:i-e)*t}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight-1,a=r+s*n+1,c=this.getScaleFactor(this.dataRange.min,this.dataRange.max,o,this.logScale),l=e=>this.logScale?this.computeYPixelValueInLogScale(e,c):this.computeYPixelValue(e,c);if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,c=-1;const h=l(0);for(let d of t){if(d.enda)break;const t=(d.start-r)/n;if(isNaN(t))continue;let u=l(d.value);const f=(d.end-r)/n-t,p=e.alpha?_s.addAlpha(this.getColorForFeature(d),e.alpha):this.getColorForFeature(d);if(\"line\"===this.graphType)void 0!==s&&xo.strokeLine(i,c,s,t,u,{fillStyle:p,strokeStyle:p}),xo.strokeLine(i,t,u,t+f,u,{fillStyle:p,strokeStyle:p});else if(\"points\"===this.graphType){const e=this.config.pointSize||3,n=t+f/2;xo.fillCircle(i,n,u,e/2,{fillStyle:p,strokeStyle:p}),d.value>this.dataRange.max?xo.fillCircle(i,n,e/2,e/2,3,{fillStyle:this.overflowColor}):d.valuethis.dataRange.max?xo.fillRect(i,t,0,f,3,{fillStyle:this.overflowColor}):d.value0){const i=e.genomicLocation,n=[];t.sort((function(e,t){return Math.abs((e.start+e.end)/2-i)-Math.abs((t.start+t.end)/2-i)}));const r=t.length>10?t.slice(0,10):t;r.sort((function(e,t){return e.start-t.start}));for(let e of r)if(e){n.length>0&&n.push(\"
\");let t=e.end-e.start==1?Rt(Math.floor(e.start)+1):Rt(Math.floor(e.start)+1)+\"-\"+Rt(Math.floor(e.end));n.push({name:\"Position:\",value:t}),n.push({name:\"Value:     \",value:Rt(e.value.toFixed(4))})}return r.length...\"),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(e){let t=e.value<0&&this.altColor?this.altColor:this.color||\"rgb(150, 150, 150)\";return\"function\"==typeof t?t(e.value):t}dispose(){this.trackView=void 0}}function hd(e,t,i,n=\"mean\"){if(i<=1||!e||0===e.length)return e;const r=e[0].chr,s=i,o=[],a=e=>{const i=t+e.bin*s,a=i+s;let c;switch(n){case\"mean\":c=e.sumData/e.count;break;case\"max\":c=e.max;break;case\"min\":c=e.min;break;default:throw Error(`Unknown window function: ${n}`)}const l=`${n} of ${e.count} values`;o.push({chr:r,start:i,end:a,value:c,description:l})};let c;for(let i of e){let e=Math.floor((i.start-t)/s);const n=Math.floor((i.end-t)/s);if(c&&e===c.bin&&(c.add(i),e++),!c||n>c.bin){if(c&&a(c),n>e){const e=t+n*s;o.push({chr:r,start:i.start,end:e,value:i.value})}c=new dd(n,i)}}c&&a(c);const l=[];let h=o[0];for(let e of o)h.value===e.value&&e.start<=h.end?h.end=e.end:(l.push(h),h=e);return l.push(h),l}class dd{constructor(e,t){this.bin=e,this.sumData=t.value,this.count=1,this.min=t.value,this.max=t.value}add(e){this.sumData+=e.value,this.max=Math.max(e.value,this.max),this.min=Math.min(e.value,this.min),this.count++}get mean(){return this.sumData/this.count}}class ud extends Hh{constructor(e,t){super(t),this.config=e||{},this.genome=t,this.sourceType=void 0===e.sourceType?\"file\":e.sourceType,this.maxWGCount=e.maxWGCount||1e4,this.windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];const i=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"tdf\"]);if(this.queryable=e.indexURL||!0===e.queryable,e.reader)this.reader=e.reader,this.queryable=!1!==e.queryable;else{if(\"ga4gh\"===e.sourceType)throw Error(\"Unsupported source type 'ga4gh'\");\"eqtl\"!==e.type&&\"qtl\"!==e.type||\"gtex-ws\"!==e.sourceType?\"htsget\"===e.sourceType?(this.reader=new Lh(e,t),this.queryable=!0):\"ucscservice\"===e.sourceType?(this.reader=new Nh(e.source),this.queryable=!0):\"custom\"===e.sourceType?(this.reader=new Eh(e.source),this.queryable=!1!==e.source.queryable):\"service\"===e.sourceType?(this.reader=new Ih(e,t),this.queryable=!0):(this.reader=new Ih(e,t),void 0!==e.queryable?this.queryable=e.queryable:(i.has(e.format)||this.reader.indexed)&&(this.queryable=!0)):(this.reader=new Bh(e),this.queryable=!0)}this.searchable=!1!==e.searchable}async defaultVisibilityWindow(){if(this.reader&&\"function\"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const e=await this.getHeader();return e?e.type:void 0}async getHeader(){if(!this.header)if(this.reader&&\"function\"==typeof this.reader.readHeader){const e=await this.reader.readHeader();e?(this.header=e,e.format&&(this.config.format=e.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r,windowFunction:s}){const o=\"all\"===e.toLowerCase();if(t=t||0,i=i||Number.MAX_SAFE_INTEGER,(o&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new hc(e,t,i)))&&await this.loadFeatures(e,t,i,r),o){if(!this.wgFeatures)if(this.supportsWholeGenome())if(\"wig\"===this.config.type){const e=await Ll(this.featureCache.getAllFeatures(),this.genome,1e6);this.wgFeatures=hd(e,0,n,s)}else this.wgFeatures=await Ll(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount);else this.wgFeatures=[];return this.wgFeatures}return this.featureCache.queryFeatures(e,t,i)}async findFeatures(e){return this.featureCache?this.featureCache.findFeatures(e):[]}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]:this.featureCache.getAllFeatures()}async loadFeatures(e,t,i,n){await this.getHeader();const r=this.reader;let s=t,o=i,a=e;if(!this.chrAliasManager&&this.reader&&this.reader.sequenceNames&&(this.chrAliasManager=new zh(this.reader.sequenceNames,this.genome)),this.chrAliasManager&&(a=await this.chrAliasManager.getAliasName(e)),(!n||n<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(a):void 0;s=0,o=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,i)}else if(n>i-t&&!1!==this.config.expandQuery){let e=Math.min(4.1*(i-t),n);this.config.minQuerySize&&et.end-t.start)continue;this.featureMap.set(i.toUpperCase(),t)}}}search(e){if(this.featureMap)return this.featureMap.get(e.toUpperCase())}}class pd{constructor({chr:e,locus:t,accession:i,aliases:n,features:r,sequence:s}){this.chr=e,this.locus=t,this.accession=i,this.aliases=n,this.features=r,this.sequence=s,this.bpLength=s.length}toJSON(){return{gbkURL:this.url}}getSequenceRecord(e){return{chr:this.chr,bpLength:this.bpLength}}get chromosomeNames(){return[this.chr]}getFirstChromosomeName(){return this.chr}get id(){return this.accession}get name(){return this.locus}get initialLocus(){return this.chr}get description(){return this.locus}get infoURL(){return this.url}showWholeGenomeView(){return!1}getHomeChromosomeName(){return this.chr}getChromosomeName(e){return e}getChromosomeDisplayName(e){return this.chr}getChromosome(e){if(e===this.chr)return{name:this.chr,bpLength:this.bpLength}}async loadChromosome(e){return this.getChromosome(e)}async getAliasRecord(e){}getCytobands(e){return[]}getChromosomes(){return[this.getChromosome(this.chr)]}get wgChromosomeNames(){}getGenomeCoordinate(e,t){if(e===this.chr)return t}getChromosomeCoordinate(e){return{chr:this.chr,position:e}}getCumulativeOffset(e){return 0}getGenomeLength(){return this.bpLength}async getSequence(e,t,i){return e===this.chr?this.sequence.substring(t,i):void 0}getSequenceInterval(e,t,i){return e===this.chr?new dc(this.chr,0,this.sequence.length,this.sequence):void 0}}const gd=/\\s+/,md=new Map;async function wd(e){let t=md.get(e);if(!t){t=function(e){if(!e)return null;const t=mh(e);let i=t.nextLine();const n=i.split(/\\s+/);if(\"LOCUS\"!==n[0].toUpperCase())throw Error(\"Expected `LOCUS` line. Found: \"+i);const r=n[1].trim();let s,o;do{if(i=t.nextLine(),i.startsWith(\"ACCESSION\")){const e=i.split(gd);if(e.length<2)throw Error(\"Genbank file missing ACCESSION number.\");s=e[1].trim()}else if(i.startsWith(\"ALIASES\")){const e=i.split(gd);e.length>1&&(o=e[1].split(\",\"))}}while(i&&!i.startsWith(\"FEATURES\"));const a=s||r,c=function(e,t){const i=[];let n,r,s,o=0;for(;;)if(r=t.nextLine(),\"\"!==r){if(!r||r.startsWith(\"ORIGIN\"))break;if(r.length<6)o<10&&console(\"Unexpected line in genbank file (skipping): \"+r),o++;else if(\" \"!==r.charAt(5)){let t=r.substring(5,21).trim();s={chr:e,type:t,attributes:{},getAttributeValue:function(e){return this.attributes[e]}},n=r.substring(21),\"source\"!==t.toLowerCase()&&i.push(s)}else{let t=r.substring(21).trim();if(t.length>0)if(47===t.charCodeAt(0)){if(47===n.charCodeAt(0)){let e=n.split(\"=\",2);if(e.length>1){let t=e[0].length>1?e[0].substring(1):\"\",i=Fd(e[1]);s.attributes[t]=i}}else{const t=n.includes(\"complement\")?\"-\":\"+\";s.strand=t;let i=n.replace(\"join\",\"\").replace(\"order\",\"\").replace(\"complement\",\"\").replace(\"(\",\"\").replace(\")\",\"\");if(i.includes(\"..\")){i=i.replace(\"<\",\"\").replace(\">\",\"\");const n=bd(i,e,t),r=n[0];s.start=r.start;const o=n[n.length-1];s.end=o.end,n.length>1&&(s.exons=n)}else s.start=parseInt(i)-1,s.end=s.start+1}n=t}else n+=t}}return i}(a,t),l=function(e){let t,i=\"\";for(;(t=e.nextLine())&&!t.startsWith(\"//\");){t=t.trim();const e=t.split(/\\s+/);for(let t=1;t1&&(o=parseInt(n[1])),r.push({chr:t,start:s,end:o,strand:i})}return r.sort((function(e,t){return e.start-t.start})),r}function Fd(e){return e.startsWith('\"')&&e.endsWith('\"')&&(e=e.substring(1,e.length-2)),e}class vd extends Hh{constructor(e,t){super(t),this.config=e,this.searchable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){if(!this.featureSource){const e=await wd(this.config.url);this.featureSource=new fd({genome:this.config.genome,features:e.features,searchableFields:[\"gene\",\"db_xref\",\"locus_tag\",\"transcript_id\"]})}return this.featureSource.getFeatures({chr:e,start:t,end:i})}supportsWholeGenome(){return!1}search(e){return this.featureSource.search(e)}}const yd=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\"]);function Ad(e,t){const i=e.format?e.format.toLowerCase():void 0;return e.features?new fd(e,t):yd.has(i)?new od(e,t):\"tdf\"===i?new Qh(e,t):\"gbk\"===i?new vd(e,t):new ud(e,t)}function Cd(e){return(3-e.readingFrame)%3}function _d(e){return e.cdStart||e.start}function xd(e){return e.cdEnd||e.end}const kd=.25;function Id(e,t,i){let n=(e.start-t)/i,r=(e.end-t)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Sd(e,t,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(e);let o,a;r.fillStyle=n,r.strokeStyle=n,\"SQUISHED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*e.row):\"EXPANDED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*e.row):(o=this.featureHeight,a=this.margin);const c=s.pixelWidth,l=a+o/2,h=o/2,d=l-h/2,u=e.exons?e.exons.length:0,f=Id(e,t,i),p=this.arrowSpacing,g=\"+\"===e.strand?1:\"-\"===e.strand?-1:0;if(0===u){const e=Math.max(0,f.px),t=Math.min(c,f.px1),i=t-e;if(r.fillRect(e,a,i,o),0!==g){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let i=e+p/2;ic)break;if(f.utr)r.fillRect(w,d,F,h);else{if(f.cdStart&&(m=Math.round((f.cdStart-t)/i),r.fillRect(w,d,m-w,h),F-=m-w,w=m),f.cdEnd&&(m=Math.round((f.cdEnd-t)/i),r.fillRect(m,d,b-m,h),F-=b-m,b=m),F=Math.max(F,1),r.fillRect(w,a,F,o),void 0!==f.readingFrame&&s.bpPerPixel0&&void 0!==e.exons[u-1].readingFrame?e.exons[u-1]:void 0,n=up+5&&0!==g&&s.bpPerPixel>kd){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let e=w+p/2;e{const f=Math.round((i-s)/o),p=Math.round((n-s)/o)-f;let g;if(void 0===r){if(l.hasSequence(i,n)){const e=l.getSequence(i,n);if(e&&3===e.length){const i=\"+\"===t?e:ac(e.split(\"\").reverse().join(\"\"));g=Gd[i]}}}else g=r;e.fillStyle=\"M\"===r||\"M\"===g&&0===u?\"#83f902\":\"STOP\"===g?\"#ff2101\":h[d],e.fillRect(f,a,p,c),g&&(e.save(),((t,i,n,r,s)=>{\"STOP\"===s&&(s=\"*\");const o=e.measureText(s).width;xo.fillText(e,s,n+(i-o)/2,r-4,{fillStyle:\"#ffffff\"})})(0,p,f,a+c,g),e.restore());const m=n-i;return m>0&&m<3?{start:i,end:n}:void 0},u=Cd(n);let f,p,g,m,w,b=_d(n),F=xd(n),v=1;if(\"+\"===t){for(u>0&&(b+=u),v=1,w=0,f=b;f0||g){const e=u>0?Bd.call(this,t,u,b-u,b,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;i&&d(t,b-u,b,i.aminoAcidLetter,0,void 0),n&&d(t,g.start,g.end,n.aminoAcidLetter,m,void 0)}}}else{for(u>0&&(F-=u),v=1,w=0,w=0,p=F;p>b;w++,p-=3)m=v%2,f=Math.max(b,p-3),g=d(t,f,p,void 0,v%2,w),++v;if(u>0||g){const e=u>0?Bd.call(this,t,u,F,F+u,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;n&&d(t,F,F+u,n.aminoAcidLetter,0,void 0),i&&d(t,g.start,g.end,i.aminoAcidLetter,m,void 0)}}}e.restore()}function Nd(e,t,i,n,r,s,o){try{e.save();let s=t.name;if(void 0===s&&t.gene&&(s=t.gene.name),void 0===s&&(s=t.id||t.ID),!s||\".\"===s)return;let a=o.pixelXOffset||0;const c=Math.max(i,-a);let l,h=(c+Math.min(n,-a+o.viewportWidth))/2;\"COLLAPSED\"===this.displayMode&&\"SLANT\"===this.labelDisplayMode&&(l={rotate:{angle:45}});const d=function(e,t){return t?e+20:e+25}(r,l);let u=this.getColorForFeature(t),f=this.browser.qtlSelections.hasPhenotype(t.name);const p={textAlign:\"SLANT\"===this.labelDisplayMode?void 0:\"center\",fillStyle:u,strokeStyle:u},g=e.measureText(s),m=h-g.width/2,w=h+g.width/2,b=o.rowLastLabelX[t.row]||-Number.MAX_SAFE_INTEGER;(o.labelAllFeatures||m>b||f)&&(o.rowLastLabelX[t.row]=w,\"y\"===o.axis?(e.save(),xo.labelTransformWithContext(e,h),xo.fillText(e,s,h,d,p,l),e.restore()):(e.clearRect(h-g.width/2-1,d-g.actualBoundingBoxAscent-1,g.width+2,g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+2),xo.fillText(e,s,h,d,p,l)))}finally{e.restore()}}function Bd(e,t,i,n,r,s,o,a,c){let l,h,d=\"\",u=\"\",f=\"\";const p={left:void 0,rite:void 0};if(\"+\"===e){if(t){if(u=c.getSequence(i,n),!u)return;if([l,h]=[xd(s)-(3-t),xd(s)],d=c.getSequence(l,h),!d)return;f=d+u,p.left={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(d=c.getSequence(r.start,r.end),!d)return;const e=Cd(a),t=_d(a);if(u=c.getSequence(t,t+e),!u)return;f=d+u,p.rite={triplet:f,aminoAcidLetter:Gd[f]}}}else{if(t){if(d=c.getSequence(i,n),void 0===d)return;if([l,h]=[_d(a),_d(a)+(3-t)],u=c.getSequence(l,h),void 0===u)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.rite={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(u=c.getSequence(r.start,r.end),void 0===u)return;const e=Cd(s),t=xd(s);if(d=c.getSequence(t-e,t),void 0===d)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.left={triplet:f,aminoAcidLetter:Gd[f]}}}return p}const Md=new Set([\"nonsense\",\"missense\",\"stop-loss\",\"frameshift\",\"cds-indel\"]),Rd=new Set([\"coding-synon\"]),Dd=new Set([\"splice-3\",\"splice-5\"]),Td=new Set([\"untranslated-5\",\"untranslated-3\"]);function Ld(e,t,i,n,r){var s,o,a,c,l,h,d=Id(e,t,i),u=this.margin,f=this.snpColors.length;switch(s=\"squished\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case\"function\":c=e.func,h=c.split(\",\"),l=h.map((function(e){return Md.has(e)||Dd.has(e)?f-1:Rd.has(e)?f-2:Td.has(e)?f-3:0})),o=l.reduce((function(e,t){return Math.max(e,t)}));break;case\"class\":o=\"deletion\"===(a=e.class)?f-1:\"mnp\"===a?f-2:\"microsatellite\"===a||\"named\"===a?f-3:0}r.fillStyle=this.snpColors[o],r.fillRect(d.px,u,d.pw,s)}function zd(e,t,i,n,r){const s=\"EXPANDED\"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;\"COLLAPSED\"!==this.displayMode&&void 0!==e.row&&(o+=e.row*s);const a=o+.5*s,c=a-.5*s,l=a+.5*s,h=Math.round((e.junction_left-t)/i),d=Math.round((e.junction_right-t)/i);r.beginPath(),r.moveTo(h,a),r.bezierCurveTo(h,c,d,c,d,a),r.lineWidth=1+Math.log(e.num_junction_reads)/Math.log(2),r.strokeStyle=\"blue\",r.stroke();const u=e.spanning_frag_coords;for(let e=0;et&&(t=i.row);return this.margin+(t+1)*(\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,bpEnd:s,pixelWidth:o,pixelHeight:a,referenceFrame:c}=e;if(nr&&i.end!isNaN(e)))));let h=[];const d=[];for(let o of t){if(o.ends)break;\"COLLAPSED\"===this.displayMode&&this.browser.qtlSelections.hasPhenotype(o.name)&&d.push(o);const t=\"COLLAPSED\"===this.displayMode?0:o.row;e.drawLabel=e.labelAllFeatures||l>10;const c=Math.ceil((o.end-r)/n),u=h[t];if(!u||c>u){this.render.call(this,o,r,n,a,i,e);const s=Math.floor((o.start-r)/n);u&&s-u<=0&&(i.globalAlpha=.5,xo.strokeLine(i,s,0,s,a,{strokeStyle:\"rgb(255, 255, 255)\"}),i.globalAlpha=1),h[t]=c}}for(let t of d)e.drawLabel=!0,this.render.call(this,t,r,n,a,i,e)}else console.log(\"No feature list\")}clickedFeatures(e){const t=e.y-this.margin,i=super.clickedFeatures(e);let n;switch(this.displayMode){case\"SQUISHED\":n=Math.floor(t/this.squishedRowHeight);break;case\"EXPANDED\":n=Math.floor(t/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(e){return void 0===n||void 0===e.row||n===e.row}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=e._f||e,r=\"function\"==typeof t.popupData?t.popupData(i):this.extractPopupData(t);if(r){n.length>0&&n.push(\"

\");const s=this.infoURL||this.config.infoURL;for(let t of r)if(n.push(t),s&&t.name&&\"name\"===t.name.toLowerCase()&&t.value&&Mt(t.value)&&!t.value.startsWith(\"<\")){const i=s.replace(\"$$\",e.name);t.value=`${t.value}`}const o=\"gff\"===this.config.format||\"gff3\"===this.config.format||\"gtf\"===this.config.format;if(t.exons&&t.exons.length>1)for(let e=0;e=r.start&&i<=r.end){const i=o?r.number:\"-\"===t.strand?t.exons.length-e:e+1;i&&(n.push(\"
\"),n.push({name:\"Exon Number\",value:i}));break}}}}return n}menuItemList(){const e=[];if(this.render===Ld){e.push(\"
\");for(const i of[\"function\",\"class\"]){const n=Bt(Dl(`Color by ${i}`,i===this.colorBy));function r(){this.colorBy=i,this.trackView.repaintViews()}e.push({object:n,click:r})}}e.push(\"
\");const t={COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"};for(const s of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){const o=Bt(Dl(t[s],s===this.displayMode));function a(){this.displayMode=s,this.config.displayMode=s,this.trackView.checkContentHeight(),this.trackView.repaintViews()}e.push({object:o,click:a})}return e}contextMenuItemList(e){const t=this.clickedFeatures(e);if(void 0===t||0===t.length)return;t.length>1&&t.sort(((e,t)=>t.end-t.start-(e.end-e.start)));const i=t[0];if(i.end-i.start<=1e6){const e=[{label:\"View feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&void 0!==navigator.clipboard&&e.push({label:\"Copy feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.push(\"
\"),e}}description(){if(Ld===this.render){let e=\"\"+this.name+\"
\";return e+=\"Color By Function:
\",e+='Red: Coding-Non-Synonymous, Splice Site
',e+='Green: Coding-Synonymous
',e+='Blue: Untranslated
',e+='Black: Intron, Locus, Unknown

',e+=\"Color By Class:
\",e+='Red: Deletion
',e+='Green: MNP
',e+='Blue: Microsatellite, Named
',e+='Black: Indel, Insertion, SNP',e+=\"\",e}return super.description()}getColorForFeature(e){const t=e._f||e;let i;if(e.name&&this.browser.qtlSelections.hasPhenotype(e.name))i=this.browser.qtlSelections.colorForGene(e.name);else if(this.altColor&&\"-\"===t.strand)i=\"function\"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)i=\"function\"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const e=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];i=this.colorTable.getColor(e)}else t.color&&(i=t.color);if(i||(i=\"rgb(0, 0, 150)\"),t.alpha&&1!==t.alpha)i=_s.addAlpha(i,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const e=function(e,t,i){const n=(t-e)/9,r=Math.floor((i-e)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,t.score);t.alpha=e,i=_s.addAlpha(i,e)}return i}dispose(){this.trackView=void 0}}class Pd{constructor(t){if(this.config=t,this.browser=t.browser,this.columnFormat=t.columnFormat,this.tableRowSelectionList=[],this.tableDOM=e({class:\"igv-roi-table\"}),t.width){let[e]=t.width.split(\"px\");e=parseInt(e,10),this.tableDOM.style.width=`${Math.min(e,1600)}px`}t.parent.appendChild(this.tableDOM),this.headerDOM=t,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=t.gotoButtonHandler}set headerDOM({browser:t,parent:i,headerTitle:n,dismissHandler:r}){const s=e();this.tableDOM.appendChild(s);const o=e();s.appendChild(o),o.innerHTML=n;const a=e();s.appendChild(a),a.appendChild(l(\"times\")),this.boundDismissHandler=function(e){e.stopPropagation(),r()}.bind(this),a.addEventListener(\"click\",this.boundDismissHandler);const{y:c}=t.root.getBoundingClientRect(),{y:h}=i.getBoundingClientRect(),d=-(h-c);p(this.tableDOM,s,{minX:0,minY:d}),this.tableDOM.style.display=\"none\",this._headerDOM=s}set tableColumnTitles(t){const i=e({class:\"igv-roi-table-column-titles\"});t.appendChild(i);for(const{label:t,width:n}of this.columnFormat){const r=e();i.appendChild(r),r.style.width=n,r.innerText=t}this._tableColumnTitlesDOM=i}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(t){const i=e({class:\"igv-roi-table-row-container\"});t.appendChild(i),this._tableRowContainerDOM=i}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(t){const i=e();this.tableDOM.appendChild(i);const n=e({class:\"igv-roi-table-button\"});i.appendChild(n),n.id=\"igv-roi-table-view-button\",n.textContent=\"Go To\",n.style.pointerEvents=\"none\",this._footerDOM=i,this.gotoButton=n,this.boundGotoButtonHandler=t.bind(this),this.gotoButton.addEventListener(\"click\",this.boundGotoButtonHandler)}tableRowDOMHelper(e){e.addEventListener(\"mousedown\",(t=>{t.stopPropagation(),e.classList.toggle(\"igv-roi-table-row-selected\"),e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\"),this.setTableRowSelectionState(e.classList.contains(\"igv-roi-table-row-selected\"))})),e.addEventListener(\"mouseover\",(t=>{e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\")})),e.addEventListener(\"mouseout\",(t=>{e.classList.remove(\"igv-roi-table-row-hover\")}))}clearTable(){const e=this.tableRowContainer.querySelectorAll(\".igv-roi-table-row\");for(let t of e)t.remove()}setTableRowSelectionState(e){e?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?\"auto\":\"none\"}present(){this.tableDOM.style.left=\"0px\";const{y:e}=this.browser.root.getBoundingClientRect(),{y:t}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=e-t+\"px\",this.tableDOM.style.display=\"flex\"}dismiss(){this.tableDOM.style.display=\"none\"}isVisible(){return\"none\"!==this.tableDOM.style.display}dispose(){this.tableDOM.innerHTML=\"\",this.tableDOM.remove();for(const e of Object.keys(this))this[e]=void 0;document.removeEventListener(\"click\",this.boundDismissHandler)}}class Od extends Pd{constructor(e){super(Object.assign({width:\"1024px\"},e)),this.descriptionDOM=e}set descriptionDOM(t){if(t.description){let i;i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.innerHTML=\"BLAT result for query sequence:\",i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.style.maxHeight=\"128px\",i.innerHTML=t.description,i=e({class:\"igv-roi-table-goto-explainer\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.innerHTML=\"Select one or more rows and click Go To to view the regions\"}}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),n=t.map((e=>isFinite(e)?Rt(e):e));for(let t=0;te.remove())),e.length>0)for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}static getColumnFormatConfiguration(){return[{label:\"chr\",width:\"7%\"},{label:\"start\",width:\"12%\"},{label:\"end\",width:\"12%\"},{label:\"strand\",width:\"5%\"},{label:\"score\",width:\"5%\"},{label:\"match\",width:\"5%\"},{label:\"mis-match\",width:\"7%\"},{label:\"rep. match\",width:\"7%\"},{label:\"N's\",width:\"3%\"},{label:\"Q gap count\",width:\"9%\"},{label:\"Q gap bases\",width:\"9%\"},{label:\"T gap count\",width:\"9%\"},{label:\"T gap bases\",width:\"9%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(const e of t){const t=[];e.querySelectorAll(\"div\").forEach((e=>t.push(e.innerText)));const[n,r,s]=t;i.push(`${n}:${r}-${s}`)}for(const e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),this.browser.search(i.join(\" \"))}}const Ud=\"https://igv.org/services/blatUCSC.php\";async function qd({url:e,userSeq:t,db:i}){if(e=e||Ud,!i)throw Error(\"Blat database is not defined\");const n=await async function(e=\"\",t,i){const n=new URLSearchParams;n.append(\"userSeq\",t),n.append(\"db\",i);const r=await fetch(e,{method:\"post\",body:n});return r.json()}(e,t,i);n.fields;return n.blat.map($c)}const Qd=25e3;class Vd extends Hd{constructor(e,t){super(e,t),this.name||(this.name=\"Blat Results\"),this.sequence=e.sequence,this.table=void 0,e.features&&(this._features=e.features,this.featureSource=new fd({features:e.features},this.browser.genome),delete e.features)}async postInit(){if(!this.featureSource){const e=this.browser.genome.id,t=this.browser.config.blatServerURL,i=await qd({url:t,userSeq:this.sequence,db:e});this._features=i,this.featureSource=new fd({features:i},this.browser.genome)}}openTableView(){if(void 0===this.table){const e=this._features.map((e=>[e.chr,e.start+1,e.end,e.strand,e.score,e.matches,e.misMatches,e.repMatches,e.nCount,e.qNumInsert,e.qBaseInsert,e.tNumInsert,e.tBaseInsert])),t={browser:this.browser,parent:this.browser.columnContainer,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:Od.getColumnFormatConfiguration(),gotoButtonHandler:Od.gotoButtonHandler};this.table=new Od(t),this.table.renderTable(e)}this.table.present()}menuItemList(){const e=super.menuItemList();return e.push(\"
\"),e.push({label:\"Open table view\",click:function(){this.openTableView()}}),e}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function jd({sequence:e,browser:t,name:i,title:n}){if(e.length>Qd)t.alert.present(`Sequence size exceeds maximum allowed length (${e.length} > 25000)`);else try{const r=t.genome.id,s=t.config.blatServerURL||\"https://igv.org/services/blatUCSC.php\",o={type:\"blat\",name:i||\"blat results\",title:n||\"blat results\",sequence:e,altColor:\"rgb(176, 176, 236)\",color:\"rgb(236, 176, 176)\",searchable:!1,features:await qd({url:s,userSeq:e,db:r})};(await t.loadTrack(o)).openTableView()}catch(e){t.alert.present(`Error performing blat search: ${e}`)}}const Wd=Number.MIN_SAFE_INTEGER,Gd={TTT:\"F\",TTC:\"F\",TTA:\"L\",TTG:\"L\",CTT:\"L\",CTC:\"L\",CTA:\"L\",CTG:\"L\",ATT:\"I\",ATC:\"I\",ATA:\"I\",ATG:\"M\",GTT:\"V\",GTC:\"V\",GTA:\"V\",GTG:\"V\",TCT:\"S\",TCC:\"S\",TCA:\"S\",TCG:\"S\",CCT:\"P\",CCC:\"P\",CCA:\"P\",CCG:\"P\",ACT:\"T\",ACC:\"T\",ACA:\"T\",ACG:\"T\",GCT:\"A\",GCC:\"A\",GCA:\"A\",GCG:\"A\",TAT:\"Y\",TAC:\"Y\",TAA:\"STOP\",TAG:\"STOP\",CAT:\"H\",CAC:\"H\",CAA:\"Q\",CAG:\"Q\",AAT:\"N\",AAC:\"N\",AAA:\"K\",AAG:\"K\",GAT:\"D\",GAC:\"D\",GAA:\"E\",GAG:\"E\",TGT:\"C\",TGC:\"C\",TGA:\"STOP\",TGG:\"W\",CGT:\"R\",CGC:\"R\",CGA:\"R\",CGG:\"R\",AGT:\"S\",AGC:\"S\",AGA:\"R\",AGG:\"R\",GGT:\"G\",GGC:\"G\",GGA:\"G\",GGG:\"G\"},$d={},Kd=[\"A\",\"G\",\"C\",\"T\",\"Y\",\"R\",\"W\",\"S\",\"K\",\"M\",\"D\",\"V\",\"H\",\"B\",\"N\",\"X\"],Yd=[\"T\",\"C\",\"G\",\"A\",\"R\",\"Y\",\"W\",\"S\",\"M\",\"K\",\"H\",\"B\",\"D\",\"V\",\"N\",\"X\"];for(let NA=0;NA{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?\"Close Translation\":\"Three-frame Translate\",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let e of this.trackView.viewports)e.setContentHeight(Xd);this.trackView.setTrackHeight(Xd)}else{for(let e of this.trackView.viewports)e.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(e){const t=e.viewport;if(t.referenceFrame.bpPerPixel<=1){const e=t.getWidth()*t.referenceFrame.bpPerPixel,i=t.referenceFrame.chr,n=Math.floor(t.referenceFrame.start),r=Math.ceil(n+e),s=[{label:this.reversed?\"View visible sequence (reversed)...\":\"View visible sequence...\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&s.push({label:\"Copy visible sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),s.push({label:\"BLAT read sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);if(e){this.reversed&&(e=cc(e));const t=`blat: ${i}:${n+1}-${r}`,s=`blat: ${i}:${n+1}-${r}`;jd({sequence:e,browser:this.browser,name:t,title:s})}}}),s.push(\"
\"),s}}translateSequence(e){const t=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;e.length-n>=3;){let r=e.slice(n,n+3);this.reversed&&(r=r.split(\"\").reverse().join(\"\"));const s=Gd[r.toUpperCase()]||\"\";t[i].push({codons:r,aminoA:s}),n+=3}}return t}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new Jd(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome}async getFeatures(e,t,i,n){if(t=Math.floor(t),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:t,sequence:await n.getSequence(e,t,i)}}}draw(e){const t=e.context;if(e.features){let i=e.features.sequence;if(!i)return;this.reversed&&(i=i.split(\"\").map((function(e){return $d[e]})).join(\"\"));const n=e.features.bpStart,r=1+e.bpStart+e.pixelWidth*e.bpPerPixel;for(let s=Math.floor(e.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r.1)xo.fillRect(t,n,5,o,10,{fillStyle:c});else{const i=n+.5*(o-t.measureText(a).width);\"y\"===e.axis?(t.save(),xo.labelTransformWithContext(t,i),xo.strokeText(t,a,i,15,{strokeStyle:c}),t.restore()):xo.strokeText(t,a,i,15,{strokeStyle:c})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;ie.pixelWidth)break;let f=c.aminoA;c.aminoA.indexOf(\"STOP\")>-1?(a=\"rgb(255, 0, 0)\",f=\"STOP\"):\"M\"===c.aminoA&&(a=\"rgb(0, 153, 0)\",f=\"START\"),xo.fillRect(t,h,r,d-h,25,{fillStyle:a}),e.bpPerPixel<=.1&&xo.strokeText(t,f,u-t.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(e){return this.height=this.frameTranslate?Xd:25,this.height}fillColor(e){return this.color?this.color:\"dna\"===this.sequenceType?this.browser.nucleotideColors[e]||\"gray\":\"rgb(0, 0, 150)\"}getState(){const e={type:\"sequence\"};return this.order!==Wd&&(e.order=this.order),this.reversed&&(e.revealed=!0),e}}class Jd{constructor(e,t){this.config=e,this.genome=t}async init(){this.fasta=await Nc(this.config),this.chrNameMap=new Map;for(let e of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(e),e)}async getSequence(e,t,i){const n=this.chrNameMap.has(e)?this.chrNameMap.get(e):e;return this.fasta.getSequence(n,t,i)}}class eu{constructor(e,t,i,n){this.guid=s(),this.trackView=e,this.referenceFrame=i,this.browser=e.browser,this.$viewport=Bt('
'),t.appendChild(this.$viewport.get(0)),e.track.height&&(this.$viewport.get(0).style.height=`${e.track.height}px`),e.track instanceof Zd&&(this.alert=new Ta(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(e){this.messageDiv||(this.messageDiv=document.createElement(\"div\"),this.messageDiv.className=\"igv-viewport-message\",this.$viewport.append(Bt(this.messageDiv))),this.messageDiv.textContent=e,this.messageDiv.style.display=\"inline-block\"}hideMessage(e){this.messageDiv&&(this.messageDiv.style.display=\"none\")}setTrackLabel(e){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(e){this.contentTop=e,this.$viewport.height()}async loadFeatures(){}clearCache(){}repaint(){}draw(e,t,i){console.log(\"Viewport - draw(drawConfiguration, features, roiFeatures)\")}checkContentHeight(e){let t=this.trackView.track;if(e=e||this.cachedFeatures,\"FILL\"===t.displayMode)this.setContentHeight(this.$viewport.height());else if(\"function\"==typeof t.computePixelHeight&&e&&e.length>0){let i=t.computePixelHeight(e);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(e){this.contentHeight=e}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(e){this.$viewport.width(e)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(e,t){console.log(\"Viewport - containsPosition(chr, position)\")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.$viewport.get(0).remove();for(let e of Object.keys(this))this[e]=void 0}}\n", - "/*!!\n", - " * Canvas 2 Svg v1.0.19\n", - " * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.\n", - " *\n", - " * Licensed under the MIT license:\n", - " * http://www.opensource.org/licenses/mit-license.php\n", - " *\n", - " * Author:\n", - " * Kerry Liu\n", - " *\n", - " * Copyright (c) 2014 Gliffy Inc.\n", - " */function tu(e,t){var i,n=Object.keys(t);for(i=0;i0){\"path\"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:t,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement(\"g\");t.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute(\"transform\");n?n+=\" \":n=\"\",n+=e,this.__currentElement.setAttribute(\"transform\",n)}addTrackGroupWithTranslationAndClipRect(e,t,i,n,r,s){const o=e+\"_clip_rect\";let a=this.__createElement(\"clipPath\",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement(\"rect\",{x:\"0\",y:s.toString(),width:n.toString(),height:r.toString()}));let c=this.__createElement(\"g\");this.__rootGroup.appendChild(c),c.setAttribute(\"transform\",tu(\"translate({x},{y})\",{x:t,y:i})),c.setAttribute(\"id\",e+\"_group\"),c.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:o})),this.__currentElement=c}scale(e,t){void 0===t&&(t=e),this.__addTransform(tu(\"scale({x},{y})\",{x:e,y:t}))}rotate(e){var t=180*e/Math.PI;this.__addTransform(tu(\"rotate({angle},{cx},{cy})\",{angle:t,cx:0,cy:0}))}translate(e,t){this.__addTransform(tu(\"translate({x},{y})\",{x:e,y:t}))}transform(e,t,i,n,r,s){this.__addTransform(tu(\"matrix({a},{b},{c},{d},{e},{f})\",{a:e,b:t,c:i,d:n,e:r,f:s}))}beginPath(){var e;this.__currentDefaultPath=\"\",this.__currentPosition={},e=this.__createElement(\"path\",{},!0),this.__closestGroupOrSvg().appendChild(e),this.__currentElement=e}__applyCurrentDefaultPath(){var e=this.__currentElement;\"path\"===e.nodeName?e.setAttribute(\"d\",this.__currentDefaultPath):console.error(\"Attempted to apply path command to node\",e.nodeName)}__addPathCommand(e){this.__currentDefaultPath+=\" \",this.__currentDefaultPath+=e}moveTo(e,t){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:e,y:t},this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand(\"Z\")}lineTo(e,t){this.__currentPosition={x:e,y:t},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf(\"M\")>-1?this.__addPathCommand(tu(\"L {x} {y}\",{x:e,y:t})):this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}bezierCurveTo(e,t,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(tu(\"C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}\",{cp1x:e,cp1y:t,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(e,t,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(tu(\"Q {cpx} {cpy} {x} {y}\",{cpx:e,cpy:t,x:i,y:n}))}arcTo(e,t,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error(\"IndexSizeError: The radius provided (\"+r+\") is negative.\");if(s===e&&o===t||e===i&&t===n||0===r)this.lineTo(e,t);else{var a=ru([s-e,o-t]),c=ru([i-e,n-t]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),d=ru([a[0]+c[0],a[1]+c[1]]),u=r/Math.sin(h/2),f=e+u*d[0],p=t+u*d[1],g=[-a[1],a[0]],m=[c[1],-c[0]],w=function(e){var t=e[0];return e[1]>=0?Math.acos(t):-Math.acos(t)},b=w(g),F=w(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,b,F)}else this.lineTo(e,t)}}}stroke(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"fill stroke markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"stroke\")}fill(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"stroke fill markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"fill\")}rect(e,t,i,n){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(e,t),this.lineTo(e+i,t),this.lineTo(e+i,t+n),this.lineTo(e,t+n),this.lineTo(e,t),this.closePath()}fillRect(e,t,i,n){n<0&&(t+=n,n=-n),i<0&&(e+=i,i=-i);var r,s,o,a={x:e,y:t,width:i,height:n};(!this.viewbox||(r=this.viewbox,s=a,r.xs.x&&r.ys.y))&&(o=this.__createElement(\"rect\",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement(\"fill\"))}strokeRect(e,t,i,n){var r;r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement(\"stroke\")}strokeEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"stroke\")}fillEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"fill\")}__ellipse(e,t,i,n,r,s,o,a,c){const l={cx:e,cy:t,rx:i,ry:n},h=this.__createElement(\"ellipse\",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var e=this.__closestGroupOrSvg().getAttribute(\"transform\"),t=this.__root.childNodes[1],i=t.childNodes,n=i.length-1;n>=0;n--)i[n]&&t.removeChild(i[n]);this.__currentElement=t,this.__groupStack=[],e&&this.__addTransform(e)}clearRect(e,t,i,n){if(0!==e||0!==t||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n,fill:\"#FFFFFF\"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(e,t,i,n){var r=this.__createElement(\"linearGradient\",{id:iu(this.__ids),x1:e+\"px\",x2:i+\"px\",y1:t+\"px\",y2:n+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(r),new au(r,this)}createRadialGradient(e,t,i,n,r,s){var o=this.__createElement(\"radialGradient\",{id:iu(this.__ids),cx:n+\"px\",cy:r+\"px\",r:s+\"px\",fx:e+\"px\",fy:t+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(o),new au(o,this)}__parseFont(){var e=/^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))(?:\\s*\\/\\s*(normal|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])))?\\s*([-,\\'\\\"\\sa-z0-9]+?)\\s*$/i.exec(this.font),t={style:e[1]||\"normal\",size:e[4]||\"10px\",family:e[6]||\"sans-serif\",weight:e[3]||\"normal\",decoration:e[2]||\"normal\",href:null};return\"underline\"===this.__fontUnderline&&(t.decoration=\"underline\"),this.__fontHref&&(t.href=this.__fontHref),t}__wrapTextLink(e,t){if(e.href){var i=this.__createElement(\"a\");return i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",e.href),i.appendChild(t),i}return t}__applyText(e,t,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement(\"text\",{\"font-family\":o.family,\"font-size\":o.size,\"font-style\":o.style,\"font-weight\":o.weight,\"text-decoration\":o.decoration,x:t,y:i,\"text-anchor\":(r=this.textAlign,s={left:\"start\",right:\"end\",center:\"middle\",start:\"start\",end:\"end\"},s[r]||s.start),\"dominant-baseline\":nu(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(e)),this.__currentElement=c,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,c))}fillText(e,t,i){this.__applyText(e,t,i,\"fill\")}strokeText(e,t,i){this.__applyText(e,t,i,\"stroke\")}measureText(e){return this.__ctx.font=this.font,this.__ctx.measureText(e)}arc(e,t,i,n,r,s){if(n!==r){(n%=2*Math.PI)===(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=e+i*Math.cos(r),a=t+i*Math.sin(r),c=e+i*Math.cos(n),l=t+i*Math.sin(n),h=s?0:1,d=0,u=r-n;u<0&&(u+=2*Math.PI),d=s?u>Math.PI?0:1:u>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(tu(\"A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}\",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:d,sweepFlag:h,endX:o,endY:a})),this.__currentPosition={x:o,y:a}}}clip(){var e=this.__closestGroupOrSvg(),t=this.__createElement(\"clipPath\"),i=iu(this.__ids),n=this.__createElement(\"g\");this.__applyCurrentDefaultPath(),e.removeChild(this.__currentElement),t.setAttribute(\"id\",i),t.appendChild(this.__currentElement),this.__defs.appendChild(t),e.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:i})),e.appendChild(n),this.__currentElement=n}drawImage(){var e,t,i,n,r,s,o,a,c,l,h,d,u,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)e=f[1],t=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)e=f[1],t=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error(\"Invalid number of arguments passed to drawImage: \"+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],e=f[5],t=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var w=\"translate(\"+e+\", \"+t+\")\";if(p instanceof lu){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)u=c.childNodes[0].getAttribute(\"id\"),this.__ids[u]=u,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,F=l.getAttribute(\"transform\");b=F?F+\" \"+w:w,l.setAttribute(\"transform\",b),o.appendChild(l)}}}else\"CANVAS\"!==p.nodeName&&\"IMG\"!==p.nodeName||((h=this.__createElement(\"image\")).setAttribute(\"width\",i),h.setAttribute(\"height\",n),h.setAttribute(\"preserveAspectRatio\",\"none\"),(g||m||r!==p.width||s!==p.height)&&((d=this.__document.createElement(\"canvas\")).width=i,d.height=n,d.getContext(\"2d\").drawImage(p,g,m,r,s,0,0,i,n),p=d),h.setAttribute(\"transform\",w),h.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===p.nodeName?p.toDataURL():p.getAttribute(\"src\")),o.appendChild(h))}createPattern(e,t){let i,n=this.__document.__createElement(\"pattern\"),r=iu(this.__ids);return n.setAttribute(\"id\",r),n.setAttribute(\"width\",e.width),n.setAttribute(\"height\",e.height),\"CANVAS\"===e.nodeName||\"IMG\"===e.nodeName?(i=this.__createElement(\"image\"),i.setAttribute(\"width\",e.width),i.setAttribute(\"height\",e.height),i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===e.nodeName?e.toDataURL():e.getAttribute(\"src\")),n.appendChild(i),this.__defs.appendChild(n)):e instanceof lu&&(n.appendChild(e.__root.childNodes[1]),this.__defs.appendChild(n)),new cu(n,this)}setLineDash(e){e&&e.length>0?this.lineDash=e.join(\",\"):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}function hu(e){if(e.startsWith(\"GCF\")||e.startsWith(\"GCA\")&&e.length>=13){return\"https://hgdownload.soe.ucsc.edu/hubs/\"+e.substring(0,3)+\"/\"+e.substring(4,7)+\"/\"+e.substring(7,10)+\"/\"+e.substring(10,13)+\"/\"+e+\"/hub.txt\"}}class du{static supportedTypes=new Set([\"bigBed\",\"bigWig\",\"bigGenePred\",\"vcfTabix\"]);static filterTracks=new Set([\"cytoBandIdeo\",\"assembly\",\"gap\",\"gapOverlap\",\"allGaps\",\"cpgIslandExtUnmasked\",\"windowMasker\"]);static async loadHub(e){const t=e.lastIndexOf(\"/\"),i=e.substring(0,t+1),n=await pu(e);let r;if(\"genome\"===n[1].type){const e=n[1];if(e.hasProperty(\"groups\")){const t=i+e.getProperty(\"groups\");r=await pu(t)}if(e.hasProperty(\"chromSizes\")){const t=i+e.getProperty(\"chromSizes\"),n=await async function(e){try{const t=(await fetch(e,{method:\"HEAD\"})).headers;return t.has(\"content-length\")?t.get(\"content-length\"):null}catch(e){return null}}(t);null!==n&&Number.parseInt(n)<1e6&&e.setProperty(\"chromSizesURL\",t)}}return new du(e,n,r)}constructor(e,t,i){this.url=e;const n=e.lastIndexOf(\"/\");if(this.baseURL=e.substring(0,n+1),\"hub\"!==t[0].type)throw Error(\"Unexpected hub.txt file -- does the first line start with 'hub'?\");if(this.hubStanza=t[0],\"on\"!==this.hubStanza.getProperty(\"useOneFile\"))throw Error(\"Only 'useOneFile' hubs are currently supported\");if(t.length<2)throw Error(\"Expected at least 2 stanzas, hub and genome\");if(\"genome\"!==t[1].type)throw Error(`Unexpected hub file -- expected \"genome\" stanza but found \"${t[1].type}\"`);this.genomeStanza=t[1],this.trackStanzas=[];for(let e=2;e0?e.substring(0,t):e}}this.genomeStanza.hasProperty(\"blat\")&&(r.blat=this.baseURL+this.genomeStanza.getProperty(\"blat\")),this.genomeStanza.hasProperty(\"chromAliasBb\")&&(r.chromAliasBbURL=this.baseURL+this.genomeStanza.getProperty(\"chromAliasBb\")),this.genomeStanza.hasProperty(\"chromAlias\")&&(r.aliasURL=this.baseURL+this.genomeStanza.getProperty(\"chromAlias\")),this.genomeStanza.hasProperty(\"twoBitBptURL\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptURL\")),this.genomeStanza.hasProperty(\"twoBitBptUrl\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptUrl\")),e.includeChromSizes&&this.genomeStanza.hasProperty(\"chromSizes\")&&(r.chromSizesURL=this.baseURL+this.genomeStanza.getProperty(\"chromSizes\")),this.hubStanza.hasProperty(\"longLabel\")?r.description=this.hubStanza.getProperty(\"longLabel\").replace(\"/\",\"\\n\"):(r.description=r.id,this.genomeStanza.hasProperty(\"description\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"description\")}`),this.genomeStanza.hasProperty(\"organism\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"organism\")}`),this.genomeStanza.hasProperty(\"scientificName\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"scientificName\")}`),this.genomeStanza.hasProperty(\"htmlPath\")&&(r.infoURL=this.baseURL+this.genomeStanza.getProperty(\"htmlPath\")));const s=this.trackStanzas.filter((e=>\"cytoBandIdeo\"===e.name&&e.hasProperty(\"bigDataUrl\")));s.length>0&&(r.cytobandBbURL=this.baseURL+s[0].getProperty(\"bigDataUrl\"));return r.tracks=this.#g((e=>!du.filterTracks.has(e.name)&&\"hide\"!==e.getProperty(\"visibility\"))),r}getGroupedTrackConfigurations(){const e=new Map;for(let t of this.#g()){if(\"cytoBandIdeo\"===t.name)continue;const i=t.group||\"other\";e.has(i)?e.get(i).push(t):e.set(i,[t])}const t=this.groupStanzas?new Map(this.groupStanzas.map((e=>[e.getProperty(\"name\"),e]))):new Map;return Array.from(e.keys()).map((i=>({label:t.has(i)?t.get(i).getProperty(\"label\"):i,tracks:e.get(i)})))}#g(e){return this.trackStanzas.filter((t=>du.supportedTypes.has(t.format)&&t.hasProperty(\"bigDataUrl\")&&(!e||e(t)))).map((e=>this.#m(e)))}#m(e){const t=e.format,i={id:e.getProperty(\"track\"),name:e.getProperty(\"shortLabel\"),format:t,url:this.baseURL+e.getProperty(\"bigDataUrl\"),displayMode:e.displayMode};if(\"vcfTabix\"===t&&(i.indexURL=i.url+\".tbi\"),e.hasProperty(\"longLabel\")&&e.hasProperty(\"html\")?(i.description&&(i.description+=\"
\"),i.description=`${e.getProperty(\"longLabel\")}`):e.hasProperty(\"longLabel\")&&(i.description=e.getProperty(\"longLabel\")),e.hasProperty(\"autoScale\")&&(i.autoscale=\"on\"===e.getProperty(\"autoScale\").toLowerCase()),e.hasProperty(\"maxHeightPixels\")){const t=e.getProperty(\"maxHeightPixels\").split(\":\");i.maxHeight=Number.parseInt(t[0]),i.height=Number.parseInt(t[1]),i.minHeight=Number.parseInt(t[2])}if(e.hasProperty(\"color\")){const t=e.getProperty(\"color\");i.color=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"altColor\")){const t=e.getProperty(\"altColor\");i.altColor=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"viewLimits\")){const t=e.getProperty(\"viewLimits\").split(\":\");let n,r;t.length>1&&(n=Number.parseInt(t[0]),r=Number.parseInt(t[1])),Number.isNaN(r)||Number.isNaN(n)?console.warn(`Unexpected viewLimits value in track line: ${properties.viewLimits}`):(i.min=n,i.max=r)}if(e.hasProperty(\"itemRgb\"),\"hide\"===e.getProperty(\"visibility\")&&(i.visible=!1),e.hasProperty(\"url\")&&(i.infoURL=e.getProperty(\"url\")),e.hasProperty(\"searchIndex\")&&(i.searchIndex=e.getProperty(\"searchIndex\")),e.hasProperty(\"searchTrix\")&&(i.trixURL=this.baseURL+e.getProperty(\"searchTrix\")),e.hasProperty(\"group\")&&(i.group=e.getProperty(\"group\"),this.groupPriorityMap&&this.groupPriorityMap.has(i.group))){const e=this.groupPriorityMap.get(i.group)+1;i.order=e,this.groupPriorityMap.set(i.group,e)}return i}}function uu(e){const t=e.indexOf(\" \");return t>0?e.substring(0,t):e}class fu{properties=new Map;constructor(e,t){this.type=e,this.name=t}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.has(e)?this.properties.get(e):this.parent?this.parent.getProperty(e):void 0}hasProperty(e){return!!this.properties.has(e)||!!this.parent&&this.parent.hasProperty(e)}get format(){const e=this.getProperty(\"type\");if(e)return uu(e)}get displayMode(){let e=this.getProperty(\"visibility\");if(!e)return\"COLLAPSED\";switch(e=e.toLowerCase(),e){case\"dense\":default:return\"COLLAPSED\";case\"pack\":return\"EXPANDED\";case\"squish\":return\"SQUISHED\"}}}async function pu(e){const t=await fetch(e),i=(await t.text()).split(/\\n|\\r\\n|\\r/g),n=[];let r,s=!0;for(let e of i){const t=gu(e),i=e.indexOf(\" \",t);if(i<0)s=!0;else{const o=e.substring(t,i).trim();if(o.startsWith(\"#\"))continue;const a=e.substring(i+1).trim();if(s){const e=new fu(o,a);n.push(e),r=e,s=!1}r.setProperty(o,a)}}return function(e){const t=new Map;for(let i of e)t.set(i.name,i);for(let i of e)if(i.properties.has(\"parent\")){const e=uu(i.properties.get(\"parent\"));i.parent=t.get(e)}return e}(n)}function gu(e){let t=0;for(t=0;t=13)try{const e=hu(i);t=(await du.loadHub(e)).getGenomeConfig()}catch(e){console.error(e)}t||e.present(new Error(`Unknown genome id: ${i}`),void 0)}return t}return t}};let wu,bu,Fu=0,vu=0,yu=[];class Au extends eu{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.$spinner=Bt(\"
\",{class:\"igv-loading-spinner-container\"}),this.$viewport.append(this.$spinner),this.$spinner.append(Bt(\"
\"));const e=this.trackView.track;\"sequence\"!==e.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),\"sequence\"!==e.id&&(this.$trackLabel=Bt('
'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(e.name||\"\"),!1===this.browser.doShowTrackLabels&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(e){super.setContentHeight(e),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(e){this.$trackLabel.empty(),this.$trackLabel.html(e);const t=this.$trackLabel.text();this.$trackLabel.attr(\"title\",t)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&\"sequence\"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return Bt(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if(\"all\"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const e=this.trackView.track.visibilityWindow;return void 0!==e&&e>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>e}return!0})()){if(this.canvas&&(Bt(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const e=this.trackView.minHeight||0;this.setContentHeight(e)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const e=this.referenceFrame;this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===e.bpPerPixel&&(this.canvas._data.pixelShift=Math.round((this.canvas._data.bpStart-e.start)/e.bpPerPixel),this.canvas.style.left=this.canvas._data.pixelShift+\"px\")}genomicRange(){return{start:this.referenceFrame.start,end:this.referenceFrame.start+this.referenceFrame.bpPerPixel*this.$viewport.width()}}setTop(e){if(super.setTop(e),this.canvas){const t=this.$viewport.height(),i=e+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n0)for(let n of i.roiSets){const i=await n.getFeatures(t,s,o,e.bpPerPixel);r.push({track:n,features:i})}const a=i&&i.resolutionAware,c=this.windowFunction;return this.featureCache=new Cu(t,s,o,e.bpPerPixel,n,r,a,c),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(e){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage(\"Error loading track data\"),this.browser.alert.present(e),console.error(e))}finally{this.loading=!1,this.stopSpinner()}}}get track(){return this.trackView.track}get windowFunction(){return this.track?this.track.windowFunction:void 0}repaintDimensions(){const e=mu.isWholeGenomeView(this.referenceFrame.chr),t=e?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(e?0:this.$viewport.width()*i),bpEnd:e?Number.MAX_SAFE_INTEGER:this.referenceFrame.start+2*this.$viewport.width()*i+1,pixelWidth:t}}repaint(){if(void 0===this.featureCache)return;const{features:e,roiFeatures:t}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=t?Math.max(o,s):o,c=Math.min(a,3*s);if(0===r||0===c)return void(this.canvas&&Bt(this.canvas).remove());const l=Math.max(0,-this.contentTop-Math.floor(c/3)),h=this.referenceFrame.bpPerPixel,d=Math.round((i-this.referenceFrame.start)/h),u=(this.contentTop||0)+l,f=document.createElement(\"canvas\");f.style.position=\"relative\",f.style.display=\"block\",f.style.width=r+\"px\",f.style.height=c+\"px\",f.style.left=d+\"px\",f.style.top=u+\"px\";const p=\"FILL\"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*c;const g=f.getContext(\"2d\");g.scale(p,p),g.translate(0,-l);const m={context:g,pixelXOffset:d,pixelWidth:r,pixelHeight:c,pixelTop:l,bpStart:i,bpEnd:n,bpPerPixel:h,pixelShift:d,windowFunction:this.windowFunction,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,e,t),this.canvas&&Bt(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(Bt(f))}refresh(){if(!this.canvas||!this.featureCache)return;const e=this.canvas._data;e.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:t,roiFeatures:i}=this.featureCache;this.draw(e,t,i)}draw(e,t,i){if(t&&(e.features=t,this.trackView.track.draw(e)),i&&i.length>0)for(let t of i)e.features=t.features,t.track.draw(e)}containsPosition(e,t){return this.referenceFrame.chr===e&&t>=this.referenceFrame.start&&t<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const e=this.canvas._data,t=e?e.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-Bt(this.canvas).position().left*i,o=(-this.contentTop-t)*i,a=this.canvas.getContext(\"2d\").getImageData(s,o,n,r),c=document.createElement(\"canvas\"),l=c.getContext(\"2d\");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);Pt((this.$trackLabel.text()?this.$trackLabel.text():\"image\")+\".png\",c.toDataURL(\"image/png\"))}saveSVG(){let{width:e,height:t}=this.browser.columnContainer.getBoundingClientRect();const i=new lu({width:e,height:8e3,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),n={deltaX:32,deltaY:32};this.renderSVGContext(i,n,!1),i.setHeight(t);const r=(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\"),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),a=i.getSerializedSvg(!0),c=URL.createObjectURL(new Blob([a],{type:\"application/octet-stream\"}));Pt(`${`${r}_referenceFrame_${o}_guid_${s()}`}.svg`,c)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){if(!(this.$zoomInNotice&&this.$zoomInNotice.is(\":visible\"))){const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,a=t,c=i+this.contentTop,l=-this.contentTop;e.saveWithTranslationAndClipRect(o,a,c,n,r,l);const{start:h,bpPerPixel:d}=this.referenceFrame,u=Math.round((h-this.referenceFrame.start)/d),f={context:e,viewport:this,referenceFrame:this.referenceFrame,top:l,pixelTop:l,pixelWidth:n,pixelHeight:r,pixelXOffset:u,pixelShift:u,bpStart:h,bpEnd:h+n*d,bpPerPixel:d,viewportWidth:n,selection:this.selection},p=this.featureCache?this.featureCache.features:void 0,g=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(f,p,g),e.restore()}if(n&&this.$trackLabel&&this.browser.doShowTrackLabels){const{x:n,y:r,width:s,height:o}=((e,t)=>{const{x:i,y:n,width:r,height:s}=e.getBoundingClientRect(),{x:o,y:a,width:c,height:l}=t.getBoundingClientRect();return{x:o-i,y:a-n,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(e,t+n,i+r,s,o)}}renderTrackLabelSVG(e,t,i,n,r){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_track_label_guid_${s()}`;e.saveWithTranslationAndClipRect(o,t,i,n,r,0),e.fillStyle=\"white\",e.fillRect(0,0,n,r),e.font=\"12px Arial\",e.fillStyle=\"rgb(68, 68, 68)\";const{width:a}=e.measureText(this.$trackLabel.text()),c=.25*(n-a),l=.7*(r-12);e.fillText(this.$trackLabel.text(),c,r-l),e.strokeStyle=\"rgb(68, 68, 68)\",e.strokeRect(0,0,n,r),e.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(e,t,i,n,r){if(this.featureCache&&this.featureCache.containsRange(t,i,n,r,this.windowFunction))return this.featureCache.features;if(\"function\"==typeof e.getFeatures){const s=await e.getFeatures(t,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const e=this.canvas._data;return!e||this.referenceFrame.starte.bpEnd||this.referenceFrame.chr!==e.referenceFrame.chr||this.referenceFrame.bpPerPixel!=e.bpPerPixel||this.windowFunction!=e.windowFunction}needsReload(){if(!this.featureCache)return!0;const{chr:e,bpPerPixel:t}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(e,i,n,t,this.windowFunction)}createZoomInNotice(e){const t=Bt(\"
\",{class:\"igv-zoom-in-notice-container\"});e.append(t);const i=Bt(\"
\");return t.append(i),i.text(\"Zoom in to see features\"),t.hide(),t}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const e=this.$viewport.get(0);this.addViewportContextMenuHandler(e);const t=e=>{this.enableClick=!0,this.browser.mouseDownOnViewport(e,this),r(e)};e.addEventListener(\"mousedown\",t),e.addEventListener(\"touchstart\",t);const i=e=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};e.addEventListener(\"mouseup\",i),e.addEventListener(\"touchend\",i),\"function\"==typeof this.trackView.track.hoverText&&e.addEventListener(\"mousemove\",(e=>{if(0===e.buttons&&Date.now()-vu>100){vu=Date.now();const t=this.createClickState(e);if(t){const e=this.trackView.track.hoverText(t);e?this.$viewport[0].setAttribute(\"title\",e):this.$viewport[0].removeAttribute(\"title\")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&\"sequence\"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(e){e.addEventListener(\"contextmenu\",(e=>{if(this.browser.dragObject)return!1;const t=this.createClickState(e);if(void 0===t)return!1;e.preventDefault();let i=[];if(\"function\"==typeof this.trackView.track.contextMenuItemList){const e=this.trackView.track.contextMenuItemList(t);e&&(i=e)}i.length>0&&i.push({label:Bt(\"
\")}),i.push({label:\"Save Image (PNG)\",click:()=>this.savePNG()}),i.push({label:\"Save Image (SVG)\",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(e,i)}))}addViewportClickHandler(e){e.addEventListener(\"click\",(e=>{if(this.enableClick&&this.canvas){if(3===e.which||e.ctrlKey)return;if(this.browser.dragObject||this.browser.isScrolling)return;e.preventDefault();const t=a(e,this.$viewport.get(0)).x,i=a(e,this.canvas).x,n=this.referenceFrame;Math.floor(n.start+n.toBP(i));const r=Date.now();if(r-Fue));e[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=t,i=e.join(\" \")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,e,this.referenceFrame)}else\"function\"==typeof this.trackView.track.popupData&&(wu=setTimeout((()=>{const t=this.getPopupContent(e);if(t)if(!1===e.shiftKey){if(bu&&bu.dispose(),yu.length>0){for(const e of yu)e.dispose();yu.length=0}bu=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{bu.dispose()})),bu.presentContentWithEvent(e,t)}else{let i=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{const e=yu.indexOf(i);yu.splice(e,1),i.dispose()}));yu.push(i),i.presentContentWithEvent(e,t)}window.clearTimeout(wu),wu=void 0}),this.browser.constants.doubleClickDelay));Fu=r}}))}addTrackLabelClickHandler(e){e.addEventListener(\"click\",(e=>{e.stopPropagation();const{track:t}=this.trackView;let i;\"function\"==typeof t.description?i=t.description():t.description&&(i=`
${t.description}
`),i&&(void 0===this.popover&&(this.popover=new tc(this.browser.columnContainer,!0,t.name||\"\",void 0)),this.popover.presentContentWithEvent(e,i))}))}createClickState(e){if(!this.canvas)return;const t=this.referenceFrame,i=a(e,this.$viewport.get(0)),n=a(e,this.canvas),r=t.start+t.toBP(i.x);return{event:e,viewport:this,referenceFrame:t,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(e){const t=this.createClickState(e);if(void 0===t)return;let i=this.trackView.track;const n=i.popupData(t),r=this.browser.fireEvent(\"trackclick\",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((e=>{if(e.name){const t=`${e.name}   ${e.value}`;return`
${t}
`}return\"
\"===e?e:e.html?e.html:`
${e}
`})).join(\"\")):\"string\"==typeof r&&(s=r),s}dispose(){this.popover&&this.popover.dispose(),super.dispose()}}class Cu{constructor(e,t,i,n,r,s,o,a){this.chr=e,this.bpStart=t,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o,this.windowFunction=a}containsRange(e,t,i,n,r){if(r&&r!==this.windowFunction)return!1;const s=this.multiresolution?this.bpPerPixel/n:1;return t>=this.bpStart&&i<=this.bpEnd&&e===this.chr&&s>.5&&s<2}overlapsRange(e,t,i){return this.chr===e&&i>=this.bpStart&&t<=this.bpEnd}}const _u=function(e,t){const{r:i,g:n,b:r}=no[e];return`rgba(${i},${n},${r},${t})`}(\"nickel\",2/16),xu=_u;class ku{constructor(e,t){if(this.url=e.url,e.name&&(this.name=e.name),this.isUserDefined=e.isUserDefined,e.featureSource)this.featureSource=e.featureSource;else if(e.features)this.featureSource=new Su(e.features,t);else{if(!e.format)throw Error(\"ROI configuration must define either features or file format\");this.featureSource=Ad(e,t)}!0===this.isUserDefined?(this.color=e.color||xu,this.headerColor=\"rgba(155,185,129)\"):(this.color=e.color||_u,this.headerColor=\"rgb(190,190,190)\"),this.isVisible=void 0===e.isVisible||e.isVisible}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}async getAllFeatures(){return\"function\"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(e){this.featureSource.addFeature(e)}removeFeature(e){this.featureSource.removeFeature(e)}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined,isVisible:this.isVisible};{const e=this.featureSource.getAllFeatures(),t=[];for(let i of Object.keys(e))for(let n of e[i])t.push(n);return{name:this.name,color:this.color,features:t,isUserDefined:this.isUserDefined,isVisible:this.isVisible}}}dispose(){for(let e of Object.keys(this))this[e]=void 0}}function Iu(e,t,i,n){let r=Math.round((e-i)/n);let s=Math.round((t-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class Su{constructor(e,t){this.featureMap={},this.genome=t;for(let i of e){const e=t?t.getChromosomeName(i.chr):i.chr;let n=this.featureMap[e];n||(n=[],this.featureMap[e]=n),n.push(i)}for(let e of Object.keys(this.featureMap))this.featureMap[e].sort(((e,t)=>e.start-t.start))}async getFeatures({chr:e,start:t,end:i}){if(\"all\"===e.toLowerCase())return Ll(this.featureMap,this.genome);{const n=this.featureMap[e];return n?n.filter((e=>e.end>t&&e.starte.start-t.start))}removeFeature({chr:e,start:t,end:i}){if(this.featureMap[e]){const n=`${e}-${t}-${i}`;this.featureMap[e]=this.featureMap[e].filter((e=>n!==`${e.chr}-${e.start}-${e.end}`)),0===this.featureMap[e].length&&delete this.featureMap[e]}}}class Eu{constructor(t,i,n,r){this.rulerViewport=t,this.rulerSweeper=e({class:\"igv-ruler-sweeper\"}),i.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(mu.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on(\"locuschange\",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off(\"locuschange\",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let e,t,i,n,r,s;this.boundContentMouseDownHandler=function(s){e=!0,t=!0;const{x:o}=a(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display=\"block\",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?xu:\"rgba(68, 134, 247, 0.25)\",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener(\"mousedown\",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let c;if(e&&t){const{x:e}=a(o,this.rulerViewport.contentDiv);c=Math.max(Math.min(e,this.rulerViewport.contentDiv.clientWidth),0),s=c-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;if(!0===e&&!0===t&&(e=t=void 0,this.rulerSweeper.style.display=\"none\",r>1)){s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))};!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(Qa(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(e,t,i){e.start=Math.round(t.start),e.end=Math.round(t.end),e.bpPerPixel=(e.end-e.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener(\"mousedown\",this.boundContentMouseDownHandler),document.removeEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),document.removeEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}function Nu(e){if(Bu[e])return Bu[e];if(Bu[\"chr\"+e]){const t=Bu[\"chr\"+e];return Bu[e]=t,t}{const t=_s.randomRGB(0,255);return Bu[e]=t,t}}const Bu={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0)\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};let Mu,Ru;class Du extends Au{constructor(e,t,i,n){super(e,t,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let e;this.$multiLocusCloseButton=Bt(\"
\",{class:\"igv-multi-locus-close-button\"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(l(\"times-circle\")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=Bt(\"
\",{class:\"igv-multi-locus-ruler-label\"}),this.$viewport.append(this.$rulerLabel),e=document.createElement(\"div\"),this.$rulerLabel.append(Bt(e)),this.$rulerLabel.get(0).addEventListener(\"click\",(async e=>{e.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=Bt(\"
\",{class:\"igv-ruler-tooltip\"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=Bt(\"
\"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new Eu(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(mu.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(e){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=Nu(this.referenceFrame.chr);const t=this.$rulerLabel.get(0).querySelector(\"div\"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();t.innerHTML=`${this.referenceFrame.getMultiLocusLabel(e)}`;const{width:n}=t.getBoundingClientRect();n/i>.5&&(t.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(e)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(e){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===e){const e=this.browser.referenceFrameList.indexOf(this.referenceFrame),t=`click${this.namespace}`;this.$viewport.on(t,(t=>{const{x:i}=a(t,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let t=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));t[e]=s,r=t.join(\" \")}this.browser.search(r)})),this.$viewport.get(0).style.cursor=\"pointer\"}else this.$viewport.get(0).style.cursor=\"default\"}mouseMove(e){if(!0===this.browser.doShowCursorGuide){void 0===Ru?(Ru=this,this.$tooltip.show()):Ru.guid!==this.guid?(Ru.$tooltip&&Ru.$tooltip.hide(),this.$tooltip.show(),Ru=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:t}=a(e,this.$viewport.get(0)),{start:i,end:n,bpPerPixel:r}=this.referenceFrame,s=Math.round(.5+i+Math.max(0,t)*r);this.$tooltipContent.text(Rt(s));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:c}=this.$viewport.get(0).getBoundingClientRect();return this.$tooltip.css({left:`${ys.clamp(t,0,c-o)}px`}),clearTimeout(Mu),Mu=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4),{start:i,bp:s,end:n}}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class Tu extends Au{featureCache=new Lu;constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.canvas=document.createElement(\"canvas\"),this.canvas.className=\"igv-ideogram-canvas\",this.$viewport.append(Bt(this.canvas)),this.ideogram_ctx=this.canvas.getContext(\"2d\"),this.addMouseHandlers()}async getFeatures(e,t,i,n){return this.featureCache.containsRange(e)?this.featureCache.get(e):this.loadFeatures()}async loadFeatures(){const e=this.referenceFrame.chr,t=await this.referenceFrame.genome.getCytobands(e);return this.featureCache.set(e,t),t}repaint(){if(void 0===this.featureCache)return;const{width:e,height:t}=this.$viewport[0].getBoundingClientRect();xo.configureHighDPICanvas(this.ideogram_ctx,e,t);const i=this.referenceFrame.chr,n=this.featureCache.get(i),r={context:this.ideogram_ctx,pixelWidth:e,pixelHeight:t,referenceFrame:this.referenceFrame,features:n};this.trackView.track.draw(r)}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(e){this.boundClickHandler=function(e){const{xNormalized:t,width:i}=a(e,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=t;s-r/2<0&&(s=r/2);s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),c=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=c,this.referenceFrame.bpPerPixel=(c-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),e.addEventListener(\"click\",this.boundClickHandler)}setWidth(e){this.$viewport.width(e)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){const{width:r,height:o}=this.$viewport.get(0).getBoundingClientRect(),a=`ideogram_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,c=t,l=i+this.contentTop,h=-this.contentTop;e.saveWithTranslationAndClipRect(a,c,l,r,o,h),this.trackView.track.draw({context:e,pixelWidth:r,pixelHeight:o,referenceFrame:this.referenceFrame,features:this.featureCache.get(this.referenceFrame.chr)}),e.restore()}startSpinner(){}stopSpinner(){}}class Lu{features=new Map;containsRange(e){return this.features.has(e)}set(e,t){this.features.set(e,t)}get(e){return this.features.get(e)}}function zu(e,t,i,n){if(\"ruler\"===e.track.type)return new Du(e,t,i,n);if(\"ideogram\"===e.track.id)return new Tu(e,t,i,n);{const r=new Au(e,t,i,n);return i.viewport=r,r}}const Hu=[\"rgb(255, 0, 0)\",\"rgb(0, 255, 0)\",\"rgb(0, 0, 255)\",\"rgb(255, 0, 255)\",\"rgb(0, 255, 255)\",\"rgb(128, 0, 128)\",\"rgb(255, 165, 0)\",\"rgb(255, 105, 180)\",\"rgb(255, 127, 80)\",\"rgb(220, 20, 60)\",\"rgb(255, 99, 71)\",\"rgb(173, 216, 230)\",\"rgb(144, 238, 144)\",\"rgb(224, 255, 255)\",\"rgb(250, 250, 210)\",\"rgb(152, 251, 152)\",\"rgb(70, 130, 180)\",\"rgb(102, 205, 170)\"].map((e=>{const[t,i,n]=e.split(\",\"),[r,s]=t.split(\"(\"),[o,a]=n.split(\")\");return[s,i,o]})),Pu=ro(\"magnesium\"),Ou=[\"#sampleTable\",\"#sampleMapping\",\"#colors\"];class Uu{static emptySpaceReplacement=\"|\";sampleDictionary={};attributeNames=[];sampleMappingDictionary={};colorDictionary={};attributeRangeLUT={};constructor(e){e.tracks.some((e=>\"function\"==typeof e.getSamples)).length>0&&e.sampleInfoControl.setButtonVisibility(!0),this.initialize()}initialize(){this.sampleInfoFiles=[],this.attributeNames=[],this.sampleDictionary={},this.sampleMappingDictionary={},this.colorDictionary={},this.attributeRangeLUT={},this.initialized=!1}get attributeCount(){return this.attributeNames?this.attributeNames.length:0}isInitialized(){return this.initialized}hasAttributes(){return this.attributeCount>0}getAttributes(e){const t=0===Object.keys(this.sampleMappingDictionary)?e:this.sampleMappingDictionary[e]||e;return this.sampleDictionary[t]}async loadSampleInfoFile(e){try{const t=await Qs.loadString(e);this.#w(t),this.sampleInfoFiles.push(e)}catch(e){console.error(e.message)}}#w(e){const t=function(e){const t={},i=e.split(/\\r?\\n|\\r/).map((e=>e.trim())).filter((e=>\"\"!==e));let n;Ou.includes(i[0])||(n=\"#sampleTable\",t[n]=[]);for(const e of i)Ou.includes(e)?(n=e,t[n]=[]):n&&!1===e.startsWith(\"#\")&&t[n].push(e);return t}(e);for(const[e,i]of Object.entries(t))switch(e){case\"#sampleTable\":this.#b(i);break;case\"#sampleMapping\":this.#F(i);break;case\"#colors\":this.#v(i)}this.initialized=!0}getAttributeColor(e,t){let i;if(\"-\"===t)i=ro(\"snow\");else if(\"string\"==typeof t&&this.colorDictionary[t])i=this.colorDictionary[t]();else if(this.colorDictionary[e])i=this.colorDictionary[e](t);else if(\"string\"==typeof t)i=\"NA\"===t?Pu:function(e){let t=0;for(let i=0;i>8*e&255;i.push(n)}return`rgb(${i.join(\", \")})`}(t);else{const[n,r]=this.attributeRangeLUT[e],s=.2,o=Math.max((t-n)/(r-n),s),[a,c,l]=Hu[Object.keys(this.attributeRangeLUT).indexOf(e)];i=`rgba(${a},${c},${l},${o})`}return i}getSortedSampleKeysByAttribute(e,t,i){i=i||1;const n=e.filter((e=>\"number\"==typeof this.getAttributes(e)[t])),r=e.filter((e=>\"string\"==typeof this.getAttributes(e)[t])),s=(e,n)=>{const r=this.getAttributes(e)[t],s=this.getAttributes(n)[t];return\"string\"==typeof r&&\"string\"==typeof s?i*r.localeCompare(s):\"number\"==typeof r&&\"number\"==typeof s?i*(r-s):void 0};return n.sort(s),r.sort(s),-1===i?[...n,...r]:[...r,...n]}toJSON(){const e=[];for(const t of this.sampleInfoFiles){const i={url:t},n=Hl.localFileInspection(i);e.push(n)}return e}#b(e){const t=e.shift().split(\"\\t\").filter((e=>e.length>0));t.shift();const i=t.map((e=>e.split(\" \").join(Uu.emptySpaceReplacement))),n=e.filter((e=>e.length>0));let r;for(const e of n){const t=e.split(\"\\t\"),n=t.shift();void 0===r&&(r={}),r[n]={};for(let e=0;e\"number\"==typeof e,r=e=>\"string\"==typeof e;for(const e of Object.keys(i)){const t=i[e],s=new Set(t),o=Array.from(s);if(!0===o.some(r)&&!0===o.some(n)?i[e]=o.filter((e=>!r(e))):i[e]=o,!i[e].some(r)){const t=i[e].slice();i[e]=[Math.min(...t),Math.max(...t)]}}return i}(i,r);qu(this.attributeRangeLUT,s);const o=new Set(this.attributeNames);for(const e of i)o.has(e)||this.attributeNames.push(e);qu(this.sampleDictionary,r)}#F(e){for(const t of e){const[e,i]=t.split(\"\\t\");this.sampleMappingDictionary[e]=i}}#v(e){const t=(e,t,i)=>{let n;switch(t){case 0:n=e.split(\" \").join(Uu.emptySpaceReplacement);break;case 1:n=e.includes(\":\")?e.split(\":\").map((e=>parseFloat(e))):e;break;case 2:case 3:n=`rgb(${e})`}return n},i=e.map((e=>e.split(\"\\t\").map(t))),n=i.filter((e=>3===e.length&&!e.includes(\"*\"))).filter((([e,t,i])=>!Array.isArray(t))),r={};for(const e of n){const[t,i,n]=e;void 0===r[t]&&(r[t]={}),r[t][i.toUpperCase()]=n}for(const[e,t]of Object.entries(r)){const i=Object.assign({},t);this.colorDictionary[e]=e=>{const t=e.toUpperCase();return i[t]||ro(\"snow\")}}const s=i.filter((e=>Array.isArray(e[1])));for(const e of s){const[t,i]=e[1],n=e[0];if(3===e.length){const[r,s,o]=uo(e[2]);this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return lo(r,s,o,(e-t)/(i-t))}}else if(4===e.length){const[t,i]=e[1],[n,r,s,o]=e;this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return fo(s,o,(e-t)/(i-t))}}}const o=i.filter((e=>3===e.length&&e.includes(\"*\")));for(const e of o)if(\"*\"===e[1]){const[t,i,n]=e;this.colorDictionary[t]=e=>{if(\"NA\"===e)return Pu;{const[i,r]=this.attributeRangeLUT[t],s=(e-i)/(r-i),[o,a,c]=uo(n);return lo(o,a,c,s)}}}else if(\"*\"===e[0]){const[t,i,n]=e;this.colorDictionary[i]=()=>n}}}function qu(e,t){for(const[i,n]of Object.entries(t))i in e&&e[i]===n||(e[i]=n)}function Qu(e){const t=Object.assign({},e);for(const[e,i]of Object.entries(t))\"string\"!=typeof i||isNaN(i)||(t[e]=Number(i));return t}const Vu=16,ju=Rt;class Wu{constructor(e){this.browser=e,this.height=40,this.name=\"\",this.id=\"ruler\",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type=\"ruler\"}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){mu.isWholeGenomeView(t.chr)?this.drawWholeGenome({context:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n}){e.save(),xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"});for(let t of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(t),s=this.browser.genome.getChromosome(t).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(e,o,0,a,i,t)}e.restore()}doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:r}){e.clearRect(0,0,i,n);const s=function(e,t){if(e<10)return new Gu(1,\"bp\",1);const i=Math.floor(Math.log10(e));let n=\"bp\",r=1;i>9?(n=\"gb\",r=1e9):i>6?(n=\"mb\",r=1e6):i>3&&(n=\"kb\",r=1e3);const s=Math.pow(10,i-1),o=e/s,a=75,c=Math.pow(10,i-1),l=Math.pow(10,i)/2;return new Gu(o0&&u+c<=d&&(xo.fillText(e,i,n,this.height-8),d=0),l>0&&xo.strokeLine(e,l,this.height-6,l,this.height-2),h=Math.floor((1+o)*s.majorTick);let f=l+(Math.round(t.toPixels(h-1-r+.5))-l)/2;f>0&&xo.strokeLine(e,f,this.height-6,f,this.height-2),++o,d+=a}while(le.measureText(o).width&&xo.fillText(e,o,t+n/2,i+r/2,{fillStyle:_s.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Gu{constructor(e,t,i){this.majorTick=e,this.minorTick=e/10,this.majorUnit=t,this.unitMultiplier=i}description(e){console.log((e||\"\")+\" tick \"+ju(this.majorTick)+\" label width \"+ju(this.labelWidthBP)+\" multiplier \"+this.unitMultiplier)}}class $u{constructor(t,i,n){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),this.viewport.style.height=`${t.track.height}px`,null===this.viewport.previousElementSibling&&(this.viewport.style.zIndex=16,this.viewport.style.overflow=\"visible\"),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.ctx.font=\"10px verdana\",this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(n),this.addMouseHandlers()}resizeCanvas(){const e=window.devicePixelRatio,t=this.browser.getSampleInfoViewportWidth();let i;if(this.browser.trackViews.length>1&&null===this.viewport.previousElementSibling){const[e,t]=[this.browser.ideogramTrackView.track,this.browser.rulerTrackView.track];i=e.height+t.height}else i=this.viewport.clientHeight;if(this.canvas.width!==t*e||this.canvas.height!==i*e){const n=this.canvas;n.width=t*e,n.height=i*e,n.style.width=`${t}px`,n.style.height=`${i}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(e,e),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}}setTop(e){\"function\"==typeof this.trackView.track.getSamples&&(this.contentTop=e,this.repaint())}setWidth(e){this.viewport.innerWidth=e,this.resizeCanvas()}setHeight(e){const t=this.browser.getSampleInfoViewportWidth();this.viewport.style.width=`${t}px`,this.viewport.style.height=`${e}px`;const i=window.devicePixelRatio;this.canvas.width=t*i,this.canvas.height=e*i,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(i,i),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}async repaint(){if(this.resizeCanvas(),\"function\"==typeof this.trackView.track.getSamples){const e=this.trackView.track.getSamples();e.names&&e.names.length>0&&this.draw({context:this.ctx,samples:e})}else null===this.viewport.previousElementSibling&&(this.browser.rulerTrackView&&this.browser.rulerTrackView.setTrackHeight(!0===this.browser.sampleInfoControl.showSampleInfo?this.calculateSampleInfoColumnHeight():40,!0),this.renderSampleInfoColumns(this.ctx))}calculateSampleInfoColumnHeight(){const e=this.browser.sampleInfo.attributeNames.map((e=>this.ctx.measureText(e).width));return 4+Math.min(Math.max(...e),128)}draw({context:e,samples:t}){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=ro(\"snow\"),e.fillRect(0,0,e.canvas.width,e.canvas.height),t&&t.names.length>0){const i=this.browser.sampleInfo.attributeNames,n=this.viewport.getBoundingClientRect().height;let r=1;const s=t.height;r=s-2*r<=1?0:1;let o=this.contentTop+t.yOffset;this.hitList={};for(const a of t.names){if(o>n)break;if(o+s>0){const t=this.browser.sampleInfo.getAttributes(a);if(t){const n=Object.entries(t);for(const t of n){const[n,a]=t;e.fillStyle=this.browser.sampleInfo.getAttributeColor(n,a);const c=8+i.indexOf(n)*Vu,l=o+r,h=s-2*r;e.fillRect(c,l,15,h);const d=`${Math.floor(c)}#${Math.floor(l)}#16#${Math.ceil(h)}`;this.hitList[d]=`${n}#${a}`}}}o+=s}}}renderSampleInfoColumns(e){const t=(e,t,i,n,r,s)=>{e.save(),e.font=\"10px verdana\",e.translate(i+r/2,n+s),e.rotate(-Math.PI/2),e.textAlign=\"left\",e.fillStyle=ro(\"lead\"),e.fillText(t,2,2),e.restore()},i=this.browser.sampleInfo.attributeNames;this.hitList={};for(let n=0;n{const{marginTop:n}=window.getComputedStyle(i),{x:r,y:s}=a(e,this.browser.columnContainer.querySelector(\".igv-sample-info-column\"));return{x:Math.floor(r),y:Math.floor(s-parseInt(n,10))}},n=this.browser.columnContainer.querySelector(\".igv-sample-info-column\"),{x:r,y:s}=i(n,this.viewport);n.setAttribute(\"title\",\"\");for(const[e,i]of t){const[t,o,a,c]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(rt+a||so+c)){n.setAttribute(\"title\",`${i}`);break}}}else{const{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){const[e,t]=r.split(\"#\");this.viewport.setAttribute(\"title\",`${e.split(Uu.emptySpaceReplacement).join(\" \")}: ${\"-\"===t?\"\":t}`);break}}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}show(){this.viewport.style.display=\"block\"}hide(){this.viewport.style.display=\"none\"}}class Ku{constructor(t,i,n,r){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.track.height}px`),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.trackScrollDelta=0,this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(r),this.addMouseHandlers()}checkCanvas(){const e=this.browser.sampleNameViewportWidth||0;this.ctx.canvas.width=e*window.devicePixelRatio,this.ctx.canvas.style.width=`${e}px`,this.ctx.canvas.height=this.viewport.clientHeight*window.devicePixelRatio,this.ctx.canvas.style.height=`${this.viewport.clientHeight}px`,this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio)}setTop(e){if(\"function\"==typeof this.trackView.track.getSamples){this.contentTop=e;const t=this.trackView.track.getSamples();this.repaint(t)}}setWidth(e){this.viewport.innerWidth=e,this.checkCanvas()}async repaint(e){if(e.names.length>0&&!0===this.browser.showSampleNames&&(this.checkCanvas(),this.draw({context:this.ctx,samples:e}),void 0===this.browser.sampleNameViewportWidth)){const t=e.names.map((e=>this.ctx.measureText(e).width));this.browser.sampleNameViewportWidth=Math.min(200,4+Math.ceil(Math.max(...t))),this.browser.layoutChange()}}draw({context:e,samples:t}){if(xo.fillRect(e,0,0,e.canvas.width,t.height,{fillStyle:ro(\"snow\")}),t&&t.names.length>0){const i=this.viewport.getBoundingClientRect().height,n=t.height,r=n-2<=1?0:1;let s=this.contentTop+t.yOffset;this.hitList={};for(const o of t.names){if(s>i)break;if(s+n>0){const t=n-2*r;Yu(e,o,0+2,s+r,e.canvas.width,t)}s+=n}}}renderSVGContext(e,{deltaX:t,deltaY:i}){if(\"function\"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:o,height:a}=this.viewport.getBoundingClientRect(),c=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_sample_names_guid_${s()}`;e.saveWithTranslationAndClipRect(c,t,i+r,o,a,-r),this.draw({context:e,samples:n}),e.restore()}}addMouseHandlers(){this.boundClickHandler=function(e){e.preventDefault();const t={label:\"Name Panel Width\",value:this.browser.sampleNameViewportWidth,callback:e=>{this.browser.sampleNameViewportWidth=parseInt(e),this.browser.layoutChange()}};this.browser.inputDialog.present(t,e)}.bind(this),this.viewport.addEventListener(\"contextmenu\",this.boundClickHandler),this.boundMouseMoveHandler=function(e){if(this.hitList){const t=Object.entries(this.hitList),{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){this.viewport.setAttribute(\"title\",`${r}`);break}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"contextmenu\",this.boundClickHandler),this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function Yu(e,t,i,n,r,s){const o=Math.min(s,10);e.font=`${o}px sans-serif`,e.textAlign=\"start\",e.fillStyle=ro(\"lead\");const a=i,c=e.measureText(t),l=n+s/2+(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent)/2;e.fillText(t,a,l)}class Xu{constructor(t){this.popover=e({class:\"igv-menu-popup\"}),t.appendChild(this.popover),this.parent=t;const i=e({class:\"igv-menu-popup-header\"});this.popover.appendChild(i),u(i,(()=>this.popover.style.display=\"none\")),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),p(this.popover,i),i.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault()})),this.popover.style.display=\"none\"}presentMenuList(e,t){if(Zu(this.parent),t.length>0){this.popoverContent.innerHTML=\"\";const i=this.parseMenuList(e,t);for(let e of i){e.init&&e.init();let t=e.object;0===i.indexOf(e)&&t.removeClass(\"igv-track-menu-border-top\"),t.hasClass(\"igv-track-menu-border-top\")||t.hasClass(\"igv-menu-popup-check-container\")||t.is(\"div\")&&t.addClass(\"igv-menu-popup-shim\"),this.popoverContent.appendChild(t.get(0))}this.popover.style.display=\"flex\";const{width:n}=this.popover.getBoundingClientRect();this.popover.style.left=-n+\"px\",this.popover.style.top=\"0px\"}}parseMenuList(e,t){return t.map(((t,i)=>{let n;if(t.name?(n=Bt(\"
\"),n.text(t.name)):t.object?n=t.object:\"string\"==typeof t.label?(n=Bt(\"
\"),n.html(t.label)):\"string\"==typeof t&&(n=t.startsWith(\"<\")?Bt(t):Bt(\"
\"+t+\"
\")),0===i&&n.addClass(\"igv-track-menu-border-top\"),t.click||t.dialog){const i=i=>{if(i.preventDefault(),i.stopPropagation(),t.click)if(e.track.selected){const n=e.browser.getSelectedTrackViews();if(!0===t.doAllMultiSelectedTracks)t.click.call(e.track,i);else if(\"removeTrack\"===t.menuItemType){const r=()=>{e.browser.overlayTrackButton.setVisibility(!1);for(const{track:e}of n)t.click.call(e,i)},s={html:`Are you sure you want to delete ${n.length} tracks?`,callback:r};e.browser.menuUtils.dialog.present(s,i)}else for(const{track:e}of n)t.click.call(e,i)}else t.click.call(e.track,i);else t.dialog&&t.dialog.call(e.track,i);this.popover.style.display=\"none\"};n.on(\"click\",i),n.on(\"touchend\",(e=>i(e))),n.on(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}return{object:n,init:t.init||void 0}}))}presentTrackContextMenu(t,n){this.popoverContent.innerHTML=\"\";const r=function(t,n){return t.map((t=>{let r;if(\"string\"==typeof t&&\"
\"===t)r=document.createElement(\"hr\");else if(\"string\"==typeof t)r=e({class:\"context-menu\"}),r.innerHTML=t;else if(\"Node\"==typeof t)r=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)r=Dl(\"Show all bases\",t.value);else if(\"color\"===t.type){const s=new Ra(n.parentElement);s.configure({color:\"grey\"}),r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);const o=e=>{s.show(),i(n),e.preventDefault(),e.stopPropagation()};r.addEventListener(\"click\",o),r.addEventListener(\"touchend\",o),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function a(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}r.addEventListener(\"click\",a),r.addEventListener(\"touchend\",a),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{el:r,init:t.init}}))}(n,this.popover);for(let{el:e}of r)this.popoverContent.appendChild(e);!function(e,t){t.style.display=\"flex\";const{x:i,y:n}=a(e,t.parentNode),{width:r}=t.getBoundingClientRect(),s=i+r,{width:o}=t.parentNode.getBoundingClientRect();t.style.left=`${s>o?i-(s-o):i}px`,t.style.top=`${n}px`}(t,this.popover)}hide(){this.popover.style.display=\"none\"}dispose(){this.popoverContent.innerHTML=\"\",this.popover.innerHTML=\"\",Object.keys(this).forEach((function(e){this[e]=void 0}))}}const Zu=e=>{const t=e.querySelectorAll(\".igv-menu-popup\");for(const e of t)e.style.display=\"none\"};class Ju{constructor(t,i,n,r,s,o,a){this.browser=i,this.button=e({class:\"igv-navbar-text-button\"}),t.appendChild(this.button),Array.isArray(n)?(this.textContent=n[0],this.title=n[1]):this.textContent=this.title=n,this.buttonLabel=r,this.imageDictionary={image:`url(\"data:image/svg+xml,${encodeURIComponent(s)}\")`,imageHover:`url(\"data:image/svg+xml,${encodeURIComponent(o)}\")`},this.responsiveKey=\"text\",this.configureButton(this.textContent,this.title),this.setState(a),i.on(\"navbar-resize\",(e=>{this.navbarResizeHandler(e)}))}navbarResizeHandler(e){const t=\"igv-navbar-icon-button\"===e?\"image\":\"text\";t!==this.responsiveKey&&(this.responsiveKey=t,this.configureButton(this.textContent,this.title),this.setState(void 0))}configureButton(e,t){this.groupElement=void 0,this.button.title=t,this.button.innerHTML=\"\",this.button.style.backgroundImage=\"none\",this.button.classList.remove(\"igv-navbar-icon-button\"),this.button.classList.remove(\"igv-navbar-text-button\"),\"text\"===this.responsiveKey?this.configureTextButton(e):this.configureIconButton()}configureTextButton(e){console.log(`text ${this.title}`),this.button.classList.add(\"igv-navbar-text-button\");const t=document.createElement(\"div\");t.innerHTML=this.buttonLabel;const i=t.firstChild;this.button.appendChild(i),this.groupElement=i.querySelector(\"#igv-navbar-button-group\");i.querySelector(\"#igv-navbar-button-label\").textContent=e}configureIconButton(){console.log(`icon ${this.title}`),this.button.classList.add(\"igv-navbar-icon-button\")}setState(e){void 0!==e&&(this.doHover=e),\"text\"===this.responsiveKey?this.setTextButtonState(this.doHover):this.setIconButtonState(this.doHover)}setTextButtonState(e){this.groupElement.classList.remove(...this.groupElement.classList);const t=!0===e?\"igv-navbar-text-button-svg-hover\":\"igv-navbar-text-button-svg-inactive\";this.groupElement.classList.add(t)}setIconButtonState(e){this.button.style.backgroundImage=!0===e?this.imageDictionary.imageHover:this.imageDictionary.image}show(){this.button.style.display=\"flex\"}hide(){this.button.style.display=\"none\"}setVisibility(e){!0===e?this.show():this.hide()}}const ef='\\n \\n \\n \\n \\n \\n \\n \\n \\n';class tf extends Hl{static defaults={autoscale:void 0,alpha:.5,height:50};constructor(e,t,i){super(e,t),this.type=\"merged\",this.paintAxis=cd,this.graphType=e.graphType,this.tracks=i||[]}async postInit(){if(this.config.tracks){for(let e of this.config.tracks){const t=await this.browser.createTrack(e);t?this.tracks.push(t):console.warn(\"Could not create track \"+e),\"function\"==typeof t.postInit&&await t.postInit()}this.config.tracks.every((e=>void 0!==e.autoscale||void 0!==e.max))||(this.config.autoscale=void 0===this.config.max)}for(let e of this.tracks)e.isMergedTrack=!0;if(this.config.autoscale?this.autoscale=this.config.autoscale:void 0!==this.config.max&&this.setDataRange({min:this.config.min||0,max:this.config.max}),void 0!==this.config.flipAxis)for(let e of this.tracks)e.flipAxis=this.config.flipAxis;if(void 0!==this.config.logScale)for(let e of this.tracks)e.logScale=this.config.logScale;this.resolutionAware=this.tracks.some((e=>e.resolutionAware))}set flipAxis(e){this.config.flipAxis=e;for(let t of rf(this.tracks))t.flipAxis=e}get flipAxis(){return rf(this.tracks).every((e=>e.flipAxis))}set logScale(e){this.config.logScale=e;for(let t of rf(this.tracks))t.logScale=e}get logScale(){return rf(this.tracks).every((e=>e.logScale))}get height(){return this._height}set height(e){if(this.config.height=e,this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}set autoscale(e){if(this._autoscale=e,!1===e&&this.tracks)for(let e of this.tracks)e.autoscale=!1}get autoscale(){return this._autoscale}set autoscaleGroup(e){if(this.tracks)for(let t of this.tracks)t.autoscaleGroup=e}get autoscaleGroup(){if(this.tracks&&this.tracks.length>0){const e=this.tracks[0].autoscaleGroup;return this.tracks.some((t=>e!==t.autoscaleGroup))?void 0:e}}setDataRange({min:e,max:t}){this.autoscale=!1;for(const i of rf(this.tracks))i.dataRange={min:e,max:t},i.autoscale=!1,i.autoscaleGroup=!1}set dataRange({min:e,max:t}){for(const i of rf(this.tracks))i.dataRange={min:e,max:t}}get dataRange(){if(this.tracks){const e=rf(this.tracks);if(e.length>0){const t=e[0].dataRange;if(e.every((e=>e.dataRange&&e.dataRange.min===t.min&&e.dataRange.max===t.max)))return t}}}menuItemList(){const e=[];return rf(this.tracks).length>0&&(void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e.push(...this.numericDataMenuItems())),e.push(\"
\"),e.push(this.overlayTrackAlphaAdjustmentMenuItem()),e.push(this.trackSeparationMenuItem()),e}async getFeatures(e,t,i,n){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n))),s=await Promise.all(r);if(s.every((e=>0===e.length)))return new nf([],[]);{const e=this.tracks.map((e=>e.name));return new nf(s,e)}}draw(e){const t=e.features;for(let i=0,n=this.tracks.length;i0&&i.push(\"
\"),i.push(`
${t[r].trackName}
`),t[r].features.length>0){n=!1;const s=this.tracks[r].popupData(e,t[r].features);i.push(...s)}else i.push(\"Missing or 0 value(s)\");return!0===n?[]:i}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!t.featureArrays||!Array.isArray(t.featureArrays)||0===t.featureArrays.length)return[];const i=e.genomicLocation,n=[],r=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2,s=i-r,o=i+r;for(let e=0;ee.supportsWholeGenome))}getState(){const e=super.getState(),t=[];for(let e of this.tracks)t.push(e.getState());return e.tracks=t,e}updateScales(e){let t;if(this.autoscale){t=!0;let i=[];for(let t of e){if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,r=n+e.toBP(t.getWidth()),s=t.featureCache.features;this.autoscale&&(i.push({value:s.getMax(n,r)}),i.push({value:s.getMin(n,r)}))}const e=qa(i);for(const t of rf(this.tracks))t.dataRange=e}}else{let i=-1;for(let n of this.tracks)if(++i,n.autoscale){t=!0;let r=[];for(let t of e)if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,s=n+e.toBP(t.getWidth()),o=t.featureCache.features.featureArrays[i];if(o)for(let e of o)if(!(e.ends)break;r.push(e)}}n.dataRange=qa(r)}}return t}overlayTrackAlphaAdjustmentMenuItem(){const t=e();return t.innerText=\"Set transparency\",{object:Bt(t),dialog:function(e){const t={label:\"Transparency\",value:this.alpha,min:0,max:1,scaleFactor:1e3,callback:e=>{this.alpha=Math.max(.001,e),this.repaintViews()}};this.browser.sliderDialog.present(t,e)}}}trackSeparationMenuItem(){const e=Bt(\"
\");return e.text(\"Separate tracks\"),{object:e,click:function(e){const t=this.autoscale,i=this.name,n=this.tracks,r=this.browser,s=this.order;r.removeTrack(this);for(let e of n)e.order=s,t&&(e.autoscaleGroup=i),e.isMergedTrack=!1,r.addTrack(e.config,e);r.updateViews()}}}}class nf{constructor(e,t){this.featureArrays=e,this.trackNames=t}getMax(e,t){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(!(void 0===r.value||Number.isNaN(r.value)||r.endt)break;i=Math.max(i,r.value)}return i!==-Number.MAX_VALUE?i:100}getMin(e,t){let i=0;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.endt)break;i=Math.min(i,r.value)}return i}}const rf=e=>e?e.filter((e=>void 0!==e.dataRange||void 0!==e.autoscale||void 0!==e.autoscaleGroup)):[];class sf extends Ju{constructor(e,t){super(e,t,\"Overlay Tracks\",ef,'\\n Overlay Tracks\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n Overlay Tracks Hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>this.setState(!1)));this.boundMouseClickHandler=(()=>{this.setVisibility(!1),of.call(this)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(!0)}}function of(e){if(!0===af(this.browser)){const e=this.browser.getSelectedTrackViews().map((({track:e})=>e));for(const t of e)t.selected=!1;const t=[];for(let i of e)\"merged\"===i.type?t.push(...i.tracks):t.push(i);const i={name:\"Overlay\",type:\"merged\",autoscale:!1,alpha:.5,height:Math.max(...e.map((({height:e})=>e))),order:Math.min(...e.map((({order:e})=>e)))},n=new tf(i,this.browser,t);for(const t of e){const e=this.browser.trackViews.indexOf(t.trackView);this.browser.trackViews.splice(e,1),t.trackView.dispose()}this.browser.addTrack(i,n),n.trackView.updateViews()}}function af(e){const t=e.getSelectedTrackViews();if(t&&t.length>1){const e=new Set([\"wig\",\"merged\"]);return t.filter((({track:t})=>e.has(t.type))).length>1}return!1}const cf=new Set([\"sequence\",\"ruler\",\"ideogram\"]),lf=new Set([\"ruler\",\"sequence\",\"ideogram\"]);class hf{constructor(e,t,i){this.namespace=`trackview-${s()}`,this.browser=e,this.track=i,i.trackView=this,this.addDOMToColumnContainer(e,t,e.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(e,t,i){this.axis=this.createAxis(e,this.track),this.createViewports(e,t,i),this.sampleInfoViewport=new $u(this,e.columnContainer.querySelector(\".igv-sample-info-column\"),e.getSampleInfoViewportWidth()),this.sampleNameViewport=new Ku(this,e.columnContainer.querySelector(\".igv-sample-name-column\"),void 0,e.getSampleNameViewportWidth()),this.createTrackScrollbar(e),this.createTrackDragHandle(e),this.createTrackGearPopup(e)}createViewports(e,t,i){this.viewports=[];const n=e.calculateViewportWidth(i.length),r=t.querySelectorAll(\".igv-column\");for(let e=0;e{e.preventDefault(),e.stopPropagation(),this.track.selected=e.target.checked,this.setDragHandleSelectionState(e.target.checked),this.browser.overlayTrackButton.setVisibility(af(this.browser))})),this.enableTrackSelection(!1)}return n}resizeAxisCanvas(e,t){this.axis.style.width=`${e}px`,this.axis.style.height=`${t}px`,\"function\"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${e}px`,this.axisCanvas.style.height=`${t}px`)}renderSVGContext(e,{deltaX:t,deltaY:i}){!function(e,t,i,n,r){if(\"function\"==typeof t.paintAxis){const{y:o,width:a,height:c}=i.getBoundingClientRect(),l=`${(t.name||t.id).replace(/\\W/g,\"\")}_axis_guid_${s()}`;e.saveWithTranslationAndClipRect(l,n,o+r,a,c,0),t.paintAxis(e,a,c),e.restore()}}(e,this.track,this.axisCanvas,t,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:n+t,deltaY:r+i};for(let t of this.viewports){t.renderSVGContext(e,o);const{width:i}=t.$viewport.get(0).getBoundingClientRect();o.deltaX+=i}if(!0===this.browser.sampleInfo.isInitialized()&&!0===this.browser.sampleInfoControl.showSampleInfo){this.sampleInfoViewport.renderSVGContext(e,o);const{width:t}=this.sampleInfoViewport.viewport.getBoundingClientRect();o.deltaX+=t}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(e,o)}presentColorPicker(e){if(!1===lf.has(this.track.type)){const t=[],i=this.track.color||this.track.defaultColor;Mt(i)&&t.push(i),this.track.altColor&&Mt(this.track.altColor)&&t.push(this.track.altColor);let n=t.map((e=>e.startsWith(\"#\")?e:e.startsWith(\"rgb(\")?_s.rgbToHex(e):_s.colorNameToHex(e))),r={color:e=>{this.track.color=io(e),this.repaintViews()},altColor:e=>{this.track.altColor=io(e),this.repaintViews()}};const s=this.browser.getSelectedTrackViews();s.length>0&&new Set(s).has(this)?(r={color:e=>{for(let t of s)t.track.color=e,t.repaintViews()}},this.browser.genericColorPicker.configure(n,r)):this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(e),this.browser.genericColorPicker.show()}}setTrackHeight(e,t){t||(this.track.minHeight&&(e=Math.max(this.track.minHeight,e)),this.track.maxHeight&&(e=Math.min(this.track.maxHeight,e))),this.track.height=e,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),\"function\"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:t}of this.viewports)t.height(e);if(this.sampleInfoViewport.setHeight(e),this.sampleNameViewport.viewport.style.height=`${e}px`,\"function\"!=typeof this.track.computePixelHeight)for(let t of this.viewports)t.setContentHeight(e);this.repaintViews(),this.updateScrollbar(),this.dragHandle.style.height=`${e}px`,this.gearContainer.style.height=`${e}px`}updateScrollbar(){const e=this.viewports[0].$viewport.height();if(this.outerScroll.style.height=`${e}px`,!1===cf.has(this.track.type)){const t=this.maxViewportContentHeight(),i=Math.round(e/t*e);t>e?(this.innerScroll.style.display=\"block\",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display=\"none\"}}moveScroller(e){const t=Bt(this.innerScroll).position().top+e,i=Math.min(Math.max(0,t),this.outerScroll.clientHeight-this.innerScroll.clientHeight);Bt(this.innerScroll).css(\"top\",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let e of this.viewports)e.setTop(r);this.sampleInfoViewport.setTop(r),this.sampleNameViewport.trackScrollDelta=e,this.sampleNameViewport.setTop(r)}isLoading(){for(let e of this.viewports)if(e.isLoading())return!0}repaintViews(){for(let e of this.viewports)e.isVisible()&&e.repaint();\"function\"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSampleInfo(),this.repaintSamples()}repaintSampleInfo(){this.sampleInfoViewport.repaint()}repaintSamples(){if(\"function\"==typeof this.track.getSamples){const e=this.track.getSamples();e.names&&e.names.length>0&&this.sampleNameViewport.repaint(e)}}setTrackLabelName(e){this.viewports.forEach((t=>t.setTrackLabel(e)))}resize(e){for(let t of this.viewports)t.setWidth(e)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const e=this.viewports.filter((e=>e.isVisible()));if(e.forEach((e=>e.shift())),this.browser.dragObject)return;const t=e.filter((e=>e.needsRepaint())).filter((e=>e.checkZoomIn())),i=e.filter((e=>e.checkZoomIn())).filter((e=>e.needsReload()));for(let e of i)await e.loadFeatures();if(this.disposed)return;if(this.track&&\"function\"==typeof this.track.variantRowCount&&i.length>0){let e=0;for(let t of this.viewports)t.featureCache&&t.featureCache.features&&(e=Math.max(e,t.featureCache.features.reduce(((e,t)=>Math.max(e,t.row||0)),0)));if(this.track.nVariantRows!==e+1){this.track.variantRowCount(e+1);for(let e of this.viewports)e.checkContentHeight()}}let n;if(\"merged\"===this.track.type)n=this.track.updateScales(e);else if(this.track.autoscale){let t=[];for(let i of e){const e=i.referenceFrame,n=e.start,r=n+e.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(n,r);if(t.push({value:e}),\"function\"==typeof i.featureCache.features.getMin){const e=i.featureCache.features.getMin(n,r);t.push({value:e})}}else{const e=to(i.featureCache.features,n,r);for(let i of e)t.push(i)}}\"function\"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(t):this.track.dataRange=qa(t)}const r=this.track.autoscale||this.track.autoscaleGroup||\"ruler\"===this.track.type||n||this.track.groupBy;for(let i of e)t.includes(i)?i.repaint():r&&i.refresh();this.adjustTrackHeight(),this.repaintSampleInfo(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let e of this.viewports)e.clearCache()}updateRulerViewportLabels(){const e=this.browser.calculateViewportWidth(this.viewports.length);for(let t of this.viewports)\"ruler\"===this.track.type&&(this.viewports.length>1?t.presentLocusLabel(e):t.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let e=[];const t=this.viewports.filter((e=>e.isVisible()));for(let i of t){const t=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+t.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(r,o);e.push({value:t})}else{const t=\"function\"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):to(i.featureCache.features,r,o);e=e.concat(t)}}return e}checkContentHeight(){for(let e of this.viewports)e.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var e=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(e,!1):this.track.paintAxis&&this.paintAxis(),!1===cf.has(this.track.type)){const t=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-e);if(t{if(!t.isVisible())return!1;if(t.checkZoomIn()){const i=t.referenceFrame,n=t.referenceFrame.chr,r=i.start,s=r+i.toBP(Bt(t.contentDiv).width()),o=i.bpPerPixel;return e||!t.tile||t.tile.invalidate||!t.tile.containsRange(n,r,s,o)}return!1}))}createTrackScrollbar(t){const i=e();if(t.columnContainer.querySelector(\".igv-scrollbar-column\").appendChild(i),i.style.height=`${this.track.height}px`,this.outerScroll=i,!1===cf.has(this.track.type)){const n=e();i.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){\"sequence\"!==this.track.type&&!0===mo.has(this.track.type)?this.dragHandle=e({class:\"igv-track-drag-shim\"}):(this.dragHandle=e({class:\"igv-track-drag-handle\"}),this.dragHandle.classList.add(\"igv-track-drag-handle-color\")),t.columnContainer.querySelector(\".igv-track-drag-column\").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){if(this.gearContainer=e(),t.columnContainer.querySelector(\".igv-gear-menu-column\").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu);else{function i(e){if(e.preventDefault(),e.stopPropagation(),\"none\"===this.trackGearPopup.popover.style.display){for(const e of t.trackViews.filter((e=>e!==this&&void 0!==e.trackGearPopup)))e.trackGearPopup.popover.style.display=\"none\";this.trackGearPopup.presentMenuList(this,t.menuUtils.trackMenuItemList(this))}else this.trackGearPopup.popover.style.display=\"none\"}this.gear=e(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(l(\"cog\")),this.trackGearPopup=new Xu(this.gear),this.boundTrackGearClickHandler=i.bind(this),this.gear.addEventListener(\"click\",this.boundTrackGearClickHandler)}}addTrackScrollMouseHandlers(e){this.boundTrackScrollMouseDownHandler=function(t){t.stopPropagation();const{y:i}=r(t);Bt(this.innerScroll).data(\"yDown\",i.toString()),this.boundColumnContainerMouseMoveHandler=function(e){e.stopPropagation();const{y:t}=r(e);this.moveScroller(t-parseInt(Bt(this.innerScroll).data(\"yDown\"))),Bt(this.innerScroll).data(\"yDown\",t.toString())}.bind(this),e.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(t){e.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),e.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),e.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===cf.has(this.track.type)&&(this.innerScroll.removeEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.browser.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.browser.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.browser.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseMoveHandler))}addTrackDragMouseHandlers(e){if(\"sequence\"===this.track.type||!1===mo.has(this.track.type)){let t;function i(i){i.preventDefault(),t=i.target,!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.add(\"igv-track-drag-handle-hover-color\")),e.startTrackDrag(this)}function n(i){e.endTrackDrag(),t&&i.target!==t&&!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-color\")),t=void 0}function r(i){i.preventDefault(),void 0===t&&!1===this.track.selected&&(i.target.classList.remove(\"igv-track-drag-handle-color\"),i.target.classList.add(\"igv-track-drag-handle-hover-color\")),e.updateTrackDrag(this)}function s(e){e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))}this.boundTrackDragMouseDownHandler=i.bind(this),this.dragHandle.addEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=n.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=r.bind(this),this.dragHandle.addEventListener(\"mouseenter\",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener(\"mouseout\",(e=>{e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){\"ideogram\"===this.track.type||\"ruler\"===this.track.type||(this.dragHandle.removeEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),document.removeEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener(\"mouseup\",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler))}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener(\"click\",this.boundTrackGearClickHandler)}removeDOMFromColumnContainer(){this.axis.remove(),this.removeViewportsFromColumnContainer(),this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}removeViewportsFromColumnContainer(){for(let e of this.viewports)e.$viewport.remove()}dispose(){this.axis.remove();for(let e of this.viewports)e.dispose();this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),\"function\"==typeof this.track.dispose&&this.track.dispose();for(let e of Object.keys(this))this[e]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if(\"function\"==typeof this.track.paintAxis){const{width:e,height:t}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*t,this.axisCanvas.width=i*e;const n=this.axisCanvas.getContext(\"2d\");if(n.scale(i,i),this.track.autoscaleGroup){if(void 0===wo[this.track.autoscaleGroup]){const e=so.Dark2,t=Math.floor(Math.random()*so.Dark2.length);wo[this.track.autoscaleGroup]=e[t]}const i=_s.addAlpha(wo[this.track.autoscaleGroup],.75);this.track.paintAxis(n,e,t,i)}else this.track.paintAxis(n,e,t,void 0)}}maxViewportContentHeight(){return Math.max(...this.viewports.map((e=>e.getContentHeight())))}enableTrackSelection(e){const t=this.trackSelectionContainer;if(t&&!mo.has(this.track.type))if(!1!==e)t.style.display=\"grid\";else{this.track.selected=!1;t.querySelector(\"[name=track-select]\").checked=this.track.selected,this.dragHandle&&this.setDragHandleSelectionState(!1),t.style.display=\"none\"}}setDragHandleSelectionState(e){const t=this.dragHandle;e?(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-selected-color\")):(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.remove(\"igv-track-drag-handle-selected-color\"),t.classList.add(\"igv-track-drag-handle-color\"))}}function df(e){this.thresholds=e.thresholds,this.colors=e.colors}function uf(e){this.scale=e,this.lowColor=\"rgb(\"+e.lowR+\",\"+e.lowG+\",\"+e.lowB+\")\",this.highColor=\"rgb(\"+e.highR+\",\"+e.highG+\",\"+e.highB+\")\",this.diff=e.high-e.low}df.prototype.getColor=function(e){for(let t of this.thresholds)if(e=i.high?this.highColor:(t=(e-i.low)/this.diff,\"rgb(\"+Math.floor(i.lowR+t*(i.highR-i.lowR))+\",\"+Math.floor(i.lowG+t*(i.highG-i.lowG))+\",\"+Math.floor(i.lowB+t*(i.highB-i.lowB))+\")\")};class ff{constructor(e){this.color=e}getColor(){return this.color}}const pf={threshold:2e3,r:0,g:0,b:255};class gf{constructor(e){e=e||pf,this.threshold=e.threshold,this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[],this.nbins=2e3,this.binsize=this.threshold/this.nbins}setThreshold(e){this.threshold=e,this.cache=[],this.binsize=this.threshold/this.nbins}getThreshold(){return this.threshold}setColorComponents(e){this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[]}getColorComponents(){return{r:this.r,g:this.g,b:this.b}}equals(e){return JSON.stringify(this)===JSON.stringify(e)}getColor(e){const t=Math.floor(Math.min(this.threshold,e)/this.binsize);if(void 0===this.cache[t]){const i=(ys.clamp(e,0,this.threshold)-0)/(this.threshold-0);this.cache[t]=`rgba(${this.r},${this.g},${this.b}, ${i})`}return this.cache[t]}stringify(){return this.threshold+\",\"+this.r+\",\"+this.g+\",\"+this.b}static parse(e){var t,i;return e.startsWith(\"R:\")?(t=e.substring(2).split(\":\"),(i=new RatioColorScale(Number.parseFloat(t[0]))).positiveScale=n(t[1]),i.negativeScale=n(t[2]),i):n(e);function n(e){var t,i;return t={threshold:(i=e.split(\",\"))[0],r:i[1],g:i[2],b:i[3]},new gf(t)}}}class mf{constructor(e){this.config=e,this.url=e.path||e.url}async read(e,t){const i={start:e,size:t};return Qs.loadArrayBuffer(this.url,{range:i})}}class wf{constructor(e){this.file=e}async read(e,t){const i=this.file;return void 0!==e?i.slice(e,e+t).arrayBuffer():i.arrayBuffer()}}class bf{constructor(e,t){this.file=e,this.rateLimiter=t}async read(e,t){const i=this.file,n=this.rateLimiter;return new Promise((function(r,s){n.limiter((async function(i){try{const n=await i.read(e,t);r(n)}catch(e){s(e)}}))(i)}))}}class Ff{constructor(e){this.file=e.file,this.size=e.size||64e3,this.position=0,this.bufferStart=0,this.bufferLength=0,this.buffer=void 0}async read(e,t){const i=e,n=e+t,r=this.bufferStart,s=this.bufferStart+this.bufferLength;if(t>this.size)return this.buffer=void 0,this.bufferStart=0,this.bufferLength=0,this.file.read(e,t);if(i>=r&&n<=s){const e=i-r,n=e+t;return this.buffer.slice(e,n)}if(ir){const n=r-i,s=await this.file.read(e,n),o=t-n;if(o>0){const e=this.buffer.slice(0,o);return vf(s,e)}return s}if(!(is))return this.buffer=await this.file.read(e,this.size),this.bufferStart=e,this.bufferLength=this.buffer.byteLength,this.buffer.slice(0,t);{const e=s-i,n=this.bufferLength-e,r=this.buffer.slice(n,this.bufferLength),o=t-e;if(!(o>0))return r;try{this.buffer=await this.file.read(s,this.size),this.bufferStart=s,this.bufferLength=this.buffer.byteLength;const e=this.buffer.slice(0,o);return vf(r,e)}catch(e){if(e.code&&416===e.code)return r;throw e}}}}var vf=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer};const yf=function(e,t){this.littleEndian=void 0===t||t,this.position=0,this.view=e,this.length=e.byteLength};function Af(e,t){this.block=e,this.offset=t}yf.prototype.available=function(){return this.length-this.position},yf.prototype.remLength=function(){return this.length-this.position},yf.prototype.hasNext=function(){return this.position=0;i--)t=256*t+e[i];else for(i=0;i0&&(n+=String.fromCharCode(i));return n},yf.prototype.getFixedLengthTrimmedString=function(e){var t,i,n=\"\";for(t=0;t32&&(n+=String.fromCharCode(i));return n},yf.prototype.getFloat=function(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e},yf.prototype.getDouble=function(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e},yf.prototype.skip=function(e){return this.position+=e,this.position},yf.prototype.getVPointer=function(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Af(i,t)},Af.prototype.isLessThan=function(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset},Af.prototype.print=function(){return this.block+\":\"+this.offset};class Cf{constructor(e,t){this.chr1=e,this.chr2=t}getKey(){return this.chr1.name+\"_\"+this.chr2.name+\"_\"+this.zoom.unit+\"_\"+this.zoom.binSize}getBlockNumbers(e,t,i){if(e.chr==this.chr2&&t.chr===this.chr1){const i=e;e=t,t=i}const n=this.chr1===this.chr2,r=this.zoom.binSize,s=this.blockBinCount,o=this.blockColumnCount;return i<9||!n?function(){const i=e.start/r,a=e.end/r,c=t.start/r,l=t.end/r,h=Math.floor(i/s),d=Math.floor((a-1)/s),u=Math.floor(c/s),f=Math.floor((l-1)/s),p=[];for(let e=u;e<=f;e++)for(let t=h;t<=d;t++){let i;i=n&&e0;){const e=t.getInt(),i=t.getLong(),n=t.getInt();this.blockIndex[e]={filePosition:i,size:n}}}getBlockIndexEntry(e){return this.blockIndex[e]}}class xf{constructor(e,t,i){this.chr1=e,this.chr2=t,this.bpZoomData=[],this.fragZoomData=[];for(let e of i)\"BP\"===e.zoom.unit?this.bpZoomData.push(e):this.fragZoomData.push(e)}findZoomForResolution(e,t){const i=\"FRAG\"===t?this.fragZoomData:this.bpZoomData;for(let t=1;tt){const i=e;e=t,t=i}return`${e}_${t}`}static parseMatrix(e,t){const i=new yf(new DataView(e)),n=i.getInt(),r=i.getInt(),s=t[n],o=t[r];let a=i.getInt();const c=[];for(;a-- >0;){const e=Cf.parseMatrixZoomData(s,o,i);c.push(e)}return new xf(n,r,c)}}class kf{constructor(e,t,i){this.bin1=e,this.bin2=t,this.counts=i}getKey(){return this.bin1+\"_\"+this.bin2}}class If{constructor(e=10){this.max=e,this.map=new Map}get(e){let t=this.map.get(e);return t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size===this.max&&this.map.delete(this.first()),this.map.set(e,t)}has(e){return this.map.has(e)}clear(){this.map.clear()}first(){return this.map.keys().next().value}}class Sf{constructor(e,t,i,n){this.file=e,this.filePosition=t,this.nValues=i,this.dataType=n,this.cache=void 0}async getValues(e,t){if(!this.cache||ethis.cache.end){const i=Math.max(0,e-1e3),n=Math.min(this.nValues,t+1e3),r=this.filePosition+i*this.dataType,s=n-i,o=s*this.dataType,a=await this.file.read(r,o);if(!a)return;const c=new yf(new DataView(a)),l=[];for(let e=0;e=0||t.indexOf(\"www.googleapis.com/drive\")>0?this.file=new bf(i,Bf):this.file=i}}var t}async init(){this.initialized||(await this.readHeaderAndFooter(),this.initialized=!0)}async getVersion(){if(void 0===this.version){const e=await this.file.read(0,128);if(!e)return;const t=new yf(new DataView(e));return this.magic=t.getString(),this.version=t.getInt(),this.version}return this.version}async getMetaData(){return await this.init(),this.meta}async readHeaderAndFooter(){let e=await this.file.read(0,16);if(!e||0===e.byteLength)throw Error(\"File content is empty\");let t=new yf(new DataView(e));if(this.magic=t.getString(),this.version=t.getInt(),this.version<5)throw Error(\"Unsupported hic version: \"+this.version);this.footerPosition=t.getLong(),await this.readFooter();const i=Object.values(this.masterIndex).reduce(((e,t)=>Math.min(e,t.start)),Number.MAX_VALUE)-16;e=await this.file.read(16,i),t=new yf(new DataView(e)),this.genomeId=t.getString(),this.version>=9&&(this.normVectorIndexPosition=t.getLong(),this.normVectorIndexSize=t.getLong()),this.attributes={};let n=t.getInt();for(;n-- >0;)this.attributes[t.getString()]=t.getString();this.chromosomes=[],this.chromosomeIndexMap={};let r=t.getInt(),s=0;for(;r-- >0;){const e={index:s,name:t.getString(),size:this.version<9?t.getInt():t.getLong()};\"all\"===e.name.toLowerCase()&&(this.wholeGenomeChromosome=e,this.wholeGenomeResolution=Math.round(2*e.size)),this.chromosomes.push(e),this.chromosomeIndexMap[e.name]=e.index,s++}this.bpResolutions=[];let o=t.getInt();for(;o-- >0;)this.bpResolutions.push(t.getInt());if(this.loadFragData){this.fragResolutions=[];let e=t.getInt();if(e>0)for(;e-- >0;)this.fragResolutions.push(t.getInt())}this.chrAliasTable={};for(let e of Object.keys(this.chromosomeIndexMap))e.startsWith(\"chr\")?this.chrAliasTable[e.substr(3)]=e:\"MT\"===e?this.chrAliasTable.chrM=e:this.chrAliasTable[\"chr\"+e]=e;this.meta={version:this.version,genome:this.genomeId,chromosomes:this.chromosomes,resolutions:this.bpResolutions}}async readFooter(){const e=this.version<9?8:12;let t=await this.file.read(this.footerPosition,e);if(!t)return null;let i=new yf(new DataView(t));const n=this.version<9?i.getInt():i.getLong();let r=i.getInt();const s=196*r;for(t=await this.file.read(this.footerPosition+e,Math.min(s,n)),i=new yf(new DataView(t)),this.masterIndex={};r-- >0;){const e=i.getString(),t=i.getLong(),n=i.getInt();this.masterIndex[e]={start:t,size:n}}if(this.expectedValueVectors={},this.version>5){const e=this.version<9?4:8;this.normExpectedValueVectorsPosition=this.footerPosition+e+n}return this}async printIndexStats(){let e,t=0,i=0;await await this.init();for(let n of Object.keys(this.masterIndex)){const r=this.masterIndex[n];t+=r.size,r.size>i&&(i=r.size,e=n)}console.log(`${i} ${e} ${this.config.url}`)}async getMatrix(e,t){const i=xf.getKey(e,t);if(this.matrixCache.has(i))return this.matrixCache.get(i);{const n=await this.readMatrix(e,t);return this.matrixCache.set(i,n),n}}async readMatrix(e,t){if(await this.init(),e>t){const i=e;e=t,t=i}const i=xf.getKey(e,t),n=this.masterIndex[i];if(!n)return;const r=await this.file.read(n.start,n.size);return r?xf.parseMatrix(r,this.chromosomes):void 0}async getContactRecords(e,t,i,n,r,s=!1){await this.init();const o=this.chromosomeIndexMap[this.getFileChrName(t.chr)],a=this.chromosomeIndexMap[this.getFileChrName(i.chr)];if(o>a||o===a&&t.start>=i.end){const e=t;t=i,i=e}const c=await this.getBlocks(t,i,n,r);if(!c||0===c.length)return[];const l=[],h=t.start/r,d=t.end/r,u=i.start/r,f=i.end/r,p=Math.floor(h),g=Math.ceil(d),m=Math.floor(u),w=Math.ceil(f);for(let o of c)if(o){let a,c,b=e&&\"NONE\"!==e;const F=this.getFileChrName(t.chr),v=this.getFileChrName(i.chr);if(b){const t=await this.getNormalizationVector(e,F,n,r),i=F===v?t:await this.getNormalizationVector(e,v,n,r);t&&i?(a=await t.getValues(p,g),c=await i.getValues(m,w)):b=!1}for(let e of o.records)if(s||e.bin1>=h&&e.bin1=u&&e.bin210&&(this.percentile95=Lf(o.records,95))}return l}async getBlocks(e,t,i,n){const r=(e,t)=>`${t.getKey()}_${e}`;await this.init();const s=this.getFileChrName(e.chr),o=this.getFileChrName(t.chr),a=this.chromosomeIndexMap[s],c=this.chromosomeIndexMap[o];if(void 0===a)return console.log(\"No chromosome named: \"+e.chr),[];if(void 0===c)return console.log(\"No chromosome named: \"+t.chr),[];const l=await this.getMatrix(a,c);if(!l)return console.log(\"No matrix for \"+e.chr+\"-\"+t.chr),[];const h=l.getZoomData(n,i);if(!h){let i=`No data avalailble for resolution: ${n} for map ${e.chr}-${t.chr}`;throw new Error(i)}const d=h.getBlockNumbers(e,t,this.version),u=[],f=[];for(let e of d){const t=r(e,h);this.blockCache.has(n,t)?u.push(this.blockCache.get(n,t)):f.push(e)}const p=f.map((e=>this.readBlock(e,h))),g=await Promise.all(p);for(let e of g)e&&this.blockCache.set(n,r(e.blockNumber,h),e);return u.concat(g)}async readBlock(e,t){const i=await t.blockIndex.getBlockIndexEntry(e);if(i){let n=await this.file.read(i.filePosition,i.size);if(!n)return;n=new ls(new Uint8Array(n)).buffer;const r=new yf(new DataView(n)),s=r.getInt(),o=[];if(this.version<7)for(let e=0;e0;)this.parseNormVectorEntry(i);return this.normVectorIndex}async readNormExpectedValuesAndNormVectorIndex(){if(await this.init(),void 0===this.normExpectedValueVectorsPosition)return;const e=await this.skipExpectedValues(this.normExpectedValueVectorsPosition);let t=4,i=await this.file.read(e,4);if(0===i.byteLength)return;const n=new yf(new DataView(i)).getInt(),r={start:e+t,size:30*n};i=await this.file.read(r.start,r.size),this.normalizedExpectedValueVectors={},this.normVectorIndex={},await async function i(n,r){const s=new yf(new DataView(r));for(;n-- >0;){if(s.available()<100){n++,t+=s.position;const r=Math.max(1e3,30*n),o={start:e+t,size:r},a=await this.file.read(o.start,o.size);return i.call(this,n,a)}this.parseNormVectorEntry(s)}t+=s.position}.call(this,n,i),this.config.nvi=e.toString()+\",\"+t}async skipExpectedValues(e){const t=this.version,i=new Ff({file:this.file,size:256e3}),n={start:e,size:4},r=await i.read(n.start,n.size),s=new yf(new DataView(r)).getInt();return 0===s?e+4:async function e(n,r){let s={start:n,size:500},o=0,a=n,c=await i.read(s.start,s.size),l=new yf(new DataView(c));l.getString(),l.getString(),l.getInt();const h=t<9?l.getInt():l.getLong();o+=l.position+h*(t<9?8:4),s={start:n+o,size:4},c=await i.read(s.start,s.size),l=new yf(new DataView(c));const d=l.getInt();return o+=4+d*(4+(t<9?8:4)),r--,0===r?a+o:e(a+o,r)}(e+4,s)}getZoomIndexForBinSize(e,t){let i;if(\"BP\"===(t=t||\"BP\"))i=this.bpResolutions;else{if(\"FRAG\"!==t)throw new Error(\"Invalid unit: \"+t);i=this.fragResolutions}for(let t=0;te.counts));i.sort((function(e,t){return e-t}));return i[Math.floor(t/100*e.length)]}class zf{constructor(e,t){this.config=e,this.genome=t,this.hicFile=e._hicFile?e._hicFile:new Mf(e),e._hicFile=void 0}async getHeader(){return await this.hicFile.init(),this.hicFile}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){this.hicFile.initialized||await this.hicFile.init();const s=this.hicFile.bpResolutions,o=s[s.length-1];return(await this.hicFile.getContactRecords(void 0,{chr:e,start:t,end:i},{chr:\"celltype\",start:0,end:1e8},\"BP\",o)).map((t=>{const i=t.bin1*o;return{chr:e,start:i,end:i+o,value:t.counts,sample:t.bin2.toString()}}))}supportsWholeGenome(){return!1}}function Hf(e,t){const i=new Set(e.attributeNames),n=t[0];if(void 0===e.getAttributes(n))return!1;{const t=Object.keys(e.getAttributes(n));for(const e of t)if(!1===i.has(e))return!1}return!0}class Pf extends Hl{#y=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),this.type=e.type||\"seg\",\"maf\"===this.type&&(this.type=\"mut\"),this.isLog=e.isLog,this.displayMode=e.displayMode||\"EXPANDED\",this.height=e.height||300,this.maxHeight=e.maxHeight||500,this.squishedRowHeight=e.sampleSquishHeight||e.squishedRowHeight||2,this.expandedRowHeight=e.sampleExpandHeight||e.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,this.sampleKeys=[],e.samples){for(let t of e.samples)this.sampleKeys.push(t);this.explicitSamples=!0}if(e.color)this.color=e.color;else if(e.colorTable)this.colorTable=new ao(e.colorTable);else switch(this.type){case\"mut\":this.colorTable=new ao(qf);break;case\"shoebox\":e.colorScale&&(this.sbColorScale=gf.parse(e.colorScale));break;default:this.posColorScale=new uf(e.posColorScale||Of),this.negColorScale=new uf(e.negColorScale||Uf)}const t=Object.assign({},this.config);t.maxWGCount=t.maxWGCount||Number.MAX_SAFE_INTEGER,\"shoebox\"===this.type?(this.featureSource=new zf(t,this.browser.genome),this.height=e.height||500,this.maxHeight=e.maxHeight||800,this.isLog=!1,this.squishedRowHeight=e.squishedRowHeight||1,this.displayMode=e.displayMode||\"SQUISHED\",this.visibilityWindow=void 0===e.visibilityWindow?1e6:e.visibilityWindow):this.featureSource=Ad(t,this.browser.genome),this.initialSort=e.sort}async postInit(){\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const e=[];if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const n of this.browser.sampleInfo.attributeNames){if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[n]}))){const r=Bt(\"
\");function s(){const e=this.#y.get(n)||1;this.sortByAttribute(n,e),this.#y.set(n,-1*e),this.config.sort={option:\"ATTRIBUTE\",attribute:n,direction:1===e?\"ASC\":\"DESC\"}}r.html(`  ${n.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:r,click:s})}}}const t={SQUISHED:\"Squish\",EXPANDED:\"Expand\",FILL:\"Fill\"};if(\"shoebox\"===this.type&&this.sbColorScale){function o(e){this.browser.inputDialog.present({label:\"Color Scale Threshold\",value:this.sbColorScale.threshold,callback:()=>{const e=Number(this.browser.inputDialog.value,10);e&&(this.sbColorScale.setThreshold(e),this.trackView.repaintViews())}},e)}e.push(\"
\"),e.push({object:Bt(\"
Set color scale threshold
\"),dialog:o})}e.push(\"
\"),e.push(\"DisplayMode:\");const i=\"seg\"===this.type||\"shoebox\"===this.type?[\"SQUISHED\",\"EXPANDED\",\"FILL\"]:[\"SQUISHED\",\"EXPANDED\"];for(let a of i){const c=Dl(t[a],a===this.displayMode);e.push({object:Bt(c),click:function(){this.displayMode=a,this.config.displayMode=a,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return e}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.sampleHeight,yOffset:0}}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:t,end:i});if(this.updateSampleKeys(n),this.initialSort){const e=this.initialSort;if(void 0===e.option||\"VALUE\"===e.option.toUpperCase())this.sortByValue(e,n);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"DESC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return n}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){if(this.checkForLog(r),\"shoebox\"===this.type&&!this.sbColorScale){const e=this.featureSource.hicFile.percentile95||2e3;this.sbColorScale=new gf({threshold:e,r:0,g:0,b:255})}const a={};let c;switch(this.sampleKeys.forEach((function(e,t){a[e]=t})),this.displayMode){case\"FILL\":this.sampleHeight=n/this.sampleKeys.length,c=0;break;case\"SQUISHED\":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let e of r)e.pixelRect=void 0;const h=t+n,d=o+i*s+1,u=s;this.sampleYStart=void 0;for(let i of r){if(i.endd)continue;const n=i.sampleKey||i.sample;i.row=a[n];const r=i.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=r);if(r+lh)continue;const s=Math.max(i.start,o);let f=Math.round((s-o)/u);const p=Math.min(i.end,d),g=Math.round((p-o)/u);let m,w,b=Math.max(1,g-f);if(this.color?m=\"function\"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),\"mut\"===this.type)w=l-2*c,b<3&&(b=3,f-=1);else if(\"shoebox\"===this.type){m=this.sbColorScale.getColor(i.value);let e=l;if(l<.25){const t=.1+2*Math.abs(t.value);e=Math.min(1,t*l)}w=e-2*c}else{let e=i.value;this.isLog||(e=ys.log2(e/2)),m=e<-.1?this.negColorScale.getColor(e):e>.1?this.posColorScale.getColor(e):\"white\";let t=l;if(l<.25){const i=.1+2*Math.abs(e);t=Math.min(1,i*l)}w=t-2*c}i.pixelRect={x:f,y:r,w:b,h:w},e.fillStyle=m,e.fillRect(f,r,b,w)}}}checkForLog(e){if(void 0===this.isLog){this.isLog=!1;for(let t of e)if(t.value<0)return void(this.isLog=!0)}}computePixelHeight(e){if(!e)return 0;const t=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(e),this.sampleKeys.length*t}async sortByValue(e,t){const i=e.chr;let n,r;if(e.position?(n=e.position-1,r=n+1):(n=e.start,r=e.end),t||(t=await this.featureSource.getFeatures({chr:i,start:n,end:r})),!t)return;this.updateSampleKeys(t);const s={},o=\"ASC\"===e.direction?1:-1,a=()=>{const e=r-n+1;for(let i of t){if(i.endr)break;const t=Math.max(n,i.start),o=(Math.min(r,i.end)-t)/e,a=i.sampleKey||i.sample,c=s[a]||0;s[a]=c+o*i.value}this.sampleKeys.sort((function(e,t){let i=s[e],n=s[t];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))},c=()=>{for(let e of t){if(e.endr)break;const t=e.sampleKey||e.sample;(!s.hasOwnProperty(t)||e.value.localeCompare(s[t])>0)&&(s[t]=e.value)}this.sampleKeys.sort((function(e,t){let i=s[e]||\"\",n=s[t]||\"\";return o*i.localeCompare(n)}))};\"mut\"===this.type?c():a(),this.trackView.repaintViews()}sortByAttribute(e,t){this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(e){const t=e.genomicLocation,i=t=>{const i=e.viewport.cachedFeatures;this.sortByValue(t,i)},n=e.referenceFrame.toBP(2.5);return[\"DESC\",\"ASC\"].map((r=>{const s=\"DESC\"===r?\"descending\":\"ascending\";return{label:\"seg\"===this.type||\"shoebox\"===this.type?`Sort by value (${s})`:`Sort by type (${s})`,click:()=>{const s={option:\"VALUE\",direction:r,chr:e.referenceFrame.chr,start:Math.floor(t-n),end:Math.floor(t+n)};i(s),this.config.sort=s}}}))}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(e){if(this.explicitSamples)return;const t=new Set(this.sampleKeys);for(let i of e){const e=i.sampleKey||i.sample;t.has(e)||(this.sampleKeys.push(e),t.add(e))}}}const Of={low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0},Uf={low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255},qf={indel:\"rgb(0,200,0)\",\"targeted region\":\"rgb(236,155,43)\",truncating:\"rgb(\\t150,0,0)\",\"non-coding transcript\":\"rgb(0,0,150)\",synonymous:\"rgb(109,165,95)\",silent:\"rgb(109,135,80)\",missense_mutation:\"rgb(72,130,187)\",missense:\"rgb(72,130,187)\",\"splice site\":\"rgb(143,83,155)\",splice_region:\"rgb(143,83,155)\",nonsense:\"rgb(216, 57,81)\",nonsense_mutation:\"rgb(216, 57,81)\",frame_shift_del:\"rgb(226,135,65)\",frame_shift_ins:\"rgb(226,135,65)\",in_frame_del:\"rgb(247,235,94)\",in_frame_ins:\"rgb(247,235,94)\",\"*other*\":\"rgb(159,91,50)\"};class Qf{constructor(e){this.paired=!0,this.firstAlignment=e,this.chr=e.chr,this.readName=e.readName,e.startt.start?this.connectingEnd=e.start:this.connectingStart=e.start+e.lengthOnRef,this.start=Math.min(t.start,e.start),this.end=Math.max(t.start+t.lengthOnRef,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(t.scStart,e.scStart);const i=Math.max(t.scStart+t.scLengthOnRef,e.scStart+e.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}alignmentContaining(e,t){return this.firstAlignment.containsLocation(e,t)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(e,t)?this.secondAlignment:void 0}popupData(e){let t=this.firstAlignment.popupData(e);return this.secondAlignment&&(t.push(\"-------------------------------\"),t=t.concat(this.secondAlignment.popupData(e))),t}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}get firstOfPairStrand(){return this.firstAlignment.firstOfPairStrand}get pairOrientation(){return this.firstAlignment.pairOrientation}hasTag(e){return this.firstAlignment.hasTag(e)||this.secondAlignment&&this.secondAlignment.hasTag(e)}getGroupValue({option:e,tag:t}){switch(e){case\"strand\":return this.isNegativeStrand()?\"-\":\"+\";case\"FIRST_IN_PAIR_STRAND\":return this.isPaired()?this.isFirstOfPair()?this.isNegativeStrand()?\"-\":\"+\":this.isSecondOfPair()?this.isNegativeStrand()?\"+\":\"-\":void 0:void 0;case\"START\":return this.start;case\"INSERT_SIZE\":return this.fragmentLength;case\"MATE_CHR\":return this.mate?this.mate.chr:void 0;case\"MQ\":return this.mq;case\"ALIGNED_READ_LENGTH\":return this.lengthOnRef;case\"TAG\":return this.tags()[t];case\"PHASE\":return this.tags().HP;case\"READ_ORDER\":return this.isPaired()&&this.isFirstOfPair()?\"FIRST\":this.isPaired()&&this.isSecondOfPair()?\"SECOND\":\"\";default:return}}}class Vf{static instances=new Map;static getKey(e,t,i){const n=\"\"+e+t+i;return Vf.instances.has(n)||Vf.instances.set(n,new Vf(e,t,i)),Vf.instances.get(n)}constructor(e,t,i){this.base=e,this.strand=t,this.modification=i,this.canonicalBase=\"+\"===this.strand?this.base:oc(this.base)}getCanonicalBase(){}toString(){return\"\"+this.base+this.strand+this.modification}static compare(e,t){const i=e.modification,n=t.modification;return i===n?e.strand.charAt(0)-t.strand.charAt(0):jf.has(i)&jf.has(n)?jf.get(i)-jf.get(n):jf.has(i)?1:jf.has(n)?-1:i>n?1:-1}}const jf=new Map([\"NONE_C\",\"NONE_T\",\"NONE_G\",\"NONE_A\",\"m\",\"h\",\"f\",\"c\",\"C\",\"g\",\"e\",\"b\",\"T\",\"U\",\"a\",\"A\",\"o\",\"G\",\"n\",\"N\"].map(((e,t)=>[e,t])));class Wf{constructor(e,t,i,n){this.base=e,this.modification=i,this.strand=t,this.likelihoods=n,this.canonicalBase=\"+\"==this.strand?this.base:oc(this.base),this.key=Vf.getKey(e,t,i)}containsPosition(e){return this.likelihoods.has(e)}is5mC(){return this.modification.equals(\"m\")&&(\"C\"===this.base&&\"+\"===this.strand||\"G\"===this.base&&\"-\"===this.strand)}fullName(){return Gf.get(this.modification)||this.modification}}const Gf=new Map;Gf.set(\"m\",\"5mC\"),Gf.set(\"h\",\"5hmC\"),Gf.set(\"f\",\"5fC\"),Gf.set(\"c\",\"5caC\"),Gf.set(\"g\",\"5hmU\"),Gf.set(\"e\",\"5fU\"),Gf.set(\"b\",\"5caU\"),Gf.set(\"a\",\"6mA\"),Gf.set(\"o\",\"8xoG\"),Gf.set(\"n\",\"Xao\"),Gf.set(\"C\",\"Unknown C\"),Gf.set(\"T\",\"Unknown T\"),Gf.set(\"A\",\"Unknown A\"),Gf.set(\"G\",\"Unknown G\"),Gf.set(\"N\",\"Unknown\");const $f=new Map([[\"m\",\"5mC\"],[\"h\",\"5hmC\"],[\"f\",\"5fC\"],[\"c\",\"5caC\"],[\"g\",\"5hmU\"],[\"e\",\"5fU\"],[\"b\",\"5caU\"],[\"a\",\"6mA\"],[\"o\",\"8xoG\"],[\"n\",\"Xao\"],[\"C\",\"Unknown C\"],[\"T\",\"Unknown T\"],[\"A\",\"Unknown A\"],[\"G\",\"Unknown G\"],[\"N\",\"Unknown\"]]);function Kf(e){return $f.has(e)?$f.get(e):\"Uknown\"}function Yf(e){if(!e)return!1;const t=e.length;if(0==t)return!1;for(let i=0;i\"9\")return!1}return!0}function Xf(e){return e<0?e+256:e}class Zf{allModifications=new Set;simplexModifications=new Set;maxLikelihoods=new Map;nomodLikelihoods=new Map;lastThreshold;incrementCounts(e){if(!e.blocks)return;const t=e.getBaseModificationSets();if(t)for(let i of e.blocks)if(\"S\"!==i.type)for(let e=0;eo&&(s=e.canonicalBase,o=c,n=t)}}if(0!=s){const t=i.start+e,r=Vf.getKey(s,\"+\",\"NONE_\"+s);this.allModifications.add(r);const c=(e,t,i,n)=>{let r=n.get(i);r||(r=new Map,n.set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push(t)};c(t,o,n,this.maxLikelihoods),a>o?c(t,a,r,this.nomodLikelihoods):c(t,o,n,this.nomodLikelihoods)}}}getCount(e,t,i,n){this.lastThreshold=i;const r=255*i,s=n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t);if(!s)return 0;const o=s.get(e);if(o){let e=0;for(let t of o){Xf(t)>=r&&e++}return e}return 0}getLikelihoodSum(e,t,i,n){this.lastThreshold=i;const r=255*i,s=(n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t)).get(e);if(s){let e=0;for(let t of s){const i=Xf(t);i>=r&&(e+=i)}return e}return 0}popupData(e,t){const i=[];i.push(\"Modifications with likelihood > \"+100*this.lastThreshold+\"%\");for(let n of this.maxLikelihoods.keys()){if(this.maxLikelihoods.get(n).has(e)){let r=\"basemod2\"===t;const s=this.getCount(e,n,this.lastThreshold,r);if(s>0){const t=this.getLikelihoodSum(e,n,this.lastThreshold,r)/s*.3921568,o=Kf(n.modification);i.push(o+\" (\"+n.base+n.strand+\"): \"+s+\" @ average likelihood \"+Math.round(t)+\"%\")}}}return i}computeSimplex(){const e=new Set(Array.from(this.allModifications).filter((e=>\"-\"===e.strand)).map((e=>e.modification)));for(let t of this.allModifications)\"+\"!==t.strand||e.has(t.modification)||(this.simplexModifications.add(t.modification),this.simplexModifications.add(\"NONE_\"+t.getCanonicalBase()))}}class Jf{constructor(){this.alignments=[],this.score=void 0}findAlignment(e,t=!1){const i=(e,i)=>i>=e.start&&i=s.start&&e0?h-=e:0===h&&(h=1)}return h}(s,r,e);case\"strand\":return s.strand?1:-1;case\"START\":return s.start;case\"TAG\":return s.tags()[i];case\"READ_NAME\":return s.readName;case\"INSERT_SIZE\":return-Math.abs(s.fragmentLength);case\"GAP_SIZE\":return-s.gapSizeAt(e);case\"MATE_CHR\":return s.mate?s.mate.chr:Number.MAX_VALUE;case\"MQ\":return void 0===s.mq?Number.MAX_VALUE:-s.mq;case\"ALIGNED_READ_LENGTH\":return-s.lengthOnRef;default:return Number.MAX_VALUE}}}var ep={fr:{F1R2:\"LR\",F2R1:\"LR\",F1F2:\"LL\",F2F1:\"LL\",R1R2:\"RR\",R2R1:\"RR\",R1F2:\"RL\",R2F1:\"RL\"},rf:{R1F2:\"LR\",R2F1:\"LR\",R1R2:\"LL\",R2R1:\"LL\",F1F2:\"RR\",F2F1:\"RR\",F1R2:\"RL\",F2R1:\"RL\"},ff:{F2F1:\"LR\",R1R2:\"LR\",F2R1:\"LL\",R1F2:\"LL\",R2F1:\"RR\",F1R2:\"RR\",R2R1:\"RL\",F1F2:\"RL\"}};class tp{#A=[];baseModificationKeys=new Set;constructor(e,t,i,{samplingWindowSize:n,samplingDepth:r,alleleFreqThreshold:s,colorBy:o}){this.alleleFreqThreshold=void 0===s?.2:s,this.samplingWindowSize=n||100,this.samplingDepth=r||1e3,this.chr=e,this.start=Math.floor(t),this.end=Math.ceil(i),this.length=i-t,this.coverageMap=new np(e,t,i,this.alleleFreqThreshold),this.downsampledIntervals=[],o&&o.startsWith(\"basemod\")&&(this.baseModCounts=new Zf),this.alignments=[],this.pairsCache=new Map,this.downsampledReads=new Set,this.currentBucket=new ip(this.start,this.start+this.samplingWindowSize,this),this.hasPairs=!1}pack({viewAsPairs:e,showSoftClips:t,expectedPairOrientation:i,groupBy:n,displayMode:r}){let s=this.allAlignments();s=e?function(e){const t=new Map,i=e.map((e=>{if(ap(e)){let i=t.get(e.readName);return i?(i.setSecondAlignment(e),t.delete(e.readName),i):(i=new Qf(e),t.set(e.readName,i),i)}return e}));return i}(s):function(e){return e.flatMap((e=>e instanceof Qf?[e.firstAlignment,e.secondAlignment].filter(Boolean):[e]))}(s),this.packAlignmentRows(s,t,i,n,r),this.alignments&&delete this.alignments}packAlignmentRows(e,t,i,n,r){this.#A=[];const s=(e,i)=>{e.sort((function(e,i){return t?e.scStart-i.scStart:e.start-i.start}));const n=new op(i);let r,s=0,o=0;const a=new Set,c=()=>{r=new Jf,n.push(r),s=0,o=0,a.clear()};for(c();e.length>0;)if(o>=0&&o(t?e.scStart:e.start)>s),o)}else e=e.filter((e=>!a.has(e))),c();return n},o=(e,t)=>{e.sort((function(e,t){return e.start-t.start}));const i=new op(t),{start:n,end:r}=this.viewport.genomicRange();for(let t of e)if(t.endr)this.#A.push(t);else{const e=new Jf;e.alignments.push(t),i.push(e)}return i};if(!e||0===e.length)return new Map;{const t=new Map;if(n)for(let r of e){const e=lp(r,n,i)||\"\";t.has(e)||t.set(e,[]),t.get(e).push(r)}else t.set(\"\",e);const a=new Map,c=Array.from(t.keys()).sort(function(e,t){switch(e){case\"pairOrientation\":return function(e){const t=[\"LL\",\"RR\",\"RL\",\"LR\",\"\"];return(e,i)=>t.indexOf(e)-t.indexOf(i)}();case\"strand\":case\"firstOfPairStrand\":return up;default:return e&&e.startsWith(\"base:\")?dp:fp}}(n));for(let e of c){const i=t.get(e),n=\"FULL\"===r?o(i,e):s(i,e);a.set(e,n)}this.packedGroups=a}}push(e){this.hasPairs=this.hasPairs||e.isPaired(),this.coverageMap.incCounts(e);const t=e.getBaseModificationSets();if(t)for(let e of t)this.baseModificationKeys.add(e.key);this.baseModCounts&&this.baseModCounts.incrementCounts(e),this.downsampledReads.has(e.readName)?this.currentBucket.downsampledCount++:(e.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new ip(e.start,e.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(e))}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.hasAlignments=this.alignments.length>0,this.alignments.sort((function(e,t){return e.start-t.start})),this.baseModCounts&&this.baseModCounts.computeSimplex(),delete this.currentBucket,delete this.pairsCache,delete this.downsampledReads}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new sp(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount))}allAlignments(){if(this.alignments)return this.alignments;if(this.packedGroups){const e=Array.from(this.packedGroups.values()).flatMap((e=>e.rows.flatMap((e=>e.alignments))));if(this.#A&&this.#A.length>0)for(let t of this.#A)e.push(t);return e}return[]}getMax(e,t){return this.coverageMap.getMax(e,t)}sortRows(e){if(this.packedGroups)for(let t of this.packedGroups.values())t.sortRows(e,this)}}class ip{constructor(e,t,{samplingDepth:i,downsampledReads:n,pairsCache:r}){this.start=e,this.end=t,this.alignments=[],this.downsampledCount=0,this.samplingDepth=i,this.downsampledReads=n,this.pairsCache=r,this.hasPairs=!1}addAlignment(e){this.hasPairs=this.hasPairs||e.isPaired();const t=this.hasPairs?Math.ceil(this.samplingDepth/2):this.samplingDepth;if(ap(e)){const t=this.pairsCache.get(e.readName);if(t)return t.setSecondAlignment(e),void this.pairsCache.delete(e.readName)}if(this.alignments.lengtht)break;const s=this.coverage[r];n>=e&&s&&(i=Math.max(i,s.total))}return i}incCounts(e){var t=this;if(void 0===e.blocks?i(e):e.blocks.forEach((function(e){i(e)})),e.gaps)for(let i of e.gaps)if(\"D\"===i.type){const e=i.start-t.bpStart;for(let n=e;n=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.posA;case\"C\":case\"c\":return n.posC;case\"T\":case\"t\":return n.posT;case\"G\":case\"g\":return n.posG;case\"N\":case\"n\":return n.posN;default:return 0}}getNegCount(e,t){const i=e-this.bpStart;if(i<0||i>=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.negA;case\"C\":case\"c\":return n.negC;case\"T\":case\"t\":return n.negT;case\"G\":case\"g\":return n.negG;case\"N\":case\"n\":return n.negN;default:return 0}}getCount(e,t){return this.getPosCount(e,t)+this.getNegCount(e,t)}getTotalCount(e){const t=e-this.bpStart;return t>=0&&t=t}}class sp{constructor(e,t,i){this.start=e,this.end=t,this.counts=i}popupData(e){return[{name:\"start\",value:Math.floor(this.start+1)},{name:\"end\",value:this.end},{name:\"# downsampled:\",value:this.counts}]}}class op{pixelTop=0;pixelBottom=0;rows=[];constructor(e){this.name=this.name}push(e){this.rows.push(e)}get length(){return this.rows.length}sortRows(e,t){const i=[],n=[];for(let t of this.rows){void 0!==t.findAlignment(e.position,e.sortAsPairs)?i.push(t):n.push(t)}i.sort(((i,n)=>{const r=e.direction,s=i.getSortValue(e,t),o=n.getSortValue(e,t);if(void 0===o&&void 0!==o)return 1;if(void 0!==s&&void 0===o)return-1;const a=s>o?1:s>1);t(e[i])?r=i:n=i}return r}function lp(e,t,i){let n,r,s;if(t.startsWith(\"tag:\"))n=t.substring(4),t=\"tag\";else if(t.startsWith(\"base:\")){const e=t.split(\":\");3===e.length&&(t=\"base\",r=e[1],s=Number.parseInt(e[2].replaceAll(\",\",\"\"))-1)}switch(t){case\"strand\":return e.strand?\"+\":\"-\";case\"firstOfPairStrand\":const t=e.firstOfPairStrand;return void 0===t?\"\":t?\"+\":\"-\";case\"mateChr\":return e.mate&&e.isMateMapped()?e.mate.chr:\"\";case\"pairOrientation\":return ep[i][e.pairOrientation]||\"\";case\"chimeric\":return e.tags().SA?\"chimeric\":\"\";case\"supplementary\":return e.isSupplementary?\"supplementary\":\"\";case\"readOrder\":return e.isPaired()&&e.isFirstOfPair()?\"first\":e.isPaired()&&e.isSecondOfPair()?\"second\":\"\";case\"phase\":return e.tags().HP||\"\";case\"tag\":return e.tags()[n]||\"\";case\"base\":if(e.chr===r&&e.start<=s&&e.end>s){const t=e.readBaseAt(s);return t||\"GAP\"}return\"\";default:return}}const hp=new Map([[\"A\",1],[\"T\",2],[\"C\",3],[\"G\",4],[\"N\",5],[\"GAP\",5],[\"\",7]]);function dp(e,t){return hp.has(e)&&hp.has(t)?hp.get(e)-hp.get(t):e.localeCompare(t,void 0,{sensitivity:\"base\"})}function up(e,t){return e===t?0:e&&t?-e.localeCompare(t):e?1:-1}function fp(e,t){if(e||t){if(e){if(t){if(e===t)return 0;if(Va(e)&&(Va(t),1))return Number.parseFloat(e)-Number.parseFloat(t);{let i=e.toString(),n=t.toString();return i.localeCompare(n,void 0,{sensitivity:\"base\"})}}return-1}return 1}return 0}class pp{constructor(e){const t=e.split(\",\");this.chr=t[0],this.start=parseInt(t[1]),this.strand=t[2].charAt(0),this.mapQ=parseInt(t[4]),this.numMismatches=parseInt(t[5]),this.lenOnRef=function(e){let t=0,i=\"\";for(let n=0;n47&&r<58)i+=e.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:t+=parseInt(i.toString())}i=\"\"}}return t}(t[3])}printString(){return this.chr+\":\"+Rt(this.start)+\"-\"+Rt(this.start+this.lenOnRef)+\" (\"+this.strand+\") = \"+Rt(this.lenOnRef)+\"bp @MAPQ: \"+this.mapQ+\" NM: \"+this.numMismatches}}function gp(e){return e.split(\";\").filter((e=>e.length>0)).map((e=>new pp(e)))}const mp={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class wp{constructor(){this.hidden=!1}isMapped(){return!(4&this.flags)}isPaired(){return!!(1&this.flags)}isProperPair(){return!!(2&this.flags)}isFirstOfPair(){return!!(64&this.flags)}isSecondOfPair(){return!!(128&this.flags)}isSecondary(){return!!(256&this.flags)}isSupplementary(){return!!(2048&this.flags)}isFailsVendorQualityCheck(){return!!(512&this.flags)}isDuplicate(){return!!(1024&this.flags)}isMateMapped(){return!(8&this.flags)}isNegativeStrand(){return!!(16&this.flags)}isMateNegativeStrand(){return!!(32&this.flags)}hasTag(e){const t=this.tagDict||function(e){let t=0;const i=e.length,n={};for(;t=i&&e<=i+n}popupData(e){const t=[];if(e=Math.floor(e),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(e===i||e===i-1)return t.push({name:\"Insertion\",value:n.substr(r.seqOffset,r.len)}),t.push({name:\"Location\",value:i}),t}}t.push({name:\"Read Name\",value:this.readName}),t.push(\"
\"),t.push({name:\"Alignment Start\",value:Rt(1+this.start),borderTop:!0}),t.push({name:\"Read Strand\",value:!0===this.strand?\"(+)\":\"(-)\",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const e=25;n=`${n.substring(0,e-2)} ... ${n.substring(n.length-e+2)}`}t.push({name:\"Cigar\",value:n}),t.push({name:\"Mapping Quality\",value:this.mq}),t.push({name:\"Secondary\",value:a(this.isSecondary())}),t.push({name:\"Supplementary\",value:a(this.isSupplementary())}),t.push({name:\"Duplicate\",value:a(this.isDuplicate())}),t.push({name:\"Failed QC\",value:a(this.isFailsVendorQualityCheck())}),this.isPaired()&&(t.push(\"
\"),t.push({name:\"First in Pair\",value:!this.isSecondOfPair(),borderTop:!0}),t.push({name:\"Mate is Mapped\",value:a(this.isMateMapped())}),this.pairOrientation&&t.push({name:\"Pair Orientation\",value:this.pairOrientation}),this.isMateMapped()&&(t.push({name:\"Mate Chromosome\",value:this.mate.chr}),t.push({name:\"Mate Start\",value:this.mate.position+1}),t.push({name:\"Mate Strand\",value:!0===this.mate.strand?\"(+)\":\"(-)\"}),t.push({name:\"Insert Size\",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty(\"SA\")){t.push(\"
\"),t.push({name:\"Supplementary Alignments\",value:\"\"});const e=gp(r.SA);if(e){t.push(\"
    \");for(let i of e)t.push(`
  • ${i.printString()}
  • `);t.push(\"
\")}}const s=new Set([\"SA\",\"MD\"]);t.push(\"
\");for(let e in r)s.has(e)||t.push({name:e,value:r[e]});t.push({name:\"Hidden Tags\",value:\"SA, MD\"}),t.push(\"
\"),t.push({name:\"Genomic Location: \",value:Rt(1+e)}),t.push({name:\"Read Base:\",value:this.readBaseAt(e)}),t.push({name:\"Base Quality:\",value:this.readBaseQualityAt(e)});const o=this.getBaseModificationSets();if(o){const i=this.positionToReadIndex(e);if(void 0!==i){let e=!1;for(let n of o)if(n.containsPosition(i)){e||(t.push(\"
\"),t.push(\"Base modifications:\"),e=!0);const r=Math.round(100/255*Xf(n.likelihoods.get(i)));t.push(`${n.fullName()} @ likelihood = ${r}%`)}}}return t;function a(e){return e?\"Yes\":\"No\"}}readBaseAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.seq)return\"*\";{const i=t.seqIndexAt(e);return this.seq[i]}}}readBaseQualityAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.qual)return 30;{const i=t.seqIndexAt(e);return i>=0&&this.qual&&i=t.start&&e1)if(Yf(e))h.push(e);else for(let t=0;t=n.start&&t>1)+n;a+4=t)return!1;if(\"B\"!==String.fromCharCode(e[a+2])||\"I\"!==String.fromCharCode(e[a+3]))return!1;var l=Dp(e,a+4),h=a+8;if(h+4*l>t)return!1;var d=\"\",u=0;s.length=0,a=h;for(var f=0;f>4,m=Ep[15&p];\"M\"!==m&&\"EQ\"!==m&&\"X\"!==m&&\"D\"!==m&&\"N\"!==m&&\"=\"!==m||(u+=g),d=d+g+m,s.push({len:g,ltr:m})}return r.cigar=d,r.lengthOnRef=u,!0},decodeBamRecords:function(e,t,i,n,r,s,o,a){for(;te.length)return;if(p<0){t=u;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p>8,b=255&m,F=Dp(e,t+16),v=(4294901760&F)>>16,y=65535&F,A=Dp(e,t+20),C=Dp(e,t+24),_=Dp(e,t+28),x=Dp(e,t+32);let k=[];for(let i=0;i>4,h=Ep[15&c];\"M\"!==h&&\"EQ\"!==h&&\"X\"!==h&&\"D\"!==h&&\"N\"!==h&&\"=\"!==h||(I+=l),S=S+l+h,E+=4,B={len:l,ltr:h},N.push(B)}if(f.chr=n[p],f.start=g,f.flags=v,f.strand=!(16&v),f.readName=k,f.cigar=S,f.lengthOnRef=I,f.fragmentLength=x,f.mq=w,Mp.bam_tag2cigar(e,u,E,A,f,N),f.end=f.start+f.lengthOnRef,f.end>1;for(let t=0;t>4]),M.push(Sp[15&d])}M=M.slice(0,A).join(\"\"),E+=R;const D=[];for(let t=0;t=0&&(f.mate={chr:n[C],position:_,strand:!(32&v)}),f.seq=M,f.qual=D;const T=new Uint8Array(e.buffer.slice(E,u));f.tagDict=zp(T),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Rp(f,N),i.push(f)),t=u}},decodeSamRecords:function(e,t,i,n,r,s){var o,a,c,l,h,d,u,f,p,g;for(l=(o=Dt(e)).length,!1,a=0;ar)break;if(f=0,(g=Tp(p.cigar)).forEach((function(e){var t=e.len,i=e.ltr;\"M\"!==i&&\"EQ\"!==i&&\"X\"!==i&&\"D\"!==i&&\"N\"!==i&&\"=\"!==i||(f+=t)})),p.lengthOnRef=f,!(p.start+fBp&&(console.log(\"Warning: attempt to set sampling depth > maximum value of \"+Bp),e.samplingDepth=Bp)},setPairOrientation:function(e){if(e.isMapped()&&e.mate&&e.isMateMapped()&&e.mate.chr===e.chr){var t=e.strand?\"F\":\"R\",i=e.mate,n=i.strand?\"F\":\"R\",r=\" \",s=\" \";e.isFirstOfPair()?(r=\"1\",s=\"2\"):e.isSecondOfPair()&&(r=\"2\",s=\"1\");var o=[],a=e.fragmentLength,c=e.end-e.start;if(0===a)a=(e.start0?(o[0]=t,o[1]=r,o[2]=n,o[3]=s):(o[2]=t,o[3]=r,o[0]=n,o[1]=s),e.pairOrientation=o.join(\"\")}}};function Rp(e,t){const i=[];let n,r,s=0,o=e.start;e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef;for(let a of t){let t;switch(a.ltr){case\"H\":case\"P\":break;case\"S\":t=o,e.scLengthOnRef+=a.len,0===i.length&&(e.scStart-=a.len,t-=a.len),i.push(new xp({start:t,seqOffset:s,len:a.len,type:\"S\"})),s+=a.len;break;case\"N\":case\"D\":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case\"I\":void 0===n&&(n=[]),n.push(new xp({start:o,len:a.len,seqOffset:s,type:\"I\"})),s+=a.len;break;case\"M\":case\"EQ\":case\"=\":case\"X\":i.push(new xp({start:o,seqOffset:s,len:a.len,type:\"M\"})),s+=a.len,o+=a.len;break;default:console.log(\"Error processing cigar element: \"+a.len+a.ltr)}}e.blocks=i,e.insertions=n,e.gaps=r}function Dp(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Tp(e){var t,i,n,r,s,o,a,c,l;for(t=[],i=[],s=null,r=e.length,n=0;n=48&&l<=57?i.push(o):(a=o,c=Number.parseInt(i.join(\"\")),i=[],null!==s&&s.ltr===a?s.len+=c:(s={len:c,ltr:a},t.push(s)));return t}function Lp(e){var t={};return e.forEach((function(e){var i=e.split(\":\");t[i[0]]=i[2]})),t}function zp(e){let t=0;const i=e.length,n={},r=new DataView(e.buffer);for(;t=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>t.has(e)));e.length>0&&(n=e[0])}return this.chrAliasTable.set(e,n),n}return e}}class Pp{chrAliasTable=new Map;constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.baiPath=e.indexURL,Mp.setReaderDefaults(this,e),this._blockLoader=new yh(e)}async readAlignments(e,t,i){const n=await this.#x(e),r=new tp(e,t,i,this.config);if(void 0===n)return r;{const e=(await this.getIndex()).chunksForRange(n,t,i);if(!e||0===e.length)return r;for(let s of e){const e=await this._blockLoader.getData(s.minv,s.maxv);if(Mp.decodeBamRecords(e,s.minv.offset,r,this.header.chrNames,n,t,i,this.filter))break}return r.finish(),r}}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async getHeader(){if(!this.header){const e=this.genome,t=await this.getIndex();let i;if(t.firstBlockPosition){const e=Ua(this.config,{range:{start:t.firstBlockPosition,size:26}}),n=ms(await Qs.loadArrayBuffer(this.bamPath,e));i=t.firstBlockPosition+n}else i=64e3;const n=Ua(this.config,{range:{start:0,size:i}});this.header=await Mp.readHeader(this.bamPath,n,e)}return this.header}async getIndex(){return this.index||(this.index=await gh(this.baiPath,this.config)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const e=await this.getHeader();return this.chrToIndex=e.chrToIndex,this.indexToChr=e.chrNames,this.chrNames=new Set(e.chrNames),this.chrToIndex}}}class Op{constructor(e,t){this.config=e,this.genome=t;const i={};e.sources.sequences.forEach((function(n){const r=t?t.getChromosomeName(n):n;i[r]=function(e,t,i){const n={url:e.sources.url.replace(\"$CHR\",i)};e.sources.indexURL&&(n.indexURL=e.sources.indexURL.replace(\"$CHR\",i));const r=Object.assign(e,n);return new Pp(r,t)}(e,t,n)})),this.bamReaders=i,Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.bamReaders.hasOwnProperty(e)){let n=this.bamReaders[e];return await n.readAlignments(e,t,i)}return new tp(e,t,i,this.config)}}const Up=function(e,t){this.config=e,this.genome=t,Mp.setReaderDefaults(this,e)};function qp(){const e=this,t=this.genome;if(this.header)return Promise.resolve(this.header);{const i=this.config.url+\"?file=\"+this.config.alignmentFile+\"&options=-b,-H\",n=Ua(this.config);return Mp.readHeader(i,n,t).then((function(t){return e.header=t,t}))}}Up.prototype.readAlignments=function(e,t,i){var n=this;return qp.call(n).then((function(r){var s,o;return s=r.chrAliasTable.hasOwnProperty(e)?r.chrAliasTable[e]:e,o=n.config.url+\"?reference=\"+n.config.referenceFile+\"&file=\"+n.config.alignmentFile+\"®ion=\"+s+\":\"+t+\"-\"+i,Qs.loadString(o,Ua(n.config)).then((function(o){var a;return r.chrToIndex[s],a=new tp(e,t,i,n.config),Mp.decodeSamRecords(o,a,s,t,i,n.filter),a}))}))};class Qp extends Rh{constructor(e,t){super(e,t),Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(!this.header){const e=gs((await this.readHeaderData()).buffer);this.header=Mp.decodeBamHeader(e,this.genome),this.chrAliasTable=new Map;for(let e of this.header.chrNames)this.chrAliasTable.set(e,this.genome.getChromosomeName(e))}let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=gs((await this.readData(n,t,i)).buffer);this.header=Mp.decodeBamHeader(r,this.genome);const s=this.header.chrToIndex[e],o=new tp(e,t,i,this.config);return Mp.decodeBamRecords(r,this.header.size,o,this.header.chrNames,s,t,i,this.filter),o.finish(),o}}\n", - "/*! For license information please see cram-bundle.js.LICENSE.txt */for(var Vp=(()=>{var e={4923:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(8712),s=i(5931),o=i(9747);function a(e,t){const[i,n,r,s,o,a]=t,c=i;e[c]||(e[c]=[]),e[c].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}t.default=class{constructor(e){this.filehandle=(0,s.open)(e.url,e.path,e.filehandle)}parseIndex(){return n(this,void 0,void 0,(function*(){const e={},t=31===(i=yield this.filehandle.readFile())[0]&&139===i[1]?(0,r.unzip)(i):i;var i;if(t.length>4&&21578050===t.readUInt32LE(0))throw new o.CramMalformedError(\"invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support\");let n=[],s=\"\";for(const i of t)if(i>=48&&i<=57||!s&&45===i)s+=String.fromCharCode(i);else if(9===i)n.push(Number.parseInt(s,10)),s=\"\";else if(10===i)n.push(Number.parseInt(s,10)),s=\"\",a(e,n),n=[];else if(13!==i&&32!==i)throw new o.CramMalformedError(\"invalid .crai index file\");return s&&n.push(Number.parseInt(s,10)),6===n.length&&a(e,n),Object.entries(e).forEach((([t,i])=>{const n=i;e[t]=n.sort(((e,t)=>e.start-t.start||e.span-t.span))})),e}))}getIndex(){return this.parseIndexP||(this.parseIndexP=this.parseIndex().catch((e=>{throw this.parseIndexP=void 0,e}))),this.parseIndexP}hasDataForReferenceSequence(e){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[e]}))}getEntriesForRange(e,t,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[e];if(!n)return[];const r=e=>{const n=e.start,r=e.start+e.span;return n>i?-1:r<=t?1:0},s=[];for(const e of n)0===r(e)&&s.push(e);return s}))}}},9508:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=class{constructor(e,t){this.parameters=e,this.dataType=t}}},368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(e,t,i,n){return(0,o.getBits)(t.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}t.default=a},8635:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(9508)),s=i(400);class o extends r.default{constructor(e,t,i){super(e,t),this.instantiateCodec=i}decode(e,t,i,n){const r=this._getLengthCodec().decode(e,t,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a{(0,s.tinyMemoize)(o,e)}))},4839:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(e,t){const i=e.content,{stopByte:n}=this.parameters,r=t.bytePosition;let s=t.bytePosition;for(;i[s]!==n&&s=e.content.length)throw new a.CramBufferOverrunError(\"attempted to read beyond end of block. this file seems truncated.\");return e.content[t.bytePosition++]}}t.default=c},8185:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(e,t,i,n){let r=1;for(;0===(0,o.getBits)(t.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(t.content,n.coreBlock,r-1)|1<{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramBufferOverrunError=void 0,t.getBits=function(e,t,n){let r=0;if(t.bytePosition+(7-t.bitPosition+n)/8>e.length)throw new i(\"read error during decoding. the file seems to be truncated.\");for(let i=n;i;i--)r<<=1,r|=e[t.bytePosition]>>t.bitPosition&1,t.bitPosition-=1,t.bitPosition<0&&(t.bytePosition+=1),t.bitPosition&=7;return r};class i extends Error{}t.CramBufferOverrunError=i},4341:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),this.codes={},this.codeBook={},this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],![\"byte\",\"int\"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let e=new Array(this.parameters.numCodes);for(let t=0;te.bitLength-t.bitLength||e.symbol-t.symbol)),this.codeBook={},e.forEach((e=>{this.codeBook[e.bitLength]||(this.codeBook[e.bitLength]=[]),this.codeBook[e.bitLength].push(e.symbol)}))}buildCodes(){this.codes={};let e=0,t=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=Number.parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};t+=1;const o=s-e;if(t<<=o,n.bitCode=t,e+=o,function(e){let t=e-(e>>1)&1431655765;return t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}(t)>s)throw new r.CramMalformedError(\"Symbol out of range\");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((e,t)=>e.bitLength-t.bitLength||e.bitCode-t.bitCode)),this.sortedValuesByBitCode=this.sortedCodes.map((e=>e.value)),this.sortedBitCodes=this.sortedCodes.map((e=>e.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((e=>e.bitLength));const e=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(e+1).fill(-1);for(let e=0;e-1&&this.sortedBitLengthsByBitCode[i]===t)return this.sortedValuesByBitCode[i];for(let i=e;this.sortedCodes[i+1].bitLength===t&&i{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:\"MIDNSHP:XB\",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},7219:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(6524),r=i(9747),s={BF:\"int\",CF:\"int\",RI:\"int\",RL:\"int\",AP:\"int\",RG:\"int\",MF:\"int\",NS:\"int\",NP:\"int\",TS:\"int\",NF:\"int\",TC:\"byte\",TN:\"int\",FN:\"int\",FC:\"byte\",FP:\"int\",BS:\"byte\",IN:\"byteArray\",SC:\"byteArray\",DL:\"int\",BA:\"byte\",BB:\"byteArray\",RS:\"int\",PD:\"int\",HC:\"int\",MQ:\"int\",RN:\"byteArray\",QS:\"byte\",QQ:\"byteArray\",TL:\"int\"};t.default=class{constructor(e){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(e){const t=new Array(5);for(let e=0;e<5;e+=1)t[e]=new Array(4);return t[0][e[0]>>6&3]=\"C\",t[0][e[0]>>4&3]=\"G\",t[0][e[0]>>2&3]=\"T\",t[0][3&e[0]]=\"N\",t[1][e[1]>>6&3]=\"A\",t[1][e[1]>>4&3]=\"G\",t[1][e[1]>>2&3]=\"T\",t[1][3&e[1]]=\"N\",t[2][e[2]>>6&3]=\"A\",t[2][e[2]>>4&3]=\"C\",t[2][e[2]>>2&3]=\"T\",t[2][3&e[2]]=\"N\",t[3][e[3]>>6&3]=\"A\",t[3][e[3]>>4&3]=\"C\",t[3][e[3]>>2&3]=\"G\",t[3][3&e[3]]=\"N\",t[4][e[4]>>6&3]=\"A\",t[4][e[4]>>4&3]=\"C\",t[4][e[4]>>2&3]=\"G\",t[4][3&e[4]]=\"T\",t}(e.preservation.SM),this.dataSeriesEncoding=e.dataSeriesEncoding,this.tagEncoding=e.tagEncoding}getCodecForTag(e){const t=this.tagCodecCache[e];if(t)return t;{const t=this.tagEncoding[e];if(!t)throw new Error(\"Error, no tag encoding\");const i=(0,n.instantiateCodec)(t,\"byteArray\");return this.tagCodecCache[e]=i,i}}getTagNames(e){return this.tagIdsDictionary[e]}getCodecForDataSeries(e){let t=this.dataSeriesCodecCache[e];if(void 0===t){const i=this.dataSeriesEncoding[e];if(i){const o=s[e];if(!o)throw new r.CramMalformedError(`data series name ${e} not defined in file compression header`);t=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[e]=t}}return t}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.endsWith(\"Cache\")||(e[t]=this[t])})),e}}},78:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=i(9747),a=i(400),c=r(i(6771)),l=r(i(7219)),h=i(3165);class d{constructor(e,t){this.file=e,this.filePosition=t}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(!(null==e?void 0:e.numRecords))return null;const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),n=yield this.getFirstBlock();if(void 0===n)return;if(\"COMPRESSION_HEADER\"!==n.contentType)throw new o.CramMalformedError(`invalid content type ${n.contentType} in compression header block`);const r=(0,a.parseItem)(n.content,i.cramCompressionHeader.parser,0,n.contentPosition);return Object.assign(Object.assign({},n),{parsedContent:r})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(e)return this.file.readBlock(e._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const e=yield this.getCompressionHeaderBlock();if(e)return new l.default(e.parsedContent)}))}getSlice(e,t){return new c.default(this,e,t)}_readContainerHeader(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),{cramContainerHeader1:n,cramContainerHeader2:r}=i,{size:o}=yield this.file.stat();if(e>=o)return void console.warn(`pos:${e}>=fileSize:${o} in cram container`);const c=s.Buffer.allocUnsafe(n.maxLength);yield this.file.read(c,0,n.maxLength,e);const l=(0,a.parseItem)(c,n.parser),d=(0,a.itf8Size)(l.numLandmarks);if(e+l.length>=o)return void console.warn(`container at ${e} is beyond fileSize:${o}, skipping`);const u=s.Buffer.allocUnsafe(r.maxLength(l.numLandmarks));yield this.file.read(u,0,r.maxLength(l.numLandmarks),e+l._size-d);const f=(0,a.parseItem)(u,r.parser);return this.file.validateChecksums&&void 0!==f.crc32&&(yield this.file.checkCrc32(e,l._size+f._size-d-4,f.crc32,`container header beginning at position ${e}`)),Object.assign(l,f,{_size:l._size+f._size-d,_endPosition:l._size+f._size-d+e})}))}}t.default=d,\"getHeader getCompressionHeaderBlock getCompressionScheme\".split(\" \").forEach((e=>{(0,a.tinyMemoize)(d,e)}))},6794:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=r(i(928)),a=r(i(7392)),c=r(i(6960)),l=r(i(235)),h=i(1307),d=i(9747),u=i(8712),f=r(i(9989)),p=i(3165),g=r(i(78)),m=i(5931),w=i(400),b=i(5417);class F{constructor(e){var t;if(this.file=(0,m.open)(e.url,e.path,e.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=e.seqFetch,this.options={checkSequenceMD5:e.checkSequenceMD5,cacheSize:null!==(t=e.cacheSize)&&void 0!==t?t:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const e=new Uint32Array([287454020]),t=new Uint8Array(e.buffer);return 68===t[0]?0:17===t[0]?1:2}()>0)throw new Error(\"Detected big-endian machine, may be unable to run\")}read(e,t,i,n){return this.file.read(e,t,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const{maxLength:e,parser:t}=(0,p.cramFileDefinition)(),i=s.Buffer.allocUnsafe(e);yield this.file.read(i,0,e,0);const n=t(i).value;if(2!==n.majorVersion&&3!==n.majorVersion)throw new d.CramUnimplementedError(`CRAM version ${n.majorVersion} not supported`);return n}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.getContainerById(0);if(!e)throw new d.CramMalformedError(\"file contains no containers\");const t=yield e.getFirstBlock();if(void 0===t)return(0,b.parseHeaderText)(\"\");const i=t.content,n=i.readInt32LE(0),r=i.toString(\"utf8\",4,4+n);return this.header=r,(0,b.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getContainerById(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t);let n=i.cramFileDefinition.maxLength;const{size:r}=yield this.file.stat(),{cramContainerHeader1:s}=i;let o;for(let t=0;t<=e;t++){if(n+s.maxLength+8>=r)return;o=this.getContainerAtPosition(n);const i=yield o.getHeader();if(!i)throw new d.CramMalformedError(`container ${e} not found in file`);if(0===t){n=i._endPosition;for(let e=0;e=r)return;const o=s.Buffer.allocUnsafe(n.maxLength);return yield this.file.read(o,0,n.maxLength,e),(0,w.parseItem)(o,n.parser,0,e)}))}_parseSection(e,t){return n(this,arguments,void 0,(function*(e,t,i=e.maxLength,n){let r;if(n)r=n;else{const{size:e}=yield this.file.stat();if(t+i>=e)return;r=s.Buffer.allocUnsafe(i),yield this.file.read(r,0,i,t)}const o=(0,w.parseItem)(r,e.parser,0,t);if(o._size!==i)throw new d.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${o._size}`);return o}))}_uncompress(e,t,i){return n(this,void 0,void 0,(function*(){if(\"gzip\"===e)(0,u.unzip)(t).copy(i);else if(\"bzip2\"===e){const e=l.default.array(t);let n,r=l.default.header(e),o=0;do{n=l.default.decompress(e,r),-1!==n&&(s.Buffer.from(n).copy(i,o),o+=n.length,r-=n.length)}while(-1!==n)}else if(\"lzma\"===e){const e=new Response(new h.XzReadableStream((n=t,new ReadableStream({start(e){e.enqueue(n),e.close()}}))));s.Buffer.from(yield e.arrayBuffer()).copy(i)}else if(\"rans\"===e)(0,f.default)(t,i);else if(\"rans4x16\"===e)c.default.r4x16_uncompress(t,i);else if(\"arith\"===e)c.default.arith_uncompress(t,i);else if(\"fqzcomp\"===e)c.default.fqzcomp_uncompress(t,i);else{if(\"tok3\"!==e)throw new d.CramUnimplementedError(`${e} decompression not yet implemented`);c.default.tok3_uncompress(t,i)}var n}))}readBlock(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t),n=yield this.readBlockHeader(e);if(void 0===n)return;const r=n._endPosition,o=s.Buffer.allocUnsafe(n.uncompressedSize),a=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:o});if(\"raw\"!==n.compressionMethod){const e=s.Buffer.allocUnsafe(n.compressedSize);yield this.read(e,0,n.compressedSize,r),yield this._uncompress(n.compressionMethod,e,o)}else yield this.read(o,0,n.uncompressedSize,r);if(t>=3){const t=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===t)return;a.crc32=t.crc32,this.validateChecksums&&(yield this.checkCrc32(e,n._size+n.compressedSize,t.crc32,\"block data\")),a._endPosition=t._endPosition,a._size=a.compressedSize+i.cramBlockCrc32.maxLength}else a._endPosition=r+a.compressedSize,a._size=a.compressedSize;return a}))}}t.default=F,\"getDefinition getSectionParsers getSamHeader\".split(\" \").forEach((e=>{(0,w.tinyMemoize)(F,e)}))},7390:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=t.CramRecord=void 0;var r=i(8401);Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return n(r).default}});var s=i(6794);Object.defineProperty(t,\"default\",{enumerable:!0,get:function(){return n(s).default}})},8401:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.MateFlagsDecoder=t.CramFlagsDecoder=t.BamFlagsDecoder=t.MateFlags=t.CramFlags=t.BamFlags=void 0;const r=n(i(7295)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(e){const t={};for(const[i,n]of e)t[`is${n}`]=e=>!!(e&i),t[`set${n}`]=e=>e|i;return t}t.BamFlags=[[1,\"Paired\"],[2,\"ProperlyPaired\"],[4,\"SegmentUnmapped\"],[8,\"MateUnmapped\"],[16,\"ReverseComplemented\"],[32,\"MateReverseComplemented\"],[64,\"Read1\"],[128,\"Read2\"],[256,\"Secondary\"],[512,\"FailedQc\"],[1024,\"Duplicate\"],[2048,\"Supplementary\"]],t.CramFlags=[[1,\"PreservingQualityScores\"],[2,\"Detached\"],[4,\"WithMateDownstream\"],[8,\"DecodeSequenceAsStar\"]],t.MateFlags=[[1,\"OnNegativeStrand\"],[2,\"Unmapped\"]],t.BamFlagsDecoder=o(t.BamFlags),t.CramFlagsDecoder=o(t.CramFlags),t.MateFlagsDecoder=o(t.MateFlags),t.default=class{constructor({flags:e,cramFlags:t,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:c,mateToUse:l,readGroupId:h,readName:d,sequenceId:u,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=e,this.cramFlags=t,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=h,this.readName=d,this.sequenceId=u,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,c&&(this.readFeatures=c),l&&(this.mate={flags:l.mateFlags,readName:l.mateReadName,sequenceId:l.mateSequenceId,alignmentStart:l.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const e=function(e,t){if(!e.lengthOnRef&&!e.readLength)return null;if(e.isUnknownBases())return null;const i=e.alignmentStart-t.start;if(!e.readFeatures)return t.seq.slice(i,i+(e.lengthOnRef||0)).toUpperCase();let n=\"\",r=i,s=0;for(;n.lengththis.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=e,r[1]=i,r[2]=t,r[3]=n):(r[2]=e,r[3]=i,r[0]=t,r[1]=n),r.join(\"\")}return null}addReferenceSequence(e,t){this.readFeatures&&this.readFeatures.forEach((i=>{\"X\"===i.code&&function(e,t,i,n){const r=n.refPos-t.start,o=t.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const c=i.substitutionMatrix[a][n.data];c&&(n.sub=c)}(0,e,t,i)})),!this.readBases&&e.start<=this.alignmentStart&&e.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=e)}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.startsWith(\"_\")||(e[t]=this[t])})),e.readBases=this.getReadBases(),e}}},3165:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.cramFileDefinition=r,t.cramBlockHeader=s,t.cramBlockCrc32=o,t.cramTagDictionary=c,t.cramPreservationMap=l,t.isMappedSliceHeader=function(e){return\"number\"==typeof e.refSeqId},t.getSectionParsers=function(e){return{cramFileDefinition:r(),cramBlockHeader:s(),cramBlockCrc32:o(),cramDataSeriesEncodingMap:p(),cramTagEncodingMap:g(),cramCompressionHeader:{parser:(e,t)=>{const{value:i,offset:n}=l().parser(e,t);t=n;const{value:r,offset:s}=p().parser(e,t);t=s;const{value:o,offset:a}=g().parser(e,t);return t=a,{value:{dataSeriesEncoding:h(r),preservation:h(i),tagEncoding:h(o)},offset:t}}},cramEncoding:{parser:(e,t)=>f(e,t)},cramUnmappedSliceHeader:d(e),cramMappedSliceHeader:u(e),cramContainerHeader1:m(e),cramContainerHeader2:w(e)}};const n=i(400);function r(){return{parser:(e,t=0)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length);let r=0;const s=e.subarray(r,r+4).toString();r+=4;const o=n.getUint8(r);r+=1;const a=n.getUint8(r);r+=1;const c=i.subarray(r,r+20).toString().replaceAll(\"\\0\",\"\");return r+=20,{value:{magic:s,majorVersion:o,minorVersion:a,fileId:c},offset:r}},maxLength:26}}function s(){return{parser:(e,t=0)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length);let s=0;const o=r.getUint8(s),a=[\"raw\",\"gzip\",\"bzip2\",\"lzma\",\"rans\",\"rans4x16\",\"arith\",\"fqzcomp\",\"tok3\"][o];if(!a)throw new Error(`compression method number ${o} not implemented`);s+=1;const c=r.getUint8(s),l=[\"FILE_HEADER\",\"COMPRESSION_HEADER\",\"MAPPED_SLICE_HEADER\",\"UNMAPPED_SLICE_HEADER\",\"EXTERNAL_DATA\",\"CORE_DATA\"][c];if(!l)throw new Error(`invalid block content type id ${c}`);s+=1;const[h,d]=(0,n.parseItf8)(e,s);s+=d;const[u,f]=(0,n.parseItf8)(e,s);s+=f;const[p,g]=(0,n.parseItf8)(e,s);return s+=g,{offset:s,value:{uncompressedSize:p,compressedSize:u,contentId:h,contentType:l,compressionMethod:a}}},maxLength:17}}function o(){return{parser:(e,t)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length).getUint32(t,!0);return{offset:t+=4,value:{crc32:n}}},maxLength:4}}function a(e,t,i){const n=e.toString(\"utf8\",t,i),r=[];for(let e=0;e{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const s=e.subarray(t,t+i);t+=i;const o=[];let c=0,l=0;for(;lc&&o.push(a(s,c,l)),{value:{size:i,ents:o},offset:t}}}}function l(){return{parser:(e,t)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,l]=(0,n.parseItf8)(e,t);t+=l;const h=[];for(let i=0;i{const[r,s]=(0,n.parseItf8)(t,i);i+=s;let o=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,o=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,o=e}else console.warn(\"recordCounter=0\");const[a,c]=(0,n.parseItf8)(t,i);i+=c;const[l,h]=(0,n.parseItf8)(t,i);i+=h;const d=[];for(let e=0;e=2&&(u=[...t.subarray(i,i+16)],i+=16),{value:{recordCounter:o,md5:u,contentIds:d,numContentIds:l,numBlocks:a,numRecords:r},offset:i}},maxLength:e=>40+5*e}}function u(e){return{parser:(t,i)=>{const[r,s]=(0,n.parseItf8)(t,i);i+=s;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;let u=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,u=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,u=e}else console.warn(\"majorVersion is <2, recordCounter set to 0\");const[f,p]=(0,n.parseItf8)(t,i);i+=p;const[g,m]=(0,n.parseItf8)(t,i);i+=m;const w=[];for(let e=0;e=2&&(v=[...t.subarray(i,i+16)],i+=16),{value:{md5:v,numBlocks:f,numRecords:h,numContentIds:g,refSeqSpan:c,refSeqId:r,refSeqStart:o,recordCounter:u,refBaseBlockId:b,contentIds:w},offset:i}},maxLength:e=>60+5*e}}function f(e,t){const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,c]=(0,n.parseItf8)(e,t);t+=c;const l={};if(0===s);else if(1===s){const[i,r]=(0,n.parseItf8)(e,t);l.blockContentId=i,t+=r}else if(2===s){const[i,r]=(0,n.parseItf8)(e,t);l.offset=i,t+=r;const[s,o]=(0,n.parseItf8)(e,t);l.M=s,t+=o}else if(3===s){const i=(0,n.parseItf8)(e,t),r=i[0];t+=i[1];const s=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(255&i),{value:o,offset:c}=f(e,t);t=c,a.push({key:s,value:o})}return{value:{mapSize:i,ents:a,mapCount:s},offset:t}}}}function m(e){return{maxLength:52,parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length).getInt32(i,!0);i+=4;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;const[u,f]=(0,n.parseItf8)(t,i);i+=f;let p,g=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);g=e,i+=r}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);g=e,i+=r}else console.warn(\"setting recordCounter=0\");if(e>1){const[e,r]=(0,n.parseLtf8)(t,i);p=e,i+=r}const[m,w]=(0,n.parseItf8)(t,i);i+=w;const[b,F]=(0,n.parseItf8)(t,i);return{value:{length:s,refSeqId:o,refSeqStart:c,alignmentSpan:h,numBlocks:m,numLandmarks:b,numBases:p,recordCounter:g,numRecords:u},offset:i+=F}}}}function w(e){return{parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length),[o,a]=(0,n.parseItf8)(t,i);i+=a;const c=[];for(let e=0;e=3&&(l=s.getUint32(i,!0),i+=4),{value:Object.assign(Object.assign({},void 0===l?{}:{crc32:l}),{numLandmarks:o,landmarks:c}),offset:i}},maxLength:e=>5+5*e+4}}},6484:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,c,l,h,d,u,f){let p=t(\"BF\");const g=t(\"CF\");if(!(0,s.isMappedSliceHeader)(c.parsedContent))throw new Error(\"slice header not mapped\");const m=u>1&&-2===c.parsedContent.refSeqId?t(\"RI\"):c.parsedContent.refSeqId,w=t(\"RL\");let b=t(\"AP\");i.APdelta&&(b+=d.lastAlignmentStart),d.lastAlignmentStart=b;const F=t(\"RG\");let v,y,A,C;if(i.readNamesIncluded&&(v=o(t(\"RN\"))),r.CramFlagsDecoder.isDetached(g)){const e=t(\"MF\");let n;i.readNamesIncluded||(n=o(t(\"RN\")),v=n);const s=t(\"NS\"),a=t(\"NP\");(e||s>-1)&&(y={mateFlags:e,mateSequenceId:s,mateAlignmentStart:a,mateReadName:n}),A=t(\"TS\"),r.MateFlagsDecoder.isUnmapped(e)&&(p=r.BamFlagsDecoder.setMateUnmapped(p)),r.MateFlagsDecoder.isOnNegativeStrand(e)&&(p=r.BamFlagsDecoder.setMateReverseComplemented(p))}else r.CramFlagsDecoder.isWithMateDownstream(g)&&(C=t(\"NF\")+f+1);const _=t(\"TL\");if(_<0)throw new n.CramMalformedError(\"invalid TL index\");const x={},k=i.getTagNames(_),I=k.length;for(let t=0;t1?\"SC\":\"IN\"],X:[\"number\",\"BS\"],D:[\"number\",\"DL\"],I:[\"string\",\"IN\"],i:[\"character\",\"BA\"],b:[\"string\",\"BB\"],q:[\"numArray\",\"QQ\"],Q:[\"number\",\"QS\"],H:[\"number\",\"HC\"],P:[\"number\",\"PD\"],N:[\"number\",\"RS\"]}[t];if(!h)throw new n.CramMalformedError(`invalid read feature code \"${t}\"`);let d=l(h);const u={B:[\"number\",\"QS\"]}[t];u&&(d=[d,l(u)]),o+=r;const f=o;a+=r;const p=a;\"D\"===t||\"N\"===t?a+=d:\"I\"===t||\"S\"===t?a-=d.length:\"i\"===t&&(a-=1),c[e]={code:t,pos:f,refPos:p,data:d}}return c}(b,e,t,0,u)),E=w,S)for(const{code:e,data:t}of S)\"D\"===e||\"N\"===e?E+=t:\"I\"===e||\"S\"===e?E-=t.length:\"i\"===e&&(E-=1);if(Number.isNaN(E)&&(console.warn(`${v||`${m}:${b}`} record has invalid read features`),E=w),N=t(\"MQ\"),r.CramFlagsDecoder.isPreservingQualityScores(g)){B=new Array(w);for(let e=0;e=0){const r=e[i.mateRecordNumber];if(!r)throw new s.CramMalformedError(\"intra-slice mate record not found, this file seems malformed\");n.push(...t(r))}return n}(i),r=n.map((e=>e.alignmentStart)),o=n.map((e=>e.alignmentStart+e.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((e=>{if(void 0!==e.templateLength)throw new s.CramMalformedError(\"mate pair group has some members that have template lengths already, this file seems malformed\");e.templateLength=a}))}(e,0,i):function(e,t){const i=Math.min(e.alignmentStart,t.alignmentStart),n=Math.max(e.alignmentStart+e.readLength-1,t.alignmentStart+t.readLength-1)-i+1;e.templateLength=n,t.templateLength=n}(i,n)),i.mateRecordNumber=void 0}class f{constructor(e,t,i){this.container=e,this.containerPosition=t,this.sliceSize=i,this.file=e.file}getHeader(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.file.getDefinition(),t=(0,h.getSectionParsers)(e),i=yield this.container.getHeader();if(!i)throw new Error(\"no container header detected\");const n=yield this.file.readBlock(i._endPosition+this.containerPosition);if(void 0===n)throw new Error(\"block header undefined\");if(\"MAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramMappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}if(\"UNMAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramUnmappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${n.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();let t=e._endPosition;const i=new Array(e.parsedContent.numBlocks);for(let e=0;e{\"EXTERNAL_DATA\"===e.contentType&&(t[e.contentId]=e)})),t}))}getBlockByContentId(e){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[e]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const e=(yield this.getHeader()).parsedContent;if(!(0,h.isMappedSliceHeader)(e))throw new Error(\"slice header not mapped\");if(e.refSeqId<0)return;const t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error(\"compression scheme undefined\");if(e.refBaseBlockId>=0){const t=yield this.getBlockByContentId(e.refBaseBlockId);if(!t)throw new s.CramMalformedError(\"embedded reference specified, but reference block does not exist\");return{seq:t.data.toString(\"utf8\"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}if(t.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error(\"reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence\");const t=yield this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);if(t.length!==e.refSeqSpan)throw new s.CramArgumentError(\"seqFetch callback returned a reference sequence of the wrong length\");return{seq:t,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){var e,t;const{majorVersion:i}=yield this.file.getDefinition(),n=yield this.container.getCompressionScheme();if(void 0===n)throw new Error(\"compression scheme undefined\");const r=yield this.getHeader(),a=yield this._getBlocksContentIdIndex();if(i>1&&this.file.options.checkSequenceMD5&&(0,h.isMappedSliceHeader)(r.parsedContent)&&r.parsedContent.refSeqId>=0&&\"0000000000000000\"!==(null===(e=r.parsedContent.md5)||void 0===e?void 0:e.join(\"\"))){const e=yield this.getReferenceRegion();if(e){const{seq:i,start:n,end:a}=e,c=(0,o.sequenceMD5)(i),l=null===(t=r.parsedContent.md5)||void 0===t?void 0:t.map((e=>(e<16?\"0\":\"\")+e.toString(16))).join(\"\");if(c!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${r.parsedContent.refSeqId} pos ${n}..${a}. recorded MD5: ${l}, calculated MD5: ${c}`)}}const f=yield this.getCoreDataBlock(),p={lastAlignmentStart:(0,h.isMappedSliceHeader)(r.parsedContent)?r.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(e){let t=this.map.get(e);return void 0===t&&(t={bitPosition:7,bytePosition:0},this.map.set(e,t)),t}}},g=e=>{const t=n.getCodecForDataSeries(e);if(!t)throw new s.CramMalformedError(`no codec defined for ${e} data series`);return t.decode(this,f,a,p)},m=new Array(r.parsedContent.numRecords);for(let t=0;t=0&&u(m,e,m[e],m[t])}return m}))}getRecords(e){return n(this,void 0,void 0,(function*(){const t=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(t.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(t.toString(),i));const r=(yield i).filter(e);if(r.length&&this.file.fetchReferenceSequenceCallback){const e=yield this.getHeader();if((0,h.isMappedSliceHeader)(e.parsedContent)&&(e.parsedContent.refSeqId>=0||-2===e.parsedContent.refSeqId)){const t=e.parsedContent.refSeqId>=0?e.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error(\"compression scheme undefined\");const s={};for(const e of r){const i=void 0!==t?t:e.sequenceId;let n=s[i];n||(n={id:i,start:e.alignmentStart,end:Number.NEGATIVE_INFINITY,seq:null},s[i]=n);const r=e.alignmentStart+(e.lengthOnRef||e.readLength)-1;r>n.end&&(n.end=r),e.alignmentStartn(this,void 0,void 0,(function*(){-1!==e.id&&e.start<=e.end&&this.file.fetchReferenceSequenceCallback&&(e.seq=yield this.file.fetchReferenceSequenceCallback(e.id,e.start,e.end))})))));for(const e of r){const n=s[void 0!==t?t:e.sequenceId];if(null==n?void 0:n.seq){const t=n.seq;e.addReferenceSequence(Object.assign(Object.assign({},n),{seq:t}),i)}}}}return r}))}}t.default=f,\"getHeader getBlocks _getBlocksContentIdIndex\".split(\" \").forEach((e=>{(0,o.tinyMemoize)(f,e)}))},400:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.itf8Size=function(e){return-128&e?-16384&e?-2097152&e?-268435456&e?5:4:3:2:1},t.parseItf8=function(e,t){let i=t;const n=e[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|e[i+1]),i+=2):n<224?(r=2097151&(n<<16|e[i+1]<<8|e[i+2]),i+=3):n<240?(r=268435455&(n<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4):(r=(15&n)<<28|e[i+1]<<20|e[i+2]<<12|e[i+3]<<4|15&e[i+4],i+=5),i>e.length)throw new o.CramBufferOverrunError(\"Attempted to read beyond end of buffer; this file seems truncated.\");return[r,i-t]},t.parseLtf8=function(e,t){let i=t;const n=e[i];let r;if(n<128)r=n,i+=1;else if(n<192)r=16383&(e[i]<<8|e[i+1]),i+=2;else if(n<224)r=2097151&(e[i]<<16|e[i+1]<<8|e[i+2]),r=(63&n)<<16|e.readUInt16LE(i+1),i+=3;else if(n<240)r=268435455&(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4;else if(n<248)r=(15&e[i])*Math.pow(2,32)+(e[i+1]<<24)|e[i+2]<<16|e[i+3]<<8|e[i+4],i+=5;else if(n<252)r=((7&e[i])<<8|e[i+1])*Math.pow(2,32)+(e[i+2]<<24)|e[i+3]<<16|e[i+4]<<8|e[i+5],i+=6;else if(n<254)r=((3&e[i])<<16|e[i+1]<<8|e[i+2])*Math.pow(2,32)+(e[i+3]<<24)|e[i+4]<<16|e[i+5]<<8|e[i+6],i+=7;else if(n<255){if(r=s.default.fromBytesBE(e.slice(i+1,i+8)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=8}else{if(r=s.default.fromBytesBE(e.slice(i+1,i+9)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=9}return[r,i-t]},t.parseItem=function(e,t,i=0,n=0){const{offset:r,value:s}=t(e,i);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},t.tinyMemoize=function(e,t){const i=e.prototype[t],n=`_memo_${t}`;e.prototype[t]=function(){if(!(n in this)){const e=i.call(this);this[n]=e,Promise.resolve(e).catch((()=>{delete this[n]}))}return this[n]}},t.sequenceMD5=function(e){return(0,r.default)(e.toUpperCase().replaceAll(/[^\\u0021-\\u007e]/g,\"\"))};const r=n(i(3503)),s=n(i(8570)),o=i(612)},9747:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramArgumentError=t.CramSizeLimitError=t.CramMalformedError=t.CramUnimplementedError=t.CramError=void 0;class i extends Error{}t.CramError=i;class n extends Error{}t.CramUnimplementedError=n,t.CramMalformedError=class extends i{},t.CramSizeLimitError=class extends i{},t.CramArgumentError=class extends i{}},7806:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.IndexedCramFile=t.CraiIndex=t.CramRecord=t.CramFile=void 0;var r=i(7390);Object.defineProperty(t,\"CramFile\",{enumerable:!0,get:function(){return n(r).default}}),Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return r.CramRecord}});var s=i(4923);Object.defineProperty(t,\"CraiIndex\",{enumerable:!0,get:function(){return n(s).default}});var o=i(6014);Object.defineProperty(t,\"IndexedCramFile\",{enumerable:!0,get:function(){return n(o).default}})},6014:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(9747),o=r(i(7390));t.default=class{constructor(e){var t;if(this.cram=null!==(t=e.cram)&&void 0!==t?t:new o.default({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof o.default))throw new Error(\"invalid arguments: no cramfile\");this.index=e.index}getRecordsForRange(e,t,i){return n(this,arguments,void 0,(function*(e,t,i,n={}){if(n.viewAsPairs=n.viewAsPairs||!1,n.pairAcrossChr=n.pairAcrossChr||!1,n.maxInsertSize=n.maxInsertSize||2e5,\"string\"==typeof e)throw new s.CramUnimplementedError(\"string sequence names not yet supported\");const r=e,o=yield this.index.getEntriesForRange(r,t,i),a=n=>n.sequenceId===e&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=t,c=yield Promise.all(o.map((e=>this.getRecordsInSlice(e,a))));let l=Array.prototype.concat(...c);if(n.viewAsPairs){const e={},t={};for(const i of l){const n=i.readName;if(void 0===n)throw new Error(\"readName undefined\");const r=i.uniqueId;e[n]||(e[n]=0),e[n]+=1,t[r]=1}const i={};Object.entries(e).forEach((([e,t])=>{1===t&&(i[e]=!0)}));const s=[];for(const e of l){const t=e.readName;if(void 0===t)throw new Error(\"readName undefined\");if(i[t]&&e.mate&&(e.mate.sequenceId===r||n.pairAcrossChr)&&Math.abs(e.alignmentStart-e.mate.alignmentStart)e.toString().localeCompare(t.toString()))).filter(((e,t,i)=>!t||e.toString()!==i[t-1].toString()));const c=[];for(const e of a){let n=this.cram.featureCache.get(e.toString());n||(n=this.getRecordsInSlice(e,(()=>!0)),this.cram.featureCache.set(e.toString(),n));const r=n.then((e=>{const n=[];for(const r of e){if(void 0===r.readName)throw new Error(\"readName undefined\");i[r.readName]&&!t[r.uniqueId]&&n.push(r)}return n}));c.push(r)}const h=yield Promise.all(c);if(h.length){const e=h.reduce(((e,t)=>e.concat(t)));l=l.concat(e)}}return l}))}getRecordsInSlice({containerStart:e,sliceStart:t,sliceBytes:i},n){return this.cram.getContainerAtPosition(e).getSlice(t,i).getRecords(n)}hasDataForReferenceSequence(e){return this.index.hasDataForReferenceSequence(e)}}},5931:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RemoteFile=t.LocalFile=void 0,t.open=function(e,t,i){if(i)return i;if(e)return new n.RemoteFile(e);if(t)return new n.LocalFile(t);throw new Error(\"no url, path, or filehandle provided, cannot open\")};const n=i(1113);var r=i(1113);Object.defineProperty(t,\"LocalFile\",{enumerable:!0,get:function(){return r.LocalFile}}),Object.defineProperty(t,\"RemoteFile\",{enumerable:!0,get:function(){return r.RemoteFile}})},6476:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RANS_BYTE_L=t.TOTFREQ=t.TF_SHIFT=void 0,t.TF_SHIFT=12,t.TOTFREQ=4096,t.RANS_BYTE_L=1<<23},997:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,n){let a=e.getInt(),c=e.getInt(),l=e.getInt(),h=e.getInt();const d=n.remaining(),u=-4&d;for(let r=0;r>2;let u=0,f=d,p=2*d,g=3*d,m=0,w=0,b=0,F=0;for(;u{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(9747),r=i(6476);class s{constructor(){this.F=void 0,this.C=void 0}}function o(e,t,i,n){return i*(e>>n)+(e&(1<>s)+(e&(1<=128&&(t.fc[c].F&=-129,t.fc[c].F=(127&t.fc[c].F)<<8|255&e.get()),t.fc[c].C=r,o.default.symbolInit(i[c],t.fc[c].C,t.fc[c].F),t.R||(t.R=new Array(s.TOTFREQ)),t.R.fill(c,r,r+t.fc[c].F),r+=t.fc[c].F,0===n&&c+1===(255&e.getByteAt(e.position()))?(c=255&e.get(),n=255&e.get()):0!==n?(n-=1,c+=1):c=255&e.get()}while(0!==c);a(r=128&&(t[r].fc[h].F&=-129,t[r].fc[h].F=(127&t[r].fc[h].F)<<8|255&e.get()),t[r].fc[h].C=l,0===t[r].fc[h].F&&(t[r].fc[h].F=s.TOTFREQ),null==i[r][h]&&(i[r][h]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][h],t[r].fc[h].C,t[r].fc[h].F),null==t[r].R&&(t[r].R=new Array(s.TOTFREQ)),t[r].R.fill(h,l,l+t[r].fc[h].F),l+=t[r].fc[h].F,a(l<=s.TOTFREQ),0===c&&h+1===(255&e.getByteAt(e.position()))?(h=255&e.get(),c=255&e.get()):0!==c?(c-=1,h+=1):h=255&e.get()}while(0!==h);0===n&&r+1===(255&e.getByteAt(e.position()))?(r=255&e.get(),n=255&e.get()):0!==n?(n-=1,r+=1):r=255&e.get()}while(0!==r)};const r=i(9747),s=i(6476),o=n(i(488));function a(e){if(!e)throw new r.CramMalformedError(\"assertion failed\")}},9989:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i=0){if(0===e.length)return t.fill(0),t;const n=new d(e,i),u=n.get();if(0!==u&&1!==u)throw new s.CramMalformedError(`Invalid rANS order ${u}`);if(n.getInt()!==n.remaining()-h)throw new s.CramMalformedError(\"Incorrect input length.\");const f=n.getInt(),p=new d(t||r.Buffer.allocUnsafe(f));if(p.length{Object.defineProperty(t,\"__esModule\",{value:!0}),t.parseHeaderText=function(e){const t=e.split(/\\r?\\n/),i=[];for(const e of t){const[t,...n]=e.split(/\\t/);t&&i.push({tag:t.slice(1),data:n.map((e=>{const t=e.indexOf(\":\");return-1!==t?{tag:e.slice(0,t),value:e.slice(t+1)}:{tag:e,value:\"\"}}))})}return i}},8712:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.unzip=function(e){return r.Buffer.from((0,n.inflate)(e))};const n=i(1668),r=i(8287)},635:(e,t,i)=>{var n=i(8287).Buffer;const r=i(4646),s=i(8706),o=i(9614),a=i(235),c=128;e.exports=class{decode(e){return this.stream=new s(e),this.decodeStream(this.stream)}decodeStream(e,t=0){var i=this.stream.ReadByte();16&i||(t=this.stream.ReadUint7());var n,r=t,s=1&i;if(8&i)return this.decodeStripe(this.stream,t);if(i&c&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&c&&(o=this.decodePack(o,n,t)),o}encode(e,t){if(this.stream=new s(\"\",0,1.1*e.length+100),this.stream.WriteByte(t),16&t||this.stream.WriteUint7(e.length),8&t)return n.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,e,t>>8)]);var i,r=1&t,o=e.length;return t&c&&([i,e,o]=this.encodePack(e)),t&c&&this.stream.WriteStream(i),64&t?r?this.encodeRLE1(e,o,this.stream):this.encodeRLE0(e,o,this.stream):r?this.encode1(e,o,this.stream):this.encode0(e,o,this.stream)}decode0(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);var a=new o(s),c=new r(e);c.RangeStartDecode(e);for(var l=0;l=3?3:h;for(c[d].ModelEncode(i,l,u),h-=u,d=256;3==u;)u=h>=3?3:h,c[d].ModelEncode(i,l,u),d=257,h-=u}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);for(var a=new Array(s),c=0;c=3?3:d;for(c[u].ModelEncode(i,l,f),d-=f,u=256;3==f;)f=d>=3?3:d,c[u].ModelEncode(i,l,f),u=257,d-=f}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(e){this.nsym=e.ReadByte();for(var t=new Array(this.nsym),i=0;i>=1}}else if(this.nsym<=4)for(s=0,o=0;s>=2;else{if(!(this.nsym<=16))return e;for(s=0,o=0;s>=4}return r}packMeta(e){for(var t=new s(\"\",0,1024),i=new Array(256),n=0;no),n[o]=new Array(r[o]);for(var a=0,c=0;co),a[o]=this.decodeStream(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o{e.exports=class{constructor(e){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(e){for(var t=0;t<5;t++)this.code=(this.code<<8)+e.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(e){return this.range=Math.floor(this.range/e),Math.floor(this.code/this.range)}RangeDecode(e,t,i,n){for(this.code-=t*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+e.ReadByte()}RangeShiftLow(e){if(this.low<4278190080|this.carry){for(e.WriteByte(this.cache+this.carry);this.FFnum;)e.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(e,t,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=t*this.range,this.low>>>=0,this.range*=i,this.low{e.exports=class{constructor(e=256){this.total_freq=e,this.max_sym=e-1,this.S=new Array,this.F=new Array;for(var t=0;t<=this.max_sym;t++)this.S[t]=t,this.F[t]=1}ModelDecode(e,t){for(var i=t.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];t.RangeDecode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var e=0;e<=this.max_sym;e++)this.F[e]-=Math.floor(this.F[e]/2),this.total_freq+=this.F[e]}ModelEncode(e,t,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(t.RangeEncode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},6038:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(9614),o=i(4646);function a(e,t,i){for(var n=0,r=0,s=-1,o=new Array(1024);r>4,t.qshift=15&i,i=e.ReadByte(),t.qloc=i>>4,t.sloc=15&i,i=e.ReadByte(),t.ploc=i>>4,t.dloc=15&i,t.qmap=new Array(256),16&t.pflags)for(var n=0;n0&&128&t.pflags)a(e,t.qtab,256);else for(n=0;n<256;n++)t.qtab[n]=n;return t.ptab=new Array(1024),32&t.pflags&&a(e,t.ptab,1024),t.dtab=new Array(256),64&t.pflags&&a(e,t.dtab,256),t}function h(e,t,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(e,t):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(e,t);a|=n.len[1].ModelDecode(e,t)<<8,a|=n.len[2].ModelDecode(e,t)<<16,a|=n.len[3].ModelDecode(e,t)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(e,t)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(e,t)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function d(e,t,i){for(var n=0,r=0,s=new Array(2*i),o=0;n1?i.nparam-1:0,s=new Array(256);if(2&i)r=e.ReadByte(),a(e,s,256);else{for(var o=0;o0&&(t.sel=new s(e.max_sel+1)),t}(r),p=new o(e);p.RangeStartDecode(e);for(var g=new n.allocUnsafe(i),m={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},w=0;w0&&f.dup.ModelDecode(e,p)){for(var b=0;b4),qshift:d,qloc:7,pbits:7,pshift:t[0]>128?1:0,ploc:0,dbits:d>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:c,nsym:a,do_qmap:u,do_dedup:0,fixed_len:1==t.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:d<=4?1:0,do_qtab:0,qbits:8+(d>4)-(0==o),sbits:1,sloc:15-(d<=4),do_stab:1,do_sel:1}]}(e,t,i,n),p=function(e,t,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],c=0;c1?1:0)|(t[0].do_stab?2:0);if(e.WriteByte(l),1&l&&e.WriteByte(t.length),2&l){var h=1<0&&h--,e.WriteByte(h),d(e,o,256)}for(var u=0;u0){for(c=0;c<256;c++)n[u][c]=c;t[u].do_qtab&&d(e,n[u],256)}if(t[u].pbits>0){for(c=0;c<1024;c++)r[u][c]=Math.min((1<>t[u].pshift);d(e,r[u],1024)}if(t[u].dbits>0){for(c=0;c<256;c++)a[c]>(1<>t[u].dshift)];d(e,s[u],256)}}return e}(p,f,n,a,c,l,h);return function(e,t,i,n,r,a,c,l,h,d){var u=1<0&&u--;for(var f=t.length,p=0,g=0;g0&&F.ModelEncode(e,v,A);var C=d[A],_=i[Math.min(i.length-1,y++)];r[C].fixed_len?r[C].fixed_len>0&&(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255),r[C].fixed_len=-1):(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255)),r[C].do_dedup&&process.exit(1),g=_;var x=0,k=r[C].context,I=0,S=0}var E=t[w++],N=a[C][E];m[k].ModelEncode(e,v,N),I=(I<0&&(k+=l[C][Math.min(g,1023)]<0&&(k+=h[C][Math.min(x,255)]<{var n=i(8287).Buffer,r=i(5460),s=i(8223),o=i(635),a=i(6038),c=i(5997);e.exports={r4x8_uncompress:function(e,t){r.decode(e).copy(t,0,0)},r4x16_uncompress:function(e,t){s.decode(e).copy(t,0,0)},arith_uncompress:function(e,t){o.decode(e).copy(t,0,0)},fqzcomp_uncompress:function(e,t){var i=new Array;a.decode(e,i).copy(t,0,0)},tok3_uncompress:function(e,t){var i=c.decode(e,0,\"\\0\");n.from(i,\"binary\").copy(t,0,0)}}},8706:(e,t,i)=>{var n=i(8287).Buffer;e.exports=class{constructor(e,t=0,i=0){0!=i?(this.buf=n.allocUnsafe(i),this.length=i):(this.buf=e,this.length=e.length),this.pos=t}EOF(){return this.pos>=this.length}ReadData(e){var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}ReadByte(){const e=this.buf[this.pos];return this.pos++,e}ReadChar(){const e=this.buf[this.pos];return this.pos++,String.fromCharCode(e)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const e=this.buf.readInt32LE(this.pos);return this.pos+=4,e}ReadString(){var e=\"\";do{var t=this.buf[this.pos++];t&&(e+=String.fromCharCode(t))}while(t);return e}ReadUint7(){var e=0;do{var t=this.ReadByte();e=e<<7|127&t}while(128&t);return e}ReadITF8(){var e=this.buf[this.pos];return this.pos++,e>=240?(e=(15&e)<<28,e+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):e>=224?(e=(15&e)<<24,e+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(0|this.buf[this.pos+2]),this.pos+=3):e>=192?(e=(31&e)<<16,e+=(this.buf[this.pos+0]<<8)+(0|this.buf[this.pos+1]),this.pos+=2):e>=128&&(e=(63&e)<<8,e+=this.buf[this.pos],this.pos++),e}WriteByte(e){this.buf[this.pos++]=e}WriteChar(e){this.buf[this.pos++]=e.charCodeAt(0)}WriteString(e){for(var t=0;t>8&255)}WriteUint32(e){this.buf.writeInt32LE(e,this.pos),this.pos+=4}WriteUint7(e){var t=0,i=e;do{t+=7,i>>=7}while(i>0);do{t-=7,this.WriteByte((e>>t&127)+((t>0)<<7))}while(t>0)}WriteITF8(e){e<0&&(e=1+e),e<=127?this.buf[this.pos++]=e:e<=16383?(this.buf[this.pos++]=128|Math.floor(e/256),this.buf[this.pos++]=255&e):e<131071?(this.buf[this.pos++]=192|Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):e<268435455?(this.buf[this.pos++]=224|Math.floor(e/16777216),this.buf[this.pos++]=255&Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):(this.buf[this.pos++]=240|Math.floor(e/268435456),this.buf[this.pos++]=255&Math.floor(e/1048576),this.buf[this.pos++]=255&Math.floor(e/4096),this.buf[this.pos++]=255&Math.floor(e/4),this.buf[this.pos++]=15&e)}WriteByteNeg(e){this.buf[--this.pos]=e}}},5460:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e){return 4095&e}function o(e,t){for(var i=0;t>=e[i+1];)i++;return i}function a(e){for(var t=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=e[i+1];)i++;t[n]=i}return t}function c(e,t,i){return i*(e>>12)+(4095&e)-t}function l(e,t){for(;t<1<<23;)t=(t<<8)+e.ReadByte();return t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<23>>n<<8)*i;e>=r;)t.WriteByteNeg(255&e),e>>=8;return e}(e,t,n,r),(Math.floor(e/n)<0?(o--,r++):(r=e.ReadByte())==s+1&&(o=e.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}function f(e){for(var t=0,i=0;i<256;i++)t+=e[i];const n=4096;var r=n/t;do{var s=0,o=0,a=0;for(t=0,i=0;i<256;i++)0!=e[i]&&(s2?e[o]-=t-n:t!=n&&(r*=.99,a=1)}while(a)}function p(e,t){for(var i=0,n=0;n<256;n++)if(t[n]){if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteITF8(t[n])}e.WriteByte(0)}e.exports={decode:function(e){var t=new r(e),i=t.ReadByte(),h=(t.ReadUint32(),t.ReadUint32());return 0==i?function(e,t){var i=new Array(256),r=new Array(256);u(e,i,r);for(var o=a(r),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var f=new n.allocUnsafe(t);for(d=0;d0?(a--,s++):(s=e.ReadByte())==o+1&&(a=e.ReadByte()),o=s}while(0!=s)}(e,i,r);for(var h=new Array(256),d=0;d<256;d++)h[d]=a(r[d]);for(var f=new Array(4),p=new Array(4),g=0;g<4;g++)f[g]=e.ReadUint32(),p[g]=0;var m=new n.allocUnsafe(t),w=Math.floor(t/4);for(d=0;d=0;a--)c[a%4]=d(c[a%4],u,o[e[a]],s[e[a]],12);for(a=3;a>=0;a--)h(c[a],u);var g=i.pos;return i.buf.writeInt32LE(g-9+(u.length-u.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}(e):function(e){const t=e.length;var i=new r(\"\",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var s=new Array(256),o=new Array(256),a=new Array(256),c=0;c<256;c++)o[c]=new Array(256),a[c]=new Array(256);for(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3}(e,o,s),function(e,t){for(var i=0;i<256;i++)t[i]&&f(e[i])}(o,s),function(e,t,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(e.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,e.WriteByte(n)}p(e,t[r])}e.WriteByte(0)}(i,o,s),c=0;c<256;c++)if(s[c]){a[c][0]=0;for(var l=1;l<256;l++)a[c][l]=a[c][l-1]+o[c][l-1]}var u=new Array(4),g=new Array(4);for(l=0;l<4;l++)u[l]=1<<23,g[l]=0;var m=new r(\"\",t,t),w=Math.floor(t/4),b=new Array(4),F=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*w-2,F[l]=e[b[l]+1];for(F[3]=e[t-1],c=t-2;c>4*w-2;c--)u[3]=d(u[3],m,a[e[c]][F[3]],o[e[c]][F[3]],12),F[3]=e[c];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=e[b[l]];u[l]=d(u[l],m,a[v][F[l]],o[v][F[l]],12),F[l]=v,b[l]--}for(l=3;l>=0;l--)u[l]=d(u[l],m,a[0][F[l]],o[0][F[l]],12);for(c=3;c>=0;c--)h(u[c],m);var y=i.pos;return i.buf.writeInt32LE(y-9+(m.length-m.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e)}}},8223:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e,t){return e&(1<=e[i+1];)i++;return i}function a(e,t){for(var i=1<=e[r+1];)r++;n[s]=r}return n}function c(e,t,i,n){return i*(e>>n)+(e&(1<>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<31-n)*i;e>=r;)t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e),e>>=16;return e}(e,t,n,r),(Math.floor(e/n)<o),n[o]=new Array(s[o]);for(var a=0,c=0;co),a[o]=f(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o>4,h=e;if(1&f){var d=e.ReadUint7(),u=e.ReadUint7(),f=new r(e.ReadData(u));h=new r(m(f,d))}var p=new Array(256),w=new Array(256);!function(e,t,i,n){for(var r=0;r<256;r++){t[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)t[r][s]=0}var o=g(e);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(t[r][s]=e.ReadUint7(),0==t[r][s]&&(a=e.ReadByte())));for(b(t[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+t[r][s]}}(h,p,w,i);for(var F=new Array(256),v=0;v<256;v++)F[v]=a(w[v],i);for(var y=new Array(4),A=new Array(4),C=0;C<4;C++)y[C]=e.ReadUint32(),A[C]=0;var _=new n.allocUnsafe(t),x=Math.floor(t/4);for(v=0;v>=1}else if(i<=4)for(a=0;a>=2;else if(i<=16)for(a=0;a>=4;return s}(x,v,y,F)),x}function p(e,t){var i=new r(\"\",0,10);i.WriteByte(t);var s=1&t,o=8&t,a=32&t,c=64&t,l=128&t,f=t>>8;if(16&t||i.WriteUint7(e.length),o)return n.concat([i.buf.slice(0,i.pos),u(0,e,f)]);var p=new n.alloc(0);l&&([p,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;for(i=0;i0&&(s[i]=o++);if(!(o>16)){if(o<=1)var a=new n.allocUnsafe(0);else if(o<=2){a=new n.allocUnsafe(Math.ceil(e.length/8));var c=-1;for(i=0;i0&&(t[i]=c++,l.WriteByte(i));return l.WriteUint7(a.length),[l.buf.slice(0,l.pos),a]}}(e));var g=new n.alloc(0);if(c&&([g,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var s=-1;for(i=0;i0&&o++;for(o||(o=1,t[0]=1),(h=new r(\"\",0,o+1+e.length)).WriteByte(o),i=0;i<256;i++)t[i]>0&&h.WriteByte(i);var a=new n.allocUnsafe(e.length),c=0;for(i=0;i0){s=e[i];for(var l=0;i+l+1>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3})(e,o,s),function(e,t){for(var i=0;i<256;i++)if(t[i]){var n=Math.ceil(Math.log2(t[i]));n>12&&(n=12),w(e[i],n)}}(o,s);var l=new r(\"\",0,198156);!function(e,t,i){F(e,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(e.WriteUint7(t[n][s]),!t[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=t[n][o])break;r++}e.WriteByte(r)}}(l,o,s);var u=v(l.buf.slice(0,l.pos));for(u.length4*y-2;c--)p[3]=d(p[3],m,a[e[c]][C[3]],o[e[c]][C[3]],12),C[3]=e[c];for(;A[0]>=0;)for(f=3;f>=0;f--){var _=e[A[f]];p[f]=d(p[f],m,a[_][C[f]],o[_][C[f]],12),C[f]=_,A[f]--}for(f=3;f>=0;f--)p[f]=d(p[f],m,a[0][C[f]],o[0][C[f]],12);for(c=3;c>=0;c--)h(p[c],m);return n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e);return n.concat([i.buf.slice(0,i.pos),p,g,m])}function g(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var n=0,r=e.ReadByte(),s=r;do{t[r]=1,n>0?(n--,r++):(r=e.ReadByte())==s+1&&(n=e.ReadByte()),s=r}while(0!=r);return t}function m(e,t){var i=new Array(256),r=new Array(256);!function(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=g(e);for(n=0;n<256;n++)r[n]>0&&(t[n]=e.ReadUint7());for(b(t,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}(e,i,r);for(var o=a(r,12),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var u=new n.allocUnsafe(t);for(d=0;d2?e[a]-=i-r:i!=r&&(s=r/i,c=1)}while(c)}function b(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];if(0!=i&&i!=1<0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteByte(0)}function v(e){const t=e.length;var i=new r(\"\",0,780),s=new Array(256);!function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i12&&(o=12),w(s,o),function(e,t){F(e,t);for(var i=0;i<256;i++)t[i]&&e.WriteUint7(t[i])}(i,s),w(s,12);var a=new Array(256);a[0]=0;for(var c=1;c<256;c++)a[c]=a[c-1]+s[c-1];var l=new Array(4);for(c=0;c<4;c++)l[c]=32768;var u=new r(\"\",1.05*t+100|0,1.05*t+100|0);for(c=t-1;c>=0;c--)l[c%4]=d(l[c%4],u,a[e[c]],s[e[c]],12);for(c=3;c>=0;c--)h(l[c],u);return n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}e.exports={decode:function(e){return f(new r(e),0)},encode:p}},5997:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(8223);var o=new(i(635));function a(e,t){for(var i=e+\"\";i.length0&&5==t[o][0].type)&&t[o][i])switch(e[0].WriteByte(t[o][i].type),t[o][i].type){case 6:e[6].WriteUint32(t[o][i].val);break;case 5:e[5].WriteUint32(t[o][i].val);break;case 1:e[1].WriteString(t[o][i].val);break;case 2:e[2].WriteChar(t[o][i].val);break;case 7:e[7].WriteUint32(t[o][i].val);break;case 3:e[3].WriteUint32(t[o][i].val),e[4].WriteByte(t[o][i].val.length);break;case 8:case 9:e[t[o][i].type].WriteByte(t[o][i].val)}}function h(e,t,i,n){for(var r=0;r<=12;r++)if(!(e[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),e[r]=e[r].buf.slice(0,e[r].pos);var s=d(e[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function d(e,t){var i,n=1<<30,r=[0,1,64,65,128,129,201];for(var a in r){var c=r[a];if(!(1&c&&e.length<100||8&c&&e.length%4!=0)){try{var l=t?o.encode(e,c):s.encode(e,c)}catch(e){l=0}l&&n>l.length&&(n=l.length,i=l)}}return i}function u(e,t,i,n,r){var s=0,o=r-1;e[r]=new Array(256),t[n]?e[r][0]={type:5,val:r-t[n]}:e[r][0]={type:6,val:0==r?0:1},t[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),c=0;c=0&&e[o][l])if(e[o][l].str==a[c])h=10,d=\"\";else if(7==e[o][l].type||8==e[o][l].type){var u=d-e[o][l].str;i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=8,d=u)}else 3!=e[o][l].type&&9!=e[o][l].type||e[o][l].str.length!=d.length||(u=d-e[o][l].str,i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=9,d=u));e[r][l]={str:a[c],val:d,type:h},s{t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),o=s[0],c=s[1],l=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,c)),h=0,d=c>0?o-4:o;for(i=0;i>16&255,l[h++]=t>>8&255,l[h++]=255&t;return 2===c&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,l[h++]=255&t),1===c&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,l=n-r;al?l:a+o));return 1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+\"==\")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+\"=\")),s.join(\"\")};for(var i=[],n=[],r=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function c(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},8287:(e,t,i)=>{const n=i(7526),r=i(251),s=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return d(e)}return l(e,t,i)}function l(e,t,i){if(\"string\"==typeof e)return function(e,t){if(\"string\"==typeof t&&\"\"!==t||(t=\"utf8\"),!c.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|g(e,t);let n=a(i);const r=n.write(e,t);return r!==i&&(n=n.slice(0,r)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,i);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?\"number\"!=typeof e.length||Y(e.length)?a(0):u(e):\"Buffer\"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function h(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function d(e){return h(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),i=a(t);for(let n=0;n=o)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o.toString(16)+\" bytes\");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return W(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return G(e).length;default:if(r)return n?-1:W(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function m(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return N(this,t,i);case\"utf8\":case\"utf-8\":return k(this,t,i);case\"ascii\":return S(this,t,i);case\"latin1\":case\"binary\":return E(this,t,i);case\"base64\":return x(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return B(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function w(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function b(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Y(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:F(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):F(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function F(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function x(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function k(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!c.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;ti&&(e+=\" ... \"),\"\"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,i,n,r){if(K(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),l=this.slice(n,r),h=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return v(this,e,t,i);case\"utf8\":case\"utf-8\":return y(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return A(this,e,t,i);case\"base64\":return C(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return _(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function S(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function R(e,t,i,n,r,s){if(!c.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function D(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function T(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function L(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function z(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,4),r.write(e,t,i,n,23,4),i+4}function H(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,8),r.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||M(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return D(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return T(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return D(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return T(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(e,t,i){return z(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return z(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return H(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return H(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(!c.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function q(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new P.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Q(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||V(t,e.length-(i+1))}(n,r,s)}function Q(e,t){if(\"number\"!=typeof e)throw new P.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function V(e,t,i){if(Math.floor(e)!==e)throw Q(e,i),new P.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}O(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),O(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),O(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=U(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=U(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function W(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(e){return n.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(j,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function $(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}const X=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Z(e){return\"undefined\"==typeof BigInt?J:e}function J(){throw new Error(\"BigInt not supported\")}},235:e=>{var t={array:function(e){var t=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-t;r>=o?(s<<=o,s|=n[o]&e[i++],t=0,r-=o):(s<<=r,s|=(e[i]&n[r]<<8-r-t)>>8-r-t,t+=r,r=0)}return s}},simple:function(e){var i,n,r=t.header(e),s=[],o=0;do{-1!=(n=t.decompress(e,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a9)throw\"Not a BZIP archive\";return t},decompress:function(e,t,i){for(var n=9e5,r=\"\",s=0;s<6;s++)r+=e(8).toString(16);if(\"177245385090\"==r)return-1;if(\"314159265359\"!=r)throw\"eek not valid bzip data\";if(e(32),e(1))throw\"unsupported obsolete version\";var o=e(24);if(o>n)throw\"Initial position larger than buffer size\";var a=e(16),c=new Uint8Array(256),l=0;for(s=0;s<16;s++)if(a&1<<15-s){var h=e(16);for(g=0;g<16;g++)h&1<<15-g&&(c[l++]=16*s+g)}var d=e(3);if(d<2||d>6)throw\"another error\";var u=e(15);if(0==u)throw\"meh\";var f=[];for(s=0;s=d)throw\"whoops another error\";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var w=l+2,b=[];for(g=0;g20)throw\"I gave up a while ago on writing error messages\";if(!e(1))break;e(1)?a--:a++}A[s]=a}for(F=v=A[0],s=1;sv?v=A[s]:A[s]=u)throw\"meow i'm a kitty, that's an error\";_=(y=b[p[E++]]).base.subarray(1),x=y.limit.subarray(1)}for(g=e(s=y.minLen);;){if(s>y.maxLen)throw\"rawr i'm a dinosaur\";if(g<=x[s])break;s++,g=g<<1|e(1)}if((g-=_[s])<0||g>=258)throw\"moo i'm a cow\";var M=y.permute[g];if(0!=M&&1!=M){if(I){if(I=0,S+a>=n)throw\"Boom.\";for(N[m=c[f[0]]]+=a;a--;)B[S++]=m}if(M>l)break;if(S>=n)throw\"I can't think of anything. Error\";m=f[s=M-1],f.splice(s,1),f.splice(0,0,m),N[m=c[m]]++,B[S++]=m}else I||(I=1,a=0),a+=0==M?I:2*I,I<<=1}if(o<0||o>=S)throw\"I'm a monkey and I'm throwing something at someone, namely you\";for(g=0,s=0;s<256;s++)h=g+N[s],N[s]=g,g=h;for(s=0;s>=8,T=-1);var L,z,H,P=new Uint8Array(n),O=0;for(i||(i=1/0);S;){for(S--,z=D,D=255&(R=B[R]),R>>=8,3==T++?(L=D,H=z,D=-1):(L=1,H=D);L--;)if(P[O++]=H,! --i)return P;D!=z&&(T=0)}return P.subarray(0,O)}};e.exports=t},2151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],i=0;i{var t,i;t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",i={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&i.rotl(e,8)|4278255360&i.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],i=0,n=0;i>>5]|=e[i]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],i=0;i<32*e.length;i+=8)t.push(e[i>>>5]>>>24-i%32&255);return t},bytesToHex:function(e){for(var t=[],i=0;i>>4).toString(16)),t.push((15&e[i]).toString(16));return t.join(\"\")},hexToBytes:function(e){for(var t=[],i=0;i>>6*(3-s)&63)):i.push(\"=\");return i.join(\"\")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,\"\");for(var i=[],n=0,r=0;n>>6-2*r);return i}},e.exports=i},1113:(e,t,i)=>{i.r(t),i.d(t,{BlobFile:()=>l,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>h,open:()=>d});var n=i(3617),r=i.n(n),s=i(8287);function o(e){return(\"object\"==typeof e&&null!==e&&\"message\"in e?e.message:`${e}`).replace(/\\.$/,\"\")}class a{async getBufferFromResponse(e){const t=await e.arrayBuffer();return s.Buffer.from(t)}constructor(e,t={}){this.baseOverrides={},this.url=e;const i=t.fetch||globalThis.fetch.bind(globalThis);if(!i)throw new TypeError(\"no fetch function supplied, and none found in global environment\");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=i}async fetch(e,t){let i;try{i=await this.fetchImplementation(e,t)}catch(n){if(!`${n}`.includes(\"Failed to fetch\"))throw new Error(`${o(n)} fetching ${e}`,{cause:n});console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`);try{i=await this.fetchImplementation(e,{...t,cache:\"reload\"})}catch(t){throw new Error(`${o(t)} fetching ${e}`,{cause:t})}}return i}async read(e,t=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const c=await this.fetch(this.url,{...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:o});if(!c.ok)throw new Error(`HTTP ${c.status} fetching ${this.url}`);if(200===c.status&&0===n||206===c.status){const n=await this.getBufferFromResponse(c),r=n.copy(e,t,0,Math.min(i,n.length)),s=c.headers.get(\"content-range\"),o=/\\/(\\d+)$/.exec(s||\"\");return(null==o?void 0:o[1])&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:e}}if(200===c.status)throw new Error(`${this.url} fetch returned status 200, expected 206`);throw new Error(`HTTP ${c.status} fetching ${this.url}`)}async readFile(e={}){let t,i;\"string\"==typeof e?(t=e,i={}):(t=e.encoding,i=e,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o=await this.fetch(this.url,{headers:n,method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:r,...this.baseOverrides,...s});if(200!==o.status)throw new Error(`HTTP ${o.status} fetching ${this.url}`);if(\"utf8\"===t)return o.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(o)}async stat(){if(!this._stat){const e=s.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function c(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"!=typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsArrayBuffer(e)}))}class l{constructor(e){this.blob=e,this.size=e.size}async read(e,t=0,i,n=0){if(!i)return{bytesRead:0,buffer:e};const r=n,o=r+i,a=await c(this.blob.slice(r,o)),l=s.Buffer.from(a);return{bytesRead:l.copy(e,t),buffer:l}}async readFile(e){const t=\"string\"==typeof e?e:null==e?void 0:e.encoding;if(\"utf8\"===t)return function(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"==typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsText(e)}))}(this.blob);if(t)throw new Error(`unsupported encoding: ${t}`);const i=await c(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function h(e,t={}){return new a(e,t)}function d(e,t,i,n={}){if(void 0!==i)return i;if(void 0!==e)return h(e,n);if(void 0!==t)return new(r())(t,n);throw new Error(\"no url, path, or filehandle provided, cannot open\")}},251:(e,t)=>{t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}},8570:e=>{e.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,\"__isLong__\",{value:!0}),i.isLong=n;var r={},s={};function o(e,t){var i,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(i=c(e,(0|e)<0?-1:0,!0),o&&(s[e]=i),i):(o=-128<=(e|=0)&&e<128)&&(n=r[e])?n:(i=c(e,e<0?-1:0,!1),o&&(r[e]=i),i)}function a(e,t){if(isNaN(e))return t?w:m;if(t){if(e<0)return w;if(e>=f)return A}else{if(e<=-p)return C;if(e+1>=p)return y}return e<0?a(-e,t).neg():c(e%u|0,e/u|0,t)}function c(e,t,n){return new i(e,t,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=c;var l=Math.pow;function h(e,t,i){if(0===e.length)throw Error(\"empty string\");if(\"NaN\"===e||\"Infinity\"===e||\"+Infinity\"===e||\"-Infinity\"===e)return m;if(\"number\"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||360)throw Error(\"interior hyphen\");if(0===n)return h(e.substring(1),t,i).neg();for(var r=a(l(i,8)),s=m,o=0;o>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=c).isZero())return h+o;for(;h.length<6;)h=\"0\"+h;o=\"\"+h+o}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(C)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.ne=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.le=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.ge=_.greaterThanOrEqual,_.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(b)},_.neg=_.negate,_.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,a=65535&e.high,l=e.low>>>16,h=0,u=0,f=0,p=0;return f+=(p+=s+(65535&e.low))>>>16,u+=(f+=r+l)>>>16,h+=(u+=i+a)>>>16,h+=t+o,c((f&=65535)<<16|(p&=65535),(h&=65535)<<16|(u&=65535),this.unsigned)},_.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return m;if(n(e)||(e=d(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(C))return e.isOdd()?C:m;if(e.eq(C))return this.isOdd()?C:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return a(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,l=e.high>>>16,h=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,w=0,b=0,F=0;return b+=(F+=o*f)>>>16,w+=(b+=s*f)>>>16,b&=65535,w+=(b+=o*u)>>>16,p+=(w+=r*f)>>>16,w&=65535,p+=(w+=s*u)>>>16,w&=65535,p+=(w+=o*h)>>>16,p+=i*f+r*u+s*h+o*l,c((b&=65535)<<16|(F&=65535),(p&=65535)<<16|(w&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error(\"division by zero\");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return w;if(e.gt(this.shru(1)))return F;s=w}else{if(this.eq(C))return e.eq(b)||e.eq(v)?C:e.eq(C)?b:(i=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?b:v:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(C))return this.unsigned?w:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=m}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),h=o<=48?1:l(2,o-48),u=a(i),f=u.mul(e);f.isNegative()||f.gt(r);)f=(u=a(i-=h,this.unsigned)).mul(e);u.isZero()&&(u=b),s=s.add(u),r=r.sub(f)}return s},_.div=_.divide,_.modulo=function(e){return n(e)||(e=d(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.rem=_.modulo,_.not=function(){return c(~this.low,~this.high,this.unsigned)},_.and=function(e){return n(e)||(e=d(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return n(e)||(e=d(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return n(e)||(e=d(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low<>>32-e,this.unsigned):c(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?c(this.low>>>e|t<<32-e,t>>>e,this.unsigned):c(32===e?t:t>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.shr_u=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},_.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},3503:(e,t,i)=>{var n,r,s,o,a;n=i(3939),r=i(2151).utf8,s=i(652),o=i(2151).bin,(a=function(e,t){e.constructor==String?e=t&&\"binary\"===t.encoding?o.stringToBytes(e):r.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var i=n.bytesToWords(e),c=8*e.length,l=1732584193,h=-271733879,d=-1732584194,u=271733878,f=0;f>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[c>>>5]|=128<>>9<<4)]=c;var p=a._ff,g=a._gg,m=a._hh,w=a._ii;for(f=0;f>>0,h=h+F>>>0,d=d+v>>>0,u=u+y>>>0}return n.endian([l,h,d,u])})._ff=function(e,t,i,n,r,s,o){var a=e+(t&i|~t&n)+(r>>>0)+o;return(a<>>32-s)+t},a._gg=function(e,t,i,n,r,s,o){var a=e+(t&n|i&~n)+(r>>>0)+o;return(a<>>32-s)+t},a._hh=function(e,t,i,n,r,s,o){var a=e+(t^i^n)+(r>>>0)+o;return(a<>>32-s)+t},a._ii=function(e,t,i,n,r,s,o){var a=e+(i^(t|~n))+(r>>>0)+o;return(a<>>32-s)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error(\"Illegal argument \"+e);var i=n.wordsToBytes(a(e,t));return t&&t.asBytes?i:t&&t.asString?o.bytesToString(i):n.bytesToHex(i)}},652:e=>{function t(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return\"function\"==typeof e.readFloatLE&&\"function\"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},1668:(e,t,i)=>{var n={};(0,i(9805).assign)(n,i(3303),i(7083),i(9681)),e.exports=n},3303:(e,t,i)=>{var n=i(8411),r=i(9805),s=i(1996),o=i(4674),a=i(4442),c=Object.prototype.toString,l=0,h=-1,d=0,u=8;function f(e){if(!(this instanceof f))return new f(e);this.options=r.assign({level:h,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==l)throw new Error(o[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p=\"string\"==typeof t.dictionary?s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=n.deflateSetDictionary(this.strm,p))!==l)throw new Error(o[i]);this._dict_set=!0}}function p(e,t){var i=new f(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}f.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,\"string\"==typeof e?a.input=s.string2buf(e):\"[object ArrayBuffer]\"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&i!==l)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||(\"string\"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===l):2!==o||(this.onEnd(l),a.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===l&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},7083:(e,t,i)=>{var n=i(1447),r=i(9805),s=i(1996),o=i(9681),a=i(4674),c=i(4442),l=i(7414),h=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new l,n.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===h.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[i])}function u(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(e,t){var i,a,c,l,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,\"string\"==typeof e?u.input=s.binstring2buf(e):\"[object ArrayBuffer]\"===h.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new r.Buf8(f),u.next_out=0,u.avail_out=f),(i=n.inflate(u,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==o.Z_STREAM_END&&(0!==u.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||(\"string\"===this.options.to?(c=s.utf8border(u.output,u.next_out),l=u.next_out-c,d=s.buf2string(u.output,c),u.next_out=l,u.avail_out=f-l,l&&r.arraySet(u.output,u.output,c,l,0),this.onData(d)):this.onData(r.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=d,t.inflate=u,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.ungzip=u},9805:(e,t)=>{var i=\"undefined\"!=typeof Uint8Array&&\"undefined\"!=typeof Uint16Array&&\"undefined\"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,n,r){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),r);else for(var s=0;s{var n=i(9805),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var i=\"\",o=0;o>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},t.buf2binstring=function(e){return c(e,e.length)},t.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i4)l[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?l[n++]=65533:r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|1023&r)}return c(l,n)},t.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},3269:e=>{e.exports=function(e,t,i,n){for(var r=65535&e,s=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16}},9681:e=>{e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:e=>{var t=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();e.exports=function(e,i,n,r){var s=t,o=r+n;e^=-1;for(var a=r;a>>8^s[255&(e^i[a])];return~e}},8411:(e,t,i)=>{var n,r=i(9805),s=i(3665),o=i(3269),a=i(4823),c=i(4674),l=0,h=0,d=-2,u=2,f=8,p=286,g=30,m=19,w=2*p+1,b=15,F=3,v=258,y=v+F+1,A=42,C=103,_=113,x=666;function k(e,t){return e.msg=c[t],t}function I(e){return(e<<1)-(e>4?9:0)}function S(e){for(var t=e.length;--t>=0;)e[t]=0}function E(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function N(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,E(e.strm)}function B(e,t){e.pending_buf[e.pending++]=t}function M(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function R(e,t,i,n){var s=e.avail_in;return s>n&&(s=n),0===s?0:(e.avail_in-=s,r.arraySet(t,e.input,e.next_in,s,i),1===e.state.wrap?e.adler=o(e.adler,t,s,i):2===e.state.wrap&&(e.adler=a(e.adler,t,s,i)),e.next_in+=s,e.total_in+=s,s)}function D(e,t){var i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-y?e.strstart-(e.w_size-y):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+v,f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead}function T(e){var t,i,n,s,o,a=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-y)){r.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=i=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--i);t=i=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--i);s+=a}if(0===e.strm.avail_in)break;if(i=R(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=F)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<=F)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-F,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<15&&(a=2,n-=16),s<1||s>9||i!==f||n<8||n>15||t<0||t>9||o<0||o>4)return k(e,d);8===n&&(n=9);var c=new P;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=n,c.w_size=1<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(T(e),0===e.lookahead&&t===l)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-y&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),1)})),new H(4,4,8,4,L),new H(4,5,16,8,L),new H(4,6,32,32,L),new H(4,4,16,16,z),new H(8,16,32,32,z),new H(8,16,128,128,z),new H(8,32,128,256,z),new H(32,128,258,1024,z),new H(32,258,258,4096,z)],t.deflateInit=function(e,t){return q(e,t,f,15,8,0)},t.deflateInit2=q,t.deflateReset=U,t.deflateResetKeep=O,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?d:(e.state.gzhead=t,h):d},t.deflate=function(e,t){var i,r,o,c;if(!e||!e.state||t>5||t<0)return e?k(e,d):d;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===x&&4!==t)return k(e,0===e.avail_out?-5:d);if(r.strm=e,i=r.last_flush,r.last_flush=t,r.status===A)if(2===r.wrap)e.adler=0,B(r,31),B(r,139),B(r,8),r.gzhead?(B(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),B(r,255&r.gzhead.time),B(r,r.gzhead.time>>8&255),B(r,r.gzhead.time>>16&255),B(r,r.gzhead.time>>24&255),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(B(r,255&r.gzhead.extra.length),B(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(B(r,0),B(r,0),B(r,0),B(r,0),B(r,0),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,3),r.status=_);else{var u=f+(r.w_bits-8<<4)<<8;u|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(u|=32),u+=31-u%31,r.status=_,M(r,u),0!==r.strstart&&(M(r,e.adler>>>16),M(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending!==r.pending_buf_size));)B(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.status=C)}else r.status=C;if(r.status===C&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&E(e),r.pending+2<=r.pending_buf_size&&(B(r,255&e.adler),B(r,e.adler>>8&255),e.adler=0,r.status=_)):r.status=_),0!==r.pending){if(E(e),0===e.avail_out)return r.last_flush=-1,h}else if(0===e.avail_in&&I(t)<=I(i)&&4!==t)return k(e,-5);if(r.status===x&&0!==e.avail_in)return k(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==l&&r.status!==x){var p=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(T(e),0===e.lookahead)){if(t===l)return 1;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,n,r,o,a=e.window;;){if(e.lookahead<=v){if(T(e),e.lookahead<=v&&t===l)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&e.strstart>0&&(n=a[r=e.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=e.strstart+v;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=s._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):n[r.level].func(r,t);if(3!==p&&4!==p||(r.status=x),1===p||3===p)return 0===e.avail_out&&(r.last_flush=-1),h;if(2===p&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(S(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),E(e),0===e.avail_out))return r.last_flush=-1,h}return 4!==t?h:r.wrap<=0?1:(2===r.wrap?(B(r,255&e.adler),B(r,e.adler>>8&255),B(r,e.adler>>16&255),B(r,e.adler>>24&255),B(r,255&e.total_in),B(r,e.total_in>>8&255),B(r,e.total_in>>16&255),B(r,e.total_in>>24&255)):(M(r,e.adler>>>16),M(r,65535&e.adler)),E(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?h:1)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==A&&69!==t&&73!==t&&91!==t&&t!==C&&t!==_&&t!==x?k(e,d):(e.state=null,t===_?k(e,-3):h):d},t.deflateSetDictionary=function(e,t){var i,n,s,a,c,l,u,f,p=t.length;if(!e||!e.state)return d;if(2===(a=(i=e.state).wrap)||1===a&&i.status!==A||i.lookahead)return d;for(1===a&&(e.adler=o(e.adler,t,p,0)),i.wrap=0,p>=i.w_size&&(0===a&&(S(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new r.Buf8(i.w_size),r.arraySet(f,t,p-i.w_size,i.w_size,0),t=f,p=i.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,T(i);i.lookahead>=F;){n=i.strstart,s=i.lookahead-(F-1);do{i.ins_h=(i.ins_h<{e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}},7293:e=>{e.exports=function(e,t){var i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x,k;i=e.state,n=e.next_in,x=e.input,r=n+(e.avail_in-5),s=e.next_out,k=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,w=(1<>>=v=F>>>24,p-=v,0==(v=F>>>16&255))k[s++]=65535&F;else{if(!(16&v)){if(64&v){if(32&v){i.mode=12;break e}e.msg=\"invalid literal/length code\",i.mode=30;break e}F=g[(65535&F)+(f&(1<>>=v,p-=v),p<15&&(f+=x[n++]<>>=v=F>>>24,p-=v,16&(v=F>>>16&255)){if(A=65535&F,p<(v&=15)&&(f+=x[n++]<c){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(f>>>=v,p-=v,A>(v=s-o)){if((v=A-v)>h&&i.sane){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(C=0,_=u,0===d){if(C+=l-v,v2;)k[s++]=_[C++],k[s++]=_[C++],k[s++]=_[C++],y-=3;y&&(k[s++]=_[C++],y>1&&(k[s++]=_[C++]))}else{C=s-A;do{k[s++]=k[C++],k[s++]=k[C++],k[s++]=k[C++],y-=3}while(y>2);y&&(k[s++]=k[C++],y>1&&(k[s++]=k[C++]))}break}if(64&v){e.msg=\"invalid distance code\",i.mode=30;break e}F=m[(65535&F)+(f&(1<>3,f&=(1<<(p-=y<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n{var n=i(9805),r=i(3269),s=i(4823),o=i(7293),a=i(1998),c=0,l=-2,h=1,d=12,u=30,f=852,p=592;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(f),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,c):l}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,w(e)):l}function F(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,b(e))):l}function v(e,t){var i,n;return e?(n=new m,e.state=n,n.window=null,(i=F(e,t))!==c&&(e.state=null),i):l}var y,A,C=!0;function _(e){if(C){var t;for(y=new n.Buf32(512),A=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,y,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,A,0,e.work,{bits:5}),C=!1}e.lencode=y,e.lenbits=9,e.distcode=A,e.distbits=5}function x(e,t,i,r){var s,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(n.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,t,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,t,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=s(i.check,O,2,0),v=0,y=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg=\"incorrect header check\",i.mode=u;break}if(8!=(15&v)){e.msg=\"unknown compression method\",i.mode=u;break}if(y-=4,T=8+(15&(v>>>=4)),0===i.wbits)i.wbits=T;else if(T>i.wbits){e.msg=\"invalid window size\",i.mode=u;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=3;case 3:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>8&255,O[2]=v>>>16&255,O[3]=v>>>24&255,i.check=s(i.check,O,4,0)),v=0,y=0,i.mode=4;case 4:for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>8),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=5;case 5:if(1024&i.flags){for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((k=i.length)>b&&(k=b),k&&(i.head&&(T=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,f,m,k,T)),512&i.flags&&(i.check=s(i.check,f,k,m)),b-=k,m+=k,i.length-=k),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===b)break e;k=0;do{T=f[m+k++],i.head&&T&&i.length<65536&&(i.head.name+=String.fromCharCode(T))}while(T&&k>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=d;break;case 10:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>=7&y,y-=7&y,i.mode=27;break}for(;y<3;){if(0===b)break e;b--,v+=f[m++]<>>=1)){case 0:i.mode=14;break;case 1:if(_(i),i.mode=20,6===t){v>>>=2,y-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=u}v>>>=2,y-=2;break;case 14:for(v>>>=7&y,y-=7&y;y<32;){if(0===b)break e;b--,v+=f[m++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=u;break}if(i.length=65535&v,v=0,y=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(k=i.length){if(k>b&&(k=b),k>F&&(k=F),0===k)break e;n.arraySet(p,f,m,k,w),b-=k,m+=k,F-=k,w+=k,i.length-=k;break}i.mode=d;break;case 17:for(;y<14;){if(0===b)break e;b--,v+=f[m++]<>>=5,y-=5,i.ndist=1+(31&v),v>>>=5,y-=5,i.ncode=4+(15&v),v>>>=4,y-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=u;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,y-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,z={bits:i.lenbits},L=a(0,i.lens,0,19,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid code lengths set\",i.mode=u;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=E,y-=E,i.lens[i.have++]=B;else{if(16===B){for(H=E+2;y>>=E,y-=E,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=u;break}T=i.lens[i.have-1],k=3+(3&v),v>>>=2,y-=2}else if(17===B){for(H=E+3;y>>=E)),v>>>=3,y-=3}else{for(H=E+7;y>>=E)),v>>>=7,y-=7}if(i.have+k>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=u;break}for(;k--;)i.lens[i.have++]=T}}if(i.mode===u)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=u;break}if(i.lenbits=9,z={bits:i.lenbits},L=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid literal/lengths set\",i.mode=u;break}if(i.distbits=6,i.distcode=i.distdyn,z={bits:i.distbits},L=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,z),i.distbits=z.bits,L){e.msg=\"invalid distances set\",i.mode=u;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(b>=6&&F>=258){e.next_out=w,e.avail_out=F,e.next_in=m,e.avail_in=b,i.hold=v,i.bits=y,o(e,C),w=e.next_out,p=e.output,F=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,v=i.hold,y=i.bits,i.mode===d&&(i.back=-1);break}for(i.back=0;N=(P=i.lencode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,i.length=B,0===N){i.mode=26;break}if(32&N){i.back=-1,i.mode=d;break}if(64&N){e.msg=\"invalid literal/length code\",i.mode=u;break}i.extra=15&N,i.mode=22;case 22:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;N=(P=i.distcode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,64&N){e.msg=\"invalid distance code\",i.mode=u;break}i.offset=B,i.extra=15&N,i.mode=24;case 24:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=u;break}i.mode=25;case 25:if(0===F)break e;if(k=C-F,i.offset>k){if((k=i.offset-k)>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=u;break}k>i.wnext?(k-=i.wnext,I=i.wsize-k):I=i.wnext-k,k>i.length&&(k=i.length),S=i.window}else S=p,I=w-i.offset,k=i.length;k>F&&(k=F),F-=k,i.length-=k;do{p[w++]=S[I++]}while(--k);0===i.length&&(i.mode=21);break;case 26:if(0===F)break e;p[w++]=i.length,F--,i.mode=21;break;case 27:if(i.wrap){for(;y<32;){if(0===b)break e;b--,v|=f[m++]<{var n=i(9805),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,i,c,l,h,d,u){var f,p,g,m,w,b,F,v,y,A=u.bits,C=0,_=0,x=0,k=0,I=0,S=0,E=0,N=0,B=0,M=0,R=null,D=0,T=new n.Buf16(16),L=new n.Buf16(16),z=null,H=0;for(C=0;C<=15;C++)T[C]=0;for(_=0;_=1&&0===T[k];k--);if(I>k&&(I=k),0===k)return l[h++]=20971520,l[h++]=20971520,u.bits=1,0;for(x=1;x0&&(0===e||1!==k))return-1;for(L[1]=0,C=1;C<15;C++)L[C+1]=L[C]+T[C];for(_=0;_852||2===e&&B>592)return 1;for(;;){F=C-E,d[_]b?(v=z[H+d[_]],y=R[D+d[_]]):(v=96,y=0),f=1<>E)+(p-=f)]=F<<24|v<<16|y}while(0!==p);for(f=1<>=1;if(0!==f?(M&=f-1,M+=f):M=0,_++,0==--T[C]){if(C===k)break;C=t[i+d[_]]}if(C>I&&(M&m)!==g){for(0===E&&(E=I),w+=x,N=1<<(S=C-E);S+E852||2===e&&B>592)return 1;l[g=M&m]=I<<24|S<<16|w-h}}return 0!==M&&(l[w+M]=C-E<<24|64<<16),u.bits=I,0}},4674:e=>{e.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},3665:(e,t,i)=>{var n=i(9805);function r(e){for(var t=e.length;--t>=0;)e[t]=0}var s=15,o=16,a=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);r(d);var u=new Array(60);r(u);var f=new Array(512);r(f);var p=new Array(256);r(p);var g=new Array(29);r(g);var m,w,b,F=new Array(30);function v(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}function y(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?f[e]:f[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function _(e,t,i){e.bi_valid>o-i?(e.bi_buf|=t<>o-e.bi_valid,e.bi_valid+=i-o):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1}function I(e,t,i){var n,r,o=new Array(s+1),a=0;for(n=1;n<=s;n++)o[n]=a=a+i[n-1]<<1;for(r=0;r<=t;r++){var c=e[2*r+1];0!==c&&(e[2*r]=k(o[c]++,c))}}function S(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function E(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function N(e,t,i,n){var r=2*t,s=2*i;return e[r]>1;i>=1;i--)B(e,o,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],B(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,o[2*r]=o[2*i]+o[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,o[2*i+1]=o[2*n+1]=r,e.heap[1]=r++,B(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,o,a,c,l=t.dyn_tree,h=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(o=0;o<=s;o++)e.bl_count[o]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(o=l[2*l[2*(n=e.heap[i])+1]+1]+1)>g&&(o=g,m++),l[2*n+1]=o,n>h||(e.bl_count[o]++,a=0,n>=p&&(a=f[n-p]),c=l[2*n],e.opt_len+=c*(o+a),u&&(e.static_len+=c*(d[2*n+1]+a)));if(0!==m){do{for(o=g-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[g]--,m-=2}while(m>0);for(o=g;0!==o;o--)for(n=e.bl_count[o];0!==n;)(r=e.heap[--i])>h||(l[2*r+1]!==o&&(e.opt_len+=(o-l[2*r+1])*l[2*r],l[2*r+1]=o),n--)}}(e,t),I(o,h,e.bl_count)}function D(e,t,i){var n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a>=7;n<30;n++)for(F[n]=r<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),o=function(e){var t;for(D(e,e.dyn_ltree,e.l_desc.max_code),D(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?z(e,t,i,n):4===e.strategy||s===r?(_(e,2+(n?1:0),3),M(e,d,u)):(_(e,4+(n?1:0),3),function(e,t,i,n){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,n-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(p[i]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){_(e,2,3),x(e,256,d),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},4442:e=>{e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},7392:e=>{class t{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError(\"`maxSize` must be a number greater than 0\");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}e.exports=t},1307:function(e,t,i){var n;n=e=>(()=>{var t=[,e=>{e.exports=\"data:application/wasm;base64,AGFzbQEAAAABOApgAX8Bf2ABfwBgAABgA39/fwF/YAABf2ACf38AYAN/f34BfmACf38Bf2AEf39/fwF/YAN/f38AAyEgAAABAgMDAwMEAQUAAgMCBgcIBwUDAAMHAQcABwcBAwkFAwEAAgYIAX8BQfCgBAsHTgUGbWVtb3J5AgAOY3JlYXRlX2NvbnRleHQACA9kZXN0cm95X2NvbnRleHQACQxzdXBwbHlfaW5wdXQACg9nZXRfbmV4dF9vdXRwdXQACwqNYCDfAgEFf0EAIQECQCAAQQdqIgJBEEkNAEEBIQEgAkEDdiIDQQJGDQBBAiEBIAJBIEkNAEEDIQEgA0EERg0AQQQhASACQTBJDQBBBSEBIANBBkYNAEEGIQEgAkHIAEkNAEEHIQEgAkHYAEkNAEEIIQEgAkGIAUkNAEEJIQEgAkGIAkkNACAAEIGAgIAAIgBBCGpBACAAGw8LAkACQCABQQJ0QcCIgIAAaiIEKAIAIgANAEEAIQACQAJAQQAoAuSIgIAAIgJFDQBBACACKAIANgLkiICAAAwBC0EAEIGAgIAAIgJFDQILIAJBgIB8cSIAIAJBCHZB/wFxIgJyIAE6AAAgAkEIdCAAckGAAmohAEEAIQJBACABQQJ0QYCIgIAAaigCACIDayEFIAMhAQNAIAAgBWoiACACNgIAIAAhAiABIANqIgFBgQJJDQALIAQgADYCAAsgBCAAKAIANgIACyAAC+4HAQd/AkACQAJAAkACQEEALQC0iICAAEUNAEEAQQA6ALSIgIAAQQAoArCIgIAAIgFFDQFBsIiAgAAhAgNAAkACQCABQQhqIgMgASgCBCIEaiIFQQh2Qf8BcSIGDQAgASECDAELAkADQCAFQYCAfHEgBmotAABB/gFHDQFBsIiAgAAhBgNAIAYiBygCACIGIAVHDQALIAcgBSgCADYCACABIAQgBSgCBGpBCGoiBDYCBCAHIAIgAiAFRhshAiADIARqIgVBCHZB/wFxIgYNAAsLIAIoAgAhAgsgAigCACIBDQALC0EAKAKwiICAACIFRQ0AIABBhwJqQYB+cSEDQX8hAkGwiICAACEEQQAhAUGwiICAACEGA0AgBiEHAkAgBSIGKAIEIgUgAEkNACAFIAJPDQAgBSECIAchBCAGIQEgBUEIaiADRw0AIAchBCAFIQIgBiEBDAQLIAYoAgAiBQ0ACyABDQIMAQtBsIiAgAAhBAs/AEEQdCEBIABBiAJqIQdBACEDAkACQEEAKAK4iICAACICRQ0AQQAhBSABIQYMAQtBACABQfCghIAAQf//A2pBgIB8cSIGayICNgK4iICAACACIQULAkAgByAFTQ0AIAcgBWsiByACQQF2IgIgAiAHSRtB//8DaiIHQRB2QABBf0YNAkEAQQAoAriIgIAAIAdBgIB8cSIDajYCuIiAgAALIAZFDQEgBkH/AToAASAGQQAoArCIgIAANgKAAiAGQYQCaiADIAVqQYCAfHFB+H1qIgI2AgAgBkGAAmohAQsgAUGAgHxxIgYgAUEIdkH/AXFyQf8BOgAAIAQgASgCADYCAAJAIAIgAGtBgH5xIgUNACABDwsgASEDAkAgBiABQQhqIgQgAmoiByAFQX9zakGAgHxxRg0AIARB//8DcSEFAkAgAEH3/QNLDQAgBiAEQQh2Qf8BcWpB/gE6AAAgAUEAKAKwiICAADYCACABQYCABCAFayIFNgIEQQAgATYCsIiAgAAQg4CAgAAgBkGEggRqIAIgBWtB+H1qIgU2AgAgBkGBgARqQf8BOgAAIAZBgIIEaiEDIAUgAGtBgH5xIQUMAQsgAiAFaiAAIAVqQX9qQYCAfHFrQYCAfGohBSABIQMLIAMgAygCBCAFazYCBCAFQfgBaiEGIAcgBWtBCHZB/wFxIQUCQANAIAYiB0GAfmohBiAFIgQNAUEBIQUgB0H4AUcNAAsLAkAgB0H4AUYNACACIAFqIAZrQYCAfHEiBSAEakH+AToAACAFIARBCHRqIgVBACgCsIiAgAA2AgAgBSAGNgIEQQAgBTYCsIiAgAAQg4CAgAALIAMPC0EAC3wBAn8CQCAARQ0AAkAgAEGAgHxxIABBCHZB/wFxciIBLQAAIgJB/wFHDQAgAEF4aiIAQQAoArCIgIAANgIAQQAgADYCsIiAgAAgAUH+AToAAEEAQQE6ALSIgIAADwsgACACQQJ0QcCIgIAAaiICKAIANgIAIAIgADYCAAsLawECfwJAQQAoArCIgIAAIgAoAgRB/wFLDQAgAEGAgHxxIgEgAEEIdkH/AXEiAHJBCToAAEEAQQAoArCIgIAAKAIANgKwiICAACABIABBCHRyIgBBACgC5IiAgAA2AgBBACAANgLkiICAAAsLTgECfwJAIAAgAUYNACACRQ0AA0ACQCAALQAAIgMgAS0AACIERg0AQQFBfyADIARLGw8LIAFBAWohASAAQQFqIQAgAkF/aiICDQALC0EAC3gBAX8CQAJAIAAgAU8NACACRQ0BIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ADAILCyAAIAFNDQAgAkUNACABQX9qIQEgAEF/aiEDA0AgAyACaiABIAJqLQAAOgAAIAJBf2oiAg0ACwsgAAssAQF/AkAgAkUNACAAIQMDQCADIAE6AAAgA0EBaiEDIAJBf2oiAg0ACwsgAAuCAQEBfwJAAkAgAEEDcQ0AIAEgAnJBA3ENACACQQRJDQEgAkECdiECIAAhAwNAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIAJBf2oiAg0ADAILCyACRQ0AIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ACwsgAAuIAQECfwJAQQAtAOiIgIAADQBBAEEBOgDoiICAABCMgICAABCOgICAAAtBoIAIEICAgIAAIgBBgIAENgIAQQJBgICAIBCXgICAACEBIABBFGpCgICAgICAwAA3AgAgAEEQaiAAQaCABGo2AgAgAEEIakIANwMAIAAgAEEgajYCBCAAIAE2AhwgAAsVACAAKAIcEJiAgIAAIAAQgoCAgAALFgAgAEEMaiABNgIAIABBCGpBADYCAAsbACAAKAIcIABBBGogAEEMaigCAEUQloCAgAALVAEDf0EAIQADQEEIIQEgACECA0BBACACQQFxa0GghuLtfnEgAkEBdnMhAiABQX9qIgENAAsgAEECdEHwiICAAGogAjYCACAAQQFqIgBBgAJHDQALC0oAIAJBf3MhAgJAIAFFDQADQCACQf8BcSAALQAAc0ECdEHwiICAAGooAgAgAkEIdnMhAiAAQQFqIQAgAUF/aiIBDQALCyACQX9zC10DAX4BfwF+QgAhAANAQQghASAAIQIDQEIAIAJCAYN9QsKenLzd8pW2SYMgAkIBiIUhAiABQX9qIgENAAsgAKdBA3RB8JCAgABqIAI3AwAgAEIBfCIAQoACUg0ACwtLACACQn+FIQICQCABRQ0AA0AgAkL/AYMgADEAAIWnQQN0QfCQgIAAaikDACACQgiIhSECIABBAWohACABQX9qIgENAAsLIAJCf4UL1RACDH8CfgJAAkAgACgCJEUNACAAKAIAIQIMAQtBACECIABBADoAKCAAQgA3AwAgAEIANwMYIABByABqQQBB5AAQhoCAgAAaIABBrAFqQQw2AgALIAAgASgCBCIDNgIQIABBsAFqIQQgAEHgAGohBSAAQcgAaiEGIABBtgFqIQcgAEGoAWohCCABKAIQIQkCQAJAAkACQANAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAIOCgECAAQFBgcICQoPCyABKAIAIQogACgCqAEhAiAAKAKsASELIAEoAgQhDCABKAIIIQ0MAgsgCCAAKAKoASIMakEIaiABKAIAIAEoAgQiAmogASgCCCACayICIAAoAqwBIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0RIABBATYCAAJAIARBqIiAgABBBhCEgICAAEUNAEEFIQwMEgsgB0ECQQAQjYCAgAAgACgAuAFHDRBBBiEMIActAAANESAAIAAtALcBIgI2AiAgAkEESw0RQQEgAnRBE3FFDRELIAEoAgQiDCABKAIIIg1GDQ4CQCABKAIAIgogDGotAAAiCw0AIAAgDDYCECABIAxBAWo2AgRBBiECDAwLQQAhAiAAQQA2AqgBIABBAjYCACAAIAtBAnRBBGoiCzYCrAEgACALNgJACyAIIAJqQQhqIAogDGogDSAMayIMIAsgAmsiAiAMIAJJGyICEIeAgIAAGiABIAIgASgCBGo2AgRBACEMIABBACAAKAKoASACaiICIAIgACgCrAEiC0YbNgKoASACIAtHDQ8gACACQXxqIgI2AqwBQQchDCAEIAJBABCNgICAACAAIAAoAqwBIgtqQbABaigAAEcNDyAAQQI2AqgBIAAtALEBIgJBP3ENDAJAAkAgAkHAAHFFDQAgACAEIAggCxCRgICAAEEBRw0RIAAgACkDCDcDMCAALQCxASECDAELIABCfzcDMAtCfyEOAkAgAkEYdEEYdUF/Sg0AIAAgBCAIIAAoAqwBEJGAgIAAQQFHDRAgACkDCCEOCyAAIA43AzggACgCrAEiDSAAKAKoASICa0ECSQ0PIAAgAkEBaiIKNgKoASAIIAJqQQhqLQAAQSFHDQwgACACQQJqIgs2AqgBIAggCmpBCGotAABBAUcNDCANIAtGDQ8gACACQQNqNgKoASAAKAKwCSAIIAtqQQhqLQAAEJyAgIAAIgwNDyAAKAKoASIMIAAoAqwBIgIgDCACSxshDQJAA0AgDSAMRg0BIAggDEEBaiICNgIAIAQgDGohCyACIQwgCy0AAA0ODAALCyAGQgA3AwAgAEEANgKoASAAQQM2AgAgBkEIakIANwMACyAAIAEoAgQ2AhAgACABKAIQNgIUIAAoArAJIAEQmYCAgAAhDCAAIAApA0ggASgCBCAAKAIQa618Ig43A0ggACAAKQNQIAEoAhAgACgCFCICayILrXwiDzcDUCAOIAApAzBWDQ0gDyAAKQM4Vg0NAkACQAJAAkAgACgCIEF/ag4EAAMDAQMLIAEoAgwgAmogCyAAKAIYEI2AgIAArSEODAELIAEoAgwgAmogCyAAKQMYEI+AgIAAIQ4LIAAgDjcDGAsgDEEBRw0OAkAgACkDMCIOQn9RDQAgDiAGKQMAUg0OCwJAIAApAzgiDkJ/UQ0AQQchDCAOIAApA1BSDQ8LIAAgACkDSCAANQJAfCAAKQNgfCIPNwNgQgQhDgJAAkACQCAAKAIgQX9qDgQBAgIAAgtCCCEOCyAFIA4gD3w3AwALIAAgACkDaCAAKQNQfDcDaCAAIAVBGCAAKAJwEI2AgIAANgJwIABBBDYCACAAIAApA1hCAXw3A1gLAkAgBikDACIOQgODUA0AIA5CAXwhDiABKAIEIQwgASgCCCELA0AgCyAMRg0NIAEgDEEBaiICNgIEIAEoAgAgDGotAAANDiAGIA43AwAgDkIDgyEPIA5CAXwhDiACIQwgD0IAUg0ACwsgAEEFNgIAC0EBIQIgACgCIEF/ag4EBgcHBQcLIAAgARCSgICAACIMQQFHDQsgAEEHNgIAC0EAIAAoAhBrIQggAEGAAWopAwAhDiABKAIEIQwCQANAIA4gCCAMaq18QgODUA0BAkAgDCABKAIIRw0AIAAgARCTgICAAAwLCyABIAxBAWoiAjYCBCABKAIAIAxqIQsgAiEMIAstAAANCwwACwsgACABEJOAgIAAQQchDCAFIABBkAFqQRgQhICAgAANCiAAQQg2AgALIAAgAUEgEJSAgIAAIgxBAUcNCSAAQQk2AgBBDCELIABBDDYCrAEMAQsgACgCrAEhCwsgAEGoAWogACgCqAEiDGpBCGogASgCACABKAIEIgJqIAEoAgggAmsiAiALIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0HIAAQlYCAgAAhDAwHC0EBIQIgACABQcAAEJSAgIAAIgxBAUcNBgwBC0EBIQIgACABQSAQlICAgAAiDEEBRw0FCyAAIAI2AgAMAAsLQQYhDAwCC0EAIQwMAQtBByEMCwJAAkAgACgCJA0AAkACQCAMDgIAAwELQQdBCCABKAIEIAEoAghGGyEMCyABIAk2AhAgASADNgIEIAwPCwJAIAwNACADIAEoAgRHDQAgCSABKAIQRw0AIAAtACghASAAQQE6ACggAUEDdA8LIABBADoAKAsgDAuaAQEDfwJAIAAoAgQiBA0AIABCADcDCAsgAigCACEFA0ACQCAFIANJDQBBAA8LIAEgBWotAAAhBiACIAVBAWoiBTYCACAAIAZB/wBxrSAErYYgACkDCIQ3AwgCQAJAIAZBgAFxDQACQCAGDQBBByEGIAQNAgsgAEEANgIEQQEPC0EHIQYgACAEQQdqIgQ2AgQgBEE/Rw0BCwsgBguhAgIDfwF+IABBkAFqIQIgAUEEaiEDA0ACQCAAIAEoAgAgAyABKAIIEJGAgIAAIgRBAUYNACAAQYABaiIDIAMpAwAgASgCBCAAKAIQIgNrIgKtfDcDACAAIAMgASgCAGogAiAAKAIYEI2AgIAArTcDGCAEDwsCQAJAAkACQAJAIAAoAngOAwACAQMLIAAgACkDCCIFNwOIAQJAIAUgACkDWFENAEEHDwsgAEEBNgJ4DAMLIAAgACkDmAEgACkDCHw3A5gBIAAgAkEYIAAoAqABEI2AgIAANgKgASAAQQE2AnggACAAKQOIAUJ/fCIFNwOIAQwCCyAAQQI2AnggACAAKQOQASAAKQMIfDcDkAELIAApA4gBIQULIAVCAFINAAtBAQtAAQJ/IABBgAFqIgIgAikDACABKAIEIAAoAhAiAmsiA618NwMAIAAgAiABKAIAaiADIAAoAhgQjYCAgACtNwMYC3wBBH8gASgCBCEDIAEoAgghBANAAkAgBCADRw0AQQAPCyABIANBAWoiBTYCBAJAIAEoAgAgA2otAAAgACkDGCAAKAIEIgOtiKdB/wFxRg0AQQcPCyAAIANBCGoiBjYCBCAFIQMgBiACSQ0ACyAAQQA2AgQgAEIANwMYQQELbwEBf0EHIQECQCAAQboBai8AAEHZtAFHDQAgAEG0AWpBBkEAEI2AgIAAIABBsAFqKAAARw0AIABBgAFqKQMAQgKIIAA1ALQBUg0AIABBuAFqLQAADQBBAUEHIAAoAiAgAEG5AWotAABGGyEBCyABC7QCAQR/AkACQCAAKAIkRQ0AIAAoAgAhAwwBC0EAIQMgAEEAOgAoIABCADcDACAAQgA3AxggAEHIAGpBAEHkABCGgICAABogAEGsAWpBDDYCAEEBIQILIABByABqIQQCQAJAA0ACQCADQQpHDQAgASgCBCIDIAEoAggiBUYNAiABKAIAIQYCQANAIAYgA2otAAANASABIANBAWoiAzYCBCAAIAAoAgRBAWpBA3E2AgQgBSADRg0EDAALCwJAIAAoAgRFDQBBBw8LIAAoAiRFDQAgAEEAOgAoIABCADcDACAAQgA3AxggBEEAQeQAEIaAgIAAGiAAQQw2AqwBCyAAIAEQkICAgAAiA0EBRw0CQQohAyAAQQo2AgAMAAsLAkAgAg0AQQAPC0EHQQEgACgCBBshAwsgAwt1AQF/AkBBuAkQgICAgAAiAkUNACACIAA2AiQgAiAAIAEQm4CAgAAiADYCsAkCQCAARQ0AIAJBADoAKCACQgA3AwAgAkIANwMYIAJByABqQQBB5AAQhoCAgAAaIAJBrAFqQQw2AgAgAg8LIAIQgoCAgAALQQALHgACQCAARQ0AIAAoArAJEJ2AgIAAIAAQgoCAgAALC4ARAQx/IABB6N0BaiECIABB1ABqIQMgAEEcaiIEQQhqIQUCQAJAA0AgACgCQCEGAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgASgCBCIHIAEoAggiCEkNACAGQQdGDQEMEgsgBg4JAQIDBAUGBwAJDwsgACgCTCEGDAcLQQEhCSABIAdBAWo2AgQgASgCACAHai0AACIHRQ0IAkACQCAHQd8BSw0AIAdBAUcNAQsgAEGAAjsBUAJAIAAoAjwNACAAIAEoAgwgASgCECIGajYCGCAAIAEoAhQgBms2AiwLIARCADcCACAFQgA3AgAMCwsgAC0AUEUNCgwOCyABIAdBAWo2AgQgASgCACAHai0AACEHIABBAjYCQCAAIAdBCHQgACgCSGo2AkgMDAsgASAHQQFqNgIEIAEoAgAgB2otAAAhByAAQQM2AkAgACAHIAAoAkhqQQFqNgJIDAsLIAEgB0EBajYCBCABKAIAIAdqLQAAIQcgAEEENgJAIAAgB0EIdDYCTAwKCyABIAdBAWo2AgQgASgCACAHai0AACEHIAAgACgCRDYCQCAAIAcgACgCTGpBAWo2AkwMCQsgASAHQQFqNgIEQQchCSABKAIAIAdqLQAAIgdB4AFLDQNBACEGAkACQCAHQS1PDQBBACEIDAELIAdBU2oiByAHQf8BcUEtbiIIQS1sayEHIAhBAWohCAsgAEF/IAh0QX9zNgJ0AkAgB0H/AXFBCUkNACAHQXdqIgcgB0H/AXFBCW4iBkEJbGshByAGQQFqIQYLIAAgBjYCcCAAIAdB/wFxIgc2AmwgBiAHakEESw0DIANCADcCACADQQhqQgA3AgAgA0EQakEANgIAIABBfyAGdEF/czYCcEH4ACEHA0AgACAHakGACDsBACAHQQJqIgdB5N0BRw0ACyAAQQY2AkAgAEEFNgIIIABC/////w83AgALIAAoAkwiCUEFSQ0IAkAgACgCCCIHRQ0AIAdBf2ohBiABKAIEIQcgASgCCCEKA0AgCiAHRg0LIAEgB0EBaiIINgIEIAEoAgAgB2otAAAhByAAIAY2AgggACAHIAAoAgRBCHRyNgIEIAghByAGQX9qIgZBf0cNAAsLIABBBzYCQCAAIAlBe2oiBjYCTAsgACAAKAIgIgcgASgCFCABKAIQayIIIAAoAkgiCiAIIApJGyIIaiAAKAIsIgogCiAHayAISxs2AiggASgCCCIJIAEoAgQiCGshBwJAAkACQCAAKALk3QEiCg0AIAYNAUEAIQYLIABB5N0BaiILIApqQQRqIAEoAgAgCGogByAGIAprIgZBKiAKayIIIAggBksbIgYgBiAHSxsiBxCHgICAABoCQAJAIAcgACgC5N0BIghqIgYgACgCTEcNACALIAhqIAdqQQRqQQBBPyAGaxCGgICAABogACgC5N0BIAdqIQYMAQsCQCAGQRRLDQAgACAGNgLk3QEgASABKAIEIAdqNgIEDAMLIAZBa2ohBgsgAEEANgIQIAAgAjYCDCAAIAY2AhRBByEJIAAQmoCAgABFDQMgACgCECIIIAAoAuTdASIKIAdqSw0DIAAgACgCTCAIayIGNgJMAkAgCiAITQ0AIAAgCiAIayIHNgLk3QEgAiALIAhqQQRqIAcQhYCAgAAaDAILIABBADYC5N0BIAEgASgCBCAIIApraiIINgIEIAEoAggiCSAIayEHCwJAIAdBFUkNACAAIAg2AhAgACABKAIANgIMIAAgCUFraiAIIAZqIAcgBkEVakkbNgIUQQchCSAAEJqAgIAARQ0DIAAoAkwiByAAKAIQIgggASgCBGsiBkkNAyABIAg2AgQgACAHIAZrIgY2AkwgASgCCCAIayIHQRRLDQELIAIgASgCACAIaiAGIAcgByAGSxsiBxCHgICAABogACAHNgLk3QEgASABKAIEIAdqNgIECyAAKAIgIgYgACgCHCIIayEHAkAgACgCPEUNAAJAIAYgACgCLEcNACAAQQA2AiALIAEoAgwgASgCEGogACgCGCAIaiAHEIeAgIAAGiAAKAIgIQYLIAAgBjYCHCABIAEoAhAgB2oiBjYCECAAIAAoAkggB2siBzYCSAJAIAcNAEEHIQkgACgCTA0CIAAoAmgNAiAAKAIEDQIgAEEANgJADAULQQAhCSAGIAEoAhRGDQEgASgCBCABKAIIRw0GIAAoAuTdASAAKAJMTw0GDAELIAAoAkwiCkUNAUEAIQkgCCAHTQ0AA0AgASgCFCIGIAEoAhAiC00NASAAIAogCiAAKAIsIAAoAiAiDGsiDSAIIAdrIgggBiALayIGIAggBkkbIgYgBiANSxsiBiAGIApLGyIGazYCTCAMIAAoAhhqIAEoAgAgB2ogBhCFgICAABogACAAKAIgIAZqIgc2AiACQCAAKAIkIAdPDQAgACAHNgIkCwJAIAAoAjxFDQACQCAHIAAoAixHDQAgAEEANgIgCyABKAIMIAEoAhBqIAEoAgAgASgCBGogBhCFgICAABogACgCICEHCyAAIAc2AhwgASABKAIQIAZqNgIQIAEgASgCBCAGaiIHNgIEIAAoAkwiCkUNAiABKAIIIgggB0sNAAsLIAkPCyAAQQA2AkAMAwsgB0EYdEEYdUF/Sg0BIABBATYCQCAAIAdBEHRBgID8AHE2AkgCQCAHQcABSQ0AIABBBTYCRCAAQQA6AFEMAwsgAC0AUQ0DIABBBjYCRCAHQaABSQ0CIANCADcCACADQRBqQQA2AgAgA0EIakIANwIAQfgAIQcDQCAAIAdqQYAIOwEAIAdBAmoiB0Hk3QFHDQALCyAAQQU2AgggAEL/////DzcCAAwBCyAHQQJLDQEgAEKDgICAgAE3AkAMAAsLQQcPC0EAC/8XARJ/IABBGGohAQJAIABBIGooAgAiAiAAQShqKAIAIgNPDQAgAEHoAGoiBCgCAEUNACABIAQgACgCVBCegICAABogACgCKCEDIAAoAiAhAgsCQCACIANPDQAgAEHcDWohBSAAQegAaiEGIABB4BVqIQcgAEHUAGohCANAIAAoAhAiCSAAKAIUSw0BIAAgACgCZCIKQQV0aiAAKAJ0IAJxIgtBAXRqIgxB+ABqIQ0CQAJAIAAoAgAiBEGAgIAISQ0AIAAoAgQhDgwBCyAAIARBCHQiBDYCACAAIAlBAWoiAzYCECAAIAAoAgRBCHQgACgCDCAJai0AAHIiDjYCBCADIQkLAkACQCAOIARBC3YgDS8BACIPbCIDTw0AIAAgAzYCACANIA9BgBAgD2tBBXZqOwEAIAJBf2ohBAJAIAINACAAKAIsIARqIQQLAkACQCAAKAIkIg8NAEEAIQQMAQsgACgCGCAEai0AACEECyAAKAJwIAJxIAAoAmwiDXQgBEEIIA1rdmohDAJAAkAgCkEGSw0AQQEhBANAIAAgDEGADGxqIARBAXQiBGpB5B1qIQ0CQAJAIANB////B00NACADIQoMAQsgACADQQh0Igo2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiAKQQt2IA0vAQAiD2wiA0kNACAAIA4gA2siDjYCBCAAIAogA2siAzYCACANIA8gD0EFdms7AQAgBEEBciEEDAELIAAgAzYCACANIA9BgBAgD2tBBXZqOwEACyAEQYACSQ0ADAILCyACIAAoAlQiDUF/c2ohBAJAIAIgDUsNACAAKAIsIARqIQQLAkACQCAPDQBBACEQDAELIAAoAhggBGotAAAhEAtBASEEQYACIQ0DQCAAIAxBgAxsaiAQQQF0IhAgDXEiESANaiAEakEBdGpB5B1qIQ8CQAJAIANB////B00NACADIQsMAQsgACADQQh0Igs2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiALQQt2IA8vAQAiCmwiA08iEg0AIAAgAzYCACAKQYAQIAprQQV2aiEKDAELIAAgDiADayIONgIEIAAgCyADayIDNgIAIAogCkEFdmshCkEAIQ0LIA8gCjsBACANIBFzIQ0gBEEBdCASciIEQYACSQ0ACwsgACACQQFqNgIgIAAoAhggAmogBDoAAAJAIAAoAiQgACgCICICTw0AIAAgAjYCJAtBACEDAkAgACgCZCIEQQRJDQACQCAEQQlLDQAgBEF9aiEDDAELIARBemohAwsgACADNgJkDAELIAAgDiADayIONgIEIAAgBCADayIDNgIAIA0gDyAPQQV2azsBACAAIApBAXRqIg9B+ANqIQQCQAJAIANB////B00NACAJIQoMAQsgACADQQh0IgM2AgAgACAJQQFqIgo2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQLAkACQCAOIANBC3YgBC8BACINbCIJSQ0AIAAgDiAJayIONgIEIAAgAyAJayIDNgIAIAQgDSANQQV2azsBACAPQZAEaiENAkACQCADQf///wdNDQAgCiEQDAELIAAgA0EIdCIDNgIAIAAgCkEBaiIQNgIQIAAgDkEIdCAAKAIMIApqLQAAciIONgIECwJAAkAgDiADQQt2IA0vAQAiCWwiBE8NACANIAlBgBAgCWtBBXZqOwEAIAxB2ARqIQMCQCAEQf///wdLDQAgACAEQQh0IgQ2AgAgACAQQQFqNgIQIAAgDkEIdCAAKAIMIBBqLQAAciIONgIECwJAIA4gBEELdiADLwEAIg1sIglJDQAgACAOIAlrNgIEIAAgBCAJazYCACADIA0gDUEFdms7AQAMAgsgAyANQYAQIA1rQQV2ajsBACAAIAk2AgAgAEEBNgJoIABBCUELIAAoAmRBB0kbNgJkDAMLIAAgDiAEayIONgIEIA0gCSAJQQV2azsBACAPQagEaiENAkACQCADIARrIgNB////B00NACAQIQoMAQsgACADQQh0IgM2AgAgACAQQQFqIgo2AhAgACAOQQh0IAAoAgwgEGotAAByIg42AgQLAkACQCAOIANBC3YgDS8BACIEbCIJTw0AIAAgCTYCACANIARBgBAgBGtBBXZqOwEAIAAoAlghAwwBCyAAIA4gCWsiDjYCBCANIAQgBEEFdms7AQAgD0HABGohBAJAIAMgCWsiA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgCkEBajYCECAAIA5BCHQgACgCDCAKai0AAHIiDjYCBAsCQAJAIA4gA0ELdiAELwEAIg1sIglPDQAgACAJNgIAIAQgDUGAECANa0EFdmo7AQAgACgCXCEDDAELIAAgDiAJazYCBCAAIAMgCWs2AgAgACgCYCEDIAAgACgCXDYCYCAEIA0gDUEFdms7AQALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAzYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAHIAsQn4CAgAAMAQsgBCANQYAQIA1rQQV2ajsBACAAIAk2AgAgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIAUgCxCfgICAACAAKAJoIgNBfmpBAyADQQZJGyEKIAAoAgAhA0EBIQ4DQCAAIApBB3RqIA5BAXQiDmpB2AdqIQ0CQAJAIANBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgRBAWo2AhAgACAAKAIEQQh0IAQgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgDS8BACIJbCIPSQ0AIAAgBCAPayIENgIEIAAgAyAPayIDNgIAIA0gCSAJQQV2azsBACAOQQFyIQ4MAQsgACAPNgIAIA0gCUGAECAJa0EFdmo7AQAgDyEDCyAOQcAASQ0ACwJAIA5BQGoiCUEDSw0AIAAgCTYCVAwBCyAAIA5BAXFBAnIiDTYCVCAJQQF2IQ8CQCAJQQ1LDQAgACANIA9Bf2oiDHQiCzYCVEEBIQ0gCCALQQF0akGEC2ohEEE/IA5rIRFBACEPA0AgECARIA1qQQF0aiEOAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA4vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACAOIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDUEBdEEBciENDAELIAAgAzYCACAOIAlBgBAgCWtBBXZqOwEAIA1BAXQhDQsgDCAPQQFqIg9HDQAMAgsLIA9Be2ohDgNAAkAgA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgACgCECIJQQFqNgIQIARBCHQgCSAAKAIMai0AAHIhBAsgACADQQF2IgM2AgAgACAEIANrIgRBH3UiCSANQQF0akEBaiINNgJUIAAgCSADcSAEaiIENgIEIA5Bf2oiDg0ACyAAIA1BBHQiCzYCVEEAIQ9BASEOA0AgACAOQQF0Ig5qQbwNaiENAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA0vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACANIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDkEBciEODAELIAAgAzYCACANIAlBgBAgCWtBBXZqOwEACyAPQQFqIg9BBEcNAAsLAkAgASAGIAAoAlQQnoCAgAANAEEADwsgACgCICECCyACIAAoAihJDQALC0EBIQMCQCAAKAIAIgRB////B0sNACAAIARBCHQ2AgBBASEDIAAgACgCECIEQQFqNgIQIAAgACgCBEEIdCAEIAAoAgxqLQAAcjYCBAsgAwtwAQF/AkBBqN4BEICAgIAAIgJFDQAgAkE0aiABNgIAIAJBPGogADYCAAJAAkACQCAAQX9qDgIAAQILIAIgARCAgICAACIANgIYIAANASACEIKAgIAADAILIAJBADYCGCACQThqQQA2AgALIAIPC0EAC9IBAQJ/QQYhAgJAIAFBJ0sNACAAQTBqIAFBAXFBAnIgAUEBdkELanQiATYCAAJAAkAgAEE8aigCACIDRQ0AQQQhAiABIABBNGooAgBLDQIgAEEsaiABNgIAIANBAkcNACAAQThqIgMoAgAgAU8NACAAIAE2AjggACgCGBCCgICAACAAIAAoAjAQgICAgAAiATYCGCABDQBBAyECDAELQQAhAiAAQQA2AkAgAEHQAGpBAToAACAAQegAakEANgIAIABB5N0BaiEDCyADQQA2AgALIAILIwACQCAAQTxqKAIARQ0AIAAoAhgQgoCAgAALIAAQgoCAgAAL9QEBBH9BACEDAkAgACgCDCACTQ0AIAAoAhggAk0NACABIAEoAgAiBCAAKAIQIAAoAggiBWsiBiAEIAYgBEkbIgRrNgIAIAUgAkF/c2ohAQJAIAUgAksNACAAKAIUIAFqIQELIAAoAgAiAiABai0AACEGQQEhAyAAIAVBAWo2AgggAiAFaiAGOgAAAkAgBEF/aiICRQ0AA0AgACgCACIFQQAgAUEBaiIBIAEgACgCFEYbIgFqLQAAIQQgACAAKAIIIgZBAWo2AgggBSAGaiAEOgAAIAJBf2oiAg0ACwsgACgCDCAAKAIIIgFPDQAgACABNgIMCyADC8gEAQd/AkACQCAAKAIAIgNBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAAKAIEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgAS8BACIGbCIFTw0AIAEgBkGAECAGa0EFdmo7AQAgASACQQR0akEEaiEHQQghCEECIQkMAQsgACAEIAVrIgQ2AgQgASAGIAZBBXZrOwEAAkAgAyAFayIDQf///wdLDQAgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkAgBCADQQt2IAEvAQIiBmwiBU8NACABIAZBgBAgBmtBBXZqOwECIAEgAkEEdGpBhAJqIQdBCCEIQQohCQwBCyAAIAQgBWsiBDYCBCABIAYgBkEFdms7AQIgAUGEBGohByADIAVrIQVBgAIhCEESIQkLIABB6ABqIAk2AgBBASEBA0AgByABQQF0IgFqIQMCQAJAIAVB////B00NACAFIQIMAQsgACAFQQh0IgI2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIAJBC3YgAy8BACIGbCIFSQ0AIAAgBCAFayIENgIEIAAgAiAFayIFNgIAIAMgBiAGQQV2azsBACABQQFyIQEMAQsgACAFNgIAIAMgBkGAECAGa0EFdmo7AQALIAEgCEkNAAsgAEHoAGogASAIayAJajYCAAsLNQEAQYAICy4IAAAAEAAAABgAAAAgAAAAKAAAADAAAABAAAAAUAAAAIAAAAAAAQAA/Td6WFoA\"},t=>{t.exports=e}],i={};function n(e){var r=i[e];if(void 0!==r)return r.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{XzReadableStream:()=>s});var e=n(1);const t=globalThis.ReadableStream||n(2).ReadableStream;class i{constructor(e){this.exports=e.exports,this.memory=this.exports.memory,this.ptr=this.exports.create_context(),this._refresh(),this.bufSize=this.mem32[0],this.inStart=this.mem32[1]-this.ptr,this.inEnd=this.inStart+this.bufSize,this.outStart=this.mem32[4]-this.ptr}supplyInput(e){this._refresh(),this.mem8.subarray(this.inStart,this.inEnd).set(e,0),this.exports.supply_input(this.ptr,e.byteLength),this._refresh()}getNextOutput(){const e=this.exports.get_next_output(this.ptr);if(this._refresh(),0!==e&&1!==e)throw new Error(`get_next_output failed with error code ${e}`);return{outChunk:this.mem8.slice(this.outStart,this.outStart+this.mem32[5]),finished:1===e}}needsMoreInput(){return this.mem32[2]===this.mem32[3]}outputBufferIsFull(){return this.mem32[5]===this.bufSize}resetOutputBuffer(){this.outPos=this.mem32[5]=0}dispose(){this.exports.destroy_context(this.ptr),this.exports=null}_refresh(){this.memory.buffer!==this.mem8?.buffer&&(this.mem8=new Uint8Array(this.memory.buffer,this.ptr),this.mem32=new Uint32Array(this.memory.buffer,this.ptr))}}class s extends t{static _moduleInstancePromise;static _moduleInstance;static async _getModuleInstance(){const t=e.replace(\"data:application/wasm;base64,\",\"\"),i=Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer,n=await WebAssembly.instantiate(i,{});s._moduleInstance=n.instance}constructor(e){let t,n=null;const r=e.getReader();super({async start(e){s._moduleInstance||await(s._moduleInstancePromise||(s._moduleInstancePromise=s._getModuleInstance())),t=new i(s._moduleInstance)},async pull(e){if(t.needsMoreInput()){if(null===n||0===n.byteLength){const{done:e,value:t}=await r.read();e||(n=t)}const e=Math.min(t.bufSize,n.byteLength);t.supplyInput(n.subarray(0,e)),n=n.subarray(e)}const i=t.getNextOutput();e.enqueue(i.outChunk),t.resetOutputBuffer(),i.finished&&(t.dispose(),e.close())},cancel:()=>(t.dispose(),r.cancel())})}}})(),r})(),e.exports=n(i(772))},3617:()=>{},772:()=>{},928:(e,t,i)=>{const n=i(2886).default;e.exports=n,e.exports.default=n},1308:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0});let i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];\"undefined\"!=typeof Int32Array&&(i=new Int32Array(i)),t.default=(e,t)=>{let n=0===t?0:~t;for(let t=0;t>>8;return~n}},2886:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(1308)),s=n(i(7327));t.default=(0,s.default)(\"crc-32\",r.default)},4422:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(8287);t.default=(e,t)=>n.Buffer.from(e,t)},7327:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(4422));t.default=function(e,t){const i=(e,i)=>t((0,r.default)(e),i)>>>0;return i.signed=(e,i)=>t((0,r.default)(e),i),i.unsigned=i,i.model=e,i}}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}return i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i(7806)})(),jp=[],Wp=[],Gp=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,$p=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Kp=0;Kp<64;++Kp)jp[Kp]=$p[Kp],Wp[$p.charCodeAt(Kp)]=Kp;function Yp(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function Xp(e,t,i){for(var n,r,s=[],o=t;o>18&63]+jp[r>>12&63]+jp[r>>6&63]+jp[63&r]);return s.join(\"\")}Wp[\"-\".charCodeAt(0)]=62,Wp[\"_\".charCodeAt(0)]=63;var Zp={byteLength:function(e){var t=Yp(e),i=t[0],n=t[1];return 3*(i+n)/4-n},toByteArray:function(e){var t,i,n=Yp(e),r=n[0],s=n[1],o=new Gp(function(e,t,i){return 3*(t+i)/4-i}(0,r,s)),a=0,c=s>0?r-4:r;for(i=0;i>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===s&&(t=Wp[e.charCodeAt(i)]<<2|Wp[e.charCodeAt(i+1)]>>4,o[a++]=255&t),1===s&&(t=Wp[e.charCodeAt(i)]<<10|Wp[e.charCodeAt(i+1)]<<4|Wp[e.charCodeAt(i+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o},fromByteArray:function(e){for(var t,i=e.length,n=i%3,r=[],s=16383,o=0,a=i-n;oa?a:o+s));return 1===n?(t=e[i-1],r.push(jp[t>>2]+jp[t<<4&63]+\"==\")):2===n&&(t=(e[i-2]<<8)+e[i-1],r.push(jp[t>>10]+jp[t>>4&63]+jp[t<<2&63]+\"=\")),r.join(\"\")}};\n", - "/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Jp={read:function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},write:function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}};\n", - "/*!\n", - " * The buffer module from node.js, for the browser.\n", - " *\n", - " * @author Feross Aboukhadijeh \n", - " * @license MIT\n", - " */const eg=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null,tg=2147483647;function ig(e){if(e>tg)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,ng.prototype),t}function ng(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return og(e)}return rg(e,t,i)}function rg(e,t,i){if(\"string\"==typeof e)return function(e,t){\"string\"==typeof t&&\"\"!==t||(t=\"utf8\");if(!ng.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|hg(e,t);let n=ig(i);const r=n.write(e,t);r!==i&&(n=n.slice(0,r));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Vg(e,Uint8Array)){const t=new Uint8Array(e);return cg(t.buffer,t.byteOffset,t.byteLength)}return ag(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(Vg(e,ArrayBuffer)||e&&Vg(e.buffer,ArrayBuffer))return cg(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(Vg(e,SharedArrayBuffer)||e&&Vg(e.buffer,SharedArrayBuffer)))return cg(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return ng.from(n,t,i);const r=function(e){if(ng.isBuffer(e)){const t=0|lg(e.length),i=ig(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return\"number\"!=typeof e.length||jg(e.length)?ig(0):ag(e);if(\"Buffer\"===e.type&&Array.isArray(e.data))return ag(e.data)}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return ng.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function sg(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function og(e){return sg(e),ig(e<0?0:0|lg(e))}function ag(e){const t=e.length<0?0:0|lg(e.length),i=ig(t);for(let n=0;n=tg)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+tg.toString(16)+\" bytes\");return 0|e}function hg(e,t){if(ng.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Vg(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return Ug(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return qg(e).length;default:if(r)return n?-1:Ug(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function dg(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return xg(this,t,i);case\"utf8\":case\"utf-8\":return yg(this,t,i);case\"ascii\":return Cg(this,t,i);case\"latin1\":case\"binary\":return _g(this,t,i);case\"base64\":return vg(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return kg(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function ug(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function fg(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),jg(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=ng.from(t,n)),ng.isBuffer(t))return 0===t.length?-1:pg(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):pg(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function pg(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function vg(e,t,i){return 0===t&&i===e.length?Zp.fromByteArray(e):Zp.fromByteArray(e.slice(t,i))}function yg(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=Ag)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(ng.isBuffer(t)||(t=ng.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!ng.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},ng.byteLength=hg,ng.prototype._isBuffer=!0,ng.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;tt&&(e+=\" ... \"),\"\"},eg&&(ng.prototype[eg]=ng.prototype.inspect),ng.prototype.compare=function(e,t,i,n,r){if(Vg(e,Uint8Array)&&(e=ng.from(e,e.offset,e.byteLength)),!ng.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),c=this.slice(n,r),l=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return gg(this,e,t,i);case\"utf8\":case\"utf-8\":return mg(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return wg(this,e,t,i);case\"base64\":return bg(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return Fg(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},ng.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const Ag=4096;function Cg(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function Sg(e,t,i,n,r,s){if(!ng.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function Eg(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function Ng(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function Bg(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function Mg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,4),Jp.write(e,t,i,n,23,4),i+4}function Rg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,8),Jp.write(e,t,i,n,52,8),i+8}ng.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},ng.prototype.readUint8=ng.prototype.readUInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),this[e]},ng.prototype.readUint16LE=ng.prototype.readUInt16LE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]|this[e+1]<<8},ng.prototype.readUint16BE=ng.prototype.readUInt16BE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]<<8|this[e+1]},ng.prototype.readUint32LE=ng.prototype.readUInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ng.prototype.readUint32BE=ng.prototype.readUInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ng.prototype.readBigUInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},ng.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||Ig(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},ng.prototype.readInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ng.prototype.readInt16LE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt16BE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ng.prototype.readInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ng.prototype.readBigInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!0,23,4)},ng.prototype.readFloatBE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!1,23,4)},ng.prototype.readDoubleLE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!0,52,8)},ng.prototype.readDoubleBE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!1,52,8)},ng.prototype.writeUintLE=ng.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},ng.prototype.writeUint8=ng.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,255,0),this[t]=255&e,t+1},ng.prototype.writeUint16LE=ng.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeUint16BE=ng.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeUint32LE=ng.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},ng.prototype.writeUint32BE=ng.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigUInt64LE=Gg((function(e,t=0){return Eg(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeBigUInt64BE=Gg((function(e,t=0){return Ng(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},ng.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},ng.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},ng.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigInt64LE=Gg((function(e,t=0){return Eg(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeBigInt64BE=Gg((function(e,t=0){return Ng(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeFloatLE=function(e,t,i){return Mg(this,e,t,!0,i)},ng.prototype.writeFloatBE=function(e,t,i){return Mg(this,e,t,!1,i)},ng.prototype.writeDoubleLE=function(e,t,i){return Rg(this,e,t,!0,i)},ng.prototype.writeDoubleBE=function(e,t,i){return Rg(this,e,t,!1,i)},ng.prototype.copy=function(e,t,i,n){if(!ng.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function zg(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new Dg.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Hg(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||Pg(t,e.length-(i+1))}(n,r,s)}function Hg(e,t){if(\"number\"!=typeof e)throw new Dg.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function Pg(e,t,i){if(Math.floor(e)!==e)throw Hg(e,i),new Dg.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new Dg.ERR_BUFFER_OUT_OF_BOUNDS;throw new Dg.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}Tg(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),Tg(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),Tg(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=Lg(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=Lg(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const Og=/[^+/0-9A-Za-z-_]/g;function Ug(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function qg(e){return Zp.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(Og,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function Qg(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Vg(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function jg(e){return e!=e}const Wg=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Gg(e){return\"undefined\"==typeof BigInt?$g:e}function $g(){throw new Error(\"BigInt not supported\")}class Kg{constructor(e,t){this.position=0,this.url=e,this.config=t,Ht(e)||!1===t.cacheFetches?this.useCache=!1:(this.useCache=!0,this.cache=new Yg({fetch:(e,t)=>this._fetch(e,t),fetchSize:t.fetchSize||1e4}))}async _fetch(e,t){const i={start:e,size:t};this._stat={size:void 0};const n=await Qs.loadArrayBuffer(this.url,Ua(this.config,{range:i}));return ng.from(n)}async read(e,t=0,i=1/0,n=0){if(this.useCache)await this.cache.get(e,t,n,i);else{(await this._fetch(n,i)).copy(e,t)}return{bytesRead:i,buffer:e}}async readFile(){const e=await Qs.loadArrayBuffer(this.url,Ua(this.config));return ng.from(e)}async stat(){if(!this._stat){const e=ng.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class Yg{constructor({fetch:e,fetchSize:t=3e4}){this.fetch=e,this.position=0,this.buffer=ng.allocUnsafe(0),this.fetchSize=t}async get(e,t,i,n){if(e.length=this.position&&i+n<=this.position+this.buffer.length);else{const e=Math.max(n,this.fetchSize);this.buffer=await this.fetch(i,e),this.position=i}const r=t,s=i-this.position,o=s+n;this.buffer.copy(e,r,s,o)}}class Xg{chrAliasTable=new Map;constructor(e,t,i){this.config=e,this.browser=i,this.genome=t,this.cramFile=new Vp.CramFile({filehandle:e.fileHandle?e.fileHandle:new Kg(e.url,e),seqFetch:e.seqFetch||async function(e,t,i){const n=this.genome,r=await this.getHeader(),s=n.getChromosomeName(r.indexToChr[e]);return this.genome.getSequence(s,t-1,i)}.bind(this),checkSequenceMD5:void 0===e.checkSequenceMD5||e.checkSequenceMD5});const n=e.indexFileHandle?e.indexFileHandle:new Kg(e.indexURL,e);this.indexedCramFile=new Vp.IndexedCramFile({cram:this.cramFile,index:new Vp.CraiIndex({filehandle:n}),fetchSizeLimit:e.fetchSizeLimit||1e9}),Mp.setReaderDefaults(this,e)}async getHeader(){if(!this.header){const e=await this.cramFile.getSamHeader(),t={},i=[],n=[];for(let r of e)if(\"SQ\"===r.tag){for(let e of r.data)if(\"SN\"===e.tag){const n=e.value;t[n]=i.length,i.push(n);break}}else\"RG\"===r.tag&&n.push(r.data);this.header={indexToChr:i,chrToIndex:t,chrNames:Object.keys(t),readGroups:n}}return this.header}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async readAlignments(e,t,i){const n=await this.getHeader(),r=await this.#x(e),s=new tp(e,t,i,this.config);if(void 0===r)return s;try{const e=await this.indexedCramFile.getRecordsForRange(r,t,i);for(let a of e){const e=a.sequenceId,c=a.alignmentStart,l=c+a.lengthOnRef;if(e<0)continue;if(e>r||c>i)return;if(e=0&&(t=\"Sequence mismatch. Is this the correct genome for the loaded CRAM?\"),this.browser.alert.present(new Error(t)),e}function o(e,t){const i=new wp;if(i.chr=t[e.sequenceId],i.start=e.alignmentStart-1,i.lengthOnRef=e.lengthOnRef,i.flags=e.flags,i.strand=!(16&e.flags),i.fragmentLength=e.templateLength||e.templateSize,i.mq=e.mappingQuality,i.end=e.alignmentStart+e.lengthOnRef,i.readGroupId=e.readGroupId,e.mate&&void 0!==e.mate.sequenceId){const n=void 0!==e.mate.flags?!(1&e.mate.flags):!(32&e.flags);i.mate={chr:t[e.mate.sequenceId],position:e.mate.alignmentStart,strand:n}}return i.seq=e.getReadBases(),i.qual=e.qualityScores,i.tagDict=e.tags,i.readName=e.readName,function(e,t){const i=[];let n,r,s=0,o=\"\";if(t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef,e.readFeatures)for(let a of e.readFeatures){const e=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(e){case\"S\":case\"I\":case\"i\":case\"N\":case\"D\":if(l>s){const e=l-s;i.push(new xp({start:h-e,seqOffset:s,len:e,type:\"M\"})),s+=e,o+=e+\"M\"}if(\"S\"===e){let n=h;t.scLengthOnRef+=c.length,0===l&&(t.scStart-=c.length,n-=c.length);const r=c.length;i.push(new xp({start:n,seqOffset:s,len:r,type:\"S\"})),s+=r,o+=r+e}else if(\"I\"===e||\"i\"===e){void 0===n&&(n=[]);const t=\"i\"===e?1:c.length;n.push(new xp({start:h,len:t,seqOffset:s,type:\"I\"})),s+=t,o+=t+e}else\"D\"!==e&&\"N\"!==e||(r||(r=[]),r.push({start:h,len:c,type:e}),o+=c+e);break;case\"H\":case\"P\":o+=c+e}}const a=e.readLength-s;a>0&&(i.push(new xp({start:e.alignmentStart+e.lengthOnRef-a-1,seqOffset:s,len:a,type:\"M\"})),o+=a+\"M\");t.blocks=i,t.insertions=n,t.gaps=r,t.cigar=o}(e,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Mp.setPairOrientation(i),i}}}const Zg=2291137574,Jg=2273964779,em=[84,68,70,52],tm=new Uint8Array([66,65,77,1]),im=[67,82,65,77],nm=[31,139],rm=4,sm=new Set([\"narrowpeak\",\"broadpeak\",\"regionpeak\",\"peaks\",\"bedgraph\",\"wig\",\"gff3\",\"gff\",\"gtf\",\"fusionjuncspan\",\"refflat\",\"seg\",\"aed\",\"bed\",\"bedMethyl\",\"vcf\",\"bb\",\"bigbed\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"bw\",\"bigwig\",\"bam\",\"tdf\",\"refgene\",\"genepred\",\"genepredext\",\"bedpe\",\"bp\",\"snp\",\"rmsk\",\"cram\",\"gwas\",\"maf\",\"mut\",\"hiccups\",\"fasta\",\"fa\",\"fna\",\"pytor\",\"hic\",\"qtl\"]);function om(e,t){const i=Math.min(e.length,t.length);if(0==i)return!1;for(let n=0;n=this.start&&e.end<=this.end}overlaps(e){return e.chr===this.chr&&!(e.endthis.end)}extend(e){e.chr===this.chr&&(this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}getLocusString(){if(\"all\"===this.chr)return\"all\";{const e=Rt(Math.floor(this.start)+1),t=Rt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}static fromLocusString(e){if(\"all\"===e)return new lm({chr:\"all\"});const t=e.split(\":\"),i=t[0],n=t[1].split(\"-\"),r=Number.parseInt(n[0].replace(/,/g,\"\"))-1,s=Number.parseInt(n[1].replace(/,/g,\"\"));return new lm({chr:i,start:r,end:s})}}\n", - "/*!\n", - " * vanilla-picker v2.12.1\n", - " * https://vanilla-picker.js.org\n", - " *\n", - " * Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)\n", - " * Released under the ISC license.\n", - " */var hm=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},dm=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1;return(t>0?e.toFixed(t).replace(/0+$/,\"\").replace(/\\.$/,\"\"):e.toString())||\"0\"}var gm=function(){function e(t,i,n,r){hm(this,e);var s=this;if(void 0===t);else if(Array.isArray(t))this.rgba=t;else if(void 0===n){var o=t&&\"\"+t;o&&function(t){if(t.startsWith(\"hsl\")){var i=t.match(/([\\-\\d\\.e]+)/g).map(Number),n=um(i,4),r=n[0],o=n[1],a=n[2],c=n[3];void 0===c&&(c=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,c]}else if(t.startsWith(\"rgb\")){var l=t.match(/([\\-\\d\\.e]+)/g).map(Number),h=um(l,4),d=h[0],u=h[1],f=h[2],p=h[3];void 0===p&&(p=1),s.rgba=[d,u,f,p]}else t.startsWith(\"#\")?s.rgba=e.hexToRgb(t):s.rgba=e.nameToRgb(t)||e.hexToRgb(t)}(o.toLowerCase())}else this.rgba=[t,i,n,void 0===r?1:r]}return dm(e,[{key:\"printRGB\",value:function(e){var t=(e?this.rgba:this.rgba.slice(0,3)).map((function(e,t){return pm(e,3===t?3:0)}));return e?\"rgba(\"+t+\")\":\"rgb(\"+t+\")\"}},{key:\"printHSL\",value:function(e){var t=[360,100,100,1],i=[\"\",\"%\",\"%\",\"\"],n=(e?this.hsla:this.hsla.slice(0,3)).map((function(e,n){return pm(e*t[n],3===n?3:1)+i[n]}));return e?\"hsla(\"+n+\")\":\"hsl(\"+n+\")\"}},{key:\"printHex\",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:\"rgba\",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error(\"No color is set\");return this._rgba=e.hslToRgb(this._hsla)},set:function(e){3===e.length&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:\"rgbString\",get:function(){return this.printRGB()}},{key:\"rgbaString\",get:function(){return this.printRGB(!0)}},{key:\"hsla\",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error(\"No color is set\");return this._hsla=e.rgbToHsl(this._rgba)},set:function(e){3===e.length&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:\"hslString\",get:function(){return this.printHSL()}},{key:\"hslaString\",get:function(){return this.printHSL(!0)}},{key:\"hex\",get:function(){var e=this.rgba.map((function(e,t){return t<3?e.toString(16):Math.round(255*e).toString(16)}));return\"#\"+e.map((function(e){return e.padStart(2,\"0\")})).join(\"\")},set:function(t){this.rgba=e.hexToRgb(t)}}],[{key:\"hexToRgb\",value:function(e){var t=(e.startsWith(\"#\")?e.slice(1):e).replace(/^(\\w{3})$/,\"$1F\").replace(/^(\\w)(\\w)(\\w)(\\w)$/,\"$1$1$2$2$3$3$4$4\").replace(/^(\\w{6})$/,\"$1FF\");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error(\"Unknown hex color; \"+e);var i=t.match(/^(\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)$/).slice(1).map((function(e){return parseInt(e,16)}));return i[3]=i[3]/255,i}},{key:\"nameToRgb\",value:function(t){var i=t.toLowerCase().replace(\"at\",\"T\").replace(/[aeiouyldf]/g,\"\").replace(\"ght\",\"L\").replace(\"rk\",\"D\").slice(-5,4),n=fm[i];return void 0===n?n:e.hexToRgb(n.replace(/\\-/g,\"00\").padStart(6,\"f\"))}},{key:\"rgbToHsl\",value:function(e){var t=um(e,4),i=t[0],n=t[1],r=t[2],s=t[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),c=void 0,l=void 0,h=(o+a)/2;if(o===a)c=l=0;else{var d=o-a;switch(l=h>.5?d/(2-o-a):d/(o+a),o){case i:c=(n-r)/d+(n1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e},h=r<.5?r*(1+n):r+n-r*n,d=2*r-h;o=l(d,h,i+1/3),a=l(d,h,i),c=l(d,h,i-1/3)}var u=[255*o,255*a,255*c].map(Math.round);return u[3]=s,u}}]),e}(),mm=function(){function e(){hm(this,e),this._events=[]}return dm(e,[{key:\"add\",value:function(e,t,i){e.addEventListener(t,i,!1),this._events.push({target:e,type:t,handler:i})}},{key:\"remove\",value:function(t,i,n){this._events=this._events.filter((function(r){var s=!0;return t&&t!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&e._doRemove(r.target,r.type,r.handler),!s}))}},{key:\"destroy\",value:function(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)})),this._events=[]}}],[{key:\"_doRemove\",value:function(e,t,i){e.removeEventListener(t,i,!1)}}]),e}();function wm(e,t,i){var n=!1;function r(e,t,i){return Math.max(t,Math.min(e,i))}function s(e,s,o){if(o&&(n=!0),n){e.preventDefault();var a=t.getBoundingClientRect(),c=a.width,l=a.height,h=s.clientX,d=s.clientY,u=r(h-a.left,0,c),f=r(d-a.top,0,l);i(u/c,f/l)}}function o(e,t){1===(void 0===e.buttons?e.which:e.buttons)?s(e,e,t):n=!1}function a(e,t){1===e.touches.length?s(e,e.touches[0],t):n=!1}e.add(t,\"mousedown\",(function(e){o(e,!0)})),e.add(t,\"touchstart\",(function(e){a(e,!0)})),e.add(window,\"mousemove\",o),e.add(t,\"touchmove\",a),e.add(window,\"mouseup\",(function(e){n=!1})),e.add(t,\"touchend\",(function(e){n=!1})),e.add(t,\"touchcancel\",(function(e){n=!1}))}var bm=\"keydown\",Fm=\"mousedown\",vm=\"focusin\";function ym(e,t){return(t||document).querySelector(e)}function Am(e){e.preventDefault(),e.stopPropagation()}function Cm(e,t,i,n,r){e.add(t,bm,(function(e){i.indexOf(e.key)>=0&&(r&&Am(e),n(e))}))}var _m=function(){function e(t){hm(this,e),this.settings={popup:\"right\",layout:\"default\",alpha:!0,editor:!0,editorFormat:\"hex\",cancelButton:!1,defaultColor:\"#0cf\"},this._events=new mm,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(t)}return dm(e,[{key:\"setOptions\",value:function(e){var t=this;if(e){var i=this.settings;if(e instanceof HTMLElement)i.parent=e;else{i.parent&&e.parent&&i.parent!==e.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(e,t,i){for(var n in e)i&&i.indexOf(n)>=0||(t[n]=e[n])}(e,i),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var n=e.color||e.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(e){return t.openHandler(e)};this._events.add(r,\"click\",s),Cm(this._events,r,[\" \",\"Spacebar\",\"Enter\"],s),this._popupInited=!0}else e.parent&&!i.popup&&this.show()}}},{key:\"openHandler\",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents=\"none\";var t=e&&e.type===bm?this._domEdit:this.domElement;setTimeout((function(){return t.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:\"closeHandler\",value:function(e){var t=e&&e.type,i=!1;if(e)if(t===Fm||t===vm){var n=(this.__containedEvent||0)+100;e.timeStamp>n&&(i=!0)}else Am(e),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents=\"\",t!==Fm&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:\"movePopup\",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:\"setColor\",value:function(e,t){this._setColor(e,{silent:t})}},{key:\"_setColor\",value:function(e,t){if(\"string\"==typeof e&&(e=e.trim()),e){t=t||{};var i=void 0;try{i=new gm(e)}catch(e){if(t.failSilently)return;throw e}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,t)}}},{key:\"setColour\",value:function(e,t){this.setColor(e,t)}},{key:\"show\",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var e=this._toggleDOM(!0);return this._setPosition(),e}var t=function(e){var t=document.createElement(\"div\");return t.innerHTML=e,t.firstElementChild}(this.settings.template||'
');return this.domElement=t,this._domH=ym(\".picker_hue\",t),this._domSL=ym(\".picker_sl\",t),this._domA=ym(\".picker_alpha\",t),this._domEdit=ym(\".picker_editor input\",t),this._domSample=ym(\".picker_sample\",t),this._domOkay=ym(\".picker_done button\",t),this._domCancel=ym(\".picker_cancel button\",t),t.classList.add(\"layout_\"+this.settings.layout),this.settings.alpha||t.classList.add(\"no_alpha\"),this.settings.editor||t.classList.add(\"no_editor\"),this.settings.cancelButton||t.classList.add(\"no_cancel\"),this._ifPopup((function(){return t.classList.add(\"popup\")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:\"hide\",value:function(){return this._toggleDOM(!1)}},{key:\"destroy\",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:\"_bindEvents\",value:function(){var e=this,t=this,i=this.domElement,n=this._events;function r(e,t,i){n.add(e,t,i)}r(i,\"click\",(function(e){return e.preventDefault()})),wm(n,this._domH,(function(e,i){return t._setHSLA(e)})),wm(n,this._domSL,(function(e,i){return t._setHSLA(null,e,1-i)})),this.settings.alpha&&wm(n,this._domA,(function(e,i){return t._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,\"input\",(function(e){t._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,\"focus\",(function(e){var t=this;t.selectionStart===t.selectionEnd&&t.select()})),this._ifPopup((function(){var t=function(t){return e.closeHandler(t)};r(window,Fm,t),r(window,vm,t),Cm(n,i,[\"Esc\",\"Escape\"],t);var s=function(t){e.__containedEvent=t.timeStamp};r(i,Fm,s),r(i,vm,s),r(e._domCancel,\"click\",t)}));var o=function(t){e._ifPopup((function(){return e.closeHandler(t)})),e.onDone&&e.onDone(e.colour)};r(this._domOkay,\"click\",o),Cm(n,i,[\"Enter\"],o)}},{key:\"_setPosition\",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup((function(i){\"static\"===getComputedStyle(e).position&&(e.style.position=\"relative\");var n=!0===i?\"popup_right\":\"popup_\"+i;[\"popup_top\",\"popup_bottom\",\"popup_left\",\"popup_right\"].forEach((function(e){e===n?t.classList.add(e):t.classList.remove(e)})),t.classList.add(n)}))}},{key:\"_setHSLA\",value:function(e,t,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[e,t,i,n].forEach((function(e,t){(e||0===e)&&(o[t]=e)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:\"_updateUI\",value:function(e){if(this.domElement){e=e||{};var t=this.colour,i=t.hsla,n=\"hsl(\"+360*i[0]+\", 100%, 50%)\",r=t.hslString,s=t.hslaString,o=this._domH,a=this._domSL,c=this._domA,l=ym(\".picker_selector\",o),h=ym(\".picker_selector\",a),d=ym(\".picker_selector\",c);b(0,l,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,b(0,h,i[1]),F(0,h,1-i[2]),a.style.color=r,F(0,d,1-i[3]);var u=r,f=u.replace(\"hsl\",\"hsla\").replace(\")\",\", 0)\"),p=\"linear-gradient(\"+[u,f]+\")\";if(this._domA.style.background=p+\", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em\",!e.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,w=void 0;switch(g){case\"rgb\":w=t.printRGB(m);break;case\"hsl\":w=t.printHSL(m);break;default:w=t.printHex(m)}this._domEdit.value=w}this._domSample.style.color=s}function b(e,t,i){t.style.left=100*i+\"%\"}function F(e,t,i){t.style.top=100*i+\"%\"}}},{key:\"_ifPopup\",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:\"_toggleDOM\",value:function(e){var t=this.domElement;if(!t)return!1;var i=e?\"\":\"none\",n=t.style.display!==i;return n&&(t.style.display=i),n}}]),e}(),xm=document.createElement(\"style\");function km(e){if(Im[e])return Im[e];if(Im[\"chr\"+e]){const t=Im[\"chr\"+e];return Im[e]=t,t}{const r=(t=Math.round(255*Math.random()).toString(10),i=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),\"rgb(\"+t+\",\"+i+\",\"+n+\")\");return Im[e]=r,r}var t,i,n}xm.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:\"\";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:\"\";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:\"\";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(xm),_m.StyleElement=xm;const Im={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};class Sm{constructor(e){this.tracks=[],this.chordSets=[]}addChordSet(e){this.chordSets=this.chordSets.filter((t=>t.name!==e.name)),this.chordSets.push(e);let t=this.tracks.find((t=>e.trackName===t.name));t&&(t.chordSets=t.chordSets.filter((t=>t.name!==e.name)),t.chordSets.push(e)),t||(t=new Em(e),this.tracks.push(t))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(e){return this.tracks.find((t=>e===t.name))}getChordSet(e){return this.chordSets.find((t=>e===t.name))}}class Em{constructor(e){this.name=e.trackName,this.color=e.trackColor,this.visible=!0,this.chordSets=[e],this.id=(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const e=[];for(let t of this.chordSets)for(let i of t.chords)e.push(i);return e}}const Nm=Math.exp(5);class Bm{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(e,t){if(t=t||{},this.config=t,Bm.isInstalled()){this.parent=e,this.groupByTrack=!0===t.groupByTrack,this.chordManager=new Sm(t);const i=document.createElement(\"div\");i.className=\"igv-circview-container\",e.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement(\"div\");n.className=\"igv-circview-circular-genome-view\",i.appendChild(n),this.container=n,t.assembly&&this.setAssembly(t.assembly),this.width=t.width||500,this.height=t.height||500,this.setSize(this.width,this.height)}else console.error(\"JBrowse circular view is not installed\")}createControls(e){const t=document.createElement(\"div\");t.className=\"igv-circview-toolbar\",e.appendChild(t),this.toolbar=t;const i=document.createElement(\"div\");i.className=\"igv-circview-track-panel\",e.appendChild(i),this.controlPanel=i,this.controlPanel.style.display=\"none\";const n=document.createElement(\"div\");n.className=\"igv-circview-toolbar-button-container\",this.toolbar.appendChild(n),this.showControlsButton=document.createElement(\"div\"),this.showControlsButton.className=\"igv-circview-button\",n.appendChild(this.showControlsButton),this.showControlsButton.innerText=\"none\"===this.controlPanel.style.display?\"Show Controls\":\"Hide Controls\",this.showControlsButton.addEventListener(\"click\",(e=>{this.controlPanel.querySelectorAll(\"div\").length>0&&(\"none\"===this.controlPanel.style.display?(this.controlPanel.style.display=\"flex\",e.target.innerText=\"Hide Controls\"):(this.controlPanel.style.display=\"none\",e.target.innerText=\"Show Controls\"))}));let r=document.createElement(\"div\");r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Clear All\",r.addEventListener(\"click\",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement(\"div\"),r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Close\",r.addEventListener(\"click\",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML=\"\",this.controlPanel.appendChild(this.createGroupByCB());const e=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let t of e)this.addToControlPanel(t)}createGroupByCB(){const e=document.createElement(\"input\");e.type=\"checkbox\",e.id=\"groupByCB\",e.style.width=\"1.4em\",e.style.height=\"1.4em\",e.checked=this.groupByTrack,e.onclick=e=>{this.groupByTrack=e.target.checked,this.resetControlPanel(),this.render()};const t=document.createElement(\"label\");t.for=\"groupByCB\",t.innerText=\"Group by track\",t.style.color=\"black\",t.style.paddingLeft=\"10px\";const i=document.createElement(\"div\");return i.style.width=\"100%\",i.style.paddingTop=\"5px\",i.style.paddingBottom=\"5px\",i.style.background=\"rgb(216, 230, 234)\",i.appendChild(e),i.appendChild(t),i}addToControlPanel(e){const t=document.createElement(\"div\");this.controlPanel.appendChild(t);const i=document.createElement(\"div\");i.className=\"igv-circview-button\",t.appendChild(i),i.innerText=!0===e.visible?\"Hide\":\"Show\",i.addEventListener(\"click\",(t=>{!0===e.visible?(this.hideChordSet(e.name),t.target.innerText=\"Show\"):(this.showChordSet(e.name),t.target.innerText=\"Hide\")}));const n=document.createElement(\"input\"),r=e=>200*Math.log(e*Nm),s=document.createElement(\"div\");s.className=\"igv-circview-button\",s.innerHTML=\"    \",t.appendChild(s),s.style.backgroundColor=Mm(e.color,1);const o={parent:s,popup:\"right\",editorFormat:\"rgb\",color:e.color,onChange:({rgbaString:t})=>{s.style.backgroundColor=Mm(t,1),this.setColor(e.name,t),n.value=r(Rm(e.color))}},a=new _m(o);n.setAttribute(\"title\",\"Adjust transparency of arcs\"),n.type=\"range\",n.style.width=\"100px\",n.style.marginRight=\"10px\",n.setAttribute(\"class\",\"range\"),n.setAttribute(\"min\",\"0\"),n.setAttribute(\"max\",\"1000\"),n.value=r(Rm(e.color)),n.oninput=()=>{const t=(i=n.value,Math.exp(i/200)/Nm);var i;this.setColor(e.name,Mm(e.color,t)),a.setColor(e.color)},t.appendChild(n);const c=document.createElement(\"div\");c.style.color=\"black\",t.appendChild(c),c.innerText=c.title=e.name}setAssembly(e){const t=this.genomeId||Lm();if(this.genomeId===t)return;this.chordManager.clearChords(),this.genomeId=t,this.chrNames=new Set(e.chromosomes.map((e=>Dm(e.name))));const i=[],n=[];for(let t of e.chromosomes){const e=Dm(t.name);n.push(t.color||km(e)),i.push({refName:e,uniqueId:e,start:0,end:t.bpLength})}this.assembly={name:e.name,sequence:{trackId:t,type:\"ReferenceSequenceTrack\",adapter:{type:\"FromConfigSequenceAdapter\",features:i}},refNameColors:n},this.render()}addChords(e,t={}){const i=t.name||t.track||\"*\",n=i.split(\" \")[0].replaceAll(\"%20\",\" \"),r={name:i.replaceAll(\"%20\",\" \"),trackName:n,chords:e,color:t.color||\"black\",trackColor:t.trackColor||t.color||\"black\",visible:!0,id:t.id||Lm()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(e,t){if(t=t||e,this.width=e,this.height=t,this.viewState){const i=this.viewState.session.view;i.setWidth(e),i.setHeight(t),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display=\"block\"}hide(){this.parent.style.display=\"none\"}get visible(){return\"none\"!==this.parent.style.display}set visible(e){this.parent.style.display=e?\"block\":\"none\"}hideChordSet(e){let t=this.getChordSet(e);t?(t.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(e){let t=this.getChordSet(e);t?(t.visible=!0,this.render()):console.warn(`No track with name: ${e}`)}deleteTrack(e){let t=this.tracks.findIndex((t=>e===t.name));t>=0&&this.tracks.splice(t,1),this.render()}getChordSet(e){return this.groupByTrack?this.chordManager.getTrack(e):this.chordManager.getChordSet(e)}setColor(e,t){const i=this.getChordSet(e);if(i){i.color=t;const e=i.id;for(let i of this.viewState.config.tracks)if(e===i.trackId){i.displays[0].renderer.strokeColor.set(t);break}}}render(){const{createViewState:e,JBrowseCircularGenomeView:t}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((e=>e.visible)),n=[],r=[];for(let e of i)n.push({trackId:e.id,name:e.name,assemblyNames:[\"forIGV\"],type:\"VariantTrack\",adapter:{type:\"FromConfigAdapter\",features:e.chords}}),r.push(e.color);this.viewState=e({assembly:this.assembly,tracks:n});for(let e=0;e div {\\n margin: 4px;\\n}\\n\\n.igv-circview-track-panel {\\n z-index: 1024;\\n position: absolute;\\n top: 33px;\\n left: 0;\\n width: 100%;\\n height: fit-content;\\n border-bottom-style: solid;\\n border-bottom-color: dimgray;\\n border-bottom-width: thin;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n.igv-circview-track-panel > div {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-circview-track-panel > div > div {\\n margin: 4px;\\n}\\n\\n.igv-circview-swatch-button {\\n cursor: pointer;\\n padding: 5px;\\n width: 8px;\\n height: 8px;\\n border: 1px solid #8d8b8b;\\n border-radius: 16px;\\n}\\n\\n.igv-circview-button {\\n cursor: pointer;\\n padding: 5px;\\n color: #444;\\n vertical-align: middle;\\n text-align: center;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n border: 1px solid #8d8b8b;\\n border-radius: 4px;\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\\n}\\n\\n.igv-circview-button:hover {\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n.igv-circview-button:active {\\n color: #007bff;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n/*# sourceMappingURL=circular-view.css.map */\\n',document.head.insertBefore(e,document.head.childNodes[document.head.childNodes.length-1])}()}const zm=e=>e.startsWith(\"chr\")?e.substring(3):e;function Hm(e){const t=[],i=[];if(e.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n);i.push(Nu(r.name)),t.push({name:r.name,bpLength:r.bpLength})}return t}function Pm(e,t,i,n){const r=t.color||\"rgb(0,0,255)\",s=_s.addAlpha(\"all\"===i.chr?r:Nu(i.chr),n),o=_s.addAlpha(r,n),a=t.name.replaceAll(\" \",\"%20\"),c=\"all\"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;t.browser.circularView.addChords(e,{track:c,color:s,trackColor:o}),t.browser.circularViewVisible||(t.browser.circularViewVisible=!0)}class Om{constructor(e,{minTLENPercentile:t,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===t?.1:t,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(e)}compute(e){for(let n of e)if(n.isProperPair()){var t=Math.abs(n.fragmentLength);this.sumF+=t,this.sumF2+=t*t,this.isizes.push(t);var i=n.pairOrientation;if(\"string\"==typeof i&&4===i.length)switch(\"\"+i.charAt(0)+i.charAt(2)){case\"FF\":case\"RR\":this.ffCount++;break;case\"FR\":this.frCount++;break;case\"RF\":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation=\"ff\":this.frCount/this.totalCount>.9?this.orienation=\"fr\":this.rfCount/this.totalCount>.9&&(this.orienation=\"rf\"),this.minTLEN=0===this.lp?0:Um(this.isizes,this.lp),this.maxTLEN=Um(this.isizes,this.up)}}function Um(e,t){if(0!==e.length){var i=Math.floor(e.length*(t/100));return e.sort((function(e,t){return e-t})),e[i]}}const qm=\"rgb(255,0,255)\",Qm=\"rgb(0,0,255)\",Vm=\"rgb(132, 178, 158)\",jm=new Map;jm.set(\"m\",\"rgb(255,0,0)\"),jm.set(\"h\",qm),jm.set(\"o\",\"rgb(111, 78, 129)\"),jm.set(\"f\",\"rgb(246, 200, 95)\"),jm.set(\"c\",\"rgb(157, 216, 102)\"),jm.set(\"g\",\"rgb(255, 160, 86)\"),jm.set(\"e\",\"rgb(141, 221, 208)\"),jm.set(\"b\",\"rgb(202, 71, 47)\"),jm.set(\"h\",qm),jm.set(\"a\",\"rgb(51,0,111)\"),jm.set(\"NONE_A\",Qm),jm.set(\"NONE_C\",Qm),jm.set(\"NONE_T\",Qm),jm.set(\"NONE_G\",Qm),jm.set(\"NONE_N\",Qm);const Wm=new Map;function Gm(e,t,i){let n=function(e,t){return jm.has(e)?jm.get(e):Vm}(e),r=Xf(t);if(r>255)return n;const s=e+r+i;if(r<0&&(r=0),!Wm.has(s)){const e=\"basemod2\"===i?Math.max(20,Math.min(255,r*r/50-4*r+200+20)):Math.max(20,Math.min(255,.006127*r*r)),[t,o,a]=_s.rgbComponents(n);Wm.set(s,`rgba(${t},${o},${a},${e/255})`)}return Wm.get(s)}class $m{constructor(e){this.alignmentTrack=e}updateContext(e){this.context=e}drawModifications(e,t,i,n,r,s){const{ctx:o,pixelEnd:a,bpStart:c,bpPerPixel:l}=n,h=e.getBaseModificationSets();if(h){let n;const d=r.split(\":\");2==d.length&&(r=d[0],n=d[1]);for(let d of e.blocks){if(\"S\"===d.type)continue;const e=t,u=i;let f=Math.max(1,1/l);for(let t=d.seqOffset;ta)break;if(i+f<0)continue;let p,g=-1,m=255,w=0;for(let e of h)if((!n||e.modification===n)&&e.containsPosition(t)){const i=Xf(e.likelihoods.get(t));m-=i,(!p||i>g)&&(p=e.modification,w=e.canonicalBase,g=i)}if(p){const t=255*s;let n;m>g&&\"basemod2\"===r&&m>=t?n=Gm(\"NONE_\"+w,m,r):g>=t&&(n=Gm(p,g,r)),o.fillStyle=n,f<3&&(f=3,i--),o.fillRect(i,e,f,Math.max(1,u-2))}}}}}}const Km=new Set([\"firstOfPairStrand\"]);class Ym extends Hl{static defaults={viewAsPairs:!1,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,colorBy:void 0,groupBy:void 0,displayMode:\"EXPANDED\",alignmentRowHeight:14,squishedRowHeight:3,negStrandColor:\"rgba(150, 150, 230, 0.75)\",posStrandColor:\"rgba(230, 150, 150, 0.75)\",baseModPosStrandColor:\"rgb(195, 195, 195)\",baseModNegStrandColor:\"rgb(195, 210, 195)\",insertionColor:\"rgb(138, 94, 161)\",insertionTextColor:\"white\",showInsertionText:!1,deletionColor:\"black\",deletionTextColor:\"black\",showDeletionText:!1,skippedColor:\"rgb(150, 170, 170)\",pairConnectorColor:void 0,smallTLENColor:\"rgb(0, 0, 150)\",largeTLENColor:\"rgb(200, 0, 0)\",expectedPairOrientation:\"fr\",rlColor:\"rgb(0, 150, 0)\",rrColor:\"rgb(20, 50, 200)\",llColor:\"rgb(0, 150, 150)\",bamColorTag:\"YC\",hideSmallIndels:!1,indelSizeThreshold:1,highlightColor:void 0,minTLEN:void 0,maxTLEN:void 0,tagColorPallete:\"Set1\"};_colorTables=new Map;_baseModifications=new Set;constructor(e,t){super(e,t),(e.colorTable||e.tagColorTable)&&(this.colorTable=new ao(e.tagColorTable)),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.pairOrienation&&(this.expectedPairOrientation=e.pairOrientation),e.smallFragmentLengthColor&&(this.smallTLENColor=e.smallFragmentLengthColor),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.minFragmentLength&&(this.minTLEN=e.minFragmentLength),e.maxFragmentLength&&(this.maxTLEN=e.maxFragmentLength),e.displayMode&&(this.displayMode=e.displayMode.toUpperCase()),e.colorBy&&e.colorByTag&&(this.colorBy=e.colorBy+\":\"+e.colorByTag),this.featureSource=this.parent.featureSource,this.top=0===e.coverageTrackHeight?0:e.coverageTrackHeight+5,this.pairColors={RL:this.rlColor,RR:this.rrColor,LL:this.llColor},e.highlightedReads&&this.setHighlightedReads(e.highlightedReads),this.hasPairs=!1,this.hasSupplemental=!1,this._groupByTags=[],this._groupByPositions=[],e.groupBy&&(this.groupBy=e.groupBy,e.groupBy.startsWith(\"base:\")&&this._groupByPositions.push(e.groupBy.substring(5)),e.groupBy.startsWith(\"tag:\")&&this._groupByTags.push(e.groupBy.substring(4))),this._locusChange=Zm.bind(this),this.browser.on(\"locuschange\",this._locusChange)}init(e){this.parent=e.parent,delete e.parent,super.init(e)}dispose(){this.browser.off(\"locuschage\",this._locusChange)}get baseModRenderer(){return this._baseModRenderer||(this._baseModRenderer=new $m(this)),this._baseModRenderer}get baseModificationThreshold(){return this.parent.baseModificationThreshold}setTop(e,t){this.top=0===e.height||!1===t?0:5+e.height}setHighlightedReads(e,t){if(!Array.isArray(e)||!e.every((e=>\"string\"==typeof e)))throw new Error(\"AlignmentTrack.setHighlightedReads() only accept array of strings\");t&&(this.highlightColor=t),this.highlightedReads=new Set(e)}computePixelHeight(e){if(e.packedGroups){let t=e.hasDownsampledIntervals()?15:0;const i=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;for(let n of e.packedGroups.values())t+=i*n.length+10;return t+5}return 0}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=r+s*n+1,a=this.showSoftClips,c=this.showAllBases,l=this.browser.nucleotideColors;i.save();for(let e of t.baseModificationKeys)this._baseModifications.add(e.modification);let h=t.sequence;h&&(h=h.toUpperCase());let d=0;this.colorBy||(this.colorBy=this.hasPairs?\"unexpectedPair\":\"none\");let u=e.pixelTop;this.top&&i.translate(0,this.top);const f=u+e.pixelHeight;t.hasDownsampledIntervals()?(d=15,t.downsampledIntervals.forEach((function(e){var t=(e.start-r)/n,s=(e.end-r)/n;s-t>5&&(t+=1,s-=1),xo.fillRect(i,t,2,s-t,8,{fillStyle:\"black\"})}))):d=0,this.alignmentsYOffset=d;const p=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight,g=t.packedGroups;if(g){let t=d;for(let n of g.keys()){const a=g.get(n),c=a.rows,l=c.length;a.pixelTop=t;for(let e=0;ef)break;if(t+no)break;!0!==e.hidden&&(e instanceof Qf?(m.call(this,e,t,n),w.call(this,e.firstAlignment,t,n),e.secondAlignment&&w.call(this,e.secondAlignment,t,n)):w.call(this,e,t,n))}t+=p}}if(a.pixelBottom=t,this.groupBy&&n){i.save(),i.font=\"400 12px sans-serif\";const r=i.measureText(n),o=r.width+10,c=-e.pixelShift+e.viewportWidth-o-10,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+10,h=Math.min(a.pixelTop+l-1,a.pixelBottom);i.textAlign=\"center\",i.fillStyle=\"white\",i.strokeStyle=\"lightGray\",xo.roundRect(i,c,h-r.actualBoundingBoxAscent-5,o,l,2,1,1),i.fillStyle=\"black\",i.fillText(n,c+o/2,h),xo.dashedLine(i,0,t,s,t),i.restore(),t+=10}}}function m(e,t,s){var a=this.getConnectorColor(e.firstAlignment),c=(e.connectingStart-r)/n,l=(e.connectingEnd-r)/n,h=t+s/2;e.connectingEndo||(e.mq<=0&&(a=_s.addAlpha(a,.15)),xo.setProperties(i,{fillStyle:a,strokeStyle:a}),xo.strokeLine(i,c,h,l,h))}function w(e,d,u){if(e.start+e.lengthOnRefo)return;const f=a?e.blocks:e.blocks.filter((e=>\"S\"!==e.type));let g=this.getAlignmentColor(e);const m=g;e.mq<=0&&(g=_s.addAlpha(g,.15)),xo.setProperties(i,{fillStyle:g,strokeStyle:m});const w=[];for(let e=0;eo))break}if(e.gaps){const t=d+u/2;for(let s of e.gaps){const e=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-e,c=s.len.toString(),l=6*c.length,h=e+a/2,u=\"D\"===s.type?this.deletionColor:this.skippedColor;if(xo.strokeLine(i,e,t,o,t,{strokeStyle:u,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=l+8){const e=h-l/2;xo.fillRect(i,e-1,d-1,l+2,12,{fillStyle:\"white\"}),xo.fillText(i,c,e,d+10,{font:\"normal 10px monospace\",fillStyle:this.deletionTextColor})}}}if(e.insertions&&this.showInsertions){let t=-1;for(let s of e.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.starto)break;const e=s.start-r,a=s.len.toString(),c=2+6*a.length,l=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,h=Math.max(Math.min(c,l),2),f=e/n-h/2;if(f-t>2){const e={fillStyle:this.insertionColor};xo.fillRect(i,f-2,d,h+4,2,e),xo.fillRect(i,f,d+2,h,u-4,e),xo.fillRect(i,f-2,d+u-2,h+4,2,e),this.showInsertionText&&s.len>1&&l>c&&xo.fillText(i,a,f+1,d+10,{font:\"normal 10px monospace\",fillStyle:this.insertionTextColor}),t=f}}}for(let{bbox:e,baseColor:t,readChar:r}of w){if(n<=.1&&e.height>=8){const n=Math.min(10,e.height);i.font=n+\"px sans-serif\";const s=e.x+e.width/2;xo.strokeText(i,r,s-i.measureText(r).width/2,n-1+e.y,{strokeStyle:t})}else xo.fillRect(i,e.x,e.y,e.width,e.height,{fillStyle:t})}if(this.colorBy&&this.colorBy.startsWith(\"basemod\")){const t={ctx:i,bpPerPixel:n,bpStart:r,bpEnd:o,pixelEnd:s};this.baseModRenderer.drawModifications(e,d,u,t,this.colorBy,this.baseModificationThreshold)}function b(o,a){const w=[],b=o.start-t.start,F=(o.start-r)/n,v=(o.start+o.len-r)/n,y=Math.max(1,v-F),A=100/n,C=Math.min(p/2,A/6),_=\"S\"===o.type,x=e.mq<=0||this.selectedReadName===e.readName||_||this.highlightedReads&&this.highlightedReads.has(e.readName);let k=m;this.selectedReadName===e.readName?k=\"red\":_?k=\"rgb(50,50,50)\":this.highlightedReads&&this.highlightedReads.has(e.readName)&&(k=this.highlightColor||\"#00ff00\");const I=!0===e.strand&&a===f.length-1,S=!1===e.strand&&0===a;if(I|S){let e,t;I?(e=[F,v,v+C,v,F,F],t=[d,d,d+u/2,d+u,d+u,d]):S&&(e=[v,F,F-C,F,v,v],t=[d,d,d+u/2,d+u,d+u,d]),xo.fillPolygon(i,e,t,{fillStyle:g}),x&&xo.strokePolygon(i,e,t,{strokeStyle:k})}else xo.fillRect(i,F,d,y,u,{fillStyle:g}),x&&(i.save(),i.strokeStyle=k,i.strokeRect(F,d,y,u),i.restore());if(_||c||this.showMismatches&&h&&e.seq&&\"*\"!==e.seq){const t=e.seq?e.seq.toUpperCase():void 0,i=e.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let e=0,p=o.len;es)break;let g=t?t.charAt(a+e):\"\";const m=b+e>=0?h.charAt(b+e):\"\";if(\"=\"===g&&(g=m),\"X\"===g||m!==g||_||c){let t=l[g]||\"rgb(0,0,0)\";if(!_&&void 0!==i&&i.length>a+e){t=Xm(i[a+e],t)}w.push({bbox:{x:p,y:d,width:f,height:u},baseColor:t,readChar:g})}}}return w}}i.restore()}popupData(e){const t=this.getClickedObject(e);return t?t.popupData(e.genomicLocation):void 0}menuItemList(){let e=[];e.push(\"
\");const t=Bt('
');t.text(\"Color by:\"),e.push({name:void 0,object:t,click:void 0,init:void 0});const i=[];i.push({key:\"none\",label:\"none\"}),i.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(i.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),i.push({key:\"pairOrientation\",label:\"pair orientation\"}),i.push({key:\"tlen\",label:\"insert size (TLEN)\"}),i.push({key:\"unexpectedPair\",label:\"pair orientation & insert size (TLEN)\"})),i.push({key:\"tag\",label:\"tag\"});for(let t of i){const i=void 0===this.colorBy&&\"none\"===t.key||this.colorBy===t.key;e.push(this.colorByCB(t,i))}const n=this._baseModifications.size;if(n>0){e.push('
');let t=1===n?\"base modification\":\"base modification (all)\";if(e.push(this.basemodColorByCB({key:\"basemod\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod:\"+t,label:`base modification (${Kf(t)})`}));if(e.push('
'),t=1===n?\"base modification 2-color\":\"base modification 2-color (all)\",e.push(this.basemodColorByCB({key:\"basemod2\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod2:\"+t,label:`base modification 2-color (${Kf(t)})`}))}e.push(\"
\");const r=Bt('
');r.text(\"Group by:\"),e.push({name:void 0,object:r,click:void 0,init:void 0});const s=[];s.push({key:\"none\",label:\"none\"}),s.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(s.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),s.push({key:\"pairOrientation\",label:\"pair orientation\"}),s.push({key:\"mateChr\",label:\"chromosome of mate\"})),s.push({key:\"chimeric\",label:\"chimeric\"}),s.push({key:\"supplementary\",label:\"supplementary flag\"}),s.push({key:\"readOrder\",label:\"read order\"});for(let e of this._groupByTags)s.push({key:`tag:${e}`,label:`tag:${e}`});for(let e of this._groupByPositions)s.push({key:`base:${e}`,label:`base:${e}`});s.push({key:\"tag\",label:\"tag...\"});for(let t of s){const i=void 0===this.groupBy&&\"none\"===t.key||this.groupBy===t.key;e.push(this.groupByCB(t,i))}e.push(\"
\"),e.push({object:Bt(Dl(\"Show all bases\",this.showAllBases)),click:function(){this.alignmentTrack.showAllBases=!this.alignmentTrack.showAllBases,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show mismatches\",this.showMismatches)),click:function(){this.alignmentTrack.showMismatches=!this.alignmentTrack.showMismatches,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show insertions\",this.showInsertions)),click:function(){this.alignmentTrack.showInsertions=!this.alignmentTrack.showInsertions,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show soft clips\",this.showSoftClips)),click:function(){this.alignmentTrack.showSoftClips=!this.alignmentTrack.showSoftClips;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.repaintViews()}}),this.hasPairs&&(e.push(\"
\"),e.push({object:Bt(Dl(\"View as pairs\",this.viewAsPairs)),click:function(){const e=!this.alignmentTrack.viewAsPairs;if(e&&this.groupBy&&!Km.has(this.groupBy))return void this.browser.alert.present(`'View as Pairs' is incompatible with 'Group By ${this.groupBy}'`);this.alignmentTrack.viewAsPairs=e;const t=this.getCachedAlignmentContainers();for(let e of t)e.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(e.push(\"
\"),this.hasPairs&&e.push({label:\"Add discordant pairs to circular view\",click:function(){for(let e of this.trackView.viewports)this.addPairedChordsForViewport(e)}}),this.hasSupplemental&&e.push({label:\"Add split reads to circular view\",click:function(){for(let e of this.trackView.viewports)this.addSplitChordsForViewport(e)}})),e.push(\"
\");const o=Bt('
');o.text(\"Display mode:\"),e.push({name:void 0,object:o,click:void 0,init:void 0});for(let t of[\"EXPANDED\",\"SQUISHED\",\"FULL\"])e.push({object:Bt(Dl(t.toLowerCase(),this.displayMode===t)),click:function(){this.alignmentTrack.setDisplayMode(t)}});return e}setDisplayMode(e){const t=\"FULL\"===this.displayMode||\"FULL\"===e;if(this.displayMode=e,t){const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this)}this.trackView.checkContentHeight(),this.trackView.repaintViews()}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"tag\"!==e.key){function n(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){const t=this.alignmentTrack.colorBy.startsWith(\"tag:\")?this.alignmentTrack.colorBy.substring(4):\"\";this.browser.inputDialog.present({label:\"Tag Name\",value:t,callback:e=>{const t=this.alignmentTrack;e?(t.colorBy=\"tag:\"+e,t.colorTable||(t.colorTable=new oo(\"Set1\"))):t.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}basemodColorByCB(e){const t=this.colorBy===e.key;return{name:void 0,object:Bt(Dl(e.label,t)),click:function(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()},init:void 0}}groupByCB(e,t){return{name:void 0,object:Bt(Dl(e.label,t)),dialog:function(t){const i=()=>this.alignmentTrack.repackAlignments();if(\"tag\"===e.key){let e=\"\";this.alignmentTrack.groupBy&&this.alignmentTrack.groupBy.startsWith(\"tag:\")&&(e=this.alignmentTrack.groupBy.substring(4)),this.browser.inputDialog.present({label:\"Tag Name\",value:e,callback:e=>{e&&(this.alignmentTrack.groupBy=\"tag:\"+e,this.alignmentTrack._groupByTags.push(e),i())}},t)}else\"none\"===e.key?this.alignmentTrack.groupBy=void 0:this.alignmentTrack.groupBy=e.key,i()},init:void 0}}repackAlignments(){const e=this.getCachedAlignmentContainers();for(let t of e)\"function\"==typeof t.pack&&t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}contextMenuItemList(e){const t=e.viewport,i=[],n=i=>{const n=this.sortObject,r=!n||n.position!==Math.floor(e.genomicLocation)||!n.direction,s={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:i,direction:r,sortAsPairs:t.trackView.track.viewAsPairs};this.sortObject=s,t.cachedFeatures.sortRows(s),t.repaint()};i.push(\"Sort by...\"),i.push({label:\"  base\",click:()=>n(\"BASE\")}),i.push({label:\"  read strand\",click:()=>n(\"strand\")}),i.push({label:\"  start location\",click:()=>n(\"START\")}),i.push({label:\"  insert size\",click:()=>n(\"INSERT_SIZE\")}),i.push({label:\"  gap size\",click:()=>n(\"GAP_SIZE\")}),i.push({label:\"  chromosome of mate\",click:()=>n(\"MATE_CHR\")}),i.push({label:\"  mapping quality\",click:()=>n(\"MQ\")}),i.push({label:\"  read name\",click:()=>n(\"READ_NAME\")}),i.push({label:\"  aligned read length\",click:()=>n(\"ALIGNED_READ_LENGTH\")}),i.push({label:\"  tag\",click:()=>{const i=this.sortObject,n=!i||i.position!==Math.floor(e.genomicLocation)||!i.direction,r={label:\"Tag Name\",value:this.sortByTag?this.sortByTag:\"\",callback:i=>{if(i){const r={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:\"TAG\",tag:i,direction:n};this.sortByTag=i,this.sortObject=r,t.cachedFeatures.sortRows(r),t.repaint()}}};this.browser.inputDialog.present(r,e.event)}}),i.push(\"
\");const r=`${t.referenceFrame.chr}:${Rt(Math.floor(e.genomicLocation)+1)}`;i.push({label:`Group by base @${r}`,click:()=>{this._groupByPositions.push(r),this.groupBy=`base:${r}`;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),i.push(\"
\");const s=this.getClickedObject(e);if(s){const t=this.showSoftClips,n=\"function\"==typeof s.alignmentContaining?s.alignmentContaining(e.genomicLocation,t):s;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:\"View mate in split screen\",click:()=>{if(n.mate){const t=e.viewport.referenceFrame,i=this.browser.genome.getChromosome(n.mate.chr);if(i){this.selectedReadName=n.readName;const r=t.bpPerPixel*e.viewport.getWidth(),s=n.mate.position-r/2,o=n.mate.position+r/2;this.browser.addMultiLocusPanel(i.name,s,o,t)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:\"View read sequence\",click:()=>{const e=n.seq;e&&\"*\"!==e?this.browser.alert.present(e):this.browser.alert.present(\"Read sequence: *\")}}),Xa()&&i.push({label:\"Copy read sequence\",click:async()=>{const e=n.seq;try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}});const t=n.seq;if(t&&\"*\"!==t){t.length{const e=n.isNegativeStrand()?cc(t):t,i=`${n.readName} - blat`,r=`${this.name} - ${i}`;jd({sequence:e,browser:this.browser,name:i,title:r})}});const e=n.softClippedBlocks();e.left&&e.left.len>20&&e.left.len{const i=t.substr(e.left.seqOffset,e.left.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat left clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}}),e.right&&e.right.len>20&&e.right.len{const i=t.substr(e.right.seqOffset,e.right.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat right clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}})}i.push(\"
\")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:\"Add discordant pairs to circular view\",click:()=>{this.addPairedChordsForViewport(t)}}),this.hasSupplemental&&i.push({label:\"Add split reads to circular view\",click:()=>{this.addSplitChordsForViewport(t)}}),i.push(\"
\")),i}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t)return;const i=e.y-this.top,n=e.genomicLocation;if(t.packedGroups){let e=Number.MAX_VALUE;for(let r of t.packedGroups.values())if(e=Math.min(e,r.pixelTop),i>r.pixelTop&&i<=r.pixelBottom){const e=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let t=Math.floor((i-r.pixelTop)/e);if(t>=0&&te.containsLocation(n,this.showSoftClips)));if(e.length>0)return e[0]}}}if(i=n)return e}getConnectorColor(e){if(this.pairConnectorColor)return this.pairConnectorColor;let t=this.colorBy;switch(t&&t.startsWith(\"tag:\")&&(t.substring(4),t=\"tag\"),t){case\"strand\":case\"firstOfPairStrand\":case\"pairOrientation\":case\"tag\":return this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(200, 200, 200)\";default:return this.getAlignmentColor(e)}}getAlignmentColor(e){let t;t=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(185, 185, 185)\";let i,n=this.colorBy;switch(n&&n.startsWith(\"tag:\")&&(i=n.substring(4),n=\"tag\"),n){case\"basemod\":case\"basemod2\":t=e.strand?this.baseModPosStrandColor:this.baseModNegStrandColor;break;case\"strand\":t=e.strand?this.posStrandColor:this.negStrandColor;break;case\"firstOfPairStrand\":const r=e.firstOfPairStrand;void 0!==r&&(t=r?this.posStrandColor:this.negStrandColor);break;case\"unexpectedPair\":case\"pairOrientation\":if(e.pairOrientation){const i=ep[this.expectedPairOrientation];if(i){const n=this.pairColors[i[e.pairOrientation]];if(n){t=n;break}}}if(\"pairOrientation\"===n)break;case\"tlen\":case\"fragmentLength\":e.mate&&e.isMateMapped()&&(e.mate.chr!==e.chr?t=Nu(e.mate.chr):this.minTemplateLength&&Math.abs(e.fragmentLength)this.maxTemplateLength&&(t=this.largeTLENColor));break;case\"tag\":const s=e.tags()[i];void 0!==s&&(this.bamColorTag===i&&(t=_s.createColorStringSafe(s)),this.colorTable||(this.colorTable=new oo(this.tagColorPallete)),t=this.colorTable.getColor(s))}return t}get nucleotideColors(){return this.browser.nucleotideColors}get minTemplateLength(){return void 0!==this.minTLEN?this.minTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.minTLEN:0}get maxTemplateLength(){return void 0!==this.maxTLEN?this.maxTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.maxTLEN:1e3}getState(){const e=super.getState();return this.highlightedReads&&(e.highlightedReads=Array.from(this.highlightedReads)),e}get name(){return this.parent.name}set name(e){this.parent.name=e}get color(){return this.parent.color}set color(e){this.parent.color=e}get trackView(){return this.parent.trackView}get getCachedAlignmentContainers(){return this.parent.getCachedAlignmentContainers}get sortObject(){return this.parent.sortObject}set sortObject(e){this.parent.sortObject=e}addPairedChordsForViewport(e){return this.parent.addPairedChordsForViewport(e)}addSplitChordsForViewport(e){return this.parent.addSplitChordsForViewport(e)}}function Xm(e,t){let i;return i=e<5?.1:Math.max(.1,Math.min(1,.1+.9*(e-5)/15)),i=Math.round(10*i)/10,i<1&&(t=_s.addAlpha(t,i)),t}function Zm(){\"FULL\"!==this.displayMode||this.browser.isTrackPanning()||this.repackAlignments()}function Jm(e,t,i,n,r,s,o,a,c){const l=o.baseModCounts,h=o.coverageMap;if(l){let o;const d=a.split(\":\");2==d.length&&(a=d[0],o=d[1]);const u=Array.from(l.allModifications);u.sort(Vf.compare);const f=h.getTotalCount(s);if(!u.filter((e=>o?o===e.modification:!e.modification.startsWith(\"NONE_\"))).find((e=>l.getCount(s,e,0,!1)>0)))return;for(let d of u){if(d.modification.startsWith(\"NONE_\")&&\"basemod2\"!==a)continue;if(o&&o!==d.modification&&!d.modification.startsWith(\"NONE_\"))continue;const u=d.base,p=oc(u),g=h.getCount(s,u)+h.getCount(s,p),m=l.simplexModifications.has(d.modification)?h.getPosCount(s,u)+h.getNegCount(s,p):g;if(0==m)continue;const w=\"basemod2\"===a,b=l.getCount(s,d,c,w);if(0==b)continue;const F=g/f*(b/m),v=Math.round(F*r),y=l.getLikelihoodSum(s,d,c,w)/b,A=i-v,C=Gm(d.modification,y,a);e.fillStyle=C,e.fillRect(t,A,n,v),i=A}}}class ew{constructor(e,t){this.featureType=\"numeric\",this.parent=t,this.featureSource=t.featureSource,this.paintAxis=cd,this.top=0,this.autoscale=e.autoscale||void 0===e.max,e.coverageColor&&(this.color=e.coverageColor),this.autoscale||(this.dataRange={min:e.min||0,max:e.max})}get height(){return this.parent.coverageTrackHeight}draw(e){const t=e.pixelTop;e.pixelHeight;const i=this.parent.browser.nucleotideColors;if(t>this.height)return;const n=e.context,r=e.features,s=r.coverageMap;let o;s.refSeq&&(o=s.refSeq.toUpperCase());const a=e.bpPerPixel,c=e.bpStart,l=c+e.pixelWidth*a+1;let h;h=this.color?this.color:this.parent.color&&\"function\"!=typeof this.parent.color?_s.darkenLighten(this.parent.color,-35):\"rgb(150, 150, 150)\",xo.setProperties(n,{fillStyle:h,strokeStyle:h});const d=Math.max(1,1/a);for(let e=0,t=s.coverage.length;el)break;const i=s.coverage[e];if(!i)continue;const r=i.total/this.dataRange.max*this.height,o=this.height-r,h=(t-c)/a;xo.fillRect(n,h,o,d,r)}if(o)for(let e=0,t=s.coverage.length;el)break;const h=s.coverage[e];if(!h)continue;const u=h.total/this.dataRange.max*this.height;let f=this.height-u;const p=Math.floor((t-c)/a),g=o[e];if(this.parent.colorBy&&this.parent.colorBy.startsWith(\"basemod\"))Jm(n,p,this.height,d,u,t,r,this.parent.colorBy,this.parent.baseModificationThreshold);else if(h.isMismatch(g)){xo.setProperties(n,{fillStyle:i[g]}),xo.fillRect(n,p,f,d,u);let e=0;for(let t of[\"A\",\"C\",\"T\",\"G\"]){const r=(h[\"pos\"+t]+h[\"neg\"+t])/this.dataRange.max*this.height;f=this.height-r-e,e+=r,xo.setProperties(n,{fillStyle:i[t]}),xo.fillRect(n,p,f,d,r)}}}}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t||0===t.length)return;const i=Math.floor(e.genomicLocation),n=t.coverageMap,r=Math.floor(i-n.bpStart),s=n.coverage[r];return s?{coverage:s,baseModCounts:t.baseModCounts,hoverText:()=>n.coverage[r].hoverText()}:void 0}popupData(e){const t=[],{coverage:i,baseModCounts:n}=this.getClickedObject(e);if(i){const r=Math.floor(e.genomicLocation),s=e.viewport.referenceFrame;t.push(s.chr+\":\"+Rt(1+r)),t.push({name:\"Total Count\",value:i.total});let o=i.posA+i.negA;o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posA+\"+, \"+i.negA+\"- )\"),t.push({name:\"A\",value:o}),o=i.posC+i.negC,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posC+\"+, \"+i.negC+\"- )\"),t.push({name:\"C\",value:o}),o=i.posG+i.negG,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posG+\"+, \"+i.negG+\"- )\"),t.push({name:\"G\",value:o}),o=i.posT+i.negT,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posT+\"+, \"+i.negT+\"- )\"),t.push({name:\"T\",value:o}),o=i.posN+i.negN,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posN+\"+, \"+i.negN+\"- )\"),t.push({name:\"N\",value:o}),t.push(\"
\"),t.push({name:\"DEL\",value:i.del.toString()}),t.push({name:\"INS\",value:i.ins.toString()}),n&&(t.push(\"
\"),t.push(...n.popupData(r,this.parent.colorBy)))}return t}}class tw extends Hl{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,height:300,coverageTrackHeight:50,baseModificationThreshold:0};constructor(e,t){super(e,t)}init(e){this.type=\"alignment\",this.featureSource=new cm(e,this.browser);const t=Object.assign({parent:this},e);this.coverageTrack=new ew(t,this);const i=Object.assign({parent:this},e);this.alignmentTrack=new Ym(i,this.browser),super.init(e),this.showAlignments||(this._height=this.coverageTrackHeight),e.sort&&(Array.isArray(e.sort)?this.assignSort(e.sort[0]):this.assignSort(e.sort))}dispose(){this.alignmentTrack.dispose()}setHighlightedReads(e,t){this.alignmentTrack.setHighlightedReads(e,t),this.updateViews()}get expectedPairOrientation(){return this.alignmentTrack.expectedPairOrientation}get viewAsPairs(){return this.alignmentTrack.viewAsPairs}get colorBy(){return this.alignmentTrack.colorBy}set height(e){this._height=e,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?e-this.coverageTrackHeight:e)}get height(){return this._height}sort(e){e=this.assignSort(e);for(let t of this.trackView.viewports)if(t.containsPosition(e.chr,e.position)){const i=t.cachedFeatures;i&&(i.sortRows(e),t.repaint())}}assignSort(e){if(e.locus){const t=function(e){const t=e.split(\":\"),i=t[1].split(\"-\"),n={chr:t[0],start:Number.parseInt(i[0].replace(/,/g,\"\"))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,\"\")):n.end=n.start+1,n}(e.locus);e.chr=t.chr,e.position=t.start}else e.position--;return e.direction=\"ASC\"===e.direction||!0===e.direction,e.chr=this.browser.genome.getChromosomeName(e.chr),this.sortObject=e,this.sortObject}async getFeatures(e,t,i,n,r){const s=await this.featureSource.getAlignments(e,t,i);if(s.viewport=r,s.hasPairs&&!this._pairedEndStats&&!this.config.maxFragmentLength){const e=new Om(s.allAlignments(),this.config);e.totalCount>99&&(this._pairedEndStats=e)}s.pack(this.alignmentTrack);const o=this.sortObject;return o&&o.chr===e&&o.position>=t&&o.position<=i&&s.sortRows(o),this.alignmentTrack.hasPairs=this.alignmentTrack.hasPairs||s.hasPairs,s}computePixelHeight(e){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(e):0)}draw(e){xo.fillRect(e.context,0,e.pixelTop,e.pixelWidth,e.pixelHeight,{fillStyle:\"rgb(255, 255, 255)\"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display=\"block\",this.coverageTrack.draw(e)):this.trackView.axisCanvas.style.display=\"none\",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(e))}paintAxis(e,t,i){this.coverageTrack.paintAxis(e,t,this.coverageTrackHeight)}contextMenuItemList(e){return this.alignmentTrack.contextMenuItemList(e)}popupData(e){return!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y{if(!this.autoHeight){const e=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(e)}};return e.push(\"
\"),e.push({object:Bt(Dl(\"Show Coverage\",this.showCoverage)),click:function(){this.showCoverage=!this.showCoverage,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show Alignments\",this.showAlignments)),click:function(){this.showAlignments=!this.showAlignments,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e}getState(){const e=super.getState();return this.sortObject&&(e.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?\"ASC\":\"DESC\"}),Object.assign(e,this.alignmentTrack.getState()),e}getCachedAlignmentContainers(){return this.trackView.viewports.map((e=>e.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(e){this.coverageTrack.dataRange=e}get logScale(){return this.coverageTrack.logScale}set logScale(e){this.coverageTrack.logScale=e}get autoscale(){return this.coverageTrack.autoscale}set autoscale(e){this.coverageTrack.autoscale=e}addPairedChordsForViewport(e){const t=this.maxTemplateLength,i=[],n=e.referenceFrame;for(let r of e.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>t&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>t)&&i.push(r));Pm((e=>{const t=[];for(let i of e)if(i.paired)i.firstAlignment&&i.secondAlignment&&t.push({uniqueId:i.readName,refName:zm(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:zm(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const e=i.mate;e&&e.chr&&e.position&&t.push({uniqueId:i.readName,refName:zm(i.chr),start:i.start,end:i.end,mate:{refName:zm(e.chr),start:e.position-1,end:e.position}})}return t})(i),this,n,.02)}addSplitChordsForViewport(e){const t=[],i=e.referenceFrame;for(let n of e.cachedFeatures.allAlignments()){const e=n.hasTag(\"SA\");n.end>=i.start&&n.start<=i.end&&e&&t.push(n)}Pm((e=>{const t=e=>{const t=gp(e.tags().SA);let n=0;for(let r of t)r.start!==e.start&&i.push({uniqueId:`${e.readName}_${n++}`,refName:zm(e.chr),start:e.start,end:e.end,mate:{refName:zm(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of e)i.paired?(t(i.firstAlignment),i.secondAlignment&&t(i.secondAlignment)):t(i);return i})(t),this,i,.02)}}class iw extends Hl{static defaults={height:250,theta:Math.PI/4,arcOrientation:\"UP\",showBlocks:!0,blockHeight:3,thickness:1,color:\"rgb(180,25,137)\",alpha:.02,logScale:!0};constructor(e,t){super(e,t)}init(e){super.init(e),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(e){if(!e.arcType)return\"nested\";switch(e.arcType){case\"chiapet\":return\"inView\";case\"chiapetoutbound\":return\"partialInView\";default:return e.arcType}}(e),this.painter={flipAxis:\"DOWN\"===this.arcOrientation,dataRange:this.dataRange,paintAxis:cd},e.valueColumn?(this.valueColumn=e.valueColumn,this.hasValue=!0):e.useScore&&(this.hasValue=!0,this.valueColumn=\"score\"),e.max?(this.dataRange={min:e.min||0,max:e.max},this.autoscale=!1):this.autoscale=!0,e.featureSource?(this.featureSource=e.featureSource,delete e._featureSource):(this.featureSource=Ad(e,this.browser.genome),this.featureSource.getWGFeatures=aw)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(e){\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?this.drawProportional(e):this.drawNested(e)}drawNested(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.viewportWidth,s=e.bpPerPixel,o=e.bpStart,a=s;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const c=e.features;if(c){(function(){let e=0;for(let t of c){let n=(t.start-o)/a,r=(t.end-o)/a;n>=0&&r<=i&&(e=Math.max(e,r-n))}let t=Math.min(r,e)/2;if(e>0){let e=(n-10)/t;this.theta=function(e){let t,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(t=0;te);t++);let r=0===t?0:i[t-1],s=ti)continue;let f=u-d;f<3&&(f=3,d--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,w=d+p;let b,F,v;if(s?(b=this.height+m,F=Math.PI+Math.PI/2-this.theta,v=Math.PI+Math.PI/2+this.theta):(b=-m,F=Math.PI/2-this.theta,v=Math.PI/2+this.theta),this.showBlocks&&\"all\"!==e.chr){const i=(e.start1-o)/a,n=(e.end1-o)/a,r=(e.start2-o)/a,c=(e.end2-o)/a,l=s?-this.blockHeight:this.blockHeight;t.fillRect(i,h,n-i,l),t.fillRect(r,h,c-r,l)}n&&!this.config.useScore&&f>r&&(n=ow(n,this.alpha)),t.strokeStyle=n,t.fillStyle=n,t.beginPath(),t.arc(w,b,g,F,v,!1),t.stroke(),e.drawState={xc:w,yc:b,r:g}}else{let r=Math.round((e.start-o)/a),c=Math.round((e.end-o)/a);if(c<0||r>i)continue;let l=c-r;l<3&&(l=3,r--);const h=e.chr===e.chr1?e.chr2:e.chr1;t.strokeStyle=n,t.fillStyle=ow(Nu(h),.5),s?(t.fillRect(r,this.height/2,l,this.height/2),t.fillText(h,r+l/2,this.height/2-5),e.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(t.fillRect(r,0,l,this.height/2),t.fillText(h,r+l/2,this.height/2+13),e.drawState={x:r,y:0,w:l,h:this.height/2})}}}var l}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}drawProportional(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.bpPerPixel,s=e.bpStart,o=r,a=e.referenceFrame.start,c=e.referenceFrame.end,l=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const h=e.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,e.pixelHeight-1,this.logScale),d=l?e.pixelHeight:0;for(let e of h){e.drawState=void 0;const n=this.valueColumn?e[this.valueColumn]:e.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(e.chr1===e.chr2||\"all\"===e.chr){const{m1:i,m2:r}=nw(e,this.browser.genome);let u=Math.round((i-s)/o),f=Math.round((r-s)/o)-u;if(f<3&&(f=3,u--),nthis.dataRange.max)continue;if(\"proportional\"!==this.arcType){const e=\"partialInView\"===this.arcType,t=i>=a&&r<=c;let n=!1,s=!1;if(!t&&e&&(n=a<=i&&i<=c,n||(s=a<=r&&r<=c)),!(t||n||s))continue}const p=f/2,g=u+f/2;e.drawState={xc:g,yc:d,radiusX:p,radiusY:h};const m=l,w=e.color||this.color;if(t.strokeStyle=w,t.lineWidth=e.thickness||this.thickness||1,!0===t.isSVG?t.strokeEllipse(g,d,p,h,0,0,Math.PI,m):(t.beginPath(),t.ellipse(g,d,p,h,0,0,Math.PI,m),t.stroke()),this.alpha&&(t.fillStyle=ow(w,this.alpha),!0===t.isSVG?t.fillEllipse(g,d,p,h,0,0,Math.PI,m):t.fill()),this.showBlocks&&\"all\"!==e.chr){t.fillStyle=w;const i=(e.start1-s)/o,n=(e.end1-s)/o,r=(e.start2-s)/o,a=(e.end2-s)/o,c=l?-this.blockHeight:this.blockHeight;t.fillRect(i,d,n-i,c),t.fillRect(r,d,a-r,c)}}else{let r=Math.round((e.start-s)/o),a=Math.round((e.end-s)/o);if(a<0||r>i||nthis.dataRange.max)continue;const c=Math.min(h,this.height-13);let d=a-r;d<3&&(d=3,r--);const u=e.chr===e.chr1?e.chr2:e.chr1;if(t.font=\"8px sans-serif\",t.textAlign=\"center\",t.fillStyle=ow(Nu(u),.5),l){const i=this.height-c;t.fillRect(r,i,d,c),t.fillText(u,r+d/2,i-5),e.drawState={x:r,y:i,w:d,h:c}}else t.fillRect(r,0,d,c),t.fillText(u,r+d/2,c+13),e.drawState={x:r,y:0,w:d,h:c}}}}}clearAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"})}paintAxis(e,t,i){const n={min:0,max:this.dataRange.max};\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?(this.painter.flipAxis=\"DOWN\"===this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(e,t,i)):this.clearAxis(e,t,i)}menuItemList(){let e=[];if(this.hasValue){e.push(\"
\");const t={nested:\"Nested\",proportional:\"Proportional - All\",inView:\"Proportional - Both Ends in View\",partialInView:\"Proportional - One End in View\"};e.push(\"Arc Type\");for(let i of[\"nested\",\"proportional\",\"inView\",\"partialInView\"])e.push({object:Bt(Dl(t[i],i===this.arcType)),click:function(){this.arcType=i,this.trackView.repaintViews()}})}return e.push(\"
\"),e.push({name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}),e.push({name:this.showBlocks?\"Hide Blocks\":\"Show Blocks\",click:function(){this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),\"proportional\"!==this.arcType&&\"inView\"!==this.arcType&&\"partialInView\"!==this.arcType||(e=e.concat(this.numericDataMenuItems())),this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add interactions to circular view\",click:function(){for(let e of this.trackView.viewports)this.addChordsForViewport(e.referenceFrame)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:\"Add interactions to circular view\",click:()=>{const e=t.referenceFrame;this.addChordsForViewport(e)}}),i.push(\"
\"),i}}addChordsForViewport(e){let t;if(\"all\"===e.chr)t=Object.values(this.featureSource.getAllFeatures()).flat();else{t=this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end).filter((e=>e.drawState))}if(0===t.length)return;Pm(t.map((e=>{const t=e._f||e;return{uniqueId:`${t.chr1}:${t.start1}-${t.end1}_${t.chr2}:${t.start2}-${t.end2}`,refName:zm(t.chr1),start:t.start1,end:t.end1,mate:{refName:zm(t.chr2),start:t.start2,end:t.end2}}})),this,e,.5)}doAutoscale(e){let t=0;if(e)for(let i of e){const e=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(e)||(t=Math.max(t,e))}return{min:0,max:t}}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){const t=e._||e;if(i.push({name:\"Region 1\",value:rw(t.chr1,t.start1,t.end1,t.strand1)}),i.push({name:\"Region 2\",value:rw(t.chr2,t.start2,t.end2,t.strand2)}),t.name&&i.push({name:\"Name\",value:t.name}),void 0!==t.value&&i.push({name:\"Value\",value:t.value}),void 0!==t.score&&i.push({name:\"Score\",value:t.score}),t.extras&&this.header&&this.header.columnNames){const e=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r=t-a&&e.canvasX<=t+s+a&&e.canvasY>=n&&e.canvasY<=n+o){const n=-Math.abs(e.canvasX-(t+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((e,t)=>e.score-t.score)),i.map((e=>e.feature))}}function nw(e,t){let i=(e.start1+e.end1)/2,n=(e.start2+e.end2)/2;if(\"all\"===e.chr&&(i=t.getGenomeCoordinate(e.chr1,i),n=t.getGenomeCoordinate(e.chr2,n)),i>n){const e=i;i=n,n=e}return{m1:i,m2:n}}function rw(e,t,i,n){return n&&\".\"!==n?`${e}:${Rt(t+1)}-${Rt(i)} (${n})`:`${e}:${Rt(t+1)}-${Rt(i)}`}const sw=new Map;function ow(e,t){const i=`${e}_${t}`;let n=sw.get(i);return n||(n=_s.addAlpha(e,t),sw.set(i,n)),n}function aw(e){const t=e=>{const t=Object.assign({},e);return t.chr=\"all\",t.start=i.getGenomeCoordinate(e.chr1,e.start1),t.end=i.getGenomeCoordinate(e.chr2,e.end2),t},i=this.genome;let n,r=0;for(let t of i.wgChromosomeNames){let i=e[t];if(i)for(let e of i)e.dup||(r++,e.score&&(!n||e.score>n.score)&&(n=e))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),c=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let l,h=[],d=[];for(let e=0;e=400){const e=Error(r.statusText);throw e.code=s,e}return r.arrayBuffer()}}class hw{constructor(e){this.file=e.file,this.fetchSize=e.fetchSize||16e3,this.maxSize=e.maxSize||1e6,this.buffers=[]}async read(e,t){let i=this.buffers.filter((i=>i.overlaps(e,e+t)));for(let n of i)if(n.contains(e,e+t))return n.slice(e,e+t);if(0===i.length){let i=Math.max(t,this.fetchSize);this.buffers.sort(((e,t)=>e.start-t.start));const n=function(e,t,i){let n=i-1,r=e.length;for(;1+n>1);t(e[i])?r=i:n=i}return r}(this.buffers,(t=>t.start>e),0);ne.start-t.start));const n=[];let r=e;for(let e of i){if(rr){const e=r,t=s-e,i=await this.file.read(e,t),o=new dw(e,i);n.push(o)}const o=n[0].start,a=function(e){const t=e.reduce(((e,t)=>e+t.byteLength),0),i=new Uint8Array(t);let n=0;for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(n.map((e=>e.buffer))),c=new dw(o,a),l=new Set(i);return this.buffers=this.buffers.filter((e=>!l.has(e))),this.addBuffer(c),c.slice(e,e+t)}}addBuffer(e){const t=this.buffers.reduce(((e,t)=>e+t.size),0)+e.size;if(t>this.maxSize){const e=t-this.maxSize;this.buffers.sort(((e,t)=>e.creationTime-t.creationTime));let i,n=0;for(i=0;ie));i++);this.buffers=ithis.buffer.byteLength)throw Error(\"buffer bounds error\");return this.buffer.slice(e-this.start,t-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(e,t){return e>=this.start&&t<=this.end}overlaps(e,t){return e>this.start&&ethis.start&&t(((e,t,i)=>{t in e?fw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,\"symbol\"!=typeof t?t+\"\":t,i),i);async function gw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=await Aw.unpack_from_async(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function mw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=Aw.unpack_from(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function ww(e){e||e()}function bw(e){var t=\"<\"+Array.from(e.values()).join(\"\");return Aw.calcsize(t)}function Fw(e,t=8){return Math.ceil(e/t)*t}var vw={u:\"Uint\",i:\"Int\",f:\"Float\"};function yw(e){var t,i,n=Aw._is_big_endian(e);if(/S/.test(e))t=\"getString\",i=0|((e.match(/S(\\d*)/)||[])[1]||1);else{let[n,r,s]=e.match(/[<>=!@]?(i|u|f)(\\d*)/);i=parseInt(s||4,10),t=\"get\"+vw[r]+(8*i).toFixed()}return[t,n,i]}var Aw=new class{constructor(){this.big_endian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}(),this.getters={s:\"getUint8\",b:\"getInt8\",B:\"getUint8\",h:\"getInt16\",H:\"getUint16\",i:\"getInt32\",I:\"getUint32\",l:\"getInt32\",L:\"getUint32\",q:\"getInt64\",Q:\"getUint64\",f:\"getFloat32\",d:\"getFloat64\"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let e=Object.keys(this.byte_lengths).join(\"\");this.fmt_size_regex=\"(\\\\d*)([\"+e+\"])\"}calcsize(e){for(var t,i=0,n=new RegExp(this.fmt_size_regex,\"g\");null!==(t=n.exec(e));){let e=parseInt(t[1]||1,10),n=t[2];i+=e*this.byte_lengths[n]}return i}_is_big_endian(e){return!/^)/.test(e)||this.big_endian)}async unpack_from_async(e,t,i){i=Number.parseInt(i||0);const n=this.calcsize(e),r=await t.slice(i,i+n);let s=0;for(var o,a=new Cw(r),c=[],l=this._is_big_endian(e),h=new RegExp(this.fmt_size_regex,\"g\");null!==(o=h.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if(\"s\"==t)c.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;de+(t<<8*i)),0);return o}var kw=class{constructor(e,t){this.buf=e,this.offset=t,this.dtype=this.determine_dtype()}async determine_dtype(){let e=await gw(Iw,this.buf,this.offset);this.offset+=Sw;let t=15&e.get(\"class_and_version\");if(t==Ew)return this._determine_dtype_fixed_point(e);if(t==Nw)return this._determine_dtype_floating_point(e);if(t==Bw)throw\"Time datatype class not supported.\";if(t==Mw)return this._determine_dtype_string(e);if(t==Rw)throw\"Bitfield datatype class not supported.\";if(t==Dw)return{datatype_class:Dw,size:e.get(\"size\")};if(t==Tw)return this._determine_dtype_compound(e);if(t==Lw)return[\"REFERENCE\",e.get(\"size\")];if(t==zw)return this.determine_dtype();if(t==Pw)throw\"Array datatype class not supported.\";if(t==Hw){let t=this._determine_dtype_vlen(e);if(\"VLEN_SEQUENCE\"==t[0]){t=[\"VLEN_SEQUENCE\",this.determine_dtype()]}return t}throw\"Invalid datatype class \"+t}_determine_dtype_fixed_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;var n;return i=(8&e.get(\"class_bit_field_0\"))>0?\"i\":\"u\",n=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=4,n+i+t.toFixed()}_determine_dtype_floating_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;return i=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=12,i+\"f\"+t.toFixed()}_determine_dtype_string(e){return\"S\"+e.get(\"size\").toFixed()}_determine_dtype_vlen(e){return 1!=(1&e.get(\"class_bit_field_0\"))?[\"VLEN_SEQUENCE\",0,0]:[\"VLEN_STRING\",e.get(\"class_bit_field_0\")>>4,1&e.get(\"class_bit_field_1\")]}_determine_dtype_compound(e){throw\"Compound type not yet implemented!\"}},Iw=new Map([[\"class_and_version\",\"B\"],[\"class_bit_field_0\",\"B\"],[\"class_bit_field_1\",\"B\"],[\"class_bit_field_2\",\"B\"],[\"size\",\"I\"]]),Sw=bw(Iw);bw(new Map([[\"offset\",\"I\"],[\"dimensionality\",\"B\"],[\"reserved_0\",\"B\"],[\"reserved_1\",\"B\"],[\"reserved_2\",\"B\"],[\"permutation\",\"I\"],[\"reserved_3\",\"I\"],[\"dim_size_1\",\"I\"],[\"dim_size_2\",\"I\"],[\"dim_size_3\",\"I\"],[\"dim_size_4\",\"I\"]]));var Ew=0,Nw=1,Bw=2,Mw=3,Rw=4,Dw=5,Tw=6,Lw=7,zw=8,Hw=9,Pw=10;function Ow(e){let t=e.length;for(;--t>=0;)e[t]=0}Ow(new Array(576)),Ow(new Array(60)),Ow(new Array(512)),Ow(new Array(256)),Ow(new Array(29)),Ow(new Array(30));var Uw=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16},qw=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})()),Qw=(e,t,i,n)=>{const r=qw,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Vw={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},jw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Ww=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gw={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Ww(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:RA>=248?5:RA>=240?4:RA>=224?3:RA>=192?2:1;Kw[254]=Kw[254]=1;var Yw={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&$w)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Kw[e[i]]>t?i:t}};var Xw=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Zw=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=12;break e}e.msg=\"invalid literal/length code\",k.mode=30;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=30;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null,k=0;const I=new Uint16Array(16),S=new Uint16Array(16);let E,N,B,M=null,R=0;for(g=0;g<=Jw;g++)I[g]=0;for(m=0;m=1&&0===I[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(S[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){E=g-y,o[m]p?(N=M[R+o[m]],B=x[k+o[m]]):(N=96,B=0),l=1<>y)+h]=E<<24|N<<16|B}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--I[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0},{Z_FINISH:sb,Z_BLOCK:ob,Z_TREES:ab,Z_OK:cb,Z_STREAM_END:lb,Z_NEED_DICT:hb,Z_STREAM_ERROR:db,Z_DATA_ERROR:ub,Z_MEM_ERROR:fb,Z_BUF_ERROR:pb,Z_DEFLATED:gb}=jw,mb=12,wb=30,bb=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Fb(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var vb,yb,Ab=e=>{if(!e||!e.state)return db;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,cb},Cb=e=>{if(!e||!e.state)return db;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ab(e)},_b=(e,t)=>{let i;if(!e||!e.state)return db;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?db:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Cb(e))},xb=(e,t)=>{if(!e)return db;const i=new Fb;e.state=i,i.window=null;const n=_b(e,t);return n!==cb&&(e.state=null),n},kb=!0,Ib=e=>{if(kb){vb=new Int32Array(512),yb=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rb(1,e.lens,0,288,vb,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rb(2,e.lens,0,32,yb,0,e.work,{bits:5}),kb=!1}e.lencode=vb,e.lenbits=9,e.distcode=yb,e.distbits=5},Sb=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return db;i=e.state,i.mode===mb&&(i.mode=13),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=cb;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=wb;break}if((15&l)!==gb){e.msg=\"unknown compression method\",i.mode=wb;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg=\"invalid window size\",i.mode=wb;break}i.dmax=1<>8&1),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Qw(i.check,x,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&(i.check=Qw(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mb;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=14;break;case 1:if(Ib(i),i.mode=20,t===ab){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=wb}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=wb;break}if(i.length=65535&l,l=0,h=0,i.mode=15,t===ab)break e;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=mb;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=wb;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=rb(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=wb;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=wb;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=wb;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===wb)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=wb;break}if(i.lenbits=9,k={bits:i.lenbits},C=rb(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=wb;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=rb(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=wb;break}if(i.mode=20,t===ab)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Zw(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===mb&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=mb;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=wb;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=wb;break}i.offset=b,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=wb;break}i.mode=25;case 25:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=wb;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<xb(e,15),inflateInit2:xb,inflate:Eb,inflateEnd:e=>{if(!e||!e.state)return db;let t=e.state;return t.window&&(t.window=null),e.state=null,cb},inflateGetHeader:(e,t)=>{if(!e||!e.state)return db;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,cb):db},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?db:11===n.mode&&(r=1,r=Uw(r,t,i,0),r!==n.check)?ub:(s=Sb(e,t,i,i),s?(n.mode=31,fb):(n.havedict=1,cb))):db},inflateInfo:\"pako inflate (from Nodeca project)\"};var Bb=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1},Mb=Object.prototype.toString,{Z_NO_FLUSH:Rb,Z_FINISH:Db,Z_OK:Tb,Z_STREAM_END:Lb,Z_NEED_DICT:zb,Z_STREAM_ERROR:Hb,Z_DATA_ERROR:Pb,Z_MEM_ERROR:Ob}=jw;function Ub(e){this.options=Gw.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Xw,this.strm.avail_out=0;let i=Nb.inflateInit2(this.strm,t.windowBits);if(i!==Tb)throw new Error(Vw[i]);if(this.header=new Bb,Nb.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Yw.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Mb.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Nb.inflateSetDictionary(this.strm,t.dictionary),i!==Tb)))throw new Error(Vw[i])}function qb(e,t){const i=new Ub(t);if(i.push(e),i.err)throw i.msg||Vw[i.err];return i.result}Ub.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Db:Rb,\"[object ArrayBuffer]\"===Mb.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Nb.inflate(i,o),s===zb&&r&&(s=Nb.inflateSetDictionary(i,r),s===Tb?s=Nb.inflate(i,o):s===Pb&&(s=zb));i.avail_in>0&&s===Lb&&i.state.wrap>0&&0!==e[i.next_in];)Nb.inflateReset(i),s=Nb.inflate(i,o);switch(s){case Hb:case Pb:case zb:case Ob:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===Lb))if(\"string\"===this.options.to){let e=Yw.utf8border(i.output,i.next_out),t=i.next_out-e,r=Yw.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Tb||0!==a){if(s===Lb)return s=Nb.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ub.prototype.onData=function(e){this.chunks.push(e)},Ub.prototype.onEnd=function(e){e===Tb&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Gw.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qb=function(e,t){return(t=t||{}).raw=!0,qb(e,t)},Vb={Inflate:Ub,inflate:qb,inflateRaw:Qb,ungzip:qb,constants:jw},{Inflate:jb,inflate:Wb,inflateRaw:Gb,ungzip:$b}=Vb,Kb=Wb,Yb=$b;var Xb=new Map([[1,function(e,t){let i=new Uint8Array(e);return Kb(i).buffer}],[2,function(e,t){let i=e.byteLength,n=new Uint8Array(i),r=Math.floor(i/t),s=new DataView(e);for(var o=0;oHH\",e,i);if(c%=65535,r!=(a%=65535)||s!=c)throw'ValueError(\"fletcher32 checksum invalid\")'}(e),e.slice(0,-4)}]]),Zb=class{constructor(e,t){this.fh=e,this.offset=t,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let e=this.depth;for(;e>0;){for(var t of this.all_nodes.get(e))for(var i of t.get(\"addresses\"))this._add_node(await this._read_node(i,e-1));e--}}async _read_root_node(){let e=await this._read_node(this.offset,null);this._add_node(e),this.depth=e.get(\"node_level\")}_add_node(e){let t=e.get(\"node_level\");this.all_nodes.has(t)?this.all_nodes.get(t).push(e):this.all_nodes.set(t,[e])}async _read_node(e,t){let i=await this._read_node_header(e,t);return i.set(\"keys\",[]),i.set(\"addresses\",[]),i}async _read_node_header(e){throw\"NotImplementedError: must define _read_node_header in implementation class\"}},Jb=class extends Zb{constructor(){super(...arguments),pw(this,\"B_LINK_NODE\",new Map([[\"signature\",\"4s\"],[\"node_type\",\"B\"],[\"node_level\",\"B\"],[\"entries_used\",\"H\"],[\"left_sibling\",\"Q\"],[\"right_sibling\",\"Q\"]]))}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);if(null!=t&&i.get(\"node_level\")!=t)throw\"node level does not match\";return i}},eF=class extends Jb{constructor(e,t){super(e,t),pw(this,\"NODE_TYPE\",0),this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=bw(this.B_LINK_NODE);let n=[],r=[],s=i.get(\"entries_used\");for(var o=0;o=0&&F[A]>=e[A];A--)F[A]=0,b[A]=w[A],A>0&&(F[A-1]+=1,b[A-1]+=1);if(b.slice(0,-1).every((function(e,i){return e=0;o--){if(t&1<0?r*=n:r=n}}return s}_nrecords_max(e,t,i){return Math.floor((e-10-i)/(t+i))}_required_bytes(e){return Math.ceil(_w(e)/8)}_int_format(e){return[\"0&&(h=(await Aw.unpack_from_async(a,this.fh,i))[0],i+=r),c.push([n,l,h])}}return s.set(\"keys\",a),s.set(\"addresses\",c),s}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);return i.set(\"node_level\",t),i}*iter_records(){for(let e of this.all_nodes.values())for(let t of e)for(let e of t.get(\"keys\"))yield e}_parse_record(e){throw\"NotImplementedError\"}},nF=class extends iF{constructor(){super(...arguments),pw(this,\"NODE_TYPE\",5)}async _parse_record(e,t,i){let n=(await Aw.unpack_from_async(\"0)throw\"Filter info size not supported on FractalHeap\";if(t.get(\"btree_address_huge_objects\")!=dF)throw\"Huge objects not implemented in FractalHeap\";t.set(\"btree_address_huge_objects\",null),t.get(\"root_block_address\")==dF&&t.set(\"root_block_address\",null);let i=t.get(\"log2_maximum_heap_size\"),n=this._min_size_nbits(i),r=new Map([[\"signature\",\"4s\"],[\"version\",\"B\"],[\"heap_header_adddress\",\"Q\"],[\"block_offset\",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=bw(r),2&~t.get(\"flags\")||r.set(\"checksum\",\"I\"),this.direct_block_header=r,this.direct_block_header_size=bw(r);let s=t.get(\"maximum_direct_block_size\");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,t.get(\"max_managed_object_size\"));this._managed_object_length_size=this._min_size_integer(o);let a=t.get(\"starting_block_size\"),c=t.get(\"table_width\");if(!(a>0))throw\"Starting block size == 0 not implemented\";let l=Number(Math.floor(Math.log2(s)));ww(1n<0)for await(let e of this._iter_indirect_block(this.fh,f,p))u.push(e);else{let e=await this._read_direct_block(this.fh,f,a);u.push(e)}let g=u.reduce(((e,t)=>e+t.byteLength),0),m=new Uint8Array(g),w=0;u.forEach((e=>{m.set(new Uint8Array(e),w),w+=e.byteLength})),this.managed=m.buffer}async _read_direct_block(e,t,i){let n=await e.slice(t,t+i);return ww(\"FHDB\"==mw(this.direct_block_header,n).get(\"signature\")),n}get_data(e){let t=Aw.unpack_from(\">4&3,n=1;if(0==i){ww(0==t>>6);let i=this._managed_object_offset_size,r=xw(i,e,n);n+=i,i=this._managed_object_length_size;let s=xw(i,e,n);return this.managed.slice(r,r+s)}throw 1==i?\"tiny objectID not supported in FractalHeap\":2==i?\"huge objectID not supported in FractalHeap\":\"unknown objectID type in FractalHeap\"}_min_size_integer(e){return this._min_size_nbits(_w(e))}_min_size_nbits(e){return Math.ceil(e/8)}async*_iter_indirect_block(e,t,i){let n=await gw(this.indirect_block_header,e,t);t+=this.indirect_block_header_size,ww(\"FHIB\"==n.get(\"signature\"));let r=n.get(\"block_offset\").reduce(((e,t,i)=>e+(t<<8*i)),0);n.set(\"block_offset\",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;ithis._chunks))}get shape(){let e=this.find_msg_type(ZF)[0].get(\"offset_to_message\");return async function(e,t){let i=(await Aw.unpack_from_async(\"255&&(s=(await Aw.unpack_from_async(\"0;e.set(\"optional\",a);let c,l=(await Aw.unpack_from_async(\"0&&(c=(await Aw.unpack_from_async(`${s}s`,i,t))[0],t+=s),e.set(\"name\",c);let h=await Aw.unpack_from_async(`<${l}i`,i,t);t+=4*l,e.set(\"client_data_values\",h),r.push(e)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(e){return this.msgs.filter((function(t){return t.get(\"type\")==e}))}async get_attributes(){let e={},t=this.find_msg_type(sv);for(let i of t){let t=i.get(\"offset_to_message\"),[n,r]=await this.unpack_attribute(t);e[n]=r}return e}async get_fillvalue(){var e,t=this.find_msg_type(tv)[0].get(\"offset_to_message\");let i=(await Aw.unpack_from_async(\"=r&&([s,r]=a[++c],l=0);let t=await gw(PF,e,s+l),i=s+l+OF;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[u,f]=await Aw.unpack_from_async(\"=o-qF){let e=c[++l];if(null==e)break;[r,o]=e,h=0}let t=await gw(UF,e,r+h),i=r+h+qF+n;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[d,u]=await Aw.unpack_from_async(\"0,c=(4&n)>0;(8&n)>0?(r=(await Aw.unpack_from_async(\"0&&(t+=8);let r=(2&n)>0?jF:VF,s=await gw(r,e,t),o=new Map;for(let[e,t]of s.entries())o.set(e,t==IF?null:t);return o}get is_dataset(){return this.find_msg_type(ZF).length>0}async get_data(){let e=this.find_msg_type(nv)[0].get(\"offset_to_message\");var[t,i,n,r]=await this._get_data_message_properties(e);if(0==n)throw\"Compact storage of DataObject not implemented\";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(e):void 0}async _get_data_message_properties(e){let t,i,n,[r,s,o]=await Aw.unpack_from_async(\"=1&&r<=4),[r,t,i,n]}async _get_contiguous_data(e){let[t]=await Aw.unpack_from_async(\"=!@\\|]?(i|u|f|S)(\\d*)/.test(n)){let[e,i,s]=yw(n),a=new Array(r);const c=await this.fh.slice(t,t+s*r);let l=new Cw(c);for(var o=0;o=1&&t<=3);var a=\"<\"+(i-1).toFixed()+\"I\",c=await Aw.unpack_from_async(a,this.fh,s);this._chunks=c,this._chunk_dims=i,this._chunk_address=o}}}};var IF=Aw.unpack_from(\"this.get(e)))}length(){return this.keys.length}_dereference(e){if(!e)throw\"cannot deference null reference\";let t=this.file._get_object_by_address(e);if(null==t)throw\"reference not found in file\";return t}async get(e){if(\"number\"==typeof e)return this._dereference(e);var t=dv(e);if(\"/\"==t)return this.file;if(\".\"==t)return this;if(/^\\//.test(t))return this.file.get(t.slice(1));if(\"\"!=function(e){let t=\"/\",i=e.lastIndexOf(t)+1,n=e.slice(0,i),r=new RegExp(\"^\"+t+\"+$\"),s=new RegExp(t+\"$\");n&&!r.test(n)&&(n=n.replace(s,\"\"));return n}(t))var[i,n]=t.split(/\\/(.*)/);else var i=t,n=\".\";if(!(i in this._links))throw i+\" not found in group\";var r=dv(this.name+\"/\"+i);let s=this._links[i];if(\"string\"==typeof s)try{return this.get(s)}catch(e){return null}var o=new kF(this.file._fh,s);if(await o.ready,o.is_dataset){if(\".\"!=n)throw r+\" is a dataset, not a group\";return new hv(r,o,this)}var a=new cv(r,this);return await a.init(o),a.get(n)}visit(e){return this.visititems(((t,i)=>e(t)))}visititems(e){var t=this.name.length;/\\/$/.test(this.name)||(t+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=e(n.name.slice(t),n);if(null!=r)return r;n instanceof cv&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},lv=class extends cv{constructor(e,t,i){super(\"/\",null),this.ready=this.init(e,t,i)}async init(e,t,i){var n=new sF(e,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new kF(e,r);if(await s.ready,this.parent=this,this.file=this,this.name=\"/\",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=e,this.filename=t||\"\",this.mode=\"r\",this.userblock_size=0,i&&i.index)this.index=i.index;else{let t;if(i&&i.indexOffset)t=i.indexOffset;else{const e=await this.attrs;if(e.hasOwnProperty(\"_index_offset\"))t=e._index_offset;else{const e=this.indexName||\"_index\",i=await s.find_link(e);i&&(t=i[1])}}if(t)try{const i=new kF(e,t);await i.ready;const n=await i.get_data(),r=Yb(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(e){console.error(`Error loading index by offset ${e}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(e){return this._dataobjects.offset==e?this:this.visititems((e=>{e._dataobjects.offset}))}},hv=class extends Array{constructor(e,t,i){super(),this.parent=i,this.file=i.file,this.name=e,this._dataobjects=t,this._attrs=null,this._astype=null}get value(){var e=this._dataobjects.get_data();return null==this._astype?this.getValue(e):e.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(e,t){const i=e.length,n=t.reduce(((e,t)=>e*t),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=e;const s=t.slice(1).reverse();for(let e of s){const t=[],{length:i}=r;let n=0;for(;n{let t=e.indexOf(\"\\0\");return t>=0?e.substring(0,t):e})):e}};function dv(e){return e.replace(/\\/(\\/)+/g,\"/\")}async function uv(e){var t;e.url&&(\"function\"==typeof(t=e.url).slice&&\"function\"==typeof t.arrayBuffer)&&(e.file=e.url,e.url=void 0);const i=void 0!==e.url;let n=e.reader?e.reader:function(e){if(e.url)return new lw(e);if(e.path)return new NodeLocalFile(e);if(e.file)return new uw(e.file);throw Error(\"One of 'url', 'path (node only)', or 'file (browser only)' must be specified\")}(e);const r=e.fetchSize||2e3,s=e.maxSize||2e5;i&&(n=new hw({file:n,fetchSize:r,maxSize:s}));const o=new fv(n),a=await async function(e){let t;if(e.indexReader)t=e.indexReader;else{if(e.index)return e.index;e.indexURL?t=new lw({url:e.indexURL}):e.indexPath?t=new NodeLocalFile({path:e.indexPath}):e.indexFile&&(t=new uw({file:e.indexFile}))}if(t){const e=await t.read(),i=(new TextDecoder).decode(e);return JSON.parse(i)}return}(e),c=e.indexOffset,l=function(e){if(e.url)return pv(e.url);if(e.path)return pv(e.path);if(e.file)return e.file.name}(e),h=new lv(o,l,{index:a,indexOffset:c});return await h.ready,h}class fv{constructor(e){this.fileReader=e}async slice(e,t){return this.fileReader.read(e,t-e)}}function pv(e){const t=e.lastIndexOf(\"/\");return t>0?e.substring(t+1):e}class gv{constructor(e,t){this.chrom=e,this.signal_bin_size=t;this.signals={raw_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}`,gc_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}_GC`,gc_partition:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_merge`,baf:`snp_likelihood_${this.chrom}_${this.signal_bin_size}_mask`,baf_i1:`snp_i1_${this.chrom}_${this.signal_bin_size}_mask`,Mosaic_segments:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_segments_2d`,Mosaic_calls:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_call_2d`}}}class mv{constructor(e,t=1e5){this.h5_file=e,this.bin_size=t,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await uv({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(e=this.bin_size){let t=await this.fetch();this.h5_obj=t,this.pytor_keys=t.keys;let i=new wv(this.pytor_keys),n=i.get_rd_bins(),r=i.get_snp_bins();this.available_bins=[...new Set(n,r)],this.available_bins.includes(e)||(e=this.available_bins.at(-1));const s=await t.get(\"rd_chromosomes\");await s.dtype;let o=await s.value,a=await this.rd_stat(e);var c=[],l=[],h=[],d=[],u=[],f=[];for(let t of o){let i=new gv(t,e);var p=i.signals.raw_RD;let n=await this.get_chr_signal(t,e,p,a);c=c.concat(n);var g=i.signals.gc_RD;let r=await this.get_chr_signal(t,e,g,a);l=l.concat(r);let s=i.signals.gc_partition,o=await this.get_chr_signal(t,e,s,a);h=h.concat(o);let m=await this.rd_call_combined(t,e,a,i);d=d.concat(m);let w=i.signals.baf_i1,b=await this.get_baf_signals_v2(t,e,w);u=u.concat(b[0]),f=f.concat(b[1])}this.callers=[],0!=d.length&&this.callers.push(\"ReadDepth\"),0!=d.length&&this.callers.push(\"2D\");var m={},w={RD_Raw:c,RD_Raw_gc_coor:l,ReadDepth:h,\"2D\":d,BAF1:u,BAF2:f};return m[e]=w,m}decode_segments(e){let t=[],i=[];for(let n of e)4294967295==n?(t.push(i),i=[]):i.push(n);return t}async rd_call_combined(e,t,i,n){let r,s=[],o=n.signals.Mosaic_segments;if(this.pytor_keys.includes(o)){const e=await this.h5_obj.get(o);let t=await e.value;r=this.decode_segments(t)}let a=n.signals.Mosaic_calls;if(this.pytor_keys.includes(a)){const n=await this.h5_obj.get(a);let o=await n.to_array();r.forEach(((n,r)=>{n.forEach(((n,a)=>{s.push({chr:e,start:n*t,end:(n+1)*t,value:o[0][r]/i[4]*2})}))}))}return s}async rd_stat(e){let t,i=`rd_stat_${e}_auto`;if(this.pytor_keys.includes(i)){const e=await this.h5_obj.get(i);t=await e.value}return t}async get_chr_signal(e,t,i,n){let r=[];if(this.pytor_keys.includes(i)){const s=await this.h5_obj.get(i);(await s.value).forEach(((i,s)=>{r.push({chr:e,start:s*t,end:(s+1)*t,value:i/n[4]*2})}))}return r}async get_baf_signals(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{let a=Math.max(...i);const c=i.indexOf(a);let l=Math.max(c/200,1-c/200);r.push({chr:e,start:o*t,end:(o+1)*t,value:n*l}),.5!=l&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(1-l)})}))}return[r,s]}async get_baf_signals_v2(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{isNaN(i)||(r.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5-i)}),.5!=i&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5+i)}))}))}return[r,s]}}class wv{constructor(e){this.signals=e}get_rd_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^his_rd_p_(.*)_(\\d+)$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}get_snp_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^snp_likelihood_(.*)_(\\d+)_mask$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}}function bv(e){let t=function(e){if(e.length<4)return e;let t,i,n,r,s,o;return t=e.slice().sort(((e,t)=>e-t)),t.length/4%1==0?(i=.5*(t[t.length/4]+t[t.length/4+1]),n=.5*(t[t.length*(3/4)]+t[t.length*(3/4)+1])):(i=t[Math.floor(t.length/4+1)],n=t[Math.ceil(t.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,t.filter((e=>e>=o&&e<=s))}(e);const i=t.length,n=t.reduce(((e,t)=>e+t))/i,r=Math.sqrt(t.map((e=>Math.pow(e-n,2))).reduce(((e,t)=>e+t))/i);return[n,r]}var Fv={range_function:function(e,t,i){return Array(Math.ceil((t-e)/i)).fill(e).map(((e,t)=>e+t*i))},getDistParams:bv,linspace:function(e,t,i){if(void 0===i&&(i=Math.max(Math.round(t-e)+1,1)),i<2)return 1===i?[e]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*t+(i-r)*e)/i;return n},GetFit:class{constructor(e){this.allBins=e}getValues(){return Object.values(this.allBins).reduce(((e,t)=>e.concat(t.filter((e=>e.binScore>0)).map((e=>e.binScore)))),[])}getMean(e){return e.reduce((function(e,t){return e+t}))/e.length}fit_data(){return bv(this.getValues())}histogram(e,t){const i=t[1]-t[0],n=[];e.forEach(((e,r)=>{t.forEach(((t,r)=>{if(n[t]||(n[t]={count:0}),t<=e&&e{r.push(e.count)})),r}}};function vv(e,t){return isNaN(e)||isNaN(t)||t<=0?NaN:0===e?.5:.5+.5*(yv(.5*t,.5,1)-yv(.5*t,.5,t/(t+e*e)))*Math.sign(e)}function yv(e,t,i){if(0==i)return 0;if(1==i)return 1;{let n=xv(e+t)-xv(e)-xv(t)+e*Math.log(i)+t*Math.log(1-i);return i<(e+1)/(e+t+2)?Math.exp(n)*Av(e,t,i)/e:1-Math.exp(n)*Av(t,e,1-i)/t}}function Av(e,t,i,n=1e3){let r=1,s=1,o=1,a=e+t,c=e+1,l=e-1,h=1-a*i/c;for(let d=0;d<=n;d++){let n=parseFloat(d+1),u=n+n,f=n*(t-n)*i/((l+u)*(e+u)),p=r+f*s,g=h+f*o;f=-(e+n)*(a+n)*i/((c+u)*(e+u));let m=g+f*h,w=r;if(s=p/m,o=g/m,r=(p+f*r)/m,h=1,Math.abs(r-w)<3e-7*Math.abs(r))return r}}function Cv(e){if(0==e||1==e)return 1;return e*Cv(e-1)}function _v(e){let t;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==e)t=1e99;else if(e%1==0)t=Cv(e-1);else{for(let t=0;tt?e:t}))}function Sv(e,t,i,n){return t*Math.exp(-1*(e-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function Ev(e,t,i,n){return Math.exp(-1*(e-i)**2/(t**2+n**2))}function Nv(e,t){let i;try{i=e.reduce(((e,i,n)=>e+Math.min(i,t[n])))}catch{return console.log(\"Failed to find likelihood overlap: \",e,t),0}return i}function Bv(e,t,i,n){return 0==t&&0==n?{nl:.5*(e+i),ne:0}:{nl:(e*n*n+i*t*t)/(t*t+n*n),ne:Math.sqrt(t*t*n*n/(t*t+n*n))}}function Mv(e,t){let i=parseInt(t*(e.length-1)),n=t*(e.length-1)-i;return iMath.floor(t/2)&&(n=t-1-n);const r=(t/2-n)/(t+1),s=Math.floor((t/2+n)/2),o=t-1-s;let a=e.slice(s,o+1).reduce(((e,t)=>e+t),0)/e.reduce(((e,t)=>e+t),0);return n===Math.floor(t/2)&&(a=1),{mean:r,p:a}}var Dv=class{constructor(e,t){this.wigFeatures=e,this.binSize=t}get_fit(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data();return{globalMean:t,globalStd:i}}async call_2d(e=null,t=null,i=\"both\",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let c=null==e?.05*this.binSize/3e9:e,l=null==t?parseInt(this.binSize/1e4):t,h=[],d=[],u=[],f=[],p=[],g=[];for(const[e,t]of Object.entries(this.wigFeatures)){let e=[],i=[],s=[];t.forEach(((t,n)=>{t.hets_count>4&&t.dp_count>l&&(e.push([n]),i.push(t.binScore),s.push(t.likelihood_score),delete t.likelihood_score)}));let o=[];for(let e=1;eMath.sqrt(Math.sqrt(e)**2+this.globalStd**2+Math.pow(a[t]/2,2)))),m=[];for(let t=0;t0;){m=m.filter((e=>\"number\"==typeof e));let t=Iv(m);if(isNaN(t)&&console.log(\"NaN value\",m),te*s[o+1][t])),r=n.reduce(((e,t)=>e+t))}catch{console.log(s),console.log(\"max_overlap:\",t,o,m.length),console.log(\"likelihood: \",o,s[o],s[o+1]),console.log(\"nlh: \",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(e){return e/r})),e[o].push(...e[o+1]),i.splice(o+1,1),g.splice(o+1,1),e.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o0){let e=Ev(i[o-1],g[o-1],i[o],g[o])*Nv(s[o-1],s[o]);m[o-1]=e}}let w=-1;for(;;){m=[];for(let t=0;te*s[r+1][t])),a=n.reduce(((e,t)=>e+t));s[r]=n.map((function(e){return e/a})),e[r].push(...e[r+1]),e[r]=e[r].sort(((e,t)=>e-t)),i.splice(o,1),g.splice(o,1),e.splice(o,1),s.splice(o,1),o>=e.length&&(r+=1,o=r+1)}else o+=1,o>=e.length&&(r+=1,o=r+1)}if(w==e.length)break;w=e.length}e.forEach(((e,n)=>{let o=Rv(s[n]);e.length>1&&(e.forEach(((e,s)=>{d.push(t[e]),o.mean<=r&&h.push(t[e]),t[e].segment_score=i[n]})),u.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let w=Fv.linspace(o,1,m),b={},F={};for(let e=10;e>-1;e--)for(let t=0;t1-t+t*e/2)),a=e/2;e>0?(n=.5-t/(t+s),r=w.map(((e,i)=>.5-(1-e+e*t)/(2-2*e+(t+s)*e)))):(n=0,r=w.map(((e,t)=>0*e)));for(let i=0;i{if(!isNaN(r[t])){let n=Sv(e*this.globalMean,1,u[i],f[i])*Mv(p[i],.5+r[t]);l+=n,n>h&&(h=n,d=w[t])}})),i in b?b[i].push([e,t,s,l/w.length,d]):b[i]=[e,t,s,l/w.length,d]}for(let e=0;ee[3]-t[3]));else if(b[e].sort(((e,t)=>e[3]-t[3])),\"both\"==i&&(F[e].sort(((e,t)=>e[3]-t[3])),F[e][0][3]>b[e][0][3])){let t=b[e].filter((t=>t[0]!=F[e][0][0]&&t[1]<=F[e][0][1]));b[e]=[F[e][0]].push(...t)}for(let e=0;e{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}formatDataStructure_BAF(e,t=-1){const i=[],n=[];for(const[r,s]of Object.entries(this.wigFeatures))s.forEach((r=>{var s={...r},o={...r};let a=r[e];.5!=a&&(o.value=t*(1-a),n.push(o)),s.value=t*a,i.push(s)}));return[i,n]}};const Tv=2871e6;function Lv(e){for(var t=1,i=1,n=1*e,r=1;r<50;r++)t*=r,n+=(i*=-1)*Math.pow(e,2*r+1)/(t*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function zv(e,t,i,n,r){var s=new Ov(i.slice(n,r));return 0==s.std&&(s.std=t>0?t*s.mean/e:1),Uv(e,s.mean,s.std,r-n)/(r-n)}function Hv(e,t,i,n,r){var s=new Ov(i.slice(n,r));if(s.means&!l&c0&&(h=zv(e,t,i,n-1,r)),r-n>2)var d=zv(e,t,i,n+1,r),u=zv(e,t,i,n,r-1);if(re+t))/e.length,this.std=Math.sqrt(e.reduce(((e,t)=>(t-this.mean)**2))/e.length)}}function Uv(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-kv.TdistributionCDF(Math.abs(r),n-1)}function qv(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-kv.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var Qv=class{constructor(e,t,i){this.rd=e,this.mean=t,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(e){var t=[];return e.forEach(((e,i)=>{var n=0;n=e>this.mean/4?this.mean/(this.std**2*e):4/this.std**2,t.push(n)})),t}meanShiftCaller(e,t=3){var i={};return Object.entries(this.rd).forEach((([e,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let e=0;e{var o=r.map(((e,t)=>!e)),a=[];Object.entries(n).forEach((([e,t])=>{a.push(t.binScore)}));var c=[0],l=0;for(let e=0;e0&&(c.push(c[c.length-1]+l-1),l=0):l+=1;c.shift();for(let i=0;i=a.length||Math.abs(t-i)>=a.length)){var u=(i-t)*Math.exp(-.5*(i-t)**2/e**2)*Math.exp(-.5*(a[t]-a[i])**2*h[t]);d[t]+=u}for(var f=new Array,p=0;p=0&&f.push(p);f.push(d.length-1),f=f.concat(c).sort(((e,t)=>e-t)),f=Array.from(new Set(f));var g=0;for(p=0;pe+t))/m.length;a.fill(w,g,f[p]+1),g=f[p]+1}}p=0;for(var b=0;p.01&&f.push(p+1)}f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1);for(p=1;p1))continue;v[0]=f[p-2];var y=[f[p],f[p]];if(!(p.01/Tv*bin_size*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>.01/Tv*bin_size*(A+_))continue}if(Uv(this.mean,x.mean,x.std,x.data.length)>.05)continue;let e=a.slice(F[0],F[1]);var B=new Ov(e);r.fill(!0,F[0],F[1]),s.fill(B.mean,F[0],F[1])}})),i[e]=s})),i}call_mean_shift(e=3){for(var t=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n{var s=t.map(((e,t)=>!e)),o=[];s.forEach(((e,t)=>{e&&o.push(this.rd[t])}));for(var a=[0],c=0,l=0;l0&&(a.push(a[a.length-1]+c-1),c=0):c+=1;a.shift();for(var h=0;h=o.length||Math.abs(l-f)>=o.length)){var p=(f-l)*Math.exp(-.5*(f-l)**2/n**2)*Math.exp(-.5*(o[l]-o[f])**2*d[l]);u[l]+=p}var g=new Array;for(l=0;l=0&&g.push(l);g.push(u.length-1),g=g.concat(a).sort(((e,t)=>e-t)),g=Array.from(new Set(g));var m=0;for(l=0;le+t))/w.length;o.fill(b,m,g[l]+1),m=g[l]+1}}for(l=0,f=0;l.01&&g.push(l+1)}g.unshift(0),g.push(i.length),t=new Array(this.rd.length).fill(!1);for(l=1;l1){v[0]=g[l-2];var y=[g[l],g[l]];if(l3.483106931382794e-9*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>3.483106931382794e-9*(A+_))continue}if(!(Uv(this.mean,x.mean,x.std,x.data.length)>.05)){var B=new Ov(this.rd.slice(F[0],F[1]));t.fill(!0,F[0],F[1]),i.fill(B.mean,F[0],F[1])}}}}}})),i}cnv_calling(e=1e5){var t=.25*this.mean,i=this.mean-t,n=this.mean+t,r=2971e6,s=this.meanShiftCaller(e),o={},a=[];return Object.entries(s).forEach((([c,l])=>{for(var h=!1;!h;){h=!0;var d=new Array(1).fill(0);for(let e=0;e.01&&d.push(e+1)}d.push(l.length);for(let e=0;e0&&(f=Math.abs(l[d[e]]-l[d[e-1]])),e{m.push(t.binScore)}));for(var w,b=new Array(l.length).fill(\"\"),F=0,v=.05*e/r;FA+1){var C=Pv(this.mean,this.std,m,A,_,v);if(C){var _=C;b.fill(\"D\",A,_)}}for(A=F;Fn;)F+=1;(_=F)>A+1&&(C=Pv(this.mean,this.std,m,A,_,v))&&(_=C,b.fill(\"A\",A,_)),F==y&&(F+=1)}for(F=0;FA+1&&(Hv(this.mean,this.std,m,A,_)<1682935038707506e-26&&b.fill([\"d\"]*(_-A),A,_),F-=1),F+=1}(F=0)=b.length););if(F>A){var k=new Ov(x.slice(A,F));x.fill(k.mean,A,F)}F=0;e--){var i;let n=this.allVariants[e];this.allVariants.splice(e,1);let r=n.chr;i=Math.max(Math.floor(n.start/this.rowBinSize),0),t[r]||(t[r]=[]),t[r][i]||(t[r][i]={chr:r,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const s=Object.values(n.calls);if(1!==s.length)throw Error(`Unexpected number of genotypes: ${s.length}. CNVPytor expects 1 and only 1 genotype`);const o=s[0],a=o.info.DP;a&&(t[r][i].dp_sum_score+=Number.parseInt(a),t[r][i].dp_count++);let c=o.info.AD.split(\",\"),l=o.genotype;if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){t[r][i].hets_count++;let e=parseInt(c[0]),n=parseInt(c[1]);t[r][i].hets.push({ref:e,alt:n})}}this.chromosomes=Object.keys(t);var n,r=this.adjust_bin_size(t);if(\"ReadDepth\"==e){n=new Wv(r,this.binSize).ReadDepth_caller();var s=this.formatDataStructure_BAF(r,\"max_likelihood\")}else if(\"2D\"==e){let e=new Dv(r,this.binSize),t=await e.call_2d();n=[t.binScore,[],t.segment_score];s=e.formatDataStructure_BAF(\"max_likelihood\",-1)}return[n,s]}formatDataStructure(e,t,i=1){const n=[];for(const[s,o]of Object.entries(e))for(let e of o){var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}return n}format_BAF_likelihood(e){const t=[];for(const[n,r]of Object.entries(e))for(let e of r){var i={...e};.5!=e.value&&(i.value=1-e.value,t.push(i))}return t}get_max_min_score(e){if(e.likelihood_score.length>0){const t=Math.max(...e.likelihood_score),i=e.likelihood_score.indexOf(t);e.value=Math.max(i/100,1-i/100),e.min_score=Math.min(i/100,1-i/100)}else e.score=0;return e}async getAllbins(){const e=await this.computeDepthFeatures();return new Fv.GetFit(e).fit_data(),e}formatDataStructure_BAF(e,t,i=-1){const n=[],r=[];for(const[a,c]of Object.entries(e))for(let e of c){var s={...e},o={...e};let a=e[t];.5!=a&&(o.value=i*(1-a),r.push(o)),s.value=i*a,n.push(s)}return[n,r]}adjust_bin_size(e){var t={};for(let r of this.chromosomes){t[r]||(t[r]=[]);for(let s=0;sjv(o.ref,o.alt,e)));else{var n=0;t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>{var a=t[r][s].likelihood_score[i]*jv(o.ref,o.alt,e);return n+=a,a})),t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>t[r][s].likelihood_score[i]/n))}t[r][s].binScore=100*parseInt(t[r][s].dp_sum_score/t[r][s].dp_count);const a=this.get_max_min_score(t[r][s]);t[r][s].max_likelihood=a.value}}return t}}function jv(e,t,i,n=!0){return Math.pow(i,e)*Math.pow(1-i,t)+Math.pow(i,t)*Math.pow(1-i,e)}class Wv{constructor(e,t){this.wigFeatures=e,this.binSize=t}ReadDepth_caller(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data(),n=new Qv(this.wigFeatures,t,i),r=n.meanShiftCaller(this.binSize),s=n.cnv_calling();return Object.entries(this.wigFeatures).forEach((([e,t])=>{t.forEach(((t,i)=>{t.partition_level=parseInt(r[e][i]),t.partition_call=parseInt(s[0][e][i])}))})),[this.formatDataStructure(\"binScore\",t),this.formatDataStructure(\"partition_level\",t),this.formatDataStructure(\"partition_call\",t),s[1]]}formatDataStructure(e,t=1){const i=[];for(const[r,s]of Object.entries(this.wigFeatures))for(let r of s){var n={...r};1!=t&&(n.value=r[e]/t*2),i.push(n)}return i}}class Gv extends Hl{static DEFAULT_TRACK_HEIGHT=250;constructor(e,t){super(e,t)}init(e){this.featureType=\"numeric\",this.type=\"cnvpytor\",e.max||(this.defaultScale=!0,this.autoscale=!1),e.height||(e.height=Gv.DEFAULT_TRACK_HEIGHT),this.type=\"cnvpytor\",this.graphType=e.graphType||\"points\",this.bin_size=e.bin_size||1e5,this.signal_name=e.signal_name||\"rd_snp\",this.cnv_caller=e.cnv_caller||\"2D\",this.colors=e.colors||[\"gray\",\"black\",\"green\",\"blue\"],super.init(e)}get supportsWholeGenome(){return!0}get_signals(){let e=[];return\"rd_snp\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller,\"BAF1\",\"BAF2\"]:\"rd\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller]:\"snp\"==this.signal_name?e=[\"BAF1\",\"BAF2\"]:\"cnh\"==this.signal_name&&(e=[this.cnv_caller]),e}get_signal_colors(){return[{singal_name:\"RD_Raw\",color:this.colors[0]},{singal_name:\"RD_Raw_gc_coor\",color:this.colors[1]},{singal_name:\"ReadDepth\",color:this.colors[2]},{singal_name:\"2D\",color:this.colors[2]},{singal_name:\"BAF1\",color:this.colors[3]},{singal_name:\"BAF2\",color:this.colors[3]}]}async postInit(){if(\"vcf\"==this.config.format){let e;this.featureSource?e=Object.values(this.featureSource.getAllFeatures()).flat():(this.featureSource=this.featureSource||Ad(this.config,this.browser.genome),this.header=await this.getHeader(),e=this.featureSource.reader.features);const t=new Vv(e,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},\"2D\"==this.cnv_caller?(r=await t.read_rd_baf(\"2D\"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size][\"2D\"]=i[2],this.available_callers=[\"2D\"]):(r=await t.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=[\"ReadDepth\"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new mv(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const e=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let t in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:\"wig\"};t.features=n,t.name=i,t.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(t);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+t),\"function\"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(e)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if(\"function\"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleKeys=this.callSets?this.callSets.map((e=>e.sample)):[],this.sampleNames=this.sampleKeys}return this.header}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat(this.numericDataMenuItems()),e.push(\"
\"),e.push(\"Bin Sizes\");for(let t of this.available_bins){const i=Dl(t,t===this.bin_size);e.push({object:Bt(i),click:async function(){this.bin_size=t,this.trackView.startSpinner(),await this.recreate_tracks(t),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"Signal Type\");let t={rd_snp:\"RD and BAF Likelihood\",rd:\"RD Signal\",snp:\"BAF Likelihood\"};for(let i in t){const n=Dl(t[i],i===this.signal_name);e.push({object:Bt(n),click:async function(){this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"CNV caller\");for(let t of this.available_callers){const i=Dl(t,t===this.cnv_caller);e.push({object:Bt(i),click:async function(){this.cnv_caller=t,this.trackView.startSpinner(),await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}if(this.variantState){e.push(\"
\");for(let t of this.available_callers)e.push({label:\"Convert to variant track\",click:()=>{this.convertToVariant()}})}return e}async recreate_tracks(e){this.tracks=[];const t=[];e in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(e)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:\"wig\"};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+e),\"function\"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}async getFeatures(e,t,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n)));return Promise.all(r)}}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features;if(!t)return;if(this.defaultScale&&(\"rd_snp\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||5}:\"rd\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||5}:\"snp\"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(e,t){let i=0,n=-Number.MAX_VALUE;for(let e of t)for(let t of e)void 0===t.value||Number.isNaN(t.value)||(i=Math.min(i,t.value),n=Math.max(n,t.value));return{min:i,max:n}}(e.referenceFrame.chr,t)),this.tracks)for(let i=0,n=this.tracks.length;ithis.logScale?this.computeYPixelValueInLogScale(e,i):this.computeYPixelValue(e,i);if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=n(t.y),r={strokeStyle:t.color,strokeWidth:1};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,r):xo.strokeLine(e.context,0,i,e.pixelWidth,i,r)}let r=n(2);xo.dashedLine(e.context,0,r,e.pixelWidth,r,5,{strokeStyle:\"lightgray\",strokeWidth:.5})}paintAxis(e,t,i){var n,r,s,o,a,c,l,h={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let d=void 0!==this.flipAxis&&this.flipAxis;function u(e){return e<0?Math.abs(e):0===e?\"0\":Math.abs(e)>=10||e%1==0?e.toFixed():Math.abs(e)>=1?e.toFixed(1):e.toFixed(2)}xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"}),n=(l=.95*t)-8,a={x:r=l,y:s=o=.01*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.min:this.dataRange.max),n+4,s+12,h),c={x:r,y:s=o=.99*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.max:this.dataRange.min),n+4,s-4,h),xo.strokeLine(e,a.x,a.y,c.x,c.y,h);const f=this.getScaleFactor(this.dataRange.min,this.dataRange.max,i,this.logScale),p=e=>this.logScale?this.computeYPixelValueInLogScale(e,f):this.computeYPixelValue(e,f),g=Math.ceil((this.dataRange.max-this.dataRange.min)/10);for(let t=Math.ceil(this.dataRange.min+1);t0&&t.push(\"
\"),t.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(e,i[n]);t.push(...r)}return t}}async convertToVariant(){this.variantState&&(Object.setPrototypeOf(this,Yv.prototype),this.init(this.variantState),await this.postInit(),this.trackView.clearCachedFeatures(),this.variantState.trackHeight&&this.trackView.setTrackHeight(this.variantState.trackHeight),this.trackView.checkContentHeight(),this.trackView.updateViews(),delete this.variantState)}}const $v=Mt,Kv=10;class Yv extends Hl{static defaults={displayMode:\"EXPANDED\",sortDirection:\"ASC\",showGenotypes:!0,expandedVariantHeight:10,squishedVariantHeight:2,squishedCallHeight:1,expandedCallHeight:10,expandedVGap:2,squishedVGap:1,expandedGroupGap:10,squishedGroupGap:5,featureHeight:14,noGenotypeColor:\"rgb(200,180,180)\",noCallColor:\"rgb(225, 225, 225)\",nonRefColor:\"rgb(200, 200, 215)\",mixedColor:\"rgb(200, 220, 200)\",homrefColor:\"rgb(200, 200, 200)\",homvarColor:\"rgb(17,248,254)\",hetvarColor:\"rgb(34,12,253)\",refColor:\"rgb(0,0,220)\",altColor:\"rgb(255,0,0)\",visibilityWindow:void 0,labelDisplayMode:void 0,type:\"variant\"};_sortDirections=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),e.variantHeight&&(this.expandedVariantHeight=e.variantHeight),this.featureSource=Ad(e,this.browser.genome),this.colorTables=new Map,e.colorTable){const t=e.colorBy||\"*\";this.colorTables.set(t,new ao(e.colorTable))}if(this.strokecolor=e.strokecolor,this._context_hook=e.context_hook,e.color&&(this.colorBy=void 0),this.nVariantRows=1,e.samples)for(let t of e.samples)this.sampleKeys=e.samples;e.sort&&(this.initialSort=e.sort),this._colorByItems=new Map([[\"none\",\"None\"]])}async postInit(){if(this.header=await this.getHeader(),this.header.INFO){const e=new Set(Object.keys(this.header.INFO));this.config.colorBy?this.colorBy=this.config.colorBy:!this.config.color&&e.has(\"AF\")&&(this.colorBy=\"AF\"),e.has(\"AF\")&&this._colorByItems.set(\"AF\",\"Allele frequency\"),e.has(\"VT\")&&this._colorByItems.set(\"VT\",\"Variant Type\"),e.has(\"SVTYPE\")&&this._colorByItems.set(\"SVTYPE\",\"SV Type\")}if(this.config.colorBy&&!this._colorByItems.has(this.config.colorBy)&&this._colorByItems.set(this.config.colorBy,this.config.colorBy),!this.disposed){if(this.header&&!this.sampleKeys&&(this.sampleKeys=this.header.sampleNameMap?Array.from(this.header.sampleNameMap.keys()):[]),void 0===this.visibilityWindow&&!1!==this.config.indexed){const e=Ht(this.config.url)?this.config.url.name:this.config.url;$v(e)&&e.toLowerCase().includes(\"gnomad\")?this.visibilityWindow=1e3:\"function\"==typeof this.featureSource.defaultVisibilityWindow?this.visibilityWindow=await this.featureSource.defaultVisibilityWindow():this.visibilityWindow=1e6}return this}}get supportsWholeGenome(){return!this.config.indexURL||!0===this.config.supportsWholeGenome}get color(){return this._color||\"rgb(0,0,150)\"}set color(e){this._color=e,e&&(this.colorBy=void 0)}async getHeader(){return this.header||\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getSampleCount(){return this.sampleKeys?this.sampleKeys.length:0}async getFeatures(e,t,i,n){void 0===this.header&&(this.header=await this.getHeader());const r=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow});if(this.initialSort){const e=this.initialSort;if(void 0===e.option||\"GENOTYPE\"===e.option.toUpperCase())this.sortSamplesByGenotype(e,r);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"ASC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return r}hasSamples(){return this.getSampleCount()>0}getSamples(){const e=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=t*((\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight)+e),r=Kv+t*(i+e);return{names:this.sampleKeys,yOffset:r,height:n}}computePixelHeight(e){if(!e||0===e.length)return Kv;const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,n=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=!1===this.showGenotypes?0:this.getSampleCount()*t;return Kv+t*(n+i)+i+(s+1)*(r+i)}variantRowCount(e){this.nVariantRows=e}draw({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){xo.fillRect(e,0,s,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const a=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,c=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,l=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=Kv+c*(l+a);let h=this.sampleColumns;const d=this.hasSamples();if(h&&d&&!1!==this.showGenotypes&&xo.strokeLine(e,0,this.variantBandHeight,t,this.variantBandHeight,{strokeStyle:\"rgb(224,224,224) \"}),o){const i=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+t*n+1;for(let t of o){if(t.enda)break;const o=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=Kv+(\"COLLAPSED\"===this.displayMode?0:t.row*(o+s)),l=o;let h=(t.start-r)/n,u=(t.end-r)/n,f=Math.max(1,u-h);f<3?(f=3,h-=1):f>5&&(h+=1,f-=2);const p=t._f||t;let g;try{g=p.alleleFreq()}catch(e){console.log(e)}if(\"AF\"===this.colorBy&&g){const t=Math.min(1,g)*l,i=l-t;e.fillStyle=p.isFiltered()?this.refColorFiltered:this.refColor,e.fillRect(h,c,f,i),e.fillStyle=p.isFiltered()?this.altColorFiltered:this.altColor,e.fillRect(h,c+i,f,t)}else e.fillStyle=this.getColorForFeature(p),e.fillRect(h,c,f,l);let m=this.getVariantStrokecolor(p);if(m&&(e.strokeStyle=m,e.strokeRect(h,c,f,l)),this.callContextHook(p,e,h,c,f,l),d&&!1!==this.showGenotypes){const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=t*(i+s);let n=0;for(let t of this.sampleKeys){const r=this.header.sampleNameMap.get(t),o=p.calls[r];if(o){const t=\"COLLAPSED\"===this.displayMode?0:p.row,r=this.sampleYOffset+n*this.sampleHeight+t*(i+s);let a=!0,c=!0,l=!1;if(o.genotype)for(let e of o.genotype){if(\".\"===e){l=!0;break}0!==e&&(c=!1),0===e&&(a=!1)}o.genotype?e.fillStyle=l?this.noCallColor:c?this.homrefColor:a?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,r,f,i)}n++}}}}else console.log(\"No feature list\")}get refColorFiltered(){return this._refColorFiltered||(this._refColorFiltered=_s.addAlpha(this.refColor,.2)),this._refColorFiltered}get altColorFiltered(){return this._altColorFiltered||(this._altColorFiltered=_s.addAlpha(this.altColor,.2)),this._altColorFiltered}getColorForFeature(e){const t=e._f||e;let i;if(this.colorBy&&\"none\"!==this.colorBy){const e=t.getAttributeValue(this.colorBy);i=void 0!==e?this.getVariantColorTable(this.colorBy).getColor(e):\"gray\"}else i=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"NONVARIANT\"===t.type?this.nonRefColor:\"MIXED\"===t.type?this.mixedColor:this.color;return t.isFiltered()&&(i=_s.addAlpha(i,.2)),i}getVariantStrokecolor(e){const t=e._f||e;let i;return i=this.strokecolor?\"function\"==typeof this.strokecolor?this.strokecolor(t):this.strokecolor:void 0,i}callContextHook(e,t,i,n,r,s){if(this._context_hook&&\"function\"==typeof this._context_hook){const o=e._f||e;t.save(),this._context_hook(o,t,i,n,r,s),t.restore()}}clickedFeatures(e){let t=super.clickedFeatures(e);const i=\"EXPANDED\"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+(\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=e.y;if(r<=this.variantBandHeight){const e=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-Kv)/(e+i));\"COLLAPSED\"!==this.displayMode&&(t=t.filter((e=>e.row===n)))}else if(this.sampleKeys){const e=r-this.variantBandHeight,i=Math.floor(e/this.sampleHeight);if(i>=0&&ie.row===r)),o=this.sampleKeys[i],a=this.header.sampleNameMap.get(o);t=s.map((e=>{const t=e.calls[a];return t.genotypeString=function(e,t){if(e.genotype){let i=\"\";if(\".\"===t.alternateBases)i=\"No Call\";else{const n=t.alternateBases.split(\",\");for(let r of e.genotype)if(i.length>0&&(i+=\" | \"),\".\"===r)i+=\".\";else if(0===r)i+=t.referenceBases;else{i+=n[r-1].replace(\"<\",\"<\")}}return i}}(t,e),t}))}}return t}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=this.browser.genome.id;let r=[];for(let e of t){const t=e._f||e;if(r.length>0&&r.push({html:'
'}),\"function\"==typeof t.popupData){const e=t.popupData(i,n);Array.prototype.push.apply(r,e)}}return r}menuItemList(){const e=[];if(this.header.INFO&&this.header.INFO){const t=this._colorByItems;e.push(\"
\");const i=Bt('
');i.text(\"Color by:\"),e.push({name:void 0,object:i,click:void 0,init:void 0});for(let n of t.keys()){const r=this.colorBy===n;e.push(this.colorByCB({key:n,label:t.get(n)},r))}e.push(this.colorByCB({key:\"info\",label:\"Info field...\"}))}if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const s of this.browser.sampleInfo.attributeNames)if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[s]}))){const o=Bt(\"
\");function a(){const e=this._sortDirections.get(s)||1;this.sortByAttribute(s,e),this.config.sort={option:\"ATTRIBUTE\",attribute:s,direction:e>0?\"ASC\":\"DESC\"},this._sortDirections.set(s,-1*e)}o.html(`  ${s.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:o,click:a})}}e.push(\"
\"),this.getSampleCount()>0&&(e.push({object:Bt('
')}),e.push({object:Bt(Dl(\"Show Genotypes\",this.showGenotypes)),click:function(){this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.browser.sampleNameControl.performClickWithState(this.browser,this.showGenotypes),this.browser.sampleInfoControl.performClickWithState(this.browser,this.showGenotypes)}})),e.push({object:Bt('
')});for(let c of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){e.push({object:Bt(Dl({COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"}[c],c===this.displayMode)),click:function(){this.displayMode=c,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add SVs to circular view\",click:function(){for(let e of this.trackView.viewports)this.sendChordsForViewport(e)}})),this.canCovertToPytor()&&(e.push(\"
\"),e.push({label:\"Convert to CNVpytor track\",click:function(){this.convertToPytor()}})),e}contextMenuItemList(e){const t=[];if(this.hasSamples()&&this.showGenotypes){const i=e.viewport.referenceFrame,n=e.genomicLocation,r=i.toBP(2.5),s=this._sortDirections.get(\"genotype\")||1;this._sortDirections.set(\"genotype\",-1*s),t.push({label:\"Sort by genotype\",click:t=>{const i={direction:s,option:\"genotype\",chr:e.viewport.referenceFrame.chr,start:Math.floor(n-r),end:Math.ceil(n+r)},o=e.viewport.cachedFeatures;this.sortSamplesByGenotype(i,o),this.config.sort=i}}),t.push(\"
\")}if(this.browser.circularView){const i=e.viewport;t.push({label:\"Add SVs to Circular View\",click:()=>{this.sendChordsForViewport(i)}}),t.push(\"
\")}return t}async sortSamplesByGenotype({chr:e,position:t,start:i,end:n,direction:r},s){if(void 0===i&&(i=t-1),void 0===n&&(n=t),s||(s=await this.featureSource.getFeatures({chr:e,start:i,end:n})),!s)return;const o=new Map,a=\"ASC\"===r?1:-1;for(let e of s)if(!(e.endn)break;for(let t of e.calls){const e=t.sample,i=t.zygosityScore();o.set(e,o.has(e)?o.get(e)+i:i)}}this.sampleKeys.sort((function(e,t){let i=o.get(e)||0,n=o.get(t)||0;return a*(i-n)})),this.trackView.repaintViews()}sortByAttribute(e,t){this.config.sort={option:\"ATTRIBUTE\",attribute:e,direction:1===t?\"ASC\":\"DESC\"},this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}sendChordsForViewport(e){const t=e.referenceFrame;let i;if(\"all\"===t.chr){const e=this.featureSource.getAllFeatures(),t=Object.keys(e).map((t=>e[t]));i=[].concat(...t)}else i=this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end);Pm(i.filter((e=>{const t=e._f||e;return t.info&&t.info.CHR2&&t.info.END&&(t.info.CHR2!==t.chr||Math.abs(Number.parseInt(t.info.END)-t.pos)>1e6)})).map((e=>{const t=e._f||e,i=Number.parseInt(t.info.END),n=i-100,r=i+100;return{uniqueId:`${t.chr}:${t.start}-${t.end}_${t.info.CHR2}:${t.info.END}`,refName:zm(t.chr),start:t.start,end:t.end,mate:{refName:zm(t.info.CHR2),start:n,end:r}}})),this,t,.5)}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"info\"!==e.key){function n(){const t=\"none\"===e.key?void 0:e.key;this.colorBy=t,this.config.colorBy=t,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){this.browser.inputDialog.present({label:\"Info field\",value:\"\",callback:e=>{e?(this.colorBy=e,this._colorByItems.set(e,e)):this.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}getState(){const e=super.getState();return this.color&&\"function\"!=typeof this.color&&(e.color=this.color),e}getVariantColorTable(e){if(this.colorTables.has(e))return this.colorTables.get(e);if(this.colorTables.has(\"*\"))return this.colorTables.get(\"*\");{let t;if(\"SVTYPE\"===e)t=Xv;else t=new oo(\"Set1\");return this.colorTables.set(e,t),t}}paintAxis(){}canCovertToPytor(){return!this.config.indexURL&&(!!this.header&&(1===Object.keys(this.sampleKeys).length&&this.header.FORMAT&&this.header.FORMAT.AD&&this.header.FORMAT.DP))}async convertToPytor(){this.variantState={...this.config,...this.getState()},this.variantState.trackHeight=this.height,this.trackView.startSpinner(),setTimeout((async()=>{try{const e=Object.assign({},this.config);Object.setPrototypeOf(this,Gv.prototype),this.init(e),await this.postInit(),this.trackView.clearCachedFeatures(),this.trackView.setTrackHeight(this.config.height||Gv.DEFAULT_TRACK_HEIGHT),this.trackView.checkContentHeight(),this.trackView.updateViews()}finally{this.trackView.stopSpinner()}}),100)}}const Xv=new ao({DEL:\"#ff2101\",INS:\"#001888\",DUP:\"#028401\",INV:\"#008688\",CNV:\"#8931ff\",BND:\"#891100\",\"*\":\"#002eff\"}),Zv={timeout:5e3,type:\"plain\",url:\"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$\",coords:0};async function Jv(e,t){const i=e.searchConfig||Zv;let n;t=t.toUpperCase();const r=e.tracks.filter((e=>e.searchable));for(let e of r){const i=await e.search(t);if(i)return i}if(e.config&&!1!==e.config.search)try{return n=await async function(e,t,i){let n=i.url.replace(\"$FEATURE$\",t.toUpperCase());n.indexOf(\"$GENOME$\")>-1&&(n=n.replace(\"$GENOME$\",e.genome.id?e.genome.id:\"hg19\"));const r=i.timeout?{timeout:i.timeout}:void 0,s=await Qs.loadString(n,r);return function(e,t,i){let n;n=\"plain\"===i.type?function(e,t){const i=[],n=Dt(t);for(let t of n){const n=t.split(\"\\t\");if(n.length>=3){const t=n[1].split(\":\"),r=t[1].split(\"-\");i.push({chromosome:e.genome.getChromosomeName(t[0].trim()),start:parseInt(r[0].replace(/,/g,\"\")),end:parseInt(r[1].replace(/,/g,\"\")),name:n[0].toUpperCase()})}}return i}(e,t):JSON.parse(t);i.resultsField&&(n=n[i.resultsField]);if(n&&0!==n.length){const e=i.chromosomeField||\"chromosome\",t=i.startField||\"start\",r=i.endField||\"end\",s=i.coords||1;let o;o=Array.isArray(n)?n[0]:n,o.hasOwnProperty(e)&&o.hasOwnProperty(t)||console.error(\"Search service results must include chromosome and start fields: \"+o);const a=o[e];let c=o[t]-s,l=o[r];void 0===l&&(l=c+1);const h={chr:a,start:c,end:l};if(!o.type||o.type,i.geneField&&i.snpField){const e=o[i.geneField]||o[i.snpField];e&&(h.name=e.toUpperCase())}return h}return}(e,s,i)}(e,t,i),n}catch(e){console.log(\"Search service not available \"+e)}}function ey(e,t=!1){const i=e.split(\"\\t\");if(i.length>2)try{const e=i[0],t=parseInt(i[1].replace(/,/g,\"\"),10)-1,n=parseInt(i[2].replace(/,/g,\"\"),10);if(!isNaN(t)&&!isNaN(n))return{chr:e,start:t,end:n}}catch(e){}const n=e.split(\":\"),r={chr:n[0]};if(n.length>1){let e,i=n[1].split(\"-\");if(i.length>2){if(!n[1].startsWith(\"-\"))return;{const e=n[1].indexOf(\"-\",1);if(e>0){i=[n[1].substring(0,e),n[1].substring(e+1)]}}}if(e=i[0].replace(/,/g,\"\"),isNaN(e))return;if(r.start=parseInt(e,10)-1,r.end=r.start+1,1===i.length&&(r.start-=20,r.end+=20),2===i.length){if(e=i[1].replace(/,/g,\"\"),isNaN(e))return;if(r.end=parseInt(e,10),r.start<0&&!t){const e=-extent.start;r.start+=e,r.end+=e}}}return r}class ty extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"qtl\",this.name=e.name;const t=e.minLogP||e.min,i=e.maxLogP||e.max;this.dataRange={min:void 0!==t?t:3.5,max:i||25},this.autoscale=!i||e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||2,this.height=e.height||100,this.disableButtons=e.disableButtons,this.featureSource=Ad(e,this.browser.genome)}paintAxis(e,t,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*t,a=s-5,c=s,l=i-(o-this.dataRange.min)/n;xo.strokeLine(e,a,l,c,l,r),l>8&&xo.fillText(e,o,a-1,l+2,r)}r.textAlign=\"center\",xo.fillText(e,\"-log10(pvalue)\",t/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(e,t,i){const n=this.visibilityWindow;return await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const{context:t,referenceFrame:i,pixelWidth:n,pixelHeight:r}=e;this.background&&xo.fillRect(t,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(t,0,r-1,n,r-1,{strokeStyle:this.divider}),i.feature&&i.feature.match(/RS[0-9]+/);const s=i=>{const s=i?2*this.dotSize:this.dotSize,o=e.bpStart,a=(this.dataRange.max-this.dataRange.min)/r;for(let d of e.features){const u=(d.start-o+.5)/e.bpPerPixel;if(u<0)continue;if(u>n)break;const f=d.phenotype;let p;if(this.browser.qtlSelections.qtl?(l=this.browser.qtlSelections.qtl,h=d,p=l.chr===h.chr&&l.start===h.start&&l.pValue===h.pValue):p=this.browser.qtlSelections.snps.size>0?this.browser.qtlSelections.hasSnp(d.snp)&&this.browser.qtlSelections.hasPhenotype(f):this.browser.qtlSelections.hasPhenotype(f),!i||p){var c=-Math.log(d.pValue)/Math.LN10;if(c>=this.dataRange.min){let e;c>this.dataRange.max?(c=this.dataRange.max,e=!0):e=!1;const n=Math.max(0+s,r-Math.round((c-this.dataRange.min)/a));let o;d.px=u,d.py=n,d.radius=s,i&&p?(o=this.browser.qtlSelections.colorForGene(f),xo.setProperties(t,{fillStyle:o,strokeStyle:\"black\"})):(o=e?\"rgb(150, 150, 150)\":\"rgb(180, 180, 180)\",xo.setProperties(t,{fillStyle:o,strokeStyle:o})),xo.fillCircle(t,u,n,s),xo.strokeCircle(t,u,n,s)}}}var l,h};s(!1),s(!0)}popupData(e,t){if(void 0===t&&(t=e.viewport.cachedFeatures),!t||0===t.length)return[];const i=this.name,n=[];for(let r of this._clickedFeatures(e,t))n.length>0&&n.push(\"
\"),\"function\"==typeof r.popupData?n.push(...r.popupData(e)):n.push({name:\"snp id\",value:r.snp},{name:\"gene id\",value:r.gencodeId},{name:\"gene name\",value:r.geneSymbol},{name:\"p value\",value:r.pValue},{name:\"tissue\",value:i});return n}_clickedFeatures(e,t){const i=(e,t)=>Math.sqrt((e.px-t.canvasX)*(e.px-t.canvasX)+(e.py-t.canvasY)*(e.py-t.canvasY)),n=t.filter((t=>i(t,e)<6));if(n.length>1){n.sort(((t,n)=>i(t,e)-i(n,e)));const t=i(n[0],e);return n.filter((n=>i(n,e)<=t))}return n}contextMenuItemList(e){const t=[],i=e.viewport.cachedFeatures;if(i){const n=this._clickedFeatures(e,i);n.length>0&&(t.push({label:\"Highlight associated features\",click:async()=>{this.browser.qtlSelections.clear();for(let e of n)this.browser.qtlSelections.qtl=e,this.browser.qtlSelections.addPhenotype(e.phenotype);this.browser.repaintViews()}}),t.push(\"
\"))}return t}menuItemList(){const e=[];return e.push(...this.numericDataMenuItems()),e.push(\"
\"),e.push({label:\"Search for...\",dialog:function(e){this.browser.inputDialog.present({label:\"Search for snp or phenotype\",value:\"\",callback:async e=>{if(e){e=e.trim().toUpperCase();const t=t=>((t.phenotype&&t.phenotype.toUpperCase())===e||t.snp&&t.snp.toUpperCase()===e)&&-Math.log(t.pValue)/Math.LN10>this.dataRange.min;let i,n,r,s=await this.featureSource.findFeatures(t);if(0==s.length){await this.browser.search(e)&&(s=await this.featureSource.findFeatures(t))}if(s.length>0){this.browser.qtlSelections.clear();const t=new Set;i=s[0].chr,n=s[0].start,r=s[0].end;for(let o of s)o.snp&&o.snp.toUpperCase()===e&&this.browser.qtlSelections.addSnp(o.snp),this.browser.qtlSelections.addPhenotype(o.phenotype),t.add(o.phenotype),o.chr===i&&(n=Math.min(n,o.start),r=Math.max(r,o.end));const o=this.browser.genome.getChromosomeName(i);for(let e of t){const t=await Jv(this.browser,e);t&&o===this.browser.genome.getChromosomeName(t.chr)&&(n=Math.min(n,t.start),r=Math.max(r,t.end))}const a=Math.floor(.1*(r-n));n=Math.max(0,n-a),r+=a,await this.browser.search(`${i}:${n}-${r}`)}}}},e)}}),e}doAutoscale(e){let t=this.config.max||25;if(e.length>0){const i=e.map((e=>-Math.log(e.pValue)/Math.LN10));i.sort(((e,t)=>e-t));t=i[Math.floor(i.length*(this.autoscalePercentile/100))]}return this.dataRange.max=Math.max(t,10),this.dataRange}}const iy={X:\"rgb(204, 153, 0)\",Y:\"rgb(153, 204, 0)\",Un:\"darkGray)\",1:\"rgb(80, 80, 255)\",2:\"rgb(206, 61, 50)\",\"2a\":\"rgb(210, 65, 55)\",\"2b\":\"rgb(215, 70, 60)\",3:\"rgb(116, 155, 88)\",4:\"rgb(240, 230, 133)\",5:\"rgb(70, 105, 131)\",6:\"rgb(186, 99, 56)\",7:\"rgb(93, 177, 221)\",8:\"rgb(128, 34, 104)\",9:\"rgb(107, 215, 107)\",10:\"rgb(213, 149, 167)\",11:\"rgb(146, 72, 34)\",12:\"rgb(131, 123, 141)\",13:\"rgb(199, 81, 39)\",14:\"rgb(213, 143, 92)\",15:\"rgb(122, 101, 165)\",16:\"rgb(228, 175, 105)\",17:\"rgb(59, 27, 83)\",18:\"rgb(205, 222, 183)\",19:\"rgb(97, 42, 121)\",20:\"rgb(174, 31, 99)\",21:\"rgb(231, 199, 111)\",22:\"rgb(90, 101, 94)\",23:\"rgb(204, 153, 0)\",24:\"rgb(153, 204, 0)\",25:\"rgb(51, 204, 0)\",26:\"rgb(0, 204, 51)\",27:\"rgb(0, 204, 153)\",28:\"rgb(0, 153, 204)\",29:\"rgb(10, 71, 255)\",30:\"rgb(71, 117, 255)\",31:\"rgb(255, 194, 10)\",32:\"rgb(255, 209, 71)\",33:\"rgb(153, 0, 51)\",34:\"rgb(153, 26, 0)\",35:\"rgb(153, 102, 0)\",36:\"rgb(128, 153, 0)\",37:\"rgb(51, 153, 0)\",38:\"rgb(0, 153, 26)\",39:\"rgb(0, 153, 102)\",40:\"rgb(0, 128, 153)\",41:\"rgb(0, 51, 153)\",42:\"rgb(26, 0, 153)\",43:\"rgb(102, 0, 153)\",44:\"rgb(153, 0, 128)\",45:\"rgb(214, 0, 71)\",46:\"rgb(255, 20, 99)\",47:\"rgb(0, 214, 143)\",48:\"rgb(20, 255, 177)\"};for(let DA of Object.keys(iy)){iy[\"chr\"+DA]=iy[DA]}for(let TA=1;TA<=48;TA++){if(10===TA)continue;const LA=ny(TA);iy[LA]=iy[TA.toString()]}function ny(e){if(!+e)return!1;for(var t=String(+e).split(\"\"),i=[\"\",\"C\",\"CC\",\"CCC\",\"CD\",\"D\",\"DC\",\"DCC\",\"DCCC\",\"CM\",\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\",\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"],n=\"\",r=3;r--;)n=(i[+t.pop()+10*r]||\"\")+n;return Array(+t.join(\"\")+1).join(\"M\")+n}class ry extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.useChrColors=void 0===e.useChrColors||e.useChrColors,this.trait=e.trait,this.posteriorProbability=e.posteriorProbability,this.valueProperty=\"bed\"===e.format?\"score\":\"value\",this.height=e.height||100,this.autoscale=e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||3,this.popoverWindow=void 0===e.popoverWindow?1e8:e.popoverWindow,this.useChrColors?this.colorScale=new ao(e.colorTable||iy):e.color?this.colorScale=new ff(e.color):this.colorScale=new df(e.colorScale||{thresholds:[5e-8,5e-4,.5],colors:[\"rgb(255,50,50)\",\"rgb(251,100,100)\",\"rgb(251,170,170)\",\"rgb(227,238,249)\"]}),this.featureSource=Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.features,i=e.context,n=e.pixelWidth,r=e.pixelHeight;if(this.background&&xo.fillRect(i,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),t){const s=e.bpPerPixel,o=e.bpStart,a=o+n*s+1;for(let e of t){const t=e.start;if(ta)break;let n;if(this.posteriorProbability)n=e[this.valueProperty];else{const t=e[this.valueProperty];if(!t)continue;n=-Math.log10(t)}const c=this.useChrColors?e._f?e._f.chr:e.chr:n,l=this.colorScale.getColor(c),h=(this.dataRange.max-this.dataRange.min)/r,d=Math.round((t-o)/s),u=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/h));l&&xo.setProperties(i,{fillStyle:l,strokeStyle:\"black\"}),xo.fillCircle(i,d,u,this.dotSize),e.px=d,e.py=u}}}paintAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});var n={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const t=.1;for(let s=this.dataRange.min;s0&&i.push(\"
\"),5==r){i.push(\"...\");break}if(s=s._f||s,\"function\"==typeof s.popupData)i=i.concat(s.popupData());else{const e=s[this.valueProperty],t=s.chr,r=Rt(s.start+1);i.push({name:\"chromosome\",value:t}),i.push({name:\"position\",value:r}),i.push({name:\"name\",value:s.name}),n.posteriorProbability?i.push({name:\"posterior probability\",value:e}):i.push({name:\"pValue\",value:e})}r++}}}return i}menuItemList(){return this.numericDataMenuItems()}doAutoscale(e){if(e.length>0){const t=this.valueProperty,i=this.posteriorProbability,n=e.map((function(e){const n=e[t];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=qa(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class sy extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.autoscale=e.autoscale||void 0===e.max,this.dataRange={min:e.min||0,max:e.max},this.windowFunction=e.windowFunction||\"mean\",this.paintAxis=cd,this.graphType=e.graphType||\"bar\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=Ad(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if(\"function\"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleKeys=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty(\"clickToHighlight\")){let e=this.header.clickToHighlight;this.config.clickToHighlight=e,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty(\"highlight\")){this.config.highlightSamples={};let e=this.header.highlight;Array.isArray(e)||(e=[e]);for(let t of e){const e=t.split(\";\");2===e.length&&(this.config.highlightSamples[e[0]]=e[1])}}}}menuItemList(){return this.numericDataMenuItems()}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let e=1;et&&(r=e-1),void 0===s&&n[e].start>i){s=e+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=e,a=e=>(this.dataRange.max-e)/(this.dataRange.max-this.dataRange.min)*o,c=function(e){let t=Math.floor((e-r)/n);return isNaN(t)&&console.warn(\"isNaN(x). feature start \"+Rt(e)+\" bp start \"+Rt(r)),t};if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const e=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},l=[],h=[];this.clickDetectorCache={};for(let d of t){const t=c(d.start),u=c(d.end),f=s>=0?c(s):t;if(!isNaN(t)&&!isNaN(u)){this.clickDetectorCache[t]=[],this.clickDetectorCache[u]=[];for(let s=0;s=1){const s=o[c],h=a(s),d=e&&e[c];d?l.push([f,h,t,g,d]):r&&c in this.config.samplesClickedToHighlight?l.push([f,h,t,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,f,h,t,g,{strokeStyle:\"#D9D9D9\"}),n&&!(c in e)||this.clickDetectorCache[t].push([f,h,t,g,c,d||\"gray\"])}if(u-t>=1){const s=e&&e[c];s?h.push([t,g,u,g,s]):r&&c in this.config.samplesClickedToHighlight?h.push([t,g,u,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,t,g,u,g,{strokeStyle:\"gray\"}),n&&!(c in e)||this.clickDetectorCache[u].push([t,g,u,g,c,s||\"gray\"])}o[c]=p}s=d.end}}for(let e of l)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:1.3});for(let e of h)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:2})}(e=>{if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=a(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):xo.strokeLine(e.context,0,i,e.pixelWidth,i,n)}})(e)}doAutoscale(e){let t,i;return e.length>0?(t=Number.MAX_VALUE,i=-Number.MAX_VALUE,e.forEach((function(e){t=Math.min(t,...e.values),i=Math.max(i,...e.values)})),t-=.01,i+=.01):(t=0,i=100),{min:t,max:i}}clickedFeatures(e){const t=e.canvasX,i=e.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=t)break;if(n){let e=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(ts)return[];const a=n[1],c=n[3];if(iMath.max(a,c)+10)continue;const l=oy(t,i,r,a,s,c);l0?c/l:0}class ay extends Hl{static defaults={height:300,theta:Math.PI/2,arcOrientation:\"UP\"};constructor(e,t){super(e,t),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",\"bp\"===e.format?this.featureSource=new ly(e,t.genome):this.featureSource=new ud(e,t.genome)}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.context,i=Math.PI/2,n=e.pixelWidth,r=e.pixelHeight;e.viewportWidth;const s=e.bpPerPixel,o=e.bpStart,a=s,c=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,n,r,{fillStyle:\"rgb(255, 255, 255)\"});const l=e.features;if(l){cy(l,1);for(let e of l)if(e.startLeft){let n=Math.round((e.startLeft-o)/a),r=Math.round((e.startRight-o)/a),s=Math.round((e.endLeft-o)/a),l=Math.round((e.endRight-o)/a);t.fillStyle=e.color,t.strokeStyle=e.color,t.beginPath();let h=(n+l)/2,d=(l-n)/2,u=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);c?(t.arc(h,u,d,f,p),t.lineTo(s,u)):(u=0,t.arc(h,u,d,p,f),t.lineTo(l,u));const g=(r+s)/2,m=(s-r)/2,w=u;c?(t.arc(g,w,m,p,f,!0),t.lineTo(n,w)):(t.arc(g,w,m,f,p,!0),t.lineTo(s,w)),t.stroke(),t.fill(),e.drawState={x1:h,y1:u,r1:d,x2:g,y2:w,r2:m,sa:f,ea:p}}else{let n=Math.round((e.start-o)/a),r=Math.round((e.end-o)/a);t.strokeStyle=e.color,t.beginPath();let s=(n+r)/2,l=(r-n)/2,h=this.height,d=Math.PI+(Math.PI/2-i),u=2*Math.PI-(Math.PI/2-i);c?t.arc(s,h,l,d,u):(h=0,t.arc(s,h,l,u,d)),t.stroke(),e.drawState={x1:s,y1:h,r1:l,sa:d,ea:u}}}}clickedFeatures(e){const t=super.clickedFeatures(e),i=[];cy(t,-1);for(let n of t){const t=n.drawState,r=e.canvasX-t.x1,s=e.canvasY-t.y1,o=Math.sqrt(r*r+s*s),a=t.r1+3;let c,l;if(void 0===t.x2)c=o,l=t.r1-3;else{const i=e.canvasX-t.x2,n=e.canvasY-t.y2;c=Math.sqrt(i*i+n*n),l=t.r2-3}if(ol){i.push(n);break}}return i}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0)return this.extractPopupData(t[0],this.getGenomeId())}menuItemList(){return[{name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}]}}function cy(e,t){e.sort((function(e,i){const n=void 0===e.score?-Number.MAX_VALUE:e.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===t?1:t)*(n-r)}))}class ly{constructor(e,t){this.config=e,this.genome=t}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,t,i);{const n=Ua(this.config),r=await Qs.loadByteArray(this.config.url,n);return this.featureCache=new Zs(function(e){if(!e)return null;const t=mh(e);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=t.nextLine());){const e=i.split(\"\\t\");if(n&&i.startsWith(\"color:\")){const t=\"rgb(\"+e[1]+\",\"+e[2]+\",\"+e[3]+\")\";r.push(t),e.length>4&&s.push(e[4])}else{n=!1;const t=e[0],i=Number.parseInt(e[1])-1,c=Number.parseInt(e[2])-1,l=Number.parseInt(e[3]),h=Number.parseInt(e[4]);var a=Number.parseInt(e[5]);const d=r[a];let u;u=i<=h?{chr:t,startLeft:Math.min(i,c),startRight:Math.max(i,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:d,score:a}:{chr:t,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(i,c),endRight:Math.max(i,c),color:d,score:a},u.start=u.startLeft,u.end=u.endRight,s.length>a&&(u.description=s[a]),o.push(u)}}return o}(r),s),this.featureCache.queryFeatures(e,t,i)}}}class hy{constructor(e){this.browser=e,this.type=\"ideogram\",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,features:r}){const s=t.chr,o=t.genome.getChromosome(s);if(void 0===o||i<=0||n<=0||\"all\"===s.toLowerCase())return;!function({ctx:e,chr:t,referenceFrame:i,genome:n,width:r,height:s,stainColors:o,features:a}){const c=1,l=.5*c,h=0;if(void 0===n)return;xo.fillRect(e,0,0,r,s,{fillStyle:_s.greyScale(255)});const d=a;if(d){const t=h+s/2,i=[],n=[];if(0===d.length)return;const a=r/d[d.length-1].end;e.beginPath(),xo.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1),e.clip();for(let r=0;r0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),o.bpLength=l),a{uy.getColor(e)}));class fy extends Hl{static defaults={margin:10,colorByNumReadsThreshold:5,height:100};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=e.type||\"junctions\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){return this.height}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.isMergedTrack||xo.fillRect(i,0,e.pixelTop,s,o,{fillStyle:\"rgb(255, 255, 255)\"}),t){const s={};s.referenceFrame=e.viewport.referenceFrame,s.referenceFrameStart=s.referenceFrame.start,s.referenceFrameEnd=s.referenceFrameStart+s.referenceFrame.toBP(e.viewport.getWidth()),s.featureZoomOutTracker={};for(let e of t)if(!(e.enda)break;this.renderJunction(e,r,n,o,i,s)}}else console.log(\"No feature list\")}renderJunction(e,t,i,n,r,s){e.isVisible=!1;const o=Math.round((e.start-t)/i),a=Math.round((e.end-t)/i),c=(o+a)/2;if(a-o<=3){if(c in s.featureZoomOutTracker)return;s.featureZoomOutTracker[c]=!0}if(this.config.hideAnnotatedJunctions&&\"true\"===e.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&\"false\"===e.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(e.attributes.motif))return;if(this.config.hideStrand===e.strand)return;if(this.config.minJunctionEndsVisible){let t=0;if(e.start>=s.referenceFrameStart&&e.start<=s.referenceFrameEnd&&(t+=1),e.end>=s.referenceFrameStart&&e.end<=s.referenceFrameEnd&&(t+=1),t0&&h/d>this.config.maxFractionMultiMappedReads)return;if(e.attributes.maximum_spliced_alignment_overhang&&parseInt(e.attributes.maximum_spliced_alignment_overhang)this.config.maxSamplesWithThisJunction)return;if(e.attributes.num_samples_total&&(e.attributes.percent_samples_with_this_junction=100*u/Number(e.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(e.attributes.percent_samples_with_this_junctionthis.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,p=n,g=f+.5*p;let m=f;const w=f+p-10,b=(o+c)/2,F=(c+a)/2;let v,y,A=1;e.attributes.line_width?A=Number(e.attributes.line_width):(void 0===this.config.thicknessBasedOn||\"numUniqueReads\"===this.config.thicknessBasedOn?A=l:\"numReads\"===this.config.thicknessBasedOn?A=d:\"numSamplesWithThisJunction\"===this.config.thicknessBasedOn&&void 0!==u&&(A=u),A=1+Math.log(A+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||\"random\"===this.config.bounceHeightBasedOn?v=(e.start+e.end)%7:\"distance\"===this.config.bounceHeightBasedOn?v=6*(e.end-e.start)/(s.referenceFrameEnd-s.referenceFrameStart):\"thickness\"===this.config.bounceHeightBasedOn&&(v=2*A),m+=p*Math.max(7-v,0)/10,y=e.attributes.color?e.attributes.color:void 0===this.config.colorBy||\"numUniqueReads\"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"numReads\"===this.config.colorBy?d>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"isAnnotatedJunction\"===this.config.colorBy?\"true\"===e.attributes.annotated_junction?\"#b0b0ec\":\"orange\":\"strand\"===this.config.colorBy?\"+\"===e.strand?\"#b0b0ec\":\"#ecb0b0\":\"motif\"===this.config.colorBy?uy.getColor(e.attributes.motif):\"#AAAAAA\";let C=\"\";e.attributes.label?C=e.attributes.label.replace(/_/g,\" \"):void 0===this.config.labelWith||\"uniqueReadCount\"===this.config.labelWith?C=l:\"totalReadCount\"===this.config.labelWith?C=d:\"numSamplesWithThisJunction\"===this.config.labelWith?void 0!==u&&(C=u):\"percentSamplesWithThisJunction\"===this.config.labelWith?void 0!==e.attributes.percent_samples_with_this_junction&&(C=e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%\"):\"motif\"===this.config.labelWith&&void 0!==e.attributes.motif&&(C+=e.attributes.motif),\"uniqueReadCount\"===this.config.labelWithInParen?C+=\" (\"+l+\")\":\"totalReadCount\"===this.config.labelWithInParen?C+=\" (\"+d+\")\":\"multiMappedReadCount\"===this.config.labelWithInParen?h>0&&(C+=\" (+\"+h+\")\"):\"numSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==u&&(C+=\" (\"+u+\")\"):\"percentSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==e.attributes.percent_samples_with_this_junction&&(C+=\" (\"+e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%)\"):\"motif\"===this.config.labelWithInParen&&void 0!==e.attributes.motif&&(C+=` ${e.attributes.motif}`),e.isVisible=!0,r.beginPath(),r.moveTo(o,w),r.bezierCurveTo(b,m,F,m,a,w),r.lineWidth=A,r.strokeStyle=y,r.stroke();const _=(e,t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-n/2,i-n),e.lineTo(t+n/2,i-n),e.lineTo(t,i),e.closePath(),e.fill()};if(e.attributes.left_shape||e.attributes.right_shape){r.fillStyle=y;const t=r.lineWidth>2?10:7;e.attributes.left_shape&&_(r,o,w,t),e.attributes.right_shape&&_(r,a,w,t)}r.fillText(C,c-r.measureText(C).width/2,(7*m+g)/8)}clickedFeatures(e){return super.clickedFeatures(e).filter((function(e){return e.isVisible&&e.attributes}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=\"function\"==typeof e.popupData?e.popupData(i):this.extractPopupData(e._f||e,this.getGenomeId());t&&(n.length>0&&n.push(\"

\"),Array.prototype.push.apply(n,t))}return n}dispose(){this.trackView=void 0}}const py={min:0,max:3e3,color:\"rgb(0,0,255)\"};class gy{constructor(e){e=e||py,this.max=e.max,this.min=e.min||0,this.cache=[],this.nbins=1e3,this.binsize=(this.max-this.min)/this.nbins,this.updateColor(e.color||\"rgb(0,0,255)\")}updateColor(e){const t=e.substring(4).replace(\")\",\"\").split(\",\");3===t.length&&(this.r=Number.parseInt(t[0].trim()),this.g=Number.parseInt(t[1].trim()),this.b=Number.parseInt(t[2].trim())),this.cache=[]}setMinMax(e,t){this.min=e,this.max=t,this.cache=[],this.binsize=(this.max-this.min)/this.nbins}getColor(e){if(e\");let t=Bt(\"
\");return t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),e}setDataRange({min:e,max:t}){this.dataRange.min=e,this.dataRange.max=t,this.colorScale.min=e,this.colorScale.max=t,this.trackView.repaintViews()}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.rowHeight,yOffset:0}}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){const a=this.rowHeight,c=t+n,l=o+i*s+1,h=a;for(let i of r){if(i.endl)continue;const n=Math.round((i.start-o)/s),r=Math.round((i.end-o)/s),d=Math.max(1,r-n);let u=0;for(let r=i.values.length-1;r>=0;r--){const s=i.values[r],o=u*a;if(o+ac)continue;const l=this.colorScale.getColor(s);e.fillStyle=l,e.fillRect(n,o,d,h),u++}}}}computePixelHeight(e){return e&&0!==e.length?e[0].values.length*this.rowHeight:0}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}get supportsWholeGenome(){return!1}getState(){const e=super.getState();return e.colorScale=this.colorScale.toJson(),e}}const wy=new Map([[\"ideogram\",(e,t)=>new hy(e,t)],[\"sequence\",(e,t)=>new Zd(e,t)],[\"feature\",(e,t)=>new Hd(e,t)],[\"seg\",(e,t)=>new Pf(e,t)],[\"mut\",(e,t)=>new Pf(e,t)],[\"maf\",(e,t)=>new Pf(e,t)],[\"shoebox\",(e,t)=>new my(e,t)],[\"wig\",(e,t)=>new ld(e,t)],[\"merged\",(e,t)=>new tf(e,t)],[\"alignment\",(e,t)=>new tw(e,t)],[\"interaction\",(e,t)=>new iw(e,t)],[\"interact\",(e,t)=>new iw(e,t)],[\"variant\",(e,t)=>new Yv(e,t)],[\"qtl\",(e,t)=>new ty(e,t)],[\"eqtl\",(e,t)=>new ty(e,t)],[\"gwas\",(e,t)=>new ry(e,t)],[\"arc\",(e,t)=>new ay(e,t)],[\"gcnv\",(e,t)=>new sy(e,t)],[\"junction\",(e,t)=>new fy(e,t)],[\"blat\",(e,t)=>new Vd(e,t)],[\"cnvpytor\",(e,t)=>new Gv(e,t)]]);class by{constructor(e,t){const i=(new DOMParser).parseFromString(e,\"text/xml\");this.processRootNode(i,t);const n=i.getElementsByTagName(\"Resource\"),r=i.getElementsByTagName(\"Track\"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(e,t){var i={url:e.getAttribute(\"path\"),indexURL:e.getAttribute(\"index\"),order:t};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(e){const t=e.getElementsByTagName(\"Track\");if(t&&t.length>0){const i={type:\"merged\",tracks:[]};Fy(e,i),o.push(i),Array.from(t).forEach((function(e){e.processed=!0;const t=e.getAttribute(\"id\"),n=a.get(t);n&&(i.tracks.push(n),Fy(e,n),n.autoscale=!1,i.height=n.height)}))}else if(!e.processed){const t=e.getAttribute(\"id\"),i=a.get(t);i&&(o.push(i),Fy(e,i))}}))}processRootNode(e,t){const i=e.getElementsByTagName(\"Session\");!i||i.length;const n=i.item(0),r=n.getAttribute(\"genome\"),s=n.getAttribute(\"locus\"),o=n.getAttribute(\"ucscID\");t&&t.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Fy(e,t){t.name=e.getAttribute(\"name\");const i=e.getAttribute(\"color\");i&&(t.color=\"rgb(\"+i+\")\");const n=e.getAttribute(\"altColor\");i&&(t.altColor=\"rgb(\"+n+\")\");const r=e.getAttribute(\"height\");r&&(t.height=parseInt(r));const s=e.getAttribute(\"autoScale\");s&&(t.autoscale=\"true\"===s);const o=e.getAttribute(\"autoscaleGroup\");o&&(t.autoscaleGroup=o);const a=e.getAttribute(\"windowFunction\");a&&(t.windowFunction=a);const c=e.getAttribute(\"visibilityWindow\")||e.getAttribute(\"featureVisibilityWindow\");c&&(t.visibilityWindow=c);const l=e.getAttribute(\"indexed\");l&&(t.indexed=\"true\"===l);const h=e.getAttribute(\"normalize\");h&&(t.normalize=\"true\"===h);const d=e.getElementsByTagName(\"DataRange\");if(d.length>0){const e=d.item(0);t.min=Number(e.getAttribute(\"minimum\")),t.max=Number(e.getAttribute(\"maximum\")),t.logScale=\"LOG\"===e.getAttribute(\"type\")}}class vy{constructor(e,t,i,n,r){this.genome=e,this.chr=t,this.start=i,this.end=n,this.bpPerPixel=r,this.id=s()}get center(){return(this.start+this.end)/2}get locusSearchString(){return`${this.chr}:${this.start+1}-${this.end}`}extend(e){const t=Math.min(e.start,this.start),i=Math.max(e.end,this.end),n=(i-t)/(this.end-this.start);this.start=t,this.end=i,this.bpPerPixel*=n}calculateEnd(e){return this.start+this.bpPerPixel*e}calculateCenter(e){return this.start+this.bpPerPixel*e/2}calculateBPP(e,t){return(e-this.start)/t}set(e){this.chr=e.chr,this.start=e.start,this.bpPerPixel=e.bpPerPixel}toPixels(e){return e/this.bpPerPixel}toBP(e){return this.bpPerPixel*e}shift(e){this.start+=e,this.end+=e}shiftPixels(e,t,i){const n=this.start,r=e*this.bpPerPixel;return this.start+=r,i&&this.clampStart(t),this.end=this.start+t*this.bpPerPixel,n!==this.start}clampStart(e){const t=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(t,this.start),e){const{bpLength:t}=this.genome.getChromosome(this.chr),i=t-e*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(e,t,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,s=this.start,o=this.bpPerPixel,a=this.getChromosome().bpLength,c=t<1?e.minimumBases()/i:a/i;this.bpPerPixel=t<1?Math.max(this.bpPerPixel*t,c):Math.min(this.bpPerPixel*t,c);const l=this.bpPerPixel*i;this.start=r-.5*l,this.clampStart(i),this.end=this.start+l;(s!==this.start||o!==this.bpPerPixel)&&await e.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(e){const t=\" \",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*e);return`${t}${this.chr}${t}${Wa(n-i)}${t}`}getMultiLocusLabelLocusOnly(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e);return`${t}${i}:${n}-${r}${t}`}getMultiLocusLabel(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e),s=Math.floor(this.start)+1;return`${t}${i}:${n}-${r}${t}${t}(${Wa(Math.round(this.start+this.bpPerPixel*e)-s)})${t}`}getPresentationLocusComponents(e){if(\"all\"===this.chr)return{chr:this.chr};{const t=Rt(Math.floor(this.start)+1),i=Rt(Math.round(this.start+this.bpPerPixel*e));return{chr:this.chr,start:t,end:i}}}getLocusString(){if(\"all\"===this.chr)return\"all\";return`${this.genome.getChromosomeDisplayName(this.chr)}:${Rt(Math.floor(this.start)+1)}-${Rt(Math.round(this.end))}`}description(e){console.log(` ${e||\"\"} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Rt(Math.round(this.start))} end ${Rt(Math.round(this.end))} `)}overlaps(e){return this.chr===e.chr&&this.end>=e.start&&e.end>=this.start}}function yy(){return\"3.0.9\"}const Ay=\"Maximum sequence count exceeded\";class Cy{constructor(t,i){this.container=e({class:\"igv-chromosome-select-widget-container\"}),i.appendChild(this.container),this.select=document.createElement(\"select\"),this.select.setAttribute(\"name\",\"chromosome-select-widget\"),this.container.appendChild(this.select),this.select.addEventListener(\"change\",(()=>{this.select.blur(),\"\"!==this.select.value&&Ay!==this.select.value&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes,this.genome=t.genome}show(){this.container.style.display=\"flex\"}hide(){this.container.style.display=\"none\"}setValue(e){this.select.value=this.genome.getChromosomeDisplayName(e)}update(e){this.genome=e;const t=e.wgChromosomeNames.map((t=>e.getChromosomeDisplayName(t)))||[];if(this.showAllChromosomes&&e.chromosomeNames.length>1){const i=new Set(t);let n=0;for(let r of e.chromosomeNames){if(1e3==++n){t.push(Ay);break}i.has(r)||(r=e.getChromosomeDisplayName(r),t.push(r))}}this.select.innerHTML=\"\",e.showWholeGenomeView()&&t.unshift(\"all\");for(let i of t){const t=document.createElement(\"option\");t.setAttribute(\"value\",i),t.innerText=e.getChromosomeDisplayName(i),this.select.appendChild(t)}}}class _y{constructor(t,i){this.container=e({class:\"igv-windowsize-panel-container\"}),t.appendChild(this.container),i.on(\"locuschange\",(e=>{this.updatePanel(e)})),this.browser=i}show(){this.container.style.display=\"block\"}hide(){this.container.style.display=\"none\"}updatePanel(e){const t=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===e.length?Wa(Math.round(t*e[0].bpPerPixel)):\"\"}}class xy extends Ju{constructor(e,t,i,n){super(e,t,\"Select Tracks\",ef,'\\n multi select\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n multi select hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.navbar=i,this.enableMultiTrackSelection=!1,this.button.addEventListener(\"mouseenter\",(e=>{!1===n&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(e=>{!1===n&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{this.setMultiTrackSelection(!this.enableMultiTrackSelection)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler)}setMultiTrackSelection(e){this.enableMultiTrackSelection=e,this.setState(this.enableMultiTrackSelection),!1===this.enableMultiTrackSelection&&this.navbar.overlayTrackButton.setVisibility(!1);for(const t of this.browser.trackViews)t.enableTrackSelection(e)}}class ky{constructor(t,i){this.browser=i,this.columnContainer=t,this.horizontalGuide=e({class:\"igv-cursor-guide-horizontal\"}),t.appendChild(this.horizontalGuide),this.verticalGuide=e({class:\"igv-cursor-guide-vertical\"}),t.appendChild(this.verticalGuide),this.addMouseHandler(i),this.setVisibility(i.config.showCursorGuide)}addMouseHandler(e){this.boundMouseMoveHandler=function(t){t.target.tagName;const{x:i,y:n}=a(t,this.columnContainer);if(this.horizontalGuide.style.top=`${n}px`,\"CANVAS\"===t.target.tagName){const n=function(e,t){for(;e.parentElement;){if(e.parentElement.classList.contains(t))return e.parentElement;e=e.parentElement}return}(t.target,\"igv-viewport\");if(n&&e.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const r=e.root.querySelectorAll(\".igv-column\");let s;const o=n.parentElement;for(let e=0;e\\n cursor\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n cursor hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.doShowCursorGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCursorGuide&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCursorGuide&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCursorGuide=!t.doShowCursorGuide,t.setCursorGuideVisibility(t.doShowCursorGuide),this.setState(t.doShowCursorGuide)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCursorTrackingGuideButton)}}class Sy extends Ju{constructor(e,t){super(e,t,\"Center Line\",ef,'\\n centerline\\n \\n \\n \\n \\n \\n \\n','\\n centerline hover\\n \\n \\n \\n \\n \\n \\n',t.config.showCenterGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCenterLine&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCenterLine&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCenterLine=!t.doShowCenterLine,t.setCenterLineVisibility(t.doShowCenterLine),this.setState(t.doShowCenterLine)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCenterGuideButton)}}class Ey extends Ju{constructor(e,t){super(e,t,\"Track Labels\",ef,'\\n track labels\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n track labels hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showTrackLabels),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowTrackLabels&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowTrackLabels&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowTrackLabels=!t.doShowTrackLabels,t.setTrackLabelVisibility(t.doShowTrackLabels),this.setState(t.doShowTrackLabels)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showTrackLabelButton)}}class Ny extends Ju{constructor(e,t){super(e,t,[\"ROI\",\"Regions of Interest Table\"],ef,'\\n roi\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n','\\n roi hover\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowROITable&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowROITable&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>this.buttonHandler(!t.doShowROITable))),this.setVisibility(!1)}buttonHandler(e){this.setState(e),this.browser.setROITableVisibility(e)}}class By extends Ju{constructor(e,t){super(e,t,\"Sample Info\",ef,'\\n sample info\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample info hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.showSampleInfo=!1,this.button.addEventListener(\"mouseenter\",(()=>{!1===this.showSampleInfo&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===this.showSampleInfo&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)}))}performClickWithState(e,t){this.showSampleInfo=void 0===t?!this.showSampleInfo:t;e.columnContainer.querySelector(\".igv-sample-info-column\").style.display=!1===this.showSampleInfo?\"none\":\"flex\",this.setState(this.showSampleInfo),e.layoutChange()}setButtonVisibility(e){this.showSampleInfo=e,this.setState(this.showSampleInfo),!0===this.showSampleInfo?this.show():this.hide()}}class My extends Ju{constructor(e,t){super(e,t,\"Sample Names\",'\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names hover\\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showSampleNames),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.showSampleNames&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.showSampleNames&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)})),!0===t.config.showSampleNameButton?this.show():this.hide()}performClickWithState(e,t){e.showSampleNames=void 0===t?!e.showSampleNames:t;e.columnContainer.querySelector(\".igv-sample-name-column\").style.display=!1===e.showSampleNames?\"none\":\"flex\",this.setState(e.showSampleNames),e.layoutChange()}}class Ry{constructor(t,i){this.parent=t,this.popover=e({class:\"igv-ui-dropdown\"}),t.appendChild(this.popover),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\",this.shim=i}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";let{x:t,y:i}=a(e,this.parent);this.popover.style.left=`${t+this.shim.left}px`,this.popover.style.top=`${i+this.shim.top}px`}_present(e){this.popover.style.display=\"block\";let{x:t,y:i,width:n}=a(e,this.parent);t+=this.shim.left,i+=this.shim.top,this.popover.style.top=`${i}px`;const{width:r}=this.popover.getBoundingClientRect(),s=t+r,o=s-n;this.popover.style.left=`${s>n?t-o:t}px`}dismiss(){this.popover.style.display=\"none\"}}class Dy extends Ju{constructor(e,t){super(e,t,\"Save Image\",ef,'\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>{for(const e of this.button.querySelectorAll(\"div\"))if(\"block\"===e.style.display)return;this.setState(!1)})),this.dropdown=new Ry(this.button.parentNode,{top:24,left:-88});const i=[{label:\"Save as SVG\",click:e=>{this.browser.saveSVGtoFile(\"igvjs.svg\"),this.dropdown.dismiss()}},{label:\"Save as PNG\",click:e=>{this.browser.savePNGtoFile(\"igvjs.png\"),this.dropdown.dismiss()}}];this.dropdown.configure(i),this.button.addEventListener(\"click\",(e=>{let t;if(e.target===this.button)t=!0;else if(e.target.closest(\"svg\")){e.target.closest(\"div\")===this.button&&(t=!0)}!0===t&&(\"none\"===this.dropdown.popover.style.display?this.dropdown.present(e):this.dropdown.dismiss())})),this.setVisibility(t.config.showSVGButton)}navbarResizeHandler(e){this.dropdown.dismiss(),super.navbarResizeHandler(e)}}const Ty=function(t,i,n){const r=e({class:\"igv-navbar-button\"});t.append(r),r.textContent=n.label,r.addEventListener(\"click\",(()=>n.callback(i)))};let Ly=23,zy=0;class Hy{constructor(t,i,n){this.browser=i,this.zoomContainer=e({class:\"igv-zoom-widget\"}),n.appendChild(this.zoomContainer),this.zoomOutButton=e(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(l(\"minus-circle\")),this.zoomOutButton.addEventListener(\"click\",(()=>{i.zoomOut()}));const r=e();this.zoomContainer.appendChild(r),this.slider=document.createElement(\"input\"),this.slider.type=\"range\",this.slider.min=\"0\",this.slider.max=`${Ly}`,r.appendChild(this.slider),this.slider.addEventListener(\"change\",(e=>{e.preventDefault(),e.stopPropagation();const t=i.referenceFrameList[0],{bpLength:n}=t.genome.getChromosome(t.chr),{end:r,start:s}=t,o=r-s,a=n/Math.pow(2,e.target.valueAsNumber);i.zoomWithScaleFactor(a/o)})),this.zoomInButton=e(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(l(\"plus-circle\")),this.zoomInButton.addEventListener(\"click\",(()=>{i.zoomIn()})),i.on(\"locuschange\",(e=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(e))}))}update(e){if(this.slider){const t=e[0],{bpLength:i}=t.genome.getChromosome(t.chr),{start:n,end:r}=t;Ly=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${Ly}`;const s=i/(r-n);zy=Math.log2(s),this.slider.value=`${Math.round(zy)}`}}enable(){this.slider&&(this.slider.disabled=!1)}disable(){this.slider&&(this.slider.disabled=!0)}hide(){this.zoomContainer.style.display=\"none\"}show(){this.zoomContainer.style.display=\"block\"}hideSlider(){this.slider&&(this.slider.style.display=\"none\")}showSlider(){this.slider&&(this.slider.style.display=\"block\")}}class Py{constructor(t,i){this.browser=i,this.config=t,this.currentClass=\"igv-navbar-text-button\";const n=Bt(\"
\",{class:\"igv-navbar\"});this.$navigation=n;const r=Bt(\"
\",{class:\"igv-navbar-left-container\"});n.append(r),this.navbarLeftContainer=r.get(0);const s=Bt(\"
\",{class:\"igv-logo\"});r.append(s);const o=Bt('IGV; ');o.css(\"width\",\"34px\"),o.css(\"height\",\"32px\"),s.append(o),this.$current_genome=Bt(\"
\",{class:\"igv-current-genome\"}),r.append(this.$current_genome),this.$current_genome.text(\"\");const a=Bt(\"
\",{class:\"igv-navbar-genomic-location\"});r.append(a),this.chromosomeSelectWidget=new Cy(i,a.get(0)),!1!==t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const c=Bt(\"
\",{class:\"igv-locus-size-group\"});a.append(c);const h=Bt(\"
\",{class:\"igv-search-container\"});c.append(h),this.$searchInput=Bt(\"\",{class:\"igv-search-input\",type:\"text\",placeholder:\"Locus Search\"}),h.append(this.$searchInput),this.$searchInput[0].addEventListener(\"keyup\",(e=>{e.stopImmediatePropagation()})),this.$searchInput.change((()=>i.doSearch(this.$searchInput.val())));const d=e({class:\"igv-search-icon-container\"});h.append(Bt(d)),d.appendChild(l(\"search\")),d.addEventListener(\"click\",(()=>i.doSearch(this.$searchInput.val()))),this.windowSizePanel=new _y(c.get(0),i);const u=Bt(\"
\",{class:\"igv-navbar-right-container\"});n.append(u),this.navbarRightContainer=u.get(0);const f=Bt('
');u.append(f);const p=f.get(0);this.toggle_button_container=p,this.overlayTrackButton=new sf(p,i),this.overlayTrackButton.setVisibility(!1);const g=!1!==t.showMultiSelectButton;if(this.multiTrackSelectButton=new xy(p,i,this,g),this.cursorGuideButton=new Iy(p,i),this.centerLineButton=new Sy(p,i),this.trackLabelControl=new Ey(p,i),this.roiTableControl=new Ny(p,i),this.sampleInfoControl=new By(p,i),this.sampleNameControl=new My(p,i),!0===t.showSVGButton&&(this.saveImageControl=new Dy(p,i)),t.customButtons)for(let e of t.customButtons)new Ty(p,i,e);this.zoomWidget=new Hy(t,i,u.get(0)),!1===t.showNavigation&&this.$navigation.hide()}navbarDidResize(){const e=this.$navigation.width(),t=this.currentNavbarButtonClass();\"igv-navbar-text-button\"===t&&(this.textButtonContainerWidth=this.navbarRightContainer.getBoundingClientRect().width);const i=this.browser,n=i.isMultiLocusWholeGenomeView()||i.referenceFrameList&&mu.isWholeGenomeView(i.referenceFrameList[0].chr);n?this.windowSizePanel.hide():this.windowSizePanel.show();const{x:r,width:s}=this.navbarLeftContainer.getBoundingClientRect(),o=r+s,{x:a}=this.navbarRightContainer.getBoundingClientRect();let c;if(\"igv-navbar-text-button\"===t&&a-o<8)c=\"igv-navbar-icon-button\";else if(this.textButtonContainerWidth&&\"igv-navbar-icon-button\"===t){e-o-this.textButtonContainerWidth>8&&(c=\"igv-navbar-text-button\")}let l;c&&t!==c&&(this.currentClass=c,this.browser.fireEvent(\"navbar-resize\",[c])),l=n?\"igv-zoom-widget-hidden\":e>860?\"igv-zoom-widget\":\"igv-zoom-widget-900\",Bt(this.zoomWidget.zoomContainer).removeClass(),Bt(this.zoomWidget.zoomContainer).addClass(l)}setCenterLineButtonVisibility(e){e?this.centerLineButton.setVisibility(!e):this.centerLineButton.setVisibility(this.config.showCenterGuideButton)}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}updateGenome(e){let t=e.id&&e.id.length<20?e.id:`${e.id.substring(0,8)}...${e.id.substring(e.id.length-8)}`;this.$current_genome.text(t),this.$current_genome.attr(\"title\",e.description);!1!==this.config.showChromosomeWidget&&!1!==e.showChromosomeWidget&&e.chromosomeNames&&e.chromosomeNames.length>1?(this.chromosomeSelectWidget.update(e),this.chromosomeSelectWidget.show()):this.chromosomeSelectWidget.hide()}updateLocus(e,t){this.$searchInput&&this.$searchInput.val(e),this.chromosomeSelectWidget&&(this.chromosomeSelectWidget.select.value=t)}currentNavbarButtonClass(){return this.currentClass}setEnableTrackSelection(e){this.multiTrackSelectButton.setMultiTrackSelection(e)}getEnableTrackSelection(){return this.multiTrackSelectButton.enableMultiTrackSelection}hide(){this.$navigation.hide()}show(){this.$navigation.show()}}const Oy=(e,t)=>{const i=0===e?t.nextElementSibling:t.previousElementSibling;t.remove(),i.remove()},Uy=t=>{const i=e({class:\"igv-column-shim\"});Ya(i,t);const n=e({class:\"igv-column\"});return Ya(n,i),n},qy=(t,i)=>{for(let n=0;n1&&n>0){Ka(e({class:\"igv-column-shim\"}),r)}}};class Qy{constructor(t,i,n){this.browser=t,this.referenceFrame=i,this.column=n,this.container=e({class:\"igv-center-line\"}),n.appendChild(this.container),t.doShowCenterLine?this.show():this.hide()}repaint(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const e=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${e}px`,this.container.classList.remove(\"igv-center-line-thin\"),this.container.classList.add(\"igv-center-line-wide\")}else this.container.style.width=\"1px\",this.container.classList.remove(\"igv-center-line-wide\"),this.container.classList.add(\"igv-center-line-thin\")}}show(){this.isVisible=!0,this.container.style.display=\"block\",this.repaint()}hide(){this.isVisible=!1,this.container.style.display=\"none\"}resize(){this.repaint()}}const Vy=function(t,i){this.button=e({class:\"igv-navbar-button\"}),t.appendChild(this.button),this.button.textContent=\"circular view\",this.button.addEventListener(\"click\",(()=>{i.circularViewVisible=!i.circularViewVisible})),this.browser=i,this.setVisibility(i.config.showCircularViewButton),this.setState(i.circularViewVisible)};Vy.prototype.setVisibility=function(e){!0===e?this.show():this.hide()},Vy.prototype.setState=function(e){!0===e?this.button.classList.add(\"igv-navbar-button-clicked\"):this.button.classList.remove(\"igv-navbar-button-clicked\")},Vy.prototype.show=function(){this.button.style.display=\"block\",this.setState(this.browser.circularViewVisible)},Vy.prototype.hide=function(){this.button.style.display=\"none\"};class jy{constructor(t,i){this.browser=t,this.container=e({class:\"igv-roi-menu\"}),i.appendChild(this.container);const n=e();this.container.appendChild(n),u(n,(()=>this.container.style.display=\"none\")),this.body=e(),this.container.appendChild(this.body),this.container.style.display=\"none\"}async present(e,t,i,n,r,s){const o=this.menuItems(e,t,i,n,r,s);this.browser.menuPopup.presentTrackContextMenu(i,o)}menuItems(e,t,i,n,r,s){const o=e.name?[`${e.name}
`]:[];return\"name\"in t&&o.push(`ROI Set: ${t.name}`),o.length>0&&o.push(\"
\"),t.isUserDefined&&o.push({label:\"Set description ...\",click:()=>{const t={label:\"Description\",value:e.name||\"\",callback:()=>{const t=this.browser.inputDialog.value||\"\";e.name=t.trim(),this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(t,i)}}),Xa()&&e.end-e.start<1e6&&o.push({label:\"Copy reference sequence\",click:async()=>{this.container.style.display=\"none\";let t=await this.browser.genome.getSequence(e.chr,e.start,e.end);t||(t=\"Unknown sequence\");try{await navigator.clipboard.writeText(t)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.end-e.start<=25e3&&o.push({label:\"BLAT reference sequence\",click:async()=>{this.container.style.display=\"none\";const{chr:t,start:i,end:n}=e;let r=await this.browser.genome.getSequence(t,i,n);if(r){const e=`blat: ${t}:${i+1}-${n}`,s=`blat: ${t}:${i+1}-${n}`;jd({sequence:r,browser:this.browser,name:e,title:s})}}}),t.isUserDefined&&o.push(\"
\",{label:\"Delete\",click:async()=>{t.removeFeature(e);const i=await t.getAllFeatures();0===Object.keys(i).length&&n.deleteUserDefinedROISet(),n.deleteRegionWithKey(s.dataset.region,r),n.repaintTable()}}),o}dispose(){this.container.innerHTML=\"\"}}class Wy extends Pd{constructor(e){const t={browser:e,parent:e.columnContainer,headerTitle:\"Regions of Interest\",dismissHandler:()=>e.roiTableControl.buttonHandler(!1),gotoButtonHandler:Wy.gotoButtonHandler};t.columnFormat=Wy.getColumnFormatConfiguration(!0),super(Object.assign({width:\"640px\"},t))}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),{setName:n,feature:r}=t;i.dataset.region=Xy(r.chr,r.start,r.end);let s=[r.chr,Rt(r.start),Rt(r.end),r.name||\"\",n];4===this.columnFormat.length&&(s=s.slice(0,4));for(let t=0;te.remove())),e.length>0){const t=e.sort(((e,t)=>e.feature.chr.localeCompare(t.feature.chr)||e.feature.start-t.feature.start||e.feature.end-t.feature.end));for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}}set footerDOM(t){super.footerDOM=t,this.gotoButton.textContent=\"Go to selected region(s)\";const i=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(i),i.id=\"igv-roi-hide-show-button\",i.textContent=\"Copy Sequence\",i.title=\"One region only of max size 1 mb\",this.copySequenceButton=i,Gy(this.copySequenceButton,!1),this.boundCopySequenceButtonHandler=async function(e){e.preventDefault(),e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\");if(t.length>0){const e=[];for(let i of t){const{locus:t}=Jy(i.dataset.region);e.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");if(this.setTableRowSelectionState(!1),e.length>0){const{chr:t,start:i,end:n}=ey(e[0],this.browser.isSoftclipped()),r=await this.browser.genome.getSequence(t,i,n);await navigator.clipboard.writeText(r)}}}.bind(this),this.copySequenceButton.addEventListener(\"click\",this.boundCopySequenceButtonHandler);const n=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(n),n.id=\"igv-roi-hide-show-button\",n.textContent=\"Hide all ROIs\",this.toggleROIButton=n,this.boundToggleDisplayButtonHandler=function(e){e.preventDefault(),e.stopPropagation(),this.browser.roiManager.toggleROIs()}.bind(this),this.toggleROIButton.addEventListener(\"click\",this.boundToggleDisplayButtonHandler)}setROIVisibility(e){const t=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let i=0;i0&&t.length<2){const{locus:e}=Jy(t[0].dataset.region),{chr:i,start:n,end:r}=ey(e,this.browser.isSoftclipped());Gy(this.copySequenceButton,r-n<1e6)}else Gy(this.copySequenceButton,!1)}dispose(){document.removeEventListener(\"click\",this.boundGotoButtonHandler),document.removeEventListener(\"click\",this.boundCopySequenceButtonHandler),document.removeEventListener(\"click\",this.boundToggleDisplayButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(e){return!0===e?[{label:\"Chr\",width:\"20%\"},{label:\"Start\",width:\"15%\"},{label:\"End\",width:\"15%\"},{label:\"Description\",width:\"30%\"},{label:\"ROI Set\",width:\"20%\"}]:[{label:\"Chr\",width:\"25%\"},{label:\"Start\",width:\"20%\"},{label:\"End\",width:\"20%\"},{label:\"Description\",width:\"35%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(let e of t){const{locus:t}=Jy(e.dataset.region);i.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(\" \"))}}function Gy(e,t){e.style.pointerEvents=t?\"auto\":\"none\",e.style.color=ro(t?\"licorice\":\"silver\"),e.style.borderColor=ro(t?\"licorice\":\"silver\")}function $y(e,t){const i=window.getComputedStyle(e).backgroundColor.match(/[\\d.]+/g);3===i.length&&i.push(1),i[3]=t,e.style.backgroundColor=`rgba(${i.join(\", \")})`}class Ky{constructor(e){this.browser=e,this.roiMenu=new jy(e,e.columnContainer),this.roiTable=new Wy(e,e.columnContainer),this.top=0,this.roiSets=[],this.boundLocusChangeHandler=Yy.bind(this),e.on(\"locuschange\",this.boundLocusChangeHandler);this.observer=new MutationObserver((()=>{const t=e.findTracks((e=>new Set([\"ideogram\",\"ruler\"]).has(e.type))),[i,n]=t.map((e=>e.trackView.viewports[0].$viewport.get(0))).map((e=>function(e){const t=window.getComputedStyle(e),i=parseInt(t.marginTop),n=parseInt(t.marginBottom),{top:r,bottom:s,height:o}=e.getBoundingClientRect();return{top:Math.floor(r)-i,bottom:Math.floor(s)+n,height:Math.floor(o)+i+n}}(e))),r=i?i.height:0,s=n?n.height:0,o=e.columnContainer.querySelectorAll(\".igv-roi-region\");if(o)for(const e of o)e.style.marginTop=`${r+s+-.5}px`})),this.observer.observe(e.columnContainer,{attributes:!0,childList:!0,subtree:!0})}async reset(){this.roiSets.length>0&&this.browser.roiTableControl.setVisibility(!0);const e=this.roiSets.map((e=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})));e.length>0&&await Promise.all(e);const t=await this.getTableRecords();if(this.roiTable.renderTable(t),this.roiSets.length>0){const e=this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e)}}async loadROI(e,t){const i=Array.isArray(e)?e:[e];for(let e of i)!e.name&&e.url&&(e.name=await ja(e.url)),e.url&&!e.format&&(e.format=await am(e)),this.roiSets.push(new ku(e,t));await this.reset()}clearROIs(){this.roiTable.clearTable();const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();for(let e of this.roiSets)e.dispose();this.roiSets=[]}async getTableRecords(){const e=[];for(let t of this.roiSets){const i=t.name||\"\",n=await t.getAllFeatures();for(let t of Object.keys(n))for(let r of n[t])e.push({setName:i,feature:r})}return e}presentTable(){this.roiTable.present()}async repaintTable(){const e=await this.getTableRecords();this.roiTable.renderTable(e)}dismissTable(){this.roiTable.dismiss()}roiTableIsVisible(){return this.roiTable.isVisible()}async updateUserDefinedROISet(e){let t=await this.getUserDefinedROISet();void 0===t&&(t=this.initializeUserDefinedROISet()),t.addFeature(e),this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(e){this.browser.roiTableControl.setVisibility(e)}toggleROIs(){const e=!this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e);for(const t of this.roiSets)t.isVisible=e}async renderAllROISets(){for(let e of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})}async renderROISet({browser:e,pixelTop:t,roiSet:i}){const n=e.columnContainer.querySelectorAll(\".igv-column\");for(let r=0;ra)&&e.remove()}const h=await i.getFeatures(s,o,a);if(h)for(let l of h){const h=Xy(s,l.start,l.end),{x:d,width:u}=Iu(Math.max(o,l.start),Math.min(a,l.end),o,c),f=n[r].querySelector(Zy(h));if(f)f.style.left=`${d}px`,f.style.width=`${u}px`;else{const s=this.createRegionElement(e.columnContainer,t,d,u,i,h,l);n[r].appendChild(s)}}}}createRegionElement(t,i,n,r,s,o,c){const l=e({class:\"igv-roi-region\"});l.style.top=`${i}px`,l.style.left=`${n}px`,l.style.width=`${r}px`,l.style.backgroundColor=s.color,l.dataset.color=s.color,l.dataset.region=o;const h=e();return l.appendChild(h),h.style.backgroundColor=s.headerColor,h.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation(),a(e,t),this.roiMenu.present(c,s,e,this,t,l)})),l}renderSVGContext(e,t,{deltaX:i,deltaY:n}){for(const r of e.querySelectorAll(\".igv-roi-region\")){const{x:e,y:s,width:o,height:a}=r.getBoundingClientRect();t.fillStyle=r.style.backgroundColor,t.fillRect(e-i,s+n,o,a);const c=r.querySelector(\"div\"),{x:l,y:h,width:d,height:u}=c.getBoundingClientRect();t.fillStyle=c.style.backgroundColor,t.fillRect(l-i,h+n,d,u)}}getUserDefinedROISet(){return this.roiSets.find((e=>!0===e.isUserDefined))}deleteUserDefinedROISet(){this.roiSets=this.roiSets.filter((e=>!0!==e.isUserDefined))}initializeUserDefinedROISet(){const e=new ku({name:\"user defined\",isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(e),e}async deleteRegionWithKey(e,t){t.querySelectorAll(Zy(e)).forEach((e=>e.remove()));0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}toJSON(){return this.roiSets.map((e=>e.toJSON()))}dispose(){this.browser.off(\"locuschange\",this.boundLocusChangeHandler);const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let e of this.roiSets)e.dispose();for(let e of Object.keys(this))this[e]=void 0}}function Yy(){this.renderAllROISets()}function Xy(e,t,i){return`${e}-${t}-${i}`}function Zy(e){return`[data-region=\"${e}\"]`}function Jy(e){let t=e.split(\"-\"),i=parseInt(t.pop()),n=parseInt(t.pop()),r=t.join(\"-\");return{chr:r,start:n,end:i,locus:`${r}:${n}-${i}`,bedRecord:`${r}\\t${n}\\t${i}`}}class eA{constructor(e,t){this.name=e.name,this.featureSource=e.featureSource||Ad(e,t),this.color=e.color||_u}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}draw(e){const{context:t,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=e;if(!a)return;const c=n+o*i+1;for(let{start:e,end:o}of a){if(oc)break;const{x:a,width:l}=Iu(e,o,n,i);xo.fillRect(t,a,r,l,s,{fillStyle:this.color})}}}class tA{aliasRecordCache=new Map;constructor(e,t,i){(t=t||{}).url=e,this.reader=new Zh(t,i)}async preload(e){await this.reader.preload();for(let t of e)await this.search(t)}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async search(e){if(!this.aliasRecordCache.has(e)){const t=await this.reader.search(e);if(t)for(let e of Object.keys(t))\"start\"!==e&&\"end\"!==e&&this.aliasRecordCache.set(t[e],t)}return this.aliasRecordCache.get(e)}async getChromosomeNames(){return await this.reader.loadHeader(),Array.from(this.reader.chrNames)}}class iA{aliasRecordCache=new Map;constructor(e,t,i){this.aliasURL=e,this.config=t,this.genome=i}async preload(){return this.loadAliases()}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async loadAliases(){const e=await Qs.loadString(this.aliasURL,Ua(this.config)),t=Dt(e),i=t[0];i.startsWith(\"#\")&&(this.headings=i.substring(1).split(\"\\t\").map((e=>e.trim())),this.altNameSets=this.headings.slice(1));const n=this.genome.chromosomeNames?new Set(this.genome.chromosomeNames):new Set;for(let e of t)if(!e.startsWith(\"#\")&&e.length>0){const t=e.split(\"\\t\");let i=t.find((e=>n.has(e)));i||(i=t[0]);const r={chr:i};for(let e=0;enew nA(e.start,e.end,e.name,e.gieStain)))}}class sA{cytobands=new Map;constructor(e,t){this.url=e,this.config=t}async getCytobands(e){return 0===this.cytobands.size&&await this.#I(),this.cytobands.get(e)}async#I(){let e,t;if(Ga(this.url)){const t=vs(this.url);e=\"\";const i=t.length;for(let n=0;n0){const e=e.substring(0,t);r[\"ncbi-gi\"]=e}}else{if(e.startsWith(\"hg\")||e.startsWith(\"GRCh\")||\"1kg_ref\"===e||\"b37\"===e)switch(n){case\"23\":r.ucsc=\"chrX\",t=!0;break;case\"24\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"23\",t=!0;break;case\"chrY\":r.ncbi=\"24\",t=!0}else if(e.startsWith(\"mm\")||e.startsWith(\"GRCm\")||e.startsWith(\"rheMac\"))switch(n){case\"21\":r.ucsc=\"chrX\",t=!0;break;case\"22\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"21\",t=!0;break;case\"chrY\":r.ncbi=\"22\",t=!0}if(t)continue;\"chrM\"===n?r.ncbi=\"MT\":\"MT\"===n?r.ucsc=\"chrM\":n.toLowerCase().startsWith(\"chr\")?r.ncbi=n.substring(3):Number.isInteger(Number(n))&&(r.ucsc=\"chr\"+n)}}for(let e of i){for(let t of Object.values(e))this.aliasRecordCache.set(t,e);this.aliasRecordCache.set(e.chr.toLowerCase(),e),this.aliasRecordCache.set(e.chr.toUpperCase(),e)}}}search(e){return this.aliasRecordCache.get(e)}static getNCBIName(e){const t=e.split(\"\\\\|\");return t[t.length-1]}}class aA{#S;static async createGenome(e,t){const i=new aA(e,t);return await i.init(),i}constructor(e,t){this.config=e,this.browser=t,this.id=e.id||function(e){return void 0!==e.id?e.id:e.fastaURL&&Mt(e.fastaURL)&&!e.fastaURL.startsWith(\"data:\")?e.fastaURL:e.fastaURL&&e.fastaURL.name?e.fastaURL.name:\"\"}(e),this.name=e.name,this.nameSet=e.nameSet}async init(){const e=this.config;if(this.sequence=await Nc(e,this.browser),e.chromSizesURL?this.chromosomes=await async function(e){const t=new Map;let i;if(Ga(e)){let t=vs(e);i=\"\";for(let e of t)i+=String.fromCharCode(e)}else i=await Qs.load(e,{});const n=Fc(i);let r=0;for(let e of n){const i=e.split(\"\\t\");if(i.length>1){const e=Number.parseInt(i[1]);t.set(i[0],new lc(i[0],r++,e))}}return t}(e.chromSizesURL):this.chromosomes=this.sequence.chromosomes||new Map,this.chromosomes.size>0&&(this.chromosomeNames=Array.from(this.chromosomes.keys())),e.chromAliasBbURL?(this.chromAlias=new tA(e.chromAliasBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.chromAlias.getChromosomeNames())):e.aliasURL?this.chromAlias=new iA(e.aliasURL,Object.assign({},e),this):this.chromosomeNames&&(this.chromAlias=new oA(this.id,this.chromosomeNames)),e.cytobandBbURL)this.cytobandSource=new rA(e.cytobandBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames());else if(e.cytobandURL&&(this.cytobandSource=new sA(e.cytobandURL,Object.assign({},e)),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames()),0===this.chromosomes.size)){const e=await this.cytobandSource.getChromosomes();for(let t of e)this.chromosomes.set(e.name,e)}if(!1!==e.wholeGenomeView&&this.chromosomes.size>0&&(e.chromosomeOrder?Array.isArray(e.chromosomeOrder)?this.#S=e.chromosomeOrder:this.#S=e.chromosomeOrder.split(\",\").map((e=>e.trim())):this.#S=function(e){const t=[];let i,n=1;for(let r of e.values()){if(i){if(r.bpLength1,this.wholeGenomeView){const e=this.#S.reduce(((e,t)=>e+this.chromosomes.get(t).bpLength),0);this.chromosomes.set(\"all\",new lc(\"all\",0,e))}}get description(){return this.config.description||`${this.id}\\n${this.name}`}get infoURL(){return this.config.infoURL}showWholeGenomeView(){return this.wholeGenomeView}toJSON(){return Object.assign({},this.config,{tracks:void 0})}get initialLocus(){return this.config.locus?this.config.locus:this.getHomeChromosomeName()}getHomeChromosomeName(){return this.showWholeGenomeView()&&this.chromosomes.has(\"all\")?\"all\":this.chromosomeNames[0]}getChromosomeName(e){return this.chromAlias?this.chromAlias.getChromosomeName(e,this.chromosomes.keys()):e}getChromosomeDisplayName(e){return this.nameSet&&this.chromAlias&&this.chromAlias.getChromosomeAlias(e,this.nameSet)||e}getChromosome(e){return this.chromAlias&&(e=this.chromAlias.getChromosomeName(e)),this.chromosomes.get(e)}async loadChromosome(e){if(this.chromAlias){const t=await this.chromAlias.search(e);t&&(e=t.chr)}if(!this.chromosomes.has(e)){let t;const i=await this.sequence.getSequenceRecord(e);i&&(t=new lc(e,0,i.bpLength)),this.chromosomes.set(e,t)}return this.chromosomes.get(e)}async getAliasRecord(e){if(this.chromAlias)return this.chromAlias.search(e)}async getCytobands(e){if(this.cytobandSource){const t=this.getChromosomeName(e);return await this.cytobandSource.getCytobands(t)}}getChromosomes(){return this.chromosomes}get wgChromosomeNames(){return this.#S?this.#S.slice():void 0}get showChromosomeWidget(){return this.config.showChromosomeWidget}getGenomeCoordinate(e,t){var i=this.getCumulativeOffset(e);if(void 0!==i)return i+t}getChromosomeCoordinate(e){let t;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.#S){const r=this.cumulativeOffsets[n];if(r>e){return{chr:t,position:e-i}}t=n,i=r}return{chr:this.#S[this.#S.length-1],position:0}}getCumulativeOffset(e){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let e={},t=0;for(let i of this.#S){e[i]=Math.floor(t);t+=this.getChromosome(i).bpLength}return e}.call(this));const t=this.getChromosomeName(e);return this.cumulativeOffsets[t]}getGenomeLength(){if(!this.bpLength){let e=0;for(let t of this.#S){e+=this.chromosomes.get(t).bpLength}this.bpLength=e}return this.bpLength}async getSequence(e,t,i){return e=this.getChromosomeName(e),this.sequence.getSequence(e,t,i)}getSequenceInterval(e,t,i){return\"function\"==typeof this.sequence.getSequenceInterval?this.sequence.getSequenceInterval(e,t,i):void 0}}class cA{constructor(){this.clear()}clear(){this.phenotypeColors=new Map,this.snps=new Set,this.qtl=null}isEmpty(){return 0===this.phenotypeColors.size&&0===this.snps.size&&null===this.qtl}addSnp(e){e=e.toUpperCase(),this.snps.add(e)}addPhenotype(e){e=e.toUpperCase();const t=this.phenotypeColors.size;if(!this.phenotypeColors.has(e.toUpperCase())){const i=t0&&(e.phenotypes=Array.from(this.phenotypeColors.keys())),this.snps.size>0&&(e.snps=Array.from(this.snps)),this.qtl&&(e.qtl=this.qtl),e}static fromJSON(e){const t=new cA;if(e.phenotypes)for(let i of e.phenotypes)t.addPhenotype(i);if(e.snps)for(let i of e.snps)t.addSnp(i);return e.qtl&&(t.qtl=e.qtl),t}}const lA=[];lA.push(\"rgb(228,26,28)\"),lA.push(\"rgb(55,126,184)\"),lA.push(\"rgb(77,175,74)\"),lA.push(\"rgb(166,86,40)\"),lA.push(\"rgb(152,78,163)\"),lA.push(\"rgb(255,127,0)\"),lA.push(\"rgb(247,129,191)\"),lA.push(\"rgb(255,255,51)\"),lA.push(\"rgb(102,194,165)\"),lA.push(\"rgb(252,141,98)\"),lA.push(\"rgb(141, 160, 203)\"),lA.push(\"rgb(231, 138, 195)\"),lA.push(\"rgb(166, 216, 84)\"),lA.push(\"rgb(255, 217, 47)\"),lA.push(\"rgb(229, 196, 148)\"),lA.push(\"rgb( 141, 211, 199)\"),lA.push(\"rgb(255, 255, 179)\"),lA.push(\"rgb(190, 186, 218)\"),lA.push(\"rgb(251, 128, 114)\"),lA.push(\"rgb(128, 177, 211)\"),lA.push(\"rgb(253, 180, 98)\"),lA.push(\"rgb(179, 222, 105)\"),lA.push(\"rgb(252, 205, 229)\"),lA.push(\"rgb(188, 128, 189)\"),lA.push(\"rgb(204, 235, 197)\"),lA.push(\"rgb(255, 237, 111)\");class hA{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container);let r='';this._input=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._input),r='',this._output=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._output);const s=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(s),this.ok=e(),s.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),s.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"input\",(()=>{const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this._output.value=`${e.toFixed(2)}`}),!1),this.ok.addEventListener(\"click\",(()=>{if(\"function\"==typeof this.callback){const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this.callback=void 0}this._input.value=void 0,i(this.container)}));const o=()=>{this._input.value=void 0,i(this.container)};this.cancel.addEventListener(\"click\",o),u(n,o),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._scaleFactor=e.scaleFactor;const[i,r,s]=[e.min,e.max,e.value].map((e=>Math.floor(this._scaleFactor*e).toString()));this._input.min=i,this._input.max=r,this._input.value=s;const o=parseFloat(s)/this._scaleFactor;this._output.value=`${o.toFixed(2)}`,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}class dA{qtlSelections=new cA;constructor(t,i){this.config=t,this.guid=s(),this.namespace=\".browser_\"+this.guid,this.parent=i;let n=i.shadowRoot;if(!n){n=i.attachShadow({mode:\"open\"});const e=new CSSStyleSheet;e.replaceSync('.igv-ui-dropdown {\\n cursor: default;\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div {\\n overflow-y: auto;\\n overflow-x: hidden;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div {\\n padding: 4px;\\n width: 100%;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: 1px;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div:last-child {\\n border-bottom-color: transparent;\\n border-bottom-width: 0;\\n}\\n.igv-ui-dropdown > div > div:hover {\\n cursor: pointer;\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n\\n.igv-ui-popover {\\n cursor: default;\\n position: absolute;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n background-color: white;\\n}\\n.igv-ui-popover > div:first-child {\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-width: 0;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-popover > div:first-child > div:first-child {\\n margin-left: 4px;\\n}\\n.igv-ui-popover > div:first-child > div:last-child {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-popover > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-popover > div:last-child {\\n user-select: text;\\n overflow-y: auto;\\n overflow-x: hidden;\\n max-height: 400px;\\n max-width: 800px;\\n background-color: white;\\n border-bottom-width: 0;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-ui-popover > div:last-child > div {\\n margin-left: 4px;\\n margin-right: 4px;\\n min-width: 220px;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n.igv-ui-popover > div:last-child > div > span {\\n font-weight: bolder;\\n}\\n.igv-ui-popover > div:last-child hr {\\n width: 100%;\\n}\\n\\n.igv-ui-alert-dialog-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n top: 50%;\\n left: 50%;\\n width: 400px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n outline: none;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 15px;\\n font-weight: 400;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:first-child {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\\n padding-left: 8px;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\\n -webkit-user-select: text;\\n -moz-user-select: text;\\n -ms-user-select: text;\\n user-select: text;\\n color: #373737;\\n width: 100%;\\n height: calc(100% - 24px - 64px);\\n overflow-y: scroll;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\\n margin: 16px;\\n width: auto;\\n height: auto;\\n overflow-wrap: break-word;\\n word-break: break-word;\\n background-color: white;\\n border: unset;\\n}\\n.igv-ui-alert-dialog-container > div:last-child {\\n width: 100%;\\n margin-bottom: 10px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div {\\n margin: unset;\\n width: 40px;\\n height: 30px;\\n line-height: 30px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n border-color: #2B81AF;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div:hover {\\n cursor: pointer;\\n border-color: #25597f;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-color-swatch {\\n position: relative;\\n box-sizing: content-box;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: wrap;\\n justify-content: center;\\n align-items: center;\\n width: 32px;\\n height: 32px;\\n border-style: solid;\\n border-width: 2px;\\n border-color: white;\\n border-radius: 4px;\\n}\\n\\n.igv-ui-color-swatch:hover {\\n border-color: dimgray;\\n}\\n\\n.igv-ui-colorpicker-menu-close-button {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 32px;\\n margin-top: 4px;\\n margin-bottom: 4px;\\n padding-right: 8px;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa {\\n display: block;\\n margin-left: 4px;\\n margin-right: 4px;\\n color: #5f5f5f;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\\n.igv-ui-colorpicker-menu-close-button i.fa:active {\\n cursor: pointer;\\n color: #0f0f0f;\\n}\\n\\n.igv-ui-generic-dialog-container {\\n box-sizing: content-box;\\n position: fixed;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: fit-content;\\n padding-bottom: 16px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input > div {\\n width: fit-content;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input[type=range] {\\n width: 70%;\\n -webkit-appearance: none;\\n background: linear-gradient(90deg, white, black);\\n outline: none;\\n margin: 0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input output {\\n display: block;\\n height: 100%;\\n width: 20%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n padding-top: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div {\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n\\n.igv-ui-generic-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-container > div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-ui-generic-container > div:first-child > div {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-ui-dialog {\\n z-index: 2048;\\n position: fixed;\\n width: fit-content;\\n height: fit-content;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n background-color: white;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-dialog .igv-ui-dialog-one-liner {\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n font-weight: bold;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\\n width: 100%;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\\n margin: 16px;\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\\n background-color: #5ea4e0;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\\n background-color: #c4c4c4;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\\n z-index: 2048;\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-panel-column {\\n display: flex;\\n flex-direction: column;\\n}\\n\\n.igv-ui-panel-row {\\n display: flex;\\n flex-direction: row;\\n}\\n\\n.igv-ui-textbox {\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-table {\\n background-color: white;\\n}\\n\\n.igv-ui-table thead {\\n position: sticky;\\n top: 0;\\n}\\n\\n.igv-ui-table th {\\n text-align: left;\\n}\\n\\n.igv-ui-table td {\\n padding-right: 20px;\\n}\\n\\n.igv-ui-table tr:hover {\\n background-color: lightblue;\\n}\\n\\n.igv-ui-center-fixed {\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.igv-navbar {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n box-sizing: border-box;\\n width: 100%;\\n color: #444;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n line-height: 32px;\\n padding-left: 8px;\\n padding-right: 8px;\\n margin-top: 2px;\\n margin-bottom: 6px;\\n height: 32px;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: #f3f3f3;\\n}\\n.igv-navbar .igv-navbar-left-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 32px;\\n line-height: 32px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-logo {\\n width: 34px;\\n height: 32px;\\n margin-right: 8px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\\n height: 32px;\\n margin-left: 4px;\\n margin-right: 4px;\\n user-select: none;\\n line-height: 32px;\\n vertical-align: middle;\\n text-align: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n height: 100%;\\n width: 125px;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\\n display: block;\\n cursor: pointer;\\n width: 100px;\\n height: 75%;\\n outline: none;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n margin-left: 8px;\\n height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 240px;\\n height: 22px;\\n line-height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\\n cursor: text;\\n width: 85%;\\n height: 22px;\\n line-height: 22px;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n text-align: left;\\n padding-left: 8px;\\n margin-right: 8px;\\n outline: none;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: white;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\\n cursor: pointer;\\n height: 16px;\\n width: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\\n margin-left: 4px;\\n user-select: none;\\n}\\n.igv-navbar .igv-navbar-right-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\\n position: relative;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-hidden {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\\n color: #737373;\\n font-size: 18px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\\n display: block;\\n height: fit-content;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\\n display: block;\\n width: 125px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\\n color: #737373;\\n font-size: 18px;\\n height: 32px;\\n line-height: 32px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\\n display: none;\\n}\\n\\n.igv-navbar-button {\\n display: block;\\n box-sizing: unset;\\n padding-left: 6px;\\n padding-right: 6px;\\n height: 18px;\\n text-transform: capitalize;\\n user-select: none;\\n line-height: 18px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 11px;\\n font-weight: 200;\\n color: #737373;\\n background-color: #f3f3f3;\\n border-color: #737373;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 6px;\\n}\\n\\n.igv-navbar-button:hover {\\n cursor: pointer;\\n}\\n\\n.igv-navbar-button-clicked {\\n color: white;\\n background-color: #737373;\\n}\\n\\n.igv-navbar-icon-button {\\n cursor: pointer;\\n position: relative;\\n width: 24px;\\n height: 24px;\\n margin-left: 4px;\\n margin-right: 4px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:first-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: -18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:last-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n.igv-navbar-text-button {\\n cursor: pointer;\\n position: relative;\\n margin-left: 2px;\\n margin-right: 2px;\\n border: none;\\n display: flex;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar-text-button > div:nth-child(2) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 0;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-text-button > div:nth-child(3) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 42px;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n#igv-text-button-label {\\n text-anchor: middle;\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-inactive rect {\\n stroke: #737373;\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-inactive text {\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-inactive tspan {\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-hover text {\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-hover tspan {\\n dominant-baseline: middle;\\n}\\n\\n#igv-save-svg-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-svg-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-svg-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-svg-group:hover text {\\n fill: white;\\n}\\n\\n#igv-save-png-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-png-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-png-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-png-group:hover text {\\n fill: white;\\n}\\n\\n.igv-zoom-in-notice-container {\\n z-index: 256;\\n position: absolute;\\n top: 8px;\\n left: 50%;\\n transform: translate(-50%, 0%);\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n background-color: white;\\n}\\n.igv-zoom-in-notice-container > div {\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-top: 2px;\\n padding-bottom: 2px;\\n width: 100%;\\n height: 100%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: #3f3f3f;\\n}\\n\\n.igv-zoom-in-notice {\\n position: absolute;\\n top: 10px;\\n left: 50%;\\n}\\n.igv-zoom-in-notice div {\\n position: relative;\\n left: -50%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #3f3f3f;\\n background-color: rgba(255, 255, 255, 0.51);\\n z-index: 64;\\n}\\n\\n.igv-container-spinner {\\n position: absolute;\\n top: 90%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n z-index: 1024;\\n width: 24px;\\n height: 24px;\\n pointer-events: none;\\n color: #737373;\\n}\\n\\n.igv-multi-locus-close-button {\\n position: absolute;\\n top: 2px;\\n right: 0;\\n padding-left: 2px;\\n padding-right: 2px;\\n width: 12px;\\n height: 12px;\\n color: #666666;\\n background-color: white;\\n z-index: 1000;\\n}\\n.igv-multi-locus-close-button > svg {\\n vertical-align: top;\\n}\\n\\n.igv-multi-locus-close-button:hover {\\n cursor: pointer;\\n color: #434343;\\n}\\n\\n.igv-multi-locus-ruler-label {\\n z-index: 64;\\n position: absolute;\\n top: 2px;\\n left: 0;\\n width: 100%;\\n height: 12px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label > div {\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n color: rgb(16, 16, 16);\\n background-color: white;\\n}\\n.igv-multi-locus-ruler-label > div {\\n cursor: pointer;\\n}\\n\\n.igv-multi-locus-ruler-label-square-dot {\\n z-index: 64;\\n position: absolute;\\n left: 50%;\\n top: 5%;\\n transform: translate(-50%, 0%);\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\\n width: 14px;\\n height: 14px;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\\n margin-left: 16px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: rgb(16, 16, 16);\\n}\\n\\n.igv-ruler-sweeper {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 26px;\\n bottom: 0;\\n left: 0;\\n width: 0;\\n z-index: 99999;\\n background-color: rgba(68, 134, 247, 0.25);\\n}\\n\\n.igv-ruler-tooltip {\\n pointer-events: none;\\n z-index: 128;\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 1px;\\n height: 32px;\\n background-color: transparent;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ruler-tooltip > div {\\n pointer-events: none;\\n width: 128px;\\n height: auto;\\n padding: 1px;\\n color: #373737;\\n font-size: 10px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n background-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-color: #373737;\\n}\\n\\n.igv-track-label {\\n position: absolute;\\n left: 8px;\\n top: 8px;\\n width: auto;\\n height: auto;\\n max-width: 50%;\\n padding-left: 4px;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n text-align: center;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-color: #444;\\n border-radius: 2px;\\n border-style: solid;\\n border-width: thin;\\n background-color: white;\\n z-index: 128;\\n cursor: pointer;\\n}\\n\\n.igv-track-label:hover,\\n.igv-track-label:focus,\\n.igv-track-label:active {\\n background-color: #e8e8e8;\\n}\\n\\n.igv-track-label-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-top: 4px;\\n}\\n\\n.igv-center-line {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n transform: translateX(-50%);\\n z-index: 8;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-left-style: dashed;\\n border-left-width: thin;\\n border-right-style: dashed;\\n border-right-width: thin;\\n}\\n\\n.igv-center-line-wide {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(127, 127, 127, 0.51);\\n}\\n\\n.igv-center-line-thin {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(0, 0, 0, 0);\\n}\\n\\n.igv-cursor-guide-horizontal {\\n display: none;\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n left: 0;\\n right: 0;\\n top: 50%;\\n height: 1px;\\n z-index: 32;\\n margin-left: 50px;\\n margin-right: 54px;\\n border-top-style: dotted;\\n border-top-width: thin;\\n border-top-color: rgba(127, 127, 127, 0.76);\\n}\\n\\n.igv-cursor-guide-vertical {\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n width: 1px;\\n z-index: 32;\\n border-left-style: dotted;\\n border-left-width: thin;\\n border-left-color: rgba(127, 127, 127, 0.76);\\n display: none;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-generic-dialog-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\\n width: 30%;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-generic-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-container div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-generic-container div:first-child i {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-menu-popup {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: max-content;\\n max-width: 400px;\\n z-index: 512;\\n cursor: pointer;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background: white;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-end;\\n text-align: left;\\n}\\n.igv-menu-popup > div:not(:first-child) {\\n width: 100%;\\n}\\n.igv-menu-popup > div:not(:first-child) > div {\\n background: white;\\n}\\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\\n padding-left: 4px;\\n padding-right: 4px;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:last-child {\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:hover {\\n background: #efefef;\\n}\\n\\n.igv-menu-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-bottom: 1px;\\n padding-top: 1px;\\n}\\n\\n.igv-menu-popup-header {\\n position: relative;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-menu-popup-header div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-menu-popup-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n.igv-menu-popup-check-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 20px;\\n margin-right: 4px;\\n background-color: transparent;\\n}\\n.igv-menu-popup-check-container div {\\n padding-top: 2px;\\n padding-left: 8px;\\n}\\n.igv-menu-popup-check-container div:first-child {\\n position: relative;\\n width: 12px;\\n height: 12px;\\n}\\n.igv-menu-popup-check-container div:first-child svg {\\n position: absolute;\\n width: 12px;\\n height: 12px;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-loading-spinner-container {\\n z-index: 1024;\\n position: absolute;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 32px;\\n height: 32px;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-loading-spinner-container > div {\\n box-sizing: border-box;\\n width: 100%;\\n height: 100%;\\n border-radius: 50%;\\n border: 4px solid rgba(128, 128, 128, 0.5);\\n border-top-color: rgb(255, 255, 255);\\n animation: spin 1s ease-in-out infinite;\\n -webkit-animation: spin 1s ease-in-out infinite;\\n}\\n\\n@keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n@-webkit-keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n.igv-roi-menu {\\n position: absolute;\\n z-index: 512;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background-color: white;\\n width: 192px;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-menu > div:first-child {\\n height: 24px;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-roi-menu > div:first-child > div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-roi-menu > div:first-child > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-menu > div:last-child {\\n background-color: white;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: 0;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n text-align: start;\\n vertical-align: middle;\\n}\\n.igv-roi-menu > div:last-child > div {\\n height: 24px;\\n padding-left: 4px;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n border-bottom-color: #7f7f7f;\\n}\\n.igv-roi-menu > div:last-child > div:not(:first-child):hover {\\n cursor: pointer;\\n background-color: rgba(127, 127, 127, 0.1);\\n}\\n.igv-roi-menu > div:last-child div:first-child {\\n font-style: italic;\\n text-align: center;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n}\\n.igv-roi-menu > div:last-child > div:last-child {\\n border-bottom-width: 0;\\n border-bottom-color: transparent;\\n}\\n\\n.igv-roi-placeholder {\\n font-style: normal;\\n color: rgba(75, 75, 75, 0.6);\\n}\\n\\n.igv-roi-table {\\n position: absolute;\\n z-index: 1024;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n resize: both;\\n overflow: hidden;\\n width: min-content;\\n max-width: 1600px;\\n border-color: #7f7f7f;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n font-weight: 400;\\n background-color: white;\\n cursor: default;\\n}\\n.igv-roi-table > div {\\n height: 24px;\\n font-size: 14px;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n}\\n.igv-roi-table > div:first-child {\\n border-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-top-width: 0;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-roi-table > div:first-child > div:first-child {\\n text-align: center;\\n white-space: nowrap;\\n text-overflow: ellipsis;\\n overflow: hidden;\\n margin-left: 4px;\\n margin-right: 4px;\\n width: calc(100% - 4px - 12px);\\n}\\n.igv-roi-table > div:first-child > div:last-child {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7f7f7f;\\n}\\n.igv-roi-table > div:first-child > div:last-child > svg {\\n display: block;\\n}\\n.igv-roi-table > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-table > .igv-roi-table-description {\\n padding: 4px;\\n margin-left: 4px;\\n word-break: break-all;\\n overflow-y: auto;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-goto-explainer {\\n margin-top: 5px;\\n margin-left: 4px;\\n color: #7F7F7F;\\n font-style: italic;\\n height: 24px;\\n border-top: solid lightgray;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n padding-right: 16px;\\n background-color: white;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: #7f7f7f;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n overflow: auto;\\n height: 360px;\\n flex: 1 1 auto;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: transparent;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n.igv-roi-table > div:last-child {\\n min-height: 32px;\\n height: 32px;\\n line-height: 32px;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: transparent;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-width: 0;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n\\n.igv-roi-table-row-selected {\\n background-color: rgba(0, 0, 0, 0.125);\\n}\\n\\n.igv-roi-table-button {\\n cursor: pointer;\\n height: 20px;\\n user-select: none;\\n line-height: 20px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 13px;\\n font-weight: 400;\\n color: black;\\n padding-left: 6px;\\n padding-right: 6px;\\n background-color: rgb(239, 239, 239);\\n border-color: black;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 3px;\\n}\\n\\n.igv-roi-table-button:hover {\\n font-weight: 400;\\n background-color: rgba(0, 0, 0, 0.13);\\n}\\n\\n.igv-roi-region {\\n z-index: 64;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n pointer-events: none;\\n overflow: visible;\\n margin-top: 66px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-region > div {\\n position: relative;\\n width: 100%;\\n height: 8px;\\n pointer-events: auto;\\n}\\n\\n.igv-roi-menu-row {\\n height: 24px;\\n padding-left: 8px;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n background-color: white;\\n}\\n\\n.igv-roi-menu-row-edit-description {\\n width: -webkit-fill-available;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n background-color: white;\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-bottom: 4px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-menu-row-edit-description > label {\\n margin-left: 2px;\\n margin-bottom: 0;\\n display: block;\\n width: -webkit-fill-available;\\n}\\n.igv-roi-menu-row-edit-description > input {\\n display: block;\\n margin-left: 2px;\\n margin-right: 2px;\\n margin-bottom: 1px;\\n width: -webkit-fill-available;\\n}\\n\\n.igv-container {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n padding-top: 4px;\\n user-select: none;\\n -webkit-user-select: none;\\n -ms-user-select: none;\\n min-height: 160px;\\n}\\n\\n.igv-viewport {\\n position: relative;\\n margin-top: 5px;\\n line-height: 1;\\n overflow-x: hidden;\\n overflow-y: hidden;\\n}\\n\\n.igv-viewport-content {\\n position: relative;\\n width: 100%;\\n}\\n.igv-viewport-content > canvas {\\n position: relative;\\n display: block;\\n}\\n\\n.igv-column-container {\\n position: relative;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n width: 100%;\\n}\\n\\n.igv-column-shim {\\n width: 1px;\\n margin-left: 2px;\\n margin-right: 2px;\\n background-color: #545453;\\n}\\n\\n.igv-axis-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 50px;\\n}\\n.igv-axis-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n}\\n.igv-axis-column > div > div {\\n z-index: 512;\\n position: absolute;\\n top: 8px;\\n left: 8px;\\n width: fit-content;\\n height: fit-content;\\n background-color: transparent;\\n display: grid;\\n align-items: start;\\n justify-items: center;\\n}\\n.igv-axis-column > div > div > input {\\n display: block;\\n margin: unset;\\n cursor: pointer;\\n}\\n\\n.igv-column {\\n position: relative;\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-info-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-name-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-scrollbar-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div > div {\\n cursor: pointer;\\n position: absolute;\\n top: 0;\\n left: 2px;\\n width: 8px;\\n border-width: 1px;\\n border-style: solid;\\n border-color: #c4c4c4;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-scrollbar-column > div > div:hover {\\n background-color: #c4c4c4;\\n}\\n\\n.igv-track-drag-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 12px;\\n background-color: white;\\n}\\n.igv-track-drag-column > .igv-track-drag-handle {\\n z-index: 512;\\n position: relative;\\n cursor: pointer;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n border-top-right-radius: 6px;\\n border-bottom-right-radius: 6px;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-color {\\n background-color: #c4c4c4;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-hover-color {\\n background-color: #787878;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-selected-color {\\n background-color: #0963fa;\\n}\\n.igv-track-drag-column > .igv-track-drag-shim {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n}\\n\\n.igv-gear-menu-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 28px;\\n}\\n.igv-gear-menu-column > div {\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n margin-top: 5px;\\n width: 100%;\\n background: white;\\n}\\n.igv-gear-menu-column > div > div {\\n position: relative;\\n margin-top: 4px;\\n width: 16px;\\n height: 16px;\\n color: #7F7F7F;\\n}\\n.igv-gear-menu-column > div > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n/*# sourceMappingURL=igv.css.map */\\n'),n.adoptedStyleSheets=[e]}if(this.root=e({class:\"igv-container\"}),n.appendChild(this.root),this.spinner=e({class:\"igv-loading-spinner-container\"}),this.root.appendChild(this.spinner),this.spinner.appendChild(e()),this.spinner.style.width=\"64px\",this.spinner.style.height=\"64px\",this.stopSpinner(),this.alert=new La(this.root),this.columnContainer=e({class:\"igv-column-container\"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Xu(this.columnContainer),this.menuUtils=new bo(this),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:\"rgb(0,0,150)\",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},t.listeners)for(let e of Object.keys(t.listeners))this.on(e,t.listeners[e]);this.on(\"trackremoved\",(()=>{0===this.findTracks((e=>\"function\"==typeof e.getSamples)).length&&(this.sampleInfoControl.setButtonVisibility(!1),this.sampleNameViewportWidth=void 0,this.showSampleNames=!1,this.sampleNameControl.setState(this.showSampleNames),this.sampleNameControl.hide(),this.layoutChange())})),this.on(\"didchangecolumnlayout\",(()=>{if(yu.length>0){const e=yu.length;for(let t=0;t1}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let e of this.referenceFrameList)if(\"all\"===e.chr.toLowerCase())return!0;return!1}currentLoci(){const e=e=>`${e.chr}:${e.start+1}-${e.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?\"\":1===this.referenceFrameList.length?e(this.referenceFrameList[0]):this.referenceFrameList.map((t=>e(t)))}toSVG(){const{x:e,y:t,width:i,height:n}=this.columnContainer.getBoundingClientRect(),r=new lu({width:i,height:n,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:i,height:n}}),s={deltaX:0,deltaY:-t};for(let e of this.trackViews)e.renderSVGContext(r,s);return s.deltaX=e,this.roiManager.renderSVGContext(this.columnContainer,r,s),r.getSerializedSvg(!0)}saveSVGtoFile(e,t){let i=this.toSVG();if(t){const e=document.createElement(\"svg\");e.innerHTML=i,t.append(e),t.appendChild(e)}const n=e||\"igvjs.svg\",r=URL.createObjectURL(new Blob([i],{type:\"application/octet-stream\"}));Pt(n,r),URL.revokeObjectURL(r)}savePNGtoFile(e){const t=this.toSVG(),i=new Blob([t],{type:\"image/svg+xml\"}),n=URL.createObjectURL(i),r=document.createElement(\"img\");r.addEventListener(\"load\",(()=>{const t=this.columnContainer.getBoundingClientRect(),i=window.devicePixelRatio,s=t.width*i,o=t.height*i,a=document.createElement(\"canvas\");a.width=s,a.height=o;const c=a.getContext(\"2d\");c.scale(i,i),c.drawImage(r,0,0);const l=a.toDataURL(\"image/png\");Pt(e=e||\"igvjs.png\",l),URL.revokeObjectURL(n)})),r.src=n}async loadSession(e){let t;return this.sampleInfo.initialize(),this.roiSets=[],t=e.url||e.file?await dA.loadSessionFile(e):e,this.loadSessionObject(t)}static async loadSessionFile(e){const t=e.url||e.file;let i;if(e.url&&Mt(e.url)&&(e.url.startsWith(\"blob:\")||e.url.startsWith(\"data:\"))){const t=dA.uncompressSession(e.url);i=JSON.parse(t)}else{let n=e.filename;if(n||(n=e.url?await ja(e.url):e.file.name),n.endsWith(\".xml\")){const e=mu.KNOWN_GENOMES,n=await Qs.loadString(t);i=new by(n,e)}else if(n.endsWith(\"hub.txt\")){i={reference:(await du.loadHub(t,e)).getGenomeConfig()}}else{if(!n.endsWith(\".json\"))throw Error(\"Unrecognized session file format:\"+n);i=await Qs.loadJson(t)}}return bA(i)}async loadSessionObject(e){this.cleanHouseForSession(),this.config=e,e.browsers&&(e=await async function(e){const t=e.browsers[0],i={},n=new Mf({url:t.url});await n.readHeaderAndFooter(),i.sampleNameViewportWidth=20,i.genome=\"hg38\";const r=t.state.split(\",\"),s=n.bpResolutions[Number.parseInt(r[2])],o=Number.parseInt(r[0]),a=Math.floor(Number.parseFloat(r[3])*s),c=a+Math.floor(1700*s);return i.locus=`${n.chromosomes[o].name}:${a}-${c}`,i.tracks=(t.tracks||[]).filter((e=>!(\"refgene\"===e.format||\"cellType\"===e.name))),i.tracks.push({type:\"shoebox\",url:t.url,name:t.name,colorScale:t.colorScale,_hicFile:n}),i}(e)),this.navbar.sampleInfoControl.setButtonVisibility(!1),this.showSampleNames=e.showSampleNames||!1,this.navbar.sampleNameControl.setState(!0===this.showSampleNames),e.sampleNameViewportWidth&&(this.sampleNameViewportWidth=e.sampleNameViewportWidth),$a(this.columnContainer,\"igv-axis-column\"),$a(this.columnContainer,\"igv-sample-info-column\"),$a(this.columnContainer,\"igv-sample-name-column\"),$a(this.columnContainer,\"igv-scrollbar-column\"),$a(this.columnContainer,\"igv-track-drag-column\"),$a(this.columnContainer,\"igv-gear-menu-column\");const t=e.reference||e.genome;if(!t)return void console.warn(\"No genome or reference object specified\");const i=Mt(t)?await mu.expandReference(this.alert,t):t;if(await this.loadReference(i,i.locus||e.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==e.showIdeogram){const e=new hy(this);e.id=\"ideogram\";const t=new hf(this,this.columnContainer,e);this.trackViews.push(t)}if(!1!==e.showRuler){const e=new hf(this,this.columnContainer,new Wu(this));this.trackViews.push(e)}e.qtlSelections&&(this.qtlSelections=cA.fromJSON(e.qtlSelections)),this.roiManager.clearROIs(),e.roi?this.roiManager.loadROI(e.roi):await this.roiManager.reset();const n=[];if(e.sampleinfo)for(const t of e.sampleinfo)t.file?n.push(t.file):this.loadSampleInfo(t);const r=i.tracks||[],s=e.tracks?r.concat(e.tracks):r;0===s.filter((e=>\"sequence\"===e.type&&!e.url&&!e.fastaURL)).length&&s.push({type:\"sequence\",order:Wd,removable:!1});const o=s.filter((e=>void 0!==e.file)).map((({file:e})=>e)),a=s.filter((e=>void 0!==e.indexFile)).map((({indexFile:e})=>e));a.length>0&&o.push(...a),n.length>0&&o.push(...n),o.length>0&&alert(`Local files cannot be loaded automatically.\\nThis session contains references to these local files:\\n${o.map((e=>` ${e}`)).join(\"\\n\")}`);const c=s.filter((e=>void 0===e.file));let l=1;for(let e of c)void 0===e.order&&(e.order=l++);await this.loadTrackList(c);for(let e of this.trackViews.filter((e=>\"ruler\"===e.track.type||\"ideogram\"===e.track.type)))await e.updateViews();return this.trackViews.some((e=>e.track.selected))&&this.navbar.setEnableTrackSelection(!0),this.updateUIWithReferenceFrameList(),this.updateLocusSearchWidget(),s}cleanHouseForSession(){for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-info-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column\").forEach((e=>e.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}async loadReference(e,t){let i;this.removeAllTracks(),this.roiManager.clearROIs(),this.navbar.setEnableTrackSelection(!1),i=e.gbkURL?await wd(e.gbkURL):await aA.createGenome(e,this);const n=void 0===this.genome||this.genome.id!==i.id;this.genome=i,this.navbar.updateGenome(i);let r=t||i.initialLocus;Array.isArray(r)&&(r=r.join(\" \"));if(!await this.search(r,!0))throw new Error(`Cannot set initial locus ${r}`);if(n){let t;if(e.hubURL){t=(await du.loadHub(e.hubURL)).getGroupedTrackConfigurations()}this.fireEvent(\"genomechange\",[{genome:i,trackConfigurations:t}]),this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)})}}async loadGenome(e){let t;e.genarkAccession&&(e.url=hu(e.genarkAccession)),e.url&&(Mt(e.url)&&e.url.endsWith(\"/hub.txt\")?(e.hubURL=e.url,delete e.url):\"gbk\"===function(e){let t;if(e instanceof File)t=e.name;else{if(\"string\"!=typeof e)throw new Error(\"Input must be a File object or a URL string\");t=e}const i=t.split(\".\").pop();return i.split(\"?\")[0]}(e.url)&&(e.gbkURL=e.url,delete e.url));if(e.hubURL||e.url&&Mt(e.url)&&e.url.endsWith(\"/hub.txt\")){t=(await du.loadHub(e.hubURL||e.url,e)).getGenomeConfig()}else t=Mt(e)||!(e.url||e.fastaURL||e.twoBitURL||e.gbkURL)?await mu.expandReference(this.alert,e):e;let i;await this.loadReference(t),i=t.gbkURL||\"gbk\"===t.format?[{name:\"Annotations\",format:\"gbk\",url:t.gbkURL}]:t.tracks||[];return 0===i.filter((e=>\"sequence\"===e.type)).length&&i.push({type:\"sequence\",order:Wd}),await this.loadTrackList(i),await this.updateViews(),this.genome}async loadTrackHub(e){const t=bA((await du.loadHub(e.url,e)).getGenomeConfig());return this.loadGenome(t)}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(e[0].chr),this.navbar.navbarDidResize(),mA(this.trackViews,this.doShowTrackLabels),this.doShowCenterLine&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.centerLineButton.boundMouseClickHandler(),this.doShowCursorGuide&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.cursorGuideButton.boundMouseClickHandler(),this.setCenterLineAndCenterLineButtonVisibility(mu.isWholeGenomeView(e[0].chr))}setCenterLineAndCenterLineButtonVisibility(e){e?this.navbar.centerLineButton.setVisibility(!1):this.navbar.centerLineButton.setVisibility(this.config.showCenterGuideButton);for(let t of this.centerLineList)e?this.setCenterLineVisibility(!e):this.setCenterLineVisibility(this.doShowCenterLine)}setTrackLabelVisibility(e){mA(this.trackViews,e)}setROITableVisibility(e){!0===e?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)!0===e?(t.show(),t.repaint()):t.hide()}async loadTrackList(e){let t=0;for(let i of e)void 0===i.order&&(i.order=t++);const i=[];for(let t of e)i.push(this._loadTrack(t));const n=await Promise.all(i);return this.trackViews.filter((function(e){return e.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadTrack(e){e.sync=!1!==e.sync;const t=this._loadTrack(e);return t&&e.autoscaleGroup&&(await t,this.updateViews()),t}async _loadTrack(e){Mt(e)&&(e=JSON.parse(e));try{if(e.hidden){const t=Ad(e,this.genome);return void await t.getFeatures({chr:\"1\",start:0,end:Number.MAX_SAFE_INTEGER})}const t=await this.createTrack(e);if(\"sampleinfo\"===e.type)return void this.layoutChange();if(void 0===t)return;return this.addTrack(e,t)}catch(t){let i=t.message||t.error||t.toString();const n={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};n.hasOwnProperty(i)&&(i=n[i]),i=`${i} : ${Ht(e.url)?e.url.name:e.url}`;const r=new Error(i);throw console.error(r),r}}async addTrack(e,t){void 0===t.order&&(t.order=this.trackViews.length);const i=new hf(this,this.columnContainer,t);if(this.trackViews.push(i),mA(this.trackViews,this.doShowTrackLabels),\"function\"==typeof t.postInit)try{i.startSpinner(),await t.postInit()}finally{i.stopSpinner()}return t.autoscaleGroup||(e.sync?await i.updateViews():i.updateViews()),\"function\"==typeof t.hasSamples&&t.hasSamples()&&(this.sampleInfo.hasAttributes()&&this.sampleInfoControl.setButtonVisibility(!0),!1!==this.config.showSampleNameButton&&this.sampleNameControl.show()),this.reorderTracks(),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),t.trackView.enableTrackSelection(this.navbar.getEnableTrackSelection()),t}async loadROI(e){return this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=this.roiManager.getUserDefinedROISet();if(void 0===e)return[];const t=await e.getAllFeatures(),i=[];for(let e of Object.values(t))i.push(...e);return i}return[]}getRulerTrackView(){const e=this.trackViews.filter((({track:e})=>\"ruler\"===e.id));return e.length>0?e[0]:void 0}async createTrack(e){let t=await async function(e){return\"function\"==typeof e?e():e}\n", - "/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(e.url||e.fastaURL);if(Mt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format=\"fasta\";else if(e.sourceType)\"htsget\"===e.sourceType&&await Rh.inferFormat(e);else{const t=await am(e);t&&(e.format=t)}e.type&&Ha(e);let i=e.type?e.type.toLowerCase():void 0;if(!i){if(!e.format)throw Error(`Unrecognized track: ${JSON.stringify(e)}`);if(\"hic\"===e.format){const t=new Mf(e);if(await t.readHeaderAndFooter(),!t.chromosomeIndexMap.celltype)throw Error(\"'.hic' files not supported\");i=\"shoebox\",e._hicFile=t}else if(i=za(e.format),\"bedtype\"===i){const t=Ad(e,this.genome);e._featureSource=t;const n=await t.trackType();i=n||\"annotation\"}e.type=i}if(this.trackDefaults&&i){const t=this.trackDefaults[i];if(t)for(let i in t)t.hasOwnProperty(i)&&void 0===e[i]&&(e[i]=t[i])}const n=function(e,t,i){let n;switch(e){case\"annotation\":case\"genes\":case\"fusionjuncspan\":case\"snp\":n=\"feature\";break;case\"seg\":case\"maf\":case\"mut\":n=\"seg\";break;case\"junctions\":case\"splicejunctions\":n=\"junction\";break;default:n=e}return wy.has(n)?wy.get(n)(t,i):void 0}(i,e,this);if(void 0!==n)return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map((e=>new eA(e,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0)}reorderTracks(){this.trackViews.sort((function(e,t){const i=e=>\"ideogram\"===e.track.id?1:\"ruler\"===e.track.id?2:3,n=i(e),r=i(t);if(n===r){return(e.track.order||0)-(t.track.order||0)}return n-r}));for(let{axis:e,viewports:t,sampleInfoViewport:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){e.remove();for(let{$viewport:e}of t)e.detach();i.viewport.remove(),n.viewport.remove(),r.remove(),s.remove(),o.remove()}const e=this.columnContainer.querySelectorAll(\".igv-column\");for(let{axis:t,viewports:i,sampleInfoViewport:n,sampleNameViewport:r,outerScroll:s,dragHandle:o,gearContainer:a}of this.trackViews){this.columnContainer.querySelector(\".igv-axis-column\").appendChild(t);for(let t=0;te.track&&e.track.name)).map((e=>e.track.name))}getSelectedTrackViews(){return this.trackViews.filter((e=>!0===e.track.selected))}removeTrackByName(e){const t=this.trackViews.slice();for(let i of t)e===i.track.name&&this.removeTrack(i.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent(\"trackremoved\",[e]),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=this.trackViews;this.trackViews=[];for(let t of e)\"ruler\"!==t.track.id&&\"ideogram\"!==t.track.id?(this.fireEvent(\"trackremoved\",[t.track]),t.dispose()):this.trackViews.push(t)}get ideogramTrackView(){return this.trackViews[0]}get rulerTrackView(){return this.trackViews[1]}findTracks(e,t){let i=\"function\"==typeof e?t=>e(t.track):i=>t===i.track[e];return this.trackViews.filter(i).map((e=>e.track))}get tracks(){return this.trackViews.map((e=>e.track)).filter((e=>void 0!==e))}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach((function(t){t.setTrackHeight(e)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((e=>e.bpPerPixel<0))){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel=(t.end-t.start)/e}this.referenceFrameList&&this.navbar.navbarDidResize(),uA.call(this),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(let e of this.referenceFrameList)e.bpPerPixel<=10&&await this.genome.getSequence(e.chr,e.start,e.start+1);for(let e of this.centerLineList)e.repaint();if(this.dragObject)for(let t of e)await t.updateViews();else{const t={},i=[];for(const n of e)if(n.track.autoscaleGroup){const e=n.track.autoscaleGroup;t[e]||(t[e]=[]),t[e].push(n)}else i.push(n);if(Object.entries(t).length>0)for(const[e,i]of Object.entries(t)){const e=await Promise.all(i.map((e=>e.getInViewFeatures()))),t=qa(e.flat());for(const e of i)e.track.dataRange=Object.assign({},t),e.track.autoscale=!1;await Promise.all(i.map((e=>e.updateViews())))}await Promise.all(i.map((e=>e.updateViews())))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of e)i.end=i.start+i.bpPerPixel*t;const i=1===e.length?this.referenceFrameList[0].chr:\"\",n=this.referenceFrameList.map((e=>e.getLocusString())).join(\" \");this.navbar.updateLocus(n,i),this.fireEvent(\"locuschange\",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleInfoViewportWidth()+this.getSampleNameViewportWidth()+14+12+28,t-=5*(e-1),Math.floor(t/e)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=s;const o=(i-t)/r,a=new vy(this.genome,e,t,i,o),c=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],d=Uy(h.get(0).parentElement);if(this.fireEvent(\"didchangecolumnlayout\"),l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.push(t)}}else{this.referenceFrameList.splice(l,0,a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.splice(l,0,t)}}this.centerLineList=this.createCenterLineList(this.columnContainer),uA.call(this),await this.updateViews(!0)}createCenterLineList(e){const t=e.querySelectorAll(\".igv-center-line\");for(let e=0;e{i===t||e.remove()})),this.columnContainer.querySelectorAll(\".igv-column-shim\").forEach((e=>e.remove()));for(let e of this.trackViews){const i=e.viewports[t];e.viewports.filter(((e,i)=>i!==t)).forEach((e=>e.dispose())),e.viewports=[i]}const i=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/i,this.referenceFrameList=[e],this.trackViews.forEach((({viewports:e})=>e.forEach((e=>e.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=e;for(let{viewports:e}of this.trackViews)for(let i of e)i.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,i){await this.search(e+\":\"+t+\"-\"+i)}async doSearch(e,t){const i=await this.search(e,t);return i||this.alert.present(new Error(`Unrecognized locus: ${e} `)),i}async search(e,t){const i=await async function(e,t){if(void 0===t||\"\"===t.trim())return;const i=t.split(\" \");let n=[];const r=async t=>{if(\"all\"===t.trim().toLowerCase()||\"*\"===t)return e.genome.wholeGenomeView?{chr:\"all\",start:0,end:e.genome.getChromosome(\"all\").bpLength}:void 0;let i,n;if(t.includes(\":\")&&(i=ey(t,e.isSoftclipped()),i&&(n=await e.genome.loadChromosome(i.chr))),!n){i=void 0;const r=await Jv(e,t);r&&(i={chr:r.chr,start:r.start,end:r.end,name:(r.name||t).toUpperCase()}),i||(n=await e.genome.loadChromosome(t),n&&(i={chr:n.name}))}return i&&(n=n||await e.genome.loadChromosome(i.chr),i.chr=n.name,void 0===i.start&&void 0===i.end&&(i.start=0,i.end=n.bpLength)),i};for(let e of i){const t=await r(e);t&&n.push(t)}if(0===n.length){const e=await r(t.replaceAll(\" \",\"+\"));e&&n.push(e)}return 0===n.length?void 0:n}(this,e);if(i&&i.length>0){this.referenceFrameList=function(e,t,i,n,r,s){return e.map((e=>{const o=Object.assign({},e);if(i&&o.name&&(o.start=Math.max(0,o.start-i),o.end+=i),!s){const e=t.getChromosome(o.chr);Qa(e.bpLength,o,n)}return new vy(t,o.chr,o.start,o.end,(o.end-o.start)/r)}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let e of this.trackViews)e.removeViewportsFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-column-shim, .igv-column\").forEach((e=>e.remove())),qy(this.columnContainer.querySelector(\".igv-sample-info-column\"),this.referenceFrameList.length),this.fireEvent(\"didchangecolumnlayout\");for(let e of this.trackViews)e.createViewports(this,this.columnContainer,this.referenceFrameList);return this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}return!1}async loadSampleInfo(e){await this.sampleInfo.loadSampleInfoFile(e.url);for(const{sampleInfoViewport:e}of this.trackViews)e.setWidth(this.getSampleInfoColumnWidth());this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0&&(this.sampleInfoControl.performClickWithState(this,!0),this.sampleInfoControl.setButtonVisibility(!0));for(const{sampleInfoViewport:e}of this.trackViews)e.repaint()}getSampleInfoColumnWidth(){if(this.sampleInfo.attributeCount){const e=this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0,t=this.sampleInfo.hasAttributes(),i=this.sampleInfoControl.showSampleInfo;return e&&t&&i?this.sampleInfo.attributeCount*Vu+8:0}return 0}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(e)if(t){const i=this.eventHandlers[e];if(i&&0!==i.length){const n=i.indexOf(t);-1!==n&&this.eventHandlers[e].splice(n,1)}else console.warn(\"No handlers to remove for event: \"+e)}else this.eventHandlers[e]=[];else this.eventHandlers={}}fireEvent(e,t,i){const n=this.eventHandlers[e];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(e){return e.apply(r,t)}))[0]}dispose(){this.removeEventHandlers();for(let e of this.trackViews)e.dispose();this.roiManager&&this.roiManager.dispose()}toJSON(){const e={version:\"3.0.9\"};if(void 0!==this.showSampleNames&&(e.showSampleNames=this.showSampleNames),this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[];let i=this.trackViews[0];for(let{referenceFrame:e}of i.viewports){const i=e.getLocusString();t.push(i)}e.locus=1===t.length?t[0]:t,e.roi=this.roiManager.toJSON(),this.qtlSelections.isEmpty()||(e.qtlSelections=this.qtlSelections.toJSON());const n=[],r=[];for(const{track:e}of this.trackViews)try{let t;\"function\"==typeof e.getState?t=Hl.localFileInspection(e.getState()):e.config&&(t=Hl.localFileInspection(e.config)),t&&(t.browser&&delete t.browser,t.order=e.order,n.push(t))}catch(t){const i=`Track: ${e.name}: ${t}`;console.error(i),r.push(i)}if(r.length>0){let e=1,t=\"Errors encountered saving session:
\";for(let i of r)t+=` (${e++}) ${i.toString()}
`;throw Error(t)}e.tracks=n;const s=[];for(const e of n)for(const t of Object.keys(e))\"file\"!==t&&\"indexFile\"!==t||s.push(e[t]);const o=[];if(this.sampleInfo.sampleInfoFiles.length>0){const t=this.sampleInfo.toJSON();t.length>0&&(e.sampleinfo=t);for(const e of this.sampleInfo.sampleInfoFiles){const t=Hl.localFileInspection({url:e});t.file&&o.push(t.file)}o.length>0&&s.push(...o)}return s.length>0&&alert(`This session includes reference(s) to local file(s):\\n${s.map((e=>` ${e}`)).join(\"\\n\")}\\nLocal files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){return function(e){const t=new Uint8Array(e.length);for(var i=0;i0?e.substring(0,t):e)+\"?sessionURL=blob:\"+this.compressedSession()}mouseDownOnViewport(e,t){var i;i=r(e),this.vpMouseDown={viewport:t,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent(\"trackdragend\",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((e=>!0===e.track.showSoftClips))}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,i=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),r=this.trackViews;r[i]=t,r[n]=e;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i0;e--){const t=r[e].track;if(!(t.order>=a))break;t.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=t.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=uA.bind(this),window.addEventListener(\"resize\",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener(\"resize\",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=pA.bind(this),this.root.addEventListener(\"mouseup\",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener(\"mouseup\",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=pA.bind(this),this.root.addEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=fA.bind(this),this.boundColumnContainerTouchMoveHandler=fA.bind(this),this.boundColumnContainerMouseLeaveHandler=pA.bind(this),this.boundColumnContainerMouseUpHandler=pA.bind(this),this.boundColumnContainerTouchEndHandler=pA.bind(this),this.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=gA.bind(this),document.addEventListener(\"keyup\",this.keyUpHandler)}removeKeyboardHandler(){console.log(\"Remove handler\"),document.addEventListener(\"keyup\",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf(\"/gzip;base64\")>0){t=vs(e);let i=\"\";for(let e of t)i+=String.fromCharCode(e);return i}return function(e){e=e.replace(/\\./g,\"+\").replace(/_/g,\"/\").replace(/-/g,\"=\");const t=atob(e),i=[];for(let e=0;e{const r=e.data,s=r.mate;function o(e){e.chr=i.genome.getChromosomeName(e.refName);let t=!1;for(let n of i.referenceFrameList){const i=lm.fromLocusString(n.getLocusString());if(i.contains(e)){t=!0;break}if(i.overlaps(e)){n.extend(e),t=!0;break}}if(!t){const t=2e3,n=(e.start+e.end)/2;i.addMultiLocusPanel(e.chr,n-t,n+t)}}o(r),o(s)}})),this.circularViewControl=new Vy(this.navbar.toggle_button_container,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get sampleInfoControl(){return this.navbar.sampleInfoControl}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}get sampleNameControl(){return this.navbar.sampleNameControl}}async function uA(){if(!this.referenceFrameList)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList){const i=this.referenceFrameList.indexOf(t),{chr:n,genome:r}=t,{bpLength:s}=r.getChromosome(t.chr),o=t.toBP(e);mu.isWholeGenomeView(n)||o>s?t.bpPerPixel=s/e:t.end=t.start+t.toBP(e);for(let{viewports:t}of this.trackViews)t[i].setWidth(e)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function fA(e){e.preventDefault();const{x:t,y:i}=r(e);if(this.vpMouseDown){const{viewport:e,referenceFrame:n}=this.vpMouseDown,r=Math.abs(t-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(t-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:e,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const t=e.$viewport.height(),i=e.trackView.maxViewportContentHeight();this.vpMouseDown.r=t/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-t;n.shiftPixels(r,e.$viewport.width(),i)&&this.updateViews(),this.fireEvent(\"trackdrag\")}if(this.isScrolling){const t=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);e.trackView.moveScroller(t)}this.vpMouseDown.lastMouseX=t,this.vpMouseDown.lastMouseY=i}}function pA(e){this.cancelTrackPan(),this.endTrackDrag()}async function gA(e){if(this.referenceFrameList&&!(this.referenceFrameList.length>1)&&(\"KeyF\"===e.code||\"KeyB\"===e.code)){const t=this.getSelectedTrackViews();if(t.length>0){const i=t[0].track;if(\"function\"==typeof i.nextFeatureAfter){const t=this.referenceFrameList[0],n=t.viewport?t.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),r=\"all\"===t.chr.toLowerCase(),s=i.visibilityWindow;if(r||s&&s>0&&t.bpPerPixel*n>s)return;const o=\"KeyF\"===e.code,a=t.chr,c=t.center,l=await i.nextFeatureAfter(a,c,o);if(l){const i=await this.genome.getChromosomeName(l.chr);if(a===i){const i=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,r=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,i-r/2),t.end=i+r/2,t.bpPerPixel=(t.end-t.start)/n}else t.shift(i-c);this.updateViews()}else{t.chr=i;const r=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,i=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,r-i/2),t.end=t.start+i,t.bpPerPixel=(t.end-t.start)/n}else t.start=r-n*t.bpPerPixel/2,t.end=t.start+n*t.bpPerPixel;this.updateViews()}}}}}}function mA(e,t){for(let{viewports:i}of e)for(let e of i)e.$trackLabel&&(0===i.indexOf(e)&&!0===t?e.$trackLabel.show():e.$trackLabel.hide())}let wA=[];function bA(e){return void 0===e.minimumBases&&(e.minimumBases=40),void 0===e.showIdeogram&&(e.showIdeogram=!0),void 0===e.showCircularView&&(e.showCircularView=!1),void 0===e.showCircularViewButton&&(e.showCircularViewButton=!1),void 0===e.showTrackLabelButton&&(e.showTrackLabelButton=!0),void 0===e.showTrackLabels&&(e.showTrackLabels=!0),void 0===e.showCursorTrackingGuideButton&&(e.showCursorTrackingGuideButton=!0),void 0===e.showCursorGuide&&(e.showCursorGuide=e.showCursorTrackingGuide||!1),void 0===e.showCenterGuideButton&&(e.showCenterGuideButton=!0),void 0===e.showCenterGuide&&(e.showCenterGuide=!1),void 0===e.showSampleNames&&(e.showSampleNames=!1),void 0===e.showSVGButton&&(e.showSVGButton=!0),void 0===e.showControls&&(e.showControls=!0),void 0===e.showNavigation&&(e.showNavigation=!0),void 0===e.showRuler&&(e.showRuler=!0),void 0===e.flanking&&(e.flanking=1e3),void 0===e.pairsSupported&&(e.pairsSupported=!0),e.tracks||(e.tracks=[]),e}const FA=Qs.setApiKey;const vA=Qs.oauth;var yA={TrackUtils:Pa,IGVGraphics:xo,MenuUtils:bo,DataRangeDialog:_o,createTrack:async function(e,t){return await dA.prototype.createTrack.call(t,e)},createBrowser:async function(e,t){void 0===t&&(t={}),mu.KNOWN_GENOMES||await mu.initializeGenomes(t),bA(t),t.queryParametersSupported&&function(e){var t,i,n,r,s,o,a,c,l;let h,d,u;if(a=window.location.href,s={},t=a.indexOf(\"?\"),i=a.lastIndexOf(\"#\"),t>=0)for(i<0&&(i=a.length),n=t+1;nt&&(i.indexURL=d[t]),u&&u.length>t&&(i.name=u[t]),e.tracks.push(i)}}}(t),t.apiKey&&Qs.setApiKey(t.apiKey),t.oauthToken&&Qs.setOauthToken(t.oauthToken),t.clientId&&!Ts()&&await async function(e){if(!google.accounts.oauth2.initTokenClient)throw new Error(\"Google accounts token client not loaded (https://accounts.google.com/gsi/client)\");if(Ts())throw new Error(\"Google client is already initialized\");const t={client_id:e.client_id||e.clientId,scope:e.scope||\"https://www.googleapis.com/auth/userinfo.profile\",state:e.state||\"igv\",error:e=>{throw new Error(e.type)},hint:e.hint,hosted_domain:e.hosted_domain},i=google.accounts.oauth2.initTokenClient(t);google.igv={tokenClient:i,apiKey:e.apiKey}}({client_id:t.clientId,apiKey:t.apiKey,scope:\"https://www.googleapis.com/auth/userinfo.profile\"});const i=new dA(t,e);wA.push(i),i.startSpinner();const n=t.sessionURL||t.session||t.hubURL;return n?await i.loadSession({url:n}):await i.loadSessionObject(t),i.stopSpinner(),i.navbar.navbarDidResize(),i},removeBrowser:function(e){e.dispose(),e.root.remove(),wA=wA.filter((t=>t!==e))},removeAllBrowsers:function(){for(let e of wA)e.dispose(),e.root.remove();wA=[]},visibilityChange:async function(){for(let e of wA)await e.visibilityChange()},setGoogleOauthToken:function(e){return Qs.setOauthToken(e)},setOauthToken:function(e,t){return Qs.setOauthToken(e,t)},oauth:vA,version:yy,setApiKey:FA,TrackBase:Hl,registerTrackClass:function(e,t){wy.set(e,((e,i)=>new t(e,i)))},registerTrackCreatorFunction:function(e,t){wy.set(e,t)},registerFileFormats:function(e,t){Sl[e]={fields:t}},loadSessionFile:dA.loadSessionFile};return yA}();\n", - "//# sourceMappingURL=igv.iife.js.map\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Global handler for igv.js messages. Messages have the form\n", - " * {\n", - " * command -- the command to execute\n", - " * id -- the id of the igv.js browser, if applicable\n", - " * data -- any data needed for the command\n", - " * }\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope, with the execption of the global handler\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " let svgComm\n", - " if (isNotebook) {\n", - " svgComm = Jupyter.notebook.kernel.comm_manager.new_comm('svg', {})\n", - " }\n", - "\n", - " async function toSVG(displayID, locus, svg) {\n", - " //console.log(isNotebook + \" \" + locus)\n", - " if (isNotebook) {\n", - " svgComm.send({\n", - " \"display_id\": displayID,\n", - " \"locus\": locus,\n", - " \"svg\": svg\n", - " })\n", - " }\n", - " }\n", - "\n", - " console.log(\"Installing IGVMessageHandler\")\n", - "\n", - " function convertUrlsAndPaths(session) {\n", - " if (session.reference) {\n", - " for (let pre of [\"fasta\", \"index\", \"cytoband\", \"cytobandBb\", \"compressedIndex\", \"alias\", \"aliasBb\",\n", - " \"twoBit\", \"twoBitBpt\", \"chromAliasBb\", \"chromSizes\", \"trix\"]) {\n", - " convert(session.reference, pre)\n", - " }\n", - " if (session.reference.tracks) {\n", - " for (let t of session.reference.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " if (session.tracks) {\n", - " for (let t of session.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Return true if the sessionJson object contains only absolute URLs to resources\n", - " */\n", - " function safeToWeblink(sessionJson) {\n", - " const unsafe = (url) => typeof url.startsWith != 'function' || !url.startsWith(\"http\")\n", - " if (sessionJson.reference) {\n", - " if (unsafe(sessionJson.reference.fastaURL)) return false\n", - " }\n", - " if (sessionJson.tracks) {\n", - " const urls = sessionJson.tracks.filter(t => t.url).map(t => t.url)\n", - " if (urls.some(unsafe)) return false\n", - " }\n", - " return true\n", - " }\n", - "\n", - " class MessageHandler {\n", - "\n", - " constructor() {\n", - " this.browserCache = new Map()\n", - " this.messageQueue = new Queue()\n", - " }\n", - "\n", - " on(msg) {\n", - " this.messageQueue.enqueue(msg)\n", - " this.processQueue()\n", - " }\n", - "\n", - " async processQueue() {\n", - "\n", - " const convertTrackData = (data) => {\n", - " convert(data)\n", - " convert(data, \"index\")\n", - " if (!data.indexURL) {\n", - " data.indexed = false\n", - " }\n", - " }\n", - "\n", - " if (!this.processing) {\n", - " this.processing = true\n", - " while (!this.messageQueue.isEmpty()) {\n", - " const msg = this.messageQueue.dequeue()\n", - " const command = msg.command\n", - " const browserID = msg.id\n", - " const data = msg.data\n", - " const browser = this.browserCache.get(browserID)\n", - " try {\n", - " switch (command) {\n", - " case \"createBrowser\":\n", - "\n", - " // custom button bar\n", - " const button_container = document.getElementById(`${browserID}_buttons`) // <= created from python\n", - " const customButtonDiv = document.createElement('div')\n", - " customButtonDiv.style = `background: #f3f3f3;padding: 5px;border-color: #bfbfbf;border-style: solid;border-width: thin;border-radius: 3px;`\n", - " button_container.appendChild(customButtonDiv)\n", - "\n", - " data.sync = true\n", - " convertUrlsAndPaths(data)\n", - "\n", - " const container = document.getElementById(`${browserID}_igvcontainer`) // <= created from python\n", - " const newBrowser = await igv.createBrowser(container, data)\n", - " this.browserCache.set(browserID, newBrowser)\n", - "\n", - " // Add igv-notebook button bar\n", - " const toJsonButton = document.createElement('button')\n", - " toJsonButton.innerText = \"Save Session\"\n", - " toJsonButton.style = \"margin-right:5px\"\n", - " toJsonButton.addEventListener('click', (evt) => {\n", - " let fn\n", - " if (isNotebook) {\n", - " fn = prompt(\"Filename:\", \"session.json\")\n", - " } else {\n", - " fn = \"session.json\"\n", - " }\n", - " if (fn) {\n", - " const json = newBrowser.toJSON()\n", - " const jsonString = JSON.stringify(json, null, '\\t')\n", - " download(fn, jsonString)\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(toJsonButton)\n", - "\n", - " const webLinkNode = document.createElement('a')\n", - " webLinkNode.target = \"igvWeb\"\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.style.display = \"none\"\n", - "\n", - " const shareButton = document.createElement('button')\n", - " shareButton.innerText = \"Show IGV-Web Link\"\n", - " shareButton.style = \"margin-right:5px\"\n", - " shareButton.addEventListener('click', async (evt) => {\n", - "\n", - " if (safeToWeblink(newBrowser.toJSON())) {\n", - " const sessionURL = `https://igv.org/app?sessionURL=blob:${newBrowser.compressedSession()}`\n", - " const shortURL = await shortenURL(sessionURL)\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.setAttribute(\"href\", shortURL)\n", - " webLinkNode.style.display = \"inline-block\"\n", - " shareButton.innerText = \"Update IGV-Web Link\"\n", - " } else {\n", - " webLinkNode.innerText = \"Cannot link -- non URL resources used\"\n", - " webLinkNode.style.display = \"inline-block\"\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(shareButton)\n", - " customButtonDiv.appendChild(webLinkNode)\n", - "\n", - " if (isNotebook) {\n", - " const toSVGButton = document.createElement('button')\n", - " toSVGButton.innerText = \"To SVG\"\n", - " toSVGButton.style = \"float:right\"\n", - " toSVGButton.addEventListener('click', (evt) => {\n", - " const locus = newBrowser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " const svg = newBrowser.toSVG()\n", - " toSVG(browserID, locus, svg)\n", - " })\n", - " customButtonDiv.appendChild(toSVGButton)\n", - " }\n", - "\n", - " break\n", - "\n", - " case \"loadSession\":\n", - " convertUrlsAndPaths(data)\n", - " browser.loadSessionObject(data)\n", - " break\n", - "\n", - " case \"loadTrack\":\n", - " convertTrackData(data)\n", - " await browser.loadTrack(data)\n", - " break\n", - "\n", - " case \"loadROI\":\n", - " if (Array.isArray(data)) {\n", - " data.map(convertTrackData)\n", - " } else {\n", - " convertTrackData(data)\n", - " }\n", - " await browser.loadROI(data)\n", - " break\n", - "\n", - " case \"clearROIs\":\n", - " await browser.clearROIs()\n", - " break\n", - "\n", - " case \"search\":\n", - " browser.search(data)\n", - " break\n", - "\n", - " case \"zoomIn\":\n", - " browser.zoomIn()\n", - " break\n", - "\n", - " case \"zoomOut\":\n", - " browser.zoomOut()\n", - " break\n", - "\n", - " case \"remove\":\n", - " this.browserCache.delete(browserID)\n", - " document.getElementById(browserID).parentNode.removeChild(container)\n", - " break\n", - "\n", - " case \"toSVG\":\n", - " const displayId = data\n", - " const svg = browser.toSVG()\n", - " const locus = browser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " toSVG(displayId, locus, svg)\n", - " break\n", - "\n", - " default:\n", - " console.error(\"Unrecognized method: \" + msg.command)\n", - " }\n", - " } catch (e) {\n", - " console.error(e)\n", - " }\n", - " }\n", - " this.processing = false\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Potentially convert a path to a local File-like object.\n", - " * @param path\n", - " * @returns {*}\n", - " */\n", - " function createNotebookFile(path) {\n", - " if (!path ||\n", - " path.startsWith(\"https://\") || path.startsWith(\"http://\") || path.startsWith(\"gs://\") || path.startsWith(\"data:\")) {\n", - " return path\n", - " } else {\n", - " // Try to create a notebook file. If no notebook file implementation is available for the kernel in\n", - " // use (e.g. Jupyter Lab) treat as a URL.\n", - " const nbFile = igv.createNotebookLocalFile({path})\n", - " if (nbFile != null) {\n", - " return nbFile\n", - " } else {\n", - " // Try to treat as relative URL. This may or may not work\n", - " return convertURL(path)\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Convert relative URLs to absolute. Primarily for Jupyter Lab, not generally needed for Jupyter Notebook\n", - " * @param url\n", - " * @returns {*}\n", - " */\n", - " function convertURL(url) {\n", - "\n", - " const pageURL = window.location.href\n", - "\n", - " if (!url ||\n", - " url.startsWith(\"https://\") ||\n", - " url.startsWith(\"http://\") ||\n", - " url.startsWith(\"gs://\") ||\n", - " url.startsWith(\"data:\")) {\n", - " return url\n", - " } else if (isColab) {\n", - " // Interpret relative url as a path.\n", - " igv.createNotebookLocalFile({path: url})\n", - " } else if (isNotebook) {\n", - " // Jupyter Notebook\n", - " //\n", - " // Examples\n", - " // https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/notebooks/examples/BamFiles-Jupyter.ipynb\n", - " // => https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/files/examples/data/gstt1_sample.bam\",\n", - "\n", - " const baseURL = document.querySelector('body').getAttribute('data-base-url')\n", - " const notebookPath = document.querySelector('body').getAttribute('data-notebook-path')\n", - " const notebookName = document.querySelector('body').getAttribute('data-notebook-name')\n", - " const notebookDir = notebookPath.slice(0, -1 * notebookName.length)\n", - "\n", - " //`${location.origin}${base_path}files/${nb_dir}${url}`\n", - " if (url.startsWith(\"/\")) {\n", - " url = `files${url}`\n", - " return encodeURI(`${location.origin}${baseURL}${url}`)\n", - " } else {\n", - " // URL is relative to notebook\n", - " return encodeURI(`${location.origin}${baseURL}files/${notebookDir}${url}`)\n", - " }\n", - " } else if (pageURL.includes(\"/lab\")) {\n", - "\n", - " console.log(\"Jupyter lab\")\n", - " // Jupyter Lab\n", - "\n", - " // Examples\n", - " // http://localhost:8888/lab/workspaces/auto-N/tree/examples/BamFiles.ipynb\n", - " // => http://localhost:8888/files/examples/data/gstt1_sample.bam\n", - " //\n", - " // https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/lab/tree/examples/BamFiles.ipynb\n", - " // => https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/files/examples/data/gstt1_sample.bam\n", - "\n", - " const baseIndex = pageURL.indexOf(\"/lab\")\n", - " const baseURL = pageURL.substring(0, baseIndex)\n", - "\n", - " if (url.startsWith(\"/\")) {\n", - " return encodeURI(`${baseURL}/files${url}`)\n", - " } else if (pageURL.includes(\"/tree/\")) {\n", - " // Interpret URL as relative to notebook location. This is not reliable, '/tree/' is not always in the page URL\n", - " const treeIndex = pageURL.indexOf(\"/tree/\") + 6\n", - " const lastSlashIndex = pageURL.lastIndexOf(\"/\")\n", - " const notebookDir = pageURL.substring(treeIndex, lastSlashIndex)\n", - " return encodeURI(`${baseURL}/files/${notebookDir}/${url}`)\n", - " } else {\n", - " // We don't know how to determine the notebook path\n", - " console.warn(\"Page url missing '/tree/'. Can't determine notebook path.\")\n", - " return encodeURI(`${baseURL}/files/${url}`)\n", - " }\n", - " } else {\n", - " // We should never get here,\n", - " return encodeURI(url)\n", - " }\n", - " }\n", - "\n", - "\n", - " function convert(config, prefix) {\n", - " const urlProp = prefix ? prefix + \"URL\" : \"url\"\n", - " const pathProp = prefix ? prefix + \"Path\" : \"path\"\n", - " if (config[pathProp]) {\n", - " config[urlProp] = createNotebookFile(config[pathProp])\n", - " } else if (config[urlProp]) {\n", - " config[urlProp] = convertURL(config[urlProp])\n", - " }\n", - " }\n", - "\n", - "\n", - " class Queue {\n", - " constructor() {\n", - " this.elements = []\n", - " }\n", - "\n", - " enqueue(e) {\n", - " this.elements.push(e)\n", - " }\n", - "\n", - " dequeue() {\n", - " return this.elements.shift()\n", - " }\n", - "\n", - " isEmpty() {\n", - " return this.elements.length == 0\n", - " }\n", - "\n", - " peek() {\n", - " return !this.isEmpty() ? this.elements[0] : undefined\n", - " }\n", - "\n", - " length() {\n", - " return this.elements.length\n", - " }\n", - " }\n", - "\n", - " window.igv.MessageHandler = new MessageHandler()\n", - "\n", - " function download(filename, text) {\n", - "\n", - " const data = URL.createObjectURL(new Blob([text], {type: \"application/octet-stream\"}))\n", - " const element = document.createElement('a')\n", - " element.setAttribute('href', data)\n", - " element.setAttribute('download', filename)\n", - " element.style.display = 'none'\n", - " document.body.appendChild(element)\n", - " element.click()\n", - " document.body.removeChild(element)\n", - " }\n", - "\n", - " async function shortenURL(url) {\n", - " const endpoint = \"https://2et6uxfezb.execute-api.us-east-1.amazonaws.com/dev/tinyurl/\"\n", - " const enc = encodeURIComponent(url)\n", - " const response = await fetch(`${endpoint}${enc}`)\n", - " if (response.ok) {\n", - " return response.text()\n", - " } else {\n", - " throw new Error(response.statusText)\n", - " }\n", - " }\n", - "\n", - " console.log(\"igv.MessageHandler installed\")\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Mock objects to emulate the browser \"File\" class for use with Jupyter and Colab notebooks. These objects delegate\n", - " * actual file reading to python.\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " igv.createNotebookLocalFile = function (options) {\n", - " if (isColab) {\n", - " return new ColabLocalFile(options)\n", - " } else if (isNotebook) {\n", - " return new JupyterLocalFile(options)\n", - " } else {\n", - " return undefined; //TODO -- throw error?\n", - " }\n", - " }\n", - "\n", - "\n", - " // Start up a Comm object if in a Jupyter Notebook environment (i.e. not Colab or JupyterLab).\n", - " let comm\n", - " const pendingRequests = new Map()\n", - " if (isNotebook) {\n", - " console.log('registering comm')\n", - " comm = Jupyter.notebook.kernel.comm_manager.new_comm('file_request', {})\n", - " // Register a handler\n", - " comm.on_msg(function (msg) {\n", - " const id = msg.content.data.id\n", - " const data = msg.content.data.data\n", - " pendingRequests.set(id, data)\n", - " })\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Jupyter notebooks. File reading is delegated to python via Comms messaging.\n", - " * Polling is used to synchronize the async message passing.\n", - " *\n", - " * NOTE: This will not work for JupyterLab\n", - " */\n", - " class JupyterLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'JupyterLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new JupyterLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as binary data.\n", - " *\n", - " * @returns {Promise<*>}\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const id = uniqueID()\n", - " const path = this.path\n", - " const promise = new Promise((resolve, reject) => {\n", - " let count = 0\n", - "\n", - " function poll() {\n", - "\n", - " if (count > 100) {\n", - " console.error(`error reading ${path}: timed out`)\n", - " reject(`error reading ${path}: timed out`)\n", - " }\n", - "\n", - " count++\n", - " if (pendingRequests.has(id)) {\n", - " const data = pendingRequests.get(id)\n", - " const dataString = atob(data)\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " pendingRequests.delete(id)\n", - " resolve(bytes.buffer)\n", - " } else {\n", - " setTimeout(poll, 100)\n", - " }\n", - " }\n", - "\n", - " poll()\n", - " })\n", - "\n", - " const msg = (this.start === undefined) ?\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer'} :\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer', 'start': this.start, 'end': this.end}\n", - "\n", - " comm.send(msg)\n", - "\n", - " return promise\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Colab environments.\n", - " */\n", - " class ColabLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'ColabLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new ColabLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as\n", - " * binary data.\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const args = (this.start === undefined) ?\n", - " [this.path] :\n", - " [this.path, this.start.toString(), this.end.toString()]\n", - "\n", - " const result = await google.colab.kernel.invokeFunction(\n", - " 'ReadFile', // The callback name.\n", - " args, // The arguments.\n", - " {}) // kwargs\n", - " const data = result.data[\"text/plain\"]\n", - " const dataString = atob(data.substring(2, data.length - 1))\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " return bytes.buffer\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " let counter = 0\n", - "\n", - " function uniqueID() {\n", - " return `${Math.random()}-${counter++}`\n", - " }\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "window.igv.MessageHandler.on({\"id\": \"jb_831280\", \"command\": \"createBrowser\", \"data\": {\"reference\": {\"id\": \"AgamP4\", \"name\": \"Anopheles gambiae (PEST)\", \"fastaURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_CHROMOSOMES_AgamP4.fa.fai\", \"tracks\": [{\"name\": \"Genes\", \"type\": \"annotation\", \"format\": \"gff3\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/reference/genome/agamp4/Anopheles-gambiae-PEST_BASEFEATURES_AgamP4.12.gff3.gz\", \"indexed\": false}]}, \"locus\": \"2L:2,422,600-2,422,700\", \"tracks\": [{\"name\": \"Filters - gamb_colu_arab\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu_arab/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu_arab/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"Filters - gamb_colu\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/gamb_colu/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"Filters - arab\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/arab/2L_sitefilters.vcf.gz\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_agam_release/v3/site_filters/dt_20200416/vcf/arab/2L_sitefilters.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 30, \"colorBy\": \"FILTER\", \"colorTable\": {\"PASS\": \"#00cc96\", \"*\": \"#ef553b\"}}, {\"name\": \"SNPs\", \"url\": \"https://1177-vo-ml-lehmann-vmf00004.cog.sanger.ac.uk/VBS00256-4651STDY7017184.vcf.gz\", \"indexURL\": \"https://1177-vo-ml-lehmann-vmf00004.cog.sanger.ac.uk/VBS00256-4651STDY7017184.vcf.gz.tbi\", \"format\": \"vcf\", \"type\": \"variant\", \"visibilityWindow\": 20000, \"height\": 50}, {\"name\": \"Alignments\", \"url\": \"https://1177-vo-ml-lehmann-vmf00004.cog.sanger.ac.uk/VBS00256-4651STDY7017184.fixmate.bam\", \"indexURL\": \"https://1177-vo-ml-lehmann-vmf00004.cog.sanger.ac.uk/VBS00256-4651STDY7017184.fixmate.bam.bai\", \"format\": \"bam\", \"type\": \"alignment\", \"visibilityWindow\": 20000, \"height\": 500}], \"id\": \"jb_831280\"}})" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "ag3.view_alignments(\n", " sample=ag3.sample_metadata(sample_sets=\"3.1\").iloc[0][\"sample_id\"],\n", @@ -2644,7 +77,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14fb9ad2", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -2657,7 +90,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c3f68890", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -2670,7 +103,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fe787f1c", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -2683,7 +116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "064a2953", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -2696,7 +129,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd41cf04", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -2708,413 +141,10 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "fe887a0a", + "execution_count": null, + "id": "12", "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "'use strict';\n", - "(function(root) {\n", - " function now() {\n", - " return new Date();\n", - " }\n", - "\n", - " const force = true;\n", - "\n", - " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n", - " root._bokeh_onload_callbacks = [];\n", - " root._bokeh_is_loading = undefined;\n", - " }\n", - "\n", - "const JS_MIME_TYPE = 'application/javascript';\n", - " const HTML_MIME_TYPE = 'text/html';\n", - " const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", - " const CLASS_NAME = 'output_bokeh rendered_html';\n", - "\n", - " /**\n", - " * Render data to the DOM node\n", - " */\n", - " function render(props, node) {\n", - " const script = document.createElement(\"script\");\n", - " node.appendChild(script);\n", - " }\n", - "\n", - " /**\n", - " * Handle when an output is cleared or removed\n", - " */\n", - " function handleClearOutput(event, handle) {\n", - " function drop(id) {\n", - " const view = Bokeh.index.get_by_id(id)\n", - " if (view != null) {\n", - " view.model.document.clear()\n", - " Bokeh.index.delete(view)\n", - " }\n", - " }\n", - "\n", - " const cell = handle.cell;\n", - "\n", - " const id = cell.output_area._bokeh_element_id;\n", - " const server_id = cell.output_area._bokeh_server_id;\n", - "\n", - " // Clean up Bokeh references\n", - " if (id != null) {\n", - " drop(id)\n", - " }\n", - "\n", - " if (server_id !== undefined) {\n", - " // Clean up Bokeh references\n", - " const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", - " cell.notebook.kernel.execute(cmd_clean, {\n", - " iopub: {\n", - " output: function(msg) {\n", - " const id = msg.content.text.trim()\n", - " drop(id)\n", - " }\n", - " }\n", - " });\n", - " // Destroy server and session\n", - " const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", - " cell.notebook.kernel.execute(cmd_destroy);\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Handle when a new output is added\n", - " */\n", - " function handleAddOutput(event, handle) {\n", - " const output_area = handle.output_area;\n", - " const output = handle.output;\n", - "\n", - " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", - " if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n", - " return\n", - " }\n", - "\n", - " const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", - "\n", - " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", - " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", - " // store reference to embed id on output_area\n", - " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", - " }\n", - " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", - " const bk_div = document.createElement(\"div\");\n", - " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", - " const script_attrs = bk_div.children[0].attributes;\n", - " for (let i = 0; i < script_attrs.length; i++) {\n", - " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", - " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n", - " }\n", - " // store reference to server id on output_area\n", - " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", - " }\n", - " }\n", - "\n", - " function register_renderer(events, OutputArea) {\n", - "\n", - " function append_mime(data, metadata, element) {\n", - " // create a DOM node to render to\n", - " const toinsert = this.create_output_subarea(\n", - " metadata,\n", - " CLASS_NAME,\n", - " EXEC_MIME_TYPE\n", - " );\n", - " this.keyboard_manager.register_events(toinsert);\n", - " // Render to node\n", - " const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", - " render(props, toinsert[toinsert.length - 1]);\n", - " element.append(toinsert);\n", - " return toinsert\n", - " }\n", - "\n", - " /* Handle when an output is cleared or removed */\n", - " events.on('clear_output.CodeCell', handleClearOutput);\n", - " events.on('delete.Cell', handleClearOutput);\n", - "\n", - " /* Handle when a new output is added */\n", - " events.on('output_added.OutputArea', handleAddOutput);\n", - "\n", - " /**\n", - " * Register the mime type and append_mime function with output_area\n", - " */\n", - " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", - " /* Is output safe? */\n", - " safe: true,\n", - " /* Index of renderer in `output_area.display_order` */\n", - " index: 0\n", - " });\n", - " }\n", - "\n", - " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", - " if (root.Jupyter !== undefined) {\n", - " const events = require('base/js/events');\n", - " const OutputArea = require('notebook/js/outputarea').OutputArea;\n", - "\n", - " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", - " register_renderer(events, OutputArea);\n", - " }\n", - " }\n", - " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", - " root._bokeh_timeout = Date.now() + 5000;\n", - " root._bokeh_failed_load = false;\n", - " }\n", - "\n", - " const NB_LOAD_WARNING = {'data': {'text/html':\n", - " \"
\\n\"+\n", - " \"

\\n\"+\n", - " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", - " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", - " \"

\\n\"+\n", - " \"
    \\n\"+\n", - " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", - " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", - " \"
\\n\"+\n", - " \"\\n\"+\n", - " \"from bokeh.resources import INLINE\\n\"+\n", - " \"output_notebook(resources=INLINE)\\n\"+\n", - " \"\\n\"+\n", - " \"
\"}};\n", - "\n", - " function display_loaded(error = null) {\n", - " const el = document.getElementById(null);\n", - " if (el != null) {\n", - " const html = (() => {\n", - " if (typeof root.Bokeh === \"undefined\") {\n", - " if (error == null) {\n", - " return \"BokehJS is loading ...\";\n", - " } else {\n", - " return \"BokehJS failed to load.\";\n", - " }\n", - " } else {\n", - " const prefix = `BokehJS ${root.Bokeh.version}`;\n", - " if (error == null) {\n", - " return `${prefix} successfully loaded.`;\n", - " } else {\n", - " return `${prefix} encountered errors while loading and may not function as expected.`;\n", - " }\n", - " }\n", - " })();\n", - " el.innerHTML = html;\n", - "\n", - " if (error != null) {\n", - " const wrapper = document.createElement(\"div\");\n", - " wrapper.style.overflow = \"auto\";\n", - " wrapper.style.height = \"5em\";\n", - " wrapper.style.resize = \"vertical\";\n", - " const content = document.createElement(\"div\");\n", - " content.style.fontFamily = \"monospace\";\n", - " content.style.whiteSpace = \"pre-wrap\";\n", - " content.style.backgroundColor = \"rgb(255, 221, 221)\";\n", - " content.textContent = error.stack ?? error.toString();\n", - " wrapper.append(content);\n", - " el.append(wrapper);\n", - " }\n", - " } else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(() => display_loaded(error), 100);\n", - " }\n", - " }\n", - "\n", - " function run_callbacks() {\n", - " try {\n", - " root._bokeh_onload_callbacks.forEach(function(callback) {\n", - " if (callback != null)\n", - " callback();\n", - " });\n", - " } finally {\n", - " delete root._bokeh_onload_callbacks\n", - " }\n", - " console.debug(\"Bokeh: all callbacks have finished\");\n", - " }\n", - "\n", - " function load_libs(css_urls, js_urls, callback) {\n", - " if (css_urls == null) css_urls = [];\n", - " if (js_urls == null) js_urls = [];\n", - "\n", - " root._bokeh_onload_callbacks.push(callback);\n", - " if (root._bokeh_is_loading > 0) {\n", - " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", - " return null;\n", - " }\n", - " if (js_urls == null || js_urls.length === 0) {\n", - " run_callbacks();\n", - " return null;\n", - " }\n", - " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", - " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", - "\n", - " function on_load() {\n", - " root._bokeh_is_loading--;\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", - " run_callbacks()\n", - " }\n", - " }\n", - "\n", - " function on_error(url) {\n", - " console.error(\"failed to load \" + url);\n", - " }\n", - "\n", - " for (let i = 0; i < css_urls.length; i++) {\n", - " const url = css_urls[i];\n", - " const element = document.createElement(\"link\");\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.rel = \"stylesheet\";\n", - " element.type = \"text/css\";\n", - " element.href = url;\n", - " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " for (let i = 0; i < js_urls.length; i++) {\n", - " const url = js_urls[i];\n", - " const element = document.createElement('script');\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.async = false;\n", - " element.src = url;\n", - " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", - " document.head.appendChild(element);\n", - " }\n", - " };\n", - "\n", - " function inject_raw_css(css) {\n", - " const element = document.createElement(\"style\");\n", - " element.appendChild(document.createTextNode(css));\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.1.min.js\"];\n", - " const css_urls = [];\n", - "\n", - " const inline_js = [ function(Bokeh) {\n", - " Bokeh.set_log_level(\"info\");\n", - " },\n", - "function(Bokeh) {\n", - " }\n", - " ];\n", - "\n", - " function run_inline_js() {\n", - " if (root.Bokeh !== undefined || force === true) {\n", - " try {\n", - " for (let i = 0; i < inline_js.length; i++) {\n", - " inline_js[i].call(root, root.Bokeh);\n", - " }\n", - "\n", - " } catch (error) {throw error;\n", - " }} else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(run_inline_js, 100);\n", - " } else if (!root._bokeh_failed_load) {\n", - " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", - " root._bokeh_failed_load = true;\n", - " } else if (force !== true) {\n", - " const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n", - " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", - " }\n", - " }\n", - "\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", - " run_inline_js();\n", - " } else {\n", - " load_libs(css_urls, js_urls, function() {\n", - " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", - " run_inline_js();\n", - " });\n", - " }\n", - "}(window));" - ], - "application/vnd.bokehjs_load.v0+json": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"
    \\n\"+\n \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n \"
  • use INLINE resources instead, as so:
  • \\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
MalariaGEN Af1 API client
\n", - " Please note that data are subject to terms of use,\n", - " for more information see \n", - " the MalariaGEN website or contact support@malariagen.net.\n", - " See also the Af1 API docs.\n", - "
\n", - " Storage URL\n", - " gs://vo_afun_release_master_us_central1/
\n", - " Data releases available\n", - " 1.0, 1.1, 1.2, 1.3, 1.4
\n", - " Results cache\n", - " None
\n", - " Cohorts analysis\n", - " 20240515
\n", - " Site filters analysis\n", - " dt_20200416
\n", - " Software version\n", - " malariagen_data 0.0.0
\n", - " Client location\n", - " England, United Kingdom
\n", - " " - ], - "text/plain": [ - "\n", - "Storage URL : gs://vo_afun_release_master_us_central1/\n", - "Data releases available : 1.0, 1.1, 1.2, 1.3, 1.4\n", - "Results cache : None\n", - "Cohorts analysis : 20240515\n", - "Site filters analysis : dt_20200416\n", - "Software version : malariagen_data 0.0.0\n", - "Client location : England, United Kingdom\n", - "---\n", - "Please note that data are subject to terms of use,\n", - "for more information see https://www.malariagen.net/data\n", - "or contact support@malariagen.net. For API documentation see \n", - "https://malariagen.github.io/malariagen-data-python/v0.0.0/Af1.html" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "af1 = malariagen_data.Af1(pre=True)\n", "af1" @@ -3122,731 +152,10 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "9d6bbf22", + "execution_count": null, + "id": "13", "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "window.igv=function(){\"use strict\";function e(e){return t(\"div\",e)}function t(e,t){const i=document.createElement(e);return t&&(t.class&&i.classList.add(t.class),t.id&&(i.id=t.id),t.style&&function(e,t){for(let i of Object.keys(t))e.style[i]=t[i]}(i,t.style)),i}function i(e){const t=getComputedStyle(e);\"none\"!==t.display&&(e._initialDisplay=t.display),e.style.display=\"none\"}function n(e){if(\"none\"===getComputedStyle(e).display){const t=e._initialDisplay||\"block\";e.style.display=t}}function r(e){if(e.type.startsWith(\"touch\")){const t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.pageX,y:e.pageY}}function s(){return(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}let o=(e,{clientX:t,clientY:i})=>{const{left:n,top:r,width:s,height:o}=e.getBoundingClientRect(),a=t-n,c=i-r;return{x:a,y:c,xNormalized:a/s,yNormalized:c/o,width:s,height:o}};function a(e,t){const{clientX:i,clientY:n}=e;return o(t,{clientX:i,clientY:n})}class c{constructor(){this.elem=t(\"div\",{class:\"igv-ui-panel-column\"})}add(t){if(t instanceof Node)this.elem.append(t);else if(\"object\"==typeof t)this.elem.append(t.elem);else{const i=e();i.innerHTML=t,this.elem.append(i),this.html=i}}}function l(e,t){return h(e,t)}function h(e,t){t=t||\"currentColor\";let i=d[e];i||(console.error(`No icon named: ${e}`),i=d.question);const n=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");n.setAttributeNS(null,\"viewBox\",\"0 0 \"+i[0]+\" \"+i[1]);const r=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");return r.setAttributeNS(null,\"fill\",t),r.setAttributeNS(null,\"d\",i[4]),n.appendChild(r),n}const d={check:[512,512,[],\"f00c\",\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\"],cog:[512,512,[],\"f013\",\"M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z\"],exclamation:[192,512,[],\"f12a\",\"M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z\"],\"exclamation-circle\":[512,512,[],\"f06a\",\"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],\"exclamation-triangle\":[576,512,[],\"f071\",\"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z\"],minus:[448,512,[],\"f068\",\"M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z\"],\"minus-circle\":[512,512,[],\"f056\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z\"],\"minus-square\":[448,512,[],\"f146\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z\"],plus:[448,512,[],\"f067\",\"M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z\"],\"plus-circle\":[512,512,[],\"f055\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],\"plus-square\":[448,512,[],\"f0fe\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z\"],question:[384,512,[],\"f128\",\"M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z\"],save:[448,512,[],\"f0c7\",\"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z\"],search:[512,512,[],\"f002\",\"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z\"],share:[512,512,[],\"f064\",\"M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z\"],spinner:[512,512,[],\"f110\",\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"],square:[448,512,[],\"f0c8\",\"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z\"],\"square-full\":[512,512,[],\"f45c\",\"M512 512H0V0h512v512z\"],times:[384,512,[],\"f00d\",\"M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z\"],\"times-circle\":[512,512,[],\"f057\",\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z\"],wrench:[512,512,[],\"f0ad\",\"M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z\"]};function u(e,t){var i=document.createElement(\"div\");e.appendChild(i),i.appendChild(l(\"times\")),i.addEventListener(\"click\",(function(e){e.preventDefault(),e.stopPropagation(),t()}))}let f;function p(e,t,i){t.addEventListener(\"mousedown\",function(e){e.stopPropagation(),e.preventDefault();const t=g.bind(this),n=m.bind(this),r=getComputedStyle(this),s=this.getBoundingClientRect();f={constraint:i,dragFunction:t,dragEndFunction:n,screenX:e.screenX,screenY:e.screenY,minDy:-s.top,minDx:-s.left,top:parseInt(r.top.replace(\"px\",\"\")),left:parseInt(r.left.replace(\"px\",\"\"))},document.addEventListener(\"mousemove\",t),document.addEventListener(\"mouseup\",n),document.addEventListener(\"mouseleave\",n),document.addEventListener(\"mouseexit\",n)}.bind(e))}function g(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=Math.max(f.minDx,e.screenX-f.screenX),i=Math.max(f.minDy,e.screenY-f.screenY),n=f.left+t,r=f.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function m(e){if(!f)return void console.error(\"No drag data!\");e.stopPropagation(),e.preventDefault();const t=f.dragFunction,i=f.dragEndFunction;document.removeEventListener(\"mousemove\",t),document.removeEventListener(\"mouseup\",i),document.removeEventListener(\"mouseleave\",i),document.removeEventListener(\"mouseexit\",i),f=void 0}class w{constructor({parent:t,label:n,content:r,okHandler:s,cancelHandler:o}){this.parent=t;const a=()=>{i(this.elem),\"function\"==typeof o&&o(this)};this.elem=e(),this.elem.classList.add(\"igv-ui-generic-dialog-container\",\"igv-ui-center-fixed\");const c=e({class:\"igv-ui-generic-dialog-header\"});if(this.elem.appendChild(c),u(c,a),n){const t=e({class:\"igv-ui-dialog-one-liner\"});this.elem.appendChild(t),t.innerHTML=n}r.elem.style.margin=\"16px\",this.elem.appendChild(r.elem),this.content=r;const l=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.elem.appendChild(l),this.ok=e(),l.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),l.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",this.callback=void 0,this.ok.addEventListener(\"click\",(e=>{i(this.elem),\"function\"==typeof s?s(this):this.callback&&\"function\"==typeof this.callback&&this.callback(this)})),this.cancel.addEventListener(\"click\",a),p(this.elem,c),this.elem.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation()}))}present(e,t){if(e.label&&this.label&&(this.label.textContent=e.label),e.html){this.content.html.innerHTML=e.html}if(e.text){this.content.html.innerText=e.text}e.value&&this.input&&(this.input.value=e.value),e.callback&&(this.callback=e.callback),n(this.elem)}clampLocation(e,t){let i=this.elem.getBoundingClientRect(),n=this.parent.getBoundingClientRect();const r=Math.min(Math.max(t,n.y),n.y+n.height-i.height),s=Math.min(Math.max(e,n.x),n.x+n.width-i.width);this.elem.style.left=s+\"px\",this.elem.style.top=r+\"px\"}}\n", - "/*!\n", - " * jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\n", - " * https://jquery.com/\n", - " *\n", - " * Includes Sizzle.js\n", - " * https://sizzlejs.com/\n", - " *\n", - " * Copyright JS Foundation and other contributors\n", - " * Released under the MIT license\n", - " * https://jquery.org/license\n", - " *\n", - " * Date: 2018-01-20T17:24Z\n", - " */var b=[],F=window.document,v=Object.getPrototypeOf,y=b.slice,A=b.concat,C=b.push,_=b.indexOf,x={},k=x.toString,I=x.hasOwnProperty,S=I.toString,E=S.call(Object),N={},B=function(e){return\"function\"==typeof e&&\"number\"!=typeof e.nodeType},M=function(e){return null!=e&&e===e.window},R={type:!0,src:!0,noModule:!0};function D(e,t,i){var n,r=(t=t||F).createElement(\"script\");if(r.text=e,i)for(n in R)i[n]&&(r[n]=i[n]);t.head.appendChild(r).parentNode.removeChild(r)}function T(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?x[k.call(e)]||\"object\":typeof e}var L=\"3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector\",z=function(e,t){return new z.fn.init(e,t)},H=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;function P(e){var t=!!e&&\"length\"in e&&e.length,i=T(e);return!B(e)&&!M(e)&&(\"array\"===i||0===t||\"number\"==typeof t&&t>0&&t-1 in e)}z.fn=z.prototype={jquery:L,constructor:z,length:0,toArray:function(){return y.call(this)},get:function(e){return null==e?y.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=z.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return z.each(this,e)},map:function(e){return this.pushStack(z.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(y.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i+~]|\"+L+\")\"+L+\"*\"),V=new RegExp(\"=\"+L+\"*([^\\\\]'\\\"]*?)\"+L+\"*\\\\]\",\"g\"),j=new RegExp(P),W=new RegExp(\"^\"+z+\"$\"),G={ID:new RegExp(\"^#(\"+z+\")\"),CLASS:new RegExp(\"^\\\\.(\"+z+\")\"),TAG:new RegExp(\"^(\"+z+\"|[*])\"),ATTR:new RegExp(\"^\"+H),PSEUDO:new RegExp(\"^\"+P),CHILD:new RegExp(\"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\"+L+\"*(even|odd|(([+-]|)(\\\\d*)n|)\"+L+\"*(?:([+-]|)\"+L+\"*(\\\\d+)|))\"+L+\"*\\\\)|)\",\"i\"),bool:new RegExp(\"^(?:\"+T+\")$\",\"i\"),needsContext:new RegExp(\"^\"+L+\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\"+L+\"*((?:-\\\\d)?\\\\d*)\"+L+\"*\\\\)|)(?=[^-]|$)\",\"i\")},$=/^(?:input|select|textarea|button)$/i,K=/^h\\d$/i,Y=/^[^{]+\\{\\s*\\[native \\w/,X=/^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,Z=/[+~]/,J=new RegExp(\"\\\\\\\\([\\\\da-f]{1,6}\"+L+\"?|(\"+L+\")|.)\",\"ig\"),ee=function(e,t,i){var n=\"0x\"+t-65536;return n!=n||i?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},te=/([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\0-\\x1f\\x7f-\\uFFFF\\w-]/g,ie=function(e,t){return t?\"\\0\"===e?\"�\":e.slice(0,-1)+\"\\\\\"+e.charCodeAt(e.length-1).toString(16)+\" \":\"\\\\\"+e},ne=function(){u()},re=we((function(e){return!0===e.disabled&&(\"form\"in e||\"label\"in e)}),{dir:\"parentNode\",next:\"legend\"});try{M.apply(E=R.call(y.childNodes),y.childNodes),E[y.childNodes.length].nodeType}catch(e){M={apply:E.length?function(e,t){B.apply(e,R.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function se(e,t,n,r){var s,a,l,h,d,p,w,b=t&&t.ownerDocument,A=t?t.nodeType:9;if(n=n||[],\"string\"!=typeof e||!e||1!==A&&9!==A&&11!==A)return n;if(!r&&((t?t.ownerDocument||t:y)!==f&&u(t),t=t||f,g)){if(11!==A&&(d=X.exec(e)))if(s=d[1]){if(9===A){if(!(l=t.getElementById(s)))return n;if(l.id===s)return n.push(l),n}else if(b&&(l=b.getElementById(s))&&F(t,l)&&l.id===s)return n.push(l),n}else{if(d[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=d[3])&&i.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(i.qsa&&!k[e+\" \"]&&(!m||!m.test(e))){if(1!==A)b=t,w=e;else if(\"object\"!==t.nodeName.toLowerCase()){for((h=t.getAttribute(\"id\"))?h=h.replace(te,ie):t.setAttribute(\"id\",h=v),a=(p=o(e)).length;a--;)p[a]=\"#\"+h+\" \"+me(p[a]);w=p.join(\",\"),b=Z.test(e)&&pe(t.parentNode)||t}if(w)try{return M.apply(n,b.querySelectorAll(w)),n}catch(e){}finally{h===v&&t.removeAttribute(\"id\")}}}return c(e.replace(U,\"$1\"),t,n,r)}function oe(){var e=[];return function t(i,r){return e.push(i+\" \")>n.cacheLength&&delete t[e.shift()],t[i+\" \"]=r}}function ae(e){return e[v]=!0,e}function ce(e){var t=f.createElement(\"fieldset\");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function he(e){return function(t){return\"input\"===t.nodeName.toLowerCase()&&t.type===e}}function de(e){return function(t){var i=t.nodeName.toLowerCase();return(\"input\"===i||\"button\"===i)&&t.type===e}}function ue(e){return function(t){return\"form\"in t?t.parentNode&&!1===t.disabled?\"label\"in t?\"label\"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:\"label\"in t&&t.disabled===e}}function fe(e){return ae((function(t){return t=+t,ae((function(i,n){for(var r,s=e([],i.length,t),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=se.support={},s=se.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&\"HTML\"!==t.nodeName},u=se.setDocument=function(e){var t,r,o=e?e.ownerDocument||e:y;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),y!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener(\"unload\",ne,!1):r.attachEvent&&r.attachEvent(\"onunload\",ne)),i.attributes=ce((function(e){return e.className=\"i\",!e.getAttribute(\"className\")})),i.getElementsByTagName=ce((function(e){return e.appendChild(f.createComment(\"\")),!e.getElementsByTagName(\"*\").length})),i.getElementsByClassName=Y.test(f.getElementsByClassName),i.getById=ce((function(e){return p.appendChild(e).id=v,!f.getElementsByName||!f.getElementsByName(v).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){return e.getAttribute(\"id\")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode(\"id\");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,r,s=t.getElementById(e);if(s){if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s];for(r=t.getElementsByName(e),n=0;s=r[n++];)if((i=s.getAttributeNode(\"id\"))&&i.value===e)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],r=0,s=t.getElementsByTagName(e);if(\"*\"===e){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},w=[],m=[],(i.qsa=Y.test(f.querySelectorAll))&&(ce((function(e){p.appendChild(e).innerHTML=\"\",e.querySelectorAll(\"[msallowcapture^='']\").length&&m.push(\"[*^$]=\"+L+\"*(?:''|\\\"\\\")\"),e.querySelectorAll(\"[selected]\").length||m.push(\"\\\\[\"+L+\"*(?:value|\"+T+\")\"),e.querySelectorAll(\"[id~=\"+v+\"-]\").length||m.push(\"~=\"),e.querySelectorAll(\":checked\").length||m.push(\":checked\"),e.querySelectorAll(\"a#\"+v+\"+*\").length||m.push(\".#.+[+~]\")})),ce((function(e){e.innerHTML=\"\";var t=f.createElement(\"input\");t.setAttribute(\"type\",\"hidden\"),e.appendChild(t).setAttribute(\"name\",\"D\"),e.querySelectorAll(\"[name=d]\").length&&m.push(\"name\"+L+\"*[*^$|!~]?=\"),2!==e.querySelectorAll(\":enabled\").length&&m.push(\":enabled\",\":disabled\"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(\":disabled\").length&&m.push(\":enabled\",\":disabled\"),e.querySelectorAll(\"*,:x\"),m.push(\",.*:\")}))),(i.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ce((function(e){i.disconnectedMatch=b.call(e,\"*\"),b.call(e,\"[s!='']:x\"),w.push(\"!=\",P)})),m=m.length&&new RegExp(m.join(\"|\")),w=w.length&&new RegExp(w.join(\"|\")),t=Y.test(p.compareDocumentPosition),F=t||Y.test(p.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},I=t?function(e,t){if(e===t)return d=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e===f||e.ownerDocument===y&&F(y,e)?-1:t===f||t.ownerDocument===y&&F(y,t)?1:h?D(h,e)-D(h,t):0:4&n?-1:1)}:function(e,t){if(e===t)return d=!0,0;var i,n=0,r=e.parentNode,s=t.parentNode,o=[e],a=[t];if(!r||!s)return e===f?-1:t===f?1:r?-1:s?1:h?D(h,e)-D(h,t):0;if(r===s)return le(e,t);for(i=e;i=i.parentNode;)o.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?le(o[n],a[n]):o[n]===y?-1:a[n]===y?1:0},f):f},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&u(e),t=t.replace(V,\"='$1']\"),i.matchesSelector&&g&&!k[t+\" \"]&&(!w||!w.test(t))&&(!m||!m.test(t)))try{var n=b.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return se(t,f,null,[e]).length>0},se.contains=function(e,t){return(e.ownerDocument||e)!==f&&u(e),F(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!==f&&u(e);var r=n.attrHandle[t.toLowerCase()],s=r&&S.call(n.attrHandle,t.toLowerCase())?r(e,t,!g):void 0;return void 0!==s?s:i.attributes||!g?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},se.escape=function(e){return(e+\"\").replace(te,ie)},se.error=function(e){throw new Error(\"Syntax error, unrecognized expression: \"+e)},se.uniqueSort=function(e){var t,n=[],r=0,s=0;if(d=!i.detectDuplicates,h=!i.sortStable&&e.slice(0),e.sort(I),d){for(;t=e[s++];)t===e[s]&&(r=n.push(s));for(;r--;)e.splice(n[r],1)}return h=null,e},r=se.getText=function(e){var t,i=\"\",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if(\"string\"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=r(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n++];)i+=r(t);return i},n=se.selectors={cacheLength:50,createPseudo:ae,match:G,attrHandle:{},find:{},relative:{\">\":{dir:\"parentNode\",first:!0},\" \":{dir:\"parentNode\"},\"+\":{dir:\"previousSibling\",first:!0},\"~\":{dir:\"previousSibling\"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(J,ee),e[3]=(e[3]||e[4]||e[5]||\"\").replace(J,ee),\"~=\"===e[2]&&(e[3]=\" \"+e[3]+\" \"),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),\"nth\"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(\"even\"===e[3]||\"odd\"===e[3])),e[5]=+(e[7]+e[8]||\"odd\"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||\"\":i&&j.test(i)&&(t=o(i,!0))&&(t=i.indexOf(\")\",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(J,ee).toLowerCase();return\"*\"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=_[e+\" \"];return t||(t=new RegExp(\"(^|\"+L+\")\"+e+\"(\"+L+\"|$)\"))&&_(e,(function(e){return t.test(\"string\"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute(\"class\")||\"\")}))},ATTR:function(e,t,i){return function(n){var r=se.attr(n,e);return null==r?\"!=\"===t:!t||(r+=\"\",\"=\"===t?r===i:\"!=\"===t?r!==i:\"^=\"===t?i&&0===r.indexOf(i):\"*=\"===t?i&&r.indexOf(i)>-1:\"$=\"===t?i&&r.slice(-i.length)===i:\"~=\"===t?(\" \"+r.replace(O,\" \")+\" \").indexOf(i)>-1:\"|=\"===t&&(r===i||r.slice(0,i.length+1)===i+\"-\"))}},CHILD:function(e,t,i,n,r){var s=\"nth\"!==e.slice(0,3),o=\"last\"!==e.slice(-4),a=\"of-type\"===t;return 1===n&&0===r?function(e){return!!e.parentNode}:function(t,i,c){var l,h,d,u,f,p,g=s!==o?\"nextSibling\":\"previousSibling\",m=t.parentNode,w=a&&t.nodeName.toLowerCase(),b=!c&&!a,F=!1;if(m){if(s){for(;g;){for(u=t;u=u[g];)if(a?u.nodeName.toLowerCase()===w:1===u.nodeType)return!1;p=g=\"only\"===e&&!p&&\"nextSibling\"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&b){for(F=(f=(l=(h=(d=(u=m)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1])&&l[2],u=f&&m.childNodes[f];u=++f&&u&&u[g]||(F=f=0)||p.pop();)if(1===u.nodeType&&++F&&u===t){h[e]=[A,f,F];break}}else if(b&&(F=f=(l=(h=(d=(u=t)[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===A&&l[1]),!1===F)for(;(u=++f&&u&&u[g]||(F=f=0)||p.pop())&&((a?u.nodeName.toLowerCase()!==w:1!==u.nodeType)||!++F||(b&&((h=(d=u[v]||(u[v]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]=[A,F]),u!==t)););return(F-=r)===n||F%n==0&&F/n>=0}}},PSEUDO:function(e,t){var i,r=n.pseudos[e]||n.setFilters[e.toLowerCase()]||se.error(\"unsupported pseudo: \"+e);return r[v]?r(t):r.length>1?(i=[e,e,\"\",t],n.setFilters.hasOwnProperty(e.toLowerCase())?ae((function(e,i){for(var n,s=r(e,t),o=s.length;o--;)e[n=D(e,s[o])]=!(i[n]=s[o])})):function(e){return r(e,0,i)}):r}},pseudos:{not:ae((function(e){var t=[],i=[],n=a(e.replace(U,\"$1\"));return n[v]?ae((function(e,t,i,r){for(var s,o=n(e,null,r,[]),a=e.length;a--;)(s=o[a])&&(e[a]=!(t[a]=s))})):function(e,r,s){return t[0]=e,n(t,null,s,i),t[0]=null,!i.pop()}})),has:ae((function(e){return function(t){return se(e,t).length>0}})),contains:ae((function(e){return e=e.replace(J,ee),function(t){return(t.textContent||t.innerText||r(t)).indexOf(e)>-1}})),lang:ae((function(e){return W.test(e||\"\")||se.error(\"unsupported lang: \"+e),e=e.replace(J,ee).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute(\"xml:lang\")||t.getAttribute(\"lang\"))return(i=i.toLowerCase())===e||0===i.indexOf(e+\"-\")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ue(!1),disabled:ue(!0),checked:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&!!e.checked||\"option\"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return $.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&\"button\"===e.type||\"button\"===t},text:function(e){var t;return\"input\"===e.nodeName.toLowerCase()&&\"text\"===e.type&&(null==(t=e.getAttribute(\"type\"))||\"text\"===t.toLowerCase())},first:fe((function(){return[0]})),last:fe((function(e,t){return[t-1]})),eq:fe((function(e,t,i){return[i<0?i+t:i]})),even:fe((function(e,t){for(var i=0;i=0;)e.push(n);return e})),gt:fe((function(e,t,i){for(var n=i<0?i+t:i;++n1?function(t,i,n){for(var r=e.length;r--;)if(!e[r](t,i,n))return!1;return!0}:e[0]}function Fe(e,t,i,n,r){for(var s,o=[],a=0,c=e.length,l=null!=t;a-1&&(s[l]=!(o[l]=d))}}else w=Fe(w===o?w.splice(p,w.length):w),r?r(null,o,w,c):M.apply(o,w)}))}function ye(e){for(var t,i,r,s=e.length,o=n.relative[e[0].type],a=o||n.relative[\" \"],c=o?1:0,h=we((function(e){return e===t}),a,!0),d=we((function(e){return D(t,e)>-1}),a,!0),u=[function(e,i,n){var r=!o&&(n||i!==l)||((t=i).nodeType?h(e,i,n):d(e,i,n));return t=null,r}];c1&&be(u),c>1&&me(e.slice(0,c-1).concat({value:\" \"===e[c-2].type?\"*\":\"\"})).replace(U,\"$1\"),i,c0,r=e.length>0,s=function(s,o,a,c,h){var d,p,m,w=0,b=\"0\",F=s&&[],v=[],y=l,C=s||r&&n.find.TAG(\"*\",h),_=A+=null==y?1:Math.random()||.1,x=C.length;for(h&&(l=o===f||o||h);b!==x&&null!=(d=C[b]);b++){if(r&&d){for(p=0,o||d.ownerDocument===f||(u(d),a=!g);m=e[p++];)if(m(d,o||f,a)){c.push(d);break}h&&(A=_)}i&&((d=!m&&d)&&w--,s&&F.push(d))}if(w+=b,i&&b!==w){for(p=0;m=t[p++];)m(F,v,o,a);if(s){if(w>0)for(;b--;)F[b]||v[b]||(v[b]=N.call(c));v=Fe(v)}M.apply(c,v),h&&!s&&v.length>0&&w+t.length>1&&se.uniqueSort(c)}return h&&(A=_,l=y),F};return i?ae(s):s}(s,r)),a.selector=e}return a},c=se.select=function(e,t,i,r){var s,c,l,h,d,u=\"function\"==typeof e&&e,f=!r&&o(e=u.selector||e);if(i=i||[],1===f.length){if((c=f[0]=f[0].slice(0)).length>2&&\"ID\"===(l=c[0]).type&&9===t.nodeType&&g&&n.relative[c[1].type]){if(!(t=(n.find.ID(l.matches[0].replace(J,ee),t)||[])[0]))return i;u&&(t=t.parentNode),e=e.slice(c.shift().value.length)}for(s=G.needsContext.test(e)?0:c.length;s--&&(l=c[s],!n.relative[h=l.type]);)if((d=n.find[h])&&(r=d(l.matches[0].replace(J,ee),Z.test(c[0].type)&&pe(t.parentNode)||t))){if(c.splice(s,1),!(e=r.length&&me(c)))return M.apply(i,r),i;break}}return(u||a(e,f))(r,t,!g,i,!t||Z.test(e)&&pe(t.parentNode)||t),i},i.sortStable=v.split(\"\").sort(I).join(\"\")===v,i.detectDuplicates=!!d,u(),se}(window);z.find=O,z.expr=O.selectors,z.expr[\":\"]=z.expr.pseudos,z.uniqueSort=z.unique=O.uniqueSort,z.text=O.getText,z.isXMLDoc=O.isXML,z.contains=O.contains,z.escapeSelector=O.escape;var U=function(e,t,i){for(var n=[],r=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&z(e).is(i))break;n.push(e)}return n},q=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},Q=z.expr.match.needsContext;function V(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var j=/^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i;function W(e,t,i){return B(t)?z.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?z.grep(e,(function(e){return e===t!==i})):\"string\"!=typeof t?z.grep(e,(function(e){return _.call(t,e)>-1!==i})):z.filter(t,e,i)}z.filter=function(e,t,i){var n=t[0];return i&&(e=\":not(\"+e+\")\"),1===t.length&&1===n.nodeType?z.find.matchesSelector(n,e)?[n]:[]:z.find.matches(e,z.grep(t,(function(e){return 1===e.nodeType})))},z.fn.extend({find:function(e){var t,i,n=this.length,r=this;if(\"string\"!=typeof e)return this.pushStack(z(e).filter((function(){for(t=0;t1?z.uniqueSort(i):i},filter:function(e){return this.pushStack(W(this,e||[],!1))},not:function(e){return this.pushStack(W(this,e||[],!0))},is:function(e){return!!W(this,\"string\"==typeof e&&Q.test(e)?z(e):e||[],!1).length}});var G,$=/^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/;(z.fn.init=function(e,t,i){var n,r;if(!e)return this;if(i=i||G,\"string\"==typeof e){if(!(n=\"<\"===e[0]&&\">\"===e[e.length-1]&&e.length>=3?[null,e,null]:$.exec(e))||!n[1]&&t)return!t||t.jquery?(t||i).find(e):this.constructor(t).find(e);if(n[1]){if(t=t instanceof z?t[0]:t,z.merge(this,z.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:F,!0)),j.test(n[1])&&z.isPlainObject(t))for(n in t)B(this[n])?this[n](t[n]):this.attr(n,t[n]);return this}return(r=F.getElementById(n[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):B(e)?void 0!==i.ready?i.ready(e):e(z):z.makeArray(e,this)}).prototype=z.fn,G=z(F);var K=/^(?:parents|prev(?:Until|All))/,Y={children:!0,contents:!0,next:!0,prev:!0};function X(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}z.fn.extend({has:function(e){var t=z(e,this),i=t.length;return this.filter((function(){for(var e=0;e-1:1===i.nodeType&&z.find.matchesSelector(i,e))){s.push(i);break}return this.pushStack(s.length>1?z.uniqueSort(s):s)},index:function(e){return e?\"string\"==typeof e?_.call(z(e),this[0]):_.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(z.uniqueSort(z.merge(this.get(),z(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),z.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return U(e,\"parentNode\")},parentsUntil:function(e,t,i){return U(e,\"parentNode\",i)},next:function(e){return X(e,\"nextSibling\")},prev:function(e){return X(e,\"previousSibling\")},nextAll:function(e){return U(e,\"nextSibling\")},prevAll:function(e){return U(e,\"previousSibling\")},nextUntil:function(e,t,i){return U(e,\"nextSibling\",i)},prevUntil:function(e,t,i){return U(e,\"previousSibling\",i)},siblings:function(e){return q((e.parentNode||{}).firstChild,e)},children:function(e){return q(e.firstChild)},contents:function(e){return V(e,\"iframe\")?e.contentDocument:(V(e,\"template\")&&(e=e.content||e),z.merge([],e.childNodes))}},(function(e,t){z.fn[e]=function(i,n){var r=z.map(this,t,i);return\"Until\"!==e.slice(-5)&&(n=i),n&&\"string\"==typeof n&&(r=z.filter(n,r)),this.length>1&&(Y[e]||z.uniqueSort(r),K.test(e)&&r.reverse()),this.pushStack(r)}}));var Z=/[^\\x20\\t\\r\\n\\f]+/g;function J(e){return e}function ee(e){throw e}function te(e,t,i,n){var r;try{e&&B(r=e.promise)?r.call(e).done(t).fail(i):e&&B(r=e.then)?r.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}z.Callbacks=function(e){e=\"string\"==typeof e?function(e){var t={};return z.each(e.match(Z)||[],(function(e,i){t[i]=!0})),t}(e):z.extend({},e);var t,i,n,r,s=[],o=[],a=-1,c=function(){for(r=r||e.once,n=t=!0;o.length;a=-1)for(i=o.shift();++a-1;)s.splice(i,1),i<=a&&a--})),this},has:function(e){return e?z.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i=\"\",this},disabled:function(){return!s},lock:function(){return r=o=[],i||t||(s=i=\"\"),this},locked:function(){return!!r},fireWith:function(e,i){return r||(i=[e,(i=i||[]).slice?i.slice():i],o.push(i),t||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!n}};return l},z.extend({Deferred:function(e){var t=[[\"notify\",\"progress\",z.Callbacks(\"memory\"),z.Callbacks(\"memory\"),2],[\"resolve\",\"done\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),0,\"resolved\"],[\"reject\",\"fail\",z.Callbacks(\"once memory\"),z.Callbacks(\"once memory\"),1,\"rejected\"]],i=\"pending\",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return z.Deferred((function(i){z.each(t,(function(t,n){var s=B(e[n[4]])&&e[n[4]];r[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&B(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+\"With\"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,n){var r=0;function s(e,t,i,n){return function(){var o=this,a=arguments,c=function(){var c,l;if(!(e=r&&(i!==ee&&(o=void 0,a=[n]),t.rejectWith(o,a))}};e?l():(z.Deferred.getStackHook&&(l.stackTrace=z.Deferred.getStackHook()),window.setTimeout(l))}}return z.Deferred((function(r){t[0][3].add(s(0,r,B(n)?n:J,r.notifyWith)),t[1][3].add(s(0,r,B(e)?e:J)),t[2][3].add(s(0,r,B(i)?i:ee))})).promise()},promise:function(e){return null!=e?z.extend(e,n):n}},r={};return z.each(t,(function(e,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+\"With\"](this===r?void 0:this,arguments),this},r[s[0]+\"With\"]=o.fireWith})),n.promise(r),e&&e.call(r,r),r},when:function(e){var t=arguments.length,i=t,n=Array(i),r=y.call(arguments),s=z.Deferred(),o=function(e){return function(i){n[e]=this,r[e]=arguments.length>1?y.call(arguments):i,--t||s.resolveWith(n,r)}};if(t<=1&&(te(e,s.done(o(i)).resolve,s.reject,!t),\"pending\"===s.state()||B(r[i]&&r[i].then)))return s.then();for(;i--;)te(r[i],o(i),s.reject);return s.promise()}});var ie=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;z.Deferred.exceptionHook=function(e,t){window.console&&window.console.warn&&e&&ie.test(e.name)&&window.console.warn(\"jQuery.Deferred exception: \"+e.message,e.stack,t)},z.readyException=function(e){window.setTimeout((function(){throw e}))};var ne=z.Deferred();function re(){F.removeEventListener(\"DOMContentLoaded\",re),window.removeEventListener(\"load\",re),z.ready()}z.fn.ready=function(e){return ne.then(e).catch((function(e){z.readyException(e)})),this},z.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--z.readyWait:z.isReady)||(z.isReady=!0,!0!==e&&--z.readyWait>0||ne.resolveWith(F,[z]))}}),z.ready.then=ne.then,\"complete\"===F.readyState||\"loading\"!==F.readyState&&!F.documentElement.doScroll?window.setTimeout(z.ready):(F.addEventListener(\"DOMContentLoaded\",re),window.addEventListener(\"load\",re));var se=function(e,t,i,n,r,s,o){var a=0,c=e.length,l=null==i;if(\"object\"===T(i))for(a in r=!0,i)se(e,t,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,B(n)||(o=!0),l&&(o?(t.call(e,n),t=null):(l=t,t=function(e,t,i){return l.call(z(e),i)})),t))for(;a1,null,!0)},removeData:function(e){return this.each((function(){fe.remove(this,e)}))}}),z.extend({queue:function(e,t,i){var n;if(e)return t=(t||\"fx\")+\"queue\",n=ue.get(e,t),i&&(!n||Array.isArray(i)?n=ue.access(e,t,z.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||\"fx\";var i=z.queue(e,t),n=i.length,r=i.shift(),s=z._queueHooks(e,t);\"inprogress\"===r&&(r=i.shift(),n--),r&&(\"fx\"===t&&i.unshift(\"inprogress\"),delete s.stop,r.call(e,(function(){z.dequeue(e,t)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(e,t){var i=t+\"queueHooks\";return ue.get(e,i)||ue.access(e,i,{empty:z.Callbacks(\"once memory\").add((function(){ue.remove(e,[t+\"queue\",i])}))})}}),z.fn.extend({queue:function(e,t){var i=2;return\"string\"!=typeof e&&(t=e,e=\"fx\",i--),arguments.length\\x20\\t\\r\\n\\f]+)/i,Ie=/^$|^module$|\\/(?:java|ecma)script/i,Se={option:[1,\"\"],thead:[1,\"\",\"
\"],col:[2,\"\",\"
\"],tr:[2,\"\",\"
\"],td:[3,\"\",\"
\"],_default:[0,\"\",\"\"]};function Ee(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||\"*\"):void 0!==e.querySelectorAll?e.querySelectorAll(t||\"*\"):[],void 0===t||t&&V(e,t)?z.merge([e],i):i}function Ne(e,t){for(var i=0,n=e.length;i-1)r&&r.push(s);else if(l=z.contains(s.ownerDocument,s),o=Ee(d.appendChild(s),\"script\"),l&&Ne(o),i)for(h=0;s=o[h++];)Ie.test(s.type||\"\")&&i.push(s);return d}!function(){var e=F.createDocumentFragment().appendChild(F.createElement(\"div\")),t=F.createElement(\"input\");t.setAttribute(\"type\",\"radio\"),t.setAttribute(\"checked\",\"checked\"),t.setAttribute(\"name\",\"t\"),e.appendChild(t),N.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML=\"\",N.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var Re=F.documentElement,De=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Le=/^([^.]*)(?:\\.(.+)|)/;function ze(){return!0}function He(){return!1}function Pe(){try{return F.activeElement}catch(e){}}function Oe(e,t,i,n,r,s){var o,a;if(\"object\"==typeof t){for(a in\"string\"!=typeof i&&(n=n||i,i=void 0),t)Oe(e,a,i,n,t[a],s);return e}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&(\"string\"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=He;else if(!r)return e;return 1===s&&(o=r,r=function(e){return z().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=z.guid++)),e.each((function(){z.event.add(this,t,r,n,i)}))}z.event={global:{},add:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.get(e);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&z.find.matchesSelector(Re,r),i.guid||(i.guid=z.guid++),(c=m.events)||(c=m.events={}),(o=m.handle)||(o=m.handle=function(t){return void 0!==z&&z.event.triggered!==t.type?z.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f&&(d=z.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,d=z.event.special[f]||{},h=z.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&z.expr.match.needsContext.test(r),namespace:p.join(\".\")},s),(u=c[f])||((u=c[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,n,p,o)||e.addEventListener&&e.addEventListener(f,o)),d.add&&(d.add.call(e,h),h.handler.guid||(h.handler.guid=i.guid)),r?u.splice(u.delegateCount++,0,h):u.push(h),z.event.global[f]=!0)},remove:function(e,t,i,n,r){var s,o,a,c,l,h,d,u,f,p,g,m=ue.hasData(e)&&ue.get(e);if(m&&(c=m.events)){for(l=(t=(t||\"\").match(Z)||[\"\"]).length;l--;)if(f=g=(a=Le.exec(t[l])||[])[1],p=(a[2]||\"\").split(\".\").sort(),f){for(d=z.event.special[f]||{},u=c[f=(n?d.delegateType:d.bindType)||f]||[],a=a[2]&&new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"),o=s=u.length;s--;)h=u[s],!r&&g!==h.origType||i&&i.guid!==h.guid||a&&!a.test(h.namespace)||n&&n!==h.selector&&(\"**\"!==n||!h.selector)||(u.splice(s,1),h.selector&&u.delegateCount--,d.remove&&d.remove.call(e,h));o&&!u.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||z.removeEvent(e,f,m.handle),delete c[f])}else for(f in c)z.event.remove(e,f+t[l],i,n,!0);z.isEmptyObject(c)&&ue.remove(e,\"handle events\")}},dispatch:function(e){var t,i,n,r,s,o,a=z.event.fix(e),c=new Array(arguments.length),l=(ue.get(this,\"events\")||{})[a.type]||[],h=z.event.special[a.type]||{};for(c[0]=a,t=1;t=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&(\"click\"!==e.type||!0!==l.disabled)){for(s=[],o={},i=0;i-1:z.find(r,this,null,[l]).length),o[r]&&s.push(n);s.length&&a.push({elem:l,handlers:s})}return l=this,c\\x20\\t\\r\\n\\f]*)[^>]*)\\/>/gi,qe=/\\s*$/g;function je(e,t){return V(e,\"table\")&&V(11!==t.nodeType?t:t.firstChild,\"tr\")&&z(e).children(\"tbody\")[0]||e}function We(e){return e.type=(null!==e.getAttribute(\"type\"))+\"/\"+e.type,e}function Ge(e){return\"true/\"===(e.type||\"\").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute(\"type\"),e}function $e(e,t){var i,n,r,s,o,a,c,l;if(1===t.nodeType){if(ue.hasData(e)&&(s=ue.access(e),o=ue.set(t,s),l=s.events))for(r in delete o.handle,o.events={},l)for(i=0,n=l[r].length;i1&&\"string\"==typeof f&&!N.checkClone&&Qe.test(f))return e.each((function(r){var s=e.eq(r);p&&(t[0]=f.call(this,r,s.html())),Ye(s,t,i,n)}));if(d&&(s=(r=Me(t,e[0].ownerDocument,!1,e,n)).firstChild,1===r.childNodes.length&&(r=s),s||n)){for(a=(o=z.map(Ee(r,\"script\"),We)).length;h\")},clone:function(e,t,i){var n,r,s,o,a=e.cloneNode(!0),c=z.contains(e.ownerDocument,e);if(!(N.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||z.isXMLDoc(e)))for(o=Ee(a),n=0,r=(s=Ee(e)).length;n0&&Ne(o,!c&&Ee(e,\"script\")),a},cleanData:function(e){for(var t,i,n,r=z.event.special,s=0;void 0!==(i=e[s]);s++)if(he(i)){if(t=i[ue.expando]){if(t.events)for(n in t.events)r[n]?z.event.remove(i,n):z.removeEvent(i,n,t.handle);i[ue.expando]=void 0}i[fe.expando]&&(i[fe.expando]=void 0)}}}),z.fn.extend({detach:function(e){return Xe(this,e,!0)},remove:function(e){return Xe(this,e)},text:function(e){return se(this,(function(e){return void 0===e?z.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ye(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)}))},prepend:function(){return Ye(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ye(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(z.cleanData(Ee(e,!1)),e.textContent=\"\");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return z.clone(this,e,t)}))},html:function(e){return se(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if(\"string\"==typeof e&&!qe.test(e)&&!Se[(ke.exec(e)||[\"\",\"\"])[1].toLowerCase()]){e=z.htmlPrefilter(e);try{for(;i=0&&(c+=Math.max(0,Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-s-c-a-.5))),c}function pt(e,t,i){var n=Je(e),r=tt(e,t,n),s=\"border-box\"===z.css(e,\"boxSizing\",!1,n),o=s;if(Ze.test(r)){if(!i)return r;r=\"auto\"}return o=o&&(N.boxSizingReliable()||r===e.style[t]),(\"auto\"===r||!parseFloat(r)&&\"inline\"===z.css(e,\"display\",!1,n))&&(r=e[\"offset\"+t[0].toUpperCase()+t.slice(1)],o=!0),(r=parseFloat(r)||0)+ft(e,t,i||(s?\"border\":\"content\"),o,n,r)+\"px\"}z.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=tt(e,\"opacity\");return\"\"===i?\"1\":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,s,o,a=le(t),c=ot.test(t),l=e.style;if(c||(t=dt(a)),o=z.cssHooks[t]||z.cssHooks[a],void 0===i)return o&&\"get\"in o&&void 0!==(r=o.get(e,!1,n))?r:l[t];\"string\"===(s=typeof i)&&(r=be.exec(i))&&r[1]&&(i=function(e,t,i,n){var r,s,o=20,a=n?function(){return n.cur()}:function(){return z.css(e,t,\"\")},c=a(),l=i&&i[3]||(z.cssNumber[t]?\"\":\"px\"),h=(z.cssNumber[t]||\"px\"!==l&&+c)&&be.exec(z.css(e,t));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;o--;)z.style(e,t,h+l),(1-s)*(1-(s=a()/c||.5))<=0&&(o=0),h/=s;h*=2,z.style(e,t,h+l),i=i||[]}return i&&(h=+h||+c||0,r=i[1]?h+(i[1]+1)*i[2]:+i[2],n&&(n.unit=l,n.start=h,n.end=r)),r}(e,t,r),s=\"number\"),null!=i&&i==i&&(\"number\"===s&&(i+=r&&r[3]||(z.cssNumber[a]?\"\":\"px\")),N.clearCloneStyle||\"\"!==i||0!==t.indexOf(\"background\")||(l[t]=\"inherit\"),o&&\"set\"in o&&void 0===(i=o.set(e,i,n))||(c?l.setProperty(t,i):l[t]=i))}},css:function(e,t,i,n){var r,s,o,a=le(t);return ot.test(t)||(t=dt(a)),(o=z.cssHooks[t]||z.cssHooks[a])&&\"get\"in o&&(r=o.get(e,!0,i)),void 0===r&&(r=tt(e,t,n)),\"normal\"===r&&t in ct&&(r=ct[t]),\"\"===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),z.each([\"height\",\"width\"],(function(e,t){z.cssHooks[t]={get:function(e,i,n){if(i)return!st.test(z.css(e,\"display\"))||e.getClientRects().length&&e.getBoundingClientRect().width?pt(e,t,n):ye(e,at,(function(){return pt(e,t,n)}))},set:function(e,i,n){var r,s=Je(e),o=\"border-box\"===z.css(e,\"boxSizing\",!1,s),a=n&&ft(e,t,n,o,s);return o&&N.scrollboxSize()===s.position&&(a-=Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-parseFloat(s[t])-ft(e,t,\"border\",!1,s)-.5)),a&&(r=be.exec(i))&&\"px\"!==(r[3]||\"px\")&&(e.style[t]=i,i=z.css(e,t)),ut(0,i,a)}}})),z.cssHooks.marginLeft=it(N.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(tt(e,\"marginLeft\"))||e.getBoundingClientRect().left-ye(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+\"px\"})),z.each({margin:\"\",padding:\"\",border:\"Width\"},(function(e,t){z.cssHooks[e+t]={expand:function(i){for(var n=0,r={},s=\"string\"==typeof i?i.split(\" \"):[i];n<4;n++)r[e+Fe[n]+t]=s[n]||s[n-2]||s[0];return r}},\"margin\"!==e&&(z.cssHooks[e+t].set=ut)})),z.fn.extend({css:function(e,t){return se(this,(function(e,t,i){var n,r,s={},o=0;if(Array.isArray(t)){for(n=Je(e),r=t.length;o1)}}),z.fn.delay=function(e,t){return e=z.fx&&z.fx.speeds[e]||e,t=t||\"fx\",this.queue(t,(function(t,i){var n=window.setTimeout(t,e);i.stop=function(){window.clearTimeout(n)}}))},nt=F.createElement(\"input\"),rt=F.createElement(\"select\").appendChild(F.createElement(\"option\")),nt.type=\"checkbox\",N.checkOn=\"\"!==nt.value,N.optSelected=rt.selected,(nt=F.createElement(\"input\")).value=\"t\",nt.type=\"radio\",N.radioValue=\"t\"===nt.value;var gt,mt=z.expr.attrHandle;z.fn.extend({attr:function(e,t){return se(this,z.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){z.removeAttr(this,e)}))}}),z.extend({attr:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===e.getAttribute?z.prop(e,t,i):(1===s&&z.isXMLDoc(e)||(r=z.attrHooks[t.toLowerCase()]||(z.expr.match.bool.test(t)?gt:void 0)),void 0!==i?null===i?void z.removeAttr(e,t):r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:(e.setAttribute(t,i+\"\"),i):r&&\"get\"in r&&null!==(n=r.get(e,t))?n:null==(n=z.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!N.radioValue&&\"radio\"===t&&V(e,\"input\")){var i=e.value;return e.setAttribute(\"type\",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,r=t&&t.match(Z);if(r&&1===e.nodeType)for(;i=r[n++];)e.removeAttribute(i)}}),gt={set:function(e,t,i){return!1===t?z.removeAttr(e,i):e.setAttribute(i,i),i}},z.each(z.expr.match.bool.source.match(/\\w+/g),(function(e,t){var i=mt[t]||z.find.attr;mt[t]=function(e,t,n){var r,s,o=t.toLowerCase();return n||(s=mt[o],mt[o]=r,r=null!=i(e,t,n)?o:null,mt[o]=s),r}}));var wt=/^(?:input|select|textarea|button)$/i,bt=/^(?:a|area)$/i;function Ft(e){return(e.match(Z)||[]).join(\" \")}function vt(e){return e.getAttribute&&e.getAttribute(\"class\")||\"\"}function yt(e){return Array.isArray(e)?e:\"string\"==typeof e&&e.match(Z)||[]}z.fn.extend({prop:function(e,t){return se(this,z.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[z.propFix[e]||e]}))}}),z.extend({prop:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&z.isXMLDoc(e)||(t=z.propFix[t]||t,r=z.propHooks[t]),void 0!==i?r&&\"set\"in r&&void 0!==(n=r.set(e,i,t))?n:e[t]=i:r&&\"get\"in r&&null!==(n=r.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=z.find.attr(e,\"tabindex\");return t?parseInt(t,10):wt.test(e.nodeName)||bt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:\"htmlFor\",class:\"className\"}}),N.optSelected||(z.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),z.each([\"tabIndex\",\"readOnly\",\"maxLength\",\"cellSpacing\",\"cellPadding\",\"rowSpan\",\"colSpan\",\"useMap\",\"frameBorder\",\"contentEditable\"],(function(){z.propFix[this.toLowerCase()]=this})),z.fn.extend({addClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).addClass(e.call(this,t,vt(this)))}));if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)n.indexOf(\" \"+s+\" \")<0&&(n+=s+\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},removeClass:function(e){var t,i,n,r,s,o,a,c=0;if(B(e))return this.each((function(t){z(this).removeClass(e.call(this,t,vt(this)))}));if(!arguments.length)return this.attr(\"class\",\"\");if((t=yt(e)).length)for(;i=this[c++];)if(r=vt(i),n=1===i.nodeType&&\" \"+Ft(r)+\" \"){for(o=0;s=t[o++];)for(;n.indexOf(\" \"+s+\" \")>-1;)n=n.replace(\" \"+s+\" \",\" \");r!==(a=Ft(n))&&i.setAttribute(\"class\",a)}return this},toggleClass:function(e,t){var i=typeof e,n=\"string\"===i||Array.isArray(e);return\"boolean\"==typeof t&&n?t?this.addClass(e):this.removeClass(e):B(e)?this.each((function(i){z(this).toggleClass(e.call(this,i,vt(this),t),t)})):this.each((function(){var t,r,s,o;if(n)for(r=0,s=z(this),o=yt(e);t=o[r++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&\"boolean\"!==i||((t=vt(this))&&ue.set(this,\"__className__\",t),this.setAttribute&&this.setAttribute(\"class\",t||!1===e?\"\":ue.get(this,\"__className__\")||\"\"))}))},hasClass:function(e){var t,i,n=0;for(t=\" \"+e+\" \";i=this[n++];)if(1===i.nodeType&&(\" \"+Ft(vt(i))+\" \").indexOf(t)>-1)return!0;return!1}});var At=/\\r/g;z.fn.extend({val:function(e){var t,i,n,r=this[0];return arguments.length?(n=B(e),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?e.call(this,i,z(this).val()):e)?r=\"\":\"number\"==typeof r?r+=\"\":Array.isArray(r)&&(r=z.map(r,(function(e){return null==e?\"\":e+\"\"}))),(t=z.valHooks[this.type]||z.valHooks[this.nodeName.toLowerCase()])&&\"set\"in t&&void 0!==t.set(this,r,\"value\")||(this.value=r))}))):r?(t=z.valHooks[r.type]||z.valHooks[r.nodeName.toLowerCase()])&&\"get\"in t&&void 0!==(i=t.get(r,\"value\"))?i:\"string\"==typeof(i=r.value)?i.replace(At,\"\"):null==i?\"\":i:void 0}}),z.extend({valHooks:{option:{get:function(e){var t=z.find.attr(e,\"value\");return null!=t?t:Ft(z.text(e))}},select:{get:function(e){var t,i,n,r=e.options,s=e.selectedIndex,o=\"select-one\"===e.type,a=o?null:[],c=o?s+1:r.length;for(n=s<0?c:o?s:0;n-1)&&(i=!0);return i||(e.selectedIndex=-1),s}}}}),z.each([\"radio\",\"checkbox\"],(function(){z.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=z.inArray(z(e).val(),t)>-1}},N.checkOn||(z.valHooks[this].get=function(e){return null===e.getAttribute(\"value\")?\"on\":e.value})})),N.focusin=\"onfocusin\"in window;var Ct=/^(?:focusinfocus|focusoutblur)$/,_t=function(e){e.stopPropagation()};z.extend(z.event,{trigger:function(e,t,i,n){var r,s,o,a,c,l,h,d,u=[i||F],f=I.call(e,\"type\")?e.type:e,p=I.call(e,\"namespace\")?e.namespace.split(\".\"):[];if(s=d=o=i=i||F,3!==i.nodeType&&8!==i.nodeType&&!Ct.test(f+z.event.triggered)&&(f.indexOf(\".\")>-1&&(p=f.split(\".\"),f=p.shift(),p.sort()),c=f.indexOf(\":\")<0&&\"on\"+f,(e=e[z.expando]?e:new z.Event(f,\"object\"==typeof e&&e)).isTrigger=n?2:3,e.namespace=p.join(\".\"),e.rnamespace=e.namespace?new RegExp(\"(^|\\\\.)\"+p.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:z.makeArray(t,[e]),h=z.event.special[f]||{},n||!h.trigger||!1!==h.trigger.apply(i,t))){if(!n&&!h.noBubble&&!M(i)){for(a=h.delegateType||f,Ct.test(a+f)||(s=s.parentNode);s;s=s.parentNode)u.push(s),o=s;o===(i.ownerDocument||F)&&u.push(o.defaultView||o.parentWindow||window)}for(r=0;(s=u[r++])&&!e.isPropagationStopped();)d=s,e.type=r>1?a:h.bindType||f,(l=(ue.get(s,\"events\")||{})[e.type]&&ue.get(s,\"handle\"))&&l.apply(s,t),(l=c&&s[c])&&l.apply&&he(s)&&(e.result=l.apply(s,t),!1===e.result&&e.preventDefault());return e.type=f,n||e.isDefaultPrevented()||h._default&&!1!==h._default.apply(u.pop(),t)||!he(i)||c&&B(i[f])&&!M(i)&&((o=i[c])&&(i[c]=null),z.event.triggered=f,e.isPropagationStopped()&&d.addEventListener(f,_t),i[f](),e.isPropagationStopped()&&d.removeEventListener(f,_t),z.event.triggered=void 0,o&&(i[c]=o)),e.result}},simulate:function(e,t,i){var n=z.extend(new z.Event,i,{type:e,isSimulated:!0});z.event.trigger(n,null,t)}}),z.fn.extend({trigger:function(e,t){return this.each((function(){z.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return z.event.trigger(e,t,i,!0)}}),N.focusin||z.each({focus:\"focusin\",blur:\"focusout\"},(function(e,t){var i=function(e){z.event.simulate(t,e.target,z.event.fix(e))};z.event.special[t]={setup:function(){var n=this.ownerDocument||this,r=ue.access(n,t);r||n.addEventListener(e,i,!0),ue.access(n,t,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=ue.access(n,t)-1;r?ue.access(n,t,r):(n.removeEventListener(e,i,!0),ue.remove(n,t))}}}));var xt,kt=/\\[\\]$/,It=/\\r?\\n/g,St=/^(?:submit|button|image|reset|file)$/i,Et=/^(?:input|select|textarea|keygen)/i;function Nt(e,t,i,n){var r;if(Array.isArray(t))z.each(t,(function(t,r){i||kt.test(e)?n(e,r):Nt(e+\"[\"+(\"object\"==typeof r&&null!=r?t:\"\")+\"]\",r,i,n)}));else if(i||\"object\"!==T(t))n(e,t);else for(r in t)Nt(e+\"[\"+r+\"]\",t[r],i,n)}z.param=function(e,t){var i,n=[],r=function(e,t){var i=B(t)?t():t;n[n.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(null==i?\"\":i)};if(Array.isArray(e)||e.jquery&&!z.isPlainObject(e))z.each(e,(function(){r(this.name,this.value)}));else for(i in e)Nt(i,e[i],t,r);return n.join(\"&\")},z.fn.extend({serialize:function(){return z.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=z.prop(this,\"elements\");return e?z.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!z(this).is(\":disabled\")&&Et.test(this.nodeName)&&!St.test(e)&&(this.checked||!xe.test(e))})).map((function(e,t){var i=z(this).val();return null==i?null:Array.isArray(i)?z.map(i,(function(e){return{name:t.name,value:e.replace(It,\"\\r\\n\")}})):{name:t.name,value:i.replace(It,\"\\r\\n\")}})).get()}}),z.fn.extend({wrapAll:function(e){var t;return this[0]&&(B(e)&&(e=e.call(this[0])),t=z(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return B(e)?this.each((function(t){z(this).wrapInner(e.call(this,t))})):this.each((function(){var t=z(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=B(e);return this.each((function(i){z(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not(\"body\").each((function(){z(this).replaceWith(this.childNodes)})),this}}),z.expr.pseudos.hidden=function(e){return!z.expr.pseudos.visible(e)},z.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},N.createHTMLDocument=((xt=F.implementation.createHTMLDocument(\"\").body).innerHTML=\"
\",2===xt.childNodes.length),z.parseHTML=function(e,t,i){return\"string\"!=typeof e?[]:(\"boolean\"==typeof t&&(i=t,t=!1),t||(N.createHTMLDocument?((n=(t=F.implementation.createHTMLDocument(\"\")).createElement(\"base\")).href=F.location.href,t.head.appendChild(n)):t=F),s=!i&&[],(r=j.exec(e))?[t.createElement(r[1])]:(r=Me([e],t,s),s&&s.length&&z(s).remove(),z.merge([],r.childNodes)));var n,r,s},z.offset={setOffset:function(e,t,i){var n,r,s,o,a,c,l=z.css(e,\"position\"),h=z(e),d={};\"static\"===l&&(e.style.position=\"relative\"),a=h.offset(),s=z.css(e,\"top\"),c=z.css(e,\"left\"),(\"absolute\"===l||\"fixed\"===l)&&(s+c).indexOf(\"auto\")>-1?(o=(n=h.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(c)||0),B(t)&&(t=t.call(e,i,z.extend({},a))),null!=t.top&&(d.top=t.top-a.top+o),null!=t.left&&(d.left=t.left-a.left+r),\"using\"in t?t.using.call(e,d):h.css(d)}},z.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){z.offset.setOffset(this,e,t)}));var t,i,n=this[0];return n?n.getClientRects().length?(t=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,i,n=this[0],r={top:0,left:0};if(\"fixed\"===z.css(n,\"position\"))t=n.getBoundingClientRect();else{for(t=this.offset(),i=n.ownerDocument,e=n.offsetParent||i.documentElement;e&&(e===i.body||e===i.documentElement)&&\"static\"===z.css(e,\"position\");)e=e.parentNode;e&&e!==n&&1===e.nodeType&&((r=z(e).offset()).top+=z.css(e,\"borderTopWidth\",!0),r.left+=z.css(e,\"borderLeftWidth\",!0))}return{top:t.top-r.top-z.css(n,\"marginTop\",!0),left:t.left-r.left-z.css(n,\"marginLeft\",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&\"static\"===z.css(e,\"position\");)e=e.offsetParent;return e||Re}))}}),z.each({scrollLeft:\"pageXOffset\",scrollTop:\"pageYOffset\"},(function(e,t){var i=\"pageYOffset\"===t;z.fn[e]=function(n){return se(this,(function(e,n,r){var s;if(M(e)?s=e:9===e.nodeType&&(s=e.defaultView),void 0===r)return s?s[t]:e[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):e[n]=r}),e,n,arguments.length)}})),z.each([\"top\",\"left\"],(function(e,t){z.cssHooks[t]=it(N.pixelPosition,(function(e,i){if(i)return i=tt(e,t),Ze.test(i)?z(e).position()[t]+\"px\":i}))})),z.each({Height:\"height\",Width:\"width\"},(function(e,t){z.each({padding:\"inner\"+e,content:t,\"\":\"outer\"+e},(function(i,n){z.fn[n]=function(r,s){var o=arguments.length&&(i||\"boolean\"!=typeof r),a=i||(!0===r||!0===s?\"margin\":\"border\");return se(this,(function(t,i,r){var s;return M(t)?0===n.indexOf(\"outer\")?t[\"inner\"+e]:t.document.documentElement[\"client\"+e]:9===t.nodeType?(s=t.documentElement,Math.max(t.body[\"scroll\"+e],s[\"scroll\"+e],t.body[\"offset\"+e],s[\"offset\"+e],s[\"client\"+e])):void 0===r?z.css(t,i,a):z.style(t,i,r,a)}),t,o?r:void 0,o)}}))})),z.each(\"blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu\".split(\" \"),(function(e,t){z.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)}})),z.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),z.fn.extend({bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,\"**\"):this.off(t,e||\"**\",i)}}),z.proxy=function(e,t){var i,n,r;if(\"string\"==typeof t&&(i=e[t],t=e,e=i),B(e))return n=y.call(arguments,2),r=function(){return e.apply(t||this,n.concat(y.call(arguments)))},r.guid=e.guid=e.guid||z.guid++,r},z.holdReady=function(e){e?z.readyWait++:z.ready(!0)},z.isArray=Array.isArray,z.parseJSON=JSON.parse,z.nodeName=V,z.isFunction=B,z.isWindow=M,z.camelCase=le,z.type=T,z.now=Date.now,z.isNumeric=function(e){var t=z.type(e);return(\"number\"===t||\"string\"===t)&&!isNaN(e-parseFloat(e))};const Bt=z;function Mt(e){return\"string\"==typeof e||e instanceof String}function Rt(e){var t=String(e).split(/[.,]/);return t[0].split(\"\").reverse().reduce((function(e,t,i){return i%3==0?e+\",\"+t:e+t})).split(\"\").reverse().join(\"\")+(t[1]?\".\"+t[1]:\"\")}const Dt=function(e){return e.split(/\\n|\\r\\n|\\r/g)};function Tt(e,t){var i,n,r=[],s=e.length,o=0,a=!1;if(s>0)for(r[o]=e.charAt(0),i=1;i0?e.charAt(0).toUpperCase()+e.slice(1):e}function zt(e){if(void 0!==e.name)return e.name;if(Mt(e)){let t=e.lastIndexOf(\"/\"),i=t<0?e:e.substr(t+1);return t=i.indexOf(\"?\"),t>0&&(i=i.substr(0,t)),i}throw Error(\"Expected File or string, got \"+typeof e)}function Ht(e){return!!e&&(\"function\"!=typeof e&&(e instanceof File||e.hasOwnProperty(\"name\")&&\"function\"==typeof e.slice&&\"function\"==typeof e.arrayBuffer))}function Pt(e,t){const i=document.createElement(\"a\");i.setAttribute(\"href\",t),i.setAttribute(\"download\",e),i.style.display=\"none\",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Ot(e){for(var t=Ut,i=t.parser.loose.exec(e),n={},r=14;r--;)n[t.key[r]]=i[r]||\"\";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,i,r){i&&(n[t.q.name][i]=r)})),n}\"object\"==typeof process&&\"undefined\"==typeof window&&(global.atob=function(e){return Buffer.from(e,\"base64\").toString(\"binary\")});const Ut={strictMode:!1,key:[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"],q:{name:\"queryKey\",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/}};function qt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Qt=256,Vt=286,jt=30,Wt=15,Gt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),$t=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Kt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Yt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xt=new Array(576);qt(Xt);const Zt=new Array(60);qt(Zt);const Jt=new Array(512);qt(Jt);const ei=new Array(256);qt(ei);const ti=new Array(29);qt(ti);const ii=new Array(jt);function ni(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let ri,si,oi;function ai(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}qt(ii);const ci=e=>e<256?Jt[e]:Jt[256+(e>>>7)],li=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},hi=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{hi(e,i[2*t],i[2*t+1])},ui=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},fi=(e,t,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=Wt;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=ui(n[t]++,t))}},pi=e=>{let t;for(t=0;t{e.bi_valid>8?li(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},mi=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let n,r,s,o,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?di(e,r,t):(s=ei[r],di(e,s+Qt+1,t),o=Gt[s],0!==o&&(r-=ti[s],hi(e,r,o)),n--,s=ci(n),di(e,s,i),o=$t[s],0!==o&&(n-=ii[s],hi(e,n,o)))}while(a{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,l=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)wi(e,i,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],wi(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*c]=i[2*o]+i[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=c,e.heap[1]=c++,wi(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let l,h,d,u,f,p,g=0;for(u=0;u<=Wt;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)h=e.heap[l],u=i[2*i[2*h+1]+1]+1,u>c&&(u=c,g++),i[2*h+1]=u,h>n||(e.bl_count[u]++,f=0,h>=a&&(f=o[h-a]),p=i[2*h],e.opt_len+=p*(u+f),s&&(e.static_len+=p*(r[2*h+1]+f)));if(0!==g){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(u=c;0!==u;u--)for(h=e.bl_count[u];0!==h;)d=e.heap[--l],d>n||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),h--)}})(e,t),fi(i,l,e.bl_count)},vi=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a{let n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a{hi(e,0+(n?1:0),3),gi(e),li(e,i),li(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var _i=e=>{Ai||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(ti[n]=i,e=0;e<1<>=7;n{let r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t{let t;for(vi(e,e.dyn_ltree,e.l_desc.max_code),vi(e,e.dyn_dtree,e.d_desc.max_code),Fi(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Yt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Ci(e,t,i,n):4===e.strategy||s===r?(hi(e,2+(n?1:0),3),bi(e,Xt,Zt)):(hi(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(hi(e,t-257,5),hi(e,i-1,5),hi(e,n-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(ei[i]+Qt+1)]++,e.dyn_dtree[2*ci(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{hi(e,2,3),di(e,256,Xt),(e=>{16===e.bi_valid?(li(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ii=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const Si=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ei=(e,t,i,n)=>{const r=Si,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Ni={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},Bi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Mi,_tr_stored_block:Ri,_tr_flush_block:Di,_tr_tally:Ti,_tr_align:Li}=ki,{Z_NO_FLUSH:zi,Z_PARTIAL_FLUSH:Hi,Z_FULL_FLUSH:Pi,Z_FINISH:Oi,Z_BLOCK:Ui,Z_OK:qi,Z_STREAM_END:Qi,Z_STREAM_ERROR:Vi,Z_DATA_ERROR:ji,Z_BUF_ERROR:Wi,Z_DEFAULT_COMPRESSION:Gi,Z_FILTERED:$i,Z_HUFFMAN_ONLY:Ki,Z_RLE:Yi,Z_FIXED:Xi,Z_DEFAULT_STRATEGY:Zi,Z_UNKNOWN:Ji,Z_DEFLATED:en}=Bi,tn=258,nn=262,rn=42,sn=113,on=666,an=(e,t)=>(e.msg=Ni[t],t),cn=e=>2*e-(e>4?9:0),ln=e=>{let t=e.length;for(;--t>=0;)e[t]=0},hn=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let dn=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},fn=(e,t)=>{Di(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,un(e.strm)},pn=(e,t)=>{e.pending_buf[e.pending++]=t},gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},mn=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=Ii(e.adler,t,r,i):2===e.state.wrap&&(e.adler=Ei(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},wn=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-nn?e.strstart-(e.w_size-nn):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+tn;let f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,l[i+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead},bn=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nn)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),hn(e),n+=t),0===e.strm.avail_in)break;if(i=mn(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=dn(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=dn(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,n,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outn+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,un(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(mn(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(mn(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=s||(n||t===Oi)&&t!==zi&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=t===Oi&&0===e.strm.avail_in&&i===n?1:0,Ri(e,e.block_start,i,o),e.block_start+=i,un(e.strm)),o?3:1)},vn=(e,t)=>{let i,n;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nn&&(e.match_length=wn(e,i)),e.match_length>=3)if(n=Ti(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=dn(e,e.ins_h,e.window[e.strstart+1]);else n=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2},yn=(e,t)=>{let i,n,r;for(;;){if(e.lookahead=3&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=Ti(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=dn(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(fn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Ti(e,0,e.window[e.strstart-1]),n&&fn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ti(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2};function An(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const Cn=[new An(0,0,0,0,Fn),new An(4,4,8,4,vn),new An(4,5,16,8,vn),new An(4,6,32,32,vn),new An(4,4,16,16,yn),new An(8,16,32,32,yn),new An(8,16,128,128,yn),new An(8,32,128,256,yn),new An(32,128,258,1024,yn),new An(32,258,258,4096,yn)];function _n(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ln(this.dyn_ltree),ln(this.dyn_dtree),ln(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ln(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ln(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const xn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==sn&&t.status!==on?1:0},kn=e=>{if(xn(e))return an(e,Vi);e.total_in=e.total_out=0,e.data_type=Ji;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?rn:sn,e.adler=2===t.wrap?0:1,t.last_flush=-2,Mi(t),qi},In=e=>{const t=kn(e);var i;return t===qi&&((i=e.state).window_size=2*i.w_size,ln(i.head),i.max_lazy_match=Cn[i.level].max_lazy,i.good_match=Cn[i.level].good_length,i.nice_match=Cn[i.level].nice_length,i.max_chain_length=Cn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Sn=(e,t,i,n,r,s)=>{if(!e)return Vi;let o=1;if(t===Gi&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==en||n<8||n>15||t<0||t>9||s<0||s>Xi||8===n&&1!==o)return an(e,Vi);8===n&&(n=9);const a=new _n;return e.state=a,a.strm=e,a.status=rn,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<{let i=t.length;if(xn(e))return Vi;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==rn||n.lookahead)return Vi;if(1===r&&(e.adler=Ii(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(ln(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,bn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=dn(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,bn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,n.wrap=r,qi},Nn={deflateInit:(e,t)=>Sn(e,t,en,15,8,Zi),deflateInit2:Sn,deflateReset:In,deflateResetKeep:kn,deflateSetHeader:(e,t)=>xn(e)||2!==e.state.wrap?Vi:(e.state.gzhead=t,qi),deflate:(e,t)=>{if(xn(e)||t>Ui||t<0)return e?an(e,Vi):Vi;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===on&&t!==Oi)return an(e,0===e.avail_out?Wi:Vi);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(un(e),0===e.avail_out)return i.last_flush=-1,qi}else if(0===e.avail_in&&cn(t)<=cn(n)&&t!==Oi)return an(e,Wi);if(i.status===on&&0!==e.avail_in)return an(e,Wi);if(i.status===rn&&0===i.wrap&&(i.status=sn),i.status===rn){let t=en+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=Ki||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,gn(i,t),0!==i.strstart&&(gn(i,e.adler>>>16),gn(i,65535&e.adler)),e.adler=1,i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(57===i.status)if(e.adler=0,pn(i,31),pn(i,139),pn(i,8),i.gzhead)pn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),pn(i,255&i.gzhead.time),pn(i,i.gzhead.time>>8&255),pn(i,i.gzhead.time>>16&255),pn(i,i.gzhead.time>>24&255),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(pn(i,255&i.gzhead.extra.length),pn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ei(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,0),pn(i,9===i.level?2:i.strategy>=Ki||i.level<2?4:0),pn(i,3),i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,un(e),0!==i.pending)return i.last_flush=-1,qi;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n)),un(e),0!==i.pending)return i.last_flush=-1,qi;n=0}t=i.gzindexn&&(e.adler=Ei(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(un(e),0!==i.pending))return i.last_flush=-1,qi;pn(i,255&e.adler),pn(i,e.adler>>8&255),e.adler=0}if(i.status=sn,un(e),0!==i.pending)return i.last_flush=-1,qi}if(0!==e.avail_in||0!==i.lookahead||t!==zi&&i.status!==on){let n=0===i.level?Fn(i,t):i.strategy===Ki?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(bn(e),0===e.lookahead)){if(t===zi)return 1;break}if(e.match_length=0,i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Yi?((e,t)=>{let i,n,r,s;const o=e.window;for(;;){if(e.lookahead<=tn){if(bn(e),e.lookahead<=tn&&t===zi)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=e.strstart+tn;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ti(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ti(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(fn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oi?(fn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(fn(e,!1),0===e.strm.avail_out)?1:2})(i,t):Cn[i.level].func(i,t);if(3!==n&&4!==n||(i.status=on),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),qi;if(2===n&&(t===Hi?Li(i):t!==Ui&&(Ri(i,0,0,!1),t===Pi&&(ln(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),un(e),0===e.avail_out))return i.last_flush=-1,qi}return t!==Oi?qi:i.wrap<=0?Qi:(2===i.wrap?(pn(i,255&e.adler),pn(i,e.adler>>8&255),pn(i,e.adler>>16&255),pn(i,e.adler>>24&255),pn(i,255&e.total_in),pn(i,e.total_in>>8&255),pn(i,e.total_in>>16&255),pn(i,e.total_in>>24&255)):(gn(i,e.adler>>>16),gn(i,65535&e.adler)),un(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?qi:Qi)},deflateEnd:e=>{if(xn(e))return Vi;const t=e.state.status;return e.state=null,t===sn?an(e,ji):qi},deflateSetDictionary:En,deflateInfo:\"pako deflate (from Nodeca project)\"};const Bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Bn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:CA>=248?5:CA>=240?4:CA>=224?3:CA>=192?2:1;Dn[254]=Dn[254]=1;var Tn={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Rn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Dn[e[i]]>t?i:t}};var Ln=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0};const zn=Object.prototype.toString,{Z_NO_FLUSH:Hn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:On,Z_FINISH:Un,Z_OK:qn,Z_STREAM_END:Qn,Z_DEFAULT_COMPRESSION:Vn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Wn}=Bi;function Gn(e){this.options=Mn.assign({level:Vn,method:Wn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Nn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==qn)throw new Error(Ni[i]);if(t.header&&Nn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=\"string\"==typeof t.dictionary?Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===zn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Nn.deflateSetDictionary(this.strm,e),i!==qn)throw new Error(Ni[i]);this._dict_set=!0}}function $n(e,t){const i=new Gn(t);if(i.push(e,!0),i.err)throw i.msg||Ni[i.err];return i.result}Gn.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Un:Hn,\"string\"==typeof e?i.input=Tn.string2buf(e):\"[object ArrayBuffer]\"===zn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===Pn||s===On)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Nn.deflate(i,s),r===Qn)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Nn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===qn;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Gn.prototype.onData=function(e){this.chunks.push(e)},Gn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn=function(e,t){return(t=t||{}).raw=!0,$n(e,t)},Yn=function(e,t){return(t=t||{}).gzip=!0,$n(e,t)},Xn={Deflate:Gn,deflate:$n,deflateRaw:Kn,gzip:Yn,constants:Bi};const Zn=16209;var Jn=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=16191;break e}e.msg=\"invalid literal/length code\",k.mode=Zn;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=Zn;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=Zn;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null;const k=new Uint16Array(16),I=new Uint16Array(16);let S,E,N,B=null;for(g=0;g<=er;g++)k[g]=0;for(m=0;m=1&&0===k[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(I[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){S=g-y,o[m]+1=p?(E=B[o[m]-p],N=x[o[m]-p]):(E=96,N=0),l=1<>y)+h]=S<<24|E<<16|N}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--k[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0};const{Z_FINISH:or,Z_BLOCK:ar,Z_TREES:cr,Z_OK:lr,Z_STREAM_END:hr,Z_NEED_DICT:dr,Z_STREAM_ERROR:ur,Z_DATA_ERROR:fr,Z_MEM_ERROR:pr,Z_BUF_ERROR:gr,Z_DEFLATED:mr}=Bi,wr=16180,br=16190,Fr=16191,vr=16192,yr=16194,Ar=16199,Cr=16200,_r=16206,xr=16209,kr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ir(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Sr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Er=e=>{if(Sr(e))return ur;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=wr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,lr},Nr=e=>{if(Sr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Er(e)},Br=(e,t)=>{let i;if(Sr(e))return ur;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Nr(e))},Mr=(e,t)=>{if(!e)return ur;const i=new Ir;e.state=i,i.strm=e,i.window=null,i.mode=wr;const n=Br(e,t);return n!==lr&&(e.state=null),n};let Rr,Dr,Tr=!0;const Lr=e=>{if(Tr){Rr=new Int32Array(512),Dr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(sr(1,e.lens,0,288,Rr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sr(2,e.lens,0,32,Dr,0,e.work,{bits:5}),Tr=!1}e.lencode=Rr,e.lenbits=9,e.distcode=Dr,e.distbits=5},zr=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Sr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;i=e.state,i.mode===Fr&&(i.mode=vr),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=lr;e:for(;;)switch(i.mode){case wr:if(0===i.wrap){i.mode=vr;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0),l=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=xr;break}if((15&l)!==mr){e.msg=\"unknown compression method\",i.mode=xr;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits&&(i.wbits=A),A>15||A>i.wbits){e.msg=\"invalid window size\",i.mode=xr;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Ei(i.check,x,4,0)),l=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&4&i.wrap&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Ei(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&4&i.wrap&&(i.check=Ei(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Fr;break;case 16189:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=_r;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=16193;break;case 1:if(Lr(i),i.mode=Ar,t===cr){l>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg=\"invalid block type\",i.mode=xr}l>>>=2,h-=2;break;case 16193:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=xr;break}if(i.length=65535&l,l=0,h=0,i.mode=yr,t===cr)break e;case yr:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Fr;break;case 16196:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=xr;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=sr(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=xr;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=xr;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=xr;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===xr)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=xr;break}if(i.lenbits=9,k={bits:i.lenbits},C=sr(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=xr;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=sr(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=xr;break}if(i.mode=Ar,t===cr)break e;case Ar:i.mode=Cr;case Cr:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Jn(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Fr&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=Fr;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=xr;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=xr;break}i.offset=b,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=xr;break}i.mode=16204;case 16204:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=xr;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=Cr);break;case 16205:if(0===c)break e;r[o++]=i.length,c--,i.mode=Cr;break;case _r:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<Mr(e,15),inflateInit2:Mr,inflate:Hr,inflateEnd:e=>{if(Sr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,lr},inflateGetHeader:(e,t)=>{if(Sr(e))return ur;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,lr):ur},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return Sr(e)?ur:(n=e.state,0!==n.wrap&&n.mode!==br?ur:n.mode===br&&(r=1,r=Ii(r,t,i,0),r!==n.check)?fr:(s=zr(e,t,i,i),s?(n.mode=16210,pr):(n.havedict=1,lr)))},inflateInfo:\"pako inflate (from Nodeca project)\"};var Or=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1};const Ur=Object.prototype.toString,{Z_NO_FLUSH:qr,Z_FINISH:Qr,Z_OK:Vr,Z_STREAM_END:jr,Z_NEED_DICT:Wr,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:$r,Z_MEM_ERROR:Kr}=Bi;function Yr(e){this.options=Mn.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Ln,this.strm.avail_out=0;let i=Pr.inflateInit2(this.strm,t.windowBits);if(i!==Vr)throw new Error(Ni[i]);if(this.header=new Or,Pr.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Tn.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Ur.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Pr.inflateSetDictionary(this.strm,t.dictionary),i!==Vr)))throw new Error(Ni[i])}function Xr(e,t){const i=new Yr(t);if(i.push(e),i.err)throw i.msg||Ni[i.err];return i.result}Yr.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Qr:qr,\"[object ArrayBuffer]\"===Ur.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Pr.inflate(i,o),s===Wr&&r&&(s=Pr.inflateSetDictionary(i,r),s===Vr?s=Pr.inflate(i,o):s===$r&&(s=Wr));i.avail_in>0&&s===jr&&i.state.wrap>0&&0!==e[i.next_in];)Pr.inflateReset(i),s=Pr.inflate(i,o);switch(s){case Gr:case $r:case Wr:case Kr:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===jr))if(\"string\"===this.options.to){let e=Tn.utf8border(i.output,i.next_out),t=i.next_out-e,r=Tn.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Vr||0!==a){if(s===jr)return s=Pr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Yr.prototype.onData=function(e){this.chunks.push(e)},Yr.prototype.onEnd=function(e){e===Vr&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Zr=function(e,t){return(t=t||{}).raw=!0,Xr(e,t)},Jr={Inflate:Yr,inflate:Xr,inflateRaw:Zr,ungzip:Xr,constants:Bi};const{Deflate:es,deflate:ts,deflateRaw:is,gzip:ns}=Xn,{Inflate:rs,inflate:ss,inflateRaw:os,ungzip:as}=Jr;var cs=is,ls=ss,hs=os,ds=as;const us=4;function fs(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 31===t[0]&&139===t[1]}function ps(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 0!==(t[3]&us)&&66===t[12]&&67===t[13]?gs(t.buffer):ds(t)}function gs(e,t){const i=[];let n=0,r=0;for(t=t||e.byteLength-18;n100?Fs(new Uint8Array(e.buffer,e.byteOffset+t,r),i,n):function(e,t,i,n,r){for(let s=0;s=0){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t0?ds(e):e,i}return decodeURIComponent(r)}const ys={lerp:(e,t,i)=>(1-i)*e+i*t,mean:function(e){var t,i=0,n=0;for(t=0;t0?i/n:0},meanAndStdev:function(e){var t,i,n=0,r=0,s=0;for(i=0;i0?{mean:n/s,stdev:Math.sqrt(r-n*n/s)}:{mean:0,stdev:0}},median:function(e){var t=e.length;return e.sort(),t%2==0?(e[t/2-1]+e[t/2])/2:e[(t-1)/2]},percentile:function(e,t){if(0!==e.length){var i=Math.floor(e.length*((100-t)/100));return 0===i?(e.sort((function(e,t){return t-e})),e[i]):function(e,t){var i,n=new As;for(i=0;in.content[0])&&(n.content.length===t&&n.pop(),n.push(r))}return n.content[0]}(e,i)}},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},log2:function(e){return Math.log(e)/Math.LN2}};function As(){this.content=[]}function Cs(e,t){return Math.random()*(t-e)+e}As.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},remove:function(e){for(var t=this.content.length,i=0;i0;){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=t,this.content[e]=r,e=n}},sinkDown:function(e){for(var t=this.content.length,i=this.content[e],n=i;;){var r=2*(e+1),s=r-1,o=null;if(s{let e=[];for(let t=1;t>=.5;t-=.1)for(let i=0;i<1;i+=1/28){const n=\"rgb(\"+_s.hsvToRgb(i,1,t).join(\",\")+\")\";e.push(n)}return e.pop(),e.push(_s.rgbColor(16,16,16)),e},rgbToHex:function(e){return(e=e.match(/^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i))&&4===e.length?\"#\"+(\"0\"+parseInt(e[1],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[2],10).toString(16)).slice(-2)+(\"0\"+parseInt(e[3],10).toString(16)).slice(-2):\"\"},hexToRgb:function(e){var t=/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(e);if(null!==t)return\"rgb(\"+parseInt(t[1],16)+\",\"+parseInt(t[2],16)+\",\"+parseInt(t[3],16)+\")\"},hsvToRgb:function(e,t,i){var n,r,s,o=Math.floor(6*e),a=6*e-o,c=i*(1-t),l=i*(1-a*t),h=i*(1-(1-a)*t);switch(o%6){case 0:n=i,r=h,s=c;break;case 1:n=l,r=i,s=c;break;case 2:n=c,r=i,s=h;break;case 3:n=c,r=l,s=i;break;case 4:n=h,r=c,s=i;break;case 5:n=i,r=c,s=l}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(e,t,i){var n,r,s;if(0===t)n=r=s=i;else{var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=_s.hue2rgb(a,o,e+1/3),r=_s.hue2rgb(a,o,e),s=_s.hue2rgb(a,o,e-1/3)}return[255*n,255*r,255*s]},hue2rgb:(e,t,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e),rgbaColor:function(e,t,i,n){return\"rgba(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\",\"+(n=ys.clamp(n,0,1))+\")\"},rgbColor:function(e,t,i){return\"rgb(\"+(e=ys.clamp(e,0,255))+\",\"+(t=ys.clamp(t,0,255))+\",\"+(i=ys.clamp(i,0,255))+\")\"},greyScale:function(e){var t=ys.clamp(e,0,255);return\"rgb(\"+t+\",\"+t+\",\"+t+\")\"},randomGrey:function(e,t){e=ys.clamp(e,0,255),t=ys.clamp(t,0,255);var i=Math.round(Cs(e,t)).toString(10);return\"rgb(\"+i+\",\"+i+\",\"+i+\")\"},randomRGB:function(e,t){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgb(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\")\"},randomRGBConstantAlpha:function(e,t,i){return e=ys.clamp(e,0,255),t=ys.clamp(t,0,255),\"rgba(\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+Math.round(Cs(e,t)).toString(10)+\",\"+i+\")\"},addAlpha:function(e,t){if(\"0\"===e||\".\"===e)e=\"rgb(0,0,0)\";else{const t=this.colorNameToHex(e);t&&(e=t)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);if(e.startsWith(\"rgba\")){const i=e.lastIndexOf(\",\");return e.substring(0,i+1)+t.toString()+\")\"}return i&&(e=_s.hexToRgb(e)),e.startsWith(\"rgb\")?e.replace(\"rgb\",\"rgba\").replace(\")\",\", \"+t+\")\"):(console.log(e+\" is not an rgb style string\"),e)},rgbComponents:function(e){if(\"0\"===e||\".\"===e)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e))e=_s.hexToRgb(e);else if(!e.startsWith(\"rgb\")){const t=this.colorNameToHex(e);e=this.hexToRgb(t)}if(e.startsWith(\"rgb(\"))return e.substring(4,e.length-1).split(\",\").map((e=>Number.parseInt(e.trim())));if(e.startsWith(\"rgba(\"))return e.substring(5,e.length-1).split(\",\").map(((e,t)=>(e=e.trim(),3===t?Number.parseFloat(e):Number.parseInt(e))));throw Error(\"Unrecognized color string: color\")},getCompositeColor:function(e,t,i){return\"rgb(\"+Math.floor(i*t[0]+(1-i)*e[0])+\",\"+Math.floor(i*t[1]+(1-i)*e[1])+\",\"+Math.floor(i*t[2]+(1-i)*e[2])+\")\"},createColorString:function(e){const t=this.createColorStringSafe(e);return t||e},createColorStringSafe:function(e){if((e=function(e){return void 0===e||((e.startsWith(\"'\")||e.startsWith('\"'))&&(e=e.substring(1)),(e.endsWith(\"'\")||e.endsWith('\"'))&&(e=e.substring(0,e.length-1))),e}(e)).startsWith(\"rgb(\")&&e.endsWith(\")\"))return e;if(e.startsWith(\"#\")&&e.length<8)return e;const t=this.colorNameToHex(e);if(t)return t;const i=e.split(\",\");return 3===i.length&&xs(i[0])&&xs(i[1])&&xs(i[2])?`rgb(${e})`:void 0},darkenLighten:function(e,t){let i,n=this.colorNameToHex(e);i=n?_s.hexToRgb(n):e.startsWith(\"rgb(\")?e:_s.hexToRgb(e);const r=i.replace(\")\",\"\").substring(4).split(\",\"),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+t)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+t)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+t));return\"rgb(\"+s.toString()+\",\"+o.toString()+\",\"+a.toString()+\")\"},colorNameToHex:function(e){return{aliceblue:\"#f0f8ff\",antiquewhite:\"#faebd7\",aqua:\"#00ffff\",aquamarine:\"#7fffd4\",azure:\"#f0ffff\",beige:\"#f5f5dc\",bisque:\"#ffe4c4\",black:\"#000000\",blanchedalmond:\"#ffebcd\",blue:\"#0000ff\",blueviolet:\"#8a2be2\",brown:\"#a52a2a\",burlywood:\"#deb887\",cadetblue:\"#5f9ea0\",chartreuse:\"#7fff00\",chocolate:\"#d2691e\",coral:\"#ff7f50\",cornflowerblue:\"#6495ed\",cornsilk:\"#fff8dc\",crimson:\"#dc143c\",cyan:\"#00ffff\",darkblue:\"#00008b\",darkcyan:\"#008b8b\",darkgoldenrod:\"#b8860b\",darkgray:\"#a9a9a9\",darkgreen:\"#006400\",darkkhaki:\"#bdb76b\",darkmagenta:\"#8b008b\",darkolivegreen:\"#556b2f\",darkorange:\"#ff8c00\",darkorchid:\"#9932cc\",darkred:\"#8b0000\",darksalmon:\"#e9967a\",darkseagreen:\"#8fbc8f\",darkslateblue:\"#483d8b\",darkslategray:\"#2f4f4f\",darkturquoise:\"#00ced1\",darkviolet:\"#9400d3\",deeppink:\"#ff1493\",deepskyblue:\"#00bfff\",dimgray:\"#696969\",dodgerblue:\"#1e90ff\",firebrick:\"#b22222\",floralwhite:\"#fffaf0\",forestgreen:\"#228b22\",fuchsia:\"#ff00ff\",gainsboro:\"#dcdcdc\",ghostwhite:\"#f8f8ff\",gold:\"#ffd700\",goldenrod:\"#daa520\",gray:\"#808080\",green:\"#008000\",greenyellow:\"#adff2f\",honeydew:\"#f0fff0\",hotpink:\"#ff69b4\",\"indianred \":\"#cd5c5c\",\"indigo \":\"#4b0082\",ivory:\"#fffff0\",khaki:\"#f0e68c\",lavender:\"#e6e6fa\",lavenderblush:\"#fff0f5\",lawngreen:\"#7cfc00\",lemonchiffon:\"#fffacd\",lightblue:\"#add8e6\",lightcoral:\"#f08080\",lightcyan:\"#e0ffff\",lightgoldenrodyellow:\"#fafad2\",lightgrey:\"#d3d3d3\",lightgreen:\"#90ee90\",lightpink:\"#ffb6c1\",lightsalmon:\"#ffa07a\",lightseagreen:\"#20b2aa\",lightskyblue:\"#87cefa\",lightslategray:\"#778899\",lightsteelblue:\"#b0c4de\",lightyellow:\"#ffffe0\",lime:\"#00ff00\",limegreen:\"#32cd32\",linen:\"#faf0e6\",magenta:\"#ff00ff\",maroon:\"#800000\",mediumaquamarine:\"#66cdaa\",mediumblue:\"#0000cd\",mediumorchid:\"#ba55d3\",mediumpurple:\"#9370d8\",mediumseagreen:\"#3cb371\",mediumslateblue:\"#7b68ee\",mediumspringgreen:\"#00fa9a\",mediumturquoise:\"#48d1cc\",mediumvioletred:\"#c71585\",midnightblue:\"#191970\",mintcream:\"#f5fffa\",mistyrose:\"#ffe4e1\",moccasin:\"#ffe4b5\",navajowhite:\"#ffdead\",navy:\"#000080\",oldlace:\"#fdf5e6\",olive:\"#808000\",olivedrab:\"#6b8e23\",orange:\"#ffa500\",orangered:\"#ff4500\",orchid:\"#da70d6\",palegoldenrod:\"#eee8aa\",palegreen:\"#98fb98\",paleturquoise:\"#afeeee\",palevioletred:\"#d87093\",papayawhip:\"#ffefd5\",peachpuff:\"#ffdab9\",peru:\"#cd853f\",pink:\"#ffc0cb\",plum:\"#dda0dd\",powderblue:\"#b0e0e6\",purple:\"#800080\",red:\"#ff0000\",rosybrown:\"#bc8f8f\",royalblue:\"#4169e1\",saddlebrown:\"#8b4513\",salmon:\"#fa8072\",sandybrown:\"#f4a460\",seagreen:\"#2e8b57\",seashell:\"#fff5ee\",sienna:\"#a0522d\",silver:\"#c0c0c0\",skyblue:\"#87ceeb\",slateblue:\"#6a5acd\",slategray:\"#708090\",snow:\"#fffafa\",springgreen:\"#00ff7f\",steelblue:\"#4682b4\",tan:\"#d2b48c\",teal:\"#008080\",thistle:\"#d8bfd8\",tomato:\"#ff6347\",turquoise:\"#40e0d0\",violet:\"#ee82ee\",wheat:\"#f5deb3\",white:\"#ffffff\",whitesmoke:\"#f5f5f5\",yellow:\"#ffff00\",yellowgreen:\"#9acd32\",darkgrey:\"#a9a9a9\",darkslategrey:\"#2f4f4f\",dimgrey:\"#696969\",grey:\"#808080\",lightgray:\"#d3d3d3\",lightslategrey:\"#778899\",slategrey:\"#708090\"}[e]}};function xs(e){const t=Number.parseInt(e);return!Number.isNaN(t)&&t>=0&&t<=255}const ks=\"googleapis\";class Is{constructor(){this.oauthTokens={}}setToken(e,t){t=t||ks,this.oauthTokens[t]=e}getToken(e){let t;e=e||ks;for(let i of Object.keys(this.oauthTokens)){if(Ss(i).test(e)){t=this.oauthTokens[i];break}}return t}removeToken(e){e=e||ks;for(let t of Object.keys(this.oauthTokens)){Ss(t).test(e)&&(this.oauthTokens[t]=void 0)}}}function Ss(e){return new RegExp(\"^\"+e.split(/\\*+/).map(Es).join(\".*\")+\"$\")}function Es(e){return e.replace(/[|\\\\{}()[\\]^$+*?.]/g,\"\\\\$&\")}function Ns(e){return e.includes(\"googleapis\")&&!e.includes(\"urlshortener\")||Bs(e)||Ms(e)}function Bs(e){return e.startsWith(\"gs://\")||e.startsWith(\"https://www.googleapis.com/storage\")||e.startsWith(\"https://storage.cloud.google.com\")||e.startsWith(\"https://storage.googleapis.com\")}function Ms(e){return e.indexOf(\"drive.google.com\")>=0||e.indexOf(\"www.googleapis.com/drive\")>0}function Rs(e){let{bucket:t,object:i}=function(e){let t,i;if(e.startsWith(\"gs://\")){const n=e.indexOf(\"/\",5);if(n>=0){t=e.substring(5,n);const r=e.indexOf(\"?\");i=r<0?e.substring(n+1):e.substring(n+1,r)}}else if(e.startsWith(\"https://storage.googleapis.com\")||e.startsWith(\"https://storage.cloud.google.com\")){const n=e.indexOf(\"/v1/b/\",8);if(n>0){const r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}else{const n=e.indexOf(\"/\",8),r=e.indexOf(\"/\",n+1),s=e.indexOf(\"?\",r);r>0&&(t=e.substring(n+1,r),i=s<0?e.substring(r+1):e.substring(r+1,s))}}else if(e.startsWith(\"https://www.googleapis.com/storage/v1/b\")){const n=e.indexOf(\"/v1/b/\",8),r=e.indexOf(\"/o/\",n);if(r>0){const s=e.indexOf(\"?\",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}if(t&&i)return{bucket:t,object:i};throw Error(`Unrecognized Google Storage URI: ${e}`)}(e);i=function(e){let t=\"\";return e.split(\"\").forEach((function(e){Ds.has(e)?t+=Ds.get(e):t+=e})),t}(i);const n=e.indexOf(\"?\");return`https://storage.googleapis.com/storage/v1/b/${t}/o/${i}${n>0?e.substring(n)+\"&alt=media\":\"?alt=media\"}`}const Ds=new Map;function Ts(){return window.google&&window.google.igv}async function Ls(e){if(!Ts())throw Error(\"Google oAuth has not been initialized\");if(google.igv.tokenResponse&&Date.now(){try{t.callback=e=>{void 0!==e.error&&n(e),google.igv.tokenResponse=e,google.igv.tokenExpiresAt=Date.now()+1e3*e.expires_in,i(e.access_token)},t.requestAccessToken({scope:e})}catch(e){console.log(e)}}))}}function zs(){return google.igv.apiKey}function Hs(e){var t=Ps(e);return t?\"https://www.googleapis.com/drive/v3/files/\"+t+\"?alt=media&supportsTeamDrives=true\":e}function Ps(e){if(e.includes(\"/open?id=\")){const t=e.indexOf(\"/open?id=\")+9,i=e.indexOf(\"&\");if(t>0&&i>t)return e.substring(t,i);if(t>0)return e.substring(t)}else{if(e.includes(\"/file/d/\")){const t=e.indexOf(\"/file/d/\")+8,i=e.lastIndexOf(\"/\");return e.substring(t,i)}if(e.startsWith(\"https://www.googleapis.com/drive\")){let t=e.indexOf(\"/files/\");const i=e.indexOf(\"?\");if(t>0)return t+=7,i>0?e.substring(t,i):e.substring(t)}}throw Error(\"Unknown Google Drive url format: \"+e)}Ds.set(\"!\",\"%21\"),Ds.set(\"#\",\"%23\"),Ds.set(\"$\",\"%24\"),Ds.set(\"%\",\"%25\"),Ds.set(\"&\",\"%26\"),Ds.set(\"'\",\"%27\"),Ds.set(\"(\",\"%28\"),Ds.set(\")\",\"%29\"),Ds.set(\"*\",\"%2A\"),Ds.set(\"+\",\"%2B\"),Ds.set(\",\",\"%2C\"),Ds.set(\"/\",\"%2F\"),Ds.set(\":\",\"%3A\"),Ds.set(\";\",\"%3B\"),Ds.set(\"=\",\"%3D\"),Ds.set(\"?\",\"%3F\"),Ds.set(\"@\",\"%40\"),Ds.set(\"[\",\"%5B\"),Ds.set(\"]\",\"%5D\"),Ds.set(\" \",\"%20\");class Os{constructor(e){this.requestsPerSecond=e.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(e,t){var i=this;return new Promise((function(t,n){i.queued.push({resolve:t,reject:n,asyncFunction:e}),i.dequeue()}))}addAll(e,t){var i=e.map(function(e){return this.add(e,t)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var e=new Date,t=1e3/this.requestsPerSecond+1,i=e-this.lastStartTime;i>=t?this._execute():setTimeout(function(){this.dequeue()}.bind(this),t-i)}}async _execute(){this.lastStartTime=new Date;var e=this.queued.shift();const t=e.asyncFunction;try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}}}function Us(){if(Ts()){return Ts()&&google.igv.tokenResponse&&Date.now()0)for(var o=0;othis._loadURL(e,t))):this._loadURL(e,t)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async _loadURL(e,t){const i=this,n=e;e=function(e){return e.startsWith(\"https://www.dropbox.com\")?e.replace(\"//www.dropbox.com\",\"//dl.dropboxusercontent.com\"):e.startsWith(\"https://drive.google.com\")?Hs(e):e.includes(\"//www.broadinstitute.org/igvdata\")?e.replace(\"//www.broadinstitute.org/igvdata\",\"//data.broadinstitute.org/igvdata\"):e.includes(\"//igvdata.broadinstitute.org\")?e.replace(\"//igvdata.broadinstitute.org\",\"//s3.amazonaws.com/igv.broadinstitute.org\"):e.includes(\"//igv.genepattern.org\")?e.replace(\"//igv.genepattern.org\",\"//igv-genepattern-org.s3.amazonaws.com\"):e.startsWith(\"ftp://ftp.ncbi.nlm.nih.gov/geo\")?e.replace(\"ftp://\",\"https://\"):e}(e);let r=(t=t||{}).oauthToken||this.getOauthToken(e);return r&&(r=await(\"function\"==typeof r?r():r)),new Promise((function(s,o){Ns(e)&&!function(e){return e.indexOf(\"X-Goog-Signature\")>-1}(e)&&(Bs(e)&&(e=Rs(e)),Ms(e=function(e){let t=Qs.apiKey;t||\"undefined\"==typeof gapi||(t=gapi.apiKey);if(void 0!==t&&!e.includes(\"key=\")){const i=e.includes(\"?\")?\"&\":\"?\";e=e+i+\"key=\"+t}return e}(e))&&function(e){if(e.includes(\"supportsTeamDrive\"))return e;{const t=e.includes(\"?\")?\"&\":\"?\";e=e+t+\"supportsTeamDrive=true\"}}(e),r||(r=Us()));const a=t.headers||{};r&&function(e,t){t&&(e[\"Cache-Control\"]=\"no-cache\",e.Authorization=\"Bearer \"+t)}(a,r);const c=t.range,l=new XMLHttpRequest,h=t.sendData||t.body,d=t.method||(h?\"POST\":\"GET\"),u=t.responseType,f=t.contentType,p=t.mimeType;if(l.open(d,e),t.timeout&&(l.timeout=t.timeout),c){let e=\"\";c.size&&(e=c.start+c.size-1),l.setRequestHeader(\"Range\",\"bytes=\"+c.start+\"-\"+e)}if(f&&l.setRequestHeader(\"Content-Type\",f),p&&l.overrideMimeType(p),u&&(l.responseType=u),a)for(let e of Object.keys(a)){const t=a[e];l.setRequestHeader(e,t)}!0===t.withCredentials&&(l.withCredentials=!0),l.onload=async function(n){if(0===l.status||l.status>=200&&l.status<=300)if(\"HEAD\"===t.method){const e=t.requestedHeaders||[\"content-length\"],i={};for(let t of e)i[t]=l.getResponseHeader(t);s(i)}else c&&206!==l.status&&0!==c.start?(l.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${e}. This can have severe performance impacts.`),s(l.response.slice(c.start,c.start+c.size))):s(l.response);else 416===l.status?g(Error(\"416 Unsatisfiable Range\")):!Ts()||404!==l.status&&401!==l.status&&403!==l.status||!Ns(e)||t.retries?403===l.status?g(\"Access forbidden: \"+e):g(l.status):m()},l.onerror=function(i){Ns(e)&&!t.retries?m():g(\"Error accessing resource: \"+e+\" Status: \"+l.status)},l.ontimeout=function(e){g(\"Timed out\")},l.onabort=function(e){console.log(\"Aborted\"),o(e)};try{l.send(h)}catch(i){Ns(e)&&!t.retries?m():g(i)}function g(e){if(!o)throw e;o(e)}async function m(){try{const e=await async function(e){if(Ts()){const t=function(e){return Ms(e)?\"https://www.googleapis.com/auth/drive.file\":Bs(e)?\"https://www.googleapis.com/auth/devstorage.read_only\":\"https://www.googleapis.com/auth/userinfo.profile\"}(e);return await Ls(t)}throw Error(\"Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.\")}(n);t.retries=1,t.oauthToken=e;const r=await i.load(n,t);s(r)}catch(e){if(e.error){const t=e.error.startsWith(\"popup_blocked\")?\"Google login popup blocked by browser.\":e.error;alert(t)}else g(e)}}}))}async _loadFileSlice(e,t){let i=t&&t.range?e.slice(t.range.start,t.range.start+t.range.size):e;const n=await i.arrayBuffer();return\"arraybuffer\"===t.responseType?n:qs(n)}async _loadStringFromFile(e,t){const i=t.range?e.slice(t.range.start,t.range.start+t.range.size):e;return qs(await i.arrayBuffer())}async _loadStringFromUrl(e,t){(t=t||{}).responseType=\"arraybuffer\";return qs(await this.load(e,t))}setOauthToken(e,t){this.oauth.setToken(e,t)}getOauthToken(e){const t=Ns(e)?void 0:Ot(e).host;let i=this.oauth.getToken(t);if(i)return i;if(void 0===t){const e=Us();if(e&&e.expires_at>Date.now())return e.access_token}}async getContentLength(e,t){(t=t||{}).method=\"HEAD\",t.requestedHeaders=[\"content-length\"];const i=(await this._loadURL(e,t))[\"content-length\"];return i?Number.parseInt(i):0}};var Vs={color:1};Vs.parent=Vs,Vs.left=Vs,Vs.right=Vs;class js{constructor(){this.root=Vs}insert(e,t,i){var n=new Xs(new Ys(e,t,i));for(this.treeInsert(n),n.color=2;n!==this.root&&2===n.parent.color;)if(n.parent===n.parent.parent.left){let e=n.parent.parent.right;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,Gs.call(this,n)),n.parent.color=1,n.parent.parent.color=2,$s.call(this,n.parent.parent))}else{let e=n.parent.parent.left;2===e.color?(n.parent.color=1,e.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,$s.call(this,n)),n.parent.color=1,n.parent.parent.color=2,Gs.call(this,n.parent.parent))}this.root.color=1}findOverlapping(e,t){var i=new Ys(e,t,0);if(this.root===Vs)return[];var n=Ws.call(this,i,this.root,[]);return n.length>1&&n.sort((function(e,t){return e.low-t.low})),n}logIntervals(){!function e(t,i){for(var n=\"\",r=0;r=e.low&&Ws.call(this,e,t.left,i),t.right!==Vs&&t.right.min<=e.high&&Ws.call(this,e,t.right,i),i}function Gs(e){var t=e.right;e.right=t.left,t.left!==Vs&&(t.left.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,Ks.call(this,e)}function $s(e){var t=e.left;e.left=t.right,t.right!==Vs&&(t.right.parent=e),t.parent=e.parent,e.parent===Vs?this.root=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t,Ks.call(this,e)}function Ks(e){for(;e!==Vs;){var t=e.left.max>e.right.max?e.left.max:e.right.max,i=e.interval.high;e.max=t>i?t:i;var n=e.left.mine.low?1:this.highe.high?1:0}overlaps(e){return this.low<=e.high&&e.low<=this.high}}function Xs(e){this.parent=Vs,this.left=Vs,this.right=Vs,this.interval=e,this.color=2}class Zs{constructor(e,t,i){e=e||[],this.treeMap=this.buildTreeMap(e,t),this.range=i,this.count=e.length}containsRange(e){return void 0===this.range||this.range.contains(e.chr,e.start,e.end)}findFeatures(e){const t=[];for(let i of Object.values(this.allFeatures))for(let n of i)e(n)&&t.push(n);return t}queryFeatures(e,t,i){const n=this.treeMap[e];if(!n)return[];const r=n.findOverlapping(t,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[e];if(s){for(let e of r){const r=e.value;for(let e=r.start;ei)break;r.end>=t&&n.push(r)}}n.sort((function(e,t){return e.start-t.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(e,t){const i={},n=[];if(this.allFeatures={},e){for(let i of e){let e=i.chr;t&&(e=t.getChromosomeName(e));let r=this.allFeatures[e];r||(n.push(e),r=[],this.allFeatures[e]=r),r.push(i)}for(let e of n){const t=this.allFeatures[e];t.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1})),i[e]=Js(t)}}return i}}function Js(e){const t=new js,i=e.length,n=Math.max(10,Math.round(i/10));for(let r=0;rt.start?1:-1}));for(let r=0;ri)break;s.end>t&&e.push(s)}})),e.sort((function(e,t){return e.start-t.start})),e)}return[]};function io(e){if(3===(e=e.replace(/^#/,\"\")).length&&(e=e.split(\"\").map((e=>e+e)).join(\"\")),6!==e.length)throw new Error(\"Invalid HEX color.\");let t=parseInt(e,16);return`rgb(${t>>16&255}, ${t>>8&255}, ${255&t})`}const no={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}};function ro(e){const{r:t,g:i,b:n}=no[e];return`rgb(${t},${i},${n})`}const so={Set1:[\"rgb(228,26,28)\",\"rgb(55,126,184)\",\"rgb(77,175,74)\",\"rgb(166,86,40)\",\"rgb(152,78,163)\",\"rgb(255,127,0)\",\"rgb(247,129,191)\",\"rgb(153,153,153)\",\"rgb(255,255,51)\"],Dark2:[\"rgb(27,158,119)\",\"rgb(217,95,2)\",\"rgb(117,112,179)\",\"rgb(231,41,138)\",\"rgb(102,166,30)\",\"rgb(230,171,2)\",\"rgb(166,118,29)\",\"rgb(102,102,102)\"],Set2:[\"rgb(102, 194,165)\",\"rgb(252,141,98)\",\"rgb(141,160,203)\",\"rgb(231,138,195)\",\"rgb(166,216,84)\",\"rgb(255,217,47)\",\"rgb(229,196,148)\",\"rgb(179,179,179)\"],Set3:[\"rgb(141,211,199)\",\"rgb(255,255,179)\",\"rgb(190,186,218)\",\"rgb(251,128,114)\",\"rgb(128,177,211)\",\"rgb(253,180,98)\",\"rgb(179,222,105)\",\"rgb(252,205,229)\",\"rgb(217,217,217)\",\"rgb(188,128,189)\",\"rgb(204,235,197)\",\"rgb(255,237,111)\"],Pastel1:[\"rgb(251,180,174)\",\"rgb(179,205,227)\",\"rgb(204,235,197)\",\"rgb(222,203,228)\",\"rgb(254,217,166)\",\"rgb(255,255,204)\",\"rgb(229,216,189)\",\"rgb(253,218,236)\"],Pastel2:[\"rgb(173,226,207)\",\"rgb(253,205,172)\",\"rgb(203,213,232)\",\"rgb(244,202,228)\",\"rgb(230,245,201)\",\"rgb(255,242,174)\",\"rgb(243,225,206)\"],Accent:[\"rgb(127,201,127)\",\"rgb(190,174,212)\",\"rgb(253,192,134)\",\"rgb(255,255,153)\",\"rgb(56,108,176)\",\"rgb(240,2,127)\",\"rgb(191,91,23)\"]};class oo{constructor(e){this.colors=so[e],Array.isArray(this.colors)||(this.colors=[]),this.colorTable=new Map,this.nextIdx=0,this.colorGenerator=new co}getColor(e){return this.colorTable.has(e)||(this.nextIdxparseInt(e)))}}co.prototype.hsvToRgb=function(e,t,i){var n=Math.floor(6*e),r=6*e-n,s=i*(1-t),o=i*(1-r*t),a=i*(1-(1-r)*t),c=255,l=255,h=255;switch(n){case 0:c=i,l=a,h=s;break;case 1:c=o,l=i,h=s;break;case 2:c=s,l=i,h=a;break;case 3:c=s,l=o,h=i;break;case 4:c=a,l=s,h=i;break;case 5:c=i,l=s,h=o}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},co.prototype.padHex=function(e){return e.length>this.hexwidth?e:new Array(this.hexwidth-e.length+1).join(\"0\")+e},co.prototype.get=function(e,t){this.hue+=this.goldenRatio,this.hue%=1,\"number\"!=typeof e&&(e=.5),\"number\"!=typeof t&&(t=.95);var i=this.hsvToRgb(this.hue,e,t);return\"#\"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new co;function fo(e,t,i){if(i<.005)return e;if(i>.995)return t;{let n,r,s,o,a,c;i<.5?(i/=.5,[n,r,s]=uo(e),[o,a,c]=uo(ro(\"snow\"))):(i=(i-.5)/.5,[n,r,s]=uo(ro(\"snow\")),[o,a,c]=uo(t));const[l,h,d]=[Math.floor(ys.lerp(n,o,i)),Math.floor(ys.lerp(r,a,i)),Math.floor(ys.lerp(s,c,i))];return function(e,t,i){return`rgb(${e=ys.clamp(e,0,255)}, ${t=ys.clamp(t,0,255)}, ${i=ys.clamp(i,0,255)})`}(l,h,d)}}const po=new Set([\"bedtype\",\"alignment\",\"annotation\",\"variant\",\"wig\",\"interact\",\"shoebox\"]),go=new Set([\"alignment\",\"annotation\",\"variant\",\"eqtl\",\"qtl\",\"snp\",\"shoebox\",\"wig\"]),mo=new Set([\"sequence\",\"ruler\",\"ideogram\"]),wo={};class bo{constructor(e){this.browser=e,this.initialize()}initialize(){const e=new c;e.add(\"...\");const t={parent:this.browser.root,content:e};this.dialog=new w(t),this.browser.root.appendChild(this.dialog.elem),i(this.dialog.elem)}trackMenuItemList(e){const t=[];return\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{const e=parseInt(this.browser.inputDialog.value,10);if(void 0!==e){const t=[];this.trackView.track.selected?t.push(...this.trackView.browser.getSelectedTrackViews().map((({track:e})=>e))):t.push(this);for(const i of t)i.trackView.autoHeight=!1,void 0!==i.minHeight&&i.minHeight>e&&(i.minHeight=e),void 0!==i.maxHeight&&i.maxHeight1&&new Set(t).has(e)}(e)?t.push(...this.multiSelectMenuItems(e)):(\"sequence\"!==e.track.config.type&&t.push(function(){const e=Bt(\"
\");function t(e){const t=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?\"untitled\":e.trim(),this.name=e},i={label:\"Track Name\",value:Ao(this)||\"unnamed\",callback:t};this.browser.inputDialog.present(i,e)}return e.text(\"Set track name\"),{object:e,click:t}}()),t.push(...this.defaultMenuItems(e))),!1!==e.track.removable&&(t.push(\"
\"),t.push(function(e){const t=e.track.selected?\"Remove tracks\":\"Remove track\",i=Bt(\"
\");function n(e){this.trackView.browser._removeTrack(this)}return i.text(t),{object:i,click:n,menuItemType:\"removeTrack\"}}(e))),t}defaultMenuItems(e){const t=[];return Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),e.track.menuItemList&&t.push(...e.track.menuItemList()),function(e){const t=e.track;return t&&t.config&&void 0!==t.config.visibilityWindow||t&&go.has(t.type)}(e)&&(t.push(\"
\"),t.push(function(e){const t=Bt(\"
\");function i(t){const i=()=>{let e=this.browser.inputDialog.value;e=\"\"===e||void 0===e?-1:e.trim(),this.visibilityWindow=Number.parseInt(e),this.config.visibilityWindow=Number.parseInt(e),this.trackView.updateViews()},n={label:\"wig\"===e?\"Visibility window (bp). Enter 0 for whole chromosome, -1 for whole genome.\":\"Visibility window (bp). Enter 0 for whole chromosome.\",value:this.visibilityWindow,callback:i};this.browser.inputDialog.present(n,t)}return t.text(\"Set visibility window\"),{object:t,click:i}}(e.track.type))),t}multiSelectMenuItems(e){const t=[],i=e.browser.getSelectedTrackViews();var n;return!0===(n=i.map((({track:e})=>e.type)),1===[...new Set(n)].length)?(t.push(...this.defaultMenuItems(e)),\"wig\"===e.track.type&&(t.push(\"
\"),t.push(function(){const e=Bt(\"
\");function t(e){const t=so.Dark2,i=Math.floor(Math.random()*t.length),n=`auto-scale-group-${s()}`;wo[n]=t[i];const r=this.browser.getSelectedTrackViews();for(const{track:e}of r)e.autoscaleGroup=n;this.browser.updateViews()}return e.text(\"Group autoscale\"),{object:e,doAllMultiSelectedTracks:!0,click:t}}()))):Co(e.track)&&(t.push(\"
\"),t.push(Fo({trackView:e,label:\"Set track color\",option:\"color\"})),t.push(vo({trackView:e,label:\"Unset track color\"})),\"wig\"!==e.track.config.type&&\"annotation\"!==e.track.config.type||(t.push(Fo({trackView:e,label:\"Set alt color\",option:\"altColor\"})),t.push(yo({trackView:e,label:\"Unset alt color\"})))),t}}function Fo({trackView:e,label:t,option:i}){const n=Bt(\"
\");return n.text(t),{object:n,click:()=>e.presentColorPicker(i)}}function vo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.color=void 0,e.repaintViews()}}}function yo({trackView:e,label:t}){const i=Bt(\"
\");return i.text(t),{object:i,click:()=>{e.track.altColor=void 0,e.repaintViews()}}}function Ao(e){return e.name}function Co(e){return void 0===e.type||po.has(e.type)}class _o{constructor(e,t){this.browser=e,this.$container=Bt(\"
\",{class:\"igv-generic-dialog-container\"}),t.append(this.$container),this.$container.offset({left:0,top:0});const i=Bt(\"
\",{class:\"igv-generic-dialog-header\"});this.$container.append(i),u(i[0],(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$minimum);const n=Bt(\"
\");n.text(\"Minimum\"),this.$minimum.append(n),this.$minimum_input=Bt(\"\"),this.$minimum.append(this.$minimum_input),this.$maximum=Bt(\"
\",{class:\"igv-generic-dialog-label-input\"}),this.$container.append(this.$maximum);const r=Bt(\"
\");r.text(\"Maximum\"),this.$maximum.append(r),this.$maximum_input=Bt(\"\"),this.$maximum.append(this.$maximum_input);const s=Bt(\"
\",{class:\"igv-generic-dialog-ok-cancel\"});this.$container.append(s),this.$ok=Bt(\"
\"),s.append(this.$ok),this.$ok.text(\"OK\"),this.$cancel=Bt(\"
\"),s.append(this.$cancel),this.$cancel.text(\"Cancel\"),this.$cancel.on(\"click\",(()=>{this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\"),this.$container.offset({left:0,top:0}),this.$container.hide()})),p(this.$container.get(0),i.get(0)),this.$container.hide()}configure(e){let t;if(Array.isArray(e)){t={min:Number.MAX_SAFE_INTEGER,max:-Number.MAX_SAFE_INTEGER};for(const i of e)i.track.dataRange&&(t.min=Math.min(i.track.dataRange.min,t.min),t.max=Math.max(i.track.dataRange.max,t.max))}else t=e.track.dataRange;t&&(this.$minimum_input.val(t.min),this.$maximum_input.val(t.max)),this.$minimum_input.unbind(),this.$minimum_input.on(\"keyup\",(t=>{13===t.keyCode&&this.processResults(e),t.stopImmediatePropagation()})),this.$maximum_input.unbind(),this.$maximum_input.on(\"keyup\",(t=>{13===t.keyCode&&(t.stopImmediatePropagation(),this.processResults(e))})),this.$ok.unbind(),this.$ok.on(\"click\",(t=>{this.processResults(e)}))}processResults(e){if(\"\"!==this.$minimum_input.val()&&\"\"!==this.$maximum_input.val()){const t=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());if(isNaN(t)||isNaN(i))this.browser.alert.present(new Error(\"Must input numeric values\"),void 0);else{const n=Array.isArray(e)?e:[e];for(const e of n)e.track.setDataRange({min:t,max:i})}this.$minimum_input.val(\"\"),this.$maximum_input.val(\"\")}this.$container.offset({left:0,top:0}),this.$container.hide()}present(e){const t=e.offset().top,i=Bt(\"body\").scrollTop();this.$container.offset({left:e.width()-this.$container.width(),top:t+i}),this.$container.show()}}const xo={configureHighDPICanvas:function(e,t,i){const n=window.devicePixelRatio;e.canvas.style.width=`${t}px`,e.canvas.width=Math.floor(n*t),e.canvas.style.height=`${i}px`,e.canvas.height=Math.floor(n*i),e.scale(n,n)},setProperties:function(e,t){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];e[i]=n}},strokeLine:function(e,t,i,n,r,s){t=Math.floor(t)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(e.save(),xo.setProperties(e,s)),e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke(),s&&e.restore()},fillRect:function(e,t,i,n,r,s){s&&(e.save(),xo.setProperties(e,s)),e.fillRect(t,i,n,r),s&&e.restore()},fillPolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.fill(),n&&e.restore()},strokePolygon:function(e,t,i,n){n&&(e.save(),xo.setProperties(e,n)),ko(e,t,i),e.stroke(),n&&e.restore()},fillText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.fillText(t,0,0)}else e.fillText(t,i,n);(r||s)&&e.restore()},strokeText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&xo.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];\"translate\"===o&&e.translate(a.x,a.y),\"rotate\"===o&&e.rotate(a.angle*Math.PI/180)}e.strokeText(t,0,0)}else e.strokeText(t,i,n);(r||s)&&e.restore()},strokeCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.stroke(),r&&e.restore()},fillCircle:function(e,t,i,n,r){r&&(e.save(),xo.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.fill(),r&&e.restore()},drawArrowhead:function(e,t,i,n,r){e.save(),n||(n=5),r&&(e.lineWidth=r),e.beginPath(),e.moveTo(t,i-n/2),e.lineTo(t,i+n/2),e.lineTo(t+n,i),e.lineTo(t,i-n/2),e.closePath(),e.fill(),e.restore()},dashedLine:function(e,t,i,n,r,s,o={}){void 0===s&&(s=2),e.setLineDash([s,s]),xo.strokeLine(e,t,i,n,r,o),e.setLineDash([])},roundRect:function(e,t,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),e.beginPath(),e.moveTo(t+s,i),e.lineTo(t+n-s,i),e.quadraticCurveTo(t+n,i,t+n,i+s),e.lineTo(t+n,i+r-s),e.quadraticCurveTo(t+n,i+r,t+n-s,i+r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t,i+r,t,i+r-s),e.lineTo(t,i+s),e.quadraticCurveTo(t,i,t+s,i),e.closePath(),a&&e.stroke(),o&&e.fill()},polygon:function(e,t,i,n,r){void 0===r&&(r=!0),e.beginPath();var s=t.length;e.moveTo(t[0],i[0]);for(var o=1;o{for(let t=0;t{e.translate(t,0),e.scale(-1,1),e.translate(-t,0)}};function ko(e,t,i){var n,r=t.length;for(e.beginPath(),e.moveTo(t[0],i[0]),n=1;n1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:Oo;So&&So(e,null);let n=t.length;for(;n--;){let r=t[n];if(\"string\"==typeof r){const e=i(r);e!==r&&(Eo(t)||(t[n]=e),r=e)}e[r]=!0}return e}function Zo(e){for(let t=0;t/gm),pa=Ro(/\\${[\\w\\W]*}/gm),ga=Ro(/^data-[\\-\\w.\\u00B7-\\uFFFF]/),ma=Ro(/^aria-[\\-\\w]+$/),wa=Ro(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i),ba=Ro(/^(?:\\w+script|data):/i),Fa=Ro(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g),va=Ro(/^html$/i),ya=Ro(/^[a-z][.\\w]*(-[.\\w]+)+$/i);var Aa=Object.freeze({__proto__:null,MUSTACHE_EXPR:ua,ERB_EXPR:fa,TMPLIT_EXPR:pa,DATA_ATTR:ga,ARIA_ATTR:ma,IS_ALLOWED_URI:wa,IS_SCRIPT_OR_DATA:ba,ATTR_WHITESPACE:Fa,DOCTYPE_NAME:va,CUSTOM_ELEMENT:ya});const Ca=1,_a=3,xa=7,ka=8,Ia=9,Sa=function(){return\"undefined\"==typeof window?null:window};var Ea=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Sa();const i=t=>e(t);if(i.version=\"3.1.6\",i.removed=[],!t||!t.document||t.document.nodeType!==Ia)return i.isSupported=!1,i;let{document:n}=t;const r=n,s=r.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:h,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:p}=t,g=l.prototype,m=ea(g,\"cloneNode\"),w=ea(g,\"remove\"),b=ea(g,\"nextSibling\"),F=ea(g,\"childNodes\"),v=ea(g,\"parentNode\");if(\"function\"==typeof a){const e=n.createElement(\"template\");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let y,A=\"\";const{implementation:C,createNodeIterator:_,createDocumentFragment:x,getElementsByTagName:k}=n,{importNode:I}=r;let S={};i.isSupported=\"function\"==typeof Io&&\"function\"==typeof v&&C&&void 0!==C.createHTMLDocument;const{MUSTACHE_EXPR:E,ERB_EXPR:N,TMPLIT_EXPR:B,DATA_ATTR:M,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:D,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:L}=Aa;let{IS_ALLOWED_URI:z}=Aa,H=null;const P=Xo({},[...ta,...ia,...na,...sa,...aa]);let O=null;const U=Xo({},[...ca,...la,...ha,...da]);let q=Object.seal(Do(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Q=null,V=null,j=!0,W=!0,G=!1,$=!0,K=!1,Y=!0,X=!1,Z=!1,J=!1,ee=!1,te=!1,ie=!1,ne=!0,re=!1,se=!0,oe=!1,ae={},ce=null;const le=Xo({},[\"annotation-xml\",\"audio\",\"colgroup\",\"desc\",\"foreignobject\",\"head\",\"iframe\",\"math\",\"mi\",\"mn\",\"mo\",\"ms\",\"mtext\",\"noembed\",\"noframes\",\"noscript\",\"plaintext\",\"script\",\"style\",\"svg\",\"template\",\"thead\",\"title\",\"video\",\"xmp\"]);let he=null;const de=Xo({},[\"audio\",\"video\",\"img\",\"source\",\"image\",\"track\"]);let ue=null;const fe=Xo({},[\"alt\",\"class\",\"for\",\"id\",\"label\",\"name\",\"pattern\",\"placeholder\",\"role\",\"summary\",\"title\",\"value\",\"style\",\"xmlns\"]),pe=\"http://www.w3.org/1998/Math/MathML\",ge=\"http://www.w3.org/2000/svg\",me=\"http://www.w3.org/1999/xhtml\";let we=me,be=!1,Fe=null;const ve=Xo({},[pe,ge,me],Uo);let ye=null;const Ae=[\"application/xhtml+xml\",\"text/html\"];let Ce=null,_e=null;const xe=n.createElement(\"form\"),ke=function(e){return e instanceof RegExp||e instanceof Function},Ie=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!_e||_e!==e){if(e&&\"object\"==typeof e||(e={}),e=Jo(e),ye=-1===Ae.indexOf(e.PARSER_MEDIA_TYPE)?\"text/html\":e.PARSER_MEDIA_TYPE,Ce=\"application/xhtml+xml\"===ye?Uo:Oo,H=Wo(e,\"ALLOWED_TAGS\")?Xo({},e.ALLOWED_TAGS,Ce):P,O=Wo(e,\"ALLOWED_ATTR\")?Xo({},e.ALLOWED_ATTR,Ce):U,Fe=Wo(e,\"ALLOWED_NAMESPACES\")?Xo({},e.ALLOWED_NAMESPACES,Uo):ve,ue=Wo(e,\"ADD_URI_SAFE_ATTR\")?Xo(Jo(fe),e.ADD_URI_SAFE_ATTR,Ce):fe,he=Wo(e,\"ADD_DATA_URI_TAGS\")?Xo(Jo(de),e.ADD_DATA_URI_TAGS,Ce):de,ce=Wo(e,\"FORBID_CONTENTS\")?Xo({},e.FORBID_CONTENTS,Ce):le,Q=Wo(e,\"FORBID_TAGS\")?Xo({},e.FORBID_TAGS,Ce):{},V=Wo(e,\"FORBID_ATTR\")?Xo({},e.FORBID_ATTR,Ce):{},ae=!!Wo(e,\"USE_PROFILES\")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,W=!1!==e.ALLOW_DATA_ATTR,G=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,K=e.SAFE_FOR_TEMPLATES||!1,Y=!1!==e.SAFE_FOR_XML,X=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,se=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,z=e.ALLOWED_URI_REGEXP||wa,we=e.NAMESPACE||me,q=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(q.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ke(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(q.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&\"boolean\"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(q.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),K&&(W=!1),te&&(ee=!0),ae&&(H=Xo({},aa),O=[],!0===ae.html&&(Xo(H,ta),Xo(O,ca)),!0===ae.svg&&(Xo(H,ia),Xo(O,la),Xo(O,da)),!0===ae.svgFilters&&(Xo(H,na),Xo(O,la),Xo(O,da)),!0===ae.mathMl&&(Xo(H,sa),Xo(O,ha),Xo(O,da))),e.ADD_TAGS&&(H===P&&(H=Jo(H)),Xo(H,e.ADD_TAGS,Ce)),e.ADD_ATTR&&(O===U&&(O=Jo(O)),Xo(O,e.ADD_ATTR,Ce)),e.ADD_URI_SAFE_ATTR&&Xo(ue,e.ADD_URI_SAFE_ATTR,Ce),e.FORBID_CONTENTS&&(ce===le&&(ce=Jo(ce)),Xo(ce,e.FORBID_CONTENTS,Ce)),se&&(H[\"#text\"]=!0),X&&Xo(H,[\"html\",\"head\",\"body\"]),H.table&&(Xo(H,[\"tbody\"]),delete Q.tbody),e.TRUSTED_TYPES_POLICY){if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');if(\"function\"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw $o('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');y=e.TRUSTED_TYPES_POLICY,A=y.createHTML(\"\")}else void 0===y&&(y=function(e,t){if(\"object\"!=typeof e||\"function\"!=typeof e.createPolicy)return null;let i=null;const n=\"data-tt-policy-suffix\";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r=\"dompurify\"+(i?\"#\"+i:\"\");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn(\"TrustedTypes policy \"+r+\" could not be created.\"),null}}(p,s)),null!==y&&\"string\"==typeof A&&(A=y.createHTML(\"\"));Mo&&Mo(e),_e=e}},Se=Xo({},[\"mi\",\"mo\",\"mn\",\"ms\",\"mtext\"]),Ee=Xo({},[\"foreignobject\",\"annotation-xml\"]),Ne=Xo({},[\"title\",\"style\",\"font\",\"a\",\"script\"]),Be=Xo({},[...ia,...na,...ra]),Me=Xo({},[...sa,...oa]),Re=function(e){Po(i.removed,{element:e});try{v(e).removeChild(e)}catch(t){w(e)}},De=function(e,t){try{Po(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Po(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),\"is\"===e&&!O[e])if(ee||te)try{Re(t)}catch(e){}else try{t.setAttribute(e,\"\")}catch(e){}},Te=function(e){let t=null,i=null;if(J)e=\"\"+e;else{const t=qo(e,/^[\\r\\n\\t ]+/);i=t&&t[0]}\"application/xhtml+xml\"===ye&&we===me&&(e=''+e+\"\");const r=y?y.createHTML(e):e;if(we===me)try{t=(new f).parseFromString(r,ye)}catch(e){}if(!t||!t.documentElement){t=C.createDocument(we,\"template\",null);try{t.documentElement.innerHTML=be?A:r}catch(e){}}const s=t.body||t.documentElement;return e&&i&&s.insertBefore(n.createTextNode(i),s.childNodes[0]||null),we===me?k.call(t,X?\"html\":\"body\")[0]:X?t.documentElement:s},Le=function(e){return _.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},ze=function(e){return e instanceof u&&(\"string\"!=typeof e.nodeName||\"string\"!=typeof e.textContent||\"function\"!=typeof e.removeChild||!(e.attributes instanceof d)||\"function\"!=typeof e.removeAttribute||\"function\"!=typeof e.setAttribute||\"string\"!=typeof e.namespaceURI||\"function\"!=typeof e.insertBefore||\"function\"!=typeof e.hasChildNodes)},He=function(e){return\"function\"==typeof c&&e instanceof c},Pe=function(e,t,n){S[e]&&zo(S[e],(e=>{e.call(i,t,n,_e)}))},Oe=function(e){let t=null;if(Pe(\"beforeSanitizeElements\",e,null),ze(e))return Re(e),!0;const n=Ce(e.nodeName);if(Pe(\"uponSanitizeElement\",e,{tagName:n,allowedTags:H}),e.hasChildNodes()&&!He(e.firstElementChild)&&Go(/<[/\\w]/g,e.innerHTML)&&Go(/<[/\\w]/g,e.textContent))return Re(e),!0;if(e.nodeType===xa)return Re(e),!0;if(Y&&e.nodeType===ka&&Go(/<[/\\w]/g,e.data))return Re(e),!0;if(!H[n]||Q[n]){if(!Q[n]&&qe(n)){if(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,n))return!1;if(q.tagNameCheck instanceof Function&&q.tagNameCheck(n))return!1}if(se&&!ce[n]){const t=v(e)||e.parentNode,i=F(e)||e.childNodes;if(i&&t){for(let n=i.length-1;n>=0;--n){const r=m(i[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,b(e))}}}return Re(e),!0}return e instanceof l&&!function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:we,tagName:\"template\"});const i=Oo(e.tagName),n=Oo(t.tagName);return!!Fe[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?\"svg\"===i:t.namespaceURI===pe?\"svg\"===i&&(\"annotation-xml\"===n||Se[n]):Boolean(Be[i]):e.namespaceURI===pe?t.namespaceURI===me?\"math\"===i:t.namespaceURI===ge?\"math\"===i&&Ee[n]:Boolean(Me[i]):e.namespaceURI===me?!(t.namespaceURI===ge&&!Ee[n])&&!(t.namespaceURI===pe&&!Se[n])&&!Me[i]&&(Ne[i]||!Be[i]):!(\"application/xhtml+xml\"!==ye||!Fe[e.namespaceURI]))}(e)?(Re(e),!0):\"noscript\"!==n&&\"noembed\"!==n&&\"noframes\"!==n||!Go(/<\\/no(script|embed|frames)/i,e.innerHTML)?(K&&e.nodeType===_a&&(t=e.textContent,zo([E,N,B],(e=>{t=Qo(t,e,\" \")})),e.textContent!==t&&(Po(i.removed,{element:e.cloneNode()}),e.textContent=t)),Pe(\"afterSanitizeElements\",e,null),!1):(Re(e),!0)},Ue=function(e,t,i){if(ne&&(\"id\"===t||\"name\"===t)&&(i in n||i in xe))return!1;if(W&&!V[t]&&Go(M,t));else if(j&&Go(R,t));else if(!O[t]||V[t]){if(!(qe(e)&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,e)||q.tagNameCheck instanceof Function&&q.tagNameCheck(e))&&(q.attributeNameCheck instanceof RegExp&&Go(q.attributeNameCheck,t)||q.attributeNameCheck instanceof Function&&q.attributeNameCheck(t))||\"is\"===t&&q.allowCustomizedBuiltInElements&&(q.tagNameCheck instanceof RegExp&&Go(q.tagNameCheck,i)||q.tagNameCheck instanceof Function&&q.tagNameCheck(i))))return!1}else if(ue[t]);else if(Go(z,Qo(i,T,\"\")));else if(\"src\"!==t&&\"xlink:href\"!==t&&\"href\"!==t||\"script\"===e||0!==Vo(i,\"data:\")||!he[e]){if(G&&!Go(D,Qo(i,T,\"\")));else if(i)return!1}else;return!0},qe=function(e){return\"annotation-xml\"!==e&&qo(e,L)},Qe=function(e){Pe(\"beforeSanitizeAttributes\",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:\"\",attrValue:\"\",keepAttr:!0,allowedAttributes:O};let r=t.length;for(;r--;){const s=t[r],{name:o,namespaceURI:a,value:c}=s,l=Ce(o);let h=\"value\"===o?c:jo(c);if(n.attrName=l,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Pe(\"uponSanitizeAttribute\",e,n),h=n.attrValue,Y&&Go(/((--!?|])>)|<\\/(style|title)/i,h)){De(o,e);continue}if(n.forceKeepAttr)continue;if(De(o,e),!n.keepAttr)continue;if(!$&&Go(/\\/>/i,h)){De(o,e);continue}K&&zo([E,N,B],(e=>{h=Qo(h,e,\" \")}));const d=Ce(e.nodeName);if(Ue(d,l,h)){if(!re||\"id\"!==l&&\"name\"!==l||(De(o,e),h=\"user-content-\"+h),y&&\"object\"==typeof p&&\"function\"==typeof p.getAttributeType)if(a);else switch(p.getAttributeType(d,l)){case\"TrustedHTML\":h=y.createHTML(h);break;case\"TrustedScriptURL\":h=y.createScriptURL(h)}try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),ze(e)?Re(e):Ho(i.removed)}catch(e){}}}Pe(\"afterSanitizeAttributes\",e,null)},Ve=function e(t){let i=null;const n=Le(t);for(Pe(\"beforeSanitizeShadowDOM\",t,null);i=n.nextNode();)Pe(\"uponSanitizeShadowNode\",i,null),Oe(i)||(i.content instanceof o&&e(i.content),Qe(i));Pe(\"afterSanitizeShadowDOM\",t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,a=null,l=null;if(be=!e,be&&(e=\"\\x3c!--\\x3e\"),\"string\"!=typeof e&&!He(e)){if(\"function\"!=typeof e.toString)throw $o(\"toString is not a function\");if(\"string\"!=typeof(e=e.toString()))throw $o(\"dirty is not a string, aborting\")}if(!i.isSupported)return e;if(Z||Ie(t),i.removed=[],\"string\"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Ce(e.nodeName);if(!H[t]||Q[t])throw $o(\"root node is forbidden and cannot be sanitized in-place\")}}else if(e instanceof c)n=Te(\"\\x3c!----\\x3e\"),s=n.ownerDocument.importNode(e,!0),s.nodeType===Ca&&\"BODY\"===s.nodeName||\"HTML\"===s.nodeName?n=s:n.appendChild(s);else{if(!ee&&!K&&!X&&-1===e.indexOf(\"<\"))return y&&ie?y.createHTML(e):e;if(n=Te(e),!n)return ee?null:ie?A:\"\"}n&&J&&Re(n.firstChild);const h=Le(oe?e:n);for(;a=h.nextNode();)Oe(a)||(a.content instanceof o&&Ve(a.content),Qe(a));if(oe)return e;if(ee){if(te)for(l=x.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(O.shadowroot||O.shadowrootmode)&&(l=I.call(r,l,!0)),l}let d=X?n.outerHTML:n.innerHTML;return X&&H[\"!doctype\"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Go(va,n.ownerDocument.doctype.name)&&(d=\"\\n\"+d),K&&zo([E,N,B],(e=>{d=Qo(d,e,\" \")})),y&&ie?y.createHTML(d):d},i.setConfig=function(){Ie(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Z=!0},i.clearConfig=function(){_e=null,Z=!1},i.isValidAttribute=function(e,t,i){_e||Ie({});const n=Ce(e),r=Ce(t);return Ue(n,r,i)},i.addHook=function(e,t){\"function\"==typeof t&&(S[e]=S[e]||[],Po(S[e],t))},i.removeHook=function(e){if(S[e])return Ho(S[e])},i.removeHooks=function(e){S[e]&&(S[e]=[])},i.removeAllHooks=function(){S={}},i}();class Na{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container),this._input=document.createElement(\"input\"),this.input_container.appendChild(this._input);const r=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(r),this.ok=e(),r.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),r.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"keyup\",(e=>{\"Enter\"===e.code&&(\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)),e.stopImmediatePropagation()})),this.ok.addEventListener(\"click\",(()=>{\"function\"==typeof this.callback&&(this.callback(this._input.value),this.callback=void 0),this._input.value=void 0,i(this.container)}));const s=()=>{this._input.value=\"\",i(this.container)};this.cancel.addEventListener(\"click\",s),u(n,s),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._input.value=e.value,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ba={licorice:\"#000000\",lead:\"#1e1e1e\",tungsten:\"#3a3a3a\",iron:\"#545453\",steel:\"#6e6e6e\",tin:\"#878687\",nickel:\"#888787\",aluminum:\"#a09fa0\",magnesium:\"#b8b8b8\",silver:\"#d0d0d0\",mercury:\"#e8e8e8\",snow:\"#ffffff\",cayenne:\"#891100\",mocha:\"#894800\",aspargus:\"#888501\",fern:\"#458401\",clover:\"#028401\",moss:\"#018448\",teal:\"#008688\",ocean:\"#004a88\",midnight:\"#001888\",eggplant:\"#491a88\",plum:\"#891e88\",maroon:\"#891648\",maraschino:\"#ff2101\",tangerine:\"#ff8802\",lemon:\"#fffa03\",lime:\"#83f902\",spring:\"#05f802\",seam_foam:\"#03f987\",turquoise:\"#00fdff\",aqua:\"#008cff\",blueberry:\"#002eff\",grape:\"#8931ff\",magenta:\"#ff39ff\",strawberry:\"#ff2987\",salmon:\"#ff726e\",cantaloupe:\"#ffce6e\",banana:\"#fffb6d\",honeydew:\"#cefa6e\",flora:\"#68f96e\",spindrift:\"#68fbd0\",ice:\"#68fdff\",sky:\"#6acfff\",orchid:\"#6e76ff\",lavender:\"#d278ff\",bubblegum:\"#ff7aff\",carnation:\"#ff7fd3\"};class Ma{constructor({parent:t,top:n,left:r,width:s,height:o,border:a,closeHandler:c}){let l=e({class:\"igv-ui-generic-container\"});t.appendChild(l),i(l),this.container=l,void 0!==n&&(this.container.style.top=`${n}px`),void 0!==r&&(this.container.style.left=`${r}px`),void 0!==s&&(this.container.style.width=`${s}px`),void 0!==o&&(this.container.style.height=`${o}px`),a&&(this.container.style.border=a);const h=e();this.container.appendChild(h),u(h,(e=>{i(this.container),\"function\"==typeof c&&c(e)})),p(this.container,h)}show(){n(this.container)}hide(){i(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Ra extends Ma{constructor({parent:e,width:t}){super({parent:e,width:t,border:\"1px solid gray\"})}configure(e,t){this.colorHandlers=t,this.setActiveColorHandler(\"color\"),this.createSwatches(e)}setActiveColorHandler(e){this.activeColorHandler=this.colorHandlers[e]}createSwatches(t){this.container.querySelectorAll(\".igv-ui-color-swatch\").forEach((e=>e.remove()));const i=Object.values(Ba);for(let t of i){const i=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(i),this.decorateSwatch(i,t)}if(t)for(let i of t){const t=e({class:\"igv-ui-color-swatch\"});this.container.appendChild(t),this.decorateSwatch(t,i)}}decorateSwatch(e,t){e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(()=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(()=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),this.activeColorHandler(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),this.activeColorHandler(t)}))}}const Da={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};class Ta{constructor(t,n){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},n),this.container=e({class:\"igv-ui-alert-dialog-container\"}),t.appendChild(this.container),this.container.setAttribute(\"tabIndex\",\"-1\");const r=e();this.container.appendChild(r),this.errorHeadline=e(),r.appendChild(this.errorHeadline),this.errorHeadline.textContent=\"\";let s=e({class:\"igv-ui-alert-dialog-body\"});this.container.appendChild(s),this.body=e({class:\"igv-ui-alert-dialog-body-copy\"}),s.appendChild(this.body);let o=e();this.container.appendChild(o),this.ok=e(),o.appendChild(this.ok),this.ok.textContent=\"OK\";const a=()=>{\"function\"==typeof this.callback&&(this.callback(\"OK\"),this.callback=void 0),this.body.innerHTML=\"\",i(this.container)};this.ok.addEventListener(\"click\",(e=>{e.stopPropagation(),a()})),this.container.addEventListener(\"keypress\",(e=>{e.stopPropagation(),\"Enter\"===e.key&&a()})),p(this.container,r),i(this.container)}present(e,t){this.errorHeadline.textContent=e.message?\"ERROR\":\"\";let i=e.message||e;Da.hasOwnProperty(i)&&(i=Da[i]);const r=Ea.sanitize(i);this.body.innerHTML=r,this.callback=t,n(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class La{constructor(e){this.dialog=new Ta(e)}present(e,t){this.dialog.present(e,t)}}function za(e){if(e)switch(e.toLowerCase()){case\"bw\":case\"bigwig\":case\"wig\":case\"bedgraph\":case\"tdf\":return\"wig\";case\"vcf\":return\"variant\";case\"seg\":return\"seg\";case\"mut\":case\"maf\":return\"mut\";case\"bam\":case\"cram\":return\"alignment\";case\"hiccups\":case\"bedpe\":case\"bedpe-loop\":case\"biginteract\":return\"interact\";case\"bp\":return\"arc\";case\"gwas\":return\"gwas\";case\"bed\":case\"bigbed\":case\"bb\":case\"biggenepred\":case\"bignarrowpeak\":return\"bedtype\";case\"fasta\":return\"sequence\";case\"pytor\":return\"cnvpytor\";case\"qtl\":return\"qtl\";default:return\"annotation\"}}function Ha(e){e.featureType&&(e.type=e.type||e.featureType,e.featureType=void 0),\"junctions\"===e.type?e.type=\"junction\":\"bed\"===e.type?(e.type=\"annotation\",e.format=e.format||\"bed\"):\"annotations\"===e.type?e.type=\"annotation\":\"alignments\"===e.type?e.type=\"alignment\":\"bam\"===e.type?(e.type=\"alignment\",e.format=\"bam\"):\"vcf\"===e.type?(e.type=\"variant\",e.format=\"vcf\"):\"t2d\"===e.type?e.type=\"gwas\":\"FusionJuncSpan\"!==e.type||e.format?\"aed\"===e.type&&(e.type=\"annotation\",e.format=e.format||\"aed\"):e.format=\"fusionjuncspan\"}var Pa=Object.freeze({__proto__:null,inferTrackType:za,translateDeprecatedTypes:Ha});function Oa(e){const t=new Set([\"boolean\",\"number\",\"string\",\"symbol\"]),i=typeof e;return void 0!==e&&(t.has(i)||e.substring||e.toFixed)}function Ua(e,t){var i={oauthToken:e.oauthToken,headers:e.headers,withCredentials:e.withCredentials,filename:e.filename};return Object.assign(i,t)}const qa=function(e){var t,i;if(e&&e.length>0){t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of e)Number.isNaN(n.value)||(t=Math.min(t,n.value),i=Math.max(i,n.value));i>0&&(t=Math.min(0,t)),i<0&&(i=0)}else t=0,i=100;return{min:t,max:i}},Qa=function(e,t,i){let n=t.start,r=t.end;if(void 0===r)n-=i/2,r=n+i,r>e?(r=e,n=r-i):n<0&&(n=0,r=i);else if(r-ne?(r=e,n=r-i):(n=t-i/2,r=n+i)}t.start=Math.ceil(n),t.end=Math.floor(r)},Va=function(e){return\"number\"==typeof e?e-e==0:\"string\"==typeof e&&\"\"!==e.trim()&&Number.isFinite(+e)};async function ja(e){if(Mt(e)&&e.startsWith(\"https://drive.google.com\")){if(void 0===zs())throw Error(\"Google drive is referenced, but API key is not defined. An API key is required for Google Drive access\");const t=await async function(e){let t=\"https://www.googleapis.com/drive/v3/files/\"+Ps(e)+\"?supportsTeamDrives=true\";const i=zs();i&&(t+=\"&key=\"+i);const n=await fetch(t);let r=await n.json();if(r.error&&404===r.error.code){let e=\"https://www.googleapis.com/auth/drive.readonly\";const i=await Ls(e);if(!i)throw Error(r.error);{const e=await fetch(t,{headers:{Authorization:`Bearer ${i}`}});if(r=await e.json(),r.error)throw Error(r.error)}}return r}(e);return t.originalFileName||t.name}return zt(e)}function Wa(e){var t,i;return e>1e7?(t=\" mb\",i=e/1e6,Math.floor(i).toString()+t):e>1e4?(t=\" kb\",i=e/1e3,Rt(Math.floor(i))+t):Rt(e)+\" bp\"}function Ga(e){return Mt(e)&&e.startsWith(\"data:\")}function $a(t,i){const n=e({class:i});t.appendChild(n)}function Ka(e,t){t.parentNode.insertBefore(e,t)}function Ya(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function Xa(){return\"https:\"===window.location.protocol||\"localhost\"===window.location.hostname}class Za extends Ma{constructor({parent:e,top:t,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:e,top:t,left:i,width:n,height:r,border:\"1px solid gray\"}),Ja(this.container,o,s)}}const Ja=(t,i,n)=>{const r=Object.values(Ba);for(let n of r){const r=e({class:\"igv-ui-color-swatch\"});t.appendChild(r),ec(r,n,i)}if(n)for(let r of n){const n=e({class:\"igv-ui-color-swatch\"});t.appendChild(n),ec(n,r,i)}},ec=(e,t,i)=>{e.style.backgroundColor=t,e.addEventListener(\"mouseenter\",(i=>e.style.borderColor=t)),e.addEventListener(\"mouseleave\",(t=>e.style.borderColor=\"white\")),e.addEventListener(\"click\",(e=>{e.stopPropagation(),i(t)})),e.addEventListener(\"touchend\",(e=>{e.stopPropagation(),i(t)}))};class tc{constructor(t,i,n,r){this.parent=t,this.popover=e({class:\"igv-ui-popover\"}),t.appendChild(this.popover),this.popoverHeader=e(),this.popover.appendChild(this.popoverHeader);const s=e();this.popoverHeader.appendChild(s),n&&(s.textContent=n);const o=e();this.popoverHeader.appendChild(o),o.appendChild(l(\"times\")),o.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault(),r?r():this.dismiss()})),!0===i&&p(this.popover,this.popoverHeader,{minX:0,minY:0}),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\"}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";const t=this.popover.parentNode,{x:i,y:n,width:r}=a(e,t);this.popover.style.top=`${n}px`;const{width:s}=this.popover.getBoundingClientRect(),o=i+s,c=o-r;this.popover.style.left=`${o>r?i-c:i}px`,this.popoverContent.style.maxWidth=`${Math.min(s,r)}px`}presentContentWithEvent(e,t){this.popover.style.display=\"block\",this.popoverContent.innerHTML=t,ic(e,this.popover,this.popoverContent)}presentMenu(e,t){if(0===t.length)return;this.popover.style.display=\"block\";const i=nc(t,this.popover);for(let e of i)this.popoverContent.appendChild(e.object);ic(e,this.popover,this.popoverContent)}dismiss(){this.popover.style.display=\"none\"}hide(){this.popover.style.display=\"none\",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const e=Object.keys(this);for(let t of e)this[t]=void 0}}function ic(e,t,i){const{x:n,y:r,width:s}=a(e,t.parentNode);t.style.top=`${r}px`;const{width:o}=t.getBoundingClientRect(),c=n+o,l=c-s;t.style.left=`${c>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}function nc(t,n){const r=t.map((function(t,r){let s;if(\"string\"==typeof t)s=e(),s.innerHTML=t;else if(\"Node\"==typeof t)s=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)s=function(t,i){const n=e({class:\"igv-ui-trackgear-popover-check-container\"}),r=h(\"check\",!0===i?\"#444\":\"transparent\");r.style.borderColor=\"gray\",r.style.borderWidth=\"1px\",r.style.borderStyle=\"solid\",n.appendChild(r);let s=e();return s.textContent=t,n.appendChild(s),n}(\"Show all bases\",t.value);else if(\"color\"===t.type){const o=new Za({parent:n.parentElement,width:364,colorHandler:e=>t.click(e)});s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);const a=e=>{o.show(),i(n),e.preventDefault(),e.stopPropagation()};s.addEventListener(\"click\",a),s.addEventListener(\"touchend\",a),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else s=e(),\"string\"==typeof t.label&&(s.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function c(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}s.addEventListener(\"click\",c),s.addEventListener(\"touchend\",c),s.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{object:s,init:t.init}}));return r}const rc=[[\"A\",\"T\"],[\"G\",\"C\"],[\"Y\",\"R\"],[\"W\",\"S\"],[\"K\",\"M\"],[\"D\",\"H\"],[\"B\",\"V\"]],sc=new Map;for(let _A of rc){const xA=_A[0],kA=_A[1];sc.set(xA,kA),sc.set(kA,xA),sc.set(xA.toLowerCase(),kA.toLowerCase()),sc.set(kA.toLowerCase(),xA.toLowerCase())}function oc(e){return sc.has(e)?sc.get(e):e}function ac(e){let t=\"\";for(let i of e)t+=sc.has(i)?sc.get(i):i;return t}function cc(e){let t=\"\",i=e.length;for(;i-- >0;){const n=e[i];t+=sc.has(n)?sc.get(n):n}return t}class lc{constructor(e,t,i,n){this.name=e,this.order=t,this.bpLength=i,this.altNames=n}getAltName(e){return this.altNames&&this.altNames.has(e)?this.altNames.get(e):this.name}}class hc{constructor(e,t,i,n){this.chr=e,this.start=t,this.end=i,this.features=n}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}containsRange(e){return this.chr===e.chr&&this.start<=e.start&&this.end>=e.end}get locusString(){return`${this.chr}:${this.start+1}-${this.end}`}}class dc extends hc{constructor(e,t,i,n){super(e,t,i,n)}getSequence(e,t){if(ethis.end)return null;const i=e-this.start,n=t-e;return this.features?this.features.substring(i,i+n):null}hasSequence(e,t){return e>=this.start&&t<=this.end}}const uc=Dt,fc=new Set([\"fastaURL\",\"indexURL\",\"cytobandURL\",\"indexed\"]);class pc{#e;chromosomes=new Map;sequences=new Map;constructor(e){this.fastaURL=e.fastaURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!fc.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.loadAll()}getSequenceRecord(e){return this.chromosomes.get(e)}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getSequence(e,t,i){if(0===this.sequences.size&&await this.loadAll(),!this.sequences.has(e))return;let n=this.sequences.get(e).find((e=>e.contains(t,i)));if(!n&&(n=this.sequences.get(e).find((e=>e.overlaps(t,i))),!n))return;t-=n.offset,i-=n.offset;let r=\"\";if(t<0)for(let e=t;e\")){a&&a.seq&&c.call(this,a,o++);const e=r.substr(1).split(/\\s+/),t=e[0].split(\":\");if(a.chr=t[0],a.seq=\"\",a.offset=0,t.length>1&&t[1].indexOf(\"-\")>0){const i=t[1].split(\"-\");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),e.length>1&&e[1].startsWith(\"@len=\"))try{a.length=parseInt(e[1].trim().substring(5))}catch(e){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&c.call(this,a,o)}function c(e,i){const n=e.length||e.offset+e.seq.length;if(t.has(e.chr)){const t=this.chromosomes.get(e.chr);t.bpLength=Math.max(t.bpLength,n)}else this.sequences.set(e.chr,[]),this.chromosomes.set(e.chr,new lc(e.chr,i,n)),t.add(e.chr);this.sequences.get(e.chr).push(new gc(e.offset,e.seq))}}getSequenceInterval(e,t,i){const n=this.sequences.get(e);if(n)for(let r of n){const n=r.sequence,s=r.offset,o=s+n.length;if(s<=t&&o>=i)return new dc(e,s,o,n)}}}class gc{constructor(e,t){this.offset=e,this.sequence=t}contains(e,t){return this.offset<=e&&this.end>=t}overlaps(e,t){return this.offsete}get end(){return this.offset+this.sequence.length}}const mc=Dt,wc=new Set([\"fastaURL\",\"indexURL\",\"compressedIndexURL\",\"cytobandURL\",\"indexed\"]);class bc{#e;chromosomes=new Map;constructor(e){this.file=e.fastaURL,this.indexFile=e.indexURL,this.compressedIndexFile=e.compressedIndexURL,this.withCredentials=e.withCredentials;const t={};for(let i in e)e.hasOwnProperty(i)&&!wc.has(i)&&(t[i]=e[i]);this.config=t}getSequenceRecord(e){return this.chromosomes.get(e)}async init(){return this.getIndex()}get chromosomeNames(){return this.#e||(this.#e=Array.from(this.chromosomes.keys())),this.#e}getFirstChromosomeName(){return this.chromosomeNames[0]}async getIndex(){if(this.index)return this.index;{const e=await Qs.load(this.indexFile,Ua(this.config)),t=mc(e),i=t.length;let n=0,r=0;for(this.index={};nthis.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let t=0;te){c=!0;break}t=t)break}const l=i[i.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]0&&(w=Math.min(s-r,a-u),b+=m.substr(F,w),F+=w+l);F1){const e=Number.parseInt(t[1]),n=new lc(t[0],i++,e);this.chromosomes.set(t[0],n)}}}}class yc{constructor(e,t=!0){this.littleEndian=t,this.position=0,this.view=e,this.length=e.byteLength}dumpBytes(e=100){const t=this.position,i=[];for(let t=0;t<=e;t++)i.push(this.getByte());console.log(i.join(\" \")),this.setPosition(t)}setPosition(e){this.position=e}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position=0;i--)t=256*t+e[i];else for(let i=0;i0&&(t+=String.fromCharCode(e))}return t}getFloat(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e}getDouble(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e}skip(e){return this.position+=e,this.position}getVPointer(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Ac(i,t)}}class Ac{constructor(e,t){this.block=e,this.offset=t}isLessThan(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset}isEqualTo(e){return this.block===e.block&&this.offset===e.offset}print(){return this.block+\":\"+this.offset}}class Cc{static magic=2026540177;littleEndian=!0;nodeCache=new Map;static async loadBpTree(e,t,i){return new Cc(e,t,i).init()}constructor(e,t,i){this.path=e,this.config=t,this.startOffset=i}async init(){const e=await this.#t(this.startOffset,32);let t=e.getInt();if(t!==Cc.magic&&(e.setPosition(0),this.littleEndian=!this.littleEndian,e.littleEndian=this.littleEndian,t=e.getInt(),t!==Cc.magic))throw Error(`Bad magic number ${t}`);const i=e.getInt(),n=e.getInt(),r=e.getInt(),s=e.getLong(),o=e.getLong(),a=this.startOffset+32;return this.header={magic:t,blockSize:i,keySize:n,valSize:r,itemCount:s,reserved:o,nodeOffset:a},this}async search(e){this.header||await this.init();const{keySize:t,valSize:i}=this.header;if(16!==i&&8!==i)throw Error(`Unexpected valSize ${i}`);const n=async e=>{if(this.nodeCache.has(e))return this.nodeCache.get(e);{let n=await this.#t(e,4);const r=n.getByte();n.getByte();const s=n.getUShort(),o=[];if(1===r){const r=s*(t+i);n=await this.#t(e+4,r);for(let e=0;e{const i=await n(t);if(1!==i.type){let t=i.items[0].offset;for(let n=1;n>6&3]+_c[IA>>4&3]+_c[IA>>2&3]+_c[3&IA]);const kc=xc.map((e=>e.toLowerCase()));class Ic{littleEndian;metaIndex=new Map;constructor(e){this.url=e.twoBitURL||e.fastaURL,this.config=e,e.twoBitBptURL&&(this.bptURL=e.twoBitBptURL)}async init(){if(this.bptURL)this.index=await Cc.loadBpTree(this.bptURL,this.config,0);else{const e=await this._readIndex();this.index={search:async t=>e.has(t)?{offset:e.get(t)}:void 0}}}async readSequence(e,t,i){this.index||await this.init();const n=await this.getSequenceRecord(e);if(!n)return null;if(t<0)throw new TypeError(\"regionStart cannot be less than 0\");(void 0===i||i>n.dnaSize)&&(i=n.dnaSize);const r=this._getOverlappingBlocks(t,i,n.nBlocks),s=this._getOverlappingBlocks(t,i,n.maskBlocks),o=Math.floor(t/4),a=n.packedPos+o,c=Math.floor(i/4)-o+1,l=await Qs.loadArrayBuffer(this.url,{range:{start:a,size:c}}),h=new Uint8Array(l);let d=\"\";for(let e=t;ee;if(r[0]&&e>=r[0].start&&et)break;r.endn.contains(e,t,i)));if(n||(n=await this.#o(e,t,i),this.#a(n),this.#r.push(n)),n){const e=t-n.start,r=i-t;return n.features?n.features.substring(e,e+r):null}}#a(e){this.#r=this.#r.filter((t=>!e.contains(t))),this.#r.length===this.#s&&this.#r.shift(),this.browser&&this.browser.referenceFrameList.length<100&&(this.#r=this.#r.filter((e=>void 0!==this.browser.referenceFrameList.find((t=>t.overlaps(e))))))}getSequenceInterval(e,t,i){return this.#r.find((n=>n.contains(e,t,i)))}async#o(e,t,i){let n=t,r=i;if(i-t{s.features=await this.sequenceReader.readSequence(e,n,r),t(s)}));return this.#n=[s,t],t}}async init(){return this.sequenceReader.init()}get chromosomeNames(){return this.sequenceReader.chromosomeNames}getFirstChromosomeName(){return\"function\"==typeof this.sequenceReader.getFirstChromosomeName?this.sequenceReader.getFirstChromosomeName():void 0}#c(e){this.browser.referenceFrameList}}async function Nc(e,t){let i;return\"chromsizes\"===e.format?i=new vc(e.fastaURL||e.url):\"2bit\"===e.format||e.twoBitURL?i=new Ec(new Ic(e),t):Ga(e.fastaURL)||!e.indexURL?i=new pc(e):\"gbk\"===e.format||e.gbkURL||(i=new Ec(new bc(e),t)),await i.init(),i}const Bc={A:\"rgb( 0, 200, 0)\",C:\"rgb( 0,0,200)\",T:\"rgb(255,0,0)\",G:\"rgb(209,113, 5)\",N:\"rgb(80,80,80)\"};function Mc(e,t){if(e.length<6)return void console.log(\"Skipping line: \"+e.join(\" \"));var i={chr1:e[0],start1:Number.parseInt(e[1]),end1:Number.parseInt(e[2]),chr2:e[3],start2:Number.parseInt(e[4]),end2:Number.parseInt(e[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;t&&void 0===t.hiccups&&(t.hiccups=!!t.columnNames&&Dc(t.columnNames));const n=t&&t.hiccups,r=n?6:10;if(n||(e.length>6&&\".\"!==e[6]&&(i.name=e[6]),e.length>7&&\".\"!==e[7]&&(i.score=Number(e[7])),e.length>8&&\".\"!==e[8]&&(i.strand1=e[8]),e.length>9&&\".\"!==e[9]&&(i.strand2=e[9])),t){const n=t.colorColumn;n&&nr&&t.columnNames&&t.columnNames.length===e.length&&(i.extras=e.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function Rc(e,t){if(!(e.length<8))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),color:_s.createColorString(e[6]),value:Number(e[7])}}function Dc(e){return e&&(e.includes(\"fdrDonut\")||e.includes(\"fdr_donut\"))}function Tc(e,t){if(!(e.length<6))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),chr1:e[8],start1:Number.parseInt(e[9]),end1:Number.parseInt(e[10]),chr2:e[13],start2:Number.parseInt(e[14]),end2:Number.parseInt(e[15]),name:e[3],score:Number(e[4]),value:Number(e[5]),color:\".\"===e[7]?void 0:\"0\"===e[7]?\"rgb(0,0,0)\":e[7]};console.log(\"Skipping line: \"+e.join(\" \"))}class Lc{constructor(e){this.message=e}}const zc=new Map([[\"%09\",\"\\t\"],[\"%0A\",\"\\n\"],[\"%0D\",\"\\r\"],[\"%25\",\"%\"],[\"%3B\",\";\"],[\"%3D\",\"=\"],[\"%26\",\"&\"],[\"%2C\",\",\"]]);function Hc(e){if(!e.includes(\"%\"))return e;let t=\"\";for(let i=0;i0&&e2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3});let a=3;try{if(e.length>3&&a++0&&e[3].indexOf(\"=\")>0){const i=Pc(e[3],\"=\");o.attributes={};for(let e of i)o.attributes[e[0]]=e[1],null!=t.nameField&&e[0]===t.nameField&&(o.name=e[1])}o.name||(o.name=\".\"===e[3]?\"\":e[3])}if(e.length>4&&a++5&&a++6&&a++7&&a++8&&a++11&&a++1e3)return o;const i=e[10].replace(/,$/,\"\").split(\",\"),n=e[11].replace(/,$/,\"\").split(\",\");if(i.length!==n.length||t!==i.length)return o;const s=[];for(let e=0;e0&&(Yc(s,o.cdStart,o.cdEnd),o.exons=s)}if(t){let i=t.thicknessColumn,n=t.colorColumn;n&&n14&&(i.signal=Number(e[12]),i.pValue=Number(e[13]),i.qValue=Number(e[14])),i}function Qc(e,t){const i=Uc(e,t,9);if(i){const t=[\"Coverage\",\"% Showing Methylation\",\"N-mod\",\"N-canonical\",\"N-other mod\",\"N-delete\",\"N-fail\",\"N-dff\",\"N-nocall\"];for(let n=9;ni?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}function Xc(e,t){var i,n,r,s,o,a,c;if(!(e.length<9))return i=e[0],n=parseInt(e[1]),r=parseInt(e[2]),o=e[3],a=Number(e[4]),s=e[5].trim(),c=Number(e[6]),0===a&&(a=c),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:c,pValue:Number(e[7]),qValue:Number(e[8])}}function Zc(e,t){const i=Xc(e);return e.length>9&&(i.peak=Number(e[9])),i}function Jc(e,t){if(e.length<=3)return;const i={chr:e[0],start:parseInt(e[1]),end:parseInt(e[2]),value:Number(e[3])};if(t){let n=t.colorColumn;n&&n2?parseInt(e[2]):r+1;if(isNaN(r)||isNaN(s))return new Lc(\"Unparsable bed record.\");const o=new nl({chr:n,start:r,end:s,score:1e3}),a=[];for(let t=3;t\"),this.name&&t.push({name:\"Name\",value:this.name}),t.push({name:\"Type\",value:this.type}),t.push({name:\"Source\",value:this.source}),void 0!==this.score&&t.push({name:\"Score\",value:this.score}),t.push({name:\"Phase\",value:this.phase}),this.attributeString){const e=Pc(this.attributeString,this.delim);for(let[i,n]of e)void 0!==n&&n.length>0&&!ml.has(i.toLowerCase())&&t.push({name:i+\":\",value:n})}return t.push({name:\"Location\",value:`${this.chr}:${Rt(this.start+1)}-${Rt(this.end)}`}),t}getAttributeValue(e){if(this.hasOwnProperty(e))return this[e];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(e))return this._attributeCache.get(e);{const t=Pc(this.attributeString,this.delim);let i;for(let[n,r]of t)if(n===e){i=r;break}return this._attributeCache.set(e,i),i}}}class bl extends wl{constructor(e){super(e),this.exons=[],this.parts=[]}addExon(e){this.exons.push(e),this.start=Math.min(this.start,e.start),this.end=Math.max(this.end,e.end)}addPart(e){this.parts.push(e)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(e,t){return e.start-t.start}));let e=this.parts[0].start,t=this.parts[0].end;for(let i=1;i=t&&i.start<=e)return i}addCDS(e){let t;const i=this.exons;for(let n of i)if(n.start<=e.start&&n.end>=e.end){t=n;break}t?(t.cdStart=t.cdStart?Math.min(e.start,t.cdStart):e.start,t.cdEnd=t.cdEnd?Math.max(e.end,t.cdEnd):e.end,t.readingFrame=e.readingFrame):console.error(\"No exon found spanning \"+e.start+\"-\"+e.end),this.cdStart=this.cdStart?Math.min(e.start,this.cdStart):e.start,this.cdEnd=this.cdEnd?Math.max(e.end,this.cdEnd):e.end}addUTR(e){let t;const i=this.exons;for(let n=0;n=e.end){t=i[n];break}t?e.start===t.start&&e.end===t.end?t.utr=!0:(e.endt.start&&(t.cdEnd=e.start)):console.error(\"No exon found spanning \"+cds.start+\"-\"+cds.end)}finish(){this.assembleParts();var e=this.cdStart,t=this.cdEnd;this.exons.sort((function(e,t){return e.start-t.start})),e&&this.exons.forEach((function(i){(i.endt)&&(i.utr=!0)}))}popupData(e){const t=super.popupData(e);for(let i of this.exons)if(!i.pseudo&&e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}for(let i of this.parts)if(e>=i.start&&e\");const n=i.popupData(e);for(let e of n)t.push(e)}return t}}function Fl(e,t){const i=t.format;if(e.length<9)return;const n=\"gff3\"===i?\"=\":\" \";return new wl({source:Hc(e[1]),type:e[2],chr:e[0],start:parseInt(e[3])-1,end:parseInt(e[4]),score:\".\"===e[5]?void 0:Number(e[5]),strand:e[6],phase:\".\"===e[7]?\".\":parseInt(e[7]),attributeString:e[8],delim:n})}function vl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):\"ID\"===e?i.id=t:\"Parent\"===e&&(i.parent=t)}return i}function yl(e,t){const i=Fl(e,t);if(!i)return;const n=Pc(i.attributeString,i.delim);let r,s;switch(i.type){case\"gene\":r=\"gene_id\";break;case\"transcript\":r=\"transcript_id\",s=\"gene_id\";break;default:s=\"transcript_id\"}for(let[e,t]of n){const n=e.toLowerCase();\"color\"===n||\"colour\"===n?i.color=_s.createColorString(t):e===r?i.id=t:e===s&&(i.parent=t)}return i}function Al(e,t){if(!(e.length<7)){var i=e[0],n=e[1],r=parseInt(e[2]),s=parseInt(e[3]),o=parseInt(e[4]),a=parseInt(e[5]),c=e[6],l={chr:i,name:n,junction_left:r,junction_right:s,num_junction_reads:o,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=r,d=s;if(a>0)for(var u=c.split(\",\"),f=0;fd&&(d=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=d,l}}function Cl(e,t){if(e.length<7)return null;const i={chr:e[0],start:parseInt(e[1])-1,end:parseInt(e[2]),\"Strongest SNP-risk allele\":e[3],\"Disease/Phenotype\":e[4],\"P-value\":e[5],\"Odds ratio or beta\":e[6]};return e.length>6&&(i.PUBMEDID=`${e[7]}`),i}function _l(e,t){const i=t.customFormat;if(e.lengthvoid 0===n||!n.has(e.type))),\"gff3\"===this.format){const t=this.combineFeaturesById(e);i=this.combineFeaturesByType(t)}else i=this.combineFeaturesByType(e);return this.numberExons(i,t),this.nameFeatures(i),i}combineFeaturesById(e){const t=new Map,i=[];for(let n of e)if(gl(n.type)||pl(n.type)||!n.id)i.push(n);else{let e=t.get(n.chr);e||(e=new Map,t.set(n.chr,e));let i=e.get(n.id);i?i.push(n):e.set(n.id,[n])}for(let e of t.values())for(let t of e.values())if(t.length>1){const e=t[0];e.exons=[];for(let i of t)e.start=Math.min(e.start,i.start),e.end=Math.max(e.end,i.end),e.exons.push({start:i.start,end:i.end});i.push(e)}else i.push(t[0]);return i}combineFeaturesByType(e){const t=e.filter((e=>\"gene\"===e.type||e.type.endsWith(\"_gene\"))),i=Object.create(null);for(let e of t)i[e.id]=e;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;e=e.filter((e=>void 0===o||!o.has(e.type)));for(let t of e)if(pl(t.type)){const e=t.id;if(void 0!==e){const o=new bl(t);n[e]=o,r.push(o),s.add(t);const a=i[t.parent];a&&(o.geneObject=a,s.add(a))}}for(let t of e)if(gl(t.type)){const e=l(t);if(e)for(let i of e){let o=n[i];if(!o&&\"gtf\"===this.format){const e=Object.assign({},t);e.type=\"transcript\",o=new bl(e),n[i]=o,r.push(o)}if(void 0!==o){if(a=t.type,ll.has(a))if(e.length>1){const e=new wl(t);o.addExon(e)}else o.addExon(t);else o.addPart(t);s.add(t)}}}var a;r.forEach((function(e){\"function\"==typeof e.finish&&e.finish()}));const c=e.filter((e=>!s.has(e)));for(let e of c)r.push(e);return r;function l(e){return e.parent&&\"\"!==e.parent.trim()?e.parent.trim().split(\",\"):null}}numberExons(e,t){for(let i of e)if(i.exons&&(!t||i.end<=t.end&&i.start>t.start))for(let e=0;e1&&(t=e)}else{this.setDecoder(n.format);const e=i.split(this.delimiter||\"\\t\");try{const i=Object.assign({columnNames:t},n);if(this.decode(e,i))break;e.length>1&&(t=e)}catch(i){e.length>1&&(t=e)}}}if(t){n.columnNames=t;for(let e=0;e0&&console.error(`Error parsing line '${s}': ${c.message}`)):c&&t.push(c)}return i===Mc&&function(e){if(0==e.length)return;const t=e[0];if(void 0===t.score&&void 0!==t.name){for(let t of e)if(!Va(t.name)&&\".\"!==t.name)return;for(let t of e)t.score=Number(t.name),delete t.name}const i=e.filter((e=>e.chr1!==e.chr2));for(let t of i){const i=Object.assign({},t);i.dup=!0,e.push(i),t.chr=t.chr1,t.start=t.start1,t.end=t.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(t),\"gtf\"!==this.config.format&&\"gff3\"!==this.config.format&&\"gff\"!==this.config.format||!1===this.config.assembleGFF?t:new Il(this.config).combineFeatures(t)}setDecoder(e){switch(e){case\"broadpeak\":case\"regionpeak\":case\"peaks\":this.decode=Xc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"narrowpeak\":this.decode=Zc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedgraph\":this.decode=Jc,this.delimiter=/\\s+/;break;case\"wig\":this.decode=el,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gff3\":case\"gff\":this.decode=vl,this.delimiter=\"\\t\";break;case\"gtf\":this.decode=yl,this.delimiter=\"\\t\";break;case\"fusionjuncspan\":this.decode=Al,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gtexgwas\":this.skipRows=1,this.decode=Cl,this.delimiter=\"\\t\";break;case\"refflat\":this.decode=Gc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepred\":this.decode=jc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"genepredext\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"ensgene\":this.decode=jc,this.header.shift=1,this.delimiter=this.config.delimiter||/\\s+/;break;case\"refgene\":this.decode=Wc,this.delimiter=this.config.delimiter||/\\s+/,this.header.shift=1;break;case\"bed\":this.decode=Uc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"gappedpeak\":this.decode=qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedmethyl\":this.decode=Qc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"bedpe\":case\"hiccups\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-domain\":this.decode=Rc,this.headerLine=!0,this.delimiter=this.config.delimiter||\"\\t\";break;case\"bedpe-loop\":this.decode=Mc,this.delimiter=this.config.delimiter||\"\\t\",this.header={colorColumn:7};break;case\"interact\":this.decode=Tc,this.delimiter=this.config.delimiter||/\\s+/;break;case\"snp\":this.decode=tl,this.delimiter=\"\\t\";break;case\"rmsk\":this.decode=Vc,this.delimiter=\"\\t\";break;case\"gcnv\":this.decode=xl,this.delimiter=\"\\t\";break;case\"shoebox\":this.decode=il,this.delimiter=\"\\t\";break;default:const t=function(e){return Sl&&Sl[e]?function(e){const t=e.fields,i=[\"chr\",\"start\",\"end\"];for(let n=0;n4?parseInt(t[4].split(\"=\")[1],10):1,index:0}}function Rl(e){const t=e.split(/\\s+/);return{format:\"variableStep\",chrom:t[1].split(\"=\")[1],span:t.length>2?parseInt(t[2].split(\"=\")[1],10):1}}function Dl(t,i){const n=e({class:\"igv-menu-popup-check-container\"}),r=e();n.appendChild(r);const s=l(\"check\",!0===i?\"#444\":\"transparent\");r.appendChild(s);const o=e();return o.innerText=t,n.appendChild(o),n}function Tl(e,t){t=t||Number.MAX_SAFE_INTEGER;const i=[];e.sort((function(e,t){return e.start-t.start})),i.push(-1e3);for(let n of e){let e=0;const r=Math.min(i.length,t);for(e=0;e=i[e]){n.row=e,i[e]=n.end;break}n.row=e,i[e]=n.end}}async function Ll(e,t,i){const n=e=>{const i=Object.assign({},e);return i.chr=\"all\",i.start=t.getGenomeCoordinate(e.chr,e.start),i.end=t.getGenomeCoordinate(e.chr,e.end),i._f=e,i.exons&&delete i.exons,i},r=new Set(t.wgChromosomeNames),s=[];let o=0;for(let a of t.wgChromosomeNames){if(Array.isArray(e)){const i={};for(let n of e){const e=t.getChromosomeName(n.chr);i.hasOwnProperty(e)||(i[e]=[]),i[e].push(n)}e=i}const c=e[a];if(c){const e=i||1e4;for(let i of c){let a=t.getChromosomeName(i.chr);if(r.has(a))if(s.length0&&!i.startsWith(\"rgb(\")&&!i.startsWith(\"rgba(\")?`rgb(${i})`:i);var i;e.name||e.label?this.name=e.name||e.label:Ht(e.url)?this.name=e.url.name:Mt(e.url)&&!e.url.startsWith(\"data:\")&&(this.name=zt(e.url)),this.url=e.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=e.order,this.autoscaleGroup=e.autoscaleGroup,this.removable=void 0===e.removable||e.removable,this.minHeight=e.minHeight||Math.min(25,this.height),this.maxHeight=e.maxHeight||Math.max(1e3,this.height),e.onclick&&(this.onclick=e.onclick,e.onclick=void 0),e.description&&(\"function\"==typeof e.description?this.description=e.description:this.description=()=>e.description),e.hoverTextFields?this.hoverText=Pl.bind(this):\"function\"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(e){this._name=e,this.trackView&&this.trackView.setTrackLabelName(e)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}repaintViews(){this.trackView&&this.trackView.repaintViews()}getState(){const e={},t=Object.keys(this.config).filter((e=>{return!(void 0===(t=this.config[e])||\"function\"==typeof t||t instanceof Promise);var t}));for(const i of t)i.startsWith(\"_\")||(e[i]=this.config[i]);for(let t of Object.keys(e)){if(t.startsWith(\"_\"))continue;const i=this[t];void 0===i||!Oa(i)&&\"boolean\"!=typeof i&&\"metadata\"!==t||(e[t]=i)}const i=Object.assign({},Hl.defaults);if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))i[e]=this.constructor.defaults[e];for(let t of Object.keys(i))void 0!==this[t]&&i[t]!==this[t]&&(e[t]=this[t]);return!this.autoscale&&this.dataRange&&(e.min=this.dataRange.min,e.max=this.dataRange.max),this.autoscaleGroup&&(e.autoscaleGroup=this.autoscaleGroup),e}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(e){if(this.disposed)return;const t={};let i;for(let n of Object.keys(e))switch(n.toLowerCase()){case\"usescore\":t.useScore=1===e[n]||\"1\"===e[n]||\"on\"===e[n]||!0===e[n];break;case\"visibility\":switch(e[n]){case\"2\":case\"3\":case\"pack\":case\"full\":t.displayMode=\"EXPANDED\";break;case\"4\":case\"squish\":t.displayMode=\"SQUISHED\";break;case\"1\":case\"dense\":t.displayMode=\"COLLAPSED\"}break;case\"color\":case\"altcolor\":t[n]=e[n].startsWith(\"rgb(\")?e[n]:\"rgb(\"+e[n]+\")\";break;case\"featurevisiblitywindow\":case\"visibilitywindow\":t.visibilityWindow=Number.parseInt(e[n]);break;case\"maxheightpixels\":i=e[n].split(\":\"),3===i.length&&(t.minHeight=Number.parseInt(i[2]),t.height=Number.parseInt(i[1]),t.maxHeight=Number.parseInt(i[0]));break;case\"viewlimits\":if(!this.config.autoscale){i=e[n].split(\":\");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),Number.isNaN(r)||Number.isNaN(s)?console.warn(`Unexpected viewLimits value in track line: ${e.viewLimits}`):(t.autoscale=!1,t.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r)}case\"name\":t[n]=e[n];break;case\"url\":t.infoURL=e[n];break;case\"type\":const r=e[n];Ol.has(r)?t[n]=Ol.get(r):t[n]=r;break;case\"graphtype\":t.graphType=e[n];break;default:t[n]=e[n]}for(let e of Object.keys(t))if(!this.config.hasOwnProperty(e)||\"name\"===e&&this.config._derivedName){let i=t[e];if(\"true\"===i&&(i=!0),\"false\"===i&&(i=!1),this[e]=i,\"height\"===e&&this.trackView)try{const e=Number.parseInt(i);this.trackView.setTrackHeight(e)}catch(e){console.error(e)}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!Array.isArray(t)||0===t.length)return[];const i=e.genomicLocation,n=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2;return to(t,i-n,i+n)}extractPopupData(e,t){const i=new Set([\"row\",\"color\",\"chr\",\"start\",\"end\",\"cdStart\",\"cdEnd\",\"strand\",\"alpha\"]),n=[];let r,s;for(let t in e)if(e.hasOwnProperty(t)&&!i.has(t)&&Oa(e[t])){let i=e[t];n.push({name:Lt(t),value:i}),\"alleles\"===t?r=e[t]:\"alleleFreqs\"===t&&(s=e[t])}if(r&&s){r.endsWith(\",\")&&(r=r.substr(0,r.length-1)),s.endsWith(\",\")&&(s=s.substr(0,s.length-1));let i=r.split(\",\"),o=s.split(\",\");if(o.length>1){let r=[];for(let e=0;e=0;i--){let o=r[i].a;if(1===o.length){t||(t=this.getGenomeId());const i=Hl.getCravatLink(e.chr,e.start+1,s,o,t);console.log(i),i&&(n.push(\"
\"),n.push({html:i}),n.push(\"
\"))}}}}if(e.attributes)for(let t of Object.keys(e.attributes))n.push({name:t,value:e.attributes[t]});let o=`${e.chr}:${Rt(e.start+1)}-${Rt(e.end)}`;return e.strand&&(o+=` (${e.strand})`),n.push({name:\"Location\",value:o}),n}description(){const e=(e,t)=>`
${e}: ${t}
`;let t='
';if(this.url?Ht(this.url)?t+=e(\"Filename\",this.url.name):t+=e(\"URL\",this.url):t=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata)){t+=e(i,this.config.metadata[i])}for(let i of Object.keys(this.config)){if(i.startsWith(\"_\"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&Oa(n)&&(t+=e(i,n))}}}return t+=\"
\",t}getColorForFeature(e){return\"function\"==typeof this.color?this.color(feature):this.color}numericDataMenuItems(){const e=[];e.push(\"
\");let t=Bt(\"
\");if(t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),void 0!==this.logScale){function i(){this.logScale=!this.logScale,this.trackView.repaintViews()}t=Bt(Dl(\"Log scale\",this.logScale)),e.push({object:t,click:i})}return t=Bt(Dl(\"Autoscale\",this.autoscale)),e.push({object:t,click:function(){this.autoscaleGroup=void 0,this.autoscale=!this.autoscale,this.browser.updateViews()}}),e}setDataRange({min:e,max:t}){this.dataRange={min:e,max:t},this.autoscale=!1,this.autoscaleGroup=void 0,this.trackView.repaintViews()}async nextFeatureAfter(e,t,i){let n=this.trackView.viewports[0].cachedFeatures;if(n&&Array.isArray(n)&&n.length>0){if(this.browser.genome.getChromosomeName(n[0].chr)===e){const e=function(e,t,i=!0){const n=e=>(e.start+e.end)/2,r=i?(e,t)=>e.start-t.start+e.end-t.end:(e,t)=>t.start-e.start+t.end-e.end,s=Array.from(e);s.sort(r);let o=0,a=s.length;for(;o=t?o=e+1:a=e}return s[o]}(n,t,i);if(e)return e}}if(\"function\"==typeof this.featureSource.nextFeature)return this.featureSource.nextFeature(e,t,i,this.visibilityWindow)}dispose(){this.disposed=!0;for(let e of Object.keys(this))this[e]=void 0}static getCravatLink(e,t,i,n,r){if(\"hg38\"===r||\"GRCh38\"===r){return`Cravat ${i}->${n}`}}static localFileInspection(e){const t=Object.assign({},e),i={url:\"file\",indexURL:\"indexFile\"};for(const e of[\"url\",\"indexURL\"])t[e]&&t[e]instanceof File&&(t[i[e]]=t[e].name,delete t[e]);return t}}function Pl(e){if(!this.hoverTextFields)return;const t=this.clickedFeatures(e);if(t&&t.length>0){let e=\"\";for(let i=0;i0&&(e+=\"\\n\"),e=\"\";for(let t of this.hoverTextFields)e.length>0&&(e+=\"\\n\"),n.hasOwnProperty(t)?e+=n[t]:\"function\"==typeof n.getAttribute&&(e+=n.getAttribute(t))}return e}}const Ol=new Map([[\"wiggle_0\",\"wig\"],[\"bed\",\"bed\"],[\"bigBed\",\"bigBed\"],[\"bigWig\",\"bigWig\"]]);class Ul{constructor(e){switch(this.type=e||\"seg\",this.type){case\"mut\":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case\"maf\":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(e){let t;for(;void 0!==(t=await e.nextLine());)if(!t.startsWith(\"#\")){const e=t.split(\"\\t\");this.header={headings:e};break}return this.header}async parseFeatures(e){const t=[];let i;this.header||(this.header=await this.parseHeader(e)),\"seg\"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await e.nextLine());){const e=r.split(\"\\t\"),s=\"seg\"===this.type?Number(e[this.dataColumn]):e[this.dataColumn];if(e.length>this.dataColumn){const r=new ql({sample:e[this.sampleColumn],chr:e[this.chrColumn],start:parseInt(e[this.startColumn])-1,end:parseInt(e[this.endColumn]),value:s,valueColumnName:n});if(i){const t=this.extractExtraColumns(e);r.setAttributes({names:i,values:t})}t.push(r)}}return t}extractExtraColumns(e){const t=[];for(let i=0;i=0)return this.attributeValues[t]}}popupData(e,t){const i=new Set([\"chr\",\"start\",\"end\",\"sample\",\"value\",\"row\",\"color\",\"sampleKey\",\"uniqueSampleKey\",\"sampleId\",\"chromosome\",\"uniquePatientKey\"]),n=this.chr+\":\"+Rt(this.start+1)+\"-\"+Rt(this.end),r=[{name:\"Sample\",value:this.sample},{name:\"Location\",value:n},{name:this.valueColumnName?Lt(this.valueColumnName):\"Value\",value:this.value}];if(\"mut\"===e&&\"hg38\"===t){const e=this.extractCravatLink(t);e&&(r.push(\"
\"),r.push({html:e}),r.push(\"
\"))}if(this.attributeNames&&this.attributeNames.length>0)for(let e=0;e0)for(let n=0;n\"===t||\"<*>\"===t||\".\"===t)return\"NONVARIANT\";{const e=t.split(\",\").map((function(e){return 1===i&&1===e.length?\"SNP\":\"\"===e?\"NONVARIANT\":e.length>i&&$l(e)?\"INSERTION\":e.lengthe.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let t of i)if(this.alleles.push(t),\"SV\"!==this.type&&$l(t)){let i=t.length,n=e.length;const r=Math.min(i,n);let s=0;for(;s0&&n>0;){const r=s+i-1,o=s+n-1;if(t.charCodeAt(r)!==e.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(t.charCodeAt(r)!==e.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos),this.start===this.end&&(this.start-=.5,this.end+=.5)}}popupData(e,t){const i=`${Rt(this.pos)}`,n=this.start===this.end?`${Rt(this.start)} | ${Rt(this.start+1)}`:`${Rt(this.start+1)}-${Rt(this.end)}`,r=[{name:\"Chr\",value:this.chr},{name:\"Pos\",value:i},{name:\"Loc\",value:n},{name:\"ID\",value:this.names?this.names:\"\"},{name:\"Ref\",value:this.referenceBases},{name:\"Alt\",value:this.alternateBases.replace(\"<\",\"<\")},{name:\"Qual\",value:this.quality},{name:\"Filter\",value:this.filter}];if(this.type&&r.push({name:\"Type\",value:this.type}),\"SNP\"===this.type){let e=this.referenceBases;if(1===e.length){let i=this.alternateBases.split(\",\");for(let n of i)if(1===n.length){let i=Hl.getCravatLink(this.chr,this.pos,e,n,t);i&&(r.push(\"
\"),r.push({html:i}))}}}const s=Object.keys(this.info);if(this.info&&s.length>0){r.push({html:'
'});for(let e of s)r.push({name:e,value:Kl(decodeURIComponent(this.info[e]))})}return r}getInfo(e){return this.info?this.info[e]:void 0}isRefBlock(){return\"NONVARIANT\"===this.type}isFiltered(){return!(\".\"===this.filter||\"PASS\"===this.filter)}alleleFreq(){return this.info?this.info.AF:void 0}}class jl{constructor(e){this.mate=e,this.chr=e.info.CHR2,this.pos=Number.parseInt(e.info.END),this.start=this.pos-1,this.end=this.pos}get info(){return this.mate.info}get names(){return this.mate.names}get referenceBases(){return this.mate.referenceBases}get alternateBases(){return this.mate.alternateBases}get quality(){return this.mate.quality}get filter(){return this.mate.filter}get calls(){return this.mate.calls}getAttributeValue(e){return this.mate.getAttributeValue(e)}getInfo(e){this.mate.getInfo(e)}isFiltered(){return this.mate.isFiltered()}alleleFreq(){return this.mate.alleleFreq()}popupData(e,t){const i=[];return i.push(\"SV Breakpoint\"),i.push({name:\"Chr\",value:this.chr}),i.push({name:\"Pos\",value:`${Rt(this.pos)}`}),i.push({html:'
'}),i.push(\"SV\"),i.push(...this.mate.popupData(e,t)),i}}class Wl{constructor({formatFields:e,sample:t,token:i}){this.info={},this.sample=t;const n=i.split(\":\");for(let t=0;t\");for(let e of r)i.push({name:e,value:decodeURIComponent(this.info[e])});return i}}const Gl=new Set([\"A\",\"C\",\"T\",\"G\"].map((e=>e.charCodeAt(0))));function $l(e){for(let t=0;t\");if(!(t>2&&o>0)){console.log(\"Malformed VCF header line: \"+n);continue}const a=n.substring(2,t-1);i[a]||(i[a]={});const c=Tt(n.substring(t+1,o-1),\",\");for(let t of c){var r=t.split(\"=\");r.length>1&&(\"ID\"===r[0]?e=r[1]:s[r[0]]=r[1])}e&&(i[a][e]=s)}else if(n.startsWith(\"##contig\")&&t){const e=n.indexOf(\"\",e));const s=n.substring(e+4,r),o=t.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith(\"#CHROM\")){const e=n.split(\"\\t\");if(e.length>8){i.sampleNameMap=new Map;for(let t=9;t9){const r=Xl(e[8].split(\":\"));n.calls=[];for(let t=9;t{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))0||0==i.length||i.indexOf(\"x\")>0)continue;const s=e[this.chrCol],o=r(e[this.valueCol]),a=parseInt(i)-1,c=a+1;t.push(new eh({chr:s,start:a,end:c,value:o,line:n,columns:this.columns}))}}return t}static isGWAS(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class eh{constructor({chr:e,start:t,end:i,value:n,line:r,columns:s}){this.chr=e,this.start=t,this.end=i,this.value=n,this.line=r,this.columns=s}popupData(){const e=this.line.split(/\\t/);return this.columns.map((function(t,i){return{name:t,value:e[i]}}))}getAttribute(e){const t=this.line.split(/\\t/);for(let i=0;i0?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split(\"=\",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();t[e]=i}}return t}function ah(e){let t={},i=e.split(/\\s+/);if(2===i.length){i[1].split(\";\").forEach((function(e){let i=e.split(\"=\");\"color\"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:\"thickness\"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function ch(e,t){var i,n,r=e.columns;this.aed=e,this.allColumns=t,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=\".\",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let e=0;e0)for(let e=0;ee.maxv.isGreaterThan(t))));const i=[];let n;for(let t of e)n&&dh(n,t)?t.maxv.isGreaterThan(n.maxv)&&(n.maxv=t.maxv):(i.push(t),n=t);return i}function dh(e,t){const i=t.minv.block-e.maxv.block;return t.maxv.block-e.minv.block<5e6&&i<65e3}ch.prototype.popupData=function(){for(var e=[],t=this.aed,i=0;i=28){t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt(),t.getInt();const e=t.getInt(),i=t.position+e;let r=0;for(;t.positions)t.getInt(),t.getVPointer(),t.getVPointer(),t.getLong(),t.getLong();else{i[e]=[];const n=t.getInt();for(let s=0;sr&&(r=s.block),i[e].push([n,s]))}}}o>0&&(this.indices[e]={binIndex:i,loffset:n})}this.lastBlockPosition=r}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=this.reg2bins(t,i);if(0==e.length)return[];const r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let i of t){const t=i[0],n=i[1];r.push({minv:t,maxv:n,bin:e})}}let s=e[this.depth][0];do{if(n.binIndex[s])break;s>1+(this.getParentBin(s)<<3)?s--:s=this.getParentBin(s)}while(0!=s);return hh(r,n.loffset[s])}return[]}getParentBin(e){return 0==e?0:e-1>>3}reg2bins(e,t){(e-=1)<1&&(e=1),t>2**34&&(t=2**34),t-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(e>>r),o=n+(t>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class fh{constructor(){}async parse(e,t){const i=[];let n=Number.MAX_SAFE_INTEGER,r=0;const s=new yc(new DataView(e)),o=s.getInt(),a={};if(!(21578050===o||t&&21578324===o))throw new Error(indexURL+\" is not a \"+(t?\"tabix\":\"bai\")+\" file\");{const e=s.getInt();if(t){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let t=0;tr&&(r=o.block),e[t].push([i,o]))}}}const c=s.getInt();for(let e=0;e0&&(i[t]={binIndex:e,linearIndex:o})}this.firstBlockPosition=n,this.lastBlockPosition=r,this.indices=i,this.sequenceIndexMap=a,this.tabix=t}}get sequenceNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=function(e,t){const i=[];t>=1<<29&&(t=1<<29);return--t,i.push([0,0]),i.push([1+(e>>26),1+(t>>26)]),i.push([9+(e>>23),9+(t>>23)]),i.push([73+(e>>20),73+(t>>20)]),i.push([585+(e>>17),585+(t>>17)]),i.push([4681+(e>>14),4681+(t>>14)]),i}(t,i),r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let e of t){const t=e[0],i=e[1];r.push({minv:t,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(t>>14,s-1),c=Math.min(i>>14,s-1);for(let e=a;e<=c;e++){const t=n.linearIndex[e];if(t){o=t;break}}return hh(r,o)}return[]}}class ph{constructor(){this.tribble=!0}async parse(e){let t=0;this.chrIndex={},this.lastBlockPosition=[];const i=new yc(new DataView(e));!function(e){e.getInt(),e.getInt();const t=e.getInt();if(e.getString(),e.getLong(),e.getLong(),e.getString(),e.getInt(),t>=3){let t=e.getInt();for(;t-- >0;)e.getString(),e.getString()}}(i);let n=i.getInt();for(;n-- >0;){let e=i.getString();const n=i.getInt(),r=i.getInt(),s=i.getInt();i.getInt(),i.getInt();let o=i.getLong();const a=[];for(let e=0;et&&(t=e)}this.chrIndex[e]={chr:e,blocks:a,longestFeature:s,binWidth:n}}this.lastBlockPosition=t}get sequenceNames(){return Object.keys(this.chrIndex)}chunksForRange(e,t,i){const n=this.chrIndex[e];if(n){const e=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(t-r,0),a=Math.floor(o/s);if(a>=e.length)return[];{const t=Math.min(Math.floor((i-1)/s),e.length-1),n=e[a].min,r=e[t].max;if(0===r-n)return[];return[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function gh(e,t){let i=await Qs.loadArrayBuffer(e,Ua(t)),n=new DataView(i);if(31===n.getUint8(0)&&139===n.getUint8(1)){i=gs(i).buffer,n=new DataView(i)}switch(n.getInt32(0,!0)){case 21578050:return async function(e){const t=new fh;return await t.parse(e,!1),t}(i);case 21578324:return async function(e){const t=new fh;return await t.parse(e,!0),t}(i);case 21582659:return async function(e){const t=new uh;return t.parse(e),t}(i);case 1480870228:return async function(e){const t=new ph;return t.parse(e),t}(i);case 38359875:throw Error(\"CSI version 2 is not supported.\");default:throw Error(`Unrecognized index type: ${e}`)}}function mh(e){return\"string\"==typeof e||e instanceof String?new wh(e):new bh(e)}class wh{constructor(e){this.data=e,this.ptr=0}nextLine(){var e=this.ptr,t=this.data.indexOf(\"\\n\",e),i=this.data;if(t>0)return this.ptr=t+1,t>e&&\"\\r\"===i.charAt(t-1)?i.substring(e,t-1):i.substring(e,t);var n=i.length;return this.ptr=n,e>=n?void 0:i.substring(e)}}class bh{constructor(e){this.data=e,this.length=this.data.length,this.ptr=0}nextLine(){if(this.ptr>=this.data.length)return;let e=this.ptr;const t=this.data;let i=\"\",n=!1;for(;e0)for(var a=0;a{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])};class yh{constructor(e){this.config=e,this.cacheBlocks=0!=e.cacheBlocks,this.cache=void 0}async getData(e,t){const i=e.block,n=t.block,r=0===t.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const e of s)o+=e.byteLength;const a=new Uint8Array(o);let c=0;for(const e of s)a.set(e,c),c+=e.byteLength;return a}async getInflatedBlocks(e,t,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=e&&(n.endBlock>=t||i&&n.nextEndBlock===t)){const i=e-n.startBlock,r=t-n.startBlock;return Ch(n.buffer,i,r)}{let r;if(!n||n.startBlock>t||n.endBlock=n.endBlock)o=n.buffer;else{const i=Math.max(0,e-n.startBlock);let r;if(t>=n.endBlock)r=n.buffer.byteLength;else{const e=Ah(n.buffer);for(let i=0;in.endBlock){const e=await this.loadBLockData(n.endBlock,t,{skipStart:!0,skipEnd:i});s.push(e)}r=function(e){if(1===e.length)return e[0];let t=0;for(const i of e)t+=i.byteLength;const i=new Uint8Array(t);let n=0;for(const t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(s)}let s=t;if(i){const e=Ah(r);t=e[e.length-1]}return this.cache={startBlock:e,endBlock:t,nextEndBlock:s,buffer:r},Ch(r)}}return Ch(await this.loadBLockData(e,t,{skipEnd:i}))}async loadBLockData(e,t,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!(i&&i.skipEnd)){const e=Ua(n,{range:{start:t,size:26}}),i=await Qs.loadArrayBuffer(n.url,e);s=vh(i)}if(r){const t=Ua(n,{range:{start:e,size:26}}),i=await Qs.loadArrayBuffer(n.url,t);e+=vh(i)}const o=Ua(n,{range:{start:e,size:t+s-e}});return Qs.loadArrayBuffer(n.url,o)}}function Ah(e){const t=e.byteLength;let i=0;const n=[0];for(;i{const t=e.indexOf(\"E\");if(t>0){if(Number.parseInt(e.substring(t+1))<_h)return Number.MIN_VALUE}return Number(e)};for(;void 0!==(n=e.nextLine());){const e=n.split(this.delimiter);if(e.length===this.columns.length){const i=e[this.posColumn];if(i.indexOf(\";\")>0||0==i.length||i.indexOf(\"x\")>0)continue;const n=e[this.chrColumn],s=r(e[this.pValueColumn]),o=parseInt(i)-1,a=o+1,c=e[this.snpColumn],l=e[this.phenotypeColumn],h=new kh({chr:n,start:o,end:a,pValue:s,snp:c,phenotype:l},this.columns,e);t.push(h)}}return t}static isQTL(e){const t=e.split(\"\\t\");if(t.length<5)return!1;const i=[[\"chr\",\"chromosome\",\"chr_id\",\"chrom\"],[\"bp\",\"pos\",\"position\",\"chr_pos\",\"chromEnd\"],[\"p\",\"pval\",\"p-value\",\"p.value\"],[\"rsid\",\"variant\",\"snp\"],[\"phenotype\",\"gene\",\"gene_id\",\"molecular_trait_id\"]];for(let e of i)if(!t.some((t=>e.includes(t.toLowerCase()))))return!1;return!0}}class kh{constructor({chr:e,start:t,end:i,pValue:n,snp:r,phenotype:s},o,a){this.chr=e,this.start=t,this.end=i,this.pValue=n,this.snp=r,this.phenotype=s,this.headers=o,this.tokens=a}popupData(){const e=[];for(let t=0;te.blocks)).map((e=>e.max)).reduce(((e,t)=>Math.min(e,t)),Number.MAX_SAFE_INTEGER),n=Ua(this.config,{bgz:e.tabix,range:{start:0,size:i}});t=mh(await Qs.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(t),this.header}if(\"service\"!==this.config.sourceType){let e;if(this.config._filecontents)e=this.config._filecontents,delete this.config._filecontents;else{const t=Ua(this.config);e=await Qs.loadByteArray(this.config.url,t)}e.length<5e8&&(e=(new TextDecoder).decode(e));let t=mh(e);this.header=await this.parser.parseHeader(t),t=mh(e),this.features=await this.parser.parseFeatures(t),this.sequenceNames=new Set;for(let e of this.features)this.sequenceNames.add(e.chr);return this.header}if(this.config.seqnamesURL){const e=Ua(this.config,{}),t=await Qs.loadString(this.config.seqnamesURL,e);t&&(this.sequenceNames=new Set(t.split(\",\").map((e=>e.trim())).filter((e=>e))))}if(this.config.headerURL){const e=Ua(this.config,{}),t=mh(await Qs.loadString(this.config.headerURL,e));return this.header=await this.parser.parseHeader(t),this.header}}getParser(e){switch(e.format){case\"vcf\":return new Yl(e);case\"seg\":return new Ul(\"seg\");case\"mut\":return new Ul(\"mut\");case\"maf\":return new Ul(\"maf\");case\"gwas\":return new Jl(e);case\"qtl\":return new xh(e);case\"aed\":return new nh(e);default:return new El(e)}}async loadFeaturesNoIndex(){if(this.features){const e=this.features;return delete this.features,e}{const e=Ua(this.config),t=await Qs.loadByteArray(this.config.url,e);if(!this.header){const e=mh(t);this.header=await this.parser.parseHeader(e)}const i=mh(t),n=[];return await this._parse(n,i),n}}async loadFeaturesWithIndex(e,t,i){const n=this.config;this.parser;const r=this.index.tabix,s=r?this.index.sequenceIndexMap[e]:e;if(void 0===s)return[];const o=this.index.chunksForRange(s,t,i);if(o&&0!==o.length){const s=[];for(let a of o){let o;if(r)o=await this._blockLoader.getData(a.minv,a.maxv);else{const e=Ua(n,{range:{start:a.minv.block,size:a.maxv.block-a.minv.block+1}});o=await Qs.loadString(n.url,e)}const c=mh(a.minv.offset?o.slice(a.minv.offset):o);await this._parse(s,c,e,i,t)}return s}return[]}async loadFeaturesFromService(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);const r=Ua(this.config),s=mh(await Qs.loadString(n,r)),o=[];return await this._parse(o,s),o}async _parse(e,t,i,n,r){let s=await this.parser.parseFeatures(t);if(s.sort((function(e,t){return e.chr===t.chr?e.start-t.start:e.chr.localeCompare(t.chr)})),void 0===i)for(let t of s)e.push(t);else{let t=!1;for(let o=0;on){e.push(a);break}a.end>=r&&a.start<=n&&(t||(t=!0,o>0&&e.push(s[o-1])),e.push(a))}}}}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return gh(this.config.indexURL,this.config)}async loadFeaturesFromDataURI(){if(this.features){const e=this.features;return delete this.features,e}{const e=vs(this.dataURI);let t=mh(e);this.header=await this.parser.parseHeader(t),this.header instanceof String&&this.header.startsWith(\"##gff-version 3\")&&(this.format=\"gff3\"),t=mh(e);const i=[];return await this._parse(i,t),i}}}const Sh=Mt;class Eh{constructor(e){this.config=e}async readFeatures(e,t,i){let n;n=\"function\"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&(\"function\"==typeof this.config.body?s.body=this.config.body({chr:e,start:t,end:i}):s.body=this.config.body.replace(\"$CHR\",e).replace(\"$START\",t).replace(\"$END\",i));const o=await Qs.load(n,s);if(o&&(r=\"function\"==typeof this.config.parser?this.config.parser(o):Sh(o)?JSON.parse(o):o),this.config.mappings){let e=Object.keys(this.config.mappings);for(let t of r)for(let i of e)t[i]=t[this.config.mappings[i]]}return r}}const Nh=function(e,t){this.config=e,this.genome=t,this.expandQueryInterval=!1};Nh.prototype.readFeatures=function(e,t,i){const n=Math.max(0,Math.floor(t));let r=Math.ceil(i);if(this.genome){const t=this.genome.getChromosome(e);t&&r>t.bpLength&&(r=t.bpLength)}const s=this.config.url+\"?db=\"+this.config.db+\"&table=\"+this.config.tableName+\"&chr=\"+e+\"&start=\"+n+\"&end=\"+r;return Qs.loadJson(s,this.config).then((function(e){return e?(e.forEach((function(e){e.hasOwnProperty(\"exonStarts\")&&e.hasOwnProperty(\"exonEnds\")&&e.hasOwnProperty(\"exonCount\")&&e.hasOwnProperty(\"cdsStart\")&&e.hasOwnProperty(\"cdsEnd\")&&function(e){var t,i,n,r,s,o;t=e.exonCount,i=e.exonStarts.split(\",\"),n=e.exonEnds.split(\",\"),r=[];for(var a=0;ao||e.cdsEnd=s&&e.cdsStart<=o&&(c.cdStart=e.cdsStart),e.cdsEnd>=s&&e.cdsEnd<=o&&(c.cdEnd=e.cdsEnd),r.push(c)}e.exons=r}(e)})),e):null}))};class Bh{featureCaches=[];gtexChrs=new Set([\"chr1\",\"chr10\",\"chr11\",\"chr12\",\"chr13\",\"chr14\",\"chr15\",\"chr16\",\"chr17\",\"chr18\",\"chr19\",\"chr2\",\"chr20\",\"chr21\",\"chr22\",\"chr3\",\"chr4\",\"chr5\",\"chr6\",\"chr7\",\"chr8\",\"chr9\",\"chrM\",\"chrX\",\"chrY\"]);constructor(e){this.config=e,this.url=e.url,this.tissueId=e.tissueSiteDetailId,this.datasetId=e.datasetId||\"gtex_v8\"}async readFeatures(e,t,i){const n=e.startsWith(\"chr\")?e:\"MT\"===e?\"chrM\":\"chr\"+e;if(!this.gtexChrs.has(n))return[];const r=Math.floor(t),s=Math.ceil(i),o=this.datasetId,a=this.url+\"?chromosome=\"+n+\"&start=\"+r+\"&end=\"+s+\"&tissueSiteDetailId=\"+this.tissueId+\"&datasetId=\"+o,c=await Qs.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?c.singleTissueEqtl.map((e=>new Mh(e))):[]}}class Mh{constructor(e){this.chr=e.chromosome,this.start=e.pos-1,this.end=this.start+1,this.snp=e.snpId,this.phenotype=e.geneSymbol,this.pValue=e.pValue,this.json=e}popupData(){return Object.keys(this.json).map((e=>({name:e,value:this.json[e]})))}}class Rh{constructor(e,t){if(this.config=e,this.genome=t,!e.format)throw Error('Format is required, and must be either \"bam\" or \"cram\"');if(this.format=e.format.toUpperCase(),\"BAM\"!==this.format&&\"VCF\"!==this.format)throw Error(`htsget format ${e.format} is not supported`)}async readHeaderData(){const e=`${Dh(this.config)}?class=header&format=${this.format}`,t=await Qs.loadJson(e,Ua(this.config));return await this.loadUrls(t.htsget.urls)}async readData(e,t,i){const n=`${Dh(this.config)}?format=${this.format}&referenceName=${e}&start=${Math.floor(t)}&end=${Math.ceil(i)}`,r=await Qs.loadJson(n,Ua(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(e){const t=[];for(let i of e)if(i.url.startsWith(\"data:\"))t.push(Promise.resolve(Th(i.url)));else{const e=Ua(this.config||{});i.headers&&(e.headers=Object.assign(e.headers||{},i.headers)),t.push(Qs.loadArrayBuffer(i.url,e))}return function(e){let t=0;for(let i of e)t+=i.byteLength;let i=0;const n=new Uint8Array(t);for(let t of e){const e=new Uint8Array(t);n.set(e,i),i+=e.length}return n}(await Promise.all(t))}static async inferFormat(e){try{const t=Dh(e),i=`${t}${t.includes(\"?\")?\"&\":\"?\"}class=header`,n=await Qs.loadJson(i,Ua(e));if(n.htsget){const t=n.htsget.format;if(\"BAM\"!==t&&\"VCF\"!==t)throw Error(`htsget format ${t} is not supported`);e.format=t.toLowerCase(),e.sourceType=\"htsget\",e.name||(e.name=await ja(e.url))}}catch(e){}}}function Dh(e){if(e.url&&e.endpoint&&e.id)return e.url+e.endpoint+e.id;if(e.endpoint&&e.id)return e.endpoint+e.id;if(e.url)return e.url.startsWith(\"htsget://\")?e.url.replace(\"htsget://\",\"https://\"):e.url;throw Error(\"Must specify either 'url', or 'endpoint' and 'id\")}function Th(e){const t=e.split(\",\"),i=t[0].split(\":\")[1];let n=t[1];n=i.indexOf(\"base64\")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>t[e])).filter((e=>this.sequenceNames.has(e)));n.length>0&&(i=n[0]),this.chrAliasTable.set(e,i)}else this.chrAliasTable.set(e,void 0)}return this.chrAliasTable.get(e)}}class Hh{constructor(e){this.genome=e}async nextFeature(e,t,i,n){let r=this.genome.chromosomeNames||[e],s=r.indexOf(e);if(s<0)return;const o=Math.min(1e4,n||1e4);let a=i?t:Math.max(t-o,0);for(;s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=i?a+o:Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=0;){e=r[s];const c=this.genome.getChromosome(e).bpLength;for(;a=0;){let r=Math.min(t,a+o);const s=await this.getFeatures({chr:e,start:a,end:r,visibilityWindow:n});if(s){const e=(e,t)=>e.start-t.start+e.end-t.end,n=Array.from(s);n.sort(e);let r=i?0:n.length-1;for(;r>=0&&rt)return e;r++}else{if(s=2){let e=t.getInt();for(this.windowFunctions=[];e-- >0;)this.windowFunctions.push(t.getString())}this.trackType=t.getString(),this.trackLine=t.getString();let i=t.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(t.getString());this.genomeID=t.getString(),this.flags=t.getInt(),this.compressed=!!(1&this.flags),e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:this.indexPos,size:this.indexSize}})),t=new yc(new DataView(e)),this.datasetIndex={};let n=t.getInt();for(;n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.datasetIndex[e]={position:i,size:n}}for(this.groupIndex={},n=t.getInt();n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.groupIndex[e]={position:i,size:n}}return this}async readDataset(e,t,i){const n=e+\"_\"+t+\"_\"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?\"\":\"/\"+t,s=\"all\"===e.toLowerCase()||void 0===i?\"0\":i.toString();let o;o=\"raw\"===t?\"/\"+e+\"/raw\":\"/\"+e+\"/z\"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const c=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new yc(new DataView(c));let h=l.getInt();const d={};for(;h-- >0;)d[l.getString()]=l.getString();const u=l.getString(),f=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:o,attributes:d,dataType:u,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const e=this.genome,t=this.groupCache[\"/\"];if(t)return t;{const t=await this.readGroup(\"/\"),i=t.chromosomes,n=t.maxZoom;n&&(this.maxZoom=Number(n));const r=t.totalCount;r&&(t.totalCount=Number(r));const s={};return i&&i.split(\",\").forEach((function(t){const i=e.getChromosomeName(t);s[i]=t})),this.chrAliasTable=s,this.groupCache[\"/\"]=t,t}}async readGroup(e){const t=this.groupCache[e];if(t)return t;{await this.readHeader();const t=this.groupIndex[e];if(void 0===t)return;const i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:t.position,size:t.size}}));if(!i)return;const n=new yc(new DataView(i)),r={name:e};let s=n.getInt();for(;s-- >0;){const e=n.getString(),t=n.getString();r[e]=t}return this.groupCache[e]=r,r}}async readTiles(e,t){if(e.sort((function(e,t){return e.position-t.position})),0===(e=e.filter((function(e){return e.size>0}))).length)return[];const i=[];for(let n of e){const e=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:n.position,size:n.size}}));let r;try{r=this.compressed?ls(e).buffer:e}catch(e){console.error(e);continue}const s=new yc(new DataView(r)),o=s.getString();let a;switch(o){case\"fixedStep\":a=Oh(s,t);break;case\"variableStep\":a=Uh(s,t);break;case\"bed\":case\"bedWithName\":a=qh(s,t,o);break;default:throw\"Unknown tile type: \"+o}i.push(a)}return i}async readTile(e,t){let i=await Qs.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e.position,size:e.size}}));if(this.compressed){i=ls(i).buffer}const n=new yc(new DataView(i)),r=n.getString();switch(r){case\"fixedStep\":return Oh(n,t);case\"variableStep\":return Uh(n,t);case\"bed\":case\"bedWithName\":return qh(n,t,r);default:throw\"Unknown tile type: \"+r}}}function Oh(e,t){const i=e.getInt(),n=e.getInt(),r=e.getFloat(),s=[];let o=t;for(;o-- >0;){let t=i;const n=[];for(;t-- >0;)n.push(e.getFloat());s.push(n)}return{type:\"fixedStep\",start:n,span:r,data:s,nTracks:t,nPositions:i}}function Uh(e,t){const i=e.getInt(),n=e.getFloat(),r=e.getInt(),s=[];let o=r;for(;o-- >0;)s.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){o=r;const t=[];for(;o-- >0;)t.push(e.getFloat());a.push(t)}return{type:\"variableStep\",tileStart:i,span:n,start:s,data:a,nTracks:t,nPositions:r}}function qh(e,t,i){const n=e.getInt();let r=n;const s=[];for(;r-- >0;)s.push(e.getInt());r=n;const o=[];for(;r-- >0;)o.push(e.getInt());e.getInt();const a=[];let c=t;for(;c-- >0;){let t=n;const i=[];for(;t-- >0;)i.push(e.getFloat());a.push(i)}if(\"bedWithName\"===i){r=n;const t=[];for(;r-- >0;)t.push(e.getString())}return{type:i,start:s,end:o,data:a,nTracks:t,nPositions:n}}class Qh extends Hh{#h={};searchable=!1;constructor(e,t){super(t),this.genome=t,this.reader=new Ph(e,t),this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r=\"mean\"}){return\"all\"===e.toLowerCase()?this.getWGValues(r,n):this._getFeatures(e,t,i,n,r)}async _getFeatures(e,t,i,n,r){const s=new hc(e,t,i),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const e=this.rootGroup.totalCount;e&&(this.normalizationFactor=1e6/e)}s.bpPerPixel=n;const a=function(e,t,i){var n=i.getChromosome(e).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*t)))/Gh)}(e,n,o);let c=this.reader.chrAliasTable[e],l=this.reader.maxZoom;void 0===c&&(c=e),void 0===l&&(l=-1);const h=a>l?\"raw\":r,d=await this.reader.readDataset(c,h,a);if(null==d)return[];const u=d.tileWidth,f=Math.floor(t/u),p=Math.floor(i/u),g=await this.reader.readTiles(d.tiles.slice(f,p+1),1),m=[];for(let r of g)switch(r.type){case\"bed\":Vh(r,e,t,i,n,m);break;case\"variableStep\":jh(r,e,t,i,n,m);break;case\"fixedStep\":Wh(r,e,t,i,n,m);break;default:throw\"Unknown tile type: \"+r.type}return m.sort((function(e,t){return e.start-t.start})),m}get supportsWholeGenome(){return!0}get windowFunctions(){return this.reader.windowFunctions}async getWGValues(e,t){const i=this.#h[e];if(i&&i.bpPerPixel>.8*t&&i.bpPerPixel<1.2*t)return i.values;{const i=[],n=this.genome;if(this.genome.wgChromosomeNames)for(let r of n.wgChromosomeNames){const s=n.getChromosome(r).bpLength;t=s/1e3;const o=await this._getFeatures(r,0,s,t,e);if(o)for(let e of o){const t=Object.assign({},e);t.chr=\"all\",t.start=n.getGenomeCoordinate(e.chr,e.start),t.end=n.getGenomeCoordinate(e.chr,e.end),t._f=e,i.push(t)}}return this.#h[e]={values:i,bpPerPixel:t},i}}}function Vh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.end,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function jh(e,t,i,n,r,s){const o=e.nPositions,a=e.start,c=e.span,l=e.data[0];for(let e=0;en)break;s.push({chr:t,start:r,end:o,value:l[e]})}}}function Wh(e,t,i,n,r,s){const o=e.nPositions;let a=e.start;const c=e.span,l=e.data[0];for(let e=0;en)break;r>=i&&(Number.isNaN(l[e])||s.push({chr:t,start:a,end:r,value:l[e]})),a=r}}var Gh=Math.log(2);class $h{constructor(e,t,i,n){this.header=e,this.nameToId=t,this.idToName=i,this.sumLengths=n}static parseTree(e,t,i=!1){{const n=e.getInt(),r=e.getInt(),s=e.getInt(),o=e.getInt(),a=e.getLong(),c=e.getLong(),l={magic:n,blockSize:r,keySize:s,valSize:o,itemCount:a,reserved:c},h=new Map,d=[];let u=0;const f=n=>{n>=0&&(e.position=n);const r=e.getByte();e.getByte();const a=e.getUShort();if(1===r)for(let t=0;t{const a=await this.readNode(o);for(let o of a.items)Yh(o,e,t,i,n)&&(1===a.type?r.push(o):await s(o.childOffset))};return await s(this.header.rootNodeOffset),r}async readNode(e){const t=e;if(this.nodeCache.has(t))return this.nodeCache.get(t);let i=await this.#t(e,4);const n=i.getByte(),r=1===n;i.getByte();const s=i.getUShort();let o=s*(r?32:24);i=await this.#t(e+4,o);const a=[];for(let e=0;ee.startChrom||n===e.startChrom&&r>=e.startBase)&&(t!!e)),s=[];for(let e of r){const t=e.split(\" \")[0];if(t.startsWith(i)&&s.push(e),t.slice(0,i.length)>i)break}if(0!==s.length){const e=new Map;for(let t of s){const[i,...n]=t.split(\" \");e.set(i,n.map((e=>e.split(\",\")[0])))}return e}}async getIndex(e){return this.index||(this.index=await this._readIndex()),this.index}async _readIndex(e){return(await Qs.loadString(this.ixxFile)).split(\"\\n\").filter((e=>!!e)).map((e=>{const t=e.length-10,i=e.slice(0,t),n=e.slice(t);return[i,Number.parseInt(n,16)]}))}async _getBuffer(e,t){let i=0,n=65536;const r=await this.getIndex(t);for(let t=0;t0?ls(r):r,a.call(this,new DataView(d.buffer),c,t,l,n,h,this.chromTree.idToName,s,this.littleEndian)}return h.sort((function(e,t){return e.start-t.start})),h}return[]}async#d(e){if(this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.chromTree.nameToId.get(e);if(void 0===t&&this.genome){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>this.chromTree.nameToId.has(e)));e.length>0&&(n=e[0],t=this.chromTree.nameToId.get(e[0]))}this.chrAliasTable.set(e,n)}return t}get searchable(){return\"bigbed\"===this.type}async search(e){if(this.header||await this.loadHeader(),!this.header||!this.header.extraIndexCount)return;const t=await this._searchForRegions(e);if(t){const i=await this._loadFeaturesForRange(t.offset,t.length);if(i){const t=i.filter((t=>{for(let i of Object.keys(t)){const n=t[i];if(Mt(n)&&n.toLowerCase()===e.toLowerCase())return!0}return!1}));return t.length>0?t.reduce(((e,t)=>e.end-e.start>t.end-t.start?e:t),i[0]):void 0}}}async _searchForRegions(e){const t=await this.#u();if(t){if(this._trix){const t=e.toLowerCase(),i=await this._trix.search(t);i&&i.has(t)&&(e=i.get(t)[0])}for(let i of t){const t=await i.search(e);if(t)return t}}}async#u(){if(void 0===this._searchTrees&&this.header.extraIndexOffsets&&this.header.extraIndexOffsets.length>0){this._searchTrees=[];for(let e of this.header.extraIndexOffsets){const t=await Cc.loadBpTree(this.path,this.config,e);this._searchTrees.push(t)}}return this._searchTrees}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let e,t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;const i=new yc(new DataView(t),this.littleEndian);let n=i.getUInt();if(2291137574===n)this.type=\"bigwig\";else if(2273964779===n)this.type=\"bigbed\";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let e=i.getUInt();654085990===e?this.type=\"bigwig\":3958540679===e&&(this.type=\"bigbed\")}e={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:e.totalSummaryOffset>0?e.totalSummaryOffset-r+40:Math.min(e.fullDataOffset,e.chromTreeOffset)-r};t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:s}));const o=new yc(new DataView(t),this.littleEndian),a=e.nZoomLevels;this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let e=1;e<=a;e++){const t=a-e,i=new Jh(t,o);this.firstZoomDataOffset=Math.min(i.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[t]=i}if(e.autoSqlOffset>0){o.position=e.autoSqlOffset-r;const t=o.getString();t&&(this.autoSql=function(e){let t;const i=[];let n=!1;const r=e.trim().split(/\\s*[\\r\\n]+\\s*/g);for(let e of r)if(e=e.trim(),e.length>0){if(e.startsWith(\"#\"))continue;if(e.startsWith(\"table\"))t=e.split(/\\s+/)[1].trim();else if(e.startsWith(\"(\"))n=!0;else if(e.startsWith(\")\"));else if(n){const t=e.indexOf(\";\");if(t>0){const n=e.substr(0,t).split(/\\s+/),r=e.substr(t+1).replace(/\"/g,\"\").trim();i.push({type:n[0],name:n[1],description:r})}}}return{table:t,fields:i}}(t))}e.totalSummaryOffset>0&&(o.position=e.totalSummaryOffset-r,this.totalSummary=new ed(o));const c=Math.min(2e5,Math.max(1e4,e.fullDataOffset-e.chromTreeOffset));if(this.chromTree=await this.#f(e.chromTreeOffset,c),this.chrNames=new Set(this.chromTree.idToName),\"bigbed\"===this.type){const t=await this.#p(e.fullDataOffset);this.featureDensity=t/this.chromTree.sumLengths}return this.header=e,e.extensionOffset>0&&await this.loadExtendedHeader(e.extensionOffset),this.header}}async#p(e){const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:4}}));return new yc(new DataView(t),this.littleEndian).getInt()}async#f(e,t){let i=t;const n=async()=>{const t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:i}})),n=new yc(new DataView(t),this.littleEndian);return $h.parseTree(n,e,this.genome)};let r;for(;i<1e6;)try{return await n()}catch(e){r=e,i*=2}throw r}async loadExtendedHeader(e){let t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:e,size:64}})),i=new yc(new DataView(t),this.littleEndian);i.getUShort();const n=i.getUShort(),r=i.getLong();if(0===n)return;let s=56*n;t=await this.loader.loadArrayBuffer(this.path,Ua(this.config,{range:{start:r,size:s}})),i=new yc(new DataView(t),this.littleEndian);const o=[],a=[],c=[];for(let e=0;e0?ls(n):n,s=[];return nd.call(this).call(this,new DataView(r.buffer),0,0,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,s,this.chromTree.idToName),s}}class Jh{constructor(e,t){this.index=e,this.reductionLevel=t.getInt(),this.reserved=t.getInt(),this.dataOffset=t.getLong(),this.indexOffset=t.getLong()}}class ed{constructor(e){e?(this.basesCovered=e.getLong(),this.minVal=e.getDouble(),this.maxVal=e.getDouble(),this.sumData=e.getDouble(),this.sumSquares=e.getDouble(),td.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function td(){let e=this.basesCovered;if(e>0){this.mean=this.sumData/e,this.stddev=Math.sqrt(this.sumSquares/(e-1));let t=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:t,max:i}}}function id(e,t,i,n,r,s,o,a,c){const l=new yc(e,c),h=l.getInt(),d=l.getInt();let u=d,f=l.getInt();const p=l.getInt(),g=l.getInt(),m=l.getByte();l.getByte();let w=l.getUShort();if(h>=t&&h<=n){let e=0;for(;w-- >0;){let a;switch(m){case 1:u=l.getInt(),f=l.getInt(),a=l.getFloat();break;case 2:u=l.getInt(),a=l.getFloat(),f=u+g;break;case 3:a=l.getFloat(),u=d+e*p,f=u+g,e++}if(!(hn||h===n&&u>=r)break;if(Number.isFinite(a)){const e=o[h];s.push({chr:e,start:u,end:f,value:a})}}}}}function nd(){const e=function(e,t,i,n){if(\"biginteract\"===n||i&&(\"chromatinInteract\"===i.table||\"interact\"===i.table))return function(e,t){return e.chr1=t[5],e.start1=Number.parseInt(t[6]),e.end1=Number.parseInt(t[7]),e.chr2=t[10],e.start2=Number.parseInt(t[11]),e.end2=Number.parseInt(t[12]),e.name=t[0],e.score=Number(t[1]),e.value=Number(t[2]),e.color=\".\"===t[4]?void 0:\"0\"===t[4]?\"rgb(0,0,0)\":t[4],e};{const n=e-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&\".\"!==s[5]&&\"0\"!==s[5]&&\"-1\"!==s[5]){const e=_s.createColorString(s[5]);r.color=e.startsWith(\"rgb\")?e:void 0}if(n>8){const e=parseInt(s[6]),t=s[7].split(\",\"),i=s[8].split(\",\"),n=[];for(let s=0;si?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=e;n=13;){const t=h.getInt(),c=a[t],l=h.getInt(),d=h.getInt(),u=h.getString();if(!(tr||t===r&&l>=s)break;if(d>0){const t={chr:c,start:l,end:d};o.push(t);const i=u.split(\"\\t\");e(t,i)}}}}}function rd(e,t,i,n,r,s,o,a,c){const l=new yc(e,c);for(;l.remLength()>=32;){const e=l.getInt(),c=l.getInt(),h=l.getInt(),d=l.getInt(),u=l.getFloat(),f=l.getFloat(),p=l.getFloat();let g;switch(l.getFloat(),a){case\"min\":g=u;break;case\"max\":g=f;break;default:g=0===d?0:p/d}if(!(en||e===n&&c>=r)break;if(Number.isFinite(g)){const t=o[e];s.push({chr:t,start:c,end:h,value:g})}}}}class sd{constructor(e){this.data=e}loadArrayBuffer(e,t){const i=t.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(e,t){const i=Math.min(this.data.byteLength-e.start,e.size);return t?new Uint8Array(this.data,e.start,i):new DataView(this.data,e.start,i)}}class od extends Hh{queryable=!0;#h={};windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];constructor(e,t){super(t),this.reader=new Zh(e,t),this.genome=t,this.format=e.format||\"bigwig\"}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r}){await this.reader.loadHeader();const s=\"bigwig\"===this.reader.type;let o;return o=\"all\"===e.toLowerCase()?s?await this.getWGValues(r,n):[]:await this.reader.readFeatures(e,t,e,i,n,r),s||Tl(o),o}async getHeader(){return this.reader.loadHeader()}async defaultVisibilityWindow(){return\"bigwig\"===this.reader.type?-1:this.reader.featureDensity?Math.floor(1e4/this.reader.featureDensity):-1}async getWGValues(e,t){const i=this.genome,n=this.#h[e];if(n&&n.bpPerPixel>.8*t&&n.bpPerPixel<1.2*t)return n.values;{const n=await this.reader.readWGFeatures(t,e);let r=[];for(let e of n){const t=e.chr,n=i.getCumulativeOffset(t);if(void 0===n)continue;const s=Object.assign({},e);s.chr=\"all\",s.start=n+e.start,s.end=n+e.end,s._f=e,r.push(s)}return r.sort(((e,t)=>e.start-t.start)),this.#h[e]={values:r,bpPerPixel:t},r}}supportsWholeGenome(){return\"bigwig\"===this.reader.type}async trackType(){return this.reader.getTrackType()}get searchable(){return this.reader.searchable}async search(e){return this.reader.search(e)}}const ad=.01;function cd(e,t,i,n){if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"}),n&&xo.fillRect(e,t-4-2,0,4,i,{fillStyle:n});const r=void 0!==this.flipAxis&&this.flipAxis,s=.95*t-8-5,o=.95*t-5,a={font:\"normal 10px Arial\",textAlign:\"right\",fillStyle:\"black\",strokeStyle:\"black\"};xo.strokeLine(e,s,ad*i,o,ad*i,a),xo.fillText(e,l(r?this.dataRange.min:this.dataRange.max),s+4,ad*i+12,a);const c=.99*i;function l(e){return 0===e?\"0\":Math.abs(e)>=10?e.toFixed():Math.abs(e)>=1?e.toFixed(1):Math.abs(e)>=.1?e.toFixed(2):e.toExponential(1)}xo.strokeLine(e,s,c,o,c,a),xo.fillText(e,l(r?this.dataRange.max:this.dataRange.min),s+4,c-4,a),xo.strokeLine(e,o,ad*i,o,c,a)}class ld extends Hl{static defaults={height:50,flipAxis:!1,logScale:!1,windowFunction:\"mean\",graphType:\"bar\",normalize:void 0,scaleFactor:void 0,overflowColor:\"rgb(255, 32, 255)\",baselineColor:\"lightGray\",summarize:!0,visibilityWindow:void 0};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"wig\",this.featureType=\"numeric\",this.resolutionAware=!0,this.paintAxis=cd;const t=e.format?e.format.toLowerCase():e.format;e.featureSource?(this.featureSource=e.featureSource,delete e.featureSource):this.featureSource=\"bigwig\"===t?new od(e,this.browser.genome):\"tdf\"===t?new Qh(e,this.browser.genome):Ad(e,this.browser.genome),void 0===e.max||!0===e.autoscale?this.autoscale=!0:this.dataRange={min:e.min||0,max:e.max}}async postInit(){const e=await this.getHeader();this.disposed||e&&this.setTrackProperties(e)}supportsWholeGenome(){return void 0===this.visibilityWindow||this.visibilityWindow<0}async getFeatures(e,t,i,n){const r=this.windowFunction,s=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:r});if(this.normalize&&this.featureSource.normalizationFactor){const e=this.featureSource.normalizationFactor;for(let t of s)t.value*=e}if(this.scaleFactor){const e=this.scaleFactor;for(let t of s)t.value*=e}return!this.summarize||\"mean\"!==r&&\"min\"!==r&&\"max\"!==r?s:hd(s,t,n,r)}menuItemList(){const e=[];if(void 0!==this.flipAxis){function t(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}e.push(\"
\"),e.push({label:\"Flip y-axis\",click:t})}return this.featureSource.windowFunctions&&e.push(...this.wigSummarizationItems()),e.push(...this.numericDataMenuItems()),e}wigSummarizationItems(){const e=this.featureSource.windowFunctions,t=[];t.push(\"
\"),t.push(\"
Windowing function
\");for(const i of e){const n=Bt(Dl(i,this.windowFunction===i));function r(){this.windowFunction=i,this.trackView.updateViews()}t.push({object:n,click:r})}return t}async getHeader(){return\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(e,t,i,n){const r=!0===n?e<0?-Math.log10(Math.abs(e)+1):Math.log10(Math.abs(e)+1):e;return i/((!0===n?Math.log10(Math.abs(t)+1):t)-r)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return n=n<0?-Math.log10(Math.abs(n)+1):Math.log10(Math.abs(n)+1),i=i<0?-Math.log10(Math.abs(i)+1):Math.log10(Math.abs(i)+1),e=e<0?-Math.log10(Math.abs(e)+1):Math.log10(e+1),(this.flipAxis?e-n:i-e)*t}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight-1,a=r+s*n+1,c=this.getScaleFactor(this.dataRange.min,this.dataRange.max,o,this.logScale),l=e=>this.logScale?this.computeYPixelValueInLogScale(e,c):this.computeYPixelValue(e,c);if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,c=-1;const h=l(0);for(let d of t){if(d.enda)break;const t=(d.start-r)/n;if(isNaN(t))continue;let u=l(d.value);const f=(d.end-r)/n-t,p=e.alpha?_s.addAlpha(this.getColorForFeature(d),e.alpha):this.getColorForFeature(d);if(\"line\"===this.graphType)void 0!==s&&xo.strokeLine(i,c,s,t,u,{fillStyle:p,strokeStyle:p}),xo.strokeLine(i,t,u,t+f,u,{fillStyle:p,strokeStyle:p});else if(\"points\"===this.graphType){const e=this.config.pointSize||3,n=t+f/2;xo.fillCircle(i,n,u,e/2,{fillStyle:p,strokeStyle:p}),d.value>this.dataRange.max?xo.fillCircle(i,n,e/2,e/2,3,{fillStyle:this.overflowColor}):d.valuethis.dataRange.max?xo.fillRect(i,t,0,f,3,{fillStyle:this.overflowColor}):d.value0){const i=e.genomicLocation,n=[];t.sort((function(e,t){return Math.abs((e.start+e.end)/2-i)-Math.abs((t.start+t.end)/2-i)}));const r=t.length>10?t.slice(0,10):t;r.sort((function(e,t){return e.start-t.start}));for(let e of r)if(e){n.length>0&&n.push(\"
\");let t=e.end-e.start==1?Rt(Math.floor(e.start)+1):Rt(Math.floor(e.start)+1)+\"-\"+Rt(Math.floor(e.end));n.push({name:\"Position:\",value:t}),n.push({name:\"Value:     \",value:Rt(e.value.toFixed(4))})}return r.length...\"),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(e){let t=e.value<0&&this.altColor?this.altColor:this.color||\"rgb(150, 150, 150)\";return\"function\"==typeof t?t(e.value):t}dispose(){this.trackView=void 0}}function hd(e,t,i,n=\"mean\"){if(i<=1||!e||0===e.length)return e;const r=e[0].chr,s=i,o=[],a=e=>{const i=t+e.bin*s,a=i+s;let c;switch(n){case\"mean\":c=e.sumData/e.count;break;case\"max\":c=e.max;break;case\"min\":c=e.min;break;default:throw Error(`Unknown window function: ${n}`)}const l=`${n} of ${e.count} values`;o.push({chr:r,start:i,end:a,value:c,description:l})};let c;for(let i of e){let e=Math.floor((i.start-t)/s);const n=Math.floor((i.end-t)/s);if(c&&e===c.bin&&(c.add(i),e++),!c||n>c.bin){if(c&&a(c),n>e){const e=t+n*s;o.push({chr:r,start:i.start,end:e,value:i.value})}c=new dd(n,i)}}c&&a(c);const l=[];let h=o[0];for(let e of o)h.value===e.value&&e.start<=h.end?h.end=e.end:(l.push(h),h=e);return l.push(h),l}class dd{constructor(e,t){this.bin=e,this.sumData=t.value,this.count=1,this.min=t.value,this.max=t.value}add(e){this.sumData+=e.value,this.max=Math.max(e.value,this.max),this.min=Math.min(e.value,this.min),this.count++}get mean(){return this.sumData/this.count}}class ud extends Hh{constructor(e,t){super(t),this.config=e||{},this.genome=t,this.sourceType=void 0===e.sourceType?\"file\":e.sourceType,this.maxWGCount=e.maxWGCount||1e4,this.windowFunctions=[\"mean\",\"min\",\"max\",\"none\"];const i=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"tdf\"]);if(this.queryable=e.indexURL||!0===e.queryable,e.reader)this.reader=e.reader,this.queryable=!1!==e.queryable;else{if(\"ga4gh\"===e.sourceType)throw Error(\"Unsupported source type 'ga4gh'\");\"eqtl\"!==e.type&&\"qtl\"!==e.type||\"gtex-ws\"!==e.sourceType?\"htsget\"===e.sourceType?(this.reader=new Lh(e,t),this.queryable=!0):\"ucscservice\"===e.sourceType?(this.reader=new Nh(e.source),this.queryable=!0):\"custom\"===e.sourceType?(this.reader=new Eh(e.source),this.queryable=!1!==e.source.queryable):\"service\"===e.sourceType?(this.reader=new Ih(e,t),this.queryable=!0):(this.reader=new Ih(e,t),void 0!==e.queryable?this.queryable=e.queryable:(i.has(e.format)||this.reader.indexed)&&(this.queryable=!0)):(this.reader=new Bh(e),this.queryable=!0)}this.searchable=!1!==e.searchable}async defaultVisibilityWindow(){if(this.reader&&\"function\"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const e=await this.getHeader();return e?e.type:void 0}async getHeader(){if(!this.header)if(this.reader&&\"function\"==typeof this.reader.readHeader){const e=await this.reader.readHeader();e?(this.header=e,e.format&&(this.config.format=e.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r,windowFunction:s}){const o=\"all\"===e.toLowerCase();if(t=t||0,i=i||Number.MAX_SAFE_INTEGER,(o&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new hc(e,t,i)))&&await this.loadFeatures(e,t,i,r),o){if(!this.wgFeatures)if(this.supportsWholeGenome())if(\"wig\"===this.config.type){const e=await Ll(this.featureCache.getAllFeatures(),this.genome,1e6);this.wgFeatures=hd(e,0,n,s)}else this.wgFeatures=await Ll(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount);else this.wgFeatures=[];return this.wgFeatures}return this.featureCache.queryFeatures(e,t,i)}async findFeatures(e){return this.featureCache?this.featureCache.findFeatures(e):[]}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]:this.featureCache.getAllFeatures()}async loadFeatures(e,t,i,n){await this.getHeader();const r=this.reader;let s=t,o=i,a=e;if(!this.chrAliasManager&&this.reader&&this.reader.sequenceNames&&(this.chrAliasManager=new zh(this.reader.sequenceNames,this.genome)),this.chrAliasManager&&(a=await this.chrAliasManager.getAliasName(e)),(!n||n<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(a):void 0;s=0,o=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,i)}else if(n>i-t&&!1!==this.config.expandQuery){let e=Math.min(4.1*(i-t),n);this.config.minQuerySize&&et.end-t.start)continue;this.featureMap.set(i.toUpperCase(),t)}}}search(e){if(this.featureMap)return this.featureMap.get(e.toUpperCase())}}class pd{constructor({chr:e,locus:t,accession:i,aliases:n,features:r,sequence:s}){this.chr=e,this.locus=t,this.accession=i,this.aliases=n,this.features=r,this.sequence=s,this.bpLength=s.length}toJSON(){return{gbkURL:this.url}}getSequenceRecord(e){return{chr:this.chr,bpLength:this.bpLength}}get chromosomeNames(){return[this.chr]}getFirstChromosomeName(){return this.chr}get id(){return this.accession}get name(){return this.locus}get initialLocus(){return this.chr}get description(){return this.locus}get infoURL(){return this.url}showWholeGenomeView(){return!1}getHomeChromosomeName(){return this.chr}getChromosomeName(e){return e}getChromosomeDisplayName(e){return this.chr}getChromosome(e){if(e===this.chr)return{name:this.chr,bpLength:this.bpLength}}async loadChromosome(e){return this.getChromosome(e)}async getAliasRecord(e){}getCytobands(e){return[]}getChromosomes(){return[this.getChromosome(this.chr)]}get wgChromosomeNames(){}getGenomeCoordinate(e,t){if(e===this.chr)return t}getChromosomeCoordinate(e){return{chr:this.chr,position:e}}getCumulativeOffset(e){return 0}getGenomeLength(){return this.bpLength}async getSequence(e,t,i){return e===this.chr?this.sequence.substring(t,i):void 0}getSequenceInterval(e,t,i){return e===this.chr?new dc(this.chr,0,this.sequence.length,this.sequence):void 0}}const gd=/\\s+/,md=new Map;async function wd(e){let t=md.get(e);if(!t){t=function(e){if(!e)return null;const t=mh(e);let i=t.nextLine();const n=i.split(/\\s+/);if(\"LOCUS\"!==n[0].toUpperCase())throw Error(\"Expected `LOCUS` line. Found: \"+i);const r=n[1].trim();let s,o;do{if(i=t.nextLine(),i.startsWith(\"ACCESSION\")){const e=i.split(gd);if(e.length<2)throw Error(\"Genbank file missing ACCESSION number.\");s=e[1].trim()}else if(i.startsWith(\"ALIASES\")){const e=i.split(gd);e.length>1&&(o=e[1].split(\",\"))}}while(i&&!i.startsWith(\"FEATURES\"));const a=s||r,c=function(e,t){const i=[];let n,r,s,o=0;for(;;)if(r=t.nextLine(),\"\"!==r){if(!r||r.startsWith(\"ORIGIN\"))break;if(r.length<6)o<10&&console(\"Unexpected line in genbank file (skipping): \"+r),o++;else if(\" \"!==r.charAt(5)){let t=r.substring(5,21).trim();s={chr:e,type:t,attributes:{},getAttributeValue:function(e){return this.attributes[e]}},n=r.substring(21),\"source\"!==t.toLowerCase()&&i.push(s)}else{let t=r.substring(21).trim();if(t.length>0)if(47===t.charCodeAt(0)){if(47===n.charCodeAt(0)){let e=n.split(\"=\",2);if(e.length>1){let t=e[0].length>1?e[0].substring(1):\"\",i=Fd(e[1]);s.attributes[t]=i}}else{const t=n.includes(\"complement\")?\"-\":\"+\";s.strand=t;let i=n.replace(\"join\",\"\").replace(\"order\",\"\").replace(\"complement\",\"\").replace(\"(\",\"\").replace(\")\",\"\");if(i.includes(\"..\")){i=i.replace(\"<\",\"\").replace(\">\",\"\");const n=bd(i,e,t),r=n[0];s.start=r.start;const o=n[n.length-1];s.end=o.end,n.length>1&&(s.exons=n)}else s.start=parseInt(i)-1,s.end=s.start+1}n=t}else n+=t}}return i}(a,t),l=function(e){let t,i=\"\";for(;(t=e.nextLine())&&!t.startsWith(\"//\");){t=t.trim();const e=t.split(/\\s+/);for(let t=1;t1&&(o=parseInt(n[1])),r.push({chr:t,start:s,end:o,strand:i})}return r.sort((function(e,t){return e.start-t.start})),r}function Fd(e){return e.startsWith('\"')&&e.endsWith('\"')&&(e=e.substring(1,e.length-2)),e}class vd extends Hh{constructor(e,t){super(t),this.config=e,this.searchable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){if(!this.featureSource){const e=await wd(this.config.url);this.featureSource=new fd({genome:this.config.genome,features:e.features,searchableFields:[\"gene\",\"db_xref\",\"locus_tag\",\"transcript_id\"]})}return this.featureSource.getFeatures({chr:e,start:t,end:i})}supportsWholeGenome(){return!1}search(e){return this.featureSource.search(e)}}const yd=new Set([\"bigwig\",\"bw\",\"bigbed\",\"bb\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\"]);function Ad(e,t){const i=e.format?e.format.toLowerCase():void 0;return e.features?new fd(e,t):yd.has(i)?new od(e,t):\"tdf\"===i?new Qh(e,t):\"gbk\"===i?new vd(e,t):new ud(e,t)}function Cd(e){return(3-e.readingFrame)%3}function _d(e){return e.cdStart||e.start}function xd(e){return e.cdEnd||e.end}const kd=.25;function Id(e,t,i){let n=(e.start-t)/i,r=(e.end-t)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Sd(e,t,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(e);let o,a;r.fillStyle=n,r.strokeStyle=n,\"SQUISHED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*e.row):\"EXPANDED\"===this.displayMode&&void 0!==e.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*e.row):(o=this.featureHeight,a=this.margin);const c=s.pixelWidth,l=a+o/2,h=o/2,d=l-h/2,u=e.exons?e.exons.length:0,f=Id(e,t,i),p=this.arrowSpacing,g=\"+\"===e.strand?1:\"-\"===e.strand?-1:0;if(0===u){const e=Math.max(0,f.px),t=Math.min(c,f.px1),i=t-e;if(r.fillRect(e,a,i,o),0!==g){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let i=e+p/2;ic)break;if(f.utr)r.fillRect(w,d,F,h);else{if(f.cdStart&&(m=Math.round((f.cdStart-t)/i),r.fillRect(w,d,m-w,h),F-=m-w,w=m),f.cdEnd&&(m=Math.round((f.cdEnd-t)/i),r.fillRect(m,d,b-m,h),F-=b-m,b=m),F=Math.max(F,1),r.fillRect(w,a,F,o),void 0!==f.readingFrame&&s.bpPerPixel0&&void 0!==e.exons[u-1].readingFrame?e.exons[u-1]:void 0,n=up+5&&0!==g&&s.bpPerPixel>kd){r.fillStyle=\"white\",r.strokeStyle=\"white\";for(let e=w+p/2;e{const f=Math.round((i-s)/o),p=Math.round((n-s)/o)-f;let g;if(void 0===r){if(l.hasSequence(i,n)){const e=l.getSequence(i,n);if(e&&3===e.length){const i=\"+\"===t?e:ac(e.split(\"\").reverse().join(\"\"));g=Gd[i]}}}else g=r;e.fillStyle=\"M\"===r||\"M\"===g&&0===u?\"#83f902\":\"STOP\"===g?\"#ff2101\":h[d],e.fillRect(f,a,p,c),g&&(e.save(),((t,i,n,r,s)=>{\"STOP\"===s&&(s=\"*\");const o=e.measureText(s).width;xo.fillText(e,s,n+(i-o)/2,r-4,{fillStyle:\"#ffffff\"})})(0,p,f,a+c,g),e.restore());const m=n-i;return m>0&&m<3?{start:i,end:n}:void 0},u=Cd(n);let f,p,g,m,w,b=_d(n),F=xd(n),v=1;if(\"+\"===t){for(u>0&&(b+=u),v=1,w=0,f=b;f0||g){const e=u>0?Bd.call(this,t,u,b-u,b,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;i&&d(t,b-u,b,i.aminoAcidLetter,0,void 0),n&&d(t,g.start,g.end,n.aminoAcidLetter,m,void 0)}}}else{for(u>0&&(F-=u),v=1,w=0,w=0,p=F;p>b;w++,p-=3)m=v%2,f=Math.max(b,p-3),g=d(t,f,p,void 0,v%2,w),++v;if(u>0||g){const e=u>0?Bd.call(this,t,u,F,F+u,g,i,n,r,l):Bd.call(this,t,void 0,void 0,void 0,g,i,n,r,l);if(e){const{left:i,rite:n}=e;n&&d(t,F,F+u,n.aminoAcidLetter,0,void 0),i&&d(t,g.start,g.end,i.aminoAcidLetter,m,void 0)}}}e.restore()}function Nd(e,t,i,n,r,s,o){try{e.save();let s=t.name;if(void 0===s&&t.gene&&(s=t.gene.name),void 0===s&&(s=t.id||t.ID),!s||\".\"===s)return;let a=o.pixelXOffset||0;const c=Math.max(i,-a);let l,h=(c+Math.min(n,-a+o.viewportWidth))/2;\"COLLAPSED\"===this.displayMode&&\"SLANT\"===this.labelDisplayMode&&(l={rotate:{angle:45}});const d=function(e,t){return t?e+20:e+25}(r,l);let u=this.getColorForFeature(t),f=this.browser.qtlSelections.hasPhenotype(t.name);const p={textAlign:\"SLANT\"===this.labelDisplayMode?void 0:\"center\",fillStyle:u,strokeStyle:u},g=e.measureText(s),m=h-g.width/2,w=h+g.width/2,b=o.rowLastLabelX[t.row]||-Number.MAX_SAFE_INTEGER;(o.labelAllFeatures||m>b||f)&&(o.rowLastLabelX[t.row]=w,\"y\"===o.axis?(e.save(),xo.labelTransformWithContext(e,h),xo.fillText(e,s,h,d,p,l),e.restore()):(e.clearRect(h-g.width/2-1,d-g.actualBoundingBoxAscent-1,g.width+2,g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+2),xo.fillText(e,s,h,d,p,l)))}finally{e.restore()}}function Bd(e,t,i,n,r,s,o,a,c){let l,h,d=\"\",u=\"\",f=\"\";const p={left:void 0,rite:void 0};if(\"+\"===e){if(t){if(u=c.getSequence(i,n),!u)return;if([l,h]=[xd(s)-(3-t),xd(s)],d=c.getSequence(l,h),!d)return;f=d+u,p.left={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(d=c.getSequence(r.start,r.end),!d)return;const e=Cd(a),t=_d(a);if(u=c.getSequence(t,t+e),!u)return;f=d+u,p.rite={triplet:f,aminoAcidLetter:Gd[f]}}}else{if(t){if(d=c.getSequence(i,n),void 0===d)return;if([l,h]=[_d(a),_d(a)+(3-t)],u=c.getSequence(l,h),void 0===u)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.rite={triplet:f,aminoAcidLetter:Gd[f]}}if(r){if(u=c.getSequence(r.start,r.end),void 0===u)return;const e=Cd(s),t=xd(s);if(d=c.getSequence(t-e,t),void 0===d)return;f=d+u,f=ac(f.split(\"\").reverse().join(\"\")),p.left={triplet:f,aminoAcidLetter:Gd[f]}}}return p}const Md=new Set([\"nonsense\",\"missense\",\"stop-loss\",\"frameshift\",\"cds-indel\"]),Rd=new Set([\"coding-synon\"]),Dd=new Set([\"splice-3\",\"splice-5\"]),Td=new Set([\"untranslated-5\",\"untranslated-3\"]);function Ld(e,t,i,n,r){var s,o,a,c,l,h,d=Id(e,t,i),u=this.margin,f=this.snpColors.length;switch(s=\"squished\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case\"function\":c=e.func,h=c.split(\",\"),l=h.map((function(e){return Md.has(e)||Dd.has(e)?f-1:Rd.has(e)?f-2:Td.has(e)?f-3:0})),o=l.reduce((function(e,t){return Math.max(e,t)}));break;case\"class\":o=\"deletion\"===(a=e.class)?f-1:\"mnp\"===a?f-2:\"microsatellite\"===a||\"named\"===a?f-3:0}r.fillStyle=this.snpColors[o],r.fillRect(d.px,u,d.pw,s)}function zd(e,t,i,n,r){const s=\"EXPANDED\"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;\"COLLAPSED\"!==this.displayMode&&void 0!==e.row&&(o+=e.row*s);const a=o+.5*s,c=a-.5*s,l=a+.5*s,h=Math.round((e.junction_left-t)/i),d=Math.round((e.junction_right-t)/i);r.beginPath(),r.moveTo(h,a),r.bezierCurveTo(h,c,d,c,d,a),r.lineWidth=1+Math.log(e.num_junction_reads)/Math.log(2),r.strokeStyle=\"blue\",r.stroke();const u=e.spanning_frag_coords;for(let e=0;et&&(t=i.row);return this.margin+(t+1)*(\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,bpEnd:s,pixelWidth:o,pixelHeight:a,referenceFrame:c}=e;if(nr&&i.end!isNaN(e)))));let h=[];const d=[];for(let o of t){if(o.ends)break;\"COLLAPSED\"===this.displayMode&&this.browser.qtlSelections.hasPhenotype(o.name)&&d.push(o);const t=\"COLLAPSED\"===this.displayMode?0:o.row;e.drawLabel=e.labelAllFeatures||l>10;const c=Math.ceil((o.end-r)/n),u=h[t];if(!u||c>u){this.render.call(this,o,r,n,a,i,e);const s=Math.floor((o.start-r)/n);u&&s-u<=0&&(i.globalAlpha=.5,xo.strokeLine(i,s,0,s,a,{strokeStyle:\"rgb(255, 255, 255)\"}),i.globalAlpha=1),h[t]=c}}for(let t of d)e.drawLabel=!0,this.render.call(this,t,r,n,a,i,e)}else console.log(\"No feature list\")}clickedFeatures(e){const t=e.y-this.margin,i=super.clickedFeatures(e);let n;switch(this.displayMode){case\"SQUISHED\":n=Math.floor(t/this.squishedRowHeight);break;case\"EXPANDED\":n=Math.floor(t/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(e){return void 0===n||void 0===e.row||n===e.row}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=e._f||e,r=\"function\"==typeof t.popupData?t.popupData(i):this.extractPopupData(t);if(r){n.length>0&&n.push(\"

\");const s=this.infoURL||this.config.infoURL;for(let t of r)if(n.push(t),s&&t.name&&\"name\"===t.name.toLowerCase()&&t.value&&Mt(t.value)&&!t.value.startsWith(\"<\")){const i=s.replace(\"$$\",e.name);t.value=`${t.value}`}const o=\"gff\"===this.config.format||\"gff3\"===this.config.format||\"gtf\"===this.config.format;if(t.exons&&t.exons.length>1)for(let e=0;e=r.start&&i<=r.end){const i=o?r.number:\"-\"===t.strand?t.exons.length-e:e+1;i&&(n.push(\"
\"),n.push({name:\"Exon Number\",value:i}));break}}}}return n}menuItemList(){const e=[];if(this.render===Ld){e.push(\"
\");for(const i of[\"function\",\"class\"]){const n=Bt(Dl(`Color by ${i}`,i===this.colorBy));function r(){this.colorBy=i,this.trackView.repaintViews()}e.push({object:n,click:r})}}e.push(\"
\");const t={COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"};for(const s of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){const o=Bt(Dl(t[s],s===this.displayMode));function a(){this.displayMode=s,this.config.displayMode=s,this.trackView.checkContentHeight(),this.trackView.repaintViews()}e.push({object:o,click:a})}return e}contextMenuItemList(e){const t=this.clickedFeatures(e);if(void 0===t||0===t.length)return;t.length>1&&t.sort(((e,t)=>t.end-t.start-(e.end-e.start)));const i=t[0];if(i.end-i.start<=1e6){const e=[{label:\"View feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&void 0!==navigator.clipboard&&e.push({label:\"Copy feature sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?\"-\"===i.strand&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.push(\"
\"),e}}description(){if(Ld===this.render){let e=\"\"+this.name+\"
\";return e+=\"Color By Function:
\",e+='Red: Coding-Non-Synonymous, Splice Site
',e+='Green: Coding-Synonymous
',e+='Blue: Untranslated
',e+='Black: Intron, Locus, Unknown

',e+=\"Color By Class:
\",e+='Red: Deletion
',e+='Green: MNP
',e+='Blue: Microsatellite, Named
',e+='Black: Indel, Insertion, SNP',e+=\"\",e}return super.description()}getColorForFeature(e){const t=e._f||e;let i;if(e.name&&this.browser.qtlSelections.hasPhenotype(e.name))i=this.browser.qtlSelections.colorForGene(e.name);else if(this.altColor&&\"-\"===t.strand)i=\"function\"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)i=\"function\"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const e=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];i=this.colorTable.getColor(e)}else t.color&&(i=t.color);if(i||(i=\"rgb(0, 0, 150)\"),t.alpha&&1!==t.alpha)i=_s.addAlpha(i,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const e=function(e,t,i){const n=(t-e)/9,r=Math.floor((i-e)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,t.score);t.alpha=e,i=_s.addAlpha(i,e)}return i}dispose(){this.trackView=void 0}}class Pd{constructor(t){if(this.config=t,this.browser=t.browser,this.columnFormat=t.columnFormat,this.tableRowSelectionList=[],this.tableDOM=e({class:\"igv-roi-table\"}),t.width){let[e]=t.width.split(\"px\");e=parseInt(e,10),this.tableDOM.style.width=`${Math.min(e,1600)}px`}t.parent.appendChild(this.tableDOM),this.headerDOM=t,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=t.gotoButtonHandler}set headerDOM({browser:t,parent:i,headerTitle:n,dismissHandler:r}){const s=e();this.tableDOM.appendChild(s);const o=e();s.appendChild(o),o.innerHTML=n;const a=e();s.appendChild(a),a.appendChild(l(\"times\")),this.boundDismissHandler=function(e){e.stopPropagation(),r()}.bind(this),a.addEventListener(\"click\",this.boundDismissHandler);const{y:c}=t.root.getBoundingClientRect(),{y:h}=i.getBoundingClientRect(),d=-(h-c);p(this.tableDOM,s,{minX:0,minY:d}),this.tableDOM.style.display=\"none\",this._headerDOM=s}set tableColumnTitles(t){const i=e({class:\"igv-roi-table-column-titles\"});t.appendChild(i);for(const{label:t,width:n}of this.columnFormat){const r=e();i.appendChild(r),r.style.width=n,r.innerText=t}this._tableColumnTitlesDOM=i}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(t){const i=e({class:\"igv-roi-table-row-container\"});t.appendChild(i),this._tableRowContainerDOM=i}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(t){const i=e();this.tableDOM.appendChild(i);const n=e({class:\"igv-roi-table-button\"});i.appendChild(n),n.id=\"igv-roi-table-view-button\",n.textContent=\"Go To\",n.style.pointerEvents=\"none\",this._footerDOM=i,this.gotoButton=n,this.boundGotoButtonHandler=t.bind(this),this.gotoButton.addEventListener(\"click\",this.boundGotoButtonHandler)}tableRowDOMHelper(e){e.addEventListener(\"mousedown\",(t=>{t.stopPropagation(),e.classList.toggle(\"igv-roi-table-row-selected\"),e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\"),this.setTableRowSelectionState(e.classList.contains(\"igv-roi-table-row-selected\"))})),e.addEventListener(\"mouseover\",(t=>{e.classList.contains(\"igv-roi-table-row-selected\")?e.classList.remove(\"igv-roi-table-row-hover\"):e.classList.add(\"igv-roi-table-row-hover\")})),e.addEventListener(\"mouseout\",(t=>{e.classList.remove(\"igv-roi-table-row-hover\")}))}clearTable(){const e=this.tableRowContainer.querySelectorAll(\".igv-roi-table-row\");for(let t of e)t.remove()}setTableRowSelectionState(e){e?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?\"auto\":\"none\"}present(){this.tableDOM.style.left=\"0px\";const{y:e}=this.browser.root.getBoundingClientRect(),{y:t}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=e-t+\"px\",this.tableDOM.style.display=\"flex\"}dismiss(){this.tableDOM.style.display=\"none\"}isVisible(){return\"none\"!==this.tableDOM.style.display}dispose(){this.tableDOM.innerHTML=\"\",this.tableDOM.remove();for(const e of Object.keys(this))this[e]=void 0;document.removeEventListener(\"click\",this.boundDismissHandler)}}class Od extends Pd{constructor(e){super(Object.assign({width:\"1024px\"},e)),this.descriptionDOM=e}set descriptionDOM(t){if(t.description){let i;i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.innerHTML=\"BLAT result for query sequence:\",i=e({class:\"igv-roi-table-description\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.style.height=\"auto\",i.style.maxHeight=\"128px\",i.innerHTML=t.description,i=e({class:\"igv-roi-table-goto-explainer\"}),this.tableDOM.insertBefore(i,this.tableColumnTitles),i.innerHTML=\"Select one or more rows and click Go To to view the regions\"}}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),n=t.map((e=>isFinite(e)?Rt(e):e));for(let t=0;te.remove())),e.length>0)for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}static getColumnFormatConfiguration(){return[{label:\"chr\",width:\"7%\"},{label:\"start\",width:\"12%\"},{label:\"end\",width:\"12%\"},{label:\"strand\",width:\"5%\"},{label:\"score\",width:\"5%\"},{label:\"match\",width:\"5%\"},{label:\"mis-match\",width:\"7%\"},{label:\"rep. match\",width:\"7%\"},{label:\"N's\",width:\"3%\"},{label:\"Q gap count\",width:\"9%\"},{label:\"Q gap bases\",width:\"9%\"},{label:\"T gap count\",width:\"9%\"},{label:\"T gap bases\",width:\"9%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(const e of t){const t=[];e.querySelectorAll(\"div\").forEach((e=>t.push(e.innerText)));const[n,r,s]=t;i.push(`${n}:${r}-${s}`)}for(const e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),this.browser.search(i.join(\" \"))}}const Ud=\"https://igv.org/services/blatUCSC.php\";async function qd({url:e,userSeq:t,db:i}){if(e=e||Ud,!i)throw Error(\"Blat database is not defined\");const n=await async function(e=\"\",t,i){const n=new URLSearchParams;n.append(\"userSeq\",t),n.append(\"db\",i);const r=await fetch(e,{method:\"post\",body:n});return r.json()}(e,t,i);n.fields;return n.blat.map($c)}const Qd=25e3;class Vd extends Hd{constructor(e,t){super(e,t),this.name||(this.name=\"Blat Results\"),this.sequence=e.sequence,this.table=void 0,e.features&&(this._features=e.features,this.featureSource=new fd({features:e.features},this.browser.genome),delete e.features)}async postInit(){if(!this.featureSource){const e=this.browser.genome.id,t=this.browser.config.blatServerURL,i=await qd({url:t,userSeq:this.sequence,db:e});this._features=i,this.featureSource=new fd({features:i},this.browser.genome)}}openTableView(){if(void 0===this.table){const e=this._features.map((e=>[e.chr,e.start+1,e.end,e.strand,e.score,e.matches,e.misMatches,e.repMatches,e.nCount,e.qNumInsert,e.qBaseInsert,e.tNumInsert,e.tBaseInsert])),t={browser:this.browser,parent:this.browser.columnContainer,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:Od.getColumnFormatConfiguration(),gotoButtonHandler:Od.gotoButtonHandler};this.table=new Od(t),this.table.renderTable(e)}this.table.present()}menuItemList(){const e=super.menuItemList();return e.push(\"
\"),e.push({label:\"Open table view\",click:function(){this.openTableView()}}),e}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function jd({sequence:e,browser:t,name:i,title:n}){if(e.length>Qd)t.alert.present(`Sequence size exceeds maximum allowed length (${e.length} > 25000)`);else try{const r=t.genome.id,s=t.config.blatServerURL||\"https://igv.org/services/blatUCSC.php\",o={type:\"blat\",name:i||\"blat results\",title:n||\"blat results\",sequence:e,altColor:\"rgb(176, 176, 236)\",color:\"rgb(236, 176, 176)\",searchable:!1,features:await qd({url:s,userSeq:e,db:r})};(await t.loadTrack(o)).openTableView()}catch(e){t.alert.present(`Error performing blat search: ${e}`)}}const Wd=Number.MIN_SAFE_INTEGER,Gd={TTT:\"F\",TTC:\"F\",TTA:\"L\",TTG:\"L\",CTT:\"L\",CTC:\"L\",CTA:\"L\",CTG:\"L\",ATT:\"I\",ATC:\"I\",ATA:\"I\",ATG:\"M\",GTT:\"V\",GTC:\"V\",GTA:\"V\",GTG:\"V\",TCT:\"S\",TCC:\"S\",TCA:\"S\",TCG:\"S\",CCT:\"P\",CCC:\"P\",CCA:\"P\",CCG:\"P\",ACT:\"T\",ACC:\"T\",ACA:\"T\",ACG:\"T\",GCT:\"A\",GCC:\"A\",GCA:\"A\",GCG:\"A\",TAT:\"Y\",TAC:\"Y\",TAA:\"STOP\",TAG:\"STOP\",CAT:\"H\",CAC:\"H\",CAA:\"Q\",CAG:\"Q\",AAT:\"N\",AAC:\"N\",AAA:\"K\",AAG:\"K\",GAT:\"D\",GAC:\"D\",GAA:\"E\",GAG:\"E\",TGT:\"C\",TGC:\"C\",TGA:\"STOP\",TGG:\"W\",CGT:\"R\",CGC:\"R\",CGA:\"R\",CGG:\"R\",AGT:\"S\",AGC:\"S\",AGA:\"R\",AGG:\"R\",GGT:\"G\",GGC:\"G\",GGA:\"G\",GGG:\"G\"},$d={},Kd=[\"A\",\"G\",\"C\",\"T\",\"Y\",\"R\",\"W\",\"S\",\"K\",\"M\",\"D\",\"V\",\"H\",\"B\",\"N\",\"X\"],Yd=[\"T\",\"C\",\"G\",\"A\",\"R\",\"Y\",\"W\",\"S\",\"M\",\"K\",\"H\",\"B\",\"D\",\"V\",\"N\",\"X\"];for(let NA=0;NA{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?\"Close Translation\":\"Three-frame Translate\",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let e of this.trackView.viewports)e.setContentHeight(Xd);this.trackView.setTrackHeight(Xd)}else{for(let e of this.trackView.viewports)e.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(e){const t=e.viewport;if(t.referenceFrame.bpPerPixel<=1){const e=t.getWidth()*t.referenceFrame.bpPerPixel,i=t.referenceFrame.chr,n=Math.floor(t.referenceFrame.start),r=Math.ceil(n+e),s=[{label:this.reversed?\"View visible sequence (reversed)...\":\"View visible sequence...\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\",this.browser.alert.present(e)}}];return Xa()&&s.push({label:\"Copy visible sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);e?this.reversed&&(e=cc(e)):e=\"Unknown sequence\";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),s.push({label:\"BLAT read sequence\",click:async()=>{let e=await this.browser.genome.getSequence(i,n,r);if(e){this.reversed&&(e=cc(e));const t=`blat: ${i}:${n+1}-${r}`,s=`blat: ${i}:${n+1}-${r}`;jd({sequence:e,browser:this.browser,name:t,title:s})}}}),s.push(\"
\"),s}}translateSequence(e){const t=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;e.length-n>=3;){let r=e.slice(n,n+3);this.reversed&&(r=r.split(\"\").reverse().join(\"\"));const s=Gd[r.toUpperCase()]||\"\";t[i].push({codons:r,aminoA:s}),n+=3}}return t}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new Jd(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome}async getFeatures(e,t,i,n){if(t=Math.floor(t),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:t,sequence:await n.getSequence(e,t,i)}}}draw(e){const t=e.context;if(e.features){let i=e.features.sequence;if(!i)return;this.reversed&&(i=i.split(\"\").map((function(e){return $d[e]})).join(\"\"));const n=e.features.bpStart,r=1+e.bpStart+e.pixelWidth*e.bpPerPixel;for(let s=Math.floor(e.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r.1)xo.fillRect(t,n,5,o,10,{fillStyle:c});else{const i=n+.5*(o-t.measureText(a).width);\"y\"===e.axis?(t.save(),xo.labelTransformWithContext(t,i),xo.strokeText(t,a,i,15,{strokeStyle:c}),t.restore()):xo.strokeText(t,a,i,15,{strokeStyle:c})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;ie.pixelWidth)break;let f=c.aminoA;c.aminoA.indexOf(\"STOP\")>-1?(a=\"rgb(255, 0, 0)\",f=\"STOP\"):\"M\"===c.aminoA&&(a=\"rgb(0, 153, 0)\",f=\"START\"),xo.fillRect(t,h,r,d-h,25,{fillStyle:a}),e.bpPerPixel<=.1&&xo.strokeText(t,f,u-t.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(e){return this.height=this.frameTranslate?Xd:25,this.height}fillColor(e){return this.color?this.color:\"dna\"===this.sequenceType?this.browser.nucleotideColors[e]||\"gray\":\"rgb(0, 0, 150)\"}getState(){const e={type:\"sequence\"};return this.order!==Wd&&(e.order=this.order),this.reversed&&(e.revealed=!0),e}}class Jd{constructor(e,t){this.config=e,this.genome=t}async init(){this.fasta=await Nc(this.config),this.chrNameMap=new Map;for(let e of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(e),e)}async getSequence(e,t,i){const n=this.chrNameMap.has(e)?this.chrNameMap.get(e):e;return this.fasta.getSequence(n,t,i)}}class eu{constructor(e,t,i,n){this.guid=s(),this.trackView=e,this.referenceFrame=i,this.browser=e.browser,this.$viewport=Bt('
'),t.appendChild(this.$viewport.get(0)),e.track.height&&(this.$viewport.get(0).style.height=`${e.track.height}px`),e.track instanceof Zd&&(this.alert=new Ta(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(e){this.messageDiv||(this.messageDiv=document.createElement(\"div\"),this.messageDiv.className=\"igv-viewport-message\",this.$viewport.append(Bt(this.messageDiv))),this.messageDiv.textContent=e,this.messageDiv.style.display=\"inline-block\"}hideMessage(e){this.messageDiv&&(this.messageDiv.style.display=\"none\")}setTrackLabel(e){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(e){this.contentTop=e,this.$viewport.height()}async loadFeatures(){}clearCache(){}repaint(){}draw(e,t,i){console.log(\"Viewport - draw(drawConfiguration, features, roiFeatures)\")}checkContentHeight(e){let t=this.trackView.track;if(e=e||this.cachedFeatures,\"FILL\"===t.displayMode)this.setContentHeight(this.$viewport.height());else if(\"function\"==typeof t.computePixelHeight&&e&&e.length>0){let i=t.computePixelHeight(e);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(e){this.contentHeight=e}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(e){this.$viewport.width(e)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(e,t){console.log(\"Viewport - containsPosition(chr, position)\")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.$viewport.get(0).remove();for(let e of Object.keys(this))this[e]=void 0}}\n", - "/*!!\n", - " * Canvas 2 Svg v1.0.19\n", - " * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.\n", - " *\n", - " * Licensed under the MIT license:\n", - " * http://www.opensource.org/licenses/mit-license.php\n", - " *\n", - " * Author:\n", - " * Kerry Liu\n", - " *\n", - " * Copyright (c) 2014 Gliffy Inc.\n", - " */function tu(e,t){var i,n=Object.keys(t);for(i=0;i0){\"path\"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:t,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement(\"g\");t.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute(\"transform\");n?n+=\" \":n=\"\",n+=e,this.__currentElement.setAttribute(\"transform\",n)}addTrackGroupWithTranslationAndClipRect(e,t,i,n,r,s){const o=e+\"_clip_rect\";let a=this.__createElement(\"clipPath\",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement(\"rect\",{x:\"0\",y:s.toString(),width:n.toString(),height:r.toString()}));let c=this.__createElement(\"g\");this.__rootGroup.appendChild(c),c.setAttribute(\"transform\",tu(\"translate({x},{y})\",{x:t,y:i})),c.setAttribute(\"id\",e+\"_group\"),c.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:o})),this.__currentElement=c}scale(e,t){void 0===t&&(t=e),this.__addTransform(tu(\"scale({x},{y})\",{x:e,y:t}))}rotate(e){var t=180*e/Math.PI;this.__addTransform(tu(\"rotate({angle},{cx},{cy})\",{angle:t,cx:0,cy:0}))}translate(e,t){this.__addTransform(tu(\"translate({x},{y})\",{x:e,y:t}))}transform(e,t,i,n,r,s){this.__addTransform(tu(\"matrix({a},{b},{c},{d},{e},{f})\",{a:e,b:t,c:i,d:n,e:r,f:s}))}beginPath(){var e;this.__currentDefaultPath=\"\",this.__currentPosition={},e=this.__createElement(\"path\",{},!0),this.__closestGroupOrSvg().appendChild(e),this.__currentElement=e}__applyCurrentDefaultPath(){var e=this.__currentElement;\"path\"===e.nodeName?e.setAttribute(\"d\",this.__currentDefaultPath):console.error(\"Attempted to apply path command to node\",e.nodeName)}__addPathCommand(e){this.__currentDefaultPath+=\" \",this.__currentDefaultPath+=e}moveTo(e,t){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:e,y:t},this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand(\"Z\")}lineTo(e,t){this.__currentPosition={x:e,y:t},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf(\"M\")>-1?this.__addPathCommand(tu(\"L {x} {y}\",{x:e,y:t})):this.__addPathCommand(tu(\"M {x} {y}\",{x:e,y:t}))}bezierCurveTo(e,t,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(tu(\"C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}\",{cp1x:e,cp1y:t,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(e,t,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(tu(\"Q {cpx} {cpy} {x} {y}\",{cpx:e,cpy:t,x:i,y:n}))}arcTo(e,t,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error(\"IndexSizeError: The radius provided (\"+r+\") is negative.\");if(s===e&&o===t||e===i&&t===n||0===r)this.lineTo(e,t);else{var a=ru([s-e,o-t]),c=ru([i-e,n-t]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),d=ru([a[0]+c[0],a[1]+c[1]]),u=r/Math.sin(h/2),f=e+u*d[0],p=t+u*d[1],g=[-a[1],a[0]],m=[c[1],-c[0]],w=function(e){var t=e[0];return e[1]>=0?Math.acos(t):-Math.acos(t)},b=w(g),F=w(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,b,F)}else this.lineTo(e,t)}}}stroke(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"fill stroke markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"stroke\")}fill(){\"path\"===this.__currentElement.nodeName&&this.__currentElement.setAttribute(\"paint-order\",\"stroke fill markers\"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement(\"fill\")}rect(e,t,i,n){\"path\"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(e,t),this.lineTo(e+i,t),this.lineTo(e+i,t+n),this.lineTo(e,t+n),this.lineTo(e,t),this.closePath()}fillRect(e,t,i,n){n<0&&(t+=n,n=-n),i<0&&(e+=i,i=-i);var r,s,o,a={x:e,y:t,width:i,height:n};(!this.viewbox||(r=this.viewbox,s=a,r.xs.x&&r.ys.y))&&(o=this.__createElement(\"rect\",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement(\"fill\"))}strokeRect(e,t,i,n){var r;r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement(\"stroke\")}strokeEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"stroke\")}fillEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,\"fill\")}__ellipse(e,t,i,n,r,s,o,a,c){const l={cx:e,cy:t,rx:i,ry:n},h=this.__createElement(\"ellipse\",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var e=this.__closestGroupOrSvg().getAttribute(\"transform\"),t=this.__root.childNodes[1],i=t.childNodes,n=i.length-1;n>=0;n--)i[n]&&t.removeChild(i[n]);this.__currentElement=t,this.__groupStack=[],e&&this.__addTransform(e)}clearRect(e,t,i,n){if(0!==e||0!==t||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement(\"rect\",{x:e,y:t,width:i,height:n,fill:\"#FFFFFF\"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(e,t,i,n){var r=this.__createElement(\"linearGradient\",{id:iu(this.__ids),x1:e+\"px\",x2:i+\"px\",y1:t+\"px\",y2:n+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(r),new au(r,this)}createRadialGradient(e,t,i,n,r,s){var o=this.__createElement(\"radialGradient\",{id:iu(this.__ids),cx:n+\"px\",cy:r+\"px\",r:s+\"px\",fx:e+\"px\",fy:t+\"px\",gradientUnits:\"userSpaceOnUse\"},!1);return this.__defs.appendChild(o),new au(o,this)}__parseFont(){var e=/^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))(?:\\s*\\/\\s*(normal|[.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])))?\\s*([-,\\'\\\"\\sa-z0-9]+?)\\s*$/i.exec(this.font),t={style:e[1]||\"normal\",size:e[4]||\"10px\",family:e[6]||\"sans-serif\",weight:e[3]||\"normal\",decoration:e[2]||\"normal\",href:null};return\"underline\"===this.__fontUnderline&&(t.decoration=\"underline\"),this.__fontHref&&(t.href=this.__fontHref),t}__wrapTextLink(e,t){if(e.href){var i=this.__createElement(\"a\");return i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",e.href),i.appendChild(t),i}return t}__applyText(e,t,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement(\"text\",{\"font-family\":o.family,\"font-size\":o.size,\"font-style\":o.style,\"font-weight\":o.weight,\"text-decoration\":o.decoration,x:t,y:i,\"text-anchor\":(r=this.textAlign,s={left:\"start\",right:\"end\",center:\"middle\",start:\"start\",end:\"end\"},s[r]||s.start),\"dominant-baseline\":nu(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(e)),this.__currentElement=c,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,c))}fillText(e,t,i){this.__applyText(e,t,i,\"fill\")}strokeText(e,t,i){this.__applyText(e,t,i,\"stroke\")}measureText(e){return this.__ctx.font=this.font,this.__ctx.measureText(e)}arc(e,t,i,n,r,s){if(n!==r){(n%=2*Math.PI)===(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=e+i*Math.cos(r),a=t+i*Math.sin(r),c=e+i*Math.cos(n),l=t+i*Math.sin(n),h=s?0:1,d=0,u=r-n;u<0&&(u+=2*Math.PI),d=s?u>Math.PI?0:1:u>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(tu(\"A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}\",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:d,sweepFlag:h,endX:o,endY:a})),this.__currentPosition={x:o,y:a}}}clip(){var e=this.__closestGroupOrSvg(),t=this.__createElement(\"clipPath\"),i=iu(this.__ids),n=this.__createElement(\"g\");this.__applyCurrentDefaultPath(),e.removeChild(this.__currentElement),t.setAttribute(\"id\",i),t.appendChild(this.__currentElement),this.__defs.appendChild(t),e.setAttribute(\"clip-path\",tu(\"url(#{id})\",{id:i})),e.appendChild(n),this.__currentElement=n}drawImage(){var e,t,i,n,r,s,o,a,c,l,h,d,u,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)e=f[1],t=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)e=f[1],t=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error(\"Invalid number of arguments passed to drawImage: \"+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],e=f[5],t=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var w=\"translate(\"+e+\", \"+t+\")\";if(p instanceof lu){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)u=c.childNodes[0].getAttribute(\"id\"),this.__ids[u]=u,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,F=l.getAttribute(\"transform\");b=F?F+\" \"+w:w,l.setAttribute(\"transform\",b),o.appendChild(l)}}}else\"CANVAS\"!==p.nodeName&&\"IMG\"!==p.nodeName||((h=this.__createElement(\"image\")).setAttribute(\"width\",i),h.setAttribute(\"height\",n),h.setAttribute(\"preserveAspectRatio\",\"none\"),(g||m||r!==p.width||s!==p.height)&&((d=this.__document.createElement(\"canvas\")).width=i,d.height=n,d.getContext(\"2d\").drawImage(p,g,m,r,s,0,0,i,n),p=d),h.setAttribute(\"transform\",w),h.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===p.nodeName?p.toDataURL():p.getAttribute(\"src\")),o.appendChild(h))}createPattern(e,t){let i,n=this.__document.__createElement(\"pattern\"),r=iu(this.__ids);return n.setAttribute(\"id\",r),n.setAttribute(\"width\",e.width),n.setAttribute(\"height\",e.height),\"CANVAS\"===e.nodeName||\"IMG\"===e.nodeName?(i=this.__createElement(\"image\"),i.setAttribute(\"width\",e.width),i.setAttribute(\"height\",e.height),i.setAttributeNS(\"http://www.w3.org/1999/xlink\",\"xlink:href\",\"CANVAS\"===e.nodeName?e.toDataURL():e.getAttribute(\"src\")),n.appendChild(i),this.__defs.appendChild(n)):e instanceof lu&&(n.appendChild(e.__root.childNodes[1]),this.__defs.appendChild(n)),new cu(n,this)}setLineDash(e){e&&e.length>0?this.lineDash=e.join(\",\"):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}function hu(e){if(e.startsWith(\"GCF\")||e.startsWith(\"GCA\")&&e.length>=13){return\"https://hgdownload.soe.ucsc.edu/hubs/\"+e.substring(0,3)+\"/\"+e.substring(4,7)+\"/\"+e.substring(7,10)+\"/\"+e.substring(10,13)+\"/\"+e+\"/hub.txt\"}}class du{static supportedTypes=new Set([\"bigBed\",\"bigWig\",\"bigGenePred\",\"vcfTabix\"]);static filterTracks=new Set([\"cytoBandIdeo\",\"assembly\",\"gap\",\"gapOverlap\",\"allGaps\",\"cpgIslandExtUnmasked\",\"windowMasker\"]);static async loadHub(e){const t=e.lastIndexOf(\"/\"),i=e.substring(0,t+1),n=await pu(e);let r;if(\"genome\"===n[1].type){const e=n[1];if(e.hasProperty(\"groups\")){const t=i+e.getProperty(\"groups\");r=await pu(t)}if(e.hasProperty(\"chromSizes\")){const t=i+e.getProperty(\"chromSizes\"),n=await async function(e){try{const t=(await fetch(e,{method:\"HEAD\"})).headers;return t.has(\"content-length\")?t.get(\"content-length\"):null}catch(e){return null}}(t);null!==n&&Number.parseInt(n)<1e6&&e.setProperty(\"chromSizesURL\",t)}}return new du(e,n,r)}constructor(e,t,i){this.url=e;const n=e.lastIndexOf(\"/\");if(this.baseURL=e.substring(0,n+1),\"hub\"!==t[0].type)throw Error(\"Unexpected hub.txt file -- does the first line start with 'hub'?\");if(this.hubStanza=t[0],\"on\"!==this.hubStanza.getProperty(\"useOneFile\"))throw Error(\"Only 'useOneFile' hubs are currently supported\");if(t.length<2)throw Error(\"Expected at least 2 stanzas, hub and genome\");if(\"genome\"!==t[1].type)throw Error(`Unexpected hub file -- expected \"genome\" stanza but found \"${t[1].type}\"`);this.genomeStanza=t[1],this.trackStanzas=[];for(let e=2;e0?e.substring(0,t):e}}this.genomeStanza.hasProperty(\"blat\")&&(r.blat=this.baseURL+this.genomeStanza.getProperty(\"blat\")),this.genomeStanza.hasProperty(\"chromAliasBb\")&&(r.chromAliasBbURL=this.baseURL+this.genomeStanza.getProperty(\"chromAliasBb\")),this.genomeStanza.hasProperty(\"chromAlias\")&&(r.aliasURL=this.baseURL+this.genomeStanza.getProperty(\"chromAlias\")),this.genomeStanza.hasProperty(\"twoBitBptURL\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptURL\")),this.genomeStanza.hasProperty(\"twoBitBptUrl\")&&(r.twoBitBptURL=this.baseURL+this.genomeStanza.getProperty(\"twoBitBptUrl\")),e.includeChromSizes&&this.genomeStanza.hasProperty(\"chromSizes\")&&(r.chromSizesURL=this.baseURL+this.genomeStanza.getProperty(\"chromSizes\")),this.hubStanza.hasProperty(\"longLabel\")?r.description=this.hubStanza.getProperty(\"longLabel\").replace(\"/\",\"\\n\"):(r.description=r.id,this.genomeStanza.hasProperty(\"description\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"description\")}`),this.genomeStanza.hasProperty(\"organism\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"organism\")}`),this.genomeStanza.hasProperty(\"scientificName\")&&(r.description+=`\\n${this.genomeStanza.getProperty(\"scientificName\")}`),this.genomeStanza.hasProperty(\"htmlPath\")&&(r.infoURL=this.baseURL+this.genomeStanza.getProperty(\"htmlPath\")));const s=this.trackStanzas.filter((e=>\"cytoBandIdeo\"===e.name&&e.hasProperty(\"bigDataUrl\")));s.length>0&&(r.cytobandBbURL=this.baseURL+s[0].getProperty(\"bigDataUrl\"));return r.tracks=this.#g((e=>!du.filterTracks.has(e.name)&&\"hide\"!==e.getProperty(\"visibility\"))),r}getGroupedTrackConfigurations(){const e=new Map;for(let t of this.#g()){if(\"cytoBandIdeo\"===t.name)continue;const i=t.group||\"other\";e.has(i)?e.get(i).push(t):e.set(i,[t])}const t=this.groupStanzas?new Map(this.groupStanzas.map((e=>[e.getProperty(\"name\"),e]))):new Map;return Array.from(e.keys()).map((i=>({label:t.has(i)?t.get(i).getProperty(\"label\"):i,tracks:e.get(i)})))}#g(e){return this.trackStanzas.filter((t=>du.supportedTypes.has(t.format)&&t.hasProperty(\"bigDataUrl\")&&(!e||e(t)))).map((e=>this.#m(e)))}#m(e){const t=e.format,i={id:e.getProperty(\"track\"),name:e.getProperty(\"shortLabel\"),format:t,url:this.baseURL+e.getProperty(\"bigDataUrl\"),displayMode:e.displayMode};if(\"vcfTabix\"===t&&(i.indexURL=i.url+\".tbi\"),e.hasProperty(\"longLabel\")&&e.hasProperty(\"html\")?(i.description&&(i.description+=\"
\"),i.description=`${e.getProperty(\"longLabel\")}`):e.hasProperty(\"longLabel\")&&(i.description=e.getProperty(\"longLabel\")),e.hasProperty(\"autoScale\")&&(i.autoscale=\"on\"===e.getProperty(\"autoScale\").toLowerCase()),e.hasProperty(\"maxHeightPixels\")){const t=e.getProperty(\"maxHeightPixels\").split(\":\");i.maxHeight=Number.parseInt(t[0]),i.height=Number.parseInt(t[1]),i.minHeight=Number.parseInt(t[2])}if(e.hasProperty(\"color\")){const t=e.getProperty(\"color\");i.color=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"altColor\")){const t=e.getProperty(\"altColor\");i.altColor=t.indexOf(\",\")>0?`rgb(${t})`:t}if(e.hasProperty(\"viewLimits\")){const t=e.getProperty(\"viewLimits\").split(\":\");let n,r;t.length>1&&(n=Number.parseInt(t[0]),r=Number.parseInt(t[1])),Number.isNaN(r)||Number.isNaN(n)?console.warn(`Unexpected viewLimits value in track line: ${properties.viewLimits}`):(i.min=n,i.max=r)}if(e.hasProperty(\"itemRgb\"),\"hide\"===e.getProperty(\"visibility\")&&(i.visible=!1),e.hasProperty(\"url\")&&(i.infoURL=e.getProperty(\"url\")),e.hasProperty(\"searchIndex\")&&(i.searchIndex=e.getProperty(\"searchIndex\")),e.hasProperty(\"searchTrix\")&&(i.trixURL=this.baseURL+e.getProperty(\"searchTrix\")),e.hasProperty(\"group\")&&(i.group=e.getProperty(\"group\"),this.groupPriorityMap&&this.groupPriorityMap.has(i.group))){const e=this.groupPriorityMap.get(i.group)+1;i.order=e,this.groupPriorityMap.set(i.group,e)}return i}}function uu(e){const t=e.indexOf(\" \");return t>0?e.substring(0,t):e}class fu{properties=new Map;constructor(e,t){this.type=e,this.name=t}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.has(e)?this.properties.get(e):this.parent?this.parent.getProperty(e):void 0}hasProperty(e){return!!this.properties.has(e)||!!this.parent&&this.parent.hasProperty(e)}get format(){const e=this.getProperty(\"type\");if(e)return uu(e)}get displayMode(){let e=this.getProperty(\"visibility\");if(!e)return\"COLLAPSED\";switch(e=e.toLowerCase(),e){case\"dense\":default:return\"COLLAPSED\";case\"pack\":return\"EXPANDED\";case\"squish\":return\"SQUISHED\"}}}async function pu(e){const t=await fetch(e),i=(await t.text()).split(/\\n|\\r\\n|\\r/g),n=[];let r,s=!0;for(let e of i){const t=gu(e),i=e.indexOf(\" \",t);if(i<0)s=!0;else{const o=e.substring(t,i).trim();if(o.startsWith(\"#\"))continue;const a=e.substring(i+1).trim();if(s){const e=new fu(o,a);n.push(e),r=e,s=!1}r.setProperty(o,a)}}return function(e){const t=new Map;for(let i of e)t.set(i.name,i);for(let i of e)if(i.properties.has(\"parent\")){const e=uu(i.properties.get(\"parent\"));i.parent=t.get(e)}return e}(n)}function gu(e){let t=0;for(t=0;t=13)try{const e=hu(i);t=(await du.loadHub(e)).getGenomeConfig()}catch(e){console.error(e)}t||e.present(new Error(`Unknown genome id: ${i}`),void 0)}return t}return t}};let wu,bu,Fu=0,vu=0,yu=[];class Au extends eu{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.$spinner=Bt(\"
\",{class:\"igv-loading-spinner-container\"}),this.$viewport.append(this.$spinner),this.$spinner.append(Bt(\"
\"));const e=this.trackView.track;\"sequence\"!==e.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),\"sequence\"!==e.id&&(this.$trackLabel=Bt('
'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(e.name||\"\"),!1===this.browser.doShowTrackLabels&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(e){super.setContentHeight(e),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(e){this.$trackLabel.empty(),this.$trackLabel.html(e);const t=this.$trackLabel.text();this.$trackLabel.attr(\"title\",t)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&\"sequence\"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return Bt(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if(\"all\"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const e=this.trackView.track.visibilityWindow;return void 0!==e&&e>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>e}return!0})()){if(this.canvas&&(Bt(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const e=this.trackView.minHeight||0;this.setContentHeight(e)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const e=this.referenceFrame;this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===e.bpPerPixel&&(this.canvas._data.pixelShift=Math.round((this.canvas._data.bpStart-e.start)/e.bpPerPixel),this.canvas.style.left=this.canvas._data.pixelShift+\"px\")}genomicRange(){return{start:this.referenceFrame.start,end:this.referenceFrame.start+this.referenceFrame.bpPerPixel*this.$viewport.width()}}setTop(e){if(super.setTop(e),this.canvas){const t=this.$viewport.height(),i=e+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n0)for(let n of i.roiSets){const i=await n.getFeatures(t,s,o,e.bpPerPixel);r.push({track:n,features:i})}const a=i&&i.resolutionAware,c=this.windowFunction;return this.featureCache=new Cu(t,s,o,e.bpPerPixel,n,r,a,c),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(e){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage(\"Error loading track data\"),this.browser.alert.present(e),console.error(e))}finally{this.loading=!1,this.stopSpinner()}}}get track(){return this.trackView.track}get windowFunction(){return this.track?this.track.windowFunction:void 0}repaintDimensions(){const e=mu.isWholeGenomeView(this.referenceFrame.chr),t=e?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(e?0:this.$viewport.width()*i),bpEnd:e?Number.MAX_SAFE_INTEGER:this.referenceFrame.start+2*this.$viewport.width()*i+1,pixelWidth:t}}repaint(){if(void 0===this.featureCache)return;const{features:e,roiFeatures:t}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=t?Math.max(o,s):o,c=Math.min(a,3*s);if(0===r||0===c)return void(this.canvas&&Bt(this.canvas).remove());const l=Math.max(0,-this.contentTop-Math.floor(c/3)),h=this.referenceFrame.bpPerPixel,d=Math.round((i-this.referenceFrame.start)/h),u=(this.contentTop||0)+l,f=document.createElement(\"canvas\");f.style.position=\"relative\",f.style.display=\"block\",f.style.width=r+\"px\",f.style.height=c+\"px\",f.style.left=d+\"px\",f.style.top=u+\"px\";const p=\"FILL\"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*c;const g=f.getContext(\"2d\");g.scale(p,p),g.translate(0,-l);const m={context:g,pixelXOffset:d,pixelWidth:r,pixelHeight:c,pixelTop:l,bpStart:i,bpEnd:n,bpPerPixel:h,pixelShift:d,windowFunction:this.windowFunction,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,e,t),this.canvas&&Bt(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(Bt(f))}refresh(){if(!this.canvas||!this.featureCache)return;const e=this.canvas._data;e.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:t,roiFeatures:i}=this.featureCache;this.draw(e,t,i)}draw(e,t,i){if(t&&(e.features=t,this.trackView.track.draw(e)),i&&i.length>0)for(let t of i)e.features=t.features,t.track.draw(e)}containsPosition(e,t){return this.referenceFrame.chr===e&&t>=this.referenceFrame.start&&t<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const e=this.canvas._data,t=e?e.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-Bt(this.canvas).position().left*i,o=(-this.contentTop-t)*i,a=this.canvas.getContext(\"2d\").getImageData(s,o,n,r),c=document.createElement(\"canvas\"),l=c.getContext(\"2d\");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);Pt((this.$trackLabel.text()?this.$trackLabel.text():\"image\")+\".png\",c.toDataURL(\"image/png\"))}saveSVG(){let{width:e,height:t}=this.browser.columnContainer.getBoundingClientRect();const i=new lu({width:e,height:8e3,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),n={deltaX:32,deltaY:32};this.renderSVGContext(i,n,!1),i.setHeight(t);const r=(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\"),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),a=i.getSerializedSvg(!0),c=URL.createObjectURL(new Blob([a],{type:\"application/octet-stream\"}));Pt(`${`${r}_referenceFrame_${o}_guid_${s()}`}.svg`,c)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){if(!(this.$zoomInNotice&&this.$zoomInNotice.is(\":visible\"))){const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,a=t,c=i+this.contentTop,l=-this.contentTop;e.saveWithTranslationAndClipRect(o,a,c,n,r,l);const{start:h,bpPerPixel:d}=this.referenceFrame,u=Math.round((h-this.referenceFrame.start)/d),f={context:e,viewport:this,referenceFrame:this.referenceFrame,top:l,pixelTop:l,pixelWidth:n,pixelHeight:r,pixelXOffset:u,pixelShift:u,bpStart:h,bpEnd:h+n*d,bpPerPixel:d,viewportWidth:n,selection:this.selection},p=this.featureCache?this.featureCache.features:void 0,g=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(f,p,g),e.restore()}if(n&&this.$trackLabel&&this.browser.doShowTrackLabels){const{x:n,y:r,width:s,height:o}=((e,t)=>{const{x:i,y:n,width:r,height:s}=e.getBoundingClientRect(),{x:o,y:a,width:c,height:l}=t.getBoundingClientRect();return{x:o-i,y:a-n,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(e,t+n,i+r,s,o)}}renderTrackLabelSVG(e,t,i,n,r){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_track_label_guid_${s()}`;e.saveWithTranslationAndClipRect(o,t,i,n,r,0),e.fillStyle=\"white\",e.fillRect(0,0,n,r),e.font=\"12px Arial\",e.fillStyle=\"rgb(68, 68, 68)\";const{width:a}=e.measureText(this.$trackLabel.text()),c=.25*(n-a),l=.7*(r-12);e.fillText(this.$trackLabel.text(),c,r-l),e.strokeStyle=\"rgb(68, 68, 68)\",e.strokeRect(0,0,n,r),e.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(e,t,i,n,r){if(this.featureCache&&this.featureCache.containsRange(t,i,n,r,this.windowFunction))return this.featureCache.features;if(\"function\"==typeof e.getFeatures){const s=await e.getFeatures(t,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const e=this.canvas._data;return!e||this.referenceFrame.starte.bpEnd||this.referenceFrame.chr!==e.referenceFrame.chr||this.referenceFrame.bpPerPixel!=e.bpPerPixel||this.windowFunction!=e.windowFunction}needsReload(){if(!this.featureCache)return!0;const{chr:e,bpPerPixel:t}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(e,i,n,t,this.windowFunction)}createZoomInNotice(e){const t=Bt(\"
\",{class:\"igv-zoom-in-notice-container\"});e.append(t);const i=Bt(\"
\");return t.append(i),i.text(\"Zoom in to see features\"),t.hide(),t}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const e=this.$viewport.get(0);this.addViewportContextMenuHandler(e);const t=e=>{this.enableClick=!0,this.browser.mouseDownOnViewport(e,this),r(e)};e.addEventListener(\"mousedown\",t),e.addEventListener(\"touchstart\",t);const i=e=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};e.addEventListener(\"mouseup\",i),e.addEventListener(\"touchend\",i),\"function\"==typeof this.trackView.track.hoverText&&e.addEventListener(\"mousemove\",(e=>{if(0===e.buttons&&Date.now()-vu>100){vu=Date.now();const t=this.createClickState(e);if(t){const e=this.trackView.track.hoverText(t);e?this.$viewport[0].setAttribute(\"title\",e):this.$viewport[0].removeAttribute(\"title\")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&\"sequence\"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(e){e.addEventListener(\"contextmenu\",(e=>{if(this.browser.dragObject)return!1;const t=this.createClickState(e);if(void 0===t)return!1;e.preventDefault();let i=[];if(\"function\"==typeof this.trackView.track.contextMenuItemList){const e=this.trackView.track.contextMenuItemList(t);e&&(i=e)}i.length>0&&i.push({label:Bt(\"
\")}),i.push({label:\"Save Image (PNG)\",click:()=>this.savePNG()}),i.push({label:\"Save Image (SVG)\",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(e,i)}))}addViewportClickHandler(e){e.addEventListener(\"click\",(e=>{if(this.enableClick&&this.canvas){if(3===e.which||e.ctrlKey)return;if(this.browser.dragObject||this.browser.isScrolling)return;e.preventDefault();const t=a(e,this.$viewport.get(0)).x,i=a(e,this.canvas).x,n=this.referenceFrame;Math.floor(n.start+n.toBP(i));const r=Date.now();if(r-Fue));e[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=t,i=e.join(\" \")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,e,this.referenceFrame)}else\"function\"==typeof this.trackView.track.popupData&&(wu=setTimeout((()=>{const t=this.getPopupContent(e);if(t)if(!1===e.shiftKey){if(bu&&bu.dispose(),yu.length>0){for(const e of yu)e.dispose();yu.length=0}bu=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{bu.dispose()})),bu.presentContentWithEvent(e,t)}else{let i=new tc(this.$viewport.get(0).parentElement,!0,void 0,(()=>{const e=yu.indexOf(i);yu.splice(e,1),i.dispose()}));yu.push(i),i.presentContentWithEvent(e,t)}window.clearTimeout(wu),wu=void 0}),this.browser.constants.doubleClickDelay));Fu=r}}))}addTrackLabelClickHandler(e){e.addEventListener(\"click\",(e=>{e.stopPropagation();const{track:t}=this.trackView;let i;\"function\"==typeof t.description?i=t.description():t.description&&(i=`
${t.description}
`),i&&(void 0===this.popover&&(this.popover=new tc(this.browser.columnContainer,!0,t.name||\"\",void 0)),this.popover.presentContentWithEvent(e,i))}))}createClickState(e){if(!this.canvas)return;const t=this.referenceFrame,i=a(e,this.$viewport.get(0)),n=a(e,this.canvas),r=t.start+t.toBP(i.x);return{event:e,viewport:this,referenceFrame:t,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(e){const t=this.createClickState(e);if(void 0===t)return;let i=this.trackView.track;const n=i.popupData(t),r=this.browser.fireEvent(\"trackclick\",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((e=>{if(e.name){const t=`${e.name}   ${e.value}`;return`
${t}
`}return\"
\"===e?e:e.html?e.html:`
${e}
`})).join(\"\")):\"string\"==typeof r&&(s=r),s}dispose(){this.popover&&this.popover.dispose(),super.dispose()}}class Cu{constructor(e,t,i,n,r,s,o,a){this.chr=e,this.bpStart=t,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o,this.windowFunction=a}containsRange(e,t,i,n,r){if(r&&r!==this.windowFunction)return!1;const s=this.multiresolution?this.bpPerPixel/n:1;return t>=this.bpStart&&i<=this.bpEnd&&e===this.chr&&s>.5&&s<2}overlapsRange(e,t,i){return this.chr===e&&i>=this.bpStart&&t<=this.bpEnd}}const _u=function(e,t){const{r:i,g:n,b:r}=no[e];return`rgba(${i},${n},${r},${t})`}(\"nickel\",2/16),xu=_u;class ku{constructor(e,t){if(this.url=e.url,e.name&&(this.name=e.name),this.isUserDefined=e.isUserDefined,e.featureSource)this.featureSource=e.featureSource;else if(e.features)this.featureSource=new Su(e.features,t);else{if(!e.format)throw Error(\"ROI configuration must define either features or file format\");this.featureSource=Ad(e,t)}!0===this.isUserDefined?(this.color=e.color||xu,this.headerColor=\"rgba(155,185,129)\"):(this.color=e.color||_u,this.headerColor=\"rgb(190,190,190)\"),this.isVisible=void 0===e.isVisible||e.isVisible}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}async getAllFeatures(){return\"function\"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(e){this.featureSource.addFeature(e)}removeFeature(e){this.featureSource.removeFeature(e)}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined,isVisible:this.isVisible};{const e=this.featureSource.getAllFeatures(),t=[];for(let i of Object.keys(e))for(let n of e[i])t.push(n);return{name:this.name,color:this.color,features:t,isUserDefined:this.isUserDefined,isVisible:this.isVisible}}}dispose(){for(let e of Object.keys(this))this[e]=void 0}}function Iu(e,t,i,n){let r=Math.round((e-i)/n);let s=Math.round((t-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class Su{constructor(e,t){this.featureMap={},this.genome=t;for(let i of e){const e=t?t.getChromosomeName(i.chr):i.chr;let n=this.featureMap[e];n||(n=[],this.featureMap[e]=n),n.push(i)}for(let e of Object.keys(this.featureMap))this.featureMap[e].sort(((e,t)=>e.start-t.start))}async getFeatures({chr:e,start:t,end:i}){if(\"all\"===e.toLowerCase())return Ll(this.featureMap,this.genome);{const n=this.featureMap[e];return n?n.filter((e=>e.end>t&&e.starte.start-t.start))}removeFeature({chr:e,start:t,end:i}){if(this.featureMap[e]){const n=`${e}-${t}-${i}`;this.featureMap[e]=this.featureMap[e].filter((e=>n!==`${e.chr}-${e.start}-${e.end}`)),0===this.featureMap[e].length&&delete this.featureMap[e]}}}class Eu{constructor(t,i,n,r){this.rulerViewport=t,this.rulerSweeper=e({class:\"igv-ruler-sweeper\"}),i.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(mu.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on(\"locuschange\",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off(\"locuschange\",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let e,t,i,n,r,s;this.boundContentMouseDownHandler=function(s){e=!0,t=!0;const{x:o}=a(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display=\"block\",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?xu:\"rgba(68, 134, 247, 0.25)\",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener(\"mousedown\",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let c;if(e&&t){const{x:e}=a(o,this.rulerViewport.contentDiv);c=Math.max(Math.min(e,this.rulerViewport.contentDiv.clientWidth),0),s=c-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;if(!0===e&&!0===t&&(e=t=void 0,this.rulerSweeper.style.display=\"none\",r>1)){s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))};!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(Qa(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(e,t,i){e.start=Math.round(t.start),e.end=Math.round(t.end),e.bpPerPixel=(e.end-e.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener(\"mousedown\",this.boundContentMouseDownHandler),document.removeEventListener(\"mousemove\",this.boundDocumentMouseMoveHandler),document.removeEventListener(\"mouseup\",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}function Nu(e){if(Bu[e])return Bu[e];if(Bu[\"chr\"+e]){const t=Bu[\"chr\"+e];return Bu[e]=t,t}{const t=_s.randomRGB(0,255);return Bu[e]=t,t}}const Bu={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0)\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};let Mu,Ru;class Du extends Au{constructor(e,t,i,n){super(e,t,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let e;this.$multiLocusCloseButton=Bt(\"
\",{class:\"igv-multi-locus-close-button\"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(l(\"times-circle\")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=Bt(\"
\",{class:\"igv-multi-locus-ruler-label\"}),this.$viewport.append(this.$rulerLabel),e=document.createElement(\"div\"),this.$rulerLabel.append(Bt(e)),this.$rulerLabel.get(0).addEventListener(\"click\",(async e=>{e.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=Bt(\"
\",{class:\"igv-ruler-tooltip\"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=Bt(\"
\"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new Eu(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(mu.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(e){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=Nu(this.referenceFrame.chr);const t=this.$rulerLabel.get(0).querySelector(\"div\"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();t.innerHTML=`${this.referenceFrame.getMultiLocusLabel(e)}`;const{width:n}=t.getBoundingClientRect();n/i>.5&&(t.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(e)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(e){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===e){const e=this.browser.referenceFrameList.indexOf(this.referenceFrame),t=`click${this.namespace}`;this.$viewport.on(t,(t=>{const{x:i}=a(t,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let t=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));t[e]=s,r=t.join(\" \")}this.browser.search(r)})),this.$viewport.get(0).style.cursor=\"pointer\"}else this.$viewport.get(0).style.cursor=\"default\"}mouseMove(e){if(!0===this.browser.doShowCursorGuide){void 0===Ru?(Ru=this,this.$tooltip.show()):Ru.guid!==this.guid?(Ru.$tooltip&&Ru.$tooltip.hide(),this.$tooltip.show(),Ru=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:t}=a(e,this.$viewport.get(0)),{start:i,end:n,bpPerPixel:r}=this.referenceFrame,s=Math.round(.5+i+Math.max(0,t)*r);this.$tooltipContent.text(Rt(s));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:c}=this.$viewport.get(0).getBoundingClientRect();return this.$tooltip.css({left:`${ys.clamp(t,0,c-o)}px`}),clearTimeout(Mu),Mu=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4),{start:i,bp:s,end:n}}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class Tu extends Au{featureCache=new Lu;constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.canvas=document.createElement(\"canvas\"),this.canvas.className=\"igv-ideogram-canvas\",this.$viewport.append(Bt(this.canvas)),this.ideogram_ctx=this.canvas.getContext(\"2d\"),this.addMouseHandlers()}async getFeatures(e,t,i,n){return this.featureCache.containsRange(e)?this.featureCache.get(e):this.loadFeatures()}async loadFeatures(){const e=this.referenceFrame.chr,t=await this.referenceFrame.genome.getCytobands(e);return this.featureCache.set(e,t),t}repaint(){if(void 0===this.featureCache)return;const{width:e,height:t}=this.$viewport[0].getBoundingClientRect();xo.configureHighDPICanvas(this.ideogram_ctx,e,t);const i=this.referenceFrame.chr,n=this.featureCache.get(i),r={context:this.ideogram_ctx,pixelWidth:e,pixelHeight:t,referenceFrame:this.referenceFrame,features:n};this.trackView.track.draw(r)}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(e){this.boundClickHandler=function(e){const{xNormalized:t,width:i}=a(e,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=t;s-r/2<0&&(s=r/2);s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),c=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=c,this.referenceFrame.bpPerPixel=(c-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),e.addEventListener(\"click\",this.boundClickHandler)}setWidth(e){this.$viewport.width(e)}renderSVGContext(e,{deltaX:t,deltaY:i},n=!0){const{width:r,height:o}=this.$viewport.get(0).getBoundingClientRect(),a=`ideogram_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${s()}`,c=t,l=i+this.contentTop,h=-this.contentTop;e.saveWithTranslationAndClipRect(a,c,l,r,o,h),this.trackView.track.draw({context:e,pixelWidth:r,pixelHeight:o,referenceFrame:this.referenceFrame,features:this.featureCache.get(this.referenceFrame.chr)}),e.restore()}startSpinner(){}stopSpinner(){}}class Lu{features=new Map;containsRange(e){return this.features.has(e)}set(e,t){this.features.set(e,t)}get(e){return this.features.get(e)}}function zu(e,t,i,n){if(\"ruler\"===e.track.type)return new Du(e,t,i,n);if(\"ideogram\"===e.track.id)return new Tu(e,t,i,n);{const r=new Au(e,t,i,n);return i.viewport=r,r}}const Hu=[\"rgb(255, 0, 0)\",\"rgb(0, 255, 0)\",\"rgb(0, 0, 255)\",\"rgb(255, 0, 255)\",\"rgb(0, 255, 255)\",\"rgb(128, 0, 128)\",\"rgb(255, 165, 0)\",\"rgb(255, 105, 180)\",\"rgb(255, 127, 80)\",\"rgb(220, 20, 60)\",\"rgb(255, 99, 71)\",\"rgb(173, 216, 230)\",\"rgb(144, 238, 144)\",\"rgb(224, 255, 255)\",\"rgb(250, 250, 210)\",\"rgb(152, 251, 152)\",\"rgb(70, 130, 180)\",\"rgb(102, 205, 170)\"].map((e=>{const[t,i,n]=e.split(\",\"),[r,s]=t.split(\"(\"),[o,a]=n.split(\")\");return[s,i,o]})),Pu=ro(\"magnesium\"),Ou=[\"#sampleTable\",\"#sampleMapping\",\"#colors\"];class Uu{static emptySpaceReplacement=\"|\";sampleDictionary={};attributeNames=[];sampleMappingDictionary={};colorDictionary={};attributeRangeLUT={};constructor(e){e.tracks.some((e=>\"function\"==typeof e.getSamples)).length>0&&e.sampleInfoControl.setButtonVisibility(!0),this.initialize()}initialize(){this.sampleInfoFiles=[],this.attributeNames=[],this.sampleDictionary={},this.sampleMappingDictionary={},this.colorDictionary={},this.attributeRangeLUT={},this.initialized=!1}get attributeCount(){return this.attributeNames?this.attributeNames.length:0}isInitialized(){return this.initialized}hasAttributes(){return this.attributeCount>0}getAttributes(e){const t=0===Object.keys(this.sampleMappingDictionary)?e:this.sampleMappingDictionary[e]||e;return this.sampleDictionary[t]}async loadSampleInfoFile(e){try{const t=await Qs.loadString(e);this.#w(t),this.sampleInfoFiles.push(e)}catch(e){console.error(e.message)}}#w(e){const t=function(e){const t={},i=e.split(/\\r?\\n|\\r/).map((e=>e.trim())).filter((e=>\"\"!==e));let n;Ou.includes(i[0])||(n=\"#sampleTable\",t[n]=[]);for(const e of i)Ou.includes(e)?(n=e,t[n]=[]):n&&!1===e.startsWith(\"#\")&&t[n].push(e);return t}(e);for(const[e,i]of Object.entries(t))switch(e){case\"#sampleTable\":this.#b(i);break;case\"#sampleMapping\":this.#F(i);break;case\"#colors\":this.#v(i)}this.initialized=!0}getAttributeColor(e,t){let i;if(\"-\"===t)i=ro(\"snow\");else if(\"string\"==typeof t&&this.colorDictionary[t])i=this.colorDictionary[t]();else if(this.colorDictionary[e])i=this.colorDictionary[e](t);else if(\"string\"==typeof t)i=\"NA\"===t?Pu:function(e){let t=0;for(let i=0;i>8*e&255;i.push(n)}return`rgb(${i.join(\", \")})`}(t);else{const[n,r]=this.attributeRangeLUT[e],s=.2,o=Math.max((t-n)/(r-n),s),[a,c,l]=Hu[Object.keys(this.attributeRangeLUT).indexOf(e)];i=`rgba(${a},${c},${l},${o})`}return i}getSortedSampleKeysByAttribute(e,t,i){i=i||1;const n=e.filter((e=>\"number\"==typeof this.getAttributes(e)[t])),r=e.filter((e=>\"string\"==typeof this.getAttributes(e)[t])),s=(e,n)=>{const r=this.getAttributes(e)[t],s=this.getAttributes(n)[t];return\"string\"==typeof r&&\"string\"==typeof s?i*r.localeCompare(s):\"number\"==typeof r&&\"number\"==typeof s?i*(r-s):void 0};return n.sort(s),r.sort(s),-1===i?[...n,...r]:[...r,...n]}toJSON(){const e=[];for(const t of this.sampleInfoFiles){const i={url:t},n=Hl.localFileInspection(i);e.push(n)}return e}#b(e){const t=e.shift().split(\"\\t\").filter((e=>e.length>0));t.shift();const i=t.map((e=>e.split(\" \").join(Uu.emptySpaceReplacement))),n=e.filter((e=>e.length>0));let r;for(const e of n){const t=e.split(\"\\t\"),n=t.shift();void 0===r&&(r={}),r[n]={};for(let e=0;e\"number\"==typeof e,r=e=>\"string\"==typeof e;for(const e of Object.keys(i)){const t=i[e],s=new Set(t),o=Array.from(s);if(!0===o.some(r)&&!0===o.some(n)?i[e]=o.filter((e=>!r(e))):i[e]=o,!i[e].some(r)){const t=i[e].slice();i[e]=[Math.min(...t),Math.max(...t)]}}return i}(i,r);qu(this.attributeRangeLUT,s);const o=new Set(this.attributeNames);for(const e of i)o.has(e)||this.attributeNames.push(e);qu(this.sampleDictionary,r)}#F(e){for(const t of e){const[e,i]=t.split(\"\\t\");this.sampleMappingDictionary[e]=i}}#v(e){const t=(e,t,i)=>{let n;switch(t){case 0:n=e.split(\" \").join(Uu.emptySpaceReplacement);break;case 1:n=e.includes(\":\")?e.split(\":\").map((e=>parseFloat(e))):e;break;case 2:case 3:n=`rgb(${e})`}return n},i=e.map((e=>e.split(\"\\t\").map(t))),n=i.filter((e=>3===e.length&&!e.includes(\"*\"))).filter((([e,t,i])=>!Array.isArray(t))),r={};for(const e of n){const[t,i,n]=e;void 0===r[t]&&(r[t]={}),r[t][i.toUpperCase()]=n}for(const[e,t]of Object.entries(r)){const i=Object.assign({},t);this.colorDictionary[e]=e=>{const t=e.toUpperCase();return i[t]||ro(\"snow\")}}const s=i.filter((e=>Array.isArray(e[1])));for(const e of s){const[t,i]=e[1],n=e[0];if(3===e.length){const[r,s,o]=uo(e[2]);this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return lo(r,s,o,(e-t)/(i-t))}}else if(4===e.length){const[t,i]=e[1],[n,r,s,o]=e;this.colorDictionary[n]=e=>{e=ys.clamp(e,t,i);return fo(s,o,(e-t)/(i-t))}}}const o=i.filter((e=>3===e.length&&e.includes(\"*\")));for(const e of o)if(\"*\"===e[1]){const[t,i,n]=e;this.colorDictionary[t]=e=>{if(\"NA\"===e)return Pu;{const[i,r]=this.attributeRangeLUT[t],s=(e-i)/(r-i),[o,a,c]=uo(n);return lo(o,a,c,s)}}}else if(\"*\"===e[0]){const[t,i,n]=e;this.colorDictionary[i]=()=>n}}}function qu(e,t){for(const[i,n]of Object.entries(t))i in e&&e[i]===n||(e[i]=n)}function Qu(e){const t=Object.assign({},e);for(const[e,i]of Object.entries(t))\"string\"!=typeof i||isNaN(i)||(t[e]=Number(i));return t}const Vu=16,ju=Rt;class Wu{constructor(e){this.browser=e,this.height=40,this.name=\"\",this.id=\"ruler\",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type=\"ruler\"}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){mu.isWholeGenomeView(t.chr)?this.drawWholeGenome({context:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n}){e.save(),xo.fillRect(e,0,0,t,i,{fillStyle:\"white\"});for(let t of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(t),s=this.browser.genome.getChromosome(t).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(e,o,0,a,i,t)}e.restore()}doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:r}){e.clearRect(0,0,i,n);const s=function(e,t){if(e<10)return new Gu(1,\"bp\",1);const i=Math.floor(Math.log10(e));let n=\"bp\",r=1;i>9?(n=\"gb\",r=1e9):i>6?(n=\"mb\",r=1e6):i>3&&(n=\"kb\",r=1e3);const s=Math.pow(10,i-1),o=e/s,a=75,c=Math.pow(10,i-1),l=Math.pow(10,i)/2;return new Gu(o0&&u+c<=d&&(xo.fillText(e,i,n,this.height-8),d=0),l>0&&xo.strokeLine(e,l,this.height-6,l,this.height-2),h=Math.floor((1+o)*s.majorTick);let f=l+(Math.round(t.toPixels(h-1-r+.5))-l)/2;f>0&&xo.strokeLine(e,f,this.height-6,f,this.height-2),++o,d+=a}while(le.measureText(o).width&&xo.fillText(e,o,t+n/2,i+r/2,{fillStyle:_s.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Gu{constructor(e,t,i){this.majorTick=e,this.minorTick=e/10,this.majorUnit=t,this.unitMultiplier=i}description(e){console.log((e||\"\")+\" tick \"+ju(this.majorTick)+\" label width \"+ju(this.labelWidthBP)+\" multiplier \"+this.unitMultiplier)}}class $u{constructor(t,i,n){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),this.viewport.style.height=`${t.track.height}px`,null===this.viewport.previousElementSibling&&(this.viewport.style.zIndex=16,this.viewport.style.overflow=\"visible\"),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.ctx.font=\"10px verdana\",this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(n),this.addMouseHandlers()}resizeCanvas(){const e=window.devicePixelRatio,t=this.browser.getSampleInfoViewportWidth();let i;if(this.browser.trackViews.length>1&&null===this.viewport.previousElementSibling){const[e,t]=[this.browser.ideogramTrackView.track,this.browser.rulerTrackView.track];i=e.height+t.height}else i=this.viewport.clientHeight;if(this.canvas.width!==t*e||this.canvas.height!==i*e){const n=this.canvas;n.width=t*e,n.height=i*e,n.style.width=`${t}px`,n.style.height=`${i}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(e,e),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}}setTop(e){\"function\"==typeof this.trackView.track.getSamples&&(this.contentTop=e,this.repaint())}setWidth(e){this.viewport.innerWidth=e,this.resizeCanvas()}setHeight(e){const t=this.browser.getSampleInfoViewportWidth();this.viewport.style.width=`${t}px`,this.viewport.style.height=`${e}px`;const i=window.devicePixelRatio;this.canvas.width=t*i,this.canvas.height=e*i,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${e}px`,this.ctx=this.canvas.getContext(\"2d\"),this.ctx.scale(i,i),null===this.viewport.previousElementSibling&&xo.fillRect(this.ctx,0,0,this.ctx.canvas.width,this.ctx.canvas.height,{fillStyle:ro(\"snow\")})}async repaint(){if(this.resizeCanvas(),\"function\"==typeof this.trackView.track.getSamples){const e=this.trackView.track.getSamples();e.names&&e.names.length>0&&this.draw({context:this.ctx,samples:e})}else null===this.viewport.previousElementSibling&&(this.browser.rulerTrackView&&this.browser.rulerTrackView.setTrackHeight(!0===this.browser.sampleInfoControl.showSampleInfo?this.calculateSampleInfoColumnHeight():40,!0),this.renderSampleInfoColumns(this.ctx))}calculateSampleInfoColumnHeight(){const e=this.browser.sampleInfo.attributeNames.map((e=>this.ctx.measureText(e).width));return 4+Math.min(Math.max(...e),128)}draw({context:e,samples:t}){if(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=ro(\"snow\"),e.fillRect(0,0,e.canvas.width,e.canvas.height),t&&t.names.length>0){const i=this.browser.sampleInfo.attributeNames,n=this.viewport.getBoundingClientRect().height;let r=1;const s=t.height;r=s-2*r<=1?0:1;let o=this.contentTop+t.yOffset;this.hitList={};for(const a of t.names){if(o>n)break;if(o+s>0){const t=this.browser.sampleInfo.getAttributes(a);if(t){const n=Object.entries(t);for(const t of n){const[n,a]=t;e.fillStyle=this.browser.sampleInfo.getAttributeColor(n,a);const c=8+i.indexOf(n)*Vu,l=o+r,h=s-2*r;e.fillRect(c,l,15,h);const d=`${Math.floor(c)}#${Math.floor(l)}#16#${Math.ceil(h)}`;this.hitList[d]=`${n}#${a}`}}}o+=s}}}renderSampleInfoColumns(e){const t=(e,t,i,n,r,s)=>{e.save(),e.font=\"10px verdana\",e.translate(i+r/2,n+s),e.rotate(-Math.PI/2),e.textAlign=\"left\",e.fillStyle=ro(\"lead\"),e.fillText(t,2,2),e.restore()},i=this.browser.sampleInfo.attributeNames;this.hitList={};for(let n=0;n{const{marginTop:n}=window.getComputedStyle(i),{x:r,y:s}=a(e,this.browser.columnContainer.querySelector(\".igv-sample-info-column\"));return{x:Math.floor(r),y:Math.floor(s-parseInt(n,10))}},n=this.browser.columnContainer.querySelector(\".igv-sample-info-column\"),{x:r,y:s}=i(n,this.viewport);n.setAttribute(\"title\",\"\");for(const[e,i]of t){const[t,o,a,c]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(rt+a||so+c)){n.setAttribute(\"title\",`${i}`);break}}}else{const{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){const[e,t]=r.split(\"#\");this.viewport.setAttribute(\"title\",`${e.split(Uu.emptySpaceReplacement).join(\" \")}: ${\"-\"===t?\"\":t}`);break}}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}show(){this.viewport.style.display=\"block\"}hide(){this.viewport.style.display=\"none\"}}class Ku{constructor(t,i,n,r){this.guid=s(),this.trackView=t,this.browser=t.browser,this.viewport=e({class:\"igv-viewport\"}),i.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.track.height}px`),this.canvas=document.createElement(\"canvas\"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext(\"2d\"),this.trackScrollDelta=0,this.contentTop=0,this.hitList=void 0,this.sortDirection=1,this.setWidth(r),this.addMouseHandlers()}checkCanvas(){const e=this.browser.sampleNameViewportWidth||0;this.ctx.canvas.width=e*window.devicePixelRatio,this.ctx.canvas.style.width=`${e}px`,this.ctx.canvas.height=this.viewport.clientHeight*window.devicePixelRatio,this.ctx.canvas.style.height=`${this.viewport.clientHeight}px`,this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio)}setTop(e){if(\"function\"==typeof this.trackView.track.getSamples){this.contentTop=e;const t=this.trackView.track.getSamples();this.repaint(t)}}setWidth(e){this.viewport.innerWidth=e,this.checkCanvas()}async repaint(e){if(e.names.length>0&&!0===this.browser.showSampleNames&&(this.checkCanvas(),this.draw({context:this.ctx,samples:e}),void 0===this.browser.sampleNameViewportWidth)){const t=e.names.map((e=>this.ctx.measureText(e).width));this.browser.sampleNameViewportWidth=Math.min(200,4+Math.ceil(Math.max(...t))),this.browser.layoutChange()}}draw({context:e,samples:t}){if(xo.fillRect(e,0,0,e.canvas.width,t.height,{fillStyle:ro(\"snow\")}),t&&t.names.length>0){const i=this.viewport.getBoundingClientRect().height,n=t.height,r=n-2<=1?0:1;let s=this.contentTop+t.yOffset;this.hitList={};for(const o of t.names){if(s>i)break;if(s+n>0){const t=n-2*r;Yu(e,o,0+2,s+r,e.canvas.width,t)}s+=n}}}renderSVGContext(e,{deltaX:t,deltaY:i}){if(\"function\"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:o,height:a}=this.viewport.getBoundingClientRect(),c=`${(this.trackView.track.name||this.trackView.track.id).replace(/\\W/g,\"\")}_sample_names_guid_${s()}`;e.saveWithTranslationAndClipRect(c,t,i+r,o,a,-r),this.draw({context:e,samples:n}),e.restore()}}addMouseHandlers(){this.boundClickHandler=function(e){e.preventDefault();const t={label:\"Name Panel Width\",value:this.browser.sampleNameViewportWidth,callback:e=>{this.browser.sampleNameViewportWidth=parseInt(e),this.browser.layoutChange()}};this.browser.inputDialog.present(t,e)}.bind(this),this.viewport.addEventListener(\"contextmenu\",this.boundClickHandler),this.boundMouseMoveHandler=function(e){if(this.hitList){const t=Object.entries(this.hitList),{x:i,y:n}=a(e,this.viewport);this.viewport.setAttribute(\"title\",\"\");for(const[e,r]of t){const[t,s,o,a]=e.split(\"#\").map((e=>parseInt(e,10)));if(!(it+o||ns+a)){this.viewport.setAttribute(\"title\",`${r}`);break}}}}.bind(this),this.viewport.addEventListener(\"mousemove\",this.boundMouseMoveHandler)}removeMouseHandlers(){this.viewport.removeEventListener(\"contextmenu\",this.boundClickHandler),this.viewport.removeEventListener(\"mousemove\",this.boundMouseMoveHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function Yu(e,t,i,n,r,s){const o=Math.min(s,10);e.font=`${o}px sans-serif`,e.textAlign=\"start\",e.fillStyle=ro(\"lead\");const a=i,c=e.measureText(t),l=n+s/2+(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent)/2;e.fillText(t,a,l)}class Xu{constructor(t){this.popover=e({class:\"igv-menu-popup\"}),t.appendChild(this.popover),this.parent=t;const i=e({class:\"igv-menu-popup-header\"});this.popover.appendChild(i),u(i,(()=>this.popover.style.display=\"none\")),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),p(this.popover,i),i.addEventListener(\"click\",(e=>{e.stopPropagation(),e.preventDefault()})),this.popover.style.display=\"none\"}presentMenuList(e,t){if(Zu(this.parent),t.length>0){this.popoverContent.innerHTML=\"\";const i=this.parseMenuList(e,t);for(let e of i){e.init&&e.init();let t=e.object;0===i.indexOf(e)&&t.removeClass(\"igv-track-menu-border-top\"),t.hasClass(\"igv-track-menu-border-top\")||t.hasClass(\"igv-menu-popup-check-container\")||t.is(\"div\")&&t.addClass(\"igv-menu-popup-shim\"),this.popoverContent.appendChild(t.get(0))}this.popover.style.display=\"flex\";const{width:n}=this.popover.getBoundingClientRect();this.popover.style.left=-n+\"px\",this.popover.style.top=\"0px\"}}parseMenuList(e,t){return t.map(((t,i)=>{let n;if(t.name?(n=Bt(\"
\"),n.text(t.name)):t.object?n=t.object:\"string\"==typeof t.label?(n=Bt(\"
\"),n.html(t.label)):\"string\"==typeof t&&(n=t.startsWith(\"<\")?Bt(t):Bt(\"
\"+t+\"
\")),0===i&&n.addClass(\"igv-track-menu-border-top\"),t.click||t.dialog){const i=i=>{if(i.preventDefault(),i.stopPropagation(),t.click)if(e.track.selected){const n=e.browser.getSelectedTrackViews();if(!0===t.doAllMultiSelectedTracks)t.click.call(e.track,i);else if(\"removeTrack\"===t.menuItemType){const r=()=>{e.browser.overlayTrackButton.setVisibility(!1);for(const{track:e}of n)t.click.call(e,i)},s={html:`Are you sure you want to delete ${n.length} tracks?`,callback:r};e.browser.menuUtils.dialog.present(s,i)}else for(const{track:e}of n)t.click.call(e,i)}else t.click.call(e.track,i);else t.dialog&&t.dialog.call(e.track,i);this.popover.style.display=\"none\"};n.on(\"click\",i),n.on(\"touchend\",(e=>i(e))),n.on(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}return{object:n,init:t.init||void 0}}))}presentTrackContextMenu(t,n){this.popoverContent.innerHTML=\"\";const r=function(t,n){return t.map((t=>{let r;if(\"string\"==typeof t&&\"
\"===t)r=document.createElement(\"hr\");else if(\"string\"==typeof t)r=e({class:\"context-menu\"}),r.innerHTML=t;else if(\"Node\"==typeof t)r=t;else{if(\"function\"==typeof t.init&&t.init(),\"checkbox\"===t.type)r=Dl(\"Show all bases\",t.value);else if(\"color\"===t.type){const s=new Ra(n.parentElement);s.configure({color:\"grey\"}),r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);const o=e=>{s.show(),i(n),e.preventDefault(),e.stopPropagation()};r.addEventListener(\"click\",o),r.addEventListener(\"touchend\",o),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}else r=e({class:\"context-menu\"}),\"string\"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&\"color\"!==t.type){function a(e){t.click(),i(n),e.preventDefault(),e.stopPropagation()}r.addEventListener(\"click\",a),r.addEventListener(\"touchend\",a),r.addEventListener(\"mouseup\",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{el:r,init:t.init}}))}(n,this.popover);for(let{el:e}of r)this.popoverContent.appendChild(e);!function(e,t){t.style.display=\"flex\";const{x:i,y:n}=a(e,t.parentNode),{width:r}=t.getBoundingClientRect(),s=i+r,{width:o}=t.parentNode.getBoundingClientRect();t.style.left=`${s>o?i-(s-o):i}px`,t.style.top=`${n}px`}(t,this.popover)}hide(){this.popover.style.display=\"none\"}dispose(){this.popoverContent.innerHTML=\"\",this.popover.innerHTML=\"\",Object.keys(this).forEach((function(e){this[e]=void 0}))}}const Zu=e=>{const t=e.querySelectorAll(\".igv-menu-popup\");for(const e of t)e.style.display=\"none\"};class Ju{constructor(t,i,n,r,s,o,a){this.browser=i,this.button=e({class:\"igv-navbar-text-button\"}),t.appendChild(this.button),Array.isArray(n)?(this.textContent=n[0],this.title=n[1]):this.textContent=this.title=n,this.buttonLabel=r,this.imageDictionary={image:`url(\"data:image/svg+xml,${encodeURIComponent(s)}\")`,imageHover:`url(\"data:image/svg+xml,${encodeURIComponent(o)}\")`},this.responsiveKey=\"text\",this.configureButton(this.textContent,this.title),this.setState(a),i.on(\"navbar-resize\",(e=>{this.navbarResizeHandler(e)}))}navbarResizeHandler(e){const t=\"igv-navbar-icon-button\"===e?\"image\":\"text\";t!==this.responsiveKey&&(this.responsiveKey=t,this.configureButton(this.textContent,this.title),this.setState(void 0))}configureButton(e,t){this.groupElement=void 0,this.button.title=t,this.button.innerHTML=\"\",this.button.style.backgroundImage=\"none\",this.button.classList.remove(\"igv-navbar-icon-button\"),this.button.classList.remove(\"igv-navbar-text-button\"),\"text\"===this.responsiveKey?this.configureTextButton(e):this.configureIconButton()}configureTextButton(e){console.log(`text ${this.title}`),this.button.classList.add(\"igv-navbar-text-button\");const t=document.createElement(\"div\");t.innerHTML=this.buttonLabel;const i=t.firstChild;this.button.appendChild(i),this.groupElement=i.querySelector(\"#igv-navbar-button-group\");i.querySelector(\"#igv-navbar-button-label\").textContent=e}configureIconButton(){console.log(`icon ${this.title}`),this.button.classList.add(\"igv-navbar-icon-button\")}setState(e){void 0!==e&&(this.doHover=e),\"text\"===this.responsiveKey?this.setTextButtonState(this.doHover):this.setIconButtonState(this.doHover)}setTextButtonState(e){this.groupElement.classList.remove(...this.groupElement.classList);const t=!0===e?\"igv-navbar-text-button-svg-hover\":\"igv-navbar-text-button-svg-inactive\";this.groupElement.classList.add(t)}setIconButtonState(e){this.button.style.backgroundImage=!0===e?this.imageDictionary.imageHover:this.imageDictionary.image}show(){this.button.style.display=\"flex\"}hide(){this.button.style.display=\"none\"}setVisibility(e){!0===e?this.show():this.hide()}}const ef='\\n \\n \\n \\n \\n \\n \\n \\n \\n';class tf extends Hl{static defaults={autoscale:void 0,alpha:.5,height:50};constructor(e,t,i){super(e,t),this.type=\"merged\",this.paintAxis=cd,this.graphType=e.graphType,this.tracks=i||[]}async postInit(){if(this.config.tracks){for(let e of this.config.tracks){const t=await this.browser.createTrack(e);t?this.tracks.push(t):console.warn(\"Could not create track \"+e),\"function\"==typeof t.postInit&&await t.postInit()}this.config.tracks.every((e=>void 0!==e.autoscale||void 0!==e.max))||(this.config.autoscale=void 0===this.config.max)}for(let e of this.tracks)e.isMergedTrack=!0;if(this.config.autoscale?this.autoscale=this.config.autoscale:void 0!==this.config.max&&this.setDataRange({min:this.config.min||0,max:this.config.max}),void 0!==this.config.flipAxis)for(let e of this.tracks)e.flipAxis=this.config.flipAxis;if(void 0!==this.config.logScale)for(let e of this.tracks)e.logScale=this.config.logScale;this.resolutionAware=this.tracks.some((e=>e.resolutionAware))}set flipAxis(e){this.config.flipAxis=e;for(let t of rf(this.tracks))t.flipAxis=e}get flipAxis(){return rf(this.tracks).every((e=>e.flipAxis))}set logScale(e){this.config.logScale=e;for(let t of rf(this.tracks))t.logScale=e}get logScale(){return rf(this.tracks).every((e=>e.logScale))}get height(){return this._height}set height(e){if(this.config.height=e,this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}set autoscale(e){if(this._autoscale=e,!1===e&&this.tracks)for(let e of this.tracks)e.autoscale=!1}get autoscale(){return this._autoscale}set autoscaleGroup(e){if(this.tracks)for(let t of this.tracks)t.autoscaleGroup=e}get autoscaleGroup(){if(this.tracks&&this.tracks.length>0){const e=this.tracks[0].autoscaleGroup;return this.tracks.some((t=>e!==t.autoscaleGroup))?void 0:e}}setDataRange({min:e,max:t}){this.autoscale=!1;for(const i of rf(this.tracks))i.dataRange={min:e,max:t},i.autoscale=!1,i.autoscaleGroup=!1}set dataRange({min:e,max:t}){for(const i of rf(this.tracks))i.dataRange={min:e,max:t}}get dataRange(){if(this.tracks){const e=rf(this.tracks);if(e.length>0){const t=e[0].dataRange;if(e.every((e=>e.dataRange&&e.dataRange.min===t.min&&e.dataRange.max===t.max)))return t}}}menuItemList(){const e=[];return rf(this.tracks).length>0&&(void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e.push(...this.numericDataMenuItems())),e.push(\"
\"),e.push(this.overlayTrackAlphaAdjustmentMenuItem()),e.push(this.trackSeparationMenuItem()),e}async getFeatures(e,t,i,n){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n))),s=await Promise.all(r);if(s.every((e=>0===e.length)))return new nf([],[]);{const e=this.tracks.map((e=>e.name));return new nf(s,e)}}draw(e){const t=e.features;for(let i=0,n=this.tracks.length;i0&&i.push(\"
\"),i.push(`
${t[r].trackName}
`),t[r].features.length>0){n=!1;const s=this.tracks[r].popupData(e,t[r].features);i.push(...s)}else i.push(\"Missing or 0 value(s)\");return!0===n?[]:i}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!t.featureArrays||!Array.isArray(t.featureArrays)||0===t.featureArrays.length)return[];const i=e.genomicLocation,n=[],r=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2,s=i-r,o=i+r;for(let e=0;ee.supportsWholeGenome))}getState(){const e=super.getState(),t=[];for(let e of this.tracks)t.push(e.getState());return e.tracks=t,e}updateScales(e){let t;if(this.autoscale){t=!0;let i=[];for(let t of e){if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,r=n+e.toBP(t.getWidth()),s=t.featureCache.features;this.autoscale&&(i.push({value:s.getMax(n,r)}),i.push({value:s.getMin(n,r)}))}const e=qa(i);for(const t of rf(this.tracks))t.dataRange=e}}else{let i=-1;for(let n of this.tracks)if(++i,n.autoscale){t=!0;let r=[];for(let t of e)if(t.featureCache&&t.featureCache.features){const e=t.referenceFrame,n=e.start,s=n+e.toBP(t.getWidth()),o=t.featureCache.features.featureArrays[i];if(o)for(let e of o)if(!(e.ends)break;r.push(e)}}n.dataRange=qa(r)}}return t}overlayTrackAlphaAdjustmentMenuItem(){const t=e();return t.innerText=\"Set transparency\",{object:Bt(t),dialog:function(e){const t={label:\"Transparency\",value:this.alpha,min:0,max:1,scaleFactor:1e3,callback:e=>{this.alpha=Math.max(.001,e),this.repaintViews()}};this.browser.sliderDialog.present(t,e)}}}trackSeparationMenuItem(){const e=Bt(\"
\");return e.text(\"Separate tracks\"),{object:e,click:function(e){const t=this.autoscale,i=this.name,n=this.tracks,r=this.browser,s=this.order;r.removeTrack(this);for(let e of n)e.order=s,t&&(e.autoscaleGroup=i),e.isMergedTrack=!1,r.addTrack(e.config,e);r.updateViews()}}}}class nf{constructor(e,t){this.featureArrays=e,this.trackNames=t}getMax(e,t){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(!(void 0===r.value||Number.isNaN(r.value)||r.endt)break;i=Math.max(i,r.value)}return i!==-Number.MAX_VALUE?i:100}getMin(e,t){let i=0;for(let n of this.featureArrays)if(Array.isArray(n))for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.endt)break;i=Math.min(i,r.value)}return i}}const rf=e=>e?e.filter((e=>void 0!==e.dataRange||void 0!==e.autoscale||void 0!==e.autoscaleGroup)):[];class sf extends Ju{constructor(e,t){super(e,t,\"Overlay Tracks\",ef,'\\n Overlay Tracks\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n Overlay Tracks Hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>this.setState(!1)));this.boundMouseClickHandler=(()=>{this.setVisibility(!1),of.call(this)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(!0)}}function of(e){if(!0===af(this.browser)){const e=this.browser.getSelectedTrackViews().map((({track:e})=>e));for(const t of e)t.selected=!1;const t=[];for(let i of e)\"merged\"===i.type?t.push(...i.tracks):t.push(i);const i={name:\"Overlay\",type:\"merged\",autoscale:!1,alpha:.5,height:Math.max(...e.map((({height:e})=>e))),order:Math.min(...e.map((({order:e})=>e)))},n=new tf(i,this.browser,t);for(const t of e){const e=this.browser.trackViews.indexOf(t.trackView);this.browser.trackViews.splice(e,1),t.trackView.dispose()}this.browser.addTrack(i,n),n.trackView.updateViews()}}function af(e){const t=e.getSelectedTrackViews();if(t&&t.length>1){const e=new Set([\"wig\",\"merged\"]);return t.filter((({track:t})=>e.has(t.type))).length>1}return!1}const cf=new Set([\"sequence\",\"ruler\",\"ideogram\"]),lf=new Set([\"ruler\",\"sequence\",\"ideogram\"]);class hf{constructor(e,t,i){this.namespace=`trackview-${s()}`,this.browser=e,this.track=i,i.trackView=this,this.addDOMToColumnContainer(e,t,e.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(e,t,i){this.axis=this.createAxis(e,this.track),this.createViewports(e,t,i),this.sampleInfoViewport=new $u(this,e.columnContainer.querySelector(\".igv-sample-info-column\"),e.getSampleInfoViewportWidth()),this.sampleNameViewport=new Ku(this,e.columnContainer.querySelector(\".igv-sample-name-column\"),void 0,e.getSampleNameViewportWidth()),this.createTrackScrollbar(e),this.createTrackDragHandle(e),this.createTrackGearPopup(e)}createViewports(e,t,i){this.viewports=[];const n=e.calculateViewportWidth(i.length),r=t.querySelectorAll(\".igv-column\");for(let e=0;e{e.preventDefault(),e.stopPropagation(),this.track.selected=e.target.checked,this.setDragHandleSelectionState(e.target.checked),this.browser.overlayTrackButton.setVisibility(af(this.browser))})),this.enableTrackSelection(!1)}return n}resizeAxisCanvas(e,t){this.axis.style.width=`${e}px`,this.axis.style.height=`${t}px`,\"function\"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${e}px`,this.axisCanvas.style.height=`${t}px`)}renderSVGContext(e,{deltaX:t,deltaY:i}){!function(e,t,i,n,r){if(\"function\"==typeof t.paintAxis){const{y:o,width:a,height:c}=i.getBoundingClientRect(),l=`${(t.name||t.id).replace(/\\W/g,\"\")}_axis_guid_${s()}`;e.saveWithTranslationAndClipRect(l,n,o+r,a,c,0),t.paintAxis(e,a,c),e.restore()}}(e,this.track,this.axisCanvas,t,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:n+t,deltaY:r+i};for(let t of this.viewports){t.renderSVGContext(e,o);const{width:i}=t.$viewport.get(0).getBoundingClientRect();o.deltaX+=i}if(!0===this.browser.sampleInfo.isInitialized()&&!0===this.browser.sampleInfoControl.showSampleInfo){this.sampleInfoViewport.renderSVGContext(e,o);const{width:t}=this.sampleInfoViewport.viewport.getBoundingClientRect();o.deltaX+=t}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(e,o)}presentColorPicker(e){if(!1===lf.has(this.track.type)){const t=[],i=this.track.color||this.track.defaultColor;Mt(i)&&t.push(i),this.track.altColor&&Mt(this.track.altColor)&&t.push(this.track.altColor);let n=t.map((e=>e.startsWith(\"#\")?e:e.startsWith(\"rgb(\")?_s.rgbToHex(e):_s.colorNameToHex(e))),r={color:e=>{this.track.color=io(e),this.repaintViews()},altColor:e=>{this.track.altColor=io(e),this.repaintViews()}};const s=this.browser.getSelectedTrackViews();s.length>0&&new Set(s).has(this)?(r={color:e=>{for(let t of s)t.track.color=e,t.repaintViews()}},this.browser.genericColorPicker.configure(n,r)):this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(e),this.browser.genericColorPicker.show()}}setTrackHeight(e,t){t||(this.track.minHeight&&(e=Math.max(this.track.minHeight,e)),this.track.maxHeight&&(e=Math.min(this.track.maxHeight,e))),this.track.height=e,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),\"function\"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:t}of this.viewports)t.height(e);if(this.sampleInfoViewport.setHeight(e),this.sampleNameViewport.viewport.style.height=`${e}px`,\"function\"!=typeof this.track.computePixelHeight)for(let t of this.viewports)t.setContentHeight(e);this.repaintViews(),this.updateScrollbar(),this.dragHandle.style.height=`${e}px`,this.gearContainer.style.height=`${e}px`}updateScrollbar(){const e=this.viewports[0].$viewport.height();if(this.outerScroll.style.height=`${e}px`,!1===cf.has(this.track.type)){const t=this.maxViewportContentHeight(),i=Math.round(e/t*e);t>e?(this.innerScroll.style.display=\"block\",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display=\"none\"}}moveScroller(e){const t=Bt(this.innerScroll).position().top+e,i=Math.min(Math.max(0,t),this.outerScroll.clientHeight-this.innerScroll.clientHeight);Bt(this.innerScroll).css(\"top\",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let e of this.viewports)e.setTop(r);this.sampleInfoViewport.setTop(r),this.sampleNameViewport.trackScrollDelta=e,this.sampleNameViewport.setTop(r)}isLoading(){for(let e of this.viewports)if(e.isLoading())return!0}repaintViews(){for(let e of this.viewports)e.isVisible()&&e.repaint();\"function\"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSampleInfo(),this.repaintSamples()}repaintSampleInfo(){this.sampleInfoViewport.repaint()}repaintSamples(){if(\"function\"==typeof this.track.getSamples){const e=this.track.getSamples();e.names&&e.names.length>0&&this.sampleNameViewport.repaint(e)}}setTrackLabelName(e){this.viewports.forEach((t=>t.setTrackLabel(e)))}resize(e){for(let t of this.viewports)t.setWidth(e)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const e=this.viewports.filter((e=>e.isVisible()));if(e.forEach((e=>e.shift())),this.browser.dragObject)return;const t=e.filter((e=>e.needsRepaint())).filter((e=>e.checkZoomIn())),i=e.filter((e=>e.checkZoomIn())).filter((e=>e.needsReload()));for(let e of i)await e.loadFeatures();if(this.disposed)return;if(this.track&&\"function\"==typeof this.track.variantRowCount&&i.length>0){let e=0;for(let t of this.viewports)t.featureCache&&t.featureCache.features&&(e=Math.max(e,t.featureCache.features.reduce(((e,t)=>Math.max(e,t.row||0)),0)));if(this.track.nVariantRows!==e+1){this.track.variantRowCount(e+1);for(let e of this.viewports)e.checkContentHeight()}}let n;if(\"merged\"===this.track.type)n=this.track.updateScales(e);else if(this.track.autoscale){let t=[];for(let i of e){const e=i.referenceFrame,n=e.start,r=n+e.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(n,r);if(t.push({value:e}),\"function\"==typeof i.featureCache.features.getMin){const e=i.featureCache.features.getMin(n,r);t.push({value:e})}}else{const e=to(i.featureCache.features,n,r);for(let i of e)t.push(i)}}\"function\"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(t):this.track.dataRange=qa(t)}const r=this.track.autoscale||this.track.autoscaleGroup||\"ruler\"===this.track.type||n||this.track.groupBy;for(let i of e)t.includes(i)?i.repaint():r&&i.refresh();this.adjustTrackHeight(),this.repaintSampleInfo(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let e of this.viewports)e.clearCache()}updateRulerViewportLabels(){const e=this.browser.calculateViewportWidth(this.viewports.length);for(let t of this.viewports)\"ruler\"===this.track.type&&(this.viewports.length>1?t.presentLocusLabel(e):t.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let e=[];const t=this.viewports.filter((e=>e.isVisible()));for(let i of t){const t=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+t.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if(\"function\"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(r,o);e.push({value:t})}else{const t=\"function\"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):to(i.featureCache.features,r,o);e=e.concat(t)}}return e}checkContentHeight(){for(let e of this.viewports)e.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var e=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(e,!1):this.track.paintAxis&&this.paintAxis(),!1===cf.has(this.track.type)){const t=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-e);if(t{if(!t.isVisible())return!1;if(t.checkZoomIn()){const i=t.referenceFrame,n=t.referenceFrame.chr,r=i.start,s=r+i.toBP(Bt(t.contentDiv).width()),o=i.bpPerPixel;return e||!t.tile||t.tile.invalidate||!t.tile.containsRange(n,r,s,o)}return!1}))}createTrackScrollbar(t){const i=e();if(t.columnContainer.querySelector(\".igv-scrollbar-column\").appendChild(i),i.style.height=`${this.track.height}px`,this.outerScroll=i,!1===cf.has(this.track.type)){const n=e();i.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){\"sequence\"!==this.track.type&&!0===mo.has(this.track.type)?this.dragHandle=e({class:\"igv-track-drag-shim\"}):(this.dragHandle=e({class:\"igv-track-drag-handle\"}),this.dragHandle.classList.add(\"igv-track-drag-handle-color\")),t.columnContainer.querySelector(\".igv-track-drag-column\").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){if(this.gearContainer=e(),t.columnContainer.querySelector(\".igv-gear-menu-column\").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu);else{function i(e){if(e.preventDefault(),e.stopPropagation(),\"none\"===this.trackGearPopup.popover.style.display){for(const e of t.trackViews.filter((e=>e!==this&&void 0!==e.trackGearPopup)))e.trackGearPopup.popover.style.display=\"none\";this.trackGearPopup.presentMenuList(this,t.menuUtils.trackMenuItemList(this))}else this.trackGearPopup.popover.style.display=\"none\"}this.gear=e(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(l(\"cog\")),this.trackGearPopup=new Xu(this.gear),this.boundTrackGearClickHandler=i.bind(this),this.gear.addEventListener(\"click\",this.boundTrackGearClickHandler)}}addTrackScrollMouseHandlers(e){this.boundTrackScrollMouseDownHandler=function(t){t.stopPropagation();const{y:i}=r(t);Bt(this.innerScroll).data(\"yDown\",i.toString()),this.boundColumnContainerMouseMoveHandler=function(e){e.stopPropagation();const{y:t}=r(e);this.moveScroller(t-parseInt(Bt(this.innerScroll).data(\"yDown\"))),Bt(this.innerScroll).data(\"yDown\",t.toString())}.bind(this),e.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(t){e.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler)}.bind(this),e.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),e.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===cf.has(this.track.type)&&(this.innerScroll.removeEventListener(\"mousedown\",this.boundTrackScrollMouseDownHandler),this.browser.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.browser.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.browser.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseMoveHandler))}addTrackDragMouseHandlers(e){if(\"sequence\"===this.track.type||!1===mo.has(this.track.type)){let t;function i(i){i.preventDefault(),t=i.target,!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.add(\"igv-track-drag-handle-hover-color\")),e.startTrackDrag(this)}function n(i){e.endTrackDrag(),t&&i.target!==t&&!1===this.track.selected&&(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-color\")),t=void 0}function r(i){i.preventDefault(),void 0===t&&!1===this.track.selected&&(i.target.classList.remove(\"igv-track-drag-handle-color\"),i.target.classList.add(\"igv-track-drag-handle-hover-color\")),e.updateTrackDrag(this)}function s(e){e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))}this.boundTrackDragMouseDownHandler=i.bind(this),this.dragHandle.addEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=n.bind(this),document.addEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=r.bind(this),this.dragHandle.addEventListener(\"mouseenter\",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener(\"mouseout\",(e=>{e.preventDefault(),void 0===t&&!1===this.track.selected&&(e.target.classList.remove(\"igv-track-drag-handle-hover-color\"),e.target.classList.add(\"igv-track-drag-handle-color\"))})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){\"ideogram\"===this.track.type||\"ruler\"===this.track.type||(this.dragHandle.removeEventListener(\"mousedown\",this.boundTrackDragMouseDownHandler),document.removeEventListener(\"mouseup\",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener(\"mouseup\",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener(\"mouseout\",this.boundTrackDragMouseOutHandler))}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener(\"click\",this.boundTrackGearClickHandler)}removeDOMFromColumnContainer(){this.axis.remove(),this.removeViewportsFromColumnContainer(),this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}removeViewportsFromColumnContainer(){for(let e of this.viewports)e.$viewport.remove()}dispose(){this.axis.remove();for(let e of this.viewports)e.dispose();this.sampleInfoViewport.dispose(),this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),\"function\"==typeof this.track.dispose&&this.track.dispose();for(let e of Object.keys(this))this[e]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if(\"function\"==typeof this.track.paintAxis){const{width:e,height:t}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*t,this.axisCanvas.width=i*e;const n=this.axisCanvas.getContext(\"2d\");if(n.scale(i,i),this.track.autoscaleGroup){if(void 0===wo[this.track.autoscaleGroup]){const e=so.Dark2,t=Math.floor(Math.random()*so.Dark2.length);wo[this.track.autoscaleGroup]=e[t]}const i=_s.addAlpha(wo[this.track.autoscaleGroup],.75);this.track.paintAxis(n,e,t,i)}else this.track.paintAxis(n,e,t,void 0)}}maxViewportContentHeight(){return Math.max(...this.viewports.map((e=>e.getContentHeight())))}enableTrackSelection(e){const t=this.trackSelectionContainer;if(t&&!mo.has(this.track.type))if(!1!==e)t.style.display=\"grid\";else{this.track.selected=!1;t.querySelector(\"[name=track-select]\").checked=this.track.selected,this.dragHandle&&this.setDragHandleSelectionState(!1),t.style.display=\"none\"}}setDragHandleSelectionState(e){const t=this.dragHandle;e?(t.classList.remove(\"igv-track-drag-handle-color\"),t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.add(\"igv-track-drag-handle-selected-color\")):(t.classList.remove(\"igv-track-drag-handle-hover-color\"),t.classList.remove(\"igv-track-drag-handle-selected-color\"),t.classList.add(\"igv-track-drag-handle-color\"))}}function df(e){this.thresholds=e.thresholds,this.colors=e.colors}function uf(e){this.scale=e,this.lowColor=\"rgb(\"+e.lowR+\",\"+e.lowG+\",\"+e.lowB+\")\",this.highColor=\"rgb(\"+e.highR+\",\"+e.highG+\",\"+e.highB+\")\",this.diff=e.high-e.low}df.prototype.getColor=function(e){for(let t of this.thresholds)if(e=i.high?this.highColor:(t=(e-i.low)/this.diff,\"rgb(\"+Math.floor(i.lowR+t*(i.highR-i.lowR))+\",\"+Math.floor(i.lowG+t*(i.highG-i.lowG))+\",\"+Math.floor(i.lowB+t*(i.highB-i.lowB))+\")\")};class ff{constructor(e){this.color=e}getColor(){return this.color}}const pf={threshold:2e3,r:0,g:0,b:255};class gf{constructor(e){e=e||pf,this.threshold=e.threshold,this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[],this.nbins=2e3,this.binsize=this.threshold/this.nbins}setThreshold(e){this.threshold=e,this.cache=[],this.binsize=this.threshold/this.nbins}getThreshold(){return this.threshold}setColorComponents(e){this.r=e.r,this.g=e.g,this.b=e.b,this.cache=[]}getColorComponents(){return{r:this.r,g:this.g,b:this.b}}equals(e){return JSON.stringify(this)===JSON.stringify(e)}getColor(e){const t=Math.floor(Math.min(this.threshold,e)/this.binsize);if(void 0===this.cache[t]){const i=(ys.clamp(e,0,this.threshold)-0)/(this.threshold-0);this.cache[t]=`rgba(${this.r},${this.g},${this.b}, ${i})`}return this.cache[t]}stringify(){return this.threshold+\",\"+this.r+\",\"+this.g+\",\"+this.b}static parse(e){var t,i;return e.startsWith(\"R:\")?(t=e.substring(2).split(\":\"),(i=new RatioColorScale(Number.parseFloat(t[0]))).positiveScale=n(t[1]),i.negativeScale=n(t[2]),i):n(e);function n(e){var t,i;return t={threshold:(i=e.split(\",\"))[0],r:i[1],g:i[2],b:i[3]},new gf(t)}}}class mf{constructor(e){this.config=e,this.url=e.path||e.url}async read(e,t){const i={start:e,size:t};return Qs.loadArrayBuffer(this.url,{range:i})}}class wf{constructor(e){this.file=e}async read(e,t){const i=this.file;return void 0!==e?i.slice(e,e+t).arrayBuffer():i.arrayBuffer()}}class bf{constructor(e,t){this.file=e,this.rateLimiter=t}async read(e,t){const i=this.file,n=this.rateLimiter;return new Promise((function(r,s){n.limiter((async function(i){try{const n=await i.read(e,t);r(n)}catch(e){s(e)}}))(i)}))}}class Ff{constructor(e){this.file=e.file,this.size=e.size||64e3,this.position=0,this.bufferStart=0,this.bufferLength=0,this.buffer=void 0}async read(e,t){const i=e,n=e+t,r=this.bufferStart,s=this.bufferStart+this.bufferLength;if(t>this.size)return this.buffer=void 0,this.bufferStart=0,this.bufferLength=0,this.file.read(e,t);if(i>=r&&n<=s){const e=i-r,n=e+t;return this.buffer.slice(e,n)}if(ir){const n=r-i,s=await this.file.read(e,n),o=t-n;if(o>0){const e=this.buffer.slice(0,o);return vf(s,e)}return s}if(!(is))return this.buffer=await this.file.read(e,this.size),this.bufferStart=e,this.bufferLength=this.buffer.byteLength,this.buffer.slice(0,t);{const e=s-i,n=this.bufferLength-e,r=this.buffer.slice(n,this.bufferLength),o=t-e;if(!(o>0))return r;try{this.buffer=await this.file.read(s,this.size),this.bufferStart=s,this.bufferLength=this.buffer.byteLength;const e=this.buffer.slice(0,o);return vf(r,e)}catch(e){if(e.code&&416===e.code)return r;throw e}}}}var vf=function(e,t){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer};const yf=function(e,t){this.littleEndian=void 0===t||t,this.position=0,this.view=e,this.length=e.byteLength};function Af(e,t){this.block=e,this.offset=t}yf.prototype.available=function(){return this.length-this.position},yf.prototype.remLength=function(){return this.length-this.position},yf.prototype.hasNext=function(){return this.position=0;i--)t=256*t+e[i];else for(i=0;i0&&(n+=String.fromCharCode(i));return n},yf.prototype.getFixedLengthTrimmedString=function(e){var t,i,n=\"\";for(t=0;t32&&(n+=String.fromCharCode(i));return n},yf.prototype.getFloat=function(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e},yf.prototype.getDouble=function(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e},yf.prototype.skip=function(e){return this.position+=e,this.position},yf.prototype.getVPointer=function(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new Af(i,t)},Af.prototype.isLessThan=function(e){return this.blocke.block||this.block===e.block&&this.offset>e.offset},Af.prototype.print=function(){return this.block+\":\"+this.offset};class Cf{constructor(e,t){this.chr1=e,this.chr2=t}getKey(){return this.chr1.name+\"_\"+this.chr2.name+\"_\"+this.zoom.unit+\"_\"+this.zoom.binSize}getBlockNumbers(e,t,i){if(e.chr==this.chr2&&t.chr===this.chr1){const i=e;e=t,t=i}const n=this.chr1===this.chr2,r=this.zoom.binSize,s=this.blockBinCount,o=this.blockColumnCount;return i<9||!n?function(){const i=e.start/r,a=e.end/r,c=t.start/r,l=t.end/r,h=Math.floor(i/s),d=Math.floor((a-1)/s),u=Math.floor(c/s),f=Math.floor((l-1)/s),p=[];for(let e=u;e<=f;e++)for(let t=h;t<=d;t++){let i;i=n&&e0;){const e=t.getInt(),i=t.getLong(),n=t.getInt();this.blockIndex[e]={filePosition:i,size:n}}}getBlockIndexEntry(e){return this.blockIndex[e]}}class xf{constructor(e,t,i){this.chr1=e,this.chr2=t,this.bpZoomData=[],this.fragZoomData=[];for(let e of i)\"BP\"===e.zoom.unit?this.bpZoomData.push(e):this.fragZoomData.push(e)}findZoomForResolution(e,t){const i=\"FRAG\"===t?this.fragZoomData:this.bpZoomData;for(let t=1;tt){const i=e;e=t,t=i}return`${e}_${t}`}static parseMatrix(e,t){const i=new yf(new DataView(e)),n=i.getInt(),r=i.getInt(),s=t[n],o=t[r];let a=i.getInt();const c=[];for(;a-- >0;){const e=Cf.parseMatrixZoomData(s,o,i);c.push(e)}return new xf(n,r,c)}}class kf{constructor(e,t,i){this.bin1=e,this.bin2=t,this.counts=i}getKey(){return this.bin1+\"_\"+this.bin2}}class If{constructor(e=10){this.max=e,this.map=new Map}get(e){let t=this.map.get(e);return t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){this.map.has(e)?this.map.delete(e):this.map.size===this.max&&this.map.delete(this.first()),this.map.set(e,t)}has(e){return this.map.has(e)}clear(){this.map.clear()}first(){return this.map.keys().next().value}}class Sf{constructor(e,t,i,n){this.file=e,this.filePosition=t,this.nValues=i,this.dataType=n,this.cache=void 0}async getValues(e,t){if(!this.cache||ethis.cache.end){const i=Math.max(0,e-1e3),n=Math.min(this.nValues,t+1e3),r=this.filePosition+i*this.dataType,s=n-i,o=s*this.dataType,a=await this.file.read(r,o);if(!a)return;const c=new yf(new DataView(a)),l=[];for(let e=0;e=0||t.indexOf(\"www.googleapis.com/drive\")>0?this.file=new bf(i,Bf):this.file=i}}var t}async init(){this.initialized||(await this.readHeaderAndFooter(),this.initialized=!0)}async getVersion(){if(void 0===this.version){const e=await this.file.read(0,128);if(!e)return;const t=new yf(new DataView(e));return this.magic=t.getString(),this.version=t.getInt(),this.version}return this.version}async getMetaData(){return await this.init(),this.meta}async readHeaderAndFooter(){let e=await this.file.read(0,16);if(!e||0===e.byteLength)throw Error(\"File content is empty\");let t=new yf(new DataView(e));if(this.magic=t.getString(),this.version=t.getInt(),this.version<5)throw Error(\"Unsupported hic version: \"+this.version);this.footerPosition=t.getLong(),await this.readFooter();const i=Object.values(this.masterIndex).reduce(((e,t)=>Math.min(e,t.start)),Number.MAX_VALUE)-16;e=await this.file.read(16,i),t=new yf(new DataView(e)),this.genomeId=t.getString(),this.version>=9&&(this.normVectorIndexPosition=t.getLong(),this.normVectorIndexSize=t.getLong()),this.attributes={};let n=t.getInt();for(;n-- >0;)this.attributes[t.getString()]=t.getString();this.chromosomes=[],this.chromosomeIndexMap={};let r=t.getInt(),s=0;for(;r-- >0;){const e={index:s,name:t.getString(),size:this.version<9?t.getInt():t.getLong()};\"all\"===e.name.toLowerCase()&&(this.wholeGenomeChromosome=e,this.wholeGenomeResolution=Math.round(2*e.size)),this.chromosomes.push(e),this.chromosomeIndexMap[e.name]=e.index,s++}this.bpResolutions=[];let o=t.getInt();for(;o-- >0;)this.bpResolutions.push(t.getInt());if(this.loadFragData){this.fragResolutions=[];let e=t.getInt();if(e>0)for(;e-- >0;)this.fragResolutions.push(t.getInt())}this.chrAliasTable={};for(let e of Object.keys(this.chromosomeIndexMap))e.startsWith(\"chr\")?this.chrAliasTable[e.substr(3)]=e:\"MT\"===e?this.chrAliasTable.chrM=e:this.chrAliasTable[\"chr\"+e]=e;this.meta={version:this.version,genome:this.genomeId,chromosomes:this.chromosomes,resolutions:this.bpResolutions}}async readFooter(){const e=this.version<9?8:12;let t=await this.file.read(this.footerPosition,e);if(!t)return null;let i=new yf(new DataView(t));const n=this.version<9?i.getInt():i.getLong();let r=i.getInt();const s=196*r;for(t=await this.file.read(this.footerPosition+e,Math.min(s,n)),i=new yf(new DataView(t)),this.masterIndex={};r-- >0;){const e=i.getString(),t=i.getLong(),n=i.getInt();this.masterIndex[e]={start:t,size:n}}if(this.expectedValueVectors={},this.version>5){const e=this.version<9?4:8;this.normExpectedValueVectorsPosition=this.footerPosition+e+n}return this}async printIndexStats(){let e,t=0,i=0;await await this.init();for(let n of Object.keys(this.masterIndex)){const r=this.masterIndex[n];t+=r.size,r.size>i&&(i=r.size,e=n)}console.log(`${i} ${e} ${this.config.url}`)}async getMatrix(e,t){const i=xf.getKey(e,t);if(this.matrixCache.has(i))return this.matrixCache.get(i);{const n=await this.readMatrix(e,t);return this.matrixCache.set(i,n),n}}async readMatrix(e,t){if(await this.init(),e>t){const i=e;e=t,t=i}const i=xf.getKey(e,t),n=this.masterIndex[i];if(!n)return;const r=await this.file.read(n.start,n.size);return r?xf.parseMatrix(r,this.chromosomes):void 0}async getContactRecords(e,t,i,n,r,s=!1){await this.init();const o=this.chromosomeIndexMap[this.getFileChrName(t.chr)],a=this.chromosomeIndexMap[this.getFileChrName(i.chr)];if(o>a||o===a&&t.start>=i.end){const e=t;t=i,i=e}const c=await this.getBlocks(t,i,n,r);if(!c||0===c.length)return[];const l=[],h=t.start/r,d=t.end/r,u=i.start/r,f=i.end/r,p=Math.floor(h),g=Math.ceil(d),m=Math.floor(u),w=Math.ceil(f);for(let o of c)if(o){let a,c,b=e&&\"NONE\"!==e;const F=this.getFileChrName(t.chr),v=this.getFileChrName(i.chr);if(b){const t=await this.getNormalizationVector(e,F,n,r),i=F===v?t:await this.getNormalizationVector(e,v,n,r);t&&i?(a=await t.getValues(p,g),c=await i.getValues(m,w)):b=!1}for(let e of o.records)if(s||e.bin1>=h&&e.bin1=u&&e.bin210&&(this.percentile95=Lf(o.records,95))}return l}async getBlocks(e,t,i,n){const r=(e,t)=>`${t.getKey()}_${e}`;await this.init();const s=this.getFileChrName(e.chr),o=this.getFileChrName(t.chr),a=this.chromosomeIndexMap[s],c=this.chromosomeIndexMap[o];if(void 0===a)return console.log(\"No chromosome named: \"+e.chr),[];if(void 0===c)return console.log(\"No chromosome named: \"+t.chr),[];const l=await this.getMatrix(a,c);if(!l)return console.log(\"No matrix for \"+e.chr+\"-\"+t.chr),[];const h=l.getZoomData(n,i);if(!h){let i=`No data avalailble for resolution: ${n} for map ${e.chr}-${t.chr}`;throw new Error(i)}const d=h.getBlockNumbers(e,t,this.version),u=[],f=[];for(let e of d){const t=r(e,h);this.blockCache.has(n,t)?u.push(this.blockCache.get(n,t)):f.push(e)}const p=f.map((e=>this.readBlock(e,h))),g=await Promise.all(p);for(let e of g)e&&this.blockCache.set(n,r(e.blockNumber,h),e);return u.concat(g)}async readBlock(e,t){const i=await t.blockIndex.getBlockIndexEntry(e);if(i){let n=await this.file.read(i.filePosition,i.size);if(!n)return;n=new ls(new Uint8Array(n)).buffer;const r=new yf(new DataView(n)),s=r.getInt(),o=[];if(this.version<7)for(let e=0;e0;)this.parseNormVectorEntry(i);return this.normVectorIndex}async readNormExpectedValuesAndNormVectorIndex(){if(await this.init(),void 0===this.normExpectedValueVectorsPosition)return;const e=await this.skipExpectedValues(this.normExpectedValueVectorsPosition);let t=4,i=await this.file.read(e,4);if(0===i.byteLength)return;const n=new yf(new DataView(i)).getInt(),r={start:e+t,size:30*n};i=await this.file.read(r.start,r.size),this.normalizedExpectedValueVectors={},this.normVectorIndex={},await async function i(n,r){const s=new yf(new DataView(r));for(;n-- >0;){if(s.available()<100){n++,t+=s.position;const r=Math.max(1e3,30*n),o={start:e+t,size:r},a=await this.file.read(o.start,o.size);return i.call(this,n,a)}this.parseNormVectorEntry(s)}t+=s.position}.call(this,n,i),this.config.nvi=e.toString()+\",\"+t}async skipExpectedValues(e){const t=this.version,i=new Ff({file:this.file,size:256e3}),n={start:e,size:4},r=await i.read(n.start,n.size),s=new yf(new DataView(r)).getInt();return 0===s?e+4:async function e(n,r){let s={start:n,size:500},o=0,a=n,c=await i.read(s.start,s.size),l=new yf(new DataView(c));l.getString(),l.getString(),l.getInt();const h=t<9?l.getInt():l.getLong();o+=l.position+h*(t<9?8:4),s={start:n+o,size:4},c=await i.read(s.start,s.size),l=new yf(new DataView(c));const d=l.getInt();return o+=4+d*(4+(t<9?8:4)),r--,0===r?a+o:e(a+o,r)}(e+4,s)}getZoomIndexForBinSize(e,t){let i;if(\"BP\"===(t=t||\"BP\"))i=this.bpResolutions;else{if(\"FRAG\"!==t)throw new Error(\"Invalid unit: \"+t);i=this.fragResolutions}for(let t=0;te.counts));i.sort((function(e,t){return e-t}));return i[Math.floor(t/100*e.length)]}class zf{constructor(e,t){this.config=e,this.genome=t,this.hicFile=e._hicFile?e._hicFile:new Mf(e),e._hicFile=void 0}async getHeader(){return await this.hicFile.init(),this.hicFile}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){this.hicFile.initialized||await this.hicFile.init();const s=this.hicFile.bpResolutions,o=s[s.length-1];return(await this.hicFile.getContactRecords(void 0,{chr:e,start:t,end:i},{chr:\"celltype\",start:0,end:1e8},\"BP\",o)).map((t=>{const i=t.bin1*o;return{chr:e,start:i,end:i+o,value:t.counts,sample:t.bin2.toString()}}))}supportsWholeGenome(){return!1}}function Hf(e,t){const i=new Set(e.attributeNames),n=t[0];if(void 0===e.getAttributes(n))return!1;{const t=Object.keys(e.getAttributes(n));for(const e of t)if(!1===i.has(e))return!1}return!0}class Pf extends Hl{#y=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),this.type=e.type||\"seg\",\"maf\"===this.type&&(this.type=\"mut\"),this.isLog=e.isLog,this.displayMode=e.displayMode||\"EXPANDED\",this.height=e.height||300,this.maxHeight=e.maxHeight||500,this.squishedRowHeight=e.sampleSquishHeight||e.squishedRowHeight||2,this.expandedRowHeight=e.sampleExpandHeight||e.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,this.sampleKeys=[],e.samples){for(let t of e.samples)this.sampleKeys.push(t);this.explicitSamples=!0}if(e.color)this.color=e.color;else if(e.colorTable)this.colorTable=new ao(e.colorTable);else switch(this.type){case\"mut\":this.colorTable=new ao(qf);break;case\"shoebox\":e.colorScale&&(this.sbColorScale=gf.parse(e.colorScale));break;default:this.posColorScale=new uf(e.posColorScale||Of),this.negColorScale=new uf(e.negColorScale||Uf)}const t=Object.assign({},this.config);t.maxWGCount=t.maxWGCount||Number.MAX_SAFE_INTEGER,\"shoebox\"===this.type?(this.featureSource=new zf(t,this.browser.genome),this.height=e.height||500,this.maxHeight=e.maxHeight||800,this.isLog=!1,this.squishedRowHeight=e.squishedRowHeight||1,this.displayMode=e.displayMode||\"SQUISHED\",this.visibilityWindow=void 0===e.visibilityWindow?1e6:e.visibilityWindow):this.featureSource=Ad(t,this.browser.genome),this.initialSort=e.sort}async postInit(){\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const e=[];if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const n of this.browser.sampleInfo.attributeNames){if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[n]}))){const r=Bt(\"
\");function s(){const e=this.#y.get(n)||1;this.sortByAttribute(n,e),this.#y.set(n,-1*e),this.config.sort={option:\"ATTRIBUTE\",attribute:n,direction:1===e?\"ASC\":\"DESC\"}}r.html(`  ${n.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:r,click:s})}}}const t={SQUISHED:\"Squish\",EXPANDED:\"Expand\",FILL:\"Fill\"};if(\"shoebox\"===this.type&&this.sbColorScale){function o(e){this.browser.inputDialog.present({label:\"Color Scale Threshold\",value:this.sbColorScale.threshold,callback:()=>{const e=Number(this.browser.inputDialog.value,10);e&&(this.sbColorScale.setThreshold(e),this.trackView.repaintViews())}},e)}e.push(\"
\"),e.push({object:Bt(\"
Set color scale threshold
\"),dialog:o})}e.push(\"
\"),e.push(\"DisplayMode:\");const i=\"seg\"===this.type||\"shoebox\"===this.type?[\"SQUISHED\",\"EXPANDED\",\"FILL\"]:[\"SQUISHED\",\"EXPANDED\"];for(let a of i){const c=Dl(t[a],a===this.displayMode);e.push({object:Bt(c),click:function(){this.displayMode=a,this.config.displayMode=a,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return e}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.sampleHeight,yOffset:0}}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:t,end:i});if(this.updateSampleKeys(n),this.initialSort){const e=this.initialSort;if(void 0===e.option||\"VALUE\"===e.option.toUpperCase())this.sortByValue(e,n);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"DESC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return n}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){if(this.checkForLog(r),\"shoebox\"===this.type&&!this.sbColorScale){const e=this.featureSource.hicFile.percentile95||2e3;this.sbColorScale=new gf({threshold:e,r:0,g:0,b:255})}const a={};let c;switch(this.sampleKeys.forEach((function(e,t){a[e]=t})),this.displayMode){case\"FILL\":this.sampleHeight=n/this.sampleKeys.length,c=0;break;case\"SQUISHED\":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let e of r)e.pixelRect=void 0;const h=t+n,d=o+i*s+1,u=s;this.sampleYStart=void 0;for(let i of r){if(i.endd)continue;const n=i.sampleKey||i.sample;i.row=a[n];const r=i.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=r);if(r+lh)continue;const s=Math.max(i.start,o);let f=Math.round((s-o)/u);const p=Math.min(i.end,d),g=Math.round((p-o)/u);let m,w,b=Math.max(1,g-f);if(this.color?m=\"function\"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),\"mut\"===this.type)w=l-2*c,b<3&&(b=3,f-=1);else if(\"shoebox\"===this.type){m=this.sbColorScale.getColor(i.value);let e=l;if(l<.25){const t=.1+2*Math.abs(t.value);e=Math.min(1,t*l)}w=e-2*c}else{let e=i.value;this.isLog||(e=ys.log2(e/2)),m=e<-.1?this.negColorScale.getColor(e):e>.1?this.posColorScale.getColor(e):\"white\";let t=l;if(l<.25){const i=.1+2*Math.abs(e);t=Math.min(1,i*l)}w=t-2*c}i.pixelRect={x:f,y:r,w:b,h:w},e.fillStyle=m,e.fillRect(f,r,b,w)}}}checkForLog(e){if(void 0===this.isLog){this.isLog=!1;for(let t of e)if(t.value<0)return void(this.isLog=!0)}}computePixelHeight(e){if(!e)return 0;const t=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(e),this.sampleKeys.length*t}async sortByValue(e,t){const i=e.chr;let n,r;if(e.position?(n=e.position-1,r=n+1):(n=e.start,r=e.end),t||(t=await this.featureSource.getFeatures({chr:i,start:n,end:r})),!t)return;this.updateSampleKeys(t);const s={},o=\"ASC\"===e.direction?1:-1,a=()=>{const e=r-n+1;for(let i of t){if(i.endr)break;const t=Math.max(n,i.start),o=(Math.min(r,i.end)-t)/e,a=i.sampleKey||i.sample,c=s[a]||0;s[a]=c+o*i.value}this.sampleKeys.sort((function(e,t){let i=s[e],n=s[t];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))},c=()=>{for(let e of t){if(e.endr)break;const t=e.sampleKey||e.sample;(!s.hasOwnProperty(t)||e.value.localeCompare(s[t])>0)&&(s[t]=e.value)}this.sampleKeys.sort((function(e,t){let i=s[e]||\"\",n=s[t]||\"\";return o*i.localeCompare(n)}))};\"mut\"===this.type?c():a(),this.trackView.repaintViews()}sortByAttribute(e,t){this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(e){const t=e.genomicLocation,i=t=>{const i=e.viewport.cachedFeatures;this.sortByValue(t,i)},n=e.referenceFrame.toBP(2.5);return[\"DESC\",\"ASC\"].map((r=>{const s=\"DESC\"===r?\"descending\":\"ascending\";return{label:\"seg\"===this.type||\"shoebox\"===this.type?`Sort by value (${s})`:`Sort by type (${s})`,click:()=>{const s={option:\"VALUE\",direction:r,chr:e.referenceFrame.chr,start:Math.floor(t-n),end:Math.floor(t+n)};i(s),this.config.sort=s}}}))}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(e){if(this.explicitSamples)return;const t=new Set(this.sampleKeys);for(let i of e){const e=i.sampleKey||i.sample;t.has(e)||(this.sampleKeys.push(e),t.add(e))}}}const Of={low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0},Uf={low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255},qf={indel:\"rgb(0,200,0)\",\"targeted region\":\"rgb(236,155,43)\",truncating:\"rgb(\\t150,0,0)\",\"non-coding transcript\":\"rgb(0,0,150)\",synonymous:\"rgb(109,165,95)\",silent:\"rgb(109,135,80)\",missense_mutation:\"rgb(72,130,187)\",missense:\"rgb(72,130,187)\",\"splice site\":\"rgb(143,83,155)\",splice_region:\"rgb(143,83,155)\",nonsense:\"rgb(216, 57,81)\",nonsense_mutation:\"rgb(216, 57,81)\",frame_shift_del:\"rgb(226,135,65)\",frame_shift_ins:\"rgb(226,135,65)\",in_frame_del:\"rgb(247,235,94)\",in_frame_ins:\"rgb(247,235,94)\",\"*other*\":\"rgb(159,91,50)\"};class Qf{constructor(e){this.paired=!0,this.firstAlignment=e,this.chr=e.chr,this.readName=e.readName,e.startt.start?this.connectingEnd=e.start:this.connectingStart=e.start+e.lengthOnRef,this.start=Math.min(t.start,e.start),this.end=Math.max(t.start+t.lengthOnRef,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(t.scStart,e.scStart);const i=Math.max(t.scStart+t.scLengthOnRef,e.scStart+e.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}alignmentContaining(e,t){return this.firstAlignment.containsLocation(e,t)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(e,t)?this.secondAlignment:void 0}popupData(e){let t=this.firstAlignment.popupData(e);return this.secondAlignment&&(t.push(\"-------------------------------\"),t=t.concat(this.secondAlignment.popupData(e))),t}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}get firstOfPairStrand(){return this.firstAlignment.firstOfPairStrand}get pairOrientation(){return this.firstAlignment.pairOrientation}hasTag(e){return this.firstAlignment.hasTag(e)||this.secondAlignment&&this.secondAlignment.hasTag(e)}getGroupValue({option:e,tag:t}){switch(e){case\"strand\":return this.isNegativeStrand()?\"-\":\"+\";case\"FIRST_IN_PAIR_STRAND\":return this.isPaired()?this.isFirstOfPair()?this.isNegativeStrand()?\"-\":\"+\":this.isSecondOfPair()?this.isNegativeStrand()?\"+\":\"-\":void 0:void 0;case\"START\":return this.start;case\"INSERT_SIZE\":return this.fragmentLength;case\"MATE_CHR\":return this.mate?this.mate.chr:void 0;case\"MQ\":return this.mq;case\"ALIGNED_READ_LENGTH\":return this.lengthOnRef;case\"TAG\":return this.tags()[t];case\"PHASE\":return this.tags().HP;case\"READ_ORDER\":return this.isPaired()&&this.isFirstOfPair()?\"FIRST\":this.isPaired()&&this.isSecondOfPair()?\"SECOND\":\"\";default:return}}}class Vf{static instances=new Map;static getKey(e,t,i){const n=\"\"+e+t+i;return Vf.instances.has(n)||Vf.instances.set(n,new Vf(e,t,i)),Vf.instances.get(n)}constructor(e,t,i){this.base=e,this.strand=t,this.modification=i,this.canonicalBase=\"+\"===this.strand?this.base:oc(this.base)}getCanonicalBase(){}toString(){return\"\"+this.base+this.strand+this.modification}static compare(e,t){const i=e.modification,n=t.modification;return i===n?e.strand.charAt(0)-t.strand.charAt(0):jf.has(i)&jf.has(n)?jf.get(i)-jf.get(n):jf.has(i)?1:jf.has(n)?-1:i>n?1:-1}}const jf=new Map([\"NONE_C\",\"NONE_T\",\"NONE_G\",\"NONE_A\",\"m\",\"h\",\"f\",\"c\",\"C\",\"g\",\"e\",\"b\",\"T\",\"U\",\"a\",\"A\",\"o\",\"G\",\"n\",\"N\"].map(((e,t)=>[e,t])));class Wf{constructor(e,t,i,n){this.base=e,this.modification=i,this.strand=t,this.likelihoods=n,this.canonicalBase=\"+\"==this.strand?this.base:oc(this.base),this.key=Vf.getKey(e,t,i)}containsPosition(e){return this.likelihoods.has(e)}is5mC(){return this.modification.equals(\"m\")&&(\"C\"===this.base&&\"+\"===this.strand||\"G\"===this.base&&\"-\"===this.strand)}fullName(){return Gf.get(this.modification)||this.modification}}const Gf=new Map;Gf.set(\"m\",\"5mC\"),Gf.set(\"h\",\"5hmC\"),Gf.set(\"f\",\"5fC\"),Gf.set(\"c\",\"5caC\"),Gf.set(\"g\",\"5hmU\"),Gf.set(\"e\",\"5fU\"),Gf.set(\"b\",\"5caU\"),Gf.set(\"a\",\"6mA\"),Gf.set(\"o\",\"8xoG\"),Gf.set(\"n\",\"Xao\"),Gf.set(\"C\",\"Unknown C\"),Gf.set(\"T\",\"Unknown T\"),Gf.set(\"A\",\"Unknown A\"),Gf.set(\"G\",\"Unknown G\"),Gf.set(\"N\",\"Unknown\");const $f=new Map([[\"m\",\"5mC\"],[\"h\",\"5hmC\"],[\"f\",\"5fC\"],[\"c\",\"5caC\"],[\"g\",\"5hmU\"],[\"e\",\"5fU\"],[\"b\",\"5caU\"],[\"a\",\"6mA\"],[\"o\",\"8xoG\"],[\"n\",\"Xao\"],[\"C\",\"Unknown C\"],[\"T\",\"Unknown T\"],[\"A\",\"Unknown A\"],[\"G\",\"Unknown G\"],[\"N\",\"Unknown\"]]);function Kf(e){return $f.has(e)?$f.get(e):\"Uknown\"}function Yf(e){if(!e)return!1;const t=e.length;if(0==t)return!1;for(let i=0;i\"9\")return!1}return!0}function Xf(e){return e<0?e+256:e}class Zf{allModifications=new Set;simplexModifications=new Set;maxLikelihoods=new Map;nomodLikelihoods=new Map;lastThreshold;incrementCounts(e){if(!e.blocks)return;const t=e.getBaseModificationSets();if(t)for(let i of e.blocks)if(\"S\"!==i.type)for(let e=0;eo&&(s=e.canonicalBase,o=c,n=t)}}if(0!=s){const t=i.start+e,r=Vf.getKey(s,\"+\",\"NONE_\"+s);this.allModifications.add(r);const c=(e,t,i,n)=>{let r=n.get(i);r||(r=new Map,n.set(i,r));let s=r.get(e);s||(s=[],r.set(e,s)),s.push(t)};c(t,o,n,this.maxLikelihoods),a>o?c(t,a,r,this.nomodLikelihoods):c(t,o,n,this.nomodLikelihoods)}}}getCount(e,t,i,n){this.lastThreshold=i;const r=255*i,s=n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t);if(!s)return 0;const o=s.get(e);if(o){let e=0;for(let t of o){Xf(t)>=r&&e++}return e}return 0}getLikelihoodSum(e,t,i,n){this.lastThreshold=i;const r=255*i,s=(n?this.nomodLikelihoods.get(t):this.maxLikelihoods.get(t)).get(e);if(s){let e=0;for(let t of s){const i=Xf(t);i>=r&&(e+=i)}return e}return 0}popupData(e,t){const i=[];i.push(\"Modifications with likelihood > \"+100*this.lastThreshold+\"%\");for(let n of this.maxLikelihoods.keys()){if(this.maxLikelihoods.get(n).has(e)){let r=\"basemod2\"===t;const s=this.getCount(e,n,this.lastThreshold,r);if(s>0){const t=this.getLikelihoodSum(e,n,this.lastThreshold,r)/s*.3921568,o=Kf(n.modification);i.push(o+\" (\"+n.base+n.strand+\"): \"+s+\" @ average likelihood \"+Math.round(t)+\"%\")}}}return i}computeSimplex(){const e=new Set(Array.from(this.allModifications).filter((e=>\"-\"===e.strand)).map((e=>e.modification)));for(let t of this.allModifications)\"+\"!==t.strand||e.has(t.modification)||(this.simplexModifications.add(t.modification),this.simplexModifications.add(\"NONE_\"+t.getCanonicalBase()))}}class Jf{constructor(){this.alignments=[],this.score=void 0}findAlignment(e,t=!1){const i=(e,i)=>i>=e.start&&i=s.start&&e0?h-=e:0===h&&(h=1)}return h}(s,r,e);case\"strand\":return s.strand?1:-1;case\"START\":return s.start;case\"TAG\":return s.tags()[i];case\"READ_NAME\":return s.readName;case\"INSERT_SIZE\":return-Math.abs(s.fragmentLength);case\"GAP_SIZE\":return-s.gapSizeAt(e);case\"MATE_CHR\":return s.mate?s.mate.chr:Number.MAX_VALUE;case\"MQ\":return void 0===s.mq?Number.MAX_VALUE:-s.mq;case\"ALIGNED_READ_LENGTH\":return-s.lengthOnRef;default:return Number.MAX_VALUE}}}var ep={fr:{F1R2:\"LR\",F2R1:\"LR\",F1F2:\"LL\",F2F1:\"LL\",R1R2:\"RR\",R2R1:\"RR\",R1F2:\"RL\",R2F1:\"RL\"},rf:{R1F2:\"LR\",R2F1:\"LR\",R1R2:\"LL\",R2R1:\"LL\",F1F2:\"RR\",F2F1:\"RR\",F1R2:\"RL\",F2R1:\"RL\"},ff:{F2F1:\"LR\",R1R2:\"LR\",F2R1:\"LL\",R1F2:\"LL\",R2F1:\"RR\",F1R2:\"RR\",R2R1:\"RL\",F1F2:\"RL\"}};class tp{#A=[];baseModificationKeys=new Set;constructor(e,t,i,{samplingWindowSize:n,samplingDepth:r,alleleFreqThreshold:s,colorBy:o}){this.alleleFreqThreshold=void 0===s?.2:s,this.samplingWindowSize=n||100,this.samplingDepth=r||1e3,this.chr=e,this.start=Math.floor(t),this.end=Math.ceil(i),this.length=i-t,this.coverageMap=new np(e,t,i,this.alleleFreqThreshold),this.downsampledIntervals=[],o&&o.startsWith(\"basemod\")&&(this.baseModCounts=new Zf),this.alignments=[],this.pairsCache=new Map,this.downsampledReads=new Set,this.currentBucket=new ip(this.start,this.start+this.samplingWindowSize,this),this.hasPairs=!1}pack({viewAsPairs:e,showSoftClips:t,expectedPairOrientation:i,groupBy:n,displayMode:r}){let s=this.allAlignments();s=e?function(e){const t=new Map,i=e.map((e=>{if(ap(e)){let i=t.get(e.readName);return i?(i.setSecondAlignment(e),t.delete(e.readName),i):(i=new Qf(e),t.set(e.readName,i),i)}return e}));return i}(s):function(e){return e.flatMap((e=>e instanceof Qf?[e.firstAlignment,e.secondAlignment].filter(Boolean):[e]))}(s),this.packAlignmentRows(s,t,i,n,r),this.alignments&&delete this.alignments}packAlignmentRows(e,t,i,n,r){this.#A=[];const s=(e,i)=>{e.sort((function(e,i){return t?e.scStart-i.scStart:e.start-i.start}));const n=new op(i);let r,s=0,o=0;const a=new Set,c=()=>{r=new Jf,n.push(r),s=0,o=0,a.clear()};for(c();e.length>0;)if(o>=0&&o(t?e.scStart:e.start)>s),o)}else e=e.filter((e=>!a.has(e))),c();return n},o=(e,t)=>{e.sort((function(e,t){return e.start-t.start}));const i=new op(t),{start:n,end:r}=this.viewport.genomicRange();for(let t of e)if(t.endr)this.#A.push(t);else{const e=new Jf;e.alignments.push(t),i.push(e)}return i};if(!e||0===e.length)return new Map;{const t=new Map;if(n)for(let r of e){const e=lp(r,n,i)||\"\";t.has(e)||t.set(e,[]),t.get(e).push(r)}else t.set(\"\",e);const a=new Map,c=Array.from(t.keys()).sort(function(e,t){switch(e){case\"pairOrientation\":return function(e){const t=[\"LL\",\"RR\",\"RL\",\"LR\",\"\"];return(e,i)=>t.indexOf(e)-t.indexOf(i)}();case\"strand\":case\"firstOfPairStrand\":return up;default:return e&&e.startsWith(\"base:\")?dp:fp}}(n));for(let e of c){const i=t.get(e),n=\"FULL\"===r?o(i,e):s(i,e);a.set(e,n)}this.packedGroups=a}}push(e){this.hasPairs=this.hasPairs||e.isPaired(),this.coverageMap.incCounts(e);const t=e.getBaseModificationSets();if(t)for(let e of t)this.baseModificationKeys.add(e.key);this.baseModCounts&&this.baseModCounts.incrementCounts(e),this.downsampledReads.has(e.readName)?this.currentBucket.downsampledCount++:(e.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new ip(e.start,e.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(e))}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.hasAlignments=this.alignments.length>0,this.alignments.sort((function(e,t){return e.start-t.start})),this.baseModCounts&&this.baseModCounts.computeSimplex(),delete this.currentBucket,delete this.pairsCache,delete this.downsampledReads}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new sp(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount))}allAlignments(){if(this.alignments)return this.alignments;if(this.packedGroups){const e=Array.from(this.packedGroups.values()).flatMap((e=>e.rows.flatMap((e=>e.alignments))));if(this.#A&&this.#A.length>0)for(let t of this.#A)e.push(t);return e}return[]}getMax(e,t){return this.coverageMap.getMax(e,t)}sortRows(e){if(this.packedGroups)for(let t of this.packedGroups.values())t.sortRows(e,this)}}class ip{constructor(e,t,{samplingDepth:i,downsampledReads:n,pairsCache:r}){this.start=e,this.end=t,this.alignments=[],this.downsampledCount=0,this.samplingDepth=i,this.downsampledReads=n,this.pairsCache=r,this.hasPairs=!1}addAlignment(e){this.hasPairs=this.hasPairs||e.isPaired();const t=this.hasPairs?Math.ceil(this.samplingDepth/2):this.samplingDepth;if(ap(e)){const t=this.pairsCache.get(e.readName);if(t)return t.setSecondAlignment(e),void this.pairsCache.delete(e.readName)}if(this.alignments.lengtht)break;const s=this.coverage[r];n>=e&&s&&(i=Math.max(i,s.total))}return i}incCounts(e){var t=this;if(void 0===e.blocks?i(e):e.blocks.forEach((function(e){i(e)})),e.gaps)for(let i of e.gaps)if(\"D\"===i.type){const e=i.start-t.bpStart;for(let n=e;n=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.posA;case\"C\":case\"c\":return n.posC;case\"T\":case\"t\":return n.posT;case\"G\":case\"g\":return n.posG;case\"N\":case\"n\":return n.posN;default:return 0}}getNegCount(e,t){const i=e-this.bpStart;if(i<0||i>=this.coverage.length)return 0;const n=this.coverage[i];switch(t){case\"A\":case\"a\":return n.negA;case\"C\":case\"c\":return n.negC;case\"T\":case\"t\":return n.negT;case\"G\":case\"g\":return n.negG;case\"N\":case\"n\":return n.negN;default:return 0}}getCount(e,t){return this.getPosCount(e,t)+this.getNegCount(e,t)}getTotalCount(e){const t=e-this.bpStart;return t>=0&&t=t}}class sp{constructor(e,t,i){this.start=e,this.end=t,this.counts=i}popupData(e){return[{name:\"start\",value:Math.floor(this.start+1)},{name:\"end\",value:this.end},{name:\"# downsampled:\",value:this.counts}]}}class op{pixelTop=0;pixelBottom=0;rows=[];constructor(e){this.name=this.name}push(e){this.rows.push(e)}get length(){return this.rows.length}sortRows(e,t){const i=[],n=[];for(let t of this.rows){void 0!==t.findAlignment(e.position,e.sortAsPairs)?i.push(t):n.push(t)}i.sort(((i,n)=>{const r=e.direction,s=i.getSortValue(e,t),o=n.getSortValue(e,t);if(void 0===o&&void 0!==o)return 1;if(void 0!==s&&void 0===o)return-1;const a=s>o?1:s>1);t(e[i])?r=i:n=i}return r}function lp(e,t,i){let n,r,s;if(t.startsWith(\"tag:\"))n=t.substring(4),t=\"tag\";else if(t.startsWith(\"base:\")){const e=t.split(\":\");3===e.length&&(t=\"base\",r=e[1],s=Number.parseInt(e[2].replaceAll(\",\",\"\"))-1)}switch(t){case\"strand\":return e.strand?\"+\":\"-\";case\"firstOfPairStrand\":const t=e.firstOfPairStrand;return void 0===t?\"\":t?\"+\":\"-\";case\"mateChr\":return e.mate&&e.isMateMapped()?e.mate.chr:\"\";case\"pairOrientation\":return ep[i][e.pairOrientation]||\"\";case\"chimeric\":return e.tags().SA?\"chimeric\":\"\";case\"supplementary\":return e.isSupplementary?\"supplementary\":\"\";case\"readOrder\":return e.isPaired()&&e.isFirstOfPair()?\"first\":e.isPaired()&&e.isSecondOfPair()?\"second\":\"\";case\"phase\":return e.tags().HP||\"\";case\"tag\":return e.tags()[n]||\"\";case\"base\":if(e.chr===r&&e.start<=s&&e.end>s){const t=e.readBaseAt(s);return t||\"GAP\"}return\"\";default:return}}const hp=new Map([[\"A\",1],[\"T\",2],[\"C\",3],[\"G\",4],[\"N\",5],[\"GAP\",5],[\"\",7]]);function dp(e,t){return hp.has(e)&&hp.has(t)?hp.get(e)-hp.get(t):e.localeCompare(t,void 0,{sensitivity:\"base\"})}function up(e,t){return e===t?0:e&&t?-e.localeCompare(t):e?1:-1}function fp(e,t){if(e||t){if(e){if(t){if(e===t)return 0;if(Va(e)&&(Va(t),1))return Number.parseFloat(e)-Number.parseFloat(t);{let i=e.toString(),n=t.toString();return i.localeCompare(n,void 0,{sensitivity:\"base\"})}}return-1}return 1}return 0}class pp{constructor(e){const t=e.split(\",\");this.chr=t[0],this.start=parseInt(t[1]),this.strand=t[2].charAt(0),this.mapQ=parseInt(t[4]),this.numMismatches=parseInt(t[5]),this.lenOnRef=function(e){let t=0,i=\"\";for(let n=0;n47&&r<58)i+=e.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:t+=parseInt(i.toString())}i=\"\"}}return t}(t[3])}printString(){return this.chr+\":\"+Rt(this.start)+\"-\"+Rt(this.start+this.lenOnRef)+\" (\"+this.strand+\") = \"+Rt(this.lenOnRef)+\"bp @MAPQ: \"+this.mapQ+\" NM: \"+this.numMismatches}}function gp(e){return e.split(\";\").filter((e=>e.length>0)).map((e=>new pp(e)))}const mp={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class wp{constructor(){this.hidden=!1}isMapped(){return!(4&this.flags)}isPaired(){return!!(1&this.flags)}isProperPair(){return!!(2&this.flags)}isFirstOfPair(){return!!(64&this.flags)}isSecondOfPair(){return!!(128&this.flags)}isSecondary(){return!!(256&this.flags)}isSupplementary(){return!!(2048&this.flags)}isFailsVendorQualityCheck(){return!!(512&this.flags)}isDuplicate(){return!!(1024&this.flags)}isMateMapped(){return!(8&this.flags)}isNegativeStrand(){return!!(16&this.flags)}isMateNegativeStrand(){return!!(32&this.flags)}hasTag(e){const t=this.tagDict||function(e){let t=0;const i=e.length,n={};for(;t=i&&e<=i+n}popupData(e){const t=[];if(e=Math.floor(e),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(e===i||e===i-1)return t.push({name:\"Insertion\",value:n.substr(r.seqOffset,r.len)}),t.push({name:\"Location\",value:i}),t}}t.push({name:\"Read Name\",value:this.readName}),t.push(\"
\"),t.push({name:\"Alignment Start\",value:Rt(1+this.start),borderTop:!0}),t.push({name:\"Read Strand\",value:!0===this.strand?\"(+)\":\"(-)\",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const e=25;n=`${n.substring(0,e-2)} ... ${n.substring(n.length-e+2)}`}t.push({name:\"Cigar\",value:n}),t.push({name:\"Mapping Quality\",value:this.mq}),t.push({name:\"Secondary\",value:a(this.isSecondary())}),t.push({name:\"Supplementary\",value:a(this.isSupplementary())}),t.push({name:\"Duplicate\",value:a(this.isDuplicate())}),t.push({name:\"Failed QC\",value:a(this.isFailsVendorQualityCheck())}),this.isPaired()&&(t.push(\"
\"),t.push({name:\"First in Pair\",value:!this.isSecondOfPair(),borderTop:!0}),t.push({name:\"Mate is Mapped\",value:a(this.isMateMapped())}),this.pairOrientation&&t.push({name:\"Pair Orientation\",value:this.pairOrientation}),this.isMateMapped()&&(t.push({name:\"Mate Chromosome\",value:this.mate.chr}),t.push({name:\"Mate Start\",value:this.mate.position+1}),t.push({name:\"Mate Strand\",value:!0===this.mate.strand?\"(+)\":\"(-)\"}),t.push({name:\"Insert Size\",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty(\"SA\")){t.push(\"
\"),t.push({name:\"Supplementary Alignments\",value:\"\"});const e=gp(r.SA);if(e){t.push(\"
    \");for(let i of e)t.push(`
  • ${i.printString()}
  • `);t.push(\"
\")}}const s=new Set([\"SA\",\"MD\"]);t.push(\"
\");for(let e in r)s.has(e)||t.push({name:e,value:r[e]});t.push({name:\"Hidden Tags\",value:\"SA, MD\"}),t.push(\"
\"),t.push({name:\"Genomic Location: \",value:Rt(1+e)}),t.push({name:\"Read Base:\",value:this.readBaseAt(e)}),t.push({name:\"Base Quality:\",value:this.readBaseQualityAt(e)});const o=this.getBaseModificationSets();if(o){const i=this.positionToReadIndex(e);if(void 0!==i){let e=!1;for(let n of o)if(n.containsPosition(i)){e||(t.push(\"
\"),t.push(\"Base modifications:\"),e=!0);const r=Math.round(100/255*Xf(n.likelihoods.get(i)));t.push(`${n.fullName()} @ likelihood = ${r}%`)}}}return t;function a(e){return e?\"Yes\":\"No\"}}readBaseAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.seq)return\"*\";{const i=t.seqIndexAt(e);return this.seq[i]}}}readBaseQualityAt(e){const t=Fp(this.blocks,e);if(t){if(\"*\"===this.qual)return 30;{const i=t.seqIndexAt(e);return i>=0&&this.qual&&i=t.start&&e1)if(Yf(e))h.push(e);else for(let t=0;t=n.start&&t>1)+n;a+4=t)return!1;if(\"B\"!==String.fromCharCode(e[a+2])||\"I\"!==String.fromCharCode(e[a+3]))return!1;var l=Dp(e,a+4),h=a+8;if(h+4*l>t)return!1;var d=\"\",u=0;s.length=0,a=h;for(var f=0;f>4,m=Ep[15&p];\"M\"!==m&&\"EQ\"!==m&&\"X\"!==m&&\"D\"!==m&&\"N\"!==m&&\"=\"!==m||(u+=g),d=d+g+m,s.push({len:g,ltr:m})}return r.cigar=d,r.lengthOnRef=u,!0},decodeBamRecords:function(e,t,i,n,r,s,o,a){for(;te.length)return;if(p<0){t=u;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p>8,b=255&m,F=Dp(e,t+16),v=(4294901760&F)>>16,y=65535&F,A=Dp(e,t+20),C=Dp(e,t+24),_=Dp(e,t+28),x=Dp(e,t+32);let k=[];for(let i=0;i>4,h=Ep[15&c];\"M\"!==h&&\"EQ\"!==h&&\"X\"!==h&&\"D\"!==h&&\"N\"!==h&&\"=\"!==h||(I+=l),S=S+l+h,E+=4,B={len:l,ltr:h},N.push(B)}if(f.chr=n[p],f.start=g,f.flags=v,f.strand=!(16&v),f.readName=k,f.cigar=S,f.lengthOnRef=I,f.fragmentLength=x,f.mq=w,Mp.bam_tag2cigar(e,u,E,A,f,N),f.end=f.start+f.lengthOnRef,f.end>1;for(let t=0;t>4]),M.push(Sp[15&d])}M=M.slice(0,A).join(\"\"),E+=R;const D=[];for(let t=0;t=0&&(f.mate={chr:n[C],position:_,strand:!(32&v)}),f.seq=M,f.qual=D;const T=new Uint8Array(e.buffer.slice(E,u));f.tagDict=zp(T),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Rp(f,N),i.push(f)),t=u}},decodeSamRecords:function(e,t,i,n,r,s){var o,a,c,l,h,d,u,f,p,g;for(l=(o=Dt(e)).length,!1,a=0;ar)break;if(f=0,(g=Tp(p.cigar)).forEach((function(e){var t=e.len,i=e.ltr;\"M\"!==i&&\"EQ\"!==i&&\"X\"!==i&&\"D\"!==i&&\"N\"!==i&&\"=\"!==i||(f+=t)})),p.lengthOnRef=f,!(p.start+fBp&&(console.log(\"Warning: attempt to set sampling depth > maximum value of \"+Bp),e.samplingDepth=Bp)},setPairOrientation:function(e){if(e.isMapped()&&e.mate&&e.isMateMapped()&&e.mate.chr===e.chr){var t=e.strand?\"F\":\"R\",i=e.mate,n=i.strand?\"F\":\"R\",r=\" \",s=\" \";e.isFirstOfPair()?(r=\"1\",s=\"2\"):e.isSecondOfPair()&&(r=\"2\",s=\"1\");var o=[],a=e.fragmentLength,c=e.end-e.start;if(0===a)a=(e.start0?(o[0]=t,o[1]=r,o[2]=n,o[3]=s):(o[2]=t,o[3]=r,o[0]=n,o[1]=s),e.pairOrientation=o.join(\"\")}}};function Rp(e,t){const i=[];let n,r,s=0,o=e.start;e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef;for(let a of t){let t;switch(a.ltr){case\"H\":case\"P\":break;case\"S\":t=o,e.scLengthOnRef+=a.len,0===i.length&&(e.scStart-=a.len,t-=a.len),i.push(new xp({start:t,seqOffset:s,len:a.len,type:\"S\"})),s+=a.len;break;case\"N\":case\"D\":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case\"I\":void 0===n&&(n=[]),n.push(new xp({start:o,len:a.len,seqOffset:s,type:\"I\"})),s+=a.len;break;case\"M\":case\"EQ\":case\"=\":case\"X\":i.push(new xp({start:o,seqOffset:s,len:a.len,type:\"M\"})),s+=a.len,o+=a.len;break;default:console.log(\"Error processing cigar element: \"+a.len+a.ltr)}}e.blocks=i,e.insertions=n,e.gaps=r}function Dp(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Tp(e){var t,i,n,r,s,o,a,c,l;for(t=[],i=[],s=null,r=e.length,n=0;n=48&&l<=57?i.push(o):(a=o,c=Number.parseInt(i.join(\"\")),i=[],null!==s&&s.ltr===a?s.len+=c:(s={len:c,ltr:a},t.push(s)));return t}function Lp(e){var t={};return e.forEach((function(e){var i=e.split(\":\");t[i[0]]=i[2]})),t}function zp(e){let t=0;const i=e.length,n={},r=new DataView(e.buffer);for(;t=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>t.has(e)));e.length>0&&(n=e[0])}return this.chrAliasTable.set(e,n),n}return e}}class Pp{chrAliasTable=new Map;constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.baiPath=e.indexURL,Mp.setReaderDefaults(this,e),this._blockLoader=new yh(e)}async readAlignments(e,t,i){const n=await this.#x(e),r=new tp(e,t,i,this.config);if(void 0===n)return r;{const e=(await this.getIndex()).chunksForRange(n,t,i);if(!e||0===e.length)return r;for(let s of e){const e=await this._blockLoader.getData(s.minv,s.maxv);if(Mp.decodeBamRecords(e,s.minv.offset,r,this.header.chrNames,n,t,i,this.filter))break}return r.finish(),r}}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async getHeader(){if(!this.header){const e=this.genome,t=await this.getIndex();let i;if(t.firstBlockPosition){const e=Ua(this.config,{range:{start:t.firstBlockPosition,size:26}}),n=ms(await Qs.loadArrayBuffer(this.bamPath,e));i=t.firstBlockPosition+n}else i=64e3;const n=Ua(this.config,{range:{start:0,size:i}});this.header=await Mp.readHeader(this.bamPath,n,e)}return this.header}async getIndex(){return this.index||(this.index=await gh(this.baiPath,this.config)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const e=await this.getHeader();return this.chrToIndex=e.chrToIndex,this.indexToChr=e.chrNames,this.chrNames=new Set(e.chrNames),this.chrToIndex}}}class Op{constructor(e,t){this.config=e,this.genome=t;const i={};e.sources.sequences.forEach((function(n){const r=t?t.getChromosomeName(n):n;i[r]=function(e,t,i){const n={url:e.sources.url.replace(\"$CHR\",i)};e.sources.indexURL&&(n.indexURL=e.sources.indexURL.replace(\"$CHR\",i));const r=Object.assign(e,n);return new Pp(r,t)}(e,t,n)})),this.bamReaders=i,Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.bamReaders.hasOwnProperty(e)){let n=this.bamReaders[e];return await n.readAlignments(e,t,i)}return new tp(e,t,i,this.config)}}const Up=function(e,t){this.config=e,this.genome=t,Mp.setReaderDefaults(this,e)};function qp(){const e=this,t=this.genome;if(this.header)return Promise.resolve(this.header);{const i=this.config.url+\"?file=\"+this.config.alignmentFile+\"&options=-b,-H\",n=Ua(this.config);return Mp.readHeader(i,n,t).then((function(t){return e.header=t,t}))}}Up.prototype.readAlignments=function(e,t,i){var n=this;return qp.call(n).then((function(r){var s,o;return s=r.chrAliasTable.hasOwnProperty(e)?r.chrAliasTable[e]:e,o=n.config.url+\"?reference=\"+n.config.referenceFile+\"&file=\"+n.config.alignmentFile+\"®ion=\"+s+\":\"+t+\"-\"+i,Qs.loadString(o,Ua(n.config)).then((function(o){var a;return r.chrToIndex[s],a=new tp(e,t,i,n.config),Mp.decodeSamRecords(o,a,s,t,i,n.filter),a}))}))};class Qp extends Rh{constructor(e,t){super(e,t),Mp.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(!this.header){const e=gs((await this.readHeaderData()).buffer);this.header=Mp.decodeBamHeader(e,this.genome),this.chrAliasTable=new Map;for(let e of this.header.chrNames)this.chrAliasTable.set(e,this.genome.getChromosomeName(e))}let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=gs((await this.readData(n,t,i)).buffer);this.header=Mp.decodeBamHeader(r,this.genome);const s=this.header.chrToIndex[e],o=new tp(e,t,i,this.config);return Mp.decodeBamRecords(r,this.header.size,o,this.header.chrNames,s,t,i,this.filter),o.finish(),o}}\n", - "/*! For license information please see cram-bundle.js.LICENSE.txt */for(var Vp=(()=>{var e={4923:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(8712),s=i(5931),o=i(9747);function a(e,t){const[i,n,r,s,o,a]=t,c=i;e[c]||(e[c]=[]),e[c].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}t.default=class{constructor(e){this.filehandle=(0,s.open)(e.url,e.path,e.filehandle)}parseIndex(){return n(this,void 0,void 0,(function*(){const e={},t=31===(i=yield this.filehandle.readFile())[0]&&139===i[1]?(0,r.unzip)(i):i;var i;if(t.length>4&&21578050===t.readUInt32LE(0))throw new o.CramMalformedError(\"invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support\");let n=[],s=\"\";for(const i of t)if(i>=48&&i<=57||!s&&45===i)s+=String.fromCharCode(i);else if(9===i)n.push(Number.parseInt(s,10)),s=\"\";else if(10===i)n.push(Number.parseInt(s,10)),s=\"\",a(e,n),n=[];else if(13!==i&&32!==i)throw new o.CramMalformedError(\"invalid .crai index file\");return s&&n.push(Number.parseInt(s,10)),6===n.length&&a(e,n),Object.entries(e).forEach((([t,i])=>{const n=i;e[t]=n.sort(((e,t)=>e.start-t.start||e.span-t.span))})),e}))}getIndex(){return this.parseIndexP||(this.parseIndexP=this.parseIndex().catch((e=>{throw this.parseIndexP=void 0,e}))),this.parseIndexP}hasDataForReferenceSequence(e){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[e]}))}getEntriesForRange(e,t,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[e];if(!n)return[];const r=e=>{const n=e.start,r=e.start+e.span;return n>i?-1:r<=t?1:0},s=[];for(const e of n)0===r(e)&&s.push(e);return s}))}}},9508:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=class{constructor(e,t){this.parameters=e,this.dataType=t}}},368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(e,t,i,n){return(0,o.getBits)(t.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}t.default=a},8635:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(9508)),s=i(400);class o extends r.default{constructor(e,t,i){super(e,t),this.instantiateCodec=i}decode(e,t,i,n){const r=this._getLengthCodec().decode(e,t,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a{(0,s.tinyMemoize)(o,e)}))},4839:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(e,t){const i=e.content,{stopByte:n}=this.parameters,r=t.bytePosition;let s=t.bytePosition;for(;i[s]!==n&&s=e.content.length)throw new a.CramBufferOverrunError(\"attempted to read beyond end of block. this file seems truncated.\");return e.content[t.bytePosition++]}}t.default=c},8185:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),\"int\"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(e,t,i,n){let r=1;for(;0===(0,o.getBits)(t.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(t.content,n.coreBlock,r-1)|1<{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramBufferOverrunError=void 0,t.getBits=function(e,t,n){let r=0;if(t.bytePosition+(7-t.bitPosition+n)/8>e.length)throw new i(\"read error during decoding. the file seems to be truncated.\");for(let i=n;i;i--)r<<=1,r|=e[t.bytePosition]>>t.bitPosition&1,t.bitPosition-=1,t.bitPosition<0&&(t.bytePosition+=1),t.bitPosition&=7;return r};class i extends Error{}t.CramBufferOverrunError=i},4341:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=i(9747),s=n(i(9508)),o=i(612);class a extends s.default{constructor(e,t){if(super(e,t),this.codes={},this.codeBook={},this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],![\"byte\",\"int\"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let e=new Array(this.parameters.numCodes);for(let t=0;te.bitLength-t.bitLength||e.symbol-t.symbol)),this.codeBook={},e.forEach((e=>{this.codeBook[e.bitLength]||(this.codeBook[e.bitLength]=[]),this.codeBook[e.bitLength].push(e.symbol)}))}buildCodes(){this.codes={};let e=0,t=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=Number.parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};t+=1;const o=s-e;if(t<<=o,n.bitCode=t,e+=o,function(e){let t=e-(e>>1)&1431655765;return t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}(t)>s)throw new r.CramMalformedError(\"Symbol out of range\");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((e,t)=>e.bitLength-t.bitLength||e.bitCode-t.bitCode)),this.sortedValuesByBitCode=this.sortedCodes.map((e=>e.value)),this.sortedBitCodes=this.sortedCodes.map((e=>e.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((e=>e.bitLength));const e=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(e+1).fill(-1);for(let e=0;e-1&&this.sortedBitLengthsByBitCode[i]===t)return this.sortedValuesByBitCode[i];for(let i=e;this.sortedCodes[i+1].bitLength===t&&i{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:\"MIDNSHP:XB\",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},7219:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(6524),r=i(9747),s={BF:\"int\",CF:\"int\",RI:\"int\",RL:\"int\",AP:\"int\",RG:\"int\",MF:\"int\",NS:\"int\",NP:\"int\",TS:\"int\",NF:\"int\",TC:\"byte\",TN:\"int\",FN:\"int\",FC:\"byte\",FP:\"int\",BS:\"byte\",IN:\"byteArray\",SC:\"byteArray\",DL:\"int\",BA:\"byte\",BB:\"byteArray\",RS:\"int\",PD:\"int\",HC:\"int\",MQ:\"int\",RN:\"byteArray\",QS:\"byte\",QQ:\"byteArray\",TL:\"int\"};t.default=class{constructor(e){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(e){const t=new Array(5);for(let e=0;e<5;e+=1)t[e]=new Array(4);return t[0][e[0]>>6&3]=\"C\",t[0][e[0]>>4&3]=\"G\",t[0][e[0]>>2&3]=\"T\",t[0][3&e[0]]=\"N\",t[1][e[1]>>6&3]=\"A\",t[1][e[1]>>4&3]=\"G\",t[1][e[1]>>2&3]=\"T\",t[1][3&e[1]]=\"N\",t[2][e[2]>>6&3]=\"A\",t[2][e[2]>>4&3]=\"C\",t[2][e[2]>>2&3]=\"T\",t[2][3&e[2]]=\"N\",t[3][e[3]>>6&3]=\"A\",t[3][e[3]>>4&3]=\"C\",t[3][e[3]>>2&3]=\"G\",t[3][3&e[3]]=\"N\",t[4][e[4]>>6&3]=\"A\",t[4][e[4]>>4&3]=\"C\",t[4][e[4]>>2&3]=\"G\",t[4][3&e[4]]=\"T\",t}(e.preservation.SM),this.dataSeriesEncoding=e.dataSeriesEncoding,this.tagEncoding=e.tagEncoding}getCodecForTag(e){const t=this.tagCodecCache[e];if(t)return t;{const t=this.tagEncoding[e];if(!t)throw new Error(\"Error, no tag encoding\");const i=(0,n.instantiateCodec)(t,\"byteArray\");return this.tagCodecCache[e]=i,i}}getTagNames(e){return this.tagIdsDictionary[e]}getCodecForDataSeries(e){let t=this.dataSeriesCodecCache[e];if(void 0===t){const i=this.dataSeriesEncoding[e];if(i){const o=s[e];if(!o)throw new r.CramMalformedError(`data series name ${e} not defined in file compression header`);t=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[e]=t}}return t}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.endsWith(\"Cache\")||(e[t]=this[t])})),e}}},78:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=i(9747),a=i(400),c=r(i(6771)),l=r(i(7219)),h=i(3165);class d{constructor(e,t){this.file=e,this.filePosition=t}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(!(null==e?void 0:e.numRecords))return null;const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),n=yield this.getFirstBlock();if(void 0===n)return;if(\"COMPRESSION_HEADER\"!==n.contentType)throw new o.CramMalformedError(`invalid content type ${n.contentType} in compression header block`);const r=(0,a.parseItem)(n.content,i.cramCompressionHeader.parser,0,n.contentPosition);return Object.assign(Object.assign({},n),{parsedContent:r})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();if(e)return this.file.readBlock(e._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const e=yield this.getCompressionHeaderBlock();if(e)return new l.default(e.parsedContent)}))}getSlice(e,t){return new c.default(this,e,t)}_readContainerHeader(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.file.getDefinition(),i=(0,h.getSectionParsers)(t),{cramContainerHeader1:n,cramContainerHeader2:r}=i,{size:o}=yield this.file.stat();if(e>=o)return void console.warn(`pos:${e}>=fileSize:${o} in cram container`);const c=s.Buffer.allocUnsafe(n.maxLength);yield this.file.read(c,0,n.maxLength,e);const l=(0,a.parseItem)(c,n.parser),d=(0,a.itf8Size)(l.numLandmarks);if(e+l.length>=o)return void console.warn(`container at ${e} is beyond fileSize:${o}, skipping`);const u=s.Buffer.allocUnsafe(r.maxLength(l.numLandmarks));yield this.file.read(u,0,r.maxLength(l.numLandmarks),e+l._size-d);const f=(0,a.parseItem)(u,r.parser);return this.file.validateChecksums&&void 0!==f.crc32&&(yield this.file.checkCrc32(e,l._size+f._size-d-4,f.crc32,`container header beginning at position ${e}`)),Object.assign(l,f,{_size:l._size+f._size-d,_endPosition:l._size+f._size-d+e})}))}}t.default=d,\"getHeader getCompressionHeaderBlock getCompressionScheme\".split(\" \").forEach((e=>{(0,a.tinyMemoize)(d,e)}))},6794:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(8287),o=r(i(928)),a=r(i(7392)),c=r(i(6960)),l=r(i(235)),h=i(1307),d=i(9747),u=i(8712),f=r(i(9989)),p=i(3165),g=r(i(78)),m=i(5931),w=i(400),b=i(5417);class F{constructor(e){var t;if(this.file=(0,m.open)(e.url,e.path,e.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=e.seqFetch,this.options={checkSequenceMD5:e.checkSequenceMD5,cacheSize:null!==(t=e.cacheSize)&&void 0!==t?t:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const e=new Uint32Array([287454020]),t=new Uint8Array(e.buffer);return 68===t[0]?0:17===t[0]?1:2}()>0)throw new Error(\"Detected big-endian machine, may be unable to run\")}read(e,t,i,n){return this.file.read(e,t,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const{maxLength:e,parser:t}=(0,p.cramFileDefinition)(),i=s.Buffer.allocUnsafe(e);yield this.file.read(i,0,e,0);const n=t(i).value;if(2!==n.majorVersion&&3!==n.majorVersion)throw new d.CramUnimplementedError(`CRAM version ${n.majorVersion} not supported`);return n}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.getContainerById(0);if(!e)throw new d.CramMalformedError(\"file contains no containers\");const t=yield e.getFirstBlock();if(void 0===t)return(0,b.parseHeaderText)(\"\");const i=t.content,n=i.readInt32LE(0),r=i.toString(\"utf8\",4,4+n);return this.header=r,(0,b.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getContainerById(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t);let n=i.cramFileDefinition.maxLength;const{size:r}=yield this.file.stat(),{cramContainerHeader1:s}=i;let o;for(let t=0;t<=e;t++){if(n+s.maxLength+8>=r)return;o=this.getContainerAtPosition(n);const i=yield o.getHeader();if(!i)throw new d.CramMalformedError(`container ${e} not found in file`);if(0===t){n=i._endPosition;for(let e=0;e=r)return;const o=s.Buffer.allocUnsafe(n.maxLength);return yield this.file.read(o,0,n.maxLength,e),(0,w.parseItem)(o,n.parser,0,e)}))}_parseSection(e,t){return n(this,arguments,void 0,(function*(e,t,i=e.maxLength,n){let r;if(n)r=n;else{const{size:e}=yield this.file.stat();if(t+i>=e)return;r=s.Buffer.allocUnsafe(i),yield this.file.read(r,0,i,t)}const o=(0,w.parseItem)(r,e.parser,0,t);if(o._size!==i)throw new d.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${o._size}`);return o}))}_uncompress(e,t,i){return n(this,void 0,void 0,(function*(){if(\"gzip\"===e)(0,u.unzip)(t).copy(i);else if(\"bzip2\"===e){const e=l.default.array(t);let n,r=l.default.header(e),o=0;do{n=l.default.decompress(e,r),-1!==n&&(s.Buffer.from(n).copy(i,o),o+=n.length,r-=n.length)}while(-1!==n)}else if(\"lzma\"===e){const e=new Response(new h.XzReadableStream((n=t,new ReadableStream({start(e){e.enqueue(n),e.close()}}))));s.Buffer.from(yield e.arrayBuffer()).copy(i)}else if(\"rans\"===e)(0,f.default)(t,i);else if(\"rans4x16\"===e)c.default.r4x16_uncompress(t,i);else if(\"arith\"===e)c.default.arith_uncompress(t,i);else if(\"fqzcomp\"===e)c.default.fqzcomp_uncompress(t,i);else{if(\"tok3\"!==e)throw new d.CramUnimplementedError(`${e} decompression not yet implemented`);c.default.tok3_uncompress(t,i)}var n}))}readBlock(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=(0,p.getSectionParsers)(t),n=yield this.readBlockHeader(e);if(void 0===n)return;const r=n._endPosition,o=s.Buffer.allocUnsafe(n.uncompressedSize),a=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:o});if(\"raw\"!==n.compressionMethod){const e=s.Buffer.allocUnsafe(n.compressedSize);yield this.read(e,0,n.compressedSize,r),yield this._uncompress(n.compressionMethod,e,o)}else yield this.read(o,0,n.uncompressedSize,r);if(t>=3){const t=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===t)return;a.crc32=t.crc32,this.validateChecksums&&(yield this.checkCrc32(e,n._size+n.compressedSize,t.crc32,\"block data\")),a._endPosition=t._endPosition,a._size=a.compressedSize+i.cramBlockCrc32.maxLength}else a._endPosition=r+a.compressedSize,a._size=a.compressedSize;return a}))}}t.default=F,\"getDefinition getSectionParsers getSamHeader\".split(\" \").forEach((e=>{(0,w.tinyMemoize)(F,e)}))},7390:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=t.CramRecord=void 0;var r=i(8401);Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return n(r).default}});var s=i(6794);Object.defineProperty(t,\"default\",{enumerable:!0,get:function(){return n(s).default}})},8401:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.MateFlagsDecoder=t.CramFlagsDecoder=t.BamFlagsDecoder=t.MateFlags=t.CramFlags=t.BamFlags=void 0;const r=n(i(7295)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(e){const t={};for(const[i,n]of e)t[`is${n}`]=e=>!!(e&i),t[`set${n}`]=e=>e|i;return t}t.BamFlags=[[1,\"Paired\"],[2,\"ProperlyPaired\"],[4,\"SegmentUnmapped\"],[8,\"MateUnmapped\"],[16,\"ReverseComplemented\"],[32,\"MateReverseComplemented\"],[64,\"Read1\"],[128,\"Read2\"],[256,\"Secondary\"],[512,\"FailedQc\"],[1024,\"Duplicate\"],[2048,\"Supplementary\"]],t.CramFlags=[[1,\"PreservingQualityScores\"],[2,\"Detached\"],[4,\"WithMateDownstream\"],[8,\"DecodeSequenceAsStar\"]],t.MateFlags=[[1,\"OnNegativeStrand\"],[2,\"Unmapped\"]],t.BamFlagsDecoder=o(t.BamFlags),t.CramFlagsDecoder=o(t.CramFlags),t.MateFlagsDecoder=o(t.MateFlags),t.default=class{constructor({flags:e,cramFlags:t,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:c,mateToUse:l,readGroupId:h,readName:d,sequenceId:u,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=e,this.cramFlags=t,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=h,this.readName=d,this.sequenceId=u,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,c&&(this.readFeatures=c),l&&(this.mate={flags:l.mateFlags,readName:l.mateReadName,sequenceId:l.mateSequenceId,alignmentStart:l.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const e=function(e,t){if(!e.lengthOnRef&&!e.readLength)return null;if(e.isUnknownBases())return null;const i=e.alignmentStart-t.start;if(!e.readFeatures)return t.seq.slice(i,i+(e.lengthOnRef||0)).toUpperCase();let n=\"\",r=i,s=0;for(;n.lengththis.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=e,r[1]=i,r[2]=t,r[3]=n):(r[2]=e,r[3]=i,r[0]=t,r[1]=n),r.join(\"\")}return null}addReferenceSequence(e,t){this.readFeatures&&this.readFeatures.forEach((i=>{\"X\"===i.code&&function(e,t,i,n){const r=n.refPos-t.start,o=t.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const c=i.substitutionMatrix[a][n.data];c&&(n.sub=c)}(0,e,t,i)})),!this.readBases&&e.start<=this.alignmentStart&&e.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=e)}toJSON(){const e={};return Object.keys(this).forEach((t=>{t.startsWith(\"_\")||(e[t]=this[t])})),e.readBases=this.getReadBases(),e}}},3165:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.cramFileDefinition=r,t.cramBlockHeader=s,t.cramBlockCrc32=o,t.cramTagDictionary=c,t.cramPreservationMap=l,t.isMappedSliceHeader=function(e){return\"number\"==typeof e.refSeqId},t.getSectionParsers=function(e){return{cramFileDefinition:r(),cramBlockHeader:s(),cramBlockCrc32:o(),cramDataSeriesEncodingMap:p(),cramTagEncodingMap:g(),cramCompressionHeader:{parser:(e,t)=>{const{value:i,offset:n}=l().parser(e,t);t=n;const{value:r,offset:s}=p().parser(e,t);t=s;const{value:o,offset:a}=g().parser(e,t);return t=a,{value:{dataSeriesEncoding:h(r),preservation:h(i),tagEncoding:h(o)},offset:t}}},cramEncoding:{parser:(e,t)=>f(e,t)},cramUnmappedSliceHeader:d(e),cramMappedSliceHeader:u(e),cramContainerHeader1:m(e),cramContainerHeader2:w(e)}};const n=i(400);function r(){return{parser:(e,t=0)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length);let r=0;const s=e.subarray(r,r+4).toString();r+=4;const o=n.getUint8(r);r+=1;const a=n.getUint8(r);r+=1;const c=i.subarray(r,r+20).toString().replaceAll(\"\\0\",\"\");return r+=20,{value:{magic:s,majorVersion:o,minorVersion:a,fileId:c},offset:r}},maxLength:26}}function s(){return{parser:(e,t=0)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length);let s=0;const o=r.getUint8(s),a=[\"raw\",\"gzip\",\"bzip2\",\"lzma\",\"rans\",\"rans4x16\",\"arith\",\"fqzcomp\",\"tok3\"][o];if(!a)throw new Error(`compression method number ${o} not implemented`);s+=1;const c=r.getUint8(s),l=[\"FILE_HEADER\",\"COMPRESSION_HEADER\",\"MAPPED_SLICE_HEADER\",\"UNMAPPED_SLICE_HEADER\",\"EXTERNAL_DATA\",\"CORE_DATA\"][c];if(!l)throw new Error(`invalid block content type id ${c}`);s+=1;const[h,d]=(0,n.parseItf8)(e,s);s+=d;const[u,f]=(0,n.parseItf8)(e,s);s+=f;const[p,g]=(0,n.parseItf8)(e,s);return s+=g,{offset:s,value:{uncompressedSize:p,compressedSize:u,contentId:h,contentType:l,compressionMethod:a}}},maxLength:17}}function o(){return{parser:(e,t)=>{const i=e,n=new DataView(i.buffer,i.byteOffset,i.length).getUint32(t,!0);return{offset:t+=4,value:{crc32:n}}},maxLength:4}}function a(e,t,i){const n=e.toString(\"utf8\",t,i),r=[];for(let e=0;e{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const s=e.subarray(t,t+i);t+=i;const o=[];let c=0,l=0;for(;lc&&o.push(a(s,c,l)),{value:{size:i,ents:o},offset:t}}}}function l(){return{parser:(e,t)=>{const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,l]=(0,n.parseItf8)(e,t);t+=l;const h=[];for(let i=0;i{const[r,s]=(0,n.parseItf8)(t,i);i+=s;let o=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,o=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,o=e}else console.warn(\"recordCounter=0\");const[a,c]=(0,n.parseItf8)(t,i);i+=c;const[l,h]=(0,n.parseItf8)(t,i);i+=h;const d=[];for(let e=0;e=2&&(u=[...t.subarray(i,i+16)],i+=16),{value:{recordCounter:o,md5:u,contentIds:d,numContentIds:l,numBlocks:a,numRecords:r},offset:i}},maxLength:e=>40+5*e}}function u(e){return{parser:(t,i)=>{const[r,s]=(0,n.parseItf8)(t,i);i+=s;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;let u=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);i+=r,u=e}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);i+=r,u=e}else console.warn(\"majorVersion is <2, recordCounter set to 0\");const[f,p]=(0,n.parseItf8)(t,i);i+=p;const[g,m]=(0,n.parseItf8)(t,i);i+=m;const w=[];for(let e=0;e=2&&(v=[...t.subarray(i,i+16)],i+=16),{value:{md5:v,numBlocks:f,numRecords:h,numContentIds:g,refSeqSpan:c,refSeqId:r,refSeqStart:o,recordCounter:u,refBaseBlockId:b,contentIds:w},offset:i}},maxLength:e=>60+5*e}}function f(e,t){const i=e,r=new DataView(i.buffer,i.byteOffset,i.length),[s,o]=(0,n.parseItf8)(e,t);t+=o;const[a,c]=(0,n.parseItf8)(e,t);t+=c;const l={};if(0===s);else if(1===s){const[i,r]=(0,n.parseItf8)(e,t);l.blockContentId=i,t+=r}else if(2===s){const[i,r]=(0,n.parseItf8)(e,t);l.offset=i,t+=r;const[s,o]=(0,n.parseItf8)(e,t);l.M=s,t+=o}else if(3===s){const i=(0,n.parseItf8)(e,t),r=i[0];t+=i[1];const s=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i{const[i,r]=(0,n.parseItf8)(e,t);t+=r;const[s,o]=(0,n.parseItf8)(e,t);t+=o;const a=[];for(let i=0;i>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(255&i),{value:o,offset:c}=f(e,t);t=c,a.push({key:s,value:o})}return{value:{mapSize:i,ents:a,mapCount:s},offset:t}}}}function m(e){return{maxLength:52,parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length).getInt32(i,!0);i+=4;const[o,a]=(0,n.parseItf8)(t,i);i+=a;const[c,l]=(0,n.parseItf8)(t,i);i+=l;const[h,d]=(0,n.parseItf8)(t,i);i+=d;const[u,f]=(0,n.parseItf8)(t,i);i+=f;let p,g=0;if(e>=3){const[e,r]=(0,n.parseLtf8)(t,i);g=e,i+=r}else if(2===e){const[e,r]=(0,n.parseItf8)(t,i);g=e,i+=r}else console.warn(\"setting recordCounter=0\");if(e>1){const[e,r]=(0,n.parseLtf8)(t,i);p=e,i+=r}const[m,w]=(0,n.parseItf8)(t,i);i+=w;const[b,F]=(0,n.parseItf8)(t,i);return{value:{length:s,refSeqId:o,refSeqStart:c,alignmentSpan:h,numBlocks:m,numLandmarks:b,numBases:p,recordCounter:g,numRecords:u},offset:i+=F}}}}function w(e){return{parser:(t,i)=>{const r=t,s=new DataView(r.buffer,r.byteOffset,r.length),[o,a]=(0,n.parseItf8)(t,i);i+=a;const c=[];for(let e=0;e=3&&(l=s.getUint32(i,!0),i+=4),{value:Object.assign(Object.assign({},void 0===l?{}:{crc32:l}),{numLandmarks:o,landmarks:c}),offset:i}},maxLength:e=>5+5*e+4}}},6484:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,c,l,h,d,u,f){let p=t(\"BF\");const g=t(\"CF\");if(!(0,s.isMappedSliceHeader)(c.parsedContent))throw new Error(\"slice header not mapped\");const m=u>1&&-2===c.parsedContent.refSeqId?t(\"RI\"):c.parsedContent.refSeqId,w=t(\"RL\");let b=t(\"AP\");i.APdelta&&(b+=d.lastAlignmentStart),d.lastAlignmentStart=b;const F=t(\"RG\");let v,y,A,C;if(i.readNamesIncluded&&(v=o(t(\"RN\"))),r.CramFlagsDecoder.isDetached(g)){const e=t(\"MF\");let n;i.readNamesIncluded||(n=o(t(\"RN\")),v=n);const s=t(\"NS\"),a=t(\"NP\");(e||s>-1)&&(y={mateFlags:e,mateSequenceId:s,mateAlignmentStart:a,mateReadName:n}),A=t(\"TS\"),r.MateFlagsDecoder.isUnmapped(e)&&(p=r.BamFlagsDecoder.setMateUnmapped(p)),r.MateFlagsDecoder.isOnNegativeStrand(e)&&(p=r.BamFlagsDecoder.setMateReverseComplemented(p))}else r.CramFlagsDecoder.isWithMateDownstream(g)&&(C=t(\"NF\")+f+1);const _=t(\"TL\");if(_<0)throw new n.CramMalformedError(\"invalid TL index\");const x={},k=i.getTagNames(_),I=k.length;for(let t=0;t1?\"SC\":\"IN\"],X:[\"number\",\"BS\"],D:[\"number\",\"DL\"],I:[\"string\",\"IN\"],i:[\"character\",\"BA\"],b:[\"string\",\"BB\"],q:[\"numArray\",\"QQ\"],Q:[\"number\",\"QS\"],H:[\"number\",\"HC\"],P:[\"number\",\"PD\"],N:[\"number\",\"RS\"]}[t];if(!h)throw new n.CramMalformedError(`invalid read feature code \"${t}\"`);let d=l(h);const u={B:[\"number\",\"QS\"]}[t];u&&(d=[d,l(u)]),o+=r;const f=o;a+=r;const p=a;\"D\"===t||\"N\"===t?a+=d:\"I\"===t||\"S\"===t?a-=d.length:\"i\"===t&&(a-=1),c[e]={code:t,pos:f,refPos:p,data:d}}return c}(b,e,t,0,u)),E=w,S)for(const{code:e,data:t}of S)\"D\"===e||\"N\"===e?E+=t:\"I\"===e||\"S\"===e?E-=t.length:\"i\"===e&&(E-=1);if(Number.isNaN(E)&&(console.warn(`${v||`${m}:${b}`} record has invalid read features`),E=w),N=t(\"MQ\"),r.CramFlagsDecoder.isPreservingQualityScores(g)){B=new Array(w);for(let e=0;e=0){const r=e[i.mateRecordNumber];if(!r)throw new s.CramMalformedError(\"intra-slice mate record not found, this file seems malformed\");n.push(...t(r))}return n}(i),r=n.map((e=>e.alignmentStart)),o=n.map((e=>e.alignmentStart+e.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((e=>{if(void 0!==e.templateLength)throw new s.CramMalformedError(\"mate pair group has some members that have template lengths already, this file seems malformed\");e.templateLength=a}))}(e,0,i):function(e,t){const i=Math.min(e.alignmentStart,t.alignmentStart),n=Math.max(e.alignmentStart+e.readLength-1,t.alignmentStart+t.readLength-1)-i+1;e.templateLength=n,t.templateLength=n}(i,n)),i.mateRecordNumber=void 0}class f{constructor(e,t,i){this.container=e,this.containerPosition=t,this.sliceSize=i,this.file=e.file}getHeader(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.file.getDefinition(),t=(0,h.getSectionParsers)(e),i=yield this.container.getHeader();if(!i)throw new Error(\"no container header detected\");const n=yield this.file.readBlock(i._endPosition+this.containerPosition);if(void 0===n)throw new Error(\"block header undefined\");if(\"MAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramMappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}if(\"UNMAPPED_SLICE_HEADER\"===n.contentType){const e=(0,o.parseItem)(n.content,t.cramUnmappedSliceHeader.parser,0,i._endPosition);return Object.assign(Object.assign({},n),{parsedContent:e})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${n.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();let t=e._endPosition;const i=new Array(e.parsedContent.numBlocks);for(let e=0;e{\"EXTERNAL_DATA\"===e.contentType&&(t[e.contentId]=e)})),t}))}getBlockByContentId(e){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[e]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const e=(yield this.getHeader()).parsedContent;if(!(0,h.isMappedSliceHeader)(e))throw new Error(\"slice header not mapped\");if(e.refSeqId<0)return;const t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error(\"compression scheme undefined\");if(e.refBaseBlockId>=0){const t=yield this.getBlockByContentId(e.refBaseBlockId);if(!t)throw new s.CramMalformedError(\"embedded reference specified, but reference block does not exist\");return{seq:t.data.toString(\"utf8\"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}if(t.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error(\"reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence\");const t=yield this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);if(t.length!==e.refSeqSpan)throw new s.CramArgumentError(\"seqFetch callback returned a reference sequence of the wrong length\");return{seq:t,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){var e,t;const{majorVersion:i}=yield this.file.getDefinition(),n=yield this.container.getCompressionScheme();if(void 0===n)throw new Error(\"compression scheme undefined\");const r=yield this.getHeader(),a=yield this._getBlocksContentIdIndex();if(i>1&&this.file.options.checkSequenceMD5&&(0,h.isMappedSliceHeader)(r.parsedContent)&&r.parsedContent.refSeqId>=0&&\"0000000000000000\"!==(null===(e=r.parsedContent.md5)||void 0===e?void 0:e.join(\"\"))){const e=yield this.getReferenceRegion();if(e){const{seq:i,start:n,end:a}=e,c=(0,o.sequenceMD5)(i),l=null===(t=r.parsedContent.md5)||void 0===t?void 0:t.map((e=>(e<16?\"0\":\"\")+e.toString(16))).join(\"\");if(c!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${r.parsedContent.refSeqId} pos ${n}..${a}. recorded MD5: ${l}, calculated MD5: ${c}`)}}const f=yield this.getCoreDataBlock(),p={lastAlignmentStart:(0,h.isMappedSliceHeader)(r.parsedContent)?r.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(e){let t=this.map.get(e);return void 0===t&&(t={bitPosition:7,bytePosition:0},this.map.set(e,t)),t}}},g=e=>{const t=n.getCodecForDataSeries(e);if(!t)throw new s.CramMalformedError(`no codec defined for ${e} data series`);return t.decode(this,f,a,p)},m=new Array(r.parsedContent.numRecords);for(let t=0;t=0&&u(m,e,m[e],m[t])}return m}))}getRecords(e){return n(this,void 0,void 0,(function*(){const t=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(t.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(t.toString(),i));const r=(yield i).filter(e);if(r.length&&this.file.fetchReferenceSequenceCallback){const e=yield this.getHeader();if((0,h.isMappedSliceHeader)(e.parsedContent)&&(e.parsedContent.refSeqId>=0||-2===e.parsedContent.refSeqId)){const t=e.parsedContent.refSeqId>=0?e.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error(\"compression scheme undefined\");const s={};for(const e of r){const i=void 0!==t?t:e.sequenceId;let n=s[i];n||(n={id:i,start:e.alignmentStart,end:Number.NEGATIVE_INFINITY,seq:null},s[i]=n);const r=e.alignmentStart+(e.lengthOnRef||e.readLength)-1;r>n.end&&(n.end=r),e.alignmentStartn(this,void 0,void 0,(function*(){-1!==e.id&&e.start<=e.end&&this.file.fetchReferenceSequenceCallback&&(e.seq=yield this.file.fetchReferenceSequenceCallback(e.id,e.start,e.end))})))));for(const e of r){const n=s[void 0!==t?t:e.sequenceId];if(null==n?void 0:n.seq){const t=n.seq;e.addReferenceSequence(Object.assign(Object.assign({},n),{seq:t}),i)}}}}return r}))}}t.default=f,\"getHeader getBlocks _getBlocksContentIdIndex\".split(\" \").forEach((e=>{(0,o.tinyMemoize)(f,e)}))},400:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.itf8Size=function(e){return-128&e?-16384&e?-2097152&e?-268435456&e?5:4:3:2:1},t.parseItf8=function(e,t){let i=t;const n=e[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|e[i+1]),i+=2):n<224?(r=2097151&(n<<16|e[i+1]<<8|e[i+2]),i+=3):n<240?(r=268435455&(n<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4):(r=(15&n)<<28|e[i+1]<<20|e[i+2]<<12|e[i+3]<<4|15&e[i+4],i+=5),i>e.length)throw new o.CramBufferOverrunError(\"Attempted to read beyond end of buffer; this file seems truncated.\");return[r,i-t]},t.parseLtf8=function(e,t){let i=t;const n=e[i];let r;if(n<128)r=n,i+=1;else if(n<192)r=16383&(e[i]<<8|e[i+1]),i+=2;else if(n<224)r=2097151&(e[i]<<16|e[i+1]<<8|e[i+2]),r=(63&n)<<16|e.readUInt16LE(i+1),i+=3;else if(n<240)r=268435455&(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4;else if(n<248)r=(15&e[i])*Math.pow(2,32)+(e[i+1]<<24)|e[i+2]<<16|e[i+3]<<8|e[i+4],i+=5;else if(n<252)r=((7&e[i])<<8|e[i+1])*Math.pow(2,32)+(e[i+2]<<24)|e[i+3]<<16|e[i+4]<<8|e[i+5],i+=6;else if(n<254)r=((3&e[i])<<16|e[i+1]<<8|e[i+2])*Math.pow(2,32)+(e[i+3]<<24)|e[i+4]<<16|e[i+5]<<8|e[i+6],i+=7;else if(n<255){if(r=s.default.fromBytesBE(e.slice(i+1,i+8)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=8}else{if(r=s.default.fromBytesBE(e.slice(i+1,i+9)),r.greaterThan(Number.MAX_SAFE_INTEGER)||r.lessThan(Number.MIN_SAFE_INTEGER))throw new Error(\"integer overflow\");r=r.toNumber(),i+=9}return[r,i-t]},t.parseItem=function(e,t,i=0,n=0){const{offset:r,value:s}=t(e,i);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},t.tinyMemoize=function(e,t){const i=e.prototype[t],n=`_memo_${t}`;e.prototype[t]=function(){if(!(n in this)){const e=i.call(this);this[n]=e,Promise.resolve(e).catch((()=>{delete this[n]}))}return this[n]}},t.sequenceMD5=function(e){return(0,r.default)(e.toUpperCase().replaceAll(/[^\\u0021-\\u007e]/g,\"\"))};const r=n(i(3503)),s=n(i(8570)),o=i(612)},9747:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.CramArgumentError=t.CramSizeLimitError=t.CramMalformedError=t.CramUnimplementedError=t.CramError=void 0;class i extends Error{}t.CramError=i;class n extends Error{}t.CramUnimplementedError=n,t.CramMalformedError=class extends i{},t.CramSizeLimitError=class extends i{},t.CramArgumentError=class extends i{}},7806:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.IndexedCramFile=t.CraiIndex=t.CramRecord=t.CramFile=void 0;var r=i(7390);Object.defineProperty(t,\"CramFile\",{enumerable:!0,get:function(){return n(r).default}}),Object.defineProperty(t,\"CramRecord\",{enumerable:!0,get:function(){return r.CramRecord}});var s=i(4923);Object.defineProperty(t,\"CraiIndex\",{enumerable:!0,get:function(){return n(s).default}});var o=i(6014);Object.defineProperty(t,\"IndexedCramFile\",{enumerable:!0,get:function(){return n(o).default}})},6014:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const s=i(9747),o=r(i(7390));t.default=class{constructor(e){var t;if(this.cram=null!==(t=e.cram)&&void 0!==t?t:new o.default({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof o.default))throw new Error(\"invalid arguments: no cramfile\");this.index=e.index}getRecordsForRange(e,t,i){return n(this,arguments,void 0,(function*(e,t,i,n={}){if(n.viewAsPairs=n.viewAsPairs||!1,n.pairAcrossChr=n.pairAcrossChr||!1,n.maxInsertSize=n.maxInsertSize||2e5,\"string\"==typeof e)throw new s.CramUnimplementedError(\"string sequence names not yet supported\");const r=e,o=yield this.index.getEntriesForRange(r,t,i),a=n=>n.sequenceId===e&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=t,c=yield Promise.all(o.map((e=>this.getRecordsInSlice(e,a))));let l=Array.prototype.concat(...c);if(n.viewAsPairs){const e={},t={};for(const i of l){const n=i.readName;if(void 0===n)throw new Error(\"readName undefined\");const r=i.uniqueId;e[n]||(e[n]=0),e[n]+=1,t[r]=1}const i={};Object.entries(e).forEach((([e,t])=>{1===t&&(i[e]=!0)}));const s=[];for(const e of l){const t=e.readName;if(void 0===t)throw new Error(\"readName undefined\");if(i[t]&&e.mate&&(e.mate.sequenceId===r||n.pairAcrossChr)&&Math.abs(e.alignmentStart-e.mate.alignmentStart)e.toString().localeCompare(t.toString()))).filter(((e,t,i)=>!t||e.toString()!==i[t-1].toString()));const c=[];for(const e of a){let n=this.cram.featureCache.get(e.toString());n||(n=this.getRecordsInSlice(e,(()=>!0)),this.cram.featureCache.set(e.toString(),n));const r=n.then((e=>{const n=[];for(const r of e){if(void 0===r.readName)throw new Error(\"readName undefined\");i[r.readName]&&!t[r.uniqueId]&&n.push(r)}return n}));c.push(r)}const h=yield Promise.all(c);if(h.length){const e=h.reduce(((e,t)=>e.concat(t)));l=l.concat(e)}}return l}))}getRecordsInSlice({containerStart:e,sliceStart:t,sliceBytes:i},n){return this.cram.getContainerAtPosition(e).getSlice(t,i).getRecords(n)}hasDataForReferenceSequence(e){return this.index.hasDataForReferenceSequence(e)}}},5931:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RemoteFile=t.LocalFile=void 0,t.open=function(e,t,i){if(i)return i;if(e)return new n.RemoteFile(e);if(t)return new n.LocalFile(t);throw new Error(\"no url, path, or filehandle provided, cannot open\")};const n=i(1113);var r=i(1113);Object.defineProperty(t,\"LocalFile\",{enumerable:!0,get:function(){return r.LocalFile}}),Object.defineProperty(t,\"RemoteFile\",{enumerable:!0,get:function(){return r.RemoteFile}})},6476:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.RANS_BYTE_L=t.TOTFREQ=t.TF_SHIFT=void 0,t.TF_SHIFT=12,t.TOTFREQ=4096,t.RANS_BYTE_L=1<<23},997:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i,n){let a=e.getInt(),c=e.getInt(),l=e.getInt(),h=e.getInt();const d=n.remaining(),u=-4&d;for(let r=0;r>2;let u=0,f=d,p=2*d,g=3*d,m=0,w=0,b=0,F=0;for(;u{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(9747),r=i(6476);class s{constructor(){this.F=void 0,this.C=void 0}}function o(e,t,i,n){return i*(e>>n)+(e&(1<>s)+(e&(1<=128&&(t.fc[c].F&=-129,t.fc[c].F=(127&t.fc[c].F)<<8|255&e.get()),t.fc[c].C=r,o.default.symbolInit(i[c],t.fc[c].C,t.fc[c].F),t.R||(t.R=new Array(s.TOTFREQ)),t.R.fill(c,r,r+t.fc[c].F),r+=t.fc[c].F,0===n&&c+1===(255&e.getByteAt(e.position()))?(c=255&e.get(),n=255&e.get()):0!==n?(n-=1,c+=1):c=255&e.get()}while(0!==c);a(r=128&&(t[r].fc[h].F&=-129,t[r].fc[h].F=(127&t[r].fc[h].F)<<8|255&e.get()),t[r].fc[h].C=l,0===t[r].fc[h].F&&(t[r].fc[h].F=s.TOTFREQ),null==i[r][h]&&(i[r][h]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][h],t[r].fc[h].C,t[r].fc[h].F),null==t[r].R&&(t[r].R=new Array(s.TOTFREQ)),t[r].R.fill(h,l,l+t[r].fc[h].F),l+=t[r].fc[h].F,a(l<=s.TOTFREQ),0===c&&h+1===(255&e.getByteAt(e.position()))?(h=255&e.get(),c=255&e.get()):0!==c?(c-=1,h+=1):h=255&e.get()}while(0!==h);0===n&&r+1===(255&e.getByteAt(e.position()))?(r=255&e.get(),n=255&e.get()):0!==n?(n-=1,r+=1):r=255&e.get()}while(0!==r)};const r=i(9747),s=i(6476),o=n(i(488));function a(e){if(!e)throw new r.CramMalformedError(\"assertion failed\")}},9989:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0}),t.default=function(e,t,i=0){if(0===e.length)return t.fill(0),t;const n=new d(e,i),u=n.get();if(0!==u&&1!==u)throw new s.CramMalformedError(`Invalid rANS order ${u}`);if(n.getInt()!==n.remaining()-h)throw new s.CramMalformedError(\"Incorrect input length.\");const f=n.getInt(),p=new d(t||r.Buffer.allocUnsafe(f));if(p.length{Object.defineProperty(t,\"__esModule\",{value:!0}),t.parseHeaderText=function(e){const t=e.split(/\\r?\\n/),i=[];for(const e of t){const[t,...n]=e.split(/\\t/);t&&i.push({tag:t.slice(1),data:n.map((e=>{const t=e.indexOf(\":\");return-1!==t?{tag:e.slice(0,t),value:e.slice(t+1)}:{tag:e,value:\"\"}}))})}return i}},8712:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0}),t.unzip=function(e){return r.Buffer.from((0,n.inflate)(e))};const n=i(1668),r=i(8287)},635:(e,t,i)=>{var n=i(8287).Buffer;const r=i(4646),s=i(8706),o=i(9614),a=i(235),c=128;e.exports=class{decode(e){return this.stream=new s(e),this.decodeStream(this.stream)}decodeStream(e,t=0){var i=this.stream.ReadByte();16&i||(t=this.stream.ReadUint7());var n,r=t,s=1&i;if(8&i)return this.decodeStripe(this.stream,t);if(i&c&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&c&&(o=this.decodePack(o,n,t)),o}encode(e,t){if(this.stream=new s(\"\",0,1.1*e.length+100),this.stream.WriteByte(t),16&t||this.stream.WriteUint7(e.length),8&t)return n.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,e,t>>8)]);var i,r=1&t,o=e.length;return t&c&&([i,e,o]=this.encodePack(e)),t&c&&this.stream.WriteStream(i),64&t?r?this.encodeRLE1(e,o,this.stream):this.encodeRLE0(e,o,this.stream):r?this.encode1(e,o,this.stream):this.encode0(e,o,this.stream)}decode0(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);var a=new o(s),c=new r(e);c.RangeStartDecode(e);for(var l=0;l=3?3:h;for(c[d].ModelEncode(i,l,u),h-=u,d=256;3==u;)u=h>=3?3:h,c[d].ModelEncode(i,l,u),d=257,h-=u}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(e,t){var i=new n.allocUnsafe(t),s=e.ReadByte();0==s&&(s=256);for(var a=new Array(s),c=0;c=3?3:d;for(c[u].ModelEncode(i,l,f),d-=f,u=256;3==f;)f=d>=3?3:d,c[u].ModelEncode(i,l,f),u=257,d-=f}return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(e){this.nsym=e.ReadByte();for(var t=new Array(this.nsym),i=0;i>=1}}else if(this.nsym<=4)for(s=0,o=0;s>=2;else{if(!(this.nsym<=16))return e;for(s=0,o=0;s>=4}return r}packMeta(e){for(var t=new s(\"\",0,1024),i=new Array(256),n=0;no),n[o]=new Array(r[o]);for(var a=0,c=0;co),a[o]=this.decodeStream(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o{e.exports=class{constructor(e){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(e){for(var t=0;t<5;t++)this.code=(this.code<<8)+e.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(e){return this.range=Math.floor(this.range/e),Math.floor(this.code/this.range)}RangeDecode(e,t,i,n){for(this.code-=t*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+e.ReadByte()}RangeShiftLow(e){if(this.low<4278190080|this.carry){for(e.WriteByte(this.cache+this.carry);this.FFnum;)e.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(e,t,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=t*this.range,this.low>>>=0,this.range*=i,this.low{e.exports=class{constructor(e=256){this.total_freq=e,this.max_sym=e-1,this.S=new Array,this.F=new Array;for(var t=0;t<=this.max_sym;t++)this.S[t]=t,this.F[t]=1}ModelDecode(e,t){for(var i=t.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];t.RangeDecode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var e=0;e<=this.max_sym;e++)this.F[e]-=Math.floor(this.F[e]/2),this.total_freq+=this.F[e]}ModelEncode(e,t,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(t.RangeEncode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},6038:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(9614),o=i(4646);function a(e,t,i){for(var n=0,r=0,s=-1,o=new Array(1024);r>4,t.qshift=15&i,i=e.ReadByte(),t.qloc=i>>4,t.sloc=15&i,i=e.ReadByte(),t.ploc=i>>4,t.dloc=15&i,t.qmap=new Array(256),16&t.pflags)for(var n=0;n0&&128&t.pflags)a(e,t.qtab,256);else for(n=0;n<256;n++)t.qtab[n]=n;return t.ptab=new Array(1024),32&t.pflags&&a(e,t.ptab,1024),t.dtab=new Array(256),64&t.pflags&&a(e,t.dtab,256),t}function h(e,t,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(e,t):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(e,t);a|=n.len[1].ModelDecode(e,t)<<8,a|=n.len[2].ModelDecode(e,t)<<16,a|=n.len[3].ModelDecode(e,t)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(e,t)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(e,t)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function d(e,t,i){for(var n=0,r=0,s=new Array(2*i),o=0;n1?i.nparam-1:0,s=new Array(256);if(2&i)r=e.ReadByte(),a(e,s,256);else{for(var o=0;o0&&(t.sel=new s(e.max_sel+1)),t}(r),p=new o(e);p.RangeStartDecode(e);for(var g=new n.allocUnsafe(i),m={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},w=0;w0&&f.dup.ModelDecode(e,p)){for(var b=0;b4),qshift:d,qloc:7,pbits:7,pshift:t[0]>128?1:0,ploc:0,dbits:d>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:c,nsym:a,do_qmap:u,do_dedup:0,fixed_len:1==t.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:d<=4?1:0,do_qtab:0,qbits:8+(d>4)-(0==o),sbits:1,sloc:15-(d<=4),do_stab:1,do_sel:1}]}(e,t,i,n),p=function(e,t,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],c=0;c1?1:0)|(t[0].do_stab?2:0);if(e.WriteByte(l),1&l&&e.WriteByte(t.length),2&l){var h=1<0&&h--,e.WriteByte(h),d(e,o,256)}for(var u=0;u0){for(c=0;c<256;c++)n[u][c]=c;t[u].do_qtab&&d(e,n[u],256)}if(t[u].pbits>0){for(c=0;c<1024;c++)r[u][c]=Math.min((1<>t[u].pshift);d(e,r[u],1024)}if(t[u].dbits>0){for(c=0;c<256;c++)a[c]>(1<>t[u].dshift)];d(e,s[u],256)}}return e}(p,f,n,a,c,l,h);return function(e,t,i,n,r,a,c,l,h,d){var u=1<0&&u--;for(var f=t.length,p=0,g=0;g0&&F.ModelEncode(e,v,A);var C=d[A],_=i[Math.min(i.length-1,y++)];r[C].fixed_len?r[C].fixed_len>0&&(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255),r[C].fixed_len=-1):(b[0].ModelEncode(e,v,255&_),b[1].ModelEncode(e,v,_>>8&255),b[2].ModelEncode(e,v,_>>16&255),b[3].ModelEncode(e,v,_>>24&255)),r[C].do_dedup&&process.exit(1),g=_;var x=0,k=r[C].context,I=0,S=0}var E=t[w++],N=a[C][E];m[k].ModelEncode(e,v,N),I=(I<0&&(k+=l[C][Math.min(g,1023)]<0&&(k+=h[C][Math.min(x,255)]<{var n=i(8287).Buffer,r=i(5460),s=i(8223),o=i(635),a=i(6038),c=i(5997);e.exports={r4x8_uncompress:function(e,t){r.decode(e).copy(t,0,0)},r4x16_uncompress:function(e,t){s.decode(e).copy(t,0,0)},arith_uncompress:function(e,t){o.decode(e).copy(t,0,0)},fqzcomp_uncompress:function(e,t){var i=new Array;a.decode(e,i).copy(t,0,0)},tok3_uncompress:function(e,t){var i=c.decode(e,0,\"\\0\");n.from(i,\"binary\").copy(t,0,0)}}},8706:(e,t,i)=>{var n=i(8287).Buffer;e.exports=class{constructor(e,t=0,i=0){0!=i?(this.buf=n.allocUnsafe(i),this.length=i):(this.buf=e,this.length=e.length),this.pos=t}EOF(){return this.pos>=this.length}ReadData(e){var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}ReadByte(){const e=this.buf[this.pos];return this.pos++,e}ReadChar(){const e=this.buf[this.pos];return this.pos++,String.fromCharCode(e)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const e=this.buf.readInt32LE(this.pos);return this.pos+=4,e}ReadString(){var e=\"\";do{var t=this.buf[this.pos++];t&&(e+=String.fromCharCode(t))}while(t);return e}ReadUint7(){var e=0;do{var t=this.ReadByte();e=e<<7|127&t}while(128&t);return e}ReadITF8(){var e=this.buf[this.pos];return this.pos++,e>=240?(e=(15&e)<<28,e+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):e>=224?(e=(15&e)<<24,e+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(0|this.buf[this.pos+2]),this.pos+=3):e>=192?(e=(31&e)<<16,e+=(this.buf[this.pos+0]<<8)+(0|this.buf[this.pos+1]),this.pos+=2):e>=128&&(e=(63&e)<<8,e+=this.buf[this.pos],this.pos++),e}WriteByte(e){this.buf[this.pos++]=e}WriteChar(e){this.buf[this.pos++]=e.charCodeAt(0)}WriteString(e){for(var t=0;t>8&255)}WriteUint32(e){this.buf.writeInt32LE(e,this.pos),this.pos+=4}WriteUint7(e){var t=0,i=e;do{t+=7,i>>=7}while(i>0);do{t-=7,this.WriteByte((e>>t&127)+((t>0)<<7))}while(t>0)}WriteITF8(e){e<0&&(e=1+e),e<=127?this.buf[this.pos++]=e:e<=16383?(this.buf[this.pos++]=128|Math.floor(e/256),this.buf[this.pos++]=255&e):e<131071?(this.buf[this.pos++]=192|Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):e<268435455?(this.buf[this.pos++]=224|Math.floor(e/16777216),this.buf[this.pos++]=255&Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):(this.buf[this.pos++]=240|Math.floor(e/268435456),this.buf[this.pos++]=255&Math.floor(e/1048576),this.buf[this.pos++]=255&Math.floor(e/4096),this.buf[this.pos++]=255&Math.floor(e/4),this.buf[this.pos++]=15&e)}WriteByteNeg(e){this.buf[--this.pos]=e}}},5460:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e){return 4095&e}function o(e,t){for(var i=0;t>=e[i+1];)i++;return i}function a(e){for(var t=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=e[i+1];)i++;t[n]=i}return t}function c(e,t,i){return i*(e>>12)+(4095&e)-t}function l(e,t){for(;t<1<<23;)t=(t<<8)+e.ReadByte();return t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<23>>n<<8)*i;e>=r;)t.WriteByteNeg(255&e),e>>=8;return e}(e,t,n,r),(Math.floor(e/n)<0?(o--,r++):(r=e.ReadByte())==s+1&&(o=e.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}function f(e){for(var t=0,i=0;i<256;i++)t+=e[i];const n=4096;var r=n/t;do{var s=0,o=0,a=0;for(t=0,i=0;i<256;i++)0!=e[i]&&(s2?e[o]-=t-n:t!=n&&(r*=.99,a=1)}while(a)}function p(e,t){for(var i=0,n=0;n<256;n++)if(t[n]){if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteITF8(t[n])}e.WriteByte(0)}e.exports={decode:function(e){var t=new r(e),i=t.ReadByte(),h=(t.ReadUint32(),t.ReadUint32());return 0==i?function(e,t){var i=new Array(256),r=new Array(256);u(e,i,r);for(var o=a(r),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var f=new n.allocUnsafe(t);for(d=0;d0?(a--,s++):(s=e.ReadByte())==o+1&&(a=e.ReadByte()),o=s}while(0!=s)}(e,i,r);for(var h=new Array(256),d=0;d<256;d++)h[d]=a(r[d]);for(var f=new Array(4),p=new Array(4),g=0;g<4;g++)f[g]=e.ReadUint32(),p[g]=0;var m=new n.allocUnsafe(t),w=Math.floor(t/4);for(d=0;d=0;a--)c[a%4]=d(c[a%4],u,o[e[a]],s[e[a]],12);for(a=3;a>=0;a--)h(c[a],u);var g=i.pos;return i.buf.writeInt32LE(g-9+(u.length-u.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}(e):function(e){const t=e.length;var i=new r(\"\",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var s=new Array(256),o=new Array(256),a=new Array(256),c=0;c<256;c++)o[c]=new Array(256),a[c]=new Array(256);for(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3}(e,o,s),function(e,t){for(var i=0;i<256;i++)t[i]&&f(e[i])}(o,s),function(e,t,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(e.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,e.WriteByte(n)}p(e,t[r])}e.WriteByte(0)}(i,o,s),c=0;c<256;c++)if(s[c]){a[c][0]=0;for(var l=1;l<256;l++)a[c][l]=a[c][l-1]+o[c][l-1]}var u=new Array(4),g=new Array(4);for(l=0;l<4;l++)u[l]=1<<23,g[l]=0;var m=new r(\"\",t,t),w=Math.floor(t/4),b=new Array(4),F=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*w-2,F[l]=e[b[l]+1];for(F[3]=e[t-1],c=t-2;c>4*w-2;c--)u[3]=d(u[3],m,a[e[c]][F[3]],o[e[c]][F[3]],12),F[3]=e[c];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=e[b[l]];u[l]=d(u[l],m,a[v][F[l]],o[v][F[l]],12),F[l]=v,b[l]--}for(l=3;l>=0;l--)u[l]=d(u[l],m,a[0][F[l]],o[0][F[l]],12);for(c=3;c>=0;c--)h(u[c],m);var y=i.pos;return i.buf.writeInt32LE(y-9+(m.length-m.pos),1),i.buf.writeInt32LE(t,5),n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e)}}},8223:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706);function s(e,t){return e&(1<=e[i+1];)i++;return i}function a(e,t){for(var i=1<=e[r+1];)r++;n[s]=r}return n}function c(e,t,i,n){return i*(e>>n)+(e&(1<>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e)}function d(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<31-n)*i;e>=r;)t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e),e>>=16;return e}(e,t,n,r),(Math.floor(e/n)<o),n[o]=new Array(s[o]);for(var a=0,c=0;co),a[o]=f(e,s[o]);var c=new n.allocUnsafe(t);for(o=0;o>4,h=e;if(1&f){var d=e.ReadUint7(),u=e.ReadUint7(),f=new r(e.ReadData(u));h=new r(m(f,d))}var p=new Array(256),w=new Array(256);!function(e,t,i,n){for(var r=0;r<256;r++){t[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)t[r][s]=0}var o=g(e);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(t[r][s]=e.ReadUint7(),0==t[r][s]&&(a=e.ReadByte())));for(b(t[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+t[r][s]}}(h,p,w,i);for(var F=new Array(256),v=0;v<256;v++)F[v]=a(w[v],i);for(var y=new Array(4),A=new Array(4),C=0;C<4;C++)y[C]=e.ReadUint32(),A[C]=0;var _=new n.allocUnsafe(t),x=Math.floor(t/4);for(v=0;v>=1}else if(i<=4)for(a=0;a>=2;else if(i<=16)for(a=0;a>=4;return s}(x,v,y,F)),x}function p(e,t){var i=new r(\"\",0,10);i.WriteByte(t);var s=1&t,o=8&t,a=32&t,c=64&t,l=128&t,f=t>>8;if(16&t||i.WriteUint7(e.length),o)return n.concat([i.buf.slice(0,i.pos),u(0,e,f)]);var p=new n.alloc(0);l&&([p,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;for(i=0;i0&&(s[i]=o++);if(!(o>16)){if(o<=1)var a=new n.allocUnsafe(0);else if(o<=2){a=new n.allocUnsafe(Math.ceil(e.length/8));var c=-1;for(i=0;i0&&(t[i]=c++,l.WriteByte(i));return l.WriteUint7(a.length),[l.buf.slice(0,l.pos),a]}}(e));var g=new n.alloc(0);if(c&&([g,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var s=-1;for(i=0;i0&&o++;for(o||(o=1,t[0]=1),(h=new r(\"\",0,o+1+e.length)).WriteByte(o),i=0;i<256;i++)t[i]>0&&h.WriteByte(i);var a=new n.allocUnsafe(e.length),c=0;for(i=0;i0){s=e[i];for(var l=0;i+l+1>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3})(e,o,s),function(e,t){for(var i=0;i<256;i++)if(t[i]){var n=Math.ceil(Math.log2(t[i]));n>12&&(n=12),w(e[i],n)}}(o,s);var l=new r(\"\",0,198156);!function(e,t,i){F(e,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(e.WriteUint7(t[n][s]),!t[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=t[n][o])break;r++}e.WriteByte(r)}}(l,o,s);var u=v(l.buf.slice(0,l.pos));for(u.length4*y-2;c--)p[3]=d(p[3],m,a[e[c]][C[3]],o[e[c]][C[3]],12),C[3]=e[c];for(;A[0]>=0;)for(f=3;f>=0;f--){var _=e[A[f]];p[f]=d(p[f],m,a[_][C[f]],o[_][C[f]],12),C[f]=_,A[f]--}for(f=3;f>=0;f--)p[f]=d(p[f],m,a[0][C[f]],o[0][C[f]],12);for(c=3;c>=0;c--)h(p[c],m);return n.concat([i.buf.slice(0,i.pos),m.buf.slice(m.pos,m.length)],i.pos+m.length-m.pos)}(e);return n.concat([i.buf.slice(0,i.pos),p,g,m])}function g(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var n=0,r=e.ReadByte(),s=r;do{t[r]=1,n>0?(n--,r++):(r=e.ReadByte())==s+1&&(n=e.ReadByte()),s=r}while(0!=r);return t}function m(e,t){var i=new Array(256),r=new Array(256);!function(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=g(e);for(n=0;n<256;n++)r[n]>0&&(t[n]=e.ReadUint7());for(b(t,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}(e,i,r);for(var o=a(r,12),h=new Array(4),d=0;d<4;d++)h[d]=e.ReadUint32();var u=new n.allocUnsafe(t);for(d=0;d2?e[a]-=i-r:i!=r&&(s=r/i,c=1)}while(c)}function b(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];if(0!=i&&i!=1<0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteByte(0)}function v(e){const t=e.length;var i=new r(\"\",0,780),s=new Array(256);!function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i12&&(o=12),w(s,o),function(e,t){F(e,t);for(var i=0;i<256;i++)t[i]&&e.WriteUint7(t[i])}(i,s),w(s,12);var a=new Array(256);a[0]=0;for(var c=1;c<256;c++)a[c]=a[c-1]+s[c-1];var l=new Array(4);for(c=0;c<4;c++)l[c]=32768;var u=new r(\"\",1.05*t+100|0,1.05*t+100|0);for(c=t-1;c>=0;c--)l[c%4]=d(l[c%4],u,a[e[c]],s[e[c]],12);for(c=3;c>=0;c--)h(l[c],u);return n.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}e.exports={decode:function(e){return f(new r(e),0)},encode:p}},5997:(e,t,i)=>{var n=i(8287).Buffer;const r=i(8706),s=i(8223);var o=new(i(635));function a(e,t){for(var i=e+\"\";i.length0&&5==t[o][0].type)&&t[o][i])switch(e[0].WriteByte(t[o][i].type),t[o][i].type){case 6:e[6].WriteUint32(t[o][i].val);break;case 5:e[5].WriteUint32(t[o][i].val);break;case 1:e[1].WriteString(t[o][i].val);break;case 2:e[2].WriteChar(t[o][i].val);break;case 7:e[7].WriteUint32(t[o][i].val);break;case 3:e[3].WriteUint32(t[o][i].val),e[4].WriteByte(t[o][i].val.length);break;case 8:case 9:e[t[o][i].type].WriteByte(t[o][i].val)}}function h(e,t,i,n){for(var r=0;r<=12;r++)if(!(e[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),e[r]=e[r].buf.slice(0,e[r].pos);var s=d(e[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function d(e,t){var i,n=1<<30,r=[0,1,64,65,128,129,201];for(var a in r){var c=r[a];if(!(1&c&&e.length<100||8&c&&e.length%4!=0)){try{var l=t?o.encode(e,c):s.encode(e,c)}catch(e){l=0}l&&n>l.length&&(n=l.length,i=l)}}return i}function u(e,t,i,n,r){var s=0,o=r-1;e[r]=new Array(256),t[n]?e[r][0]={type:5,val:r-t[n]}:e[r][0]={type:6,val:0==r?0:1},t[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),c=0;c=0&&e[o][l])if(e[o][l].str==a[c])h=10,d=\"\";else if(7==e[o][l].type||8==e[o][l].type){var u=d-e[o][l].str;i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=8,d=u)}else 3!=e[o][l].type&&9!=e[o][l].type||e[o][l].str.length!=d.length||(u=d-e[o][l].str,i[l]++,u>=0&&u<256&&i[l]>r/2&&(h=9,d=u));e[r][l]={str:a[c],val:d,type:h},s{t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),o=s[0],c=s[1],l=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,c)),h=0,d=c>0?o-4:o;for(i=0;i>16&255,l[h++]=t>>8&255,l[h++]=255&t;return 2===c&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,l[h++]=255&t),1===c&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,l[h++]=t>>8&255,l[h++]=255&t),l},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,l=n-r;al?l:a+o));return 1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+\"==\")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+\"=\")),s.join(\"\")};for(var i=[],n=[],r=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,s=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function c(e,t,n){for(var r,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},8287:(e,t,i)=>{const n=i(7526),r=i(251),s=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return d(e)}return l(e,t,i)}function l(e,t,i){if(\"string\"==typeof e)return function(e,t){if(\"string\"==typeof t&&\"\"!==t||(t=\"utf8\"),!c.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|g(e,t);let n=a(i);const r=n.write(e,t);return r!==i&&(n=n.slice(0,r)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return f(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return f(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,i);const r=function(e){if(c.isBuffer(e)){const t=0|p(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?\"number\"!=typeof e.length||Y(e.length)?a(0):u(e):\"Buffer\"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function h(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function d(e){return h(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),i=a(t);for(let n=0;n=o)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o.toString(16)+\" bytes\");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return W(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return G(e).length;default:if(r)return n?-1:W(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function m(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return N(this,t,i);case\"utf8\":case\"utf-8\":return k(this,t,i);case\"ascii\":return S(this,t,i);case\"latin1\":case\"binary\":return E(this,t,i);case\"base64\":return x(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return B(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function w(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function b(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Y(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:F(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):F(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function F(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function x(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function k(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!c.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;ti&&(e+=\" ... \"),\"\"},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,i,n,r){if(K(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),l=this.slice(n,r),h=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return v(this,e,t,i);case\"utf8\":case\"utf-8\":return y(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return A(this,e,t,i);case\"base64\":return C(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return _(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function S(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function R(e,t,i,n,r,s){if(!c.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function D(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function T(e,t,i,n,r){q(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function L(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function z(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,4),r.write(e,t,i,n,23,4),i+4}function H(e,t,i,n,s){return t=+t,i>>>=0,s||L(e,0,i,8),r.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||M(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||M(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=Z((function(e){Q(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||V(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,n||R(this,e,t,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=Z((function(e,t=0){return D(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(e,t=0){return T(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);R(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=Z((function(e,t=0){return D(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(e,t=0){return T(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(e,t,i){return z(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return z(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return H(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return H(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(!c.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function q(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new P.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Q(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||V(t,e.length-(i+1))}(n,r,s)}function Q(e,t){if(\"number\"!=typeof e)throw new P.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function V(e,t,i){if(Math.floor(e)!==e)throw Q(e,i),new P.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}O(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),O(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),O(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=U(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=U(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const j=/[^+/0-9A-Za-z-_]/g;function W(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(e){return n.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(j,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function $(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}const X=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Z(e){return\"undefined\"==typeof BigInt?J:e}function J(){throw new Error(\"BigInt not supported\")}},235:e=>{var t={array:function(e){var t=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-t;r>=o?(s<<=o,s|=n[o]&e[i++],t=0,r-=o):(s<<=r,s|=(e[i]&n[r]<<8-r-t)>>8-r-t,t+=r,r=0)}return s}},simple:function(e){var i,n,r=t.header(e),s=[],o=0;do{-1!=(n=t.decompress(e,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a9)throw\"Not a BZIP archive\";return t},decompress:function(e,t,i){for(var n=9e5,r=\"\",s=0;s<6;s++)r+=e(8).toString(16);if(\"177245385090\"==r)return-1;if(\"314159265359\"!=r)throw\"eek not valid bzip data\";if(e(32),e(1))throw\"unsupported obsolete version\";var o=e(24);if(o>n)throw\"Initial position larger than buffer size\";var a=e(16),c=new Uint8Array(256),l=0;for(s=0;s<16;s++)if(a&1<<15-s){var h=e(16);for(g=0;g<16;g++)h&1<<15-g&&(c[l++]=16*s+g)}var d=e(3);if(d<2||d>6)throw\"another error\";var u=e(15);if(0==u)throw\"meh\";var f=[];for(s=0;s=d)throw\"whoops another error\";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var w=l+2,b=[];for(g=0;g20)throw\"I gave up a while ago on writing error messages\";if(!e(1))break;e(1)?a--:a++}A[s]=a}for(F=v=A[0],s=1;sv?v=A[s]:A[s]=u)throw\"meow i'm a kitty, that's an error\";_=(y=b[p[E++]]).base.subarray(1),x=y.limit.subarray(1)}for(g=e(s=y.minLen);;){if(s>y.maxLen)throw\"rawr i'm a dinosaur\";if(g<=x[s])break;s++,g=g<<1|e(1)}if((g-=_[s])<0||g>=258)throw\"moo i'm a cow\";var M=y.permute[g];if(0!=M&&1!=M){if(I){if(I=0,S+a>=n)throw\"Boom.\";for(N[m=c[f[0]]]+=a;a--;)B[S++]=m}if(M>l)break;if(S>=n)throw\"I can't think of anything. Error\";m=f[s=M-1],f.splice(s,1),f.splice(0,0,m),N[m=c[m]]++,B[S++]=m}else I||(I=1,a=0),a+=0==M?I:2*I,I<<=1}if(o<0||o>=S)throw\"I'm a monkey and I'm throwing something at someone, namely you\";for(g=0,s=0;s<256;s++)h=g+N[s],N[s]=g,g=h;for(s=0;s>=8,T=-1);var L,z,H,P=new Uint8Array(n),O=0;for(i||(i=1/0);S;){for(S--,z=D,D=255&(R=B[R]),R>>=8,3==T++?(L=D,H=z,D=-1):(L=1,H=D);L--;)if(P[O++]=H,! --i)return P;D!=z&&(T=0)}return P.subarray(0,O)}};e.exports=t},2151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],i=0;i{var t,i;t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",i={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&i.rotl(e,8)|4278255360&i.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],i=0,n=0;i>>5]|=e[i]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],i=0;i<32*e.length;i+=8)t.push(e[i>>>5]>>>24-i%32&255);return t},bytesToHex:function(e){for(var t=[],i=0;i>>4).toString(16)),t.push((15&e[i]).toString(16));return t.join(\"\")},hexToBytes:function(e){for(var t=[],i=0;i>>6*(3-s)&63)):i.push(\"=\");return i.join(\"\")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\\/]/gi,\"\");for(var i=[],n=0,r=0;n>>6-2*r);return i}},e.exports=i},1113:(e,t,i)=>{i.r(t),i.d(t,{BlobFile:()=>l,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>h,open:()=>d});var n=i(3617),r=i.n(n),s=i(8287);function o(e){return(\"object\"==typeof e&&null!==e&&\"message\"in e?e.message:`${e}`).replace(/\\.$/,\"\")}class a{async getBufferFromResponse(e){const t=await e.arrayBuffer();return s.Buffer.from(t)}constructor(e,t={}){this.baseOverrides={},this.url=e;const i=t.fetch||globalThis.fetch.bind(globalThis);if(!i)throw new TypeError(\"no fetch function supplied, and none found in global environment\");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=i}async fetch(e,t){let i;try{i=await this.fetchImplementation(e,t)}catch(n){if(!`${n}`.includes(\"Failed to fetch\"))throw new Error(`${o(n)} fetching ${e}`,{cause:n});console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`);try{i=await this.fetchImplementation(e,{...t,cache:\"reload\"})}catch(t){throw new Error(`${o(t)} fetching ${e}`,{cause:t})}}return i}async read(e,t=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const c=await this.fetch(this.url,{...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:o});if(!c.ok)throw new Error(`HTTP ${c.status} fetching ${this.url}`);if(200===c.status&&0===n||206===c.status){const n=await this.getBufferFromResponse(c),r=n.copy(e,t,0,Math.min(i,n.length)),s=c.headers.get(\"content-range\"),o=/\\/(\\d+)$/.exec(s||\"\");return(null==o?void 0:o[1])&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:e}}if(200===c.status)throw new Error(`${this.url} fetch returned status 200, expected 206`);throw new Error(`HTTP ${c.status} fetching ${this.url}`)}async readFile(e={}){let t,i;\"string\"==typeof e?(t=e,i={}):(t=e.encoding,i=e,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o=await this.fetch(this.url,{headers:n,method:\"GET\",redirect:\"follow\",mode:\"cors\",signal:r,...this.baseOverrides,...s});if(200!==o.status)throw new Error(`HTTP ${o.status} fetching ${this.url}`);if(\"utf8\"===t)return o.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(o)}async stat(){if(!this._stat){const e=s.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function c(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"!=typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsArrayBuffer(e)}))}class l{constructor(e){this.blob=e,this.size=e.size}async read(e,t=0,i,n=0){if(!i)return{bytesRead:0,buffer:e};const r=n,o=r+i,a=await c(this.blob.slice(r,o)),l=s.Buffer.from(a);return{bytesRead:l.copy(e,t),buffer:l}}async readFile(e){const t=\"string\"==typeof e?e:null==e?void 0:e.encoding;if(\"utf8\"===t)return function(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error(\"problem reading blob\"))},t.onabort=()=>{n(new Error(\"blob reading was aborted\"))},t.onload=()=>{t.result&&\"string\"==typeof t.result?i(t.result):n(new Error(\"unknown error reading blob\"))},t.readAsText(e)}))}(this.blob);if(t)throw new Error(`unsupported encoding: ${t}`);const i=await c(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function h(e,t={}){return new a(e,t)}function d(e,t,i,n={}){if(void 0!==i)return i;if(void 0!==e)return h(e,n);if(void 0!==t)return new(r())(t,n);throw new Error(\"no url, path, or filehandle provided, cannot open\")}},251:(e,t)=>{t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}},8570:e=>{e.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,\"__isLong__\",{value:!0}),i.isLong=n;var r={},s={};function o(e,t){var i,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(i=c(e,(0|e)<0?-1:0,!0),o&&(s[e]=i),i):(o=-128<=(e|=0)&&e<128)&&(n=r[e])?n:(i=c(e,e<0?-1:0,!1),o&&(r[e]=i),i)}function a(e,t){if(isNaN(e))return t?w:m;if(t){if(e<0)return w;if(e>=f)return A}else{if(e<=-p)return C;if(e+1>=p)return y}return e<0?a(-e,t).neg():c(e%u|0,e/u|0,t)}function c(e,t,n){return new i(e,t,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=c;var l=Math.pow;function h(e,t,i){if(0===e.length)throw Error(\"empty string\");if(\"NaN\"===e||\"Infinity\"===e||\"+Infinity\"===e||\"-Infinity\"===e)return m;if(\"number\"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||360)throw Error(\"interior hyphen\");if(0===n)return h(e.substring(1),t,i).neg();for(var r=a(l(i,8)),s=m,o=0;o>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},_.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=c).isZero())return h+o;for(;h.length<6;)h=\"0\"+h;o=\"\"+h+o}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(C)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<=0},_.isOdd=function(){return!(1&~this.low)},_.isEven=function(){return!(1&this.low)},_.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},_.eq=_.equals,_.notEquals=function(e){return!this.eq(e)},_.neq=_.notEquals,_.ne=_.notEquals,_.lessThan=function(e){return this.comp(e)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(e){return this.comp(e)<=0},_.lte=_.lessThanOrEqual,_.le=_.lessThanOrEqual,_.greaterThan=function(e){return this.comp(e)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(e){return this.comp(e)>=0},_.gte=_.greaterThanOrEqual,_.ge=_.greaterThanOrEqual,_.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(C)?C:this.not().add(b)},_.neg=_.negate,_.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,a=65535&e.high,l=e.low>>>16,h=0,u=0,f=0,p=0;return f+=(p+=s+(65535&e.low))>>>16,u+=(f+=r+l)>>>16,h+=(u+=i+a)>>>16,h+=t+o,c((f&=65535)<<16|(p&=65535),(h&=65535)<<16|(u&=65535),this.unsigned)},_.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},_.sub=_.subtract,_.multiply=function(e){if(this.isZero())return m;if(n(e)||(e=d(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(C))return e.isOdd()?C:m;if(e.eq(C))return this.isOdd()?C:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return a(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,l=e.high>>>16,h=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,w=0,b=0,F=0;return b+=(F+=o*f)>>>16,w+=(b+=s*f)>>>16,b&=65535,w+=(b+=o*u)>>>16,p+=(w+=r*f)>>>16,w&=65535,p+=(w+=s*u)>>>16,w&=65535,p+=(w+=o*h)>>>16,p+=i*f+r*u+s*h+o*l,c((b&=65535)<<16|(F&=65535),(p&=65535)<<16|(w&=65535),this.unsigned)},_.mul=_.multiply,_.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error(\"division by zero\");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?w:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return w;if(e.gt(this.shru(1)))return F;s=w}else{if(this.eq(C))return e.eq(b)||e.eq(v)?C:e.eq(C)?b:(i=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?b:v:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(C))return this.unsigned?w:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=m}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),h=o<=48?1:l(2,o-48),u=a(i),f=u.mul(e);f.isNegative()||f.gt(r);)f=(u=a(i-=h,this.unsigned)).mul(e);u.isZero()&&(u=b),s=s.add(u),r=r.sub(f)}return s},_.div=_.divide,_.modulo=function(e){return n(e)||(e=d(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},_.mod=_.modulo,_.rem=_.modulo,_.not=function(){return c(~this.low,~this.high,this.unsigned)},_.and=function(e){return n(e)||(e=d(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},_.or=function(e){return n(e)||(e=d(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},_.xor=function(e){return n(e)||(e=d(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},_.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?c(this.low<>>32-e,this.unsigned):c(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?c(this.low>>>e|t<<32-e,t>>>e,this.unsigned):c(32===e?t:t>>>e-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.shr_u=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},_.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},_.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},_.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},3503:(e,t,i)=>{var n,r,s,o,a;n=i(3939),r=i(2151).utf8,s=i(652),o=i(2151).bin,(a=function(e,t){e.constructor==String?e=t&&\"binary\"===t.encoding?o.stringToBytes(e):r.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var i=n.bytesToWords(e),c=8*e.length,l=1732584193,h=-271733879,d=-1732584194,u=271733878,f=0;f>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[c>>>5]|=128<>>9<<4)]=c;var p=a._ff,g=a._gg,m=a._hh,w=a._ii;for(f=0;f>>0,h=h+F>>>0,d=d+v>>>0,u=u+y>>>0}return n.endian([l,h,d,u])})._ff=function(e,t,i,n,r,s,o){var a=e+(t&i|~t&n)+(r>>>0)+o;return(a<>>32-s)+t},a._gg=function(e,t,i,n,r,s,o){var a=e+(t&n|i&~n)+(r>>>0)+o;return(a<>>32-s)+t},a._hh=function(e,t,i,n,r,s,o){var a=e+(t^i^n)+(r>>>0)+o;return(a<>>32-s)+t},a._ii=function(e,t,i,n,r,s,o){var a=e+(i^(t|~n))+(r>>>0)+o;return(a<>>32-s)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error(\"Illegal argument \"+e);var i=n.wordsToBytes(a(e,t));return t&&t.asBytes?i:t&&t.asString?o.bytesToString(i):n.bytesToHex(i)}},652:e=>{function t(e){return!!e.constructor&&\"function\"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return\"function\"==typeof e.readFloatLE&&\"function\"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},1668:(e,t,i)=>{var n={};(0,i(9805).assign)(n,i(3303),i(7083),i(9681)),e.exports=n},3303:(e,t,i)=>{var n=i(8411),r=i(9805),s=i(1996),o=i(4674),a=i(4442),c=Object.prototype.toString,l=0,h=-1,d=0,u=8;function f(e){if(!(this instanceof f))return new f(e);this.options=r.assign({level:h,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==l)throw new Error(o[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var p;if(p=\"string\"==typeof t.dictionary?s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=n.deflateSetDictionary(this.strm,p))!==l)throw new Error(o[i]);this._dict_set=!0}}function p(e,t){var i=new f(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}f.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,\"string\"==typeof e?a.input=s.string2buf(e):\"[object ArrayBuffer]\"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&i!==l)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||(\"string\"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===l):2!==o||(this.onEnd(l),a.avail_out=0,!0)},f.prototype.onData=function(e){this.chunks.push(e)},f.prototype.onEnd=function(e){e===l&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=f,t.deflate=p,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,p(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,p(e,t)}},7083:(e,t,i)=>{var n=i(1447),r=i(9805),s=i(1996),o=i(9681),a=i(4674),c=i(4442),l=i(7414),h=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:\"\"},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new l,n.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):\"[object ArrayBuffer]\"===h.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[i])}function u(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(e,t){var i,a,c,l,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,\"string\"==typeof e?u.input=s.binstring2buf(e):\"[object ArrayBuffer]\"===h.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new r.Buf8(f),u.next_out=0,u.avail_out=f),(i=n.inflate(u,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==o.Z_STREAM_END&&(0!==u.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||(\"string\"===this.options.to?(c=s.utf8border(u.output,u.next_out),l=u.next_out-c,d=s.buf2string(u.output,c),u.next_out=l,u.avail_out=f-l,l&&r.arraySet(u.output,u.output,c,l,0),this.onData(d)):this.onData(r.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=d,t.inflate=u,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.ungzip=u},9805:(e,t)=>{var i=\"undefined\"!=typeof Uint8Array&&\"undefined\"!=typeof Uint16Array&&\"undefined\"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,n,r){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),r);else for(var s=0;s{var n=i(9805),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var i=\"\",o=0;o>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},t.buf2binstring=function(e){return c(e,e.length)},t.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i4)l[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?l[n++]=65533:r<65536?l[n++]=r:(r-=65536,l[n++]=55296|r>>10&1023,l[n++]=56320|1023&r)}return c(l,n)},t.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},3269:e=>{e.exports=function(e,t,i,n){for(var r=65535&e,s=e>>>16&65535,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16}},9681:e=>{e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:e=>{var t=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();e.exports=function(e,i,n,r){var s=t,o=r+n;e^=-1;for(var a=r;a>>8^s[255&(e^i[a])];return~e}},8411:(e,t,i)=>{var n,r=i(9805),s=i(3665),o=i(3269),a=i(4823),c=i(4674),l=0,h=0,d=-2,u=2,f=8,p=286,g=30,m=19,w=2*p+1,b=15,F=3,v=258,y=v+F+1,A=42,C=103,_=113,x=666;function k(e,t){return e.msg=c[t],t}function I(e){return(e<<1)-(e>4?9:0)}function S(e){for(var t=e.length;--t>=0;)e[t]=0}function E(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function N(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,E(e.strm)}function B(e,t){e.pending_buf[e.pending++]=t}function M(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function R(e,t,i,n){var s=e.avail_in;return s>n&&(s=n),0===s?0:(e.avail_in-=s,r.arraySet(t,e.input,e.next_in,s,i),1===e.state.wrap?e.adler=o(e.adler,t,s,i):2===e.state.wrap&&(e.adler=a(e.adler,t,s,i)),e.next_in+=s,e.total_in+=s,s)}function D(e,t){var i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-y?e.strstart-(e.w_size-y):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+v,f=l[s+o-1],p=l[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+o]===p&&l[i+o-1]===f&&l[i]===l[s]&&l[++i]===l[s+1]){s+=2,i++;do{}while(l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&l[++s]===l[++i]&&so){if(e.match_start=t,o=n,n>=a)break;f=l[s+o-1],p=l[s+o]}}}while((t=d[t&h])>c&&0!=--r);return o<=e.lookahead?o:e.lookahead}function T(e){var t,i,n,s,o,a=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-y)){r.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=i=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--i);t=i=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--i);s+=a}if(0===e.strm.avail_in)break;if(i=R(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=F)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<=F)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=F&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-F,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<15&&(a=2,n-=16),s<1||s>9||i!==f||n<8||n>15||t<0||t>9||o<0||o>4)return k(e,d);8===n&&(n=9);var c=new P;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=n,c.w_size=1<e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(T(e),0===e.lookahead&&t===l)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-y&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),1)})),new H(4,4,8,4,L),new H(4,5,16,8,L),new H(4,6,32,32,L),new H(4,4,16,16,z),new H(8,16,32,32,z),new H(8,16,128,128,z),new H(8,32,128,256,z),new H(32,128,258,1024,z),new H(32,258,258,4096,z)],t.deflateInit=function(e,t){return q(e,t,f,15,8,0)},t.deflateInit2=q,t.deflateReset=U,t.deflateResetKeep=O,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?d:(e.state.gzhead=t,h):d},t.deflate=function(e,t){var i,r,o,c;if(!e||!e.state||t>5||t<0)return e?k(e,d):d;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===x&&4!==t)return k(e,0===e.avail_out?-5:d);if(r.strm=e,i=r.last_flush,r.last_flush=t,r.status===A)if(2===r.wrap)e.adler=0,B(r,31),B(r,139),B(r,8),r.gzhead?(B(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),B(r,255&r.gzhead.time),B(r,r.gzhead.time>>8&255),B(r,r.gzhead.time>>16&255),B(r,r.gzhead.time>>24&255),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(B(r,255&r.gzhead.extra.length),B(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(B(r,0),B(r,0),B(r,0),B(r,0),B(r,0),B(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),B(r,3),r.status=_);else{var u=f+(r.w_bits-8<<4)<<8;u|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(u|=32),u+=31-u%31,r.status=_,M(r,u),0!==r.strstart&&(M(r,e.adler>>>16),M(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending!==r.pending_buf_size));)B(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),E(e),o=r.pending,r.pending===r.pending_buf_size)){c=1;break}c=r.gzindexo&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===c&&(r.status=C)}else r.status=C;if(r.status===C&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&E(e),r.pending+2<=r.pending_buf_size&&(B(r,255&e.adler),B(r,e.adler>>8&255),e.adler=0,r.status=_)):r.status=_),0!==r.pending){if(E(e),0===e.avail_out)return r.last_flush=-1,h}else if(0===e.avail_in&&I(t)<=I(i)&&4!==t)return k(e,-5);if(r.status===x&&0!==e.avail_in)return k(e,-5);if(0!==e.avail_in||0!==r.lookahead||t!==l&&r.status!==x){var p=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(T(e),0===e.lookahead)){if(t===l)return 1;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,n,r,o,a=e.window;;){if(e.lookahead<=v){if(T(e),e.lookahead<=v&&t===l)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&e.strstart>0&&(n=a[r=e.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=e.strstart+v;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=s._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(N(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(N(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?1:2}(r,t):n[r.level].func(r,t);if(3!==p&&4!==p||(r.status=x),1===p||3===p)return 0===e.avail_out&&(r.last_flush=-1),h;if(2===p&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(S(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),E(e),0===e.avail_out))return r.last_flush=-1,h}return 4!==t?h:r.wrap<=0?1:(2===r.wrap?(B(r,255&e.adler),B(r,e.adler>>8&255),B(r,e.adler>>16&255),B(r,e.adler>>24&255),B(r,255&e.total_in),B(r,e.total_in>>8&255),B(r,e.total_in>>16&255),B(r,e.total_in>>24&255)):(M(r,e.adler>>>16),M(r,65535&e.adler)),E(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?h:1)},t.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==A&&69!==t&&73!==t&&91!==t&&t!==C&&t!==_&&t!==x?k(e,d):(e.state=null,t===_?k(e,-3):h):d},t.deflateSetDictionary=function(e,t){var i,n,s,a,c,l,u,f,p=t.length;if(!e||!e.state)return d;if(2===(a=(i=e.state).wrap)||1===a&&i.status!==A||i.lookahead)return d;for(1===a&&(e.adler=o(e.adler,t,p,0)),i.wrap=0,p>=i.w_size&&(0===a&&(S(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new r.Buf8(i.w_size),r.arraySet(f,t,p-i.w_size,i.w_size,0),t=f,p=i.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,T(i);i.lookahead>=F;){n=i.strstart,s=i.lookahead-(F-1);do{i.ins_h=(i.ins_h<{e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1}},7293:e=>{e.exports=function(e,t){var i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x,k;i=e.state,n=e.next_in,x=e.input,r=n+(e.avail_in-5),s=e.next_out,k=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,w=(1<>>=v=F>>>24,p-=v,0==(v=F>>>16&255))k[s++]=65535&F;else{if(!(16&v)){if(64&v){if(32&v){i.mode=12;break e}e.msg=\"invalid literal/length code\",i.mode=30;break e}F=g[(65535&F)+(f&(1<>>=v,p-=v),p<15&&(f+=x[n++]<>>=v=F>>>24,p-=v,16&(v=F>>>16&255)){if(A=65535&F,p<(v&=15)&&(f+=x[n++]<c){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(f>>>=v,p-=v,A>(v=s-o)){if((v=A-v)>h&&i.sane){e.msg=\"invalid distance too far back\",i.mode=30;break e}if(C=0,_=u,0===d){if(C+=l-v,v2;)k[s++]=_[C++],k[s++]=_[C++],k[s++]=_[C++],y-=3;y&&(k[s++]=_[C++],y>1&&(k[s++]=_[C++]))}else{C=s-A;do{k[s++]=k[C++],k[s++]=k[C++],k[s++]=k[C++],y-=3}while(y>2);y&&(k[s++]=k[C++],y>1&&(k[s++]=k[C++]))}break}if(64&v){e.msg=\"invalid distance code\",i.mode=30;break e}F=m[(65535&F)+(f&(1<>3,f&=(1<<(p-=y<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n{var n=i(9805),r=i(3269),s=i(4823),o=i(7293),a=i(1998),c=0,l=-2,h=1,d=12,u=30,f=852,p=592;function g(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(f),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,c):l}function b(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,w(e)):l}function F(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,b(e))):l}function v(e,t){var i,n;return e?(n=new m,e.state=n,n.window=null,(i=F(e,t))!==c&&(e.state=null),i):l}var y,A,C=!0;function _(e){if(C){var t;for(y=new n.Buf32(512),A=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,y,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,A,0,e.work,{bits:5}),C=!1}e.lencode=y,e.lenbits=9,e.distcode=A,e.distbits=5}function x(e,t,i,r){var s,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(n.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,t,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,t,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=s(i.check,O,2,0),v=0,y=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg=\"incorrect header check\",i.mode=u;break}if(8!=(15&v)){e.msg=\"unknown compression method\",i.mode=u;break}if(y-=4,T=8+(15&(v>>>=4)),0===i.wbits)i.wbits=T;else if(T>i.wbits){e.msg=\"invalid window size\",i.mode=u;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=3;case 3:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>8&255,O[2]=v>>>16&255,O[3]=v>>>24&255,i.check=s(i.check,O,4,0)),v=0,y=0,i.mode=4;case 4:for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>8),512&i.flags&&(O[0]=255&v,O[1]=v>>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0,i.mode=5;case 5:if(1024&i.flags){for(;y<16;){if(0===b)break e;b--,v+=f[m++]<>>8&255,i.check=s(i.check,O,2,0)),v=0,y=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((k=i.length)>b&&(k=b),k&&(i.head&&(T=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,f,m,k,T)),512&i.flags&&(i.check=s(i.check,f,k,m)),b-=k,m+=k,i.length-=k),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===b)break e;k=0;do{T=f[m+k++],i.head&&T&&i.length<65536&&(i.head.name+=String.fromCharCode(T))}while(T&&k>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=d;break;case 10:for(;y<32;){if(0===b)break e;b--,v+=f[m++]<>>=7&y,y-=7&y,i.mode=27;break}for(;y<3;){if(0===b)break e;b--,v+=f[m++]<>>=1)){case 0:i.mode=14;break;case 1:if(_(i),i.mode=20,6===t){v>>>=2,y-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=u}v>>>=2,y-=2;break;case 14:for(v>>>=7&y,y-=7&y;y<32;){if(0===b)break e;b--,v+=f[m++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=u;break}if(i.length=65535&v,v=0,y=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(k=i.length){if(k>b&&(k=b),k>F&&(k=F),0===k)break e;n.arraySet(p,f,m,k,w),b-=k,m+=k,F-=k,w+=k,i.length-=k;break}i.mode=d;break;case 17:for(;y<14;){if(0===b)break e;b--,v+=f[m++]<>>=5,y-=5,i.ndist=1+(31&v),v>>>=5,y-=5,i.ncode=4+(15&v),v>>>=4,y-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=u;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,y-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,z={bits:i.lenbits},L=a(0,i.lens,0,19,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid code lengths set\",i.mode=u;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=E,y-=E,i.lens[i.have++]=B;else{if(16===B){for(H=E+2;y>>=E,y-=E,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=u;break}T=i.lens[i.have-1],k=3+(3&v),v>>>=2,y-=2}else if(17===B){for(H=E+3;y>>=E)),v>>>=3,y-=3}else{for(H=E+7;y>>=E)),v>>>=7,y-=7}if(i.have+k>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=u;break}for(;k--;)i.lens[i.have++]=T}}if(i.mode===u)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=u;break}if(i.lenbits=9,z={bits:i.lenbits},L=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,z),i.lenbits=z.bits,L){e.msg=\"invalid literal/lengths set\",i.mode=u;break}if(i.distbits=6,i.distcode=i.distdyn,z={bits:i.distbits},L=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,z),i.distbits=z.bits,L){e.msg=\"invalid distances set\",i.mode=u;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(b>=6&&F>=258){e.next_out=w,e.avail_out=F,e.next_in=m,e.avail_in=b,i.hold=v,i.bits=y,o(e,C),w=e.next_out,p=e.output,F=e.avail_out,m=e.next_in,f=e.input,b=e.avail_in,v=i.hold,y=i.bits,i.mode===d&&(i.back=-1);break}for(i.back=0;N=(P=i.lencode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,i.length=B,0===N){i.mode=26;break}if(32&N){i.back=-1,i.mode=d;break}if(64&N){e.msg=\"invalid literal/length code\",i.mode=u;break}i.extra=15&N,i.mode=22;case 22:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;N=(P=i.distcode[v&(1<>>16&255,B=65535&P,!((E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>M)])>>>16&255,B=65535&P,!(M+(E=P>>>24)<=y);){if(0===b)break e;b--,v+=f[m++]<>>=M,y-=M,i.back+=M}if(v>>>=E,y-=E,i.back+=E,64&N){e.msg=\"invalid distance code\",i.mode=u;break}i.offset=B,i.extra=15&N,i.mode=24;case 24:if(i.extra){for(H=i.extra;y>>=i.extra,y-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=u;break}i.mode=25;case 25:if(0===F)break e;if(k=C-F,i.offset>k){if((k=i.offset-k)>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=u;break}k>i.wnext?(k-=i.wnext,I=i.wsize-k):I=i.wnext-k,k>i.length&&(k=i.length),S=i.window}else S=p,I=w-i.offset,k=i.length;k>F&&(k=F),F-=k,i.length-=k;do{p[w++]=S[I++]}while(--k);0===i.length&&(i.mode=21);break;case 26:if(0===F)break e;p[w++]=i.length,F--,i.mode=21;break;case 27:if(i.wrap){for(;y<32;){if(0===b)break e;b--,v|=f[m++]<{var n=i(9805),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,i,c,l,h,d,u){var f,p,g,m,w,b,F,v,y,A=u.bits,C=0,_=0,x=0,k=0,I=0,S=0,E=0,N=0,B=0,M=0,R=null,D=0,T=new n.Buf16(16),L=new n.Buf16(16),z=null,H=0;for(C=0;C<=15;C++)T[C]=0;for(_=0;_=1&&0===T[k];k--);if(I>k&&(I=k),0===k)return l[h++]=20971520,l[h++]=20971520,u.bits=1,0;for(x=1;x0&&(0===e||1!==k))return-1;for(L[1]=0,C=1;C<15;C++)L[C+1]=L[C]+T[C];for(_=0;_852||2===e&&B>592)return 1;for(;;){F=C-E,d[_]b?(v=z[H+d[_]],y=R[D+d[_]]):(v=96,y=0),f=1<>E)+(p-=f)]=F<<24|v<<16|y}while(0!==p);for(f=1<>=1;if(0!==f?(M&=f-1,M+=f):M=0,_++,0==--T[C]){if(C===k)break;C=t[i+d[_]]}if(C>I&&(M&m)!==g){for(0===E&&(E=I),w+=x,N=1<<(S=C-E);S+E852||2===e&&B>592)return 1;l[g=M&m]=I<<24|S<<16|w-h}}return 0!==M&&(l[w+M]=C-E<<24|64<<16),u.bits=I,0}},4674:e=>{e.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}},3665:(e,t,i)=>{var n=i(9805);function r(e){for(var t=e.length;--t>=0;)e[t]=0}var s=15,o=16,a=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],c=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);r(d);var u=new Array(60);r(u);var f=new Array(512);r(f);var p=new Array(256);r(p);var g=new Array(29);r(g);var m,w,b,F=new Array(30);function v(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}function y(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?f[e]:f[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function _(e,t,i){e.bi_valid>o-i?(e.bi_buf|=t<>o-e.bi_valid,e.bi_valid+=i-o):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1}function I(e,t,i){var n,r,o=new Array(s+1),a=0;for(n=1;n<=s;n++)o[n]=a=a+i[n-1]<<1;for(r=0;r<=t;r++){var c=e[2*r+1];0!==c&&(e[2*r]=k(o[c]++,c))}}function S(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function E(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function N(e,t,i,n){var r=2*t,s=2*i;return e[r]>1;i>=1;i--)B(e,o,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],B(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,o[2*r]=o[2*i]+o[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,o[2*i+1]=o[2*n+1]=r,e.heap[1]=r++,B(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,o,a,c,l=t.dyn_tree,h=t.max_code,d=t.stat_desc.static_tree,u=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,m=0;for(o=0;o<=s;o++)e.bl_count[o]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(o=l[2*l[2*(n=e.heap[i])+1]+1]+1)>g&&(o=g,m++),l[2*n+1]=o,n>h||(e.bl_count[o]++,a=0,n>=p&&(a=f[n-p]),c=l[2*n],e.opt_len+=c*(o+a),u&&(e.static_len+=c*(d[2*n+1]+a)));if(0!==m){do{for(o=g-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[g]--,m-=2}while(m>0);for(o=g;0!==o;o--)for(n=e.bl_count[o];0!==n;)(r=e.heap[--i])>h||(l[2*r+1]!==o&&(e.opt_len+=(o-l[2*r+1])*l[2*r],l[2*r+1]=o),n--)}}(e,t),I(o,h,e.bl_count)}function D(e,t,i){var n,r,s=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a>=7;n<30;n++)for(F[n]=r<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),o=function(e){var t;for(D(e,e.dyn_ltree,e.l_desc.max_code),D(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?z(e,t,i,n):4===e.strategy||s===r?(_(e,2+(n?1:0),3),M(e,d,u)):(_(e,4+(n?1:0),3),function(e,t,i,n){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,n-4,4),r=0;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(p[i]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){_(e,2,3),x(e,256,d),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},4442:e=>{e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},7392:e=>{class t{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError(\"`maxSize` must be a number greater than 0\");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}e.exports=t},1307:function(e,t,i){var n;n=e=>(()=>{var t=[,e=>{e.exports=\"data:application/wasm;base64,AGFzbQEAAAABOApgAX8Bf2ABfwBgAABgA39/fwF/YAABf2ACf38AYAN/f34BfmACf38Bf2AEf39/fwF/YAN/f38AAyEgAAABAgMDAwMEAQUAAgMCBgcIBwUDAAMHAQcABwcBAwkFAwEAAgYIAX8BQfCgBAsHTgUGbWVtb3J5AgAOY3JlYXRlX2NvbnRleHQACA9kZXN0cm95X2NvbnRleHQACQxzdXBwbHlfaW5wdXQACg9nZXRfbmV4dF9vdXRwdXQACwqNYCDfAgEFf0EAIQECQCAAQQdqIgJBEEkNAEEBIQEgAkEDdiIDQQJGDQBBAiEBIAJBIEkNAEEDIQEgA0EERg0AQQQhASACQTBJDQBBBSEBIANBBkYNAEEGIQEgAkHIAEkNAEEHIQEgAkHYAEkNAEEIIQEgAkGIAUkNAEEJIQEgAkGIAkkNACAAEIGAgIAAIgBBCGpBACAAGw8LAkACQCABQQJ0QcCIgIAAaiIEKAIAIgANAEEAIQACQAJAQQAoAuSIgIAAIgJFDQBBACACKAIANgLkiICAAAwBC0EAEIGAgIAAIgJFDQILIAJBgIB8cSIAIAJBCHZB/wFxIgJyIAE6AAAgAkEIdCAAckGAAmohAEEAIQJBACABQQJ0QYCIgIAAaigCACIDayEFIAMhAQNAIAAgBWoiACACNgIAIAAhAiABIANqIgFBgQJJDQALIAQgADYCAAsgBCAAKAIANgIACyAAC+4HAQd/AkACQAJAAkACQEEALQC0iICAAEUNAEEAQQA6ALSIgIAAQQAoArCIgIAAIgFFDQFBsIiAgAAhAgNAAkACQCABQQhqIgMgASgCBCIEaiIFQQh2Qf8BcSIGDQAgASECDAELAkADQCAFQYCAfHEgBmotAABB/gFHDQFBsIiAgAAhBgNAIAYiBygCACIGIAVHDQALIAcgBSgCADYCACABIAQgBSgCBGpBCGoiBDYCBCAHIAIgAiAFRhshAiADIARqIgVBCHZB/wFxIgYNAAsLIAIoAgAhAgsgAigCACIBDQALC0EAKAKwiICAACIFRQ0AIABBhwJqQYB+cSEDQX8hAkGwiICAACEEQQAhAUGwiICAACEGA0AgBiEHAkAgBSIGKAIEIgUgAEkNACAFIAJPDQAgBSECIAchBCAGIQEgBUEIaiADRw0AIAchBCAFIQIgBiEBDAQLIAYoAgAiBQ0ACyABDQIMAQtBsIiAgAAhBAs/AEEQdCEBIABBiAJqIQdBACEDAkACQEEAKAK4iICAACICRQ0AQQAhBSABIQYMAQtBACABQfCghIAAQf//A2pBgIB8cSIGayICNgK4iICAACACIQULAkAgByAFTQ0AIAcgBWsiByACQQF2IgIgAiAHSRtB//8DaiIHQRB2QABBf0YNAkEAQQAoAriIgIAAIAdBgIB8cSIDajYCuIiAgAALIAZFDQEgBkH/AToAASAGQQAoArCIgIAANgKAAiAGQYQCaiADIAVqQYCAfHFB+H1qIgI2AgAgBkGAAmohAQsgAUGAgHxxIgYgAUEIdkH/AXFyQf8BOgAAIAQgASgCADYCAAJAIAIgAGtBgH5xIgUNACABDwsgASEDAkAgBiABQQhqIgQgAmoiByAFQX9zakGAgHxxRg0AIARB//8DcSEFAkAgAEH3/QNLDQAgBiAEQQh2Qf8BcWpB/gE6AAAgAUEAKAKwiICAADYCACABQYCABCAFayIFNgIEQQAgATYCsIiAgAAQg4CAgAAgBkGEggRqIAIgBWtB+H1qIgU2AgAgBkGBgARqQf8BOgAAIAZBgIIEaiEDIAUgAGtBgH5xIQUMAQsgAiAFaiAAIAVqQX9qQYCAfHFrQYCAfGohBSABIQMLIAMgAygCBCAFazYCBCAFQfgBaiEGIAcgBWtBCHZB/wFxIQUCQANAIAYiB0GAfmohBiAFIgQNAUEBIQUgB0H4AUcNAAsLAkAgB0H4AUYNACACIAFqIAZrQYCAfHEiBSAEakH+AToAACAFIARBCHRqIgVBACgCsIiAgAA2AgAgBSAGNgIEQQAgBTYCsIiAgAAQg4CAgAALIAMPC0EAC3wBAn8CQCAARQ0AAkAgAEGAgHxxIABBCHZB/wFxciIBLQAAIgJB/wFHDQAgAEF4aiIAQQAoArCIgIAANgIAQQAgADYCsIiAgAAgAUH+AToAAEEAQQE6ALSIgIAADwsgACACQQJ0QcCIgIAAaiICKAIANgIAIAIgADYCAAsLawECfwJAQQAoArCIgIAAIgAoAgRB/wFLDQAgAEGAgHxxIgEgAEEIdkH/AXEiAHJBCToAAEEAQQAoArCIgIAAKAIANgKwiICAACABIABBCHRyIgBBACgC5IiAgAA2AgBBACAANgLkiICAAAsLTgECfwJAIAAgAUYNACACRQ0AA0ACQCAALQAAIgMgAS0AACIERg0AQQFBfyADIARLGw8LIAFBAWohASAAQQFqIQAgAkF/aiICDQALC0EAC3gBAX8CQAJAIAAgAU8NACACRQ0BIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ADAILCyAAIAFNDQAgAkUNACABQX9qIQEgAEF/aiEDA0AgAyACaiABIAJqLQAAOgAAIAJBf2oiAg0ACwsgAAssAQF/AkAgAkUNACAAIQMDQCADIAE6AAAgA0EBaiEDIAJBf2oiAg0ACwsgAAuCAQEBfwJAAkAgAEEDcQ0AIAEgAnJBA3ENACACQQRJDQEgAkECdiECIAAhAwNAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIAJBf2oiAg0ADAILCyACRQ0AIAAhAwNAIAMgAS0AADoAACABQQFqIQEgA0EBaiEDIAJBf2oiAg0ACwsgAAuIAQECfwJAQQAtAOiIgIAADQBBAEEBOgDoiICAABCMgICAABCOgICAAAtBoIAIEICAgIAAIgBBgIAENgIAQQJBgICAIBCXgICAACEBIABBFGpCgICAgICAwAA3AgAgAEEQaiAAQaCABGo2AgAgAEEIakIANwMAIAAgAEEgajYCBCAAIAE2AhwgAAsVACAAKAIcEJiAgIAAIAAQgoCAgAALFgAgAEEMaiABNgIAIABBCGpBADYCAAsbACAAKAIcIABBBGogAEEMaigCAEUQloCAgAALVAEDf0EAIQADQEEIIQEgACECA0BBACACQQFxa0GghuLtfnEgAkEBdnMhAiABQX9qIgENAAsgAEECdEHwiICAAGogAjYCACAAQQFqIgBBgAJHDQALC0oAIAJBf3MhAgJAIAFFDQADQCACQf8BcSAALQAAc0ECdEHwiICAAGooAgAgAkEIdnMhAiAAQQFqIQAgAUF/aiIBDQALCyACQX9zC10DAX4BfwF+QgAhAANAQQghASAAIQIDQEIAIAJCAYN9QsKenLzd8pW2SYMgAkIBiIUhAiABQX9qIgENAAsgAKdBA3RB8JCAgABqIAI3AwAgAEIBfCIAQoACUg0ACwtLACACQn+FIQICQCABRQ0AA0AgAkL/AYMgADEAAIWnQQN0QfCQgIAAaikDACACQgiIhSECIABBAWohACABQX9qIgENAAsLIAJCf4UL1RACDH8CfgJAAkAgACgCJEUNACAAKAIAIQIMAQtBACECIABBADoAKCAAQgA3AwAgAEIANwMYIABByABqQQBB5AAQhoCAgAAaIABBrAFqQQw2AgALIAAgASgCBCIDNgIQIABBsAFqIQQgAEHgAGohBSAAQcgAaiEGIABBtgFqIQcgAEGoAWohCCABKAIQIQkCQAJAAkACQANAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAIAIOCgECAAQFBgcICQoPCyABKAIAIQogACgCqAEhAiAAKAKsASELIAEoAgQhDCABKAIIIQ0MAgsgCCAAKAKoASIMakEIaiABKAIAIAEoAgQiAmogASgCCCACayICIAAoAqwBIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0RIABBATYCAAJAIARBqIiAgABBBhCEgICAAEUNAEEFIQwMEgsgB0ECQQAQjYCAgAAgACgAuAFHDRBBBiEMIActAAANESAAIAAtALcBIgI2AiAgAkEESw0RQQEgAnRBE3FFDRELIAEoAgQiDCABKAIIIg1GDQ4CQCABKAIAIgogDGotAAAiCw0AIAAgDDYCECABIAxBAWo2AgRBBiECDAwLQQAhAiAAQQA2AqgBIABBAjYCACAAIAtBAnRBBGoiCzYCrAEgACALNgJACyAIIAJqQQhqIAogDGogDSAMayIMIAsgAmsiAiAMIAJJGyICEIeAgIAAGiABIAIgASgCBGo2AgRBACEMIABBACAAKAKoASACaiICIAIgACgCrAEiC0YbNgKoASACIAtHDQ8gACACQXxqIgI2AqwBQQchDCAEIAJBABCNgICAACAAIAAoAqwBIgtqQbABaigAAEcNDyAAQQI2AqgBIAAtALEBIgJBP3ENDAJAAkAgAkHAAHFFDQAgACAEIAggCxCRgICAAEEBRw0RIAAgACkDCDcDMCAALQCxASECDAELIABCfzcDMAtCfyEOAkAgAkEYdEEYdUF/Sg0AIAAgBCAIIAAoAqwBEJGAgIAAQQFHDRAgACkDCCEOCyAAIA43AzggACgCrAEiDSAAKAKoASICa0ECSQ0PIAAgAkEBaiIKNgKoASAIIAJqQQhqLQAAQSFHDQwgACACQQJqIgs2AqgBIAggCmpBCGotAABBAUcNDCANIAtGDQ8gACACQQNqNgKoASAAKAKwCSAIIAtqQQhqLQAAEJyAgIAAIgwNDyAAKAKoASIMIAAoAqwBIgIgDCACSxshDQJAA0AgDSAMRg0BIAggDEEBaiICNgIAIAQgDGohCyACIQwgCy0AAA0ODAALCyAGQgA3AwAgAEEANgKoASAAQQM2AgAgBkEIakIANwMACyAAIAEoAgQ2AhAgACABKAIQNgIUIAAoArAJIAEQmYCAgAAhDCAAIAApA0ggASgCBCAAKAIQa618Ig43A0ggACAAKQNQIAEoAhAgACgCFCICayILrXwiDzcDUCAOIAApAzBWDQ0gDyAAKQM4Vg0NAkACQAJAAkAgACgCIEF/ag4EAAMDAQMLIAEoAgwgAmogCyAAKAIYEI2AgIAArSEODAELIAEoAgwgAmogCyAAKQMYEI+AgIAAIQ4LIAAgDjcDGAsgDEEBRw0OAkAgACkDMCIOQn9RDQAgDiAGKQMAUg0OCwJAIAApAzgiDkJ/UQ0AQQchDCAOIAApA1BSDQ8LIAAgACkDSCAANQJAfCAAKQNgfCIPNwNgQgQhDgJAAkACQCAAKAIgQX9qDgQBAgIAAgtCCCEOCyAFIA4gD3w3AwALIAAgACkDaCAAKQNQfDcDaCAAIAVBGCAAKAJwEI2AgIAANgJwIABBBDYCACAAIAApA1hCAXw3A1gLAkAgBikDACIOQgODUA0AIA5CAXwhDiABKAIEIQwgASgCCCELA0AgCyAMRg0NIAEgDEEBaiICNgIEIAEoAgAgDGotAAANDiAGIA43AwAgDkIDgyEPIA5CAXwhDiACIQwgD0IAUg0ACwsgAEEFNgIAC0EBIQIgACgCIEF/ag4EBgcHBQcLIAAgARCSgICAACIMQQFHDQsgAEEHNgIAC0EAIAAoAhBrIQggAEGAAWopAwAhDiABKAIEIQwCQANAIA4gCCAMaq18QgODUA0BAkAgDCABKAIIRw0AIAAgARCTgICAAAwLCyABIAxBAWoiAjYCBCABKAIAIAxqIQsgAiEMIAstAAANCwwACwsgACABEJOAgIAAQQchDCAFIABBkAFqQRgQhICAgAANCiAAQQg2AgALIAAgAUEgEJSAgIAAIgxBAUcNCSAAQQk2AgBBDCELIABBDDYCrAEMAQsgACgCrAEhCwsgAEGoAWogACgCqAEiDGpBCGogASgCACABKAIEIgJqIAEoAgggAmsiAiALIAxrIgwgAiAMSRsiAhCHgICAABogASABKAIEIAJqNgIEQQAhDCAAQQAgACgCqAEgAmoiAiACIAAoAqwBIgtGGzYCqAEgAiALRw0HIAAQlYCAgAAhDAwHC0EBIQIgACABQcAAEJSAgIAAIgxBAUcNBgwBC0EBIQIgACABQSAQlICAgAAiDEEBRw0FCyAAIAI2AgAMAAsLQQYhDAwCC0EAIQwMAQtBByEMCwJAAkAgACgCJA0AAkACQCAMDgIAAwELQQdBCCABKAIEIAEoAghGGyEMCyABIAk2AhAgASADNgIEIAwPCwJAIAwNACADIAEoAgRHDQAgCSABKAIQRw0AIAAtACghASAAQQE6ACggAUEDdA8LIABBADoAKAsgDAuaAQEDfwJAIAAoAgQiBA0AIABCADcDCAsgAigCACEFA0ACQCAFIANJDQBBAA8LIAEgBWotAAAhBiACIAVBAWoiBTYCACAAIAZB/wBxrSAErYYgACkDCIQ3AwgCQAJAIAZBgAFxDQACQCAGDQBBByEGIAQNAgsgAEEANgIEQQEPC0EHIQYgACAEQQdqIgQ2AgQgBEE/Rw0BCwsgBguhAgIDfwF+IABBkAFqIQIgAUEEaiEDA0ACQCAAIAEoAgAgAyABKAIIEJGAgIAAIgRBAUYNACAAQYABaiIDIAMpAwAgASgCBCAAKAIQIgNrIgKtfDcDACAAIAMgASgCAGogAiAAKAIYEI2AgIAArTcDGCAEDwsCQAJAAkACQAJAIAAoAngOAwACAQMLIAAgACkDCCIFNwOIAQJAIAUgACkDWFENAEEHDwsgAEEBNgJ4DAMLIAAgACkDmAEgACkDCHw3A5gBIAAgAkEYIAAoAqABEI2AgIAANgKgASAAQQE2AnggACAAKQOIAUJ/fCIFNwOIAQwCCyAAQQI2AnggACAAKQOQASAAKQMIfDcDkAELIAApA4gBIQULIAVCAFINAAtBAQtAAQJ/IABBgAFqIgIgAikDACABKAIEIAAoAhAiAmsiA618NwMAIAAgAiABKAIAaiADIAAoAhgQjYCAgACtNwMYC3wBBH8gASgCBCEDIAEoAgghBANAAkAgBCADRw0AQQAPCyABIANBAWoiBTYCBAJAIAEoAgAgA2otAAAgACkDGCAAKAIEIgOtiKdB/wFxRg0AQQcPCyAAIANBCGoiBjYCBCAFIQMgBiACSQ0ACyAAQQA2AgQgAEIANwMYQQELbwEBf0EHIQECQCAAQboBai8AAEHZtAFHDQAgAEG0AWpBBkEAEI2AgIAAIABBsAFqKAAARw0AIABBgAFqKQMAQgKIIAA1ALQBUg0AIABBuAFqLQAADQBBAUEHIAAoAiAgAEG5AWotAABGGyEBCyABC7QCAQR/AkACQCAAKAIkRQ0AIAAoAgAhAwwBC0EAIQMgAEEAOgAoIABCADcDACAAQgA3AxggAEHIAGpBAEHkABCGgICAABogAEGsAWpBDDYCAEEBIQILIABByABqIQQCQAJAA0ACQCADQQpHDQAgASgCBCIDIAEoAggiBUYNAiABKAIAIQYCQANAIAYgA2otAAANASABIANBAWoiAzYCBCAAIAAoAgRBAWpBA3E2AgQgBSADRg0EDAALCwJAIAAoAgRFDQBBBw8LIAAoAiRFDQAgAEEAOgAoIABCADcDACAAQgA3AxggBEEAQeQAEIaAgIAAGiAAQQw2AqwBCyAAIAEQkICAgAAiA0EBRw0CQQohAyAAQQo2AgAMAAsLAkAgAg0AQQAPC0EHQQEgACgCBBshAwsgAwt1AQF/AkBBuAkQgICAgAAiAkUNACACIAA2AiQgAiAAIAEQm4CAgAAiADYCsAkCQCAARQ0AIAJBADoAKCACQgA3AwAgAkIANwMYIAJByABqQQBB5AAQhoCAgAAaIAJBrAFqQQw2AgAgAg8LIAIQgoCAgAALQQALHgACQCAARQ0AIAAoArAJEJ2AgIAAIAAQgoCAgAALC4ARAQx/IABB6N0BaiECIABB1ABqIQMgAEEcaiIEQQhqIQUCQAJAA0AgACgCQCEGAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgASgCBCIHIAEoAggiCEkNACAGQQdGDQEMEgsgBg4JAQIDBAUGBwAJDwsgACgCTCEGDAcLQQEhCSABIAdBAWo2AgQgASgCACAHai0AACIHRQ0IAkACQCAHQd8BSw0AIAdBAUcNAQsgAEGAAjsBUAJAIAAoAjwNACAAIAEoAgwgASgCECIGajYCGCAAIAEoAhQgBms2AiwLIARCADcCACAFQgA3AgAMCwsgAC0AUEUNCgwOCyABIAdBAWo2AgQgASgCACAHai0AACEHIABBAjYCQCAAIAdBCHQgACgCSGo2AkgMDAsgASAHQQFqNgIEIAEoAgAgB2otAAAhByAAQQM2AkAgACAHIAAoAkhqQQFqNgJIDAsLIAEgB0EBajYCBCABKAIAIAdqLQAAIQcgAEEENgJAIAAgB0EIdDYCTAwKCyABIAdBAWo2AgQgASgCACAHai0AACEHIAAgACgCRDYCQCAAIAcgACgCTGpBAWo2AkwMCQsgASAHQQFqNgIEQQchCSABKAIAIAdqLQAAIgdB4AFLDQNBACEGAkACQCAHQS1PDQBBACEIDAELIAdBU2oiByAHQf8BcUEtbiIIQS1sayEHIAhBAWohCAsgAEF/IAh0QX9zNgJ0AkAgB0H/AXFBCUkNACAHQXdqIgcgB0H/AXFBCW4iBkEJbGshByAGQQFqIQYLIAAgBjYCcCAAIAdB/wFxIgc2AmwgBiAHakEESw0DIANCADcCACADQQhqQgA3AgAgA0EQakEANgIAIABBfyAGdEF/czYCcEH4ACEHA0AgACAHakGACDsBACAHQQJqIgdB5N0BRw0ACyAAQQY2AkAgAEEFNgIIIABC/////w83AgALIAAoAkwiCUEFSQ0IAkAgACgCCCIHRQ0AIAdBf2ohBiABKAIEIQcgASgCCCEKA0AgCiAHRg0LIAEgB0EBaiIINgIEIAEoAgAgB2otAAAhByAAIAY2AgggACAHIAAoAgRBCHRyNgIEIAghByAGQX9qIgZBf0cNAAsLIABBBzYCQCAAIAlBe2oiBjYCTAsgACAAKAIgIgcgASgCFCABKAIQayIIIAAoAkgiCiAIIApJGyIIaiAAKAIsIgogCiAHayAISxs2AiggASgCCCIJIAEoAgQiCGshBwJAAkACQCAAKALk3QEiCg0AIAYNAUEAIQYLIABB5N0BaiILIApqQQRqIAEoAgAgCGogByAGIAprIgZBKiAKayIIIAggBksbIgYgBiAHSxsiBxCHgICAABoCQAJAIAcgACgC5N0BIghqIgYgACgCTEcNACALIAhqIAdqQQRqQQBBPyAGaxCGgICAABogACgC5N0BIAdqIQYMAQsCQCAGQRRLDQAgACAGNgLk3QEgASABKAIEIAdqNgIEDAMLIAZBa2ohBgsgAEEANgIQIAAgAjYCDCAAIAY2AhRBByEJIAAQmoCAgABFDQMgACgCECIIIAAoAuTdASIKIAdqSw0DIAAgACgCTCAIayIGNgJMAkAgCiAITQ0AIAAgCiAIayIHNgLk3QEgAiALIAhqQQRqIAcQhYCAgAAaDAILIABBADYC5N0BIAEgASgCBCAIIApraiIINgIEIAEoAggiCSAIayEHCwJAIAdBFUkNACAAIAg2AhAgACABKAIANgIMIAAgCUFraiAIIAZqIAcgBkEVakkbNgIUQQchCSAAEJqAgIAARQ0DIAAoAkwiByAAKAIQIgggASgCBGsiBkkNAyABIAg2AgQgACAHIAZrIgY2AkwgASgCCCAIayIHQRRLDQELIAIgASgCACAIaiAGIAcgByAGSxsiBxCHgICAABogACAHNgLk3QEgASABKAIEIAdqNgIECyAAKAIgIgYgACgCHCIIayEHAkAgACgCPEUNAAJAIAYgACgCLEcNACAAQQA2AiALIAEoAgwgASgCEGogACgCGCAIaiAHEIeAgIAAGiAAKAIgIQYLIAAgBjYCHCABIAEoAhAgB2oiBjYCECAAIAAoAkggB2siBzYCSAJAIAcNAEEHIQkgACgCTA0CIAAoAmgNAiAAKAIEDQIgAEEANgJADAULQQAhCSAGIAEoAhRGDQEgASgCBCABKAIIRw0GIAAoAuTdASAAKAJMTw0GDAELIAAoAkwiCkUNAUEAIQkgCCAHTQ0AA0AgASgCFCIGIAEoAhAiC00NASAAIAogCiAAKAIsIAAoAiAiDGsiDSAIIAdrIgggBiALayIGIAggBkkbIgYgBiANSxsiBiAGIApLGyIGazYCTCAMIAAoAhhqIAEoAgAgB2ogBhCFgICAABogACAAKAIgIAZqIgc2AiACQCAAKAIkIAdPDQAgACAHNgIkCwJAIAAoAjxFDQACQCAHIAAoAixHDQAgAEEANgIgCyABKAIMIAEoAhBqIAEoAgAgASgCBGogBhCFgICAABogACgCICEHCyAAIAc2AhwgASABKAIQIAZqNgIQIAEgASgCBCAGaiIHNgIEIAAoAkwiCkUNAiABKAIIIgggB0sNAAsLIAkPCyAAQQA2AkAMAwsgB0EYdEEYdUF/Sg0BIABBATYCQCAAIAdBEHRBgID8AHE2AkgCQCAHQcABSQ0AIABBBTYCRCAAQQA6AFEMAwsgAC0AUQ0DIABBBjYCRCAHQaABSQ0CIANCADcCACADQRBqQQA2AgAgA0EIakIANwIAQfgAIQcDQCAAIAdqQYAIOwEAIAdBAmoiB0Hk3QFHDQALCyAAQQU2AgggAEL/////DzcCAAwBCyAHQQJLDQEgAEKDgICAgAE3AkAMAAsLQQcPC0EAC/8XARJ/IABBGGohAQJAIABBIGooAgAiAiAAQShqKAIAIgNPDQAgAEHoAGoiBCgCAEUNACABIAQgACgCVBCegICAABogACgCKCEDIAAoAiAhAgsCQCACIANPDQAgAEHcDWohBSAAQegAaiEGIABB4BVqIQcgAEHUAGohCANAIAAoAhAiCSAAKAIUSw0BIAAgACgCZCIKQQV0aiAAKAJ0IAJxIgtBAXRqIgxB+ABqIQ0CQAJAIAAoAgAiBEGAgIAISQ0AIAAoAgQhDgwBCyAAIARBCHQiBDYCACAAIAlBAWoiAzYCECAAIAAoAgRBCHQgACgCDCAJai0AAHIiDjYCBCADIQkLAkACQCAOIARBC3YgDS8BACIPbCIDTw0AIAAgAzYCACANIA9BgBAgD2tBBXZqOwEAIAJBf2ohBAJAIAINACAAKAIsIARqIQQLAkACQCAAKAIkIg8NAEEAIQQMAQsgACgCGCAEai0AACEECyAAKAJwIAJxIAAoAmwiDXQgBEEIIA1rdmohDAJAAkAgCkEGSw0AQQEhBANAIAAgDEGADGxqIARBAXQiBGpB5B1qIQ0CQAJAIANB////B00NACADIQoMAQsgACADQQh0Igo2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiAKQQt2IA0vAQAiD2wiA0kNACAAIA4gA2siDjYCBCAAIAogA2siAzYCACANIA8gD0EFdms7AQAgBEEBciEEDAELIAAgAzYCACANIA9BgBAgD2tBBXZqOwEACyAEQYACSQ0ADAILCyACIAAoAlQiDUF/c2ohBAJAIAIgDUsNACAAKAIsIARqIQQLAkACQCAPDQBBACEQDAELIAAoAhggBGotAAAhEAtBASEEQYACIQ0DQCAAIAxBgAxsaiAQQQF0IhAgDXEiESANaiAEakEBdGpB5B1qIQ8CQAJAIANB////B00NACADIQsMAQsgACADQQh0Igs2AgAgACAJQQFqIgM2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQgAyEJCwJAAkAgDiALQQt2IA8vAQAiCmwiA08iEg0AIAAgAzYCACAKQYAQIAprQQV2aiEKDAELIAAgDiADayIONgIEIAAgCyADayIDNgIAIAogCkEFdmshCkEAIQ0LIA8gCjsBACANIBFzIQ0gBEEBdCASciIEQYACSQ0ACwsgACACQQFqNgIgIAAoAhggAmogBDoAAAJAIAAoAiQgACgCICICTw0AIAAgAjYCJAtBACEDAkAgACgCZCIEQQRJDQACQCAEQQlLDQAgBEF9aiEDDAELIARBemohAwsgACADNgJkDAELIAAgDiADayIONgIEIAAgBCADayIDNgIAIA0gDyAPQQV2azsBACAAIApBAXRqIg9B+ANqIQQCQAJAIANB////B00NACAJIQoMAQsgACADQQh0IgM2AgAgACAJQQFqIgo2AhAgACAOQQh0IAAoAgwgCWotAAByIg42AgQLAkACQCAOIANBC3YgBC8BACINbCIJSQ0AIAAgDiAJayIONgIEIAAgAyAJayIDNgIAIAQgDSANQQV2azsBACAPQZAEaiENAkACQCADQf///wdNDQAgCiEQDAELIAAgA0EIdCIDNgIAIAAgCkEBaiIQNgIQIAAgDkEIdCAAKAIMIApqLQAAciIONgIECwJAAkAgDiADQQt2IA0vAQAiCWwiBE8NACANIAlBgBAgCWtBBXZqOwEAIAxB2ARqIQMCQCAEQf///wdLDQAgACAEQQh0IgQ2AgAgACAQQQFqNgIQIAAgDkEIdCAAKAIMIBBqLQAAciIONgIECwJAIA4gBEELdiADLwEAIg1sIglJDQAgACAOIAlrNgIEIAAgBCAJazYCACADIA0gDUEFdms7AQAMAgsgAyANQYAQIA1rQQV2ajsBACAAIAk2AgAgAEEBNgJoIABBCUELIAAoAmRBB0kbNgJkDAMLIAAgDiAEayIONgIEIA0gCSAJQQV2azsBACAPQagEaiENAkACQCADIARrIgNB////B00NACAQIQoMAQsgACADQQh0IgM2AgAgACAQQQFqIgo2AhAgACAOQQh0IAAoAgwgEGotAAByIg42AgQLAkACQCAOIANBC3YgDS8BACIEbCIJTw0AIAAgCTYCACANIARBgBAgBGtBBXZqOwEAIAAoAlghAwwBCyAAIA4gCWsiDjYCBCANIAQgBEEFdms7AQAgD0HABGohBAJAIAMgCWsiA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgCkEBajYCECAAIA5BCHQgACgCDCAKai0AAHIiDjYCBAsCQAJAIA4gA0ELdiAELwEAIg1sIglPDQAgACAJNgIAIAQgDUGAECANa0EFdmo7AQAgACgCXCEDDAELIAAgDiAJazYCBCAAIAMgCWs2AgAgACgCYCEDIAAgACgCXDYCYCAEIA0gDUEFdms7AQALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAzYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAHIAsQn4CAgAAMAQsgBCANQYAQIA1rQQV2ajsBACAAIAk2AgAgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIAUgCxCfgICAACAAKAJoIgNBfmpBAyADQQZJGyEKIAAoAgAhA0EBIQ4DQCAAIApBB3RqIA5BAXQiDmpB2AdqIQ0CQAJAIANBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgRBAWo2AhAgACAAKAIEQQh0IAQgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgDS8BACIJbCIPSQ0AIAAgBCAPayIENgIEIAAgAyAPayIDNgIAIA0gCSAJQQV2azsBACAOQQFyIQ4MAQsgACAPNgIAIA0gCUGAECAJa0EFdmo7AQAgDyEDCyAOQcAASQ0ACwJAIA5BQGoiCUEDSw0AIAAgCTYCVAwBCyAAIA5BAXFBAnIiDTYCVCAJQQF2IQ8CQCAJQQ1LDQAgACANIA9Bf2oiDHQiCzYCVEEBIQ0gCCALQQF0akGEC2ohEEE/IA5rIRFBACEPA0AgECARIA1qQQF0aiEOAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA4vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACAOIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDUEBdEEBciENDAELIAAgAzYCACAOIAlBgBAgCWtBBXZqOwEAIA1BAXQhDQsgDCAPQQFqIg9HDQAMAgsLIA9Be2ohDgNAAkAgA0H///8HSw0AIAAgA0EIdCIDNgIAIAAgACgCECIJQQFqNgIQIARBCHQgCSAAKAIMai0AAHIhBAsgACADQQF2IgM2AgAgACAEIANrIgRBH3UiCSANQQF0akEBaiINNgJUIAAgCSADcSAEaiIENgIEIA5Bf2oiDg0ACyAAIA1BBHQiCzYCVEEAIQ9BASEOA0AgACAOQQF0Ig5qQbwNaiENAkACQCADQf///wdNDQAgAyEKDAELIAAgA0EIdCIKNgIAIAAgACgCECIDQQFqNgIQIAAgBEEIdCADIAAoAgxqLQAAciIENgIECwJAAkAgBCAKQQt2IA0vAQAiCWwiA0kNACAAIAQgA2siBDYCBCAAIAogA2siAzYCACANIAkgCUEFdms7AQAgAEEBIA90IAtqIgs2AlQgDkEBciEODAELIAAgAzYCACANIAlBgBAgCWtBBXZqOwEACyAPQQFqIg9BBEcNAAsLAkAgASAGIAAoAlQQnoCAgAANAEEADwsgACgCICECCyACIAAoAihJDQALC0EBIQMCQCAAKAIAIgRB////B0sNACAAIARBCHQ2AgBBASEDIAAgACgCECIEQQFqNgIQIAAgACgCBEEIdCAEIAAoAgxqLQAAcjYCBAsgAwtwAQF/AkBBqN4BEICAgIAAIgJFDQAgAkE0aiABNgIAIAJBPGogADYCAAJAAkACQCAAQX9qDgIAAQILIAIgARCAgICAACIANgIYIAANASACEIKAgIAADAILIAJBADYCGCACQThqQQA2AgALIAIPC0EAC9IBAQJ/QQYhAgJAIAFBJ0sNACAAQTBqIAFBAXFBAnIgAUEBdkELanQiATYCAAJAAkAgAEE8aigCACIDRQ0AQQQhAiABIABBNGooAgBLDQIgAEEsaiABNgIAIANBAkcNACAAQThqIgMoAgAgAU8NACAAIAE2AjggACgCGBCCgICAACAAIAAoAjAQgICAgAAiATYCGCABDQBBAyECDAELQQAhAiAAQQA2AkAgAEHQAGpBAToAACAAQegAakEANgIAIABB5N0BaiEDCyADQQA2AgALIAILIwACQCAAQTxqKAIARQ0AIAAoAhgQgoCAgAALIAAQgoCAgAAL9QEBBH9BACEDAkAgACgCDCACTQ0AIAAoAhggAk0NACABIAEoAgAiBCAAKAIQIAAoAggiBWsiBiAEIAYgBEkbIgRrNgIAIAUgAkF/c2ohAQJAIAUgAksNACAAKAIUIAFqIQELIAAoAgAiAiABai0AACEGQQEhAyAAIAVBAWo2AgggAiAFaiAGOgAAAkAgBEF/aiICRQ0AA0AgACgCACIFQQAgAUEBaiIBIAEgACgCFEYbIgFqLQAAIQQgACAAKAIIIgZBAWo2AgggBSAGaiAEOgAAIAJBf2oiAg0ACwsgACgCDCAAKAIIIgFPDQAgACABNgIMCyADC8gEAQd/AkACQCAAKAIAIgNBgICACEkNACAAKAIEIQQMAQsgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAAKAIEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIANBC3YgAS8BACIGbCIFTw0AIAEgBkGAECAGa0EFdmo7AQAgASACQQR0akEEaiEHQQghCEECIQkMAQsgACAEIAVrIgQ2AgQgASAGIAZBBXZrOwEAAkAgAyAFayIDQf///wdLDQAgACADQQh0IgM2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkAgBCADQQt2IAEvAQIiBmwiBU8NACABIAZBgBAgBmtBBXZqOwECIAEgAkEEdGpBhAJqIQdBCCEIQQohCQwBCyAAIAQgBWsiBDYCBCABIAYgBkEFdms7AQIgAUGEBGohByADIAVrIQVBgAIhCEESIQkLIABB6ABqIAk2AgBBASEBA0AgByABQQF0IgFqIQMCQAJAIAVB////B00NACAFIQIMAQsgACAFQQh0IgI2AgAgACAAKAIQIgVBAWo2AhAgACAEQQh0IAUgACgCDGotAAByIgQ2AgQLAkACQCAEIAJBC3YgAy8BACIGbCIFSQ0AIAAgBCAFayIENgIEIAAgAiAFayIFNgIAIAMgBiAGQQV2azsBACABQQFyIQEMAQsgACAFNgIAIAMgBkGAECAGa0EFdmo7AQALIAEgCEkNAAsgAEHoAGogASAIayAJajYCAAsLNQEAQYAICy4IAAAAEAAAABgAAAAgAAAAKAAAADAAAABAAAAAUAAAAIAAAAAAAQAA/Td6WFoA\"},t=>{t.exports=e}],i={};function n(e){var r=i[e];if(void 0!==r)return r.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{XzReadableStream:()=>s});var e=n(1);const t=globalThis.ReadableStream||n(2).ReadableStream;class i{constructor(e){this.exports=e.exports,this.memory=this.exports.memory,this.ptr=this.exports.create_context(),this._refresh(),this.bufSize=this.mem32[0],this.inStart=this.mem32[1]-this.ptr,this.inEnd=this.inStart+this.bufSize,this.outStart=this.mem32[4]-this.ptr}supplyInput(e){this._refresh(),this.mem8.subarray(this.inStart,this.inEnd).set(e,0),this.exports.supply_input(this.ptr,e.byteLength),this._refresh()}getNextOutput(){const e=this.exports.get_next_output(this.ptr);if(this._refresh(),0!==e&&1!==e)throw new Error(`get_next_output failed with error code ${e}`);return{outChunk:this.mem8.slice(this.outStart,this.outStart+this.mem32[5]),finished:1===e}}needsMoreInput(){return this.mem32[2]===this.mem32[3]}outputBufferIsFull(){return this.mem32[5]===this.bufSize}resetOutputBuffer(){this.outPos=this.mem32[5]=0}dispose(){this.exports.destroy_context(this.ptr),this.exports=null}_refresh(){this.memory.buffer!==this.mem8?.buffer&&(this.mem8=new Uint8Array(this.memory.buffer,this.ptr),this.mem32=new Uint32Array(this.memory.buffer,this.ptr))}}class s extends t{static _moduleInstancePromise;static _moduleInstance;static async _getModuleInstance(){const t=e.replace(\"data:application/wasm;base64,\",\"\"),i=Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer,n=await WebAssembly.instantiate(i,{});s._moduleInstance=n.instance}constructor(e){let t,n=null;const r=e.getReader();super({async start(e){s._moduleInstance||await(s._moduleInstancePromise||(s._moduleInstancePromise=s._getModuleInstance())),t=new i(s._moduleInstance)},async pull(e){if(t.needsMoreInput()){if(null===n||0===n.byteLength){const{done:e,value:t}=await r.read();e||(n=t)}const e=Math.min(t.bufSize,n.byteLength);t.supplyInput(n.subarray(0,e)),n=n.subarray(e)}const i=t.getNextOutput();e.enqueue(i.outChunk),t.resetOutputBuffer(),i.finished&&(t.dispose(),e.close())},cancel:()=>(t.dispose(),r.cancel())})}}})(),r})(),e.exports=n(i(772))},3617:()=>{},772:()=>{},928:(e,t,i)=>{const n=i(2886).default;e.exports=n,e.exports.default=n},1308:(e,t)=>{Object.defineProperty(t,\"__esModule\",{value:!0});let i=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];\"undefined\"!=typeof Int32Array&&(i=new Int32Array(i)),t.default=(e,t)=>{let n=0===t?0:~t;for(let t=0;t>>8;return~n}},2886:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(1308)),s=n(i(7327));t.default=(0,s.default)(\"crc-32\",r.default)},4422:(e,t,i)=>{Object.defineProperty(t,\"__esModule\",{value:!0});const n=i(8287);t.default=(e,t)=>n.Buffer.from(e,t)},7327:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,\"__esModule\",{value:!0});const r=n(i(4422));t.default=function(e,t){const i=(e,i)=>t((0,r.default)(e),i)>>>0;return i.signed=(e,i)=>t((0,r.default)(e),i),i.unsigned=i,i.model=e,i}}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}return i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},i(7806)})(),jp=[],Wp=[],Gp=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,$p=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",Kp=0;Kp<64;++Kp)jp[Kp]=$p[Kp],Wp[$p.charCodeAt(Kp)]=Kp;function Yp(e){var t=e.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var i=e.indexOf(\"=\");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function Xp(e,t,i){for(var n,r,s=[],o=t;o>18&63]+jp[r>>12&63]+jp[r>>6&63]+jp[63&r]);return s.join(\"\")}Wp[\"-\".charCodeAt(0)]=62,Wp[\"_\".charCodeAt(0)]=63;var Zp={byteLength:function(e){var t=Yp(e),i=t[0],n=t[1];return 3*(i+n)/4-n},toByteArray:function(e){var t,i,n=Yp(e),r=n[0],s=n[1],o=new Gp(function(e,t,i){return 3*(t+i)/4-i}(0,r,s)),a=0,c=s>0?r-4:r;for(i=0;i>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===s&&(t=Wp[e.charCodeAt(i)]<<2|Wp[e.charCodeAt(i+1)]>>4,o[a++]=255&t),1===s&&(t=Wp[e.charCodeAt(i)]<<10|Wp[e.charCodeAt(i+1)]<<4|Wp[e.charCodeAt(i+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o},fromByteArray:function(e){for(var t,i=e.length,n=i%3,r=[],s=16383,o=0,a=i-n;oa?a:o+s));return 1===n?(t=e[i-1],r.push(jp[t>>2]+jp[t<<4&63]+\"==\")):2===n&&(t=(e[i-2]<<8)+e[i-1],r.push(jp[t>>10]+jp[t>>4&63]+jp[t<<2&63]+\"=\")),r.join(\"\")}};\n", - "/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */var Jp={read:function(e,t,i,n,r){var s,o,a=8*r-n-1,c=(1<>1,h=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+d],d+=u,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+d],d+=u,h-=8);if(0===s)s=1-l;else{if(s===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=l}return(f?-1:1)*o*Math.pow(2,s-n)},write:function(e,t,i,n,r,s){var o,a,c,l=8*s-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?u/c:u*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=h?(a=0,o=h):o+d>=1?(a=(t*c-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;e[i+f]=255&o,f+=p,o/=256,l-=8);e[i+f-p]|=128*g}};\n", - "/*!\n", - " * The buffer module from node.js, for the browser.\n", - " *\n", - " * @author Feross Aboukhadijeh \n", - " * @license MIT\n", - " */const eg=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null,tg=2147483647;function ig(e){if(e>tg)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,ng.prototype),t}function ng(e,t,i){if(\"number\"==typeof e){if(\"string\"==typeof t)throw new TypeError('The \"string\" argument must be of type string. Received type number');return og(e)}return rg(e,t,i)}function rg(e,t,i){if(\"string\"==typeof e)return function(e,t){\"string\"==typeof t&&\"\"!==t||(t=\"utf8\");if(!ng.isEncoding(t))throw new TypeError(\"Unknown encoding: \"+t);const i=0|hg(e,t);let n=ig(i);const r=n.write(e,t);r!==i&&(n=n.slice(0,r));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Vg(e,Uint8Array)){const t=new Uint8Array(e);return cg(t.buffer,t.byteOffset,t.byteLength)}return ag(e)}(e);if(null==e)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e);if(Vg(e,ArrayBuffer)||e&&Vg(e.buffer,ArrayBuffer))return cg(e,t,i);if(\"undefined\"!=typeof SharedArrayBuffer&&(Vg(e,SharedArrayBuffer)||e&&Vg(e.buffer,SharedArrayBuffer)))return cg(e,t,i);if(\"number\"==typeof e)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return ng.from(n,t,i);const r=function(e){if(ng.isBuffer(e)){const t=0|lg(e.length),i=ig(t);return 0===i.length||e.copy(i,0,0,t),i}if(void 0!==e.length)return\"number\"!=typeof e.length||jg(e.length)?ig(0):ag(e);if(\"Buffer\"===e.type&&Array.isArray(e.data))return ag(e.data)}(e);if(r)return r;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof e[Symbol.toPrimitive])return ng.from(e[Symbol.toPrimitive](\"string\"),t,i);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof e)}function sg(e){if(\"number\"!=typeof e)throw new TypeError('\"size\" argument must be of type number');if(e<0)throw new RangeError('The value \"'+e+'\" is invalid for option \"size\"')}function og(e){return sg(e),ig(e<0?0:0|lg(e))}function ag(e){const t=e.length<0?0:0|lg(e.length),i=ig(t);for(let n=0;n=tg)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+tg.toString(16)+\" bytes\");return 0|e}function hg(e,t){if(ng.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Vg(e,ArrayBuffer))return e.byteLength;if(\"string\"!=typeof e)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case\"ascii\":case\"latin1\":case\"binary\":return i;case\"utf8\":case\"utf-8\":return Ug(e).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*i;case\"hex\":return i>>>1;case\"base64\":return qg(e).length;default:if(r)return n?-1:Ug(e).length;t=(\"\"+t).toLowerCase(),r=!0}}function dg(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return\"\";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return\"\";if((i>>>=0)<=(t>>>=0))return\"\";for(e||(e=\"utf8\");;)switch(e){case\"hex\":return xg(this,t,i);case\"utf8\":case\"utf-8\":return yg(this,t,i);case\"ascii\":return Cg(this,t,i);case\"latin1\":case\"binary\":return _g(this,t,i);case\"base64\":return vg(this,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return kg(this,t,i);default:if(n)throw new TypeError(\"Unknown encoding: \"+e);e=(e+\"\").toLowerCase(),n=!0}}function ug(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function fg(e,t,i,n,r){if(0===e.length)return-1;if(\"string\"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),jg(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if(\"string\"==typeof t&&(t=ng.from(t,n)),ng.isBuffer(t))return 0===t.length?-1:pg(e,t,i,n,r);if(\"number\"==typeof t)return t&=255,\"function\"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):pg(e,[t],i,n,r);throw new TypeError(\"val must be string, number or Buffer\")}function pg(e,t,i,n,r){let s,o=1,a=e.length,c=t.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,i/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;sa&&(i=a-c),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function vg(e,t,i){return 0===t&&i===e.length?Zp.fromByteArray(e):Zp.fromByteArray(e.slice(t,i))}function yg(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,c;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(c=(31&t)<<6|63&i,c>127&&(s=c));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(c=(15&t)<<12|(63&i)<<6|63&n,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=Ag)return String.fromCharCode.apply(String,e);let i=\"\",n=0;for(;nn.length?(ng.isBuffer(t)||(t=ng.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!ng.isBuffer(t))throw new TypeError('\"list\" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},ng.byteLength=hg,ng.prototype._isBuffer=!0,ng.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let t=0;tt&&(e+=\" ... \"),\"\"},eg&&(ng.prototype[eg]=ng.prototype.inspect),ng.prototype.compare=function(e,t,i,n,r){if(Vg(e,Uint8Array)&&(e=ng.from(e,e.offset,e.byteLength)),!ng.isBuffer(e))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError(\"out of range index\");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),c=this.slice(n,r),l=e.slice(t,i);for(let e=0;e>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n=\"utf8\")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let s=!1;for(;;)switch(n){case\"hex\":return gg(this,e,t,i);case\"utf8\":case\"utf-8\":return mg(this,e,t,i);case\"ascii\":case\"latin1\":case\"binary\":return wg(this,e,t,i);case\"base64\":return bg(this,e,t,i);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return Fg(this,e,t,i);default:if(s)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),s=!0}},ng.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const Ag=4096;function Cg(e,t,i){let n=\"\";i=Math.min(e.length,i);for(let r=t;rn)&&(i=n);let r=\"\";for(let n=t;ni)throw new RangeError(\"Trying to access beyond buffer length\")}function Sg(e,t,i,n,r,s){if(!ng.isBuffer(e))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError(\"Index out of range\")}function Eg(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function Ng(e,t,i,n,r){zg(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function Bg(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError(\"Index out of range\");if(i<0)throw new RangeError(\"Index out of range\")}function Mg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,4),Jp.write(e,t,i,n,23,4),i+4}function Rg(e,t,i,n,r){return t=+t,i>>>=0,r||Bg(e,0,i,8),Jp.write(e,t,i,n,52,8),i+8}ng.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},ng.prototype.readUint8=ng.prototype.readUInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),this[e]},ng.prototype.readUint16LE=ng.prototype.readUInt16LE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]|this[e+1]<<8},ng.prototype.readUint16BE=ng.prototype.readUInt16BE=function(e,t){return e>>>=0,t||Ig(e,2,this.length),this[e]<<8|this[e+1]},ng.prototype.readUint32LE=ng.prototype.readUInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ng.prototype.readUint32BE=ng.prototype.readUInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ng.prototype.readBigUInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<>>=0,t>>>=0,i||Ig(e,t,this.length);let n=this[e],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*t)),n},ng.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||Ig(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},ng.prototype.readInt8=function(e,t){return e>>>=0,t||Ig(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ng.prototype.readInt16LE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt16BE=function(e,t){e>>>=0,t||Ig(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},ng.prototype.readInt32LE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ng.prototype.readInt32BE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ng.prototype.readBigInt64LE=Gg((function(e){Hg(e>>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<>>=0,\"offset\");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||Pg(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!0,23,4)},ng.prototype.readFloatBE=function(e,t){return e>>>=0,t||Ig(e,4,this.length),Jp.read(this,e,!1,23,4)},ng.prototype.readDoubleLE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!0,52,8)},ng.prototype.readDoubleBE=function(e,t){return e>>>=0,t||Ig(e,8,this.length),Jp.read(this,e,!1,52,8)},ng.prototype.writeUintLE=ng.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t>>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=1,s=0;for(this[t]=255&e;++s>>=0,i>>>=0,!n){Sg(this,e,t,i,Math.pow(2,8*i)-1,0)}let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},ng.prototype.writeUint8=ng.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,255,0),this[t]=255&e,t+1},ng.prototype.writeUint16LE=ng.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeUint16BE=ng.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeUint32LE=ng.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},ng.prototype.writeUint32BE=ng.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigUInt64LE=Gg((function(e,t=0){return Eg(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeBigUInt64BE=Gg((function(e,t=0){return Ng(this,e,t,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),ng.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r>>=0,!n){const n=Math.pow(2,8*i-1);Sg(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s|0)-o&255;return t+i},ng.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},ng.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},ng.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},ng.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},ng.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||Sg(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},ng.prototype.writeBigInt64LE=Gg((function(e,t=0){return Eg(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeBigInt64BE=Gg((function(e,t=0){return Ng(this,e,t,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),ng.prototype.writeFloatLE=function(e,t,i){return Mg(this,e,t,!0,i)},ng.prototype.writeFloatBE=function(e,t,i){return Mg(this,e,t,!1,i)},ng.prototype.writeDoubleLE=function(e,t,i){return Rg(this,e,t,!0,i)},ng.prototype.writeDoubleBE=function(e,t,i){return Rg(this,e,t,!1,i)},ng.prototype.copy=function(e,t,i,n){if(!ng.isBuffer(e))throw new TypeError(\"argument should be a Buffer\");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),e.length-t>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),\"number\"==typeof e)for(r=t;r=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function zg(e,t,i,n,r,s){if(e>i||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new Dg.ERR_OUT_OF_RANGE(\"value\",r,e)}!function(e,t,i){Hg(t,\"offset\"),void 0!==e[t]&&void 0!==e[t+i]||Pg(t,e.length-(i+1))}(n,r,s)}function Hg(e,t){if(\"number\"!=typeof e)throw new Dg.ERR_INVALID_ARG_TYPE(t,\"number\",e)}function Pg(e,t,i){if(Math.floor(e)!==e)throw Hg(e,i),new Dg.ERR_OUT_OF_RANGE(i||\"offset\",\"an integer\",e);if(t<0)throw new Dg.ERR_BUFFER_OUT_OF_BOUNDS;throw new Dg.ERR_OUT_OF_RANGE(i||\"offset\",`>= ${i?1:0} and <= ${t}`,e)}Tg(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(e){return e?`${e} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),Tg(\"ERR_INVALID_ARG_TYPE\",(function(e,t){return`The \"${e}\" argument must be of type number. Received type ${typeof t}`}),TypeError),Tg(\"ERR_OUT_OF_RANGE\",(function(e,t,i){let n=`The value of \"${e}\" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=Lg(String(i)):\"bigint\"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=Lg(r)),r+=\"n\"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const Og=/[^+/0-9A-Za-z-_]/g;function Ug(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error(\"Invalid code point\");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function qg(e){return Zp.toByteArray(function(e){if((e=(e=e.split(\"=\")[0]).trim().replace(Og,\"\")).length<2)return\"\";for(;e.length%4!=0;)e+=\"=\";return e}(e))}function Qg(e,t,i,n){let r;for(r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Vg(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function jg(e){return e!=e}const Wg=function(){const e=\"0123456789abcdef\",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function Gg(e){return\"undefined\"==typeof BigInt?$g:e}function $g(){throw new Error(\"BigInt not supported\")}class Kg{constructor(e,t){this.position=0,this.url=e,this.config=t,Ht(e)||!1===t.cacheFetches?this.useCache=!1:(this.useCache=!0,this.cache=new Yg({fetch:(e,t)=>this._fetch(e,t),fetchSize:t.fetchSize||1e4}))}async _fetch(e,t){const i={start:e,size:t};this._stat={size:void 0};const n=await Qs.loadArrayBuffer(this.url,Ua(this.config,{range:i}));return ng.from(n)}async read(e,t=0,i=1/0,n=0){if(this.useCache)await this.cache.get(e,t,n,i);else{(await this._fetch(n,i)).copy(e,t)}return{bytesRead:i,buffer:e}}async readFile(){const e=await Qs.loadArrayBuffer(this.url,Ua(this.config));return ng.from(e)}async stat(){if(!this._stat){const e=ng.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class Yg{constructor({fetch:e,fetchSize:t=3e4}){this.fetch=e,this.position=0,this.buffer=ng.allocUnsafe(0),this.fetchSize=t}async get(e,t,i,n){if(e.length=this.position&&i+n<=this.position+this.buffer.length);else{const e=Math.max(n,this.fetchSize);this.buffer=await this.fetch(i,e),this.position=i}const r=t,s=i-this.position,o=s+n;this.buffer.copy(e,r,s,o)}}class Xg{chrAliasTable=new Map;constructor(e,t,i){this.config=e,this.browser=i,this.genome=t,this.cramFile=new Vp.CramFile({filehandle:e.fileHandle?e.fileHandle:new Kg(e.url,e),seqFetch:e.seqFetch||async function(e,t,i){const n=this.genome,r=await this.getHeader(),s=n.getChromosomeName(r.indexToChr[e]);return this.genome.getSequence(s,t-1,i)}.bind(this),checkSequenceMD5:void 0===e.checkSequenceMD5||e.checkSequenceMD5});const n=e.indexFileHandle?e.indexFileHandle:new Kg(e.indexURL,e);this.indexedCramFile=new Vp.IndexedCramFile({cram:this.cramFile,index:new Vp.CraiIndex({filehandle:n}),fetchSizeLimit:e.fetchSizeLimit||1e9}),Mp.setReaderDefaults(this,e)}async getHeader(){if(!this.header){const e=await this.cramFile.getSamHeader(),t={},i=[],n=[];for(let r of e)if(\"SQ\"===r.tag){for(let e of r.data)if(\"SN\"===e.tag){const n=e.value;t[n]=i.length,i.push(n);break}}else\"RG\"===r.tag&&n.push(r.data);this.header={indexToChr:i,chrToIndex:t,chrNames:Object.keys(t),readGroups:n}}return this.header}async#x(e){if(await this.getHeader(),this.chrAliasTable.has(e)&&void 0===(e=this.chrAliasTable.get(e)))return;let t=this.header.chrToIndex[e];if(void 0===t){const i=await this.genome.getAliasRecord(e);let n;if(i){const e=Object.keys(i).filter((e=>\"start\"!==e&&\"end\"!==e)).map((e=>i[e])).filter((e=>void 0!==this.header.chrToIndex[e]));e.length>0&&(n=e[0],t=this.header.chrToIndex[e[0]])}this.chrAliasTable.set(e,n)}return t}async readAlignments(e,t,i){const n=await this.getHeader(),r=await this.#x(e),s=new tp(e,t,i,this.config);if(void 0===r)return s;try{const e=await this.indexedCramFile.getRecordsForRange(r,t,i);for(let a of e){const e=a.sequenceId,c=a.alignmentStart,l=c+a.lengthOnRef;if(e<0)continue;if(e>r||c>i)return;if(e=0&&(t=\"Sequence mismatch. Is this the correct genome for the loaded CRAM?\"),this.browser.alert.present(new Error(t)),e}function o(e,t){const i=new wp;if(i.chr=t[e.sequenceId],i.start=e.alignmentStart-1,i.lengthOnRef=e.lengthOnRef,i.flags=e.flags,i.strand=!(16&e.flags),i.fragmentLength=e.templateLength||e.templateSize,i.mq=e.mappingQuality,i.end=e.alignmentStart+e.lengthOnRef,i.readGroupId=e.readGroupId,e.mate&&void 0!==e.mate.sequenceId){const n=void 0!==e.mate.flags?!(1&e.mate.flags):!(32&e.flags);i.mate={chr:t[e.mate.sequenceId],position:e.mate.alignmentStart,strand:n}}return i.seq=e.getReadBases(),i.qual=e.qualityScores,i.tagDict=e.tags,i.readName=e.readName,function(e,t){const i=[];let n,r,s=0,o=\"\";if(t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef,e.readFeatures)for(let a of e.readFeatures){const e=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(e){case\"S\":case\"I\":case\"i\":case\"N\":case\"D\":if(l>s){const e=l-s;i.push(new xp({start:h-e,seqOffset:s,len:e,type:\"M\"})),s+=e,o+=e+\"M\"}if(\"S\"===e){let n=h;t.scLengthOnRef+=c.length,0===l&&(t.scStart-=c.length,n-=c.length);const r=c.length;i.push(new xp({start:n,seqOffset:s,len:r,type:\"S\"})),s+=r,o+=r+e}else if(\"I\"===e||\"i\"===e){void 0===n&&(n=[]);const t=\"i\"===e?1:c.length;n.push(new xp({start:h,len:t,seqOffset:s,type:\"I\"})),s+=t,o+=t+e}else\"D\"!==e&&\"N\"!==e||(r||(r=[]),r.push({start:h,len:c,type:e}),o+=c+e);break;case\"H\":case\"P\":o+=c+e}}const a=e.readLength-s;a>0&&(i.push(new xp({start:e.alignmentStart+e.lengthOnRef-a-1,seqOffset:s,len:a,type:\"M\"})),o+=a+\"M\");t.blocks=i,t.insertions=n,t.gaps=r,t.cigar=o}(e,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Mp.setPairOrientation(i),i}}}const Zg=2291137574,Jg=2273964779,em=[84,68,70,52],tm=new Uint8Array([66,65,77,1]),im=[67,82,65,77],nm=[31,139],rm=4,sm=new Set([\"narrowpeak\",\"broadpeak\",\"regionpeak\",\"peaks\",\"bedgraph\",\"wig\",\"gff3\",\"gff\",\"gtf\",\"fusionjuncspan\",\"refflat\",\"seg\",\"aed\",\"bed\",\"bedMethyl\",\"vcf\",\"bb\",\"bigbed\",\"biginteract\",\"biggenepred\",\"bignarrowpeak\",\"bw\",\"bigwig\",\"bam\",\"tdf\",\"refgene\",\"genepred\",\"genepredext\",\"bedpe\",\"bp\",\"snp\",\"rmsk\",\"cram\",\"gwas\",\"maf\",\"mut\",\"hiccups\",\"fasta\",\"fa\",\"fna\",\"pytor\",\"hic\",\"qtl\"]);function om(e,t){const i=Math.min(e.length,t.length);if(0==i)return!1;for(let n=0;n=this.start&&e.end<=this.end}overlaps(e){return e.chr===this.chr&&!(e.endthis.end)}extend(e){e.chr===this.chr&&(this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}getLocusString(){if(\"all\"===this.chr)return\"all\";{const e=Rt(Math.floor(this.start)+1),t=Rt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}static fromLocusString(e){if(\"all\"===e)return new lm({chr:\"all\"});const t=e.split(\":\"),i=t[0],n=t[1].split(\"-\"),r=Number.parseInt(n[0].replace(/,/g,\"\"))-1,s=Number.parseInt(n[1].replace(/,/g,\"\"));return new lm({chr:i,start:r,end:s})}}\n", - "/*!\n", - " * vanilla-picker v2.12.1\n", - " * https://vanilla-picker.js.org\n", - " *\n", - " * Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)\n", - " * Released under the ISC license.\n", - " */var hm=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},dm=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1;return(t>0?e.toFixed(t).replace(/0+$/,\"\").replace(/\\.$/,\"\"):e.toString())||\"0\"}var gm=function(){function e(t,i,n,r){hm(this,e);var s=this;if(void 0===t);else if(Array.isArray(t))this.rgba=t;else if(void 0===n){var o=t&&\"\"+t;o&&function(t){if(t.startsWith(\"hsl\")){var i=t.match(/([\\-\\d\\.e]+)/g).map(Number),n=um(i,4),r=n[0],o=n[1],a=n[2],c=n[3];void 0===c&&(c=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,c]}else if(t.startsWith(\"rgb\")){var l=t.match(/([\\-\\d\\.e]+)/g).map(Number),h=um(l,4),d=h[0],u=h[1],f=h[2],p=h[3];void 0===p&&(p=1),s.rgba=[d,u,f,p]}else t.startsWith(\"#\")?s.rgba=e.hexToRgb(t):s.rgba=e.nameToRgb(t)||e.hexToRgb(t)}(o.toLowerCase())}else this.rgba=[t,i,n,void 0===r?1:r]}return dm(e,[{key:\"printRGB\",value:function(e){var t=(e?this.rgba:this.rgba.slice(0,3)).map((function(e,t){return pm(e,3===t?3:0)}));return e?\"rgba(\"+t+\")\":\"rgb(\"+t+\")\"}},{key:\"printHSL\",value:function(e){var t=[360,100,100,1],i=[\"\",\"%\",\"%\",\"\"],n=(e?this.hsla:this.hsla.slice(0,3)).map((function(e,n){return pm(e*t[n],3===n?3:1)+i[n]}));return e?\"hsla(\"+n+\")\":\"hsl(\"+n+\")\"}},{key:\"printHex\",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:\"rgba\",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error(\"No color is set\");return this._rgba=e.hslToRgb(this._hsla)},set:function(e){3===e.length&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:\"rgbString\",get:function(){return this.printRGB()}},{key:\"rgbaString\",get:function(){return this.printRGB(!0)}},{key:\"hsla\",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error(\"No color is set\");return this._hsla=e.rgbToHsl(this._rgba)},set:function(e){3===e.length&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:\"hslString\",get:function(){return this.printHSL()}},{key:\"hslaString\",get:function(){return this.printHSL(!0)}},{key:\"hex\",get:function(){var e=this.rgba.map((function(e,t){return t<3?e.toString(16):Math.round(255*e).toString(16)}));return\"#\"+e.map((function(e){return e.padStart(2,\"0\")})).join(\"\")},set:function(t){this.rgba=e.hexToRgb(t)}}],[{key:\"hexToRgb\",value:function(e){var t=(e.startsWith(\"#\")?e.slice(1):e).replace(/^(\\w{3})$/,\"$1F\").replace(/^(\\w)(\\w)(\\w)(\\w)$/,\"$1$1$2$2$3$3$4$4\").replace(/^(\\w{6})$/,\"$1FF\");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error(\"Unknown hex color; \"+e);var i=t.match(/^(\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)$/).slice(1).map((function(e){return parseInt(e,16)}));return i[3]=i[3]/255,i}},{key:\"nameToRgb\",value:function(t){var i=t.toLowerCase().replace(\"at\",\"T\").replace(/[aeiouyldf]/g,\"\").replace(\"ght\",\"L\").replace(\"rk\",\"D\").slice(-5,4),n=fm[i];return void 0===n?n:e.hexToRgb(n.replace(/\\-/g,\"00\").padStart(6,\"f\"))}},{key:\"rgbToHsl\",value:function(e){var t=um(e,4),i=t[0],n=t[1],r=t[2],s=t[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),c=void 0,l=void 0,h=(o+a)/2;if(o===a)c=l=0;else{var d=o-a;switch(l=h>.5?d/(2-o-a):d/(o+a),o){case i:c=(n-r)/d+(n1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e},h=r<.5?r*(1+n):r+n-r*n,d=2*r-h;o=l(d,h,i+1/3),a=l(d,h,i),c=l(d,h,i-1/3)}var u=[255*o,255*a,255*c].map(Math.round);return u[3]=s,u}}]),e}(),mm=function(){function e(){hm(this,e),this._events=[]}return dm(e,[{key:\"add\",value:function(e,t,i){e.addEventListener(t,i,!1),this._events.push({target:e,type:t,handler:i})}},{key:\"remove\",value:function(t,i,n){this._events=this._events.filter((function(r){var s=!0;return t&&t!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&e._doRemove(r.target,r.type,r.handler),!s}))}},{key:\"destroy\",value:function(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)})),this._events=[]}}],[{key:\"_doRemove\",value:function(e,t,i){e.removeEventListener(t,i,!1)}}]),e}();function wm(e,t,i){var n=!1;function r(e,t,i){return Math.max(t,Math.min(e,i))}function s(e,s,o){if(o&&(n=!0),n){e.preventDefault();var a=t.getBoundingClientRect(),c=a.width,l=a.height,h=s.clientX,d=s.clientY,u=r(h-a.left,0,c),f=r(d-a.top,0,l);i(u/c,f/l)}}function o(e,t){1===(void 0===e.buttons?e.which:e.buttons)?s(e,e,t):n=!1}function a(e,t){1===e.touches.length?s(e,e.touches[0],t):n=!1}e.add(t,\"mousedown\",(function(e){o(e,!0)})),e.add(t,\"touchstart\",(function(e){a(e,!0)})),e.add(window,\"mousemove\",o),e.add(t,\"touchmove\",a),e.add(window,\"mouseup\",(function(e){n=!1})),e.add(t,\"touchend\",(function(e){n=!1})),e.add(t,\"touchcancel\",(function(e){n=!1}))}var bm=\"keydown\",Fm=\"mousedown\",vm=\"focusin\";function ym(e,t){return(t||document).querySelector(e)}function Am(e){e.preventDefault(),e.stopPropagation()}function Cm(e,t,i,n,r){e.add(t,bm,(function(e){i.indexOf(e.key)>=0&&(r&&Am(e),n(e))}))}var _m=function(){function e(t){hm(this,e),this.settings={popup:\"right\",layout:\"default\",alpha:!0,editor:!0,editorFormat:\"hex\",cancelButton:!1,defaultColor:\"#0cf\"},this._events=new mm,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(t)}return dm(e,[{key:\"setOptions\",value:function(e){var t=this;if(e){var i=this.settings;if(e instanceof HTMLElement)i.parent=e;else{i.parent&&e.parent&&i.parent!==e.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(e,t,i){for(var n in e)i&&i.indexOf(n)>=0||(t[n]=e[n])}(e,i),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var n=e.color||e.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(e){return t.openHandler(e)};this._events.add(r,\"click\",s),Cm(this._events,r,[\" \",\"Spacebar\",\"Enter\"],s),this._popupInited=!0}else e.parent&&!i.popup&&this.show()}}},{key:\"openHandler\",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents=\"none\";var t=e&&e.type===bm?this._domEdit:this.domElement;setTimeout((function(){return t.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:\"closeHandler\",value:function(e){var t=e&&e.type,i=!1;if(e)if(t===Fm||t===vm){var n=(this.__containedEvent||0)+100;e.timeStamp>n&&(i=!0)}else Am(e),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents=\"\",t!==Fm&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:\"movePopup\",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:\"setColor\",value:function(e,t){this._setColor(e,{silent:t})}},{key:\"_setColor\",value:function(e,t){if(\"string\"==typeof e&&(e=e.trim()),e){t=t||{};var i=void 0;try{i=new gm(e)}catch(e){if(t.failSilently)return;throw e}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,t)}}},{key:\"setColour\",value:function(e,t){this.setColor(e,t)}},{key:\"show\",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var e=this._toggleDOM(!0);return this._setPosition(),e}var t=function(e){var t=document.createElement(\"div\");return t.innerHTML=e,t.firstElementChild}(this.settings.template||'
');return this.domElement=t,this._domH=ym(\".picker_hue\",t),this._domSL=ym(\".picker_sl\",t),this._domA=ym(\".picker_alpha\",t),this._domEdit=ym(\".picker_editor input\",t),this._domSample=ym(\".picker_sample\",t),this._domOkay=ym(\".picker_done button\",t),this._domCancel=ym(\".picker_cancel button\",t),t.classList.add(\"layout_\"+this.settings.layout),this.settings.alpha||t.classList.add(\"no_alpha\"),this.settings.editor||t.classList.add(\"no_editor\"),this.settings.cancelButton||t.classList.add(\"no_cancel\"),this._ifPopup((function(){return t.classList.add(\"popup\")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:\"hide\",value:function(){return this._toggleDOM(!1)}},{key:\"destroy\",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:\"_bindEvents\",value:function(){var e=this,t=this,i=this.domElement,n=this._events;function r(e,t,i){n.add(e,t,i)}r(i,\"click\",(function(e){return e.preventDefault()})),wm(n,this._domH,(function(e,i){return t._setHSLA(e)})),wm(n,this._domSL,(function(e,i){return t._setHSLA(null,e,1-i)})),this.settings.alpha&&wm(n,this._domA,(function(e,i){return t._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,\"input\",(function(e){t._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,\"focus\",(function(e){var t=this;t.selectionStart===t.selectionEnd&&t.select()})),this._ifPopup((function(){var t=function(t){return e.closeHandler(t)};r(window,Fm,t),r(window,vm,t),Cm(n,i,[\"Esc\",\"Escape\"],t);var s=function(t){e.__containedEvent=t.timeStamp};r(i,Fm,s),r(i,vm,s),r(e._domCancel,\"click\",t)}));var o=function(t){e._ifPopup((function(){return e.closeHandler(t)})),e.onDone&&e.onDone(e.colour)};r(this._domOkay,\"click\",o),Cm(n,i,[\"Enter\"],o)}},{key:\"_setPosition\",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup((function(i){\"static\"===getComputedStyle(e).position&&(e.style.position=\"relative\");var n=!0===i?\"popup_right\":\"popup_\"+i;[\"popup_top\",\"popup_bottom\",\"popup_left\",\"popup_right\"].forEach((function(e){e===n?t.classList.add(e):t.classList.remove(e)})),t.classList.add(n)}))}},{key:\"_setHSLA\",value:function(e,t,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[e,t,i,n].forEach((function(e,t){(e||0===e)&&(o[t]=e)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:\"_updateUI\",value:function(e){if(this.domElement){e=e||{};var t=this.colour,i=t.hsla,n=\"hsl(\"+360*i[0]+\", 100%, 50%)\",r=t.hslString,s=t.hslaString,o=this._domH,a=this._domSL,c=this._domA,l=ym(\".picker_selector\",o),h=ym(\".picker_selector\",a),d=ym(\".picker_selector\",c);b(0,l,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,b(0,h,i[1]),F(0,h,1-i[2]),a.style.color=r,F(0,d,1-i[3]);var u=r,f=u.replace(\"hsl\",\"hsla\").replace(\")\",\", 0)\"),p=\"linear-gradient(\"+[u,f]+\")\";if(this._domA.style.background=p+\", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em\",!e.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,w=void 0;switch(g){case\"rgb\":w=t.printRGB(m);break;case\"hsl\":w=t.printHSL(m);break;default:w=t.printHex(m)}this._domEdit.value=w}this._domSample.style.color=s}function b(e,t,i){t.style.left=100*i+\"%\"}function F(e,t,i){t.style.top=100*i+\"%\"}}},{key:\"_ifPopup\",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:\"_toggleDOM\",value:function(e){var t=this.domElement;if(!t)return!1;var i=e?\"\":\"none\",n=t.style.display!==i;return n&&(t.style.display=i),n}}]),e}(),xm=document.createElement(\"style\");function km(e){if(Im[e])return Im[e];if(Im[\"chr\"+e]){const t=Im[\"chr\"+e];return Im[e]=t,t}{const r=(t=Math.round(255*Math.random()).toString(10),i=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),\"rgb(\"+t+\",\"+i+\",\"+n+\")\");return Im[e]=r,r}var t,i,n}xm.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:\"\";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:\"\";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:\"\";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:\"\";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(xm),_m.StyleElement=xm;const Im={chrX:\"rgb(204, 153, 0)\",chrY:\"rgb(153, 204, 0\",chrUn:\"rgb(50, 50, 50)\",chr1:\"rgb(80, 80, 255)\",chrI:\"rgb(139, 155, 187)\",chr2:\"rgb(206, 61, 50)\",chrII:\"rgb(206, 61, 50)\",chr2a:\"rgb(216, 71, 60)\",chr2b:\"rgb(226, 81, 70)\",chr3:\"rgb(116, 155, 88)\",chrIII:\"rgb(116, 155, 88)\",chr4:\"rgb(240, 230, 133)\",chrIV:\"rgb(240, 230, 133)\",chr5:\"rgb(70, 105, 131)\",chr6:\"rgb(186, 99, 56)\",chr7:\"rgb(93, 177, 221)\",chr8:\"rgb(128, 34, 104)\",chr9:\"rgb(107, 215, 107)\",chr10:\"rgb(213, 149, 167)\",chr11:\"rgb(146, 72, 34)\",chr12:\"rgb(131, 123, 141)\",chr13:\"rgb(199, 81, 39)\",chr14:\"rgb(213, 143, 92)\",chr15:\"rgb(122, 101, 165)\",chr16:\"rgb(228, 175, 105)\",chr17:\"rgb(59, 27, 83)\",chr18:\"rgb(205, 222, 183)\",chr19:\"rgb(97, 42, 121)\",chr20:\"rgb(174, 31, 99)\",chr21:\"rgb(231, 199, 111)\",chr22:\"rgb(90, 101, 94)\",chr23:\"rgb(204, 153, 0)\",chr24:\"rgb(153, 204, 0)\",chr25:\"rgb(51, 204, 0)\",chr26:\"rgb(0, 204, 51)\",chr27:\"rgb(0, 204, 153)\",chr28:\"rgb(0, 153, 204)\",chr29:\"rgb(10, 71, 255)\",chr30:\"rgb(71, 117, 255)\",chr31:\"rgb(255, 194, 10)\",chr32:\"rgb(255, 209, 71)\",chr33:\"rgb(153, 0, 51)\",chr34:\"rgb(153, 26, 0)\",chr35:\"rgb(153, 102, 0)\",chr36:\"rgb(128, 153, 0)\",chr37:\"rgb(51, 153, 0)\",chr38:\"rgb(0, 153, 26)\",chr39:\"rgb(0, 153, 102)\",chr40:\"rgb(0, 128, 153)\",chr41:\"rgb(0, 51, 153)\",chr42:\"rgb(26, 0, 153)\",chr43:\"rgb(102, 0, 153)\",chr44:\"rgb(153, 0, 128)\",chr45:\"rgb(214, 0, 71)\",chr46:\"rgb(255, 20, 99)\",chr47:\"rgb(0, 214, 143)\",chr48:\"rgb(20, 255, 177)\"};class Sm{constructor(e){this.tracks=[],this.chordSets=[]}addChordSet(e){this.chordSets=this.chordSets.filter((t=>t.name!==e.name)),this.chordSets.push(e);let t=this.tracks.find((t=>e.trackName===t.name));t&&(t.chordSets=t.chordSets.filter((t=>t.name!==e.name)),t.chordSets.push(e)),t||(t=new Em(e),this.tracks.push(t))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(e){return this.tracks.find((t=>e===t.name))}getChordSet(e){return this.chordSets.find((t=>e===t.name))}}class Em{constructor(e){this.name=e.trackName,this.color=e.trackColor,this.visible=!0,this.chordSets=[e],this.id=(\"0000\"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const e=[];for(let t of this.chordSets)for(let i of t.chords)e.push(i);return e}}const Nm=Math.exp(5);class Bm{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(e,t){if(t=t||{},this.config=t,Bm.isInstalled()){this.parent=e,this.groupByTrack=!0===t.groupByTrack,this.chordManager=new Sm(t);const i=document.createElement(\"div\");i.className=\"igv-circview-container\",e.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement(\"div\");n.className=\"igv-circview-circular-genome-view\",i.appendChild(n),this.container=n,t.assembly&&this.setAssembly(t.assembly),this.width=t.width||500,this.height=t.height||500,this.setSize(this.width,this.height)}else console.error(\"JBrowse circular view is not installed\")}createControls(e){const t=document.createElement(\"div\");t.className=\"igv-circview-toolbar\",e.appendChild(t),this.toolbar=t;const i=document.createElement(\"div\");i.className=\"igv-circview-track-panel\",e.appendChild(i),this.controlPanel=i,this.controlPanel.style.display=\"none\";const n=document.createElement(\"div\");n.className=\"igv-circview-toolbar-button-container\",this.toolbar.appendChild(n),this.showControlsButton=document.createElement(\"div\"),this.showControlsButton.className=\"igv-circview-button\",n.appendChild(this.showControlsButton),this.showControlsButton.innerText=\"none\"===this.controlPanel.style.display?\"Show Controls\":\"Hide Controls\",this.showControlsButton.addEventListener(\"click\",(e=>{this.controlPanel.querySelectorAll(\"div\").length>0&&(\"none\"===this.controlPanel.style.display?(this.controlPanel.style.display=\"flex\",e.target.innerText=\"Hide Controls\"):(this.controlPanel.style.display=\"none\",e.target.innerText=\"Show Controls\"))}));let r=document.createElement(\"div\");r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Clear All\",r.addEventListener(\"click\",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement(\"div\"),r.className=\"igv-circview-button\",n.appendChild(r),r.innerText=\"Close\",r.addEventListener(\"click\",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML=\"\",this.controlPanel.appendChild(this.createGroupByCB());const e=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let t of e)this.addToControlPanel(t)}createGroupByCB(){const e=document.createElement(\"input\");e.type=\"checkbox\",e.id=\"groupByCB\",e.style.width=\"1.4em\",e.style.height=\"1.4em\",e.checked=this.groupByTrack,e.onclick=e=>{this.groupByTrack=e.target.checked,this.resetControlPanel(),this.render()};const t=document.createElement(\"label\");t.for=\"groupByCB\",t.innerText=\"Group by track\",t.style.color=\"black\",t.style.paddingLeft=\"10px\";const i=document.createElement(\"div\");return i.style.width=\"100%\",i.style.paddingTop=\"5px\",i.style.paddingBottom=\"5px\",i.style.background=\"rgb(216, 230, 234)\",i.appendChild(e),i.appendChild(t),i}addToControlPanel(e){const t=document.createElement(\"div\");this.controlPanel.appendChild(t);const i=document.createElement(\"div\");i.className=\"igv-circview-button\",t.appendChild(i),i.innerText=!0===e.visible?\"Hide\":\"Show\",i.addEventListener(\"click\",(t=>{!0===e.visible?(this.hideChordSet(e.name),t.target.innerText=\"Show\"):(this.showChordSet(e.name),t.target.innerText=\"Hide\")}));const n=document.createElement(\"input\"),r=e=>200*Math.log(e*Nm),s=document.createElement(\"div\");s.className=\"igv-circview-button\",s.innerHTML=\"    \",t.appendChild(s),s.style.backgroundColor=Mm(e.color,1);const o={parent:s,popup:\"right\",editorFormat:\"rgb\",color:e.color,onChange:({rgbaString:t})=>{s.style.backgroundColor=Mm(t,1),this.setColor(e.name,t),n.value=r(Rm(e.color))}},a=new _m(o);n.setAttribute(\"title\",\"Adjust transparency of arcs\"),n.type=\"range\",n.style.width=\"100px\",n.style.marginRight=\"10px\",n.setAttribute(\"class\",\"range\"),n.setAttribute(\"min\",\"0\"),n.setAttribute(\"max\",\"1000\"),n.value=r(Rm(e.color)),n.oninput=()=>{const t=(i=n.value,Math.exp(i/200)/Nm);var i;this.setColor(e.name,Mm(e.color,t)),a.setColor(e.color)},t.appendChild(n);const c=document.createElement(\"div\");c.style.color=\"black\",t.appendChild(c),c.innerText=c.title=e.name}setAssembly(e){const t=this.genomeId||Lm();if(this.genomeId===t)return;this.chordManager.clearChords(),this.genomeId=t,this.chrNames=new Set(e.chromosomes.map((e=>Dm(e.name))));const i=[],n=[];for(let t of e.chromosomes){const e=Dm(t.name);n.push(t.color||km(e)),i.push({refName:e,uniqueId:e,start:0,end:t.bpLength})}this.assembly={name:e.name,sequence:{trackId:t,type:\"ReferenceSequenceTrack\",adapter:{type:\"FromConfigSequenceAdapter\",features:i}},refNameColors:n},this.render()}addChords(e,t={}){const i=t.name||t.track||\"*\",n=i.split(\" \")[0].replaceAll(\"%20\",\" \"),r={name:i.replaceAll(\"%20\",\" \"),trackName:n,chords:e,color:t.color||\"black\",trackColor:t.trackColor||t.color||\"black\",visible:!0,id:t.id||Lm()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(e,t){if(t=t||e,this.width=e,this.height=t,this.viewState){const i=this.viewState.session.view;i.setWidth(e),i.setHeight(t),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display=\"block\"}hide(){this.parent.style.display=\"none\"}get visible(){return\"none\"!==this.parent.style.display}set visible(e){this.parent.style.display=e?\"block\":\"none\"}hideChordSet(e){let t=this.getChordSet(e);t?(t.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(e){let t=this.getChordSet(e);t?(t.visible=!0,this.render()):console.warn(`No track with name: ${e}`)}deleteTrack(e){let t=this.tracks.findIndex((t=>e===t.name));t>=0&&this.tracks.splice(t,1),this.render()}getChordSet(e){return this.groupByTrack?this.chordManager.getTrack(e):this.chordManager.getChordSet(e)}setColor(e,t){const i=this.getChordSet(e);if(i){i.color=t;const e=i.id;for(let i of this.viewState.config.tracks)if(e===i.trackId){i.displays[0].renderer.strokeColor.set(t);break}}}render(){const{createViewState:e,JBrowseCircularGenomeView:t}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((e=>e.visible)),n=[],r=[];for(let e of i)n.push({trackId:e.id,name:e.name,assemblyNames:[\"forIGV\"],type:\"VariantTrack\",adapter:{type:\"FromConfigAdapter\",features:e.chords}}),r.push(e.color);this.viewState=e({assembly:this.assembly,tracks:n});for(let e=0;e div {\\n margin: 4px;\\n}\\n\\n.igv-circview-track-panel {\\n z-index: 1024;\\n position: absolute;\\n top: 33px;\\n left: 0;\\n width: 100%;\\n height: fit-content;\\n border-bottom-style: solid;\\n border-bottom-color: dimgray;\\n border-bottom-width: thin;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n.igv-circview-track-panel > div {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-circview-track-panel > div > div {\\n margin: 4px;\\n}\\n\\n.igv-circview-swatch-button {\\n cursor: pointer;\\n padding: 5px;\\n width: 8px;\\n height: 8px;\\n border: 1px solid #8d8b8b;\\n border-radius: 16px;\\n}\\n\\n.igv-circview-button {\\n cursor: pointer;\\n padding: 5px;\\n color: #444;\\n vertical-align: middle;\\n text-align: center;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n border: 1px solid #8d8b8b;\\n border-radius: 4px;\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\\n}\\n\\n.igv-circview-button:hover {\\n background: #efefef;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n.igv-circview-button:active {\\n color: #007bff;\\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\\n}\\n\\n/*# sourceMappingURL=circular-view.css.map */\\n',document.head.insertBefore(e,document.head.childNodes[document.head.childNodes.length-1])}()}const zm=e=>e.startsWith(\"chr\")?e.substring(3):e;function Hm(e){const t=[],i=[];if(e.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n);i.push(Nu(r.name)),t.push({name:r.name,bpLength:r.bpLength})}return t}function Pm(e,t,i,n){const r=t.color||\"rgb(0,0,255)\",s=_s.addAlpha(\"all\"===i.chr?r:Nu(i.chr),n),o=_s.addAlpha(r,n),a=t.name.replaceAll(\" \",\"%20\"),c=\"all\"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;t.browser.circularView.addChords(e,{track:c,color:s,trackColor:o}),t.browser.circularViewVisible||(t.browser.circularViewVisible=!0)}class Om{constructor(e,{minTLENPercentile:t,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===t?.1:t,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(e)}compute(e){for(let n of e)if(n.isProperPair()){var t=Math.abs(n.fragmentLength);this.sumF+=t,this.sumF2+=t*t,this.isizes.push(t);var i=n.pairOrientation;if(\"string\"==typeof i&&4===i.length)switch(\"\"+i.charAt(0)+i.charAt(2)){case\"FF\":case\"RR\":this.ffCount++;break;case\"FR\":this.frCount++;break;case\"RF\":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation=\"ff\":this.frCount/this.totalCount>.9?this.orienation=\"fr\":this.rfCount/this.totalCount>.9&&(this.orienation=\"rf\"),this.minTLEN=0===this.lp?0:Um(this.isizes,this.lp),this.maxTLEN=Um(this.isizes,this.up)}}function Um(e,t){if(0!==e.length){var i=Math.floor(e.length*(t/100));return e.sort((function(e,t){return e-t})),e[i]}}const qm=\"rgb(255,0,255)\",Qm=\"rgb(0,0,255)\",Vm=\"rgb(132, 178, 158)\",jm=new Map;jm.set(\"m\",\"rgb(255,0,0)\"),jm.set(\"h\",qm),jm.set(\"o\",\"rgb(111, 78, 129)\"),jm.set(\"f\",\"rgb(246, 200, 95)\"),jm.set(\"c\",\"rgb(157, 216, 102)\"),jm.set(\"g\",\"rgb(255, 160, 86)\"),jm.set(\"e\",\"rgb(141, 221, 208)\"),jm.set(\"b\",\"rgb(202, 71, 47)\"),jm.set(\"h\",qm),jm.set(\"a\",\"rgb(51,0,111)\"),jm.set(\"NONE_A\",Qm),jm.set(\"NONE_C\",Qm),jm.set(\"NONE_T\",Qm),jm.set(\"NONE_G\",Qm),jm.set(\"NONE_N\",Qm);const Wm=new Map;function Gm(e,t,i){let n=function(e,t){return jm.has(e)?jm.get(e):Vm}(e),r=Xf(t);if(r>255)return n;const s=e+r+i;if(r<0&&(r=0),!Wm.has(s)){const e=\"basemod2\"===i?Math.max(20,Math.min(255,r*r/50-4*r+200+20)):Math.max(20,Math.min(255,.006127*r*r)),[t,o,a]=_s.rgbComponents(n);Wm.set(s,`rgba(${t},${o},${a},${e/255})`)}return Wm.get(s)}class $m{constructor(e){this.alignmentTrack=e}updateContext(e){this.context=e}drawModifications(e,t,i,n,r,s){const{ctx:o,pixelEnd:a,bpStart:c,bpPerPixel:l}=n,h=e.getBaseModificationSets();if(h){let n;const d=r.split(\":\");2==d.length&&(r=d[0],n=d[1]);for(let d of e.blocks){if(\"S\"===d.type)continue;const e=t,u=i;let f=Math.max(1,1/l);for(let t=d.seqOffset;ta)break;if(i+f<0)continue;let p,g=-1,m=255,w=0;for(let e of h)if((!n||e.modification===n)&&e.containsPosition(t)){const i=Xf(e.likelihoods.get(t));m-=i,(!p||i>g)&&(p=e.modification,w=e.canonicalBase,g=i)}if(p){const t=255*s;let n;m>g&&\"basemod2\"===r&&m>=t?n=Gm(\"NONE_\"+w,m,r):g>=t&&(n=Gm(p,g,r)),o.fillStyle=n,f<3&&(f=3,i--),o.fillRect(i,e,f,Math.max(1,u-2))}}}}}}const Km=new Set([\"firstOfPairStrand\"]);class Ym extends Hl{static defaults={viewAsPairs:!1,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,colorBy:void 0,groupBy:void 0,displayMode:\"EXPANDED\",alignmentRowHeight:14,squishedRowHeight:3,negStrandColor:\"rgba(150, 150, 230, 0.75)\",posStrandColor:\"rgba(230, 150, 150, 0.75)\",baseModPosStrandColor:\"rgb(195, 195, 195)\",baseModNegStrandColor:\"rgb(195, 210, 195)\",insertionColor:\"rgb(138, 94, 161)\",insertionTextColor:\"white\",showInsertionText:!1,deletionColor:\"black\",deletionTextColor:\"black\",showDeletionText:!1,skippedColor:\"rgb(150, 170, 170)\",pairConnectorColor:void 0,smallTLENColor:\"rgb(0, 0, 150)\",largeTLENColor:\"rgb(200, 0, 0)\",expectedPairOrientation:\"fr\",rlColor:\"rgb(0, 150, 0)\",rrColor:\"rgb(20, 50, 200)\",llColor:\"rgb(0, 150, 150)\",bamColorTag:\"YC\",hideSmallIndels:!1,indelSizeThreshold:1,highlightColor:void 0,minTLEN:void 0,maxTLEN:void 0,tagColorPallete:\"Set1\"};_colorTables=new Map;_baseModifications=new Set;constructor(e,t){super(e,t),(e.colorTable||e.tagColorTable)&&(this.colorTable=new ao(e.tagColorTable)),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.pairOrienation&&(this.expectedPairOrientation=e.pairOrientation),e.smallFragmentLengthColor&&(this.smallTLENColor=e.smallFragmentLengthColor),e.largeFragmentLengthColor&&(this.largeTLENColor=e.largeFragmentLengthColor),e.minFragmentLength&&(this.minTLEN=e.minFragmentLength),e.maxFragmentLength&&(this.maxTLEN=e.maxFragmentLength),e.displayMode&&(this.displayMode=e.displayMode.toUpperCase()),e.colorBy&&e.colorByTag&&(this.colorBy=e.colorBy+\":\"+e.colorByTag),this.featureSource=this.parent.featureSource,this.top=0===e.coverageTrackHeight?0:e.coverageTrackHeight+5,this.pairColors={RL:this.rlColor,RR:this.rrColor,LL:this.llColor},e.highlightedReads&&this.setHighlightedReads(e.highlightedReads),this.hasPairs=!1,this.hasSupplemental=!1,this._groupByTags=[],this._groupByPositions=[],e.groupBy&&(this.groupBy=e.groupBy,e.groupBy.startsWith(\"base:\")&&this._groupByPositions.push(e.groupBy.substring(5)),e.groupBy.startsWith(\"tag:\")&&this._groupByTags.push(e.groupBy.substring(4))),this._locusChange=Zm.bind(this),this.browser.on(\"locuschange\",this._locusChange)}init(e){this.parent=e.parent,delete e.parent,super.init(e)}dispose(){this.browser.off(\"locuschage\",this._locusChange)}get baseModRenderer(){return this._baseModRenderer||(this._baseModRenderer=new $m(this)),this._baseModRenderer}get baseModificationThreshold(){return this.parent.baseModificationThreshold}setTop(e,t){this.top=0===e.height||!1===t?0:5+e.height}setHighlightedReads(e,t){if(!Array.isArray(e)||!e.every((e=>\"string\"==typeof e)))throw new Error(\"AlignmentTrack.setHighlightedReads() only accept array of strings\");t&&(this.highlightColor=t),this.highlightedReads=new Set(e)}computePixelHeight(e){if(e.packedGroups){let t=e.hasDownsampledIntervals()?15:0;const i=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;for(let n of e.packedGroups.values())t+=i*n.length+10;return t+5}return 0}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=r+s*n+1,a=this.showSoftClips,c=this.showAllBases,l=this.browser.nucleotideColors;i.save();for(let e of t.baseModificationKeys)this._baseModifications.add(e.modification);let h=t.sequence;h&&(h=h.toUpperCase());let d=0;this.colorBy||(this.colorBy=this.hasPairs?\"unexpectedPair\":\"none\");let u=e.pixelTop;this.top&&i.translate(0,this.top);const f=u+e.pixelHeight;t.hasDownsampledIntervals()?(d=15,t.downsampledIntervals.forEach((function(e){var t=(e.start-r)/n,s=(e.end-r)/n;s-t>5&&(t+=1,s-=1),xo.fillRect(i,t,2,s-t,8,{fillStyle:\"black\"})}))):d=0,this.alignmentsYOffset=d;const p=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight,g=t.packedGroups;if(g){let t=d;for(let n of g.keys()){const a=g.get(n),c=a.rows,l=c.length;a.pixelTop=t;for(let e=0;ef)break;if(t+no)break;!0!==e.hidden&&(e instanceof Qf?(m.call(this,e,t,n),w.call(this,e.firstAlignment,t,n),e.secondAlignment&&w.call(this,e.secondAlignment,t,n)):w.call(this,e,t,n))}t+=p}}if(a.pixelBottom=t,this.groupBy&&n){i.save(),i.font=\"400 12px sans-serif\";const r=i.measureText(n),o=r.width+10,c=-e.pixelShift+e.viewportWidth-o-10,l=r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+10,h=Math.min(a.pixelTop+l-1,a.pixelBottom);i.textAlign=\"center\",i.fillStyle=\"white\",i.strokeStyle=\"lightGray\",xo.roundRect(i,c,h-r.actualBoundingBoxAscent-5,o,l,2,1,1),i.fillStyle=\"black\",i.fillText(n,c+o/2,h),xo.dashedLine(i,0,t,s,t),i.restore(),t+=10}}}function m(e,t,s){var a=this.getConnectorColor(e.firstAlignment),c=(e.connectingStart-r)/n,l=(e.connectingEnd-r)/n,h=t+s/2;e.connectingEndo||(e.mq<=0&&(a=_s.addAlpha(a,.15)),xo.setProperties(i,{fillStyle:a,strokeStyle:a}),xo.strokeLine(i,c,h,l,h))}function w(e,d,u){if(e.start+e.lengthOnRefo)return;const f=a?e.blocks:e.blocks.filter((e=>\"S\"!==e.type));let g=this.getAlignmentColor(e);const m=g;e.mq<=0&&(g=_s.addAlpha(g,.15)),xo.setProperties(i,{fillStyle:g,strokeStyle:m});const w=[];for(let e=0;eo))break}if(e.gaps){const t=d+u/2;for(let s of e.gaps){const e=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-e,c=s.len.toString(),l=6*c.length,h=e+a/2,u=\"D\"===s.type?this.deletionColor:this.skippedColor;if(xo.strokeLine(i,e,t,o,t,{strokeStyle:u,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=l+8){const e=h-l/2;xo.fillRect(i,e-1,d-1,l+2,12,{fillStyle:\"white\"}),xo.fillText(i,c,e,d+10,{font:\"normal 10px monospace\",fillStyle:this.deletionTextColor})}}}if(e.insertions&&this.showInsertions){let t=-1;for(let s of e.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.starto)break;const e=s.start-r,a=s.len.toString(),c=2+6*a.length,l=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,h=Math.max(Math.min(c,l),2),f=e/n-h/2;if(f-t>2){const e={fillStyle:this.insertionColor};xo.fillRect(i,f-2,d,h+4,2,e),xo.fillRect(i,f,d+2,h,u-4,e),xo.fillRect(i,f-2,d+u-2,h+4,2,e),this.showInsertionText&&s.len>1&&l>c&&xo.fillText(i,a,f+1,d+10,{font:\"normal 10px monospace\",fillStyle:this.insertionTextColor}),t=f}}}for(let{bbox:e,baseColor:t,readChar:r}of w){if(n<=.1&&e.height>=8){const n=Math.min(10,e.height);i.font=n+\"px sans-serif\";const s=e.x+e.width/2;xo.strokeText(i,r,s-i.measureText(r).width/2,n-1+e.y,{strokeStyle:t})}else xo.fillRect(i,e.x,e.y,e.width,e.height,{fillStyle:t})}if(this.colorBy&&this.colorBy.startsWith(\"basemod\")){const t={ctx:i,bpPerPixel:n,bpStart:r,bpEnd:o,pixelEnd:s};this.baseModRenderer.drawModifications(e,d,u,t,this.colorBy,this.baseModificationThreshold)}function b(o,a){const w=[],b=o.start-t.start,F=(o.start-r)/n,v=(o.start+o.len-r)/n,y=Math.max(1,v-F),A=100/n,C=Math.min(p/2,A/6),_=\"S\"===o.type,x=e.mq<=0||this.selectedReadName===e.readName||_||this.highlightedReads&&this.highlightedReads.has(e.readName);let k=m;this.selectedReadName===e.readName?k=\"red\":_?k=\"rgb(50,50,50)\":this.highlightedReads&&this.highlightedReads.has(e.readName)&&(k=this.highlightColor||\"#00ff00\");const I=!0===e.strand&&a===f.length-1,S=!1===e.strand&&0===a;if(I|S){let e,t;I?(e=[F,v,v+C,v,F,F],t=[d,d,d+u/2,d+u,d+u,d]):S&&(e=[v,F,F-C,F,v,v],t=[d,d,d+u/2,d+u,d+u,d]),xo.fillPolygon(i,e,t,{fillStyle:g}),x&&xo.strokePolygon(i,e,t,{strokeStyle:k})}else xo.fillRect(i,F,d,y,u,{fillStyle:g}),x&&(i.save(),i.strokeStyle=k,i.strokeRect(F,d,y,u),i.restore());if(_||c||this.showMismatches&&h&&e.seq&&\"*\"!==e.seq){const t=e.seq?e.seq.toUpperCase():void 0,i=e.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let e=0,p=o.len;es)break;let g=t?t.charAt(a+e):\"\";const m=b+e>=0?h.charAt(b+e):\"\";if(\"=\"===g&&(g=m),\"X\"===g||m!==g||_||c){let t=l[g]||\"rgb(0,0,0)\";if(!_&&void 0!==i&&i.length>a+e){t=Xm(i[a+e],t)}w.push({bbox:{x:p,y:d,width:f,height:u},baseColor:t,readChar:g})}}}return w}}i.restore()}popupData(e){const t=this.getClickedObject(e);return t?t.popupData(e.genomicLocation):void 0}menuItemList(){let e=[];e.push(\"
\");const t=Bt('
');t.text(\"Color by:\"),e.push({name:void 0,object:t,click:void 0,init:void 0});const i=[];i.push({key:\"none\",label:\"none\"}),i.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(i.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),i.push({key:\"pairOrientation\",label:\"pair orientation\"}),i.push({key:\"tlen\",label:\"insert size (TLEN)\"}),i.push({key:\"unexpectedPair\",label:\"pair orientation & insert size (TLEN)\"})),i.push({key:\"tag\",label:\"tag\"});for(let t of i){const i=void 0===this.colorBy&&\"none\"===t.key||this.colorBy===t.key;e.push(this.colorByCB(t,i))}const n=this._baseModifications.size;if(n>0){e.push('
');let t=1===n?\"base modification\":\"base modification (all)\";if(e.push(this.basemodColorByCB({key:\"basemod\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod:\"+t,label:`base modification (${Kf(t)})`}));if(e.push('
'),t=1===n?\"base modification 2-color\":\"base modification 2-color (all)\",e.push(this.basemodColorByCB({key:\"basemod2\",label:t})),n>1)for(let t of this._baseModifications)e.push(this.basemodColorByCB({key:\"basemod2:\"+t,label:`base modification 2-color (${Kf(t)})`}))}e.push(\"
\");const r=Bt('
');r.text(\"Group by:\"),e.push({name:void 0,object:r,click:void 0,init:void 0});const s=[];s.push({key:\"none\",label:\"none\"}),s.push({key:\"strand\",label:\"read strand\"}),this.hasPairs&&(s.push({key:\"firstOfPairStrand\",label:\"first-of-pair strand\"}),s.push({key:\"pairOrientation\",label:\"pair orientation\"}),s.push({key:\"mateChr\",label:\"chromosome of mate\"})),s.push({key:\"chimeric\",label:\"chimeric\"}),s.push({key:\"supplementary\",label:\"supplementary flag\"}),s.push({key:\"readOrder\",label:\"read order\"});for(let e of this._groupByTags)s.push({key:`tag:${e}`,label:`tag:${e}`});for(let e of this._groupByPositions)s.push({key:`base:${e}`,label:`base:${e}`});s.push({key:\"tag\",label:\"tag...\"});for(let t of s){const i=void 0===this.groupBy&&\"none\"===t.key||this.groupBy===t.key;e.push(this.groupByCB(t,i))}e.push(\"
\"),e.push({object:Bt(Dl(\"Show all bases\",this.showAllBases)),click:function(){this.alignmentTrack.showAllBases=!this.alignmentTrack.showAllBases,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show mismatches\",this.showMismatches)),click:function(){this.alignmentTrack.showMismatches=!this.alignmentTrack.showMismatches,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show insertions\",this.showInsertions)),click:function(){this.alignmentTrack.showInsertions=!this.alignmentTrack.showInsertions,this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show soft clips\",this.showSoftClips)),click:function(){this.alignmentTrack.showSoftClips=!this.alignmentTrack.showSoftClips;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.repaintViews()}}),this.hasPairs&&(e.push(\"
\"),e.push({object:Bt(Dl(\"View as pairs\",this.viewAsPairs)),click:function(){const e=!this.alignmentTrack.viewAsPairs;if(e&&this.groupBy&&!Km.has(this.groupBy))return void this.browser.alert.present(`'View as Pairs' is incompatible with 'Group By ${this.groupBy}'`);this.alignmentTrack.viewAsPairs=e;const t=this.getCachedAlignmentContainers();for(let e of t)e.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(e.push(\"
\"),this.hasPairs&&e.push({label:\"Add discordant pairs to circular view\",click:function(){for(let e of this.trackView.viewports)this.addPairedChordsForViewport(e)}}),this.hasSupplemental&&e.push({label:\"Add split reads to circular view\",click:function(){for(let e of this.trackView.viewports)this.addSplitChordsForViewport(e)}})),e.push(\"
\");const o=Bt('
');o.text(\"Display mode:\"),e.push({name:void 0,object:o,click:void 0,init:void 0});for(let t of[\"EXPANDED\",\"SQUISHED\",\"FULL\"])e.push({object:Bt(Dl(t.toLowerCase(),this.displayMode===t)),click:function(){this.alignmentTrack.setDisplayMode(t)}});return e}setDisplayMode(e){const t=\"FULL\"===this.displayMode||\"FULL\"===e;if(this.displayMode=e,t){const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this)}this.trackView.checkContentHeight(),this.trackView.repaintViews()}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"tag\"!==e.key){function n(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){const t=this.alignmentTrack.colorBy.startsWith(\"tag:\")?this.alignmentTrack.colorBy.substring(4):\"\";this.browser.inputDialog.present({label:\"Tag Name\",value:t,callback:e=>{const t=this.alignmentTrack;e?(t.colorBy=\"tag:\"+e,t.colorTable||(t.colorTable=new oo(\"Set1\"))):t.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}basemodColorByCB(e){const t=this.colorBy===e.key;return{name:void 0,object:Bt(Dl(e.label,t)),click:function(){this.alignmentTrack.colorBy=e.key,this.trackView.repaintViews()},init:void 0}}groupByCB(e,t){return{name:void 0,object:Bt(Dl(e.label,t)),dialog:function(t){const i=()=>this.alignmentTrack.repackAlignments();if(\"tag\"===e.key){let e=\"\";this.alignmentTrack.groupBy&&this.alignmentTrack.groupBy.startsWith(\"tag:\")&&(e=this.alignmentTrack.groupBy.substring(4)),this.browser.inputDialog.present({label:\"Tag Name\",value:e,callback:e=>{e&&(this.alignmentTrack.groupBy=\"tag:\"+e,this.alignmentTrack._groupByTags.push(e),i())}},t)}else\"none\"===e.key?this.alignmentTrack.groupBy=void 0:this.alignmentTrack.groupBy=e.key,i()},init:void 0}}repackAlignments(){const e=this.getCachedAlignmentContainers();for(let t of e)\"function\"==typeof t.pack&&t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}contextMenuItemList(e){const t=e.viewport,i=[],n=i=>{const n=this.sortObject,r=!n||n.position!==Math.floor(e.genomicLocation)||!n.direction,s={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:i,direction:r,sortAsPairs:t.trackView.track.viewAsPairs};this.sortObject=s,t.cachedFeatures.sortRows(s),t.repaint()};i.push(\"Sort by...\"),i.push({label:\"  base\",click:()=>n(\"BASE\")}),i.push({label:\"  read strand\",click:()=>n(\"strand\")}),i.push({label:\"  start location\",click:()=>n(\"START\")}),i.push({label:\"  insert size\",click:()=>n(\"INSERT_SIZE\")}),i.push({label:\"  gap size\",click:()=>n(\"GAP_SIZE\")}),i.push({label:\"  chromosome of mate\",click:()=>n(\"MATE_CHR\")}),i.push({label:\"  mapping quality\",click:()=>n(\"MQ\")}),i.push({label:\"  read name\",click:()=>n(\"READ_NAME\")}),i.push({label:\"  aligned read length\",click:()=>n(\"ALIGNED_READ_LENGTH\")}),i.push({label:\"  tag\",click:()=>{const i=this.sortObject,n=!i||i.position!==Math.floor(e.genomicLocation)||!i.direction,r={label:\"Tag Name\",value:this.sortByTag?this.sortByTag:\"\",callback:i=>{if(i){const r={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:\"TAG\",tag:i,direction:n};this.sortByTag=i,this.sortObject=r,t.cachedFeatures.sortRows(r),t.repaint()}}};this.browser.inputDialog.present(r,e.event)}}),i.push(\"
\");const r=`${t.referenceFrame.chr}:${Rt(Math.floor(e.genomicLocation)+1)}`;i.push({label:`Group by base @${r}`,click:()=>{this._groupByPositions.push(r),this.groupBy=`base:${r}`;const e=this.getCachedAlignmentContainers();for(let t of e)t.pack(this);this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),i.push(\"
\");const s=this.getClickedObject(e);if(s){const t=this.showSoftClips,n=\"function\"==typeof s.alignmentContaining?s.alignmentContaining(e.genomicLocation,t):s;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:\"View mate in split screen\",click:()=>{if(n.mate){const t=e.viewport.referenceFrame,i=this.browser.genome.getChromosome(n.mate.chr);if(i){this.selectedReadName=n.readName;const r=t.bpPerPixel*e.viewport.getWidth(),s=n.mate.position-r/2,o=n.mate.position+r/2;this.browser.addMultiLocusPanel(i.name,s,o,t)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:\"View read sequence\",click:()=>{const e=n.seq;e&&\"*\"!==e?this.browser.alert.present(e):this.browser.alert.present(\"Read sequence: *\")}}),Xa()&&i.push({label:\"Copy read sequence\",click:async()=>{const e=n.seq;try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}});const t=n.seq;if(t&&\"*\"!==t){t.length{const e=n.isNegativeStrand()?cc(t):t,i=`${n.readName} - blat`,r=`${this.name} - ${i}`;jd({sequence:e,browser:this.browser,name:i,title:r})}});const e=n.softClippedBlocks();e.left&&e.left.len>20&&e.left.len{const i=t.substr(e.left.seqOffset,e.left.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat left clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}}),e.right&&e.right.len>20&&e.right.len{const i=t.substr(e.right.seqOffset,e.right.len),r=n.isNegativeStrand()?cc(i):i,s=`${n.readName} - blat right clip`,o=`${this.name} - ${s}`;jd({sequence:r,browser:this.browser,name:s,title:o})}})}i.push(\"
\")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:\"Add discordant pairs to circular view\",click:()=>{this.addPairedChordsForViewport(t)}}),this.hasSupplemental&&i.push({label:\"Add split reads to circular view\",click:()=>{this.addSplitChordsForViewport(t)}}),i.push(\"
\")),i}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t)return;const i=e.y-this.top,n=e.genomicLocation;if(t.packedGroups){let e=Number.MAX_VALUE;for(let r of t.packedGroups.values())if(e=Math.min(e,r.pixelTop),i>r.pixelTop&&i<=r.pixelBottom){const e=\"SQUISHED\"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let t=Math.floor((i-r.pixelTop)/e);if(t>=0&&te.containsLocation(n,this.showSoftClips)));if(e.length>0)return e[0]}}}if(i=n)return e}getConnectorColor(e){if(this.pairConnectorColor)return this.pairConnectorColor;let t=this.colorBy;switch(t&&t.startsWith(\"tag:\")&&(t.substring(4),t=\"tag\"),t){case\"strand\":case\"firstOfPairStrand\":case\"pairOrientation\":case\"tag\":return this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(200, 200, 200)\";default:return this.getAlignmentColor(e)}}getAlignmentColor(e){let t;t=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"rgb(185, 185, 185)\";let i,n=this.colorBy;switch(n&&n.startsWith(\"tag:\")&&(i=n.substring(4),n=\"tag\"),n){case\"basemod\":case\"basemod2\":t=e.strand?this.baseModPosStrandColor:this.baseModNegStrandColor;break;case\"strand\":t=e.strand?this.posStrandColor:this.negStrandColor;break;case\"firstOfPairStrand\":const r=e.firstOfPairStrand;void 0!==r&&(t=r?this.posStrandColor:this.negStrandColor);break;case\"unexpectedPair\":case\"pairOrientation\":if(e.pairOrientation){const i=ep[this.expectedPairOrientation];if(i){const n=this.pairColors[i[e.pairOrientation]];if(n){t=n;break}}}if(\"pairOrientation\"===n)break;case\"tlen\":case\"fragmentLength\":e.mate&&e.isMateMapped()&&(e.mate.chr!==e.chr?t=Nu(e.mate.chr):this.minTemplateLength&&Math.abs(e.fragmentLength)this.maxTemplateLength&&(t=this.largeTLENColor));break;case\"tag\":const s=e.tags()[i];void 0!==s&&(this.bamColorTag===i&&(t=_s.createColorStringSafe(s)),this.colorTable||(this.colorTable=new oo(this.tagColorPallete)),t=this.colorTable.getColor(s))}return t}get nucleotideColors(){return this.browser.nucleotideColors}get minTemplateLength(){return void 0!==this.minTLEN?this.minTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.minTLEN:0}get maxTemplateLength(){return void 0!==this.maxTLEN?this.maxTLEN:this.parent._pairedEndStats?this.parent._pairedEndStats.maxTLEN:1e3}getState(){const e=super.getState();return this.highlightedReads&&(e.highlightedReads=Array.from(this.highlightedReads)),e}get name(){return this.parent.name}set name(e){this.parent.name=e}get color(){return this.parent.color}set color(e){this.parent.color=e}get trackView(){return this.parent.trackView}get getCachedAlignmentContainers(){return this.parent.getCachedAlignmentContainers}get sortObject(){return this.parent.sortObject}set sortObject(e){this.parent.sortObject=e}addPairedChordsForViewport(e){return this.parent.addPairedChordsForViewport(e)}addSplitChordsForViewport(e){return this.parent.addSplitChordsForViewport(e)}}function Xm(e,t){let i;return i=e<5?.1:Math.max(.1,Math.min(1,.1+.9*(e-5)/15)),i=Math.round(10*i)/10,i<1&&(t=_s.addAlpha(t,i)),t}function Zm(){\"FULL\"!==this.displayMode||this.browser.isTrackPanning()||this.repackAlignments()}function Jm(e,t,i,n,r,s,o,a,c){const l=o.baseModCounts,h=o.coverageMap;if(l){let o;const d=a.split(\":\");2==d.length&&(a=d[0],o=d[1]);const u=Array.from(l.allModifications);u.sort(Vf.compare);const f=h.getTotalCount(s);if(!u.filter((e=>o?o===e.modification:!e.modification.startsWith(\"NONE_\"))).find((e=>l.getCount(s,e,0,!1)>0)))return;for(let d of u){if(d.modification.startsWith(\"NONE_\")&&\"basemod2\"!==a)continue;if(o&&o!==d.modification&&!d.modification.startsWith(\"NONE_\"))continue;const u=d.base,p=oc(u),g=h.getCount(s,u)+h.getCount(s,p),m=l.simplexModifications.has(d.modification)?h.getPosCount(s,u)+h.getNegCount(s,p):g;if(0==m)continue;const w=\"basemod2\"===a,b=l.getCount(s,d,c,w);if(0==b)continue;const F=g/f*(b/m),v=Math.round(F*r),y=l.getLikelihoodSum(s,d,c,w)/b,A=i-v,C=Gm(d.modification,y,a);e.fillStyle=C,e.fillRect(t,A,n,v),i=A}}}class ew{constructor(e,t){this.featureType=\"numeric\",this.parent=t,this.featureSource=t.featureSource,this.paintAxis=cd,this.top=0,this.autoscale=e.autoscale||void 0===e.max,e.coverageColor&&(this.color=e.coverageColor),this.autoscale||(this.dataRange={min:e.min||0,max:e.max})}get height(){return this.parent.coverageTrackHeight}draw(e){const t=e.pixelTop;e.pixelHeight;const i=this.parent.browser.nucleotideColors;if(t>this.height)return;const n=e.context,r=e.features,s=r.coverageMap;let o;s.refSeq&&(o=s.refSeq.toUpperCase());const a=e.bpPerPixel,c=e.bpStart,l=c+e.pixelWidth*a+1;let h;h=this.color?this.color:this.parent.color&&\"function\"!=typeof this.parent.color?_s.darkenLighten(this.parent.color,-35):\"rgb(150, 150, 150)\",xo.setProperties(n,{fillStyle:h,strokeStyle:h});const d=Math.max(1,1/a);for(let e=0,t=s.coverage.length;el)break;const i=s.coverage[e];if(!i)continue;const r=i.total/this.dataRange.max*this.height,o=this.height-r,h=(t-c)/a;xo.fillRect(n,h,o,d,r)}if(o)for(let e=0,t=s.coverage.length;el)break;const h=s.coverage[e];if(!h)continue;const u=h.total/this.dataRange.max*this.height;let f=this.height-u;const p=Math.floor((t-c)/a),g=o[e];if(this.parent.colorBy&&this.parent.colorBy.startsWith(\"basemod\"))Jm(n,p,this.height,d,u,t,r,this.parent.colorBy,this.parent.baseModificationThreshold);else if(h.isMismatch(g)){xo.setProperties(n,{fillStyle:i[g]}),xo.fillRect(n,p,f,d,u);let e=0;for(let t of[\"A\",\"C\",\"T\",\"G\"]){const r=(h[\"pos\"+t]+h[\"neg\"+t])/this.dataRange.max*this.height;f=this.height-r-e,e+=r,xo.setProperties(n,{fillStyle:i[t]}),xo.fillRect(n,p,f,d,r)}}}}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t||0===t.length)return;const i=Math.floor(e.genomicLocation),n=t.coverageMap,r=Math.floor(i-n.bpStart),s=n.coverage[r];return s?{coverage:s,baseModCounts:t.baseModCounts,hoverText:()=>n.coverage[r].hoverText()}:void 0}popupData(e){const t=[],{coverage:i,baseModCounts:n}=this.getClickedObject(e);if(i){const r=Math.floor(e.genomicLocation),s=e.viewport.referenceFrame;t.push(s.chr+\":\"+Rt(1+r)),t.push({name:\"Total Count\",value:i.total});let o=i.posA+i.negA;o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posA+\"+, \"+i.negA+\"- )\"),t.push({name:\"A\",value:o}),o=i.posC+i.negC,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posC+\"+, \"+i.negC+\"- )\"),t.push({name:\"C\",value:o}),o=i.posG+i.negG,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posG+\"+, \"+i.negG+\"- )\"),t.push({name:\"G\",value:o}),o=i.posT+i.negT,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posT+\"+, \"+i.negT+\"- )\"),t.push({name:\"T\",value:o}),o=i.posN+i.negN,o>0&&(o=o.toString()+\" (\"+Math.round(o/i.total*100)+\"%, \"+i.posN+\"+, \"+i.negN+\"- )\"),t.push({name:\"N\",value:o}),t.push(\"
\"),t.push({name:\"DEL\",value:i.del.toString()}),t.push({name:\"INS\",value:i.ins.toString()}),n&&(t.push(\"
\"),t.push(...n.popupData(r,this.parent.colorBy)))}return t}}class tw extends Hl{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,height:300,coverageTrackHeight:50,baseModificationThreshold:0};constructor(e,t){super(e,t)}init(e){this.type=\"alignment\",this.featureSource=new cm(e,this.browser);const t=Object.assign({parent:this},e);this.coverageTrack=new ew(t,this);const i=Object.assign({parent:this},e);this.alignmentTrack=new Ym(i,this.browser),super.init(e),this.showAlignments||(this._height=this.coverageTrackHeight),e.sort&&(Array.isArray(e.sort)?this.assignSort(e.sort[0]):this.assignSort(e.sort))}dispose(){this.alignmentTrack.dispose()}setHighlightedReads(e,t){this.alignmentTrack.setHighlightedReads(e,t),this.updateViews()}get expectedPairOrientation(){return this.alignmentTrack.expectedPairOrientation}get viewAsPairs(){return this.alignmentTrack.viewAsPairs}get colorBy(){return this.alignmentTrack.colorBy}set height(e){this._height=e,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?e-this.coverageTrackHeight:e)}get height(){return this._height}sort(e){e=this.assignSort(e);for(let t of this.trackView.viewports)if(t.containsPosition(e.chr,e.position)){const i=t.cachedFeatures;i&&(i.sortRows(e),t.repaint())}}assignSort(e){if(e.locus){const t=function(e){const t=e.split(\":\"),i=t[1].split(\"-\"),n={chr:t[0],start:Number.parseInt(i[0].replace(/,/g,\"\"))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,\"\")):n.end=n.start+1,n}(e.locus);e.chr=t.chr,e.position=t.start}else e.position--;return e.direction=\"ASC\"===e.direction||!0===e.direction,e.chr=this.browser.genome.getChromosomeName(e.chr),this.sortObject=e,this.sortObject}async getFeatures(e,t,i,n,r){const s=await this.featureSource.getAlignments(e,t,i);if(s.viewport=r,s.hasPairs&&!this._pairedEndStats&&!this.config.maxFragmentLength){const e=new Om(s.allAlignments(),this.config);e.totalCount>99&&(this._pairedEndStats=e)}s.pack(this.alignmentTrack);const o=this.sortObject;return o&&o.chr===e&&o.position>=t&&o.position<=i&&s.sortRows(o),this.alignmentTrack.hasPairs=this.alignmentTrack.hasPairs||s.hasPairs,s}computePixelHeight(e){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(e):0)}draw(e){xo.fillRect(e.context,0,e.pixelTop,e.pixelWidth,e.pixelHeight,{fillStyle:\"rgb(255, 255, 255)\"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display=\"block\",this.coverageTrack.draw(e)):this.trackView.axisCanvas.style.display=\"none\",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(e))}paintAxis(e,t,i){this.coverageTrack.paintAxis(e,t,this.coverageTrackHeight)}contextMenuItemList(e){return this.alignmentTrack.contextMenuItemList(e)}popupData(e){return!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y=this.coverageTrack.top&&e.y{if(!this.autoHeight){const e=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(e)}};return e.push(\"
\"),e.push({object:Bt(Dl(\"Show Coverage\",this.showCoverage)),click:function(){this.showCoverage=!this.showCoverage,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:Bt(Dl(\"Show Alignments\",this.showAlignments)),click:function(){this.showAlignments=!this.showAlignments,t(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e}getState(){const e=super.getState();return this.sortObject&&(e.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?\"ASC\":\"DESC\"}),Object.assign(e,this.alignmentTrack.getState()),e}getCachedAlignmentContainers(){return this.trackView.viewports.map((e=>e.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(e){this.coverageTrack.dataRange=e}get logScale(){return this.coverageTrack.logScale}set logScale(e){this.coverageTrack.logScale=e}get autoscale(){return this.coverageTrack.autoscale}set autoscale(e){this.coverageTrack.autoscale=e}addPairedChordsForViewport(e){const t=this.maxTemplateLength,i=[],n=e.referenceFrame;for(let r of e.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>t&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>t)&&i.push(r));Pm((e=>{const t=[];for(let i of e)if(i.paired)i.firstAlignment&&i.secondAlignment&&t.push({uniqueId:i.readName,refName:zm(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:zm(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const e=i.mate;e&&e.chr&&e.position&&t.push({uniqueId:i.readName,refName:zm(i.chr),start:i.start,end:i.end,mate:{refName:zm(e.chr),start:e.position-1,end:e.position}})}return t})(i),this,n,.02)}addSplitChordsForViewport(e){const t=[],i=e.referenceFrame;for(let n of e.cachedFeatures.allAlignments()){const e=n.hasTag(\"SA\");n.end>=i.start&&n.start<=i.end&&e&&t.push(n)}Pm((e=>{const t=e=>{const t=gp(e.tags().SA);let n=0;for(let r of t)r.start!==e.start&&i.push({uniqueId:`${e.readName}_${n++}`,refName:zm(e.chr),start:e.start,end:e.end,mate:{refName:zm(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of e)i.paired?(t(i.firstAlignment),i.secondAlignment&&t(i.secondAlignment)):t(i);return i})(t),this,i,.02)}}class iw extends Hl{static defaults={height:250,theta:Math.PI/4,arcOrientation:\"UP\",showBlocks:!0,blockHeight:3,thickness:1,color:\"rgb(180,25,137)\",alpha:.02,logScale:!0};constructor(e,t){super(e,t)}init(e){super.init(e),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(e){if(!e.arcType)return\"nested\";switch(e.arcType){case\"chiapet\":return\"inView\";case\"chiapetoutbound\":return\"partialInView\";default:return e.arcType}}(e),this.painter={flipAxis:\"DOWN\"===this.arcOrientation,dataRange:this.dataRange,paintAxis:cd},e.valueColumn?(this.valueColumn=e.valueColumn,this.hasValue=!0):e.useScore&&(this.hasValue=!0,this.valueColumn=\"score\"),e.max?(this.dataRange={min:e.min||0,max:e.max},this.autoscale=!1):this.autoscale=!0,e.featureSource?(this.featureSource=e.featureSource,delete e._featureSource):(this.featureSource=Ad(e,this.browser.genome),this.featureSource.getWGFeatures=aw)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(e){\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?this.drawProportional(e):this.drawNested(e)}drawNested(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.viewportWidth,s=e.bpPerPixel,o=e.bpStart,a=s;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const c=e.features;if(c){(function(){let e=0;for(let t of c){let n=(t.start-o)/a,r=(t.end-o)/a;n>=0&&r<=i&&(e=Math.max(e,r-n))}let t=Math.min(r,e)/2;if(e>0){let e=(n-10)/t;this.theta=function(e){let t,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(t=0;te);t++);let r=0===t?0:i[t-1],s=ti)continue;let f=u-d;f<3&&(f=3,d--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,w=d+p;let b,F,v;if(s?(b=this.height+m,F=Math.PI+Math.PI/2-this.theta,v=Math.PI+Math.PI/2+this.theta):(b=-m,F=Math.PI/2-this.theta,v=Math.PI/2+this.theta),this.showBlocks&&\"all\"!==e.chr){const i=(e.start1-o)/a,n=(e.end1-o)/a,r=(e.start2-o)/a,c=(e.end2-o)/a,l=s?-this.blockHeight:this.blockHeight;t.fillRect(i,h,n-i,l),t.fillRect(r,h,c-r,l)}n&&!this.config.useScore&&f>r&&(n=ow(n,this.alpha)),t.strokeStyle=n,t.fillStyle=n,t.beginPath(),t.arc(w,b,g,F,v,!1),t.stroke(),e.drawState={xc:w,yc:b,r:g}}else{let r=Math.round((e.start-o)/a),c=Math.round((e.end-o)/a);if(c<0||r>i)continue;let l=c-r;l<3&&(l=3,r--);const h=e.chr===e.chr1?e.chr2:e.chr1;t.strokeStyle=n,t.fillStyle=ow(Nu(h),.5),s?(t.fillRect(r,this.height/2,l,this.height/2),t.fillText(h,r+l/2,this.height/2-5),e.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(t.fillRect(r,0,l,this.height/2),t.fillText(h,r+l/2,this.height/2+13),e.drawState={x:r,y:0,w:l,h:this.height/2})}}}var l}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}drawProportional(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.bpPerPixel,s=e.bpStart,o=r,a=e.referenceFrame.start,c=e.referenceFrame.end,l=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,i,n,{fillStyle:\"rgb(255, 255, 255)\"});const h=e.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,e.pixelHeight-1,this.logScale),d=l?e.pixelHeight:0;for(let e of h){e.drawState=void 0;const n=this.valueColumn?e[this.valueColumn]:e.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(e.chr1===e.chr2||\"all\"===e.chr){const{m1:i,m2:r}=nw(e,this.browser.genome);let u=Math.round((i-s)/o),f=Math.round((r-s)/o)-u;if(f<3&&(f=3,u--),nthis.dataRange.max)continue;if(\"proportional\"!==this.arcType){const e=\"partialInView\"===this.arcType,t=i>=a&&r<=c;let n=!1,s=!1;if(!t&&e&&(n=a<=i&&i<=c,n||(s=a<=r&&r<=c)),!(t||n||s))continue}const p=f/2,g=u+f/2;e.drawState={xc:g,yc:d,radiusX:p,radiusY:h};const m=l,w=e.color||this.color;if(t.strokeStyle=w,t.lineWidth=e.thickness||this.thickness||1,!0===t.isSVG?t.strokeEllipse(g,d,p,h,0,0,Math.PI,m):(t.beginPath(),t.ellipse(g,d,p,h,0,0,Math.PI,m),t.stroke()),this.alpha&&(t.fillStyle=ow(w,this.alpha),!0===t.isSVG?t.fillEllipse(g,d,p,h,0,0,Math.PI,m):t.fill()),this.showBlocks&&\"all\"!==e.chr){t.fillStyle=w;const i=(e.start1-s)/o,n=(e.end1-s)/o,r=(e.start2-s)/o,a=(e.end2-s)/o,c=l?-this.blockHeight:this.blockHeight;t.fillRect(i,d,n-i,c),t.fillRect(r,d,a-r,c)}}else{let r=Math.round((e.start-s)/o),a=Math.round((e.end-s)/o);if(a<0||r>i||nthis.dataRange.max)continue;const c=Math.min(h,this.height-13);let d=a-r;d<3&&(d=3,r--);const u=e.chr===e.chr1?e.chr2:e.chr1;if(t.font=\"8px sans-serif\",t.textAlign=\"center\",t.fillStyle=ow(Nu(u),.5),l){const i=this.height-c;t.fillRect(r,i,d,c),t.fillText(u,r+d/2,i-5),e.drawState={x:r,y:i,w:d,h:c}}else t.fillRect(r,0,d,c),t.fillText(u,r+d/2,c+13),e.drawState={x:r,y:0,w:d,h:c}}}}}clearAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"})}paintAxis(e,t,i){const n={min:0,max:this.dataRange.max};\"proportional\"===this.arcType||\"inView\"===this.arcType||\"partialInView\"===this.arcType?(this.painter.flipAxis=\"DOWN\"===this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(e,t,i)):this.clearAxis(e,t,i)}menuItemList(){let e=[];if(this.hasValue){e.push(\"
\");const t={nested:\"Nested\",proportional:\"Proportional - All\",inView:\"Proportional - Both Ends in View\",partialInView:\"Proportional - One End in View\"};e.push(\"Arc Type\");for(let i of[\"nested\",\"proportional\",\"inView\",\"partialInView\"])e.push({object:Bt(Dl(t[i],i===this.arcType)),click:function(){this.arcType=i,this.trackView.repaintViews()}})}return e.push(\"
\"),e.push({name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}),e.push({name:this.showBlocks?\"Hide Blocks\":\"Show Blocks\",click:function(){this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),\"proportional\"!==this.arcType&&\"inView\"!==this.arcType&&\"partialInView\"!==this.arcType||(e=e.concat(this.numericDataMenuItems())),this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add interactions to circular view\",click:function(){for(let e of this.trackView.viewports)this.addChordsForViewport(e.referenceFrame)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:\"Add interactions to circular view\",click:()=>{const e=t.referenceFrame;this.addChordsForViewport(e)}}),i.push(\"
\"),i}}addChordsForViewport(e){let t;if(\"all\"===e.chr)t=Object.values(this.featureSource.getAllFeatures()).flat();else{t=this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end).filter((e=>e.drawState))}if(0===t.length)return;Pm(t.map((e=>{const t=e._f||e;return{uniqueId:`${t.chr1}:${t.start1}-${t.end1}_${t.chr2}:${t.start2}-${t.end2}`,refName:zm(t.chr1),start:t.start1,end:t.end1,mate:{refName:zm(t.chr2),start:t.start2,end:t.end2}}})),this,e,.5)}doAutoscale(e){let t=0;if(e)for(let i of e){const e=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(e)||(t=Math.max(t,e))}return{min:0,max:t}}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){const t=e._||e;if(i.push({name:\"Region 1\",value:rw(t.chr1,t.start1,t.end1,t.strand1)}),i.push({name:\"Region 2\",value:rw(t.chr2,t.start2,t.end2,t.strand2)}),t.name&&i.push({name:\"Name\",value:t.name}),void 0!==t.value&&i.push({name:\"Value\",value:t.value}),void 0!==t.score&&i.push({name:\"Score\",value:t.score}),t.extras&&this.header&&this.header.columnNames){const e=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r=t-a&&e.canvasX<=t+s+a&&e.canvasY>=n&&e.canvasY<=n+o){const n=-Math.abs(e.canvasX-(t+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((e,t)=>e.score-t.score)),i.map((e=>e.feature))}}function nw(e,t){let i=(e.start1+e.end1)/2,n=(e.start2+e.end2)/2;if(\"all\"===e.chr&&(i=t.getGenomeCoordinate(e.chr1,i),n=t.getGenomeCoordinate(e.chr2,n)),i>n){const e=i;i=n,n=e}return{m1:i,m2:n}}function rw(e,t,i,n){return n&&\".\"!==n?`${e}:${Rt(t+1)}-${Rt(i)} (${n})`:`${e}:${Rt(t+1)}-${Rt(i)}`}const sw=new Map;function ow(e,t){const i=`${e}_${t}`;let n=sw.get(i);return n||(n=_s.addAlpha(e,t),sw.set(i,n)),n}function aw(e){const t=e=>{const t=Object.assign({},e);return t.chr=\"all\",t.start=i.getGenomeCoordinate(e.chr1,e.start1),t.end=i.getGenomeCoordinate(e.chr2,e.end2),t},i=this.genome;let n,r=0;for(let t of i.wgChromosomeNames){let i=e[t];if(i)for(let e of i)e.dup||(r++,e.score&&(!n||e.score>n.score)&&(n=e))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),c=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let l,h=[],d=[];for(let e=0;e=400){const e=Error(r.statusText);throw e.code=s,e}return r.arrayBuffer()}}class hw{constructor(e){this.file=e.file,this.fetchSize=e.fetchSize||16e3,this.maxSize=e.maxSize||1e6,this.buffers=[]}async read(e,t){let i=this.buffers.filter((i=>i.overlaps(e,e+t)));for(let n of i)if(n.contains(e,e+t))return n.slice(e,e+t);if(0===i.length){let i=Math.max(t,this.fetchSize);this.buffers.sort(((e,t)=>e.start-t.start));const n=function(e,t,i){let n=i-1,r=e.length;for(;1+n>1);t(e[i])?r=i:n=i}return r}(this.buffers,(t=>t.start>e),0);ne.start-t.start));const n=[];let r=e;for(let e of i){if(rr){const e=r,t=s-e,i=await this.file.read(e,t),o=new dw(e,i);n.push(o)}const o=n[0].start,a=function(e){const t=e.reduce(((e,t)=>e+t.byteLength),0),i=new Uint8Array(t);let n=0;for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(n.map((e=>e.buffer))),c=new dw(o,a),l=new Set(i);return this.buffers=this.buffers.filter((e=>!l.has(e))),this.addBuffer(c),c.slice(e,e+t)}}addBuffer(e){const t=this.buffers.reduce(((e,t)=>e+t.size),0)+e.size;if(t>this.maxSize){const e=t-this.maxSize;this.buffers.sort(((e,t)=>e.creationTime-t.creationTime));let i,n=0;for(i=0;ie));i++);this.buffers=ithis.buffer.byteLength)throw Error(\"buffer bounds error\");return this.buffer.slice(e-this.start,t-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(e,t){return e>=this.start&&t<=this.end}overlaps(e,t){return e>this.start&&ethis.start&&t(((e,t,i)=>{t in e?fw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,\"symbol\"!=typeof t?t+\"\":t,i),i);async function gw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=await Aw.unpack_from_async(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function mw(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=Aw.unpack_from(\"<\"+s,t,i);i+=Aw.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function ww(e){e||e()}function bw(e){var t=\"<\"+Array.from(e.values()).join(\"\");return Aw.calcsize(t)}function Fw(e,t=8){return Math.ceil(e/t)*t}var vw={u:\"Uint\",i:\"Int\",f:\"Float\"};function yw(e){var t,i,n=Aw._is_big_endian(e);if(/S/.test(e))t=\"getString\",i=0|((e.match(/S(\\d*)/)||[])[1]||1);else{let[n,r,s]=e.match(/[<>=!@]?(i|u|f)(\\d*)/);i=parseInt(s||4,10),t=\"get\"+vw[r]+(8*i).toFixed()}return[t,n,i]}var Aw=new class{constructor(){this.big_endian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}(),this.getters={s:\"getUint8\",b:\"getInt8\",B:\"getUint8\",h:\"getInt16\",H:\"getUint16\",i:\"getInt32\",I:\"getUint32\",l:\"getInt32\",L:\"getUint32\",q:\"getInt64\",Q:\"getUint64\",f:\"getFloat32\",d:\"getFloat64\"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let e=Object.keys(this.byte_lengths).join(\"\");this.fmt_size_regex=\"(\\\\d*)([\"+e+\"])\"}calcsize(e){for(var t,i=0,n=new RegExp(this.fmt_size_regex,\"g\");null!==(t=n.exec(e));){let e=parseInt(t[1]||1,10),n=t[2];i+=e*this.byte_lengths[n]}return i}_is_big_endian(e){return!/^)/.test(e)||this.big_endian)}async unpack_from_async(e,t,i){i=Number.parseInt(i||0);const n=this.calcsize(e),r=await t.slice(i,i+n);let s=0;for(var o,a=new Cw(r),c=[],l=this._is_big_endian(e),h=new RegExp(this.fmt_size_regex,\"g\");null!==(o=h.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if(\"s\"==t)c.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;de+(t<<8*i)),0);return o}var kw=class{constructor(e,t){this.buf=e,this.offset=t,this.dtype=this.determine_dtype()}async determine_dtype(){let e=await gw(Iw,this.buf,this.offset);this.offset+=Sw;let t=15&e.get(\"class_and_version\");if(t==Ew)return this._determine_dtype_fixed_point(e);if(t==Nw)return this._determine_dtype_floating_point(e);if(t==Bw)throw\"Time datatype class not supported.\";if(t==Mw)return this._determine_dtype_string(e);if(t==Rw)throw\"Bitfield datatype class not supported.\";if(t==Dw)return{datatype_class:Dw,size:e.get(\"size\")};if(t==Tw)return this._determine_dtype_compound(e);if(t==Lw)return[\"REFERENCE\",e.get(\"size\")];if(t==zw)return this.determine_dtype();if(t==Pw)throw\"Array datatype class not supported.\";if(t==Hw){let t=this._determine_dtype_vlen(e);if(\"VLEN_SEQUENCE\"==t[0]){t=[\"VLEN_SEQUENCE\",this.determine_dtype()]}return t}throw\"Invalid datatype class \"+t}_determine_dtype_fixed_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;var n;return i=(8&e.get(\"class_bit_field_0\"))>0?\"i\":\"u\",n=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=4,n+i+t.toFixed()}_determine_dtype_floating_point(e){let t=e.get(\"size\");if(![1,2,4,8].includes(t))throw\"Unsupported datatype size\";var i;return i=0==(1&e.get(\"class_bit_field_0\"))?\"<\":\">\",this.offset+=12,i+\"f\"+t.toFixed()}_determine_dtype_string(e){return\"S\"+e.get(\"size\").toFixed()}_determine_dtype_vlen(e){return 1!=(1&e.get(\"class_bit_field_0\"))?[\"VLEN_SEQUENCE\",0,0]:[\"VLEN_STRING\",e.get(\"class_bit_field_0\")>>4,1&e.get(\"class_bit_field_1\")]}_determine_dtype_compound(e){throw\"Compound type not yet implemented!\"}},Iw=new Map([[\"class_and_version\",\"B\"],[\"class_bit_field_0\",\"B\"],[\"class_bit_field_1\",\"B\"],[\"class_bit_field_2\",\"B\"],[\"size\",\"I\"]]),Sw=bw(Iw);bw(new Map([[\"offset\",\"I\"],[\"dimensionality\",\"B\"],[\"reserved_0\",\"B\"],[\"reserved_1\",\"B\"],[\"reserved_2\",\"B\"],[\"permutation\",\"I\"],[\"reserved_3\",\"I\"],[\"dim_size_1\",\"I\"],[\"dim_size_2\",\"I\"],[\"dim_size_3\",\"I\"],[\"dim_size_4\",\"I\"]]));var Ew=0,Nw=1,Bw=2,Mw=3,Rw=4,Dw=5,Tw=6,Lw=7,zw=8,Hw=9,Pw=10;function Ow(e){let t=e.length;for(;--t>=0;)e[t]=0}Ow(new Array(576)),Ow(new Array(60)),Ow(new Array(512)),Ow(new Array(256)),Ow(new Array(29)),Ow(new Array(30));var Uw=(e,t,i,n)=>{let r=65535&e,s=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16},qw=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})()),Qw=(e,t,i,n)=>{const r=qw,s=n+i;e^=-1;for(let i=n;i>>8^r[255&(e^t[i])];return~e},Vw={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"},jw={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Ww=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gw={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if(\"object\"!=typeof i)throw new TypeError(i+\"must be non-object\");for(const t in i)Ww(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i=252?6:RA>=248?5:RA>=240?4:RA>=224?3:RA>=192?2:1;Kw[254]=Kw[254]=1;var Yw={string2buf:e=>{if(\"function\"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if(\"function\"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&$w)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i=\"\";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Kw[e[i]]>t?i:t}};var Xw=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0},Zw=function(e,t){let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_,x;const k=e.state;i=e.next_in,_=e.input,n=i+(e.avail_in-5),r=e.next_out,x=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=k.dmax,c=k.wsize,l=k.whave,h=k.wnext,d=k.window,u=k.hold,f=k.bits,p=k.lencode,g=k.distcode,m=(1<>>24,u>>>=F,f-=F,F=b>>>16&255,0===F)x[r++]=65535&b;else{if(!(16&F)){if(64&F){if(32&F){k.mode=12;break e}e.msg=\"invalid literal/length code\",k.mode=30;break e}b=p[(65535&b)+(u&(1<>>=F,f-=F),f<15&&(u+=_[i++]<>>24,u>>>=F,f-=F,F=b>>>16&255,16&F){if(y=65535&b,F&=15,fa){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(u>>>=F,f-=F,F=r-s,y>F){if(F=y-F,F>l&&k.sane){e.msg=\"invalid distance too far back\",k.mode=30;break e}if(A=0,C=d,0===h){if(A+=c-F,F2;)x[r++]=C[A++],x[r++]=C[A++],x[r++]=C[A++],v-=3;v&&(x[r++]=C[A++],v>1&&(x[r++]=C[A++]))}else{A=r-y;do{x[r++]=x[A++],x[r++]=x[A++],x[r++]=x[A++],v-=3}while(v>2);v&&(x[r++]=x[A++],v>1&&(x[r++]=x[A++]))}break}if(64&F){e.msg=\"invalid distance code\",k.mode=30;break e}b=g[(65535&b)+(u&(1<>3,i-=v,f-=v<<3,u&=(1<{const c=a.bits;let l,h,d,u,f,p,g=0,m=0,w=0,b=0,F=0,v=0,y=0,A=0,C=0,_=0,x=null,k=0;const I=new Uint16Array(16),S=new Uint16Array(16);let E,N,B,M=null,R=0;for(g=0;g<=Jw;g++)I[g]=0;for(m=0;m=1&&0===I[b];b--);if(F>b&&(F=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(w=1;w0&&(0===e||1!==b))return-1;for(S[1]=0,g=1;g852||2===e&&C>592)return 1;for(;;){E=g-y,o[m]p?(N=M[R+o[m]],B=x[k+o[m]]):(N=96,B=0),l=1<>y)+h]=E<<24|N<<16|B}while(0!==h);for(l=1<>=1;if(0!==l?(_&=l-1,_+=l):_=0,m++,0==--I[g]){if(g===b)break;g=t[i+o[m]]}if(g>F&&(_&u)!==d){for(0===y&&(y=F),f+=w,v=g-y,A=1<852||2===e&&C>592)return 1;d=_&u,r[d]=F<<24|v<<16|f-s}}return 0!==_&&(r[f+_]=g-y<<24|64<<16),a.bits=F,0},{Z_FINISH:sb,Z_BLOCK:ob,Z_TREES:ab,Z_OK:cb,Z_STREAM_END:lb,Z_NEED_DICT:hb,Z_STREAM_ERROR:db,Z_DATA_ERROR:ub,Z_MEM_ERROR:fb,Z_BUF_ERROR:pb,Z_DEFLATED:gb}=jw,mb=12,wb=30,bb=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Fb(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var vb,yb,Ab=e=>{if(!e||!e.state)return db;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,cb},Cb=e=>{if(!e||!e.state)return db;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ab(e)},_b=(e,t)=>{let i;if(!e||!e.state)return db;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?db:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Cb(e))},xb=(e,t)=>{if(!e)return db;const i=new Fb;e.state=i,i.window=null;const n=_b(e,t);return n!==cb&&(e.state=null),n},kb=!0,Ib=e=>{if(kb){vb=new Int32Array(512),yb=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rb(1,e.lens,0,288,vb,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rb(2,e.lens,0,32,yb,0,e.work,{bits:5}),kb=!1}e.lencode=vb,e.lenbits=9,e.distcode=yb,e.distbits=5},Sb=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave{let i,n,r,s,o,a,c,l,h,d,u,f,p,g,m,w,b,F,v,y,A,C,_=0;const x=new Uint8Array(4);let k,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return db;i=e.state,i.mode===mb&&(i.mode=13),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,d=a,u=c,C=cb;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg=\"incorrect header check\",i.mode=wb;break}if((15&l)!==gb){e.msg=\"unknown compression method\",i.mode=wb;break}if(l>>>=4,h-=4,A=8+(15&l),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg=\"invalid window size\",i.mode=wb;break}i.dmax=1<>8&1),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,i.check=Qw(i.check,x,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(x[0]=255&l,x[1]=l>>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=Qw(i.check,x,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),A)),512&i.flags&&(i.check=Qw(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{A=n[s+f++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mb;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1,h-=1,3&l){case 0:i.mode=14;break;case 1:if(Ib(i),i.mode=20,t===ab){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg=\"invalid block type\",i.mode=wb}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",i.mode=wb;break}if(i.length=65535&l,l=0,h=0,i.mode=15,t===ab)break e;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=mb;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg=\"too many length or distance symbols\",i.mode=wb;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,k={bits:i.lenbits},C=rb(0,i.lens,0,19,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid code lengths set\",i.mode=wb;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=m,h-=m,i.lens[i.have++]=b;else{if(16===b){for(I=m+2;h>>=m,h-=m,0===i.have){e.msg=\"invalid bit length repeat\",i.mode=wb;break}A=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===b){for(I=m+3;h>>=m,h-=m,A=0,f=3+(7&l),l>>>=3,h-=3}else{for(I=m+7;h>>=m,h-=m,A=0,f=11+(127&l),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg=\"invalid bit length repeat\",i.mode=wb;break}for(;f--;)i.lens[i.have++]=A}}if(i.mode===wb)break;if(0===i.lens[256]){e.msg=\"invalid code -- missing end-of-block\",i.mode=wb;break}if(i.lenbits=9,k={bits:i.lenbits},C=rb(1,i.lens,0,i.nlen,i.lencode,0,i.work,k),i.lenbits=k.bits,C){e.msg=\"invalid literal/lengths set\",i.mode=wb;break}if(i.distbits=6,i.distcode=i.distdyn,k={bits:i.distbits},C=rb(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,k),i.distbits=k.bits,C){e.msg=\"invalid distances set\",i.mode=wb;break}if(i.mode=20,t===ab)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,Zw(e,u),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===mb&&(i.back=-1);break}for(i.back=0;_=i.lencode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,i.length=b,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=mb;break}if(64&w){e.msg=\"invalid literal/length code\",i.mode=wb;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;_=i.distcode[l&(1<>>24,w=_>>>16&255,b=65535&_,!(m<=h);){if(0===a)break e;a--,l+=n[s++]<>F)],m=_>>>24,w=_>>>16&255,b=65535&_,!(F+m<=h);){if(0===a)break e;a--,l+=n[s++]<>>=F,h-=F,i.back+=F}if(l>>>=m,h-=m,i.back+=m,64&w){e.msg=\"invalid distance code\",i.mode=wb;break}i.offset=b,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(I=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg=\"invalid distance too far back\",i.mode=wb;break}i.mode=25;case 25:if(0===c)break e;if(f=u-c,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg=\"invalid distance too far back\",i.mode=wb;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<xb(e,15),inflateInit2:xb,inflate:Eb,inflateEnd:e=>{if(!e||!e.state)return db;let t=e.state;return t.window&&(t.window=null),e.state=null,cb},inflateGetHeader:(e,t)=>{if(!e||!e.state)return db;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,cb):db},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?db:11===n.mode&&(r=1,r=Uw(r,t,i,0),r!==n.check)?ub:(s=Sb(e,t,i,i),s?(n.mode=31,fb):(n.havedict=1,cb))):db},inflateInfo:\"pako inflate (from Nodeca project)\"};var Bb=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=\"\",this.comment=\"\",this.hcrc=0,this.done=!1},Mb=Object.prototype.toString,{Z_NO_FLUSH:Rb,Z_FINISH:Db,Z_OK:Tb,Z_STREAM_END:Lb,Z_NEED_DICT:zb,Z_STREAM_ERROR:Hb,Z_DATA_ERROR:Pb,Z_MEM_ERROR:Ob}=jw;function Ub(e){this.options=Gw.assign({chunkSize:65536,windowBits:15,to:\"\"},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg=\"\",this.ended=!1,this.chunks=[],this.strm=new Xw,this.strm.avail_out=0;let i=Nb.inflateInit2(this.strm,t.windowBits);if(i!==Tb)throw new Error(Vw[i]);if(this.header=new Bb,Nb.inflateGetHeader(this.strm,this.header),t.dictionary&&(\"string\"==typeof t.dictionary?t.dictionary=Yw.string2buf(t.dictionary):\"[object ArrayBuffer]\"===Mb.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Nb.inflateSetDictionary(this.strm,t.dictionary),i!==Tb)))throw new Error(Vw[i])}function qb(e,t){const i=new Ub(t);if(i.push(e),i.err)throw i.msg||Vw[i.err];return i.result}Ub.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Db:Rb,\"[object ArrayBuffer]\"===Mb.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Nb.inflate(i,o),s===zb&&r&&(s=Nb.inflateSetDictionary(i,r),s===Tb?s=Nb.inflate(i,o):s===Pb&&(s=zb));i.avail_in>0&&s===Lb&&i.state.wrap>0&&0!==e[i.next_in];)Nb.inflateReset(i),s=Nb.inflate(i,o);switch(s){case Hb:case Pb:case zb:case Ob:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===Lb))if(\"string\"===this.options.to){let e=Yw.utf8border(i.output,i.next_out),t=i.next_out-e,r=Yw.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Tb||0!==a){if(s===Lb)return s=Nb.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ub.prototype.onData=function(e){this.chunks.push(e)},Ub.prototype.onEnd=function(e){e===Tb&&(\"string\"===this.options.to?this.result=this.chunks.join(\"\"):this.result=Gw.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Qb=function(e,t){return(t=t||{}).raw=!0,qb(e,t)},Vb={Inflate:Ub,inflate:qb,inflateRaw:Qb,ungzip:qb,constants:jw},{Inflate:jb,inflate:Wb,inflateRaw:Gb,ungzip:$b}=Vb,Kb=Wb,Yb=$b;var Xb=new Map([[1,function(e,t){let i=new Uint8Array(e);return Kb(i).buffer}],[2,function(e,t){let i=e.byteLength,n=new Uint8Array(i),r=Math.floor(i/t),s=new DataView(e);for(var o=0;oHH\",e,i);if(c%=65535,r!=(a%=65535)||s!=c)throw'ValueError(\"fletcher32 checksum invalid\")'}(e),e.slice(0,-4)}]]),Zb=class{constructor(e,t){this.fh=e,this.offset=t,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let e=this.depth;for(;e>0;){for(var t of this.all_nodes.get(e))for(var i of t.get(\"addresses\"))this._add_node(await this._read_node(i,e-1));e--}}async _read_root_node(){let e=await this._read_node(this.offset,null);this._add_node(e),this.depth=e.get(\"node_level\")}_add_node(e){let t=e.get(\"node_level\");this.all_nodes.has(t)?this.all_nodes.get(t).push(e):this.all_nodes.set(t,[e])}async _read_node(e,t){let i=await this._read_node_header(e,t);return i.set(\"keys\",[]),i.set(\"addresses\",[]),i}async _read_node_header(e){throw\"NotImplementedError: must define _read_node_header in implementation class\"}},Jb=class extends Zb{constructor(){super(...arguments),pw(this,\"B_LINK_NODE\",new Map([[\"signature\",\"4s\"],[\"node_type\",\"B\"],[\"node_level\",\"B\"],[\"entries_used\",\"H\"],[\"left_sibling\",\"Q\"],[\"right_sibling\",\"Q\"]]))}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);if(null!=t&&i.get(\"node_level\")!=t)throw\"node level does not match\";return i}},eF=class extends Jb{constructor(e,t){super(e,t),pw(this,\"NODE_TYPE\",0),this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=bw(this.B_LINK_NODE);let n=[],r=[],s=i.get(\"entries_used\");for(var o=0;o=0&&F[A]>=e[A];A--)F[A]=0,b[A]=w[A],A>0&&(F[A-1]+=1,b[A-1]+=1);if(b.slice(0,-1).every((function(e,i){return e=0;o--){if(t&1<0?r*=n:r=n}}return s}_nrecords_max(e,t,i){return Math.floor((e-10-i)/(t+i))}_required_bytes(e){return Math.ceil(_w(e)/8)}_int_format(e){return[\"0&&(h=(await Aw.unpack_from_async(a,this.fh,i))[0],i+=r),c.push([n,l,h])}}return s.set(\"keys\",a),s.set(\"addresses\",c),s}async _read_node_header(e,t){let i=await gw(this.B_LINK_NODE,this.fh,e);return i.set(\"node_level\",t),i}*iter_records(){for(let e of this.all_nodes.values())for(let t of e)for(let e of t.get(\"keys\"))yield e}_parse_record(e){throw\"NotImplementedError\"}},nF=class extends iF{constructor(){super(...arguments),pw(this,\"NODE_TYPE\",5)}async _parse_record(e,t,i){let n=(await Aw.unpack_from_async(\"0)throw\"Filter info size not supported on FractalHeap\";if(t.get(\"btree_address_huge_objects\")!=dF)throw\"Huge objects not implemented in FractalHeap\";t.set(\"btree_address_huge_objects\",null),t.get(\"root_block_address\")==dF&&t.set(\"root_block_address\",null);let i=t.get(\"log2_maximum_heap_size\"),n=this._min_size_nbits(i),r=new Map([[\"signature\",\"4s\"],[\"version\",\"B\"],[\"heap_header_adddress\",\"Q\"],[\"block_offset\",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=bw(r),2&~t.get(\"flags\")||r.set(\"checksum\",\"I\"),this.direct_block_header=r,this.direct_block_header_size=bw(r);let s=t.get(\"maximum_direct_block_size\");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,t.get(\"max_managed_object_size\"));this._managed_object_length_size=this._min_size_integer(o);let a=t.get(\"starting_block_size\"),c=t.get(\"table_width\");if(!(a>0))throw\"Starting block size == 0 not implemented\";let l=Number(Math.floor(Math.log2(s)));ww(1n<0)for await(let e of this._iter_indirect_block(this.fh,f,p))u.push(e);else{let e=await this._read_direct_block(this.fh,f,a);u.push(e)}let g=u.reduce(((e,t)=>e+t.byteLength),0),m=new Uint8Array(g),w=0;u.forEach((e=>{m.set(new Uint8Array(e),w),w+=e.byteLength})),this.managed=m.buffer}async _read_direct_block(e,t,i){let n=await e.slice(t,t+i);return ww(\"FHDB\"==mw(this.direct_block_header,n).get(\"signature\")),n}get_data(e){let t=Aw.unpack_from(\">4&3,n=1;if(0==i){ww(0==t>>6);let i=this._managed_object_offset_size,r=xw(i,e,n);n+=i,i=this._managed_object_length_size;let s=xw(i,e,n);return this.managed.slice(r,r+s)}throw 1==i?\"tiny objectID not supported in FractalHeap\":2==i?\"huge objectID not supported in FractalHeap\":\"unknown objectID type in FractalHeap\"}_min_size_integer(e){return this._min_size_nbits(_w(e))}_min_size_nbits(e){return Math.ceil(e/8)}async*_iter_indirect_block(e,t,i){let n=await gw(this.indirect_block_header,e,t);t+=this.indirect_block_header_size,ww(\"FHIB\"==n.get(\"signature\"));let r=n.get(\"block_offset\").reduce(((e,t,i)=>e+(t<<8*i)),0);n.set(\"block_offset\",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;ithis._chunks))}get shape(){let e=this.find_msg_type(ZF)[0].get(\"offset_to_message\");return async function(e,t){let i=(await Aw.unpack_from_async(\"255&&(s=(await Aw.unpack_from_async(\"0;e.set(\"optional\",a);let c,l=(await Aw.unpack_from_async(\"0&&(c=(await Aw.unpack_from_async(`${s}s`,i,t))[0],t+=s),e.set(\"name\",c);let h=await Aw.unpack_from_async(`<${l}i`,i,t);t+=4*l,e.set(\"client_data_values\",h),r.push(e)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(e){return this.msgs.filter((function(t){return t.get(\"type\")==e}))}async get_attributes(){let e={},t=this.find_msg_type(sv);for(let i of t){let t=i.get(\"offset_to_message\"),[n,r]=await this.unpack_attribute(t);e[n]=r}return e}async get_fillvalue(){var e,t=this.find_msg_type(tv)[0].get(\"offset_to_message\");let i=(await Aw.unpack_from_async(\"=r&&([s,r]=a[++c],l=0);let t=await gw(PF,e,s+l),i=s+l+OF;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[u,f]=await Aw.unpack_from_async(\"=o-qF){let e=c[++l];if(null==e)break;[r,o]=e,h=0}let t=await gw(UF,e,r+h),i=r+h+qF+n;if(t.set(\"offset_to_message\",i),t.get(\"type\")==ov){var[d,u]=await Aw.unpack_from_async(\"0,c=(4&n)>0;(8&n)>0?(r=(await Aw.unpack_from_async(\"0&&(t+=8);let r=(2&n)>0?jF:VF,s=await gw(r,e,t),o=new Map;for(let[e,t]of s.entries())o.set(e,t==IF?null:t);return o}get is_dataset(){return this.find_msg_type(ZF).length>0}async get_data(){let e=this.find_msg_type(nv)[0].get(\"offset_to_message\");var[t,i,n,r]=await this._get_data_message_properties(e);if(0==n)throw\"Compact storage of DataObject not implemented\";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(e):void 0}async _get_data_message_properties(e){let t,i,n,[r,s,o]=await Aw.unpack_from_async(\"=1&&r<=4),[r,t,i,n]}async _get_contiguous_data(e){let[t]=await Aw.unpack_from_async(\"=!@\\|]?(i|u|f|S)(\\d*)/.test(n)){let[e,i,s]=yw(n),a=new Array(r);const c=await this.fh.slice(t,t+s*r);let l=new Cw(c);for(var o=0;o=1&&t<=3);var a=\"<\"+(i-1).toFixed()+\"I\",c=await Aw.unpack_from_async(a,this.fh,s);this._chunks=c,this._chunk_dims=i,this._chunk_address=o}}}};var IF=Aw.unpack_from(\"this.get(e)))}length(){return this.keys.length}_dereference(e){if(!e)throw\"cannot deference null reference\";let t=this.file._get_object_by_address(e);if(null==t)throw\"reference not found in file\";return t}async get(e){if(\"number\"==typeof e)return this._dereference(e);var t=dv(e);if(\"/\"==t)return this.file;if(\".\"==t)return this;if(/^\\//.test(t))return this.file.get(t.slice(1));if(\"\"!=function(e){let t=\"/\",i=e.lastIndexOf(t)+1,n=e.slice(0,i),r=new RegExp(\"^\"+t+\"+$\"),s=new RegExp(t+\"$\");n&&!r.test(n)&&(n=n.replace(s,\"\"));return n}(t))var[i,n]=t.split(/\\/(.*)/);else var i=t,n=\".\";if(!(i in this._links))throw i+\" not found in group\";var r=dv(this.name+\"/\"+i);let s=this._links[i];if(\"string\"==typeof s)try{return this.get(s)}catch(e){return null}var o=new kF(this.file._fh,s);if(await o.ready,o.is_dataset){if(\".\"!=n)throw r+\" is a dataset, not a group\";return new hv(r,o,this)}var a=new cv(r,this);return await a.init(o),a.get(n)}visit(e){return this.visititems(((t,i)=>e(t)))}visititems(e){var t=this.name.length;/\\/$/.test(this.name)||(t+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=e(n.name.slice(t),n);if(null!=r)return r;n instanceof cv&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},lv=class extends cv{constructor(e,t,i){super(\"/\",null),this.ready=this.init(e,t,i)}async init(e,t,i){var n=new sF(e,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new kF(e,r);if(await s.ready,this.parent=this,this.file=this,this.name=\"/\",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=e,this.filename=t||\"\",this.mode=\"r\",this.userblock_size=0,i&&i.index)this.index=i.index;else{let t;if(i&&i.indexOffset)t=i.indexOffset;else{const e=await this.attrs;if(e.hasOwnProperty(\"_index_offset\"))t=e._index_offset;else{const e=this.indexName||\"_index\",i=await s.find_link(e);i&&(t=i[1])}}if(t)try{const i=new kF(e,t);await i.ready;const n=await i.get_data(),r=Yb(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(e){console.error(`Error loading index by offset ${e}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(e){return this._dataobjects.offset==e?this:this.visititems((e=>{e._dataobjects.offset}))}},hv=class extends Array{constructor(e,t,i){super(),this.parent=i,this.file=i.file,this.name=e,this._dataobjects=t,this._attrs=null,this._astype=null}get value(){var e=this._dataobjects.get_data();return null==this._astype?this.getValue(e):e.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(e,t){const i=e.length,n=t.reduce(((e,t)=>e*t),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=e;const s=t.slice(1).reverse();for(let e of s){const t=[],{length:i}=r;let n=0;for(;n{let t=e.indexOf(\"\\0\");return t>=0?e.substring(0,t):e})):e}};function dv(e){return e.replace(/\\/(\\/)+/g,\"/\")}async function uv(e){var t;e.url&&(\"function\"==typeof(t=e.url).slice&&\"function\"==typeof t.arrayBuffer)&&(e.file=e.url,e.url=void 0);const i=void 0!==e.url;let n=e.reader?e.reader:function(e){if(e.url)return new lw(e);if(e.path)return new NodeLocalFile(e);if(e.file)return new uw(e.file);throw Error(\"One of 'url', 'path (node only)', or 'file (browser only)' must be specified\")}(e);const r=e.fetchSize||2e3,s=e.maxSize||2e5;i&&(n=new hw({file:n,fetchSize:r,maxSize:s}));const o=new fv(n),a=await async function(e){let t;if(e.indexReader)t=e.indexReader;else{if(e.index)return e.index;e.indexURL?t=new lw({url:e.indexURL}):e.indexPath?t=new NodeLocalFile({path:e.indexPath}):e.indexFile&&(t=new uw({file:e.indexFile}))}if(t){const e=await t.read(),i=(new TextDecoder).decode(e);return JSON.parse(i)}return}(e),c=e.indexOffset,l=function(e){if(e.url)return pv(e.url);if(e.path)return pv(e.path);if(e.file)return e.file.name}(e),h=new lv(o,l,{index:a,indexOffset:c});return await h.ready,h}class fv{constructor(e){this.fileReader=e}async slice(e,t){return this.fileReader.read(e,t-e)}}function pv(e){const t=e.lastIndexOf(\"/\");return t>0?e.substring(t+1):e}class gv{constructor(e,t){this.chrom=e,this.signal_bin_size=t;this.signals={raw_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}`,gc_RD:`his_rd_p_${this.chrom}_${this.signal_bin_size}_GC`,gc_partition:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_merge`,baf:`snp_likelihood_${this.chrom}_${this.signal_bin_size}_mask`,baf_i1:`snp_i1_${this.chrom}_${this.signal_bin_size}_mask`,Mosaic_segments:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_segments_2d`,Mosaic_calls:`his_rd_p_${this.chrom}_${this.signal_bin_size}_partition_GC_mosaic_call_2d`}}}class mv{constructor(e,t=1e5){this.h5_file=e,this.bin_size=t,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await uv({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(e=this.bin_size){let t=await this.fetch();this.h5_obj=t,this.pytor_keys=t.keys;let i=new wv(this.pytor_keys),n=i.get_rd_bins(),r=i.get_snp_bins();this.available_bins=[...new Set(n,r)],this.available_bins.includes(e)||(e=this.available_bins.at(-1));const s=await t.get(\"rd_chromosomes\");await s.dtype;let o=await s.value,a=await this.rd_stat(e);var c=[],l=[],h=[],d=[],u=[],f=[];for(let t of o){let i=new gv(t,e);var p=i.signals.raw_RD;let n=await this.get_chr_signal(t,e,p,a);c=c.concat(n);var g=i.signals.gc_RD;let r=await this.get_chr_signal(t,e,g,a);l=l.concat(r);let s=i.signals.gc_partition,o=await this.get_chr_signal(t,e,s,a);h=h.concat(o);let m=await this.rd_call_combined(t,e,a,i);d=d.concat(m);let w=i.signals.baf_i1,b=await this.get_baf_signals_v2(t,e,w);u=u.concat(b[0]),f=f.concat(b[1])}this.callers=[],0!=d.length&&this.callers.push(\"ReadDepth\"),0!=d.length&&this.callers.push(\"2D\");var m={},w={RD_Raw:c,RD_Raw_gc_coor:l,ReadDepth:h,\"2D\":d,BAF1:u,BAF2:f};return m[e]=w,m}decode_segments(e){let t=[],i=[];for(let n of e)4294967295==n?(t.push(i),i=[]):i.push(n);return t}async rd_call_combined(e,t,i,n){let r,s=[],o=n.signals.Mosaic_segments;if(this.pytor_keys.includes(o)){const e=await this.h5_obj.get(o);let t=await e.value;r=this.decode_segments(t)}let a=n.signals.Mosaic_calls;if(this.pytor_keys.includes(a)){const n=await this.h5_obj.get(a);let o=await n.to_array();r.forEach(((n,r)=>{n.forEach(((n,a)=>{s.push({chr:e,start:n*t,end:(n+1)*t,value:o[0][r]/i[4]*2})}))}))}return s}async rd_stat(e){let t,i=`rd_stat_${e}_auto`;if(this.pytor_keys.includes(i)){const e=await this.h5_obj.get(i);t=await e.value}return t}async get_chr_signal(e,t,i,n){let r=[];if(this.pytor_keys.includes(i)){const s=await this.h5_obj.get(i);(await s.value).forEach(((i,s)=>{r.push({chr:e,start:s*t,end:(s+1)*t,value:i/n[4]*2})}))}return r}async get_baf_signals(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{let a=Math.max(...i);const c=i.indexOf(a);let l=Math.max(c/200,1-c/200);r.push({chr:e,start:o*t,end:(o+1)*t,value:n*l}),.5!=l&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(1-l)})}))}return[r,s]}async get_baf_signals_v2(e,t,i,n=-1){let r=[],s=[];if(this.pytor_keys.includes(i)){let o=await this.h5_obj.get(i);(await o.to_array()).forEach(((i,o)=>{isNaN(i)||(r.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5-i)}),.5!=i&&s.push({chr:e,start:o*t,end:(o+1)*t,value:n*(.5+i)}))}))}return[r,s]}}class wv{constructor(e){this.signals=e}get_rd_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^his_rd_p_(.*)_(\\d+)$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}get_snp_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^snp_likelihood_(.*)_(\\d+)_mask$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}}function bv(e){let t=function(e){if(e.length<4)return e;let t,i,n,r,s,o;return t=e.slice().sort(((e,t)=>e-t)),t.length/4%1==0?(i=.5*(t[t.length/4]+t[t.length/4+1]),n=.5*(t[t.length*(3/4)]+t[t.length*(3/4)+1])):(i=t[Math.floor(t.length/4+1)],n=t[Math.ceil(t.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,t.filter((e=>e>=o&&e<=s))}(e);const i=t.length,n=t.reduce(((e,t)=>e+t))/i,r=Math.sqrt(t.map((e=>Math.pow(e-n,2))).reduce(((e,t)=>e+t))/i);return[n,r]}var Fv={range_function:function(e,t,i){return Array(Math.ceil((t-e)/i)).fill(e).map(((e,t)=>e+t*i))},getDistParams:bv,linspace:function(e,t,i){if(void 0===i&&(i=Math.max(Math.round(t-e)+1,1)),i<2)return 1===i?[e]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*t+(i-r)*e)/i;return n},GetFit:class{constructor(e){this.allBins=e}getValues(){return Object.values(this.allBins).reduce(((e,t)=>e.concat(t.filter((e=>e.binScore>0)).map((e=>e.binScore)))),[])}getMean(e){return e.reduce((function(e,t){return e+t}))/e.length}fit_data(){return bv(this.getValues())}histogram(e,t){const i=t[1]-t[0],n=[];e.forEach(((e,r)=>{t.forEach(((t,r)=>{if(n[t]||(n[t]={count:0}),t<=e&&e{r.push(e.count)})),r}}};function vv(e,t){return isNaN(e)||isNaN(t)||t<=0?NaN:0===e?.5:.5+.5*(yv(.5*t,.5,1)-yv(.5*t,.5,t/(t+e*e)))*Math.sign(e)}function yv(e,t,i){if(0==i)return 0;if(1==i)return 1;{let n=xv(e+t)-xv(e)-xv(t)+e*Math.log(i)+t*Math.log(1-i);return i<(e+1)/(e+t+2)?Math.exp(n)*Av(e,t,i)/e:1-Math.exp(n)*Av(t,e,1-i)/t}}function Av(e,t,i,n=1e3){let r=1,s=1,o=1,a=e+t,c=e+1,l=e-1,h=1-a*i/c;for(let d=0;d<=n;d++){let n=parseFloat(d+1),u=n+n,f=n*(t-n)*i/((l+u)*(e+u)),p=r+f*s,g=h+f*o;f=-(e+n)*(a+n)*i/((c+u)*(e+u));let m=g+f*h,w=r;if(s=p/m,o=g/m,r=(p+f*r)/m,h=1,Math.abs(r-w)<3e-7*Math.abs(r))return r}}function Cv(e){if(0==e||1==e)return 1;return e*Cv(e-1)}function _v(e){let t;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==e)t=1e99;else if(e%1==0)t=Cv(e-1);else{for(let t=0;tt?e:t}))}function Sv(e,t,i,n){return t*Math.exp(-1*(e-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function Ev(e,t,i,n){return Math.exp(-1*(e-i)**2/(t**2+n**2))}function Nv(e,t){let i;try{i=e.reduce(((e,i,n)=>e+Math.min(i,t[n])))}catch{return console.log(\"Failed to find likelihood overlap: \",e,t),0}return i}function Bv(e,t,i,n){return 0==t&&0==n?{nl:.5*(e+i),ne:0}:{nl:(e*n*n+i*t*t)/(t*t+n*n),ne:Math.sqrt(t*t*n*n/(t*t+n*n))}}function Mv(e,t){let i=parseInt(t*(e.length-1)),n=t*(e.length-1)-i;return iMath.floor(t/2)&&(n=t-1-n);const r=(t/2-n)/(t+1),s=Math.floor((t/2+n)/2),o=t-1-s;let a=e.slice(s,o+1).reduce(((e,t)=>e+t),0)/e.reduce(((e,t)=>e+t),0);return n===Math.floor(t/2)&&(a=1),{mean:r,p:a}}var Dv=class{constructor(e,t){this.wigFeatures=e,this.binSize=t}get_fit(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data();return{globalMean:t,globalStd:i}}async call_2d(e=null,t=null,i=\"both\",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let c=null==e?.05*this.binSize/3e9:e,l=null==t?parseInt(this.binSize/1e4):t,h=[],d=[],u=[],f=[],p=[],g=[];for(const[e,t]of Object.entries(this.wigFeatures)){let e=[],i=[],s=[];t.forEach(((t,n)=>{t.hets_count>4&&t.dp_count>l&&(e.push([n]),i.push(t.binScore),s.push(t.likelihood_score),delete t.likelihood_score)}));let o=[];for(let e=1;eMath.sqrt(Math.sqrt(e)**2+this.globalStd**2+Math.pow(a[t]/2,2)))),m=[];for(let t=0;t0;){m=m.filter((e=>\"number\"==typeof e));let t=Iv(m);if(isNaN(t)&&console.log(\"NaN value\",m),te*s[o+1][t])),r=n.reduce(((e,t)=>e+t))}catch{console.log(s),console.log(\"max_overlap:\",t,o,m.length),console.log(\"likelihood: \",o,s[o],s[o+1]),console.log(\"nlh: \",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(e){return e/r})),e[o].push(...e[o+1]),i.splice(o+1,1),g.splice(o+1,1),e.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o0){let e=Ev(i[o-1],g[o-1],i[o],g[o])*Nv(s[o-1],s[o]);m[o-1]=e}}let w=-1;for(;;){m=[];for(let t=0;te*s[r+1][t])),a=n.reduce(((e,t)=>e+t));s[r]=n.map((function(e){return e/a})),e[r].push(...e[r+1]),e[r]=e[r].sort(((e,t)=>e-t)),i.splice(o,1),g.splice(o,1),e.splice(o,1),s.splice(o,1),o>=e.length&&(r+=1,o=r+1)}else o+=1,o>=e.length&&(r+=1,o=r+1)}if(w==e.length)break;w=e.length}e.forEach(((e,n)=>{let o=Rv(s[n]);e.length>1&&(e.forEach(((e,s)=>{d.push(t[e]),o.mean<=r&&h.push(t[e]),t[e].segment_score=i[n]})),u.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let w=Fv.linspace(o,1,m),b={},F={};for(let e=10;e>-1;e--)for(let t=0;t1-t+t*e/2)),a=e/2;e>0?(n=.5-t/(t+s),r=w.map(((e,i)=>.5-(1-e+e*t)/(2-2*e+(t+s)*e)))):(n=0,r=w.map(((e,t)=>0*e)));for(let i=0;i{if(!isNaN(r[t])){let n=Sv(e*this.globalMean,1,u[i],f[i])*Mv(p[i],.5+r[t]);l+=n,n>h&&(h=n,d=w[t])}})),i in b?b[i].push([e,t,s,l/w.length,d]):b[i]=[e,t,s,l/w.length,d]}for(let e=0;ee[3]-t[3]));else if(b[e].sort(((e,t)=>e[3]-t[3])),\"both\"==i&&(F[e].sort(((e,t)=>e[3]-t[3])),F[e][0][3]>b[e][0][3])){let t=b[e].filter((t=>t[0]!=F[e][0][0]&&t[1]<=F[e][0][1]));b[e]=[F[e][0]].push(...t)}for(let e=0;e{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}formatDataStructure_BAF(e,t=-1){const i=[],n=[];for(const[r,s]of Object.entries(this.wigFeatures))s.forEach((r=>{var s={...r},o={...r};let a=r[e];.5!=a&&(o.value=t*(1-a),n.push(o)),s.value=t*a,i.push(s)}));return[i,n]}};const Tv=2871e6;function Lv(e){for(var t=1,i=1,n=1*e,r=1;r<50;r++)t*=r,n+=(i*=-1)*Math.pow(e,2*r+1)/(t*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function zv(e,t,i,n,r){var s=new Ov(i.slice(n,r));return 0==s.std&&(s.std=t>0?t*s.mean/e:1),Uv(e,s.mean,s.std,r-n)/(r-n)}function Hv(e,t,i,n,r){var s=new Ov(i.slice(n,r));if(s.means&!l&c0&&(h=zv(e,t,i,n-1,r)),r-n>2)var d=zv(e,t,i,n+1,r),u=zv(e,t,i,n,r-1);if(re+t))/e.length,this.std=Math.sqrt(e.reduce(((e,t)=>(t-this.mean)**2))/e.length)}}function Uv(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-kv.TdistributionCDF(Math.abs(r),n-1)}function qv(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-kv.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var Qv=class{constructor(e,t,i){this.rd=e,this.mean=t,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(e){var t=[];return e.forEach(((e,i)=>{var n=0;n=e>this.mean/4?this.mean/(this.std**2*e):4/this.std**2,t.push(n)})),t}meanShiftCaller(e,t=3){var i={};return Object.entries(this.rd).forEach((([e,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let e=0;e{var o=r.map(((e,t)=>!e)),a=[];Object.entries(n).forEach((([e,t])=>{a.push(t.binScore)}));var c=[0],l=0;for(let e=0;e0&&(c.push(c[c.length-1]+l-1),l=0):l+=1;c.shift();for(let i=0;i=a.length||Math.abs(t-i)>=a.length)){var u=(i-t)*Math.exp(-.5*(i-t)**2/e**2)*Math.exp(-.5*(a[t]-a[i])**2*h[t]);d[t]+=u}for(var f=new Array,p=0;p=0&&f.push(p);f.push(d.length-1),f=f.concat(c).sort(((e,t)=>e-t)),f=Array.from(new Set(f));var g=0;for(p=0;pe+t))/m.length;a.fill(w,g,f[p]+1),g=f[p]+1}}p=0;for(var b=0;p.01&&f.push(p+1)}f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1);for(p=1;p1))continue;v[0]=f[p-2];var y=[f[p],f[p]];if(!(p.01/Tv*bin_size*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>.01/Tv*bin_size*(A+_))continue}if(Uv(this.mean,x.mean,x.std,x.data.length)>.05)continue;let e=a.slice(F[0],F[1]);var B=new Ov(e);r.fill(!0,F[0],F[1]),s.fill(B.mean,F[0],F[1])}})),i[e]=s})),i}call_mean_shift(e=3){for(var t=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n{var s=t.map(((e,t)=>!e)),o=[];s.forEach(((e,t)=>{e&&o.push(this.rd[t])}));for(var a=[0],c=0,l=0;l0&&(a.push(a[a.length-1]+c-1),c=0):c+=1;a.shift();for(var h=0;h=o.length||Math.abs(l-f)>=o.length)){var p=(f-l)*Math.exp(-.5*(f-l)**2/n**2)*Math.exp(-.5*(o[l]-o[f])**2*d[l]);u[l]+=p}var g=new Array;for(l=0;l=0&&g.push(l);g.push(u.length-1),g=g.concat(a).sort(((e,t)=>e-t)),g=Array.from(new Set(g));var m=0;for(l=0;le+t))/w.length;o.fill(b,m,g[l]+1),m=g[l]+1}}for(l=0,f=0;l.01&&g.push(l+1)}g.unshift(0),g.push(i.length),t=new Array(this.rd.length).fill(!1);for(l=1;l1){v[0]=g[l-2];var y=[g[l],g[l]];if(l3.483106931382794e-9*(A+C))continue;if(qv(x.mean,x.std,x.data.length,N.mean,N.std,N.data.length)>3.483106931382794e-9*(A+_))continue}if(!(Uv(this.mean,x.mean,x.std,x.data.length)>.05)){var B=new Ov(this.rd.slice(F[0],F[1]));t.fill(!0,F[0],F[1]),i.fill(B.mean,F[0],F[1])}}}}}})),i}cnv_calling(e=1e5){var t=.25*this.mean,i=this.mean-t,n=this.mean+t,r=2971e6,s=this.meanShiftCaller(e),o={},a=[];return Object.entries(s).forEach((([c,l])=>{for(var h=!1;!h;){h=!0;var d=new Array(1).fill(0);for(let e=0;e.01&&d.push(e+1)}d.push(l.length);for(let e=0;e0&&(f=Math.abs(l[d[e]]-l[d[e-1]])),e{m.push(t.binScore)}));for(var w,b=new Array(l.length).fill(\"\"),F=0,v=.05*e/r;FA+1){var C=Pv(this.mean,this.std,m,A,_,v);if(C){var _=C;b.fill(\"D\",A,_)}}for(A=F;Fn;)F+=1;(_=F)>A+1&&(C=Pv(this.mean,this.std,m,A,_,v))&&(_=C,b.fill(\"A\",A,_)),F==y&&(F+=1)}for(F=0;FA+1&&(Hv(this.mean,this.std,m,A,_)<1682935038707506e-26&&b.fill([\"d\"]*(_-A),A,_),F-=1),F+=1}(F=0)=b.length););if(F>A){var k=new Ov(x.slice(A,F));x.fill(k.mean,A,F)}F=0;e--){var i;let n=this.allVariants[e];this.allVariants.splice(e,1);let r=n.chr;i=Math.max(Math.floor(n.start/this.rowBinSize),0),t[r]||(t[r]=[]),t[r][i]||(t[r][i]={chr:r,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const s=Object.values(n.calls);if(1!==s.length)throw Error(`Unexpected number of genotypes: ${s.length}. CNVPytor expects 1 and only 1 genotype`);const o=s[0],a=o.info.DP;a&&(t[r][i].dp_sum_score+=Number.parseInt(a),t[r][i].dp_count++);let c=o.info.AD.split(\",\"),l=o.genotype;if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){t[r][i].hets_count++;let e=parseInt(c[0]),n=parseInt(c[1]);t[r][i].hets.push({ref:e,alt:n})}}this.chromosomes=Object.keys(t);var n,r=this.adjust_bin_size(t);if(\"ReadDepth\"==e){n=new Wv(r,this.binSize).ReadDepth_caller();var s=this.formatDataStructure_BAF(r,\"max_likelihood\")}else if(\"2D\"==e){let e=new Dv(r,this.binSize),t=await e.call_2d();n=[t.binScore,[],t.segment_score];s=e.formatDataStructure_BAF(\"max_likelihood\",-1)}return[n,s]}formatDataStructure(e,t,i=1){const n=[];for(const[s,o]of Object.entries(e))for(let e of o){var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}return n}format_BAF_likelihood(e){const t=[];for(const[n,r]of Object.entries(e))for(let e of r){var i={...e};.5!=e.value&&(i.value=1-e.value,t.push(i))}return t}get_max_min_score(e){if(e.likelihood_score.length>0){const t=Math.max(...e.likelihood_score),i=e.likelihood_score.indexOf(t);e.value=Math.max(i/100,1-i/100),e.min_score=Math.min(i/100,1-i/100)}else e.score=0;return e}async getAllbins(){const e=await this.computeDepthFeatures();return new Fv.GetFit(e).fit_data(),e}formatDataStructure_BAF(e,t,i=-1){const n=[],r=[];for(const[a,c]of Object.entries(e))for(let e of c){var s={...e},o={...e};let a=e[t];.5!=a&&(o.value=i*(1-a),r.push(o)),s.value=i*a,n.push(s)}return[n,r]}adjust_bin_size(e){var t={};for(let r of this.chromosomes){t[r]||(t[r]=[]);for(let s=0;sjv(o.ref,o.alt,e)));else{var n=0;t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>{var a=t[r][s].likelihood_score[i]*jv(o.ref,o.alt,e);return n+=a,a})),t[r][s].likelihood_score=Fv.linspace(0,1,100).map(((e,i)=>t[r][s].likelihood_score[i]/n))}t[r][s].binScore=100*parseInt(t[r][s].dp_sum_score/t[r][s].dp_count);const a=this.get_max_min_score(t[r][s]);t[r][s].max_likelihood=a.value}}return t}}function jv(e,t,i,n=!0){return Math.pow(i,e)*Math.pow(1-i,t)+Math.pow(i,t)*Math.pow(1-i,e)}class Wv{constructor(e,t){this.wigFeatures=e,this.binSize=t}ReadDepth_caller(){var e=new Fv.GetFit(this.wigFeatures),[t,i]=e.fit_data(),n=new Qv(this.wigFeatures,t,i),r=n.meanShiftCaller(this.binSize),s=n.cnv_calling();return Object.entries(this.wigFeatures).forEach((([e,t])=>{t.forEach(((t,i)=>{t.partition_level=parseInt(r[e][i]),t.partition_call=parseInt(s[0][e][i])}))})),[this.formatDataStructure(\"binScore\",t),this.formatDataStructure(\"partition_level\",t),this.formatDataStructure(\"partition_call\",t),s[1]]}formatDataStructure(e,t=1){const i=[];for(const[r,s]of Object.entries(this.wigFeatures))for(let r of s){var n={...r};1!=t&&(n.value=r[e]/t*2),i.push(n)}return i}}class Gv extends Hl{static DEFAULT_TRACK_HEIGHT=250;constructor(e,t){super(e,t)}init(e){this.featureType=\"numeric\",this.type=\"cnvpytor\",e.max||(this.defaultScale=!0,this.autoscale=!1),e.height||(e.height=Gv.DEFAULT_TRACK_HEIGHT),this.type=\"cnvpytor\",this.graphType=e.graphType||\"points\",this.bin_size=e.bin_size||1e5,this.signal_name=e.signal_name||\"rd_snp\",this.cnv_caller=e.cnv_caller||\"2D\",this.colors=e.colors||[\"gray\",\"black\",\"green\",\"blue\"],super.init(e)}get supportsWholeGenome(){return!0}get_signals(){let e=[];return\"rd_snp\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller,\"BAF1\",\"BAF2\"]:\"rd\"==this.signal_name?e=[\"RD_Raw\",\"RD_Raw_gc_coor\",this.cnv_caller]:\"snp\"==this.signal_name?e=[\"BAF1\",\"BAF2\"]:\"cnh\"==this.signal_name&&(e=[this.cnv_caller]),e}get_signal_colors(){return[{singal_name:\"RD_Raw\",color:this.colors[0]},{singal_name:\"RD_Raw_gc_coor\",color:this.colors[1]},{singal_name:\"ReadDepth\",color:this.colors[2]},{singal_name:\"2D\",color:this.colors[2]},{singal_name:\"BAF1\",color:this.colors[3]},{singal_name:\"BAF2\",color:this.colors[3]}]}async postInit(){if(\"vcf\"==this.config.format){let e;this.featureSource?e=Object.values(this.featureSource.getAllFeatures()).flat():(this.featureSource=this.featureSource||Ad(this.config,this.browser.genome),this.header=await this.getHeader(),e=this.featureSource.reader.features);const t=new Vv(e,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},\"2D\"==this.cnv_caller?(r=await t.read_rd_baf(\"2D\"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size][\"2D\"]=i[2],this.available_callers=[\"2D\"]):(r=await t.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=[\"ReadDepth\"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new mv(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const e=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let t in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:\"wig\"};t.features=n,t.name=i,t.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(t);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+t),\"function\"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(e)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if(\"function\"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleKeys=this.callSets?this.callSets.map((e=>e.sample)):[],this.sampleNames=this.sampleKeys}return this.header}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];void 0!==this.flipAxis&&e.push({label:\"Flip y-axis\",click:function(){this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat(this.numericDataMenuItems()),e.push(\"
\"),e.push(\"Bin Sizes\");for(let t of this.available_bins){const i=Dl(t,t===this.bin_size);e.push({object:Bt(i),click:async function(){this.bin_size=t,this.trackView.startSpinner(),await this.recreate_tracks(t),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"Signal Type\");let t={rd_snp:\"RD and BAF Likelihood\",rd:\"RD Signal\",snp:\"BAF Likelihood\"};for(let i in t){const n=Dl(t[i],i===this.signal_name);e.push({object:Bt(n),click:async function(){this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push(\"
\"),e.push(\"CNV caller\");for(let t of this.available_callers){const i=Dl(t,t===this.cnv_caller);e.push({object:Bt(i),click:async function(){this.cnv_caller=t,this.trackView.startSpinner(),await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}if(this.variantState){e.push(\"
\");for(let t of this.available_callers)e.push({label:\"Convert to variant track\",click:()=>{this.convertToVariant()}})}return e}async recreate_tracks(e){this.tracks=[];const t=[];e in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(e)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:\"wig\"};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.isMergedTrack=!0,r.autoscale=!1,this.tracks.push(r)):console.warn(\"Could not create track \"+e),\"function\"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}async getFeatures(e,t,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n)));return Promise.all(r)}}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features;if(!t)return;if(this.defaultScale&&(\"rd_snp\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||5}:\"rd\"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||5}:\"snp\"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-1,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(e,t){let i=0,n=-Number.MAX_VALUE;for(let e of t)for(let t of e)void 0===t.value||Number.isNaN(t.value)||(i=Math.min(i,t.value),n=Math.max(n,t.value));return{min:i,max:n}}(e.referenceFrame.chr,t)),this.tracks)for(let i=0,n=this.tracks.length;ithis.logScale?this.computeYPixelValueInLogScale(e,i):this.computeYPixelValue(e,i);if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=n(t.y),r={strokeStyle:t.color,strokeWidth:1};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,r):xo.strokeLine(e.context,0,i,e.pixelWidth,i,r)}let r=n(2);xo.dashedLine(e.context,0,r,e.pixelWidth,r,5,{strokeStyle:\"lightgray\",strokeWidth:.5})}paintAxis(e,t,i){var n,r,s,o,a,c,l,h={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let d=void 0!==this.flipAxis&&this.flipAxis;function u(e){return e<0?Math.abs(e):0===e?\"0\":Math.abs(e)>=10||e%1==0?e.toFixed():Math.abs(e)>=1?e.toFixed(1):e.toFixed(2)}xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"}),n=(l=.95*t)-8,a={x:r=l,y:s=o=.01*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.min:this.dataRange.max),n+4,s+12,h),c={x:r,y:s=o=.99*i},xo.strokeLine(e,n,s,r,o,h),xo.fillText(e,u(d?this.dataRange.max:this.dataRange.min),n+4,s-4,h),xo.strokeLine(e,a.x,a.y,c.x,c.y,h);const f=this.getScaleFactor(this.dataRange.min,this.dataRange.max,i,this.logScale),p=e=>this.logScale?this.computeYPixelValueInLogScale(e,f):this.computeYPixelValue(e,f),g=Math.ceil((this.dataRange.max-this.dataRange.min)/10);for(let t=Math.ceil(this.dataRange.min+1);t0&&t.push(\"
\"),t.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(e,i[n]);t.push(...r)}return t}}async convertToVariant(){this.variantState&&(Object.setPrototypeOf(this,Yv.prototype),this.init(this.variantState),await this.postInit(),this.trackView.clearCachedFeatures(),this.variantState.trackHeight&&this.trackView.setTrackHeight(this.variantState.trackHeight),this.trackView.checkContentHeight(),this.trackView.updateViews(),delete this.variantState)}}const $v=Mt,Kv=10;class Yv extends Hl{static defaults={displayMode:\"EXPANDED\",sortDirection:\"ASC\",showGenotypes:!0,expandedVariantHeight:10,squishedVariantHeight:2,squishedCallHeight:1,expandedCallHeight:10,expandedVGap:2,squishedVGap:1,expandedGroupGap:10,squishedGroupGap:5,featureHeight:14,noGenotypeColor:\"rgb(200,180,180)\",noCallColor:\"rgb(225, 225, 225)\",nonRefColor:\"rgb(200, 200, 215)\",mixedColor:\"rgb(200, 220, 200)\",homrefColor:\"rgb(200, 200, 200)\",homvarColor:\"rgb(17,248,254)\",hetvarColor:\"rgb(34,12,253)\",refColor:\"rgb(0,0,220)\",altColor:\"rgb(255,0,0)\",visibilityWindow:void 0,labelDisplayMode:void 0,type:\"variant\"};_sortDirections=new Map;constructor(e,t){super(e,t)}init(e){if(super.init(e),e.variantHeight&&(this.expandedVariantHeight=e.variantHeight),this.featureSource=Ad(e,this.browser.genome),this.colorTables=new Map,e.colorTable){const t=e.colorBy||\"*\";this.colorTables.set(t,new ao(e.colorTable))}if(this.strokecolor=e.strokecolor,this._context_hook=e.context_hook,e.color&&(this.colorBy=void 0),this.nVariantRows=1,e.samples)for(let t of e.samples)this.sampleKeys=e.samples;e.sort&&(this.initialSort=e.sort),this._colorByItems=new Map([[\"none\",\"None\"]])}async postInit(){if(this.header=await this.getHeader(),this.header.INFO){const e=new Set(Object.keys(this.header.INFO));this.config.colorBy?this.colorBy=this.config.colorBy:!this.config.color&&e.has(\"AF\")&&(this.colorBy=\"AF\"),e.has(\"AF\")&&this._colorByItems.set(\"AF\",\"Allele frequency\"),e.has(\"VT\")&&this._colorByItems.set(\"VT\",\"Variant Type\"),e.has(\"SVTYPE\")&&this._colorByItems.set(\"SVTYPE\",\"SV Type\")}if(this.config.colorBy&&!this._colorByItems.has(this.config.colorBy)&&this._colorByItems.set(this.config.colorBy,this.config.colorBy),!this.disposed){if(this.header&&!this.sampleKeys&&(this.sampleKeys=this.header.sampleNameMap?Array.from(this.header.sampleNameMap.keys()):[]),void 0===this.visibilityWindow&&!1!==this.config.indexed){const e=Ht(this.config.url)?this.config.url.name:this.config.url;$v(e)&&e.toLowerCase().includes(\"gnomad\")?this.visibilityWindow=1e3:\"function\"==typeof this.featureSource.defaultVisibilityWindow?this.visibilityWindow=await this.featureSource.defaultVisibilityWindow():this.visibilityWindow=1e6}return this}}get supportsWholeGenome(){return!this.config.indexURL||!0===this.config.supportsWholeGenome}get color(){return this._color||\"rgb(0,0,150)\"}set color(e){this._color=e,e&&(this.colorBy=void 0)}async getHeader(){return this.header||\"function\"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getSampleCount(){return this.sampleKeys?this.sampleKeys.length:0}async getFeatures(e,t,i,n){void 0===this.header&&(this.header=await this.getHeader());const r=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow});if(this.initialSort){const e=this.initialSort;if(void 0===e.option||\"GENOTYPE\"===e.option.toUpperCase())this.sortSamplesByGenotype(e,r);else if(\"ATTRIBUTE\"===e.option.toUpperCase()&&e.attribute){const t=\"ASC\"===e.direction?1:-1;this.sortByAttribute(e.attribute,t)}this.initialSort=void 0}return r}hasSamples(){return this.getSampleCount()>0}getSamples(){const e=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=t*((\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight)+e),r=Kv+t*(i+e);return{names:this.sampleKeys,yOffset:r,height:n}}computePixelHeight(e){if(!e||0===e.length)return Kv;const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,i=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,n=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=!1===this.showGenotypes?0:this.getSampleCount()*t;return Kv+t*(n+i)+i+(s+1)*(r+i)}variantRowCount(e){this.nVariantRows=e}draw({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){xo.fillRect(e,0,s,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const a=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,c=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows,l=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=Kv+c*(l+a);let h=this.sampleColumns;const d=this.hasSamples();if(h&&d&&!1!==this.showGenotypes&&xo.strokeLine(e,0,this.variantBandHeight,t,this.variantBandHeight,{strokeStyle:\"rgb(224,224,224) \"}),o){const i=\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s=\"SQUISHED\"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+t*n+1;for(let t of o){if(t.enda)break;const o=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=Kv+(\"COLLAPSED\"===this.displayMode?0:t.row*(o+s)),l=o;let h=(t.start-r)/n,u=(t.end-r)/n,f=Math.max(1,u-h);f<3?(f=3,h-=1):f>5&&(h+=1,f-=2);const p=t._f||t;let g;try{g=p.alleleFreq()}catch(e){console.log(e)}if(\"AF\"===this.colorBy&&g){const t=Math.min(1,g)*l,i=l-t;e.fillStyle=p.isFiltered()?this.refColorFiltered:this.refColor,e.fillRect(h,c,f,i),e.fillStyle=p.isFiltered()?this.altColorFiltered:this.altColor,e.fillRect(h,c+i,f,t)}else e.fillStyle=this.getColorForFeature(p),e.fillRect(h,c,f,l);let m=this.getVariantStrokecolor(p);if(m&&(e.strokeStyle=m,e.strokeRect(h,c,f,l)),this.callContextHook(p,e,h,c,f,l),d&&!1!==this.showGenotypes){const t=\"COLLAPSED\"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=t*(i+s);let n=0;for(let t of this.sampleKeys){const r=this.header.sampleNameMap.get(t),o=p.calls[r];if(o){const t=\"COLLAPSED\"===this.displayMode?0:p.row,r=this.sampleYOffset+n*this.sampleHeight+t*(i+s);let a=!0,c=!0,l=!1;if(o.genotype)for(let e of o.genotype){if(\".\"===e){l=!0;break}0!==e&&(c=!1),0===e&&(a=!1)}o.genotype?e.fillStyle=l?this.noCallColor:c?this.homrefColor:a?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,r,f,i)}n++}}}}else console.log(\"No feature list\")}get refColorFiltered(){return this._refColorFiltered||(this._refColorFiltered=_s.addAlpha(this.refColor,.2)),this._refColorFiltered}get altColorFiltered(){return this._altColorFiltered||(this._altColorFiltered=_s.addAlpha(this.altColor,.2)),this._altColorFiltered}getColorForFeature(e){const t=e._f||e;let i;if(this.colorBy&&\"none\"!==this.colorBy){const e=t.getAttributeValue(this.colorBy);i=void 0!==e?this.getVariantColorTable(this.colorBy).getColor(e):\"gray\"}else i=this.color?\"function\"==typeof this.color?this.color(e):this.color:\"NONVARIANT\"===t.type?this.nonRefColor:\"MIXED\"===t.type?this.mixedColor:this.color;return t.isFiltered()&&(i=_s.addAlpha(i,.2)),i}getVariantStrokecolor(e){const t=e._f||e;let i;return i=this.strokecolor?\"function\"==typeof this.strokecolor?this.strokecolor(t):this.strokecolor:void 0,i}callContextHook(e,t,i,n,r,s){if(this._context_hook&&\"function\"==typeof this._context_hook){const o=e._f||e;t.save(),this._context_hook(o,t,i,n,r,s),t.restore()}}clickedFeatures(e){let t=super.clickedFeatures(e);const i=\"EXPANDED\"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+(\"SQUISHED\"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=e.y;if(r<=this.variantBandHeight){const e=\"SQUISHED\"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-Kv)/(e+i));\"COLLAPSED\"!==this.displayMode&&(t=t.filter((e=>e.row===n)))}else if(this.sampleKeys){const e=r-this.variantBandHeight,i=Math.floor(e/this.sampleHeight);if(i>=0&&ie.row===r)),o=this.sampleKeys[i],a=this.header.sampleNameMap.get(o);t=s.map((e=>{const t=e.calls[a];return t.genotypeString=function(e,t){if(e.genotype){let i=\"\";if(\".\"===t.alternateBases)i=\"No Call\";else{const n=t.alternateBases.split(\",\");for(let r of e.genotype)if(i.length>0&&(i+=\" | \"),\".\"===r)i+=\".\";else if(0===r)i+=t.referenceBases;else{i+=n[r-1].replace(\"<\",\"<\")}}return i}}(t,e),t}))}}return t}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=this.browser.genome.id;let r=[];for(let e of t){const t=e._f||e;if(r.length>0&&r.push({html:'
'}),\"function\"==typeof t.popupData){const e=t.popupData(i,n);Array.prototype.push.apply(r,e)}}return r}menuItemList(){const e=[];if(this.header.INFO&&this.header.INFO){const t=this._colorByItems;e.push(\"
\");const i=Bt('
');i.text(\"Color by:\"),e.push({name:void 0,object:i,click:void 0,init:void 0});for(let n of t.keys()){const r=this.colorBy===n;e.push(this.colorByCB({key:n,label:t.get(n)},r))}e.push(this.colorByCB({key:\"info\",label:\"Info field...\"}))}if(!0===Hf(this.browser.sampleInfo,this.sampleKeys)){e.push(\"
\"),e.push(\"Sort by attribute:\");for(const s of this.browser.sampleInfo.attributeNames)if(this.sampleKeys.some((e=>{const t=this.browser.sampleInfo.getAttributes(e);return t&&t[s]}))){const o=Bt(\"
\");function a(){const e=this._sortDirections.get(s)||1;this.sortByAttribute(s,e),this.config.sort={option:\"ATTRIBUTE\",attribute:s,direction:e>0?\"ASC\":\"DESC\"},this._sortDirections.set(s,-1*e)}o.html(`  ${s.split(Uu.emptySpaceReplacement).join(\" \")}`),e.push({object:o,click:a})}}e.push(\"
\"),this.getSampleCount()>0&&(e.push({object:Bt('
')}),e.push({object:Bt(Dl(\"Show Genotypes\",this.showGenotypes)),click:function(){this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.browser.sampleNameControl.performClickWithState(this.browser,this.showGenotypes),this.browser.sampleInfoControl.performClickWithState(this.browser,this.showGenotypes)}})),e.push({object:Bt('
')});for(let c of[\"COLLAPSED\",\"SQUISHED\",\"EXPANDED\"]){e.push({object:Bt(Dl({COLLAPSED:\"Collapse\",SQUISHED:\"Squish\",EXPANDED:\"Expand\"}[c],c===this.displayMode)),click:function(){this.displayMode=c,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(e.push(\"
\"),e.push({label:\"Add SVs to circular view\",click:function(){for(let e of this.trackView.viewports)this.sendChordsForViewport(e)}})),this.canCovertToPytor()&&(e.push(\"
\"),e.push({label:\"Convert to CNVpytor track\",click:function(){this.convertToPytor()}})),e}contextMenuItemList(e){const t=[];if(this.hasSamples()&&this.showGenotypes){const i=e.viewport.referenceFrame,n=e.genomicLocation,r=i.toBP(2.5),s=this._sortDirections.get(\"genotype\")||1;this._sortDirections.set(\"genotype\",-1*s),t.push({label:\"Sort by genotype\",click:t=>{const i={direction:s,option:\"genotype\",chr:e.viewport.referenceFrame.chr,start:Math.floor(n-r),end:Math.ceil(n+r)},o=e.viewport.cachedFeatures;this.sortSamplesByGenotype(i,o),this.config.sort=i}}),t.push(\"
\")}if(this.browser.circularView){const i=e.viewport;t.push({label:\"Add SVs to Circular View\",click:()=>{this.sendChordsForViewport(i)}}),t.push(\"
\")}return t}async sortSamplesByGenotype({chr:e,position:t,start:i,end:n,direction:r},s){if(void 0===i&&(i=t-1),void 0===n&&(n=t),s||(s=await this.featureSource.getFeatures({chr:e,start:i,end:n})),!s)return;const o=new Map,a=\"ASC\"===r?1:-1;for(let e of s)if(!(e.endn)break;for(let t of e.calls){const e=t.sample,i=t.zygosityScore();o.set(e,o.has(e)?o.get(e)+i:i)}}this.sampleKeys.sort((function(e,t){let i=o.get(e)||0,n=o.get(t)||0;return a*(i-n)})),this.trackView.repaintViews()}sortByAttribute(e,t){this.config.sort={option:\"ATTRIBUTE\",attribute:e,direction:1===t?\"ASC\":\"DESC\"},this.sampleKeys=this.browser.sampleInfo.getSortedSampleKeysByAttribute(this.sampleKeys,e,t),this.trackView.repaintViews()}sendChordsForViewport(e){const t=e.referenceFrame;let i;if(\"all\"===t.chr){const e=this.featureSource.getAllFeatures(),t=Object.keys(e).map((t=>e[t]));i=[].concat(...t)}else i=this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end);Pm(i.filter((e=>{const t=e._f||e;return t.info&&t.info.CHR2&&t.info.END&&(t.info.CHR2!==t.chr||Math.abs(Number.parseInt(t.info.END)-t.pos)>1e6)})).map((e=>{const t=e._f||e,i=Number.parseInt(t.info.END),n=i-100,r=i+100;return{uniqueId:`${t.chr}:${t.start}-${t.end}_${t.info.CHR2}:${t.info.END}`,refName:zm(t.chr),start:t.start,end:t.end,mate:{refName:zm(t.info.CHR2),start:n,end:r}}})),this,t,.5)}colorByCB(e,t){const i=Bt(Dl(e.label,t));if(\"info\"!==e.key){function n(){const t=\"none\"===e.key?void 0:e.key;this.colorBy=t,this.config.colorBy=t,this.trackView.repaintViews()}return{name:void 0,object:i,click:n,init:void 0}}{function r(e){this.browser.inputDialog.present({label:\"Info field\",value:\"\",callback:e=>{e?(this.colorBy=e,this._colorByItems.set(e,e)):this.colorBy=void 0,this.trackView.repaintViews()}},e)}return{name:void 0,object:i,dialog:r,init:void 0}}}getState(){const e=super.getState();return this.color&&\"function\"!=typeof this.color&&(e.color=this.color),e}getVariantColorTable(e){if(this.colorTables.has(e))return this.colorTables.get(e);if(this.colorTables.has(\"*\"))return this.colorTables.get(\"*\");{let t;if(\"SVTYPE\"===e)t=Xv;else t=new oo(\"Set1\");return this.colorTables.set(e,t),t}}paintAxis(){}canCovertToPytor(){return!this.config.indexURL&&(!!this.header&&(1===Object.keys(this.sampleKeys).length&&this.header.FORMAT&&this.header.FORMAT.AD&&this.header.FORMAT.DP))}async convertToPytor(){this.variantState={...this.config,...this.getState()},this.variantState.trackHeight=this.height,this.trackView.startSpinner(),setTimeout((async()=>{try{const e=Object.assign({},this.config);Object.setPrototypeOf(this,Gv.prototype),this.init(e),await this.postInit(),this.trackView.clearCachedFeatures(),this.trackView.setTrackHeight(this.config.height||Gv.DEFAULT_TRACK_HEIGHT),this.trackView.checkContentHeight(),this.trackView.updateViews()}finally{this.trackView.stopSpinner()}}),100)}}const Xv=new ao({DEL:\"#ff2101\",INS:\"#001888\",DUP:\"#028401\",INV:\"#008688\",CNV:\"#8931ff\",BND:\"#891100\",\"*\":\"#002eff\"}),Zv={timeout:5e3,type:\"plain\",url:\"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$\",coords:0};async function Jv(e,t){const i=e.searchConfig||Zv;let n;t=t.toUpperCase();const r=e.tracks.filter((e=>e.searchable));for(let e of r){const i=await e.search(t);if(i)return i}if(e.config&&!1!==e.config.search)try{return n=await async function(e,t,i){let n=i.url.replace(\"$FEATURE$\",t.toUpperCase());n.indexOf(\"$GENOME$\")>-1&&(n=n.replace(\"$GENOME$\",e.genome.id?e.genome.id:\"hg19\"));const r=i.timeout?{timeout:i.timeout}:void 0,s=await Qs.loadString(n,r);return function(e,t,i){let n;n=\"plain\"===i.type?function(e,t){const i=[],n=Dt(t);for(let t of n){const n=t.split(\"\\t\");if(n.length>=3){const t=n[1].split(\":\"),r=t[1].split(\"-\");i.push({chromosome:e.genome.getChromosomeName(t[0].trim()),start:parseInt(r[0].replace(/,/g,\"\")),end:parseInt(r[1].replace(/,/g,\"\")),name:n[0].toUpperCase()})}}return i}(e,t):JSON.parse(t);i.resultsField&&(n=n[i.resultsField]);if(n&&0!==n.length){const e=i.chromosomeField||\"chromosome\",t=i.startField||\"start\",r=i.endField||\"end\",s=i.coords||1;let o;o=Array.isArray(n)?n[0]:n,o.hasOwnProperty(e)&&o.hasOwnProperty(t)||console.error(\"Search service results must include chromosome and start fields: \"+o);const a=o[e];let c=o[t]-s,l=o[r];void 0===l&&(l=c+1);const h={chr:a,start:c,end:l};if(!o.type||o.type,i.geneField&&i.snpField){const e=o[i.geneField]||o[i.snpField];e&&(h.name=e.toUpperCase())}return h}return}(e,s,i)}(e,t,i),n}catch(e){console.log(\"Search service not available \"+e)}}function ey(e,t=!1){const i=e.split(\"\\t\");if(i.length>2)try{const e=i[0],t=parseInt(i[1].replace(/,/g,\"\"),10)-1,n=parseInt(i[2].replace(/,/g,\"\"),10);if(!isNaN(t)&&!isNaN(n))return{chr:e,start:t,end:n}}catch(e){}const n=e.split(\":\"),r={chr:n[0]};if(n.length>1){let e,i=n[1].split(\"-\");if(i.length>2){if(!n[1].startsWith(\"-\"))return;{const e=n[1].indexOf(\"-\",1);if(e>0){i=[n[1].substring(0,e),n[1].substring(e+1)]}}}if(e=i[0].replace(/,/g,\"\"),isNaN(e))return;if(r.start=parseInt(e,10)-1,r.end=r.start+1,1===i.length&&(r.start-=20,r.end+=20),2===i.length){if(e=i[1].replace(/,/g,\"\"),isNaN(e))return;if(r.end=parseInt(e,10),r.start<0&&!t){const e=-extent.start;r.start+=e,r.end+=e}}}return r}class ty extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.type=\"qtl\",this.name=e.name;const t=e.minLogP||e.min,i=e.maxLogP||e.max;this.dataRange={min:void 0!==t?t:3.5,max:i||25},this.autoscale=!i||e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||2,this.height=e.height||100,this.disableButtons=e.disableButtons,this.featureSource=Ad(e,this.browser.genome)}paintAxis(e,t,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*t,a=s-5,c=s,l=i-(o-this.dataRange.min)/n;xo.strokeLine(e,a,l,c,l,r),l>8&&xo.fillText(e,o,a-1,l+2,r)}r.textAlign=\"center\",xo.fillText(e,\"-log10(pvalue)\",t/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(e,t,i){const n=this.visibilityWindow;return await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const{context:t,referenceFrame:i,pixelWidth:n,pixelHeight:r}=e;this.background&&xo.fillRect(t,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(t,0,r-1,n,r-1,{strokeStyle:this.divider}),i.feature&&i.feature.match(/RS[0-9]+/);const s=i=>{const s=i?2*this.dotSize:this.dotSize,o=e.bpStart,a=(this.dataRange.max-this.dataRange.min)/r;for(let d of e.features){const u=(d.start-o+.5)/e.bpPerPixel;if(u<0)continue;if(u>n)break;const f=d.phenotype;let p;if(this.browser.qtlSelections.qtl?(l=this.browser.qtlSelections.qtl,h=d,p=l.chr===h.chr&&l.start===h.start&&l.pValue===h.pValue):p=this.browser.qtlSelections.snps.size>0?this.browser.qtlSelections.hasSnp(d.snp)&&this.browser.qtlSelections.hasPhenotype(f):this.browser.qtlSelections.hasPhenotype(f),!i||p){var c=-Math.log(d.pValue)/Math.LN10;if(c>=this.dataRange.min){let e;c>this.dataRange.max?(c=this.dataRange.max,e=!0):e=!1;const n=Math.max(0+s,r-Math.round((c-this.dataRange.min)/a));let o;d.px=u,d.py=n,d.radius=s,i&&p?(o=this.browser.qtlSelections.colorForGene(f),xo.setProperties(t,{fillStyle:o,strokeStyle:\"black\"})):(o=e?\"rgb(150, 150, 150)\":\"rgb(180, 180, 180)\",xo.setProperties(t,{fillStyle:o,strokeStyle:o})),xo.fillCircle(t,u,n,s),xo.strokeCircle(t,u,n,s)}}}var l,h};s(!1),s(!0)}popupData(e,t){if(void 0===t&&(t=e.viewport.cachedFeatures),!t||0===t.length)return[];const i=this.name,n=[];for(let r of this._clickedFeatures(e,t))n.length>0&&n.push(\"
\"),\"function\"==typeof r.popupData?n.push(...r.popupData(e)):n.push({name:\"snp id\",value:r.snp},{name:\"gene id\",value:r.gencodeId},{name:\"gene name\",value:r.geneSymbol},{name:\"p value\",value:r.pValue},{name:\"tissue\",value:i});return n}_clickedFeatures(e,t){const i=(e,t)=>Math.sqrt((e.px-t.canvasX)*(e.px-t.canvasX)+(e.py-t.canvasY)*(e.py-t.canvasY)),n=t.filter((t=>i(t,e)<6));if(n.length>1){n.sort(((t,n)=>i(t,e)-i(n,e)));const t=i(n[0],e);return n.filter((n=>i(n,e)<=t))}return n}contextMenuItemList(e){const t=[],i=e.viewport.cachedFeatures;if(i){const n=this._clickedFeatures(e,i);n.length>0&&(t.push({label:\"Highlight associated features\",click:async()=>{this.browser.qtlSelections.clear();for(let e of n)this.browser.qtlSelections.qtl=e,this.browser.qtlSelections.addPhenotype(e.phenotype);this.browser.repaintViews()}}),t.push(\"
\"))}return t}menuItemList(){const e=[];return e.push(...this.numericDataMenuItems()),e.push(\"
\"),e.push({label:\"Search for...\",dialog:function(e){this.browser.inputDialog.present({label:\"Search for snp or phenotype\",value:\"\",callback:async e=>{if(e){e=e.trim().toUpperCase();const t=t=>((t.phenotype&&t.phenotype.toUpperCase())===e||t.snp&&t.snp.toUpperCase()===e)&&-Math.log(t.pValue)/Math.LN10>this.dataRange.min;let i,n,r,s=await this.featureSource.findFeatures(t);if(0==s.length){await this.browser.search(e)&&(s=await this.featureSource.findFeatures(t))}if(s.length>0){this.browser.qtlSelections.clear();const t=new Set;i=s[0].chr,n=s[0].start,r=s[0].end;for(let o of s)o.snp&&o.snp.toUpperCase()===e&&this.browser.qtlSelections.addSnp(o.snp),this.browser.qtlSelections.addPhenotype(o.phenotype),t.add(o.phenotype),o.chr===i&&(n=Math.min(n,o.start),r=Math.max(r,o.end));const o=this.browser.genome.getChromosomeName(i);for(let e of t){const t=await Jv(this.browser,e);t&&o===this.browser.genome.getChromosomeName(t.chr)&&(n=Math.min(n,t.start),r=Math.max(r,t.end))}const a=Math.floor(.1*(r-n));n=Math.max(0,n-a),r+=a,await this.browser.search(`${i}:${n}-${r}`)}}}},e)}}),e}doAutoscale(e){let t=this.config.max||25;if(e.length>0){const i=e.map((e=>-Math.log(e.pValue)/Math.LN10));i.sort(((e,t)=>e-t));t=i[Math.floor(i.length*(this.autoscalePercentile/100))]}return this.dataRange.max=Math.max(t,10),this.dataRange}}const iy={X:\"rgb(204, 153, 0)\",Y:\"rgb(153, 204, 0)\",Un:\"darkGray)\",1:\"rgb(80, 80, 255)\",2:\"rgb(206, 61, 50)\",\"2a\":\"rgb(210, 65, 55)\",\"2b\":\"rgb(215, 70, 60)\",3:\"rgb(116, 155, 88)\",4:\"rgb(240, 230, 133)\",5:\"rgb(70, 105, 131)\",6:\"rgb(186, 99, 56)\",7:\"rgb(93, 177, 221)\",8:\"rgb(128, 34, 104)\",9:\"rgb(107, 215, 107)\",10:\"rgb(213, 149, 167)\",11:\"rgb(146, 72, 34)\",12:\"rgb(131, 123, 141)\",13:\"rgb(199, 81, 39)\",14:\"rgb(213, 143, 92)\",15:\"rgb(122, 101, 165)\",16:\"rgb(228, 175, 105)\",17:\"rgb(59, 27, 83)\",18:\"rgb(205, 222, 183)\",19:\"rgb(97, 42, 121)\",20:\"rgb(174, 31, 99)\",21:\"rgb(231, 199, 111)\",22:\"rgb(90, 101, 94)\",23:\"rgb(204, 153, 0)\",24:\"rgb(153, 204, 0)\",25:\"rgb(51, 204, 0)\",26:\"rgb(0, 204, 51)\",27:\"rgb(0, 204, 153)\",28:\"rgb(0, 153, 204)\",29:\"rgb(10, 71, 255)\",30:\"rgb(71, 117, 255)\",31:\"rgb(255, 194, 10)\",32:\"rgb(255, 209, 71)\",33:\"rgb(153, 0, 51)\",34:\"rgb(153, 26, 0)\",35:\"rgb(153, 102, 0)\",36:\"rgb(128, 153, 0)\",37:\"rgb(51, 153, 0)\",38:\"rgb(0, 153, 26)\",39:\"rgb(0, 153, 102)\",40:\"rgb(0, 128, 153)\",41:\"rgb(0, 51, 153)\",42:\"rgb(26, 0, 153)\",43:\"rgb(102, 0, 153)\",44:\"rgb(153, 0, 128)\",45:\"rgb(214, 0, 71)\",46:\"rgb(255, 20, 99)\",47:\"rgb(0, 214, 143)\",48:\"rgb(20, 255, 177)\"};for(let DA of Object.keys(iy)){iy[\"chr\"+DA]=iy[DA]}for(let TA=1;TA<=48;TA++){if(10===TA)continue;const LA=ny(TA);iy[LA]=iy[TA.toString()]}function ny(e){if(!+e)return!1;for(var t=String(+e).split(\"\"),i=[\"\",\"C\",\"CC\",\"CCC\",\"CD\",\"D\",\"DC\",\"DCC\",\"DCCC\",\"CM\",\"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\",\"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\"],n=\"\",r=3;r--;)n=(i[+t.pop()+10*r]||\"\")+n;return Array(+t.join(\"\")+1).join(\"M\")+n}class ry extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.useChrColors=void 0===e.useChrColors||e.useChrColors,this.trait=e.trait,this.posteriorProbability=e.posteriorProbability,this.valueProperty=\"bed\"===e.format?\"score\":\"value\",this.height=e.height||100,this.autoscale=e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||\"rgb(225,225,225)\",this.dotSize=e.dotSize||3,this.popoverWindow=void 0===e.popoverWindow?1e8:e.popoverWindow,this.useChrColors?this.colorScale=new ao(e.colorTable||iy):e.color?this.colorScale=new ff(e.color):this.colorScale=new df(e.colorScale||{thresholds:[5e-8,5e-4,.5],colors:[\"rgb(255,50,50)\",\"rgb(251,100,100)\",\"rgb(251,170,170)\",\"rgb(227,238,249)\"]}),this.featureSource=Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.features,i=e.context,n=e.pixelWidth,r=e.pixelHeight;if(this.background&&xo.fillRect(i,0,0,n,r,{fillStyle:this.background}),xo.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),t){const s=e.bpPerPixel,o=e.bpStart,a=o+n*s+1;for(let e of t){const t=e.start;if(ta)break;let n;if(this.posteriorProbability)n=e[this.valueProperty];else{const t=e[this.valueProperty];if(!t)continue;n=-Math.log10(t)}const c=this.useChrColors?e._f?e._f.chr:e.chr:n,l=this.colorScale.getColor(c),h=(this.dataRange.max-this.dataRange.min)/r,d=Math.round((t-o)/s),u=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/h));l&&xo.setProperties(i,{fillStyle:l,strokeStyle:\"black\"}),xo.fillCircle(i,d,u,this.dotSize),e.px=d,e.py=u}}}paintAxis(e,t,i){xo.fillRect(e,0,0,t,i,{fillStyle:\"rgb(255, 255, 255)\"});var n={font:\"normal 10px Arial\",textAlign:\"right\",strokeStyle:\"black\"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const t=.1;for(let s=this.dataRange.min;s0&&i.push(\"
\"),5==r){i.push(\"...\");break}if(s=s._f||s,\"function\"==typeof s.popupData)i=i.concat(s.popupData());else{const e=s[this.valueProperty],t=s.chr,r=Rt(s.start+1);i.push({name:\"chromosome\",value:t}),i.push({name:\"position\",value:r}),i.push({name:\"name\",value:s.name}),n.posteriorProbability?i.push({name:\"posterior probability\",value:e}):i.push({name:\"pValue\",value:e})}r++}}}return i}menuItemList(){return this.numericDataMenuItems()}doAutoscale(e){if(e.length>0){const t=this.valueProperty,i=this.posteriorProbability,n=e.map((function(e){const n=e[t];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=qa(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class sy extends Hl{constructor(e,t){super(e,t)}init(e){super.init(e),this.autoscale=e.autoscale||void 0===e.max,this.dataRange={min:e.min||0,max:e.max},this.windowFunction=e.windowFunction||\"mean\",this.paintAxis=cd,this.graphType=e.graphType||\"bar\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=Ad(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if(\"function\"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleKeys=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty(\"clickToHighlight\")){let e=this.header.clickToHighlight;this.config.clickToHighlight=e,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty(\"highlight\")){this.config.highlightSamples={};let e=this.header.highlight;Array.isArray(e)||(e=[e]);for(let t of e){const e=t.split(\";\");2===e.length&&(this.config.highlightSamples[e[0]]=e[1])}}}}menuItemList(){return this.numericDataMenuItems()}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let e=1;et&&(r=e-1),void 0===s&&n[e].start>i){s=e+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=e,a=e=>(this.dataRange.max-e)/(this.dataRange.max-this.dataRange.min)*o,c=function(e){let t=Math.floor((e-r)/n);return isNaN(t)&&console.warn(\"isNaN(x). feature start \"+Rt(e)+\" bp start \"+Rt(r)),t};if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const e=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},l=[],h=[];this.clickDetectorCache={};for(let d of t){const t=c(d.start),u=c(d.end),f=s>=0?c(s):t;if(!isNaN(t)&&!isNaN(u)){this.clickDetectorCache[t]=[],this.clickDetectorCache[u]=[];for(let s=0;s=1){const s=o[c],h=a(s),d=e&&e[c];d?l.push([f,h,t,g,d]):r&&c in this.config.samplesClickedToHighlight?l.push([f,h,t,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,f,h,t,g,{strokeStyle:\"#D9D9D9\"}),n&&!(c in e)||this.clickDetectorCache[t].push([f,h,t,g,c,d||\"gray\"])}if(u-t>=1){const s=e&&e[c];s?h.push([t,g,u,g,s]):r&&c in this.config.samplesClickedToHighlight?h.push([t,g,u,g,this.config.samplesClickedToHighlight[c]]):xo.strokeLine(i,t,g,u,g,{strokeStyle:\"gray\"}),n&&!(c in e)||this.clickDetectorCache[u].push([t,g,u,g,c,s||\"gray\"])}o[c]=p}s=d.end}}for(let e of l)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:1.3});for(let e of h)xo.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:2})}(e=>{if(this.config.hasOwnProperty(\"guideLines\"))for(let t of this.config.guideLines)if(t.hasOwnProperty(\"color\")&&t.hasOwnProperty(\"y\")&&t.hasOwnProperty(\"dotted\")){let i=a(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?xo.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):xo.strokeLine(e.context,0,i,e.pixelWidth,i,n)}})(e)}doAutoscale(e){let t,i;return e.length>0?(t=Number.MAX_VALUE,i=-Number.MAX_VALUE,e.forEach((function(e){t=Math.min(t,...e.values),i=Math.max(i,...e.values)})),t-=.01,i+=.01):(t=0,i=100),{min:t,max:i}}clickedFeatures(e){const t=e.canvasX,i=e.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=t)break;if(n){let e=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(ts)return[];const a=n[1],c=n[3];if(iMath.max(a,c)+10)continue;const l=oy(t,i,r,a,s,c);l0?c/l:0}class ay extends Hl{static defaults={height:300,theta:Math.PI/2,arcOrientation:\"UP\"};constructor(e,t){super(e,t),!1===e.arcOrientation?this.arcOrientation=\"DOWN\":!0===e.arcOrientation?this.arcOrientation=\"UP\":e.arcOrientation?this.arcOrientation=e.arcOrientation.toUpperCase():this.arcOrientation=\"UP\",\"bp\"===e.format?this.featureSource=new ly(e,t.genome):this.featureSource=new ud(e,t.genome)}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.context,i=Math.PI/2,n=e.pixelWidth,r=e.pixelHeight;e.viewportWidth;const s=e.bpPerPixel,o=e.bpStart,a=s,c=\"UP\"===this.arcOrientation;xo.fillRect(t,0,e.pixelTop,n,r,{fillStyle:\"rgb(255, 255, 255)\"});const l=e.features;if(l){cy(l,1);for(let e of l)if(e.startLeft){let n=Math.round((e.startLeft-o)/a),r=Math.round((e.startRight-o)/a),s=Math.round((e.endLeft-o)/a),l=Math.round((e.endRight-o)/a);t.fillStyle=e.color,t.strokeStyle=e.color,t.beginPath();let h=(n+l)/2,d=(l-n)/2,u=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);c?(t.arc(h,u,d,f,p),t.lineTo(s,u)):(u=0,t.arc(h,u,d,p,f),t.lineTo(l,u));const g=(r+s)/2,m=(s-r)/2,w=u;c?(t.arc(g,w,m,p,f,!0),t.lineTo(n,w)):(t.arc(g,w,m,f,p,!0),t.lineTo(s,w)),t.stroke(),t.fill(),e.drawState={x1:h,y1:u,r1:d,x2:g,y2:w,r2:m,sa:f,ea:p}}else{let n=Math.round((e.start-o)/a),r=Math.round((e.end-o)/a);t.strokeStyle=e.color,t.beginPath();let s=(n+r)/2,l=(r-n)/2,h=this.height,d=Math.PI+(Math.PI/2-i),u=2*Math.PI-(Math.PI/2-i);c?t.arc(s,h,l,d,u):(h=0,t.arc(s,h,l,u,d)),t.stroke(),e.drawState={x1:s,y1:h,r1:l,sa:d,ea:u}}}}clickedFeatures(e){const t=super.clickedFeatures(e),i=[];cy(t,-1);for(let n of t){const t=n.drawState,r=e.canvasX-t.x1,s=e.canvasY-t.y1,o=Math.sqrt(r*r+s*s),a=t.r1+3;let c,l;if(void 0===t.x2)c=o,l=t.r1-3;else{const i=e.canvasX-t.x2,n=e.canvasY-t.y2;c=Math.sqrt(i*i+n*n),l=t.r2-3}if(ol){i.push(n);break}}return i}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0)return this.extractPopupData(t[0],this.getGenomeId())}menuItemList(){return[{name:\"Toggle arc direction\",click:function(){this.arcOrientation=\"UP\"===this.arcOrientation?\"DOWN\":\"UP\",this.trackView.repaintViews()}}]}}function cy(e,t){e.sort((function(e,i){const n=void 0===e.score?-Number.MAX_VALUE:e.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===t?1:t)*(n-r)}))}class ly{constructor(e,t){this.config=e,this.genome=t}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,t,i);{const n=Ua(this.config),r=await Qs.loadByteArray(this.config.url,n);return this.featureCache=new Zs(function(e){if(!e)return null;const t=mh(e);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=t.nextLine());){const e=i.split(\"\\t\");if(n&&i.startsWith(\"color:\")){const t=\"rgb(\"+e[1]+\",\"+e[2]+\",\"+e[3]+\")\";r.push(t),e.length>4&&s.push(e[4])}else{n=!1;const t=e[0],i=Number.parseInt(e[1])-1,c=Number.parseInt(e[2])-1,l=Number.parseInt(e[3]),h=Number.parseInt(e[4]);var a=Number.parseInt(e[5]);const d=r[a];let u;u=i<=h?{chr:t,startLeft:Math.min(i,c),startRight:Math.max(i,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:d,score:a}:{chr:t,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(i,c),endRight:Math.max(i,c),color:d,score:a},u.start=u.startLeft,u.end=u.endRight,s.length>a&&(u.description=s[a]),o.push(u)}}return o}(r),s),this.featureCache.queryFeatures(e,t,i)}}}class hy{constructor(e){this.browser=e,this.type=\"ideogram\",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,features:r}){const s=t.chr,o=t.genome.getChromosome(s);if(void 0===o||i<=0||n<=0||\"all\"===s.toLowerCase())return;!function({ctx:e,chr:t,referenceFrame:i,genome:n,width:r,height:s,stainColors:o,features:a}){const c=1,l=.5*c,h=0;if(void 0===n)return;xo.fillRect(e,0,0,r,s,{fillStyle:_s.greyScale(255)});const d=a;if(d){const t=h+s/2,i=[],n=[];if(0===d.length)return;const a=r/d[d.length-1].end;e.beginPath(),xo.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1),e.clip();for(let r=0;r0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),o.bpLength=l),a{uy.getColor(e)}));class fy extends Hl{static defaults={margin:10,colorByNumReadsThreshold:5,height:100};constructor(e,t){super(e,t)}init(e){super.init(e),this.type=e.type||\"junctions\",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:Ad(e,this.browser.genome)}async postInit(){if(\"function\"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&\"function\"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){return this.height}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.isMergedTrack||xo.fillRect(i,0,e.pixelTop,s,o,{fillStyle:\"rgb(255, 255, 255)\"}),t){const s={};s.referenceFrame=e.viewport.referenceFrame,s.referenceFrameStart=s.referenceFrame.start,s.referenceFrameEnd=s.referenceFrameStart+s.referenceFrame.toBP(e.viewport.getWidth()),s.featureZoomOutTracker={};for(let e of t)if(!(e.enda)break;this.renderJunction(e,r,n,o,i,s)}}else console.log(\"No feature list\")}renderJunction(e,t,i,n,r,s){e.isVisible=!1;const o=Math.round((e.start-t)/i),a=Math.round((e.end-t)/i),c=(o+a)/2;if(a-o<=3){if(c in s.featureZoomOutTracker)return;s.featureZoomOutTracker[c]=!0}if(this.config.hideAnnotatedJunctions&&\"true\"===e.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&\"false\"===e.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(e.attributes.motif))return;if(this.config.hideStrand===e.strand)return;if(this.config.minJunctionEndsVisible){let t=0;if(e.start>=s.referenceFrameStart&&e.start<=s.referenceFrameEnd&&(t+=1),e.end>=s.referenceFrameStart&&e.end<=s.referenceFrameEnd&&(t+=1),t0&&h/d>this.config.maxFractionMultiMappedReads)return;if(e.attributes.maximum_spliced_alignment_overhang&&parseInt(e.attributes.maximum_spliced_alignment_overhang)this.config.maxSamplesWithThisJunction)return;if(e.attributes.num_samples_total&&(e.attributes.percent_samples_with_this_junction=100*u/Number(e.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(e.attributes.percent_samples_with_this_junctionthis.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,p=n,g=f+.5*p;let m=f;const w=f+p-10,b=(o+c)/2,F=(c+a)/2;let v,y,A=1;e.attributes.line_width?A=Number(e.attributes.line_width):(void 0===this.config.thicknessBasedOn||\"numUniqueReads\"===this.config.thicknessBasedOn?A=l:\"numReads\"===this.config.thicknessBasedOn?A=d:\"numSamplesWithThisJunction\"===this.config.thicknessBasedOn&&void 0!==u&&(A=u),A=1+Math.log(A+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||\"random\"===this.config.bounceHeightBasedOn?v=(e.start+e.end)%7:\"distance\"===this.config.bounceHeightBasedOn?v=6*(e.end-e.start)/(s.referenceFrameEnd-s.referenceFrameStart):\"thickness\"===this.config.bounceHeightBasedOn&&(v=2*A),m+=p*Math.max(7-v,0)/10,y=e.attributes.color?e.attributes.color:void 0===this.config.colorBy||\"numUniqueReads\"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"numReads\"===this.config.colorBy?d>this.config.colorByNumReadsThreshold?\"blue\":\"#AAAAAA\":\"isAnnotatedJunction\"===this.config.colorBy?\"true\"===e.attributes.annotated_junction?\"#b0b0ec\":\"orange\":\"strand\"===this.config.colorBy?\"+\"===e.strand?\"#b0b0ec\":\"#ecb0b0\":\"motif\"===this.config.colorBy?uy.getColor(e.attributes.motif):\"#AAAAAA\";let C=\"\";e.attributes.label?C=e.attributes.label.replace(/_/g,\" \"):void 0===this.config.labelWith||\"uniqueReadCount\"===this.config.labelWith?C=l:\"totalReadCount\"===this.config.labelWith?C=d:\"numSamplesWithThisJunction\"===this.config.labelWith?void 0!==u&&(C=u):\"percentSamplesWithThisJunction\"===this.config.labelWith?void 0!==e.attributes.percent_samples_with_this_junction&&(C=e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%\"):\"motif\"===this.config.labelWith&&void 0!==e.attributes.motif&&(C+=e.attributes.motif),\"uniqueReadCount\"===this.config.labelWithInParen?C+=\" (\"+l+\")\":\"totalReadCount\"===this.config.labelWithInParen?C+=\" (\"+d+\")\":\"multiMappedReadCount\"===this.config.labelWithInParen?h>0&&(C+=\" (+\"+h+\")\"):\"numSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==u&&(C+=\" (\"+u+\")\"):\"percentSamplesWithThisJunction\"===this.config.labelWithInParen?void 0!==e.attributes.percent_samples_with_this_junction&&(C+=\" (\"+e.attributes.percent_samples_with_this_junction.toFixed(0)+\"%)\"):\"motif\"===this.config.labelWithInParen&&void 0!==e.attributes.motif&&(C+=` ${e.attributes.motif}`),e.isVisible=!0,r.beginPath(),r.moveTo(o,w),r.bezierCurveTo(b,m,F,m,a,w),r.lineWidth=A,r.strokeStyle=y,r.stroke();const _=(e,t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-n/2,i-n),e.lineTo(t+n/2,i-n),e.lineTo(t,i),e.closePath(),e.fill()};if(e.attributes.left_shape||e.attributes.right_shape){r.fillStyle=y;const t=r.lineWidth>2?10:7;e.attributes.left_shape&&_(r,o,w,t),e.attributes.right_shape&&_(r,a,w,t)}r.fillText(C,c-r.measureText(C).width/2,(7*m+g)/8)}clickedFeatures(e){return super.clickedFeatures(e).filter((function(e){return e.isVisible&&e.attributes}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=\"function\"==typeof e.popupData?e.popupData(i):this.extractPopupData(e._f||e,this.getGenomeId());t&&(n.length>0&&n.push(\"

\"),Array.prototype.push.apply(n,t))}return n}dispose(){this.trackView=void 0}}const py={min:0,max:3e3,color:\"rgb(0,0,255)\"};class gy{constructor(e){e=e||py,this.max=e.max,this.min=e.min||0,this.cache=[],this.nbins=1e3,this.binsize=(this.max-this.min)/this.nbins,this.updateColor(e.color||\"rgb(0,0,255)\")}updateColor(e){const t=e.substring(4).replace(\")\",\"\").split(\",\");3===t.length&&(this.r=Number.parseInt(t[0].trim()),this.g=Number.parseInt(t[1].trim()),this.b=Number.parseInt(t[2].trim())),this.cache=[]}setMinMax(e,t){this.min=e,this.max=t,this.cache=[],this.binsize=(this.max-this.min)/this.nbins}getColor(e){if(e\");let t=Bt(\"
\");return t.text(\"Set data range\"),e.push({object:t,dialog:function(){this.trackView.track.selected?this.browser.dataRangeDialog.configure(this.trackView.browser.getSelectedTrackViews()):this.browser.dataRangeDialog.configure(this.trackView),this.browser.dataRangeDialog.present(Bt(this.browser.columnContainer))}}),e}setDataRange({min:e,max:t}){this.dataRange.min=e,this.dataRange.max=t,this.colorScale.min=e,this.colorScale.max=t,this.trackView.repaintViews()}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys,height:this.rowHeight,yOffset:0}}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}draw({context:e,pixelTop:t,pixelWidth:i,pixelHeight:n,features:r,bpPerPixel:s,bpStart:o}){if(xo.fillRect(e,0,t,i,n,{fillStyle:\"rgb(255, 255, 255)\"}),r&&r.length>0){const a=this.rowHeight,c=t+n,l=o+i*s+1,h=a;for(let i of r){if(i.endl)continue;const n=Math.round((i.start-o)/s),r=Math.round((i.end-o)/s),d=Math.max(1,r-n);let u=0;for(let r=i.values.length-1;r>=0;r--){const s=i.values[r],o=u*a;if(o+ac)continue;const l=this.colorScale.getColor(s);e.fillStyle=l,e.fillRect(n,o,d,h),u++}}}}computePixelHeight(e){return e&&0!==e.length?e[0].values.length*this.rowHeight:0}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push(\"
\"),i.push(\"
\"));const t=e._f||e,n=\"function\"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}get supportsWholeGenome(){return!1}getState(){const e=super.getState();return e.colorScale=this.colorScale.toJson(),e}}const wy=new Map([[\"ideogram\",(e,t)=>new hy(e,t)],[\"sequence\",(e,t)=>new Zd(e,t)],[\"feature\",(e,t)=>new Hd(e,t)],[\"seg\",(e,t)=>new Pf(e,t)],[\"mut\",(e,t)=>new Pf(e,t)],[\"maf\",(e,t)=>new Pf(e,t)],[\"shoebox\",(e,t)=>new my(e,t)],[\"wig\",(e,t)=>new ld(e,t)],[\"merged\",(e,t)=>new tf(e,t)],[\"alignment\",(e,t)=>new tw(e,t)],[\"interaction\",(e,t)=>new iw(e,t)],[\"interact\",(e,t)=>new iw(e,t)],[\"variant\",(e,t)=>new Yv(e,t)],[\"qtl\",(e,t)=>new ty(e,t)],[\"eqtl\",(e,t)=>new ty(e,t)],[\"gwas\",(e,t)=>new ry(e,t)],[\"arc\",(e,t)=>new ay(e,t)],[\"gcnv\",(e,t)=>new sy(e,t)],[\"junction\",(e,t)=>new fy(e,t)],[\"blat\",(e,t)=>new Vd(e,t)],[\"cnvpytor\",(e,t)=>new Gv(e,t)]]);class by{constructor(e,t){const i=(new DOMParser).parseFromString(e,\"text/xml\");this.processRootNode(i,t);const n=i.getElementsByTagName(\"Resource\"),r=i.getElementsByTagName(\"Track\"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(e,t){var i={url:e.getAttribute(\"path\"),indexURL:e.getAttribute(\"index\"),order:t};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(e){const t=e.getElementsByTagName(\"Track\");if(t&&t.length>0){const i={type:\"merged\",tracks:[]};Fy(e,i),o.push(i),Array.from(t).forEach((function(e){e.processed=!0;const t=e.getAttribute(\"id\"),n=a.get(t);n&&(i.tracks.push(n),Fy(e,n),n.autoscale=!1,i.height=n.height)}))}else if(!e.processed){const t=e.getAttribute(\"id\"),i=a.get(t);i&&(o.push(i),Fy(e,i))}}))}processRootNode(e,t){const i=e.getElementsByTagName(\"Session\");!i||i.length;const n=i.item(0),r=n.getAttribute(\"genome\"),s=n.getAttribute(\"locus\"),o=n.getAttribute(\"ucscID\");t&&t.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Fy(e,t){t.name=e.getAttribute(\"name\");const i=e.getAttribute(\"color\");i&&(t.color=\"rgb(\"+i+\")\");const n=e.getAttribute(\"altColor\");i&&(t.altColor=\"rgb(\"+n+\")\");const r=e.getAttribute(\"height\");r&&(t.height=parseInt(r));const s=e.getAttribute(\"autoScale\");s&&(t.autoscale=\"true\"===s);const o=e.getAttribute(\"autoscaleGroup\");o&&(t.autoscaleGroup=o);const a=e.getAttribute(\"windowFunction\");a&&(t.windowFunction=a);const c=e.getAttribute(\"visibilityWindow\")||e.getAttribute(\"featureVisibilityWindow\");c&&(t.visibilityWindow=c);const l=e.getAttribute(\"indexed\");l&&(t.indexed=\"true\"===l);const h=e.getAttribute(\"normalize\");h&&(t.normalize=\"true\"===h);const d=e.getElementsByTagName(\"DataRange\");if(d.length>0){const e=d.item(0);t.min=Number(e.getAttribute(\"minimum\")),t.max=Number(e.getAttribute(\"maximum\")),t.logScale=\"LOG\"===e.getAttribute(\"type\")}}class vy{constructor(e,t,i,n,r){this.genome=e,this.chr=t,this.start=i,this.end=n,this.bpPerPixel=r,this.id=s()}get center(){return(this.start+this.end)/2}get locusSearchString(){return`${this.chr}:${this.start+1}-${this.end}`}extend(e){const t=Math.min(e.start,this.start),i=Math.max(e.end,this.end),n=(i-t)/(this.end-this.start);this.start=t,this.end=i,this.bpPerPixel*=n}calculateEnd(e){return this.start+this.bpPerPixel*e}calculateCenter(e){return this.start+this.bpPerPixel*e/2}calculateBPP(e,t){return(e-this.start)/t}set(e){this.chr=e.chr,this.start=e.start,this.bpPerPixel=e.bpPerPixel}toPixels(e){return e/this.bpPerPixel}toBP(e){return this.bpPerPixel*e}shift(e){this.start+=e,this.end+=e}shiftPixels(e,t,i){const n=this.start,r=e*this.bpPerPixel;return this.start+=r,i&&this.clampStart(t),this.end=this.start+t*this.bpPerPixel,n!==this.start}clampStart(e){const t=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(t,this.start),e){const{bpLength:t}=this.genome.getChromosome(this.chr),i=t-e*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(e,t,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,s=this.start,o=this.bpPerPixel,a=this.getChromosome().bpLength,c=t<1?e.minimumBases()/i:a/i;this.bpPerPixel=t<1?Math.max(this.bpPerPixel*t,c):Math.min(this.bpPerPixel*t,c);const l=this.bpPerPixel*i;this.start=r-.5*l,this.clampStart(i),this.end=this.start+l;(s!==this.start||o!==this.bpPerPixel)&&await e.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(e){const t=\" \",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*e);return`${t}${this.chr}${t}${Wa(n-i)}${t}`}getMultiLocusLabelLocusOnly(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e);return`${t}${i}:${n}-${r}${t}`}getMultiLocusLabel(e){const t=\" \",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e),s=Math.floor(this.start)+1;return`${t}${i}:${n}-${r}${t}${t}(${Wa(Math.round(this.start+this.bpPerPixel*e)-s)})${t}`}getPresentationLocusComponents(e){if(\"all\"===this.chr)return{chr:this.chr};{const t=Rt(Math.floor(this.start)+1),i=Rt(Math.round(this.start+this.bpPerPixel*e));return{chr:this.chr,start:t,end:i}}}getLocusString(){if(\"all\"===this.chr)return\"all\";return`${this.genome.getChromosomeDisplayName(this.chr)}:${Rt(Math.floor(this.start)+1)}-${Rt(Math.round(this.end))}`}description(e){console.log(` ${e||\"\"} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Rt(Math.round(this.start))} end ${Rt(Math.round(this.end))} `)}overlaps(e){return this.chr===e.chr&&this.end>=e.start&&e.end>=this.start}}function yy(){return\"3.0.9\"}const Ay=\"Maximum sequence count exceeded\";class Cy{constructor(t,i){this.container=e({class:\"igv-chromosome-select-widget-container\"}),i.appendChild(this.container),this.select=document.createElement(\"select\"),this.select.setAttribute(\"name\",\"chromosome-select-widget\"),this.container.appendChild(this.select),this.select.addEventListener(\"change\",(()=>{this.select.blur(),\"\"!==this.select.value&&Ay!==this.select.value&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes,this.genome=t.genome}show(){this.container.style.display=\"flex\"}hide(){this.container.style.display=\"none\"}setValue(e){this.select.value=this.genome.getChromosomeDisplayName(e)}update(e){this.genome=e;const t=e.wgChromosomeNames.map((t=>e.getChromosomeDisplayName(t)))||[];if(this.showAllChromosomes&&e.chromosomeNames.length>1){const i=new Set(t);let n=0;for(let r of e.chromosomeNames){if(1e3==++n){t.push(Ay);break}i.has(r)||(r=e.getChromosomeDisplayName(r),t.push(r))}}this.select.innerHTML=\"\",e.showWholeGenomeView()&&t.unshift(\"all\");for(let i of t){const t=document.createElement(\"option\");t.setAttribute(\"value\",i),t.innerText=e.getChromosomeDisplayName(i),this.select.appendChild(t)}}}class _y{constructor(t,i){this.container=e({class:\"igv-windowsize-panel-container\"}),t.appendChild(this.container),i.on(\"locuschange\",(e=>{this.updatePanel(e)})),this.browser=i}show(){this.container.style.display=\"block\"}hide(){this.container.style.display=\"none\"}updatePanel(e){const t=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===e.length?Wa(Math.round(t*e[0].bpPerPixel)):\"\"}}class xy extends Ju{constructor(e,t,i,n){super(e,t,\"Select Tracks\",ef,'\\n multi select\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n multi select hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.navbar=i,this.enableMultiTrackSelection=!1,this.button.addEventListener(\"mouseenter\",(e=>{!1===n&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(e=>{!1===n&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{this.setMultiTrackSelection(!this.enableMultiTrackSelection)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler)}setMultiTrackSelection(e){this.enableMultiTrackSelection=e,this.setState(this.enableMultiTrackSelection),!1===this.enableMultiTrackSelection&&this.navbar.overlayTrackButton.setVisibility(!1);for(const t of this.browser.trackViews)t.enableTrackSelection(e)}}class ky{constructor(t,i){this.browser=i,this.columnContainer=t,this.horizontalGuide=e({class:\"igv-cursor-guide-horizontal\"}),t.appendChild(this.horizontalGuide),this.verticalGuide=e({class:\"igv-cursor-guide-vertical\"}),t.appendChild(this.verticalGuide),this.addMouseHandler(i),this.setVisibility(i.config.showCursorGuide)}addMouseHandler(e){this.boundMouseMoveHandler=function(t){t.target.tagName;const{x:i,y:n}=a(t,this.columnContainer);if(this.horizontalGuide.style.top=`${n}px`,\"CANVAS\"===t.target.tagName){const n=function(e,t){for(;e.parentElement;){if(e.parentElement.classList.contains(t))return e.parentElement;e=e.parentElement}return}(t.target,\"igv-viewport\");if(n&&e.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const r=e.root.querySelectorAll(\".igv-column\");let s;const o=n.parentElement;for(let e=0;e\\n cursor\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n cursor hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.doShowCursorGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCursorGuide&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCursorGuide&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCursorGuide=!t.doShowCursorGuide,t.setCursorGuideVisibility(t.doShowCursorGuide),this.setState(t.doShowCursorGuide)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCursorTrackingGuideButton)}}class Sy extends Ju{constructor(e,t){super(e,t,\"Center Line\",ef,'\\n centerline\\n \\n \\n \\n \\n \\n \\n','\\n centerline hover\\n \\n \\n \\n \\n \\n \\n',t.config.showCenterGuide),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowCenterLine&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowCenterLine&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowCenterLine=!t.doShowCenterLine,t.setCenterLineVisibility(t.doShowCenterLine),this.setState(t.doShowCenterLine)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showCenterGuideButton)}}class Ey extends Ju{constructor(e,t){super(e,t,\"Track Labels\",ef,'\\n track labels\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n track labels hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showTrackLabels),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowTrackLabels&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowTrackLabels&&this.setState(!1)}));this.boundMouseClickHandler=(()=>{t.doShowTrackLabels=!t.doShowTrackLabels,t.setTrackLabelVisibility(t.doShowTrackLabels),this.setState(t.doShowTrackLabels)}).bind(this),this.button.addEventListener(\"click\",this.boundMouseClickHandler),this.setVisibility(t.config.showTrackLabelButton)}}class Ny extends Ju{constructor(e,t){super(e,t,[\"ROI\",\"Regions of Interest Table\"],ef,'\\n roi\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n','\\n roi hover\\n \\n \\n \\n \\n ROI\\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.doShowROITable&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.doShowROITable&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>this.buttonHandler(!t.doShowROITable))),this.setVisibility(!1)}buttonHandler(e){this.setState(e),this.browser.setROITableVisibility(e)}}class By extends Ju{constructor(e,t){super(e,t,\"Sample Info\",ef,'\\n sample info\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample info hover\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.showSampleInfo=!1,this.button.addEventListener(\"mouseenter\",(()=>{!1===this.showSampleInfo&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===this.showSampleInfo&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)}))}performClickWithState(e,t){this.showSampleInfo=void 0===t?!this.showSampleInfo:t;e.columnContainer.querySelector(\".igv-sample-info-column\").style.display=!1===this.showSampleInfo?\"none\":\"flex\",this.setState(this.showSampleInfo),e.layoutChange()}setButtonVisibility(e){this.showSampleInfo=e,this.setState(this.showSampleInfo),!0===this.showSampleInfo?this.show():this.hide()}}class My extends Ju{constructor(e,t){super(e,t,\"Sample Names\",'\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names\\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n sample names hover\\n \\n \\n \\n \\n \\n \\n \\n \\n',t.config.showSampleNames),this.button.addEventListener(\"mouseenter\",(()=>{!1===t.showSampleNames&&this.setState(!0)})),this.button.addEventListener(\"mouseleave\",(()=>{!1===t.showSampleNames&&this.setState(!1)})),this.button.addEventListener(\"click\",(()=>{this.performClickWithState(t,void 0)})),!0===t.config.showSampleNameButton?this.show():this.hide()}performClickWithState(e,t){e.showSampleNames=void 0===t?!e.showSampleNames:t;e.columnContainer.querySelector(\".igv-sample-name-column\").style.display=!1===e.showSampleNames?\"none\":\"flex\",this.setState(e.showSampleNames),e.layoutChange()}}class Ry{constructor(t,i){this.parent=t,this.popover=e({class:\"igv-ui-dropdown\"}),t.appendChild(this.popover),this.popoverContent=e(),this.popover.appendChild(this.popoverContent),this.popover.style.display=\"none\",this.shim=i}configure(e){if(0===e.length)return;const t=nc(e,this.popover);for(const{object:e}of t)this.popoverContent.appendChild(e)}present(e){this.popover.style.display=\"block\";let{x:t,y:i}=a(e,this.parent);this.popover.style.left=`${t+this.shim.left}px`,this.popover.style.top=`${i+this.shim.top}px`}_present(e){this.popover.style.display=\"block\";let{x:t,y:i,width:n}=a(e,this.parent);t+=this.shim.left,i+=this.shim.top,this.popover.style.top=`${i}px`;const{width:r}=this.popover.getBoundingClientRect(),s=t+r,o=s-n;this.popover.style.left=`${s>n?t-o:t}px`}dismiss(){this.popover.style.display=\"none\"}}class Dy extends Ju{constructor(e,t){super(e,t,\"Save Image\",ef,'\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n','\\n save image\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n',!1),this.button.addEventListener(\"mouseenter\",(()=>this.setState(!0))),this.button.addEventListener(\"mouseleave\",(()=>{for(const e of this.button.querySelectorAll(\"div\"))if(\"block\"===e.style.display)return;this.setState(!1)})),this.dropdown=new Ry(this.button.parentNode,{top:24,left:-88});const i=[{label:\"Save as SVG\",click:e=>{this.browser.saveSVGtoFile(\"igvjs.svg\"),this.dropdown.dismiss()}},{label:\"Save as PNG\",click:e=>{this.browser.savePNGtoFile(\"igvjs.png\"),this.dropdown.dismiss()}}];this.dropdown.configure(i),this.button.addEventListener(\"click\",(e=>{let t;if(e.target===this.button)t=!0;else if(e.target.closest(\"svg\")){e.target.closest(\"div\")===this.button&&(t=!0)}!0===t&&(\"none\"===this.dropdown.popover.style.display?this.dropdown.present(e):this.dropdown.dismiss())})),this.setVisibility(t.config.showSVGButton)}navbarResizeHandler(e){this.dropdown.dismiss(),super.navbarResizeHandler(e)}}const Ty=function(t,i,n){const r=e({class:\"igv-navbar-button\"});t.append(r),r.textContent=n.label,r.addEventListener(\"click\",(()=>n.callback(i)))};let Ly=23,zy=0;class Hy{constructor(t,i,n){this.browser=i,this.zoomContainer=e({class:\"igv-zoom-widget\"}),n.appendChild(this.zoomContainer),this.zoomOutButton=e(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(l(\"minus-circle\")),this.zoomOutButton.addEventListener(\"click\",(()=>{i.zoomOut()}));const r=e();this.zoomContainer.appendChild(r),this.slider=document.createElement(\"input\"),this.slider.type=\"range\",this.slider.min=\"0\",this.slider.max=`${Ly}`,r.appendChild(this.slider),this.slider.addEventListener(\"change\",(e=>{e.preventDefault(),e.stopPropagation();const t=i.referenceFrameList[0],{bpLength:n}=t.genome.getChromosome(t.chr),{end:r,start:s}=t,o=r-s,a=n/Math.pow(2,e.target.valueAsNumber);i.zoomWithScaleFactor(a/o)})),this.zoomInButton=e(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(l(\"plus-circle\")),this.zoomInButton.addEventListener(\"click\",(()=>{i.zoomIn()})),i.on(\"locuschange\",(e=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(e))}))}update(e){if(this.slider){const t=e[0],{bpLength:i}=t.genome.getChromosome(t.chr),{start:n,end:r}=t;Ly=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${Ly}`;const s=i/(r-n);zy=Math.log2(s),this.slider.value=`${Math.round(zy)}`}}enable(){this.slider&&(this.slider.disabled=!1)}disable(){this.slider&&(this.slider.disabled=!0)}hide(){this.zoomContainer.style.display=\"none\"}show(){this.zoomContainer.style.display=\"block\"}hideSlider(){this.slider&&(this.slider.style.display=\"none\")}showSlider(){this.slider&&(this.slider.style.display=\"block\")}}class Py{constructor(t,i){this.browser=i,this.config=t,this.currentClass=\"igv-navbar-text-button\";const n=Bt(\"
\",{class:\"igv-navbar\"});this.$navigation=n;const r=Bt(\"
\",{class:\"igv-navbar-left-container\"});n.append(r),this.navbarLeftContainer=r.get(0);const s=Bt(\"
\",{class:\"igv-logo\"});r.append(s);const o=Bt('IGV; ');o.css(\"width\",\"34px\"),o.css(\"height\",\"32px\"),s.append(o),this.$current_genome=Bt(\"
\",{class:\"igv-current-genome\"}),r.append(this.$current_genome),this.$current_genome.text(\"\");const a=Bt(\"
\",{class:\"igv-navbar-genomic-location\"});r.append(a),this.chromosomeSelectWidget=new Cy(i,a.get(0)),!1!==t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const c=Bt(\"
\",{class:\"igv-locus-size-group\"});a.append(c);const h=Bt(\"
\",{class:\"igv-search-container\"});c.append(h),this.$searchInput=Bt(\"\",{class:\"igv-search-input\",type:\"text\",placeholder:\"Locus Search\"}),h.append(this.$searchInput),this.$searchInput[0].addEventListener(\"keyup\",(e=>{e.stopImmediatePropagation()})),this.$searchInput.change((()=>i.doSearch(this.$searchInput.val())));const d=e({class:\"igv-search-icon-container\"});h.append(Bt(d)),d.appendChild(l(\"search\")),d.addEventListener(\"click\",(()=>i.doSearch(this.$searchInput.val()))),this.windowSizePanel=new _y(c.get(0),i);const u=Bt(\"
\",{class:\"igv-navbar-right-container\"});n.append(u),this.navbarRightContainer=u.get(0);const f=Bt('
');u.append(f);const p=f.get(0);this.toggle_button_container=p,this.overlayTrackButton=new sf(p,i),this.overlayTrackButton.setVisibility(!1);const g=!1!==t.showMultiSelectButton;if(this.multiTrackSelectButton=new xy(p,i,this,g),this.cursorGuideButton=new Iy(p,i),this.centerLineButton=new Sy(p,i),this.trackLabelControl=new Ey(p,i),this.roiTableControl=new Ny(p,i),this.sampleInfoControl=new By(p,i),this.sampleNameControl=new My(p,i),!0===t.showSVGButton&&(this.saveImageControl=new Dy(p,i)),t.customButtons)for(let e of t.customButtons)new Ty(p,i,e);this.zoomWidget=new Hy(t,i,u.get(0)),!1===t.showNavigation&&this.$navigation.hide()}navbarDidResize(){const e=this.$navigation.width(),t=this.currentNavbarButtonClass();\"igv-navbar-text-button\"===t&&(this.textButtonContainerWidth=this.navbarRightContainer.getBoundingClientRect().width);const i=this.browser,n=i.isMultiLocusWholeGenomeView()||i.referenceFrameList&&mu.isWholeGenomeView(i.referenceFrameList[0].chr);n?this.windowSizePanel.hide():this.windowSizePanel.show();const{x:r,width:s}=this.navbarLeftContainer.getBoundingClientRect(),o=r+s,{x:a}=this.navbarRightContainer.getBoundingClientRect();let c;if(\"igv-navbar-text-button\"===t&&a-o<8)c=\"igv-navbar-icon-button\";else if(this.textButtonContainerWidth&&\"igv-navbar-icon-button\"===t){e-o-this.textButtonContainerWidth>8&&(c=\"igv-navbar-text-button\")}let l;c&&t!==c&&(this.currentClass=c,this.browser.fireEvent(\"navbar-resize\",[c])),l=n?\"igv-zoom-widget-hidden\":e>860?\"igv-zoom-widget\":\"igv-zoom-widget-900\",Bt(this.zoomWidget.zoomContainer).removeClass(),Bt(this.zoomWidget.zoomContainer).addClass(l)}setCenterLineButtonVisibility(e){e?this.centerLineButton.setVisibility(!e):this.centerLineButton.setVisibility(this.config.showCenterGuideButton)}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}updateGenome(e){let t=e.id&&e.id.length<20?e.id:`${e.id.substring(0,8)}...${e.id.substring(e.id.length-8)}`;this.$current_genome.text(t),this.$current_genome.attr(\"title\",e.description);!1!==this.config.showChromosomeWidget&&!1!==e.showChromosomeWidget&&e.chromosomeNames&&e.chromosomeNames.length>1?(this.chromosomeSelectWidget.update(e),this.chromosomeSelectWidget.show()):this.chromosomeSelectWidget.hide()}updateLocus(e,t){this.$searchInput&&this.$searchInput.val(e),this.chromosomeSelectWidget&&(this.chromosomeSelectWidget.select.value=t)}currentNavbarButtonClass(){return this.currentClass}setEnableTrackSelection(e){this.multiTrackSelectButton.setMultiTrackSelection(e)}getEnableTrackSelection(){return this.multiTrackSelectButton.enableMultiTrackSelection}hide(){this.$navigation.hide()}show(){this.$navigation.show()}}const Oy=(e,t)=>{const i=0===e?t.nextElementSibling:t.previousElementSibling;t.remove(),i.remove()},Uy=t=>{const i=e({class:\"igv-column-shim\"});Ya(i,t);const n=e({class:\"igv-column\"});return Ya(n,i),n},qy=(t,i)=>{for(let n=0;n1&&n>0){Ka(e({class:\"igv-column-shim\"}),r)}}};class Qy{constructor(t,i,n){this.browser=t,this.referenceFrame=i,this.column=n,this.container=e({class:\"igv-center-line\"}),n.appendChild(this.container),t.doShowCenterLine?this.show():this.hide()}repaint(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const e=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${e}px`,this.container.classList.remove(\"igv-center-line-thin\"),this.container.classList.add(\"igv-center-line-wide\")}else this.container.style.width=\"1px\",this.container.classList.remove(\"igv-center-line-wide\"),this.container.classList.add(\"igv-center-line-thin\")}}show(){this.isVisible=!0,this.container.style.display=\"block\",this.repaint()}hide(){this.isVisible=!1,this.container.style.display=\"none\"}resize(){this.repaint()}}const Vy=function(t,i){this.button=e({class:\"igv-navbar-button\"}),t.appendChild(this.button),this.button.textContent=\"circular view\",this.button.addEventListener(\"click\",(()=>{i.circularViewVisible=!i.circularViewVisible})),this.browser=i,this.setVisibility(i.config.showCircularViewButton),this.setState(i.circularViewVisible)};Vy.prototype.setVisibility=function(e){!0===e?this.show():this.hide()},Vy.prototype.setState=function(e){!0===e?this.button.classList.add(\"igv-navbar-button-clicked\"):this.button.classList.remove(\"igv-navbar-button-clicked\")},Vy.prototype.show=function(){this.button.style.display=\"block\",this.setState(this.browser.circularViewVisible)},Vy.prototype.hide=function(){this.button.style.display=\"none\"};class jy{constructor(t,i){this.browser=t,this.container=e({class:\"igv-roi-menu\"}),i.appendChild(this.container);const n=e();this.container.appendChild(n),u(n,(()=>this.container.style.display=\"none\")),this.body=e(),this.container.appendChild(this.body),this.container.style.display=\"none\"}async present(e,t,i,n,r,s){const o=this.menuItems(e,t,i,n,r,s);this.browser.menuPopup.presentTrackContextMenu(i,o)}menuItems(e,t,i,n,r,s){const o=e.name?[`${e.name}
`]:[];return\"name\"in t&&o.push(`ROI Set: ${t.name}`),o.length>0&&o.push(\"
\"),t.isUserDefined&&o.push({label:\"Set description ...\",click:()=>{const t={label:\"Description\",value:e.name||\"\",callback:()=>{const t=this.browser.inputDialog.value||\"\";e.name=t.trim(),this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(t,i)}}),Xa()&&e.end-e.start<1e6&&o.push({label:\"Copy reference sequence\",click:async()=>{this.container.style.display=\"none\";let t=await this.browser.genome.getSequence(e.chr,e.start,e.end);t||(t=\"Unknown sequence\");try{await navigator.clipboard.writeText(t)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.end-e.start<=25e3&&o.push({label:\"BLAT reference sequence\",click:async()=>{this.container.style.display=\"none\";const{chr:t,start:i,end:n}=e;let r=await this.browser.genome.getSequence(t,i,n);if(r){const e=`blat: ${t}:${i+1}-${n}`,s=`blat: ${t}:${i+1}-${n}`;jd({sequence:r,browser:this.browser,name:e,title:s})}}}),t.isUserDefined&&o.push(\"
\",{label:\"Delete\",click:async()=>{t.removeFeature(e);const i=await t.getAllFeatures();0===Object.keys(i).length&&n.deleteUserDefinedROISet(),n.deleteRegionWithKey(s.dataset.region,r),n.repaintTable()}}),o}dispose(){this.container.innerHTML=\"\"}}class Wy extends Pd{constructor(e){const t={browser:e,parent:e.columnContainer,headerTitle:\"Regions of Interest\",dismissHandler:()=>e.roiTableControl.buttonHandler(!1),gotoButtonHandler:Wy.gotoButtonHandler};t.columnFormat=Wy.getColumnFormatConfiguration(!0),super(Object.assign({width:\"640px\"},t))}tableRowDOM(t){const i=e({class:\"igv-roi-table-row\"}),{setName:n,feature:r}=t;i.dataset.region=Xy(r.chr,r.start,r.end);let s=[r.chr,Rt(r.start),Rt(r.end),r.name||\"\",n];4===this.columnFormat.length&&(s=s.slice(0,4));for(let t=0;te.remove())),e.length>0){const t=e.sort(((e,t)=>e.feature.chr.localeCompare(t.feature.chr)||e.feature.start-t.feature.start||e.feature.end-t.feature.end));for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}}set footerDOM(t){super.footerDOM=t,this.gotoButton.textContent=\"Go to selected region(s)\";const i=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(i),i.id=\"igv-roi-hide-show-button\",i.textContent=\"Copy Sequence\",i.title=\"One region only of max size 1 mb\",this.copySequenceButton=i,Gy(this.copySequenceButton,!1),this.boundCopySequenceButtonHandler=async function(e){e.preventDefault(),e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\");if(t.length>0){const e=[];for(let i of t){const{locus:t}=Jy(i.dataset.region);e.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");if(this.setTableRowSelectionState(!1),e.length>0){const{chr:t,start:i,end:n}=ey(e[0],this.browser.isSoftclipped()),r=await this.browser.genome.getSequence(t,i,n);await navigator.clipboard.writeText(r)}}}.bind(this),this.copySequenceButton.addEventListener(\"click\",this.boundCopySequenceButtonHandler);const n=e({class:\"igv-roi-table-button\"});this._footerDOM.appendChild(n),n.id=\"igv-roi-hide-show-button\",n.textContent=\"Hide all ROIs\",this.toggleROIButton=n,this.boundToggleDisplayButtonHandler=function(e){e.preventDefault(),e.stopPropagation(),this.browser.roiManager.toggleROIs()}.bind(this),this.toggleROIButton.addEventListener(\"click\",this.boundToggleDisplayButtonHandler)}setROIVisibility(e){const t=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let i=0;i0&&t.length<2){const{locus:e}=Jy(t[0].dataset.region),{chr:i,start:n,end:r}=ey(e,this.browser.isSoftclipped());Gy(this.copySequenceButton,r-n<1e6)}else Gy(this.copySequenceButton,!1)}dispose(){document.removeEventListener(\"click\",this.boundGotoButtonHandler),document.removeEventListener(\"click\",this.boundCopySequenceButtonHandler),document.removeEventListener(\"click\",this.boundToggleDisplayButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(e){return!0===e?[{label:\"Chr\",width:\"20%\"},{label:\"Start\",width:\"15%\"},{label:\"End\",width:\"15%\"},{label:\"Description\",width:\"30%\"},{label:\"ROI Set\",width:\"20%\"}]:[{label:\"Chr\",width:\"25%\"},{label:\"Start\",width:\"20%\"},{label:\"End\",width:\"20%\"},{label:\"Description\",width:\"35%\"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(\".igv-roi-table-row-selected\"),i=[];for(let e of t){const{locus:t}=Jy(e.dataset.region);i.push(t)}for(let e of this.tableDOM.querySelectorAll(\".igv-roi-table-row\"))e.classList.remove(\"igv-roi-table-row-selected\");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(\" \"))}}function Gy(e,t){e.style.pointerEvents=t?\"auto\":\"none\",e.style.color=ro(t?\"licorice\":\"silver\"),e.style.borderColor=ro(t?\"licorice\":\"silver\")}function $y(e,t){const i=window.getComputedStyle(e).backgroundColor.match(/[\\d.]+/g);3===i.length&&i.push(1),i[3]=t,e.style.backgroundColor=`rgba(${i.join(\", \")})`}class Ky{constructor(e){this.browser=e,this.roiMenu=new jy(e,e.columnContainer),this.roiTable=new Wy(e,e.columnContainer),this.top=0,this.roiSets=[],this.boundLocusChangeHandler=Yy.bind(this),e.on(\"locuschange\",this.boundLocusChangeHandler);this.observer=new MutationObserver((()=>{const t=e.findTracks((e=>new Set([\"ideogram\",\"ruler\"]).has(e.type))),[i,n]=t.map((e=>e.trackView.viewports[0].$viewport.get(0))).map((e=>function(e){const t=window.getComputedStyle(e),i=parseInt(t.marginTop),n=parseInt(t.marginBottom),{top:r,bottom:s,height:o}=e.getBoundingClientRect();return{top:Math.floor(r)-i,bottom:Math.floor(s)+n,height:Math.floor(o)+i+n}}(e))),r=i?i.height:0,s=n?n.height:0,o=e.columnContainer.querySelectorAll(\".igv-roi-region\");if(o)for(const e of o)e.style.marginTop=`${r+s+-.5}px`})),this.observer.observe(e.columnContainer,{attributes:!0,childList:!0,subtree:!0})}async reset(){this.roiSets.length>0&&this.browser.roiTableControl.setVisibility(!0);const e=this.roiSets.map((e=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})));e.length>0&&await Promise.all(e);const t=await this.getTableRecords();if(this.roiTable.renderTable(t),this.roiSets.length>0){const e=this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e)}}async loadROI(e,t){const i=Array.isArray(e)?e:[e];for(let e of i)!e.name&&e.url&&(e.name=await ja(e.url)),e.url&&!e.format&&(e.format=await am(e)),this.roiSets.push(new ku(e,t));await this.reset()}clearROIs(){this.roiTable.clearTable();const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();for(let e of this.roiSets)e.dispose();this.roiSets=[]}async getTableRecords(){const e=[];for(let t of this.roiSets){const i=t.name||\"\",n=await t.getAllFeatures();for(let t of Object.keys(n))for(let r of n[t])e.push({setName:i,feature:r})}return e}presentTable(){this.roiTable.present()}async repaintTable(){const e=await this.getTableRecords();this.roiTable.renderTable(e)}dismissTable(){this.roiTable.dismiss()}roiTableIsVisible(){return this.roiTable.isVisible()}async updateUserDefinedROISet(e){let t=await this.getUserDefinedROISet();void 0===t&&(t=this.initializeUserDefinedROISet()),t.addFeature(e),this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(e){this.browser.roiTableControl.setVisibility(e)}toggleROIs(){const e=!this.roiSets[0].isVisible;this.roiTable.setROIVisibility(e);for(const t of this.roiSets)t.isVisible=e}async renderAllROISets(){for(let e of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})}async renderROISet({browser:e,pixelTop:t,roiSet:i}){const n=e.columnContainer.querySelectorAll(\".igv-column\");for(let r=0;ra)&&e.remove()}const h=await i.getFeatures(s,o,a);if(h)for(let l of h){const h=Xy(s,l.start,l.end),{x:d,width:u}=Iu(Math.max(o,l.start),Math.min(a,l.end),o,c),f=n[r].querySelector(Zy(h));if(f)f.style.left=`${d}px`,f.style.width=`${u}px`;else{const s=this.createRegionElement(e.columnContainer,t,d,u,i,h,l);n[r].appendChild(s)}}}}createRegionElement(t,i,n,r,s,o,c){const l=e({class:\"igv-roi-region\"});l.style.top=`${i}px`,l.style.left=`${n}px`,l.style.width=`${r}px`,l.style.backgroundColor=s.color,l.dataset.color=s.color,l.dataset.region=o;const h=e();return l.appendChild(h),h.style.backgroundColor=s.headerColor,h.addEventListener(\"click\",(e=>{e.preventDefault(),e.stopPropagation(),a(e,t),this.roiMenu.present(c,s,e,this,t,l)})),l}renderSVGContext(e,t,{deltaX:i,deltaY:n}){for(const r of e.querySelectorAll(\".igv-roi-region\")){const{x:e,y:s,width:o,height:a}=r.getBoundingClientRect();t.fillStyle=r.style.backgroundColor,t.fillRect(e-i,s+n,o,a);const c=r.querySelector(\"div\"),{x:l,y:h,width:d,height:u}=c.getBoundingClientRect();t.fillStyle=c.style.backgroundColor,t.fillRect(l-i,h+n,d,u)}}getUserDefinedROISet(){return this.roiSets.find((e=>!0===e.isUserDefined))}deleteUserDefinedROISet(){this.roiSets=this.roiSets.filter((e=>!0!==e.isUserDefined))}initializeUserDefinedROISet(){const e=new ku({name:\"user defined\",isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(e),e}async deleteRegionWithKey(e,t){t.querySelectorAll(Zy(e)).forEach((e=>e.remove()));0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}toJSON(){return this.roiSets.map((e=>e.toJSON()))}dispose(){this.browser.off(\"locuschange\",this.boundLocusChangeHandler);const e=this.browser.columnContainer.querySelectorAll(\".igv-roi-region\");for(let t of e)t.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let e of this.roiSets)e.dispose();for(let e of Object.keys(this))this[e]=void 0}}function Yy(){this.renderAllROISets()}function Xy(e,t,i){return`${e}-${t}-${i}`}function Zy(e){return`[data-region=\"${e}\"]`}function Jy(e){let t=e.split(\"-\"),i=parseInt(t.pop()),n=parseInt(t.pop()),r=t.join(\"-\");return{chr:r,start:n,end:i,locus:`${r}:${n}-${i}`,bedRecord:`${r}\\t${n}\\t${i}`}}class eA{constructor(e,t){this.name=e.name,this.featureSource=e.featureSource||Ad(e,t),this.color=e.color||_u}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}draw(e){const{context:t,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=e;if(!a)return;const c=n+o*i+1;for(let{start:e,end:o}of a){if(oc)break;const{x:a,width:l}=Iu(e,o,n,i);xo.fillRect(t,a,r,l,s,{fillStyle:this.color})}}}class tA{aliasRecordCache=new Map;constructor(e,t,i){(t=t||{}).url=e,this.reader=new Zh(t,i)}async preload(e){await this.reader.preload();for(let t of e)await this.search(t)}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async search(e){if(!this.aliasRecordCache.has(e)){const t=await this.reader.search(e);if(t)for(let e of Object.keys(t))\"start\"!==e&&\"end\"!==e&&this.aliasRecordCache.set(t[e],t)}return this.aliasRecordCache.get(e)}async getChromosomeNames(){return await this.reader.loadHeader(),Array.from(this.reader.chrNames)}}class iA{aliasRecordCache=new Map;constructor(e,t,i){this.aliasURL=e,this.config=t,this.genome=i}async preload(){return this.loadAliases()}getChromosomeName(e){return this.aliasRecordCache.has(e)?this.aliasRecordCache.get(e).chr:e}getChromosomeAlias(e,t){const i=this.aliasRecordCache.get(e);return i&&i[t]||e}async loadAliases(){const e=await Qs.loadString(this.aliasURL,Ua(this.config)),t=Dt(e),i=t[0];i.startsWith(\"#\")&&(this.headings=i.substring(1).split(\"\\t\").map((e=>e.trim())),this.altNameSets=this.headings.slice(1));const n=this.genome.chromosomeNames?new Set(this.genome.chromosomeNames):new Set;for(let e of t)if(!e.startsWith(\"#\")&&e.length>0){const t=e.split(\"\\t\");let i=t.find((e=>n.has(e)));i||(i=t[0]);const r={chr:i};for(let e=0;enew nA(e.start,e.end,e.name,e.gieStain)))}}class sA{cytobands=new Map;constructor(e,t){this.url=e,this.config=t}async getCytobands(e){return 0===this.cytobands.size&&await this.#I(),this.cytobands.get(e)}async#I(){let e,t;if(Ga(this.url)){const t=vs(this.url);e=\"\";const i=t.length;for(let n=0;n0){const e=e.substring(0,t);r[\"ncbi-gi\"]=e}}else{if(e.startsWith(\"hg\")||e.startsWith(\"GRCh\")||\"1kg_ref\"===e||\"b37\"===e)switch(n){case\"23\":r.ucsc=\"chrX\",t=!0;break;case\"24\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"23\",t=!0;break;case\"chrY\":r.ncbi=\"24\",t=!0}else if(e.startsWith(\"mm\")||e.startsWith(\"GRCm\")||e.startsWith(\"rheMac\"))switch(n){case\"21\":r.ucsc=\"chrX\",t=!0;break;case\"22\":r.ucsc=\"chrY\",t=!0;break;case\"chrX\":r.ncbi=\"21\",t=!0;break;case\"chrY\":r.ncbi=\"22\",t=!0}if(t)continue;\"chrM\"===n?r.ncbi=\"MT\":\"MT\"===n?r.ucsc=\"chrM\":n.toLowerCase().startsWith(\"chr\")?r.ncbi=n.substring(3):Number.isInteger(Number(n))&&(r.ucsc=\"chr\"+n)}}for(let e of i){for(let t of Object.values(e))this.aliasRecordCache.set(t,e);this.aliasRecordCache.set(e.chr.toLowerCase(),e),this.aliasRecordCache.set(e.chr.toUpperCase(),e)}}}search(e){return this.aliasRecordCache.get(e)}static getNCBIName(e){const t=e.split(\"\\\\|\");return t[t.length-1]}}class aA{#S;static async createGenome(e,t){const i=new aA(e,t);return await i.init(),i}constructor(e,t){this.config=e,this.browser=t,this.id=e.id||function(e){return void 0!==e.id?e.id:e.fastaURL&&Mt(e.fastaURL)&&!e.fastaURL.startsWith(\"data:\")?e.fastaURL:e.fastaURL&&e.fastaURL.name?e.fastaURL.name:\"\"}(e),this.name=e.name,this.nameSet=e.nameSet}async init(){const e=this.config;if(this.sequence=await Nc(e,this.browser),e.chromSizesURL?this.chromosomes=await async function(e){const t=new Map;let i;if(Ga(e)){let t=vs(e);i=\"\";for(let e of t)i+=String.fromCharCode(e)}else i=await Qs.load(e,{});const n=Fc(i);let r=0;for(let e of n){const i=e.split(\"\\t\");if(i.length>1){const e=Number.parseInt(i[1]);t.set(i[0],new lc(i[0],r++,e))}}return t}(e.chromSizesURL):this.chromosomes=this.sequence.chromosomes||new Map,this.chromosomes.size>0&&(this.chromosomeNames=Array.from(this.chromosomes.keys())),e.chromAliasBbURL?(this.chromAlias=new tA(e.chromAliasBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.chromAlias.getChromosomeNames())):e.aliasURL?this.chromAlias=new iA(e.aliasURL,Object.assign({},e),this):this.chromosomeNames&&(this.chromAlias=new oA(this.id,this.chromosomeNames)),e.cytobandBbURL)this.cytobandSource=new rA(e.cytobandBbURL,Object.assign({},e),this),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames());else if(e.cytobandURL&&(this.cytobandSource=new sA(e.cytobandURL,Object.assign({},e)),this.chromosomeNames||(this.chromosomeNames=await this.cytobandSource.getChromosomeNames()),0===this.chromosomes.size)){const e=await this.cytobandSource.getChromosomes();for(let t of e)this.chromosomes.set(e.name,e)}if(!1!==e.wholeGenomeView&&this.chromosomes.size>0&&(e.chromosomeOrder?Array.isArray(e.chromosomeOrder)?this.#S=e.chromosomeOrder:this.#S=e.chromosomeOrder.split(\",\").map((e=>e.trim())):this.#S=function(e){const t=[];let i,n=1;for(let r of e.values()){if(i){if(r.bpLength1,this.wholeGenomeView){const e=this.#S.reduce(((e,t)=>e+this.chromosomes.get(t).bpLength),0);this.chromosomes.set(\"all\",new lc(\"all\",0,e))}}get description(){return this.config.description||`${this.id}\\n${this.name}`}get infoURL(){return this.config.infoURL}showWholeGenomeView(){return this.wholeGenomeView}toJSON(){return Object.assign({},this.config,{tracks:void 0})}get initialLocus(){return this.config.locus?this.config.locus:this.getHomeChromosomeName()}getHomeChromosomeName(){return this.showWholeGenomeView()&&this.chromosomes.has(\"all\")?\"all\":this.chromosomeNames[0]}getChromosomeName(e){return this.chromAlias?this.chromAlias.getChromosomeName(e,this.chromosomes.keys()):e}getChromosomeDisplayName(e){return this.nameSet&&this.chromAlias&&this.chromAlias.getChromosomeAlias(e,this.nameSet)||e}getChromosome(e){return this.chromAlias&&(e=this.chromAlias.getChromosomeName(e)),this.chromosomes.get(e)}async loadChromosome(e){if(this.chromAlias){const t=await this.chromAlias.search(e);t&&(e=t.chr)}if(!this.chromosomes.has(e)){let t;const i=await this.sequence.getSequenceRecord(e);i&&(t=new lc(e,0,i.bpLength)),this.chromosomes.set(e,t)}return this.chromosomes.get(e)}async getAliasRecord(e){if(this.chromAlias)return this.chromAlias.search(e)}async getCytobands(e){if(this.cytobandSource){const t=this.getChromosomeName(e);return await this.cytobandSource.getCytobands(t)}}getChromosomes(){return this.chromosomes}get wgChromosomeNames(){return this.#S?this.#S.slice():void 0}get showChromosomeWidget(){return this.config.showChromosomeWidget}getGenomeCoordinate(e,t){var i=this.getCumulativeOffset(e);if(void 0!==i)return i+t}getChromosomeCoordinate(e){let t;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.#S){const r=this.cumulativeOffsets[n];if(r>e){return{chr:t,position:e-i}}t=n,i=r}return{chr:this.#S[this.#S.length-1],position:0}}getCumulativeOffset(e){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let e={},t=0;for(let i of this.#S){e[i]=Math.floor(t);t+=this.getChromosome(i).bpLength}return e}.call(this));const t=this.getChromosomeName(e);return this.cumulativeOffsets[t]}getGenomeLength(){if(!this.bpLength){let e=0;for(let t of this.#S){e+=this.chromosomes.get(t).bpLength}this.bpLength=e}return this.bpLength}async getSequence(e,t,i){return e=this.getChromosomeName(e),this.sequence.getSequence(e,t,i)}getSequenceInterval(e,t,i){return\"function\"==typeof this.sequence.getSequenceInterval?this.sequence.getSequenceInterval(e,t,i):void 0}}class cA{constructor(){this.clear()}clear(){this.phenotypeColors=new Map,this.snps=new Set,this.qtl=null}isEmpty(){return 0===this.phenotypeColors.size&&0===this.snps.size&&null===this.qtl}addSnp(e){e=e.toUpperCase(),this.snps.add(e)}addPhenotype(e){e=e.toUpperCase();const t=this.phenotypeColors.size;if(!this.phenotypeColors.has(e.toUpperCase())){const i=t0&&(e.phenotypes=Array.from(this.phenotypeColors.keys())),this.snps.size>0&&(e.snps=Array.from(this.snps)),this.qtl&&(e.qtl=this.qtl),e}static fromJSON(e){const t=new cA;if(e.phenotypes)for(let i of e.phenotypes)t.addPhenotype(i);if(e.snps)for(let i of e.snps)t.addSnp(i);return e.qtl&&(t.qtl=e.qtl),t}}const lA=[];lA.push(\"rgb(228,26,28)\"),lA.push(\"rgb(55,126,184)\"),lA.push(\"rgb(77,175,74)\"),lA.push(\"rgb(166,86,40)\"),lA.push(\"rgb(152,78,163)\"),lA.push(\"rgb(255,127,0)\"),lA.push(\"rgb(247,129,191)\"),lA.push(\"rgb(255,255,51)\"),lA.push(\"rgb(102,194,165)\"),lA.push(\"rgb(252,141,98)\"),lA.push(\"rgb(141, 160, 203)\"),lA.push(\"rgb(231, 138, 195)\"),lA.push(\"rgb(166, 216, 84)\"),lA.push(\"rgb(255, 217, 47)\"),lA.push(\"rgb(229, 196, 148)\"),lA.push(\"rgb( 141, 211, 199)\"),lA.push(\"rgb(255, 255, 179)\"),lA.push(\"rgb(190, 186, 218)\"),lA.push(\"rgb(251, 128, 114)\"),lA.push(\"rgb(128, 177, 211)\"),lA.push(\"rgb(253, 180, 98)\"),lA.push(\"rgb(179, 222, 105)\"),lA.push(\"rgb(252, 205, 229)\"),lA.push(\"rgb(188, 128, 189)\"),lA.push(\"rgb(204, 235, 197)\"),lA.push(\"rgb(255, 237, 111)\");class hA{constructor(t){this.parent=t,this.container=e({class:\"igv-ui-generic-dialog-container\"}),t.appendChild(this.container);const n=e({class:\"igv-ui-generic-dialog-header\"});this.container.appendChild(n),this.label=e({class:\"igv-ui-generic-dialog-one-liner\"}),this.container.appendChild(this.label),this.label.text=\"Unlabeled\",this.input_container=e({class:\"igv-ui-generic-dialog-input\"}),this.container.appendChild(this.input_container);let r='';this._input=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._input),r='',this._output=document.createRange().createContextualFragment(r).firstChild,this.input_container.appendChild(this._output);const s=e({class:\"igv-ui-generic-dialog-ok-cancel\"});this.container.appendChild(s),this.ok=e(),s.appendChild(this.ok),this.ok.textContent=\"OK\",this.cancel=e(),s.appendChild(this.cancel),this.cancel.textContent=\"Cancel\",i(this.container),this._input.addEventListener(\"input\",(()=>{const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this._output.value=`${e.toFixed(2)}`}),!1),this.ok.addEventListener(\"click\",(()=>{if(\"function\"==typeof this.callback){const e=parseFloat(this._input.value)/this._scaleFactor;this.callback(e),this.callback=void 0}this._input.value=void 0,i(this.container)}));const o=()=>{this._input.value=void 0,i(this.container)};this.cancel.addEventListener(\"click\",o),u(n,o),p(this.container,n)}get value(){return Ea.sanitize(this._input.value)}present(e,t){this.label.textContent=e.label,this._scaleFactor=e.scaleFactor;const[i,r,s]=[e.min,e.max,e.value].map((e=>Math.floor(this._scaleFactor*e).toString()));this._input.min=i,this._input.max=r,this._input.value=s;const o=parseFloat(s)/this._scaleFactor;this._output.value=`${o.toFixed(2)}`,this.callback=e.callback||e.click,n(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}class dA{qtlSelections=new cA;constructor(t,i){this.config=t,this.guid=s(),this.namespace=\".browser_\"+this.guid,this.parent=i;let n=i.shadowRoot;if(!n){n=i.attachShadow({mode:\"open\"});const e=new CSSStyleSheet;e.replaceSync('.igv-ui-dropdown {\\n cursor: default;\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div {\\n overflow-y: auto;\\n overflow-x: hidden;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div {\\n padding: 4px;\\n width: 100%;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: 1px;\\n background-color: white;\\n}\\n.igv-ui-dropdown > div > div:last-child {\\n border-bottom-color: transparent;\\n border-bottom-width: 0;\\n}\\n.igv-ui-dropdown > div > div:hover {\\n cursor: pointer;\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n\\n.igv-ui-popover {\\n cursor: default;\\n position: absolute;\\n z-index: 2048;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: 1px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n background-color: white;\\n}\\n.igv-ui-popover > div:first-child {\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-width: 0;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-popover > div:first-child > div:first-child {\\n margin-left: 4px;\\n}\\n.igv-ui-popover > div:first-child > div:last-child {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-popover > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-popover > div:last-child {\\n user-select: text;\\n overflow-y: auto;\\n overflow-x: hidden;\\n max-height: 400px;\\n max-width: 800px;\\n background-color: white;\\n border-bottom-width: 0;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-ui-popover > div:last-child > div {\\n margin-left: 4px;\\n margin-right: 4px;\\n min-width: 220px;\\n overflow-x: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n}\\n.igv-ui-popover > div:last-child > div > span {\\n font-weight: bolder;\\n}\\n.igv-ui-popover > div:last-child hr {\\n width: 100%;\\n}\\n\\n.igv-ui-alert-dialog-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n top: 50%;\\n left: 50%;\\n width: 400px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n outline: none;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 15px;\\n font-weight: 400;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:first-child {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\\n padding-left: 8px;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\\n -webkit-user-select: text;\\n -moz-user-select: text;\\n -ms-user-select: text;\\n user-select: text;\\n color: #373737;\\n width: 100%;\\n height: calc(100% - 24px - 64px);\\n overflow-y: scroll;\\n}\\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\\n margin: 16px;\\n width: auto;\\n height: auto;\\n overflow-wrap: break-word;\\n word-break: break-word;\\n background-color: white;\\n border: unset;\\n}\\n.igv-ui-alert-dialog-container > div:last-child {\\n width: 100%;\\n margin-bottom: 10px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div {\\n margin: unset;\\n width: 40px;\\n height: 30px;\\n line-height: 30px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n border-color: #2B81AF;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-alert-dialog-container > div:last-child div:hover {\\n cursor: pointer;\\n border-color: #25597f;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-color-swatch {\\n position: relative;\\n box-sizing: content-box;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: wrap;\\n justify-content: center;\\n align-items: center;\\n width: 32px;\\n height: 32px;\\n border-style: solid;\\n border-width: 2px;\\n border-color: white;\\n border-radius: 4px;\\n}\\n\\n.igv-ui-color-swatch:hover {\\n border-color: dimgray;\\n}\\n\\n.igv-ui-colorpicker-menu-close-button {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 32px;\\n margin-top: 4px;\\n margin-bottom: 4px;\\n padding-right: 8px;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa {\\n display: block;\\n margin-left: 4px;\\n margin-right: 4px;\\n color: #5f5f5f;\\n}\\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\\n.igv-ui-colorpicker-menu-close-button i.fa:active {\\n cursor: pointer;\\n color: #0f0f0f;\\n}\\n\\n.igv-ui-generic-dialog-container {\\n box-sizing: content-box;\\n position: fixed;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: fit-content;\\n padding-bottom: 16px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input > div {\\n width: fit-content;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input[type=range] {\\n width: 70%;\\n -webkit-appearance: none;\\n background: linear-gradient(90deg, white, black);\\n outline: none;\\n margin: 0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input output {\\n display: block;\\n height: 100%;\\n width: 20%;\\n font-size: 16px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n padding-top: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div {\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel > div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n\\n.igv-ui-generic-container {\\n box-sizing: content-box;\\n position: absolute;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ui-generic-container > div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-ui-generic-container > div:first-child > div {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-ui-dialog {\\n z-index: 2048;\\n position: fixed;\\n width: fit-content;\\n height: fit-content;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n background-color: white;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-ui-dialog .igv-ui-dialog-one-liner {\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n font-weight: bold;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\\n width: 100%;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\\n margin: 16px;\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\\n background-color: #5ea4e0;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\\n background-color: #c4c4c4;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\\n z-index: 2048;\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-panel-column {\\n display: flex;\\n flex-direction: column;\\n}\\n\\n.igv-ui-panel-row {\\n display: flex;\\n flex-direction: row;\\n}\\n\\n.igv-ui-textbox {\\n background-color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n display: flex;\\n justify-content: flex-start;\\n align-items: flex-start;\\n}\\n\\n.igv-ui-table {\\n background-color: white;\\n}\\n\\n.igv-ui-table thead {\\n position: sticky;\\n top: 0;\\n}\\n\\n.igv-ui-table th {\\n text-align: left;\\n}\\n\\n.igv-ui-table td {\\n padding-right: 20px;\\n}\\n\\n.igv-ui-table tr:hover {\\n background-color: lightblue;\\n}\\n\\n.igv-ui-center-fixed {\\n left: 50%;\\n top: 50%;\\n transform: translate(-50%, -50%);\\n}\\n\\n.igv-navbar {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n box-sizing: border-box;\\n width: 100%;\\n color: #444;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n line-height: 32px;\\n padding-left: 8px;\\n padding-right: 8px;\\n margin-top: 2px;\\n margin-bottom: 6px;\\n height: 32px;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: #f3f3f3;\\n}\\n.igv-navbar .igv-navbar-left-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 32px;\\n line-height: 32px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-logo {\\n width: 34px;\\n height: 32px;\\n margin-right: 8px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\\n height: 32px;\\n margin-left: 4px;\\n margin-right: 4px;\\n user-select: none;\\n line-height: 32px;\\n vertical-align: middle;\\n text-align: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n height: 100%;\\n width: 125px;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\\n display: block;\\n cursor: pointer;\\n width: 100px;\\n height: 75%;\\n outline: none;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n margin-left: 8px;\\n height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 240px;\\n height: 22px;\\n line-height: 22px;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\\n cursor: text;\\n width: 85%;\\n height: 22px;\\n line-height: 22px;\\n font-size: 12px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n text-align: left;\\n padding-left: 8px;\\n margin-right: 8px;\\n outline: none;\\n border-style: solid;\\n border-radius: 3px;\\n border-width: thin;\\n border-color: #bfbfbf;\\n background-color: white;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\\n cursor: pointer;\\n height: 16px;\\n width: 16px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\\n margin-left: 4px;\\n user-select: none;\\n}\\n.igv-navbar .igv-navbar-right-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\\n position: relative;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-hidden {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n height: 100%;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\\n color: #737373;\\n font-size: 18px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\\n display: block;\\n height: fit-content;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\\n display: block;\\n width: 125px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\\n color: #737373;\\n font-size: 18px;\\n height: 32px;\\n line-height: 32px;\\n margin-left: 8px;\\n user-select: none;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\\n cursor: pointer;\\n margin-left: unset;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\\n height: 20px;\\n width: 20px;\\n margin-left: unset;\\n margin-right: 4px;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\\n height: 20px;\\n width: 20px;\\n margin-left: 4px;\\n margin-right: unset;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\\n width: 0;\\n height: 0;\\n display: none;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\\n display: block;\\n}\\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\\n display: none;\\n}\\n\\n.igv-navbar-button {\\n display: block;\\n box-sizing: unset;\\n padding-left: 6px;\\n padding-right: 6px;\\n height: 18px;\\n text-transform: capitalize;\\n user-select: none;\\n line-height: 18px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 11px;\\n font-weight: 200;\\n color: #737373;\\n background-color: #f3f3f3;\\n border-color: #737373;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 6px;\\n}\\n\\n.igv-navbar-button:hover {\\n cursor: pointer;\\n}\\n\\n.igv-navbar-button-clicked {\\n color: white;\\n background-color: #737373;\\n}\\n\\n.igv-navbar-icon-button {\\n cursor: pointer;\\n position: relative;\\n width: 24px;\\n height: 24px;\\n margin-left: 4px;\\n margin-right: 4px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:first-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: -18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-icon-button > div:last-child {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 18px;\\n width: 24px;\\n height: 24px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n.igv-navbar-text-button {\\n cursor: pointer;\\n position: relative;\\n margin-left: 2px;\\n margin-right: 2px;\\n border: none;\\n display: flex;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-navbar-text-button > div:nth-child(2) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 0;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n.igv-navbar-text-button > div:nth-child(3) {\\n z-index: 512;\\n position: absolute;\\n top: 36px;\\n left: 42px;\\n width: 38px;\\n height: 18px;\\n border: none;\\n background-size: contain;\\n background-repeat: no-repeat;\\n background-position: center;\\n}\\n\\n#igv-text-button-label {\\n text-anchor: middle;\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-inactive rect {\\n stroke: #737373;\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-inactive text {\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-inactive tspan {\\n dominant-baseline: middle;\\n}\\n\\n.igv-navbar-text-button-svg-hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n.igv-navbar-text-button-svg-hover text {\\n fill: white;\\n}\\n.igv-navbar-text-button-svg-hover tspan {\\n dominant-baseline: middle;\\n}\\n\\n#igv-save-svg-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-svg-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-svg-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-svg-group:hover text {\\n fill: white;\\n}\\n\\n#igv-save-png-group rect {\\n stroke: #737373;\\n fill: white;\\n}\\n#igv-save-png-group text {\\n fill: #737373;\\n}\\n\\n#igv-save-png-group:hover rect {\\n stroke: #737373;\\n fill: #737373;\\n}\\n#igv-save-png-group:hover text {\\n fill: white;\\n}\\n\\n.igv-zoom-in-notice-container {\\n z-index: 256;\\n position: absolute;\\n top: 8px;\\n left: 50%;\\n transform: translate(-50%, 0%);\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n background-color: white;\\n}\\n.igv-zoom-in-notice-container > div {\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-top: 2px;\\n padding-bottom: 2px;\\n width: 100%;\\n height: 100%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: #3f3f3f;\\n}\\n\\n.igv-zoom-in-notice {\\n position: absolute;\\n top: 10px;\\n left: 50%;\\n}\\n.igv-zoom-in-notice div {\\n position: relative;\\n left: -50%;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #3f3f3f;\\n background-color: rgba(255, 255, 255, 0.51);\\n z-index: 64;\\n}\\n\\n.igv-container-spinner {\\n position: absolute;\\n top: 90%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n z-index: 1024;\\n width: 24px;\\n height: 24px;\\n pointer-events: none;\\n color: #737373;\\n}\\n\\n.igv-multi-locus-close-button {\\n position: absolute;\\n top: 2px;\\n right: 0;\\n padding-left: 2px;\\n padding-right: 2px;\\n width: 12px;\\n height: 12px;\\n color: #666666;\\n background-color: white;\\n z-index: 1000;\\n}\\n.igv-multi-locus-close-button > svg {\\n vertical-align: top;\\n}\\n\\n.igv-multi-locus-close-button:hover {\\n cursor: pointer;\\n color: #434343;\\n}\\n\\n.igv-multi-locus-ruler-label {\\n z-index: 64;\\n position: absolute;\\n top: 2px;\\n left: 0;\\n width: 100%;\\n height: 12px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label > div {\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n color: rgb(16, 16, 16);\\n background-color: white;\\n}\\n.igv-multi-locus-ruler-label > div {\\n cursor: pointer;\\n}\\n\\n.igv-multi-locus-ruler-label-square-dot {\\n z-index: 64;\\n position: absolute;\\n left: 50%;\\n top: 5%;\\n transform: translate(-50%, 0%);\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\\n width: 14px;\\n height: 14px;\\n}\\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\\n margin-left: 16px;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n color: rgb(16, 16, 16);\\n}\\n\\n.igv-ruler-sweeper {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 26px;\\n bottom: 0;\\n left: 0;\\n width: 0;\\n z-index: 99999;\\n background-color: rgba(68, 134, 247, 0.25);\\n}\\n\\n.igv-ruler-tooltip {\\n pointer-events: none;\\n z-index: 128;\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 1px;\\n height: 32px;\\n background-color: transparent;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-ruler-tooltip > div {\\n pointer-events: none;\\n width: 128px;\\n height: auto;\\n padding: 1px;\\n color: #373737;\\n font-size: 10px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n background-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-color: #373737;\\n}\\n\\n.igv-track-label {\\n position: absolute;\\n left: 8px;\\n top: 8px;\\n width: auto;\\n height: auto;\\n max-width: 50%;\\n padding-left: 4px;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n text-align: center;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-color: #444;\\n border-radius: 2px;\\n border-style: solid;\\n border-width: thin;\\n background-color: white;\\n z-index: 128;\\n cursor: pointer;\\n}\\n\\n.igv-track-label:hover,\\n.igv-track-label:focus,\\n.igv-track-label:active {\\n background-color: #e8e8e8;\\n}\\n\\n.igv-track-label-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-top: 4px;\\n}\\n\\n.igv-center-line {\\n display: none;\\n pointer-events: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n transform: translateX(-50%);\\n z-index: 8;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n border-left-style: dashed;\\n border-left-width: thin;\\n border-right-style: dashed;\\n border-right-width: thin;\\n}\\n\\n.igv-center-line-wide {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(127, 127, 127, 0.51);\\n}\\n\\n.igv-center-line-thin {\\n background-color: rgba(0, 0, 0, 0);\\n border-left-color: rgba(127, 127, 127, 0.51);\\n border-right-color: rgba(0, 0, 0, 0);\\n}\\n\\n.igv-cursor-guide-horizontal {\\n display: none;\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n left: 0;\\n right: 0;\\n top: 50%;\\n height: 1px;\\n z-index: 32;\\n margin-left: 50px;\\n margin-right: 54px;\\n border-top-style: dotted;\\n border-top-width: thin;\\n border-top-color: rgba(127, 127, 127, 0.76);\\n}\\n\\n.igv-cursor-guide-vertical {\\n pointer-events: none;\\n user-select: none;\\n -moz-user-select: none;\\n -webkit-user-select: none;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n left: 50%;\\n width: 1px;\\n z-index: 32;\\n border-left-style: dotted;\\n border-left-width: thin;\\n border-left-color: rgba(127, 127, 127, 0.76);\\n display: none;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-generic-dialog-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: 300px;\\n height: 200px;\\n border-color: #7F7F7F;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n z-index: 2048;\\n background-color: white;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\\n color: #373737;\\n width: 95%;\\n height: 24px;\\n line-height: 24px;\\n text-align: left;\\n margin-top: 8px;\\n padding-left: 8px;\\n overflow-wrap: break-word;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\\n margin-top: 8px;\\n width: 95%;\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n padding-left: 8px;\\n background-color: white;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\\n width: 30%;\\n height: 100%;\\n font-size: 16px;\\n text-align: right;\\n padding-right: 8px;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\\n width: 50%;\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input {\\n margin-top: 8px;\\n width: calc(100% - 16px);\\n height: 24px;\\n color: #373737;\\n line-height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n display: block;\\n height: 100%;\\n width: 100%;\\n padding-left: 4px;\\n font-family: \"Open Sans\", sans-serif;\\n font-weight: 400;\\n color: #373737;\\n text-align: left;\\n outline: none;\\n border-style: solid;\\n border-width: thin;\\n border-color: #7F7F7F;\\n background-color: white;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-input input {\\n font-size: 16px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\\n width: 100%;\\n height: 28px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\\n margin-top: 32px;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 14px;\\n font-weight: 400;\\n width: 75px;\\n height: 28px;\\n line-height: 28px;\\n text-align: center;\\n border-color: transparent;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 2px;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\\n margin-left: 32px;\\n margin-right: 0;\\n background-color: #5ea4e0;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\\n margin-left: 0;\\n margin-right: 32px;\\n background-color: #c4c4c4;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\\n cursor: pointer;\\n background-color: #3b5c7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\\n cursor: pointer;\\n background-color: #7f7f7f;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok {\\n width: 100%;\\n height: 36px;\\n margin-top: 32px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\\n width: 98px;\\n height: 36px;\\n line-height: 36px;\\n text-align: center;\\n color: white;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n border-color: white;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 4px;\\n background-color: #2B81AF;\\n}\\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\\n cursor: pointer;\\n background-color: #25597f;\\n}\\n\\n.igv-generic-container {\\n position: absolute;\\n top: 0;\\n left: 0;\\n z-index: 2048;\\n background-color: white;\\n cursor: pointer;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: wrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-generic-container div:first-child {\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n height: 24px;\\n width: 100%;\\n background-color: #dddddd;\\n}\\n.igv-generic-container div:first-child i {\\n display: block;\\n color: #5f5f5f;\\n cursor: pointer;\\n width: 14px;\\n height: 14px;\\n margin-right: 8px;\\n margin-bottom: 4px;\\n}\\n\\n.igv-menu-popup {\\n position: absolute;\\n top: 0;\\n left: 0;\\n width: max-content;\\n max-width: 400px;\\n z-index: 512;\\n cursor: pointer;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background: white;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-end;\\n text-align: left;\\n}\\n.igv-menu-popup > div:not(:first-child) {\\n width: 100%;\\n}\\n.igv-menu-popup > div:not(:first-child) > div {\\n background: white;\\n}\\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\\n padding-left: 4px;\\n padding-right: 4px;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:last-child {\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-menu-popup > div:not(:first-child) > div:hover {\\n background: #efefef;\\n}\\n\\n.igv-menu-popup-shim {\\n padding-left: 8px;\\n padding-right: 8px;\\n padding-bottom: 1px;\\n padding-top: 1px;\\n}\\n\\n.igv-menu-popup-header {\\n position: relative;\\n width: 100%;\\n height: 24px;\\n cursor: move;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-menu-popup-header div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-menu-popup-header div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n.igv-menu-popup-check-container {\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n width: 100%;\\n height: 20px;\\n margin-right: 4px;\\n background-color: transparent;\\n}\\n.igv-menu-popup-check-container div {\\n padding-top: 2px;\\n padding-left: 8px;\\n}\\n.igv-menu-popup-check-container div:first-child {\\n position: relative;\\n width: 12px;\\n height: 12px;\\n}\\n.igv-menu-popup-check-container div:first-child svg {\\n position: absolute;\\n width: 12px;\\n height: 12px;\\n}\\n\\n.igv-user-feedback {\\n position: fixed;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 512px;\\n height: 360px;\\n z-index: 2048;\\n background-color: white;\\n border-color: #a2a2a2;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: medium;\\n font-weight: 400;\\n color: #444;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n}\\n.igv-user-feedback div:first-child {\\n position: relative;\\n height: 24px;\\n width: 100%;\\n background-color: white;\\n border-bottom-color: #a2a2a2;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-user-feedback div:first-child div {\\n position: absolute;\\n top: 2px;\\n width: 16px;\\n height: 16px;\\n background-color: transparent;\\n}\\n.igv-user-feedback div:first-child div:first-child {\\n left: 8px;\\n}\\n.igv-user-feedback div:first-child div:last-child {\\n cursor: pointer;\\n right: 8px;\\n}\\n.igv-user-feedback div:last-child {\\n width: 100%;\\n height: calc(100% - 24px);\\n border-width: 0;\\n}\\n.igv-user-feedback div:last-child div {\\n width: auto;\\n height: auto;\\n margin: 8px;\\n}\\n\\n.igv-loading-spinner-container {\\n z-index: 1024;\\n position: absolute;\\n top: 50%;\\n left: 50%;\\n transform: translate(-50%, -50%);\\n width: 32px;\\n height: 32px;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: center;\\n align-items: center;\\n}\\n.igv-loading-spinner-container > div {\\n box-sizing: border-box;\\n width: 100%;\\n height: 100%;\\n border-radius: 50%;\\n border: 4px solid rgba(128, 128, 128, 0.5);\\n border-top-color: rgb(255, 255, 255);\\n animation: spin 1s ease-in-out infinite;\\n -webkit-animation: spin 1s ease-in-out infinite;\\n}\\n\\n@keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n@-webkit-keyframes spin {\\n to {\\n -webkit-transform: rotate(360deg);\\n transform: rotate(360deg);\\n }\\n}\\n.igv-roi-menu {\\n position: absolute;\\n z-index: 512;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: small;\\n font-weight: 400;\\n color: #4b4b4b;\\n background-color: white;\\n width: 192px;\\n border-radius: 4px;\\n border-color: #7F7F7F;\\n border-style: solid;\\n border-width: thin;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-menu > div:first-child {\\n height: 24px;\\n border-top-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-color: #7F7F7F;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: flex-end;\\n align-items: center;\\n}\\n.igv-roi-menu > div:first-child > div {\\n margin-right: 4px;\\n height: 12px;\\n width: 12px;\\n color: #7F7F7F;\\n}\\n.igv-roi-menu > div:first-child > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-menu > div:last-child {\\n background-color: white;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-color: transparent;\\n border-bottom-style: solid;\\n border-bottom-width: 0;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n text-align: start;\\n vertical-align: middle;\\n}\\n.igv-roi-menu > div:last-child > div {\\n height: 24px;\\n padding-left: 4px;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n border-bottom-color: #7f7f7f;\\n}\\n.igv-roi-menu > div:last-child > div:not(:first-child):hover {\\n cursor: pointer;\\n background-color: rgba(127, 127, 127, 0.1);\\n}\\n.igv-roi-menu > div:last-child div:first-child {\\n font-style: italic;\\n text-align: center;\\n padding-right: 4px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n}\\n.igv-roi-menu > div:last-child > div:last-child {\\n border-bottom-width: 0;\\n border-bottom-color: transparent;\\n}\\n\\n.igv-roi-placeholder {\\n font-style: normal;\\n color: rgba(75, 75, 75, 0.6);\\n}\\n\\n.igv-roi-table {\\n position: absolute;\\n z-index: 1024;\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n resize: both;\\n overflow: hidden;\\n width: min-content;\\n max-width: 1600px;\\n border-color: #7f7f7f;\\n border-radius: 4px;\\n border-style: solid;\\n border-width: thin;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 12px;\\n font-weight: 400;\\n background-color: white;\\n cursor: default;\\n}\\n.igv-roi-table > div {\\n height: 24px;\\n font-size: 14px;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n}\\n.igv-roi-table > div:first-child {\\n border-color: transparent;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-top-width: 0;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n background-color: #eee;\\n cursor: move;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-between;\\n align-items: center;\\n}\\n.igv-roi-table > div:first-child > div:first-child {\\n text-align: center;\\n white-space: nowrap;\\n text-overflow: ellipsis;\\n overflow: hidden;\\n margin-left: 4px;\\n margin-right: 4px;\\n width: calc(100% - 4px - 12px);\\n}\\n.igv-roi-table > div:first-child > div:last-child {\\n margin-right: 4px;\\n margin-bottom: 2px;\\n height: 12px;\\n width: 12px;\\n color: #7f7f7f;\\n}\\n.igv-roi-table > div:first-child > div:last-child > svg {\\n display: block;\\n}\\n.igv-roi-table > div:first-child > div:last-child:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n.igv-roi-table > .igv-roi-table-description {\\n padding: 4px;\\n margin-left: 4px;\\n word-break: break-all;\\n overflow-y: auto;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-goto-explainer {\\n margin-top: 5px;\\n margin-left: 4px;\\n color: #7F7F7F;\\n font-style: italic;\\n height: 24px;\\n border-top: solid lightgray;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n padding-right: 16px;\\n background-color: white;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: #7f7f7f;\\n border-bottom-style: solid;\\n border-bottom-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: #7f7f7f;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container {\\n display: flex;\\n flex-flow: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n overflow: auto;\\n height: 360px;\\n flex: 1 1 auto;\\n background-color: transparent;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\\n height: 24px;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\\n font-size: 14px;\\n vertical-align: middle;\\n line-height: 24px;\\n text-align: left;\\n margin-left: 4px;\\n height: 24px;\\n white-space: nowrap;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n border-right-color: transparent;\\n border-right-style: solid;\\n border-right-width: thin;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\\n border-right: unset;\\n}\\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\\n background-color: rgba(0, 0, 0, 0.04);\\n}\\n.igv-roi-table > div:last-child {\\n min-height: 32px;\\n height: 32px;\\n line-height: 32px;\\n border-top-color: #7f7f7f;\\n border-top-style: solid;\\n border-top-width: thin;\\n border-bottom-color: transparent;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n border-bottom-width: 0;\\n background-color: #eee;\\n display: flex;\\n flex-flow: row;\\n flex-wrap: nowrap;\\n justify-content: space-around;\\n align-items: center;\\n}\\n\\n.igv-roi-table-row-selected {\\n background-color: rgba(0, 0, 0, 0.125);\\n}\\n\\n.igv-roi-table-button {\\n cursor: pointer;\\n height: 20px;\\n user-select: none;\\n line-height: 20px;\\n text-align: center;\\n vertical-align: middle;\\n font-family: \"Open Sans\", sans-serif;\\n font-size: 13px;\\n font-weight: 400;\\n color: black;\\n padding-left: 6px;\\n padding-right: 6px;\\n background-color: rgb(239, 239, 239);\\n border-color: black;\\n border-style: solid;\\n border-width: thin;\\n border-radius: 3px;\\n}\\n\\n.igv-roi-table-button:hover {\\n font-weight: 400;\\n background-color: rgba(0, 0, 0, 0.13);\\n}\\n\\n.igv-roi-region {\\n z-index: 64;\\n position: absolute;\\n top: 0;\\n bottom: 0;\\n pointer-events: none;\\n overflow: visible;\\n margin-top: 66px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n}\\n.igv-roi-region > div {\\n position: relative;\\n width: 100%;\\n height: 8px;\\n pointer-events: auto;\\n}\\n\\n.igv-roi-menu-row {\\n height: 24px;\\n padding-left: 8px;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n line-height: 24px;\\n background-color: white;\\n}\\n\\n.igv-roi-menu-row-edit-description {\\n width: -webkit-fill-available;\\n font-size: small;\\n text-align: start;\\n vertical-align: middle;\\n background-color: white;\\n padding-left: 4px;\\n padding-right: 4px;\\n padding-bottom: 4px;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: stretch;\\n align-items: stretch;\\n}\\n.igv-roi-menu-row-edit-description > label {\\n margin-left: 2px;\\n margin-bottom: 0;\\n display: block;\\n width: -webkit-fill-available;\\n}\\n.igv-roi-menu-row-edit-description > input {\\n display: block;\\n margin-left: 2px;\\n margin-right: 2px;\\n margin-bottom: 1px;\\n width: -webkit-fill-available;\\n}\\n\\n.igv-container {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n padding-top: 4px;\\n user-select: none;\\n -webkit-user-select: none;\\n -ms-user-select: none;\\n min-height: 160px;\\n}\\n\\n.igv-viewport {\\n position: relative;\\n margin-top: 5px;\\n line-height: 1;\\n overflow-x: hidden;\\n overflow-y: hidden;\\n}\\n\\n.igv-viewport-content {\\n position: relative;\\n width: 100%;\\n}\\n.igv-viewport-content > canvas {\\n position: relative;\\n display: block;\\n}\\n\\n.igv-column-container {\\n position: relative;\\n display: flex;\\n flex-direction: row;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: stretch;\\n width: 100%;\\n}\\n\\n.igv-column-shim {\\n width: 1px;\\n margin-left: 2px;\\n margin-right: 2px;\\n background-color: #545453;\\n}\\n\\n.igv-axis-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 50px;\\n}\\n.igv-axis-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n}\\n.igv-axis-column > div > div {\\n z-index: 512;\\n position: absolute;\\n top: 8px;\\n left: 8px;\\n width: fit-content;\\n height: fit-content;\\n background-color: transparent;\\n display: grid;\\n align-items: start;\\n justify-items: center;\\n}\\n.igv-axis-column > div > div > input {\\n display: block;\\n margin: unset;\\n cursor: pointer;\\n}\\n\\n.igv-column {\\n position: relative;\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-info-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-sample-name-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n}\\n\\n.igv-scrollbar-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div {\\n position: relative;\\n margin-top: 5px;\\n width: 14px;\\n}\\n.igv-scrollbar-column > div > div {\\n cursor: pointer;\\n position: absolute;\\n top: 0;\\n left: 2px;\\n width: 8px;\\n border-width: 1px;\\n border-style: solid;\\n border-color: #c4c4c4;\\n border-top-left-radius: 4px;\\n border-top-right-radius: 4px;\\n border-bottom-left-radius: 4px;\\n border-bottom-right-radius: 4px;\\n}\\n.igv-scrollbar-column > div > div:hover {\\n background-color: #c4c4c4;\\n}\\n\\n.igv-track-drag-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 12px;\\n background-color: white;\\n}\\n.igv-track-drag-column > .igv-track-drag-handle {\\n z-index: 512;\\n position: relative;\\n cursor: pointer;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n border-top-right-radius: 6px;\\n border-bottom-right-radius: 6px;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-color {\\n background-color: #c4c4c4;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-hover-color {\\n background-color: #787878;\\n}\\n.igv-track-drag-column .igv-track-drag-handle-selected-color {\\n background-color: #0963fa;\\n}\\n.igv-track-drag-column > .igv-track-drag-shim {\\n position: relative;\\n margin-top: 5px;\\n width: 100%;\\n border-style: solid;\\n border-width: 0;\\n}\\n\\n.igv-gear-menu-column {\\n position: relative;\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: flex-start;\\n box-sizing: border-box;\\n height: 100%;\\n width: 28px;\\n}\\n.igv-gear-menu-column > div {\\n display: flex;\\n flex-direction: column;\\n flex-wrap: nowrap;\\n justify-content: flex-start;\\n align-items: center;\\n margin-top: 5px;\\n width: 100%;\\n background: white;\\n}\\n.igv-gear-menu-column > div > div {\\n position: relative;\\n margin-top: 4px;\\n width: 16px;\\n height: 16px;\\n color: #7F7F7F;\\n}\\n.igv-gear-menu-column > div > div:hover {\\n cursor: pointer;\\n color: #444;\\n}\\n\\n/*# sourceMappingURL=igv.css.map */\\n'),n.adoptedStyleSheets=[e]}if(this.root=e({class:\"igv-container\"}),n.appendChild(this.root),this.spinner=e({class:\"igv-loading-spinner-container\"}),this.root.appendChild(this.spinner),this.spinner.appendChild(e()),this.spinner.style.width=\"64px\",this.spinner.style.height=\"64px\",this.stopSpinner(),this.alert=new La(this.root),this.columnContainer=e({class:\"igv-column-container\"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Xu(this.columnContainer),this.menuUtils=new bo(this),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:\"rgb(0,0,150)\",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},t.listeners)for(let e of Object.keys(t.listeners))this.on(e,t.listeners[e]);this.on(\"trackremoved\",(()=>{0===this.findTracks((e=>\"function\"==typeof e.getSamples)).length&&(this.sampleInfoControl.setButtonVisibility(!1),this.sampleNameViewportWidth=void 0,this.showSampleNames=!1,this.sampleNameControl.setState(this.showSampleNames),this.sampleNameControl.hide(),this.layoutChange())})),this.on(\"didchangecolumnlayout\",(()=>{if(yu.length>0){const e=yu.length;for(let t=0;t1}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let e of this.referenceFrameList)if(\"all\"===e.chr.toLowerCase())return!0;return!1}currentLoci(){const e=e=>`${e.chr}:${e.start+1}-${e.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?\"\":1===this.referenceFrameList.length?e(this.referenceFrameList[0]):this.referenceFrameList.map((t=>e(t)))}toSVG(){const{x:e,y:t,width:i,height:n}=this.columnContainer.getBoundingClientRect(),r=new lu({width:i,height:n,backdropColor:\"white\",multiLocusGap:0,viewbox:{x:0,y:0,width:i,height:n}}),s={deltaX:0,deltaY:-t};for(let e of this.trackViews)e.renderSVGContext(r,s);return s.deltaX=e,this.roiManager.renderSVGContext(this.columnContainer,r,s),r.getSerializedSvg(!0)}saveSVGtoFile(e,t){let i=this.toSVG();if(t){const e=document.createElement(\"svg\");e.innerHTML=i,t.append(e),t.appendChild(e)}const n=e||\"igvjs.svg\",r=URL.createObjectURL(new Blob([i],{type:\"application/octet-stream\"}));Pt(n,r),URL.revokeObjectURL(r)}savePNGtoFile(e){const t=this.toSVG(),i=new Blob([t],{type:\"image/svg+xml\"}),n=URL.createObjectURL(i),r=document.createElement(\"img\");r.addEventListener(\"load\",(()=>{const t=this.columnContainer.getBoundingClientRect(),i=window.devicePixelRatio,s=t.width*i,o=t.height*i,a=document.createElement(\"canvas\");a.width=s,a.height=o;const c=a.getContext(\"2d\");c.scale(i,i),c.drawImage(r,0,0);const l=a.toDataURL(\"image/png\");Pt(e=e||\"igvjs.png\",l),URL.revokeObjectURL(n)})),r.src=n}async loadSession(e){let t;return this.sampleInfo.initialize(),this.roiSets=[],t=e.url||e.file?await dA.loadSessionFile(e):e,this.loadSessionObject(t)}static async loadSessionFile(e){const t=e.url||e.file;let i;if(e.url&&Mt(e.url)&&(e.url.startsWith(\"blob:\")||e.url.startsWith(\"data:\"))){const t=dA.uncompressSession(e.url);i=JSON.parse(t)}else{let n=e.filename;if(n||(n=e.url?await ja(e.url):e.file.name),n.endsWith(\".xml\")){const e=mu.KNOWN_GENOMES,n=await Qs.loadString(t);i=new by(n,e)}else if(n.endsWith(\"hub.txt\")){i={reference:(await du.loadHub(t,e)).getGenomeConfig()}}else{if(!n.endsWith(\".json\"))throw Error(\"Unrecognized session file format:\"+n);i=await Qs.loadJson(t)}}return bA(i)}async loadSessionObject(e){this.cleanHouseForSession(),this.config=e,e.browsers&&(e=await async function(e){const t=e.browsers[0],i={},n=new Mf({url:t.url});await n.readHeaderAndFooter(),i.sampleNameViewportWidth=20,i.genome=\"hg38\";const r=t.state.split(\",\"),s=n.bpResolutions[Number.parseInt(r[2])],o=Number.parseInt(r[0]),a=Math.floor(Number.parseFloat(r[3])*s),c=a+Math.floor(1700*s);return i.locus=`${n.chromosomes[o].name}:${a}-${c}`,i.tracks=(t.tracks||[]).filter((e=>!(\"refgene\"===e.format||\"cellType\"===e.name))),i.tracks.push({type:\"shoebox\",url:t.url,name:t.name,colorScale:t.colorScale,_hicFile:n}),i}(e)),this.navbar.sampleInfoControl.setButtonVisibility(!1),this.showSampleNames=e.showSampleNames||!1,this.navbar.sampleNameControl.setState(!0===this.showSampleNames),e.sampleNameViewportWidth&&(this.sampleNameViewportWidth=e.sampleNameViewportWidth),$a(this.columnContainer,\"igv-axis-column\"),$a(this.columnContainer,\"igv-sample-info-column\"),$a(this.columnContainer,\"igv-sample-name-column\"),$a(this.columnContainer,\"igv-scrollbar-column\"),$a(this.columnContainer,\"igv-track-drag-column\"),$a(this.columnContainer,\"igv-gear-menu-column\");const t=e.reference||e.genome;if(!t)return void console.warn(\"No genome or reference object specified\");const i=Mt(t)?await mu.expandReference(this.alert,t):t;if(await this.loadReference(i,i.locus||e.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==e.showIdeogram){const e=new hy(this);e.id=\"ideogram\";const t=new hf(this,this.columnContainer,e);this.trackViews.push(t)}if(!1!==e.showRuler){const e=new hf(this,this.columnContainer,new Wu(this));this.trackViews.push(e)}e.qtlSelections&&(this.qtlSelections=cA.fromJSON(e.qtlSelections)),this.roiManager.clearROIs(),e.roi?this.roiManager.loadROI(e.roi):await this.roiManager.reset();const n=[];if(e.sampleinfo)for(const t of e.sampleinfo)t.file?n.push(t.file):this.loadSampleInfo(t);const r=i.tracks||[],s=e.tracks?r.concat(e.tracks):r;0===s.filter((e=>\"sequence\"===e.type&&!e.url&&!e.fastaURL)).length&&s.push({type:\"sequence\",order:Wd,removable:!1});const o=s.filter((e=>void 0!==e.file)).map((({file:e})=>e)),a=s.filter((e=>void 0!==e.indexFile)).map((({indexFile:e})=>e));a.length>0&&o.push(...a),n.length>0&&o.push(...n),o.length>0&&alert(`Local files cannot be loaded automatically.\\nThis session contains references to these local files:\\n${o.map((e=>` ${e}`)).join(\"\\n\")}`);const c=s.filter((e=>void 0===e.file));let l=1;for(let e of c)void 0===e.order&&(e.order=l++);await this.loadTrackList(c);for(let e of this.trackViews.filter((e=>\"ruler\"===e.track.type||\"ideogram\"===e.track.type)))await e.updateViews();return this.trackViews.some((e=>e.track.selected))&&this.navbar.setEnableTrackSelection(!0),this.updateUIWithReferenceFrameList(),this.updateLocusSearchWidget(),s}cleanHouseForSession(){for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-info-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column\").forEach((e=>e.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}async loadReference(e,t){let i;this.removeAllTracks(),this.roiManager.clearROIs(),this.navbar.setEnableTrackSelection(!1),i=e.gbkURL?await wd(e.gbkURL):await aA.createGenome(e,this);const n=void 0===this.genome||this.genome.id!==i.id;this.genome=i,this.navbar.updateGenome(i);let r=t||i.initialLocus;Array.isArray(r)&&(r=r.join(\" \"));if(!await this.search(r,!0))throw new Error(`Cannot set initial locus ${r}`);if(n){let t;if(e.hubURL){t=(await du.loadHub(e.hubURL)).getGroupedTrackConfigurations()}this.fireEvent(\"genomechange\",[{genome:i,trackConfigurations:t}]),this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)})}}async loadGenome(e){let t;e.genarkAccession&&(e.url=hu(e.genarkAccession)),e.url&&(Mt(e.url)&&e.url.endsWith(\"/hub.txt\")?(e.hubURL=e.url,delete e.url):\"gbk\"===function(e){let t;if(e instanceof File)t=e.name;else{if(\"string\"!=typeof e)throw new Error(\"Input must be a File object or a URL string\");t=e}const i=t.split(\".\").pop();return i.split(\"?\")[0]}(e.url)&&(e.gbkURL=e.url,delete e.url));if(e.hubURL||e.url&&Mt(e.url)&&e.url.endsWith(\"/hub.txt\")){t=(await du.loadHub(e.hubURL||e.url,e)).getGenomeConfig()}else t=Mt(e)||!(e.url||e.fastaURL||e.twoBitURL||e.gbkURL)?await mu.expandReference(this.alert,e):e;let i;await this.loadReference(t),i=t.gbkURL||\"gbk\"===t.format?[{name:\"Annotations\",format:\"gbk\",url:t.gbkURL}]:t.tracks||[];return 0===i.filter((e=>\"sequence\"===e.type)).length&&i.push({type:\"sequence\",order:Wd}),await this.loadTrackList(i),await this.updateViews(),this.genome}async loadTrackHub(e){const t=bA((await du.loadHub(e.url,e)).getGenomeConfig());return this.loadGenome(t)}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.isMultiLocusWholeGenomeView()||mu.isWholeGenomeView(e[0].chr),this.navbar.navbarDidResize(),mA(this.trackViews,this.doShowTrackLabels),this.doShowCenterLine&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.centerLineButton.boundMouseClickHandler(),this.doShowCursorGuide&&mu.isWholeGenomeView(e[0].chr)&&this.navbar.cursorGuideButton.boundMouseClickHandler(),this.setCenterLineAndCenterLineButtonVisibility(mu.isWholeGenomeView(e[0].chr))}setCenterLineAndCenterLineButtonVisibility(e){e?this.navbar.centerLineButton.setVisibility(!1):this.navbar.centerLineButton.setVisibility(this.config.showCenterGuideButton);for(let t of this.centerLineList)e?this.setCenterLineVisibility(!e):this.setCenterLineVisibility(this.doShowCenterLine)}setTrackLabelVisibility(e){mA(this.trackViews,e)}setROITableVisibility(e){!0===e?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)!0===e?(t.show(),t.repaint()):t.hide()}async loadTrackList(e){let t=0;for(let i of e)void 0===i.order&&(i.order=t++);const i=[];for(let t of e)i.push(this._loadTrack(t));const n=await Promise.all(i);return this.trackViews.filter((function(e){return e.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadTrack(e){e.sync=!1!==e.sync;const t=this._loadTrack(e);return t&&e.autoscaleGroup&&(await t,this.updateViews()),t}async _loadTrack(e){Mt(e)&&(e=JSON.parse(e));try{if(e.hidden){const t=Ad(e,this.genome);return void await t.getFeatures({chr:\"1\",start:0,end:Number.MAX_SAFE_INTEGER})}const t=await this.createTrack(e);if(\"sampleinfo\"===e.type)return void this.layoutChange();if(void 0===t)return;return this.addTrack(e,t)}catch(t){let i=t.message||t.error||t.toString();const n={401:\"Access unauthorized\",403:\"Access forbidden\",404:\"Not found\"};n.hasOwnProperty(i)&&(i=n[i]),i=`${i} : ${Ht(e.url)?e.url.name:e.url}`;const r=new Error(i);throw console.error(r),r}}async addTrack(e,t){void 0===t.order&&(t.order=this.trackViews.length);const i=new hf(this,this.columnContainer,t);if(this.trackViews.push(i),mA(this.trackViews,this.doShowTrackLabels),\"function\"==typeof t.postInit)try{i.startSpinner(),await t.postInit()}finally{i.stopSpinner()}return t.autoscaleGroup||(e.sync?await i.updateViews():i.updateViews()),\"function\"==typeof t.hasSamples&&t.hasSamples()&&(this.sampleInfo.hasAttributes()&&this.sampleInfoControl.setButtonVisibility(!0),!1!==this.config.showSampleNameButton&&this.sampleNameControl.show()),this.reorderTracks(),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),t.trackView.enableTrackSelection(this.navbar.getEnableTrackSelection()),t}async loadROI(e){return this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=this.roiManager.getUserDefinedROISet();if(void 0===e)return[];const t=await e.getAllFeatures(),i=[];for(let e of Object.values(t))i.push(...e);return i}return[]}getRulerTrackView(){const e=this.trackViews.filter((({track:e})=>\"ruler\"===e.id));return e.length>0?e[0]:void 0}async createTrack(e){let t=await async function(e){return\"function\"==typeof e?e():e}\n", - "/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(e.url||e.fastaURL);if(Mt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format=\"fasta\";else if(e.sourceType)\"htsget\"===e.sourceType&&await Rh.inferFormat(e);else{const t=await am(e);t&&(e.format=t)}e.type&&Ha(e);let i=e.type?e.type.toLowerCase():void 0;if(!i){if(!e.format)throw Error(`Unrecognized track: ${JSON.stringify(e)}`);if(\"hic\"===e.format){const t=new Mf(e);if(await t.readHeaderAndFooter(),!t.chromosomeIndexMap.celltype)throw Error(\"'.hic' files not supported\");i=\"shoebox\",e._hicFile=t}else if(i=za(e.format),\"bedtype\"===i){const t=Ad(e,this.genome);e._featureSource=t;const n=await t.trackType();i=n||\"annotation\"}e.type=i}if(this.trackDefaults&&i){const t=this.trackDefaults[i];if(t)for(let i in t)t.hasOwnProperty(i)&&void 0===e[i]&&(e[i]=t[i])}const n=function(e,t,i){let n;switch(e){case\"annotation\":case\"genes\":case\"fusionjuncspan\":case\"snp\":n=\"feature\";break;case\"seg\":case\"maf\":case\"mut\":n=\"seg\";break;case\"junctions\":case\"splicejunctions\":n=\"junction\";break;default:n=e}return wy.has(n)?wy.get(n)(t,i):void 0}(i,e,this);if(void 0!==n)return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map((e=>new eA(e,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0)}reorderTracks(){this.trackViews.sort((function(e,t){const i=e=>\"ideogram\"===e.track.id?1:\"ruler\"===e.track.id?2:3,n=i(e),r=i(t);if(n===r){return(e.track.order||0)-(t.track.order||0)}return n-r}));for(let{axis:e,viewports:t,sampleInfoViewport:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){e.remove();for(let{$viewport:e}of t)e.detach();i.viewport.remove(),n.viewport.remove(),r.remove(),s.remove(),o.remove()}const e=this.columnContainer.querySelectorAll(\".igv-column\");for(let{axis:t,viewports:i,sampleInfoViewport:n,sampleNameViewport:r,outerScroll:s,dragHandle:o,gearContainer:a}of this.trackViews){this.columnContainer.querySelector(\".igv-axis-column\").appendChild(t);for(let t=0;te.track&&e.track.name)).map((e=>e.track.name))}getSelectedTrackViews(){return this.trackViews.filter((e=>!0===e.track.selected))}removeTrackByName(e){const t=this.trackViews.slice();for(let i of t)e===i.track.name&&this.removeTrack(i.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent(\"trackremoved\",[e]),this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=this.trackViews;this.trackViews=[];for(let t of e)\"ruler\"!==t.track.id&&\"ideogram\"!==t.track.id?(this.fireEvent(\"trackremoved\",[t.track]),t.dispose()):this.trackViews.push(t)}get ideogramTrackView(){return this.trackViews[0]}get rulerTrackView(){return this.trackViews[1]}findTracks(e,t){let i=\"function\"==typeof e?t=>e(t.track):i=>t===i.track[e];return this.trackViews.filter(i).map((e=>e.track))}get tracks(){return this.trackViews.map((e=>e.track)).filter((e=>void 0!==e))}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach((function(t){t.setTrackHeight(e)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((e=>e.bpPerPixel<0))){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel=(t.end-t.start)/e}this.referenceFrameList&&this.navbar.navbarDidResize(),uA.call(this),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(let e of this.referenceFrameList)e.bpPerPixel<=10&&await this.genome.getSequence(e.chr,e.start,e.start+1);for(let e of this.centerLineList)e.repaint();if(this.dragObject)for(let t of e)await t.updateViews();else{const t={},i=[];for(const n of e)if(n.track.autoscaleGroup){const e=n.track.autoscaleGroup;t[e]||(t[e]=[]),t[e].push(n)}else i.push(n);if(Object.entries(t).length>0)for(const[e,i]of Object.entries(t)){const e=await Promise.all(i.map((e=>e.getInViewFeatures()))),t=qa(e.flat());for(const e of i)e.track.dataRange=Object.assign({},t),e.track.autoscale=!1;await Promise.all(i.map((e=>e.updateViews())))}await Promise.all(i.map((e=>e.updateViews())))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of e)i.end=i.start+i.bpPerPixel*t;const i=1===e.length?this.referenceFrameList[0].chr:\"\",n=this.referenceFrameList.map((e=>e.getLocusString())).join(\" \");this.navbar.updateLocus(n,i),this.fireEvent(\"locuschange\",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleInfoViewportWidth()+this.getSampleNameViewportWidth()+14+12+28,t-=5*(e-1),Math.floor(t/e)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=s;const o=(i-t)/r,a=new vy(this.genome,e,t,i,o),c=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],d=Uy(h.get(0).parentElement);if(this.fireEvent(\"didchangecolumnlayout\"),l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.push(t)}}else{this.referenceFrameList.splice(l,0,a);for(let e of this.trackViews){const t=zu(e,d,a);e.viewports.splice(l,0,t)}}this.centerLineList=this.createCenterLineList(this.columnContainer),uA.call(this),await this.updateViews(!0)}createCenterLineList(e){const t=e.querySelectorAll(\".igv-center-line\");for(let e=0;e{i===t||e.remove()})),this.columnContainer.querySelectorAll(\".igv-column-shim\").forEach((e=>e.remove()));for(let e of this.trackViews){const i=e.viewports[t];e.viewports.filter(((e,i)=>i!==t)).forEach((e=>e.dispose())),e.viewports=[i]}const i=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/i,this.referenceFrameList=[e],this.trackViews.forEach((({viewports:e})=>e.forEach((e=>e.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=e;for(let{viewports:e}of this.trackViews)for(let i of e)i.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,i){await this.search(e+\":\"+t+\"-\"+i)}async doSearch(e,t){const i=await this.search(e,t);return i||this.alert.present(new Error(`Unrecognized locus: ${e} `)),i}async search(e,t){const i=await async function(e,t){if(void 0===t||\"\"===t.trim())return;const i=t.split(\" \");let n=[];const r=async t=>{if(\"all\"===t.trim().toLowerCase()||\"*\"===t)return e.genome.wholeGenomeView?{chr:\"all\",start:0,end:e.genome.getChromosome(\"all\").bpLength}:void 0;let i,n;if(t.includes(\":\")&&(i=ey(t,e.isSoftclipped()),i&&(n=await e.genome.loadChromosome(i.chr))),!n){i=void 0;const r=await Jv(e,t);r&&(i={chr:r.chr,start:r.start,end:r.end,name:(r.name||t).toUpperCase()}),i||(n=await e.genome.loadChromosome(t),n&&(i={chr:n.name}))}return i&&(n=n||await e.genome.loadChromosome(i.chr),i.chr=n.name,void 0===i.start&&void 0===i.end&&(i.start=0,i.end=n.bpLength)),i};for(let e of i){const t=await r(e);t&&n.push(t)}if(0===n.length){const e=await r(t.replaceAll(\" \",\"+\"));e&&n.push(e)}return 0===n.length?void 0:n}(this,e);if(i&&i.length>0){this.referenceFrameList=function(e,t,i,n,r,s){return e.map((e=>{const o=Object.assign({},e);if(i&&o.name&&(o.start=Math.max(0,o.start-i),o.end+=i),!s){const e=t.getChromosome(o.chr);Qa(e.bpLength,o,n)}return new vy(t,o.chr,o.start,o.end,(o.end-o.start)/r)}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let e of this.trackViews)e.removeViewportsFromColumnContainer();this.columnContainer.querySelectorAll(\".igv-column-shim, .igv-column\").forEach((e=>e.remove())),qy(this.columnContainer.querySelector(\".igv-sample-info-column\"),this.referenceFrameList.length),this.fireEvent(\"didchangecolumnlayout\");for(let e of this.trackViews)e.createViewports(this,this.columnContainer,this.referenceFrameList);return this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}return!1}async loadSampleInfo(e){await this.sampleInfo.loadSampleInfoFile(e.url);for(const{sampleInfoViewport:e}of this.trackViews)e.setWidth(this.getSampleInfoColumnWidth());this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0&&(this.sampleInfoControl.performClickWithState(this,!0),this.sampleInfoControl.setButtonVisibility(!0));for(const{sampleInfoViewport:e}of this.trackViews)e.repaint()}getSampleInfoColumnWidth(){if(this.sampleInfo.attributeCount){const e=this.findTracks((e=>\"function\"==typeof e.getSamples)).length>0,t=this.sampleInfo.hasAttributes(),i=this.sampleInfoControl.showSampleInfo;return e&&t&&i?this.sampleInfo.attributeCount*Vu+8:0}return 0}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(e)if(t){const i=this.eventHandlers[e];if(i&&0!==i.length){const n=i.indexOf(t);-1!==n&&this.eventHandlers[e].splice(n,1)}else console.warn(\"No handlers to remove for event: \"+e)}else this.eventHandlers[e]=[];else this.eventHandlers={}}fireEvent(e,t,i){const n=this.eventHandlers[e];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(e){return e.apply(r,t)}))[0]}dispose(){this.removeEventHandlers();for(let e of this.trackViews)e.dispose();this.roiManager&&this.roiManager.dispose()}toJSON(){const e={version:\"3.0.9\"};if(void 0!==this.showSampleNames&&(e.showSampleNames=this.showSampleNames),this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[];let i=this.trackViews[0];for(let{referenceFrame:e}of i.viewports){const i=e.getLocusString();t.push(i)}e.locus=1===t.length?t[0]:t,e.roi=this.roiManager.toJSON(),this.qtlSelections.isEmpty()||(e.qtlSelections=this.qtlSelections.toJSON());const n=[],r=[];for(const{track:e}of this.trackViews)try{let t;\"function\"==typeof e.getState?t=Hl.localFileInspection(e.getState()):e.config&&(t=Hl.localFileInspection(e.config)),t&&(t.browser&&delete t.browser,t.order=e.order,n.push(t))}catch(t){const i=`Track: ${e.name}: ${t}`;console.error(i),r.push(i)}if(r.length>0){let e=1,t=\"Errors encountered saving session:
\";for(let i of r)t+=` (${e++}) ${i.toString()}
`;throw Error(t)}e.tracks=n;const s=[];for(const e of n)for(const t of Object.keys(e))\"file\"!==t&&\"indexFile\"!==t||s.push(e[t]);const o=[];if(this.sampleInfo.sampleInfoFiles.length>0){const t=this.sampleInfo.toJSON();t.length>0&&(e.sampleinfo=t);for(const e of this.sampleInfo.sampleInfoFiles){const t=Hl.localFileInspection({url:e});t.file&&o.push(t.file)}o.length>0&&s.push(...o)}return s.length>0&&alert(`This session includes reference(s) to local file(s):\\n${s.map((e=>` ${e}`)).join(\"\\n\")}\\nLocal files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){return function(e){const t=new Uint8Array(e.length);for(var i=0;i0?e.substring(0,t):e)+\"?sessionURL=blob:\"+this.compressedSession()}mouseDownOnViewport(e,t){var i;i=r(e),this.vpMouseDown={viewport:t,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent(\"trackdragend\",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((e=>!0===e.track.showSoftClips))}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,i=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),r=this.trackViews;r[i]=t,r[n]=e;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i0;e--){const t=r[e].track;if(!(t.order>=a))break;t.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=t.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent(\"trackorderchanged\",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=uA.bind(this),window.addEventListener(\"resize\",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener(\"resize\",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=pA.bind(this),this.root.addEventListener(\"mouseup\",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener(\"mouseup\",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=pA.bind(this),this.root.addEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener(\"mouseleave\",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=fA.bind(this),this.boundColumnContainerTouchMoveHandler=fA.bind(this),this.boundColumnContainerMouseLeaveHandler=pA.bind(this),this.boundColumnContainerMouseUpHandler=pA.bind(this),this.boundColumnContainerTouchEndHandler=pA.bind(this),this.columnContainer.addEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener(\"mousemove\",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener(\"touchmove\",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener(\"mouseleave\",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener(\"mouseup\",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener(\"touchend\",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=gA.bind(this),document.addEventListener(\"keyup\",this.keyUpHandler)}removeKeyboardHandler(){console.log(\"Remove handler\"),document.addEventListener(\"keyup\",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf(\"/gzip;base64\")>0){t=vs(e);let i=\"\";for(let e of t)i+=String.fromCharCode(e);return i}return function(e){e=e.replace(/\\./g,\"+\").replace(/_/g,\"/\").replace(/-/g,\"=\");const t=atob(e),i=[];for(let e=0;e{const r=e.data,s=r.mate;function o(e){e.chr=i.genome.getChromosomeName(e.refName);let t=!1;for(let n of i.referenceFrameList){const i=lm.fromLocusString(n.getLocusString());if(i.contains(e)){t=!0;break}if(i.overlaps(e)){n.extend(e),t=!0;break}}if(!t){const t=2e3,n=(e.start+e.end)/2;i.addMultiLocusPanel(e.chr,n-t,n+t)}}o(r),o(s)}})),this.circularViewControl=new Vy(this.navbar.toggle_button_container,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Hm(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get sampleInfoControl(){return this.navbar.sampleInfoControl}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}get sampleNameControl(){return this.navbar.sampleNameControl}}async function uA(){if(!this.referenceFrameList)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList){const i=this.referenceFrameList.indexOf(t),{chr:n,genome:r}=t,{bpLength:s}=r.getChromosome(t.chr),o=t.toBP(e);mu.isWholeGenomeView(n)||o>s?t.bpPerPixel=s/e:t.end=t.start+t.toBP(e);for(let{viewports:t}of this.trackViews)t[i].setWidth(e)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function fA(e){e.preventDefault();const{x:t,y:i}=r(e);if(this.vpMouseDown){const{viewport:e,referenceFrame:n}=this.vpMouseDown,r=Math.abs(t-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(t-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:e,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const t=e.$viewport.height(),i=e.trackView.maxViewportContentHeight();this.vpMouseDown.r=t/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-t;n.shiftPixels(r,e.$viewport.width(),i)&&this.updateViews(),this.fireEvent(\"trackdrag\")}if(this.isScrolling){const t=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);e.trackView.moveScroller(t)}this.vpMouseDown.lastMouseX=t,this.vpMouseDown.lastMouseY=i}}function pA(e){this.cancelTrackPan(),this.endTrackDrag()}async function gA(e){if(this.referenceFrameList&&!(this.referenceFrameList.length>1)&&(\"KeyF\"===e.code||\"KeyB\"===e.code)){const t=this.getSelectedTrackViews();if(t.length>0){const i=t[0].track;if(\"function\"==typeof i.nextFeatureAfter){const t=this.referenceFrameList[0],n=t.viewport?t.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),r=\"all\"===t.chr.toLowerCase(),s=i.visibilityWindow;if(r||s&&s>0&&t.bpPerPixel*n>s)return;const o=\"KeyF\"===e.code,a=t.chr,c=t.center,l=await i.nextFeatureAfter(a,c,o);if(l){const i=await this.genome.getChromosomeName(l.chr);if(a===i){const i=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,r=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,i-r/2),t.end=i+r/2,t.bpPerPixel=(t.end-t.start)/n}else t.shift(i-c);this.updateViews()}else{t.chr=i;const r=(l.start+l.end)/2;if(e.shiftKey){const e=this.config.minimumBases||40,i=Math.max(e,1.1*(l.end-l.start));t.start=Math.max(0,r-i/2),t.end=t.start+i,t.bpPerPixel=(t.end-t.start)/n}else t.start=r-n*t.bpPerPixel/2,t.end=t.start+n*t.bpPerPixel;this.updateViews()}}}}}}function mA(e,t){for(let{viewports:i}of e)for(let e of i)e.$trackLabel&&(0===i.indexOf(e)&&!0===t?e.$trackLabel.show():e.$trackLabel.hide())}let wA=[];function bA(e){return void 0===e.minimumBases&&(e.minimumBases=40),void 0===e.showIdeogram&&(e.showIdeogram=!0),void 0===e.showCircularView&&(e.showCircularView=!1),void 0===e.showCircularViewButton&&(e.showCircularViewButton=!1),void 0===e.showTrackLabelButton&&(e.showTrackLabelButton=!0),void 0===e.showTrackLabels&&(e.showTrackLabels=!0),void 0===e.showCursorTrackingGuideButton&&(e.showCursorTrackingGuideButton=!0),void 0===e.showCursorGuide&&(e.showCursorGuide=e.showCursorTrackingGuide||!1),void 0===e.showCenterGuideButton&&(e.showCenterGuideButton=!0),void 0===e.showCenterGuide&&(e.showCenterGuide=!1),void 0===e.showSampleNames&&(e.showSampleNames=!1),void 0===e.showSVGButton&&(e.showSVGButton=!0),void 0===e.showControls&&(e.showControls=!0),void 0===e.showNavigation&&(e.showNavigation=!0),void 0===e.showRuler&&(e.showRuler=!0),void 0===e.flanking&&(e.flanking=1e3),void 0===e.pairsSupported&&(e.pairsSupported=!0),e.tracks||(e.tracks=[]),e}const FA=Qs.setApiKey;const vA=Qs.oauth;var yA={TrackUtils:Pa,IGVGraphics:xo,MenuUtils:bo,DataRangeDialog:_o,createTrack:async function(e,t){return await dA.prototype.createTrack.call(t,e)},createBrowser:async function(e,t){void 0===t&&(t={}),mu.KNOWN_GENOMES||await mu.initializeGenomes(t),bA(t),t.queryParametersSupported&&function(e){var t,i,n,r,s,o,a,c,l;let h,d,u;if(a=window.location.href,s={},t=a.indexOf(\"?\"),i=a.lastIndexOf(\"#\"),t>=0)for(i<0&&(i=a.length),n=t+1;nt&&(i.indexURL=d[t]),u&&u.length>t&&(i.name=u[t]),e.tracks.push(i)}}}(t),t.apiKey&&Qs.setApiKey(t.apiKey),t.oauthToken&&Qs.setOauthToken(t.oauthToken),t.clientId&&!Ts()&&await async function(e){if(!google.accounts.oauth2.initTokenClient)throw new Error(\"Google accounts token client not loaded (https://accounts.google.com/gsi/client)\");if(Ts())throw new Error(\"Google client is already initialized\");const t={client_id:e.client_id||e.clientId,scope:e.scope||\"https://www.googleapis.com/auth/userinfo.profile\",state:e.state||\"igv\",error:e=>{throw new Error(e.type)},hint:e.hint,hosted_domain:e.hosted_domain},i=google.accounts.oauth2.initTokenClient(t);google.igv={tokenClient:i,apiKey:e.apiKey}}({client_id:t.clientId,apiKey:t.apiKey,scope:\"https://www.googleapis.com/auth/userinfo.profile\"});const i=new dA(t,e);wA.push(i),i.startSpinner();const n=t.sessionURL||t.session||t.hubURL;return n?await i.loadSession({url:n}):await i.loadSessionObject(t),i.stopSpinner(),i.navbar.navbarDidResize(),i},removeBrowser:function(e){e.dispose(),e.root.remove(),wA=wA.filter((t=>t!==e))},removeAllBrowsers:function(){for(let e of wA)e.dispose(),e.root.remove();wA=[]},visibilityChange:async function(){for(let e of wA)await e.visibilityChange()},setGoogleOauthToken:function(e){return Qs.setOauthToken(e)},setOauthToken:function(e,t){return Qs.setOauthToken(e,t)},oauth:vA,version:yy,setApiKey:FA,TrackBase:Hl,registerTrackClass:function(e,t){wy.set(e,((e,i)=>new t(e,i)))},registerTrackCreatorFunction:function(e,t){wy.set(e,t)},registerFileFormats:function(e,t){Sl[e]={fields:t}},loadSessionFile:dA.loadSessionFile};return yA}();\n", - "//# sourceMappingURL=igv.iife.js.map\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Global handler for igv.js messages. Messages have the form\n", - " * {\n", - " * command -- the command to execute\n", - " * id -- the id of the igv.js browser, if applicable\n", - " * data -- any data needed for the command\n", - " * }\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope, with the execption of the global handler\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " let svgComm\n", - " if (isNotebook) {\n", - " svgComm = Jupyter.notebook.kernel.comm_manager.new_comm('svg', {})\n", - " }\n", - "\n", - " async function toSVG(displayID, locus, svg) {\n", - " //console.log(isNotebook + \" \" + locus)\n", - " if (isNotebook) {\n", - " svgComm.send({\n", - " \"display_id\": displayID,\n", - " \"locus\": locus,\n", - " \"svg\": svg\n", - " })\n", - " }\n", - " }\n", - "\n", - " console.log(\"Installing IGVMessageHandler\")\n", - "\n", - " function convertUrlsAndPaths(session) {\n", - " if (session.reference) {\n", - " for (let pre of [\"fasta\", \"index\", \"cytoband\", \"cytobandBb\", \"compressedIndex\", \"alias\", \"aliasBb\",\n", - " \"twoBit\", \"twoBitBpt\", \"chromAliasBb\", \"chromSizes\", \"trix\"]) {\n", - " convert(session.reference, pre)\n", - " }\n", - " if (session.reference.tracks) {\n", - " for (let t of session.reference.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " if (session.tracks) {\n", - " for (let t of session.tracks) {\n", - " convert(t)\n", - " convert(t, \"index\")\n", - " if (!t.indexURL) {\n", - " t.indexed = false\n", - " }\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Return true if the sessionJson object contains only absolute URLs to resources\n", - " */\n", - " function safeToWeblink(sessionJson) {\n", - " const unsafe = (url) => typeof url.startsWith != 'function' || !url.startsWith(\"http\")\n", - " if (sessionJson.reference) {\n", - " if (unsafe(sessionJson.reference.fastaURL)) return false\n", - " }\n", - " if (sessionJson.tracks) {\n", - " const urls = sessionJson.tracks.filter(t => t.url).map(t => t.url)\n", - " if (urls.some(unsafe)) return false\n", - " }\n", - " return true\n", - " }\n", - "\n", - " class MessageHandler {\n", - "\n", - " constructor() {\n", - " this.browserCache = new Map()\n", - " this.messageQueue = new Queue()\n", - " }\n", - "\n", - " on(msg) {\n", - " this.messageQueue.enqueue(msg)\n", - " this.processQueue()\n", - " }\n", - "\n", - " async processQueue() {\n", - "\n", - " const convertTrackData = (data) => {\n", - " convert(data)\n", - " convert(data, \"index\")\n", - " if (!data.indexURL) {\n", - " data.indexed = false\n", - " }\n", - " }\n", - "\n", - " if (!this.processing) {\n", - " this.processing = true\n", - " while (!this.messageQueue.isEmpty()) {\n", - " const msg = this.messageQueue.dequeue()\n", - " const command = msg.command\n", - " const browserID = msg.id\n", - " const data = msg.data\n", - " const browser = this.browserCache.get(browserID)\n", - " try {\n", - " switch (command) {\n", - " case \"createBrowser\":\n", - "\n", - " // custom button bar\n", - " const button_container = document.getElementById(`${browserID}_buttons`) // <= created from python\n", - " const customButtonDiv = document.createElement('div')\n", - " customButtonDiv.style = `background: #f3f3f3;padding: 5px;border-color: #bfbfbf;border-style: solid;border-width: thin;border-radius: 3px;`\n", - " button_container.appendChild(customButtonDiv)\n", - "\n", - " data.sync = true\n", - " convertUrlsAndPaths(data)\n", - "\n", - " const container = document.getElementById(`${browserID}_igvcontainer`) // <= created from python\n", - " const newBrowser = await igv.createBrowser(container, data)\n", - " this.browserCache.set(browserID, newBrowser)\n", - "\n", - " // Add igv-notebook button bar\n", - " const toJsonButton = document.createElement('button')\n", - " toJsonButton.innerText = \"Save Session\"\n", - " toJsonButton.style = \"margin-right:5px\"\n", - " toJsonButton.addEventListener('click', (evt) => {\n", - " let fn\n", - " if (isNotebook) {\n", - " fn = prompt(\"Filename:\", \"session.json\")\n", - " } else {\n", - " fn = \"session.json\"\n", - " }\n", - " if (fn) {\n", - " const json = newBrowser.toJSON()\n", - " const jsonString = JSON.stringify(json, null, '\\t')\n", - " download(fn, jsonString)\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(toJsonButton)\n", - "\n", - " const webLinkNode = document.createElement('a')\n", - " webLinkNode.target = \"igvWeb\"\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.style.display = \"none\"\n", - "\n", - " const shareButton = document.createElement('button')\n", - " shareButton.innerText = \"Show IGV-Web Link\"\n", - " shareButton.style = \"margin-right:5px\"\n", - " shareButton.addEventListener('click', async (evt) => {\n", - "\n", - " if (safeToWeblink(newBrowser.toJSON())) {\n", - " const sessionURL = `https://igv.org/app?sessionURL=blob:${newBrowser.compressedSession()}`\n", - " const shortURL = await shortenURL(sessionURL)\n", - " webLinkNode.innerText = \"Link to IGV-Web\"\n", - " webLinkNode.setAttribute(\"href\", shortURL)\n", - " webLinkNode.style.display = \"inline-block\"\n", - " shareButton.innerText = \"Update IGV-Web Link\"\n", - " } else {\n", - " webLinkNode.innerText = \"Cannot link -- non URL resources used\"\n", - " webLinkNode.style.display = \"inline-block\"\n", - " }\n", - " })\n", - " customButtonDiv.appendChild(shareButton)\n", - " customButtonDiv.appendChild(webLinkNode)\n", - "\n", - " if (isNotebook) {\n", - " const toSVGButton = document.createElement('button')\n", - " toSVGButton.innerText = \"To SVG\"\n", - " toSVGButton.style = \"float:right\"\n", - " toSVGButton.addEventListener('click', (evt) => {\n", - " const locus = newBrowser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " const svg = newBrowser.toSVG()\n", - " toSVG(browserID, locus, svg)\n", - " })\n", - " customButtonDiv.appendChild(toSVGButton)\n", - " }\n", - "\n", - " break\n", - "\n", - " case \"loadSession\":\n", - " convertUrlsAndPaths(data)\n", - " browser.loadSessionObject(data)\n", - " break\n", - "\n", - " case \"loadTrack\":\n", - " convertTrackData(data)\n", - " await browser.loadTrack(data)\n", - " break\n", - "\n", - " case \"loadROI\":\n", - " if (Array.isArray(data)) {\n", - " data.map(convertTrackData)\n", - " } else {\n", - " convertTrackData(data)\n", - " }\n", - " await browser.loadROI(data)\n", - " break\n", - "\n", - " case \"clearROIs\":\n", - " await browser.clearROIs()\n", - " break\n", - "\n", - " case \"search\":\n", - " browser.search(data)\n", - " break\n", - "\n", - " case \"zoomIn\":\n", - " browser.zoomIn()\n", - " break\n", - "\n", - " case \"zoomOut\":\n", - " browser.zoomOut()\n", - " break\n", - "\n", - " case \"remove\":\n", - " this.browserCache.delete(browserID)\n", - " document.getElementById(browserID).parentNode.removeChild(container)\n", - " break\n", - "\n", - " case \"toSVG\":\n", - " const displayId = data\n", - " const svg = browser.toSVG()\n", - " const locus = browser.referenceFrameList.map(rf => rf.getLocusString()).join(' ')\n", - " toSVG(displayId, locus, svg)\n", - " break\n", - "\n", - " default:\n", - " console.error(\"Unrecognized method: \" + msg.command)\n", - " }\n", - " } catch (e) {\n", - " console.error(e)\n", - " }\n", - " }\n", - " this.processing = false\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Potentially convert a path to a local File-like object.\n", - " * @param path\n", - " * @returns {*}\n", - " */\n", - " function createNotebookFile(path) {\n", - " if (!path ||\n", - " path.startsWith(\"https://\") || path.startsWith(\"http://\") || path.startsWith(\"gs://\") || path.startsWith(\"data:\")) {\n", - " return path\n", - " } else {\n", - " // Try to create a notebook file. If no notebook file implementation is available for the kernel in\n", - " // use (e.g. Jupyter Lab) treat as a URL.\n", - " const nbFile = igv.createNotebookLocalFile({path})\n", - " if (nbFile != null) {\n", - " return nbFile\n", - " } else {\n", - " // Try to treat as relative URL. This may or may not work\n", - " return convertURL(path)\n", - " }\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Convert relative URLs to absolute. Primarily for Jupyter Lab, not generally needed for Jupyter Notebook\n", - " * @param url\n", - " * @returns {*}\n", - " */\n", - " function convertURL(url) {\n", - "\n", - " const pageURL = window.location.href\n", - "\n", - " if (!url ||\n", - " url.startsWith(\"https://\") ||\n", - " url.startsWith(\"http://\") ||\n", - " url.startsWith(\"gs://\") ||\n", - " url.startsWith(\"data:\")) {\n", - " return url\n", - " } else if (isColab) {\n", - " // Interpret relative url as a path.\n", - " igv.createNotebookLocalFile({path: url})\n", - " } else if (isNotebook) {\n", - " // Jupyter Notebook\n", - " //\n", - " // Examples\n", - " // https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/notebooks/examples/BamFiles-Jupyter.ipynb\n", - " // => https://hub-binder.mybinder.ovh/user/igvteam-igv-notebook-tnlb45ie/files/examples/data/gstt1_sample.bam\",\n", - "\n", - " const baseURL = document.querySelector('body').getAttribute('data-base-url')\n", - " const notebookPath = document.querySelector('body').getAttribute('data-notebook-path')\n", - " const notebookName = document.querySelector('body').getAttribute('data-notebook-name')\n", - " const notebookDir = notebookPath.slice(0, -1 * notebookName.length)\n", - "\n", - " //`${location.origin}${base_path}files/${nb_dir}${url}`\n", - " if (url.startsWith(\"/\")) {\n", - " url = `files${url}`\n", - " return encodeURI(`${location.origin}${baseURL}${url}`)\n", - " } else {\n", - " // URL is relative to notebook\n", - " return encodeURI(`${location.origin}${baseURL}files/${notebookDir}${url}`)\n", - " }\n", - " } else if (pageURL.includes(\"/lab\")) {\n", - "\n", - " console.log(\"Jupyter lab\")\n", - " // Jupyter Lab\n", - "\n", - " // Examples\n", - " // http://localhost:8888/lab/workspaces/auto-N/tree/examples/BamFiles.ipynb\n", - " // => http://localhost:8888/files/examples/data/gstt1_sample.bam\n", - " //\n", - " // https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/lab/tree/examples/BamFiles.ipynb\n", - " // => https://hub.gke2.mybinder.org/user/igvteam-igv-notebook-5ivkyktt/files/examples/data/gstt1_sample.bam\n", - "\n", - " const baseIndex = pageURL.indexOf(\"/lab\")\n", - " const baseURL = pageURL.substring(0, baseIndex)\n", - "\n", - " if (url.startsWith(\"/\")) {\n", - " return encodeURI(`${baseURL}/files${url}`)\n", - " } else if (pageURL.includes(\"/tree/\")) {\n", - " // Interpret URL as relative to notebook location. This is not reliable, '/tree/' is not always in the page URL\n", - " const treeIndex = pageURL.indexOf(\"/tree/\") + 6\n", - " const lastSlashIndex = pageURL.lastIndexOf(\"/\")\n", - " const notebookDir = pageURL.substring(treeIndex, lastSlashIndex)\n", - " return encodeURI(`${baseURL}/files/${notebookDir}/${url}`)\n", - " } else {\n", - " // We don't know how to determine the notebook path\n", - " console.warn(\"Page url missing '/tree/'. Can't determine notebook path.\")\n", - " return encodeURI(`${baseURL}/files/${url}`)\n", - " }\n", - " } else {\n", - " // We should never get here,\n", - " return encodeURI(url)\n", - " }\n", - " }\n", - "\n", - "\n", - " function convert(config, prefix) {\n", - " const urlProp = prefix ? prefix + \"URL\" : \"url\"\n", - " const pathProp = prefix ? prefix + \"Path\" : \"path\"\n", - " if (config[pathProp]) {\n", - " config[urlProp] = createNotebookFile(config[pathProp])\n", - " } else if (config[urlProp]) {\n", - " config[urlProp] = convertURL(config[urlProp])\n", - " }\n", - " }\n", - "\n", - "\n", - " class Queue {\n", - " constructor() {\n", - " this.elements = []\n", - " }\n", - "\n", - " enqueue(e) {\n", - " this.elements.push(e)\n", - " }\n", - "\n", - " dequeue() {\n", - " return this.elements.shift()\n", - " }\n", - "\n", - " isEmpty() {\n", - " return this.elements.length == 0\n", - " }\n", - "\n", - " peek() {\n", - " return !this.isEmpty() ? this.elements[0] : undefined\n", - " }\n", - "\n", - " length() {\n", - " return this.elements.length\n", - " }\n", - " }\n", - "\n", - " window.igv.MessageHandler = new MessageHandler()\n", - "\n", - " function download(filename, text) {\n", - "\n", - " const data = URL.createObjectURL(new Blob([text], {type: \"application/octet-stream\"}))\n", - " const element = document.createElement('a')\n", - " element.setAttribute('href', data)\n", - " element.setAttribute('download', filename)\n", - " element.style.display = 'none'\n", - " document.body.appendChild(element)\n", - " element.click()\n", - " document.body.removeChild(element)\n", - " }\n", - "\n", - " async function shortenURL(url) {\n", - " const endpoint = \"https://2et6uxfezb.execute-api.us-east-1.amazonaws.com/dev/tinyurl/\"\n", - " const enc = encodeURIComponent(url)\n", - " const response = await fetch(`${endpoint}${enc}`)\n", - " if (response.ok) {\n", - " return response.text()\n", - " } else {\n", - " throw new Error(response.statusText)\n", - " }\n", - " }\n", - "\n", - " console.log(\"igv.MessageHandler installed\")\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "/**\n", - " * Mock objects to emulate the browser \"File\" class for use with Jupyter and Colab notebooks. These objects delegate\n", - " * actual file reading to python.\n", - " */\n", - "\n", - "// Use a self-evaluating function to keep variables in this file scope\n", - "\n", - "(function () {\n", - "\n", - " const isColab = window.google !== undefined && window.google.colab\n", - " const isNotebook = !isColab && window.Jupyter !== undefined\n", - "\n", - " igv.createNotebookLocalFile = function (options) {\n", - " if (isColab) {\n", - " return new ColabLocalFile(options)\n", - " } else if (isNotebook) {\n", - " return new JupyterLocalFile(options)\n", - " } else {\n", - " return undefined; //TODO -- throw error?\n", - " }\n", - " }\n", - "\n", - "\n", - " // Start up a Comm object if in a Jupyter Notebook environment (i.e. not Colab or JupyterLab).\n", - " let comm\n", - " const pendingRequests = new Map()\n", - " if (isNotebook) {\n", - " console.log('registering comm')\n", - " comm = Jupyter.notebook.kernel.comm_manager.new_comm('file_request', {})\n", - " // Register a handler\n", - " comm.on_msg(function (msg) {\n", - " const id = msg.content.data.id\n", - " const data = msg.content.data.data\n", - " pendingRequests.set(id, data)\n", - " })\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Jupyter notebooks. File reading is delegated to python via Comms messaging.\n", - " * Polling is used to synchronize the async message passing.\n", - " *\n", - " * NOTE: This will not work for JupyterLab\n", - " */\n", - " class JupyterLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'JupyterLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new JupyterLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as binary data.\n", - " *\n", - " * @returns {Promise<*>}\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const id = uniqueID()\n", - " const path = this.path\n", - " const promise = new Promise((resolve, reject) => {\n", - " let count = 0\n", - "\n", - " function poll() {\n", - "\n", - " if (count > 100) {\n", - " console.error(`error reading ${path}: timed out`)\n", - " reject(`error reading ${path}: timed out`)\n", - " }\n", - "\n", - " count++\n", - " if (pendingRequests.has(id)) {\n", - " const data = pendingRequests.get(id)\n", - " const dataString = atob(data)\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " pendingRequests.delete(id)\n", - " resolve(bytes.buffer)\n", - " } else {\n", - " setTimeout(poll, 100)\n", - " }\n", - " }\n", - "\n", - " poll()\n", - " })\n", - "\n", - " const msg = (this.start === undefined) ?\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer'} :\n", - " {id: id, 'path': this.path, 'method': 'arrayBuffer', 'start': this.start, 'end': this.end}\n", - "\n", - " comm.send(msg)\n", - "\n", - " return promise\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Emulates a browser \"File\" for Colab environments.\n", - " */\n", - " class ColabLocalFile {\n", - "\n", - " constructor({path, name, start, end}) {\n", - " this.type = 'ColabLocalFile'\n", - " this.path = path\n", - " this.name = name || path\n", - " this.start = start\n", - " this.end = end\n", - " }\n", - "\n", - " /**\n", - " * Returns a new Blob object containing the data in the specified range of bytes of the blob on which it's called.\n", - " * @param start An index into the Blob indicating the first byte to include in the new Blob\n", - " * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob\n", - " * @param contentType\n", - " * @returns {*}\n", - " */\n", - " slice(start, end) {\n", - " return new ColabLocalFile({path: this.path, name: this.name, start, end})\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with an ArrayBuffer containing the entire contents of the Blob as\n", - " * binary data.\n", - " */\n", - " async arrayBuffer() {\n", - "\n", - " const args = (this.start === undefined) ?\n", - " [this.path] :\n", - " [this.path, this.start.toString(), this.end.toString()]\n", - "\n", - " const result = await google.colab.kernel.invokeFunction(\n", - " 'ReadFile', // The callback name.\n", - " args, // The arguments.\n", - " {}) // kwargs\n", - " const data = result.data[\"text/plain\"]\n", - " const dataString = atob(data.substring(2, data.length - 1))\n", - " const bytes = new Uint8Array(dataString.length)\n", - " for (var i = 0; i < dataString.length; i++) {\n", - " bytes[i] = dataString.charCodeAt(i)\n", - " }\n", - " return bytes.buffer\n", - " }\n", - "\n", - " /**\n", - " * Returns a promise that resolves with a USVString containing the entire contents of the Blob interpreted as UTF-8 text.\n", - " *\n", - " * @returns {Promise}\n", - " */\n", - " async text() {\n", - " throw Error(\"text not implemented\")\n", - " }\n", - "\n", - " stream() {\n", - " throw Error(\"stream not implemented\")\n", - " }\n", - " }\n", - "\n", - " let counter = 0\n", - "\n", - " function uniqueID() {\n", - " return `${Math.random()}-${counter++}`\n", - " }\n", - "\n", - "})()" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": [ - "window.igv.MessageHandler.on({\"id\": \"jb_3263345\", \"command\": \"createBrowser\", \"data\": {\"reference\": {\"id\": \"idAnoFuneDA-416_04\", \"name\": \"Anopheles funestus\", \"fastaURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_afun_release/reference/genome/idAnoFuneDA-416_04/idAnoFuneDA-416_04_1.curated_primary.fa\", \"indexURL\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_afun_release/reference/genome/idAnoFuneDA-416_04/idAnoFuneDA-416_04_1.curated_primary.fa.fai\", \"tracks\": [{\"name\": \"Genes\", \"type\": \"annotation\", \"format\": \"gff3\", \"url\": \"https://storage.googleapis.com/vo_anoph_temp_us_central1/vo_afun_release/reference/genome/idAnoFuneDA-416_04/VectorBase-61_AfunestusidAnoFuneDA416_04_patched.gff3.gz\", \"indexed\": false}]}, \"locus\": \"2RL:2,441,878-2,468,205\", \"id\": \"jb_3263345\"}})" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "af1.igv(region=\"2RL:2,441,878-2,468,205\")" ] @@ -3854,7 +163,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d73b2743", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -3864,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6ccb0fe4", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -3879,7 +188,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d96182f0", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -3894,7 +203,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ac02dc0b", + "id": "17", "metadata": {}, "outputs": [], "source": [] @@ -3902,7 +211,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -3915,15 +223,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, From 6802977d917fd04559e207d9d4094a53d7ecf10b Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 13:01:47 +0100 Subject: [PATCH 11/38] fix field order to hopefully enable analysis of outputs from bcftools --- malariagen_data/anoph/to_vcf.py | 15 +++++++++- tests/anoph/test_vcf_exporter.py | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 132386520..387a99599 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -13,8 +13,12 @@ from . import plink_params from . import vcf_params -# Supported FORMAT fields and their VCF header definitions. +# Supported FORMAT fields, the fixed order in which their values are +# always written per sample (regardless of what order the caller's +# `fields` argument happens to iterate in — e.g. a set has no +# guaranteed order at all), and their VCF header definitions. _VALID_FIELDS = {"GT", "GQ", "AD", "MQ"} +_FIELD_ORDER = ("GT", "GQ", "AD", "MQ") _FORMAT_HEADERS = { "GT": '##FORMAT=', "GQ": '##FORMAT=', @@ -131,6 +135,15 @@ def snp_calls_to_vcf( if "GT" not in fields: raise ValueError("GT must be included in fields.") + # Canonicalise the field order to _FIELD_ORDER. The per-sample + # values below are always written in this fixed order; if the + # FORMAT column (built from `fields` further down) used the + # caller's order instead, a `fields` argument with a different + # (or undefined, e.g. a set) order would produce a VCF whose + # FORMAT column lies about which value is which — which is + # exactly what happened before this fix. + fields = tuple(f for f in _FIELD_ORDER if f in fields) + if os.path.exists(output_path) and not overwrite: return output_path diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 7ea33a846..bcdd67e4e 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -335,6 +335,53 @@ def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): assert len(parts) == 2, f"Expected GT:GQ, got {sample_val!r}" +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_fields_as_set(fixture, api: SnpVcfExporter, tmp_path): + # A `set` has no guaranteed iteration order. The FORMAT column must + # still come out in the same fixed order (GT, GQ, AD, MQ) that the + # per-sample values are actually written in, regardless of what + # order `fields` iterates in as passed by the caller. Previously + # the FORMAT column used the caller's (here, arbitrary) order while + # values were always written GT:GQ:AD:MQ, so a `set` could easily + # produce a VCF whose header lied about which value was which — + # e.g. declaring the first value as "MQ" when it was actually the + # GT string, which bcftools then fails to parse. + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + + output_path = str(tmp_path / "test_fields_set.vcf") + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + fields={"GT", "GQ", "AD", "MQ"}, + ) + + with open(output_path) as f: + lines = f.readlines() + + data_lines = [line for line in lines if not line.startswith("#")] + assert len(data_lines) > 0 + + for line in data_lines: + fields_row = line.strip().split("\t") + # FORMAT column must always be in this fixed order. + assert fields_row[8] == "GT:GQ:AD:MQ" + + for sample_val in fields_row[9:]: + gt, gq, ad, mq = sample_val.split(":") + # GT is the only field allowed to contain "/"; if it ended + # up anywhere else (or something else ended up in its + # place), that's exactly the bug this test guards against. + assert gt == "./." or "/" in gt + assert "/" not in gq + assert "/" not in ad + assert "/" not in mq + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] From 6428c98c4b4998851eb3b22716930efcfd58f77a Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 13:17:05 +0100 Subject: [PATCH 12/38] more format fixing --- malariagen_data/anoph/to_vcf.py | 2 +- tests/anoph/test_vcf_exporter.py | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 387a99599..ac1f32f5f 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -23,7 +23,7 @@ "GT": '##FORMAT=', "GQ": '##FORMAT=', "AD": '##FORMAT=', - "MQ": '##FORMAT=', + "MQ": '##FORMAT=', } # snp_calls_to_vcf() only supports exporting a single sample at a time diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index bcdd67e4e..92237cabc 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -1,6 +1,8 @@ import gzip import os import random +import shutil +import subprocess import pytest from pytest_cases import parametrize_with_cases @@ -382,6 +384,43 @@ def test_vcf_exporter_fields_as_set(fixture, api: SnpVcfExporter, tmp_path): assert "/" not in mq +@pytest.mark.skipif(shutil.which("bcftools") is None, reason="bcftools not installed") +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_output_is_valid_per_bcftools( + fixture, api: SnpVcfExporter, tmp_path +): + # A stronger check than the Python-level assertions above: actually + # parse the output with bcftools, the way a real consumer would. + # This is what caught both the FORMAT field-order bug (a `set` of + # fields could desync the FORMAT column from the hardcoded value + # order) and the MQ header Type=Integer/actual-float-value mismatch + # — neither of which a purely structural Python check (e.g. + # splitting on "\t"/":") would notice, since both produce + # "well-formed" tab/colon-separated text that just happens to lie + # about, or misdeclare, its own content. + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + + output_path = str(tmp_path / "test_bcftools_valid.vcf") + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + fields={"GT", "GQ", "AD", "MQ"}, + ) + + result = subprocess.run( + ["bcftools", "view", "-v", "snps", output_path], + capture_output=True, + text=True, + ) + assert result.returncode == 0, f"bcftools failed to parse output: {result.stderr}" + assert "Error" not in result.stderr + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] From b7ec7c783a266c9ab0559173194747577d9ebc5f Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 15:21:05 +0100 Subject: [PATCH 13/38] more twiddling with header due to bcftools warning, still looking into agreement with reference VCF --- malariagen_data/anoph/to_vcf.py | 14 +++++++++++--- tests/anoph/test_vcf_exporter.py | 21 ++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index ac1f32f5f..b65712f7d 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -23,7 +23,12 @@ "GT": '##FORMAT=', "GQ": '##FORMAT=', "AD": '##FORMAT=', - "MQ": '##FORMAT=', + # N.B., "MQ" is a reserved FORMAT key in the VCF specification, + # fixed there as Integer, Number=1 — even though the underlying + # data is a float (RMS mapping quality), so values are rounded to + # the nearest integer when written below to stay spec-compliant + # under the reserved key's declared type. + "MQ": '##FORMAT=', } # snp_calls_to_vcf() only supports exporting a single sample at a time @@ -371,11 +376,14 @@ def snp_calls_to_vcf( ) else: parts.append(".") - # MQ. + # MQ. Rounded to the nearest integer: the + # underlying data is a float, but the VCF + # spec fixes the reserved FORMAT/MQ key as + # Integer (see _FORMAT_HEADERS). if include_mq: if mq_chunk is not None: v = mq_chunk[j, k] - parts.append("." if v < 0 else str(v)) + parts.append("." if v < 0 else str(round(v))) else: parts.append(".") sample_fields.append(":".join(parts)) diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 92237cabc..df5532abf 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -391,13 +391,15 @@ def test_vcf_exporter_output_is_valid_per_bcftools( ): # A stronger check than the Python-level assertions above: actually # parse the output with bcftools, the way a real consumer would. - # This is what caught both the FORMAT field-order bug (a `set` of - # fields could desync the FORMAT column from the hardcoded value - # order) and the MQ header Type=Integer/actual-float-value mismatch - # — neither of which a purely structural Python check (e.g. - # splitting on "\t"/":") would notice, since both produce - # "well-formed" tab/colon-separated text that just happens to lie - # about, or misdeclare, its own content. + # This is what caught the FORMAT field-order bug (a `set` of fields + # could desync the FORMAT column from the hardcoded value order), + # the MQ header Type=Integer/actual-float-value mismatch, and (via + # the sanity-check warning below) declaring the reserved FORMAT/MQ + # key as Type=Float instead of the spec-mandated Integer — none of + # which a purely structural Python check (e.g. splitting on + # "\t"/":") would notice, since all three produce "well-formed" + # tab/colon-separated text that just happens to lie about, or + # misdeclare, its own content. region = api.contigs[0] all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] @@ -419,6 +421,11 @@ def test_vcf_exporter_output_is_valid_per_bcftools( ) assert result.returncode == 0, f"bcftools failed to parse output: {result.stderr}" assert "Error" not in result.stderr + # Not just error-free: bcftools' own header sanity check should not + # flag any of our FORMAT field declarations against the VCF spec's + # reserved-key type definitions (e.g. FORMAT/MQ is fixed as + # Integer by the spec, regardless of the underlying data type). + assert "should be declared as" not in result.stderr, result.stderr @parametrize_with_cases("fixture,api", cases=".") From aeab10095ec9ae0933d53921197d88c20d9f1e52 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 29 Sep 2026 16:51:35 +0100 Subject: [PATCH 14/38] Claude draft to output only heterozygous sites in VCF --- malariagen_data/anoph/to_vcf.py | 29 +++++++- tests/anoph/test_vcf_exporter.py | 119 +++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index b65712f7d..783b425fa 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -104,6 +104,19 @@ def __init__( selecting samples by cohort, or more than one sample_id) is rejected. """, + parameters=dict( + non_ref_only=""" + If True, only write sites where the sample's genotype + carries at least one non-reference allele (i.e. skip + sites where the sample is homozygous reference or + missing). Equivalent to filtering the output with + `bcftools view -e 'F_PASS(GT="ref") == 1'`, except that + missing genotype calls are also excluded here (whereas + that particular bcftools expression only excludes + homozygous reference calls, since a missing call is + neither "ref" nor selected by `-e`). + """, + ), returns=""" Path to the VCF output file. """, @@ -116,11 +129,12 @@ def snp_calls_to_vcf( sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, sample_indices: Optional[base_params.sample_indices] = None, - site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, + site_mask: Optional[base_params.site_mask] = None, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, fields: vcf_params.vcf_fields = ("GT",), + non_ref_only: bool = False, ) -> str: base_params._validate_sample_selection_params( sample_query=sample_query, sample_indices=sample_indices @@ -306,6 +320,16 @@ def snp_calls_to_vcf( a1 = gt_chunk_2d[:, :, 1] # (n_variants, n_samples) missing = (a0 < 0) | (a1 < 0) + # If non_ref_only, work out up front which variants + # to skip: those where the sample is homozygous + # reference (0/0) or missing. Computed vectorized + # across the whole chunk, same as `missing` above. + if non_ref_only: + is_hom_ref = (a0 == 0) & (a1 == 0) + skip_variant = (missing | is_hom_ref)[:, 0] + else: + skip_variant = None + # Build formatted GT strings using NumPy vectorization gt_formatted = np.empty( (gt_chunk.shape[0], n_samples), dtype=object @@ -323,6 +347,9 @@ def snp_calls_to_vcf( lines_to_write = [] for j in range(gt_chunk.shape[0]): + if skip_variant is not None and skip_variant[j]: + continue + chrom = contigs[contig_chunk[j]] pos = str(pos_chunk[j]) alleles = allele_chunk[j] diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index df5532abf..091a5dece 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -140,6 +140,125 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): ), f"byte-string repr in REF/ALT: REF={ref!r} ALT={alt!r}" +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_non_ref_only(fixture, api: SnpVcfExporter, tmp_path): + # non_ref_only=True should keep only sites where the sample's + # genotype carries at least one non-reference allele, dropping both + # homozygous reference (0/0) and missing (./.) calls. Equivalent in + # spirit to `bcftools view -e 'F_PASS(GT="ref") == 1'`, except that + # a missing call is also excluded here (that particular bcftools + # expression only excludes homozygous reference calls, since a + # missing call is neither "ref" nor caught by that `-e` filter). + region = random.choice(api.contigs) + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) + _, sample_query = _pick_single_sample_query(api, sample_sets) + + data_params = dict( + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) + + # Work out the expected set of non-ref, non-missing positions + # directly from the dataset, independently of snp_calls_to_vcf. + ds = api.snp_calls(**data_params) + gt = ds["call_genotype"].values[:, 0, :] # (variants, ploidy) + is_missing = (gt < 0).any(axis=1) + is_hom_ref = (gt == 0).all(axis=1) + expect_keep = ~is_missing & ~is_hom_ref + expected_positions = sorted(ds["variant_position"].values[expect_keep].tolist()) + + output_path = str(tmp_path / "test_non_ref_only.vcf") + api.snp_calls_to_vcf( + output_path=output_path, + non_ref_only=True, + **data_params, + ) + + with open(output_path) as f: + lines = f.readlines() + data_lines = [line for line in lines if not line.startswith("#")] + + # Every written site should have a non-ref, non-missing GT. + for line in data_lines: + fields_row = line.strip().split("\t") + gt_str = fields_row[9].split(":")[0] + assert gt_str != "./." + a0, a1 = gt_str.split("/") + assert not (a0 == "0" and a1 == "0") + + # And the set of positions written should exactly match what we + # expect directly from the dataset (no extras, none missing). + vcf_positions = sorted(int(line.split("\t")[1]) for line in data_lines) + assert vcf_positions == expected_positions + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_non_ref_only_defaults_to_false( + fixture, api: SnpVcfExporter, tmp_path +): + # Not passing non_ref_only should behave identically to passing + # non_ref_only=False (i.e. include homozygous reference / missing + # sites too) — this locks in the default. + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + + output_path_default = str(tmp_path / "default.vcf") + output_path_explicit = str(tmp_path / "explicit_false.vcf") + api.snp_calls_to_vcf( + output_path=output_path_default, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) + api.snp_calls_to_vcf( + output_path=output_path_explicit, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + non_ref_only=False, + ) + + with open(output_path_default) as f: + default_lines = f.readlines() + with open(output_path_explicit) as f: + explicit_lines = f.readlines() + assert default_lines == explicit_lines + + +@pytest.mark.skipif(shutil.which("bcftools") is None, reason="bcftools not installed") +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_non_ref_only_valid_per_bcftools( + fixture, api: SnpVcfExporter, tmp_path +): + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + + output_path = str(tmp_path / "test_non_ref_only_bcftools.vcf") + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + fields={"GT", "GQ", "AD", "MQ"}, + non_ref_only=True, + ) + + result = subprocess.run( + ["bcftools", "view", "-v", "snps", output_path], + capture_output=True, + text=True, + ) + assert result.returncode == 0, f"bcftools failed to parse output: {result.stderr}" + assert "Error" not in result.stderr + assert "should be declared as" not in result.stderr, result.stderr + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_requires_sample_sets_and_query( fixture, api: SnpVcfExporter, tmp_path From 050415a7bcb9c14c2e0165192c79998e90f0e1a2 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 11:15:30 +0100 Subject: [PATCH 15/38] Claude draft of bug fix with removing homozygous sites --- malariagen_data/anoph/to_vcf.py | 88 ++++++++++++++++++++++----- tests/anoph/test_vcf_exporter.py | 100 +++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 16 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 783b425fa..50ee39395 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -324,22 +324,82 @@ def snp_calls_to_vcf( # to skip: those where the sample is homozygous # reference (0/0) or missing. Computed vectorized # across the whole chunk, same as `missing` above. + # N.B., this uses the *original* (un-remapped) + # allele indices computed below — 0 always means REF + # both before and after remapping, so this check is + # unaffected by it. if non_ref_only: is_hom_ref = (a0 == 0) & (a1 == 0) skip_variant = (missing | is_hom_ref)[:, 0] else: skip_variant = None + # Decode alleles once per chunk (rather than + # per-variant further down) and work out, per + # variant, which of the ALT candidate slots are + # actually populated. call_genotype's allele indices + # refer to these *original* variant_allele slot + # positions (0=REF, 1..3=ALT candidates), which are + # not guaranteed to be contiguous from 1 — a site's + # only real ALT allele can sit in slot 2 or 3 while + # an earlier slot is empty. The ALT column written + # below only lists the populated slots, so genotype + # indices must be remapped to match that compacted + # numbering, or a GT value could end up referring to + # an ALT allele that isn't listed at all (or the + # wrong one). + decoded_alleles = np.empty(allele_chunk.shape, dtype=object) + for col in range(allele_chunk.shape[1]): + decoded_alleles[:, col] = [ + a.decode() if hasattr(a, "decode") else str(a) + for a in allele_chunk[:, col] + ] + is_present = decoded_alleles != "" + is_present[:, 0] = True # REF is always present + # compacted_index[i, k] = the index original slot k + # occupies in the ALT column for variant i, or -1 if + # slot k isn't populated there. + compacted_index = np.cumsum(is_present, axis=1) - 1 + compacted_index[~is_present] = -1 + + # Remap this chunk's genotype allele indices to the + # compacted numbering. n_samples is always 1 here + # (snp_calls_to_vcf only supports a single sample), + # so a0/a1 are worked with as flat (n_variants,) + # arrays. Clip before gathering so a missing + # genotype's sentinel value (-1) can't trigger an + # out-of-bounds index — the gathered result for + # those rows is discarded below anyway, since they + # are written as "./." based on `missing`, not on + # this remapping. + row_idx = np.arange(gt_chunk.shape[0]) + n_allele_slots = allele_chunk.shape[1] + remapped_a0 = compacted_index[ + row_idx, np.clip(a0[:, 0], 0, n_allele_slots - 1) + ] + remapped_a1 = compacted_index[ + row_idx, np.clip(a1[:, 0], 0, n_allele_slots - 1) + ] + # A remapped index of -1 means the genotype + # references an allele slot that variant_allele + # doesn't actually have populated at this site — + # inconsistent data that shouldn't occur, but is + # treated as missing defensively rather than writing + # a nonsensical negative allele index. + missing_or_unmapped = ( + missing[:, 0] | (remapped_a0 < 0) | (remapped_a1 < 0) + ) + # Build formatted GT strings using NumPy vectorization gt_formatted = np.empty( (gt_chunk.shape[0], n_samples), dtype=object ) - gt_formatted[missing] = "./." - present_idx = ~missing + gt_formatted[missing_or_unmapped, 0] = "./." + present_idx = ~missing_or_unmapped if np.any(present_idx): - a0_str = a0[present_idx].astype(str) - a1_str = a1[present_idx].astype(str) - gt_formatted[present_idx] = np.char.add( + a0_str = remapped_a0[present_idx].astype(str) + a1_str = remapped_a1[present_idx].astype(str) + gt_formatted[present_idx, 0] = np.char.add( np.char.add(a0_str, "/"), a1_str ) @@ -352,17 +412,13 @@ def snp_calls_to_vcf( chrom = contigs[contig_chunk[j]] pos = str(pos_chunk[j]) - alleles = allele_chunk[j] - ref = ( - alleles[0].decode() - if hasattr(alleles[0], "decode") - else str(alleles[0]) - ) - alt_alleles = [] - for a in alleles[1:]: - s = a.decode() if hasattr(a, "decode") else str(a) - if s: - alt_alleles.append(s) + # Reuse the chunk-level decode from above, so + # the ALT column built here is guaranteed + # consistent with the allele-index remapping + # used for GT (both derive from the same + # decoded_alleles/is_present arrays). + ref = decoded_alleles[j, 0] + alt_alleles = [s for s in decoded_alleles[j, 1:] if s] alt = ",".join(alt_alleles) if alt_alleles else "." # Build fixed VCF columns once per variant diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 091a5dece..a583b081a 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -4,7 +4,10 @@ import shutil import subprocess +import dask.array as da +import numpy as np import pytest +import xarray as xr from pytest_cases import parametrize_with_cases from malariagen_data import af1 as _af1 @@ -563,3 +566,100 @@ def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path) sample_query=sample_query, fields=("GQ",), ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_allele_index_remapping( + fixture, api: SnpVcfExporter, tmp_path, monkeypatch +): + # variant_allele slots for a site are not guaranteed to be + # contiguous from slot 1: a site's only real ALT allele can sit in + # slot 2 or 3 while an earlier slot is empty (cohort-wide allele + # arrays aren't necessarily left-justified per site). The ALT + # column only lists populated slots, so call_genotype's allele + # indices (which refer to the *original* slot positions) must be + # remapped to match, or a GT value can end up pointing at an ALT + # allele that isn't listed (or the wrong one) — exactly the bug + # that produced invalid records like "0/2" against a single-allele + # ALT column, which bcftools then silently mishandled. + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + contig = api.contigs[0] + + variant_allele = np.array( + [ + [b"A", b"", b"T", b""], # only real ALT in slot 2 + [b"A", b"T", b"", b""], # real ALT in slot 1 (unaffected case) + [b"A", b"", b"", b"T"], # only real ALT in slot 3 + [b"A", b"C", b"", b"T"], # two real ALTs, gap in slot 2 + ], + dtype="S1", + ) + call_genotype = np.array( + [ + [[0, 2]], # het for the slot-2 "T" -> ALT="T" -> expect 0/1 + [[0, 1]], # het for the slot-1 "T" -> ALT="T" -> expect 0/1 + [[3, 3]], # hom-alt for the slot-3 "T" -> ALT="T" -> expect 1/1 + [[0, 3]], # het for the slot-3 "T" -> ALT="C,T" -> expect 0/2 + ], + dtype="i1", + ) + expected = { + 100: ("T", "0/1"), + 200: ("T", "0/1"), + 300: ("T", "1/1"), + 400: ("C,T", "0/2"), + } + + ds = xr.Dataset( + data_vars={ + "call_genotype": ( + ["variants", "samples", "ploidy"], + da.from_array(call_genotype, chunks=(4, 1, 2)), + ), + "variant_allele": ( + ["variants", "alleles"], + da.from_array(variant_allele, chunks=(4, 4)), + ), + }, + coords={ + "variant_position": ( + "variants", + da.from_array(np.array([100, 200, 300, 400]), chunks=4), + ), + "variant_contig": ( + "variants", + da.from_array(np.array([0, 0, 0, 0], dtype="u1"), chunks=4), + ), + "sample_id": ("samples", np.array([sample])), + }, + attrs={"contigs": (contig,)}, + ) + monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) + + output_path = str(tmp_path / "test_allele_remap.vcf") + api.snp_calls_to_vcf( + output_path=output_path, + region=contig, + sample_sets=["dummy"], + sample_query=f"sample_id == '{sample}'", + ) + + with open(output_path) as f: + lines = f.readlines() + data_lines = [line for line in lines if not line.startswith("#")] + assert len(data_lines) == 4 + + for line in data_lines: + fields_row = line.strip().split("\t") + pos = int(fields_row[1]) + alt = fields_row[4] + gt = fields_row[9].split(":")[0] + expected_alt, expected_gt = expected[pos] + assert alt == expected_alt, f"at {pos}: expected ALT {expected_alt}, got {alt}" + assert gt == expected_gt, f"at {pos}: expected GT {expected_gt}, got {gt}" + # Every GT allele index must be valid for the ALT column that + # was actually written (i.e. in range for the number of ALT + # alleles listed), which is the invariant this fix guarantees. + n_alt_alleles = len(alt.split(",")) + for allele_idx in gt.split("/"): + assert int(allele_idx) <= n_alt_alleles From 8e4b62eec05d4cf61ccb157b77369c803e8047f2 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 11:53:42 +0100 Subject: [PATCH 16/38] still trying to get to_vcf correct Claude thinks its something to to with compression despite me testing on uncompressed outputs, so I am unconvinced --- malariagen_data/anoph/to_coverage.py | 5 + malariagen_data/anoph/to_vcf.py | 16 +- malariagen_data/anoph/to_vcf_cnv.py | 20 +- malariagen_data/bgzf.py | 125 +++++++++++ tests/anoph/test_coverage_exporter.py | 295 ++++++++++++++++++++++++++ tests/anoph/test_igv_coverage.py | 143 +++++++++++++ tests/anoph/test_vcf_exporter.py | 13 +- tests/anoph/test_vcf_exporter_cnv.py | 10 + tests/test_bgzf.py | 95 +++++++++ 9 files changed, 710 insertions(+), 12 deletions(-) create mode 100644 malariagen_data/bgzf.py create mode 100644 tests/anoph/test_coverage_exporter.py create mode 100644 tests/anoph/test_igv_coverage.py create mode 100644 tests/test_bgzf.py diff --git a/malariagen_data/anoph/to_coverage.py b/malariagen_data/anoph/to_coverage.py index dc5d1c234..ee0248693 100644 --- a/malariagen_data/anoph/to_coverage.py +++ b/malariagen_data/anoph/to_coverage.py @@ -15,6 +15,11 @@ def _bedgraph_opener(output_path: str): + # N.B., plain gzip is intentional here, unlike the VCF exporters + # (see malariagen_data.bgzf): bedGraph doesn't carry the same + # ecosystem-wide expectation that a `.gz` file specifically be + # BGZF, and IGV loads a plain-gzipped bedGraph track without + # issue. compress = output_path.endswith(".gz") return gzip.open if compress else open diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 50ee39395..3139eefaa 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -1,4 +1,3 @@ -import gzip import os import re from datetime import date @@ -8,6 +7,7 @@ import numpy as np from numpydoc_decorator import doc # type: ignore +from ..bgzf import bgzf_open from .snp_data import AnophelesSnpData from . import base_params from . import plink_params @@ -177,7 +177,7 @@ def snp_calls_to_vcf( chunks=chunks, ) - # Confirm inputs actually resolved to exactly + # Confirm inputs resolve to exactly # one sample within the given sample_sets # checked defensively rather than silently written # out as a multi-sample VCF. @@ -192,7 +192,11 @@ def snp_calls_to_vcf( sample_ids = ds["sample_id"].values contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") - opener = gzip.open if compress else open + # N.B., genuine BGZF, not plain gzip: tools that specifically + # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can + # fail to read, or silently mis-parse, plain gzip even though + # it decompresses fine as a byte stream. + opener = bgzf_open if compress else open # Determine which extra fields to include. include_gq = "GQ" in fields @@ -285,7 +289,7 @@ def snp_calls_to_vcf( ) # Fetch requested optional fields for this chunk - # as a single batched call. If any of them fail + # as a single batched call. If any fail # to load, fall back to "." for all requested # optional fields in this chunk — these arrays live # in the same region of the same store, so a failure @@ -345,9 +349,7 @@ def snp_calls_to_vcf( # an earlier slot is empty. The ALT column written # below only lists the populated slots, so genotype # indices must be remapped to match that compacted - # numbering, or a GT value could end up referring to - # an ALT allele that isn't listed at all (or the - # wrong one). + # numbering decoded_alleles = np.empty(allele_chunk.shape, dtype=object) for col in range(allele_chunk.shape[1]): decoded_alleles[:, col] = [ diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py index fbc16f520..676897e5a 100644 --- a/malariagen_data/anoph/to_vcf_cnv.py +++ b/malariagen_data/anoph/to_vcf_cnv.py @@ -1,4 +1,3 @@ -import gzip import os from datetime import date from typing import List, Optional, Sequence @@ -6,6 +5,7 @@ import numpy as np from numpydoc_decorator import doc # type: ignore +from ..bgzf import bgzf_open from .cnv_data import AnophelesCnvData from . import base_params from . import cnv_params @@ -120,7 +120,11 @@ def cnv_hmm_to_vcf( sample_ids = ds["sample_id"].values contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") - opener = gzip.open if compress else open + # N.B., genuine BGZF, not plain gzip: tools that specifically + # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can + # fail to read, or silently mis-parse, plain gzip even though + # it decompresses fine as a byte stream. + opener = bgzf_open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( @@ -215,7 +219,11 @@ def cnv_coverage_calls_to_vcf( sample_ids = ds["sample_id"].values contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") - opener = gzip.open if compress else open + # N.B., genuine BGZF, not plain gzip: tools that specifically + # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can + # fail to read, or silently mis-parse, plain gzip even though + # it decompresses fine as a byte stream. + opener = bgzf_open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( @@ -329,7 +337,11 @@ def cnv_discordant_read_calls_to_vcf( sample_ids = ds["sample_id"].values all_contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") - opener = gzip.open if compress else open + # N.B., genuine BGZF, not plain gzip: tools that specifically + # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can + # fail to read, or silently mis-parse, plain gzip even though + # it decompresses fine as a byte stream. + opener = bgzf_open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( diff --git a/malariagen_data/bgzf.py b/malariagen_data/bgzf.py new file mode 100644 index 000000000..d49a35853 --- /dev/null +++ b/malariagen_data/bgzf.py @@ -0,0 +1,125 @@ +"""Minimal, write-only BGZF (Blocked GZip Format) support. + +BGZF is the compression format used throughout the SAM/BAM/VCF tooling +ecosystem (samtools, bcftools, tabix, bedtools, IGV, ...) for +compressed, indexable files. Structurally, it's just a sequence of +ordinary gzip members, each holding up to ~64KB of uncompressed data, +with a small extra header field recording each member's total size, +plus a fixed, empty final member used as an EOF marker. + +Python's standard library `gzip.open()` produces valid gzip, but not +valid BGZF: tools that specifically expect BGZF for a `.vcf.gz` (or +similar) file can fail to read it correctly, or silently mis-parse it, +even though plain gzip decompresses just fine as a byte stream. This +module exists so that `.gz` output written by malariagen_data is +genuine BGZF, and therefore usable with the wider standard toolset +(bcftools, tabix, bedtools, etc.), not just tools that happen to +tolerate plain gzip. + +See the BGZF section of the SAM specification for the on-disk format +this implements: https://samtools.github.io/hts-specs/SAMv1.pdf +""" + +import struct +import zlib +from typing import Optional + +# The fixed, empty BGZF block used to mark genuine end-of-file (as +# opposed to a truncated file). This exact byte sequence is part of the +# BGZF specification, not something we generate ourselves. +_BGZF_EOF_MARKER = bytes.fromhex( + "1f8b08040000000000ff0600424302001b0003000000000000000000" +) + +# Maximum amount of *uncompressed* data placed in a single BGZF block. +# Kept comfortably under the 16-bit BSIZE field's range (a block's +# total on-disk size, header and footer included, must fit in 65536 +# bytes) even in the worst case where compression doesn't shrink the +# input at all; this matches the conservative block size used by other +# BGZF writers (e.g. Biopython's `Bio.bgzf`). +_MAX_BLOCK_UNCOMPRESSED_SIZE = 65280 + + +def _compress_bgzf_block(data: bytes, level: int = 6) -> bytes: + """Compress `data` (must be <= _MAX_BLOCK_UNCOMPRESSED_SIZE bytes) + into a single, standalone BGZF block.""" + compressor = zlib.compressobj(level, zlib.DEFLATED, -15) + compressed = compressor.compress(data) + compressor.flush(zlib.Z_FINISH) + crc = zlib.crc32(data) & 0xFFFFFFFF + isize = len(data) & 0xFFFFFFFF + + # Block layout: 18-byte header (with the BGZF "BC" extra field), + # the compressed payload, then an 8-byte footer (CRC32 + ISIZE) — + # the same footer any gzip member ends with. + block_size = 18 + len(compressed) + 8 + header = struct.pack( + " None: + self._buffer.extend(text.encode(self._encoding)) + while len(self._buffer) >= _MAX_BLOCK_UNCOMPRESSED_SIZE: + chunk = bytes(self._buffer[:_MAX_BLOCK_UNCOMPRESSED_SIZE]) + del self._buffer[:_MAX_BLOCK_UNCOMPRESSED_SIZE] + self._fh.write(_compress_bgzf_block(chunk)) + + def close(self) -> None: + if self._closed: + return + if self._buffer: + self._fh.write(_compress_bgzf_block(bytes(self._buffer))) + self._buffer = bytearray() + self._fh.write(_BGZF_EOF_MARKER) + self._fh.close() + self._closed = True + + def __enter__(self) -> "BgzfWriter": + return self + + def __exit__(self, *exc_info) -> None: + self.close() + + +def bgzf_open(path: str, mode: str = "wt", encoding: Optional[str] = "utf-8"): + """Open `path` for BGZF-compressed text writing. + + Signature-compatible with `gzip.open(path, "wt")` for the subset of + usage malariagen_data's VCF/text exporters need (write-only, text + mode), so it can be used as a drop-in replacement for `gzip.open` + wherever genuine BGZF (rather than plain gzip) output is required. + """ + if mode not in ("wt", "w"): + raise ValueError( + f"Unsupported mode {mode!r}: bgzf_open() only supports writing text " + "('wt' or 'w')." + ) + return BgzfWriter(path, encoding=encoding or "utf-8") diff --git a/tests/anoph/test_coverage_exporter.py b/tests/anoph/test_coverage_exporter.py new file mode 100644 index 000000000..d0770af3e --- /dev/null +++ b/tests/anoph/test_coverage_exporter.py @@ -0,0 +1,295 @@ +import gzip +import os +import random + +import dask.array as da +import numpy as np +import pytest +import xarray as xr +from pytest_cases import parametrize_with_cases + +from malariagen_data import af1 as _af1 +from malariagen_data import ag3 as _ag3 + +from malariagen_data.anoph.to_coverage import CoverageExporter + + +@pytest.fixture +def ag3_sim_api(ag3_sim_fixture): + return CoverageExporter( + url=ag3_sim_fixture.url, + public_url=ag3_sim_fixture.url, + config_path=_ag3.CONFIG_PATH, + major_version_number=_ag3.MAJOR_VERSION_NUMBER, + major_version_path=_ag3.MAJOR_VERSION_PATH, + pre=True, + aim_metadata_dtype={ + "aim_species_fraction_arab": "float64", + "aim_species_fraction_colu": "float64", + "aim_species_fraction_colu_no2l": "float64", + "aim_species_gambcolu_arabiensis": object, + "aim_species_gambiae_coluzzii": object, + "aim_species": object, + }, + gff_gene_type="gene", + gff_gene_name_attribute="Name", + gff_default_attributes=("ID", "Parent", "Name", "description"), + results_cache=ag3_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="gamb_colu", + discordant_read_calls_analysis=ag3_sim_fixture.config[ + "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" + ], + ) + + +@pytest.fixture +def af1_sim_api(af1_sim_fixture): + return CoverageExporter( + url=af1_sim_fixture.url, + public_url=af1_sim_fixture.url, + config_path=_af1.CONFIG_PATH, + major_version_number=_af1.MAJOR_VERSION_NUMBER, + major_version_path=_af1.MAJOR_VERSION_PATH, + pre=False, + gff_gene_type="protein_coding_gene", + gff_gene_name_attribute="Note", + gff_default_attributes=("ID", "Parent", "Note", "description"), + results_cache=af1_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="funestus", + discordant_read_calls_analysis=None, + ) + + +def case_ag3_sim(ag3_sim_fixture, ag3_sim_api): + return ag3_sim_fixture, ag3_sim_api + + +def case_af1_sim(af1_sim_fixture, af1_sim_api): + return af1_sim_fixture, af1_sim_api + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph(fixture, api: CoverageExporter, tmp_path): + region = random.choice(api.contigs) + sample = str(np.random.choice(api.sample_metadata()["sample_id"])) + + output_path = str(tmp_path / "test_coverage.bedgraph") + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample=sample, + ) + + assert os.path.exists(output_path) + + with open(output_path) as f: + lines = f.readlines() + + assert lines[0].startswith("track type=bedGraph") + + data_lines = lines[1:] + assert len(data_lines) > 0 + + for line in data_lines: + fields = line.rstrip("\n").split("\t") + assert len(fields) == 4 + chrom, start, end, value = fields + assert chrom == region + assert int(start) >= 0 + assert int(end) > int(start) + # Should be a valid number and non-negative (masked/missing + # values are skipped rather than written). + assert float(value) >= 0 + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph_raw_cov(fixture, api: CoverageExporter, tmp_path): + region = api.contigs[0] + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + + output_path = str(tmp_path / "test_coverage_raw.bedgraph") + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample=sample, + field="RawCov", + ) + assert os.path.exists(output_path) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph_invalid_field( + fixture, api: CoverageExporter, tmp_path +): + region = api.contigs[0] + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + + output_path = str(tmp_path / "test_coverage_bad.bedgraph") + with pytest.raises(ValueError, match="Unknown coverage field"): + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample=sample, + field="NotAField", + ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph_unknown_sample( + fixture, api: CoverageExporter, tmp_path +): + region = api.contigs[0] + output_path = str(tmp_path / "test_coverage_unknown.bedgraph") + with pytest.raises(ValueError, match="No data found for sample"): + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample="not_a_real_sample", + ) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph_overwrite( + fixture, api: CoverageExporter, tmp_path +): + region = api.contigs[0] + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + output_path = str(tmp_path / "test_coverage.bedgraph") + + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, region=region, sample=sample + ) + mtime_first = os.path.getmtime(output_path) + + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, region=region, sample=sample + ) + assert os.path.getmtime(output_path) == mtime_first + + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, region=region, sample=sample, overwrite=True + ) + assert os.path.exists(output_path) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_cnv_hmm_coverage_to_bedgraph_gzip(fixture, api: CoverageExporter, tmp_path): + region = api.contigs[0] + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + output_path = str(tmp_path / "test_coverage.bedgraph.gz") + + api.cnv_hmm_coverage_to_bedgraph( + output_path=output_path, region=region, sample=sample + ) + assert os.path.exists(output_path) + + with gzip.open(output_path, "rt") as f: + first_line = f.readline() + assert first_line.startswith("track type=bedGraph") + + +@parametrize_with_cases("fixture,api", cases=".") +def test_snp_calls_coverage_to_bedgraph(fixture, api: CoverageExporter, tmp_path): + region = random.choice(api.contigs) + sample = str(np.random.choice(api.sample_metadata()["sample_id"])) + + output_path = str(tmp_path / "test_snp_coverage.bedgraph") + api.snp_calls_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample=sample, + ) + + assert os.path.exists(output_path) + + with open(output_path) as f: + lines = f.readlines() + + assert lines[0].startswith("track type=bedGraph") + + # N.B., the simulated AD data is filled with a missing-value + # sentinel (-1) for every site, so no data lines are expected here; + # this exercises that missing values are skipped rather than + # written as misleading zero-depth entries. The arithmetic for + # sites that do have depth is checked separately below, using a + # synthetic dataset. + for line in lines[1:]: + fields = line.rstrip("\n").split("\t") + assert len(fields) == 4 + chrom, start, end, value = fields + assert chrom == region + assert int(end) == int(start) + 1 + assert int(value) >= 0 + + +@parametrize_with_cases("fixture,api", cases=".") +def test_snp_calls_coverage_to_bedgraph_depth_values( + fixture, api: CoverageExporter, tmp_path, monkeypatch +): + # Exercise the depth arithmetic directly against a small synthetic + # dataset, since the simulated fixture data fills call_AD with a + # missing-value sentinel throughout (see test above). + contig = api.contigs[0] + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + + ds = xr.Dataset( + data_vars={ + "call_AD": ( + ["variants", "samples", "alleles"], + da.from_array( + np.array( + [ + [[10, 2, 0, 0]], # total depth 12 + [[-1, -1, -1, -1]], # missing, should be skipped + [[5, -1, 0, 0]], # negative components clipped to 0 + ], + dtype="i2", + ), + chunks=(2, 1, 4), + ), + ), + }, + coords={ + "variant_position": ( + "variants", + da.from_array(np.array([100, 200, 300]), chunks=2), + ), + "variant_contig": ( + "variants", + da.from_array(np.array([0, 0, 0], dtype="u1"), chunks=2), + ), + "sample_id": ("samples", np.array([sample])), + }, + attrs={"contigs": (contig,)}, + ) + monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) + + output_path = str(tmp_path / "test_snp_coverage_values.bedgraph") + api.snp_calls_coverage_to_bedgraph( + output_path=output_path, + region=contig, + sample=sample, + ) + + with open(output_path) as f: + lines = f.readlines() + + data_lines = [line.rstrip("\n").split("\t") for line in lines[1:]] + assert data_lines == [ + [contig, "99", "100", "12"], + [contig, "299", "300", "5"], + ] + + +@parametrize_with_cases("fixture,api", cases=".") +def test_snp_calls_coverage_to_bedgraph_unknown_sample( + fixture, api: CoverageExporter, tmp_path +): + region = api.contigs[0] + output_path = str(tmp_path / "test_snp_coverage_unknown.bedgraph") + with pytest.raises(ValueError, match="No data found for sample"): + api.snp_calls_coverage_to_bedgraph( + output_path=output_path, + region=region, + sample="not_a_real_sample", + ) diff --git a/tests/anoph/test_igv_coverage.py b/tests/anoph/test_igv_coverage.py new file mode 100644 index 000000000..a39a0154c --- /dev/null +++ b/tests/anoph/test_igv_coverage.py @@ -0,0 +1,143 @@ +import numpy as np +import pytest +from pytest_cases import parametrize_with_cases + +from malariagen_data import af1 as _af1 +from malariagen_data import ag3 as _ag3 +from malariagen_data.anoph.igv import AnophelesIgv +from malariagen_data.anoph.to_coverage import CoverageExporter + + +class _IgvWithCoverage(CoverageExporter, AnophelesIgv): + """Combines AnophelesIgv with CoverageExporter, the way the + top-level Ag3/Af1 data resource classes do, so that the local + coverage fallback functionality can be exercised in isolation.""" + + +@pytest.fixture +def ag3_sim_api(ag3_sim_fixture): + return AnophelesIgv( + url=ag3_sim_fixture.url, + public_url=ag3_sim_fixture.url, + config_path=_ag3.CONFIG_PATH, + major_version_number=_ag3.MAJOR_VERSION_NUMBER, + major_version_path=_ag3.MAJOR_VERSION_PATH, + pre=True, + aim_metadata_dtype={ + "aim_species_fraction_arab": "float64", + "aim_species_fraction_colu": "float64", + "aim_species_fraction_colu_no2l": "float64", + "aim_species_gambcolu_arabiensis": object, + "aim_species_gambiae_coluzzii": object, + "aim_species": object, + }, + gff_gene_type="gene", + gff_gene_name_attribute="Name", + gff_default_attributes=("ID", "Parent", "Name", "description"), + default_site_mask="gamb_colu_arab", + results_cache=ag3_sim_fixture.results_cache_path.as_posix(), + ) + + +@pytest.fixture +def ag3_sim_api_with_coverage(ag3_sim_fixture): + return _IgvWithCoverage( + url=ag3_sim_fixture.url, + public_url=ag3_sim_fixture.url, + config_path=_ag3.CONFIG_PATH, + major_version_number=_ag3.MAJOR_VERSION_NUMBER, + major_version_path=_ag3.MAJOR_VERSION_PATH, + pre=True, + aim_metadata_dtype={ + "aim_species_fraction_arab": "float64", + "aim_species_fraction_colu": "float64", + "aim_species_fraction_colu_no2l": "float64", + "aim_species_gambcolu_arabiensis": object, + "aim_species_gambiae_coluzzii": object, + "aim_species": object, + }, + gff_gene_type="gene", + gff_gene_name_attribute="Name", + gff_default_attributes=("ID", "Parent", "Name", "description"), + default_site_mask="gamb_colu_arab", + results_cache=ag3_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="gamb_colu", + discordant_read_calls_analysis=ag3_sim_fixture.config[ + "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" + ], + ) + + +@pytest.fixture +def af1_sim_api_with_coverage(af1_sim_fixture): + return _IgvWithCoverage( + url=af1_sim_fixture.url, + public_url=af1_sim_fixture.url, + config_path=_af1.CONFIG_PATH, + major_version_number=_af1.MAJOR_VERSION_NUMBER, + major_version_path=_af1.MAJOR_VERSION_PATH, + pre=False, + gff_gene_type="protein_coding_gene", + gff_gene_name_attribute="Note", + gff_default_attributes=("ID", "Parent", "Note", "description"), + default_site_mask="funestus", + results_cache=af1_sim_fixture.results_cache_path.as_posix(), + default_coverage_calls_analysis="funestus", + discordant_read_calls_analysis=None, + ) + + +def case_ag3_sim(ag3_sim_fixture, ag3_sim_api_with_coverage): + return ag3_sim_fixture, ag3_sim_api_with_coverage + + +def case_af1_sim(af1_sim_fixture, af1_sim_api_with_coverage): + return af1_sim_fixture, af1_sim_api_with_coverage + + +@parametrize_with_cases("fixture,api", cases=".") +def test_view_coverage(fixture, api: _IgvWithCoverage): + region = api.contigs[0] + sample = str(np.random.choice(api.sample_metadata()["sample_id"])) + ret = api.view_coverage(region=region, sample=sample, init=False) + # No return value to avoid cluttering notebook output. + assert ret is None + + +@parametrize_with_cases("fixture,api", cases=".") +def test_view_alignments_with_local_coverage_fallback(fixture, api: _IgvWithCoverage): + region = api.contigs[0] + sample = str(np.random.choice(api.sample_metadata()["sample_id"])) + ret = api.view_alignments( + region=region, + sample=sample, + init=False, + local_coverage_fallback=True, + ) + assert ret is None + + +@parametrize_with_cases("fixture,api", cases=".") +def test_view_coverage_writes_bedgraph(fixture, api: _IgvWithCoverage, tmp_path): + region = api.contigs[0] + sample = str(np.random.choice(api.sample_metadata()["sample_id"])) + output_path = str(tmp_path / "coverage.bedgraph") + api.view_coverage(region=region, sample=sample, init=False, output_path=output_path) + with open(output_path) as f: + first_line = f.readline() + assert first_line.startswith("track type=bedGraph") + + +def test_local_coverage_fallback_requires_cnv_mixin(ag3_sim_fixture, ag3_sim_api): + # Plain AnophelesIgv, without CoverageExporter mixed in, should + # raise a clear error rather than an AttributeError if asked for a + # local coverage track. + region = ag3_sim_api.contigs[0] + sample = str(np.random.choice(ag3_sim_api.sample_metadata()["sample_id"])) + with pytest.raises(NotImplementedError): + ag3_sim_api.view_alignments( + region=region, + sample=sample, + init=False, + local_coverage_fallback=True, + ) diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index a583b081a..b320a947d 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -415,11 +415,22 @@ def test_vcf_exporter_gzip(fixture, api: SnpVcfExporter, tmp_path): ) assert os.path.exists(output_path) - # Verify it's valid gzip. + # Verify it's valid gzip (BGZF is valid gzip, so this works either + # way; the stronger, BGZF-specific check follows below). with gzip.open(output_path, "rt") as f: first_line = f.readline() assert first_line.strip() == "##fileformat=VCFv4.3" + # Verify it's specifically valid BGZF, not just plain gzip: this is + # what tools like tabix/bedtools require for .vcf.gz files, and + # what distinguishes genuine BGZF from a plain gzip stream that + # happens to decompress fine but isn't block-structured. + if shutil.which("bgzip") is not None: + result = subprocess.run( + ["bgzip", "-t", output_path], capture_output=True, text=True + ) + assert result.returncode == 0, f"not valid BGZF: {result.stderr}" + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): diff --git a/tests/anoph/test_vcf_exporter_cnv.py b/tests/anoph/test_vcf_exporter_cnv.py index e111ce70b..8081cef1c 100644 --- a/tests/anoph/test_vcf_exporter_cnv.py +++ b/tests/anoph/test_vcf_exporter_cnv.py @@ -1,6 +1,8 @@ import gzip import os import random +import shutil +import subprocess import pytest from pytest_cases import parametrize_with_cases @@ -232,3 +234,11 @@ def test_cnv_hmm_to_vcf_gzip(fixture, api: CnvVcfExporter, tmp_path): with gzip.open(output_path, "rt") as f: first_line = f.readline() assert first_line.strip() == "##fileformat=VCFv4.3" + + # Verify it's specifically valid BGZF, not just plain gzip — what + # tools like tabix/bedtools require for .vcf.gz files. + if shutil.which("bgzip") is not None: + result = subprocess.run( + ["bgzip", "-t", output_path], capture_output=True, text=True + ) + assert result.returncode == 0, f"not valid BGZF: {result.stderr}" diff --git a/tests/test_bgzf.py b/tests/test_bgzf.py new file mode 100644 index 000000000..38e8e5d61 --- /dev/null +++ b/tests/test_bgzf.py @@ -0,0 +1,95 @@ +import gzip +import shutil +import subprocess + +import pytest + +from malariagen_data.bgzf import _MAX_BLOCK_UNCOMPRESSED_SIZE, bgzf_open + + +def test_bgzf_round_trip(tmp_path): + output_path = str(tmp_path / "test.txt.gz") + lines = [f"line {i}\n" for i in range(100)] + + with bgzf_open(output_path, "wt") as f: + for line in lines: + f.write(line) + + # BGZF is valid gzip, so a plain gzip reader must be able to read + # the exact content back. + with gzip.open(output_path, "rt") as f: + content = f.read() + assert content == "".join(lines) + + +def test_bgzf_multi_block_round_trip(tmp_path): + # Write enough data to force multiple BGZF blocks, and include + # content that lands exactly on, just under, and just over a block + # boundary, to exercise the block-splitting logic. + output_path = str(tmp_path / "test_multiblock.txt.gz") + line = "the quick brown fox jumps over the lazy dog 0123456789\n" + n_lines = (_MAX_BLOCK_UNCOMPRESSED_SIZE // len(line)) * 3 + 7 + expected = "".join(f"{i}:{line}" for i in range(n_lines)) + + with bgzf_open(output_path, "wt") as f: + for i in range(n_lines): + f.write(f"{i}:{line}") + + with gzip.open(output_path, "rt") as f: + content = f.read() + assert content == expected + + +def test_bgzf_empty_file(tmp_path): + # Writing nothing should still produce a valid (if empty) BGZF + # file, i.e. just the EOF marker. + output_path = str(tmp_path / "test_empty.txt.gz") + with bgzf_open(output_path, "wt"): + pass + + with gzip.open(output_path, "rt") as f: + content = f.read() + assert content == "" + + +def test_bgzf_rejects_binary_mode(tmp_path): + output_path = str(tmp_path / "test.txt.gz") + with pytest.raises(ValueError): + bgzf_open(output_path, "wb") + + +@pytest.mark.skipif(shutil.which("bgzip") is None, reason="bgzip not installed") +def test_bgzf_valid_per_bgzip(tmp_path): + # The definitive check: the reference BGZF implementation itself + # must accept this as valid BGZF, not just "some gzip stream that + # happens to decompress correctly." + output_path = str(tmp_path / "test.txt.gz") + with bgzf_open(output_path, "wt") as f: + for i in range(10_000): + f.write(f"line {i}\n") + + result = subprocess.run( + ["bgzip", "-t", output_path], capture_output=True, text=True + ) + assert result.returncode == 0, f"not valid BGZF: {result.stderr}" + + +@pytest.mark.skipif(shutil.which("tabix") is None, reason="tabix not installed") +def test_bgzf_tabix_indexable(tmp_path): + # tabix specifically requires genuine BGZF block structure to + # build an index at all; plain gzip fails here even though it + # decompresses fine. This is the property that made bedtools (and + # other BGZF-aware tools) unable to read plain-gzip VCF output + # correctly, even though bcftools tolerated it. + output_path = str(tmp_path / "test.vcf.gz") + with bgzf_open(output_path, "wt") as f: + f.write("##fileformat=VCFv4.3\n") + f.write("##contig=\n") + f.write("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n") + for pos in (100, 200, 300): + f.write(f"2R\t{pos}\t.\tA\tT\t.\t.\t.\n") + + result = subprocess.run( + ["tabix", "-p", "vcf", output_path], capture_output=True, text=True + ) + assert result.returncode == 0, f"tabix failed to index: {result.stderr}" From 417ddb703d4ef1705013ca0ce865e211e3945700 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 13:09:57 +0100 Subject: [PATCH 17/38] removing Claudes allele remapping to see if that improves results --- malariagen_data/anoph/to_vcf.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 3139eefaa..af866b7e4 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -414,15 +414,18 @@ def snp_calls_to_vcf( chrom = contigs[contig_chunk[j]] pos = str(pos_chunk[j]) - # Reuse the chunk-level decode from above, so - # the ALT column built here is guaranteed - # consistent with the allele-index remapping - # used for GT (both derive from the same - # decoded_alleles/is_present arrays). - ref = decoded_alleles[j, 0] - alt_alleles = [s for s in decoded_alleles[j, 1:] if s] + alleles = allele_chunk[j] + ref = ( + alleles[0].decode() + if hasattr(alleles[0], "decode") + else str(alleles[0]) + ) + alt_alleles = [] + for a in alleles[1:]: + s = a.decode() if hasattr(a, "decode") else str(a) + if s: + alt_alleles.append(s) alt = ",".join(alt_alleles) if alt_alleles else "." - # Build fixed VCF columns once per variant fixed_cols = ( f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\t.\t{format_str}\t" From b4876a6b3619f3d5013d0cb2861101ead50b2d58 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 14:36:34 +0100 Subject: [PATCH 18/38] claudes last attempt, problems persisted, going to revert to a better version and figure out removing homozygous sites --- malariagen_data/anoph/to_vcf.py | 78 ++++++++++++++++++++------------ tests/anoph/test_vcf_exporter.py | 73 ++++++++++++++++++++++-------- 2 files changed, 101 insertions(+), 50 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index af866b7e4..00a243dfe 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -340,27 +340,50 @@ def snp_calls_to_vcf( # Decode alleles once per chunk (rather than # per-variant further down) and work out, per - # variant, which of the ALT candidate slots are - # actually populated. call_genotype's allele indices - # refer to these *original* variant_allele slot - # positions (0=REF, 1..3=ALT candidates), which are - # not guaranteed to be contiguous from 1 — a site's - # only real ALT allele can sit in slot 2 or 3 while - # an earlier slot is empty. The ALT column written - # below only lists the populated slots, so genotype - # indices must be remapped to match that compacted - # numbering + # variant, which of the (REF + 3 ALT candidate) + # variant_allele slots to actually write to the ALT + # column. variant_allele lists a fixed, canonical + # set of alternate bases per site regardless of + # whether they're relevant to *this* sample — e.g. + # for a REF=C site it lists "A,T,G" as ALT + # candidates even if this sample is only ever + # heterozygous for T, with zero read support for A + # or G. Writing all of them to ALT produces a + # non-standard single-sample VCF (real single-sample + # VCFs only list alleles the sample's own genotype + # actually uses) and breaks REF/ALT-based comparison + # against any VCF that follows that convention, + # since two VCFs listing the "same" call at the same + # position end up with different ALT strings. So + # only a slot that is both non-empty *and* actually + # referenced by this sample's genotype is kept; the + # remaining slots are dropped from ALT, and + # genotype indices remapped to match, exactly as for + # a genuinely empty slot. decoded_alleles = np.empty(allele_chunk.shape, dtype=object) for col in range(allele_chunk.shape[1]): decoded_alleles[:, col] = [ a.decode() if hasattr(a, "decode") else str(a) for a in allele_chunk[:, col] ] + n_allele_slots = allele_chunk.shape[1] is_present = decoded_alleles != "" + + slot_referenced = np.zeros_like(is_present) + slot_referenced[:, 0] = True # REF is always kept + valid = ~missing[:, 0] + row_idx = np.arange(gt_chunk.shape[0]) + safe_a0 = np.clip(a0[:, 0], 0, n_allele_slots - 1) + safe_a1 = np.clip(a1[:, 0], 0, n_allele_slots - 1) + slot_referenced[row_idx[valid], safe_a0[valid]] = True + slot_referenced[row_idx[valid], safe_a1[valid]] = True + + is_present = is_present & slot_referenced is_present[:, 0] = True # REF is always present + # compacted_index[i, k] = the index original slot k # occupies in the ALT column for variant i, or -1 if - # slot k isn't populated there. + # slot k isn't kept there. compacted_index = np.cumsum(is_present, axis=1) - 1 compacted_index[~is_present] = -1 @@ -374,14 +397,8 @@ def snp_calls_to_vcf( # those rows is discarded below anyway, since they # are written as "./." based on `missing`, not on # this remapping. - row_idx = np.arange(gt_chunk.shape[0]) - n_allele_slots = allele_chunk.shape[1] - remapped_a0 = compacted_index[ - row_idx, np.clip(a0[:, 0], 0, n_allele_slots - 1) - ] - remapped_a1 = compacted_index[ - row_idx, np.clip(a1[:, 0], 0, n_allele_slots - 1) - ] + remapped_a0 = compacted_index[row_idx, safe_a0] + remapped_a1 = compacted_index[row_idx, safe_a1] # A remapped index of -1 means the genotype # references an allele slot that variant_allele # doesn't actually have populated at this site — @@ -414,18 +431,19 @@ def snp_calls_to_vcf( chrom = contigs[contig_chunk[j]] pos = str(pos_chunk[j]) - alleles = allele_chunk[j] - ref = ( - alleles[0].decode() - if hasattr(alleles[0], "decode") - else str(alleles[0]) - ) - alt_alleles = [] - for a in alleles[1:]: - s = a.decode() if hasattr(a, "decode") else str(a) - if s: - alt_alleles.append(s) + # Reuse the chunk-level decode from above, so + # the ALT column built here is guaranteed + # consistent with the allele-index remapping + # used for GT (both derive from the same + # decoded_alleles/is_present arrays). + ref = decoded_alleles[j, 0] + alt_alleles = [ + decoded_alleles[j, k] + for k in range(1, n_allele_slots) + if is_present[j, k] + ] alt = ",".join(alt_alleles) if alt_alleles else "." + # Build fixed VCF columns once per variant fixed_cols = ( f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\t.\t{format_str}\t" diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index b320a947d..2edc02c27 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -583,25 +583,42 @@ def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path) def test_vcf_exporter_allele_index_remapping( fixture, api: SnpVcfExporter, tmp_path, monkeypatch ): - # variant_allele slots for a site are not guaranteed to be - # contiguous from slot 1: a site's only real ALT allele can sit in - # slot 2 or 3 while an earlier slot is empty (cohort-wide allele - # arrays aren't necessarily left-justified per site). The ALT - # column only lists populated slots, so call_genotype's allele - # indices (which refer to the *original* slot positions) must be - # remapped to match, or a GT value can end up pointing at an ALT - # allele that isn't listed (or the wrong one) — exactly the bug - # that produced invalid records like "0/2" against a single-allele - # ALT column, which bcftools then silently mishandled. + # ALT should only ever list alleles that are both (a) genuinely + # populated in variant_allele and (b) actually referenced by this + # sample's own genotype. variant_allele lists a fixed, canonical + # set of alternate bases per site (e.g. for REF=A it can list + # "C,T,G" regardless of what's actually segregating, let alone + # relevant to one particular sample), and call_genotype's allele + # indices refer to those *original* slot positions, which are not + # guaranteed to be contiguous from 1 either (a site's only real ALT + # allele can sit in slot 2 or 3 while an earlier slot is empty). + # Writing every populated-but-irrelevant slot to ALT (a) produces + # invalid records when combined with un-remapped genotype indices + # (e.g. "0/2" against a single-allele ALT column, which bcftools + # then silently mishandled), and (b) even once indices are + # correctly remapped, produces a non-standard single-sample VCF + # (real single-sample VCFs only list alleles that sample's + # genotype actually uses) that fails REF/ALT-based comparison + # against any VCF following that convention — two VCFs recording + # the "same" call at the same position end up with different ALT + # strings purely because of unrelated candidate alleles. sample = str(api.sample_metadata()["sample_id"].iloc[0]) contig = api.contigs[0] variant_allele = np.array( [ [b"A", b"", b"T", b""], # only real ALT in slot 2 - [b"A", b"T", b"", b""], # real ALT in slot 1 (unaffected case) + [b"A", b"T", b"", b""], # real ALT in slot 1 (baseline case) [b"A", b"", b"", b"T"], # only real ALT in slot 3 - [b"A", b"C", b"", b"T"], # two real ALTs, gap in slot 2 + [b"A", b"C", b"", b"T"], # two real ALTs, only one used + [b"A", b"C", b"T", b"G"], # all 3 canonical ALTs populated, + # only one used (the real-world + # pattern: REF=A ALT="C,T,G" + # regardless of relevance) + [b"A", b"C", b"T", b"G"], # all 3 populated, compound het + # using two of them + [b"A", b"C", b"T", b"G"], # all 3 populated, hom-ref + [b"A", b"C", b"T", b"G"], # all 3 populated, missing ], dtype="S1", ) @@ -610,36 +627,50 @@ def test_vcf_exporter_allele_index_remapping( [[0, 2]], # het for the slot-2 "T" -> ALT="T" -> expect 0/1 [[0, 1]], # het for the slot-1 "T" -> ALT="T" -> expect 0/1 [[3, 3]], # hom-alt for the slot-3 "T" -> ALT="T" -> expect 1/1 - [[0, 3]], # het for the slot-3 "T" -> ALT="C,T" -> expect 0/2 + [[0, 3]], # het for slot-3 "T"; slot-1 "C" unused -> expect ALT="T", GT=0/1 + [ + [0, 2] + ], # het for slot-2 "T"; "C" and "G" unused -> expect ALT="T", GT=0/1 + [ + [1, 3] + ], # het for slot-1 "C" and slot-3 "G"; "T" unused -> expect ALT="C,G", GT=1/2 + [[0, 0]], # hom-ref -> expect ALT=".", GT=0/0 + [[-1, -1]], # missing -> expect ALT=".", GT=./. ], dtype="i1", ) + positions = [100, 200, 300, 400, 500, 600, 700, 800] expected = { 100: ("T", "0/1"), 200: ("T", "0/1"), 300: ("T", "1/1"), - 400: ("C,T", "0/2"), + 400: ("T", "0/1"), + 500: ("T", "0/1"), + 600: ("C,G", "1/2"), + 700: (".", "0/0"), + 800: (".", "./."), } + n_variants = len(positions) ds = xr.Dataset( data_vars={ "call_genotype": ( ["variants", "samples", "ploidy"], - da.from_array(call_genotype, chunks=(4, 1, 2)), + da.from_array(call_genotype, chunks=(n_variants, 1, 2)), ), "variant_allele": ( ["variants", "alleles"], - da.from_array(variant_allele, chunks=(4, 4)), + da.from_array(variant_allele, chunks=(n_variants, 4)), ), }, coords={ "variant_position": ( "variants", - da.from_array(np.array([100, 200, 300, 400]), chunks=4), + da.from_array(np.array(positions), chunks=n_variants), ), "variant_contig": ( "variants", - da.from_array(np.array([0, 0, 0, 0], dtype="u1"), chunks=4), + da.from_array(np.zeros(n_variants, dtype="u1"), chunks=n_variants), ), "sample_id": ("samples", np.array([sample])), }, @@ -658,7 +689,7 @@ def test_vcf_exporter_allele_index_remapping( with open(output_path) as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] - assert len(data_lines) == 4 + assert len(data_lines) == n_variants for line in data_lines: fields_row = line.strip().split("\t") @@ -671,6 +702,8 @@ def test_vcf_exporter_allele_index_remapping( # Every GT allele index must be valid for the ALT column that # was actually written (i.e. in range for the number of ALT # alleles listed), which is the invariant this fix guarantees. - n_alt_alleles = len(alt.split(",")) + if gt == "./.": + continue + n_alt_alleles = 0 if alt == "." else len(alt.split(",")) for allele_idx in gt.split("/"): assert int(allele_idx) <= n_alt_alleles From 67f4ed65996fb3015bb911b09776ae1871f2e80f Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 16:14:51 +0100 Subject: [PATCH 19/38] removed leftover bits from to_vcf_cnv --- malariagen_data/anoph/to_vcf.py | 363 ++++++++++++---------------- malariagen_data/anoph/to_vcf_cnv.py | 8 +- malariagen_data/bgzf.py | 125 ---------- 3 files changed, 158 insertions(+), 338 deletions(-) delete mode 100644 malariagen_data/bgzf.py diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 00a243dfe..ae68408d1 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -1,18 +1,34 @@ +import gzip import os import re from datetime import date from typing import Optional - import dask +from dask.array.core import Array +from xarray.core.dataset import Dataset import numpy as np from numpydoc_decorator import doc # type: ignore +from dataclasses import dataclass +from collections import OrderedDict +import math -from ..bgzf import bgzf_open from .snp_data import AnophelesSnpData from . import base_params from . import plink_params from . import vcf_params + +@dataclass +class VariantChunkData: + gq_chunk: Array + ad_chunk: Array + mq_chunk: Array + gt_chunk: Array + pos_chunk: Array + contig_chunk: Array + allele_chunk: Array + + # Supported FORMAT fields, the fixed order in which their values are # always written per sample (regardless of what order the caller's # `fields` argument happens to iterate in — e.g. a set has no @@ -104,19 +120,6 @@ def __init__( selecting samples by cohort, or more than one sample_id) is rejected. """, - parameters=dict( - non_ref_only=""" - If True, only write sites where the sample's genotype - carries at least one non-reference allele (i.e. skip - sites where the sample is homozygous reference or - missing). Equivalent to filtering the output with - `bcftools view -e 'F_PASS(GT="ref") == 1'`, except that - missing genotype calls are also excluded here (whereas - that particular bcftools expression only excludes - homozygous reference calls, since a missing call is - neither "ref" nor selected by `-e`). - """, - ), returns=""" Path to the VCF output file. """, @@ -129,12 +132,11 @@ def snp_calls_to_vcf( sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, sample_indices: Optional[base_params.sample_indices] = None, - site_mask: Optional[base_params.site_mask] = None, + site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, fields: vcf_params.vcf_fields = ("GT",), - non_ref_only: bool = False, ) -> str: base_params._validate_sample_selection_params( sample_query=sample_query, sample_indices=sample_indices @@ -177,7 +179,7 @@ def snp_calls_to_vcf( chunks=chunks, ) - # Confirm inputs resolve to exactly + # Confirm inputs actually resolved to exactly # one sample within the given sample_sets # checked defensively rather than silently written # out as a multi-sample VCF. @@ -192,11 +194,7 @@ def snp_calls_to_vcf( sample_ids = ds["sample_id"].values contigs = ds.attrs.get("contigs", self.contigs) compress = output_path.endswith(".gz") - # N.B., genuine BGZF, not plain gzip: tools that specifically - # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can - # fail to read, or silently mis-parse, plain gzip even though - # it decompresses fine as a byte stream. - opener = bgzf_open if compress else open + opener = gzip.open if compress else open # Determine which extra fields to include. include_gq = "GQ" in fields @@ -232,84 +230,27 @@ def snp_calls_to_vcf( contig_data = ds["variant_contig"].data allele_data = ds["variant_allele"].data - # Optional field arrays — may not exist in all datasets. - gq_data = None - ad_data = None - mq_data = None - if include_gq: - try: - gq_data = ds["call_GQ"].data - except KeyError: - pass - if include_ad: - try: - ad_data = ds["call_AD"].data - except KeyError: - pass - if include_mq: - try: - mq_data = ds["call_MQ"].data - except KeyError: - pass + optional_arrays = self._get_optional_data( + include_gq, include_ad, include_mq, ds + ) chunk_sizes = gt_data.chunks[0] offsets = np.cumsum((0,) + chunk_sizes) - # Which optional fields were requested, so we know what to - # fetch (and where to put the results) for each chunk below. - optional_names = [] - optional_arrays = [] - if gq_data is not None: - optional_names.append("GQ") - optional_arrays.append(gq_data) - if ad_data is not None: - optional_names.append("AD") - optional_arrays.append(ad_data) - if mq_data is not None: - optional_names.append("MQ") - optional_arrays.append(mq_data) - # Write records in chunks. with self._spinner(f"Write VCF ({ds.sizes['variants']} variants)"): for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - - # Fetch the required arrays for this chunk in a - # single batched call, rather than one .compute() - # call per array. Each separate .compute() call is - # its own blocking round trip to the underlying - # store (e.g. GCS); batching lets dask fetch all of - # them concurrently instead of one at a time - gt_chunk, pos_chunk, contig_chunk, allele_chunk = dask.compute( - gt_data[start:stop], - pos_data[start:stop], - contig_data[start:stop], - allele_data[start:stop], + variant_chunk_data = self._get_chunks( + ci, + offsets, + gt_data, + pos_data, + contig_data, + allele_data, + optional_arrays, ) - # Fetch requested optional fields for this chunk - # as a single batched call. If any fail - # to load, fall back to "." for all requested - # optional fields in this chunk — these arrays live - # in the same region of the same store, so a failure - # affecting one is likely to affect the others too, - gq_chunk = None - ad_chunk = None - mq_chunk = None - if optional_arrays: - try: - computed = dask.compute( - *(arr[start:stop] for arr in optional_arrays) - ) - optional_chunks = dict(zip(optional_names, computed)) - gq_chunk = optional_chunks.get("GQ") - ad_chunk = optional_chunks.get("AD") - mq_chunk = optional_chunks.get("MQ") - except (FileNotFoundError, KeyError): - pass - - n_samples = gt_chunk.shape[1] + n_samples = variant_chunk_data.gt_chunk.shape[1] # OPTIMIZATION: Vectorize GT field formatting across entire chunk. # Instead of formatting each sample's GT field in a nested Python loop @@ -317,131 +258,45 @@ def snp_calls_to_vcf( # use NumPy's vectorized string operations on the entire chunk at once. # This provides ~3x speedup while maintaining exact output compatibility. # See issue #1280 for performance analysis. - gt_chunk_2d = gt_chunk.reshape( - gt_chunk.shape[0], gt_chunk.shape[1], 2 + gt_chunk_2d = variant_chunk_data.gt_chunk.reshape( + variant_chunk_data.gt_chunk.shape[0], + variant_chunk_data.gt_chunk.shape[1], + 2, ) a0 = gt_chunk_2d[:, :, 0] # (n_variants, n_samples) a1 = gt_chunk_2d[:, :, 1] # (n_variants, n_samples) missing = (a0 < 0) | (a1 < 0) - # If non_ref_only, work out up front which variants - # to skip: those where the sample is homozygous - # reference (0/0) or missing. Computed vectorized - # across the whole chunk, same as `missing` above. - # N.B., this uses the *original* (un-remapped) - # allele indices computed below — 0 always means REF - # both before and after remapping, so this check is - # unaffected by it. - if non_ref_only: - is_hom_ref = (a0 == 0) & (a1 == 0) - skip_variant = (missing | is_hom_ref)[:, 0] - else: - skip_variant = None - - # Decode alleles once per chunk (rather than - # per-variant further down) and work out, per - # variant, which of the (REF + 3 ALT candidate) - # variant_allele slots to actually write to the ALT - # column. variant_allele lists a fixed, canonical - # set of alternate bases per site regardless of - # whether they're relevant to *this* sample — e.g. - # for a REF=C site it lists "A,T,G" as ALT - # candidates even if this sample is only ever - # heterozygous for T, with zero read support for A - # or G. Writing all of them to ALT produces a - # non-standard single-sample VCF (real single-sample - # VCFs only list alleles the sample's own genotype - # actually uses) and breaks REF/ALT-based comparison - # against any VCF that follows that convention, - # since two VCFs listing the "same" call at the same - # position end up with different ALT strings. So - # only a slot that is both non-empty *and* actually - # referenced by this sample's genotype is kept; the - # remaining slots are dropped from ALT, and - # genotype indices remapped to match, exactly as for - # a genuinely empty slot. - decoded_alleles = np.empty(allele_chunk.shape, dtype=object) - for col in range(allele_chunk.shape[1]): - decoded_alleles[:, col] = [ - a.decode() if hasattr(a, "decode") else str(a) - for a in allele_chunk[:, col] - ] - n_allele_slots = allele_chunk.shape[1] - is_present = decoded_alleles != "" - - slot_referenced = np.zeros_like(is_present) - slot_referenced[:, 0] = True # REF is always kept - valid = ~missing[:, 0] - row_idx = np.arange(gt_chunk.shape[0]) - safe_a0 = np.clip(a0[:, 0], 0, n_allele_slots - 1) - safe_a1 = np.clip(a1[:, 0], 0, n_allele_slots - 1) - slot_referenced[row_idx[valid], safe_a0[valid]] = True - slot_referenced[row_idx[valid], safe_a1[valid]] = True - - is_present = is_present & slot_referenced - is_present[:, 0] = True # REF is always present - - # compacted_index[i, k] = the index original slot k - # occupies in the ALT column for variant i, or -1 if - # slot k isn't kept there. - compacted_index = np.cumsum(is_present, axis=1) - 1 - compacted_index[~is_present] = -1 - - # Remap this chunk's genotype allele indices to the - # compacted numbering. n_samples is always 1 here - # (snp_calls_to_vcf only supports a single sample), - # so a0/a1 are worked with as flat (n_variants,) - # arrays. Clip before gathering so a missing - # genotype's sentinel value (-1) can't trigger an - # out-of-bounds index — the gathered result for - # those rows is discarded below anyway, since they - # are written as "./." based on `missing`, not on - # this remapping. - remapped_a0 = compacted_index[row_idx, safe_a0] - remapped_a1 = compacted_index[row_idx, safe_a1] - # A remapped index of -1 means the genotype - # references an allele slot that variant_allele - # doesn't actually have populated at this site — - # inconsistent data that shouldn't occur, but is - # treated as missing defensively rather than writing - # a nonsensical negative allele index. - missing_or_unmapped = ( - missing[:, 0] | (remapped_a0 < 0) | (remapped_a1 < 0) - ) - # Build formatted GT strings using NumPy vectorization gt_formatted = np.empty( - (gt_chunk.shape[0], n_samples), dtype=object + (variant_chunk_data.gt_chunk.shape[0], n_samples), dtype=object ) - gt_formatted[missing_or_unmapped, 0] = "./." - present_idx = ~missing_or_unmapped + gt_formatted[missing] = "./." + present_idx = ~missing if np.any(present_idx): - a0_str = remapped_a0[present_idx].astype(str) - a1_str = remapped_a1[present_idx].astype(str) - gt_formatted[present_idx, 0] = np.char.add( + a0_str = a0[present_idx].astype(str) + a1_str = a1[present_idx].astype(str) + gt_formatted[present_idx] = np.char.add( np.char.add(a0_str, "/"), a1_str ) # Pre-allocate line buffer for better I/O lines_to_write = [] - for j in range(gt_chunk.shape[0]): - if skip_variant is not None and skip_variant[j]: - continue - - chrom = contigs[contig_chunk[j]] - pos = str(pos_chunk[j]) - # Reuse the chunk-level decode from above, so - # the ALT column built here is guaranteed - # consistent with the allele-index remapping - # used for GT (both derive from the same - # decoded_alleles/is_present arrays). - ref = decoded_alleles[j, 0] - alt_alleles = [ - decoded_alleles[j, k] - for k in range(1, n_allele_slots) - if is_present[j, k] - ] + for j in range(variant_chunk_data.gt_chunk.shape[0]): + chrom = contigs[variant_chunk_data.contig_chunk[j]] + pos = str(variant_chunk_data.pos_chunk[j]) + alleles = variant_chunk_data.allele_chunk[j] + ref = ( + alleles[0].decode() + if hasattr(alleles[0], "decode") + else str(alleles[0]) + ) + alt_alleles = [] + for a in alleles[1:]: + s = a.decode() if hasattr(a, "decode") else str(a) + if s: + alt_alleles.append(s) alt = ",".join(alt_alleles) if alt_alleles else "." # Build fixed VCF columns once per variant @@ -466,15 +321,15 @@ def snp_calls_to_vcf( # GQ. if include_gq: - if gq_chunk is not None: - v = gq_chunk[j, k] + if variant_chunk_data.gq_chunk is not None: + v = variant_chunk_data.gq_chunk[j, k] parts.append("." if v < 0 else str(v)) else: parts.append(".") # AD. if include_ad: - if ad_chunk is not None: - ad_vals = ad_chunk[j, k] + if variant_chunk_data.ad_chunk is not None: + ad_vals = variant_chunk_data.ad_chunk[j, k] parts.append( ",".join( "." if x < 0 else str(x) for x in ad_vals @@ -487,9 +342,10 @@ def snp_calls_to_vcf( # spec fixes the reserved FORMAT/MQ key as # Integer (see _FORMAT_HEADERS). if include_mq: - if mq_chunk is not None: - v = mq_chunk[j, k] - parts.append("." if v < 0 else str(round(v))) + if variant_chunk_data.mq_chunk is not None: + v = variant_chunk_data.mq_chunk[j, k] + if not math.isnan(v): + parts.append("." if v < 0 else str(round(v))) else: parts.append(".") sample_fields.append(":".join(parts)) @@ -502,3 +358,92 @@ def snp_calls_to_vcf( f.write("".join(lines_to_write)) return output_path + + def _get_chunks( + self, + ci: int, + offsets: np.array, + gt_data: Array, + pos_data: Array, + contig_data: Array, + allele_data: Array, + optional_arrays: OrderedDict, + ) -> tuple: + start = offsets[ci] + stop = offsets[ci + 1] + + # Fetch the required arrays for this chunk in a + # single batched call, rather than one .compute() + # call per array. Each separate .compute() call is + # its own blocking round trip to the underlying + # store (e.g. GCS); batching lets dask fetch all of + # them concurrently instead of one at a time + gt_chunk, pos_chunk, contig_chunk, allele_chunk = dask.compute( + gt_data[start:stop], + pos_data[start:stop], + contig_data[start:stop], + allele_data[start:stop], + ) + # Fetch requested optional fields for this chunk + # as a single batched call. If any of them fail + # to load, fall back to "." for all requested + # optional fields in this chunk — these arrays live + # in the same region of the same store, so a failure + # affecting one is likely to affect the others too, + gq_chunk = None + ad_chunk = None + mq_chunk = None + if optional_arrays: + try: + computed = dask.compute( + *(arr[start:stop] for arr in optional_arrays.values()) + ) + optional_chunks = dict(zip(optional_arrays.keys(), computed)) + gq_chunk = optional_chunks.get("GQ") + ad_chunk = optional_chunks.get("AD") + mq_chunk = optional_chunks.get("MQ") + except (FileNotFoundError, KeyError): + pass + chunk_output = VariantChunkData( + gt_chunk=gt_chunk, + pos_chunk=pos_chunk, + contig_chunk=contig_chunk, + allele_chunk=allele_chunk, + gq_chunk=gq_chunk, + ad_chunk=ad_chunk, + mq_chunk=mq_chunk, + ) + return chunk_output + + def _get_optional_data( + self, include_gq: bool, include_ad: bool, include_mq: bool, ds: Dataset + ) -> OrderedDict: + # Optional field arrays — may not exist in all datasets. + gq_data = None + ad_data = None + mq_data = None + if include_gq: + try: + gq_data = ds["call_GQ"].data + except KeyError: + pass + if include_ad: + try: + ad_data = ds["call_AD"].data + except KeyError: + pass + if include_mq: + try: + mq_data = ds["call_MQ"].data + except KeyError: + pass + # Which optional fields were requested, so we know what to + # fetch (and where to put the results) for each chunk below. + optional_arrays = OrderedDict() # check needed + if gq_data is not None: + optional_arrays["GQ"] = gq_data + if ad_data is not None: + optional_arrays["AD"] = ad_data + if mq_data is not None: + optional_arrays["MQ"] = mq_data + return optional_arrays diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py index 676897e5a..b42d63832 100644 --- a/malariagen_data/anoph/to_vcf_cnv.py +++ b/malariagen_data/anoph/to_vcf_cnv.py @@ -1,11 +1,11 @@ import os from datetime import date from typing import List, Optional, Sequence +import gzip import numpy as np from numpydoc_decorator import doc # type: ignore -from ..bgzf import bgzf_open from .cnv_data import AnophelesCnvData from . import base_params from . import cnv_params @@ -124,7 +124,7 @@ def cnv_hmm_to_vcf( # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can # fail to read, or silently mis-parse, plain gzip even though # it decompresses fine as a byte stream. - opener = bgzf_open if compress else open + opener = gzip.open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( @@ -223,7 +223,7 @@ def cnv_coverage_calls_to_vcf( # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can # fail to read, or silently mis-parse, plain gzip even though # it decompresses fine as a byte stream. - opener = bgzf_open if compress else open + opener = gzip.open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( @@ -341,7 +341,7 @@ def cnv_discordant_read_calls_to_vcf( # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can # fail to read, or silently mis-parse, plain gzip even though # it decompresses fine as a byte stream. - opener = bgzf_open if compress else open + opener = gzip.open if compress else open with opener(output_path, "wt") as f: _write_vcf_header( diff --git a/malariagen_data/bgzf.py b/malariagen_data/bgzf.py deleted file mode 100644 index d49a35853..000000000 --- a/malariagen_data/bgzf.py +++ /dev/null @@ -1,125 +0,0 @@ -"""Minimal, write-only BGZF (Blocked GZip Format) support. - -BGZF is the compression format used throughout the SAM/BAM/VCF tooling -ecosystem (samtools, bcftools, tabix, bedtools, IGV, ...) for -compressed, indexable files. Structurally, it's just a sequence of -ordinary gzip members, each holding up to ~64KB of uncompressed data, -with a small extra header field recording each member's total size, -plus a fixed, empty final member used as an EOF marker. - -Python's standard library `gzip.open()` produces valid gzip, but not -valid BGZF: tools that specifically expect BGZF for a `.vcf.gz` (or -similar) file can fail to read it correctly, or silently mis-parse it, -even though plain gzip decompresses just fine as a byte stream. This -module exists so that `.gz` output written by malariagen_data is -genuine BGZF, and therefore usable with the wider standard toolset -(bcftools, tabix, bedtools, etc.), not just tools that happen to -tolerate plain gzip. - -See the BGZF section of the SAM specification for the on-disk format -this implements: https://samtools.github.io/hts-specs/SAMv1.pdf -""" - -import struct -import zlib -from typing import Optional - -# The fixed, empty BGZF block used to mark genuine end-of-file (as -# opposed to a truncated file). This exact byte sequence is part of the -# BGZF specification, not something we generate ourselves. -_BGZF_EOF_MARKER = bytes.fromhex( - "1f8b08040000000000ff0600424302001b0003000000000000000000" -) - -# Maximum amount of *uncompressed* data placed in a single BGZF block. -# Kept comfortably under the 16-bit BSIZE field's range (a block's -# total on-disk size, header and footer included, must fit in 65536 -# bytes) even in the worst case where compression doesn't shrink the -# input at all; this matches the conservative block size used by other -# BGZF writers (e.g. Biopython's `Bio.bgzf`). -_MAX_BLOCK_UNCOMPRESSED_SIZE = 65280 - - -def _compress_bgzf_block(data: bytes, level: int = 6) -> bytes: - """Compress `data` (must be <= _MAX_BLOCK_UNCOMPRESSED_SIZE bytes) - into a single, standalone BGZF block.""" - compressor = zlib.compressobj(level, zlib.DEFLATED, -15) - compressed = compressor.compress(data) + compressor.flush(zlib.Z_FINISH) - crc = zlib.crc32(data) & 0xFFFFFFFF - isize = len(data) & 0xFFFFFFFF - - # Block layout: 18-byte header (with the BGZF "BC" extra field), - # the compressed payload, then an 8-byte footer (CRC32 + ISIZE) — - # the same footer any gzip member ends with. - block_size = 18 + len(compressed) + 8 - header = struct.pack( - " None: - self._buffer.extend(text.encode(self._encoding)) - while len(self._buffer) >= _MAX_BLOCK_UNCOMPRESSED_SIZE: - chunk = bytes(self._buffer[:_MAX_BLOCK_UNCOMPRESSED_SIZE]) - del self._buffer[:_MAX_BLOCK_UNCOMPRESSED_SIZE] - self._fh.write(_compress_bgzf_block(chunk)) - - def close(self) -> None: - if self._closed: - return - if self._buffer: - self._fh.write(_compress_bgzf_block(bytes(self._buffer))) - self._buffer = bytearray() - self._fh.write(_BGZF_EOF_MARKER) - self._fh.close() - self._closed = True - - def __enter__(self) -> "BgzfWriter": - return self - - def __exit__(self, *exc_info) -> None: - self.close() - - -def bgzf_open(path: str, mode: str = "wt", encoding: Optional[str] = "utf-8"): - """Open `path` for BGZF-compressed text writing. - - Signature-compatible with `gzip.open(path, "wt")` for the subset of - usage malariagen_data's VCF/text exporters need (write-only, text - mode), so it can be used as a drop-in replacement for `gzip.open` - wherever genuine BGZF (rather than plain gzip) output is required. - """ - if mode not in ("wt", "w"): - raise ValueError( - f"Unsupported mode {mode!r}: bgzf_open() only supports writing text " - "('wt' or 'w')." - ) - return BgzfWriter(path, encoding=encoding or "utf-8") From 5aabdfd519ba81fa525f03327fecb02f2a747db9 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 17:05:41 +0100 Subject: [PATCH 20/38] try simple if statement to exclude homozygous sites --- malariagen_data/anoph/to_vcf.py | 73 +++++++++++++++++---------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index ae68408d1..ff1414ad8 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -265,7 +265,7 @@ def snp_calls_to_vcf( ) a0 = gt_chunk_2d[:, :, 0] # (n_variants, n_samples) a1 = gt_chunk_2d[:, :, 1] # (n_variants, n_samples) - missing = (a0 < 0) | (a1 < 0) + missing = (a0 < 0) | (a1 < 0) # array of loci not present # Build formatted GT strings using NumPy vectorization gt_formatted = np.empty( @@ -318,41 +318,44 @@ def snp_calls_to_vcf( # Use pre-formatted GT strings and add other fields for k in range(n_samples): parts = [gt_formatted[j, k]] - - # GQ. - if include_gq: - if variant_chunk_data.gq_chunk is not None: - v = variant_chunk_data.gq_chunk[j, k] - parts.append("." if v < 0 else str(v)) - else: - parts.append(".") - # AD. - if include_ad: - if variant_chunk_data.ad_chunk is not None: - ad_vals = variant_chunk_data.ad_chunk[j, k] - parts.append( - ",".join( - "." if x < 0 else str(x) for x in ad_vals + if parts != "0/0": # homozygous genotype + # GQ. + if include_gq: + if variant_chunk_data.gq_chunk is not None: + v = variant_chunk_data.gq_chunk[j, k] + parts.append("." if v < 0 else str(v)) + else: + parts.append(".") + # AD. + if include_ad: + if variant_chunk_data.ad_chunk is not None: + ad_vals = variant_chunk_data.ad_chunk[j, k] + parts.append( + ",".join( + "." if x < 0 else str(x) + for x in ad_vals + ) ) - ) - else: - parts.append(".") - # MQ. Rounded to the nearest integer: the - # underlying data is a float, but the VCF - # spec fixes the reserved FORMAT/MQ key as - # Integer (see _FORMAT_HEADERS). - if include_mq: - if variant_chunk_data.mq_chunk is not None: - v = variant_chunk_data.mq_chunk[j, k] - if not math.isnan(v): - parts.append("." if v < 0 else str(round(v))) - else: - parts.append(".") - sample_fields.append(":".join(parts)) - - # Build and buffer the line - line = fixed_cols + "\t".join(sample_fields) + "\n" - lines_to_write.append(line) + else: + parts.append(".") + # MQ. Rounded to the nearest integer: the + # underlying data is a float, but the VCF + # spec fixes the reserved FORMAT/MQ key as + # Integer (see _FORMAT_HEADERS). + if include_mq: + if variant_chunk_data.mq_chunk is not None: + v = variant_chunk_data.mq_chunk[j, k] + if not math.isnan(v): + parts.append( + "." if v < 0 else str(round(v)) + ) + else: + parts.append(".") + sample_fields.append(":".join(parts)) + + # Build and buffer the line + line = fixed_cols + "\t".join(sample_fields) + "\n" + lines_to_write.append(line) # Write buffered lines in one go per chunk f.write("".join(lines_to_write)) From b23e4b6f39105b6be806669f938465f688b0ce85 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 30 Sep 2026 17:21:52 +0100 Subject: [PATCH 21/38] fixed indentation to only output heterozygous sites --- malariagen_data/anoph/to_vcf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index ff1414ad8..beb72275b 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -318,7 +318,7 @@ def snp_calls_to_vcf( # Use pre-formatted GT strings and add other fields for k in range(n_samples): parts = [gt_formatted[j, k]] - if parts != "0/0": # homozygous genotype + if parts != ["0/0"]: # homozygous genotype # GQ. if include_gq: if variant_chunk_data.gq_chunk is not None: @@ -353,9 +353,9 @@ def snp_calls_to_vcf( parts.append(".") sample_fields.append(":".join(parts)) - # Build and buffer the line - line = fixed_cols + "\t".join(sample_fields) + "\n" - lines_to_write.append(line) + # Build and buffer the line + line = fixed_cols + "\t".join(sample_fields) + "\n" + lines_to_write.append(line) # Write buffered lines in one go per chunk f.write("".join(lines_to_write)) From 4203d04e1d52f8e6588692e491f2de579c1eb30b Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Thu, 1 Oct 2026 13:34:51 +0100 Subject: [PATCH 22/38] reverted igv to original version and removed to_coverage as bam urls will be fine --- malariagen_data/anoph/igv.py | 212 +------------------ malariagen_data/anoph/to_coverage.py | 298 --------------------------- malariagen_data/anoph/to_vcf.py | 107 ++++------ 3 files changed, 45 insertions(+), 572 deletions(-) delete mode 100644 malariagen_data/anoph/to_coverage.py diff --git a/malariagen_data/anoph/igv.py b/malariagen_data/anoph/igv.py index 19c59ca48..59680640b 100644 --- a/malariagen_data/anoph/igv.py +++ b/malariagen_data/anoph/igv.py @@ -1,4 +1,3 @@ -import os from typing import List, Optional import igv_notebook # type: ignore @@ -78,97 +77,11 @@ def _igv_site_filters_tracks( tracks.append(track_config) return tracks - def _igv_local_coverage_track( - self, - *, - region: Region, - sample: str, - visibility_window: int, - source: str = "cnv_hmm", - field: str = "NormCov", - output_path: Optional[str] = None, - ): - # Build a coverage track computed locally from the Zarr arrays - # rather than loaded from an externally-hosted file. This is not - # a substitute for an alignments track (there are no individual - # reads), but gives a fallback source of coverage information - # for a sample when the BAM file is not available. Two sources - # are supported: "cnv_hmm" gives windowed coverage genome-wide; - # "snp_calls" gives per-base read depth, but only at called SNP - # sites. - # - # N.B., this method is only usable when this class is combined - # (via cooperative multiple inheritance) with CoverageExporter, - # as is the case for the top-level Ag3/Af1 data resource classes. - # Methods are accessed via getattr rather than a direct import to - # avoid adding CoverageExporter as a base class of AnophelesIgv, - # which would conflict with the method resolution order of the - # combined data resource classes. - extra_kwargs: dict - if source == "cnv_hmm": - to_bedgraph = getattr(self, "cnv_hmm_coverage_to_bedgraph", None) - extra_kwargs = dict(field=field) - track_name = f"Coverage ({field}, local) - {sample}" - path_suffix = field - elif source == "snp_calls": - to_bedgraph = getattr(self, "snp_calls_coverage_to_bedgraph", None) - extra_kwargs = dict() - track_name = f"SNP read depth (local) - {sample}" - path_suffix = "AD" - else: - raise ValueError( - f"Unknown coverage source: {source!r}. " - "Valid sources are 'cnv_hmm', 'snp_calls'." - ) - - if to_bedgraph is None: - raise NotImplementedError( - "Local coverage tracks require this API object to also " - "provide CNV and SNP data (see CoverageExporter)." - ) - - if output_path is None: - if self._results_cache is None: - raise ValueError( - "Cannot create a local coverage track without knowing " - "where to write it. Either pass `coverage_track_path`, " - "or configure `results_cache` when creating this API " - "object." - ) - safe_region = ( - str(region).replace(":", "_").replace(",", "").replace("-", "_") - ) - cache_dir = self._results_cache / "igv_coverage" - os.makedirs(cache_dir, exist_ok=True) - output_path = str( - cache_dir / f"{sample}_{safe_region}_{source}_{path_suffix}.bedgraph" - ) - - to_bedgraph( - output_path=output_path, - region=region, - sample=sample, - **extra_kwargs, - ) - - return { - "name": track_name, - "url": output_path, - "format": "bedgraph", - "type": "wig", - "visibilityWindow": visibility_window, # bp - "height": 50, - "color": "#5e3c99", - } - def _igv_view_alignments_tracks( self, region: Region, sample: str, visibility_window: int = 20_000, - local_coverage_fallback: bool = False, - coverage_source: str = "cnv_hmm", - coverage_track_path: Optional[str] = None, ): # Look up sample set for sample. try: @@ -208,10 +121,7 @@ def _igv_view_alignments_tracks( } ) - # Add alignments track. N.B., this depends on the BAM file being - # hosted at `bam_url` and remaining reachable; if that URL stops - # working (e.g. following migration of raw data to ENA/EVA) this - # track will fail to load in the browser. + # Add alignments track. tracks.append( { "name": "Alignments", @@ -224,21 +134,6 @@ def _igv_view_alignments_tracks( } ) - # Optionally also add a coverage track computed locally from CNV - # HMM or SNP calls data, as a fallback source of coverage - # information that does not depend on the alignments BAM file - # remaining available. - if local_coverage_fallback: - tracks.append( - self._igv_local_coverage_track( - region=region, - sample=sample, - visibility_window=visibility_window, - source=coverage_source, - output_path=coverage_track_path, - ) - ) - return tracks @_check_types @@ -288,28 +183,6 @@ def igv( visible. """, init="If True, call igv_notebook.init().", - local_coverage_fallback=""" - If True, also add a coverage track computed locally from - CNV HMM or SNP calls data. Unlike the alignments track, - this does not depend on the BAM file remaining available - at its hosted URL, so it provides a fallback source of - coverage information if that URL stops working. It is - not a substitute for the alignments track, since it - contains only summarised coverage values, not individual - reads. - """, - coverage_source=""" - Which data to compute the local coverage track from, if - `local_coverage_fallback` is True. "cnv_hmm" gives - windowed coverage genome-wide; "snp_calls" gives - per-base read depth, but only at called SNP sites. - """, - coverage_track_path=""" - Path to write the local coverage track file to, if - `local_coverage_fallback` is True. If not provided, - defaults to a location under `results_cache` (which must - therefore be configured). - """, ), ) def view_alignments( @@ -318,9 +191,6 @@ def view_alignments( sample: str, visibility_window: int = 20_000, init: bool = True, - local_coverage_fallback: bool = False, - coverage_source: str = "cnv_hmm", - coverage_track_path: Optional[str] = None, ): # Parse region. region_prepped: Region = _parse_single_region(self, region) @@ -331,86 +201,6 @@ def view_alignments( region=region_prepped, sample=sample, visibility_window=visibility_window, - local_coverage_fallback=local_coverage_fallback, - coverage_source=coverage_source, - coverage_track_path=coverage_track_path, - ) - - # Create IGV browser. - self.igv(region=region_prepped, tracks=tracks, init=init) - - @_check_types - @doc( - summary=""" - Launch IGV and view sequence read coverage from the given - sample, computed locally from CNV HMM or SNP calls data. - """, - extended_summary=""" - Unlike `view_alignments()`, this does not depend on an - externally-hosted BAM file, or on the WGS data catalog: - coverage is derived directly from data already available in - the Zarr arrays. It shows only summarised coverage depth, - not individual aligned reads, so it is a fallback source of - information about read coverage rather than a substitute for - viewing alignments. - """, - parameters=dict( - sample="Sample identifier.", - source=""" - Which data to compute the coverage track from. - "cnv_hmm" gives windowed coverage genome-wide; - "snp_calls" gives per-base read depth, but only at - called SNP sites. - """, - field=""" - Which coverage field to display, if `source` is - "cnv_hmm". "NormCov" is coverage normalised against a set - of reference windows; "RawCov" is unnormalised read - counts per window. Ignored if `source` is "snp_calls". - """, - visibility_window=""" - Zoom level in base pairs at which SNP data will become - visible. - """, - init="If True, call igv_notebook.init().", - output_path=""" - Path to write the local coverage track file to. If not - provided, defaults to a location under `results_cache` - (which must therefore be configured). - """, - ), - ) - def view_coverage( - self, - region: base_params.region, - sample: str, - source: str = "cnv_hmm", - field: str = "NormCov", - visibility_window: int = 20_000, - init: bool = True, - output_path: Optional[str] = None, - ): - # Parse region. - region_prepped: Region = _parse_single_region(self, region) - del region - - # Set up site filters tracks, consistent with view_alignments(). - tracks = self._igv_site_filters_tracks( - contig=region_prepped.contig, - visibility_window=visibility_window, - ) - - # Add the locally-computed coverage track. N.B., this does not - # touch the WGS data catalog or any externally-hosted files. - tracks.append( - self._igv_local_coverage_track( - region=region_prepped, - sample=sample, - visibility_window=visibility_window, - source=source, - field=field, - output_path=output_path, - ) ) # Create IGV browser. diff --git a/malariagen_data/anoph/to_coverage.py b/malariagen_data/anoph/to_coverage.py deleted file mode 100644 index ee0248693..000000000 --- a/malariagen_data/anoph/to_coverage.py +++ /dev/null @@ -1,298 +0,0 @@ -import gzip -import os -from typing import List, Optional - -import numpy as np -from numpydoc_decorator import doc # type: ignore - -from .cnv_data import AnophelesCnvData -from .snp_data import AnophelesSnpData -from . import base_params -from . import cnv_params -from . import plink_params - -_VALID_CNV_COVERAGE_FIELDS = {"NormCov", "RawCov"} - - -def _bedgraph_opener(output_path: str): - # N.B., plain gzip is intentional here, unlike the VCF exporters - # (see malariagen_data.bgzf): bedGraph doesn't carry the same - # ecosystem-wide expectation that a `.gz` file specifically be - # BGZF, and IGV loads a plain-gzipped bedGraph track without - # issue. - compress = output_path.endswith(".gz") - return gzip.open if compress else open - - -class CoverageExporter( - AnophelesCnvData, - AnophelesSnpData, -): - """ - Export per-sample read coverage to bedGraph, derived either from - CNV HMM data (windowed coverage, genome-wide) or from SNP calls - (per-site read depth, only at called SNP positions). - - N.B., this does not reconstruct read alignments. It cannot - substitute for a BAM file, because the underlying Zarr arrays only - ever store windowed or per-site summary values (and copy number - calls derived from them) rather than individual reads. What this - class provides is a coverage-depth track that can be loaded into - IGV alongside (or instead of) an alignments track, as a fallback - for when the raw BAM file for a sample is not available, e.g. - because it is hosted externally and that host has become - unreachable. - """ - - def __init__( - self, - **kwargs, - ): - # N.B., this class is designed to work cooperatively, and - # so it's important that any remaining parameters are passed - # to the superclass constructor. - super().__init__(**kwargs) - - def _lookup_sample_set(self, sample: str) -> str: - try: - sample_rec = self.sample_metadata().set_index("sample_id").loc[sample] - except KeyError as e: - raise ValueError( - f"No data found for sample {sample!r}. This sample might be " - "unavailable or irrelevant with respect to settings." - ) from e - return sample_rec["sample_set"] - - @doc( - summary=""" - Export per-sample CNV HMM coverage to bedGraph format. - """, - extended_summary=""" - This function writes windowed read coverage for a single - sample, derived from CNV HMM data, to a bedGraph file. This - is not a substitute for a BAM file of aligned reads: it - contains only per-window summary coverage values (as stored - in the Zarr arrays), not individual reads. It is intended as - a fallback coverage track for IGV, for use when the aligned - reads (BAM) for a sample are not available, e.g. because the - file is hosted externally and unreachable. Coverage is - available genome-wide (in fixed-size windows), regardless of - whether any SNPs were called nearby. Data is written in - chunks to avoid loading the entire array into memory. - Supports optional gzip compression when the output path ends - with `.gz`. - """, - parameters=dict( - output_path=""" - Path to write the bedGraph output file. Use a `.gz` - extension to enable gzip compression. - """, - sample="Sample identifier.", - field=""" - Which coverage field to export. "NormCov" is coverage - normalised against a set of reference windows (comparable - between samples); "RawCov" is unnormalised read counts - per window. - """, - ), - returns=""" - Path to the bedGraph output file. - """, - ) - def cnv_hmm_coverage_to_bedgraph( - self, - output_path: str, - region: base_params.regions, - sample: str, - field: str = "NormCov", - max_coverage_variance: cnv_params.max_coverage_variance = None, - inline_array: base_params.inline_array = base_params.inline_array_default, - chunks: base_params.chunks = base_params.native_chunks, - overwrite: plink_params.overwrite = False, - ) -> str: - if field not in _VALID_CNV_COVERAGE_FIELDS: - raise ValueError( - f"Unknown coverage field: {field!r}. " - f"Valid fields are: {sorted(_VALID_CNV_COVERAGE_FIELDS)}" - ) - - if os.path.exists(output_path) and not overwrite: - return output_path - - # Look up which sample set this sample belongs to, so we only - # need to open the CNV HMM data for that one sample set. - sample_set = self._lookup_sample_set(sample) - - ds = self.cnv_hmm( - region=region, - sample_sets=sample_set, - sample_query=f"sample_id == {sample!r}", - max_coverage_variance=max_coverage_variance, - inline_array=inline_array, - chunks=chunks, - ) - - if ds.sizes["samples"] == 0: - raise ValueError( - f"No CNV HMM data available for sample {sample!r}, this may be " - "because it was excluded by max_coverage_variance." - ) - - contigs = ds.attrs.get("contigs", self.contigs) - opener = _bedgraph_opener(output_path) - - with opener(output_path, "wt") as f: - f.write( - f'track type=bedGraph name="{sample} {field}" ' - f'description="CNV HMM {field} for {sample}"\n' - ) - - pos_data = ds["variant_position"].data - end_data = ds["variant_end"].data - contig_data = ds["variant_contig"].data - cov_data = ds[f"call_{field}"].data - - chunk_sizes = pos_data.chunks[0] - offsets = np.cumsum((0,) + chunk_sizes) - - with self._spinner( - f"Write bedGraph ({ds.sizes['variants']} coverage windows)" - ): - for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - pos_chunk = pos_data[start:stop].compute() - end_chunk = end_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - # Select the single requested sample's coverage - # column from the already-materialised chunk, rather - # than indexing the dask/zarr array before compute, - # which can trigger a less efficient (and, for - # arrays with unwritten/fill-value chunks, buggy) - # orthogonal-selection code path. - cov_chunk = cov_data[start:stop].compute()[:, 0] - - lines: List[str] = [] - for j in range(pos_chunk.shape[0]): - v = cov_chunk[j] - if v < 0: - # Masked/missing value, skip rather than - # write a misleading zero. - continue - chrom = contigs[contig_chunk[j]] - # bedGraph coordinates are 0-based, half-open; - # variant_position is 1-based inclusive. - bed_start = int(pos_chunk[j]) - 1 - bed_end = int(end_chunk[j]) - lines.append(f"{chrom}\t{bed_start}\t{bed_end}\t{v}\n") - f.write("".join(lines)) - - return output_path - - @doc( - summary=""" - Export per-sample SNP read depth to bedGraph format. - """, - extended_summary=""" - This function writes read depth at called SNP sites for a - single sample, derived from the allele depth (`AD`) field of - SNP calls, to a bedGraph file. Unlike - `cnv_hmm_coverage_to_bedgraph()`, this only has a value at - positions where a SNP was called, not genome-wide, but gives - higher-resolution, per-base depth in those locations rather - than a windowed summary. This is not a substitute for a BAM - file of aligned reads. It is intended as a fallback coverage - track for IGV, for use when the aligned reads (BAM) for a - sample are not available, e.g. because the file is hosted - externally and unreachable. Data is written in chunks to - avoid loading the entire array into memory. Supports - optional gzip compression when the output path ends with - `.gz`. - """, - parameters=dict( - output_path=""" - Path to write the bedGraph output file. Use a `.gz` - extension to enable gzip compression. - """, - sample="Sample identifier.", - ), - returns=""" - Path to the bedGraph output file. - """, - ) - def snp_calls_coverage_to_bedgraph( - self, - output_path: str, - region: base_params.regions, - sample: str, - site_mask: Optional[base_params.site_mask] = None, - inline_array: base_params.inline_array = base_params.inline_array_default, - chunks: base_params.chunks = base_params.native_chunks, - overwrite: plink_params.overwrite = False, - ) -> str: - if os.path.exists(output_path) and not overwrite: - return output_path - - # Look up which sample set this sample belongs to, so we only - # need to open the SNP calls data for that one sample set. - sample_set = self._lookup_sample_set(sample) - - ds = self.snp_calls( - region=region, - sample_sets=sample_set, - sample_query=f"sample_id == {sample!r}", - site_mask=site_mask, - inline_array=inline_array, - chunks=chunks, - ) - - if ds.sizes["samples"] == 0: - raise ValueError(f"No SNP calls data available for sample {sample!r}.") - - contigs = ds.attrs.get("contigs", self.contigs) - opener = _bedgraph_opener(output_path) - - with opener(output_path, "wt") as f: - f.write( - f'track type=bedGraph name="{sample} SNP depth" ' - f'description="SNP read depth (sum of AD) for {sample}"\n' - ) - - pos_data = ds["variant_position"].data - contig_data = ds["variant_contig"].data - ad_data = ds["call_AD"].data - - chunk_sizes = pos_data.chunks[0] - offsets = np.cumsum((0,) + chunk_sizes) - - with self._spinner(f"Write bedGraph ({ds.sizes['variants']} SNP sites)"): - for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - pos_chunk = pos_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - # Select the single requested sample's allele depth - # values from the already-materialised chunk, rather - # than indexing the dask/zarr array before compute - # (see the equivalent comment in - # cnv_hmm_coverage_to_bedgraph). - ad_chunk = ad_data[start:stop].compute()[:, 0, :] - - lines: List[str] = [] - for j in range(pos_chunk.shape[0]): - ad_row = ad_chunk[j] - if np.all(ad_row < 0): - # No call for this sample at this site, skip - # rather than write a misleading zero. - continue - depth = int(np.clip(ad_row, 0, None).sum()) - chrom = contigs[contig_chunk[j]] - # bedGraph coordinates are 0-based, half-open; - # variant_position is 1-based, and each SNP is a - # single base position. - bed_start = int(pos_chunk[j]) - 1 - bed_end = int(pos_chunk[j]) - lines.append(f"{chrom}\t{bed_start}\t{bed_end}\t{depth}\n") - f.write("".join(lines)) - - return output_path diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index beb72275b..a62f3958c 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -250,26 +250,20 @@ def snp_calls_to_vcf( optional_arrays, ) - n_samples = variant_chunk_data.gt_chunk.shape[1] - # OPTIMIZATION: Vectorize GT field formatting across entire chunk. # Instead of formatting each sample's GT field in a nested Python loop # (which results in billions of string operations for large datasets), # use NumPy's vectorized string operations on the entire chunk at once. # This provides ~3x speedup while maintaining exact output compatibility. # See issue #1280 for performance analysis. - gt_chunk_2d = variant_chunk_data.gt_chunk.reshape( - variant_chunk_data.gt_chunk.shape[0], - variant_chunk_data.gt_chunk.shape[1], - 2, - ) - a0 = gt_chunk_2d[:, :, 0] # (n_variants, n_samples) - a1 = gt_chunk_2d[:, :, 1] # (n_variants, n_samples) - missing = (a0 < 0) | (a1 < 0) # array of loci not present + gt_chunk_2d = variant_chunk_data.gt_chunk[:, 0, :] + a0 = gt_chunk_2d[:, 0] # n_variants + a1 = gt_chunk_2d[:, 1] # (n_variants + missing = (a0 < 0) | (a1 < 0) # Build formatted GT strings using NumPy vectorization gt_formatted = np.empty( - (variant_chunk_data.gt_chunk.shape[0], n_samples), dtype=object + variant_chunk_data.gt_chunk.shape[0], dtype=object ) gt_formatted[missing] = "./." present_idx = ~missing @@ -304,58 +298,45 @@ def snp_calls_to_vcf( f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\t.\t{format_str}\t" ) - # N.B., a plain Python list here, not a NumPy - # array: this loop builds a handful of short - # strings per variant via ordinary Python string - # concatenation, not a numeric/vectorized - # operation, so a `np.empty(..., dtype=object)` - # array bought nothing but the overhead of a - # NumPy allocation on every single variant row - # (up to ~150 million times for a whole-genome - # export). - sample_fields = [] - - # Use pre-formatted GT strings and add other fields - for k in range(n_samples): - parts = [gt_formatted[j, k]] - if parts != ["0/0"]: # homozygous genotype - # GQ. - if include_gq: - if variant_chunk_data.gq_chunk is not None: - v = variant_chunk_data.gq_chunk[j, k] - parts.append("." if v < 0 else str(v)) - else: - parts.append(".") - # AD. - if include_ad: - if variant_chunk_data.ad_chunk is not None: - ad_vals = variant_chunk_data.ad_chunk[j, k] - parts.append( - ",".join( - "." if x < 0 else str(x) - for x in ad_vals - ) - ) - else: - parts.append(".") - # MQ. Rounded to the nearest integer: the - # underlying data is a float, but the VCF - # spec fixes the reserved FORMAT/MQ key as - # Integer (see _FORMAT_HEADERS). - if include_mq: - if variant_chunk_data.mq_chunk is not None: - v = variant_chunk_data.mq_chunk[j, k] - if not math.isnan(v): - parts.append( - "." if v < 0 else str(round(v)) - ) - else: - parts.append(".") - sample_fields.append(":".join(parts)) - - # Build and buffer the line - line = fixed_cols + "\t".join(sample_fields) + "\n" - lines_to_write.append(line) + genotype = gt_formatted[j] + if genotype == "0/0": + continue + + parts = [genotype] + # GQ. + if include_gq: + if variant_chunk_data.gq_chunk is not None: + value = variant_chunk_data.gq_chunk[j, 0] + parts.append("." if value < 0 else str(value)) + else: + parts.append(".") + # AD. + if include_ad: + if variant_chunk_data.ad_chunk is not None: + ad_values = variant_chunk_data.ad_chunk[j, 0] + parts.append( + ",".join( + "." if value < 0 else str(value) + for value in ad_values + ) + ) + else: + parts.append(".") + # MQ. Rounded to the nearest integer: the + # underlying data is a float, but the VCF spec + # fixes the reserved FORMAT/MQ key as Integer. + if include_mq: + if variant_chunk_data.mq_chunk is not None: + value = variant_chunk_data.mq_chunk[j, 0] + if not math.isnan(value): + parts.append( + "." if value < 0 else str(round(value)) + ) + else: + parts.append(".") + + line = fixed_cols + ":".join(parts) + "\n" + lines_to_write.append(line) # Write buffered lines in one go per chunk f.write("".join(lines_to_write)) From c22b1b54c7ddf01f6cbe4c4cff88ccae957f203e Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Thu, 1 Oct 2026 14:07:13 +0100 Subject: [PATCH 23/38] removed OrderedDict --- malariagen_data/anoph/to_vcf.py | 7 +++---- malariagen_data/anoph/to_vcf_cnv.py | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index a62f3958c..22d90e94e 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -9,7 +9,6 @@ import numpy as np from numpydoc_decorator import doc # type: ignore from dataclasses import dataclass -from collections import OrderedDict import math from .snp_data import AnophelesSnpData @@ -351,7 +350,7 @@ def _get_chunks( pos_data: Array, contig_data: Array, allele_data: Array, - optional_arrays: OrderedDict, + optional_arrays: dict, ) -> tuple: start = offsets[ci] stop = offsets[ci + 1] @@ -401,7 +400,7 @@ def _get_chunks( def _get_optional_data( self, include_gq: bool, include_ad: bool, include_mq: bool, ds: Dataset - ) -> OrderedDict: + ) -> dict: # Optional field arrays — may not exist in all datasets. gq_data = None ad_data = None @@ -423,7 +422,7 @@ def _get_optional_data( pass # Which optional fields were requested, so we know what to # fetch (and where to put the results) for each chunk below. - optional_arrays = OrderedDict() # check needed + optional_arrays = {} if gq_data is not None: optional_arrays["GQ"] = gq_data if ad_data is not None: diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py index b42d63832..618c86c5f 100644 --- a/malariagen_data/anoph/to_vcf_cnv.py +++ b/malariagen_data/anoph/to_vcf_cnv.py @@ -12,6 +12,11 @@ from . import plink_params from . import vcf_params +# don't think we want this, IGV accepts seg format for CNVs +# VCF not well defined for CNVs +# use something like this: +# https://cnvkit.readthedocs.io/en/v0.7.7/fileformats.html + def _decode(value) -> str: return value.decode() if hasattr(value, "decode") else str(value) From f2e074fe2feb879adf7543ced2c059c6d0c318ca Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Thu, 1 Oct 2026 15:53:37 +0100 Subject: [PATCH 24/38] trying pysam so bgzf compression can be used so index needed for IGV can be made alognside VCF --- malariagen_data/anoph/to_vcf.py | 149 +++++++++++----------------- malariagen_data/anoph/to_vcf_cnv.py | 4 + malariagen_data/anopheles.py | 2 - poetry.lock | 57 ++++++++++- pyproject.toml | 1 + tests/anoph/test_vcf_exporter.py | 50 +++++----- 6 files changed, 144 insertions(+), 119 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 22d90e94e..f24a0fc66 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -1,4 +1,3 @@ -import gzip import os import re from datetime import date @@ -10,6 +9,7 @@ from numpydoc_decorator import doc # type: ignore from dataclasses import dataclass import math +import pysam from .snp_data import AnophelesSnpData from . import base_params @@ -107,8 +107,8 @@ def __init__( extended_summary=""" This function writes SNP calls to a VCF file. Data is written in chunks to avoid loading the entire genotype matrix into - memory. Supports optional gzip compression when the output - path ends with `.gz`. + memory. Output is BGZF-compressed and tabix-indexed; the + `output_path` must end with `.vcf.gz`. `sample_sets` and `sample_query` are both required: a VCF is only meaningful with respect to an explicit sample basis for @@ -143,6 +143,11 @@ def snp_calls_to_vcf( _validate_single_sample_selection( sample_sets=sample_sets, sample_query=sample_query ) + if not output_path.endswith(".vcf.gz"): + raise ValueError( + "output_path must end with .vcf.gz: " + "BGZF compression and tabix indexing require this suffix." + ) # Validate fields parameter. fields = tuple(fields) @@ -155,16 +160,12 @@ def snp_calls_to_vcf( if "GT" not in fields: raise ValueError("GT must be included in fields.") - # Canonicalise the field order to _FIELD_ORDER. The per-sample - # values below are always written in this fixed order; if the - # FORMAT column (built from `fields` further down) used the - # caller's order instead, a `fields` argument with a different - # (or undefined, e.g. a set) order would produce a VCF whose - # FORMAT column lies about which value is which — which is - # exactly what happened before this fix. + # Canonicalise the field order to _FIELD_ORDER fields = tuple(f for f in _FIELD_ORDER if f in fields) if os.path.exists(output_path) and not overwrite: + if not os.path.exists(output_path + ".tbi"): + pysam.tabix_index(output_path, preset="vcf") return output_path ds = self.snp_calls( @@ -190,39 +191,30 @@ def snp_calls_to_vcf( f"{sample_sets!r}, expected exactly 1." ) - sample_ids = ds["sample_id"].values + sample_id = ds["sample_id"].values[0] + sample_id = ( + sample_id.decode() if hasattr(sample_id, "decode") else str(sample_id) + ) contigs = ds.attrs.get("contigs", self.contigs) - compress = output_path.endswith(".gz") - opener = gzip.open if compress else open # Determine which extra fields to include. include_gq = "GQ" in fields include_ad = "AD" in fields include_mq = "MQ" in fields - format_str = ":".join(fields) - - with opener(output_path, "wt") as f: - # Write VCF header. - f.write("##fileformat=VCFv4.3\n") - f.write(f"##fileDate={date.today().strftime('%Y%m%d')}\n") - f.write("##source=malariagen_data\n") - for contig in contigs: - f.write(f"##contig=\n") - for field in fields: - f.write(_FORMAT_HEADERS[field] + "\n") - header_cols = [ - "#CHROM", - "POS", - "ID", - "REF", - "ALT", - "QUAL", - "FILTER", - "INFO", - "FORMAT", - ] - f.write("\t".join(header_cols + list(sample_ids)) + "\n") - + header = pysam.VariantHeader() + for header_record in list(header.records): + if header_record.key in {"fileformat", "FILTER"}: + header_record.remove() + header.add_meta("fileformat", value="VCFv4.3") + header.add_meta("fileDate", value=date.today().strftime("%Y%m%d")) + header.add_meta("source", value="malariagen_data") + for contig in contigs: + header.contigs.add(str(contig)) + for field in fields: + header.add_line(_FORMAT_HEADERS[field]) + header.add_sample(sample_id) + + with pysam.VariantFile(output_path, mode="w", header=header) as f: # Extract dask arrays. gt_data = ds["call_genotype"].data pos_data = ds["variant_position"].data @@ -249,36 +241,9 @@ def snp_calls_to_vcf( optional_arrays, ) - # OPTIMIZATION: Vectorize GT field formatting across entire chunk. - # Instead of formatting each sample's GT field in a nested Python loop - # (which results in billions of string operations for large datasets), - # use NumPy's vectorized string operations on the entire chunk at once. - # This provides ~3x speedup while maintaining exact output compatibility. - # See issue #1280 for performance analysis. - gt_chunk_2d = variant_chunk_data.gt_chunk[:, 0, :] - a0 = gt_chunk_2d[:, 0] # n_variants - a1 = gt_chunk_2d[:, 1] # (n_variants - missing = (a0 < 0) | (a1 < 0) - - # Build formatted GT strings using NumPy vectorization - gt_formatted = np.empty( - variant_chunk_data.gt_chunk.shape[0], dtype=object - ) - gt_formatted[missing] = "./." - present_idx = ~missing - if np.any(present_idx): - a0_str = a0[present_idx].astype(str) - a1_str = a1[present_idx].astype(str) - gt_formatted[present_idx] = np.char.add( - np.char.add(a0_str, "/"), a1_str - ) - - # Pre-allocate line buffer for better I/O - lines_to_write = [] - for j in range(variant_chunk_data.gt_chunk.shape[0]): chrom = contigs[variant_chunk_data.contig_chunk[j]] - pos = str(variant_chunk_data.pos_chunk[j]) + pos = int(variant_chunk_data.pos_chunk[j]) alleles = variant_chunk_data.allele_chunk[j] ref = ( alleles[0].decode() @@ -290,56 +255,56 @@ def snp_calls_to_vcf( s = a.decode() if hasattr(a, "decode") else str(a) if s: alt_alleles.append(s) - alt = ",".join(alt_alleles) if alt_alleles else "." - # Build fixed VCF columns once per variant - fixed_cols = ( - f"{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\t.\t{format_str}\t" + genotype_data = variant_chunk_data.gt_chunk[j, 0] + genotype = ( + (None,) * len(genotype_data) + if np.any(genotype_data < 0) + else tuple(int(allele) for allele in genotype_data) ) - - genotype = gt_formatted[j] - if genotype == "0/0": + if genotype == (0, 0): continue - parts = [genotype] + record = header.new_record( + contig=str(chrom), + start=pos - 1, + alleles=(ref, *alt_alleles), + ) + sample = record.samples[sample_id] + sample["GT"] = genotype # GQ. if include_gq: if variant_chunk_data.gq_chunk is not None: value = variant_chunk_data.gq_chunk[j, 0] - parts.append("." if value < 0 else str(value)) + sample["GQ"] = None if value < 0 else int(value) else: - parts.append(".") + sample["GQ"] = None # AD. if include_ad: if variant_chunk_data.ad_chunk is not None: ad_values = variant_chunk_data.ad_chunk[j, 0] - parts.append( - ",".join( - "." if value < 0 else str(value) - for value in ad_values - ) + sample["AD"] = tuple( + None if value < 0 else int(value) + for value in ad_values ) else: - parts.append(".") + sample["AD"] = None # MQ. Rounded to the nearest integer: the # underlying data is a float, but the VCF spec # fixes the reserved FORMAT/MQ key as Integer. if include_mq: if variant_chunk_data.mq_chunk is not None: value = variant_chunk_data.mq_chunk[j, 0] - if not math.isnan(value): - parts.append( - "." if value < 0 else str(round(value)) - ) + sample["MQ"] = ( + None + if math.isnan(value) or value < 0 + else round(value) + ) else: - parts.append(".") - - line = fixed_cols + ":".join(parts) + "\n" - lines_to_write.append(line) - - # Write buffered lines in one go per chunk - f.write("".join(lines_to_write)) + sample["MQ"] = None + f.write(record) + pysam.tabix_index(output_path, preset="vcf", force=overwrite) return output_path def _get_chunks( diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py index 618c86c5f..927c95134 100644 --- a/malariagen_data/anoph/to_vcf_cnv.py +++ b/malariagen_data/anoph/to_vcf_cnv.py @@ -16,6 +16,10 @@ # VCF not well defined for CNVs # use something like this: # https://cnvkit.readthedocs.io/en/v0.7.7/fileformats.html +# or maybe not: +# https://igv.org/doc/igvjs/#tracks/CNVPytor/ +# though it says only works for full genome, not regions, +# so maybe not useful for us def _decode(value) -> str: diff --git a/malariagen_data/anopheles.py b/malariagen_data/anopheles.py index 6d0cf6940..b775dad1e 100644 --- a/malariagen_data/anopheles.py +++ b/malariagen_data/anopheles.py @@ -38,7 +38,6 @@ from .anoph.ld import AnophelesLdAnalysis from .anoph.to_vcf import SnpVcfExporter from .anoph.to_vcf_cnv import CnvVcfExporter -from .anoph.to_coverage import CoverageExporter from .anoph.g123 import AnophelesG123Analysis from .anoph.fst import AnophelesFstAnalysis from .anoph.h12 import AnophelesH12Analysis @@ -96,7 +95,6 @@ class AnophelesDataResource( AnophelesLdAnalysis, SnpVcfExporter, CnvVcfExporter, - CoverageExporter, AnophelesIgv, AnophelesKaryotypeAnalysis, AnophelesAimData, diff --git a/poetry.lock b/poetry.lock index 9405fd2b8..2a96df4e9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.4.3 and should not be changed by hand. [[package]] name = "accessible-pygments" @@ -4548,6 +4548,59 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] +[[package]] +name = "pysam" +version = "0.24.1" +description = "Package for reading, manipulating, and writing genomic data" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "pysam-0.24.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3829b13896a624c47b17599e47bff28cbc87211c7777852ac1f11aa0697cc530"}, + {file = "pysam-0.24.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f842fc7638b8acccd5e470820cff3f490c5845e616fa668667531da22b686a7b"}, + {file = "pysam-0.24.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f3abec4f08929c5090f747975787febe7db437bad34349f29c8e0328d6f9ad06"}, + {file = "pysam-0.24.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e601c4626e7310db74823a4152483bf903392ff1d30eec619594808280da699"}, + {file = "pysam-0.24.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:84c80a7d3475e675d142a850ff3ea0d4a929e698130f01323f1a550a0e13cc27"}, + {file = "pysam-0.24.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:10cc2b840ef651be8c7087d7c0c9c51e220162eae1e5ad68b6ccf427594357fc"}, + {file = "pysam-0.24.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f1bdd44bcd85d8562925436bec24dcf7325e4001575a9c24d58806b93de2293"}, + {file = "pysam-0.24.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0e48e4b3d341734078e97fe05a2358d60837ca88741625ec17d45ba7c629dc64"}, + {file = "pysam-0.24.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c21dd9b801175d14c4d7b78898de921f8771edf141db5957226c9bf1ed4bf293"}, + {file = "pysam-0.24.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:050d4c72211a961d26fad70b655694d4d500422e4b7d0ed3c7f244c49df8d16e"}, + {file = "pysam-0.24.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8696e88156edee884416fd50c15fcc61da67089232198c1ae731731f6da765d6"}, + {file = "pysam-0.24.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f34eba531bdfd71817110a56c00443f9947d3a01e10358f341d10f614ea3bf1e"}, + {file = "pysam-0.24.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1d114ddd64b562d2fe253a31703613b762c71b4a3d856ac960a39e40269c51fa"}, + {file = "pysam-0.24.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ceb448961fd35b5b90795d7c7c80b1b35592be7ae0127e28187e3f41c27e035b"}, + {file = "pysam-0.24.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39914c2e395be44126e120be0933aaea3ea1d664f3c421a91afc4be086b49a79"}, + {file = "pysam-0.24.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:06eabdc8f7c3894b73d2c4365ea6197d6ba5308e203dd2887b5df635fe6e249b"}, + {file = "pysam-0.24.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2c03ca38923941e460a5edc62d9208393ee9083ecd3f57a3e5a96c1337112dc7"}, + {file = "pysam-0.24.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2fbbcd9ccad9627e6b9a46bbb93e0a244c137ecaa6d7d471033f9b75bc17e6e0"}, + {file = "pysam-0.24.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c7e756b8a9da0f04f6e1ccaad611513f6d52e622b1ae03dcace76af3722100a9"}, + {file = "pysam-0.24.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a52f12c808e53fd16c7f3c42d95914a9d5084a5504f3c32a5138ba08bdfa8408"}, + {file = "pysam-0.24.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:817624cb93fc2373bf3d3e7298a59db88323308b25fcdfd19a0a4df6f119e8dd"}, + {file = "pysam-0.24.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:68b742b2db84cf3982c21be69f886baf3d3cb49fbb070cb4a4c09b4d2fc907c0"}, + {file = "pysam-0.24.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:fdb008b9dfe673ec029189f6394b2d60ce1380ee387c106e799ada237809b2ee"}, + {file = "pysam-0.24.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5cb4a0ffe496111d0acead00a60f2e7e977a4d716089367dc6cc8c0cf511fcbb"}, + {file = "pysam-0.24.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:ec95cc0c4a4fbea432066d9d8e2f566ab4e1e11b4a4bb70b2143ed5b9f2fbf3b"}, + {file = "pysam-0.24.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:897f9a76dfc568e0a18350c5d545cc158e2200884c59ec2eb9895385e33b4315"}, + {file = "pysam-0.24.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9598dd5a571c5c8b4383b4fe1a27823d72b3261c5299100cf3d88dfb09b45019"}, + {file = "pysam-0.24.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:25ffcc2aca0a49358c02e666ddd789afe701c5cf320dcb894ac22ede7347049f"}, + {file = "pysam-0.24.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e520b7311e3822ce029adaf24472e563e724cec442314c6c702956e242dc27d4"}, + {file = "pysam-0.24.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a4e0206a6b8c2b84686f0c5f9087b69dc4c1e8d5e66c98970f86809947d7cb0a"}, + {file = "pysam-0.24.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:1527e9fcfbdbc72d8bf3e06970cca229a041eefe36a30bf14997f52c1f29ccf6"}, + {file = "pysam-0.24.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:886f5c1a2a45b174345c217c821cbd4231311d43ecf5e8157cc7a4bee5db182a"}, + {file = "pysam-0.24.1-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:57d7921761ce2b902711e55857f861733b909155fb6299b5559da4a20a353eeb"}, + {file = "pysam-0.24.1-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7a22778002a2a401374733dc5698bc3552ff0a6c43d27aeaf37976048bd3d867"}, + {file = "pysam-0.24.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:15dca5345f67b622dfb303ed5328e13799ffc13df12407a6d4542caab5a6ffb1"}, + {file = "pysam-0.24.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:b64fb7c97f8ad78fd5b8cd16f0d8b931d89f0c30b48a061625280ce8b2145782"}, + {file = "pysam-0.24.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0b4b1fec32675cfb992cd6c23e0fbf86481f695959e3973e00c9c1432c78d801"}, + {file = "pysam-0.24.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:cb70dd2c190dab4de044d8d2168c4d74fbc8acad9b9993bdf235c85b1c9b9ce6"}, + {file = "pysam-0.24.1-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a222fb89c91c8acdbe4e77f233c9ee1b9ab2e832afae49797ddefedfbb3191a3"}, + {file = "pysam-0.24.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d5fd6fbd19fa0f833f0e7f02ce16e99679b58fbe311b818fb7ddac2a6a435eef"}, + {file = "pysam-0.24.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1f672fc17990d395d658e191b57c681bd101ae7b4825446a6938fc9ddb797630"}, + {file = "pysam-0.24.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b8281b79e8b989c224ba0a7de41d06a47c38a0767f1efdfa2cbff1cee86deb6a"}, + {file = "pysam-0.24.1.tar.gz", hash = "sha256:90f612afccdb454d2447ecb5229266c6e7f991093deed4ed0a791db01f7fc994"}, +] + [[package]] name = "pytest" version = "9.0.1" @@ -6417,4 +6470,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.10,<3.13" -content-hash = "064fbc09218cd1b8480ad0cc9bf921218e72302757230c244948b85adadd54d9" +content-hash = "e850038fc2366ed56556f41e363264d87030fc3489e6372a6ab7b26acd1a804e" diff --git a/pyproject.toml b/pyproject.toml index f061b25fa..03761d9aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ BioPython = "*" scikit-allel = ">=1.3.13" xarray = "*" plotly = "*" +pysam = ">=0.22.0" # https://github.com/malariagen/malariagen-data-python/issues/845 # https://github.com/malariagen/malariagen-data-python/issues/734 # https://github.com/malariagen/malariagen-data-python/issues/743 diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 2edc02c27..a87669fe3 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -6,6 +6,7 @@ import dask.array as da import numpy as np +import pysam import pytest import xarray as xr from pytest_cases import parametrize_with_cases @@ -105,12 +106,12 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): # sample. assert list(sample_ids) == [sample_id] - output_path = str(tmp_path / "test.vcf") + output_path = str(tmp_path / "test.vcf.gz") api.snp_calls_to_vcf(output_path=output_path, **data_params) assert os.path.exists(output_path) - with open(output_path) as f: + with gzip.open(output_path, "rt") as f: lines = f.readlines() header_lines = [line for line in lines if line.startswith("##")] @@ -172,14 +173,14 @@ def test_vcf_exporter_non_ref_only(fixture, api: SnpVcfExporter, tmp_path): expect_keep = ~is_missing & ~is_hom_ref expected_positions = sorted(ds["variant_position"].values[expect_keep].tolist()) - output_path = str(tmp_path / "test_non_ref_only.vcf") + output_path = str(tmp_path / "test_non_ref_only.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, non_ref_only=True, **data_params, ) - with open(output_path) as f: + with gzip.open(output_path, "rt") as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] @@ -209,8 +210,8 @@ def test_vcf_exporter_non_ref_only_defaults_to_false( sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path_default = str(tmp_path / "default.vcf") - output_path_explicit = str(tmp_path / "explicit_false.vcf") + output_path_default = str(tmp_path / "default.vcf.gz") + output_path_explicit = str(tmp_path / "explicit_false.vcf.gz") api.snp_calls_to_vcf( output_path=output_path_default, region=region, @@ -225,9 +226,9 @@ def test_vcf_exporter_non_ref_only_defaults_to_false( non_ref_only=False, ) - with open(output_path_default) as f: + with gzip.open(output_path_default, "rt") as f: default_lines = f.readlines() - with open(output_path_explicit) as f: + with gzip.open(output_path_explicit, "rt") as f: explicit_lines = f.readlines() assert default_lines == explicit_lines @@ -242,7 +243,7 @@ def test_vcf_exporter_non_ref_only_valid_per_bcftools( sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test_non_ref_only_bcftools.vcf") + output_path = str(tmp_path / "test_non_ref_only_bcftools.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=region, @@ -270,7 +271,7 @@ def test_vcf_exporter_requires_sample_sets_and_query( # explicit cohort/sample basis for the calls it contains is not # meaningful. region = api.contigs[0] - output_path = str(tmp_path / "test_missing_args.vcf") + output_path = str(tmp_path / "test_missing_args.vcf.gz") with pytest.raises(TypeError): api.snp_calls_to_vcf(output_path=output_path, region=region) # type: ignore[call-arg] @@ -286,7 +287,7 @@ def test_vcf_exporter_requires_sample_sets_and_query( @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_empty_sample_sets(fixture, api: SnpVcfExporter, tmp_path): region = api.contigs[0] - output_path = str(tmp_path / "test_empty_sample_sets.vcf") + output_path = str(tmp_path / "test_empty_sample_sets.vcf.gz") with pytest.raises(ValueError, match="sample_sets must be provided"): api.snp_calls_to_vcf( @@ -302,7 +303,7 @@ def test_vcf_exporter_empty_sample_query(fixture, api: SnpVcfExporter, tmp_path) region = api.contigs[0] all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] - output_path = str(tmp_path / "test_empty_sample_query.vcf") + output_path = str(tmp_path / "test_empty_sample_query.vcf.gz") with pytest.raises(ValueError, match="sample_query must be provided"): api.snp_calls_to_vcf( @@ -324,7 +325,7 @@ def test_vcf_exporter_multi_sample_query_rejected( region = api.contigs[0] all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] - output_path = str(tmp_path / "test_multi_sample_query.vcf") + output_path = str(tmp_path / "test_multi_sample_query.vcf.gz") for bad_query in [ "country == 'Uganda'", @@ -352,7 +353,7 @@ def test_vcf_exporter_sample_query_matches_zero_samples( region = api.contigs[0] all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] - output_path = str(tmp_path / "test_zero_sample_query.vcf") + output_path = str(tmp_path / "test_zero_sample_query.vcf.gz") with pytest.raises(ValueError): api.snp_calls_to_vcf( @@ -369,7 +370,7 @@ def test_vcf_exporter_overwrite(fixture, api: SnpVcfExporter, tmp_path): all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test.vcf") + output_path = str(tmp_path / "test.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, @@ -397,6 +398,9 @@ def test_vcf_exporter_overwrite(fixture, api: SnpVcfExporter, tmp_path): overwrite=True, ) assert os.path.exists(output_path) + assert os.path.exists(output_path + ".tbi") + with pysam.VariantFile(output_path) as vcf: + list(vcf.fetch()) @parametrize_with_cases("fixture,api", cases=".") @@ -440,7 +444,7 @@ def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): _, sample_query = _pick_single_sample_query(api, sample_sets) # Test with additional FORMAT fields. - output_path = str(tmp_path / "test_fields.vcf") + output_path = str(tmp_path / "test_fields.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=region, @@ -449,7 +453,7 @@ def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): fields=("GT", "GQ"), ) - with open(output_path) as f: + with gzip.open(output_path, "rt") as f: lines = f.readlines() # Check FORMAT header lines. @@ -486,7 +490,7 @@ def test_vcf_exporter_fields_as_set(fixture, api: SnpVcfExporter, tmp_path): sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test_fields_set.vcf") + output_path = str(tmp_path / "test_fields_set.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=region, @@ -495,7 +499,7 @@ def test_vcf_exporter_fields_as_set(fixture, api: SnpVcfExporter, tmp_path): fields={"GT", "GQ", "AD", "MQ"}, ) - with open(output_path) as f: + with gzip.open(output_path, "rt") as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] @@ -538,7 +542,7 @@ def test_vcf_exporter_output_is_valid_per_bcftools( sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test_bcftools_valid.vcf") + output_path = str(tmp_path / "test_bcftools_valid.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=region, @@ -567,7 +571,7 @@ def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path) all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test_no_gt.vcf") + output_path = str(tmp_path / "test_no_gt.vcf.gz") with pytest.raises(ValueError, match="GT must be included"): api.snp_calls_to_vcf( @@ -678,7 +682,7 @@ def test_vcf_exporter_allele_index_remapping( ) monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) - output_path = str(tmp_path / "test_allele_remap.vcf") + output_path = str(tmp_path / "test_allele_remap.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=contig, @@ -686,7 +690,7 @@ def test_vcf_exporter_allele_index_remapping( sample_query=f"sample_id == '{sample}'", ) - with open(output_path) as f: + with gzip.open(output_path, "rt") as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] assert len(data_lines) == n_variants From e12691209b33f032e34cd291a2734acf0317462a Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Thu, 1 Oct 2026 17:04:38 +0100 Subject: [PATCH 25/38] wired through to IGV, checked with notebook --- malariagen_data/anoph/igv.py | 13 ++++++++- notebooks/igv.ipynb | 42 +++++++++++++++++++++++++++-- tests/anoph/test_igv.py | 52 ++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) diff --git a/malariagen_data/anoph/igv.py b/malariagen_data/anoph/igv.py index 59680640b..cccf7f877 100644 --- a/malariagen_data/anoph/igv.py +++ b/malariagen_data/anoph/igv.py @@ -82,6 +82,7 @@ def _igv_view_alignments_tracks( region: Region, sample: str, visibility_window: int = 20_000, + snp_vcf_url: Optional[str] = None, ): # Look up sample set for sample. try: @@ -99,7 +100,9 @@ def _igv_view_alignments_tracks( # Locate record for sample. cat_rec = df_cat.set_index("sample_id").loc[sample] bam_url = cat_rec["alignments_bam"] - vcf_url = cat_rec["snp_genotypes_vcf"] + vcf_url = ( + snp_vcf_url if snp_vcf_url is not None else cat_rec["snp_genotypes_vcf"] + ) # Set up site filters tracks. contig = region.contig @@ -183,6 +186,12 @@ def igv( visible. """, init="If True, call igv_notebook.init().", + snp_vcf_url=""" + Optional URL for a local, tabix-indexed VCF. For Jupyter Notebook + and Lab, the VCF and its `.tbi` index must be under the Jupyter + startup directory tree; pass a URL relative to that tree (e.g. + `/data/sample.vcf.gz`). If omitted, use the catalog VCF. + """, ), ) def view_alignments( @@ -191,6 +200,7 @@ def view_alignments( sample: str, visibility_window: int = 20_000, init: bool = True, + snp_vcf_url: Optional[str] = None, ): # Parse region. region_prepped: Region = _parse_single_region(self, region) @@ -201,6 +211,7 @@ def view_alignments( region=region_prepped, sample=sample, visibility_window=visibility_window, + snp_vcf_url=snp_vcf_url, ) # Create IGV browser. diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index 104f217f0..b7fc56328 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -200,13 +200,51 @@ ")" ] }, + { + "cell_type": "markdown", + "id": "17", + "metadata": {}, + "source": [ + "## Local tabix-indexed VCF in IGV\n", + "This exports one sample to a BGZF VCF and `.tbi` under the notebook working directory, then loads it as the SNP track. Both files must be inside the Jupyter server startup directory tree. The `snp_vcf_url` below assumes the server was started from the workspace root; if it was started from `notebooks/`, use the alternate URL shown in the code cell." + ] + }, { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "18", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "from pathlib import Path\n", + "\n", + "\n", + "sample_set = \"1229-VO-GH-DADZIE-VMF00095\"\n", + "sample_id = str(\n", + " af1.sample_metadata(sample_sets=sample_set).iloc[0][\"sample_id\"]\n", + ")\n", + "region = \"2RL:2,447,600-2,447,700\"\n", + "\n", + "local_vcf_path = Path(\"local_igv_vcfs\") / f\"{sample_id}.vcf.gz\"\n", + "local_vcf_path.parent.mkdir(parents=True, exist_ok=True)\n", + "\n", + "af1.snp_calls_to_vcf(\n", + " output_path=str(local_vcf_path),\n", + " region=region,\n", + " sample_sets=[sample_set],\n", + " sample_query=f\"sample_id == '{sample_id}'\",\n", + ")\n", + "\n", + "# The URL is relative to the Jupyter server startup directory.\n", + "# If started from notebooks/, use f\"/{local_vcf_path.as_posix()}\" instead.\n", + "snp_vcf_url = f\"/notebooks/{local_vcf_path.as_posix()}\"\n", + "\n", + "af1.view_alignments(\n", + " sample=sample_id,\n", + " region=region,\n", + " snp_vcf_url=snp_vcf_url,\n", + ")" + ] } ], "metadata": { diff --git a/tests/anoph/test_igv.py b/tests/anoph/test_igv.py index 7d3680ffb..8aaa1eef1 100644 --- a/tests/anoph/test_igv.py +++ b/tests/anoph/test_igv.py @@ -1,10 +1,14 @@ +from types import SimpleNamespace + import igv_notebook # type: ignore import numpy as np +import pandas as pd import pytest from pytest_cases import parametrize_with_cases from malariagen_data import af1 as _af1 from malariagen_data import ag3 as _ag3 +import malariagen_data.anoph.igv as igv_module from malariagen_data.anoph.igv import AnophelesIgv @@ -84,3 +88,51 @@ def test_view_alignments(fixture, api: AnophelesIgv): ret = api.view_alignments(region=region, sample=sample, init=False) # No return value to avoid cluttering notebook output. assert ret is None + + +def test_view_alignments_with_local_snp_vcf(monkeypatch): + class FakeAnophelesIgv(AnophelesIgv): + @property + def site_mask_ids(self): + return [] + + def sample_metadata(self): + return pd.DataFrame({"sample_id": ["S1"], "sample_set": ["set1"]}) + + def wgs_data_catalog(self, sample_set): + return pd.DataFrame( + { + "sample_id": ["S1"], + "alignments_bam": ["https://example.org/S1.bam"], + "snp_genotypes_vcf": ["https://example.org/S1.vcf.gz"], + } + ) + + api = object.__new__(FakeAnophelesIgv) + captured = {} + monkeypatch.setattr( + igv_module, + "_parse_single_region", + lambda self, region: SimpleNamespace(contig="2L"), + ) + monkeypatch.setattr( + api, + "igv", + lambda **kwargs: captured.update(kwargs), + ) + local_vcf_url = "/data/sample.vcf.gz" + api.view_alignments( + region="2L:1-10", + sample="S1", + init=False, + snp_vcf_url=local_vcf_url, + ) + + snp_track = next(track for track in captured["tracks"] if track["name"] == "SNPs") + assert snp_track["url"] == local_vcf_url + assert snp_track["indexURL"] == f"{local_vcf_url}.tbi" + + captured.clear() + api.view_alignments(region="2L:1-10", sample="S1", init=False) + snp_track = next(track for track in captured["tracks"] if track["name"] == "SNPs") + assert snp_track["url"] == "https://example.org/S1.vcf.gz" From 04f6c83b62e975e836e6926170002e7718192e15 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 5 Oct 2026 10:20:32 +0100 Subject: [PATCH 26/38] fixed type annotaitons and moved homozygous check --- malariagen_data/anoph/to_vcf.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index f24a0fc66..d62d03612 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -1,14 +1,14 @@ import os import re +import math from datetime import date +from dataclasses import dataclass from typing import Optional import dask from dask.array.core import Array from xarray.core.dataset import Dataset import numpy as np from numpydoc_decorator import doc # type: ignore -from dataclasses import dataclass -import math import pysam from .snp_data import AnophelesSnpData @@ -19,13 +19,13 @@ @dataclass class VariantChunkData: - gq_chunk: Array - ad_chunk: Array - mq_chunk: Array - gt_chunk: Array - pos_chunk: Array - contig_chunk: Array - allele_chunk: Array + gq_chunk: Optional[np.ndarray] + ad_chunk: Optional[np.ndarray] + mq_chunk: Optional[np.ndarray] + gt_chunk: np.ndarray + pos_chunk: np.ndarray + contig_chunk: np.ndarray + allele_chunk: np.ndarray # Supported FORMAT fields, the fixed order in which their values are @@ -242,6 +242,9 @@ def snp_calls_to_vcf( ) for j in range(variant_chunk_data.gt_chunk.shape[0]): + genotype_data = variant_chunk_data.gt_chunk[j, 0] + if np.array_equal(genotype_data, (0, 0)): + continue chrom = contigs[variant_chunk_data.contig_chunk[j]] pos = int(variant_chunk_data.pos_chunk[j]) alleles = variant_chunk_data.allele_chunk[j] @@ -262,8 +265,6 @@ def snp_calls_to_vcf( if np.any(genotype_data < 0) else tuple(int(allele) for allele in genotype_data) ) - if genotype == (0, 0): - continue record = header.new_record( contig=str(chrom), @@ -310,13 +311,13 @@ def snp_calls_to_vcf( def _get_chunks( self, ci: int, - offsets: np.array, + offsets: np.ndarray, gt_data: Array, pos_data: Array, contig_data: Array, allele_data: Array, - optional_arrays: dict, - ) -> tuple: + optional_arrays: dict[str, Array], + ) -> VariantChunkData: start = offsets[ci] stop = offsets[ci + 1] @@ -365,7 +366,7 @@ def _get_chunks( def _get_optional_data( self, include_gq: bool, include_ad: bool, include_mq: bool, ds: Dataset - ) -> dict: + ) -> dict[str, Array]: # Optional field arrays — may not exist in all datasets. gq_data = None ad_data = None From b9db52d58a0c72aa245a6892965bd4a691e21216 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 5 Oct 2026 14:10:34 +0100 Subject: [PATCH 27/38] removed the to_vcf_cnf draft for now --- malariagen_data/anoph/to_vcf_cnv.py | 422 ---------------------------- 1 file changed, 422 deletions(-) delete mode 100644 malariagen_data/anoph/to_vcf_cnv.py diff --git a/malariagen_data/anoph/to_vcf_cnv.py b/malariagen_data/anoph/to_vcf_cnv.py deleted file mode 100644 index 927c95134..000000000 --- a/malariagen_data/anoph/to_vcf_cnv.py +++ /dev/null @@ -1,422 +0,0 @@ -import os -from datetime import date -from typing import List, Optional, Sequence -import gzip - -import numpy as np -from numpydoc_decorator import doc # type: ignore - -from .cnv_data import AnophelesCnvData -from . import base_params -from . import cnv_params -from . import plink_params -from . import vcf_params - -# don't think we want this, IGV accepts seg format for CNVs -# VCF not well defined for CNVs -# use something like this: -# https://cnvkit.readthedocs.io/en/v0.7.7/fileformats.html -# or maybe not: -# https://igv.org/doc/igvjs/#tracks/CNVPytor/ -# though it says only works for full genome, not regions, -# so maybe not useful for us - - -def _decode(value) -> str: - return value.decode() if hasattr(value, "decode") else str(value) - - -def _write_vcf_header( - f, - *, - contigs: Sequence[str], - sample_ids: Sequence[str], - info_lines: Sequence[str], - format_lines: Sequence[str], - alt_lines: Sequence[str] = (), -) -> None: - f.write("##fileformat=VCFv4.3\n") - f.write(f"##fileDate={date.today().strftime('%Y%m%d')}\n") - f.write("##source=malariagen_data\n") - for contig in contigs: - f.write(f"##contig=\n") - for line in alt_lines: - f.write(line + "\n") - for line in info_lines: - f.write(line + "\n") - for line in format_lines: - f.write(line + "\n") - header_cols = [ - "#CHROM", - "POS", - "ID", - "REF", - "ALT", - "QUAL", - "FILTER", - "INFO", - "FORMAT", - ] - f.write("\t".join(header_cols + list(sample_ids)) + "\n") - - -class CnvVcfExporter( - AnophelesCnvData, -): - """ - Export CNV calls to VCF. - - N.B., unlike SNP calls, CNV calls are not fully standardised in VCF. - Here each CNV region or call is written as a single symbolic `` - ALT allele (REF is written as "N", per the VCF specification for - imprecise/symbolic variants), with the relevant per-sample data - encoded in FORMAT fields. This is a draft representation intended - to give IGV something sensible to render, and to remove the - dependency on separately-hosted CNV VCF files; it is not intended - to be a fully general-purpose CNV VCF writer. - """ - - def __init__( - self, - **kwargs, - ): - # N.B., this class is designed to work cooperatively, and - # so it's important that any remaining parameters are passed - # to the superclass constructor. - super().__init__(**kwargs) - - @doc( - summary=""" - Export CNV HMM copy number calls to Variant Call Format (VCF). - """, - extended_summary=""" - This function writes genome-wide CNV HMM calls to a VCF file. - Each CNV region is written as a symbolic `` allele, with - the estimated copy number for each sample stored in the `CN` - FORMAT field. Data is written in chunks to avoid loading the - entire array into memory. Supports optional gzip compression - when the output path ends with `.gz`. - """, - returns=""" - Path to the VCF output file. - """, - ) - def cnv_hmm_to_vcf( - self, - output_path: vcf_params.vcf_output_path, - region: base_params.regions, - sample_sets: Optional[base_params.sample_sets] = None, - sample_query: Optional[base_params.sample_query] = None, - sample_query_options: Optional[base_params.sample_query_options] = None, - max_coverage_variance: cnv_params.max_coverage_variance = cnv_params.max_coverage_variance_default, - inline_array: base_params.inline_array = base_params.inline_array_default, - chunks: base_params.chunks = base_params.native_chunks, - overwrite: plink_params.overwrite = False, - ) -> str: - if os.path.exists(output_path) and not overwrite: - return output_path - - ds = self.cnv_hmm( - region=region, - sample_sets=sample_sets, - sample_query=sample_query, - sample_query_options=sample_query_options, - max_coverage_variance=max_coverage_variance, - inline_array=inline_array, - chunks=chunks, - ) - - sample_ids = ds["sample_id"].values - contigs = ds.attrs.get("contigs", self.contigs) - compress = output_path.endswith(".gz") - # N.B., genuine BGZF, not plain gzip: tools that specifically - # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can - # fail to read, or silently mis-parse, plain gzip even though - # it decompresses fine as a byte stream. - opener = gzip.open if compress else open - - with opener(output_path, "wt") as f: - _write_vcf_header( - f, - contigs=contigs, - sample_ids=sample_ids, - alt_lines=[ - '##ALT=', - ], - info_lines=[ - '##INFO=', - ], - format_lines=[ - '##FORMAT=', - ], - ) - - pos_data = ds["variant_position"].data - end_data = ds["variant_end"].data - contig_data = ds["variant_contig"].data - cn_data = ds["call_CN"].data - - chunk_sizes = pos_data.chunks[0] - offsets = np.cumsum((0,) + chunk_sizes) - - with self._spinner(f"Write VCF ({ds.sizes['variants']} CNV HMM regions)"): - for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - pos_chunk = pos_data[start:stop].compute() - end_chunk = end_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - cn_chunk = cn_data[start:stop].compute() - - lines: List[str] = [] - for j in range(pos_chunk.shape[0]): - chrom = contigs[contig_chunk[j]] - pos = str(pos_chunk[j]) - end = int(end_chunk[j]) - info = f"END={end}" - sample_fields = ( - "." if v < 0 else str(int(v)) for v in cn_chunk[j] - ) - lines.append( - f"{chrom}\t{pos}\t.\tN\t\t.\t.\t{info}\tCN\t" - + "\t".join(sample_fields) - + "\n" - ) - f.write("".join(lines)) - - return output_path - - @doc( - summary=""" - Export CNV coverage calls to Variant Call Format (VCF). - """, - extended_summary=""" - This function writes CNV coverage calls (discrete CNV alleles - called from read coverage) to a VCF file. Each CNV allele is - written as a symbolic `` allele, with the presence/absence - call for each sample stored in the `GT` FORMAT field (as a - haploid call: "1" if the CNV allele was called, "0" if not, - "." if missing). Data is written in chunks to avoid loading - the entire array into memory. Supports optional gzip - compression when the output path ends with `.gz`. - """, - returns=""" - Path to the VCF output file. - """, - ) - def cnv_coverage_calls_to_vcf( - self, - output_path: vcf_params.vcf_output_path, - region: base_params.regions, - sample_set: base_params.sample_set, - analysis: cnv_params.coverage_calls_analysis, - inline_array: base_params.inline_array = base_params.inline_array_default, - chunks: base_params.chunks = base_params.native_chunks, - overwrite: plink_params.overwrite = False, - ) -> str: - if os.path.exists(output_path) and not overwrite: - return output_path - - ds = self.cnv_coverage_calls( - region=region, - sample_set=sample_set, - analysis=analysis, - inline_array=inline_array, - chunks=chunks, - ) - - sample_ids = ds["sample_id"].values - contigs = ds.attrs.get("contigs", self.contigs) - compress = output_path.endswith(".gz") - # N.B., genuine BGZF, not plain gzip: tools that specifically - # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can - # fail to read, or silently mis-parse, plain gzip even though - # it decompresses fine as a byte stream. - opener = gzip.open if compress else open - - with opener(output_path, "wt") as f: - _write_vcf_header( - f, - contigs=contigs, - sample_ids=sample_ids, - alt_lines=[ - '##ALT=', - ], - info_lines=[ - '##INFO=', - '##INFO=', - '##INFO=', - ], - format_lines=[ - '##FORMAT=', - ], - ) - - pos_data = ds["variant_position"].data - end_data = ds["variant_end"].data - contig_data = ds["variant_contig"].data - id_data = ds["variant_id"].data - cipos_data = ds["variant_CIPOS"].data - ciend_data = ds["variant_CIEND"].data - filter_data = ds["variant_filter_pass"].data - gt_data = ds["call_genotype"].data - - chunk_sizes = pos_data.chunks[0] - offsets = np.cumsum((0,) + chunk_sizes) - - with self._spinner( - f"Write VCF ({ds.sizes['variants']} CNV coverage calls)" - ): - for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - pos_chunk = pos_data[start:stop].compute() - end_chunk = end_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - id_chunk = id_data[start:stop].compute() - cipos_chunk = cipos_data[start:stop].compute() - ciend_chunk = ciend_data[start:stop].compute() - filter_chunk = filter_data[start:stop].compute() - gt_chunk = gt_data[start:stop].compute() - - lines: List[str] = [] - for j in range(pos_chunk.shape[0]): - chrom = contigs[contig_chunk[j]] - pos = str(pos_chunk[j]) - variant_id = _decode(id_chunk[j]) - end = int(end_chunk[j]) - filt = "PASS" if filter_chunk[j] else "." - info = ( - f"END={end};CIPOS={int(cipos_chunk[j])}" - f";CIEND={int(ciend_chunk[j])}" - ) - sample_fields = ( - "." if v < 0 else str(int(v)) for v in gt_chunk[j] - ) - lines.append( - f"{chrom}\t{pos}\t{variant_id}\tN\t\t.\t{filt}\t{info}\tGT\t" - + "\t".join(sample_fields) - + "\n" - ) - f.write("".join(lines)) - - return output_path - - @doc( - summary=""" - Export CNV discordant read calls to Variant Call Format (VCF). - """, - extended_summary=""" - This function writes CNV discordant read calls (CNV alleles - supported by discordant/paired-end read evidence) to a VCF - file. Each CNV allele is written as a symbolic `` allele, - with the call for each sample stored in the `GT` FORMAT field - (as a haploid call: "1" if the CNV allele was called, "0" if - not, "." if missing). Data is written in chunks to avoid - loading the entire array into memory. Supports optional gzip - compression when the output path ends with `.gz`. - """, - returns=""" - Path to the VCF output file. - """, - ) - def cnv_discordant_read_calls_to_vcf( - self, - output_path: vcf_params.vcf_output_path, - contigs: base_params.contigs, - sample_sets: Optional[base_params.sample_sets] = None, - sample_query: Optional[base_params.sample_query] = None, - sample_query_options: Optional[base_params.sample_query_options] = None, - inline_array: base_params.inline_array = base_params.inline_array_default, - chunks: base_params.chunks = base_params.native_chunks, - overwrite: plink_params.overwrite = False, - ) -> str: - if os.path.exists(output_path) and not overwrite: - return output_path - - ds = self.cnv_discordant_read_calls( - contigs=contigs, - sample_sets=sample_sets, - sample_query=sample_query, - sample_query_options=sample_query_options, - inline_array=inline_array, - chunks=chunks, - ) - - sample_ids = ds["sample_id"].values - all_contigs = ds.attrs.get("contigs", self.contigs) - compress = output_path.endswith(".gz") - # N.B., genuine BGZF, not plain gzip: tools that specifically - # expect BGZF for a .vcf.gz file (tabix, bedtools, ...) can - # fail to read, or silently mis-parse, plain gzip even though - # it decompresses fine as a byte stream. - opener = gzip.open if compress else open - - with opener(output_path, "wt") as f: - _write_vcf_header( - f, - contigs=all_contigs, - sample_ids=sample_ids, - alt_lines=[ - '##ALT=', - ], - info_lines=[ - '##INFO=', - '##INFO=', - '##INFO=', - '##INFO=', - ], - format_lines=[ - '##FORMAT=', - ], - ) - - pos_data = ds["variant_position"].data - end_data = ds["variant_end"].data - contig_data = ds["variant_contig"].data - id_data = ds["variant_id"].data - region_data = ds["variant_Region"].data - sbm_data = ds["variant_StartBreakpointMethod"].data - ebm_data = ds["variant_EndBreakpointMethod"].data - gt_data = ds["call_genotype"].data - - chunk_sizes = pos_data.chunks[0] - offsets = np.cumsum((0,) + chunk_sizes) - - with self._spinner( - f"Write VCF ({ds.sizes['variants']} CNV discordant read calls)" - ): - for ci in range(len(chunk_sizes)): - start = offsets[ci] - stop = offsets[ci + 1] - pos_chunk = pos_data[start:stop].compute() - end_chunk = end_data[start:stop].compute() - contig_chunk = contig_data[start:stop].compute() - id_chunk = id_data[start:stop].compute() - region_chunk = region_data[start:stop].compute() - sbm_chunk = sbm_data[start:stop].compute() - ebm_chunk = ebm_data[start:stop].compute() - gt_chunk = gt_data[start:stop].compute() - - lines: List[str] = [] - for j in range(pos_chunk.shape[0]): - chrom = all_contigs[contig_chunk[j]] - pos = str(pos_chunk[j]) - variant_id = _decode(id_chunk[j]) - end = int(end_chunk[j]) - region_val = _decode(region_chunk[j]) - info = ( - f"END={end};REGION={region_val}" - f";SBM={int(sbm_chunk[j])};EBM={int(ebm_chunk[j])}" - ) - sample_fields = ( - "." if v < 0 else str(int(v)) for v in gt_chunk[j] - ) - lines.append( - f"{chrom}\t{pos}\t{variant_id}\tN\t\t.\t.\t{info}\tGT\t" - + "\t".join(sample_fields) - + "\n" - ) - f.write("".join(lines)) - - return output_path From 03f8fb352012c889e16d93b031e34b73fd5a3626 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 5 Oct 2026 14:51:49 +0100 Subject: [PATCH 28/38] getting ready for PR, removing unused functions that were drafter previously and their related tests --- malariagen_data/anoph/to_vcf.py | 36 ++-- malariagen_data/anopheles.py | 2 - tests/anoph/test_coverage_exporter.py | 295 -------------------------- tests/anoph/test_igv_coverage.py | 143 ------------- tests/anoph/test_vcf_exporter.py | 218 +++++-------------- tests/anoph/test_vcf_exporter_cnv.py | 244 --------------------- tests/test_bgzf.py | 95 --------- 7 files changed, 65 insertions(+), 968 deletions(-) delete mode 100644 tests/anoph/test_coverage_exporter.py delete mode 100644 tests/anoph/test_igv_coverage.py delete mode 100644 tests/anoph/test_vcf_exporter_cnv.py delete mode 100644 tests/test_bgzf.py diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index d62d03612..5707c8859 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -5,8 +5,8 @@ from dataclasses import dataclass from typing import Optional import dask -from dask.array.core import Array -from xarray.core.dataset import Dataset +import dask.array as da +import xarray as xr import numpy as np from numpydoc_decorator import doc # type: ignore import pysam @@ -130,16 +130,12 @@ def snp_calls_to_vcf( sample_sets: base_params.sample_sets, sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, - sample_indices: Optional[base_params.sample_indices] = None, site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, fields: vcf_params.vcf_fields = ("GT",), ) -> str: - base_params._validate_sample_selection_params( - sample_query=sample_query, sample_indices=sample_indices - ) _validate_single_sample_selection( sample_sets=sample_sets, sample_query=sample_query ) @@ -173,7 +169,6 @@ def snp_calls_to_vcf( sample_sets=sample_sets, sample_query=sample_query, sample_query_options=sample_query_options, - sample_indices=sample_indices, site_mask=site_mask, inline_array=inline_array, chunks=chunks, @@ -259,12 +254,11 @@ def snp_calls_to_vcf( if s: alt_alleles.append(s) - genotype_data = variant_chunk_data.gt_chunk[j, 0] - genotype = ( - (None,) * len(genotype_data) - if np.any(genotype_data < 0) - else tuple(int(allele) for allele in genotype_data) - ) + genotype: tuple[Optional[int], ...] + if np.any(genotype_data < 0): + genotype = (None,) * len(genotype_data) + else: + genotype = tuple(int(allele) for allele in genotype_data) record = header.new_record( contig=str(chrom), @@ -305,18 +299,18 @@ def snp_calls_to_vcf( sample["MQ"] = None f.write(record) - pysam.tabix_index(output_path, preset="vcf", force=overwrite) + pysam.tabix_index(output_path, preset="vcf", force=True) return output_path def _get_chunks( self, ci: int, offsets: np.ndarray, - gt_data: Array, - pos_data: Array, - contig_data: Array, - allele_data: Array, - optional_arrays: dict[str, Array], + gt_data: da.Array, + pos_data: da.Array, + contig_data: da.Array, + allele_data: da.Array, + optional_arrays: dict[str, da.Array], ) -> VariantChunkData: start = offsets[ci] stop = offsets[ci + 1] @@ -365,8 +359,8 @@ def _get_chunks( return chunk_output def _get_optional_data( - self, include_gq: bool, include_ad: bool, include_mq: bool, ds: Dataset - ) -> dict[str, Array]: + self, include_gq: bool, include_ad: bool, include_mq: bool, ds: xr.Dataset + ) -> dict[str, da.Array]: # Optional field arrays — may not exist in all datasets. gq_data = None ad_data = None diff --git a/malariagen_data/anopheles.py b/malariagen_data/anopheles.py index b775dad1e..8342dbb88 100644 --- a/malariagen_data/anopheles.py +++ b/malariagen_data/anopheles.py @@ -37,7 +37,6 @@ from .anoph.to_plink import PlinkConverter from .anoph.ld import AnophelesLdAnalysis from .anoph.to_vcf import SnpVcfExporter -from .anoph.to_vcf_cnv import CnvVcfExporter from .anoph.g123 import AnophelesG123Analysis from .anoph.fst import AnophelesFstAnalysis from .anoph.h12 import AnophelesH12Analysis @@ -94,7 +93,6 @@ class AnophelesDataResource( PlinkConverter, AnophelesLdAnalysis, SnpVcfExporter, - CnvVcfExporter, AnophelesIgv, AnophelesKaryotypeAnalysis, AnophelesAimData, diff --git a/tests/anoph/test_coverage_exporter.py b/tests/anoph/test_coverage_exporter.py deleted file mode 100644 index d0770af3e..000000000 --- a/tests/anoph/test_coverage_exporter.py +++ /dev/null @@ -1,295 +0,0 @@ -import gzip -import os -import random - -import dask.array as da -import numpy as np -import pytest -import xarray as xr -from pytest_cases import parametrize_with_cases - -from malariagen_data import af1 as _af1 -from malariagen_data import ag3 as _ag3 - -from malariagen_data.anoph.to_coverage import CoverageExporter - - -@pytest.fixture -def ag3_sim_api(ag3_sim_fixture): - return CoverageExporter( - url=ag3_sim_fixture.url, - public_url=ag3_sim_fixture.url, - config_path=_ag3.CONFIG_PATH, - major_version_number=_ag3.MAJOR_VERSION_NUMBER, - major_version_path=_ag3.MAJOR_VERSION_PATH, - pre=True, - aim_metadata_dtype={ - "aim_species_fraction_arab": "float64", - "aim_species_fraction_colu": "float64", - "aim_species_fraction_colu_no2l": "float64", - "aim_species_gambcolu_arabiensis": object, - "aim_species_gambiae_coluzzii": object, - "aim_species": object, - }, - gff_gene_type="gene", - gff_gene_name_attribute="Name", - gff_default_attributes=("ID", "Parent", "Name", "description"), - results_cache=ag3_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="gamb_colu", - discordant_read_calls_analysis=ag3_sim_fixture.config[ - "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" - ], - ) - - -@pytest.fixture -def af1_sim_api(af1_sim_fixture): - return CoverageExporter( - url=af1_sim_fixture.url, - public_url=af1_sim_fixture.url, - config_path=_af1.CONFIG_PATH, - major_version_number=_af1.MAJOR_VERSION_NUMBER, - major_version_path=_af1.MAJOR_VERSION_PATH, - pre=False, - gff_gene_type="protein_coding_gene", - gff_gene_name_attribute="Note", - gff_default_attributes=("ID", "Parent", "Note", "description"), - results_cache=af1_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="funestus", - discordant_read_calls_analysis=None, - ) - - -def case_ag3_sim(ag3_sim_fixture, ag3_sim_api): - return ag3_sim_fixture, ag3_sim_api - - -def case_af1_sim(af1_sim_fixture, af1_sim_api): - return af1_sim_fixture, af1_sim_api - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph(fixture, api: CoverageExporter, tmp_path): - region = random.choice(api.contigs) - sample = str(np.random.choice(api.sample_metadata()["sample_id"])) - - output_path = str(tmp_path / "test_coverage.bedgraph") - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample=sample, - ) - - assert os.path.exists(output_path) - - with open(output_path) as f: - lines = f.readlines() - - assert lines[0].startswith("track type=bedGraph") - - data_lines = lines[1:] - assert len(data_lines) > 0 - - for line in data_lines: - fields = line.rstrip("\n").split("\t") - assert len(fields) == 4 - chrom, start, end, value = fields - assert chrom == region - assert int(start) >= 0 - assert int(end) > int(start) - # Should be a valid number and non-negative (masked/missing - # values are skipped rather than written). - assert float(value) >= 0 - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph_raw_cov(fixture, api: CoverageExporter, tmp_path): - region = api.contigs[0] - sample = str(api.sample_metadata()["sample_id"].iloc[0]) - - output_path = str(tmp_path / "test_coverage_raw.bedgraph") - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample=sample, - field="RawCov", - ) - assert os.path.exists(output_path) - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph_invalid_field( - fixture, api: CoverageExporter, tmp_path -): - region = api.contigs[0] - sample = str(api.sample_metadata()["sample_id"].iloc[0]) - - output_path = str(tmp_path / "test_coverage_bad.bedgraph") - with pytest.raises(ValueError, match="Unknown coverage field"): - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample=sample, - field="NotAField", - ) - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph_unknown_sample( - fixture, api: CoverageExporter, tmp_path -): - region = api.contigs[0] - output_path = str(tmp_path / "test_coverage_unknown.bedgraph") - with pytest.raises(ValueError, match="No data found for sample"): - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample="not_a_real_sample", - ) - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph_overwrite( - fixture, api: CoverageExporter, tmp_path -): - region = api.contigs[0] - sample = str(api.sample_metadata()["sample_id"].iloc[0]) - output_path = str(tmp_path / "test_coverage.bedgraph") - - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, region=region, sample=sample - ) - mtime_first = os.path.getmtime(output_path) - - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, region=region, sample=sample - ) - assert os.path.getmtime(output_path) == mtime_first - - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, region=region, sample=sample, overwrite=True - ) - assert os.path.exists(output_path) - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_coverage_to_bedgraph_gzip(fixture, api: CoverageExporter, tmp_path): - region = api.contigs[0] - sample = str(api.sample_metadata()["sample_id"].iloc[0]) - output_path = str(tmp_path / "test_coverage.bedgraph.gz") - - api.cnv_hmm_coverage_to_bedgraph( - output_path=output_path, region=region, sample=sample - ) - assert os.path.exists(output_path) - - with gzip.open(output_path, "rt") as f: - first_line = f.readline() - assert first_line.startswith("track type=bedGraph") - - -@parametrize_with_cases("fixture,api", cases=".") -def test_snp_calls_coverage_to_bedgraph(fixture, api: CoverageExporter, tmp_path): - region = random.choice(api.contigs) - sample = str(np.random.choice(api.sample_metadata()["sample_id"])) - - output_path = str(tmp_path / "test_snp_coverage.bedgraph") - api.snp_calls_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample=sample, - ) - - assert os.path.exists(output_path) - - with open(output_path) as f: - lines = f.readlines() - - assert lines[0].startswith("track type=bedGraph") - - # N.B., the simulated AD data is filled with a missing-value - # sentinel (-1) for every site, so no data lines are expected here; - # this exercises that missing values are skipped rather than - # written as misleading zero-depth entries. The arithmetic for - # sites that do have depth is checked separately below, using a - # synthetic dataset. - for line in lines[1:]: - fields = line.rstrip("\n").split("\t") - assert len(fields) == 4 - chrom, start, end, value = fields - assert chrom == region - assert int(end) == int(start) + 1 - assert int(value) >= 0 - - -@parametrize_with_cases("fixture,api", cases=".") -def test_snp_calls_coverage_to_bedgraph_depth_values( - fixture, api: CoverageExporter, tmp_path, monkeypatch -): - # Exercise the depth arithmetic directly against a small synthetic - # dataset, since the simulated fixture data fills call_AD with a - # missing-value sentinel throughout (see test above). - contig = api.contigs[0] - sample = str(api.sample_metadata()["sample_id"].iloc[0]) - - ds = xr.Dataset( - data_vars={ - "call_AD": ( - ["variants", "samples", "alleles"], - da.from_array( - np.array( - [ - [[10, 2, 0, 0]], # total depth 12 - [[-1, -1, -1, -1]], # missing, should be skipped - [[5, -1, 0, 0]], # negative components clipped to 0 - ], - dtype="i2", - ), - chunks=(2, 1, 4), - ), - ), - }, - coords={ - "variant_position": ( - "variants", - da.from_array(np.array([100, 200, 300]), chunks=2), - ), - "variant_contig": ( - "variants", - da.from_array(np.array([0, 0, 0], dtype="u1"), chunks=2), - ), - "sample_id": ("samples", np.array([sample])), - }, - attrs={"contigs": (contig,)}, - ) - monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) - - output_path = str(tmp_path / "test_snp_coverage_values.bedgraph") - api.snp_calls_coverage_to_bedgraph( - output_path=output_path, - region=contig, - sample=sample, - ) - - with open(output_path) as f: - lines = f.readlines() - - data_lines = [line.rstrip("\n").split("\t") for line in lines[1:]] - assert data_lines == [ - [contig, "99", "100", "12"], - [contig, "299", "300", "5"], - ] - - -@parametrize_with_cases("fixture,api", cases=".") -def test_snp_calls_coverage_to_bedgraph_unknown_sample( - fixture, api: CoverageExporter, tmp_path -): - region = api.contigs[0] - output_path = str(tmp_path / "test_snp_coverage_unknown.bedgraph") - with pytest.raises(ValueError, match="No data found for sample"): - api.snp_calls_coverage_to_bedgraph( - output_path=output_path, - region=region, - sample="not_a_real_sample", - ) diff --git a/tests/anoph/test_igv_coverage.py b/tests/anoph/test_igv_coverage.py deleted file mode 100644 index a39a0154c..000000000 --- a/tests/anoph/test_igv_coverage.py +++ /dev/null @@ -1,143 +0,0 @@ -import numpy as np -import pytest -from pytest_cases import parametrize_with_cases - -from malariagen_data import af1 as _af1 -from malariagen_data import ag3 as _ag3 -from malariagen_data.anoph.igv import AnophelesIgv -from malariagen_data.anoph.to_coverage import CoverageExporter - - -class _IgvWithCoverage(CoverageExporter, AnophelesIgv): - """Combines AnophelesIgv with CoverageExporter, the way the - top-level Ag3/Af1 data resource classes do, so that the local - coverage fallback functionality can be exercised in isolation.""" - - -@pytest.fixture -def ag3_sim_api(ag3_sim_fixture): - return AnophelesIgv( - url=ag3_sim_fixture.url, - public_url=ag3_sim_fixture.url, - config_path=_ag3.CONFIG_PATH, - major_version_number=_ag3.MAJOR_VERSION_NUMBER, - major_version_path=_ag3.MAJOR_VERSION_PATH, - pre=True, - aim_metadata_dtype={ - "aim_species_fraction_arab": "float64", - "aim_species_fraction_colu": "float64", - "aim_species_fraction_colu_no2l": "float64", - "aim_species_gambcolu_arabiensis": object, - "aim_species_gambiae_coluzzii": object, - "aim_species": object, - }, - gff_gene_type="gene", - gff_gene_name_attribute="Name", - gff_default_attributes=("ID", "Parent", "Name", "description"), - default_site_mask="gamb_colu_arab", - results_cache=ag3_sim_fixture.results_cache_path.as_posix(), - ) - - -@pytest.fixture -def ag3_sim_api_with_coverage(ag3_sim_fixture): - return _IgvWithCoverage( - url=ag3_sim_fixture.url, - public_url=ag3_sim_fixture.url, - config_path=_ag3.CONFIG_PATH, - major_version_number=_ag3.MAJOR_VERSION_NUMBER, - major_version_path=_ag3.MAJOR_VERSION_PATH, - pre=True, - aim_metadata_dtype={ - "aim_species_fraction_arab": "float64", - "aim_species_fraction_colu": "float64", - "aim_species_fraction_colu_no2l": "float64", - "aim_species_gambcolu_arabiensis": object, - "aim_species_gambiae_coluzzii": object, - "aim_species": object, - }, - gff_gene_type="gene", - gff_gene_name_attribute="Name", - gff_default_attributes=("ID", "Parent", "Name", "description"), - default_site_mask="gamb_colu_arab", - results_cache=ag3_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="gamb_colu", - discordant_read_calls_analysis=ag3_sim_fixture.config[ - "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" - ], - ) - - -@pytest.fixture -def af1_sim_api_with_coverage(af1_sim_fixture): - return _IgvWithCoverage( - url=af1_sim_fixture.url, - public_url=af1_sim_fixture.url, - config_path=_af1.CONFIG_PATH, - major_version_number=_af1.MAJOR_VERSION_NUMBER, - major_version_path=_af1.MAJOR_VERSION_PATH, - pre=False, - gff_gene_type="protein_coding_gene", - gff_gene_name_attribute="Note", - gff_default_attributes=("ID", "Parent", "Note", "description"), - default_site_mask="funestus", - results_cache=af1_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="funestus", - discordant_read_calls_analysis=None, - ) - - -def case_ag3_sim(ag3_sim_fixture, ag3_sim_api_with_coverage): - return ag3_sim_fixture, ag3_sim_api_with_coverage - - -def case_af1_sim(af1_sim_fixture, af1_sim_api_with_coverage): - return af1_sim_fixture, af1_sim_api_with_coverage - - -@parametrize_with_cases("fixture,api", cases=".") -def test_view_coverage(fixture, api: _IgvWithCoverage): - region = api.contigs[0] - sample = str(np.random.choice(api.sample_metadata()["sample_id"])) - ret = api.view_coverage(region=region, sample=sample, init=False) - # No return value to avoid cluttering notebook output. - assert ret is None - - -@parametrize_with_cases("fixture,api", cases=".") -def test_view_alignments_with_local_coverage_fallback(fixture, api: _IgvWithCoverage): - region = api.contigs[0] - sample = str(np.random.choice(api.sample_metadata()["sample_id"])) - ret = api.view_alignments( - region=region, - sample=sample, - init=False, - local_coverage_fallback=True, - ) - assert ret is None - - -@parametrize_with_cases("fixture,api", cases=".") -def test_view_coverage_writes_bedgraph(fixture, api: _IgvWithCoverage, tmp_path): - region = api.contigs[0] - sample = str(np.random.choice(api.sample_metadata()["sample_id"])) - output_path = str(tmp_path / "coverage.bedgraph") - api.view_coverage(region=region, sample=sample, init=False, output_path=output_path) - with open(output_path) as f: - first_line = f.readline() - assert first_line.startswith("track type=bedGraph") - - -def test_local_coverage_fallback_requires_cnv_mixin(ag3_sim_fixture, ag3_sim_api): - # Plain AnophelesIgv, without CoverageExporter mixed in, should - # raise a clear error rather than an AttributeError if asked for a - # local coverage track. - region = ag3_sim_api.contigs[0] - sample = str(np.random.choice(ag3_sim_api.sample_metadata()["sample_id"])) - with pytest.raises(NotImplementedError): - ag3_sim_api.view_alignments( - region=region, - sample=sample, - init=False, - local_coverage_fallback=True, - ) diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index a87669fe3..450a8ca97 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -97,9 +97,13 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): ) ds = api.snp_calls(**data_params) - n_variants = ds.sizes["variants"] sample_ids = ds["sample_id"].values + # Homozygous reference sites are not written. + gt = ds["call_genotype"].values[:, 0, :] + is_hom_ref = (gt == 0).all(axis=1) + expected_positions = sorted(ds["variant_position"].values[~is_hom_ref].tolist()) + # snp_calls_to_vcf() only supports exporting a single sample at a # time (its only current use case is generating a per-sample VCF # for IGV), so sample_query must narrow the dataset down to one @@ -127,13 +131,9 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): vcf_samples = col_fields[9:] assert list(vcf_samples) == list(sample_ids) - # Variant count matches. - assert len(data_lines) == n_variants - - # Positions match. + # Positions match the non-homozygous-reference sites. vcf_positions = sorted([int(line.split("\t")[1]) for line in data_lines]) - ds_positions = sorted(ds["variant_position"].values.tolist()) - assert vcf_positions == ds_positions + assert vcf_positions == expected_positions # Allele values are clean strings, not byte-string representations. for line in data_lines: @@ -145,122 +145,52 @@ def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): @parametrize_with_cases("fixture,api", cases=".") -def test_vcf_exporter_non_ref_only(fixture, api: SnpVcfExporter, tmp_path): - # non_ref_only=True should keep only sites where the sample's - # genotype carries at least one non-reference allele, dropping both - # homozygous reference (0/0) and missing (./.) calls. Equivalent in - # spirit to `bcftools view -e 'F_PASS(GT="ref") == 1'`, except that - # a missing call is also excluded here (that particular bcftools - # expression only excludes homozygous reference calls, since a - # missing call is neither "ref" nor caught by that `-e` filter). +def test_vcf_exporter_excludes_hom_ref(fixture, api: SnpVcfExporter, tmp_path): + # Homozygous reference (0/0) sites are not written. Missing calls + # are still written, as "./.". region = random.choice(api.contigs) all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) + site_mask = random.choice((None,) + api.site_mask_ids) _, sample_query = _pick_single_sample_query(api, sample_sets) data_params = dict( region=region, sample_sets=sample_sets, sample_query=sample_query, + site_mask=site_mask, ) - # Work out the expected set of non-ref, non-missing positions - # directly from the dataset, independently of snp_calls_to_vcf. + # Work out the expected positions directly from the dataset, + # independently of snp_calls_to_vcf. ds = api.snp_calls(**data_params) gt = ds["call_genotype"].values[:, 0, :] # (variants, ploidy) is_missing = (gt < 0).any(axis=1) is_hom_ref = (gt == 0).all(axis=1) - expect_keep = ~is_missing & ~is_hom_ref - expected_positions = sorted(ds["variant_position"].values[expect_keep].tolist()) + positions = ds["variant_position"].values + expected_positions = sorted(positions[~is_hom_ref].tolist()) + expected_missing_positions = sorted(positions[is_missing].tolist()) - output_path = str(tmp_path / "test_non_ref_only.vcf.gz") - api.snp_calls_to_vcf( - output_path=output_path, - non_ref_only=True, - **data_params, - ) + output_path = str(tmp_path / "test_excludes_hom_ref.vcf.gz") + api.snp_calls_to_vcf(output_path=output_path, **data_params) with gzip.open(output_path, "rt") as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] - # Every written site should have a non-ref, non-missing GT. + vcf_positions = [] + vcf_missing_positions = [] for line in data_lines: fields_row = line.strip().split("\t") + pos = int(fields_row[1]) gt_str = fields_row[9].split(":")[0] - assert gt_str != "./." - a0, a1 = gt_str.split("/") - assert not (a0 == "0" and a1 == "0") - - # And the set of positions written should exactly match what we - # expect directly from the dataset (no extras, none missing). - vcf_positions = sorted(int(line.split("\t")[1]) for line in data_lines) - assert vcf_positions == expected_positions - - -@parametrize_with_cases("fixture,api", cases=".") -def test_vcf_exporter_non_ref_only_defaults_to_false( - fixture, api: SnpVcfExporter, tmp_path -): - # Not passing non_ref_only should behave identically to passing - # non_ref_only=False (i.e. include homozygous reference / missing - # sites too) — this locks in the default. - region = api.contigs[0] - all_sample_sets = api.sample_sets()["sample_set"].to_list() - sample_sets = [all_sample_sets[0]] - _, sample_query = _pick_single_sample_query(api, sample_sets) - - output_path_default = str(tmp_path / "default.vcf.gz") - output_path_explicit = str(tmp_path / "explicit_false.vcf.gz") - api.snp_calls_to_vcf( - output_path=output_path_default, - region=region, - sample_sets=sample_sets, - sample_query=sample_query, - ) - api.snp_calls_to_vcf( - output_path=output_path_explicit, - region=region, - sample_sets=sample_sets, - sample_query=sample_query, - non_ref_only=False, - ) + assert gt_str != "0/0", f"hom-ref call written at {pos}" + vcf_positions.append(pos) + if gt_str == "./.": + vcf_missing_positions.append(pos) - with gzip.open(output_path_default, "rt") as f: - default_lines = f.readlines() - with gzip.open(output_path_explicit, "rt") as f: - explicit_lines = f.readlines() - assert default_lines == explicit_lines - - -@pytest.mark.skipif(shutil.which("bcftools") is None, reason="bcftools not installed") -@parametrize_with_cases("fixture,api", cases=".") -def test_vcf_exporter_non_ref_only_valid_per_bcftools( - fixture, api: SnpVcfExporter, tmp_path -): - region = api.contigs[0] - all_sample_sets = api.sample_sets()["sample_set"].to_list() - sample_sets = [all_sample_sets[0]] - _, sample_query = _pick_single_sample_query(api, sample_sets) - - output_path = str(tmp_path / "test_non_ref_only_bcftools.vcf.gz") - api.snp_calls_to_vcf( - output_path=output_path, - region=region, - sample_sets=sample_sets, - sample_query=sample_query, - fields={"GT", "GQ", "AD", "MQ"}, - non_ref_only=True, - ) - - result = subprocess.run( - ["bcftools", "view", "-v", "snps", output_path], - capture_output=True, - text=True, - ) - assert result.returncode == 0, f"bcftools failed to parse output: {result.stderr}" - assert "Error" not in result.stderr - assert "should be declared as" not in result.stderr, result.stderr + assert sorted(vcf_positions) == expected_positions + assert sorted(vcf_missing_positions) == expected_missing_positions @parametrize_with_cases("fixture,api", cases=".") @@ -584,75 +514,36 @@ def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path) @parametrize_with_cases("fixture,api", cases=".") -def test_vcf_exporter_allele_index_remapping( +def test_vcf_exporter_synthetic_genotypes( fixture, api: SnpVcfExporter, tmp_path, monkeypatch ): - # ALT should only ever list alleles that are both (a) genuinely - # populated in variant_allele and (b) actually referenced by this - # sample's own genotype. variant_allele lists a fixed, canonical - # set of alternate bases per site (e.g. for REF=A it can list - # "C,T,G" regardless of what's actually segregating, let alone - # relevant to one particular sample), and call_genotype's allele - # indices refer to those *original* slot positions, which are not - # guaranteed to be contiguous from 1 either (a site's only real ALT - # allele can sit in slot 2 or 3 while an earlier slot is empty). - # Writing every populated-but-irrelevant slot to ALT (a) produces - # invalid records when combined with un-remapped genotype indices - # (e.g. "0/2" against a single-allele ALT column, which bcftools - # then silently mishandled), and (b) even once indices are - # correctly remapped, produces a non-standard single-sample VCF - # (real single-sample VCFs only list alleles that sample's - # genotype actually uses) that fails REF/ALT-based comparison - # against any VCF following that convention — two VCFs recording - # the "same" call at the same position end up with different ALT - # strings purely because of unrelated candidate alleles. + # Deterministic check on a small synthetic dataset: ALT lists every + # alternate allele in variant_allele, GT allele indices are written + # as-is, homozygous reference sites are dropped and missing calls + # are written as "./.". sample = str(api.sample_metadata()["sample_id"].iloc[0]) contig = api.contigs[0] variant_allele = np.array( - [ - [b"A", b"", b"T", b""], # only real ALT in slot 2 - [b"A", b"T", b"", b""], # real ALT in slot 1 (baseline case) - [b"A", b"", b"", b"T"], # only real ALT in slot 3 - [b"A", b"C", b"", b"T"], # two real ALTs, only one used - [b"A", b"C", b"T", b"G"], # all 3 canonical ALTs populated, - # only one used (the real-world - # pattern: REF=A ALT="C,T,G" - # regardless of relevance) - [b"A", b"C", b"T", b"G"], # all 3 populated, compound het - # using two of them - [b"A", b"C", b"T", b"G"], # all 3 populated, hom-ref - [b"A", b"C", b"T", b"G"], # all 3 populated, missing - ], + [[b"A", b"C", b"T", b"G"]] * 5, dtype="S1", ) call_genotype = np.array( [ - [[0, 2]], # het for the slot-2 "T" -> ALT="T" -> expect 0/1 - [[0, 1]], # het for the slot-1 "T" -> ALT="T" -> expect 0/1 - [[3, 3]], # hom-alt for the slot-3 "T" -> ALT="T" -> expect 1/1 - [[0, 3]], # het for slot-3 "T"; slot-1 "C" unused -> expect ALT="T", GT=0/1 - [ - [0, 2] - ], # het for slot-2 "T"; "C" and "G" unused -> expect ALT="T", GT=0/1 - [ - [1, 3] - ], # het for slot-1 "C" and slot-3 "G"; "T" unused -> expect ALT="C,G", GT=1/2 - [[0, 0]], # hom-ref -> expect ALT=".", GT=0/0 - [[-1, -1]], # missing -> expect ALT=".", GT=./. + [[0, 1]], # het + [[0, 0]], # hom-ref -> not written + [[-1, -1]], # missing + [[1, 3]], # het for two alternate alleles + [[2, 2]], # hom-alt ], dtype="i1", ) - positions = [100, 200, 300, 400, 500, 600, 700, 800] + positions = [100, 200, 300, 400, 500] expected = { - 100: ("T", "0/1"), - 200: ("T", "0/1"), - 300: ("T", "1/1"), - 400: ("T", "0/1"), - 500: ("T", "0/1"), - 600: ("C,G", "1/2"), - 700: (".", "0/0"), - 800: (".", "./."), + 100: "0/1", + 300: "./.", + 400: "1/3", + 500: "2/2", } n_variants = len(positions) @@ -682,7 +573,7 @@ def test_vcf_exporter_allele_index_remapping( ) monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) - output_path = str(tmp_path / "test_allele_remap.vcf.gz") + output_path = str(tmp_path / "test_synthetic.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=contig, @@ -693,21 +584,12 @@ def test_vcf_exporter_allele_index_remapping( with gzip.open(output_path, "rt") as f: lines = f.readlines() data_lines = [line for line in lines if not line.startswith("#")] - assert len(data_lines) == n_variants + written = {} for line in data_lines: fields_row = line.strip().split("\t") pos = int(fields_row[1]) - alt = fields_row[4] - gt = fields_row[9].split(":")[0] - expected_alt, expected_gt = expected[pos] - assert alt == expected_alt, f"at {pos}: expected ALT {expected_alt}, got {alt}" - assert gt == expected_gt, f"at {pos}: expected GT {expected_gt}, got {gt}" - # Every GT allele index must be valid for the ALT column that - # was actually written (i.e. in range for the number of ALT - # alleles listed), which is the invariant this fix guarantees. - if gt == "./.": - continue - n_alt_alleles = 0 if alt == "." else len(alt.split(",")) - for allele_idx in gt.split("/"): - assert int(allele_idx) <= n_alt_alleles + assert fields_row[3] == "A" + assert fields_row[4] == "C,T,G" + written[pos] = fields_row[9].split(":")[0] + assert written == expected diff --git a/tests/anoph/test_vcf_exporter_cnv.py b/tests/anoph/test_vcf_exporter_cnv.py deleted file mode 100644 index 8081cef1c..000000000 --- a/tests/anoph/test_vcf_exporter_cnv.py +++ /dev/null @@ -1,244 +0,0 @@ -import gzip -import os -import random -import shutil -import subprocess - -import pytest -from pytest_cases import parametrize_with_cases - -from malariagen_data import af1 as _af1 -from malariagen_data import ag3 as _ag3 - -from malariagen_data.anoph.to_vcf_cnv import CnvVcfExporter - - -@pytest.fixture -def ag3_sim_api(ag3_sim_fixture): - return CnvVcfExporter( - url=ag3_sim_fixture.url, - public_url=ag3_sim_fixture.url, - config_path=_ag3.CONFIG_PATH, - major_version_number=_ag3.MAJOR_VERSION_NUMBER, - major_version_path=_ag3.MAJOR_VERSION_PATH, - pre=True, - aim_metadata_dtype={ - "aim_species_fraction_arab": "float64", - "aim_species_fraction_colu": "float64", - "aim_species_fraction_colu_no2l": "float64", - "aim_species_gambcolu_arabiensis": object, - "aim_species_gambiae_coluzzii": object, - "aim_species": object, - }, - gff_gene_type="gene", - gff_gene_name_attribute="Name", - gff_default_attributes=("ID", "Parent", "Name", "description"), - results_cache=ag3_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="gamb_colu", - discordant_read_calls_analysis=ag3_sim_fixture.config[ - "DEFAULT_DISCORDANT_READ_CALLS_ANALYSIS" - ], - ) - - -@pytest.fixture -def af1_sim_api(af1_sim_fixture): - return CnvVcfExporter( - url=af1_sim_fixture.url, - public_url=af1_sim_fixture.url, - config_path=_af1.CONFIG_PATH, - major_version_number=_af1.MAJOR_VERSION_NUMBER, - major_version_path=_af1.MAJOR_VERSION_PATH, - pre=False, - gff_gene_type="protein_coding_gene", - gff_gene_name_attribute="Note", - gff_default_attributes=("ID", "Parent", "Note", "description"), - results_cache=af1_sim_fixture.results_cache_path.as_posix(), - default_coverage_calls_analysis="funestus", - discordant_read_calls_analysis=None, - ) - - -def case_ag3_sim(ag3_sim_fixture, ag3_sim_api): - return ag3_sim_fixture, ag3_sim_api - - -def case_af1_sim(af1_sim_fixture, af1_sim_api): - return af1_sim_fixture, af1_sim_api - - -def _check_basic_vcf_structure(output_path, expected_n_variants, expected_sample_ids): - assert os.path.exists(output_path) - - opener = gzip.open if output_path.endswith(".gz") else open - with opener(output_path, "rt") as f: - lines = f.readlines() - - header_lines = [line for line in lines if line.startswith("##")] - column_line = [line for line in lines if line.startswith("#CHROM")] - data_lines = [line for line in lines if not line.startswith("#")] - - assert header_lines[0].strip() == "##fileformat=VCFv4.3" - assert len(column_line) == 1 - - col_fields = column_line[0].strip().split("\t") - vcf_samples = col_fields[9:] - assert list(vcf_samples) == list(expected_sample_ids) - - assert len(data_lines) == expected_n_variants - - for line in data_lines: - fields = line.rstrip("\n").split("\t") - assert len(fields) == 9 + len(expected_sample_ids) - ref, alt = fields[3], fields[4] - assert ref == "N" - assert alt == "" - - return data_lines - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_to_vcf(fixture, api: CnvVcfExporter, tmp_path): - region = random.choice(api.contigs) - all_sample_sets = api.sample_sets()["sample_set"].to_list() - sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) - - ds = api.cnv_hmm(region=region, sample_sets=sample_sets, max_coverage_variance=None) - n_variants = ds.sizes["variants"] - sample_ids = ds["sample_id"].values - - output_path = str(tmp_path / "test_cnv_hmm.vcf") - api.cnv_hmm_to_vcf( - output_path=output_path, - region=region, - sample_sets=sample_sets, - max_coverage_variance=None, - ) - - data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) - - # Check positions match. - vcf_positions = sorted([int(line.split("\t")[1]) for line in data_lines]) - ds_positions = sorted(ds["variant_position"].values.tolist()) - assert vcf_positions == ds_positions - - # Check FORMAT is CN. - for line in data_lines: - fields = line.rstrip("\n").split("\t") - assert fields[8] == "CN" - assert fields[7].startswith("END=") - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_coverage_calls_to_vcf(fixture, api: CnvVcfExporter, tmp_path): - all_sample_sets = api.sample_sets()["sample_set"].to_list() - sample_set = random.choice(all_sample_sets) - analysis = random.choice(api.coverage_calls_analysis_ids) - region = random.choice(api.contigs) - - ds = api.cnv_coverage_calls(region=region, sample_set=sample_set, analysis=analysis) - n_variants = ds.sizes["variants"] - sample_ids = ds["sample_id"].values - - output_path = str(tmp_path / "test_cnv_coverage_calls.vcf") - api.cnv_coverage_calls_to_vcf( - output_path=output_path, - region=region, - sample_set=sample_set, - analysis=analysis, - ) - - data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) - - ds_ids = [ - v.decode() if hasattr(v, "decode") else str(v) for v in ds["variant_id"].values - ] - vcf_ids = [line.split("\t")[2] for line in data_lines] - assert sorted(vcf_ids) == sorted(ds_ids) - - for line in data_lines: - fields = line.rstrip("\n").split("\t") - assert fields[8] == "GT" - assert fields[6] in ("PASS", ".") - assert "CIPOS=" in fields[7] - assert "CIEND=" in fields[7] - for sample_val in fields[9:]: - assert sample_val in ("0", "1", ".") - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_discordant_read_calls_to_vcf(fixture, api: CnvVcfExporter, tmp_path): - contig = random.choice(api.contigs) - all_sample_sets = api.sample_sets()["sample_set"].to_list() - sample_sets = random.sample(all_sample_sets, min(2, len(all_sample_sets))) - - ds = api.cnv_discordant_read_calls(contigs=contig, sample_sets=sample_sets) - n_variants = ds.sizes["variants"] - sample_ids = ds["sample_id"].values - - output_path = str(tmp_path / "test_cnv_discordant.vcf") - api.cnv_discordant_read_calls_to_vcf( - output_path=output_path, - contigs=contig, - sample_sets=sample_sets, - ) - - data_lines = _check_basic_vcf_structure(output_path, n_variants, sample_ids) - - for line in data_lines: - fields = line.rstrip("\n").split("\t") - assert fields[8] == "GT" - assert "REGION=" in fields[7] - assert "SBM=" in fields[7] - assert "EBM=" in fields[7] - for sample_val in fields[9:]: - assert sample_val in ("0", "1", ".") - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_to_vcf_overwrite(fixture, api: CnvVcfExporter, tmp_path): - region = api.contigs[0] - output_path = str(tmp_path / "test_cnv_hmm.vcf") - - api.cnv_hmm_to_vcf( - output_path=output_path, region=region, max_coverage_variance=None - ) - mtime_first = os.path.getmtime(output_path) - - # Without overwrite, should return early. - api.cnv_hmm_to_vcf( - output_path=output_path, region=region, max_coverage_variance=None - ) - assert os.path.getmtime(output_path) == mtime_first - - # With overwrite, file should be rewritten. - api.cnv_hmm_to_vcf( - output_path=output_path, - region=region, - max_coverage_variance=None, - overwrite=True, - ) - assert os.path.exists(output_path) - - -@parametrize_with_cases("fixture,api", cases=".") -def test_cnv_hmm_to_vcf_gzip(fixture, api: CnvVcfExporter, tmp_path): - region = api.contigs[0] - output_path = str(tmp_path / "test_cnv_hmm.vcf.gz") - - api.cnv_hmm_to_vcf( - output_path=output_path, region=region, max_coverage_variance=None - ) - assert os.path.exists(output_path) - - with gzip.open(output_path, "rt") as f: - first_line = f.readline() - assert first_line.strip() == "##fileformat=VCFv4.3" - - # Verify it's specifically valid BGZF, not just plain gzip — what - # tools like tabix/bedtools require for .vcf.gz files. - if shutil.which("bgzip") is not None: - result = subprocess.run( - ["bgzip", "-t", output_path], capture_output=True, text=True - ) - assert result.returncode == 0, f"not valid BGZF: {result.stderr}" diff --git a/tests/test_bgzf.py b/tests/test_bgzf.py deleted file mode 100644 index 38e8e5d61..000000000 --- a/tests/test_bgzf.py +++ /dev/null @@ -1,95 +0,0 @@ -import gzip -import shutil -import subprocess - -import pytest - -from malariagen_data.bgzf import _MAX_BLOCK_UNCOMPRESSED_SIZE, bgzf_open - - -def test_bgzf_round_trip(tmp_path): - output_path = str(tmp_path / "test.txt.gz") - lines = [f"line {i}\n" for i in range(100)] - - with bgzf_open(output_path, "wt") as f: - for line in lines: - f.write(line) - - # BGZF is valid gzip, so a plain gzip reader must be able to read - # the exact content back. - with gzip.open(output_path, "rt") as f: - content = f.read() - assert content == "".join(lines) - - -def test_bgzf_multi_block_round_trip(tmp_path): - # Write enough data to force multiple BGZF blocks, and include - # content that lands exactly on, just under, and just over a block - # boundary, to exercise the block-splitting logic. - output_path = str(tmp_path / "test_multiblock.txt.gz") - line = "the quick brown fox jumps over the lazy dog 0123456789\n" - n_lines = (_MAX_BLOCK_UNCOMPRESSED_SIZE // len(line)) * 3 + 7 - expected = "".join(f"{i}:{line}" for i in range(n_lines)) - - with bgzf_open(output_path, "wt") as f: - for i in range(n_lines): - f.write(f"{i}:{line}") - - with gzip.open(output_path, "rt") as f: - content = f.read() - assert content == expected - - -def test_bgzf_empty_file(tmp_path): - # Writing nothing should still produce a valid (if empty) BGZF - # file, i.e. just the EOF marker. - output_path = str(tmp_path / "test_empty.txt.gz") - with bgzf_open(output_path, "wt"): - pass - - with gzip.open(output_path, "rt") as f: - content = f.read() - assert content == "" - - -def test_bgzf_rejects_binary_mode(tmp_path): - output_path = str(tmp_path / "test.txt.gz") - with pytest.raises(ValueError): - bgzf_open(output_path, "wb") - - -@pytest.mark.skipif(shutil.which("bgzip") is None, reason="bgzip not installed") -def test_bgzf_valid_per_bgzip(tmp_path): - # The definitive check: the reference BGZF implementation itself - # must accept this as valid BGZF, not just "some gzip stream that - # happens to decompress correctly." - output_path = str(tmp_path / "test.txt.gz") - with bgzf_open(output_path, "wt") as f: - for i in range(10_000): - f.write(f"line {i}\n") - - result = subprocess.run( - ["bgzip", "-t", output_path], capture_output=True, text=True - ) - assert result.returncode == 0, f"not valid BGZF: {result.stderr}" - - -@pytest.mark.skipif(shutil.which("tabix") is None, reason="tabix not installed") -def test_bgzf_tabix_indexable(tmp_path): - # tabix specifically requires genuine BGZF block structure to - # build an index at all; plain gzip fails here even though it - # decompresses fine. This is the property that made bedtools (and - # other BGZF-aware tools) unable to read plain-gzip VCF output - # correctly, even though bcftools tolerated it. - output_path = str(tmp_path / "test.vcf.gz") - with bgzf_open(output_path, "wt") as f: - f.write("##fileformat=VCFv4.3\n") - f.write("##contig=\n") - f.write("#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n") - for pos in (100, 200, 300): - f.write(f"2R\t{pos}\t.\tA\tT\t.\t.\t.\n") - - result = subprocess.run( - ["tabix", "-p", "vcf", output_path], capture_output=True, text=True - ) - assert result.returncode == 0, f"tabix failed to index: {result.stderr}" From f96236f96cdad9a0bf6f2107e745e2d44e7b096f Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Mon, 5 Oct 2026 16:16:22 +0100 Subject: [PATCH 29/38] make site_masks=None default, updated doctring --- malariagen_data/anoph/to_vcf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 5707c8859..50f0e8806 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -102,7 +102,7 @@ def __init__( @doc( summary=""" - Export SNP calls to Variant Call Format (VCF). + Extract SNP calls for sample and export to Variant Call Format (VCF). """, extended_summary=""" This function writes SNP calls to a VCF file. Data is written @@ -117,7 +117,9 @@ def __init__( required to select exactly one sample, and must be of the form `"sample_id == ''"`. Any other query (e.g. selecting samples by cohort, or more than one sample_id) is - rejected. + rejected. An accompanying tabix-format index file is created + in the same location as the VCF output file, with the same name but a + `.tbi` suffix. """, returns=""" Path to the VCF output file. @@ -130,7 +132,7 @@ def snp_calls_to_vcf( sample_sets: base_params.sample_sets, sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, - site_mask: Optional[base_params.site_mask] = base_params.DEFAULT, + site_mask: Optional[base_params.site_mask] = None, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, From b018131dc694ce517118dd9889e5a86ec2b4ffb0 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 6 Oct 2026 11:12:47 +0100 Subject: [PATCH 30/38] remove pysam as with it, either Windows install of malariagen_data won't work at all, or IGV-related funcitonality will not be available to Windows users --- malariagen_data/anoph/igv.py | 39 ++++++----- malariagen_data/anoph/to_vcf.py | 117 ++++++++++++++++++------------- notebooks/igv.ipynb | 4 +- poetry.lock | 58 --------------- pyproject.toml | 1 - tests/anoph/test_igv.py | 6 +- tests/anoph/test_vcf_exporter.py | 19 +++-- 7 files changed, 112 insertions(+), 132 deletions(-) diff --git a/malariagen_data/anoph/igv.py b/malariagen_data/anoph/igv.py index cccf7f877..5958106d4 100644 --- a/malariagen_data/anoph/igv.py +++ b/malariagen_data/anoph/igv.py @@ -100,9 +100,6 @@ def _igv_view_alignments_tracks( # Locate record for sample. cat_rec = df_cat.set_index("sample_id").loc[sample] bam_url = cat_rec["alignments_bam"] - vcf_url = ( - snp_vcf_url if snp_vcf_url is not None else cat_rec["snp_genotypes_vcf"] - ) # Set up site filters tracks. contig = region.contig @@ -112,17 +109,23 @@ def _igv_view_alignments_tracks( ) # Add SNPs track. - tracks.append( - { - "name": "SNPs", - "url": vcf_url, - "indexURL": f"{vcf_url}.tbi", - "format": "vcf", - "type": "variant", - "visibilityWindow": visibility_window, # bp - "height": 50, - } - ) + snp_track = { + "name": "SNPs", + "format": "vcf", + "type": "variant", + "visibilityWindow": visibility_window, # bp + "height": 50, + } + if snp_vcf_url is not None: + # A local VCF, e.g. from snp_calls_to_vcf(), has no index, so + # IGV loads it in full. + snp_track["url"] = snp_vcf_url + snp_track["indexed"] = False + else: + vcf_url = cat_rec["snp_genotypes_vcf"] + snp_track["url"] = vcf_url + snp_track["indexURL"] = f"{vcf_url}.tbi" + tracks.append(snp_track) # Add alignments track. tracks.append( @@ -187,9 +190,11 @@ def igv( """, init="If True, call igv_notebook.init().", snp_vcf_url=""" - Optional URL for a local, tabix-indexed VCF. For Jupyter Notebook - and Lab, the VCF and its `.tbi` index must be under the Jupyter - startup directory tree; pass a URL relative to that tree (e.g. + Optional URL for a local VCF, e.g. one written by + `snp_calls_to_vcf()`. The VCF is loaded without an index, so it + should be small (e.g. a single sample over a region). For Jupyter + Notebook and Lab, the VCF must be under the Jupyter startup + directory tree; pass a URL relative to that tree (e.g. `/data/sample.vcf.gz`). If omitted, use the catalog VCF. """, ), diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 50f0e8806..0f18e6b23 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -9,7 +9,7 @@ import xarray as xr import numpy as np from numpydoc_decorator import doc # type: ignore -import pysam +from Bio import bgzf # type: ignore from .snp_data import AnophelesSnpData from . import base_params @@ -45,6 +45,17 @@ class VariantChunkData: # under the reserved key's declared type. "MQ": '##FORMAT=', } +_HEADER_COLUMNS = ( + "#CHROM", + "POS", + "ID", + "REF", + "ALT", + "QUAL", + "FILTER", + "INFO", + "FORMAT", +) # snp_calls_to_vcf() only supports exporting a single sample at a time # (its current use case is generating a per-sample VCF for IGV), so @@ -54,6 +65,11 @@ class VariantChunkData: ) +def _format_int(value) -> str: + # Negative values are missing data. + return "." if value < 0 else str(int(value)) + + def _validate_single_sample_selection( *, sample_sets: base_params.sample_sets, @@ -107,8 +123,9 @@ def __init__( extended_summary=""" This function writes SNP calls to a VCF file. Data is written in chunks to avoid loading the entire genotype matrix into - memory. Output is BGZF-compressed and tabix-indexed; the - `output_path` must end with `.vcf.gz`. + memory. Output is BGZF-compressed; the `output_path` must end + with `.vcf.gz`. No index is created, so the output is intended + to be small enough to load in full (e.g. by IGV). `sample_sets` and `sample_query` are both required: a VCF is only meaningful with respect to an explicit sample basis for @@ -117,9 +134,7 @@ def __init__( required to select exactly one sample, and must be of the form `"sample_id == ''"`. Any other query (e.g. selecting samples by cohort, or more than one sample_id) is - rejected. An accompanying tabix-format index file is created - in the same location as the VCF output file, with the same name but a - `.tbi` suffix. + rejected. """, returns=""" Path to the VCF output file. @@ -143,8 +158,7 @@ def snp_calls_to_vcf( ) if not output_path.endswith(".vcf.gz"): raise ValueError( - "output_path must end with .vcf.gz: " - "BGZF compression and tabix indexing require this suffix." + "output_path must end with .vcf.gz: output is BGZF-compressed." ) # Validate fields parameter. @@ -162,8 +176,6 @@ def snp_calls_to_vcf( fields = tuple(f for f in _FIELD_ORDER if f in fields) if os.path.exists(output_path) and not overwrite: - if not os.path.exists(output_path + ".tbi"): - pysam.tabix_index(output_path, preset="vcf") return output_path ds = self.snp_calls( @@ -198,20 +210,23 @@ def snp_calls_to_vcf( include_gq = "GQ" in fields include_ad = "AD" in fields include_mq = "MQ" in fields - header = pysam.VariantHeader() - for header_record in list(header.records): - if header_record.key in {"fileformat", "FILTER"}: - header_record.remove() - header.add_meta("fileformat", value="VCFv4.3") - header.add_meta("fileDate", value=date.today().strftime("%Y%m%d")) - header.add_meta("source", value="malariagen_data") - for contig in contigs: - header.contigs.add(str(contig)) - for field in fields: - header.add_line(_FORMAT_HEADERS[field]) - header.add_sample(sample_id) - - with pysam.VariantFile(output_path, mode="w", header=header) as f: + format_str = ":".join(fields) + + header_lines = [ + "##fileformat=VCFv4.3", + '##FILTER=', + f"##fileDate={date.today().strftime('%Y%m%d')}", + "##source=malariagen_data", + ] + header_lines += [f"##contig=" for contig in contigs] + header_lines += [_FORMAT_HEADERS[field] for field in fields] + header_lines.append("\t".join(_HEADER_COLUMNS + (sample_id,))) + + # BGZF is valid gzip, and is the block-compressed variant that + # genomics tools (e.g. IGV, bcftools) expect for .vcf.gz files. + with bgzf.BgzfWriter(output_path, "wb") as f: + f.write(("\n".join(header_lines) + "\n").encode()) + # Extract dask arrays. gt_data = ds["call_genotype"].data pos_data = ds["variant_position"].data @@ -238,6 +253,7 @@ def snp_calls_to_vcf( optional_arrays, ) + lines = [] for j in range(variant_chunk_data.gt_chunk.shape[0]): genotype_data = variant_chunk_data.gt_chunk[j, 0] if np.array_equal(genotype_data, (0, 0)): @@ -256,52 +272,57 @@ def snp_calls_to_vcf( if s: alt_alleles.append(s) - genotype: tuple[Optional[int], ...] if np.any(genotype_data < 0): - genotype = (None,) * len(genotype_data) + gt = "/".join("." for _ in genotype_data) else: - genotype = tuple(int(allele) for allele in genotype_data) - - record = header.new_record( - contig=str(chrom), - start=pos - 1, - alleles=(ref, *alt_alleles), - ) - sample = record.samples[sample_id] - sample["GT"] = genotype + gt = "/".join(str(int(allele)) for allele in genotype_data) + sample_values = [gt] # GQ. if include_gq: if variant_chunk_data.gq_chunk is not None: - value = variant_chunk_data.gq_chunk[j, 0] - sample["GQ"] = None if value < 0 else int(value) + sample_values.append( + _format_int(variant_chunk_data.gq_chunk[j, 0]) + ) else: - sample["GQ"] = None + sample_values.append(".") # AD. if include_ad: if variant_chunk_data.ad_chunk is not None: ad_values = variant_chunk_data.ad_chunk[j, 0] - sample["AD"] = tuple( - None if value < 0 else int(value) - for value in ad_values + sample_values.append( + ",".join(_format_int(value) for value in ad_values) ) else: - sample["AD"] = None + sample_values.append(".") # MQ. Rounded to the nearest integer: the # underlying data is a float, but the VCF spec # fixes the reserved FORMAT/MQ key as Integer. if include_mq: if variant_chunk_data.mq_chunk is not None: value = variant_chunk_data.mq_chunk[j, 0] - sample["MQ"] = ( - None + sample_values.append( + "." if math.isnan(value) or value < 0 - else round(value) + else str(round(float(value))) ) else: - sample["MQ"] = None - f.write(record) + sample_values.append(".") + + record = ( + str(chrom), + str(pos), + ".", + ref, + ",".join(alt_alleles) or ".", + ".", + ".", + ".", + format_str, + ":".join(sample_values), + ) + lines.append("\t".join(record) + "\n") + f.write("".join(lines).encode()) - pysam.tabix_index(output_path, preset="vcf", force=True) return output_path def _get_chunks( diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index b7fc56328..d584f04ae 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -205,8 +205,8 @@ "id": "17", "metadata": {}, "source": [ - "## Local tabix-indexed VCF in IGV\n", - "This exports one sample to a BGZF VCF and `.tbi` under the notebook working directory, then loads it as the SNP track. Both files must be inside the Jupyter server startup directory tree. The `snp_vcf_url` below assumes the server was started from the workspace root; if it was started from `notebooks/`, use the alternate URL shown in the code cell." + "## Local VCF in IGV\n", + "This exports one sample over a region to a BGZF-compressed VCF under the notebook working directory, then loads it as the SNP track. No index is created, so IGV loads the whole file; keep the region small. The file must be inside the Jupyter server startup directory tree. The `snp_vcf_url` below assumes the server was started from the workspace root; if it was started from `notebooks/`, use the alternate URL shown in the code cell." ] }, { diff --git a/poetry.lock b/poetry.lock index a91246179..a1b7f41ac 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4631,59 +4631,6 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] -[[package]] -name = "pysam" -version = "0.24.1" -description = "Package for reading, manipulating, and writing genomic data" -optional = false -python-versions = ">=3.9" -groups = ["main"] -files = [ - {file = "pysam-0.24.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3829b13896a624c47b17599e47bff28cbc87211c7777852ac1f11aa0697cc530"}, - {file = "pysam-0.24.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f842fc7638b8acccd5e470820cff3f490c5845e616fa668667531da22b686a7b"}, - {file = "pysam-0.24.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f3abec4f08929c5090f747975787febe7db437bad34349f29c8e0328d6f9ad06"}, - {file = "pysam-0.24.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e601c4626e7310db74823a4152483bf903392ff1d30eec619594808280da699"}, - {file = "pysam-0.24.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:84c80a7d3475e675d142a850ff3ea0d4a929e698130f01323f1a550a0e13cc27"}, - {file = "pysam-0.24.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:10cc2b840ef651be8c7087d7c0c9c51e220162eae1e5ad68b6ccf427594357fc"}, - {file = "pysam-0.24.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f1bdd44bcd85d8562925436bec24dcf7325e4001575a9c24d58806b93de2293"}, - {file = "pysam-0.24.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0e48e4b3d341734078e97fe05a2358d60837ca88741625ec17d45ba7c629dc64"}, - {file = "pysam-0.24.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c21dd9b801175d14c4d7b78898de921f8771edf141db5957226c9bf1ed4bf293"}, - {file = "pysam-0.24.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:050d4c72211a961d26fad70b655694d4d500422e4b7d0ed3c7f244c49df8d16e"}, - {file = "pysam-0.24.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8696e88156edee884416fd50c15fcc61da67089232198c1ae731731f6da765d6"}, - {file = "pysam-0.24.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f34eba531bdfd71817110a56c00443f9947d3a01e10358f341d10f614ea3bf1e"}, - {file = "pysam-0.24.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1d114ddd64b562d2fe253a31703613b762c71b4a3d856ac960a39e40269c51fa"}, - {file = "pysam-0.24.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ceb448961fd35b5b90795d7c7c80b1b35592be7ae0127e28187e3f41c27e035b"}, - {file = "pysam-0.24.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39914c2e395be44126e120be0933aaea3ea1d664f3c421a91afc4be086b49a79"}, - {file = "pysam-0.24.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:06eabdc8f7c3894b73d2c4365ea6197d6ba5308e203dd2887b5df635fe6e249b"}, - {file = "pysam-0.24.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2c03ca38923941e460a5edc62d9208393ee9083ecd3f57a3e5a96c1337112dc7"}, - {file = "pysam-0.24.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2fbbcd9ccad9627e6b9a46bbb93e0a244c137ecaa6d7d471033f9b75bc17e6e0"}, - {file = "pysam-0.24.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c7e756b8a9da0f04f6e1ccaad611513f6d52e622b1ae03dcace76af3722100a9"}, - {file = "pysam-0.24.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a52f12c808e53fd16c7f3c42d95914a9d5084a5504f3c32a5138ba08bdfa8408"}, - {file = "pysam-0.24.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:817624cb93fc2373bf3d3e7298a59db88323308b25fcdfd19a0a4df6f119e8dd"}, - {file = "pysam-0.24.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:68b742b2db84cf3982c21be69f886baf3d3cb49fbb070cb4a4c09b4d2fc907c0"}, - {file = "pysam-0.24.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:fdb008b9dfe673ec029189f6394b2d60ce1380ee387c106e799ada237809b2ee"}, - {file = "pysam-0.24.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5cb4a0ffe496111d0acead00a60f2e7e977a4d716089367dc6cc8c0cf511fcbb"}, - {file = "pysam-0.24.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:ec95cc0c4a4fbea432066d9d8e2f566ab4e1e11b4a4bb70b2143ed5b9f2fbf3b"}, - {file = "pysam-0.24.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:897f9a76dfc568e0a18350c5d545cc158e2200884c59ec2eb9895385e33b4315"}, - {file = "pysam-0.24.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9598dd5a571c5c8b4383b4fe1a27823d72b3261c5299100cf3d88dfb09b45019"}, - {file = "pysam-0.24.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:25ffcc2aca0a49358c02e666ddd789afe701c5cf320dcb894ac22ede7347049f"}, - {file = "pysam-0.24.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e520b7311e3822ce029adaf24472e563e724cec442314c6c702956e242dc27d4"}, - {file = "pysam-0.24.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a4e0206a6b8c2b84686f0c5f9087b69dc4c1e8d5e66c98970f86809947d7cb0a"}, - {file = "pysam-0.24.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:1527e9fcfbdbc72d8bf3e06970cca229a041eefe36a30bf14997f52c1f29ccf6"}, - {file = "pysam-0.24.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:886f5c1a2a45b174345c217c821cbd4231311d43ecf5e8157cc7a4bee5db182a"}, - {file = "pysam-0.24.1-cp315-cp315-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:57d7921761ce2b902711e55857f861733b909155fb6299b5559da4a20a353eeb"}, - {file = "pysam-0.24.1-cp315-cp315-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7a22778002a2a401374733dc5698bc3552ff0a6c43d27aeaf37976048bd3d867"}, - {file = "pysam-0.24.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:15dca5345f67b622dfb303ed5328e13799ffc13df12407a6d4542caab5a6ffb1"}, - {file = "pysam-0.24.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:b64fb7c97f8ad78fd5b8cd16f0d8b931d89f0c30b48a061625280ce8b2145782"}, - {file = "pysam-0.24.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0b4b1fec32675cfb992cd6c23e0fbf86481f695959e3973e00c9c1432c78d801"}, - {file = "pysam-0.24.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:cb70dd2c190dab4de044d8d2168c4d74fbc8acad9b9993bdf235c85b1c9b9ce6"}, - {file = "pysam-0.24.1-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a222fb89c91c8acdbe4e77f233c9ee1b9ab2e832afae49797ddefedfbb3191a3"}, - {file = "pysam-0.24.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d5fd6fbd19fa0f833f0e7f02ce16e99679b58fbe311b818fb7ddac2a6a435eef"}, - {file = "pysam-0.24.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1f672fc17990d395d658e191b57c681bd101ae7b4825446a6938fc9ddb797630"}, - {file = "pysam-0.24.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:b8281b79e8b989c224ba0a7de41d06a47c38a0767f1efdfa2cbff1cee86deb6a"}, - {file = "pysam-0.24.1.tar.gz", hash = "sha256:90f612afccdb454d2447ecb5229266c6e7f991093deed4ed0a791db01f7fc994"}, -] - [[package]] name = "pytest" version = "8.4.2" @@ -6590,10 +6537,5 @@ test = ["pytest", "pytest-cases", "pytest-cov", "pytest-mock", "pytest-xdist"] [metadata] lock-version = "2.1" -<<<<<<< HEAD -python-versions = ">=3.10,<3.13" -content-hash = "e850038fc2366ed56556f41e363264d87030fc3489e6372a6ab7b26acd1a804e" -======= python-versions = ">=3.10,<3.14" content-hash = "467eb9c7c1811697036da4aa4c78df66b69178cf25a3a0bb015808eec5621d6f" ->>>>>>> master diff --git a/pyproject.toml b/pyproject.toml index b9c18b7e3..0cd916ed5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,7 +105,6 @@ BioPython = "*" scikit-allel = ">=1.3.13" xarray = "*" plotly = "*" -pysam = ">=0.22.0" # https://github.com/malariagen/malariagen-data-python/issues/845 # https://github.com/malariagen/malariagen-data-python/issues/734 # https://github.com/malariagen/malariagen-data-python/issues/743 diff --git a/tests/anoph/test_igv.py b/tests/anoph/test_igv.py index 8aaa1eef1..84cda5cf3 100644 --- a/tests/anoph/test_igv.py +++ b/tests/anoph/test_igv.py @@ -130,9 +130,13 @@ def wgs_data_catalog(self, sample_set): snp_track = next(track for track in captured["tracks"] if track["name"] == "SNPs") assert snp_track["url"] == local_vcf_url - assert snp_track["indexURL"] == f"{local_vcf_url}.tbi" + # A local VCF has no index, so IGV must load it in full. + assert snp_track["indexed"] is False + assert "indexURL" not in snp_track captured.clear() api.view_alignments(region="2L:1-10", sample="S1", init=False) snp_track = next(track for track in captured["tracks"] if track["name"] == "SNPs") assert snp_track["url"] == "https://example.org/S1.vcf.gz" + assert snp_track["indexURL"] == "https://example.org/S1.vcf.gz.tbi" + assert "indexed" not in snp_track diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index 450a8ca97..bdbf18a63 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -6,9 +6,9 @@ import dask.array as da import numpy as np -import pysam import pytest import xarray as xr +from Bio import bgzf # type: ignore from pytest_cases import parametrize_with_cases from malariagen_data import af1 as _af1 @@ -328,9 +328,8 @@ def test_vcf_exporter_overwrite(fixture, api: SnpVcfExporter, tmp_path): overwrite=True, ) assert os.path.exists(output_path) - assert os.path.exists(output_path + ".tbi") - with pysam.VariantFile(output_path) as vcf: - list(vcf.fetch()) + with bgzf.BgzfReader(output_path, "rt") as f: + assert f.readline().strip() == "##fileformat=VCFv4.3" @parametrize_with_cases("fixture,api", cases=".") @@ -358,7 +357,17 @@ def test_vcf_exporter_gzip(fixture, api: SnpVcfExporter, tmp_path): # Verify it's specifically valid BGZF, not just plain gzip: this is # what tools like tabix/bedtools require for .vcf.gz files, and # what distinguishes genuine BGZF from a plain gzip stream that - # happens to decompress fine but isn't block-structured. + # happens to decompress fine but isn't block-structured. IGV also + # relies on the "BC" extra subfield to decompress every block. + with open(output_path, "rb") as f: + data = f.read() + assert data[12:14] == b"BC", "missing BGZF extra subfield" + assert data.endswith(bgzf._bgzf_eof), "missing BGZF EOF marker" + with bgzf.BgzfReader(output_path, "rt") as f: + bgzf_text = "".join(iter(lambda: f.read(65536), "")) + with gzip.open(output_path, "rt") as f: + assert f.read() == bgzf_text + if shutil.which("bgzip") is not None: result = subprocess.run( ["bgzip", "-t", output_path], capture_output=True, text=True From ba281e1ee8662e88e5c1695f096e0695f4d3e8f3 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 6 Oct 2026 13:50:27 +0100 Subject: [PATCH 31/38] slight changes after running pytest with coverage --- malariagen_data/anoph/to_vcf.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 0f18e6b23..d05915b40 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -29,9 +29,7 @@ class VariantChunkData: # Supported FORMAT fields, the fixed order in which their values are -# always written per sample (regardless of what order the caller's -# `fields` argument happens to iterate in — e.g. a set has no -# guaranteed order at all), and their VCF header definitions. +# always written per sample , and their VCF header definitions. _VALID_FIELDS = {"GT", "GQ", "AD", "MQ"} _FIELD_ORDER = ("GT", "GQ", "AD", "MQ") _FORMAT_HEADERS = { @@ -41,8 +39,7 @@ class VariantChunkData: # N.B., "MQ" is a reserved FORMAT key in the VCF specification, # fixed there as Integer, Number=1 — even though the underlying # data is a float (RMS mapping quality), so values are rounded to - # the nearest integer when written below to stay spec-compliant - # under the reserved key's declared type. + # the nearest integer "MQ": '##FORMAT=', } _HEADER_COLUMNS = ( From 96f059064e36fbe35e6245d3e8286a454b7cfd81 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 6 Oct 2026 14:12:35 +0100 Subject: [PATCH 32/38] added some extra tests --- tests/anoph/test_vcf_exporter.py | 141 ++++++++++++++++++++++++------- 1 file changed, 112 insertions(+), 29 deletions(-) diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index bdbf18a63..ed4edb606 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -81,6 +81,40 @@ def _pick_single_sample_query(api: SnpVcfExporter, sample_sets): return sample_id, sample_query +def _synthetic_snp_calls(sample, contig, call_genotype, positions): + """Build a small single-sample SNP calls dataset, with REF "A" and + ALT "C,T,G" at every site and no GQ, AD or MQ arrays.""" + n_variants = len(positions) + variant_allele = np.array( + [[b"A", b"C", b"T", b"G"]] * n_variants, + dtype="S1", + ) + return xr.Dataset( + data_vars={ + "call_genotype": ( + ["variants", "samples", "ploidy"], + da.from_array(call_genotype, chunks=(n_variants, 1, 2)), + ), + "variant_allele": ( + ["variants", "alleles"], + da.from_array(variant_allele, chunks=(n_variants, 4)), + ), + }, + coords={ + "variant_position": ( + "variants", + da.from_array(np.array(positions), chunks=n_variants), + ), + "variant_contig": ( + "variants", + da.from_array(np.zeros(n_variants, dtype="u1"), chunks=n_variants), + ), + "sample_id": ("samples", np.array([sample])), + }, + attrs={"contigs": (contig,)}, + ) + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter(fixture, api: SnpVcfExporter, tmp_path): region = random.choice(api.contigs) @@ -522,6 +556,83 @@ def test_vcf_exporter_fields_gt_required(fixture, api: SnpVcfExporter, tmp_path) ) +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_fields_unknown(fixture, api: SnpVcfExporter, tmp_path): + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + output_path = str(tmp_path / "test_unknown_field.vcf.gz") + + with pytest.raises(ValueError, match="Unknown FORMAT fields"): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + fields=("GT", "DP"), + ) + + +@pytest.mark.parametrize("filename", ["test.vcf", "test.vcf.bgz", "test.gz"]) +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_output_path_suffix( + fixture, api: SnpVcfExporter, tmp_path, filename +): + region = api.contigs[0] + all_sample_sets = api.sample_sets()["sample_set"].to_list() + sample_sets = [all_sample_sets[0]] + _, sample_query = _pick_single_sample_query(api, sample_sets) + output_path = str(tmp_path / filename) + + with pytest.raises(ValueError, match="must end with .vcf.gz"): + api.snp_calls_to_vcf( + output_path=output_path, + region=region, + sample_sets=sample_sets, + sample_query=sample_query, + ) + assert not os.path.exists(output_path) + + +@parametrize_with_cases("fixture,api", cases=".") +def test_vcf_exporter_missing_optional_fields( + fixture, api: SnpVcfExporter, tmp_path, monkeypatch +): + # If GQ, AD or MQ are requested but the dataset has no such array, + # the FORMAT column still lists them and their values are written + # as missing ("."). + sample = str(api.sample_metadata()["sample_id"].iloc[0]) + contig = api.contigs[0] + call_genotype = np.array([[[0, 1]], [[-1, -1]], [[2, 2]]], dtype="i1") + ds = _synthetic_snp_calls(sample, contig, call_genotype, [100, 200, 300]) + monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) + + output_path = str(tmp_path / "test_missing_optional.vcf.gz") + api.snp_calls_to_vcf( + output_path=output_path, + region=contig, + sample_sets=["dummy"], + sample_query=f"sample_id == '{sample}'", + fields=("GT", "GQ", "AD", "MQ"), + ) + + with gzip.open(output_path, "rt") as f: + lines = f.readlines() + data_lines = [line for line in lines if not line.startswith("#")] + + written = {} + for line in data_lines: + fields_row = line.strip().split("\t") + assert fields_row[8] == "GT:GQ:AD:MQ" + written[int(fields_row[1])] = fields_row[9] + assert written == { + 100: "0/1:.:.:.", + 200: "./.:.:.:.", + 300: "2/2:.:.:.", + } + + @parametrize_with_cases("fixture,api", cases=".") def test_vcf_exporter_synthetic_genotypes( fixture, api: SnpVcfExporter, tmp_path, monkeypatch @@ -533,10 +644,6 @@ def test_vcf_exporter_synthetic_genotypes( sample = str(api.sample_metadata()["sample_id"].iloc[0]) contig = api.contigs[0] - variant_allele = np.array( - [[b"A", b"C", b"T", b"G"]] * 5, - dtype="S1", - ) call_genotype = np.array( [ [[0, 1]], # het @@ -555,31 +662,7 @@ def test_vcf_exporter_synthetic_genotypes( 500: "2/2", } - n_variants = len(positions) - ds = xr.Dataset( - data_vars={ - "call_genotype": ( - ["variants", "samples", "ploidy"], - da.from_array(call_genotype, chunks=(n_variants, 1, 2)), - ), - "variant_allele": ( - ["variants", "alleles"], - da.from_array(variant_allele, chunks=(n_variants, 4)), - ), - }, - coords={ - "variant_position": ( - "variants", - da.from_array(np.array(positions), chunks=n_variants), - ), - "variant_contig": ( - "variants", - da.from_array(np.zeros(n_variants, dtype="u1"), chunks=n_variants), - ), - "sample_id": ("samples", np.array([sample])), - }, - attrs={"contigs": (contig,)}, - ) + ds = _synthetic_snp_calls(sample, contig, call_genotype, positions) monkeypatch.setattr(api, "snp_calls", lambda **kwargs: ds) output_path = str(tmp_path / "test_synthetic.vcf.gz") From a18921d62138ffd0151cdeb099d6b0eaf18ed207 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 6 Oct 2026 15:17:44 +0100 Subject: [PATCH 33/38] ran pre-commit run --all-files --- notebooks/auto_chunks.ipynb | 49 +- notebooks/biallelic_snps.ipynb | 49 +- notebooks/cohort_geometries.ipynb | 4 +- notebooks/extra_metadata.ipynb | 33 +- notebooks/karyotype.ipynb | 58 +- notebooks/ld_pruning.ipynb | 39 +- notebooks/local_cluster.ipynb | 27 +- notebooks/phenotype_data_demo.ipynb | 862 +------------------- notebooks/plink_convert.ipynb | 4 +- notebooks/plot_aims.ipynb | 25 +- notebooks/plot_cnv.ipynb | 63 +- notebooks/plot_diplotype_clustering.ipynb | 59 +- notebooks/plot_diversity.ipynb | 37 +- notebooks/plot_frequencies_heatmap.ipynb | 79 +- notebooks/plot_frequencies_space_time.ipynb | 786 ++---------------- notebooks/plot_fst_gwss.ipynb | 33 +- notebooks/plot_g123_gwss.ipynb | 43 +- notebooks/plot_genes.ipynb | 119 +-- notebooks/plot_h12_h1x.ipynb | 65 +- notebooks/plot_haplotype_clustering.ipynb | 61 +- notebooks/plot_haplotype_networks.ipynb | 61 +- notebooks/plot_haplotypes_frequencies.ipynb | 24 +- notebooks/plot_heterozygosity.ipynb | 37 +- notebooks/plot_ihs_gwss.ipynb | 31 +- notebooks/plot_njt.ipynb | 59 +- notebooks/plot_pairwise_average_fst.ipynb | 42 +- notebooks/plot_pca.ipynb | 119 ++- notebooks/plot_samples.ipynb | 13 +- notebooks/plot_snps.ipynb | 53 +- notebooks/plot_xpehh_gwss.ipynb | 33 +- notebooks/profiling/gh498.ipynb | 20 +- notebooks/repr.ipynb | 25 +- notebooks/spike_sim_test_data.ipynb | 11 +- 33 files changed, 629 insertions(+), 2394 deletions(-) diff --git a/notebooks/auto_chunks.ipynb b/notebooks/auto_chunks.ipynb index 291f7318b..5ca68310e 100644 --- a/notebooks/auto_chunks.ipynb +++ b/notebooks/auto_chunks.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ba32f43-2308-43a0-9849-489d77a2f841", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8015add7-81c7-42bd-94c3-a433047c6ca2", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "fe297aa9-cfe2-40e5-aa18-3f3a082cdd34", + "id": "2", "metadata": {}, "source": [ "## Default chunk sizes" @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27c25fb3-ad5c-4652-bf6c-c51d07558790", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0dbaca2c-d4f0-44c9-b5c8-a992e52dc476", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f149f390-8e34-42c0-aaa5-7cfe3bbd4c6c", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ }, { "cell_type": "markdown", - "id": "8c1a6207-29bb-4ef9-a8a0-4c6a20acda3c", + "id": "6", "metadata": {}, "source": [ "## Explicit chunk sizes" @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5cbedcb4-cf4e-4f5b-9f0a-901e6abb7dd6", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ { "cell_type": "code", "execution_count": null, - "id": "05598e4a-f362-4b21-a601-9968619135a4", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -97,7 +97,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b903fb3a-1f17-403a-bf8b-43623148ffaa", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "497bd930-c0a1-4ab9-9f56-874673420fbd", + "id": "10", "metadata": {}, "source": [ "## Auto chunk sizes" @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9238bb0f-739e-428b-b4f4-9797b15e045b", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8c894749-6486-478d-9f83-0849aa8a62f2", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f9caefda-4adf-4836-bae4-f7b7bedf8e86", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "markdown", - "id": "84bd96e2-42d3-402b-9bca-e071802cb53e", + "id": "14", "metadata": {}, "source": [ "## ND auto chunk sizes" @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7f5c439-505f-44c0-abfb-05999e4d9759", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6b2e3c60-5d05-445b-91fc-da5115b190bb", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "92c9edab-9653-438c-990a-0bffeb81d5fe", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "04e2f86c-bd3d-4bc1-9142-4f1d243ddbd7", + "id": "18", "metadata": {}, "outputs": [], "source": [] @@ -191,7 +191,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -204,15 +203,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/biallelic_snps.ipynb b/notebooks/biallelic_snps.ipynb index e4ebef4fc..fb1b784e9 100644 --- a/notebooks/biallelic_snps.ipynb +++ b/notebooks/biallelic_snps.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "890ed13a-3e8e-4fd6-b0cb-464e31ab5f64", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "42ecae20-46b7-4218-a37c-e96df62241fb", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9151e470-bdbe-4eee-902c-6178b5f6b62f", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9cb9bfcb-19b5-40e1-bd2b-11a8c2247af3", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "489c3941-1ae6-4954-ae48-585823b46649", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8b024a95-6f9d-4371-95bb-eb6887481a6a", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "787973c4-1974-4c8e-8b57-e82b4ea90e6a", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -89,7 +89,7 @@ { "cell_type": "code", "execution_count": null, - "id": "34dfc71b-4e81-4083-8c8a-c08d712e2fa3", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29e17deb-830f-4f5a-9e5f-4707a6041743", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -110,7 +110,7 @@ { "cell_type": "code", "execution_count": null, - "id": "42afc05c-045e-47c8-925a-9df3676ad0fc", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c419ef30-504f-4e8b-8b77-6b15fa29ccb5", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ { "cell_type": "code", "execution_count": null, - "id": "489878b8-eb77-41b8-8b1d-cf6f5035877d", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ef087212-fef9-45da-a797-00be884887a2", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -160,7 +160,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52d0e6c9-b994-4dd9-91b6-00c58af1ee3b", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -170,7 +170,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b8b26acb-c6c5-4c92-9831-a8a276c952f3", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -181,7 +181,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87cdfec5-ca1e-4139-91fa-93506a112b1a", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -200,7 +200,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c83b492b-11ec-400b-bceb-de6630c34a7b", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "07f75f48-bf25-4491-8891-77765867e9a0", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -221,7 +221,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e434252-0c77-4a5d-ac76-55c87c84fd94", + "id": "18", "metadata": {}, "outputs": [], "source": [] @@ -229,7 +229,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -242,15 +241,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/cohort_geometries.ipynb b/notebooks/cohort_geometries.ipynb index fc8e24a27..4c690099b 100644 --- a/notebooks/cohort_geometries.ipynb +++ b/notebooks/cohort_geometries.ipynb @@ -101,13 +101,11 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { - "name": "python", - "version": "3.10.0" + "name": "python" } }, "nbformat": 4, diff --git a/notebooks/extra_metadata.ipynb b/notebooks/extra_metadata.ipynb index c75b619f0..69b65a87a 100644 --- a/notebooks/extra_metadata.ipynb +++ b/notebooks/extra_metadata.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38bb6b32", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "142627af", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e1634546", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -40,7 +40,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5e6e7edd", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ { "cell_type": "code", "execution_count": null, - "id": "140cd606", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3f507df0", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47a85795", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d51ae27a", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -98,7 +98,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c13b4e5a", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "171ad0ce", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "450d0e1f", + "id": "10", "metadata": {}, "outputs": [], "source": [] @@ -128,7 +128,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -141,15 +140,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/karyotype.ipynb b/notebooks/karyotype.ipynb index 857d560ca..ff5ce5f56 100644 --- a/notebooks/karyotype.ipynb +++ b/notebooks/karyotype.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95754202-48fb-40fb-8630-8de938cd90a8", + "id": "0", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0913ba40-7f43-4f3e-8405-f2c3efae65be", + "id": "1", "metadata": { "tags": [] }, @@ -32,7 +32,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d65aea9d-953c-47ad-838e-cf205822b6c8", + "id": "2", "metadata": { "tags": [] }, @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8b1f82f-a60a-4326-a105-a7fd169ed85e", + "id": "3", "metadata": { "tags": [] }, @@ -62,7 +62,7 @@ }, { "cell_type": "markdown", - "id": "35e8569a-5e2c-450d-ad8a-283de669aa27", + "id": "4", "metadata": {}, "source": [ "## 2La" @@ -71,7 +71,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b7556095-b24a-4a26-9a3a-c98cb14d2e24", + "id": "5", "metadata": { "tags": [] }, @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4a16ebf5-1a66-4b10-9f5a-d57080e26cb7", + "id": "6", "metadata": { "tags": [] }, @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8cb4d566-fde1-42e7-a7ba-7294b6adbb66", + "id": "7", "metadata": { "tags": [] }, @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b522c176-da60-4a4b-ad01-5de74c2a49a6", + "id": "8", "metadata": { "tags": [] }, @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0daf1c4e-4e19-43e6-ac9b-b4e0680a01a8", + "id": "9", "metadata": { "tags": [] }, @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f7054916-64b8-4b52-a624-1f4eae413b09", + "id": "10", "metadata": { "tags": [] }, @@ -151,7 +151,7 @@ }, { "cell_type": "markdown", - "id": "32a8664a-67c7-48c8-9870-43f5ec2777ff", + "id": "11", "metadata": {}, "source": [ "## 2Rb" @@ -160,7 +160,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8d7dc314-9bae-487e-9078-0bf0dec42d9c", + "id": "12", "metadata": { "tags": [] }, @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a131e26-730a-479d-acaf-735ea92ec93f", + "id": "13", "metadata": { "tags": [] }, @@ -191,7 +191,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b728fe52-cae6-4c22-9429-52f3d30d475a", + "id": "14", "metadata": { "tags": [] }, @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b674c67a-f4fc-471a-a9d0-08f45e9006e9", + "id": "15", "metadata": { "tags": [] }, @@ -216,7 +216,7 @@ }, { "cell_type": "markdown", - "id": "51595e8d-d911-4f7f-932b-ed1007fa95fd", + "id": "16", "metadata": {}, "source": [ "## 2Rc_gam" @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3091fec6-6484-4c76-9078-f78fc988ae28", + "id": "17", "metadata": { "tags": [] }, @@ -242,7 +242,7 @@ { "cell_type": "code", "execution_count": null, - "id": "da7cd248-2a43-412c-99cf-22ca9786cf2b", + "id": "18", "metadata": { "tags": [] }, @@ -256,7 +256,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f5a08876-0431-4190-87bb-48962fd4c98c", + "id": "19", "metadata": { "tags": [] }, @@ -275,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fa62428f-09c8-4dc5-b45b-e4761041b966", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2287b6e9-50b7-4ce4-9ef5-a4dd0e5463af", + "id": "21", "metadata": { "tags": [] }, @@ -300,7 +300,7 @@ }, { "cell_type": "markdown", - "id": "8fc6d2af-3d22-42e3-8ca8-756c4e72b141", + "id": "22", "metadata": {}, "source": [ "## 2Rc_col" @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "483722dc-86ba-4766-826b-c7d3d2d00cf5", + "id": "23", "metadata": { "tags": [] }, @@ -326,7 +326,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8ec9135f-4abc-432b-9707-14db25e650ea", + "id": "24", "metadata": { "tags": [] }, @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1bcb2209-a5db-4cc2-8fac-d51dae1f214c", + "id": "25", "metadata": { "tags": [] }, @@ -359,7 +359,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ecee39ab-b8f5-4a79-a31b-2badfafc329b", + "id": "26", "metadata": { "tags": [] }, @@ -379,7 +379,6 @@ "uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m124" }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -392,8 +391,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/ld_pruning.ipynb b/notebooks/ld_pruning.ipynb index 292649aeb..f2637cc44 100644 --- a/notebooks/ld_pruning.ipynb +++ b/notebooks/ld_pruning.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "id": "0", "metadata": {}, "source": [ "# LD-pruned biallelic SNP calls\n", @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901", + "id": "1", "metadata": {}, "source": [ "## Setup" @@ -23,7 +23,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c3d4e5f6-a7b8-9012-cdef-123456789012", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d4e5f6a7-b8c9-0123-defa-234567890123", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -47,7 +47,7 @@ }, { "cell_type": "markdown", - "id": "e5f6a7b8-c9d0-1234-efab-345678901234", + "id": "4", "metadata": {}, "source": [ "## Basic usage" @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6a7b8c9-d0e1-2345-fabc-456789012345", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -71,7 +71,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7b8c9d0-e1f2-3456-abcd-567890123456", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -83,7 +83,7 @@ }, { "cell_type": "markdown", - "id": "b8c9d0e1-f2a3-4567-bcde-678901234567", + "id": "7", "metadata": {}, "source": [ "## Effect of LD parameters" @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c9d0e1f2-a3b4-5678-cdef-789012345678", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ }, { "cell_type": "markdown", - "id": "d0e1f2a3-b4c5-6789-defa-890123456789", + "id": "9", "metadata": {}, "source": [ "## Before vs after pruning" @@ -127,7 +127,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e1f2a3b4-c5d6-7890-efab-901234567890", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ }, { "cell_type": "markdown", - "id": "f2a3b4c5-d6e7-8901-fabc-012345678901", + "id": "11", "metadata": {}, "source": [ "## Downstream compatibility\n", @@ -156,7 +156,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a3b4c5d6-e7f8-9012-abcd-123456789abc", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -179,7 +179,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4c5d6e7-f8a9-0123-bcde-234567890bcd", + "id": "13", "metadata": {}, "outputs": [], "source": [] @@ -187,7 +187,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -200,15 +199,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/local_cluster.ipynb b/notebooks/local_cluster.ipynb index 91d56dc41..66da8100b 100644 --- a/notebooks/local_cluster.ipynb +++ b/notebooks/local_cluster.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ba32f43-2308-43a0-9849-489d77a2f841", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8015add7-81c7-42bd-94c3-a433047c6ca2", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27c25fb3-ad5c-4652-bf6c-c51d07558790", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "176f77d9-6376-41ce-b3bf-d8025b5a7174", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d9657559-8fc9-4a70-97da-12208b9502ea", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37bbdfb4-b27d-49d0-9888-042f33d17d32", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -75,7 +75,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87aad9d0-75e6-4d9c-b6a2-814b8fe2ccea", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -85,7 +85,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a6508f51-6915-4da5-b3ce-f3baa4f69937", + "id": "7", "metadata": {}, "outputs": [], "source": [] @@ -93,7 +93,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -106,15 +105,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/phenotype_data_demo.ipynb b/notebooks/phenotype_data_demo.ipynb index ac1e224f8..dccab55ee 100644 --- a/notebooks/phenotype_data_demo.ipynb +++ b/notebooks/phenotype_data_demo.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "cef10418-08a1-4cc4-a3b0-b8b516cc64fd", + "id": "0", "metadata": {}, "source": [ "# Demonstrating New Phenotype Data Access and Filtering\n", @@ -13,7 +13,7 @@ }, { "cell_type": "markdown", - "id": "29554ea2-5e37-40b6-90c1-08088bf9793a", + "id": "1", "metadata": {}, "source": [ "## 1. Setup and Imports\n", @@ -23,351 +23,10 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "f1280de7-129f-4875-bf12-eb68b8d88573", + "execution_count": null, + "id": "2", "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": [ - "'use strict';\n", - "(function(root) {\n", - " function now() {\n", - " return new Date();\n", - " }\n", - "\n", - " const force = true;\n", - "\n", - " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n", - " root._bokeh_onload_callbacks = [];\n", - " root._bokeh_is_loading = undefined;\n", - " }\n", - "\n", - "const JS_MIME_TYPE = 'application/javascript';\n", - " const HTML_MIME_TYPE = 'text/html';\n", - " const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", - " const CLASS_NAME = 'output_bokeh rendered_html';\n", - "\n", - " /**\n", - " * Render data to the DOM node\n", - " */\n", - " function render(props, node) {\n", - " const script = document.createElement(\"script\");\n", - " node.appendChild(script);\n", - " }\n", - "\n", - " /**\n", - " * Handle when an output is cleared or removed\n", - " */\n", - " function handleClearOutput(event, handle) {\n", - " function drop(id) {\n", - " const view = Bokeh.index.get_by_id(id)\n", - " if (view != null) {\n", - " view.model.document.clear()\n", - " Bokeh.index.delete(view)\n", - " }\n", - " }\n", - "\n", - " const cell = handle.cell;\n", - "\n", - " const id = cell.output_area._bokeh_element_id;\n", - " const server_id = cell.output_area._bokeh_server_id;\n", - "\n", - " // Clean up Bokeh references\n", - " if (id != null) {\n", - " drop(id)\n", - " }\n", - "\n", - " if (server_id !== undefined) {\n", - " // Clean up Bokeh references\n", - " const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", - " cell.notebook.kernel.execute(cmd_clean, {\n", - " iopub: {\n", - " output: function(msg) {\n", - " const id = msg.content.text.trim()\n", - " drop(id)\n", - " }\n", - " }\n", - " });\n", - " // Destroy server and session\n", - " const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", - " cell.notebook.kernel.execute(cmd_destroy);\n", - " }\n", - " }\n", - "\n", - " /**\n", - " * Handle when a new output is added\n", - " */\n", - " function handleAddOutput(event, handle) {\n", - " const output_area = handle.output_area;\n", - " const output = handle.output;\n", - "\n", - " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", - " if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n", - " return\n", - " }\n", - "\n", - " const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", - "\n", - " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", - " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", - " // store reference to embed id on output_area\n", - " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", - " }\n", - " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", - " const bk_div = document.createElement(\"div\");\n", - " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", - " const script_attrs = bk_div.children[0].attributes;\n", - " for (let i = 0; i < script_attrs.length; i++) {\n", - " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", - " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n", - " }\n", - " // store reference to server id on output_area\n", - " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", - " }\n", - " }\n", - "\n", - " function register_renderer(events, OutputArea) {\n", - "\n", - " function append_mime(data, metadata, element) {\n", - " // create a DOM node to render to\n", - " const toinsert = this.create_output_subarea(\n", - " metadata,\n", - " CLASS_NAME,\n", - " EXEC_MIME_TYPE\n", - " );\n", - " this.keyboard_manager.register_events(toinsert);\n", - " // Render to node\n", - " const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", - " render(props, toinsert[toinsert.length - 1]);\n", - " element.append(toinsert);\n", - " return toinsert\n", - " }\n", - "\n", - " /* Handle when an output is cleared or removed */\n", - " events.on('clear_output.CodeCell', handleClearOutput);\n", - " events.on('delete.Cell', handleClearOutput);\n", - "\n", - " /* Handle when a new output is added */\n", - " events.on('output_added.OutputArea', handleAddOutput);\n", - "\n", - " /**\n", - " * Register the mime type and append_mime function with output_area\n", - " */\n", - " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", - " /* Is output safe? */\n", - " safe: true,\n", - " /* Index of renderer in `output_area.display_order` */\n", - " index: 0\n", - " });\n", - " }\n", - "\n", - " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", - " if (root.Jupyter !== undefined) {\n", - " const events = require('base/js/events');\n", - " const OutputArea = require('notebook/js/outputarea').OutputArea;\n", - "\n", - " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", - " register_renderer(events, OutputArea);\n", - " }\n", - " }\n", - " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", - " root._bokeh_timeout = Date.now() + 5000;\n", - " root._bokeh_failed_load = false;\n", - " }\n", - "\n", - " const NB_LOAD_WARNING = {'data': {'text/html':\n", - " \"
\\n\"+\n", - " \"

\\n\"+\n", - " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", - " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", - " \"

\\n\"+\n", - " \"
    \\n\"+\n", - " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", - " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", - " \"
\\n\"+\n", - " \"\\n\"+\n", - " \"from bokeh.resources import INLINE\\n\"+\n", - " \"output_notebook(resources=INLINE)\\n\"+\n", - " \"\\n\"+\n", - " \"
\"}};\n", - "\n", - " function display_loaded(error = null) {\n", - " const el = document.getElementById(null);\n", - " if (el != null) {\n", - " const html = (() => {\n", - " if (typeof root.Bokeh === \"undefined\") {\n", - " if (error == null) {\n", - " return \"BokehJS is loading ...\";\n", - " } else {\n", - " return \"BokehJS failed to load.\";\n", - " }\n", - " } else {\n", - " const prefix = `BokehJS ${root.Bokeh.version}`;\n", - " if (error == null) {\n", - " return `${prefix} successfully loaded.`;\n", - " } else {\n", - " return `${prefix} encountered errors while loading and may not function as expected.`;\n", - " }\n", - " }\n", - " })();\n", - " el.innerHTML = html;\n", - "\n", - " if (error != null) {\n", - " const wrapper = document.createElement(\"div\");\n", - " wrapper.style.overflow = \"auto\";\n", - " wrapper.style.height = \"5em\";\n", - " wrapper.style.resize = \"vertical\";\n", - " const content = document.createElement(\"div\");\n", - " content.style.fontFamily = \"monospace\";\n", - " content.style.whiteSpace = \"pre-wrap\";\n", - " content.style.backgroundColor = \"rgb(255, 221, 221)\";\n", - " content.textContent = error.stack ?? error.toString();\n", - " wrapper.append(content);\n", - " el.append(wrapper);\n", - " }\n", - " } else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(() => display_loaded(error), 100);\n", - " }\n", - " }\n", - "\n", - " function run_callbacks() {\n", - " try {\n", - " root._bokeh_onload_callbacks.forEach(function(callback) {\n", - " if (callback != null)\n", - " callback();\n", - " });\n", - " } finally {\n", - " delete root._bokeh_onload_callbacks\n", - " }\n", - " console.debug(\"Bokeh: all callbacks have finished\");\n", - " }\n", - "\n", - " function load_libs(css_urls, js_urls, callback) {\n", - " if (css_urls == null) css_urls = [];\n", - " if (js_urls == null) js_urls = [];\n", - "\n", - " root._bokeh_onload_callbacks.push(callback);\n", - " if (root._bokeh_is_loading > 0) {\n", - " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", - " return null;\n", - " }\n", - " if (js_urls == null || js_urls.length === 0) {\n", - " run_callbacks();\n", - " return null;\n", - " }\n", - " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", - " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", - "\n", - " function on_load() {\n", - " root._bokeh_is_loading--;\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", - " run_callbacks()\n", - " }\n", - " }\n", - "\n", - " function on_error(url) {\n", - " console.error(\"failed to load \" + url);\n", - " }\n", - "\n", - " for (let i = 0; i < css_urls.length; i++) {\n", - " const url = css_urls[i];\n", - " const element = document.createElement(\"link\");\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.rel = \"stylesheet\";\n", - " element.type = \"text/css\";\n", - " element.href = url;\n", - " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " for (let i = 0; i < js_urls.length; i++) {\n", - " const url = js_urls[i];\n", - " const element = document.createElement('script');\n", - " element.onload = on_load;\n", - " element.onerror = on_error.bind(null, url);\n", - " element.async = false;\n", - " element.src = url;\n", - " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", - " document.head.appendChild(element);\n", - " }\n", - " };\n", - "\n", - " function inject_raw_css(css) {\n", - " const element = document.createElement(\"style\");\n", - " element.appendChild(document.createTextNode(css));\n", - " document.body.appendChild(element);\n", - " }\n", - "\n", - " const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.min.js\"];\n", - " const css_urls = [];\n", - "\n", - " const inline_js = [ function(Bokeh) {\n", - " Bokeh.set_log_level(\"info\");\n", - " },\n", - "function(Bokeh) {\n", - " }\n", - " ];\n", - "\n", - " function run_inline_js() {\n", - " if (root.Bokeh !== undefined || force === true) {\n", - " try {\n", - " for (let i = 0; i < inline_js.length; i++) {\n", - " inline_js[i].call(root, root.Bokeh);\n", - " }\n", - "\n", - " } catch (error) {throw error;\n", - " }} else if (Date.now() < root._bokeh_timeout) {\n", - " setTimeout(run_inline_js, 100);\n", - " } else if (!root._bokeh_failed_load) {\n", - " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", - " root._bokeh_failed_load = true;\n", - " } else if (force !== true) {\n", - " const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n", - " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", - " }\n", - " }\n", - "\n", - " if (root._bokeh_is_loading === 0) {\n", - " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", - " run_inline_js();\n", - " } else {\n", - " load_libs(css_urls, js_urls, function() {\n", - " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", - " run_inline_js();\n", - " });\n", - " }\n", - "}(window));" - ], - "application/vnd.bokehjs_load.v0+json": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"
    \\n\"+\n \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n \"
  • use INLINE resources instead, as so:
  • \\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "MalariaGEN Ag3 API client initialized.\n", - "\n", - "Storage URL : gs://vo_agam_release_master_us_central1/\n", - "Data releases available : 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15\n", - "Results cache : None\n", - "Cohorts analysis : 20250502\n", - "AIM analysis : 20220528\n", - "Site filters analysis : dt_20200416\n", - "Software version : malariagen_data 15.2.2.post22+48d1097a\n", - "Client location : Tanger-Tetouan-Al Hoceima, Morocco\n", - "---\n", - "Please note that data are subject to terms of use,\n", - "for more information see https://www.malariagen.net/data\n", - "or contact support@malariagen.net. For API documentation see \n", - "https://malariagen.github.io/malariagen-data-python/v15.2.2.post22+48d1097a/Ag3.html\n" - ] - } - ], + "outputs": [], "source": [ "import pandas as pd\n", "import xarray as xr\n", @@ -387,7 +46,7 @@ }, { "cell_type": "markdown", - "id": "5b1975f3-ad03-450d-b387-6d2ffd5c0143", + "id": "3", "metadata": {}, "source": [ "## 2. Listing Available Phenotype Sample Sets\n", @@ -396,20 +55,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "7dd3ebc4-64f7-4d0b-ad01-fbc1e08b0636", + "execution_count": null, + "id": "4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Available phenotype sample sets: ['1237-VO-BJ-DJOGBENOU-VMF00050', '1244-VO-GH-YAWSON-VMF00051', '1245-VO-CI-CONSTANT-VMF00054', '1253-VO-TG-DJOGBENOU-VMF00052']\n", - "\n", - "Using sample set for demonstration: 1237-VO-BJ-DJOGBENOU-VMF00050\n" - ] - } - ], + "outputs": [], "source": [ "phenotype_sample_sets = ag3.phenotype_sample_sets()\n", "print(f\"Available phenotype sample sets: {phenotype_sample_sets}\")\n", @@ -428,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "1319b97a-bd6f-4246-b653-a394aee97930", + "id": "5", "metadata": {}, "source": [ "## 3. Loading Phenotype Data with sample_query\n", @@ -437,7 +86,7 @@ }, { "cell_type": "markdown", - "id": "6f6d5023-17b1-4988-8683-22b3f71096ff", + "id": "6", "metadata": {}, "source": [ "### Example 1: Filter by a specific insecticide" @@ -445,93 +94,10 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "c0b9d0ae-6a79-458a-ad9f-9281a1c6112e", + "execution_count": null, + "id": "7", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Loading phenotype data for '1237-VO-BJ-DJOGBENOU-VMF00050' filtered by Deltamethrin ---\n", - "Shape of DataFrame: (88, 60) \n", - "\n", - "First 5 rows of the filtered DataFrame:\n", - "\n", - "Unique insecticides in filtered data: ['Deltamethrin']\n", - "\n", - "DataFrame Info:\n", - "\n", - "Index: 88 entries, 0 to 87\n", - "Data columns (total 60 columns):\n", - " # Column Non-Null Count Dtype \n", - "--- ------ -------------- ----- \n", - " 0 sample_id 88 non-null object \n", - " 1 country 88 non-null object \n", - " 2 location 88 non-null object \n", - " 3 insecticide 88 non-null object \n", - " 4 dose 88 non-null float64\n", - " 5 phenotype 88 non-null object \n", - " 6 sample_set 88 non-null object \n", - " 7 partner_sample_id 88 non-null object \n", - " 8 contributor 88 non-null object \n", - " 9 year 88 non-null int64 \n", - " 10 month 88 non-null int64 \n", - " 11 latitude 88 non-null float64\n", - " 12 longitude 88 non-null float64\n", - " 13 sex_call 88 non-null object \n", - " 14 release 88 non-null object \n", - " 15 quarter 88 non-null int64 \n", - " 16 study_id 88 non-null object \n", - " 17 study_url 88 non-null object \n", - " 18 terms_of_use_expiry_date 88 non-null object \n", - " 19 terms_of_use_url 88 non-null object \n", - " 20 unrestricted_use 88 non-null bool \n", - " 21 mean_cov 88 non-null Float64\n", - " 22 median_cov 88 non-null Int64 \n", - " 23 modal_cov 88 non-null Int64 \n", - " 24 mean_cov_2L 88 non-null Float64\n", - " 25 median_cov_2L 88 non-null Int64 \n", - " 26 mode_cov_2L 88 non-null Int64 \n", - " 27 mean_cov_2R 88 non-null Float64\n", - " 28 median_cov_2R 88 non-null Int64 \n", - " 29 mode_cov_2R 88 non-null Int64 \n", - " 30 mean_cov_3L 88 non-null Float64\n", - " 31 median_cov_3L 88 non-null Int64 \n", - " 32 mode_cov_3L 88 non-null Int64 \n", - " 33 mean_cov_3R 88 non-null Float64\n", - " 34 median_cov_3R 88 non-null Int64 \n", - " 35 mode_cov_3R 88 non-null Int64 \n", - " 36 mean_cov_X 88 non-null Float64\n", - " 37 median_cov_X 88 non-null Int64 \n", - " 38 mode_cov_X 88 non-null Int64 \n", - " 39 frac_gen_cov 88 non-null Float64\n", - " 40 divergence 88 non-null Float64\n", - " 41 contam_pct 88 non-null Float64\n", - " 42 contam_LLR 88 non-null Float64\n", - " 43 aim_species_fraction_arab 88 non-null float64\n", - " 44 aim_species_fraction_colu 88 non-null float64\n", - " 45 aim_species_fraction_colu_no2l 88 non-null float64\n", - " 46 aim_species_gambcolu_arabiensis 88 non-null object \n", - " 47 aim_species_gambiae_coluzzii 88 non-null object \n", - " 48 aim_species 88 non-null object \n", - " 49 country_iso 88 non-null object \n", - " 50 admin1_name 88 non-null object \n", - " 51 admin1_iso 88 non-null object \n", - " 52 admin2_name 88 non-null object \n", - " 53 taxon 88 non-null object \n", - " 54 cohort_admin1_year 88 non-null object \n", - " 55 cohort_admin1_month 88 non-null object \n", - " 56 cohort_admin1_quarter 88 non-null object \n", - " 57 cohort_admin2_year 88 non-null object \n", - " 58 cohort_admin2_month 88 non-null object \n", - " 59 cohort_admin2_quarter 88 non-null object \n", - "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", - "memory usage: 43.2+ KB\n" - ] - } - ], + "outputs": [], "source": [ "print(\n", " f\"\\n--- Loading phenotype data for '{demo_sample_set}' filtered by Deltamethrin ---\"\n", @@ -552,7 +118,7 @@ }, { "cell_type": "markdown", - "id": "daede4ca-01cc-450a-8185-294033af85ad", + "id": "8", "metadata": {}, "source": [ "### Example 2: Filter by multiple conditions (insecticide and dose)" @@ -560,94 +126,10 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "eab7d81c-d80c-4279-9263-a0d7b425ff85", + "execution_count": null, + "id": "9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Loading phenotype data filtered by Deltamethrin and dose >= 1.0 ---\n", - "Shape of DataFrame: (48, 60)\n", - "\n", - "First 5 rows of the multi-filtered DataFrame:\n", - "\n", - "Unique insecticides: ['Deltamethrin']\n", - "Unique doses: [2.]\n", - "\n", - "DataFrame Info:\n", - "\n", - "Index: 48 entries, 40 to 87\n", - "Data columns (total 60 columns):\n", - " # Column Non-Null Count Dtype \n", - "--- ------ -------------- ----- \n", - " 0 sample_id 48 non-null object \n", - " 1 country 48 non-null object \n", - " 2 location 48 non-null object \n", - " 3 insecticide 48 non-null object \n", - " 4 dose 48 non-null float64\n", - " 5 phenotype 48 non-null object \n", - " 6 sample_set 48 non-null object \n", - " 7 partner_sample_id 48 non-null object \n", - " 8 contributor 48 non-null object \n", - " 9 year 48 non-null int64 \n", - " 10 month 48 non-null int64 \n", - " 11 latitude 48 non-null float64\n", - " 12 longitude 48 non-null float64\n", - " 13 sex_call 48 non-null object \n", - " 14 release 48 non-null object \n", - " 15 quarter 48 non-null int64 \n", - " 16 study_id 48 non-null object \n", - " 17 study_url 48 non-null object \n", - " 18 terms_of_use_expiry_date 48 non-null object \n", - " 19 terms_of_use_url 48 non-null object \n", - " 20 unrestricted_use 48 non-null bool \n", - " 21 mean_cov 48 non-null Float64\n", - " 22 median_cov 48 non-null Int64 \n", - " 23 modal_cov 48 non-null Int64 \n", - " 24 mean_cov_2L 48 non-null Float64\n", - " 25 median_cov_2L 48 non-null Int64 \n", - " 26 mode_cov_2L 48 non-null Int64 \n", - " 27 mean_cov_2R 48 non-null Float64\n", - " 28 median_cov_2R 48 non-null Int64 \n", - " 29 mode_cov_2R 48 non-null Int64 \n", - " 30 mean_cov_3L 48 non-null Float64\n", - " 31 median_cov_3L 48 non-null Int64 \n", - " 32 mode_cov_3L 48 non-null Int64 \n", - " 33 mean_cov_3R 48 non-null Float64\n", - " 34 median_cov_3R 48 non-null Int64 \n", - " 35 mode_cov_3R 48 non-null Int64 \n", - " 36 mean_cov_X 48 non-null Float64\n", - " 37 median_cov_X 48 non-null Int64 \n", - " 38 mode_cov_X 48 non-null Int64 \n", - " 39 frac_gen_cov 48 non-null Float64\n", - " 40 divergence 48 non-null Float64\n", - " 41 contam_pct 48 non-null Float64\n", - " 42 contam_LLR 48 non-null Float64\n", - " 43 aim_species_fraction_arab 48 non-null float64\n", - " 44 aim_species_fraction_colu 48 non-null float64\n", - " 45 aim_species_fraction_colu_no2l 48 non-null float64\n", - " 46 aim_species_gambcolu_arabiensis 48 non-null object \n", - " 47 aim_species_gambiae_coluzzii 48 non-null object \n", - " 48 aim_species 48 non-null object \n", - " 49 country_iso 48 non-null object \n", - " 50 admin1_name 48 non-null object \n", - " 51 admin1_iso 48 non-null object \n", - " 52 admin2_name 48 non-null object \n", - " 53 taxon 48 non-null object \n", - " 54 cohort_admin1_year 48 non-null object \n", - " 55 cohort_admin1_month 48 non-null object \n", - " 56 cohort_admin1_quarter 48 non-null object \n", - " 57 cohort_admin2_year 48 non-null object \n", - " 58 cohort_admin2_month 48 non-null object \n", - " 59 cohort_admin2_quarter 48 non-null object \n", - "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", - "memory usage: 23.6+ KB\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Loading phenotype data filtered by Deltamethrin and dose >= 1.0 ---\")\n", "df_filtered_multi = ag3.phenotype_data(\n", @@ -667,7 +149,7 @@ }, { "cell_type": "markdown", - "id": "fc1cc12c-b24b-41f3-b147-9e4d817ab588", + "id": "10", "metadata": {}, "source": [ "### Example 3: Applying cohort size filtering\n", @@ -676,91 +158,10 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "de8cd777-a4b2-44dd-a0bf-64a6ef419da7", + "execution_count": null, + "id": "11", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Loading phenotype data with min_cohort_size=10 ---\n", - "Shape of DataFrame: (88, 60)\n", - "\n", - "First 5 rows of the cohort-filtered DataFrame:\n", - "\n", - "DataFrame Info:\n", - "\n", - "RangeIndex: 88 entries, 0 to 87\n", - "Data columns (total 60 columns):\n", - " # Column Non-Null Count Dtype \n", - "--- ------ -------------- ----- \n", - " 0 sample_id 88 non-null object \n", - " 1 country 88 non-null object \n", - " 2 location 88 non-null object \n", - " 3 insecticide 88 non-null object \n", - " 4 dose 88 non-null float64\n", - " 5 phenotype 88 non-null object \n", - " 6 sample_set 88 non-null object \n", - " 7 partner_sample_id 88 non-null object \n", - " 8 contributor 88 non-null object \n", - " 9 year 88 non-null int64 \n", - " 10 month 88 non-null int64 \n", - " 11 latitude 88 non-null float64\n", - " 12 longitude 88 non-null float64\n", - " 13 sex_call 88 non-null object \n", - " 14 release 88 non-null object \n", - " 15 quarter 88 non-null int64 \n", - " 16 study_id 88 non-null object \n", - " 17 study_url 88 non-null object \n", - " 18 terms_of_use_expiry_date 88 non-null object \n", - " 19 terms_of_use_url 88 non-null object \n", - " 20 unrestricted_use 88 non-null bool \n", - " 21 mean_cov 88 non-null Float64\n", - " 22 median_cov 88 non-null Int64 \n", - " 23 modal_cov 88 non-null Int64 \n", - " 24 mean_cov_2L 88 non-null Float64\n", - " 25 median_cov_2L 88 non-null Int64 \n", - " 26 mode_cov_2L 88 non-null Int64 \n", - " 27 mean_cov_2R 88 non-null Float64\n", - " 28 median_cov_2R 88 non-null Int64 \n", - " 29 mode_cov_2R 88 non-null Int64 \n", - " 30 mean_cov_3L 88 non-null Float64\n", - " 31 median_cov_3L 88 non-null Int64 \n", - " 32 mode_cov_3L 88 non-null Int64 \n", - " 33 mean_cov_3R 88 non-null Float64\n", - " 34 median_cov_3R 88 non-null Int64 \n", - " 35 mode_cov_3R 88 non-null Int64 \n", - " 36 mean_cov_X 88 non-null Float64\n", - " 37 median_cov_X 88 non-null Int64 \n", - " 38 mode_cov_X 88 non-null Int64 \n", - " 39 frac_gen_cov 88 non-null Float64\n", - " 40 divergence 88 non-null Float64\n", - " 41 contam_pct 88 non-null Float64\n", - " 42 contam_LLR 88 non-null Float64\n", - " 43 aim_species_fraction_arab 88 non-null float64\n", - " 44 aim_species_fraction_colu 88 non-null float64\n", - " 45 aim_species_fraction_colu_no2l 88 non-null float64\n", - " 46 aim_species_gambcolu_arabiensis 88 non-null object \n", - " 47 aim_species_gambiae_coluzzii 88 non-null object \n", - " 48 aim_species 88 non-null object \n", - " 49 country_iso 88 non-null object \n", - " 50 admin1_name 88 non-null object \n", - " 51 admin1_iso 88 non-null object \n", - " 52 admin2_name 88 non-null object \n", - " 53 taxon 88 non-null object \n", - " 54 cohort_admin1_year 88 non-null object \n", - " 55 cohort_admin1_month 88 non-null object \n", - " 56 cohort_admin1_quarter 88 non-null object \n", - " 57 cohort_admin2_year 88 non-null object \n", - " 58 cohort_admin2_month 88 non-null object \n", - " 59 cohort_admin2_quarter 88 non-null object \n", - "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", - "memory usage: 42.7+ KB\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Loading phenotype data with min_cohort_size=10 ---\")\n", "df_cohort_filtered = ag3.phenotype_data(\n", @@ -787,51 +188,10 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "9a1f4cc9-528f-40bf-9efe-71aee41c21c3", + "execution_count": null, + "id": "12", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Getting binary phenotype outcomes for '1237-VO-BJ-DJOGBENOU-VMF00050' ---\n", - "Shape of binary series: (88,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18949-5562STDY7801785 0.0\n", - "VBS18950-5562STDY7801786 0.0\n", - "VBS18951-5562STDY7801787 0.0\n", - "VBS18952-5562STDY7801788 0.0\n", - "VBS18953-5562STDY7801789 0.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [0. 1.]\n", - "\n", - "Shape of binary series (alive Deltamethrin): (48,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18995-5562STDY7801828 1.0\n", - "VBS18996-5562STDY7801829 1.0\n", - "VBS18998-5562STDY7801830 1.0\n", - "VBS18999-5562STDY7801831 1.0\n", - "VBS19000-5562STDY7801832 1.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [1.]\n", - "\n", - "Shape of binary series (dose 0.5): (40,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18949-5562STDY7801785 0.0\n", - "VBS18950-5562STDY7801786 0.0\n", - "VBS18951-5562STDY7801787 0.0\n", - "VBS18952-5562STDY7801788 0.0\n", - "VBS18953-5562STDY7801789 0.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [0.]\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Getting binary phenotype outcomes for '{demo_sample_set}' ---\")\n", "\n", @@ -872,7 +232,7 @@ }, { "cell_type": "markdown", - "id": "a92e430e-7f40-48a8-8c98-2405d27aabfb", + "id": "13", "metadata": {}, "source": [ "## 4. Getting Binary Phenotype Outcomes with phenotype_binary\n", @@ -882,51 +242,10 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "fda88368", + "execution_count": null, + "id": "14", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Getting binary phenotype outcomes for '1237-VO-BJ-DJOGBENOU-VMF00050' ---\n", - "Shape of binary series: (88,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18949-5562STDY7801785 0.0\n", - "VBS18950-5562STDY7801786 0.0\n", - "VBS18951-5562STDY7801787 0.0\n", - "VBS18952-5562STDY7801788 0.0\n", - "VBS18953-5562STDY7801789 0.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [0. 1.]\n", - "\n", - "Shape of binary series (alive Deltamethrin): (48,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18995-5562STDY7801828 1.0\n", - "VBS18996-5562STDY7801829 1.0\n", - "VBS18998-5562STDY7801830 1.0\n", - "VBS18999-5562STDY7801831 1.0\n", - "VBS19000-5562STDY7801832 1.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [1.]\n", - "\n", - "Shape of binary series (dose 0.5): (40,)\n", - "First 5 entries:\n", - "sample_id\n", - "VBS18949-5562STDY7801785 0.0\n", - "VBS18950-5562STDY7801786 0.0\n", - "VBS18951-5562STDY7801787 0.0\n", - "VBS18952-5562STDY7801788 0.0\n", - "VBS18953-5562STDY7801789 0.0\n", - "Name: phenotype_binary, dtype: float64\n", - "Unique values in series: [0.]\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Getting binary phenotype outcomes for '{demo_sample_set}' ---\")\n", "\n", @@ -967,7 +286,7 @@ }, { "cell_type": "markdown", - "id": "62e84ea0", + "id": "15", "metadata": {}, "source": [ "## 5. Loading Phenotype Data Merged with SNP Calls\n", @@ -976,64 +295,10 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "726ab8a3-6573-49d5-9b29-479176e5dee6", + "execution_count": null, + "id": "16", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Loading phenotype data merged with SNP calls ---\n", - "Dataset dimensions: FrozenMappingWarningOnValuesAccess({'samples': 48, 'variants': 10001, 'alleles': 4, 'ploidy': 2})\n", - "\n", - "Dataset structure (rich display):\n", - "\n", - "First 5 samples and their phenotype_binary values:\n", - "[1. 1. 1. 1. 1.]\n", - "\n", - "First 5 samples and their insecticide values:\n", - "['Deltamethrin' 'Deltamethrin' 'Deltamethrin' 'Deltamethrin'\n", - " 'Deltamethrin']\n", - "\n", - "First 5 variant positions:\n", - "[2420000 2420001 2420002 2420003 2420004]\n", - "\n", - "Dataset Info:\n", - "xarray.Dataset {\n", - "dimensions:\n", - "\tsamples = 48 ;\n", - "\tvariants = 10001 ;\n", - "\talleles = 4 ;\n", - "\tploidy = 2 ;\n", - "\n", - "variables:\n", - "\tfloat64 phenotype_binary(samples) ;\n", - "\tobject insecticide(samples) ;\n", - "\tfloat64 dose(samples) ;\n", - "\tobject phenotype(samples) ;\n", - "\tobject location(samples) ;\n", - "\tobject country(samples) ;\n", - "\tobject sample_set(samples) ;\n", - "\tobject samples(samples) ;\n", - "\t|S1 variant_allele(variants, alleles) ;\n", - "\tbool variant_filter_pass_gamb_colu_arab(variants) ;\n", - "\tbool variant_filter_pass_gamb_colu(variants) ;\n", - "\tbool variant_filter_pass_arab(variants) ;\n", - "\tint32 variant_position(variants) ;\n", - "\tuint8 variant_contig(variants) ;\n", - "\tint8 call_genotype(variants, samples, ploidy) ;\n", - "\tint16 call_GQ(variants, samples) ;\n", - "\tfloat32 call_MQ(variants, samples) ;\n", - "\tint16 call_AD(variants, samples, alleles) ;\n", - "\tbool call_genotype_mask(variants, samples, ploidy) ;\n", - "\n", - "// global attributes:\n", - "}" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Loading phenotype data merged with SNP calls ---\")\n", "\n", @@ -1062,7 +327,7 @@ }, { "cell_type": "markdown", - "id": "99e7b505-4ea4-43dc-91ae-14ac8f12076e", + "id": "17", "metadata": {}, "source": [ "## 6. Loading Phenotype Data Merged with Haplotypes\n", @@ -1071,57 +336,10 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "403f3a26-71eb-4781-975d-d94b7a021d97", + "execution_count": null, + "id": "18", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "--- Loading phenotype data merged with Haplotypes ---\n", - "Dataset dimensions: FrozenMappingWarningOnValuesAccess({'samples': 40, 'variants': 2153, 'alleles': 2, 'ploidy': 2})\n", - "\n", - "Dataset structure (rich display):\n", - "\n", - "First 5 samples and their phenotype_binary values:\n", - "[0. 0. 0. 0. 0.]\n", - "\n", - "First 5 samples and their insecticide values:\n", - "['Deltamethrin' 'Deltamethrin' 'Deltamethrin' 'Deltamethrin'\n", - " 'Deltamethrin']\n", - "\n", - "First 5 variant positions:\n", - "[2420351 2420359 2420370 2420371 2420375]\n", - "\n", - "Dataset Info:\n", - "xarray.Dataset {\n", - "dimensions:\n", - "\tsamples = 40 ;\n", - "\tvariants = 2153 ;\n", - "\talleles = 2 ;\n", - "\tploidy = 2 ;\n", - "\n", - "variables:\n", - "\tfloat64 phenotype_binary(samples) ;\n", - "\tobject insecticide(samples) ;\n", - "\tfloat64 dose(samples) ;\n", - "\tobject phenotype(samples) ;\n", - "\tobject location(samples) ;\n", - "\tobject country(samples) ;\n", - "\tobject sample_set(samples) ;\n", - "\tobject samples(samples) ;\n", - "\tint32 variant_position(variants) ;\n", - "\tuint8 variant_contig(variants) ;\n", - "\t|S1 variant_allele(variants, alleles) ;\n", - "\tint8 call_genotype(variants, samples, ploidy) ;\n", - "\n", - "// global attributes:\n", - "}" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\n--- Loading phenotype data merged with Haplotypes ---\")\n", "\n", @@ -1150,7 +368,7 @@ }, { "cell_type": "markdown", - "id": "e2ca345f-33e9-481d-8cf6-0ec08253121c", + "id": "19", "metadata": {}, "source": [ "## Conclusion\n", @@ -1160,7 +378,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1173,8 +390,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.4" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plink_convert.ipynb b/notebooks/plink_convert.ipynb index a82710ef2..192a0ee1f 100644 --- a/notebooks/plink_convert.ipynb +++ b/notebooks/plink_convert.ipynb @@ -29,7 +29,6 @@ ], "metadata": { "kernelspec": { - "display_name": "malariagen_plink", "language": "python", "name": "python3" }, @@ -42,8 +41,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.5" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_aims.ipynb b/notebooks/plot_aims.ipynb index 580a64a39..0e045d92d 100644 --- a/notebooks/plot_aims.ipynb +++ b/notebooks/plot_aims.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17ea65d6", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e5fa0a3", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15a6c908", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a2bfe151", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "446a82fb", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2c181775", + "id": "5", "metadata": {}, "outputs": [], "source": [] @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "98686752", + "id": "6", "metadata": {}, "outputs": [], "source": [] @@ -84,7 +84,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -97,15 +96,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_cnv.ipynb b/notebooks/plot_cnv.ipynb index 87def583b..666648045 100644 --- a/notebooks/plot_cnv.ipynb +++ b/notebooks/plot_cnv.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a6b71675", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -14,7 +14,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4526413e", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ef6e539", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ }, { "cell_type": "markdown", - "id": "74c46a04", + "id": "3", "metadata": {}, "source": [ "## CNV HMM coverage" @@ -49,7 +49,7 @@ }, { "cell_type": "markdown", - "id": "4ccf170b", + "id": "4", "metadata": {}, "source": [ "### Ag3" @@ -58,7 +58,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d6bb2a01", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ { "cell_type": "code", "execution_count": null, - "id": "acd1653f", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -86,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f6bbcce7", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "300c961c", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fc1acd04", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e995780b", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ }, { "cell_type": "markdown", - "id": "1de6d11f", + "id": "11", "metadata": {}, "source": [ "### Af1" @@ -150,7 +150,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a94daf7", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "markdown", - "id": "a302d86c", + "id": "13", "metadata": {}, "source": [ "## CNV HMM heatmap" @@ -171,7 +171,7 @@ }, { "cell_type": "markdown", - "id": "1e5b281f", + "id": "14", "metadata": {}, "source": [ "### Ag3" @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17a8a79d", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -193,7 +193,7 @@ { "cell_type": "code", "execution_count": null, - "id": "649a9194", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -206,7 +206,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81b8ece4", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c8d588ae", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -233,7 +233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54fc714b", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d240bb8", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ddc76e07", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -274,7 +274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cac3c68b", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ }, { "cell_type": "markdown", - "id": "c566c8ac", + "id": "23", "metadata": {}, "source": [ "### Af1" @@ -296,7 +296,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c4dcf97", + "id": "24", "metadata": {}, "outputs": [], "source": [ @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "abdffd76", + "id": "25", "metadata": {}, "outputs": [], "source": [] @@ -318,7 +318,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -331,15 +330,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_diplotype_clustering.ipynb b/notebooks/plot_diplotype_clustering.ipynb index 83a7df3ea..0f32ce3e8 100644 --- a/notebooks/plot_diplotype_clustering.ipynb +++ b/notebooks/plot_diplotype_clustering.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d3f73666", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -12,7 +12,7 @@ }, { "cell_type": "markdown", - "id": "0b889fd3", + "id": "1", "metadata": {}, "source": [ "## Ag3" @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ae9caa20-bdce-4b69-81f9-32d560caa5a2", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15d0bf3e-bbbe-4b67-a39d-c7ed5622cc3b", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -60,7 +60,7 @@ { "cell_type": "code", "execution_count": null, - "id": "92a9bdfd-d808-4c07-8bdd-f2eb3d1e5614", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -82,7 +82,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b6976257-a5be-489f-940f-9e6c717394b1", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ccb2366f", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0420334-124d-4bab-9ef7-bb9ceb99d6f0", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e957de19-af70-412a-8c75-2e6835ffb2cd", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "857145af", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f41b7e63", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -208,7 +208,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b93d6d94-1add-4ba4-8618-87a11c843e6e", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -227,7 +227,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5773cf5a-6040-4ed9-8bdd-01d7f16408a7", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52c159c8-1751-4be7-92d9-52bd17751259", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7bd7b04c-5401-4c1e-92eb-cae5b3d87851", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -284,7 +284,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f6415e6-8d0d-4446-9adb-58c5b236dbcc", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31df6632-8025-4f55-9d5d-9d04978b1690", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -322,7 +322,7 @@ }, { "cell_type": "markdown", - "id": "6016ee62", + "id": "17", "metadata": {}, "source": [ "## Af1" @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87f36d07", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -347,7 +347,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e1f68c6c", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -368,7 +368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5bc93110", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -388,7 +388,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45bdce7c", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -406,7 +406,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5979cca3", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -426,7 +426,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5318dd95-0621-47c1-a3d7-ccfe1950e73f", + "id": "23", "metadata": {}, "outputs": [], "source": [] @@ -434,7 +434,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -447,20 +446,12 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" + "pygments_lexer": "ipython3" }, "vscode": { "interpreter": { "hash": "3b9ddb1005cd06989fd869b9e3d566470f1be01faa610bb17d64e58e32302e8b" } - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } } }, "nbformat": 4, diff --git a/notebooks/plot_diversity.ipynb b/notebooks/plot_diversity.ipynb index d6d3cd17a..4215cdcdd 100644 --- a/notebooks/plot_diversity.ipynb +++ b/notebooks/plot_diversity.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a383fb19-cc62-4433-9f05-ba2709dd446b", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56ea182c-2446-45ba-921a-a0b5cc1d413e", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "75759d4b-d0f8-4489-bda2-5d7d1d9adf17", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "531a2131-c2e1-42fc-85b6-09561b67c820", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e86a9ebd-5fba-4d6e-8ffb-6338d6a59e11", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -74,7 +74,7 @@ { "cell_type": "code", "execution_count": null, - "id": "da8bcab8-897f-4f5b-9058-137fb3ee1064", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b3f385ed-d0f8-45da-9ae1-e8ef4f2360c3", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7b0b6f96-f292-446b-a231-6a82fb4fb808", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63e55e75-ff85-46e1-b20f-4edd2a02ab92", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "149cab79-3f22-4a20-8a13-63f9319d466c", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -124,7 +124,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1928463b-2461-4025-898f-dc05dc0cb214", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fa7cad0a-e9cb-4d06-bece-298642fa79b3", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "431f1274-fc55-4baa-8c67-f8f3d16d5874", + "id": "12", "metadata": {}, "outputs": [], "source": [] @@ -152,7 +152,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -165,15 +164,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_frequencies_heatmap.ipynb b/notebooks/plot_frequencies_heatmap.ipynb index daab3576e..1aa68d198 100644 --- a/notebooks/plot_frequencies_heatmap.ipynb +++ b/notebooks/plot_frequencies_heatmap.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "820bd2a0-eb8c-42e7-ba56-bef15ae7358a", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "702a2213", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "7607169c", + "id": "2", "metadata": {}, "source": [ "## SNP allele frequencies" @@ -46,7 +46,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ab3ddd98", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "204d0b93", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc92d92f-31ed-4d1b-ac22-0282692db8c1", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ea2ee8e2", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "60f9e53f", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "055a88cb", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b41a1026", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "69ee0608", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7bcfc20a", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "86ee6d8a", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -164,7 +164,7 @@ { "cell_type": "code", "execution_count": null, - "id": "65c5093e", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -174,7 +174,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "2a682de7", + "id": "14", "metadata": {}, "source": [ "## Amino acid frequencies" @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c24c45f6", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64066236", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -208,7 +208,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a83a404", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -218,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d5a68fe6", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -230,7 +230,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1fca6e11", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9d55aa57", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -256,7 +256,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63f02680", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -271,7 +271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8895338", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ { "cell_type": "code", "execution_count": null, - "id": "220945ee", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -296,7 +296,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "7a9b4bc6", + "id": "24", "metadata": {}, "source": [ "## Gene CNV frequencies" @@ -305,7 +305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8c914a1b", + "id": "25", "metadata": {}, "outputs": [], "source": [ @@ -315,7 +315,7 @@ { "cell_type": "code", "execution_count": null, - "id": "edd39fc3", + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -330,7 +330,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fa51bcc3-90fc-4879-8366-b2ad80bc833b", + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "763ed786", + "id": "28", "metadata": {}, "outputs": [], "source": [ @@ -352,7 +352,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f5099554", + "id": "29", "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f3c20291", + "id": "30", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ { "cell_type": "code", "execution_count": null, - "id": "86c5c594", + "id": "31", "metadata": {}, "outputs": [], "source": [ @@ -402,7 +402,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6d7ad130-30c2-4cd3-8906-a7ada3ccc75f", + "id": "32", "metadata": {}, "outputs": [], "source": [ @@ -416,7 +416,7 @@ { "cell_type": "code", "execution_count": null, - "id": "83aab417-632e-4fd2-8da4-3ffdd6e233f6", + "id": "33", "metadata": {}, "outputs": [], "source": [] @@ -424,7 +424,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -437,15 +436,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_frequencies_space_time.ipynb b/notebooks/plot_frequencies_space_time.ipynb index 231d86aaa..bb3977e0f 100644 --- a/notebooks/plot_frequencies_space_time.ipynb +++ b/notebooks/plot_frequencies_space_time.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47f669f3", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f820bc66-2fb2-4ca2-9b54-824e50d61a0a", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22b94b9c", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "865f02ea-0673-4d35-ad9e-33088e2d0e58", + "id": "3", "metadata": {}, "source": [ "## Gene CNV frequencies" @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1c612c69-27ee-4f50-b467-786bd998de58", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7b38fb26-9562-4f52-9381-ced0687b5a40", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "790c99e8", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1bfc7298", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fb104e66-7ba0-42ec-9ed0-625a43b69d5b", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ccf5279d-fc5a-4efe-972e-60c7b9515558", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -127,7 +127,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "8d39da45-6875-42e1-9b84-2f0a64189ff4", + "id": "10", "metadata": {}, "source": [ "## Amino acid change frequencies" @@ -136,7 +136,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf75e5b1-f2ca-41f4-a0fd-08a03c979fa4", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2c6ffd89-7edc-4f90-bd23-b03e15ce9714", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c058a196-2f78-49a0-8a18-cb2420c3278a", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e733c877-a1f1-4dc6-b8a3-a9652430ff39", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -193,7 +193,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82927720", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -203,7 +203,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5f9257e0", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "94ccc5bf", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10d0004b", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "9b189c4f-fbf6-45cf-96ef-04817084b5ec", + "id": "19", "metadata": {}, "source": [ "## SNP allele frequencies" @@ -250,7 +250,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c3738721-8d16-40dd-8a4d-4b588af36b15", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -273,7 +273,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c743429", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e16ab3fe", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26af27a1", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f6a7920", + "id": "24", "metadata": {}, "outputs": [], "source": [ @@ -322,7 +322,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03cfc0e7", + "id": "25", "metadata": {}, "outputs": [], "source": [ @@ -332,7 +332,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28922f73-f38d-424a-a9c5-1e839c86567b", + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -350,7 +350,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2a8ea4a0-6bf7-41a3-b734-06535e7dbbc8", + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -360,7 +360,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ce2800c-dfa5-49c3-bde4-3b67423f7807", + "id": "28", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b0f6bda5", + "id": "29", "metadata": {}, "outputs": [], "source": [ @@ -387,7 +387,7 @@ }, { "cell_type": "markdown", - "id": "a94d6521", + "id": "30", "metadata": {}, "source": [ "### SNP allele frequencies using `taxon_by`" @@ -396,7 +396,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0cf222ee", + "id": "31", "metadata": {}, "outputs": [], "source": [ @@ -420,7 +420,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2b7e9acc", + "id": "32", "metadata": {}, "outputs": [], "source": [ @@ -430,14 +430,14 @@ { "cell_type": "code", "execution_count": null, - "id": "2c3227e4", + "id": "33", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", - "id": "eb89088f", + "id": "34", "metadata": {}, "source": [ "### SNP allele frequencies using a custom `period_by`" @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd7856d2", + "id": "35", "metadata": {}, "outputs": [], "source": [ @@ -456,7 +456,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8a54c978", + "id": "36", "metadata": {}, "outputs": [], "source": [ @@ -467,7 +467,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a36cd399", + "id": "37", "metadata": {}, "outputs": [], "source": [ @@ -478,7 +478,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1087bada", + "id": "38", "metadata": {}, "outputs": [], "source": [ @@ -489,7 +489,7 @@ { "cell_type": "code", "execution_count": null, - "id": "018e9a59", + "id": "39", "metadata": {}, "outputs": [], "source": [ @@ -504,7 +504,7 @@ { "cell_type": "code", "execution_count": null, - "id": "454c36d9", + "id": "40", "metadata": {}, "outputs": [], "source": [ @@ -514,7 +514,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6b078bd1", + "id": "41", "metadata": {}, "outputs": [], "source": [ @@ -524,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33d392d3", + "id": "42", "metadata": {}, "outputs": [], "source": [ @@ -534,7 +534,7 @@ { "cell_type": "code", "execution_count": null, - "id": "71bf535c", + "id": "43", "metadata": {}, "outputs": [], "source": [ @@ -544,7 +544,7 @@ { "cell_type": "code", "execution_count": null, - "id": "72feb026", + "id": "44", "metadata": {}, "outputs": [], "source": [ @@ -554,7 +554,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31b9acee", + "id": "45", "metadata": {}, "outputs": [], "source": [ @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16ac5eb6", + "id": "46", "metadata": {}, "outputs": [], "source": [ @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d22d6d58", + "id": "47", "metadata": {}, "outputs": [], "source": [] @@ -587,7 +587,6 @@ ], "metadata": { "kernelspec": { - "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -600,694 +599,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": { - "07e9e6c0ec1c4d508dcea9a114ac0b0a": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "move", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "11daaa1c092d4087a034542d7be112d8": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletTileLayerModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletTileLayerModel", - "_view_name": "ErrorWidgetView", - "attribution": "© OpenStreetMap contributors", - "base": true, - "bottom": true, - "bounds": null, - "detect_retina": false, - "error": {}, - "loading": false, - "max_native_zoom": null, - "max_zoom": 19, - "min_native_zoom": null, - "min_zoom": 1, - "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", - "name": "OpenStreetMap.Mapnik", - "no_wrap": false, - "opacity": 1, - "options": [ - "attribution", - "bounds", - "detect_retina", - "max_native_zoom", - "max_zoom", - "min_native_zoom", - "min_zoom", - "no_wrap", - "tile_size", - "tms", - "zoom_offset" - ], - "pane": "", - "popup": null, - "popup_max_height": null, - "popup_max_width": 300, - "popup_min_width": 50, - "show_loading": false, - "subitems": [], - "tile_size": 256, - "tms": false, - "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", - "visible": true, - "zoom_offset": 0 - } - }, - "17ce13191ef8482596ea4952c7a52bc9": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletAttributionControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletAttributionControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "prefix" - ], - "position": "bottomright", - "prefix": "ipyleaflet" - } - }, - "23a5c26c626a4d0a80140ed91ac45b31": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "4adf518de8f14f06a6a26b1da007107c": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletZoomControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletZoomControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "zoom_in_text", - "zoom_in_title", - "zoom_out_text", - "zoom_out_title" - ], - "position": "topleft", - "zoom_in_text": "+", - "zoom_in_title": "Zoom in", - "zoom_out_text": "-", - "zoom_out_title": "Zoom out" - } - }, - "61c564b2766a467daf09f6d22add5730": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "62fb525b1c3646ca9e6b45cb3515a0f5": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "move", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "66c6ef459b264db2893c627f45bdde3a": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "move", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "7caf3c5c54274e9b9d93641bdb7a9339": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "87119c6f04ac46628c069e5742f7ce08": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapModel", - "_view_name": "ErrorWidgetView", - "bottom": 0, - "bounce_at_zoom_limits": true, - "box_zoom": true, - "center": [ - -2, - 20 - ], - "close_popup_on_click": true, - "controls": [ - "IPY_MODEL_f47067463b3a4c42b9e29e76528a5735", - "IPY_MODEL_17ce13191ef8482596ea4952c7a52bc9" - ], - "crs": { - "custom": false, - "name": "EPSG3857" - }, - "default_style": "IPY_MODEL_7caf3c5c54274e9b9d93641bdb7a9339", - "double_click_zoom": true, - "dragging": true, - "dragging_style": "IPY_MODEL_62fb525b1c3646ca9e6b45cb3515a0f5", - "east": 0, - "error": {}, - "fullscreen": false, - "inertia": true, - "inertia_deceleration": 3000, - "inertia_max_speed": 1500, - "interpolation": "bilinear", - "keyboard": true, - "keyboard_pan_offset": 80, - "keyboard_zoom_offset": 1, - "layers": [ - "IPY_MODEL_11daaa1c092d4087a034542d7be112d8" - ], - "layout": "IPY_MODEL_9cfcb8f8e7aa45b6b3b944a6aae9f28e", - "left": 9007199254740991, - "max_zoom": null, - "min_zoom": null, - "modisdate": "2022-12-22", - "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", - "north": 0, - "options": [ - "bounce_at_zoom_limits", - "box_zoom", - "center", - "close_popup_on_click", - "double_click_zoom", - "dragging", - "fullscreen", - "inertia", - "inertia_deceleration", - "inertia_max_speed", - "interpolation", - "keyboard", - "keyboard_pan_offset", - "keyboard_zoom_offset", - "max_zoom", - "min_zoom", - "prefer_canvas", - "scroll_wheel_zoom", - "tap", - "tap_tolerance", - "touch_zoom", - "world_copy_jump", - "zoom", - "zoom_animation_threshold", - "zoom_delta", - "zoom_snap" - ], - "panes": {}, - "prefer_canvas": false, - "right": 0, - "scroll_wheel_zoom": false, - "south": 0, - "style": "IPY_MODEL_cdb18012556e4a548d1696617b42e52a", - "tap": true, - "tap_tolerance": 15, - "top": 9007199254740991, - "touch_zoom": true, - "west": 0, - "window_url": "", - "world_copy_jump": false, - "zoom": 3, - "zoom_animation_threshold": 4, - "zoom_delta": 1, - "zoom_snap": 1 - } - }, - "9aeaff05b3cd4ad481b58cba4903c26a": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "aafb5325f81749efa3385c31feff90b0": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletZoomControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletZoomControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "zoom_in_text", - "zoom_in_title", - "zoom_out_text", - "zoom_out_title" - ], - "position": "topleft", - "zoom_in_text": "+", - "zoom_in_title": "Zoom in", - "zoom_out_text": "-", - "zoom_out_title": "Zoom out" - } - }, - "c25a9ad7c44e4fa194988bd6143b4a38": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletAttributionControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletAttributionControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "prefix" - ], - "position": "bottomright", - "prefix": "ipyleaflet" - } - }, - "cdb18012556e4a548d1696617b42e52a": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "cdb3d44557d74e8494dd753f4461fa4f": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapModel", - "_view_name": "ErrorWidgetView", - "bottom": 0, - "bounce_at_zoom_limits": true, - "box_zoom": true, - "center": [ - -2, - 20 - ], - "close_popup_on_click": true, - "controls": [ - "IPY_MODEL_aafb5325f81749efa3385c31feff90b0", - "IPY_MODEL_e58d799116564ba082f693bab2ca6d26" - ], - "crs": { - "custom": false, - "name": "EPSG3857" - }, - "default_style": "IPY_MODEL_d2fb36e653324e9fb8d26258bd1cd46e", - "double_click_zoom": true, - "dragging": true, - "dragging_style": "IPY_MODEL_07e9e6c0ec1c4d508dcea9a114ac0b0a", - "east": 0, - "error": {}, - "fullscreen": false, - "inertia": true, - "inertia_deceleration": 3000, - "inertia_max_speed": 1500, - "interpolation": "bilinear", - "keyboard": true, - "keyboard_pan_offset": 80, - "keyboard_zoom_offset": 1, - "layers": [ - "IPY_MODEL_f000402c088144dabd3ea1d8506af240" - ], - "layout": "IPY_MODEL_c047232214b9406590eee50bbe5401d2", - "left": 9007199254740991, - "max_zoom": null, - "min_zoom": null, - "modisdate": "2022-12-22", - "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", - "north": 0, - "options": [ - "bounce_at_zoom_limits", - "box_zoom", - "center", - "close_popup_on_click", - "double_click_zoom", - "dragging", - "fullscreen", - "inertia", - "inertia_deceleration", - "inertia_max_speed", - "interpolation", - "keyboard", - "keyboard_pan_offset", - "keyboard_zoom_offset", - "max_zoom", - "min_zoom", - "prefer_canvas", - "scroll_wheel_zoom", - "tap", - "tap_tolerance", - "touch_zoom", - "world_copy_jump", - "zoom", - "zoom_animation_threshold", - "zoom_delta", - "zoom_snap" - ], - "panes": {}, - "prefer_canvas": false, - "right": 0, - "scroll_wheel_zoom": false, - "south": 0, - "style": "IPY_MODEL_23a5c26c626a4d0a80140ed91ac45b31", - "tap": true, - "tap_tolerance": 15, - "top": 9007199254740991, - "touch_zoom": true, - "west": 0, - "window_url": "", - "world_copy_jump": false, - "zoom": 3, - "zoom_animation_threshold": 4, - "zoom_delta": 1, - "zoom_snap": 1 - } - }, - "d2fb36e653324e9fb8d26258bd1cd46e": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapStyleModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapStyleModel", - "_view_name": "ErrorWidgetView", - "cursor": "grab", - "error": {}, - "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" - } - }, - "e58d799116564ba082f693bab2ca6d26": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletAttributionControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletAttributionControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "prefix" - ], - "position": "bottomright", - "prefix": "ipyleaflet" - } - }, - "e59db8352cbb4a5c9d9ecaed8611159e": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletMapModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletMapModel", - "_view_name": "ErrorWidgetView", - "bottom": 0, - "bounce_at_zoom_limits": true, - "box_zoom": true, - "center": [ - -2, - 20 - ], - "close_popup_on_click": true, - "controls": [ - "IPY_MODEL_4adf518de8f14f06a6a26b1da007107c", - "IPY_MODEL_c25a9ad7c44e4fa194988bd6143b4a38" - ], - "crs": { - "custom": false, - "name": "EPSG3857" - }, - "default_style": "IPY_MODEL_9aeaff05b3cd4ad481b58cba4903c26a", - "double_click_zoom": true, - "dragging": true, - "dragging_style": "IPY_MODEL_66c6ef459b264db2893c627f45bdde3a", - "east": 0, - "error": {}, - "fullscreen": false, - "inertia": true, - "inertia_deceleration": 3000, - "inertia_max_speed": 1500, - "interpolation": "bilinear", - "keyboard": true, - "keyboard_pan_offset": 80, - "keyboard_zoom_offset": 1, - "layers": [ - "IPY_MODEL_f72eb35d576b4a51ab743a0427bdab68" - ], - "layout": "IPY_MODEL_a44bea80c0824335ba071b309104e454", - "left": 9007199254740991, - "max_zoom": null, - "min_zoom": null, - "modisdate": "2022-12-22", - "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", - "north": 0, - "options": [ - "bounce_at_zoom_limits", - "box_zoom", - "center", - "close_popup_on_click", - "double_click_zoom", - "dragging", - "fullscreen", - "inertia", - "inertia_deceleration", - "inertia_max_speed", - "interpolation", - "keyboard", - "keyboard_pan_offset", - "keyboard_zoom_offset", - "max_zoom", - "min_zoom", - "prefer_canvas", - "scroll_wheel_zoom", - "tap", - "tap_tolerance", - "touch_zoom", - "world_copy_jump", - "zoom", - "zoom_animation_threshold", - "zoom_delta", - "zoom_snap" - ], - "panes": {}, - "prefer_canvas": false, - "right": 0, - "scroll_wheel_zoom": false, - "south": 0, - "style": "IPY_MODEL_61c564b2766a467daf09f6d22add5730", - "tap": true, - "tap_tolerance": 15, - "top": 9007199254740991, - "touch_zoom": true, - "west": 0, - "window_url": "", - "world_copy_jump": false, - "zoom": 3, - "zoom_animation_threshold": 4, - "zoom_delta": 1, - "zoom_snap": 1 - } - }, - "f000402c088144dabd3ea1d8506af240": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletTileLayerModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletTileLayerModel", - "_view_name": "ErrorWidgetView", - "attribution": "© OpenStreetMap contributors", - "base": true, - "bottom": true, - "bounds": null, - "detect_retina": false, - "error": {}, - "loading": false, - "max_native_zoom": null, - "max_zoom": 19, - "min_native_zoom": null, - "min_zoom": 1, - "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", - "name": "OpenStreetMap.Mapnik", - "no_wrap": false, - "opacity": 1, - "options": [ - "attribution", - "bounds", - "detect_retina", - "max_native_zoom", - "max_zoom", - "min_native_zoom", - "min_zoom", - "no_wrap", - "tile_size", - "tms", - "zoom_offset" - ], - "pane": "", - "popup": null, - "popup_max_height": null, - "popup_max_width": 300, - "popup_min_width": 50, - "show_loading": false, - "subitems": [], - "tile_size": 256, - "tms": false, - "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", - "visible": true, - "zoom_offset": 0 - } - }, - "f47067463b3a4c42b9e29e76528a5735": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletZoomControlModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletZoomControlModel", - "_view_name": "ErrorWidgetView", - "error": {}, - "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", - "options": [ - "position", - "zoom_in_text", - "zoom_in_title", - "zoom_out_text", - "zoom_out_title" - ], - "position": "topleft", - "zoom_in_text": "+", - "zoom_in_title": "Zoom in", - "zoom_out_text": "-", - "zoom_out_title": "Zoom out" - } - }, - "f72eb35d576b4a51ab743a0427bdab68": { - "model_module": "jupyter-leaflet", - "model_module_version": "2.0.0", - "model_name": "LeafletTileLayerModel", - "state": { - "_model_module": "jupyter-leaflet", - "_model_name": "LeafletTileLayerModel", - "_view_name": "ErrorWidgetView", - "attribution": "© OpenStreetMap contributors", - "base": true, - "bottom": true, - "bounds": null, - "detect_retina": false, - "error": {}, - "loading": false, - "max_native_zoom": null, - "max_zoom": 19, - "min_native_zoom": null, - "min_zoom": 1, - "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", - "name": "OpenStreetMap.Mapnik", - "no_wrap": false, - "opacity": 1, - "options": [ - "attribution", - "bounds", - "detect_retina", - "max_native_zoom", - "max_zoom", - "min_native_zoom", - "min_zoom", - "no_wrap", - "tile_size", - "tms", - "zoom_offset" - ], - "pane": "", - "popup": null, - "popup_max_height": null, - "popup_max_width": 300, - "popup_min_width": 50, - "show_loading": false, - "subitems": [], - "tile_size": 256, - "tms": false, - "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", - "visible": true, - "zoom_offset": 0 - } - } - }, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_fst_gwss.ipynb b/notebooks/plot_fst_gwss.ipynb index a627356d6..4b89cca28 100644 --- a/notebooks/plot_fst_gwss.ipynb +++ b/notebooks/plot_fst_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a31720f1", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ece45863", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "30c285b1-533c-409c-ad40-86ffed0a9e41", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "effd3060", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e747d9a", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b63d02fe", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f77bbae1", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -123,7 +123,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1b87b2f2", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e3fc1c8", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9875e22f", + "id": "9", "metadata": {}, "outputs": [], "source": [] @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": null, - "id": "950fe2b8", + "id": "10", "metadata": {}, "outputs": [], "source": [] @@ -173,7 +173,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -186,15 +185,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_g123_gwss.ipynb b/notebooks/plot_g123_gwss.ipynb index f2f31a42f..79fd65732 100644 --- a/notebooks/plot_g123_gwss.ipynb +++ b/notebooks/plot_g123_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a31720f1", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ece45863", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ada4f50-bfc0-4524-96de-8903896c7c68", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "44ff6b91-cc69-4683-b408-45f199816d9a", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "db33f6d9", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -79,7 +79,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a585cbba-ea63-4fd9-97ca-d97a3a4f163a", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "effd3060", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "efe89451-f05b-4e55-83ef-0f85204f4b04", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e747d9a", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b63d02fe", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -175,7 +175,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e6d69754-951c-48be-9eaf-c3ff2ead80b4", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -194,7 +194,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f4c9c960-0f72-497d-9938-4dc9516498c8", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd3c2a2d", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -216,7 +216,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1b87b2f2", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -234,7 +234,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e3fc1c8", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6ef172dc-e697-4a6c-b63d-d8841aca3b97", + "id": "15", "metadata": {}, "outputs": [], "source": [] @@ -260,7 +260,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -273,15 +272,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_genes.ipynb b/notebooks/plot_genes.ipynb index 8e7e9ff02..d72d7e8a2 100644 --- a/notebooks/plot_genes.ipynb +++ b/notebooks/plot_genes.ipynb @@ -3,15 +3,8 @@ { "cell_type": "code", "execution_count": null, - "id": "381912bf", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:27.950846Z", - "iopub.status.busy": "2022-03-09T18:09:27.950618Z", - "iopub.status.idle": "2022-03-09T18:09:29.094180Z", - "shell.execute_reply": "2022-03-09T18:09:29.093711Z" - } - }, + "id": "0", + "metadata": {}, "outputs": [], "source": [ "import malariagen_data\n", @@ -22,15 +15,8 @@ { "cell_type": "code", "execution_count": null, - "id": "d1f1824b", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:29.096307Z", - "iopub.status.busy": "2022-03-09T18:09:29.096169Z", - "iopub.status.idle": "2022-03-09T18:09:29.271174Z", - "shell.execute_reply": "2022-03-09T18:09:29.270693Z" - } - }, + "id": "1", + "metadata": {}, "outputs": [], "source": [ "ag3 = malariagen_data.Ag3(\n", @@ -43,15 +29,8 @@ { "cell_type": "code", "execution_count": null, - "id": "f54b8381", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:29.273487Z", - "iopub.status.busy": "2022-03-09T18:09:29.273298Z", - "iopub.status.idle": "2022-03-09T18:09:31.492555Z", - "shell.execute_reply": "2022-03-09T18:09:31.492104Z" - } - }, + "id": "2", + "metadata": {}, "outputs": [], "source": [ "ag3.plot_genes(\"2R\")" @@ -60,15 +39,8 @@ { "cell_type": "code", "execution_count": null, - "id": "6c6865ac", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:31.499205Z", - "iopub.status.busy": "2022-03-09T18:09:31.499024Z", - "iopub.status.idle": "2022-03-09T18:09:31.551337Z", - "shell.execute_reply": "2022-03-09T18:09:31.550930Z" - } - }, + "id": "3", + "metadata": {}, "outputs": [], "source": [ "ag3.plot_genes(\"2R:28,000,000-29,000,000\")" @@ -77,15 +49,8 @@ { "cell_type": "code", "execution_count": null, - "id": "40b63386", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:31.553318Z", - "iopub.status.busy": "2022-03-09T18:09:31.553187Z", - "iopub.status.idle": "2022-03-09T18:09:31.702387Z", - "shell.execute_reply": "2022-03-09T18:09:31.701939Z" - } - }, + "id": "4", + "metadata": {}, "outputs": [], "source": [ "fig = bklay.column(\n", @@ -101,7 +66,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4df200c7", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -111,15 +76,8 @@ { "cell_type": "code", "execution_count": null, - "id": "066fb262", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:31.712754Z", - "iopub.status.busy": "2022-03-09T18:09:31.712597Z", - "iopub.status.idle": "2022-03-09T18:09:33.866554Z", - "shell.execute_reply": "2022-03-09T18:09:33.865947Z" - } - }, + "id": "6", + "metadata": {}, "outputs": [], "source": [ "ag3.plot_transcript(\"AGAP004707-RD\")" @@ -128,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8694654d", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -138,15 +96,8 @@ { "cell_type": "code", "execution_count": null, - "id": "ce93e47e", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:33.868626Z", - "iopub.status.busy": "2022-03-09T18:09:33.868483Z", - "iopub.status.idle": "2022-03-09T18:09:34.121104Z", - "shell.execute_reply": "2022-03-09T18:09:34.120683Z" - } - }, + "id": "8", + "metadata": {}, "outputs": [], "source": [ "ag3.plot_transcript(\"AGAP004050-RA\")" @@ -155,15 +106,8 @@ { "cell_type": "code", "execution_count": null, - "id": "86178607", - "metadata": { - "execution": { - "iopub.execute_input": "2022-03-09T18:09:34.123309Z", - "iopub.status.busy": "2022-03-09T18:09:34.123167Z", - "iopub.status.idle": "2022-03-09T18:09:35.690698Z", - "shell.execute_reply": "2022-03-09T18:09:35.690292Z" - } - }, + "id": "9", + "metadata": {}, "outputs": [], "source": [ "fig1 = ag3.plot_transcript(f\"AGAP004707-RA\", show=False)\n", @@ -184,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be70a93a", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -198,7 +142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48814614", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -208,7 +152,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c3399fa", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -218,7 +162,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0ed22cf1", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -228,7 +172,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0589ed21", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -238,7 +182,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c27741d9", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -258,7 +202,7 @@ { "cell_type": "code", "execution_count": null, - "id": "523197c3", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -294,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e2a3a927", + "id": "17", "metadata": {}, "outputs": [], "source": [] @@ -302,7 +246,6 @@ ], "metadata": { "kernelspec": { - "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -315,15 +258,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_h12_h1x.ipynb b/notebooks/plot_h12_h1x.ipynb index 2f751b5c8..f253a5b40 100644 --- a/notebooks/plot_h12_h1x.ipynb +++ b/notebooks/plot_h12_h1x.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ced974cd", + "id": "0", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9d17216f", + "id": "1", "metadata": { "tags": [] }, @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "a67ec21b", + "id": "2", "metadata": {}, "source": [ "## Ag3" @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "65b7ff2f", + "id": "3", "metadata": { "tags": [] }, @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ac276861-43fb-4f09-b004-57487d75aa41", + "id": "4", "metadata": { "tags": [] }, @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7c10446", + "id": "5", "metadata": { "tags": [] }, @@ -82,7 +82,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b0d308fe-4e8a-412f-9487-7f1c29d3323a", + "id": "6", "metadata": { "tags": [] }, @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63cb17ff", + "id": "7", "metadata": { "tags": [] }, @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4470d24c-8cf1-4d22-b774-0121b4560e27", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd125828", + "id": "9", "metadata": { "tags": [] }, @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5716e777", + "id": "10", "metadata": { "tags": [] }, @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fe11bb35", + "id": "11", "metadata": { "tags": [] }, @@ -194,7 +194,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b4b7a8d2-95d0-48dc-a32f-3bc96aacfb9f", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73e0e746-add1-4774-bced-461c9742bd95", + "id": "13", "metadata": { "tags": [] }, @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67f48075-6b79-4722-82f7-278bd0868410", + "id": "14", "metadata": { "tags": [] }, @@ -244,7 +244,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c3e4622b-31e9-444a-8a09-1590862709fe", + "id": "15", "metadata": { "tags": [] }, @@ -262,7 +262,7 @@ }, { "cell_type": "markdown", - "id": "2801861c", + "id": "16", "metadata": {}, "source": [ "## Af1" @@ -271,7 +271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9144452f", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5d835e1", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1aaa0573-723c-43b1-baea-750172c4dabc", + "id": "19", "metadata": {}, "outputs": [], "source": [] @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ffc7dc06-6bdb-42d2-a1fb-878612d10dd1", + "id": "20", "metadata": {}, "outputs": [], "source": [] @@ -317,7 +317,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89b1cd80", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -333,7 +333,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82cefa93", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -349,7 +349,7 @@ { "cell_type": "code", "execution_count": null, - "id": "981ba052-1960-4f2e-ba91-72ac442ca178", + "id": "23", "metadata": { "tags": [] }, @@ -368,7 +368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e3296b4c-cd72-436f-b21a-d210c7520c39", + "id": "24", "metadata": { "tags": [] }, @@ -386,7 +386,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1a60cc83-cf30-4152-9eb0-dae7c00ac41b", + "id": "25", "metadata": { "tags": [] }, @@ -404,7 +404,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a3b1c22e", + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -427,7 +427,6 @@ "uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m125" }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -440,20 +439,12 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" + "pygments_lexer": "ipython3" }, "vscode": { "interpreter": { "hash": "3b9ddb1005cd06989fd869b9e3d566470f1be01faa610bb17d64e58e32302e8b" } - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } } }, "nbformat": 4, diff --git a/notebooks/plot_haplotype_clustering.ipynb b/notebooks/plot_haplotype_clustering.ipynb index f035681b9..8c1e37492 100644 --- a/notebooks/plot_haplotype_clustering.ipynb +++ b/notebooks/plot_haplotype_clustering.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d3f73666", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "0b889fd3", + "id": "1", "metadata": {}, "source": [ "## Ag3" @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38abbb28", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "60bd6d1f-e8bd-499e-8c78-e64d2d7e9210", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "04e74ac9-51db-4bae-875c-1ee50e02d024", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -81,7 +81,7 @@ { "cell_type": "code", "execution_count": null, - "id": "637ae668-c3b8-4914-a0c2-1587cc252c0c", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9bca4ab4-89b4-4238-9f82-d7920e107583", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ccb2366f", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -132,7 +132,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0420334-124d-4bab-9ef7-bb9ceb99d6f0", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e957de19-af70-412a-8c75-2e6835ffb2cd", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -176,7 +176,7 @@ { "cell_type": "code", "execution_count": null, - "id": "857145af", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -197,7 +197,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f41b7e63", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -216,7 +216,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b93d6d94-1add-4ba4-8618-87a11c843e6e", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -235,7 +235,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5773cf5a-6040-4ed9-8bdd-01d7f16408a7", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -255,7 +255,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52c159c8-1751-4be7-92d9-52bd17751259", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -272,7 +272,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7bd7b04c-5401-4c1e-92eb-cae5b3d87851", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -291,7 +291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f6415e6-8d0d-4446-9adb-58c5b236dbcc", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31df6632-8025-4f55-9d5d-9d04978b1690", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51846e18", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -354,7 +354,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "6016ee62", + "id": "19", "metadata": {}, "source": [ "## Af1" @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "87f36d07", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -379,7 +379,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e1f68c6c", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -399,7 +399,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5bc93110", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -419,7 +419,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45bdce7c", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -437,7 +437,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5979cca3", + "id": "24", "metadata": {}, "outputs": [], "source": [] @@ -445,7 +445,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -458,15 +457,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.8" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_haplotype_networks.ipynb b/notebooks/plot_haplotype_networks.ipynb index 0ecc0d121..7088b6725 100644 --- a/notebooks/plot_haplotype_networks.ipynb +++ b/notebooks/plot_haplotype_networks.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "f6b86889", + "id": "0", "metadata": {}, "source": [ "# Haplotype Network Plotting Examples\n", @@ -12,7 +12,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1cadfacf", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -22,7 +22,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "dcfe9fab", + "id": "2", "metadata": {}, "source": [ "## Ag3" @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0ebfe96b", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -47,7 +47,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "e3ffe116", + "id": "4", "metadata": {}, "source": [ "N.B., manually specifying the server_port parameter doesn't seem to be necessary on colab, but is needed when running locally via Jupyter notebook, otherwise get \"Address already in use\" error and cannot run multiple plots in same notebook." @@ -55,7 +55,7 @@ }, { "cell_type": "markdown", - "id": "e5687f24", + "id": "5", "metadata": {}, "source": [ "## Example 1: Direct Column Name (String)\n", @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81ceebb1-2316-4a0f-bf85-55cc561ab00c", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -82,7 +82,7 @@ }, { "cell_type": "markdown", - "id": "2798b459", + "id": "7", "metadata": {}, "source": [ "## Example 2: Cohorts Prefix (String)\n", @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3206fc04-1074-4f6c-8130-81dadff05c72", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ }, { "cell_type": "markdown", - "id": "44c6a40b", + "id": "9", "metadata": {}, "source": [ "This example uses a dictionary to define custom color groups based on conditions applied to the `\"country\"` column." @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8236cd99", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ }, { "cell_type": "markdown", - "id": "bd1962ba", + "id": "11", "metadata": {}, "source": [ "Setting `color=None` applies the default coloring scheme, typically uniform across all nodes." @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eab4c6fb", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "20b54aa0", + "id": "13", "metadata": {}, "source": [ "This replicates Example 1 but uses `server_mode=\"external\"`, useful for rendering plots in certain environments." @@ -168,7 +168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "698ab518", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "bc416bb4", + "id": "15", "metadata": {}, "source": [ "## Af1" @@ -195,7 +195,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5e601014", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "d8aeab21", + "id": "17", "metadata": {}, "source": [ "Here, nodes are colored based on the `\"sample_set\"` column." @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6b6f149e", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -236,7 +236,7 @@ }, { "cell_type": "markdown", - "id": "b1cde074", + "id": "19", "metadata": {}, "source": [ "Using `\"year\"` implies the function looks for `\"cohorts_year\"` in the metadata." @@ -245,7 +245,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6d7fc155", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "e6e60160", + "id": "21", "metadata": {}, "source": [ "A dictionary defines custom groups based on the `\"year\"` column (assuming year data is available)." @@ -269,7 +269,7 @@ { "cell_type": "code", "execution_count": null, - "id": "882e6b8f", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -285,7 +285,7 @@ }, { "cell_type": "markdown", - "id": "485becad", + "id": "23", "metadata": {}, "source": [ "With `color=None`, the default coloring is applied." @@ -294,7 +294,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd013c5c", + "id": "24", "metadata": {}, "outputs": [], "source": [ @@ -310,7 +310,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -323,15 +322,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.0" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_haplotypes_frequencies.ipynb b/notebooks/plot_haplotypes_frequencies.ipynb index 9ad777363..d88f3c20b 100644 --- a/notebooks/plot_haplotypes_frequencies.ipynb +++ b/notebooks/plot_haplotypes_frequencies.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "74a45bfa-2af5-4a9d-9285-84f34a82d986", + "id": "0", "metadata": {}, "source": [ "# Ag3" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a46f23bf-2635-4249-b115-aa8cfd35d33f", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8130522f-98de-463f-83fd-a1c1c460e00e", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2cefad62-e558-4797-9d1a-4b501ad364b0", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6bac8aca-8835-43b7-84c0-f6eb62594d91", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2770b59a-6b6d-4458-99cf-cdf08e47ddac", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "a771fda2-ae68-46bc-b38e-2f4ba6b41b71", + "id": "6", "metadata": {}, "source": [ "# Af1" @@ -86,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "415cc454-ffdd-4bff-8881-95180bcf66f6", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d8fb2b5-5b49-4856-8e1c-895174e32f04", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ef2cb769-4a8d-49fe-8e28-c9dc1af0159d", + "id": "9", "metadata": {}, "outputs": [], "source": [] @@ -125,7 +125,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -138,8 +137,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.11" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_heterozygosity.ipynb b/notebooks/plot_heterozygosity.ipynb index 136836b47..89a75efd8 100644 --- a/notebooks/plot_heterozygosity.ipynb +++ b/notebooks/plot_heterozygosity.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29e2e4a7", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -19,7 +19,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a751077f", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4b2bb835", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ac466ddf", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "522b2a30", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10aff683", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c66bd85", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8fc0887", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e564c19b", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0202112", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3ebba22a", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ { "cell_type": "code", "execution_count": null, - "id": "df452208", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ { "cell_type": "code", "execution_count": null, - "id": "af3bf25f", + "id": "12", "metadata": {}, "outputs": [], "source": [] @@ -179,7 +179,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -192,15 +191,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_ihs_gwss.ipynb b/notebooks/plot_ihs_gwss.ipynb index 4a8fa53c7..3fd872e69 100644 --- a/notebooks/plot_ihs_gwss.ipynb +++ b/notebooks/plot_ihs_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a31720f1", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ece45863", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ { "cell_type": "code", "execution_count": null, - "id": "effd3060", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e747d9a", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b63d02fe", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f77bbae1", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -112,7 +112,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cd3c2a2d", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -122,7 +122,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1b87b2f2", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e3fc1c8", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "110b81e5", + "id": "9", "metadata": {}, "outputs": [], "source": [] @@ -162,7 +162,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -175,15 +174,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_njt.ipynb b/notebooks/plot_njt.ipynb index 7ece0d852..94e210973 100644 --- a/notebooks/plot_njt.ipynb +++ b/notebooks/plot_njt.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3139f0e8-e82f-4d3d-a031-bc9c2d92edd8", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3112b35f-d951-441e-a850-59615aa1f9ec", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1e83d8ad-e20e-449b-8601-150540e6dd82", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2964c092-65de-4d2a-9dd9-970418b13bd8", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5f86a798-51c8-4c79-ac60-e7520ab9a503", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "392e6c4c-512f-4a80-bbe9-932280a4efdb", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4437435f-d3b3-4ad6-9e62-6e5f6f01edea", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "664a9d48-001e-40ed-8901-08bccb2184ba", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -119,7 +119,7 @@ { "cell_type": "code", "execution_count": null, - "id": "76405cc3-6cdd-4067-a2cb-71095d2c28b3", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -137,7 +137,7 @@ { "cell_type": "code", "execution_count": null, - "id": "972f4787-7c2b-47e2-859c-cd1cc800d92e", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95d20897-6100-4b11-a3e6-38155feb98c2", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -168,7 +168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5bf936d6-5dc0-409c-828d-7af326102d41", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8ea0532c-58f4-4bdf-bd56-0bdfb245e060", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2335937a-eec7-4d9e-b4ca-b737ff481cd6", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -220,7 +220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68fb01ae-2567-4c13-b0a3-5890b38165d5", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -236,7 +236,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2f1139fe-9c06-420f-855f-e3900186768a", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3f8f8976-0080-4f44-b665-1534980f0da1", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -269,7 +269,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18fde26a-339a-44a1-a91f-425f22ed96d1", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ { "cell_type": "code", "execution_count": null, - "id": "72155de8-c657-4530-af38-82e0248b85a8", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "69aec527-1351-44ba-b394-681fd3d424dd", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -316,7 +316,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38a2817d-933e-46f8-af0a-fedeb7370a38", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -333,7 +333,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9c1dc76a-1fea-49ee-9341-a7542b2a74f0", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -346,7 +346,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bc7b2566-ac5d-4ca0-bc91-0208fe9d2cb0", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f5cd515-4933-4f08-82cc-c0fa57e77fb3", + "id": "23", "metadata": {}, "outputs": [], "source": [] @@ -371,7 +371,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -384,15 +383,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_pairwise_average_fst.ipynb b/notebooks/plot_pairwise_average_fst.ipynb index 0b41014a6..b519e3776 100644 --- a/notebooks/plot_pairwise_average_fst.ipynb +++ b/notebooks/plot_pairwise_average_fst.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d0f3796b-cc12-4370-bdb2-ad4f4bd50a3e", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -17,7 +17,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0e719256-3561-4362-a169-c38c9fe96972", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6af54463-584b-443b-9538-cd141578fde4", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "be539d92-3bd5-40b5-b67f-7ae6569db62f", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a7c0815f-7ca9-4ed0-9982-16409f2bc675", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53a6b0e2-959d-4af1-92ed-bdb748be51c1", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -91,7 +91,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35959f42-732e-40fa-86ad-16d95fb6e740", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -101,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35d304bd-3f39-4dc7-9f7d-905068d5cd0d", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ec418b8f-1451-415e-96e5-bcc5e98428bb", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -121,7 +121,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c16035d2-b5d3-4441-87d9-eda953079161", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13afd6ed-7962-4935-b1f1-ed12f5e2ceed", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48a52211-2ef9-47da-b715-d0d74a69a4ad", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -162,7 +162,7 @@ { "cell_type": "code", "execution_count": null, - "id": "09cc1824-e6f4-4799-a8f4-cf61e472eaf8", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +172,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95f112d2-fe76-4091-b73b-d7a17a61cc18", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -182,7 +182,7 @@ { "cell_type": "code", "execution_count": null, - "id": "908b08c8-290f-49d1-b3d3-cb8f9e7d2d21", + "id": "14", "metadata": {}, "outputs": [], "source": [ @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": null, - "id": "818fdac7-dcb4-4da2-8a52-f16ce51a2c0d", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -215,7 +215,7 @@ { "cell_type": "code", "execution_count": null, - "id": "65c1bdd5-f1d2-4814-93e5-ddb1d9c42258", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5ec8cfe3-336c-4362-9361-78d40ffa0a8e", + "id": "17", "metadata": {}, "outputs": [], "source": [] @@ -233,7 +233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2d3236a2-842d-4c13-92ec-9a4338750aca", + "id": "18", "metadata": {}, "outputs": [], "source": [] @@ -241,7 +241,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -254,8 +253,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_pca.ipynb b/notebooks/plot_pca.ipynb index 74421ccc3..a32a6000a 100644 --- a/notebooks/plot_pca.ipynb +++ b/notebooks/plot_pca.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "7d93e741-bddf-4a29-aea2-7bc6be697cb7", + "id": "0", "metadata": {}, "source": [ "# PCA plotting" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "2f274c61-c660-47b0-92b9-83ab701eb9eb", + "id": "1", "metadata": {}, "source": [ "### Setup" @@ -19,7 +19,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36039d6f", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d8bf7a3a", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bfd56044", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -59,7 +59,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4e5e1c70", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ }, { "cell_type": "markdown", - "id": "b3760474-2ab2-4291-b5ee-48feccd091f4", + "id": "6", "metadata": {}, "source": [ "## Mayotte" @@ -77,7 +77,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e5743579", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ede14f05-a45d-4e12-9e02-3f4980d867cd", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5578c99a-37b1-4011-b34f-267aad0b2763", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a027022f-f700-49c1-8f2d-a43100956155", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -127,7 +127,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b73b8a6f", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c0b018e3", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -151,7 +151,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32e505db", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "markdown", - "id": "467dbd69-8ba2-41a2-8d01-d9fa78d42326", + "id": "14", "metadata": {}, "source": [ "## Burkina Faso" @@ -172,7 +172,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6a2ce979-1553-4459-b3c1-f3dea40bc1a1", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4cb47917-0d8c-47c8-a68d-34d193e2f61a", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "241cae4e-3305-4c2a-845f-8871a1a114d4", + "id": "17", "metadata": {}, "outputs": [], "source": [ @@ -214,7 +214,7 @@ }, { "cell_type": "markdown", - "id": "a2b46eb9-832d-417c-a082-9fc365b0fc62", + "id": "18", "metadata": {}, "source": [ "## Ag3.0" @@ -223,7 +223,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8ac26ed8", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -238,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6e02f847", + "id": "20", "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4b957863", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -263,7 +263,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17baa8d0", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -277,7 +277,7 @@ { "cell_type": "code", "execution_count": null, - "id": "114fb016", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "92795fa4", + "id": "24", "metadata": {}, "outputs": [], "source": [ @@ -307,7 +307,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e0c10b0d-3244-4862-acb7-cf60b9a6a9f2", + "id": "25", "metadata": {}, "outputs": [], "source": [ @@ -324,7 +324,7 @@ { "cell_type": "code", "execution_count": null, - "id": "727402e7-43a1-4c7d-b21e-a051cd881f01", + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -337,7 +337,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cccf1386-c578-4af3-97ec-dc7704840102", + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -351,7 +351,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1b1a399a-762d-42db-9e40-776575d9ef5a", + "id": "28", "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ }, { "cell_type": "markdown", - "id": "14d04103-2f6f-4f53-8d35-f286de5980d2", + "id": "29", "metadata": {}, "source": [ "## Af1.0" @@ -373,7 +373,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6c3fc8d5", + "id": "30", "metadata": {}, "outputs": [], "source": [ @@ -388,7 +388,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fbe1f54f", + "id": "31", "metadata": {}, "outputs": [], "source": [ @@ -398,7 +398,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c055c99", + "id": "32", "metadata": {}, "outputs": [], "source": [ @@ -411,7 +411,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ea74cb43", + "id": "33", "metadata": {}, "outputs": [], "source": [ @@ -425,7 +425,7 @@ }, { "cell_type": "markdown", - "id": "fdfbcd5a-5ef4-4cbc-b430-c0b541925142", + "id": "34", "metadata": {}, "source": [ "## Excluding samples" @@ -434,7 +434,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6c3251e2-a95c-4d4a-bff1-8e632be0eaf5", + "id": "35", "metadata": {}, "outputs": [], "source": [ @@ -449,7 +449,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1f0b88a7-d9f6-44a8-9778-4cbaad397765", + "id": "36", "metadata": {}, "outputs": [], "source": [ @@ -459,7 +459,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4e370936-925a-4e97-86cb-b22f72b39e64", + "id": "37", "metadata": {}, "outputs": [], "source": [ @@ -469,7 +469,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ea24435-d752-4269-a391-b057e1650d44", + "id": "38", "metadata": {}, "outputs": [], "source": [ @@ -482,7 +482,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0f114dd9-965d-4579-8cce-76f45fde6a37", + "id": "39", "metadata": {}, "outputs": [], "source": [ @@ -500,7 +500,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5392844-a828-48f3-8222-bfc1817c3493", + "id": "40", "metadata": {}, "outputs": [], "source": [ @@ -510,7 +510,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6d87eeb5-8dc6-4a31-a8a3-e936d4d05215", + "id": "41", "metadata": {}, "outputs": [], "source": [ @@ -520,7 +520,7 @@ { "cell_type": "code", "execution_count": null, - "id": "770b01ee-642e-4903-93fa-eef084924234", + "id": "42", "metadata": {}, "outputs": [], "source": [ @@ -530,7 +530,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9438fd91-b463-4d28-8279-5eaa728a8f2e", + "id": "43", "metadata": {}, "outputs": [], "source": [ @@ -542,7 +542,7 @@ }, { "cell_type": "markdown", - "id": "58e7b2c1-b4c1-4c93-823c-8531693636e4", + "id": "44", "metadata": {}, "source": [ "## Excluding samples during fit" @@ -551,7 +551,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1014a17c-12bb-46c3-9a7b-f2449d205ce3", + "id": "45", "metadata": {}, "outputs": [], "source": [ @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e48d46dd-5c7f-4573-a5f5-c15a389d2e1e", + "id": "46", "metadata": {}, "outputs": [], "source": [ @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1fb5192e-f63f-443d-91a9-e82b2de14c69", + "id": "47", "metadata": {}, "outputs": [], "source": [ @@ -589,7 +589,7 @@ { "cell_type": "code", "execution_count": null, - "id": "873c53f5-8690-4690-85f0-8ce1845e2862", + "id": "48", "metadata": {}, "outputs": [], "source": [ @@ -599,7 +599,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0bb86ba2-e428-4ae0-9e0c-703345c89324", + "id": "49", "metadata": {}, "outputs": [], "source": [ @@ -612,7 +612,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7b28c4c8-9382-4889-8651-77ef0be929f6", + "id": "50", "metadata": {}, "outputs": [], "source": [ @@ -624,7 +624,7 @@ }, { "cell_type": "markdown", - "id": "f1e8c954", + "id": "51", "metadata": {}, "source": [ "## PCA with cohort downsampling" @@ -633,7 +633,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e4a484f3", + "id": "52", "metadata": {}, "outputs": [], "source": [ @@ -653,7 +653,7 @@ { "cell_type": "code", "execution_count": null, - "id": "abb2ee83", + "id": "53", "metadata": {}, "outputs": [], "source": [] @@ -661,7 +661,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -674,15 +673,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_samples.ipynb b/notebooks/plot_samples.ipynb index 2f7f31c8a..ec7be4fe3 100644 --- a/notebooks/plot_samples.ipynb +++ b/notebooks/plot_samples.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -256,7 +256,6 @@ ], "metadata": { "kernelspec": { - "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -269,15 +268,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_snps.ipynb b/notebooks/plot_snps.ipynb index 5daa69c4e..502545139 100644 --- a/notebooks/plot_snps.ipynb +++ b/notebooks/plot_snps.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14640993", + "id": "0", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5d740cac", + "id": "1", "metadata": { "tags": [] }, @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd576b75", + "id": "2", "metadata": { "tags": [] }, @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7de3ba82", + "id": "3", "metadata": { "tags": [] }, @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3a3de267-affa-46e6-92b9-d07553cad816", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2c66985f-592b-4fb5-a560-5cdedb472bee", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82096dc0", + "id": "6", "metadata": { "tags": [] }, @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10c340aa", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -98,7 +98,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e8e463dd", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7fb757a7", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0e3a8961", + "id": "10", "metadata": { "tags": [] }, @@ -132,7 +132,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63aca10c", + "id": "11", "metadata": { "tags": [] }, @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6fb5216e", + "id": "12", "metadata": { "tags": [] }, @@ -158,7 +158,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0d88ceb5", + "id": "13", "metadata": { "tags": [] }, @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c98cabe", + "id": "14", "metadata": { "tags": [] }, @@ -186,7 +186,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8a7c297d", + "id": "15", "metadata": { "tags": [] }, @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d0552711", + "id": "16", "metadata": { "tags": [] }, @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d269e02e", + "id": "17", "metadata": { "tags": [] }, @@ -224,7 +224,7 @@ { "cell_type": "code", "execution_count": null, - "id": "872c56ab", + "id": "18", "metadata": { "tags": [] }, @@ -238,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c24a21ab", + "id": "19", "metadata": { "tags": [] }, @@ -254,7 +254,7 @@ { "cell_type": "code", "execution_count": null, - "id": "60280e52", + "id": "20", "metadata": {}, "outputs": [], "source": [] @@ -262,7 +262,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -275,15 +274,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/plot_xpehh_gwss.ipynb b/notebooks/plot_xpehh_gwss.ipynb index cd9e67583..ba03632a5 100644 --- a/notebooks/plot_xpehh_gwss.ipynb +++ b/notebooks/plot_xpehh_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32067e1d", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "966049ec", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "838eddc4", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -54,7 +54,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e780aa23", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -75,7 +75,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b26a9654", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -93,7 +93,7 @@ { "cell_type": "code", "execution_count": null, - "id": "181227f6", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89cf50ac", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78b452f5", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "079a3308", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d6290896", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5aed96d", + "id": "10", "metadata": {}, "outputs": [], "source": [] @@ -182,7 +182,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -195,15 +194,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/profiling/gh498.ipynb b/notebooks/profiling/gh498.ipynb index 06012f43e..21818ea9b 100644 --- a/notebooks/profiling/gh498.ipynb +++ b/notebooks/profiling/gh498.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a790fb90-492e-480a-9403-d1d242c48389", + "id": "0", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a00d7b52-ac2e-44ef-9e08-a9d33ee90276", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0fdd5aea-803c-477e-9b35-8edc61a31b7e", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ff092693-dd1e-44ff-bd09-7cfb57b9134f", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9a75f64f-fe2c-44d9-abae-18ff8453d154", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c433078-8c78-4a2a-93d3-d9330762bbbd", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8f945545-7a73-4c9a-8867-e2cae9e1aece", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1fcae9c4-9c1c-402f-a6c9-70a7f6f939a7", + "id": "7", "metadata": {}, "outputs": [], "source": [] @@ -125,7 +125,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -138,8 +137,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.18" + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/repr.ipynb b/notebooks/repr.ipynb index 3b8c2a289..7aa1dbb88 100644 --- a/notebooks/repr.ipynb +++ b/notebooks/repr.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "aa5bad7b", + "id": "0", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24cdd3a1", + "id": "1", "metadata": { "tags": [] }, @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "362dedbf", + "id": "2", "metadata": { "tags": [] }, @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "294fc8b7", + "id": "3", "metadata": { "tags": [] }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9ca832ac", + "id": "4", "metadata": { "tags": [] }, @@ -64,7 +64,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73e79af6", + "id": "5", "metadata": { "tags": [] }, @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4781d110", + "id": "6", "metadata": {}, "outputs": [], "source": [] @@ -84,7 +84,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -97,15 +96,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, diff --git a/notebooks/spike_sim_test_data.ipynb b/notebooks/spike_sim_test_data.ipynb index ba87ef806..ae7709062 100644 --- a/notebooks/spike_sim_test_data.ipynb +++ b/notebooks/spike_sim_test_data.ipynb @@ -1197,7 +1197,6 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1210,15 +1209,7 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } + "pygments_lexer": "ipython3" } }, "nbformat": 4, From a0cf6b8543a35c59e529eb8f12857a253600161a Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 6 Oct 2026 15:47:36 +0100 Subject: [PATCH 34/38] think i fixed tests failing under CI --- tests/anoph/test_igv.py | 5 ++--- tests/anoph/test_vcf_exporter.py | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/anoph/test_igv.py b/tests/anoph/test_igv.py index 84cda5cf3..61faa0645 100644 --- a/tests/anoph/test_igv.py +++ b/tests/anoph/test_igv.py @@ -1,5 +1,3 @@ -from types import SimpleNamespace - import igv_notebook # type: ignore import numpy as np import pandas as pd @@ -10,6 +8,7 @@ from malariagen_data import ag3 as _ag3 import malariagen_data.anoph.igv as igv_module from malariagen_data.anoph.igv import AnophelesIgv +from malariagen_data.util import Region @pytest.fixture @@ -113,7 +112,7 @@ def wgs_data_catalog(self, sample_set): monkeypatch.setattr( igv_module, "_parse_single_region", - lambda self, region: SimpleNamespace(contig="2L"), + lambda self, region: Region("2L", 1, 10), ) monkeypatch.setattr( api, diff --git a/tests/anoph/test_vcf_exporter.py b/tests/anoph/test_vcf_exporter.py index ed4edb606..f4eead2d7 100644 --- a/tests/anoph/test_vcf_exporter.py +++ b/tests/anoph/test_vcf_exporter.py @@ -448,28 +448,27 @@ def test_vcf_exporter_fields(fixture, api: SnpVcfExporter, tmp_path): @parametrize_with_cases("fixture,api", cases=".") -def test_vcf_exporter_fields_as_set(fixture, api: SnpVcfExporter, tmp_path): - # A `set` has no guaranteed iteration order. The FORMAT column must - # still come out in the same fixed order (GT, GQ, AD, MQ) that the - # per-sample values are actually written in, regardless of what - # order `fields` iterates in as passed by the caller. Previously - # the FORMAT column used the caller's (here, arbitrary) order while - # values were always written GT:GQ:AD:MQ, so a `set` could easily - # produce a VCF whose header lied about which value was which — - # e.g. declaring the first value as "MQ" when it was actually the - # GT string, which bcftools then fails to parse. +def test_vcf_exporter_fields_order(fixture, api: SnpVcfExporter, tmp_path): + # The FORMAT column must come out in the same fixed order (GT, GQ, + # AD, MQ) that the per-sample values are actually written in, + # regardless of the order of `fields` as passed by the caller. + # Previously the FORMAT column used the caller's order while values + # were always written GT:GQ:AD:MQ, producing a VCF whose header lied + # about which value was which — e.g. declaring the first value as + # "MQ" when it was actually the GT string, which bcftools then + # fails to parse. region = api.contigs[0] all_sample_sets = api.sample_sets()["sample_set"].to_list() sample_sets = [all_sample_sets[0]] _, sample_query = _pick_single_sample_query(api, sample_sets) - output_path = str(tmp_path / "test_fields_set.vcf.gz") + output_path = str(tmp_path / "test_fields_order.vcf.gz") api.snp_calls_to_vcf( output_path=output_path, region=region, sample_sets=sample_sets, sample_query=sample_query, - fields={"GT", "GQ", "AD", "MQ"}, + fields=("MQ", "AD", "GT", "GQ"), ) with gzip.open(output_path, "rt") as f: @@ -521,7 +520,7 @@ def test_vcf_exporter_output_is_valid_per_bcftools( region=region, sample_sets=sample_sets, sample_query=sample_query, - fields={"GT", "GQ", "AD", "MQ"}, + fields=("MQ", "AD", "GT", "GQ"), ) result = subprocess.run( From 4e20404bc055b5c2be42e7f36a2052ae84064067 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 7 Oct 2026 11:22:11 +0100 Subject: [PATCH 35/38] limit region size to ensure it will load in IGV --- malariagen_data/anoph/to_vcf.py | 14 ++++++++++++++ notebooks/igv.ipynb | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index d05915b40..6dc6b018d 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -15,6 +15,7 @@ from . import base_params from . import plink_params from . import vcf_params +from ..util import _parse_multi_region @dataclass @@ -145,6 +146,7 @@ def snp_calls_to_vcf( sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, site_mask: Optional[base_params.site_mask] = None, + max_region_size: Optional[int] = 1_000_000, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, @@ -168,6 +170,18 @@ def snp_calls_to_vcf( ) if "GT" not in fields: raise ValueError("GT must be included in fields.") + # IGV loads the whole (unindexed) VCF into the browser, so cap the + # total region size. + region_size = sum( + self.genome_sequence(region=r).shape[0] + for r in _parse_multi_region(self, region) + ) + if max_region_size is not None and region_size > max_region_size: + raise ValueError( + f"region {region!r} spans {region_size:,} bp, more than " + f"max_region_size ({max_region_size:,} bp). Use a smaller region, " + 'e.g. "2R:2,400,000-2,500,000", or set max_region_size=None.' + ) # Canonicalise the field order to _FIELD_ORDER fields = tuple(f for f in _FIELD_ORDER if f in fields) diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index d584f04ae..9626a7d09 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -245,6 +245,14 @@ " snp_vcf_url=snp_vcf_url,\n", ")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "19", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 98ad89aa41ac1cef9ae3fabaa2aca36cee272cc9 Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 7 Oct 2026 13:53:39 +0100 Subject: [PATCH 36/38] fixed vcf paths for jupyter lab --- malariagen_data/anoph/igv.py | 42 ++++++++++++++++--------- malariagen_data/anoph/to_vcf.py | 2 +- malariagen_data/anoph/vcf_params.py | 11 ++++++- notebooks/igv.ipynb | 26 +++++++++++----- tests/anoph/test_igv.py | 48 ++++++++++++++++++++--------- 5 files changed, 90 insertions(+), 39 deletions(-) diff --git a/malariagen_data/anoph/igv.py b/malariagen_data/anoph/igv.py index 5958106d4..964f8dddc 100644 --- a/malariagen_data/anoph/igv.py +++ b/malariagen_data/anoph/igv.py @@ -1,4 +1,6 @@ -from typing import List, Optional +import base64 +import os +from typing import List, Optional, Union import igv_notebook # type: ignore from numpydoc_decorator import doc # type: ignore @@ -8,6 +10,15 @@ from .snp_data import AnophelesSnpData +def _vcf_data_uri(path: Union[str, os.PathLike]) -> str: + """Read a local VCF file and return it as a data URI.""" + with open(path, "rb") as f: + data = f.read() + is_gzip = data[:2] == b"\x1f\x8b" + media_type = "application/gzip" if is_gzip else "text/plain" + return f"data:{media_type};base64,{base64.b64encode(data).decode()}" + + class AnophelesIgv( AnophelesSnpData, ): @@ -82,7 +93,7 @@ def _igv_view_alignments_tracks( region: Region, sample: str, visibility_window: int = 20_000, - snp_vcf_url: Optional[str] = None, + snp_vcf_path: Optional[Union[str, os.PathLike]] = None, ): # Look up sample set for sample. try: @@ -116,10 +127,12 @@ def _igv_view_alignments_tracks( "visibilityWindow": visibility_window, # bp "height": 50, } - if snp_vcf_url is not None: - # A local VCF, e.g. from snp_calls_to_vcf(), has no index, so - # IGV loads it in full. - snp_track["url"] = snp_vcf_url + if snp_vcf_path is not None: + # Embed the local VCF, e.g. from snp_calls_to_vcf(), in the track + # as a data URI, so it doesn't need to be served over HTTP (which + # isn't possible in all notebook environments, e.g. VS Code). It + # has no index, so IGV loads it in full. + snp_track["url"] = _vcf_data_uri(snp_vcf_path) snp_track["indexed"] = False else: vcf_url = cat_rec["snp_genotypes_vcf"] @@ -189,13 +202,12 @@ def igv( visible. """, init="If True, call igv_notebook.init().", - snp_vcf_url=""" - Optional URL for a local VCF, e.g. one written by - `snp_calls_to_vcf()`. The VCF is loaded without an index, so it - should be small (e.g. a single sample over a region). For Jupyter - Notebook and Lab, the VCF must be under the Jupyter startup - directory tree; pass a URL relative to that tree (e.g. - `/data/sample.vcf.gz`). If omitted, use the catalog VCF. + snp_vcf_path=""" + Optional path to a local VCF file (`.vcf` or `.vcf.gz`), e.g. one + written by `snp_calls_to_vcf()`, to show as the SNPs track. The + file is embedded in the notebook and loaded in full, so it should + be small (e.g. a single sample over a region). If omitted, use + the catalog VCF. """, ), ) @@ -205,7 +217,7 @@ def view_alignments( sample: str, visibility_window: int = 20_000, init: bool = True, - snp_vcf_url: Optional[str] = None, + snp_vcf_path: Optional[Union[str, os.PathLike]] = None, ): # Parse region. region_prepped: Region = _parse_single_region(self, region) @@ -216,7 +228,7 @@ def view_alignments( region=region_prepped, sample=sample, visibility_window=visibility_window, - snp_vcf_url=snp_vcf_url, + snp_vcf_path=snp_vcf_path, ) # Create IGV browser. diff --git a/malariagen_data/anoph/to_vcf.py b/malariagen_data/anoph/to_vcf.py index 6dc6b018d..e2de4ae84 100644 --- a/malariagen_data/anoph/to_vcf.py +++ b/malariagen_data/anoph/to_vcf.py @@ -146,7 +146,7 @@ def snp_calls_to_vcf( sample_query: base_params.sample_query, sample_query_options: Optional[base_params.sample_query_options] = None, site_mask: Optional[base_params.site_mask] = None, - max_region_size: Optional[int] = 1_000_000, + max_region_size: vcf_params.vcf_max_region_size = 1_000_000, inline_array: base_params.inline_array = base_params.inline_array_default, chunks: base_params.chunks = base_params.native_chunks, overwrite: plink_params.overwrite = False, diff --git a/malariagen_data/anoph/vcf_params.py b/malariagen_data/anoph/vcf_params.py index 52b25fd15..2ca02d10d 100644 --- a/malariagen_data/anoph/vcf_params.py +++ b/malariagen_data/anoph/vcf_params.py @@ -1,6 +1,6 @@ """Parameters for VCF exporter functions.""" -from typing import Tuple +from typing import Optional, Tuple from typing_extensions import Annotated, TypeAlias @@ -19,3 +19,12 @@ Supported fields: "GT", "GQ", "AD", "MQ". """, ] + +vcf_max_region_size: TypeAlias = Annotated[ + Optional[int], + """ + Maximum total size of `region` in base pairs. The VCF is loaded in + full by IGV, so large regions are rejected. Set to None to disable + this check. + """, +] diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index 9626a7d09..4d521f2ad 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -206,7 +206,7 @@ "metadata": {}, "source": [ "## Local VCF in IGV\n", - "This exports one sample over a region to a BGZF-compressed VCF under the notebook working directory, then loads it as the SNP track. No index is created, so IGV loads the whole file; keep the region small. The file must be inside the Jupyter server startup directory tree. The `snp_vcf_url` below assumes the server was started from the workspace root; if it was started from `notebooks/`, use the alternate URL shown in the code cell." + "This exports one sample over a region to a BGZF-compressed VCF under the notebook working directory, then loads it as the SNP track. No index is created, so IGV loads the whole file; keep the region small. The file is passed to `view_alignments()` by its local path and embedded in the notebook, so it works in any notebook environment (Jupyter, VS Code, Colab)." ] }, { @@ -219,11 +219,11 @@ "from pathlib import Path\n", "\n", "\n", - "sample_set = \"1229-VO-GH-DADZIE-VMF00095\"\n", + "sample_set = \"1240-VO-MZ-KOEKEMOER-VMF00101\"\n", "sample_id = str(\n", " af1.sample_metadata(sample_sets=sample_set).iloc[0][\"sample_id\"]\n", ")\n", - "region = \"2RL:2,447,600-2,447,700\"\n", + "region = \"2RL:2,440,000-2,441,000\"\n", "\n", "local_vcf_path = Path(\"local_igv_vcfs\") / f\"{sample_id}.vcf.gz\"\n", "local_vcf_path.parent.mkdir(parents=True, exist_ok=True)\n", @@ -233,16 +233,13 @@ " region=region,\n", " sample_sets=[sample_set],\n", " sample_query=f\"sample_id == '{sample_id}'\",\n", + " overwrite=True,\n", ")\n", "\n", - "# The URL is relative to the Jupyter server startup directory.\n", - "# If started from notebooks/, use f\"/{local_vcf_path.as_posix()}\" instead.\n", - "snp_vcf_url = f\"/notebooks/{local_vcf_path.as_posix()}\"\n", - "\n", "af1.view_alignments(\n", " sample=sample_id,\n", " region=region,\n", - " snp_vcf_url=snp_vcf_url,\n", + " snp_vcf_path=local_vcf_path,\n", ")" ] }, @@ -252,6 +249,19 @@ "id": "19", "metadata": {}, "outputs": [], + "source": [ + "af1.view_alignments(\n", + " sample=sample_id,\n", + " region=region,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20", + "metadata": {}, + "outputs": [], "source": [] } ], diff --git a/tests/anoph/test_igv.py b/tests/anoph/test_igv.py index 61faa0645..bb18bcfb1 100644 --- a/tests/anoph/test_igv.py +++ b/tests/anoph/test_igv.py @@ -1,3 +1,6 @@ +import base64 +import gzip + import igv_notebook # type: ignore import numpy as np import pandas as pd @@ -89,7 +92,7 @@ def test_view_alignments(fixture, api: AnophelesIgv): assert ret is None -def test_view_alignments_with_local_snp_vcf(monkeypatch): +def test_view_alignments_with_local_snp_vcf(monkeypatch, tmp_path): class FakeAnophelesIgv(AnophelesIgv): @property def site_mask_ids(self): @@ -119,19 +122,36 @@ def wgs_data_catalog(self, sample_set): "igv", lambda **kwargs: captured.update(kwargs), ) - local_vcf_url = "/data/sample.vcf.gz" - api.view_alignments( - region="2L:1-10", - sample="S1", - init=False, - snp_vcf_url=local_vcf_url, - ) - - snp_track = next(track for track in captured["tracks"] if track["name"] == "SNPs") - assert snp_track["url"] == local_vcf_url - # A local VCF has no index, so IGV must load it in full. - assert snp_track["indexed"] is False - assert "indexURL" not in snp_track + vcf_text = b"##fileformat=VCFv4.3\n" + vcf_gz_path = tmp_path / "sample.vcf.gz" + with gzip.open(vcf_gz_path, "wb") as f: + f.write(vcf_text) + vcf_plain_path = tmp_path / "sample.vcf" + vcf_plain_path.write_bytes(vcf_text) + + for path, media_type in [ + (vcf_gz_path, "application/gzip"), + (str(vcf_plain_path), "text/plain"), + ]: + captured.clear() + api.view_alignments( + region="2L:1-10", + sample="S1", + init=False, + snp_vcf_path=path, + ) + + snp_track = next( + track for track in captured["tracks"] if track["name"] == "SNPs" + ) + # The local VCF is embedded in the track as a data URI. + prefix = f"data:{media_type};base64," + assert snp_track["url"].startswith(prefix) + with open(path, "rb") as f: + assert base64.b64decode(snp_track["url"][len(prefix) :]) == f.read() + # A local VCF has no index, so IGV must load it in full. + assert snp_track["indexed"] is False + assert "indexURL" not in snp_track captured.clear() api.view_alignments(region="2L:1-10", sample="S1", init=False) From debaed8eab0a29f6861b32fa1a67b95bbeff97ae Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Wed, 7 Oct 2026 16:37:23 +0100 Subject: [PATCH 37/38] shown 5bp region with SNPs, and same region with original VCF, plus some extra explanatio in notebookn --- notebooks/igv.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index 4d521f2ad..39c04f4b6 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -206,7 +206,7 @@ "metadata": {}, "source": [ "## Local VCF in IGV\n", - "This exports one sample over a region to a BGZF-compressed VCF under the notebook working directory, then loads it as the SNP track. No index is created, so IGV loads the whole file; keep the region small. The file is passed to `view_alignments()` by its local path and embedded in the notebook, so it works in any notebook environment (Jupyter, VS Code, Colab)." + "This exports one sample over a region to a BGZF-compressed VCF under the notebook working directory, then loads it as the SNP track. No index is created, so IGV loads the whole file; keep the region small- 5000 base pairs, as shown in this demo, works on a modern (2026 Mac) but if you are experiencing crashes, reduce the number of base pairs in the region the VCF is created for. The file is passed to `view_alignments()` by its local path and embedded in the notebook, so it works in any notebook environment (Jupyter, VS Code, Colab). If no variants are present, the SNPs track will be empty, as homozygous calls are escluded for resource reasons. " ] }, { @@ -223,7 +223,7 @@ "sample_id = str(\n", " af1.sample_metadata(sample_sets=sample_set).iloc[0][\"sample_id\"]\n", ")\n", - "region = \"2RL:2,440,000-2,441,000\"\n", + "region = \"2RL:2,440,000-2,445,000\"\n", "\n", "local_vcf_path = Path(\"local_igv_vcfs\") / f\"{sample_id}.vcf.gz\"\n", "local_vcf_path.parent.mkdir(parents=True, exist_ok=True)\n", From 57911967bc2793d7f7938f20a44d5d54364517bf Mon Sep 17 00:00:00 2001 From: Katie Barr Date: Tue, 13 Oct 2026 12:22:16 +0100 Subject: [PATCH 38/38] hopefully restored notebooks to previous state and commented nbstripout from my pre commit hooks to make sure it doesn't alter them --- .pre-commit-config.yaml | 24 +- notebooks/auto_chunks.ipynb | 49 +- notebooks/biallelic_snps.ipynb | 49 +- notebooks/cohort_geometries.ipynb | 4 +- notebooks/extra_metadata.ipynb | 33 +- notebooks/igv.ipynb | 4 +- notebooks/karyotype.ipynb | 58 +- notebooks/ld_pruning.ipynb | 39 +- notebooks/local_cluster.ipynb | 27 +- notebooks/phenotype_data_demo.ipynb | 862 +++++++++++++++++++- notebooks/plink_convert.ipynb | 4 +- notebooks/plot_aims.ipynb | 25 +- notebooks/plot_cnv.ipynb | 63 +- notebooks/plot_diplotype_clustering.ipynb | 59 +- notebooks/plot_diversity.ipynb | 37 +- notebooks/plot_frequencies_heatmap.ipynb | 79 +- notebooks/plot_frequencies_space_time.ipynb | 786 ++++++++++++++++-- notebooks/plot_fst_gwss.ipynb | 33 +- notebooks/plot_g123_gwss.ipynb | 43 +- notebooks/plot_genes.ipynb | 119 ++- notebooks/plot_h12_h1x.ipynb | 65 +- notebooks/plot_haplotype_clustering.ipynb | 61 +- notebooks/plot_haplotype_networks.ipynb | 61 +- notebooks/plot_haplotypes_frequencies.ipynb | 24 +- notebooks/plot_heterozygosity.ipynb | 37 +- notebooks/plot_ihs_gwss.ipynb | 31 +- notebooks/plot_njt.ipynb | 59 +- notebooks/plot_pairwise_average_fst.ipynb | 42 +- notebooks/plot_pca.ipynb | 119 +-- notebooks/plot_samples.ipynb | 13 +- notebooks/plot_snps.ipynb | 53 +- notebooks/plot_xpehh_gwss.ipynb | 33 +- notebooks/profiling/gh498.ipynb | 20 +- notebooks/repr.ipynb | 25 +- notebooks/spike_sim_test_data.ipynb | 11 +- 35 files changed, 2409 insertions(+), 642 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb9d17692..f64769051 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,15 +16,15 @@ repos: - "--fix" # Run the formatter. - id: ruff-format - - repo: https://github.com/kynan/nbstripout - rev: 0.9.1 - hooks: - # Strip outputs, execution counts and volatile metadata (kernel - # display name, language version — these change depending on - # which local environment a notebook was last run under, not on - # any real edit) from notebooks before they're committed, so - # `git diff` only shows real cell-source changes. - - id: nbstripout - args: - - "--extra-keys" - - "metadata.kernelspec.display_name metadata.language_info.version" +# - repo: https://github.com/kynan/nbstripout +# rev: 0.9.1 +# hooks: +# # Strip outputs, execution counts and volatile metadata (kernel +# # display name, language version — these change depending on +# # which local environment a notebook was last run under, not on +# # any real edit) from notebooks before they're committed, so +# # `git diff` only shows real cell-source changes. +# - id: nbstripout +# args: +# - "--extra-keys" +# - "metadata.kernelspec.display_name metadata.language_info.version" diff --git a/notebooks/auto_chunks.ipynb b/notebooks/auto_chunks.ipynb index 5ca68310e..291f7318b 100644 --- a/notebooks/auto_chunks.ipynb +++ b/notebooks/auto_chunks.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "5ba32f43-2308-43a0-9849-489d77a2f841", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "8015add7-81c7-42bd-94c3-a433047c6ca2", "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "2", + "id": "fe297aa9-cfe2-40e5-aa18-3f3a082cdd34", "metadata": {}, "source": [ "## Default chunk sizes" @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "27c25fb3-ad5c-4652-bf6c-c51d07558790", "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "0dbaca2c-d4f0-44c9-b5c8-a992e52dc476", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "f149f390-8e34-42c0-aaa5-7cfe3bbd4c6c", "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "8c1a6207-29bb-4ef9-a8a0-4c6a20acda3c", "metadata": {}, "source": [ "## Explicit chunk sizes" @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "5cbedcb4-cf4e-4f5b-9f0a-901e6abb7dd6", "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "05598e4a-f362-4b21-a601-9968619135a4", "metadata": {}, "outputs": [], "source": [ @@ -97,7 +97,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "b903fb3a-1f17-403a-bf8b-43623148ffaa", "metadata": {}, "outputs": [], "source": [ @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "10", + "id": "497bd930-c0a1-4ab9-9f56-874673420fbd", "metadata": {}, "source": [ "## Auto chunk sizes" @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "9238bb0f-739e-428b-b4f4-9797b15e045b", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "8c894749-6486-478d-9f83-0849aa8a62f2", "metadata": {}, "outputs": [], "source": [ @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "f9caefda-4adf-4836-bae4-f7b7bedf8e86", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "markdown", - "id": "14", + "id": "84bd96e2-42d3-402b-9bca-e071802cb53e", "metadata": {}, "source": [ "## ND auto chunk sizes" @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "a7f5c439-505f-44c0-abfb-05999e4d9759", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "6b2e3c60-5d05-445b-91fc-da5115b190bb", "metadata": {}, "outputs": [], "source": [ @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "92c9edab-9653-438c-990a-0bffeb81d5fe", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "04e2f86c-bd3d-4bc1-9142-4f1d243ddbd7", "metadata": {}, "outputs": [], "source": [] @@ -191,6 +191,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -203,7 +204,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/biallelic_snps.ipynb b/notebooks/biallelic_snps.ipynb index fb1b784e9..e4ebef4fc 100644 --- a/notebooks/biallelic_snps.ipynb +++ b/notebooks/biallelic_snps.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "890ed13a-3e8e-4fd6-b0cb-464e31ab5f64", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "42ecae20-46b7-4218-a37c-e96df62241fb", "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "9151e470-bdbe-4eee-902c-6178b5f6b62f", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "9cb9bfcb-19b5-40e1-bd2b-11a8c2247af3", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "489c3941-1ae6-4954-ae48-585823b46649", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "8b024a95-6f9d-4371-95bb-eb6887481a6a", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "787973c4-1974-4c8e-8b57-e82b4ea90e6a", "metadata": {}, "outputs": [], "source": [ @@ -89,7 +89,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "34dfc71b-4e81-4083-8c8a-c08d712e2fa3", "metadata": {}, "outputs": [], "source": [ @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "29e17deb-830f-4f5a-9e5f-4707a6041743", "metadata": {}, "outputs": [], "source": [ @@ -110,7 +110,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "42afc05c-045e-47c8-925a-9df3676ad0fc", "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "c419ef30-504f-4e8b-8b77-6b15fa29ccb5", "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "489878b8-eb77-41b8-8b1d-cf6f5035877d", "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "ef087212-fef9-45da-a797-00be884887a2", "metadata": {}, "outputs": [], "source": [ @@ -160,7 +160,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "52d0e6c9-b994-4dd9-91b6-00c58af1ee3b", "metadata": {}, "outputs": [], "source": [ @@ -170,7 +170,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "b8b26acb-c6c5-4c92-9831-a8a276c952f3", "metadata": {}, "outputs": [], "source": [ @@ -181,7 +181,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "87cdfec5-ca1e-4139-91fa-93506a112b1a", "metadata": {}, "outputs": [], "source": [ @@ -200,7 +200,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "c83b492b-11ec-400b-bceb-de6630c34a7b", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "07f75f48-bf25-4491-8891-77765867e9a0", "metadata": {}, "outputs": [], "source": [ @@ -221,7 +221,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "9e434252-0c77-4a5d-ac76-55c87c84fd94", "metadata": {}, "outputs": [], "source": [] @@ -229,6 +229,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -241,7 +242,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/cohort_geometries.ipynb b/notebooks/cohort_geometries.ipynb index 4c690099b..fc8e24a27 100644 --- a/notebooks/cohort_geometries.ipynb +++ b/notebooks/cohort_geometries.ipynb @@ -101,11 +101,13 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { - "name": "python" + "name": "python", + "version": "3.10.0" } }, "nbformat": 4, diff --git a/notebooks/extra_metadata.ipynb b/notebooks/extra_metadata.ipynb index 69b65a87a..c75b619f0 100644 --- a/notebooks/extra_metadata.ipynb +++ b/notebooks/extra_metadata.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "38bb6b32", "metadata": {}, "outputs": [], "source": [ @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "142627af", "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "e1634546", "metadata": {}, "outputs": [], "source": [ @@ -40,7 +40,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "5e6e7edd", "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "140cd606", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "3f507df0", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "47a85795", "metadata": {}, "outputs": [], "source": [ @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "d51ae27a", "metadata": {}, "outputs": [], "source": [ @@ -98,7 +98,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "c13b4e5a", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "171ad0ce", "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "450d0e1f", "metadata": {}, "outputs": [], "source": [] @@ -128,6 +128,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -140,7 +141,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/igv.ipynb b/notebooks/igv.ipynb index 39c04f4b6..bdecd784d 100644 --- a/notebooks/igv.ipynb +++ b/notebooks/igv.ipynb @@ -267,6 +267,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -279,7 +280,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.11.16" } }, "nbformat": 4, diff --git a/notebooks/karyotype.ipynb b/notebooks/karyotype.ipynb index ff5ce5f56..857d560ca 100644 --- a/notebooks/karyotype.ipynb +++ b/notebooks/karyotype.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "95754202-48fb-40fb-8630-8de938cd90a8", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "0913ba40-7f43-4f3e-8405-f2c3efae65be", "metadata": { "tags": [] }, @@ -32,7 +32,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "d65aea9d-953c-47ad-838e-cf205822b6c8", "metadata": { "tags": [] }, @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "a8b1f82f-a60a-4326-a105-a7fd169ed85e", "metadata": { "tags": [] }, @@ -62,7 +62,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "35e8569a-5e2c-450d-ad8a-283de669aa27", "metadata": {}, "source": [ "## 2La" @@ -71,7 +71,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "b7556095-b24a-4a26-9a3a-c98cb14d2e24", "metadata": { "tags": [] }, @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "4a16ebf5-1a66-4b10-9f5a-d57080e26cb7", "metadata": { "tags": [] }, @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "8cb4d566-fde1-42e7-a7ba-7294b6adbb66", "metadata": { "tags": [] }, @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "b522c176-da60-4a4b-ad01-5de74c2a49a6", "metadata": { "tags": [] }, @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "0daf1c4e-4e19-43e6-ac9b-b4e0680a01a8", "metadata": { "tags": [] }, @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "f7054916-64b8-4b52-a624-1f4eae413b09", "metadata": { "tags": [] }, @@ -151,7 +151,7 @@ }, { "cell_type": "markdown", - "id": "11", + "id": "32a8664a-67c7-48c8-9870-43f5ec2777ff", "metadata": {}, "source": [ "## 2Rb" @@ -160,7 +160,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "8d7dc314-9bae-487e-9078-0bf0dec42d9c", "metadata": { "tags": [] }, @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "3a131e26-730a-479d-acaf-735ea92ec93f", "metadata": { "tags": [] }, @@ -191,7 +191,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "b728fe52-cae6-4c22-9429-52f3d30d475a", "metadata": { "tags": [] }, @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "b674c67a-f4fc-471a-a9d0-08f45e9006e9", "metadata": { "tags": [] }, @@ -216,7 +216,7 @@ }, { "cell_type": "markdown", - "id": "16", + "id": "51595e8d-d911-4f7f-932b-ed1007fa95fd", "metadata": {}, "source": [ "## 2Rc_gam" @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "3091fec6-6484-4c76-9078-f78fc988ae28", "metadata": { "tags": [] }, @@ -242,7 +242,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "da7cd248-2a43-412c-99cf-22ca9786cf2b", "metadata": { "tags": [] }, @@ -256,7 +256,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "f5a08876-0431-4190-87bb-48962fd4c98c", "metadata": { "tags": [] }, @@ -275,7 +275,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "fa62428f-09c8-4dc5-b45b-e4761041b966", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "2287b6e9-50b7-4ce4-9ef5-a4dd0e5463af", "metadata": { "tags": [] }, @@ -300,7 +300,7 @@ }, { "cell_type": "markdown", - "id": "22", + "id": "8fc6d2af-3d22-42e3-8ca8-756c4e72b141", "metadata": {}, "source": [ "## 2Rc_col" @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "483722dc-86ba-4766-826b-c7d3d2d00cf5", "metadata": { "tags": [] }, @@ -326,7 +326,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "8ec9135f-4abc-432b-9707-14db25e650ea", "metadata": { "tags": [] }, @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "1bcb2209-a5db-4cc2-8fac-d51dae1f214c", "metadata": { "tags": [] }, @@ -359,7 +359,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "ecee39ab-b8f5-4a79-a31b-2badfafc329b", "metadata": { "tags": [] }, @@ -379,6 +379,7 @@ "uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m124" }, "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -391,7 +392,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.11" } }, "nbformat": 4, diff --git a/notebooks/ld_pruning.ipynb b/notebooks/ld_pruning.ipynb index f2637cc44..292649aeb 100644 --- a/notebooks/ld_pruning.ipynb +++ b/notebooks/ld_pruning.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0", + "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "metadata": {}, "source": [ "# LD-pruned biallelic SNP calls\n", @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "1", + "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901", "metadata": {}, "source": [ "## Setup" @@ -23,7 +23,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "c3d4e5f6-a7b8-9012-cdef-123456789012", "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "d4e5f6a7-b8c9-0123-defa-234567890123", "metadata": {}, "outputs": [], "source": [ @@ -47,7 +47,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "e5f6a7b8-c9d0-1234-efab-345678901234", "metadata": {}, "source": [ "## Basic usage" @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "f6a7b8c9-d0e1-2345-fabc-456789012345", "metadata": {}, "outputs": [], "source": [ @@ -71,7 +71,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "a7b8c9d0-e1f2-3456-abcd-567890123456", "metadata": {}, "outputs": [], "source": [ @@ -83,7 +83,7 @@ }, { "cell_type": "markdown", - "id": "7", + "id": "b8c9d0e1-f2a3-4567-bcde-678901234567", "metadata": {}, "source": [ "## Effect of LD parameters" @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "c9d0e1f2-a3b4-5678-cdef-789012345678", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ }, { "cell_type": "markdown", - "id": "9", + "id": "d0e1f2a3-b4c5-6789-defa-890123456789", "metadata": {}, "source": [ "## Before vs after pruning" @@ -127,7 +127,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "e1f2a3b4-c5d6-7890-efab-901234567890", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ }, { "cell_type": "markdown", - "id": "11", + "id": "f2a3b4c5-d6e7-8901-fabc-012345678901", "metadata": {}, "source": [ "## Downstream compatibility\n", @@ -156,7 +156,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "a3b4c5d6-e7f8-9012-abcd-123456789abc", "metadata": {}, "outputs": [], "source": [ @@ -179,7 +179,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "b4c5d6e7-f8a9-0123-bcde-234567890bcd", "metadata": {}, "outputs": [], "source": [] @@ -187,6 +187,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -199,7 +200,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/local_cluster.ipynb b/notebooks/local_cluster.ipynb index 66da8100b..91d56dc41 100644 --- a/notebooks/local_cluster.ipynb +++ b/notebooks/local_cluster.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "5ba32f43-2308-43a0-9849-489d77a2f841", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "8015add7-81c7-42bd-94c3-a433047c6ca2", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "27c25fb3-ad5c-4652-bf6c-c51d07558790", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "176f77d9-6376-41ce-b3bf-d8025b5a7174", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "d9657559-8fc9-4a70-97da-12208b9502ea", "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "37bbdfb4-b27d-49d0-9888-042f33d17d32", "metadata": {}, "outputs": [], "source": [ @@ -75,7 +75,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "87aad9d0-75e6-4d9c-b6a2-814b8fe2ccea", "metadata": {}, "outputs": [], "source": [ @@ -85,7 +85,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "a6508f51-6915-4da5-b3ce-f3baa4f69937", "metadata": {}, "outputs": [], "source": [] @@ -93,6 +93,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -105,7 +106,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/phenotype_data_demo.ipynb b/notebooks/phenotype_data_demo.ipynb index dccab55ee..ac1e224f8 100644 --- a/notebooks/phenotype_data_demo.ipynb +++ b/notebooks/phenotype_data_demo.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0", + "id": "cef10418-08a1-4cc4-a3b0-b8b516cc64fd", "metadata": {}, "source": [ "# Demonstrating New Phenotype Data Access and Filtering\n", @@ -13,7 +13,7 @@ }, { "cell_type": "markdown", - "id": "1", + "id": "29554ea2-5e37-40b6-90c1-08088bf9793a", "metadata": {}, "source": [ "## 1. Setup and Imports\n", @@ -23,10 +23,351 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "2", + "execution_count": 1, + "id": "f1280de7-129f-4875-bf12-eb68b8d88573", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/javascript": [ + "'use strict';\n", + "(function(root) {\n", + " function now() {\n", + " return new Date();\n", + " }\n", + "\n", + " const force = true;\n", + "\n", + " if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n", + " root._bokeh_onload_callbacks = [];\n", + " root._bokeh_is_loading = undefined;\n", + " }\n", + "\n", + "const JS_MIME_TYPE = 'application/javascript';\n", + " const HTML_MIME_TYPE = 'text/html';\n", + " const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", + " const CLASS_NAME = 'output_bokeh rendered_html';\n", + "\n", + " /**\n", + " * Render data to the DOM node\n", + " */\n", + " function render(props, node) {\n", + " const script = document.createElement(\"script\");\n", + " node.appendChild(script);\n", + " }\n", + "\n", + " /**\n", + " * Handle when an output is cleared or removed\n", + " */\n", + " function handleClearOutput(event, handle) {\n", + " function drop(id) {\n", + " const view = Bokeh.index.get_by_id(id)\n", + " if (view != null) {\n", + " view.model.document.clear()\n", + " Bokeh.index.delete(view)\n", + " }\n", + " }\n", + "\n", + " const cell = handle.cell;\n", + "\n", + " const id = cell.output_area._bokeh_element_id;\n", + " const server_id = cell.output_area._bokeh_server_id;\n", + "\n", + " // Clean up Bokeh references\n", + " if (id != null) {\n", + " drop(id)\n", + " }\n", + "\n", + " if (server_id !== undefined) {\n", + " // Clean up Bokeh references\n", + " const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", + " cell.notebook.kernel.execute(cmd_clean, {\n", + " iopub: {\n", + " output: function(msg) {\n", + " const id = msg.content.text.trim()\n", + " drop(id)\n", + " }\n", + " }\n", + " });\n", + " // Destroy server and session\n", + " const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", + " cell.notebook.kernel.execute(cmd_destroy);\n", + " }\n", + " }\n", + "\n", + " /**\n", + " * Handle when a new output is added\n", + " */\n", + " function handleAddOutput(event, handle) {\n", + " const output_area = handle.output_area;\n", + " const output = handle.output;\n", + "\n", + " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", + " if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n", + " return\n", + " }\n", + "\n", + " const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", + "\n", + " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", + " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", + " // store reference to embed id on output_area\n", + " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", + " }\n", + " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", + " const bk_div = document.createElement(\"div\");\n", + " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", + " const script_attrs = bk_div.children[0].attributes;\n", + " for (let i = 0; i < script_attrs.length; i++) {\n", + " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", + " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n", + " }\n", + " // store reference to server id on output_area\n", + " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", + " }\n", + " }\n", + "\n", + " function register_renderer(events, OutputArea) {\n", + "\n", + " function append_mime(data, metadata, element) {\n", + " // create a DOM node to render to\n", + " const toinsert = this.create_output_subarea(\n", + " metadata,\n", + " CLASS_NAME,\n", + " EXEC_MIME_TYPE\n", + " );\n", + " this.keyboard_manager.register_events(toinsert);\n", + " // Render to node\n", + " const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", + " render(props, toinsert[toinsert.length - 1]);\n", + " element.append(toinsert);\n", + " return toinsert\n", + " }\n", + "\n", + " /* Handle when an output is cleared or removed */\n", + " events.on('clear_output.CodeCell', handleClearOutput);\n", + " events.on('delete.Cell', handleClearOutput);\n", + "\n", + " /* Handle when a new output is added */\n", + " events.on('output_added.OutputArea', handleAddOutput);\n", + "\n", + " /**\n", + " * Register the mime type and append_mime function with output_area\n", + " */\n", + " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", + " /* Is output safe? */\n", + " safe: true,\n", + " /* Index of renderer in `output_area.display_order` */\n", + " index: 0\n", + " });\n", + " }\n", + "\n", + " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", + " if (root.Jupyter !== undefined) {\n", + " const events = require('base/js/events');\n", + " const OutputArea = require('notebook/js/outputarea').OutputArea;\n", + "\n", + " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", + " register_renderer(events, OutputArea);\n", + " }\n", + " }\n", + " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", + " root._bokeh_timeout = Date.now() + 5000;\n", + " root._bokeh_failed_load = false;\n", + " }\n", + "\n", + " const NB_LOAD_WARNING = {'data': {'text/html':\n", + " \"
\\n\"+\n", + " \"

\\n\"+\n", + " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", + " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", + " \"

\\n\"+\n", + " \"
    \\n\"+\n", + " \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n", + " \"
  • use INLINE resources instead, as so:
  • \\n\"+\n", + " \"
\\n\"+\n", + " \"\\n\"+\n", + " \"from bokeh.resources import INLINE\\n\"+\n", + " \"output_notebook(resources=INLINE)\\n\"+\n", + " \"\\n\"+\n", + " \"
\"}};\n", + "\n", + " function display_loaded(error = null) {\n", + " const el = document.getElementById(null);\n", + " if (el != null) {\n", + " const html = (() => {\n", + " if (typeof root.Bokeh === \"undefined\") {\n", + " if (error == null) {\n", + " return \"BokehJS is loading ...\";\n", + " } else {\n", + " return \"BokehJS failed to load.\";\n", + " }\n", + " } else {\n", + " const prefix = `BokehJS ${root.Bokeh.version}`;\n", + " if (error == null) {\n", + " return `${prefix} successfully loaded.`;\n", + " } else {\n", + " return `${prefix} encountered errors while loading and may not function as expected.`;\n", + " }\n", + " }\n", + " })();\n", + " el.innerHTML = html;\n", + "\n", + " if (error != null) {\n", + " const wrapper = document.createElement(\"div\");\n", + " wrapper.style.overflow = \"auto\";\n", + " wrapper.style.height = \"5em\";\n", + " wrapper.style.resize = \"vertical\";\n", + " const content = document.createElement(\"div\");\n", + " content.style.fontFamily = \"monospace\";\n", + " content.style.whiteSpace = \"pre-wrap\";\n", + " content.style.backgroundColor = \"rgb(255, 221, 221)\";\n", + " content.textContent = error.stack ?? error.toString();\n", + " wrapper.append(content);\n", + " el.append(wrapper);\n", + " }\n", + " } else if (Date.now() < root._bokeh_timeout) {\n", + " setTimeout(() => display_loaded(error), 100);\n", + " }\n", + " }\n", + "\n", + " function run_callbacks() {\n", + " try {\n", + " root._bokeh_onload_callbacks.forEach(function(callback) {\n", + " if (callback != null)\n", + " callback();\n", + " });\n", + " } finally {\n", + " delete root._bokeh_onload_callbacks\n", + " }\n", + " console.debug(\"Bokeh: all callbacks have finished\");\n", + " }\n", + "\n", + " function load_libs(css_urls, js_urls, callback) {\n", + " if (css_urls == null) css_urls = [];\n", + " if (js_urls == null) js_urls = [];\n", + "\n", + " root._bokeh_onload_callbacks.push(callback);\n", + " if (root._bokeh_is_loading > 0) {\n", + " console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n", + " return null;\n", + " }\n", + " if (js_urls == null || js_urls.length === 0) {\n", + " run_callbacks();\n", + " return null;\n", + " }\n", + " console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", + " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", + "\n", + " function on_load() {\n", + " root._bokeh_is_loading--;\n", + " if (root._bokeh_is_loading === 0) {\n", + " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", + " run_callbacks()\n", + " }\n", + " }\n", + "\n", + " function on_error(url) {\n", + " console.error(\"failed to load \" + url);\n", + " }\n", + "\n", + " for (let i = 0; i < css_urls.length; i++) {\n", + " const url = css_urls[i];\n", + " const element = document.createElement(\"link\");\n", + " element.onload = on_load;\n", + " element.onerror = on_error.bind(null, url);\n", + " element.rel = \"stylesheet\";\n", + " element.type = \"text/css\";\n", + " element.href = url;\n", + " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", + " document.body.appendChild(element);\n", + " }\n", + "\n", + " for (let i = 0; i < js_urls.length; i++) {\n", + " const url = js_urls[i];\n", + " const element = document.createElement('script');\n", + " element.onload = on_load;\n", + " element.onerror = on_error.bind(null, url);\n", + " element.async = false;\n", + " element.src = url;\n", + " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", + " document.head.appendChild(element);\n", + " }\n", + " };\n", + "\n", + " function inject_raw_css(css) {\n", + " const element = document.createElement(\"style\");\n", + " element.appendChild(document.createTextNode(css));\n", + " document.body.appendChild(element);\n", + " }\n", + "\n", + " const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.min.js\"];\n", + " const css_urls = [];\n", + "\n", + " const inline_js = [ function(Bokeh) {\n", + " Bokeh.set_log_level(\"info\");\n", + " },\n", + "function(Bokeh) {\n", + " }\n", + " ];\n", + "\n", + " function run_inline_js() {\n", + " if (root.Bokeh !== undefined || force === true) {\n", + " try {\n", + " for (let i = 0; i < inline_js.length; i++) {\n", + " inline_js[i].call(root, root.Bokeh);\n", + " }\n", + "\n", + " } catch (error) {throw error;\n", + " }} else if (Date.now() < root._bokeh_timeout) {\n", + " setTimeout(run_inline_js, 100);\n", + " } else if (!root._bokeh_failed_load) {\n", + " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", + " root._bokeh_failed_load = true;\n", + " } else if (force !== true) {\n", + " const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n", + " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", + " }\n", + " }\n", + "\n", + " if (root._bokeh_is_loading === 0) {\n", + " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", + " run_inline_js();\n", + " } else {\n", + " load_libs(css_urls, js_urls, function() {\n", + " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", + " run_inline_js();\n", + " });\n", + " }\n", + "}(window));" + ], + "application/vnd.bokehjs_load.v0+json": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"
    \\n\"+\n \"
  • re-rerun `output_notebook()` to attempt to load from CDN again, or
  • \\n\"+\n \"
  • use INLINE resources instead, as so:
  • \\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MalariaGEN Ag3 API client initialized.\n", + "\n", + "Storage URL : gs://vo_agam_release_master_us_central1/\n", + "Data releases available : 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, 3.14, 3.15\n", + "Results cache : None\n", + "Cohorts analysis : 20250502\n", + "AIM analysis : 20220528\n", + "Site filters analysis : dt_20200416\n", + "Software version : malariagen_data 15.2.2.post22+48d1097a\n", + "Client location : Tanger-Tetouan-Al Hoceima, Morocco\n", + "---\n", + "Please note that data are subject to terms of use,\n", + "for more information see https://www.malariagen.net/data\n", + "or contact support@malariagen.net. For API documentation see \n", + "https://malariagen.github.io/malariagen-data-python/v15.2.2.post22+48d1097a/Ag3.html\n" + ] + } + ], "source": [ "import pandas as pd\n", "import xarray as xr\n", @@ -46,7 +387,7 @@ }, { "cell_type": "markdown", - "id": "3", + "id": "5b1975f3-ad03-450d-b387-6d2ffd5c0143", "metadata": {}, "source": [ "## 2. Listing Available Phenotype Sample Sets\n", @@ -55,10 +396,20 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "4", + "execution_count": 2, + "id": "7dd3ebc4-64f7-4d0b-ad01-fbc1e08b0636", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Available phenotype sample sets: ['1237-VO-BJ-DJOGBENOU-VMF00050', '1244-VO-GH-YAWSON-VMF00051', '1245-VO-CI-CONSTANT-VMF00054', '1253-VO-TG-DJOGBENOU-VMF00052']\n", + "\n", + "Using sample set for demonstration: 1237-VO-BJ-DJOGBENOU-VMF00050\n" + ] + } + ], "source": [ "phenotype_sample_sets = ag3.phenotype_sample_sets()\n", "print(f\"Available phenotype sample sets: {phenotype_sample_sets}\")\n", @@ -77,7 +428,7 @@ }, { "cell_type": "markdown", - "id": "5", + "id": "1319b97a-bd6f-4246-b653-a394aee97930", "metadata": {}, "source": [ "## 3. Loading Phenotype Data with sample_query\n", @@ -86,7 +437,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "6f6d5023-17b1-4988-8683-22b3f71096ff", "metadata": {}, "source": [ "### Example 1: Filter by a specific insecticide" @@ -94,10 +445,93 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "7", + "execution_count": 3, + "id": "c0b9d0ae-6a79-458a-ad9f-9281a1c6112e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Loading phenotype data for '1237-VO-BJ-DJOGBENOU-VMF00050' filtered by Deltamethrin ---\n", + "Shape of DataFrame: (88, 60) \n", + "\n", + "First 5 rows of the filtered DataFrame:\n", + "\n", + "Unique insecticides in filtered data: ['Deltamethrin']\n", + "\n", + "DataFrame Info:\n", + "\n", + "Index: 88 entries, 0 to 87\n", + "Data columns (total 60 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 sample_id 88 non-null object \n", + " 1 country 88 non-null object \n", + " 2 location 88 non-null object \n", + " 3 insecticide 88 non-null object \n", + " 4 dose 88 non-null float64\n", + " 5 phenotype 88 non-null object \n", + " 6 sample_set 88 non-null object \n", + " 7 partner_sample_id 88 non-null object \n", + " 8 contributor 88 non-null object \n", + " 9 year 88 non-null int64 \n", + " 10 month 88 non-null int64 \n", + " 11 latitude 88 non-null float64\n", + " 12 longitude 88 non-null float64\n", + " 13 sex_call 88 non-null object \n", + " 14 release 88 non-null object \n", + " 15 quarter 88 non-null int64 \n", + " 16 study_id 88 non-null object \n", + " 17 study_url 88 non-null object \n", + " 18 terms_of_use_expiry_date 88 non-null object \n", + " 19 terms_of_use_url 88 non-null object \n", + " 20 unrestricted_use 88 non-null bool \n", + " 21 mean_cov 88 non-null Float64\n", + " 22 median_cov 88 non-null Int64 \n", + " 23 modal_cov 88 non-null Int64 \n", + " 24 mean_cov_2L 88 non-null Float64\n", + " 25 median_cov_2L 88 non-null Int64 \n", + " 26 mode_cov_2L 88 non-null Int64 \n", + " 27 mean_cov_2R 88 non-null Float64\n", + " 28 median_cov_2R 88 non-null Int64 \n", + " 29 mode_cov_2R 88 non-null Int64 \n", + " 30 mean_cov_3L 88 non-null Float64\n", + " 31 median_cov_3L 88 non-null Int64 \n", + " 32 mode_cov_3L 88 non-null Int64 \n", + " 33 mean_cov_3R 88 non-null Float64\n", + " 34 median_cov_3R 88 non-null Int64 \n", + " 35 mode_cov_3R 88 non-null Int64 \n", + " 36 mean_cov_X 88 non-null Float64\n", + " 37 median_cov_X 88 non-null Int64 \n", + " 38 mode_cov_X 88 non-null Int64 \n", + " 39 frac_gen_cov 88 non-null Float64\n", + " 40 divergence 88 non-null Float64\n", + " 41 contam_pct 88 non-null Float64\n", + " 42 contam_LLR 88 non-null Float64\n", + " 43 aim_species_fraction_arab 88 non-null float64\n", + " 44 aim_species_fraction_colu 88 non-null float64\n", + " 45 aim_species_fraction_colu_no2l 88 non-null float64\n", + " 46 aim_species_gambcolu_arabiensis 88 non-null object \n", + " 47 aim_species_gambiae_coluzzii 88 non-null object \n", + " 48 aim_species 88 non-null object \n", + " 49 country_iso 88 non-null object \n", + " 50 admin1_name 88 non-null object \n", + " 51 admin1_iso 88 non-null object \n", + " 52 admin2_name 88 non-null object \n", + " 53 taxon 88 non-null object \n", + " 54 cohort_admin1_year 88 non-null object \n", + " 55 cohort_admin1_month 88 non-null object \n", + " 56 cohort_admin1_quarter 88 non-null object \n", + " 57 cohort_admin2_year 88 non-null object \n", + " 58 cohort_admin2_month 88 non-null object \n", + " 59 cohort_admin2_quarter 88 non-null object \n", + "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", + "memory usage: 43.2+ KB\n" + ] + } + ], "source": [ "print(\n", " f\"\\n--- Loading phenotype data for '{demo_sample_set}' filtered by Deltamethrin ---\"\n", @@ -118,7 +552,7 @@ }, { "cell_type": "markdown", - "id": "8", + "id": "daede4ca-01cc-450a-8185-294033af85ad", "metadata": {}, "source": [ "### Example 2: Filter by multiple conditions (insecticide and dose)" @@ -126,10 +560,94 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "9", + "execution_count": 4, + "id": "eab7d81c-d80c-4279-9263-a0d7b425ff85", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Loading phenotype data filtered by Deltamethrin and dose >= 1.0 ---\n", + "Shape of DataFrame: (48, 60)\n", + "\n", + "First 5 rows of the multi-filtered DataFrame:\n", + "\n", + "Unique insecticides: ['Deltamethrin']\n", + "Unique doses: [2.]\n", + "\n", + "DataFrame Info:\n", + "\n", + "Index: 48 entries, 40 to 87\n", + "Data columns (total 60 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 sample_id 48 non-null object \n", + " 1 country 48 non-null object \n", + " 2 location 48 non-null object \n", + " 3 insecticide 48 non-null object \n", + " 4 dose 48 non-null float64\n", + " 5 phenotype 48 non-null object \n", + " 6 sample_set 48 non-null object \n", + " 7 partner_sample_id 48 non-null object \n", + " 8 contributor 48 non-null object \n", + " 9 year 48 non-null int64 \n", + " 10 month 48 non-null int64 \n", + " 11 latitude 48 non-null float64\n", + " 12 longitude 48 non-null float64\n", + " 13 sex_call 48 non-null object \n", + " 14 release 48 non-null object \n", + " 15 quarter 48 non-null int64 \n", + " 16 study_id 48 non-null object \n", + " 17 study_url 48 non-null object \n", + " 18 terms_of_use_expiry_date 48 non-null object \n", + " 19 terms_of_use_url 48 non-null object \n", + " 20 unrestricted_use 48 non-null bool \n", + " 21 mean_cov 48 non-null Float64\n", + " 22 median_cov 48 non-null Int64 \n", + " 23 modal_cov 48 non-null Int64 \n", + " 24 mean_cov_2L 48 non-null Float64\n", + " 25 median_cov_2L 48 non-null Int64 \n", + " 26 mode_cov_2L 48 non-null Int64 \n", + " 27 mean_cov_2R 48 non-null Float64\n", + " 28 median_cov_2R 48 non-null Int64 \n", + " 29 mode_cov_2R 48 non-null Int64 \n", + " 30 mean_cov_3L 48 non-null Float64\n", + " 31 median_cov_3L 48 non-null Int64 \n", + " 32 mode_cov_3L 48 non-null Int64 \n", + " 33 mean_cov_3R 48 non-null Float64\n", + " 34 median_cov_3R 48 non-null Int64 \n", + " 35 mode_cov_3R 48 non-null Int64 \n", + " 36 mean_cov_X 48 non-null Float64\n", + " 37 median_cov_X 48 non-null Int64 \n", + " 38 mode_cov_X 48 non-null Int64 \n", + " 39 frac_gen_cov 48 non-null Float64\n", + " 40 divergence 48 non-null Float64\n", + " 41 contam_pct 48 non-null Float64\n", + " 42 contam_LLR 48 non-null Float64\n", + " 43 aim_species_fraction_arab 48 non-null float64\n", + " 44 aim_species_fraction_colu 48 non-null float64\n", + " 45 aim_species_fraction_colu_no2l 48 non-null float64\n", + " 46 aim_species_gambcolu_arabiensis 48 non-null object \n", + " 47 aim_species_gambiae_coluzzii 48 non-null object \n", + " 48 aim_species 48 non-null object \n", + " 49 country_iso 48 non-null object \n", + " 50 admin1_name 48 non-null object \n", + " 51 admin1_iso 48 non-null object \n", + " 52 admin2_name 48 non-null object \n", + " 53 taxon 48 non-null object \n", + " 54 cohort_admin1_year 48 non-null object \n", + " 55 cohort_admin1_month 48 non-null object \n", + " 56 cohort_admin1_quarter 48 non-null object \n", + " 57 cohort_admin2_year 48 non-null object \n", + " 58 cohort_admin2_month 48 non-null object \n", + " 59 cohort_admin2_quarter 48 non-null object \n", + "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", + "memory usage: 23.6+ KB\n" + ] + } + ], "source": [ "print(f\"\\n--- Loading phenotype data filtered by Deltamethrin and dose >= 1.0 ---\")\n", "df_filtered_multi = ag3.phenotype_data(\n", @@ -149,7 +667,7 @@ }, { "cell_type": "markdown", - "id": "10", + "id": "fc1cc12c-b24b-41f3-b147-9e4d817ab588", "metadata": {}, "source": [ "### Example 3: Applying cohort size filtering\n", @@ -158,10 +676,91 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "11", + "execution_count": 5, + "id": "de8cd777-a4b2-44dd-a0bf-64a6ef419da7", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Loading phenotype data with min_cohort_size=10 ---\n", + "Shape of DataFrame: (88, 60)\n", + "\n", + "First 5 rows of the cohort-filtered DataFrame:\n", + "\n", + "DataFrame Info:\n", + "\n", + "RangeIndex: 88 entries, 0 to 87\n", + "Data columns (total 60 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 sample_id 88 non-null object \n", + " 1 country 88 non-null object \n", + " 2 location 88 non-null object \n", + " 3 insecticide 88 non-null object \n", + " 4 dose 88 non-null float64\n", + " 5 phenotype 88 non-null object \n", + " 6 sample_set 88 non-null object \n", + " 7 partner_sample_id 88 non-null object \n", + " 8 contributor 88 non-null object \n", + " 9 year 88 non-null int64 \n", + " 10 month 88 non-null int64 \n", + " 11 latitude 88 non-null float64\n", + " 12 longitude 88 non-null float64\n", + " 13 sex_call 88 non-null object \n", + " 14 release 88 non-null object \n", + " 15 quarter 88 non-null int64 \n", + " 16 study_id 88 non-null object \n", + " 17 study_url 88 non-null object \n", + " 18 terms_of_use_expiry_date 88 non-null object \n", + " 19 terms_of_use_url 88 non-null object \n", + " 20 unrestricted_use 88 non-null bool \n", + " 21 mean_cov 88 non-null Float64\n", + " 22 median_cov 88 non-null Int64 \n", + " 23 modal_cov 88 non-null Int64 \n", + " 24 mean_cov_2L 88 non-null Float64\n", + " 25 median_cov_2L 88 non-null Int64 \n", + " 26 mode_cov_2L 88 non-null Int64 \n", + " 27 mean_cov_2R 88 non-null Float64\n", + " 28 median_cov_2R 88 non-null Int64 \n", + " 29 mode_cov_2R 88 non-null Int64 \n", + " 30 mean_cov_3L 88 non-null Float64\n", + " 31 median_cov_3L 88 non-null Int64 \n", + " 32 mode_cov_3L 88 non-null Int64 \n", + " 33 mean_cov_3R 88 non-null Float64\n", + " 34 median_cov_3R 88 non-null Int64 \n", + " 35 mode_cov_3R 88 non-null Int64 \n", + " 36 mean_cov_X 88 non-null Float64\n", + " 37 median_cov_X 88 non-null Int64 \n", + " 38 mode_cov_X 88 non-null Int64 \n", + " 39 frac_gen_cov 88 non-null Float64\n", + " 40 divergence 88 non-null Float64\n", + " 41 contam_pct 88 non-null Float64\n", + " 42 contam_LLR 88 non-null Float64\n", + " 43 aim_species_fraction_arab 88 non-null float64\n", + " 44 aim_species_fraction_colu 88 non-null float64\n", + " 45 aim_species_fraction_colu_no2l 88 non-null float64\n", + " 46 aim_species_gambcolu_arabiensis 88 non-null object \n", + " 47 aim_species_gambiae_coluzzii 88 non-null object \n", + " 48 aim_species 88 non-null object \n", + " 49 country_iso 88 non-null object \n", + " 50 admin1_name 88 non-null object \n", + " 51 admin1_iso 88 non-null object \n", + " 52 admin2_name 88 non-null object \n", + " 53 taxon 88 non-null object \n", + " 54 cohort_admin1_year 88 non-null object \n", + " 55 cohort_admin1_month 88 non-null object \n", + " 56 cohort_admin1_quarter 88 non-null object \n", + " 57 cohort_admin2_year 88 non-null object \n", + " 58 cohort_admin2_month 88 non-null object \n", + " 59 cohort_admin2_quarter 88 non-null object \n", + "dtypes: Float64(10), Int64(12), bool(1), float64(6), int64(3), object(28)\n", + "memory usage: 42.7+ KB\n" + ] + } + ], "source": [ "print(f\"\\n--- Loading phenotype data with min_cohort_size=10 ---\")\n", "df_cohort_filtered = ag3.phenotype_data(\n", @@ -188,10 +787,51 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "12", + "execution_count": 6, + "id": "9a1f4cc9-528f-40bf-9efe-71aee41c21c3", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Getting binary phenotype outcomes for '1237-VO-BJ-DJOGBENOU-VMF00050' ---\n", + "Shape of binary series: (88,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18949-5562STDY7801785 0.0\n", + "VBS18950-5562STDY7801786 0.0\n", + "VBS18951-5562STDY7801787 0.0\n", + "VBS18952-5562STDY7801788 0.0\n", + "VBS18953-5562STDY7801789 0.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [0. 1.]\n", + "\n", + "Shape of binary series (alive Deltamethrin): (48,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18995-5562STDY7801828 1.0\n", + "VBS18996-5562STDY7801829 1.0\n", + "VBS18998-5562STDY7801830 1.0\n", + "VBS18999-5562STDY7801831 1.0\n", + "VBS19000-5562STDY7801832 1.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [1.]\n", + "\n", + "Shape of binary series (dose 0.5): (40,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18949-5562STDY7801785 0.0\n", + "VBS18950-5562STDY7801786 0.0\n", + "VBS18951-5562STDY7801787 0.0\n", + "VBS18952-5562STDY7801788 0.0\n", + "VBS18953-5562STDY7801789 0.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [0.]\n" + ] + } + ], "source": [ "print(f\"\\n--- Getting binary phenotype outcomes for '{demo_sample_set}' ---\")\n", "\n", @@ -232,7 +872,7 @@ }, { "cell_type": "markdown", - "id": "13", + "id": "a92e430e-7f40-48a8-8c98-2405d27aabfb", "metadata": {}, "source": [ "## 4. Getting Binary Phenotype Outcomes with phenotype_binary\n", @@ -242,10 +882,51 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "14", + "execution_count": 7, + "id": "fda88368", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Getting binary phenotype outcomes for '1237-VO-BJ-DJOGBENOU-VMF00050' ---\n", + "Shape of binary series: (88,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18949-5562STDY7801785 0.0\n", + "VBS18950-5562STDY7801786 0.0\n", + "VBS18951-5562STDY7801787 0.0\n", + "VBS18952-5562STDY7801788 0.0\n", + "VBS18953-5562STDY7801789 0.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [0. 1.]\n", + "\n", + "Shape of binary series (alive Deltamethrin): (48,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18995-5562STDY7801828 1.0\n", + "VBS18996-5562STDY7801829 1.0\n", + "VBS18998-5562STDY7801830 1.0\n", + "VBS18999-5562STDY7801831 1.0\n", + "VBS19000-5562STDY7801832 1.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [1.]\n", + "\n", + "Shape of binary series (dose 0.5): (40,)\n", + "First 5 entries:\n", + "sample_id\n", + "VBS18949-5562STDY7801785 0.0\n", + "VBS18950-5562STDY7801786 0.0\n", + "VBS18951-5562STDY7801787 0.0\n", + "VBS18952-5562STDY7801788 0.0\n", + "VBS18953-5562STDY7801789 0.0\n", + "Name: phenotype_binary, dtype: float64\n", + "Unique values in series: [0.]\n" + ] + } + ], "source": [ "print(f\"\\n--- Getting binary phenotype outcomes for '{demo_sample_set}' ---\")\n", "\n", @@ -286,7 +967,7 @@ }, { "cell_type": "markdown", - "id": "15", + "id": "62e84ea0", "metadata": {}, "source": [ "## 5. Loading Phenotype Data Merged with SNP Calls\n", @@ -295,10 +976,64 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "16", + "execution_count": 8, + "id": "726ab8a3-6573-49d5-9b29-479176e5dee6", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Loading phenotype data merged with SNP calls ---\n", + "Dataset dimensions: FrozenMappingWarningOnValuesAccess({'samples': 48, 'variants': 10001, 'alleles': 4, 'ploidy': 2})\n", + "\n", + "Dataset structure (rich display):\n", + "\n", + "First 5 samples and their phenotype_binary values:\n", + "[1. 1. 1. 1. 1.]\n", + "\n", + "First 5 samples and their insecticide values:\n", + "['Deltamethrin' 'Deltamethrin' 'Deltamethrin' 'Deltamethrin'\n", + " 'Deltamethrin']\n", + "\n", + "First 5 variant positions:\n", + "[2420000 2420001 2420002 2420003 2420004]\n", + "\n", + "Dataset Info:\n", + "xarray.Dataset {\n", + "dimensions:\n", + "\tsamples = 48 ;\n", + "\tvariants = 10001 ;\n", + "\talleles = 4 ;\n", + "\tploidy = 2 ;\n", + "\n", + "variables:\n", + "\tfloat64 phenotype_binary(samples) ;\n", + "\tobject insecticide(samples) ;\n", + "\tfloat64 dose(samples) ;\n", + "\tobject phenotype(samples) ;\n", + "\tobject location(samples) ;\n", + "\tobject country(samples) ;\n", + "\tobject sample_set(samples) ;\n", + "\tobject samples(samples) ;\n", + "\t|S1 variant_allele(variants, alleles) ;\n", + "\tbool variant_filter_pass_gamb_colu_arab(variants) ;\n", + "\tbool variant_filter_pass_gamb_colu(variants) ;\n", + "\tbool variant_filter_pass_arab(variants) ;\n", + "\tint32 variant_position(variants) ;\n", + "\tuint8 variant_contig(variants) ;\n", + "\tint8 call_genotype(variants, samples, ploidy) ;\n", + "\tint16 call_GQ(variants, samples) ;\n", + "\tfloat32 call_MQ(variants, samples) ;\n", + "\tint16 call_AD(variants, samples, alleles) ;\n", + "\tbool call_genotype_mask(variants, samples, ploidy) ;\n", + "\n", + "// global attributes:\n", + "}" + ] + } + ], "source": [ "print(f\"\\n--- Loading phenotype data merged with SNP calls ---\")\n", "\n", @@ -327,7 +1062,7 @@ }, { "cell_type": "markdown", - "id": "17", + "id": "99e7b505-4ea4-43dc-91ae-14ac8f12076e", "metadata": {}, "source": [ "## 6. Loading Phenotype Data Merged with Haplotypes\n", @@ -336,10 +1071,57 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "18", + "execution_count": 9, + "id": "403f3a26-71eb-4781-975d-d94b7a021d97", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--- Loading phenotype data merged with Haplotypes ---\n", + "Dataset dimensions: FrozenMappingWarningOnValuesAccess({'samples': 40, 'variants': 2153, 'alleles': 2, 'ploidy': 2})\n", + "\n", + "Dataset structure (rich display):\n", + "\n", + "First 5 samples and their phenotype_binary values:\n", + "[0. 0. 0. 0. 0.]\n", + "\n", + "First 5 samples and their insecticide values:\n", + "['Deltamethrin' 'Deltamethrin' 'Deltamethrin' 'Deltamethrin'\n", + " 'Deltamethrin']\n", + "\n", + "First 5 variant positions:\n", + "[2420351 2420359 2420370 2420371 2420375]\n", + "\n", + "Dataset Info:\n", + "xarray.Dataset {\n", + "dimensions:\n", + "\tsamples = 40 ;\n", + "\tvariants = 2153 ;\n", + "\talleles = 2 ;\n", + "\tploidy = 2 ;\n", + "\n", + "variables:\n", + "\tfloat64 phenotype_binary(samples) ;\n", + "\tobject insecticide(samples) ;\n", + "\tfloat64 dose(samples) ;\n", + "\tobject phenotype(samples) ;\n", + "\tobject location(samples) ;\n", + "\tobject country(samples) ;\n", + "\tobject sample_set(samples) ;\n", + "\tobject samples(samples) ;\n", + "\tint32 variant_position(variants) ;\n", + "\tuint8 variant_contig(variants) ;\n", + "\t|S1 variant_allele(variants, alleles) ;\n", + "\tint8 call_genotype(variants, samples, ploidy) ;\n", + "\n", + "// global attributes:\n", + "}" + ] + } + ], "source": [ "print(f\"\\n--- Loading phenotype data merged with Haplotypes ---\")\n", "\n", @@ -368,7 +1150,7 @@ }, { "cell_type": "markdown", - "id": "19", + "id": "e2ca345f-33e9-481d-8cf6-0ec08253121c", "metadata": {}, "source": [ "## Conclusion\n", @@ -378,6 +1160,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -390,7 +1173,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.12.4" } }, "nbformat": 4, diff --git a/notebooks/plink_convert.ipynb b/notebooks/plink_convert.ipynb index 192a0ee1f..a82710ef2 100644 --- a/notebooks/plink_convert.ipynb +++ b/notebooks/plink_convert.ipynb @@ -29,6 +29,7 @@ ], "metadata": { "kernelspec": { + "display_name": "malariagen_plink", "language": "python", "name": "python3" }, @@ -41,7 +42,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/plot_aims.ipynb b/notebooks/plot_aims.ipynb index 0e045d92d..580a64a39 100644 --- a/notebooks/plot_aims.ipynb +++ b/notebooks/plot_aims.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "17ea65d6", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "8e5fa0a3", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "15a6c908", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "a2bfe151", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "446a82fb", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "2c181775", "metadata": {}, "outputs": [], "source": [] @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "98686752", "metadata": {}, "outputs": [], "source": [] @@ -84,6 +84,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -96,7 +97,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_cnv.ipynb b/notebooks/plot_cnv.ipynb index 666648045..87def583b 100644 --- a/notebooks/plot_cnv.ipynb +++ b/notebooks/plot_cnv.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a6b71675", "metadata": {}, "outputs": [], "source": [ @@ -14,7 +14,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "4526413e", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "5ef6e539", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ }, { "cell_type": "markdown", - "id": "3", + "id": "74c46a04", "metadata": {}, "source": [ "## CNV HMM coverage" @@ -49,7 +49,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "4ccf170b", "metadata": {}, "source": [ "### Ag3" @@ -58,7 +58,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "d6bb2a01", "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "acd1653f", "metadata": {}, "outputs": [], "source": [ @@ -86,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "f6bbcce7", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "300c961c", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "fc1acd04", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "e995780b", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ }, { "cell_type": "markdown", - "id": "11", + "id": "1de6d11f", "metadata": {}, "source": [ "### Af1" @@ -150,7 +150,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "3a94daf7", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "markdown", - "id": "13", + "id": "a302d86c", "metadata": {}, "source": [ "## CNV HMM heatmap" @@ -171,7 +171,7 @@ }, { "cell_type": "markdown", - "id": "14", + "id": "1e5b281f", "metadata": {}, "source": [ "### Ag3" @@ -180,7 +180,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "17a8a79d", "metadata": {}, "outputs": [], "source": [ @@ -193,7 +193,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "649a9194", "metadata": {}, "outputs": [], "source": [ @@ -206,7 +206,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "81b8ece4", "metadata": {}, "outputs": [], "source": [ @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "c8d588ae", "metadata": {}, "outputs": [], "source": [ @@ -233,7 +233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "54fc714b", "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "1d240bb8", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "ddc76e07", "metadata": {}, "outputs": [], "source": [ @@ -274,7 +274,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "cac3c68b", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ }, { "cell_type": "markdown", - "id": "23", + "id": "c566c8ac", "metadata": {}, "source": [ "### Af1" @@ -296,7 +296,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "5c4dcf97", "metadata": {}, "outputs": [], "source": [ @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "abdffd76", "metadata": {}, "outputs": [], "source": [] @@ -318,6 +318,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -330,7 +331,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_diplotype_clustering.ipynb b/notebooks/plot_diplotype_clustering.ipynb index 0f32ce3e8..83a7df3ea 100644 --- a/notebooks/plot_diplotype_clustering.ipynb +++ b/notebooks/plot_diplotype_clustering.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "d3f73666", "metadata": {}, "outputs": [], "source": [ @@ -12,7 +12,7 @@ }, { "cell_type": "markdown", - "id": "1", + "id": "0b889fd3", "metadata": {}, "source": [ "## Ag3" @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "ae9caa20-bdce-4b69-81f9-32d560caa5a2", "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "15d0bf3e-bbbe-4b67-a39d-c7ed5622cc3b", "metadata": {}, "outputs": [], "source": [ @@ -60,7 +60,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "92a9bdfd-d808-4c07-8bdd-f2eb3d1e5614", "metadata": {}, "outputs": [], "source": [ @@ -82,7 +82,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "b6976257-a5be-489f-940f-9e6c717394b1", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "ccb2366f", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "c0420334-124d-4bab-9ef7-bb9ceb99d6f0", "metadata": {}, "outputs": [], "source": [ @@ -145,7 +145,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "e957de19-af70-412a-8c75-2e6835ffb2cd", "metadata": {}, "outputs": [], "source": [ @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "857145af", "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "f41b7e63", "metadata": {}, "outputs": [], "source": [ @@ -208,7 +208,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "b93d6d94-1add-4ba4-8618-87a11c843e6e", "metadata": {}, "outputs": [], "source": [ @@ -227,7 +227,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "5773cf5a-6040-4ed9-8bdd-01d7f16408a7", "metadata": {}, "outputs": [], "source": [ @@ -247,7 +247,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "52c159c8-1751-4be7-92d9-52bd17751259", "metadata": {}, "outputs": [], "source": [ @@ -264,7 +264,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "7bd7b04c-5401-4c1e-92eb-cae5b3d87851", "metadata": {}, "outputs": [], "source": [ @@ -284,7 +284,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "9f6415e6-8d0d-4446-9adb-58c5b236dbcc", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "31df6632-8025-4f55-9d5d-9d04978b1690", "metadata": {}, "outputs": [], "source": [ @@ -322,7 +322,7 @@ }, { "cell_type": "markdown", - "id": "17", + "id": "6016ee62", "metadata": {}, "source": [ "## Af1" @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "87f36d07", "metadata": {}, "outputs": [], "source": [ @@ -347,7 +347,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "e1f68c6c", "metadata": {}, "outputs": [], "source": [ @@ -368,7 +368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "5bc93110", "metadata": {}, "outputs": [], "source": [ @@ -388,7 +388,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "45bdce7c", "metadata": {}, "outputs": [], "source": [ @@ -406,7 +406,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "5979cca3", "metadata": {}, "outputs": [], "source": [ @@ -426,7 +426,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "5318dd95-0621-47c1-a3d7-ccfe1950e73f", "metadata": {}, "outputs": [], "source": [] @@ -434,6 +434,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -446,12 +447,20 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.11" }, "vscode": { "interpreter": { "hash": "3b9ddb1005cd06989fd869b9e3d566470f1be01faa610bb17d64e58e32302e8b" } + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_diversity.ipynb b/notebooks/plot_diversity.ipynb index 4215cdcdd..d6d3cd17a 100644 --- a/notebooks/plot_diversity.ipynb +++ b/notebooks/plot_diversity.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a383fb19-cc62-4433-9f05-ba2709dd446b", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "56ea182c-2446-45ba-921a-a0b5cc1d413e", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "75759d4b-d0f8-4489-bda2-5d7d1d9adf17", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "531a2131-c2e1-42fc-85b6-09561b67c820", "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "e86a9ebd-5fba-4d6e-8ffb-6338d6a59e11", "metadata": {}, "outputs": [], "source": [ @@ -74,7 +74,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "da8bcab8-897f-4f5b-9058-137fb3ee1064", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "b3f385ed-d0f8-45da-9ae1-e8ef4f2360c3", "metadata": {}, "outputs": [], "source": [ @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "7b0b6f96-f292-446b-a231-6a82fb4fb808", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "63e55e75-ff85-46e1-b20f-4edd2a02ab92", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "149cab79-3f22-4a20-8a13-63f9319d466c", "metadata": {}, "outputs": [], "source": [ @@ -124,7 +124,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "1928463b-2461-4025-898f-dc05dc0cb214", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "fa7cad0a-e9cb-4d06-bece-298642fa79b3", "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "431f1274-fc55-4baa-8c67-f8f3d16d5874", "metadata": {}, "outputs": [], "source": [] @@ -152,6 +152,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -164,7 +165,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_frequencies_heatmap.ipynb b/notebooks/plot_frequencies_heatmap.ipynb index 1aa68d198..daab3576e 100644 --- a/notebooks/plot_frequencies_heatmap.ipynb +++ b/notebooks/plot_frequencies_heatmap.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "820bd2a0-eb8c-42e7-ba56-bef15ae7358a", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "702a2213", "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "2", + "id": "7607169c", "metadata": {}, "source": [ "## SNP allele frequencies" @@ -46,7 +46,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "ab3ddd98", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "204d0b93", "metadata": {}, "outputs": [], "source": [ @@ -72,7 +72,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "cc92d92f-31ed-4d1b-ac22-0282692db8c1", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "ea2ee8e2", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "60f9e53f", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "055a88cb", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "b41a1026", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "69ee0608", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "7bcfc20a", "metadata": {}, "outputs": [], "source": [ @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "86ee6d8a", "metadata": {}, "outputs": [], "source": [ @@ -164,7 +164,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "65c5093e", "metadata": {}, "outputs": [], "source": [ @@ -174,7 +174,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "14", + "id": "2a682de7", "metadata": {}, "source": [ "## Amino acid frequencies" @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "c24c45f6", "metadata": {}, "outputs": [], "source": [ @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "64066236", "metadata": {}, "outputs": [], "source": [ @@ -208,7 +208,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "3a83a404", "metadata": {}, "outputs": [], "source": [ @@ -218,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "d5a68fe6", "metadata": {}, "outputs": [], "source": [ @@ -230,7 +230,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "1fca6e11", "metadata": {}, "outputs": [], "source": [ @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "9d55aa57", "metadata": {}, "outputs": [], "source": [ @@ -256,7 +256,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "63f02680", "metadata": {}, "outputs": [], "source": [ @@ -271,7 +271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "a8895338", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "220945ee", "metadata": {}, "outputs": [], "source": [ @@ -296,7 +296,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "24", + "id": "7a9b4bc6", "metadata": {}, "source": [ "## Gene CNV frequencies" @@ -305,7 +305,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "8c914a1b", "metadata": {}, "outputs": [], "source": [ @@ -315,7 +315,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "edd39fc3", "metadata": {}, "outputs": [], "source": [ @@ -330,7 +330,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27", + "id": "fa51bcc3-90fc-4879-8366-b2ad80bc833b", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28", + "id": "763ed786", "metadata": {}, "outputs": [], "source": [ @@ -352,7 +352,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29", + "id": "f5099554", "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ { "cell_type": "code", "execution_count": null, - "id": "30", + "id": "f3c20291", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31", + "id": "86c5c594", "metadata": {}, "outputs": [], "source": [ @@ -402,7 +402,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32", + "id": "6d7ad130-30c2-4cd3-8906-a7ada3ccc75f", "metadata": {}, "outputs": [], "source": [ @@ -416,7 +416,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33", + "id": "83aab417-632e-4fd2-8da4-3ffdd6e233f6", "metadata": {}, "outputs": [], "source": [] @@ -424,6 +424,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -436,7 +437,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_frequencies_space_time.ipynb b/notebooks/plot_frequencies_space_time.ipynb index bb3977e0f..231d86aaa 100644 --- a/notebooks/plot_frequencies_space_time.ipynb +++ b/notebooks/plot_frequencies_space_time.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "47f669f3", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "f820bc66-2fb2-4ca2-9b54-824e50d61a0a", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "22b94b9c", "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "3", + "id": "865f02ea-0673-4d35-ad9e-33088e2d0e58", "metadata": {}, "source": [ "## Gene CNV frequencies" @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "1c612c69-27ee-4f50-b467-786bd998de58", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "7b38fb26-9562-4f52-9381-ced0687b5a40", "metadata": {}, "outputs": [], "source": [ @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "790c99e8", "metadata": {}, "outputs": [], "source": [ @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "1bfc7298", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "fb104e66-7ba0-42ec-9ed0-625a43b69d5b", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "ccf5279d-fc5a-4efe-972e-60c7b9515558", "metadata": {}, "outputs": [], "source": [ @@ -127,7 +127,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "10", + "id": "8d39da45-6875-42e1-9b84-2f0a64189ff4", "metadata": {}, "source": [ "## Amino acid change frequencies" @@ -136,7 +136,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "bf75e5b1-f2ca-41f4-a0fd-08a03c979fa4", "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "2c6ffd89-7edc-4f90-bd23-b03e15ce9714", "metadata": {}, "outputs": [], "source": [ @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "c058a196-2f78-49a0-8a18-cb2420c3278a", "metadata": {}, "outputs": [], "source": [ @@ -183,7 +183,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "e733c877-a1f1-4dc6-b8a3-a9652430ff39", "metadata": {}, "outputs": [], "source": [ @@ -193,7 +193,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "82927720", "metadata": {}, "outputs": [], "source": [ @@ -203,7 +203,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "5f9257e0", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "94ccc5bf", "metadata": {}, "outputs": [], "source": [ @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "10d0004b", "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "19", + "id": "9b189c4f-fbf6-45cf-96ef-04817084b5ec", "metadata": {}, "source": [ "## SNP allele frequencies" @@ -250,7 +250,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "c3738721-8d16-40dd-8a4d-4b588af36b15", "metadata": {}, "outputs": [], "source": [ @@ -273,7 +273,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "5c743429", "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "e16ab3fe", "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "26af27a1", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "9f6a7920", "metadata": {}, "outputs": [], "source": [ @@ -322,7 +322,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "03cfc0e7", "metadata": {}, "outputs": [], "source": [ @@ -332,7 +332,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "28922f73-f38d-424a-a9c5-1e839c86567b", "metadata": {}, "outputs": [], "source": [ @@ -350,7 +350,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27", + "id": "2a8ea4a0-6bf7-41a3-b734-06535e7dbbc8", "metadata": {}, "outputs": [], "source": [ @@ -360,7 +360,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28", + "id": "5ce2800c-dfa5-49c3-bde4-3b67423f7807", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ { "cell_type": "code", "execution_count": null, - "id": "29", + "id": "b0f6bda5", "metadata": {}, "outputs": [], "source": [ @@ -387,7 +387,7 @@ }, { "cell_type": "markdown", - "id": "30", + "id": "a94d6521", "metadata": {}, "source": [ "### SNP allele frequencies using `taxon_by`" @@ -396,7 +396,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31", + "id": "0cf222ee", "metadata": {}, "outputs": [], "source": [ @@ -420,7 +420,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32", + "id": "2b7e9acc", "metadata": {}, "outputs": [], "source": [ @@ -430,14 +430,14 @@ { "cell_type": "code", "execution_count": null, - "id": "33", + "id": "2c3227e4", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", - "id": "34", + "id": "eb89088f", "metadata": {}, "source": [ "### SNP allele frequencies using a custom `period_by`" @@ -446,7 +446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35", + "id": "bd7856d2", "metadata": {}, "outputs": [], "source": [ @@ -456,7 +456,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36", + "id": "8a54c978", "metadata": {}, "outputs": [], "source": [ @@ -467,7 +467,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37", + "id": "a36cd399", "metadata": {}, "outputs": [], "source": [ @@ -478,7 +478,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38", + "id": "1087bada", "metadata": {}, "outputs": [], "source": [ @@ -489,7 +489,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39", + "id": "018e9a59", "metadata": {}, "outputs": [], "source": [ @@ -504,7 +504,7 @@ { "cell_type": "code", "execution_count": null, - "id": "40", + "id": "454c36d9", "metadata": {}, "outputs": [], "source": [ @@ -514,7 +514,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41", + "id": "6b078bd1", "metadata": {}, "outputs": [], "source": [ @@ -524,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "42", + "id": "33d392d3", "metadata": {}, "outputs": [], "source": [ @@ -534,7 +534,7 @@ { "cell_type": "code", "execution_count": null, - "id": "43", + "id": "71bf535c", "metadata": {}, "outputs": [], "source": [ @@ -544,7 +544,7 @@ { "cell_type": "code", "execution_count": null, - "id": "44", + "id": "72feb026", "metadata": {}, "outputs": [], "source": [ @@ -554,7 +554,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45", + "id": "31b9acee", "metadata": {}, "outputs": [], "source": [ @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "46", + "id": "16ac5eb6", "metadata": {}, "outputs": [], "source": [ @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47", + "id": "d22d6d58", "metadata": {}, "outputs": [], "source": [] @@ -587,6 +587,7 @@ ], "metadata": { "kernelspec": { + "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -599,7 +600,694 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.11.5" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": { + "07e9e6c0ec1c4d508dcea9a114ac0b0a": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "move", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "11daaa1c092d4087a034542d7be112d8": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletTileLayerModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletTileLayerModel", + "_view_name": "ErrorWidgetView", + "attribution": "© OpenStreetMap contributors", + "base": true, + "bottom": true, + "bounds": null, + "detect_retina": false, + "error": {}, + "loading": false, + "max_native_zoom": null, + "max_zoom": 19, + "min_native_zoom": null, + "min_zoom": 1, + "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", + "name": "OpenStreetMap.Mapnik", + "no_wrap": false, + "opacity": 1, + "options": [ + "attribution", + "bounds", + "detect_retina", + "max_native_zoom", + "max_zoom", + "min_native_zoom", + "min_zoom", + "no_wrap", + "tile_size", + "tms", + "zoom_offset" + ], + "pane": "", + "popup": null, + "popup_max_height": null, + "popup_max_width": 300, + "popup_min_width": 50, + "show_loading": false, + "subitems": [], + "tile_size": 256, + "tms": false, + "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + "visible": true, + "zoom_offset": 0 + } + }, + "17ce13191ef8482596ea4952c7a52bc9": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletAttributionControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletAttributionControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "prefix" + ], + "position": "bottomright", + "prefix": "ipyleaflet" + } + }, + "23a5c26c626a4d0a80140ed91ac45b31": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "4adf518de8f14f06a6a26b1da007107c": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletZoomControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletZoomControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "zoom_in_text", + "zoom_in_title", + "zoom_out_text", + "zoom_out_title" + ], + "position": "topleft", + "zoom_in_text": "+", + "zoom_in_title": "Zoom in", + "zoom_out_text": "-", + "zoom_out_title": "Zoom out" + } + }, + "61c564b2766a467daf09f6d22add5730": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "62fb525b1c3646ca9e6b45cb3515a0f5": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "move", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "66c6ef459b264db2893c627f45bdde3a": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "move", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "7caf3c5c54274e9b9d93641bdb7a9339": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "87119c6f04ac46628c069e5742f7ce08": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapModel", + "_view_name": "ErrorWidgetView", + "bottom": 0, + "bounce_at_zoom_limits": true, + "box_zoom": true, + "center": [ + -2, + 20 + ], + "close_popup_on_click": true, + "controls": [ + "IPY_MODEL_f47067463b3a4c42b9e29e76528a5735", + "IPY_MODEL_17ce13191ef8482596ea4952c7a52bc9" + ], + "crs": { + "custom": false, + "name": "EPSG3857" + }, + "default_style": "IPY_MODEL_7caf3c5c54274e9b9d93641bdb7a9339", + "double_click_zoom": true, + "dragging": true, + "dragging_style": "IPY_MODEL_62fb525b1c3646ca9e6b45cb3515a0f5", + "east": 0, + "error": {}, + "fullscreen": false, + "inertia": true, + "inertia_deceleration": 3000, + "inertia_max_speed": 1500, + "interpolation": "bilinear", + "keyboard": true, + "keyboard_pan_offset": 80, + "keyboard_zoom_offset": 1, + "layers": [ + "IPY_MODEL_11daaa1c092d4087a034542d7be112d8" + ], + "layout": "IPY_MODEL_9cfcb8f8e7aa45b6b3b944a6aae9f28e", + "left": 9007199254740991, + "max_zoom": null, + "min_zoom": null, + "modisdate": "2022-12-22", + "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", + "north": 0, + "options": [ + "bounce_at_zoom_limits", + "box_zoom", + "center", + "close_popup_on_click", + "double_click_zoom", + "dragging", + "fullscreen", + "inertia", + "inertia_deceleration", + "inertia_max_speed", + "interpolation", + "keyboard", + "keyboard_pan_offset", + "keyboard_zoom_offset", + "max_zoom", + "min_zoom", + "prefer_canvas", + "scroll_wheel_zoom", + "tap", + "tap_tolerance", + "touch_zoom", + "world_copy_jump", + "zoom", + "zoom_animation_threshold", + "zoom_delta", + "zoom_snap" + ], + "panes": {}, + "prefer_canvas": false, + "right": 0, + "scroll_wheel_zoom": false, + "south": 0, + "style": "IPY_MODEL_cdb18012556e4a548d1696617b42e52a", + "tap": true, + "tap_tolerance": 15, + "top": 9007199254740991, + "touch_zoom": true, + "west": 0, + "window_url": "", + "world_copy_jump": false, + "zoom": 3, + "zoom_animation_threshold": 4, + "zoom_delta": 1, + "zoom_snap": 1 + } + }, + "9aeaff05b3cd4ad481b58cba4903c26a": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "aafb5325f81749efa3385c31feff90b0": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletZoomControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletZoomControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "zoom_in_text", + "zoom_in_title", + "zoom_out_text", + "zoom_out_title" + ], + "position": "topleft", + "zoom_in_text": "+", + "zoom_in_title": "Zoom in", + "zoom_out_text": "-", + "zoom_out_title": "Zoom out" + } + }, + "c25a9ad7c44e4fa194988bd6143b4a38": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletAttributionControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletAttributionControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "prefix" + ], + "position": "bottomright", + "prefix": "ipyleaflet" + } + }, + "cdb18012556e4a548d1696617b42e52a": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "cdb3d44557d74e8494dd753f4461fa4f": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapModel", + "_view_name": "ErrorWidgetView", + "bottom": 0, + "bounce_at_zoom_limits": true, + "box_zoom": true, + "center": [ + -2, + 20 + ], + "close_popup_on_click": true, + "controls": [ + "IPY_MODEL_aafb5325f81749efa3385c31feff90b0", + "IPY_MODEL_e58d799116564ba082f693bab2ca6d26" + ], + "crs": { + "custom": false, + "name": "EPSG3857" + }, + "default_style": "IPY_MODEL_d2fb36e653324e9fb8d26258bd1cd46e", + "double_click_zoom": true, + "dragging": true, + "dragging_style": "IPY_MODEL_07e9e6c0ec1c4d508dcea9a114ac0b0a", + "east": 0, + "error": {}, + "fullscreen": false, + "inertia": true, + "inertia_deceleration": 3000, + "inertia_max_speed": 1500, + "interpolation": "bilinear", + "keyboard": true, + "keyboard_pan_offset": 80, + "keyboard_zoom_offset": 1, + "layers": [ + "IPY_MODEL_f000402c088144dabd3ea1d8506af240" + ], + "layout": "IPY_MODEL_c047232214b9406590eee50bbe5401d2", + "left": 9007199254740991, + "max_zoom": null, + "min_zoom": null, + "modisdate": "2022-12-22", + "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", + "north": 0, + "options": [ + "bounce_at_zoom_limits", + "box_zoom", + "center", + "close_popup_on_click", + "double_click_zoom", + "dragging", + "fullscreen", + "inertia", + "inertia_deceleration", + "inertia_max_speed", + "interpolation", + "keyboard", + "keyboard_pan_offset", + "keyboard_zoom_offset", + "max_zoom", + "min_zoom", + "prefer_canvas", + "scroll_wheel_zoom", + "tap", + "tap_tolerance", + "touch_zoom", + "world_copy_jump", + "zoom", + "zoom_animation_threshold", + "zoom_delta", + "zoom_snap" + ], + "panes": {}, + "prefer_canvas": false, + "right": 0, + "scroll_wheel_zoom": false, + "south": 0, + "style": "IPY_MODEL_23a5c26c626a4d0a80140ed91ac45b31", + "tap": true, + "tap_tolerance": 15, + "top": 9007199254740991, + "touch_zoom": true, + "west": 0, + "window_url": "", + "world_copy_jump": false, + "zoom": 3, + "zoom_animation_threshold": 4, + "zoom_delta": 1, + "zoom_snap": 1 + } + }, + "d2fb36e653324e9fb8d26258bd1cd46e": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapStyleModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapStyleModel", + "_view_name": "ErrorWidgetView", + "cursor": "grab", + "error": {}, + "msg": "Failed to load model class 'LeafletMapStyleModel' from module 'jupyter-leaflet'" + } + }, + "e58d799116564ba082f693bab2ca6d26": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletAttributionControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletAttributionControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletAttributionControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "prefix" + ], + "position": "bottomright", + "prefix": "ipyleaflet" + } + }, + "e59db8352cbb4a5c9d9ecaed8611159e": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletMapModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletMapModel", + "_view_name": "ErrorWidgetView", + "bottom": 0, + "bounce_at_zoom_limits": true, + "box_zoom": true, + "center": [ + -2, + 20 + ], + "close_popup_on_click": true, + "controls": [ + "IPY_MODEL_4adf518de8f14f06a6a26b1da007107c", + "IPY_MODEL_c25a9ad7c44e4fa194988bd6143b4a38" + ], + "crs": { + "custom": false, + "name": "EPSG3857" + }, + "default_style": "IPY_MODEL_9aeaff05b3cd4ad481b58cba4903c26a", + "double_click_zoom": true, + "dragging": true, + "dragging_style": "IPY_MODEL_66c6ef459b264db2893c627f45bdde3a", + "east": 0, + "error": {}, + "fullscreen": false, + "inertia": true, + "inertia_deceleration": 3000, + "inertia_max_speed": 1500, + "interpolation": "bilinear", + "keyboard": true, + "keyboard_pan_offset": 80, + "keyboard_zoom_offset": 1, + "layers": [ + "IPY_MODEL_f72eb35d576b4a51ab743a0427bdab68" + ], + "layout": "IPY_MODEL_a44bea80c0824335ba071b309104e454", + "left": 9007199254740991, + "max_zoom": null, + "min_zoom": null, + "modisdate": "2022-12-22", + "msg": "Failed to load model class 'LeafletMapModel' from module 'jupyter-leaflet'", + "north": 0, + "options": [ + "bounce_at_zoom_limits", + "box_zoom", + "center", + "close_popup_on_click", + "double_click_zoom", + "dragging", + "fullscreen", + "inertia", + "inertia_deceleration", + "inertia_max_speed", + "interpolation", + "keyboard", + "keyboard_pan_offset", + "keyboard_zoom_offset", + "max_zoom", + "min_zoom", + "prefer_canvas", + "scroll_wheel_zoom", + "tap", + "tap_tolerance", + "touch_zoom", + "world_copy_jump", + "zoom", + "zoom_animation_threshold", + "zoom_delta", + "zoom_snap" + ], + "panes": {}, + "prefer_canvas": false, + "right": 0, + "scroll_wheel_zoom": false, + "south": 0, + "style": "IPY_MODEL_61c564b2766a467daf09f6d22add5730", + "tap": true, + "tap_tolerance": 15, + "top": 9007199254740991, + "touch_zoom": true, + "west": 0, + "window_url": "", + "world_copy_jump": false, + "zoom": 3, + "zoom_animation_threshold": 4, + "zoom_delta": 1, + "zoom_snap": 1 + } + }, + "f000402c088144dabd3ea1d8506af240": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletTileLayerModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletTileLayerModel", + "_view_name": "ErrorWidgetView", + "attribution": "© OpenStreetMap contributors", + "base": true, + "bottom": true, + "bounds": null, + "detect_retina": false, + "error": {}, + "loading": false, + "max_native_zoom": null, + "max_zoom": 19, + "min_native_zoom": null, + "min_zoom": 1, + "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", + "name": "OpenStreetMap.Mapnik", + "no_wrap": false, + "opacity": 1, + "options": [ + "attribution", + "bounds", + "detect_retina", + "max_native_zoom", + "max_zoom", + "min_native_zoom", + "min_zoom", + "no_wrap", + "tile_size", + "tms", + "zoom_offset" + ], + "pane": "", + "popup": null, + "popup_max_height": null, + "popup_max_width": 300, + "popup_min_width": 50, + "show_loading": false, + "subitems": [], + "tile_size": 256, + "tms": false, + "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + "visible": true, + "zoom_offset": 0 + } + }, + "f47067463b3a4c42b9e29e76528a5735": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletZoomControlModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletZoomControlModel", + "_view_name": "ErrorWidgetView", + "error": {}, + "msg": "Failed to load model class 'LeafletZoomControlModel' from module 'jupyter-leaflet'", + "options": [ + "position", + "zoom_in_text", + "zoom_in_title", + "zoom_out_text", + "zoom_out_title" + ], + "position": "topleft", + "zoom_in_text": "+", + "zoom_in_title": "Zoom in", + "zoom_out_text": "-", + "zoom_out_title": "Zoom out" + } + }, + "f72eb35d576b4a51ab743a0427bdab68": { + "model_module": "jupyter-leaflet", + "model_module_version": "2.0.0", + "model_name": "LeafletTileLayerModel", + "state": { + "_model_module": "jupyter-leaflet", + "_model_name": "LeafletTileLayerModel", + "_view_name": "ErrorWidgetView", + "attribution": "© OpenStreetMap contributors", + "base": true, + "bottom": true, + "bounds": null, + "detect_retina": false, + "error": {}, + "loading": false, + "max_native_zoom": null, + "max_zoom": 19, + "min_native_zoom": null, + "min_zoom": 1, + "msg": "Failed to load model class 'LeafletTileLayerModel' from module 'jupyter-leaflet'", + "name": "OpenStreetMap.Mapnik", + "no_wrap": false, + "opacity": 1, + "options": [ + "attribution", + "bounds", + "detect_retina", + "max_native_zoom", + "max_zoom", + "min_native_zoom", + "min_zoom", + "no_wrap", + "tile_size", + "tms", + "zoom_offset" + ], + "pane": "", + "popup": null, + "popup_max_height": null, + "popup_max_width": 300, + "popup_min_width": 50, + "show_loading": false, + "subitems": [], + "tile_size": 256, + "tms": false, + "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + "visible": true, + "zoom_offset": 0 + } + } + }, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_fst_gwss.ipynb b/notebooks/plot_fst_gwss.ipynb index 4b89cca28..a627356d6 100644 --- a/notebooks/plot_fst_gwss.ipynb +++ b/notebooks/plot_fst_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a31720f1", "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "ece45863", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "30c285b1-533c-409c-ad40-86ffed0a9e41", "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "effd3060", "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "8e747d9a", "metadata": {}, "outputs": [], "source": [ @@ -87,7 +87,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "b63d02fe", "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "f77bbae1", "metadata": {}, "outputs": [], "source": [ @@ -123,7 +123,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "1b87b2f2", "metadata": {}, "outputs": [], "source": [ @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "9e3fc1c8", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "9875e22f", "metadata": {}, "outputs": [], "source": [] @@ -165,7 +165,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "950fe2b8", "metadata": {}, "outputs": [], "source": [] @@ -173,6 +173,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -185,7 +186,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_g123_gwss.ipynb b/notebooks/plot_g123_gwss.ipynb index 79fd65732..f2f31a42f 100644 --- a/notebooks/plot_g123_gwss.ipynb +++ b/notebooks/plot_g123_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a31720f1", "metadata": {}, "outputs": [], "source": [ @@ -21,7 +21,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "ece45863", "metadata": {}, "outputs": [], "source": [ @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "9ada4f50-bfc0-4524-96de-8903896c7c68", "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "44ff6b91-cc69-4683-b408-45f199816d9a", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "db33f6d9", "metadata": {}, "outputs": [], "source": [ @@ -79,7 +79,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "a585cbba-ea63-4fd9-97ca-d97a3a4f163a", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "effd3060", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "efe89451-f05b-4e55-83ef-0f85204f4b04", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "8e747d9a", "metadata": {}, "outputs": [], "source": [ @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "b63d02fe", "metadata": {}, "outputs": [], "source": [ @@ -175,7 +175,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "e6d69754-951c-48be-9eaf-c3ff2ead80b4", "metadata": {}, "outputs": [], "source": [ @@ -194,7 +194,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "f4c9c960-0f72-497d-9938-4dc9516498c8", "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "cd3c2a2d", "metadata": {}, "outputs": [], "source": [ @@ -216,7 +216,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "1b87b2f2", "metadata": {}, "outputs": [], "source": [ @@ -234,7 +234,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "9e3fc1c8", "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "6ef172dc-e697-4a6c-b63d-d8841aca3b97", "metadata": {}, "outputs": [], "source": [] @@ -260,6 +260,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -272,7 +273,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_genes.ipynb b/notebooks/plot_genes.ipynb index d72d7e8a2..8e7e9ff02 100644 --- a/notebooks/plot_genes.ipynb +++ b/notebooks/plot_genes.ipynb @@ -3,8 +3,15 @@ { "cell_type": "code", "execution_count": null, - "id": "0", - "metadata": {}, + "id": "381912bf", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:27.950846Z", + "iopub.status.busy": "2022-03-09T18:09:27.950618Z", + "iopub.status.idle": "2022-03-09T18:09:29.094180Z", + "shell.execute_reply": "2022-03-09T18:09:29.093711Z" + } + }, "outputs": [], "source": [ "import malariagen_data\n", @@ -15,8 +22,15 @@ { "cell_type": "code", "execution_count": null, - "id": "1", - "metadata": {}, + "id": "d1f1824b", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:29.096307Z", + "iopub.status.busy": "2022-03-09T18:09:29.096169Z", + "iopub.status.idle": "2022-03-09T18:09:29.271174Z", + "shell.execute_reply": "2022-03-09T18:09:29.270693Z" + } + }, "outputs": [], "source": [ "ag3 = malariagen_data.Ag3(\n", @@ -29,8 +43,15 @@ { "cell_type": "code", "execution_count": null, - "id": "2", - "metadata": {}, + "id": "f54b8381", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:29.273487Z", + "iopub.status.busy": "2022-03-09T18:09:29.273298Z", + "iopub.status.idle": "2022-03-09T18:09:31.492555Z", + "shell.execute_reply": "2022-03-09T18:09:31.492104Z" + } + }, "outputs": [], "source": [ "ag3.plot_genes(\"2R\")" @@ -39,8 +60,15 @@ { "cell_type": "code", "execution_count": null, - "id": "3", - "metadata": {}, + "id": "6c6865ac", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:31.499205Z", + "iopub.status.busy": "2022-03-09T18:09:31.499024Z", + "iopub.status.idle": "2022-03-09T18:09:31.551337Z", + "shell.execute_reply": "2022-03-09T18:09:31.550930Z" + } + }, "outputs": [], "source": [ "ag3.plot_genes(\"2R:28,000,000-29,000,000\")" @@ -49,8 +77,15 @@ { "cell_type": "code", "execution_count": null, - "id": "4", - "metadata": {}, + "id": "40b63386", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:31.553318Z", + "iopub.status.busy": "2022-03-09T18:09:31.553187Z", + "iopub.status.idle": "2022-03-09T18:09:31.702387Z", + "shell.execute_reply": "2022-03-09T18:09:31.701939Z" + } + }, "outputs": [], "source": [ "fig = bklay.column(\n", @@ -66,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "4df200c7", "metadata": {}, "outputs": [], "source": [ @@ -76,8 +111,15 @@ { "cell_type": "code", "execution_count": null, - "id": "6", - "metadata": {}, + "id": "066fb262", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:31.712754Z", + "iopub.status.busy": "2022-03-09T18:09:31.712597Z", + "iopub.status.idle": "2022-03-09T18:09:33.866554Z", + "shell.execute_reply": "2022-03-09T18:09:33.865947Z" + } + }, "outputs": [], "source": [ "ag3.plot_transcript(\"AGAP004707-RD\")" @@ -86,7 +128,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "8694654d", "metadata": {}, "outputs": [], "source": [ @@ -96,8 +138,15 @@ { "cell_type": "code", "execution_count": null, - "id": "8", - "metadata": {}, + "id": "ce93e47e", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:33.868626Z", + "iopub.status.busy": "2022-03-09T18:09:33.868483Z", + "iopub.status.idle": "2022-03-09T18:09:34.121104Z", + "shell.execute_reply": "2022-03-09T18:09:34.120683Z" + } + }, "outputs": [], "source": [ "ag3.plot_transcript(\"AGAP004050-RA\")" @@ -106,8 +155,15 @@ { "cell_type": "code", "execution_count": null, - "id": "9", - "metadata": {}, + "id": "86178607", + "metadata": { + "execution": { + "iopub.execute_input": "2022-03-09T18:09:34.123309Z", + "iopub.status.busy": "2022-03-09T18:09:34.123167Z", + "iopub.status.idle": "2022-03-09T18:09:35.690698Z", + "shell.execute_reply": "2022-03-09T18:09:35.690292Z" + } + }, "outputs": [], "source": [ "fig1 = ag3.plot_transcript(f\"AGAP004707-RA\", show=False)\n", @@ -128,7 +184,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "be70a93a", "metadata": {}, "outputs": [], "source": [ @@ -142,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "48814614", "metadata": {}, "outputs": [], "source": [ @@ -152,7 +208,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "0c3399fa", "metadata": {}, "outputs": [], "source": [ @@ -162,7 +218,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "0ed22cf1", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +228,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "0589ed21", "metadata": {}, "outputs": [], "source": [ @@ -182,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "c27741d9", "metadata": {}, "outputs": [], "source": [ @@ -202,7 +258,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "523197c3", "metadata": {}, "outputs": [], "source": [ @@ -238,7 +294,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "e2a3a927", "metadata": {}, "outputs": [], "source": [] @@ -246,6 +302,7 @@ ], "metadata": { "kernelspec": { + "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -258,7 +315,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.11.5" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_h12_h1x.ipynb b/notebooks/plot_h12_h1x.ipynb index f253a5b40..2f751b5c8 100644 --- a/notebooks/plot_h12_h1x.ipynb +++ b/notebooks/plot_h12_h1x.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "ced974cd", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "9d17216f", "metadata": { "tags": [] }, @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "2", + "id": "a67ec21b", "metadata": {}, "source": [ "## Ag3" @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "65b7ff2f", "metadata": { "tags": [] }, @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "ac276861-43fb-4f09-b004-57487d75aa41", "metadata": { "tags": [] }, @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "a7c10446", "metadata": { "tags": [] }, @@ -82,7 +82,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "b0d308fe-4e8a-412f-9487-7f1c29d3323a", "metadata": { "tags": [] }, @@ -99,7 +99,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "63cb17ff", "metadata": { "tags": [] }, @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "4470d24c-8cf1-4d22-b774-0121b4560e27", "metadata": {}, "outputs": [], "source": [ @@ -135,7 +135,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "cd125828", "metadata": { "tags": [] }, @@ -155,7 +155,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "5716e777", "metadata": { "tags": [] }, @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "fe11bb35", "metadata": { "tags": [] }, @@ -194,7 +194,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "b4b7a8d2-95d0-48dc-a32f-3bc96aacfb9f", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "73e0e746-add1-4774-bced-461c9742bd95", "metadata": { "tags": [] }, @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "67f48075-6b79-4722-82f7-278bd0868410", "metadata": { "tags": [] }, @@ -244,7 +244,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "c3e4622b-31e9-444a-8a09-1590862709fe", "metadata": { "tags": [] }, @@ -262,7 +262,7 @@ }, { "cell_type": "markdown", - "id": "16", + "id": "2801861c", "metadata": {}, "source": [ "## Af1" @@ -271,7 +271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "9144452f", "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "c5d835e1", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "1aaa0573-723c-43b1-baea-750172c4dabc", "metadata": {}, "outputs": [], "source": [] @@ -309,7 +309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "ffc7dc06-6bdb-42d2-a1fb-878612d10dd1", "metadata": {}, "outputs": [], "source": [] @@ -317,7 +317,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "89b1cd80", "metadata": {}, "outputs": [], "source": [ @@ -333,7 +333,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "82cefa93", "metadata": {}, "outputs": [], "source": [ @@ -349,7 +349,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "981ba052-1960-4f2e-ba91-72ac442ca178", "metadata": { "tags": [] }, @@ -368,7 +368,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "e3296b4c-cd72-436f-b21a-d210c7520c39", "metadata": { "tags": [] }, @@ -386,7 +386,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "1a60cc83-cf30-4152-9eb0-dae7c00ac41b", "metadata": { "tags": [] }, @@ -404,7 +404,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "a3b1c22e", "metadata": {}, "outputs": [], "source": [ @@ -427,6 +427,7 @@ "uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m125" }, "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -439,12 +440,20 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.11" }, "vscode": { "interpreter": { "hash": "3b9ddb1005cd06989fd869b9e3d566470f1be01faa610bb17d64e58e32302e8b" } + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_haplotype_clustering.ipynb b/notebooks/plot_haplotype_clustering.ipynb index 8c1e37492..f035681b9 100644 --- a/notebooks/plot_haplotype_clustering.ipynb +++ b/notebooks/plot_haplotype_clustering.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "d3f73666", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "1", + "id": "0b889fd3", "metadata": {}, "source": [ "## Ag3" @@ -22,7 +22,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "38abbb28", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "60bd6d1f-e8bd-499e-8c78-e64d2d7e9210", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "04e74ac9-51db-4bae-875c-1ee50e02d024", "metadata": {}, "outputs": [], "source": [ @@ -81,7 +81,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "637ae668-c3b8-4914-a0c2-1587cc252c0c", "metadata": {}, "outputs": [], "source": [ @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "9bca4ab4-89b4-4238-9f82-d7920e107583", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "ccb2366f", "metadata": {}, "outputs": [], "source": [ @@ -132,7 +132,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "c0420334-124d-4bab-9ef7-bb9ceb99d6f0", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "e957de19-af70-412a-8c75-2e6835ffb2cd", "metadata": {}, "outputs": [], "source": [ @@ -176,7 +176,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "857145af", "metadata": {}, "outputs": [], "source": [ @@ -197,7 +197,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "f41b7e63", "metadata": {}, "outputs": [], "source": [ @@ -216,7 +216,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "b93d6d94-1add-4ba4-8618-87a11c843e6e", "metadata": {}, "outputs": [], "source": [ @@ -235,7 +235,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "5773cf5a-6040-4ed9-8bdd-01d7f16408a7", "metadata": {}, "outputs": [], "source": [ @@ -255,7 +255,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "52c159c8-1751-4be7-92d9-52bd17751259", "metadata": {}, "outputs": [], "source": [ @@ -272,7 +272,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "7bd7b04c-5401-4c1e-92eb-cae5b3d87851", "metadata": {}, "outputs": [], "source": [ @@ -291,7 +291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "9f6415e6-8d0d-4446-9adb-58c5b236dbcc", "metadata": {}, "outputs": [], "source": [ @@ -310,7 +310,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "31df6632-8025-4f55-9d5d-9d04978b1690", "metadata": {}, "outputs": [], "source": [ @@ -331,7 +331,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "51846e18", "metadata": {}, "outputs": [], "source": [ @@ -354,7 +354,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "19", + "id": "6016ee62", "metadata": {}, "source": [ "## Af1" @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "87f36d07", "metadata": {}, "outputs": [], "source": [ @@ -379,7 +379,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "e1f68c6c", "metadata": {}, "outputs": [], "source": [ @@ -399,7 +399,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "5bc93110", "metadata": {}, "outputs": [], "source": [ @@ -419,7 +419,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "45bdce7c", "metadata": {}, "outputs": [], "source": [ @@ -437,7 +437,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "5979cca3", "metadata": {}, "outputs": [], "source": [] @@ -445,6 +445,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -457,7 +458,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.12.8" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_haplotype_networks.ipynb b/notebooks/plot_haplotype_networks.ipynb index 7088b6725..0ecc0d121 100644 --- a/notebooks/plot_haplotype_networks.ipynb +++ b/notebooks/plot_haplotype_networks.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0", + "id": "f6b86889", "metadata": {}, "source": [ "# Haplotype Network Plotting Examples\n", @@ -12,7 +12,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "1cadfacf", "metadata": {}, "outputs": [], "source": [ @@ -22,7 +22,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "2", + "id": "dcfe9fab", "metadata": {}, "source": [ "## Ag3" @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "0ebfe96b", "metadata": {}, "outputs": [], "source": [ @@ -47,7 +47,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "4", + "id": "e3ffe116", "metadata": {}, "source": [ "N.B., manually specifying the server_port parameter doesn't seem to be necessary on colab, but is needed when running locally via Jupyter notebook, otherwise get \"Address already in use\" error and cannot run multiple plots in same notebook." @@ -55,7 +55,7 @@ }, { "cell_type": "markdown", - "id": "5", + "id": "e5687f24", "metadata": {}, "source": [ "## Example 1: Direct Column Name (String)\n", @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "81ceebb1-2316-4a0f-bf85-55cc561ab00c", "metadata": {}, "outputs": [], "source": [ @@ -82,7 +82,7 @@ }, { "cell_type": "markdown", - "id": "7", + "id": "2798b459", "metadata": {}, "source": [ "## Example 2: Cohorts Prefix (String)\n", @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "3206fc04-1074-4f6c-8130-81dadff05c72", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ }, { "cell_type": "markdown", - "id": "9", + "id": "44c6a40b", "metadata": {}, "source": [ "This example uses a dictionary to define custom color groups based on conditions applied to the `\"country\"` column." @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "8236cd99", "metadata": {}, "outputs": [], "source": [ @@ -134,7 +134,7 @@ }, { "cell_type": "markdown", - "id": "11", + "id": "bd1962ba", "metadata": {}, "source": [ "Setting `color=None` applies the default coloring scheme, typically uniform across all nodes." @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "eab4c6fb", "metadata": {}, "outputs": [], "source": [ @@ -159,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "13", + "id": "20b54aa0", "metadata": {}, "source": [ "This replicates Example 1 but uses `server_mode=\"external\"`, useful for rendering plots in certain environments." @@ -168,7 +168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "698ab518", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ { "attachments": {}, "cell_type": "markdown", - "id": "15", + "id": "bc416bb4", "metadata": {}, "source": [ "## Af1" @@ -195,7 +195,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "5e601014", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "17", + "id": "d8aeab21", "metadata": {}, "source": [ "Here, nodes are colored based on the `\"sample_set\"` column." @@ -219,7 +219,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "6b6f149e", "metadata": {}, "outputs": [], "source": [ @@ -236,7 +236,7 @@ }, { "cell_type": "markdown", - "id": "19", + "id": "b1cde074", "metadata": {}, "source": [ "Using `\"year\"` implies the function looks for `\"cohorts_year\"` in the metadata." @@ -245,7 +245,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "6d7fc155", "metadata": {}, "outputs": [], "source": [ @@ -260,7 +260,7 @@ }, { "cell_type": "markdown", - "id": "21", + "id": "e6e60160", "metadata": {}, "source": [ "A dictionary defines custom groups based on the `\"year\"` column (assuming year data is available)." @@ -269,7 +269,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "882e6b8f", "metadata": {}, "outputs": [], "source": [ @@ -285,7 +285,7 @@ }, { "cell_type": "markdown", - "id": "23", + "id": "485becad", "metadata": {}, "source": [ "With `color=None`, the default coloring is applied." @@ -294,7 +294,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "bd013c5c", "metadata": {}, "outputs": [], "source": [ @@ -310,6 +310,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -322,7 +323,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.12.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_haplotypes_frequencies.ipynb b/notebooks/plot_haplotypes_frequencies.ipynb index d88f3c20b..9ad777363 100644 --- a/notebooks/plot_haplotypes_frequencies.ipynb +++ b/notebooks/plot_haplotypes_frequencies.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0", + "id": "74a45bfa-2af5-4a9d-9285-84f34a82d986", "metadata": {}, "source": [ "# Ag3" @@ -11,7 +11,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "a46f23bf-2635-4249-b115-aa8cfd35d33f", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "8130522f-98de-463f-83fd-a1c1c460e00e", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "2cefad62-e558-4797-9d1a-4b501ad364b0", "metadata": {}, "outputs": [], "source": [ @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "6bac8aca-8835-43b7-84c0-f6eb62594d91", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "2770b59a-6b6d-4458-99cf-cdf08e47ddac", "metadata": {}, "outputs": [], "source": [ @@ -77,7 +77,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "a771fda2-ae68-46bc-b38e-2f4ba6b41b71", "metadata": {}, "source": [ "# Af1" @@ -86,7 +86,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "415cc454-ffdd-4bff-8881-95180bcf66f6", "metadata": {}, "outputs": [], "source": [ @@ -100,7 +100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "5d8fb2b5-5b49-4856-8e1c-895174e32f04", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "ef2cb769-4a8d-49fe-8e28-c9dc1af0159d", "metadata": {}, "outputs": [], "source": [] @@ -125,6 +125,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -137,7 +138,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.11" } }, "nbformat": 4, diff --git a/notebooks/plot_heterozygosity.ipynb b/notebooks/plot_heterozygosity.ipynb index 89a75efd8..136836b47 100644 --- a/notebooks/plot_heterozygosity.ipynb +++ b/notebooks/plot_heterozygosity.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "29e2e4a7", "metadata": {}, "outputs": [], "source": [ @@ -19,7 +19,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "a751077f", "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "4b2bb835", "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "ac466ddf", "metadata": {}, "outputs": [], "source": [ @@ -65,7 +65,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "522b2a30", "metadata": {}, "outputs": [], "source": [ @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "10aff683", "metadata": {}, "outputs": [], "source": [ @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "0c66bd85", "metadata": {}, "outputs": [], "source": [ @@ -105,7 +105,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "a8fc0887", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "e564c19b", "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "c0202112", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "3ebba22a", "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "df452208", "metadata": {}, "outputs": [], "source": [ @@ -171,7 +171,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "af3bf25f", "metadata": {}, "outputs": [], "source": [] @@ -179,6 +179,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -191,7 +192,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_ihs_gwss.ipynb b/notebooks/plot_ihs_gwss.ipynb index 3fd872e69..4a8fa53c7 100644 --- a/notebooks/plot_ihs_gwss.ipynb +++ b/notebooks/plot_ihs_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a31720f1", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "ece45863", "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "effd3060", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "8e747d9a", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "b63d02fe", "metadata": {}, "outputs": [], "source": [ @@ -94,7 +94,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "f77bbae1", "metadata": {}, "outputs": [], "source": [ @@ -112,7 +112,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "cd3c2a2d", "metadata": {}, "outputs": [], "source": [ @@ -122,7 +122,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "1b87b2f2", "metadata": {}, "outputs": [], "source": [ @@ -138,7 +138,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "9e3fc1c8", "metadata": {}, "outputs": [], "source": [ @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "110b81e5", "metadata": {}, "outputs": [], "source": [] @@ -162,6 +162,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -174,7 +175,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_njt.ipynb b/notebooks/plot_njt.ipynb index 94e210973..7ece0d852 100644 --- a/notebooks/plot_njt.ipynb +++ b/notebooks/plot_njt.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "3139f0e8-e82f-4d3d-a031-bc9c2d92edd8", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "3112b35f-d951-441e-a850-59615aa1f9ec", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "1e83d8ad-e20e-449b-8601-150540e6dd82", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "2964c092-65de-4d2a-9dd9-970418b13bd8", "metadata": {}, "outputs": [], "source": [ @@ -53,7 +53,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "5f86a798-51c8-4c79-ac60-e7520ab9a503", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "392e6c4c-512f-4a80-bbe9-932280a4efdb", "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "4437435f-d3b3-4ad6-9e62-6e5f6f01edea", "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "664a9d48-001e-40ed-8901-08bccb2184ba", "metadata": {}, "outputs": [], "source": [ @@ -119,7 +119,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "76405cc3-6cdd-4067-a2cb-71095d2c28b3", "metadata": {}, "outputs": [], "source": [ @@ -137,7 +137,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "972f4787-7c2b-47e2-859c-cd1cc800d92e", "metadata": {}, "outputs": [], "source": [ @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "95d20897-6100-4b11-a3e6-38155feb98c2", "metadata": {}, "outputs": [], "source": [ @@ -168,7 +168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "5bf936d6-5dc0-409c-828d-7af326102d41", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "8ea0532c-58f4-4bdf-bd56-0bdfb245e060", "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "2335937a-eec7-4d9e-b4ca-b737ff481cd6", "metadata": {}, "outputs": [], "source": [ @@ -220,7 +220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "68fb01ae-2567-4c13-b0a3-5890b38165d5", "metadata": {}, "outputs": [], "source": [ @@ -236,7 +236,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "2f1139fe-9c06-420f-855f-e3900186768a", "metadata": {}, "outputs": [], "source": [ @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "3f8f8976-0080-4f44-b665-1534980f0da1", "metadata": {}, "outputs": [], "source": [ @@ -269,7 +269,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "18fde26a-339a-44a1-a91f-425f22ed96d1", "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "72155de8-c657-4530-af38-82e0248b85a8", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "69aec527-1351-44ba-b394-681fd3d424dd", "metadata": {}, "outputs": [], "source": [ @@ -316,7 +316,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "38a2817d-933e-46f8-af0a-fedeb7370a38", "metadata": {}, "outputs": [], "source": [ @@ -333,7 +333,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "9c1dc76a-1fea-49ee-9341-a7542b2a74f0", "metadata": {}, "outputs": [], "source": [ @@ -346,7 +346,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "bc7b2566-ac5d-4ca0-bc91-0208fe9d2cb0", "metadata": {}, "outputs": [], "source": [ @@ -363,7 +363,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "9f5cd515-4933-4f08-82cc-c0fa57e77fb3", "metadata": {}, "outputs": [], "source": [] @@ -371,6 +371,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -383,7 +384,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_pairwise_average_fst.ipynb b/notebooks/plot_pairwise_average_fst.ipynb index b519e3776..0b41014a6 100644 --- a/notebooks/plot_pairwise_average_fst.ipynb +++ b/notebooks/plot_pairwise_average_fst.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "d0f3796b-cc12-4370-bdb2-ad4f4bd50a3e", "metadata": {}, "outputs": [], "source": [ @@ -17,7 +17,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "0e719256-3561-4362-a169-c38c9fe96972", "metadata": {}, "outputs": [], "source": [ @@ -33,7 +33,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "6af54463-584b-443b-9538-cd141578fde4", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "be539d92-3bd5-40b5-b67f-7ae6569db62f", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "a7c0815f-7ca9-4ed0-9982-16409f2bc675", "metadata": {}, "outputs": [], "source": [ @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "53a6b0e2-959d-4af1-92ed-bdb748be51c1", "metadata": {}, "outputs": [], "source": [ @@ -91,7 +91,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "35959f42-732e-40fa-86ad-16d95fb6e740", "metadata": {}, "outputs": [], "source": [ @@ -101,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "35d304bd-3f39-4dc7-9f7d-905068d5cd0d", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "ec418b8f-1451-415e-96e5-bcc5e98428bb", "metadata": {}, "outputs": [], "source": [ @@ -121,7 +121,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "c16035d2-b5d3-4441-87d9-eda953079161", "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "13afd6ed-7962-4935-b1f1-ed12f5e2ceed", "metadata": {}, "outputs": [], "source": [ @@ -143,7 +143,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "48a52211-2ef9-47da-b715-d0d74a69a4ad", "metadata": {}, "outputs": [], "source": [ @@ -162,7 +162,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "09cc1824-e6f4-4799-a8f4-cf61e472eaf8", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +172,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "95f112d2-fe76-4091-b73b-d7a17a61cc18", "metadata": {}, "outputs": [], "source": [ @@ -182,7 +182,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "908b08c8-290f-49d1-b3d3-cb8f9e7d2d21", "metadata": {}, "outputs": [], "source": [ @@ -192,7 +192,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "818fdac7-dcb4-4da2-8a52-f16ce51a2c0d", "metadata": {}, "outputs": [], "source": [ @@ -215,7 +215,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "65c1bdd5-f1d2-4814-93e5-ddb1d9c42258", "metadata": {}, "outputs": [], "source": [ @@ -225,7 +225,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "5ec8cfe3-336c-4362-9361-78d40ffa0a8e", "metadata": {}, "outputs": [], "source": [] @@ -233,7 +233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "2d3236a2-842d-4c13-92ec-9a4338750aca", "metadata": {}, "outputs": [], "source": [] @@ -241,6 +241,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -253,7 +254,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" } }, "nbformat": 4, diff --git a/notebooks/plot_pca.ipynb b/notebooks/plot_pca.ipynb index a32a6000a..74421ccc3 100644 --- a/notebooks/plot_pca.ipynb +++ b/notebooks/plot_pca.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "0", + "id": "7d93e741-bddf-4a29-aea2-7bc6be697cb7", "metadata": {}, "source": [ "# PCA plotting" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "1", + "id": "2f274c61-c660-47b0-92b9-83ab701eb9eb", "metadata": {}, "source": [ "### Setup" @@ -19,7 +19,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "36039d6f", "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "d8bf7a3a", "metadata": {}, "outputs": [], "source": [ @@ -44,7 +44,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "bfd56044", "metadata": {}, "outputs": [], "source": [ @@ -59,7 +59,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "4e5e1c70", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "b3760474-2ab2-4291-b5ee-48feccd091f4", "metadata": {}, "source": [ "## Mayotte" @@ -77,7 +77,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "e5743579", "metadata": {}, "outputs": [], "source": [ @@ -92,7 +92,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "ede14f05-a45d-4e12-9e02-3f4980d867cd", "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "5578c99a-37b1-4011-b34f-267aad0b2763", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "a027022f-f700-49c1-8f2d-a43100956155", "metadata": {}, "outputs": [], "source": [ @@ -127,7 +127,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "b73b8a6f", "metadata": {}, "outputs": [], "source": [ @@ -141,7 +141,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "c0b018e3", "metadata": {}, "outputs": [], "source": [ @@ -151,7 +151,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "32e505db", "metadata": {}, "outputs": [], "source": [ @@ -163,7 +163,7 @@ }, { "cell_type": "markdown", - "id": "14", + "id": "467dbd69-8ba2-41a2-8d01-d9fa78d42326", "metadata": {}, "source": [ "## Burkina Faso" @@ -172,7 +172,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "6a2ce979-1553-4459-b3c1-f3dea40bc1a1", "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "4cb47917-0d8c-47c8-a68d-34d193e2f61a", "metadata": {}, "outputs": [], "source": [ @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "241cae4e-3305-4c2a-845f-8871a1a114d4", "metadata": {}, "outputs": [], "source": [ @@ -214,7 +214,7 @@ }, { "cell_type": "markdown", - "id": "18", + "id": "a2b46eb9-832d-417c-a082-9fc365b0fc62", "metadata": {}, "source": [ "## Ag3.0" @@ -223,7 +223,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "8ac26ed8", "metadata": {}, "outputs": [], "source": [ @@ -238,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "6e02f847", "metadata": {}, "outputs": [], "source": [ @@ -253,7 +253,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "4b957863", "metadata": {}, "outputs": [], "source": [ @@ -263,7 +263,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "17baa8d0", "metadata": {}, "outputs": [], "source": [ @@ -277,7 +277,7 @@ { "cell_type": "code", "execution_count": null, - "id": "23", + "id": "114fb016", "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "92795fa4", "metadata": {}, "outputs": [], "source": [ @@ -307,7 +307,7 @@ { "cell_type": "code", "execution_count": null, - "id": "25", + "id": "e0c10b0d-3244-4862-acb7-cf60b9a6a9f2", "metadata": {}, "outputs": [], "source": [ @@ -324,7 +324,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "727402e7-43a1-4c7d-b21e-a051cd881f01", "metadata": {}, "outputs": [], "source": [ @@ -337,7 +337,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27", + "id": "cccf1386-c578-4af3-97ec-dc7704840102", "metadata": {}, "outputs": [], "source": [ @@ -351,7 +351,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28", + "id": "1b1a399a-762d-42db-9e40-776575d9ef5a", "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ }, { "cell_type": "markdown", - "id": "29", + "id": "14d04103-2f6f-4f53-8d35-f286de5980d2", "metadata": {}, "source": [ "## Af1.0" @@ -373,7 +373,7 @@ { "cell_type": "code", "execution_count": null, - "id": "30", + "id": "6c3fc8d5", "metadata": {}, "outputs": [], "source": [ @@ -388,7 +388,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31", + "id": "fbe1f54f", "metadata": {}, "outputs": [], "source": [ @@ -398,7 +398,7 @@ { "cell_type": "code", "execution_count": null, - "id": "32", + "id": "5c055c99", "metadata": {}, "outputs": [], "source": [ @@ -411,7 +411,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33", + "id": "ea74cb43", "metadata": {}, "outputs": [], "source": [ @@ -425,7 +425,7 @@ }, { "cell_type": "markdown", - "id": "34", + "id": "fdfbcd5a-5ef4-4cbc-b430-c0b541925142", "metadata": {}, "source": [ "## Excluding samples" @@ -434,7 +434,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35", + "id": "6c3251e2-a95c-4d4a-bff1-8e632be0eaf5", "metadata": {}, "outputs": [], "source": [ @@ -449,7 +449,7 @@ { "cell_type": "code", "execution_count": null, - "id": "36", + "id": "1f0b88a7-d9f6-44a8-9778-4cbaad397765", "metadata": {}, "outputs": [], "source": [ @@ -459,7 +459,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37", + "id": "4e370936-925a-4e97-86cb-b22f72b39e64", "metadata": {}, "outputs": [], "source": [ @@ -469,7 +469,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38", + "id": "9ea24435-d752-4269-a391-b057e1650d44", "metadata": {}, "outputs": [], "source": [ @@ -482,7 +482,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39", + "id": "0f114dd9-965d-4579-8cce-76f45fde6a37", "metadata": {}, "outputs": [], "source": [ @@ -500,7 +500,7 @@ { "cell_type": "code", "execution_count": null, - "id": "40", + "id": "a5392844-a828-48f3-8222-bfc1817c3493", "metadata": {}, "outputs": [], "source": [ @@ -510,7 +510,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41", + "id": "6d87eeb5-8dc6-4a31-a8a3-e936d4d05215", "metadata": {}, "outputs": [], "source": [ @@ -520,7 +520,7 @@ { "cell_type": "code", "execution_count": null, - "id": "42", + "id": "770b01ee-642e-4903-93fa-eef084924234", "metadata": {}, "outputs": [], "source": [ @@ -530,7 +530,7 @@ { "cell_type": "code", "execution_count": null, - "id": "43", + "id": "9438fd91-b463-4d28-8279-5eaa728a8f2e", "metadata": {}, "outputs": [], "source": [ @@ -542,7 +542,7 @@ }, { "cell_type": "markdown", - "id": "44", + "id": "58e7b2c1-b4c1-4c93-823c-8531693636e4", "metadata": {}, "source": [ "## Excluding samples during fit" @@ -551,7 +551,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45", + "id": "1014a17c-12bb-46c3-9a7b-f2449d205ce3", "metadata": {}, "outputs": [], "source": [ @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "46", + "id": "e48d46dd-5c7f-4573-a5f5-c15a389d2e1e", "metadata": {}, "outputs": [], "source": [ @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47", + "id": "1fb5192e-f63f-443d-91a9-e82b2de14c69", "metadata": {}, "outputs": [], "source": [ @@ -589,7 +589,7 @@ { "cell_type": "code", "execution_count": null, - "id": "48", + "id": "873c53f5-8690-4690-85f0-8ce1845e2862", "metadata": {}, "outputs": [], "source": [ @@ -599,7 +599,7 @@ { "cell_type": "code", "execution_count": null, - "id": "49", + "id": "0bb86ba2-e428-4ae0-9e0c-703345c89324", "metadata": {}, "outputs": [], "source": [ @@ -612,7 +612,7 @@ { "cell_type": "code", "execution_count": null, - "id": "50", + "id": "7b28c4c8-9382-4889-8651-77ef0be929f6", "metadata": {}, "outputs": [], "source": [ @@ -624,7 +624,7 @@ }, { "cell_type": "markdown", - "id": "51", + "id": "f1e8c954", "metadata": {}, "source": [ "## PCA with cohort downsampling" @@ -633,7 +633,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52", + "id": "e4a484f3", "metadata": {}, "outputs": [], "source": [ @@ -653,7 +653,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53", + "id": "abb2ee83", "metadata": {}, "outputs": [], "source": [] @@ -661,6 +661,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -673,7 +674,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_samples.ipynb b/notebooks/plot_samples.ipynb index ec7be4fe3..2f7f31c8a 100644 --- a/notebooks/plot_samples.ipynb +++ b/notebooks/plot_samples.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -256,6 +256,7 @@ ], "metadata": { "kernelspec": { + "display_name": "mgen_data_py3.11", "language": "python", "name": "python3" }, @@ -268,7 +269,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.11.5" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_snps.ipynb b/notebooks/plot_snps.ipynb index 502545139..5daa69c4e 100644 --- a/notebooks/plot_snps.ipynb +++ b/notebooks/plot_snps.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "14640993", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "5d740cac", "metadata": { "tags": [] }, @@ -31,7 +31,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "bd576b75", "metadata": { "tags": [] }, @@ -43,7 +43,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "7de3ba82", "metadata": { "tags": [] }, @@ -56,7 +56,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "3a3de267-affa-46e6-92b9-d07553cad816", "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "2c66985f-592b-4fb5-a560-5cdedb472bee", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "82096dc0", "metadata": { "tags": [] }, @@ -88,7 +88,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "10c340aa", "metadata": {}, "outputs": [], "source": [ @@ -98,7 +98,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "e8e463dd", "metadata": {}, "outputs": [], "source": [ @@ -108,7 +108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "7fb757a7", "metadata": {}, "outputs": [], "source": [ @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "0e3a8961", "metadata": { "tags": [] }, @@ -132,7 +132,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "63aca10c", "metadata": { "tags": [] }, @@ -144,7 +144,7 @@ { "cell_type": "code", "execution_count": null, - "id": "12", + "id": "6fb5216e", "metadata": { "tags": [] }, @@ -158,7 +158,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "0d88ceb5", "metadata": { "tags": [] }, @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "14", + "id": "0c98cabe", "metadata": { "tags": [] }, @@ -186,7 +186,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "8a7c297d", "metadata": { "tags": [] }, @@ -198,7 +198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "16", + "id": "d0552711", "metadata": { "tags": [] }, @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "d269e02e", "metadata": { "tags": [] }, @@ -224,7 +224,7 @@ { "cell_type": "code", "execution_count": null, - "id": "18", + "id": "872c56ab", "metadata": { "tags": [] }, @@ -238,7 +238,7 @@ { "cell_type": "code", "execution_count": null, - "id": "19", + "id": "c24a21ab", "metadata": { "tags": [] }, @@ -254,7 +254,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "60280e52", "metadata": {}, "outputs": [], "source": [] @@ -262,6 +262,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -274,7 +275,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/plot_xpehh_gwss.ipynb b/notebooks/plot_xpehh_gwss.ipynb index ba03632a5..cd9e67583 100644 --- a/notebooks/plot_xpehh_gwss.ipynb +++ b/notebooks/plot_xpehh_gwss.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "32067e1d", "metadata": {}, "outputs": [], "source": [ @@ -20,7 +20,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "966049ec", "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "838eddc4", "metadata": {}, "outputs": [], "source": [ @@ -54,7 +54,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "e780aa23", "metadata": {}, "outputs": [], "source": [ @@ -75,7 +75,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "b26a9654", "metadata": {}, "outputs": [], "source": [ @@ -93,7 +93,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "181227f6", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +111,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "89cf50ac", "metadata": {}, "outputs": [], "source": [ @@ -130,7 +130,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "78b452f5", "metadata": {}, "outputs": [], "source": [ @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8", + "id": "079a3308", "metadata": {}, "outputs": [], "source": [ @@ -157,7 +157,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "d6290896", "metadata": {}, "outputs": [], "source": [ @@ -174,7 +174,7 @@ { "cell_type": "code", "execution_count": null, - "id": "10", + "id": "a5aed96d", "metadata": {}, "outputs": [], "source": [] @@ -182,6 +182,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -194,7 +195,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/profiling/gh498.ipynb b/notebooks/profiling/gh498.ipynb index 21818ea9b..06012f43e 100644 --- a/notebooks/profiling/gh498.ipynb +++ b/notebooks/profiling/gh498.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "a790fb90-492e-480a-9403-d1d242c48389", "metadata": {}, "outputs": [], "source": [ @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "a00d7b52-ac2e-44ef-9e08-a9d33ee90276", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "0fdd5aea-803c-477e-9b35-8edc61a31b7e", "metadata": {}, "outputs": [], "source": [ @@ -45,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "ff092693-dd1e-44ff-bd09-7cfb57b9134f", "metadata": {}, "outputs": [], "source": [ @@ -55,7 +55,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "9a75f64f-fe2c-44d9-abae-18ff8453d154", "metadata": {}, "outputs": [], "source": [ @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "0c433078-8c78-4a2a-93d3-d9330762bbbd", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "8f945545-7a73-4c9a-8867-e2cae9e1aece", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "1fcae9c4-9c1c-402f-a6c9-70a7f6f939a7", "metadata": {}, "outputs": [], "source": [] @@ -125,6 +125,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -137,7 +138,8 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.8.18" } }, "nbformat": 4, diff --git a/notebooks/repr.ipynb b/notebooks/repr.ipynb index 7aa1dbb88..3b8c2a289 100644 --- a/notebooks/repr.ipynb +++ b/notebooks/repr.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0", + "id": "aa5bad7b", "metadata": { "tags": [] }, @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1", + "id": "24cdd3a1", "metadata": { "tags": [] }, @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2", + "id": "362dedbf", "metadata": { "tags": [] }, @@ -39,7 +39,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "294fc8b7", "metadata": { "tags": [] }, @@ -51,7 +51,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "9ca832ac", "metadata": { "tags": [] }, @@ -64,7 +64,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "73e79af6", "metadata": { "tags": [] }, @@ -76,7 +76,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "4781d110", "metadata": {}, "outputs": [], "source": [] @@ -84,6 +84,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -96,7 +97,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4, diff --git a/notebooks/spike_sim_test_data.ipynb b/notebooks/spike_sim_test_data.ipynb index ae7709062..ba87ef806 100644 --- a/notebooks/spike_sim_test_data.ipynb +++ b/notebooks/spike_sim_test_data.ipynb @@ -1197,6 +1197,7 @@ ], "metadata": { "kernelspec": { + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1209,7 +1210,15 @@ "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3" + "pygments_lexer": "ipython3", + "version": "3.10.12" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } } }, "nbformat": 4,