import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { o as openWormhole } from './consumer.js';
import { _ as __ } from './default-i18n.js';
import './index2.js';
import { d as defineCustomElement$4 } from './sc-format-number2.js';
import { d as defineCustomElement$3 } from './sc-line-item2.js';
import { d as defineCustomElement$2 } from './sc-skeleton2.js';
import { d as defineCustomElement$1 } from './sc-total2.js';

const scLineItemTotalCss = ":host{display:block}sc-line-item{text-align:left}.line-item-total__group sc-line-item{margin:4px 0px !important}.scratch-price{text-decoration:line-through;color:var(--sc-color-gray-500);font-size:var(--sc-font-size-small);margin-right:var(--sc-spacing-xx-small)}";

const ScLineItemTotal = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    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, _h, _j, _k, _l;
    // 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 = this.order) === null || _h === void 0 ? void 0 : _h.total_savings_amount) && this.total === 'total' && (h("sc-format-number", { class: "scratch-price", type: "currency", value: -((_j = this.order) === null || _j === void 0 ? void 0 : _j.total_savings_amount) + ((_k = this.order) === null || _k === void 0 ? void 0 : _k.total_amount), currency: ((_l = this.order) === null || _l === void 0 ? void 0 : _l.currency) || 'usd' })), h("sc-total", { order: this.order, total: this.total }))));
  }
  static get style() { return scLineItemTotalCss; }
}, [1, "sc-line-item-total", {
    "total": [1],
    "loading": [4],
    "order": [16],
    "size": [1]
  }]);
openWormhole(ScLineItemTotal, ['order', 'loading', 'calculating'], false);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-line-item-total", "sc-format-number", "sc-line-item", "sc-skeleton", "sc-total"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-line-item-total":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScLineItemTotal);
      }
      break;
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "sc-line-item":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-skeleton":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
    case "sc-total":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { ScLineItemTotal as S, defineCustomElement as d };
