'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),s=require("react"),a=require("../base/base.js"),l=require("../color/color.js"),r=require("../image/Image.js"),i=require("../image-shopify/ImageShopify.js"),o=require("../rectangle-list/RectangleList.js"),n=require("@gem-sdk/system"),u=require("../../common/variants/classes.js"),c=require("../../common/variants/styles.js"),d=require("../../common/variants/attrs.js");const p=p=>{let{name:m,variantKey:g,optionName:h,optionValue:v,typeOfOption:b}=p,{setSelectedOption:f}=t.useSelectedOption(),j=t.useProduct(),y=s.useMemo(()=>{if(!p.presetConfiguration)return;let{presets:e,optionType:t}=p.presetConfiguration;return e?.[t||"rectangle_list"]},[p.presetConfiguration]),w=s.useMemo(()=>{if(!p.showAsSwatches)return o.default;switch(b){case"color":return l.default;case"image":return r.default;case"image_shopify":return i.default;default:return a.default}},[b,p.showAsSwatches]),x=t.useVariantOutStock(m??"",p.value?.label??"",{position:p.optionPosition,optionNumber:p.optionNumber||0}),S=s.useMemo(()=>"disable"===p.soldOutStyle,[p.soldOutStyle]),C=s.useMemo(()=>"line"===p.soldOutStyle,[p.soldOutStyle]),q=n.createClass(u.getVariantItemLabelClass({...p,available:x})),O=n.createClass(u.getTooltipClass()),N=n.createClass(u.getTooltipSvgClass()),V=n.createClass(u.getVariantOptionClass()),k=n.createStyle(c.getLabelVariantStyle(y?.width)),M=n.createAttr(d.getVariantOptionAttr(p,"React"));return e.jsxs("label",{className:q,style:k,htmlFor:`${p.uid}-${g}`,children:[e.jsxs("div",{className:O,children:[e.jsx("p",{className:"gp-text-[#F9F9F9]",children:p.value?.label}),e.jsx("svg",{className:N,width:"8",height:"4",viewBox:"0 0 16 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 10L0 0L16 1.41326e-06L8 10Z",fill:"#333333"})})]}),e.jsx("input",{checked:p.checked,name:`${j?.id}-options-${m?.toString().replaceAll('"','\\"')}`,id:`${p.uid}-${g}`,value:p.value?.label,type:"radio",className:"gp-sr-only",onChange:()=>{if(x||!S){f(m,p.value?.label,j?.id);let e=new CustomEvent("change-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{optionId:m,optionValue:p.value?.label,productId:j?.id}});window.dispatchEvent(e)}}}),e.jsx("span",{className:"gp-sr-only",children:p.value?.label}),e.jsx("div",{...M,className:V,children:e.jsx(w,{...p,optionName:h,optionNameValue:v,preset:y,isVariantOutStock:S&&!x&&0!==p.optionPosition,soldOutMark:S,soldOutMarkLine:C,available:x,swatchValue:p.value,product:j,variantKey:`${p.uid}-${g}`})})]})};p.defaultProps={},exports.default=p;
