"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[5649],{45649:(n,e,o)=>{o.r(e),o.d(e,{default:()=>w});var t=o(7552),c=o(99546),s=o(49204),i=o(39901),r=o(61180),a=o(6986),l=o(8846),d=o(69092),p=o(68446),u=o(75785),f=o(67112),h=o(59099),m=o(69500);const g=(0,p.observer)((function({connectionType:n,model:e,session:o}){const c=n.configEditorComponent||h.S;return(0,m.jsx)(t.Suspense,{fallback:(0,m.jsx)(f.LoadingEllipses,{}),children:(0,m.jsx)(c,{model:{target:e},session:o})})})),C=(0,o(29772).A)((0,m.jsx)("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"}),"OpenInNew");var b=o(93062),j=o(89870),v=o(10240);const x=(0,p.observer)((function({connectionTypeChoices:n,connectionType:e,setConnectionType:o}){const c=n[0];return(0,t.useEffect)((()=>{e||o(c)}),[e,c,o]),(0,m.jsx)("form",{autoComplete:"off",children:e?(0,m.jsx)(b.A,{value:e.name,label:"connectionType",helperText:e.description?(0,m.jsxs)(m.Fragment,{children:[e.description,e.url?(0,m.jsx)(j.A,{href:e.url,rel:"noopener noreferrer",target:"_blank",children:(0,m.jsx)(C,{})}):null]}):null,select:!0,fullWidth:!0,onChange:e=>{o(n.find((n=>n.name===e.target.value)))},variant:"outlined",children:n.map((n=>(0,m.jsx)(v.A,{value:n.name,children:n.displayName||n.name},n.name)))}):null})})),y=(0,u.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)}}))),k=["Select a Connection Type","Configure Connection"],w=(0,p.observer)((function({model:n}){const[e,o]=(0,t.useState)(),[p,u]=(0,t.useState)(),[f,h]=(0,t.useState)(0),{classes:C}=y(),b=(0,c.getSession)(n),{pluginManager:j}=(0,c.getEnv)(b),v=(0,t.useMemo)((()=>e?.configSchema.create({connectionId:p},(0,c.getEnv)(n))),[p,e,n]);return(0,m.jsx)("div",{className:C.root,children:(0,m.jsx)(i.A,{className:C.stepper,activeStep:f,orientation:"vertical",children:k.map((t=>(0,m.jsxs)(r.A,{children:[(0,m.jsx)(a.A,{children:t}),(0,m.jsxs)(l.A,{children:[0===f?(0,m.jsx)(x,{connectionTypeChoices:j.getConnectionElements(),connectionType:e,setConnectionType:n=>{o(n),n&&u(`${n.name}-${Date.now()}`)}}):e&&v?(0,m.jsx)(g,{connectionType:e,model:v,session:b}):null,(0,m.jsxs)("div",{className:C.actionsContainer,children:[(0,m.jsx)(d.A,{disabled:0===f,onClick:()=>{h(f-1)},className:C.button,children:"Back"}),(0,m.jsx)(d.A,{disabled:!(0===f&&e||1===f&&v),variant:"contained",color:"primary",onClick:()=>{if(f===k.length-1){if(v&&(0,s.M)(b)){const n=b.addConnectionConf(v);b.makeConnection(n)}else b.notify("No config model to add");(0,c.isSessionModelWithWidgets)(b)&&b.hideWidget(n)}else h(f+1)},className:C.button,"data-testid":"addConnectionNext",children:f===k.length-1?"Connect":"Next"})]})]})]},t)))})})}))},49204:(n,e,o)=>{o.d(e,{F:()=>i,M:()=>r});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 r=e.connectionInstances.push({...c,name:i,type:s,configuration:o});return e.connectionInstances[r-1]},prepareToBreakConnection(n){const o=e,c=[],s={},i=(0,t.readConfObject)(n,"name"),r=e.connectionInstances.find((n=>n.name===i));if(r){for(const n of r.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 r(n){return(0,s.qk)(n)&&"connectionInstances"in n}}}]);
//# sourceMappingURL=5649.6e461a22.chunk.js.map