geneviewer-js 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/SHA256SUMS +7 -7
- package/dist/geneviewer.core.js +3 -2
- package/dist/geneviewer.min.js +2 -2
- package/dist/geneviewer.min.js.map +3 -3
- package/dist/geneviewer.mjs +3 -2
- package/dist/geneviewer.standalone.mjs +2 -2
- package/dist/geneviewer.standalone.mjs.map +3 -3
- package/dist/geneviewerwidget.js +13 -9
- package/package.json +1 -1
package/dist/geneviewer.mjs
CHANGED
|
@@ -6047,7 +6047,8 @@ function shiftAnnotation(options, shift) {
|
|
|
6047
6047
|
}
|
|
6048
6048
|
if (options.position !== null && options.position !== void 0) {
|
|
6049
6049
|
if (options.type === "rectangle") {
|
|
6050
|
-
options.position
|
|
6050
|
+
const rectangles = Array.isArray(options.position) ? options.position : [options.position];
|
|
6051
|
+
options.position = rectangles.map((corners) => {
|
|
6051
6052
|
if (!Array.isArray(corners)) return [move(corners)];
|
|
6052
6053
|
return corners.map((point) => Array.isArray(point) ? [move(point[0]), ...point.slice(1)] : move(point));
|
|
6053
6054
|
});
|
|
@@ -7297,7 +7298,7 @@ function createSaveIcon(widgetId, el, container2, iconClass = null, save = downl
|
|
|
7297
7298
|
}
|
|
7298
7299
|
|
|
7299
7300
|
// src/lib/chart.js
|
|
7300
|
-
var version = "0.3.
|
|
7301
|
+
var version = "0.3.2";
|
|
7301
7302
|
var renderSequence = 0;
|
|
7302
7303
|
var chartCount = 0;
|
|
7303
7304
|
var activeShortcuts = null;
|
|
@@ -24,7 +24,7 @@ var v2=Object.defineProperty;var w2=(t,e)=>{for(var n in e)v2(t,n,{get:e[n],enum
|
|
|
24
24
|
<b>Best hit:</b> {BlastP}<br>
|
|
25
25
|
<b>Identity:</b> {identity}%<br>
|
|
26
26
|
<b>Similarity:</b> {similarity}%<br>
|
|
27
|
-
<b>Location:</b> {start} - {end}<br>`,tb=["1","forward","+","sense"],_E=["-1","0","reverse","-","antisense","complement"];function SE(t,e=null){if(!t||t.nrow===0)return null;if(e===null&&t.has("strand")&&(e="strand"),!t.has("start"))throw new Error("start column not found in data");if(!t.has("end"))throw new Error("end column not found in data");let n=t.get("start"),r=t.get("end");if(e===null)return t.set("strand",n.map((c,l)=>c===null||r[l]===null?null:c<r[l]?"forward":"reverse")),t;if(!t.has(e))throw new Error("strand column not found in data");let i=t.get(e).map(pe);if(!i.every(c=>tb.includes(c)||_E.includes(c)))throw new Error("Invalid strand values found. Valid values are 1/forward/+/sense or -1/0/reverse/-/antisense/complement.");let o=i.map(c=>tb.includes(c)?"forward":"reverse");t.set("strand",o);let a=n.slice(),s=r.slice();return o.forEach((c,l)=>{(c==="forward"&&n[l]>r[l]||c==="reverse"&&n[l]<r[l])&&(a[l]=r[l],s[l]=n[l])}),t.set("start",a),t.set("end",s),t}function Vt(t,e){let n=[...t.x.series.keys()];if(e==null)return n;let r=Array.isArray(e)?e:[e];if(r.length&&r.every(o=>typeof o=="number"))return r.some(o=>o>n.length||o<1)?(t.warnings.push("Some cluster numbers provided are out of range. Please check the cluster numbers."),[]):r.map(o=>n[Math.trunc(o)-1]);let i=r.map(o=>pe(o));return i.every(o=>n.includes(o))?i:(t.warnings.push("Some cluster names provided are not valid. Please check the cluster names."),[])}function Ql(t){let e=t.fields||{},n=e.start??"start",r=e.end??"end",i=e.cluster??null,o=e.group??null,a=e.strand??null,s=t.width??"100%",c=t.height??"400px",l=t.style??{},u=t.toolbar&&!Array.isArray(t.toolbar)?t.toolbar.buttons:void 0,h=!(Array.isArray(u)&&!u.includes("save")),f={};f.params={start:n,end:r},i!==null&&(f.params.cluster=i),o!==null&&(f.params.group=o),a!==null&&(f.params.strand=a),f.params.width=s,f.params.height=c,Object.keys(l).length&&(f.params.style=ge(l)),f.params.save_button=h;let d=Ke.from(t.data);for(let[k,C]of[[n,"start"],[r,"end"],[i,"cluster"],[o,"group"],[a,"strand"]])if(k!==null&&!d.has(k))throw new Error(`${C} column not found in data`);let m=d.names,p=d.get(n),g=d.get(r),y=d.filter(k=>p[k]!==null&&g[k]!==null),w=[];y.nrow<d.nrow&&w.push("Rows with NA values in 'start' or 'end' columns have been filtered out."),d=y,d.set("rowID",Array.from({length:d.nrow},(k,C)=>C+1));let b=d.copy();d.set("start",b.get(n).slice()),d.set("end",b.get(r).slice()),i!==null&&d.set(i,d.get(i).map(pe)),d=SE(d,a),f.data=d,o!==null&&(f.group=o),i!==null&&(f.cluster=i),f.graphContainer={direction:"column"},f.style=l,f.title={style:{width:"100%"}},f.legend={group:o,show:o!==null,width:s},f.legend.style={width:"100%",backgroundColor:l.backgroundColor??null},f.saveButton=h;let v=i===null?["cluster"]:[...new Set(d.get(i))],_=m.includes("BlastP")&&m.includes("protein_id"),S=new Map;for(let k of v){let C=i===null?d.copy():d.filter(M=>d.get(i)[M]===k);C.set("cluster",k);let F=typeof c=="string"&&/%$/.test(c)?Kl(c,v.length):Number(Vn(c,c))/v.length,A=C.get("start"),E=C.get("end"),D=[...A,...E].filter(M=>M!==null),$=vE;if(_){let M=C.get("BlastP"),T=C.get("protein_id");$=M.some((N,L)=>N!==null&&T[L]!==null&&N===T[L])&&M.every(N=>N===null||N==="No Hit"||T.includes(N))?wE:xE}S.set(k,{clusterName:k,data:C,cluster:{},container:{height:F,width:s,style:{width:"100%",backgroundColor:l.backgroundColor??null}},genes:{group:o,show:!0},sequence:{show:!0},scale:{xMin:Math.min(...D),xMax:Math.max(...D)},transcript:{group:o,show:!1},labels:{group:o,show:!0},coordinates:{show:!1},scaleBar:{},footer:{},clusterLabel:{},clusterTitle:{},annotations:[],trackMouse:{show:!1},tooltip:{show:!0,formatter:$}})}return f.series=S,{x:f,width:s,height:c,spec:t,warnings:w}}var qh={palettes:{okabeIto:["#E69F00","#56B4E9","#009E73","#F0E442","#0072B2","#D55E00","#CC79A7","#999999"],classic:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],vivid:["#4992ff","#7cffb2","#fddd60","#ff6e76","#58d9f9","#05c091","#ff8a45","#8d48e3","#dd79ff"],dark:["#dd6b66","#759aa0","#e69d87","#8dc1a9","#ea7e53","#eedd78","#73a373","#73b9bc","#7289ab","#91ca8c","#f49f42"],vintage:["#d87c7c","#919e8b","#d7ab82","#6e7074","#61a0a8","#efa18d","#787464","#cc7e63","#724e58","#4b565b"],infographic:["#C1232B","#27727B","#FCCE10","#E87C25","#B5C334","#FE8463","#9BCA63","#FAD860","#F3A43B","#60C0DD","#D7504B","#C6E579","#F4E001","#F0805A","#26C0C0"],greys:["#252525","#525252","#737373","#969696","#bdbdbd","#d9d9d9"],blues:["#08306b","#08519c","#2171b5","#4292c6","#6baed6","#9ecae1","#c6dbef"]},themes:{default:{},classic:{fontFamily:"sans-serif",textColor:"#6E7079",lineColor:"#6E7079",palette:"classic",title:{titleFont:{fontSize:"18px",fill:"#464646"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"#464646"}},clusterLabel:{fill:"#464646"},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"#464646"}},links:{normal_color:"#5470c6",inverted_color:"#ee6666",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#999999",hoverColor:"#3E98C5",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},dark:{fontFamily:"sans-serif",background:"#333333",textColor:"#eeeeee",lineColor:"#eeeeee",palette:"dark",title:{titleFont:{fontSize:"18px"},subtitleFont:{fontSize:"12px",fill:"#aaaaaa"}},clusterTitle:{subtitleFont:{fill:"#aaaaaa"}},clusterLabel:{subtitleFont:{fill:"#aaaaaa"}},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3},links:{normal_color:"#759aa0",inverted_color:"#dd6b66",low_color:"#333333",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#999999",hoverColor:"#eeeeee",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},vintage:{background:"#fef8ef",textColor:"#3f3a33",lineColor:"#787464",palette:"vintage",title:{subtitleFont:{fill:"#787464"}},clusterTitle:{subtitleFont:{fill:"#787464"}},clusterLabel:{subtitleFont:{fill:"#787464"}},sequence:{sequenceStyle:{stroke:"#c9c2b5"}},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"11px",leaderLine:{stroke:"#c9c2b5",strokeWidth:1}},legend:{corner_radius:3},links:{normal_color:"#61a0a8",inverted_color:"#d87c7c",low_color:"#fef8ef",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#c9c2b5",hoverColor:"#d87c7c",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},infographic:{fontFamily:"sans-serif",textColor:"#6E7079",lineColor:"#6E7079",palette:"infographic",title:{titleFont:{fontSize:"18px",fill:"#464646"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"#464646"}},clusterLabel:{fill:"#464646"},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"#464646"}},links:{normal_color:"#27727B",inverted_color:"#C1232B",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"rgba(50, 50, 50, 0.85)",color:"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px"},trackMouse:{backgroundColor:"rgba(50, 50, 50, 0.85)",color:"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px"},toolbar:{color:"#C1232B",hoverColor:"#E87C25",tooltipBackground:"rgba(50, 50, 50, 0.85)",tooltipColor:"#ffffff",tooltipBorder:"none",tooltipRadius:"4px"}},publication:{fontFamily:"Arial, Helvetica, sans-serif",textColor:"black",lineColor:"black",palette:"okabeIto",title:{titleFont:{fontSize:"9.33px",fill:"black"},subtitleFont:{fontSize:"9.33px"}},clusterTitle:{titleFont:{fontSize:"9.33px"},subtitleFont:{fontSize:"9.33px"}},clusterFooter:{titleFont:{fontSize:"9.33px"},subtitleFont:{fontSize:"9.33px"}},clusterLabel:{fontSize:"9.33px",subtitleFont:{fontSize:"9.33px"}},genes:{stroke:"black",strokeWidth:.75,corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3,fontSize:"9.33px"},labelOptions:{fontSize:"9.33px"}},labels:{fontStyle:"italic",fontSize:"9.33px",leaderLine:{strokeWidth:.75}},coordinates:{textStyle:{fontSize:"9.33px"},tickStyle:{lineLength:4}},scale:{textStyle:{fontSize:"9.33px"},tickStyle:{lineLength:4}},scaleBar:{labelStyle:{fontSize:"9.33px"}},legend:{corner_radius:2,legendOptions:{stroke:"black",strokeWidth:.75},legendTextOptions:{fontSize:"9.33px"}},links:{normal_color:"#0072B2",inverted_color:"#D55E00",linkStyle:{fillOpacity:.6},labelStyle:{fontSize:"9.33px"},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:9.33},titleOptions:{fontSize:9.33}}},annotations:{text:{style:{fontSize:"9.33px"}},textMarker:{textStyle:{fontSize:"9.33px"}},arc:{textStyle:{fontSize:"9.33px"}}},tooltip:{backgroundColor:"white",color:"black",border:"1px solid black",borderRadius:"0",boxShadow:"none",fontSize:"9.33px",padding:"8px"},trackMouse:{backgroundColor:"white",color:"black",border:"1px solid black",borderRadius:"0",boxShadow:"none",fontSize:"9.33px",padding:"8px"},toolbar:{color:"#999999",hoverColor:"black",tooltipBackground:"white",tooltipColor:"black",tooltipBorder:"1px solid black",tooltipRadius:"0",tooltipShadow:"none"}},bw:{fontFamily:"sans-serif",textColor:"#555555",lineColor:"#555555",pattern:{color:"black",background:"white",size:6,strokeWidth:1},title:{titleFont:{fontSize:"18px",fill:"black"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"black"}},clusterLabel:{fill:"black"},genes:{stroke:"black",strokeWidth:.75,corner_radius:3},transcript:{styleExons:{stroke:"black",strokeWidth:.75,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"black"}},links:{normal_color:"#bdbdbd",inverted_color:"#525252",colorBarOptions:{barOptions:{stroke:"#555555"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#bdbdbd",hoverColor:"black",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}}}};function Ft(t,e){let n={};for(let[r,i]of Object.entries(t))e.includes(r)||(n[r]=i);return n}function _a(t,e){return Array.from({length:t},(r,i)=>i).sort((r,i)=>{for(let o of e){let a=o(r),s=o(i),c=a===null||Number.isNaN(a),l=s===null||Number.isNaN(s);if(c||l){if(c!==l)return c?1:-1;continue}if(a<s)return-1;if(a>s)return 1}return r-i})}function AE(t,e=!1,n=0){if(!t||t.nrow===0)return null;let r=t.get("start"),i=t.get("end"),o=r.map((d,m)=>Math.min(d,i[m])),a=r.map((d,m)=>Math.max(d,i[m])),s=typeof n=="string",c=s?Number(n.replace(/%$/,""))/100:n,l=(d,m)=>{let p=Math.min(a[d],a[m])-Math.max(o[d],o[m])+1;if(p<=0)return!1;let g=s?c*Math.min(a[d]-o[d]+1,a[m]-o[m]+1):c;return p>g},u=o.map((d,m)=>o.some((p,g)=>g!==m&&o[g]<=o[m]&&a[g]>=a[m]&&(o[g]<o[m]||a[g]>a[m]||g<m))),h=[],f=new Map;for(let d=0;d<o.length;d++){if(e&&!u[d]){h[d]=1;continue}let m=e?2:1;for(;(f.get(m)||[]).some(p=>l(d,p));)m++;h[d]=m,f.set(m,[...f.get(m)||[],d])}return t.set("geneTrack",h),t}var EE=["separateStrands","strandSpacing","preventGeneOverlap","overlapMin","overlapSpacing","clusters","style"];function eb(t,e){let n=e.separateStrands??null,r=e.preventGeneOverlap??null,i=e.overlapMin??null;n===!0&&r!==null&&r!==!1&&(t.warnings.push("Setting both 'separate_strands' and 'prevent_gene_overlap' to TRUE is not supported. Resetting to NULL."),n=null,r=null);let o=Ft(e,EE);for(let a of Vt(t,e.clusters)){let s=t.x.series.get(a);if(r!==null&&r!==!1){let l=s.data,u=l.get("start"),h=l.get("end"),f=_a(l.nrow,[d=>-Math.max(u[d],h[d]),d=>Math.abs(h[d]-u[d])]);s.data=AE(l.rows(f),r==="nested",i===null?0:i)}s.container.style=Qe(s.container.style,e.style??{});let c=Ce({separateStrands:n,strandSpacing:e.strandSpacing,preventGeneOverlap:r!==null?r!==!1:null,overlapSpacing:e.overlapSpacing,...o});s.cluster=Qe(s.cluster,c),s.container=Qe(s.container,Ce({...o}))}}var Yh={white:"#FFFFFF",aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",antiquewhite1:"#FFEFDB",antiquewhite2:"#EEDFCC",antiquewhite3:"#CDC0B0",antiquewhite4:"#8B8378",aquamarine:"#7FFFD4",aquamarine1:"#7FFFD4",aquamarine2:"#76EEC6",aquamarine3:"#66CDAA",aquamarine4:"#458B74",azure:"#F0FFFF",azure1:"#F0FFFF",azure2:"#E0EEEE",azure3:"#C1CDCD",azure4:"#838B8B",beige:"#F5F5DC",bisque:"#FFE4C4",bisque1:"#FFE4C4",bisque2:"#EED5B7",bisque3:"#CDB79E",bisque4:"#8B7D6B",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blue1:"#0000FF",blue2:"#0000EE",blue3:"#0000CD",blue4:"#00008B",blueviolet:"#8A2BE2",brown:"#A52A2A",brown1:"#FF4040",brown2:"#EE3B3B",brown3:"#CD3333",brown4:"#8B2323",burlywood:"#DEB887",burlywood1:"#FFD39B",burlywood2:"#EEC591",burlywood3:"#CDAA7D",burlywood4:"#8B7355",cadetblue:"#5F9EA0",cadetblue1:"#98F5FF",cadetblue2:"#8EE5EE",cadetblue3:"#7AC5CD",cadetblue4:"#53868B",chartreuse:"#7FFF00",chartreuse1:"#7FFF00",chartreuse2:"#76EE00",chartreuse3:"#66CD00",chartreuse4:"#458B00",chocolate:"#D2691E",chocolate1:"#FF7F24",chocolate2:"#EE7621",chocolate3:"#CD661D",chocolate4:"#8B4513",coral:"#FF7F50",coral1:"#FF7256",coral2:"#EE6A50",coral3:"#CD5B45",coral4:"#8B3E2F",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",cornsilk1:"#FFF8DC",cornsilk2:"#EEE8CD",cornsilk3:"#CDC8B1",cornsilk4:"#8B8878",cyan:"#00FFFF",cyan1:"#00FFFF",cyan2:"#00EEEE",cyan3:"#00CDCD",cyan4:"#008B8B",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgoldenrod1:"#FFB90F",darkgoldenrod2:"#EEAD0E",darkgoldenrod3:"#CD950C",darkgoldenrod4:"#8B6508",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkolivegreen1:"#CAFF70",darkolivegreen2:"#BCEE68",darkolivegreen3:"#A2CD5A",darkolivegreen4:"#6E8B3D",darkorange:"#FF8C00",darkorange1:"#FF7F00",darkorange2:"#EE7600",darkorange3:"#CD6600",darkorange4:"#8B4500",darkorchid:"#9932CC",darkorchid1:"#BF3EFF",darkorchid2:"#B23AEE",darkorchid3:"#9A32CD",darkorchid4:"#68228B",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkseagreen1:"#C1FFC1",darkseagreen2:"#B4EEB4",darkseagreen3:"#9BCD9B",darkseagreen4:"#698B69",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategray1:"#97FFFF",darkslategray2:"#8DEEEE",darkslategray3:"#79CDCD",darkslategray4:"#528B8B",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deeppink1:"#FF1493",deeppink2:"#EE1289",deeppink3:"#CD1076",deeppink4:"#8B0A50",deepskyblue:"#00BFFF",deepskyblue1:"#00BFFF",deepskyblue2:"#00B2EE",deepskyblue3:"#009ACD",deepskyblue4:"#00688B",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",dodgerblue1:"#1E90FF",dodgerblue2:"#1C86EE",dodgerblue3:"#1874CD",dodgerblue4:"#104E8B",firebrick:"#B22222",firebrick1:"#FF3030",firebrick2:"#EE2C2C",firebrick3:"#CD2626",firebrick4:"#8B1A1A",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",gold1:"#FFD700",gold2:"#EEC900",gold3:"#CDAD00",gold4:"#8B7500",goldenrod:"#DAA520",goldenrod1:"#FFC125",goldenrod2:"#EEB422",goldenrod3:"#CD9B1D",goldenrod4:"#8B6914",gray:"#BEBEBE",gray0:"#000000",gray1:"#030303",gray2:"#050505",gray3:"#080808",gray4:"#0A0A0A",gray5:"#0D0D0D",gray6:"#0F0F0F",gray7:"#121212",gray8:"#141414",gray9:"#171717",gray10:"#1A1A1A",gray11:"#1C1C1C",gray12:"#1F1F1F",gray13:"#212121",gray14:"#242424",gray15:"#262626",gray16:"#292929",gray17:"#2B2B2B",gray18:"#2E2E2E",gray19:"#303030",gray20:"#333333",gray21:"#363636",gray22:"#383838",gray23:"#3B3B3B",gray24:"#3D3D3D",gray25:"#404040",gray26:"#424242",gray27:"#454545",gray28:"#474747",gray29:"#4A4A4A",gray30:"#4D4D4D",gray31:"#4F4F4F",gray32:"#525252",gray33:"#545454",gray34:"#575757",gray35:"#595959",gray36:"#5C5C5C",gray37:"#5E5E5E",gray38:"#616161",gray39:"#636363",gray40:"#666666",gray41:"#696969",gray42:"#6B6B6B",gray43:"#6E6E6E",gray44:"#707070",gray45:"#737373",gray46:"#757575",gray47:"#787878",gray48:"#7A7A7A",gray49:"#7D7D7D",gray50:"#7F7F7F",gray51:"#828282",gray52:"#858585",gray53:"#878787",gray54:"#8A8A8A",gray55:"#8C8C8C",gray56:"#8F8F8F",gray57:"#919191",gray58:"#949494",gray59:"#969696",gray60:"#999999",gray61:"#9C9C9C",gray62:"#9E9E9E",gray63:"#A1A1A1",gray64:"#A3A3A3",gray65:"#A6A6A6",gray66:"#A8A8A8",gray67:"#ABABAB",gray68:"#ADADAD",gray69:"#B0B0B0",gray70:"#B3B3B3",gray71:"#B5B5B5",gray72:"#B8B8B8",gray73:"#BABABA",gray74:"#BDBDBD",gray75:"#BFBFBF",gray76:"#C2C2C2",gray77:"#C4C4C4",gray78:"#C7C7C7",gray79:"#C9C9C9",gray80:"#CCCCCC",gray81:"#CFCFCF",gray82:"#D1D1D1",gray83:"#D4D4D4",gray84:"#D6D6D6",gray85:"#D9D9D9",gray86:"#DBDBDB",gray87:"#DEDEDE",gray88:"#E0E0E0",gray89:"#E3E3E3",gray90:"#E5E5E5",gray91:"#E8E8E8",gray92:"#EBEBEB",gray93:"#EDEDED",gray94:"#F0F0F0",gray95:"#F2F2F2",gray96:"#F5F5F5",gray97:"#F7F7F7",gray98:"#FAFAFA",gray99:"#FCFCFC",gray100:"#FFFFFF",green:"#00FF00",green1:"#00FF00",green2:"#00EE00",green3:"#00CD00",green4:"#008B00",greenyellow:"#ADFF2F",grey:"#BEBEBE",grey0:"#000000",grey1:"#030303",grey2:"#050505",grey3:"#080808",grey4:"#0A0A0A",grey5:"#0D0D0D",grey6:"#0F0F0F",grey7:"#121212",grey8:"#141414",grey9:"#171717",grey10:"#1A1A1A",grey11:"#1C1C1C",grey12:"#1F1F1F",grey13:"#212121",grey14:"#242424",grey15:"#262626",grey16:"#292929",grey17:"#2B2B2B",grey18:"#2E2E2E",grey19:"#303030",grey20:"#333333",grey21:"#363636",grey22:"#383838",grey23:"#3B3B3B",grey24:"#3D3D3D",grey25:"#404040",grey26:"#424242",grey27:"#454545",grey28:"#474747",grey29:"#4A4A4A",grey30:"#4D4D4D",grey31:"#4F4F4F",grey32:"#525252",grey33:"#545454",grey34:"#575757",grey35:"#595959",grey36:"#5C5C5C",grey37:"#5E5E5E",grey38:"#616161",grey39:"#636363",grey40:"#666666",grey41:"#696969",grey42:"#6B6B6B",grey43:"#6E6E6E",grey44:"#707070",grey45:"#737373",grey46:"#757575",grey47:"#787878",grey48:"#7A7A7A",grey49:"#7D7D7D",grey50:"#7F7F7F",grey51:"#828282",grey52:"#858585",grey53:"#878787",grey54:"#8A8A8A",grey55:"#8C8C8C",grey56:"#8F8F8F",grey57:"#919191",grey58:"#949494",grey59:"#969696",grey60:"#999999",grey61:"#9C9C9C",grey62:"#9E9E9E",grey63:"#A1A1A1",grey64:"#A3A3A3",grey65:"#A6A6A6",grey66:"#A8A8A8",grey67:"#ABABAB",grey68:"#ADADAD",grey69:"#B0B0B0",grey70:"#B3B3B3",grey71:"#B5B5B5",grey72:"#B8B8B8",grey73:"#BABABA",grey74:"#BDBDBD",grey75:"#BFBFBF",grey76:"#C2C2C2",grey77:"#C4C4C4",grey78:"#C7C7C7",grey79:"#C9C9C9",grey80:"#CCCCCC",grey81:"#CFCFCF",grey82:"#D1D1D1",grey83:"#D4D4D4",grey84:"#D6D6D6",grey85:"#D9D9D9",grey86:"#DBDBDB",grey87:"#DEDEDE",grey88:"#E0E0E0",grey89:"#E3E3E3",grey90:"#E5E5E5",grey91:"#E8E8E8",grey92:"#EBEBEB",grey93:"#EDEDED",grey94:"#F0F0F0",grey95:"#F2F2F2",grey96:"#F5F5F5",grey97:"#F7F7F7",grey98:"#FAFAFA",grey99:"#FCFCFC",grey100:"#FFFFFF",honeydew:"#F0FFF0",honeydew1:"#F0FFF0",honeydew2:"#E0EEE0",honeydew3:"#C1CDC1",honeydew4:"#838B83",hotpink:"#FF69B4",hotpink1:"#FF6EB4",hotpink2:"#EE6AA7",hotpink3:"#CD6090",hotpink4:"#8B3A62",indianred:"#CD5C5C",indianred1:"#FF6A6A",indianred2:"#EE6363",indianred3:"#CD5555",indianred4:"#8B3A3A",ivory:"#FFFFF0",ivory1:"#FFFFF0",ivory2:"#EEEEE0",ivory3:"#CDCDC1",ivory4:"#8B8B83",khaki:"#F0E68C",khaki1:"#FFF68F",khaki2:"#EEE685",khaki3:"#CDC673",khaki4:"#8B864E",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lavenderblush1:"#FFF0F5",lavenderblush2:"#EEE0E5",lavenderblush3:"#CDC1C5",lavenderblush4:"#8B8386",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lemonchiffon1:"#FFFACD",lemonchiffon2:"#EEE9BF",lemonchiffon3:"#CDC9A5",lemonchiffon4:"#8B8970",lightblue:"#ADD8E6",lightblue1:"#BFEFFF",lightblue2:"#B2DFEE",lightblue3:"#9AC0CD",lightblue4:"#68838B",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightcyan1:"#E0FFFF",lightcyan2:"#D1EEEE",lightcyan3:"#B4CDCD",lightcyan4:"#7A8B8B",lightgoldenrod:"#EEDD82",lightgoldenrod1:"#FFEC8B",lightgoldenrod2:"#EEDC82",lightgoldenrod3:"#CDBE70",lightgoldenrod4:"#8B814C",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightpink1:"#FFAEB9",lightpink2:"#EEA2AD",lightpink3:"#CD8C95",lightpink4:"#8B5F65",lightsalmon:"#FFA07A",lightsalmon1:"#FFA07A",lightsalmon2:"#EE9572",lightsalmon3:"#CD8162",lightsalmon4:"#8B5742",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightskyblue1:"#B0E2FF",lightskyblue2:"#A4D3EE",lightskyblue3:"#8DB6CD",lightskyblue4:"#607B8B",lightslateblue:"#8470FF",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightsteelblue1:"#CAE1FF",lightsteelblue2:"#BCD2EE",lightsteelblue3:"#A2B5CD",lightsteelblue4:"#6E7B8B",lightyellow:"#FFFFE0",lightyellow1:"#FFFFE0",lightyellow2:"#EEEED1",lightyellow3:"#CDCDB4",lightyellow4:"#8B8B7A",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",magenta1:"#FF00FF",magenta2:"#EE00EE",magenta3:"#CD00CD",magenta4:"#8B008B",maroon:"#B03060",maroon1:"#FF34B3",maroon2:"#EE30A7",maroon3:"#CD2990",maroon4:"#8B1C62",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumorchid1:"#E066FF",mediumorchid2:"#D15FEE",mediumorchid3:"#B452CD",mediumorchid4:"#7A378B",mediumpurple:"#9370DB",mediumpurple1:"#AB82FF",mediumpurple2:"#9F79EE",mediumpurple3:"#8968CD",mediumpurple4:"#5D478B",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",mistyrose1:"#FFE4E1",mistyrose2:"#EED5D2",mistyrose3:"#CDB7B5",mistyrose4:"#8B7D7B",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navajowhite1:"#FFDEAD",navajowhite2:"#EECFA1",navajowhite3:"#CDB38B",navajowhite4:"#8B795E",navy:"#000080",navyblue:"#000080",oldlace:"#FDF5E6",olivedrab:"#6B8E23",olivedrab1:"#C0FF3E",olivedrab2:"#B3EE3A",olivedrab3:"#9ACD32",olivedrab4:"#698B22",orange:"#FFA500",orange1:"#FFA500",orange2:"#EE9A00",orange3:"#CD8500",orange4:"#8B5A00",orangered:"#FF4500",orangered1:"#FF4500",orangered2:"#EE4000",orangered3:"#CD3700",orangered4:"#8B2500",orchid:"#DA70D6",orchid1:"#FF83FA",orchid2:"#EE7AE9",orchid3:"#CD69C9",orchid4:"#8B4789",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",palegreen1:"#9AFF9A",palegreen2:"#90EE90",palegreen3:"#7CCD7C",palegreen4:"#548B54",paleturquoise:"#AFEEEE",paleturquoise1:"#BBFFFF",paleturquoise2:"#AEEEEE",paleturquoise3:"#96CDCD",paleturquoise4:"#668B8B",palevioletred:"#DB7093",palevioletred1:"#FF82AB",palevioletred2:"#EE799F",palevioletred3:"#CD6889",palevioletred4:"#8B475D",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peachpuff1:"#FFDAB9",peachpuff2:"#EECBAD",peachpuff3:"#CDAF95",peachpuff4:"#8B7765",peru:"#CD853F",pink:"#FFC0CB",pink1:"#FFB5C5",pink2:"#EEA9B8",pink3:"#CD919E",pink4:"#8B636C",plum:"#DDA0DD",plum1:"#FFBBFF",plum2:"#EEAEEE",plum3:"#CD96CD",plum4:"#8B668B",powderblue:"#B0E0E6",purple:"#A020F0",purple1:"#9B30FF",purple2:"#912CEE",purple3:"#7D26CD",purple4:"#551A8B",red:"#FF0000",red1:"#FF0000",red2:"#EE0000",red3:"#CD0000",red4:"#8B0000",rosybrown:"#BC8F8F",rosybrown1:"#FFC1C1",rosybrown2:"#EEB4B4",rosybrown3:"#CD9B9B",rosybrown4:"#8B6969",royalblue:"#4169E1",royalblue1:"#4876FF",royalblue2:"#436EEE",royalblue3:"#3A5FCD",royalblue4:"#27408B",saddlebrown:"#8B4513",salmon:"#FA8072",salmon1:"#FF8C69",salmon2:"#EE8262",salmon3:"#CD7054",salmon4:"#8B4C39",sandybrown:"#F4A460",seagreen:"#2E8B57",seagreen1:"#54FF9F",seagreen2:"#4EEE94",seagreen3:"#43CD80",seagreen4:"#2E8B57",seashell:"#FFF5EE",seashell1:"#FFF5EE",seashell2:"#EEE5DE",seashell3:"#CDC5BF",seashell4:"#8B8682",sienna:"#A0522D",sienna1:"#FF8247",sienna2:"#EE7942",sienna3:"#CD6839",sienna4:"#8B4726",skyblue:"#87CEEB",skyblue1:"#87CEFF",skyblue2:"#7EC0EE",skyblue3:"#6CA6CD",skyblue4:"#4A708B",slateblue:"#6A5ACD",slateblue1:"#836FFF",slateblue2:"#7A67EE",slateblue3:"#6959CD",slateblue4:"#473C8B",slategray:"#708090",slategray1:"#C6E2FF",slategray2:"#B9D3EE",slategray3:"#9FB6CD",slategray4:"#6C7B8B",slategrey:"#708090",snow:"#FFFAFA",snow1:"#FFFAFA",snow2:"#EEE9E9",snow3:"#CDC9C9",snow4:"#8B8989",springgreen:"#00FF7F",springgreen1:"#00FF7F",springgreen2:"#00EE76",springgreen3:"#00CD66",springgreen4:"#008B45",steelblue:"#4682B4",steelblue1:"#63B8FF",steelblue2:"#5CACEE",steelblue3:"#4F94CD",steelblue4:"#36648B",tan:"#D2B48C",tan1:"#FFA54F",tan2:"#EE9A49",tan3:"#CD853F",tan4:"#8B5A2B",thistle:"#D8BFD8",thistle1:"#FFE1FF",thistle2:"#EED2EE",thistle3:"#CDB5CD",thistle4:"#8B7B8B",tomato:"#FF6347",tomato1:"#FF6347",tomato2:"#EE5C42",tomato3:"#CD4F39",tomato4:"#8B3626",turquoise:"#40E0D0",turquoise1:"#00F5FF",turquoise2:"#00E5EE",turquoise3:"#00C5CD",turquoise4:"#00868B",violet:"#EE82EE",violetred:"#D02090",violetred1:"#FF3E96",violetred2:"#EE3A8C",violetred3:"#CD3278",violetred4:"#8B2252",wheat:"#F5DEB3",wheat1:"#FFE7BA",wheat2:"#EED8AE",wheat3:"#CDBA96",wheat4:"#8B7E66",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellow1:"#FFFF00",yellow2:"#EEEE00",yellow3:"#CDCD00",yellow4:"#8B8B00",yellowgreen:"#9ACD32"},Uh=["#000000","#DF536B","#61D04F","#2297E6","#28E2E5","#CD0BBC","#F5C710","#9E9E9E"];function ee(t,e,n){let r=e[e.length-1],i=t;for(let o of e.slice(0,-1)){if(!Ht(i[o])){if(n==null)return;i[o]={}}i=i[o]}n==null?delete i[r]:i[r]=n}function En(t,e,n){for(let[r,i]of Object.entries(e)){let o=gt(i,n);o===void 0?delete t[r]:t[r]=o}return t}function Vr(t,e,n,r){Vt(t,e).forEach((i,o)=>{let a=t.x.series.get(i);a[n]=r(o,a)})}var ME=t=>Array.isArray(t)?t:[t];function Wh(t,e,n){let r=t.x.data.names;if(!ME(e).every(i=>r.includes(i)))throw new Error(n)}var CE=["label","show","clusters","itemStyle","groupStyle","styleBy"];function rb(t,e){let n=e.label??null,r=e.show??!0;if(n===null&&t.x.group===void 0)throw new Error("Please define labels");n===null&&(n=t.x.group),Wh(t,n,"label column not found in data");let i=Ft(e,CE);Vt(t,e.clusters).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({label:gt(n,a),show:gt(r,a),itemStyle:e.itemStyle,groupStyle:e.groupStyle,styleBy:e.styleBy,...i});s.labels=Qe(s.labels,c)})}function jh(t,e){return t.colorScheme==null&&t.customColors==null&&(ee(t,["colorScheme"],e?.colorScheme),ee(t,["customColors"],e?.customColors)),t.pattern==null&&ee(t,["pattern"],e?.pattern),t}function Xh(t,e,n){e==null&&n==null||(ee(t.x,["legend","legendOptions","colorScheme"],e),ee(t.x,["legend","legendOptions","customColors"],n))}var FE=["group","marker","markerSize","show","colorScheme","customColors","clusters","itemStyle","groupStyle","styleBy","cornerRadius"];function ib(t,e){let n=e.group??null,r=e.show??!0;n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&Wh(t,n,"group column not found in data");let i=Ft(e,FE);Vt(t,e.clusters).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({group:gt(n,a),marker:gt(e.marker,a),cornerRadius:e.cornerRadius,markerSize:e.markerSize,show:gt(r,a),colorScheme:e.colorScheme,customColors:e.customColors,itemStyle:e.itemStyle,groupStyle:e.groupStyle,styleBy:e.styleBy,...i});s.genes=jh(c,s.genes)}),e.clusters==null&&Xh(t,e.colorScheme,e.customColors)}function ob(t,e){let n=e.colorScheme??null,r=e.customColors??null;if(n!==null&&r!==null&&!Ht(r)){t.warnings.push("Both colorScheme and customColors are selected. Use a named list of customColors to set the colours of some groups, or choose only one.");return}ee(t.x,["legend","legendOptions","colorScheme"],n),ee(t.x,["legend","legendOptions","customColors"],r);for(let i of t.x.series.values())for(let o of["genes","transcript"])ee(i,[o,"colorScheme"],n),ee(i,[o,"customColors"],r)}var nb=["none","solid","horizontal","vertical","diagonal","antidiagonal","grid","crosshatch","dots","zigzag","checkerboard","rings","bricks","plus","wideStripes","inverseDots"];function Hh(t){if(t==null)return"#FFFFFF00";let e=String(t),n=o=>o.toString(16).toUpperCase().padStart(2,"0"),r=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e);if(r){let o=r[1];return o.length<=4&&(o=o.split("").map(a=>a+a).join("")),o=o.toUpperCase(),o.length===8&&o.endsWith("FF")?`#${o.slice(0,6)}`:`#${o}`}let i=e.toLowerCase();return i==="transparent"?"#FFFFFF00":Yh[i]?Yh[i]:/^[1-9][0-9]*$/.test(e)?Uh[(Number(e)-1)%Uh.length]:t}function Gh(t){let n=(Ht(t.patterns)?Object.values(t.patterns):[t.patterns??[]].flat()).filter(o=>o!==null&&!nb.includes(o));if(n.length)throw new Error(`Unknown pattern(s): ${n.join(", ")}. Available patterns: ${nb.join(", ")}`);let r=o=>{if(o!=null)return Ht(o)?Object.fromEntries(Object.entries(o).map(([a,s])=>[a,Hh(s)])):Array.isArray(o)?o.map(Hh):Hh(o)},i={};for(let[o,a]of Object.entries({patterns:t.patterns,color:r(t.color),background:r(t.background),size:t.size,strokeWidth:t.strokeWidth}))a!=null&&(i[o]=a);return i}function ab(t,e){let n=Gh({patterns:e.patterns,color:wa(e,"color","black"),background:wa(e,"background","white"),size:wa(e,"size",6),strokeWidth:wa(e,"strokeWidth",1)});ee(t.x,["legend","legendOptions","pattern"],n);for(let r of t.x.series.values())r.genes.pattern=n,r.transcript.pattern=n}var TE=["group","show","backgroundColor","order","position","align","style","markerStyle","textStyle","cornerRadius","groupStyle"];function sb(t,e){let n=e.group??null,r=e.show??!0;if(r===!0&&n===null&&t.x.group===void 0)throw new Error("Please define a group");n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&Wh(t,n,"group column not found in data");let i={...e.style??{}};e.backgroundColor!=null&&i.backgroundColor==null&&(i.backgroundColor=e.backgroundColor);let o=Ce({group:n,show:r,order:e.order,position:e.position,align:e.align,cornerRadius:e.cornerRadius,style:i,legendOptions:e.markerStyle,legendTextOptions:e.textStyle,groupStyle:e.groupStyle,...Ft(e,TE)});t.x.legend=Qe(t.x.legend,o)}var OE=["show","clusters","y","lineStyle","markerStyle"];function Vh(t,e){if(!t||!e)return t;for(let n of["start","end"])typeof t[n]=="number"&&(t[n]-=e);return t}function lb(t,e){let n=e.show??!0,r=Ft(e,OE);Vr(t,e.clusters,"sequence",(i,o)=>{let a={show:gt(n,i),y:gt(e.y,i)??null,sequenceStyle:e.lineStyle??{},markerStyle:e.markerStyle??{}};return Vh(En(a,r,i),o.positionShift)})}var BE=["show","tickValuesTop","tickValuesBottom","ticksFormat","tickStyle","textStyle","clusters","groupStyle","styleBy"];function cb(t,e){let n=e.show??!0,r=e.styleBy??null;if(r===null&&t.x.group!==void 0&&(r=t.x.group),e.groupStyle!=null&&r===null)throw new Error("groupStyle needs a group in GC_chart() or a style_by column");let i=Ft(e,BE);Vr(t,e.clusters,"coordinates",o=>{let a={show:gt(n,o),ticksFormat:e.ticksFormat??null,tickStyle:e.tickStyle??{},textStyle:e.textStyle??{}};return e.groupStyle!=null&&(a.groupStyle=e.groupStyle,a.styleBy=r),En(a,i,o),ee(a,["tickValuesTop"],e.tickValuesTop),ee(a,["tickValuesBottom"],e.tickValuesBottom),a})}var DE=["formatter","show","clusters"];function ub(t,e){let n=e.formatter??"<b>Start:</b> {start}<br><b>End:</b> {end}",r=e.show??!0,i=Ft(e,DE);Vr(t,e.clusters,"tooltip",o=>En({formatter:n,show:gt(r,o)},i,o))}var fb={scaleBar:{unit:"scaleBarUnit"},labels:{labelAdjustment:"labelAdjustmentOptions"},links:{labelAdjustment:"labelAdjustmentOptions"}},Zh={legend:{markerStyle:"legendOptions",textStyle:"legendTextOptions"},sequence:{lineStyle:"sequenceStyle"},scaleBar:{lineStyle:"scaleBarLineStyle",tickStyle:"scaleBarTickStyle",unit:"scaleBarUnit"},links:{show:"showLinks",labelAdjustment:"labelAdjustmentOptions"},labels:{labelAdjustment:"labelAdjustmentOptions"},scale:{autoBreaks:"scaleBreaks",autoBreakThreshold:"scaleBreakThreshold",breakPadding:"scaleBreakPadding"}};function Jl(t,e){return!e||t===null||typeof t!="object"||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).map(([n,r])=>[e[n]??n,r]))}var Kh={chart:"chartOptions",grid:"containerOptions",cluster:"clusterOptions",title:"titleOptions",clusterTitle:"clusterTitleOptions",clusterFooter:"footerOptions",clusterLabel:"clusterLabelOptions",sequence:"sequenceOptions",genes:"geneOptions",transcript:"transcriptOptions",labels:"labelsOptions",coordinates:"coordinatesOptions",scale:"scaleOptions",scaleBar:"scaleBarOptions",legend:"legendOptions",links:"linkOptions",tooltip:"tooltipOptions",trackMouse:"trackMouseOptions",toolbar:"toolbarOptions"},hb={text:"textAnnotationOptions",line:"lineAnnotationOptions",arrow:"arrowAnnotationOptions",textMarker:"textMarkerAnnotationOptions",symbol:"symbolAnnotationOptions",rectangle:"rectangleAnnotationOptions",promoter:"promoterAnnotationOptions",terminator:"terminatorAnnotationOptions",arc:"curveAnnotationOptions"},tc=qh.themes,Sa=qh.palettes,$E=t=>t.replace(/_([a-z])/g,(e,n)=>n.toUpperCase());function ec(t){return Ht(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[$E(e),n])):t}function zE(t){let e={...t};for(let n of Object.keys(e))n==="annotations"?Ht(e[n])&&(e[n]=Object.fromEntries(Object.entries(e[n]).map(([r,i])=>[r,ec(i)]))):n in Kh&&(e[n]=ec(e[n]));return e}function Jh(t,e){let n={...t};for(let[r,i]of Object.entries(e||{}))i==null?delete n[r]:Ht(n[r])&&Ht(i)?n[r]=Jh(n[r],i):n[r]=i;return n}function db(t,e){let n=typeof e=="string"?{base:e}:ge(e),r=n.base;delete n.base;let i;if(r==null)i=t.x.theme||{};else{if(!(r in tc))throw new Error(`name must be one of: ${Object.keys(tc).map(a=>`"${a}"`).join(", ")}`);i=zE(ge(tc[r]))}for(let a of Object.keys(n))a in Zh&&(n[a]=Jl(n[a],Zh[a]));let o=n.pattern===!1;o&&delete n.pattern,t.x.theme=Jh(i,n),o&&delete t.x.theme.pattern}function Qh(t){if(!Ht(t)&&!Array.isArray(t))return t;if(Array.isArray(t))return t.map(Qh).filter(n=>!((Ht(n)||Array.isArray(n))&&!Object.keys(n).length));let e={};for(let[n,r]of Object.entries(t)){let i=Qh(r);(Ht(i)||Array.isArray(i))&&Object.keys(i).length===0||(e[n]=i)}return e}function NE(t){let e=t.fontFamily!=null?{fontFamily:t.fontFamily}:{},n={...e,...t.textColor!=null?{fill:t.textColor}:{}},r={...e,...t.textColor!=null?{color:t.textColor}:{}},i=t.lineColor!=null?{stroke:t.lineColor}:{},o=t.palette??null;o!==null&&!(typeof o=="string"&&(o.startsWith("scheme")||o in Sa))&&(o=Array.isArray(o)?o:[o]);let a=o!==null?{colorScheme:o}:{},s=t.pattern!=null?{pattern:Gh(t.pattern)}:{},c=t.background!=null?{backgroundColor:t.background}:{};return Qh({chart:{style:c},title:{titleFont:n,subtitleFont:n},clusterTitle:{titleFont:n,subtitleFont:n},clusterFooter:{titleFont:n,subtitleFont:n},clusterLabel:{...n,subtitleFont:n},sequence:{sequenceStyle:i,markerStyle:i},genes:{...a,...s},transcript:{...a,...s,labelOptions:r,styleUTRs:t.background!=null?{fill:t.background}:{}},labels:{...n,leaderLine:i},coordinates:{textStyle:n,tickStyle:i},scale:{textStyle:n,tickStyle:i,lineStyle:i},scaleBar:{labelStyle:n,scaleBarLineStyle:i,scaleBarTickStyle:i},legend:{legendOptions:{...a,...s},legendTextOptions:n},links:{labelStyle:n,colorBarOptions:{labelOptions:n,titleOptions:n}},tooltip:r,trackMouse:r,toolbar:e,annotations:{text:{style:n},textMarker:{textStyle:n},arc:{textStyle:n}}})}function pb(t){if(!t||Object.keys(t).length===0)return;let e={};for(let i of Object.keys(t))i in Kh&&(e[i]=ec(t[i]));t.annotations!=null&&(e.annotations=Object.fromEntries(Object.entries(t.annotations).map(([i,o])=>[i,ec(o)])));let n=Jh(NE(t),e),r={};for(let[i,o]of Object.entries(Kh))i in n&&(r[o]=n[i]);for(let i of Object.keys(n.annotations||{}))i in hb&&(r[hb[i]]=n.annotations[i]);return t.textScale!=null&&(r.textScale=t.textScale),r}var RE=["translation","sequence"];function nc(t,e=[]){if(t instanceof Ke)return e;if(t instanceof Map)for(let n of t.values())nc(n,e);else if(Array.isArray(t))for(let n of t)nc(n,e);else if(t!==null&&typeof t=="object")for(let n of Object.values(t))nc(n,e);else typeof t=="string"&&e.push(t);return e}function PE(t){if(!t.data)return;let e={...t,data:void 0,series:new Map};for(let[o,a]of t.series)e.series.set(o,{...a,data:void 0});let n=nc(e),r=t.data.names,i=RE.filter(o=>r.includes(o)&&!n.some(a=>a.includes(o)));t.dataColumns=r.filter(o=>!i.includes(o)),delete t.data;for(let o of t.series.values())o.data instanceof Ke&&(o.data=o.data.select(o.data.names.filter(a=>!i.includes(a))))}function td(t){if(t instanceof Map){for(let[e,n]of t)t.set(e,td(n));return t}if(t===null||typeof t!="object"||t instanceof Ke)return t;for(let[e,n]of Object.entries(t))e==="colorScheme"&&typeof n=="string"&&Sa[n]?t[e]=Sa[n].slice():n!==null&&typeof n=="object"&&(t[e]=td(n));return t}function gb(t){let e=t.x;e.size={width:t.width};let n=pb(e.theme);return n===void 0?delete e.theme:e.theme=n,td(e),PE(e),e}var IE=["title","subtitle","style","subtitleFont","titleFont","show","height","align","spacing"];function mb(t,e){let n=e.show??!0;if(!n||e.title==null&&e.subtitle==null)return;let r=Ce({title:e.title,subtitle:e.subtitle,subtitleFont:e.subtitleFont,titleFont:e.titleFont,style:e.style,height:e.height,show:n,align:e.align,spacing:e.spacing,...Ft(e,IE)});t.x.title=Qe(t.x.title,r)}var LE=["title","subtitle","subtitleFont","titleFont","show","height","clusters","align","spacing"];function yb(t,e){let n=e.show??!0,r=Ft(e,LE);Vt(t,e.clusters).forEach((i,o)=>{let a=t.x.series.get(i),s={title:gt(e.title,o)??null,subtitle:gt(e.subtitle,o)??null,subtitleFont:e.subtitleFont??{},titleFont:e.titleFont??{},show:gt(n,o)};ee(s,["align"],gt(e.align,o)),ee(s,["spacing"],gt(e.spacing,o)),En(s,r,o),ee(a,["grid","margin","top"],gt(e.height,o)),a.clusterTitle=s})}var qE=["title","show","width","clusters","position","align","wrapLabel","wrapOptions","subtitle","subtitleFont","spacing"];function bb(t,e){let n=e.show??!0,r=Ft(e,qE),i=Vt(t,e.clusters),o=e.title??null;t.x.cluster!==void 0&&o===null&&(o=i),i.forEach((a,s)=>{let c=t.x.series.get(a),l=xa({title:gt(o,s),show:gt(n,s),width:gt(e.width,s),wrapLabel:e.wrapLabel,wrapOptions:e.wrapOptions??{},position:gt(e.position,s),align:gt(e.align,s),subtitle:gt(e.subtitle,s),spacing:gt(e.spacing,s)});Jy(e.subtitleFont)||(l.subtitleFont=e.subtitleFont),c.clusterLabel=En(l,r,s)})}var YE=["title","subtitle","show","clusters","subtitleFont","titleFont","align","spacing"];function vb(t,e){let n=e.show??!0,r=Ft(e,YE);Vr(t,e.clusters,"footer",i=>{let o={title:gt(e.title,i)??null,subtitle:gt(e.subtitle,i)??null,show:gt(n,i),subtitleFont:e.subtitleFont??{},titleFont:e.titleFont??{}};return ee(o,["align"],gt(e.align,i)),ee(o,["spacing"],gt(e.spacing,i)),En(o,r,i)})}function UE(t,e){let n=10**e;return Math.round(t*n)/n}function ka(t,e){let n=t.x,r=[...n.series.keys()],i=Vt(t,e.clusters),o=t.height,a=e.clusters!=null,s=e.margin==null?null:{...e.margin},c=e.width??null,l=e.height??null;if(c!==null&&!a&&(t.width=Vn(t.width,c)),(e.direction??"column")==="row"&&(n.graphContainer.direction="row",i.length>0)){let u=`${pe(UE(100/i.length,3))}%`;for(let h of i){let f=n.series.get(h).container;f.style={...f.style||{},width:u},f.width=u}}if(s!==null&&!a){let u=s.top!=null?Vn(o,s.top):0,h=s.bottom!=null?Vn(o,s.bottom):0;if(typeof u!="number"||typeof h!="number")throw new Error("Use pixel values for the top and bottom margins when the chart height is a percentage.");if(delete s.top,delete s.bottom,n.legend.margin=Qe(n.legend.margin,s),n.title.margin=Qe(n.title.margin,s),Array.isArray(n.style)&&(n.style={}),u>0&&(n.style.paddingTop=`${pe(u)}px`),h>0&&(n.style.paddingBottom=`${pe(h)}px`),u>0||h>0){t.height="100%";for(let f of r){let d=n.series.get(f).container;if(typeof d.height=="string"&&/%$/.test(d.height))continue;let m=Number(Vn(d.height,d.height));d.height=m-(u+h)/r.length}}}i.forEach((u,h)=>{let f=n.series.get(u).container;if(s!==null&&(f.margin=Qe(f.margin,s)),c!==null&&a){let d=Vn(t.width,gt(c,h));f.style={...f.style||{},width:d},f.width=d}l!==null&&(f.height=a?Vn(o,gt(l,h)):Kl(l,r.length))})}function wb(t){if(!/^\s*[0-9]*\.?[0-9]+\s*bp\s*$/.test(t))throw new Error('scale_break_padding must be a percentage, e.g. 1, or base pairs, e.g. "500bp"');return Number(t.replace(/\s*bp\s*$/,""))}function HE(t,e=0,n=0){let r=t.get("start").slice(),i=t.get("end").slice();r.forEach((f,d)=>{f>i[d]&&([r[d],i[d]]=[i[d],f])});let o=Math.max(...i)-Math.min(...r)+1,a=o*e/100,s=_a(r.length,[f=>r[f]]);r=s.map(f=>r[f]),i=s.map(f=>i[f]);let c=[],l={start:r[0],end:i[0]};for(let f=1;f<r.length;f++)r[f]<=l.end?l.end=Math.max(l.end,i[f]):(c.push(l),l={start:r[f],end:i[f]});c.push(l);let u=[];for(let f=0;f<c.length-1;f++){let d=c[f].end+1,m=c[f+1].start-1;m-d+1>=a&&u.push({start:d,end:m})}let h;return typeof n=="string"?h=wb(n):h=(o-u.reduce((d,m)=>d+(m.end-m.start+1),0))*n/100,u=u.map(f=>({start:f.start+h,end:f.end-h})),u.filter(f=>f.start<f.end)}function WE(t,e,n){if(Ht(t)){if(!("start"in t)||!("end"in t))throw new Error("A data frame of breaks needs a start and an end column");let r=[t.start].flat(),i=[t.end].flat(),o=r.map((a,s)=>s);if("cluster"in t){let a=[t.cluster].flat();o=o.filter(s=>pe(a[s])===e)}t=o.map(a=>({start:r[a],end:i[a]}))}return n?(t||[]).map(r=>({...r,start:r.start-n,end:r.end-n})):t}function ed(t,e){if(!e)return t;let n=i=>typeof i=="number"?i-e:i,r=i=>Array.isArray(i)?i.map(n):n(i);for(let i of["x","x1","x2"])i in t&&(t[i]=r(t[i]));return t.position!==null&&t.position!==void 0&&(t.type==="rectangle"?t.position=[t.position].flat(0).map(i=>Array.isArray(i)?i.map(o=>Array.isArray(o)?[n(o[0]),...o.slice(1)]:n(o)):[n(i)]):t.position=r(t.position)),t}var jE=["clusters","start","end","padding","hidden","breaks","tickValues","reverse","axisPosition","axisType","y","autoBreaks","autoBreakThreshold","breakPadding","ticksCount","ticksFormat","tickStyle","textStyle","lineStyle"];function xb(t,e){let n=t.x,r=e.axisType??"position",i=e.hidden??!1,o=e.autoBreaks??!1,a=e.autoBreakThreshold??20,s=e.breakPadding??1,c=e.ticksFormat??null;typeof s=="string"&&wb(s);let l=null,u=null,h=Vt(t,e.clusters);if(r==="range"){c===null&&(c=".2s");for(let d of h){let m=n.series.get(d),p=m.data,g=Math.min(...p.get("start"),...p.get("end"));p.set("start",p.get("start").map(_=>_-g+1)),p.set("end",p.get("end").map(_=>_-g+1));let y=g-1;m.sequence=Vh(m.sequence,y),m.annotations.length>0&&(m.annotations=m.annotations.map(_=>ed(_,y))),m.positionShift=m.positionShift==null?y:m.positionShift+y;let w=n.data.get("rowID"),b=n.data.get("start"),v=n.data.get("end");p.get("rowID").forEach((_,S)=>{let k=w.indexOf(_);b[k]=p.get("start")[S],v[k]=p.get("end")[S]})}l=1,u=Math.max(...h.flatMap(d=>{let m=n.series.get(d).data;return[...m.get("start"),...m.get("end")]}))}let f=Ft(e,jE);h.forEach((d,m)=>{let p=n.series.get(d),g=r==="range"&&!i&&m<h.length-1?!0:i,y=o?HE(p.data,a,s):WE(e.breaks??[],d,p.positionShift),w={start:gt(e.start,m)??null,end:gt(e.end,m)??null,xMin:l,xMax:u,padding:e.padding??null,hidden:g,breaks:y,tickValues:e.tickValues??null,reverse:gt(e.reverse??!1,m),axisPosition:e.axisPosition??null,axisType:r,scale_breaks:o,scale_break_threshold:a,scale_break_padding:s,ticksCount:e.ticksCount??null,ticksFormat:c,y:e.y??null,tickStyle:e.tickStyle??{},textStyle:e.textStyle??{},lineStyle:e.lineStyle??{}};p.scale=En(w,f,m)}),kb(t)}var XE=["show","clusters","lineStyle","tickStyle","labelStyle"];function _b(t,e){let n=e.show??!0,r=Ft(e,XE);Vr(t,e.clusters,"scaleBar",i=>En({show:gt(n,i),scaleBarLineStyle:e.lineStyle??{},scaleBarTickStyle:e.tickStyle??{},labelStyle:e.labelStyle??{}},r,i))}function GE(t,e,n,r){return t==="left"&&!r||t==="right"&&r?e:t==="right"&&!r||t==="left"&&r?n:t==="center"?(e+n)/2:e}function Sb(t,e){let n=t.x;if(n.cluster===void 0){t.warnings.push("Could not align selected gene. Please define cluster in the GC_chart function.");return}if(!n.data.has(e.idColumn)){t.warnings.push(`Column ${e.idColumn} not found in the data.`);return}let r=pe(e.id);if(!n.data.get(e.idColumn).some(i=>pe(i)===r)){t.warnings.push(`ID ${e.id} not found in the ${e.idColumn} column.`);return}t.align={idColumn:e.idColumn,id:e.id,align:e.align??"left"},n.align={id_column:e.idColumn,id:e.id,align:t.align.align},kb(t)}function kb(t){let e=t.align;if(!e)return;let n=t.x,r=n.data,i=n.cluster,o=r.get(i),a=[...new Set(o)],s=new Set(a.filter(w=>n.series.get(w)?.scale?.reverse===!0)),c=r.get("start").map((w,b)=>Math.min(w,r.get("end")[b])),l=r.get("start").map((w,b)=>Math.max(w,r.get("end")[b])),u=r.get(e.idColumn),h=pe(e.id),f=[];for(let w=0;w<r.nrow;w++)u[w]!==null&&pe(u[w])===h&&f.push(w);if(!f.length){t.warnings.push(`Selected gene coud not be aligned. Gene ${e.id} not found in the ${e.idColumn} column.`);return}if(new Set(f.map(w=>o[w])).size<f.length){t.warnings.push(`The selected gene ${e.id} appears multiple times in some clusters. Please make sure to use a unique gene id.`);return}let d=new Map;o.forEach((w,b)=>{let v=d.get(w)||{start:1/0,end:-1/0};d.set(w,{start:Math.min(v.start,c[b]),end:Math.max(v.end,l[b])})});let m=(w,b,v)=>(n.series.get(v)?.scale?.breaks||[]).reduce((_,S)=>_+Math.max(0,Math.min(S.end,b)-Math.max(S.start,w)),0),p=f.map(w=>{let b=o[w],v=s.has(b),_=GE(e.align,c[w],l[w],v),{start:S,end:k}=d.get(b),C=m(S,_,b),F=m(_,k,b),A=_-S-C,E=k-_-F;return{cl:b,isReversed:v,position:_,gapsBelow:C,gapsAbove:F,left:v?E:A,right:v?A:E}}),g=Math.max(...p.map(w=>w.left)),y=Math.max(...p.map(w=>w.right));for(let w of p){let b=n.series.get(w.cl);b.scale.start=w.position-(w.isReversed?y:g)-w.gapsBelow,b.scale.end=w.position+(w.isReversed?g:y)+w.gapsAbove}}var VE=["identity","similarity","none"],ZE=["data","group","value1","value2","clusters","curve","measure","show","label","labelPosition","normalColor","invertedColor","lowColor","vmin","vmax","useGroupColors","colorBar","colorBarOptions","linkWidth","linkStyle","labelStyle"],KE={position:["bottomright","bottomleft","topright","topleft","legend"],orientation:["vertical","horizontal"],labels:["inline","below"],legendSide:["left","right"]};function rc(t,e,n){t.has(e)&&(t.columns=new Map([...t.columns].map(([r,i])=>[r===e?n:r,i])))}function Ab(t,e){let n=e.measure??"identity",r=e.labelPosition??"gene",i=e.colorBarOptions??{};if(!VE.includes(n))throw new Error("Invalid measure specified. Choose 'identity', 'similarity', or 'none'.");if(!["gene","link"].includes(r))throw new Error(`'label_position' must be one of "gene", "link".`);for(let[y,w]of Object.entries(KE)){let b=i[y];if(b!=null&&!w.includes(b))throw new Error(`'colorBarOptions$${y}' must be one of ${w.map(v=>`"${v}"`).join(", ")}.`)}let o=e.vmin??null,a=e.vmax??null;if((o!==null||a!==null)&&(o??0)>=(a??100))throw new Error("'vmin' must be smaller than 'vmax'.");let s=e.group??null,c=e.label??!0;s===null&&r==="gene"&&(c=!1);let l=Ke.from(e.data??[]);if(l.nrow===0)return;l.has("identity2")&&rc(l,"identity2","identity"),l.has("similarity2")&&rc(l,"similarity2","similarity"),rc(l,`${s??""}1`,"group1"),rc(l,`${s??""}2`,"group2");let u=["cluster1","group1","start1","end1","cluster2","group2","start2","end2"];n!=="none"&&u.push(n);let h=e.useGroupColors??!1,f=e.colorBar;if(h){let y=t.x.group!==void 0?t.x.group:s,w=l.get(`${y??""}2`);w&&l.set("groupColor",w.slice()),u.push("groupColor"),f=!1}let d=l.select(u.filter(y=>l.has(y))),m=d.get("start2")||[];d=d.rows(_a(d.nrow,[y=>m[y]]));let p=Ce({group:s,curve:e.curve,measure:n,showLinks:e.show??!0,label:c,labelPosition:r,normalColor:e.normalColor,invertedColor:e.invertedColor,lowColor:e.lowColor,vmin:o,vmax:a,useGroupColors:h,value1:e.value1,value2:e.value2,colorBar:f,colorBarOptions:i,linkWidth:e.linkWidth,linkStyle:e.linkStyle,labelStyle:e.labelStyle,...Ft(e,ZE)}),g=t.x.links||[];d.set("linkID",Array.from({length:d.nrow},(y,w)=>`${g.length}-${w+1}`)),t.x.links=[...g,{data:d,options:p}]}var QE=["transcript","type","strand","group","selection","show","colorScheme","customColors","styleExons","styleIntrons","styleUTRs","itemStyleExons","itemStyleIntrons","itemStyleUTRs","groupStyleExons","groupStyleIntrons","groupStyleUTRs","styleBy","labelOptions"];function JE(t,e){return JSON.stringify(t)===JSON.stringify(e)}function tM(t,e){for(let a of["title","legend","theme","events","toolbar","zoom"])e.x[a]===void 0?delete t.x[a]:t.x[a]=e.x[a];t.width=e.width;let n=[...e.x.series.values()].map(a=>a.container.margin),i=n.length>0&&n.every(a=>JE(a,n[0]))?n[0]:{},o=Array.isArray(e.x.style)?{}:e.x.style||{};o.paddingTop!=null&&(i={...i||{},top:o.paddingTop}),o.paddingBottom!=null&&(i={...i||{},bottom:o.paddingBottom}),i&&Object.keys(i).length>0&&ka(t,{margin:i}),e.x.graphContainer?.direction==="row"&&ka(t,{direction:"row"})}function Eb(t,e){if(!t.x.transcript_called){let o=t.x.params,a={...t,x:t.x},s={start:o.start,end:o.end,cluster:e.transcript??"transcript"};o.group!==void 0&&(s.group=o.group),e.strand!=null&&(s.strand=e.strand);let c=Ql({...t.spec,fields:s,width:o.width,height:o.height,style:o.style});c.x.saveButton=o.save_button,c.x.params.save_button=o.save_button,t.x=c.x,t.width=c.width,t.height=c.height,tM(t,a);let l=[...new Set(t.x.data.get("transcript").map(String))];for(let u of l){let h=t.x.series.get(u);h.genes={group:null,show:!1},h.sequence={show:!1},h.transcript={group:null,show:!0}}}let n=e.group??null,r=e.show??!0;if(n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&![n].flat().every(o=>t.x.data.has(o)))throw new Error("group column not found in data");let i=Ft(e,QE);Vt(t,e.selection).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({group:gt(n,a),show:gt(r,a),colorScheme:e.colorScheme,customColors:e.customColors,styleExons:e.styleExons,styleIntrons:e.styleIntrons,styleUTRs:e.styleUTRs,itemStyleExons:e.itemStyleExons,itemStyleIntrons:e.itemStyleIntrons,itemStyleUTRs:e.itemStyleUTRs,groupStyleExons:e.groupStyleExons,groupStyleIntrons:e.groupStyleIntrons,groupStyleUTRs:e.groupStyleUTRs,styleBy:e.styleBy,labelOptions:e.labelOptions,...i});s.transcript=jh(c,s.transcript)}),e.selection==null&&Xh(t,e.colorScheme,e.customColors),t.x.transcript_called=!0}var Mb=["text","textMarker","line","arrow","symbol","rectangle","promoter","terminator","arc"];function Tb(t,e){let n=e.type??"text";if(typeof n!="string"||!Mb.includes(n))throw new Error(`'type' must be one of ${Mb.map(i=>`"${i}"`).join(", ")}.`);let r=Ft(e,["type","clusters"]);for(let i of Vt(t,e.clusters)){let o=t.x.series.get(i),a=ed(Ce({type:n,...ge(r)}),o.positionShift);o.annotations=[...o.annotations||[],a]}}var eM=["genes","labels","coordinates"],nM=["legend","title"],rM=["scaleBar","scale"],Cb=["genes","labels","coordinates","clusterTitle","clusterFooter","clusterLabel","legend","title","scaleBar","scale"];function Fb(t,e,n,r){let i=Array.isArray(t)?t:[],o=i.find(e)||{},a=i.filter(c=>!e(c)),s=Gr(o,r);for(let[c,l]of Object.entries(n))s[c]=l;return[...a,s]}function Ob(t,e){let n=e.component??"genes";if(!Cb.includes(n))throw new Error(`'component' must be one of ${Cb.join(", ")}`);let{rowID:r=null,cluster:i=null,part:o=null,end:a=null,group:s=null}=e,c=ge(Ft(e,["component","rowID","cluster","part","end","group"])),l=eM.includes(n),u=t.x;if(nM.includes(n)){if(n==="legend"){let y=u.legend?.group;if(s===null||y==null||!u.data.get(y)?.some(w=>String(w)===String(s)))throw new Error("'group' must identify one group in the legend.")}let p=n==="legend"?{group:s,part:o}:{part:o},g=y=>y.part===o&&(n==="title"||y.group===s);u[n].itemStyle=Fb(u[n].itemStyle,g,p,c);return}let h=n==="clusterFooter"?"footer":n,f,d,m;if(l){if(typeof r!="number"||!u.data.get("rowID").includes(r))throw new Error("'row_id' must identify one row in the chart's data.");f=a===null?{rowID:r}:{rowID:r,end:a},d=p=>Number(p.rowID)===Number(r)&&(p.end??null)===a,m=[...u.series.keys()]}else if(f=rM.includes(n)?{}:{part:o},d=p=>(p.part??null)===o,m=Vt(t,i),!m.length)throw new Error("'cluster' must be the name or number of a cluster of the chart.");for(let p of m){let g=u.series.get(p);l&&!g.data.get("rowID").includes(r)||((!g[h]||Array.isArray(g[h]))&&(g[h]={}),g[h].itemStyle=Fb(g[h].itemStyle,d,f,c))}}function Bb(t,e){let n=e.show??!0,r=Ft(e,["show","clusters"]);Vt(t,e.clusters).forEach((i,o)=>{t.x.series.get(i).trackMouse={show:gt(n,o),...ge(r)}})}function Db(t,e){let n={click:e.click??!0,highlight:e.highlight??!1};e.dblclick&&(n.dblclick=!0),e.select&&(n.select=!0),e.drag&&(n.drag=!0),e.legendClick===!1&&(n.legendClick=!1),e.zoom&&(n.zoom=!0),e.rendered&&(n.rendered=!0),e.renderId!=null&&(n.renderId=e.renderId),t.x.events=n}var iM=["show","position","buttons","size","color","hoverColor","tooltipBackground","tooltipColor","tooltipBorder","tooltipRadius","tooltipShadow","fontFamily","icons"];function $b(t,e){let n=xa(Object.fromEntries(iM.map(r=>[r,ge(e[r])])));n.buttons!==void 0&&!Array.isArray(n.buttons)&&(n.buttons=[n.buttons]),t.x.toolbar=Gr(t.x.toolbar||{},n)}var oM=["show","range","mode","min","update","height","overview","color","style","windowStyle","handleStyle"];function zb(t,e){let n=xa(Object.fromEntries(oM.map(i=>[i,ge(e[i])])));n.show===void 0&&(n.show=!0);let r={...t.x.zoom||{}};n.mode!==void 0&&n.mode!==r.mode&&(delete r.range,delete r.min),n.range!==void 0&&(n.range=[n.range].flat().map(Number).sort((i,o)=>i-o)),t.x.zoom=Gr(r,n)}var aM={cluster:eb,labels:rb,genes:ib,color:ob,pattern:ab,legend:sb,sequence:lb,coordinates:cb,tooltip:ub,title:mb,clusterTitle:yb,clusterLabel:bb,clusterFooter:vb,grid:ka,scale:xb,scaleBar:_b,align:Sb,links:Ab,transcript:Eb,annotation:Tb,elementStyle:Ob,theme:db,zoom:zb,toolbar:$b,events:Db,trackMouse:Bb},Nb=1,sM=new Set(["version","data","fields","width","height","style"]);function lM(t){return t==null?[]:Array.isArray(t)?t:[t]}function oc(t){if(!t||typeof t!="object")throw new Error("compile() needs a spec object");typeof t.version=="number"&&t.version>Nb&&console.warn(`geneviewer: spec version ${t.version} is newer than this library's (${Nb}); drawing what it knows`),t=ge(t);let e=Ql(t);for(let[n,r]of Object.entries(t)){if(sM.has(n))continue;let i=aM[n];if(i)for(let o of lM(r))i(e,Jl(o,fb[n]))}return ic(gb(e))}function ic(t){if(t instanceof Ke)return t.toJSON();if(t instanceof Map){let e={};for(let[n,r]of t)e[n]=ic(r);return e}if(Array.isArray(t))return t.map(ic);if(t!==null&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=ic(r));return e}return t}var Rb=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);function nd(t,e){let n={...t};for(let[r,i]of Object.entries(e||{}))i!==void 0&&(n[r]=r!=="data"&&Rb(n[r])&&Rb(i)?nd(n[r],i):structuredClone(i));return n}var Pb=`.geneviewer-container {
|
|
27
|
+
<b>Location:</b> {start} - {end}<br>`,tb=["1","forward","+","sense"],_E=["-1","0","reverse","-","antisense","complement"];function SE(t,e=null){if(!t||t.nrow===0)return null;if(e===null&&t.has("strand")&&(e="strand"),!t.has("start"))throw new Error("start column not found in data");if(!t.has("end"))throw new Error("end column not found in data");let n=t.get("start"),r=t.get("end");if(e===null)return t.set("strand",n.map((c,l)=>c===null||r[l]===null?null:c<r[l]?"forward":"reverse")),t;if(!t.has(e))throw new Error("strand column not found in data");let i=t.get(e).map(pe);if(!i.every(c=>tb.includes(c)||_E.includes(c)))throw new Error("Invalid strand values found. Valid values are 1/forward/+/sense or -1/0/reverse/-/antisense/complement.");let o=i.map(c=>tb.includes(c)?"forward":"reverse");t.set("strand",o);let a=n.slice(),s=r.slice();return o.forEach((c,l)=>{(c==="forward"&&n[l]>r[l]||c==="reverse"&&n[l]<r[l])&&(a[l]=r[l],s[l]=n[l])}),t.set("start",a),t.set("end",s),t}function Vt(t,e){let n=[...t.x.series.keys()];if(e==null)return n;let r=Array.isArray(e)?e:[e];if(r.length&&r.every(o=>typeof o=="number"))return r.some(o=>o>n.length||o<1)?(t.warnings.push("Some cluster numbers provided are out of range. Please check the cluster numbers."),[]):r.map(o=>n[Math.trunc(o)-1]);let i=r.map(o=>pe(o));return i.every(o=>n.includes(o))?i:(t.warnings.push("Some cluster names provided are not valid. Please check the cluster names."),[])}function Ql(t){let e=t.fields||{},n=e.start??"start",r=e.end??"end",i=e.cluster??null,o=e.group??null,a=e.strand??null,s=t.width??"100%",c=t.height??"400px",l=t.style??{},u=t.toolbar&&!Array.isArray(t.toolbar)?t.toolbar.buttons:void 0,h=!(Array.isArray(u)&&!u.includes("save")),f={};f.params={start:n,end:r},i!==null&&(f.params.cluster=i),o!==null&&(f.params.group=o),a!==null&&(f.params.strand=a),f.params.width=s,f.params.height=c,Object.keys(l).length&&(f.params.style=ge(l)),f.params.save_button=h;let d=Ke.from(t.data);for(let[k,C]of[[n,"start"],[r,"end"],[i,"cluster"],[o,"group"],[a,"strand"]])if(k!==null&&!d.has(k))throw new Error(`${C} column not found in data`);let m=d.names,p=d.get(n),g=d.get(r),y=d.filter(k=>p[k]!==null&&g[k]!==null),w=[];y.nrow<d.nrow&&w.push("Rows with NA values in 'start' or 'end' columns have been filtered out."),d=y,d.set("rowID",Array.from({length:d.nrow},(k,C)=>C+1));let b=d.copy();d.set("start",b.get(n).slice()),d.set("end",b.get(r).slice()),i!==null&&d.set(i,d.get(i).map(pe)),d=SE(d,a),f.data=d,o!==null&&(f.group=o),i!==null&&(f.cluster=i),f.graphContainer={direction:"column"},f.style=l,f.title={style:{width:"100%"}},f.legend={group:o,show:o!==null,width:s},f.legend.style={width:"100%",backgroundColor:l.backgroundColor??null},f.saveButton=h;let v=i===null?["cluster"]:[...new Set(d.get(i))],_=m.includes("BlastP")&&m.includes("protein_id"),S=new Map;for(let k of v){let C=i===null?d.copy():d.filter(M=>d.get(i)[M]===k);C.set("cluster",k);let F=typeof c=="string"&&/%$/.test(c)?Kl(c,v.length):Number(Vn(c,c))/v.length,A=C.get("start"),E=C.get("end"),D=[...A,...E].filter(M=>M!==null),$=vE;if(_){let M=C.get("BlastP"),T=C.get("protein_id");$=M.some((N,L)=>N!==null&&T[L]!==null&&N===T[L])&&M.every(N=>N===null||N==="No Hit"||T.includes(N))?wE:xE}S.set(k,{clusterName:k,data:C,cluster:{},container:{height:F,width:s,style:{width:"100%",backgroundColor:l.backgroundColor??null}},genes:{group:o,show:!0},sequence:{show:!0},scale:{xMin:Math.min(...D),xMax:Math.max(...D)},transcript:{group:o,show:!1},labels:{group:o,show:!0},coordinates:{show:!1},scaleBar:{},footer:{},clusterLabel:{},clusterTitle:{},annotations:[],trackMouse:{show:!1},tooltip:{show:!0,formatter:$}})}return f.series=S,{x:f,width:s,height:c,spec:t,warnings:w}}var qh={palettes:{okabeIto:["#E69F00","#56B4E9","#009E73","#F0E442","#0072B2","#D55E00","#CC79A7","#999999"],classic:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],vivid:["#4992ff","#7cffb2","#fddd60","#ff6e76","#58d9f9","#05c091","#ff8a45","#8d48e3","#dd79ff"],dark:["#dd6b66","#759aa0","#e69d87","#8dc1a9","#ea7e53","#eedd78","#73a373","#73b9bc","#7289ab","#91ca8c","#f49f42"],vintage:["#d87c7c","#919e8b","#d7ab82","#6e7074","#61a0a8","#efa18d","#787464","#cc7e63","#724e58","#4b565b"],infographic:["#C1232B","#27727B","#FCCE10","#E87C25","#B5C334","#FE8463","#9BCA63","#FAD860","#F3A43B","#60C0DD","#D7504B","#C6E579","#F4E001","#F0805A","#26C0C0"],greys:["#252525","#525252","#737373","#969696","#bdbdbd","#d9d9d9"],blues:["#08306b","#08519c","#2171b5","#4292c6","#6baed6","#9ecae1","#c6dbef"]},themes:{default:{},classic:{fontFamily:"sans-serif",textColor:"#6E7079",lineColor:"#6E7079",palette:"classic",title:{titleFont:{fontSize:"18px",fill:"#464646"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"#464646"}},clusterLabel:{fill:"#464646"},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"#464646"}},links:{normal_color:"#5470c6",inverted_color:"#ee6666",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#999999",hoverColor:"#3E98C5",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},dark:{fontFamily:"sans-serif",background:"#333333",textColor:"#eeeeee",lineColor:"#eeeeee",palette:"dark",title:{titleFont:{fontSize:"18px"},subtitleFont:{fontSize:"12px",fill:"#aaaaaa"}},clusterTitle:{subtitleFont:{fill:"#aaaaaa"}},clusterLabel:{subtitleFont:{fill:"#aaaaaa"}},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3},links:{normal_color:"#759aa0",inverted_color:"#dd6b66",low_color:"#333333",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#999999",hoverColor:"#eeeeee",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},vintage:{background:"#fef8ef",textColor:"#3f3a33",lineColor:"#787464",palette:"vintage",title:{subtitleFont:{fill:"#787464"}},clusterTitle:{subtitleFont:{fill:"#787464"}},clusterLabel:{subtitleFont:{fill:"#787464"}},sequence:{sequenceStyle:{stroke:"#c9c2b5"}},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"11px",leaderLine:{stroke:"#c9c2b5",strokeWidth:1}},legend:{corner_radius:3},links:{normal_color:"#61a0a8",inverted_color:"#d87c7c",low_color:"#fef8ef",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#c9c2b5",hoverColor:"#d87c7c",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}},infographic:{fontFamily:"sans-serif",textColor:"#6E7079",lineColor:"#6E7079",palette:"infographic",title:{titleFont:{fontSize:"18px",fill:"#464646"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"#464646"}},clusterLabel:{fill:"#464646"},genes:{stroke:"none",corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"#464646"}},links:{normal_color:"#27727B",inverted_color:"#C1232B",linkStyle:{fillOpacity:.6},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"rgba(50, 50, 50, 0.85)",color:"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px"},trackMouse:{backgroundColor:"rgba(50, 50, 50, 0.85)",color:"#ffffff",border:"none",borderRadius:"4px",fontSize:"12px"},toolbar:{color:"#C1232B",hoverColor:"#E87C25",tooltipBackground:"rgba(50, 50, 50, 0.85)",tooltipColor:"#ffffff",tooltipBorder:"none",tooltipRadius:"4px"}},publication:{fontFamily:"Arial, Helvetica, sans-serif",textColor:"black",lineColor:"black",palette:"okabeIto",title:{titleFont:{fontSize:"9.33px",fill:"black"},subtitleFont:{fontSize:"9.33px"}},clusterTitle:{titleFont:{fontSize:"9.33px"},subtitleFont:{fontSize:"9.33px"}},clusterFooter:{titleFont:{fontSize:"9.33px"},subtitleFont:{fontSize:"9.33px"}},clusterLabel:{fontSize:"9.33px",subtitleFont:{fontSize:"9.33px"}},genes:{stroke:"black",strokeWidth:.75,corner_radius:3},transcript:{styleExons:{strokeWidth:0,cornerRadius:3},styleUTRs:{cornerRadius:3,fontSize:"9.33px"},labelOptions:{fontSize:"9.33px"}},labels:{fontStyle:"italic",fontSize:"9.33px",leaderLine:{strokeWidth:.75}},coordinates:{textStyle:{fontSize:"9.33px"},tickStyle:{lineLength:4}},scale:{textStyle:{fontSize:"9.33px"},tickStyle:{lineLength:4}},scaleBar:{labelStyle:{fontSize:"9.33px"}},legend:{corner_radius:2,legendOptions:{stroke:"black",strokeWidth:.75},legendTextOptions:{fontSize:"9.33px"}},links:{normal_color:"#0072B2",inverted_color:"#D55E00",linkStyle:{fillOpacity:.6},labelStyle:{fontSize:"9.33px"},colorBarOptions:{barOptions:{stroke:"none"},labelOptions:{fontSize:9.33},titleOptions:{fontSize:9.33}}},annotations:{text:{style:{fontSize:"9.33px"}},textMarker:{textStyle:{fontSize:"9.33px"}},arc:{textStyle:{fontSize:"9.33px"}}},tooltip:{backgroundColor:"white",color:"black",border:"1px solid black",borderRadius:"0",boxShadow:"none",fontSize:"9.33px",padding:"8px"},trackMouse:{backgroundColor:"white",color:"black",border:"1px solid black",borderRadius:"0",boxShadow:"none",fontSize:"9.33px",padding:"8px"},toolbar:{color:"#999999",hoverColor:"black",tooltipBackground:"white",tooltipColor:"black",tooltipBorder:"1px solid black",tooltipRadius:"0",tooltipShadow:"none"}},bw:{fontFamily:"sans-serif",textColor:"#555555",lineColor:"#555555",pattern:{color:"black",background:"white",size:6,strokeWidth:1},title:{titleFont:{fontSize:"18px",fill:"black"},subtitleFont:{fontSize:"12px"}},clusterTitle:{titleFont:{fill:"black"}},clusterLabel:{fill:"black"},genes:{stroke:"black",strokeWidth:.75,corner_radius:3},transcript:{styleExons:{stroke:"black",strokeWidth:.75,cornerRadius:3},styleUTRs:{cornerRadius:3}},labels:{fontStyle:"normal",fontSize:"12px",leaderLine:{strokeWidth:1}},coordinates:{tickStyle:{lineLength:5}},scale:{textStyle:{fontSize:"12px"},tickStyle:{lineLength:5}},scaleBar:{labelStyle:{fontSize:"12px"}},legend:{corner_radius:3,legendTextOptions:{fill:"black"}},links:{normal_color:"#bdbdbd",inverted_color:"#525252",colorBarOptions:{barOptions:{stroke:"#555555"},labelOptions:{fontSize:12},titleOptions:{fontSize:12}}},tooltip:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},trackMouse:{backgroundColor:"#ffffff",color:"#6d6e73",border:"1px solid #b7b9be",borderRadius:"4px",fontSize:"12px",fontFamily:"sans-serif",padding:"8px",boxShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)"},toolbar:{color:"#bdbdbd",hoverColor:"black",tooltipBackground:"#ffffff",tooltipColor:"#6d6e73",tooltipBorder:"1px solid #b7b9be",tooltipRadius:"4px",tooltipShadow:"1px 2px 10px rgba(0, 0, 0, 0.2)",fontFamily:"sans-serif"}}}};function Ft(t,e){let n={};for(let[r,i]of Object.entries(t))e.includes(r)||(n[r]=i);return n}function _a(t,e){return Array.from({length:t},(r,i)=>i).sort((r,i)=>{for(let o of e){let a=o(r),s=o(i),c=a===null||Number.isNaN(a),l=s===null||Number.isNaN(s);if(c||l){if(c!==l)return c?1:-1;continue}if(a<s)return-1;if(a>s)return 1}return r-i})}function AE(t,e=!1,n=0){if(!t||t.nrow===0)return null;let r=t.get("start"),i=t.get("end"),o=r.map((d,m)=>Math.min(d,i[m])),a=r.map((d,m)=>Math.max(d,i[m])),s=typeof n=="string",c=s?Number(n.replace(/%$/,""))/100:n,l=(d,m)=>{let p=Math.min(a[d],a[m])-Math.max(o[d],o[m])+1;if(p<=0)return!1;let g=s?c*Math.min(a[d]-o[d]+1,a[m]-o[m]+1):c;return p>g},u=o.map((d,m)=>o.some((p,g)=>g!==m&&o[g]<=o[m]&&a[g]>=a[m]&&(o[g]<o[m]||a[g]>a[m]||g<m))),h=[],f=new Map;for(let d=0;d<o.length;d++){if(e&&!u[d]){h[d]=1;continue}let m=e?2:1;for(;(f.get(m)||[]).some(p=>l(d,p));)m++;h[d]=m,f.set(m,[...f.get(m)||[],d])}return t.set("geneTrack",h),t}var EE=["separateStrands","strandSpacing","preventGeneOverlap","overlapMin","overlapSpacing","clusters","style"];function eb(t,e){let n=e.separateStrands??null,r=e.preventGeneOverlap??null,i=e.overlapMin??null;n===!0&&r!==null&&r!==!1&&(t.warnings.push("Setting both 'separate_strands' and 'prevent_gene_overlap' to TRUE is not supported. Resetting to NULL."),n=null,r=null);let o=Ft(e,EE);for(let a of Vt(t,e.clusters)){let s=t.x.series.get(a);if(r!==null&&r!==!1){let l=s.data,u=l.get("start"),h=l.get("end"),f=_a(l.nrow,[d=>-Math.max(u[d],h[d]),d=>Math.abs(h[d]-u[d])]);s.data=AE(l.rows(f),r==="nested",i===null?0:i)}s.container.style=Qe(s.container.style,e.style??{});let c=Ce({separateStrands:n,strandSpacing:e.strandSpacing,preventGeneOverlap:r!==null?r!==!1:null,overlapSpacing:e.overlapSpacing,...o});s.cluster=Qe(s.cluster,c),s.container=Qe(s.container,Ce({...o}))}}var Yh={white:"#FFFFFF",aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",antiquewhite1:"#FFEFDB",antiquewhite2:"#EEDFCC",antiquewhite3:"#CDC0B0",antiquewhite4:"#8B8378",aquamarine:"#7FFFD4",aquamarine1:"#7FFFD4",aquamarine2:"#76EEC6",aquamarine3:"#66CDAA",aquamarine4:"#458B74",azure:"#F0FFFF",azure1:"#F0FFFF",azure2:"#E0EEEE",azure3:"#C1CDCD",azure4:"#838B8B",beige:"#F5F5DC",bisque:"#FFE4C4",bisque1:"#FFE4C4",bisque2:"#EED5B7",bisque3:"#CDB79E",bisque4:"#8B7D6B",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blue1:"#0000FF",blue2:"#0000EE",blue3:"#0000CD",blue4:"#00008B",blueviolet:"#8A2BE2",brown:"#A52A2A",brown1:"#FF4040",brown2:"#EE3B3B",brown3:"#CD3333",brown4:"#8B2323",burlywood:"#DEB887",burlywood1:"#FFD39B",burlywood2:"#EEC591",burlywood3:"#CDAA7D",burlywood4:"#8B7355",cadetblue:"#5F9EA0",cadetblue1:"#98F5FF",cadetblue2:"#8EE5EE",cadetblue3:"#7AC5CD",cadetblue4:"#53868B",chartreuse:"#7FFF00",chartreuse1:"#7FFF00",chartreuse2:"#76EE00",chartreuse3:"#66CD00",chartreuse4:"#458B00",chocolate:"#D2691E",chocolate1:"#FF7F24",chocolate2:"#EE7621",chocolate3:"#CD661D",chocolate4:"#8B4513",coral:"#FF7F50",coral1:"#FF7256",coral2:"#EE6A50",coral3:"#CD5B45",coral4:"#8B3E2F",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",cornsilk1:"#FFF8DC",cornsilk2:"#EEE8CD",cornsilk3:"#CDC8B1",cornsilk4:"#8B8878",cyan:"#00FFFF",cyan1:"#00FFFF",cyan2:"#00EEEE",cyan3:"#00CDCD",cyan4:"#008B8B",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgoldenrod1:"#FFB90F",darkgoldenrod2:"#EEAD0E",darkgoldenrod3:"#CD950C",darkgoldenrod4:"#8B6508",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkolivegreen1:"#CAFF70",darkolivegreen2:"#BCEE68",darkolivegreen3:"#A2CD5A",darkolivegreen4:"#6E8B3D",darkorange:"#FF8C00",darkorange1:"#FF7F00",darkorange2:"#EE7600",darkorange3:"#CD6600",darkorange4:"#8B4500",darkorchid:"#9932CC",darkorchid1:"#BF3EFF",darkorchid2:"#B23AEE",darkorchid3:"#9A32CD",darkorchid4:"#68228B",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkseagreen1:"#C1FFC1",darkseagreen2:"#B4EEB4",darkseagreen3:"#9BCD9B",darkseagreen4:"#698B69",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategray1:"#97FFFF",darkslategray2:"#8DEEEE",darkslategray3:"#79CDCD",darkslategray4:"#528B8B",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deeppink1:"#FF1493",deeppink2:"#EE1289",deeppink3:"#CD1076",deeppink4:"#8B0A50",deepskyblue:"#00BFFF",deepskyblue1:"#00BFFF",deepskyblue2:"#00B2EE",deepskyblue3:"#009ACD",deepskyblue4:"#00688B",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",dodgerblue1:"#1E90FF",dodgerblue2:"#1C86EE",dodgerblue3:"#1874CD",dodgerblue4:"#104E8B",firebrick:"#B22222",firebrick1:"#FF3030",firebrick2:"#EE2C2C",firebrick3:"#CD2626",firebrick4:"#8B1A1A",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",gold1:"#FFD700",gold2:"#EEC900",gold3:"#CDAD00",gold4:"#8B7500",goldenrod:"#DAA520",goldenrod1:"#FFC125",goldenrod2:"#EEB422",goldenrod3:"#CD9B1D",goldenrod4:"#8B6914",gray:"#BEBEBE",gray0:"#000000",gray1:"#030303",gray2:"#050505",gray3:"#080808",gray4:"#0A0A0A",gray5:"#0D0D0D",gray6:"#0F0F0F",gray7:"#121212",gray8:"#141414",gray9:"#171717",gray10:"#1A1A1A",gray11:"#1C1C1C",gray12:"#1F1F1F",gray13:"#212121",gray14:"#242424",gray15:"#262626",gray16:"#292929",gray17:"#2B2B2B",gray18:"#2E2E2E",gray19:"#303030",gray20:"#333333",gray21:"#363636",gray22:"#383838",gray23:"#3B3B3B",gray24:"#3D3D3D",gray25:"#404040",gray26:"#424242",gray27:"#454545",gray28:"#474747",gray29:"#4A4A4A",gray30:"#4D4D4D",gray31:"#4F4F4F",gray32:"#525252",gray33:"#545454",gray34:"#575757",gray35:"#595959",gray36:"#5C5C5C",gray37:"#5E5E5E",gray38:"#616161",gray39:"#636363",gray40:"#666666",gray41:"#696969",gray42:"#6B6B6B",gray43:"#6E6E6E",gray44:"#707070",gray45:"#737373",gray46:"#757575",gray47:"#787878",gray48:"#7A7A7A",gray49:"#7D7D7D",gray50:"#7F7F7F",gray51:"#828282",gray52:"#858585",gray53:"#878787",gray54:"#8A8A8A",gray55:"#8C8C8C",gray56:"#8F8F8F",gray57:"#919191",gray58:"#949494",gray59:"#969696",gray60:"#999999",gray61:"#9C9C9C",gray62:"#9E9E9E",gray63:"#A1A1A1",gray64:"#A3A3A3",gray65:"#A6A6A6",gray66:"#A8A8A8",gray67:"#ABABAB",gray68:"#ADADAD",gray69:"#B0B0B0",gray70:"#B3B3B3",gray71:"#B5B5B5",gray72:"#B8B8B8",gray73:"#BABABA",gray74:"#BDBDBD",gray75:"#BFBFBF",gray76:"#C2C2C2",gray77:"#C4C4C4",gray78:"#C7C7C7",gray79:"#C9C9C9",gray80:"#CCCCCC",gray81:"#CFCFCF",gray82:"#D1D1D1",gray83:"#D4D4D4",gray84:"#D6D6D6",gray85:"#D9D9D9",gray86:"#DBDBDB",gray87:"#DEDEDE",gray88:"#E0E0E0",gray89:"#E3E3E3",gray90:"#E5E5E5",gray91:"#E8E8E8",gray92:"#EBEBEB",gray93:"#EDEDED",gray94:"#F0F0F0",gray95:"#F2F2F2",gray96:"#F5F5F5",gray97:"#F7F7F7",gray98:"#FAFAFA",gray99:"#FCFCFC",gray100:"#FFFFFF",green:"#00FF00",green1:"#00FF00",green2:"#00EE00",green3:"#00CD00",green4:"#008B00",greenyellow:"#ADFF2F",grey:"#BEBEBE",grey0:"#000000",grey1:"#030303",grey2:"#050505",grey3:"#080808",grey4:"#0A0A0A",grey5:"#0D0D0D",grey6:"#0F0F0F",grey7:"#121212",grey8:"#141414",grey9:"#171717",grey10:"#1A1A1A",grey11:"#1C1C1C",grey12:"#1F1F1F",grey13:"#212121",grey14:"#242424",grey15:"#262626",grey16:"#292929",grey17:"#2B2B2B",grey18:"#2E2E2E",grey19:"#303030",grey20:"#333333",grey21:"#363636",grey22:"#383838",grey23:"#3B3B3B",grey24:"#3D3D3D",grey25:"#404040",grey26:"#424242",grey27:"#454545",grey28:"#474747",grey29:"#4A4A4A",grey30:"#4D4D4D",grey31:"#4F4F4F",grey32:"#525252",grey33:"#545454",grey34:"#575757",grey35:"#595959",grey36:"#5C5C5C",grey37:"#5E5E5E",grey38:"#616161",grey39:"#636363",grey40:"#666666",grey41:"#696969",grey42:"#6B6B6B",grey43:"#6E6E6E",grey44:"#707070",grey45:"#737373",grey46:"#757575",grey47:"#787878",grey48:"#7A7A7A",grey49:"#7D7D7D",grey50:"#7F7F7F",grey51:"#828282",grey52:"#858585",grey53:"#878787",grey54:"#8A8A8A",grey55:"#8C8C8C",grey56:"#8F8F8F",grey57:"#919191",grey58:"#949494",grey59:"#969696",grey60:"#999999",grey61:"#9C9C9C",grey62:"#9E9E9E",grey63:"#A1A1A1",grey64:"#A3A3A3",grey65:"#A6A6A6",grey66:"#A8A8A8",grey67:"#ABABAB",grey68:"#ADADAD",grey69:"#B0B0B0",grey70:"#B3B3B3",grey71:"#B5B5B5",grey72:"#B8B8B8",grey73:"#BABABA",grey74:"#BDBDBD",grey75:"#BFBFBF",grey76:"#C2C2C2",grey77:"#C4C4C4",grey78:"#C7C7C7",grey79:"#C9C9C9",grey80:"#CCCCCC",grey81:"#CFCFCF",grey82:"#D1D1D1",grey83:"#D4D4D4",grey84:"#D6D6D6",grey85:"#D9D9D9",grey86:"#DBDBDB",grey87:"#DEDEDE",grey88:"#E0E0E0",grey89:"#E3E3E3",grey90:"#E5E5E5",grey91:"#E8E8E8",grey92:"#EBEBEB",grey93:"#EDEDED",grey94:"#F0F0F0",grey95:"#F2F2F2",grey96:"#F5F5F5",grey97:"#F7F7F7",grey98:"#FAFAFA",grey99:"#FCFCFC",grey100:"#FFFFFF",honeydew:"#F0FFF0",honeydew1:"#F0FFF0",honeydew2:"#E0EEE0",honeydew3:"#C1CDC1",honeydew4:"#838B83",hotpink:"#FF69B4",hotpink1:"#FF6EB4",hotpink2:"#EE6AA7",hotpink3:"#CD6090",hotpink4:"#8B3A62",indianred:"#CD5C5C",indianred1:"#FF6A6A",indianred2:"#EE6363",indianred3:"#CD5555",indianred4:"#8B3A3A",ivory:"#FFFFF0",ivory1:"#FFFFF0",ivory2:"#EEEEE0",ivory3:"#CDCDC1",ivory4:"#8B8B83",khaki:"#F0E68C",khaki1:"#FFF68F",khaki2:"#EEE685",khaki3:"#CDC673",khaki4:"#8B864E",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lavenderblush1:"#FFF0F5",lavenderblush2:"#EEE0E5",lavenderblush3:"#CDC1C5",lavenderblush4:"#8B8386",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lemonchiffon1:"#FFFACD",lemonchiffon2:"#EEE9BF",lemonchiffon3:"#CDC9A5",lemonchiffon4:"#8B8970",lightblue:"#ADD8E6",lightblue1:"#BFEFFF",lightblue2:"#B2DFEE",lightblue3:"#9AC0CD",lightblue4:"#68838B",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightcyan1:"#E0FFFF",lightcyan2:"#D1EEEE",lightcyan3:"#B4CDCD",lightcyan4:"#7A8B8B",lightgoldenrod:"#EEDD82",lightgoldenrod1:"#FFEC8B",lightgoldenrod2:"#EEDC82",lightgoldenrod3:"#CDBE70",lightgoldenrod4:"#8B814C",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightpink1:"#FFAEB9",lightpink2:"#EEA2AD",lightpink3:"#CD8C95",lightpink4:"#8B5F65",lightsalmon:"#FFA07A",lightsalmon1:"#FFA07A",lightsalmon2:"#EE9572",lightsalmon3:"#CD8162",lightsalmon4:"#8B5742",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightskyblue1:"#B0E2FF",lightskyblue2:"#A4D3EE",lightskyblue3:"#8DB6CD",lightskyblue4:"#607B8B",lightslateblue:"#8470FF",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightsteelblue1:"#CAE1FF",lightsteelblue2:"#BCD2EE",lightsteelblue3:"#A2B5CD",lightsteelblue4:"#6E7B8B",lightyellow:"#FFFFE0",lightyellow1:"#FFFFE0",lightyellow2:"#EEEED1",lightyellow3:"#CDCDB4",lightyellow4:"#8B8B7A",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",magenta1:"#FF00FF",magenta2:"#EE00EE",magenta3:"#CD00CD",magenta4:"#8B008B",maroon:"#B03060",maroon1:"#FF34B3",maroon2:"#EE30A7",maroon3:"#CD2990",maroon4:"#8B1C62",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumorchid1:"#E066FF",mediumorchid2:"#D15FEE",mediumorchid3:"#B452CD",mediumorchid4:"#7A378B",mediumpurple:"#9370DB",mediumpurple1:"#AB82FF",mediumpurple2:"#9F79EE",mediumpurple3:"#8968CD",mediumpurple4:"#5D478B",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",mistyrose1:"#FFE4E1",mistyrose2:"#EED5D2",mistyrose3:"#CDB7B5",mistyrose4:"#8B7D7B",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navajowhite1:"#FFDEAD",navajowhite2:"#EECFA1",navajowhite3:"#CDB38B",navajowhite4:"#8B795E",navy:"#000080",navyblue:"#000080",oldlace:"#FDF5E6",olivedrab:"#6B8E23",olivedrab1:"#C0FF3E",olivedrab2:"#B3EE3A",olivedrab3:"#9ACD32",olivedrab4:"#698B22",orange:"#FFA500",orange1:"#FFA500",orange2:"#EE9A00",orange3:"#CD8500",orange4:"#8B5A00",orangered:"#FF4500",orangered1:"#FF4500",orangered2:"#EE4000",orangered3:"#CD3700",orangered4:"#8B2500",orchid:"#DA70D6",orchid1:"#FF83FA",orchid2:"#EE7AE9",orchid3:"#CD69C9",orchid4:"#8B4789",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",palegreen1:"#9AFF9A",palegreen2:"#90EE90",palegreen3:"#7CCD7C",palegreen4:"#548B54",paleturquoise:"#AFEEEE",paleturquoise1:"#BBFFFF",paleturquoise2:"#AEEEEE",paleturquoise3:"#96CDCD",paleturquoise4:"#668B8B",palevioletred:"#DB7093",palevioletred1:"#FF82AB",palevioletred2:"#EE799F",palevioletred3:"#CD6889",palevioletred4:"#8B475D",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peachpuff1:"#FFDAB9",peachpuff2:"#EECBAD",peachpuff3:"#CDAF95",peachpuff4:"#8B7765",peru:"#CD853F",pink:"#FFC0CB",pink1:"#FFB5C5",pink2:"#EEA9B8",pink3:"#CD919E",pink4:"#8B636C",plum:"#DDA0DD",plum1:"#FFBBFF",plum2:"#EEAEEE",plum3:"#CD96CD",plum4:"#8B668B",powderblue:"#B0E0E6",purple:"#A020F0",purple1:"#9B30FF",purple2:"#912CEE",purple3:"#7D26CD",purple4:"#551A8B",red:"#FF0000",red1:"#FF0000",red2:"#EE0000",red3:"#CD0000",red4:"#8B0000",rosybrown:"#BC8F8F",rosybrown1:"#FFC1C1",rosybrown2:"#EEB4B4",rosybrown3:"#CD9B9B",rosybrown4:"#8B6969",royalblue:"#4169E1",royalblue1:"#4876FF",royalblue2:"#436EEE",royalblue3:"#3A5FCD",royalblue4:"#27408B",saddlebrown:"#8B4513",salmon:"#FA8072",salmon1:"#FF8C69",salmon2:"#EE8262",salmon3:"#CD7054",salmon4:"#8B4C39",sandybrown:"#F4A460",seagreen:"#2E8B57",seagreen1:"#54FF9F",seagreen2:"#4EEE94",seagreen3:"#43CD80",seagreen4:"#2E8B57",seashell:"#FFF5EE",seashell1:"#FFF5EE",seashell2:"#EEE5DE",seashell3:"#CDC5BF",seashell4:"#8B8682",sienna:"#A0522D",sienna1:"#FF8247",sienna2:"#EE7942",sienna3:"#CD6839",sienna4:"#8B4726",skyblue:"#87CEEB",skyblue1:"#87CEFF",skyblue2:"#7EC0EE",skyblue3:"#6CA6CD",skyblue4:"#4A708B",slateblue:"#6A5ACD",slateblue1:"#836FFF",slateblue2:"#7A67EE",slateblue3:"#6959CD",slateblue4:"#473C8B",slategray:"#708090",slategray1:"#C6E2FF",slategray2:"#B9D3EE",slategray3:"#9FB6CD",slategray4:"#6C7B8B",slategrey:"#708090",snow:"#FFFAFA",snow1:"#FFFAFA",snow2:"#EEE9E9",snow3:"#CDC9C9",snow4:"#8B8989",springgreen:"#00FF7F",springgreen1:"#00FF7F",springgreen2:"#00EE76",springgreen3:"#00CD66",springgreen4:"#008B45",steelblue:"#4682B4",steelblue1:"#63B8FF",steelblue2:"#5CACEE",steelblue3:"#4F94CD",steelblue4:"#36648B",tan:"#D2B48C",tan1:"#FFA54F",tan2:"#EE9A49",tan3:"#CD853F",tan4:"#8B5A2B",thistle:"#D8BFD8",thistle1:"#FFE1FF",thistle2:"#EED2EE",thistle3:"#CDB5CD",thistle4:"#8B7B8B",tomato:"#FF6347",tomato1:"#FF6347",tomato2:"#EE5C42",tomato3:"#CD4F39",tomato4:"#8B3626",turquoise:"#40E0D0",turquoise1:"#00F5FF",turquoise2:"#00E5EE",turquoise3:"#00C5CD",turquoise4:"#00868B",violet:"#EE82EE",violetred:"#D02090",violetred1:"#FF3E96",violetred2:"#EE3A8C",violetred3:"#CD3278",violetred4:"#8B2252",wheat:"#F5DEB3",wheat1:"#FFE7BA",wheat2:"#EED8AE",wheat3:"#CDBA96",wheat4:"#8B7E66",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellow1:"#FFFF00",yellow2:"#EEEE00",yellow3:"#CDCD00",yellow4:"#8B8B00",yellowgreen:"#9ACD32"},Uh=["#000000","#DF536B","#61D04F","#2297E6","#28E2E5","#CD0BBC","#F5C710","#9E9E9E"];function ee(t,e,n){let r=e[e.length-1],i=t;for(let o of e.slice(0,-1)){if(!Ht(i[o])){if(n==null)return;i[o]={}}i=i[o]}n==null?delete i[r]:i[r]=n}function En(t,e,n){for(let[r,i]of Object.entries(e)){let o=gt(i,n);o===void 0?delete t[r]:t[r]=o}return t}function Vr(t,e,n,r){Vt(t,e).forEach((i,o)=>{let a=t.x.series.get(i);a[n]=r(o,a)})}var ME=t=>Array.isArray(t)?t:[t];function Wh(t,e,n){let r=t.x.data.names;if(!ME(e).every(i=>r.includes(i)))throw new Error(n)}var CE=["label","show","clusters","itemStyle","groupStyle","styleBy"];function rb(t,e){let n=e.label??null,r=e.show??!0;if(n===null&&t.x.group===void 0)throw new Error("Please define labels");n===null&&(n=t.x.group),Wh(t,n,"label column not found in data");let i=Ft(e,CE);Vt(t,e.clusters).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({label:gt(n,a),show:gt(r,a),itemStyle:e.itemStyle,groupStyle:e.groupStyle,styleBy:e.styleBy,...i});s.labels=Qe(s.labels,c)})}function jh(t,e){return t.colorScheme==null&&t.customColors==null&&(ee(t,["colorScheme"],e?.colorScheme),ee(t,["customColors"],e?.customColors)),t.pattern==null&&ee(t,["pattern"],e?.pattern),t}function Xh(t,e,n){e==null&&n==null||(ee(t.x,["legend","legendOptions","colorScheme"],e),ee(t.x,["legend","legendOptions","customColors"],n))}var FE=["group","marker","markerSize","show","colorScheme","customColors","clusters","itemStyle","groupStyle","styleBy","cornerRadius"];function ib(t,e){let n=e.group??null,r=e.show??!0;n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&Wh(t,n,"group column not found in data");let i=Ft(e,FE);Vt(t,e.clusters).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({group:gt(n,a),marker:gt(e.marker,a),cornerRadius:e.cornerRadius,markerSize:e.markerSize,show:gt(r,a),colorScheme:e.colorScheme,customColors:e.customColors,itemStyle:e.itemStyle,groupStyle:e.groupStyle,styleBy:e.styleBy,...i});s.genes=jh(c,s.genes)}),e.clusters==null&&Xh(t,e.colorScheme,e.customColors)}function ob(t,e){let n=e.colorScheme??null,r=e.customColors??null;if(n!==null&&r!==null&&!Ht(r)){t.warnings.push("Both colorScheme and customColors are selected. Use a named list of customColors to set the colours of some groups, or choose only one.");return}ee(t.x,["legend","legendOptions","colorScheme"],n),ee(t.x,["legend","legendOptions","customColors"],r);for(let i of t.x.series.values())for(let o of["genes","transcript"])ee(i,[o,"colorScheme"],n),ee(i,[o,"customColors"],r)}var nb=["none","solid","horizontal","vertical","diagonal","antidiagonal","grid","crosshatch","dots","zigzag","checkerboard","rings","bricks","plus","wideStripes","inverseDots"];function Hh(t){if(t==null)return"#FFFFFF00";let e=String(t),n=o=>o.toString(16).toUpperCase().padStart(2,"0"),r=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e);if(r){let o=r[1];return o.length<=4&&(o=o.split("").map(a=>a+a).join("")),o=o.toUpperCase(),o.length===8&&o.endsWith("FF")?`#${o.slice(0,6)}`:`#${o}`}let i=e.toLowerCase();return i==="transparent"?"#FFFFFF00":Yh[i]?Yh[i]:/^[1-9][0-9]*$/.test(e)?Uh[(Number(e)-1)%Uh.length]:t}function Gh(t){let n=(Ht(t.patterns)?Object.values(t.patterns):[t.patterns??[]].flat()).filter(o=>o!==null&&!nb.includes(o));if(n.length)throw new Error(`Unknown pattern(s): ${n.join(", ")}. Available patterns: ${nb.join(", ")}`);let r=o=>{if(o!=null)return Ht(o)?Object.fromEntries(Object.entries(o).map(([a,s])=>[a,Hh(s)])):Array.isArray(o)?o.map(Hh):Hh(o)},i={};for(let[o,a]of Object.entries({patterns:t.patterns,color:r(t.color),background:r(t.background),size:t.size,strokeWidth:t.strokeWidth}))a!=null&&(i[o]=a);return i}function ab(t,e){let n=Gh({patterns:e.patterns,color:wa(e,"color","black"),background:wa(e,"background","white"),size:wa(e,"size",6),strokeWidth:wa(e,"strokeWidth",1)});ee(t.x,["legend","legendOptions","pattern"],n);for(let r of t.x.series.values())r.genes.pattern=n,r.transcript.pattern=n}var TE=["group","show","backgroundColor","order","position","align","style","markerStyle","textStyle","cornerRadius","groupStyle"];function sb(t,e){let n=e.group??null,r=e.show??!0;if(r===!0&&n===null&&t.x.group===void 0)throw new Error("Please define a group");n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&Wh(t,n,"group column not found in data");let i={...e.style??{}};e.backgroundColor!=null&&i.backgroundColor==null&&(i.backgroundColor=e.backgroundColor);let o=Ce({group:n,show:r,order:e.order,position:e.position,align:e.align,cornerRadius:e.cornerRadius,style:i,legendOptions:e.markerStyle,legendTextOptions:e.textStyle,groupStyle:e.groupStyle,...Ft(e,TE)});t.x.legend=Qe(t.x.legend,o)}var OE=["show","clusters","y","lineStyle","markerStyle"];function Vh(t,e){if(!t||!e)return t;for(let n of["start","end"])typeof t[n]=="number"&&(t[n]-=e);return t}function lb(t,e){let n=e.show??!0,r=Ft(e,OE);Vr(t,e.clusters,"sequence",(i,o)=>{let a={show:gt(n,i),y:gt(e.y,i)??null,sequenceStyle:e.lineStyle??{},markerStyle:e.markerStyle??{}};return Vh(En(a,r,i),o.positionShift)})}var BE=["show","tickValuesTop","tickValuesBottom","ticksFormat","tickStyle","textStyle","clusters","groupStyle","styleBy"];function cb(t,e){let n=e.show??!0,r=e.styleBy??null;if(r===null&&t.x.group!==void 0&&(r=t.x.group),e.groupStyle!=null&&r===null)throw new Error("groupStyle needs a group in GC_chart() or a style_by column");let i=Ft(e,BE);Vr(t,e.clusters,"coordinates",o=>{let a={show:gt(n,o),ticksFormat:e.ticksFormat??null,tickStyle:e.tickStyle??{},textStyle:e.textStyle??{}};return e.groupStyle!=null&&(a.groupStyle=e.groupStyle,a.styleBy=r),En(a,i,o),ee(a,["tickValuesTop"],e.tickValuesTop),ee(a,["tickValuesBottom"],e.tickValuesBottom),a})}var DE=["formatter","show","clusters"];function ub(t,e){let n=e.formatter??"<b>Start:</b> {start}<br><b>End:</b> {end}",r=e.show??!0,i=Ft(e,DE);Vr(t,e.clusters,"tooltip",o=>En({formatter:n,show:gt(r,o)},i,o))}var fb={scaleBar:{unit:"scaleBarUnit"},labels:{labelAdjustment:"labelAdjustmentOptions"},links:{labelAdjustment:"labelAdjustmentOptions"}},Zh={legend:{markerStyle:"legendOptions",textStyle:"legendTextOptions"},sequence:{lineStyle:"sequenceStyle"},scaleBar:{lineStyle:"scaleBarLineStyle",tickStyle:"scaleBarTickStyle",unit:"scaleBarUnit"},links:{show:"showLinks",labelAdjustment:"labelAdjustmentOptions"},labels:{labelAdjustment:"labelAdjustmentOptions"},scale:{autoBreaks:"scaleBreaks",autoBreakThreshold:"scaleBreakThreshold",breakPadding:"scaleBreakPadding"}};function Jl(t,e){return!e||t===null||typeof t!="object"||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).map(([n,r])=>[e[n]??n,r]))}var Kh={chart:"chartOptions",grid:"containerOptions",cluster:"clusterOptions",title:"titleOptions",clusterTitle:"clusterTitleOptions",clusterFooter:"footerOptions",clusterLabel:"clusterLabelOptions",sequence:"sequenceOptions",genes:"geneOptions",transcript:"transcriptOptions",labels:"labelsOptions",coordinates:"coordinatesOptions",scale:"scaleOptions",scaleBar:"scaleBarOptions",legend:"legendOptions",links:"linkOptions",tooltip:"tooltipOptions",trackMouse:"trackMouseOptions",toolbar:"toolbarOptions"},hb={text:"textAnnotationOptions",line:"lineAnnotationOptions",arrow:"arrowAnnotationOptions",textMarker:"textMarkerAnnotationOptions",symbol:"symbolAnnotationOptions",rectangle:"rectangleAnnotationOptions",promoter:"promoterAnnotationOptions",terminator:"terminatorAnnotationOptions",arc:"curveAnnotationOptions"},tc=qh.themes,Sa=qh.palettes,$E=t=>t.replace(/_([a-z])/g,(e,n)=>n.toUpperCase());function ec(t){return Ht(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[$E(e),n])):t}function zE(t){let e={...t};for(let n of Object.keys(e))n==="annotations"?Ht(e[n])&&(e[n]=Object.fromEntries(Object.entries(e[n]).map(([r,i])=>[r,ec(i)]))):n in Kh&&(e[n]=ec(e[n]));return e}function Jh(t,e){let n={...t};for(let[r,i]of Object.entries(e||{}))i==null?delete n[r]:Ht(n[r])&&Ht(i)?n[r]=Jh(n[r],i):n[r]=i;return n}function db(t,e){let n=typeof e=="string"?{base:e}:ge(e),r=n.base;delete n.base;let i;if(r==null)i=t.x.theme||{};else{if(!(r in tc))throw new Error(`name must be one of: ${Object.keys(tc).map(a=>`"${a}"`).join(", ")}`);i=zE(ge(tc[r]))}for(let a of Object.keys(n))a in Zh&&(n[a]=Jl(n[a],Zh[a]));let o=n.pattern===!1;o&&delete n.pattern,t.x.theme=Jh(i,n),o&&delete t.x.theme.pattern}function Qh(t){if(!Ht(t)&&!Array.isArray(t))return t;if(Array.isArray(t))return t.map(Qh).filter(n=>!((Ht(n)||Array.isArray(n))&&!Object.keys(n).length));let e={};for(let[n,r]of Object.entries(t)){let i=Qh(r);(Ht(i)||Array.isArray(i))&&Object.keys(i).length===0||(e[n]=i)}return e}function NE(t){let e=t.fontFamily!=null?{fontFamily:t.fontFamily}:{},n={...e,...t.textColor!=null?{fill:t.textColor}:{}},r={...e,...t.textColor!=null?{color:t.textColor}:{}},i=t.lineColor!=null?{stroke:t.lineColor}:{},o=t.palette??null;o!==null&&!(typeof o=="string"&&(o.startsWith("scheme")||o in Sa))&&(o=Array.isArray(o)?o:[o]);let a=o!==null?{colorScheme:o}:{},s=t.pattern!=null?{pattern:Gh(t.pattern)}:{},c=t.background!=null?{backgroundColor:t.background}:{};return Qh({chart:{style:c},title:{titleFont:n,subtitleFont:n},clusterTitle:{titleFont:n,subtitleFont:n},clusterFooter:{titleFont:n,subtitleFont:n},clusterLabel:{...n,subtitleFont:n},sequence:{sequenceStyle:i,markerStyle:i},genes:{...a,...s},transcript:{...a,...s,labelOptions:r,styleUTRs:t.background!=null?{fill:t.background}:{}},labels:{...n,leaderLine:i},coordinates:{textStyle:n,tickStyle:i},scale:{textStyle:n,tickStyle:i,lineStyle:i},scaleBar:{labelStyle:n,scaleBarLineStyle:i,scaleBarTickStyle:i},legend:{legendOptions:{...a,...s},legendTextOptions:n},links:{labelStyle:n,colorBarOptions:{labelOptions:n,titleOptions:n}},tooltip:r,trackMouse:r,toolbar:e,annotations:{text:{style:n},textMarker:{textStyle:n},arc:{textStyle:n}}})}function pb(t){if(!t||Object.keys(t).length===0)return;let e={};for(let i of Object.keys(t))i in Kh&&(e[i]=ec(t[i]));t.annotations!=null&&(e.annotations=Object.fromEntries(Object.entries(t.annotations).map(([i,o])=>[i,ec(o)])));let n=Jh(NE(t),e),r={};for(let[i,o]of Object.entries(Kh))i in n&&(r[o]=n[i]);for(let i of Object.keys(n.annotations||{}))i in hb&&(r[hb[i]]=n.annotations[i]);return t.textScale!=null&&(r.textScale=t.textScale),r}var RE=["translation","sequence"];function nc(t,e=[]){if(t instanceof Ke)return e;if(t instanceof Map)for(let n of t.values())nc(n,e);else if(Array.isArray(t))for(let n of t)nc(n,e);else if(t!==null&&typeof t=="object")for(let n of Object.values(t))nc(n,e);else typeof t=="string"&&e.push(t);return e}function PE(t){if(!t.data)return;let e={...t,data:void 0,series:new Map};for(let[o,a]of t.series)e.series.set(o,{...a,data:void 0});let n=nc(e),r=t.data.names,i=RE.filter(o=>r.includes(o)&&!n.some(a=>a.includes(o)));t.dataColumns=r.filter(o=>!i.includes(o)),delete t.data;for(let o of t.series.values())o.data instanceof Ke&&(o.data=o.data.select(o.data.names.filter(a=>!i.includes(a))))}function td(t){if(t instanceof Map){for(let[e,n]of t)t.set(e,td(n));return t}if(t===null||typeof t!="object"||t instanceof Ke)return t;for(let[e,n]of Object.entries(t))e==="colorScheme"&&typeof n=="string"&&Sa[n]?t[e]=Sa[n].slice():n!==null&&typeof n=="object"&&(t[e]=td(n));return t}function gb(t){let e=t.x;e.size={width:t.width};let n=pb(e.theme);return n===void 0?delete e.theme:e.theme=n,td(e),PE(e),e}var IE=["title","subtitle","style","subtitleFont","titleFont","show","height","align","spacing"];function mb(t,e){let n=e.show??!0;if(!n||e.title==null&&e.subtitle==null)return;let r=Ce({title:e.title,subtitle:e.subtitle,subtitleFont:e.subtitleFont,titleFont:e.titleFont,style:e.style,height:e.height,show:n,align:e.align,spacing:e.spacing,...Ft(e,IE)});t.x.title=Qe(t.x.title,r)}var LE=["title","subtitle","subtitleFont","titleFont","show","height","clusters","align","spacing"];function yb(t,e){let n=e.show??!0,r=Ft(e,LE);Vt(t,e.clusters).forEach((i,o)=>{let a=t.x.series.get(i),s={title:gt(e.title,o)??null,subtitle:gt(e.subtitle,o)??null,subtitleFont:e.subtitleFont??{},titleFont:e.titleFont??{},show:gt(n,o)};ee(s,["align"],gt(e.align,o)),ee(s,["spacing"],gt(e.spacing,o)),En(s,r,o),ee(a,["grid","margin","top"],gt(e.height,o)),a.clusterTitle=s})}var qE=["title","show","width","clusters","position","align","wrapLabel","wrapOptions","subtitle","subtitleFont","spacing"];function bb(t,e){let n=e.show??!0,r=Ft(e,qE),i=Vt(t,e.clusters),o=e.title??null;t.x.cluster!==void 0&&o===null&&(o=i),i.forEach((a,s)=>{let c=t.x.series.get(a),l=xa({title:gt(o,s),show:gt(n,s),width:gt(e.width,s),wrapLabel:e.wrapLabel,wrapOptions:e.wrapOptions??{},position:gt(e.position,s),align:gt(e.align,s),subtitle:gt(e.subtitle,s),spacing:gt(e.spacing,s)});Jy(e.subtitleFont)||(l.subtitleFont=e.subtitleFont),c.clusterLabel=En(l,r,s)})}var YE=["title","subtitle","show","clusters","subtitleFont","titleFont","align","spacing"];function vb(t,e){let n=e.show??!0,r=Ft(e,YE);Vr(t,e.clusters,"footer",i=>{let o={title:gt(e.title,i)??null,subtitle:gt(e.subtitle,i)??null,show:gt(n,i),subtitleFont:e.subtitleFont??{},titleFont:e.titleFont??{}};return ee(o,["align"],gt(e.align,i)),ee(o,["spacing"],gt(e.spacing,i)),En(o,r,i)})}function UE(t,e){let n=10**e;return Math.round(t*n)/n}function ka(t,e){let n=t.x,r=[...n.series.keys()],i=Vt(t,e.clusters),o=t.height,a=e.clusters!=null,s=e.margin==null?null:{...e.margin},c=e.width??null,l=e.height??null;if(c!==null&&!a&&(t.width=Vn(t.width,c)),(e.direction??"column")==="row"&&(n.graphContainer.direction="row",i.length>0)){let u=`${pe(UE(100/i.length,3))}%`;for(let h of i){let f=n.series.get(h).container;f.style={...f.style||{},width:u},f.width=u}}if(s!==null&&!a){let u=s.top!=null?Vn(o,s.top):0,h=s.bottom!=null?Vn(o,s.bottom):0;if(typeof u!="number"||typeof h!="number")throw new Error("Use pixel values for the top and bottom margins when the chart height is a percentage.");if(delete s.top,delete s.bottom,n.legend.margin=Qe(n.legend.margin,s),n.title.margin=Qe(n.title.margin,s),Array.isArray(n.style)&&(n.style={}),u>0&&(n.style.paddingTop=`${pe(u)}px`),h>0&&(n.style.paddingBottom=`${pe(h)}px`),u>0||h>0){t.height="100%";for(let f of r){let d=n.series.get(f).container;if(typeof d.height=="string"&&/%$/.test(d.height))continue;let m=Number(Vn(d.height,d.height));d.height=m-(u+h)/r.length}}}i.forEach((u,h)=>{let f=n.series.get(u).container;if(s!==null&&(f.margin=Qe(f.margin,s)),c!==null&&a){let d=Vn(t.width,gt(c,h));f.style={...f.style||{},width:d},f.width=d}l!==null&&(f.height=a?Vn(o,gt(l,h)):Kl(l,r.length))})}function wb(t){if(!/^\s*[0-9]*\.?[0-9]+\s*bp\s*$/.test(t))throw new Error('scale_break_padding must be a percentage, e.g. 1, or base pairs, e.g. "500bp"');return Number(t.replace(/\s*bp\s*$/,""))}function HE(t,e=0,n=0){let r=t.get("start").slice(),i=t.get("end").slice();r.forEach((f,d)=>{f>i[d]&&([r[d],i[d]]=[i[d],f])});let o=Math.max(...i)-Math.min(...r)+1,a=o*e/100,s=_a(r.length,[f=>r[f]]);r=s.map(f=>r[f]),i=s.map(f=>i[f]);let c=[],l={start:r[0],end:i[0]};for(let f=1;f<r.length;f++)r[f]<=l.end?l.end=Math.max(l.end,i[f]):(c.push(l),l={start:r[f],end:i[f]});c.push(l);let u=[];for(let f=0;f<c.length-1;f++){let d=c[f].end+1,m=c[f+1].start-1;m-d+1>=a&&u.push({start:d,end:m})}let h;return typeof n=="string"?h=wb(n):h=(o-u.reduce((d,m)=>d+(m.end-m.start+1),0))*n/100,u=u.map(f=>({start:f.start+h,end:f.end-h})),u.filter(f=>f.start<f.end)}function WE(t,e,n){if(Ht(t)){if(!("start"in t)||!("end"in t))throw new Error("A data frame of breaks needs a start and an end column");let r=[t.start].flat(),i=[t.end].flat(),o=r.map((a,s)=>s);if("cluster"in t){let a=[t.cluster].flat();o=o.filter(s=>pe(a[s])===e)}t=o.map(a=>({start:r[a],end:i[a]}))}return n?(t||[]).map(r=>({...r,start:r.start-n,end:r.end-n})):t}function ed(t,e){if(!e)return t;let n=i=>typeof i=="number"?i-e:i,r=i=>Array.isArray(i)?i.map(n):n(i);for(let i of["x","x1","x2"])i in t&&(t[i]=r(t[i]));if(t.position!==null&&t.position!==void 0)if(t.type==="rectangle"){let i=Array.isArray(t.position)?t.position:[t.position];t.position=i.map(o=>Array.isArray(o)?o.map(a=>Array.isArray(a)?[n(a[0]),...a.slice(1)]:n(a)):[n(o)])}else t.position=r(t.position);return t}var jE=["clusters","start","end","padding","hidden","breaks","tickValues","reverse","axisPosition","axisType","y","autoBreaks","autoBreakThreshold","breakPadding","ticksCount","ticksFormat","tickStyle","textStyle","lineStyle"];function xb(t,e){let n=t.x,r=e.axisType??"position",i=e.hidden??!1,o=e.autoBreaks??!1,a=e.autoBreakThreshold??20,s=e.breakPadding??1,c=e.ticksFormat??null;typeof s=="string"&&wb(s);let l=null,u=null,h=Vt(t,e.clusters);if(r==="range"){c===null&&(c=".2s");for(let d of h){let m=n.series.get(d),p=m.data,g=Math.min(...p.get("start"),...p.get("end"));p.set("start",p.get("start").map(_=>_-g+1)),p.set("end",p.get("end").map(_=>_-g+1));let y=g-1;m.sequence=Vh(m.sequence,y),m.annotations.length>0&&(m.annotations=m.annotations.map(_=>ed(_,y))),m.positionShift=m.positionShift==null?y:m.positionShift+y;let w=n.data.get("rowID"),b=n.data.get("start"),v=n.data.get("end");p.get("rowID").forEach((_,S)=>{let k=w.indexOf(_);b[k]=p.get("start")[S],v[k]=p.get("end")[S]})}l=1,u=Math.max(...h.flatMap(d=>{let m=n.series.get(d).data;return[...m.get("start"),...m.get("end")]}))}let f=Ft(e,jE);h.forEach((d,m)=>{let p=n.series.get(d),g=r==="range"&&!i&&m<h.length-1?!0:i,y=o?HE(p.data,a,s):WE(e.breaks??[],d,p.positionShift),w={start:gt(e.start,m)??null,end:gt(e.end,m)??null,xMin:l,xMax:u,padding:e.padding??null,hidden:g,breaks:y,tickValues:e.tickValues??null,reverse:gt(e.reverse??!1,m),axisPosition:e.axisPosition??null,axisType:r,scale_breaks:o,scale_break_threshold:a,scale_break_padding:s,ticksCount:e.ticksCount??null,ticksFormat:c,y:e.y??null,tickStyle:e.tickStyle??{},textStyle:e.textStyle??{},lineStyle:e.lineStyle??{}};p.scale=En(w,f,m)}),kb(t)}var XE=["show","clusters","lineStyle","tickStyle","labelStyle"];function _b(t,e){let n=e.show??!0,r=Ft(e,XE);Vr(t,e.clusters,"scaleBar",i=>En({show:gt(n,i),scaleBarLineStyle:e.lineStyle??{},scaleBarTickStyle:e.tickStyle??{},labelStyle:e.labelStyle??{}},r,i))}function GE(t,e,n,r){return t==="left"&&!r||t==="right"&&r?e:t==="right"&&!r||t==="left"&&r?n:t==="center"?(e+n)/2:e}function Sb(t,e){let n=t.x;if(n.cluster===void 0){t.warnings.push("Could not align selected gene. Please define cluster in the GC_chart function.");return}if(!n.data.has(e.idColumn)){t.warnings.push(`Column ${e.idColumn} not found in the data.`);return}let r=pe(e.id);if(!n.data.get(e.idColumn).some(i=>pe(i)===r)){t.warnings.push(`ID ${e.id} not found in the ${e.idColumn} column.`);return}t.align={idColumn:e.idColumn,id:e.id,align:e.align??"left"},n.align={id_column:e.idColumn,id:e.id,align:t.align.align},kb(t)}function kb(t){let e=t.align;if(!e)return;let n=t.x,r=n.data,i=n.cluster,o=r.get(i),a=[...new Set(o)],s=new Set(a.filter(w=>n.series.get(w)?.scale?.reverse===!0)),c=r.get("start").map((w,b)=>Math.min(w,r.get("end")[b])),l=r.get("start").map((w,b)=>Math.max(w,r.get("end")[b])),u=r.get(e.idColumn),h=pe(e.id),f=[];for(let w=0;w<r.nrow;w++)u[w]!==null&&pe(u[w])===h&&f.push(w);if(!f.length){t.warnings.push(`Selected gene coud not be aligned. Gene ${e.id} not found in the ${e.idColumn} column.`);return}if(new Set(f.map(w=>o[w])).size<f.length){t.warnings.push(`The selected gene ${e.id} appears multiple times in some clusters. Please make sure to use a unique gene id.`);return}let d=new Map;o.forEach((w,b)=>{let v=d.get(w)||{start:1/0,end:-1/0};d.set(w,{start:Math.min(v.start,c[b]),end:Math.max(v.end,l[b])})});let m=(w,b,v)=>(n.series.get(v)?.scale?.breaks||[]).reduce((_,S)=>_+Math.max(0,Math.min(S.end,b)-Math.max(S.start,w)),0),p=f.map(w=>{let b=o[w],v=s.has(b),_=GE(e.align,c[w],l[w],v),{start:S,end:k}=d.get(b),C=m(S,_,b),F=m(_,k,b),A=_-S-C,E=k-_-F;return{cl:b,isReversed:v,position:_,gapsBelow:C,gapsAbove:F,left:v?E:A,right:v?A:E}}),g=Math.max(...p.map(w=>w.left)),y=Math.max(...p.map(w=>w.right));for(let w of p){let b=n.series.get(w.cl);b.scale.start=w.position-(w.isReversed?y:g)-w.gapsBelow,b.scale.end=w.position+(w.isReversed?g:y)+w.gapsAbove}}var VE=["identity","similarity","none"],ZE=["data","group","value1","value2","clusters","curve","measure","show","label","labelPosition","normalColor","invertedColor","lowColor","vmin","vmax","useGroupColors","colorBar","colorBarOptions","linkWidth","linkStyle","labelStyle"],KE={position:["bottomright","bottomleft","topright","topleft","legend"],orientation:["vertical","horizontal"],labels:["inline","below"],legendSide:["left","right"]};function rc(t,e,n){t.has(e)&&(t.columns=new Map([...t.columns].map(([r,i])=>[r===e?n:r,i])))}function Ab(t,e){let n=e.measure??"identity",r=e.labelPosition??"gene",i=e.colorBarOptions??{};if(!VE.includes(n))throw new Error("Invalid measure specified. Choose 'identity', 'similarity', or 'none'.");if(!["gene","link"].includes(r))throw new Error(`'label_position' must be one of "gene", "link".`);for(let[y,w]of Object.entries(KE)){let b=i[y];if(b!=null&&!w.includes(b))throw new Error(`'colorBarOptions$${y}' must be one of ${w.map(v=>`"${v}"`).join(", ")}.`)}let o=e.vmin??null,a=e.vmax??null;if((o!==null||a!==null)&&(o??0)>=(a??100))throw new Error("'vmin' must be smaller than 'vmax'.");let s=e.group??null,c=e.label??!0;s===null&&r==="gene"&&(c=!1);let l=Ke.from(e.data??[]);if(l.nrow===0)return;l.has("identity2")&&rc(l,"identity2","identity"),l.has("similarity2")&&rc(l,"similarity2","similarity"),rc(l,`${s??""}1`,"group1"),rc(l,`${s??""}2`,"group2");let u=["cluster1","group1","start1","end1","cluster2","group2","start2","end2"];n!=="none"&&u.push(n);let h=e.useGroupColors??!1,f=e.colorBar;if(h){let y=t.x.group!==void 0?t.x.group:s,w=l.get(`${y??""}2`);w&&l.set("groupColor",w.slice()),u.push("groupColor"),f=!1}let d=l.select(u.filter(y=>l.has(y))),m=d.get("start2")||[];d=d.rows(_a(d.nrow,[y=>m[y]]));let p=Ce({group:s,curve:e.curve,measure:n,showLinks:e.show??!0,label:c,labelPosition:r,normalColor:e.normalColor,invertedColor:e.invertedColor,lowColor:e.lowColor,vmin:o,vmax:a,useGroupColors:h,value1:e.value1,value2:e.value2,colorBar:f,colorBarOptions:i,linkWidth:e.linkWidth,linkStyle:e.linkStyle,labelStyle:e.labelStyle,...Ft(e,ZE)}),g=t.x.links||[];d.set("linkID",Array.from({length:d.nrow},(y,w)=>`${g.length}-${w+1}`)),t.x.links=[...g,{data:d,options:p}]}var QE=["transcript","type","strand","group","selection","show","colorScheme","customColors","styleExons","styleIntrons","styleUTRs","itemStyleExons","itemStyleIntrons","itemStyleUTRs","groupStyleExons","groupStyleIntrons","groupStyleUTRs","styleBy","labelOptions"];function JE(t,e){return JSON.stringify(t)===JSON.stringify(e)}function tM(t,e){for(let a of["title","legend","theme","events","toolbar","zoom"])e.x[a]===void 0?delete t.x[a]:t.x[a]=e.x[a];t.width=e.width;let n=[...e.x.series.values()].map(a=>a.container.margin),i=n.length>0&&n.every(a=>JE(a,n[0]))?n[0]:{},o=Array.isArray(e.x.style)?{}:e.x.style||{};o.paddingTop!=null&&(i={...i||{},top:o.paddingTop}),o.paddingBottom!=null&&(i={...i||{},bottom:o.paddingBottom}),i&&Object.keys(i).length>0&&ka(t,{margin:i}),e.x.graphContainer?.direction==="row"&&ka(t,{direction:"row"})}function Eb(t,e){if(!t.x.transcript_called){let o=t.x.params,a={...t,x:t.x},s={start:o.start,end:o.end,cluster:e.transcript??"transcript"};o.group!==void 0&&(s.group=o.group),e.strand!=null&&(s.strand=e.strand);let c=Ql({...t.spec,fields:s,width:o.width,height:o.height,style:o.style});c.x.saveButton=o.save_button,c.x.params.save_button=o.save_button,t.x=c.x,t.width=c.width,t.height=c.height,tM(t,a);let l=[...new Set(t.x.data.get("transcript").map(String))];for(let u of l){let h=t.x.series.get(u);h.genes={group:null,show:!1},h.sequence={show:!1},h.transcript={group:null,show:!0}}}let n=e.group??null,r=e.show??!0;if(n===null&&t.x.group!==void 0&&(n=t.x.group),n!==null&&![n].flat().every(o=>t.x.data.has(o)))throw new Error("group column not found in data");let i=Ft(e,QE);Vt(t,e.selection).forEach((o,a)=>{let s=t.x.series.get(o),c=Ce({group:gt(n,a),show:gt(r,a),colorScheme:e.colorScheme,customColors:e.customColors,styleExons:e.styleExons,styleIntrons:e.styleIntrons,styleUTRs:e.styleUTRs,itemStyleExons:e.itemStyleExons,itemStyleIntrons:e.itemStyleIntrons,itemStyleUTRs:e.itemStyleUTRs,groupStyleExons:e.groupStyleExons,groupStyleIntrons:e.groupStyleIntrons,groupStyleUTRs:e.groupStyleUTRs,styleBy:e.styleBy,labelOptions:e.labelOptions,...i});s.transcript=jh(c,s.transcript)}),e.selection==null&&Xh(t,e.colorScheme,e.customColors),t.x.transcript_called=!0}var Mb=["text","textMarker","line","arrow","symbol","rectangle","promoter","terminator","arc"];function Tb(t,e){let n=e.type??"text";if(typeof n!="string"||!Mb.includes(n))throw new Error(`'type' must be one of ${Mb.map(i=>`"${i}"`).join(", ")}.`);let r=Ft(e,["type","clusters"]);for(let i of Vt(t,e.clusters)){let o=t.x.series.get(i),a=ed(Ce({type:n,...ge(r)}),o.positionShift);o.annotations=[...o.annotations||[],a]}}var eM=["genes","labels","coordinates"],nM=["legend","title"],rM=["scaleBar","scale"],Cb=["genes","labels","coordinates","clusterTitle","clusterFooter","clusterLabel","legend","title","scaleBar","scale"];function Fb(t,e,n,r){let i=Array.isArray(t)?t:[],o=i.find(e)||{},a=i.filter(c=>!e(c)),s=Gr(o,r);for(let[c,l]of Object.entries(n))s[c]=l;return[...a,s]}function Ob(t,e){let n=e.component??"genes";if(!Cb.includes(n))throw new Error(`'component' must be one of ${Cb.join(", ")}`);let{rowID:r=null,cluster:i=null,part:o=null,end:a=null,group:s=null}=e,c=ge(Ft(e,["component","rowID","cluster","part","end","group"])),l=eM.includes(n),u=t.x;if(nM.includes(n)){if(n==="legend"){let y=u.legend?.group;if(s===null||y==null||!u.data.get(y)?.some(w=>String(w)===String(s)))throw new Error("'group' must identify one group in the legend.")}let p=n==="legend"?{group:s,part:o}:{part:o},g=y=>y.part===o&&(n==="title"||y.group===s);u[n].itemStyle=Fb(u[n].itemStyle,g,p,c);return}let h=n==="clusterFooter"?"footer":n,f,d,m;if(l){if(typeof r!="number"||!u.data.get("rowID").includes(r))throw new Error("'row_id' must identify one row in the chart's data.");f=a===null?{rowID:r}:{rowID:r,end:a},d=p=>Number(p.rowID)===Number(r)&&(p.end??null)===a,m=[...u.series.keys()]}else if(f=rM.includes(n)?{}:{part:o},d=p=>(p.part??null)===o,m=Vt(t,i),!m.length)throw new Error("'cluster' must be the name or number of a cluster of the chart.");for(let p of m){let g=u.series.get(p);l&&!g.data.get("rowID").includes(r)||((!g[h]||Array.isArray(g[h]))&&(g[h]={}),g[h].itemStyle=Fb(g[h].itemStyle,d,f,c))}}function Bb(t,e){let n=e.show??!0,r=Ft(e,["show","clusters"]);Vt(t,e.clusters).forEach((i,o)=>{t.x.series.get(i).trackMouse={show:gt(n,o),...ge(r)}})}function Db(t,e){let n={click:e.click??!0,highlight:e.highlight??!1};e.dblclick&&(n.dblclick=!0),e.select&&(n.select=!0),e.drag&&(n.drag=!0),e.legendClick===!1&&(n.legendClick=!1),e.zoom&&(n.zoom=!0),e.rendered&&(n.rendered=!0),e.renderId!=null&&(n.renderId=e.renderId),t.x.events=n}var iM=["show","position","buttons","size","color","hoverColor","tooltipBackground","tooltipColor","tooltipBorder","tooltipRadius","tooltipShadow","fontFamily","icons"];function $b(t,e){let n=xa(Object.fromEntries(iM.map(r=>[r,ge(e[r])])));n.buttons!==void 0&&!Array.isArray(n.buttons)&&(n.buttons=[n.buttons]),t.x.toolbar=Gr(t.x.toolbar||{},n)}var oM=["show","range","mode","min","update","height","overview","color","style","windowStyle","handleStyle"];function zb(t,e){let n=xa(Object.fromEntries(oM.map(i=>[i,ge(e[i])])));n.show===void 0&&(n.show=!0);let r={...t.x.zoom||{}};n.mode!==void 0&&n.mode!==r.mode&&(delete r.range,delete r.min),n.range!==void 0&&(n.range=[n.range].flat().map(Number).sort((i,o)=>i-o)),t.x.zoom=Gr(r,n)}var aM={cluster:eb,labels:rb,genes:ib,color:ob,pattern:ab,legend:sb,sequence:lb,coordinates:cb,tooltip:ub,title:mb,clusterTitle:yb,clusterLabel:bb,clusterFooter:vb,grid:ka,scale:xb,scaleBar:_b,align:Sb,links:Ab,transcript:Eb,annotation:Tb,elementStyle:Ob,theme:db,zoom:zb,toolbar:$b,events:Db,trackMouse:Bb},Nb=1,sM=new Set(["version","data","fields","width","height","style"]);function lM(t){return t==null?[]:Array.isArray(t)?t:[t]}function oc(t){if(!t||typeof t!="object")throw new Error("compile() needs a spec object");typeof t.version=="number"&&t.version>Nb&&console.warn(`geneviewer: spec version ${t.version} is newer than this library's (${Nb}); drawing what it knows`),t=ge(t);let e=Ql(t);for(let[n,r]of Object.entries(t)){if(sM.has(n))continue;let i=aM[n];if(i)for(let o of lM(r))i(e,Jl(o,fb[n]))}return ic(gb(e))}function ic(t){if(t instanceof Ke)return t.toJSON();if(t instanceof Map){let e={};for(let[n,r]of t)e[n]=ic(r);return e}if(Array.isArray(t))return t.map(ic);if(t!==null&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&(e[n]=ic(r));return e}return t}var Rb=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);function nd(t,e){let n={...t};for(let[r,i]of Object.entries(e||{}))i!==void 0&&(n[r]=r!=="data"&&Rb(n[r])&&Rb(i)?nd(n[r],i):structuredClone(i));return n}var Pb=`.geneviewer-container {
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-direction: column; /* or row, depending on the desired layout */
|
|
30
30
|
align-content: stretch;
|
|
@@ -412,6 +412,6 @@ var v2=Object.defineProperty;var w2=(t,e)=>{for(var n in e)v2(t,n,{get:e[n],enum
|
|
|
412
412
|
outline-offset: 1px;
|
|
413
413
|
}
|
|
414
414
|
`;function Ib(t){if(!t||!t.head||t.querySelector("style[data-geneviewer]"))return;let e=t.createElement("style");e.setAttribute("data-geneviewer",""),e.textContent=Pb,t.head.insertBefore(e,t.head.firstChild)}var uM={download:{width:512,height:512,path:"M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"},"rotate-left":{width:512,height:512,path:"M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"},"rotate-right":{width:512,height:512,path:"M463.5 224H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5z"},house:{width:576,height:512,path:"M575.8 255.5c0 18-15 32.1-32 32.1h-32l.7 160.2c0 2.7-.2 5.4-.5 8.1V472c0 22.1-17.9 40-40 40H456c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1H416 392c-22.1 0-40-17.9-40-40V448 384c0-17.7-14.3-32-32-32H256c-17.7 0-32 14.3-32 32v64 24c0 22.1-17.9 40-40 40H160 128.1c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2H104c-22.1 0-40-17.9-40-40V360c0-.9 0-1.9 .1-2.8V287.6H32c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"},"magnifying-glass-minus":{width:512,height:512,path:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM136 184c-13.3 0-24 10.7-24 24s10.7 24 24 24H280c13.3 0 24-10.7 24-24s-10.7-24-24-24H136z"}};function ac(t,e){let n=uM[e],r=t.append("svg").attr("class","geneviewer-icon-svg").attr("viewBox",`0 0 ${n.width} ${n.height}`).attr("aria-hidden","true").attr("focusable","false").style("width",`${n.width/n.height}em`);return r.append("path").attr("d",n.path),r}var fM=["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","stroke-linejoin","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","visibility"],hM={opacity:"1"};function Aa(t,e=null){let n="http://www.w3.org/2000/svg",r=t.getBoundingClientRect(),i=Math.ceil(r.width),o=t.querySelector(".geneviewer-zoom-row"),a=null;if(o){let p=o.getBoundingClientRect(),g=getComputedStyle(o),y=p.top-r.top-(parseFloat(g.marginTop)||0),w=p.bottom-r.top+(parseFloat(g.marginBottom)||0);w>y&&(a={top:y,bottom:w,height:w-y})}let s=p=>a&&p>=a.bottom-.5?a.height:0,c=Math.ceil(r.height-(a?a.height:0)),l=document.createElementNS(n,"svg");l.setAttribute("xmlns",n),l.setAttribute("width",i),l.setAttribute("height",c),l.setAttribute("viewBox",`0 0 ${i} ${c}`);let u=(p,g,y,w,b,v)=>{if(!v||v==="transparent"||v==="rgba(0, 0, 0, 0)")return;let _=document.createElementNS(n,"rect");_.setAttribute("x",g),_.setAttribute("y",y),_.setAttribute("width",w),_.setAttribute("height",b),_.setAttribute("fill",v),_.setAttribute("shape-rendering","crispEdges"),p.appendChild(_)};u(l,0,0,i,c,getComputedStyle(t).backgroundColor);let h=p=>p.replace(/url\((["']?)[^#)]*#([^)"']+)\1\)/g,"url(#$2)"),f=(p,g,y)=>{let w=getComputedStyle(p);return fM.forEach(b=>{let v=w.getPropertyValue(b);v&&(!y||y.getPropertyValue(b)!==v)&&g.style.setProperty(b,h(v))}),Object.entries(hM).forEach(([b,v])=>{let _=w.getPropertyValue(b);_&&_!==v&&g.style.setProperty(b,_)}),w},d=p=>parseInt(getComputedStyle(p).zIndex,10)||0;return Array.from(t.querySelectorAll("svg")).filter(p=>!p.parentElement.closest("svg")&&!(e&&e.contains(p))&&!p.closest(".geneviewer-zoom-slider")).map((p,g)=>({svg:p,order:g,z:d(p)})).sort((p,g)=>p.z-g.z||p.order-g.order).map(p=>p.svg).forEach(p=>{let g=getComputedStyle(p);if(g.display==="none"||g.visibility==="hidden")return;let y=p.getBoundingClientRect();if(y.width===0||y.height===0)return;let w=y.left-r.left,b=y.top-r.top,v=b-s(b);u(l,w,v,y.width,y.height,g.backgroundColor);let _=p.cloneNode(!0);_.removeAttribute("style"),_.removeAttribute("class"),_.setAttribute("x",w),_.setAttribute("y",v),_.setAttribute("width",y.width),_.setAttribute("height",y.height);let S=p.querySelectorAll("*"),k=_.querySelectorAll("*"),C=new Map([[p,f(p,_,null)]]);S.forEach((F,A)=>{let E=k[A];if(getComputedStyle(F).display==="none"&&!F.closest("defs")){E.setAttribute("display","none");return}F.closest("defs")||(E.removeAttribute("class"),C.set(F,f(F,E,C.get(F.parentNode))))}),a&&b<a.bottom-.5&&Array.from(p.children).forEach((F,A)=>{if(F.tagName.toLowerCase()==="defs")return;let E=F.getBoundingClientRect().top-r.top,D=s(E);if(!D)return;let $=_.children[A];$.setAttribute("transform",`translate(0, ${-D}) ${$.getAttribute("transform")||""}`.trim())}),_.querySelectorAll("[display='none']").forEach(F=>F.remove()),l.appendChild(_)}),`<?xml version="1.0" encoding="UTF-8"?>
|
|
415
|
-
`+new XMLSerializer().serializeToString(l)}function sc(t,e=null){let n=new Blob([Aa(t,e)],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(n);return new Promise((i,o)=>{let a=new Image,s=c=>{URL.revokeObjectURL(r),o(c)};a.onerror=()=>s(new Error("Could not render the chart SVG as PNG.")),a.onload=()=>{try{let c=window.devicePixelRatio||1,l=document.createElement("canvas");l.width=Math.ceil(a.naturalWidth*c),l.height=Math.ceil(a.naturalHeight*c),l.getContext("2d").drawImage(a,0,0,l.width,l.height),l.toBlob(u=>{URL.revokeObjectURL(r),u?i(u):o(new Error("Could not encode the chart as PNG."))},"image/png")}catch(c){s(c)}},a.src=r})}function rd(t,e){let n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),4e4)}function Lb(t,e,n,r=null,i=rd){var o=R.select(n).append("div").attr("id",`saveMenu-${t}`).style("position","relative").style("z-index","1000").style("display","block"),a=o.append(r?"i":"span").attr("class",(r?r+" ":"")+"geneviewer-save-icon").attr("id",`saveIcon-${t}`).attr("tabindex","0").attr("role","button").attr("aria-label","Save chart").attr("aria-haspopup","menu").style("text-align","right").style("cursor","pointer");r||ac(a,"download");var s=o.append("div").attr("id",`saveIconTooltip-${t}`).attr("class","save-tooltip").attr("role","menu").style("display","none").style("font-size","12px").style("overflow","hidden").style("white-space","nowrap"),c=function(){s.style("display","none")},l=[{label:"Save as SVG",save:function(){var u=Aa(e,n);i(new Blob([u],{type:"image/svg+xml;charset=utf-8"}),"graph.svg")}},{label:"Save as PNG",save:function(){return sc(e,n).then(u=>i(u,"graph.png"))}}];l.forEach(function(u){s.append("div").attr("class","save-option").attr("tabindex","0").attr("role","menuitem").text(u.label).style("padding","5px 8px").style("cursor","pointer").on("click",function(){c(),u.save()}).on("keydown",function(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.click())})}),o.on("focusin",function(){s.style("display","block")}).on("focusout",function(u){o.node().contains(u.relatedTarget)||c()}),R.select(e).on("mouseleave",c),o.on("mouseenter",function(){s.style("display","block")}).on("mouseleave",c)}var dM="0.3.
|
|
415
|
+
`+new XMLSerializer().serializeToString(l)}function sc(t,e=null){let n=new Blob([Aa(t,e)],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(n);return new Promise((i,o)=>{let a=new Image,s=c=>{URL.revokeObjectURL(r),o(c)};a.onerror=()=>s(new Error("Could not render the chart SVG as PNG.")),a.onload=()=>{try{let c=window.devicePixelRatio||1,l=document.createElement("canvas");l.width=Math.ceil(a.naturalWidth*c),l.height=Math.ceil(a.naturalHeight*c),l.getContext("2d").drawImage(a,0,0,l.width,l.height),l.toBlob(u=>{URL.revokeObjectURL(r),u?i(u):o(new Error("Could not encode the chart as PNG."))},"image/png")}catch(c){s(c)}},a.src=r})}function rd(t,e){let n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),4e4)}function Lb(t,e,n,r=null,i=rd){var o=R.select(n).append("div").attr("id",`saveMenu-${t}`).style("position","relative").style("z-index","1000").style("display","block"),a=o.append(r?"i":"span").attr("class",(r?r+" ":"")+"geneviewer-save-icon").attr("id",`saveIcon-${t}`).attr("tabindex","0").attr("role","button").attr("aria-label","Save chart").attr("aria-haspopup","menu").style("text-align","right").style("cursor","pointer");r||ac(a,"download");var s=o.append("div").attr("id",`saveIconTooltip-${t}`).attr("class","save-tooltip").attr("role","menu").style("display","none").style("font-size","12px").style("overflow","hidden").style("white-space","nowrap"),c=function(){s.style("display","none")},l=[{label:"Save as SVG",save:function(){var u=Aa(e,n);i(new Blob([u],{type:"image/svg+xml;charset=utf-8"}),"graph.svg")}},{label:"Save as PNG",save:function(){return sc(e,n).then(u=>i(u,"graph.png"))}}];l.forEach(function(u){s.append("div").attr("class","save-option").attr("tabindex","0").attr("role","menuitem").text(u.label).style("padding","5px 8px").style("cursor","pointer").on("click",function(){c(),u.save()}).on("keydown",function(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.click())})}),o.on("focusin",function(){s.style("display","block")}).on("focusout",function(u){o.node().contains(u.relatedTarget)||c()}),R.select(e).on("mouseleave",c),o.on("mouseenter",function(){s.style("display","block")}).on("mouseleave",c)}var dM="0.3.2",pM=0,gM=0,Ca=null,mM=function(t){return!t||t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||!!(t.closest&&t.closest('[role="combobox"], [role="listbox"], [role="menu"], [role="dialog"], [role="slider"], [role="tablist"], [role="radiogroup"], [role="spinbutton"]'))};document.addEventListener("keydown",function(t){!Ca||t.defaultPrevented||t.altKey||mM(t.target)||Ca(t)});var qb=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),Ub=["scale","scaleBar"],Ea=function(t){return Ub.includes(t)},Yb=Ub.map(function(t){return'[data-component="'+t+'"]'}).join(", "),yM=["undo","redo","reset","zoom","save"],bM=["click","dblclick","select","selection","drag","dragmove","moves","zoom","rendered"],Ma=function(t,e){return!!t&&!!e&&Math.abs(t.moveX-e.moveX)<.01&&Math.abs(t.moveY-e.moveY)<.01},id=function(t){return Object.keys(t).forEach(function(e){window.addEventListener(e,t[e],e==="pointermove"?{passive:!1}:void 0)}),function(){Object.keys(t).forEach(function(e){window.removeEventListener(e,t[e])})}},vM=function(){var t=[],e=[],n=function(r){return r.map(function(i){return i.key}).join(`
|
|
416
416
|
`)};return{canUndo:function(){return t.length>0},canRedo:function(){return e.length>0},clear:function(){t=[],e=[]},record:function(r,i){if(r=r.filter(function(s){return s.key!==null&&!Ma(s.before,s.after)}),!!r.length){var o=t[t.length-1],a=performance.now();i&&o&&o.merge&&n(o.items)===n(r)&&a-o.time<1e3?(o.items.forEach(function(s,c){s.after=r[c].after}),o.time=a):(t.push({items:r,merge:i,time:a}),t.length>100&&t.shift()),e=[]}},next:function(r){var i=r?t:e;return i[i.length-1]},take:function(r){var i=(r?t:e).pop();return i.merge=!1,(r?e:t).push(i),i.items.map(function(o){return{key:o.key,position:r?o.before:o.after}})},expected:function(){var r={};return e.forEach(function(i){i.items.forEach(function(o){r[o.key]=o.before})}),t.forEach(function(i){i.items.forEach(function(o){r[o.key]=o.after})}),r}}};function wM(t,e,n){if(typeof t=="string"){var r=document.querySelector(t);if(!r)throw new Error("No element matches "+t);t=r}var i=t;n=n||{},n.injectStyles!==!1&&Ib(i.ownerDocument);var o=!i.classList.contains("geneviewer");i.classList.add("geneviewer");var a,s,c,l,u,h,f,d,m,p,g={},y={},w=i.style.width,b=i.style.flex,v=!1,_=!1,S=i.id?i.id.replace(/[^A-Za-z0-9_-]/g,"_"):"geneviewer-chart-"+ ++gM,k={},C=!1,F=[],A=["genes","transcript","labels","links","legend","coordinates"],E=["genes","labels","coordinates","clusterTitle","clusterFooter","clusterLabel","legend","title","scaleBar","scale"],D=".gene, text.label, text.coordinate, [data-part], "+Yb,$=E.filter(function(x){return!["genes","coordinates"].includes(x)}),M="text.label, [data-part], "+Yb,T=[],B=null,N=function(x){T=x,B=x[x.length-1]??null},L=null,q=!0,U=function(x){var O=x.target;if(!O.classList||!O.classList.contains("geneviewer-svg-content")||typeof x.clientX!="number")return O;var z=document.elementsFromPoint(x.clientX,x.clientY).find(function(P){return P.closest&&P.closest('[data-component="links"]')&&i.contains(P)});return z||O},Z=function(x){var O=/^rgba?\((\d+), (\d+), (\d+)(?:, ([\d.]+))?\)$/.exec(x);return!O||O[4]!==void 0&&O[4]!=="1"?x:"#"+O.slice(1,4).map(function(z){return(+z).toString(16).padStart(2,"0")}).join("")},Q=function(x){var O=/^url\("?#([^")]+)"?\)$/.exec(x),z=O&&i.querySelector("#"+CSS.escape(O[1]));return!z||z.children.length!==1||z.firstElementChild.tagName!=="rect"?x:getComputedStyle(z.firstElementChild).fill},j=function(x,O){if(Ea(x))return Object.assign({moveX:0,moveY:0},O.__drawn__);O=O.closest(x==="genes"?".gene":x==="legend"?"[data-part]":"text")||O;var z=getComputedStyle(O),P={fill:Z(Q(z.fill)),opacity:+z.opacity};return x==="genes"||x==="legend"&&O.matches(".legend-marker")?Object.assign(P,{stroke:Z(z.stroke),strokeWidth:parseFloat(z.strokeWidth),strokeDasharray:z.strokeDasharray},O.__drawn__):(Object.assign(P,{text:O.__text__??O.textContent,fontSize:parseFloat(z.fontSize),fontWeight:z.fontWeight,fontStyle:z.fontStyle,fontFamily:z.fontFamily},O.__drawn__),x==="labels"&&["dx","dy"].forEach(function(I){var Y=O[I].baseVal;Y.numberOfItems&&(P[I]=Y.getItem(0).value)}),P)},H=function(x,O){var z=U(x),P=z.closest&&z.closest("[data-component]");if(!(!P||!i.contains(P))){for(var I=P.getAttribute("data-component"),Y=null,nt=z;A.includes(I)&&nt&&nt!==P.parentNode;nt=nt.parentNode)if(nt.__data__!==void 0){Y=nt.__data__;break}var wt=P.closest("[data-cluster]"),kt={component:I,cluster:wt?wt.getAttribute("data-cluster"):null,data:Y},Pt=z.closest("[data-part]");return Pt&&P.contains(Pt)&&(kt.part=Pt.getAttribute("data-part")),O&&W(kt)!==null&&(kt.style=j(I,Ea(I)?P:I==="legend"?Pt:nt)),kt}},W=function(x){return!x||!E.includes(x.component)?null:Ea(x.component)?[x.component,x.cluster].join("|"):x.component==="legend"?x.data!=null&&["label","marker"].includes(x.part)?JSON.stringify([x.component,x.data,x.part]):null:["genes","labels","coordinates"].includes(x.component)?!x.data||x.data.rowID==null?null:[x.component,x.cluster,x.data.rowID,x.data.end??""].join("|"):x.part?[x.component,x.cluster,x.part].join("|"):null},J=function(x){return JSON.stringify(x.map(W))},K=function(x,O){(k[x]||[]).slice().forEach(function(z){z({type:x,detail:O})}),i.dispatchEvent(new CustomEvent("geneviewer:"+x,{bubbles:!0,detail:O}))},ht=function(x,O){return W(x)!==null&&W(x)===W(O)},G=function(x){var O=W(x);return O!==null&&T.some(function(z){return W(z)===O})},tt=function(x){return x===null?null:structuredClone(x)},ot=function(){return T.map(tt)},X=function(){K("select",tt(B)),K("selection",ot())},vt=function(x){var O=JSON.stringify(T.map(function(Y){return Y.style})),z={};i.querySelectorAll(D).forEach(function(Y){var nt=H({target:Y}),wt=W(nt);if(wt!==null){var kt=G(nt);Y.classList.toggle("geneviewer-selected",kt),y.select===!0&&(Y.setAttribute("tabindex","0"),Y.setAttribute("role","button"),Y.setAttribute("aria-pressed",String(kt)),Y.setAttribute("aria-label",nt.component+": "+(nt.component==="legend"?String(nt.data)+" "+nt.part:nt.data?.name??Y.__text__??Y.textContent))),kt&&!z[wt]&&(z[wt]=H({target:Y},!0))}});var P=T.map(function(Y){return z[W(Y)]}).filter(Boolean),I=P.length!==T.length;N(P),(I||x&&T.length&&JSON.stringify(T.map(function(Y){return Y.style}))!==O)&&X()},yt=function(x,O,z){var P=z==="replace"?[]:x.slice();return O.forEach(function(I){if(W(I)!==null){var Y=P.findIndex(function(nt){return W(nt)===W(I)});Y>=0&&z==="toggle"?P.splice(Y,1):Y<0&&P.push(I)}}),P},Tt=function(x,O,z){var P=yt(T,x,O);J(P)!==J(T)&&(N(P),vt(),z||X())},Mt=function(x){Tt(x?[x]:[],"replace")},st=function(x,O){return x===null||typeof x!="object"?x===O:O===null||typeof O!="object"?!1:Object.keys(x).every(function(z){return st(x[z],O[z])})},St=function(x){var O=[];i.querySelectorAll(D).forEach(function(P){var I=H({target:P});W(I)!==null&&O.push(I)});var z=[];return x.forEach(function(P){if(!P||typeof P!="object"||typeof P.component!="string")throw new Error("select() needs items with a component, as getSelection() gives them");O.forEach(function(I){var Y=I.component===P.component&&(P.cluster==null||String(P.cluster)===I.cluster)&&(P.part==null||P.part===I.part)&&(P.data===void 0||st(P.data,I.data));Y&&z.push(I)})}),z},ne=0,Zt=function(x){if(performance.now()<ne){x.preventDefault(),x.stopPropagation();return}var O=H(x,!0);if(y.select===!0&&x.detail<2){var z=x.shiftKey||x.metaKey||x.ctrlKey;if(z)W(O)!==null&&Tt([O],"toggle");else if(O||x.target.closest("svg")&&!x.target.closest(".geneviewer-toolbar")||x.target===i){var P=T.length===1&&ht(B,O);Mt(P?null:O??null)}}!O||O.component==="legend"&&y.legendClick===!1||y.click===!0&&K("click",O)},Mn=function(x){if(!(performance.now()<ne)){var O=H(x,!0);O&&(y.select===!0&&Mt(O),K("dblclick",O))}},Fa=function(x,O){return Ea(O)?x.closest('[data-component="'+O+'"]'):x.closest(O==="legend"?"[data-part]":"text")},Vi=function(x,O){if(x.closest(".geneviewer-move-overlay")||!i.clientWidth||!i.clientHeight)return null;var z=x.parentNode,P=z.getScreenCTM();if(!P)return null;var I="http://www.w3.org/2000/svg",Y=i.querySelector(".geneviewer-move-overlay");Y||(Y=document.createElementNS(I,"svg"),Y.setAttribute("class","geneviewer-move-overlay"),Y.setAttribute("width",i.clientWidth),Y.setAttribute("height",i.clientHeight),Y.setAttribute("viewBox",`0 0 ${i.clientWidth} ${i.clientHeight}`),Object.assign(Y.style,{position:"absolute",left:"0",top:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"4"}),i.appendChild(Y));var nt={parent:z,next:x.nextSibling};O.component==="legend"&&(x.__home__=z.closest(".legend"));var wt=getComputedStyle(x);["fill","fill-opacity","stroke","stroke-width","stroke-opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline"].forEach(function(Dt){x.style.getPropertyValue(Dt)||x.style.setProperty(Dt,wt.getPropertyValue(Dt))});var kt=document.createElementNS(I,"g"),Pt=Y.getScreenCTM().inverse().multiply(P);return kt.setAttribute("transform",`matrix(${Pt.a} ${Pt.b} ${Pt.c} ${Pt.d} ${Pt.e} ${Pt.f})`),Ea(O.component)||kt.setAttribute("data-component",O.component),O.cluster!=null&&kt.setAttribute("data-cluster",O.cluster),Y.appendChild(kt),kt.appendChild(x),x.style.pointerEvents="visiblePainted",nt.frame=kt,Zr(),nt},Zr=function(){i.querySelectorAll(".geneviewer-move-overlay [data-part]").forEach(function(x){x.__home__&&x.parentNode.classList.toggle("unselected",x.__home__.classList.contains("unselected"))})},ie=function(){i.querySelectorAll(M).forEach(function(x){if(x.__drawn__?.moveX||x.__drawn__?.moveY){var O=H({target:x});O&&$.includes(O.component)&&Vi(x,O)}})},lc=function(x,O){K("dragmove",Object.assign({},x,{position:O}))},$e=null,Zi=null,cc=function(){var x=Zi;return Zi=null,x&&Pa(x),!!x},od=function(x){if($e){var O=$e;if($e=null,O.stopListening(),i.classList.remove("geneviewer-dragging"),!O.moved){cc();return}if(ne=performance.now()+350,!x){O.items.forEach(function(I){if(I.node.setAttribute("transform",I.transform),I.placement){var Y=I.placement;Y.parent.insertBefore(I.node,Y.next&&Y.next.parentNode===Y.parent?Y.next:null);var nt=Y.frame.parentNode;Y.frame.remove(),nt.firstChild||nt.remove()}lc(I.detail,{moveX:I.moveX,moveY:I.moveY})}),N(O.selection),vt(),cc();return}var z=O.items.map(function(I){I.node.__drawn__=Object.assign({},I.node.__drawn__,I.position);var Y=H({target:I.node},!0);return Y.position=I.position,Y.action="drag",Y});if(cc()){var P=fn();O.items.forEach(function(I){var Y=P[W(I.detail)];Y&&Da(Y,I.position)})}ze.record(O.items.map(function(I){return{key:W(I.detail),before:{moveX:I.moveX,moveY:I.moveY},after:I.position}}),!1),Ki(),fc(z,!1)}},Zn=function(){od(!1)},Hb=function(x){x.key==="Escape"&&$e&&(x.preventDefault(),Zn())},Wb=function(x){$e&&x.pointerId===$e.id&&od(!0)},jb=function(x){var O=$e;!O||x.pointerId!==O.id||!O.moved&&Math.hypot(x.clientX-O.x,x.clientY-O.y)<4||(O.moved||(O.moved=!0,O.items.forEach(function(z){z.placement=Vi(z.node,z.detail)}),y.select===!0&&O.items.length===1&&!G(O.items[0].detail)&&(N([O.items[0].detail]),vt()),i.classList.add("geneviewer-dragging")),x.preventDefault(),O.items.forEach(function(z){var P=new DOMPoint(x.clientX,x.clientY).matrixTransform(z.inverse);z.position={moveX:Math.round(z.moveX+P.x-z.start.x),moveY:Math.round(z.moveY+P.y-z.start.y)};var I=z.position.moveX-z.moveX,Y=z.position.moveY-z.moveY;z.node.setAttribute("transform",`translate(${I}, ${Y}) ${z.transform}`),lc(z.detail,z.position)}))},ad=function(x,O,z){var P=x.parentNode.getScreenCTM();if(!P)return null;var I=P.inverse();return{node:x,detail:O,inverse:I,start:new DOMPoint(z.clientX,z.clientY).matrixTransform(I),transform:x.getAttribute("transform")||"",moveX:O.style?.moveX??Je(x).moveX,moveY:O.style?.moveY??Je(x).moveY}},uc=function(x){if(!(x.button!==0||x.isPrimary===!1)){var O=H(x,!0);if(!O||!$.includes(O.component)||W(O)===null){Xb(x,O);return}if(y.drag===!0){var z=Fa(x.target,O.component);if(z){var P=ad(z,O,x);if(P){var I=[P];if(y.select===!0&&G(O)&&T.length>1){var Y=fn();T.forEach(function(nt){var wt=W(nt);if(!(wt===W(O)||!Y[wt])){var kt=ad(Y[wt],H({target:Y[wt]},!0),x);kt&&I.push(kt)}})}$e={id:x.pointerId,items:I,selection:T.slice(),x:x.clientX,y:x.clientY,moved:!1,stopListening:id({pointermove:jb,pointerup:Wb,pointercancel:Zn,blur:Zn,keydown:Hb})}}}}}},Ot=null,Xb=function(x,O){y.select!==!0||W(O)!==null||x.target.closest(".geneviewer-toolbar")||!i.contains(x.target)||(Ot={id:x.pointerId,x:x.clientX,y:x.clientY,node:null,mode:x.shiftKey||x.metaKey||x.ctrlKey?"add":"replace",selection:T.slice(),stopListening:id({pointermove:Vb,pointerup:Zb,pointercancel:Oa,blur:Oa,keydown:Kb})})},Gb=function(x){var O={};return i.querySelectorAll(D).forEach(function(z){var P=H({target:z}),I=W(P);if(!(I===null||O[I])){var Y=z.getBoundingClientRect();(Y.width||Y.height)&&Y.left>=x.left&&Y.right<=x.right&&Y.top>=x.top&&Y.bottom<=x.bottom&&(O[I]=H({target:z},!0))}}),Object.values(O)},Vb=function(x){if(!(!Ot||x.pointerId!==Ot.id)&&!(!Ot.node&&Math.hypot(x.clientX-Ot.x,x.clientY-Ot.y)<4)){x.preventDefault();var O={left:Math.min(Ot.x,x.clientX),right:Math.max(Ot.x,x.clientX),top:Math.min(Ot.y,x.clientY),bottom:Math.max(Ot.y,x.clientY)};Ot.node||(Ot.node=document.createElement("div"),Ot.node.className="geneviewer-marquee",i.appendChild(Ot.node));var z=i.getBoundingClientRect(),P=z.width/i.offsetWidth||1,I=z.height/i.offsetHeight||1;Object.assign(Ot.node.style,{left:(O.left-z.left)/P+"px",top:(O.top-z.top)/I+"px",width:(O.right-O.left)/P+"px",height:(O.bottom-O.top)/I+"px"}),N(yt(Ot.selection,Gb(O),Ot.mode)),vt()}},Ta=function(x){if(Ot){var O=Ot;if(Ot=null,O.stopListening(),!!O.node){if(O.node.remove(),ne=performance.now()+350,!x){N(O.selection),vt();return}J(T)!==J(O.selection)&&X()}}},Zb=function(x){Ot&&x.pointerId===Ot.id&&Ta(!0)},Oa=function(){Ta(!1)},Kb=function(x){x.key==="Escape"&&Ot&&(x.preventDefault(),Oa())},ze=vM(),Kr={},Ba={},Qr={},_r=null,oe=null,Je=function(x){return{moveX:x.__drawn__?.moveX??0,moveY:x.__drawn__?.moveY??0}},fn=function(){var x={};return i.querySelectorAll(D).forEach(function(O){var z=H({target:O}),P=z&&$.includes(z.component)?W(z):null;P===null||x[P]||(x[P]=Fa(O,z.component))}),x},Da=function(x,O){var z=Je(x),P=O.moveX-z.moveX,I=O.moveY-z.moveY;if(P||I){var Y=H({target:x});Y&&Vi(x,Y),x.setAttribute("transform",`translate(${P}, ${I}) ${x.getAttribute("transform")||""}`.trim())}x.__drawn__=Object.assign({},x.__drawn__,{moveX:O.moveX,moveY:O.moveY})},sd=function(x,O){var z=H({target:x},!0);return z?(z.position=Je(x),z.action=O,z):null},fc=function(x,O){x.forEach(function(z){var P=W(z);n.server?Kr[P]=z.position:Ba[P]=z.position}),x.length&&(y.select===!0&&(O&&x.length===1&&N([x[0]]),vt(),X()),x.length===1?K("drag",x[0]):K("moves",{action:x[0].action,moves:x}))},ld=function(x){return Object.keys(x).filter(function(O){return Qr[O]&&!Ma(Je(x[O]),Qr[O])})},Ki=function(x){if(!(!oe||y.drag!==!0)){var O=ld(x||fn()).length>0;oe.select(".geneviewer-history").property("hidden",!ze.canUndo()&&!ze.canRedo()&&!O),oe.select(".geneviewer-undo").property("disabled",!ze.canUndo()),oe.select(".geneviewer-redo").property("disabled",!ze.canRedo()),oe.select(".geneviewer-reset").property("disabled",!O)}},cd=function(x,O,z){var P=fn(),I=[];x.forEach(function(Y){var nt=P[Y.key];if(nt){Da(nt,Y.position);var wt=sd(nt,O);wt&&I.push(wt)}}),clearTimeout(_r),_r=null,Ki(P),fc(I,z)},Qi=function(x){var O=ze.next(x);if(!(!O||$e)){var z=fn(),P=O.items.every(function(I){return z[I.key]&&Ma(Je(z[I.key]),x?I.after:I.before)});if(!P)return ze.clear(),Ki(z);cd(ze.take(x),x?"undo":"redo",O.items.length===1)}},Qb=function(){if(!$e){var x=fn(),O=ld(x).map(function(z){return{key:z,before:Je(x[z]),after:Qr[z]}});O.length&&(ze.record(O,!1),cd(O.map(function(z){return{key:z.key,position:z.after}}),"reset",!1))}},ud=function(){var x=fn();if(Object.keys(x).forEach(function(P){Qr[P]||(Qr[P]=Je(x[P]))}),Object.keys(Kr).forEach(function(P){(!x[P]||Ma(Je(x[P]),Kr[P]))&&delete Kr[P]}),_r===null&&!Object.keys(Kr).length){var O=ze.expected(),z=Object.keys(O).some(function(P){return!x[P]||!Ma(Je(x[P]),O[P])});z&&ze.clear()}Ki(x)},Jb=function(){var x=fn();Object.keys(Ba).forEach(function(O){x[O]&&Da(x[O],Ba[O])})},t2=function(x,O){var z=fn(),P=T.map(function(I){return W(I)}).filter(function(I){return I!==null&&z[I]}).map(function(I){var Y=Je(z[I]),nt={moveX:Math.round(Y.moveX+x),moveY:Math.round(Y.moveY+O)};return Da(z[I],nt),lc(H({target:z[I]}),nt),{key:I,before:Y,after:nt}});return P.length?(ze.record(P,!0),Ki(),clearTimeout(_r),_r=setTimeout(function(){_r=null;var I=fn();fc(P.map(function(Y){return I[Y.key]&&sd(I[Y.key],"nudge")}).filter(Boolean),!1)},300),!0):!1},fd=function(x){if(!(y.drag!==!0||!i.isConnected)){var O=x.key.toLowerCase();if((x.metaKey||x.ctrlKey)&&(O==="z"||O==="y")){x.preventDefault(),Qi(!(O==="y"||x.shiftKey));return}var z={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[x.key];if(!(!z||x.metaKey||x.ctrlKey||y.select!==!0||$e)&&!(x.target!==document.body&&!i.contains(x.target))){var P=x.shiftKey?10:1;t2(z[0]*P,z[1]*P)&&x.preventDefault()}}},$a=function(){Ca=fd},hd=function(x){if(performance.now()<ne&&!x.target.closest(".geneviewer-toolbar")){ne=0,x.preventDefault(),x.stopPropagation();return}var O=x.target.closest&&x.target.closest(".geneviewer-move-overlay [data-part]")?.__home__,z=y.select===!0||y.dblclick===!0||y.click===!0&&y.legendClick!==!1;O&&!z&&O.isConnected&&(x.stopPropagation(),O.dispatchEvent(new MouseEvent("click",{bubbles:!1,detail:x.detail})),Zr())};i.addEventListener("click",hd,!0),i.addEventListener("click",Zr),i.addEventListener("pointerdown",$a,!0),i.addEventListener("focusin",$a);var e2=function(x){return/(^|\s)fa-/.test(x)?x:"fa-solid fa-"+x},n2=function(){oe=null;var x=ut({show:"hover",position:"topright",buttons:yM,icons:{}},"toolbarOptions",p,d),O=[].concat(x.buttons),z=function(_t){return O.includes(_t)},P=y.drag===!0&&["undo","redo","reset"].some(z),I=m&&z("save"),Y=!!Nt&&z("zoom");if(!(x.show==="never"||!P&&!I&&!Y)){var nt=function(_t){return x.icons[_t]!=null?e2(x.icons[_t]):null};oe=R.select(i).append("div").attr("class",`geneviewer-toolbar geneviewer-toolbar-${x.position}`+(x.show==="always"?" geneviewer-toolbar-always":"")).attr("id",`geneviewer-toolbar-${S}`).attr("role","toolbar").attr("aria-label","Chart");var wt=function(_t){return typeof _t=="number"?_t+"px":_t};[["color","--gv-toolbar-color"],["hoverColor","--gv-toolbar-hover"],["tooltipBackground","--gv-toolbar-tip-background"],["tooltipColor","--gv-toolbar-tip-color"],["tooltipBorder","--gv-toolbar-tip-border"],["tooltipRadius","--gv-toolbar-tip-radius"],["tooltipShadow","--gv-toolbar-tip-shadow"],["fontFamily","--gv-toolbar-font"],["size","--gv-toolbar-size"]].forEach(function(_t){x[_t[0]]!=null&&oe.style(_t[1],wt(x[_t[0]]))});var kt=function(_t,jt){var ae=_t.append("button").attr("type","button").attr("class","geneviewer-toolbar-button geneviewer-"+jt.name).attr("aria-label",jt.label).attr("aria-keyshortcuts",jt.shortcuts).property("disabled",!!jt.disabled).on("click",jt.onClick);nt(jt.name)?ae.append("i").attr("class",nt(jt.name)).attr("aria-hidden","true"):ac(ae.append("span").attr("class","geneviewer-icon").attr("aria-hidden","true"),jt.icon);var Fn=ae.append("span").attr("class","geneviewer-toolbar-tip").attr("aria-hidden","true");Fn.append("span").text(jt.label),jt.kbd&&Fn.append("kbd").text(jt.kbd)};if(P){var Pt=oe.append("div").attr("class","geneviewer-history").attr("role","group").attr("aria-label","Positions").property("hidden",!0);[{name:"undo",label:"Undo",icon:"rotate-left",kbd:qb?"⌘Z":"Ctrl+Z",shortcuts:"Control+Z Meta+Z",onClick:function(){Qi(!0)}},{name:"redo",label:"Redo",icon:"rotate-right",kbd:qb?"⇧⌘Z":"Ctrl+Y",shortcuts:"Control+Shift+Z Meta+Shift+Z Control+Y",onClick:function(){Qi(!1)}},{name:"reset",label:"Reset positions",icon:"house",kbd:null,shortcuts:null,onClick:Qb}].filter(function(_t){return z(_t.name)}).forEach(function(_t){kt(Pt,Object.assign({disabled:!0},_t))}),(I||Y)&&Pt.append("span").attr("class","geneviewer-toolbar-divider")}if(Y){var Dt=oe.append("div").attr("class","geneviewer-history geneviewer-zoom-buttons").attr("role","group").attr("aria-label","Zoom").property("hidden",Yt===null);kt(Dt,{name:"zoom",label:"Reset zoom",icon:"magnifying-glass-minus",kbd:null,shortcuts:null,onClick:vd}),I&&Dt.append("span").attr("class","geneviewer-toolbar-divider")}I&&Lb(S,i,oe.node(),nt("save"),n.saveAs)}},Kn=null,dd=function(x){Kn!==x&&(Kn&&Kn.classList.remove("geneviewer-hover"),Kn=x,Kn&&Kn.classList.add("geneviewer-hover"),i.classList.toggle("geneviewer-hover-below",!!Kn))},hc=function(x){var O=U(x);dd(O===x.target?null:O.closest("[data-component]"))},dc=function(){dd(null)},pc=function(x){if(x.key==="Escape"){$e?Zn():Ot?Oa():Mt(null);return}x.key==="Enter"&&y.dblclick===!0&&x.target.matches(D)&&(x.preventDefault(),Mn(x))},pd=function(){Zn();var x=y.click===!0;i.removeEventListener("click",Zt),i.removeEventListener("dblclick",Mn),i.removeEventListener("keydown",pc),i.removeEventListener("pointerdown",uc),Ta(!1),i.removeEventListener("mousemove",hc),i.removeEventListener("mouseleave",dc),Kn=null,i.classList.remove("geneviewer-hover-below");var O=(x||y.select===!0||y.dblclick===!0)&&y.highlight===!0;O&&(i.addEventListener("mousemove",hc),i.addEventListener("mouseleave",dc)),(x||y.select===!0)&&i.addEventListener("click",Zt),y.dblclick===!0&&i.addEventListener("dblclick",Mn),(y.select===!0||y.drag===!0)&&i.addEventListener("keydown",pc),(y.drag===!0||y.select===!0)&&i.addEventListener("pointerdown",uc),i.classList.toggle("geneviewer-draggable",y.drag===!0),y.select!==!0&&T.length&&(N([]),X()),i.classList.toggle("geneviewer-selectable",y.select===!0),i.classList.toggle("geneviewer-highlight",O),vt(!0)},Nt=null,Yt=null,gd=null,md=null,tn=[],en=[0,1],za=null,nn=null,Rt=null,Qn=null,Ji=null,Ne=function(){return Nt?.mode==="absolute"?"absolute":"relative"},r2=function(){var x=Nt?.range;return!Array.isArray(x)||x.length!==2?null:(x=x.slice().sort(function(O,z){return O-z}),Ne()==="relative"&&x[0]<=0&&x[1]>=1?null:x)},yd=function(x){return(x-en[0])/(en[1]-en[0])},i2=function(x){return en[0]+x*(en[1]-en[0])},gc=function(){return Yt?Ne()==="absolute"?Yt.map(yd):Yt.slice():[0,1]},bd=function(){var x=Nt?.min;return x==null?.01:Math.min(1,Ne()==="absolute"?x/(en[1]-en[0]):x)},mc=function(x){return Ne()==="absolute"?Math.round(x):Math.round(x*1e4)/1e4},o2=function(x){Yt=x[0]<=1e-6&&x[1]>=1-1e-6?null:x.map(function(O){return mc(Ne()==="absolute"?i2(O):O)})},a2=function(){var x=Ne()==="absolute",O=Yt||(x?en:[0,1]);return{mode:Ne(),start:mc(O[0]),end:mc(O[1]),zoomed:Yt!==null,range:Yt?Yt.slice():null,clusters:tn.map(function(z){var P=z.chart,I=[P.xScale.invert(0),P.xScale.invert(P.width-P.margin.left-P.margin.right)].sort(function(Y,nt){return Y-nt});return{cluster:z.key,start:Math.round(I[0]),end:Math.round(I[1])}})}},Na=null,to=function(x){if(clearTimeout(Ji),Ji=null,!(y.zoom!==!0||!Nt)){var O=a2(),z=JSON.stringify([O.mode,O.range,O.clusters]);(x==="render"||x==="set")&&z===Na||(Na=z,O.action=x,K("zoom",O))}},yc=function(){if(nn){var x=gc(),O=function(Y){return Y*100+"%"};nn.querySelector('[data-side="start"]').style.width=O(x[0]),nn.querySelector('[data-side="end"]').style.left=O(x[1]);var z=nn.querySelector('[data-zoom-part="window"]');z.style.left=O(x[0]),z.style.width=O(x[1]-x[0]);var P=Yt||(Ne()==="absolute"?en:[0,1]),I=function(Y){return Ne()==="absolute"?R.format(",.0f")(Y):R.format(".0%")(Y)};["start","end"].forEach(function(Y,nt){var wt=nn.querySelector('[data-zoom-part="'+Y+'"]');wt.style.left=O(x[nt]),wt.setAttribute("aria-valuenow",Math.round(x[nt]*100)),wt.setAttribute("aria-valuetext",I(P[nt]))}),z.setAttribute("aria-valuenow",Math.round(x[0]*100)),z.setAttribute("aria-valuetext",I(P[0])+" to "+I(P[1])),oe?.select(".geneviewer-zoom-buttons").property("hidden",Yt===null)}},bc=function(x){if(yc(),x)return Qn&&cancelAnimationFrame(Qn),Qn=null,xc();Qn||(Qn=requestAnimationFrame(function(){Qn=null,xc()}))},Ra=function(x,O){o2(x),Rt&&Nt?.update==="release"?yc():bc(O)},vd=function(){Yt!==null&&(Ra([0,1],!0),to("reset"))},s2=function(x){if(x.stopPropagation(),!(x.button!==0||Rt)){x.preventDefault();var O=x.currentTarget.getBoundingClientRect(),z=(x.clientX-O.left)/O.width,P=x.target.closest("[data-zoom-part]")?.getAttribute("data-zoom-part")??"track",I=gc();if(Rt={id:x.pointerId,left:O.left,width:O.width,at:z,moved:!1,stopListening:id({pointermove:l2,pointerup:vc,pointercancel:vc,blur:vc})},P==="track"){var Y=(I[1]-I[0])/2,nt=Math.max(Y,Math.min(1-Y,z));I=[nt-Y,nt+Y],Rt.moved=!0,Ra(I),P="window"}Rt.part=P,Rt.shares=I}},l2=function(x){if(!(!Rt||x.pointerId!==Rt.id)){x.preventDefault();var O=(x.clientX-Rt.left)/Rt.width-Rt.at,z=Rt.shares,P=bd(),I=Rt.part==="start"?[Math.max(0,Math.min(z[1]-P,z[0]+O)),z[1]]:Rt.part==="end"?[z[0],Math.min(1,Math.max(z[0]+P,z[1]+O))]:(function(){var Y=Math.max(-z[0],Math.min(1-z[1],O));return[z[0]+Y,z[1]+Y]})();Rt.moved=!0,Ra(I)}},vc=function(x){if(!(!Rt||x.pointerId!==void 0&&x.pointerId!==Rt.id)){var O=Rt;Rt=null,O.stopListening(),O.moved&&(bc(!0),to("drag"))}},c2=function(x){var O=x.target.getAttribute&&x.target.getAttribute("data-zoom-part");if(O){var z=gc(),P=bd(),I={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1}[x.key],Y=null;if(I){var nt=I*(x.shiftKey?.1:.01);Y=O==="start"?[Math.max(0,Math.min(z[1]-P,z[0]+nt)),z[1]]:O==="end"?[z[0],Math.min(1,Math.max(z[0]+P,z[1]+nt))]:[z[0]+Math.max(-z[0],Math.min(1-z[1],nt)),z[1]+Math.max(-z[0],Math.min(1-z[1],nt))]}else x.key==="Home"?Y=O==="end"?[z[0],Math.min(1,z[0]+P)]:O==="start"?[0,z[1]]:[0,z[1]-z[0]]:x.key==="End"&&(Y=O==="start"?[Math.max(0,z[1]-P),z[1]]:O==="end"?[z[0],1]:[1-(z[1]-z[0]),1]);Y&&(x.preventDefault(),x.stopPropagation(),Ra(Y),clearTimeout(Ji),Ji=setTimeout(function(){to("keyboard")},300))}},wc=function(x,O){Object.keys(O||{}).forEach(function(z){z.includes("-")?x.style.setProperty(z,O[z]):x.style[z]=O[z]})},u2=function(x){if(nn=null,!(!Nt||!tn.length)){var O=Ne()==="absolute";en=O?[R.min(tn,function(Ut){return Ut.chart.minStart}),R.max(tn,function(Ut){return Ut.chart.maxEnd})]:[0,1];var z=tn[0].chart,P=R.select(i).append("div").attr("class","geneviewer-zoom-row").style("height",x+"px"),I=i.getBoundingClientRect(),Y=I.width/i.offsetWidth||1,nt=z.svg.node().getBoundingClientRect(),wt=nt.width/z.width||1,kt=z.width-z.margin.left-z.margin.right,Pt=P.node().getBoundingClientRect(),Dt=P.append("div").attr("class","geneviewer-zoom-slider").attr("role","group").attr("aria-label","Zoom").style("left",(nt.left+z.margin.left*wt-Pt.left)/Y+"px").style("width",kt*wt/Y+"px").on("pointerdown",s2).on("click",function(Ut){Ut.stopPropagation()}).on("dblclick",function(Ut){Ut.stopPropagation(),vd()}).on("keydown",c2);if(wc(Dt.node(),Nt.style),Nt.overview!==!1){var _t=Dt.append("svg").attr("class","geneviewer-zoom-overview").attr("viewBox","0 0 1000 "+x).attr("preserveAspectRatio","none").attr("aria-hidden","true"),jt=(x-6)/tn.length,ae=Math.max(1,Math.min(jt*.7,8));tn.forEach(function(Ut,hn){var Tn=Ut.chart,Sr=Tn.width-Tn.margin.left-Tn.margin.right,no=function(rn){if(O)return yd(rn);var Jn=Tn.fullScale(rn);return Jn===null?null:Jn/Sr},Sc=function(rn){return Nt.color?Nt.color:Ut.group&&Tn.genesColorScale?Tn.genesColorScale(rn[Ut.group]):"#9e9e9e"};(Tn.data||[]).forEach(function(rn){var Jn=no(rn.start),ro=no(rn.end);Jn===null||ro===null||_t.append("rect").attr("x",Math.min(Jn,ro)*1e3).attr("width",Math.max(Math.abs(ro-Jn)*1e3,1)).attr("y",3+jt*hn+(jt-ae)/2).attr("height",ae).attr("fill",Sc(rn))})})}Dt.append("div").attr("class","geneviewer-zoom-shade").attr("data-side","start"),Dt.append("div").attr("class","geneviewer-zoom-shade").attr("data-side","end");var Fn=Dt.append("div").attr("class","geneviewer-zoom-window").attr("data-zoom-part","window");wc(Fn.node(),Nt.windowStyle),[Fn].concat(["start","end"].map(function(Ut){var hn=Dt.append("div").attr("class","geneviewer-zoom-handle").attr("data-zoom-part",Ut);return wc(hn.node(),Nt.handleStyle),hn})).forEach(function(Ut){var hn=Ut.attr("data-zoom-part");Ut.attr("tabindex",0).attr("role","slider").attr("aria-label",hn==="window"?"Zoom window":hn==="start"?"Zoom start":"Zoom end").attr("aria-valuemin",0).attr("aria-valuemax",100)}),nn=Dt.node(),yc()}},f2=function(){if(tn.some(function(O){return O.chart.zoom})){var x="http://www.w3.org/2000/svg";i.querySelectorAll("svg.GeneLink").forEach(function(O,z){var P=O.getBoundingClientRect(),I=P.width/(+O.getAttribute("width")||P.width)||1,Y="geneviewer-zoom-links-"+S+"-"+z,nt=document.createElementNS(x,"clipPath");nt.setAttribute("id",Y),tn.forEach(function(Pt){var Dt=Pt.chart,_t=Dt.svg.node().getBoundingClientRect(),jt=_t.width/Dt.width||1,ae=document.createElementNS(x,"rect");ae.setAttribute("x",(_t.left+Dt.margin.left*jt-P.left)/I),ae.setAttribute("y",0),ae.setAttribute("width",(Dt.width-Dt.margin.left-Dt.margin.right)*jt/I),ae.setAttribute("height",O.getAttribute("height")),nt.appendChild(ae)});var wt=document.createElementNS(x,"defs");wt.appendChild(nt);var kt=document.createElementNS(x,"g");kt.setAttribute("clip-path","url(#"+Y+")"),Array.from(O.childNodes).forEach(function(Pt){kt.appendChild(Pt)}),O.appendChild(wt),O.appendChild(kt)})}},h2=function(x){C||!Nt||(Yt=Array.isArray(x)&&x.length===2?x.slice().sort(function(O,z){return O-z}):null,Yt&&Ne()==="relative"&&Yt[0]<=0&&Yt[1]>=1&&(Yt=null),bc(!0),to("set"))},wd=function(){Zn(),tn=[],za=null;var x=q?Array.from(i.querySelectorAll(".legend.unselected"),function(se){return se.__data__}):[];if(q=!0,R.select(i).selectAll("*").remove(),F.forEach(function(se){i.style[se]=""}),n.server){var O=typeof g.width=="number"?g.width+"px":g.width,z=typeof O=="string"&&/^\d+(\.\d+)?px$/.test(O);z?(i.style.width=O,v=!0):v&&(i.style.width=w,v=!1);var P=i.parentElement&&getComputedStyle(i.parentElement),I=P&&/^(inline-)?flex$/.test(P.display)&&/^row/.test(P.flexDirection);z&&I?(i.style.flex="0 0 auto",_=!0):_&&(i.style.flex=b,_=!1)}i.style.height="100%",i.style.position="relative",i.style.boxSizing="border-box";var Y=ut({style:{}},"chartOptions",{style:s},d).style;F=Object.keys(Y);for(var nt in Y)i.style[nt]=Y[nt];var wt=0;if(h?.show){var kt=R.select(i).append("div").attr("id",`geneviewer-title-container-${S}`).classed("geneviewer-container",!0),Pt=(h.title&&h.subtitle?50:40)*Gn(d),Dt=ut({height:Pt},"titleOptions",h,d).height;wt=Le(Dt,i.clientHeight);var _t={...h,width:i.clientWidth,height:wt},jt=Vl(`#geneviewer-title-container-${S}`,"svg-container","titleOptions",_t,d).title(_t.title,_t.subtitle,_t.show??!1,_t)}var ae=f?.show===!1?0:Le(f?.height,i.clientHeight);if(f?.group!==null&&f?.show){R.select(i).append("div").attr("id",`geneviewer-legend-container-${S}`).classed("geneviewer-container",!0);var Fn=Array.isArray(l)&&l.length?Ih(l,d):null;za=Fn&&Fn.colorBarOptions.position==="legend"?Fn:null;var Ut={...f,width:i.clientWidth,height:Le(f.height,i.clientHeight),editable:y.select===!0||y.dblclick===!0||y.click===!0&&y.legendClick!==!1};Vl(`#geneviewer-legend-container-${S}`,"svg-container","legendOptions",Ut,d).legendData(c).legend(Ut.group??!1,Ut.show??!1,i.id,Ut,za);var hn=R.select(`#geneviewer-legend-container-${S}`).node(),Tn=hn.getBoundingClientRect();ae=Tn.height}R.select(i).append("div").attr("id",`geneviewer-graph-container-${S}`).style("flex-direction",a.direction).style("position","relative").classed("geneviewer-container",!0);var Sr=Object.keys(u),no=Nt?Nt.height??24:0,Sc=Nt?no+8:0,rn=Nt&&Yt?{from:Yt[0],to:Yt[1],mode:Ne()}:null,Jn=(Array.isArray(l)?l:[]).map(se=>({data:jr(se.data),options:se.options??{}}));Sr.forEach(function(se){var me=u[se],Ia=me.container,g2=me.cluster,m2=jr(u[se].data),_d=me.scale,La=me.clusterTitle,qa=me.footer,io=me.clusterLabel,kc=me.labels,Sd=me.sequence,Ya=me.genes,Ac=me.transcript,kd=me.coordinates,Ad=me.scaleBar,y2=me.annotations,Ed=me.trackMouse,Md=me.tooltip,on=JSON.parse(JSON.stringify(Ia));if(on.height=Le(on.height,i.clientHeight),on.height-=wt/Sr.length,on.height-=ae?ae/Sr.length:0,on.height-=Sc/Sr.length,typeof Ia.height=="string"&&Ia.height.endsWith("%")){var b2=(parseFloat(Y.paddingTop)||0)+(parseFloat(Y.paddingBottom)||0);on.height-=b2/Sr.length}on.width=Le(on.width,i.clientWidth),io?.show&&(on.margin={...on.margin,...Wy(Ia,io,d)});var Ua=Vl(`#geneviewer-graph-container-${S}`,"svg-container","containerOptions",on,d).cluster(g2).title(La?.title,La?.subtitle,La?.show??!1,La,"clusterTitleOptions").footer(qa?.title,qa?.subtitle,qa?.show??!1,qa).clusterLabel(io?.title,io?.show??!1,io).geneData(c,m2).scale(rn?Object.assign({},_d,{zoom:rn}):_d).sequence(Sd?.show??!1,Sd).genes(Ya?.group,Ya?.show??!1,Ya).transcript(Ac?.group,Ac?.show??!1,Ac);Ua.svg.attr("data-cluster",se),Jn.forEach(Cd=>{Ua.links(Ky(Cd.data,se),se,Cd.options)}),Ua.coordinates(kd?.show??!1,kd).labels(kc?.label,kc?.show??!1,kc).scaleBar(Ad?.show??!1,Ad).addAnnotations(y2).trackMouse(Ed?.show??!1,Ed).tooltip(Md?.show??!1,Md).clipZoom(),tn.push({key:se,chart:Ua,group:Ya?.group})}),u2(no);var ro=ut({position:"bottom"},"legendOptions",f,d).position;ro=="bottom"&&f?.show&&f?.group!==null&&i.appendChild(hn),n2(),i.querySelectorAll(".legend").forEach(function(se){x.includes(se.__data__)&&se.dispatchEvent(new MouseEvent("click",{bubbles:!1}))})},xd=function(){if(!l||l.length===0)return;let x=R.select(`#geneviewer-graph-container-${S}`);Zy(x,l,d),Qy(x,l,d,za!==null),f2()},d2=function(x){for(var O=[],z=i.parentElement;z;z=z.parentElement)(z.scrollTop||z.scrollLeft)&&O.push([z,z.scrollTop,z.scrollLeft]);var P=document.scrollingElement;P&&!O.some(function(I){return I[0]===P})&&O.push([P,P.scrollTop,P.scrollLeft]);try{x()}finally{O.forEach(function(I){I[0].scrollTop!==I[1]&&(I[0].scrollTop=I[1]),I[0].scrollLeft!==I[2]&&(I[0].scrollLeft=I[2])})}},xc=function(){var x=nn&&nn.contains(document.activeElement)?document.activeElement.getAttribute("data-zoom-part"):null;d2(function(){wd(),xd(),ie(),Jb(),pd(),ud()}),x&&nn&&nn.querySelector('[data-zoom-part="'+x+'"]')?.focus({preventScroll:!0})},p2=function(x){if(x.data)return jr(x.data);var O=x.dataColumns??[],z=[];return Object.values(x.series??{}).forEach(function(P){jr(P.data).forEach(function(I){var Y={};O.forEach(function(nt){Y[nt]=I[nt]}),z.push(Y)})}),z.sort(function(P,I){return P.rowID-I.rowID})},Pa=function(x){var O=p2(x),z=JSON.stringify([O,x.group,x.cluster,x.legend?.group]);if($e&&z===L&&x.events?.drag===!0){Zi=x;return}Zi=null,Zn(),Nt=x.zoom&&x.zoom.show!==!1?x.zoom:null;var P=Nt?JSON.stringify([Nt.range??null,Ne()]):null,I=x.events?.renderId??null,Y=I!==null&&I!==md;if(md=I,(z!==L||P!==gd||Y)&&(Yt=r2(),Na=null),Nt||(Na=null),gd=P,L!==null&&z!==L&&(q=!1,T.length&&(N([]),X()),ze.clear(),Kr={},Qr={}),Ba={},L=z,a=x.graphContainer,s=x.style,c=O,l=x.links,u=x.series,m=x.saveButton,p=x.toolbar??{},h=x.title,f=x.legend,d=x.theme??{},y=x.events??{},g=x.size??{},wd(),xd(),ie(),pd(),ud(),to("render"),y.rendered===!0){var nt={id:y.renderId??i.id+"-render-"+ ++pM,chartId:i.id,width:i.clientWidth,height:i.clientHeight};K("rendered",nt)}},Cn=null,_c=function(x){x&&x.version!==void 0?(Cn=structuredClone(x),Pa(oc(Cn))):(Cn=null,Pa(x))},eo={update:function(x){C||(Cn!==null?(Cn=nd(Cn,x),Pa(oc(Cn))):_c(x))},setSpec:function(x){if(!C){if(!x||x.version===void 0)throw new Error("setSpec() needs a spec with a version");_c(x)}},getSpec:function(){return Cn===null?null:structuredClone(Cn)},resize:function(){C||xc()},on:function(x,O){if(!bM.includes(x))throw new Error("Unknown event: "+x);return(k[x]=k[x]||[]).push(O),function(){eo.off(x,O)}},off:function(x,O){var z=k[x]||[],P=z.indexOf(O);P>=0&&z.splice(P,1)},zoomTo:h2,select:function(x){if(!C){if(y.select!==!0){qe("chart.select() needs events: { select: true }; nothing was selected.");return}Tt(St(x==null?[]:Array.isArray(x)?x:[x]),"replace")}},getSelection:function(){return ot()},undo:function(){C||Qi(!0)},redo:function(){C||Qi(!1)},download:function(x,O){if(x!=="svg"&&x!=="png")return Promise.reject(new Error('download() needs the format "svg" or "png"'));var z=O??"graph."+x,P=n.saveAs||rd;return Promise.resolve().then(function(){return x==="svg"?new Blob([eo.toSVG()],{type:"image/svg+xml;charset=utf-8"}):eo.toPNG()}).then(function(I){return P(I,z)}).then(function(){})},toSVG:function(){return Aa(i,oe?oe.node():null)},toPNG:function(){return sc(i,oe?oe.node():null)},destroy:function(){C||(C=!0,Zi=null,Zn(),Ta(!1),Rt&&Rt.stopListening(),Rt=null,clearTimeout(_r),clearTimeout(Ji),Qn&&cancelAnimationFrame(Qn),Ca===fd&&(Ca=null),k={},[["click",hd,!0],["click",Zr],["pointerdown",$a,!0],["focusin",$a],["click",Zt],["dblclick",Mn],["keydown",pc],["pointerdown",uc],["mousemove",hc],["mouseleave",dc]].forEach(function(x){i.removeEventListener(x[0],x[1],x[2])}),R.select(i).on("mouseleave",null).selectAll("*").remove(),F.forEach(function(x){i.style[x]=""}),i.classList.remove("geneviewer-draggable","geneviewer-selectable","geneviewer-highlight","geneviewer-dragging","geneviewer-hover-below"),o&&i.classList.remove("geneviewer"))}};return Object.keys(n.on||{}).forEach(function(x){eo.on(x,n.on[x])}),_c(e),eo}export{sc as chartToPNG,Aa as chartToSVG,oc as compile,wM as newChart,Sa as palettes,tc as themes,dM as version};
|
|
417
417
|
//# sourceMappingURL=geneviewer.standalone.mjs.map
|