'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../common/common.js"),s=require("@gem-sdk/system"),l=require("../../common/base/classes.js"),a=require("../../common/base/attrs.js"),o=require("../../common/base/styles.js");exports.default=c=>{let{value:i,checked:n,optionTypography:m,optionTypo:g,swatchesImage:p,swatchesColor:d,preset:C,typeOfOption:f,available:h,variantKey:x,soldOutMarkLine:u}=c,y=r.useMemo(()=>"color"===f,[f]),j=C?.optionBgColor,v=C?.optionBorder,b=C?.optionRounded,S=r.useMemo(()=>"image"===f||"image_shopify"===f,[f]),w=r.useMemo(()=>n?t.isColorDark(j?.active)?"#fff":"#121212":t.isColorDark(j?.normal)?"#fff":"#121212",[j?.active,j?.normal,n]),D=e=>t.isColorDark(e)?"#fff":"#121212",q=()=>s.If(u,e.jsx("style",{children:`
        .${x}:before {
          width: ${y&&d?.length?`calc(${C?.height} - 12px) !important`:"200px !important"};
          border-color: ${y?"#121212":w};
        }
        `})," "),A=s.createClass(l.getColorClass({soldOutMarkLine:u,available:h})),W=()=>e.jsx(e.Fragment,{children:d?.map(t=>{let l=t,a=t.startsWith("linear-gradient");a&&(l=t.match(/#(([\da-fA-F]{2}){3,4}|([\da-fA-F]){3,4})/g)?.[0]);let c=s.createStyle(o.getColorStyle({optionRounded:b,optionBorder:v,isActive:n,color:t}));return e.jsxs(r.Fragment,{children:[e.jsx("style",{children:`
                .${x} .color:before {
                  border-color: ${D(l)} !important;
                }
                `}),e.jsx("div",{className:A,style:c},t)]},t)})}),N=s.createClass(l.getWrapperTextClass(S,y)),$=s.createStyle(o.getWrapperTextStyle(c)),k=s.createClass(l.getTextClass({optionTypo:g,optionTypography:m,isColorType:y,isUploadImageType:S})),F=s.createStyle(o.getTextStyle({optionTypo:g,optionTypography:m})),L=()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:N,style:$,children:[q(),s.If(S,e.jsxs("svg",{width:"15",height:"12",viewBox:"0 0 15 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"2",cy:"2",r:"2",fill:"#D6D6D6"}),e.jsx("path",{d:"M0.196854 10.6453L2.40968 8.05946C2.4846 7.97175 2.57719 7.9008 2.68141 7.85124C2.78562 7.80168 2.89913 7.77461 3.01452 7.77181C3.12991 7.76902 3.2446 7.79055 3.3511 7.835C3.45761 7.87945 3.55353 7.94583 3.63262 8.02981L4.66733 9.12714L8.71205 4.29464C8.79123 4.19995 8.89077 4.1243 9.00325 4.07333C9.11573 4.02236 9.23827 3.99737 9.36176 4.00022C9.48524 4.00307 9.6065 4.03369 9.71651 4.08979C9.82651 4.1459 9.92245 4.22605 9.99717 4.32429L14.8329 10.6772C14.9254 10.7989 14.982 10.9441 14.9964 11.0962C15.0107 11.2484 14.9823 11.4016 14.9144 11.5385C14.8464 11.6754 14.7415 11.7907 14.6115 11.8713C14.4815 11.952 14.3316 11.9948 14.1786 11.995L0.822048 12C0.664945 11.9999 0.511148 11.9549 0.378853 11.8703C0.246557 11.7857 0.141299 11.6649 0.0755311 11.5224C0.00976323 11.3799 -0.013762 11.2216 0.00773837 11.0661C0.0292388 10.9107 0.0948652 10.7646 0.196854 10.6453Z",fill:"#D6D6D6"})]})),e.jsx("span",{className:k,style:F,children:i?.label})]})}),M=()=>e.jsx("img",{className:"gp-h-full gp-w-full gp-object-cover",src:p,alt:""}),I=s.createClass(l.getWrapperClass(c)),T=s.createAttr(a.getWrapperAttr(c)),_=s.createStyle(o.getWrapperStyleActive(c)),B=s.createStyle(o.getWrapperStyleNormalAndHover(c)),H=n?_:B;return e.jsxs("div",{...T,className:I,style:H,children:[q(),(()=>{switch(f){case"color":return s.If(d&&d.length>0,W(),L());case"image":case"image_shopify":return s.If(!!p,M(),L());default:return L()}})()]})};
