import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { d as defineCustomElement$3 } from './sc-alert2.js';
import { d as defineCustomElement$2 } from './sc-icon2.js';
import { d as defineCustomElement$1 } from './sc-order-manual-instructions2.js';

const ScOrderConfirmComponentsValidator = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
  }
  handleOrderChange() {
    var _a;
    if ((_a = this.checkout) === null || _a === void 0 ? void 0 : _a.manual_payment) {
      this.addManualPaymentInstructions();
    }
  }
  addManualPaymentInstructions() {
    var _a, _b;
    if (this.hasManualInstructions)
      return;
    const details = this.el.shadowRoot
      .querySelector('slot')
      .assignedElements({ flatten: true })
      .find(element => element.tagName === 'SC-ORDER-CONFIRMATION-DETAILS');
    const address = document.createElement('sc-order-manual-instructions');
    (_b = (_a = details === null || details === void 0 ? void 0 : details.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore) === null || _b === void 0 ? void 0 : _b.call(_a, address, details);
    this.hasManualInstructions = true;
  }
  componentWillLoad() {
    this.hasManualInstructions = !!this.el.querySelector('sc-order-manual-instructions');
  }
  render() {
    return h("slot", null);
  }
  get el() { return this; }
  static get watchers() { return {
    "checkout": ["handleOrderChange"]
  }; }
}, [1, "sc-order-confirm-components-validator", {
    "checkout": [16],
    "hasManualInstructions": [32]
  }]);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-order-confirm-components-validator", "sc-alert", "sc-icon", "sc-order-manual-instructions"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-order-confirm-components-validator":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScOrderConfirmComponentsValidator);
      }
      break;
    case "sc-alert":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-icon":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
    case "sc-order-manual-instructions":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { ScOrderConfirmComponentsValidator as S, defineCustomElement as d };
