import{useProductStore as e,usePageStore as t,useProduct as r,useVariants as n}from"@gem-sdk/core";import{useMemo as s}from"react";import{checkDefaultVariant as i}from"../../../product/helpers/product.js";import{useBuyerConsentChecked as o}from"../../buyer-consent/hooks/useBuyerConsentChecked.js";import{useSubscriptionSellingType as l}from"./useSubscriptionSellingType.js";let useSubscriptionConsentCheck=()=>{let{checked:u}=o(),p=e(e=>e.selectedOptions),{isOneTime:c}=l(),m=t(e=>e.getSubscriptionVisible()),d=r(),g=n(),f=s(()=>{let e=!m?.[d?.id??""]?.length;if(u||c||e)return!1;let t=!!d?.sellingPlanGroups?.length||!!d?.variants?.edges.find(e=>!!e.node?.sellingPlanGroups?.length);if(!t||!p)return!1;let r=i(d);if(!r){let e=g.find(e=>e?.selectedOptions.every(e=>p[e.name??""]===e.value)),t=!!e?.sellingPlanGroups?.length;return t}return!0},[p,c,u,d,g]);return{isDisableAccept:f}};export{useSubscriptionConsentCheck};
