import{h,Host}from"@stencil/core";import{__}from"@wordpress/i18n";import{state as processorsState}from"../../../../store/processors/index";import{state as selectedProcessorState}from"../../../../store/selected-processor/index";import{clearCheckout}from"../../../../store/checkout/mutations";export class ScCheckoutTestComplete{constructor(){this.showSuccessModal=!1,this.manualPaymentMethod=void 0,this.checkoutStatus=void 0,this.successUrl=void 0}handleConfirmOrderEvent(){"test_mode_restricted"===this.checkoutStatus&&this.confirmOrder()}async confirmOrder(){var e;this.manualPaymentMethod=null===(e=processorsState.manualPaymentMethods||[])||void 0===e?void 0:e.find((e=>e.id===selectedProcessorState.id)),this.showSuccessModal=!0,clearCheckout()}handleSuccessModal(){this.showSuccessModal&&setTimeout((()=>{var e;null===(e=this.continueButton)||void 0===e||e.focus()}),50)}render(){var e,t,s,c,o;return h(Host,{key:"3c0c52fb69aacbf3bf4fb797586c7a2432c1f790"},h("slot",{key:"d63060fd4eb7e78e7a658bbd8d17c0cf8707e473"}),h("sc-dialog",{key:"01e59224ca7271e9bd5c7457e374f097e4276a73",open:!!this.showSuccessModal,style:{"--body-spacing":"var(--sc-spacing-xxx-large)","--width":"400px"},noHeader:!0,onScRequestClose:e=>e.preventDefault()},h("div",{key:"039b32ae7d4c69f45ee0269422cac7154e333ec3",class:"confirm__icon"},h("div",{key:"1a9da9a6d06ab049b13e26dfc59a89e79de54a87",class:"confirm__icon-container"},h("sc-icon",{key:"3e4b7bd0355bd487dfb6c8064353adb79f348b14",name:"check"}))),h("sc-dashboard-module",{key:"3be338aee9787680a67a7dc62fb1f7c835702f98",heading:__("Test checkout successful!","surecart"),style:{"--sc-dashboard-module-spacing":"var(--sc-spacing-x-large)",textAlign:"center"}},h("span",{key:"b0ae504ecc5c5ba5bc9f2bd7808cfa3b1ec7b088",slot:"description"},__("This is a simulated test checkout, and no orders were processed. To perform a test order, please contact your store administrator. ","surecart")),!!(null===(e=this.manualPaymentMethod)||void 0===e?void 0:e.name)&&!!(null===(t=this.manualPaymentMethod)||void 0===t?void 0:t.instructions)&&h("sc-alert",{key:"a3781ca62e40a451874384561f69d4443efec91e",type:"info",open:!0,style:{"text-align":"left"}},h("span",{key:"ead7333597d5ba39dafc5ec79713a3311ac8f316",slot:"title"},null===(s=this.manualPaymentMethod)||void 0===s?void 0:s.name),h("div",{key:"98fd27422acf9b9f822a96735828b99660e02ebe",innerHTML:null===(c=this.manualPaymentMethod)||void 0===c?void 0:c.instructions})),h("sc-button",{key:"fae99645209c19f410aea3814cb15da84e2f714f",href:null===(o=null===window||void 0===window?void 0:window.scData)||void 0===o?void 0:o.home_url,size:"large",type:"primary",ref:e=>this.continueButton=e},__("Go to Homepage","surecart"),h("sc-icon",{key:"11c366e99b08f2197a044734c748d98d6a29aa35",name:"arrow-right",slot:"suffix"})))))}static get is(){return"sc-checkout-test-complete"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["checkout-test-complete.scss"]}}static get styleUrls(){return{$:["checkout-test-complete.css"]}}static get properties(){return{checkoutStatus:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Checkout status to listen and do payment related stuff."},attribute:"checkout-status",reflect:!1},successUrl:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Success url."},attribute:"success-url",reflect:!1}}}static get states(){return{showSuccessModal:{},manualPaymentMethod:{}}}static get events(){return[{method:"scOrderPaid",name:"scOrderPaid",bubbles:!0,cancelable:!0,composed:!0,docs:{tags:[],text:"The order is paid event."},complexType:{original:"Checkout",resolved:"Checkout",references:{Checkout:{location:"import",path:"../../../../types",id:"src/types.ts::Checkout"}}}},{method:"scSetState",name:"scSetState",bubbles:!0,cancelable:!0,composed:!0,docs:{tags:[],text:""},complexType:{original:"string",resolved:"string",references:{}}}]}static get elementRef(){return"el"}static get watchers(){return[{propName:"checkoutStatus",methodName:"handleConfirmOrderEvent"},{propName:"showSuccessModal",methodName:"handleSuccessModal"}]}}