import{r as e,h as s,H as i}from"./p-ec7718e6.js";import{T as n}from"./p-2d511d0e.js";import"./p-35c7f358.js";import"./p-83f217d4.js";import{D as o}from"./p-3c3b4f3f.js";import"./p-d66fb38c.js";import"./p-e249790d.js";import{D as a,a as t}from"./p-552063c3.js";import{S as r,a as d}from"./p-9c626387.js";import"./p-ae623d5d.js";import{i as c}from"./p-949ef1f9.js";import{D as m}from"./p-a8682d9e.js";import{V as p}from"./p-ad6da9fe.js";import{F as l,M as v}from"./p-598a7fd7.js";import{A as w}from"./p-c788c392.js";import{I as f}from"./p-6cf8ecf7.js";class u{constructor(e){this.api=e}onSubmit(e){const{values:{name:s,workspaceId:i,type:n}}=e.detail;return new Promise(((e,o)=>{this.api.createProduct(s,i,n).then((()=>{e({events:[new f("","")],navigation:{type:"navigation",direction:"back"}})})).catch((()=>{o(["Unexpected error"])}))}))}}const h={"devingen-workspaces":o.decode({_id:"devingen-workspaces",base:"devingen-dev",fields:[new a("_created","Created").setDataType(t.Unix).setDateFormat("DD MMM YYYY HH:mm"),new n("name","Name")],name:"devingen-workspaces"})},g=e=>l.decode({_id:"new-product-form",base:"devingen-dev",title:"New domain",table:h["devingen-workspaces"],type:w.FormView,handler:new u(e),ui:{fields:[{field:new m("workspaceId")},{field:new n("name","Name").addInterceptor("onSubmit",new p(2,32)).addInterceptor("onSubmit",new v).require()},{field:new r("type","Product Type",[new d("Damga","damga",void 0,"Proxy service that generates SSL certificate for your domains.")],"","radioCard").require()}]}});class b{constructor(e){this.api=e}onSubmit(e){const{values:{name:s}}=e.detail;return new Promise(((e,i)=>{this.api.createWorkspace(s).then((()=>{e({events:[new f("","")],navigation:{type:"navigation",direction:"back"}})})).catch((()=>{i(["Unexpected error"])}))}))}}const j=class{constructor(s){e(this,s),this.isCreateWorkspaceFormShown=!1,this.isCreateProductFormShown=!1}onInvalidation(e){this.isCreateWorkspaceFormShown=!1,this.isCreateProductFormShown=!1}componentWillLoad(){}render(){const{isCreateProductFormShown:e,isCreateWorkspaceFormShown:o,products:a,selectedWorkspaceToCreateProduct:t,workspaceOwnerships:r}=this;return r&&a?s(i,null,s("div",{class:"container"},s("div",{class:"row"},r.map((e=>{const{workspace:i}=e;return s("div",{class:"col-sm-12"},s("h2",{class:"mt-3"},i.name),s("div",{class:"row"},a.filter((e=>e.workspace._id===i._id)).map((e=>s("div",{class:"col-sm-12 col-md-4"},s("stencil-route-link",{url:"/products/"+e._id},s("dvn-card",{bodyLeaned:!0,elevation:0,leaned:!0,selectable:!0,tint:"primary"},s("devingen-product-card",{product:e})))))),s("div",{class:"col-sm-12 col-md-4"},s("dvn-card",{bodyLeaned:!0,elevation:0,leaned:!0,selectable:!0,tint:"primary"},s("devingen-product-card",{onClick:()=>{this.isCreateProductFormShown=!0,this.selectedWorkspaceToCreateProduct=i._id}})))))}))),s("div",{class:"row"},s("div",{class:"col-sm-12 col-md-4 mt-3 pt-3"},s("dvn-button",{leaned:!0,onClick:()=>this.isCreateWorkspaceFormShown=!0,view:"flat"},s("dvn-icon",{iconName:"uil uil-plus"}),"Add new workspace")))),o&&s("dvn-dialog",{raw:!0,shown:!0,onDismiss:()=>this.isCreateWorkspaceFormShown=!1},s("dvn-app-view-form-view",{view:(d=this.apiDevingen,l.decode({_id:"new-workspace-form",base:"devingen-dev",title:"New domain",table:h["devingen-workspaces"],type:w.FormView,handler:new b(d),ui:{fields:[{field:new n("name","Name").addInterceptor("onSubmit",new p(2,32)).addInterceptor("onSubmit",new v).require()}]}}))})),e&&s("dvn-dialog",{raw:!0,shown:!0,onDismiss:()=>this.isCreateProductFormShown=!1},s("dvn-app-view-form-view",{view:g(this.apiDevingen),params:{workspaceId:t,type:"damga"}}))):s("div",{class:"d-flex justify-content-center pt-3"},s("dvn-progress",{indefinite:!0}));var d}};c(j);export{j as devingen_home_page}