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