import{C as R,q as r,an as z,ao as F,cp as Q,ap as y,aq as A,ar as f,N as u,K as G,E as N,O as c,P as H,Q as m,D as K,a3 as L,u as a,at as S,S as $,R as g}from"./vendor-BGtMsOoo.js";import{c3 as C,aV as X,Q as j}from"./index-CRze-aDK.js";const x={class:"space-y-4"},J={key:0},k=250,ae=R({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(T){const l=T,B=r(()=>{var e;return(e=l.list)==null?void 0:e.name}),I=r(()=>{var e;return(e=l.list)==null?void 0:e.description}),M=r(()=>{var e;return((e=l.list)==null?void 0:e.scope)===C.Organization}),{loading:w,createWishlist:E,updateWishlist:O}=X(),{isCorporateMember:q}=j(),D=z(F({name:y().required().max(25),description:y().max(k),isShared:Q()})),{errors:p,meta:i}=A({validationSchema:D,initialValues:{name:B.value,description:I.value??"",isShared:M.value},validateOnMount:!0}),{value:o}=f("name"),{value:d}=f("description"),{value:_}=f("isShared"),b=r(()=>!!l.list),U=r(()=>i.value.dirty&&i.value.valid);async function W(e){var h,v,V,n;if(!i.value.valid)return;const s=_.value?C.Organization:C.Private;b.value?await O({listId:l.list.id,listName:(h=o.value)==null?void 0:h.trim(),description:(v=d.value)==null?void 0:v.trim(),scope:s}):await E({listName:(V=o.value)==null?void 0:V.trim(),description:(n=d.value)==null?void 0:n.trim(),scope:s}),e()}return(e,s)=>{const h=u("VcInput"),v=u("VcTextarea"),V=u("VcSwitch"),n=u("VcButton"),P=u("VcModal");return N(),G(P,{title:b.value?e.$t("shared.wishlists.add_or_update_wishlist_modal.edit_mode_title"):e.$t("shared.wishlists.add_or_update_wishlist_modal.title"),dividers:"","is-mobile-fullscreen":""},{actions:c(({close:t})=>[m(n,{color:"secondary",variant:"outline",onClick:t},{default:c(()=>[$(g(e.$t("shared.wishlists.add_or_update_wishlist_modal.cancel_button")),1)]),_:2},1032,["onClick"]),m(n,{loading:a(w),disabled:!U.value,class:"ms-auto",onClick:Y=>W(t)},{default:c(()=>[$(g(b.value?e.$t("shared.wishlists.add_or_update_wishlist_modal.save_button"):e.$t("shared.wishlists.add_or_update_wishlist_modal.create_button")),1)]),_:2},1032,["loading","disabled","onClick"])]),default:c(()=>[H("div",x,[m(h,{modelValue:a(o),"onUpdate:modelValue":s[0]||(s[0]=t=>S(o)?o.value=t:null),label:e.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_label"),placeholder:e.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_placeholder"),disabled:a(w),message:a(p).name,error:!!a(p).name&&a(i).dirty,required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),m(v,{modelValue:a(d),"onUpdate:modelValue":s[1]||(s[1]=t=>S(d)?d.value=t:null),label:e.$t("common.labels.description"),disabled:a(w),message:a(p).description,error:!!a(p).description&&a(i).dirty,rows:"4",counter:"","max-length":k},null,8,["modelValue","label","disabled","message","error"]),a(q)?(N(),K("div",J,[m(V,{modelValue:a(_),"onUpdate:modelValue":s[2]||(s[2]=t=>S(_)?_.value=t:null),"label-position":"right"},{default:c(()=>[$(g(e.$t("shared.wishlists.add_or_update_wishlist_modal.make_shared")),1)]),_:1},8,["modelValue"])])):L("",!0)])]),_:1},8,["title"])}}});export{ae as _};
//# sourceMappingURL=add-or-update-wishlist-modal.vue_vue_type_script_setup_true_lang-Dtm3kah_.js.map
