'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-9c866aeb.js');
const watchers = require('./watchers-203d7acd.js');
const ui = require('./ui-180b96fe.js');
require('./index-f6f80680.js');
require('./add-query-args-17c551b6.js');

const scCartLoaderCss = ":host{position:absolute;z-index:var(--sc-cart-z-index, 999999);font-family:var(--sc-font-sans)}";

const ScCartLoader = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    /** The mode for the form. */
    this.mode = 'live';
  }
  render() {
    var _a, _b, _c, _d;
    /**
     * Search for the sc-checkout component on a page to make sure
     * we don't show the cart on a checkout page.
     */
    if (!!document.querySelector('sc-checkout'))
      return null;
    // clear the order if it's already paid.
    const order = watchers.getOrder(this.formId, this.mode);
    if ((order === null || order === void 0 ? void 0 : order.status) === 'paid') {
      watchers.clearOrder(this.formId, this.mode);
      return null;
    }
    // return the loader.
    return index.h("div", { innerHTML: ((_b = (_a = order === null || order === void 0 ? void 0 : order.line_items) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.count) || ((_d = (_c = ui.uiStore === null || ui.uiStore === void 0 ? void 0 : ui.uiStore.state) === null || _c === void 0 ? void 0 : _c.cart) === null || _d === void 0 ? void 0 : _d.open) ? this.template : '' });
  }
};
ScCartLoader.style = scCartLoaderCss;

exports.sc_cart_loader = ScCartLoader;
