'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),r=require("../../../text/components/Text.js"),a=require("./components/variants/index.js"),o=require("./components/dropdown-swatches/Dropdown.js"),s=require("./components/dropdown-group/DropdownGroup.js"),n=require("../../../common/components/NoDataState.js"),i=require("@gem-sdk/system"),l=require("./common/main/styles.js"),p=require("./common/main/getAttr.js"),c=require("./common/main/classes.js"),u=require("./common/main/getData.js"),d=require("./hooks/useGpVariants.js"),m=require("./common/variants/classes.js"),y=require("./common/variants/styles.js");exports.default=g=>{let{t:j}=t.useI18nStore(),{builderProps:f,styles:h,setting:x}=g,{align:v,optionTypo:S,swatchItemWidth:q,dropdownItemWidth:w,swatchSpacing:V,marginBottom:C}=h??{},{label:D,showAsSwatches:N,layout:T,hasPreSelected:b}=x??{},{uid:A}=f??{},O=t.useVariants(),{mode:k,options:E,variantId:G,elementRef:I,variantGroup:W,isChangeVariant:P,selectedOptions:$,isDefaultVariant:_,getVariantConfiguration:B,redirectProductShopifyLink:M}=d.useGpVariants(g,O),R=()=>{let e={};return t.DEVICES.forEach(r=>{let a=t.getResponsiveValueByScreen(q,r);e[r]="auto"===a}),e},z=()=>{let e={};return t.DEVICES.forEach(t=>{e[t]=w?.[t]==="fill"}),e},K=i.createClass(c.getWrapDropdownClass(v)),F=u.getDropdownGroupData(g);if(_&&"edit"===k)return e.jsx(n.default,{elementType:"secondary",description:j("Setup options like colors, sizes with product variant."),descriptionActions:[{text:j("Add new variant"),callback:M},{text:j("sync data"),callback:"syncProduct"}]});if(_)return;let H=i.createAttr(p.getAttrs({uid:A,hasPreSelected:b})),J=i.createStyle(l.getWrapperStyle(g)),L=i.createClass({"gp-flex gp-flex-col !gp-ml-0":!0});return e.jsx("div",{ref:I,...H,className:L,style:J,children:i.If(W,e.jsx("div",{className:K,children:e.jsx(s.default,{...F})}),(()=>{let s=E?.filter(e=>{let t=B(e.name);return!t?.hide});return s?.map((n,p)=>{let d=B(n.name),j=d?d.optionType:n.optionType,f=d?d.presets[d.optionType||"rectangle_list"]?.spacing:V,q=(b||G)&&n.name?$?.[n.name]:void 0,w=i.createClass(c.getVariantOptionGroupClass(v)),k=i.createStyle(l.getVariantOptionGroupStyle(V,f)),I=u.getTextVariantTitleData(g,"React",{optionName:n.name,hasPreSelected:b,selectedOptions:$,styleOptionSelected:j}),W=i.createClass(m.getWrapVariantOptionClass(T,v)),_=p===s.length-1;return e.jsxs("div",{className:W,style:i.createStyle(y.getMarginBottomStyle(C,_)),children:[i.If(D,e.jsx(r.default,{...I})),e.jsxs("div",{className:w,style:k,children:[N&&t.OptionSpecialStyle.includes(`${j}`)&&n.values.map(t=>{let r=(!!b||!!P||!!G)&&!!n.name&&$?.[n.name]===t.label;return e.jsx(a.default,{variantKey:`${n.id}-${t.id}`,showAsSwatches:N,uid:A,optionName:n.name??"",optionValue:t.label??"",name:n.name,value:t,optionNumber:E.length,optionPosition:p,...h,...x,presetConfiguration:B(n.name),checked:r,typeOfOption:j||"dropdown",swatchAutoWidth:R(),optionTypo:S},t.id)}),i.If(("dropdown"===j||N&&!t.OptionSpecialStyle.includes(`${j}`))&&"radio_buttons"!==j,e.jsx(o.default,{...h,...x,variants:O,option:n,initValue:q,presetConfiguration:B(n.name),swatchAutoWidth:z(),optionTypo:S,optionPosition:p,optionNumber:E.length}))]})]},n.id)})})())})};
