"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@gem-sdk/core"),t=require("../../../helpers.js"),s=require("@gem-sdk/system"),l=require("./common/classes.js"),o=require("./common/styles.js"),a=require("./common/helpers.js");exports.default=({setting:r,builderProps:i,pageContext:c})=>{let{displayQuantity:n}=r??{},p=s.createClass({...l.getClassContainer()}),d=s.createClass({...l.getClassToolbarWrapper()}),u=s.createClass({...l.getClassToolbarSortWrapper()}),g=s.createClass({...l.getClassSelect(r)}),y=s.createClass({...l.getClassToolbarWrapperQuantity(r)}),S=s.createClass({"gp-flex-1":!0}),v=s.createStyle({...o.getStyleCollectionToolbar(r)}),b=s.createStyle({...o.getStyleToolbarWrapper(r)}),$=s.createStyle({...o.getStyleSelect(r)}),f=s.createStyle({...o.getStyleToolbarWrapperQuantity(r)}),m=a.getSortingTextDisplayVal({setting:r,builderProps:i,pageContext:c},"liquid"),C=a.getQuantityTextDisplayVal({setting:r,builderProps:i,pageContext:c},"liquid"),_=s.createStateOrContext({uid:i?.uid});return e.template`
    <gp-collection-toolbar
      class="${p}"
      style="${v}"
      id="${i?.uid}"
      gp-data='${JSON.stringify(_)}'
    >
      <div class="${d}" style="${b}" >
        <div class="${u}">
          <select id="sorting" class="${g}" style="${$}" >

            {% if collection.sort_by == "" %}
              {% assign sort_by = collection.default_sort_by %}
            {% else %}
              {% assign sort_by = collection.sort_by %}
            {% endif %}

            <option key=${m} value="">
              ${m}
            </option>
            {% for option in collection.sort_options %}
              {% if sort_by == option.value %}
                <option value="{{ option.value }}" selected>{{ option.name }}</option>
              {% else %}
                <option value="{{ option.value }}">{{ option.name }}</option>
              {% endif %}
            {% endfor %}
          </select>
        </div>
        <div
          class="${y}"
          style="${f}"
        >
          {% assign quantityTemplate = ${C} %}
          {% assign productsCount = collection.products_count %}
          ${s.LiquidIf(n?.toString()??"",e.template`<span class="gf_product-quantity">{{ quantityTemplate | replace: '%number%', productsCount }}</span>`,"")}
        </div>
        <div class="${S}">&nbsp;</div>
      </div>
    </gp-collection-toolbar>
    ${e.RenderIf(e.isLocalEnv,`<script ${t.getSettingPreloadData('class="gps-link" delay',"src")}="{{ 'gp-collection-toolbar-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${t.getSettingPreloadData('class="gps-link" delay',"src")}="${e.baseAssetURL}/assets-v2/gp-collection-toolbar-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
  `};
