import{T as V}from"./bootstrap.esm-BOBBXxos.js";import{V as $,D as E}from"./datatables.net-vue3-B28JL-vi.js";import{_ as C}from"./DeleteDialog-GXib_x-K.js";import{p as i,c as h,b as U,w as B,o as w,z as e,k as O,f as s,P as y,U as g,g as x,e as M,h as P,V as A,N as q}from"./vue-CSzJdJby.js";import{$ as N}from"./jquery-BALIvAru.js";import{_ as z}from"./Error-BXO_ADNF.js";import{_ as H}from"./ModalDialog-BxAzqKGJ.js";import"./highlight.js-CWp04Ajj.js";const J={class:"modal-body p-3"},R={class:"row"},W={class:"col"},X={class:"row"},F={class:"mb-3 col-sm-6"},G=e("label",{for:"inputName",class:"form-label"},"Name",-1),I=["disabled"],K={class:"row"},L={class:"mb-3 col-sm-12"},Q=e("label",{for:"inputDescription",class:"form-label"},"Description",-1),Y=["disabled"],Z={class:"modal-footer"},ee=e("button",{type:"button",class:"btn btn-outline-secondary","data-bs-dismiss":"modal"},"Cancel",-1),te=["disabled"],oe={key:0,class:"fa fa-spinner fa-spin loader"},ae={__name:"EnvironmentDialog",setup(u,{expose:T}){const m=i(null),c=i(null),t=i(!0),p=i(!1),n=i(""),v=h(()=>t.value||p.value),f=h(()=>n.value?"Update":"Create");let _={name:"",description:""};const o=i({..._});let l="/json/environments";function j(a){n.value=a,o.value.name=a,m.value.show()}T({edit:j});function D(){if(n.value)l=`/json/environments/${n.value}`;else{t.value=!1;return}t.value=!0,N.ajax({url:l,contentType:"application/json",error:b,success:function(a){o.value.description=a.description,t.value=!1}})}function k(){t.value=!0,N.ajax({url:l,type:n.value?"PUT":"POST",data:JSON.stringify(o.value),contentType:"application/json",error:b,success:function(){window.location.reload()}})}function b(a){c.value.fromXHR(a),t.value=!1}function S(){c.value.clear(),t.value=!0,p.value=!1,n.value="",Object.assign(o.value,_),l="/json/environments"}return(a,r)=>(w(),U(H,{ref_key:"root",ref:m,id:"modalEditEnvironment",title:`${f.value} environment`,onOpening:D,onClosed:S},{default:B(()=>[e("form",{onSubmit:A(k,["prevent"])},[e("div",J,[e("div",R,[e("div",W,[O(z,{ref_key:"error",ref:c,showTitle:!1},null,512)])]),s(),e("div",X,[e("div",F,[G,s(),y(e("input",{type:"text",class:"form-control",id:"inputName",placeholder:"Environment name",disabled:v.value,"onUpdate:modelValue":r[0]||(r[0]=d=>o.value.name=d)},null,8,I),[[g,o.value.name]])])]),s(),e("div",K,[e("div",L,[Q,s(),y(e("textarea",{class:"form-control",rows:"3",placeholder:"Description",id:"inputDescription","onUpdate:modelValue":r[1]||(r[1]=d=>o.value.description=d),disabled:v.value},x(o.value.description),9,Y),[[g,o.value.description]])])])]),s(),e("div",Z,[ee,s(),e("button",{id:"buttonSubmit",class:"btn btn-success ms-auto",type:"submit",disabled:t.value},[s(x(f.value)+" ",1),t.value?(w(),M("i",oe)):P("",!0)],8,te)])],32)]),_:1},8,["title"]))}};$.use(E);q({components:{deletedialog:C,environmentdialog:ae},created(){this.$nextTick(()=>{new E("#tableEnvironments",{stateSave:!0,autoWidth:!1,columns:[{width:"32rem"},{width:"auto"},{width:"8rem",orderable:!1}],layout:{topStart:"search",topEnd:{buttons:[{text:"New environment",className:"btn btn-sm btn-success",attr:{"data-bs-toggle":"modal","data-bs-target":"#modalEditEnvironment","data-testid":"new"}}]}}}),document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(u=>new V(u))})}}).mount("#vue-app");
