import{template as t,RenderChildren as e}from"@gem-sdk/core";import{getClass as n}from"./common/classes.js";import{filterPageContext as o}from"../../../helpers.js";let a=a=>{let{pageContext:r,rawChildren:i}=a,{productItemClass:c,gpProductClass:p}=n(a);return t`
      <gp-product
        gp-context='{"variantSelected": {{ variant | json | escape }}, "inventory_management": {{ variant.inventory_management | json | escape  }}, "inventory_policy": {{ variant.inventory_policy | json | escape }}, "quantity": 1 , "inventoryQuantity": {{ variant.inventory_quantity | default: 0 }},  "formId": "{{ product_form_id }}"}'
        gp-data='{"variantSelected": {{ variant | json | escape }}, "quantity": 1, "productUrl":{{ product.url | json | escape }}, "productHandle":{{ product.handle | json | escape }}, "collectionUrl": {{ collection.url | json | escape }}, "collectionHandle": {{ collection.handle | json | escape }},"pageContext" : ${JSON.stringify(o(r))}}'
        class="${p}"

      >
        {%- form 'product', product, id: product_form_id, class: 'form contents ${c}',  data-type: 'add-to-cart-form', autocomplete: 'off' -%}
        <input type="hidden" name="id" value="{{ variant.id }}" />
        <input type="hidden" min="1" name="quantity"  value="{{ quantity }}" />
        <button type="submit" onclick="return false;" style="display:none;"></button>
          ${t`
      ${i?.map((n,o)=>{if(n)return t`
            ${e({...n,index:o})}
          `}).join("")}
    `}
        {%- endform -%}
      </gp-product>
  `};export{a as default};
