import{F as Q,ai as Y,bx as j,L as Z,aE as ee,M as S,J as ae,m as i,K as $,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-DWvj1jit.js";import{a6 as le,ci as l,bL as te,x as oe}from"./index-8PssKxKU.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=oe(),E=i(()=>d.list?.name),O=i(()=>d.list?.description),P=i(()=>d.list?.sharingSetting?.scope),{loading:h,createWishlist:W,updateWishlist:z}=te(),{isCorporateMember:D}=le(),K=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}`)}]),q=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}`),F=Z(ee({name:S().trim().required().max(25),description:S().max(I),sharingScope:S().required()})),{errors:v,meta:n}=ae({validationSchema:F,initialValues:{name:E.value,description:O.value??"",sharingScope:P.value??l.Private},validateOnMount:!0}),{value:r}=$("name"),{value:u}=$("description"),{value:o}=$("sharingScope"),y=i(()=>!!d.list),R=i(()=>n.value.dirty&&n.value.valid);async function x(a){n.value.valid&&(y.value?await z({listId:d.list.id,listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}):await W({listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}),a())}async function X(){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"),G=c("VcTextarea"),H=c("VcSelect"),V=c("VcButton"),J=c("VcModal");return g(),f(J,{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(G,{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(D)?(g(),ie("div",ne,[m(H,{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:K.value,"text-field":"label","value-field":"id"},null,8,["modelValue","label","placeholder","disabled","items"]),q.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:X})):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-BAqqOCfV.js.map
