"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),system=require("@gem-sdk/system"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),translate=require("../../settings/form-dropdown/configs/translate.js");const FormDropdown=({builderProps:e,setting:s,advanced:t,pageContext:r,styles:o})=>{let{name:l,childItem:a,required:p}=s??{},d=a?.map((s,t)=>helpers.getDynamicSourceLocales({val:s,uid:e?.uid,settingId:helpers.createSettingId({id:translate.FormDropdown?.childItem?.id,index:t}),pageContext:r??{}})),c=system.createStyle(styles.composeContainerStyles(t,s)),i=system.createStyle({...styles.composeFormDropdownStyles(t,s,o),...styles.getAppendTypoStyleFirstTime(s)}),n=system.createStyle(styles.getStyleOption(s)),m=system.createClass(classes.composeContainerClasses(t,e)),y=system.createClass(classes.composeFormDropdownClasses(s));return core.template`
    <gp-form-dropdown
      data-id="${e?.uid}"
      class="${m}"
      style="${c}"
    >
      <select
        type="email"
        class="${y}"
        style="${i}"
        ${system.If(p,"required")}
        name="${l}"
        gp-data='${JSON.stringify(s).replaceAll("'","&#039;")}'
      >
        ${system.If(!Number(s?.defaultOption),`<option class="gp-hidden" value="" disabled selected>
            ${s?.placeholder}
          </option>`)}
        ${d?.map(e=>core.template`
            <option
              value="${e}"
              style="${n}"
              ${system.If(!!Number(s?.defaultOption),`selected: ${e===d[Number(s?.defaultOption)-1]}`)}
            >
              ${e}
            </option>`).join("")}
      </select>
    </gp-form-dropdown>
    ${core.RenderIf(core.isLocalEnv,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-form-dropdown-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${helpers.getSettingPreloadData('class="gps-link" delay',"src")}="${core.baseAssetURL}/assets-v2/gp-form-dropdown-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};exports.default=FormDropdown;
