import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useVariants as t,OptionSpecialStyle as i}from"@gem-sdk/core";import{createStyle as n,createClass as r}from"@gem-sdk/system";import{postPurchaseSpacing as m}from"../../../../common/helper.js";import{getDisplayLabelSetting as s}from"../common/helpers.js";import{getVariantItemWrapperStyles as a,getDisplayLabelStyles as p,getDisplayLabelSettingStyles as l}from"../common/styles.js";import d from"./variants/Dropdown.js";import c from"./variants/VariantItem.js";import u from"../../../../../text/components/Text.js";import{getProductOptionClasses as f,getVariantItemWrapperClasses as h,getDropdownVariantWrapperClasses as v}from"../common/classes.js";let ProductOption=({option:y,indexOption:g,productVariantSettings:j,styles:w,setting:b,builderProps:N,optionLength:T})=>{let{showAsSwatches:x}=b??{},{align:P}=w??{},{uid:$}=N??{},k=t(),{getVariantConfiguration:A,getSwatchDropdownAutoWidth:C,hasPreSelected:O,variantId:S,selectedOptions:V,isChangeVariant:D}=j,I=A(y.name),K=I?I.optionType:y.optionType,W=(O||S)&&y.name?V?.[y.name]:void 0,_=I?.hide;if(_)return null;let q=I.presets[K],z=q?.labelToggle,B=q?.itemSpacing,E=m[B||"none"],F=n({...a(K,E)}),G=r({...f()}),H=r({...h()}),J=r({...v(w)}),L=n({...p(P)});return o("div",{className:G,children:[z&&"dropdown"!==K&&e(u,{style:L,styles:l(),setting:s({option:y,hasPreSelected:O,isChangeVariant:D,selectedOptions:V})}),o("div",{className:H,style:F,children:[x&&i.includes(`${K}`)&&y.values.map(o=>{let t=(!!O||!!D||!!S)&&!!y.name&&V?.[y.name]===o.label;return e(c,{variantKey:`${y.id}-${o.id}`,showAsSwatches:x,uid:$,name:y.name,value:o,optionNumber:T,optionPosition:g,...w,...b,presetConfiguration:A(y.name),checked:t,optionType:K||"dropdown"},o.id)}),e("div",{className:J,children:("dropdown"===K||x&&!i.includes(`${K}`))&&"radio_buttons"!==K&&e(d,{...w,...b,variants:k,preset:q,option:y,initValue:W,label:y.name,presetConfiguration:A(y.name),swatchAutoWidth:C(),optionPosition:g,optionNumber:T})})]})]},y.id)};export{ProductOption as default};
