import{F as Q,ai as Y,bx as j,m as i,M as S,L as Z,aF as ee,K as $,J as ae,P as c,_ as f,R as g,a1 as p,T as se,X as m,Q as ie,W as k,e,Y as C,a2 as T,a0 as A}from"./vendor-BmRNukEL.js";import{x as le,bJ as te,a7 as oe,ce as l}from"./index-PU-0vjEQ.js";const de={class:"space-y-4"},ne={key:0,class:"space-y-4"},I=250,pe=Q({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(M){const d=M,{t:_}=Y(),{copy:U,isSupported:B}=j(),L=le(),O=i(()=>d.list?.name),P=i(()=>d.list?.description),W=i(()=>d.list?.sharingSetting?.scope),{loading:h,createWishlist:z,updateWishlist:D}=te(),{isCorporateMember:E}=oe(),F=i(()=>[{id:l.Private,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.Private}`)},{id:l.AnyoneAnonymous,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.AnyoneAnonymous}`)},{id:l.Organization,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.Organization}`)}]),K=i(()=>o.value==l.AnyoneAnonymous||o.value==l.Organization),b=i(()=>d.list?.sharingSetting?.id??crypto.randomUUID()),w=i(()=>`${location.protocol}//${location.host}/shared-list/${b.value}`),q=Z(ee({name:$().trim().required().max(25),description:$().max(I),sharingScope:$().required()})),{errors:v,meta:n}=ae({validationSchema:q,initialValues:{name:O.value,description:P.value??"",sharingScope:W.value??l.Private},validateOnMount:!0}),{value:r}=S("name"),{value:u}=S("description"),{value:o}=S("sharingScope"),y=i(()=>!!d.list),R=i(()=>n.value.dirty&&n.value.valid);async function x(a){n.value.valid&&(y.value?await D({listId:d.list.id,listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}):await z({listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}),a())}async function J(){await U(w.value),L.success({text:_("shared.wishlists.add_or_update_wishlist_modal.clipboard_success"),duration:4e3,single:!0})}return(a,t)=>{const N=c("VcInput"),X=c("VcTextarea"),G=c("VcSelect"),V=c("VcButton"),H=c("VcModal");return g(),f(H,{title:y.value?a.$t("shared.wishlists.add_or_update_wishlist_modal.edit_mode_title"):a.$t("shared.wishlists.add_or_update_wishlist_modal.title"),dividers:"","is-mobile-fullscreen":""},{actions:p(({close:s})=>[m(V,{color:"secondary",variant:"outline",onClick:s},{default:p(()=>[T(A(a.$t("shared.wishlists.add_or_update_wishlist_modal.cancel_button")),1)]),_:1},8,["onClick"]),m(V,{loading:e(h),disabled:!R.value,class:"ms-auto",onClick:re=>x(s)},{default:p(()=>[T(A(y.value?a.$t("shared.wishlists.add_or_update_wishlist_modal.save_button"):a.$t("shared.wishlists.add_or_update_wishlist_modal.create_button")),1)]),_:1},8,["loading","disabled","onClick"])]),default:p(()=>[se("div",de,[m(N,{modelValue:e(r),"onUpdate:modelValue":t[0]||(t[0]=s=>C(r)?r.value=s:null),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_label"),placeholder:a.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_placeholder"),disabled:e(h),message:e(v).name,error:!!e(v).name&&e(n).dirty,required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),m(X,{modelValue:e(u),"onUpdate:modelValue":t[1]||(t[1]=s=>C(u)?u.value=s:null),label:a.$t("common.labels.description"),disabled:e(h),message:e(v).description,error:!!e(v).description&&e(n).dirty,rows:"4",counter:"","max-length":I},null,8,["modelValue","label","disabled","message","error"]),e(E)?(g(),ie("div",ne,[m(G,{modelValue:e(o),"onUpdate:modelValue":t[2]||(t[2]=s=>C(o)?o.value=s:null),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_scope_label"),placeholder:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_scope_placeholder"),disabled:e(h),items:F.value,"text-field":"label","value-field":"id"},null,8,["modelValue","label","placeholder","disabled","items"]),K.value?(g(),f(N,{key:0,modelValue:w.value,"onUpdate:modelValue":t[3]||(t[3]=s=>w.value=s),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_link_label"),readonly:""},{append:p(()=>[e(B)?(g(),f(V,{key:0,color:"secondary",variant:"solid-light",icon:"document-duplicate","icon-size":"1.25rem",onClick:J})):k("",!0)]),_:1},8,["modelValue","label"])):k("",!0)])):k("",!0)])]),_:1},8,["title"])}}});export{pe as _};
//# sourceMappingURL=add-or-update-wishlist-modal.vue_vue_type_script_setup_true_lang-DDIdUhnQ.js.map
