"use strict";var e=require("@gem-sdk/core"),i=require("@gem-sdk/system"),s=require("./common/const.js");exports.renderOptionValuesNewFormatSwatches=n=>{let{renderVariantItem:t,variantPresetsLiquid:r}=n;return e.template`
    ${i.Liquid("{%- assign optionRendered = false -%}")}
    ${i.Liquid("{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}")}

    ${i.Liquid(`{% for swatch in swatches %}
      {%- assign optionTitle = swatch.optionTitle -%}
      {%- assign optionType = swatch.optionType -%}
      {%- assign labelsString = "" -%}
      {%- assign colorArraysString = "" -%}
      {%- assign imageUrlsString = "" -%}

      {% for optionValue in swatch.optionValues %}
        {%- assign labelsString = labelsString | append: optionValue.label | append: '${s.OPTION_VALUES_DELIMITER}' -%}
        {%- assign colorsJoined = optionValue.colors | join: '${s.OPTION_VALUES_DELIMITER}' -%}
        {%- assign colorArraysString = colorArraysString | append: colorsJoined | append: '${s.OPTION_VALUES_DELIMITER}' -%}
        {%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: '${s.OPTION_VALUES_DELIMITER}' -%}
      {% endfor %}

      {%- assign labels = labelsString | split: '${s.OPTION_VALUES_DELIMITER}' | slice: 0, labelsString.size -%}
      {%- assign colorStrings = colorArraysString | split: '${s.OPTION_VALUES_DELIMITER}' | slice: 0, colorArraysString.size -%}
      {%- assign imageUrls = imageUrlsString | split: '${s.OPTION_VALUES_DELIMITER}' | slice: 0, imageUrlsString.size -%}

      {% if optionTitle == option.name %}
        {%- assign variantPresetString = "${r}" -%}
        {%- assign optionName = option.name | replace: "'", "&apos;" | replace: '"', "&quot;" -%}
        {%- assign items = variantPresetString | split: '($2)' -%}
        {%- assign type = 'dropdown' -%}

        {% for item in items %}
          {%- assign itemPreset = item | split: '($1)' -%}
          {% if itemPreset[0] == optionName %}{%- assign type = itemPreset[1] -%}{% endif %}
          {% if itemPreset[0] == 'base' %}{%- assign type = itemPreset[1] -%}{% endif %}
        {% endfor %}
        {%- assign optionRendered = true -%}

        ${t({showDropdown:!0})}
      {% endif %}
    {% endfor %}`)}

    ${i.LiquidIf("optionRendered == false",t({showDropdown:!1,isRenderDefault:!0,typeOfOption:"optionType"}))}
  `};
