import{M as g}from"./MkPagination-urywMrXv.js";import{i as s,a4 as A,v as N,f as $,aA as D,M as k,bt as V,w as E,P as F,n as H}from"./app-JmgyQoR0.js";import{_ as v}from"./MkAvatars.vue_vue_type_style_index_0_lang-3o9u3dW8.js";import{b as T,a as w,c as y,D as _,h as i,i as z,j as a,l as t,K as p,E as d,z as x,t as l,G as M,u as n,F as I,I as J,J as K}from"./vue-y3KLWBaS.js";const L=r=>(J("data-v-9478359d"),r=r(),K(),r),W=L(()=>n("i",{class:"ph-plus ph-bold ph-lg"},null,-1)),q={class:"_title"},O={class:"_content"},Q={class:"_title"},R={class:"_content"},U={class:"_footer"},X=T({__name:"index",setup(r){const m=w("owned"),f=w("joined"),b={endpoint:"users/groups/owned",limit:10},C={endpoint:"users/groups/joined",limit:10},P=y(()=>[{icon:"ph-plus ph-bold ph-lg",text:s.ts.createGroup,handler:h}]);A(y(()=>({title:s.ts.groups,icon:"ph-users-three ph-bold ph-lg"})));async function h(){const{canceled:o,result:c}=await N({title:s.ts.groupName});o||(await $("users/groups/create",{name:c}),m.value.reload(),D())}async function j(o){const{canceled:c}=await E({type:"warning",text:s.t("leaveGroupConfirm",{name:o.name})});c||F("users/groups/leave",{groupId:o.id}).then(()=>{f.value.reload()})}return(o,c)=>{const S=_("MkPageHeader"),B=_("MkA"),G=_("MkSpacer");return i(),z(V,null,{header:a(()=>[t(S,{actions:P.value,"display-back-button":!0},null,8,["actions"])]),default:a(()=>[t(G,{"content-max":800,"margin-min":20},{default:a(()=>[t(k,{primary:"",style:{margin:"0 auto var(--margin) auto"},onClick:h},{default:a(()=>[W,p(" "+d(x(s).ts.createGroup),1)]),_:1}),t(g,{ref_key:"owned",ref:m,pagination:b},{default:a(({items:u})=>[(i(!0),l(I,null,M(u,e=>(i(),l("div",{key:e.id,class:"_card"},[n("div",q,[t(B,{to:`/my/groups/${e.id}`,class:"_link"},{default:a(()=>[p(d(e.name),1)]),_:2},1032,["to"])]),n("div",O,[t(v,{"user-ids":e.userIds},null,8,["user-ids"])])]))),128))]),_:1},512),t(g,{ref_key:"joined",ref:f,pagination:C},{default:a(({items:u})=>[(i(!0),l(I,null,M(u,e=>(i(),l("div",{key:e.id,class:"_card"},[n("div",Q,d(e.name),1),n("div",R,[t(v,{"user-ids":e.userIds},null,8,["user-ids"])]),n("div",U,[t(k,{danger:"",onClick:Y=>j(e)},{default:a(()=>[p(d(x(s).ts.leaveGroup),1)]),_:2},1032,["onClick"])])]))),128))]),_:1},512)]),_:1})]),_:1})}}}),se=H(X,[["__scopeId","data-v-9478359d"]]);export{se as default};
