import{u as E,R as e,av as T,P as w,aw as k,ax as C,ay as d,az as o,aA as N,B as f,aB as R,aC as D,c as S,D as x,T as y,ae as L,e as A}from"./index-Bm2SqMk3.js";function B({searchResults:m,assemblyName:u,model:t,handleClose:i}){const l=E.getSession(t),{pluginManager:b}=E.getEnv(l),{assemblyManager:h}=l,g=u||t.displayedRegions[0].assemblyName,c=h.get(g);if(!c)throw new Error(`assembly ${g} not found`);if(!c.regions)throw new Error(`assembly ${g} regions not loaded`);function p(n){var a;if(n){const r=b.pluggableConfigSchemaType("track"),s=R(r,D(t),n);return((a=s==null?void 0:s.name)===null||a===void 0?void 0:a.value)||""}return""}async function v(n){var a;try{const r=(a=c==null?void 0:c.regions)===null||a===void 0?void 0:a.find(s=>n===s.refName);r?(t.setDisplayedRegions([r]),t.showAllRegions()):await t.navToLocString(n,g)}catch(r){console.warn(r),l.notify(`${r}`,"warning")}}return e.createElement(T,{component:w},e.createElement(k,null,e.createElement(C,null,e.createElement(d,null,e.createElement(o,null,"Name"),e.createElement(o,{align:"right"},"Location"),e.createElement(o,{align:"right"},"Track"),e.createElement(o,{align:"right"}))),e.createElement(N,null,m.map(n=>e.createElement(d,{key:n.getId()},e.createElement(o,{component:"th",scope:"row"},n.getLabel()),e.createElement(o,{align:"right"},n.getLocation()),e.createElement(o,{align:"right"},p(n.getTrackId())||"N/A"),e.createElement(o,{align:"right"},e.createElement(f,{onClick:async()=>{try{await v(n.getLocation()||n.getLabel());const a=n.getTrackId();a&&t.showTrack(a)}catch(a){console.error(a),l.notifyError(`${a}`,a)}i()},color:"primary",variant:"contained"},"Go")))))))}function $({model:m,assemblyName:u,searchQuery:t,searchResults:i,handleClose:l}){return e.createElement(S.Dialog,{open:!0,maxWidth:"xl",onClose:l,title:"Search results"},e.createElement(x,null,i!=null&&i.length?e.createElement(e.Fragment,null,e.createElement(y,null,"Showing results for ",e.createElement("b",null,t)),e.createElement(B,{model:m,handleClose:l,assemblyName:u,searchResults:i})):e.createElement(y,null,"No results found for ",e.createElement("b",null,t))),e.createElement(L,null),e.createElement(A,null,e.createElement(f,{onClick:()=>{l()},color:"primary"},"Cancel")))}export{$ as default};
