import{Fragment,h}from"@stencil/core";import{state}from"../../../../store/upsell/index";import{__,sprintf}from"@wordpress/i18n";export class ScUpsellTotals{renderAmountDue(){var e,t;return state.amount_due>0?null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_display_amount:(null===(t=null==state?void 0:state.line_item)||void 0===t?void 0:t.trial_amount)?__("Trial","surecart"):__("Free","surecart")}getCurrencyToDisplay(){var e,t,l,i,a,s,n;return(null===(l=null===(t=null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_default_currency_display_amount)||void 0===t?void 0:t.toLowerCase())||void 0===l?void 0:l.includes(null===(a=null===(i=null==state?void 0:state.line_item)||void 0===i?void 0:i.currency)||void 0===a?void 0:a.toLowerCase()))?"":null===(n=null===(s=null==state?void 0:state.line_item)||void 0===s?void 0:s.currency)||void 0===n?void 0:n.toUpperCase()}renderConversion(){var e,t,l,i,a,s;const n=null==state?void 0:state.checkout;return(null==n?void 0:n.show_converted_total)?(null==n?void 0:n.currency)===(null==n?void 0:n.current_currency)?null:(null===(e=null==state?void 0:state.line_item)||void 0===e?void 0:e.total_amount)?h(Fragment,null,h("sc-divider",null),h("sc-line-item",{style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{slot:"title"},h("slot",{name:"charge-amount-description"},sprintf(__("Payment Total","surecart"),null===(l=null===(t=null==state?void 0:state.line_item)||void 0===t?void 0:t.currency)||void 0===l?void 0:l.toUpperCase()))),h("span",{slot:"price"},this.getCurrencyToDisplay()&&h("span",{class:"currency-label"},this.getCurrencyToDisplay()),null===(i=null==state?void 0:state.line_item)||void 0===i?void 0:i.total_default_currency_display_amount)),h("sc-line-item",null,h("span",{slot:"description",class:"conversion-description"},sprintf(__("Your payment will be processed in %s.","surecart"),null===(s=null===(a=null==state?void 0:state.line_item)||void 0===a?void 0:a.currency)||void 0===s?void 0:s.toUpperCase())))):null:null}render(){var e,t,l,i,a,s,n;return h("sc-summary",{key:"5e51e4f2d57d941315f7194bfdb6b7ca05064be3","open-text":"Total","closed-text":"Total",collapsible:!0,collapsed:!0},!!(null===(e=state.line_item)||void 0===e?void 0:e.id)&&h("span",{key:"6db4cb6aff477a5ca39464185d5314ddec9b7c10",slot:"price"},this.renderAmountDue()),h("sc-divider",{key:"36e72c9e2e44b790ce40d8dc26fb6d17e2715d2d"}),h("sc-line-item",{key:"bd9e43fb6bfa0f2aee6d374e8aebae30f5d4c528"},h("span",{key:"1fe30f972808c90348d12ff45fd19ed3ea310a11",slot:"description"},__("Subtotal","surecart")),h("span",{key:"d8f0193a7ba8b97b14195310fe832de0f7515114",slot:"price"},null===(t=state.line_item)||void 0===t?void 0:t.subtotal_display_amount)),((null===(i=null===(l=null==state?void 0:state.line_item)||void 0===l?void 0:l.fees)||void 0===i?void 0:i.data)||[]).filter((e=>"upsell"===e.fee_type)).map((e=>h("sc-line-item",null,h("span",{slot:"description"},e.description," ",`(${__("one time","surecart")})`),h("span",{slot:"price"},null==e?void 0:e.display_amount)))),!!(null===(a=state.line_item)||void 0===a?void 0:a.tax_amount)&&h("sc-line-item",{key:"89ff1c99d84e425b1b9711c68ec8f310394bb606"},h("span",{key:"745dc449429f6e5477d402f8b69c575063524f46",slot:"description"},__("Tax","surecart")),h("span",{key:"eaae0e33767a697afbb3c1c75be1086aaa812671",slot:"price"},null===(s=state.line_item)||void 0===s?void 0:s.tax_display_amount)),h("sc-divider",{key:"89fa21fbe6b6acc1bbe5152139a4ef798f877da6"}),h("sc-line-item",{key:"7417b410544ac8ad468559c3be69dae70070d4e7",style:{"--price-size":"var(--sc-font-size-x-large)"}},h("span",{key:"4021ded5d9a097a6c0539c6b7e057ee865a2f9e8",slot:"title"},__("Total","surecart")),h("span",{key:"406f967030d47dc0a85843665e5287fb3eaec1ac",slot:"price"},null===(n=state.line_item)||void 0===n?void 0:n.total_display_amount)),this.renderConversion())}static get is(){return"sc-upsell-totals"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-upsell-totals.css"]}}static get styleUrls(){return{$:["sc-upsell-totals.css"]}}}