1import{j as e}from"./vendor-puck-lPnaRYA0.js";import{aT as le,J as me,B as S,A as ue,q as v,l,E as $,b as he,d as pe,b2 as fe,u as ge,j as xe,aI as d,b9 as D,bX as be,bw as je,c as ye,P as ke,b1 as we,y as Ce,bY as ve,K as Ne,bZ as _e,g as H,bk as Ie,X as Pe}from"./index-RBIFUHQq.js";import{R as Te,r as A,L as K,d as Re,u as Ee}from"./vendor-react-TOOSQ9Q-.js";import{I as Be}from"./InvoiceItemFactory-lk6YJ2mg.js";import{B as Ae}from"./ButtonWithConfirmation-PaGRCEeK.js";import{u as P}from"./vendor-i18n-eTj0Pfmx.js";import{D as J}from"./vendor-luxon-2n2xc3QM.js";import{a as q,R as y,C as j,c as W,k as z}from"./vendor-bootstrap-QfZpN2Mb.js";var N=(s=>(s[s.Open=1]="Open",s[s.Completed=2]="Completed",s[s.Refunded=3]="Refunded",s[s.Cancelled=4]="Cancelled",s))(N||{});const E=s=>{const{t:n}=P(),{renderWaiting:u,renderComplete:x,renderFailed:f,endpoint:k,onPaymentFailed:h}=s,{httpClient:p}=le(),[t,F]=Te.useState(!0),w=k,{resource:c}=me(p,w,{queryConfig:{refetchInterval:5*1e3,enabled:t},method:"post"});return A.useEffect(()=>{c?.invoice!=null&&F(!1)},[c]),A.useEffect(()=>{(c?.status==N.Cancelled||c?.status==N.Refunded)&&h?.()},[c?.status]),c?.status==N.Cancelled||c?.status==N.Refunded?f?.()??e.jsxs(e.Fragment,{children:[n("Payment was cancelled. Please try again.")," "]}):c?.invoice?x(c):u?.()??e.jsxs(e.Fragment,{children:[JSON.stringify(c),e.jsx("div",{children:n("Waiting for payment confirmation...")})]})},B=s=>{const{t:n}=P(),u=Ee(),{exchangeToken:x}=$(),{getRoutePath:f}=he(),{hasBilling:k,getBoolSetting:h}=pe(),p=fe(),{invoice:t,method:F,token:w,hideCreateAccount:c,guestInvoiceId:Y}=s,{httpClient:C}=ge(),{config:X}=xe(),{isAuthenticated:L,coworker:G}=$(),Q=async()=>{try{const a=l.billing.invoices.registerByToken(t.Id,w),r=await C.post(a.url);r.data?.Token&&(await x(r.data.Token),d("guest_account_created"),setTimeout(()=>{u(f(H.profile_dashboard_personal))},1e3))}catch(a){if(console.error("Error creating account from invoice token:",a),a.response?.data?.Message){const r=a.response.data.Message;throw new Error(Pe(n,r))}throw new Error(n("There was an error creating your account. Please contact us to help you creating your account. Your order is not affected."))}},T=t?.LinesRaw.some(a=>a.BookingUniqueId),R=t?.LinesRaw.some(a=>a.EventAttendeeUniqueId),V=t?.LinesRaw.some(a=>a.CoworkerContractUniqueId),Z=t?.LinesRaw.some(a=>a.CoworkerProductUniqueId),O=A.useRef(!1);if(A.useEffect(()=>{if(p.clearCart(),!t||O.current)return;O.current=!0;const a=T?"booking":R?"event":V?"tariff":Z?"product":"other",r=t.TransactionTotalAmount,m=t.TransactionCurrency?.Code;d("checkout_completed",{checkout_type:a,value:r,currency:m,...D()}),L||d("guest_checkout_completed",{checkout_type:a,value:r,currency:m,...D()});const re=[...new Set(t.LinesRaw.map(i=>i.BookingUniqueId).filter(Boolean))],ie=[...new Set(t.LinesRaw.map(i=>i.EventAttendeeUniqueId).filter(Boolean))],ce=[...new Set(t.LinesRaw.map(i=>i.CoworkerContractUniqueId).filter(Boolean))],de=[...new Set(t.LinesRaw.map(i=>i.CoworkerProductUniqueId).filter(Boolean))],g=D();re.forEach(async i=>{try{const b=l.billing.invoices.booking(t.Id,i),o=(await C.get(b.url)).data;d("booking_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,booking_id:o.Id,resource_id:o.ResourceId,resource_name:o.ResourceName,resource_type:o.ResourceTypeName,from_time:o.FromTime,to_time:o.ToTime,...g})}catch{d("booking_purchase_completed",{value:r,currency:m,coworker_id:t.CoworkerId,method:"checkout",...g})}}),ie.forEach(async i=>{try{const b=l.billing.invoices.attendee(t.Id,i),o=(await C.get(b.url)).data;d("event_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,event_id:o.CalendarEvent?.Id,event_name:o.CalendarEvent?.Name,event_product_name:o.EventProductName,attendee_id:o.Id,...g})}catch{d("event_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,...g})}}),ce.forEach(async i=>{try{const b=l.billing.invoices.coworkerContract(t.Id,i),o=(await C.get(b.url)).data;d("plan_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,contract_id:o.Id,tariff_name:o.Tariff?.Name,tariff_id:o.Tariff?.Id,tariff_type:be[o.Tariff?.SystemTariffType],start_date:o.StartDate,...g})}catch{d("plan_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,...g})}}),de.forEach(async i=>{try{const b=l.billing.invoices.coworkerProduct(t.Id,i),o=(await C.get(b.url)).data;d("product_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,product_id:o.Product?.Id,product_name:o.Product?.Name,product_type:je[o.Product?.SystemProductType],quantity:o.Quantity,...g})}catch{d("product_purchase_completed",{value:r,currency:m,method:"checkout",coworker_id:t.CoworkerId,...g})}})},[t?.Id]),!t)return e.jsx(e.Fragment,{});const ee=()=>T?n("Booking confirmation - {{invoiceNumber}}",{invoiceNumber:t.InvoiceNumber}):R?n("Event booking confirmation - {{invoiceNumber}}",{invoiceNumber:t.InvoiceNumber}):n("Checkout complete - {{invoiceNumber}}",{invoiceNumber:t.InvoiceNumber}),te=()=>T?t?.Paid===!1?n("Your booking is pending confirmation!"):n("Your booking is confirmed!"):R?t?.Paid===!1?n("Your event booking is pending confirmation!"):n("Your event booking is confirmed!"):n("You are all set!"),ne=()=>T?t?.Paid===!1?n("A confirmation email will be sent to you with the details of your booking. Your booking will be confirmed once the payment is processed."):n("A confirmation email has been sent to you with the details of your booking."):R?t?.Paid===!1?n("A confirmation email will be sent to you with the details of your event booking. Your booking will be confirmed once the payment is processed."):n("A confirmation email has been sent to you with the details of your event booking."):n("A confirmation email has been sent to you with the details of your purchase."),se=ee(),oe=te(),ae=ne(),{isSmDown:M}=ye();return e.jsxs(q,{children:[e.jsx(ke,{title:se}),e.jsx(y,{children:e.jsx(j,{md:10,xl:8,className:"mt-md-6 mx-auto",children:e.jsxs(W,{className:"shadow",children:[e.jsx("div",{className:"d-flex justify-content-center",children:e.jsx(we,{duration:3e3})}),e.jsxs(z,{className:"text-center p-4",children:[e.jsx(S,{name:"claps",className:"icon-pulse m-4 d-print-none",size:100,colors:[{from:"#FF5100",to:"var(--bs-primary)"}]}),e.jsx("h1",{className:"card-title fs-3 fw-bolder mb-4",children:oe}),t&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{className:"justify-content-between text-start mb-4",children:[e.jsx(j,{lg:5,children:e.jsxs("ul",{className:"list-group list-group-borderless",children:[e.jsxs("li",{className:"list-group-item d-sm-flex justify-content-between align-items-center",children:[e.jsxs("span",{className:"mb-0 items-center",children:[e.jsx(v,{name:"invoice",className:"me-2",size:24}),n("Transaction ID"),":"]}),e.jsx("span",{className:"h6 fw-normal mb-0",children:t.InvoiceNumber})]}),e.jsxs("li",{className:"list-group-item d-sm-flex justify-content-between align-items-center",children:[e.jsxs("span",{className:"mb-0 items-center",children:[e.jsx(v,{name:"calendar",className:"me-2",size:24}),n("Date"),":"]}),e.jsx("span",{className:"h6 fw-normal mb-0",children:J.fromISO(t.CreatedOn).toLocaleStr
1ing(J.DATE_MED)})]})]})}),k&&e.jsx(j,{lg:6,children:e.jsxs("ul",{className:"list-group list-group-borderless",children:[e.jsxs("li",{className:"list-group-item d-sm-flex justify-content-between align-items-center",children:[e.jsxs("span",{className:"mb-0 items-center",children:[e.jsx(v,{name:"credit-card",className:"me-2",size:24}),n("Paid by"),":"]}),e.jsx("span",{className:"h6 fw-normal mb-0",children:F})]}),e.jsxs("li",{className:"list-group-item d-sm-flex justify-content-between align-items-center",children:[e.jsxs("span",{className:"mb-0 items-center",children:[e.jsx(v,{name:"dollar",className:"me-2",size:24}),n("Total amount:")]}),e.jsx("span",{className:"h6 fw-normal mb-0",children:e.jsx(Ce,{currency:t.Currency.Code,amount:t.TotalAmount})})]})]})})]}),e.jsx("p",{className:"lead mb-6",children:ae}),e.jsx("h2",{className:"h5 fw-bolder fs-5 mb-3 text-start",children:n("Items purchased")}),t.LinesRaw.map(a=>e.jsx(y,{children:e.jsx(j,{md:12,className:"mb-2 text-start",children:e.jsx(Be,{invoice:t,line:a})},a.Id)})),e.jsx(y,{children:e.jsx(j,{children:e.jsxs("div",{className:`d-flex justify-content-center d-print-none ${M?"flex-column gap-2":""}`,children:[!M&&e.jsxs("a",{href:"#",onClick:()=>window.print(),className:"btn btn-link mb-0",id:"checkout-complete-print",children:[e.jsx(ve,{className:"me-2"}),n("Print confirmation")]}),h(Ne.billing.print)&&e.jsxs("a",{href:`https://${t.BusinessWebAddress}${X.publicBaseUrl}${c&&Y?l.billing.invoices.guestPdf(w,Y):l.billing.invoices.pdfByToken(t.Id,w)}`,target:"_blank",rel:"noopener noreferrer",className:"btn btn-link mb-0",children:[e.jsx(_e,{className:"me-2"}),n("Download invoice")]})]})})})]}),e.jsx("hr",{}),!L&&!c&&e.jsx("p",{className:"mb-4 d-print-none",children:e.jsx("p",{children:n("Create an account to manage your bookings and purchases, view invoices, and more.")})}),e.jsxs("div",{className:"d-flex flex-wrap justify-content-center justify-content-md-end gap-2 d-print-none",children:[!L&&!c&&e.jsx(Ae,{id:"checkout-complete-create-account",label:n("Create an account"),message:n("Creating an account will allow you to place bookings faster, manage all your bookings and purchases, view invoices, and much more. We will send you an email with your login details. Do you want to continue?"),options:{title:n("Create an account?"),confirmText:n("Create account"),cancelText:n("No, go back")},buttonClassName:"btn btn-primary mb-0 items-center",variant:"primary",fn:Q}),e.jsxs(K,{to:G?f(H.profile_dashboard_personal):"/",className:"btn btn-link mb-0 items-center",id:"checkout-complete-continue",children:[n("Continue"),e.jsx(Ie,{className:" ms-2"})]})]})]})]})})})]})},_=()=>{const{t:s}=P();return e.jsx(q,{children:e.jsx(y,{children:e.jsx(j,{md:10,xl:8,className:"mt-6 mx-auto",children:e.jsx(W,{className:"shadow",children:e.jsxs(z,{className:"text-center p-4",children:[e.jsx(S,{name:"request-sent",size:100,colors:[{from:"#FF5100",to:"var(--bs-primary)"}]}),e.jsx("h1",{className:"card-title fs-3",children:s("Waiting for payment confirmation...")}),e.jsx("p",{className:"lead mb-3",children:s("Please wait while we confirm your payment.")})]})})})})})},I=s=>{const{t:n}=P(),{goBackUrl:u}=s;return e.jsx(q,{children:e.jsx(y,{children:e.jsx(j,{md:10,xl:8,className:"mt-6 mx-auto",children:e.jsx(W,{className:"shadow",children:e.jsxs(z,{className:"text-center p-4",children:[e.jsx(S,{name:"error",size:100}),e.jsx("h1",{className:"card-title fs-3",children:n("Payment failed")}),e.jsx("p",{className:"lead mb-3",children:n("Please try again or contact us for more details. No charges have been made to your account.")}),e.jsx("p",{children:e.jsxs(ue,{variant:"primary",as:K,to:u,children:[e.jsx(v,{name:"arrow-left",className:"me-2"}),n("Go back and try again")]})})]})})})})})},Fe=()=>{const{t:s}=P(),[n]=Re(),u=n.get("stripe_session_id"),x=n.get("spreedly_session_id"),f=n.get("paypal_session_id"),k=n.get("guest_invoice_paid"),h=n.get("cguid"),p=n.get("iguid");return e.jsxs("div",{className:"my-7",children:[u&&e.jsx(E,{endpoint:l.basket.payments.stripeCheckout.sessionStatus(u,1),renderWaiting:()=>e.jsx(_,{}),renderFailed:()=>e.jsx(I,{goBackUrl:"/"}),renderComplete:t=>e.jsx(B,{token:u,method:s("Stripe"),invoice:t.invoice})}),x&&e.jsx(E,{endpoint:l.basket.payments.spreedly.sessionStatus(x,1),renderWaiting:()=>e.jsx(_,{}),renderFailed:()=>e.jsx(I,{goBackUrl:"/"}),renderComplete:t=>
1e.jsx(B,{token:x,method:s("Credit/debit card"),invoice:t.invoice})}),f&&e.jsx(E,{endpoint:l.basket.payments.paypalStandardRest.sessionStatus(f,1),renderWaiting:()=>e.jsx(_,{}),renderFailed:()=>e.jsx(I,{goBackUrl:"/"}),renderComplete:t=>e.jsx(B,{token:h??f,method:s("PayPal"),invoice:t.invoice,hideCreateAccount:!!(h&&p),guestInvoiceId:p??void 0})}),k&&h&&p&&e.jsx(E,{endpoint:l.basket.payments.spreedly.guestInvoiceSessionStatus(h,p,1),renderWaiting:()=>e.jsx(_,{}),renderFailed:()=>e.jsx(I,{goBackUrl:"/"}),renderComplete:t=>e.jsx(B,{token:h,method:s("Credit/debit card"),invoice:t.invoice,hideCreateAccount:!0,guestInvoiceId:p})})]})},Oe=Object.freeze(Object.defineProperty({__proto__:null,FailedContents:I,WaitingContents:_,default:Fe},Symbol.toStringTag,{value:"Module"}));export{E as C,I as F,_ as W,Oe as i};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.