jbrowse-plugin-protein3d 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/AlignTranscriptRpc/index.js +14 -0
  2. package/dist/LaunchProteinView/codingFeature.js +21 -0
  3. package/dist/LaunchProteinView/hooks/useTranscriptSelection.js +3 -1
  4. package/dist/LaunchProteinView/resolveGeneLaunch.js +6 -4
  5. package/dist/LaunchProteinView/utils/util.js +4 -2
  6. package/dist/Protein1DLinkage/linkage.js +22 -6
  7. package/dist/chunks/{AddStructureDialog-TJWA75N4.js → AddStructureDialog-GMJTCTRP.js} +2 -2
  8. package/dist/chunks/{ManualAlignmentDialog-YK3AOABQ.js → ManualAlignmentDialog-T6V6TALA.js} +2 -2
  9. package/dist/chunks/{ProteinView-2PMPVRSZ.js → ProteinView-M6MAEBRS.js} +2 -2
  10. package/dist/chunks/{chunk-6WDCIFCW.js → chunk-3QM6HC4V.js} +1 -1
  11. package/dist/chunks/{chunk-6WDCIFCW.js.map → chunk-3QM6HC4V.js.map} +1 -1
  12. package/dist/chunks/{chunk-3SRUB4H5.js → chunk-DO32DM3V.js} +2 -2
  13. package/dist/chunks/{chunk-3SRUB4H5.js.map → chunk-DO32DM3V.js.map} +1 -1
  14. package/dist/chunks/{chunk-DQAVCUTJ.js → chunk-NSRFB7YQ.js} +2 -2
  15. package/dist/chunks/{chunk-DQAVCUTJ.js.map → chunk-NSRFB7YQ.js.map} +1 -1
  16. package/dist/chunks/{chunk-335ZIVRW.js → chunk-OH7LYKSD.js} +1 -1
  17. package/dist/chunks/{chunk-335ZIVRW.js.map → chunk-OH7LYKSD.js.map} +1 -1
  18. package/dist/chunks/{molstarExports-I4O6AZHY.js → molstarExports-VX3JPTXO.js} +2 -2
  19. package/dist/chunks/{molstarExports-I4O6AZHY.js.map → molstarExports-VX3JPTXO.js.map} +3 -3
  20. package/dist/jbrowse-plugin-protein3d.esm.js +7 -7
  21. package/dist/jbrowse-plugin-protein3d.esm.js.map +4 -4
  22. package/dist/version.js +1 -1
  23. package/package.json +5 -5
  24. package/src/AlignTranscriptRpc/index.ts +21 -0
  25. package/src/LaunchProteinView/codingFeature.ts +24 -0
  26. package/src/LaunchProteinView/hooks/useTranscriptSelection.ts +3 -1
  27. package/src/LaunchProteinView/resolveGeneLaunch.test.ts +43 -0
  28. package/src/LaunchProteinView/resolveGeneLaunch.ts +7 -4
  29. package/src/LaunchProteinView/utils/util.ts +4 -2
  30. package/src/Protein1DLinkage/linkage.test.ts +28 -0
  31. package/src/Protein1DLinkage/linkage.ts +25 -5
  32. package/src/version.ts +1 -1
  33. /package/dist/chunks/{AddStructureDialog-TJWA75N4.js.map → AddStructureDialog-GMJTCTRP.js.map} +0 -0
  34. /package/dist/chunks/{ManualAlignmentDialog-YK3AOABQ.js.map → ManualAlignmentDialog-T6V6TALA.js.map} +0 -0
  35. /package/dist/chunks/{ProteinView-2PMPVRSZ.js.map → ProteinView-M6MAEBRS.js.map} +0 -0
@@ -9,6 +9,20 @@ export function rankIsoforms(isoforms, structureSequences) {
9
9
  ranking: classifyIsoforms({ isoforms, structureSequence }),
10
10
  };
11
11
  }
12
+ /**
13
+ * The isoform to open from a ranking. An exact match to the structure wins;
14
+ * the annotation's flagged transcript (MANE Select) breaks a tie between exact
15
+ * matches, and leads when there is no structure to rank against, where length
16
+ * alone would decide.
17
+ */
18
+ export function rankedTranscriptId({ matches, nonMatches }, flaggedId) {
19
+ const flagged = (list) => list.find(i => i.id === flaggedId);
20
+ const unranked = nonMatches.every(i => i.score === undefined);
21
+ return (flagged(matches) ??
22
+ matches[0] ??
23
+ (unranked ? flagged(nonMatches) : undefined) ??
24
+ nonMatches[0])?.id;
25
+ }
12
26
  // The alignment DP runs ~50 ns a cell, so a 4,000-residue transcript against
13
27
  // its structure is almost a second and a complex of long chains several: on
14
28
  // the main thread, frozen UI. These run it in the host's RPC worker instead,
@@ -17,3 +17,24 @@ export function codingTranscripts(feature) {
17
17
  export function isCodingFeature(feature) {
18
18
  return codingTranscripts(feature).length > 0;
19
19
  }
20
+ // GENCODE tags the transcript row; NCBI's RefSeq GFF carries no such tag and
21
+ // keeps Select status in separate tracks.
22
+ const REPRESENTATIVE_TAGS = ['MANE_Select', 'Ensembl_canonical'];
23
+ function tagsOf(feature) {
24
+ const tag = feature.get('tag');
25
+ return Array.isArray(tag)
26
+ ? tag
27
+ : typeof tag === 'string'
28
+ ? tag.split(',')
29
+ : [];
30
+ }
31
+ /** The transcript its annotation flags as the gene's representative. */
32
+ export function flaggedTranscriptId(transcripts) {
33
+ for (const tag of REPRESENTATIVE_TAGS) {
34
+ const flagged = transcripts.find(t => tagsOf(t).includes(tag));
35
+ if (flagged) {
36
+ return flagged.id();
37
+ }
38
+ }
39
+ return undefined;
40
+ }
@@ -1,4 +1,6 @@
1
1
  import { useState } from 'react';
2
+ import { rankedTranscriptId } from '../../AlignTranscriptRpc';
3
+ import { flaggedTranscriptId } from '../codingFeature';
2
4
  import { rankableIsoforms } from '../utils/util';
3
5
  /**
4
6
  * The isoform the user right-clicked when it translates, else the one whose
@@ -8,7 +10,7 @@ import { rankableIsoforms } from '../utils/util';
8
10
  export function defaultTranscriptId({ options, isoformSequences, ranking, preferredTranscriptId, }) {
9
11
  return rankableIsoforms(options, isoformSequences).some(i => i.id === preferredTranscriptId && i.seq)
10
12
  ? preferredTranscriptId
11
- : ranking && (ranking.matches[0] ?? ranking.nonMatches[0])?.id;
13
+ : ranking && rankedTranscriptId(ranking, flaggedTranscriptId(options));
12
14
  }
13
15
  export default function useTranscriptSelection({ options, isoformSequences, ranking, preferredTranscriptId, resetKey, }) {
14
16
  const [userSelection, setUserSelection] = useState();
@@ -1,7 +1,7 @@
1
1
  import { getConf } from '@jbrowse/core/configuration';
2
2
  import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, } from 'p2s_mapper';
3
- import { codingTranscripts } from './codingFeature';
4
- import { rankIsoforms } from '../AlignTranscriptRpc';
3
+ import { codingTranscripts, flaggedTranscriptId } from './codingFeature';
4
+ import { rankIsoforms, rankedTranscriptId } from '../AlignTranscriptRpc';
5
5
  import { fetchTranscriptProteinSeqs } from './utils/translateTranscripts';
6
6
  import { extractFeatureIdentifiers, extractTaxonId } from './utils/util';
7
7
  import { alignOffThread } from '../ProteinView/alignOffThread';
@@ -80,7 +80,8 @@ async function searchForEntry(host, ids) {
80
80
  * Everything the launch dialog works out from a gene, without the dialog: the
81
81
  * UniProt entry from the feature's identifiers, the AlphaFold model of that
82
82
  * entry, and the isoform to map — the preferred one when it translates, else
83
- * the one the model was folded from, else the longest.
83
+ * the one the model was folded from, else the annotation's MANE Select, else
84
+ * the longest.
84
85
  */
85
86
  export async function resolveGeneLaunch({ host, feature, preferredTranscriptId, uniprotId: givenUniprotId, findStructure = true, }) {
86
87
  const ids = extractFeatureIdentifiers(feature, preferredTranscriptId);
@@ -119,7 +120,8 @@ export async function resolveGeneLaunch({ host, feature, preferredTranscriptId,
119
120
  : structureSequences.length > 0
120
121
  ? (await host.rankIsoforms(isoforms, structureSequences)).ranking
121
122
  : rankIsoforms(isoforms).ranking;
122
- const bestId = ranking && (ranking.matches[0] ?? ranking.nonMatches[0])?.id;
123
+ const bestId = ranking &&
124
+ rankedTranscriptId(ranking, flaggedTranscriptId(codingTranscripts(feature)));
123
125
  const chosen = preferred ??
124
126
  translated.find(t => t.transcript.id() === bestId) ??
125
127
  translated[0];
@@ -1,7 +1,7 @@
1
1
  import { isGeneLikeType } from '@jbrowse/core/util';
2
2
  import { isRecognizedDatabaseId, matchDbIdPattern } from 'p2s_mapper';
3
3
  import { isRecord } from './isRecord';
4
- import { codingTranscripts } from '../codingFeature';
4
+ import { codingTranscripts, flaggedTranscriptId } from '../codingFeature';
5
5
  /**
6
6
  * Pull an NCBI taxon id out of reference-sequence-track metadata. jb2hubs
7
7
  * assemblies expose it differently by source: UCSC golden-path spreads it flat
@@ -121,7 +121,7 @@ function dbxrefUniProtId(f) {
121
121
  /**
122
122
  * Extract all useful identifiers from a feature for UniProt lookup.
123
123
  * If the feature is a gene, prioritizes identifiers from the preferred
124
- * transcript, else its first. Otherwise, extracts identifiers from the feature
124
+ * transcript, else its MANE Select, else its first. Otherwise, extracts identifiers from the feature
125
125
  * itself. geneId and geneName are always extracted from the parent feature 'f'.
126
126
  */
127
127
  export function extractFeatureIdentifiers(f, preferredTranscriptId) {
@@ -131,8 +131,10 @@ export function extractFeatureIdentifiers(f, preferredTranscriptId) {
131
131
  let featureToProcess = f; // Default to the parent feature
132
132
  if (isGeneLikeType(f.get('type'))) {
133
133
  const transcripts = codingTranscripts(f);
134
+ const flagged = flaggedTranscriptId(transcripts);
134
135
  featureToProcess =
135
136
  transcripts.find(t => t.id() === preferredTranscriptId) ??
137
+ transcripts.find(t => t.id() === flagged) ??
136
138
  transcripts[0] ??
137
139
  f;
138
140
  }
@@ -1,5 +1,5 @@
1
1
  import { SimpleFeature } from '@jbrowse/core/util';
2
- import { DEFAULT_ALIGNMENT_ALGORITHM, alignTranscriptToEntity, alignmentQuality, isLowSimilarity, structurePos, transcriptPos, } from 'p2s_mapper';
2
+ import { DEFAULT_ALIGNMENT_ALGORITHM, alignTranscriptToEntity, alignmentQuality, isLowSimilarity, keepSharedStretches, mappedStructureIdentity, structurePos, transcriptPos, } from 'p2s_mapper';
3
3
  import { isIdentical } from '../ProteinView/alignOffThread';
4
4
  import { assemblyNaming, genomeHoverToTranscriptPos, viewAssemblyName, } from '../ProteinView/util';
5
5
  import { codingSpans, genomeToTranscriptSeqMapping } from '../mappings';
@@ -79,12 +79,28 @@ export function genomeHighlightsForUniProtPosition(views, uniprotPos) {
79
79
  ...new Map(spans.map(s => [`${s.refName}:${s.start}-${s.end}`, s])).values(),
80
80
  ];
81
81
  }
82
+ // Two isoforms of one protein differ only in their alternative exons, so the
83
+ // shared-stretch rule keeps most of their alignment: 92% for PKM1 on PKM2, 94%
84
+ // for FGFR2 IIIc on IIIb. A homolog a Foldseek hit opened differs everywhere,
85
+ // and the rule shreds it: mouse TP53 keeps 41%, HBB 28%, BRCA1 9%. Below this
86
+ // the entry is another protein, and the alignment maps it column for column.
87
+ const ISOFORM_KEPT_FRACTION = 0.8;
88
+ function isoformAlignment(pa) {
89
+ const kept = keepSharedStretches(pa);
90
+ return mappedStructureIdentity(kept).size >=
91
+ ISOFORM_KEPT_FRACTION * mappedStructureIdentity(pa).size
92
+ ? kept
93
+ : pa;
94
+ }
82
95
  /**
83
96
  * Align the linked transcript's translation to the sequence the 1D view
84
- * shows. Run when the view attaches rather than stored at launch: the
85
- * temporary assembly fetches the UniProt entry afresh on every load, so a
86
- * saved alignment could describe a sequence the view no longer shows, and a
87
- * snapshot written by hand or before this existed has none.
97
+ * shows. Where that is another isoform, only the stretches the two spell
98
+ * letter for letter map: a mutually exclusive exon aligns column for column
99
+ * against its partner, and no codon of one encodes a residue of the other.
100
+ * Run when the view attaches rather than stored at launch: the temporary
101
+ * assembly fetches the UniProt entry afresh on every load, so a saved
102
+ * alignment could describe a sequence the view no longer shows, and a snapshot
103
+ * written by hand or before this existed has none.
88
104
  */
89
105
  export async function resolveLinkageAlignment(host) {
90
106
  const [transcript, uniprot] = await Promise.all([
@@ -105,5 +121,5 @@ export async function resolveLinkageAlignment(host) {
105
121
  }
106
122
  return isLowSimilarity(alignmentQuality(scored.alignment))
107
123
  ? { problem: 'the transcript and the UniProt entry are too dissimilar' }
108
- : { alignment: scored.alignment };
124
+ : { alignment: isoformAlignment(scored.alignment) };
109
125
  }
@@ -1,2 +1,2 @@
1
- import{b as p,e as m,f as C,g as S,h as P}from"./chunk-335ZIVRW.js";import{a as W}from"./chunk-LOG7ZCI7.js";import{a as N}from"./chunk-HLB63AD7.js";import{a as q}from"./chunk-HAGLAQP5.js";import{a as V}from"./chunk-GVEKA5YG.js";import{c as a}from"./chunk-KVMUXFPB.js";var e=a(V()),T=a(N()),r=a(q()),I=a(W());var _=(0,I.observer)(function({model:s,handleClose:c}){let[n,D]=(0,e.useState)(),[l,x]=(0,e.useState)(""),[u,A]=(0,e.useState)(""),[t,U]=(0,e.useState)("pdb"),[d,w]=(0,e.useState)(""),[g,h]=(0,e.useState)(),[F,f]=(0,e.useState)(!1),[b,B]=(0,e.useState)(!0),k=!!s.primaryStructure?.userProvidedTranscriptSequence,E=async()=>{f(!0),h(void 0);try{let o=t==="pdb"&&l?{pdbId:l}:t==="uniprot"&&u?{uniprotId:u}:t==="url"&&d?{url:d}:t==="file"&&n?{data:await S(n)}:void 0;if(o){let i=s.primaryStructure,L=b&&i?.userProvidedTranscriptSequence?{userProvidedTranscriptSequence:i.userProvidedTranscriptSequence,feature:i.feature,connectedViewId:i.connectedViewId}:{};s.addStructure({...o,...L}),c()}}catch(o){console.error(o),h(o)}finally{f(!1)}},v=l!==""&&!p(l),y=u!==""&&!m(u),M=t==="url"&&d!==""||t==="file"&&n!==void 0||t==="pdb"&&p(l)||t==="uniprot"&&m(u);return e.default.createElement(r.Dialog,{open:!0,onClose:c,maxWidth:"sm",fullWidth:!0},e.default.createElement(r.DialogTitle,null,"Add structure"),e.default.createElement(r.DialogContent,null,g?e.default.createElement(T.ErrorMessage,{error:g}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Add another structure to superpose on the existing structure(s)."),e.default.createElement(r.FormControl,{component:"fieldset",sx:{mb:2}},e.default.createElement(r.RadioGroup,{value:t,onChange:o=>{U(o.target.value)}},e.default.createElement(r.FormControlLabel,{value:"pdb",control:e.default.createElement(r.Radio,null),label:"PDB ID"}),e.default.createElement(r.FormControlLabel,{value:"uniprot",control:e.default.createElement(r.Radio,null),label:"UniProt ID (AlphaFold)"}),e.default.createElement(r.FormControlLabel,{value:"url",control:e.default.createElement(r.Radio,null),label:"URL"}),e.default.createElement(r.FormControlLabel,{value:"file",control:e.default.createElement(r.Radio,null),label:"File"}))),t==="pdb"?e.default.createElement(r.TextField,{fullWidth:!0,value:l,onChange:o=>{x(o.target.value.trim().toUpperCase())},label:"PDB ID (e.g. 1CRN)",placeholder:"Enter PDB ID",error:v,helperText:v?"A PDB ID is four characters beginning with a digit":void 0,sx:{mb:2}}):null,t==="uniprot"?e.default.createElement(r.TextField,{fullWidth:!0,value:u,onChange:o=>{A(o.target.value.trim().toUpperCase())},label:"UniProt ID (e.g. P04637)",placeholder:"Enter UniProt ID",error:y,helperText:y?C:"Fetches the AlphaFold predicted structure",sx:{mb:2}}):null,t==="url"?e.default.createElement(r.TextField,{fullWidth:!0,label:"Structure URL",value:d,onChange:o=>{w(o.target.value.trim())},placeholder:"https://files.rcsb.org/download/1CRN.cif",sx:{mb:2}}):null,t==="file"?e.default.createElement("div",{style:{marginBottom:16}},e.default.createElement(r.Button,{variant:"outlined",component:"label"},n?n.name:"Choose file",e.default.createElement("input",{type:"file",hidden:!0,accept:P,onChange:({target:o})=>{let i=o.files?.[0];i&&D(i)}})),n?e.default.createElement(r.Typography,{variant:"body2",sx:{mt:1}},"Selected: ",n.name):null):null,k?e.default.createElement(r.FormControlLabel,{control:e.default.createElement(r.Checkbox,{checked:b,onChange:o=>{B(o.target.checked)}}),label:"Map to the same transcript as the first structure (alignment, hover and click linked to the genome)"}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1}},"Tip: Structures will be automatically superposed using TM-align. For manual control, use the Mol* controls (\u{1F527} wrench icon).")),e.default.createElement(r.DialogActions,null,e.default.createElement(r.Button,{onClick:c},"Cancel"),e.default.createElement(r.Button,{onClick:()=>{E()},variant:"contained",color:"primary",disabled:!M||F},"Add structure")))}),j=_;export{j as default};
2
- //# sourceMappingURL=AddStructureDialog-TJWA75N4.js.map
1
+ import{b as p,e as m,f as C,g as S,h as P}from"./chunk-OH7LYKSD.js";import{a as W}from"./chunk-LOG7ZCI7.js";import{a as N}from"./chunk-HLB63AD7.js";import{a as q}from"./chunk-HAGLAQP5.js";import{a as V}from"./chunk-GVEKA5YG.js";import{c as a}from"./chunk-KVMUXFPB.js";var e=a(V()),T=a(N()),r=a(q()),I=a(W());var _=(0,I.observer)(function({model:s,handleClose:c}){let[n,D]=(0,e.useState)(),[l,x]=(0,e.useState)(""),[u,A]=(0,e.useState)(""),[t,U]=(0,e.useState)("pdb"),[d,w]=(0,e.useState)(""),[g,h]=(0,e.useState)(),[F,f]=(0,e.useState)(!1),[b,B]=(0,e.useState)(!0),k=!!s.primaryStructure?.userProvidedTranscriptSequence,E=async()=>{f(!0),h(void 0);try{let o=t==="pdb"&&l?{pdbId:l}:t==="uniprot"&&u?{uniprotId:u}:t==="url"&&d?{url:d}:t==="file"&&n?{data:await S(n)}:void 0;if(o){let i=s.primaryStructure,L=b&&i?.userProvidedTranscriptSequence?{userProvidedTranscriptSequence:i.userProvidedTranscriptSequence,feature:i.feature,connectedViewId:i.connectedViewId}:{};s.addStructure({...o,...L}),c()}}catch(o){console.error(o),h(o)}finally{f(!1)}},v=l!==""&&!p(l),y=u!==""&&!m(u),M=t==="url"&&d!==""||t==="file"&&n!==void 0||t==="pdb"&&p(l)||t==="uniprot"&&m(u);return e.default.createElement(r.Dialog,{open:!0,onClose:c,maxWidth:"sm",fullWidth:!0},e.default.createElement(r.DialogTitle,null,"Add structure"),e.default.createElement(r.DialogContent,null,g?e.default.createElement(T.ErrorMessage,{error:g}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Add another structure to superpose on the existing structure(s)."),e.default.createElement(r.FormControl,{component:"fieldset",sx:{mb:2}},e.default.createElement(r.RadioGroup,{value:t,onChange:o=>{U(o.target.value)}},e.default.createElement(r.FormControlLabel,{value:"pdb",control:e.default.createElement(r.Radio,null),label:"PDB ID"}),e.default.createElement(r.FormControlLabel,{value:"uniprot",control:e.default.createElement(r.Radio,null),label:"UniProt ID (AlphaFold)"}),e.default.createElement(r.FormControlLabel,{value:"url",control:e.default.createElement(r.Radio,null),label:"URL"}),e.default.createElement(r.FormControlLabel,{value:"file",control:e.default.createElement(r.Radio,null),label:"File"}))),t==="pdb"?e.default.createElement(r.TextField,{fullWidth:!0,value:l,onChange:o=>{x(o.target.value.trim().toUpperCase())},label:"PDB ID (e.g. 1CRN)",placeholder:"Enter PDB ID",error:v,helperText:v?"A PDB ID is four characters beginning with a digit":void 0,sx:{mb:2}}):null,t==="uniprot"?e.default.createElement(r.TextField,{fullWidth:!0,value:u,onChange:o=>{A(o.target.value.trim().toUpperCase())},label:"UniProt ID (e.g. P04637)",placeholder:"Enter UniProt ID",error:y,helperText:y?C:"Fetches the AlphaFold predicted structure",sx:{mb:2}}):null,t==="url"?e.default.createElement(r.TextField,{fullWidth:!0,label:"Structure URL",value:d,onChange:o=>{w(o.target.value.trim())},placeholder:"https://files.rcsb.org/download/1CRN.cif",sx:{mb:2}}):null,t==="file"?e.default.createElement("div",{style:{marginBottom:16}},e.default.createElement(r.Button,{variant:"outlined",component:"label"},n?n.name:"Choose file",e.default.createElement("input",{type:"file",hidden:!0,accept:P,onChange:({target:o})=>{let i=o.files?.[0];i&&D(i)}})),n?e.default.createElement(r.Typography,{variant:"body2",sx:{mt:1}},"Selected: ",n.name):null):null,k?e.default.createElement(r.FormControlLabel,{control:e.default.createElement(r.Checkbox,{checked:b,onChange:o=>{B(o.target.checked)}}),label:"Map to the same transcript as the first structure (alignment, hover and click linked to the genome)"}):null,e.default.createElement(r.Typography,{variant:"body2",color:"text.secondary",sx:{mt:1}},"Tip: Structures will be automatically superposed using TM-align. For manual control, use the Mol* controls (\u{1F527} wrench icon).")),e.default.createElement(r.DialogActions,null,e.default.createElement(r.Button,{onClick:c},"Cancel"),e.default.createElement(r.Button,{onClick:()=>{E()},variant:"contained",color:"primary",disabled:!M||F},"Add structure")))}),j=_;export{j as default};
2
+ //# sourceMappingURL=AddStructureDialog-GMJTCTRP.js.map
@@ -1,8 +1,8 @@
1
- import{c as w,d as q}from"./chunk-3SRUB4H5.js";import"./chunk-6WDCIFCW.js";import{a as L}from"./chunk-LOG7ZCI7.js";import{a as k}from"./chunk-HAGLAQP5.js";import{a as S}from"./chunk-GVEKA5YG.js";import{c as g}from"./chunk-KVMUXFPB.js";var r=g(S()),o=g(k());function x(t){let e=t.next();for(;!e.done&&e.value.trim()==="";)e=t.next();return e.value}function E(t){let e=t.trim();return e?e.split(/\s+/).every(n=>/^\d+$/.test(n)):!1}function C(t){let e=t.trim();return/^\w+\s+/.test(e)&&!E(t)}function D(t){return t.length>=3&&/^\d+$/.test(t[1])}function v(t,e){let n=t.trim().split(/\s+/),i=n[e],l=t.indexOf(i,t.indexOf(n[0])+n[0].length);return[l,l+i.length]}function y(t){let e=x(t),s=[],n="";if(!e)return;for(;e;)E(e)||(C(e)?s.push(e):n=e),e=t.next().value;if(s.length===0)return;let i=s.map(p=>p.trim().split(/\s+/)),l=i[0];if(!l)return;let a=D(l)?2:1,[c,f]=v(s[0],a),u=i.map(p=>p[0]),m=i.map(p=>p[a]),d=n.slice(c,f),h=m[0];if(h){let p=h.length-d.length;p>0&&(d+=" ".repeat(p))}return{ids:u,seqs:m,consensus:d}}function b(t){let e,s=y(t);if(s!==void 0)for(;e=y(t);){for(let n=0;n<e.seqs.length;n++)s.seqs[n]+=e.seqs[n];s.consensus+=e.consensus}return s}function A(t){let e=t.split(`
1
+ import{c as w,d as q}from"./chunk-DO32DM3V.js";import"./chunk-3QM6HC4V.js";import{a as L}from"./chunk-LOG7ZCI7.js";import{a as k}from"./chunk-HAGLAQP5.js";import{a as S}from"./chunk-GVEKA5YG.js";import{c as g}from"./chunk-KVMUXFPB.js";var r=g(S()),o=g(k());function x(t){let e=t.next();for(;!e.done&&e.value.trim()==="";)e=t.next();return e.value}function E(t){let e=t.trim();return e?e.split(/\s+/).every(n=>/^\d+$/.test(n)):!1}function C(t){let e=t.trim();return/^\w+\s+/.test(e)&&!E(t)}function D(t){return t.length>=3&&/^\d+$/.test(t[1])}function v(t,e){let n=t.trim().split(/\s+/),i=n[e],l=t.indexOf(i,t.indexOf(n[0])+n[0].length);return[l,l+i.length]}function y(t){let e=x(t),s=[],n="";if(!e)return;for(;e;)E(e)||(C(e)?s.push(e):n=e),e=t.next().value;if(s.length===0)return;let i=s.map(p=>p.trim().split(/\s+/)),l=i[0];if(!l)return;let a=D(l)?2:1,[c,f]=v(s[0],a),u=i.map(p=>p[0]),m=i.map(p=>p[a]),d=n.slice(c,f),h=m[0];if(h){let p=h.length-d.length;p>0&&(d+=" ".repeat(p))}return{ids:u,seqs:m,consensus:d}}function b(t){let e,s=y(t);if(s!==void 0)for(;e=y(t);){for(let n=0;n<e.seqs.length;n++)s.seqs[n]+=e.seqs[n];s.consensus+=e.consensus}return s}function A(t){let e=t.split(`
2
2
  `).filter(a=>!a.startsWith("#")).join(`
3
3
  `),s=b(e.split(`
4
4
  `)[Symbol.iterator]());if(s===void 0)throw new Error("No blocks parsed");let n=s.seqs.map((a,c)=>({id:s.ids[c],seq:a})),{consensus:i}=s,l=n[0];if(!l)throw new Error("No alignments found");if(i.length!==l.seq.length)throw new Error(`Consensus length !== sequence length. Con ${i.length} seq ${l.seq.length}`);if(n.length!==2)throw new Error(`Expected exactly 2 sequences in pairwise alignment, got ${n.length}`);return{consensus:i,alns:n}}var P=g(L());var B=(0,P.observer)(function({model:e,handleClose:s}){let[n,i]=(0,r.useState)(""),[l,a]=(0,r.useState)(),{alignmentStructure:c}=e,f=()=>{if(n.trim())try{let u=A(n.trim()),m=c?.entities,d=c&&m?q(u,c.userProvidedTranscriptSequence,m,c.mappedEntityId):void 0;!c||!d?a("No structure loaded to apply alignment to"):"problem"in d?a(d.problem):(c.importAlignment(w(u)),s())}catch(u){a(`Failed to parse alignment: ${u}`)}};return r.default.createElement(o.Dialog,{open:!0,onClose:s,maxWidth:"md",fullWidth:!0},r.default.createElement(o.DialogTitle,null,"Import manual alignment",c?.label?` for ${c.label}`:""),r.default.createElement(o.DialogContent,null,r.default.createElement(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Paste a pre-computed alignment in Clustal format. The first sequence should be the transcript and the second should be the structure."),r.default.createElement(o.TextField,{multiline:!0,rows:12,fullWidth:!0,placeholder:`Example:
5
5
  transcript MKAAYLSMFGKEDHKPFGDDEVELFRAVPGLKLKIAG
6
6
  |||||||||||||||||||||||||||||||||||||
7
7
  structure MKAAYLSMFGKEDHKPFGDDEVELFRAVPGLKLKIAG`,value:n,onChange:u=>{i(u.target.value),a(void 0)},slotProps:{htmlInput:{style:{fontFamily:"monospace",fontSize:12}}}}),l?r.default.createElement(o.Typography,{color:"error",variant:"body2",sx:{mt:1}},l):null),r.default.createElement(o.DialogActions,null,r.default.createElement(o.Button,{onClick:s},"Cancel"),r.default.createElement(o.Button,{onClick:()=>{f()},variant:"contained",color:"primary",disabled:!n.trim()},"Apply alignment")))}),I=B;export{I as default};
8
- //# sourceMappingURL=ManualAlignmentDialog-YK3AOABQ.js.map
8
+ //# sourceMappingURL=ManualAlignmentDialog-T6V6TALA.js.map
@@ -1,3 +1,3 @@
1
- import{D as et,F as tt,O as it,P as st,Q as lt,R as he,T as be,Y as at,a as to,aa as ut,ba as dt,ca as mt,da as ct,ea as pt,f as Ue,fa as ft,g as ro,ga as gt,h as je,ha as ht,i as Ke,ia as bt,j as Ge,ja as ye,l as qe,la as yt,m as Ye,n as Qe,o as Xe,r as Ze,z as Re}from"./chunk-DQAVCUTJ.js";import{a as eo}from"./chunk-B3HKXTGK.js";import{a as b}from"./chunk-X5RLRQSB.js";import{c as rt,d as ot,f as ge,g as nt}from"./chunk-GQU3SL56.js";import{a as I}from"./chunk-533QNNGN.js";import{c as Ve,d as We,e as Ne}from"./chunk-6WDCIFCW.js";import{a as P}from"./chunk-LOG7ZCI7.js";import{a as fe}from"./chunk-HLB63AD7.js";import{a as z}from"./chunk-HAGLAQP5.js";import{a as v}from"./chunk-GVEKA5YG.js";import{a as k,c as s}from"./chunk-KVMUXFPB.js";var kt=k((qo,Mt)=>{Mt.exports=JBrowseExports["@mui/material/Checkbox"]});var Tt=k((Yo,Ct)=>{Ct.exports=JBrowseExports["@mui/material/Divider"]});var ve=k((Qo,It)=>{It.exports=JBrowseExports["@mui/material/IconButton"]});var Et=k((Xo,Lt)=>{Lt.exports=JBrowseExports["@mui/material/ListItemIcon"]});var Ht=k((Zo,Bt)=>{Bt.exports=JBrowseExports["@mui/material/ListItemText"]});var At=k((Ro,Ft)=>{Ft.exports=JBrowseExports["@mui/material/Menu"]});var zt=k((en,$t)=>{$t.exports=JBrowseExports["@mui/material/MenuItem"]});var xe=k((tn,Dt)=>{Dt.exports=JBrowseExports["@mui/material/Tooltip"]});var Se=k((rn,Jt)=>{Jt.exports=JBrowseExports["@mui/material/Typography"]});var Zt=k((pn,Xt)=>{Xt.exports=JBrowseExports["@mui/material/Chip"]});var er=k((fn,Rt)=>{Rt.exports=JBrowseExports["@mui/material/Link"]});var y=s(v()),F=s(fe());var vt=s(I(),1),O=(0,b.createSvgIcon)((0,vt.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var Zr=s(z()),Q=s(P());var c=s(v()),jr=s(fe());var xt=s(I(),1),St=(0,b.createSvgIcon)((0,xt.jsx)("path",{d:"M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9m5.5 11c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m-3-4c-.83 0-1.5-.67-1.5-1.5S13.67 6 14.5 6s1.5.67 1.5 1.5S15.33 9 14.5 9M5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S7.33 13 6.5 13 5 12.33 5 11.5m6-4c0 .83-.67 1.5-1.5 1.5S8 8.33 8 7.5 8.67 6 9.5 6s1.5.67 1.5 1.5"}),"Palette");var Pt=s(I(),1),wt=(0,b.createSvgIcon)((0,Pt.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var Kr=s(kt()),Gr=s(Tt()),He=s(ve()),qr=s(Et()),Yr=s(Ht()),Fe=s(At()),Ae=s(zt()),$e=s(xe()),ie=s(P());var T=s(v()),Ot=s(Se()),_t={width:8,height:8,border:"1px solid rgba(0,0,0,0.3)"};function Ut({title:o,testId:e,color:r,children:n}){return T.default.createElement(Ot.default,{variant:"caption",color:r,component:"div","data-testid":e,style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,fontSize:9,paddingLeft:8}},T.default.createElement("span",null,o,":"),n)}function we({title:o,entries:e,testId:r="track-legend",color:n="textSecondary"}){return T.default.createElement(Ut,{title:o,testId:r,color:n},e.map(({label:t,color:i},l)=>T.default.createElement("span",{key:`${l}-${t}`,style:{display:"inline-flex",alignItems:"center",gap:3}},T.default.createElement("span",{style:{..._t,background:i}}),t)))}function Me({title:o,minLabel:e,maxLabel:r,colors:n,testId:t="track-legend",color:i="textSecondary"}){return T.default.createElement(Ut,{title:o,testId:t,color:i},e,T.default.createElement("span",{style:{..._t,width:60,background:`linear-gradient(to right, ${n.join(", ")})`}}),r)}function Pe(o){return`#${o.toString(16).padStart(6,"0")}`}function oo(o){return o.replaceAll(/([a-z])([A-Z])(?=[a-z])/g,(e,r,n)=>`${r} ${n.toLowerCase()}`)}function Vt({title:o,legend:e}){return e.kind==="table-legend"?T.default.createElement(we,{title:o,testId:"structure-legend",entries:e.table.map(([r,n])=>({label:oo(r),color:Pe(n)}))}):T.default.createElement(Me,{title:o,testId:"structure-legend",minLabel:e.minLabel,maxLabel:e.maxLabel,colors:e.colors.map(r=>Array.isArray(r)?`${Pe(r[0])} ${100*r[1]}%`:Pe(r))})}var g=s(v());var Wt=s(I(),1),Nt=(0,b.createSvgIcon)((0,Wt.jsx)("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"ChevronRight");var jt=s(I(),1),Kt=(0,b.createSvgIcon)((0,jt.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");var Gt=s(I(),1),qt=(0,b.createSvgIcon)((0,Gt.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var Yt=s(I(),1),Qt=(0,b.createSvgIcon)((0,Yt.jsx)("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");var nr=s(Zt()),re=s(ve()),ir=s(er()),D=s(xe()),K=s(Se()),oe=s(P());var te=s(v()),_=s(z()),tr=s(P());var no=(0,tr.observer)(function({model:e}){let{entities:r,mappedEntity:n,userProvidedTranscriptSequence:t}=e;return!r||r.length<2?null:te.default.createElement(_.Tooltip,{title:t?"Mapped chain: the one the transcript maps to":"Chain: the one hovers read",placement:"left"},te.default.createElement(_.TextField,{select:!0,size:"small",variant:"standard","data-testid":"protein-mapped-chain",value:e.pendingEntityId??n?.entityId??"",onChange:i=>{e.chooseEntity(i.target.value)},slotProps:{input:{disableUnderline:!0,sx:{fontSize:12}},htmlInput:{"aria-label":"Mapped chain"}},sx:{minWidth:60}},r.map(i=>te.default.createElement(_.MenuItem,{key:i.entityId,value:i.entityId,dense:!0},Ze(i)))))}),rr=no;function or(o){return o.aligned===0?"no residues aligned":[`${Math.round(o.identity*100)}% identity`,o.aligned===o.transcriptLength?"whole transcript":`transcript ${o.transcriptStart}\u2013${o.transcriptEnd} (${o.aligned} of ${o.transcriptLength})`,o.aligned<o.structureLength?`${o.aligned} of ${o.structureLength} structure residues`:void 0].filter(Boolean).join(" \xB7 ")}var io=`Under ${Math.round(je*100)}% of the shorter sequence is identical (${Math.round(Ge*100)}% for an alignment of fewer than ${Ke} residues): an alignment this weak is what two unrelated proteins produce, so the positions it maps may be unrelated. Check the mapped chain, the transcript isoform, or import a curated alignment.`,so=(0,oe.observer)(function({structure:e}){let{uniprotId:r,uniprotName:n}=e.uniProtEntry;return r?g.default.createElement(D.default,{title:`The mapped chain is UniProt ${r}${n?` (${n})`:""}, which its feature tracks annotate`},g.default.createElement(ir.default,{variant:"caption",href:tt(r),target:"_blank",rel:"noreferrer",noWrap:!0,sx:{minWidth:40}},"UniProt ",r)):null}),lo=(0,oe.observer)(function({model:e,structure:r,readout:n}){let{label:t,alignmentQuality:i,statusMessage:l,hidden:a}=r,h=e.structures.length>1,p=e.showAlignment&&h,m=e.alignmentStructure===r,f=i?Xe(i):void 0;return g.default.createElement("div",{"data-testid":"structure-row","data-label":t,"data-open":p?m:void 0,"data-hidden":a||void 0,style:{opacity:a?.6:void 0,display:"flex",alignItems:"center",gap:8,minHeight:24,minWidth:0}},p?g.default.createElement(D.default,{title:m?"Alignment shown below":"Show alignment"},g.default.createElement("span",null,g.default.createElement(re.default,{size:"small","aria-label":`Show ${t} alignment`,"aria-expanded":m,disabled:m,onClick:()=>{e.openAlignmentOf(r)},sx:{p:0}},m?g.default.createElement(Kt,{fontSize:"small"}):g.default.createElement(Nt,{fontSize:"small"})))):null,g.default.createElement(K.default,{variant:"caption",sx:{fontWeight:"bold",flexShrink:0}},t),l?g.default.createElement(K.default,{variant:"caption",color:"error","data-testid":"structure-status"},l):null,n?g.default.createElement(K.default,{variant:"caption",noWrap:!0,title:n,"data-testid":"structure-hover"},n):i?g.default.createElement(D.default,{title:i.aligned===0?"":`${Qe(i)}${f?`, ${f}`:""}; ${Ye(i)}`},g.default.createElement(K.default,{variant:"caption",color:"textSecondary",noWrap:!0,"data-testid":"header-alignment-quality"},or(i))):null,g.default.createElement(so,{structure:r}),g.default.createElement("div",{style:{flex:1}}),e.offersChainPicker(r)?g.default.createElement(rr,{model:r}):null,i&&qe(i)?g.default.createElement(D.default,{title:io},g.default.createElement(nr.default,{size:"small",color:"warning",variant:"outlined",label:"low similarity","data-testid":"header-low-similarity"})):null,h||a?g.default.createElement(D.default,{title:a?`Show ${t}`:`Hide ${t}`},g.default.createElement(re.default,{size:"small","aria-label":a?`Show ${t}`:`Hide ${t}`,"aria-pressed":a,onClick:()=>{r.setHidden(!a)},sx:{p:.25}},a?g.default.createElement(Qt,{fontSize:"small"}):g.default.createElement(qt,{fontSize:"small"}))):null,g.default.createElement(D.default,{title:`Remove ${t}`},g.default.createElement(re.default,{size:"small","aria-label":`Remove ${t}`,onClick:()=>{e.removeStructure(r)},sx:{p:.25}},g.default.createElement(O,{fontSize:"small"}))))}),ao=(0,oe.observer)(function({model:e}){let{structures:r}=e,n=r.some(t=>t.hoverPosition&&t.hoverPosition.source!=="structure");return g.default.createElement("div",{style:{flex:1,minWidth:0}},r.map((t,i)=>g.default.createElement(lo,{key:i,model:e,structure:t,readout:t.hoverString||(n&&t.genomeToTranscriptSeqMapping?"not in structure":"")})))}),sr=ao;var d=s(v()),Dr=s(fe()),Jr=s(z()),Or=s(at()),_r=s(P());var Ur=s(to());var ke=s(v()),lr=s(P());function uo(o,e,r){let n=[];if(!o)return n;for(let t=0;t<e;t++){let i=o[t];if(i===void 0)continue;let l=r(i);l%10===0?n.push({col:t,label:`${l}`}):l%5===0&&n.push({col:t})}return n}var mo=(0,lr.observer)(function({model:e,columns:r}){let{columnWidth:n}=e,t=uo(e.pairwiseAlignmentToStructurePosition,r,i=>e.residueNumber(i));return ke.default.createElement("div",{style:{position:"relative",height:"100%",color:"#888",fontSize:8}},t.map(({col:i,label:l})=>ke.default.createElement("span",{key:i,style:{position:"absolute",left:i*n,top:0,bottom:0,borderLeft:"1px solid #aaa",paddingLeft:2,lineHeight:`${12}px`,whiteSpace:"nowrap"}},l)))}),ar=mo;var C=s(v()),Ce=s(P());function G({start:o,end:e,columnWidth:r,background:n,border:t}){return C.default.createElement("div",{style:{position:"absolute",top:0,bottom:0,left:o*r,width:(e-o+1)*r,background:n,border:t,boxSizing:"border-box",pointerEvents:"none"}})}function ur({zIndex:o,children:e}){return C.default.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:o}},e)}var dr=(0,Ce.observer)(function({model:e,matchHeight:r}){let{clickAlignmentRanges:n,columnWidth:t,showHighlight:i,alignmentMatchSet:l}=e;return C.default.createElement(ur,{zIndex:0},i&&l?C.default.createElement("div",{style:{position:"relative",height:r}},yt(l).map(a=>C.default.createElement(G,{key:a.start,start:a.start,end:a.end-1,columnWidth:t,background:pt}))):null,n.map(a=>C.default.createElement(G,{key:a.start,start:a.start,end:a.end,columnWidth:t,background:mt})))}),co=(0,Ce.observer)(function({model:e}){let{clickAlignmentRanges:r,alignmentHoverRange:n,alignmentHoverPos:t,columnWidth:i}=e;return C.default.createElement(ur,{zIndex:1},r.map(l=>C.default.createElement(G,{key:l.start,start:l.start,end:l.end,columnWidth:i,background:"transparent",border:ct})),n?C.default.createElement(G,{start:n.start,end:n.end,columnWidth:i,background:dt}):null,t===void 0?null:C.default.createElement(G,{start:t,end:t,columnWidth:i,background:ut}))}),mr=co;var L=s(v());var cr=s(I(),1),pr=(0,b.createSvgIcon)((0,cr.jsx)("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");var fr=s(I(),1),gr=(0,b.createSvgIcon)((0,fr.jsx)("path",{d:"M12 5.83 15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15z"}),"UnfoldMore");var q=s(z()),hr=s(P());var fo=(0,hr.observer)(function({type:e,laneCount:r,model:n}){let t=n.expandedFeatureTypes.has(e),i=Math.min(n.trackHeight,12);return L.default.createElement(q.Tooltip,{title:e,placement:"left"},L.default.createElement("div",{style:{height:"100%",whiteSpace:"nowrap",display:"flex",alignItems:t?"flex-start":"center",justifyContent:"flex-end",gap:2}},L.default.createElement(q.IconButton,{onClick:()=>{n.hideFeatureType(e)},title:`Hide ${e} track`,sx:{p:0,color:ye}},L.default.createElement(O,{sx:{fontSize:i}})),r>1?L.default.createElement(q.IconButton,{onClick:()=>{n.toggleFeatureTypeExpanded(e)},title:t?`Collapse ${e} track`:`Expand ${e} track (${r} overlapping rows)`,sx:{p:0,color:ye}},t?L.default.createElement(pr,{sx:{fontSize:i}}):L.default.createElement(gr,{sx:{fontSize:i}})):null,L.default.createElement("span",null,e)))}),br=fo;var vr=s(v()),xr=s(P());function go(o,e,r){if(!(!o||!e||o==="-"||e==="-"||o.toUpperCase()===e.toUpperCase()))return r===":"||r==="."?"similar":"different"}function yr(o){let e=o.alns[0]?.seq??"",r=o.alns[1]?.seq??"",n=[];for(let t=0;t<e.length;t++){let i=go(e[t],r[t],o.consensus[t]),l=n.at(-1);i&&l?.kind===i&&l.end===t?l.end=t+1:i&&n.push({start:t,end:t+1,kind:i})}return n}var ho=(0,xr.observer)(function({model:e}){let{alignment:r,columnWidth:n}=e;return r?yr(r).map(t=>vr.default.createElement("div",{key:t.start,style:{position:"absolute",top:0,bottom:0,left:t.start*n,width:(t.end-t.start)*n,background:t.kind==="similar"?ft:gt}})):null}),Sr=ho;var Cr=s(v()),Tr=s(P());var M=s(v()),wr=s(z()),Mr=s(P());var bo={Domain:"#1f77b4","DNA binding":"#ff7f0e",Region:"#2ca02c","Zinc finger":"#d62728","Coiled coil":"#9467bd",Motif:"#8c564b","Compositional bias":"#e377c2",Repeat:"#7f7f7f",Transmembrane:"#bcbd22",Intramembrane:"#17becf","Topological domain":"#aec7e8",Signal:"#ffbb78","Signal peptide":"#ffbb78",Propeptide:"#98df8a","Transit peptide":"#ff9896",Chain:"#c5b0d5","Disulfide bond":"#c49c94","Active site":"#f7b6d2","Binding site":"#c7c7c7",Site:"#dbdb8d","Modified residue":"#9edae5",Glycosylation:"#393b79",Lipidation:"#637939","Cross-link":"#8c6d31","Alternative sequence":"#e7969c","Natural variant":"#de9ed6",Mutagenesis:"#ad494a","Sequence conflict":"#b5cf6b",Helix:"#e7ba52","Beta strand":"#6b6ecf",Turn:"#d6616b","Initiator methionine":"#ce6dbd",Peptide:"#6baed6","Calcium binding":"#fd8d3c","Nucleotide binding":"#74c476"};function Pr(o){return bo[o]??"#999999"}async function yo(o){let e=await(await Re(o)).text(),r=[];for(let n of e.split(`
1
+ import{D as et,F as tt,O as it,P as st,Q as lt,R as he,T as be,Y as at,a as to,aa as ut,ba as dt,ca as mt,da as ct,ea as pt,f as Ue,fa as ft,g as ro,ga as gt,h as je,ha as ht,i as Ke,ia as bt,j as Ge,ja as ye,l as qe,la as yt,m as Ye,n as Qe,o as Xe,r as Ze,z as Re}from"./chunk-NSRFB7YQ.js";import{a as eo}from"./chunk-B3HKXTGK.js";import{a as b}from"./chunk-X5RLRQSB.js";import{c as rt,d as ot,f as ge,g as nt}from"./chunk-GQU3SL56.js";import{a as I}from"./chunk-533QNNGN.js";import{c as Ve,d as We,e as Ne}from"./chunk-3QM6HC4V.js";import{a as P}from"./chunk-LOG7ZCI7.js";import{a as fe}from"./chunk-HLB63AD7.js";import{a as z}from"./chunk-HAGLAQP5.js";import{a as v}from"./chunk-GVEKA5YG.js";import{a as k,c as s}from"./chunk-KVMUXFPB.js";var kt=k((qo,Mt)=>{Mt.exports=JBrowseExports["@mui/material/Checkbox"]});var Tt=k((Yo,Ct)=>{Ct.exports=JBrowseExports["@mui/material/Divider"]});var ve=k((Qo,It)=>{It.exports=JBrowseExports["@mui/material/IconButton"]});var Et=k((Xo,Lt)=>{Lt.exports=JBrowseExports["@mui/material/ListItemIcon"]});var Ht=k((Zo,Bt)=>{Bt.exports=JBrowseExports["@mui/material/ListItemText"]});var At=k((Ro,Ft)=>{Ft.exports=JBrowseExports["@mui/material/Menu"]});var zt=k((en,$t)=>{$t.exports=JBrowseExports["@mui/material/MenuItem"]});var xe=k((tn,Dt)=>{Dt.exports=JBrowseExports["@mui/material/Tooltip"]});var Se=k((rn,Jt)=>{Jt.exports=JBrowseExports["@mui/material/Typography"]});var Zt=k((pn,Xt)=>{Xt.exports=JBrowseExports["@mui/material/Chip"]});var er=k((fn,Rt)=>{Rt.exports=JBrowseExports["@mui/material/Link"]});var y=s(v()),F=s(fe());var vt=s(I(),1),O=(0,b.createSvgIcon)((0,vt.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var Zr=s(z()),Q=s(P());var c=s(v()),jr=s(fe());var xt=s(I(),1),St=(0,b.createSvgIcon)((0,xt.jsx)("path",{d:"M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9m5.5 11c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m-3-4c-.83 0-1.5-.67-1.5-1.5S13.67 6 14.5 6s1.5.67 1.5 1.5S15.33 9 14.5 9M5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S7.33 13 6.5 13 5 12.33 5 11.5m6-4c0 .83-.67 1.5-1.5 1.5S8 8.33 8 7.5 8.67 6 9.5 6s1.5.67 1.5 1.5"}),"Palette");var Pt=s(I(),1),wt=(0,b.createSvgIcon)((0,Pt.jsx)("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"}),"Tune");var Kr=s(kt()),Gr=s(Tt()),He=s(ve()),qr=s(Et()),Yr=s(Ht()),Fe=s(At()),Ae=s(zt()),$e=s(xe()),ie=s(P());var T=s(v()),Ot=s(Se()),_t={width:8,height:8,border:"1px solid rgba(0,0,0,0.3)"};function Ut({title:o,testId:e,color:r,children:n}){return T.default.createElement(Ot.default,{variant:"caption",color:r,component:"div","data-testid":e,style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:6,fontSize:9,paddingLeft:8}},T.default.createElement("span",null,o,":"),n)}function we({title:o,entries:e,testId:r="track-legend",color:n="textSecondary"}){return T.default.createElement(Ut,{title:o,testId:r,color:n},e.map(({label:t,color:i},l)=>T.default.createElement("span",{key:`${l}-${t}`,style:{display:"inline-flex",alignItems:"center",gap:3}},T.default.createElement("span",{style:{..._t,background:i}}),t)))}function Me({title:o,minLabel:e,maxLabel:r,colors:n,testId:t="track-legend",color:i="textSecondary"}){return T.default.createElement(Ut,{title:o,testId:t,color:i},e,T.default.createElement("span",{style:{..._t,width:60,background:`linear-gradient(to right, ${n.join(", ")})`}}),r)}function Pe(o){return`#${o.toString(16).padStart(6,"0")}`}function oo(o){return o.replaceAll(/([a-z])([A-Z])(?=[a-z])/g,(e,r,n)=>`${r} ${n.toLowerCase()}`)}function Vt({title:o,legend:e}){return e.kind==="table-legend"?T.default.createElement(we,{title:o,testId:"structure-legend",entries:e.table.map(([r,n])=>({label:oo(r),color:Pe(n)}))}):T.default.createElement(Me,{title:o,testId:"structure-legend",minLabel:e.minLabel,maxLabel:e.maxLabel,colors:e.colors.map(r=>Array.isArray(r)?`${Pe(r[0])} ${100*r[1]}%`:Pe(r))})}var g=s(v());var Wt=s(I(),1),Nt=(0,b.createSvgIcon)((0,Wt.jsx)("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}),"ChevronRight");var jt=s(I(),1),Kt=(0,b.createSvgIcon)((0,jt.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");var Gt=s(I(),1),qt=(0,b.createSvgIcon)((0,Gt.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var Yt=s(I(),1),Qt=(0,b.createSvgIcon)((0,Yt.jsx)("path",{d:"M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z"}),"VisibilityOff");var nr=s(Zt()),re=s(ve()),ir=s(er()),D=s(xe()),K=s(Se()),oe=s(P());var te=s(v()),_=s(z()),tr=s(P());var no=(0,tr.observer)(function({model:e}){let{entities:r,mappedEntity:n,userProvidedTranscriptSequence:t}=e;return!r||r.length<2?null:te.default.createElement(_.Tooltip,{title:t?"Mapped chain: the one the transcript maps to":"Chain: the one hovers read",placement:"left"},te.default.createElement(_.TextField,{select:!0,size:"small",variant:"standard","data-testid":"protein-mapped-chain",value:e.pendingEntityId??n?.entityId??"",onChange:i=>{e.chooseEntity(i.target.value)},slotProps:{input:{disableUnderline:!0,sx:{fontSize:12}},htmlInput:{"aria-label":"Mapped chain"}},sx:{minWidth:60}},r.map(i=>te.default.createElement(_.MenuItem,{key:i.entityId,value:i.entityId,dense:!0},Ze(i)))))}),rr=no;function or(o){return o.aligned===0?"no residues aligned":[`${Math.round(o.identity*100)}% identity`,o.aligned===o.transcriptLength?"whole transcript":`transcript ${o.transcriptStart}\u2013${o.transcriptEnd} (${o.aligned} of ${o.transcriptLength})`,o.aligned<o.structureLength?`${o.aligned} of ${o.structureLength} structure residues`:void 0].filter(Boolean).join(" \xB7 ")}var io=`Under ${Math.round(je*100)}% of the shorter sequence is identical (${Math.round(Ge*100)}% for an alignment of fewer than ${Ke} residues): an alignment this weak is what two unrelated proteins produce, so the positions it maps may be unrelated. Check the mapped chain, the transcript isoform, or import a curated alignment.`,so=(0,oe.observer)(function({structure:e}){let{uniprotId:r,uniprotName:n}=e.uniProtEntry;return r?g.default.createElement(D.default,{title:`The mapped chain is UniProt ${r}${n?` (${n})`:""}, which its feature tracks annotate`},g.default.createElement(ir.default,{variant:"caption",href:tt(r),target:"_blank",rel:"noreferrer",noWrap:!0,sx:{minWidth:40}},"UniProt ",r)):null}),lo=(0,oe.observer)(function({model:e,structure:r,readout:n}){let{label:t,alignmentQuality:i,statusMessage:l,hidden:a}=r,h=e.structures.length>1,p=e.showAlignment&&h,m=e.alignmentStructure===r,f=i?Xe(i):void 0;return g.default.createElement("div",{"data-testid":"structure-row","data-label":t,"data-open":p?m:void 0,"data-hidden":a||void 0,style:{opacity:a?.6:void 0,display:"flex",alignItems:"center",gap:8,minHeight:24,minWidth:0}},p?g.default.createElement(D.default,{title:m?"Alignment shown below":"Show alignment"},g.default.createElement("span",null,g.default.createElement(re.default,{size:"small","aria-label":`Show ${t} alignment`,"aria-expanded":m,disabled:m,onClick:()=>{e.openAlignmentOf(r)},sx:{p:0}},m?g.default.createElement(Kt,{fontSize:"small"}):g.default.createElement(Nt,{fontSize:"small"})))):null,g.default.createElement(K.default,{variant:"caption",sx:{fontWeight:"bold",flexShrink:0}},t),l?g.default.createElement(K.default,{variant:"caption",color:"error","data-testid":"structure-status"},l):null,n?g.default.createElement(K.default,{variant:"caption",noWrap:!0,title:n,"data-testid":"structure-hover"},n):i?g.default.createElement(D.default,{title:i.aligned===0?"":`${Qe(i)}${f?`, ${f}`:""}; ${Ye(i)}`},g.default.createElement(K.default,{variant:"caption",color:"textSecondary",noWrap:!0,"data-testid":"header-alignment-quality"},or(i))):null,g.default.createElement(so,{structure:r}),g.default.createElement("div",{style:{flex:1}}),e.offersChainPicker(r)?g.default.createElement(rr,{model:r}):null,i&&qe(i)?g.default.createElement(D.default,{title:io},g.default.createElement(nr.default,{size:"small",color:"warning",variant:"outlined",label:"low similarity","data-testid":"header-low-similarity"})):null,h||a?g.default.createElement(D.default,{title:a?`Show ${t}`:`Hide ${t}`},g.default.createElement(re.default,{size:"small","aria-label":a?`Show ${t}`:`Hide ${t}`,"aria-pressed":a,onClick:()=>{r.setHidden(!a)},sx:{p:.25}},a?g.default.createElement(Qt,{fontSize:"small"}):g.default.createElement(qt,{fontSize:"small"}))):null,g.default.createElement(D.default,{title:`Remove ${t}`},g.default.createElement(re.default,{size:"small","aria-label":`Remove ${t}`,onClick:()=>{e.removeStructure(r)},sx:{p:.25}},g.default.createElement(O,{fontSize:"small"}))))}),ao=(0,oe.observer)(function({model:e}){let{structures:r}=e,n=r.some(t=>t.hoverPosition&&t.hoverPosition.source!=="structure");return g.default.createElement("div",{style:{flex:1,minWidth:0}},r.map((t,i)=>g.default.createElement(lo,{key:i,model:e,structure:t,readout:t.hoverString||(n&&t.genomeToTranscriptSeqMapping?"not in structure":"")})))}),sr=ao;var d=s(v()),Dr=s(fe()),Jr=s(z()),Or=s(at()),_r=s(P());var Ur=s(to());var ke=s(v()),lr=s(P());function uo(o,e,r){let n=[];if(!o)return n;for(let t=0;t<e;t++){let i=o[t];if(i===void 0)continue;let l=r(i);l%10===0?n.push({col:t,label:`${l}`}):l%5===0&&n.push({col:t})}return n}var mo=(0,lr.observer)(function({model:e,columns:r}){let{columnWidth:n}=e,t=uo(e.pairwiseAlignmentToStructurePosition,r,i=>e.residueNumber(i));return ke.default.createElement("div",{style:{position:"relative",height:"100%",color:"#888",fontSize:8}},t.map(({col:i,label:l})=>ke.default.createElement("span",{key:i,style:{position:"absolute",left:i*n,top:0,bottom:0,borderLeft:"1px solid #aaa",paddingLeft:2,lineHeight:`${12}px`,whiteSpace:"nowrap"}},l)))}),ar=mo;var C=s(v()),Ce=s(P());function G({start:o,end:e,columnWidth:r,background:n,border:t}){return C.default.createElement("div",{style:{position:"absolute",top:0,bottom:0,left:o*r,width:(e-o+1)*r,background:n,border:t,boxSizing:"border-box",pointerEvents:"none"}})}function ur({zIndex:o,children:e}){return C.default.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:o}},e)}var dr=(0,Ce.observer)(function({model:e,matchHeight:r}){let{clickAlignmentRanges:n,columnWidth:t,showHighlight:i,alignmentMatchSet:l}=e;return C.default.createElement(ur,{zIndex:0},i&&l?C.default.createElement("div",{style:{position:"relative",height:r}},yt(l).map(a=>C.default.createElement(G,{key:a.start,start:a.start,end:a.end-1,columnWidth:t,background:pt}))):null,n.map(a=>C.default.createElement(G,{key:a.start,start:a.start,end:a.end,columnWidth:t,background:mt})))}),co=(0,Ce.observer)(function({model:e}){let{clickAlignmentRanges:r,alignmentHoverRange:n,alignmentHoverPos:t,columnWidth:i}=e;return C.default.createElement(ur,{zIndex:1},r.map(l=>C.default.createElement(G,{key:l.start,start:l.start,end:l.end,columnWidth:i,background:"transparent",border:ct})),n?C.default.createElement(G,{start:n.start,end:n.end,columnWidth:i,background:dt}):null,t===void 0?null:C.default.createElement(G,{start:t,end:t,columnWidth:i,background:ut}))}),mr=co;var L=s(v());var cr=s(I(),1),pr=(0,b.createSvgIcon)((0,cr.jsx)("path",{d:"M7.41 18.59 8.83 20 12 16.83 15.17 20l1.41-1.41L12 14zm9.18-13.18L15.17 4 12 7.17 8.83 4 7.41 5.41 12 10z"}),"UnfoldLess");var fr=s(I(),1),gr=(0,b.createSvgIcon)((0,fr.jsx)("path",{d:"M12 5.83 15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15z"}),"UnfoldMore");var q=s(z()),hr=s(P());var fo=(0,hr.observer)(function({type:e,laneCount:r,model:n}){let t=n.expandedFeatureTypes.has(e),i=Math.min(n.trackHeight,12);return L.default.createElement(q.Tooltip,{title:e,placement:"left"},L.default.createElement("div",{style:{height:"100%",whiteSpace:"nowrap",display:"flex",alignItems:t?"flex-start":"center",justifyContent:"flex-end",gap:2}},L.default.createElement(q.IconButton,{onClick:()=>{n.hideFeatureType(e)},title:`Hide ${e} track`,sx:{p:0,color:ye}},L.default.createElement(O,{sx:{fontSize:i}})),r>1?L.default.createElement(q.IconButton,{onClick:()=>{n.toggleFeatureTypeExpanded(e)},title:t?`Collapse ${e} track`:`Expand ${e} track (${r} overlapping rows)`,sx:{p:0,color:ye}},t?L.default.createElement(pr,{sx:{fontSize:i}}):L.default.createElement(gr,{sx:{fontSize:i}})):null,L.default.createElement("span",null,e)))}),br=fo;var vr=s(v()),xr=s(P());function go(o,e,r){if(!(!o||!e||o==="-"||e==="-"||o.toUpperCase()===e.toUpperCase()))return r===":"||r==="."?"similar":"different"}function yr(o){let e=o.alns[0]?.seq??"",r=o.alns[1]?.seq??"",n=[];for(let t=0;t<e.length;t++){let i=go(e[t],r[t],o.consensus[t]),l=n.at(-1);i&&l?.kind===i&&l.end===t?l.end=t+1:i&&n.push({start:t,end:t+1,kind:i})}return n}var ho=(0,xr.observer)(function({model:e}){let{alignment:r,columnWidth:n}=e;return r?yr(r).map(t=>vr.default.createElement("div",{key:t.start,style:{position:"absolute",top:0,bottom:0,left:t.start*n,width:(t.end-t.start)*n,background:t.kind==="similar"?ft:gt}})):null}),Sr=ho;var Cr=s(v()),Tr=s(P());var M=s(v()),wr=s(z()),Mr=s(P());var bo={Domain:"#1f77b4","DNA binding":"#ff7f0e",Region:"#2ca02c","Zinc finger":"#d62728","Coiled coil":"#9467bd",Motif:"#8c564b","Compositional bias":"#e377c2",Repeat:"#7f7f7f",Transmembrane:"#bcbd22",Intramembrane:"#17becf","Topological domain":"#aec7e8",Signal:"#ffbb78","Signal peptide":"#ffbb78",Propeptide:"#98df8a","Transit peptide":"#ff9896",Chain:"#c5b0d5","Disulfide bond":"#c49c94","Active site":"#f7b6d2","Binding site":"#c7c7c7",Site:"#dbdb8d","Modified residue":"#9edae5",Glycosylation:"#393b79",Lipidation:"#637939","Cross-link":"#8c6d31","Alternative sequence":"#e7969c","Natural variant":"#de9ed6",Mutagenesis:"#ad494a","Sequence conflict":"#b5cf6b",Helix:"#e7ba52","Beta strand":"#6b6ecf",Turn:"#d6616b","Initiator methionine":"#ce6dbd",Peptide:"#6baed6","Calcium binding":"#fd8d3c","Nucleotide binding":"#74c476"};function Pr(o){return bo[o]??"#999999"}async function yo(o){let e=await(await Re(o)).text(),r=[];for(let n of e.split(`
2
2
  `)){if(n.startsWith("#")||!n.trim())continue;let t=n.split(" ");if(t.length<9)continue;let i=t[2],l=Number.parseInt(t[3]??"",10),a=Number.parseInt(t[4]??"",10),p=(t[8]??"").split(";").find(m=>m.startsWith("Note="))?.slice(5);i&&l>=1&&a>=l&&r.push({type:i,start:l,end:a,description:decodeURIComponent(p??""),uniqueId:`${i}-${l}-${a}-${r.length}`})}return r}function Te(o){let{data:e,error:r,isLoading:n}=it(o?et(o):null,yo,st);return{features:e,error:r,isLoading:n}}function vo({feature:o,layout:e,model:r}){let n=r.residueNumber(e.structureStart),t=r.residueNumber(e.structureEnd-1),i=n!==o.start||t!==o.end;return M.default.createElement("div",null,M.default.createElement("div",null,M.default.createElement("strong",null,o.type)),M.default.createElement("div",null,"UniProt position: ",o.start,"-",o.end),i?M.default.createElement("div",null,"Structure residue: ",n,"-",t,e.clipped?" (the structure lacks the rest)":""):null,o.description?M.default.createElement("div",null,o.description):null)}var xo=(0,Mr.observer)(function({layout:e,top:r,height:n,selected:t,model:i}){let[l,a]=(0,M.useState)(!1),{feature:h,alignmentStart:p,alignmentEnd:m}=e,{columnWidth:f}=i;return M.default.createElement(wr.Tooltip,{title:M.default.createElement(vo,{feature:h,layout:e,model:i}),followCursor:!0},M.default.createElement("div",{"data-testid":`protein-feature-${h.type}`,"data-feature-id":h.uniqueId,"data-feature-start":h.start,"data-feature-end":h.end,onClick:()=>{t?(i.setSelectedFeatureId(void 0),i.setClickedStructureRanges([])):(i.selectResidues(e.structureStart,e.structureEnd),i.setSelectedFeatureId(h.uniqueId))},onMouseEnter:()=>{a(!0),i.setAlignmentHoverRange({start:p,end:m})},onMouseLeave:()=>{a(!1),i.setAlignmentHoverRange(void 0)},style:{position:"absolute",left:p*f,top:r,width:(m-p+1)*f,height:n,backgroundColor:Pr(h.type),opacity:l||t?.9:.6,cursor:"pointer",borderRadius:2,border:t?ht:l?bt:"none",boxSizing:"border-box"}}))}),kr=xo;var So=(0,Tr.observer)(function({group:e,model:r}){let{selectedFeatureId:n,trackGap:t}=r,i=r.expandedFeatureTypes.has(e.type)?e.laneCount:1,l=`calc(${100/i}% - ${t}px)`;return e.layouts.map(a=>Cr.default.createElement(kr,{key:a.feature.uniqueId,layout:a,top:`${Math.min(a.lane,i-1)/i*100}%`,height:l,selected:n===a.feature.uniqueId,model:r}))}),Ir=So;var H=s(v()),Lr=s(z()),Ie=s(P()),Po=(0,Ie.observer)(function({cells:e,colorFor:r,model:n}){let{columnWidth:t,trackGap:i}=n;return H.default.createElement("div",{style:{position:"relative",height:`calc(100% - ${i}px)`}},e.map(l=>H.default.createElement("div",{key:l.col,style:{position:"absolute",left:l.col*t,width:t,height:"100%",backgroundColor:r(l.value)}})))}),wo=(0,Ie.observer)(function({cells:e,colorFor:r,formatValue:n,model:t}){let i=(0,H.useMemo)(()=>new Map(e.map(h=>[h.col,h.value])),[e]),{alignmentHoverPos:l}=t,a=l===void 0?void 0:i.get(l);return H.default.createElement(Lr.Tooltip,{title:a===void 0?"":n(a),followCursor:!0},H.default.createElement("div",{style:{height:"100%"}},H.default.createElement(Po,{cells:e,colorFor:r,model:t})))}),Le=wo;var Er=s(v()),Br=s(P()),Mo=(0,Br.observer)(function({model:e,str:r}){let{columnWidth:n}=e;return r.split("").map((t,i)=>Er.default.createElement("span",{key:i,style:{position:"absolute",left:i*n,width:n}},t===" "?"\xA0":t))}),Hr=Mo;var Fr=s(at());function ko({x:o,width:e,scrollLeft:r,clientWidth:n}){return o>=r&&o+e<=r+n?void 0:o+e/2-n/2}function Ar({start:o,end:e,scrollLeft:r,clientWidth:n}){let t=r+n;return e>=r&&o<=t?void 0:(o+e)/2-n/2}function $r(o,e){return(0,Fr.reaction)(()=>o.alignmentHoverPos,r=>{let n=e();if(r!==void 0&&n&&o.autoScrollAlignment&&!o.isMouseInAlignment){let t=ko({x:r*o.columnWidth,width:o.columnWidth,scrollLeft:n.scrollLeft,clientWidth:n.clientWidth});t!==void 0&&(n.scrollLeft=t)}})}var zr=s(v());var Co=new Set(["Disulfide bond","Cross-link"]);function To(o,e,r){let n=p=>{let m=r(p),f=m===void 0?void 0:e[m];return m===void 0||f===void 0?void 0:{structurePos:m,column:f}},t=o.start,i=n(t);for(;!i&&t<o.end;)i=n(++t);let l=o.end,a=n(l);for(;!a&&l>t;)a=n(--l);let h=t!==o.start||l!==o.end;return!i||!a||h&&Co.has(o.type)?void 0:{feature:o,structureStart:i.structurePos,structureEnd:a.structurePos+1,alignmentStart:i.column,alignmentEnd:a.column,clipped:h,lane:0}}function Io(o){let e=[],r=[...o].sort((n,t)=>n.alignmentStart-t.alignmentStart);for(let n of r){let t=e.findIndex(i=>i<n.alignmentStart);t===-1?(n.lane=e.length,e.push(n.alignmentEnd)):(n.lane=t,e[t]=n.alignmentEnd)}return Math.max(e.length,1)}function Lo(o){return[...o].sort((e,r)=>r.alignmentEnd-r.alignmentStart-(e.alignmentEnd-e.alignmentStart))}function Ee(o,e,r){let{features:n,isLoading:t,error:i}=Te(e),{omittedFeatureTypes:l,structurePositionToAlignmentMap:a}=o;return{groups:(0,zr.useMemo)(()=>{if(!n||!a)return;let p=new Map;for(let m of n)if(!l.has(m.type)){let f=To(m,a,r);if(f){let w=p.get(m.type);w?w.push(f):p.set(m.type,[f])}}return[...p].map(([m,f])=>({type:m,laneCount:Io(f),layouts:Lo(f)}))},[n,l,a,r]),isLoading:t,error:i}}var Bo=(0,Ur.makeStyles)()(o=>({scroll:{overflow:"auto",whiteSpace:"nowrap",flex:1,paddingBottom:2,backgroundColor:o.palette.background.paper},trackMessage:{position:"sticky",left:0,lineHeight:`${12}px`,color:o.palette.text.secondary},trackError:{color:o.palette.error.main}}));function Y({label:o,title:e}){return d.default.createElement(Jr.Tooltip,{title:e,placement:"left"},d.default.createElement("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"flex-end"}},o))}var Ho=(0,_r.observer)(function({model:e}){let{alignment:r,showProteinTracks:n,showAllFeatureTracks:t,label:i,confidenceCells:l,columnWidth:a,laneHeight:h}=e,p=t?e.hydrophobicityCells:[],{classes:m,cx:f}=Bo(),w=(0,d.useRef)(null),V=(0,d.useRef)(void 0),{uniprotId:W,mapUniProtPosition:se,isLoading:X,error:Z,isoformAccession:N}=e.uniProtEntry,{groups:le,isLoading:ae,error:ue}=Ee(e,N?void 0:W,se),R=X||ae,A=Z??ue,j=A?`${Z?`Could not map ${i} to a UniProt entry through SIFTS`:`Could not load UniProt features for ${W??i}`}: ${Ue(A)}`:void 0;if((0,d.useEffect)(()=>$r(e,()=>w.current),[e]),(0,d.useEffect)(()=>(0,Or.autorun)(()=>{let u=w.current,x=e.clickAlignmentRanges,S=x[0];if(u)if(S){let J=x.map($=>`${$.start}-${$.end}`).join(",");if(J!==V.current){V.current=J;let $=Ar({start:S.start*e.columnWidth,end:(S.end+1)*e.columnWidth,scrollLeft:u.scrollLeft,clientWidth:u.clientWidth});$!==void 0&&(u.scrollLeft=$)}}else V.current=void 0}),[e]),!r)return null;let de=Ne(r),Je=(u,x,S,J,$)=>({key:u,height:12,label:d.default.createElement(Y,{label:x,title:S}),content:d.default.createElement("div",{style:{lineHeight:`${12}px`}},$,d.default.createElement(Hr,{model:e,str:J})),selectsResidue:!0}),me=j??(N?`UniProt features are numbered for ${W}; this model is isoform ${N}`:R?"Loading UniProt features...":""),Oe=[Je("transcript","GENOME","The protein as the reference genome's transcript translates",Ve(r)),Je("structure","STRUCT","The protein as the structure file spells it. Shaded where it differs from the transcript's: amber for a similar amino acid, red for a different one.",We(r),d.default.createElement(Sr,{model:e}))],ee=[...Oe,{key:"ruler",height:12,label:d.default.createElement(Y,{label:"residue",title:"Residue numbers as the structure's authors assigned them, the numbering papers and the 3D view's hover label use"}),content:d.default.createElement(ar,{model:e,columns:de}),selectsResidue:!0}],Rr=Oe.length*12,ce=0,pe=(u,x,S,J)=>{ce+=x,ee.push({key:u,height:x*h,label:S,content:J})};if(n){me&&ee.push({key:"uniprot-status",height:12,label:d.default.createElement(Y,{label:"UniProt",title:me}),content:d.default.createElement("span",{className:f(m.trackMessage,j&&m.trackError)},me)});for(let u of le??[])pe(`feature-${u.type}`,e.expandedFeatureTypes.has(u.type)?u.laneCount:1,d.default.createElement(br,{type:u.type,laneCount:u.laneCount,model:e}),d.default.createElement(Ir,{group:u,model:e}));l.length>0&&pe("plddt",1,d.default.createElement(Y,{label:"pLDDT",title:d.default.createElement(we,{title:"AlphaFold per-residue confidence (pLDDT)",entries:rt,color:"inherit"})}),d.default.createElement(Le,{cells:l,colorFor:ot,formatValue:u=>`pLDDT ${u.toFixed(0)}`,model:e})),p.length>0&&pe("hydrophobicity",1,d.default.createElement(Y,{label:"hydro",title:d.default.createElement(Me,{title:"Kyte-Doolittle hydrophobicity",testId:"hydrophobicity-legend",minLabel:"hydrophilic",maxLabel:"hydrophobic",colors:nt.map(u=>ge(u)),color:"inherit"})}),d.default.createElement(Le,{cells:p,colorFor:ge,formatValue:u=>`Kyte-Doolittle ${u.toFixed(1)}`,model:e}))}let _e=u=>{let{left:x}=u.currentTarget.getBoundingClientRect(),S=Math.floor((u.clientX-x)/a);return S>=0&&S<de?S:void 0};return d.default.createElement("div",{"data-testid":"protein-alignment-panel","data-structure":i},d.default.createElement("div",{style:{display:"flex",fontSize:9,fontFamily:"monospace",margin:"2px 8px 4px"},onMouseEnter:()=>{e.setIsMouseInAlignment(!0)},onMouseLeave:()=>{e.leaveAlignment()}},d.default.createElement("div",{style:{flexShrink:0,minWidth:124,paddingRight:4,whiteSpace:"nowrap",lineHeight:1}},ee.map(u=>d.default.createElement("div",{key:u.key,"data-row-label":u.key,style:{height:u.height,overflow:"hidden"}},u.label))),d.default.createElement("div",{ref:w,className:m.scroll},d.default.createElement("div",{"data-testid":"alignment-rows",style:{position:"relative",width:de*a},onMouseMove:u=>{let x=_e(u);x===void 0?e.setHoveredPosition(void 0):e.hoverAlignmentPosition(x)},onMouseLeave:()=>{e.setHoveredPosition(void 0)}},d.default.createElement(dr,{model:e,matchHeight:Rr}),ee.map(u=>d.default.createElement("div",{key:u.key,"data-row":u.key,style:{position:"relative",height:u.height,cursor:u.selectsResidue?"pointer":void 0},onClick:u.selectsResidue?x=>{let S=_e(x);S!==void 0&&e.clickAlignmentPosition(S)}:void 0},u.content)),d.default.createElement(mr,{model:e})))),ce>0?d.default.createElement(Dr.ResizeHandle,{bar:!0,title:"Drag to resize the feature tracks","data-testid":"feature-tracks-resize-handle",gain:ce,onDrag:u=>{e.resizeTracks(u)}}):null)}),Vr=Ho;var U=s(v()),Wr=s(eo());var ne=s(z()),Fo=(0,U.lazy)(()=>import("./ProteinAlignmentHelpDialog-LURGMLCI.js"));function Be({model:o}){return U.default.createElement(ne.Tooltip,{title:"What the alignment panel shows"},U.default.createElement(ne.IconButton,{size:"small",onClick:()=>{(0,Wr.getSession)(o).queueDialog(e=>[Fo,{handleClose:e}])}},U.default.createElement(lt,{fontSize:"small"})))}var Ao=(0,ie.observer)(function({model:e}){let[r,n]=(0,c.useState)(null),i=`Color scheme: ${be.find(l=>l.value===e.colorScheme)?.label??e.colorScheme}`;return c.default.createElement(c.default.Fragment,null,c.default.createElement($e.default,{title:i},c.default.createElement(He.default,{size:"small","aria-label":i,onClick:l=>{n(l.currentTarget)}},c.default.createElement(St,{fontSize:"small"}))),c.default.createElement(Fe.default,{anchorEl:r,open:!!r,onClose:()=>{n(null)}},be.map(l=>c.default.createElement(Ae.default,{key:l.value,dense:!0,selected:l.value===e.colorScheme,onClick:()=>{e.setColorScheme(l.value),n(null)}},l.label))))});function Nr({checked:o,label:e,disabled:r,onToggle:n}){return c.default.createElement(Ae.default,{onClick:()=>{n()},disabled:r,dense:!0},c.default.createElement(qr.default,null,c.default.createElement(Kr.default,{checked:o,size:"small",edge:"start",disableRipple:!0})),c.default.createElement(Yr.default,null,e))}var $o=(0,ie.observer)(function({model:e}){let[r,n]=(0,c.useState)(null);return c.default.createElement(c.default.Fragment,null,c.default.createElement($e.default,{title:"Display settings"},c.default.createElement(He.default,{size:"small",onClick:t=>{n(t.currentTarget)}},c.default.createElement(wt,{fontSize:"small"}))),c.default.createElement(Fe.default,{anchorEl:r,open:!!r,onClose:()=>{n(null)}},e.displayToggles.map(t=>c.default.createElement(Nr,{key:t.key,checked:t.checked,label:t.label,disabled:t.disabled,onToggle:t.toggle})),c.default.createElement(Gr.default,null),e.behaviorToggles.map(t=>c.default.createElement(Nr,{key:t.label,checked:t.checked,label:t.label,onToggle:t.toggle}))))}),zo=(0,ie.observer)(function({model:e}){let{alignmentStructure:r,showAlignment:n,colorLegend:t}=e;return c.default.createElement("div",null,c.default.createElement("div",{style:{display:"flex",alignItems:"flex-start",gap:8}},c.default.createElement(sr,{model:e}),c.default.createElement("div",{style:{display:"flex",gap:4,alignItems:"center",flexShrink:0,minHeight:24}},c.default.createElement(Ao,{model:e}),c.default.createElement($o,{model:e}),c.default.createElement(Be,{model:e}))),t?c.default.createElement(Vt,{title:"Structure colors",legend:t}):null,n&&r?.pairwiseAlignment?c.default.createElement(Vr,{model:r}):n&&r?.alignmentPending?c.default.createElement(jr.LoadingEllipses,{message:"Loading pairwise alignment"}):null)}),Qr=zo;var E=s(v()),ze=s(ro());var Xr=!1;function Do(o){if(!Xr){Xr=!0;let e=document.createElement("style");e.append(o),document.head.append(e)}}function De({showControls:o,model:e}){let r=(0,E.useRef)(null),[n,t]=(0,E.useState)(),[i,l]=(0,E.useState)(),[a,h]=(0,E.useState)(!0);return(0,E.useEffect)(()=>{let p={cancelled:!1},m=()=>p.cancelled;return(async()=>{let f;try{let{Color:w,GeometryExport:V,MAQualityAssessment:W,PluginConfig:se,PluginSpec:X,DefaultPluginUISpec:Z,createPluginUI:N,registerColorThemes:le,renderReact18:ae,css:ue}=await he(),R=r.current;if(m()||!R)return;Do(ue);let A=document.createElement("div");R.append(A),p.host=A;let j=Z();f=await N({target:A,render:ae,spec:{...j,behaviors:[...j.behaviors,X.Behavior(V),X.Behavior(W)],layout:{initial:{controlsDisplay:"reactive",showControls:o}},config:[[se.Viewport.ShowExpand,!1]]}}),await f.initialized,le(f),f.canvas3d?.setProps({renderer:{selectColor:w(16711935),selectStrength:1},marking:{selectEdgeColor:w(16711935)}}),m()?(f.dispose(),A.remove()):(p.plugin=f,t(f),e.setMolstarPluginContext(f))}catch(w){f&&p.plugin!==f&&(f.dispose(),p.host?.remove()),console.error(w),l(w)}finally{h(!1)}})(),()=>{p.cancelled=!0,(0,ze.isAlive)(e)&&e.setMolstarPluginContext(void 0),p.plugin?.dispose(),p.host?.remove()}},[]),(0,E.useEffect)(()=>{let p={cancelled:!1};return(async()=>{try{if(n){let{PluginCommands:m}=await he();p.cancelled||await m.Layout.Update(n,{state:{showControls:o}})}}catch(m){console.error(m),(0,ze.isAlive)(e)&&e.setError(m)}})(),()=>{p.cancelled=!0}},[n,o,e]),{parentRef:r,error:i,loading:a}}var Jo=(0,Q.observer)(function({model:e}){let{showControls:r}=e,{parentRef:n,error:t,loading:i}=De({showControls:r,model:e});return t?y.default.createElement(F.ErrorMessage,{error:t}):y.default.createElement(Uo,{model:e,parentRef:n,loading:i})}),Oo=(0,Q.observer)(function({model:e}){let{error:r}=e;return r?y.default.createElement("div",{style:{display:"flex",alignItems:"flex-start"}},y.default.createElement("div",{style:{flex:1}},y.default.createElement(F.ErrorMessage,{error:r})),y.default.createElement(Zr.IconButton,{size:"small","aria-label":"Dismiss error",onClick:()=>{e.setError(void 0)}},y.default.createElement(O,{fontSize:"small"}))):null}),_o=(0,Q.observer)(function({model:e}){let{loadingMessages:r}=e;return r.length>0?y.default.createElement("div",{"data-testid":"protein-view-loading-overlay",style:{position:"absolute",top:8,left:8,maxWidth:"calc(100% - 16px)",padding:"2px 8px",borderRadius:4,background:"rgba(255,255,255,0.85)",color:"#000",pointerEvents:"none"}},r.map(({id:n,message:t})=>y.default.createElement(F.LoadingEllipses,{key:n,message:t}))):null}),Uo=(0,Q.observer)(function({model:e,parentRef:r,loading:n}){let{width:t,height:i}=e,l=!n&&!e.showLoading;return y.default.createElement("div",{style:{background:"#ccc"},"data-testid":l?"protein-view-ready":"protein-view-loading"},y.default.createElement(Oo,{model:e}),n?y.default.createElement(F.LoadingEllipses,{message:"Loading protein viewer"}):y.default.createElement(Qr,{model:e}),y.default.createElement("div",{style:{position:"relative",width:t,height:i}},y.default.createElement("div",{ref:r,"data-testid":"protein-view-molstar",style:{position:"relative",width:t,height:i}}),y.default.createElement(_o,{model:e})),y.default.createElement(F.ResizeHandle,{style:{height:4,background:"grey"},onDrag:a=>{e.setHeight(e.height+a)}}))}),$i=Jo;export{$i as default};
3
- //# sourceMappingURL=ProteinView-2PMPVRSZ.js.map
3
+ //# sourceMappingURL=ProteinView-M6MAEBRS.js.map
@@ -1,2 +1,2 @@
1
1
  function P(t){let e=t.strand,n=t.refName;if(e!==-1&&e!==1)throw new Error(`Invalid strand value: ${e}. Expected 1 or -1.`);if(!n)throw new Error("refName is required");let o=new Map;for(let r of t.subfeatures??[])if(r.type==="CDS"&&r.start<r.end){let a=`${r.start}-${r.end}`;o.has(a)||o.set(a,r)}let s=[...o.values()].sort((r,a)=>e*(r.start-a.start)),i={},c={},u={};if(s.length!==0){let a=(3-(s[0]?.phase??0))%3,l=-1;for(let g of s){let p=g.end-g.start;for(let f=0;f<p;f++){let h=e===1?g.start+f:g.end-1-f,m=Math.floor(a++/3);i[h]=m,m!==l?(c[m]=h,u[m]=[h],l=m):u[m].push(h)}}}return{g2p:i,p2g:c,p2gCodon:u,refName:n,strand:e}}function C(t,e){let n=t[e];if(n===void 0)return;let o=[...n].sort((i,c)=>i-c),s=[];for(let i of o){let c=s.at(-1);c?.[1]===i?c[1]=i+1:s.push([i,i+1])}return s}var d=t=>t.alns[0].seq,q=t=>t.alns[1].seq,w=t=>d(t).length;function T(t){let e=d(t),n=q(t);if(e.length===0||n.length===0)return"The aligned sequences must not be empty";if(e.length!==n.length)return`The two aligned sequences must be the same length (got ${e.length} and ${n.length})`}var S=t=>t.replaceAll("-","").toUpperCase();function $(t,e,n){let o=S(d(t)),s=S(q(t));if(o!==e.toUpperCase())return`The first sequence is not this transcript's translation (${o.length} vs ${e.length} residues)`;if(s!==n.toUpperCase())return`The second sequence is not the mapped chain's sequence (${s.length} vs ${n.length} residues)`}function j(t){let e=T(t);if(e)throw new Error(e);let n=q(t),o=d(t),s=0,i=0,c={},u={};for(let r=0;r<n.length;r++){let a=n[r]!=="-",l=o[r]!=="-";a&&l&&(c[s]=i,u[i]=s),a&&s++,l&&i++}return{structureSeqToTranscriptSeqPosition:c,transcriptSeqToStructureSeqPosition:u}}function b(t){let e=d(t),n=q(t),o=new Map;for(let s=0,i=0;s<n.length;s++)n[s]!=="-"&&(e[s]!=="-"&&o.set(i,e[s].toUpperCase()===n[s].toUpperCase()),i++);return o}function A(t,e){let n=d(t),o=q(t),s=[],i=[],c=[],u=[],r=[],a=()=>{s.push(...u,...r.map(()=>"-")),i.push(...u.map(()=>"-"),...r),c.push(...u.map(()=>" "),...r.map(()=>" ")),u.length=0,r.length=0},l=0,g=!1;for(let p=0;p<o.length;p++){let f=o[p]!=="-",h=n[p]!=="-";f&&h&&e.has(l)?(u.push(n[p]),r.push(o[p]),g=!0):u.length>0&&!(f&&h)?(h&&u.push(n[p]),f&&r.push(o[p])):(a(),s.push(n[p]),i.push(o[p]),c.push(t.consensus[p]??" ")),f&&l++}return a(),g?{consensus:c.join(""),alns:[{...t.alns[0],seq:s.join("")},{...t.alns[1],seq:i.join("")}]}:t}function x(t){let e={};for(let n=0,o=0;n<t.length;n++)t[n]!=="-"&&(e[o]=n,o++);return e}function v(t){return x(q(t))}function U(t){return x(d(t))}export{P as a,C as b,d as c,q as d,w as e,T as f,$ as g,j as h,b as i,A as j,v as k,U as l};
2
- //# sourceMappingURL=chunk-6WDCIFCW.js.map
2
+ //# sourceMappingURL=chunk-3QM6HC4V.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/g2p_mapper@2.1.7/node_modules/g2p_mapper/src/index.ts", "../../node_modules/.pnpm/p2s_mapper@1.2.2/node_modules/p2s_mapper/src/mappings.ts"],
3
+ "sources": ["../../node_modules/.pnpm/g2p_mapper@2.1.7/node_modules/g2p_mapper/src/index.ts", "../../node_modules/.pnpm/p2s_mapper@1.3.0/node_modules/p2s_mapper/src/mappings.ts"],
4
4
  "sourcesContent": ["export interface Feat {\n refName: string\n start: number\n end: number\n id?: string\n name?: string\n type?: string\n strand?: number\n phase?: number\n subfeatures?: Feat[]\n}\n\nexport function genomeToTranscriptSeqMapping(feature: Feat) {\n const strand = feature.strand\n const refName = feature.refName\n\n if (strand !== -1 && strand !== 1) {\n throw new Error(`Invalid strand value: ${strand}. Expected 1 or -1.`)\n }\n if (!refName) {\n throw new Error('refName is required')\n }\n\n // GFF3 files can repeat CDS rows; dedupe on start/end, keeping the first.\n const uniqueCds = new Map<string, Feat>()\n for (const f of feature.subfeatures ?? []) {\n if (f.type === 'CDS' && f.start < f.end) {\n const key = `${f.start}-${f.end}`\n if (!uniqueCds.has(key)) {\n uniqueCds.set(key, f)\n }\n }\n }\n const cds = [...uniqueCds.values()].sort(\n (a, b) => strand * (a.start - b.start),\n )\n\n const g2p: Record<number, number> = {}\n const p2g: Record<number, number> = {}\n const p2gCodon: Record<number, number[]> = {}\n\n if (cds.length !== 0) {\n // Phase: number of bases at the start of the first CDS that complete a\n // codon begun outside this transcript. Per-segment phase is assumed\n // consistent with running the counter through all bases.\n const firstPhase = cds[0]?.phase ?? 0\n let proteinCounter = (3 - firstPhase) % 3\n let lastProteinPos = -1\n\n for (const f of cds) {\n const length = f.end - f.start\n for (let i = 0; i < length; i++) {\n const genomePos = strand === 1 ? f.start + i : f.end - 1 - i\n const proteinPos = Math.floor(proteinCounter++ / 3)\n g2p[genomePos] = proteinPos\n if (proteinPos !== lastProteinPos) {\n p2g[proteinPos] = genomePos\n p2gCodon[proteinPos] = [genomePos]\n lastProteinPos = proteinPos\n } else {\n p2gCodon[proteinPos]!.push(genomePos)\n }\n }\n }\n }\n\n return { g2p, p2g, p2gCodon, refName, strand }\n}\n\n/**\n * Genomic range [start, end) covering the codon at `proteinPos`.\n * On the reverse strand p2g stores the highest coordinate of the codon, so\n * the range extends from genomePos-2 to genomePos+1.\n *\n * Caveat: assumes the codon's three bases are contiguous in genome\n * coordinates. Codons that span an exon boundary, or split codons at the\n * start of a CDS (phase != 0), will produce a range that includes intronic\n * or out-of-CDS positions. Use `getCodonRanges` with `p2gCodon` to handle\n * those cases correctly.\n */\nexport function getCodonRange(\n p2g: Record<number, number>,\n proteinPos: number,\n strand: number,\n) {\n const genomePos = p2g[proteinPos]\n if (genomePos !== undefined) {\n if (strand === 1) {\n return [genomePos, genomePos + 3] as const\n } else {\n return [genomePos - 2, genomePos + 1] as const\n }\n }\n return undefined\n}\n\n/**\n * One or more genomic [start, end) ranges covering the codon at `proteinPos`,\n * derived from the full set of genomic positions in `p2gCodon`. Returns\n * multiple ranges when the codon spans an exon boundary. Ranges are sorted\n * ascending and use 0-based half-open coordinates regardless of strand.\n * Returns undefined if `proteinPos` is unknown.\n */\nexport function getCodonRanges(\n p2gCodon: Record<number, number[]>,\n proteinPos: number,\n) {\n const positions = p2gCodon[proteinPos]\n if (positions === undefined) {\n return undefined\n }\n const sorted = [...positions].sort((a, b) => a - b)\n const ranges: [number, number][] = []\n for (const pos of sorted) {\n const last = ranges.at(-1)\n if (last?.[1] === pos) {\n last[1] = pos + 1\n } else {\n ranges.push([pos, pos + 1])\n }\n }\n return ranges\n}\n", "import { getCodonRanges } from 'g2p_mapper'\n\nexport interface AlignmentRow {\n id: string\n seq: string\n}\n\n/**\n * A two-row alignment whose ROW ORDER IS A CONTRACT: row 0 is the transcript,\n * row 1 is the structure. Every producer honors it \u2014 runLocalAlignment is\n * always called as (transcript, structure), and the manual-import dialog tells\n * the user to paste them in that order \u2014 and every consumer depends on it, but\n * nothing in the type can enforce it, and swapping the two silently inverts\n * every coordinate map. Read the rows through the accessors below rather than\n * indexing, so a call site states which sequence it means.\n */\nexport interface PairwiseAlignment {\n consensus: string\n alns: readonly [AlignmentRow, AlignmentRow]\n}\n\nexport const transcriptAlignedSeq = (pa: PairwiseAlignment) => pa.alns[0].seq\nexport const structureAlignedSeq = (pa: PairwiseAlignment) => pa.alns[1].seq\n\n/** Number of columns, gaps included. Both rows have this length by definition;\n * `pairwiseAlignmentProblem` is what guarantees it. */\nexport const alignmentLength = (pa: PairwiseAlignment) =>\n transcriptAlignedSeq(pa).length\n\n/**\n * Why a pairwise alignment can't be used, or undefined if it's usable. The two\n * rows must be the same non-zero length \u2014 every coordinate map walks them in\n * lockstep, so a ragged pair would map positions to nonsense. Callers that\n * accept alignments from outside (the manual-import dialog) check this and\n * report it; the internal map builders assert on it.\n */\nexport function pairwiseAlignmentProblem(pa: PairwiseAlignment) {\n const transcript = transcriptAlignedSeq(pa)\n const structure = structureAlignedSeq(pa)\n if (transcript.length === 0 || structure.length === 0) {\n return 'The aligned sequences must not be empty'\n }\n if (transcript.length !== structure.length) {\n return `The two aligned sequences must be the same length (got ${transcript.length} and ${structure.length})`\n }\n return undefined\n}\n\nconst ungapped = (row: string) => row.replaceAll('-', '').toUpperCase()\n\n/**\n * Why an externally supplied alignment does not describe these two sequences,\n * or undefined if it does. The coordinate maps index the transcript and the\n * structure by counting residues along each row, so a row whose residues are\n * not the sequence being mapped (an alignment made against UniProt canonical\n * for a different isoform, or against another chain) shifts every position\n * after the first difference without any map noticing.\n */\nexport function pairwiseAlignmentSequenceProblem(\n pa: PairwiseAlignment,\n transcript: string,\n structure: string,\n) {\n const t = ungapped(transcriptAlignedSeq(pa))\n const s = ungapped(structureAlignedSeq(pa))\n if (t !== transcript.toUpperCase()) {\n return `The first sequence is not this transcript's translation (${t.length} vs ${transcript.length} residues)`\n }\n if (s !== structure.toUpperCase()) {\n return `The second sequence is not the mapped chain's sequence (${s.length} vs ${structure.length} residues)`\n }\n return undefined\n}\n\nexport function structureSeqVsTranscriptSeqMap(\n pairwiseAlignment: PairwiseAlignment,\n) {\n const problem = pairwiseAlignmentProblem(pairwiseAlignment)\n if (problem) {\n throw new Error(problem)\n }\n const structureSeq = structureAlignedSeq(pairwiseAlignment)\n const transcriptSeq = transcriptAlignedSeq(pairwiseAlignment)\n\n let j = 0\n let k = 0\n const structureSeqToTranscriptSeqPosition: Record<number, number> = {}\n const transcriptSeqToStructureSeqPosition: Record<number, number> = {}\n\n for (let i = 0; i < structureSeq.length; i++) {\n const inStructure = structureSeq[i] !== '-'\n const inTranscript = transcriptSeq[i] !== '-'\n if (inStructure && inTranscript) {\n structureSeqToTranscriptSeqPosition[j] = k\n transcriptSeqToStructureSeqPosition[k] = j\n }\n if (inStructure) {\n j++\n }\n if (inTranscript) {\n k++\n }\n }\n\n return {\n structureSeqToTranscriptSeqPosition,\n transcriptSeqToStructureSeqPosition,\n }\n}\n\n/** Each 0-based structure position opposite a transcript residue, and whether\n * the two residues are identical. */\nexport function mappedStructureIdentity(pa: PairwiseAlignment) {\n const transcript = transcriptAlignedSeq(pa)\n const structure = structureAlignedSeq(pa)\n const mapped = new Map<number, boolean>()\n for (let i = 0, j = 0; i < structure.length; i++) {\n if (structure[i] !== '-') {\n if (transcript[i] !== '-') {\n mapped.set(\n j,\n transcript[i]!.toUpperCase() === structure[i]!.toUpperCase(),\n )\n }\n j++\n }\n }\n return mapped\n}\n\n/**\n * The alignment with each listed structure position taken out of its column,\n * so both rows still spell their sequences and those residues map to nothing.\n * An unmapped region, including the gap columns inside it, becomes its\n * transcript residues against gaps, then gaps against its structure residues,\n * rather than alternating column by column. Returns `pa` itself when nothing\n * changes.\n */\nexport function unmapStructurePositions(\n pa: PairwiseAlignment,\n positions: ReadonlySet<number>,\n): PairwiseAlignment {\n const transcript = transcriptAlignedSeq(pa)\n const structure = structureAlignedSeq(pa)\n const t: string[] = []\n const s: string[] = []\n const c: string[] = []\n const runT: string[] = []\n const runS: string[] = []\n const flushRun = () => {\n t.push(...runT, ...runS.map(() => '-'))\n s.push(...runT.map(() => '-'), ...runS)\n c.push(...runT.map(() => ' '), ...runS.map(() => ' '))\n runT.length = 0\n runS.length = 0\n }\n let j = 0\n let changed = false\n for (let i = 0; i < structure.length; i++) {\n const inStructure = structure[i] !== '-'\n const inTranscript = transcript[i] !== '-'\n if (inStructure && inTranscript && positions.has(j)) {\n runT.push(transcript[i]!)\n runS.push(structure[i]!)\n changed = true\n } else if (runT.length > 0 && !(inStructure && inTranscript)) {\n if (inTranscript) {\n runT.push(transcript[i]!)\n }\n if (inStructure) {\n runS.push(structure[i]!)\n }\n } else {\n flushRun()\n t.push(transcript[i]!)\n s.push(structure[i]!)\n c.push(pa.consensus[i] ?? ' ')\n }\n if (inStructure) {\n j++\n }\n }\n flushRun()\n return changed\n ? {\n consensus: c.join(''),\n alns: [\n { ...pa.alns[0], seq: t.join('') },\n { ...pa.alns[1], seq: s.join('') },\n ],\n }\n : pa\n}\n\nfunction seqPositionToAlignmentMap(seq: string) {\n const map: Record<number, number> = {}\n for (let i = 0, j = 0; i < seq.length; i++) {\n if (seq[i] !== '-') {\n map[j] = i\n j++\n }\n }\n return map\n}\n\nexport function structurePositionToAlignmentMap(\n pairwiseAlignment: PairwiseAlignment,\n) {\n return seqPositionToAlignmentMap(structureAlignedSeq(pairwiseAlignment))\n}\n\nexport function transcriptPositionToAlignmentMap(\n pairwiseAlignment: PairwiseAlignment,\n) {\n return seqPositionToAlignmentMap(transcriptAlignedSeq(pairwiseAlignment))\n}\n\n// Enclosing 0-based half-open [start, end) genome span for a codon. getCodonRanges\n// returns the codon's separate genomic pieces (multiple when it straddles an\n// exon/intron boundary); this collapses them to the outer span for navigation\n// and highlighting. undefined when the protein position isn't mapped.\nexport function codonGenomeSpan(\n p2gCodon: Record<number, number[]>,\n proteinPos: number,\n): readonly [number, number] | undefined {\n const ranges = getCodonRanges(p2gCodon, proteinPos)\n return ranges && ranges.length > 0\n ? [Math.min(...ranges.map(r => r[0])), Math.max(...ranges.map(r => r[1]))]\n : undefined\n}\n"],
5
5
  "mappings": "AAYM,SAAUA,EAA6BC,EAAa,CACxD,IAAMC,EAASD,EAAQ,OACjBE,EAAUF,EAAQ,QAExB,GAAIC,IAAW,IAAMA,IAAW,EAC9B,MAAM,IAAI,MAAM,yBAAyBA,CAAM,qBAAqB,EAEtE,GAAI,CAACC,EACH,MAAM,IAAI,MAAM,qBAAqB,EAIvC,IAAMC,EAAY,IAAI,IACtB,QAAWC,KAAKJ,EAAQ,aAAe,CAAA,EACrC,GAAII,EAAE,OAAS,OAASA,EAAE,MAAQA,EAAE,IAAK,CACvC,IAAMC,EAAM,GAAGD,EAAE,KAAK,IAAIA,EAAE,GAAG,GAC1BD,EAAU,IAAIE,CAAG,GACpBF,EAAU,IAAIE,EAAKD,CAAC,CAExB,CAEF,IAAME,EAAM,CAAC,GAAGH,EAAU,OAAM,CAAE,EAAE,KAClC,CAACI,EAAGC,IAAMP,GAAUM,EAAE,MAAQC,EAAE,MAAM,EAGlCC,EAA8B,CAAA,EAC9BC,EAA8B,CAAA,EAC9BC,EAAqC,CAAA,EAE3C,GAAIL,EAAI,SAAW,EAAG,CAKpB,IAAIM,GAAkB,GADHN,EAAI,CAAC,GAAG,OAAS,IACI,EACpCO,EAAiB,GAErB,QAAWT,KAAKE,EAAK,CACnB,IAAMQ,EAASV,EAAE,IAAMA,EAAE,MACzB,QAASW,EAAI,EAAGA,EAAID,EAAQC,IAAK,CAC/B,IAAMC,EAAYf,IAAW,EAAIG,EAAE,MAAQW,EAAIX,EAAE,IAAM,EAAIW,EACrDE,EAAa,KAAK,MAAML,IAAmB,CAAC,EAClDH,EAAIO,CAAS,EAAIC,EACbA,IAAeJ,GACjBH,EAAIO,CAAU,EAAID,EAClBL,EAASM,CAAU,EAAI,CAACD,CAAS,EACjCH,EAAiBI,GAEjBN,EAASM,CAAU,EAAG,KAAKD,CAAS,CAExC,CACF,CACF,CAEA,MAAO,CAAE,IAAAP,EAAK,IAAAC,EAAK,SAAAC,EAAU,QAAAT,EAAS,OAAAD,CAAM,CAC9C,CAoCM,SAAUiB,EACdC,EACAC,EAAkB,CAElB,IAAMC,EAAYF,EAASC,CAAU,EACrC,GAAIC,IAAc,OAChB,OAEF,IAAMC,EAAS,CAAC,GAAGD,CAAS,EAAE,KAAK,CAACE,EAAGC,IAAMD,EAAIC,CAAC,EAC5CC,EAA6B,CAAA,EACnC,QAAWC,KAAOJ,EAAQ,CACxB,IAAMK,EAAOF,EAAO,GAAG,EAAE,EACrBE,IAAO,CAAC,IAAMD,EAChBC,EAAK,CAAC,EAAID,EAAM,EAEhBD,EAAO,KAAK,CAACC,EAAKA,EAAM,CAAC,CAAC,CAE9B,CACA,OAAOD,CACT,CCrGO,IAAMG,EAAwBC,GAA0BA,EAAG,KAAK,CAAC,EAAE,IAC7DC,EAAuBD,GAA0BA,EAAG,KAAK,CAAC,EAAE,IAI5DE,EAAmBF,GAC9BD,EAAqBC,CAAE,EAAE,OASrB,SAAUG,EAAyBH,EAAqB,CAC5D,IAAMI,EAAaL,EAAqBC,CAAE,EACpCK,EAAYJ,EAAoBD,CAAE,EACxC,GAAII,EAAW,SAAW,GAAKC,EAAU,SAAW,EAClD,MAAO,0CAET,GAAID,EAAW,SAAWC,EAAU,OAClC,MAAO,0DAA0DD,EAAW,MAAM,QAAQC,EAAU,MAAM,GAG9G,CAEA,IAAMC,EAAYC,GAAgBA,EAAI,WAAW,IAAK,EAAE,EAAE,YAAW,EAU/D,SAAUC,EACdR,EACAI,EACAC,EAAiB,CAEjB,IAAMI,EAAIH,EAASP,EAAqBC,CAAE,CAAC,EACrC,EAAIM,EAASL,EAAoBD,CAAE,CAAC,EAC1C,GAAIS,IAAML,EAAW,YAAW,EAC9B,MAAO,4DAA4DK,EAAE,MAAM,OAAOL,EAAW,MAAM,aAErG,GAAI,IAAMC,EAAU,YAAW,EAC7B,MAAO,2DAA2D,EAAE,MAAM,OAAOA,EAAU,MAAM,YAGrG,CAEM,SAAUK,EACdC,EAAoC,CAEpC,IAAMC,EAAUT,EAAyBQ,CAAiB,EAC1D,GAAIC,EACF,MAAM,IAAI,MAAMA,CAAO,EAEzB,IAAMC,EAAeZ,EAAoBU,CAAiB,EACpDG,EAAgBf,EAAqBY,CAAiB,EAExDI,EAAI,EACJC,EAAI,EACFC,EAA8D,CAAA,EAC9DC,EAA8D,CAAA,EAEpE,QAASC,EAAI,EAAGA,EAAIN,EAAa,OAAQM,IAAK,CAC5C,IAAMC,EAAcP,EAAaM,CAAC,IAAM,IAClCE,EAAeP,EAAcK,CAAC,IAAM,IACtCC,GAAeC,IACjBJ,EAAoCF,CAAC,EAAIC,EACzCE,EAAoCF,CAAC,EAAID,GAEvCK,GACFL,IAEEM,GACFL,GAEJ,CAEA,MAAO,CACL,oCAAAC,EACA,oCAAAC,EAEJ,CAIM,SAAUI,EAAwBtB,EAAqB,CAC3D,IAAMI,EAAaL,EAAqBC,CAAE,EACpCK,EAAYJ,EAAoBD,CAAE,EAClCuB,EAAS,IAAI,IACnB,QAASJ,EAAI,EAAGJ,EAAI,EAAGI,EAAId,EAAU,OAAQc,IACvCd,EAAUc,CAAC,IAAM,MACff,EAAWe,CAAC,IAAM,KACpBI,EAAO,IACLR,EACAX,EAAWe,CAAC,EAAG,YAAW,IAAOd,EAAUc,CAAC,EAAG,YAAW,CAAE,EAGhEJ,KAGJ,OAAOQ,CACT,CAUM,SAAUC,EACdxB,EACAyB,EAA8B,CAE9B,IAAMrB,EAAaL,EAAqBC,CAAE,EACpCK,EAAYJ,EAAoBD,CAAE,EAClCS,EAAc,CAAA,EACdiB,EAAc,CAAA,EACd,EAAc,CAAA,EACdC,EAAiB,CAAA,EACjBC,EAAiB,CAAA,EACjBC,EAAW,IAAK,CACpBpB,EAAE,KAAK,GAAGkB,EAAM,GAAGC,EAAK,IAAI,IAAM,GAAG,CAAC,EACtCF,EAAE,KAAK,GAAGC,EAAK,IAAI,IAAM,GAAG,EAAG,GAAGC,CAAI,EACtC,EAAE,KAAK,GAAGD,EAAK,IAAI,IAAM,GAAG,EAAG,GAAGC,EAAK,IAAI,IAAM,GAAG,CAAC,EACrDD,EAAK,OAAS,EACdC,EAAK,OAAS,CAChB,EACIb,EAAI,EACJe,EAAU,GACd,QAASX,EAAI,EAAGA,EAAId,EAAU,OAAQc,IAAK,CACzC,IAAMC,EAAcf,EAAUc,CAAC,IAAM,IAC/BE,EAAejB,EAAWe,CAAC,IAAM,IACnCC,GAAeC,GAAgBI,EAAU,IAAIV,CAAC,GAChDY,EAAK,KAAKvB,EAAWe,CAAC,CAAE,EACxBS,EAAK,KAAKvB,EAAUc,CAAC,CAAE,EACvBW,EAAU,IACDH,EAAK,OAAS,GAAK,EAAEP,GAAeC,IACzCA,GACFM,EAAK,KAAKvB,EAAWe,CAAC,CAAE,EAEtBC,GACFQ,EAAK,KAAKvB,EAAUc,CAAC,CAAE,IAGzBU,EAAQ,EACRpB,EAAE,KAAKL,EAAWe,CAAC,CAAE,EACrBO,EAAE,KAAKrB,EAAUc,CAAC,CAAE,EACpB,EAAE,KAAKnB,EAAG,UAAUmB,CAAC,GAAK,GAAG,GAE3BC,GACFL,GAEJ,CACA,OAAAc,EAAQ,EACDC,EACH,CACE,UAAW,EAAE,KAAK,EAAE,EACpB,KAAM,CACJ,CAAE,GAAG9B,EAAG,KAAK,CAAC,EAAG,IAAKS,EAAE,KAAK,EAAE,CAAC,EAChC,CAAE,GAAGT,EAAG,KAAK,CAAC,EAAG,IAAK0B,EAAE,KAAK,EAAE,CAAC,IAGpC1B,CACN,CAEA,SAAS+B,EAA0BC,EAAW,CAC5C,IAAMC,EAA8B,CAAA,EACpC,QAASd,EAAI,EAAGJ,EAAI,EAAGI,EAAIa,EAAI,OAAQb,IACjCa,EAAIb,CAAC,IAAM,MACbc,EAAIlB,CAAC,EAAII,EACTJ,KAGJ,OAAOkB,CACT,CAEM,SAAUC,EACdvB,EAAoC,CAEpC,OAAOoB,EAA0B9B,EAAoBU,CAAiB,CAAC,CACzE,CAEM,SAAUwB,EACdxB,EAAoC,CAEpC,OAAOoB,EAA0BhC,EAAqBY,CAAiB,CAAC,CAC1E",
6
6
  "names": ["genomeToTranscriptSeqMapping", "feature", "strand", "refName", "uniqueCds", "f", "key", "cds", "a", "b", "g2p", "p2g", "p2gCodon", "proteinCounter", "lastProteinPos", "length", "i", "genomePos", "proteinPos", "getCodonRanges", "p2gCodon", "proteinPos", "positions", "sorted", "a", "b", "ranges", "pos", "last", "transcriptAlignedSeq", "pa", "structureAlignedSeq", "alignmentLength", "pairwiseAlignmentProblem", "transcript", "structure", "ungapped", "row", "pairwiseAlignmentSequenceProblem", "t", "structureSeqVsTranscriptSeqMap", "pairwiseAlignment", "problem", "structureSeq", "transcriptSeq", "j", "k", "structureSeqToTranscriptSeqPosition", "transcriptSeqToStructureSeqPosition", "i", "inStructure", "inTranscript", "mappedStructureIdentity", "mapped", "unmapStructurePositions", "positions", "s", "runT", "runS", "flushRun", "changed", "seqPositionToAlignmentMap", "seq", "map", "structurePositionToAlignmentMap", "transcriptPositionToAlignmentMap"]
@@ -1,2 +1,2 @@
1
- import{c as g,d as o,f as y,g as c}from"./chunk-6WDCIFCW.js";function l(t){return t.replace(/\*+$/,"")}function w(t){return t.replaceAll("*","")}function h(t){let i=g(t),r=o(t),[s,e]=t.alns;return i.endsWith("*")&&r.endsWith("-")?{consensus:t.consensus.slice(0,-1),alns:[{...s,seq:i.slice(0,-1)},{...e,seq:r.slice(0,-1)}]}:t}function P(t,i,r,s){let e=h(t),p=l(i),u=y(e);if(u)return{problem:u};let a=o(e).replaceAll("-",""),d=c(e,p,a);if(d)return{problem:d};let m=n=>(n.entityId===s?0:2)+(n.nucleicAcid?1:0),A=[...r].sort((n,f)=>m(n)-m(f)).find(n=>!c(e,p,l(n.seq)));return A?{entityId:A.entityId}:{problem:`The second sequence (${a.length} residues) is not the sequence of any chain in this structure`}}export{l as a,w as b,h as c,P as d};
2
- //# sourceMappingURL=chunk-3SRUB4H5.js.map
1
+ import{c as g,d as o,f as y,g as c}from"./chunk-3QM6HC4V.js";function l(t){return t.replace(/\*+$/,"")}function w(t){return t.replaceAll("*","")}function h(t){let i=g(t),r=o(t),[s,e]=t.alns;return i.endsWith("*")&&r.endsWith("-")?{consensus:t.consensus.slice(0,-1),alns:[{...s,seq:i.slice(0,-1)},{...e,seq:r.slice(0,-1)}]}:t}function P(t,i,r,s){let e=h(t),p=l(i),u=y(e);if(u)return{problem:u};let a=o(e).replaceAll("-",""),d=c(e,p,a);if(d)return{problem:d};let m=n=>(n.entityId===s?0:2)+(n.nucleicAcid?1:0),A=[...r].sort((n,f)=>m(n)-m(f)).find(n=>!c(e,p,l(n.seq)));return A?{entityId:A.entityId}:{problem:`The second sequence (${a.length} residues) is not the sequence of any chain in this structure`}}export{l as a,w as b,h as c,P as d};
2
+ //# sourceMappingURL=chunk-DO32DM3V.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/p2s_mapper@1.2.2/node_modules/p2s_mapper/src/stripStopCodon.ts", "../../src/ProteinView/entityAlignedTo.ts"],
3
+ "sources": ["../../node_modules/.pnpm/p2s_mapper@1.3.0/node_modules/p2s_mapper/src/stripStopCodon.ts", "../../src/ProteinView/entityAlignedTo.ts"],
4
4
  "sourcesContent": ["/**\n * Drop the terminal stop codon(s) from a translated protein sequence.\n *\n * Only trailing `*` go: an interior stop (mis-annotated CDS, selenoprotein\n * read-through) occupies a real codon position, and deleting it would shift\n * every later residue out of step with g2p's codon-indexed transcript\n * coordinates \u2014 offsetting every genome\u2194structure hover past that point.\n */\nexport function stripStopCodon(seq: string) {\n return seq.replace(/\\*+$/, '')\n}\n\n/**\n * Strip every stop codon, including interior ones. Only for sequences handed to\n * an external similarity search (Foldseek, AlphaFold), where `*` is not a valid\n * query character and no coordinate depends on the result's positions.\n */\nexport function stripAllStopCodons(seq: string) {\n return seq.replaceAll('*', '')\n}\n", "import {\n pairwiseAlignmentProblem,\n pairwiseAlignmentSequenceProblem,\n stripStopCodon,\n structureAlignedSeq,\n transcriptAlignedSeq,\n} from 'p2s_mapper'\n\nimport type { Entity, PairwiseAlignment } from 'p2s_mapper'\n\nexport function withoutStopColumn(\n alignment: PairwiseAlignment,\n): PairwiseAlignment {\n const t = transcriptAlignedSeq(alignment)\n const s = structureAlignedSeq(alignment)\n const [a, b] = alignment.alns\n return t.endsWith('*') && s.endsWith('-')\n ? {\n consensus: alignment.consensus.slice(0, -1),\n alns: [\n { ...a, seq: t.slice(0, -1) },\n { ...b, seq: s.slice(0, -1) },\n ],\n }\n : alignment\n}\n\nexport function entityAlignedTo(\n supplied: PairwiseAlignment,\n transcript: string,\n entities: readonly Entity[],\n preferredId?: string,\n): { entityId: string } | { problem: string } {\n const alignment = withoutStopColumn(supplied)\n const t = stripStopCodon(transcript)\n const shape = pairwiseAlignmentProblem(alignment)\n if (shape) {\n return { problem: shape }\n }\n const ownRow = structureAlignedSeq(alignment).replaceAll('-', '')\n const transcriptProblem = pairwiseAlignmentSequenceProblem(\n alignment,\n t,\n ownRow,\n )\n if (transcriptProblem) {\n return { problem: transcriptProblem }\n }\n const rank = (e: Entity) =>\n (e.entityId === preferredId ? 0 : 2) + (e.nucleicAcid ? 1 : 0)\n const match = [...entities]\n .sort((a, b) => rank(a) - rank(b))\n .find(\n e =>\n !pairwiseAlignmentSequenceProblem(alignment, t, stripStopCodon(e.seq)),\n )\n return match\n ? { entityId: match.entityId }\n : {\n problem: `The second sequence (${ownRow.length} residues) is not the sequence of any chain in this structure`,\n }\n}\n"],
5
5
  "mappings": "6DAQM,SAAUA,EAAeC,EAAW,CACxC,OAAOA,EAAI,QAAQ,OAAQ,EAAE,CAC/B,CAOM,SAAUC,EAAmBD,EAAW,CAC5C,OAAOA,EAAI,WAAW,IAAK,EAAE,CAC/B,CCTO,SAASE,EACdC,EACmB,CACnB,IAAMC,EAAIC,EAAqBF,CAAS,EAClCG,EAAIC,EAAoBJ,CAAS,EACjC,CAACK,EAAGC,CAAC,EAAIN,EAAU,KACzB,OAAOC,EAAE,SAAS,GAAG,GAAKE,EAAE,SAAS,GAAG,EACpC,CACE,UAAWH,EAAU,UAAU,MAAM,EAAG,EAAE,EAC1C,KAAM,CACJ,CAAE,GAAGK,EAAG,IAAKJ,EAAE,MAAM,EAAG,EAAE,CAAE,EAC5B,CAAE,GAAGK,EAAG,IAAKH,EAAE,MAAM,EAAG,EAAE,CAAE,CAC9B,CACF,EACAH,CACN,CAEO,SAASO,EACdC,EACAC,EACAC,EACAC,EAC4C,CAC5C,IAAMX,EAAYD,EAAkBS,CAAQ,EACtCP,EAAIW,EAAeH,CAAU,EAC7BI,EAAQC,EAAyBd,CAAS,EAChD,GAAIa,EACF,MAAO,CAAE,QAASA,CAAM,EAE1B,IAAME,EAASX,EAAoBJ,CAAS,EAAE,WAAW,IAAK,EAAE,EAC1DgB,EAAoBC,EACxBjB,EACAC,EACAc,CACF,EACA,GAAIC,EACF,MAAO,CAAE,QAASA,CAAkB,EAEtC,IAAME,EAAQC,IACXA,EAAE,WAAaR,EAAc,EAAI,IAAMQ,EAAE,YAAc,EAAI,GACxDC,EAAQ,CAAC,GAAGV,CAAQ,EACvB,KAAK,CAACL,EAAGC,IAAMY,EAAKb,CAAC,EAAIa,EAAKZ,CAAC,CAAC,EAChC,KACCa,GACE,CAACF,EAAiCjB,EAAWC,EAAGW,EAAeO,EAAE,GAAG,CAAC,CACzE,EACF,OAAOC,EACH,CAAE,SAAUA,EAAM,QAAS,EAC3B,CACE,QAAS,wBAAwBL,EAAO,MAAM,+DAChD,CACN",
6
6
  "names": ["stripStopCodon", "seq", "stripAllStopCodons", "withoutStopColumn", "alignment", "t", "transcriptAlignedSeq", "s", "structureAlignedSeq", "a", "b", "entityAlignedTo", "supplied", "transcript", "entities", "preferredId", "stripStopCodon", "shape", "pairwiseAlignmentProblem", "ownRow", "transcriptProblem", "pairwiseAlignmentSequenceProblem", "rank", "e", "match"]
@@ -1,4 +1,4 @@
1
- import{a as _t}from"./chunk-X5RLRQSB.js";import{a as rn}from"./chunk-533QNNGN.js";import{c as St,d as Ct,e as bt}from"./chunk-6WDCIFCW.js";import{a as be}from"./chunk-GVEKA5YG.js";import{a as he,c as ge}from"./chunk-KVMUXFPB.js";var on=he((fr,xt)=>{xt.exports=JBrowseExports["mobx-state-tree"]});var an=he((Sr,At)=>{At.exports=JBrowseExports["tss-react/mui"]});var gn=he((Gr,Dt)=>{Dt.exports=JBrowseExports.mobx});var Vt=he(Ft=>{"use strict";var le=be();function wn(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dn=typeof Object.is=="function"?Object.is:wn,Nn=le.useState,Ln=le.useEffect,Mn=le.useLayoutEffect,Pn=le.useDebugValue;function Hn(e,t){var n=t(),r=Nn({inst:{value:n,getSnapshot:t}}),o=r[0].inst,s=r[1];return Mn(function(){o.value=n,o.getSnapshot=t,qe(o)&&s({inst:o})},[e,n,t]),Ln(function(){return qe(o)&&s({inst:o}),e(function(){qe(o)&&s({inst:o})})},[e]),Pn(n),n}function qe(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dn(e,n)}catch{return!0}}function Fn(e,t){return t()}var Vn=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Fn:Hn;Ft.useSyncExternalStore=le.useSyncExternalStore!==void 0?le.useSyncExternalStore:Vn});var kt=he((_o,Ut)=>{"use strict";Ut.exports=Vt()});var Fe;function Ve(){return Fe??=import("./molstarExports-I4O6AZHY.js").catch(e=>{throw Fe=void 0,e}),Fe}function Tt(e,t,n){let r=e.helpers.substructureParent.get(n);return r?e.state.data.selectQ(o=>o.byValue(r).rootOfType(t.PluginStateObject.Molecule.Structure))[0]:void 0}var Ot=[{value:"default",label:"Default (element/chain)"},{value:"plddt-confidence",label:"pLDDT confidence (AlphaFold)"},{value:"chain-id",label:"Chain"},{value:"secondary-structure",label:"Secondary structure"},{value:"hydrophobicity",label:"Hydrophobicity (Kyte-Doolittle)",theme:"kyte-doolittle"},{value:"residue-name",label:"Residue type"},{value:"uncertainty",label:"B-factor / uncertainty"},{value:"molecule-type",label:"Molecule type"},{value:"mapped-chain",label:"Mapped chain"}],sn=Ot.map(e=>e.value);function gr(e){return sn.find(t=>t===e)??"default"}function vt(e){let t=Ot.find(n=>n.value===e);return t&&"theme"in t?t.theme:e}async function Er({plugin:e,colorScheme:t,structures:n}){let r=await Ve(),{StateSelection:o,StateTransforms:s,createStructureColorThemeParams:i}=r,a=t==="default"?void 0:vt(t),l=e.state.data.build(),x=0;for(let{molstarStructure:R,entityId:T}of n){let g=Tt(e,r,R),d=g?e.state.data.select(o.Generators.ofTransformer(s.Representation.StructureRepresentation3D,g.transform.ref)):[],p=t==="mapped-chain"?{entityId:T??""}:void 0;for(let E of d)E.state.isGhost||(l.to(E).update(A=>{A.colorTheme=i(e,R,A.type.name,a,p)}),x++)}x>0&&await l.commit()}function Rr({plugin:e,colorScheme:t,structure:n,entityId:r}){return t==="default"?void 0:e.representation.structure.themes.colorThemeRegistry.create(vt(t),{structure:n},t==="mapped-chain"?{entityId:r??""}:{}).legend}function Cr(e,t){let n=e.views.find(s=>s.id===t),r=n&&"assemblyNames"in n?n.assemblyNames:void 0,o=Array.isArray(r)?r[0]:void 0;return typeof o=="string"?o:void 0}function br(e,t){let n=t?e.get(t):void 0;return{canonicalRefName:r=>(n?.initialized?n.getCanonicalRefName(r):void 0)??r,isAssembly:r=>r===void 0||!!n&&e.get(r)?.name===n.name}}function cn(e){return!!e&&typeof e=="object"&&"hoverPosition"in e&&!!e.hoverPosition&&typeof e.hoverPosition=="object"&&"coord"in e.hoverPosition&&"refName"in e.hoverPosition}function _r(e,t,n){if(!t||!cn(e))return;let{coord:r,refName:o,assemblyName:s}=e.hoverPosition,{canonicalRefName:i,isAssembly:a}=n;return a(s)&&i(o)===i(t.refName)?t.g2p[r-1]:void 0}function xr(e){return e instanceof Error?e.message:typeof e=="string"?e:JSON.stringify(e)}var un=.3,ln=20,fn=.8,dn=5;function vr(e){let t=St(e),n=Ct(e),r=0,o=0,s=0,i=0,a=0,l=0;for(let R=0;R<bt(e);R++){let T=t[R],g=n[R],d=T!=="-",p=g!=="-";d&&s++,p&&i++,d&&p&&(r++,a=a||s,l=s,T.toUpperCase()===g.toUpperCase()&&o++)}let x=Math.min(s,i);return{aligned:r,identical:o,transcriptLength:s,structureLength:i,identity:r?o/r:0,identityOverShorter:x?o/x:0,structureCoverage:i?r/i:0,transcriptStart:a,transcriptEnd:l}}function Ar(e){let t=e.identical<ln?fn:un;return e.identical<dn||e.identityOverShorter<t}function Ir(e){return e.aligned===0?"no residues aligned":`${Math.round(e.identity*100)}% identity over ${e.aligned} of ${e.structureLength} structure residues`}function wr(e){return e.aligned===0?"no residues aligned":`${Math.round(e.identity*100)}% identity, ${e.aligned} of ${e.transcriptLength} transcript residues covered`}function Dr(e){return e.aligned===0||e.aligned===e.transcriptLength?void 0:`covers transcript residues ${e.transcriptStart}\u2013${e.transcriptEnd}`}function Lr(e){return`https://rest.uniprot.org/uniprotkb/${e}.gff`}function Mr(e){return`https://rest.uniprot.org/uniprotkb/${e}.fasta`}function Pr(e){return`https://www.uniprot.org/uniprotkb/${e}/entry`}function Hr(e,t="v6"){return`https://alphafold.ebi.ac.uk/files/AF-${e}-F1-model_${t}.cif`}function It(e){return`https://files.rcsb.org/download/${e}.cif`}function Fr({url:e,data:t,uniprotId:n,pdbId:r}){return e!==void 0||t!==void 0?e:n!==void 0||r===void 0?void 0:It(r)}var pn=["files.rcsb.org","www.ebi.ac.uk","ftp.ebi.ac.uk"];function mn(e){let{host:t,file:n}=(()=>{try{let o=new URL(e);return{host:o.hostname,file:o.pathname.split("/").pop()}}catch{return{host:void 0,file:void 0}}})();return t===void 0||!pn.includes(t)?void 0:/^(?:pdb)?([1-9][a-z0-9]{3})(?:_updated)?\.(?:cif|bcif|pdb|ent)(?:\.gz)?$/i.exec(n??"")?.[1]?.toLowerCase()}function Ue(e){return e.split(" ")[0]}function hn(e){return/AF-([A-Z0-9]+(?:-\d+)?)-F\d+/.exec(Ue(e))?.[1]}function Vr(e,t){let n=Ue(e);if(n.startsWith("AF-"))return`https://alphafold.ebi.ac.uk/files/${n}.cif`;let r=t==="pdb100"?/^([1-9][a-z0-9]{3})(?:[-_.]|$)/i.exec(n)?.[1]:void 0;return r?It(r):void 0}function Ur(e){let t=Ue(e);if(t.startsWith("AF-"))return`https://alphafold.ebi.ac.uk/files/${t.replace("-model_","-confidence_")}.json`}function kr({url:e,data:t,uniprotId:n}){if(e===void 0)return t!==void 0?"Uploaded structure":n?`AlphaFold ${n}`:"";let r=mn(e);if(r)return r.toUpperCase();let o=hn(e);if(o)return`AlphaFold ${o}`;let s=e.split("/").pop()?.split("?")[0];return s===void 0||s===""?e:s}var wt=ge(rn(),1),$r=(0,_t.createSvgIcon)((0,wt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 17h-2v-2h2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25"}),"Help");function Br({trackHeight:e,compactTracks:t}){return e===void 0?t?8:12:Math.min(40,Math.max(2,e))}function Kr(e){return e<12?1:2}var zr=new Set(["Chain","Helix","Turn","Beta strand","Compositional bias","Modified residue","Glycosylation","Lipidation","Cross-link","Alternative sequence","Sequence conflict","Initiator methionine"]),Jr="rgba(255, 105, 180, 0.5)",Yr="rgba(255, 165, 0, 0.35)",Xr="rgba(0, 120, 255, 0.25)",Qr="1px solid rgba(0, 120, 255, 0.6)",Zr="#33ff19a0",eo="rgba(230, 160, 0, 0.3)",to="rgba(220, 40, 40, 0.3)",no="2px solid #333",ro="1px solid black",oo="#999";function En(e){let t=e.obj?.data.atomicHierarchy,n=new Map,{residues:r,residueAtomSegments:o,chainAtomSegments:s,chains:i}=t??{};if(!(!r||!o||!s||!i)){for(let a=0;a<o.count;a++){let l=o.offsets[a],x=i.label_entity_id.value(s.index[l]),R=n.get(x);R||(R=new Map,n.set(x,R));let T=r.label_seq_id.value(a);R.has(T)||R.set(T,r.auth_seq_id.value(a))}return n}}function Rn(e,t){let n=[],r,o=e.find(s=>t?.has(s));o!==void 0&&(r=t.get(o)-o);for(let s of e){let i=t?.get(s);i!==void 0&&(r=i-s),n.push(s+(r??0))}return n}function Nt(e,t){return e?.authSeqIds?.[t]??e?.seqIds[t]??t+1}function yn(e){let t=e.obj?.data.atomicHierarchy?.chains,n=new Map;if(t)for(let r=0;r<t.label_entity_id.rowCount;r++){let o=t.label_entity_id.value(r),s=t.auth_asym_id.value(r),i=n.get(o)??[];i.includes(s)||i.push(s),n.set(o,i)}return n}var Sn=new Set(["polydeoxyribonucleotide","polyribonucleotide","polydeoxyribonucleotide/polyribonucleotide hybrid","peptide nucleic acid"]);function Cn(e,t){let n=e.obj?.data.entities;if(!n)return!1;let r=n.getEntityIndex(t);return r>=0&&Sn.has(n.subtype.value(r))}function bn(e){let n=e.obj?.data.sourceData?.data?.db?.entity_poly,r=new Map;if(n)for(let o=0;o<n.entity_id.rowCount;o++)r.set(n.entity_id.value(o),n.pdbx_seq_one_letter_code_can.value(o).replaceAll(/\s/g,""));return r}function _n(e,t){let n=Array.from(e);return n.map((r,o)=>r==="X"&&t?.length===n.length?t[o]:r).join("")}function xn(e){let t=yn(e),n=En(e),r=bn(e);return e.obj?.data.sequence.sequences.map(o=>{let s=Array.from(o.sequence.seqId.toArray());return{entityId:o.entityId,seq:_n(o.sequence.code.toArray(),r.get(o.entityId)),seqIds:s,chains:t.get(o.entityId)??[],...Cn(e,o.entityId)?{nucleicAcid:!0}:{},...n?{authSeqIds:Rn(s,n.get(o.entityId))}:{}}})}function io(e){return`${e.chains.length>0?`Chain ${e.chains.join("/")}`:`Entity ${e.entityId}`} (${e.seq.length} ${e.nucleicAcid?"nt":"aa"})`}function ao(e){return xn(e)?.filter(t=>!t.nucleicAcid).map(t=>t.seq)}function co(e,t){if(!e)return[];let n=[];for(let r of t){let o=e.seqIds[r];o!==void 0&&n.push(o)}return n}function uo(e,t){if(!e||!t)return[];let n=Math.max(0,t.start),r=Math.min(e.seqIds.length,t.end);return r>n?e.seqIds.slice(n,r):[]}function lo(e){let t=new Map;return e?.seqIds.forEach((n,r)=>{t.has(n)||t.set(n,r)}),t}function Pt(e){try{return new URL(e).host}catch{return e}}var Lt=200;function Tn(e){let t=e.split(`
1
+ import{a as _t}from"./chunk-X5RLRQSB.js";import{a as rn}from"./chunk-533QNNGN.js";import{c as St,d as Ct,e as bt}from"./chunk-3QM6HC4V.js";import{a as be}from"./chunk-GVEKA5YG.js";import{a as he,c as ge}from"./chunk-KVMUXFPB.js";var on=he((fr,xt)=>{xt.exports=JBrowseExports["mobx-state-tree"]});var an=he((Sr,At)=>{At.exports=JBrowseExports["tss-react/mui"]});var gn=he((Gr,Dt)=>{Dt.exports=JBrowseExports.mobx});var Vt=he(Ft=>{"use strict";var le=be();function wn(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Dn=typeof Object.is=="function"?Object.is:wn,Nn=le.useState,Ln=le.useEffect,Mn=le.useLayoutEffect,Pn=le.useDebugValue;function Hn(e,t){var n=t(),r=Nn({inst:{value:n,getSnapshot:t}}),o=r[0].inst,s=r[1];return Mn(function(){o.value=n,o.getSnapshot=t,qe(o)&&s({inst:o})},[e,n,t]),Ln(function(){return qe(o)&&s({inst:o}),e(function(){qe(o)&&s({inst:o})})},[e]),Pn(n),n}function qe(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Dn(e,n)}catch{return!0}}function Fn(e,t){return t()}var Vn=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Fn:Hn;Ft.useSyncExternalStore=le.useSyncExternalStore!==void 0?le.useSyncExternalStore:Vn});var kt=he((_o,Ut)=>{"use strict";Ut.exports=Vt()});var Fe;function Ve(){return Fe??=import("./molstarExports-VX3JPTXO.js").catch(e=>{throw Fe=void 0,e}),Fe}function Tt(e,t,n){let r=e.helpers.substructureParent.get(n);return r?e.state.data.selectQ(o=>o.byValue(r).rootOfType(t.PluginStateObject.Molecule.Structure))[0]:void 0}var Ot=[{value:"default",label:"Default (element/chain)"},{value:"plddt-confidence",label:"pLDDT confidence (AlphaFold)"},{value:"chain-id",label:"Chain"},{value:"secondary-structure",label:"Secondary structure"},{value:"hydrophobicity",label:"Hydrophobicity (Kyte-Doolittle)",theme:"kyte-doolittle"},{value:"residue-name",label:"Residue type"},{value:"uncertainty",label:"B-factor / uncertainty"},{value:"molecule-type",label:"Molecule type"},{value:"mapped-chain",label:"Mapped chain"}],sn=Ot.map(e=>e.value);function gr(e){return sn.find(t=>t===e)??"default"}function vt(e){let t=Ot.find(n=>n.value===e);return t&&"theme"in t?t.theme:e}async function Er({plugin:e,colorScheme:t,structures:n}){let r=await Ve(),{StateSelection:o,StateTransforms:s,createStructureColorThemeParams:i}=r,a=t==="default"?void 0:vt(t),l=e.state.data.build(),x=0;for(let{molstarStructure:R,entityId:T}of n){let g=Tt(e,r,R),d=g?e.state.data.select(o.Generators.ofTransformer(s.Representation.StructureRepresentation3D,g.transform.ref)):[],p=t==="mapped-chain"?{entityId:T??""}:void 0;for(let E of d)E.state.isGhost||(l.to(E).update(A=>{A.colorTheme=i(e,R,A.type.name,a,p)}),x++)}x>0&&await l.commit()}function Rr({plugin:e,colorScheme:t,structure:n,entityId:r}){return t==="default"?void 0:e.representation.structure.themes.colorThemeRegistry.create(vt(t),{structure:n},t==="mapped-chain"?{entityId:r??""}:{}).legend}function Cr(e,t){let n=e.views.find(s=>s.id===t),r=n&&"assemblyNames"in n?n.assemblyNames:void 0,o=Array.isArray(r)?r[0]:void 0;return typeof o=="string"?o:void 0}function br(e,t){let n=t?e.get(t):void 0;return{canonicalRefName:r=>(n?.initialized?n.getCanonicalRefName(r):void 0)??r,isAssembly:r=>r===void 0||!!n&&e.get(r)?.name===n.name}}function cn(e){return!!e&&typeof e=="object"&&"hoverPosition"in e&&!!e.hoverPosition&&typeof e.hoverPosition=="object"&&"coord"in e.hoverPosition&&"refName"in e.hoverPosition}function _r(e,t,n){if(!t||!cn(e))return;let{coord:r,refName:o,assemblyName:s}=e.hoverPosition,{canonicalRefName:i,isAssembly:a}=n;return a(s)&&i(o)===i(t.refName)?t.g2p[r-1]:void 0}function xr(e){return e instanceof Error?e.message:typeof e=="string"?e:JSON.stringify(e)}var un=.3,ln=20,fn=.8,dn=5;function vr(e){let t=St(e),n=Ct(e),r=0,o=0,s=0,i=0,a=0,l=0;for(let R=0;R<bt(e);R++){let T=t[R],g=n[R],d=T!=="-",p=g!=="-";d&&s++,p&&i++,d&&p&&(r++,a=a||s,l=s,T.toUpperCase()===g.toUpperCase()&&o++)}let x=Math.min(s,i);return{aligned:r,identical:o,transcriptLength:s,structureLength:i,identity:r?o/r:0,identityOverShorter:x?o/x:0,structureCoverage:i?r/i:0,transcriptStart:a,transcriptEnd:l}}function Ar(e){let t=e.identical<ln?fn:un;return e.identical<dn||e.identityOverShorter<t}function Ir(e){return e.aligned===0?"no residues aligned":`${Math.round(e.identity*100)}% identity over ${e.aligned} of ${e.structureLength} structure residues`}function wr(e){return e.aligned===0?"no residues aligned":`${Math.round(e.identity*100)}% identity, ${e.aligned} of ${e.transcriptLength} transcript residues covered`}function Dr(e){return e.aligned===0||e.aligned===e.transcriptLength?void 0:`covers transcript residues ${e.transcriptStart}\u2013${e.transcriptEnd}`}function Lr(e){return`https://rest.uniprot.org/uniprotkb/${e}.gff`}function Mr(e){return`https://rest.uniprot.org/uniprotkb/${e}.fasta`}function Pr(e){return`https://www.uniprot.org/uniprotkb/${e}/entry`}function Hr(e,t="v6"){return`https://alphafold.ebi.ac.uk/files/AF-${e}-F1-model_${t}.cif`}function It(e){return`https://files.rcsb.org/download/${e}.cif`}function Fr({url:e,data:t,uniprotId:n,pdbId:r}){return e!==void 0||t!==void 0?e:n!==void 0||r===void 0?void 0:It(r)}var pn=["files.rcsb.org","www.ebi.ac.uk","ftp.ebi.ac.uk"];function mn(e){let{host:t,file:n}=(()=>{try{let o=new URL(e);return{host:o.hostname,file:o.pathname.split("/").pop()}}catch{return{host:void 0,file:void 0}}})();return t===void 0||!pn.includes(t)?void 0:/^(?:pdb)?([1-9][a-z0-9]{3})(?:_updated)?\.(?:cif|bcif|pdb|ent)(?:\.gz)?$/i.exec(n??"")?.[1]?.toLowerCase()}function Ue(e){return e.split(" ")[0]}function hn(e){return/AF-([A-Z0-9]+(?:-\d+)?)-F\d+/.exec(Ue(e))?.[1]}function Vr(e,t){let n=Ue(e);if(n.startsWith("AF-"))return`https://alphafold.ebi.ac.uk/files/${n}.cif`;let r=t==="pdb100"?/^([1-9][a-z0-9]{3})(?:[-_.]|$)/i.exec(n)?.[1]:void 0;return r?It(r):void 0}function Ur(e){let t=Ue(e);if(t.startsWith("AF-"))return`https://alphafold.ebi.ac.uk/files/${t.replace("-model_","-confidence_")}.json`}function kr({url:e,data:t,uniprotId:n}){if(e===void 0)return t!==void 0?"Uploaded structure":n?`AlphaFold ${n}`:"";let r=mn(e);if(r)return r.toUpperCase();let o=hn(e);if(o)return`AlphaFold ${o}`;let s=e.split("/").pop()?.split("?")[0];return s===void 0||s===""?e:s}var wt=ge(rn(),1),$r=(0,_t.createSvgIcon)((0,wt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 17h-2v-2h2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25"}),"Help");function Br({trackHeight:e,compactTracks:t}){return e===void 0?t?8:12:Math.min(40,Math.max(2,e))}function Kr(e){return e<12?1:2}var zr=new Set(["Chain","Helix","Turn","Beta strand","Compositional bias","Modified residue","Glycosylation","Lipidation","Cross-link","Alternative sequence","Sequence conflict","Initiator methionine"]),Jr="rgba(255, 105, 180, 0.5)",Yr="rgba(255, 165, 0, 0.35)",Xr="rgba(0, 120, 255, 0.25)",Qr="1px solid rgba(0, 120, 255, 0.6)",Zr="#33ff19a0",eo="rgba(230, 160, 0, 0.3)",to="rgba(220, 40, 40, 0.3)",no="2px solid #333",ro="1px solid black",oo="#999";function En(e){let t=e.obj?.data.atomicHierarchy,n=new Map,{residues:r,residueAtomSegments:o,chainAtomSegments:s,chains:i}=t??{};if(!(!r||!o||!s||!i)){for(let a=0;a<o.count;a++){let l=o.offsets[a],x=i.label_entity_id.value(s.index[l]),R=n.get(x);R||(R=new Map,n.set(x,R));let T=r.label_seq_id.value(a);R.has(T)||R.set(T,r.auth_seq_id.value(a))}return n}}function Rn(e,t){let n=[],r,o=e.find(s=>t?.has(s));o!==void 0&&(r=t.get(o)-o);for(let s of e){let i=t?.get(s);i!==void 0&&(r=i-s),n.push(s+(r??0))}return n}function Nt(e,t){return e?.authSeqIds?.[t]??e?.seqIds[t]??t+1}function yn(e){let t=e.obj?.data.atomicHierarchy?.chains,n=new Map;if(t)for(let r=0;r<t.label_entity_id.rowCount;r++){let o=t.label_entity_id.value(r),s=t.auth_asym_id.value(r),i=n.get(o)??[];i.includes(s)||i.push(s),n.set(o,i)}return n}var Sn=new Set(["polydeoxyribonucleotide","polyribonucleotide","polydeoxyribonucleotide/polyribonucleotide hybrid","peptide nucleic acid"]);function Cn(e,t){let n=e.obj?.data.entities;if(!n)return!1;let r=n.getEntityIndex(t);return r>=0&&Sn.has(n.subtype.value(r))}function bn(e){let n=e.obj?.data.sourceData?.data?.db?.entity_poly,r=new Map;if(n)for(let o=0;o<n.entity_id.rowCount;o++)r.set(n.entity_id.value(o),n.pdbx_seq_one_letter_code_can.value(o).replaceAll(/\s/g,""));return r}function _n(e,t){let n=Array.from(e);return n.map((r,o)=>r==="X"&&t?.length===n.length?t[o]:r).join("")}function xn(e){let t=yn(e),n=En(e),r=bn(e);return e.obj?.data.sequence.sequences.map(o=>{let s=Array.from(o.sequence.seqId.toArray());return{entityId:o.entityId,seq:_n(o.sequence.code.toArray(),r.get(o.entityId)),seqIds:s,chains:t.get(o.entityId)??[],...Cn(e,o.entityId)?{nucleicAcid:!0}:{},...n?{authSeqIds:Rn(s,n.get(o.entityId))}:{}}})}function io(e){return`${e.chains.length>0?`Chain ${e.chains.join("/")}`:`Entity ${e.entityId}`} (${e.seq.length} ${e.nucleicAcid?"nt":"aa"})`}function ao(e){return xn(e)?.filter(t=>!t.nucleicAcid).map(t=>t.seq)}function co(e,t){if(!e)return[];let n=[];for(let r of t){let o=e.seqIds[r];o!==void 0&&n.push(o)}return n}function uo(e,t){if(!e||!t)return[];let n=Math.max(0,t.start),r=Math.min(e.seqIds.length,t.end);return r>n?e.seqIds.slice(n,r):[]}function lo(e){let t=new Map;return e?.seqIds.forEach((n,r)=>{t.has(n)||t.set(n,r)}),t}function Pt(e){try{return new URL(e).host}catch{return e}}var Lt=200;function Tn(e){let t=e.split(`
2
2
  `,1)[0]?.trim()??"";return t.length>Lt?`${t.slice(0,Lt)}\u2026`:t}var _e=class extends Error{status;constructor(t,n){super(t),this.name="HttpError",this.status=n}};function po(e){return e instanceof _e&&e.status>=400&&e.status<500}async function On(e,t){let n=Tn(await e.text().catch(()=>"")),r=`HTTP ${e.status}${e.statusText?` ${e.statusText}`:""} from ${Pt(t)}`;return new _e(n?`${r}: ${n}`:r,e.status)}function vn(e,t){return t instanceof TypeError?new Error(`Could not reach ${Pt(e)}. Check your network connection; the server may also be refusing cross-origin requests from this page.`,{cause:t}):t}async function An(e,t){let{fetch:n=globalThis.fetch,...r}=t??{};try{return await n(e,r)}catch(o){throw vn(e,o)}}async function In(e,t){let n=await An(e,t);if(!n.ok)throw await On(n,e);return n}async function mo(e,t){return(await In(e,t)).json()}function Mt(e){return e.reason instanceof Error?e.reason:new Error("Aborted",{cause:e.reason})}function ho(e,t){return new Promise((n,r)=>{if(t?.aborted)r(Mt(t));else{let o=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(o),r(Mt(t))},{once:!0})}})}function ke(e){return e===void 0?[]:"start"in e?[e]:e}function Ht(e){let t=[...new Set(e)].sort((r,o)=>r-o),n=[];for(let r of t){let o=n.at(-1);o?.end===r?o.end=r+1:n.push({start:r,end:r+1})}return n}function Ro(e,t){let n=ke(t),r=[];for(let o=0;o<(e?.seq.length??0);o++){let s=Nt(e,o);n.some(i=>s>=i.start&&s<=i.end)&&r.push(o)}return Ht(r)}function yo(e,t){let n=ke(t),r=[];for(let[o,s]of Object.entries(e.maps.transcriptSeqToStructureSeqPosition)){let i=Number(o)+1;n.some(a=>i>=a.start&&i<=a.end)&&r.push(s)}return Ht(r)}function So(e){let t=[];for(let{start:n,end:r}of ke(e).filter(o=>o.end>o.start).toSorted((o,s)=>o.start-s.start)){let o=t.at(-1);o&&n<=o.end?o.end=Math.max(o.end,r):t.push({start:n,end:r})}return t}var _=ge(be(),1),ct=ge(kt(),1);var w=ge(be(),1);var qt=Object.prototype.hasOwnProperty;function xe(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&xe(e[r],t[r]););return r===-1}if(!n||typeof e=="object"){r=0;for(n in e)if(qt.call(e,n)&&++r&&!qt.call(t,n)||!(n in t)||!xe(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var Ye=0,Xe=1,Qe=2,Ze=3,et=4;var F=new WeakMap,j=()=>{},m=j(),Ee=Object,u=e=>e===m,L=e=>typeof e=="function",V=(e,t)=>({...e,...t}),Ae=e=>L(e.then),je={},Te={},tt="undefined",fe=typeof window!=tt,Ge=typeof document!=tt,Un=fe&&"Deno"in window,kn=()=>fe&&typeof window.requestAnimationFrame!=tt,nt=(e,t)=>{let n=F.get(e);return[()=>!u(t)&&e.get(t)||je,r=>{if(!u(t)){let o=e.get(t);t in Te||(Te[t]=o),n[5](t,V(o,r),o||je)}},n[6],()=>!u(t)&&t in Te?Te[t]:!u(t)&&e.get(t)||je]},Be=!0,qn=()=>Be,[Ke,ze]=fe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[j,j],jn=()=>{let e=Ge&&document.visibilityState;return u(e)||e!=="hidden"},$n=e=>(Ge&&document.addEventListener("visibilitychange",e),Ke("focus",e),()=>{Ge&&document.removeEventListener("visibilitychange",e),ze("focus",e)}),Wn=e=>{let t=()=>{Be=!0,e()},n=()=>{Be=!1};return Ke("online",t),Ke("offline",n),()=>{ze("online",t),ze("offline",n)}},Gn={isOnline:qn,isVisible:jn},Bn={initFocus:$n,initReconnect:Wn},rt=!w.default.useId,G=!fe||Un,Wt=e=>kn()?window.requestAnimationFrame(e):setTimeout(e,1),ee=G?w.useEffect:w.useLayoutEffect,$e=typeof navigator<"u"&&navigator.connection,jt=!G&&$e&&(["slow-2g","2g"].includes($e.effectiveType)||$e.saveData),Oe=new WeakMap,Kn=e=>Ee.prototype.toString.call(e),We=(e,t)=>e===`[object ${t}]`,zn=0,Je=e=>{let t=typeof e,n=Kn(e),r=We(n,"Date"),o=We(n,"RegExp"),s=We(n,"Object"),i,a;if(Ee(e)===e&&!r&&!o){if(i=Oe.get(e),i)return i;if(i=++zn+"~",Oe.set(e,i),Array.isArray(e)){for(i="@",a=0;a<e.length;a++)i+=Je(e[a])+",";Oe.set(e,i)}if(s){i="#";let l=Ee.keys(e).sort();for(;!u(a=l.pop());)u(e[a])||(i+=a+":"+Je(e[a])+",");Oe.set(e,i)}}else i=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return i},ye=e=>{if(L(e))try{e=e()}catch{e=""}let t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Je(e):"",[e,t]},Jn=0,Re=()=>++Jn;async function ot(...e){let[t,n,r,o]=e,s=V({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{}),i=s.populateCache,a=s.rollbackOnError,l=s.optimisticData,x=g=>typeof a=="function"?a(g):a!==!1,R=s.throwOnError;if(L(n)){let g=n,d=[],p=t.keys();for(let E of p)!/^\$(inf|sub)\$/.test(E)&&g(t.get(E)._k)&&d.push(E);return Promise.all(d.map(T))}return T(n);async function T(g){let[d]=ye(g);if(!d)return;let[p,E]=nt(t,d),[A,M,c,B]=F.get(t),I=()=>{let U=A[d];return(L(s.revalidate)?s.revalidate(p().data,g):s.revalidate!==!1)&&(delete c[d],delete B[d],U&&U[0])?U[0](Qe).then(()=>p().data):p().data};if(e.length<3)return I();let y=r,O,P=!1,te=Re();M[d]=[te,0];let C=!u(l),ne=p(),D=ne.data,K=ne._c,Q=u(K)?D:K;if(C&&(l=L(l)?l(Q,D):l,E({data:l,_c:Q})),L(y))try{y=y(Q)}catch(U){O=U,P=!0}if(y&&Ae(y))if(y=await y.catch(U=>{O=U,P=!0}),te!==M[d][0]){if(P)throw O;return y}else P&&C&&x(O)&&(i=!0,E({data:Q,_c:m}));if(i&&!P)if(L(i)){let U=i(y,Q);E({data:U,error:m,_c:m})}else E({data:y,error:m,_c:m});if(M[d][1]=Re(),Promise.resolve(I()).then(()=>{E({_c:m})}),P){if(R)throw O;return}return y}}var $t=(e,t)=>{for(let n in e)e[n][0]&&e[n][0](t)},Gt=(e,t)=>{if(!F.has(e)){let r=V(Bn,t),o=Object.create(null),s=ot.bind(m,e),i=j,a=Object.create(null),l=(g,d)=>{let p=a[g]||[];return a[g]=p,p.push(d),()=>{let E=p.indexOf(d);E>=0&&(p[E]=p[p.length-1],p.pop())}},x=(g,d,p)=>{e.set(g,d);let E=a[g];if(E)for(let A of E)A(d,p)},R=g=>{let d=F.get(e),[,p,E,A]=d,M=Re();d[8]++;for(let I in E)delete E[I];for(let I in A)delete A[I];for(let I in p)p[I]=[M,M];let c={};for(let I of[...e.keys()]){let y=e.get(I);e.delete(I);let O=a[I];if(O)for(let P of O)P(c,y)}let B=!g||g.revalidate!==!1;for(let I in o){let y=o[I];for(let O=0;O<y.length;O++)y[O](et,{revalidate:B&&!O})}},T=()=>{if(!F.has(e)&&(F.set(e,[o,Object.create(null),Object.create(null),Object.create(null),s,x,l,R,0]),!G)){let g=r.initFocus(setTimeout.bind(m,$t.bind(m,o,Ye))),d=r.initReconnect(setTimeout.bind(m,$t.bind(m,o,Xe)));i=()=>{g&&g(),d&&d(),F.delete(e)}}};return T(),[e,s,T,i,R]}let n=F.get(e);return[e,n[4],m,m,n[7]]},Yn=(e,t,n,r,o)=>{let s=n.errorRetryCount,i=o.retryCount,a=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!u(s)&&i>s||setTimeout(r,a,o)},Xn=xe,[Ie,Qn,,,Zn]=Gt(new Map),we=V({onLoadingSlow:j,onSuccess:j,onError:j,onErrorRetry:Yn,onDiscarded:j,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:jt?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:jt?5e3:3e3,compare:Xn,isPaused:()=>!1,cache:Ie,mutate:Qn,unload:Zn,fallback:{}},Gn),st=(e,t)=>{let n=V(e,t);if(t){let{use:r,fallback:o,cacheData:s}=e,{use:i,fallback:a,cacheData:l}=t;r&&i&&(n.use=r.concat(i)),o&&a&&(n.fallback=V(o,a)),s&&l&&(n.cacheData=V(s,l))}return n},ve=(0,w.createContext)({}),Bt=e=>{let{value:t}=e,n=(0,w.useContext)(ve),r=L(t),o=(0,w.useMemo)(()=>r?t(n):t,[r,n,t]),s=(0,w.useMemo)(()=>r?o:st(n,o),[r,n,o]),i=o&&o.provider,a=(0,w.useRef)(m);i&&!a.current&&(a.current=Gt(i(s.cache||Ie),o));let l=a.current;return l&&(s.cache=l[0],s.mutate=l[1],s.unload=l[4]),ee(()=>{if(l)return l[2]&&l[2](),l[3]},[]),(0,w.createElement)(ve.Provider,V(e,{value:s}))};var Kt="$inf$";var de=ge(be(),1),zt=fe&&window.__SWR_DEVTOOLS_USE__,er=zt?window.__SWR_DEVTOOLS_USE__:[],tr=()=>{zt&&(window.__SWR_DEVTOOLS_REACT__=de.default)},nr=e=>L(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],rr=()=>{let e=(0,de.useContext)(ve);return(0,de.useMemo)(()=>V(we,e),[e])};var or=e=>(t,n,r)=>e(t,n&&((...s)=>{let[i]=ye(t),[,,,a]=F.get(Ie);if(i.startsWith(Kt))return n(...s);let l=a[i];return u(l)?n(...s):(delete a[i],l)}),r),sr=er.concat(or),Jt=e=>function(...n){let r=rr(),[o,s,i]=nr(n),a=st(r,i),l=e,{use:x}=a,R=(x||[]).concat(sr);for(let T=R.length;T--;)l=R[T](l);return l(o,s||a.fetcher||null,a)},Yt=(e,t,n)=>{let r=t[e]||(t[e]=[]);return r.push(n),()=>{let o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};tr();var De=_.default.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}}),it={dedupe:!0},Xt=(e,t,n)=>{var r;return t?((r=e.get(t))==null?void 0:r.has(n))===!0:!1},at=(e,t,n)=>{if(!t)return;let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)},ir=({value:e,getCacheData:t,canCommit:n,setCache:r})=>{let o=s=>{n()&&u(t())&&r(s)};Promise.resolve(e).then(s=>{o({data:s,error:m})},s=>{o({error:s})})},Ne=Promise.resolve(m);Ne.status="fulfilled";Ne.value=m;var ar=()=>j,cr=(e,t,n)=>{let{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:a,revalidateIfStale:l,refreshInterval:x,refreshWhenHidden:R,refreshWhenOffline:T,keepPreviousData:g,strictServerPrefetchWarning:d}=n,[p,E,A,M]=F.get(r),[c,B]=ye(e),I=(0,_.useRef)(!1),y=(0,_.useRef)(!1),O=(0,_.useRef)(c),P=(0,_.useRef)(t),te=(0,_.useRef)(n),C=()=>te.current,ne=()=>C().isVisible()&&C().isOnline(),[D,K,Q,U]=nt(r,c),re=(0,_.useRef)({}).current,oe=u(i)?u(n.fallback)?m:n.fallback[c]:i,Z=n.cacheData,ut=c?Z?.[c]:m,lt=c?M[c]:m,se=u(lt)&&!u(ut),k=se?ut:lt,ft=(f,h)=>{for(let b in re){let S=b;if(S==="data"){if(!o(f[S],h[S])&&(!u(f[S])||!o(pe,h[S])))return!1}else if(h[S]!==f[S])return!1}return!0},Le=!I.current,dt=(0,_.useMemo)(()=>{let f=D(),h=U(),b=v=>{let $=V(v);return delete $._k,(()=>{if(!c||!t||C().isPaused())return!1;if(Le&&!u(a))return a;let X=u(oe)?$.data:oe;return s&&se&&u(X)?!1:s?u(X)||l:u(X)||l})()?{isValidating:!0,isLoading:!0,...$}:$},S=b(f),q=f===h?S:b(h),N=S;return[()=>{let v=b(D());return ft(v,N)?(N.data=v.data,N.isLoading=v.isLoading,N.isValidating=v.isValidating,N.error=v.error,N):(N=v,v)},()=>q]},[r,c]),ie=(0,ct.useSyncExternalStore)((0,_.useCallback)(f=>Q(c,(h,b)=>{ft(b,h)||f()}),[r,c]),dt[0],dt[1]),Qt=p[c]&&p[c].length>0,ae=ie.data,z=u(ae)?oe&&Ae(oe)?De(oe):oe:ae,Se=ie.error,Ce=(0,_.useRef)(z),pt=(0,_.useRef)(m),J=pt.current;J||(J=new WeakMap,pt.current=J);let Me=(0,_.useRef)(null),pe=g?u(ae)?u(Ce.current)?z:Ce.current:ae:z,Y=c&&u(z),me=(0,_.useRef)(null);!G&&(0,ct.useSyncExternalStore)(ar,()=>(me.current=!1,me),()=>(me.current=!0,me));let Zt=me.current;d&&Zt&&!s&&Y&&console.warn(`Missing pre-initiated data for serialized key "${c}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);let mt=!c||!t||C().isPaused()||Qt&&!u(Se)?!1:Le&&!u(a)?a:s&&se&&Y?!1:s?u(z)?!1:l:u(z)||l,ht=Le&&mt,en=u(ie.isValidating)?ht:ie.isValidating,tn=u(ie.isLoading)?ht:ie.isLoading,ce=(0,_.useCallback)(async f=>{let h=P.current;if(!c||!h||y.current||C().isPaused())return!1;let b,S,q=!0,N=f||{},v=!A[c]||!N.dedupe,$=se&&!Xt(J,Z,c)&&!u(k)&&u(D().data),ue=()=>rt?!y.current&&c===O.current&&I.current:c===O.current,X={isValidating:!1,isLoading:!1},Et=()=>{K(X)},Rt=()=>{let H=A[c];H&&H[1]===S&&delete A[c]},yt={isValidating:!0};u(D().data)&&(yt.isLoading=!0);try{if(v&&(K(yt),n.loadingTimeout&&u(D().data)&&setTimeout(()=>{q&&ue()&&C().onLoadingSlow(c,n)},n.loadingTimeout),$&&at(J,Z,c),A[c]=[$?k:h(B),Re()],$&&M[c]&&delete M[c]),[b,S]=A[c],b=await b,v&&setTimeout(Rt,n.dedupingInterval),!A[c]||A[c][1]!==S)return v&&ue()&&C().onDiscarded(c),!1;X.error=m;let H=E[c];if(!u(H)&&(S<=H[0]||S<=H[1]||H[1]===0))return Et(),v&&ue()&&C().onDiscarded(c),!1;let W=D().data;X.data=o(W,b)?W:b,v&&ue()&&C().onSuccess(b,c,n)}catch(H){Rt();let W=C(),{shouldRetryOnError:Pe}=W;W.isPaused()||(X.error=H,v&&ue()&&(W.onError(H,c,W),(Pe===!0||L(Pe)&&Pe(H))&&(!C().revalidateOnFocus||!C().revalidateOnReconnect||ne())&&W.onErrorRetry(H,c,W,nn=>{let He=p[c];He&&He[0]&&He[0](Ze,nn)},{retryCount:(N.retryCount||0)+1,dedupe:!0})))}return q=!1,Et(),!0},[c,r]),gt=(0,_.useCallback)((...f)=>ot(r,O.current,...f),[]);if(ee(()=>{let f=Me.current;f&&(Me.current=null,at(J,f.cacheData,f.key),u(D().data)&&K({data:f.data,error:m,_k:f._k}),M[f.key]&&delete M[f.key])}),ee(()=>{P.current=t,te.current=n,u(ae)||(Ce.current=ae)}),ee(()=>{if(t||!se||u(k)||Xt(J,Z,c)||!u(D().data))return;at(J,Z,c);let f=E[c];ir({value:k,getCacheData:()=>D().data,canCommit:()=>!y.current&&c===O.current&&E[c]===f,setCache:h=>K({...h,_k:B})})}),ee(()=>{if(!c)return;let f=ce.bind(m,it),h=0;C().revalidateOnFocus&&(h=Date.now()+C().focusThrottleInterval);let S=Yt(c,p,(q,N={})=>{if(q==Ye){let v=Date.now();C().revalidateOnFocus&&v>h&&ne()&&(h=v+C().focusThrottleInterval,f())}else if(q==Xe)C().revalidateOnReconnect&&ne()&&f();else{if(q==Qe)return ce();if(q==Ze)return ce(N);if(q==et&&(Ce.current=m,N.revalidate))return ce()}});return y.current=!1,O.current=c,I.current=!0,K({_k:B}),mt&&(A[c]||(u(z)||G?f():Wt(f))),()=>{y.current=!0,S()}},[c]),ee(()=>{let f;function h(){let S=L(x)?x(D().data):x;S&&f!==-1&&(f=setTimeout(b,S))}function b(){!D().error&&(R||C().isVisible())&&(T||C().isOnline())?ce(it).then(h):h()}return h(),()=>{f&&(clearTimeout(f),f=-1)}},[x,R,T,c]),(0,_.useDebugValue)(pe),s){if(!rt&&G&&Y&&u(k))throw new Error("Fallback data is required when using Suspense in SSR.");Y&&(P.current=t,te.current=n,y.current=!1);let f=!u(k)&&Y,h=m;if(f&&se)h=k&&Ae(k)?De(k):k,z=h,pe=h,G||(Me.current={data:h,_k:B,key:c,cacheData:Z});else{let S=f?gt(k):Ne;De(S)}if(!u(Se)&&Y)throw Se;let b=Y&&u(h)?ce(it):Ne;!u(pe)&&Y&&(b.status="fulfilled",b.value=!0),De(b)}return{mutate:gt,get data(){return re.data=!0,pe},get error(){return re.error=!0,Se},get isValidating(){return re.isValidating=!0,en},get isLoading(){return re.isLoading=!0,tn}}},Lo=Ee.defineProperty(Bt,"defaultValue",{value:we}),ur=Jt(cr);var Fo={revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,shouldRetryOnError:!1};export{an as a,Cr as b,br as c,cn as d,_r as e,xr as f,on as g,un as h,ln as i,fn as j,vr as k,Ar as l,Ir as m,wr as n,Dr as o,Nt as p,xn as q,io as r,ao as s,co as t,uo as u,lo as v,po as w,On as x,An as y,In as z,mo as A,Mt as B,ho as C,Lr as D,Mr as E,Pr as F,Hr as G,It as H,Fr as I,mn as J,hn as K,Vr as L,Ur as M,kr as N,ur as O,Fo as P,$r as Q,Ve as R,Tt as S,Ot as T,sn as U,gr as V,Er as W,Rr as X,gn as Y,Br as Z,Kr as _,zr as $,Jr as aa,Yr as ba,Xr as ca,Qr as da,Zr as ea,eo as fa,to as ga,no as ha,ro as ia,oo as ja,ke as ka,Ht as la,Ro as ma,yo as na,So as oa};
3
3
  /*! Bundled license information:
4
4
 
@@ -13,4 +13,4 @@ use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
13
13
  * LICENSE file in the root directory of this source tree.
14
14
  *)
15
15
  */
16
- //# sourceMappingURL=chunk-DQAVCUTJ.js.map
16
+ //# sourceMappingURL=chunk-NSRFB7YQ.js.map