"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3301],{33301:(e,n,t)=>{t.r(n),t.d(n,{default:()=>p});var a=t(7552),i=t(67112),s=t(76218),o=t(7946),r=t(22762),l=t(93062),c=t(30698),d=t(69092),h=t(75785),g=t(55689);const{parseCigar:y}=g.aF;function u(e,n){let t=0,a=0;for(let i=0;i<e.length;i++){const s=+e[i],o=e[i+1],r=Math.min(s,n-t);if(t>=n)break;"I"===o?a+=s:"D"===o?t+=r:"M"!==o&&"="!==o&&"X"!==o||(a+=r,t+=r)}return[t,a]}var w=t(69500);const f=(0,h.n9)()({padding:{margin:10,border:"1px solid #ccc"}});function p({session:e,view:n,feature:t,trackId:h,handleClose:g}){const{classes:p}=f(),b=-1===t.get("strand"),m=!!t.get("CIGAR"),[k,v]=(0,a.useState)(b),[C,A]=(0,a.useState)("1000"),[j,x]=(0,a.useState)(!0);return(0,w.jsxs)(i.Dialog,{open:!0,title:"Launch synteny view",onClose:g,children:[(0,w.jsxs)(s.A,{children:[n&&m?(0,w.jsx)(o.A,{className:p.padding,control:(0,w.jsx)(r.A,{checked:j,onChange:e=>{x(e.target.checked)}}),label:"Use CIGAR string to navigate the current visible to the target"}):null,b?(0,w.jsx)(o.A,{className:p.padding,control:(0,w.jsx)(r.A,{checked:k,onChange:e=>{v(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,(0,w.jsx)(l.A,{label:"Add window size in bp",value:C,onChange:e=>{A(e.target.value)}})]}),(0,w.jsxs)(c.A,{children:[(0,w.jsx)(d.A,{variant:"contained",onClick:()=>{(async()=>{try{await async function({feature:e,windowSize:n,session:t,trackId:a,region:i,horizontallyFlip:s}){const o=e.get("CIGAR"),r=e.get("strand"),l=e.get("refName"),c=e.get("assemblyName"),d=e.get("start"),h=e.get("end"),g=e.get("mate"),w=g.start,f=g.end,p=g.assemblyName,b=g.refName;let m,k,v,C;if(i&&o){const e=i.start,n=i.end,t=y(o),[a,s]=u(t,e-d),[l,c]=u(t,n-d),h=-1===r?-1:1;v=d+a,C=d+l,m=(-1===r?f:w)+s*h,k=(-1===r?f:w)+c*h}else v=d,C=h,m=w,k=f;const A=`${l}:${Math.floor(v-n)}-${Math.floor(C+n)}`,j=Math.min(m,k),x=Math.max(m,k),S=`${b}:${Math.floor(j-n)}-${Math.floor(x+n)}${s?"[rev]":""}`;t.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{type:"LinearGenomeView",hideHeader:!0,init:{assembly:c,loc:A}},{type:"LinearGenomeView",hideHeader:!0,init:{assembly:p,loc:S}}],tracks:[{configuration:a,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:`${a}-LinearSyntenyDisplay`}]}]})}({feature:t,windowSize:+C,horizontallyFlip:k,trackId:h,session:e,region:j?n?.dynamicBlocks.contentBlocks[0]:void 0})}catch(n){console.error(n),e.notifyError(`${n}`,n)}})(),g()},children:"Submit"}),(0,w.jsx)(d.A,{variant:"contained",color:"secondary",onClick:()=>{g()},children:"Cancel"})]})]})}}}]);
//# sourceMappingURL=3301.3ab5df9b.chunk.js.map