import{o as C,bt as I,R as t,r as i,b as N,aW as x,aX as h,aY as k,g as M,G as y,ai as R,M as q,m as w,u as f,bA as O,bB as W,bC as B,bD as _,a as v}from"./rpcWorker-CVTx5FIM.js";function D(e){return"id"in e&&"name"in e&&"root"in e}function j(e){return D(e)&&"connectionInstances"in e}const L=C(function({connectionType:e,model:n,session:o}){const r=e.configEditorComponent||I;return t.createElement(i.Suspense,{fallback:t.createElement(N.LoadingEllipses,null)},t.createElement(r,{model:{target:n},session:o}))});var m={},S;function V(){if(S)return m;S=1;var e=x();Object.defineProperty(m,"__esModule",{value:!0}),m.default=void 0;var n=e(h()),o=k();return m.default=(0,n.default)((0,o.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"),m}var z=V(),A=M(z);const F=C(function({connectionTypeChoices:n,connectionType:o,setConnectionType:r}){const d=n[0];return i.useEffect(()=>{o||r(d)},[o,d,r]),t.createElement("form",{autoComplete:"off"},o?t.createElement(y,{value:o.name,label:"connectionType",helperText:o.description?t.createElement(t.Fragment,null,o.description,o.url?t.createElement(R,{href:o.url,rel:"noopener noreferrer",target:"_blank"},t.createElement(A,null)):null):null,select:!0,fullWidth:!0,onChange:a=>{r(n.find(p=>p.name===a.target.value))},variant:"outlined"},n.map(a=>t.createElement(q,{key:a.name,value:a.name},a.displayName||a.name))):null)}),T=w()(e=>({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)}})),g=["Select a Connection Type","Configure Connection"],$=C(function({model:e}){const[n,o]=i.useState(),[r,d]=i.useState(),[a,p]=i.useState(0),{classes:l}=T(),s=f.getSession(e),{pluginManager:b}=f.getEnv(s),c=i.useMemo(()=>n==null?void 0:n.configSchema.create({connectionId:r},f.getEnv(e)),[r,n,e]);return t.createElement("div",{className:l.root},t.createElement(O,{className:l.stepper,activeStep:a,orientation:"vertical"},g.map(E=>t.createElement(W,{key:E},t.createElement(B,null,E),t.createElement(_,null,a===0?t.createElement(F,{connectionTypeChoices:b.getConnectionElements(),connectionType:n,setConnectionType:u=>{o(u),u&&d(`${u.name}-${Date.now()}`)}}):n&&c?t.createElement(L,{connectionType:n,model:c,session:s}):null,t.createElement("div",{className:l.actionsContainer},t.createElement(v,{disabled:a===0,onClick:()=>{p(a-1)},className:l.button},"Back"),t.createElement(v,{disabled:!(a===0&&n||a===1&&c),variant:"contained",color:"primary",onClick:()=>{if(a===g.length-1){if(c&&j(s)){const u=s.addConnectionConf(c);s.makeConnection(u)}else s.notify("No config model to add");f.isSessionModelWithWidgets(s)&&s.hideWidget(e)}else p(a+1)},className:l.button,"data-testid":"addConnectionNext"},a===g.length-1?"Connect":"Next")))))))});export{$ as default};
