"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[7412],{17412:function(n,e,t){t.r(e),t.d(e,{default:function(){return k}});var o=t(96234),c=t(81073),a=t(28599),i=t(94702),r=t(80508),s=t(53492),l=t(94534),u=t(22714),d=t(80975),p=t(90550),f=t(40909),m=t(30969),h=t(5634),g=t(37574),x=(0,p.observer)((function(n){var e=n.connectionType,t=n.model,o=n.setModelReady,c=e.configEditorComponent||h.wP;return(0,g.jsx)(m.Suspense,{fallback:(0,g.jsx)("div",{children:"Loading..."}),children:(0,g.jsx)(c,{model:{target:t},setModelReady:o})})})),j=t(32343),C=t(1720),v=t(7690),b=t(67897);var y=function(n){var e=n.connectionTypeChoices,t=n.connectionType,o=n.setConnectionType;return(0,m.useEffect)((function(){t.name||o(e[0])})),t.name?(0,g.jsx)("form",{autoComplete:"off",children:(0,g.jsx)(v.Z,{value:t.name,label:"connectionType",helperText:t.description?(0,g.jsxs)(g.Fragment,{children:[t.description,t.url?(0,g.jsx)(j.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(n){o(e.find((function(e){return e.name===n.target.value})))},variant:"outlined",children:e.map((function(n){return(0,g.jsx)(C.Z,{value:n.name,children:n.displayName||n.name},n.name)}))})}):null},Z=(0,u.Z)((function(n){return{root:{marginTop:n.spacing(1)},stepper:{backgroundColor:n.palette.background.default},button:{marginTop:n.spacing(1),marginRight:n.spacing(1)},actionsContainer:{marginBottom:n.spacing(2)}}})),T=["Select a Connection Type","Configure Connection"];var k=(0,p.observer)((function(n){var e=n.model,t=(0,m.useState)({}),u=(0,o.Z)(t,2),p=u[0],h=u[1],j=(0,m.useState)({}),C=(0,o.Z)(j,2),v=C[0],b=C[1],k=(0,m.useState)(!0),w=(0,o.Z)(k,2),S=w[0],N=w[1],E=(0,m.useState)(0),_=(0,o.Z)(E,2),M=_[0],R=_[1],B=Z(),I=(0,c.getSession)(e),W=(0,f.getEnv)(I).pluginManager;function D(n){h(n),b(n.configSchema.create({connectionId:"".concat(n.name,"-").concat(Date.now())},(0,f.getEnv)(e)))}function F(){switch(M){case 0:return(0,g.jsx)(y,{connectionTypeChoices:W.getElementTypesInGroup("connection"),connectionType:p,setConnectionType:D});case 1:return(0,g.jsx)(x,{connectionType:p,model:v,setModelReady:N});default:return(0,g.jsx)(d.Z,{children:"Unknown step"})}}function G(){M===T.length-1?function(){var n=I.addConnectionConf(v);I.makeConnection(n),I.hideWidget(e)}():R(M+1)}function L(){R(M-1)}return(0,g.jsx)("div",{className:B.root,children:(0,g.jsx)(l.Z,{className:B.stepper,activeStep:M,orientation:"vertical",children:T.map((function(n){return(0,g.jsxs)(i.Z,{children:[(0,g.jsx)(s.Z,{children:n}),(0,g.jsxs)(r.Z,{children:[F(),(0,g.jsxs)("div",{className:B.actionsContainer,children:[(0,g.jsx)(a.Z,{disabled:0===M,onClick:L,className:B.button,children:"Back"}),(0,g.jsx)(a.Z,{disabled:!(0===M&&p.name||1===M&&v&&S),variant:"contained",color:"primary",onClick:G,className:B.button,"data-testid":"addConnectionNext",children:M===T.length-1?"Connect":"Next"})]})]})]},n)}))})})}))}}]);
//# sourceMappingURL=7412.bf4bd7ef.chunk.js.map