import{r as i,h as e}from"./p-9add63ef.js";import"./p-445fd8b4.js";import{U as t}from"./p-e9ae48d3.js";import{g as o}from"./p-d3366af3.js";import{a as r}from"./p-401e165e.js";import{a as s}from"./p-259c3935.js";const n=":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}";const a=n;const d=class{constructor(e){i(this,e);this.order=undefined;this.loading=false;this.error=undefined}componentWillLoad(){t.create(this,this.state());this.getSession()}getSessionId(){var i;if((i=this.order)===null||i===void 0?void 0:i.id)return this.order.id;return o(window.location.href,"sc_order")}async getSession(){var i;if(!this.getSessionId())return;if((i=this.order)===null||i===void 0?void 0:i.id)return;try{this.loading=true;this.order=await await s({path:r(`surecart/v1/checkouts/${this.getSessionId()}`,{expand:["checkout_fees","shipping_fees","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:true,currency_conversion:false})})}catch(i){if(i===null||i===void 0?void 0:i.message){this.error=i.message}else{this.error=wp.i18n.__("Something went wrong","surecart")}}finally{this.loading=false}}state(){var i,e;const t=(i=this.order)===null||i===void 0?void 0:i.manual_payment_method;return{processor:"stripe",loading:this.loading,orderId:this.getSessionId(),order:this.order,customer:(e=this.order)===null||e===void 0?void 0:e.customer,manualPaymentTitle:t===null||t===void 0?void 0:t.name,manualPaymentInstructions:t===null||t===void 0?void 0:t.instructions}}renderOnHold(){var i,t,o;if(((i=this.order)===null||i===void 0?void 0:i.status)!=="processing")return null;if(((o=(t=this===null||this===void 0?void 0:this.order)===null||t===void 0?void 0:t.payment_intent)===null||o===void 0?void 0:o.processor_type)==="paypal"){return e("sc-alert",{type:"warning",open:true},wp.i18n.__("Paypal is taking a closer look at this payment. It’s required for some payments and normally takes up to 3 business days.","surecart"))}}renderManualInstructions(){var i;const t=(i=this.order)===null||i===void 0?void 0:i.manual_payment_method;if(!(t===null||t===void 0?void 0:t.instructions))return;return e("sc-alert",{type:"info",open:true},e("span",{slot:"title"},t===null||t===void 0?void 0:t.name),e("div",{innerHTML:t===null||t===void 0?void 0:t.instructions}))}render(){var i,o;return e(t.Provider,{key:"21e583d8b2407ebce3a355b5d303475433373148",state:this.state()},e("div",{key:"0814352b24e81fad53da042bbba33ea97025ad66",class:{"order-confirmation":true}},e("div",{key:"ca6c449acae714b486e6144753c67b3d554fc40d",class:{"order-confirmation__content":true,hidden:!((i=this.order)===null||i===void 0?void 0:i.id)&&!this.loading}},e("sc-order-confirm-components-validator",{key:"0b02ab7520b6dc6ee6abe2deef6ae9611f025383",checkout:this.order},e("slot",{key:"4a5fc2e13dccb99863415f68ea74d626972b04d4"}))),!((o=this.order)===null||o===void 0?void 0:o.id)&&!this.loading&&e("sc-heading",{key:"baead488ab30c8c5ebfb8bc67929a627cf61f624"},wp.i18n.__("Order not found.","surecart"),e("span",{key:"04e9c0c2d341cbcc00a5b2d66d9b8620ddedf076",slot:"description"},wp.i18n.__("This order could not be found. Please try again.","surecart")))))}};d.style=a;export{d as sc_order_confirmation};
//# sourceMappingURL=p-c1890633.entry.js.map