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

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

const ScLineItemTax$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
  }
  renderLabel() {
    var _a, _b, _c;
    return (h(Fragment, null, ((_a = this === null || this === void 0 ? void 0 : this.order) === null || _a === void 0 ? void 0 : _a.tax_status) === 'calculated' ? (_b = this.order) === null || _b === void 0 ? void 0 : _b.tax_label : sprintf(__('Estimated %s', 'surecart'), (_c = this === null || this === void 0 ? void 0 : this.order) === null || _c === void 0 ? void 0 : _c.tax_label), this.renderPercent()));
  }
  renderPercent() {
    var _a;
    if ((_a = this.order) === null || _a === void 0 ? void 0 : _a.tax_percent) {
      return (h(Fragment, null, '(', this.order.tax_percent, "%", ')'));
    }
    return '';
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g;
    // hide if tax is 0
    if (!((_a = this === null || this === void 0 ? void 0 : this.order) === null || _a === void 0 ? void 0 : _a.tax_amount)) {
      return null;
    }
    return (h("sc-line-item", null, h("span", { slot: "description" }, this.renderLabel()), ((_b = this.order) === null || _b === void 0 ? void 0 : _b.tax_exclusive_amount) && (h("span", { slot: "price" }, h("sc-format-number", { type: "currency", currency: ((_c = this === null || this === void 0 ? void 0 : this.order) === null || _c === void 0 ? void 0 : _c.currency) || 'usd', value: (_d = this === null || this === void 0 ? void 0 : this.order) === null || _d === void 0 ? void 0 : _d.tax_exclusive_amount }))), ((_e = this.order) === null || _e === void 0 ? void 0 : _e.tax_inclusive_amount) && (h("span", { slot: "price-description" }, '(', h("sc-format-number", { type: "currency", currency: ((_f = this === null || this === void 0 ? void 0 : this.order) === null || _f === void 0 ? void 0 : _f.currency) || 'usd', value: (_g = this === null || this === void 0 ? void 0 : this.order) === null || _g === void 0 ? void 0 : _g.tax_inclusive_amount }), " ", __('included', 'surecart'), ')'))));
  }
  static get style() { return scLineItemTaxCss; }
}, [1, "sc-line-item-tax", {
    "order": [16],
    "loading": [4]
  }]);
openWormhole(ScLineItemTax$1, ['order', 'loading'], false);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-line-item-tax", "sc-format-number", "sc-line-item"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-line-item-tax":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScLineItemTax$1);
      }
      break;
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-line-item":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}
defineCustomElement$1();

const ScLineItemTax = ScLineItemTax$1;
const defineCustomElement = defineCustomElement$1;

export { ScLineItemTax, defineCustomElement };
