import { r as registerInstance, h } from './index-f1d2a96f.js';
import { o as openWormhole } from './consumer-7a54eb9f.js';
import { _ as __ } from './default-i18n-91ef32a0.js';
import './index-0a61debd.js';
import './_commonjsHelpers-9943807e.js';

const scLineItemTotalCss = ":host{display:block}sc-line-item{text-align:left}.line-item-total__group sc-line-item{margin:4px 0px !important}";

const ScLineItemTotal = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.total = 'total';
    this.order_key = {
      total: 'total_amount',
      subtotal: 'subtotal_amount',
      amount_due: 'amount_due',
    };
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g;
    // loading state
    if (this.loading && !((_a = this.order) === null || _a === void 0 ? void 0 : _a[(_b = this === null || this === void 0 ? void 0 : this.order_key) === null || _b === void 0 ? void 0 : _b[this === null || this === void 0 ? void 0 : this.total]])) {
      return (h("sc-line-item", null, h("sc-skeleton", { slot: "title", style: { width: '120px', display: 'inline-block' } }), h("sc-skeleton", { slot: "price", style: { 'width': '70px', 'display': 'inline-block', 'height': this.size === 'large' ? '40px' : '', '--border-radius': '6px' } })));
    }
    if (!((_c = this.order) === null || _c === void 0 ? void 0 : _c.currency))
      return;
    // if the total amount is different than the amount due.
    if (this.total === 'total' && ((_d = this.order) === null || _d === void 0 ? void 0 : _d.total_amount) !== ((_e = this.order) === null || _e === void 0 ? void 0 : _e.amount_due)) {
      return (h("div", { class: "line-item-total__group" }, h("sc-line-item", null, h("span", { slot: "description" }, h("slot", { name: "title" }), h("slot", { name: "description" })), h("span", { slot: "price" }, h("sc-total", { order: this.order, total: this.total }))), h("sc-line-item", { style: { '--price-size': 'var(--sc-font-size-x-large)' } }, h("span", { slot: "title" }, h("slot", { name: "subscription-title" }, __('Total Due Today', 'surecart'))), h("span", { slot: "price" }, h("sc-format-number", { type: "currency", currency: (_f = this.order) === null || _f === void 0 ? void 0 : _f.currency, value: (_g = this.order) === null || _g === void 0 ? void 0 : _g.amount_due })))));
    }
    return (h("sc-line-item", { style: this.size === 'large' ? { '--price-size': 'var(--sc-font-size-x-large)' } : {} }, h("span", { slot: "title" }, h("slot", { name: "title" })), h("span", { slot: "description" }, h("slot", { name: "description" })), h("span", { slot: "price" }, h("sc-total", { order: this.order, total: this.total }))));
  }
};
openWormhole(ScLineItemTotal, ['order', 'loading', 'calculating'], false);
ScLineItemTotal.style = scLineItemTotalCss;

export { ScLineItemTotal as sc_line_item_total };
