"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8447],{48447:(e,t,n)=>{n.r(t),n.d(t,{default:()=>N});var r=n(7552),a=n(82725),i=n(68446),o=n(99546),l=n(37565),s=n(38033),c=n(943),d=n(75785),m=n(66684);const u=(0,d.n9)()((e=>({paper:{overflowY:"auto",height:"100%",zIndex:e.zIndex.drawer,outline:"none",background:e.palette.background.default},resizeHandle:{width:4,position:"fixed",top:0,zIndex:e.zIndex.drawer+1}}))),g=(0,i.observer)((function({children:e,session:t}){const{drawerPosition:n,drawerWidth:a}=t,{classes:i}=u(),o=(0,r.useRef)(null);return(0,r.useEffect)((()=>{function e(e){if(e.target instanceof Element&&o?.current?.contains(e.target)){const e=t.visibleWidget?.view?.id;e&&t.setFocusedViewId(e)}}return document.addEventListener("mousedown",e),document.addEventListener("keydown",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",e)}}),[o,t]),r.createElement(c.A,{ref:o,className:i.paper,elevation:16,square:!0},"right"===n?r.createElement(m.A,{onDrag:t.resizeDrawer,className:i.resizeHandle,vertical:!0}):null,e,"left"===n?r.createElement(m.A,{onDrag:t.resizeDrawer,className:i.resizeHandle,style:{left:a},vertical:!0}):null)}));var E=n(27281),w=n(17515),h=n(48171),p=n(98360),v=n(36715),f=n(29629),b=n(61723),A=n(89003),k=n(2051),y=n(78126),C=n(84313),W=n(21909),z=n(64359);const D=(0,d.n9)()((e=>({formControl:{margin:0},spacer:{flexGrow:1},drawerSelect:{margin:0,color:e.palette.secondary.contrastText},dropDownIcon:{color:e.palette.secondary.contrastText},headerFocused:{background:e.palette.secondary.main},headerUnfocused:{background:e.palette.secondary.dark}}))),T=(0,i.observer)((function({session:e,setToolbarHeight:t}){const{classes:n}=D(),a=e.focusedViewId,i=e.visibleWidget?.view?.id;return r.createElement(E.A,{position:"sticky",className:a===i?n.headerFocused:n.headerUnfocused,ref:e=>t(e?.getBoundingClientRect().height||0)},r.createElement(w.A,{disableGutters:!0},r.createElement(x,{session:e}),r.createElement("div",{className:n.spacer}),r.createElement(H,{session:e})))})),x=(0,i.observer)((function({session:e}){const{visibleWidget:t,activeWidgets:n}=e,{classes:a}=D(),{pluginManager:i}=(0,o.getEnv)(e);return r.createElement(h.A,{className:a.formControl},r.createElement(p.A,{value:t?.id,"data-testid":"widget-drawer-selects",className:a.drawerSelect,classes:{icon:a.dropDownIcon},renderValue:t=>{const n=e.activeWidgets.get(t);if(!n)return r.createElement(v.A,{variant:"h6",color:"inherit"},"Unknown widget");const a=i.getWidgetType(n.type),{HeadingComponent:o,heading:l}=a;return o?r.createElement(o,{model:n}):r.createElement(v.A,{variant:"h6",color:"inherit"},l)},onChange:t=>{const n=e.activeWidgets.get(t.target.value);n?e.showWidget(n):e.notify(`Widget not found ${t.target.value}`,"warning")}},[...n.values()].map((t=>{const n=i.getWidgetType(t.type),{HeadingComponent:a,heading:o}=n;return r.createElement(f.A,{"data-testid":`widget-drawer-selects-item-${t.type}`,key:t.id,value:t.id},a?r.createElement(a,{model:t}):r.createElement(v.A,{variant:"h6",color:"inherit"},o),r.createElement(b.A,{"data-testid":`${t.type}-drawer-delete`,color:"inherit","aria-label":"Delete",onClick:()=>e.hideWidget(t)},r.createElement(y.A,null)))}))))})),H=(0,i.observer)((function({session:e}){const[t,n]=(0,r.useState)(null),{drawerPosition:a,visibleWidget:i}=e;return r.createElement(r.Fragment,null,r.createElement(b.A,{color:"inherit",onClick:e=>n(e.currentTarget)},r.createElement(z.A,null)),r.createElement(A.A,{title:"Minimize drawer"},r.createElement(b.A,{"data-testid":"drawer-minimize",color:"inherit",onClick:()=>{e.notify(`Drawer minimized, click button on ${a} side of screen to re-open`,"info"),e.minimizeWidgetDrawer()}},r.createElement(W.A,null))),r.createElement(A.A,{title:"Close drawer"},r.createElement(b.A,{color:"inherit",onClick:()=>e.hideWidget(i)},r.createElement(C.A,null))),r.createElement(k.A,{anchorEl:t,open:Boolean(t),onClose:()=>n(null)},["left","right"].map((t=>r.createElement(f.A,{key:t,selected:"option"===a,onClick:()=>{e.setDrawerPosition(t),n(null)}},t)))))})),I=T,N=(0,i.observer)((function({session:e}){const{visibleWidget:t}=e,{pluginManager:n}=(0,o.getEnv)(e),i=t?n.evaluateExtensionPoint("Core-replaceWidget",n.getWidgetType(t.type).ReactComponent,{session:e,model:t}):null,[c,d]=(0,r.useState)(0);return r.createElement(g,{session:e},r.createElement(I,{session:e,setToolbarHeight:d}),r.createElement(r.Suspense,{fallback:r.createElement(l.A,null)},r.createElement(a.tH,{FallbackComponent:({error:e})=>r.createElement(s.A,{error:e})},i?r.createElement(r.Fragment,null,r.createElement(i,{model:t,session:e,toolbarHeight:c}),r.createElement("div",{style:{height:300}})):null)))}))}}]);
//# sourceMappingURL=8447.f8721f56.chunk.js.map