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

const scOrderConfirmationTotalsCss = ":host{display:block}";

const ScOrderConfirmationTotals = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
  }
  renderDiscountLine() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
    if (!((_c = (_b = (_a = this.order) === null || _a === void 0 ? void 0 : _a.discount) === null || _b === void 0 ? void 0 : _b.promotion) === null || _c === void 0 ? void 0 : _c.code)) {
      return null;
    }
    let humanDiscount = '';
    if ((_e = (_d = this.order) === null || _d === void 0 ? void 0 : _d.discount) === null || _e === void 0 ? void 0 : _e.coupon) {
      humanDiscount = getHumanDiscount((_g = (_f = this.order) === null || _f === void 0 ? void 0 : _f.discount) === null || _g === void 0 ? void 0 : _g.coupon);
    }
    return (h("sc-line-item", { style: { marginTop: 'var(--sc-spacing-small)' } }, h("span", { slot: "description" }, __('Discount', 'surecart'), h("br", null), ((_k = (_j = (_h = this.order) === null || _h === void 0 ? void 0 : _h.discount) === null || _j === void 0 ? void 0 : _j.promotion) === null || _k === void 0 ? void 0 : _k.code) && (h("sc-tag", { type: "success", size: "small" }, (_o = (_m = (_l = this.order) === null || _l === void 0 ? void 0 : _l.discount) === null || _m === void 0 ? void 0 : _m.promotion) === null || _o === void 0 ? void 0 : _o.code))), humanDiscount && (h("span", { class: "coupon-human-discount", slot: "price-description" }, "(", humanDiscount, ")")), h("sc-format-number", { slot: "price", type: "currency", currency: (_p = this.order) === null || _p === void 0 ? void 0 : _p.currency, value: -((_q = this.order) === null || _q === void 0 ? void 0 : _q.discount_amount) })));
  }
  render() {
    return (h("div", { class: { 'line-item-totals': true } }, h("sc-line-item-total", { order: this.order, total: "subtotal" }, h("span", { slot: "description" }, __('Subtotal', 'surecart'))), this.renderDiscountLine(), h("sc-divider", { style: { '--spacing': 'var(--sc-spacing-small)' } }), h("sc-line-item-total", { order: this.order, size: "large", "show-currency": true }, h("span", { slot: "description" }, __('Total', 'surecart')))));
  }
  static get style() { return scOrderConfirmationTotalsCss; }
}, [1, "sc-order-confirmation-totals", {
    "order": [16]
  }]);
openWormhole(ScOrderConfirmationTotals, ['order', 'busy', 'loading', 'empty'], false);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-order-confirmation-totals", "sc-divider", "sc-format-number", "sc-line-item", "sc-line-item-total", "sc-skeleton", "sc-tag", "sc-total"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-order-confirmation-totals":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScOrderConfirmationTotals);
      }
      break;
    case "sc-divider":
      if (!customElements.get(tagName)) {
        defineCustomElement$7();
      }
      break;
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        defineCustomElement$6();
      }
      break;
    case "sc-line-item":
      if (!customElements.get(tagName)) {
        defineCustomElement$5();
      }
      break;
    case "sc-line-item-total":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "sc-skeleton":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-tag":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
    case "sc-total":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { ScOrderConfirmationTotals as S, defineCustomElement as d };
