import{r as o,h as i}from"./p-dfbe004d.js";import{a as t}from"./p-7393a06c.js";import{_ as s}from"./p-8415f806.js";import"./p-fd56940f.js";import{U as r}from"./p-c7dd942d.js";import{g as n}from"./p-4d73f82a.js";import{a as e}from"./p-1c2e2695.js";import"./p-9a7a47e8.js";const a=class{constructor(i){o(this,i),this.loading=!1}componentWillLoad(){r.create(this,this.state()),this.getSession()}getSessionId(){var o;return(null===(o=this.order)||void 0===o?void 0:o.id)?this.order.id:n(window.location.href,"order")}async getSession(){var o;if(this.getSessionId()&&!(null===(o=this.order)||void 0===o?void 0:o.id))try{this.loading=!0,this.order=await await t({path:e(`surecart/v1/checkouts/${this.getSessionId()}`,{expand:["line_items","line_item.price","line_item.fees","price.product","customer","customer.shipping_address","payment_intent","discount","manual_payment_method","discount.promotion","billing_address","shipping_address"],refresh_status:!0})})}catch(o){this.error=(null==o?void 0:o.message)?o.message:s("Something went wrong","surecart")}finally{this.loading=!1}}state(){var o,i;const t=null===(o=this.order)||void 0===o?void 0:o.manual_payment_method;return{processor:"stripe",loading:this.loading,orderId:this.getSessionId(),order:this.order,customer:null===(i=this.order)||void 0===i?void 0:i.customer,manualPaymentTitle:null==t?void 0:t.name,manualPaymentInstructions:null==t?void 0:t.instructions}}renderOnHold(){var o,t,r;return"processing"!==(null===(o=this.order)||void 0===o?void 0:o.status)?null:"paypal"===(null===(r=null===(t=null==this?void 0:this.order)||void 0===t?void 0:t.payment_intent)||void 0===r?void 0:r.processor_type)?i("sc-alert",{type:"warning",open:!0},s("Paypal is taking a closer look at this payment. It’s required for some payments and normally takes up to 3 business days.","surecart")):void 0}renderManualInstructions(){var o;const t=null===(o=this.order)||void 0===o?void 0:o.manual_payment_method;if(null==t?void 0:t.instructions)return i("sc-alert",{type:"info",open:!0},i("span",{slot:"title"},null==t?void 0:t.name),null==t?void 0:t.instructions)}render(){var o,t;return i(r.Provider,{state:this.state()},i("div",{class:{"order-confirmation":!0}},i("div",{class:{"order-confirmation__content":!0,hidden:!(null===(o=this.order)||void 0===o?void 0:o.id)&&!this.loading}},i("sc-order-confirm-components-validator",{checkout:this.order},i("slot",null))),!(null===(t=this.order)||void 0===t?void 0:t.id)&&!this.loading&&i("sc-heading",null,s("Order not found.","surecart"),i("span",{slot:"description"},s("This order could not be found. Please try again.","surecart")))))}};a.style=":host{display:block;max-width:800px;margin:auto}::slotted(*:not(:last-child)),sc-form form>*:not(:last-child){margin-bottom:var(--sc-form-row-spacing-large)}.order-confirmation__content{color:var(--sc-order-confirmation-color, var(--sc-color-gray-500))}.order-confirmation__content.hidden{display:none}::part(line-items){display:grid;gap:0.5em}";export{a as sc_order_confirmation}