import{u as E}from"./settingsStore-8bwiLMEn.js";import{u as F}from"./appStore-CFAkQG2b.js";import{i as B,j as M}from"./fieldsStore-CQRN0FvQ.js";import{_ as O}from"./Button.vue_vue_type_style_index_0_lang-CxqKrtR4.js";import{_ as z}from"./ThankYouPage-DlXGumkR.js";import{d as I,e as i,a as G,b as K,f,i as d,t as w,j as C,k as Q}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as R,r as _,u as v}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as V,b as q}from"./vendor-vue-shared-DrzsEcag.js";import"./vendor-pinia-BSPefQhS.js";import"./convert-case-to-camel-case.utils-CK5dBN7n.js";import"./translationsStore-D6vLzgNA.js";import"./vendor-moment-Cv92BTSA.js";import"./vendor-bootstrap-CCU-90um.js";import"./vendor-jspdf-UFhKzYHA.js";import"./vendor-php-date-formatter-DSpPwBF8.js";import"./callbackStore-BhxBUA6V.js";import"./ProBadge.vue_vue_type_style_index_0_lang-DqDXUf8-.js";import"./vendor-vue-runtime-dom-B2rky8vu.js";import"./vendor-vue3-html2pdf-KR020wX8.js";import"./vendor-html2pdf.js-B-tok4Ns.js";import"./vendor-html2canvas-BfYXEYrK.js";import"./Popup.vue_vue_type_style_index_0_lang-uNTBWSeR.js";const U={key:0,class:"ccb-pdf-invoice",ref:"pdfInvoiceRef"},H=I({__name:"GeneratePdf",props:{hideButtons:{type:Boolean},options:{}},setup(p,{expose:l}){const s=F(),a=p,{hideButtons:r}=R(a),g=_({name:"",email:"",message:"",pdfName:""}),h=_(),S=_(),n=E(),m=()=>{var e;(e=h.value)==null||e.generate()};l({generatePdf:m});const k=()=>{var e;(e=S.value)==null||e.showPopup()},P=e=>{const t=g.value;setTimeout(async()=>{const o=new FormData;o.append("action","ccb_send_invoice"),o.append("nonce",window.ccb_nonces.ccb_send_invoice),o.append("pdfString",e.data),t.pdfName=A.value;const c=M(t);o.append("data",c),await(await fetch(window.ajax_window.ajax_url,{method:"POST",body:o})).json()},3e3)},x=i(()=>{var o,c,u;const e=(o=n.getFormSettings)==null?void 0:o.summaryDisplay;if(e!=null&&e.enable&&(e==null?void 0:e.actionAfterSubmit)!=="show_summary_block_with_pdf"||!((c=n.getInvoice)!=null&&c.useInAll))return!1;const t=B();return!((u=n.getInvoice)!=null&&u.showAfterPayment)||t.notificationType==="finish"}),D=i(()=>{var e;return((e=n.getInvoice)==null?void 0:e.pdfButtonText)||"PDF Download"}),T=i(()=>{var e;return(e=n.getInvoice)==null?void 0:e.emailButton}),A=i(()=>s.getCalcTitle),L=i(()=>s.getIsLive),N=i(()=>T.value?"ccb-pdf-invoice__actions--show-share":"ccb-pdf-invoice__actions--show-pdf"),b=()=>{m()},y=e=>{var o;((o=e.detail)==null?void 0:o.calcId)===s.getCalcId&&k()},$=()=>{var c;const e=`__ccb_pdf_listeners_${s.getCalcId}`;if(window[e])return;const t=n.getThankYouPage,o=(c=n==null?void 0:n.stickyCalc)==null?void 0:c.oneClickAction;(s.isThankYouPage||t!=null&&t.enable&&(t==null?void 0:t.type)==="modal"&&(t!=null&&t.downloadButton)||o==="pdf")&&window.addEventListener("ccbDownLoadPdf",b),window.addEventListener("ccbOpenModal",y),window[e]=!0},j=i(()=>{var t;if(r.value)return!0;const e=B();return(t=n.getInvoice)!=null&&t.showAfterPayment?e.notificationType!=="finish":!1});return G(()=>{$()}),K(()=>{window.removeEventListener("ccbDownLoadPdf",b),window.removeEventListener("ccbOpenModal",y);const e=`__ccb_pdf_listeners_${s.getCalcId}`;window[e]&&delete window[e]}),(e,t)=>(d(),f("div",null,[x.value?(d(),f("div",U,[j.value?w("",!0):(d(),f("div",{key:0,class:V(["ccb-pdf-invoice__actions",N.value])},[C(v(O),{type:"light",text:D.value,onClick:m,isDemo:L.value},null,8,["text","isDemo"])],2))],512)):w("",!0),C(v(z),{ref_key:"invoiceComponent",ref:h,onGenerateQuote:P},null,512)]))}}),ve=I({__name:"PdfButtonAlias",props:{showSummary:{type:Boolean},item:{}},setup(p){const l=p,s=i(()=>{var r;const a=(r=l.item.options)==null?void 0:r.width;return{width:a?`calc(${a}% - 5px)`:"100%"}});return(a,r)=>a.showSummary?(d(),Q(v(H),{key:0,class:"ccb-total-summary-action",options:a.item.options,style:q(s.value)},null,8,["options","style"])):w("",!0)}});export{ve as default};
//# sourceMappingURL=PdfButtonAlias-DDwJuyyD.js.map
