import{RenderIf as s,isLocalEnv as e,baseAssetURL as r,template 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 _=({builderProps:_,setting:k,children:w,style:N,formType:S,advanced:M,pageContext:b,styles:C})=>{let E=o({val:k?.errorMessage,uid:_?.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:k?.successMessage,uid:_?.uid,settingId:i({id:j?.successMessage?.id}),pageContext:b??{},defaultVal:b?.isPreviewing?"Thanks for subscribing":a("Newsletter","success_msg_default")}),h=m(_,k),x=c(_,k),I=n(u()),V=p(g("error",k)),A=p(g("success",k)),G=d(_,"error"),O=d(_,"success"),R=f(_),T=$(_),J=p(v(k,C,N)),L=n(y());return t`
    <div class="${L}" style="${J}">
      <gp-form
        ${{...h}}
        data-callback='${JSON.stringify(k?.callbackURL)}'
      >
        <a
          ${{...x}}
        >
        </a>
        {% form '${S||"customer"}', class: 'gp-form-${_?.uid} ${M?.cssClass}', id: 'contact_form_${_?.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>
          ${w}
        {% endform %}
      </gp-form>
    </div>
    ${s(e,`<script ${l('class="gps-link" delay',"src")}="{{ 'gp-form-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${l('class="gps-link" delay',"src")}="${r}/assets-v2/gp-form-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};export{_ as default};
