import{N as c,K as f,E as p,O as a,S as d,R as u,Q as C,C as N,r as $,a7 as B,ac as y,q as M,a6 as b,a3 as x,u as F,P as D}from"./vendor-BGtMsOoo.js";import{e as A,y as P,ae as E,h as I,af as O,ag as R,Q as S,g as W,ah as G}from"./index-CRze-aDK.js";const K={};function T(n,m){const s=c("VcButton"),i=c("VcModal");return p(),f(i,{title:n.$t("common.titles.remove_products"),variant:"danger",icon:"warning"},{actions:a(({close:r})=>[C(s,{class:"mx-auto",onClick:_=>r()},{default:a(()=>[d(u(n.$t("common.buttons.ok")),1)]),_:2},1032,["onClick"])]),default:a(()=>[d(" "+u(n.$t("common.messages.cart_contains_deleted_products")),1)]),_:1},8,["title"])}const U=A(K,[["render",T]]),j={class:"mb-5 text-xs font-normal text-neutral-400"},J=N({__name:"create-quote-from-cart",emits:["lockCart","unlockCart"],setup(n,{emit:m}){const s=m,i=P(),{cart:r,refetch:_}=E(),l=$(!1),{client:g}=B(),h=y(),{openModal:q}=I(),v=M(()=>{var t,e;return(e=(t=r.value)==null?void 0:t.items)==null?void 0:e.some(o=>!o.product)}),{mutate:V}=b(R,{refetchQueries:()=>O(g,[G.Query.GetFullCart])}),{isAuthenticated:k}=S();async function Q(){var o;if(v.value){q({component:U});return}l.value=!0,s("lockCart");const t=await V({command:{cartId:r.value.id,comment:""}}),e=(o=t==null?void 0:t.data)==null?void 0:o.createQuoteFromCart;e?await h.push({name:"EditQuote",params:{quoteId:e.id}}):i.error({text:W.i18n.global.t("quotes.errors.creating_quote_error"),duration:15e3,single:!0}),await _(),s("unlockCart"),l.value=!1}return(t,e)=>{const o=c("VcButton"),w=c("VcWidget");return F(k)?(p(),f(w,{key:0,title:t.$t("quotes.cart_widget.title"),class:"print:hidden"},{default:a(()=>[D("p",j,u(t.$t("quotes.cart_widget.quote_request_hint")),1),C(o,{loading:l.value,"full-width":"",variant:"outline",onClick:Q},{default:a(()=>[d(u(t.$t("quotes.cart_widget.create_quote_button")),1)]),_:1},8,["loading"])]),_:1},8,["title"])):x("",!0)}}});export{J as default};
//# sourceMappingURL=create-quote-from-cart-Uk8TUJ8Q.js.map
