"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[7412],{17412:function(e,n,t){t.r(n),t.d(n,{default:function(){return k}});var o=t(96234),c=t(30969),a=t(81073),i=t(33359),r=t(60548),s=t(60059),l=t(26952),u=t(80160),d=t(72097),p=t(2374),f=t(90550),m=t(40909),h=t(56699),g=t(37574),x=(0,f.observer)((function(e){var n=e.connectionType,t=e.model,o=e.setModelReady,a=n.configEditorComponent||h.wP;return(0,g.jsx)(c.Suspense,{fallback:(0,g.jsx)("div",{children:"Loading..."}),children:(0,g.jsx)(a,{model:{target:t},setModelReady:o})})})),j=t(87006),C=t(94551),v=t(2689),b=t(16374);var y=function(e){var n=e.connectionTypeChoices,t=e.connectionType,o=e.setConnectionType;return(0,c.useEffect)((function(){t.name||o(n[0])})),t.name?(0,g.jsx)("form",{autoComplete:"off",children:(0,g.jsx)(j.Z,{value:t.name,label:"connectionType",helperText:t.description?(0,g.jsxs)(g.Fragment,{children:[t.description,t.url?(0,g.jsx)(C.Z,{href:t.url,rel:"noopener noreferrer",target:"_blank",color:"secondary",children:(0,g.jsx)(b.Z,{})}):null]}):null,select:!0,fullWidth:!0,onChange:function(e){o(n.find((function(n){return n.name===e.target.value})))},variant:"outlined",children:n.map((function(e){return(0,g.jsx)(v.Z,{value:e.name,children:e.displayName||e.name},e.name)}))})}):null},Z=(0,p.ZL)()((function(e){return{root:{marginTop:e.spacing(1)},stepper:{backgroundColor:e.palette.background.default},button:{marginTop:e.spacing(1),marginRight:e.spacing(1)},actionsContainer:{marginBottom:e.spacing(2)}}})),T=["Select a Connection Type","Configure Connection"];var k=(0,f.observer)((function(e){var n=e.model,t=(0,c.useState)({}),p=(0,o.Z)(t,2),f=p[0],h=p[1],j=(0,c.useState)({}),C=(0,o.Z)(j,2),v=C[0],b=C[1],k=(0,c.useState)(!0),w=(0,o.Z)(k,2),S=w[0],N=w[1],E=(0,c.useState)(0),_=(0,o.Z)(E,2),M=_[0],R=_[1],B=Z().classes,I=(0,a.getSession)(n),L=(0,m.getEnv)(I).pluginManager;function W(e){h(e),b(e.configSchema.create({connectionId:"".concat(e.name,"-").concat(Date.now())},(0,m.getEnv)(n)))}function D(){switch(M){case 0:return(0,g.jsx)(y,{connectionTypeChoices:L.getElementTypesInGroup("connection"),connectionType:f,setConnectionType:W});case 1:return(0,g.jsx)(x,{connectionType:f,model:v,setModelReady:N});default:return(0,g.jsx)(i.Z,{children:"Unknown step"})}}function F(){M===T.length-1?function(){var e=I.addConnectionConf(v);I.makeConnection(e),I.hideWidget(n)}():R(M+1)}function G(){R(M-1)}return(0,g.jsx)("div",{className:B.root,children:(0,g.jsx)(r.Z,{className:B.stepper,activeStep:M,orientation:"vertical",children:T.map((function(e){return(0,g.jsxs)(s.Z,{children:[(0,g.jsx)(l.Z,{children:e}),(0,g.jsxs)(u.Z,{children:[D(),(0,g.jsxs)("div",{className:B.actionsContainer,children:[(0,g.jsx)(d.Z,{disabled:0===M,onClick:G,className:B.button,children:"Back"}),(0,g.jsx)(d.Z,{disabled:!(0===M&&f.name||1===M&&v&&S),variant:"contained",color:"primary",onClick:F,className:B.button,"data-testid":"addConnectionNext",children:M===T.length-1?"Connect":"Next"})]})]})]},e)}))})})}))}}]);
//# sourceMappingURL=7412.a3ed0c36.chunk.js.map