import{o as E,br as N,R as e,a as i,c as h,b3 as I,b4 as x,b5 as k,f as M,d as w,ac as y,M as R,m as q,u as f,bs as O,bt as W,bu as _,bv as B,B as v,bw as j}from"./index-Bm2SqMk3.js";const D=E(function({connectionType:a,model:t,session:o}){const r=a.configEditorComponent||N;return e.createElement(i.Suspense,{fallback:e.createElement(h.LoadingEllipses,null)},e.createElement(r,{model:{target:t},session:o}))});var m={},S;function L(){if(S)return m;S=1;var a=I();Object.defineProperty(m,"__esModule",{value:!0}),m.default=void 0;var t=a(x()),o=k();return m.default=(0,t.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 V=L();const z=M(V),F=E(function({connectionTypeChoices:t,connectionType:o,setConnectionType:r}){const d=t[0];return i.useEffect(()=>{o||r(d)},[o,d,r]),e.createElement("form",{autoComplete:"off"},o?e.createElement(w,{value:o.name,label:"connectionType",helperText:o.description?e.createElement(e.Fragment,null,o.description,o.url?e.createElement(y,{href:o.url,rel:"noopener noreferrer",target:"_blank"},e.createElement(z,null)):null):null,select:!0,fullWidth:!0,onChange:n=>{r(t.find(p=>p.name===n.target.value))},variant:"outlined"},t.map(n=>e.createElement(R,{key:n.name,value:n.name},n.displayName||n.name))):null)}),T=q()(a=>({root:{marginTop:a.spacing(1)},stepper:{backgroundColor:a.palette.background.default},button:{marginTop:a.spacing(1),marginRight:a.spacing(1)},actionsContainer:{marginBottom:a.spacing(2)}})),g=["Select a Connection Type","Configure Connection"],H=E(function({model:a}){const[t,o]=i.useState(),[r,d]=i.useState(),[n,p]=i.useState(0),{classes:l}=T(),s=f.getSession(a),{pluginManager:b}=f.getEnv(s),c=i.useMemo(()=>t==null?void 0:t.configSchema.create({connectionId:r},f.getEnv(a)),[r,t,a]);return e.createElement("div",{className:l.root},e.createElement(O,{className:l.stepper,activeStep:n,orientation:"vertical"},g.map(C=>e.createElement(W,{key:C},e.createElement(_,null,C),e.createElement(B,null,n===0?e.createElement(F,{connectionTypeChoices:b.getConnectionElements(),connectionType:t,setConnectionType:u=>{o(u),u&&d(`${u.name}-${Date.now()}`)}}):t&&c?e.createElement(D,{connectionType:t,model:c,session:s}):null,e.createElement("div",{className:l.actionsContainer},e.createElement(v,{disabled:n===0,onClick:()=>{p(n-1)},className:l.button},"Back"),e.createElement(v,{disabled:!(n===0&&t||n===1&&c),variant:"contained",color:"primary",onClick:()=>{if(n===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(a)}else p(n+1)},className:l.button,"data-testid":"addConnectionNext"},n===g.length-1?"Connect":"Next")))))))});export{H as default};
