"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),s=require("../../../helpers.js"),t=require("./common/attrs.js"),r=require("@gem-sdk/system"),a=require("./common/styles.js"),o=require("./common/classes.js"),c=require("../contact/common/styles.js"),l=require("../contact/common/classes.js"),i=require("../../settings/newsletter/configs/translate.js");exports.default=({builderProps:d,setting:m,children:n,style:g,formType:p,advanced:u,pageContext:f,styles:$})=>{let y=s.getDynamicSourceLocales({val:m?.errorMessage,uid:d?.uid,settingId:s.createSettingId({id:i.Newsletter?.errorMessage?.id}),pageContext:f??{},defaultVal:f?.isPreviewing?`Can’t send email. Please try again later.`:s.getStaticLocale("Newsletter","err_msg_default")}),v=s.getDynamicSourceLocales({val:m?.successMessage,uid:d?.uid,settingId:s.createSettingId({id:i.Newsletter?.successMessage?.id}),pageContext:f??{},defaultVal:f?.isPreviewing?"Thanks for subscribing":s.getStaticLocale("Newsletter","success_msg_default")}),S=t.composeContainerAttrs(d,m),C=t.composeAnchorAttrs(d,m),j=r.createClass(o.composeFormClasses()),_=r.createStyle(a.composeFormStyles("error",m)),q=r.createStyle(a.composeFormStyles("success",m)),A=t.composeFormAttrs(d,"error"),P=t.composeFormAttrs(d,"success"),k=t.composePopoverAttrs(d),w=a.popoverStyles(d),L=r.createStyle(c.composeContainerStyles(m,$,g)),b=r.createClass(l.composeContainerClasses());return e.template`
    <div class="${b}" style="${L}">
      <gp-form
        ${{...S}}
        data-callback='${JSON.stringify(m?.callbackURL)}'
      >
        <a
          ${{...C}}
        >
        </a>
        {% form '${p||"customer"}', class: 'gp-form-${d?.uid} ${u?.cssClass}', id: 'contact_form_${d?.uid}' %}
          {% if form.errors %}
            <div
              ${{...A}}
              class="${j}"
              style="${_}"
            >
              ${y}
            </div>
          {% endif %}
          <div popover ${{...k}}>
            <style>
              ${w}
            </style>
            <div
              ${{...P}}
              class="${j}"
              style="${q}"
            >
              ${v}
            </div>
          </div>
          ${n}
        {% endform %}
      </gp-form>
    </div>
    ${e.RenderIf(e.isLocalEnv,`<script ${s.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-form-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${s.getSettingPreloadData('class="gps-link" delay',"src")}="${e.baseAssetURL}/assets-v2/gp-form-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
