'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("@gem-sdk/core"),p=require("./DropdownOption.js"),a=require("react"),n=require("./VariantOption.js");exports.default=({option:l,optionPosition:i,optionNumber:s,variantGroup:r,variants:o,price:g,blankText:d,combineWidth:u,combineFullWidth:c,label:x,initValue:m,hasPreSelected:h,soldOutStyle:v,soldOutMark:f,preset:b})=>{let{setSelectedOption:w,forceSelectedOption:j,selectedOptions:y}=t.useSelectedOption(),N=t.useProduct(),k=a.useMemo(()=>"Disable"===v&&f,[v,f]),O=e=>{let p=o?.find(t=>t?.id===e);if(p&&p.selectedOptions){let e=t.parseSelectedOption(p.selectedOptions);e&&j(e,N?.id)}},[S,P]=a.useState(h?m:"blank");a.useEffect(()=>{P(y?.[l?.name??"blank"])},[y,l]),a.useEffect(()=>{h||P("blank")},[h]);let q=e=>!!e&&(e?.inventoryQuantity&&e.inventoryQuantity>0||!e?.manageInventory||"CONTINUE"===e.inventoryPolicy),M=a.useMemo(()=>r?t.makeStyleResponsive("w",t.makeWidth(u,c)):t.makeStyleResponsive("w",t.makeWidth(b?.width,b?.fullWidth)),[b?.width,b?.fullWidth,r,u,c]);return e.jsx("div",{className:"gp-grid gp-w-full gp-gap-y-[9px] gp-leading-[1.3]",style:{...M},children:e.jsxs("div",{className:"gp-relative",children:[e.jsx("label",{className:"!gp-max-w-[calc(100%_-_66px)] gp-absolute gp-left-[12px] gp-top-[6px] gp-p-0 gp-text-xs gp-leading-[1.3] gp-text-[#737373] gp-transition-[top]",children:e.jsx("span",{className:"gp-max-w-full",children:e.jsx("span",{className:"gp-block gp-overflow-hidden",children:x})})}),e.jsx("select",{autoComplete:"off",name:l?.name||"Select Option",className:"gp-min-h-[47px] gp-appearance-none gp-bg-transparent gp-w-full gp-whitespace-nowrap gp-rounded-[5px] gp-border gp-border-[#d9d9d9] gp-pb-[6px] gp-pl-[11px] gp-pr-[40px] gp-pt-[21px] gp-text-[14px] gp-outline-none gp-text-[#545454]",value:S??m,onChange:e=>{r?O(e.target?.value):w(l?.name,e.target?.value,N?.id)},children:e.jsxs(e.Fragment,{children:[!h&&e.jsx("option",{value:"blank",children:d??"Please select an option"}),l?.values?.map(t=>e.jsx(p.default,{value:t,optionName:l.name,optionPosition:i,optionNumber:s,isSoldOutMark:k},t?.id)),r&&o?.map(t=>e.jsx(n.default,{disabled:!q(t)&&k,value:t?.id,variant:t,includePrice:g},t?.id))]})}),e.jsx("div",{className:"gp-pointer-events-none gp-absolute gp-right-[2px] gp-top-[50%] gp-flex gp-h-[43%] gp-w-[40px] gp-translate-y-[-50%] gp-items-center gp-justify-center gp-border-l-[1px] gp-bg-white gp-border-[#545454]",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",focusable:"false","aria-hidden":"true",role:"presentation",className:"gp-h-[10px] gp-w-[10px]",children:e.jsx("path",{d:"M0 5h20L10 15"})})})]})})};
