import{r,f as w,j as e,g as I,R as k,C as b,a as v,d as c,e as F,B as _,T as q}from"./main-BzPVmAp-.js";import{g as T}from"./index-DEnjftNB.js";import{B as D}from"./index-5ngX0NHj.js";import{C}from"./index-7u0Bo8e4.js";import{T as E}from"./index-SGIbgpRk.js";import{F as O}from"./Table-kIlrKW-9.js";import{S as R}from"./index-BZ6Sq__j.js";import{I as B}from"./index-CUuSmggi.js";import"./callSuper-CKCGYiRV.js";import"./rgb-BwIoVOhg.js";import"./Dropdown-Clv_Pvnt.js";import"./addEventListener-CzbSevz3.js";var S=function(){return S=Object.assign||function(t){for(var a,s=1,o=arguments.length;s<o;s++){a=arguments[s];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},S.apply(this,arguments)},H=r.forwardRef(function(t,a){return w.createElement(D,S({},t,{chartType:"Heatmap",ref:a}))});const N=({data:t})=>{const a={data:t,xField:"sample1",yField:"sample2",colorField:"value",sizeField:"value",shapeField:"point",scale:{size:{range:[12,20]},color:{range:["#0d5fbb","#7eadfc","#fd8b6f","#aa3523"]}},label:{text:s=>s.value,position:"inside",style:{fill:"#fff",shadowBlur:2,shadowColor:"rgba(0, 0, 0, .45)",pointerEvents:"none"}}};return e.jsx(H,{...a})},Z=()=>{const[t,a]=r.useState([]),[s,o]=r.useState(!1),[n,g]=r.useState([]),[p,d]=r.useState([]),{project:x,sampleComposition:f}=I(),j=[{title:"seq_id",dataIndex:"seq_id",key:"seq_id"},{title:"position",dataIndex:"position",key:"position"},{title:"locus_tag",dataIndex:"locus_tag",key:"locus_tag"},{title:"type",dataIndex:"type",key:"type"},{title:"ref_seq",dataIndex:"ref_seq",key:"ref_seq"},{title:"gene_name",dataIndex:"gene_name",key:"gene_name"},{title:"gene_product",dataIndex:"gene_product",key:"gene_product"}],h=async()=>{const l=await T(x),i=l.data.map(m=>({title:m.sample_name,dataIndex:m.sample_name,key:m.sample_name})),y=l.data.map(m=>({value:m.sample_name,label:m.sample_name}));d(y),g([...j,...i])},u=async l=>{o(!0);const i=await v.post("/api/mutation-compare",l);console.log(i),o(!1),a(i.data)};return r.useEffect(()=>{h(),u({})},[]),e.jsx(e.Fragment,{children:e.jsxs(k,{children:[e.jsx(b,{lg:12,sm:24,xs:24,children:e.jsxs(C,{style:{marginRight:"0.5rem"},children:[e.jsx(z,{loadMutationCompare:u,sampleNames:p,mutationData:t}),e.jsx("hr",{}),e.jsx(L,{})]})}),e.jsx(b,{lg:12,sm:24,xs:24,children:e.jsx(C,{style:{marginLeft:"0.5rem"},children:e.jsx(E,{items:[{key:"snv_site",label:"所有SNV位点",children:e.jsx(O,{loading:s,pagination:{pageSize:30},scroll:{x:"max-content"},columns:n,rowKey:l=>l.position,dataSource:t})}]})})})]})})},z=({loadMutationCompare:t,sampleNames:a,mutationData:s})=>{const[o]=c.useForm();return e.jsxs(e.Fragment,{children:[e.jsxs(c,{form:o,onFinish:n=>{t(n),console.log(n)},children:[e.jsx(c.Item,{label:"第一组",name:"group1",rules:[{required:!0,message:"该字段不能为空!"}],children:e.jsx(F,{mode:"multiple",allowClear:!0,options:a})}),e.jsx(c.Item,{label:"第二组",name:"group2",rules:[{required:!0,message:"该字段不能为空!"}],children:e.jsx(F,{mode:"multiple",allowClear:!0,options:a})}),e.jsx(c.Item,{label:null,children:e.jsx(_,{type:"primary",htmlType:"submit",children:"提交"})}),e.jsx(_,{onClick:()=>{o.resetFields(),t({})},children:"重置"})]}),s&&e.jsxs(e.Fragment,{children:["总共检测到[",s.length,"]个突变位点",e.jsx(q,{rows:4,value:s.map(n=>n.locus_tag).join(", ")})]})]})},L=({})=>{const[t,a]=r.useState(!1),[s,o]=r.useState(),[n,g]=r.useState([]),p=async()=>{a(!0);const d=await v.get("/jupyter/snv_compare_tree");o(d.data),a(!1);const x=JSON.parse(d.data.matrix),f=Object.entries(x).map(j=>{const[h,u]=j;return Object.entries(u).map(l=>{const[i,y]=l;return{sample1:h,sample2:i,value:y}})}).flat(1/0);g(f),console.log(f)};return r.useEffect(()=>{p()},[]),e.jsxs(e.Fragment,{children:[e.jsx(_,{onClick:p,children:"刷新"}),e.jsx(R,{spinning:t,children:s&&e.jsxs(e.Fragment,{children:[e.jsx(B,{width:"100%",src:s.image}),e.jsx(N,{data:n})]})})]})};export{Z as default};
