import{Y as e,a4 as a,a5 as t,ap as i,c as s,ax as l,C as o,aq as d,k as p,a1 as r,$ as n,Z as c,ao as u,a0 as m,an as f}from"./index.3938ccd1.js";import{Q as v,a as y}from"./QItem.7059602a.js";import{a as h,Q as _}from"./QMenu.6d3c6154.js";import{Q as b}from"./QChip.1c0a47f0.js";import{C as g}from"./ClosePopup.e34b0fd0.js";import{l as k}from"./api.bf47c78e.js";import{u as A}from"./use-quasar.63a27b45.js";import{_ as j}from"./plugin-vue_export-helper.21dcd24c.js";const x={class:"relative",style:{height:"205px",width:"100%"}},C=["src"],w={key:1,src:"/assets/placeholder.1a8352b9.png"},q={class:"text-h6"},D={class:"text-subtitle2"},P={key:0,class:"text-right"};var Q=j({__name:"AppCard",props:{app:{type:Object,required:!0},showActions:{type:Boolean,required:!1,default:!1},showPrivateStatus:{type:Boolean,required:!1,default:!1}},emits:["updated","deleted"],setup(j,{emit:Q}){const E=Q,I={}.API_URL+"/file/",$=A();function z(e,a){k.patch(`t3Apps/${e.id}`,{json:a}).then((()=>{$.loading.hide(),$.notify({message:"App has been updated successfully.",color:"primary",icon:"done"}),E("deleted",e)})).catch((e=>{$.loading.hide(),$.notify({message:"Error: App couldn't be updated! "+e,color:"negative",icon:"error",timeout:0,actions:[{label:"Dismiss",color:"grey-5",handler:()=>{}}]})}))}return(A,Q)=>(e(),a(f,{class:"app-card"},{default:t((()=>[(e(),a(i,{key:0,class:"app-card-action-btn hidden absolute right-2.5 top-2.5",id:"app-card-action-btn-"+j.app.id,dense:"",flat:"",size:"md",round:"",color:"primary",icon:"more_vert"},{default:t((()=>[s(h,{"onUpdate:modelValue":Q[3]||(Q[3]=e=>{return a="app-card-action-btn-"+j.app.id,void document.getElementById(a).classList.toggle("active");var a})},{default:t((()=>[s(_,{style:{"min-width":"70px"}},{default:t((()=>[s(v,{dense:"",to:"/apps-library/"+j.app.id+"/edit"},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"edit"})])),_:1}),s(y,null,{default:t((()=>[...Q[4]||(Q[4]=[o("Edit",-1)])])),_:1})])),_:1},8,["to"]),s(d),p((e(),a(v,{clickable:"",dense:"",onClick:Q[0]||(Q[0]=e=>{return a=j.app,void $.dialog({title:"Delete Application",message:`Are you sure you want to delete (${a.name}) application?`,ok:{label:"Delete",color:"red-8",flat:!0},cancel:!0,persistent:!0}).onOk((()=>{$.loading.show(),k.delete(`t3Apps/${a.id}`).then((()=>{$.loading.hide(),$.notify({message:"App has been deleted successfully.",color:"primary",icon:"done"}),E("deleted",a)})).catch((e=>{$.loading.hide(),$.notify({message:"Error: App couldn't be deleted! "+e,color:"negative",icon:"error",timeout:0,actions:[{label:"Dismiss",color:"grey-5",handler:()=>{}}]})}))})).onCancel((()=>{})).onDismiss((()=>{}));var a})},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"delete"})])),_:1}),s(y,null,{default:t((()=>[...Q[5]||(Q[5]=[o("Delete",-1)])])),_:1})])),_:1})),[[g]]),s(d),!0===j.app.private?p((e(),a(v,{key:0,clickable:"",dense:"",onClick:Q[1]||(Q[1]=e=>z(j.app,{private:!1}))},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"visibility"})])),_:1}),s(y,null,{default:t((()=>[...Q[6]||(Q[6]=[o("Make public",-1)])])),_:1})])),_:1})),[[g]]):r("",!0),!1===j.app.private?p((e(),a(v,{key:1,clickable:"",dense:"",onClick:Q[2]||(Q[2]=e=>z(j.app,{private:!0}))},{default:t((()=>[s(y,{avatar:""},{default:t((()=>[s(l,{name:"visibility_off"})])),_:1}),s(y,null,{default:t((()=>[...Q[7]||(Q[7]=[o("Make private",-1)])])),_:1})])),_:1})),[[g]]):r("",!0)])),_:1})])),_:1})])),_:1},8,["id"])),n("div",x,[j.app.image?(e(),c("img",{key:0,class:"app-image",src:I+j.app.image.path+"?w=208&h=205"},null,8,C)):(e(),c("img",w))]),s(u,null,{default:t((()=>[n("div",q,m(j.app.name),1),n("div",D,"by "+m(j.app.user.name),1)])),_:1}),s(u,{class:"q-pt-none"},{default:t((()=>[o(m(j.app.description)+" ",1),j.showPrivateStatus?(e(),c("div",P,[j.app.private?(e(),a(b,{key:0,icon:"visibility_off",size:"md"},{default:t((()=>[...Q[8]||(Q[8]=[o("Private",-1)])])),_:1})):(e(),a(b,{key:1,icon:"visibility",size:"md"},{default:t((()=>[...Q[9]||(Q[9]=[o("Public",-1)])])),_:1}))])):r("",!0)])),_:1})])),_:1}))}},[["__scopeId","data-v-036ed5a4"]]);export{Q as A};
