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