import{o as A,u as F,R as e,aK as L,aL as M,m as O,r as m,b as x,aM as k,aN as P,aO as T,aP as u,aQ as d,ao as V,N as D,a as w}from"./rpcWorker-CVTx5FIM.js";const G=A(function({model:t,selectedAsm:r,value:o,setValue:c,setOption:i}){const g=F.getSession(t),{assemblyManager:p,textSearchManager:n}=g,{rankSearchResults:E}=t,a=t.searchScope(r),v=p.get(r);return e.createElement(L,{fetchResults:s=>M({queryString:s,assembly:v,textSearchManager:n,rankSearchResults:E,searchScope:a}),model:t,assemblyName:r,value:o,minWidth:270,onChange:s=>{c(s)},onSelect:s=>{i(s)},TextFieldProps:{variant:"outlined",helperText:"Enter sequence name, feature name, or location"}})}),K=O()(t=>({importFormContainer:{padding:t.spacing(2)},button:{margin:t.spacing(2)},container:{padding:t.spacing(4)}})),j=A(function({model:t}){var r;const{classes:o}=K(),c=F.getSession(t),{assemblyNames:i,assemblyManager:g}=c,{error:p}=t,[n,E]=m.useState(i[0]),[a,v]=m.useState(),s=g.get(n),S=i.length?s==null?void 0:s.error:"No configured assemblies",h=S||p,[l,N]=m.useState(""),y=s==null?void 0:s.regions,I=!!y,C=y&&((r=y[0])===null||r===void 0?void 0:r.refName)||"";return m.useEffect(()=>{N(C)},[C,n]),e.createElement("div",{className:o.container},h?e.createElement(x.ErrorMessage,{error:h}):null,e.createElement(k,{className:o.importFormContainer},e.createElement("form",{onSubmit:async b=>{var f;if(b.preventDefault(),t.setError(void 0),l)try{(a==null?void 0:a.getDisplayString())===l&&a.hasLocation()?await P({option:a,model:t,assemblyName:n}):!((f=a==null?void 0:a.results)===null||f===void 0)&&f.length?t.setSearchResults(a.results,a.getLabel(),n):s&&await T({input:l,assembly:s,model:t})}catch(R){console.error(R),c.notify(`${R}`,"warning")}}},e.createElement(u,{container:!0,spacing:1,justifyContent:"center",alignItems:"center"},e.createElement(u,{item:!0},e.createElement(d,null,e.createElement(x.AssemblySelector,{onChange:b=>{E(b)},localStorageKey:"lgv",session:c,selected:n}))),e.createElement(u,{item:!0},n?S?e.createElement(V,{style:{color:"red"}}):I?e.createElement(d,null,e.createElement(G,{value:l,setValue:N,selectedAsm:n,setOption:v,model:t})):e.createElement(D,{size:20,disableShrink:!0}):null),e.createElement(u,{item:!0},e.createElement(d,null,e.createElement(w,{type:"submit",disabled:!l,className:o.button,variant:"contained",color:"primary"},"Open")),e.createElement(d,null,e.createElement(w,{disabled:!l,className:o.button,onClick:()=>{t.setError(void 0),t.showAllRegionsInAssembly(n)},variant:"contained",color:"secondary"},"Show all regions in assembly")))))))});export{j as default};
