import{useProductBundleDiscount as e}from"@gem-sdk/core";import{useState as t,useCallback as r,useEffect as l}from"react";let useProductBundleDiscountState=c=>{let[a,u]=t(0),{seUseProductCompareAtPrice:s}=e(),[m,o]=t(c?.hasPreSelectItem?c?.selectItemDefault:-1),P=r(e=>m===e,[m]);return l(()=>{s(c?.useProductCompareAtPrice)},[s,c?.useProductCompareAtPrice]),l(()=>{c?.hasPreSelectItem||o(-1)},[c?.hasPreSelectItem]),l(()=>{c?.hasPreSelectItem&&o(c?.selectItemDefault)},[c?.hasPreSelectItem,c?.selectItemDefault]),l(()=>{let e;return a<10&&(e=setInterval(()=>{u(e=>e+1)},100)),()=>clearInterval(e)},[a]),{timer:a,isSelected:P,setSelected:o}};export{useProductBundleDiscountState as default};
