import{J as $,Y as b,M as y,N as C,E as w,A as B,B as a,b as t,G as m,Q as l,c as N,S as i,a8 as k,V as f,a4 as V,Z as R}from"#entry";import{a as S,V as T}from"./DlybGOWB.js";import{V as U}from"./DArAxlee.js";import{V as E}from"./gMmVrYwQ.js";import{V as O}from"./CGunDE1l.js";import{V as j}from"./DSnRMG2T.js";import{V as D}from"./D1vV9CHW.js";import"./BML-0xFj.js";import"./CIr4U5gS.js";import"./xGkJbl6f.js";import"./D_qxKlPu.js";import"./C1aoz2cp.js";import"./LWaCnj-p.js";import"./0VvUL2KS.js";import"./BNBrPSlz.js";import"./tRJ_cXK7.js";import"./DCT0cttX.js";import"./CZqgYEd3.js";import"./Cp3W8Jzz.js";import"./DkUOO-4a.js";import"./bVMbXo56.js";import"./5A-VMRTY.js";const F={class:"mb-2"},J=$({__name:"AssignAuthor",props:{event:{type:Object,default:()=>({})}},emits:["close","update"],async setup(_,{emit:v}){let r,u;const g=_,{$notify:p}=b(),d=v,s=V(!1),o=V(),{data:h}=([r,u]=y(()=>C("/api/users","$JDsH0ifUd5")),r=await r,u(),r);async function A(){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,R.ERROR)}}return(e,n)=>(w(),B(T,null,{default:a(()=>[t(S,{class:"bg-primary"},{default:a(()=>[m(l(e.$t("event.assign_to_user")),1)]),_:1}),t(U,null,{default:a(()=>[N("p",F,l(e.$t("event.assign_to_user_description")),1),t(E,null,{default:a(()=>[t(O,{modelValue:i(o),"onUpdate:modelValue":n[0]||(n[0]=c=>k(o)?o.value=c:null),items:i(h),"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(j,null,{default:a(()=>[t(D),t(f,{color:"primary",variant:"outlined",disabled:!i(o)||i(s),loading:i(s),onClick:A},{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(J,{__name:"EventAssignAuthor"});export{ne as default};
