"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3301],{33301:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var a=n(7552),i=n(49823),r=n(99546),o=n(29499),l=n(33371),c=n(32808),s=n(1343),d=n(58507),g=n(5401),y=n(75785),m=n(42781);const{parseCigar:u}=m.aF;function h(e){return Math.floor(e)}function w(e,t){let n=0,a=0;for(let i=0;i<e.length;i++){const r=+e[i],o=e[i+1],l=Math.min(r,t-n);if(n>=t)break;"I"===o?a+=r:"D"===o?n+=l:"M"!==o&&"="!==o&&"X"!==o||(a+=l,n+=l)}return[n,a]}const p=(0,y.n9)()({padding:{margin:10,border:"1px solid #ccc"}});function f({model:e,feature:t,trackId:n,handleClose:y}){const{classes:m}=p(),f=-1===t.get("strand"),[b,k]=(0,a.useState)(f),[v,S]=(0,a.useState)("1000");return a.createElement(i.Dialog,{open:!0,title:"Launch synteny view",onClose:y},a.createElement(o.A,null,f?a.createElement(l.A,{className:m.padding,control:a.createElement(c.A,{checked:b,onChange:e=>{k(e.target.checked)}}),label:"Note: The feature is inverted in orientation on the target sequence. This will result in the lower panel having genomic coordinates decreasing left to right. Horizontally flip?"}):null,a.createElement(s.A,{label:"Add window size in bp",value:v,onChange:e=>{S(e.target.value)}})),a.createElement(d.A,null,a.createElement(g.A,{variant:"contained",onClick:()=>{(async()=>{try{await async function({feature:e,windowSize:t,model:n,trackId:a,view:i,horizontallyFlip:o}){const l=(0,r.getSession)(n),c=i?.dynamicBlocks.contentBlocks[0],s=e.get("CIGAR"),d=e.get("strand"),g=e.get("refName"),y=e.get("assemblyName"),m=e.get("start"),p=e.get("end"),f=e.get("mate"),b=f.start,k=f.end,v=f.assemblyName,S=f.refName;let C,A,E,L;if(c&&s){const e=c.start,t=c.end,n=u(s),[a,i]=w(n,e-m),[r,o]=w(n,t-m),l=-1===d?-1:1;E=m+a,L=m+r,C=(-1===d?k:b)+i*l,A=(-1===d?k:b)+o*l}else E=m,L=p,C=b,A=k;const $=l.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{type:"LinearGenomeView",hideHeader:!0},{type:"LinearGenomeView",hideHeader:!0}],tracks:[{configuration:a,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:`${a}-LinearSyntenyDisplay`}]}]}),T=`${g}:${h(E-t)}-${h(L+t)}`,z=Math.min(C,A),N=Math.max(C,A),I=`${S}:${h(z-t)}-${h(N+t)}${o?"[rev]":""}`;await Promise.all([$.views[0].navToLocString(T,y),$.views[1].navToLocString(I,v)])}({feature:t,windowSize:+v,horizontallyFlip:b,trackId:n,model:e})}catch(t){console.error(t),(0,r.getSession)(e).notifyError(`${t}`,t)}})(),y()}},"Submit"),a.createElement(g.A,{variant:"contained",color:"secondary",onClick:()=>{y()}},"Cancel")))}}}]);
//# sourceMappingURL=3301.33f7fe16.chunk.js.map