import{aa as $,ct as y,cR as A,ch as C,bB as w,X as B,cS as a,a3 as t,a2 as m,c0 as l,W as R,c7 as i,aV as k,V as f,bO as V,l as N}from"#entry";import{b as O,V as S}from"./RTCSF0Ks.js";import{V as T}from"./R1_j74h_.js";import{V as U}from"./D-zBkYGg.js";import{V as j}from"./BzS00CNT.js";import{V as D}from"./BgQ5eU58.js";import{V as E}from"./VoZA954X.js";import"./BKDgfSxC.js";import"./Cp3UUybv.js";import"./BbcaTmac.js";import"./D_qxKlPu.js";import"./DmHQoNBb.js";import"./CEoxYnb5.js";import"./BPHK4Dzs.js";import"./SPpKX9fG.js";import"./C2L9cD_h.js";import"./7nzMR1a0.js";import"./CAodMEV_.js";import"./CFrOycco.js";import"./BbYgWsNS.js";import"./QUYPESwd.js";import"./-GcL7px7.js";const F={class:"mb-2"},x=$({__name:"AssignAuthor",props:{event:{type:Object,default:()=>({})}},emits:["close","update"],async setup(_,{emit:v}){let r,u;const g=_,{$notify:p}=y(),d=v,s=V(!1),o=V(),{data:b}=([r,u]=A(()=>C("/api/users","$JDsH0ifUd5")),r=await r,u(),r);async function h(){try{s.value=!0,await $fetch(`/api/events/${g.event.id}/assign_to_author`,{method:"PUT",body:{userId:o.value}}),s.value=!1,d("update"),d("close"),p("event.saved")}catch(e){s.value=!1,p(e,N.ERROR)}}return(e,n)=>(w(),B(S,null,{default:a(()=>[t(O,{class:"bg-primary"},{default:a(()=>[m(l(e.$t("event.assign_to_user")),1)]),_:1}),t(T,null,{default:a(()=>[R("p",F,l(e.$t("event.assign_to_user_description")),1),t(U,null,{default:a(()=>[t(j,{modelValue:i(o),"onUpdate:modelValue":n[0]||(n[0]=c=>k(o)?o.value=c:null),items:i(b),"prepend-inner-icon":"mdi-account","hide-no-data":"","item-title":"email","item-value":"id",placeholder:"Choose user",label:e.$t("common.user")},null,8,["modelValue","items","label"])]),_:1})]),_:1}),t(D,null,{default:a(()=>[t(E),t(f,{color:"primary",variant:"outlined",disabled:!i(o)||i(s),loading:i(s),onClick:h},{default:a(()=>[m(l(e.$t("event.assign_to_user")),1)]),_:1},8,["disabled","loading"]),t(f,{color:"warning",variant:"outlined",onClick:n[1]||(n[1]=c=>e.$emit("close"))},{default:a(()=>[m(l(e.$t("common.close")),1)]),_:1})]),_:1})]),_:1}))}}),ne=Object.assign(x,{__name:"EventAssignAuthor"});export{ne as default};
