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:"8880988be24c475421d2b54c9dfd945684766746"},h("slot",{key:"0301cb11f3a0e1d10d60df81dc880ffc77693aaa"}),h("sc-dialog",{key:"a96eb1959b206b58dc1ada90b707963e779e62f4",open:!!this.showSuccessModal,style:{"--body-spacing":"var(--sc-spacing-xxx-large)","--width":"400px"},noHeader:!0,onScRequestClose:e=>e.preventDefault()},h("div",{key:"496ecd0823810af00622b5a37748b9c2c9837b5f",class:"confirm__icon"},h("div",{key:"9677f7f47900bf129659b27a00eb90e06368a36f",class:"confirm__icon-container"},h("sc-icon",{key:"167e6fbc7a880b4092aadf657c3a780ac8136cda",name:"check"}))),h("sc-dashboard-module",{key:"ff63fb9cc9c26176ff347c9809cab0c186ecbdf1",heading:__("Test checkout successful!","surecart"),style:{"--sc-dashboard-module-spacing":"var(--sc-spacing-x-large)",textAlign:"center"}},h("span",{key:"02716802dc259ae7505ab69a817e3a6da55129c9",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:"fe6f7c7134aa4a30fb9eeb04451b418018e05c13",type:"info",open:!0,style:{"text-align":"left"}},h("span",{key:"c3ccaecdf4d8a9407ef333691d631c83a713b23a",slot:"title"},null===(s=this.manualPaymentMethod)||void 0===s?void 0:s.name),h("div",{key:"4881bc45861b75cd49989239a6ea074e8418f5a6",innerHTML:null===(c=this.manualPaymentMethod)||void 0===c?void 0:c.instructions})),h("sc-button",{key:"b27f7d8f4844d5c6fc05efc5915232fd2c3cf079",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:"c1ba21e3fec1994dd1d27c0207138e58428c0113",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"}]}}