"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core");const SealSubscriptions=({setting:e,advanced:t})=>{let{align:r}=e??{};return core.template`
    <div
      class="${t?.cssClass}"
      style="${{...core.makeStyleResponsive("ta",r)}}"
    >
      <div class="sealsubs-target-element" data-handle="{{ product.handle }}"></div>
    </div>
    <script>
      const moneyFormatGp = {{ shop.money_format | json }};
      document.addEventListener('DOMContentLoaded', function() {
        document.addEventListener('sealsubs:price_update', function(data) {
          const subPrice = data?.detail?.price || 0
          const gpPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-price.gp-money');
          const compareAtPriceElement = data.detail?.element?.closest('gp-product')?.querySelector('gp-product-price .gp-product-compare-price');

          if (gpPriceElement) {
            gpPriceElement.innerHTML = Shopify?.formatMoney(subPrice, moneyFormatGp);
          }

          if (compareAtPriceElement) {
            const compareAtPrice = data?.detail?.compareAtPrice || 0
            setTimeout(function() {
              compareAtPriceElement.innerHTML = Shopify?.formatMoney(compareAtPrice, moneyFormatGp);
            });
          }
        });
      });
    </script>
  `};exports.default=SealSubscriptions;
