'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../hooks/useStockCounterInteraction.js"),r=require("@gem-sdk/system"),l=require("../hooks/useStockCounter.js"),a=require("../common/helpers.js"),c=require("../common/classes.js"),n=require("../common/styles.js"),o=require("../common/attrs.js");exports.default=({setting:i,styles:u,builderProps:m})=>{let{displayProgressBar:y,borderRadius:d}=u??{},{showIcon:g,icon:C,layout:S="full",oosIcon:j}=i??{},{outputMessage:p,isOutOfStock:x,inventoryQuantity:I,shouldHideCounter:h}=l.useStockCounter(i,u),N=s.useRef(null),{dispatchStockCounterInteraction:_}=t.useStockCounterInteraction({element:N,uid:m?.uid}),f=a.getInlineCss(m?.uid,d),k=!1!==y&&!x,q=r.createClass({...c.getProgressBarClasses(u)}),v=r.createStyle({...n.getProgressBarStyles(u,i)}),O=r.createStyle({...n.getContainerStyles(u)}),T=r.createClass({...c.getContainerClasses(i)}),M=r.createStyle({...n.getWrapperStyles(u)}),b=r.createClass({...c.getWrapperIconClasses(i)}),A=r.createClass({...c.getIconClasses()}),H=r.createClass({...c.getOuterIconClasses()}),L=e=>r.createStyle({...n.getIconStyles(u,i,e)}),W=({isOutOfStockIcon:e,isVisible:s})=>r.createAttr({...o.getIconAttrs(e,s)}),P=r.createClass({...c.getTextClasses(u)}),B=e=>r.createStyle({...n.getTextStyles(u,e)}),V=r.createClass({...c.getWrapperClasses(i,x)}),E=r.createAttr({...o.getWrapperAttrs(m)});return(s.useEffect(()=>{_(I)},[I]),h)?null:e.jsxs("div",{...E,style:M,ref:N,className:V,children:[e.jsx("style",{children:f}),e.jsxs("div",{className:T,style:O,children:[e.jsxs("div",{className:b,children:[g&&(x?e.jsx("div",{...W({isOutOfStockIcon:x,isVisible:x}),style:L(!0),className:H,children:e.jsx("span",{className:A,dangerouslySetInnerHTML:{__html:j||""}})}):e.jsx("div",{...W({isOutOfStockIcon:!x,isVisible:!x}),style:L(!1),className:H,children:e.jsx("span",{className:A,dangerouslySetInnerHTML:{__html:C||""}})})),"progress-bar"!==S&&(x?e.jsx("p",{dangerouslySetInnerHTML:{__html:p()},className:P,style:B(!0)}):e.jsx("p",{dangerouslySetInnerHTML:{__html:p()},className:P,style:B(!1)}))]}),k&&e.jsx("div",{style:v,className:q})]})]})};
