"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4456],{44456:(n,e,o)=>{o.r(e),o.d(e,{default:()=>y});var t=o(7552),c=o(99546),s=o(49204),i=o(39901),a=o(61180),r=o(6986),l=o(8846),d=o(69092),u=o(68446),p=o(75785),f=o(67112),m=o(59099),g=o(69500);const C=(0,u.observer)(function({connectionType:n,model:e,session:o}){const c=n.configEditorComponent||m.S;return(0,g.jsx)(t.Suspense,{fallback:(0,g.jsx)(f.LoadingEllipses,{}),children:(0,g.jsx)(c,{model:{target:e},session:o})})});var h=o(93062),b=o(10240);const j=(0,u.observer)(function({connectionTypeChoices:n,connectionType:e,setConnectionType:o}){const c=n[0];return(0,t.useEffect)(()=>{e||o(c)},[e,c,o]),(0,g.jsx)("form",{autoComplete:"off",children:e?(0,g.jsx)(h.A,{value:e.name,label:"connectionType",helperText:e.description?(0,g.jsxs)(g.Fragment,{children:[e.description,e.url?(0,g.jsx)(f.ExternalLink,{href:e.url}):null]}):null,select:!0,fullWidth:!0,onChange:e=>{o(n.find(n=>n.name===e.target.value))},variant:"outlined",children:n.map(n=>(0,g.jsx)(b.A,{value:n.name,children:n.displayName||n.name},n.name))}):null})}),v=(0,p.n9)()(n=>({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)}})),x=["Select a Connection Type","Configure Connection"],y=(0,u.observer)(function({model:n}){const[e,o]=(0,t.useState)(),[u,p]=(0,t.useState)(),[f,m]=(0,t.useState)(0),{classes:h}=v(),b=(0,c.getSession)(n),{pluginManager:y}=(0,c.getEnv)(b),k=(0,t.useMemo)(()=>e?.configSchema.create({connectionId:u},(0,c.getEnv)(n)),[u,e,n]);return(0,g.jsx)("div",{className:h.root,children:(0,g.jsx)(i.A,{className:h.stepper,activeStep:f,orientation:"vertical",children:x.map(t=>(0,g.jsxs)(a.A,{children:[(0,g.jsx)(r.A,{children:t}),(0,g.jsxs)(l.A,{children:[0===f?(0,g.jsx)(j,{connectionTypeChoices:y.getConnectionElements(),connectionType:e,setConnectionType:n=>{o(n),n&&p(`${n.name}-${Date.now()}`)}}):e&&k?(0,g.jsx)(C,{connectionType:e,model:k,session:b}):null,(0,g.jsxs)("div",{className:h.actionsContainer,children:[(0,g.jsx)(d.A,{disabled:0===f,onClick:()=>{m(f-1)},className:h.button,children:"Back"}),(0,g.jsx)(d.A,{disabled:!(0===f&&e||1===f&&k),variant:"contained",color:"primary",onClick:()=>{if(f===x.length-1){if(k&&(0,s.M)(b)){const n=b.addConnectionConf(k);b.makeConnection(n)}else b.notify("No config model to add");(0,c.isSessionModelWithWidgets)(b)&&b.hideWidget(n)}else m(f+1)},className:h.button,"data-testid":"addConnectionNext",children:f===x.length-1?"Connect":"Next"})]})]})]},t))})})})},49204:(n,e,o)=>{o.d(e,{F:()=>i,M:()=>a});var t=o(68584);if(8792==o.j)var c=o(36422);var s=o(45858);function i(n){return c.types.model({connectionInstances:c.types.array(n.pluggableMstType("connection","stateModel"))}).views(n=>({get connections(){const{jbrowse:e}=n;return e.connections}})).actions(e=>({makeConnection(o,c={}){const s=o.type;if(!s)throw new Error("track configuration has no `type` listed");const i=(0,t.readConfObject)(o,"name");if(!n.getConnectionType(s))throw new Error(`unknown connection type ${s}`);const a=e.connectionInstances.push({...c,name:i,type:s,configuration:o});return e.connectionInstances[a-1]},prepareToBreakConnection(n){const o=e,c=[],s={},i=(0,t.readConfObject)(n,"name"),a=e.connectionInstances.find(n=>n.name===i);if(a){for(const n of a.tracks){const e=o.getReferring(n);o.removeReferring(e,n,c,s)}return[()=>{for(const n of c)n();this.breakConnection(n)},s]}},breakConnection(n){const o=(0,t.readConfObject)(n,"name"),c=e.connectionInstances.find(n=>n.name===o);if(!c)throw new Error(`no connection found with name ${o}`);e.connectionInstances.remove(c)},deleteConnection(n){const{jbrowse:o}=e;return o.deleteConnectionConf(n)},addConnectionConf(n){const{jbrowse:o}=e;return o.addConnectionConf(n)},clearConnections(){e.connectionInstances.clear()}}))}function a(n){return(0,s.qk)(n)&&"connectionInstances"in n}}}]);
//# sourceMappingURL=4456.341094e8.chunk.js.map