import{useInteraction as e}from"@gem-sdk/core";let useVariantInteraction=t=>{let{element:n,uid:r}=t,{trigger:o}=e(),a=(e,t)=>{n.current&&(o({event:"gp:rollback:item-selected",selector:`[data-id="${r}"]`,element:n.current}),o({event:"gp:item-selected",selector:`[data-id="${r}"]`,data:{selectedOptions:e,inStock:t},element:n.current}))},d=(e,t)=>{let n=()=>{a(e,t),window.removeEventListener("gp:flow-actions-loaded",n)};window.interactionLoaded?a(e,t):window.addEventListener("gp:flow-actions-loaded",n)};return{dispatchInteractionChangeOptions:a,dispatchInteractionChangeOptionsInit:d}};export{useVariantInteraction};
