"use strict";var core=require("@gem-sdk/core");const useVariantInteraction=e=>{let{element:t,uid:n}=e,{trigger:r}=core.useInteraction(),a=(e,a)=>{t.current&&(r({event:"gp:rollback:item-selected",selector:`[data-id="${n}"]`,element:t.current}),r({event:"gp:item-selected",selector:`[data-id="${n}"]`,data:{selectedOptions:e,inStock:a},element:t.current}))},o=(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:o}};exports.useVariantInteraction=useVariantInteraction;
